From 533e072a592826df53b90491bcaa606dfddaf646 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 21 Jun 2012 19:43:59 +0200 Subject: NEWT: Add virtual on-screen keyboard visibility interface methods incl. Android implementation. Note: Currently only w/ Android implementation. Note: On Android there is no way to reliably be notified of the current keyboard state. It would be best, if your code does not rely on this information Window adds: - setKeyboardVisible(boolean) - isKeyboardVisible() // unreliable on Android --- src/newt/classes/com/jogamp/newt/Window.java | 35 ++++++++++++--- .../classes/com/jogamp/newt/opengl/GLWindow.java | 8 ++++ src/newt/classes/jogamp/newt/WindowImpl.java | 35 ++++++++++++++- .../jogamp/newt/driver/android/AndroidWindow.java | 50 ++++++++++++++++++++++ 4 files changed, 119 insertions(+), 9 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 3c5441bf7..136c19ff8 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -106,11 +106,11 @@ public interface Window extends NativeWindow, WindowClosingProtocol { void destroy(); /** - *

* setVisible makes the window and children visible if visible is true, - * otherwise the window and children becomes invisible.

+ * otherwise the window and children becomes invisible. *

- * The setVisible(true) is responsible to actual create the native window.

+ * The setVisible(true) is responsible to actual create the native window. + *

*

* Zero size semantics are respected, see {@link #setSize(int,int)}:
*

@@ -125,10 +125,11 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
      * }
      * 

*

- * In case this window is a child window and a parent {@link javax.media.nativewindow.NativeWindow} is being used,
- * the parent's {@link javax.media.nativewindow.NativeWindow} handle is retrieved via {@link javax.media.nativewindow.NativeWindow#getWindowHandle()}.
- * If this action fails, ie if the parent {@link javax.media.nativewindow.NativeWindow} is not valid yet,
- * no native window is created yet and setVisible(true) shall be repeated when it is.

+ * In case this window is a child window and has a {@link javax.media.nativewindow.NativeWindow} parent,
+ * setVisible(true) has no effect as long the parent's is not valid yet, + * i.e. {@link javax.media.nativewindow.NativeWindow#getWindowHandle()} returns null.
+ * setVisible(true) shall be repeated when the parent becomes valid. + *

*/ void setVisible(boolean visible); @@ -399,7 +400,27 @@ public interface Window extends NativeWindow, WindowClosingProtocol { // KeyListener // + /** + * In case the platform supports or even requires a virtual on-screen keyboard, + * this method shows or hide it depending on whether visible is true + * or false. + *

+ * One known platform where NEWT supports this feature is Android. + *

+ */ + void setKeyboardVisible(boolean visible); + /** + * Return true if the virtual on-screen keyboard is visible, otherwise false. + *

+ * Currently on Android, the only supported platform right now, + * there is no way to reliably be notified of the current keyboard state.
+ * It would be best, if your code does not rely on this information. + *

+ * @see #setKeyboardVisible(boolean) + */ + boolean isKeyboardVisible(); + /** * * Appends the given {@link com.jogamp.newt.event.KeyListener} to the end of diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index f89193754..a3adf5090 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -790,6 +790,14 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC window.addWindowListener(index, l); } + public final void setKeyboardVisible(boolean visible) { + window.setKeyboardVisible(visible); + } + + public final boolean isKeyboardVisible() { + return window.isKeyboardVisible(); + } + public final void addKeyListener(KeyListener l) { window.addKeyListener(l); } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 074f635e4..68a2430f7 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -303,6 +303,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer setTitleImpl(title); setPointerVisibleImpl(pointerVisible); confinePointerImpl(pointerConfined); + setKeyboardVisible(keyboardVisible); if(waitForVisible(true, false)) { if(isFullscreen()) { synchronized(fullScreenAction) { @@ -2182,6 +2183,36 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer addKeyListener(-1, l); } + public final void setKeyboardVisible(boolean visible) { + if(isNativeValid()) { + // We don't skip the impl. if it seems that there is no state change, + // since we cannot assume the impl. reliably gives us it's current state. + final boolean n = setKeyboardVisibleImpl(visible); + if(DEBUG_IMPLEMENTATION || DEBUG_KEY_EVENT) { + System.err.println("setKeyboardVisible(native): visible "+keyboardVisible+" -> "+visible +" -> "+n); + } + keyboardVisible = n; + } else { + keyboardVisible = visible; // earmark for creation + } + } + public final boolean isKeyboardVisible() { + return keyboardVisible; + } + protected boolean setKeyboardVisibleImpl(boolean visible) { + return false; // nop + } + /** Triggered by implementation's WM events to update the virtual on-screen keyboard's visibility state. */ + protected void keyboardVisibilityChanged(boolean visible) { + if(keyboardVisible != visible) { + if(DEBUG_IMPLEMENTATION || DEBUG_KEY_EVENT) { + System.err.println("keyboardVisibilityChanged: "+keyboardVisible+" -> "+visible); + } + keyboardVisible = visible; + } + } + protected boolean keyboardVisible = false; + public void addKeyListener(int index, KeyListener l) { if(l == null) { return; @@ -2356,8 +2387,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer enqueueWindowEvent(false, evt); } } - } - + } + /** Triggered by implementation's WM events to update the visibility state. */ protected void visibleChanged(boolean defer, boolean visible) { if(this.visible != visible) { diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java index 63d5f7003..73192a07f 100644 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java +++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java @@ -48,10 +48,14 @@ import jogamp.opengl.egl.EGLGraphicsConfigurationFactory; import android.content.Context; import android.graphics.PixelFormat; +import android.os.Bundle; +import android.os.IBinder; +import android.os.ResultReceiver; import android.util.Log; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceHolder.Callback2; +import android.view.inputmethod.InputMethodManager; import android.view.SurfaceView; import android.view.View; @@ -316,6 +320,52 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { // nop .. } + //---------------------------------------------------------------------- + // Virtual On-Screen Keyboard / SoftInput + // + + private class KeyboardVisibleReceiver extends ResultReceiver { + public KeyboardVisibleReceiver() { + super(null); + } + + @Override + public void onReceiveResult(int r, Bundle data) { + boolean v = false; + + switch(r) { + case InputMethodManager.RESULT_UNCHANGED_SHOWN: + case InputMethodManager.RESULT_SHOWN: + v = true; + break; + case InputMethodManager.RESULT_HIDDEN: + case InputMethodManager.RESULT_UNCHANGED_HIDDEN: + v = false; + break; + } + Log.d(MD.TAG, "keyboardVisible: "+v); + keyboardVisibilityChanged(v); + } + } + private KeyboardVisibleReceiver keyboardVisibleReceiver = new KeyboardVisibleReceiver(); + + protected final boolean setKeyboardVisibleImpl(boolean visible) { + if(null != androidView) { + final InputMethodManager imm = (InputMethodManager) getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + final IBinder winid = getAndroidView().getWindowToken(); + if(visible) { + // Show soft-keyboard: + imm.showSoftInput(androidView, 0, keyboardVisibleReceiver); + } else { + // hide keyboard : + imm.hideSoftInputFromWindow(winid, 0, keyboardVisibleReceiver); + } + return visible; + } else { + return false; // nop + } + } + //---------------------------------------------------------------------- // Surface Callbacks // -- cgit v1.2.3 From a393e45613d87101dbb13763df263c2f9291d2d0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 26 Jun 2012 10:44:08 +0200 Subject: Implement Bug #598 - JOGL ALL JAR File Change incl. it's Native Jar URL Derivation - Depends on GlueGen commit 9a71703904ebfec343fb2c7266343d37a2e4c3db JAR file name changes: ALL JARs: - jogl.all.jar -> jogl-all.jar - jogl.all-noawt.jar -> jogl-all-noawt.jar - jogl.all-mobile.jar -> jogl-all-mobile.jar - jogl.all-android.jar -> jogl-all-android.jar - jogl.all-android.apk -> jogl-all-android.apk Atomic JARs: - nativewindow.core.jar -> nativewindow-core.jar - nativewindow.awt.jar -> nativewindow-awt.jar - nativewindow.os.x11.jar -> nativewindow-os-x11.jar - nativewindow.os.win.jar -> nativewindow-os-win.jar - nativewindow.os.macosx.jar -> nativewindow-os-osx.jar - jogl.core.jar -> jogl-core.jar - jogl.sdk.jar -> jogl-sdk.jar - jogl.glmobile.jar -> jogl-glmobile.jar - jogl.glmobile.dbg.jar -> jogl-glmobile-dbg.jar - jogl.util.jar -> jogl-util.jar - jogl.glutess.jar -> jogl-glutess.jar - jogl.glumipmap.jar -> jogl-glumipmap.jar - jogl.util.fixedfuncemu.jar -> jogl-util-fixedfuncemu.jar - jogl.awt.jar -> jogl-awt.jar - jogl.swt.jar -> jogl-swt.jar - jogl.util.awt.jar -> jogl-util-awt.jar - jogl.os.x11.jar -> jogl-os-x11.jar - jogl.os.win.jar -> jogl-os-win.jar - jogl.os.osx.jar -> jogl-os-osx.jar - jogl.os.android.jar -> jogl-os-android.jar - jogl.gldesktop.jar -> jogl-gldesktop.jar - jogl.gldesktop.dbg.jar -> jogl-gldesktop-dbg.jar - jogl.glugldesktop.jar -> jogl-glu-gldesktop.jar - jogl.util.gldesktop.jar -> jogl-util-gldesktop.jar - jogl.omx.jar -> jogl-omx.jar - jogl.cg.jar -> jogl-cg.jar - newt.core.jar -> newt-core.jar - newt.ogl.jar -> newt-ogl.jar - newt.awt.jar -> newt-awt.jar - newt.event.jar -> newt-event.jar - newt.driver.x11.jar -> newt-driver-x11.jar - newt.driver.win.jar -> newt-driver-win.jar - newt.driver.macosx.jar -> newt-driver-osx.jar - newt.driver.android.jar -> newt-driver-android.jar - newt.driver.kd.jar -> newt-driver-kd.jar - newt.driver.intelgdl.jar -> newt-driver-intelgdl.jar - newt.driver.broadcomegl.jar -> newt-driver-broadcomegl.jar Test JARs: - jogl.test.jar -> jogl-test.jar - jogl.test-android.jar -> jogl-test-android.jar - jogl.test-android.apk -> jogl-test-android.apk --- etc/profile.jogl | 14 +- jnlp-files/atomic/jogl-awt.jnlp | 54 ++-- jnlp-files/atomic/jogl-noawt.jnlp | 50 ++-- jnlp-files/atomic/nativewindow-awt.jnlp | 19 +- jnlp-files/atomic/nativewindow-noawt.jnlp | 30 ++- jnlp-files/atomic/newt-awt-jogl.jnlp | 36 +-- jnlp-files/atomic/newt-awt.jnlp | 34 +-- jnlp-files/atomic/newt-noawt-jogl.jnlp | 36 +-- jnlp-files/atomic/newt-noawt.jnlp | 30 +-- jnlp-files/jogl-all-awt-cg.jnlp | 36 +-- jnlp-files/jogl-all-awt.jnlp | 2 +- jnlp-files/jogl-all-mobile.jnlp | 2 +- jnlp-files/jogl-all-noawt.jnlp | 2 +- ...nner-newt-ElektronenMultiplizierer-napplet.html | 8 +- ...pplet-runner-newt-ElektronenMultiplizierer.html | 8 +- ...applet-runner-newt-GraphTextDemo01-napplet.html | 8 +- .../jogl-applet-runner-newt-GraphTextDemo01.html | 8 +- ...let-runner-newt-GraphUISceneDemo01-napplet.html | 8 +- ...jogl-applet-runner-newt-GraphUISceneDemo01.html | 8 +- .../jogl-applet-runner-newt-MovieCube-napplet.html | 8 +- jnlp-files/jogl-applet-runner-newt-MovieCube.html | 8 +- ...plet-runner-newt-gears-normal-launcheronly.html | 16 +- ...gl-applet-runner-newt-gears-normal-napplet.html | 18 +- ...l-applet-runner-newt-gears-normal-napplet2.html | 18 +- .../jogl-applet-runner-newt-gears-normal.html | 20 +- ...l-applet-runner-newt-gears-special-napplet.html | 8 +- .../jogl-applet-runner-newt-gears-special.html | 8 +- jnlp-files/jogl-applet-runner-newt.jnlp | 2 +- jnlp-files/jogl-applet-version-lancheronly.html | 4 +- jnlp-files/jogl-applet-version-napplet.html | 8 +- jnlp-files/jogl-applet-version.html | 4 +- make/build-common.xml | 287 +++++++++++---------- make/build-jogl.xml | 50 ++-- make/build-nativewindow.xml | 10 +- make/build-newt.xml | 22 +- make/build-test.xml | 14 +- make/build.xml | 18 +- make/scripts/setenv-jogl.sh | 4 +- make/scripts/tests.sh | 16 +- .../opengl/cg/CgDynamicLibraryBundleInfo.java | 4 +- src/jogl/classes/javax/media/opengl/GLProfile.java | 28 +- .../jogamp/nativewindow/NWJNILibLoader.java | 4 +- src/newt/classes/jogamp/newt/NEWTJNILibLoader.java | 7 +- 43 files changed, 511 insertions(+), 468 deletions(-) (limited to 'src/newt/classes') diff --git a/etc/profile.jogl b/etc/profile.jogl index 1177aaa49..4402adde6 100755 --- a/etc/profile.jogl +++ b/etc/profile.jogl @@ -30,12 +30,12 @@ uname -a | grep -i LINUX && OSS=x11 uname -a | grep -i Darwin && OSS=osx uname -a | grep -i CYGWIN && OSS=win -JOGL_TEST="jogl.test.jar" +JOGL_TEST="jogl-test.jar" -JOGL_JAR_ALL="jogl.all.jar" -JOGL_JAR_ALL_NOAWT="jogl.all-noawt.jar" -JOGL_JAR_ALL_MOBILE="jogl.all-mobile.jar" -JOGL_JAR_SWT="atomic/jogl.swt.jar" +JOGL_JAR_ALL="jogl-all.jar" +JOGL_JAR_ALL_NOAWT="jogl-all-noawt.jar" +JOGL_JAR_ALL_MOBILE="jogl-all-mobile.jar" +JOGL_JAR_SWT="atomic/jogl-swt.jar" JOGL_LIB_ALL="libnativewindow_x11.so libnativewindow_awt.so libjogl_desktop.so libjogl_mobile.so libjogl_cg.so libnewt.so" JOGL_LIB_ALL_NOAWT="libnativewindow_x11.so libjogl_desktop.so libjogl_mobile.so libjogl_cg.so libnewt.so" @@ -76,8 +76,8 @@ export JOGL_LIB_DIR JOGL_ALL_AWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL $JOGL_TEST) JOGL_ALL_NOAWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL_NOAWT $JOGL_TEST) -JOGL_MOBILE_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL_MOBILE) -JOGL_SWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_SWT) +JOGL_MOBILE_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL_MOBILE $JOGL_TEST) +JOGL_SWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_SWT $JOGL_TEST) export JOGL_ALL_AWT_CLASSPATH JOGL_ALL_NOAWT_CLASSPATH JOGL_MOBILE_CLASSPATH JOGL_SWT_CLASSPATH if [ ! -z "$JOGL_PROFILE" ] ; then diff --git a/jnlp-files/atomic/jogl-awt.jnlp b/jnlp-files/atomic/jogl-awt.jnlp index a33eb35a6..8f15a6c58 100644 --- a/jnlp-files/atomic/jogl-awt.jnlp +++ b/jnlp-files/atomic/jogl-awt.jnlp @@ -14,83 +14,83 @@ - - - - - - - - - - - + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/jnlp-files/atomic/jogl-noawt.jnlp b/jnlp-files/atomic/jogl-noawt.jnlp index 3463a1965..91a1fe89b 100644 --- a/jnlp-files/atomic/jogl-noawt.jnlp +++ b/jnlp-files/atomic/jogl-noawt.jnlp @@ -14,81 +14,81 @@ - - - - - - - - - + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/jnlp-files/atomic/nativewindow-awt.jnlp b/jnlp-files/atomic/nativewindow-awt.jnlp index db80b644f..a993ab14a 100644 --- a/jnlp-files/atomic/nativewindow-awt.jnlp +++ b/jnlp-files/atomic/nativewindow-awt.jnlp @@ -14,57 +14,72 @@ - - + + + + + + + + + + + + + + + + + diff --git a/jnlp-files/atomic/nativewindow-noawt.jnlp b/jnlp-files/atomic/nativewindow-noawt.jnlp index fed731042..5cd4872dc 100644 --- a/jnlp-files/atomic/nativewindow-noawt.jnlp +++ b/jnlp-files/atomic/nativewindow-noawt.jnlp @@ -14,68 +14,72 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + diff --git a/jnlp-files/atomic/newt-awt-jogl.jnlp b/jnlp-files/atomic/newt-awt-jogl.jnlp index 69406e43c..0a43128bb 100644 --- a/jnlp-files/atomic/newt-awt-jogl.jnlp +++ b/jnlp-files/atomic/newt-awt-jogl.jnlp @@ -14,50 +14,50 @@ - - - + + + - + - + - + - + - + - + - + - + - + - + @@ -65,23 +65,23 @@ - + - + - + - + - + diff --git a/jnlp-files/atomic/newt-awt.jnlp b/jnlp-files/atomic/newt-awt.jnlp index 26e45e3fc..6e46b82a4 100644 --- a/jnlp-files/atomic/newt-awt.jnlp +++ b/jnlp-files/atomic/newt-awt.jnlp @@ -14,71 +14,73 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + + + - + - + diff --git a/jnlp-files/atomic/newt-noawt-jogl.jnlp b/jnlp-files/atomic/newt-noawt-jogl.jnlp index ced8b29c7..5b671edcd 100644 --- a/jnlp-files/atomic/newt-noawt-jogl.jnlp +++ b/jnlp-files/atomic/newt-noawt-jogl.jnlp @@ -14,73 +14,73 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/jnlp-files/atomic/newt-noawt.jnlp b/jnlp-files/atomic/newt-noawt.jnlp index 1616dff88..1161d7a9c 100644 --- a/jnlp-files/atomic/newt-noawt.jnlp +++ b/jnlp-files/atomic/newt-noawt.jnlp @@ -14,56 +14,56 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -73,11 +73,11 @@ - + - + diff --git a/jnlp-files/jogl-all-awt-cg.jnlp b/jnlp-files/jogl-all-awt-cg.jnlp index 18f8f498e..24c22c290 100644 --- a/jnlp-files/jogl-all-awt-cg.jnlp +++ b/jnlp-files/jogl-all-awt-cg.jnlp @@ -14,75 +14,75 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/jnlp-files/jogl-all-awt.jnlp b/jnlp-files/jogl-all-awt.jnlp index 55ae21d2a..4e05f8dac 100644 --- a/jnlp-files/jogl-all-awt.jnlp +++ b/jnlp-files/jogl-all-awt.jnlp @@ -14,7 +14,7 @@ - + diff --git a/jnlp-files/jogl-all-mobile.jnlp b/jnlp-files/jogl-all-mobile.jnlp index 5f96137c2..43b9b3b09 100644 --- a/jnlp-files/jogl-all-mobile.jnlp +++ b/jnlp-files/jogl-all-mobile.jnlp @@ -14,7 +14,7 @@ - + diff --git a/jnlp-files/jogl-all-noawt.jnlp b/jnlp-files/jogl-all-noawt.jnlp index 63f558d38..eed6749c1 100644 --- a/jnlp-files/jogl-all-noawt.jnlp +++ b/jnlp-files/jogl-all-noawt.jnlp @@ -14,7 +14,7 @@ - + diff --git a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html index 3b77157c6..19a3b2965 100644 --- a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html @@ -14,8 +14,8 @@ Demoscene Passivist's Elektronen-Multiplizierer width="640" height="480"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -28,8 +28,8 @@ Demoscene Passivist's Elektronen-Multiplizierer type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.ElektronenMultiplizierer" diff --git a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html index 2a500c9e6..71c9baff8 100644 --- a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html +++ b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html @@ -15,8 +15,8 @@ Demoscene Passivist's Elektronen-Multiplizierer + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -38,8 +38,8 @@ Demoscene Passivist's Elektronen-Multiplizierer pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="ElektronenMultiplizierer" diff --git a/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01-napplet.html b/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01-napplet.html index 59115ca36..9648b57da 100644 --- a/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01-napplet.html @@ -14,8 +14,8 @@ JOGL Graph Text Demo 01 width="800" height="400"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -31,8 +31,8 @@ JOGL Graph Text Demo 01 type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.graph.demos.GPUTextGLListener0A" gl_profile="GL2ES2" diff --git a/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01.html b/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01.html index 1c7d3472b..489984b4f 100644 --- a/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01.html +++ b/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01.html @@ -15,8 +15,8 @@ JOGL Graph Text Demo 01 + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -41,8 +41,8 @@ JOGL Graph Text Demo 01 pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL Graph Text Demo01" diff --git a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html index 6efeefc10..8f9783f03 100644 --- a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html @@ -14,8 +14,8 @@ JOGL Graph UI-Scene Demo 01 width="640" height="480"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -30,8 +30,8 @@ JOGL Graph UI-Scene Demo 01 type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.graph.demos.GPUUISceneGLListener0A" gl_profile="GL2ES2" diff --git a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html index 6b32b11e7..429e80311 100644 --- a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html +++ b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html @@ -15,8 +15,8 @@ JOGL Graph UI-Scene Demo 01 + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -40,8 +40,8 @@ JOGL Graph UI-Scene Demo 01 pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL Graph UI Demo01" diff --git a/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html b/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html index def7b72b9..f569c7c96 100644 --- a/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html @@ -14,8 +14,8 @@ JogAmp's MovieCube - GLMediaPlayer Demo 01 width="510" height="300"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -28,8 +28,8 @@ JogAmp's MovieCube - GLMediaPlayer Demo 01 type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube" diff --git a/jnlp-files/jogl-applet-runner-newt-MovieCube.html b/jnlp-files/jogl-applet-runner-newt-MovieCube.html index 6b1654ed7..7cb00244e 100644 --- a/jnlp-files/jogl-applet-runner-newt-MovieCube.html +++ b/jnlp-files/jogl-applet-runner-newt-MovieCube.html @@ -15,8 +15,8 @@ JogAmp's MovieCube - GLMediaPlayer Demo 01 + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -38,8 +38,8 @@ JogAmp's MovieCube - GLMediaPlayer Demo 01 pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="MovieCube" diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html b/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html index 91e989346..a9e42d342 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html @@ -21,8 +21,8 @@ JOGL NEWT JNLP Applet Runner Special Keys:
+ jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -43,8 +43,8 @@ JOGL NEWT JNLP Applet Runner Special Keys:
pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL GearsES2 Applet" @@ -75,8 +75,8 @@ The applet above is instantiated with the following code: <param name="code" value="org.jdesktop.applet.util.JNLPAppletLauncher"> <param name="archive" value="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar"> + jar/jogl-all.jar, + jar/jogl-test.jar"> <param name="codebase_lookup" value="false"> <param name="subapplet.classname" value="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run"> <param name="subapplet.displayname" value="JOGL GearsES2 Applet"> @@ -97,8 +97,8 @@ The applet above is instantiated with the following code: pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL GearsES2 Applet" diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html index 9db6d8cc2..37473befe 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html @@ -20,8 +20,8 @@ JOGL NEWT Applet Runner Special Keys:
width="200" height="200"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -34,8 +34,8 @@ JOGL NEWT Applet Runner Special Keys:
type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2" gl_profile="GL2ES2" @@ -58,8 +58,8 @@ The applet above is instantiated with the following code: width="200" height="200"> <param name="code" value="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run"> <param name="archive" value="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar"> + jar/jogl-all.jar, + jar/jogl-test.jar"> <param name="java_arguments" value="-Dsun.java2d.noddraw=true"> <param name="gl_event_listener_class" value="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2"> <param name="gl_profile" value="GL2ES2"> @@ -72,8 +72,8 @@ The applet above is instantiated with the following code: type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2" gl_profile="GL2ES2" @@ -90,7 +90,7 @@ The applet above is instantiated with the following code:

-Note that the jogl.test.jar, which contains the test applet class, +Note that the jogl-test.jar, which contains the test applet class, does not need to be signed! JogAmp Community signs jogl.jar and gluegen-rt.jar, which contain JOGL's supporting classes; this is the only diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html index ba2f69ef4..63df4ed60 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html @@ -21,8 +21,8 @@ If Applet is out of browser window, it is closeable. width="200" height="200"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -36,8 +36,8 @@ If Applet is out of browser window, it is closeable. type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2" gl_profile="GL2ES2" @@ -61,8 +61,8 @@ The applet above is instantiated with the following code: width="200" height="200"> <param name="code" value="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run"> <param name="archive" value="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar"> + jar/jogl-all.jar, + jar/jogl-test.jar"> <param name="java_arguments" value="-Dsun.java2d.noddraw=true"> <param name="gl_event_listener_class" value="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2"> <param name="gl_profile" value="GL2ES2"> @@ -76,8 +76,8 @@ The applet above is instantiated with the following code: type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2" gl_profile="GL2ES2" @@ -95,7 +95,7 @@ The applet above is instantiated with the following code:

-Note that the jogl.test.jar, which contains the test applet class, +Note that the jogl-test.jar, which contains the test applet class, does not need to be signed! JogAmp Community signs jogl.jar and gluegen-rt.jar, which contain JOGL's supporting classes; this is the only diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal.html b/jnlp-files/jogl-applet-runner-newt-gears-normal.html index c8d654dbc..a6dd16a0c 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal.html @@ -35,8 +35,8 @@ JOGL NEWT JNLP Applet Runner Special Keys:
+ jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -58,8 +58,8 @@ JOGL NEWT JNLP Applet Runner Special Keys:
pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL GearsES2 Applet" @@ -91,8 +91,8 @@ The applet above is instantiated with the following code: <param name="code" value="org.jdesktop.applet.util.JNLPAppletLauncher"> <param name="archive" value="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar"> + jar/jogl-all.jar, + jar/jogl-test.jar"> <param name="codebase_lookup" value="false"> <param name="subapplet.classname" value="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run"> <param name="subapplet.displayname" value="JOGL GearsES2 Applet"> @@ -114,8 +114,8 @@ The applet above is instantiated with the following code: pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL GearsES2 Applet" @@ -154,7 +154,7 @@ Where the referenced JNLP file jogl-applet-runner-newt.jnlp looks as fo <resources> <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/> <property name="sun.java2d.noddraw" value="true"/> - <jar href="jar/jogl.test.jar" main="true"/> + <jar href="jar/jogl-test.jar" main="true"/> <extension name="jogl-all-awt" href="http://jogamp.org/deployment/jogamp-current/jogl-all-awt.jnlp" /> </resources> @@ -170,7 +170,7 @@ Where the referenced JNLP file jogl-applet-runner-newt.jnlp looks as fo

-Note that the jogl.test.jar, which contains the test applet class, +Note that the jogl-test.jar, which contains the test applet class, does not need to be signed! JogAmp Community signs applet-launcher.jar, jogl.jar and gluegen-rt.jar, which contain the JNLPAppletLauncher and JOGL's supporting classes; this is the only diff --git a/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html b/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html index 3c1895b45..7df167844 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html @@ -11,8 +11,8 @@ JOGL NEWT JNLP Applet Runner Special Keys: width="1" height="1"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -32,8 +32,8 @@ JOGL NEWT JNLP Applet Runner Special Keys: type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2" gl_profile="GL2ES2" diff --git a/jnlp-files/jogl-applet-runner-newt-gears-special.html b/jnlp-files/jogl-applet-runner-newt-gears-special.html index dcbe898e2..0f5911414 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-special.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-special.html @@ -12,8 +12,8 @@ JOGL NEWT JNLP Applet Runner Special Keys: + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -42,8 +42,8 @@ JOGL NEWT JNLP Applet Runner Special Keys: pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL GearsES2 Applet Transparent" diff --git a/jnlp-files/jogl-applet-runner-newt.jnlp b/jnlp-files/jogl-applet-runner-newt.jnlp index 259e39f18..c33e1b761 100644 --- a/jnlp-files/jogl-applet-runner-newt.jnlp +++ b/jnlp-files/jogl-applet-runner-newt.jnlp @@ -12,7 +12,7 @@ - + diff --git a/jnlp-files/jogl-applet-version-lancheronly.html b/jnlp-files/jogl-applet-version-lancheronly.html index 685d9115c..6880152fc 100644 --- a/jnlp-files/jogl-applet-version-lancheronly.html +++ b/jnlp-files/jogl-applet-version-lancheronly.html @@ -20,7 +20,7 @@ and your platform. + jar/jogl-all.jar"> @@ -36,7 +36,7 @@ and your platform. pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar" + jar/jogl-all.jar" codebase_lookup" value="false" subapplet.classname="jogamp.opengl.awt.VersionApplet" subapplet.displayname="JOGL Applet Version" diff --git a/jnlp-files/jogl-applet-version-napplet.html b/jnlp-files/jogl-applet-version-napplet.html index e8104cb60..aeccb710a 100644 --- a/jnlp-files/jogl-applet-version-napplet.html +++ b/jnlp-files/jogl-applet-version-napplet.html @@ -16,7 +16,7 @@ and your platform. width="800" height="600"> + jar/jogl-all.jar"> Sorry, no Java support detected. @@ -41,7 +41,7 @@ The applet above is instantiated with the following code: width="800" height="600"> <param name="code" value="jogamp.opengl.awt.VersionApplet"> <param name="archive" value="jar/gluegen-rt.jar, - jar/jogl.all.jar"> + jar/jogl-all.jar"> <param name="java_arguments" value="-Dsun.java2d.noddraw=true"> <comment> <embed code="jogamp.opengl.awt.VersionApplet" @@ -49,7 +49,7 @@ The applet above is instantiated with the following code: type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar" + jar/jogl-all.jar" java_arguments="-Dsun.java2d.noddraw=true"> <noembed>Sorry, no Java support detected.</noembed> </embed> diff --git a/jnlp-files/jogl-applet-version.html b/jnlp-files/jogl-applet-version.html index 5b738964e..948e63095 100644 --- a/jnlp-files/jogl-applet-version.html +++ b/jnlp-files/jogl-applet-version.html @@ -22,7 +22,7 @@ otherwise it shall fallback to + jar/jogl-all.jar"> @@ -39,7 +39,7 @@ otherwise it shall fallback to pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar" + jar/jogl-all.jar" codebase_lookup" value="false" subapplet.classname="jogamp.opengl.awt.VersionApplet" subapplet.displayname="JOGL Applet Version" diff --git a/make/build-common.xml b/make/build-common.xml index 93835e0f1..b2885c8af 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -250,167 +250,168 @@ - - - - - + + + + + - - - - - + + + + + - - - - + + + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - + ${jogl-core.jar} ${jogl-glutess.jar} ${jogl-glumipmap.jar} ${jogl-glu-gldesktop.jar} ${jogl-os-x11.jar} ${jogl-os-win.jar} ${jogl-os-osx.jar} ${jogl-gldesktop.jar} ${jogl-gldesktop-dbg.jar} ${jogl-glmobile.jar} ${jogl-glmobile-dbg.jar} ${jogl-omx.jar} ${jogl-util.jar} ${jogl-util-gldesktop.jar} ${jogl-util-awt.jar} ${jogl-util-fixedfuncemu.jar} ${jogl-sdk.jar} --> + + + + + + + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - + + + + - - - + + + - - - + + + - + - - - - + + + + @@ -477,7 +478,7 @@ - + @@ -486,12 +487,12 @@ - - + + - + value="${junit.jar}${path.separator}${ant.jar}${path.separator}${ant-junit.jar}${path.separator}${gluegen-rt.jar}${path.separator}${jogl-all.jar}${path.separator}${jogl-test.jar}"/> + @@ -499,12 +500,12 @@ - - + + - + value="${junit.jar}${path.separator}${ant.jar}${path.separator}${ant-junit.jar}${path.separator}${gluegen-rt.jar}${path.separator}${jogl-all-noawt.jar}${path.separator}${jogl-test.jar}"/> + @@ -513,11 +514,11 @@ - - + + + value="${junit.jar}${path.separator}${ant.jar}${path.separator}${ant-junit.jar}${path.separator}${gluegen-rt.jar}${path.separator}${swt.jar}${path.separator}${jogl-all.jar}${path.separator}${jogl-test.jar}"/> @@ -526,13 +527,13 @@ - - + + + value="${junit.jar}${path.separator}${ant.jar}${path.separator}${ant-junit.jar}${path.separator}${gluegen-rt-android.jar}${path.separator}${jogl-all-android.jar}${path.separator}${jogl-test.jar}"/> + value="${gluegen.root}/${rootrel.build}/jogamp.android-launcher.apk${path.separator}${ant-junit-all.apk}${path.separator}${gluegen.root}/${rootrel.build}/gluegen-rt-android-${android.abi}.apk${path.separator}${jogl-all-android.apk}${path.separator}${jogl-test.apk}"/> diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 0c7328c4a..6845354f6 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1550,7 +1550,7 @@ + includes="${jogl-util.jar} ${jogl-util-fixedfuncemu.jar}" /> @@ -1570,48 +1570,48 @@ - + - + - + - + - + - + - + - + - + @@ -1619,22 +1619,22 @@ - + - + - + - + @@ -1643,50 +1643,50 @@ - + - + - + - + - + - + - + - + - + - + - + diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index 233108823..c77558d6b 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -820,7 +820,7 @@ - + @@ -828,28 +828,28 @@ - + - + - + - + diff --git a/make/build-newt.xml b/make/build-newt.xml index 695c86d19..a6be5042e 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -701,52 +701,52 @@ - + - + - + - + - + - + - + - + - + - + @@ -759,7 +759,7 @@ - + diff --git a/make/build-test.xml b/make/build-test.xml index f5437902e..51eadfebd 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -51,7 +51,7 @@ - + @@ -85,7 +85,7 @@ - + @@ -121,7 +121,7 @@ - + @@ -134,7 +134,7 @@ assetsdir="resources/assets-test" jarsrcdir="${src}/test" jarbuilddir="${jar}" - jarbasename="jogl.test-android" + jarbasename="jogl-test-android" nativebuilddir="${lib}" nativebasename="non-existing" androidmanifest.path="resources/android/AndroidManifest-test.xml" @@ -149,8 +149,8 @@ - - + + @@ -159,7 +159,7 @@ - + diff --git a/make/build.xml b/make/build.xml index 9258df0e9..23aa218b4 100644 --- a/make/build.xml +++ b/make/build.xml @@ -99,7 +99,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -120,7 +120,7 @@ - + @@ -129,7 +129,7 @@ - + @@ -147,8 +147,8 @@ - - + + @@ -158,7 +158,7 @@ assetsdir="resources/assets" jarsrcdir="${src}/jogl/classes" jarbuilddir="${jar}" - jarbasename="jogl.all-android" + jarbasename="jogl-all-android" nativebuilddir="${lib}" nativebasename="" android.abi="${android.abi}" @@ -173,12 +173,12 @@ - + - + diff --git a/make/scripts/setenv-jogl.sh b/make/scripts/setenv-jogl.sh index 2d91f278f..4067e65c9 100755 --- a/make/scripts/setenv-jogl.sh +++ b/make/scripts/setenv-jogl.sh @@ -93,8 +93,8 @@ CLASSPATH=.:$GLUEGEN_JAR:$JOGL_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS export CLASSPATH # We use TempJarCache per default now! -#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GLUEGEN_OS:$JOGL_LIB_DIR -#export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GLUEGEN_OS:$JOGL_LIB_DIR +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GLUEGEN_OS:$JOGL_LIB_DIR +export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GLUEGEN_OS:$JOGL_LIB_DIR echo JOGAMP_ALL_AWT_CLASSPATH: $CLASSPATH echo JOGAMP_ALL_NOAWT_CLASSPATH: $CLASSPATH diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 702b0dc8c..8f4237012 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -69,11 +69,11 @@ function jrun() { #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=600000" #D_ARGS="-Dnewt.debug.MainThread" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" - #D_ARGS="-Djogl.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" @@ -120,11 +120,9 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" - #D_ARGS="-Djogamp.debug.JARUtil" - #D_ARGS="-Djogamp.debug.TempFileCache" - #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.JARUtil" - #D_ARGS="-Djogamp.debug.JNILibLoader" - #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.gluegen.UseTempJarCache=false -Djogamp.debug.JARUtil" + #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" + #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" + #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.gluegen.UseTempJarCache=false" #D_ARGS="-Dnewt.test.EDTMainThread -Dnewt.debug.MainThread" #C_ARG="com.jogamp.newt.util.MainThread" #D_ARGS="-Dnewt.debug.MainThread" @@ -143,6 +141,8 @@ function jrun() { X_ARGS="-Djava.awt.headless=false $X_ARGS" else export CLASSPATH=$JOGAMP_ALL_NOAWT_CLASSPATH + #export CLASSPATH=$JOGAMP_MOBILE_CLASSPATH + #export CLASSPATH=.:$GLUEGEN_JAR:$JOGL_BUILD_DIR/jar/atomic/jogl-core.jar:$JOGL_BUILD_DIR/jar/atomic/jogl-gldesktop.jar:$JOGL_BUILD_DIR/jar/atomic/jogl-os-x11.jar:$JOGL_BUILD_DIR/jar/atomic/jogl-util.jar:$JOGL_BUILD_DIR/jar/atomic/nativewindow-core.jar:$JOGL_BUILD_DIR/jar/atomic/nativewindow-os-x11.jar:$JOGL_BUILD_DIR/jar/atomic/newt-core.jar:$JOGL_BUILD_DIR/jar/atomic/newt-driver-x11.jar:$JOGL_BUILD_DIR/jar/atomic/newt-ogl.jar:$JOGL_BUILD_DIR/jar/jogl-test.jar:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS X_ARGS="-Djava.awt.headless=true $X_ARGS" fi if [ $swton -eq 1 ] ; then @@ -332,8 +332,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* -testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01AWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java index d901096bc..d160eccff 100644 --- a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java @@ -47,8 +47,8 @@ public class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { Platform.initSingleton(); if(TempJarCache.isInitialized()) { - // Cg class and natives are available in their single atomic JAR files only - JNILibLoaderBase.addNativeJarLibs(CgDynamicLibraryBundleInfo.class, "jogl_cg", null); + // only: jogl-cg.jar -> jogl-cg-natives-.jar [atomic JAR files only] + JNILibLoaderBase.addNativeJarLibs(new Class[] { CgDynamicLibraryBundleInfo.class }, null, null ); } return null; } diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index f85c6ba23..ed457b0ea 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -37,6 +37,7 @@ package javax.media.opengl; +import jogamp.nativewindow.NWJNILibLoader; import jogamp.opengl.Debug; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.DesktopGLDynamicLookupHelper; @@ -133,11 +134,17 @@ public class GLProfile { Platform.initSingleton(); if(TempJarCache.isInitialized()) { - String[] atomicNativeJarBaseNames = new String[] { "nativewindow", "jogl", null }; - if( ReflectionUtil.isClassAvailable("com.jogamp.newt.NewtFactory", GLProfile.class.getClassLoader()) ) { - atomicNativeJarBaseNames[2] = "newt"; + final ClassLoader cl = GLProfile.class.getClassLoader(); + // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-.jar + // or: nativewindow-core.jar -> nativewindow-natives-.jar, + // jogl-core.jar -> jogl-natives-.jar, + // (newt-core.jar -> newt-natives-.jar)? (if available) + final String newtFactoryClassName = "com.jogamp.newt.NewtFactory"; + final Class[] classesFromJavaJars = new Class[] { NWJNILibLoader.class, GLProfile.class, null }; + if( ReflectionUtil.isClassAvailable(newtFactoryClassName, cl) ) { + classesFromJavaJars[2] = ReflectionUtil.getClass(newtFactoryClassName, false, cl); } - JNILibLoaderBase.addNativeJarLibs(GLProfile.class, "jogl-all", atomicNativeJarBaseNames); + JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all", new String[] { "-noawt", "-mobile", "-core" } ); } initProfilesForDefaultDevices(firstUIActionOnProcess); return null; @@ -1497,8 +1504,10 @@ public class GLProfile { System.err.println("GLProfile.init hasGLES1Impl "+hasGLES1Impl); System.err.println("GLProfile.init hasGLES2Impl "+hasGLES2Impl); System.err.println("GLProfile.init defaultDevice "+defaultDevice); - System.err.println("GLProfile.init profile order "+array2String(GL_PROFILE_LIST_ALL)); - System.err.println(JoglVersion.getDefaultOpenGLInfo(null)); + System.err.println("GLProfile.init profile order "+array2String(GL_PROFILE_LIST_ALL)); + if(hasGL234Impl || hasGLES1Impl || hasGLES2Impl) { // avoid deadlock + System.err.println(JoglVersion.getDefaultOpenGLInfo(null)); + } } } @@ -1527,7 +1536,7 @@ public class GLProfile { boolean isSet = GLContext.getAvailableGLVersionsSet(device); if(DEBUG) { - System.err.println("Info: GLProfile.initProfilesForDevice: "+device+", isSet "+isSet); + System.err.println("Info: GLProfile.initProfilesForDevice: "+device+" ("+device.getClass().getName()+"), isSet "+isSet+", hasDesktopGLFactory "+hasDesktopGLFactory+", hasEGLFactory "+hasEGLFactory); } if(isSet) { // Avoid recursion and check whether impl. is sane! @@ -1901,9 +1910,14 @@ public class GLProfile { { initSingleton(); + if(null==defaultDevice) { // avoid NPE and notify of incomplete initialization + throw new GLException("No default device available"); + } + if(null==device) { device = defaultDevice; } + final String deviceKey = device.getUniqueID(); HashMap map = deviceConn2ProfileMap.get(deviceKey); if( null != map ) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java index 99bc71c4a..6c15f9a2b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java @@ -44,7 +44,9 @@ public class NWJNILibLoader extends JNILibLoaderBase { Platform.initSingleton(); final String libName = "nativewindow_"+ossuffix ; if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) { - addNativeJarLibs(NWJNILibLoader.class, "jogl-all", new String[] { "nativewindow" } ); + // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-.jar + // or: nativewindow-core.jar -> nativewindow-natives-.jar + addNativeJarLibs(new Class[] { NWJNILibLoader.class }, "-all", new String[] { "-noawt", "-mobile", "-core" } ); } return new Boolean(loadLibrary(libName, false, NWJNILibLoader.class.getClassLoader())); } diff --git a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java index 2db9d8d05..bc0eb7531 100644 --- a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java +++ b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java @@ -42,6 +42,8 @@ package jogamp.newt; import java.security.AccessController; import java.security.PrivilegedAction; +import jogamp.nativewindow.NWJNILibLoader; + import com.jogamp.common.jvm.JNILibLoaderBase; import com.jogamp.common.os.Platform; import com.jogamp.common.util.cache.TempJarCache; @@ -54,7 +56,10 @@ public class NEWTJNILibLoader extends JNILibLoaderBase { Platform.initSingleton(); final String libName = "newt"; if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) { - addNativeJarLibs(NEWTJNILibLoader.class, "jogl-all", new String[] { "nativewindow", "newt" } ); + // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-.jar + // or: nativewindow-core.jar -> nativewindow-natives-.jar, + // newt-core.jar -> newt-natives-.jar + JNILibLoaderBase.addNativeJarLibs(new Class[] { NWJNILibLoader.class, NEWTJNILibLoader.class }, "-all", new String[] { "-noawt", "-mobile", "-core" } ); } loadLibrary(libName, false, NEWTJNILibLoader.class.getClassLoader()); return null; -- cgit v1.2.3 From 4a0a5d69ffcb7592b092991ddb3761653c389ce6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 27 Jun 2012 02:49:18 +0200 Subject: NEWT WindowImpl.runOnEDTIfAvail(..): Run task from current thread if owning the windowLock. Avoiding deadlock when cmds issued from within locked code path. This allows e.g. GLEventListener::display(..) { .. glWindow.setSize(100, 100); .. } --- src/newt/classes/jogamp/newt/WindowImpl.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 68a2430f7..73bd9ed1c 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1574,12 +1574,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public void runOnEDTIfAvail(boolean wait, final Runnable task) { - Screen scrn = getScreen(); - if(null==scrn) { - throw new RuntimeException("Null screen of inner class: "+this); + if(windowLock.isOwner()) { + task.run(); + } else { + Screen scrn = getScreen(); + if(null==scrn) { + throw new RuntimeException("Null screen of inner class: "+this); + } + DisplayImpl d = (DisplayImpl) scrn.getDisplay(); + d.runOnEDTIfAvail(wait, task); } - DisplayImpl d = (DisplayImpl) scrn.getDisplay(); - d.runOnEDTIfAvail(wait, task); } private final Runnable requestFocusAction = new Runnable() { -- cgit v1.2.3 From a06e40cce89615eb8c4b080842997c9c3ad1130b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 27 Jun 2012 05:05:36 +0200 Subject: NativeSurface Cleanup (API Change) - Adapt to GlueGen Lock cleanup commit: 834b9e530e652b7ff7c5e222720bce3ad2b11c5f - adapt to GlueGen Lock cleanup - remove isSurfaceLocked(), use 'null != getSurfaceLockOwner()' instead Misc: - remove unused priv./impl. methods - add @Override --- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 6 +- src/jogl/classes/jogamp/opengl/GLDrawableImpl.java | 4 - src/jogl/classes/jogamp/opengl/GLPbufferImpl.java | 4 - .../com/jogamp/nativewindow/awt/JAWTWindow.java | 139 ++++++++++++--------- .../javax/media/nativewindow/NativeSurface.java | 15 +-- .../javax/media/nativewindow/ProxySurface.java | 34 +++-- .../classes/com/jogamp/newt/opengl/GLWindow.java | 8 +- src/newt/classes/jogamp/newt/WindowImpl.java | 34 +++-- 8 files changed, 134 insertions(+), 110 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 51201b3a9..ff1b65520 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -164,7 +164,7 @@ public abstract class GLContextImpl extends GLContext { if(null!=read && drawable!=read && !isGLReadDrawableAvailable()) { throw new GLException("GL Read Drawable not available"); } - boolean lockHeld = lock.isOwner(); + final boolean lockHeld = lock.isOwner(Thread.currentThread()); if(lockHeld) { release(); } @@ -224,8 +224,8 @@ public abstract class GLContextImpl extends GLContext { if(TRACE_SWITCH) { System.err.println(getThreadName() +": GLContext.ContextSwitch: - release() - force: "+force+", "+lock); } - if ( !lock.isOwner() ) { - throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this); + if ( !lock.isOwner(Thread.currentThread()) ) { + throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this); } final boolean actualRelease = force || lock.getHoldCount() == 1 ; try { diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index 36f17e5a1..71624789d 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -199,10 +199,6 @@ public abstract class GLDrawableImpl implements GLDrawable { surface.unlockSurface(); } - public boolean isSurfaceLocked() { - return surface.isSurfaceLocked(); - } - public String toString() { return getClass().getSimpleName()+"[Realized "+isRealized()+ ",\n\tFactory "+getFactory()+ diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index 0f4f7f8e2..9a4cf1f94 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -267,10 +267,6 @@ public class GLPbufferImpl implements GLPbuffer { recurLock.unlock(); } - public boolean isSurfaceLocked() { - return recurLock.isLocked(); - } - public int getFloatingPointMode() { if (floatMode == 0) { throw new GLException("Pbuffer not initialized, or floating-point support not requested"); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 02dd746a0..3437358de 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -67,7 +67,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, // user properties protected boolean shallUseOffscreenLayer = false; - + // lifetime: forever protected Component component; private AWTGraphicsConfiguration config; // control access due to delegation @@ -81,13 +81,13 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected long drawable; protected Rectangle bounds; protected Insets insets; - + private long drawable_old; - + /** * Constructed by {@link jogamp.nativewindow.NativeWindowFactoryImpl#getNativeWindow(Object, AbstractGraphicsConfiguration)} * via this platform's specialization (X11, OSX, Windows, ..). - * + * * @param comp * @param config */ @@ -107,19 +107,22 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, this.component = windowObject; this.isApplet = false; } - + + @Override public void setShallUseOffscreenLayer(boolean v) { shallUseOffscreenLayer = v; } - + + @Override public final boolean getShallUseOffscreenLayer() { return shallUseOffscreenLayer; } - - public final boolean isOffscreenLayerSurfaceEnabled() { + + @Override + public final boolean isOffscreenLayerSurfaceEnabled() { return isOffscreenLayerSurface; } - + protected synchronized void invalidate() { invalidateNative(); jawt = null; @@ -136,7 +139,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, bounds.setY(jawtBounds.getY()); bounds.setWidth(jawtBounds.getWidth()); bounds.setHeight(jawtBounds.getHeight()); - + if(component instanceof Container) { java.awt.Insets contInsets = ((Container)component).getInsets(); insets.setLeftWidth(contInsets.left); @@ -148,16 +151,17 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, /** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */ public final RectangleImmutable getBounds() { return bounds; } - + + @Override public final InsetsImmutable getInsets() { return insets; } public final Component getAWTComponent() { return component; } - - /** - * Returns true if the AWT component is parented to an {@link java.applet.Applet}, - * otherwise false. This information is valid only after {@link #lockSurface()}. + + /** + * Returns true if the AWT component is parented to an {@link java.applet.Applet}, + * otherwise false. This information is valid only after {@link #lockSurface()}. */ public final boolean isApplet() { return isApplet; @@ -168,10 +172,11 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return jawt; } - /** + /** * {@inheritDoc} */ - public final void attachSurfaceLayer(final long layerHandle) throws NativeWindowException { + @Override + public final void attachSurfaceLayer(final long layerHandle) throws NativeWindowException { if( !isOffscreenLayerSurfaceEnabled() ) { throw new NativeWindowException("Not an offscreen layer surface"); } @@ -187,13 +192,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } finally { unlockSurface(); } - } + } protected abstract void attachSurfaceLayerImpl(final long layerHandle); - - /** + + /** * {@inheritDoc} */ - public final void detachSurfaceLayer(final long layerHandle) throws NativeWindowException { + @Override + public final void detachSurfaceLayer(final long layerHandle) throws NativeWindowException { if( !isOffscreenLayerSurfaceEnabled() ) { throw new java.lang.UnsupportedOperationException("Not an offscreen layer surface"); } @@ -209,29 +215,33 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } finally { unlockSurface(); } - } + } protected abstract void detachSurfaceLayerImpl(final long layerHandle); - + // // SurfaceUpdateListener // + @Override public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { surfaceUpdatedHelper.addSurfaceUpdatedListener(l); } + @Override public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); } + @Override public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); } + @Override public void surfaceUpdated(Object updater, NativeSurface ns, long when) { surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); - } - + } + // // NativeSurface // @@ -243,14 +253,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, c = c.getParent(); } } - + /** - * If JAWT offscreen layer is supported, + * If JAWT offscreen layer is supported, * implementation shall respect {@link #getShallUseOffscreenLayer()} * and may respect {@link #isApplet()}. - * + * * @return The JAWT instance reflecting offscreen layer support, etc. - * + * * @throws NativeWindowException */ protected abstract JAWT fetchJAWTImpl() throws NativeWindowException; @@ -266,7 +276,8 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } // Thread.dumpStack(); } - + + @Override public final int lockSurface() throws NativeWindowException { surfaceLock.lock(); int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? @@ -282,7 +293,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, res = lockSurfaceImpl(); if(LOCK_SUCCESS == res && drawable_old != drawable) { res = LOCK_SURFACE_CHANGED; - if(DEBUG) { + if(DEBUG) { System.err.println("JAWTWindow: surface change 0x"+Long.toHexString(drawable_old)+" -> 0x"+Long.toHexString(drawable)); // Thread.dumpStack(); } @@ -303,6 +314,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected abstract void unlockSurfaceImpl() throws NativeWindowException; + @Override public final void unlockSurface() { surfaceLock.validateLocked(); drawable_old = drawable; @@ -318,46 +330,51 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, surfaceLock.unlock(); } + @Override public final boolean isSurfaceLockedByOtherThread() { return surfaceLock.isLockedByOtherThread(); } - public final boolean isSurfaceLocked() { - return surfaceLock.isLocked(); - } - + @Override public final Thread getSurfaceLockOwner() { return surfaceLock.getOwner(); } + @Override public boolean surfaceSwap() { return false; } + @Override public long getSurfaceHandle() { return drawable; } - + public final AWTGraphicsConfiguration getPrivateGraphicsConfiguration() { return config; } - + + @Override public final AbstractGraphicsConfiguration getGraphicsConfiguration() { return config.getNativeGraphicsConfiguration(); } + @Override public final long getDisplayHandle() { return getGraphicsConfiguration().getScreen().getDevice().getHandle(); } + @Override public final int getScreenIndex() { return getGraphicsConfiguration().getScreen().getIndex(); } + @Override public int getWidth() { return component.getWidth(); } + @Override public int getHeight() { return component.getHeight(); } @@ -366,41 +383,47 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, // NativeWindow // + @Override public synchronized void destroy() { - invalidate(); - component = null; // don't dispose the AWT component, since we are merely an immutable uplink + invalidate(); + component = null; // don't dispose the AWT component, since we are merely an immutable uplink } + @Override public final NativeWindow getParent() { return null; } + @Override public long getWindowHandle() { return drawable; } - + + @Override public final int getX() { return component.getX(); } + @Override public final int getY() { return component.getY(); } - + /** * {@inheritDoc} - * + * *

- * This JAWT default implementation is currently still using + * This JAWT default implementation is currently still using * a blocking implementation. It first attempts to retrieve the location * via a native implementation. If this fails, it tries the blocking AWT implementation. - * If the latter fails due to an external AWT tree-lock, the non block + * If the latter fails due to an external AWT tree-lock, the non block * implementation {@link #getLocationOnScreenNonBlocking(Point, Component)} is being used. * The latter simply traverse up to the AWT component tree and sums the rel. position. * We have to determine whether the latter is good enough for all cases, * currently only OS X utilizes the non blocking method per default. - *

+ *

*/ + @Override public Point getLocationOnScreen(Point storage) { Point los = getLocationOnScreenNative(storage); if(null == los) { @@ -421,7 +444,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } return los; } - + protected Point getLocationOnScreenNative(Point storage) { int lockRes = lockSurface(); if(LOCK_SURFACE_NOT_READY == lockRes) { @@ -442,12 +465,12 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return d; } finally { unlockSurface(); - } + } } protected abstract Point getLocationOnScreenNativeImpl(int x, int y); - protected static Point getLocationOnScreenNonBlocking(Point storage, Component comp) { - int x = 0; + protected static Point getLocationOnScreenNonBlocking(Point storage, Component comp) { + int x = 0; int y = 0; while(null != comp) { x += comp.getX(); @@ -460,11 +483,12 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } return new Point(x, y); } - + + @Override public boolean hasFocus() { return component.hasFocus(); } - + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -487,5 +511,4 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return sb.toString(); } - } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java index b7829cb6d..c58b34b18 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java @@ -104,15 +104,16 @@ public interface NativeSurface extends SurfaceUpdatedListener { public void unlockSurface() throws NativeWindowException ; /** - * Return if surface is locked by another thread, ie not the current one + * Query if surface is locked by another thread, i.e. not the current one. + *
+ * Convenient shortcut for: + *
+   *   final Thread o = getSurfaceLockOwner();
+   *   if( null != o && Thread.currentThread() != o ) { .. }
+   * 
*/ public boolean isSurfaceLockedByOtherThread(); - - /** - * Return if surface is locked - */ - public boolean isSurfaceLocked(); - + /** * Return the locking owner's Thread, or null if not locked. */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java index 6a36bb130..c8cd78d82 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java @@ -37,7 +37,7 @@ import com.jogamp.common.util.locks.RecursiveLock; public abstract class ProxySurface implements NativeSurface { public static final boolean DEBUG = Debug.debug("ProxySurface"); - + private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); private AbstractGraphicsConfiguration config; // control access due to delegation protected RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); @@ -60,6 +60,7 @@ public abstract class ProxySurface implements NativeSurface { } protected abstract void invalidateImpl(); + @Override public final long getDisplayHandle() { return displayHandle; } @@ -67,21 +68,26 @@ public abstract class ProxySurface implements NativeSurface { protected final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() { return config; } - + + @Override public final AbstractGraphicsConfiguration getGraphicsConfiguration() { return config.getNativeGraphicsConfiguration(); } + @Override public final int getScreenIndex() { return getGraphicsConfiguration().getScreen().getIndex(); } + @Override public abstract long getSurfaceHandle(); + @Override public final int getWidth() { return width; } + @Override public final int getHeight() { return height; } @@ -91,26 +97,32 @@ public abstract class ProxySurface implements NativeSurface { this.height = height; } + @Override public boolean surfaceSwap() { return false; } + @Override public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { surfaceUpdatedHelper.addSurfaceUpdatedListener(l); } + @Override public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); } + @Override public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); } + @Override public void surfaceUpdated(Object updater, NativeSurface ns, long when) { surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); - } - + } + + @Override public int lockSurface() throws NativeWindowException { surfaceLock.lock(); int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? @@ -123,11 +135,11 @@ public abstract class ProxySurface implements NativeSurface { res = lockSurfaceImpl(); if(LOCK_SUCCESS == res && surfaceHandle_old != getSurfaceHandle()) { res = LOCK_SURFACE_CHANGED; - if(DEBUG) { + if(DEBUG) { System.err.println("ProxySurface: surface change 0x"+Long.toHexString(surfaceHandle_old)+" -> 0x"+Long.toHexString(getSurfaceHandle())); // Thread.dumpStack(); } - } + } } finally { if (LOCK_SURFACE_NOT_READY >= res) { adevice.unlock(); @@ -142,6 +154,7 @@ public abstract class ProxySurface implements NativeSurface { return res; } + @Override public final void unlockSurface() { surfaceLock.validateLocked(); surfaceHandle_old = getSurfaceHandle(); @@ -165,17 +178,16 @@ public abstract class ProxySurface implements NativeSurface { surfaceLock.validateLocked(); } - public final boolean isSurfaceLocked() { - return surfaceLock.isLocked(); - } - + @Override public final boolean isSurfaceLockedByOtherThread() { return surfaceLock.isLockedByOtherThread(); } + @Override public final Thread getSurfaceLockOwner() { return surfaceLock.getOwner(); } - public abstract String toString(); + @Override + public abstract String toString(); } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index a3adf5090..1832d4e99 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -842,22 +842,22 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC // NativeWindow completion // + @Override public final int lockSurface() { return window.lockSurface(); } + @Override public final void unlockSurface() throws NativeWindowException { window.unlockSurface(); } + @Override public final boolean isSurfaceLockedByOtherThread() { return window.isSurfaceLockedByOtherThread(); } - public final boolean isSurfaceLocked() { - return window.isSurfaceLocked(); - } - + @Override public final Thread getSurfaceLockOwner() { return window.getSurfaceLockOwner(); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 73bd9ed1c..baad77ffb 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -562,6 +562,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // NativeSurface // + @Override public final int lockSurface() { windowLock.lock(); surfaceLock.lock(); @@ -590,6 +591,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return res; } + @Override public final void unlockSurface() { surfaceLock.validateLocked(); windowLock.validateLocked(); @@ -606,30 +608,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer windowLock.unlock(); } - public final boolean isWindowLockedByOtherThread() { - return windowLock.isLockedByOtherThread(); - } - - public final boolean isWindowLocked() { - return windowLock.isLocked(); - } - - public final Thread getWindowLockOwner() { - return windowLock.getOwner(); - } - + @Override public final boolean isSurfaceLockedByOtherThread() { return surfaceLock.isLockedByOtherThread(); } - public final boolean isSurfaceLocked() { - return surfaceLock.isLocked(); - } - + @Override public final Thread getSurfaceLockOwner() { return surfaceLock.getOwner(); } + public final boolean isWindowLockedByOtherThread() { + return windowLock.isLockedByOtherThread(); + } + + public final Thread getWindowLockOwner() { + return windowLock.getOwner(); + } + public long getSurfaceHandle() { return windowHandle; // default: return window handle } @@ -1574,7 +1570,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public void runOnEDTIfAvail(boolean wait, final Runnable task) { - if(windowLock.isOwner()) { + if(windowLock.isOwner(Thread.currentThread())) { task.run(); } else { Screen scrn = getScreen(); @@ -1913,7 +1909,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // special repaint treatment case WindowEvent.EVENT_WINDOW_REPAINT: // queue repaint event in case window is locked, ie in operation - if( isWindowLocked() ) { + if( null != getWindowLockOwner() ) { // make sure only one repaint event is queued if(!repaintQueued) { repaintQueued=true; @@ -1932,7 +1928,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // common treatment case WindowEvent.EVENT_WINDOW_RESIZED: // queue event in case window is locked, ie in operation - if( isWindowLocked() ) { + if( null != getWindowLockOwner() ) { final boolean discardTO = QUEUED_EVENT_TO <= System.currentTimeMillis()-e.getWhen(); if(DEBUG_IMPLEMENTATION) { System.err.println("Window.consumeEvent: "+Thread.currentThread().getName()+" - queued "+e+", discard-to "+discardTO); -- cgit v1.2.3 From 6bff43023b630d7e9f413e39821ebf89c40a399a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 27 Jun 2012 05:06:07 +0200 Subject: Misc cleanup: add @Override --- .../com/jogamp/opengl/util/AnimatorBase.java | 2 +- .../com/jogamp/nativewindow/WrappedSurface.java | 14 +++- .../javax/media/nativewindow/NativeWindow.java | 60 +++++++-------- .../jogamp/nativewindow/windows/GDISurface.java | 5 ++ src/newt/classes/com/jogamp/newt/Window.java | 87 +++++++++++----------- 5 files changed, 90 insertions(+), 78 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index d65967da1..46fc1d991 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -208,6 +208,6 @@ public abstract class AnimatorBase implements GLAnimatorControl { } public String toString() { - return getClass().getName()+"[started "+isStarted()+", animating "+isAnimating()+", paused "+isPaused()+", drawable "+drawables.size()+"]"; + return getClass().getName()+"[started "+isStarted()+", animating "+isAnimating()+", paused "+isPaused()+", drawable "+drawables.size()+", totals[dt "+getTotalFPSDuration()+", frames "+getTotalFPSFrames()+", fps "+getTotalFPS()+"]]"; } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java index f2993abab..04f616daf 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java @@ -44,30 +44,36 @@ public class WrappedSurface extends ProxySurface implements SurfaceChangeable { super(cfg); surfaceHandle=handle; } - + + @Override protected final void invalidateImpl() { surfaceHandle = 0; } + @Override final public long getSurfaceHandle() { return surfaceHandle; } + @Override final public void setSurfaceHandle(long surfaceHandle) { this.surfaceHandle=surfaceHandle; } + @Override final protected int lockSurfaceImpl() { return LOCK_SUCCESS; } + @Override final protected void unlockSurfaceImpl() { } + @Override public String toString() { - return "WrappedSurface[config " + getPrivateGraphicsConfiguration()+ - ", displayHandle 0x" + Long.toHexString(getDisplayHandle()) + - ", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle()) + + return "WrappedSurface[config " + getPrivateGraphicsConfiguration()+ + ", displayHandle 0x" + Long.toHexString(getDisplayHandle()) + + ", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle()) + ", size " + getWidth() + "x" + getHeight() + ", surfaceLock "+surfaceLock+"]"; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java index 2bc352116..12e202975 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -52,8 +52,8 @@ import javax.media.nativewindow.util.Point; which can create NativeWindow objects for its components.

*/ public interface NativeWindow extends NativeSurface { - - /** + + /** * destroys the window and releases * windowing related resources. */ @@ -67,63 +67,63 @@ public interface NativeWindow extends NativeSurface { /** * Returns the window handle for this NativeWindow.

* - * The window handle shall reflect the platform one + * The window handle shall reflect the platform one * for all window related operations, e.g. open, close, resize.

* * On X11 this returns an entity of type Window.
- * On Microsoft Windows this returns an entity of type HWND. + * On Microsoft Windows this returns an entity of type HWND. */ public long getWindowHandle(); - /** + /** * Returns the insets defined as the width and height of the window decoration * on the left, right, top and bottom.
* Insets are zero if the window is undecorated, including child windows. - * + * *

* Insets are available only after the native window has been created, * ie. the native window has been made visible.
- * + * * The top-level window area's top-left corner is located at *

    *   getX() - getInsets().{@link InsetsImmutable#getLeftWidth() getLeftWidth()}
    *   getY() - getInsets().{@link InsetsImmutable#getTopHeight() getTopHeight()}
-   * 
- * + * + * * The top-level window size is *
-   *   getWidth()  + getInsets().{@link InsetsImmutable#getTotalWidth() getTotalWidth()} 
+   *   getWidth()  + getInsets().{@link InsetsImmutable#getTotalWidth() getTotalWidth()}
    *   getHeight() + getInsets().{@link InsetsImmutable#getTotalHeight() getTotalHeight()}
-   * 
- * + * + * * @return insets */ public InsetsImmutable getInsets(); - + /** Returns the current x position of this window, relative to it's parent. */ - - /** + + /** * @return the current x position of the top-left corner - * of the client area relative to it's parent. + * of the client area relative to it's parent. * Since the position reflects the client area, it does not include the insets. * @see #getInsets() */ public int getX(); - /** + /** * @return the current y position of the top-left corner - * of the client area relative to it's parent. + * of the client area relative to it's parent. * Since the position reflects the client area, it does not include the insets. * @see #getInsets() */ public int getY(); - /** - * Returns the current position of the top-left corner + /** + * Returns the current position of the top-left corner * of the client area in screen coordinates. *

* Since the position reflects the client area, it does not include the insets. - *

+ *

* @param point if not null, * {@link javax.media.nativewindow.util.Point#translate(javax.media.nativewindow.util.Point)} * the passed {@link javax.media.nativewindow.util.Point} by this location on the screen and return it. @@ -131,8 +131,8 @@ public interface NativeWindow extends NativeSurface { * or a new instance with the screen location of this NativeWindow. */ public Point getLocationOnScreen(Point point); - + /** Returns true if this native window owns the focus, otherwise false. */ boolean hasFocus(); - + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java index bc02ac5dc..4da48bdae 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java @@ -51,11 +51,13 @@ public class GDISurface extends ProxySurface { this.windowHandle=windowHandle; } + @Override protected final void invalidateImpl() { windowHandle=0; surfaceHandle=0; } + @Override final protected int lockSurfaceImpl() { if (0 != surfaceHandle) { throw new InternalError("surface not released"); @@ -70,6 +72,7 @@ public class GDISurface extends ProxySurface { return (0 != surfaceHandle) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY; } + @Override final protected void unlockSurfaceImpl() { if (0 == surfaceHandle) { throw new InternalError("surface not acquired: "+this+", thread: "+Thread.currentThread().getName()); @@ -80,10 +83,12 @@ public class GDISurface extends ProxySurface { surfaceHandle=0; } + @Override final public long getSurfaceHandle() { return surfaceHandle; } + @Override final public String toString() { return "GDISurface[config "+getPrivateGraphicsConfiguration()+ ", displayHandle 0x"+Long.toHexString(getDisplayHandle())+ diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 136c19ff8..71e86d520 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -71,7 +71,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { /** * Set the CapabilitiesChooser to help determine the native visual type. - * + * * @param chooser the new CapabilitiesChooser * @return the previous CapabilitiesChooser */ @@ -86,7 +86,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { /** * Gets an immutable set of chosen capabilities. - * + * * @return the chosen capabilities */ CapabilitiesImmutable getChosenCapabilities(); @@ -103,6 +103,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * @see #destroy() * @see #setVisible(boolean) */ + @Override void destroy(); /** @@ -135,14 +136,14 @@ public interface Window extends NativeWindow, WindowClosingProtocol { boolean isVisible(); - /** - * If the implementation uses delegation, return the delegated {@link Window} instance, + /** + * If the implementation uses delegation, return the delegated {@link Window} instance, * otherwise return this instance. */ Window getDelegatedWindow(); - + // // Child Window Management - // + // boolean addChild(NativeWindow win); @@ -154,7 +155,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { /** * Sets the size of the window's client area, excluding decorations. - * + * *

* Zero size semantics are respected, see {@link #setVisible(boolean)}:
*

@@ -171,72 +172,72 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
      *
      * @param width of the window's client area
      * @param height of the window's client area
-     * 
+     *
      * @see #getInsets()
      */
     void setSize(int width, int height);
 
     /**
      * Sets the size of the top-level window including insets (window decorations).
-     * 
+     *
      * 

* Note: Insets (if supported) are available only after the window is set visible and hence has been created. *

* * @param width of the top-level window area * @param height of the top-level window area - * + * * @see #setSize(int, int) * @see #getInsets() */ void setTopLevelSize(int width, int height); - + /** * Sets the location of the window's client area, excluding insets (window decorations).
- * + * * This call is ignored if in fullscreen mode.
* * @param x coord of the client-area's top left corner * @param y coord of the client-area's top left corner - * + * * @see #getInsets() */ void setPosition(int x, int y); - + /** * Sets the location of the top-level window inclusive insets (window decorations).
- * + * *

* Note: Insets (if supported) are available only after the window is set visible and hence has been created. *

- * + * * This call is ignored if in fullscreen mode.
* * @param x coord of the top-level left corner * @param y coord of the top-level left corner - * + * * @see #setPosition(int, int) * @see #getInsets() */ void setTopLevelPosition(int x, int y); void setUndecorated(boolean value); - + boolean isUndecorated(); - + void setAlwaysOnTop(boolean value); - + boolean isAlwaysOnTop(); - + void setTitle(String title); String getTitle(); boolean isPointerVisible(); - + /** * Makes the pointer visible or invisible. - * + * * @param pointerVisible defaults to true for platforms w/ visible pointer, * otherwise defaults to true, eg. Android. * @see #confinePointer(boolean) @@ -244,32 +245,32 @@ public interface Window extends NativeWindow, WindowClosingProtocol { void setPointerVisible(boolean pointerVisible); boolean isPointerConfined(); - + /** * Confine the pointer to this window, ie. pointer jail. *

- * Before jailing the mouse pointer, + * Before jailing the mouse pointer, * the window request the focus and the pointer is centered in the window. *

*

- * In combination w/ {@link #warpPointer(int, int)} + * In combination w/ {@link #warpPointer(int, int)} * and maybe {@link #setPointerVisible(boolean)} a simple mouse * navigation can be realized.

- * + * * @param confine defaults to false. */ void confinePointer(boolean confine); - + /** * Moves the pointer to x/y relative to this window's origin. - * + * * @param x relative pointer x position within this window * @param y relative pointer y position within this window - * + * * @see #confinePointer(boolean) */ void warpPointer(int x, int y); - + /** Reparenting operation types */ public enum ReparentOperation { /** No native reparenting valid */ @@ -285,7 +286,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { ACTION_NATIVE_CREATION, /** Change Window tree only, native creation is pending */ - ACTION_NATIVE_CREATION_PENDING; + ACTION_NATIVE_CREATION_PENDING; } /** @@ -305,7 +306,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate); boolean setFullscreen(boolean fullscreen); - + boolean isFullscreen(); static interface FocusRunnable { @@ -317,7 +318,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { } /** - * Sets a {@link FocusRunnable}, + * Sets a {@link FocusRunnable}, * which {@link FocusRunnable#run()} method is executed before the native focus is requested. *

* This allows notifying a covered window toolkit like AWT that the focus is requested, @@ -325,7 +326,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { *

*/ void setFocusAction(FocusRunnable focusAction); - + /** * Sets a {@link KeyListener} allowing focus traversal with a covered window toolkit like AWT. *

@@ -336,27 +337,27 @@ public interface Window extends NativeWindow, WindowClosingProtocol { */ void setKeyboardFocusHandler(KeyListener l); - /** + /** * Request focus for this native window *

* The request is handled on this Window EDT and blocked until finished. *

- * + * * @see #requestFocus(boolean) */ void requestFocus(); - /** + /** * Request focus for this native window *

- * The request is handled on this Window EDT. + * The request is handled on this Window EDT. *

- * + * * @param wait true if waiting until the request is executed, otherwise false * @see #requestFocus() */ void requestFocus(boolean wait); - + void windowRepaint(int x, int y, int width, int height); void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event); @@ -410,7 +411,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { */ void setKeyboardVisible(boolean visible); - /** + /** * Return true if the virtual on-screen keyboard is visible, otherwise false. *

* Currently on Android, the only supported platform right now, @@ -420,7 +421,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * @see #setKeyboardVisible(boolean) */ boolean isKeyboardVisible(); - + /** * * Appends the given {@link com.jogamp.newt.event.KeyListener} to the end of -- cgit v1.2.3 From 3334a924309a9361a448d69bc707d4cce416b430 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 28 Jun 2012 21:39:37 +0200 Subject: NEWT GLWindow multithreading fix and annotations (see commit bc7503c77892a9e14b10e8b8e9ce48b148c6fa4c). NEWT GLWindow multithreading fix: - Add required locking of display(), otherwise a drawable/context destruction of another threads could lead to [still] use asynced data. --- .../classes/com/jogamp/newt/opengl/GLWindow.java | 307 ++++++++++++++++----- src/newt/classes/jogamp/newt/WindowImpl.java | 7 + 2 files changed, 242 insertions(+), 72 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 1832d4e99..b94bc0f27 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,27 +29,54 @@ * 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; import java.io.PrintStream; -import com.jogamp.common.GlueGenVersion; -import com.jogamp.common.util.VersionUtil; -import com.jogamp.newt.*; -import com.jogamp.newt.event.*; - -import jogamp.newt.WindowImpl; - -import javax.media.nativewindow.*; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.CapabilitiesChooser; +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; -import javax.media.opengl.*; +import javax.media.opengl.FPSCounter; +import javax.media.opengl.GL; +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; +import javax.media.opengl.GLRunnable; +import jogamp.newt.WindowImpl; import jogamp.opengl.FPSCounterImpl; import jogamp.opengl.GLDrawableHelper; + +import com.jogamp.common.GlueGenVersion; +import com.jogamp.common.util.VersionUtil; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.event.KeyListener; +import com.jogamp.newt.event.MouseListener; +import com.jogamp.newt.event.NEWTEvent; +import com.jogamp.newt.event.NEWTEventConsumer; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowListener; +import com.jogamp.newt.event.WindowUpdateEvent; import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.util.Animator; @@ -64,7 +91,14 @@ import com.jogamp.opengl.util.Animator; * To be able to use OpenGL commands from within such input {@link com.jogamp.newt.event.NEWTEventListener},
* you can inject {@link javax.media.opengl.GLRunnable} objects * via {@link #invoke(boolean, javax.media.opengl.GLRunnable)} to the OpenGL command stream.
+ *

*

+ * NOTE: [MT-0] Methods utilizing [volatile] drawable/context are not synchronized. + In case any of the methods are called outside of a locked state + extra care should be added. Maybe we shall expose locking facilities to the user. + However, since the user shall stick to the GLEventListener model while utilizing + GLAutoDrawable implementations, she is safe due to the implicit locked state. + *

*/ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter { private final WindowImpl window; @@ -75,7 +109,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC protected GLWindow(Window window) { resetFPSCounter(); this.window = (WindowImpl) window; - ((WindowImpl)this.window).setHandleDestroyNotify(false); + this.window.setHandleDestroyNotify(false); window.addWindowListener(new WindowAdapter() { @Override public void windowRepaint(WindowUpdateEvent e) { @@ -121,13 +155,13 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC } /** - * Creates a new GLWindow attaching a new Window referencing a + * Creates a new GLWindow attaching a new Window referencing a * new default Screen and default Display with the given GLCapabilities. *

* The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()} * and {@link Screen#removeReference()}. *

- * The default Display will be reused if already instantiated. + * The default Display will be reused if already instantiated. */ public static GLWindow create(GLCapabilitiesImmutable caps) { return new GLWindow(NewtFactory.createWindow(caps)); @@ -145,7 +179,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC return new GLWindow(NewtFactory.createWindow(screen, caps)); } - /** + /** * Creates a new GLWindow attaching the given window. *

* The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()} @@ -156,13 +190,13 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC return new GLWindow(window); } - /** - * Creates a new GLWindow attaching a new child Window + /** + * Creates a new GLWindow attaching a new child Window * of the given parentNativeWindow with the given GLCapabilities. *

* The Display/Screen will be compatible with the parentNativeWindow, * or even identical in case it's a Newt Window. - * An already instantiated compatible Display will be reused. + * An already instantiated compatible Display will be reused. *

*

* The lifecycle of this Window's Screen and Display is handled via {@link Screen#addReference()} @@ -176,10 +210,12 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC //---------------------------------------------------------------------- // WindowClosingProtocol implementation // + @Override public WindowClosingMode getDefaultCloseOperation() { return window.getDefaultCloseOperation(); } + @Override public WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { return window.setDefaultCloseOperation(op); } @@ -188,10 +224,12 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC // Window Access // + @Override public CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser) { return window.setCapabilitiesChooser(chooser); } + @Override public final CapabilitiesImmutable getChosenCapabilities() { if (drawable == null) { return window.getChosenCapabilities(); @@ -200,153 +238,189 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC return drawable.getChosenGLCapabilities(); } + @Override public final CapabilitiesImmutable getRequestedCapabilities() { return window.getRequestedCapabilities(); } + @Override public final Window getDelegatedWindow() { return window.getDelegatedWindow(); } + @Override public final NativeWindow getParent() { return window.getParent(); } + @Override public final Screen getScreen() { return window.getScreen(); } + @Override public final void setTitle(String title) { window.setTitle(title); } + @Override public final String getTitle() { return window.getTitle(); } + @Override public final boolean isPointerVisible() { return window.isPointerVisible(); } - + + @Override public final void setPointerVisible(boolean mouseVisible) { - window.setPointerVisible(mouseVisible); + window.setPointerVisible(mouseVisible); } - + + @Override public final boolean isPointerConfined() { return window.isPointerConfined(); } - + + @Override public final void confinePointer(boolean grab) { window.confinePointer(grab); } - + + @Override public final void setUndecorated(boolean value) { window.setUndecorated(value); } + @Override public final void warpPointer(int x, int y) { window.warpPointer(x, y); } + @Override public final boolean isUndecorated() { return window.isUndecorated(); } + @Override public final void setAlwaysOnTop(boolean value) { window.setAlwaysOnTop(value); } - + + @Override public final boolean isAlwaysOnTop() { return window.isAlwaysOnTop(); } - + + @Override public final void setFocusAction(FocusRunnable focusAction) { window.setFocusAction(focusAction); } - + + @Override public void setKeyboardFocusHandler(KeyListener l) { window.setKeyboardFocusHandler(l); } - + + @Override public final void requestFocus() { window.requestFocus(); } + @Override public final void requestFocus(boolean wait) { - window.requestFocus(wait); + window.requestFocus(wait); } - + + @Override public boolean hasFocus() { return window.hasFocus(); } - public final InsetsImmutable getInsets() { + @Override + public final InsetsImmutable getInsets() { return window.getInsets(); } - + + @Override public final void setPosition(int x, int y) { window.setPosition(x, y); } - public void setTopLevelPosition(int x, int y) { + @Override + public void setTopLevelPosition(int x, int y) { window.setTopLevelPosition(x, y); } + @Override public final boolean setFullscreen(boolean fullscreen) { return window.setFullscreen(fullscreen); } + @Override public final boolean isFullscreen() { return window.isFullscreen(); } + @Override public final boolean isVisible() { return window.isVisible(); } @Override public final String toString() { - return "NEWT-GLWindow[ \n\tHelper: " + helper + ", \n\tDrawable: " + drawable + + return "NEWT-GLWindow[ \n\tHelper: " + helper + ", \n\tDrawable: " + drawable + ", \n\tContext: " + context + ", \n\tWindow: "+window+ /** ", \n\tFactory: "+factory+ */ "]"; } + @Override public final ReparentOperation reparentWindow(NativeWindow newParent) { return window.reparentWindow(newParent); } + @Override public final ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate) { return window.reparentWindow(newParent, forceDestroyCreate); } + @Override public final boolean removeChild(NativeWindow win) { return window.removeChild(win); } + @Override public final boolean addChild(NativeWindow win) { return window.addChild(win); } - + //---------------------------------------------------------------------- // Window.LifecycleHook Implementation // + @Override public final void destroy() { window.destroy(); } + @Override public final void setVisible(boolean visible) { window.setVisible(visible); } + @Override public final void setSize(int width, int height) { window.setSize(width, height); } + @Override public void setTopLevelSize(int width, int height) { - window.setTopLevelSize(width, height); + window.setTopLevelSize(width, height); } - + + @Override public final boolean isNativeValid() { return window.isNativeValid(); } + @Override public Point getLocationOnScreen(Point storage) { return window.getLocationOnScreen(storage); } @@ -354,10 +428,12 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC // Hide methods here .. protected class GLLifecycleHook implements WindowImpl.LifecycleHook { + @Override public synchronized void destroyActionPreLock() { // nop } + @Override public synchronized void destroyActionInLock() { if(Window.DEBUG_IMPLEMENTATION) { String msg = "GLWindow.destroy() "+Thread.currentThread()+", start"; @@ -380,12 +456,13 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC } context = null; drawable = null; - + if(Window.DEBUG_IMPLEMENTATION) { System.err.println("GLWindow.destroy() "+Thread.currentThread()+", fin"); } } + @Override public synchronized void resetCounter() { if(Window.DEBUG_IMPLEMENTATION) { System.err.println("GLWindow.resetCounter() "+Thread.currentThread()); @@ -393,6 +470,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC GLWindow.this.resetFPSCounter(); } + @Override public synchronized void setVisibleActionPost(boolean visible, boolean nativeWindowCreated) { long t0; if(Window.DEBUG_IMPLEMENTATION) { @@ -421,15 +499,16 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC } drawable.setRealized(true); context = drawable.createContext(sharedContext); - context.setContextCreationFlags(additionalCtxCreationFlags); + context.setContextCreationFlags(additionalCtxCreationFlags); } if(Window.DEBUG_IMPLEMENTATION) { System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", fin: dt "+ (System.nanoTime()-t0)/1e6 +"ms"); } } - + private GLAnimatorControl savedAnimator = null; - + + @Override public synchronized boolean pauseRenderingAction() { boolean animatorPaused = false; savedAnimator = GLWindow.this.getAnimator(); @@ -439,6 +518,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC return animatorPaused; } + @Override public synchronized void resumeRenderingAction() { if ( null != savedAnimator && savedAnimator.isPaused() ) { savedAnimator.resume(); @@ -459,8 +539,9 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC // To make reshape events be sent immediately before a display event private boolean sendReshape=false; private boolean sendDestroy=false; - private FPSCounterImpl fpsCounter = new FPSCounterImpl(); + private final FPSCounterImpl fpsCounter = new FPSCounterImpl(); + @Override public GLDrawableFactory getFactory() { return factory; } @@ -477,17 +558,20 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC this.sharedContext = sharedContext; } + @Override public void setContext(GLContext newCtx) { context = newCtx; if(null != context) { context.setContextCreationFlags(additionalCtxCreationFlags); - } + } } + @Override public GLContext getContext() { return context; } + @Override public GL getGL() { if (context == null) { return null; @@ -495,6 +579,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC return context.getGL(); } + @Override public GL setGL(GL gl) { if (context != null) { context.setGL(gl); @@ -503,30 +588,35 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC return null; } + @Override public void addGLEventListener(GLEventListener listener) { if(null!=helper) { helper.addGLEventListener(listener); } } + @Override public void addGLEventListener(int index, GLEventListener listener) { if(null!=helper) { helper.addGLEventListener(index, listener); } } + @Override public void removeGLEventListener(GLEventListener listener) { if(null!=helper) { helper.removeGLEventListener(listener); } } + @Override public void setAnimator(GLAnimatorControl animatorControl) { if(null!=helper) { helper.setAnimator(animatorControl); } } + @Override public GLAnimatorControl getAnimator() { if(null!=helper) { return helper.getAnimator(); @@ -534,51 +624,61 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC return null; } + @Override public void invoke(boolean wait, GLRunnable glRunnable) { if(null!=helper) { helper.invoke(this, wait, glRunnable); } } + @Override public void display() { if( !isNativeValid() || !isVisible() ) { return; } - + if(sendDestroy || ( window.hasDeviceChanged() && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED ) ) { sendDestroy=false; destroy(); return; } - - if( null == context && 0 Date: Fri, 29 Jun 2012 04:09:48 +0200 Subject: NativeSurface.unlockSurface(): Change fail-fast policy to fail safe tolerant - This policy allows more simple destruction handling w/o validating on the top level. - Hence 'unlockSurface()' shall not throw any exception. - 'lockSurface()' keeps unchanges, clarified w/ explicit 'throws' declaration, ie will fail-fast. --- .../classes/com/jogamp/nativewindow/awt/JAWTWindow.java | 6 ++++-- .../classes/javax/media/nativewindow/NativeSurface.java | 8 +++++--- .../classes/javax/media/nativewindow/ProxySurface.java | 2 +- .../classes/jogamp/nativewindow/windows/GDISurface.java | 11 +++++------ src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 4 ++-- src/newt/classes/jogamp/newt/WindowImpl.java | 2 +- src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java | 5 ++++- .../classes/jogamp/newt/driver/windows/WindowsWindow.java | 9 ++++----- 8 files changed, 26 insertions(+), 21 deletions(-) (limited to 'src/newt/classes') diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 3437358de..3815189ef 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -278,7 +278,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override - public final int lockSurface() throws NativeWindowException { + public final int lockSurface() throws NativeWindowException, RuntimeException { surfaceLock.lock(); int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? @@ -322,7 +322,9 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if (surfaceLock.getHoldCount() == 1) { final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); try { - unlockSurfaceImpl(); + if(null != jawt) { + unlockSurfaceImpl(); + } } finally { adevice.unlock(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java index c58b34b18..cec7d4ec3 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java @@ -83,10 +83,11 @@ public interface NativeSurface extends SurfaceUpdatedListener { * @return {@link #LOCK_SUCCESS}, {@link #LOCK_SURFACE_CHANGED} or {@link #LOCK_SURFACE_NOT_READY}. * * @throws RuntimeException after timeout when waiting for the surface lock + * @throws NativeWindowException if native locking failed, maybe platform related * * @see com.jogamp.common.util.locks.RecursiveLock */ - public int lockSurface(); + public int lockSurface() throws NativeWindowException, RuntimeException; /** * Unlock the surface of this native window @@ -96,12 +97,13 @@ public interface NativeSurface extends SurfaceUpdatedListener { * The implementation shall also invoke {@link AbstractGraphicsDevice#unlock()} * for the final unlock (recursive count zero).

* - * @throws RuntimeException if surface is not locked + * The implementation shall be fail safe, i.e. tolerant in case the native resources + * are already released / unlocked. In this case the implementation shall simply ignore the call. * * @see #lockSurface * @see com.jogamp.common.util.locks.RecursiveLock */ - public void unlockSurface() throws NativeWindowException ; + public void unlockSurface(); /** * Query if surface is locked by another thread, i.e. not the current one. diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java index c8cd78d82..1dabc3dcd 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java @@ -123,7 +123,7 @@ public abstract class ProxySurface implements NativeSurface { } @Override - public int lockSurface() throws NativeWindowException { + public int lockSurface() throws NativeWindowException, RuntimeException { surfaceLock.lock(); int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java index 4da48bdae..c24f64b32 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java @@ -74,13 +74,12 @@ public class GDISurface extends ProxySurface { @Override final protected void unlockSurfaceImpl() { - if (0 == surfaceHandle) { - throw new InternalError("surface not acquired: "+this+", thread: "+Thread.currentThread().getName()); - } - if(0 == GDI.ReleaseDC(windowHandle, surfaceHandle)) { - throw new NativeWindowException("DC not released: "+this+", isWindow "+GDI.IsWindow(windowHandle)+", werr "+GDI.GetLastError()+", thread: "+Thread.currentThread().getName()); + if (0 != surfaceHandle) { + if(0 == GDI.ReleaseDC(windowHandle, surfaceHandle)) { + throw new NativeWindowException("DC not released: "+this+", isWindow "+GDI.IsWindow(windowHandle)+", werr "+GDI.GetLastError()+", thread: "+Thread.currentThread().getName()); + } + surfaceHandle=0; } - surfaceHandle=0; } @Override diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index b94bc0f27..bff1efcb5 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -995,12 +995,12 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC // @Override - public final int lockSurface() { + public final int lockSurface() throws NativeWindowException, RuntimeException { return window.lockSurface(); } @Override - public final void unlockSurface() throws NativeWindowException { + public final void unlockSurface() { window.unlockSurface(); } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 34f248121..45745e89c 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -563,7 +563,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // @Override - public final int lockSurface() { + public final int lockSurface() throws NativeWindowException, RuntimeException { windowLock.lock(); surfaceLock.lock(); int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java index b45c60e69..942994c13 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java @@ -104,7 +104,10 @@ public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverCl @Override protected void unlockSurfaceImpl() { if(!isOffscreenInstance) { - unlockSurface0(getWindowHandle()); + final long h = getWindowHandle(); + if(0 != h) { + unlockSurface0(h); + } } } diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java index a30aa133c..5e636d982 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java @@ -87,12 +87,11 @@ public class WindowsWindow extends WindowImpl { @Override protected void unlockSurfaceImpl() { - if (0 == hdc) { - throw new InternalError("surface not acquired"); + if (0 != hdc) { + GDI.ReleaseDC(getWindowHandle(), hdc); + hdc_old = hdc; + hdc=0; } - GDI.ReleaseDC(getWindowHandle(), hdc); - hdc_old = hdc; - hdc=0; } @Override -- cgit v1.2.3 From eed8508ae1132e5f45f788e9cb3f3d5a1050ac70 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 2 Jul 2012 19:42:52 +0200 Subject: GLAutoDrawable: Refine API doc; Use new abstract impl. GLAutoDrawableBase (GLWindow, ..); Add new GLAutoDrawableDelegate. - Refine API doc - 'void setContext(GLContext)' -> 'GLContext setContext(GLContext)' - Add note to createContext(GLContext) override -Use new abstract impl. GLAutoDrawableBase, used by: - GLWindow - GLAutoDrawableDelegate - GLPbufferImpl - Add new GLAutoDrawableDelegate incl. unit test --- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 29 +- .../classes/javax/media/opengl/GLAutoDrawable.java | 47 ++- .../javax/media/opengl/GLAutoDrawableDelegate.java | 100 ++++++ .../classes/javax/media/opengl/awt/GLCanvas.java | 27 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 24 +- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 337 +++++++++++++++++++++ .../jogamp/opengl/GLDrawableFactoryImpl.java | 7 +- src/jogl/classes/jogamp/opengl/GLPbufferImpl.java | 278 +++-------------- .../classes/com/jogamp/newt/opengl/GLWindow.java | 332 +++----------------- .../jogl/acore/TestGLAutoDrawableDelegateNEWT.java | 116 +++++++ 10 files changed, 736 insertions(+), 561 deletions(-) create mode 100644 src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java create mode 100644 src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 920e63421..31b679077 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -117,7 +117,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final ProxySurface proxySurface; /* Construction parameters stored for GLAutoDrawable accessor methods */ - private int ctxCreationFlags = 0; + private int additionalCtxCreationFlags = 0; private final GLCapabilitiesImmutable glCapsRequested; @@ -327,7 +327,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public int getContextCreationFlags() { - return ctxCreationFlags; + return additionalCtxCreationFlags; } @Override @@ -357,16 +357,22 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } @Override - public void setContext(final GLContext ctx) { - if (ctx instanceof GLContextImpl) { - ((GLContextImpl) ctx).setContextCreationFlags(ctxCreationFlags); + public GLContext setContext(GLContext newCtx) { + final GLContext oldCtx = context; + final boolean newCtxCurrent = drawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + context=(GLContextImpl)newCtx; + if(newCtxCurrent) { + context.makeCurrent(); } - this.context = ctx; + return oldCtx; } @Override public void setContextCreationFlags(final int arg0) { - ctxCreationFlags = arg0; + additionalCtxCreationFlags = arg0; + if(null != context) { + context.setContextCreationFlags(additionalCtxCreationFlags); + } } @Override @@ -379,8 +385,13 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } @Override - public GLContext createContext(final GLContext arg0) { - return (drawable != null) ? drawable.createContext(arg0) : null; + public GLContext createContext(final GLContext shareWith) { + if(drawable != null) { + final GLContext _ctx = drawable.createContext(shareWith); + _ctx.setContextCreationFlags(additionalCtxCreationFlags); + return _ctx; + } + return null; } @Override diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index 94e4bad66..e4aaad23d 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -122,10 +122,36 @@ public interface GLAutoDrawable extends GLDrawable { public GLContext getContext(); /** - * Associate a new context to this drawable. + * Associate a new context to this drawable and also propagates the context/drawable switch by + * calling {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. + * drawable might be an inner GLDrawable instance if using such a delegation pattern, + * or this GLAutoDrawable itself. + *

+ * If the old context's drawable was an {@link GLAutoDrawable}, it's reference to the given drawable + * is being cleared by calling + * {@link GLAutoDrawable#setContext(GLContext) ((GLAutoDrawable)oldCtx.getGLDrawable()).setContext(null)}. + *

+ *

+ * If the old or new context was current on this thread, it is being released before switching the drawable. + * The new context will be made current afterwards, if it was current before. + * However the user shall take extra care that not other thread + * attempts to make this context current. Otherwise a race condition may happen. + *

+ *

+ * Disclaimer: Even though the API may allows this functionality in theory, your mileage may vary + * switching the drawable of an already established GLContext, i.e. which is already made current once. + * FIXME: Validate functionality! + *

+ * + * @param newCtx the new context + * @return the replaced GLContext, maybe null + * + * @see GLContext#setGLDrawable(GLDrawable, boolean) + * @see GLContext#setGLReadDrawable(GLDrawable) + * @see jogamp.opengl.GLDrawableHelper#switchContext(GLDrawable, GLContext, GLContext, int) */ - public void setContext(GLContext context); - + public GLContext setContext(GLContext newCtx); + /** Adds a {@link GLEventListener} to the end of this drawable queue. The listeners are notified of events in the order of the queue. */ public void addGLEventListener(GLEventListener listener); @@ -271,6 +297,21 @@ public interface GLAutoDrawable extends GLDrawable { */ public int getContextCreationFlags(); + /** + * {@inheritDoc} + *

+ * This GLAutoDrawable implementation holds it's own GLContext reference, + * thus created a GLContext using this methods won't replace it implicitly. + * To replace or set this GLAutoDrawable's GLContext you need to call {@link #setContext(GLContext)}. + *

+ *

+ * The GLAutoDrawable implementation shall also set the + * context creation flags as customized w/ {@link #setContextCreationFlags(int)}. + *

+ */ + @Override + public GLContext createContext(GLContext shareWith); + /** Returns the {@link GL} pipeline object this GLAutoDrawable uses. If this method is called outside of the {@link GLEventListener}'s callback methods (init, display, etc.) it may diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java new file mode 100644 index 000000000..992bf9fee --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java @@ -0,0 +1,100 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package javax.media.opengl; + +import jogamp.opengl.Debug; +import jogamp.opengl.GLAutoDrawableBase; +import jogamp.opengl.GLContextImpl; +import jogamp.opengl.GLDrawableImpl; + + +/** + * Fully functional {@link GLAutoDrawable} implementation + * utilizing already created created {@link GLDrawable} and {@link GLContext} instances. + *

+ * Since no native windowing system events are being processed, it is recommended + * to handle at least {@link com.jogamp.newt.event.WindowListener#windowResized(com.jogamp.newt.event.WindowEvent) resize}, + * {@link com.jogamp.newt.event.WindowListener#windowDestroyNotify(com.jogamp.newt.event.WindowEvent) destroy-notify} + * and maybe {@link com.jogamp.newt.event.WindowListener#windowRepaint(com.jogamp.newt.event.WindowUpdateEvent) repaint}. + * The latter is only required if no {@link GLAnimatorControl} is being used. + *

+ */ +public class GLAutoDrawableDelegate extends GLAutoDrawableBase { + public static final boolean DEBUG = Debug.debug("GLAutoDrawableDelegate"); + + public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context) { + super((GLDrawableImpl)drawable, (GLContextImpl)context); + } + + public void defaultRepaintOp() { + super.defaultRepaintOp(); + } + + public void defaultReshapeOp() { + super.defaultReshapeOp(); + } + + // + // Complete GLAutoDrawable + // + + /** + * {@inheritDoc} + *

+ * This implementation simply removes references to drawable and context. + *

+ */ + @Override + public void destroy() { + drawable = null; + context = null; + } + + @Override + public void display() { + if( null == drawable || !drawable.isRealized() || null == context ) { return; } + + // surface is locked/unlocked implicit by context's makeCurrent/release + helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction); + } + + // + // GLDrawable delegation + // + + @Override + public final GLDrawableFactory getFactory() { + return drawable.getFactory(); + } + + @Override + public final void setRealized(boolean realized) { + } + +} diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 71026a247..8c6e594b5 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -392,10 +392,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } @Override - public GLContext createContext(GLContext shareWith) { - return (null != drawable) ? drawable.createContext(shareWith) : null; + public GLContext createContext(final GLContext shareWith) { + if(drawable != null) { + final GLContext _ctx = drawable.createContext(shareWith); + _ctx.setContextCreationFlags(additionalCtxCreationFlags); + return _ctx; + } + return null; } - + @Override public void setRealized(boolean realized) { } @@ -694,11 +699,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } @Override - public void setContext(GLContext ctx) { - context=(GLContextImpl)ctx; - if(null != context) { - context.setContextCreationFlags(additionalCtxCreationFlags); - } + public GLContext setContext(GLContext newCtx) { + final GLContext oldCtx = context; + final boolean newCtxCurrent = drawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + context=(GLContextImpl)newCtx; + if(newCtxCurrent) { + context.makeCurrent(); + } + return oldCtx; } @Override @@ -744,6 +752,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public void setContextCreationFlags(int flags) { additionalCtxCreationFlags = flags; + if(null != context) { + context.setContextCreationFlags(additionalCtxCreationFlags); + } } @Override diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 152326006..c6c7cf9a1 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -456,16 +456,20 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void setContext(GLContext ctx) { - if (backend == null) { - return; - } - if(null != ctx) { - ctx.setContextCreationFlags(additionalCtxCreationFlags); - } - backend.setContext(ctx); + public GLContext setContext(GLContext newCtx) { + if (backend == null) { + return null; + } + final GLContext oldCtx = backend.getContext(); + final boolean newCtxCurrent = drawableHelper.switchContext(backend.getDrawable(), oldCtx, newCtx, additionalCtxCreationFlags); + backend.setContext(newCtx); + if(newCtxCurrent) { + newCtx.makeCurrent(); + } + return oldCtx; } + @Override public GLContext getContext() { if (backend == null) { @@ -1160,7 +1164,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void setContext(GLContext ctx) { - if (pbuffer == null && Beans.isDesignTime()) { + if (pbuffer == null || Beans.isDesignTime()) { return; } pbuffer.setContext(ctx); @@ -1169,7 +1173,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public GLContext getContext() { // Workaround for crashes in NetBeans GUI builder - if (pbuffer == null && Beans.isDesignTime()) { + if (null == pbuffer || Beans.isDesignTime()) { return null; } return pbuffer.getContext(); diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java new file mode 100644 index 000000000..3f50fe420 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -0,0 +1,337 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.opengl; + +import java.io.PrintStream; + +import javax.media.nativewindow.NativeSurface; +import javax.media.opengl.FPSCounter; +import javax.media.opengl.GL; +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLAutoDrawableDelegate; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; +import javax.media.opengl.GLRunnable; + +import com.jogamp.opengl.util.Animator; + + +/** + * Abstract common code for GLAutoDrawable implementations. + * + * @see GLAutoDrawable + * @see GLAutoDrawableDelegate + * @see GLPBufferImpl + * @see GLWindow + */ +public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { + public static final boolean DEBUG = Debug.debug("GLAutoDrawable"); + + protected final GLDrawableHelper helper = new GLDrawableHelper(); + protected final FPSCounterImpl fpsCounter = new FPSCounterImpl(); + + protected GLDrawableImpl drawable; + protected GLContextImpl context; + protected int additionalCtxCreationFlags = 0; + protected boolean sendReshape = false; + protected boolean sendDestroy = false; + + public GLAutoDrawableBase(GLDrawableImpl drawable, GLContextImpl context) { + this.drawable = drawable; + this.context = context; + resetFPSCounter(); + } + + /** Returns the delegated GLDrawable */ + public final GLDrawable getDelegatedDrawable() { return drawable; } + + protected void defaultRepaintOp() { + if( null != drawable && drawable.isRealized() ) { + if( !drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isAnimatorAnimating() ) { + display(); + } + } + } + + protected void defaultReshapeOp() { + if( null!=drawable ) { + if(DEBUG) { + System.err.println("GLAutoDrawableBase.sizeChanged: ("+Thread.currentThread().getName()+"): "+getWidth()+"x"+getHeight()+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + } + sendReshape = true; + defaultRepaintOp(); + } + } + + // + // GLAutoDrawable + // + + protected final Runnable defaultInitAction = new Runnable() { + @Override + public final void run() { + // Lock: Locked Surface/Window by MakeCurrent/Release + helper.init(GLAutoDrawableBase.this); + resetFPSCounter(); + } }; + + protected final Runnable defaultDisplayAction = new Runnable() { + @Override + public final void run() { + // Lock: Locked Surface/Window by display _and_ MakeCurrent/Release + if (sendReshape) { + helper.reshape(GLAutoDrawableBase.this, 0, 0, getWidth(), getHeight()); + sendReshape = false; + } + helper.display(GLAutoDrawableBase.this); + fpsCounter.tickFPS(); + } }; + + @Override + public final GLContext getContext() { + return context; + } + + @Override + public final GLContext setContext(GLContext newCtx) { + final GLContext oldCtx = context; + final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + context=(GLContextImpl)newCtx; + if(newCtxCurrent) { + context.makeCurrent(); + } + return oldCtx; + } + + @Override + public final GL getGL() { + if (context == null) { + return null; + } + return context.getGL(); + } + + @Override + public final GL setGL(GL gl) { + if (context != null) { + context.setGL(gl); + return gl; + } + return null; + } + + @Override + public final void addGLEventListener(GLEventListener listener) { + helper.addGLEventListener(listener); + } + + @Override + public final void addGLEventListener(int index, GLEventListener listener) + throws IndexOutOfBoundsException { + helper.addGLEventListener(index, listener); + } + + @Override + public final void removeGLEventListener(GLEventListener listener) { + helper.removeGLEventListener(listener); + } + + @Override + public final void setAnimator(GLAnimatorControl animatorControl) + throws GLException { + helper.setAnimator(animatorControl); + } + + @Override + public final GLAnimatorControl getAnimator() { + return helper.getAnimator(); + } + + @Override + public final void invoke(boolean wait, GLRunnable glRunnable) { + helper.invoke(this, wait, glRunnable); + } + + @Override + public final void setAutoSwapBufferMode(boolean enable) { + helper.setAutoSwapBufferMode(enable); + } + + @Override + public final boolean getAutoSwapBufferMode() { + return helper.getAutoSwapBufferMode(); + } + + @Override + public final void setContextCreationFlags(int flags) { + additionalCtxCreationFlags = flags; + if(null != context) { + context.setContextCreationFlags(additionalCtxCreationFlags); + } + } + + @Override + public final int getContextCreationFlags() { + return additionalCtxCreationFlags; + } + + // + // FPSCounter + // + + @Override + public final void setUpdateFPSFrames(int frames, PrintStream out) { + fpsCounter.setUpdateFPSFrames(frames, out); + } + + @Override + public final void resetFPSCounter() { + fpsCounter.resetFPSCounter(); + } + + @Override + public final int getUpdateFPSFrames() { + return fpsCounter.getUpdateFPSFrames(); + } + + @Override + public final long getFPSStartTime() { + return fpsCounter.getFPSStartTime(); + } + + @Override + public final long getLastFPSUpdateTime() { + return fpsCounter.getLastFPSUpdateTime(); + } + + @Override + public final long getLastFPSPeriod() { + return fpsCounter.getLastFPSPeriod(); + } + + @Override + public final float getLastFPS() { + return fpsCounter.getLastFPS(); + } + + @Override + public final int getTotalFPSFrames() { + return fpsCounter.getTotalFPSFrames(); + } + + @Override + public final long getTotalFPSDuration() { + return fpsCounter.getTotalFPSDuration(); + } + + @Override + public final float getTotalFPS() { + return fpsCounter.getTotalFPS(); + } + + // + // GLDrawable delegation + // + + @Override + public final GLContext createContext(final GLContext shareWith) { + if(drawable != null) { + final GLContext _ctx = drawable.createContext(shareWith); + _ctx.setContextCreationFlags(additionalCtxCreationFlags); + return _ctx; + } + return null; + } + + @Override + public final boolean isRealized() { + return null != drawable ? drawable.isRealized() : false; + } + + @Override + public int getWidth() { + return null != drawable ? drawable.getWidth() : 0; + } + + @Override + public int getHeight() { + return null != drawable ? drawable.getHeight() : 0; + } + + /** + * @param t the thread for which context release shall be skipped, usually the animation thread, + * ie. {@link Animator#getThread()}. + * @deprecated this is an experimental feature, + * intended for measuring performance in regards to GL context switch + */ + @Deprecated + public void setSkipContextReleaseThread(Thread t) { + helper.setSkipContextReleaseThread(t); + } + + /** + * @deprecated see {@link #setSkipContextReleaseThread(Thread)} + */ + @Deprecated + public Thread getSkipContextReleaseThread() { + return helper.getSkipContextReleaseThread(); + } + + @Override + public final void swapBuffers() throws GLException { + if(drawable!=null && context != null) { + drawable.swapBuffers(); + } + } + + @Override + public final GLCapabilitiesImmutable getChosenGLCapabilities() { + return null != drawable ? drawable.getChosenGLCapabilities() : null; + } + + @Override + public final GLProfile getGLProfile() { + return null != drawable ? drawable.getGLProfile() : null; + } + + @Override + public final NativeSurface getNativeSurface() { + return null != drawable ? drawable.getNativeSurface() : null; + } + + @Override + public final long getHandle() { + return null != drawable ? drawable.getHandle() : 0; + } +} diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 3c60eb699..e5c44a8d4 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -130,8 +130,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { throw new IllegalArgumentException("Null target"); } final MutableGraphicsConfiguration config = (MutableGraphicsConfiguration) target.getGraphicsConfiguration(); - GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - AbstractGraphicsDevice adevice = config.getScreen().getDevice(); + final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final AbstractGraphicsDevice adevice = config.getScreen().getDevice(); GLDrawable result = null; adevice.lock(); try { @@ -183,7 +183,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { //--------------------------------------------------------------------------- // - // PBuffer GLDrawable construction + // PBuffer Offscreen GLDrawable construction // public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device); @@ -226,7 +226,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { return new GLPbufferImpl( drawable, shareWith); } - //--------------------------------------------------------------------------- // // Offscreen GLDrawable construction diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index 0ed3be48b..d98b41bdc 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -41,38 +41,26 @@ package jogamp.opengl; import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeSurface; -import javax.media.opengl.GL; -import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLPbuffer; -import javax.media.opengl.GLProfile; -import javax.media.opengl.GLRunnable; - -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; /** Platform-independent class exposing pbuffer functionality to applications. This class is not exposed in the public API as it would probably add no value; however it implements the GLDrawable interface so can be interacted with via its display() method. */ -public class GLPbufferImpl implements GLPbuffer { - private GLDrawableImpl pbufferDrawable; - private GLContextImpl context; - private GLDrawableHelper drawableHelper = new GLDrawableHelper(); +public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { private int floatMode; - private int additionalCtxCreationFlags = 0; public GLPbufferImpl(GLDrawableImpl pbufferDrawable, - GLContext parentContext) { + GLContext sharedContext) { + super(pbufferDrawable, null); // drawable := pbufferDrawable + GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) - pbufferDrawable.getNativeSurface().getGraphicsConfiguration().getChosenCapabilities(); + drawable.getNativeSurface().getGraphicsConfiguration().getChosenCapabilities(); if(caps.isOnscreen()) { if(caps.isPBuffer()) { throw new IllegalArgumentException("Error: Given drawable is Onscreen and Pbuffer: "+pbufferDrawable); @@ -83,40 +71,63 @@ public class GLPbufferImpl implements GLPbuffer { throw new IllegalArgumentException("Error: Given drawable is not Pbuffer: "+pbufferDrawable); } } - this.pbufferDrawable = pbufferDrawable; - context = (GLContextImpl) pbufferDrawable.createContext(parentContext); + context = (GLContextImpl) drawable.createContext(sharedContext); } + // + // pbuffer specifics + // + @Override - public final GLContext createContext(GLContext shareWith) { - return pbufferDrawable.createContext(shareWith); + public void bindTexture() { + // Doesn't make much sense to try to do this on the event dispatch + // thread given that it has to be called while the context is current + context.bindPbufferToTexture(); } @Override - public final void setRealized(boolean realized) { + public void releaseTexture() { + // Doesn't make much sense to try to do this on the event dispatch + // thread given that it has to be called while the context is current + context.releasePbufferFromTexture(); } @Override - public final boolean isRealized() { - return true; + public int getFloatingPointMode() { + if (floatMode == 0) { + throw new GLException("Pbuffer not initialized, or floating-point support not requested"); + } + return floatMode; } + // + // GLDrawable delegation + // + + @Override + public final void setRealized(boolean realized) { + } + + // + // GLAutoDrawable completion + // + @Override public void destroy() { - if(pbufferDrawable.isRealized()) { - final AbstractGraphicsDevice adevice = pbufferDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); + if(drawable.isRealized()) { + final AbstractGraphicsDevice adevice = drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); if (null != context && context.isCreated()) { try { - drawableHelper.disposeGL(GLPbufferImpl.this, pbufferDrawable, context, null); + helper.disposeGL(GLPbufferImpl.this, drawable, context, null); } catch (GLException gle) { gle.printStackTrace(); } context = null; // drawableHelper.reset(); } - pbufferDrawable.destroy(); - pbufferDrawable = null; + drawable.destroy(); + drawable = null; if(null != adevice) { adevice.close(); @@ -124,217 +135,26 @@ public class GLPbufferImpl implements GLPbuffer { } } - public void setSize(int width, int height) { - // FIXME - throw new GLException("Not yet implemented"); - } - - @Override - public NativeSurface getNativeSurface() { - return pbufferDrawable.getNativeSurface(); - } - - @Override - public long getHandle() { - return pbufferDrawable.getHandle(); - } - @Override public GLDrawableFactory getFactory() { - return pbufferDrawable.getFactory(); - } - - @Override - public int getWidth() { - return pbufferDrawable.getWidth(); - } - - @Override - public int getHeight() { - return pbufferDrawable.getHeight(); + return drawable.getFactory(); } @Override public void display() { - invokeGL(displayAction); - } - - public void repaint() { - display(); - } - - @Override - public void addGLEventListener(GLEventListener listener) { - drawableHelper.addGLEventListener(listener); - } - - @Override - public void addGLEventListener(int index, GLEventListener listener) { - drawableHelper.addGLEventListener(index, listener); - } - - @Override - public void removeGLEventListener(GLEventListener listener) { - drawableHelper.removeGLEventListener(listener); - } - - @Override - public void setAnimator(GLAnimatorControl animatorControl) { - drawableHelper.setAnimator(animatorControl); - } - - @Override - public GLAnimatorControl getAnimator() { - return drawableHelper.getAnimator(); - } - - @Override - public void invoke(boolean wait, GLRunnable glRunnable) { - drawableHelper.invoke(this, wait, glRunnable); - } - - @Override - public void setContext(GLContext ctx) { - context=(GLContextImpl)ctx; - if(null != context) { - context.setContextCreationFlags(additionalCtxCreationFlags); - } - } - - @Override - public GLContext getContext() { - return context; - } - - public GLDrawable getDrawable() { - return pbufferDrawable; - } - - @Override - public GL getGL() { - return getContext().getGL(); - } - - @Override - public GL setGL(GL gl) { - return getContext().setGL(gl); - } - - @Override - public void setAutoSwapBufferMode(boolean onOrOff) { - drawableHelper.setAutoSwapBufferMode(onOrOff); - } - - @Override - public boolean getAutoSwapBufferMode() { - return drawableHelper.getAutoSwapBufferMode(); - } - - @Override - public void swapBuffers() { - invokeGL(swapBuffersAction); - } - - @Override - public void setContextCreationFlags(int flags) { - additionalCtxCreationFlags = flags; - if(null != context) { - context.setContextCreationFlags(additionalCtxCreationFlags); - } - } - - @Override - public int getContextCreationFlags() { - return additionalCtxCreationFlags; - } - - @Override - public void bindTexture() { - // Doesn't make much sense to try to do this on the event dispatch - // thread given that it has to be called while the context is current - context.bindPbufferToTexture(); - } - - @Override - public void releaseTexture() { - // Doesn't make much sense to try to do this on the event dispatch - // thread given that it has to be called while the context is current - context.releasePbufferFromTexture(); - } - - @Override - public GLCapabilitiesImmutable getChosenGLCapabilities() { - if (pbufferDrawable == null) - return null; - - return pbufferDrawable.getChosenGLCapabilities(); - } - - public GLCapabilitiesImmutable getRequestedGLCapabilities() { - if (pbufferDrawable == null) - return null; - - return pbufferDrawable.getRequestedGLCapabilities(); - } - - @Override - public GLProfile getGLProfile() { - if (pbufferDrawable == null) - return null; - - return pbufferDrawable.getGLProfile(); - } - - private RecursiveLock recurLock = LockFactory.createRecursiveLock(); - - public int lockSurface() throws GLException { - recurLock.lock(); - return NativeSurface.LOCK_SUCCESS; - } - - public void unlockSurface() { - recurLock.unlock(); - } - - @Override - public int getFloatingPointMode() { - if (floatMode == 0) { - throw new GLException("Pbuffer not initialized, or floating-point support not requested"); - } - return floatMode; + if( null == drawable || !drawable.isRealized() || null == context ) { return; } + helper.invokeGL(drawable, context, defaultDisplayAction, initAction); } //---------------------------------------------------------------------- // Internals only below this point // - private void invokeGL(Runnable invokeGLAction) { - drawableHelper.invokeGL(pbufferDrawable, context, invokeGLAction, initAction); - } - - - class InitAction implements Runnable { + protected final Runnable initAction = new Runnable() { @Override - public void run() { - floatMode = context.getFloatingPointMode(); - drawableHelper.init(GLPbufferImpl.this); - } - } - private InitAction initAction = new InitAction(); - - class DisplayAction implements Runnable { - @Override - public void run() { - drawableHelper.display(GLPbufferImpl.this); - } - } - private DisplayAction displayAction = new DisplayAction(); - - class SwapBuffersAction implements Runnable { - @Override - public void run() { - pbufferDrawable.swapBuffers(); - } - } - private SwapBuffersAction swapBuffersAction = new SwapBuffersAction(); + public final void run() { + floatMode = context.getFloatingPointMode(); + defaultInitAction.run(); + } }; + } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index bff1efcb5..6a328ed07 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -34,8 +34,6 @@ package com.jogamp.newt.opengl; -import java.io.PrintStream; - import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; @@ -53,16 +51,15 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import javax.media.opengl.GLRunnable; import jogamp.newt.WindowImpl; -import jogamp.opengl.FPSCounterImpl; -import jogamp.opengl.GLDrawableHelper; +import jogamp.opengl.GLAutoDrawableBase; +import jogamp.opengl.GLContextImpl; +import jogamp.opengl.GLDrawableImpl; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.VersionUtil; @@ -78,7 +75,6 @@ import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.WindowUpdateEvent; import com.jogamp.opengl.JoglVersion; -import com.jogamp.opengl.util.Animator; /** * An implementation of {@link GLAutoDrawable} and {@link Window} interface, @@ -100,30 +96,25 @@ import com.jogamp.opengl.util.Animator; GLAutoDrawable implementations, she is safe due to the implicit locked state. *

*/ -public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter { +public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter { private final WindowImpl window; /** * Constructor. Do not call this directly -- use {@link #create()} instead. */ protected GLWindow(Window window) { - resetFPSCounter(); + super(null, null); this.window = (WindowImpl) window; this.window.setHandleDestroyNotify(false); window.addWindowListener(new WindowAdapter() { @Override public void windowRepaint(WindowUpdateEvent e) { - if( !GLWindow.this.window.isWindowLockedByOtherThread() && !GLWindow.this.helper.isAnimatorAnimating() ) { - display(); - } + defaultRepaintOp(); } @Override public void windowResized(WindowEvent e) { - sendReshape = true; - if( !GLWindow.this.window.isWindowLockedByOtherThread() && !GLWindow.this.helper.isAnimatorAnimating() ) { - display(); - } + defaultReshapeOp(); } @Override @@ -132,7 +123,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC // Is an animator thread perform rendering? if (GLWindow.this.helper.isExternalAnimatorRunning()) { // Pause animations before initiating safe destroy. - GLAnimatorControl ctrl = GLWindow.this.helper.getAnimator(); + final GLAnimatorControl ctrl = GLWindow.this.helper.getAnimator(); boolean isPaused = ctrl.pause(); destroy(); if(isPaused) { @@ -342,6 +333,26 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC return window.getInsets(); } + @Override + public final int getX() { + return window.getX(); + } + + @Override + public final int getY() { + return window.getY(); + } + + @Override + public final int getWidth() { + return window.getWidth(); + } + + @Override + public final int getHeight() { + return window.getHeight(); + } + @Override public final void setPosition(int x, int y) { window.setPosition(x, y); @@ -495,10 +506,10 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC factory = GLDrawableFactory.getFactory(glCaps.getGLProfile()); } if(null==drawable) { - drawable = factory.createGLDrawable(nw); + drawable = (GLDrawableImpl) factory.createGLDrawable(nw); } drawable.setRealized(true); - context = drawable.createContext(sharedContext); + context = (GLContextImpl) drawable.createContext(sharedContext); context.setContextCreationFlags(additionalCtxCreationFlags); } if(Window.DEBUG_IMPLEMENTATION) { @@ -531,20 +542,6 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC // private GLContext sharedContext = null; - private int additionalCtxCreationFlags = 0; - 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 final FPSCounterImpl fpsCounter = new FPSCounterImpl(); - - @Override - public GLDrawableFactory getFactory() { - return factory; - } /** * Specifies an {@link javax.media.opengl.GLContext OpenGL context} to share with.
@@ -558,79 +555,6 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC this.sharedContext = sharedContext; } - @Override - public void setContext(GLContext newCtx) { - context = newCtx; - if(null != context) { - context.setContextCreationFlags(additionalCtxCreationFlags); - } - } - - @Override - public GLContext getContext() { - return context; - } - - @Override - public GL getGL() { - if (context == null) { - return null; - } - return context.getGL(); - } - - @Override - public GL setGL(GL gl) { - if (context != null) { - context.setGL(gl); - return gl; - } - return null; - } - - @Override - public void addGLEventListener(GLEventListener listener) { - if(null!=helper) { - helper.addGLEventListener(listener); - } - } - - @Override - public void addGLEventListener(int index, GLEventListener listener) { - if(null!=helper) { - helper.addGLEventListener(index, listener); - } - } - - @Override - public void removeGLEventListener(GLEventListener listener) { - if(null!=helper) { - helper.removeGLEventListener(listener); - } - } - - @Override - public void setAnimator(GLAnimatorControl animatorControl) { - if(null!=helper) { - helper.setAnimator(animatorControl); - } - } - - @Override - public GLAnimatorControl getAnimator() { - if(null!=helper) { - return helper.getAnimator(); - } - return null; - } - - @Override - public void invoke(boolean wait, GLRunnable glRunnable) { - if(null!=helper) { - helper.invoke(this, wait, glRunnable); - } - } - @Override public void display() { if( !isNativeValid() || !isVisible() ) { return; } @@ -650,215 +574,27 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC if( null != context ) { // surface is locked/unlocked implicit by context's makeCurrent/release - helper.invokeGL(drawable, context, displayAction, initAction); + helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction); } } finally { window.unlockWindow(); } } - @Override - public void setAutoSwapBufferMode(boolean enable) { - if(null!=helper) { - helper.setAutoSwapBufferMode(enable); - } - } - - @Override - public boolean getAutoSwapBufferMode() { - if(null!=helper) { - return helper.getAutoSwapBufferMode(); - } - return false; - } - - /** - * @param t the thread for which context release shall be skipped, usually the animation thread, - * ie. {@link Animator#getThread()}. - * @deprecated this is an experimental feature, - * intended for measuring performance in regards to GL context switch - */ - @Deprecated - public void setSkipContextReleaseThread(Thread t) { - if(null!=helper) { - helper.setSkipContextReleaseThread(t); - } - } - - /** - * @deprecated see {@link #setSkipContextReleaseThread(Thread)} - */ - @Deprecated - public Thread getSkipContextReleaseThread() { - if(null!=helper) { - return helper.getSkipContextReleaseThread(); - } - return null; - } - - @Override - public void swapBuffers() { - if(drawable!=null && context != null) { - drawable.swapBuffers(); - } - } - - @Override - public void setContextCreationFlags(int flags) { - additionalCtxCreationFlags = flags; - } - - @Override - public int getContextCreationFlags() { - return additionalCtxCreationFlags; - } - - private class InitAction implements Runnable { - @Override - public final void run() { - // Lock: Locked Surface/Window by MakeCurrent/Release - helper.init(GLWindow.this); - resetFPSCounter(); - } - } - private InitAction initAction = new InitAction(); - - private class DisplayAction implements Runnable { - @Override - public final void run() { - // Lock: Locked Surface/Window by display _and_ MakeCurrent/Release - if (sendReshape) { - helper.reshape(GLWindow.this, 0, 0, getWidth(), getHeight()); - sendReshape = false; - } - - helper.display(GLWindow.this); - - fpsCounter.tickFPS(); - } - } - private DisplayAction displayAction = new DisplayAction(); - - @Override - public final void setUpdateFPSFrames(int frames, PrintStream out) { - fpsCounter.setUpdateFPSFrames(frames, out); - } - - @Override - public final void resetFPSCounter() { - fpsCounter.resetFPSCounter(); - } - - @Override - public final int getUpdateFPSFrames() { - return fpsCounter.getUpdateFPSFrames(); - } - - @Override - public final long getFPSStartTime() { - return fpsCounter.getFPSStartTime(); - } - - @Override - public final long getLastFPSUpdateTime() { - return fpsCounter.getLastFPSUpdateTime(); - } - - @Override - public final long getLastFPSPeriod() { - return fpsCounter.getLastFPSPeriod(); - } - - @Override - public final float getLastFPS() { - return fpsCounter.getLastFPS(); - } - - @Override - public final int getTotalFPSFrames() { - return fpsCounter.getTotalFPSFrames(); - } - - @Override - public final long getTotalFPSDuration() { - return fpsCounter.getTotalFPSDuration(); - } - - @Override - public final float getTotalFPS() { - return fpsCounter.getTotalFPS(); - } - //---------------------------------------------------------------------- // GLDrawable methods // + private GLDrawableFactory factory; @Override - public final NativeSurface getNativeSurface() { - return null!=drawable ? drawable.getNativeSurface() : null; - } - - @Override - public final long getHandle() { - return null!=drawable ? drawable.getHandle() : 0; - } - - @Override - public final int getX() { - return window.getX(); - } - - @Override - public final int getY() { - return window.getY(); - } - - @Override - public final int getWidth() { - return window.getWidth(); - } - - @Override - public final int getHeight() { - return window.getHeight(); - } - - //---------------------------------------------------------------------- - // GLDrawable methods that are not really needed - // - - @Override - public final GLContext createContext(GLContext shareWith) { - return drawable.createContext(shareWith); + public GLDrawableFactory getFactory() { + return factory; } @Override public final void setRealized(boolean realized) { } - @Override - public final boolean isRealized() { - return ( null != drawable ) ? drawable.isRealized() : false; - } - - @Override - public final GLCapabilitiesImmutable getChosenGLCapabilities() { - if (drawable == null) { - throw new GLException("No drawable yet"); - } - - return drawable.getChosenGLCapabilities(); - } - - @Override - public final GLProfile getGLProfile() { - if (drawable == null) { - throw new GLException("No drawable yet"); - } - - return drawable.getGLProfile(); - } - //---------------------------------------------------------------------- // NEWTEventConsumer // diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java new file mode 100644 index 000000000..be9ae223b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java @@ -0,0 +1,116 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawableDelegate; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; + +import org.junit.Test; + +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowUpdateEvent; +import com.jogamp.opengl.util.Animator; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.NEWTGLContext; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; + +public class TestGLAutoDrawableDelegateNEWT extends UITestCase { + + @Test + public void test01() throws GLException, InterruptedException { + final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow( + new GLCapabilities(GLProfile.getGL2ES2()), 640, 480, false); + winctx.context.release(); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(winctx.drawable, winctx.context); + glad.addGLEventListener(new GearsES2(1)); + + // add basic window interaction + winctx.window.addWindowListener(new WindowAdapter() { + @Override + public void windowRepaint(WindowUpdateEvent e) { + glad.defaultRepaintOp(); + } + @Override + public void windowResized(WindowEvent e) { + glad.defaultReshapeOp(); + } + @Override + public void windowDestroyNotify(WindowEvent e) { + final GLAnimatorControl ctrl = glad.getAnimator(); + boolean isPaused = ctrl.pause(); + glad.destroy(); + NEWTGLContext.destroyWindow(winctx); + if(isPaused) { + ctrl.resume(); + } + } + }); + + final QuitAdapter quitAdapter = new QuitAdapter(); + winctx.window.addWindowListener(quitAdapter); + + final Animator animator = new Animator(glad); + animator.setUpdateFPSFrames(60, null); + animator.start(); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() Date: Wed, 4 Jul 2012 18:02:11 +0200 Subject: GLAutoDrawable* refinement of abstraction / generalization - API Change! - GLAutoDrawable (compat change - recompile): - 'void invoke(boolean wait, GLRunnable glRunnable)' -> 'boolean invoke(boolean wait, GLRunnable glRunnable)' Allows notifying caller whether the task has been executed or at least enqueued. - GLAutoDrawable add 'GLEventListener removeGLEventListener(int index)' - This allow one to remove a specific GLEventListener and reusing it (return value). - GLDrawableImpl remove 'destroy()' to favor 'setRealized(false)' - Using more common code of GLAutoDrawableBase, i.e. GLPbufferImpl can use defaultDestroyOp(). - Removes redundancy of methods - GLAutoDrawableBase/Delegate - better 'default' names to emphasize it's purpose, adding API doc - includes more generic functionality - defaultWindowDestroyNotify() - defaultDestroyOp() - TestGLAutoDrawableDelegateNEWT demonstrates a simple example w/ all window events handled. - Fix TestParenting01cSwingAWT's threading use (gl disturbance thread) --- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 46 ++++--- .../classes/javax/media/opengl/GLAutoDrawable.java | 52 +++++-- .../javax/media/opengl/GLAutoDrawableDelegate.java | 68 +++++++--- .../classes/javax/media/opengl/awt/GLCanvas.java | 43 +++--- .../classes/javax/media/opengl/awt/GLJPanel.java | 39 +++--- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 83 ++++++++++-- .../classes/jogamp/opengl/GLDrawableHelper.java | 149 +++++++++++++++++---- src/jogl/classes/jogamp/opengl/GLDrawableImpl.java | 16 +-- src/jogl/classes/jogamp/opengl/GLPbufferImpl.java | 26 +--- src/jogl/classes/jogamp/opengl/GLRunnableTask.java | 39 +++++- .../jogamp/opengl/egl/EGLPbufferDrawable.java | 5 - .../opengl/macosx/cgl/MacOSXCGLDrawable.java | 3 +- .../macosx/cgl/MacOSXCGLDrawableFactory.java | 2 +- .../macosx/cgl/MacOSXPbufferCGLDrawable.java | 5 - .../windows/wgl/WindowsBitmapWGLDrawable.java | 5 - .../windows/wgl/WindowsDummyWGLDrawable.java | 15 ++- .../windows/wgl/WindowsPbufferWGLDrawable.java | 5 - .../opengl/windows/wgl/WindowsWGLDrawable.java | 16 +-- .../windows/wgl/WindowsWGLDrawableFactory.java | 2 +- .../jogamp/opengl/x11/glx/X11DummyGLXDrawable.java | 16 ++- .../opengl/x11/glx/X11GLXDrawableFactory.java | 2 +- .../opengl/x11/glx/X11PbufferGLXDrawable.java | 5 - .../opengl/x11/glx/X11PixmapGLXDrawable.java | 5 - .../classes/com/jogamp/newt/opengl/GLWindow.java | 42 +----- .../jogl/acore/TestGLAutoDrawableDelegateNEWT.java | 84 ++++++++---- .../newt/parenting/TestParenting01cSwingAWT.java | 112 +++++++++++----- .../junit/newt/parenting/TestParenting02NEWT.java | 8 +- 27 files changed, 582 insertions(+), 311 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 31b679077..62b496891 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -107,7 +107,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { //private static final boolean useSWTThread = ThreadingImpl.getMode() != ThreadingImpl.WORKER; /* GL Stuff */ - private final GLDrawableHelper drawableHelper = new GLDrawableHelper(); + private final GLDrawableHelper helper = new GLDrawableHelper(); private volatile GLDrawable drawable; // volatile avoids locking all accessors. FIXME still need to sync destroy/display private GLContext context; @@ -130,7 +130,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final Runnable initAction = new Runnable() { @Override public void run() { - drawableHelper.init(GLCanvas.this); + helper.init(GLCanvas.this); } }; @@ -143,10 +143,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public void run() { if (sendReshape) { - drawableHelper.reshape(GLCanvas.this, 0, 0, getWidth(), getHeight()); + helper.reshape(GLCanvas.this, 0, 0, getWidth(), getHeight()); sendReshape = false; } - drawableHelper.display(GLCanvas.this); + helper.display(GLCanvas.this); } }; @@ -154,7 +154,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final Runnable makeCurrentAndDisplayAction = new Runnable() { @Override public void run() { - drawableHelper.invokeGL(drawable, context, displayAction, initAction); + helper.invokeGL(drawable, context, displayAction, initAction); } }; @@ -170,7 +170,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final Runnable makeCurrentAndSwapBuffersAction = new Runnable() { @Override public void run() { - drawableHelper.invokeGL(drawable, context, swapBuffersAction, initAction); + helper.invokeGL(drawable, context, swapBuffersAction, initAction); } }; @@ -191,7 +191,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final Runnable disposeOnEDTGLAction = new Runnable() { @Override public void run() { - drawableHelper.disposeGL(GLCanvas.this, drawable, context, postDisposeGLAction); + helper.disposeGL(GLCanvas.this, drawable, context, postDisposeGLAction); } }; @@ -266,7 +266,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { addPaintListener(new PaintListener() { @Override public void paintControl(final PaintEvent arg0) { - if (!drawableHelper.isExternalAnimatorAnimating()) { + if (!helper.isExternalAnimatorAnimating()) { display(); } } @@ -284,12 +284,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public void addGLEventListener(final GLEventListener arg0) { - drawableHelper.addGLEventListener(arg0); + helper.addGLEventListener(arg0); } @Override public void addGLEventListener(final int arg0, final GLEventListener arg1) throws IndexOutOfBoundsException { - drawableHelper.addGLEventListener(arg0, arg1); + helper.addGLEventListener(arg0, arg1); } /** @@ -312,12 +312,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLAnimatorControl getAnimator() { - return drawableHelper.getAnimator(); + return helper.getAnimator(); } @Override public boolean getAutoSwapBufferMode() { - return drawableHelper.getAutoSwapBufferMode(); + return helper.getAutoSwapBufferMode(); } @Override @@ -336,30 +336,34 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } @Override - public void invoke(final boolean wait, final GLRunnable run) { - /* Queue task for running during the next display(). */ - drawableHelper.invoke(this, wait, run); + public boolean invoke(final boolean wait, final GLRunnable run) { + return helper.invoke(this, wait, run); } @Override public void removeGLEventListener(final GLEventListener arg0) { - drawableHelper.removeGLEventListener(arg0); + helper.removeGLEventListener(arg0); } + @Override + public GLEventListener removeGLEventListener(int index) throws IndexOutOfBoundsException { + return helper.removeGLEventListener(index); + } + @Override public void setAnimator(final GLAnimatorControl arg0) throws GLException { - drawableHelper.setAnimator(arg0); + helper.setAnimator(arg0); } @Override public void setAutoSwapBufferMode(final boolean arg0) { - drawableHelper.setAutoSwapBufferMode(arg0); + helper.setAutoSwapBufferMode(arg0); } @Override public GLContext setContext(GLContext newCtx) { final GLContext oldCtx = context; - final boolean newCtxCurrent = drawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; if(newCtxCurrent) { context.makeCurrent(); @@ -477,7 +481,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { if (Threading.isSingleThreaded() && !Threading.isOpenGLThread()) { runInDesignatedGLThread(disposeOnEDTGLAction); } else if (context.isCreated()) { - drawableHelper.disposeGL(GLCanvas.this, drawable, context, postDisposeGLAction); + helper.disposeGL(GLCanvas.this, drawable, context, postDisposeGLAction); } } @@ -537,7 +541,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { runInDesignatedGLThread(asyncAction); } else { /* Run in current thread... */ - drawableHelper.invokeGL(drawable, context, syncAction, initAction); + helper.invokeGL(drawable, context, syncAction, initAction); } } diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index e4aaad23d..80d4f796c 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -165,16 +165,32 @@ public interface GLAutoDrawable extends GLDrawable { * @param listener The GLEventListener object to be inserted * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index <= size()), or -1 */ - public void addGLEventListener(int index, GLEventListener listener) - throws IndexOutOfBoundsException; + public void addGLEventListener(int index, GLEventListener listener) throws IndexOutOfBoundsException; - /** Removes a {@link GLEventListener} from this drawable. Note that - if this is done from within a particular drawable's {@link - GLEventListener} handler (reshape, display, etc.) that it is not - guaranteed that all other listeners will be evaluated properly - during this update cycle. */ + /** + * Removes a {@link GLEventListener} from this drawable. + * Note that if this is done from within a particular drawable's + * {@link GLEventListener} handler (reshape, display, etc.) that it is not + * guaranteed that all other listeners will be evaluated properly + * during this update cycle. + * @param listener The GLEventListener object to be removed + */ public void removeGLEventListener(GLEventListener listener); + /** + * Removes a {@link GLEventListener} at the given index from this drawable. + * Note that if this is done from within a particular drawable's + * {@link GLEventListener} handler (reshape, display, etc.) that it is not + * guaranteed that all other listeners will be evaluated properly + * during this update cycle. + * @param index Position of the listener to be removed. + * Should be within (0 <= index && index < size()). + * An index value of -1 is interpreted as last listener, size()-1. + * @return The removed GLEventListener object + * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index < size()), or -1 + */ + public GLEventListener removeGLEventListener(int index) throws IndexOutOfBoundsException; + /** *

* Registers the usage of an animator, an {@link javax.media.opengl.GLAnimatorControl} implementation. @@ -221,14 +237,30 @@ public interface GLAutoDrawable extends GLDrawable { *

* If an {@link GLAnimatorControl} is animating,
* no {@link #display()} call is issued, since the animator thread performs it.
- * If wait is true, the implementation waits until the GLRunnable is executed.
- *


+ *

+ *

+ * If wait is true the call blocks until the glRunnable + * has been executed.

+ *

+ * If wait is true and + * {@link #isRealized()} returns false or {@link #getContext()} returns null, + * the call is ignored and returns false.
+ * This helps avoiding deadlocking the caller. + *

+ *

+ * The internal queue of {@link GLRunnable}'s is being flushed with {@link #destroy()} + * where all blocked callers are being notified. + *

* + * @param wait if true block until execution of glRunnable is finished, otherwise return immediatly w/o waiting + * @param glRunnable the {@link GLRunnable} to execute within {@link #display()} + * @return true if the {@link GLRunnable} has been processed or queued, otherwise false. + * * @see #setAnimator(GLAnimatorControl) * @see #display() * @see GLRunnable */ - public void invoke(boolean wait, GLRunnable glRunnable); + public boolean invoke(boolean wait, GLRunnable glRunnable); /** Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext. diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java index 992bf9fee..89d5cc4cb 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java @@ -28,6 +28,9 @@ package javax.media.opengl; +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; + import jogamp.opengl.Debug; import jogamp.opengl.GLAutoDrawableBase; import jogamp.opengl.GLContextImpl; @@ -39,11 +42,16 @@ import jogamp.opengl.GLDrawableImpl; * utilizing already created created {@link GLDrawable} and {@link GLContext} instances. *

* Since no native windowing system events are being processed, it is recommended - * to handle at least {@link com.jogamp.newt.event.WindowListener#windowResized(com.jogamp.newt.event.WindowEvent) resize}, - * {@link com.jogamp.newt.event.WindowListener#windowDestroyNotify(com.jogamp.newt.event.WindowEvent) destroy-notify} - * and maybe {@link com.jogamp.newt.event.WindowListener#windowRepaint(com.jogamp.newt.event.WindowUpdateEvent) repaint}. - * The latter is only required if no {@link GLAnimatorControl} is being used. - *

+ * to handle at least: + *
    + *
  • {@link com.jogamp.newt.event.WindowListener#windowRepaint(com.jogamp.newt.event.WindowUpdateEvent) repaint} using {@link #defaultWindowRepaintOp()}
  • + *
  • {@link com.jogamp.newt.event.WindowListener#windowResized(com.jogamp.newt.event.WindowEvent) resize} using {@link #defaultWindowResizedOp()}
  • + *
  • {@link com.jogamp.newt.event.WindowListener#windowDestroyNotify(com.jogamp.newt.event.WindowEvent) destroy-notify} using {@link #defaultWindowDestroyNotifyOp()}
  • + *
+ *

+ *

+ * See example {@link com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT TestGLAutoDrawableDelegateNEWT}. + *

*/ public class GLAutoDrawableDelegate extends GLAutoDrawableBase { public static final boolean DEBUG = Debug.debug("GLAutoDrawableDelegate"); @@ -52,36 +60,64 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase { super((GLDrawableImpl)drawable, (GLContextImpl)context); } - public void defaultRepaintOp() { - super.defaultRepaintOp(); + // + // make protected methods accessible + // + + public void defaultWindowRepaintOp() { + super.defaultWindowRepaintOp(); + } + + public void defaultWindowResizedOp() { + super.defaultWindowResizedOp(); } - public void defaultReshapeOp() { - super.defaultReshapeOp(); + public void defaultWindowDestroyNotifyOp() { + super.defaultWindowDestroyNotifyOp(); } // // Complete GLAutoDrawable // + private RecursiveLock lock = LockFactory.createRecursiveLock(); // instance wide lock + /** * {@inheritDoc} *

- * This implementation simply removes references to drawable and context. + * This implementation calls {@link #defaultDestroyOp()}. + *

+ *

+ * User still needs to destroy the upstream window, which details are hidden from this aspect. *

*/ @Override public void destroy() { - drawable = null; - context = null; + lock.lock(); + try { + defaultDestroyOp(); + } finally { + lock.unlock(); + } } @Override public void display() { - if( null == drawable || !drawable.isRealized() || null == context ) { return; } - - // surface is locked/unlocked implicit by context's makeCurrent/release - helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction); + if( sendDestroy ) { + sendDestroy=false; + destroy(); + return; + } + + lock.lock(); // sync: context/drawable could been recreated/destroyed while animating + try { + if( null != drawable && drawable.isRealized() && null != context ) { + // surface is locked/unlocked implicit by context's makeCurrent/release + helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction); + } + } finally { + lock.unlock(); + } } // diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 8c6e594b5..3161f898d 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -153,7 +153,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private static final boolean DEBUG = Debug.debug("GLCanvas"); - private final GLDrawableHelper drawableHelper = new GLDrawableHelper(); + private final GLDrawableHelper helper = new GLDrawableHelper(); private AWTGraphicsConfiguration awtConfig; private volatile GLDrawable drawable; // volatile avoids locking all accessors. FIXME still need to sync destroy/display private GLContextImpl context; @@ -510,7 +510,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing (int) ((getHeight() + bounds.getHeight()) / 2)); return; } - if( ! this.drawableHelper.isAnimatorAnimating() ) { + if( ! this.helper.isAnimatorAnimating() ) { display(); } } @@ -670,38 +670,43 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public void addGLEventListener(GLEventListener listener) { - drawableHelper.addGLEventListener(listener); + helper.addGLEventListener(listener); } @Override - public void addGLEventListener(int index, GLEventListener listener) { - drawableHelper.addGLEventListener(index, listener); + public void addGLEventListener(int index, GLEventListener listener) throws IndexOutOfBoundsException { + helper.addGLEventListener(index, listener); } @Override public void removeGLEventListener(GLEventListener listener) { - drawableHelper.removeGLEventListener(listener); + helper.removeGLEventListener(listener); } + @Override + public GLEventListener removeGLEventListener(int index) throws IndexOutOfBoundsException { + return helper.removeGLEventListener(index); + } + @Override public void setAnimator(GLAnimatorControl animatorControl) { - drawableHelper.setAnimator(animatorControl); + helper.setAnimator(animatorControl); } @Override public GLAnimatorControl getAnimator() { - return drawableHelper.getAnimator(); + return helper.getAnimator(); } @Override - public void invoke(boolean wait, GLRunnable glRunnable) { - drawableHelper.invoke(this, wait, glRunnable); + public boolean invoke(boolean wait, GLRunnable glRunnable) { + return helper.invoke(this, wait, glRunnable); } @Override public GLContext setContext(GLContext newCtx) { final GLContext oldCtx = context; - final boolean newCtxCurrent = drawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; if(newCtxCurrent) { context.makeCurrent(); @@ -736,12 +741,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public void setAutoSwapBufferMode(boolean onOrOff) { - drawableHelper.setAutoSwapBufferMode(onOrOff); + helper.setAutoSwapBufferMode(onOrOff); } @Override public boolean getAutoSwapBufferMode() { - return drawableHelper.getAutoSwapBufferMode(); + return helper.getAutoSwapBufferMode(); } @Override @@ -849,7 +854,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private final Runnable disposeOnEDTAction = new Runnable() { @Override public void run() { - drawableHelper.disposeGL(GLCanvas.this, drawable, context, postDisposeAction); + helper.disposeGL(GLCanvas.this, drawable, context, postDisposeAction); } }; @@ -897,7 +902,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private final Runnable initAction = new Runnable() { @Override public void run() { - drawableHelper.init(GLCanvas.this); + helper.init(GLCanvas.this); } }; @@ -910,11 +915,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } // Note: we ignore the given x and y within the parent component // since we are drawing directly into this heavyweight component. - drawableHelper.reshape(GLCanvas.this, 0, 0, getWidth(), getHeight()); + helper.reshape(GLCanvas.this, 0, 0, getWidth(), getHeight()); sendReshape = false; } - drawableHelper.display(GLCanvas.this); + helper.display(GLCanvas.this); } }; @@ -931,14 +936,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private final Runnable displayOnEDTAction = new Runnable() { @Override public void run() { - drawableHelper.invokeGL(drawable, context, displayAction, initAction); + helper.invokeGL(drawable, context, displayAction, initAction); } }; private final Runnable swapBuffersOnEDTAction = new Runnable() { @Override public void run() { - drawableHelper.invokeGL(drawable, context, swapBuffersAction, initAction); + helper.invokeGL(drawable, context, swapBuffersAction, initAction); } }; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index c6c7cf9a1..cd18c5098 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -125,7 +125,7 @@ import com.jogamp.opengl.util.GLBuffers; public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("GLJPanel"); - private GLDrawableHelper drawableHelper = new GLDrawableHelper(); + private GLDrawableHelper helper = new GLDrawableHelper(); private volatile boolean isInitialized; // Data used for either pbuffers or pixmap-based offscreen surfaces @@ -413,32 +413,37 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void addGLEventListener(GLEventListener listener) { - drawableHelper.addGLEventListener(listener); + helper.addGLEventListener(listener); } @Override public void addGLEventListener(int index, GLEventListener listener) { - drawableHelper.addGLEventListener(index, listener); + helper.addGLEventListener(index, listener); } @Override public void removeGLEventListener(GLEventListener listener) { - drawableHelper.removeGLEventListener(listener); + helper.removeGLEventListener(listener); } + @Override + public GLEventListener removeGLEventListener(int index) throws IndexOutOfBoundsException { + return helper.removeGLEventListener(index); + } + @Override public void setAnimator(GLAnimatorControl animatorControl) { - drawableHelper.setAnimator(animatorControl); + helper.setAnimator(animatorControl); } @Override public GLAnimatorControl getAnimator() { - return drawableHelper.getAnimator(); + return helper.getAnimator(); } @Override - public void invoke(boolean wait, GLRunnable glRunnable) { - drawableHelper.invoke(this, wait, glRunnable); + public boolean invoke(boolean wait, GLRunnable glRunnable) { + return helper.invoke(this, wait, glRunnable); } @Override @@ -461,7 +466,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return null; } final GLContext oldCtx = backend.getContext(); - final boolean newCtxCurrent = drawableHelper.switchContext(backend.getDrawable(), oldCtx, newCtx, additionalCtxCreationFlags); + final boolean newCtxCurrent = helper.switchContext(backend.getDrawable(), oldCtx, newCtx, additionalCtxCreationFlags); backend.setContext(newCtx); if(newCtxCurrent) { newCtx.makeCurrent(); @@ -662,13 +667,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if (!backend.preGL(g)) { return; } - drawableHelper.init(GLJPanel.this); + helper.init(GLJPanel.this); backend.postGL(g, false); } @Override public void dispose(GLAutoDrawable drawable) { - drawableHelper.dispose(GLJPanel.this); + helper.dispose(GLJPanel.this); } @Override @@ -680,11 +685,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if (DEBUG) { System.err.println(getThreadName()+": GLJPanel.display: reshape(" + viewportX + "," + viewportY + " " + panelWidth + "x" + panelHeight + ")"); } - drawableHelper.reshape(GLJPanel.this, viewportX, viewportY, panelWidth, panelHeight); + helper.reshape(GLJPanel.this, viewportX, viewportY, panelWidth, panelHeight); sendReshape = false; } - drawableHelper.display(GLJPanel.this); + helper.display(GLJPanel.this); backend.postGL(g, true); } @@ -716,7 +721,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final Runnable disposeAction = new Runnable() { @Override public void run() { - drawableHelper.disposeGL(GLJPanel.this, backend.getDrawable(), backend.getContext(), postDisposeAction); + helper.disposeGL(GLJPanel.this, backend.getDrawable(), backend.getContext(), postDisposeAction); } }; @@ -1035,7 +1040,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } if (offscreenDrawable != null) { final AbstractGraphicsDevice adevice = offscreenDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); - offscreenDrawable.destroy(); + offscreenDrawable.setRealized(false); offscreenDrawable = null; if(null != adevice) { adevice.close(); @@ -1094,7 +1099,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override protected void doPaintComponentImpl() { - drawableHelper.invokeGL(offscreenDrawable, offscreenContext, updaterDisplayAction, updaterInitAction); + helper.invokeGL(offscreenDrawable, offscreenContext, updaterDisplayAction, updaterInitAction); } @Override @@ -1711,7 +1716,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing ((Java2DGLContext) joglContext).setGraphics(g); } - drawableHelper.invokeGL(joglDrawable, joglContext, updaterDisplayAction, updaterInitAction); + helper.invokeGL(joglDrawable, joglContext, updaterDisplayAction, updaterInitAction); } } finally { j2dContext.release(); diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index 3f50fe420..5c6d7446a 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -31,6 +31,8 @@ package jogamp.opengl; import java.io.PrintStream; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; import javax.media.opengl.FPSCounter; import javax.media.opengl.GL; import javax.media.opengl.GLAnimatorControl; @@ -76,7 +78,8 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { /** Returns the delegated GLDrawable */ public final GLDrawable getDelegatedDrawable() { return drawable; } - protected void defaultRepaintOp() { + /** Default implementation to handle repaint events from the windowing system */ + protected void defaultWindowRepaintOp() { if( null != drawable && drawable.isRealized() ) { if( !drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isAnimatorAnimating() ) { display(); @@ -84,16 +87,74 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } } - protected void defaultReshapeOp() { + /** Default implementation to handle resize events from the windowing system */ + protected void defaultWindowResizedOp() { if( null!=drawable ) { if(DEBUG) { System.err.println("GLAutoDrawableBase.sizeChanged: ("+Thread.currentThread().getName()+"): "+getWidth()+"x"+getHeight()+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); } sendReshape = true; - defaultRepaintOp(); + defaultWindowRepaintOp(); } } - + + /** Default implementation to handle destroy notifications from the windowing system */ + protected void defaultWindowDestroyNotifyOp() { + final NativeSurface ns = getNativeSurface(); + final boolean shallClose; + if(ns instanceof WindowClosingProtocol) { + shallClose = WindowClosingMode.DISPOSE_ON_CLOSE == ((WindowClosingProtocol)ns).getDefaultCloseOperation(); + } else { + shallClose = true; + } + if( shallClose ) { + // Is an animator thread perform rendering? + if (helper.isExternalAnimatorRunning()) { + // Pause animations before initiating safe destroy. + final GLAnimatorControl ctrl = helper.getAnimator(); + final boolean isPaused = ctrl.pause(); + destroy(); + if(isPaused) { + ctrl.resume(); + } + } else if (null != ns && ns.isSurfaceLockedByOtherThread()) { + // surface is locked by another thread + // Flag that destroy should be performed on the next + // attempt to display. + sendDestroy = true; + } else { + // Without an external thread animating or locking the + // surface, we are safe. + destroy (); + } + } + } + + /** + * Default implementation to destroys the drawable and context of this GLAutoDrawable: + *
    + *
  • issues the GLEventListener dispose call, if drawable and context are valid
  • + *
  • destroys the GLContext, if valid
  • + *
  • destroys the GLDrawable, if valid
  • + *
+ */ + protected void defaultDestroyOp() { + if( null != drawable && drawable.isRealized() ) { + if( null != context && context.isCreated() ) { + // Catch dispose GLExceptions by GLEventListener, just 'print' them + // so we can continue with the destruction. + try { + helper.disposeGL(this, drawable, context, null); + } catch (GLException gle) { + gle.printStackTrace(); + } + } + drawable.setRealized(false); + } + context = null; + drawable = null; + } + // // GLAutoDrawable // @@ -157,8 +218,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } @Override - public final void addGLEventListener(int index, GLEventListener listener) - throws IndexOutOfBoundsException { + public final void addGLEventListener(int index, GLEventListener listener) throws IndexOutOfBoundsException { helper.addGLEventListener(index, listener); } @@ -166,7 +226,12 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { public final void removeGLEventListener(GLEventListener listener) { helper.removeGLEventListener(listener); } - + + @Override + public GLEventListener removeGLEventListener(int index) throws IndexOutOfBoundsException { + return helper.removeGLEventListener(index); + } + @Override public final void setAnimator(GLAnimatorControl animatorControl) throws GLException { @@ -179,8 +244,8 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } @Override - public final void invoke(boolean wait, GLRunnable glRunnable) { - helper.invoke(this, wait, glRunnable); + public final boolean invoke(boolean wait, GLRunnable glRunnable) { + return helper.invoke(this, wait, glRunnable); } @Override diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index e7651eaab..0c01aa676 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -61,13 +61,13 @@ public class GLDrawableHelper { private static final boolean PERF_STATS = Debug.isPropertyDefined("jogl.debug.GLDrawable.PerfStats", true); protected static final boolean DEBUG = GLDrawableImpl.DEBUG; - private Object listenersLock = new Object(); - private ArrayList listeners; - private HashSet listenersToBeInit; + private final Object listenersLock = new Object(); + private final ArrayList listeners = new ArrayList(); + private final HashSet listenersToBeInit = new HashSet(); + private final Object glRunnablesLock = new Object(); + private volatile ArrayList glRunnables = new ArrayList(); private boolean autoSwapBufferMode; private Thread skipContextReleaseThread; - private Object glRunnablesLock = new Object(); - private ArrayList glRunnables; private GLAnimatorControl animatorCtrl; public GLDrawableHelper() { @@ -76,13 +76,13 @@ public class GLDrawableHelper { public final void reset() { synchronized(listenersLock) { - listeners = new ArrayList(); - listenersToBeInit = new HashSet(); + listeners.clear(); + listenersToBeInit.clear(); } autoSwapBufferMode = true; skipContextReleaseThread = null; synchronized(glRunnablesLock) { - glRunnables = new ArrayList(); + glRunnables.clear(); } animatorCtrl = null; } @@ -105,6 +105,46 @@ public class GLDrawableHelper { return sb.toString(); } + /** + * Associate a new context to the drawable and also propagates the context/drawable switch by + * calling {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. + *

+ * If the old context's drawable was an {@link GLAutoDrawable}, it's reference to the given drawable + * is being cleared by calling + * {@link GLAutoDrawable#setContext(GLContext) ((GLAutoDrawable)oldCtx.getGLDrawable()).setContext(null)}. + *

+ *

+ * If the old or new context was current on this thread, it is being released before switching the drawable. + *

+ * + * @param drawable the drawable which context is changed + * @param newCtx the new context + * @param oldCtx the old context + * @return true if the newt context was current, otherwise false + * + * @see GLAutoDrawable#setContext(GLContext) + */ + public final boolean switchContext(GLDrawable drawable, GLContext oldCtx, GLContext newCtx, int additionalCtxCreationFlags) { + if(null != oldCtx && oldCtx.isCurrent()) { + oldCtx.release(); + } + final boolean newCtxCurrent; + if(null!=newCtx) { + newCtxCurrent = newCtx.isCurrent(); + if(newCtxCurrent) { + newCtx.release(); + } + newCtx.setContextCreationFlags(additionalCtxCreationFlags); + newCtx.setGLDrawable(drawable, true); // propagate context/drawable switch + } else { + newCtxCurrent = false; + } + if(null!=oldCtx && oldCtx.getGLDrawable() instanceof GLAutoDrawable) { + ((GLAutoDrawable)oldCtx.getGLDrawable()).setContext(null); + } + return newCtxCurrent; + } + public final void addGLEventListener(GLEventListener listener) { addGLEventListener(-1, listener); } @@ -128,6 +168,16 @@ public class GLDrawableHelper { } } + public final GLEventListener removeGLEventListener(int index) + throws IndexOutOfBoundsException { + synchronized(listenersLock) { + if(0>index) { + index = listeners.size()-1; + } + return listeners.remove(index); + } + } + /** * Issues {@link javax.media.opengl.GLEventListener#dispose(javax.media.opengl.GLAutoDrawable)} * to all listeners. @@ -144,18 +194,19 @@ public class GLDrawableHelper { } } } - - private boolean init(GLEventListener l, GLAutoDrawable drawable, boolean sendReshape) { + + private final boolean init(GLEventListener l, GLAutoDrawable drawable, boolean sendReshape) { if(listenersToBeInit.remove(l)) { l.init(drawable); if(sendReshape) { - reshape(l, drawable, 0, 0, drawable.getWidth(), drawable.getHeight(), true /* setViewport */, false); + reshape(l, drawable, 0, 0, drawable.getWidth(), drawable.getHeight(), true /* setViewport */, false /* checkInit */); } return true; } return false; } + /** The default init action to be called once after ctx is being created @ 1st makeCurrent(). */ public final void init(GLAutoDrawable drawable) { synchronized(listenersLock) { for (int i=0; i < listeners.size(); i++) { @@ -166,7 +217,7 @@ public class GLDrawableHelper { // hence the must always be initialized unconditional. listenersToBeInit.add(listener); - if ( ! init( listener, drawable, false ) ) { + if ( ! init( listener, drawable, true /* sendReshape */) ) { throw new GLException("GLEventListener "+listener+" already initialized: "+drawable); } } @@ -179,24 +230,26 @@ public class GLDrawableHelper { displayImpl(drawable); } } - private void displayImpl(GLAutoDrawable drawable) { + private final void displayImpl(GLAutoDrawable drawable) { synchronized(listenersLock) { for (int i=0; i < listeners.size(); i++) { final GLEventListener listener = listeners.get(i) ; // GLEventListener may need to be init, // in case this one is added after the realization of the GLAutoDrawable - init( listener, drawable, true ) ; + init( listener, drawable, true /* sendReshape */) ; listener.display(drawable); } } } - private void reshape(GLEventListener listener, GLAutoDrawable drawable, - int x, int y, int width, int height, boolean setViewport, boolean checkInit) { + private final void reshape(GLEventListener listener, GLAutoDrawable drawable, + int x, int y, int width, int height, boolean setViewport, boolean checkInit) { if(checkInit) { // GLEventListener may need to be init, - // in case this one is added after the realization of the GLAutoDrawable - init( listener, drawable, false ) ; + // in case this one is added after the realization of the GLAutoDrawable + synchronized(listenersLock) { + init( listener, drawable, false /* sendReshape */) ; + } } if(setViewport) { drawable.getGL().glViewport(x, y, width, height); @@ -212,27 +265,50 @@ public class GLDrawableHelper { } } - private boolean execGLRunnables(GLAutoDrawable drawable) { + private final boolean execGLRunnables(GLAutoDrawable drawable) { boolean res = true; - if(glRunnables.size()>0) { + if(glRunnables.size()>0) { // volatile OK // swap one-shot list asap - ArrayList _glRunnables = null; + final ArrayList _glRunnables; synchronized(glRunnablesLock) { if(glRunnables.size()>0) { _glRunnables = glRunnables; - glRunnables = new ArrayList(); + glRunnables = new ArrayList(); + } else { + _glRunnables = null; } } if(null!=_glRunnables) { for (int i=0; i < _glRunnables.size(); i++) { - res = _glRunnables.get(i).run(drawable) && res; + res = _glRunnables.get(i).run(drawable) && res; } } } return res; } + public final void flushGLRunnables() { + if(glRunnables.size()>0) { // volatile OK + // swap one-shot list asap + final ArrayList _glRunnables; + synchronized(glRunnablesLock) { + if(glRunnables.size()>0) { + _glRunnables = glRunnables; + glRunnables = new ArrayList(); + } else { + _glRunnables = null; + } + } + + if(null!=_glRunnables) { + for (int i=0; i < _glRunnables.size(); i++) { + _glRunnables.get(i).flush(); + } + } + } + } + public final void setAnimator(GLAnimatorControl animator) throws GLException { synchronized(glRunnablesLock) { if(animatorCtrl!=animator && null!=animator && null!=animatorCtrl) { @@ -264,10 +340,28 @@ public class GLDrawableHelper { return ( null != animatorCtrl ) ? animatorCtrl.isAnimating() : false ; } - public final void invoke(GLAutoDrawable drawable, boolean wait, GLRunnable glRunnable) { - if( null == drawable || null == glRunnable ) { - return; + /** + *

+ * If wait is true the call blocks until the glRunnable + * has been executed.

+ *

+ * If wait is true and + * {@link GLDrawable#isRealized()} returns false or {@link GLAutoDrawable#getContext()} returns null, + * the call is ignored and returns false.
+ * This helps avoiding deadlocking the caller. + *

+ * + * @param drawable the {@link GLAutoDrawable} to be used + * @param wait if true block until execution of glRunnable is finished, otherwise return immediatly w/o waiting + * @param glRunnable the {@link GLRunnable} to execute within {@link #display()} + * @return true if the {@link GLRunnable} has been processed or queued, otherwise false. + */ + public final boolean invoke(GLAutoDrawable drawable, boolean wait, GLRunnable glRunnable) { + if( null == glRunnable || null == drawable || + wait && ( !drawable.isRealized() || null==drawable.getContext() ) ) { + return false; } + Throwable throwable = null; GLRunnableTask rTask = null; Object rTaskLock = new Object(); @@ -299,6 +393,7 @@ public class GLDrawableHelper { } } } + return true; } public final void setAutoSwapBufferMode(boolean enable) { @@ -439,6 +534,7 @@ public class GLDrawableHelper { try { if(isDisposeAction) { context.destroy(); + flushGLRunnables(); } else if( GLContext.CONTEXT_NOT_CURRENT != res ) { context.release(); } @@ -526,6 +622,7 @@ public class GLDrawableHelper { try { if(isDisposeAction) { context.destroy(); + flushGLRunnables(); ctxDestroyed = true; } else if( res != GLContext.CONTEXT_NOT_CURRENT && (null == skipContextReleaseThread || currentThread != skipContextReleaseThread) ) { diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index b3884830a..58a4ac6b4 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -70,20 +70,6 @@ public abstract class GLDrawableImpl implements GLDrawable { return (GLDrawableFactoryImpl) getFactory(); } - /** For offscreen GLDrawables (pbuffers and "pixmap" drawables), - indicates that native resources should be reclaimed. */ - public void destroy() { - surface.getGraphicsConfiguration().getScreen().getDevice().lock(); - try { - destroyImpl(); - } finally { - surface.getGraphicsConfiguration().getScreen().getDevice().unlock(); - } - } - protected void destroyImpl() { - throw new GLException("Should not call this (should only be called for offscreen GLDrawables)"); - } - @Override public final void swapBuffers() throws GLException { if( !realized ) { @@ -164,7 +150,7 @@ public abstract class GLDrawableImpl implements GLDrawable { AbstractGraphicsDevice aDevice = surface.getGraphicsConfiguration().getScreen().getDevice(); if(realizedArg) { if(NativeSurface.LOCK_SURFACE_NOT_READY >= lockSurface()) { - throw new GLException("GLDrawableImpl.setRealized(true): already realized, but surface not ready (lockSurface)"); + throw new GLException("GLDrawableImpl.setRealized(true): Surface not ready (lockSurface)"); } } else { aDevice.lock(); diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index d98b41bdc..a8277fd71 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -40,7 +40,6 @@ package jogamp.opengl; -import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; @@ -114,36 +113,19 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { @Override public void destroy() { - if(drawable.isRealized()) { - final AbstractGraphicsDevice adevice = drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); - - if (null != context && context.isCreated()) { - try { - helper.disposeGL(GLPbufferImpl.this, drawable, context, null); - } catch (GLException gle) { - gle.printStackTrace(); - } - context = null; - // drawableHelper.reset(); - } - drawable.destroy(); - drawable = null; - - if(null != adevice) { - adevice.close(); - } - } + defaultDestroyOp(); } @Override public GLDrawableFactory getFactory() { - return drawable.getFactory(); + return drawable.getFactory(); } @Override public void display() { - if( null == drawable || !drawable.isRealized() || null == context ) { return; } + if( null != drawable && drawable.isRealized() && null != context ) { helper.invokeGL(drawable, context, defaultDisplayAction, initAction); + } } //---------------------------------------------------------------------- diff --git a/src/jogl/classes/jogamp/opengl/GLRunnableTask.java b/src/jogl/classes/jogamp/opengl/GLRunnableTask.java index 448f68423..244a3fd79 100644 --- a/src/jogl/classes/jogamp/opengl/GLRunnableTask.java +++ b/src/jogl/classes/jogamp/opengl/GLRunnableTask.java @@ -39,7 +39,8 @@ public class GLRunnableTask implements GLRunnable { GLRunnable runnable; Object notifyObject; boolean catchExceptions; - boolean isExecuted; + volatile boolean isExecuted; + volatile boolean isFlushed; Throwable runnableException; @@ -48,6 +49,7 @@ public class GLRunnableTask implements GLRunnable { this.notifyObject = notifyObject ; this.catchExceptions = catchExceptions; isExecuted = false; + isFlushed = false; } public boolean run(GLAutoDrawable drawable) { @@ -84,8 +86,41 @@ public class GLRunnableTask implements GLRunnable { } return res; } - + + /** + * Simply flush this task and notify a waiting executor. + * The executor which might have been blocked until notified + * will be unblocked and the task removed from the queue. + * + * @see #isFlushed() + * @see #isInQueue() + */ + public void flush() { + if(!isExecuted() && null != notifyObject) { + synchronized (notifyObject) { + isFlushed=true; + notifyObject.notifyAll(); + } + } + } + + /** + * @return !{@link #isExecuted()} && !{@link #isFlushed()} + */ + public boolean isInQueue() { return !isExecuted && !isFlushed; } + + /** + * @return whether this task has been executed. + * @see #isInQueue() + */ public boolean isExecuted() { return isExecuted; } + + /** + * @return whether this task has been flushed. + * @see #isInQueue() + */ + public boolean isFlushed() { return isFlushed; } + public Throwable getThrowable() { return runnableException; } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java index f18b8cd02..b2217c095 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java @@ -55,11 +55,6 @@ public class EGLPbufferDrawable extends EGLDrawable { super(factory, target); } - @Override - protected void destroyImpl() { - setRealized(false); - } - @Override protected long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle) { final AbstractGraphicsConfiguration config = getNativeSurface().getGraphicsConfiguration(); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index cae60702b..257635b8c 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -151,8 +151,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { if (haveSetOpenGLMode) { throw new GLException("Can't switch between using NSOpenGLPixelBuffer and CGLPBufferObj more than once"); } - - destroyImpl(); + setRealized(false); if (DEBUG) { System.err.println("MacOSXCGLDrawable: Switching context mode " + openGLMode + " -> " + mode); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index 6bdabbf59..4e9d18fed 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -250,7 +250,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { } } } - drawable.destroy(); + drawable.setRealized(false); } } sr = new SharedResource(sharedDevice, madeCurrent, hasNPOTTextures, hasRECTTextures, hasAppleFloatPixels); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 33021c521..242cea068 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -79,11 +79,6 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { super(factory, target, false); } - @Override - protected void destroyImpl() { - setRealized(false); - } - @Override protected void setRealizedImpl() { if(realized) { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java index dc3b58cfa..296d53ce3 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java @@ -61,11 +61,6 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable { super(factory, target, false); } - @Override - protected void destroyImpl() { - setRealized(false); - } - @Override protected void setRealizedImpl() { if(realized) { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java index 244c1553f..05d6d9862 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java @@ -70,7 +70,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { System.err.println("WindowsDummyWGLDrawable: "+config); } } catch (Throwable t) { - destroyImpl(); + setRealized(false); throw new GLException(t); } finally { unlockSurface(); @@ -96,11 +96,14 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { } @Override - protected void destroyImpl() { - if (handleHwndLifecycle && hwnd != 0) { - GDI.ShowWindow(hwnd, GDI.SW_HIDE); - GDIUtil.DestroyDummyWindow(hwnd); - hwnd = 0; + protected void setRealizedImpl() { + super.setRealizedImpl(); + if(!realized) { + if (handleHwndLifecycle && hwnd != 0) { + GDI.ShowWindow(hwnd, GDI.SW_HIDE); + GDIUtil.DestroyDummyWindow(hwnd); + hwnd = 0; + } } } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java index 762bea3b1..b00c796ec 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -66,11 +66,6 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { super(factory, target, false); } - @Override - protected void destroyImpl() { - setRealized(false); - } - @Override protected void setRealizedImpl() { if(realized) { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java index ddcb898a9..ca7886e7f 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java @@ -62,15 +62,13 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl { @Override protected void setRealizedImpl() { - if(!realized) { - return; // nothing todo .. - } - - NativeSurface ns = getNativeSurface(); - WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration(); - config.updateGraphicsConfiguration(getFactory(), ns, null); - if (DEBUG) { - System.err.println("WindowsWGLDrawable.setRealized(true): "+config); + if(realized) { + NativeSurface ns = getNativeSurface(); + WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration(); + config.updateGraphicsConfiguration(getFactory(), ns, null); + if (DEBUG) { + System.err.println("WindowsWGLDrawable.setRealized(true): "+config); + } } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 054e1fe90..176d27a71 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -373,7 +373,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { } if (null != sr.drawable) { - sr.drawable.destroy(); + sr.drawable.setRealized(false); sr.drawable = null; } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java index 65f65a2ec..8914e2db9 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java @@ -86,13 +86,17 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable { public int getHeight() { return 1; } - + + @Override - protected void destroyImpl() { - if(0!=dummyWindow) { - destroyHandle(); - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration(); - X11Lib.DestroyDummyWindow(config.getScreen().getDevice().getHandle(), dummyWindow); + protected void setRealizedImpl() { + super.setRealizedImpl(); + if(!realized) { + if(0!=dummyWindow) { + destroyHandle(); + X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration(); + X11Lib.DestroyDummyWindow(config.getScreen().getDevice().getHandle(), dummyWindow); + } } } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 77af0d698..9a563bdb8 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -304,7 +304,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if (null != sr.drawable) { // may cause JVM SIGSEGV: - sr.drawable.destroy(); + sr.drawable.setRealized(false); sr.drawable = null; } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java index 29003ef52..cdf81ebd3 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java @@ -58,11 +58,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { super(factory, target, false); } - @Override - protected void destroyImpl() { - setRealized(false); - } - @Override protected void setRealizedImpl() { if(realized) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java index 18aa780b6..1e7b89828 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java @@ -58,11 +58,6 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable { super(factory, target, false); } - @Override - protected void destroyImpl() { - setRealized(false); - } - @Override protected void setRealizedImpl() { if(realized) { diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 6a328ed07..96baab3ae 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -53,7 +53,6 @@ import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import jogamp.newt.WindowImpl; @@ -109,37 +108,17 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind window.addWindowListener(new WindowAdapter() { @Override public void windowRepaint(WindowUpdateEvent e) { - defaultRepaintOp(); + defaultWindowRepaintOp(); } @Override public void windowResized(WindowEvent e) { - defaultReshapeOp(); + defaultWindowResizedOp(); } @Override public void windowDestroyNotify(WindowEvent e) { - if( WindowClosingMode.DISPOSE_ON_CLOSE == GLWindow.this.getDefaultCloseOperation() ) { - // Is an animator thread perform rendering? - if (GLWindow.this.helper.isExternalAnimatorRunning()) { - // Pause animations before initiating safe destroy. - final GLAnimatorControl ctrl = GLWindow.this.helper.getAnimator(); - boolean isPaused = ctrl.pause(); - destroy(); - if(isPaused) { - ctrl.resume(); - } - } else if (GLWindow.this.window.isWindowLockedByOtherThread()) { - // Window is locked by another thread - // Flag that destroy should be performed on the next - // attempt to display. - sendDestroy = true; - } else { - // Without an external thread animating or locking the - // surface, we are safe. - destroy (); - } - } + defaultWindowDestroyNotifyOp(); } }); this.window.setLifecycleHook(new GLLifecycleHook()); @@ -453,20 +432,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind //e1.printStackTrace(); } - if( window.isNativeValid() && null != drawable && drawable.isRealized() ) { - if( null != context && context.isCreated() ) { - // Catch dispose GLExceptions by GLEventListener, just 'print' them - // so we can continue with the destruction. - try { - helper.disposeGL(GLWindow.this, drawable, context, null); - } catch (GLException gle) { - gle.printStackTrace(); - } - } - drawable.setRealized(false); - } - context = null; - drawable = null; + defaultDestroyOp(); if(Window.DEBUG_IMPLEMENTATION) { System.err.println("GLWindow.destroy() "+Thread.currentThread()+", fin"); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java index be9ae223b..a2d060a8c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java @@ -1,5 +1,5 @@ /** - * Copyright 2010 JogAmp Community. All rights reserved. + * Copyright 2012 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: @@ -30,60 +30,95 @@ package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; -import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLAutoDrawableDelegate; import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import org.junit.Assert; import org.junit.Test; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.WindowUpdateEvent; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.NEWTGLContext; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.test.junit.util.UITestCase; +/** + * Demonstrates a full featured custom GLAutoDrawable implementation + * utilizing {@link GLAutoDrawableDelegate}. + */ public class TestGLAutoDrawableDelegateNEWT extends UITestCase { - @Test - public void test01() throws GLException, InterruptedException { - final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow( - new GLCapabilities(GLProfile.getGL2ES2()), 640, 480, false); - winctx.context.release(); + /** Note: Creates a full featured GLAutoDrawable w/ all window events connected. */ + private GLAutoDrawable createGLAutoDrawable(GLCapabilities caps, int x, int y, int width, int height, WindowListener wl) throws InterruptedException { + final Window window = NewtFactory.createWindow(caps); + Assert.assertNotNull(window); + window.setPosition(x, y); + window.setSize(width, height); + window.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); + + GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + + drawable.setRealized(true); + Assert.assertTrue(drawable.isRealized()); + + GLContext context = drawable.createContext(null); + Assert.assertNotNull(context); + + int res = context.makeCurrent(); + Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); + context.release(); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context) { + @Override + public void destroy() { + super.destroy(); // destroys drawable/context + window.destroy(); // destroys the actual window + } + }; - final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(winctx.drawable, winctx.context); - glad.addGLEventListener(new GearsES2(1)); - // add basic window interaction - winctx.window.addWindowListener(new WindowAdapter() { + window.addWindowListener(new WindowAdapter() { @Override public void windowRepaint(WindowUpdateEvent e) { - glad.defaultRepaintOp(); + glad.defaultWindowRepaintOp(); } @Override public void windowResized(WindowEvent e) { - glad.defaultReshapeOp(); + glad.defaultWindowResizedOp(); } @Override public void windowDestroyNotify(WindowEvent e) { - final GLAnimatorControl ctrl = glad.getAnimator(); - boolean isPaused = ctrl.pause(); - glad.destroy(); - NEWTGLContext.destroyWindow(winctx); - if(isPaused) { - ctrl.resume(); - } + glad.defaultWindowDestroyNotifyOp(); } }); + window.addWindowListener(wl); + return glad; + } + + @Test + public void test01() throws GLException, InterruptedException { final QuitAdapter quitAdapter = new QuitAdapter(); - winctx.window.addWindowListener(quitAdapter); - + GLAutoDrawable glad = createGLAutoDrawable(new GLCapabilities(GLProfile.getGL2ES2()), 0, 0, 640, 480, quitAdapter); + glad.addGLEventListener(new GearsES2(1)); + final Animator animator = new Animator(glad); animator.setUpdateFPSFrames(60, null); animator.start(); @@ -93,7 +128,8 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase { } animator.stop(); - NEWTGLContext.destroyWindow(winctx); + + glad.destroy(); } static long duration = 2000; // ms diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java index 22ed7c6fd..41c69336c 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java @@ -66,6 +66,57 @@ public class TestParenting01cSwingAWT extends UITestCase { glCaps = new GLCapabilities(null); } + static class GLDisturbanceAction implements Runnable { + public boolean isRunning = false; + private volatile boolean shallStop = false; + private final GLAutoDrawable glad; + private final GLRunnable glRunnable; + + public GLDisturbanceAction(GLAutoDrawable glad) { + this.glad = glad; + this.glRunnable = new GLRunnableDummy(); + } + + public void waitUntilRunning() { + synchronized(this) { + while(!isRunning) { + try { + this.wait(); + } catch (InterruptedException e) { e.printStackTrace(); } + } + } + } + + public void stopAndWaitUntilDone() { + shallStop = true; + synchronized(this) { + while(isRunning) { + try { + this.wait(); + } catch (InterruptedException e) { e.printStackTrace(); } + } + } + } + + public void run() { + synchronized(this) { + isRunning = true; + this.notifyAll(); + System.out.println("$"); + } + while(!shallStop) { + try { + glad.invoke(true, glRunnable); + Thread.sleep(100); + } catch (Throwable t) {} + } + synchronized(this) { + isRunning = false; + this.notifyAll(); + } + } + } + @Test public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { /** @@ -84,22 +135,9 @@ public class TestParenting01cSwingAWT extends UITestCase { animator1.setUpdateFPSFrames(1, null); animator1.start(); - final GLWindow _glWindow1 = glWindow1; - final GLRunnable _glRunnable = new GLRunnableDummy(); - Thread disturbanceThread = new Thread(new Runnable() { - public void run() { - System.out.println("$"); - while(true) - { - try { - _glWindow1.invoke(true, _glRunnable); - Thread.sleep(100); - } catch (Throwable t) {} - } - } - }); - disturbanceThread.start(); - + final GLDisturbanceAction disturbanceAction = new GLDisturbanceAction(glWindow1); + new Thread(disturbanceAction).start(); + disturbanceAction.waitUntilRunning(); final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Assert.assertNotNull(newtCanvasAWT); @@ -175,6 +213,7 @@ public class TestParenting01cSwingAWT extends UITestCase { } }); Assert.assertEquals(true, glWindow1.isNativeValid()); + disturbanceAction.stopAndWaitUntilDone(); glWindow1.destroy(); Assert.assertEquals(false, glWindow1.isNativeValid()); } @@ -192,26 +231,33 @@ public class TestParenting01cSwingAWT extends UITestCase { glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); GLEventListener demo1 = new RedSquareES2(); setDemoFields(demo1, glWindow1, false); + /* + glWindow1.addGLEventListener(new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) { + System.err.println("XXX init"); + } + @Override + public void dispose(GLAutoDrawable drawable) { + System.err.println("XXX dispose"); + // Thread.dumpStack(); + } + @Override + public void display(GLAutoDrawable drawable) {} + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + System.err.println("XXX reshape"); + // Thread.dumpStack(); + } + }); */ glWindow1.addGLEventListener(demo1); Animator animator1 = new Animator(glWindow1); animator1.setUpdateFPSFrames(1, null); animator1.start(); - - final GLWindow _glWindow1 = glWindow1; - final GLRunnable _glRunnable = new GLRunnableDummy(); - Thread disturbanceThread = new Thread(new Runnable() { - public void run() { - System.out.println("$"); - while(true) - { - try { - _glWindow1.invoke(true, _glRunnable); - Thread.sleep(100); - } catch (Throwable t) {} - } - } - }); - disturbanceThread.start(); + + final GLDisturbanceAction disturbanceAction = new GLDisturbanceAction(glWindow1); + new Thread(disturbanceAction).start(); + disturbanceAction.waitUntilRunning(); final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Assert.assertNotNull(newtCanvasAWT); @@ -298,6 +344,8 @@ public class TestParenting01cSwingAWT extends UITestCase { animator1.stop(); Assert.assertEquals(false, animator1.isAnimating()); + disturbanceAction.stopAndWaitUntilDone(); + SwingUtilities.invokeAndWait(new Runnable() { public void run() { jFrame1.setVisible(false); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java index bc3988338..8e2c73e9d 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java @@ -111,8 +111,8 @@ public class TestParenting02NEWT extends UITestCase { Assert.assertEquals(height,glWindow1.getHeight()); glWindow1.setTitle("testWindowParenting01NewtOnNewtParentChildDraw - PARENT"); glWindow1.setPosition(x,y); - glWindow1.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); - glWindow1.addWindowListener(new TraceWindowAdapter()); + //glWindow1.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); + //glWindow1.addWindowListener(new TraceWindowAdapter()); GLEventListener demo1 = new RedSquareES2(); setDemoFields(demo1, window1, glWindow1, false); @@ -132,8 +132,8 @@ public class TestParenting02NEWT extends UITestCase { //Assert.assertEquals(height/2,glWindow2.getHeight()); glWindow2.setTitle("testWindowParenting01NewtOnNewtParentChildDraw - CHILD"); glWindow2.setPosition(glWindow1.getWidth()/2, glWindow1.getHeight()/2); - glWindow2.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); - glWindow2.addWindowListener(new TraceWindowAdapter(new WindowAction(eventFifo))); + //glWindow2.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); + //glWindow2.addWindowListener(new TraceWindowAdapter(new WindowAction(eventFifo))); // glWindow2.addMouseListener(new TraceMouseAdapter()); GLEventListener demo2 = new GearsES2(); -- cgit v1.2.3 From fd06292d4a208cbd613f4bdce7cae12e075e70ec Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 5 Jul 2012 14:32:00 +0200 Subject: NativeWindow/Newt X11ErrorHandler enhancement / unification - don't throw exceptions. Handles also XAWT BadMatch X_SetInputFocus. X11ErrorHandler code now dumps proper information about the opcode and error message and the running Java thread. Having propery "nativewindow.debug.X11Util.XErrorStackDump" or "nativewindow.debug=all' set, a stack trace is dumped. Since the X11ErrorHandler may catch an XAWT error: BadMatch X_SetInputFocus, we cannot throw an exception and better keep running. --- .../classes/jogamp/nativewindow/x11/X11Util.java | 23 ++- src/nativewindow/native/NativewindowCommon.c | 19 ++ src/nativewindow/native/NativewindowCommon.h | 1 + src/nativewindow/native/x11/Xmisc.c | 208 ++++++++++----------- src/nativewindow/native/x11/Xmisc.h | 44 +++++ .../classes/jogamp/newt/driver/x11/X11Display.java | 4 +- .../classes/jogamp/newt/driver/x11/X11Window.java | 3 + src/newt/native/NewtCommon.c | 19 ++ src/newt/native/NewtCommon.h | 1 + src/newt/native/X11Common.h | 2 +- src/newt/native/X11Display.c | 81 +++++--- src/newt/native/X11Window.c | 12 +- 12 files changed, 276 insertions(+), 141 deletions(-) create mode 100644 src/nativewindow/native/x11/Xmisc.h (limited to 'src/newt/classes') diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 3c197062a..fcc374751 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -81,9 +81,10 @@ public class X11Util { /** Value is true, best 'stable' results if not using XLockDisplay/XUnlockDisplay at all. */ public static final boolean HAS_XLOCKDISPLAY_BUG = true; - private static final boolean DEBUG = Debug.debug("X11Util"); - private static final boolean TRACE_DISPLAY_LIFECYCLE = Debug.getBooleanProperty("nativewindow.debug.X11Util.TraceDisplayLifecycle", true); - + public static final boolean DEBUG = Debug.debug("X11Util"); + public static final boolean XSYNC_ENABLED = Debug.isPropertyDefined("nativewindow.debug.X11Util.XSync", true); + public static final boolean XERROR_STACKDUMP = DEBUG || Debug.isPropertyDefined("nativewindow.debug.X11Util.XErrorStackDump", true); + private static final boolean TRACE_DISPLAY_LIFECYCLE = Debug.isPropertyDefined("nativewindow.debug.X11Util.TraceDisplayLifecycle", true); private static String nullDisplayName = null; private static boolean isX11LockAvailable = false; private static boolean requiresX11Lock = true; @@ -105,11 +106,14 @@ public class X11Util { } final boolean callXInitThreads = XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess; - final boolean isXInitThreadsOK = initialize0( XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess ); + final boolean isXInitThreadsOK = initialize0( XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess, XERROR_STACKDUMP); isX11LockAvailable = isXInitThreadsOK && !HAS_XLOCKDISPLAY_BUG ; final long dpy = X11Lib.XOpenDisplay(null); if(0 != dpy) { + if(XSYNC_ENABLED) { + X11Lib.XSynchronize(dpy, true); + } try { nullDisplayName = X11Lib.XDisplayString(dpy); } finally { @@ -124,7 +128,8 @@ public class X11Util { ", requiresX11Lock "+requiresX11Lock+ ", XInitThreads [called "+callXInitThreads+", OK "+isXInitThreadsOK+"]"+ ", isX11LockAvailable "+isX11LockAvailable+ - ", X11 Display(NULL) <"+nullDisplayName+">"); + ", X11 Display(NULL) <"+nullDisplayName+">"+ + ", XSynchronize Enabled: "+XSYNC_ENABLED); // Thread.dumpStack(); } } @@ -455,6 +460,9 @@ public class X11Util { NativeWindowFactory.getDefaultToolkitLock().lock(); try { long handle = X11Lib.XOpenDisplay(arg0); + if(XSYNC_ENABLED && 0 != handle) { + X11Lib.XSynchronize(handle, true); + } if(TRACE_DISPLAY_LIFECYCLE) { System.err.println(Thread.currentThread()+" - X11Util.XOpenDisplay("+arg0+") 0x"+Long.toHexString(handle)); // Thread.dumpStack(); @@ -520,7 +528,10 @@ public class X11Util { return false; } - private static native boolean initialize0(boolean firstUIActionOnProcess); + private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI + private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI + + private static native boolean initialize0(boolean firstUIActionOnProcess, boolean debug); private static native void shutdown0(); private static native void setX11ErrorHandler0(boolean onoff, boolean quiet); } diff --git a/src/nativewindow/native/NativewindowCommon.c b/src/nativewindow/native/NativewindowCommon.c index b866646a6..d2fdd5d69 100644 --- a/src/nativewindow/native/NativewindowCommon.c +++ b/src/nativewindow/native/NativewindowCommon.c @@ -1,5 +1,6 @@ #include "NativewindowCommon.h" +#include static const char * const ClazzNameRuntimeException = "java/lang/RuntimeException"; static jclass runtimeExceptionClz=NULL; @@ -45,6 +46,24 @@ int NativewindowCommon_init(JNIEnv *env) { return 0; } +const char * NativewindowCommon_GetStaticStringMethod(JNIEnv *jniEnv, jclass clazz, jmethodID jGetStrID, char *dest, int destSize, const char *altText) { + if(NULL != jniEnv && NULL != clazz && NULL != jGetStrID) { + jstring jstr = (jstring) (*jniEnv)->CallStaticObjectMethod(jniEnv, clazz, jGetStrID); + if(NULL != jstr) { + const char * str = (*jniEnv)->GetStringUTFChars(jniEnv, jstr, NULL); + if( NULL != str) { + strncpy(dest, str, destSize-1); + dest[destSize-1] = 0; // EOS + (*jniEnv)->ReleaseStringUTFChars(jniEnv, jstr, str); + return dest; + } + } + } + strncpy(dest, altText, destSize-1); + dest[destSize-1] = 0; // EOS + return dest; +} + jchar* NativewindowCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str) { jchar* strChars = NULL; diff --git a/src/nativewindow/native/NativewindowCommon.h b/src/nativewindow/native/NativewindowCommon.h index 41c4bd0eb..73b890c4f 100644 --- a/src/nativewindow/native/NativewindowCommon.h +++ b/src/nativewindow/native/NativewindowCommon.h @@ -7,6 +7,7 @@ int NativewindowCommon_init(JNIEnv *env); +const char * NativewindowCommon_GetStaticStringMethod(JNIEnv *jniEnv, jclass clazz, jmethodID jGetStrID, char *dest, int destSize, const char *altText); jchar* NativewindowCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str); void NativewindowCommon_FatalError(JNIEnv *env, const char* msg, ...); diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index 439d9b334..5cbf5c04a 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -26,15 +26,19 @@ * or implied, of JogAmp Community. */ +#include "NativewindowCommon.h" +#include "Xmisc.h" +#include "jogamp_nativewindow_x11_X11Lib.h" + +// #define VERBOSE_ON 1 + +#ifdef VERBOSE_ON + #define DBG_PRINT(args...) fprintf(stderr, args); +#else + #define DBG_PRINT(args...) +#endif + -#include -#include -#include -#include -#include -#include -#include -#include /* Linux headers don't work properly */ #define __USE_GNU #include @@ -80,17 +84,6 @@ Bool XF86VidModeSetGammaRamp( #define RTLD_DEFAULT NULL #endif -#include "NativewindowCommon.h" -#include "jogamp_nativewindow_x11_X11Lib.h" - -// #define VERBOSE_ON 1 - -#ifdef VERBOSE_ON - #define DBG_PRINT(args...) fprintf(stderr, args); -#else - #define DBG_PRINT(args...) -#endif - static const char * const ClazzNameBuffers = "com/jogamp/common/nio/Buffers"; static const char * const ClazzNameBuffersStaticCstrName = "copyByteBuffer"; static const char * const ClazzNameBuffersStaticCstrSignature = "(Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;"; @@ -98,6 +91,9 @@ static const char * const ClazzNameByteBuffer = "java/nio/ByteBuffer"; static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; static const char * const ClazzAnyCstrName = ""; static const char * const ClazzNamePointCstrSignature = "(II)V"; +static jclass X11UtilClazz = NULL; +static jmethodID getCurrentThreadNameID = NULL; +static jmethodID dumpStackID = NULL; static jclass clazzBuffers = NULL; static jmethodID cstrBuffers = NULL; static jclass clazzByteBuffer = NULL; @@ -109,6 +105,15 @@ static void _initClazzAccess(JNIEnv *env) { if(!NativewindowCommon_init(env)) return; + getCurrentThreadNameID = (*env)->GetStaticMethodID(env, X11UtilClazz, "getCurrentThreadName", "()Ljava/lang/String;"); + if(NULL==getCurrentThreadNameID) { + NativewindowCommon_FatalError(env, "FatalError Java_jogamp_nativewindow_x11_X11Lib: can't get method getCurrentThreadName"); + } + dumpStackID = (*env)->GetStaticMethodID(env, X11UtilClazz, "dumpStack", "()V"); + if(NULL==dumpStackID) { + NativewindowCommon_FatalError(env, "FatalError Java_jogamp_nativewindow_x11_X11Lib: can't get method dumpStack"); + } + c = (*env)->FindClass(env, ClazzNameBuffers); if(NULL==c) { NativewindowCommon_FatalError(env, "FatalError Java_jogamp_nativewindow_x11_X11Lib: can't find %s", ClazzNameBuffers); @@ -162,66 +167,71 @@ static void setupJVMVars(JNIEnv * env) { } static XErrorHandler origErrorHandler = NULL ; -static int errorHandlerBlocked = 0 ; static int errorHandlerQuiet = 0 ; +static int errorHandlerDebug = 0 ; +static int errorHandlerThrowException = 0; static int x11ErrorHandler(Display *dpy, XErrorEvent *e) { if(!errorHandlerQuiet) { - JNIEnv *curEnv = NULL; - JNIEnv *newEnv = NULL; - int envRes ; - const char * errStr = strerror(errno); + const char * errnoStr = strerror(errno); + char threadName[80]; + char errCodeStr[80]; + char reqCodeStr[80]; - fprintf(stderr, "Info: Nativewindow X11 Error: Display %p, Code 0x%X, errno %s\n", dpy, e->error_code, errStr); - fflush(stderr); + int shallBeDetached = 0; + JNIEnv *jniEnv = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); - // retrieve this thread's JNIEnv curEnv - or detect it's detached - envRes = (*jvmHandle)->GetEnv(jvmHandle, (void **) &curEnv, jvmVersion) ; - if( JNI_EDETACHED == envRes ) { - // detached thread - attach to JVM - if( JNI_OK != ( envRes = (*jvmHandle)->AttachCurrentThread(jvmHandle, (void**) &newEnv, NULL) ) ) { - fprintf(stderr, "Nativewindow X11 Error: can't attach thread: %d\n", envRes); - return 0; + (void) NativewindowCommon_GetStaticStringMethod(jniEnv, X11UtilClazz, getCurrentThreadNameID, threadName, sizeof(threadName), "n/a"); + snprintf(errCodeStr, sizeof(errCodeStr), "%d", e->request_code); + XGetErrorDatabaseText(dpy, "XRequest", errCodeStr, "Unknown", reqCodeStr, sizeof(reqCodeStr)); + XGetErrorText(dpy, e->error_code, errCodeStr, sizeof(errCodeStr)); + + fprintf(stderr, "Info: Nativewindow X11 Error (Thread: %s): %d - %s, dpy %p, id %x, # %d: %d:%d %s\n", + threadName, e->error_code, errCodeStr, e->display, e->resourceid, e->serial, + e->request_code, e->minor_code, reqCodeStr); + + if( errorHandlerDebug ) { + (*jniEnv)->CallStaticVoidMethod(jniEnv, X11UtilClazz, dumpStackID); + } + + if(errorHandlerThrowException) { + if(NULL != jniEnv) { + NativewindowCommon_throwNewRuntimeException(jniEnv, "Nativewindow X11 Error (Thread: %s): %d - %s, dpy %p, id %x, # %d: %d:%d %s\n", + threadName, e->error_code, errCodeStr, e->display, e->resourceid, e->serial, + e->request_code, e->minor_code, reqCodeStr); + } else { + fprintf(stderr, "Nativewindow X11 Error: null JNIEnv"); + #if 0 + if(NULL!=origErrorHandler) { + origErrorHandler(dpy, e); + } + #endif } - curEnv = newEnv; - } else if( JNI_OK != envRes ) { - // oops .. - fprintf(stderr, "Nativewindow X11 Error: can't GetEnv: %d\n", envRes); - return 0; } - NativewindowCommon_throwNewRuntimeException(curEnv, "Info: Nativewindow X11 Error: Display %p, Code 0x%X, errno %s", - dpy, e->error_code, errStr); + fflush(stderr); - if( NULL != newEnv ) { - // detached attached thread + if (NULL != jniEnv && shallBeDetached) { (*jvmHandle)->DetachCurrentThread(jvmHandle); } } -#if 0 - if(NULL!=origErrorHandler) { - origErrorHandler(dpy, e); - } -#endif - return 0; } -static void x11ErrorHandlerEnable(Display *dpy, int onoff, JNIEnv * env) { - if(errorHandlerBlocked) return; - +void NativewindowCommon_x11ErrorHandlerEnable(JNIEnv * env, Display *dpy, int onoff, int quiet, int sync) { + errorHandlerQuiet = quiet; if(onoff) { if(NULL==origErrorHandler) { setupJVMVars(env); - if(NULL!=dpy) { + origErrorHandler = XSetErrorHandler(x11ErrorHandler); + if(sync && NULL!=dpy) { XSync(dpy, False); } - origErrorHandler = XSetErrorHandler(x11ErrorHandler); } } else { if(NULL!=origErrorHandler) { - if(NULL!=dpy) { + if(sync && NULL!=dpy) { XSync(dpy, False); } XSetErrorHandler(origErrorHandler); @@ -230,46 +240,27 @@ static void x11ErrorHandlerEnable(Display *dpy, int onoff, JNIEnv * env) { } } -static void x11ErrorHandlerEnableBlocking(JNIEnv * env, int onoff, int quiet) { - errorHandlerBlocked = 0 ; - x11ErrorHandlerEnable(NULL, onoff, env); - errorHandlerBlocked = onoff ; - errorHandlerQuiet = quiet; -} - - static XIOErrorHandler origIOErrorHandler = NULL; static int x11IOErrorHandler(Display *dpy) { - JNIEnv *curEnv = NULL; - JNIEnv *newEnv = NULL; - int envRes ; const char * dpyName = XDisplayName(NULL); - const char * errStr = strerror(errno); + const char * errnoStr = strerror(errno); + char threadName[80]; + int shallBeDetached = 0; + JNIEnv *jniEnv = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); - fprintf(stderr, "Nativewindow X11 IOError: Display %p (%s): %s\n", dpy, dpyName, errStr); + (void) NativewindowCommon_GetStaticStringMethod(jniEnv, X11UtilClazz, getCurrentThreadNameID, threadName, sizeof(threadName), "n/a"); - // retrieve this thread's JNIEnv curEnv - or detect it's detached - envRes = (*jvmHandle)->GetEnv(jvmHandle, (void **) &curEnv, jvmVersion) ; - if( JNI_EDETACHED == envRes ) { - // detached thread - attach to JVM - if( JNI_OK != ( envRes = (*jvmHandle)->AttachCurrentThread(jvmHandle, (void**) &newEnv, NULL) ) ) { - fprintf(stderr, "Nativewindow X11 IOError: can't attach thread: %d\n", envRes); - return; - } - curEnv = newEnv; - } else if( JNI_OK != envRes ) { - // oops .. - fprintf(stderr, "Nativewindow X11 IOError: can't GetEnv: %d\n", envRes); - return; - } + fprintf(stderr, "Nativewindow X11 IOError (Thread %s): Display %p (%s): %s\n", threadName, dpy, dpyName, errnoStr); + (*jniEnv)->CallStaticVoidMethod(jniEnv, X11UtilClazz, dumpStackID); - NativewindowCommon_FatalError(curEnv, "Nativewindow X11 IOError: Display %p (%s): %s", dpy, dpyName, errStr); + if (NULL != jniEnv) { + NativewindowCommon_FatalError(jniEnv, "Nativewindow X11 IOError (Thread %s): Display %p (%s): %s", threadName, dpy, dpyName, errnoStr); - if( NULL != newEnv ) { - // detached attached thread - (*jvmHandle)->DetachCurrentThread(jvmHandle); + if (shallBeDetached) { + (*jvmHandle)->DetachCurrentThread(jvmHandle); + } } if(NULL!=origIOErrorHandler) { origIOErrorHandler(dpy); @@ -293,22 +284,31 @@ static int _initialized=0; static jboolean _xinitThreadsOK=JNI_FALSE; JNIEXPORT jboolean JNICALL -Java_jogamp_nativewindow_x11_X11Util_initialize0(JNIEnv *env, jclass _unused, jboolean firstUIActionOnProcess) { +Java_jogamp_nativewindow_x11_X11Util_initialize0(JNIEnv *env, jclass clazz, jboolean firstUIActionOnProcess, jboolean debug) { if(0==_initialized) { + if(debug) { + errorHandlerDebug = 1; + } + X11UtilClazz = (jclass)(*env)->NewGlobalRef(env, clazz); if( JNI_TRUE == firstUIActionOnProcess ) { if( 0 == XInitThreads() ) { fprintf(stderr, "Warning: XInitThreads() failed\n"); } else { _xinitThreadsOK=JNI_TRUE; - DBG_PRINT( "X11: XInitThreads() called for concurrent Thread support\n"); + if(debug) { + fprintf(stderr, "X11: XInitThreads() called for concurrent Thread support\n"); + } } - } else { - DBG_PRINT( "X11: XInitThreads() _not_ called for concurrent Thread support\n"); + } else if(debug) { + fprintf(stderr, "X11: XInitThreads() _not_ called for concurrent Thread support\n"); } _initClazzAccess(env); x11IOErrorHandlerEnable(1, env); _initialized=1; + if(JNI_TRUE == debug) { + fprintf(stderr, "Info: NativeWindow native init passed\n"); + } } return _xinitThreadsOK; } @@ -320,7 +320,7 @@ Java_jogamp_nativewindow_x11_X11Util_shutdown0(JNIEnv *env, jclass _unused) { JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Util_setX11ErrorHandler0(JNIEnv *env, jclass _unused, jboolean onoff, jboolean quiet) { - x11ErrorHandlerEnableBlocking(env, ( JNI_TRUE == onoff ) ? 1 : 0, ( JNI_TRUE == quiet ) ? 1 : 0); + NativewindowCommon_x11ErrorHandlerEnable(env, NULL, onoff ? 1 : 0, quiet ? 1 : 0, 0 /* no dpy, no sync */); } /* Java->C glue code: @@ -345,9 +345,9 @@ Java_jogamp_nativewindow_x11_X11Lib_XGetVisualInfo1__JJLjava_nio_ByteBuffer_2Lja if (arg3 != NULL) { _ptr3 = (int *) (((char*) (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) + arg3_byte_offset); } - x11ErrorHandlerEnable((Display *) (intptr_t) arg0, 1, env); + NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) arg0, 1, 0, 0); _res = XGetVisualInfo((Display *) (intptr_t) arg0, (long) arg1, (XVisualInfo *) _ptr2, (int *) _ptr3); - x11ErrorHandlerEnable((Display *) (intptr_t) arg0, 0, env); + NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) arg0, 0, 0, 0); count = _ptr3[0]; if (arg3 != NULL) { (*env)->ReleasePrimitiveArrayCritical(env, arg3, _ptr3, 0); @@ -368,9 +368,9 @@ Java_jogamp_nativewindow_x11_X11Lib_DefaultVisualID(JNIEnv *env, jclass _unused, if(0==display) { NativewindowCommon_FatalError(env, "invalid display connection.."); } - x11ErrorHandlerEnable((Display *) (intptr_t) display, 1, env); + NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) display, 1, 0, 0); r = (jlong) XVisualIDFromVisual( DefaultVisual( (Display*) (intptr_t) display, screen ) ); - x11ErrorHandlerEnable((Display *) (intptr_t) display, 0, env); + NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) display, 0, 0, 0); return r; } @@ -411,9 +411,9 @@ Java_jogamp_nativewindow_x11_X11Lib_XCloseDisplay__J(JNIEnv *env, jclass _unused if(0==display) { NativewindowCommon_FatalError(env, "invalid display connection.."); } - x11ErrorHandlerEnable((Display *) (intptr_t) display, 1, env); + NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 1, 0, 0); _res = XCloseDisplay((Display *) (intptr_t) display); - x11ErrorHandlerEnable(NULL, 0, env); + NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 0, 0, 0); return _res; } @@ -451,7 +451,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow return 0; } - x11ErrorHandlerEnable(dpy, 1, env); + NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 1, 0, 0); scrn = ScreenOfDisplay(dpy, scrn_idx); @@ -471,7 +471,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow if (visual==NULL) { - x11ErrorHandlerEnable(dpy, 0, env); + NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); NativewindowCommon_throwNewRuntimeException(env, "could not query Visual by given VisualID, bail out!"); return 0; } @@ -511,13 +511,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow visual, attrMask, &xswa); - XSync(dpy, False); XSelectInput(dpy, window, 0); // no events - XSync(dpy, False); - x11ErrorHandlerEnable(dpy, 0, env); + NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); DBG_PRINT( "X11: [CreateWindow] created window %p on display %p\n", window, dpy); @@ -541,11 +539,11 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_DestroyDummyWindow return; } - x11ErrorHandlerEnable(dpy, 1, env); + NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 1, 0, 0); XUnmapWindow(dpy, w); XSync(dpy, False); XDestroyWindow(dpy, w); - x11ErrorHandlerEnable(dpy, 0, env); + NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); } /* @@ -569,11 +567,11 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_x11_X11Lib_GetRelativeLocatio if( 0 == jdest_win ) { dest_win = root; } if( 0 == jsrc_win ) { src_win = root; } - x11ErrorHandlerEnable(dpy, 1, env); + NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 1, 0, 0); res = XTranslateCoordinates(dpy, src_win, dest_win, src_x, src_y, &dest_x, &dest_y, &child); - x11ErrorHandlerEnable(dpy, 0, env); + NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 0); DBG_PRINT( "X11: GetRelativeLocation0: %p %d/%d -> %p %d/%d - ok: %d\n", (void*)src_win, src_x, src_y, (void*)dest_win, dest_x, dest_y, (int)res); diff --git a/src/nativewindow/native/x11/Xmisc.h b/src/nativewindow/native/x11/Xmisc.h new file mode 100644 index 000000000..a44da950d --- /dev/null +++ b/src/nativewindow/native/x11/Xmisc.h @@ -0,0 +1,44 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#ifndef Xmisc_h +#define Xmisc_h + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void NativewindowCommon_x11ErrorHandlerEnable(JNIEnv * env, Display *dpy, int onoff, int quiet, int sync); + +#endif /* Xmisc_h */ diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Display.java b/src/newt/classes/jogamp/newt/driver/x11/X11Display.java index 9464b979b..8243fcf9d 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Display.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Display.java @@ -49,7 +49,7 @@ public class X11Display extends DisplayImpl { static { NEWTJNILibLoader.loadNEWT(); - if ( !initIDs0() ) { + if ( !initIDs0(X11Util.XERROR_STACKDUMP) ) { throw new NativeWindowException("Failed to initialize X11Display jmethodIDs"); } @@ -139,7 +139,7 @@ public class X11Display extends DisplayImpl { //---------------------------------------------------------------------- // Internals only // - private static native boolean initIDs0(); + private static native boolean initIDs0(boolean debug); private native void CompleteDisplay0(long handle); diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java index 143b94a57..9a5074c29 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java @@ -230,6 +230,9 @@ public class X11Window extends WindowImpl { // Internals only // + private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI + private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI + private final long getDisplayEDTHandle() { return ((X11Display) getScreen().getDisplay()).getEDTHandle(); } diff --git a/src/newt/native/NewtCommon.c b/src/newt/native/NewtCommon.c index 3713cfd6c..7f070e7d3 100644 --- a/src/newt/native/NewtCommon.c +++ b/src/newt/native/NewtCommon.c @@ -1,5 +1,6 @@ #include "NewtCommon.h" +#include static const char * const ClazzNameRuntimeException = "java/lang/RuntimeException"; static jclass runtimeExceptionClz=NULL; @@ -43,6 +44,24 @@ void NewtCommon_init(JNIEnv *env) { } } +const char * NewtCommon_GetStaticStringMethod(JNIEnv *jniEnv, jclass clazz, jmethodID jGetStrID, char *dest, int destSize, const char *altText) { + if(NULL != jniEnv && NULL != clazz && NULL != jGetStrID) { + jstring jstr = (jstring) (*jniEnv)->CallStaticObjectMethod(jniEnv, clazz, jGetStrID); + if(NULL != jstr) { + const char * str = (*jniEnv)->GetStringUTFChars(jniEnv, jstr, NULL); + if( NULL != str) { + strncpy(dest, str, destSize-1); + dest[destSize-1] = 0; // EOS + (*jniEnv)->ReleaseStringUTFChars(jniEnv, jstr, str); + return dest; + } + } + } + strncpy(dest, altText, destSize-1); + dest[destSize-1] = 0; // EOS + return dest; +} + jchar* NewtCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str) { jchar* strChars = NULL; diff --git a/src/newt/native/NewtCommon.h b/src/newt/native/NewtCommon.h index f5ca73b74..9a4e5ac70 100644 --- a/src/newt/native/NewtCommon.h +++ b/src/newt/native/NewtCommon.h @@ -34,6 +34,7 @@ void NewtCommon_init(JNIEnv *env); +const char * NewtCommon_GetStaticStringMethod(JNIEnv *jniEnv, jclass clazz, jmethodID jGetStrID, char *dest, int destSize, const char *altText); jchar* NewtCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str); void NewtCommon_FatalError(JNIEnv *env, const char* msg, ...); diff --git a/src/newt/native/X11Common.h b/src/newt/native/X11Common.h index cefef690f..982255b8a 100644 --- a/src/newt/native/X11Common.h +++ b/src/newt/native/X11Common.h @@ -70,9 +70,9 @@ extern jclass X11NewtWindowClazz; extern jmethodID insetsChangedID; extern jmethodID visibleChangedID; +void NewtDisplay_x11ErrorHandlerEnable(JNIEnv * env, Display *dpy, int onoff, int quiet, int sync); jobject getJavaWindowProperty(JNIEnv *env, Display *dpy, Window window, jlong javaObjectAtom, Bool showWarning); -void NewtDisplay_displayDispatchErrorHandlerEnable(int onoff, JNIEnv * env); Status NewtWindows_getRootAndParent (Display *dpy, Window w, Window * root_return, Window * parent_return); Status NewtWindows_updateInsets(JNIEnv *env, jobject jwindow, Display *dpy, Window window, int *left, int *right, int *top, int *bottom); diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 88ac0df7e..5e2dc7c61 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -38,6 +38,8 @@ static const char * const ClazzNameX11NewtWindow = "jogamp/newt/driver/x11/X11Wi static jmethodID displayCompletedID = NULL; +static jmethodID getCurrentThreadNameID = NULL; +static jmethodID dumpStackID = NULL; static jmethodID sizeChangedID = NULL; static jmethodID positionChangedID = NULL; static jmethodID focusChangedID = NULL; @@ -61,32 +63,51 @@ static void setupJVMVars(JNIEnv * env) { } static XErrorHandler origErrorHandler = NULL ; +static int errorHandlerQuiet = 0 ; +static int errorHandlerDebug = 0 ; +static int errorHandlerThrowException = 0; -static int displayDispatchErrorHandler(Display *dpy, XErrorEvent *e) +static int x11ErrorHandler(Display *dpy, XErrorEvent *e) { - fprintf(stderr, "Warning: NEWT X11 Error: DisplayDispatch %p, Code 0x%X, errno %s\n", dpy, e->error_code, strerror(errno)); - - if (e->error_code == BadAtom) { - fprintf(stderr, " BadAtom (%p): Atom probably already removed\n", (void*)e->resourceid); - } else if (e->error_code == BadWindow) { - fprintf(stderr, " BadWindow (%p): Window probably already removed\n", (void*)e->resourceid); - } else { + if(!errorHandlerQuiet) { + const char * errnoStr = strerror(errno); + char threadName[80]; + char errCodeStr[80]; + char reqCodeStr[80]; + int shallBeDetached = 0; - JNIEnv *jniEnv = NULL; - const char * errStr = strerror(errno); + JNIEnv *jniEnv = NewtCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); - fprintf(stderr, "Info: NEWT X11 Error: Display %p, Code 0x%X, errno %s\n", dpy, e->error_code, errStr); + (void) NewtCommon_GetStaticStringMethod(jniEnv, X11NewtWindowClazz, getCurrentThreadNameID, threadName, sizeof(threadName), "n/a"); + snprintf(errCodeStr, sizeof(errCodeStr), "%d", e->request_code); + XGetErrorDatabaseText(dpy, "XRequest", errCodeStr, "Unknown", reqCodeStr, sizeof(reqCodeStr)); + XGetErrorText(dpy, e->error_code, errCodeStr, sizeof(errCodeStr)); - jniEnv = NewtCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); - if(NULL==jniEnv) { - fprintf(stderr, "NEWT X11 Error: null JNIEnv"); - return; + fprintf(stderr, "Info: Newt X11 Error (Thread: %s): %d - %s, dpy %p, id %x, # %d: %d:%d %s\n", + threadName, e->error_code, errCodeStr, e->display, e->resourceid, e->serial, + e->request_code, e->minor_code, reqCodeStr); + + if( errorHandlerDebug ) { + (*jniEnv)->CallStaticVoidMethod(jniEnv, X11NewtWindowClazz, dumpStackID); } - NewtCommon_throwNewRuntimeException(jniEnv, "Info: NEWT X11 Error: Display %p, Code 0x%X, errno %s", - dpy, e->error_code, errStr); + if(errorHandlerThrowException) { + if(NULL != jniEnv) { + NewtCommon_throwNewRuntimeException(jniEnv, "Newt X11 Error (Thread: %s): %d - %s, dpy %p, id %x, # %d: %d:%d %s\n", + threadName, e->error_code, errCodeStr, e->display, e->resourceid, e->serial, + e->request_code, e->minor_code, reqCodeStr); + } else { + fprintf(stderr, "Nativewindow X11 Error: null JNIEnv"); + #if 0 + if(NULL!=origErrorHandler) { + origErrorHandler(dpy, e); + } + #endif + } + } + fflush(stderr); - if (shallBeDetached) { + if (NULL != jniEnv && shallBeDetached) { (*jvmHandle)->DetachCurrentThread(jvmHandle); } } @@ -94,14 +115,21 @@ static int displayDispatchErrorHandler(Display *dpy, XErrorEvent *e) return 0; } -void NewtDisplay_displayDispatchErrorHandlerEnable(int onoff, JNIEnv * env) { +void NewtDisplay_x11ErrorHandlerEnable(JNIEnv * env, Display *dpy, int onoff, int quiet, int sync) { + errorHandlerQuiet = quiet; if(onoff) { if(NULL==origErrorHandler) { setupJVMVars(env); - origErrorHandler = XSetErrorHandler(displayDispatchErrorHandler); + origErrorHandler = XSetErrorHandler(x11ErrorHandler); + if(sync && NULL!=dpy) { + XSync(dpy, False); + } } } else { if(NULL!=origErrorHandler) { + if(sync && NULL!=dpy) { + XSync(dpy, False); + } XSetErrorHandler(origErrorHandler); origErrorHandler = NULL; } @@ -241,10 +269,13 @@ static jint X11InputState2NewtModifiers(unsigned int xstate) { * Signature: (Z)Z */ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Display_initIDs0 - (JNIEnv *env, jclass clazz) + (JNIEnv *env, jclass clazz, jboolean debug) { jclass c; + if(debug) { + errorHandlerDebug = 1 ; + } NewtCommon_init(env); if(NULL==X11NewtWindowClazz) { @@ -260,6 +291,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Display_initIDs0 } displayCompletedID = (*env)->GetMethodID(env, clazz, "displayCompleted", "(JJ)V"); + getCurrentThreadNameID = (*env)->GetStaticMethodID(env, X11NewtWindowClazz, "getCurrentThreadName", "()Ljava/lang/String;"); + dumpStackID = (*env)->GetStaticMethodID(env, X11NewtWindowClazz, "dumpStack", "()V"); insetsChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "insetsChanged", "(ZIIII)V"); sizeChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sizeChanged", "(ZIIZ)V"); positionChangedID = (*env)->GetMethodID(env, X11NewtWindowClazz, "positionChanged", "(ZII)V"); @@ -275,6 +308,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Display_initIDs0 requestFocusID = (*env)->GetMethodID(env, X11NewtWindowClazz, "requestFocus", "(Z)V"); if (displayCompletedID == NULL || + getCurrentThreadNameID == NULL || + dumpStackID == NULL || insetsChangedID == NULL || sizeChangedID == NULL || positionChangedID == NULL || @@ -403,7 +438,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0 // DBG_PRINT( "X11: DispatchMessages dpy %p, win %p, Event %d\n", (void*)dpy, (void*)evt.xany.window, (int)evt.type); - NewtDisplay_displayDispatchErrorHandlerEnable(1, env); + NewtDisplay_x11ErrorHandlerEnable(env, dpy, 1, 0, 0); jwindow = getJavaWindowProperty(env, dpy, evt.xany.window, javaObjectAtom, #ifdef VERBOSE_ON @@ -413,7 +448,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0 #endif ); - NewtDisplay_displayDispatchErrorHandlerEnable(0, env); + NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); if(NULL==jwindow) { fprintf(stderr, "Warning: NEWT X11 DisplayDispatch %p, Couldn't handle event %d for X11 window %p\n", diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 0f93b3e76..daf9f2b53 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -683,12 +683,16 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_CloseWindow0 DBG_PRINT( "X11: CloseWindow START dpy %p, win %p\n", (void*)dpy, (void*)w); + NewtDisplay_x11ErrorHandlerEnable(env, dpy, 1, 0, 0); + jwindow = getJavaWindowProperty(env, dpy, w, javaObjectAtom, True); if(NULL==jwindow) { + NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); NewtCommon_throwNewRuntimeException(env, "could not fetch Java Window object, bail out!"); return; } if ( JNI_FALSE == (*env)->IsSameObject(env, jwindow, obj) ) { + NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); NewtCommon_throwNewRuntimeException(env, "Internal Error .. Window global ref not the same!"); return; } @@ -696,7 +700,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_CloseWindow0 XSync(dpy, False); XSelectInput(dpy, w, 0); XUnmapWindow(dpy, w); - XSync(dpy, False); + NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); // Drain all events related to this window .. Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom); @@ -757,7 +761,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_reconfigureWindow0 fsEWMHFlags |= _NET_WM_ABOVE; // toggle above } - NewtDisplay_displayDispatchErrorHandlerEnable(1, env); + NewtDisplay_x11ErrorHandlerEnable(env, dpy, 1, 0, 0); DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d, parent %p/%p, win %p, %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d, alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d, tempInvisible %d, fsEWMHFlags %d\n", (void*)dpy, screen_index, (void*) jparent, (void*)parent, (void*)w, @@ -775,7 +779,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_reconfigureWindow0 ( TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_ALWAYSONTOP(flags) ) ) { Bool enable = TST_FLAG_CHANGE_FULLSCREEN(flags) ? TST_FLAG_IS_FULLSCREEN(flags) : TST_FLAG_IS_ALWAYSONTOP(flags) ; if( NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, enable) ) { - NewtDisplay_displayDispatchErrorHandlerEnable(0, env); + NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); #ifdef FS_GRAB_KEYBOARD if(TST_FLAG_CHANGE_FULLSCREEN(flags)) { if(TST_FLAG_IS_FULLSCREEN(flags)) { @@ -859,7 +863,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_reconfigureWindow0 #endif } - NewtDisplay_displayDispatchErrorHandlerEnable(0, env); + NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); DBG_PRINT( "X11: reconfigureWindow0 X\n"); } -- cgit v1.2.3 From a26d6e9361fb3287cba053aaf1a6318c853da95a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 5 Jul 2012 14:32:48 +0200 Subject: NEWT/KD Adapt to 'new' KD Window Creation API, use EGLConfig --- .../classes/jogamp/newt/driver/kd/KDWindow.java | 10 ++++++---- src/newt/native/KDWindow.c | 21 ++++----------------- 2 files changed, 10 insertions(+), 21 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java index d34ffd593..bb76d21ff 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java +++ b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java @@ -37,6 +37,7 @@ package jogamp.newt.driver.kd; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; import javax.media.opengl.GLCapabilitiesImmutable; @@ -66,11 +67,12 @@ public class KDWindow extends WindowImpl { setGraphicsConfiguration(cfg); GLCapabilitiesImmutable eglCaps = (GLCapabilitiesImmutable) cfg.getChosenCapabilities(); - int[] eglAttribs = EGLGraphicsConfiguration.GLCapabilities2AttribList(eglCaps); + int eglConfigID = eglCaps.getVisualID(VIDType.EGL_CONFIG); + long eglConfig = EGLGraphicsConfiguration.EGLConfigId2EGLConfig(getDisplayHandle(), eglConfigID); - eglWindowHandle = CreateWindow(getDisplayHandle(), eglAttribs); + eglWindowHandle = CreateWindow(getDisplayHandle(), eglConfig); if (eglWindowHandle == 0) { - throw new NativeWindowException("Error creating egl window: "+cfg); + throw new NativeWindowException("Error creating egl window: "+cfg+", eglConfigID "+eglConfigID+", eglConfig 0x"+Long.toHexString(eglConfig)); } setVisible0(eglWindowHandle, false); setWindowHandle(RealizeWindow(eglWindowHandle)); @@ -135,7 +137,7 @@ public class KDWindow extends WindowImpl { // protected static native boolean initIDs(); - private native long CreateWindow(long displayHandle, int[] attributes); + private native long CreateWindow(long displayHandle, long eglConfig); private native long RealizeWindow(long eglWindowHandle); private native int CloseWindow(long eglWindowHandle, long userData); private native void setVisible0(long eglWindowHandle, boolean visible); diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c index dc999138c..5afe6fc7b 100644 --- a/src/newt/native/KDWindow.c +++ b/src/newt/native/KDWindow.c @@ -42,6 +42,7 @@ #include #include +#include #include "jogamp_newt_driver_kd_KDWindow.h" @@ -208,11 +209,10 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_KDWindow_initIDs } JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_KDWindow_CreateWindow - (JNIEnv *env, jobject obj, jlong display, jintArray jAttrs) + (JNIEnv *env, jobject obj, jlong display, jlong jeglConfig) { - jint * attrs = NULL; - jsize attrsLen; EGLDisplay dpy = (EGLDisplay)(intptr_t)display; + EGLConfig eglConfig = (EGLConfig)(intptr_t)jeglConfig; KDWindow *window = 0; if(dpy==NULL) { @@ -220,22 +220,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_KDWindow_CreateWindow return 0; } - attrsLen = (*env)->GetArrayLength(env, jAttrs); - if(0==attrsLen) { - fprintf(stderr, "[CreateWindow] attribute array size 0..\n"); - return 0; - } - attrs = (*env)->GetIntArrayElements(env, jAttrs, 0); - if(NULL==attrs) { - fprintf(stderr, "[CreateWindow] attribute array NULL..\n"); - return 0; - } - JOGLKDUserdata * userData = kdMalloc(sizeof(JOGLKDUserdata)); userData->magic = JOGL_KD_USERDATA_MAGIC; - window = kdCreateWindow(dpy, attrs, (void *)userData); - - (*env)->ReleaseIntArrayElements(env, jAttrs, attrs, 0); + window = kdCreateWindow(dpy, eglConfig, (void *)userData); if(NULL==window) { kdFree(userData); -- cgit v1.2.3 From d5866a5d55f9445c7cedc1df03dc7958d6fd229e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 5 Jul 2012 14:57:18 +0200 Subject: GLContext adds FBO availability to profile mapping; Fix GL[Auto]Drawable/GLContext re-association (switch) incl. unit test. - GLContext adds FBO availability to profile mapping - GLContext added 'GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly)' allowing to set the write GLDrawable. This method enables switching context/drawable. Fix GL[Auto]Drawable/GLContext re-association (switch) incl. unit test Commit eed8508ae1132e5f45f788e9cb3f3d5a1050ac70 impl. of GLAutoDrawable's setContext(..) enabled proper setting of the GLAutoDrawable context incl. updating the context's drawables. Test covers: - remove/set (GLContext, GLEventListener) of GL[Auto]Drawable - switch (GLContext, GLEventListener) of 2 GLAutoDrawables --- make/scripts/tests.sh | 28 +- src/jogl/classes/javax/media/opengl/GLContext.java | 249 ++++++++++++---- .../javax/media/opengl/GLDrawableFactory.java | 17 ++ src/jogl/classes/javax/media/opengl/GLProfile.java | 9 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 97 +++++-- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 10 +- .../jogamp/opengl/egl/EGLExternalContext.java | 2 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 2 +- src/newt/classes/jogamp/newt/WindowImpl.java | 2 + .../acore/TestGLContextDrawableSwitchNEWT.java | 322 +++++++++++++++++++++ .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 17 +- .../test/junit/jogl/demos/es2/RedSquareES2.java | 15 +- .../newt/parenting/TestParenting01cSwingAWT.java | 57 +++- 13 files changed, 695 insertions(+), 132 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 55fbc5378..852dd6f25 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -53,6 +53,10 @@ function jrun() { swton=$1 shift + #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" + #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.GLDebugMessageHandler" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL" @@ -68,11 +72,8 @@ function jrun() { #D_ARGS="-Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" - #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - #D_ARGS="-Djogl.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=600000" #D_ARGS="-Dnewt.debug.MainThread" #D_ARGS="-Dnewt.debug.Window" - #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" @@ -83,8 +84,10 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.NativeWindow" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" - #D_ARGS="-Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.X11Util.TraceDisplayLifecycle=true -Dnativewindow.debug.X11Util" + #D_ARGS="-Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.XSync" + #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" @@ -100,9 +103,6 @@ function jrun() { #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.EDT -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GraphicsConfiguration" #D_ARGS="-Dnewt.debug.EDT" - #D_ARGS="-Djogamp.debug=all -Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" - #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" - #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" @@ -211,7 +211,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* @@ -226,6 +225,15 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* + +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* + + +#testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* @@ -271,7 +279,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* @@ -384,8 +392,6 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #linux: -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* # osx: #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index bf6ee31df..ecfa230d2 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -46,13 +46,13 @@ import java.util.HashSet; import javax.media.nativewindow.AbstractGraphicsDevice; +import jogamp.opengl.Debug; +import jogamp.opengl.GLContextImpl; + import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; -import jogamp.opengl.Debug; -import jogamp.opengl.GLContextImpl; - /** Abstraction for an OpenGL rendering context. In order to perform OpenGL rendering, a context must be "made current" on the current thread. OpenGL rendering semantics specify that only one context @@ -70,9 +70,9 @@ public abstract class GLContext { public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true); /** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */ - public final static boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true); + public static final boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true); /** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */ - public final static boolean TRACE_GL = Debug.isPropertyDefined("jogl.debug.TraceGL", true); + public static final boolean TRACE_GL = Debug.isPropertyDefined("jogl.debug.TraceGL", true); /** Indicates that the context was not made current during the last call to {@link #makeCurrent makeCurrent}. */ public static final int CONTEXT_NOT_CURRENT = 0; @@ -81,32 +81,49 @@ public abstract class GLContext { /** Indicates that a newly-created context was made current during the last call to {@link #makeCurrent makeCurrent}. */ public static final int CONTEXT_CURRENT_NEW = 2; - /** ARB_create_context related: created via ARB_create_context. Cache key value. */ + /** ARB_create_context related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IS_ARB_CREATED = 1 << 0; - /** ARB_create_context related: compatibility profile. Cache key value. */ + /** ARB_create_context related: desktop compatibility profile. Cache key value. See {@link #isGLCompatibilityProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_PROFILE_COMPAT = 1 << 1; - /** ARB_create_context related: core profile. Cache key value. */ + /** ARB_create_context related: desktop core profile. Cache key value. See {@link #isGLCoreProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_PROFILE_CORE = 1 << 2; - /** ARB_create_context related: ES profile. Cache key value. */ + /** ARB_create_context related: ES profile. Cache key value. See {@link #isGLES()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_PROFILE_ES = 1 << 3; - /** ARB_create_context related: flag forward compatible. Cache key value. */ + /** ARB_create_context related: flag forward compatible. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_OPTION_FORWARD = 1 << 4; - /** ARB_create_context related: flag debug. Not a cache key. */ + /** ARB_create_context related: flag debug. Not a cache key. See {@link #setContextCreationFlags(int)}, {@link GLAutoDrawable#setContextCreationFlags(int)}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ public static final int CTX_OPTION_DEBUG = 1 << 5; - /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. */ + /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IMPL_ES2_COMPAT = 1 << 8; - /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. */ - protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 15; + /** Context supports FBO, details see {@link #hasFBO()}. + * Not a cache key. + * @see #hasFBO() + * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) + */ + protected static final int CTX_IMPL_FBO = 1 << 9; - private static ThreadLocal currentContext = new ThreadLocal(); + /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. See {@link #isHardwareRasterizer()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ + protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 15; - private HashMap attachedObjectsByString = new HashMap(); - private IntObjectHashMap attachedObjectsByInt = new IntObjectHashMap(); + protected static final String GL_ARB_ES2_compatibility = "GL_ARB_ES2_compatibility"; + protected static final String GL_ARB_framebuffer_object = "GL_ARB_framebuffer_object"; + protected static final String GL_EXT_framebuffer_object = "GL_EXT_framebuffer_object"; + protected static final String GL_EXT_framebuffer_blit = "GL_EXT_framebuffer_blit"; + protected static final String GL_EXT_framebuffer_multisample = "GL_EXT_framebuffer_multisample"; + protected static final String GL_EXT_packed_depth_stencil = "GL_EXT_packed_depth_stencil"; + protected static final String GL_ARB_texture_non_power_of_two = "GL_ARB_texture_non_power_of_two"; + protected static final String GL_EXT_texture_format_BGRA8888 = "GL_EXT_texture_format_BGRA8888"; + protected static final String GL_IMG_texture_format_BGRA8888 = "GL_IMG_texture_format_BGRA8888"; + + private static final ThreadLocal currentContext = new ThreadLocal(); + + private final HashMap attachedObjectsByString = new HashMap(); + private final IntObjectHashMap attachedObjectsByInt = new IntObjectHashMap(); // RecursiveLock maintains a queue of waiting Threads, ensuring the longest waiting thread will be notified at unlock. - protected RecursiveLock lock = LockFactory.createRecursiveLock(); + protected final RecursiveLock lock = LockFactory.createRecursiveLock(); /** The underlying native OpenGL context */ protected long contextHandle; @@ -137,36 +154,74 @@ public abstract class GLContext { } /** - * Returns the GLDrawable to which this context may be used to - * draw. + * Sets the read/write drawable for framebuffer operations. + *

+ * If the context was current on this thread, it is being released before switching the drawable + * and made current afterwards. However the user shall take extra care that not other thread + * attempts to make this context current. Otherwise a race condition may happen. + *

+ *

+ * Disclaimer: Even though the API may allows this functionality in theory, your mileage may vary + * switching the drawable of an already established GLContext, i.e. which is already made current once. + * FIXME: Validate functionality! + *

+ * @param readWrite the read/write drawable for framebuffer operations. + * @param setWriteOnly if true and if the current read-drawable differs + * from the write-drawable ({@link #setGLReadDrawable(GLDrawable)}), + * only change the write-drawable. Otherwise set both drawables. + * @return the replaced read/write drawable + * + * @throws GLException in case null is being passed or + * this context is made current on another thread. + * + * @see #isGLReadDrawableAvailable() + * @see #getGLReadDrawable() + * @see #setGLReadDrawable() + * @see #getGLDrawable() + */ + public abstract GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly); + + /** + * Returns the write-drawable this context uses for framebuffer operations. */ public abstract GLDrawable getGLDrawable(); /** - * Return availability of GL read drawable. - * @return true if a GL read drawable is supported with your driver, otherwise false. + * Query whether using a distinguished read-drawable is supported. + * @return true if using a read-drawable is supported with your driver/OS, otherwise false. */ public abstract boolean isGLReadDrawableAvailable(); /** - * Set the read GLDrawable for read framebuffer operations.
+ * Set the read-Drawable for read framebuffer operations.
* The caller should query if this feature is supported via {@link #isGLReadDrawableAvailable()}. + *

+ * If the context was current on this thread, it is being released before switching the drawable + * and made current afterwards. However the user shall take extra care that not other thread + * attempts to make this context current. Otherwise a race condition may happen. + *

* - * @param read the read GLDrawable for read framebuffer operations. - * If null is passed, the default write drawable will be set. + * @param read the read-drawable for read framebuffer operations. + * If null is passed, the default write drawable will be set. + * @return the replaced read-drawable * - * @throws GLException in case a read drawable is not supported - * and the given drawable is not null and not equal to the internal write drawable. + * @throws GLException in case a read drawable is not supported or + * this context is made current on another thread. * * @see #isGLReadDrawableAvailable() * @see #getGLReadDrawable() */ - public abstract void setGLReadDrawable(GLDrawable read); + public abstract GLDrawable setGLReadDrawable(GLDrawable read); /** - * Returns the read GLDrawable this context uses for read framebuffer operations. + * Returns the read-Drawable this context uses for read framebuffer operations. + *

+ * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)}, + * it equals to the write-drawable (default). + *

* @see #isGLReadDrawableAvailable() * @see #setGLReadDrawable(javax.media.opengl.GLDrawable) + * @see #getGLDrawable() */ public abstract GLDrawable getGLReadDrawable(); @@ -190,7 +245,7 @@ public abstract class GLContext { *

*

* This method is blocking, i.e. waits until another thread has - * released the context. + * released the context. *

*

* The drawable's surface is being locked at entry @@ -547,6 +602,28 @@ public abstract class GLContext { return 0 != ( ctxOptions & CTX_IMPL_ES2_COMPAT ) ; } + /** + * @return true if impl. is a hardware rasterizer, otherwise false. + * @see GLProfile#isHardwareRasterizer() + */ + public final boolean isHardwareRasterizer() { + return 0 == ( ctxOptions & CTX_IMPL_ACCEL_SOFT ) ; + } + + /** Returns whether the context supports FBO, hence is either GL-ES >= 2.0, >= core GL 3.0 or implements the extensions + * GL_ARB_ES2_compatibility, ARB_framebuffer_object or all of + * EXT_framebuffer_object, EXT_framebuffer_multisample, + * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil. + * @see #CTX_IMPL_FBO + */ + public final boolean hasFBO() { + return 0 != ( ctxOptions & CTX_IMPL_FBO ) ; + } + + /** + * @return true if context supports GLSL + * @see GLProfile#hasGLSL() + */ public final boolean hasGLSL() { return isGL2ES2() ; } @@ -555,60 +632,70 @@ public abstract class GLContext { public boolean isNPOTTextureAvailable() { return isGL3() || isGLES2Compatible() || isExtensionAvailable(GL_ARB_texture_non_power_of_two); } - private static final String GL_ARB_texture_non_power_of_two = "GL_ARB_texture_non_power_of_two"; public boolean isTextureFormatBGRA8888Available() { return isGL2GL3() || - isExtensionAvailable("GL_EXT_texture_format_BGRA8888") || - isExtensionAvailable("GL_IMG_texture_format_BGRA8888") ; + isExtensionAvailable(GL_EXT_texture_format_BGRA8888) || + isExtensionAvailable(GL_IMG_texture_format_BGRA8888) ; } + /** @see GLProfile#isGL4bc() */ public final boolean isGL4bc() { return ctxMajorVersion>=4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & CTX_PROFILE_COMPAT); } + /** @see GLProfile#isGL4() */ public final boolean isGL4() { return ctxMajorVersion>=4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); } + /** @see GLProfile#isGL3bc() */ public final boolean isGL3bc() { return ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=1 ) && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & CTX_PROFILE_COMPAT); } + /** @see GLProfile#isGL3() */ public final boolean isGL3() { return ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=1 ) && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); } - + + /** @see GLProfile#isGL2() */ public final boolean isGL2() { return ctxMajorVersion>=1 && 0!=(ctxOptions & CTX_PROFILE_COMPAT); } + /** @see GLProfile#isGL2GL3() */ public final boolean isGL2GL3() { return isGL2() || isGL3(); } + /** @see GLProfile#isGLES1() */ public final boolean isGLES1() { return ctxMajorVersion==1 && 0 != ( ctxOptions & CTX_PROFILE_ES ) ; } + /** @see GLProfile#isGLES2() */ public final boolean isGLES2() { return ctxMajorVersion==2 && 0 != ( ctxOptions & CTX_PROFILE_ES ) ; } + /** @see GLProfile#isGLES() */ public final boolean isGLES() { return 0 != ( CTX_PROFILE_ES & ctxOptions ) ; } + /** @see GLProfile#isGL2ES1() */ public final boolean isGL2ES1() { return isGL2() || isGLES1() ; } + /** @see GLProfile#isGL2ES2() */ public final boolean isGL2ES2() { return isGL2GL3() || isGLES2() ; } @@ -846,8 +933,11 @@ public abstract class GLContext { */ private static /*final*/ HashSet deviceVersionsAvailableSet = new HashSet(); - protected static String getDeviceVersionAvailableKey(AbstractGraphicsDevice device, int major, int profile) { - return device.getUniqueID() + "-" + toHexString(composeBits(major, profile, 0)); + /** clears the device/context mappings as well as the GL/GLX proc address tables. */ + protected static void shutdown() { + deviceVersionAvailable.clear(); + deviceVersionsAvailableSet.clear(); + GLContextImpl.shutdownImpl(); // well .. } protected static boolean getAvailableGLVersionsSet(AbstractGraphicsDevice device) { @@ -869,11 +959,8 @@ public abstract class GLContext { } } - /** clears the device/context mappings as well as the GL/GLX proc address tables. */ - protected static void shutdown() { - deviceVersionAvailable.clear(); - deviceVersionsAvailableSet.clear(); - GLContextImpl.shutdownImpl(); // well .. + protected static String getDeviceVersionAvailableKey(AbstractGraphicsDevice device, int major, int profile) { + return device.getUniqueID() + "-" + toHexString(composeBits(major, profile, 0)); } /** @@ -967,18 +1054,71 @@ public abstract class GLContext { } /** + * Returns the GLProfile's major version number and it's context property (CTP) for availability mapping request. + */ + protected static final void getRequestMajorAndCompat(final GLProfile glp, int[/*2*/] reqMajorCTP) { + final GLProfile glpImpl = glp.getImpl(); + if(glpImpl.isGL4()) { + reqMajorCTP[0]=4; + } else if (glpImpl.isGL3()) { + reqMajorCTP[0]=3; + } else /* if (glpImpl.isGL2()) */ { + reqMajorCTP[0]=2; + } + if( glpImpl.isGL2() ) { // incl GL3bc and GL4bc + reqMajorCTP[1]=CTX_PROFILE_COMPAT; + } else { + reqMajorCTP[1]=CTX_PROFILE_CORE; + } + } + + /** + * @param device the device the context profile is being requested for + * @param GLProfile the GLProfile the context profile is being requested for + * @return the GLProfile's context property (CTP) if available, otherwise 0 + */ + protected static final int getAvailableContextProperties(final AbstractGraphicsDevice device, final GLProfile glp) { + final int[] reqMajorCTP = new int[] { 0, 0 }; + getRequestMajorAndCompat(glp, reqMajorCTP); + + int _major[] = { 0 }; + int _minor[] = { 0 }; + int _ctp[] = { 0 }; + if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], + _major, _minor, _ctp)) { + return _ctp[0]; + } + return 0; // n/a + } + + /** + * @param device the device the profile is being requested * @param major Key Value either 1, 2, 3 or 4 * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES} - * @return the highest GLProfile string regarding the version and profile bits. - * @throws GLException if version and context profile bits could not be mapped to a GLProfile + * @return the highest GLProfile regarding availability, version and profile bits. */ - public static String getAvailableGLProfile(AbstractGraphicsDevice device, int reqMajor, int reqProfile) + protected static GLProfile getAvailableGLProfile(AbstractGraphicsDevice device, int reqMajor, int reqProfile) throws GLException { int major[] = { 0 }; int minor[] = { 0 }; int ctp[] = { 0 }; if(GLContext.getAvailableGLVersion(device, reqMajor, reqProfile, major, minor, ctp)) { - return GLContext.getGLProfile(major[0], minor[0], ctp[0]); + return GLProfile.get(GLContext.getGLProfile(major[0], minor[0], ctp[0])); + } + return null; + } + + /** + * @param device the device the profile is being requested + * @param major Key Value either 1, 2, 3 or 4 + * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES} + */ + protected static String getAvailableGLVersionAsString(AbstractGraphicsDevice device, int major, int profile) { + int _major[] = { 0 }; + int _minor[] = { 0 }; + int _ctp[] = { 0 }; + if(getAvailableGLVersion(device, major, profile, _major, _minor, _ctp)) { + return getGLVersion(_major[0], _minor[0], _ctp[0], null); } return null; } @@ -990,7 +1130,7 @@ public abstract class GLContext { * @param isHardware return value of one boolean, whether the profile is a hardware rasterizer or not * @return true if the requested GL version is available regardless of a software or hardware rasterizer, otherwise false. */ - public static boolean isGLVersionAvailable(AbstractGraphicsDevice device, int reqMajor, int reqProfile, boolean isHardware[]) { + protected static boolean isGLVersionAvailable(AbstractGraphicsDevice device, int reqMajor, int reqProfile, boolean isHardware[]) { Integer valI = getAvailableGLVersion(device, reqMajor, reqProfile); if(null==valI) { return false; @@ -1027,21 +1167,7 @@ public abstract class GLContext { return isGLVersionAvailable(device, 2, CTX_PROFILE_COMPAT, isHardware); } - /** - * @param major Key Value either 1, 2, 3 or 4 - * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES} - */ - public static String getAvailableGLVersionAsString(AbstractGraphicsDevice device, int major, int profile) { - int _major[] = { 0 }; - int _minor[] = { 0 }; - int _ctp[] = { 0 }; - if(getAvailableGLVersion(device, major, profile, _major, _minor, _ctp)) { - return getGLVersion(_major[0], _minor[0], _ctp[0], null); - } - return null; - } - - public static String getGLVersion(int major, int minor, int ctp, String gl_version) { + protected static String getGLVersion(int major, int minor, int ctp, String gl_version) { boolean needColon = false; StringBuilder sb = new StringBuilder(); sb.append(major); @@ -1055,6 +1181,7 @@ public abstract class GLContext { needColon = appendString(sb, "arb", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp )); needColon = appendString(sb, "debug", needColon, 0 != ( CTX_OPTION_DEBUG & ctp )); needColon = appendString(sb, "ES2 compatible", needColon, 0 != ( CTX_IMPL_ES2_COMPAT & ctp )); + needColon = appendString(sb, "FBO", needColon, 0 != ( CTX_IMPL_FBO & ctp )); if( 0 != ( CTX_IMPL_ACCEL_SOFT & ctp ) ) { needColon = appendString(sb, "software", needColon, true); } else { diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 1093685d6..d6480e7aa 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -492,6 +492,23 @@ public abstract class GLDrawableFactory { GLContext shareWith) throws GLException; + /** + * Returns true if it is possible to create an framebuffer object (FBO). + *

+ * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. + *

+ *

+ * FBO support is queried as described in {@link GLContext#hasFBO()}. + *

+ * + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. + * @param glp {@link GLProfile} to check for FBO capabilities + * @see GLContext#hasFBO() + */ + public final boolean canCreateFBO(AbstractGraphicsDevice device, GLProfile glp) { + return 0 != ( GLContext.CTX_IMPL_FBO & GLContext.getAvailableContextProperties(device, glp) ); + } + //---------------------------------------------------------------------- // Methods for interacting with third-party OpenGL libraries diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index ed457b0ea..cc4f6c517 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -113,9 +113,7 @@ public class GLProfile { * @param firstUIActionOnProcess Should be true if called before the first UI action of the running program, * otherwise false. * - * @deprecated This method shall not need to be called for other reasons than having a defined initialization sequence. - * To ensure homogeneous behavior with application not calling this method, you shall pass firstUIActionOnProcess=false. - * This method is subject to be removed in future versions of JOGL. + * @deprecated Use {@link #initSingleton()}. This method is subject to be removed in future versions of JOGL. */ public static void initSingleton(final boolean firstUIActionOnProcess) { initLock.lock(); @@ -1003,6 +1001,11 @@ public class GLProfile { public final boolean isGLES2() { return GLES2 == profile; } + + /** Indicates whether this profile is capable of GLES.

Includes [ GLES1, GLES2 ].

*/ + public final boolean isGLES() { + return GLES2 == profile || GLES1 == profile; + } /** Indicates whether this profile is capable of GL2ES1.

Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].

*/ public final boolean isGL2ES1() { diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 4ef8b9750..7362a2bd8 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -161,18 +161,22 @@ public abstract class GLContextImpl extends GLContext { } @Override - public final void setGLReadDrawable(GLDrawable read) { - if(null!=read && drawable!=read && !isGLReadDrawableAvailable()) { - throw new GLException("GL Read Drawable not available"); + public final GLDrawable setGLReadDrawable(GLDrawable read) { + if(!isGLReadDrawableAvailable()) { + throw new GLException("Setting read drawable feature not available"); } final boolean lockHeld = lock.isOwner(Thread.currentThread()); if(lockHeld) { release(); + } else if(lock.isLockedByOtherThread()) { // still could glitch .. + throw new GLException("GLContext current by other thread ("+lock.getOwner()+"), operation not allowed."); } + final GLDrawable old = drawableRead; drawableRead = ( null != read ) ? (GLDrawableImpl) read : drawable; if(lockHeld) { makeCurrent(); } + return old; } @Override @@ -180,6 +184,28 @@ public abstract class GLContextImpl extends GLContext { return drawableRead; } + @Override + public final GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly) { + if(null==readWrite) { + throw new GLException("Null read/write drawable not allowed"); + } + final boolean lockHeld = lock.isOwner(Thread.currentThread()); + if(lockHeld) { + release(); + } else if(lock.isLockedByOtherThread()) { // still could glitch .. + throw new GLException("GLContext current by other thread ("+lock.getOwner()+"), operation not allowed."); + } + if(!setWriteOnly || drawableRead==drawable) { // if !setWriteOnly || !explicitReadDrawable + drawableRead = (GLDrawableImpl) readWrite; + } + final GLDrawable old = drawable; + drawable = ( null != readWrite ) ? (GLDrawableImpl) readWrite : null; + if(lockHeld) { + makeCurrent(); + } + return old; + } + @Override public final GLDrawable getGLDrawable() { return drawable; @@ -630,13 +656,10 @@ public abstract class GLContextImpl extends GLContext { * @see #createContextARBImpl * @see #destroyContextARBImpl */ - protected final long createContextARB(long share, boolean direct) + protected final long createContextARB(final long share, final boolean direct) { - AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); - AbstractGraphicsDevice device = config.getScreen().getDevice(); - GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - GLProfile glp = glCaps.getGLProfile(); - GLProfile glpImpl = glp.getImpl(); + final AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); + final AbstractGraphicsDevice device = config.getScreen().getDevice(); if (DEBUG) { System.err.println(getThreadName() + ": createContextARB: mappedVersionsAvailableSet("+device.getConnection()+"): "+ @@ -650,22 +673,15 @@ public abstract class GLContextImpl extends GLContext { } } - int reqMajor; - if(glpImpl.isGL4()) { - reqMajor=4; - } else if (glpImpl.isGL3()) { - reqMajor=3; - } else /* if (glpImpl.isGL2()) */ { - reqMajor=2; - } - - boolean compat = glpImpl.isGL2(); // incl GL3bc and GL4bc + final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final int[] reqMajorCTP = new int[] { 0, 0 }; + getRequestMajorAndCompat(glCaps.getGLProfile(), reqMajorCTP); + int _major[] = { 0 }; int _minor[] = { 0 }; int _ctp[] = { 0 }; long _ctx = 0; - - if( GLContext.getAvailableGLVersion(device, reqMajor, compat?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, + if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], _major, _minor, _ctp)) { _ctp[0] |= additionalCtxCreationFlags; _ctx = createContextARBImpl(share, direct, _ctp[0], _major[0], _minor[0]); @@ -675,7 +691,7 @@ public abstract class GLContextImpl extends GLContext { } return _ctx; } - + private final boolean mapGLVersions(AbstractGraphicsDevice device) { synchronized (GLContext.deviceVersionAvailable) { boolean success = false; @@ -698,10 +714,11 @@ public abstract class GLContextImpl extends GLContext { private final boolean createContextARBMapVersionsAvailable(int reqMajor, boolean compat) { long _context; int reqProfile = compat ? CTX_PROFILE_COMPAT : CTX_PROFILE_CORE ; - int ctp = CTX_IS_ARB_CREATED | CTX_PROFILE_CORE; // default + int ctp = CTX_IS_ARB_CREATED; if(compat) { - ctp &= ~CTX_PROFILE_CORE ; - ctp |= CTX_PROFILE_COMPAT ; + ctp |= CTX_PROFILE_COMPAT ; + } else { + ctp |= CTX_PROFILE_CORE ; } // To ensure GL profile compatibility within the JOGL application @@ -1070,10 +1087,15 @@ public abstract class GLContextImpl extends GLContext { } } } - if( isExtensionAvailable("GL_ARB_ES2_compatibility") ) { + + if( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) && ctxMajorVersion >= 2 || + isExtensionAvailable(GL_ARB_ES2_compatibility) ) { ctxProfileBits |= CTX_IMPL_ES2_COMPAT; + ctxProfileBits |= CTX_IMPL_FBO; + } else if( hasFBOImpl(ctxMajorVersion, ctxProfileBits, extensionAvailability) ) { + ctxProfileBits |= CTX_IMPL_FBO; } - + // // Set GL Version (complete w/ version string) // @@ -1081,7 +1103,24 @@ public abstract class GLContextImpl extends GLContext { setDefaultSwapInterval(); } - + + protected static final boolean hasFBOImpl(int ctxMajorVersion, int ctxProfileBits, ExtensionAvailabilityCache extCache) { + return ( ctxMajorVersion >= 3 ) || // any >= 3.0 GL ctx + + ( 0 != (ctxProfileBits & CTX_PROFILE_ES) && ctxMajorVersion >= 2 ) || // ES >= 2.0 + + ( null != extCache && + + ( extCache.isExtensionAvailable(GL_ARB_ES2_compatibility) ) || // ES 2.0 compatible + + ( extCache.isExtensionAvailable(GL_ARB_framebuffer_object) ) || // ARB_framebuffer_object + + ( extCache.isExtensionAvailable(GL_EXT_framebuffer_object) && // EXT_framebuffer_object* + extCache.isExtensionAvailable(GL_EXT_framebuffer_multisample) && + extCache.isExtensionAvailable(GL_EXT_framebuffer_blit) && + extCache.isExtensionAvailable(GL_EXT_packed_depth_stencil) ) ); + } + protected final void removeCachedVersion(int major, int minor, int ctxProfileBits) { if(!isCurrentContextHardwareRasterizer()) { ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; @@ -1212,7 +1251,7 @@ public abstract class GLContextImpl extends GLContext { protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits) { // remove non-key values - ctxProfileBits &= ~( GLContext.CTX_OPTION_DEBUG | GLContext.CTX_IMPL_ES2_COMPAT ) ; + ctxProfileBits &= ~( GLContext.CTX_OPTION_DEBUG | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) ; return device.getUniqueID() + "-" + toHexString(composeBits(major, minor, ctxProfileBits)); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 06cd550b4..65a4c3ece 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -224,15 +224,7 @@ public abstract class EGLContext extends GLContextImpl { throw new GLException("Error making context 0x" + Long.toHexString(contextHandle) + " current: error code " + EGL.eglGetError()); } - int ctp = CTX_PROFILE_ES; - int major; - if(glProfile.usesNativeGLES2()) { - ctp |= CTX_IMPL_ES2_COMPAT; - major = 2; - } else { - major = 1; - } - setGLFunctionAvailability(true, major, 0, ctp); + setGLFunctionAvailability(true, glProfile.usesNativeGLES2() ? 2 : 1, 0, CTX_PROFILE_ES); return true; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java index 0a451e5eb..585638d21 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java @@ -45,7 +45,7 @@ public class EGLExternalContext extends EGLContext { public EGLExternalContext(AbstractGraphicsScreen screen) { super(null, null); GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_IS_ARB_CREATED|CTX_PROFILE_ES); + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_ES); getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 96baab3ae..5cc0d765c 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -531,7 +531,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return; } - window.lockWindow(); // sync: context/drawable could been recreated/destroyed while animating + window.lockWindow(); // sync: context/drawable could have been recreated/destroyed while animating try { if( null == context && 0 s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + animator.pause(); + + if(0 == s%2) { + glad1.addGLEventListener(0, glad2.removeGLEventListener(0)); + GLContext ctx1 = glad1.setContext(glad2.getContext()); + glad2.setContext(ctx1); + } else { + glad2.addGLEventListener(0, glad1.removeGLEventListener(0)); + GLContext ctx2 = glad2.setContext(glad1.getContext()); + glad1.setContext(ctx2); + } + + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + + animator.resume(); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + glad1.destroy(); + glad2.destroy(); + } + + @Test(timeout=30000) + public void testSwitch2GLWindowOneDemo() throws InterruptedException { + GearsES2 gears = new GearsES2(1); + final QuitAdapter quitAdapter = new QuitAdapter(); + + GLWindow glWindow1 = GLWindow.create(caps); + glWindow1.setTitle("win1"); + glWindow1.setSize(width, height); + glWindow1.setPosition(64, 64); + glWindow1.addGLEventListener(0, gears); + glWindow1.addWindowListener(quitAdapter); + + GLWindow glWindow2 = GLWindow.create(caps); + glWindow2.setTitle("win2"); + glWindow2.setSize(width+100, height+100); + glWindow2.setPosition(2*64+width, 64); + glWindow2.addWindowListener(quitAdapter); + + Animator animator = new Animator(); + animator.add(glWindow1); + animator.add(glWindow2); + animator.start(); + + glWindow1.setVisible(true); + glWindow2.setVisible(true); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + animator.pause(); + + if(0 == s%2) { + glWindow1.addGLEventListener(0, glWindow2.removeGLEventListener(0)); + GLContext ctx1 = glWindow1.setContext(glWindow2.getContext()); + glWindow2.setContext(ctx1); + } else { + glWindow2.addGLEventListener(0, glWindow1.removeGLEventListener(0)); + GLContext ctx2 = glWindow2.setContext(glWindow1.getContext()); + glWindow1.setContext(ctx2); + } + + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + + animator.resume(); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + glWindow1.destroy(); + glWindow2.destroy(); + + } + + @Test(timeout=30000) + public void testSwitch2GLWindowEachWithOwnDemo() throws InterruptedException { + GearsES2 gears = new GearsES2(1); + RedSquareES2 rsquare = new RedSquareES2(1); + final QuitAdapter quitAdapter = new QuitAdapter(); + + GLWindow glWindow1 = GLWindow.create(caps); + glWindow1.setTitle("win1"); + glWindow1.setSize(width, height); + glWindow1.setPosition(64, 64); + glWindow1.addGLEventListener(0, gears); + glWindow1.addWindowListener(quitAdapter); + + GLWindow glWindow2 = GLWindow.create(caps); + glWindow2.setTitle("win2"); + glWindow2.setSize(width+100, height+100); + glWindow2.setPosition(2*64+width, 64); + glWindow2.addGLEventListener(0, rsquare); + glWindow2.addWindowListener(quitAdapter); + + Animator animator = new Animator(); + animator.add(glWindow1); + animator.add(glWindow2); + animator.start(); + + glWindow1.setVisible(true); + glWindow2.setVisible(true); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + animator.pause(); + + GLEventListener demo1 = glWindow1.removeGLEventListener(0); + GLEventListener demo2 = glWindow2.removeGLEventListener(0); + + GLContext ctx1 = glWindow1.setContext(glWindow2.getContext()); + glWindow1.addGLEventListener(0, demo2); + + glWindow2.setContext(ctx1); + glWindow2.addGLEventListener(0, demo1); + + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + + animator.resume(); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + glWindow1.destroy(); + glWindow2.destroy(); + + } + + // default timing for 2 switches + static long duration = 2200; // ms + static long period = 1000; // ms + + public static void main(String args[]) throws IOException { + for(int i=0; i XAWT related). + * Or ensure old/new parent is visible, see below. + * SwingUtilities.invokeAndWait(new Runnable() { public void run() { + System.err.println("Demos: 1 - X Container 1"); + container1.remove(newtCanvasAWT); + jFrame1.validate(); + System.err.println("Demos: 1 - X Container 2"); + jPanel2.remove(newtCanvasAWT); + jFrame2.validate(); + } }); */ + /* + * Invisible X11 windows may also case BadMatch (-> XAWT related) + */ + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + System.err.println("Demos: 2 - !visible"); jFrame1.setVisible(false); + System.err.println("Demos: 3 - !visible"); jFrame2.setVisible(false); } }); Assert.assertEquals(true, glWindow1.isNativeValid()); SwingUtilities.invokeAndWait(new Runnable() { public void run() { + System.err.println("Demos: 4 - X frame"); jFrame1.dispose(); + System.err.println("Demos: 5 - X frame"); jFrame2.dispose(); } }); Assert.assertEquals(true, glWindow1.isNativeValid()); + System.err.println("Demos: 6 - X GLWindow"); glWindow1.destroy(); Assert.assertEquals(false, glWindow1.isNativeValid()); + + System.err.println("Demos: 7 - X DisturbanceThread"); + disturbanceAction.stopAndWaitUntilDone(); } public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { @@ -393,8 +424,10 @@ public class TestParenting01cSwingAWT extends UITestCase { waitReparent = atoi(args[++i]); } } - System.out.println("durationPerTest "+durationPerTest); - System.out.println("waitReparent "+waitReparent); + System.err.println("durationPerTest "+durationPerTest); + System.err.println("waitReparent "+waitReparent); + org.junit.runner.JUnitCore.main(TestParenting01cSwingAWT.class.getName()); + /** String tstname = TestParenting01cSwingAWT.class.getName(); org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] { tstname, @@ -406,7 +439,7 @@ public class TestParenting01cSwingAWT extends UITestCase { "logfailedtests=true", "logtestlistenerevents=true", "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter", - "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); + "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); */ } } -- cgit v1.2.3 From e85e3ec2a73ac35aaf911f0b1e34b234be1622da Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 6 Jul 2012 01:20:48 +0200 Subject: Enhance Bootsrapping of JOGL around 37% - 40% (1st start in new JVM) - GLProfile and GLContext* GLProfile: Enhance bootsrapping performance of loading GL*Impl class - Offthread classloading of all GL*Impl via reflection at startup reduces startup time here around 12% (800ms down to 700ms). GLContext*: Enhance bootsrapping performance of querying available GL profiles - Add PROFILE_ALIASING mode, defaults to true - can be disabled w/ property 'jogl.debug.GLContext.NoProfileAliasing' - PROFILE_ALIASING: If true (default), bootstrapping the available GL profiles will use the highest compatible GL context for each profile, hence skipping querying lower profiles if a compatible higher one is found. Linux x86_64 - Nvidia: 28%, 700ms down to 500ms Linux x86_64 - AMD : 40%, 1500ms down to 900ms - GL*Impl: - make fields final: glProfile, _context, buffer*Tracker and glStateTracker - allow null _context/glProfile in initialization (bootstrapping) - JoglVersion.getDefaultOpenGLInfo(..) - add arg: 'boolean withCapabilitiesInfo', allowing to suppres the list of caps --- .../config/jogl/gl-impl-CustomJavaCode-common.java | 4 +- make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java | 18 ++-- make/config/jogl/gl-impl-CustomJavaCode-gles1.java | 18 ++-- make/config/jogl/gl-impl-CustomJavaCode-gles2.java | 18 ++-- make/scripts/tests.sh | 5 +- .../classes/com/jogamp/opengl/JoglVersion.java | 16 ++-- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 2 +- src/jogl/classes/javax/media/opengl/GLContext.java | 71 +++++++++++++-- src/jogl/classes/javax/media/opengl/GLProfile.java | 81 +++++++++-------- .../classes/javax/media/opengl/awt/GLCanvas.java | 2 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 100 +++++++++++++++++---- .../jogamp/opengl/x11/glx/X11GLXContext.java | 10 +-- .../classes/com/jogamp/newt/opengl/GLWindow.java | 2 +- .../classes/jogamp/newt/driver/android/MD.java | 2 +- .../test/junit/jogl/acore/TestGLProfile01NEWT.java | 2 +- .../junit/jogl/acore/TestShutdownCompleteNEWT.java | 19 ++-- 16 files changed, 261 insertions(+), 109 deletions(-) (limited to 'src/newt/classes') diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java index 2c3227ee5..d552bc6e4 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-common.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java @@ -1,7 +1,7 @@ public GLProfile getGLProfile() { return this.glProfile; } - private GLProfile glProfile; + private final GLProfile glProfile; public int glGetBoundBuffer(int target) { return bufferStateTracker.getBoundBufferObject(target, this); @@ -46,7 +46,7 @@ return _context; } - private GLContextImpl _context; + private final GLContextImpl _context; /** * @see javax.media.opengl.GLContext#setSwapInterval(int) diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index dc4f898e6..95aa7cc2c 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -17,9 +17,15 @@ public void setObjectTracker(GLObjectTracker tracker) { public GL4bcImpl(GLProfile glp, GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); - this.bufferStateTracker = context.getBufferStateTracker(); - this.glStateTracker = context.getGLStateTracker(); + if(null != context) { + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); + } else { + this.bufferSizeTracker = null; + this.bufferStateTracker = null; + this.glStateTracker = null; + } this.glProfile = glp; } @@ -35,9 +41,9 @@ public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, // Helpers for ensuring the correct amount of texture data // -private GLBufferSizeTracker bufferSizeTracker; -private GLBufferStateTracker bufferStateTracker; -private GLStateTracker glStateTracker; +private final GLBufferSizeTracker bufferSizeTracker; +private final GLBufferStateTracker bufferStateTracker; +private final GLStateTracker glStateTracker; private boolean bufferObjectExtensionsInitialized = false; private boolean haveARBPixelBufferObject; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java index 9b0d98fe9..dff33cf81 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java @@ -1,8 +1,14 @@ public GLES1Impl(GLProfile glp, GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); - this.bufferStateTracker = context.getBufferStateTracker(); - this.glStateTracker = context.getGLStateTracker(); + if(null != context) { + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); + } else { + this.bufferSizeTracker = null; + this.bufferStateTracker = null; + this.glStateTracker = null; + } this.glProfile = glp; } @@ -106,9 +112,9 @@ public final GL2GL3 getGL2GL3() throws GLException { // Helpers for ensuring the correct amount of texture data // -private GLBufferSizeTracker bufferSizeTracker; -private GLBufferStateTracker bufferStateTracker; -private GLStateTracker glStateTracker; +private final GLBufferSizeTracker bufferSizeTracker; +private final GLBufferStateTracker bufferStateTracker; +private final GLStateTracker glStateTracker; private boolean bufferObjectExtensionsInitialized = false; private boolean haveOESFramebufferObject; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java index ea6544d29..a4976f5ea 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java @@ -4,9 +4,15 @@ private boolean inBeginEndPair; public GLES2Impl(GLProfile glp, GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); - this.bufferStateTracker = context.getBufferStateTracker(); - this.glStateTracker = context.getGLStateTracker(); + if(null != context) { + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); + } else { + this.bufferSizeTracker = null; + this.bufferStateTracker = null; + this.glStateTracker = null; + } this.glProfile = glp; } @@ -110,9 +116,9 @@ public final GL2GL3 getGL2GL3() throws GLException { // Helpers for ensuring the correct amount of texture data // -private GLBufferSizeTracker bufferSizeTracker; -private GLBufferStateTracker bufferStateTracker; -private GLStateTracker glStateTracker; +private final GLBufferSizeTracker bufferSizeTracker; +private final GLBufferStateTracker bufferStateTracker; +private final GLStateTracker glStateTracker; private boolean bufferObjectExtensionsInitialized = false; private boolean haveOESFramebufferObject; diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 852dd6f25..10890c786 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -53,6 +53,7 @@ function jrun() { swton=$1 shift + #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" @@ -214,7 +215,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* @@ -226,7 +227,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java index c8e5d212b..75785fd86 100644 --- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java +++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java @@ -93,22 +93,24 @@ public class JoglVersion extends JogampVersion { return sb; } - public static StringBuilder getDefaultOpenGLInfo(StringBuilder sb) { + public static StringBuilder getDefaultOpenGLInfo(StringBuilder sb, boolean withCapabilitiesInfo) { if(null==sb) { sb = new StringBuilder(); } final AbstractGraphicsDevice device = GLProfile.getDefaultDevice(); - sb.append("Default Profiles ").append(Platform.getNewline()); + sb.append("Default Profiles on device ").append(device).append(Platform.getNewline()); if(null!=device) { GLProfile.glAvailabilityToString(device, sb, "\t", 1); } else { sb.append("none"); } - sb.append(Platform.getNewline()).append(Platform.getNewline()); - sb.append("Desktop Capabilities: ").append(Platform.getNewline()); - getAvailableCapabilitiesInfo(GLDrawableFactory.getDesktopFactory(), device, sb); - sb.append("EGL Capabilities: ").append(Platform.getNewline()); - getAvailableCapabilitiesInfo(GLDrawableFactory.getEGLFactory(), device, sb); + if(withCapabilitiesInfo) { + sb.append(Platform.getNewline()).append(Platform.getNewline()); + sb.append("Desktop Capabilities: ").append(Platform.getNewline()); + getAvailableCapabilitiesInfo(GLDrawableFactory.getDesktopFactory(), device, sb); + sb.append("EGL Capabilities: ").append(Platform.getNewline()); + getAvailableCapabilitiesInfo(GLDrawableFactory.getEGLFactory(), device, sb); + } return sb; } diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 62b496891..571f5c5b2 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -570,7 +570,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { // System.err.println(NativeWindowVersion.getInstance()); System.err.println(JoglVersion.getInstance()); - System.err.println(JoglVersion.getDefaultOpenGLInfo(null).toString()); + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, true).toString()); final GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault(GLProfile.getDefaultDevice()) ); final Display display = new Display(); diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index ecfa230d2..351f90027 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -43,12 +43,15 @@ package javax.media.opengl; import java.nio.IntBuffer; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; import javax.media.nativewindow.AbstractGraphicsDevice; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; +import com.jogamp.common.os.Platform; import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; @@ -66,6 +69,32 @@ import com.jogamp.common.util.locks.RecursiveLock; abstraction provides a stable object which clients can use to refer to a given context. */ public abstract class GLContext { + /** + * If true (default), bootstrapping the available GL profiles + * will use the highest compatible GL context for each profile, + * hence skipping querying lower profiles if a compatible higher one is found: + *
    + *
  • 4.2-core -> 4.2-core, 3.3-core
  • + *
  • 4.2-comp -> 4.2-comp, 3.3-comp, 2
  • + *
+ * Otherwise the dedicated GL context would be queried and used: + *
    + *
  • 4.2-core -> 4.2-core
  • + *
  • 3.3-core -> 3.3-core
  • + *
  • 4.2-comp -> 4.2-comp
  • + *
  • 3.3-comp -> 3.3-comp
  • + *
  • 3.0-comp -> 2
  • + *
+ * Using aliasing speeds up initialization about: + *

- +

+

Another implementation detail is the drawable reconfiguration. One use case is where a window is being dragged to another screen with a different pixel configuration, ie {@link GLCapabilities}. The implementation - shall be able to detect such cases in conjunction with the associated {@link javax.media.nativewindow.NativeSurface NativeSurface}.
+ shall be able to detect such cases in conjunction with the associated {@link javax.media.nativewindow.NativeSurface NativeSurface}.
For example, AWT's {@link java.awt.Canvas} 's {@link java.awt.Canvas#getGraphicsConfiguration getGraphicsConfiguration()} is capable to determine a display device change. This is demonstrated within {@link javax.media.opengl.awt.GLCanvas}'s and NEWT's AWTCanvas {@link javax.media.opengl.awt.GLCanvas#getGraphicsConfiguration getGraphicsConfiguration()} specialization. Another demonstration is NEWT's {@link javax.media.nativewindow.NativeWindow NativeWindow} - implementation on the Windows platform, which utilizes the native platform's MonitorFromWindow(HWND) function.
+ implementation on the Windows platform, which utilizes the native platform's MonitorFromWindow(HWND) function.
All OpenGL resources shall be regenerated, while the drawable's {@link GLCapabilities} has - to be choosen again. The following protocol shall be satisfied. + to be chosen again. The following protocol shall be satisfied.

  • Controlled disposal:
    • @@ -97,16 +97,16 @@ import jogamp.opengl.Debug;
    Note: Current graphics driver keep the surface configuration for a given window, even if the window is moved to a monitor with a different pixel configuration, ie 32bpp to 16bpp. However, it is best to not assume such behavior - and make your application comply with the above protocol.

    - - However, to not introduce to much breakage with older applications and because of the situation + and make your application comply with the above protocol. +

    + Avoiding breakage with older applications and because of the situation mentioned above, the boolean system property jogl.screenchange.action will control the - screen change action as follows:
    - + screen change action as follows:

         -Djogl.screenchange.action=false Disable the drawable reconfiguration (the default)
         -Djogl.screenchange.action=true  Enable  the drawable reconfiguration
         
    +

    */ public interface GLAutoDrawable extends GLDrawable { /** Flag reflecting wheather the drawable reconfiguration will be issued in @@ -362,5 +362,29 @@ public interface GLAutoDrawable extends GLDrawable { demos for examples. @return the set GL pipeline or null if not successful */ public GL setGL(GL gl); + + /** + * Method may return the upstream UI toolkit object + * holding this {@link GLAutoDrawable} instance, if exist. + *

    + * Currently known Java UI toolkits and it's known return types are: + * + * + *
    Toolkit GLAutoDrawable Implementation ~ Return Type of getUpstreamWidget() + *
    NEWT {@link com.jogamp.newt.opengl.GLWindow} has a {@link com.jogamp.newt.Window} + *
    SWT {@link com.jogamp.opengl.swt.GLCanvas} is a {@link org.eclipse.swt.widgets.Canvas} + *
    AWT {@link javax.media.opengl.awt.GLCanvas} is a {@link java.awt.Canvas} + *
    AWT {@link javax.media.opengl.awt.GLJPanel} is a {@link javax.swing.JPanel} + *
    + * However, the result may be other object types than the listed above + * due to new supported toolkits. + *

    + *

    + * This method may also return null if no UI toolkit is being used, + * as common for offscreen rendering. + *

    + * @return + */ + public Object getUpstreamWidget(); } diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java index 89d5cc4cb..1f6166719 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java @@ -56,8 +56,14 @@ import jogamp.opengl.GLDrawableImpl; public class GLAutoDrawableDelegate extends GLAutoDrawableBase { public static final boolean DEBUG = Debug.debug("GLAutoDrawableDelegate"); - public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context) { + /** + * @param drawable + * @param context + * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. + */ + public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget) { super((GLDrawableImpl)drawable, (GLContextImpl)context); + this.upstreamWidget = null; } // @@ -80,8 +86,14 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase { // Complete GLAutoDrawable // - private RecursiveLock lock = LockFactory.createRecursiveLock(); // instance wide lock - + private final RecursiveLock lock = LockFactory.createRecursiveLock(); // instance wide lock + private final Object upstreamWidget; + + @Override + public final Object getUpstreamWidget() { + return upstreamWidget; + } + /** * {@inheritDoc} *

    diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index bd24b15bc..f5831a72d 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -340,5 +340,60 @@ public interface GLBase { * completeness. */ public Object getExtension(String extensionName); + + /** Aliased entrypoint of void {@native glClearDepth}(GLclampd depth); and void {@native glClearDepthf}(GLclampf depth); . */ + public void glClearDepth( double depth ); + + /** Aliased entrypoint of void {@native glDepthRange}(GLclampd depth); and void {@native glDepthRangef}(GLclampf depth); . */ + public void glDepthRange(double zNear, double zFar); + + /** + * @param target a GL buffer (VBO) target as used in {@link GL#glBindBuffer(int, int)}, ie {@link GL#GL_ELEMENT_ARRAY_BUFFER}, {@link GL#GL_ARRAY_BUFFER}, .. + * @return the GL buffer (VBO) name bound to a target via {@link GL#glBindBuffer(int, int)} or 0 if unbound. + */ + public int glGetBoundBuffer(int target); + + /** + * @param buffer a GL buffer name, generated with {@link GL#glGenBuffers(int, int[], int)} and used in {@link GL#glBindBuffer(int, int)}, {@link GL#glBufferData(int, long, java.nio.Buffer, int)} or {@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)} for example. + * @return the size of the given GL buffer + */ + public long glGetBufferSize(int buffer); + + /** + * @return true if a VBO is bound to {@link GL.GL_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false + */ + public boolean glIsVBOArrayEnabled(); + + /** + * @return true if a VBO is bound to {@link GL.GL_ELEMENT_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false + */ + public boolean glIsVBOElementArrayEnabled(); + + /** + * Return the framebuffer name bound to this context, + * see {@link GL#glBindFramebuffer(int, int)}. + */ + public int getBoundFramebuffer(int target); + + /** + * Return the default draw framebuffer name. + *

    + * May differ from it's default zero + * in case an framebuffer object ({@link FBObject}) based drawable + * is being used. + *

    + */ + public int getDefaultDrawFramebuffer(); + + /** + * Return the default read framebuffer name. + *

    + * May differ from it's default zero + * in case an framebuffer object ({@link FBObject}) based drawable + * is being used. + *

    + */ + public int getDefaultReadFramebuffer(); + } diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java index e5258bcfd..8845ec665 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java @@ -183,8 +183,8 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil return -1; } - final int ms = sampleBuffers ? numSamples : 0; - final int xms = caps.getSampleBuffers() ? caps.getNumSamples() : 0; + final int ms = getNumSamples(); + final int xms = caps.getNumSamples() ; if(ms > xms) { return 1; @@ -231,15 +231,13 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil /** * Enables or disables pbuffer usage. *

    - * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)} - * and {@link #setFBO(int) setFBO(false)}
    + * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)}. *

    * Defaults to false. */ public void setPBuffer(boolean enable) { if(enable) { setOnscreen(false); - setFBO(false); } isPBuffer = enable; } @@ -252,28 +250,28 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil /** * Enables or disables FBO usage. *

    - * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)} - * and {@link #setPBuffer(int) setPBuffer(false)}
    + * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)}. *

    * Defaults to false. */ public void setFBO(boolean enable) { if(enable) { setOnscreen(false); - setPBuffer(false); } isFBO = enable; } /** * Sets whether the drawable surface supports onscreen.
    - * If enabled this method also invokes {@link #setPBuffer(int) setPBuffer(false)}
    + * If enabled this method also invokes {@link #setPBuffer(int) setPBuffer(false)} + * and {@link #setFBO(int) setFBO(false)}
    * Defaults to true. */ @Override public void setOnscreen(boolean onscreen) { if(onscreen) { setPBuffer(false); + setFBO(false); } super.setOnscreen(onscreen); } @@ -413,15 +411,18 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil return sampleBuffers; } - /** If sample buffers are enabled, indicates the number of buffers - to be allocated. Defaults to 2. */ + /** + * If sample buffers are enabled, indicates the number of buffers + * to be allocated. Defaults to 2. + * @see #getNumSamples() + */ public void setNumSamples(int numSamples) { this.numSamples = numSamples; } @Override public final int getNumSamples() { - return numSamples; + return sampleBuffers ? numSamples : 0; } /** For pbuffers only, indicates whether floating-point buffers @@ -492,12 +493,14 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil if(!isOnscreen()) { if(isFBO) { sink.append(", fbo"); - } else if(isPBuffer) { + } + if(isPBuffer) { sink.append(", pbuffer [r2t ").append(pbufferRenderToTexture?1:0) .append(", r2tr ").append(pbufferRenderToTextureRectangle?1:0) .append(", float ").append(pbufferFloatingPointBuffers?1:0) .append("]"); - } else { + } + if(!isFBO && !isPBuffer) { sink.append(", pixmap"); } } diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java index 883f3912e..7e0459b2d 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java @@ -111,7 +111,7 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { /** * Returns the number of sample buffers to be allocated if sample - * buffers are enabled. Defaults to 2. + * buffers are enabled, otherwise returns 0. Defaults to 2. */ int getNumSamples(); @@ -144,12 +144,12 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { boolean getStereo(); /** - * Indicates whether pbuffer is used/requested. + * Indicates whether pbuffer offscreen is used/requested. */ boolean isPBuffer(); /** - * Indicates whether FBO is used/requested. + * Indicates whether FBO offscreen is used/requested. */ boolean isFBO(); diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 351f90027..63a02ad9c 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -55,6 +55,7 @@ import com.jogamp.common.os.Platform; import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.opengl.GLExtensions; /** Abstraction for an OpenGL rendering context. In order to perform OpenGL rendering, a context must be "made current" on the current @@ -69,6 +70,7 @@ import com.jogamp.common.util.locks.RecursiveLock; abstraction provides a stable object which clients can use to refer to a given context. */ public abstract class GLContext { + /** * If true (default), bootstrapping the available GL profiles * will use the highest compatible GL context for each profile, @@ -120,13 +122,13 @@ public abstract class GLContext { protected static final int CTX_PROFILE_ES = 1 << 3; /** ARB_create_context related: flag forward compatible. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_OPTION_FORWARD = 1 << 4; - /** ARB_create_context related: flag debug. Not a cache key. See {@link #setContextCreationFlags(int)}, {@link GLAutoDrawable#setContextCreationFlags(int)}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ + /** ARB_create_context related: flag debug. Cache key value. See {@link #setContextCreationFlags(int)}, {@link GLAutoDrawable#setContextCreationFlags(int)}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ public static final int CTX_OPTION_DEBUG = 1 << 5; /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IMPL_ES2_COMPAT = 1 << 8; - /** Context supports FBO, details see {@link #hasFBO()}. + /** Context supports basic FBO, details see {@link #hasFBO()}. * Not a cache key. * @see #hasFBO() * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) @@ -136,16 +138,6 @@ public abstract class GLContext { /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. See {@link #isHardwareRasterizer()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 15; - protected static final String GL_ARB_ES2_compatibility = "GL_ARB_ES2_compatibility"; - protected static final String GL_ARB_framebuffer_object = "GL_ARB_framebuffer_object"; - protected static final String GL_EXT_framebuffer_object = "GL_EXT_framebuffer_object"; - protected static final String GL_EXT_framebuffer_blit = "GL_EXT_framebuffer_blit"; - protected static final String GL_EXT_framebuffer_multisample = "GL_EXT_framebuffer_multisample"; - protected static final String GL_EXT_packed_depth_stencil = "GL_EXT_packed_depth_stencil"; - protected static final String GL_ARB_texture_non_power_of_two = "GL_ARB_texture_non_power_of_two"; - protected static final String GL_EXT_texture_format_BGRA8888 = "GL_EXT_texture_format_BGRA8888"; - protected static final String GL_IMG_texture_format_BGRA8888 = "GL_IMG_texture_format_BGRA8888"; - private static final ThreadLocal currentContext = new ThreadLocal(); private final HashMap attachedObjectsByString = new HashMap(); @@ -639,11 +631,19 @@ public abstract class GLContext { return 0 == ( ctxOptions & CTX_IMPL_ACCEL_SOFT ) ; } - /** Returns whether the context supports FBO, hence is either GL-ES >= 2.0, >= core GL 3.0 or implements the extensions - * GL_ARB_ES2_compatibility, ARB_framebuffer_object or all of - * EXT_framebuffer_object, EXT_framebuffer_multisample, - * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil. + /** + * Returns true if basic FBO support is available, otherwise false. + *

    + * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= core 3.0 or implements the extensions + * GL_ARB_ES2_compatibility, GL_ARB_framebuffer_object, GL_EXT_framebuffer_object or GL_OES_framebuffer_object. + *

    + *

    + * Basic FBO support may only include one color attachment and no multisampling, + * as well as limited internal formats for renderbuffer. + *

    * @see #CTX_IMPL_FBO + * @see com.jogamp.opengl.FBObject#supportsBasicFBO(GL) + * @see com.jogamp.opengl.FBObject#supportsFullFBO(GL) */ public final boolean hasFBO() { return 0 != ( ctxOptions & CTX_IMPL_FBO ) ; @@ -659,13 +659,13 @@ public abstract class GLContext { /** Note: The GL impl. may return a const value, ie {@link GLES2#isNPOTTextureAvailable()} always returns true. */ public boolean isNPOTTextureAvailable() { - return isGL3() || isGLES2Compatible() || isExtensionAvailable(GL_ARB_texture_non_power_of_two); + return isGL3() || isGLES2Compatible() || isExtensionAvailable(GLExtensions.ARB_texture_non_power_of_two); } public boolean isTextureFormatBGRA8888Available() { return isGL2GL3() || - isExtensionAvailable(GL_EXT_texture_format_BGRA8888) || - isExtensionAvailable(GL_IMG_texture_format_BGRA8888) ; + isExtensionAvailable(GLExtensions.EXT_texture_format_BGRA8888) || + isExtensionAvailable(GLExtensions.IMG_texture_format_BGRA8888) ; } /** @see GLProfile#isGL4bc() */ @@ -798,7 +798,32 @@ public abstract class GLContext { } protected boolean bindSwapBarrierImpl(int group, int barrier) { /** nop per default .. **/ return false; } - + /** + * Return the framebuffer name bound to this context, + * see {@link GL#glBindFramebuffer(int, int)}. + */ + public abstract int getBoundFramebuffer(int target); + + /** + * Return the default draw framebuffer name. + *

    + * May differ from it's default zero + * in case an framebuffer object ({@link FBObject}) based drawable + * is being used. + *

    + */ + public abstract int getDefaultDrawFramebuffer(); + + /** + * Return the default read framebuffer name. + *

    + * May differ from it's default zero + * in case an framebuffer object ({@link FBObject}) based drawable + * is being used. + *

    + */ + public abstract int getDefaultReadFramebuffer(); + /** * @return The extension implementing the GLDebugOutput feature, * either GL_ARB_debug_output or GL_AMD_debug_output. @@ -984,6 +1009,7 @@ public abstract class GLContext { deviceVersionsAvailableSet.add(devKey); if (DEBUG) { System.err.println(getThreadName() + ": createContextARB: SET mappedVersionsAvailableSet "+devKey); + System.err.println(GLContext.dumpAvailableGLVersions(null).toString()); } } } @@ -1010,6 +1036,10 @@ public abstract class GLContext { validateProfileBits(profile, "profile"); validateProfileBits(resCtp, "resCtp"); + if(DEBUG) { + System.err.println("GLContext.mapAvailableGLVersion: "+device+": "+getGLVersion(reqMajor, 0, profile, null)+" -> "+getGLVersion(resMajor, resMinor, resCtp, null)); + // Thread.dumpStack(); + } final String key = getDeviceVersionAvailableKey(device, reqMajor, profile); final Integer val = new Integer(composeBits(resMajor, resMinor, resCtp)); synchronized(deviceVersionAvailable) { @@ -1122,7 +1152,9 @@ public abstract class GLContext { } else /* if (glpImpl.isGL2()) */ { reqMajorCTP[0]=2; } - if( glpImpl.isGL2() ) { // incl GL3bc and GL4bc + if( glpImpl.isGLES() ) { + reqMajorCTP[1]=CTX_PROFILE_ES; + } else if( glpImpl.isGL2() ) { // incl GL3bc and GL4bc reqMajorCTP[1]=CTX_PROFILE_COMPAT; } else { reqMajorCTP[1]=CTX_PROFILE_CORE; @@ -1141,8 +1173,7 @@ public abstract class GLContext { int _major[] = { 0 }; int _minor[] = { 0 }; int _ctp[] = { 0 }; - if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], - _major, _minor, _ctp)) { + if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], _major, _minor, _ctp)) { return _ctp[0]; } return 0; // n/a @@ -1180,6 +1211,23 @@ public abstract class GLContext { return null; } + /** + * Returns true if it is possible to create an framebuffer object (FBO). + *

    + * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. + *

    + *

    + * FBO support is queried as described in {@link #hasFBO()}. + *

    + * + * @param device the device to request whether FBO is available for + * @param glp {@link GLProfile} to check for FBO capabilities + * @see GLContext#hasFBO() + */ + public static final boolean isFBOAvailable(AbstractGraphicsDevice device, GLProfile glp) { + return 0 != ( CTX_IMPL_FBO & getAvailableContextProperties(device, glp) ); + } + /** * @param device the device to request whether the profile is available for * @param reqMajor Key Value either 1, 2, 3 or 4 diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index d6480e7aa..612a02f14 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -50,9 +50,11 @@ import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.ReflectionUtil; import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; import javax.media.opengl.GLProfile.ShutdownType; import jogamp.opengl.Debug; @@ -398,9 +400,18 @@ public abstract class GLDrawableFactory { /** * Creates a Offscreen GLDrawable incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. *

    - * A Pbuffer drawable/surface is created if both {@link javax.media.opengl.GLCapabilities#isPBuffer() caps.isPBuffer()} - * and {@link #canCreateGLPbuffer(javax.media.nativewindow.AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true.
    - * Otherwise a simple pixmap/bitmap drawable/surface is created, which is unlikely to be hardware accelerated.
    + * It's {@link AbstractGraphicsConfiguration} is properly set according to the given {@link GLCapabilitiesImmutable}, see below. + *

    + *

    + * A FBO drawable is created if both {@link javax.media.opengl.GLCapabilities#isFBO() caps.isFBO()} + * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true. + *

    + *

    + * A Pbuffer drawable is created if both {@link javax.media.opengl.GLCapabilities#isPBuffer() caps.isPBuffer()} + * and {@link #canCreateGLPbuffer(javax.media.nativewindow.AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. + *

    + *

    + * If neither FBO nor Pbuffer is available, a simple pixmap/bitmap drawable/surface is created, which is unlikely to be hardware accelerated. *

    * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. @@ -421,42 +432,31 @@ public abstract class GLDrawableFactory { throws GLException; /** - * Creates an offscreen NativeSurface.
    - * A Pbuffer surface is created if both {@link javax.media.opengl.GLCapabilities#isPBuffer() caps.isPBuffer()} - * and {@link #canCreateGLPbuffer(javax.media.nativewindow.AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true.
    - * Otherwise a simple pixmap/bitmap surface is created. The latter is unlikely to be hardware accelerated.
    - * - * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. - * @param caps the requested GLCapabilties - * @param chooser the custom chooser, may be null for default - * @param width the requested offscreen width - * @param height the requested offscreen height - * @return the created offscreen native surface - * - * @throws GLException if any window system-specific errors caused - * the creation of the GLDrawable to fail. - */ - public abstract NativeSurface createOffscreenSurface(AbstractGraphicsDevice device, - GLCapabilitiesImmutable caps, - GLCapabilitiesChooser chooser, - int width, int height); - - /** - * Highly experimental API entry, allowing developer of new windowing system bindings - * to leverage the native window handle to produce a NativeSurface implementation (ProxySurface), having the required GLCapabilities.
    - * Such surface can be used to instantiate a GLDrawable and hence test your new binding w/o the - * costs of providing a full set of abstraction like the AWT GLCanvas or even the native NEWT bindings. + * Creates a proxy {@link NativeSurface} w/ defined surface handle, i.e. a {@link WrappedSurface} or {@link GDISurface} instance. + *

    + * It's {@link AbstractGraphicsConfiguration} is properly set according to the given {@link GLCapabilitiesImmutable}. + *

    + *

    + * Lifecycle (destruction) of the given surface handle shall be handled by the caller. + *

    + *

    + * Such surface can be used to instantiate a GLDrawable. With the help of {@link GLAutoDrawableDelegate} + * you will be able to implement a new native windowing system binding almost on-the-fly, see {@link com.jogamp.opengl.swt.GLCanvas}. + *

    * - * @param device the platform's target device, shall not be null + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. + * Caller has to ensure it is compatible w/ the given windowHandle + * @param screenIdx matching screen index of given windowHandle * @param windowHandle the native window handle * @param caps the requested GLCapabilties * @param chooser the custom chooser, may be null for default - * @return The proxy surface wrapping the windowHandle on the device + * @param upstream optional {@link ProxySurface.UpstreamSurfaceHook} allowing control of the {@link ProxySurface}'s lifecycle and data it presents. + * @return the created {@link ProxySurface} instance w/ defined surface handle. */ - public abstract ProxySurface createProxySurface(AbstractGraphicsDevice device, + public abstract ProxySurface createProxySurface(AbstractGraphicsDevice device, + int screenIdx, long windowHandle, - GLCapabilitiesImmutable caps, - GLCapabilitiesChooser chooser); + GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream); /** * Returns true if it is possible to create a GLPbuffer. Some older @@ -492,23 +492,7 @@ public abstract class GLDrawableFactory { GLContext shareWith) throws GLException; - /** - * Returns true if it is possible to create an framebuffer object (FBO). - *

    - * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. - *

    - *

    - * FBO support is queried as described in {@link GLContext#hasFBO()}. - *

    - * - * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. - * @param glp {@link GLProfile} to check for FBO capabilities - * @see GLContext#hasFBO() - */ - public final boolean canCreateFBO(AbstractGraphicsDevice device, GLProfile glp) { - return 0 != ( GLContext.CTX_IMPL_FBO & GLContext.getAvailableContextProperties(device, glp) ); - } - + //---------------------------------------------------------------------- // Methods for interacting with third-party OpenGL libraries diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index a7200b560..73d13a387 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -117,10 +117,12 @@ public class GLProfile { * @deprecated Use {@link #initSingleton()}. This method is subject to be removed in future versions of JOGL. */ public static void initSingleton(final boolean firstUIActionOnProcess) { + final boolean justInitialized; initLock.lock(); try { if(!initialized) { // volatile: ok initialized = true; + justInitialized = true; if(DEBUG) { System.err.println("GLProfile.initSingleton(firstUIActionOnProcess: "+firstUIActionOnProcess+") - thread "+Thread.currentThread().getName()); Thread.dumpStack(); @@ -166,10 +168,17 @@ public class GLProfile { return null; } }); + } else { + justInitialized = false; } } finally { initLock.unlock(); } + if(DEBUG) { + if( justInitialized && ( hasGL234Impl || hasGLES1Impl || hasGLES2Impl ) ) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(defaultDevice, null, true)); + } + } } /** @@ -1532,18 +1541,17 @@ public class GLProfile { if(DEBUG) { // System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile+" (desktop: "+addedDesktopProfile+", egl "+addedEGLProfile+")"); - System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile); - System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable); - System.err.println("GLProfile.init hasDesktopGLFactory "+hasDesktopGLFactory); - System.err.println("GLProfile.init hasGL234Impl "+hasGL234Impl); - System.err.println("GLProfile.init hasEGLFactory "+hasEGLFactory); - System.err.println("GLProfile.init hasGLES1Impl "+hasGLES1Impl); - System.err.println("GLProfile.init hasGLES2Impl "+hasGLES2Impl); - System.err.println("GLProfile.init defaultDevice "+defaultDevice); - System.err.println("GLProfile.init profile order "+array2String(GL_PROFILE_LIST_ALL)); - if(hasGL234Impl || hasGLES1Impl || hasGLES2Impl) { // avoid deadlock - System.err.println(JoglVersion.getDefaultOpenGLInfo(null, true)); - } + System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile); + System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable); + System.err.println("GLProfile.init hasDesktopGLFactory "+hasDesktopGLFactory); + System.err.println("GLProfile.init hasGL234Impl "+hasGL234Impl); + System.err.println("GLProfile.init hasEGLFactory "+hasEGLFactory); + System.err.println("GLProfile.init hasGLES1Impl "+hasGLES1Impl); + System.err.println("GLProfile.init hasGLES2Impl "+hasGLES2Impl); + System.err.println("GLProfile.init defaultDevice "+defaultDevice); + System.err.println("GLProfile.init defaultDevice Desktop "+defaultDesktopDevice); + System.err.println("GLProfile.init defaultDevice EGL "+defaultEGLDevice); + System.err.println("GLProfile.init profile order "+array2String(GL_PROFILE_LIST_ALL)); } } @@ -1642,24 +1650,6 @@ public class GLProfile { if (DEBUG) { System.err.println("GLProfile.initProfilesForDevice: "+device+": egl Shared Ctx "+eglSharedCtxAvail); } - if( hasGLES2Impl ) { - // The native ES2 impl. overwrites a previous mapping using 'ES2 compatibility' by a desktop profile - GLContext.mapAvailableGLVersion(device, - 2, GLContext.CTX_PROFILE_ES, - 2, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_IMPL_ES2_COMPAT); - if (DEBUG) { - System.err.println(GLContext.getThreadName() + ": initProfilesForDeviceCritical-MapVersionsAvailable HAVE: ES2 -> ES 2.0"); - } - } - if( hasGLES1Impl ) { - // Always favor the native ES1 impl. - GLContext.mapAvailableGLVersion(device, - 1, GLContext.CTX_PROFILE_ES, - 1, 0, GLContext.CTX_PROFILE_ES); - if (DEBUG) { - System.err.println(GLContext.getThreadName() + ": initProfilesForDeviceCritical-MapVersionsAvailable HAVE: ES1 -> ES 1.0"); - } - } addedEGLProfile = computeProfileMap(device, false /* desktopCtxUndef*/, false /* esCtxUndef */); } @@ -1767,7 +1757,7 @@ public class GLProfile { } _mappedProfiles.put(profile, glProfile); if (DEBUG) { - System.err.println("GLProfile.init map "+glProfile+" on devide "+device.getConnection()); + System.err.println("GLProfile.init map "+glProfile+" on device "+device.getConnection()); } if(null==defaultGLProfileHW && isHardwareRasterizer[0]) { defaultGLProfileHW=glProfile; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 48f7ea24a..c2e36ef9b 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -261,6 +261,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing this.device = device; } + @Override + public final Object getUpstreamWidget() { + return this; + } + @Override public void setShallUseOffscreenLayer(boolean v) { shallUseOffscreenLayer = v; @@ -1070,7 +1075,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // System.err.println(NativeWindowVersion.getInstance()); System.err.println(JoglVersion.getInstance()); - System.err.println(JoglVersion.getDefaultOpenGLInfo(null, true).toString()); + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, true).toString()); final GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault(GLProfile.getDefaultDevice()) ); final Frame frame = new Frame("JOGL AWT Test"); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index cd18c5098..acb8f2183 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -87,7 +87,7 @@ import jogamp.opengl.awt.Java2D; import jogamp.opengl.awt.Java2DGLContext; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; -import com.jogamp.opengl.util.FBObject; +import com.jogamp.opengl.FBObject; import com.jogamp.opengl.util.GLBuffers; // FIXME: Subclasses need to call resetGLFunctionAvailability() on their @@ -250,6 +250,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing this.shareWith = shareWith; } + @Override + public final Object getUpstreamWidget() { + return this; + } + @Override public void display() { if (EventQueue.isDispatchThread()) { diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java index 804e9ee14..aabef29b0 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java @@ -32,7 +32,6 @@ import java.nio.FloatBuffer; import javax.media.opengl.GL2ES2; // FIXME: Subsume GL2GL3.GL_DRAW_FRAMEBUFFER -> GL2ES2.GL_DRAW_FRAMEBUFFER ! import javax.media.opengl.GL; -import javax.media.opengl.GLException; import javax.media.opengl.GLUniformData; import javax.media.opengl.fixedfunc.GLMatrixFunc; @@ -45,7 +44,9 @@ import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; -import com.jogamp.opengl.util.FBObject; +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.Attachment; +import com.jogamp.opengl.FBObject.TextureAttachment; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderState; @@ -60,6 +61,7 @@ public class VBORegion2PES2 extends GLRegion { private FBObject fbo; + private TextureAttachment texA; private PMVMatrix fboPMVMatrix; GLUniformData mgl_fboPMVMatrix; @@ -72,7 +74,7 @@ public class VBORegion2PES2 extends GLRegion { super(renderModes); fboPMVMatrix = new PMVMatrix(); mgl_fboPMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, fboPMVMatrix.glGetPMvMatrixf()); - mgl_ActiveTexture = new GLUniformData(UniformNames.gcu_TextureUnit, textureEngine); + mgl_ActiveTexture = new GLUniformData(UniformNames.gcu_TextureUnit, textureEngine); } public void update(GL2ES2 gl, RenderState rs) { @@ -214,8 +216,9 @@ public class VBORegion2PES2 extends GLRegion { final ShaderState st = rs.getShaderState(); gl.glViewport(0, 0, width, hight); - st.uniform(gl, mgl_ActiveTexture); - fbo.use(gl, 0); + st.uniform(gl, mgl_ActiveTexture); + gl.glActiveTexture(GL.GL_TEXTURE0 + mgl_ActiveTexture.intValue()); + fbo.use(gl, texA); verticeFboAttr.enableBuffer(gl, true); texCoordFboAttr.enableBuffer(gl, true); indicesFbo.enableBuffer(gl, true); @@ -244,20 +247,16 @@ public class VBORegion2PES2 extends GLRegion { // System.out.println("FBO Scale: " + m.glGetMatrixf().get(0) +" " + m.glGetMatrixf().get(5)); if(null != fbo && fbo.getWidth() != tex_width_c && fbo.getHeight() != tex_height_c ) { - fbo.destroy(gl); - fbo = null; + fbo.reset(gl, tex_width_c, tex_height_c); } - if(null == fbo) { - fbo = new FBObject(tex_width_c, tex_height_c); - fbo.init(gl); + if(null == fbo) { + fbo = new FBObject(); + fbo.reset(gl, tex_width_c, tex_height_c); // FIXME: shall not use bilinear, due to own AA ? However, w/o bilinear result is not smooth - fbo.attachTexture2D(gl, mgl_ActiveTexture.intValue(), GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE); - // fbo.attachTexture2D(gl, mgl_ActiveTexture.intValue(), GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE); - fbo.attachDepthBuffer(gl, GL.GL_DEPTH_COMPONENT16); // FIXME: or shall we use 24 or 32 bit depth ? - if(!fbo.isStatusValid()) { - throw new GLException("FBO invalid: "+fbo); - } + texA = fbo.attachTexture2D(gl, 0, true, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE); + // texA = fbo.attachTexture2D(gl, 0, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE); + fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); } else { fbo.bind(gl); } @@ -305,6 +304,7 @@ public class VBORegion2PES2 extends GLRegion { if(null != fbo) { fbo.destroy(gl); fbo = null; + texA = null; } if(null != verticeTxtAttr) { st.ownAttribute(verticeTxtAttr, false); diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 4dd8806fa..e730bc62e 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -49,8 +49,9 @@ import com.jogamp.common.os.DynamicLookupHelper; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.gluegen.runtime.FunctionAddressResolver; import com.jogamp.gluegen.runtime.ProcAddressTable; -import com.jogamp.gluegen.runtime.opengl.GLExtensionNames; +import com.jogamp.gluegen.runtime.opengl.GLNameResolver; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; +import com.jogamp.opengl.GLExtensions; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -88,13 +89,14 @@ public abstract class GLContextImpl extends GLContext { // Tracks creation and initialization of buffer objects to avoid // repeated glGet calls upon glMapBuffer operations private GLBufferSizeTracker bufferSizeTracker; // Singleton - Set by GLContextShareSet - private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); - private GLStateTracker glStateTracker = new GLStateTracker(); + private final GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); + private final GLStateTracker glStateTracker = new GLStateTracker(); private GLDebugMessageHandler glDebugHandler = null; + private final int[] boundFBOTarget = new int[] { 0, 0 }; // { draw, read } protected GLDrawableImpl drawable; protected GLDrawableImpl drawableRead; - + protected GL gl; protected static final Object mappedContextTypeObjectLock; @@ -140,11 +142,11 @@ public abstract class GLContextImpl extends GLContext { bufferSizeTracker.clearCachedBufferSizes(); } - if (bufferStateTracker != null) { + if (bufferStateTracker != null) { // bufferStateTracker.clearBufferObjectState(); } - if (glStateTracker != null) { + if (glStateTracker != null) { // glStateTracker.clearStates(false); } @@ -156,6 +158,11 @@ public abstract class GLContextImpl extends GLContext { glRenderer = ""; glRendererLowerCase = glRenderer; + + if (boundFBOTarget != null) { // + boundFBOTarget[0] = 0; // draw + boundFBOTarget[1] = 0; // read + } super.resetStates(); } @@ -199,7 +206,7 @@ public abstract class GLContextImpl extends GLContext { drawableRead = (GLDrawableImpl) readWrite; } final GLDrawable old = drawable; - drawable = ( null != readWrite ) ? (GLDrawableImpl) readWrite : null; + drawable = (GLDrawableImpl) readWrite ; if(lockHeld) { makeCurrent(); } @@ -252,16 +259,19 @@ public abstract class GLContextImpl extends GLContext { public void release() throws GLException { release(false); } - private void release(boolean force) throws GLException { + private void release(boolean inDestruction) throws GLException { if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - release() - force: "+force+", "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - release() - force: "+inDestruction+", "+lock); } if ( !lock.isOwner(Thread.currentThread()) ) { throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this); } - final boolean actualRelease = ( force || lock.getHoldCount() == 1 ) && 0 != contextHandle; + final boolean actualRelease = ( inDestruction || lock.getHoldCount() == 1 ) && 0 != contextHandle; try { if( actualRelease ) { + if( !inDestruction ) { + drawable.contextMadeCurrent(this, false); + } releaseImpl(); } } finally { @@ -306,13 +316,12 @@ public abstract class GLContextImpl extends GLContext { } try { // release current context - if(null != glDebugHandler) { - if(lock.getHoldCount() == 1) { - // needs current context to disable debug handler - makeCurrent(); - } - glDebugHandler.enable(false); + if(lock.getHoldCount() == 1) { + // needs current context to disable debug handler + makeCurrent(); } + drawable.contextRealized(this, false); + glDebugHandler.enable(false); if(lock.getHoldCount() > 1) { // pending release() after makeCurrent() release(true); @@ -488,11 +497,18 @@ public abstract class GLContextImpl extends GLContext { if(TRACE_GL) { gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ); } + + drawable.contextRealized(this, true); + if(DEBUG || TRACE_SWITCH) { System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT_NEW - "+lock); } - } else if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT - "+lock); + } else { + drawable.contextMadeCurrent(this, true); + + if(TRACE_SWITCH) { + System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT - "+lock); + } } /* FIXME: refactor dependence on Java 2D / JOGL bridge @@ -543,14 +559,11 @@ public abstract class GLContextImpl extends GLContext { final AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice device = config.getScreen().getDevice(); - if( !GLContext.getAvailableGLVersionsSet(device) ) { - final int reqMajor; - final int reqProfile; - if( 0 != ( ctxOptions & GLContext.CTX_PROFILE_ES) ) { - // ES1 or ES2 - reqMajor = ctxMajorVersion; - reqProfile = GLContext.CTX_PROFILE_ES; - } else { + // Non ARB desktop profiles may not have been registered + if( !GLContext.getAvailableGLVersionsSet(device) ) { // not yet set + if( 0 == ( ctxOptions & GLContext.CTX_PROFILE_ES) ) { // not ES profile + final int reqMajor; + final int reqProfile; if(ctxMajorVersion<3 || ctxMajorVersion==3 && ctxMinorVersion==0) { reqMajor = 2; } else { @@ -561,12 +574,13 @@ public abstract class GLContextImpl extends GLContext { } else { reqProfile = GLContext.CTX_PROFILE_COMPAT; } - } - GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, - ctxMajorVersion, ctxMinorVersion, ctxOptions); - GLContext.setAvailableGLVersionsSet(device); - if (DEBUG) { - System.err.println(getThreadName() + ": createContextOLD-MapVersionsAvailable HAVE: " + device+" -> "+reqMajor+"."+reqProfile+ " -> "+getGLVersion()); + GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, + ctxMajorVersion, ctxMinorVersion, ctxOptions); + GLContext.setAvailableGLVersionsSet(device); + + if (DEBUG) { + System.err.println(getThreadName() + ": createContextOLD-MapVersionsAvailable HAVE: " + device+" -> "+reqMajor+"."+reqProfile+ " -> "+getGLVersion()); + } } } } @@ -776,7 +790,7 @@ public abstract class GLContextImpl extends GLContext { } /** - * Note: Since context creation is temproary, caller need to issue {@link #resetStates()}, if creation was successful, i.e. returns true. + * Note: Since context creation is temporary, caller need to issue {@link #resetStates()}, if creation was successful, i.e. returns true. * This method does not reset the states, allowing the caller to utilize the state variables. **/ private final boolean createContextARBMapVersionsAvailable(int reqMajor, int reqProfile) { @@ -1034,22 +1048,29 @@ public abstract class GLContextImpl extends GLContext { table.reset(getDrawableImpl().getGLDynamicLookupHelper() ); } - private final void initGLRendererStrings() { + private final boolean initGLRendererStrings() { final GLDynamicLookupHelper glDynLookupHelper = getDrawableImpl().getGLDynamicLookupHelper(); final long _glGetString = glDynLookupHelper.dynamicLookupFunction("glGetString"); if(0 == _glGetString) { // FIXME System.err.println("Warning: Entry point to 'glGetString' is NULL."); - Thread.dumpStack(); + if(DEBUG) { + Thread.dumpStack(); + } + return false; } else { final String _glRenderer = glGetStringInt(GL.GL_RENDERER, _glGetString); if(null == _glRenderer) { // FIXME - System.err.println("Warning: GL_RENDERER is NULL."); - Thread.dumpStack(); + if(DEBUG) { + System.err.println("Warning: GL_RENDERER is NULL."); + Thread.dumpStack(); + } + return false; } else { glRenderer = _glRenderer; glRendererLowerCase = glRenderer.toLowerCase(); + return true; } } } @@ -1088,17 +1109,20 @@ public abstract class GLContextImpl extends GLContext { } updateGLXProcAddressTable(); - initGLRendererStrings(); + final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); + final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); + + if( !initGLRendererStrings() && DEBUG) { + System.err.println("Warning: intialization of GL renderer strings failed. "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); + } if(!isCurrentContextHardwareRasterizer()) { ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; } - final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); - final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits); if (DEBUG) { - System.err.println(getThreadName() + ": Context FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.0 FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); } // @@ -1154,11 +1178,10 @@ public abstract class GLContextImpl extends GLContext { } } - if( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) && ctxMajorVersion >= 2 || - isExtensionAvailable(GL_ARB_ES2_compatibility) ) { + if( ( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) && major >= 2 ) || isExtensionAvailable(GLExtensions.ARB_ES2_compatibility) ) { ctxProfileBits |= CTX_IMPL_ES2_COMPAT; ctxProfileBits |= CTX_IMPL_FBO; - } else if( hasFBOImpl(ctxMajorVersion, ctxProfileBits, extensionAvailability) ) { + } else if( hasFBOImpl(major, ctxProfileBits, extensionAvailability) ) { ctxProfileBits |= CTX_IMPL_FBO; } @@ -1168,23 +1191,26 @@ public abstract class GLContextImpl extends GLContext { setContextVersion(major, minor, ctxProfileBits, true); setDefaultSwapInterval(); + + if(DEBUG) { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: "+contextFQN+" - "+GLContext.getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, null)); + } } - protected static final boolean hasFBOImpl(int ctxMajorVersion, int ctxProfileBits, ExtensionAvailabilityCache extCache) { - return ( ctxMajorVersion >= 3 ) || // any >= 3.0 GL ctx + protected static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) { + return ( 0 != (ctp & CTX_PROFILE_ES) && major >= 2 ) || // ES >= 2.0 - ( 0 != (ctxProfileBits & CTX_PROFILE_ES) && ctxMajorVersion >= 2 ) || // ES >= 2.0 + major >= 3 || // any >= 3.0 GL ctx ( null != extCache && - ( extCache.isExtensionAvailable(GL_ARB_ES2_compatibility) ) || // ES 2.0 compatible + extCache.isExtensionAvailable(GLExtensions.ARB_ES2_compatibility) || // ES 2.0 compatible - ( extCache.isExtensionAvailable(GL_ARB_framebuffer_object) ) || // ARB_framebuffer_object + extCache.isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object - ( extCache.isExtensionAvailable(GL_EXT_framebuffer_object) && // EXT_framebuffer_object* - extCache.isExtensionAvailable(GL_EXT_framebuffer_multisample) && - extCache.isExtensionAvailable(GL_EXT_framebuffer_blit) && - extCache.isExtensionAvailable(GL_EXT_packed_depth_stencil) ) ); + extCache.isExtensionAvailable(GLExtensions.EXT_framebuffer_object) || // EXT_framebuffer_object + + extCache.isExtensionAvailable(GLExtensions.OES_framebuffer_object) ) ; // OES_framebuffer_object excluded } protected final void removeCachedVersion(int major, int minor, int ctxProfileBits) { @@ -1259,11 +1285,11 @@ public abstract class GLContextImpl extends GLContext { // dynamic function lookup at last incl name aliasing (not cached) DynamicLookupHelper dynLookup = getDrawableImpl().getGLDynamicLookupHelper(); - String tmpBase = GLExtensionNames.normalizeVEN(GLExtensionNames.normalizeARB(glFunctionName, true), true); + String tmpBase = GLNameResolver.normalizeVEN(GLNameResolver.normalizeARB(glFunctionName, true), true); long addr = 0; - int variants = GLExtensionNames.getFuncNamePermutationNumber(tmpBase); + int variants = GLNameResolver.getFuncNamePermutationNumber(tmpBase); for(int i = 0; 0==addr && i < variants; i++) { - String tmp = GLExtensionNames.getFuncNamePermutation(tmpBase, i); + String tmp = GLNameResolver.getFuncNamePermutation(tmpBase, i); try { addr = dynLookup.dynamicLookupFunction(tmp); } catch (Exception e) { } @@ -1317,7 +1343,7 @@ public abstract class GLContextImpl extends GLContext { protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits) { // remove non-key values - ctxProfileBits &= ~( GLContext.CTX_OPTION_DEBUG | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) ; + ctxProfileBits &= ~( GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) ; return device.getUniqueID() + "-" + toHexString(composeBits(major, minor, ctxProfileBits)); } @@ -1371,6 +1397,56 @@ public abstract class GLContextImpl extends GLContext { return lock.getQueueLength()>0; } + //--------------------------------------------------------------------------- + // Special FBO hook + // + + /** + * Tracks {@link GL#GL_FRAMEBUFFER}, {@link GL2GL3#GL_DRAW_FRAMEBUFFER} and {@link GL2GL3#GL_READ_FRAMEBUFFER} + * to be returned via {@link #getBoundFramebuffer(int)}. + * + *

    Invoked by {@link GL#glBindFramebuffer(int, int)}.

    + * + *

    Assumes valid framebufferName range of [0..{@link Integer#MAX_VALUE}]

    + * + *

    Does not throw an exception if target is unknown or framebufferName invalid.

    + */ + public final void setBoundFramebuffer(int target, int framebufferName) { + if(0 > framebufferName) { + return; // ignore invalid name + } + switch(target) { + case GL.GL_FRAMEBUFFER: + boundFBOTarget[0] = framebufferName; // draw + boundFBOTarget[1] = framebufferName; // read + break; + case GL2GL3.GL_DRAW_FRAMEBUFFER: + boundFBOTarget[0] = framebufferName; // draw + break; + case GL2GL3.GL_READ_FRAMEBUFFER: + boundFBOTarget[1] = framebufferName; // read + break; + default: // ignore untracked target + } + } + @Override + public final int getBoundFramebuffer(int target) { + switch(target) { + case GL.GL_FRAMEBUFFER: + case GL2GL3.GL_DRAW_FRAMEBUFFER: + return boundFBOTarget[0]; // draw + case GL2GL3.GL_READ_FRAMEBUFFER: + return boundFBOTarget[1]; // read + default: + throw new InternalError("Invalid FBO target name: "+toHexString(target)); + } + } + + @Override + public final int getDefaultDrawFramebuffer() { return drawable.getDefaultDrawFramebuffer(); } + @Override + public final int getDefaultReadFramebuffer() { return drawable.getDefaultReadFramebuffer(); } + //--------------------------------------------------------------------------- // GL_ARB_debug_output, GL_AMD_debug_output helpers // diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java index b950c2fdf..0000e6199 100644 --- a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java +++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java @@ -37,6 +37,8 @@ import javax.media.opengl.GLException; import com.jogamp.common.os.Platform; import com.jogamp.gluegen.runtime.ProcAddressTable; +import com.jogamp.opengl.GLExtensions; + import jogamp.opengl.gl4.GL4bcProcAddressTable; /** @@ -54,12 +56,6 @@ import jogamp.opengl.gl4.GL4bcProcAddressTable; * the messages are translated to ARB {@link GLDebugMessage}, using {@link GLDebugMessage#translateAMDEvent(javax.media.opengl.GLContext, long, int, int, int, String)}.

    */ public class GLDebugMessageHandler { - /** Extension GL_ARB_debug_output implementing GLDebugMessage */ - public static final String GL_ARB_debug_output = "GL_ARB_debug_output".intern(); - - /** Extension GL_AMD_debug_output implementing GLDebugMessage */ - public static final String GL_AMD_debug_output = "GL_AMD_debug_output".intern(); - private static final boolean DEBUG = Debug.debug("GLDebugMessageHandler"); private static final int EXT_ARB = 1; @@ -131,11 +127,11 @@ public class GLDebugMessageHandler { } return; } - if( ctx.isExtensionAvailable(GL_ARB_debug_output) ) { - extName = GL_ARB_debug_output; + if( ctx.isExtensionAvailable(GLExtensions.ARB_debug_output) ) { + extName = GLExtensions.ARB_debug_output; extType = EXT_ARB; - } else if( ctx.isExtensionAvailable(GL_AMD_debug_output) ) { - extName = GL_AMD_debug_output; + } else if( ctx.isExtensionAvailable(GLExtensions.AMD_debug_output) ) { + extName = GLExtensions.AMD_debug_output; extType = EXT_AMD; } if(DEBUG) { @@ -145,6 +141,8 @@ public class GLDebugMessageHandler { if(0 == extType) { if(DEBUG) { System.err.println("GLDebugMessageHandler: No extension available! "+ctx.getGLVersion()); + System.err.println("GL_EXTENSIONS "+ctx.getGLExtensionCount()); + System.err.println(ctx.getGLExtensionsString()); } return; } @@ -190,11 +188,11 @@ public class GLDebugMessageHandler { } public final boolean isExtensionARB() { - return extName == GL_ARB_debug_output; + return extName == GLExtensions.ARB_debug_output; } public final boolean isExtensionAMD() { - return extName == GL_AMD_debug_output; + return extName == GLExtensions.AMD_debug_output; } /** diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index e5c44a8d4..897d3fcaf 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -47,7 +47,8 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; @@ -88,7 +89,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { return null; } protected abstract GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device); - + /** * Returns the shared device mapped to the device {@link AbstractGraphicsDevice#getConnection()}, * either a preexisting or newly created, or null if creation failed or not supported.
    @@ -115,7 +116,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } protected abstract AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device); - /** + /** * Returns the GLDynamicLookupHelper * @param profile if EGL/ES, profile 1 refers to ES1 and 2 to ES2, * otherwise the profile is ignored. @@ -125,6 +126,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { //--------------------------------------------------------------------------- // Dispatching GLDrawable construction in respect to the NativeSurface Capabilities // + @Override public GLDrawable createGLDrawable(NativeSurface target) { if (target == null) { throw new IllegalArgumentException("Null target"); @@ -132,23 +134,37 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final MutableGraphicsConfiguration config = (MutableGraphicsConfiguration) target.getGraphicsConfiguration(); final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); final AbstractGraphicsDevice adevice = config.getScreen().getDevice(); + final boolean isFBOAvailable = GLContext.isFBOAvailable(adevice, chosenCaps.getGLProfile()); GLDrawable result = null; adevice.lock(); try { final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(target, true); if(null != ols) { - // layered surface -> Offscreen/PBuffer + // layered surface -> Offscreen/[FBO|PBuffer] final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable(); chosenCapsMod.setOnscreen(false); - chosenCapsMod.setPBuffer(canCreateGLPbuffer(adevice)); + if( isFBOAvailable ) { + chosenCapsMod.setFBO(true); + } else if(canCreateGLPbuffer(adevice)) { + chosenCapsMod.setPBuffer(true); + } else { + chosenCapsMod.setFBO(false); + chosenCapsMod.setPBuffer(false); + } config.setChosenCapabilities(chosenCapsMod); if(DEBUG) { System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable -> Offscreen-Layer: "+target); } - if( ! ( target instanceof SurfaceChangeable ) ) { + if( ! ( target instanceof MutableSurface ) ) { throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen layered surface: "+target); + } + if( ((GLCapabilitiesImmutable)config.getRequestedCapabilities()).isFBO() && isFBOAvailable ) { + // FIXME JAU: Need to revise passed MutableSurface to work w/ FBO .. + final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(target); + result = new GLFBODrawableImpl(this, dummyDrawable, target, target.getWidth(), target.getHeight(), 0 /* textureUnit */); + } else { + result = createOffscreenDrawableImpl(target); } - result = createOffscreenDrawableImpl(target); } else if(chosenCaps.isOnscreen()) { // onscreen if(DEBUG) { @@ -158,12 +174,18 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } else { // offscreen if(DEBUG) { - System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable (PBuffer: "+chosenCaps.isPBuffer()+"): "+target); + System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable, FBO-chosen(-avail)/PBuffer: "+chosenCaps.isFBO()+"("+isFBOAvailable+")/"+chosenCaps.isPBuffer()+": "+target); } - if( ! ( target instanceof SurfaceChangeable ) ) { + if( ! ( target instanceof MutableSurface ) ) { throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen: "+target); } - result = createOffscreenDrawableImpl(target); + if( ((GLCapabilitiesImmutable)config.getRequestedCapabilities()).isFBO() && isFBOAvailable ) { + // FIXME JAU: Need to revise passed MutableSurface to work w/ FBO .. + final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(target); + result = new GLFBODrawableImpl(this, dummyDrawable, target, target.getWidth(), target.getHeight(), 0 /* textureUnit */); + } else { + result = createOffscreenDrawableImpl(target); + } } } finally { adevice.unlock(); @@ -176,43 +198,42 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { //--------------------------------------------------------------------------- // - // Onscreen GLDrawable construction + // Onscreen GLDrawable construction // protected abstract GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target); //--------------------------------------------------------------------------- // - // PBuffer Offscreen GLDrawable construction + // PBuffer Offscreen GLDrawable construction // - + + @Override public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device); + @Override public GLPbuffer createGLPbuffer(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height, GLContext shareWith) { - if(height<=0 || height<=0) { - throw new GLException("Width and height of pbuffer must be positive (were (" + - width + ", " + height + "))"); + if(width<=0 || height<=0) { + throw new GLException("initial size must be positive (were (" + width + " x " + height + "))"); } - AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } - - if (!canCreateGLPbuffer(device)) { - throw new GLException("Pbuffer support not available with device: "+device); + if ( !canCreateGLPbuffer(device) ) { + throw new GLException("Pbuffer not available with device: "+device); } - - GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(capsRequested); + + final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(capsRequested); GLDrawableImpl drawable = null; device.lock(); try { - drawable = (GLDrawableImpl) createGLDrawable( createOffscreenSurfaceImpl(device, capsChosen, capsRequested, chooser, width, height) ); + drawable = (GLDrawableImpl) createGLDrawable( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, width, height, null) ); if(null != drawable) { drawable.setRealized(true); } @@ -228,75 +249,155 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { //--------------------------------------------------------------------------- // - // Offscreen GLDrawable construction + // Offscreen GLDrawable construction // - protected abstract GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) ; - + @Override public GLDrawable createOffscreenDrawable(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, - int width, - int height) { + int width, int height) { if(width<=0 || height<=0) { - throw new GLException("Width and height of pbuffer must be positive (were (" + - width + ", " + height + "))"); + throw new GLException("initial size must be positive (were (" + width + " x " + height + "))"); } - AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); + final AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } - GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffScreenGLCapabilities(capsRequested, canCreateGLPbuffer(deviceReq)); - + + if( capsRequested.isFBO() && GLContext.isFBOAvailable(device, capsRequested.getGLProfile()) ) { + device.lock(); + try { + return createFBODrawableImpl(device, capsRequested, chooser, width, height); + } finally { + device.unlock(); + } + } + + final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, false, canCreateGLPbuffer(device)); device.lock(); try { - return createGLDrawable( createOffscreenSurfaceImpl(device, capsChosen, capsRequested, chooser, width, height) ); + return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, width, height, null) ); } finally { device.unlock(); } } - public NativeSurface createOffscreenSurface(AbstractGraphicsDevice deviceReq, - GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, - int width, int height) { - AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); + /** Creates a platform independent offscreen FBO GLDrawable implementation */ + protected GLDrawable createFBODrawableImpl(AbstractGraphicsDevice device, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, + int initialWidth, int initialHeight) { + final GLCapabilitiesImmutable dummyCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); + final NativeSurface dummySurface = createDummySurfaceImpl(device, true, dummyCaps, null, 64, 64); + final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); + + return new GLFBODrawableImpl(this, dummyDrawable, dummySurface, initialWidth, initialHeight, 0 /* textureUnit */); + } + + /** Creates a platform dependent offscreen pbuffer/pixmap GLDrawable implementation */ + protected abstract GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) ; + + /** + * Creates a mutable {@link ProxySurface} w/o defined surface handle. + *

    + * It's {@link AbstractGraphicsConfiguration} is properly set according to the given {@link GLCapabilitiesImmutable}. + *

    + *

    + * Lifecycle (destruction) of the TBD surface handle shall be handled by the caller. + *

    + * @param device a valid platform dependent target device. + * @param createNewDevice if true a new device instance is created using device details, + * otherwise device instance is used as-is. + * @param capsChosen + * @param capsRequested + * @param chooser the custom chooser, may be null for default + * @param width the initial width + * @param height the initial height + * @param lifecycleHook optional control of the surface's lifecycle + * @return the created {@link MutableSurface} instance w/o defined surface handle + */ + protected abstract ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, + GLCapabilitiesImmutable capsChosen, + GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook); + + /** + * A dummy surface is not visible on screen and will not be used to render directly to, + * it maybe on- or offscreen. + *

    + * It is used to allow the creation of a {@link GLDrawable} and {@link GLContext} to query information. + * It also allows creation of framebuffer objects which are used for rendering. + *

    + * @param deviceReq which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. + * @param requestedCaps + * @param chooser the custom chooser, may be null for default + * @param width the initial width + * @param height the initial height + * + * @return the created {@link MutableSurface} instance w/o defined surface handle + */ + public NativeSurface createDummySurface(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, + int width, int height) { + final AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } - GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffScreenGLCapabilities(capsRequested, canCreateGLPbuffer(deviceReq)); - device.lock(); try { - return createOffscreenSurfaceImpl(device, capsChosen, capsRequested, chooser, width, height); + return createDummySurfaceImpl(device, true, requestedCaps, chooser, width, height); } finally { device.unlock(); } } - + /** - * creates an offscreen NativeSurface, which must implement SurfaceChangeable as well, - * so the windowing system related implementation is able to set the surface handle. + * A dummy surface is not visible on screen and will not be used to render directly to, + * it maybe on- or offscreen. + *

    + * It is used to allow the creation of a {@link GLDrawable} and {@link GLContext} to query information. + * It also allows creation of framebuffer objects which are used for rendering. + *

    + * @param device a valid platform dependent target device. + * @param createNewDevice if true a new device instance is created using device details, + * otherwise device instance is used as-is. + * @param requestedCaps + * @param chooser the custom chooser, may be null for default + * @param width the initial width + * @param height the initial height + * @return the created {@link MutableSurface} instance w/o defined surface handle */ - protected abstract NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device, - GLCapabilitiesImmutable capabilities, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, - int width, int height); + public abstract ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, + GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height); - public ProxySurface createProxySurface(AbstractGraphicsDevice device, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { + //--------------------------------------------------------------------------- + // + // ProxySurface (Wrapped pre-existing native surface) construction + // + + @Override + public ProxySurface createProxySurface(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, + GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { + final AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); if(null == device) { - throw new GLException("No shared device for requested: "+device); + throw new GLException("No shared device for requested: "+deviceReq); } device.lock(); try { - return createProxySurfaceImpl(device, windowHandle, capsRequested, chooser); + return createProxySurfaceImpl(device, screenIdx, windowHandle, capsRequested, chooser, upstream); } finally { device.unlock(); } - } - - protected abstract ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice device, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser); + } + + /** + * Creates a {@link ProxySurface} with a set surface handle. + *

    + * Implementation is also required to allocate it's own {@link AbstractGraphicsDevice} instance. + *

    + * @param upstream TODO + */ + protected abstract ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, + GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream); //--------------------------------------------------------------------------- // @@ -304,7 +405,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { // protected abstract GLContext createExternalGLContextImpl(); - + + @Override public GLContext createExternalGLContext() { NativeWindowFactory.getDefaultToolkitLock().lock(); try { @@ -316,6 +418,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { protected abstract GLDrawable createExternalGLDrawableImpl(); + @Override public GLDrawable createExternalGLDrawable() { NativeWindowFactory.getDefaultToolkitLock().lock(); try { @@ -398,7 +501,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * normal ahead of time, use resetDisplayGamma(). Throws * IllegalArgumentException if any of the parameters were * out-of-bounds. - * + * * @param gamma The gamma value, typically > 1.0 (default value is * 1.0) * @param brightness The brightness value between -1.0 and 1.0, @@ -484,7 +587,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { return; if (gammaShutdownHook == null) { gammaShutdownHook = new Thread(new Runnable() { - public void run() { + @Override + public void run() { synchronized (GLDrawableFactoryImpl.this) { resetGammaRamp(originalGammaRamp); } diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index 58a4ac6b4..abf2bf557 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -42,6 +42,7 @@ package jogamp.opengl; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.ProxySurface; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; @@ -75,7 +76,7 @@ public abstract class GLDrawableImpl implements GLDrawable { if( !realized ) { return; // destroyed already } - GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities(); + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities(); if ( caps.getDoubleBuffered() ) { if(!surface.surfaceSwap()) { int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release] @@ -149,6 +150,9 @@ public abstract class GLDrawableImpl implements GLDrawable { realized = realizedArg; AbstractGraphicsDevice aDevice = surface.getGraphicsConfiguration().getScreen().getDevice(); if(realizedArg) { + if(surface instanceof ProxySurface) { + ((ProxySurface)surface).createNotify(); + } if(NativeSurface.LOCK_SURFACE_NOT_READY >= lockSurface()) { throw new GLException("GLDrawableImpl.setRealized(true): Surface not ready (lockSurface)"); } @@ -156,17 +160,21 @@ public abstract class GLDrawableImpl implements GLDrawable { aDevice.lock(); } try { - setRealizedImpl(); if(realizedArg) { + setRealizedImpl(); updateHandle(); } else { destroyHandle(); + setRealizedImpl(); } } finally { if(realizedArg) { unlockSurface(); } else { aDevice.unlock(); + if(surface instanceof ProxySurface) { + ((ProxySurface)surface).destroyNotify(); + } } } } else if(DEBUG) { @@ -175,6 +183,39 @@ public abstract class GLDrawableImpl implements GLDrawable { } protected abstract void setRealizedImpl(); + /** + * Callback for special implementations, allowing GLContext to trigger GL related lifecycle: construct, destroy. + *

    + * If realized is true, the context has just been created and made current. + *

    + *

    + * If realized is false, the context is still current and will be release and destroyed after this method returns. + *

    + *

    + * @see #contextMadeCurrent(GLContext, boolean) + */ + protected void contextRealized(GLContext glc, boolean realized) {} + + /** + * Callback for special implementations, allowing GLContext to trigger GL related lifecycle: makeCurrent, release. + *

    + * Will not be called if {@link #contextRealized(GLContext, boolean)} has been triggered. + *

    + *

    + * If current is true, the context has just been made current. + *

    + *

    + * If current is false, the context is still current and will be release after this method returns. + *

    + * @see #contextRealized(GLContext, boolean) + */ + protected void contextMadeCurrent(GLContext glc, boolean current) { } + + /** Callback for special implementations, allowing GLContext to fetch a custom default render framebuffer. Defaults to zero.*/ + protected int getDefaultDrawFramebuffer() { return 0; } + /** Callback for special implementations, allowing GLContext to fetch a custom default read framebuffer. Defaults to zero. */ + protected int getDefaultReadFramebuffer() { return 0; } + @Override public final synchronized boolean isRealized() { return realized; @@ -190,10 +231,12 @@ public abstract class GLDrawableImpl implements GLDrawable { return surface.getHeight(); } + /** @see NativeSurface#lockSurface() */ public final int lockSurface() throws GLException { return surface.lockSurface(); } + /** @see NativeSurface#unlockSurface() */ public final void unlockSurface() { surface.unlockSurface(); } diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java new file mode 100644 index 000000000..b7ea4f826 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -0,0 +1,138 @@ +package jogamp.opengl; + +import javax.media.nativewindow.NativeSurface; +import javax.media.opengl.GL; +import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLException; + +import com.jogamp.nativewindow.MutableGraphicsConfiguration; +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.Attachment; +import com.jogamp.opengl.FBObject.TextureAttachment; + +/** + * Offscreen GLDrawable implementation using framebuffer object (FBO) + * as it's offscreen rendering mechanism. + * + * @see GLDrawableImpl#contextRealized(GLContext, boolean) + * @see GLDrawableImpl#contextMadeCurrent(GLContext, boolean) + * @see GLDrawableImpl#getDefaultDrawFramebuffer() + * @see GLDrawableImpl#getDefaultReadFramebuffer() + */ +public class GLFBODrawableImpl extends GLDrawableImpl { + final GLDrawableImpl parent; + final FBObject fbo; + int texUnit; + int samplesTexUnit = 0; + int width=0, height=0, samples=0; + + protected GLFBODrawableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, + NativeSurface surface, int initialWidth, int initialHeight, int textureUnit) { + super(factory, surface, false); + this.parent = parent; + this.texUnit = textureUnit; + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); + this.width = initialWidth; + this.height = initialHeight; + this.samples = caps.getNumSamples(); + this.fbo = new FBObject(); + } + + @Override + protected void contextRealized(GLContext glc, boolean realized) { + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); + final GL gl = glc.getGL(); + if(realized) { + fbo.reset(gl, width, height, samples); + samples = fbo.getNumSamples(); // update, maybe capped + if(samples > 0) { + fbo.attachColorbuffer(gl, 0, caps.getAlphaBits()>0); + } else { + fbo.attachTexture2D(gl, 0, caps.getAlphaBits()>0); + } + if( caps.getStencilBits() > 0 ) { + fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, 24); + } else { + fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); + } + } else if(null != fbo) { + fbo.destroy(gl); + } + } + + @Override + protected void contextMadeCurrent(GLContext glc, boolean current) { + final GL gl = glc.getGL(); + if(current) { + fbo.bind(gl); + } else { + fbo.unbind(gl); + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit); + fbo.use(gl, samples > 0 ? fbo.getSamplingSink() : (TextureAttachment) fbo.getColorbuffer(0) ); + if( samples > 0) { + gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, fbo.getReadFramebuffer()); + } + } + } + + @Override + protected int getDefaultDrawFramebuffer() { return fbo.getWriteFramebuffer(); } + + @Override + protected int getDefaultReadFramebuffer() { return fbo.getReadFramebuffer(); } + + public FBObject getFBObject() { return fbo; } + + public void setSize(GL gl, int newWidth, int newHeight) throws GLException { + width = newWidth; + height = newHeight; + fbo.reset(gl, width, height, samples); + samples = fbo.getNumSamples(); // update, maybe capped + } + + public void setSamples(GL gl, int newSamples) throws GLException { + samples = newSamples; + fbo.reset(gl, width, height, samples); + samples = fbo.getNumSamples(); // update, maybe capped + } + + + @Override + public GLContext createContext(GLContext shareWith) { + final GLContext ctx = parent.createContext(shareWith); + ctx.setGLDrawable(this, false); + return ctx; + } + + @Override + public GLDynamicLookupHelper getGLDynamicLookupHelper() { + return parent.getGLDynamicLookupHelper(); + } + + @Override + protected void swapBuffersImpl() { + } + + @Override + protected void setRealizedImpl() { + parent.setRealized(realized); + if(realized) { + final MutableGraphicsConfiguration msConfig = (MutableGraphicsConfiguration) surface.getGraphicsConfiguration(); + final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) msConfig.getChosenCapabilities(); + final GLCapabilitiesImmutable chosenFBOCaps = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(chosenCaps, true /*FBO*/, false /*PBO*/); + msConfig.setChosenCapabilities(chosenFBOCaps); + } + } + + @Override + public int getWidth() { + return width; + } + + @Override + public int getHeight() { + return height; + } +} diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java index b7c15bfda..900d6a2a0 100644 --- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java +++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java @@ -38,7 +38,8 @@ public class GLGraphicsConfigurationUtil { public static final int WINDOW_BIT = 1 << 0; public static final int BITMAP_BIT = 1 << 1; public static final int PBUFFER_BIT = 1 << 2; - public static final int ALL_BITS = WINDOW_BIT | BITMAP_BIT | PBUFFER_BIT ; + public static final int FBO_BIT = 1 << 3; + public static final int ALL_BITS = WINDOW_BIT | BITMAP_BIT | PBUFFER_BIT | FBO_BIT ; public static final StringBuilder winAttributeBits2String(StringBuilder sb, int winattrbits) { if(null==sb) { @@ -61,30 +62,43 @@ public class GLGraphicsConfigurationUtil { sb.append(", "); } sb.append("PBUFFER"); + seperator=true; + } + if( 0 != ( FBO_BIT & winattrbits ) ) { + if(seperator) { + sb.append(", "); + } + sb.append("FBO"); } return sb; } /** + * @param isFBO TODO * @return bitmask representing the input boolean in exclusive or logic, ie only one bit will be set */ - public static final int getWinAttributeBits(boolean isOnscreen, boolean isPBuffer) { + public static final int getWinAttributeBits(boolean isOnscreen, boolean isPBuffer, boolean isFBO) { int winattrbits = 0; if(isOnscreen) { winattrbits |= WINDOW_BIT; - } else if (!isPBuffer) { - winattrbits |= BITMAP_BIT; } else { - winattrbits |= PBUFFER_BIT; + if(isFBO) { + winattrbits |= FBO_BIT; + } + if (!isPBuffer) { + winattrbits |= BITMAP_BIT; + } else { + winattrbits |= PBUFFER_BIT; + } } return winattrbits; } /** - * @see #getWinAttributeBits(boolean, boolean) + * @see #getWinAttributeBits(boolean, boolean, boolean) */ public static final int getWinAttributeBits(GLCapabilitiesImmutable caps) { - return getWinAttributeBits(caps.isOnscreen(), caps.isPBuffer()); + return getWinAttributeBits(caps.isOnscreen(), caps.isPBuffer(), false); } public static final boolean addGLCapabilitiesPermutations(List capsBucket, GLCapabilitiesImmutable temp, int winattrbits) { @@ -92,43 +106,58 @@ public class GLGraphicsConfigurationUtil { if( 0 != ( WINDOW_BIT & winattrbits ) ) { GLCapabilities cpy = (GLCapabilities) temp.cloneMutable(); cpy.setOnscreen(true); + cpy.setPBuffer(false); + cpy.setFBO(false); capsBucket.add(cpy); } - if( 0 != ( PBUFFER_BIT & winattrbits ) ) { + if( 0 != ( PBUFFER_BIT & winattrbits ) || 0 != ( FBO_BIT & winattrbits ) ) { GLCapabilities cpy = (GLCapabilities) temp.cloneMutable(); - cpy.setPBuffer(true); + cpy.setFBO(0 != ( FBO_BIT & winattrbits )); + cpy.setPBuffer(0 != ( PBUFFER_BIT & winattrbits )); capsBucket.add(cpy); } if( 0 != ( BITMAP_BIT & winattrbits ) ) { GLCapabilities cpy = (GLCapabilities) temp.cloneMutable(); cpy.setOnscreen(false); cpy.setPBuffer(false); + cpy.setFBO(false); capsBucket.add(cpy); } return capsBucket.size() > preSize; } - public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean pbufferAvailable) + public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) { if( !capsRequested.isOnscreen() ) { - return fixOffScreenGLCapabilities(capsRequested, pbufferAvailable); + return fixOffscreenGLCapabilities(capsRequested, fboAvailable, pbufferAvailable); } - return capsRequested; + return fixOnscreenGLCapabilities(capsRequested); } - public static GLCapabilitiesImmutable fixOffScreenGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean pbufferAvailable) + public static GLCapabilitiesImmutable fixOnscreenGLCapabilities(GLCapabilitiesImmutable capsRequested) + { + if( !capsRequested.isOnscreen() ) { + // fix caps .. + GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); + caps2.setOnscreen(true); + return caps2; + } + return capsRequested; + } + + public static GLCapabilitiesImmutable fixOffscreenGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) { if( capsRequested.getDoubleBuffered() || capsRequested.isOnscreen() || - ( !pbufferAvailable && capsRequested.isPBuffer() ) ) + ( fboAvailable != capsRequested.isFBO() ) || + ( pbufferAvailable != capsRequested.isPBuffer() ) ) { // fix caps .. GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); caps2.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN caps2.setOnscreen(false); - if(caps2.isPBuffer() && !pbufferAvailable) { - caps2.setPBuffer(false); - } + caps2.setFBO( fboAvailable ); + caps2.setPBuffer( pbufferAvailable ); return caps2; } return capsRequested; @@ -136,12 +165,13 @@ public class GLGraphicsConfigurationUtil { public static GLCapabilitiesImmutable fixGLPBufferGLCapabilities(GLCapabilitiesImmutable capsRequested) { - if( capsRequested.getDoubleBuffered() || capsRequested.isOnscreen() || !capsRequested.isPBuffer()) { + if( capsRequested.getDoubleBuffered() || capsRequested.isOnscreen() || !capsRequested.isPBuffer() || capsRequested.isFBO() ) { // fix caps .. GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); caps2.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN - we don't need to be single buffered .. caps2.setOnscreen(false); caps2.setPBuffer(true); + caps2.setFBO(false); return caps2; } return capsRequested; diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index a8277fd71..bbc28e283 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -54,8 +54,7 @@ import javax.media.opengl.GLPbuffer; public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { private int floatMode; - public GLPbufferImpl(GLDrawableImpl pbufferDrawable, - GLContext sharedContext) { + public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContext sharedContext) { super(pbufferDrawable, null); // drawable := pbufferDrawable GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) @@ -111,6 +110,11 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { // GLAutoDrawable completion // + @Override + public final Object getUpstreamWidget() { + return null; + } + @Override public void destroy() { defaultDestroyOp(); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 65a4c3ece..c5d0df645 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -110,14 +110,8 @@ public abstract class EGLContext extends GLContextImpl { @Override protected void makeCurrentImpl() throws GLException { - if(EGL.EGL_NO_DISPLAY==((EGLDrawable)drawable).getDisplay() ) { - throw new GLException("drawable not properly initialized, NO DISPLAY: "+drawable); - } if (EGL.eglGetCurrentContext() != contextHandle) { - if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(), - drawable.getHandle(), - drawableRead.getHandle(), - contextHandle)) { + if (!EGL.eglMakeCurrent(drawable.getNativeSurface().getDisplayHandle(), drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { throw new GLException("Error making context 0x" + Long.toHexString(contextHandle) + " current: error code 0x" + Integer.toHexString(EGL.eglGetError())); } @@ -126,10 +120,7 @@ public abstract class EGLContext extends GLContextImpl { @Override protected void releaseImpl() throws GLException { - if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(), - EGL.EGL_NO_SURFACE, - EGL.EGL_NO_SURFACE, - EGL.EGL_NO_CONTEXT)) { + if (!EGL.eglMakeCurrent(drawable.getNativeSurface().getDisplayHandle(), EGL.EGL_NO_SURFACE, EGL.EGL_NO_SURFACE, EGL.EGL_NO_CONTEXT)) { throw new GLException("Error freeing OpenGL context 0x" + Long.toHexString(contextHandle) + ": error code 0x" + Integer.toHexString(EGL.eglGetError())); } @@ -137,7 +128,7 @@ public abstract class EGLContext extends GLContextImpl { @Override protected void destroyImpl() throws GLException { - if (!EGL.eglDestroyContext(((EGLDrawable)drawable).getDisplay(), contextHandle)) { + if (!EGL.eglDestroyContext(drawable.getNativeSurface().getDisplayHandle(), contextHandle)) { final int eglError = EGL.eglGetError(); if(EGL.EGL_SUCCESS != eglError) { /* oops, Mesa EGL impl. may return false, but has no EGL error */ throw new GLException("Error destroying OpenGL context 0x" + @@ -158,16 +149,16 @@ public abstract class EGLContext extends GLContextImpl { @Override protected boolean createImpl(GLContextImpl shareWith) throws GLException { - long eglDisplay = ((EGLDrawable)drawable).getDisplay(); - EGLGraphicsConfiguration config = ((EGLDrawable)drawable).getGraphicsConfiguration(); - GLProfile glProfile = drawable.getGLProfile(); - long eglConfig = config.getNativeConfig(); + final EGLGraphicsConfiguration config = (EGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); + final long eglDisplay = config.getScreen().getDevice().getHandle(); + final GLProfile glProfile = drawable.getGLProfile(); + final long eglConfig = config.getNativeConfig(); long shareWithHandle = EGL.EGL_NO_CONTEXT; - if (eglDisplay == 0) { + if ( 0 == eglDisplay ) { throw new GLException("Error: attempted to create an OpenGL context without a display connection"); } - if (eglConfig == 0) { + if ( 0 == eglConfig ) { throw new GLException("Error: attempted to create an OpenGL context without a graphics configuration"); } @@ -217,10 +208,7 @@ public abstract class EGLContext extends GLContextImpl { ",\n\t"+this+ ",\n\tsharing with 0x" + Long.toHexString(shareWithHandle)); } - if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(), - drawable.getHandle(), - drawableRead.getHandle(), - contextHandle)) { + if (!EGL.eglMakeCurrent(eglDisplay, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { throw new GLException("Error making context 0x" + Long.toHexString(contextHandle) + " current: error code " + EGL.eglGetError()); } @@ -269,8 +257,7 @@ public abstract class EGLContext extends GLContextImpl { eglQueryStringInitialized = true; } if (eglQueryStringAvailable) { - final String ret = EGL.eglQueryString(((EGLDrawable)drawable).getDisplay(), - EGL.EGL_EXTENSIONS); + final String ret = EGL.eglQueryString(drawable.getNativeSurface().getDisplayHandle(), EGL.EGL_EXTENSIONS); if (DEBUG) { System.err.println("EGL extensions: " + ret); } @@ -291,7 +278,7 @@ public abstract class EGLContext extends GLContextImpl { } return false; } - return EGL.eglSwapInterval(((EGLDrawable)drawable).getDisplay(), interval); + return EGL.eglSwapInterval(drawable.getNativeSurface().getDisplayHandle(), interval); } @Override @@ -300,6 +287,45 @@ public abstract class EGLContext extends GLContextImpl { @Override public abstract void releasePbufferFromTexture(); + // + // Accessible .. + // + + /** + * If context is an ES profile, map it to the given device + * via {@link GLContext#mapAvailableGLVersion(AbstractGraphicsDevice, int, int, int, int, int)}. + *

    + * We intentionally override a non native EGL device ES profile mapping, + * i.e. this will override/modify an already 'set' X11/WGL/.. mapping. + *

    + * + * @param device + */ + protected void mapCurrentAvailableGLVersion(AbstractGraphicsDevice device) { + mapCurrentAvailableGLVersionImpl(device, ctxMajorVersion, ctxMinorVersion, ctxOptions); + } + + protected static void mapStaticGLESVersion(AbstractGraphicsDevice device, int major) { + int ctp = ( 2 == major ) ? ( GLContext.CTX_PROFILE_ES | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) : ( GLContext.CTX_PROFILE_ES ); + mapCurrentAvailableGLVersionImpl(device, major, 0, ctp); + } + private static void mapCurrentAvailableGLVersionImpl(AbstractGraphicsDevice device, int major, int minor, int ctp) { + if( 0 != ( ctp & GLContext.CTX_PROFILE_ES) ) { + // ES1 or ES2 + final int reqMajor = major; + final int reqProfile = GLContext.CTX_PROFILE_ES; + GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, + major, minor, ctp); + } + } + + protected static boolean getAvailableGLVersionsSet(AbstractGraphicsDevice device) { + return GLContext.getAvailableGLVersionsSet(device); + } + protected static void setAvailableGLVersionsSet(AbstractGraphicsDevice device) { + GLContext.setAvailableGLVersionsSet(device); + } + protected static String toHexString(int hex) { return GLContext.toHexString(hex); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index 7f10d3bd9..432010f49 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -136,7 +136,17 @@ public class EGLDisplayUtil { return res; } - public static final EGLGraphicsDevice.EGLTerminateCallback eglTerminateCallback = new EGLGraphicsDevice.EGLTerminateCallback() { + public static final EGLGraphicsDevice.EGLDisplayLifecycleCallback eglLifecycleCallback = new EGLGraphicsDevice.EGLDisplayLifecycleCallback() { + public long eglGetAndInitDisplay(long nativeDisplayID) { + long eglDisplay = EGLDisplayUtil.eglGetDisplay(nativeDisplayID); + if (eglDisplay == EGL.EGL_NO_DISPLAY) { + throw new GLException("Failed to created EGL display: 0x"+Long.toHexString(nativeDisplayID)+", error 0x"+Integer.toHexString(EGL.eglGetError())); + } + if (!EGLDisplayUtil.eglInitialize(eglDisplay, null, null)) { + throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError())); + } + return eglDisplay; + } public void eglTerminate(long eglDisplayHandle) { EGLDisplayUtil.eglTerminate(eglDisplayHandle); } @@ -148,17 +158,12 @@ public class EGLDisplayUtil { * @param unitID * @return an initialized EGLGraphicsDevice * @throws GLException if {@link EGL#eglGetDisplay(long)} or {@link EGL#eglInitialize(long, int[], int, int[], int)} fails - * @see EGLGraphicsDevice#EGLGraphicsDevice(long, long, String, int, com.jogamp.nativewindow.egl.EGLGraphicsDevice.EGLTerminateCallback) + * @see EGLGraphicsDevice#EGLGraphicsDevice(long, long, String, int, com.jogamp.nativewindow.egl.EGLGraphicsDevice.EGLDisplayLifecycleCallback) */ public static EGLGraphicsDevice eglCreateEGLGraphicsDevice(long nativeDisplayID, String connection, int unitID) { - long eglDisplay = EGLDisplayUtil.eglGetDisplay(nativeDisplayID); - if (eglDisplay == EGL.EGL_NO_DISPLAY) { - throw new GLException("Failed to created EGL display: 0x"+Long.toHexString(nativeDisplayID)+", error 0x"+Integer.toHexString(EGL.eglGetError())); - } - if (!EGLDisplayUtil.eglInitialize(eglDisplay, null, null)) { - throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError())); - } - return new EGLGraphicsDevice(nativeDisplayID, eglDisplay, connection, unitID, eglTerminateCallback); + final EGLGraphicsDevice eglDisplay = new EGLGraphicsDevice(nativeDisplayID, 0, connection, unitID, eglLifecycleCallback); + eglDisplay.open(); + return eglDisplay; } /** @@ -189,6 +194,6 @@ public class EGLDisplayUtil { throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError())); } final AbstractGraphicsDevice adevice = surface.getGraphicsConfiguration().getScreen().getDevice(); - return new EGLGraphicsDevice(nativeDisplayID, eglDisplay, adevice.getConnection(), adevice.getUnitID(), eglTerminateCallback); + return new EGLGraphicsDevice(nativeDisplayID, eglDisplay, adevice.getConnection(), adevice.getUnitID(), eglLifecycleCallback); } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java index d777c4f04..383b61f88 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java @@ -36,82 +36,65 @@ package jogamp.opengl.egl; -import jogamp.opengl.GLDynamicLookupHelper; -import jogamp.opengl.GLDrawableImpl; +import javax.media.nativewindow.MutableSurface; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.ProxySurface; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLException; -import javax.media.nativewindow.*; -import javax.media.nativewindow.VisualIDHolder.VIDType; -import javax.media.opengl.*; +import jogamp.opengl.GLDrawableImpl; +import jogamp.opengl.GLDynamicLookupHelper; -import com.jogamp.nativewindow.egl.*; +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; public abstract class EGLDrawable extends GLDrawableImpl { - private boolean ownEGLDisplay = false; // for destruction private boolean ownEGLSurface = false; // for destruction - private EGLGraphicsConfiguration eglConfig; - private EGLGraphicsDevice eglDevice; - private long eglSurface; - protected EGLDrawable(EGLDrawableFactory factory, - NativeSurface component) throws GLException { + protected EGLDrawable(EGLDrawableFactory factory, NativeSurface component) throws GLException { super(factory, component, false); - eglSurface=EGL.EGL_NO_SURFACE; - eglDevice=null; - } - - public final long getDisplay() { - return null != eglDevice ? eglDevice.getHandle() : 0; - } - - @Override - public final long getHandle() { - return eglSurface; - } - - public final EGLGraphicsConfiguration getGraphicsConfiguration() { - return eglConfig; - } - - @Override - public final GLCapabilitiesImmutable getChosenGLCapabilities() { - return (null==eglConfig)?super.getChosenGLCapabilities():(GLCapabilitiesImmutable)eglConfig.getChosenCapabilities(); } @Override public abstract GLContext createContext(GLContext shareWith); - protected abstract long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle); + protected abstract long createSurface(EGLGraphicsConfiguration config, long nativeSurfaceHandle); private final void recreateSurface() { - // create a new EGLSurface .. - if(EGL.EGL_NO_SURFACE!=eglSurface) { - EGL.eglDestroySurface(eglDevice.getHandle(), eglSurface); - } - + final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) surface.getGraphicsConfiguration(); + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) eglConfig.getScreen().getDevice(); if(DEBUG) { - System.err.println(getThreadName() + ": createSurface using "+eglDevice+", "+eglConfig); + System.err.println(getThreadName() + ": createSurface using "+eglConfig); + } + if( EGL.EGL_NO_SURFACE != surface.getSurfaceHandle() ) { + EGL.eglDestroySurface(eglDevice.getHandle(), surface.getSurfaceHandle()); } - - eglSurface = createSurface(eglDevice.getHandle(), eglConfig.getNativeConfig(), surface.getSurfaceHandle()); - int eglError0 = EGL.EGL_SUCCESS; + + final EGLUpstreamSurfaceHook upstreamHook = (EGLUpstreamSurfaceHook) ((ProxySurface)surface).getUpstreamSurfaceHook(); + final NativeSurface upstreamSurface = upstreamHook.getUpstreamSurface(); + long eglSurface = createSurface(eglConfig, upstreamSurface.getSurfaceHandle()); + + int eglError0; if (EGL.EGL_NO_SURFACE == eglSurface) { eglError0 = EGL.eglGetError(); if(EGL.EGL_BAD_NATIVE_WINDOW == eglError0) { // Try window handle if available and differs (Windows HDC / HWND). // ANGLE impl. required HWND on Windows. - if(surface instanceof NativeWindow) { - final NativeWindow nw = (NativeWindow) surface; + if(upstreamSurface instanceof NativeWindow) { + final NativeWindow nw = (NativeWindow) upstreamSurface; if(nw.getWindowHandle() != nw.getSurfaceHandle()) { if(DEBUG) { System.err.println(getThreadName() + ": Info: Creation of window surface w/ surface handle failed: "+eglConfig+", error "+toHexString(eglError0)+", retry w/ windowHandle"); } - eglSurface = createSurface(eglDevice.getHandle(), eglConfig.getNativeConfig(), nw.getWindowHandle()); + eglSurface = createSurface(eglConfig, nw.getWindowHandle()); if (EGL.EGL_NO_SURFACE == eglSurface) { eglError0 = EGL.eglGetError(); } } } } + } else { + eglError0 = EGL.EGL_SUCCESS; } if (EGL.EGL_NO_SURFACE == eglSurface) { throw new GLException("Creation of window surface failed: "+eglConfig+", "+surface+", error "+toHexString(eglError0)); @@ -120,6 +103,8 @@ public abstract class EGLDrawable extends GLDrawableImpl { if(DEBUG) { System.err.println(getThreadName() + ": setSurface using component: handle "+toHexString(surface.getSurfaceHandle())+" -> "+toHexString(eglSurface)); } + + ((MutableSurface)surface).setSurfaceHandle(eglSurface); } @Override @@ -131,123 +116,71 @@ public abstract class EGLDrawable extends GLDrawableImpl { @Override protected final void setRealizedImpl() { + final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) surface.getGraphicsConfiguration(); + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) eglConfig.getScreen().getDevice(); if (realized) { - AbstractGraphicsConfiguration aConfig = surface.getGraphicsConfiguration(); - AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice(); - if(aDevice instanceof EGLGraphicsDevice) { + final long eglDisplayHandle = eglDevice.getHandle(); + if (EGL.EGL_NO_DISPLAY == eglDisplayHandle) { + throw new GLException("Invalid EGL display in EGLGraphicsDevice "+eglDevice); + } + int[] tmp = new int[1]; + boolean eglSurfaceValid = 0 != surface.getSurfaceHandle(); + if(eglSurfaceValid) { + eglSurfaceValid = EGL.eglQuerySurface(eglDisplayHandle, surface.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0); + if(!eglSurfaceValid) { + if(DEBUG) { + System.err.println(getThreadName() + ": EGLDrawable.setRealizedImpl eglQuerySuface failed: "+toHexString(EGL.eglGetError())+", "+surface); + } + } + } + if(eglSurfaceValid) { + // surface holds valid EGLSurface if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealized(true): using existing EGL config - START"); + System.err.println(getThreadName() + ": EGLDrawable.setRealizedImpl re-using component's EGLSurface: handle "+toHexString(surface.getSurfaceHandle())); + } + ownEGLSurface=false; + } else { + // EGLSurface is ours - subsequent updateHandle() will issue recreateSurface(); + // However .. let's validate the surface object first + if( ! (surface instanceof ProxySurface) ) { + throw new InternalError("surface not ProxySurface: "+surface.getClass().getName()+", "+surface); } - // just fetch the data .. trust but verify .. - ownEGLDisplay = false; - eglDevice = (EGLGraphicsDevice) aDevice; - if (eglDevice.getHandle() == EGL.EGL_NO_DISPLAY) { - throw new GLException("Invalid EGL display in EGLGraphicsDevice "+eglDevice); + final ProxySurface.UpstreamSurfaceHook upstreamHook = ((ProxySurface)surface).getUpstreamSurfaceHook(); + if( null == upstreamHook ) { + throw new InternalError("null upstreamHook of: "+surface); } - if(aConfig instanceof EGLGraphicsConfiguration) { - eglConfig = (EGLGraphicsConfiguration) aConfig; // done .. - if (null == eglConfig) { - throw new GLException("Null EGLGraphicsConfiguration from "+aConfig); - } - - int[] tmp = new int[1]; - if ( 0 != surface.getSurfaceHandle() && - EGL.eglQuerySurface(eglDevice.getHandle(), surface.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0) ) { - // surface holds static EGLSurface - eglSurface = surface.getSurfaceHandle(); - if(DEBUG) { - System.err.println(getThreadName() + ": setSurface re-using component's EGLSurface: handle "+toHexString(eglSurface)); - } - ownEGLSurface=false; - } else { - // EGLSurface is ours - subsequent updateHandle() will issue recreateSurface(); - ownEGLSurface=true; - } - } else { - throw new GLException("EGLGraphicsDevice hold by non EGLGraphicsConfiguration: "+aConfig); + if( ! (upstreamHook instanceof EGLUpstreamSurfaceHook) ) { + throw new InternalError("upstreamHook not EGLUpstreamSurfaceHook: Surface: "+surface.getClass().getName()+", "+surface+"; UpstreamHook: "+upstreamHook.getClass().getName()+", "+upstreamHook); } - } else { - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealized(true): creating new EGL config - START"); + if( null == ((EGLUpstreamSurfaceHook)upstreamHook).getUpstreamSurface() ) { + throw new InternalError("null upstream surface"); } - // create a new EGL config .. - ownEGLDisplay=true; - // EGLSurface is ours .. ownEGLSurface=true; - - eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface, true); - AbstractGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aConfig.getScreen().getIndex()); - final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities(); - if(aConfig instanceof EGLGraphicsConfiguration) { - final EGLGLCapabilities capsChosen = (EGLGLCapabilities) aConfig.getChosenCapabilities(); - if(0 == capsChosen.getEGLConfig()) { - // 'refresh' the native EGLConfig handle - capsChosen.setEGLConfig(EGLGraphicsConfiguration.EGLConfigId2EGLConfig(eglDevice.getHandle(), capsChosen.getEGLConfigID())); - if(0 == capsChosen.getEGLConfig()) { - throw new GLException("Refreshing native EGLConfig handle failed: "+capsChosen+" of "+aConfig); - } - } - eglConfig = new EGLGraphicsConfiguration(eglScreen, capsChosen, capsRequested, null); - if(DEBUG) { - System.err.println(getThreadName() + ": Reusing chosenCaps: "+eglConfig); - } - } else { - eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( - capsRequested, capsRequested, null, eglScreen, aConfig.getVisualID(VIDType.NATIVE), false); - - if (null == eglConfig) { - throw new GLException("Couldn't create EGLGraphicsConfiguration from "+eglScreen); - } else if(DEBUG) { - System.err.println(getThreadName() + ": Chosen eglConfig: "+eglConfig); - } + if(DEBUG) { + System.err.println(getThreadName() + ": EGLDrawable.setRealizedImpl owning EGLSurface"); } - // subsequent updateHandle() will issue recreateSurface(); - } - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealized(true): END: ownDisplay "+ownEGLDisplay+", ownSurface "+ownEGLSurface); } - } else if (ownEGLSurface && eglSurface != EGL.EGL_NO_SURFACE) { + } else if (ownEGLSurface && surface.getSurfaceHandle() != EGL.EGL_NO_SURFACE) { if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealized(false): ownDisplay "+ownEGLDisplay+", ownSurface "+ownEGLSurface+", "+eglDevice+", eglSurface: "+toHexString(eglSurface)); + System.err.println(getThreadName() + ": EGLDrawable.setRealized(false): ownSurface "+ownEGLSurface+", "+eglDevice+", eglSurface: "+toHexString(surface.getSurfaceHandle())); } // Destroy the window surface - if (!EGL.eglDestroySurface(eglDevice.getHandle(), eglSurface)) { + if (!EGL.eglDestroySurface(eglDevice.getHandle(), surface.getSurfaceHandle())) { throw new GLException("Error destroying window surface (eglDestroySurface)"); } - eglSurface = EGL.EGL_NO_SURFACE; - eglConfig=null; - eglDevice.close(); - eglDevice=null; + ((MutableSurface)surface).setSurfaceHandle(EGL.EGL_NO_SURFACE); } } @Override protected final void swapBuffersImpl() { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers() - if(!EGL.eglSwapBuffers(eglDevice.getHandle(), eglSurface)) { + if(!EGL.eglSwapBuffers(eglDevice.getHandle(), surface.getSurfaceHandle())) { throw new GLException("Error swapping buffers, eglError "+toHexString(EGL.eglGetError())+", "+this); } } - /** - * Surface not realizes yet (onscreen) .. Quering EGL surface size only makes sense for external drawable. - * Leave it here for later impl. of an EGLExternalDrawable. - public int getWidth() { - int[] tmp = new int[1]; - if (!EGL.eglQuerySurface(eglDisplay, eglSurface, EGL.EGL_WIDTH, tmp, 0)) { - throw new GLException("Error querying surface width, eglError "+toHexString(EGL.eglGetError())); - } - return tmp[0]; - } - - public int getHeight() { - int[] tmp = new int[1]; - if (!EGL.eglQuerySurface(eglDisplay, eglSurface, EGL.EGL_HEIGHT, tmp, 0)) { - throw new GLException("Error querying surface height, eglError "+toHexString(EGL.eglGetError())); - } - return tmp[0]; - } */ - @Override public GLDynamicLookupHelper getGLDynamicLookupHelper() { if (getGLProfile().usesNativeGLES2()) { @@ -263,10 +196,9 @@ public abstract class EGLDrawable extends GLDrawableImpl { public String toString() { return getClass().getName()+"[realized "+isRealized()+ ",\n\tfactory "+getFactory()+ - ",\n\tdevice "+eglDevice+ ",\n\tsurface "+getNativeSurface()+ - ",\n\teglSurface "+toHexString(eglSurface)+ - ",\n\teglConfig "+eglConfig+ + ",\n\teglSurface "+toHexString(surface.getSurfaceHandle())+ + ",\n\teglConfig "+surface.getGraphicsConfiguration()+ ",\n\trequested "+getRequestedGLCapabilities()+ ",\n\tchosen "+getChosenGLCapabilities()+"]"; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index f4fa1f13f..c848e3e5c 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -46,21 +46,29 @@ import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.nativewindow.VisualIDHolder; +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import javax.media.opengl.GLProfile.ShutdownType; +import jogamp.opengl.Debug; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; +import jogamp.opengl.GLGraphicsConfigurationUtil; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.os.Platform; @@ -69,6 +77,9 @@ import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; public class EGLDrawableFactory extends GLDrawableFactoryImpl { + /* package */ static final boolean QUERY_EGL_ES = !Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.DontQuery", true); + /* package */ static final boolean QUERY_EGL_ES_NATIVE_TK = Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.QueryNativeTK", true); + private static GLDynamicLookupHelper eglES1DynamicLookupHelper = null; private static GLDynamicLookupHelper eglES2DynamicLookupHelper = null; private static boolean isANGLE = false; @@ -231,7 +242,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { // final EGLContext getContextES1() { return contextES1; } // final EGLContext getContextES2() { return contextES2; } final boolean wasES1ContextAvailable() { return wasES1ContextCreated; } - final boolean wasES2ContextAvailable() { return wasES2ContextCreated; } + final boolean wasES2ContextAvailable() { return wasES2ContextCreated; } } @Override @@ -245,35 +256,98 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { return null!=eglES2DynamicLookupHelper || null!=eglES1DynamicLookupHelper; } - /** - private boolean isEGLContextAvailable(EGLGraphicsDevice sharedDevice, String profile) { - boolean madeCurrent = false; - final GLCapabilities caps = new GLCapabilities(GLProfile.get(profile)); - caps.setRedBits(5); caps.setGreenBits(5); caps.setBlueBits(5); caps.setAlphaBits(0); - caps.setDoubleBuffered(false); - caps.setOnscreen(false); - caps.setPBuffer(true); - final EGLDrawable drawable = (EGLDrawable) createGLDrawable( createOffscreenSurfaceImpl(sharedDevice, caps, caps, null, 64, 64) ); - if(null!=drawable) { + private boolean isEGLContextAvailable(AbstractGraphicsDevice adevice, EGLGraphicsDevice sharedEGLDevice, String profileString) { + if( !GLProfile.isAvailable(adevice, profileString) ) { + return false; + } + final GLProfile glp = GLProfile.get(adevice, profileString) ; + final GLDrawableFactoryImpl desktopFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getDesktopFactory(); + EGLGraphicsDevice eglDevice = null; + NativeSurface surface = null; + ProxySurface upstreamSurface = null; // X11, GLX, .. + boolean success = false; + boolean deviceFromUpstreamSurface = false; + try { + final GLCapabilities caps = new GLCapabilities(glp); + caps.setRedBits(5); caps.setGreenBits(5); caps.setBlueBits(5); caps.setAlphaBits(0); + if(adevice instanceof EGLGraphicsDevice || null == desktopFactory || !QUERY_EGL_ES_NATIVE_TK) { + eglDevice = sharedEGLDevice; // reuse + surface = createDummySurfaceImpl(eglDevice, false, caps, null, 64, 64); // egl pbuffer offscreen + upstreamSurface = (ProxySurface)surface; + upstreamSurface.createNotify(); + deviceFromUpstreamSurface = false; + } else { + surface = desktopFactory.createDummySurface(adevice, caps, null, 64, 64); // X11, WGL, .. dummy window + upstreamSurface = ( surface instanceof ProxySurface ) ? (ProxySurface)surface : null ; + if(null != upstreamSurface) { + upstreamSurface.createNotify(); + } + eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface, true); + deviceFromUpstreamSurface = true; + } + + final EGLDrawable drawable = (EGLDrawable) createOnscreenDrawableImpl ( surface ); + drawable.setRealized(true); final EGLContext context = (EGLContext) drawable.createContext(null); if (null != context) { - context.setSynchronized(true); try { context.makeCurrent(); // could cause exception - madeCurrent = context.isCurrent(); + success = context.isCurrent(); + if(success) { + final String glVersion = context.getGL().glGetString(GL.GL_VERSION); + if(null == glVersion) { + // Oops .. something is wrong + if(DEBUG) { + System.err.println("EGLDrawableFactory.isEGLContextAvailable: "+eglDevice+", "+context.getGLVersion()+" - VERSION is null, dropping availability!"); + } + success = false; + } + } + if(success) { + context.mapCurrentAvailableGLVersion(eglDevice); + if(eglDevice != adevice) { + context.mapCurrentAvailableGLVersion(adevice); + } + } } catch (GLException gle) { if (DEBUG) { - System.err.println("EGLDrawableFactory.createShared: INFO: makeCurrent failed"); + System.err.println("EGLDrawableFactory.createShared: INFO: context create/makeCurrent failed"); gle.printStackTrace(); } } finally { context.destroy(); } } - drawable.destroy(); + drawable.setRealized(false); + } catch (Throwable t) { + if(DEBUG) { + System.err.println("Catched Exception:"); + t.printStackTrace(); + } + success = false; + } finally { + if(eglDevice == sharedEGLDevice) { + if(null != upstreamSurface) { + upstreamSurface.destroyNotify(); + } + } else if( deviceFromUpstreamSurface ) { + if(null != eglDevice) { + eglDevice.close(); + } + if(null != upstreamSurface) { + upstreamSurface.destroyNotify(); + } + } else { + if(null != upstreamSurface) { + upstreamSurface.destroyNotify(); + } + if(null != eglDevice) { + eglDevice.close(); + } + } } - return madeCurrent; - } */ + return success; + } /* package */ SharedResource getOrCreateEGLSharedResource(AbstractGraphicsDevice adevice) { if(null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper) { @@ -285,18 +359,41 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { sr = sharedMap.get(connection); } if(null==sr) { - final EGLGraphicsDevice sharedDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, connection, adevice.getUnitID()); + final boolean madeCurrentES1; + final boolean madeCurrentES2; + final EGLGraphicsDevice sharedDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); - // final boolean madeCurrentES1 = isEGLContextAvailable(sharedDevice, GLProfile.GLES1); - // final boolean madeCurrentES2 = isEGLContextAvailable(sharedDevice, GLProfile.GLES2); - final boolean madeCurrentES1 = true; // FIXME - final boolean madeCurrentES2 = true; // FIXME + if(QUERY_EGL_ES) { + madeCurrentES1 = isEGLContextAvailable(adevice, sharedDevice, GLProfile.GLES1); + madeCurrentES2 = isEGLContextAvailable(adevice, sharedDevice, GLProfile.GLES2); + } else { + madeCurrentES1 = true; + madeCurrentES2 = true; + EGLContext.mapStaticGLESVersion(sharedDevice, 1); + if(sharedDevice != adevice) { + EGLContext.mapStaticGLESVersion(adevice, 1); + } + EGLContext.mapStaticGLESVersion(sharedDevice, 2); + if(sharedDevice != adevice) { + EGLContext.mapStaticGLESVersion(adevice, 2); + } + } + + if( !EGLContext.getAvailableGLVersionsSet(adevice) ) { + // Even though we override the non EGL native mapping intentionally, + // avoid exception due to double 'set' - carefull exception of the rule. + EGLContext.setAvailableGLVersionsSet(adevice); + } sr = new SharedResource(sharedDevice, madeCurrentES1, madeCurrentES2); + synchronized(sharedMap) { sharedMap.put(connection, sr); + if(adevice != sharedDevice) { + sharedMap.put(sharedDevice.getConnection(), sr); + } } if (DEBUG) { - System.err.println("EGLDrawableFactory.createShared: device: " + sharedDevice); + System.err.println("EGLDrawableFactory.createShared: devices: queried " + QUERY_EGL_ES + "[nativeTK "+QUERY_EGL_ES_NATIVE_TK+"], " + adevice + ", " + sharedDevice); System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1); System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2); } @@ -367,8 +464,51 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if (target == null) { throw new IllegalArgumentException("Null target"); } - return new EGLOnscreenDrawable(this, target); + return new EGLOnscreenDrawable(this, getEGLSurface(target)); + } + + protected static NativeSurface getEGLSurface(NativeSurface surface) { + AbstractGraphicsConfiguration aConfig = surface.getGraphicsConfiguration(); + AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice(); + if( aDevice instanceof EGLGraphicsDevice && aConfig instanceof EGLGraphicsConfiguration ) { + // already in native EGL format + if(DEBUG) { + System.err.println(getThreadName() + ": getEGLSurface - already in EGL format - use as-is: "+aConfig); + } + return surface; + } + // create EGL instance out of platform native types + final EGLGraphicsDevice eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface, true); + final AbstractGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aConfig.getScreen().getIndex()); + final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities(); + final EGLGraphicsConfiguration eglConfig; + if( aConfig instanceof EGLGraphicsConfiguration ) { + // Config is already in EGL type - reuse .. + final EGLGLCapabilities capsChosen = (EGLGLCapabilities) aConfig.getChosenCapabilities(); + if( 0 == capsChosen.getEGLConfig() ) { + // 'refresh' the native EGLConfig handle + capsChosen.setEGLConfig(EGLGraphicsConfiguration.EGLConfigId2EGLConfig(eglDevice.getHandle(), capsChosen.getEGLConfigID())); + if( 0 == capsChosen.getEGLConfig() ) { + throw new GLException("Refreshing native EGLConfig handle failed: "+capsChosen+" of "+aConfig); + } + } + eglConfig = new EGLGraphicsConfiguration(eglScreen, capsChosen, capsRequested, null); + if(DEBUG) { + System.err.println(getThreadName() + ": getEGLSurface - Reusing chosenCaps: "+eglConfig); + } + } else { + eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( + capsRequested, capsRequested, null, eglScreen, aConfig.getVisualID(VIDType.NATIVE), false); + + if (null == eglConfig) { + throw new GLException("Couldn't create EGLGraphicsConfiguration from "+eglScreen); + } else if(DEBUG) { + System.err.println(getThreadName() + ": getEGLSurface - Chosen eglConfig: "+eglConfig); + } + } + return new WrappedSurface(eglConfig, EGL.EGL_NO_SURFACE, surface.getWidth(), surface.getHeight(), new EGLUpstreamSurfaceHook(surface)); } + static String getThreadName() { return Thread.currentThread().getName(); } @Override protected GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) { @@ -390,22 +530,115 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) { - final EGLGraphicsDevice eglDeviceReq = (EGLGraphicsDevice) deviceReq; - final EGLGraphicsDevice device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID()); - WrappedSurface ns = new WrappedSurface(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(device, capsChosen, capsRequested, chooser)); - ns.surfaceSizeChanged(width, height); - return ns; + protected ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + final EGLGraphicsDevice device; + if(createNewDevice) { + final EGLGraphicsDevice eglDeviceReq = (EGLGraphicsDevice) deviceReq; + device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID()); + } else { + device = (EGLGraphicsDevice) deviceReq; + } + final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); + final EGLGraphicsConfiguration config = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); + if(null == config) { + throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); + } + return new WrappedSurface(config, 0, width, height, lifecycleHook); + } + + @Override + public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { + final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(requestedCaps, false, canCreateGLPbuffer(deviceReq)); + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); + } + private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { + @Override + public final void create(ProxySurface s) { + if( EGL.EGL_NO_SURFACE == s.getSurfaceHandle() ) { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) s.getGraphicsConfiguration().getScreen().getDevice(); + if(0 == eglDevice.getHandle()) { + eglDevice.open(); + s.setImplBitfield(ProxySurface.OWN_DEVICE); + } + createPBufferSurfaceImpl(s, false); + if(DEBUG) { + System.err.println("EGLDrawableFactory.dummySurfaceLifecycleHook.create: "+s); + } + } + } + @Override + public final void destroy(ProxySurface s) { + if( EGL.EGL_NO_SURFACE != s.getSurfaceHandle() ) { + final EGLGraphicsConfiguration config = (EGLGraphicsConfiguration) s.getGraphicsConfiguration(); + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) config.getScreen().getDevice(); + EGL.eglDestroySurface(eglDevice.getHandle(), s.getSurfaceHandle()); + s.setSurfaceHandle(EGL.EGL_NO_SURFACE); + if( 0 != ( ProxySurface.OWN_DEVICE & s.getImplBitfield() ) ) { + eglDevice.close(); + } + if(DEBUG) { + System.err.println("EGLDrawableFactory.dummySurfaceLifecycleHook.create: "+s); + } + } + } + @Override + public final int getWidth(ProxySurface s) { + return s.initialWidth; + } + @Override + public final int getHeight(ProxySurface s) { + return s.initialHeight; + } + @Override + public String toString() { + return "EGLSurfaceLifecycleHook[]"; + } + + }; + + /** + * @param ms {@link MutableSurface} which dimensions and config are being used to create the pbuffer surface. + * It will also hold the resulting pbuffer surface handle. + * @param useTexture + * @return the passed {@link MutableSurface} which now has the EGL pbuffer surface set as it's handle + */ + protected static MutableSurface createPBufferSurfaceImpl(MutableSurface ms, boolean useTexture) { + final EGLGraphicsConfiguration config = (EGLGraphicsConfiguration) ms.getGraphicsConfiguration(); + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) config.getScreen().getDevice(); + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final int texFormat; + + if(useTexture) { + texFormat = caps.getAlphaBits() > 0 ? EGL.EGL_TEXTURE_RGBA : EGL.EGL_TEXTURE_RGB ; + } else { + texFormat = EGL.EGL_NO_TEXTURE; + } + + if (DEBUG) { + System.out.println("Pbuffer config: " + config); + } + + final int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(ms.getWidth(), ms.getHeight(), texFormat); + final long surf = EGL.eglCreatePbufferSurface(eglDevice.getHandle(), config.getNativeConfig(), attrs, 0); + if (EGL.EGL_NO_SURFACE==surf) { + throw new GLException("Creation of window surface (eglCreatePbufferSurface) failed, dim "+ms.getWidth()+"x"+ms.getHeight()+", error 0x"+Integer.toHexString(EGL.eglGetError())); + } else if(DEBUG) { + System.err.println("PBuffer setSurface result: eglSurface 0x"+Long.toHexString(surf)); + } + ms.setSurfaceHandle(surf); + return ms; } @Override - protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice adevice, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { - // FIXME device/windowHandle -> screen ?! - EGLGraphicsDevice device = (EGLGraphicsDevice) adevice; - DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); - EGLGraphicsConfiguration cfg = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); - WrappedSurface ns = new WrappedSurface(cfg, windowHandle); - return ns; + protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { + final EGLGraphicsDevice eglDeviceReq = (EGLGraphicsDevice) deviceReq; + final EGLGraphicsDevice device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID()); + final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); + final EGLGraphicsConfiguration cfg = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); + return new WrappedSurface(cfg, windowHandle, 0, 0, upstream); } @Override diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index 56e7a4d22..214b36493 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -151,7 +151,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple public static EGLGLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, long config, boolean relaxed, boolean onscreen, boolean usePBuffer, boolean forceTransparentFlag) { List bucket = new ArrayList(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer); + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); if( EGLConfig2Capabilities(bucket, glp, display, config, winattrmask, forceTransparentFlag) ) { return (EGLGLCapabilities) bucket.get(0); } else if ( relaxed && EGLConfig2Capabilities(bucket, glp, display, config, GLGraphicsConfigurationUtil.ALL_BITS, forceTransparentFlag) ) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 809e2b688..6be9cb547 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -38,7 +38,6 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; -import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.VisualIDHolder.VIDType; @@ -47,6 +46,7 @@ import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import javax.media.opengl.GLDrawableFactory; @@ -180,6 +180,9 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact } EGLGraphicsDevice eglDevice = sharedResource.getDevice(); long eglDisplay = eglDevice.getHandle(); + if(0 == eglDisplay) { + throw new GLException("null eglDisplay"); + } List availableCaps = null; IntBuffer numConfigs = Buffers.newDirectIntBuffer(1); @@ -236,11 +239,9 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact ownEGLDisplay = true; } - EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getEGLFactory(); - capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, factory.canCreateGLPbuffer(absDevice) ); - - GLProfile glp = capsChosen.getGLProfile(); - GLCapabilities fixedCaps; + final GLProfile glp = capsChosen.getGLProfile(); + final EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getEGLFactory(); + capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(absDevice, glp), factory.canCreateGLPbuffer(absDevice) ); EGLGraphicsConfiguration res = eglChooseConfig(eglDevice.getHandle(), capsChosen, capsReq, chooser, absScreen, nativeVisualID, forceTransparentFlag); if(null==res) { @@ -251,13 +252,18 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact // Last try .. add a fixed embedded profile [ATI, Nokia, Intel, ..] // // rgb888 - d16, s4 - fixedCaps = new GLCapabilities(glp); + final GLCapabilities fixedCaps = new GLCapabilities(glp); fixedCaps.setRedBits(8); fixedCaps.setGreenBits(8); fixedCaps.setBlueBits(8); fixedCaps.setDepthBits(16); fixedCaps.setSampleBuffers(true); fixedCaps.setNumSamples(4); + if( !capsChosen.isOnscreen() ) { + fixedCaps.setOnscreen(false); + fixedCaps.setPBuffer(capsChosen.isPBuffer()); + fixedCaps.setFBO(capsChosen.isFBO()); + } if(DEBUG) { System.err.println("trying fixed caps (1): "+fixedCaps); } @@ -266,11 +272,16 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(null==res) { // // rgb565 - d16, s0 - fixedCaps = new GLCapabilities(glp); + final GLCapabilities fixedCaps = new GLCapabilities(glp); fixedCaps.setRedBits(5); fixedCaps.setGreenBits(6); fixedCaps.setBlueBits(5); fixedCaps.setDepthBits(16); + if( !capsChosen.isOnscreen() ) { + fixedCaps.setOnscreen(false); + fixedCaps.setPBuffer(capsChosen.isPBuffer()); + fixedCaps.setFBO(capsChosen.isFBO()); + } if(DEBUG) { System.err.println("trying fixed caps (2): "+fixedCaps); } @@ -279,13 +290,18 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(null==res) { // // rgb565 - d16, s4 - fixedCaps = new GLCapabilities(glp); + final GLCapabilities fixedCaps = new GLCapabilities(glp); fixedCaps.setRedBits(5); fixedCaps.setGreenBits(6); fixedCaps.setBlueBits(5); fixedCaps.setDepthBits(16); fixedCaps.setSampleBuffers(true); fixedCaps.setNumSamples(4); + if( !capsChosen.isOnscreen() ) { + fixedCaps.setOnscreen(false); + fixedCaps.setPBuffer(capsChosen.isPBuffer()); + fixedCaps.setFBO(capsChosen.isFBO()); + } if(DEBUG) { System.err.println("trying fixed caps (3): "+fixedCaps); } @@ -309,7 +325,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact final GLProfile glp = capsChosen.getGLProfile(); final boolean onscreen = capsChosen.isOnscreen(); final boolean usePBuffer = capsChosen.isPBuffer(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer); + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); List availableCaps = null; int recommendedIndex = -1; long recommendedEGLConfig = -1; @@ -322,8 +338,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: Get maxConfigs (eglGetConfigs) no configs"); } if (DEBUG) { - System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglChooseConfig maxConfigs: "+numConfigs.get(0)); - System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglDisplay "+toHexString(eglDisplay)+", "+capsChosen+", nativeVisualID "+toHexString(nativeVisualID)); + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglChooseConfig eglDisplay "+toHexString(eglDisplay)+", nativeVisualID "+toHexString(nativeVisualID)+", onscreen "+onscreen+", usePBuffer "+usePBuffer+", "+capsChosen+", numConfigs "+numConfigs.get(0)); } final IntBuffer attrs = Buffers.newDirectIntBuffer(EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen)); @@ -362,7 +377,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: #2 Get all configs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError())); } if (numConfigs.get(0) > 0) { - availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs.get(0), winattrmask, forceTransparentFlag); + availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs.get(0), winattrmask, forceTransparentFlag); } } @@ -370,6 +385,8 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(DEBUG) { // FIXME: this happens on a ATI PC Emulation .. System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #2 Graphics configuration 1st choice and 2nd choice failed - no configs"); + availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, forceTransparentFlag); + printCaps("AllCaps", availableCaps, System.err); } return null; } @@ -428,27 +445,5 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact out.println(prefix+"["+i+"] "+caps.get(i)); } } - - static EGLGraphicsConfiguration createOffscreenGraphicsConfiguration(AbstractGraphicsDevice device, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsReq, GLCapabilitiesChooser chooser) { - if(capsChosen.isOnscreen()) { - throw new GLException("Error: Onscreen set: "+capsChosen); - } - - if(capsChosen.getDoubleBuffered()) { - // OFFSCREEN !DOUBLE_BUFFER // FIXME DBLBUFOFFSCRN - GLCapabilities caps2 = (GLCapabilities) capsChosen.cloneMutable(); - caps2.setDoubleBuffered(false); - capsChosen = caps2; - } - - DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); - EGLGraphicsConfiguration eglConfig = chooseGraphicsConfigurationStatic(capsChosen, capsReq, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); - if (null == eglConfig) { - throw new GLException("Couldn't create EGLGraphicsConfiguration from "+screen); - } else if(DEBUG) { - System.err.println("Chosen eglConfig: "+eglConfig); - } - return eglConfig; - } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java index 3768f1588..d54057775 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java @@ -54,8 +54,8 @@ public class EGLOnscreenDrawable extends EGLDrawable { } @Override - protected long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle) { - return EGL.eglCreateWindowSurface(eglDpy, eglNativeCfg, surfaceHandle, null); + protected long createSurface(EGLGraphicsConfiguration config, long nativeSurfaceHandle) { + return EGL.eglCreateWindowSurface(config.getScreen().getDevice().getHandle(), config.getNativeConfig(), nativeSurfaceHandle, null); } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java index b2217c095..4a36625bd 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java @@ -40,15 +40,11 @@ package jogamp.opengl.egl; -import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceChangeable; -import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GLContext; -import javax.media.opengl.GLException; public class EGLPbufferDrawable extends EGLDrawable { - private int texFormat; protected static final boolean useTexture = false; // No yet .. protected EGLPbufferDrawable(EGLDrawableFactory factory, NativeSurface target) { @@ -56,30 +52,12 @@ public class EGLPbufferDrawable extends EGLDrawable { } @Override - protected long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle) { - final AbstractGraphicsConfiguration config = getNativeSurface().getGraphicsConfiguration(); - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - - if(useTexture) { - texFormat = caps.getAlphaBits() > 0 ? EGL.EGL_TEXTURE_RGBA : EGL.EGL_TEXTURE_RGB ; - } else { - texFormat = EGL.EGL_NO_TEXTURE; - } - - if (DEBUG) { - System.out.println("Pbuffer config: " + config); - } - - NativeSurface nw = getNativeSurface(); - int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(nw.getWidth(), nw.getHeight(), texFormat); - long surf = EGL.eglCreatePbufferSurface(eglDpy, eglNativeCfg, attrs, 0); - if (EGL.EGL_NO_SURFACE==surf) { - throw new GLException("Creation of window surface (eglCreatePbufferSurface) failed, dim "+nw.getWidth()+"x"+nw.getHeight()+", error 0x"+Integer.toHexString(EGL.eglGetError())); - } else if(DEBUG) { - System.err.println("PBuffer setSurface result: eglSurface 0x"+Long.toHexString(surf)); + protected long createSurface(EGLGraphicsConfiguration config, long nativeSurfaceHandle) { + final MutableSurface ms = (MutableSurface)getNativeSurface(); + if(config != ms.getGraphicsConfiguration()) { + throw new InternalError("Not same: "+config.hashCode()+", "+ms.getGraphicsConfiguration()+": "+config+", "+ms.getGraphicsConfiguration()); } - ((SurfaceChangeable)nw).setSurfaceHandle(surf); - return surf; + return EGLDrawableFactory.createPBufferSurfaceImpl(ms, useTexture).getSurfaceHandle(); } @Override diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java new file mode 100644 index 000000000..42c6e100e --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java @@ -0,0 +1,56 @@ +package jogamp.opengl.egl; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.ProxySurface; +import javax.media.opengl.GLException; + +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; + +public class EGLUpstreamSurfaceHook implements ProxySurface.UpstreamSurfaceHook { + private final NativeSurface upstreamSurface; + + public EGLUpstreamSurfaceHook(NativeSurface upstream) { + upstreamSurface = upstream; + } + + public final NativeSurface getUpstreamSurface() { return upstreamSurface; } + + @Override + public final void create(ProxySurface surface) { + if(upstreamSurface instanceof ProxySurface) { + ((ProxySurface)upstreamSurface).createNotify(); + if(NativeSurface.LOCK_SURFACE_NOT_READY >= upstreamSurface.lockSurface()) { + throw new GLException("Could not lock: "+upstreamSurface); + } + } + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); + eglDevice.open(); + } + + @Override + public final void destroy(ProxySurface surface) { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); + eglDevice.close(); + if(upstreamSurface instanceof ProxySurface) { + upstreamSurface.unlockSurface(); + ((ProxySurface)upstreamSurface).destroyNotify(); + } + } + + @Override + public final int getWidth(ProxySurface s) { + return upstreamSurface.getWidth(); + } + + @Override + public final int getHeight(ProxySurface s) { + return upstreamSurface.getHeight(); + } + + @Override + public String toString() { + final String us_s = null != upstreamSurface ? ( upstreamSurface.getClass().getName() + ": " + upstreamSurface ) : "nil"; + return "EGLUpstreamSurfaceHook[upstream: "+us_s+"]"; + } + +} diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index aa66aa9d1..4bf2a3c9d 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -48,6 +48,7 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerSurface; +import javax.media.nativewindow.ProxySurface; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; @@ -63,6 +64,7 @@ import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; +import com.jogamp.opengl.GLExtensions; public abstract class MacOSXCGLContext extends GLContextImpl { @@ -252,9 +254,11 @@ public abstract class MacOSXCGLContext extends GLContextImpl @Override protected void makeCurrentImpl() throws GLException { + /** FIXME: won't work w/ special drawables (like FBO) - check for CGL mode regressions! + * if (getOpenGLMode() != ((MacOSXCGLDrawable)drawable).getOpenGLMode()) { setOpenGLMode(((MacOSXCGLDrawable)drawable).getOpenGLMode()); - } + } */ if (!impl.makeCurrent(contextHandle)) { throw new GLException("Error making Context current: "+this); } @@ -338,8 +342,8 @@ public abstract class MacOSXCGLContext extends GLContextImpl @Override public boolean isExtensionAvailable(String glExtensionName) { - if (glExtensionName.equals("GL_ARB_pbuffer") || - glExtensionName.equals("GL_ARB_pixel_format")) { + if (glExtensionName.equals(GLExtensions.ARB_pbuffer) || + glExtensionName.equals(GLExtensions.ARB_pixel_format)) { return true; } return super.isExtensionAvailable(glExtensionName); @@ -426,10 +430,13 @@ public abstract class MacOSXCGLContext extends GLContextImpl @Override public long create(long share, int ctp, int major, int minor) { long ctx = 0; - final MacOSXCGLDrawable drawable = (MacOSXCGLDrawable) MacOSXCGLContext.this.drawable; final NativeSurface surface = drawable.getNativeSurface(); final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration(); final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); + boolean allowIncompleteView = null != backingLayerHost; + if( !allowIncompleteView && surface instanceof ProxySurface ) { + allowIncompleteView = 0 != ( ProxySurface.INVISIBLE_WINDOW & ((ProxySurface)surface).getImplBitfield() ) ; + } final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor); if (pixelFormat == 0) { @@ -443,13 +450,12 @@ public abstract class MacOSXCGLContext extends GLContextImpl screenVSyncTimeout = 1000000f / sRefreshRate; if(DEBUG) { System.err.println("NS create OSX>=lion "+isLionOrLater); - System.err.println("NS create backendType: "+drawable.getOpenGLMode()); + System.err.println("NS create allowIncompleteView: "+allowIncompleteView); System.err.println("NS create backingLayerHost: "+backingLayerHost); System.err.println("NS create share: "+share); System.err.println("NS create chosenCaps: "+chosenCaps); System.err.println("NS create pixelFormat: "+toHexString(pixelFormat)); System.err.println("NS create drawable native-handle: "+toHexString(drawable.getHandle())); - System.err.println("NS create drawable NSView-handle: "+toHexString(drawable.getNSViewHandle())); System.err.println("NS create screen refresh-rate: "+sRefreshRate+" hz, "+screenVSyncTimeout+" micros"); // Thread.dumpStack(); } @@ -457,7 +463,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl int[] viewNotReady = new int[1]; // Try to allocate a context with this ctx = CGL.createContext(share, - drawable.getNSViewHandle(), null!=backingLayerHost, + drawable.getHandle(), allowIncompleteView, pixelFormat, chosenCaps.isBackgroundOpaque(), viewNotReady, 0); @@ -473,10 +479,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl CGL.setContextOpacity(ctx, 0); } - if(DEBUG) { - GLCapabilitiesImmutable caps0 = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(null, pixelFormat); - System.err.println("NS create pixelformat2GLCaps: "+caps0); - } GLCapabilitiesImmutable fixedCaps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(chosenCaps.getGLProfile(), pixelFormat); fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(fixedCaps, chosenCaps.isBackgroundOpaque()); config.setChosenCapabilities(fixedCaps); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index 257635b8c..841edb2b0 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -106,10 +106,6 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { protected void setRealizedImpl() { } - protected long getNSViewHandle() { - return GLBackendType.NSOPENGL == openGLMode ? getHandle() : 0; - } - protected void registerContext(MacOSXCGLContext ctx) { // NOTE: we need to keep track of the created contexts in order to // implement swapBuffers() because of how Mac OS X implements its diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index 4e9d18fed..9689d9f64 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -50,8 +50,8 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; @@ -62,15 +62,19 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import javax.media.opengl.GLProfile.ShutdownType; +import jogamp.nativewindow.macosx.OSXUtil; import jogamp.opengl.DesktopGLDynamicLookupHelper; +import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; +import jogamp.opengl.GLGraphicsConfigurationUtil; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; +import com.jogamp.opengl.GLExtensions; public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { private static DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper = null; @@ -214,44 +218,39 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { if (null == glp) { throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice); } - final GLCapabilities caps = new GLCapabilities(glp); - caps.setRedBits(5); caps.setGreenBits(5); caps.setBlueBits(5); caps.setAlphaBits(0); - caps.setDepthBits(5); - caps.setDoubleBuffered(false); - caps.setOnscreen(false); - caps.setPBuffer(true); - final MacOSXCGLDrawable drawable = (MacOSXCGLDrawable) createGLDrawable( createOffscreenSurfaceImpl(sharedDevice, caps, caps, null, 64, 64) ); - if(null!=drawable) { - drawable.setRealized(true); - final GLContext context = drawable.createContext(null); - if (null != context) { - try { - context.makeCurrent(); // could cause exception - madeCurrent = context.isCurrent(); - if(madeCurrent) { - GL gl = context.getGL(); - hasNPOTTextures = gl.isNPOTTextureAvailable(); - hasRECTTextures = gl.isExtensionAvailable("GL_EXT_texture_rectangle"); - hasAppleFloatPixels = gl.isExtensionAvailable("GL_APPLE_float_pixels"); - } - } catch (GLException gle) { - if (DEBUG) { - System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: makeCurrent catched exception:"); - gle.printStackTrace(); - } - } finally { - try { - context.destroy(); - } catch (GLException gle) { - if (DEBUG) { - System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: destroy catched exception:"); - gle.printStackTrace(); - } - } + final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, new GLCapabilities(glp), null, 64, 64)); + sharedDrawable.setRealized(true); + + final GLContextImpl sharedContext = (GLContextImpl) sharedDrawable.createContext(null); + if (null == sharedContext) { + throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable); + } + + try { + sharedContext.makeCurrent(); // could cause exception + madeCurrent = sharedContext.isCurrent(); + if(madeCurrent) { + GL gl = sharedContext.getGL(); + hasNPOTTextures = gl.isNPOTTextureAvailable(); + hasRECTTextures = gl.isExtensionAvailable(GLExtensions.EXT_texture_rectangle); + hasAppleFloatPixels = gl.isExtensionAvailable(GLExtensions.APPLE_float_pixels); + } + } catch (GLException gle) { + if (DEBUG) { + System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: makeCurrent catched exception:"); + gle.printStackTrace(); + } + } finally { + try { + sharedContext.destroy(); + } catch (GLException gle) { + if (DEBUG) { + System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: destroy catched exception:"); + gle.printStackTrace(); } } - drawable.setRealized(false); } + sharedDrawable.setRealized(false); } sr = new SharedResource(sharedDevice, madeCurrent, hasNPOTTextures, hasRECTTextures, hasAppleFloatPixels); synchronized(sharedMap) { @@ -332,18 +331,82 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device,GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) { - AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_MACOSX); - WrappedSurface ns = new WrappedSurface(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, true)); - ns.surfaceSizeChanged(width, height); - return ns; + protected ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + final MacOSXGraphicsDevice device; + if(createNewDevice) { + device = new MacOSXGraphicsDevice(deviceReq.getUnitID()); + } else { + device = (MacOSXGraphicsDevice)deviceReq; + } + final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); + final MacOSXCGLGraphicsConfiguration config = MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, true); + if(null == config) { + throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); + } + return new WrappedSurface(config, 0, width, height, lifecycleHook); } @Override - protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice device, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { - AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); - WrappedSurface ns = new WrappedSurface(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, true), windowHandle); - return ns; + public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { + final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); + } + private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { + long nsWindow = 0; + @Override + public final void create(ProxySurface s) { + if(0 == nsWindow && 0 == s.getSurfaceHandle()) { + nsWindow = OSXUtil.CreateNSWindow(0, 0, s.getWidth(), s.getHeight()); + if(0 == nsWindow) { + throw new GLException("Error NS window 0"); + } + long nsView = OSXUtil.GetNSView(nsWindow); + if(0 == nsView) { + throw new GLException("Error NS view 0"); + } + s.setSurfaceHandle(nsView); + s.setImplBitfield(ProxySurface.INVISIBLE_WINDOW); + if(DEBUG) { + System.err.println("MacOSXCGLDrawableFactory.dummySurfaceLifecycleHook.create: "+s); + } + } + } + @Override + public final void destroy(ProxySurface s) { + if(0 != nsWindow && 0 != s.getSurfaceHandle()) { + OSXUtil.DestroyNSWindow(nsWindow); + nsWindow = 0; + s.setSurfaceHandle(0); + if(DEBUG) { + System.err.println("MacOSXCGLDrawableFactory.dummySurfaceLifecycleHook.destroy: "+s); + } + } + } + @Override + public final int getWidth(ProxySurface s) { + return s.initialWidth; + } + @Override + public final int getHeight(ProxySurface s) { + return s.initialHeight; + } + + @Override + public String toString() { + return "MacOSXLSurfaceLifecycleHook[]"; + } + + }; + + @Override + protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { + final MacOSXGraphicsDevice device = new MacOSXGraphicsDevice(deviceReq.getUnitID()); + final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); + final MacOSXCGLGraphicsConfiguration config = MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, true); + return new WrappedSurface(config, windowHandle, 0, 0, upstream); } @Override diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java index 8393a688e..421e1ef96 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java @@ -154,7 +154,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration break; case CGL.NSOpenGLPFASamples: - ivalues[idx] = caps.getSampleBuffers() ? ivalues[idx] = caps.getNumSamples() : 0; + ivalues[idx] = caps.getNumSamples() ; break; default: @@ -233,7 +233,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration return fmt.get(0); } - static GLCapabilitiesImmutable CGLPixelFormat2GLCapabilities(long pixelFormat) { + static GLCapabilitiesImmutable CGLPixelFormat2GLCapabilities(long pixelFormat) { return PixelFormat2GLCapabilities(null, pixelFormat, false); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java index ad4c06af2..6be9e386d 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java @@ -114,8 +114,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { // set a fake marker stating a valid drawable currentDrawable = 1; } - WrappedSurface ns = new WrappedSurface(cfg); - ns.setSurfaceHandle(currentDrawable); + WrappedSurface ns = new WrappedSurface(cfg, currentDrawable, 64, 64, null); return new MacOSXExternalCGLContext(new Drawable(factory, ns), isNSContext, contextHandle); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 242cea068..b144c020d 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -42,7 +42,7 @@ package jogamp.opengl.macosx.cgl; import javax.media.nativewindow.DefaultGraphicsConfiguration; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GL2GL3; @@ -95,12 +95,6 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { return ctx; } - @Override - protected long getNSViewHandle() { - // pbuffer handle is NSOpenGLPixelBuffer - return 0; - } - @Override public long getHandle() { return pBuffer; @@ -115,7 +109,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { NativeSurface ns = getNativeSurface(); impl.destroy(pBuffer); this.pBuffer = 0; - ((SurfaceChangeable)ns).setSurfaceHandle(0); + ((MutableSurface)ns).setSurfaceHandle(0); } } @@ -174,7 +168,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { throw new GLException("pbuffer creation error: CGL.createPBuffer() failed"); } - ((SurfaceChangeable)ns).setSurfaceHandle(pBuffer); + ((MutableSurface)ns).setSurfaceHandle(pBuffer); } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java index 31f13297b..6bf8839af 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java @@ -113,7 +113,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { // create EGLImage from texture clientBuffer = null; // FIXME nioTmp.put(0, EGL.EGL_NONE); - image = eglExt.eglCreateImageKHR( eglDrawable.getDisplay(), eglCtx.getHandle(), + image = eglExt.eglCreateImageKHR( eglDrawable.getNativeSurface().getDisplayHandle(), eglCtx.getHandle(), EGLExt.EGL_GL_TEXTURE_2D_KHR, clientBuffer, nioTmp); if (0==image) { @@ -130,7 +130,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { // rendering the EGLImage texture before we tell OpenMAX to fill // it with a new frame. tmp[0] = EGL.EGL_NONE; - sync = eglExt.eglCreateSyncKHR(eglDrawable.getDisplay(), EGLExt.EGL_SYNC_FENCE_KHR, tmp, 0); + sync = eglExt.eglCreateSyncKHR(eglDrawable.getNativeSurface().getDisplayHandle(), EGLExt.EGL_SYNC_FENCE_KHR, tmp, 0); if (0==sync) { throw new RuntimeException("EGLSync creation failed: "+EGL.eglGetError()+", ctx "+eglCtx+", err "+toHexString(EGL.eglGetError())); } @@ -159,10 +159,10 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { final EGLTextureFrame eglTex = (EGLTextureFrame) imgTex; if(0!=eglTex.getImage()) { - eglExt.eglDestroyImageKHR(eglDrawable.getDisplay(), eglTex.getImage()); + eglExt.eglDestroyImageKHR(eglDrawable.getNativeSurface().getDisplayHandle(), eglTex.getImage()); } if(0!=eglTex.getSync()) { - eglExt.eglDestroySyncKHR(eglDrawable.getDisplay(), eglTex.getSync()); + eglExt.eglDestroySyncKHR(eglDrawable.getNativeSurface().getDisplayHandle(), eglTex.getSync()); } super.destroyTexImage(gl, imgTex); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java index 296d53ce3..cf6f43b1c 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java @@ -41,7 +41,7 @@ package jogamp.opengl.windows.wgl; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; @@ -139,7 +139,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable { hbitmap = 0; throw new GLException("Error creating device context for offscreen OpenGL context, werr "+werr); } - ((SurfaceChangeable)ns).setSurfaceHandle(hdc); + ((MutableSurface)ns).setSurfaceHandle(hdc); if(DEBUG) { System.err.println("WindowsBitmapWGLDrawable (2): "+ns); } @@ -164,7 +164,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable { GDI.DeleteDC(ns.getSurfaceHandle()); origbitmap = 0; hbitmap = 0; - ((SurfaceChangeable)ns).setSurfaceHandle(0); + ((MutableSurface)ns).setSurfaceHandle(0); } } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java deleted file mode 100644 index 05d6d9862..000000000 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package jogamp.opengl.windows.wgl; - -import javax.media.nativewindow.AbstractGraphicsScreen; -import javax.media.nativewindow.NativeSurface; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; - -import jogamp.nativewindow.windows.GDI; -import jogamp.nativewindow.windows.GDISurface; -import jogamp.nativewindow.windows.GDIUtil; - -public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { - private long hwnd; - private boolean handleHwndLifecycle; - - private WindowsDummyWGLDrawable(GLDrawableFactory factory, GDISurface ns, boolean handleHwndLifecycle) { - super(factory, ns, true); - this.handleHwndLifecycle = handleHwndLifecycle; - - if(NativeSurface.LOCK_SURFACE_NOT_READY >= ns.lockSurface()) { - throw new GLException("WindowsDummyWGLDrawable: surface not ready (lockSurface)"); - } - try { - WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration(); - config.updateGraphicsConfiguration(factory, ns, null); - if (DEBUG) { - System.err.println("WindowsDummyWGLDrawable: "+config); - } - } catch (Throwable t) { - setRealized(false); - throw new GLException(t); - } finally { - unlockSurface(); - } - } - - public static WindowsDummyWGLDrawable create(GLDrawableFactory factory, GLProfile glp, AbstractGraphicsScreen absScreen, - long windowHandle, int width, int height, boolean handleWindowLifecycle) { - if(0 == windowHandle) { - throw new GLException("Error windowHandle 0, werr: "+GDI.GetLastError()); - } - GLCapabilities caps = new GLCapabilities(glp); - WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(caps, absScreen); - GDISurface ns = new GDISurface(cfg, windowHandle); - ns.surfaceSizeChanged(width, height); - return new WindowsDummyWGLDrawable(factory, ns, handleWindowLifecycle); - } - - @Override - public GLContext createContext(GLContext shareWith) { - // FIXME: figure out how to hook back in the Java 2D / JOGL bridge - return new WindowsWGLContext(this, shareWith); - } - - @Override - protected void setRealizedImpl() { - super.setRealizedImpl(); - if(!realized) { - if (handleHwndLifecycle && hwnd != 0) { - GDI.ShowWindow(hwnd, GDI.SW_HIDE); - GDIUtil.DestroyDummyWindow(hwnd); - hwnd = 0; - } - } - } -} diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java index 86441c688..96c1187d3 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java @@ -55,7 +55,6 @@ import com.jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.windows.GDI; import jogamp.opengl.GLContextShareSet; - public class WindowsExternalWGLContext extends WindowsWGLContext { private GLContext lastContext; @@ -103,7 +102,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { System.err.println("WindowsExternalWGLContext valid hdc/pfd, retrieved cfg: " + cfg); } } - return new WindowsExternalWGLContext(new Drawable(factory, new WrappedSurface(cfg, hdc)), ctx, cfg); + return new WindowsExternalWGLContext(new Drawable(factory, new WrappedSurface(cfg, hdc, 64, 64, null)), ctx, cfg); } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java index 8f22aa60e..15bd005dc 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java @@ -50,6 +50,7 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import jogamp.nativewindow.windows.GDI; +import jogamp.nativewindow.windows.GDIUtil; import com.jogamp.nativewindow.WrappedSurface; @@ -69,9 +70,9 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { throw new GLException("Error: attempted to make an external GLContext without a valid pixelformat, werr " + GDI.GetLastError()); } - AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); - WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromExternal(factory, hdc, pfdID, glp, aScreen, true); - return new WindowsExternalWGLDrawable(factory, new WrappedSurface(cfg, hdc)); + final AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); + final WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromExternal(factory, hdc, pfdID, glp, aScreen, true); + return new WindowsExternalWGLDrawable(factory, new WrappedSurface(cfg, hdc, 64, 64, null)); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java index a11d6e78e..7dda6a1f1 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java @@ -42,6 +42,8 @@ package jogamp.opengl.windows.wgl; import javax.media.opengl.*; +import com.jogamp.opengl.GLExtensions; + import jogamp.opengl.GLContextImpl; public class WindowsPbufferWGLContext extends WindowsWGLContext { @@ -112,7 +114,7 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext { } else { hasRTT = true; - if (rect && !gl.isExtensionAvailable("GL_NV_texture_rectangle")) { + if (rect && !gl.isExtensionAvailable(GLExtensions.NV_texture_rectangle)) { System.err.println("WindowsPbufferWGLContext: WARNING: GL_NV_texture_rectangle extension not " + "supported; skipping requested render_to_texture_rectangle support for pbuffer"); rect = false; diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java index b00c796ec..175622343 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -42,7 +42,7 @@ package jogamp.opengl.windows.wgl; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -92,7 +92,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { if (wglExt.wglReleasePbufferDCARB(buffer, ns.getSurfaceHandle()) == 0) { throw new GLException("Error releasing pbuffer device context: error code " + GDI.GetLastError()); } - ((SurfaceChangeable)ns).setSurfaceHandle(0); + ((MutableSurface)ns).setSurfaceHandle(0); } if (!wglExt.wglDestroyPbufferARB(buffer)) { throw new GLException("Error destroying pbuffer: error code " + GDI.GetLastError()); @@ -121,7 +121,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { } try { long sharedHdc = sharedSurface.getSurfaceHandle(); - WGLExt wglExt = sharedResource.getContext().getWGLExt(); + WGLExt wglExt = ((WindowsWGLContext)sharedResource.getContext()).getWGLExt(); if (DEBUG) { System.out.println("Pbuffer config: " + config); @@ -131,7 +131,6 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { float[] fattributes = new float[1]; int[] floatModeTmp = new int[1]; int niattribs = 0; - int width, height; GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); GLProfile glProfile = chosenCaps.getGLProfile(); @@ -206,7 +205,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { iattributes[niattribs++] = WGLExt.WGL_MIPMAP_TEXTURE_ARB; iattributes[niattribs++] = GL.GL_FALSE; - iattributes[niattribs++] = WGLExt.WGL_PBUFFER_LARGEST_ARB; + iattributes[niattribs++] = WGLExt.WGL_PBUFFER_LARGEST_ARB; // exact iattributes[niattribs++] = GL.GL_FALSE; } @@ -235,7 +234,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { NativeSurface ns = getNativeSurface(); // Set up instance variables buffer = tmpBuffer; - ((SurfaceChangeable)ns).setSurfaceHandle(tmpHdc); + ((MutableSurface)ns).setSurfaceHandle(tmpHdc); cachedWGLExt = wglExt; // Re-query chosen pixel format @@ -249,14 +248,6 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { } config.setCapsPFD(newCaps); } - - // Determine the actual width and height we were able to create. - int[] tmp = new int[1]; - wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_WIDTH_ARB, tmp, 0 ); - width = tmp[0]; - wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_HEIGHT_ARB, tmp, 0 ); - height = tmp[0]; - ((SurfaceChangeable)ns).surfaceSizeChanged(width, height); } finally { sharedSurface.unlockSurface(); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index f143c158b..8825bad0a 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -53,6 +53,8 @@ import javax.media.opengl.GLCapabilitiesImmutable; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; +import com.jogamp.opengl.GLExtensions; + import jogamp.nativewindow.windows.GDI; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableImpl; @@ -77,8 +79,8 @@ public class WindowsWGLContext extends GLContextImpl { functionNameMap.put("glFreeMemoryNV", "wglFreeMemoryNV"); extensionNameMap = new HashMap(); - extensionNameMap.put("GL_ARB_pbuffer", "WGL_ARB_pbuffer"); - extensionNameMap.put("GL_ARB_pixel_format", "WGL_ARB_pixel_format"); + extensionNameMap.put(GLExtensions.ARB_pbuffer, WindowsWGLDrawableFactory.WGL_ARB_pbuffer); + extensionNameMap.put(GLExtensions.ARB_pixel_format, WindowsWGLDrawableFactory.WGL_ARB_pixel_format); } // FIXME: figure out how to hook back in the Java 2D / JOGL bridge diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 176d27a71..09e97ff79 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -51,9 +51,10 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -67,9 +68,11 @@ import jogamp.nativewindow.windows.GDISurface; import jogamp.nativewindow.windows.GDIUtil; import jogamp.nativewindow.windows.RegisteredClassFactory; import jogamp.opengl.DesktopGLDynamicLookupHelper; +import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; +import jogamp.opengl.GLGraphicsConfigurationUtil; import jogamp.opengl.SharedResourceRunner; import com.jogamp.common.JogampRuntimeException; @@ -79,6 +82,7 @@ import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.VersionNumber; import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; +import com.jogamp.opengl.GLExtensions; public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { private static DesktopGLDynamicLookupHelper windowsWGLDynamicLookupHelper = null; @@ -203,8 +207,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { static class SharedResource implements SharedResourceRunner.Resource { private WindowsGraphicsDevice device; private AbstractGraphicsScreen screen; - private WindowsDummyWGLDrawable drawable; - private WindowsWGLContext context; + private GLDrawableImpl drawable; + private GLContextImpl context; private boolean hasARBPixelFormat; private boolean hasARBMultisample; private boolean hasARBPBuffer; @@ -214,7 +218,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { private boolean isVendorNVIDIA; private boolean needsCurrenContext4ARBPFDQueries; - SharedResource(WindowsGraphicsDevice dev, AbstractGraphicsScreen scrn, WindowsDummyWGLDrawable draw, WindowsWGLContext ctx, + SharedResource(WindowsGraphicsDevice dev, AbstractGraphicsScreen scrn, GLDrawableImpl draw, GLContextImpl ctx, boolean arbPixelFormat, boolean arbMultisample, boolean arbPBuffer, boolean arbReadDrawable, String glVendor) { device = dev; screen = scrn; @@ -250,9 +254,9 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { @Override final public AbstractGraphicsScreen getScreen() { return screen; } @Override - final public WindowsWGLDrawable getDrawable() { return drawable; } + final public GLDrawableImpl getDrawable() { return drawable; } @Override - final public WindowsWGLContext getContext() { return context; } + final public GLContextImpl getContext() { return context; } final boolean hasARBPixelFormat() { return hasARBPixelFormat; } final boolean hasARBMultisample() { return hasARBMultisample; } @@ -302,21 +306,18 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { @Override public SharedResourceRunner.Resource createSharedResource(String connection) { - WindowsGraphicsDevice sharedDevice = new WindowsGraphicsDevice(connection, AbstractGraphicsDevice.DEFAULT_UNIT); + final WindowsGraphicsDevice sharedDevice = new WindowsGraphicsDevice(connection, AbstractGraphicsDevice.DEFAULT_UNIT); sharedDevice.lock(); try { - AbstractGraphicsScreen absScreen = new DefaultGraphicsScreen(sharedDevice, 0); - GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP, false); + final AbstractGraphicsScreen absScreen = new DefaultGraphicsScreen(sharedDevice, 0); + final GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP, false); if (null == glp) { throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice); } - final int f_dim = 64; - long hwnd = GDIUtil.CreateDummyWindow(0, 0, f_dim, f_dim); - WindowsDummyWGLDrawable sharedDrawable = WindowsDummyWGLDrawable.create(WindowsWGLDrawableFactory.this, glp, absScreen, hwnd, f_dim, f_dim, true); - if (null == sharedDrawable) { - throw new GLException("Couldn't create shared drawable for screen: "+absScreen+", "+glp); - } - WindowsWGLContext sharedContext = (WindowsWGLContext) sharedDrawable.createContext(null); + final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, new GLCapabilities(glp), null, 64, 64)); + sharedDrawable.setRealized(true); + + final GLContextImpl sharedContext = (GLContextImpl) sharedDrawable.createContext(null); if (null == sharedContext) { throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable); } @@ -329,7 +330,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { try { hasARBPixelFormat = sharedContext.isExtensionAvailable(WGL_ARB_pixel_format); hasARBMultisample = sharedContext.isExtensionAvailable(WGL_ARB_multisample); - hasARBPBuffer = sharedContext.isExtensionAvailable(GL_ARB_pbuffer); + hasARBPBuffer = sharedContext.isExtensionAvailable(GLExtensions.ARB_pbuffer); hasARBReadDrawableAvailable = sharedContext.isExtensionAvailable(WGL_ARB_make_current_read) && sharedContext.isFunctionAvailable(wglMakeContextCurrent); vendor = sharedContext.getGL().glGetString(GL.GL_VENDOR); @@ -401,7 +402,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { return false; } - final static String GL_ARB_pbuffer = "GL_ARB_pbuffer"; + final static String WGL_ARB_pbuffer = "WGL_ARB_pbuffer"; final static String WGL_ARB_pixel_format = "WGL_ARB_pixel_format"; final static String WGL_ARB_multisample = "WGL_ARB_multisample"; final static String WGL_NV_float_buffer = "WGL_NV_float_buffer"; @@ -534,22 +535,89 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected final NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) { - AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); - WrappedSurface ns = new WrappedSurface(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( - capsChosen, capsRequested, chooser, screen) ); - ns.surfaceSizeChanged(width, height); - return ns; + protected final ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + final WindowsGraphicsDevice device; + if(createNewDevice) { + device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); + } else { + device = (WindowsGraphicsDevice)deviceReq; + } + final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); + final WindowsWGLGraphicsConfiguration config = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen); + if(null == config) { + throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); + } + return new WrappedSurface(config, 0, width, height, lifecycleHook); } @Override - protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice adevice, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { - // FIXME device/windowHandle -> screen ?! - WindowsGraphicsDevice device = (WindowsGraphicsDevice) adevice; - AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); - WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); - GDISurface ns = new GDISurface(cfg, windowHandle); - return ns; + public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { + final WindowsGraphicsDevice device; + if(createNewDevice) { + device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); + } else { + device = (WindowsGraphicsDevice)deviceReq; + } + final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); + final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); + final WindowsWGLGraphicsConfiguration config = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(chosenCaps, requestedCaps, chooser, screen); + if(null == config) { + throw new GLException("Choosing GraphicsConfiguration failed w/ "+requestedCaps+" on "+screen); + } + return new GDISurface(config, 0, width, height, dummySurfaceLifecycleHook); + } + private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { + @Override + public final void create(ProxySurface s) { + final GDISurface ms = (GDISurface)s; + if(0 == ms.getWindowHandle()) { + final long windowHandle = GDIUtil.CreateDummyWindow(0, 0, s.getWidth(), s.getHeight()); + if(0 == windowHandle) { + throw new GLException("Error windowHandle 0, werr: "+GDI.GetLastError()); + } + ms.setWindowHandle(windowHandle); + if(DEBUG) { + System.err.println("WindowsWGLDrawableFactory.dummySurfaceLifecycleHook.create: "+ms); + } + } + } + @Override + public final void destroy(ProxySurface s) { + final GDISurface ms = (GDISurface)s; + if(0 != ms.getWindowHandle()) { + GDI.ShowWindow(ms.getWindowHandle(), GDI.SW_HIDE); + GDIUtil.DestroyDummyWindow(ms.getWindowHandle()); + ms.setWindowHandle(0); + if(DEBUG) { + System.err.println("WindowsWGLDrawableFactory.dummySurfaceLifecycleHook.destroy: "+ms); + } + } + } + @Override + public final int getWidth(ProxySurface s) { + return s.initialWidth; + } + @Override + public final int getHeight(ProxySurface s) { + return s.initialHeight; + } + + @Override + public String toString() { + return "GDISurfaceLifecycleHook[]"; + } + }; + + + @Override + protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { + final WindowsGraphicsDevice device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); + final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); + final WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); + return new GDISurface(cfg, windowHandle, 0, 0, upstream); } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 408d8b074..209589b29 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -48,11 +48,13 @@ import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; import com.jogamp.nativewindow.MutableGraphicsConfiguration; +import com.jogamp.opengl.GLExtensions; import jogamp.nativewindow.windows.DWM_BLURBEHIND; import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.MARGINS; import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR; +import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLGraphicsConfigurationUtil; public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { @@ -160,7 +162,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } if (!WGLUtil.SetPixelFormat(hdc, caps.getPFDID(), caps.getPFD())) { - throw new GLException("Unable to set pixel format " + caps + + throw new GLException("Unable to set pixel format " + caps.getPFDID() + " of " + caps + " for device context " + toHexString(hdc) + ": error code " + GDI.GetLastError()); } @@ -250,7 +252,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } if(sharedResource.hasARBPBuffer()) { - WindowsWGLContext sharedCtx = sharedResource.getContext(); + GLContextImpl sharedCtx = sharedResource.getContext(); if(null != sharedCtx && sharedCtx.isExtensionAvailable(WindowsWGLDrawableFactory.WGL_NV_float_buffer)) { // pbo float buffer iattributes[niattribs++] = WGLExt.WGL_FLOAT_COMPONENTS_NV; // nvidia @@ -313,12 +315,12 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio int niattribs = fillAttribsForGeneralWGLARBQuery(sharedResource, iattributes); - if (!sharedResource.getContext().getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdID, 0, niattribs, iattributes, 0, iresults, 0)) { + if (!((WindowsWGLContext)sharedResource.getContext()).getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdID, 0, niattribs, iattributes, 0, iresults, 0)) { throw new GLException("wglARBPFID2GLCapabilities: Error getting pixel format attributes for pixel format " + pfdID + " of device context " + toHexString(hdc) + ", werr " + GDI.GetLastError()); } List bucket = new ArrayList(1); - final int winattrbits = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer); + final int winattrbits = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); if(AttribList2GLCapabilities(bucket, glp, hdc, pfdID, iattributes, niattribs, iresults, winattrbits)) { return (WGLGLCapabilities) bucket.get(0); } @@ -342,7 +344,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio int[] pformatsTmp = new int[WindowsWGLGraphicsConfiguration.MAX_PFORMATS]; int[] numFormatsTmp = new int[1]; - if ( !sharedResource.getContext().getWGLExt().wglChoosePixelFormatARB(hdc, iattributes, 0, + if ( !((WindowsWGLContext)sharedResource.getContext()).getWGLExt().wglChoosePixelFormatARB(hdc, iattributes, 0, fattributes, 0, WindowsWGLGraphicsConfiguration.MAX_PFORMATS, pformatsTmp, 0, numFormatsTmp, 0)) @@ -374,7 +376,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio static List wglARBPFIDs2GLCapabilities(WindowsWGLDrawableFactory.SharedResource sharedResource, long hdc, int[] pfdIDs, GLProfile glp, boolean onscreen, boolean usePBuffer) { - final int winattrbits = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer); + final int winattrbits = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); return wglARBPFIDs2GLCapabilitiesImpl(sharedResource, hdc, pfdIDs, glp, winattrbits); } @@ -398,7 +400,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio for(int i = 0; i= 1 && - sharedResource.getContext().getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdIDs[i], 0, niattribs, iattributes, 0, iresults, 0) ) { + ((WindowsWGLContext)sharedResource.getContext()).getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdIDs[i], 0, niattribs, iattributes, 0, iresults, 0) ) { AttribList2GLCapabilities(bucket, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, winattrbits); } else if (DEBUG) { System.err.println("wglARBPFIDs2GLCapabilities: Cannot get pixel format attributes for pixel format " + @@ -507,9 +509,9 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio throw new GLException("Render-to-texture-rectangle requires render-to-texture to be specified"); } - WindowsWGLContext sharedCtx = sharedResource.getContext(); + GLContextImpl sharedCtx = sharedResource.getContext(); if (rect) { - if (!sharedCtx.isExtensionAvailable("GL_NV_texture_rectangle")) { + if (!sharedCtx.isExtensionAvailable(GLExtensions.NV_texture_rectangle)) { throw new GLException("Render-to-texture-rectangle requires GL_NV_texture_rectangle extension"); } } @@ -658,7 +660,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } static WGLGLCapabilities PFD2GLCapabilities(GLProfile glp, long hdc, int pfdID, boolean onscreen) { - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, false); + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, false, false); List capsBucket = new ArrayList(1); if( PFD2GLCapabilities(capsBucket, glp, hdc, pfdID, winattrmask) ) { return (WGLGLCapabilities) capsBucket.get(0); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index 850b64aa8..943c7fec4 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -52,6 +52,7 @@ import javax.media.opengl.GLProfile; import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR; +import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLGraphicsConfigurationFactory; import jogamp.opengl.GLGraphicsConfigurationUtil; @@ -99,10 +100,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat if(null==absScreen) { absScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); } - AbstractGraphicsDevice absDevice = absScreen.getDevice(); - + final AbstractGraphicsDevice absDevice = absScreen.getDevice(); + final GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory(); capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( - capsChosen, GLDrawableFactory.getDesktopFactory().canCreateGLPbuffer(absDevice) ); + capsChosen, GLContext.isFBOAvailable(absDevice, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(absDevice) ); return new WindowsWGLGraphicsConfiguration( absScreen, capsChosen, capsReq, (GLCapabilitiesChooser)chooser ); } @@ -112,9 +113,9 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat if(null == sharedResource) { throw new GLException("Shared resource for device n/a: "+device); } - WindowsWGLDrawable sharedDrawable = sharedResource.getDrawable(); + GLDrawableImpl sharedDrawable = sharedResource.getDrawable(); GLCapabilitiesImmutable capsChosen = sharedDrawable.getChosenGLCapabilities(); - WindowsWGLContext sharedContext = sharedResource.getContext(); + GLContext sharedContext = sharedResource.getContext(); List availableCaps = null; if ( sharedResource.needsCurrentContext4ARBPFDQueries() ) { @@ -150,7 +151,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } static List getAvailableGLCapabilitiesARB(long hdc, WindowsWGLDrawableFactory.SharedResource sharedResource, GLProfile glProfile) { - int[] pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs(sharedResource.getContext(), hdc); + int[] pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs((WindowsWGLContext)sharedResource.getContext(), hdc); return WindowsWGLGraphicsConfiguration.wglARBPFIDs2AllGLCapabilities(sharedResource, hdc, pformats, glProfile); } @@ -265,7 +266,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } AbstractGraphicsDevice device = config.getScreen().getDevice(); WindowsWGLDrawableFactory.SharedResource sharedResource = ((WindowsWGLDrawableFactory)factory).getOrCreateSharedResource(device); - WindowsWGLContext sharedContext = null; + GLContext sharedContext = null; if (null != sharedResource && sharedResource.needsCurrentContext4ARBPFDQueries()) { sharedContext = sharedResource.getContext(); if(GLContext.CONTEXT_NOT_CURRENT == sharedContext.makeCurrent()) { @@ -355,7 +356,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat System.err.println("updateGraphicsConfigurationARB: wglChoosePixelFormatARB failed with: "+capsChosen); } // 2nd choice: get all GLCapabilities available, no preferred recommendedIndex available - pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs(sharedResource.getContext(), hdc); + pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs((WindowsWGLContext)sharedResource.getContext(), hdc); if (DEBUG) { final int len = ( null != pformats ) ? pformats.length : 0; System.err.println("updateGraphicsConfigurationARB: NumFormats (wglAllARBPFIDs) " + len); @@ -451,7 +452,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat if(null == pformats) { pformats = WindowsWGLGraphicsConfiguration.wglAllGDIPFIDs(hdc); } - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, false); + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, false, false); for (int i = 0; i < pformats.length; i++) { WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(availableCaps, glProfile, hdc, pformats[i], winattrmask); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java deleted file mode 100644 index 8914e2db9..000000000 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.opengl.x11.glx; - -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLProfile; - -import jogamp.nativewindow.x11.X11Lib; - -import com.jogamp.nativewindow.WrappedSurface; -import com.jogamp.nativewindow.x11.X11GraphicsDevice; -import com.jogamp.nativewindow.x11.X11GraphicsScreen; - -public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable { - private static final int f_dim = 64; - private long dummyWindow = 0; - - /** - * Due to the ATI Bug https://bugzilla.mozilla.org/show_bug.cgi?id=486277, - * we cannot switch the Display as we please, - * hence we reuse the target's screen configuration. - */ - public X11DummyGLXDrawable(X11GraphicsScreen screen, GLDrawableFactory factory, GLCapabilitiesImmutable caps) { - super(factory, - new WrappedSurface(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( - caps, caps, null, screen))); - this.realized = true; - - WrappedSurface ns = (WrappedSurface) getNativeSurface(); - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)ns.getGraphicsConfiguration(); - - X11GraphicsDevice device = (X11GraphicsDevice) screen.getDevice(); - long dpy = device.getHandle(); - int scrn = screen.getIndex(); - int visualID = config.getXVisualID(); - - dummyWindow = X11Lib.CreateDummyWindow(dpy, scrn, visualID, f_dim, f_dim); - ns.setSurfaceHandle( dummyWindow ); - ns.surfaceSizeChanged(f_dim, f_dim); - - updateHandle(); - } - - public static X11DummyGLXDrawable create(X11GraphicsScreen screen, GLDrawableFactory factory, GLProfile glp) { - GLCapabilities caps = new GLCapabilities(glp); - return new X11DummyGLXDrawable(screen, factory, caps); - } - - public void setSize(int width, int height) { - } - - @Override - public int getWidth() { - return 1; - } - - @Override - public int getHeight() { - return 1; - } - - - @Override - protected void setRealizedImpl() { - super.setRealizedImpl(); - if(!realized) { - if(0!=dummyWindow) { - destroyHandle(); - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration(); - X11Lib.DestroyDummyWindow(config.getScreen().getDevice().getHandle(), dummyWindow); - } - } - } -} diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index 53776386c..b847363e0 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -76,8 +76,15 @@ public class X11ExternalGLXContext extends X11GLXContext { long drawable = GLX.glXGetCurrentDrawable(); if (drawable == 0) { throw new GLException("Error: attempted to make an external GLDrawable without a drawable/context current"); - } + } int[] val = new int[1]; + + int w, h; + GLX.glXQueryDrawable(display, drawable, GLX.GLX_WIDTH, val, 0); + w=val[0]; + GLX.glXQueryDrawable(display, drawable, GLX.GLX_HEIGHT, val, 0); + h=val[0]; + GLX.glXQueryContext(display, ctx, GLX.GLX_SCREEN, val, 0); X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0], false); @@ -97,8 +104,7 @@ public class X11ExternalGLXContext extends X11GLXContext { cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]); } - WrappedSurface ns = new WrappedSurface(cfg); - ns.setSurfaceHandle(drawable); + final WrappedSurface ns = new WrappedSurface(cfg, drawable, w, h, null); return new X11ExternalGLXContext(new Drawable(factory, ns), ctx); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java index 3fabe7a13..8652e2d4a 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java @@ -87,10 +87,7 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { System.err.println("X11ExternalGLXDrawable: WARNING: forcing GLX_RGBA_TYPE for newly created contexts (current 0x"+Integer.toHexString(val[0])+")"); } } - WrappedSurface ns = new WrappedSurface(cfg); - ns.setSurfaceHandle(drawable); - ns.surfaceSizeChanged(w, h); - return new X11ExternalGLXDrawable(factory, ns); + return new X11ExternalGLXDrawable(factory, new WrappedSurface(cfg, drawable, w, h, null)); } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index 0afadc677..e6b74a769 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -61,6 +61,7 @@ import jogamp.opengl.GLDrawableImpl; import com.jogamp.common.nio.Buffers; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; +import com.jogamp.opengl.GLExtensions; public abstract class X11GLXContext extends GLContextImpl { private static final Map functionNameMap; @@ -83,8 +84,8 @@ public abstract class X11GLXContext extends GLContextImpl { functionNameMap.put("glFreeMemoryNV", "glXFreeMemoryNV"); extensionNameMap = new HashMap(); - extensionNameMap.put("GL_ARB_pbuffer", "GLX_SGIX_pbuffer"); - extensionNameMap.put("GL_ARB_pixel_format", "GLX_SGIX_pbuffer"); // good enough + extensionNameMap.put(GLExtensions.ARB_pbuffer, X11GLXDrawableFactory.GLX_SGIX_pbuffer); + extensionNameMap.put(GLExtensions.ARB_pixel_format, X11GLXDrawableFactory.GLX_SGIX_pbuffer); // good enough } X11GLXContext(GLDrawableImpl drawable, @@ -508,8 +509,8 @@ public abstract class X11GLXContext extends GLContextImpl { @Override public boolean isExtensionAvailable(String glExtensionName) { - if (glExtensionName.equals("GL_ARB_pbuffer") || - glExtensionName.equals("GL_ARB_pixel_format")) { + if (glExtensionName.equals(GLExtensions.ARB_pbuffer) || + glExtensionName.equals(GLExtensions.ARB_pixel_format)) { return getGLDrawable().getFactory().canCreateGLPbuffer( drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice() ); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 9a563bdb8..8ffbf3951 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -49,6 +49,8 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -64,6 +66,7 @@ import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; +import jogamp.opengl.GLGraphicsConfigurationUtil; import jogamp.opengl.SharedResourceRunner; import com.jogamp.common.util.VersionNumber; @@ -79,6 +82,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { public static final VersionNumber versionOneThree = new VersionNumber(1, 3, 0); public static final VersionNumber versionOneFour = new VersionNumber(1, 4, 0); + static final String GLX_SGIX_pbuffer = "GLX_SGIX_pbuffer"; + private static DesktopGLDynamicLookupHelper x11GLXDynamicLookupHelper = null; public X11GLXDrawableFactory() { @@ -153,8 +158,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { static class SharedResource implements SharedResourceRunner.Resource { X11GraphicsDevice device; X11GraphicsScreen screen; - X11DummyGLXDrawable drawable; - X11GLXContext context; + GLDrawableImpl drawable; + GLContextImpl context; String glXServerVendorName; boolean isGLXServerVendorATI; boolean isGLXServerVendorNVIDIA; @@ -164,7 +169,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { boolean glXMultisampleAvailable; SharedResource(X11GraphicsDevice dev, X11GraphicsScreen scrn, - X11DummyGLXDrawable draw, X11GLXContext ctx, + GLDrawableImpl draw, GLContextImpl ctx, VersionNumber glXServerVer, String glXServerVendor, boolean glXServerMultisampleAvail) { device = dev; screen = scrn; @@ -224,13 +229,15 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { @Override public SharedResourceRunner.Resource createSharedResource(String connection) { - X11GraphicsDevice sharedDevice = + final X11GraphicsDevice sharedDevice = new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, - true); // own non-shared display connection, no locking + true); // own non-shared display connection, w/ locking // new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, - // NativeWindowFactory.getNullToolkitLock(), true); // own non-shared display connection, no locking + // NativeWindowFactory.getNullToolkitLock(), true); // own non-shared display connection, w/o locking sharedDevice.lock(); try { + final X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, 0); + if(!GLXUtil.isGLXAvailableOnServer(sharedDevice)) { throw new GLException("GLX not available on device/server: "+sharedDevice); } @@ -242,20 +249,20 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { X11Util.setMarkAllDisplaysUnclosable(true); X11Util.markDisplayUncloseable(sharedDevice.getHandle()); } - X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, 0); - - GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP, false); + + final GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP, false); if (null == glp) { throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice); } - X11DummyGLXDrawable sharedDrawable = X11DummyGLXDrawable.create(sharedScreen, X11GLXDrawableFactory.this, glp); - if (null == sharedDrawable) { - throw new GLException("Couldn't create shared drawable for screen: "+sharedScreen+", "+glp); - } - X11GLXContext sharedContext = (X11GLXContext) sharedDrawable.createContext(null); + + final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, new GLCapabilities(glp), null, 64, 64)); + sharedDrawable.setRealized(true); + + final GLContextImpl sharedContext = (GLContextImpl) sharedDrawable.createContext(null); if (null == sharedContext) { throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable); } + boolean madeCurrent = false; sharedContext.makeCurrent(); try { @@ -298,7 +305,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if (null != sr.context) { // may cause JVM SIGSEGV: - sr.context.destroy(); + sr.context.destroy(); // will also pull the dummy MutuableSurface sr.context = null; } @@ -394,7 +401,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if (target == null) { throw new IllegalArgumentException("Null target"); } - return new X11OnscreenGLXDrawable(this, target); + return new X11OnscreenGLXDrawable(this, target, false); } @Override @@ -495,40 +502,88 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected final NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice deviceReq, - GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, - int width, int height) { - if(null == deviceReq) { - throw new InternalError("deviceReq is null"); - } - final SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(deviceReq); - if(null==sr) { - throw new InternalError("No SharedResource for: "+deviceReq); + protected final ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable capsChosen, + GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + final X11GraphicsDevice device; + if(createNewDevice) { + // Null X11 locking, due to private non-shared Display handle + device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), NativeWindowFactory.getNullToolkitLock(), true); + } else { + device = (X11GraphicsDevice)deviceReq; } - final X11GraphicsScreen sharedScreen = (X11GraphicsScreen) sr.getScreen(); - final AbstractGraphicsDevice sharedDevice = sharedScreen.getDevice(); // should be same .. - - // create screen/device pair - Null X11 locking, due to private non-shared Display handle - final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(sharedDevice.getConnection()), AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock(), true); - final X11GraphicsScreen screen = new X11GraphicsScreen(device, sharedScreen.getIndex()); - - WrappedSurface ns = new WrappedSurface( - X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen) ); - if(ns != null) { - ns.surfaceSizeChanged(width, height); + final X11GraphicsScreen screen = new X11GraphicsScreen(device, 0); + final X11GLXGraphicsConfiguration config = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen); + if(null == config) { + throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return ns; + return new WrappedSurface( config, 0, width, height, lifecycleHook); } @Override - protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice adevice, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { - // FIXME device/windowHandle -> screen ?! - X11GraphicsDevice device = (X11GraphicsDevice) adevice; - X11GraphicsScreen screen = new X11GraphicsScreen(device, 0); - X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); - WrappedSurface ns = new WrappedSurface(cfg, windowHandle); - return ns; + public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { + final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); + } + private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { + @Override + public final void create(ProxySurface s) { + if( 0 == s.getSurfaceHandle() ) { + final X11GLXGraphicsConfiguration cfg = (X11GLXGraphicsConfiguration) s.getGraphicsConfiguration(); + final X11GraphicsScreen screen = (X11GraphicsScreen) cfg.getScreen(); + final X11GraphicsDevice device = (X11GraphicsDevice) screen.getDevice(); + if(0 == device.getHandle()) { + device.open(); + s.setImplBitfield(ProxySurface.OWN_DEVICE); + } + final long windowHandle = X11Lib.CreateDummyWindow(device.getHandle(), screen.getIndex(), cfg.getXVisualID(), s.getWidth(), s.getHeight()); + if(0 == windowHandle) { + throw new GLException("Creating dummy window failed w/ "+cfg+", "+s.getWidth()+"x"+s.getHeight()); + } + s.setSurfaceHandle(windowHandle); + if(DEBUG) { + System.err.println("X11GLXDrawableFactory.dummySurfaceLifecycleHook.create: "+s); + } + } + } + @Override + public final void destroy(ProxySurface s) { + if(0 != s.getSurfaceHandle()) { + final X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) s.getGraphicsConfiguration(); + final X11GraphicsDevice device = (X11GraphicsDevice) config.getScreen().getDevice(); + X11Lib.DestroyDummyWindow(device.getHandle(), s.getSurfaceHandle()); + s.setSurfaceHandle(0); + if( 0 != ( ProxySurface.OWN_DEVICE & s.getImplBitfield() ) ) { + device.close(); + } + if(DEBUG) { + System.err.println("X11GLXDrawableFactory.dummySurfaceLifecycleHook.destroy: "+s); + } + } + } + @Override + public final int getWidth(ProxySurface s) { + return s.initialWidth; + } + @Override + public final int getHeight(ProxySurface s) { + return s.initialHeight; + } + @Override + public String toString() { + return "X11SurfaceLifecycleHook[]"; + } + }; + + + @Override + protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { + final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), NativeWindowFactory.getNullToolkitLock(), true); + final X11GraphicsScreen screen = new X11GraphicsScreen(device, screenIdx); + final X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); + return new WrappedSurface(cfg, windowHandle, 0, 0, upstream); } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java index b54b5150c..b5b80e0b3 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java @@ -36,12 +36,14 @@ package jogamp.opengl.x11.glx; import java.util.ArrayList; import java.util.List; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -67,7 +69,8 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem } static X11GLXGraphicsConfiguration create(GLProfile glp, X11GraphicsScreen x11Screen, int fbcfgID) { - final long display = x11Screen.getDevice().getHandle(); + final AbstractGraphicsDevice device = x11Screen.getDevice(); + final long display = device.getHandle(); if(0==display) { throw new GLException("Display null of "+x11Screen); } @@ -80,7 +83,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem glp = GLProfile.getDefault(x11Screen.getDevice()); } final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - final X11GLCapabilities caps = GLXFBConfig2GLCapabilities(glp, display, fbcfg, true, true, true, factory.isGLXMultisampleAvailable(x11Screen.getDevice())); + final X11GLCapabilities caps = GLXFBConfig2GLCapabilities(glp, device, fbcfg, true, true, true, factory.isGLXMultisampleAvailable(device)); if(null==caps) { throw new GLException("GLCapabilities null of "+toHexString(fbcfg)); } @@ -233,11 +236,11 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem return true; } - static int FBCfgDrawableTypeBits(final long display, final long fbcfg) { + static int FBCfgDrawableTypeBits(final AbstractGraphicsDevice device, GLProfile glp, final long fbcfg) { int val = 0; int[] tmp = new int[1]; - int fbtype = glXGetFBConfig(display, fbcfg, GLX.GLX_DRAWABLE_TYPE, tmp, 0); + int fbtype = glXGetFBConfig(device.getHandle(), fbcfg, GLX.GLX_DRAWABLE_TYPE, tmp, 0); if ( 0 != ( fbtype & GLX.GLX_WINDOW_BIT ) ) { val |= GLGraphicsConfigurationUtil.WINDOW_BIT; @@ -248,17 +251,20 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem if ( 0 != ( fbtype & GLX.GLX_PBUFFER_BIT ) ) { val |= GLGraphicsConfigurationUtil.PBUFFER_BIT; } + if ( GLContext.isFBOAvailable(device, glp) ) { + val |= GLGraphicsConfigurationUtil.FBO_BIT; + } return val; } - static X11GLCapabilities GLXFBConfig2GLCapabilities(GLProfile glp, long display, long fbcfg, + static X11GLCapabilities GLXFBConfig2GLCapabilities(GLProfile glp, AbstractGraphicsDevice device, long fbcfg, boolean relaxed, boolean onscreen, boolean usePBuffer, boolean isMultisampleAvailable) { ArrayList bucket = new ArrayList(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer); - if( GLXFBConfig2GLCapabilities(bucket, glp, display, fbcfg, winattrmask, isMultisampleAvailable) ) { + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); + if( GLXFBConfig2GLCapabilities(bucket, glp, device, fbcfg, winattrmask, isMultisampleAvailable) ) { return (X11GLCapabilities) bucket.get(0); - } else if ( relaxed && GLXFBConfig2GLCapabilities(bucket, glp, display, fbcfg, GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable) ) { + } else if ( relaxed && GLXFBConfig2GLCapabilities(bucket, glp, device, fbcfg, GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable) ) { return (X11GLCapabilities) bucket.get(0); } return null; @@ -273,11 +279,12 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem } static boolean GLXFBConfig2GLCapabilities(List capsBucket, - GLProfile glp, long display, long fbcfg, + GLProfile glp, AbstractGraphicsDevice device, long fbcfg, int winattrmask, boolean isMultisampleAvailable) { - final int allDrawableTypeBits = FBCfgDrawableTypeBits(display, fbcfg); + final int allDrawableTypeBits = FBCfgDrawableTypeBits(device, glp, fbcfg); int drawableTypeBits = winattrmask & allDrawableTypeBits; - + + final long display = device.getHandle(); int fbcfgid = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfg); XVisualInfo visualInfo = GLX.glXGetVisualFromFBConfig(display, fbcfg); if(null == visualInfo) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java index 8377d2453..331401c06 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -44,6 +44,7 @@ import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -161,7 +162,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF return null; } for (int i = 0; i < fbcfgsL.limit(); i++) { - if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, display, fbcfgsL.get(i), GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable) ) { + if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, absDevice, fbcfgsL.get(i), GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable) ) { if(DEBUG) { System.err.println("X11GLXGraphicsConfiguration.getAvailableGLCapabilitiesFBConfig: FBConfig invalid (2): ("+x11Screen+"): fbcfg: "+toHexString(fbcfgsL.get(i))); } @@ -209,7 +210,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF X11GraphicsDevice x11Device = (X11GraphicsDevice) x11Screen.getDevice(); X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, factory.canCreateGLPbuffer(x11Device) ); + capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(x11Device, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(x11Device) ); boolean usePBuffer = capsChosen.isPBuffer(); X11GLXGraphicsConfiguration res = null; @@ -245,7 +246,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - final X11GLCapabilities caps = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glp, display, fbcfg, true, true, true, factory.isGLXMultisampleAvailable(absDevice)); + final X11GLCapabilities caps = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glp, absDevice, fbcfg, true, true, true, factory.isGLXMultisampleAvailable(absDevice)); return new X11GLXGraphicsConfiguration(x11Screen, caps, caps, new DefaultGLCapabilitiesChooser()); } @@ -258,6 +259,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF GLProfile glProfile = capsChosen.getGLProfile(); boolean onscreen = capsChosen.isOnscreen(); boolean usePBuffer = capsChosen.isPBuffer(); + boolean useFBO = capsChosen.isFBO(); // Utilizing FBConfig // @@ -270,13 +272,12 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capsChosen, true, isMultisampleAvailable, display, screen); int[] count = { -1 }; List availableCaps = new ArrayList(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer); - + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, useFBO); // 1st choice: get GLCapabilities based on users GLCapabilities setting recommendedIndex as preferred choice fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, 0, count, 0); if (fbcfgsL != null && fbcfgsL.limit()>0) { for (int i = 0; i < fbcfgsL.limit(); i++) { - if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, display, fbcfgsL.get(i), winattrmask, isMultisampleAvailable) ) { + if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, absDevice, fbcfgsL.get(i), winattrmask, isMultisampleAvailable) ) { if(DEBUG) { System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid (1): ("+x11Screen+","+capsChosen+"): fbcfg: "+toHexString(fbcfgsL.get(i))); } @@ -309,7 +310,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } for (int i = 0; i < fbcfgsL.limit(); i++) { - if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, display, fbcfgsL.get(i), winattrmask, isMultisampleAvailable) ) { + if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, absDevice, fbcfgsL.get(i), winattrmask, isMultisampleAvailable) ) { if(DEBUG) { System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid (2): ("+x11Screen+"): fbcfg: "+toHexString(fbcfgsL.get(i))); } @@ -338,7 +339,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } GLProfile glProfile = capsChosen.getGLProfile(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(capsChosen.isOnscreen(), false /* pbuffer */); + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(capsChosen.isOnscreen(), false /* pbuffer */, false); List availableCaps = new ArrayList(); int recommendedIndex = -1; diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java index 9e22afa6d..363299321 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java @@ -51,10 +51,13 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable { long glXWindow; // GLXWindow, a GLXDrawable representation boolean useGLXWindow; - protected X11OnscreenGLXDrawable(GLDrawableFactory factory, NativeSurface component) { - super(factory, component, false); + protected X11OnscreenGLXDrawable(GLDrawableFactory factory, NativeSurface component, boolean realized) { + super(factory, component, realized); glXWindow=0; useGLXWindow=false; + if(realized) { + updateHandle(); + } } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java index cdf81ebd3..e1fe2f27e 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java @@ -43,7 +43,7 @@ package jogamp.opengl.x11.glx; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; @@ -77,7 +77,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { if (ns.getSurfaceHandle() != 0) { GLX.glXDestroyPbuffer(ns.getDisplayHandle(), ns.getSurfaceHandle()); } - ((SurfaceChangeable)ns).setSurfaceHandle(0); + ((MutableSurface)ns).setSurfaceHandle(0); } private void createPbuffer() { @@ -108,12 +108,14 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { // Create the p-buffer. int niattribs = 0; - int[] iattributes = new int[5]; + int[] iattributes = new int[7]; iattributes[niattribs++] = GLX.GLX_PBUFFER_WIDTH; iattributes[niattribs++] = ns.getWidth(); iattributes[niattribs++] = GLX.GLX_PBUFFER_HEIGHT; iattributes[niattribs++] = ns.getHeight(); + iattributes[niattribs++] = GLX.GLX_LARGEST_PBUFFER; // exact + iattributes[niattribs++] = 0; iattributes[niattribs++] = 0; long pbuffer = GLX.glXCreatePbuffer(display, config.getFBConfig(), iattributes, 0); @@ -123,15 +125,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { } // Set up instance variables - ((SurfaceChangeable)ns).setSurfaceHandle(pbuffer); - - // Determine the actual width and height we were able to create. - int[] tmp = new int[1]; - GLX.glXQueryDrawable(display, pbuffer, GLX.GLX_WIDTH, tmp, 0); - int width = tmp[0]; - GLX.glXQueryDrawable(display, pbuffer, GLX.GLX_HEIGHT, tmp, 0); - int height = tmp[0]; - ((SurfaceChangeable)ns).surfaceSizeChanged(width, height); + ((MutableSurface)ns).setSurfaceHandle(pbuffer); if (DEBUG) { System.err.println("Created pbuffer " + this); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java index 1e7b89828..04627724c 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java @@ -43,7 +43,7 @@ package jogamp.opengl.x11.glx; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; @@ -93,7 +93,7 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable { pixmap = 0; throw new GLException("glXCreateGLXPixmap failed"); } - ((SurfaceChangeable)ns).setSurfaceHandle(drawable); + ((MutableSurface)ns).setSurfaceHandle(drawable); if (DEBUG) { System.err.println("Created pixmap " + toHexString(pixmap) + ", GLXPixmap " + toHexString(drawable) + @@ -133,7 +133,7 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable { X11Lib.XFreePixmap(display, pixmap); drawable = 0; pixmap = 0; - ((SurfaceChangeable)ns).setSurfaceHandle(0); + ((MutableSurface)ns).setSurfaceHandle(0); display = 0; } } diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m index 776284cfc..b81b43e54 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m @@ -32,7 +32,6 @@ int texWidth; int texHeight; GLuint textureID; - struct timespec lastWaitTime; #ifdef HAS_CADisplayLink CADisplayLink* displayLink; #else @@ -41,6 +40,7 @@ int tc; struct timespec t0; @public + struct timespec lastWaitTime; GLint swapInterval; GLint swapIntervalCounter; pthread_mutex_t renderLock; diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m index 8ac9f4700..d3f703142 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m @@ -503,7 +503,7 @@ NSView* getNSView(NSOpenGLContext* ctx) { NSOpenGLContext* createContext(NSOpenGLContext* share, NSView* view, - Bool isBackingLayerView, + Bool allowIncompleteView, NSOpenGLPixelFormat* fmt, Bool opaque, int* viewNotReady) @@ -512,13 +512,13 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, getRendererInfo(); - DBG_PRINT("createContext.0: share %p, view %p, isBackingLayer %d, pixfmt %p, opaque %d\n", - share, view, (int)isBackingLayerView, fmt, opaque); + DBG_PRINT("createContext.0: share %p, view %p, allowIncompleteView %d, pixfmt %p, opaque %d\n", + share, view, (int)allowIncompleteView, fmt, opaque); if (view != NULL) { Bool viewReady = true; - if(!isBackingLayerView) { + if(!allowIncompleteView) { if ([view lockFocusIfCanDraw] == NO) { DBG_PRINT("createContext.1 [view lockFocusIfCanDraw] failed\n"); viewReady = false; @@ -527,7 +527,7 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, if(viewReady) { NSRect frame = [view frame]; if ((frame.size.width == 0) || (frame.size.height == 0)) { - if(!isBackingLayerView) { + if(!allowIncompleteView) { [view unlockFocus]; } DBG_PRINT("createContext.2 view.frame size %dx%d\n", (int)frame.size.width, (int)frame.size.height); @@ -558,7 +558,7 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, [ctx setValues:&zeroOpacity forParameter:NSOpenGLCPSurfaceOpacity]; } [ctx setView:view]; - if(!isBackingLayerView) { + if(!allowIncompleteView) { [view unlockFocus]; } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java index 04f616daf..b7f6ba45d 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java @@ -30,51 +30,49 @@ package com.jogamp.nativewindow; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.SurfaceChangeable; +public class WrappedSurface extends ProxySurface { + protected long surfaceHandle; -public class WrappedSurface extends ProxySurface implements SurfaceChangeable { - protected long surfaceHandle; - - public WrappedSurface(AbstractGraphicsConfiguration cfg) { - this(cfg, 0); - } - - public WrappedSurface(AbstractGraphicsConfiguration cfg, long handle) { - super(cfg); + public WrappedSurface(AbstractGraphicsConfiguration cfg, long handle, int initialWidth, int initialHeight, UpstreamSurfaceHook upstream) { + super(cfg, initialWidth, initialHeight, upstream); surfaceHandle=handle; } @Override - protected final void invalidateImpl() { + protected void invalidateImpl() { surfaceHandle = 0; } @Override - final public long getSurfaceHandle() { + public final long getSurfaceHandle() { return surfaceHandle; } @Override - final public void setSurfaceHandle(long surfaceHandle) { + public final void setSurfaceHandle(long surfaceHandle) { this.surfaceHandle=surfaceHandle; } - + @Override - final protected int lockSurfaceImpl() { - return LOCK_SUCCESS; + protected final int lockSurfaceImpl() { + return LOCK_SUCCESS; } @Override - final protected void unlockSurfaceImpl() { + protected final void unlockSurfaceImpl() { } @Override public String toString() { + final UpstreamSurfaceHook ush = getUpstreamSurfaceHook(); + final String ush_s = null != ush ? ( ush.getClass().getName() + ": " + ush ) : "nil"; + return "WrappedSurface[config " + getPrivateGraphicsConfiguration()+ ", displayHandle 0x" + Long.toHexString(getDisplayHandle()) + ", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle()) + ", size " + getWidth() + "x" + getHeight() + - ", surfaceLock "+surfaceLock+"]"; + ", surfaceLock "+surfaceLock+ + ", upstreamSurfaceHook "+ush_s+"]"; } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java index d161f2f34..389949e90 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java @@ -38,7 +38,7 @@ import javax.media.nativewindow.*; */ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneable { final long nativeDisplayID; - final EGLTerminateCallback eglTerminateCallback; + final EGLDisplayLifecycleCallback eglLifecycleCallback; /** * Hack to allow inject a EGL termination call. @@ -47,7 +47,14 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl * since then it can be utilized directly. *

    */ - public interface EGLTerminateCallback { + public interface EGLDisplayLifecycleCallback { + /** + * Implementation should issue an EGL.eglGetDisplay(nativeDisplayID) + * inclusive EGL.eglInitialize(eglDisplayHandle, ..) call. + * @param eglDisplayHandle + */ + public long eglGetAndInitDisplay(long nativeDisplayID); + /** * Implementation should issue an EGL.eglTerminate(eglDisplayHandle) call. * @param eglDisplayHandle @@ -61,28 +68,45 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl */ public EGLGraphicsDevice(String connection, int unitID) { super(NativeWindowFactory.TYPE_EGL, connection, unitID); - this.nativeDisplayID = 0; - this.eglTerminateCallback = null; + this.nativeDisplayID = 0 ; // EGL.EGL_DEFAULT_DISPLAY + this.eglLifecycleCallback = null; } - public EGLGraphicsDevice(long nativeDisplayID, long eglDisplay, String connection, int unitID, EGLTerminateCallback eglTerminateCallback) { + public EGLGraphicsDevice(long nativeDisplayID, long eglDisplay, String connection, int unitID, EGLDisplayLifecycleCallback eglLifecycleCallback) { super(NativeWindowFactory.TYPE_EGL, connection, unitID, eglDisplay); this.nativeDisplayID = nativeDisplayID; - this.eglTerminateCallback = eglTerminateCallback; + this.eglLifecycleCallback = eglLifecycleCallback; } public long getNativeDisplayID() { return nativeDisplayID; } + @Override public Object clone() { return super.clone(); } + + @Override + public boolean open() { + if(null != eglLifecycleCallback && 0 == handle) { + if(DEBUG) { + System.err.println(Thread.currentThread().getName() + " - EGLGraphicsDevice.open(): "+this); + } + handle = eglLifecycleCallback.eglGetAndInitDisplay(nativeDisplayID); + if(0 == handle) { + throw new NativeWindowException("EGLGraphicsDevice.open() failed: "+this); + } + return true; + } + return false; + } + @Override public boolean close() { - if(null != eglTerminateCallback) { + if(null != eglLifecycleCallback && 0 != handle) { if(DEBUG) { - System.err.println(Thread.currentThread().getName() + " - eglTerminate: "+this); + System.err.println(Thread.currentThread().getName() + " - EGLGraphicsDevice.close(): "+this); } - eglTerminateCallback.eglTerminate(handle); + eglLifecycleCallback.eglTerminate(handle); } return super.close(); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 735d85fb1..0494bb408 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -43,7 +43,6 @@ import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsDevice; -import jogamp.common.awt.AWTEDTExecutor; import jogamp.nativewindow.macosx.OSXUtil; public class SWTAccessor { @@ -204,8 +203,6 @@ public class SWTAccessor { if( null != OS_gtk_class ) { long widgedHandle = callStaticMethodL2L(OS_GTK_WIDGET_WINDOW, handle); long displayHandle = callStaticMethodL2L(OS_gdk_x11_drawable_get_xdisplay, widgedHandle); - // FIXME: May think about creating a private non-shared X11 Display handle, like we use to for AWT - // to avoid locking problems ! return new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, false); } if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) ) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index a02332413..7a98e3c25 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -33,7 +33,6 @@ package com.jogamp.nativewindow.x11; -import jogamp.nativewindow.Debug; import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; @@ -46,7 +45,7 @@ import javax.media.nativewindow.ToolkitLock; */ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneable { - final boolean closeDisplay; + final boolean handleOwner; /** Constructs a new X11GraphicsDevice corresponding to the given connection and default * {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#getDefaultToolkitLock(String)}.
    @@ -56,7 +55,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl */ public X11GraphicsDevice(String connection, int unitID) { super(NativeWindowFactory.TYPE_X11, connection, unitID); - closeDisplay = false; + handleOwner = false; } /** Constructs a new X11GraphicsDevice corresponding to the given native display handle and default @@ -69,7 +68,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl if(0==display) { throw new NativeWindowException("null display"); } - closeDisplay = owner; + handleOwner = owner; } /** @@ -82,16 +81,39 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl if(0==display) { throw new NativeWindowException("null display"); } - closeDisplay = owner; + handleOwner = owner; } + public int getDefaultVisualID() { + // It still could be an AWT hold handle .. + final long display = getHandle(); + final int scrnIdx = X11Lib.DefaultScreen(display); + return (int) X11Lib.DefaultVisualID(display, scrnIdx); + } + + @Override public Object clone() { return super.clone(); } + @Override + public boolean open() { + if(handleOwner && 0 == handle) { + if(DEBUG) { + System.err.println(Thread.currentThread().getName() + " - X11GraphicsDevice.open(): "+this); + } + handle = X11Util.openDisplay(connection); + if(0 == handle) { + throw new NativeWindowException("X11GraphicsDevice.open() failed: "+this); + } + return true; + } + return false; + } + + @Override public boolean close() { - // FIXME: shall we respect the unitID ? - if(closeDisplay && 0 != handle) { + if(handleOwner && 0 != handle) { if(DEBUG) { System.err.println(Thread.currentThread().getName() + " - X11GraphicsDevice.close(): "+this); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java index 94013ec38..014f4f688 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java @@ -56,13 +56,11 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl return new X11GraphicsScreen(new X11GraphicsDevice(display, AbstractGraphicsDevice.DEFAULT_UNIT, owner), screenIdx); } - public long getDefaultVisualID() { + public int getVisualID() { // It still could be an AWT hold handle .. - long display = getDevice().getHandle(); - int scrnIdx = X11Lib.DefaultScreen(display); - return X11Lib.DefaultVisualID(display, scrnIdx); + return (int) X11Lib.DefaultVisualID(getDevice().getHandle(), getIndex()); } - + private static int fetchScreen(X11GraphicsDevice device, int screen) { // It still could be an AWT hold handle .. if(X11Util.XineramaIsEnabled(device.getHandle())) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java index 4979f1949..756e4451b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java @@ -113,16 +113,33 @@ public interface AbstractGraphicsDevice extends Cloneable { */ public void unlock(); + /** + * Optionally [re]opening the device if handle is null. + *

    + * The default implementation is a NOP. + *

    + *

    + * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} + * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} + * issue the native open operation in case handle is null. + *

    + * + * @return true if the handle was null and opening was successful, otherwise false. + */ + public boolean open(); + /** - * Optionally closing the device. + * Optionally closing the device if handle is not null. *

    * The default implementation is a NOP, just setting the handle to null. *

    - * The specific implementing, ie {@link com.jogamp.nativewindow.x11.X11GraphicsDevice}, - * shall have a enable/disable like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice#setCloseDisplay(boolean, boolean)},
    - * which shall be invoked at creation time to determine ownership/role of freeing the resource.
    + *

    + * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} + * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} + * issue the native close operation or skip it depending on the handles's ownership. + *

    * - * @return true if the handle was not null, otherwise false. + * @return true if the handle was not null and closing was successful, otherwise false. */ public boolean close(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java index 187959a67..583fde07f 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java @@ -97,22 +97,27 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice } } + @Override public final String getType() { return type; } + @Override public final String getConnection() { return connection; } + @Override public final int getUnitID() { return unitID; } + @Override public final String getUniqueID() { return uniqueID; } + @Override public final long getHandle() { return handle; } @@ -124,6 +129,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long) * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock) */ + @Override public final void lock() { toolkitLock.lock(); } @@ -135,10 +141,17 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long) * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock) */ + @Override public final void unlock() { toolkitLock.unlock(); } + + @Override + public boolean open() { + return false; + } + @Override public boolean close() { if(0 != handle) { handle = 0; diff --git a/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java b/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java new file mode 100644 index 000000000..ff53c8109 --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java @@ -0,0 +1,44 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package javax.media.nativewindow; + +/** + * Provides a {@link NativeSurface} with a mutable surfaceHandle + * via {@link #setSurfaceHandle(long)}. + * + * @see NativeSurface + */ +public interface MutableSurface extends NativeSurface { + + /** + * Sets the surface handle which is created outside of this implementation. + */ + public void setSurfaceHandle(long surfaceHandle); +} + diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java index 1dabc3dcd..7fc9789c2 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java @@ -28,38 +28,108 @@ package javax.media.nativewindow; - import jogamp.nativewindow.Debug; import jogamp.nativewindow.SurfaceUpdatedHelper; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; -public abstract class ProxySurface implements NativeSurface { +public abstract class ProxySurface implements NativeSurface, MutableSurface { public static final boolean DEBUG = Debug.debug("ProxySurface"); + + /** + * Implementation specific bitvalue stating the upstream's {@link AbstractGraphicsDevice} is owned by this {@link ProxySurface}. + * @see #setImplBitfield(int) + * @see #getImplBitfield() + */ + public static final int OWN_DEVICE = 1 << 7; + + /** + * Implementation specific bitvalue stating the upstream's {@link NativeSurface} is an invisible window, i.e. maybe incomplete. + * @see #setImplBitfield(int) + * @see #getImplBitfield() + */ + public static final int INVISIBLE_WINDOW = 1 << 8; - private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); - private AbstractGraphicsConfiguration config; // control access due to delegation - protected RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); + /** Interface allowing upstream caller to pass lifecycle actions and size info to a {@link ProxySurface} instance. */ + public interface UpstreamSurfaceHook { + /** called within {@link ProxySurface#createNotify()} within lock, before using surface. */ + public void create(ProxySurface s); + /** called within {@link ProxySurface#destroyNotify()} within lock, before clearing fields. */ + public void destroy(ProxySurface s); + + /** Returns the width of the upstream surface */ + public int getWidth(ProxySurface s); + /** Returns the height of the upstream surface */ + public int getHeight(ProxySurface s); + } + + private final SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); + private final AbstractGraphicsConfiguration config; // control access due to delegation + private final UpstreamSurfaceHook upstream; + public final int initialWidth; + public final int initialHeight; private long surfaceHandle_old; + protected RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); protected long displayHandle; - protected int height; protected int scrnIndex; - protected int width; + protected int implBitfield; - public ProxySurface(AbstractGraphicsConfiguration cfg) { - invalidate(); - config = cfg; - displayHandle=cfg.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); - surfaceHandle_old = 0; + /** + * @param cfg the {@link AbstractGraphicsConfiguration} to be used + * @param initialWidth the initial width + * @param initialHeight the initial height + */ + protected ProxySurface(AbstractGraphicsConfiguration cfg, int initialWidth, int initialHeight, UpstreamSurfaceHook upstream) { + if(null == cfg) { + throw new IllegalArgumentException("null config"); + } + this.config = cfg; + this.upstream = upstream; + this.initialWidth = initialWidth; + this.initialHeight = initialHeight; + this.displayHandle=config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); + this.surfaceHandle_old = 0; + this.implBitfield = 0; } - void invalidate() { - displayHandle = 0; - invalidateImpl(); + public final UpstreamSurfaceHook getUpstreamSurfaceHook() { return upstream; } + + /** + * If a valid {@link UpstreamSurfaceHook} instance is passed in the + * {@link ProxySurface#ProxySurface(AbstractGraphicsConfiguration, int, int, UpstreamSurfaceHook) constructor}, + * {@link UpstreamSurfaceHook#create(ProxySurface)} is being issued and the proxy surface/window handles shall be set. + */ + public void createNotify() { + if(null != upstream) { + upstream.create(this); + } + this.displayHandle=config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); + this.surfaceHandle_old = 0; } - protected abstract void invalidateImpl(); - + + /** + * If a valid {@link UpstreamSurfaceHook} instance is passed in the + * {@link ProxySurface#ProxySurface(AbstractGraphicsConfiguration, int, int, UpstreamSurfaceHook) constructor}, + * {@link UpstreamSurfaceHook#destroy(ProxySurface)} is being issued and all fields are cleared. + */ + public void destroyNotify() { + if(null != upstream) { + upstream.destroy(this); + invalidateImpl(); + } + this.displayHandle = 0; + this.surfaceHandle_old = 0; + } + + /** + * Must be overridden by implementations allowing having a {@link UpstreamSurfaceHook} being passed. + * @see #destroyNotify() + */ + protected void invalidateImpl() { + throw new InternalError("UpstreamSurfaceHook given, but required method not implemented."); + } + @Override public final long getDisplayHandle() { return displayHandle; @@ -82,19 +152,23 @@ public abstract class ProxySurface implements NativeSurface { @Override public abstract long getSurfaceHandle(); + @Override + public abstract void setSurfaceHandle(long surfaceHandle); + @Override public final int getWidth() { - return width; + if(null != upstream) { + return upstream.getWidth(this); + } + return initialWidth; } @Override public final int getHeight() { - return height; - } - - public void surfaceSizeChanged(int width, int height) { - this.width = width; - this.height = height; + if(null != upstream) { + return upstream.getHeight(this); + } + return initialHeight; } @Override @@ -187,7 +261,10 @@ public abstract class ProxySurface implements NativeSurface { public final Thread getSurfaceLockOwner() { return surfaceLock.getOwner(); } - + @Override public abstract String toString(); + + public int getImplBitfield() { return implBitfield; } + public void setImplBitfield(int v) { implBitfield=v; } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/SurfaceChangeable.java b/src/nativewindow/classes/javax/media/nativewindow/SurfaceChangeable.java deleted file mode 100644 index 956e68e61..000000000 --- a/src/nativewindow/classes/javax/media/nativewindow/SurfaceChangeable.java +++ /dev/null @@ -1,54 +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. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package javax.media.nativewindow; - -public interface SurfaceChangeable { - - /** Sets the surface handle which is created outside of this implementation */ - public void setSurfaceHandle(long surfaceHandle); - - /** - * The surface's size has been determined or changed. - * Implementation shall update the stored surface size with the given ones. - */ - public void surfaceSizeChanged(int width, int height); - -} - diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java index 4877d5c4f..4f68c6945 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java @@ -34,8 +34,8 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.SurfaceUpdatedListener; public class SurfaceUpdatedHelper implements SurfaceUpdatedListener { - private Object surfaceUpdatedListenersLock = new Object(); - private ArrayList surfaceUpdatedListeners = new ArrayList(); + private final Object surfaceUpdatedListenersLock = new Object(); + private final ArrayList surfaceUpdatedListeners = new ArrayList(); // // Management Utils diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 42fd08df1..e81d61e0f 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -48,7 +48,7 @@ import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.MutableGraphicsConfiguration; @@ -62,7 +62,7 @@ import jogamp.nativewindow.jawt.JAWT_DrawingSurfaceInfo; import jogamp.nativewindow.jawt.macosx.JAWT_MacOSXDrawingSurfaceInfo; import jogamp.nativewindow.macosx.OSXUtil; -public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { +public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { public MacOSXJAWTWindow(Object comp, AbstractGraphicsConfiguration config) { super(comp, config); if(DEBUG) { @@ -103,24 +103,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { if(DEBUG) { System.err.println("MacOSXJAWTWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle)); } - sscSet &= 0 != surfaceHandle; // reset ssc flag if NULL surfaceHandle, ie. back to JAWT this.surfaceHandle = surfaceHandle; } - public void surfaceSizeChanged(int width, int height) { - sscSet = true; - sscWidth = width; - sscHeight = height; - } - - public int getWidth() { - return sscSet ? sscWidth : super.getWidth(); - } - - public int getHeight() { - return sscSet ? sscHeight: super.getHeight(); - } - protected JAWT fetchJAWTImpl() throws NativeWindowException { // use offscreen if supported and [ applet or requested ] return JAWTUtil.getJAWT(getShallUseOffscreenLayer() || isApplet()); @@ -280,8 +265,6 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { private long rootSurfaceLayerHandle = 0; // attached to the JAWT_SurfaceLayer private long surfaceHandle = 0; - private int sscWidth, sscHeight; - private boolean sscSet = false; // Workaround for instance of 4796548 private boolean firstLock = true; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 4d472b01a..99fc9244e 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -63,19 +63,15 @@ public class OSXUtil { return (Point) GetLocationOnScreen0(windowOrView, src_x, src_y); } - public static long CreateNSView(int x, int y, int width, int height) { - return CreateNSView0(x, y, width, height); - } - public static void DestroyNSView(long nsView) { - DestroyNSView0(nsView); - } - public static long CreateNSWindow(int x, int y, int width, int height) { return CreateNSWindow0(x, y, width, height); } public static void DestroyNSWindow(long nsWindow) { DestroyNSWindow0(nsWindow); } + public static long GetNSView(long nsWindow) { + return GetNSView0(nsWindow); + } public static long CreateCALayer(int x, int y, int width, int height) { return CreateCALayer0(x, y, width, height); @@ -134,10 +130,9 @@ public class OSXUtil { private static native boolean initIDs0(); private static native Object GetLocationOnScreen0(long windowOrView, int src_x, int src_y); - private static native long CreateNSView0(int x, int y, int width, int height); - private static native void DestroyNSView0(long nsView); private static native long CreateNSWindow0(int x, int y, int width, int height); private static native void DestroyNSWindow0(long nsWindow); + private static native long GetNSView0(long nsWindow); private static native long CreateCALayer0(int x, int y, int width, int height); private static native void AddCASublayer0(long rootCALayer, long subCALayer); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java index c24f64b32..e368aa6a1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java @@ -31,6 +31,7 @@ package jogamp.nativewindow.windows; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; /** @@ -43,22 +44,49 @@ public class GDISurface extends ProxySurface { protected long windowHandle; protected long surfaceHandle; - public GDISurface(AbstractGraphicsConfiguration cfg, long windowHandle) { - super(cfg); - if(0 == windowHandle) { - throw new NativeWindowException("Error hwnd 0, werr: "+GDI.GetLastError()); - } + public GDISurface(AbstractGraphicsConfiguration cfg, long windowHandle, int initialWidth, int initialHeight, UpstreamSurfaceHook upstream) { + super(cfg, initialWidth, initialHeight, upstream); this.windowHandle=windowHandle; + this.surfaceHandle=0; } @Override - protected final void invalidateImpl() { - windowHandle=0; - surfaceHandle=0; + protected void invalidateImpl() { + if(0 != surfaceHandle) { + throw new NativeWindowException("didn't release surface Handle: "+this); + } + windowHandle = 0; + // surfaceHandle = 0; + } + + /** + * {@inheritDoc} + *

    + * Actually the window handle (HWND), since the surfaceHandle (HDC) is derived + * from it at {@link #lockSurface()}. + *

    + */ + @Override + public final void setSurfaceHandle(long surfaceHandle) { + this.windowHandle = surfaceHandle; + } + + /** + * Sets the window handle (HWND). + */ + public final void setWindowHandle(long windowHandle) { + this.windowHandle = windowHandle; + } + + public final long getWindowHandle() { + return windowHandle; } @Override final protected int lockSurfaceImpl() { + if (0 == windowHandle) { + throw new NativeWindowException("null window handle: "+this); + } if (0 != surfaceHandle) { throw new InternalError("surface not released"); } @@ -89,12 +117,15 @@ public class GDISurface extends ProxySurface { @Override final public String toString() { - return "GDISurface[config "+getPrivateGraphicsConfiguration()+ + final UpstreamSurfaceHook ush = getUpstreamSurfaceHook(); + final String ush_s = null != ush ? ( ush.getClass().getName() + ": " + ush ) : "nil"; + return getClass().getSimpleName()+"[config "+getPrivateGraphicsConfiguration()+ ", displayHandle 0x"+Long.toHexString(getDisplayHandle())+ ", windowHandle 0x"+Long.toHexString(windowHandle)+ ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+ ", size "+getWidth()+"x"+getHeight()+ - ", surfaceLock "+surfaceLock+"]"; + ", surfaceLock "+surfaceLock+ + ", upstreamSurfaceHook "+ush_s+"]"; } } diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index e010fc440..ebfefe345 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -148,37 +148,6 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetLocationOnS return res; } -/* - * Class: Java_jogamp_nativewindow_macosx_OSXUtil - * Method: CreateNSView0 - * Signature: (IIIIZ)J - */ -JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSView0 - (JNIEnv *env, jclass unused, jint x, jint y, jint width, jint height) -{ - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSRect rect = NSMakeRect(x, y, width, height); - NSView * view = [[NSView alloc] initWithFrame: rect] ; - [view setCanDrawConcurrently: YES]; - [pool release]; - - return (jlong) (intptr_t) view; -} - -/* - * Class: Java_jogamp_nativewindow_macosx_OSXUtil - * Method: DestroyNSView0 - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSView0 - (JNIEnv *env, jclass unused, jlong nsView) -{ - NSView* view = (NSView*) (intptr_t) nsView; - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [view release]; - [pool release]; -} - /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: CreateNSWindow0 @@ -222,6 +191,27 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSWindow0 [pool release]; } +/* + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: GetNSView0 + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSView0 + (JNIEnv *env, jclass unused, jlong window) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSWindow* win = (NSWindow*) ((intptr_t) window); + + DBG_PRINT( "contentView0 - window: %p (START)\n", win); + + jlong res = (jlong) ((intptr_t) [win contentView]); + + DBG_PRINT( "contentView0 - window: %p (END)\n", win); + + [pool release]; + return res; +} + /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: CreateCALayer0 diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 71e86d520..e8537fec5 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -40,8 +40,20 @@ import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.WindowClosingProtocol; /** - * Specifying the public Window functionality for the - * using a Window and for shadowing one like {@link com.jogamp.newt.opengl.GLWindow}. + * Specifying NEWT's Window functionality: + *
      + *
    • On- and offscreen windows
    • + *
    • Keyboard and multi-pointer input
    • + *
    • Native reparenting
    • + *
    • Toggable fullscreen and decoration mode
    • + *
    • Transparency
    • + *
    • ... and more
    • + *
    + *

    + * One use case is {@link com.jogamp.newt.opengl.GLWindow}, which delegates + * window operation to an instance of this interface while providing OpenGL + * functionality. + *

    */ public interface Window extends NativeWindow, WindowClosingProtocol { public static final boolean DEBUG_MOUSE_EVENT = Debug.debug("Window.MouseEvent"); diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 44fcea49c..4db661eeb 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -43,7 +43,7 @@ public class KeyEvent extends InputEvent this.keyChar=keyChar; } - /** Only valid if delivered via {@link KeyListener#keyPressed(KeyEvent)} */ + /** Only valid on all platforms at {@link KeyListener#keyTyped(KeyEvent)} */ public char getKeyChar() { return keyChar; } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index f08fbc8fa..c50ab77c4 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -124,6 +124,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind this.window.setLifecycleHook(new GLLifecycleHook()); } + @Override + public final Object getUpstreamWidget() { + return window; + } + /** * Creates a new GLWindow attaching a new Window referencing a * new default Screen and default Display with the given GLCapabilities. @@ -762,7 +767,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind System.err.println(GlueGenVersion.getInstance()); System.err.println(JoglVersion.getInstance()); - System.err.println(JoglVersion.getDefaultOpenGLInfo(null, true).toString()); + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, true).toString()); final GLProfile glp = GLProfile.getDefault(); final GLCapabilitiesImmutable caps = new GLCapabilities( glp ); diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index 050e24b6c..be543aba9 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -34,15 +34,24 @@ package jogamp.newt; -import javax.media.nativewindow.*; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.MutableSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; -public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { +public class OffscreenWindow extends WindowImpl implements MutableSurface { long surfaceHandle = 0; - + ProxySurface.UpstreamSurfaceHook upstreamHook; + ProxySurface dummySurface; + public OffscreenWindow() { + upstreamHook = null; + dummySurface = null; } static long nextWindowHandle = 0x100; // start here - a marker @@ -52,6 +61,17 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { throw new NativeWindowException("Capabilities is onscreen"); } final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); + /** Cannot use OpenGL here .. + if(capsRequested instanceof GLCapabilitiesImmutable) { + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) capsRequested; + if(caps.isFBO() && GLContext.isFBOAvailable(aScreen.getDevice(), caps.getGLProfile()) ) { + final GLDrawableFactoryImpl factory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLCapabilitiesImmutable dummyCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(caps); + final ProxySurface dummySurface = factory.createDummySurfaceImpl(aScreen.getDevice(), false, dummyCaps, null, 64, 64); + upstreamHook = dummySurface.getUpstreamSurfaceHook(); + dummySurface.createNotify(); + } + } */ final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aScreen.getDevice()).chooseGraphicsConfiguration( capsRequested, capsRequested, capabilitiesChooser, aScreen); if (null == cfg) { @@ -68,13 +88,14 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { // nop } - public void surfaceSizeChanged(int width, int height) { - sizeChanged(false, width, height, false); - } - @Override public synchronized void destroy() { super.destroy(); + if(null != dummySurface) { + dummySurface.destroyNotify(); + dummySurface = null; + upstreamHook = null; + } surfaceHandle = 0; } @@ -84,8 +105,12 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { @Override public long getSurfaceHandle() { + if(null != dummySurface) { + return dummySurface.getSurfaceHandle(); + // return upstreamHook.getWidth(); + } return surfaceHandle; - } + } protected void requestFocusImpl(boolean reparented) { } diff --git a/src/newt/classes/jogamp/newt/driver/android/MD.java b/src/newt/classes/jogamp/newt/driver/android/MD.java index 403eae383..f2f30937b 100644 --- a/src/newt/classes/jogamp/newt/driver/android/MD.java +++ b/src/newt/classes/jogamp/newt/driver/android/MD.java @@ -43,7 +43,7 @@ public class MD { .append(JoglVersion.getInstance()).append(Platform.NEWLINE) .append(Platform.NEWLINE); - JoglVersion.getDefaultOpenGLInfo(sb, true); + JoglVersion.getDefaultOpenGLInfo(null, sb, true); return sb.toString(); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java index 942994c13..fcca5c843 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java @@ -38,7 +38,7 @@ import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; @@ -50,7 +50,7 @@ import jogamp.newt.driver.DriverUpdatePosition; import com.jogamp.newt.event.KeyEvent; -public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverClearFocus, DriverUpdatePosition { +public class MacWindow extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { static { MacDisplay.initSingleton(); @@ -131,10 +131,6 @@ public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverCl } } - public void surfaceSizeChanged(int width, int height) { - sizeChanged(false, width, height, false); - } - @Override protected void setTitleImpl(final String title) { setTitle0(getWindowHandle(), title); diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index f914467af..b58b99e38 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -972,7 +972,7 @@ static jint mods2JavaMods(NSUInteger mods) NSView* nsview = [self contentView]; if( ! [nsview isMemberOfClass:[NewtView class]] ) { - return; + return NO; } NewtView* view = (NewtView *) nsview; @@ -981,14 +981,14 @@ static jint mods2JavaMods(NSUInteger mods) DBG_PRINT( "*************** windowWillClose.0: %p\n", (void *)(intptr_t)javaWindowObject); if (javaWindowObject == NULL) { DBG_PRINT("windowWillClose: null javaWindowObject\n"); - return; + return NO; } int shallBeDetached = 0; JavaVM *jvmHandle = [view getJVMHandle]; JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached); if(NULL==env) { DBG_PRINT("windowWillClose: null JNIEnv\n"); - return; + return NO; } [view setDestroyNotifySent: true]; // earmark assumption of being closed diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java index a09cc76ac..b22be0a93 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java @@ -194,7 +194,7 @@ public class TestTextRendererNEWT00 extends UITestCase { pw.printf("%s-%03dx%03d-T%04d", objName, drawable.getWidth(), drawable.getHeight(), texSize[0]); final String filename = dir + sw +".png"; - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { + if(screenshot.readPixels(drawable.getGL(), false)) { screenshot.write(new File(filename)); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java index a3182a30f..6378c1ee3 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java @@ -194,7 +194,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { pw.printf("-%03dx%03d-Z%04d-T%04d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zoom), texSize[0], objName); final String filename = dir + tech + sw +".png"; - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { + if(screenshot.readPixels(drawable.getGL(), false)) { screenshot.write(new File(filename)); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java index d0093ad0c..15daf70cd 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java @@ -180,7 +180,7 @@ public abstract class UIListenerBase01 implements GLEventListener { pw.printf("-%03dx%03d-Z%04d-T%04d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zoom), 0, objName); final String filename = dir + tech + sw +".png"; - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { + if(screenshot.readPixels(drawable.getGL(), false)) { screenshot.write(new File(filename)); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java new file mode 100644 index 000000000..1a33845b3 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java @@ -0,0 +1,272 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import jogamp.opengl.GLFBODrawableImpl; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.OffscreenAutoDrawable; +import com.jogamp.opengl.test.junit.jogl.demos.es2.FBOMix2DemosES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; + +public class TestFBODrawableNEWT extends UITestCase { + + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + @Test + public void testGL2ES2_Demo1Normal() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } + + @Test + public void testGL2ES2_Demo1MSAA4() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } + + @Test + public void testGL2ES2_Demo2Normal() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + testGLFBODrawableImpl(caps, new MultisampleDemoES2(false)); + } + + @Test + public void testGL2ES2_Demo2MSAA4() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, new MultisampleDemoES2(true)); + } + + @Test + public void testGL2ES2_FBODemoNormal() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0); + demo.setDoRotation(false); + final GLCapabilities caps = new GLCapabilities(glp); + testGLFBODrawableImpl(caps, demo); + } + + @Test + public void testGL2ES2_FBODemoMSAA4() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0); + demo.setDoRotation(false); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, demo); + } + + @Test + public void testEGLES2_Demo0Normal() throws InterruptedException { + if( GLProfile.isAvailable(GLProfile.GLES2) ) { + final GLProfile glp = GLProfile.get(GLProfile.GLES2); + final GLCapabilities caps = new GLCapabilities(glp); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } else { + System.err.println("EGL ES2 n/a"); + } + } + + @Test + public void testEGLES2_Demo0MSAA4() throws InterruptedException { + if( GLProfile.isAvailable(GLProfile.GLES2) ) { + final GLProfile glp = GLProfile.get(GLProfile.GLES2); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } else { + System.err.println("EGL ES2 n/a"); + } + } + + boolean skipShot = false; + + void testGLFBODrawableImpl(GLCapabilities caps, GLEventListener demo) throws InterruptedException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); + caps.setFBO(true); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLDrawable fboDrawable = factory.createOffscreenDrawable(null, caps, null, widthStep*szStep, heightStep*szStep); + Assert.assertNotNull(fboDrawable); + Assert.assertTrue("Not an FBO Drawable", fboDrawable instanceof GLFBODrawableImpl); + + fboDrawable.setRealized(true); + Assert.assertTrue(fboDrawable.isRealized()); + + final FBObject fbo = ((GLFBODrawableImpl)fboDrawable).getFBObject(); + + System.out.println("Realized: "+fboDrawable); + System.out.println("Realized: "+fboDrawable.getChosenGLCapabilities()); + System.out.println("Realized: "+fbo); + + final GLContext context = fboDrawable.createContext(null); + Assert.assertNotNull(context); + + int res = context.makeCurrent(); + Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); + context.release(); + + System.out.println("Post Create-Ctx: "+fbo); + final FBObject.Colorbuffer colorA = fbo.getColorbuffer(0); + Assert.assertNotNull(colorA); + final FBObject.RenderAttachment depthA = fbo.getDepthAttachment(); + Assert.assertNotNull(depthA); + + final OffscreenAutoDrawable glad = new OffscreenAutoDrawable(fboDrawable, context, null); + + glad.addGLEventListener(demo); + glad.addGLEventListener(new GLEventListener() { + volatile int displayCount=0; + volatile int reshapeCount=0; + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + // System.err.println(Thread.currentThread().getName()+": ** display: "+displayCount+": step "+szStep+" "+drawable.getWidth()+"x"+drawable.getHeight()); + // System.err.println(Thread.currentThread().getName()+": ** FBO-THIS: "+fbo); + // System.err.println(Thread.currentThread().getName()+": ** FBO-SINK: "+fbo.getSamplingSinkFBO()); + // System.err.println(Thread.currentThread().getName()+": ** drawable-read: "+gl.getDefaultReadFramebuffer()); + if(skipShot) { + skipShot=false; + } else { + snapshot(getSimpleTestName("."), displayCount, "msaa"+fbo.getNumSamples(), gl, screenshot, TextureIO.PNG, null); + } + Assert.assertEquals(drawable.getWidth(), widthStep*szStep); + Assert.assertEquals(drawable.getHeight(), heightStep*szStep); + displayCount++; + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + System.err.println(Thread.currentThread().getName()+": ** reshape: "+reshapeCount+": step "+szStep+" "+width+"x"+height+" - "+drawable.getWidth()+"x"+drawable.getHeight()); + Assert.assertEquals(drawable.getWidth(), widthStep*szStep); + Assert.assertEquals(drawable.getHeight(), heightStep*szStep); + reshapeCount++; + } + }); + + // 0 - szStep = 2 + glad.display(); + + // 1, 2 (resize + display) + szStep = 1; + skipShot=true; + glad.setSize(widthStep*szStep, heightStep*szStep); + glad.display(); + Assert.assertEquals(glad.getWidth(), widthStep*szStep); + Assert.assertEquals(glad.getHeight(), heightStep*szStep); + { + // Check whether the attachment reference are still valid! + FBObject.Colorbuffer _colorA = fbo.getColorbuffer(0); + Assert.assertNotNull(_colorA); + Assert.assertTrue(colorA == _colorA); + Assert.assertTrue(colorA.equals(_colorA)); + FBObject.RenderAttachment _depthA = fbo.getDepthAttachment(); + Assert.assertNotNull(_depthA); + Assert.assertTrue(depthA == _depthA); + Assert.assertTrue(depthA.equals(_depthA)); + + _colorA = fbo.getColorbuffer(colorA); + Assert.assertNotNull(_colorA); + Assert.assertTrue(colorA == _colorA); + Assert.assertTrue(colorA.equals(_colorA)); + } + + // 3, 4 (resize + display) + szStep = 4; + skipShot=true; + glad.setSize(widthStep*szStep, heightStep*szStep); + glad.display(); + Assert.assertEquals(glad.getWidth(), widthStep*szStep); + Assert.assertEquals(glad.getHeight(), heightStep*szStep); + { + // Check whether the attachment reference are still valid! + FBObject.Colorbuffer _colorA = fbo.getColorbuffer(0); + Assert.assertNotNull(_colorA); + Assert.assertTrue(colorA == _colorA); + final FBObject.RenderAttachment _depthA = fbo.getDepthAttachment(); + Assert.assertNotNull(_depthA); + Assert.assertTrue(depthA == _depthA); + + _colorA = fbo.getColorbuffer(colorA); + Assert.assertNotNull(_colorA); + Assert.assertTrue(colorA == _colorA); + } + + // 5 + glad.display(); + Assert.assertEquals(glad.getWidth(), widthStep*szStep); + Assert.assertEquals(glad.getHeight(), heightStep*szStep); + + // 6, 7 (resize + display) + szStep = 3; + skipShot=true; + glad.setSize(widthStep*szStep, heightStep*szStep); + glad.display(); + Assert.assertEquals(glad.getWidth(), widthStep*szStep); + Assert.assertEquals(glad.getHeight(), heightStep*szStep); + + glad.destroy(); + System.out.println("Fin: "+fboDrawable); + + // final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(fboDrawable, context); + } + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestFBODrawableNEWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java new file mode 100644 index 000000000..f7c83a03b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java @@ -0,0 +1,266 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.acore; + +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.TextureAttachment; +import com.jogamp.opengl.util.GLArrayDataServer; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; +import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.FBObject.Attachment.Type; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.NEWTGLContext; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import java.io.IOException; + +import javax.media.nativewindow.NativeSurface; +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLPipelineFactory; +import javax.media.opengl.GLProfile; +import javax.media.opengl.GLUniformData; + +import org.junit.Assert; +import org.junit.Test; + +public class TestFBOMRTNEWT01 extends UITestCase { + static long durationPerTest = 10*40*2; // ms + + @Test + public void test01() throws InterruptedException { + final int step = 4; + final int width = 800; + final int height = 600; + // preset .. + if(!GLProfile.isAvailable(GLProfile.GL2GL3)) { + System.err.println("Test requires GL2/GL3 profile."); + return; + } + final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow( + new GLCapabilities(GLProfile.getGL2GL3()), width/step, height/step, true); + final GLDrawable drawable = winctx.context.getGLDrawable(); + GL2GL3 gl = winctx.context.getGL().getGL2GL3(); + gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, gl, null) ).getGL2GL3(); + System.err.println(winctx.context); + + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + // test code .. + final ShaderState st = new ShaderState(); + // st.setVerbose(true); + + final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader", + "shader/bin", "fbo-mrt-1", false); + final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader", + "shader/bin", "fbo-mrt-1", false); + final ShaderProgram sp0 = new ShaderProgram(); + sp0.add(gl, vp0, System.err); + sp0.add(gl, fp0, System.err); + Assert.assertTrue(0<=sp0.program()); + Assert.assertTrue(!sp0.inUse()); + Assert.assertTrue(!sp0.linked()); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + st.attachShaderProgram(gl, sp0, false); + + final ShaderCode vp1 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader", + "shader/bin", "fbo-mrt-2", false); + final ShaderCode fp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader", + "shader/bin", "fbo-mrt-2", false); + final ShaderProgram sp1 = new ShaderProgram(); + sp1.add(gl, vp1, System.err); + sp1.add(gl, fp1, System.err); + Assert.assertTrue(0<=sp1.program()); + Assert.assertTrue(!sp1.inUse()); + Assert.assertTrue(!sp1.linked()); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + st.attachShaderProgram(gl, sp1, true); + + final PMVMatrix pmvMatrix = new PMVMatrix(); + final GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + st.ownUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + final GLArrayDataServer vertices0 = GLArrayDataServer.createGLSL("gca_Vertices", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); + // st.bindAttribLocation(gl, 0, vertices0); + vertices0.putf(0); vertices0.putf(1); vertices0.putf(0); + vertices0.putf(1); vertices0.putf(1); vertices0.putf(0); + vertices0.putf(0); vertices0.putf(0); vertices0.putf(0); + vertices0.putf(1); vertices0.putf(0); vertices0.putf(0); + vertices0.seal(gl, true); + st.ownAttribute(vertices0, true); + vertices0.enableBuffer(gl, false); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + final GLArrayDataServer colors0 = GLArrayDataServer.createGLSL("gca_Colors", 4, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); + // st.bindAttribLocation(gl, 1, colors0); + colors0.putf(1); colors0.putf(0); colors0.putf(1); colors0.putf(1); + colors0.putf(0); colors0.putf(0); colors0.putf(1); colors0.putf(1); + colors0.putf(0); colors0.putf(0); colors0.putf(0); colors0.putf(1); + colors0.putf(0); colors0.putf(1); colors0.putf(1); colors0.putf(1); + colors0.seal(gl, true); + st.ownAttribute(colors0, true); + colors0.enableBuffer(gl, false); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + final GLUniformData texUnit0 = new GLUniformData("gcs_TexUnit0", 0); + st.ownUniform(texUnit0); + st.uniform(gl, texUnit0); + final GLUniformData texUnit1 = new GLUniformData("gcs_TexUnit1", 1); + st.ownUniform(texUnit1); + st.uniform(gl, texUnit1); + + final GLArrayDataServer texCoords0 = GLArrayDataServer.createGLSL("gca_TexCoords", 2, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); + // st.bindAttribLocation(gl, 2, texCoords0); + texCoords0.putf(0f); texCoords0.putf(1f); + texCoords0.putf(1f); texCoords0.putf(1f); + texCoords0.putf(0f); texCoords0.putf(0f); + texCoords0.putf(1f); texCoords0.putf(0f); + texCoords0.seal(gl, true); + st.ownAttribute(texCoords0, true); + texCoords0.enableBuffer(gl, false); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + final int texA0Point = 0; // attachment point for texA0 + final int texA1Point = 1; // attachment point for texA1 + + // FBO w/ 2 texture2D color buffers + final FBObject fbo_mrt = new FBObject(); + fbo_mrt.reset(gl, drawable.getWidth(), drawable.getHeight()); + final TextureAttachment texA0 = fbo_mrt.attachTexture2D(gl, texA0Point, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); + final TextureAttachment texA1 = fbo_mrt.attachTexture2D(gl, texA1Point, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); + fbo_mrt.attachRenderbuffer(gl, Type.DEPTH, 24); + Assert.assertTrue( fbo_mrt.isStatusValid() ) ; + fbo_mrt.unbind(gl); + + // misc GL setup + gl.glClearColor(1, 1, 1, 1); + gl.glEnable(GL2ES2.GL_DEPTH_TEST); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + // reshape + pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glOrthof(0f, 1f, 0f, 1f, -10f, 10f); + pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + st.uniform(gl, pmvMatrixUniform); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + final int[] two_buffers = new int[] { GL.GL_COLOR_ATTACHMENT0+texA0Point, GL.GL_COLOR_ATTACHMENT0+texA1Point }; + final int[] bck_buffers = new int[] { GL2GL3.GL_BACK_LEFT }; + + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); + int step_i = 0; + int[] last_snap_size = new int[] { 0, 0 }; + + for(int i=0; i buffer0, Green -> buffer1 + st.attachShaderProgram(gl, sp0, true); + vertices0.enableBuffer(gl, true); + colors0.enableBuffer(gl, true); + + fbo_mrt.bind(gl); + gl.glDrawBuffers(2, two_buffers, 0); + gl.glViewport(0, 0, fbo_mrt.getWidth(), fbo_mrt.getHeight()); + + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); + fbo_mrt.unbind(gl); + vertices0.enableBuffer(gl, false); + colors0.enableBuffer(gl, false); + + // pass 2 - mix buffer0, buffer1 and blue + // rg = buffer0.rg + buffer1.rg, b = Blue - length(rg); + st.attachShaderProgram(gl, sp1, true); + vertices0.enableBuffer(gl, true); + colors0.enableBuffer(gl, true); + texCoords0.enableBuffer(gl, true); + gl.glDrawBuffers(1, bck_buffers, 0); + + gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); + + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue()); + fbo_mrt.use(gl, texA0); + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit1.intValue()); + fbo_mrt.use(gl, texA1); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); + fbo_mrt.unuse(gl); + vertices0.enableBuffer(gl, false); + colors0.enableBuffer(gl, false); + texCoords0.enableBuffer(gl, false); + + { + final NativeSurface ns = gl.getContext().getGLReadDrawable().getNativeSurface(); + if(last_snap_size[0] != ns.getWidth() && last_snap_size[1] != ns.getHeight()) { + gl.glFinish(); // sync .. no swap buffers yet! + snapshot(getSimpleTestName("."), step_i, null, gl, screenshot, TextureIO.PNG, null); // overwrite ok + last_snap_size[0] = ns.getWidth(); + last_snap_size[1] = ns.getHeight(); + } + } + + drawable.swapBuffers(); + Thread.sleep(50); + int j = (int) ( (long)i / (durationPerTest/(long)step) ) + 1; + if(j>step_i) { + int w = width/step * j; + int h = height/step * j; + System.err.println("resize: "+step_i+" -> "+j+" - "+w+"x"+h); + fbo_mrt.reset(gl, w, h); + winctx.window.setSize(w, h); + step_i = j; + } + } + + NEWTGLContext.destroyWindow(winctx); + } + + public static void main(String args[]) throws IOException { + System.err.println("main - start"); + for(int i=0; i "+num); + demo.setMSAA(num); + } + } + } + }); + + animator.start(); + // glWindow.setSkipContextReleaseThread(animator.getThread()); + + glWindow.setVisible(true); + + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); + System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); + System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()= 0; i--) { - immModeSink.glVertex3f((float) (radius * Math.cos(i * increment)), - (float) (radius * Math.sin(i * increment)), - 0f); - immModeSink.glVertex3f((float) (-1.0 * radius * Math.cos(i * increment)), - (float) (-1.0 * radius * Math.sin(i * increment)), - 0f); - } - immModeSink.glEnd(gl, false); - } - - public void dispose(GLAutoDrawable drawable) { - immModeSink.destroy(drawable.getGL()); - immModeSink = null; - } - - public void display(GLAutoDrawable drawable) { - GL2ES1 gl = drawable.getGL().getGL2ES1(); - if (multisample) { - gl.glEnable(GL.GL_MULTISAMPLE); - } - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - immModeSink.draw(gl, true); - if (multisample) { - gl.glDisable(GL.GL_MULTISAMPLE); - } - } - - // Unused routines - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } - - public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java index 4b0caf898..478bd4543 100755 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java @@ -40,7 +40,6 @@ package com.jogamp.opengl.test.junit.jogl.caps; -import java.io.File; import java.lang.reflect.InvocationTargetException; import java.awt.BorderLayout; import java.awt.Frame; @@ -48,14 +47,15 @@ import java.awt.Frame; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; -import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; +import com.jogamp.opengl.test.junit.jogl.demos.es1.MultisampleDemoES1; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; import org.junit.Test; @@ -75,13 +75,6 @@ public class TestMultisampleES1AWT extends UITestCase { org.junit.runner.JUnitCore.main(tstname); } - protected void snapshot(GLAutoDrawable drawable, boolean alpha, boolean flip, String filename) { - GLReadBufferUtil screenshot = new GLReadBufferUtil(alpha, false); - if(screenshot.readPixels(drawable.getGL(), drawable, flip)) { - screenshot.write(new File(filename)); - } - } - @Test public void testOnscreenMultiSampleAA0() throws InterruptedException, InvocationTargetException { testMultiSampleAAImpl(0); @@ -98,6 +91,7 @@ public class TestMultisampleES1AWT extends UITestCase { } private void testMultiSampleAAImpl(int reqSamples) throws InterruptedException, InvocationTargetException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp = GLProfile.getMaxFixedFunc(true); GLCapabilities caps = new GLCapabilities(glp); GLCapabilitiesChooser chooser = new MultisampleChooser01(); @@ -110,14 +104,11 @@ public class TestMultisampleES1AWT extends UITestCase { canvas = new GLCanvas(caps, chooser, null, null); canvas.addGLEventListener(new MultisampleDemoES1(reqSamples>0?true:false)); canvas.addGLEventListener(new GLEventListener() { + int displayCount = 0; public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { - final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); - final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_"; - final String aaext = caps.getSampleExtension(); - final int samples = caps.getSampleBuffers() ? caps.getNumSamples() : 0 ; - snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-S"+samples+"-"+aaext+"-"+drawable.getGLProfile().getName()+".png"); + snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java index 2e47b6841..ed8e2bd85 100755 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java @@ -40,21 +40,20 @@ package com.jogamp.opengl.test.junit.jogl.caps; -import java.io.File; - import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; -import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import org.junit.Test; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es1.MultisampleDemoES1; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; public class TestMultisampleES1NEWT extends UITestCase { static long durationPerTest = 60; // ms @@ -71,13 +70,6 @@ public class TestMultisampleES1NEWT extends UITestCase { org.junit.runner.JUnitCore.main(tstname); } - protected void snapshot(GLAutoDrawable drawable, boolean alpha, boolean flip, String filename) { - GLReadBufferUtil screenshot = new GLReadBufferUtil(alpha, false); - if(screenshot.readPixels(drawable.getGL(), drawable, flip)) { - screenshot.write(new File(filename)); - } - } - @Test public void testOnscreenMultiSampleAA0() throws InterruptedException { testMultiSampleAAImpl(true, 0); @@ -119,6 +111,7 @@ public class TestMultisampleES1NEWT extends UITestCase { } private void testMultiSampleAAImpl(boolean onscreen, int reqSamples) throws InterruptedException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp = GLProfile.getMaxFixedFunc(true); GLCapabilities caps = new GLCapabilities(glp); GLCapabilitiesChooser chooser = new MultisampleChooser01(); @@ -136,14 +129,11 @@ public class TestMultisampleES1NEWT extends UITestCase { window.setCapabilitiesChooser(chooser); window.addGLEventListener(new MultisampleDemoES1(reqSamples>0?true:false)); window.addGLEventListener(new GLEventListener() { + int displayCount = 0; public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { - final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); - final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_"; - final String aaext = caps.getSampleExtension(); - final int samples = caps.getSampleBuffers() ? caps.getNumSamples() : 0 ; - snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-S"+samples+"-"+aaext+"-"+drawable.getGLProfile().getName()+".png"); + snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java new file mode 100644 index 000000000..b2dad1f39 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.jogamp.opengl.test.junit.jogl.caps; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; + +public class TestMultisampleES2NEWT extends UITestCase { + static long durationPerTest = 60; // ms + private GLWindow window; + + public static void main(String[] args) { + for(int i=0; i0) { + caps.setSampleBuffers(true); + caps.setNumSamples(reqSamples); + } + + window = GLWindow.create(caps); + window.setCapabilitiesChooser(chooser); + window.addGLEventListener(new MultisampleDemoES2(reqSamples>0?true:false)); + window.addGLEventListener(new GLEventListener() { + int displayCount = 0; + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + window.setSize(512, 512); + window.setVisible(true); + window.requestFocus(); + + Thread.sleep(durationPerTest); + + window.destroy(); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java index 5c82a43c6..e81d1b4af 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java @@ -129,12 +129,13 @@ public class GearsES1 implements GLEventListener { gl.glEnable(GL2ES1.GL_NORMALIZE); - if (drawable.getNativeSurface() instanceof Window) { - Window window = (Window) drawable.getNativeSurface(); + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.addMouseListener(gearsMouse); window.addKeyListener(gearsKeys); - } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) { - java.awt.Component comp = (java.awt.Component) drawable; + } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { + final java.awt.Component comp = (java.awt.Component) upstreamWidget; new com.jogamp.newt.event.awt.AWTMouseAdapter(gearsMouse).addTo(comp); new com.jogamp.newt.event.awt.AWTKeyAdapter(gearsKeys).addTo(comp); } @@ -165,8 +166,9 @@ public class GearsES1 implements GLEventListener { public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES1.dispose ... "); - if (drawable.getNativeSurface() instanceof Window) { - Window window = (Window) drawable.getNativeSurface(); + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.removeMouseListener(gearsMouse); window.removeKeyListener(gearsKeys); } @@ -188,8 +190,9 @@ public class GearsES1 implements GLEventListener { GL2ES1 gl = drawable.getGL().getGL2ES1(); final boolean hasFocus; - if(drawable.getNativeSurface() instanceof NativeWindow) { - hasFocus = ((NativeWindow)drawable.getNativeSurface()).hasFocus(); + final Object upstreamWidget = drawable.getUpstreamWidget(); + if(upstreamWidget instanceof NativeWindow) { + hasFocus = ((NativeWindow)upstreamWidget).hasFocus(); } else { hasFocus = true; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/MultisampleDemoES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/MultisampleDemoES1.java new file mode 100644 index 000000000..aad56581b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/MultisampleDemoES1.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.es1; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES1; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; + +import com.jogamp.opengl.util.ImmModeSink; + +public class MultisampleDemoES1 implements GLEventListener { + + boolean multisample; + ImmModeSink immModeSink; + + public MultisampleDemoES1(boolean multisample) { + this.multisample = multisample; + } + + public void init(GLAutoDrawable drawable) { + System.err.println(); + System.err.println("Requested: " + drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()); + System.err.println(); + System.err.println("Chosen : " + drawable.getChosenGLCapabilities()); + System.err.println(); + GL2ES1 gl = drawable.getGL().getGL2ES1(); + if (multisample) { + gl.glEnable(GL.GL_MULTISAMPLE); + } + gl.glClearColor(0, 0, 0, 0); + // gl.glEnable(GL.GL_DEPTH_TEST); + // gl.glDepthFunc(GL.GL_LESS); + gl.glMatrixMode(GL2ES1.GL_MODELVIEW); + gl.glLoadIdentity(); + gl.glMatrixMode(GL2ES1.GL_PROJECTION); + gl.glLoadIdentity(); + gl.glOrtho(-1, 1, -1, 1, -1, 1); + if (multisample) { + gl.glDisable(GL.GL_MULTISAMPLE); + } + immModeSink = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 40, + 3, GL.GL_FLOAT, // vertex + 0, GL.GL_FLOAT, // color + 0, GL.GL_FLOAT,// normal + 0, GL.GL_FLOAT); // texture + final int numSteps = 20; + final double increment = Math.PI / numSteps; + final double radius = 1; + immModeSink.glBegin(GL.GL_LINES); + for (int i = numSteps - 1; i >= 0; i--) { + immModeSink.glVertex3f((float) (radius * Math.cos(i * increment)), + (float) (radius * Math.sin(i * increment)), + 0f); + immModeSink.glVertex3f((float) (-1.0 * radius * Math.cos(i * increment)), + (float) (-1.0 * radius * Math.sin(i * increment)), + 0f); + } + immModeSink.glEnd(gl, false); + } + + public void dispose(GLAutoDrawable drawable) { + immModeSink.destroy(drawable.getGL()); + immModeSink = null; + } + + public void display(GLAutoDrawable drawable) { + GL2ES1 gl = drawable.getGL().getGL2ES1(); + if (multisample) { + gl.glEnable(GL.GL_MULTISAMPLE); + } + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + immModeSink.draw(gl, true); + if (multisample) { + gl.glDisable(GL.GL_MULTISAMPLE); + } + } + + // Unused routines + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + } + + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java new file mode 100644 index 000000000..3dfbb4893 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java @@ -0,0 +1,309 @@ +/** + * Copyright (C) 2011 JogAmp Community. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es2; + +import java.nio.FloatBuffer; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLUniformData; +import javax.media.opengl.fixedfunc.GLMatrixFunc; + +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.TextureAttachment; +import com.jogamp.opengl.FBObject.Attachment.Type; +import com.jogamp.opengl.util.GLArrayDataServer; +import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; + +public class FBOMix2DemosES2 implements GLEventListener { + private final GearsES2 demo0; + private final RedSquareES2 demo1; + private final int swapInterval; + private int numSamples; + private boolean demo0Only; + + + private final ShaderState st; + private final PMVMatrix pmvMatrix; + + private final FBObject fbo0; + private final FBObject fbo1; + + private TextureAttachment fbo0Tex; + private TextureAttachment fbo1Tex; + + private ShaderProgram sp0; + private GLUniformData pmvMatrixUniform; + private GLArrayDataServer interleavedVBO; + private GLUniformData texUnit0; + private GLUniformData texUnit1; + + public FBOMix2DemosES2(int swapInterval) { + demo0 = new GearsES2(-1); + demo0.setIsFBOSlave(true); + demo1 = new RedSquareES2(-1); + demo1.setIsFBOSlave(true); + this.swapInterval = swapInterval; + + st = new ShaderState(); + // st.setVerbose(true); + pmvMatrix = new PMVMatrix(); + + fbo0 = new FBObject(); + fbo1 = new FBObject(); + + numSamples = 0; + demo0Only = false; + } + + public void setDemo0Only(boolean v) { + this.demo0Only = v; + } + public boolean getDemo0Only() { return demo0Only; } + + public void setMSAA(int numSamples) { + this.numSamples=numSamples; + } + public int getMSAA() { return numSamples; } + + public void setDoRotation(boolean rotate) { demo1.setDoRotation(rotate); } + + static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" }; + static final String gl2_prelude = "#version 110\n"; + + @Override + public void init(GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + + demo0.init(drawable); + demo1.init(drawable); + + final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, FBOMix2DemosES2.class, "shader", + "shader/bin", "texture01_xxx", true); + final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, FBOMix2DemosES2.class, "shader", + "shader/bin", "texture02_xxx", true); + + // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ] + int fp0Pos; + if(gl.isGLES2()) { + vp0.insertShaderSource(0, 0, es2_prelude[0]); + fp0Pos = fp0.insertShaderSource(0, 0, es2_prelude[0]); + } else { + vp0.insertShaderSource(0, 0, gl2_prelude); + fp0Pos = fp0.insertShaderSource(0, 0, gl2_prelude); + } + if(gl.isGLES2()) { + fp0Pos = fp0.insertShaderSource(0, fp0Pos, es2_prelude[1]); + } + + sp0 = new ShaderProgram(); + sp0.add(gl, vp0, System.err); + sp0.add(gl, fp0, System.err); + st.attachShaderProgram(gl, sp0, true); + + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + st.ownUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); + + interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW); + { + interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER); + interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER); + //interleavedVBO.addGLSLSubArray("mgl_Normal", 3, GL.GL_ARRAY_BUFFER); + interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER); + + FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer(); + + for(int i=0; i<4; i++) { + ib.put(s_quadVertices, i*3, 3); + ib.put(s_quadColors, i*4, 4); + //ib.put(s_cubeNormals, i*3, 3); + ib.put(s_quadTexCoords, i*2, 2); + } + } + interleavedVBO.seal(gl, true); + interleavedVBO.enableBuffer(gl, false); + st.ownAttribute(interleavedVBO, true); + + texUnit0 = new GLUniformData("mgl_Texture0", 0); + st.ownUniform(texUnit0); + st.uniform(gl, texUnit0); + texUnit1 = new GLUniformData("mgl_Texture1", 1); + st.ownUniform(texUnit1); + st.uniform(gl, texUnit1); + + st.useProgram(gl, false); + + System.err.println("**** Init"); + resetFBOs(gl, drawable); + + fbo0.attachRenderbuffer(gl, Type.DEPTH, 24); + fbo0.unbind(gl); + fbo1.attachRenderbuffer(gl, Type.DEPTH, 24); + fbo1.unbind(gl); + gl.glEnable(GL2ES2.GL_DEPTH_TEST); + + numSamples=fbo0.getNumSamples(); + } + + /** Since we switch MSAA and non-MSAA we need to take extra care, i.e. sync msaa for both FBOs ..*/ + private void resetFBOs(GL gl, GLAutoDrawable drawable) { + // remove all texture attachments, since MSAA uses just color-render-buffer + // and non-MSAA uses texture2d-buffer + fbo0.detachAllColorbuffer(gl); + fbo1.detachAllColorbuffer(gl); + + fbo0.reset(gl, drawable.getWidth(), drawable.getHeight(), numSamples); + fbo1.reset(gl, drawable.getWidth(), drawable.getHeight(), numSamples); + if(fbo0.getNumSamples() != fbo1.getNumSamples()) { + throw new InternalError("sample size mismatch: \n\t0: "+fbo0+"\n\t1: "+fbo1); + } + numSamples = fbo0.getNumSamples(); + + if(numSamples>0) { + fbo0.attachColorbuffer(gl, 0, true); + fbo1.attachColorbuffer(gl, 0, true); + fbo0Tex = fbo0.getSamplingSink(); + fbo1Tex = fbo1.getSamplingSink(); + } else { + fbo0Tex = fbo0.attachTexture2D(gl, 0, true); + fbo1Tex = fbo1.attachTexture2D(gl, 0, true); + } + } + + @Override + public void dispose(GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + demo0.dispose(drawable); + demo1.dispose(drawable); + fbo0.destroy(gl); + fbo1.destroy(gl); + st.destroy(gl); + + fbo0Tex = null; + fbo1Tex = null; + sp0 = null; + pmvMatrixUniform = null; + interleavedVBO = null; + } + + @Override + public void display(GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + + if( fbo0.getNumSamples() != numSamples ) { + System.err.println("**** NumSamples: "+fbo0.getNumSamples()+" -> "+numSamples); + resetFBOs(gl, drawable); + } + + if(0 < numSamples) { + gl.glEnable(GL.GL_MULTISAMPLE); + } + + fbo0.bind(gl); + demo0.display(drawable); + fbo0.unbind(gl); + + if(!demo0Only) { + fbo1.bind(gl); + demo1.display(drawable); + fbo1.unbind(gl); + } + + st.useProgram(gl, true); + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue()); + fbo0.use(gl, fbo0Tex); + if(!demo0Only) { + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit1.intValue()); + fbo1.use(gl, fbo1Tex); + } + interleavedVBO.enableBuffer(gl, true); + + gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); + + interleavedVBO.enableBuffer(gl, false); + fbo0.unuse(gl); + if(!demo0Only) { + fbo1.unuse(gl); + } + + st.useProgram(gl, false); + } + + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + } + + // if(drawable.getWidth() == fbo0.getWidth() && drawable.getHeight() == fbo0.getHeight() ) { + System.err.println("**** Reshape: "+width+"x"+height); + resetFBOs(gl, drawable); + //} + + fbo0.bind(gl); + demo0.reshape(drawable, x, y, width, height); + fbo0.unbind(gl); + fbo1.bind(gl); + demo1.reshape(drawable, x, y, width, height); + fbo1.unbind(gl); + + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f); + + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + + st.useProgram(gl, true); + st.uniform(gl, pmvMatrixUniform); + st.useProgram(gl, false); + + } + + private static final float[] s_quadVertices = { + -1f, -1f, 0f, // LB + 1f, -1f, 0f, // RB + -1f, 1f, 0f, // LT + 1f, 1f, 0f // RT + }; + private static final float[] s_quadColors = { + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f }; + private static final float[] s_quadTexCoords = { + 0f, 0f, // LB + 1f, 0f, // RB + 0f, 1f, // LT + 1f, 1f // RT + }; +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 6aea5bb9c..38e8a15ce 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -65,6 +65,7 @@ public class GearsES2 implements GLEventListener { private int prevMouseX, prevMouseY; private boolean isInitialized = false; + boolean isFBOSlave = false; public GearsES2(int swapInterval) { this.swapInterval = swapInterval; @@ -74,6 +75,8 @@ public class GearsES2 implements GLEventListener { this.swapInterval = 1; } + public void setIsFBOSlave(boolean v) { isFBOSlave = v; } + public void setPMVUseBackingArray(boolean pmvUseBackingArray) { this.pmvUseBackingArray = pmvUseBackingArray; } @@ -115,7 +118,6 @@ public class GearsES2 implements GLEventListener { System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); - gl.glEnable(GL.GL_CULL_FACE); gl.glEnable(GL.GL_DEPTH_TEST); st = new ShaderState(); @@ -168,13 +170,14 @@ public class GearsES2 implements GLEventListener { gear3 = new GearsObjectES2(gear3, pmvMatrix, pmvMatrixUniform, colorU); System.err.println("gear3 reused: "+gear3); } - - if (drawable.getNativeSurface() instanceof Window) { - Window window = (Window) drawable.getNativeSurface(); + + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.addMouseListener(gearsMouse); window.addKeyListener(gearsKeys); - } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) { - java.awt.Component comp = (java.awt.Component) drawable; + } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { + final java.awt.Component comp = (java.awt.Component) upstreamWidget; new com.jogamp.newt.event.awt.AWTMouseAdapter(gearsMouse).addTo(comp); new com.jogamp.newt.event.awt.AWTKeyAdapter(gearsKeys).addTo(comp); } @@ -187,7 +190,9 @@ public class GearsES2 implements GLEventListener { System.err.println(Thread.currentThread()+" GearsES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval); GL2ES2 gl = drawable.getGL().getGL2ES2(); - gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + } st.useProgram(gl, true); pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); @@ -218,8 +223,9 @@ public class GearsES2 implements GLEventListener { } isInitialized = false; System.err.println(Thread.currentThread()+" GearsES2.dispose ... "); - if (drawable.getNativeSurface() instanceof Window) { - Window window = (Window) drawable.getNativeSurface(); + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.removeMouseListener(gearsMouse); window.removeKeyListener(gearsKeys); } @@ -235,6 +241,7 @@ public class GearsES2 implements GLEventListener { colorU = null; st.destroy(gl); st = null; + System.err.println(Thread.currentThread()+" GearsES2.dispose FIN"); } @@ -246,12 +253,16 @@ public class GearsES2 implements GLEventListener { GL2ES2 gl = drawable.getGL().getGL2ES2(); final boolean hasFocus; - if(drawable.getNativeSurface() instanceof NativeWindow) { - hasFocus = ((NativeWindow)drawable.getNativeSurface()).hasFocus(); + final Object upstreamWidget = drawable.getUpstreamWidget(); + if(upstreamWidget instanceof NativeWindow) { + hasFocus = ((NativeWindow)upstreamWidget).hasFocus(); } else { hasFocus = true; } - if(hasFocus) { + + gl.glEnable(GL.GL_CULL_FACE); + + if( isFBOSlave || hasFocus ) { gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); } else { gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f); @@ -278,7 +289,9 @@ public class GearsES2 implements GLEventListener { gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f, GearsObject.green); gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f, GearsObject.blue); pmvMatrix.glPopMatrix(); - st.useProgram(gl, false); + st.useProgram(gl, false); + + gl.glDisable(GL.GL_CULL_FACE); } boolean confinedFixedCenter = false; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java new file mode 100644 index 000000000..5facc1a49 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.es2; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLUniformData; +import javax.media.opengl.fixedfunc.GLMatrixFunc; + +import com.jogamp.opengl.util.ImmModeSink; +import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; + +public class MultisampleDemoES2 implements GLEventListener { + + private boolean multisample; + private final ShaderState st; + private final PMVMatrix pmvMatrix; + private ShaderProgram sp0; + private GLUniformData pmvMatrixUniform; + private ImmModeSink immModeSink; + + public MultisampleDemoES2(boolean multisample) { + this.multisample = multisample; + st = new ShaderState(); + st.setVerbose(true); + pmvMatrix = new PMVMatrix(); + } + + static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" }; + static final String gl2_prelude = "#version 110\n"; + + public void init(GLAutoDrawable glad) { + final GL2ES2 gl = glad.getGL().getGL2ES2(); + System.err.println(); + System.err.println("Requested: " + glad.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()); + System.err.println(); + System.err.println("Chosen : " + glad.getChosenGLCapabilities()); + System.err.println(); + + final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, MultisampleDemoES2.class, "shader", + "shader/bin", "mgl_default_xxx", true); + final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, MultisampleDemoES2.class, "shader", + "shader/bin", "mgl_default_xxx", true); + + // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ] + int fp0Pos; + if(gl.isGLES2()) { + vp0.insertShaderSource(0, 0, es2_prelude[0]); + fp0Pos = fp0.insertShaderSource(0, 0, es2_prelude[0]); + } else { + vp0.insertShaderSource(0, 0, gl2_prelude); + fp0Pos = fp0.insertShaderSource(0, 0, gl2_prelude); + } + if(gl.isGLES2()) { + fp0Pos = fp0.insertShaderSource(0, fp0Pos, es2_prelude[1]); + } + + sp0 = new ShaderProgram(); + sp0.add(gl, vp0, System.err); + sp0.add(gl, fp0, System.err); + st.attachShaderProgram(gl, sp0, true); + + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + st.ownUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); + + // Using predef array names, see + // GLPointerFuncUtil.getPredefinedArrayIndexName(glArrayIndex); + immModeSink = ImmModeSink.createGLSL(gl, GL.GL_STATIC_DRAW, 40, + 3, GL.GL_FLOAT, // vertex + 4, GL.GL_FLOAT, // color + 0, GL.GL_FLOAT,// normal + 0, GL.GL_FLOAT); // texture + final int numSteps = 20; + final double increment = Math.PI / numSteps; + final double radius = 1; + immModeSink.glBegin(GL.GL_LINES); + for (int i = numSteps - 1; i >= 0; i--) { + immModeSink.glVertex3f((float) (radius * Math.cos(i * increment)), + (float) (radius * Math.sin(i * increment)), + 0f); + immModeSink.glColor4f( 1f, 1f, 1f, 1f ); + immModeSink.glVertex3f((float) (-1.0 * radius * Math.cos(i * increment)), + (float) (-1.0 * radius * Math.sin(i * increment)), + 0f); + immModeSink.glColor4f( 1f, 1f, 1f, 1f ); + } + immModeSink.glEnd(gl, false); + + st.useProgram(gl, false); + } + + public void dispose(GLAutoDrawable glad) { + final GL2ES2 gl = glad.getGL().getGL2ES2(); + immModeSink.destroy(gl); + immModeSink = null; + st.destroy(gl); + } + + public void display(GLAutoDrawable glad) { + final GL2ES2 gl = glad.getGL().getGL2ES2(); + if (multisample) { + gl.glEnable(GL.GL_MULTISAMPLE); + } + gl.glClearColor(0, 0, 0, 0); + // gl.glEnable(GL.GL_DEPTH_TEST); + // gl.glDepthFunc(GL.GL_LESS); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + + st.useProgram(gl, true); + + immModeSink.draw(gl, true); + + st.useProgram(gl, false); + } + + // Unused routines + public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { + System.err.println("reshape .."); + final GL2ES2 gl = glad.getGL().getGL2ES2(); + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + // pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f); + pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f); + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + + st.useProgram(gl, true); + st.uniform(gl, pmvMatrixUniform); + st.useProgram(gl, false); + } + + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index 6982d61b7..436c44759 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -27,9 +27,9 @@ */ package com.jogamp.opengl.test.junit.jogl.demos.es2; +import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; @@ -37,10 +37,8 @@ import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; -import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLRunnable; import javax.media.opengl.GLUniformData; public class RedSquareES2 implements GLEventListener { @@ -52,10 +50,11 @@ public class RedSquareES2 implements GLEventListener { long t0; private int swapInterval = 0; MyMouseAdapter myMouse = new MyMouseAdapter(); - GLWindow glWindow = null; + Window window = null; float aspect = 1.0f; boolean doRotate = true; boolean isInitialized = false; + boolean isFBOSlave = false; public RedSquareES2(int swapInterval) { this.swapInterval = swapInterval; @@ -65,6 +64,7 @@ public class RedSquareES2 implements GLEventListener { this.swapInterval = 1; } + public void setIsFBOSlave(boolean v) { isFBOSlave = v; } public void setAspect(float aspect) { this.aspect = aspect; } public void setDoRotation(boolean rotate) { this.doRotate = rotate; } @@ -129,13 +129,13 @@ public class RedSquareES2 implements GLEventListener { colors.enableBuffer(gl, false); // OpenGL Render Settings - gl.glClearColor(0, 0, 0, 0); gl.glEnable(GL2ES2.GL_DEPTH_TEST); st.useProgram(gl, false); - if (glad instanceof GLWindow) { - glWindow = (GLWindow) glad; - glWindow.addMouseListener(myMouse); + final Object upstreamWidget = glad.getUpstreamWidget(); + if (!isFBOSlave && upstreamWidget instanceof Window) { + window = (Window) upstreamWidget; + window.addMouseListener(myMouse); } t0 = System.currentTimeMillis(); System.err.println(Thread.currentThread()+" RedSquareES2.init FIN"); @@ -145,6 +145,7 @@ public class RedSquareES2 implements GLEventListener { long t1 = System.currentTimeMillis(); GL2ES2 gl = glad.getGL().getGL2ES2(); + gl.glClearColor(0, 0, 0, 0); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); st.useProgram(gl, true); // One rotation every four seconds @@ -171,7 +172,9 @@ public class RedSquareES2 implements GLEventListener { System.err.println(Thread.currentThread()+" RedSquareES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval); GL2ES2 gl = glad.getGL().getGL2ES2(); - gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + } st.useProgram(gl, true); // Set location in front of camera @@ -192,9 +195,9 @@ public class RedSquareES2 implements GLEventListener { } isInitialized = false; System.err.println(Thread.currentThread()+" RedSquareES2.dispose ... "); - if (null != glWindow) { - glWindow.removeMouseListener(myMouse); - glWindow = null; + if (null != window) { + window.removeMouseListener(myMouse); + window = null; } GL2ES2 gl = glad.getGL().getGL2ES2(); st.destroy(gl); @@ -207,24 +210,9 @@ public class RedSquareES2 implements GLEventListener { class MyMouseAdapter extends MouseAdapter { public void mouseClicked(MouseEvent e) { System.err.println(e); - if(null != glWindow && e.getSource() == glWindow.getDelegatedWindow()) { - if(e.getX() < glWindow.getWidth()/2) { - glWindow.setFullscreen(!glWindow.isFullscreen()); - System.err.println("setFullscreen: "+glWindow.isFullscreen()); - } else { - glWindow.invoke(false, new GLRunnable() { - public boolean run(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); - gl.setSwapInterval(gl.getSwapInterval()<=0?1:0); - System.err.println("setSwapInterval: "+gl.getSwapInterval()); - final GLAnimatorControl a = drawable.getAnimator(); - if( null != a ) { - a.resetFPSCounter(); - } - return true; - } - }); - } + if(null != window && e.getSource() == window) { + window.setFullscreen(!window.isFullscreen()); + System.err.println("setFullscreen: "+window.isFullscreen()); } } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index b04bd07c1..9217e2b53 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -265,11 +265,12 @@ public class TextureSequenceCubeES2 implements GLEventListener { st.useProgram(gl, false); - if (drawable instanceof Window) { - Window window = (Window) drawable; + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.addMouseListener(mouseAction); - } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) { - java.awt.Component comp = (java.awt.Component) drawable; + } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { + final java.awt.Component comp = (java.awt.Component) upstreamWidget; new com.jogamp.newt.event.awt.AWTMouseAdapter(mouseAction).addTo(comp); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index 0b83aacd8..7f2713354 100755 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -163,8 +163,9 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { mPlayer.start(); boolean added; - if (drawable instanceof Window) { - Window window = (Window) drawable; + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.addKeyListener(keyAction); added = true; } else { added = false; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index 8210065ab..e17c9e88b 100755 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -400,8 +400,9 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { startTime = System.currentTimeMillis(); - if (drawable instanceof Window) { - Window window = (Window) drawable; + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.addMouseListener(mouseAction); winWidth = window.getWidth(); winHeight = window.getHeight(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 04563d62e..797a16485 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -258,7 +258,6 @@ public class TestGearsES2NEWT extends UITestCase { public static void main(String args[]) throws IOException { int x=0, y=0, w=640, h=480; - boolean useSize = false; boolean usePos = false; for(int i=0; i= height. + * + * Draws the Gears demo in a window that's twice as wide than it is tall, + * and checks to see if a particular pixel in the right half of the frame + * is colored. + * + * @author Wade Walker (adapted from TestGearsGLJPanelAWT) + */ +public class TestGLJPanelAWTBug450 extends UITestCase { + static GLProfile glp; + static int width, height; + static int r_x, r_y; + /** Set this if test fails. Needed because we can't throw an exception + * all the way up the stack from where we test the pixel. */ + static boolean failed; + + @BeforeClass + public static void initClass() { + glp = GLProfile.getGL2ES2(); + Assert.assertNotNull(glp); + height = 256; + width = 2*height; + r_x = 5*height/4; // 5/8 * width + r_y = height/2; + } + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL(GLCapabilities caps) + throws AWTException, InterruptedException, InvocationTargetException + { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); + JFrame frame = new JFrame("Swing GLJPanel"); + Assert.assertNotNull(frame); + + GLJPanel glJPanel = new GLJPanel(caps); + Assert.assertNotNull(glJPanel); + RedSquareES2 demo = new RedSquareES2(); + demo.setAspect((float)width/(float)height); + demo.setDoRotation(false); + glJPanel.addGLEventListener(demo); + glJPanel.addGLEventListener(new GLEventListener() { + int f = 0; + @Override + public void init(GLAutoDrawable drawable) { + // drawable.getGL().glClearColor(0, 0, 1, 1); + } + @Override + public void display(GLAutoDrawable drawable) { + // look at one pixel at the bottom of the frame, just right of + // the center line, and make sure it's not black + GL2 gl = GLUgl2.getCurrentGL2(); + ByteBuffer bytebuffer = ByteBuffer.allocateDirect( 3 ); + gl.glReadPixels( r_x, r_y, 1, 1, GL2.GL_BGR, GL2.GL_UNSIGNED_BYTE, bytebuffer ); + byte byte0 = bytebuffer.get( 0 ); + byte byte1 = bytebuffer.get( 1 ); + byte byte2 = bytebuffer.get( 2 ); + if( (byte0 == 0) && (byte1 == 0) && (byte2 == 0) ) { + failed = true; + } + if(0 == f) { + System.err.println("BGR ("+r_x+"/"+r_y+"): "+byte0+", "+byte1+", "+byte2+" - OK "+(!failed)); + snapshot(getSimpleTestName("."), f, null, gl, screenshot, TextureIO.PNG, null); + } + f++; + } + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + + FPSAnimator animator = new FPSAnimator(glJPanel, 60); + + final JFrame _frame = frame; + final GLJPanel _glJPanel = glJPanel; + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + _frame.getContentPane().add(_glJPanel, BorderLayout.CENTER); + _frame.setSize(width, height); + _frame.setVisible(true); + } } ) ; + + animator.setUpdateFPSFrames(1, null); + animator.start(); + Assert.assertEquals(true, animator.isAnimating()); + + while(animator.isAnimating() && animator.getTotalFPSDuration()= height. - * - * Draws the Gears demo in a window that's twice as wide than it is tall, - * and checks to see if a particular pixel in the right half of the frame - * is colored. - * - * @author Wade Walker (adapted from TestGearsGLJPanelAWT) - */ -public class TestGearsGLJPanelAWTBug450 extends UITestCase { - static GLProfile glp; - static int width, height; - static int r_x, r_y; - /** Set this if test fails. Needed because we can't throw an exception - * all the way up the stack from where we test the pixel. */ - static boolean failed; - - @BeforeClass - public static void initClass() { - glp = GLProfile.getGL2ES2(); - Assert.assertNotNull(glp); - height = 256; - width = 2*height; - r_x = 5*height/4; // 5/8 * width - r_y = height/2; - } - - @AfterClass - public static void releaseClass() { - } - - protected void snapshot(GLAutoDrawable drawable, boolean alpha, boolean flip, String filename) { - GLReadBufferUtil screenshot = new GLReadBufferUtil(alpha, false); - if(screenshot.readPixels(drawable.getGL(), drawable, flip)) { - screenshot.write(new File(filename)); - } - } - - protected void runTestGL(GLCapabilities caps) - throws AWTException, InterruptedException, InvocationTargetException - { - JFrame frame = new JFrame("Swing GLJPanel"); - Assert.assertNotNull(frame); - - GLJPanel glJPanel = new GLJPanel(caps); - Assert.assertNotNull(glJPanel); - RedSquareES2 demo = new RedSquareES2(); - demo.setAspect((float)width/(float)height); - demo.setDoRotation(false); - glJPanel.addGLEventListener(demo); - glJPanel.addGLEventListener(new GLEventListener() { - int f = 0; - @Override - public void init(GLAutoDrawable drawable) { - // drawable.getGL().glClearColor(0, 0, 1, 1); - } - @Override - public void display(GLAutoDrawable drawable) { - // look at one pixel at the bottom of the frame, just right of - // the center line, and make sure it's not black - GL2 gl = GLUgl2.getCurrentGL2(); - ByteBuffer bytebuffer = ByteBuffer.allocateDirect( 3 ); - gl.glReadPixels( r_x, r_y, 1, 1, GL2.GL_BGR, GL2.GL_UNSIGNED_BYTE, bytebuffer ); - byte byte0 = bytebuffer.get( 0 ); - byte byte1 = bytebuffer.get( 1 ); - byte byte2 = bytebuffer.get( 2 ); - if( (byte0 == 0) && (byte1 == 0) && (byte2 == 0) ) { - failed = true; - } - if(0 == f) { - System.err.println("BGR ("+r_x+"/"+r_y+"): "+byte0+", "+byte1+", "+byte2+" - OK "+(!failed)); - snapshot(drawable, true, false, getSimpleTestName(".")+".png"); - } - f++; - } - @Override - public void dispose(GLAutoDrawable drawable) {} - @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } - }); - - FPSAnimator animator = new FPSAnimator(glJPanel, 60); - - final JFrame _frame = frame; - final GLJPanel _glJPanel = glJPanel; - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - _frame.getContentPane().add(_glJPanel, BorderLayout.CENTER); - _frame.setSize(width, height); - _frame.setVisible(true); - } } ) ; - - animator.setUpdateFPSFrames(1, null); - animator.start(); - Assert.assertEquals(true, animator.isAnimating()); - - while(animator.isAnimating() && animator.getTotalFPSDuration() buffer0, Green -> buffer1 - st.attachShaderProgram(gl, sp0, true); - vertices0.enableBuffer(gl, true); - colors0.enableBuffer(gl, true); - - fbo_mrt.bind(gl); - gl.glDrawBuffers(2, two_buffers, 0); - gl.glViewport(0, 0, fbo_mrt.getWidth(), fbo_mrt.getHeight()); - - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); - fbo_mrt.unbind(gl); - vertices0.enableBuffer(gl, false); - colors0.enableBuffer(gl, false); - - // pass 2 - mix buffer0, buffer1 and blue - // rg = buffer0.rg + buffer1.rg, b = Blue - length(rg); - st.attachShaderProgram(gl, sp1, true); - vertices0.enableBuffer(gl, true); - colors0.enableBuffer(gl, true); - texCoords0.enableBuffer(gl, true); - gl.glDrawBuffers(1, bck_buffers, 0); - - gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); - fbo_mrt.use(gl, 0); - fbo_mrt.use(gl, 1); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); - fbo_mrt.unuse(gl); - vertices0.enableBuffer(gl, false); - colors0.enableBuffer(gl, false); - texCoords0.enableBuffer(gl, false); - - drawable.swapBuffers(); - Thread.sleep(50); - } - - NEWTGLContext.destroyWindow(winctx); - } - - public static void main(String args[]) throws IOException { - System.err.println("main - start"); - for(int i=0; i 0 ? "rgba" : "rgb_"; - snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); - snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); + snapshot(getSimpleTestName("."), f, null, drawable.getGL(), screenshotRGBA, TextureIO.PNG, null); + snapshot(getSimpleTestName("."), f, null, drawable.getGL(), screenshotRGB, TextureIO.PNG, null); + f++; } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java index b5b12035d..5681df0ad 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java @@ -28,8 +28,6 @@ package com.jogamp.opengl.test.junit.jogl.util.texture; -import java.io.File; - import com.jogamp.newt.opengl.GLWindow; import javax.media.opengl.GLAutoDrawable; @@ -37,6 +35,7 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -62,32 +61,26 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase { height = 256; } - protected void snapshot(GLAutoDrawable drawable, boolean alpha, boolean flip, String filename) { - GLReadBufferUtil screenshot = new GLReadBufferUtil(alpha, false); - if(screenshot.readPixels(drawable.getGL(), drawable, flip)) { - screenshot.write(new File(filename)); - } - } - @Test public void testOnscreenWritePNG_TGA_PAM() throws InterruptedException { + final GLReadBufferUtil screenshotRGB = new GLReadBufferUtil(false, false); + final GLReadBufferUtil screenshotRGBA = new GLReadBufferUtil(true, false); GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Shared Gears NEWT Test"); glWindow.setSize(width, height); glWindow.addGLEventListener(new GearsES2(1)); glWindow.addGLEventListener(new GLEventListener() { + int f = 0; public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { - final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; - // snapshot(drawable, false, true, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".ppm"); - snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); - snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".tga"); - snapshot(drawable, true, true, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".pam"); - snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); - snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".tga"); - snapshot(drawable, false, true, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".pam"); + snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGBA, TextureIO.PNG, null); + snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGB, TextureIO.PNG, null); + snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGBA, TextureIO.TGA, null); + snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGB, TextureIO.TGA, null); + snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGBA, TextureIO.PAM, null); + snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGB, TextureIO.PAM, null); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); @@ -98,18 +91,21 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase { @Test public void testOffscreenWritePNG() throws InterruptedException { + final GLReadBufferUtil screenshotRGB = new GLReadBufferUtil(false, false); + final GLReadBufferUtil screenshotRGBA = new GLReadBufferUtil(true, false); final GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, true, false); GLWindow glWindow = GLWindow.create(caps2); Assert.assertNotNull(glWindow); glWindow.setSize(width, height); glWindow.addGLEventListener(new GearsES2(1)); glWindow.addGLEventListener(new GLEventListener() { + int f = 0; public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { - final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; - snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); - snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); + snapshot(getSimpleTestName("."), f, null, drawable.getGL(), screenshotRGBA, TextureIO.PNG, null); + snapshot(getSimpleTestName("."), f, null, drawable.getGL(), screenshotRGB, TextureIO.PNG, null); + f++; } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java index 10dd4ea70..43641fe6d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java @@ -30,9 +30,6 @@ package com.jogamp.opengl.test.junit.jogl.util.texture; import java.awt.Dimension; import java.awt.Frame; -import java.io.File; -import java.io.PrintWriter; -import java.io.StringWriter; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; @@ -45,6 +42,7 @@ import jogamp.nativewindow.jawt.JAWTUtil; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -71,20 +69,6 @@ public class TestGLReadBufferUtilTextureIOWrite02AWT extends UITestCase { height = 64; } - protected void snapshot(GLAutoDrawable drawable, GLReadBufferUtil screenshot, int i) { - final StringWriter filename = new StringWriter(); - { - final PrintWriter pw = new PrintWriter(filename); - final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; - pw.printf("%s-F_rgba-I_%s-%s-n%03d-%04dx%04d.png", - getSimpleTestName("."), pfmt, drawable.getGLProfile().getName(), i, drawable.getWidth(), drawable.getHeight()); - } - drawable.getGL().glFinish(); // poor mans sync .. - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { - screenshot.write(new File(filename.toString())); - } - } - protected void testWritePNGWithResizeImpl(boolean offscreenLayer) throws InterruptedException { if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { System.err.println("onscreen layer n/a"); @@ -127,7 +111,7 @@ public class TestGLReadBufferUtilTextureIOWrite02AWT extends UITestCase { if(snap) { System.err.println("XXX: ["+fw_old+", "+dw_old+"], "+fw+"x"+fh+", "+dw+"x"+dh+", sz_changed "+sz_changed+", snap "+snap); c=0; - snapshot(drawable, screenshot, i++); + snapshot(getSimpleTestName("."), i++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); dw_old = dw; fw_old = fw; Threading.invoke(true, new Runnable() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java index ed0791f7c..d1ffa84cf 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java @@ -28,10 +28,6 @@ package com.jogamp.opengl.test.junit.jogl.util.texture; -import java.io.File; -import java.io.PrintWriter; -import java.io.StringWriter; - import com.jogamp.newt.opengl.GLWindow; import javax.media.opengl.GLAutoDrawable; @@ -41,6 +37,7 @@ import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -66,19 +63,6 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase { height = 64; } - protected void snapshot(GLAutoDrawable drawable, GLReadBufferUtil screenshot, int i) { - final StringWriter filename = new StringWriter(); - { - final PrintWriter pw = new PrintWriter(filename); - final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; - pw.printf("%s-F_rgba-I_%s-%s-n%03d-%04dx%04d.png", - getSimpleTestName("."), pfmt, drawable.getGLProfile().getName(), i, drawable.getWidth(), drawable.getHeight()); - } - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { - screenshot.write(new File(filename.toString())); - } - } - private void testWritePNGWithResizeImpl(boolean offscreen) throws InterruptedException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); final GLCapabilities caps2 = offscreen ? WindowUtilNEWT.fixCaps(caps, false, true, false) : caps; @@ -110,7 +94,7 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase { if(snap) { System.err.println("XXX: ["+dw_old+"], "+dw+"x"+dh+", sz_changed "+sz_changed+", snap "+snap); c=0; - snapshot(drawable, screenshot, i++); + snapshot(getSimpleTestName("."), i++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); dw_old = dw; new Thread() { @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java index 068732696..0d4f2b01e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java @@ -52,7 +52,6 @@ import com.jogamp.opengl.util.GLReadBufferUtil; import java.awt.Dimension; import java.awt.Frame; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URLConnection; @@ -96,16 +95,10 @@ public class TestPNGTextureFromFileAWT extends UITestCase { testTextureStream = null; } - protected void snapshot(GLAutoDrawable drawable, String filename) { - GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { - screenshot.write(new File(filename)); - } - } - public void testImpl(boolean useFFP, final InputStream istream, final boolean useAWTIIOP) throws InterruptedException, IOException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp; if(useFFP && GLProfile.isAvailable(GLProfile.GL2GL3)) { glp = GLProfile.getGL2GL3(); @@ -137,7 +130,7 @@ public class TestPNGTextureFromFileAWT extends UITestCase { // the bug submitter was doing it final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData ) ; glc.addGLEventListener(gle); - glc.addGLEventListener(new GLEventListener() { + glc.addGLEventListener(new GLEventListener() { boolean shot = false; @Override public void init(GLAutoDrawable drawable) {} @@ -147,7 +140,7 @@ public class TestPNGTextureFromFileAWT extends UITestCase { // 1 snapshot if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) { shot = true; - snapshot(drawable, getSimpleTestName(".")+".png"); + snapshot(getSimpleTestName("."), 0, null, drawable.getGL(), screenshot, TextureIO.PNG, null); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java index d973dea2d..b4faafbe7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java @@ -48,7 +48,6 @@ import com.jogamp.opengl.util.texture.TextureIO; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URLConnection; @@ -80,14 +79,8 @@ public class TestPNGTextureFromFileNEWT extends UITestCase { testTextureStream = null; } - protected void snapshot(GLAutoDrawable drawable, String filename) { - GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { - screenshot.write(new File(filename)); - } - } - public void testImpl(boolean useFFP, final InputStream istream) throws InterruptedException, IOException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp; if(useFFP && GLProfile.isAvailable(GLProfile.GL2GL3)) { glp = GLProfile.getGL2GL3(); @@ -119,7 +112,7 @@ public class TestPNGTextureFromFileNEWT extends UITestCase { // 1 snapshot if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) { shot = true; - snapshot(drawable, getSimpleTestName(".")+".png"); + snapshot(getSimpleTestName("."), 0, null, drawable.getGL(), screenshot, TextureIO.PNG, null); } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java index 672675fab..c07d5b741 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java +++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java @@ -28,7 +28,17 @@ package com.jogamp.opengl.test.junit.util; +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; + +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLDrawable; + import com.jogamp.common.util.locks.SingletonInstance; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; import org.junit.Assume; import org.junit.Before; @@ -108,6 +118,49 @@ public abstract class UITestCase { } static final String unsupportedTestMsg = "Test not supported on this platform."; - + + /** + * Takes a snapshot of the drawable's current framebuffer. Example filenames: + *
    +     * TestFBODrawableNEWT.test01-F_rgba-I_rgba-S0_default-GL2-n0004-0800x0600.png
    +     * TestFBODrawableNEWT.test01-F_rgba-I_rgba-S0_default-GL2-n0005-0800x0600.png
    +     * 
    + * + * @param simpleTestName will be used as the filename prefix + * @param sn sequential number + * @param postSNDetail optional detail to be added to the filename after sn + * @param gl the current GL context object. It's read drawable is being used as the pixel source and to gather some details which will end up in the filename. + * @param readBufferUtil the {@link GLReadBufferUtil} to be used to read the pixels for the screenshot. + * @param fileSuffix Optional file suffix without a dot defining the file type, i.e. "png". + * If null the "png" as defined in {@link TextureIO#PNG} is being used. + * @param destPath Optional platform dependent file path. It shall use {@link File#separatorChar} as is directory separator. + * It shall not end with a directory separator, {@link File#separatorChar}. + * If null the current working directory is being used. + */ + public static void snapshot(String simpleTestName, int sn, String postSNDetail, GL gl, GLReadBufferUtil readBufferUtil, String fileSuffix, String destPath) { + if(null == fileSuffix) { + fileSuffix = TextureIO.PNG; + } + final StringWriter filenameSW = new StringWriter(); + { + final GLDrawable drawable = gl.getContext().getGLReadDrawable(); + final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); + final String F_pfmt = readBufferUtil.hasAlpha() ? "rgba" : "rgb_"; + final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_"; + final String aaext = caps.getSampleExtension(); + final int samples = caps.getNumSamples() ; + postSNDetail = null != postSNDetail ? "-"+postSNDetail : ""; + final PrintWriter pw = new PrintWriter(filenameSW); + pw.printf("%s-n%04d%s-F_%s-I_%s-S%d_%s-%s-%04dx%04d.%s", + simpleTestName, sn, postSNDetail, F_pfmt, pfmt, samples, aaext, drawable.getGLProfile().getName(), + drawable.getWidth(), drawable.getHeight(), fileSuffix); + } + final String filename = null != destPath ? destPath + File.separator + filenameSW.toString() : filenameSW.toString(); + System.err.println(Thread.currentThread().getName()+": ** screenshot: "+filename); + gl.glFinish(); // just make sure rendering finished .. + if(readBufferUtil.readPixels(gl, false)) { + readBufferUtil.write(new File(filename)); + } + } } -- cgit v1.2.3 From 2da0d69fec6209c55832f5aae9d365e25d3aba6d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 20 Jul 2012 12:46:35 +0200 Subject: Fix NEWT exception handling in event dispatching: Catch and fwd to caller Exceptions caused by NEWTEvent processing (on it's EDT) were not propagated to the caller (diff thread). Hence the EDT were brought down and the caller may have waited forever (deadlock). Catch exception if caller waits and throw exception at waiting point. --- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 2 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 56 ++++++++++++++-------- .../classes/jogamp/newt/event/NEWTEventTask.java | 13 +++-- 3 files changed, 47 insertions(+), 24 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index fd757fba6..bdbe96070 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -340,7 +340,7 @@ public class DefaultEDTUtil implements EDTUtil { } } if(DEBUG) { - System.err.println(getName()+": EDT run() EXIT "+ getName()+", "+error); + System.err.println(getName()+": EDT run() EXIT "+ getName()+", exception: "+error); } if(null!=error) { throw error; diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index a0bbcc264..b10561c5b 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -355,24 +355,39 @@ public abstract class DisplayImpl extends Display { DispatchMessagesRunnable dispatchMessagesRunnable = new DispatchMessagesRunnable(); final void dispatchMessage(final NEWTEventTask eventTask) { - NEWTEvent event = eventTask.get(); - if(null == event) { - // Ooops ? - System.err.println("Warning: event of eventTask is NULL"); - Thread.dumpStack(); - return; - } - Object source = event.getSource(); - if(source instanceof NEWTEventConsumer) { - NEWTEventConsumer consumer = (NEWTEventConsumer) source ; - if(!consumer.consumeEvent(event)) { - // enqueue for later execution - enqueueEvent(false, event); + final NEWTEvent event = eventTask.get(); + try { + if(null == event) { + // Ooops ? + System.err.println("Warning: event of eventTask is NULL"); + Thread.dumpStack(); + return; + } + final Object source = event.getSource(); + if(source instanceof NEWTEventConsumer) { + final NEWTEventConsumer consumer = (NEWTEventConsumer) source ; + if(!consumer.consumeEvent(event)) { + // enqueue for later execution + enqueueEvent(false, event); + } + } else { + throw new RuntimeException("Event source not NEWT: "+source.getClass().getName()+", "+source); + } + } catch (Throwable t) { + final RuntimeException re; + if(t instanceof RuntimeException) { + re = (RuntimeException) t; + } else { + re = new RuntimeException(t); + } + if( eventTask.isCallerWaiting() ) { + // propagate exception to caller + eventTask.setException(re); + } else { + throw re; } - } else { - throw new RuntimeException("Event source not NEWT: "+source.getClass().getName()+", "+source); } - eventTask.notifyIssuer(); + eventTask.notifyCaller(); } public void dispatchMessages() { @@ -423,8 +438,8 @@ public abstract class DisplayImpl extends Display { return; } - Object lock = new Object(); - NEWTEventTask eTask = new NEWTEventTask(e, wait?lock:null); + final Object lock = new Object(); + final NEWTEventTask eTask = new NEWTEventTask(e, wait?lock:null); synchronized(lock) { synchronized(eventsLock) { events.add(eTask); @@ -437,7 +452,10 @@ public abstract class DisplayImpl extends Display { } catch (InterruptedException ie) { throw new RuntimeException(ie); } - } + if( null != eTask.getException() ) { + throw eTask.getException(); + } + } } } diff --git a/src/newt/classes/jogamp/newt/event/NEWTEventTask.java b/src/newt/classes/jogamp/newt/event/NEWTEventTask.java index fae6560b4..93d5e2fb9 100644 --- a/src/newt/classes/jogamp/newt/event/NEWTEventTask.java +++ b/src/newt/classes/jogamp/newt/event/NEWTEventTask.java @@ -35,17 +35,22 @@ import com.jogamp.newt.event.NEWTEvent; * which notifies after sending the event for the invokeAndWait() semantics. */ public class NEWTEventTask { - NEWTEvent event; - Object notifyObject; + private NEWTEvent event; + private Object notifyObject; + private RuntimeException exception; public NEWTEventTask(NEWTEvent event, Object notifyObject) { this.event = event ; this.notifyObject = notifyObject ; + this.exception = null; } - public NEWTEvent get() { return event; } + public final NEWTEvent get() { return event; } + public final void setException(RuntimeException e) { exception = e; } + public final RuntimeException getException() { return exception; } + public final boolean isCallerWaiting() { return null != notifyObject; } - public void notifyIssuer() { + public void notifyCaller() { if(null != notifyObject) { synchronized (notifyObject) { notifyObject.notifyAll(); -- cgit v1.2.3 From 209a5ac217b591991d520789313eb4f819da89d2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 20 Jul 2012 14:09:04 +0200 Subject: Minor edits --- src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 11 ++++++----- .../jogl/awt/TestAWTCardLayoutAnimatorStartStopBug532.java | 11 ++++------- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index c50ab77c4..32d44502f 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -431,7 +431,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind @Override public synchronized void destroyActionInLock() { if(Window.DEBUG_IMPLEMENTATION) { - String msg = "GLWindow.destroy() "+Thread.currentThread()+", start"; + String msg = "GLWindow.destroy() "+WindowImpl.getThreadName()+", start"; System.err.println(msg); //Exception e1 = new Exception(msg); //e1.printStackTrace(); @@ -440,14 +440,14 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind defaultDestroyOp(); if(Window.DEBUG_IMPLEMENTATION) { - System.err.println("GLWindow.destroy() "+Thread.currentThread()+", fin"); + System.err.println("GLWindow.destroy() "+WindowImpl.getThreadName()+", fin"); } } @Override public synchronized void resetCounter() { if(Window.DEBUG_IMPLEMENTATION) { - System.err.println("GLWindow.resetCounter() "+Thread.currentThread()); + System.err.println("GLWindow.resetCounter() "+WindowImpl.getThreadName()); } GLWindow.this.resetFPSCounter(); } @@ -457,7 +457,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind long t0; if(Window.DEBUG_IMPLEMENTATION) { t0 = System.nanoTime(); - System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", start"); + System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+WindowImpl.getThreadName()+", start"); } else { t0 = 0; } @@ -484,7 +484,8 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind context.setContextCreationFlags(additionalCtxCreationFlags); } if(Window.DEBUG_IMPLEMENTATION) { - System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", fin: dt "+ (System.nanoTime()-t0)/1e6 +"ms"); + System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+WindowImpl.getThreadName()+", fin: dt "+ (System.nanoTime()-t0)/1e6 +"ms"); + Thread.dumpStack(); // JAU } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWTCardLayoutAnimatorStartStopBug532.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWTCardLayoutAnimatorStartStopBug532.java index 8384e5b61..3f6935588 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWTCardLayoutAnimatorStartStopBug532.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWTCardLayoutAnimatorStartStopBug532.java @@ -9,11 +9,8 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.lang.reflect.InvocationTargetException; -import javax.media.nativewindow.NativeWindow; import javax.media.opengl.GLAnimatorControl; -import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; import javax.swing.JComboBox; @@ -21,11 +18,8 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; -import jogamp.nativewindow.windows.GDI; - import org.junit.Test; -import com.jogamp.common.os.Platform; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -83,7 +77,7 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { canvas.setPreferredSize(new Dimension(640, 480)); final GLAnimatorControl animatorCtrl = useFPSAnimator ? new FPSAnimator(canvas, 60) : new Animator(canvas); - animatorCtrl.setUpdateFPSFrames(60, System.err); + animatorCtrl.setUpdateFPSFrames(60, null);// System.err); switch (animCtrl) { case PauseResume: animatorCtrl.start(); @@ -92,6 +86,7 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { case Continue: animatorCtrl.start(); break; + default: } canvas.addGLEventListener(new GearsES2(1)); @@ -141,6 +136,7 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { case PauseResume: animatorCtrl.resume(); break; + default: } selected = CANVAS; } else if(newSelection.equals(LABEL)) { @@ -151,6 +147,7 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { case PauseResume: animatorCtrl.pause(); break; + default: } cl.show(cards, LABEL); selected = LABEL; -- cgit v1.2.3 From 06b6a74f4915a539f6025112a82e517d8e8cb7af Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 20 Jul 2012 14:48:52 +0200 Subject: Fix TestFocus01SwingAWTRobot failure duer to RedSquareES2's setFullscreen() toggle mouse adapter :) Moved the fullscreen toggle mouse adapter to main test class. --- src/newt/classes/jogamp/newt/WindowImpl.java | 3 +-- .../test/junit/jogl/demos/es2/RedSquareES2.java | 24 +--------------------- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 8 ++++++++ 3 files changed, 10 insertions(+), 25 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index e49f91abd..002144b2f 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1805,8 +1805,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public boolean setFullscreen(boolean fullscreen) { synchronized(fullScreenAction) { if( fullScreenAction.init(fullscreen) ) { - if(fullScreenAction.fsOn() && - isOffscreenInstance(WindowImpl.this, parentWindow)) { + if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { // enable fullscreen on offscreen instance if(null != parentWindow) { nfs_parent = parentWindow; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index 436c44759..a956fe1e4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -28,8 +28,6 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2; import com.jogamp.newt.Window; -import com.jogamp.newt.event.MouseAdapter; -import com.jogamp.newt.event.MouseEvent; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; @@ -49,7 +47,6 @@ public class RedSquareES2 implements GLEventListener { GLArrayDataServer colors ; long t0; private int swapInterval = 0; - MyMouseAdapter myMouse = new MyMouseAdapter(); Window window = null; float aspect = 1.0f; boolean doRotate = true; @@ -132,11 +129,6 @@ public class RedSquareES2 implements GLEventListener { gl.glEnable(GL2ES2.GL_DEPTH_TEST); st.useProgram(gl, false); - final Object upstreamWidget = glad.getUpstreamWidget(); - if (!isFBOSlave && upstreamWidget instanceof Window) { - window = (Window) upstreamWidget; - window.addMouseListener(myMouse); - } t0 = System.currentTimeMillis(); System.err.println(Thread.currentThread()+" RedSquareES2.init FIN"); } @@ -195,25 +187,11 @@ public class RedSquareES2 implements GLEventListener { } isInitialized = false; System.err.println(Thread.currentThread()+" RedSquareES2.dispose ... "); - if (null != window) { - window.removeMouseListener(myMouse); - window = null; - } GL2ES2 gl = glad.getGL().getGL2ES2(); st.destroy(gl); st = null; pmvMatrix.destroy(); pmvMatrix = null; System.err.println(Thread.currentThread()+" RedSquareES2.dispose FIN"); - } - - class MyMouseAdapter extends MouseAdapter { - public void mouseClicked(MouseEvent e) { - System.err.println(e); - if(null != window && e.getSource() == window) { - window.setFullscreen(!window.isFullscreen()); - System.err.println("setFullscreen: "+window.isFullscreen()); - } - } - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 797a16485..fab5bf99b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -37,6 +37,8 @@ import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.MouseAdapter; +import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; @@ -220,6 +222,12 @@ public class TestGearsES2NEWT extends UITestCase { } } }); + glWindow.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + glWindow.setFullscreen(!glWindow.isFullscreen()); + System.err.println("setFullscreen: "+glWindow.isFullscreen()); + } + }); animator.start(); // glWindow.setSkipContextReleaseThread(animator.getThread()); -- cgit v1.2.3 From e58e7739379147af8c7b875f6e8a7cdb40e342bc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 20 Jul 2012 22:05:32 +0200 Subject: Fix OSX OffscreenLayerSurface (OLS) regressions (pbuffer based) - Use pbuffer (still), don't set FBO (invisible) - OLS (only impl is JAWTWindow now) stores the attached layer handle created and attached by the GLContext implementation, so 'others' may detach it -> NewtCanvasAWT - NewtCanvasAWT.removeNotify() needs to ask the OLS to detach the layer since it's parent will be gone. - MacOSXCGLContext destroy allows a removed OLS (see above) --- make/scripts/tests.sh | 5 ++--- .../classes/jogamp/opengl/GLDrawableFactoryImpl.java | 5 +++-- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 13 +++++++------ .../com/jogamp/nativewindow/awt/JAWTWindow.java | 18 +++++++++++++++--- .../media/nativewindow/OffscreenLayerSurface.java | 9 +++++++-- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 10 ++++++++-- 6 files changed, 42 insertions(+), 18 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index af99b8e72..19297ae25 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -407,10 +407,9 @@ function testawtswt() { # osx: #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* $spath/count-edt-start.sh java-run.log diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 897d3fcaf..34bb8704a 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -143,9 +143,10 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { // layered surface -> Offscreen/[FBO|PBuffer] final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable(); chosenCapsMod.setOnscreen(false); - if( isFBOAvailable ) { + /* if( isFBOAvailable ) { // FIXME JAU: FBO n/a yet chosenCapsMod.setFBO(true); - } else if(canCreateGLPbuffer(adevice)) { + } else */ + if( canCreateGLPbuffer(adevice) ) { chosenCapsMod.setPBuffer(true); } else { chosenCapsMod.setFBO(false); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index cb79e1560..82525cfde 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -444,9 +444,10 @@ public abstract class MacOSXCGLContext extends GLContextImpl throw new RuntimeException("Anonymous drawable instance's handle not of type NSView: "+drawable.getClass().getName()+", "+drawable); } } - final NativeSurface surface = drawable.getNativeSurface(); + final NativeSurface surface = drawable.getNativeSurface(); final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration(); final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); + boolean allowIncompleteView = null != backingLayerHost; if( !allowIncompleteView && surface instanceof ProxySurface ) { allowIncompleteView = 0 != ( ProxySurface.INVISIBLE_WINDOW & ((ProxySurface)surface).getImplBitfield() ) ; @@ -519,10 +520,10 @@ public abstract class MacOSXCGLContext extends GLContextImpl texWidth = drawable.getWidth(); texHeight = drawable.getHeight(); } - nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, drawable.getHandle(), fixedCaps.isBackgroundOpaque(), texWidth, texHeight); if(0>=texWidth || 0>=texHeight || !drawable.isRealized()) { throw new GLException("Drawable not realized yet or invalid texture size, texSize "+texWidth+"x"+texHeight+", "+drawable); } + nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, drawable.getHandle(), fixedCaps.isBackgroundOpaque(), texWidth, texHeight); if (DEBUG) { System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer)+", texSize "+texWidth+"x"+texHeight+", "+drawable); } @@ -545,11 +546,11 @@ public abstract class MacOSXCGLContext extends GLContextImpl System.err.println("NS destroy nsOpenGLLayer "+toHexString(nsOpenGLLayer)); } final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(surface, true); - if(null == ols) { - throw new InternalError("XXX: "+ols); + if(null != ols && ols.isSurfaceLayerAttached()) { + // still having a valid OLS attached to surface (parent OLS could have been removed) + ols.detachSurfaceLayer(); } - CGL.releaseNSOpenGLLayer(nsOpenGLLayer); - ols.detachSurfaceLayer(nsOpenGLLayer); + CGL.releaseNSOpenGLLayer(nsOpenGLLayer); CGL.deletePixelFormat(nsOpenGLLayerPFmt); nsOpenGLLayerPFmt = 0; nsOpenGLLayer = 0; diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index cffe495f7..d4b927cf1 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -81,6 +81,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected long drawable; protected Rectangle bounds; protected Insets insets; + private long offscreenSurfaceLayer; private long drawable_old; @@ -106,6 +107,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, invalidate(); this.component = windowObject; this.isApplet = false; + this.offscreenSurfaceLayer = 0; } @Override @@ -196,6 +198,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, System.err.println("JAWTWindow.attachSurfaceHandle(): 0x"+Long.toHexString(layerHandle) + ", bounds "+bounds); } attachSurfaceLayerImpl(layerHandle); + offscreenSurfaceLayer = layerHandle; } finally { unlockSurface(); } @@ -206,25 +209,34 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, * {@inheritDoc} */ @Override - public final void detachSurfaceLayer(final long layerHandle) throws NativeWindowException { + public final void detachSurfaceLayer() throws NativeWindowException { if( !isOffscreenLayerSurfaceEnabled() ) { throw new java.lang.UnsupportedOperationException("Not an offscreen layer surface"); } + if( 0 == offscreenSurfaceLayer) { + throw new NativeWindowException("No offscreen layer attached: "+this); + } int lockRes = lockSurface(); if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { throw new NativeWindowException("Could not lock (offscreen layer): "+this); } try { if(DEBUG) { - System.err.println("JAWTWindow.detachSurfaceHandle(): 0x"+Long.toHexString(layerHandle)); + System.err.println("JAWTWindow.detachSurfaceHandle(): 0x"+Long.toHexString(offscreenSurfaceLayer)); } - detachSurfaceLayerImpl(layerHandle); + detachSurfaceLayerImpl(offscreenSurfaceLayer); + offscreenSurfaceLayer = 0; } finally { unlockSurface(); } } protected abstract void detachSurfaceLayerImpl(final long layerHandle); + @Override + public final boolean isSurfaceLayerAttached() { + return 0 != offscreenSurfaceLayer; + } + // // SurfaceUpdateListener // diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index dd36509ba..f7dbc6c27 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -42,7 +42,12 @@ public interface OffscreenLayerSurface { * Detaches a previously attached offscreen layer from this offscreen layer surface. * @see #attachSurfaceLayer(long) * @see #isOffscreenLayerSurfaceEnabled() - * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false + * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false + * or no surface layer is attached. */ - public void detachSurfaceLayer(final long layerHandle) throws NativeWindowException; + public void detachSurfaceLayer() throws NativeWindowException; + + /** Returns true if a surface layer is attached, otherwise false. */ + public boolean isSurfaceLayerAttached(); + } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 9af4a02ae..cd0e9aab6 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -42,7 +42,9 @@ import java.security.PrivilegedAction; import java.util.Set; import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerOption; +import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.WindowClosingProtocol; import javax.swing.MenuSelectionManager; @@ -368,6 +370,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println("NewtCanvasAWT.removeNotify: "+newtChild+", from "+cont); } + final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); + if(null != ols && ols.isSurfaceLayerAttached()) { + ols.detachSurfaceLayer(); + } reparentWindow(false, cont); super.removeNotify(); } @@ -413,7 +419,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto // since this it is completely covered by the newtChild (z-order). setFocusable(true); } else { - configureNewtChild(false); + configureNewtChild(false); newtChild.setVisible(false); newtChild.reparentWindow(null); if(null != jawtWindow) { @@ -445,7 +451,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto NewtFactoryAWT.destroyNativeWindow(jawtWindow); jawtWindow=null; } - newtChild.setVisible(false); + newtChild.setVisible(false); newtChild.reparentWindow(null); newtChild.destroy(); newtChild=null; -- cgit v1.2.3 From 4b5a0f6557d7152ec770bc13ad3c494449de0529 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 22 Jul 2012 04:16:55 +0200 Subject: Fix Bug 606 - New AWT threading implementation breaks .. ; Fix GLAutoDrawable multi-threading w/ proper pattern (hope so) Considering code changes and remarks: 3ed491213f8f7f05d7b9866b50d764370d8ff5f6 1a91ec5c8b6fd9d9db7bc115569c369fe7b38e9b 3334a924309a9361a448d69bc707d4cce416b430 4f27bcecf7484dc041551f52a5c49e2884cb3867 It seems necessary to have - recursive locking employed for all semantic actions which changes drawable & context (and the Window resource) - to avoid deadlock, we have to ensure the locked code segment will not spawn off to another thread, or a thread holds the lock, spawns of an action requiring the lock. .. sure - other read-only methods (flags, ..) shall at least utilize a safe local copy of a volatile field if further use to produce the result is necessary. - flags like sendReshape require to be volatile to guarantee it's being processed Patch impacts: AWT/SWT GLCanvas, GLAutoDrawableBase [and it's specializations] and hopefully closes any loopholes of missing a cache hit, etc. If you review this and find optimizations, i.e. removing a lock due to semantics etc, don't hold back and discuss it, please. --- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 172 ++++++----- .../javax/media/opengl/GLAutoDrawableDelegate.java | 44 ++- .../classes/javax/media/opengl/awt/GLCanvas.java | 317 +++++++++++---------- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 249 +++++++++++----- .../classes/jogamp/opengl/GLDrawableHelper.java | 17 +- src/jogl/classes/jogamp/opengl/GLPbufferImpl.java | 29 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 36 +-- src/newt/classes/jogamp/newt/WindowImpl.java | 99 +++---- .../jogl/acore/TestGLAutoDrawableDelegateNEWT.java | 10 +- .../acore/TestGLContextDrawableSwitchNEWT.java | 10 +- .../jogl/acore/TestGLContextSurfaceLockNEWT.java | 92 ++++-- 11 files changed, 649 insertions(+), 426 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 0d9d3ddf5..64ee1c1ad 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -63,25 +63,13 @@ import org.eclipse.swt.widgets.Shell; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionUtil; +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.opengl.JoglVersion; /** * Native SWT Canvas implementing GLAutoDrawable - *

    - * FIXME: If this instance runs in multithreading mode, see {@link Threading#isSingleThreaded()} (impossible), - * proper recursive locking is required for drawable/context @ destroy and display. - * Recreation etc could pull those instances while animating! - * Simply locking before using drawable/context offthread - * would allow a deadlock situation! - *

    - *

    - * NOTE: [MT-0] Methods utilizing [volatile] drawable/context are not synchronized. - In case any of the methods are called outside of a locked state - extra care should be added. Maybe we shall expose locking facilities to the user. - However, since the user shall stick to the GLEventListener model while utilizing - GLAutoDrawable implementations, she is safe due to the implicit locked state. - *

    */ public class GLCanvas extends Canvas implements GLAutoDrawable { @@ -97,8 +85,9 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { //private static final boolean useSWTThread = ThreadingImpl.getMode() != ThreadingImpl.WORKER; /* GL Stuff */ + private final RecursiveLock lock = LockFactory.createRecursiveLock(); private final GLDrawableHelper helper = new GLDrawableHelper(); - private volatile GLDrawable drawable; // volatile avoids locking all accessors. FIXME still need to sync destroy/display + private volatile GLDrawable drawable; // volatile: avoid locking for read-only access private GLContext context; /* Native window surface */ @@ -112,7 +101,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final GLCapabilitiesImmutable glCapsRequested; /* Flag indicating whether an unprocessed reshape is pending. */ - private volatile boolean sendReshape; + private volatile boolean sendReshape; // volatile: maybe written by WindowManager thread w/o locking /* * Invokes init(...) on all GLEventListeners. Assumes context is current when run. @@ -141,10 +130,16 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { }; /* Action to make specified context current prior to running displayAction */ - private final Runnable makeCurrentAndDisplayAction = new Runnable() { + private final Runnable makeCurrentAndDisplayOnEDTAction = new Runnable() { @Override public void run() { - helper.invokeGL(drawable, context, displayAction, initAction); + final RecursiveLock _lock = lock; + _lock.lock(); + try { + helper.invokeGL(drawable, context, displayAction, initAction); + } finally { + _lock.unlock(); + } } }; @@ -157,10 +152,16 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { }; /* Swaps buffers, making the GLContext current first */ - private final Runnable makeCurrentAndSwapBuffersAction = new Runnable() { + private final Runnable makeCurrentAndSwapBuffersOnEDTAction = new Runnable() { @Override public void run() { - helper.invokeGL(drawable, context, swapBuffersAction, initAction); + final RecursiveLock _lock = lock; + _lock.lock(); + try { + helper.invokeGL(drawable, context, swapBuffersAction, initAction); + } finally { + _lock.unlock(); + } } }; @@ -181,16 +182,33 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final Runnable disposeOnEDTGLAction = new Runnable() { @Override public void run() { - helper.disposeGL(GLCanvas.this, drawable, context, postDisposeGLAction); - } - }; - - private final Runnable disposeGraphicsDeviceAction = new Runnable() { - @Override - public void run() { - if (null != device) { - device.close(); - device = null; + final RecursiveLock _lock = lock; + _lock.lock(); + try { + if (null != drawable && null != context) { + boolean animatorPaused = false; + final GLAnimatorControl animator = getAnimator(); + if (null != animator) { + animatorPaused = animator.pause(); + } + + if(context.isCreated()) { + helper.disposeGL(GLCanvas.this, drawable, context, postDisposeGLAction); + } + + if (animatorPaused) { + animator.resume(); + } + } + // SWT is owner of the device handle, not us. + // Hence close() operation is a NOP. + if (null != device) { + device.close(); + device = null; + } + SWTAccessor.setRealized(GLCanvas.this, false); // unrealize .. + } finally { + _lock.unlock(); } } }; @@ -229,7 +247,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { clientArea = GLCanvas.this.getClientArea(); - /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite) */ + /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). + * Note: SWT is owner of the native handle, hence no closing operation will be a NOP. */ device = SWTAccessor.getDevice(this); /* Since we have no means of querying the screen index yet, assume 0. Good choice due to Xinerama alike settings anyways. */ final int screenIdx = 0; @@ -345,7 +364,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public void display() { - runInGLThread(makeCurrentAndDisplayAction); + runInGLThread(makeCurrentAndDisplayOnEDTAction); } @Override @@ -370,7 +389,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GL getGL() { - return (null == context) ? null : context.getGL(); + final GLContext _context = context; + return (null == _context) ? null : _context.getGL(); } @Override @@ -400,27 +420,35 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLContext setContext(GLContext newCtx) { - final GLContext oldCtx = context; - final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); - context=(GLContextImpl)newCtx; - if(newCtxCurrent) { - context.makeCurrent(); + final RecursiveLock _lock = lock; + _lock.lock(); + try { + final GLContext oldCtx = context; + final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + context=(GLContextImpl)newCtx; + if(newCtxCurrent) { + context.makeCurrent(); + } + return oldCtx; + } finally { + _lock.unlock(); } - return oldCtx; } @Override public void setContextCreationFlags(final int arg0) { additionalCtxCreationFlags = arg0; - if(null != context) { - context.setContextCreationFlags(additionalCtxCreationFlags); + final GLContext _context = context; + if(null != _context) { + _context.setContextCreationFlags(additionalCtxCreationFlags); } } @Override public GL setGL(final GL arg0) { - if (null != context) { - context.setGL(arg0); + final GLContext _context = context; + if (null != _context) { + _context.setGL(arg0); return arg0; } return null; @@ -428,12 +456,18 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLContext createContext(final GLContext shareWith) { - if(drawable != null) { - final GLContext _ctx = drawable.createContext(shareWith); - _ctx.setContextCreationFlags(additionalCtxCreationFlags); - return _ctx; + final RecursiveLock _lock = lock; + _lock.lock(); + try { + if(drawable != null) { + final GLContext _ctx = drawable.createContext(shareWith); + _ctx.setContextCreationFlags(additionalCtxCreationFlags); + return _ctx; + } + return null; + } finally { + _lock.unlock(); } - return null; } @Override @@ -452,7 +486,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLDrawableFactory getFactory() { - return (drawable != null) ? drawable.getFactory() : null; + final GLDrawable _drawable = drawable; + return (_drawable != null) ? _drawable.getFactory() : null; } @Override @@ -462,17 +497,20 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public long getHandle() { - return (drawable != null) ? drawable.getHandle() : 0; + final GLDrawable _drawable = drawable; + return (_drawable != null) ? _drawable.getHandle() : 0; } @Override public NativeSurface getNativeSurface() { - return (drawable != null) ? drawable.getNativeSurface() : null; + final GLDrawable _drawable = drawable; + return (_drawable != null) ? _drawable.getNativeSurface() : null; } @Override public boolean isRealized() { - return (drawable != null) ? drawable.isRealized() : false; + final GLDrawable _drawable = drawable; + return (_drawable != null) ? _drawable.isRealized() : false; } @Override @@ -482,41 +520,19 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public void swapBuffers() throws GLException { - runInGLThread(makeCurrentAndSwapBuffersAction); + runInGLThread(makeCurrentAndSwapBuffersOnEDTAction); } // FIXME: API of update() method ? @Override public void update() { - // FIXME: display(); + // FIXME: display(); ? } @Override public void dispose() { - if (null != drawable && null != context) { // drawable is volatile! - boolean animatorPaused = false; - final GLAnimatorControl animator = getAnimator(); - if (null != animator) { - // can't remove us from animator for recreational addNotify() - animatorPaused = animator.pause(); - } - - if(context.isCreated()) { - runInGLThread(disposeOnEDTGLAction); - } - - if (animatorPaused) { - animator.resume(); - } - } - final Display display = getDisplay(); - - if (display.getThread() == Thread.currentThread()) { - disposeGraphicsDeviceAction.run(); - } else { - display.syncExec(disposeGraphicsDeviceAction); - } - super.dispose(); + runInGLThread(disposeOnEDTGLAction); + super.dispose(); } /** diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java index 1f6166719..76959f3f4 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java @@ -67,18 +67,18 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase { } // - // make protected methods accessible + // expose default methods // - public void defaultWindowRepaintOp() { + public final void windowRepaintOp() { super.defaultWindowRepaintOp(); } - public void defaultWindowResizedOp() { + public final void windowResizedOp() { super.defaultWindowResizedOp(); } - public void defaultWindowDestroyNotifyOp() { + public final void windowDestroyNotifyOp() { super.defaultWindowDestroyNotifyOp(); } @@ -89,6 +89,9 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase { private final RecursiveLock lock = LockFactory.createRecursiveLock(); // instance wide lock private final Object upstreamWidget; + @Override + protected final RecursiveLock getLock() { return lock; } + @Override public final Object getUpstreamWidget() { return upstreamWidget; @@ -97,39 +100,21 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase { /** * {@inheritDoc} *

    - * This implementation calls {@link #defaultDestroyOp()}. + * This implementation calls {@link #defaultDestroy()}. *

    *

    * User still needs to destroy the upstream window, which details are hidden from this aspect. + * This can be performed by overriding {@link #destroyImplInLock()}. *

    */ @Override - public void destroy() { - lock.lock(); - try { - defaultDestroyOp(); - } finally { - lock.unlock(); - } + public final void destroy() { + defaultDestroy(); } @Override public void display() { - if( sendDestroy ) { - sendDestroy=false; - destroy(); - return; - } - - lock.lock(); // sync: context/drawable could been recreated/destroyed while animating - try { - if( null != drawable && drawable.isRealized() && null != context ) { - // surface is locked/unlocked implicit by context's makeCurrent/release - helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction); - } - } finally { - lock.unlock(); - } + defaultDisplay(); } // @@ -145,4 +130,9 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase { public final void setRealized(boolean realized) { } + @Override + public final void swapBuffers() throws GLException { + defaultSwapBuffers(); + } + } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index c2e36ef9b..694a081b8 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -84,6 +84,8 @@ import javax.media.opengl.Threading; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.VersionUtil; +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; @@ -132,20 +134,6 @@ import jogamp.opengl.GLDrawableHelper; *
      *
    • sun.awt.noerasebackground=true
    • *
    - *

    - * FIXME: If this instance runs in multithreading mode, see {@link Threading#isSingleThreaded()} (default: single-thread), - * proper recursive locking is required for drawable/context @ destroy and display. - * Recreation etc could pull those instances while animating! - * Simply locking before using drawable/context offthread - * would allow a deadlock situation! - *

    - *

    - * NOTE: [MT-0] Methods utilizing [volatile] drawable/context are not synchronized. - In case any of the methods are called outside of a locked state - extra care should be added. Maybe we shall expose locking facilities to the user. - However, since the user shall stick to the GLEventListener model while utilizing - GLAutoDrawable implementations, she is safe due to the implicit locked state. - *

    */ @SuppressWarnings("serial") @@ -153,11 +141,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private static final boolean DEBUG = Debug.debug("GLCanvas"); + private final RecursiveLock lock = LockFactory.createRecursiveLock(); private final GLDrawableHelper helper = new GLDrawableHelper(); private AWTGraphicsConfiguration awtConfig; - private volatile GLDrawable drawable; // volatile avoids locking all accessors. FIXME still need to sync destroy/display + private volatile GLDrawable drawable; // volatile: avoid locking for read-only access private GLContextImpl context; - private boolean sendReshape = false; + private volatile boolean sendReshape = false; // volatile: maybe written by EDT w/o locking // copy of the cstr args, mainly for recreation private GLCapabilitiesImmutable capsReqUser; @@ -278,8 +267,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public final boolean isOffscreenLayerSurfaceEnabled() { - if(null != drawable) { - return ((JAWTWindow)drawable.getNativeSurface()).isOffscreenLayerSurfaceEnabled(); + final GLDrawable _drawable = drawable; + if(null != _drawable) { + return ((JAWTWindow)_drawable.getNativeSurface()).isOffscreenLayerSurfaceEnabled(); } return false; } @@ -398,12 +388,18 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public GLContext createContext(final GLContext shareWith) { - if(drawable != null) { - final GLContext _ctx = drawable.createContext(shareWith); - _ctx.setContextCreationFlags(additionalCtxCreationFlags); - return _ctx; + final RecursiveLock _lock = lock; + _lock.lock(); + try { + if(drawable != null) { + final GLContext _ctx = drawable.createContext(shareWith); + _ctx.setContextCreationFlags(additionalCtxCreationFlags); + return _ctx; + } + return null; + } finally { + _lock.unlock(); } - return null; } @Override @@ -412,7 +408,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public boolean isRealized() { - return (null != drawable) ? drawable.isRealized() : false; + final GLDrawable _drawable = drawable; + return ( null != _drawable ) ? _drawable.isRealized() : false; } @Override @@ -427,50 +424,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public void display() { - if( !validateGLDrawable() ) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: GLCanvas display - skipped GL render, drawable not valid yet"); - } - return; // not yet available .. - } Threading.invoke(true, displayOnEDTAction, getTreeLock()); - awtWindowClosingProtocol.addClosingListenerOneShot(); } private void dispose(boolean regenerate) { - final GLAnimatorControl animator = getAnimator(); - if(DEBUG) { - System.err.println(getThreadName()+": Info: dispose("+regenerate+") - START, hasContext " + - (null!=context) + ", hasDrawable " + (null!=drawable)+", "+animator); - Thread.dumpStack(); - } - - if(null!=drawable && null!=context) { // drawable is volatile! - boolean animatorPaused = false; - if(null!=animator) { - // can't remove us from animator for recreational addNotify() - animatorPaused = animator.pause(); - } - - disposeRegenerate=regenerate; - - if(context.isCreated()) { - Threading.invoke(true, disposeOnEDTAction, getTreeLock()); - } - - if(animatorPaused) { - animator.resume(); - } - } - - if(!regenerate) { - disposeAbstractGraphicsDevice(); - } - - if(DEBUG) { - System.err.println(getThreadName()+": dispose("+regenerate+") - END, "+animator); - } + disposeRegenerate=regenerate; + Threading.invoke(true, disposeOnEDTAction, getTreeLock()); } /** @@ -530,43 +490,49 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @SuppressWarnings("deprecation") @Override public void addNotify() { - if(DEBUG) { - System.err.println(getThreadName()+": Info: addNotify - start, bounds: "+this.getBounds()); - Thread.dumpStack(); - } - - /** - * 'super.addNotify()' determines the GraphicsConfiguration, - * while calling this class's overriden 'getGraphicsConfiguration()' method - * after which it creates the native peer. - * Hence we have to set the 'awtConfig' before since it's GraphicsConfiguration - * is being used in getGraphicsConfiguration(). - * This code order also allows recreation, ie re-adding the GLCanvas. - */ - awtConfig = chooseGraphicsConfiguration(capsReqUser, capsReqUser, chooser, device); - if(null==awtConfig) { - throw new GLException("Error: NULL AWTGraphicsConfiguration"); - } - - // before native peer is valid: X11 - disableBackgroundErase(); - - // issues getGraphicsConfiguration() and creates the native peer - super.addNotify(); - - // after native peer is valid: Windows - disableBackgroundErase(); - - if (!Beans.isDesignTime()) { - createDrawableAndContext(); - } - - // init drawable by paint/display makes the init sequence more equal - // for all launch flavors (applet/javaws/..) - // validateGLDrawable(); - - if(DEBUG) { - System.err.println(getThreadName()+": Info: addNotify - end: peer: "+getPeer()); + final RecursiveLock _lock = lock; + _lock.lock(); + try { + if(DEBUG) { + System.err.println(getThreadName()+": Info: addNotify - start, bounds: "+this.getBounds()); + Thread.dumpStack(); + } + + /** + * 'super.addNotify()' determines the GraphicsConfiguration, + * while calling this class's overriden 'getGraphicsConfiguration()' method + * after which it creates the native peer. + * Hence we have to set the 'awtConfig' before since it's GraphicsConfiguration + * is being used in getGraphicsConfiguration(). + * This code order also allows recreation, ie re-adding the GLCanvas. + */ + awtConfig = chooseGraphicsConfiguration(capsReqUser, capsReqUser, chooser, device); + if(null==awtConfig) { + throw new GLException("Error: NULL AWTGraphicsConfiguration"); + } + + // before native peer is valid: X11 + disableBackgroundErase(); + + // issues getGraphicsConfiguration() and creates the native peer + super.addNotify(); + + // after native peer is valid: Windows + disableBackgroundErase(); + + if (!Beans.isDesignTime()) { + createDrawableAndContext(); + } + + // init drawable by paint/display makes the init sequence more equal + // for all launch flavors (applet/javaws/..) + // validateGLDrawable(); + + if(DEBUG) { + System.err.println(getThreadName()+": Info: addNotify - end: peer: "+getPeer()); + } + } finally { + _lock.unlock(); } } @@ -585,23 +551,24 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } private boolean validateGLDrawable() { - boolean realized = false; - if (!Beans.isDesignTime()) { - if ( null != drawable ) { // OK: drawable is volatile - realized = drawable.isRealized(); - if ( !realized && 0 < drawable.getWidth() * drawable.getHeight() ) { - // make sure drawable realization happens on AWT EDT, due to AWTTree lock - AWTEDTExecutor.singleton.invoke(true, setRealizedOnEDTAction); - realized = true; - sendReshape=true; // ensure a reshape is being send .. - if(DEBUG) { - System.err.println(getThreadName()+": Realized Drawable: "+drawable.toString()); - Thread.dumpStack(); - } + final GLDrawable _drawable = drawable; + if ( null != _drawable ) { + if( _drawable.isRealized() ) { + return true; + } + if (!Beans.isDesignTime() && + 0 < _drawable.getWidth() * _drawable.getHeight() ) { + // make sure drawable realization happens on AWT EDT, due to AWTTree lock + AWTEDTExecutor.singleton.invoke(true, setRealizedOnEDTAction); + sendReshape=true; // ensure a reshape is being send .. + if(DEBUG) { + System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString()); + Thread.dumpStack(); } + return true; } } - return realized; + return false; } private Runnable setRealizedOnEDTAction = new Runnable() { @Override @@ -633,9 +600,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing try { dispose(false); } finally { - context=null; - drawable=null; - awtConfig=null; super.removeNotify(); } } @@ -655,7 +619,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public void reshape(int x, int y, int width, int height) { super.reshape(x, y, width, height); - if(null != drawable && drawable.isRealized() && !drawable.getChosenGLCapabilities().isOnscreen()) { + final GLDrawable _drawable = drawable; + if(null != _drawable && _drawable.isRealized() && !_drawable.getChosenGLCapabilities().isOnscreen()) { dispose(true); } else { sendReshape = true; @@ -710,13 +675,19 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public GLContext setContext(GLContext newCtx) { - final GLContext oldCtx = context; - final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); - context=(GLContextImpl)newCtx; - if(newCtxCurrent) { - context.makeCurrent(); + final RecursiveLock _lock = lock; + _lock.lock(); + try { + final GLContext oldCtx = context; + final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + context=(GLContextImpl)newCtx; + if(newCtxCurrent) { + context.makeCurrent(); + } + return oldCtx; + } finally { + _lock.unlock(); } - return oldCtx; } @Override @@ -729,15 +700,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if (Beans.isDesignTime()) { return null; } - GLContext ctx = getContext(); - return (ctx == null) ? null : ctx.getGL(); + final GLContext _context = context; + return (_context == null) ? null : _context.getGL(); } @Override public GL setGL(GL gl) { - GLContext ctx = getContext(); - if (ctx != null) { - ctx.setGL(gl); + final GLContext _context = context; + if (_context != null) { + _context.setGL(gl); return gl; } return null; @@ -762,8 +733,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public void setContextCreationFlags(int flags) { additionalCtxCreationFlags = flags; - if(null != context) { - context.setContextCreationFlags(additionalCtxCreationFlags); + final GLContext _context = context; + if(null != _context) { + _context.setContextCreationFlags(additionalCtxCreationFlags); } } @@ -796,26 +768,30 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public NativeSurface getNativeSurface() { - return (null != drawable) ? drawable.getNativeSurface() : null; + final GLDrawable _drawable = drawable; + return (null != _drawable) ? _drawable.getNativeSurface() : null; } @Override public long getHandle() { - return (null != drawable) ? drawable.getHandle() : 0; + final GLDrawable _drawable = drawable; + return (null != _drawable) ? _drawable.getHandle() : 0; } @Override public GLDrawableFactory getFactory() { - return (null != drawable) ? drawable.getFactory() : null; + final GLDrawable _drawable = drawable; + return (null != _drawable) ? _drawable.getFactory() : null; } @Override public String toString() { - final int dw = (null!=drawable) ? drawable.getWidth() : -1; - final int dh = (null!=drawable) ? drawable.getHeight() : -1; + final GLDrawable _drawable = drawable; + final int dw = (null!=_drawable) ? _drawable.getWidth() : -1; + final int dh = (null!=_drawable) ? _drawable.getHeight() : -1; return "AWT-GLCanvas[Realized "+isRealized()+ - ",\n\t"+((null!=drawable)?drawable.getClass().getName():"null-drawable")+ + ",\n\t"+((null!=_drawable)?_drawable.getClass().getName():"null-drawable")+ ",\n\tFactory "+getFactory()+ ",\n\thandle 0x"+Long.toHexString(getHandle())+ ",\n\tDrawable size "+dw+"x"+dh+ @@ -829,7 +805,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // private boolean disposeRegenerate; - private final Runnable postDisposeAction = new Runnable() { + private final Runnable postDisposeOnEDTAction = new Runnable() { @Override public void run() { context=null; @@ -859,7 +835,47 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private final Runnable disposeOnEDTAction = new Runnable() { @Override public void run() { - helper.disposeGL(GLCanvas.this, drawable, context, postDisposeAction); + final RecursiveLock _lock = lock; + _lock.lock(); + try { + final GLAnimatorControl animator = getAnimator(); + + if(DEBUG) { + System.err.println(getThreadName()+": Info: dispose("+disposeRegenerate+") - START, hasContext " + + (null!=context) + ", hasDrawable " + (null!=drawable)+", "+animator); + Thread.dumpStack(); + } + + if(null!=drawable && null!=context) { + boolean animatorPaused = false; + if(null!=animator) { + // can't remove us from animator for recreational addNotify() + animatorPaused = animator.pause(); + } + + if(context.isCreated()) { + helper.disposeGL(GLCanvas.this, drawable, context, postDisposeOnEDTAction); + } + + if(animatorPaused) { + animator.resume(); + } + } + + if(!disposeRegenerate) { + if(null != awtConfig) { + disposeAbstractGraphicsDevice(); + } + awtConfig=null; + } + + if(DEBUG) { + System.err.println(getThreadName()+": dispose("+disposeRegenerate+") - END, "+animator); + } + + } finally { + _lock.unlock(); + } } }; @@ -879,7 +895,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if(DEBUG) { System.err.println(getThreadName()+": GLCanvas.dispose(false): closed GraphicsDevice: "+adeviceMsg+", result: "+closed); } - awtConfig=null; } } }; @@ -890,7 +905,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing * * @see #chooseGraphicsConfiguration(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, java.awt.GraphicsDevice) */ - void disposeAbstractGraphicsDevice() { + private void disposeAbstractGraphicsDevice() { if( EventQueue.isDispatchThread() || Thread.holdsLock(getTreeLock()) ) { disposeAbstractGraphicsDeviceAction.run(); } else { @@ -941,14 +956,30 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private final Runnable displayOnEDTAction = new Runnable() { @Override public void run() { - helper.invokeGL(drawable, context, displayAction, initAction); + final RecursiveLock _lock = lock; + _lock.lock(); + try { + if( validateGLDrawable() ) { + helper.invokeGL(drawable, context, displayAction, initAction); + } else if(DEBUG) { + System.err.println(getThreadName()+": Info: GLCanvas display - skipped GL render, drawable not valid yet"); + } + } finally { + _lock.unlock(); + } } }; private final Runnable swapBuffersOnEDTAction = new Runnable() { @Override public void run() { - helper.invokeGL(drawable, context, swapBuffersAction, initAction); + final RecursiveLock _lock = lock; + _lock.lock(); + try { + helper.invokeGL(drawable, context, swapBuffersAction, initAction); + } finally { + _lock.unlock(); + } } }; diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index 5c6d7446a..fe6d0fd76 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -46,6 +46,7 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; +import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.opengl.util.Animator; @@ -63,11 +64,11 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { protected final GLDrawableHelper helper = new GLDrawableHelper(); protected final FPSCounterImpl fpsCounter = new FPSCounterImpl(); - protected GLDrawableImpl drawable; + protected volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access protected GLContextImpl context; protected int additionalCtxCreationFlags = 0; - protected boolean sendReshape = false; - protected boolean sendDestroy = false; + protected volatile boolean sendReshape = false; // volatile: maybe written by WindowManager thread w/o locking + protected volatile boolean sendDestroy = false; // volatile: maybe written by WindowManager thread w/o locking public GLAutoDrawableBase(GLDrawableImpl drawable, GLContextImpl context) { this.drawable = drawable; @@ -75,31 +76,47 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { resetFPSCounter(); } + protected abstract RecursiveLock getLock(); + /** Returns the delegated GLDrawable */ public final GLDrawable getDelegatedDrawable() { return drawable; } /** Default implementation to handle repaint events from the windowing system */ - protected void defaultWindowRepaintOp() { - if( null != drawable && drawable.isRealized() ) { - if( !drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isAnimatorAnimating() ) { + protected final void defaultWindowRepaintOp() { + final GLDrawable _drawable = drawable; + if( null != _drawable && _drawable.isRealized() ) { + if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isAnimatorAnimating() ) { display(); } - } + } } /** Default implementation to handle resize events from the windowing system */ - protected void defaultWindowResizedOp() { - if( null!=drawable ) { + protected final void defaultWindowResizedOp() { + final GLDrawable _drawable = drawable; + if( null!=_drawable ) { if(DEBUG) { System.err.println("GLAutoDrawableBase.sizeChanged: ("+Thread.currentThread().getName()+"): "+getWidth()+"x"+getHeight()+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); } - sendReshape = true; - defaultWindowRepaintOp(); + sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock + if( _drawable.isRealized() ) { + if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isAnimatorAnimating() ) { + display(); + } + } } } - /** Default implementation to handle destroy notifications from the windowing system */ - protected void defaultWindowDestroyNotifyOp() { + /** + * Default implementation to handle destroy notifications from the windowing system. + * + *

    + * If the {@link NativeSurface} does not implement {@link WindowClosingProtocol} + * or {@link WindowClosingMode#DISPOSE_ON_CLOSE} is enabled (default), + * {@link #defaultDestroy()} is being called. + *

    + */ + protected final void defaultWindowDestroyNotifyOp() { final NativeSurface ns = getNativeSurface(); final boolean shallClose; if(ns instanceof WindowClosingProtocol) { @@ -108,27 +125,66 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { shallClose = true; } if( shallClose ) { - // Is an animator thread perform rendering? - if (helper.isExternalAnimatorRunning()) { - // Pause animations before initiating safe destroy. - final GLAnimatorControl ctrl = helper.getAnimator(); - final boolean isPaused = ctrl.pause(); - destroy(); - if(isPaused) { - ctrl.resume(); - } - } else if (null != ns && ns.isSurfaceLockedByOtherThread()) { - // surface is locked by another thread - // Flag that destroy should be performed on the next - // attempt to display. - sendDestroy = true; - } else { - // Without an external thread animating or locking the - // surface, we are safe. - destroy (); - } + destroyAvoidAwareOfLocking(); } } + + /** + * Calls {@link #destroy()} + * directly if the following requirements are met: + *
      + *
    • An {@link GLAnimatorControl} is bound (see {@link #getAnimator()}) and running on another thread. + * Here we pause the animation while issuing the destruction.
    • + *
    • Surface is not locked by another thread (considered anonymous).
    • + *
    + *

    + * Otherwise destroy is being flagged to be called within the next + * call of display(). + *

    + *

    + * This method is being used to avoid deadlock if + * destruction is desired by other threads, e.g. the window manager. + *

    + * @see #defaultWindowDestroyNotifyOp() + * @see #defaultDisplay() + */ + protected final void destroyAvoidAwareOfLocking() { + final NativeSurface ns = getNativeSurface(); + + final GLAnimatorControl ctrl = helper.getAnimator(); + + // Is an animator thread perform rendering? + if ( helper.isAnimatorRunningOnOtherThread() ) { + // Pause animations before initiating safe destroy. + final boolean isPaused = ctrl.pause(); + destroy(); + if(isPaused) { + ctrl.resume(); + } + } else if (null != ns && ns.isSurfaceLockedByOtherThread()) { + // surface is locked by another thread + // Flag that destroy should be performed on the next + // attempt to display. + sendDestroy = true; // async, but avoiding deadlock + } else { + // Without an external thread animating or locking the + // surface, we are safe. + destroy(); + } + } + + /** + * Calls {@link #destroyImplInLock()} while claiming the lock. + */ + protected final void defaultDestroy() { + final RecursiveLock lock = getLock(); + lock.lock(); + try { + destroyImplInLock(); + } finally { + lock.unlock(); + } + } /** * Default implementation to destroys the drawable and context of this GLAutoDrawable: @@ -137,24 +193,42 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { *
  • destroys the GLContext, if valid
  • *
  • destroys the GLDrawable, if valid
  • *
+ *

Method assumes the lock is being hold.

+ *

Override it to extend it to destroy your resources, i.e. the actual window. + * In such case call super.destroyImplInLock first.

*/ - protected void defaultDestroyOp() { - if( null != drawable && drawable.isRealized() ) { - if( null != context && context.isCreated() ) { + protected void destroyImplInLock() { + final GLContext _context = context; + final GLDrawable _drawable = drawable; + if( null != _drawable && _drawable.isRealized() ) { + if( null != _context && _context.isCreated() ) { // Catch dispose GLExceptions by GLEventListener, just 'print' them // so we can continue with the destruction. try { - helper.disposeGL(this, drawable, context, null); + helper.disposeGL(this, _drawable, _context, null); } catch (GLException gle) { gle.printStackTrace(); } } - drawable.setRealized(false); + _drawable.setRealized(false); } context = null; drawable = null; } + public final void defaultSwapBuffers() throws GLException { + final RecursiveLock _lock = getLock(); + _lock.lock(); + try { + if(drawable!=null && context != null) { + drawable.swapBuffers(); + helper.invokeGL(drawable, context, defaultSwapAction, defaultInitAction); + } + } finally { + _lock.unlock(); + } + } + // // GLAutoDrawable // @@ -179,6 +253,30 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { fpsCounter.tickFPS(); } }; + protected final void defaultDisplay() { + if( sendDestroy ) { + sendDestroy=false; + destroy(); + return; + } + final RecursiveLock _lock = getLock(); + _lock.lock(); + try { + if( null != context ) { + // surface is locked/unlocked implicit by context's makeCurrent/release + helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction); + } + } finally { + _lock.unlock(); + } + } + + protected final Runnable defaultSwapAction = new Runnable() { + @Override + public final void run() { + drawable.swapBuffers(); + } } ; + @Override public final GLContext getContext() { return context; @@ -186,27 +284,35 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { @Override public final GLContext setContext(GLContext newCtx) { - final GLContext oldCtx = context; - final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); - context=(GLContextImpl)newCtx; - if(newCtxCurrent) { - context.makeCurrent(); + final RecursiveLock lock = getLock(); + lock.lock(); + try { + final GLContext oldCtx = context; + final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + context=(GLContextImpl)newCtx; + if(newCtxCurrent) { + context.makeCurrent(); + } + return oldCtx; + } finally { + lock.unlock(); } - return oldCtx; } @Override public final GL getGL() { - if (context == null) { + final GLContext _context = context; + if (_context == null) { return null; } - return context.getGL(); + return _context.getGL(); } @Override public final GL setGL(GL gl) { - if (context != null) { - context.setGL(gl); + final GLContext _context = context; + if (_context != null) { + _context.setGL(gl); return gl; } return null; @@ -261,8 +367,9 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { @Override public final void setContextCreationFlags(int flags) { additionalCtxCreationFlags = flags; - if(null != context) { - context.setContextCreationFlags(additionalCtxCreationFlags); + final GLContext _context = context; + if(null != _context) { + _context.setContextCreationFlags(additionalCtxCreationFlags); } } @@ -331,27 +438,36 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { @Override public final GLContext createContext(final GLContext shareWith) { - if(drawable != null) { - final GLContext _ctx = drawable.createContext(shareWith); - _ctx.setContextCreationFlags(additionalCtxCreationFlags); - return _ctx; + final RecursiveLock lock = getLock(); + lock.lock(); + try { + if(drawable != null) { + final GLContext _ctx = drawable.createContext(shareWith); + _ctx.setContextCreationFlags(additionalCtxCreationFlags); + return _ctx; + } + return null; + } finally { + lock.unlock(); } - return null; } @Override public final boolean isRealized() { - return null != drawable ? drawable.isRealized() : false; + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.isRealized() : false; } @Override public int getWidth() { - return null != drawable ? drawable.getWidth() : 0; + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.getWidth() : 0; } @Override public int getHeight() { - return null != drawable ? drawable.getHeight() : 0; + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.getHeight() : 0; } /** @@ -373,30 +489,27 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { return helper.getSkipContextReleaseThread(); } - @Override - public final void swapBuffers() throws GLException { - if(drawable!=null && context != null) { - drawable.swapBuffers(); - } - } - @Override public final GLCapabilitiesImmutable getChosenGLCapabilities() { - return null != drawable ? drawable.getChosenGLCapabilities() : null; + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.getChosenGLCapabilities() : null; } @Override public final GLProfile getGLProfile() { - return null != drawable ? drawable.getGLProfile() : null; + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.getGLProfile() : null; } @Override public final NativeSurface getNativeSurface() { - return null != drawable ? drawable.getNativeSurface() : null; + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.getNativeSurface() : null; } @Override public final long getHandle() { - return null != drawable ? drawable.getHandle() : 0; + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.getHandle() : 0; } } diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 0c01aa676..090c5fe69 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -189,8 +189,9 @@ public class GLDrawableHelper { */ public final void dispose(GLAutoDrawable drawable) { synchronized(listenersLock) { - for (int i=0; i < listeners.size(); i++) { - listeners.get(i).dispose(drawable); + final ArrayList _listeners = listeners; + for (int i=0; i < _listeners.size(); i++) { + _listeners.get(i).dispose(drawable); } } } @@ -209,8 +210,9 @@ public class GLDrawableHelper { /** The default init action to be called once after ctx is being created @ 1st makeCurrent(). */ public final void init(GLAutoDrawable drawable) { synchronized(listenersLock) { - for (int i=0; i < listeners.size(); i++) { - final GLEventListener listener = listeners.get(i) ; + final ArrayList _listeners = listeners; + for (int i=0; i < _listeners.size(); i++) { + final GLEventListener listener = _listeners.get(i) ; // If make current ctx, invoked by invokGL(..), results in a new ctx, init gets called. // This may happen not just for initial setup, but for ctx recreation due to resource change (drawable/window), @@ -232,8 +234,9 @@ public class GLDrawableHelper { } private final void displayImpl(GLAutoDrawable drawable) { synchronized(listenersLock) { - for (int i=0; i < listeners.size(); i++) { - final GLEventListener listener = listeners.get(i) ; + final ArrayList _listeners = listeners; + for (int i=0; i < _listeners.size(); i++) { + final GLEventListener listener = _listeners.get(i) ; // GLEventListener may need to be init, // in case this one is added after the realization of the GLAutoDrawable init( listener, drawable, true /* sendReshape */) ; @@ -324,7 +327,7 @@ public class GLDrawableHelper { } } - public final boolean isExternalAnimatorRunning() { + public final boolean isAnimatorRunningOnOtherThread() { return ( null != animatorCtrl ) ? animatorCtrl.isStarted() && animatorCtrl.getThread() != Thread.currentThread() : false ; } diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index bbc28e283..6b64120fe 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -42,10 +42,14 @@ package jogamp.opengl; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLPbuffer; +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; + /** Platform-independent class exposing pbuffer functionality to applications. This class is not exposed in the public API as it would probably add no value; however it implements the GLDrawable @@ -101,7 +105,7 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { // // GLDrawable delegation // - + @Override public final void setRealized(boolean realized) { } @@ -109,6 +113,10 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { // // GLAutoDrawable completion // + private final RecursiveLock lock = LockFactory.createRecursiveLock(); // instance wide lock + + @Override + protected final RecursiveLock getLock() { return lock; } @Override public final Object getUpstreamWidget() { @@ -117,7 +125,7 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { @Override public void destroy() { - defaultDestroyOp(); + defaultDestroy(); } @Override @@ -126,12 +134,23 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { } @Override - public void display() { - if( null != drawable && drawable.isRealized() && null != context ) { - helper.invokeGL(drawable, context, defaultDisplayAction, initAction); + public final void display() { + final RecursiveLock _lock = lock; + _lock.lock(); // sync: context/drawable could been recreated/destroyed while animating + try { + if( null != context ) { + helper.invokeGL(drawable, context, defaultDisplayAction, initAction); + } + } finally { + _lock.unlock(); } } + @Override + public final void swapBuffers() throws GLException { + defaultSwapBuffers(); + } + //---------------------------------------------------------------------- // Internals only below this point // diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 32d44502f..2205aec8e 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -53,6 +53,7 @@ import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import jogamp.newt.WindowImpl; @@ -62,6 +63,7 @@ import jogamp.opengl.GLDrawableImpl; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.VersionUtil; +import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; @@ -87,13 +89,6 @@ import com.jogamp.opengl.JoglVersion; * you can inject {@link javax.media.opengl.GLRunnable} objects * via {@link #invoke(boolean, javax.media.opengl.GLRunnable)} to the OpenGL command stream.
*

- *

- * NOTE: [MT-0] Methods utilizing [volatile] drawable/context are not synchronized. - In case any of the methods are called outside of a locked state - extra care should be added. Maybe we shall expose locking facilities to the user. - However, since the user shall stick to the GLEventListener model while utilizing - GLAutoDrawable implementations, she is safe due to the implicit locked state. - *

*/ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter { private final WindowImpl window; @@ -437,7 +432,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind //e1.printStackTrace(); } - defaultDestroyOp(); + destroyImplInLock(); if(Window.DEBUG_IMPLEMENTATION) { System.err.println("GLWindow.destroy() "+WindowImpl.getThreadName()+", fin"); @@ -515,6 +510,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind private GLContext sharedContext = null; + @Override + protected final RecursiveLock getLock() { + return window.getLock(); + } + /** * Specifies an {@link javax.media.opengl.GLContext OpenGL context} to share with.
* At native creation, {@link #setVisible(boolean) setVisible(true)}, @@ -537,19 +537,18 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return; } - window.lockWindow(); // sync: context/drawable could have been recreated/destroyed while animating + final RecursiveLock lock = window.getLock(); + lock.lock(); // sync: context/drawable could have been recreated/destroyed while animating try { - if( null == context && 0 display + setVisible(true); } } finally { - window.unlockWindow(); + lock.unlock(); } } @@ -559,7 +558,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind private GLDrawableFactory factory; @Override - public GLDrawableFactory getFactory() { + public final GLDrawableFactory getFactory() { return factory; } @@ -567,6 +566,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final void setRealized(boolean realized) { } + @Override + public final void swapBuffers() throws GLException { + defaultSwapBuffers(); + } + //---------------------------------------------------------------------- // NEWTEventConsumer // diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 002144b2f..b12e42680 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -564,9 +564,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final int lockSurface() throws NativeWindowException, RuntimeException { - windowLock.lock(); - surfaceLock.lock(); - int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? + final RecursiveLock _wlock = windowLock; + final RecursiveLock _slock = surfaceLock; + _wlock.lock(); + _slock.lock(); + int res = _slock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? if ( LOCK_SURFACE_NOT_READY == res ) { try { @@ -583,8 +585,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } finally { if (LOCK_SURFACE_NOT_READY >= res) { - surfaceLock.unlock(); - windowLock.unlock(); + _slock.unlock(); + _wlock.unlock(); } } } @@ -593,10 +595,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final void unlockSurface() { - surfaceLock.validateLocked(); - windowLock.validateLocked(); + final RecursiveLock _slock = surfaceLock; + final RecursiveLock _wlock = windowLock; + _slock.validateLocked(); + _wlock.validateLocked(); - if (surfaceLock.getHoldCount() == 1) { + if (_slock.getHoldCount() == 1) { final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); try { unlockSurfaceImpl(); @@ -604,8 +608,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer adevice.unlock(); } } - surfaceLock.unlock(); - windowLock.unlock(); + _slock.unlock(); + _wlock.unlock(); } @Override @@ -618,21 +622,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return surfaceLock.getOwner(); } - public final void lockWindow() { - windowLock.lock(); - } - public final void unlockWindow() { - windowLock.unlock(); + public final RecursiveLock getLock() { + return windowLock; } - public final boolean isWindowLockedByOtherThread() { - return windowLock.isLockedByOtherThread(); - } - - public final Thread getWindowLockOwner() { - return windowLock.getOwner(); - } - public long getSurfaceHandle() { return windowHandle; // default: return window handle } @@ -670,11 +663,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public Point getLocationOnScreen(Point storage) { if(isNativeValid()) { Point d; - windowLock.lock(); + final RecursiveLock _lock = windowLock; + _lock.lock(); try { d = getLocationOnScreenImpl(0, 0); } finally { - windowLock.unlock(); + _lock.unlock(); } if(null!=d) { if(null!=storage) { @@ -717,7 +711,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer boolean nativeWindowCreated = false; boolean madeVisible = false; - windowLock.lock(); + final RecursiveLock _lock = windowLock; + _lock.lock(); try { if(null!=lifecycleHook) { lifecycleHook.resetCounter(); @@ -739,7 +734,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer madeVisible = nativeWindowCreated; } // always flag visible, allowing a retry .. - WindowImpl.this.visible = true; + WindowImpl.this.visible = true; } else if(WindowImpl.this.visible != visible) { if(isNativeValid()) { setVisibleImpl(visible, getX(), getY(), getWidth(), getHeight()); @@ -766,7 +761,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("Window setVisible: END ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+WindowImpl.this.visible+", nativeWindowCreated: "+nativeWindowCreated+", madeVisible: "+madeVisible); } } finally { - windowLock.unlock(); + _lock.unlock(); } if( nativeWindowCreated || madeVisible ) { sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener @@ -801,7 +796,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public final void run() { boolean recreate = false; - windowLock.lock(); + final RecursiveLock _lock = windowLock; + _lock.lock(); try { if ( !isFullscreen() && ( getWidth() != width || getHeight() != height ) ) { recreate = isNativeValid() && !getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); @@ -842,7 +838,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(recreate) { screen.removeReference(); // bring back ref-count } - windowLock.unlock(); + _lock.unlock(); } } } @@ -863,7 +859,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(null!=lifecycleHook) { lifecycleHook.destroyActionPreLock(); } - windowLock.lock(); + final RecursiveLock _lock = windowLock; + _lock.lock(); try { if(DEBUG_IMPLEMENTATION) { System.err.println("Window DestroyAction() "+getThreadName()); @@ -917,7 +914,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer hasFocus = false; parentWindowHandle = 0; - windowLock.unlock(); + _lock.unlock(); } if(animatorPaused) { lifecycleHook.resumeRenderingAction(); @@ -1002,8 +999,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int width = getWidth(); int height = getHeight(); boolean wasVisible; - - windowLock.lock(); + + final RecursiveLock _lock = windowLock; + _lock.lock(); try { if(isNativeValid()) { // force recreation if offscreen, since it may become onscreen @@ -1220,7 +1218,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("Window.reparentWindow: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+x+"/"+y+" "+width+"x"+height); } } finally { - windowLock.unlock(); + _lock.unlock(); } if(wasVisible) { switch (operation) { @@ -1245,7 +1243,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class ReparentActionRecreate implements Runnable { public final void run() { - windowLock.lock(); + final RecursiveLock _lock = windowLock; + _lock.lock(); try { visible = true; if(DEBUG_IMPLEMENTATION) { @@ -1253,7 +1252,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } setVisible(true); // native creation } finally { - windowLock.unlock(); + _lock.unlock(); } } } @@ -1291,7 +1290,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public final void run() { - windowLock.lock(); + final RecursiveLock _lock = windowLock; + _lock.lock(); try { if(WindowImpl.this.undecorated != undecorated) { // set current state @@ -1311,7 +1311,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } finally { - windowLock.unlock(); + _lock.unlock(); } sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener } @@ -1333,7 +1333,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public final void run() { - windowLock.lock(); + final RecursiveLock _lock = windowLock; + _lock.lock(); try { if(WindowImpl.this.alwaysOnTop != alwaysOnTop) { // set current state @@ -1353,7 +1354,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } finally { - windowLock.unlock(); + _lock.unlock(); } sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener } @@ -1545,7 +1546,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer "\n, ParentWindow "+parentWindow+ "\n, ParentWindowHandle "+toHexString(parentWindowHandle)+" ("+(0!=getParentWindowHandle())+")"+ "\n, WindowHandle "+toHexString(getWindowHandle())+ - "\n, SurfaceHandle "+toHexString(getSurfaceHandle())+ " (lockedExt window "+isWindowLockedByOtherThread()+", surface "+isSurfaceLockedByOtherThread()+")"+ + "\n, SurfaceHandle "+toHexString(getSurfaceHandle())+ " (lockedExt window "+windowLock.isLockedByOtherThread()+", surface "+isSurfaceLockedByOtherThread()+")"+ "\n, Pos "+getX()+"/"+getY()+" (auto "+autoPosition()+"), size "+getWidth()+"x"+getHeight()+ "\n, Visible "+isVisible()+", focus "+hasFocus()+ "\n, Undecorated "+undecorated+" ("+isUndecorated()+")"+ @@ -1675,7 +1676,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public final void run() { - windowLock.lock(); + final RecursiveLock _lock = windowLock; + _lock.lock(); try { if(DEBUG_IMPLEMENTATION) { System.err.println("Window setPosition: "+getX()+"/"+getY()+" -> "+x+"/"+y+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)); @@ -1689,7 +1691,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } finally { - windowLock.unlock(); + _lock.unlock(); } } } @@ -1718,7 +1720,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public boolean fsOn() { return fullscreen; } public final void run() { - windowLock.lock(); + final RecursiveLock _lock = windowLock; + _lock.lock(); try { // set current state WindowImpl.this.fullscreen = fullscreen; @@ -1795,7 +1798,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } finally { - windowLock.unlock(); + _lock.unlock(); } sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener } @@ -1917,7 +1920,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // special repaint treatment case WindowEvent.EVENT_WINDOW_REPAINT: // queue repaint event in case window is locked, ie in operation - if( null != getWindowLockOwner() ) { + if( null != windowLock.getOwner() ) { // make sure only one repaint event is queued if(!repaintQueued) { repaintQueued=true; @@ -1936,7 +1939,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // common treatment case WindowEvent.EVENT_WINDOW_RESIZED: // queue event in case window is locked, ie in operation - if( null != getWindowLockOwner() ) { + if( null != windowLock.getOwner() ) { final boolean discardTO = QUEUED_EVENT_TO <= System.currentTimeMillis()-e.getWhen(); if(DEBUG_IMPLEMENTATION) { System.err.println("Window.consumeEvent: "+Thread.currentThread().getName()+" - queued "+e+", discard-to "+discardTO); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java index eb716677d..426b7734f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java @@ -87,8 +87,8 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase { final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window) { @Override - public void destroy() { - super.destroy(); // destroys drawable/context + protected void destroyImplInLock() { + super.destroyImplInLock(); // destroys drawable/context window.destroy(); // destroys the actual window } }; @@ -97,15 +97,15 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase { window.addWindowListener(new WindowAdapter() { @Override public void windowRepaint(WindowUpdateEvent e) { - glad.defaultWindowRepaintOp(); + glad.windowRepaintOp(); } @Override public void windowResized(WindowEvent e) { - glad.defaultWindowResizedOp(); + glad.windowResizedOp(); } @Override public void windowDestroyNotify(WindowEvent e) { - glad.defaultWindowDestroyNotifyOp(); + glad.windowDestroyNotifyOp(); } }); window.addWindowListener(wl); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java index 06aa29b4f..92b4c5238 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java @@ -90,8 +90,8 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window) { @Override - public void destroy() { - super.destroy(); // destroys drawable/context + protected void destroyImplInLock() { + super.destroyImplInLock(); window.destroy(); // destroys the actual window } }; @@ -100,15 +100,15 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { window.addWindowListener(new WindowAdapter() { @Override public void windowRepaint(WindowUpdateEvent e) { - glad.defaultWindowRepaintOp(); + glad.windowRepaintOp(); } @Override public void windowResized(WindowEvent e) { - glad.defaultWindowResizedOp(); + glad.windowResizedOp(); } @Override public void windowDestroyNotify(WindowEvent e) { - glad.defaultWindowDestroyNotifyOp(); + glad.windowDestroyNotifyOp(); } }); window.addWindowListener(wl); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextSurfaceLockNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextSurfaceLockNEWT.java index 78988c0e5..b3516d6b4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextSurfaceLockNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextSurfaceLockNEWT.java @@ -33,9 +33,9 @@ import java.io.IOException; import javax.media.nativewindow.NativeSurface; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; -import org.junit.Assert; import org.junit.Test; import com.jogamp.newt.opengl.GLWindow; @@ -69,7 +69,7 @@ public class TestGLContextSurfaceLockNEWT extends UITestCase { } public void run() { - System.err.println("Animatr "+id+": PRE: "+Thread.currentThread().getName()); + System.err.println("Animatr "+id+", count "+frameCount+": PRE: "+Thread.currentThread().getName()); for(int c=0; c Date: Tue, 24 Jul 2012 00:14:02 +0200 Subject: Fix GraphicsConfigurationFactory: Map factory to device-type _and_ capabilities-type; Add a pre-set nativeVisualID to chooseGraphicsConfiguration(..) Map factory to device-type _and_ capabilities-type: - Allows using different GraphicsConfigurationFactory implementations for different capabilities-types. Previous impl. failed to use an OpenGL agnostic CapabilitiesImmutable for 'chooseGraphicsConfiguration(..)' since only the GL aware factory was mapped. The latter failed since it expected a GLCapabilitiesImmutable. - The passed capabilities-type as well as device-type given at getFactory(..) is traversed top-to-down to find a most suitable factory: For-All devT := getTopDownDeviceTypes(deviceType) For-All capsT := getTopDownCapabilitiesTypes(capabilitiesType) f = factory.get(devT, capsT); if(f) { return f; } end end Add a pre-set nativeVisualID to chooseGraphicsConfiguration(..) - In situations where a native visualID is already chosen [by external means for example], but we still need to query a matching GraphicsConfiguration - we require to pass a non VisualIDHolder.VID_UNDEFINED nativeVisualID. We had a hack implemented before within some implementations and their static calls, however an agnostic mechanism is required to implement new NativeSurface/Window's platform agnostic. - X11GLXGraphicsConfigurationFactory: respect a pre-set xvisualID - X11GLXDrawableFactory.createProxySurfaceImpl(..) queries the given windowHandle's visualID and 'chooses' the configuration accordingly. If the visualID is undefined an exception is thrown, since window is invalid. These mechanics are implicit for Windows and OSX. Fix X11GLXGraphicsConfiguration.updateGraphicsConfiguration(): - Skip any action if a valid X11GLCapabilities is already chosen, i.e. w/ visualID. Otherwise choose a suitable configuration incl. visualID. The latter is quite impossible and invalid, since visualID must be defined at window creation time and the update method is issued with a valid window. X11 - Misc: - Added 'int jogamp.nativewindow.x11.X11Lib.GetVisualIDFromWindow(..)' - All returned visualID's are of type 'int' --- make/config/nativewindow/x11-CustomJavaCode.java | 4 +- .../javax/media/opengl/GLDrawableFactory.java | 3 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 9 +- .../jogamp/opengl/GLDrawableFactoryImpl.java | 3 + .../opengl/egl/EGLGraphicsConfiguration.java | 6 +- .../egl/EGLGraphicsConfigurationFactory.java | 16 +- .../cgl/MacOSXCGLGraphicsConfigurationFactory.java | 4 +- .../MacOSXAWTCGLGraphicsConfigurationFactory.java | 8 +- .../WindowsWGLGraphicsConfigurationFactory.java | 4 +- .../WindowsAWTWGLGraphicsConfigurationFactory.java | 8 +- .../opengl/x11/glx/X11ExternalGLXContext.java | 5 +- .../opengl/x11/glx/X11GLXDrawableFactory.java | 15 +- .../x11/glx/X11GLXGraphicsConfiguration.java | 29 ++- .../glx/X11GLXGraphicsConfigurationFactory.java | 113 ++++++++--- .../nativewindow/awt/AWTGraphicsConfiguration.java | 4 +- .../jogamp/nativewindow/x11/X11GraphicsDevice.java | 2 +- .../jogamp/nativewindow/x11/X11GraphicsScreen.java | 2 +- .../nativewindow/GraphicsConfigurationFactory.java | 226 +++++++++++++++++---- .../DefaultGraphicsConfigurationFactoryImpl.java | 2 +- .../x11/X11GraphicsConfigurationFactory.java | 18 +- .../awt/X11AWTGraphicsConfigurationFactory.java | 16 +- src/nativewindow/native/x11/Xmisc.c | 30 ++- src/newt/classes/jogamp/newt/OffscreenWindow.java | 5 +- .../classes/jogamp/newt/driver/awt/AWTCanvas.java | 6 +- .../jogamp/newt/driver/broadcom/egl/Window.java | 5 +- .../jogamp/newt/driver/intel/gdl/Window.java | 4 +- .../classes/jogamp/newt/driver/kd/KDWindow.java | 5 +- .../jogamp/newt/driver/macosx/MacWindow.java | 5 +- .../jogamp/newt/driver/windows/WindowsWindow.java | 5 +- .../classes/jogamp/newt/driver/x11/X11Window.java | 4 +- 30 files changed, 422 insertions(+), 144 deletions(-) (limited to 'src/newt/classes') diff --git a/make/config/nativewindow/x11-CustomJavaCode.java b/make/config/nativewindow/x11-CustomJavaCode.java index 73439fcc7..56aec4725 100644 --- a/make/config/nativewindow/x11-CustomJavaCode.java +++ b/make/config/nativewindow/x11-CustomJavaCode.java @@ -24,7 +24,9 @@ /** Entry point to C language function: XVisualInfo * XGetVisualInfo(Display * , long, XVisualInfo * , int * ); */ private static native java.nio.ByteBuffer XGetVisualInfo1(long arg0, long arg1, java.nio.ByteBuffer arg2, Object arg3, int arg3_byte_offset); - public static native long DefaultVisualID(long display, int screen); + public static native int GetVisualIDFromWindow(long display, long window); + + public static native int DefaultVisualID(long display, int screen); public static native long CreateDummyWindow(long display, int screen_index, int visualID, int width, int height); public static native void DestroyDummyWindow(long display, long window); diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 612a02f14..9a0d2cb99 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -434,7 +434,8 @@ public abstract class GLDrawableFactory { /** * Creates a proxy {@link NativeSurface} w/ defined surface handle, i.e. a {@link WrappedSurface} or {@link GDISurface} instance. *

- * It's {@link AbstractGraphicsConfiguration} is properly set according to the given {@link GLCapabilitiesImmutable}. + * It's {@link AbstractGraphicsConfiguration} is properly set according to the given + * windowHandle's native visualID if set or the given {@link GLCapabilitiesImmutable}. *

*

* Lifecycle (destruction) of the given surface handle shall be handled by the caller. diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 694a081b8..03fd78ac7 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -60,6 +60,7 @@ import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.OffscreenLayerOption; +import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.WindowClosingProtocol; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; @@ -1062,9 +1063,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( EventQueue.isDispatchThread() || Thread.holdsLock(getTreeLock()) ) { config = (AWTGraphicsConfiguration) - GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class).chooseGraphicsConfiguration(capsChosen, + GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, GLCapabilitiesImmutable.class).chooseGraphicsConfiguration(capsChosen, capsRequested, - chooser, aScreen); + chooser, aScreen, VisualIDHolder.VID_UNDEFINED); } else { try { final ArrayList bucket = new ArrayList(1); @@ -1072,9 +1073,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public void run() { AWTGraphicsConfiguration c = (AWTGraphicsConfiguration) - GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class).chooseGraphicsConfiguration(capsChosen, + GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, GLCapabilitiesImmutable.class).chooseGraphicsConfiguration(capsChosen, capsRequested, - chooser, aScreen); + chooser, aScreen, VisualIDHolder.VID_UNDEFINED); bucket.add(c); } }); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 34bb8704a..f092288fb 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -381,6 +381,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } + if(0 == windowHandle) { + throw new IllegalArgumentException("Null windowHandle"); + } device.lock(); try { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index 73867fb40..716a6e6f1 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -42,6 +42,7 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.DefaultGLCapabilitiesChooser; @@ -96,9 +97,10 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } void updateGraphicsConfiguration() { + CapabilitiesImmutable capsChosen = getChosenCapabilities(); EGLGraphicsConfiguration newConfig = (EGLGraphicsConfiguration) - GraphicsConfigurationFactory.getFactory(getScreen().getDevice()).chooseGraphicsConfiguration( - getChosenCapabilities(), getRequestedCapabilities(), chooser, getScreen()); + GraphicsConfigurationFactory.getFactory(getScreen().getDevice(), capsChosen).chooseGraphicsConfiguration( + capsChosen, getRequestedCapabilities(), chooser, getScreen(), VisualIDHolder.VID_UNDEFINED); if(null!=newConfig) { // FIXME: setScreen( ... ); setChosenCapabilities(newConfig.getChosenCapabilities()); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index d79c351a0..0b21d2054 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -81,27 +81,27 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact // become the pre-selector for X11/.. to match the native visual id w/ EGL, if native ES is selected final String nwType = NativeWindowFactory.getNativeWindowType(false); if(NativeWindowFactory.TYPE_X11 == nwType) { - nativeGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, eglFactory); + nativeGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, GLCapabilitiesImmutable.class, eglFactory); } /* else if(NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false)) { nativeGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.windows.WindowsGraphicsDevice.class, eglFactory); } else if(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)) { } */ // become the selector for KD/EGL .. - kdeglGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.egl.EGLGraphicsDevice.class, eglFactory); + kdeglGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.egl.EGLGraphicsDevice.class, GLCapabilitiesImmutable.class, eglFactory); } static void unregisterFactory() { final String nwType = NativeWindowFactory.getNativeWindowType(false); if(NativeWindowFactory.TYPE_X11 == nwType) { - GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, nativeGraphicsConfigurationFactory); + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, GLCapabilitiesImmutable.class, nativeGraphicsConfigurationFactory); } /* else if(NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false)) { GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.windows.WindowsGraphicsDevice.class, nativeGraphicsConfigurationFactory); } else if(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)) { } */ nativeGraphicsConfigurationFactory = null; - GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.egl.EGLGraphicsDevice.class, kdeglGraphicsConfigurationFactory); + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.egl.EGLGraphicsDevice.class, GLCapabilitiesImmutable.class, kdeglGraphicsConfigurationFactory); kdeglGraphicsConfigurationFactory = null; } @@ -110,7 +110,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl ( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, - CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { + CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { if (absScreen == null) { throw new IllegalArgumentException("This NativeWindowFactory accepts only AbstractGraphicsDevice objects"); } @@ -140,7 +140,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact cfg = chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable) capsChosen, (GLCapabilitiesImmutable) capsRequested, (GLCapabilitiesChooser) chooser, - absScreen, VisualIDHolder.VID_UNDEFINED, false); + absScreen, nativeVisualID, false); } else { // handle non native cases (X11, ..) if(null == nativeGraphicsConfigurationFactory) { @@ -154,7 +154,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact cfg = chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable) capsChosen, (GLCapabilitiesImmutable) capsRequested, (GLCapabilitiesChooser) chooser, - absScreen, VisualIDHolder.VID_UNDEFINED, false); + absScreen, nativeVisualID, false); if(null == cfg || VisualIDHolder.VID_UNDEFINED == cfg.getVisualID(VIDType.NATIVE)) { cfg = null; if(DEBUG) { @@ -167,7 +167,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(DEBUG) { System.err.println("EGLGraphicsConfigurationFactory.choose..: Delegate to "+nativeGraphicsConfigurationFactory.getClass().getSimpleName()); } - cfg = nativeGraphicsConfigurationFactory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, absScreen); + cfg = nativeGraphicsConfigurationFactory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, absScreen, nativeVisualID); } } return cfg; diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java index 1a9070aef..f138e7557 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java @@ -50,14 +50,14 @@ import javax.media.opengl.GLCapabilitiesImmutable; public class MacOSXCGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory { static void registerFactory() { - GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice.class, new MacOSXCGLGraphicsConfigurationFactory()); + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice.class, GLCapabilitiesImmutable.class, new MacOSXCGLGraphicsConfigurationFactory()); } private MacOSXCGLGraphicsConfigurationFactory() { } protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, - CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { + CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { return chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, absScreen, false); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java index a6fa01bad..edf9b7c84 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java @@ -58,14 +58,14 @@ import jogamp.opengl.macosx.cgl.MacOSXCGLGraphicsConfiguration; public class MacOSXAWTCGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory { public static void registerFactory() { - GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, new MacOSXAWTCGLGraphicsConfigurationFactory()); + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, GLCapabilitiesImmutable.class, new MacOSXAWTCGLGraphicsConfigurationFactory()); } private MacOSXAWTCGLGraphicsConfigurationFactory() { } protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, - CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { + CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { GraphicsDevice device = null; if (absScreen != null && !(absScreen instanceof AWTGraphicsScreen)) { @@ -103,9 +103,9 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GLGraphicsConfigur GraphicsConfiguration gc = device.getDefaultConfiguration(); MacOSXCGLGraphicsConfiguration macConfig = (MacOSXCGLGraphicsConfiguration) - GraphicsConfigurationFactory.getFactory(macDevice).chooseGraphicsConfiguration(capsChosen, + GraphicsConfigurationFactory.getFactory(macDevice, capsChosen).chooseGraphicsConfiguration(capsChosen, capsRequested, - chooser, macScreen); + chooser, macScreen, nativeVisualID); if (macConfig == null) { throw new GLException("Unable to choose a GraphicsConfiguration: "+capsChosen+",\n\t"+chooser+"\n\t"+macScreen); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index 943c7fec4..00ed91bb4 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -69,13 +69,13 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat static VisualIDHolder.VIDComparator PfdIDComparator = new VisualIDHolder.VIDComparator(VisualIDHolder.VIDType.WIN32_PFD); static void registerFactory() { - GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.windows.WindowsGraphicsDevice.class, new WindowsWGLGraphicsConfigurationFactory()); + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.windows.WindowsGraphicsDevice.class, GLCapabilitiesImmutable.class, new WindowsWGLGraphicsConfigurationFactory()); } private WindowsWGLGraphicsConfigurationFactory() { } protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( - CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { + CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { if (! (capsChosen instanceof GLCapabilitiesImmutable) ) { throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - chosen"); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java index bd64b58a4..3b2ff133a 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java @@ -63,14 +63,14 @@ import javax.media.opengl.GLDrawableFactory; public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory { public static void registerFactory() { - GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, new WindowsAWTWGLGraphicsConfigurationFactory()); + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, GLCapabilitiesImmutable.class, new WindowsAWTWGLGraphicsConfigurationFactory()); } private WindowsAWTWGLGraphicsConfigurationFactory() { } protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, - CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { + CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { GraphicsDevice device = null; if (absScreen != null && !(absScreen instanceof AWTGraphicsScreen)) { @@ -105,11 +105,11 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu WindowsGraphicsDevice winDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); DefaultGraphicsScreen winScreen = new DefaultGraphicsScreen(winDevice, awtScreen.getIndex()); - GraphicsConfigurationFactory configFactory = GraphicsConfigurationFactory.getFactory(winDevice); + GraphicsConfigurationFactory configFactory = GraphicsConfigurationFactory.getFactory(winDevice, capsChosen); WindowsWGLGraphicsConfiguration winConfig = (WindowsWGLGraphicsConfiguration) configFactory.chooseGraphicsConfiguration(capsChosen, capsRequested, - chooser, winScreen); + chooser, winScreen, nativeVisualID); if (winConfig == null) { throw new GLException("Unable to choose a GraphicsConfiguration: "+capsChosen+",\n\t"+chooser+"\n\t"+winScreen); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index b847363e0..1f3edbd8a 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -41,6 +41,7 @@ package jogamp.opengl.x11.glx; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; @@ -94,9 +95,9 @@ public class X11ExternalGLXContext extends X11GLXContext { // of 0, which doesn't work in a subsequent call to glXChooseFBConfig; if this happens, // create and use a default config (this has been observed when running on CentOS 5.5 inside // of VMWare Server 2.0 with the Mesa 6.5.1 drivers) - if( X11GLXGraphicsConfiguration.GLXFBConfigIDValid(display, x11Screen.getIndex(), val[0]) ) { + if( VisualIDHolder.VID_UNDEFINED == val[0] || !X11GLXGraphicsConfiguration.GLXFBConfigIDValid(display, x11Screen.getIndex(), val[0]) ) { GLCapabilities glcapsDefault = new GLCapabilities(GLProfile.getDefault()); - cfg = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(glcapsDefault, glcapsDefault, null, x11Screen); + cfg = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(glcapsDefault, glcapsDefault, null, x11Screen, VisualIDHolder.VID_UNDEFINED); if(DEBUG) { System.err.println("X11ExternalGLXContext invalid FBCONFIG_ID "+val[0]+", using default cfg: " + cfg); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 8ffbf3951..b2e74f9d4 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -50,6 +50,7 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; @@ -514,7 +515,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { device = (X11GraphicsDevice)deviceReq; } final X11GraphicsScreen screen = new X11GraphicsScreen(device, 0); - final X11GLXGraphicsConfiguration config = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen); + final X11GLXGraphicsConfiguration config = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED); if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } @@ -582,7 +583,17 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), NativeWindowFactory.getNullToolkitLock(), true); final X11GraphicsScreen screen = new X11GraphicsScreen(device, screenIdx); - final X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); + final int xvisualID = X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle); + if(VisualIDHolder.VID_UNDEFINED == xvisualID) { + throw new GLException("Undefined VisualID of window 0x"+Long.toHexString(windowHandle)+", window probably invalid"); + } + if(DEBUG) { + System.err.println("X11GLXDrawableFactory.createProxySurfaceImpl 0x"+Long.toHexString(windowHandle)+": visualID 0x"+Integer.toHexString(xvisualID)); + } + final X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, xvisualID); + if(DEBUG) { + System.err.println("X11GLXDrawableFactory.createProxySurfaceImpl 0x"+Long.toHexString(windowHandle)+": "+cfg); + } return new WrappedSurface(cfg, windowHandle, 0, 0, upstream); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java index 95b1cc457..b458fffe1 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java @@ -37,7 +37,9 @@ import java.util.ArrayList; import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; @@ -102,16 +104,25 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem } void updateGraphicsConfiguration() { - X11GLXGraphicsConfiguration newConfig = (X11GLXGraphicsConfiguration) - GraphicsConfigurationFactory.getFactory(getScreen().getDevice()).chooseGraphicsConfiguration( - getChosenCapabilities(), getRequestedCapabilities(), chooser, getScreen()); - if(null!=newConfig) { - // FIXME: setScreen( ... ); - setXVisualInfo(newConfig.getXVisualInfo()); - setChosenCapabilities(newConfig.getChosenCapabilities()); - if(DEBUG) { - System.err.println("updateGraphicsConfiguration: "+this); + final CapabilitiesImmutable aChosenCaps = getChosenCapabilities(); + if( !(aChosenCaps instanceof X11GLCapabilities) || VisualIDHolder.VID_UNDEFINED == aChosenCaps.getVisualID(VIDType.X11_XVISUAL) ) { + // This case is actually quite impossible, since on X11 the visualID and hence GraphicsConfiguration + // must be determined _before_ window creation! + final X11GLXGraphicsConfiguration newConfig = (X11GLXGraphicsConfiguration) + GraphicsConfigurationFactory.getFactory(getScreen().getDevice(), aChosenCaps).chooseGraphicsConfiguration( + aChosenCaps, getRequestedCapabilities(), chooser, getScreen(), VisualIDHolder.VID_UNDEFINED); + if(null!=newConfig) { + // FIXME: setScreen( ... ); + setXVisualInfo(newConfig.getXVisualInfo()); + setChosenCapabilities(newConfig.getChosenCapabilities()); + if(DEBUG) { + System.err.println("X11GLXGraphicsConfiguration.updateGraphicsConfiguration updated:"+this); + } + } else { + throw new GLException("No native VisualID pre-chosen and update failed: "+this); } + } else if (DEBUG) { + System.err.println("X11GLXGraphicsConfiguration.updateGraphicsConfiguration kept:"+this); } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java index 331401c06..234b06bdb 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -40,6 +40,7 @@ import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; @@ -74,20 +75,24 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF static GraphicsConfigurationFactory fallbackX11GraphicsConfigurationFactory = null; static void registerFactory() { final GraphicsConfigurationFactory newFactory = new X11GLXGraphicsConfigurationFactory(); - final GraphicsConfigurationFactory oldFactory = GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, newFactory); + final GraphicsConfigurationFactory oldFactory = GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, GLCapabilitiesImmutable.class, newFactory); if(oldFactory == newFactory) { throw new InternalError("GraphicsConfigurationFactory lifecycle impl. error"); } - if(null == oldFactory) { - throw new InternalError("Missing fallback GraphicsConfigurationFactory"); + if(null != oldFactory) { + fallbackX11GraphicsConfigurationFactory = oldFactory; + } else { + fallbackX11GraphicsConfigurationFactory = GraphicsConfigurationFactory.getFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, CapabilitiesImmutable.class); + if( null == fallbackX11GraphicsConfigurationFactory ) { + throw new InternalError("Missing fallback GraphicsConfigurationFactory"); + } } - fallbackX11GraphicsConfigurationFactory = oldFactory; } private X11GLXGraphicsConfigurationFactory() { } protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( - CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { + CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { if (!(absScreen instanceof X11GraphicsScreen)) { throw new IllegalArgumentException("Only X11GraphicsScreen are allowed here"); } @@ -109,12 +114,12 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF if(DEBUG) { System.err.println("No GLX available, fallback to "+fallbackX11GraphicsConfigurationFactory.getClass().getSimpleName()+" for: "+absScreen); } - return fallbackX11GraphicsConfigurationFactory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, absScreen); + return fallbackX11GraphicsConfigurationFactory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, absScreen, VisualIDHolder.VID_UNDEFINED); } throw new InternalError("No GLX and no fallback GraphicsConfigurationFactory available for: "+absScreen); } return chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested, - (GLCapabilitiesChooser)chooser, (X11GraphicsScreen)absScreen); + (GLCapabilitiesChooser)chooser, (X11GraphicsScreen)absScreen, nativeVisualID); } protected static List getAvailableCapabilities(X11GLXDrawableFactory factory, AbstractGraphicsDevice device) { @@ -199,7 +204,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF static X11GLXGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsReq, GLCapabilitiesChooser chooser, - X11GraphicsScreen x11Screen) { + X11GraphicsScreen x11Screen, int xvisualID) { if (x11Screen == null) { throw new IllegalArgumentException("AbstractGraphicsScreen is null"); } @@ -215,19 +220,19 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF X11GLXGraphicsConfiguration res = null; if( factory.isGLXVersionGreaterEqualOneThree(x11Device) ) { - res = chooseGraphicsConfigurationFBConfig(capsChosen, capsReq, chooser, x11Screen); + res = chooseGraphicsConfigurationFBConfig(capsChosen, capsReq, chooser, x11Screen, xvisualID); } if(null==res) { if(usePBuffer) { - throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig for "+capsChosen); + throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig for visualID "+toHexString(xvisualID)+", "+capsChosen); } - res = chooseGraphicsConfigurationXVisual(capsChosen, capsReq, chooser, x11Screen); + res = chooseGraphicsConfigurationXVisual(capsChosen, capsReq, chooser, x11Screen, xvisualID); } if(null==res) { - throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig and XVisual for "+capsChosen); + throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig and XVisual for visualID "+toHexString(xvisualID)+", "+x11Screen+", "+capsChosen); } if(DEBUG) { - System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationStatic("+x11Screen+","+capsChosen+"): "+res); + System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationStatic(visualID "+toHexString(xvisualID)+", "+x11Screen+","+capsChosen+"): "+res); } return res; } @@ -253,7 +258,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF private static X11GLXGraphicsConfiguration chooseGraphicsConfigurationFBConfig(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsReq, GLCapabilitiesChooser chooser, - X11GraphicsScreen x11Screen) { + X11GraphicsScreen x11Screen, int xvisualID) { int recommendedIndex = -1; PointerBuffer fbcfgsL = null; GLProfile glProfile = capsChosen.getGLProfile(); @@ -273,8 +278,11 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF int[] count = { -1 }; List availableCaps = new ArrayList(); final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, useFBO); - // 1st choice: get GLCapabilities based on users GLCapabilities setting recommendedIndex as preferred choice - fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, 0, count, 0); + // 1st choice: get GLCapabilities based on users GLCapabilities setting recommendedIndex as preferred choice, + // skipped if xvisualID is given + if( VisualIDHolder.VID_UNDEFINED == xvisualID ) { + fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, 0, count, 0); + } if (fbcfgsL != null && fbcfgsL.limit()>0) { for (int i = 0; i < fbcfgsL.limit(); i++) { if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, absDevice, fbcfgsL.get(i), winattrmask, isMultisampleAvailable) ) { @@ -317,6 +325,33 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } } } + + if(DEBUG) { + System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: got configs: "+availableCaps.size()); + for(int i=0; i chosenIndex ) { if (DEBUG) { @@ -333,7 +368,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF private static X11GLXGraphicsConfiguration chooseGraphicsConfigurationXVisual(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsReq, GLCapabilitiesChooser chooser, - X11GraphicsScreen x11Screen) { + X11GraphicsScreen x11Screen, int xvisualID) { if (chooser == null) { chooser = new DefaultGLCapabilitiesChooser(); } @@ -351,14 +386,18 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF final boolean isMultisampleAvailable = factory.isGLXMultisampleAvailable(absDevice); int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capsChosen, false, isMultisampleAvailable, display, screen); + XVisualInfo recommendedVis = null; // 1st choice: get GLCapabilities based on users GLCapabilities setting recommendedIndex as preferred choice - XVisualInfo recommendedVis = GLX.glXChooseVisual(display, screen, attribs, 0); - if (DEBUG) { - System.err.print("glXChooseVisual recommended "); - if (recommendedVis == null) { - System.err.println("null visual"); - } else { - System.err.println("visual id " + toHexString(recommendedVis.getVisualid())); + // skipped if xvisualID is given + if( VisualIDHolder.VID_UNDEFINED == xvisualID ) { + recommendedVis = GLX.glXChooseVisual(display, screen, attribs, 0); + if (DEBUG) { + System.err.print("glXChooseVisual recommended "); + if (recommendedVis == null) { + System.err.println("null visual"); + } else { + System.err.println("visual id " + toHexString(recommendedVis.getVisualid())); + } } } @@ -384,6 +423,32 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } } + if(DEBUG) { + System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationXVisual: got configs: "+availableCaps.size()); + for(int i=0; i chosenIndex ) { if (DEBUG) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java index 61d5e5c0d..2a152ff35 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java @@ -95,8 +95,8 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple GraphicsConfiguration gc = awtGraphicsDevice.getDefaultConfiguration(); capsChosen = AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsRequested, gc); } - final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(awtDevice); - final AbstractGraphicsConfiguration config = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, null, awtScreen); + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(awtDevice, capsChosen); + final AbstractGraphicsConfiguration config = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, null, awtScreen, VisualIDHolder.VID_UNDEFINED); if(config instanceof AWTGraphicsConfiguration) { return (AWTGraphicsConfiguration) config; } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index 7a98e3c25..5e4d6f41a 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -88,7 +88,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl // It still could be an AWT hold handle .. final long display = getHandle(); final int scrnIdx = X11Lib.DefaultScreen(display); - return (int) X11Lib.DefaultVisualID(display, scrnIdx); + return X11Lib.DefaultVisualID(display, scrnIdx); } @Override diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java index 014f4f688..5f3c220ca 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java @@ -58,7 +58,7 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl public int getVisualID() { // It still could be an AWT hold handle .. - return (int) X11Lib.DefaultVisualID(getDevice().getHandle(), getIndex()); + return X11Lib.DefaultVisualID(getDevice().getHandle(), getIndex()); } private static int fetchScreen(X11GraphicsDevice device, int screen) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java index 2610f2cfa..c3fdc6798 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java @@ -36,9 +36,15 @@ package javax.media.nativewindow; import com.jogamp.common.util.ReflectionUtil; import jogamp.nativewindow.Debug; import jogamp.nativewindow.DefaultGraphicsConfigurationFactoryImpl; + +import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import java.util.Map; +import java.util.Set; /** * Provides the mechanism by which the graphics configuration for a @@ -59,8 +65,43 @@ import java.util.Map; public abstract class GraphicsConfigurationFactory { protected static final boolean DEBUG; - private static Map, GraphicsConfigurationFactory> registeredFactories; - private static Class abstractGraphicsDeviceClass; + private static class DeviceCapsType { + public final Class deviceType; + public final Class capsType; + private final int hash32; + + public DeviceCapsType(Class deviceType, Class capsType) { + this.deviceType = deviceType; + this.capsType = capsType; + + // 31 * x == (x << 5) - x + int hash32 = 31 + deviceType.hashCode(); + hash32 = ((hash32 << 5) - hash32) + capsType.hashCode(); + this.hash32 = hash32; + } + + public final int hashCode() { + return hash32; + } + + public final boolean equals(Object obj) { + if(this == obj) { return true; } + if (obj instanceof DeviceCapsType) { + DeviceCapsType dct = (DeviceCapsType)obj; + return deviceType == dct.deviceType && capsType == dct.capsType; + } + return false; + } + + @Override + public final String toString() { + return "DeviceCapsType["+deviceType.getName()+", "+capsType.getName()+"]"; + } + + } + + private static final Map registeredFactories; + private static final DeviceCapsType defaultDeviceCapsType; static boolean initialized = false; static { @@ -69,7 +110,8 @@ public abstract class GraphicsConfigurationFactory { System.err.println(Thread.currentThread().getName()+" - Info: GraphicsConfigurationFactory."); // Thread.dumpStack(); } - abstractGraphicsDeviceClass = javax.media.nativewindow.AbstractGraphicsDevice.class; + registeredFactories = Collections.synchronizedMap(new HashMap()); + defaultDeviceCapsType = new DeviceCapsType(AbstractGraphicsDevice.class, CapabilitiesImmutable.class); } public static synchronized void initSingleton() { @@ -79,14 +121,13 @@ public abstract class GraphicsConfigurationFactory { if(DEBUG) { System.err.println(Thread.currentThread().getName()+" - GraphicsConfigurationFactory.initSingleton()"); } - registeredFactories = Collections.synchronizedMap(new HashMap, GraphicsConfigurationFactory>()); // Register the default no-op factory for arbitrary // AbstractGraphicsDevice implementations, including // AWTGraphicsDevice instances -- the OpenGL binding will take // care of handling AWTGraphicsDevices on X11 platforms (as // well as X11GraphicsDevices in non-AWT situations) - registerFactory(abstractGraphicsDeviceClass, new DefaultGraphicsConfigurationFactoryImpl()); + registerFactory(defaultDeviceCapsType.deviceType, defaultDeviceCapsType.capsType, new DefaultGraphicsConfigurationFactoryImpl()); if (NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(true))) { try { @@ -112,7 +153,6 @@ public abstract class GraphicsConfigurationFactory { System.err.println(Thread.currentThread().getName()+" - GraphicsConfigurationFactory.shutdown()"); } registeredFactories.clear(); - registeredFactories = null; } } @@ -133,74 +173,175 @@ public abstract class GraphicsConfigurationFactory { protected GraphicsConfigurationFactory() { } - /** Returns the factory for use with the given type of - AbstractGraphicsDevice. */ - public static GraphicsConfigurationFactory getFactory(AbstractGraphicsDevice device) { + /** + * Returns the graphics configuration factory for use with the + * given device and capability. + * + * @see #getFactory(Class, Class) + */ + public static GraphicsConfigurationFactory getFactory(AbstractGraphicsDevice device, CapabilitiesImmutable caps) { if (device == null) { - return getFactory(AbstractGraphicsDevice.class); + throw new IllegalArgumentException("null device"); + } + if (caps == null) { + throw new IllegalArgumentException("null caps"); } - return getFactory(device.getClass()); + return getFactory(device.getClass(), caps.getClass()); } /** * Returns the graphics configuration factory for use with the - * given class, which must implement the {@link - * AbstractGraphicsDevice} interface. + * given device and capability class. + *

+ * Note: Registered device types maybe classes or interfaces, where capabilities types are interfaces only. + *

+ * + *

+ * Pseudo code for finding a suitable factory is: + *

+        For-All devT := getTopDownDeviceTypes(deviceType)
+            For-All capsT := getTopDownCapabilitiesTypes(capabilitiesType)
+               f = factory.get(devT, capsT);
+               if(f) { return f; }
+            end
+        end
+     * 
+ *

* - * @throws IllegalArgumentException if the given class does not implement AbstractGraphicsDevice + * @param deviceType the minimum capabilities class type accepted, must implement or extend {@link AbstractGraphicsDevice} + * @param capabilitiesType the minimum capabilities class type accepted, must implement or extend {@link CapabilitiesImmutable} + * + * @throws IllegalArgumentException if the deviceType does not implement {@link AbstractGraphicsDevice} or + * capabilitiesType does not implement {@link CapabilitiesImmutable} */ - public static GraphicsConfigurationFactory getFactory(Class abstractGraphicsDeviceImplementor) + public static GraphicsConfigurationFactory getFactory(Class deviceType, Class capabilitiesType) throws IllegalArgumentException, NativeWindowException { - if (!(abstractGraphicsDeviceClass.isAssignableFrom(abstractGraphicsDeviceImplementor))) { + if (!(defaultDeviceCapsType.deviceType.isAssignableFrom(deviceType))) { throw new IllegalArgumentException("Given class must implement AbstractGraphicsDevice"); } - - GraphicsConfigurationFactory factory = null; - Class clazz = abstractGraphicsDeviceImplementor; - while (clazz != null) { - factory = registeredFactories.get(clazz); - if (factory != null) { - if(DEBUG) { - System.err.println("GraphicsConfigurationFactory.getFactory() "+abstractGraphicsDeviceImplementor+" -> "+factory); + if (!(defaultDeviceCapsType.capsType.isAssignableFrom(capabilitiesType))) { + throw new IllegalArgumentException("Given capabilities class must implement CapabilitiesImmutable"); + } + if(DEBUG) { + Thread.dumpStack(); + System.err.println("GraphicsConfigurationFactory.getFactory: "+deviceType.getName()+", "+capabilitiesType.getName()); + dumpFactories(); + } + + final List> deviceTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.deviceType, deviceType, false); + if(DEBUG) { + System.err.println("GraphicsConfigurationFactory.getFactory() deviceTypes: " + deviceTypes); + } + final List> capabilitiesTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.capsType, capabilitiesType, true); + if(DEBUG) { + System.err.println("GraphicsConfigurationFactory.getFactory() capabilitiesTypes: " + capabilitiesTypes); + } + for(int j=0; j interfaceDevice = deviceTypes.get(j); + for(int i=0; i interfaceCaps = capabilitiesTypes.get(i); + final DeviceCapsType dct = new DeviceCapsType(interfaceDevice, interfaceCaps); + final GraphicsConfigurationFactory factory = registeredFactories.get(dct); + if (factory != null) { + if(DEBUG) { + System.err.println("GraphicsConfigurationFactory.getFactory() found "+dct+" -> "+factory); + } + return factory; } - return factory; } - clazz = clazz.getSuperclass(); } // Return the default - factory = registeredFactories.get(abstractGraphicsDeviceClass); + final GraphicsConfigurationFactory factory = registeredFactories.get(defaultDeviceCapsType); if(DEBUG) { - System.err.println("GraphicsConfigurationFactory.getFactory() DEFAULT "+abstractGraphicsDeviceClass+" -> "+factory); + System.err.println("GraphicsConfigurationFactory.getFactory() DEFAULT "+defaultDeviceCapsType+" -> "+factory); } return factory; } + private static ArrayList> getAllAssignableClassesFrom(Class superClassOrInterface, Class fromClass, boolean interfacesOnly) { + // Using a todo list avoiding a recursive loop! + final ArrayList> inspectClasses = new ArrayList>(); + final ArrayList> resolvedInterfaces = new ArrayList>(); + inspectClasses.add(fromClass); + for(int j=0; j clazz = inspectClasses.get(j); + getAllAssignableClassesFrom(superClassOrInterface, clazz, interfacesOnly, resolvedInterfaces, inspectClasses); + } + return resolvedInterfaces; + } + private static void getAllAssignableClassesFrom(Class superClassOrInterface, Class fromClass, boolean interfacesOnly, List> resolvedInterfaces, List> inspectClasses) { + final ArrayList> types = new ArrayList>(); + if( superClassOrInterface.isAssignableFrom(fromClass) && !resolvedInterfaces.contains(fromClass)) { + if( !interfacesOnly || fromClass.isInterface() ) { + types.add(fromClass); + } + } + types.addAll(Arrays.asList(fromClass.getInterfaces())); + + for(int i=0; i iface = types.get(i); + if( superClassOrInterface.isAssignableFrom(iface) && !resolvedInterfaces.contains(iface) ) { + resolvedInterfaces.add(iface); + if( !superClassOrInterface.equals(iface) && !inspectClasses.contains(iface) ) { + inspectClasses.add(iface); // safe add to todo list, avoiding a recursive nature + } + } + } + final Class parentClass = fromClass.getSuperclass(); + if( null != parentClass && superClassOrInterface.isAssignableFrom(parentClass) && !inspectClasses.contains(parentClass) ) { + inspectClasses.add(parentClass); // safe add to todo list, avoiding a recursive nature + } + } + private static void dumpFactories() { + Set dcts = registeredFactories.keySet(); + int i=0; + for(Iterator iter = dcts.iterator(); iter.hasNext(); ) { + DeviceCapsType dct = iter.next(); + System.err.println("Factory #"+i+": "+dct+" -> "+registeredFactories.get(dct)); + i++; + } + } - /** Registers a GraphicsConfigurationFactory handling graphics - * device objects of the given class. This does not need to be - * called by end users, only implementors of new + /** + * Registers a GraphicsConfigurationFactory handling + * the given graphics device and capability class. + *

+ * This does not need to be called by end users, only implementors of new * GraphicsConfigurationFactory subclasses. - * + *

+ * + *

+ * Note: Registered device types maybe classes or interfaces, where capabilities types are interfaces only. + *

+ * + *

See {@link #getFactory(Class, Class)} for a description of the find algorithm.

+ * + * @param deviceType the minimum capabilities class type accepted, must implement or extend interface {@link AbstractGraphicsDevice} + * @param capabilitiesType the minimum capabilities class type accepted, must extend interface {@link CapabilitiesImmutable} * @return the previous registered factory, or null if none * @throws IllegalArgumentException if the given class does not implement AbstractGraphicsDevice */ - protected static GraphicsConfigurationFactory registerFactory(Class abstractGraphicsDeviceImplementor, GraphicsConfigurationFactory factory) + protected static GraphicsConfigurationFactory registerFactory(Class abstractGraphicsDeviceImplementor, Class capabilitiesType, GraphicsConfigurationFactory factory) throws IllegalArgumentException { - if (!(abstractGraphicsDeviceClass.isAssignableFrom(abstractGraphicsDeviceImplementor))) { - throw new IllegalArgumentException("Given class must implement AbstractGraphicsDevice"); + if (!(defaultDeviceCapsType.deviceType.isAssignableFrom(abstractGraphicsDeviceImplementor))) { + throw new IllegalArgumentException("Given device class must implement AbstractGraphicsDevice"); } + if (!(defaultDeviceCapsType.capsType.isAssignableFrom(capabilitiesType))) { + throw new IllegalArgumentException("Given capabilities class must implement CapabilitiesImmutable"); + } + final DeviceCapsType dct = new DeviceCapsType(abstractGraphicsDeviceImplementor, capabilitiesType); final GraphicsConfigurationFactory prevFactory; if(null == factory) { - prevFactory = registeredFactories.remove(abstractGraphicsDeviceImplementor); + prevFactory = registeredFactories.remove(dct); if(DEBUG) { - System.err.println("GraphicsConfigurationFactory.registerFactory() remove "+abstractGraphicsDeviceImplementor+ + System.err.println("GraphicsConfigurationFactory.registerFactory() remove "+dct+ ", deleting: "+prevFactory); } } else { - prevFactory = registeredFactories.put(abstractGraphicsDeviceImplementor, factory); + prevFactory = registeredFactories.put(dct, factory); if(DEBUG) { - System.err.println("GraphicsConfigurationFactory.registerFactory() put "+abstractGraphicsDeviceImplementor+" -> "+factory+ + System.err.println("GraphicsConfigurationFactory.registerFactory() put "+dct+" -> "+factory+ ", overridding: "+prevFactory); } } @@ -244,6 +385,7 @@ public abstract class GraphicsConfigurationFactory { * @param capsRequested the original requested capabilities * @param chooser the choosing implementation * @param screen the referring Screen + * @param nativeVisualID if not {@link VisualIDHolder#VID_UNDEFINED} it reflects a pre-chosen visualID of the native platform's windowing system. * @return the complete GraphicsConfiguration * * @throws IllegalArgumentException if the data type of the passed @@ -258,7 +400,7 @@ public abstract class GraphicsConfigurationFactory { public final AbstractGraphicsConfiguration chooseGraphicsConfiguration(CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, - AbstractGraphicsScreen screen) + AbstractGraphicsScreen screen, int nativeVisualID) throws IllegalArgumentException, NativeWindowException { if(null==capsChosen) { throw new NativeWindowException("Chosen Capabilities are null"); @@ -275,7 +417,7 @@ public abstract class GraphicsConfigurationFactory { } device.lock(); try { - return chooseGraphicsConfigurationImpl(capsChosen, capsRequested, chooser, screen); + return chooseGraphicsConfigurationImpl(capsChosen, capsRequested, chooser, screen, nativeVisualID); } finally { device.unlock(); } @@ -283,7 +425,7 @@ public abstract class GraphicsConfigurationFactory { protected abstract AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, - CapabilitiesChooser chooser, AbstractGraphicsScreen screen) + CapabilitiesChooser chooser, AbstractGraphicsScreen screen, int nativeVisualID) throws IllegalArgumentException, NativeWindowException; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java index f34b740d4..52e9c8308 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java @@ -37,7 +37,7 @@ import javax.media.nativewindow.*; public class DefaultGraphicsConfigurationFactoryImpl extends GraphicsConfigurationFactory { protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( - CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen screen) { + CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen screen, int nativeVisualID) { return new DefaultGraphicsConfiguration(screen, capsChosen, capsRequested); } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java index 070f87216..b11dd1df1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java @@ -39,33 +39,39 @@ import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; import com.jogamp.nativewindow.x11.X11GraphicsConfiguration; import com.jogamp.nativewindow.x11.X11GraphicsScreen; public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactory { public static void registerFactory() { - GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, new X11GraphicsConfigurationFactory()); + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, CapabilitiesImmutable.class, new X11GraphicsConfigurationFactory()); } private X11GraphicsConfigurationFactory() { } protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( - CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen screen) + CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen screen, int nativeVisualID) throws IllegalArgumentException, NativeWindowException { if(!(screen instanceof X11GraphicsScreen)) { throw new NativeWindowException("Only valid X11GraphicsScreen are allowed"); } - final X11Capabilities x11CapsChosen = new X11Capabilities(getXVisualInfo(screen, capsChosen)); - AbstractGraphicsConfiguration res = new X11GraphicsConfiguration((X11GraphicsScreen)screen, x11CapsChosen, capsRequested, x11CapsChosen.getXVisualInfo()); + final X11Capabilities x11CapsChosen; + if(VisualIDHolder.VID_UNDEFINED == nativeVisualID) { + x11CapsChosen = new X11Capabilities(getXVisualInfo(screen, capsChosen)); + } else { + x11CapsChosen = new X11Capabilities(getXVisualInfo(screen, nativeVisualID)); + } + final AbstractGraphicsConfiguration res = new X11GraphicsConfiguration((X11GraphicsScreen)screen, x11CapsChosen, capsRequested, x11CapsChosen.getXVisualInfo()); if(DEBUG) { - System.err.println("X11GraphicsConfigurationFactory.chooseGraphicsConfigurationImpl("+screen+","+capsChosen+"): "+res); + System.err.println("X11GraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(visualID 0x"+Integer.toHexString(nativeVisualID)+", "+screen+","+capsChosen+"): "+res); } return res; } - public static XVisualInfo getXVisualInfo(AbstractGraphicsScreen screen, long visualID) + public static XVisualInfo getXVisualInfo(AbstractGraphicsScreen screen, int visualID) { XVisualInfo xvi_temp = XVisualInfo.create(); xvi_temp.setVisualid(visualID); diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java index b6bf63d44..1de03e8be 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java @@ -61,14 +61,14 @@ import jogamp.nativewindow.x11.X11Util; public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFactory { public static void registerFactory() { - GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, new X11AWTGraphicsConfigurationFactory()); + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, CapabilitiesImmutable.class, new X11AWTGraphicsConfigurationFactory()); } private X11AWTGraphicsConfigurationFactory() { } protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, - CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { + CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { if (absScreen != null && !(absScreen instanceof AWTGraphicsScreen)) { throw new IllegalArgumentException("This GraphicsConfigurationFactory accepts only AWTGraphicsScreen objects"); @@ -77,18 +77,18 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac absScreen = AWTGraphicsScreen.createDefault(); } - return chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, (AWTGraphicsScreen)absScreen); + return chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, (AWTGraphicsScreen)absScreen, nativeVisualID); } public static AWTGraphicsConfiguration chooseGraphicsConfigurationStatic( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, - CapabilitiesChooser chooser, AWTGraphicsScreen awtScreen) { + CapabilitiesChooser chooser, AWTGraphicsScreen awtScreen, int nativeVisualID) { if(DEBUG) { System.err.println("X11AWTGraphicsConfigurationFactory: got "+awtScreen); } final GraphicsDevice device = ((AWTGraphicsDevice)awtScreen.getDevice()).getGraphicsDevice(); - + final long displayHandleAWT = X11SunJDKReflection.graphicsDeviceGetDisplay(device); final long displayHandle; boolean owner = false; @@ -121,8 +121,8 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac System.err.println("X11AWTGraphicsConfigurationFactory: made "+x11Screen); } - final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(x11Device); - AbstractGraphicsConfiguration aConfig = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen); + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(x11Device, capsChosen); + AbstractGraphicsConfiguration aConfig = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen, nativeVisualID); if (aConfig == null) { throw new NativeWindowException("Unable to choose a GraphicsConfiguration (1): "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen); } @@ -160,7 +160,7 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac // try again using an AWT Colormodel compatible configuration GraphicsConfiguration gc = device.getDefaultConfiguration(); capsChosen = AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsChosen, gc); - aConfig = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen); + aConfig = factory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, x11Screen, nativeVisualID); if (aConfig == null) { throw new NativeWindowException("Unable to choose a GraphicsConfiguration (2): "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen); } diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index 21771c9aa..fcba8580c 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -362,14 +362,40 @@ Java_jogamp_nativewindow_x11_X11Lib_XGetVisualInfo1__JJLjava_nio_ByteBuffer_2Lja return jbyteCopy; } -JNIEXPORT jlong JNICALL +JNIEXPORT jint JNICALL +Java_jogamp_nativewindow_x11_X11Lib_GetVisualIDFromWindow(JNIEnv *env, jclass _unused, jlong display, jlong window) { + Display * dpy = (Display *)(intptr_t)display; + Window w = (Window) window; + XWindowAttributes xwa; + jlong r = 0; // undefinded + + if(NULL==dpy) { + NativewindowCommon_throwNewRuntimeException(env, "invalid display connection.."); + return; + } + + NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 1, 0, 1); + memset(&xwa, 0, sizeof(XWindowAttributes)); + XGetWindowAttributes(dpy, w, &xwa); + if(NULL != xwa.visual) { + r = (jint) XVisualIDFromVisual( xwa.visual ); + } else { + r = 0; + } + NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); + + return r; +} + + +JNIEXPORT jint JNICALL Java_jogamp_nativewindow_x11_X11Lib_DefaultVisualID(JNIEnv *env, jclass _unused, jlong display, jint screen) { jlong r; if(0==display) { NativewindowCommon_FatalError(env, "invalid display connection.."); } NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) display, 1, 0, 0); - r = (jlong) XVisualIDFromVisual( DefaultVisual( (Display*) (intptr_t) display, screen ) ); + r = (jint) XVisualIDFromVisual( DefaultVisual( (Display*) (intptr_t) display, screen ) ); NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) display, 0, 0, 0); return r; } diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index be543aba9..ba98ca3af 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -40,6 +40,7 @@ import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; @@ -72,8 +73,8 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { dummySurface.createNotify(); } } */ - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aScreen.getDevice()).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, aScreen); + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aScreen.getDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, aScreen, VisualIDHolder.VID_UNDEFINED); if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index 5a49dd57c..a7950048a 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; @@ -53,6 +54,7 @@ import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; import com.jogamp.newt.Window; +@SuppressWarnings("serial") public class AWTCanvas extends Canvas { private GraphicsDevice device; private GraphicsConfiguration chosen; @@ -252,9 +254,9 @@ public class AWTCanvas extends Canvas { AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT): AWTGraphicsScreen.createDefault(); AWTGraphicsConfiguration config = (AWTGraphicsConfiguration) - GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class).chooseGraphicsConfiguration(capsChosen, + GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, capsChosen.getClass()).chooseGraphicsConfiguration(capsChosen, capsRequested, - chooser, aScreen); + chooser, aScreen, VisualIDHolder.VID_UNDEFINED); if (config == null) { throw new NativeWindowException("Error: Couldn't fetch AWTGraphicsConfiguration"); } diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java index ed1d0511a..223ad6484 100644 --- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java +++ b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java @@ -37,6 +37,7 @@ package jogamp.newt.driver.broadcom.egl; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; import javax.media.opengl.GLCapabilitiesImmutable; @@ -57,8 +58,8 @@ public class Window extends jogamp.newt.WindowImpl { } // query a good configuration, however chose the final one by the native queried egl-cfg-id // after creation at {@link #windowCreated(int, int, int)}. - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen()); + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java index 09e0e3016..d5c75abd4 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java @@ -54,8 +54,8 @@ public class Window extends jogamp.newt.WindowImpl { final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); final AbstractGraphicsDevice aDevice = getScreen().getDisplay().getGraphicsDevice(); - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aDevice).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, aScreen); + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aDevice, capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, aScreen, VisualIDHolder.VID_UNDEFINED); if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java index bb76d21ff..9f9d6948e 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java +++ b/src/newt/classes/jogamp/newt/driver/kd/KDWindow.java @@ -37,6 +37,7 @@ package jogamp.newt.driver.kd; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; @@ -59,8 +60,8 @@ public class KDWindow extends WindowImpl { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); } - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen()); + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java index fcca5c843..720d4ee4c 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java @@ -39,6 +39,7 @@ import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; +import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; @@ -61,8 +62,8 @@ public class MacWindow extends WindowImpl implements MutableSurface, DriverClear @Override protected void createNativeImpl() { - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice()).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen()); + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java index 5e636d982..34d76a148 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java @@ -41,6 +41,7 @@ import jogamp.newt.WindowImpl; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; @@ -119,8 +120,8 @@ public class WindowsWindow extends WindowImpl { protected void createNativeImpl() { final WindowsScreen screen = (WindowsScreen) getScreen(); final WindowsDisplay display = (WindowsDisplay) screen.getDisplay(); - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen()); + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java index 9a5074c29..5501f5a3c 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java @@ -63,9 +63,9 @@ public class X11Window extends WindowImpl { protected void createNativeImpl() { final X11Screen screen = (X11Screen) getScreen(); final X11Display display = (X11Display) screen.getDisplay(); - final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice()); + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested); final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen()); + capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); if(DEBUG_IMPLEMENTATION) { System.err.println("X11Window.createNativeImpl() factory: "+factory+", chosen config: "+cfg); } -- cgit v1.2.3 From 7bb5885fc3a904f49e22f0c8cbf747d9b189a7ba Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 25 Jul 2012 04:23:35 +0200 Subject: SWT Update: SWT GLCanvas creates lazy when resource is ready; Create new NewtCanvasSWT allowing to parent NEWT windows natively. SWT GLCanvas creates lazy when resource is ready - Ensures drawable and context are created when size > zero and native visualID is valid. The latter is platform dependent. - Note that you cannot utilize custom GLCapabilities w/ this one, since the configurations is already realized - use NewtCanvasSWT. Create new NewtCanvasSWT allowing to parent NEWT windows natively: - Similar to NewtCanvasAWT - Allows attaching / detaching NEWT windows NewtCanvasAWT: Public setNEWTChild(..) fixed Added test cases for the above - tested on Linux, OSX and Windows w/ SWT Note: As usual for OSX, add -XstartOnFirstThread Details: - NEWT Display has new method: 'EDTUtil setEDTUtil(EDTUtil)' allowing to set a custom event dispatch utility. We use this to set our SWTEDTUtil for using NEWT w/ SWT complying w/ SWT threading constraints. --- etc/profile.jogl | 5 + make/build-common.xml | 2 + make/build-newt.xml | 19 +- make/build-test.xml | 99 ++-- make/scripts/java-win64-dbg.bat | 4 +- make/scripts/tests-x64.bat | 25 +- make/scripts/tests.sh | 19 +- make/stub_includes/win32/wingdi.h | 2 + .../gluegen/opengl/BuildComposablePipeline.java | 2 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 199 +++++--- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 1 - .../com/jogamp/nativewindow/swt/SWTAccessor.java | 25 + .../media/nativewindow/NativeWindowFactory.java | 17 + .../jogamp/nativewindow/macosx/OSXUtil.java | 35 +- src/nativewindow/native/macosx/OSXmisc.m | 74 ++- src/newt/classes/com/jogamp/newt/Display.java | 17 + .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 74 ++- .../classes/com/jogamp/newt/opengl/GLWindow.java | 1 - .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 508 +++++++++++++++++++++ .../classes/com/jogamp/newt/swt/SWTEDTUtil.java | 99 ++++ src/newt/classes/jogamp/newt/DisplayImpl.java | 40 +- src/newt/classes/jogamp/newt/WindowImpl.java | 11 +- .../newt/awt/event/AWTParentWindowAdapter.java | 21 +- .../classes/jogamp/newt/driver/awt/AWTDisplay.java | 11 +- .../jogamp/newt/driver/macosx/MacWindow.java | 5 +- .../jogamp/newt/driver/windows/WindowsWindow.java | 11 +- src/newt/native/MacWindow.m | 56 ++- .../test/junit/jogl/swt/TestNewtCanvasSWTGLn.java | 233 ++++++++++ .../test/junit/jogl/swt/TestSWTAccessor02GLn.java | 278 ----------- .../junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java | 55 ++- .../junit/newt/parenting/TestParenting01aSWT.java | 210 +++++++++ .../junit/newt/parenting/TestParenting04AWT.java | 239 ++++++++++ .../junit/newt/parenting/TestParenting04SWT.java | 264 +++++++++++ 33 files changed, 2158 insertions(+), 503 deletions(-) create mode 100644 src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java create mode 100644 src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02GLn.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java (limited to 'src/newt/classes') diff --git a/etc/profile.jogl b/etc/profile.jogl index 4402adde6..7dd51919d 100755 --- a/etc/profile.jogl +++ b/etc/profile.jogl @@ -25,6 +25,9 @@ function concat_jogl_list() ARCH=`uname -m` KERNEL=`uname -s | awk ' { printf "%s",tolower($0) ; } '` +if [ "$KERNEL" = "sunos" ] ; then + KERNEL="solaris" +fi uname -a | grep -i LINUX && OSS=x11 uname -a | grep -i Darwin && OSS=osx @@ -99,6 +102,8 @@ export JOGL_CLASSPATH if [ "$KERNEL" = "linux" ] ; then SWT_SUB="gtk" +elif [ "$KERNEL" = "solaris" ] ; then + SWT_SUB="gtk" elif [ "$KERNEL" = "darwin" ] ; then SWT_SUB="cocoa" KERNEL="macosx" diff --git a/make/build-common.xml b/make/build-common.xml index 8d440a766..4de5de58b 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -362,6 +362,7 @@ + @@ -374,6 +375,7 @@ + diff --git a/make/build-newt.xml b/make/build-newt.xml index a6be5042e..776708857 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -107,6 +107,9 @@ + + @@ -135,11 +138,16 @@ + + + + - + @@ -707,6 +715,13 @@ + + + + + + - + diff --git a/make/build-test.xml b/make/build-test.xml index 51eadfebd..f295ae321 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -427,7 +427,7 @@ - - + - - @@ -491,40 +489,71 @@ - - - - - - - - - - - - - - - - + + + + - + - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 109755d2e..c8a90454d 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -18,7 +18,7 @@ set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluege echo CP_ALL %CP_ALL% -set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" +REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" @@ -37,7 +37,7 @@ REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" -REM set D_ARGS="-Dnewt.debug.Window" +set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" REM set D_ARGS="-Djogl.debug.GLContext" "-Dnewt.debug=all" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 0b3711784..6d3e46af6 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -28,22 +28,29 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransf REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT -time 2000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01AWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* + +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT @@ -56,8 +63,6 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.Mo REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleAWT -time 10000 @@ -96,7 +101,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMe REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 13e172770..af6218968 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -61,7 +61,7 @@ function jrun() { #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" - #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.DontQuery -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.QueryNativeTK -Djogl.debug.GLDrawable" @@ -145,7 +145,8 @@ function jrun() { echo CLASSPATH $CLASSPATH X_ARGS="-Djava.awt.headless=false $X_ARGS" else - export CLASSPATH=$JOGAMP_ALL_NOAWT_CLASSPATH + export CLASSPATH=$JOGAMP_ALL_AWT_CLASSPATH + #export CLASSPATH=$JOGAMP_ALL_NOAWT_CLASSPATH #export CLASSPATH=$JOGAMP_MOBILE_CLASSPATH #export CLASSPATH=.:$GLUEGEN_JAR:$JOGL_BUILD_DIR/jar/atomic/jogl-core.jar:$JOGL_BUILD_DIR/jar/atomic/jogl-gldesktop.jar:$JOGL_BUILD_DIR/jar/atomic/jogl-os-x11.jar:$JOGL_BUILD_DIR/jar/atomic/jogl-util.jar:$JOGL_BUILD_DIR/jar/atomic/nativewindow-core.jar:$JOGL_BUILD_DIR/jar/atomic/nativewindow-os-x11.jar:$JOGL_BUILD_DIR/jar/atomic/newt-core.jar:$JOGL_BUILD_DIR/jar/atomic/newt-driver-x11.jar:$JOGL_BUILD_DIR/jar/atomic/newt-ogl.jar:$JOGL_BUILD_DIR/jar/jogl-test.jar:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS X_ARGS="-Djava.awt.headless=true $X_ARGS" @@ -298,13 +299,17 @@ function testawtswt() { # #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02GLn $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* # -# awtswt (testawtswt) +# awtswt (testawtswt) +# Per default (unit tests) all test are performed this way +# with OSX: -XstartOnFirstThread # +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* # # newt.awt (testawt) @@ -321,6 +326,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* +testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* @@ -402,7 +410,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #linux: -testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02GLn $* # ?? # osx: #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* diff --git a/make/stub_includes/win32/wingdi.h b/make/stub_includes/win32/wingdi.h index 2d3e33275..7a88582c2 100644 --- a/make/stub_includes/win32/wingdi.h +++ b/make/stub_includes/win32/wingdi.h @@ -44,6 +44,8 @@ WINUSERAPI BOOL WINAPI DestroyWindow(HWND hWnd); WINUSERAPI DWORD WINAPI GetObjectType(HGDIOBJ h); WINUSERAPI BOOL WINAPI IsWindowVisible(HWND hWnd); WINUSERAPI BOOL WINAPI IsWindow(HWND hWnd); +WINUSERAPI HWND WINAPI GetParent(HWND hWnd); +WINUSERAPI HWND WINAPI SetParent(HWND hWndChild,HWND hWndNewParent); WINUSERAPI HANDLE WINAPI GetCurrentProcess(void); WINUSERAPI BOOL WINAPI GetProcessAffinityMask(HANDLE hProcess,PDWORD_PTR lpProcessAffinityMask,PDWORD_PTR lpSystemAffinityMask); diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 1d9cf3668..5334d45cf 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -410,7 +410,7 @@ public class BuildComposablePipeline { output.flush(); output.close(); - System.out.println("wrote to file: " + file); // JAU + System.out.println("wrote to file: " + file); } /** Get the name of the object through which API calls should be routed. */ diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 64ee1c1ad..8d237162c 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -45,6 +45,7 @@ import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; import javax.media.opengl.Threading; +import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableHelper; @@ -70,8 +71,12 @@ import com.jogamp.opengl.JoglVersion; /** * Native SWT Canvas implementing GLAutoDrawable + * + *

Note: To employ custom GLCapabilities, NewtCanvasSWT shall be used instead.

+ * */ public class GLCanvas extends Canvas implements GLAutoDrawable { + private static final boolean DEBUG = Debug.debug("GLCanvas"); /* * Flag for whether the SWT thread should be used for OpenGL calls when in single-threaded mode. This is controlled @@ -87,18 +92,20 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* GL Stuff */ private final RecursiveLock lock = LockFactory.createRecursiveLock(); private final GLDrawableHelper helper = new GLDrawableHelper(); + + private final GLContext shareWith; + private final GLCapabilitiesImmutable capsRequested; + private final GLCapabilitiesChooser capsChooser; + private volatile GLDrawable drawable; // volatile: avoid locking for read-only access private GLContext context; /* Native window surface */ private AbstractGraphicsDevice device; - private final long nativeWindowHandle; - private final ProxySurface proxySurface; /* Construction parameters stored for GLAutoDrawable accessor methods */ private int additionalCtxCreationFlags = 0; - private final GLCapabilitiesImmutable glCapsRequested; /* Flag indicating whether an unprocessed reshape is pending. */ private volatile boolean sendReshape; // volatile: maybe written by WindowManager thread w/o locking @@ -218,6 +225,37 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { */ private volatile Rectangle clientArea; + /** + * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser, GLContext)} + * on the SWT thread. + * + * @param parent + * Required (non-null) parent Composite. + * @param style + * Optional SWT style bit-field. The {@link SWT#NO_BACKGROUND} bit is set before passing this up to the + * Canvas constructor, so OpenGL handles the background. + * @param caps + * Optional GLCapabilities. If not provided, the default capabilities for the default GLProfile for the + * graphics device determined by the parent Composite are used. Note that the GLCapabilities that are + * actually used may differ based on the capabilities of the graphics device. + * @param chooser + * Optional GLCapabilitiesChooser to customize the selection of the used GLCapabilities based on the + * requested GLCapabilities, and the available capabilities of the graphics device. + * @param shareWith + * Optional GLContext to share state (textures, vbos, shaders, etc.) with. + * @return a new instance + */ + public static GLCanvas create(final Composite parent, final int style, final GLCapabilitiesImmutable caps, + final GLCapabilitiesChooser chooser, final GLContext shareWith) { + final GLCanvas[] res = new GLCanvas[] { null }; + parent.getDisplay().syncExec(new Runnable() { + public void run() { + res[0] = new GLCanvas( parent, style, caps, chooser, shareWith ); + } + }); + return res[0]; + } + /** * Creates a new SWT GLCanvas. * @@ -250,35 +288,26 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). * Note: SWT is owner of the native handle, hence no closing operation will be a NOP. */ device = SWTAccessor.getDevice(this); - /* Since we have no means of querying the screen index yet, assume 0. Good choice due to Xinerama alike settings anyways. */ - final int screenIdx = 0; - /* Native handle for the control, used to associate with GLContext */ - nativeWindowHandle = SWTAccessor.getWindowHandle(this); /* Select default GLCapabilities if none was provided, otherwise clone provided caps to ensure safety */ if(null == caps) { caps = new GLCapabilities(GLProfile.getDefault(device)); } - glCapsRequested = caps; - - final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile()); - - /* Create a NativeWindow proxy for the SWT canvas */ - proxySurface = glFactory.createProxySurface(device, screenIdx, nativeWindowHandle, caps, chooser, swtCanvasUpStreamHook); - - /* Associate a GL surface with the proxy */ - drawable = glFactory.createGLDrawable(proxySurface); - drawable.setRealized(true); - - context = drawable.createContext(shareWith); - + this.capsRequested = caps; + this.capsChooser = chooser; + this.shareWith = shareWith; + + // post create .. when ready + drawable = null; + context = null; + /* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */ /* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */ addPaintListener(new PaintListener() { @Override public void paintControl(final PaintEvent arg0) { - if (!helper.isExternalAnimatorAnimating()) { - display(); + if ( !helper.isExternalAnimatorAnimating() ) { + display(); // checks: null != drawable } } }); @@ -291,39 +320,93 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { }); } private final ProxySurface.UpstreamSurfaceHook swtCanvasUpStreamHook = new ProxySurface.UpstreamSurfaceHook() { - @Override - public final void create(ProxySurface s) { /* nop */ } - - @Override - public final void destroy(ProxySurface s) { /* nop */ } - - @Override - public final int getWidth(ProxySurface s) { - return clientArea.width; - } - - @Override - public final int getHeight(ProxySurface s) { - return clientArea.height; - } - - @Override - public String toString() { - return "SETUpstreamSurfaceHook[upstream: "+GLCanvas.this.toString()+"]"; - } - + @Override + public final void create(ProxySurface s) { /* nop */ } + + @Override + public final void destroy(ProxySurface s) { /* nop */ } + + @Override + public final int getWidth(ProxySurface s) { + return clientArea.width; + } + + @Override + public final int getHeight(ProxySurface s) { + return clientArea.height; + } + + @Override + public String toString() { + return "SWTCanvasUpstreamSurfaceHook[upstream: "+GLCanvas.this.toString()+", "+clientArea.width+"x"+clientArea.height+"]"; + } }; protected final void updateSizeCheck() { - clientArea = GLCanvas.this.getClientArea(); - if (clientArea != null && - proxySurface.getWidth() != clientArea.width && - proxySurface.getHeight() != clientArea.height) { + final Rectangle oClientArea = clientArea; + final Rectangle nClientArea = GLCanvas.this.getClientArea(); + if ( nClientArea != null && + ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) + ) { + clientArea = nClientArea; // write back new value sendReshape = true; // Mark for OpenGL reshape next time the control is painted } - sendReshape = false; + } + + @Override + public void display() { + if( null != drawable || validateDrawableAndContext() ) { + runInGLThread(makeCurrentAndDisplayOnEDTAction); + } } + + /** assumes drawable == null ! */ + protected final boolean validateDrawableAndContext() { + if( GLCanvas.this.isDisposed() ) { + return false; + } + final Rectangle nClientArea = clientArea; + if(0 == nClientArea.width * nClientArea.height) { + return false; + } + + final RecursiveLock _lock = lock; + _lock.lock(); + try { + final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(capsRequested.getGLProfile()); + + /* Native handle for the control, used to associate with GLContext */ + final long nativeWindowHandle = SWTAccessor.getWindowHandle(this); + + /* Create a NativeWindow proxy for the SWT canvas */ + ProxySurface proxySurface = null; + try { + proxySurface = glFactory.createProxySurface(device, 0 /* screenIdx */, nativeWindowHandle, + capsRequested, capsChooser, swtCanvasUpStreamHook); + } catch (GLException gle) { + // not ready yet .. + if(DEBUG) { System.err.println(gle.getMessage()); } + } + + if(null != proxySurface) { + /* Associate a GL surface with the proxy */ + drawable = glFactory.createGLDrawable(proxySurface); + drawable.setRealized(true); + + context = drawable.createContext(shareWith); + } + } finally { + _lock.unlock(); + } + final boolean res = null != drawable; + if(DEBUG && res) { + System.err.println("SWT GLCanvas realized! "+this+", "+drawable); + Thread.dumpStack(); + } + return res; + } + @Override public final Object getUpstreamWidget() { return this; @@ -362,11 +445,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { dispose(); } - @Override - public void display() { - runInGLThread(makeCurrentAndDisplayOnEDTAction); - } - @Override public GLAnimatorControl getAnimator() { return helper.getAnimator(); @@ -379,7 +457,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLContext getContext() { - return context; + return null != drawable ? context : null; } @Override @@ -472,7 +550,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { - return (GLCapabilitiesImmutable)proxySurface.getGraphicsConfiguration().getChosenCapabilities(); + final GLDrawable _drawable = drawable; + return null != _drawable ? (GLCapabilitiesImmutable)_drawable.getChosenGLCapabilities() : null; } /** @@ -481,7 +560,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * @return Non-null GLCapabilities. */ public GLCapabilitiesImmutable getRequestedGLCapabilities() { - return (GLCapabilitiesImmutable)proxySurface.getGraphicsConfiguration().getRequestedCapabilities(); + final GLDrawable _drawable = drawable; + return null != _drawable ? (GLCapabilitiesImmutable)_drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities() : null; } @Override @@ -492,7 +572,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLProfile getGLProfile() { - return glCapsRequested.getGLProfile(); + return capsRequested.getGLProfile(); } @Override @@ -523,10 +603,9 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { runInGLThread(makeCurrentAndSwapBuffersOnEDTAction); } - // FIXME: API of update() method ? @Override public void update() { - // FIXME: display(); ? + // don't paint background etc .. nop avoids flickering } @Override @@ -551,7 +630,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * @see Platform#AWT_AVAILABLE * @see Platform#getOSType() */ - private void runInGLThread(final Runnable action) { + private static void runInGLThread(final Runnable action) { if(Platform.OSType.MACOS == Platform.OS_TYPE) { SWTAccessor.invoke(true, action); } else { diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index e730bc62e..bf6a0ee6e 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -338,7 +338,6 @@ public abstract class GLContextImpl extends GLContext { if (TRACE_SWITCH) { System.err.println(getThreadName() + ": GLContextImpl.destroy.X: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) + ", isShared "+GLContextShareSet.isShared(this)+" - "+lock); - Thread.dumpStack(); // JAU } } } finally { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 0494bb408..ba07d97dc 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -34,16 +34,21 @@ import java.lang.reflect.Method; import org.eclipse.swt.graphics.GCData; import org.eclipse.swt.widgets.Control; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.VisualIDHolder; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; import jogamp.nativewindow.macosx.OSXUtil; +import jogamp.nativewindow.x11.X11Lib; public class SWTAccessor { static final Field swt_control_handle; @@ -213,6 +218,26 @@ public class SWTAccessor { } throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false)); } + public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) { + if( null != OS_gtk_class ) { + return new X11GraphicsScreen((X11GraphicsDevice)device, screen); + } + if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) || + NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) { + return new DefaultGraphicsScreen(device, screen); + } + throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false)); + } + public static int getNativeVisualID(AbstractGraphicsDevice device, long windowHandle) { + if( null != OS_gtk_class ) { + return X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle); + } + if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) || + NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) { + return VisualIDHolder.VID_UNDEFINED; + } + throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false)); + } public static long getWindowHandle(Control swtControl) { long handle = getHandle(swtControl); diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index b85ad47f2..6faa9890c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -561,4 +561,21 @@ public abstract class NativeWindowFactory { } return null; } + + /** + * Returns true if the given visualID is valid for further processing, i.e. OpenGL usage, + * otherwise return false. + *

+ * On certain platforms, i.e. X11, a valid visualID is required at window creation. + * Other platforms may determine it later on, e.g. OSX and Windows.

+ *

+ * If the visualID is {@link VisualIDHolder#VID_UNDEFINED} and the platform requires it + * at creation time (see above), it is not valid for further processing. + *

+ */ + public static boolean isNativeVisualIDValidForProcessing(int visualID) { + return NativeWindowFactory.TYPE_X11 != NativeWindowFactory.getNativeWindowType(false) || + VisualIDHolder.VID_UNDEFINED != visualID ; + } + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 4767dff18..894084fce 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -28,6 +28,7 @@ package jogamp.nativewindow.macosx; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; import jogamp.nativewindow.Debug; @@ -63,8 +64,37 @@ public class OSXUtil { return isNSView0(object); } - public static Point GetLocationOnScreen(long windowOrView, int src_x, int src_y) { - return (Point) GetLocationOnScreen0(windowOrView, src_x, src_y); + /** + * In case the windowOrView is top-level, + * you shall set topLevel to true where + * insets gets into account to compute the client position as follows: + *
+      if(topLevel) {
+          // top-level position -> client window position
+          final Insets insets = GetInsets(windowOrView);
+          los.setX(los.getX() + insets.getLeftWidth());
+          los.setY(los.getY() + insets.getTopHeight());
+      }
+     * 
+ * @param windowOrView + * @param topLevel + * @param src_x + * @param src_y + * @return the client position + */ + public static Point GetLocationOnScreen(long windowOrView, boolean topLevel, int src_x, int src_y) { + final Point los = (Point) GetLocationOnScreen0(windowOrView, src_x, src_y); + if(topLevel) { + // top-level position -> client window position + final Insets insets = GetInsets(windowOrView); + los.setX(los.getX() + insets.getLeftWidth()); + los.setY(los.getY() + insets.getTopHeight()); + } + return los; + } + + public static Insets GetInsets(long windowOrView) { + return (Insets) GetInsets0(windowOrView); } public static long CreateNSWindow(int x, int y, int width, int height) { @@ -135,6 +165,7 @@ public class OSXUtil { private static native boolean initIDs0(); private static native boolean isNSView0(long object); private static native Object GetLocationOnScreen0(long windowOrView, int src_x, int src_y); + private static native Object GetInsets0(long windowOrView); private static native long CreateNSWindow0(int x, int y, int width, int height); private static native void DestroyNSWindow0(long nsWindow); private static native long GetNSView0(long nsWindow); diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 37fa4c88f..2c853a43d 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -52,12 +52,18 @@ static const char * const ClazzNameRunnable = "java/lang/Runnable"; static jmethodID runnableRunID = NULL; -static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; static const char * const ClazzAnyCstrName = ""; + +static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; static const char * const ClazzNamePointCstrSignature = "(II)V"; static jclass pointClz = NULL; static jmethodID pointCstr = NULL; +static const char * const ClazzNameInsets = "javax/media/nativewindow/util/Insets"; +static const char * const ClazzNameInsetsCstrSignature = "(IIII)V"; +static jclass insetsClz = NULL; +static jmethodID insetsCstr = NULL; + static int _initialized=0; JNIEXPORT jboolean JNICALL @@ -79,6 +85,21 @@ Java_jogamp_nativewindow_macosx_OSXUtil_initIDs0(JNIEnv *env, jclass _unused) { ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature); } + c = (*env)->FindClass(env, ClazzNameInsets); + if(NULL==c) { + NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't find %s", ClazzNameInsets); + } + insetsClz = (jclass)(*env)->NewGlobalRef(env, c); + (*env)->DeleteLocalRef(env, c); + if(NULL==insetsClz) { + NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't use %s", ClazzNameInsets); + } + insetsCstr = (*env)->GetMethodID(env, insetsClz, ClazzAnyCstrName, ClazzNameInsetsCstrSignature); + if(NULL==insetsCstr) { + NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't fetch %s.%s %s", + ClazzNameInsets, ClazzAnyCstrName, ClazzNameInsetsCstrSignature); + } + c = (*env)->FindClass(env, ClazzNameRunnable); if(NULL==c) { NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't find %s", ClazzNameRunnable); @@ -154,6 +175,49 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetLocationOnS return res; } +/* + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: getInsets0 + * Signature: (J)Ljavax/media/nativewindow/util/Insets; + */ +JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetInsets0 + (JNIEnv *env, jclass unused, jlong winOrView) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + NSObject *nsObj = (NSObject*) (intptr_t) winOrView; + NSWindow* win = NULL; + NSView* view = NULL; + jint il,ir,it,ib; + + if( [nsObj isKindOfClass:[NSWindow class]] ) { + win = (NSWindow*) nsObj; + view = [win contentView]; + } else if( nsObj != NULL && [nsObj isKindOfClass:[NSView class]] ) { + view = (NSView*) nsObj; + win = [view window]; + } else { + NativewindowCommon_throwNewRuntimeException(env, "neither win not view %p\n", nsObj); + } + + NSRect frameRect = [win frame]; + NSRect contentRect = [win contentRectForFrameRect: frameRect]; + + // note: this is a simplistic implementation which doesn't take + // into account DPI and scaling factor + CGFloat l = contentRect.origin.x - frameRect.origin.x; + il = (jint)l; // l + ir = (jint)(frameRect.size.width - (contentRect.size.width + l)); // r + it = (jint)(frameRect.size.height - contentRect.size.height); // t + ib = (jint)(contentRect.origin.y - frameRect.origin.y); // b + + jobject res = (*env)->NewObject(env, insetsClz, insetsCstr, il, ir, it, ib); + + [pool release]; + + return res; +} + /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: CreateNSWindow0 @@ -172,6 +236,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 defer: YES]; [myWindow setReleasedWhenClosed: YES]; // default [myWindow setPreservesContentDuringLiveResize: YES]; + // Remove animations +NS_DURING + // Available >= 10.7 - Removes default animations + [myWindow setAnimationBehavior: NSWindowAnimationBehaviorNone]; +NS_HANDLER +NS_ENDHANDLER // invisible .. [myWindow setOpaque: NO]; @@ -229,7 +299,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; CALayer* layer = [[CALayer alloc] init]; - DBG_PRINT("CALayer::CreateCALayer.0: %p %d/%d %dx%d (refcnt %d)\n", layer, x, y, width, height, (int)[layer retainCount]); + DBG_PRINT("CALayer::CreateCALayer.0: %p %d/%d %dx%d (refcnt %d)\n", layer, (int)x, (int)y, (int)width, (int)height, (int)[layer retainCount]); // avoid zero size if(0 == width) { width = 32; } if(0 == height) { height = 32; } diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 7b6849a30..1e9a0e9eb 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -141,6 +141,23 @@ public abstract class Display { */ public abstract String getType(); + /** + * Sets a new {@link EDTUtil} and returns the previous one. + *

+ * If newEDTUtil is null, + * the device's default EDTUtil is created and used. + *

+ *

+ * If a previous one exists and it differs from the new one, + * it's being stopped, wait-until-idle and reset to allow restart. + *

+ *

+ * If newEDTUtil is not null and equals the previous one, + * null is returned and no change is being made. + *

+ */ + public abstract EDTUtil setEDTUtil(EDTUtil newEDTUtil); + public abstract EDTUtil getEDTUtil(); public abstract boolean isEDTRunning(); diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index cd0e9aab6..6f0028a77 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -263,17 +263,35 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final FocusPropertyChangeListener focusPropertyChangeListener = new FocusPropertyChangeListener(); private volatile KeyboardFocusManager keyboardFocusManager = null; - /** sets a new NEWT child, provoking reparenting. */ - private NewtCanvasAWT setNEWTChild(Window child) { - if(newtChild!=child) { - newtChild = child; - if(isDisplayable()) { - // reparent right away, addNotify has been called already - final java.awt.Container cont = AWTMisc.getContainer(this); - reparentWindow( (null!=child) ? true : false, cont ); - } + /** + * Sets a new NEWT child, provoking reparenting. + *

+ * A previously detached newChild will be released to top-level status + * and made invisible. + *

+ *

+ * Note: When switching NEWT child's, detaching the previous first via setNEWTChild(null) + * produced much cleaner visual results. + *

+ * @return the previous attached newt child. + */ + public Window setNEWTChild(Window newChild) { + final Window prevChild = newtChild; + if(DEBUG) { + System.err.println("NewtCanvasAWT.setNEWTChild.0: win "+newtWinHandleToHexString(prevChild)+" -> "+newtWinHandleToHexString(newChild)); + } + final java.awt.Container cont = AWTMisc.getContainer(this); + // remove old one + if(null != newtChild) { + reparentWindow( false, cont ); + newtChild = null; } - return this; + // add new one, reparent only if ready + newtChild = newChild; + if( isDisplayable() && null != newChild) { + reparentWindow( true, cont ); + } + return prevChild; } /** @return the current NEWT child */ @@ -306,13 +324,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto awtKeyAdapter.removeFrom(this); awtKeyAdapter = null; } - newtChild.setKeyboardFocusHandler(null); if(null != keyboardFocusManager) { keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener); keyboardFocusManager = null; } if( null != newtChild ) { + newtChild.setKeyboardFocusHandler(null); if(attach) { if(null == jawtWindow.getGraphicsConfiguration()) { throw new InternalError("XXX"); @@ -360,7 +378,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto // if ( isShowing() == true ) -> Container is already visible. System.err.println("NewtCanvasAWT.addNotify: "+newtChild+", "+this+", visible "+isVisible()+", showing "+isShowing()+ ", displayable "+isDisplayable()+" -> "+cont); - } + } reparentWindow(true, cont); } @@ -375,6 +393,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto ols.detachSurfaceLayer(); } reparentWindow(false, cont); + + if(null != jawtWindow) { + NewtFactoryAWT.destroyNativeWindow(jawtWindow); + jawtWindow=null; + } + super.removeNotify(); } @@ -382,14 +406,19 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(null==newtChild) { return; // nop } + if(DEBUG) { + System.err.println("NewtCanvasAWT.reparentWindow.0: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); + } newtChild.setFocusAction(null); // no AWT focus traversal .. if(add) { - jawtWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities()); - jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); if(DEBUG) { System.err.println("NewtCanvasAWT.reparentWindow: newtChild: "+newtChild); } + if(null == jawtWindow) { + jawtWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities()); + jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); + } final int w; final int h; if(isPreferredSizeSet()) { @@ -413,7 +442,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.setVisible(true); configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener - newtChild.windowRepaint(0, 0, w, h); // force this AWT Canvas to be focus-able, // since this it is completely covered by the newtChild (z-order). @@ -422,10 +450,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto configureNewtChild(false); newtChild.setVisible(false); newtChild.reparentWindow(null); - if(null != jawtWindow) { - NewtFactoryAWT.destroyNativeWindow(jawtWindow); - jawtWindow=null; - } + } + if(DEBUG) { + System.err.println("NewtCanvasAWT.reparentWindow.X: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); } } @@ -451,7 +478,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto NewtFactoryAWT.destroyNativeWindow(jawtWindow); jawtWindow=null; } - newtChild.setVisible(false); + newtChild.setVisible(false); newtChild.reparentWindow(null); newtChild.destroy(); newtChild=null; @@ -569,5 +596,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } } + + static String newtWinHandleToHexString(Window w) { + return null != w ? toHexString(w.getWindowHandle()) : "nil"; + } + static String toHexString(long l) { + return "0x"+Long.toHexString(l); + } } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 2205aec8e..d662a743a 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -480,7 +480,6 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } if(Window.DEBUG_IMPLEMENTATION) { System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+WindowImpl.getThreadName()+", fin: dt "+ (System.nanoTime()-t0)/1e6 +"ms"); - Thread.dumpStack(); // JAU } } diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java new file mode 100644 index 000000000..f45b864fa --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -0,0 +1,508 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + + +package com.jogamp.newt.swt; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.SurfaceUpdatedListener; +import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.Point; + +import jogamp.nativewindow.macosx.OSXUtil; +import jogamp.newt.Debug; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; + +import com.jogamp.nativewindow.swt.SWTAccessor; +import com.jogamp.newt.Display; +import com.jogamp.newt.Window; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.util.EDTUtil; + +public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { + private static final boolean DEBUG = Debug.debug("Window"); + private static final boolean isOSX = NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false); + + /** SWT EDTUtil associated w/ parent's SWT Display */ + private final EDTUtil swtEDTUtil; + + private final AbstractGraphicsScreen screen; + + private WindowClosingMode newtChildCloseOp = WindowClosingMode.DISPOSE_ON_CLOSE; + private volatile Rectangle clientArea; + + private volatile SWTNativeWindow nativeWindow; + private volatile Window newtChild = null; + + /** + * Creates an instance using {@link #NewtCanvasSWT(Composite, int, Window)} + * on the SWT thread. + * + *

+ * Note: The NEWT child {@link Display}'s {@link EDTUtil} is being set to an SWT conform implementation + * via {@link Display#setEDTUtil(EDTUtil)}. + *

+ * + * @param parent the SWT composite + * @param style additional styles to SWT#NO_BACKGROUND + * @param child optional preassigned {@link #Window}, maybe null + * @return a new instance + */ + public static NewtCanvasSWT create(final Composite parent, final int style, final Window child) { + final NewtCanvasSWT[] res = new NewtCanvasSWT[] { null }; + parent.getDisplay().syncExec( new Runnable() { + public void run() { + res[0] = new NewtCanvasSWT( parent, style, child); + } + }); + return res[0]; + } + + /** + * Instantiates a NewtCanvas with a NEWT child. + * + *

+ * Note: The NEWT child {@link Display}'s {@link EDTUtil} is being set to an SWT conform implementation + * via {@link Display#setEDTUtil(EDTUtil)}. + *

+ * + * @param parent the SWT composite + * @param style additional styles to SWT#NO_BACKGROUND + * @param child optional preassigned {@link #Window}, maybe null + */ + public NewtCanvasSWT(final Composite parent, final int style, Window child) { + super(parent, style | SWT.NO_BACKGROUND); + + swtEDTUtil = new SWTEDTUtil(parent.getDisplay()); + + SWTAccessor.setRealized(this, true); + + clientArea = getClientArea(); + + final AbstractGraphicsDevice device = SWTAccessor.getDevice(this); + screen = SWTAccessor.getScreen(device, 0); + nativeWindow = null; + + if(null != child) { + setNEWTChild(child); + } + + /* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */ + /* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */ + addPaintListener(new PaintListener() { + @Override + public void paintControl(final PaintEvent arg0) { + if( null != nativeWindow || validateNative() ) { + if( null !=newtChild ) { + newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height); + } + } + } + }); + + addControlListener(new ControlAdapter() { + @Override + public void controlResized(final ControlEvent arg0) { + updateSizeCheck(); + } + }); + } + + /** assumes nativeWindow == null ! */ + protected final boolean validateNative() { + if( isDisposed() ) { + return false; + } + updateSizeCheck(); + final Rectangle nClientArea = clientArea; + if(0 == nClientArea.width * nClientArea.height) { + return false; + } + + /* Native handle for the control, used to associate with GLContext */ + final long nativeWindowHandle = SWTAccessor.getWindowHandle(this); + final int visualID = SWTAccessor.getNativeVisualID(screen.getDevice(), nativeWindowHandle); + final boolean visualIDValid = NativeWindowFactory.isNativeVisualIDValidForProcessing(visualID); + if(DEBUG) { + System.err.println("NewtCanvasSWT.validateNative() windowHandle 0x"+Long.toHexString(nativeWindowHandle)+", visualID 0x"+Integer.toHexString(visualID)+", valid "+visualIDValid); + } + if( visualIDValid ) { + /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). + * Note: SWT is owner of the native handle, hence no closing operation will be a NOP. */ + final CapabilitiesImmutable caps = new Capabilities(); + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(screen.getDevice(), caps); + final AbstractGraphicsConfiguration config = factory.chooseGraphicsConfiguration( caps, caps, null, screen, visualID ); + if(DEBUG) { + System.err.println("NewtCanvasSWT.validateNative() factory: "+factory+", windowHandle 0x"+Long.toHexString(nativeWindowHandle)+", visualID 0x"+Integer.toHexString(visualID)+", chosen config: "+config); + // Thread.dumpStack(); + } + if (null == config) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + + nativeWindow = new SWTNativeWindow(config, nativeWindowHandle); + reparentWindow( true ); + } + + return null != nativeWindow; + } + + protected final void updateSizeCheck() { + final Rectangle oClientArea = clientArea; + final Rectangle nClientArea = getClientArea(); + if ( nClientArea != null && + ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) + ) { + clientArea = nClientArea; // write back new value + if( null != newtChild ) { + newtChild.setSize(clientArea.width, clientArea.height); + } + } + } + + @Override + public void update() { + // don't paint background etc .. nop avoids flickering + } + + /** + * Destroys this resource: + *
    + *
  • Make the NEWT Child invisible
  • + *
  • Disconnects the NEWT Child from this Canvas NativeWindow, reparent to NULL
  • + *
  • Issues destroy() on the NEWT Child
  • + *
  • Remove reference to the NEWT Child
  • + *
+ * @see Window#destroy() + */ + @Override + public void dispose() { + if( null != newtChild ) { + if(DEBUG) { + System.err.println("NewtCanvasSWT.dispose.0: EDTUtil cur "+newtChild.getScreen().getDisplay().getEDTUtil()+ + ",\n\t"+newtChild); + } + configureNewtChild(false); + newtChild.setVisible(false); + newtChild.reparentWindow(null); + newtChild.destroy(); + newtChild = null; + } + nativeWindow = null; + super.dispose(); + } + + /** @return this SWT Canvas NativeWindow representation, may be null in case it has not been realized. */ + public NativeWindow getNativeWindow() { return nativeWindow; } + + public WindowClosingMode getDefaultCloseOperation() { + return newtChildCloseOp; // FIXME + } + + public WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { + return newtChildCloseOp = op; // FIXME + } + + + boolean isParent() { + return null!=newtChild ; + } + + boolean isFullscreen() { + return null != newtChild && newtChild.isFullscreen(); + } + + /** + * Sets a new NEWT child, provoking reparenting. + *

+ * A previously detached newChild will be released to top-level status + * and made invisible. + *

+ *

+ * Note: When switching NEWT child's, detaching the previous first via setNEWTChild(null) + * produced much cleaner visual results. + *

+ *

+ * Note: The NEWT child {@link Display}'s {@link EDTUtil} is being set to an SWT conform implementation + * via {@link Display#setEDTUtil(EDTUtil)}. + *

+ * @return the previous attached newt child. + */ + public Window setNEWTChild(final Window newChild) { + final Window prevChild = newtChild; + if(DEBUG) { + System.err.println("NewtCanvasSWT.setNEWTChild.0: win "+newtWinHandleToHexString(prevChild)+" -> "+newtWinHandleToHexString(newChild)); + } + // remove old one + if(null != newtChild) { + reparentWindow( false ); + newtChild = null; + } + // add new one, reparent only if ready + newtChild = newChild; + if(null != nativeWindow && null != newChild) { + reparentWindow( true ); + } + return prevChild; + } + + /** @return the current NEWT child */ + public Window getNEWTChild() { + return newtChild; + } + + @Override + public boolean setParent(Composite parent) { + return super.setParent(parent); + } + + /* package */ void configureNewtChild(boolean attach) { + + if( null != newtChild ) { + newtChild.setKeyboardFocusHandler(null); + if(attach) { + newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); + } else { + newtChild.setFocusAction(null); + newtChild.setDefaultCloseOperation(newtChildCloseOp); + } + } + } + + void reparentWindow(boolean add) { + if( null == newtChild ) { + return; // nop + } + if(DEBUG) { + System.err.println("NewtCanvasSWT.reparentWindow.0: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); + } + + newtChild.setFocusAction(null); // no AWT focus traversal .. + if(add) { + updateSizeCheck(); + final int w = clientArea.width; + final int h = clientArea.height; + + newtChild.getScreen().getDisplay().setEDTUtil(swtEDTUtil); + + newtChild.setSize(w, h); + newtChild.reparentWindow(nativeWindow); + newtChild.setVisible(true); + configureNewtChild(true); + newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener + + // force this SWT Canvas to be focus-able, + // since this it is completely covered by the newtChild (z-order). + setEnabled(true); + } else { + configureNewtChild(false); + newtChild.setVisible(false); + newtChild.reparentWindow(null); + } + if(DEBUG) { + System.err.println("NewtCanvasSWT.reparentWindow.X: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); + } + } + + private final void requestFocusNEWTChild() { + if( null != newtChild ) { + newtChild.setFocusAction(null); + newtChild.requestFocus(); + } + } + + @Override + public boolean forceFocus() { + final boolean res = NewtCanvasSWT.super.forceFocus(); + requestFocusNEWTChild(); + return res; + } + + private class SWTNativeWindow implements NativeWindow { + private final AbstractGraphicsConfiguration config; + private final long nativeWindowHandle; + private final InsetsImmutable insets; // only required to allow proper client position calculation on OSX + + public SWTNativeWindow(AbstractGraphicsConfiguration config, long nativeWindowHandle) { + this.config = config; + this.nativeWindowHandle = nativeWindowHandle; + if(isOSX) { + this.insets = OSXUtil.GetInsets(nativeWindowHandle); + } else { + this.insets = new Insets(0, 0, 0, 0); + } + } + + @Override + public int lockSurface() throws NativeWindowException, RuntimeException { + return NativeSurface.LOCK_SUCCESS; + } + + @Override + public void unlockSurface() { } + + @Override + public boolean isSurfaceLockedByOtherThread() { + return false; + } + + @Override + public Thread getSurfaceLockOwner() { + return null; + } + + @Override + public boolean surfaceSwap() { + return false; + } + + @Override + public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { } + + @Override + public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { + } + + @Override + public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { } + + @Override + public long getSurfaceHandle() { + return 0; + } + + @Override + public int getWidth() { + return clientArea.width; + } + + @Override + public int getHeight() { + return clientArea.height; + } + + @Override + public AbstractGraphicsConfiguration getGraphicsConfiguration() { + return config; + } + + @Override + public long getDisplayHandle() { + return config.getScreen().getDevice().getHandle(); + } + + @Override + public int getScreenIndex() { + return config.getScreen().getIndex(); + } + + @Override + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { } + + @Override + public void destroy() { } + + @Override + public NativeWindow getParent() { + return null; + } + + @Override + public long getWindowHandle() { + return nativeWindowHandle; + } + + @Override + public InsetsImmutable getInsets() { + return insets; + } + + @Override + public int getX() { + return 0; + } + + @Override + public int getY() { + return 0; + } + + @Override + public Point getLocationOnScreen(Point point) { + if( isOSX ) { + final Point los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); + // top-level position -> client window position + los.setX(los.getX() + insets.getLeftWidth()); + los.setY(los.getY() + insets.getTopHeight()); + if(null!=point) { + return point.translate(los); + } else { + return los; + } + } else { + // client position on 'normal' windowing systems is 0/0 + if(null == point) { + point = new Point(0, 0); + } + return point; + } + } + + @Override + public boolean hasFocus() { + return isFocusControl(); + } + }; + + static String newtWinHandleToHexString(Window w) { + return null != w ? toHexString(w.getWindowHandle()) : "nil"; + } + static String toHexString(long l) { + return "0x"+Long.toHexString(l); + } +} + diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java new file mode 100644 index 000000000..3538caad2 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java @@ -0,0 +1,99 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.newt.swt; + +import org.eclipse.swt.widgets.Display; + +import com.jogamp.newt.util.EDTUtil; + +/** + * Simple {@link EDTUtil} implementation utilizing the SWT UI thread + * of the given {@link Display}. + */ +public class SWTEDTUtil implements EDTUtil { + private final Display swtDisplay; + + public SWTEDTUtil(Display swtDisplay) { + this.swtDisplay = swtDisplay; + } + + public final Display getDisplay() { + return swtDisplay; + } + + @Override + public long getPollPeriod() { + return 0; + } + + @Override + public void setPollPeriod(long ms) { + } + + @Override + public void reset() { + } + + @Override + public void start() { + } + + @Override + public boolean isCurrentThreadEDT() { + return swtDisplay.getThread() == Thread.currentThread(); + } + + @Override + public boolean isRunning() { + return true; + } + + @Override + public void invokeStop(Runnable finalTask) { + swtDisplay.syncExec(finalTask); + } + + @Override + public void invoke(boolean wait, Runnable task) { + if(wait) { + swtDisplay.syncExec(task); + } else { + swtDisplay.asyncExec(task); + } + } + + @Override + public void waitUntilIdle() { + // all sync .. + } + + @Override + public void waitUntilStopped() { + // all sync .. + } +} diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index b10561c5b..b178bb5d3 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -101,7 +101,9 @@ public abstract class DisplayImpl extends Display { display.hashCode = display.fqname.hashCode(); displayList.add(display); } - display.createEDTUtil(); + if(null == display.edtUtil) { + display.setEDTUtil(null); // device's default if EDT is used, or null + } if(DEBUG) { System.err.println("Display.create() NEW: "+display+" "+getThreadName()); } @@ -168,15 +170,45 @@ public abstract class DisplayImpl extends Display { return true; } - protected void createEDTUtil() { + protected EDTUtil createEDTUtil() { + final EDTUtil def; if(NewtFactory.useEDT()) { - edtUtil = new DefaultEDTUtil(Thread.currentThread().getThreadGroup(), "Display-"+getFQName(), dispatchMessagesRunnable); + def = new DefaultEDTUtil(Thread.currentThread().getThreadGroup(), "Display-"+getFQName(), dispatchMessagesRunnable); if(DEBUG) { - System.err.println("Display.createNative("+getFQName()+") Create EDTUtil: "+edtUtil.getClass().getName()); + System.err.println("Display.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName()); } + } else { + def = null; } + return def; } + @Override + public EDTUtil setEDTUtil(EDTUtil newEDTUtil) { + if(null == newEDTUtil) { + newEDTUtil = createEDTUtil(); + } + if( newEDTUtil == edtUtil ) { + if(DEBUG) { + System.err.println("Display.setEDTUtil: "+newEDTUtil+" - keep!"); + } + return null; // no change + } + final EDTUtil oldEDTUtil = edtUtil; + if(DEBUG) { + System.err.println("Display.setEDTUtil: "+oldEDTUtil+" -> "+newEDTUtil); + } + if(null != oldEDTUtil) { + stopEDT( new Runnable() { public void run() {} } ); + // ready for restart .. + oldEDTUtil.waitUntilStopped(); + oldEDTUtil.reset(); + } + edtUtil = newEDTUtil; + return oldEDTUtil; + } + + @Override public final EDTUtil getEDTUtil() { return edtUtil; } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index b12e42680..606101ade 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -445,9 +445,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected abstract void closeNativeImpl(); /** - * The native implementation must invoke {@link #focusChanged(boolean, boolean)} - * to change the focus state, if force == false. - * This may happen asynchronous within {@link #TIMEOUT_NATIVEWINDOW}. + * Async request which shall be performed within {@link #TIMEOUT_NATIVEWINDOW}. + *

+ * If if force == false the native implementation + * may only request focus if not yet owner.

+ *

+ * {@link #focusChanged(boolean, boolean)} should be called + * to notify about the focus traversal. + *

* * @param force if true, bypass {@link #focusChanged(boolean, boolean)} and force focus request */ diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index ce8ed7c49..747e2368e 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -34,6 +34,7 @@ import javax.media.nativewindow.NativeWindow; import jogamp.newt.driver.DriverUpdatePosition; +import com.jogamp.newt.Window; import com.jogamp.newt.event.awt.AWTAdapter; import com.jogamp.newt.event.awt.AWTWindowAdapter; @@ -92,19 +93,20 @@ public class AWTParentWindowAdapter if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentResized: "+comp); } - getNewtWindow().runOnEDTIfAvail(false, new Runnable() { + final Window newtWindow = getNewtWindow(); + newtWindow.runOnEDTIfAvail(false, new Runnable() { public void run() { int cw = comp.getWidth(); int ch = comp.getHeight(); if( 0 < cw * ch ) { - if( getNewtWindow().getWidth() != cw || getNewtWindow().getHeight() != ch ) { - getNewtWindow().setSize(cw, ch); - if(comp.isVisible() != getNewtWindow().isVisible()) { - getNewtWindow().setVisible(comp.isVisible()); + if( newtWindow.getWidth() != cw || newtWindow.getHeight() != ch ) { + newtWindow.setSize(cw, ch); + if(comp.isVisible() != newtWindow.isVisible()) { + newtWindow.setVisible(comp.isVisible()); } } - } else if(getNewtWindow().isVisible()) { - getNewtWindow().setVisible(false); + } else if(newtWindow.isVisible()) { + newtWindow.setVisible(false); } }}); } @@ -113,8 +115,9 @@ public class AWTParentWindowAdapter if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentMoved: "+e); } - if(getNewtWindow().getDelegatedWindow() instanceof DriverUpdatePosition) { - ((DriverUpdatePosition)getNewtWindow().getDelegatedWindow()).updatePosition(); + final Window newtWindow = getNewtWindow(); + if(newtWindow.getDelegatedWindow() instanceof DriverUpdatePosition) { + ((DriverUpdatePosition)newtWindow.getDelegatedWindow()).updatePosition(); } } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java b/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java index 166da5c1c..65f8b4715 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java @@ -36,6 +36,7 @@ package jogamp.newt.driver.awt; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.util.EDTUtil; import jogamp.newt.DisplayImpl; @@ -54,13 +55,17 @@ public class AWTDisplay extends DisplayImpl { protected void closeNativeImpl() { } @Override - protected void createEDTUtil() { + protected EDTUtil createEDTUtil() { + final EDTUtil def; if(NewtFactory.useEDT()) { - edtUtil = AWTEDTUtil.getSingleton(); + def = AWTEDTUtil.getSingleton(); if(DEBUG) { - System.err.println("AWTDisplay.createNative("+getFQName()+") Create EDTUtil: "+edtUtil.getClass().getName()); + System.err.println("AWTDisplay.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName()); } + } else { + def = null; } + return def; } protected void dispatchMessagesNative() { /* nop */ } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java index 720d4ee4c..27d7a1679 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java @@ -150,7 +150,7 @@ public class MacWindow extends WindowImpl implements MutableSurface, DriverClear System.err.println("MacWindow: clearFocus() - requestFocusParent, isOffscreenInstance "+isOffscreenInstance); } if(!isOffscreenInstance) { - requestFocusParent0(getWindowHandle()); + resignFocus0(getWindowHandle()); } else { focusChanged(false, false); } @@ -360,7 +360,6 @@ public class MacWindow extends WindowImpl implements MutableSurface, DriverClear if(recreate && 0==surfaceHandle) { throw new NativeWindowException("Internal Error - recreate, window but no view"); } - orderOut0(getWindowHandle()); close0(getWindowHandle()); setWindowHandle(0); } else { @@ -397,7 +396,7 @@ public class MacWindow extends WindowImpl implements MutableSurface, DriverClear private native boolean lockSurface0(long window); private native void unlockSurface0(long window); private native void requestFocus0(long window, boolean force); - private native void requestFocusParent0(long window); + private native void resignFocus0(long window); /** in case of a child window, it actually only issues orderBack(..) */ private native void orderOut0(long window); private native void orderFront0(long window); diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java index 34d76a148..6a8c81f3d 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java @@ -151,8 +151,8 @@ public class WindowsWindow extends WindowImpl { } protected void closeNativeImpl() { - if (hdc != 0) { - if(windowHandleClose != 0) { + if(windowHandleClose != 0) { + if (hdc != 0) { try { GDI.ReleaseDC(windowHandleClose, hdc); } catch (Throwable t) { @@ -162,11 +162,8 @@ public class WindowsWindow extends WindowImpl { } } } - hdc = 0; - hdc_old = 0; - } - if(windowHandleClose != 0) { try { + GDI.SetParent(windowHandleClose, 0); // detach first, experience hang w/ SWT parent GDI.DestroyWindow(windowHandleClose); } catch (Throwable t) { if(DEBUG_IMPLEMENTATION) { @@ -177,6 +174,8 @@ public class WindowsWindow extends WindowImpl { windowHandleClose = 0; } } + hdc = 0; + hdc_old = 0; } protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 01cbd80ec..bbadc9dd0 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -599,6 +599,15 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0 } DBG_PRINT( "createWindow0 - is visible.1: %d\n", [myWindow isVisible]); + // Remove animations for child windows + if(NULL != parentWindow) { +NS_DURING + // Available >= 10.7 - Removes default animations + [myWindow setAnimationBehavior: NSWindowAnimationBehaviorNone]; +NS_HANDLER +NS_ENDHANDLER + } + #ifdef VERBOSE_ON int dbgIdx = 1; #endif @@ -734,7 +743,7 @@ NS_ENDHANDLER if(NULL!=pWin) { [mWin detachFromParent: pWin]; } - [mWin orderOut: mWin]; + [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:NO]; DBG_PRINT( "windowClose.1 - %p,%d view %p,%d, parent %p\n", mWin, getRetainCount(mWin), mView, getRetainCount(mView), pWin); @@ -742,11 +751,6 @@ NS_ENDHANDLER // Only release window, if release is not yet in process. // E.g. destroyNotifySent:=true set by NewtMacWindow::windowWillClose(), i.e. window-close was clicked. if(!destroyNotifySent) { - // '[mWin close]' causes a crash at exit. - // This probably happens b/c it sends events to the main loop - // but our resources are gone ?! - // However, issuing a simple release seems to work quite well. - // [mWin release]; [mWin performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO]; } @@ -806,11 +810,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_requestFocus0 DBG_PRINT( "requestFocus - window: %p, force %d, hasFocus %d (START)\n", mWin, force, hasFocus); [mWin makeFirstResponder: nil]; - [mWin performSelectorOnMainThread:@selector(orderFrontRegardless) withObject:nil waitUntilDone:YES]; - [mWin performSelectorOnMainThread:@selector(makeKeyWindow) withObject:nil waitUntilDone:YES]; - // This will occasionally cause a free of non allocated object crash: - // [mWin orderFrontRegardless]; - // [mWin makeKeyWindow]; + [mWin performSelectorOnMainThread:@selector(orderFrontRegardless) withObject:nil waitUntilDone:NO]; + [mWin performSelectorOnMainThread:@selector(makeKeyWindow) withObject:nil waitUntilDone:NO]; DBG_PRINT( "requestFocus - window: %p, force %d (END)\n", mWin, force); @@ -819,26 +820,27 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_requestFocus0 /* * Class: jogamp_newt_driver_macosx_MacWindow - * Method: requestFocusParent0 + * Method: resignFocus0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_requestFocusParent0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_resignFocus0 (JNIEnv *env, jobject window, jlong w) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* mWin = (NSWindow*) ((intptr_t) w); NSWindow* pWin = [mWin parentWindow]; -#ifdef VERBOSE_ON BOOL hasFocus = [mWin isKeyWindow]; -#endif - DBG_PRINT( "requestFocusParent0 - window: %p, parent: %p, hasFocus %d (START)\n", mWin, pWin, hasFocus ); - if(NULL != pWin) { - [pWin performSelectorOnMainThread:@selector(makeKeyWindow) withObject:nil waitUntilDone:YES]; - // This will occasionally cause a free of non allocated object crash: - // [pWin makeKeyWindow]; + DBG_PRINT( "requestFocusParent0 - window: %p, parent %p, hasFocus %d (START)\n", mWin, pWin, hasFocus ); + if( hasFocus ) { + if(NULL != pWin) { + // [mWin performSelectorOnMainThread:@selector(makeFirstResponder:) withObject:pWin waitUntilDone:NO]; + [pWin performSelectorOnMainThread:@selector(makeKeyWindow) withObject:nil waitUntilDone:NO]; + } else { + [mWin performSelectorOnMainThread:@selector(resignKeyWindow) withObject:nil waitUntilDone:NO]; + } } - DBG_PRINT( "requestFocusParent0 - window: %p, parent: %p (END)\n", mWin, pWin); + DBG_PRINT( "requestFocusParent0 - window: %p (END)\n", mWin); [pool release]; } @@ -856,9 +858,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderFront0 DBG_PRINT( "orderFront0 - window: %p (START)\n", win); - [win performSelectorOnMainThread:@selector(orderFrontRegardless) withObject:nil waitUntilDone:YES]; - // This will occasionally cause a free of non allocated object crash: - // [win orderFrontRegardless]; + [win performSelectorOnMainThread:@selector(orderFrontRegardless) withObject:nil waitUntilDone:NO]; DBG_PRINT( "orderFront0 - window: %p (END)\n", win); @@ -880,13 +880,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderOut0 DBG_PRINT( "orderOut0 - window: (parent %p) %p (START)\n", pWin, mWin); if(NULL == pWin) { - [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:YES]; - // This will occasionally cause a free of non allocated object crash: - // [mWin orderOut: mWin]; + [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:NO]; } else { - [mWin performSelectorOnMainThread:@selector(orderBack:) withObject:mWin waitUntilDone:YES]; - // This will occasionally cause a free of non allocated object crash: - // [mWin orderBack: mWin]; + [mWin performSelectorOnMainThread:@selector(orderBack:) withObject:mWin waitUntilDone:NO]; } DBG_PRINT( "orderOut0 - window: (parent %p) %p (END)\n", pWin, mWin); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java new file mode 100644 index 000000000..6a27e6f27 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java @@ -0,0 +1,233 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.swt; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.After; +import org.junit.Test; + +import com.jogamp.nativewindow.swt.SWTAccessor; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.swt.NewtCanvasSWT; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; + +/** + * Tests that a basic SWT app can open without crashing under different GL profiles + * _and_ custom GLCapabilities. + *

+ * Uses JOGL's NewtCanvasSWT, which allows to be a native container of a NEWT Window.
+ * This method allows utilizing custom GLCapability settings, + * independent from the already instantiated SWT visual. + *

+ *

+ * Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/ + * SWT running on Mac OSX, i.e. to enforce UI action on the main thread. + *

+ */ +public class TestNewtCanvasSWTGLn extends UITestCase { + + static int duration = 250; + + static final int iwidth = 640; + static final int iheight = 480; + + Display display = null; + Shell shell = null; + Composite composite = null; + + @BeforeClass + public static void startup() { + System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() ); + } + + @Before + public void init() { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display = new Display(); + Assert.assertNotNull( display ); + shell = new Shell( display ); + Assert.assertNotNull( shell ); + shell.setLayout( new FillLayout() ); + composite = new Composite( shell, SWT.NONE ); + composite.setLayout( new FillLayout() ); + Assert.assertNotNull( composite ); + }}); + } + + @After + public void release() { + Assert.assertNotNull( display ); + Assert.assertNotNull( shell ); + Assert.assertNotNull( composite ); + try { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + composite.dispose(); + shell.dispose(); + display.dispose(); + }}); + } + catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + display = null; + shell = null; + composite = null; + } + + protected void runTestAGL( GLCapabilitiesImmutable caps, GLEventListener demo, + boolean postAttach, boolean useAnimator ) throws InterruptedException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); + + final GLWindow glWindow1 = GLWindow.create(caps); + Assert.assertNotNull(glWindow1); + Assert.assertEquals(false, glWindow1.isVisible()); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertNull(glWindow1.getParent()); + glWindow1.addGLEventListener(demo); + glWindow1.addGLEventListener(new GLEventListener() { + int displayCount = 0; + public void init(final GLAutoDrawable drawable) { } + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { } + public void display(final GLAutoDrawable drawable) { + if(displayCount < 3) { + snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); + } + } + public void dispose(final GLAutoDrawable drawable) { } + }); + + final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( composite, 0, postAttach ? null : glWindow1 ); + Assert.assertNotNull( canvas1 ); + + SWTAccessor.invoke(true, new Runnable() { + public void run() { + shell.setText( getSimpleTestName(".") ); + shell.setSize( 640, 480 ); + shell.open(); + } + }); + + if(postAttach) { + canvas1.setNEWTChild(glWindow1); + } + + // canvas1.update(); + + Animator anim; + if(useAnimator) { + anim = new Animator(glWindow1); + anim.start(); + } else { + anim = null; + } + + long lStartTime = System.currentTimeMillis(); + long lEndTime = lStartTime + duration; + try { + while( (System.currentTimeMillis() < lEndTime) && !canvas1.isDisposed() ) { + if( !display.readAndDispatch() ) { + // blocks on linux .. display.sleep(); + Thread.sleep(10); + } + } + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + if(null != anim) { + anim.stop(); + } + + canvas1.dispose(); + } + + @Test + public void preAttach_WithAnimator() throws InterruptedException { + runTestAGL( new GLCapabilities(GLProfile.getGL2ES2()), new GearsES2(), false /* postAttach */, true /* animator */); + } + + @Test + public void preAttach_NoAnimator() throws InterruptedException { + runTestAGL( new GLCapabilities(GLProfile.getGL2ES2()), new GearsES2(), false /* postAttach */, false /* animator */); + } + + @Test + public void postAttach_WithAnimator() throws InterruptedException { + runTestAGL( new GLCapabilities(GLProfile.getGL2ES2()), new GearsES2(), true /* postAttach */, true /* animator */); + } + + @Test + public void test_MultisampleAndAlpha() throws InterruptedException { + GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); + caps.setSampleBuffers(true); + caps.setNumSamples(2); + runTestAGL( caps, new MultisampleDemoES2(true), false /* postAttach */, false /* animator */); + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) { + for(int i=0; i - * Uses JOGL's SWTAccessor only. - *

- * @author Wade Walker, et.al. - */ -public class TestSWTAccessor02GLn extends UITestCase { - - static int duration = 250; - - static final int iwidth = 640; - static final int iheight = 480; - - Display display = null; - Shell shell = null; - Composite composite = null; - - @BeforeClass - public static void startup() { - System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() ); - } - - @Before - public void init() { - SWTAccessor.invoke(true, new Runnable() { - public void run() { - display = new Display(); - Assert.assertNotNull( display ); - shell = new Shell( display ); - Assert.assertNotNull( shell ); - shell.setLayout( new FillLayout() ); - composite = new Composite( shell, SWT.NONE ); - composite.setLayout( new FillLayout() ); - Assert.assertNotNull( composite ); - }}); - } - - @After - public void release() { - Assert.assertNotNull( display ); - Assert.assertNotNull( shell ); - Assert.assertNotNull( composite ); - try { - SWTAccessor.invoke(true, new Runnable() { - public void run() { - composite.dispose(); - shell.dispose(); - display.dispose(); - }}); - } - catch( Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); - } - display = null; - shell = null; - composite = null; - } - - protected void runTestAGL( GLProfile glprofile ) throws InterruptedException { - GLCapabilities caps = new GLCapabilities(glprofile); - GLDrawableFactory factory = GLDrawableFactory.getFactory(glprofile); - - // need SWT.NO_BACKGROUND to prevent SWT from clearing the window - // at the wrong times (we use glClear for this instead) - final Canvas canvas = new Canvas( composite, SWT.NO_BACKGROUND); - Assert.assertNotNull( canvas ); - SWTAccessor.setRealized(canvas, true); - - AbstractGraphicsDevice device = SWTAccessor.getDevice(canvas); - long nativeWindowHandle = SWTAccessor.getWindowHandle(canvas); - System.err.println("*** device: " + device); - System.err.println("*** window handle: 0x" + Long.toHexString(nativeWindowHandle)); - - final SWTUpstreamHook swtUpstreamHook = new SWTUpstreamHook(canvas); - canvas.addControlListener(swtUpstreamHook); - - final ProxySurface proxySurface = factory.createProxySurface(device, 0, nativeWindowHandle, caps, null, swtUpstreamHook); - Assert.assertNotNull( proxySurface ); - System.err.println("*** ProxySurface: " + proxySurface); - - final GLDrawable drawable = factory.createGLDrawable(proxySurface); - Assert.assertNotNull( drawable ); - drawable.setRealized(true); - System.err.println("*** Drawable: " + drawable); - Assert.assertTrue( drawable.isRealized() ); - - final GLContext glcontext = drawable.createContext(null); - // trigger native creation .. - if( GLContext.CONTEXT_NOT_CURRENT < glcontext.makeCurrent() ) { - glcontext.release(); - } - - final boolean[] sizeMissing = new boolean[] { false }; - - // fix the viewport when the user resizes the window - canvas.addListener( SWT.Resize, new Listener() { - public void handleEvent( Event event ) { - Rectangle rectangle = canvas.getClientArea(); - boolean glok=false; - if( GLContext.CONTEXT_NOT_CURRENT < glcontext.makeCurrent() ) { - glok=true; - GL2ES1 gl = glcontext.getGL().getGL2ES1(); - OneTriangle.setup( gl, rectangle.width, rectangle.height ); - glcontext.release(); - } else { - sizeMissing[0] = true; - } - System.err.println("resize: glok " + glok); - } - }); - - // draw the triangle when the OS tells us that any part of the window needs drawing - canvas.addPaintListener( new PaintListener() { - public void paintControl( PaintEvent paintevent ) { - Rectangle rectangle = canvas.getClientArea(); - boolean glok=false; - if( GLContext.CONTEXT_NOT_CURRENT < glcontext.makeCurrent() ) { - glok=true; - GL2ES1 gl = glcontext.getGL().getGL2ES1(); - if(sizeMissing[0]) { - OneTriangle.setup( gl, rectangle.width, rectangle.height); - sizeMissing[0] = false; - } - OneTriangle.render( gl, rectangle.width, rectangle.height); - drawable.swapBuffers(); - glcontext.release(); - } - System.err.println("paint: glok " + glok); - } - }); - - shell.setText( getClass().getName() ); - shell.setSize( 640, 480 ); - shell.open(); - - long lStartTime = System.currentTimeMillis(); - long lEndTime = lStartTime + duration; - try { - while( (System.currentTimeMillis() < lEndTime) && !canvas.isDisposed() ) { - if( !display.readAndDispatch() ) { - // blocks on linux .. display.sleep(); - Thread.sleep(10); - } - } - } catch( Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); - } - glcontext.destroy(); - drawable.setRealized(false); - canvas.dispose(); - } - private static class SWTUpstreamHook implements ProxySurface.UpstreamSurfaceHook, ControlListener { - private Canvas c; - Rectangle clientArea; - public SWTUpstreamHook(Canvas c) { - this.c = c ; - this.clientArea = c.getClientArea(); - } - @Override - public final void create(ProxySurface s) { /* nop */ } - - @Override - public final void destroy(ProxySurface s) { /* nop */ } - - @Override - public final int getWidth(ProxySurface s) { - return clientArea.width; - } - @Override - public final int getHeight(ProxySurface s) { - return clientArea.width; - } - - @Override - public void controlResized(final ControlEvent arg0) { - clientArea = c.getClientArea(); - } - @Override - public void controlMoved(ControlEvent e) { - } - @Override - public String toString() { - final String us_s = null != c ? c.toString() : "nil"; - return "SETUpstreamSurfaceHook[upstream: "+us_s+"]"; - } - }; - - @Test - public void test() throws InterruptedException { - GLProfile glprofile = GLProfile.getGL2ES1(); - runTestAGL( glprofile ); - } - - static int atoi(String a) { - int i=0; - try { - i = Integer.parseInt(a); - } catch (Exception ex) { ex.printStackTrace(); } - return i; - } - - public static void main(String args[]) { - for(int i=0; i *

+ * Note: To employ custom GLCapabilities, NewtCanvasSWT shall be used. + *

+ *

* Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/ * SWT running on Mac OSX, i.e. to enforce UI action on the main thread. *

@@ -116,34 +121,32 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase { composite = null; } - protected void runTestAGL( GLProfile glprofile ) throws InterruptedException { - // need SWT.NO_BACKGROUND to prevent SWT from clearing the window - // at the wrong times (we use glClear for this instead) - final GLCapabilitiesImmutable caps = new GLCapabilities( glprofile ); + protected void runTestAGL( GLCapabilitiesImmutable caps, GLEventListener demo ) throws InterruptedException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); - final GLCanvas canvas = new GLCanvas( composite, 0, caps, null, null); + final GLCanvas canvas = GLCanvas.create( composite, 0, caps, null, null); Assert.assertNotNull( canvas ); + canvas.addGLEventListener( demo ); canvas.addGLEventListener(new GLEventListener() { - public void init(final GLAutoDrawable drawable) { - System.err.println(Thread.currentThread().getName()+" - SWT Canvas - GLEventListener - init()"); - } - public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { - System.err.println(Thread.currentThread().getName()+" - SWT Canvas - GLEventListener - reshape()"); - OneTriangle.setup( drawable.getGL().getGL2(), width, height ); - } + int displayCount = 0; + public void init(final GLAutoDrawable drawable) { } + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { } public void display(final GLAutoDrawable drawable) { - OneTriangle.render( drawable.getGL().getGL2(), drawable.getWidth(), drawable.getHeight()); + if(displayCount < 3) { + snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); + } } - public void dispose(final GLAutoDrawable drawable) { - System.err.println(Thread.currentThread().getName()+" - SWT Canvas - GLEventListener - dispose()"); - } - }); + public void dispose(final GLAutoDrawable drawable) { } + }); - shell.setText( getClass().getName() ); - shell.setSize( 640, 480 ); - shell.open(); - + SWTAccessor.invoke(true, new Runnable() { + public void run() { + shell.setText( getSimpleTestName(".") ); + shell.setSize( 640, 480 ); + shell.open(); + } } ); + long lStartTime = System.currentTimeMillis(); long lEndTime = lStartTime + duration; try { @@ -157,13 +160,15 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } - canvas.dispose(); + SWTAccessor.invoke(true, new Runnable() { + public void run() { + canvas.dispose(); + } } ); } @Test public void test() throws InterruptedException { - GLProfile glprofile = GLProfile.getGL2ES1(); - runTestAGL( glprofile ); + runTestAGL( new GLCapabilities(GLProfile.getGL2ES2()), new GearsES2() ); } static int atoi(String a) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java new file mode 100644 index 000000000..11aef7c24 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java @@ -0,0 +1,210 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.parenting; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.junit.After; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.nativewindow.swt.SWTAccessor; +import com.jogamp.newt.Window; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.swt.NewtCanvasSWT; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Simple visibility test .. + */ +public class TestParenting01aSWT extends UITestCase { + static int width, height; + static long durationPerTest = 800; + static GLCapabilities glCaps; + + Display display = null; + Shell shell = null; + Composite composite1 = null; + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glCaps = new GLCapabilities(null); + } + + @Before + public void init() { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display = new Display(); + Assert.assertNotNull( display ); + shell = new Shell( display ); + Assert.assertNotNull( shell ); + shell.setLayout( new FillLayout() ); + composite1 = new Composite( shell, SWT.NONE ); + composite1.setLayout( new FillLayout() ); + Assert.assertNotNull( composite1 ); + }}); + } + + @After + public void release() { + Assert.assertNotNull( display ); + Assert.assertNotNull( shell ); + Assert.assertNotNull( composite1 ); + try { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + composite1.dispose(); + shell.dispose(); + display.dispose(); + }}); + } + catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + display = null; + shell = null; + composite1 = null; + } + + @Test + public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { + + GLWindow glWindow1 = GLWindow.create(glCaps); + Assert.assertNotNull(glWindow1); + Assert.assertEquals(false, glWindow1.isVisible()); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertNull(glWindow1.getParent()); + glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); + GLEventListener demo1 = new RedSquareES2(); + setDemoFields(demo1, glWindow1, false); + glWindow1.addGLEventListener(demo1); + + final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( composite1, 0, glWindow1 ); + Assert.assertNotNull(canvas1); + Assert.assertEquals(false, glWindow1.isVisible()); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertNull(glWindow1.getParent()); + + SWTAccessor.invoke(true, new Runnable() { + public void run() { + shell.setText( getSimpleTestName(".") ); + shell.setSize( 640, 480 ); + shell.open(); + } + }); + + // visible test + Assert.assertEquals(canvas1.getNativeWindow(),glWindow1.getParent()); + + for(int i=0; i*10 2 + if(detachFirst) { + canvas1.setNEWTChild(null); + canvas2.setNEWTChild(null); + } else { + canvas2.setNEWTChild(null); // free g2 of w2 + } + canvas1.setNEWTChild(glWindow2); // put g2 -> w1. free g1 of w1 + canvas2.setNEWTChild(glWindow1); // put g1 -> w2 + frame1.validate(); + frame2.validate(); + } + }); + break; + case 1: + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + // 2 -> 1 + if(detachFirst) { + canvas1.setNEWTChild(null); + canvas2.setNEWTChild(null); + } else { + canvas2.setNEWTChild(null); + } + canvas1.setNEWTChild(glWindow1); + canvas2.setNEWTChild(glWindow2); + frame1.validate(); + frame2.validate(); + } + }); + break; + } + } + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.dispose(); + frame2.dispose(); + } } ); + glWindow1.destroy(); + glWindow2.destroy(); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertEquals(false, glWindow2.isNativeValid()); + } + + public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { + Assert.assertNotNull(demo); + Assert.assertNotNull(glWindow); + Window window = glWindow.getDelegatedWindow(); + if(debug) { + MiscUtils.setFieldIfExists(demo, "glDebug", true); + MiscUtils.setFieldIfExists(demo, "glTrace", true); + } + if(!MiscUtils.setFieldIfExists(demo, "window", window)) { + MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); + } + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i 2 + if(detachFirst) { + canvas1.setNEWTChild(null); + canvas2.setNEWTChild(null); + } else { + canvas2.setNEWTChild(null); // free g2 of w2 + } + canvas1.setNEWTChild(glWindow2); // put g2 -> w1. free g1 of w1 + canvas2.setNEWTChild(glWindow1); // put g1 -> w2 + } } ); + break; + case 1: + SWTAccessor.invoke(true, new Runnable() { + public void run() { + // 2 -> 1 + if(detachFirst) { + canvas1.setNEWTChild(null); + canvas2.setNEWTChild(null); + } else { + canvas2.setNEWTChild(null); + } + canvas1.setNEWTChild(glWindow1); + canvas2.setNEWTChild(glWindow2); + } } ); + break; + } + } + + canvas1.dispose(); + canvas2.dispose(); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertEquals(false, glWindow2.isNativeValid()); + } + + public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { + Assert.assertNotNull(demo); + Assert.assertNotNull(glWindow); + Window window = glWindow.getDelegatedWindow(); + if(debug) { + MiscUtils.setFieldIfExists(demo, "glDebug", true); + MiscUtils.setFieldIfExists(demo, "glTrace", true); + } + if(!MiscUtils.setFieldIfExists(demo, "window", window)) { + MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); + } + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i Date: Fri, 3 Aug 2012 01:38:37 +0300 Subject: Fix X11 Display Connection leak w/ new GLAutoDrawableBase code when used w/ offscreen drawables, reported by Mark Raynsford New common GLAutoDrawableBase missed to close the AbstractGraphicsDevice in case it has been created and dedicated for the passed GLDrawable. This detailed knowledge is only known to the creator, hence it is passed in the constructor and is being passed through all specializations. Further more the new X11/GLX impl. of GLDrawableFactory's 'createMutableSurfaceImpl' always creates it's own private X11 display connection to avoid locking / threading issues. Since the old implementation reused the shared display connection which is prone to threading issues, this bug was not visible before. Also fixed the unit test TestNEWTCloseX11DisplayBug565, now correctly validating that no display connection is left over after a new cycle of create/destroy of onscreen and offscreen drawables. --- make/scripts/tests.sh | 6 ++-- .../com/jogamp/opengl/OffscreenAutoDrawable.java | 13 ++++++-- .../javax/media/opengl/GLAutoDrawableDelegate.java | 14 +++++--- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 39 ++++++++++++++++------ .../jogamp/opengl/GLDrawableFactoryImpl.java | 2 +- src/jogl/classes/jogamp/opengl/GLPbufferImpl.java | 4 +-- .../classes/jogamp/nativewindow/x11/X11Util.java | 2 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 2 +- .../test/junit/jogl/acore/TestFBODrawableNEWT.java | 2 +- .../jogl/acore/TestGLAutoDrawableDelegateNEWT.java | 2 +- .../acore/TestGLContextDrawableSwitchNEWT.java | 2 +- .../jogl/acore/TestNEWTCloseX11DisplayBug565.java | 8 ++--- 12 files changed, 64 insertions(+), 32 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index af6218968..43d04c6bd 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -61,7 +61,7 @@ function jrun() { #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" - D_ARGS="-Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.DontQuery -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.QueryNativeTK -Djogl.debug.GLDrawable" @@ -217,7 +217,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* @@ -328,7 +328,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* #testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* -testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java b/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java index 1ea8595c6..8450ffdb0 100644 --- a/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java @@ -28,6 +28,7 @@ package com.jogamp.opengl; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.opengl.GLAutoDrawableDelegate; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; @@ -45,8 +46,16 @@ import jogamp.opengl.GLFBODrawableImpl; */ public class OffscreenAutoDrawable extends GLAutoDrawableDelegate { - public OffscreenAutoDrawable(GLDrawable drawable, GLContext context, Object upstreamWidget) { - super(drawable, context, upstreamWidget); + /** + * @param drawable a valid {@link GLDrawable}, may not be realized yet. + * @param context a valid {@link GLContext}, may not be made current (created) yet. + * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, + * otherwise pass false. Closing the device is required in case + * the drawable is created w/ it's own new instance, e.g. offscreen drawables, + * and no further lifecycle handling is applied. + */ + public OffscreenAutoDrawable(GLDrawable drawable, GLContext context, boolean ownDevice) { + super(drawable, context, null, ownDevice); } /** diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java index 76959f3f4..67e81270d 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java @@ -28,6 +28,8 @@ package javax.media.opengl; +import javax.media.nativewindow.AbstractGraphicsDevice; + import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; @@ -57,12 +59,16 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase { public static final boolean DEBUG = Debug.debug("GLAutoDrawableDelegate"); /** - * @param drawable - * @param context + * @param drawable a valid {@link GLDrawable}, may not be realized yet. + * @param context a valid {@link GLContext}, may not be made current (created) yet. * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. + * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, + * otherwise pass false. Closing the device is required in case + * the drawable is created w/ it's own new instance, e.g. offscreen drawables, + * and no further lifecycle handling is applied. */ - public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget) { - super((GLDrawableImpl)drawable, (GLContextImpl)context); + public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget, boolean ownDevice) { + super((GLDrawableImpl)drawable, (GLContextImpl)context, ownDevice); this.upstreamWidget = null; } diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index fe6d0fd76..cc4e1b434 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -30,6 +30,8 @@ package jogamp.opengl; import java.io.PrintStream; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.WindowClosingProtocol; import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; @@ -66,13 +68,23 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { protected volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access protected GLContextImpl context; + protected final boolean ownDevice; protected int additionalCtxCreationFlags = 0; protected volatile boolean sendReshape = false; // volatile: maybe written by WindowManager thread w/o locking protected volatile boolean sendDestroy = false; // volatile: maybe written by WindowManager thread w/o locking - public GLAutoDrawableBase(GLDrawableImpl drawable, GLContextImpl context) { + /** + * @param drawable a valid {@link GLDrawableImpl}, may not be realized yet. + * @param context a valid {@link GLContextImpl}, may not be made current (created) yet. + * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, + * otherwise pass false. Closing the device is required in case + * the drawable is created w/ it's own new instance, e.g. offscreen drawables, + * and no further lifecycle handling is applied. + */ + public GLAutoDrawableBase(GLDrawableImpl drawable, GLContextImpl context, boolean ownDevice) { this.drawable = drawable; this.context = context; + this.ownDevice = ownDevice; resetFPSCounter(); } @@ -174,7 +186,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } /** - * Calls {@link #destroyImplInLock()} while claiming the lock. + * Calls {@link #destroyImplInLock()} while claiming the lock. */ protected final void defaultDestroy() { final RecursiveLock lock = getLock(); @@ -200,17 +212,22 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { protected void destroyImplInLock() { final GLContext _context = context; final GLDrawable _drawable = drawable; - if( null != _drawable && _drawable.isRealized() ) { - if( null != _context && _context.isCreated() ) { - // Catch dispose GLExceptions by GLEventListener, just 'print' them - // so we can continue with the destruction. - try { - helper.disposeGL(this, _drawable, _context, null); - } catch (GLException gle) { - gle.printStackTrace(); + if( null != _drawable ) { + if( _drawable.isRealized() ) { + if( null != _context && _context.isCreated() ) { + // Catch dispose GLExceptions by GLEventListener, just 'print' them + // so we can continue with the destruction. + try { + helper.disposeGL(this, _drawable, _context, null); + } catch (GLException gle) { + gle.printStackTrace(); + } } + _drawable.setRealized(false); + } + if( ownDevice ) { + _drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice().close(); } - _drawable.setRealized(false); } context = null; drawable = null; diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index f092288fb..f7808294b 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -245,7 +245,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if(null==drawable) { throw new GLException("Could not create Pbuffer drawable for: "+device+", "+capsChosen+", "+width+"x"+height); } - return new GLPbufferImpl( drawable, shareWith); + return new GLPbufferImpl( drawable, shareWith, true); } //--------------------------------------------------------------------------- diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index 6b64120fe..32f4cb696 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -58,8 +58,8 @@ import com.jogamp.common.util.locks.RecursiveLock; public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { private int floatMode; - public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContext sharedContext) { - super(pbufferDrawable, null); // drawable := pbufferDrawable + public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContext sharedContext, boolean ownDevice) { + super(pbufferDrawable, null, ownDevice); // drawable := pbufferDrawable GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) drawable.getNativeSurface().getGraphicsConfiguration().getChosenCapabilities(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index fcc374751..7b46a1df0 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -255,7 +255,7 @@ public class X11Util { */ public static int shutdown(boolean realXCloseOpenAndPendingDisplays, boolean verbose) { int num=0; - if(DEBUG||verbose||pendingDisplayList.size() > 0) { + if(DEBUG || verbose || openDisplayMap.size() > 0 || pendingDisplayList.size() > 0) { System.err.println("X11Util.Display: Shutdown (close open / pending Displays: "+realXCloseOpenAndPendingDisplays+ ", open (no close attempt): "+openDisplayMap.size()+"/"+openDisplayList.size()+ ", pending (not closed, marked uncloseable): "+pendingDisplayList.size()+")"); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index d662a743a..0fc1b4e89 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -97,7 +97,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind * Constructor. Do not call this directly -- use {@link #create()} instead. */ protected GLWindow(Window window) { - super(null, null); + super(null, null, false); this.window = (WindowImpl) window; this.window.setHandleDestroyNotify(false); window.addWindowListener(new WindowAdapter() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java index 1a33845b3..7977347a7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java @@ -167,7 +167,7 @@ public class TestFBODrawableNEWT extends UITestCase { final FBObject.RenderAttachment depthA = fbo.getDepthAttachment(); Assert.assertNotNull(depthA); - final OffscreenAutoDrawable glad = new OffscreenAutoDrawable(fboDrawable, context, null); + final OffscreenAutoDrawable glad = new OffscreenAutoDrawable(fboDrawable, context, true); glad.addGLEventListener(demo); glad.addGLEventListener(new GLEventListener() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java index 426b7734f..96d9b2e28 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java @@ -85,7 +85,7 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase { Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); context.release(); - final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window) { + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false) { @Override protected void destroyImplInLock() { super.destroyImplInLock(); // destroys drawable/context diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java index 92b4c5238..cece4c6d5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java @@ -88,7 +88,7 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { drawable.setRealized(true); Assert.assertTrue(drawable.isRealized()); - final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window) { + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false) { @Override protected void destroyImplInLock() { super.destroyImplInLock(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java index e14d5b800..33a9b7799 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java @@ -43,10 +43,10 @@ public class TestNEWTCloseX11DisplayBug565 { if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { final int openD = X11Util.getOpenDisplayConnectionNumber() - open0; - if(openD>1) { + if( openD > 0) { X11Util.dumpOpenDisplayConnections(); X11Util.dumpPendingDisplayConnections(); - Assert.assertTrue("More than 1 new open display connections", false); + Assert.assertEquals("New display connection didn't close", 0, openD); } } } @@ -86,10 +86,10 @@ public class TestNEWTCloseX11DisplayBug565 { if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { final int openD = X11Util.getOpenDisplayConnectionNumber() - open0; - if(openD>1) { + if(openD > 0) { X11Util.dumpOpenDisplayConnections(); X11Util.dumpPendingDisplayConnections(); - Assert.assertTrue("More than 1 new open display connections", false); + Assert.assertEquals("New display connection didn't close", 0, openD); } } } -- cgit v1.2.3 From 0ca481381b51b4082ac2b3bbae80cfaf5b60c3b8 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 16 Aug 2012 15:46:49 +0200 Subject: NEWT: Adding support for BCM VC IV (Broadcom VideoCodec 4) and Linux console mouse tracker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rasperry PI uses the 'BCM VC IV' GPU via console as it's default configuration. This driver enables direct support for JOGL/NEWT. Due to the lack of detection (TODO) users have to specify the Java property: -Dnativewindow.ws.name=jogamp.newt.driver.bcm.vc.iv - Autodetection should be included in 'NativeWindowFactory._getNativeWindowingType()' while adding a new TYPE: 'TYPE_BCM_VC_IV'. - Autodetection may need to detect whether an X11 Display runs and the installed EGL library uses it (instead of the default console one) This work is authored in coop w/ Xerxes RÃ¥nby ! --- make/build-common.xml | 10 +- .../jogamp/newt/driver/bcm/egl/Display.java | 85 ++++++++ .../classes/jogamp/newt/driver/bcm/egl/Screen.java | 75 +++++++ .../classes/jogamp/newt/driver/bcm/egl/Window.java | 170 ++++++++++++++++ .../jogamp/newt/driver/bcm/vc/iv/Display.java | 78 ++++++++ .../jogamp/newt/driver/bcm/vc/iv/Screen.java | 73 +++++++ .../jogamp/newt/driver/bcm/vc/iv/Window.java | 149 ++++++++++++++ .../jogamp/newt/driver/broadcom/egl/Display.java | 85 -------- .../jogamp/newt/driver/broadcom/egl/Screen.java | 75 ------- .../jogamp/newt/driver/broadcom/egl/Window.java | 170 ---------------- .../newt/driver/linux/LinuxMouseTracker.java | 221 +++++++++++++++++++++ src/newt/native/BroadcomEGL.c | 190 ------------------ src/newt/native/bcm_egl.c | 190 ++++++++++++++++++ src/newt/native/bcm_vc_iv.c | 204 +++++++++++++++++++ src/newt/native/bcm_vc_iv.h | 189 ++++++++++++++++++ 15 files changed, 1443 insertions(+), 521 deletions(-) create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java delete mode 100644 src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java delete mode 100644 src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java delete mode 100644 src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java create mode 100644 src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java delete mode 100644 src/newt/native/BroadcomEGL.c create mode 100644 src/newt/native/bcm_egl.c create mode 100644 src/newt/native/bcm_vc_iv.c create mode 100644 src/newt/native/bcm_vc_iv.h (limited to 'src/newt/classes') diff --git a/make/build-common.xml b/make/build-common.xml index df19cb7a5..2cb776e74 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -364,34 +364,42 @@ + - + + + + + + + + diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java new file mode 100644 index 000000000..f08890da6 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.bcm.egl; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import jogamp.newt.NEWTJNILibLoader; +import jogamp.opengl.egl.EGL; + +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; + +public class Display extends jogamp.newt.DisplayImpl { + + static { + NEWTJNILibLoader.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 createNativeImpl() { + final long handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight); + if (handle == EGL.EGL_NO_DISPLAY) { + throw new NativeWindowException("BC EGL CreateDisplay failed"); + } + aDevice = new EGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, handle, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, null); + } + + protected void closeNativeImpl() { + if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { + DestroyDisplay(aDevice.getHandle()); + } + } + + protected void dispatchMessagesNative() { + // 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/jogamp/newt/driver/bcm/egl/Screen.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java new file mode 100644 index 000000000..909444d24 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.bcm.egl; + +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +public class Screen extends jogamp.newt.ScreenImpl { + + static { + Display.initSingleton(); + } + + + public Screen() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { } + + protected int validateScreenIndex(int idx) { + return 0; // only one screen available + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(fixedWidth); // FIXME + virtualSize.setHeight(fixedHeight); // FIXME + } + + //---------------------------------------------------------------------- + // Internals only + // + + static final int fixedWidth = 1920; // FIXME + static final int fixedHeight = 1080; // FIXME +} + diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java new file mode 100644 index 000000000..87170e4ab --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.bcm.egl; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; +import javax.media.opengl.GLCapabilitiesImmutable; + +import jogamp.opengl.egl.EGLGraphicsConfiguration; + +public class Window extends jogamp.newt.WindowImpl { + static { + Display.initSingleton(); + } + + public Window() { + } + + protected void createNativeImpl() { + if(0!=getParentWindowHandle()) { + throw new RuntimeException("Window parenting not supported (yet)"); + } + // query a good configuration, however chose the final one by the native queried egl-cfg-id + // after creation at {@link #windowCreated(int, int, int)}. + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + setSizeImpl(getScreen().getWidth(), getScreen().getHeight()); + + setWindowHandle(realizeWindow(true, getWidth(), getHeight())); + if (0 == getWindowHandle()) { + throw new NativeWindowException("Error native Window Handle is null"); + } + } + + protected void closeNativeImpl() { + if(0!=windowHandleClose) { + CloseWindow(getDisplayHandle(), windowHandleClose); + } + } + + protected void requestFocusImpl(boolean reparented) { } + + protected void setSizeImpl(int width, int height) { + if(0!=getWindowHandle()) { + // n/a in BroadcomEGL + System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); + } else { + defineSize(width, height); + } + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(0!=getWindowHandle()) { + if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { + if( 0 != ( FLAG_IS_FULLSCREEN & flags) ) { + // n/a in BroadcomEGL + System.err.println("setFullscreen n/a in BroadcomEGL"); + return false; + } + } + } + if(width>0 || height>0) { + if(0!=getWindowHandle()) { + // n/a in BroadcomEGL + System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); + } else { + defineSize((width>0)?width:getWidth(), (height>0)?height:getHeight()); + } + } + if(x>=0 || y>=0) { + System.err.println("BCEGL Window.setPositionImpl n/a in BroadcomEGL"); + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return new Point(x,y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop .. + } + + @Override + public boolean surfaceSwap() { + SwapWindow(getDisplayHandle(), getWindowHandle()); + return true; + } + + //---------------------------------------------------------------------- + // 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.err.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+getGraphicsConfiguration()); + } + 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) { + defineSize(width, height); + GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) getGraphicsConfiguration().getRequestedCapabilities(); + final AbstractGraphicsConfiguration cfg = EGLGraphicsConfiguration.create(capsReq, getScreen().getGraphicsScreen(), cfgID); + if (null == cfg) { + throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this); + } + setGraphicsConfiguration(cfg); + if(DEBUG_IMPLEMENTATION) { + System.err.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+cfg); + } + } + + private long windowHandleClose; +} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java new file mode 100644 index 000000000..62af02abb --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java @@ -0,0 +1,78 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.bcm.vc.iv; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import jogamp.newt.DisplayImpl; +import jogamp.newt.NEWTJNILibLoader; +import jogamp.opengl.egl.EGL; +import jogamp.opengl.egl.EGLDisplayUtil; + +public class Display extends DisplayImpl { + static { + NEWTJNILibLoader.loadNEWT(); + + if (!Display.initIDs()) { + throw new NativeWindowException("Failed to initialize bcm.vc.iv Display jmethodIDs"); + } + if (!Screen.initIDs()) { + throw new NativeWindowException("Failed to initialize bcm.vc.iv Screen jmethodIDs"); + } + if (!Window.initIDs()) { + throw new NativeWindowException("Failed to initialize bcm.vc.iv Window jmethodIDs"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public Display() { + } + + protected void createNativeImpl() { + // FIXME: map name to EGL_*_DISPLAY + aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + } + + protected void closeNativeImpl() { + aDevice.close(); + } + + protected void dispatchMessagesNative() { + DispatchMessages(); + } + + protected static native boolean initIDs(); + private native void DispatchMessages(); +} + diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java new file mode 100644 index 000000000..484d4bf81 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java @@ -0,0 +1,73 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.bcm.vc.iv; + +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.ScreenImpl; + +public class Screen extends ScreenImpl { + static { + Display.initSingleton(); + } + + public Screen() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + initNative(); + } + + protected void closeNativeImpl() { } + + protected int validateScreenIndex(int idx) { + return 0; // only one screen available + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(cachedWidth); + virtualSize.setHeight(cachedHeight); + } + + protected void setScreenSize(int width, int height) { + cachedWidth = width; + cachedHeight = height; + } + + private static int cachedWidth = 0; + private static int cachedHeight = 0; + + protected static native boolean initIDs(); + protected native void initNative(); +} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java new file mode 100644 index 000000000..3d00949de --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java @@ -0,0 +1,149 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.bcm.vc.iv; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.WindowImpl; +import jogamp.newt.driver.linux.LinuxMouseTracker; + +public class Window extends WindowImpl { + private static final String WINDOW_CLASS_NAME = "NewtWindow"; + + static { + Display.initSingleton(); + } + + public Window() { + } + + protected void createNativeImpl() { + if(0!=getParentWindowHandle()) { + throw new RuntimeException("Window parenting not supported (yet)"); + } + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + + nativeWindowHandle = CreateWindow(getWidth(), getHeight()); + if (nativeWindowHandle == 0) { + throw new NativeWindowException("Error creating egl window: "+cfg); + } + setVisible0(nativeWindowHandle, false); + setWindowHandle(nativeWindowHandle); + if (0 == getWindowHandle()) { + throw new NativeWindowException("Error native Window Handle is null"); + } + windowHandleClose = nativeWindowHandle; + addWindowListener(LinuxMouseTracker.getSingleton()); + focusChanged(false, true); + } + + protected void closeNativeImpl() { + removeWindowListener(LinuxMouseTracker.getSingleton()); + + if(0!=windowHandleClose) { + CloseWindow(windowHandleClose, windowUserData); + windowUserData=0; + } + } + + protected void requestFocusImpl(boolean reparented) { + focusChanged(false, true); + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + setVisible0(nativeWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + if(0!=nativeWindowHandle) { + if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { + final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; + setFullScreen0(nativeWindowHandle, fs); + if(fs) { + return true; + } + } + // int _x=(x>=0)?x:this.x; + // int _y=(x>=0)?y:this.y; + width=(width>0)?width:getWidth(); + height=(height>0)?height:getHeight(); + if(width>0 || height>0) { + setSize0(nativeWindowHandle, width, height); + } + if(x>=0 || y>=0) { + System.err.println("setPosition n/a in KD"); + } + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return new Point(x,y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop .. + } + + //---------------------------------------------------------------------- + // Internals only + // + + protected static native boolean initIDs(); + private native long CreateWindow(int width, int height); + 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 long nativeWindowHandle; + private long windowHandleClose; + private long windowUserData; +} diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java deleted file mode 100644 index e3f50b7e0..000000000 --- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Display.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.broadcom.egl; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; - -import jogamp.newt.NEWTJNILibLoader; -import jogamp.opengl.egl.EGL; - -import com.jogamp.nativewindow.egl.EGLGraphicsDevice; - -public class Display extends jogamp.newt.DisplayImpl { - - static { - NEWTJNILibLoader.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 createNativeImpl() { - final long handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight); - if (handle == EGL.EGL_NO_DISPLAY) { - throw new NativeWindowException("BC EGL CreateDisplay failed"); - } - aDevice = new EGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, handle, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, null); - } - - protected void closeNativeImpl() { - if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { - DestroyDisplay(aDevice.getHandle()); - } - } - - protected void dispatchMessagesNative() { - // 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/jogamp/newt/driver/broadcom/egl/Screen.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java deleted file mode 100644 index 0544bc06c..000000000 --- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Screen.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.broadcom.egl; - -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -public class Screen extends jogamp.newt.ScreenImpl { - - static { - Display.initSingleton(); - } - - - public Screen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { } - - protected int validateScreenIndex(int idx) { - return 0; // only one screen available - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(fixedWidth); // FIXME - virtualSize.setHeight(fixedHeight); // FIXME - } - - //---------------------------------------------------------------------- - // Internals only - // - - static final int fixedWidth = 1920; // FIXME - static final int fixedHeight = 1080; // FIXME -} - diff --git a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java b/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java deleted file mode 100644 index 223ad6484..000000000 --- a/src/newt/classes/jogamp/newt/driver/broadcom/egl/Window.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.broadcom.egl; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.Point; -import javax.media.opengl.GLCapabilitiesImmutable; - -import jogamp.opengl.egl.EGLGraphicsConfiguration; - -public class Window extends jogamp.newt.WindowImpl { - static { - Display.initSingleton(); - } - - public Window() { - } - - protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { - throw new RuntimeException("Window parenting not supported (yet)"); - } - // query a good configuration, however chose the final one by the native queried egl-cfg-id - // after creation at {@link #windowCreated(int, int, int)}. - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - setSizeImpl(getScreen().getWidth(), getScreen().getHeight()); - - setWindowHandle(realizeWindow(true, getWidth(), getHeight())); - if (0 == getWindowHandle()) { - throw new NativeWindowException("Error native Window Handle is null"); - } - } - - protected void closeNativeImpl() { - if(0!=windowHandleClose) { - CloseWindow(getDisplayHandle(), windowHandleClose); - } - } - - protected void requestFocusImpl(boolean reparented) { } - - protected void setSizeImpl(int width, int height) { - if(0!=getWindowHandle()) { - // n/a in BroadcomEGL - System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); - } else { - defineSize(width, height); - } - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if(0!=getWindowHandle()) { - if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { - if( 0 != ( FLAG_IS_FULLSCREEN & flags) ) { - // n/a in BroadcomEGL - System.err.println("setFullscreen n/a in BroadcomEGL"); - return false; - } - } - } - if(width>0 || height>0) { - if(0!=getWindowHandle()) { - // n/a in BroadcomEGL - System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); - } else { - defineSize((width>0)?width:getWidth(), (height>0)?height:getHeight()); - } - } - if(x>=0 || y>=0) { - System.err.println("BCEGL Window.setPositionImpl n/a in BroadcomEGL"); - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return new Point(x,y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop .. - } - - @Override - public boolean surfaceSwap() { - SwapWindow(getDisplayHandle(), getWindowHandle()); - return true; - } - - //---------------------------------------------------------------------- - // 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.err.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+getGraphicsConfiguration()); - } - 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) { - defineSize(width, height); - GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) getGraphicsConfiguration().getRequestedCapabilities(); - final AbstractGraphicsConfiguration cfg = EGLGraphicsConfiguration.create(capsReq, getScreen().getGraphicsScreen(), cfgID); - if (null == cfg) { - throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this); - } - setGraphicsConfiguration(cfg); - if(DEBUG_IMPLEMENTATION) { - System.err.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+cfg); - } - } - - private long windowHandleClose; -} diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java new file mode 100644 index 000000000..885649d17 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java @@ -0,0 +1,221 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.linux; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import jogamp.newt.WindowImpl; + +import com.jogamp.newt.Window; +import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowListener; +import com.jogamp.newt.event.WindowUpdateEvent; + +/** + * Experimental native mouse tracker thread for GNU/Linux + * just reading /dev/input/mice + * within it's own polling thread. + */ +public class LinuxMouseTracker implements WindowListener { + + private static final LinuxMouseTracker lmt; + + static { + lmt = new LinuxMouseTracker(); + final Thread t = new Thread(lmt.mouseDevicePoller, "NEWT-LinuxMouseTracker"); + t.setDaemon(true); + t.start(); + } + + public static LinuxMouseTracker getSingleton() { + return lmt; + } + + private volatile boolean stop = false; + private int x = 0; + private int y = 0; + private int buttonDown = 0; + private int old_x = 0; + private int old_y = 0; + private int old_buttonDown = 0; + private WindowImpl focusedWindow = null; + private MouseDevicePoller mouseDevicePoller = new MouseDevicePoller(); + + @Override + public void windowResized(WindowEvent e) { } + + @Override + public void windowMoved(WindowEvent e) { } + + @Override + public void windowDestroyNotify(WindowEvent e) { + Object s = e.getSource(); + if(focusedWindow == s) { + focusedWindow = null; + } + } + + @Override + public void windowDestroyed(WindowEvent e) { } + + @Override + public void windowGainedFocus(WindowEvent e) { + Object s = e.getSource(); + if(s instanceof WindowImpl) { + focusedWindow = (WindowImpl) s; + } + } + + @Override + public void windowLostFocus(WindowEvent e) { + Object s = e.getSource(); + if(focusedWindow == s) { + focusedWindow = null; + } + } + + @Override + public void windowRepaint(WindowUpdateEvent e) { } + + class MouseDevicePoller implements Runnable { + @Override + public void run() { + final byte[] b = new byte[3]; + final File f = new File("/dev/input/mice"); + f.setReadOnly(); + InputStream fis; + try { + fis = new FileInputStream(f); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return; + } + int xd=0,yd=0; //x/y movement delta + boolean xo=false,yo=false; // x/y overflow (out of range -255 to +255) + boolean lb=false,mb=false,rb=false,hs=false,vs=false; //left/middle/right mousebutton + while(!stop) { + int remaining=3; + while(remaining>0) { + int read = 0; + try { + read = fis.read(b, 0, remaining); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(read<0) { + stop = true; // EOF of mouse !? + } else { + remaining -= read; + } + } + lb=(b[0]&1)>0; + rb=(b[0]&2)>0; + mb=(b[0]&4)>0; + hs=(b[0]&16)>0; + vs=(b[0]&32)>0; + xo=(b[0]&64)>0; + yo=(b[0]&128)>0; + xd=b[1]; + yd=b[2]; + + x+=xd; + y+=yd; + + if(x<0) { + x=0; + } + if(y<0) { + y=0; + } + + if(lb) { + buttonDown = MouseEvent.BUTTON1; + } + if(mb) { + buttonDown = MouseEvent.BUTTON2; + } + if(rb) { + buttonDown = MouseEvent.BUTTON3; + } + + if(null != focusedWindow) { + if( x >= focusedWindow.getScreen().getWidth() ) { + x = focusedWindow.getScreen().getWidth() - 1; + } + if( y >= focusedWindow.getScreen().getHeight() ) { + y = focusedWindow.getScreen().getHeight() - 1; + } + int wx = x - focusedWindow.getX(), wy = y - focusedWindow.getY(); + + if(old_x != x || old_y != y) { + // mouse moved + focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_MOVED, 0, wx, wy, 0, 0 ); + } + + if(old_buttonDown != buttonDown) { + // press/release + if( 0 != buttonDown ) { + focusedWindow.sendMouseEvent( + MouseEvent.EVENT_MOUSE_PRESSED, + 0, wx, wy, buttonDown, 0 ); + } else { + focusedWindow.sendMouseEvent( + MouseEvent.EVENT_MOUSE_RELEASED, + 0, wx, wy, old_buttonDown, 0 ); + } + } + } else { + if(Window.DEBUG_MOUSE_EVENT) { + System.out.println(x+"/"+y+", hs="+hs+",vs="+vs+",lb="+lb+",rb="+rb+",mb="+mb+",xo="+xo+",yo="+yo+"xd="+xd+",yd="+yd); + } + } + + old_x = x; + old_y = y; + old_buttonDown = buttonDown; + + } + if(null != fis) { + try { + fis.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } +} diff --git a/src/newt/native/BroadcomEGL.c b/src/newt/native/BroadcomEGL.c deleted file mode 100644 index df6aca611..000000000 --- a/src/newt/native/BroadcomEGL.c +++ /dev/null @@ -1,190 +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. - * - */ - -#include - -#include -#include -#include - -#include "jogamp_newt_driver_broadcom_egl_Window.h" - -#include "MouseEvent.h" -#include "KeyEvent.h" - -#include - -typedef unsigned int GLuint; - -EGLDisplay EGLUtil_CreateDisplayByNative( GLuint uiWidth, GLuint uiHeight ); -void EGLUtil_DestroyDisplay( EGLDisplay eglDisplay ); - -EGLSurface EGLUtil_CreateWindowByNative( EGLDisplay eglDisplay, /* bool */ GLuint bChromakey, GLuint *puiWidth, GLuint *puiHeight ); -void EGLUtil_DestroyWindow( EGLDisplay eglDisplay, EGLSurface eglSurface ); -void EGLUtil_SwapWindow( EGLDisplay eglDisplay, EGLSurface eglSurface ); - -#define VERBOSE_ON 1 - -#ifdef VERBOSE_ON - #define DBG_PRINT(...) fprintf(stdout, __VA_ARGS__) -#else - #define DBG_PRINT(...) -#endif - -static jmethodID windowCreatedID = NULL; - -/** - * Display - */ - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_broadcom_egl_Display_DispatchMessages - (JNIEnv *env, jobject obj) -{ - // FIXME: n/a - (void) env; - (void) obj; -} - -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_broadcom_egl_Display_CreateDisplay - (JNIEnv *env, jobject obj, jint width, jint height) -{ - (void) env; - (void) obj; - EGLDisplay dpy = EGLUtil_CreateDisplayByNative( (GLuint) width, (GLuint) height ); - if(NULL==dpy) { - fprintf(stderr, "[CreateDisplay] failed: NULL\n"); - } else { - DBG_PRINT( "[CreateDisplay] ok: %p, %ux%u\n", dpy, width, height); - } - return (jlong) (intptr_t) dpy; -} - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_broadcom_egl_Display_DestroyDisplay - (JNIEnv *env, jobject obj, jlong display) -{ - EGLDisplay dpy = (EGLDisplay)(intptr_t)display; - (void) env; - (void) obj; - DBG_PRINT( "[DestroyDisplay] dpy %p\n", dpy); - - EGLUtil_DestroyDisplay(dpy); - - DBG_PRINT( "[DestroyDisplay] X\n"); -} - -/** - * Window - */ - -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_broadcom_egl_Window_initIDs - (JNIEnv *env, jclass clazz) -{ - windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(III)V"); - if (windowCreatedID == NULL) { - DBG_PRINT( "initIDs failed\n" ); - return JNI_FALSE; - } - DBG_PRINT( "initIDs ok\n" ); - return JNI_TRUE; -} - -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_broadcom_egl_Window_CreateWindow - (JNIEnv *env, jobject obj, jlong display, jboolean chromaKey, jint width, jint height) -{ - EGLDisplay dpy = (EGLDisplay)(intptr_t)display; - EGLSurface window = 0; - GLuint uiWidth=(GLuint)width, uiHeight=(GLuint)height; - - if(dpy==NULL) { - fprintf(stderr, "[RealizeWindow] invalid display connection..\n"); - return 0; - } - DBG_PRINT( "[RealizeWindow.Create] dpy %p %ux%u\n", dpy, uiWidth, uiHeight); - - window = EGLUtil_CreateWindowByNative( dpy, chromaKey, &uiWidth, &uiHeight ); - - if(NULL==window) { - fprintf(stderr, "[RealizeWindow.Create] failed: NULL\n"); - return 0; - } - EGLint cfgID=0; - if(EGL_FALSE==eglQuerySurface(dpy, window, EGL_CONFIG_ID, &cfgID)) { - fprintf(stderr, "[RealizeWindow.ConfigID] failed: window %p\n", window); - EGLUtil_DestroyWindow(dpy, window); - return 0; - } - (*env)->CallVoidMethod(env, obj, windowCreatedID, (jint) cfgID, (jint)uiWidth, (jint)uiHeight); - DBG_PRINT( "[RealizeWindow.Create] ok: win %p, cfgid %d, %ux%u\n", window, cfgID, uiWidth, uiHeight); - - // release and destroy already made context .. - EGLContext ctx = eglGetCurrentContext(); - DBG_PRINT( "[RealizeWindow.Create] ctx %p - KEEP ALIVE \n", ctx); - /*eglMakeCurrent(dpy, - EGL_NO_SURFACE, - EGL_NO_SURFACE, - EGL_NO_CONTEXT); */ - DBG_PRINT( "[RealizeWindow.Create] 2\n"); - // eglDestroyContext(dpy, ctx); // culprit ? FIXME ? - DBG_PRINT( "[RealizeWindow.Create] 2 - eglDestroyContext - DISABLED - Duh ?\n"); - - DBG_PRINT( "[RealizeWindow.Create] X\n"); - - return (jlong) (intptr_t) window; -} - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_broadcom_egl_Window_CloseWindow - (JNIEnv *env, jobject obj, jlong display, jlong window) -{ - EGLDisplay dpy = (EGLDisplay) (intptr_t) display; - EGLSurface surf = (EGLSurface) (intptr_t) window; - - DBG_PRINT( "[CloseWindow] dpy %p, win %p\n", dpy, surf); - - EGLUtil_DestroyWindow(dpy, surf); - - DBG_PRINT( "[CloseWindow] X\n"); -} - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_broadcom_egl_Window_SwapWindow - (JNIEnv *env, jobject obj, jlong display, jlong window) -{ - EGLDisplay dpy = (EGLDisplay) (intptr_t) display; - EGLSurface surf = (EGLSurface) (intptr_t) window; - - DBG_PRINT( "[SwapWindow] dpy %p, win %p\n", dpy, surf); - - EGLUtil_SwapWindow( dpy, surf ); - - DBG_PRINT( "[SwapWindow] X\n"); -} - diff --git a/src/newt/native/bcm_egl.c b/src/newt/native/bcm_egl.c new file mode 100644 index 000000000..79ebd20e0 --- /dev/null +++ b/src/newt/native/bcm_egl.c @@ -0,0 +1,190 @@ +/* + * 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. + * + */ + +#include + +#include +#include +#include + +#include "jogamp_newt_driver_bcm_egl_Window.h" + +#include "MouseEvent.h" +#include "KeyEvent.h" + +#include + +typedef unsigned int GLuint; + +EGLDisplay EGLUtil_CreateDisplayByNative( GLuint uiWidth, GLuint uiHeight ); +void EGLUtil_DestroyDisplay( EGLDisplay eglDisplay ); + +EGLSurface EGLUtil_CreateWindowByNative( EGLDisplay eglDisplay, /* bool */ GLuint bChromakey, GLuint *puiWidth, GLuint *puiHeight ); +void EGLUtil_DestroyWindow( EGLDisplay eglDisplay, EGLSurface eglSurface ); +void EGLUtil_SwapWindow( EGLDisplay eglDisplay, EGLSurface eglSurface ); + +#define VERBOSE_ON 1 + +#ifdef VERBOSE_ON + #define DBG_PRINT(...) fprintf(stdout, __VA_ARGS__) +#else + #define DBG_PRINT(...) +#endif + +static jmethodID windowCreatedID = NULL; + +/** + * Display + */ + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Display_DispatchMessages + (JNIEnv *env, jobject obj) +{ + // FIXME: n/a + (void) env; + (void) obj; +} + +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_Display_CreateDisplay + (JNIEnv *env, jobject obj, jint width, jint height) +{ + (void) env; + (void) obj; + EGLDisplay dpy = EGLUtil_CreateDisplayByNative( (GLuint) width, (GLuint) height ); + if(NULL==dpy) { + fprintf(stderr, "[CreateDisplay] failed: NULL\n"); + } else { + DBG_PRINT( "[CreateDisplay] ok: %p, %ux%u\n", dpy, width, height); + } + return (jlong) (intptr_t) dpy; +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Display_DestroyDisplay + (JNIEnv *env, jobject obj, jlong display) +{ + EGLDisplay dpy = (EGLDisplay)(intptr_t)display; + (void) env; + (void) obj; + DBG_PRINT( "[DestroyDisplay] dpy %p\n", dpy); + + EGLUtil_DestroyDisplay(dpy); + + DBG_PRINT( "[DestroyDisplay] X\n"); +} + +/** + * Window + */ + +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_egl_Window_initIDs + (JNIEnv *env, jclass clazz) +{ + windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(III)V"); + if (windowCreatedID == NULL) { + DBG_PRINT( "initIDs failed\n" ); + return JNI_FALSE; + } + DBG_PRINT( "initIDs ok\n" ); + return JNI_TRUE; +} + +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_Window_CreateWindow + (JNIEnv *env, jobject obj, jlong display, jboolean chromaKey, jint width, jint height) +{ + EGLDisplay dpy = (EGLDisplay)(intptr_t)display; + EGLSurface window = 0; + GLuint uiWidth=(GLuint)width, uiHeight=(GLuint)height; + + if(dpy==NULL) { + fprintf(stderr, "[RealizeWindow] invalid display connection..\n"); + return 0; + } + DBG_PRINT( "[RealizeWindow.Create] dpy %p %ux%u\n", dpy, uiWidth, uiHeight); + + window = EGLUtil_CreateWindowByNative( dpy, chromaKey, &uiWidth, &uiHeight ); + + if(NULL==window) { + fprintf(stderr, "[RealizeWindow.Create] failed: NULL\n"); + return 0; + } + EGLint cfgID=0; + if(EGL_FALSE==eglQuerySurface(dpy, window, EGL_CONFIG_ID, &cfgID)) { + fprintf(stderr, "[RealizeWindow.ConfigID] failed: window %p\n", window); + EGLUtil_DestroyWindow(dpy, window); + return 0; + } + (*env)->CallVoidMethod(env, obj, windowCreatedID, (jint) cfgID, (jint)uiWidth, (jint)uiHeight); + DBG_PRINT( "[RealizeWindow.Create] ok: win %p, cfgid %d, %ux%u\n", window, cfgID, uiWidth, uiHeight); + + // release and destroy already made context .. + EGLContext ctx = eglGetCurrentContext(); + DBG_PRINT( "[RealizeWindow.Create] ctx %p - KEEP ALIVE \n", ctx); + /*eglMakeCurrent(dpy, + EGL_NO_SURFACE, + EGL_NO_SURFACE, + EGL_NO_CONTEXT); */ + DBG_PRINT( "[RealizeWindow.Create] 2\n"); + // eglDestroyContext(dpy, ctx); // culprit ? FIXME ? + DBG_PRINT( "[RealizeWindow.Create] 2 - eglDestroyContext - DISABLED - Duh ?\n"); + + DBG_PRINT( "[RealizeWindow.Create] X\n"); + + return (jlong) (intptr_t) window; +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Window_CloseWindow + (JNIEnv *env, jobject obj, jlong display, jlong window) +{ + EGLDisplay dpy = (EGLDisplay) (intptr_t) display; + EGLSurface surf = (EGLSurface) (intptr_t) window; + + DBG_PRINT( "[CloseWindow] dpy %p, win %p\n", dpy, surf); + + EGLUtil_DestroyWindow(dpy, surf); + + DBG_PRINT( "[CloseWindow] X\n"); +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Window_SwapWindow + (JNIEnv *env, jobject obj, jlong display, jlong window) +{ + EGLDisplay dpy = (EGLDisplay) (intptr_t) display; + EGLSurface surf = (EGLSurface) (intptr_t) window; + + DBG_PRINT( "[SwapWindow] dpy %p, win %p\n", dpy, surf); + + EGLUtil_SwapWindow( dpy, surf ); + + DBG_PRINT( "[SwapWindow] X\n"); +} + diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c new file mode 100644 index 000000000..09ab8a634 --- /dev/null +++ b/src/newt/native/bcm_vc_iv.c @@ -0,0 +1,204 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#include +#include +#include + +#include "bcm_vc_iv.h" + +#include "jogamp_newt_driver_bcm_vc_iv_Display.h" +#include "jogamp_newt_driver_bcm_vc_iv_Screen.h" +#include "jogamp_newt_driver_bcm_vc_iv_Window.h" + +#define VERBOSE_ON 1 + +#ifdef VERBOSE_ON + #define DBG_PRINT(...) fprintf(stdout, __VA_ARGS__) +#else + #define DBG_PRINT(...) +#endif + +static jmethodID setScreenSizeID = NULL; + +static jmethodID windowCreatedID = NULL; +static jmethodID sizeChangedID = NULL; +static jmethodID visibleChangedID = NULL; +static jmethodID windowDestroyNotifyID = NULL; +static jmethodID sendMouseEventID = NULL; +static jmethodID sendKeyEventID = NULL; + +/** + * Display + */ + +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Display_initIDs + (JNIEnv *env, jclass clazz) +{ + bcm_host_init(); + // TODO: bcm_host_deinit(); + DBG_PRINT( "BCM.Display initIDs ok\n" ); + return JNI_TRUE; +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Display_DispatchMessages + (JNIEnv *env, jobject obj) +{ +} + +/** + * Screen + */ + +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Screen_initIDs + (JNIEnv *env, jclass clazz) +{ + uint32_t screen_width; + uint32_t screen_height; + int32_t success = 0; + + setScreenSizeID = (*env)->GetMethodID(env, clazz, "setScreenSize", "(II)V"); + if (setScreenSizeID == NULL) { + DBG_PRINT( "BCM.Screen initIDs FALSE\n" ); + return JNI_FALSE; + } + DBG_PRINT( "BCM.Screen initIDs ok\n" ); + return JNI_TRUE; +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Screen_initNative + (JNIEnv *env, jobject obj) +{ + uint32_t screen_width; + uint32_t screen_height; + int32_t success = 0; + + if( graphics_get_display_size(0 /* LCD */, &screen_width, &screen_height) >= 0 ) { + DBG_PRINT( "BCM.Screen initNative ok %dx%d\n", screen_width, screen_height ); + (*env)->CallVoidMethod(env, obj, setScreenSizeID, (jint) screen_width, (jint) screen_height); + } + DBG_PRINT( "BCM.Screen initNative failed\n" ); +} + +/** + * Window + */ + +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_initIDs + (JNIEnv *env, jclass clazz) +{ + windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(J)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); + windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); + sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); + if (windowCreatedID == NULL || + sizeChangedID == NULL || + visibleChangedID == NULL || + windowDestroyNotifyID == NULL || + sendMouseEventID == NULL || + sendKeyEventID == NULL) { + DBG_PRINT( "initIDs failed\n" ); + return JNI_FALSE; + } + DBG_PRINT( "BCM.Window initIDs ok\n" ); + return JNI_TRUE; +} + +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_CreateWindow + (JNIEnv *env, jobject obj, jint width, jint height) +{ + int32_t success = 0; + VC_RECT_T dst_rect; + VC_RECT_T src_rect; + + dst_rect.x = 0; + dst_rect.y = 0; + dst_rect.width = width; + dst_rect.height = height; + + src_rect.x = 0; + src_rect.y = 0; + src_rect.width = width << 16; + src_rect.height = height << 16; + + DISPMANX_DISPLAY_HANDLE_T dispman_display = vc_dispmanx_display_open( 0 /* LCD */); + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display, + 0/*layer*/, &dst_rect, 0/*src*/, + &src_rect, DISPMANX_PROTECTION_NONE, + 0 /*alpha TODO*/, 0/*clamp*/, 0/*transform*/); + EGL_DISPMANX_WINDOW_T * nativeWindowPtr = calloc(1, sizeof(EGL_DISPMANX_WINDOW_T)); + nativeWindowPtr->element = dispman_element; + nativeWindowPtr->width = width; + nativeWindowPtr->height = height; + + vc_dispmanx_update_submit_sync( dispman_update ); + + (*env)->CallVoidMethod(env, obj, visibleChangedID, JNI_FALSE, JNI_TRUE); // FIXME: or defer=true ? + + return (jlong) (intptr_t) nativeWindowPtr; +} + +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_RealizeWindow + (JNIEnv *env, jobject obj, jlong window) +{ + return (jlong) (intptr_t) 0; +} + +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_CloseWindow + (JNIEnv *env, jobject obj, jlong window, jlong juserData) +{ + EGL_DISPMANX_WINDOW_T * nativeWindowPtr = (EGL_DISPMANX_WINDOW_T *) (intptr_t) window ; + free( nativeWindowPtr ); + return 0; +} + +/* + * Class: jogamp_newt_driver_bcm_vc_iv_Window + * Method: setVisible0 + * Signature: (JJZ)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_setVisible0 + (JNIEnv *env, jobject obj, jlong window, jboolean visible) +{ +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_setFullScreen0 + (JNIEnv *env, jobject obj, jlong window, jboolean fullscreen) +{ +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_setSize0 + (JNIEnv *env, jobject obj, jlong window, jint width, jint height) +{ + // FIXME RESIZE (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); +} + + diff --git a/src/newt/native/bcm_vc_iv.h b/src/newt/native/bcm_vc_iv.h new file mode 100644 index 000000000..cfcc44b16 --- /dev/null +++ b/src/newt/native/bcm_vc_iv.h @@ -0,0 +1,189 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#ifndef BCM_VC_IV_H +#define BCM_VC_IV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef uint32_t DISPMANX_PROTECTION_T; +typedef uint32_t DISPMANX_RESOURCE_HANDLE_T; +typedef uint32_t DISPMANX_DISPLAY_HANDLE_T; +typedef uint32_t DISPMANX_UPDATE_HANDLE_T; +typedef uint32_t DISPMANX_ELEMENT_HANDLE_T; + +#define DISPMANX_NO_HANDLE 0 + +#define DISPMANX_PROTECTION_MAX 0x0f +#define DISPMANX_PROTECTION_NONE 0 +#define DISPMANX_PROTECTION_HDCP 11 // Derived from the WM DRM levels, 101-300 + + + +/* Default display IDs. + Note: if you overwrite with you own dispmanx_platfrom_init function, you + should use IDs you provided during dispmanx_display_attach. +*/ +#define DISPMANX_ID_MAIN_LCD 0 +#define DISPMANX_ID_AUX_LCD 1 +#define DISPMANX_ID_HDMI 2 +#define DISPMANX_ID_SDTV 3 + +/* Return codes. Nonzero ones indicate failure. */ +typedef enum { + DISPMANX_SUCCESS = 0, + DISPMANX_INVALID = -1 + /* XXX others TBA */ +} DISPMANX_STATUS_T; + +typedef enum { + /* Bottom 2 bits sets the orientation */ + DISPMANX_NO_ROTATE = 0, + DISPMANX_ROTATE_90 = 1, + DISPMANX_ROTATE_180 = 2, + DISPMANX_ROTATE_270 = 3, + + DISPMANX_FLIP_HRIZ = 1 << 16, + DISPMANX_FLIP_VERT = 1 << 17 +} DISPMANX_TRANSFORM_T; + +typedef enum { + /* Bottom 2 bits sets the alpha mode */ + DISPMANX_FLAGS_ALPHA_FROM_SOURCE = 0, + DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS = 1, + DISPMANX_FLAGS_ALPHA_FIXED_NON_ZERO = 2, + DISPMANX_FLAGS_ALPHA_FIXED_EXCEED_0X07 = 3, + + DISPMANX_FLAGS_ALPHA_PREMULT = 1 << 16, + DISPMANX_FLAGS_ALPHA_MIX = 1 << 17 +} DISPMANX_FLAGS_ALPHA_T; + +struct VC_IMAGE_T; +typedef struct VC_IMAGE_T VC_IMAGE_T; + +typedef struct { + DISPMANX_FLAGS_ALPHA_T flags; + uint32_t opacity; + VC_IMAGE_T *mask; +} DISPMANX_ALPHA_T; + +typedef struct { + DISPMANX_FLAGS_ALPHA_T flags; + uint32_t opacity; + DISPMANX_RESOURCE_HANDLE_T mask; +} VC_DISPMANX_ALPHA_T; /* for use with vmcs_host */ + + +typedef enum { + DISPMANX_FLAGS_CLAMP_NONE = 0, + DISPMANX_FLAGS_CLAMP_LUMA_TRANSPARENT = 1, +#if __VCCOREVER__ >= 0x04000000 + DISPMANX_FLAGS_CLAMP_TRANSPARENT = 2, + DISPMANX_FLAGS_CLAMP_REPLACE = 3 +#else + DISPMANX_FLAGS_CLAMP_CHROMA_TRANSPARENT = 2, + DISPMANX_FLAGS_CLAMP_TRANSPARENT = 3 +#endif +} DISPMANX_FLAGS_CLAMP_T; + +typedef enum { + DISPMANX_FLAGS_KEYMASK_OVERRIDE = 1, + DISPMANX_FLAGS_KEYMASK_SMOOTH = 1 << 1, + DISPMANX_FLAGS_KEYMASK_CR_INV = 1 << 2, + DISPMANX_FLAGS_KEYMASK_CB_INV = 1 << 3, + DISPMANX_FLAGS_KEYMASK_YY_INV = 1 << 4 +} DISPMANX_FLAGS_KEYMASK_T; + +typedef union { + struct { + uint8_t yy_upper; + uint8_t yy_lower; + uint8_t cr_upper; + uint8_t cr_lower; + uint8_t cb_upper; + uint8_t cb_lower; + } yuv; + struct { + uint8_t red_upper; + uint8_t red_lower; + uint8_t blue_upper; + uint8_t blue_lower; + uint8_t green_upper; + uint8_t green_lower; + } rgb; +} DISPMANX_CLAMP_KEYS_T; + +typedef struct { + DISPMANX_FLAGS_CLAMP_T mode; + DISPMANX_FLAGS_KEYMASK_T key_mask; + DISPMANX_CLAMP_KEYS_T key_value; + uint32_t replace_value; +} DISPMANX_CLAMP_T; + + +typedef uint32_t DISPMANX_ELEMENT_HANDLE_T; + +typedef struct { + DISPMANX_ELEMENT_HANDLE_T element; + int width; /* This is necessary because dispmanx elements are not queriable. */ + int height; +} EGL_DISPMANX_WINDOW_T; + +typedef struct tag_VC_RECT_T { + int32_t x; + int32_t y; + int32_t width; + int32_t height; +} VC_RECT_T; + +extern void bcm_host_init(void); +extern void bcm_host_deinit(void); + +extern int32_t graphics_get_display_size( const uint16_t display_number, + uint32_t *width, + uint32_t *height); + +extern DISPMANX_DISPLAY_HANDLE_T vc_dispmanx_display_open( uint32_t device ); +extern DISPMANX_UPDATE_HANDLE_T vc_dispmanx_update_start( int32_t priority ); +extern DISPMANX_ELEMENT_HANDLE_T vc_dispmanx_element_add ( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_DISPLAY_HANDLE_T display, + int32_t layer, const VC_RECT_T *dest_rect, DISPMANX_RESOURCE_HANDLE_T src, + const VC_RECT_T *src_rect, DISPMANX_PROTECTION_T protection, + VC_DISPMANX_ALPHA_T *alpha, + DISPMANX_CLAMP_T *clamp, DISPMANX_TRANSFORM_T transform ); + +extern int vc_dispmanx_update_submit_sync( DISPMANX_UPDATE_HANDLE_T update ); + +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.2.3 From 3ab518e90eb4cf82bcb8b990d337a5e4a531136b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 18 Aug 2012 11:46:01 +0200 Subject: GLProfile/NativeWindowFactory: Remove deprecated argument 'firstUIActionOnProcess' of initSingleton() method The notion of changing the threading behavior of native initialization was deprecated for over a year. The code still contained the bits and pieces, i.e. whether X11Util.initSingletion() is invoked before or after optional AWT initialization. This condition has been removed now and behavior is uniform, i.e. X11Util.initSingletion() is invoked after optional AWT initialization. - Removed GLProfile.initSingleton(boolean firstUIActionOnProcess), use remaining GLProfile.initSingleton() - Removed NativeWindowFactory.isFirstUIActionOnProcess() - Changed NativeWindowFactory.initSingleton(boolean firstUIActionOnProcess) to NativeWindowFactory.initSingleton() --- src/jogl/classes/javax/media/opengl/GLProfile.java | 54 +++++++++------------- .../media/nativewindow/NativeWindowFactory.java | 46 +++++------------- .../nativewindow/NativeWindowFactoryImpl.java | 2 +- .../jogamp/nativewindow/macosx/OSXUtil.java | 12 ++--- .../jogamp/nativewindow/windows/GDIUtil.java | 15 +++--- .../classes/jogamp/nativewindow/x11/X11Util.java | 13 +++--- src/newt/classes/com/jogamp/newt/NewtFactory.java | 2 +- .../classes/com/jogamp/newt/util/MainThread.java | 2 +- .../test/junit/newt/TestRemoteWindow01NEWT.java | 2 +- .../test/junit/newt/TestScreenMode00NEWT.java | 2 +- .../test/junit/newt/TestScreenMode00bNEWT.java | 2 +- .../opengl/test/junit/newt/TestWindows01NEWT.java | 2 +- 12 files changed, 57 insertions(+), 97 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 1e10dc9a6..513ccd101 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -101,29 +101,29 @@ public class GLProfile { /** * Static initialization of JOGL. + * *

- * The parameter firstUIActionOnProcess has an impact on concurrent locking,
- * see {@link javax.media.nativewindow.NativeWindowFactory#initSingleton(boolean) NativeWindowFactory.initSingleton(firstUIActionOnProcess)}. + * This method shall not need to be called for other reasons than having a defined initialization sequence. *

- *

- * Applications using this method may place it's call before any other UI invocation - * in the main class's static block or within the main function. - * In such case, applications may pass firstUIActionOnProcess=true to use native toolkit locking.

- *

- * RCP Application (Applet's, Webstart, Netbeans, ..) using JOGL are not be able to initialize JOGL - * before the first UI action. - * In such case you shall pass firstUIActionOnProcess=false.

+ * *

* In case this method is not invoked, GLProfile is initialized implicit by - * the first call to {@link #getDefault()}, {@link #get(java.lang.String)} passing firstUIActionOnProcess=false. + * the first call to {@link #getDefault()}, {@link #get(java.lang.String)}. *

- * - * @param firstUIActionOnProcess Should be true if called before the first UI action of the running program, - * otherwise false. * - * @deprecated Use {@link #initSingleton()}. This method is subject to be removed in future versions of JOGL. + *

+ * To initialize JOGL at startup ASAP, this method may be invoked in the main class's + * static initializer block, in the static main() method or in the Applet init() method. + *

+ * + *

+ * Since JOGL's initialization is complex and involves multi threading, it is not recommended + * to be have it invoked on the AWT EDT thread. In case all JOGL usage is performed + * on the AWT EDT, invoke this method outside the AWT EDT - see above. + *

+ * */ - public static void initSingleton(final boolean firstUIActionOnProcess) { + public static void initSingleton() { final boolean justInitialized; initLock.lock(); try { @@ -131,7 +131,7 @@ public class GLProfile { initialized = true; justInitialized = true; if(DEBUG) { - System.err.println("GLProfile.initSingleton(firstUIActionOnProcess: "+firstUIActionOnProcess+") - thread "+Thread.currentThread().getName()); + System.err.println("GLProfile.initSingleton() - thread "+Thread.currentThread().getName()); Thread.dumpStack(); } @@ -171,7 +171,7 @@ public class GLProfile { } JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all", new String[] { "-noawt", "-mobile", "-core" } ); } - initProfilesForDefaultDevices(firstUIActionOnProcess); + initProfilesForDefaultDevices(); return null; } }); @@ -188,17 +188,6 @@ public class GLProfile { } } - /** - * Static initialization of JOGL. - * - *

- * This method shall not need to be called for other reasons than having a defined initialization sequence. - *

- */ - public static void initSingleton() { - GLProfile.initSingleton(false); - } - /** * Trigger eager initialization of GLProfiles for the given device, * in case it isn't done yet. @@ -1411,11 +1400,10 @@ public class GLProfile { /** * Tries the profiles implementation and native libraries. */ - private static void initProfilesForDefaultDevices(boolean firstUIActionOnProcess) { - NativeWindowFactory.initSingleton(firstUIActionOnProcess); + private static void initProfilesForDefaultDevices() { + NativeWindowFactory.initSingleton(); if(DEBUG) { - System.err.println("GLProfile.init firstUIActionOnProcess: "+ firstUIActionOnProcess - + ", thread: " + Thread.currentThread().getName()); + System.err.println("GLProfile.init - thread: " + Thread.currentThread().getName()); System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); System.err.println(NativeWindowVersion.getInstance()); diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 6faa9890c..94f5d753c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -99,7 +99,6 @@ public abstract class NativeWindowFactory { private static Constructor x11JAWTToolkitLockConstructor; private static Class x11ToolkitLockClass; private static Constructor x11ToolkitLockConstructor; - private static boolean isFirstUIActionOnProcess; private static boolean requiresToolkitLock; /** Creates a new NativeWindowFactory instance. End users do not @@ -138,9 +137,7 @@ public abstract class NativeWindowFactory { static boolean initialized = false; - private static void initSingletonNativeImpl(final boolean firstUIActionOnProcess, final ClassLoader cl) { - isFirstUIActionOnProcess = firstUIActionOnProcess; - + private static void initSingletonNativeImpl(final ClassLoader cl) { final String clazzName; if( TYPE_X11.equals(nativeWindowingTypePure) ) { clazzName = X11UtilClassName; @@ -152,9 +149,7 @@ public abstract class NativeWindowFactory { clazzName = null; } if( null != clazzName ) { - ReflectionUtil.callStaticMethod(clazzName, "initSingleton", - new Class[] { boolean.class }, - new Object[] { new Boolean(firstUIActionOnProcess) }, cl ); + ReflectionUtil.callStaticMethod(clazzName, "initSingleton", null, null, cl ); final Boolean res = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresToolkitLock", null, null, cl); requiresToolkitLock = res.booleanValue(); @@ -166,24 +161,13 @@ public abstract class NativeWindowFactory { /** * Static one time initialization of this factory.
* This initialization method must be called once by the program or utilizing modules! - *

- * The parameter firstUIActionOnProcess has an impact on concurrent locking: - *

    - *
  • {@link #getDefaultToolkitLock() getDefaultToolkitLock() }
  • - *
  • {@link #getDefaultToolkitLock(java.lang.String) getDefaultToolkitLock(type) }
  • - *
  • {@link #createDefaultToolkitLock(java.lang.String, long) createDefaultToolkitLock(type, dpyHandle) }
  • - *
  • {@link #createDefaultToolkitLockNoAWT(java.lang.String, long) createDefaultToolkitLockNoAWT(type, dpyHandle) }
  • - *
- *

- * @param firstUIActionOnProcess Should be true if called before the first UI action of the running program, - * otherwise false. */ - public static synchronized void initSingleton(final boolean firstUIActionOnProcess) { + public static synchronized void initSingleton() { if(!initialized) { initialized = true; if(DEBUG) { - System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.initSingleton("+firstUIActionOnProcess+")"); + System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.initSingleton()"); } final ClassLoader cl = NativeWindowFactory.class.getClassLoader(); @@ -197,10 +181,6 @@ public abstract class NativeWindowFactory { nativeWindowingTypeCustom = tmp; } - if(firstUIActionOnProcess) { - // X11 initialization before possible AWT initialization - initSingletonNativeImpl(true, cl); - } isAWTAvailable = false; // may be set to true below if( Platform.AWT_AVAILABLE && @@ -248,10 +228,13 @@ public abstract class NativeWindowFactory { } } } - if(!firstUIActionOnProcess) { - // X11 initialization after possible AWT initialization - initSingletonNativeImpl(false, cl); - } + + // X11 initialization after possible AWT initialization + // This is performed post AWT initialization, allowing AWT to complete the same, + // which may have been triggered before NativeWindow initialization. + // This way behavior is more uniforms across configurations (Applet/RCP, applications, ..). + initSingletonNativeImpl(cl); + registeredFactories = Collections.synchronizedMap(new HashMap, NativeWindowFactory>()); // register our default factory -> NativeWindow @@ -276,7 +259,6 @@ public abstract class NativeWindowFactory { } if(DEBUG) { - System.err.println("NativeWindowFactory firstUIActionOnProcess "+firstUIActionOnProcess); System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock); System.err.println("NativeWindowFactory isAWTAvailable "+isAWTAvailable+", defaultFactory "+factory); } @@ -301,12 +283,6 @@ public abstract class NativeWindowFactory { } } - /** @return true if initialized with {@link #initSingleton(boolean) initSingleton(firstUIActionOnProcess==true)}, - otherwise false. */ - public static boolean isFirstUIActionOnProcess() { - return isFirstUIActionOnProcess; - } - /** @return true if the underlying toolkit requires locking, otherwise false. */ public static boolean requiresToolkitLock() { return requiresToolkitLock; diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java index 9e18439db..2c2a627a4 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java @@ -90,7 +90,7 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { // Assume Linux, Solaris, etc. Should probably test for these explicitly. windowClassName = "jogamp.nativewindow.jawt.x11.X11JAWTWindow"; } else { - throw new IllegalArgumentException("OS " + Platform.getOSName() + " not yet supported"); + throw new IllegalArgumentException("Native windowing type " + windowingType + " (custom) not yet supported, platform reported native windowing type: "+getNativeWindowType(false)); } nativeWindowConstructor = ReflectionUtil.getConstructor( diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 894084fce..f5f735051 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -38,20 +38,18 @@ public class OSXUtil { private static boolean isInit = false; private static final boolean DEBUG = Debug.debug("OSXUtil"); - public static synchronized void initSingleton(boolean firstX11ActionOnProcess) { + public static synchronized void initSingleton() { if(!isInit) { + if(DEBUG) { + System.out.println("OSXUtil.initSingleton()"); + } if(!NWJNILibLoader.loadNativeWindow("macosx")) { throw new NativeWindowException("NativeWindow MacOSX native library load error."); } if( !initIDs0() ) { throw new NativeWindowException("MacOSX: Could not initialized native stub"); - } - - if(DEBUG) { - System.out.println("OSX.isFirstX11ActionOnProcess: "+firstX11ActionOnProcess); - } - + } isInit = true; } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index d17a1898c..fda1649b6 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -41,24 +41,21 @@ public class GDIUtil { private static RegisteredClassFactory dummyWindowClassFactory; private static boolean isInit = false; - public static synchronized void initSingleton(boolean firstX11ActionOnProcess) { + public static synchronized void initSingleton() { if(!isInit) { synchronized(X11Util.class) { if(!isInit) { - isInit = true; + if(DEBUG) { + System.out.println("GDI.initSingleton()"); + } if(!NWJNILibLoader.loadNativeWindow("win32")) { throw new NativeWindowException("NativeWindow Windows native library load error."); } - if( !initIDs0() ) { throw new NativeWindowException("GDI: Could not initialized native stub"); } - - if(DEBUG) { - System.out.println("GDI.isFirstX11ActionOnProcess: "+firstX11ActionOnProcess); - } - - dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0()); + dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0()); + isInit = true; } } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 7b46a1df0..860238649 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -95,18 +95,20 @@ public class X11Util { private static Object setX11ErrorHandlerLock = new Object(); - @SuppressWarnings("unused") - public static void initSingleton(final boolean firstX11ActionOnProcess) { + public static void initSingleton() { if(!isInit) { synchronized(X11Util.class) { if(!isInit) { isInit = true; + if(DEBUG) { + System.out.println("X11UtilUtil.initSingleton()"); + } if(!NWJNILibLoader.loadNativeWindow("x11")) { throw new NativeWindowException("NativeWindow X11 native library load error."); } - final boolean callXInitThreads = XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess; - final boolean isXInitThreadsOK = initialize0( XINITTHREADS_ALWAYS_ENABLED || firstX11ActionOnProcess, XERROR_STACKDUMP); + final boolean callXInitThreads = XINITTHREADS_ALWAYS_ENABLED ; + final boolean isXInitThreadsOK = initialize0( callXInitThreads, XERROR_STACKDUMP); isX11LockAvailable = isXInitThreadsOK && !HAS_XLOCKDISPLAY_BUG ; final long dpy = X11Lib.XOpenDisplay(null); @@ -124,8 +126,7 @@ public class X11Util { } if(DEBUG) { - System.err.println("X11Util firstX11ActionOnProcess: "+firstX11ActionOnProcess+ - ", requiresX11Lock "+requiresX11Lock+ + System.err.println("X11Util requiresX11Lock "+requiresX11Lock+ ", XInitThreads [called "+callXInitThreads+", OK "+isXInitThreadsOK+"]"+ ", isX11LockAvailable "+isX11LockAvailable+ ", X11 Display(NULL) <"+nullDisplayName+">"+ diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 61dbfb34c..0644c9164 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -52,7 +52,7 @@ public class NewtFactory { // Work-around for initialization order problems on Mac OS X // between native Newt and (apparently) Fmod static { - NativeWindowFactory.initSingleton(false); // last resort .. + NativeWindowFactory.initSingleton(); // last resort .. WindowImpl.init(NativeWindowFactory.getNativeWindowType(true)); } diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java index bbe415b2f..a6e2ae02b 100644 --- a/src/newt/classes/com/jogamp/newt/util/MainThread.java +++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java @@ -101,7 +101,7 @@ public class MainThread { public static final boolean HINT_USE_MAIN_THREAD; static { - NativeWindowFactory.initSingleton(true); + NativeWindowFactory.initSingleton(); NEWTJNILibLoader.loadNEWT(); HINT_USE_MAIN_THREAD = !NativeWindowFactory.isAWTAvailable() || Debug.getBooleanProperty("newt.MainThread.force", true); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteWindow01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteWindow01NEWT.java index eb652584c..53995e8f7 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteWindow01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteWindow01NEWT.java @@ -47,7 +47,7 @@ public class TestRemoteWindow01NEWT extends UITestCase { @BeforeClass public static void initClass() { - NativeWindowFactory.initSingleton(true); + NativeWindowFactory.initSingleton(); width = 640; height = 480; } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java index a5b7a76e7..577119bcd 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java @@ -59,7 +59,7 @@ public class TestScreenMode00NEWT extends UITestCase { @BeforeClass public static void initClass() { - NativeWindowFactory.initSingleton(true); + NativeWindowFactory.initSingleton(); width = 640; height = 480; } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java index e9e66da2c..75a312686 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java @@ -57,7 +57,7 @@ public class TestScreenMode00bNEWT extends UITestCase { @BeforeClass public static void initClass() { - NativeWindowFactory.initSingleton(true); + NativeWindowFactory.initSingleton(); width = 640; height = 480; } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java index a99edfadb..bf72348f9 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java @@ -45,7 +45,7 @@ public class TestWindows01NEWT extends UITestCase { @BeforeClass public static void initClass() { - NativeWindowFactory.initSingleton(true); + NativeWindowFactory.initSingleton(); width = 256; height = 256; } -- cgit v1.2.3 From a694cadca4ab72481e777222f412f006f973f77e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 18 Aug 2012 14:12:54 +0200 Subject: NEWT Platform Driver: Uniform impl. class names [DisplayDriver, ScreenDriver, WindowDriver] to reduce complexity and programatic selection. --- make/build-newt.xml | 36 +- make/scripts/tests.sh | 4 +- .../media/nativewindow/NativeWindowFactory.java | 12 +- .../classes/com/jogamp/newt/util/MainThread.java | 2 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 22 +- src/newt/classes/jogamp/newt/ScreenImpl.java | 28 +- src/newt/classes/jogamp/newt/WindowImpl.java | 21 +- .../jogamp/newt/driver/android/AndroidDisplay.java | 66 --- .../jogamp/newt/driver/android/AndroidScreen.java | 138 ------- .../jogamp/newt/driver/android/AndroidWindow.java | 458 --------------------- .../jogamp/newt/driver/android/DisplayDriver.java | 66 +++ .../newt/driver/android/NewtBaseActivity.java | 10 +- .../newt/driver/android/NewtVersionActivity.java | 2 +- .../jogamp/newt/driver/android/ScreenDriver.java | 138 +++++++ .../jogamp/newt/driver/android/WindowDriver.java | 458 +++++++++++++++++++++ .../classes/jogamp/newt/driver/awt/AWTCanvas.java | 1 + .../classes/jogamp/newt/driver/awt/AWTDisplay.java | 73 ---- .../classes/jogamp/newt/driver/awt/AWTScreen.java | 81 ---- .../classes/jogamp/newt/driver/awt/AWTWindow.java | 233 ----------- .../jogamp/newt/driver/awt/DisplayDriver.java | 73 ++++ .../jogamp/newt/driver/awt/ScreenDriver.java | 81 ++++ .../jogamp/newt/driver/awt/WindowDriver.java | 233 +++++++++++ .../jogamp/newt/driver/bcm/egl/Display.java | 85 ---- .../jogamp/newt/driver/bcm/egl/DisplayDriver.java | 85 ++++ .../classes/jogamp/newt/driver/bcm/egl/Screen.java | 75 ---- .../jogamp/newt/driver/bcm/egl/ScreenDriver.java | 75 ++++ .../classes/jogamp/newt/driver/bcm/egl/Window.java | 170 -------- .../jogamp/newt/driver/bcm/egl/WindowDriver.java | 170 ++++++++ .../jogamp/newt/driver/bcm/vc/iv/Display.java | 78 ---- .../newt/driver/bcm/vc/iv/DisplayDriver.java | 78 ++++ .../jogamp/newt/driver/bcm/vc/iv/Screen.java | 73 ---- .../jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java | 73 ++++ .../jogamp/newt/driver/bcm/vc/iv/Window.java | 149 ------- .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 149 +++++++ .../jogamp/newt/driver/intel/gdl/Display.java | 104 ----- .../newt/driver/intel/gdl/DisplayDriver.java | 105 +++++ .../jogamp/newt/driver/intel/gdl/Screen.java | 85 ---- .../jogamp/newt/driver/intel/gdl/ScreenDriver.java | 86 ++++ .../jogamp/newt/driver/intel/gdl/Window.java | 146 ------- .../jogamp/newt/driver/intel/gdl/WindowDriver.java | 147 +++++++ .../classes/jogamp/newt/driver/kd/Display.java | 77 ---- .../jogamp/newt/driver/kd/DisplayDriver.java | 77 ++++ src/newt/classes/jogamp/newt/driver/kd/Screen.java | 75 ---- .../jogamp/newt/driver/kd/ScreenDriver.java | 75 ++++ src/newt/classes/jogamp/newt/driver/kd/Window.java | 163 -------- .../jogamp/newt/driver/kd/WindowDriver.java | 163 ++++++++ .../jogamp/newt/driver/macosx/DisplayDriver.java | 88 ++++ .../jogamp/newt/driver/macosx/MacDisplay.java | 87 ---- .../jogamp/newt/driver/macosx/MacKeyUtil.java | 27 ++ .../jogamp/newt/driver/macosx/MacScreen.java | 143 ------- .../jogamp/newt/driver/macosx/MacWindow.java | 431 ------------------- .../jogamp/newt/driver/macosx/ScreenDriver.java | 143 +++++++ .../jogamp/newt/driver/macosx/WindowDriver.java | 431 +++++++++++++++++++ .../jogamp/newt/driver/windows/DisplayDriver.java | 95 +++++ .../jogamp/newt/driver/windows/ScreenDriver.java | 124 ++++++ .../jogamp/newt/driver/windows/WindowDriver.java | 311 ++++++++++++++ .../jogamp/newt/driver/windows/WindowsDisplay.java | 95 ----- .../jogamp/newt/driver/windows/WindowsScreen.java | 124 ------ .../jogamp/newt/driver/windows/WindowsWindow.java | 311 -------------- .../jogamp/newt/driver/x11/DisplayDriver.java | 171 ++++++++ .../jogamp/newt/driver/x11/ScreenDriver.java | 357 ++++++++++++++++ .../jogamp/newt/driver/x11/WindowDriver.java | 261 ++++++++++++ .../classes/jogamp/newt/driver/x11/X11Display.java | 171 -------- .../classes/jogamp/newt/driver/x11/X11Screen.java | 357 ---------------- .../classes/jogamp/newt/driver/x11/X11Window.java | 261 ------------ src/newt/native/AndroidWindow.c | 18 +- src/newt/native/IntelGDL.c | 24 +- src/newt/native/KDWindow.c | 20 +- src/newt/native/MacWindow.m | 116 +++--- src/newt/native/WindowsWindow.c | 78 ++-- src/newt/native/X11Common.h | 6 +- src/newt/native/X11Display.c | 22 +- src/newt/native/X11Screen.c | 62 +-- src/newt/native/X11Window.c | 42 +- src/newt/native/bcm_egl.c | 16 +- src/newt/native/bcm_vc_iv.c | 30 +- .../opengl/test/android/MovieSimpleActivity0.java | 6 +- .../opengl/test/android/MovieSimpleActivity1.java | 10 +- 78 files changed, 4608 insertions(+), 4629 deletions(-) delete mode 100644 src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java delete mode 100644 src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java delete mode 100644 src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java create mode 100644 src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/android/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java delete mode 100644 src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java delete mode 100644 src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java create mode 100644 src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/intel/gdl/Display.java create mode 100644 src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java create mode 100644 src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java create mode 100644 src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/kd/Display.java create mode 100644 src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/kd/Screen.java create mode 100644 src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/kd/Window.java create mode 100644 src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java delete mode 100644 src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java delete mode 100644 src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java create mode 100644 src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/windows/WindowsDisplay.java delete mode 100644 src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java delete mode 100644 src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java create mode 100644 src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/x11/X11Display.java delete mode 100644 src/newt/classes/jogamp/newt/driver/x11/X11Screen.java delete mode 100644 src/newt/classes/jogamp/newt/driver/x11/X11Window.java (limited to 'src/newt/classes') diff --git a/make/build-newt.xml b/make/build-newt.xml index 0a12374dd..64dccc6ac 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -670,30 +670,30 @@ - + - - - + + + - - - - + + + + - - - - - - - - - + + + + + + + + + - + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5a8d596df..cccc825ee 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -247,7 +247,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* @@ -274,7 +274,7 @@ function testawtswt() { #testawt javax.media.opengl.awt.GLCanvas $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 94f5d753c..867d0733b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -57,22 +57,22 @@ public abstract class NativeWindowFactory { protected static final boolean DEBUG; /** OpenKODE/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}*/ - public static final String TYPE_EGL = "EGL"; + public static final String TYPE_EGL = "jogamp.newt.driver.kd"; /** Microsoft Windows type, as retrieved with {@link #getNativeWindowType(boolean)} */ - public static final String TYPE_WINDOWS = "Windows"; + public static final String TYPE_WINDOWS = "jogamp.newt.driver.windows"; /** X11 type, as retrieved with {@link #getNativeWindowType(boolean)} */ - public static final String TYPE_X11 = "X11"; + public static final String TYPE_X11 = "jogamp.newt.driver.x11"; /** Android/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}*/ - public static final String TYPE_ANDROID = "ANDROID"; + public static final String TYPE_ANDROID = "jogamp.newt.driver.android"; /** Mac OS X type, as retrieved with {@link #getNativeWindowType(boolean)} */ - public static final String TYPE_MACOSX = "MacOSX"; + public static final String TYPE_MACOSX = "jogamp.newt.driver.macosx"; /** Generic AWT type, as retrieved with {@link #getNativeWindowType(boolean)} */ - public static final String TYPE_AWT = "AWT"; + public static final String TYPE_AWT = "jogamp.newt.driver.awt"; /** Generic DEFAULT type, where platform implementation don't care, as retrieved with {@link #getNativeWindowType(boolean)} */ public static final String TYPE_DEFAULT = "default"; diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java index a6e2ae02b..9c2f2a0b7 100644 --- a/src/newt/classes/com/jogamp/newt/util/MainThread.java +++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java @@ -74,7 +74,7 @@ import jogamp.newt.NEWTJNILibLoader; * * 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.
+ * have a look at the {@link jogamp.newt.driver.macosx.WindowDriver NEWT Mac OSX Window} driver implementation.
* TODO: Some hardcoded dependencies exist in this implementation, * where you have to patch this code or factor it out.

* diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 867a1f176..bac4031f0 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -44,7 +44,6 @@ import com.jogamp.newt.util.EDTUtil; import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; public abstract class DisplayImpl extends Display { private static int serialno = 1; @@ -52,26 +51,9 @@ public abstract class DisplayImpl extends Display { private static Class getDisplayClass(String type) throws ClassNotFoundException { - Class displayClass = NewtFactory.getCustomClass(type, "Display"); + final Class displayClass = NewtFactory.getCustomClass(type, "DisplayDriver"); if(null==displayClass) { - if (NativeWindowFactory.TYPE_ANDROID == type) { - displayClass = Class.forName("jogamp.newt.driver.android.AndroidDisplay"); - } else if (NativeWindowFactory.TYPE_EGL == type) { - displayClass = Class.forName("jogamp.newt.driver.kd.Display"); - } else if (NativeWindowFactory.TYPE_WINDOWS == type) { - displayClass = Class.forName("jogamp.newt.driver.windows.WindowsDisplay"); - } else if (NativeWindowFactory.TYPE_MACOSX == type) { - displayClass = Class.forName("jogamp.newt.driver.macosx.MacDisplay"); - } else if (NativeWindowFactory.TYPE_X11 == type) { - displayClass = Class.forName("jogamp.newt.driver.x11.X11Display"); - } else if (NativeWindowFactory.TYPE_AWT == type) { - displayClass = Class.forName("jogamp.newt.driver.awt.AWTDisplay"); - } else { - throw new RuntimeException("Unknown display type \"" + type + "\""); - } - } - if(null==displayClass) { - throw new ClassNotFoundException("Failed to find NEWT Display Class <"+type+".Display>"); + throw new ClassNotFoundException("Failed to find NEWT Display Class <"+type+".DisplayDriver>"); } return displayClass; } diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 9f75a0d25..e2c0f746f 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -90,31 +90,13 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { }); } - @SuppressWarnings("unchecked") - private static Class getScreenClass(String type) throws ClassNotFoundException + private static Class getScreenClass(String type) throws ClassNotFoundException { - Class screenClass = NewtFactory.getCustomClass(type, "Screen"); + final Class screenClass = NewtFactory.getCustomClass(type, "ScreenDriver"); if(null==screenClass) { - if (NativeWindowFactory.TYPE_ANDROID == type) { - screenClass = Class.forName("jogamp.newt.driver.android.AndroidScreen"); - } else if (NativeWindowFactory.TYPE_EGL == type) { - screenClass = Class.forName("jogamp.newt.driver.kd.Screen"); - } else if (NativeWindowFactory.TYPE_WINDOWS == type) { - screenClass = Class.forName("jogamp.newt.driver.windows.WindowsScreen"); - } else if (NativeWindowFactory.TYPE_MACOSX == type) { - screenClass = Class.forName("jogamp.newt.driver.macosx.MacScreen"); - } else if (NativeWindowFactory.TYPE_X11 == type) { - screenClass = Class.forName("jogamp.newt.driver.x11.X11Screen"); - } else if (NativeWindowFactory.TYPE_AWT == type) { - screenClass = Class.forName("jogamp.newt.driver.awt.AWTScreen"); - } else { - throw new RuntimeException("Unknown window type \"" + type + "\""); - } - } - if(null==screenClass) { - throw new ClassNotFoundException("Failed to find NEWT Screen Class <"+type+".Screen>"); + throw new ClassNotFoundException("Failed to find NEWT Screen Class <"+type+".ScreenDriver>"); } - return (Class)screenClass; + return screenClass; } public static Screen create(Display display, int idx) { @@ -133,7 +115,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { } } synchronized(screenList) { - Class screenClass = getScreenClass(display.getType()); + Class screenClass = getScreenClass(display.getType()); ScreenImpl screen = (ScreenImpl) screenClass.newInstance(); screen.display = (DisplayImpl) display; idx = screen.validateScreenIndex(idx); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 2971fa07e..ad7195944 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -152,26 +152,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private static Class getWindowClass(String type) throws ClassNotFoundException { - Class windowClass = NewtFactory.getCustomClass(type, "Window"); + final Class windowClass = NewtFactory.getCustomClass(type, "WindowDriver"); if(null==windowClass) { - if (NativeWindowFactory.TYPE_ANDROID == type) { - windowClass = Class.forName("jogamp.newt.driver.android.AndroidWindow"); - } else if (NativeWindowFactory.TYPE_EGL == type) { - windowClass = Class.forName("jogamp.newt.driver.kd.Window"); - } else if (NativeWindowFactory.TYPE_WINDOWS == type) { - windowClass = Class.forName("jogamp.newt.driver.windows.WindowsWindow"); - } else if (NativeWindowFactory.TYPE_MACOSX == type) { - windowClass = Class.forName("jogamp.newt.driver.macosx.MacWindow"); - } else if (NativeWindowFactory.TYPE_X11 == type) { - windowClass = Class.forName("jogamp.newt.driver.x11.X11Window"); - } else if (NativeWindowFactory.TYPE_AWT == type) { - windowClass = Class.forName("jogamp.newt.driver.awt.AWTWindow"); - } else { - throw new NativeWindowException("Unknown window type \"" + type + "\""); - } - } - if(null==windowClass) { - throw new ClassNotFoundException("Failed to find NEWT Window Class <"+type+".Window>"); + throw new ClassNotFoundException("Failed to find NEWT Window Class <"+type+".WindowDriver>"); } return windowClass; } diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java b/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java deleted file mode 100644 index 0a43c9b8f..000000000 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.newt.driver.android; - -import jogamp.newt.*; -import jogamp.opengl.egl.*; - -import javax.media.nativewindow.*; - -public class AndroidDisplay extends jogamp.newt.DisplayImpl { - static { - NEWTJNILibLoader.loadNEWT(); - - if (!AndroidWindow.initIDs0()) { - throw new NativeWindowException("Failed to initialize Android NEWT Windowing library"); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - - public AndroidDisplay() { - } - - protected void createNativeImpl() { - // EGL Device - aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); - } - - protected void closeNativeImpl() { - aDevice.close(); - } - - protected void dispatchMessagesNative() { - // n/a .. DispatchMessages(); - } -} - diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java b/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java deleted file mode 100644 index e108ed0bb..000000000 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.newt.driver.android; - -import javax.media.nativewindow.*; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; - -import android.content.Context; -import android.graphics.PixelFormat; -import android.util.DisplayMetrics; -import android.view.Surface; -import android.view.WindowManager; - -public class AndroidScreen extends jogamp.newt.ScreenImpl { - - static { - AndroidDisplay.initSingleton(); - } - - public AndroidScreen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { } - - protected ScreenMode getCurrentScreenModeImpl() { - final Context ctx = jogamp.common.os.android.StaticContext.getContext(); - final WindowManager wmgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); - final DisplayMetrics outMetrics = new DisplayMetrics(); - final android.view.Display aDisplay = wmgr.getDefaultDisplay(); - aDisplay.getMetrics(outMetrics); - - final int arot = aDisplay.getRotation(); - final int nrot = androidRotation2NewtRotation(arot); - int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; - int offset = 1; // set later for verification of iterator - offset = getScreenSize(outMetrics, nrot, props, offset); - offset = getBpp(aDisplay, props, offset); - offset = getScreenSizeMM(outMetrics, props, offset); - props[offset++] = (int) aDisplay.getRefreshRate(); - props[offset++] = nrot; - props[offset - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = offset; // count - return ScreenModeUtil.streamIn(props, 0); - } - - protected int validateScreenIndex(int idx) { - return 0; // FIXME: only one screen available ? - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - final ScreenMode sm = getCurrentScreenMode(); - virtualSize.setWidth(sm.getRotatedWidth()); - virtualSize.setHeight(sm.getRotatedHeight()); - } - - //---------------------------------------------------------------------- - // Internals only - // - static int androidRotation2NewtRotation(int arot) { - switch(arot) { - case Surface.ROTATION_270: return ScreenMode.ROTATE_270; - case Surface.ROTATION_180: return ScreenMode.ROTATE_180; - case Surface.ROTATION_90: return ScreenMode.ROTATE_90; - case Surface.ROTATION_0: - } - return ScreenMode.ROTATE_0; - } - static int getScreenSize(DisplayMetrics outMetrics, int nrot, int[] props, int offset) { - // swap width and height, since Android reflects rotated dimension, we don't - if (ScreenMode.ROTATE_90 == nrot || ScreenMode.ROTATE_270 == nrot) { - props[offset++] = outMetrics.heightPixels; - props[offset++] = outMetrics.widthPixels; - } else { - props[offset++] = outMetrics.widthPixels; - props[offset++] = outMetrics.heightPixels; - } - return offset; - } - static int getBpp(android.view.Display aDisplay, int[] props, int offset) { - int bpp; - switch(aDisplay.getPixelFormat()) { - case PixelFormat.RGBA_8888: bpp=32; break; - case PixelFormat.RGBX_8888: bpp=32; break; - case PixelFormat.RGB_888: bpp=24; break; - case PixelFormat.RGB_565: bpp=16; break; - case PixelFormat.RGBA_5551: bpp=16; break; - case PixelFormat.RGBA_4444: bpp=16; break; - case PixelFormat.RGB_332: bpp= 8; break; - default: bpp=32; - } - props[offset++] = bpp; - return offset; - } - static int getScreenSizeMM(DisplayMetrics outMetrics, int[] props, int offset) { - final float iw = (float) outMetrics.widthPixels / outMetrics.xdpi; - final float ih = (float) outMetrics.heightPixels / outMetrics.xdpi; - final float mmpi = 25.4f; - props[offset++] = (int) ((iw * mmpi)+0.5); - props[offset++] = (int) ((ih * mmpi)+0.5); - return offset; - } -} - diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java deleted file mode 100644 index 73192a07f..000000000 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java +++ /dev/null @@ -1,458 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.newt.driver.android; - -import jogamp.common.os.android.StaticContext; -import jogamp.newt.driver.android.event.AndroidNewtEventFactory; - -import javax.media.nativewindow.Capabilities; -import javax.media.nativewindow.CapabilitiesImmutable; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.Point; -import javax.media.opengl.GLCapabilitiesChooser; -import javax.media.opengl.GLCapabilitiesImmutable; - -import com.jogamp.nativewindow.egl.EGLGraphicsDevice; - -import jogamp.opengl.egl.EGL; -import jogamp.opengl.egl.EGLGraphicsConfiguration; -import jogamp.opengl.egl.EGLGraphicsConfigurationFactory; - -import android.content.Context; -import android.graphics.PixelFormat; -import android.os.Bundle; -import android.os.IBinder; -import android.os.ResultReceiver; -import android.util.Log; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceHolder.Callback2; -import android.view.inputmethod.InputMethodManager; -import android.view.SurfaceView; -import android.view.View; - -public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { - static { - AndroidDisplay.initSingleton(); - } - - public static CapabilitiesImmutable fixCaps(boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) { - PixelFormat pf = new PixelFormat(); - PixelFormat.getPixelFormatInfo(format, pf); - final CapabilitiesImmutable res; - int r, g, b, a; - - switch(format) { - case PixelFormat.RGBA_8888: r=8; g=8; b=8; a=8; break; - case PixelFormat.RGBX_8888: r=8; g=8; b=8; a=0; break; - case PixelFormat.RGB_888: r=8; g=8; b=8; a=0; break; - case PixelFormat.RGB_565: r=5; g=6; b=5; a=0; break; - case PixelFormat.RGBA_5551: r=5; g=5; b=5; a=1; break; - case PixelFormat.RGBA_4444: r=4; g=4; b=4; a=4; break; - case PixelFormat.RGB_332: r=3; g=3; b=2; a=0; break; - default: throw new InternalError("Unhandled pixelformat: "+format); - } - final boolean change = matchFormatPrecise || - rCaps.getRedBits() > r && - rCaps.getGreenBits() > g && - rCaps.getBlueBits() > b && - rCaps.getAlphaBits() > a ; - - if(change) { - Capabilities nCaps = (Capabilities) rCaps.cloneMutable(); - nCaps.setRedBits(r); - nCaps.setGreenBits(g); - nCaps.setBlueBits(b); - nCaps.setAlphaBits(a); - res = nCaps; - } else { - res = rCaps; - } - Log.d(MD.TAG, "fixCaps: format: "+format); - Log.d(MD.TAG, "fixCaps: requested: "+rCaps); - Log.d(MD.TAG, "fixCaps: chosen: "+res); - - return res; - } - - public static int getFormat(CapabilitiesImmutable rCaps) { - int fmt = PixelFormat.UNKNOWN; - - if(!rCaps.isBackgroundOpaque()) { - fmt = PixelFormat.TRANSLUCENT; - } else if(rCaps.getRedBits()<=5 && - rCaps.getGreenBits()<=6 && - rCaps.getBlueBits()<=5 && - rCaps.getAlphaBits()==0) { - fmt = PixelFormat.RGB_565; - } - /* else if(rCaps.getRedBits()<=5 && - rCaps.getGreenBits()<=5 && - rCaps.getBlueBits()<=5 && - rCaps.getAlphaBits()==1) { - fmt = PixelFormat.RGBA_5551; // FIXME: Supported ? - } */ - else { - fmt = PixelFormat.RGBA_8888; - } - Log.d(MD.TAG, "getFormat: requested: "+rCaps); - Log.d(MD.TAG, "getFormat: returned: "+fmt); - - return fmt; - } - - public static boolean isAndroidFormatTransparent(int aFormat) { - switch (aFormat) { - case PixelFormat.TRANSLUCENT: - case PixelFormat.TRANSPARENT: - return true; - } - return false; - } - - class AndroidEvents implements View.OnKeyListener, View.OnTouchListener, View.OnFocusChangeListener { - - @Override - public boolean onTouch(View v, android.view.MotionEvent event) { - final com.jogamp.newt.event.MouseEvent[] newtEvents = AndroidNewtEventFactory.createMouseEvents(event, AndroidWindow.this); - if(null != newtEvents) { - focusChanged(false, true); - for(int i=0; i[] getCustomConstructorArgumentTypes() { - return new Class[] { Context.class } ; - } - - public AndroidWindow() { - reset(); - } - - private void reset() { - ownAndroidWindow = false; - androidView = null; - nativeFormat = VisualIDHolder.VID_UNDEFINED; - androidFormat = VisualIDHolder.VID_UNDEFINED; - capsByFormat = null; - surface = null; - surfaceHandle = 0; - eglSurface = 0; - definePosition(0, 0); // default to 0/0 - setBrokenFocusChange(true); - } - - @Override - protected void instantiationFinished() { - final Context ctx = StaticContext.getContext(); - if(null == ctx) { - throw new NativeWindowException("No static [Application] Context has been set. Call StaticContext.setContext(Context) first."); - } - androidView = new MSurfaceView(ctx); - - final AndroidEvents ae = new AndroidEvents(); - androidView.setOnTouchListener(ae); - androidView.setClickable(false); - androidView.setOnKeyListener(ae); - androidView.setOnFocusChangeListener(ae); - androidView.setFocusable(true); - androidView.setFocusableInTouchMode(true); - - final SurfaceHolder sh = androidView.getHolder(); - sh.addCallback(AndroidWindow.this); - sh.setFormat(getFormat(getRequestedCapabilities())); - - // default size -> TBD ! - defineSize(0, 0); - } - - public SurfaceView getAndroidView() { return androidView; } - - @Override - protected boolean canCreateNativeImpl() { - final boolean b = 0 != surfaceHandle; - Log.d(MD.TAG, "canCreateNativeImpl: "+b); - return b; - } - - @Override - protected void createNativeImpl() { - Log.d(MD.TAG, "createNativeImpl 0 - surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ - ", format [a "+androidFormat+", n "+nativeFormat+"], "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - "+Thread.currentThread().getName()); - - if(0!=getParentWindowHandle()) { - throw new NativeWindowException("Window parenting not supported (yet)"); - } - if(0==surfaceHandle) { - throw new InternalError("XXX"); - } - - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice(); - final EGLGraphicsConfiguration eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( - capsByFormat, (GLCapabilitiesImmutable) getRequestedCapabilities(), - (GLCapabilitiesChooser)capabilitiesChooser, getScreen().getGraphicsScreen(), nativeFormat, - isAndroidFormatTransparent(androidFormat)); - if (eglConfig == null) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - final int nativeVisualID = eglConfig.getVisualID(VisualIDHolder.VIDType.NATIVE); - Log.d(MD.TAG, "nativeVisualID 0x"+Integer.toHexString(nativeVisualID)); - if(VisualIDHolder.VID_UNDEFINED != nativeVisualID) { - setSurfaceVisualID0(surfaceHandle, nativeVisualID); - } - - eglSurface = EGL.eglCreateWindowSurface(eglDevice.getHandle(), eglConfig.getNativeConfig(), surfaceHandle, null); - if (EGL.EGL_NO_SURFACE==eglSurface) { - throw new NativeWindowException("Creation of window surface failed: "+eglConfig+", surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", error "+toHexString(EGL.eglGetError())); - } - - // propagate data .. - setGraphicsConfiguration(eglConfig); - setWindowHandle(surfaceHandle); - focusChanged(false, true); - Log.d(MD.TAG, "createNativeImpl X"); - } - - @Override - protected void closeNativeImpl() { - release0(surfaceHandle); - surface = null; - surfaceHandle = 0; - eglSurface = 0; - } - - @Override - public final long getSurfaceHandle() { - return eglSurface; - } - - protected void requestFocusImpl(boolean reparented) { - if(null != androidView) { - Log.d(MD.TAG, "requestFocusImpl: reparented "+reparented); - androidView.post(new Runnable() { - public void run() { - androidView.requestFocus(); - androidView.bringToFront(); - } - }); - } - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { - Log.d(MD.TAG, "reconfigureWindowImpl.setFullscreen post creation (setContentView()) n/a"); - return false; - } - if(width>0 || height>0) { - if(0!=getWindowHandle()) { - Log.d(MD.TAG, "reconfigureWindowImpl.setSize n/a"); - return false; - } - } - if(x>=0 || y>=0) { - Log.d(MD.TAG, "reconfigureWindowImpl.setPos n/a"); - return false; - } - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return new Point(x,y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop .. - } - - //---------------------------------------------------------------------- - // Virtual On-Screen Keyboard / SoftInput - // - - private class KeyboardVisibleReceiver extends ResultReceiver { - public KeyboardVisibleReceiver() { - super(null); - } - - @Override - public void onReceiveResult(int r, Bundle data) { - boolean v = false; - - switch(r) { - case InputMethodManager.RESULT_UNCHANGED_SHOWN: - case InputMethodManager.RESULT_SHOWN: - v = true; - break; - case InputMethodManager.RESULT_HIDDEN: - case InputMethodManager.RESULT_UNCHANGED_HIDDEN: - v = false; - break; - } - Log.d(MD.TAG, "keyboardVisible: "+v); - keyboardVisibilityChanged(v); - } - } - private KeyboardVisibleReceiver keyboardVisibleReceiver = new KeyboardVisibleReceiver(); - - protected final boolean setKeyboardVisibleImpl(boolean visible) { - if(null != androidView) { - final InputMethodManager imm = (InputMethodManager) getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - final IBinder winid = getAndroidView().getWindowToken(); - if(visible) { - // Show soft-keyboard: - imm.showSoftInput(androidView, 0, keyboardVisibleReceiver); - } else { - // hide keyboard : - imm.hideSoftInputFromWindow(winid, 0, keyboardVisibleReceiver); - } - return visible; - } else { - return false; // nop - } - } - - //---------------------------------------------------------------------- - // Surface Callbacks - // - - public void surfaceCreated(SurfaceHolder holder) { - Log.d(MD.TAG, "surfaceCreated: "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); - } - - public void surfaceChanged(SurfaceHolder aHolder, int aFormat, int aWidth, int aHeight) { - Log.d(MD.TAG, "surfaceChanged: f "+nativeFormat+" -> "+aFormat+", "+aWidth+"x"+aHeight+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle)); - if(0!=surfaceHandle && androidFormat != aFormat ) { - // re-create - Log.d(MD.TAG, "surfaceChanged (destroy old)"); - if(!windowDestroyNotify(true)) { - destroy(); - } - surfaceHandle = 0; - surface=null; - } - if(getScreen().isNativeValid()) { - getScreen().getCurrentScreenMode(); // if ScreenMode changed .. trigger ScreenMode event - } - - if(0>getX() || 0>getY()) { - positionChanged(false, 0, 0); - } - - if(0 == surfaceHandle) { - androidFormat = aFormat; - surface = aHolder.getSurface(); - surfaceHandle = getSurfaceHandle0(surface); - acquire0(surfaceHandle); - nativeFormat = getSurfaceVisualID0(surfaceHandle); - final int nWidth = getWidth0(surfaceHandle); - final int nHeight = getHeight0(surfaceHandle); - capsByFormat = (GLCapabilitiesImmutable) fixCaps(true /* matchFormatPrecise */, nativeFormat, getRequestedCapabilities()); - sizeChanged(false, nWidth, nHeight, false); - - Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+ - ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ - ", format [a "+androidFormat+"/n "+nativeFormat+"], "+ - getX()+"/"+getY()+" "+nWidth+"x"+nHeight+", visible: "+isVisible()); - - if(isVisible()) { - setVisible(true); - } - } - sizeChanged(false, aWidth, aHeight, false); - windowRepaint(0, 0, aWidth, aHeight); - Log.d(MD.TAG, "surfaceChanged: X"); - } - - public void surfaceDestroyed(SurfaceHolder holder) { - Log.d(MD.TAG, "surfaceDestroyed"); - windowDestroyNotify(true); // actually too late .. however .. - } - - public void surfaceRedrawNeeded(SurfaceHolder holder) { - Log.d(MD.TAG, "surfaceRedrawNeeded"); - windowRepaint(0, 0, getWidth(), getHeight()); - } - - private boolean ownAndroidWindow; - private MSurfaceView androidView; - private int nativeFormat; // chosen current native PixelFormat (suitable for EGL) - private int androidFormat; // chosen current android PixelFormat (-1, -2 ..) - private GLCapabilitiesImmutable capsByFormat; // fixed requestedCaps by PixelFormat - private Surface surface; - private volatile long surfaceHandle; - private long eglSurface; - - class MSurfaceView extends SurfaceView { - public MSurfaceView (Context ctx) { - super(ctx); - setBackgroundDrawable(null); - // setBackgroundColor(Color.TRANSPARENT); - } - } - //---------------------------------------------------------------------- - // Internals only - // - protected static native boolean initIDs0(); - protected static native long getSurfaceHandle0(Surface surface); - protected static native int getSurfaceVisualID0(long surfaceHandle); - protected static native void setSurfaceVisualID0(long surfaceHandle, int nativeVisualID); - protected static native int getWidth0(long surfaceHandle); - protected static native int getHeight0(long surfaceHandle); - protected static native void acquire0(long surfaceHandle); - protected static native void release0(long surfaceHandle); -} diff --git a/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java new file mode 100644 index 000000000..a367462c4 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java @@ -0,0 +1,66 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.android; + +import jogamp.newt.*; +import jogamp.opengl.egl.*; + +import javax.media.nativewindow.*; + +public class DisplayDriver extends jogamp.newt.DisplayImpl { + static { + NEWTJNILibLoader.loadNEWT(); + + if (!WindowDriver.initIDs0()) { + throw new NativeWindowException("Failed to initialize Android NEWT Windowing library"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public DisplayDriver() { + } + + protected void createNativeImpl() { + // EGL Device + aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + } + + protected void closeNativeImpl() { + aDevice.close(); + } + + protected void dispatchMessagesNative() { + // n/a .. DispatchMessages(); + } +} + diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index 4537fa963..91c589beb 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -36,7 +36,7 @@ import javax.media.opengl.FPSCounter; import com.jogamp.newt.Window; import com.jogamp.opengl.util.Animator; -import jogamp.newt.driver.android.AndroidWindow; +import jogamp.newt.driver.android.WindowDriver; import android.app.Activity; import android.content.Context; @@ -83,10 +83,10 @@ public class NewtBaseActivity extends Activity { */ public void setContentView(android.view.Window androidWindow, Window newtWindow) { newtWindow = newtWindow.getDelegatedWindow(); - if(newtWindow instanceof AndroidWindow) { + if(newtWindow instanceof WindowDriver) { adaptTheme4Transparency(newtWindow.getRequestedCapabilities()); layoutForNEWTWindow(androidWindow, newtWindow); - AndroidWindow newtAWindow = (AndroidWindow)newtWindow; + WindowDriver newtAWindow = (WindowDriver)newtWindow; androidWindow.setContentView(newtAWindow.getAndroidView()); registerNEWTWindow(newtAWindow); } else { @@ -107,8 +107,8 @@ public class NewtBaseActivity extends Activity { */ public void addContentView(android.view.Window androidWindow, Window newtWindow, android.view.ViewGroup.LayoutParams params) { newtWindow = newtWindow.getDelegatedWindow(); - if(newtWindow instanceof AndroidWindow) { - AndroidWindow newtAWindow = (AndroidWindow)newtWindow; + if(newtWindow instanceof WindowDriver) { + WindowDriver newtAWindow = (WindowDriver)newtWindow; androidWindow.addContentView(newtAWindow.getAndroidView(), params); registerNEWTWindow(newtAWindow); } else { diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java index 36b83337a..a49f1648c 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java @@ -69,7 +69,7 @@ public class NewtVersionActivity extends NewtBaseActivity { glWindow.setUndecorated(true); glWindow.setSize(32, 32); glWindow.setPosition(0, 0); - final android.view.View androidGLView = ((AndroidWindow)glWindow.getDelegatedWindow()).getAndroidView(); + final android.view.View androidGLView = ((WindowDriver)glWindow.getDelegatedWindow()).getAndroidView(); viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getWidth(), glWindow.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); registerNEWTWindow(glWindow); diff --git a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java new file mode 100644 index 000000000..795aac5fb --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java @@ -0,0 +1,138 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.android; + +import javax.media.nativewindow.*; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + +import android.content.Context; +import android.graphics.PixelFormat; +import android.util.DisplayMetrics; +import android.view.Surface; +import android.view.WindowManager; + +public class ScreenDriver extends jogamp.newt.ScreenImpl { + + static { + DisplayDriver.initSingleton(); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { } + + protected ScreenMode getCurrentScreenModeImpl() { + final Context ctx = jogamp.common.os.android.StaticContext.getContext(); + final WindowManager wmgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); + final DisplayMetrics outMetrics = new DisplayMetrics(); + final android.view.Display aDisplay = wmgr.getDefaultDisplay(); + aDisplay.getMetrics(outMetrics); + + final int arot = aDisplay.getRotation(); + final int nrot = androidRotation2NewtRotation(arot); + int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; + int offset = 1; // set later for verification of iterator + offset = getScreenSize(outMetrics, nrot, props, offset); + offset = getBpp(aDisplay, props, offset); + offset = getScreenSizeMM(outMetrics, props, offset); + props[offset++] = (int) aDisplay.getRefreshRate(); + props[offset++] = nrot; + props[offset - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = offset; // count + return ScreenModeUtil.streamIn(props, 0); + } + + protected int validateScreenIndex(int idx) { + return 0; // FIXME: only one screen available ? + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + final ScreenMode sm = getCurrentScreenMode(); + virtualSize.setWidth(sm.getRotatedWidth()); + virtualSize.setHeight(sm.getRotatedHeight()); + } + + //---------------------------------------------------------------------- + // Internals only + // + static int androidRotation2NewtRotation(int arot) { + switch(arot) { + case Surface.ROTATION_270: return ScreenMode.ROTATE_270; + case Surface.ROTATION_180: return ScreenMode.ROTATE_180; + case Surface.ROTATION_90: return ScreenMode.ROTATE_90; + case Surface.ROTATION_0: + } + return ScreenMode.ROTATE_0; + } + static int getScreenSize(DisplayMetrics outMetrics, int nrot, int[] props, int offset) { + // swap width and height, since Android reflects rotated dimension, we don't + if (ScreenMode.ROTATE_90 == nrot || ScreenMode.ROTATE_270 == nrot) { + props[offset++] = outMetrics.heightPixels; + props[offset++] = outMetrics.widthPixels; + } else { + props[offset++] = outMetrics.widthPixels; + props[offset++] = outMetrics.heightPixels; + } + return offset; + } + static int getBpp(android.view.Display aDisplay, int[] props, int offset) { + int bpp; + switch(aDisplay.getPixelFormat()) { + case PixelFormat.RGBA_8888: bpp=32; break; + case PixelFormat.RGBX_8888: bpp=32; break; + case PixelFormat.RGB_888: bpp=24; break; + case PixelFormat.RGB_565: bpp=16; break; + case PixelFormat.RGBA_5551: bpp=16; break; + case PixelFormat.RGBA_4444: bpp=16; break; + case PixelFormat.RGB_332: bpp= 8; break; + default: bpp=32; + } + props[offset++] = bpp; + return offset; + } + static int getScreenSizeMM(DisplayMetrics outMetrics, int[] props, int offset) { + final float iw = (float) outMetrics.widthPixels / outMetrics.xdpi; + final float ih = (float) outMetrics.heightPixels / outMetrics.xdpi; + final float mmpi = 25.4f; + props[offset++] = (int) ((iw * mmpi)+0.5); + props[offset++] = (int) ((ih * mmpi)+0.5); + return offset; + } +} + diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java new file mode 100644 index 000000000..8ad11b35f --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -0,0 +1,458 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.android; + +import jogamp.common.os.android.StaticContext; +import jogamp.newt.driver.android.event.AndroidNewtEventFactory; + +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLCapabilitiesImmutable; + +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; + +import jogamp.opengl.egl.EGL; +import jogamp.opengl.egl.EGLGraphicsConfiguration; +import jogamp.opengl.egl.EGLGraphicsConfigurationFactory; + +import android.content.Context; +import android.graphics.PixelFormat; +import android.os.Bundle; +import android.os.IBinder; +import android.os.ResultReceiver; +import android.util.Log; +import android.view.Surface; +import android.view.SurfaceHolder; +import android.view.SurfaceHolder.Callback2; +import android.view.inputmethod.InputMethodManager; +import android.view.SurfaceView; +import android.view.View; + +public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { + static { + DisplayDriver.initSingleton(); + } + + public static CapabilitiesImmutable fixCaps(boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) { + PixelFormat pf = new PixelFormat(); + PixelFormat.getPixelFormatInfo(format, pf); + final CapabilitiesImmutable res; + int r, g, b, a; + + switch(format) { + case PixelFormat.RGBA_8888: r=8; g=8; b=8; a=8; break; + case PixelFormat.RGBX_8888: r=8; g=8; b=8; a=0; break; + case PixelFormat.RGB_888: r=8; g=8; b=8; a=0; break; + case PixelFormat.RGB_565: r=5; g=6; b=5; a=0; break; + case PixelFormat.RGBA_5551: r=5; g=5; b=5; a=1; break; + case PixelFormat.RGBA_4444: r=4; g=4; b=4; a=4; break; + case PixelFormat.RGB_332: r=3; g=3; b=2; a=0; break; + default: throw new InternalError("Unhandled pixelformat: "+format); + } + final boolean change = matchFormatPrecise || + rCaps.getRedBits() > r && + rCaps.getGreenBits() > g && + rCaps.getBlueBits() > b && + rCaps.getAlphaBits() > a ; + + if(change) { + Capabilities nCaps = (Capabilities) rCaps.cloneMutable(); + nCaps.setRedBits(r); + nCaps.setGreenBits(g); + nCaps.setBlueBits(b); + nCaps.setAlphaBits(a); + res = nCaps; + } else { + res = rCaps; + } + Log.d(MD.TAG, "fixCaps: format: "+format); + Log.d(MD.TAG, "fixCaps: requested: "+rCaps); + Log.d(MD.TAG, "fixCaps: chosen: "+res); + + return res; + } + + public static int getFormat(CapabilitiesImmutable rCaps) { + int fmt = PixelFormat.UNKNOWN; + + if(!rCaps.isBackgroundOpaque()) { + fmt = PixelFormat.TRANSLUCENT; + } else if(rCaps.getRedBits()<=5 && + rCaps.getGreenBits()<=6 && + rCaps.getBlueBits()<=5 && + rCaps.getAlphaBits()==0) { + fmt = PixelFormat.RGB_565; + } + /* else if(rCaps.getRedBits()<=5 && + rCaps.getGreenBits()<=5 && + rCaps.getBlueBits()<=5 && + rCaps.getAlphaBits()==1) { + fmt = PixelFormat.RGBA_5551; // FIXME: Supported ? + } */ + else { + fmt = PixelFormat.RGBA_8888; + } + Log.d(MD.TAG, "getFormat: requested: "+rCaps); + Log.d(MD.TAG, "getFormat: returned: "+fmt); + + return fmt; + } + + public static boolean isAndroidFormatTransparent(int aFormat) { + switch (aFormat) { + case PixelFormat.TRANSLUCENT: + case PixelFormat.TRANSPARENT: + return true; + } + return false; + } + + class AndroidEvents implements View.OnKeyListener, View.OnTouchListener, View.OnFocusChangeListener { + + @Override + public boolean onTouch(View v, android.view.MotionEvent event) { + final com.jogamp.newt.event.MouseEvent[] newtEvents = AndroidNewtEventFactory.createMouseEvents(event, WindowDriver.this); + if(null != newtEvents) { + focusChanged(false, true); + for(int i=0; i[] getCustomConstructorArgumentTypes() { + return new Class[] { Context.class } ; + } + + public WindowDriver() { + reset(); + } + + private void reset() { + ownAndroidWindow = false; + androidView = null; + nativeFormat = VisualIDHolder.VID_UNDEFINED; + androidFormat = VisualIDHolder.VID_UNDEFINED; + capsByFormat = null; + surface = null; + surfaceHandle = 0; + eglSurface = 0; + definePosition(0, 0); // default to 0/0 + setBrokenFocusChange(true); + } + + @Override + protected void instantiationFinished() { + final Context ctx = StaticContext.getContext(); + if(null == ctx) { + throw new NativeWindowException("No static [Application] Context has been set. Call StaticContext.setContext(Context) first."); + } + androidView = new MSurfaceView(ctx); + + final AndroidEvents ae = new AndroidEvents(); + androidView.setOnTouchListener(ae); + androidView.setClickable(false); + androidView.setOnKeyListener(ae); + androidView.setOnFocusChangeListener(ae); + androidView.setFocusable(true); + androidView.setFocusableInTouchMode(true); + + final SurfaceHolder sh = androidView.getHolder(); + sh.addCallback(WindowDriver.this); + sh.setFormat(getFormat(getRequestedCapabilities())); + + // default size -> TBD ! + defineSize(0, 0); + } + + public SurfaceView getAndroidView() { return androidView; } + + @Override + protected boolean canCreateNativeImpl() { + final boolean b = 0 != surfaceHandle; + Log.d(MD.TAG, "canCreateNativeImpl: "+b); + return b; + } + + @Override + protected void createNativeImpl() { + Log.d(MD.TAG, "createNativeImpl 0 - surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ + ", format [a "+androidFormat+", n "+nativeFormat+"], "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - "+Thread.currentThread().getName()); + + if(0!=getParentWindowHandle()) { + throw new NativeWindowException("Window parenting not supported (yet)"); + } + if(0==surfaceHandle) { + throw new InternalError("XXX"); + } + + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice(); + final EGLGraphicsConfiguration eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( + capsByFormat, (GLCapabilitiesImmutable) getRequestedCapabilities(), + (GLCapabilitiesChooser)capabilitiesChooser, getScreen().getGraphicsScreen(), nativeFormat, + isAndroidFormatTransparent(androidFormat)); + if (eglConfig == null) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + final int nativeVisualID = eglConfig.getVisualID(VisualIDHolder.VIDType.NATIVE); + Log.d(MD.TAG, "nativeVisualID 0x"+Integer.toHexString(nativeVisualID)); + if(VisualIDHolder.VID_UNDEFINED != nativeVisualID) { + setSurfaceVisualID0(surfaceHandle, nativeVisualID); + } + + eglSurface = EGL.eglCreateWindowSurface(eglDevice.getHandle(), eglConfig.getNativeConfig(), surfaceHandle, null); + if (EGL.EGL_NO_SURFACE==eglSurface) { + throw new NativeWindowException("Creation of window surface failed: "+eglConfig+", surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", error "+toHexString(EGL.eglGetError())); + } + + // propagate data .. + setGraphicsConfiguration(eglConfig); + setWindowHandle(surfaceHandle); + focusChanged(false, true); + Log.d(MD.TAG, "createNativeImpl X"); + } + + @Override + protected void closeNativeImpl() { + release0(surfaceHandle); + surface = null; + surfaceHandle = 0; + eglSurface = 0; + } + + @Override + public final long getSurfaceHandle() { + return eglSurface; + } + + protected void requestFocusImpl(boolean reparented) { + if(null != androidView) { + Log.d(MD.TAG, "requestFocusImpl: reparented "+reparented); + androidView.post(new Runnable() { + public void run() { + androidView.requestFocus(); + androidView.bringToFront(); + } + }); + } + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { + Log.d(MD.TAG, "reconfigureWindowImpl.setFullscreen post creation (setContentView()) n/a"); + return false; + } + if(width>0 || height>0) { + if(0!=getWindowHandle()) { + Log.d(MD.TAG, "reconfigureWindowImpl.setSize n/a"); + return false; + } + } + if(x>=0 || y>=0) { + Log.d(MD.TAG, "reconfigureWindowImpl.setPos n/a"); + return false; + } + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return new Point(x,y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop .. + } + + //---------------------------------------------------------------------- + // Virtual On-Screen Keyboard / SoftInput + // + + private class KeyboardVisibleReceiver extends ResultReceiver { + public KeyboardVisibleReceiver() { + super(null); + } + + @Override + public void onReceiveResult(int r, Bundle data) { + boolean v = false; + + switch(r) { + case InputMethodManager.RESULT_UNCHANGED_SHOWN: + case InputMethodManager.RESULT_SHOWN: + v = true; + break; + case InputMethodManager.RESULT_HIDDEN: + case InputMethodManager.RESULT_UNCHANGED_HIDDEN: + v = false; + break; + } + Log.d(MD.TAG, "keyboardVisible: "+v); + keyboardVisibilityChanged(v); + } + } + private KeyboardVisibleReceiver keyboardVisibleReceiver = new KeyboardVisibleReceiver(); + + protected final boolean setKeyboardVisibleImpl(boolean visible) { + if(null != androidView) { + final InputMethodManager imm = (InputMethodManager) getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + final IBinder winid = getAndroidView().getWindowToken(); + if(visible) { + // Show soft-keyboard: + imm.showSoftInput(androidView, 0, keyboardVisibleReceiver); + } else { + // hide keyboard : + imm.hideSoftInputFromWindow(winid, 0, keyboardVisibleReceiver); + } + return visible; + } else { + return false; // nop + } + } + + //---------------------------------------------------------------------- + // Surface Callbacks + // + + public void surfaceCreated(SurfaceHolder holder) { + Log.d(MD.TAG, "surfaceCreated: "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); + } + + public void surfaceChanged(SurfaceHolder aHolder, int aFormat, int aWidth, int aHeight) { + Log.d(MD.TAG, "surfaceChanged: f "+nativeFormat+" -> "+aFormat+", "+aWidth+"x"+aHeight+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle)); + if(0!=surfaceHandle && androidFormat != aFormat ) { + // re-create + Log.d(MD.TAG, "surfaceChanged (destroy old)"); + if(!windowDestroyNotify(true)) { + destroy(); + } + surfaceHandle = 0; + surface=null; + } + if(getScreen().isNativeValid()) { + getScreen().getCurrentScreenMode(); // if ScreenMode changed .. trigger ScreenMode event + } + + if(0>getX() || 0>getY()) { + positionChanged(false, 0, 0); + } + + if(0 == surfaceHandle) { + androidFormat = aFormat; + surface = aHolder.getSurface(); + surfaceHandle = getSurfaceHandle0(surface); + acquire0(surfaceHandle); + nativeFormat = getSurfaceVisualID0(surfaceHandle); + final int nWidth = getWidth0(surfaceHandle); + final int nHeight = getHeight0(surfaceHandle); + capsByFormat = (GLCapabilitiesImmutable) fixCaps(true /* matchFormatPrecise */, nativeFormat, getRequestedCapabilities()); + sizeChanged(false, nWidth, nHeight, false); + + Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+ + ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ + ", format [a "+androidFormat+"/n "+nativeFormat+"], "+ + getX()+"/"+getY()+" "+nWidth+"x"+nHeight+", visible: "+isVisible()); + + if(isVisible()) { + setVisible(true); + } + } + sizeChanged(false, aWidth, aHeight, false); + windowRepaint(0, 0, aWidth, aHeight); + Log.d(MD.TAG, "surfaceChanged: X"); + } + + public void surfaceDestroyed(SurfaceHolder holder) { + Log.d(MD.TAG, "surfaceDestroyed"); + windowDestroyNotify(true); // actually too late .. however .. + } + + public void surfaceRedrawNeeded(SurfaceHolder holder) { + Log.d(MD.TAG, "surfaceRedrawNeeded"); + windowRepaint(0, 0, getWidth(), getHeight()); + } + + private boolean ownAndroidWindow; + private MSurfaceView androidView; + private int nativeFormat; // chosen current native PixelFormat (suitable for EGL) + private int androidFormat; // chosen current android PixelFormat (-1, -2 ..) + private GLCapabilitiesImmutable capsByFormat; // fixed requestedCaps by PixelFormat + private Surface surface; + private volatile long surfaceHandle; + private long eglSurface; + + class MSurfaceView extends SurfaceView { + public MSurfaceView (Context ctx) { + super(ctx); + setBackgroundDrawable(null); + // setBackgroundColor(Color.TRANSPARENT); + } + } + //---------------------------------------------------------------------- + // Internals only + // + protected static native boolean initIDs0(); + protected static native long getSurfaceHandle0(Surface surface); + protected static native int getSurfaceVisualID0(long surfaceHandle); + protected static native void setSurfaceVisualID0(long surfaceHandle, int nativeVisualID); + protected static native int getWidth0(long surfaceHandle); + protected static native int getHeight0(long surfaceHandle); + protected static native void acquire0(long surfaceHandle); + protected static native void release0(long surfaceHandle); +} diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index a7950048a..b3fdcad41 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java b/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java deleted file mode 100644 index 65f8b4715..000000000 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.awt; - -import com.jogamp.nativewindow.awt.AWTGraphicsDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.util.EDTUtil; - -import jogamp.newt.DisplayImpl; - -public class AWTDisplay extends DisplayImpl { - public AWTDisplay() { - } - - protected void createNativeImpl() { - aDevice = AWTGraphicsDevice.createDefault(); - } - - protected void setAWTGraphicsDevice(AWTGraphicsDevice d) { - aDevice = d; - } - - protected void closeNativeImpl() { } - - @Override - protected EDTUtil createEDTUtil() { - final EDTUtil def; - if(NewtFactory.useEDT()) { - def = AWTEDTUtil.getSingleton(); - if(DEBUG) { - System.err.println("AWTDisplay.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName()); - } - } else { - def = null; - } - return def; - } - - protected void dispatchMessagesNative() { /* nop */ } -} - diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java b/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java deleted file mode 100644 index a3c0281b1..000000000 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.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 jogamp.newt.driver.awt; - -import java.awt.DisplayMode; - -import jogamp.newt.ScreenImpl; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -import com.jogamp.nativewindow.awt.AWTGraphicsDevice; -import com.jogamp.nativewindow.awt.AWTGraphicsScreen; - -public class AWTScreen extends ScreenImpl { - public AWTScreen() { - } - - protected void createNativeImpl() { - aScreen = new AWTGraphicsScreen((AWTGraphicsDevice)display.getGraphicsDevice()); - } - - protected void setAWTGraphicsScreen(AWTGraphicsScreen s) { - aScreen = s; - } - - /** - * Used by AWTWindow .. - */ - @Override - protected void updateVirtualScreenOriginAndSize() { - super.updateVirtualScreenOriginAndSize(); - } - - protected void closeNativeImpl() { } - - protected int validateScreenIndex(int idx) { - return idx; // pass through ... - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - final DisplayMode mode = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice().getDisplayMode(); - if(null != mode) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(mode.getWidth()); - virtualSize.setHeight(mode.getHeight()); - } - } - -} diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java deleted file mode 100644 index 2b2fed545..000000000 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.awt; - -import java.awt.BorderLayout; -import java.awt.Container; -import java.awt.Frame; -import java.awt.Insets; - -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.util.Point; - -import jogamp.newt.WindowImpl; - -import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; -import com.jogamp.nativewindow.awt.AWTGraphicsDevice; -import com.jogamp.nativewindow.awt.AWTGraphicsScreen; -import com.jogamp.newt.event.awt.AWTKeyAdapter; -import com.jogamp.newt.event.awt.AWTMouseAdapter; -import com.jogamp.newt.event.awt.AWTWindowAdapter; - -/** An implementation of the Newt Window class built using the - AWT. This is provided for convenience of porting to platforms - supporting Java SE. */ - -public class AWTWindow extends WindowImpl { - - public AWTWindow() { - this(null); - } - - public static Class[] getCustomConstructorArgumentTypes() { - return new Class[] { Container.class } ; - } - - public AWTWindow(Container container) { - super(); - this.container = container; - if(container instanceof Frame) { - frame = (Frame) container; - } - } - - private boolean owningFrame; - private Container container = null; - private Frame frame = null; // same instance as container, just for impl. convenience - private AWTCanvas canvas; - - protected void requestFocusImpl(boolean reparented) { - container.requestFocus(); - } - - @Override - protected void setTitleImpl(final String title) { - if (frame != null) { - frame.setTitle(title); - } - } - - protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { - throw new RuntimeException("Window parenting not supported in AWT, use AWTWindow(Frame) cstr for wrapping instead"); - } - - if(null==container) { - frame = new Frame(); - container = frame; - owningFrame=true; - } else { - owningFrame=false; - defineSize(container.getWidth(), container.getHeight()); - definePosition(container.getX(), container.getY()); - } - if(null!=frame) { - frame.setTitle(getTitle()); - } - container.setLayout(new BorderLayout()); - canvas = new AWTCanvas(capsRequested, AWTWindow.this.capabilitiesChooser); - - addWindowListener(new LocalWindowListener()); - - new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here - new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here - - // canvas.addComponentListener(listener); - container.add(canvas, BorderLayout.CENTER); - container.setSize(getWidth(), getHeight()); - container.setLocation(getX(), getY()); - new AWTWindowAdapter(this).addTo(container); // fwd all AWT Window events to here - - reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true)); - // throws exception if failed .. - - setWindowHandle(1); // just a marker .. - } - - protected void closeNativeImpl() { - setWindowHandle(0); // just a marker .. - if(null!=container) { - container.setVisible(false); - container.remove(canvas); - container.setEnabled(false); - canvas.setEnabled(false); - } - if(owningFrame && null!=frame) { - frame.dispose(); - owningFrame=false; - frame = null; - } - } - - @Override - public boolean hasDeviceChanged() { - boolean res = canvas.hasDeviceChanged(); - if(res) { - final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration(); - if (null == cfg) { - throw new NativeWindowException("Error Device change null GraphicsConfiguration: "+this); - } - setGraphicsConfiguration(cfg); - - // propagate new info .. - ((AWTScreen)getScreen()).setAWTGraphicsScreen((AWTGraphicsScreen)cfg.getScreen()); - ((AWTDisplay)getScreen().getDisplay()).setAWTGraphicsDevice((AWTGraphicsDevice)cfg.getScreen().getDevice()); - - ((AWTScreen)getScreen()).updateVirtualScreenOriginAndSize(); - } - return res; - } - - protected void updateInsetsImpl(javax.media.nativewindow.util.Insets insets) { - Insets contInsets = container.getInsets(); - insets.setLeftWidth(contInsets.left); - insets.setRightWidth(contInsets.right); - insets.setTopHeight(contInsets.top); - insets.setBottomHeight(contInsets.bottom); - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if(0 != ( FLAG_CHANGE_DECORATION & flags) && null!=frame) { - if(!container.isDisplayable()) { - frame.setUndecorated(isUndecorated()); - } else { - if(DEBUG_IMPLEMENTATION) { - System.err.println("AWTWindow can't undecorate already created frame"); - } - } - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - container.setVisible(0 != ( FLAG_IS_VISIBLE & flags)); - } - - container.setLocation(x, y); - Insets insets = container.getInsets(); - container.setSize(width + insets.left + insets.right, - height + insets.top + insets.bottom); - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - if( 0 != ( FLAG_IS_VISIBLE & flags ) ) { - if( !hasDeviceChanged() ) { - // oops ?? - final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration(); - if(null == cfg) { - throw new NativeWindowException("Error: !hasDeviceChanged && null == GraphicsConfiguration: "+this); - } - setGraphicsConfiguration(cfg); - } - } - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - java.awt.Point ap = canvas.getLocationOnScreen(); - ap.translate(x, y); - return new Point((int)(ap.getX()+0.5),(int)(ap.getY()+0.5)); - } - - @Override - public Object getWrappedWindow() { - return canvas; - } - - class LocalWindowListener extends com.jogamp.newt.event.WindowAdapter { - @Override - public void windowMoved(com.jogamp.newt.event.WindowEvent e) { - if(null!=container) { - definePosition(container.getX(), container.getY()); - } - } - @Override - public void windowResized(com.jogamp.newt.event.WindowEvent e) { - if(null!=canvas) { - defineSize(canvas.getWidth(), canvas.getHeight()); - } - } - } -} diff --git a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java new file mode 100644 index 000000000..39d96585b --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.awt; + +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.util.EDTUtil; + +import jogamp.newt.DisplayImpl; + +public class DisplayDriver extends DisplayImpl { + public DisplayDriver() { + } + + protected void createNativeImpl() { + aDevice = AWTGraphicsDevice.createDefault(); + } + + protected void setAWTGraphicsDevice(AWTGraphicsDevice d) { + aDevice = d; + } + + protected void closeNativeImpl() { } + + @Override + protected EDTUtil createEDTUtil() { + final EDTUtil def; + if(NewtFactory.useEDT()) { + def = AWTEDTUtil.getSingleton(); + if(DEBUG) { + System.err.println("AWTDisplay.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName()); + } + } else { + def = null; + } + return def; + } + + protected void dispatchMessagesNative() { /* nop */ } +} + diff --git a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java new file mode 100644 index 000000000..6b1283a00 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.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 jogamp.newt.driver.awt; + +import java.awt.DisplayMode; + +import jogamp.newt.ScreenImpl; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; + +public class ScreenDriver extends ScreenImpl { + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new AWTGraphicsScreen((AWTGraphicsDevice)display.getGraphicsDevice()); + } + + protected void setAWTGraphicsScreen(AWTGraphicsScreen s) { + aScreen = s; + } + + /** + * Used by AWTWindow .. + */ + @Override + protected void updateVirtualScreenOriginAndSize() { + super.updateVirtualScreenOriginAndSize(); + } + + protected void closeNativeImpl() { } + + protected int validateScreenIndex(int idx) { + return idx; // pass through ... + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + final DisplayMode mode = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice().getDisplayMode(); + if(null != mode) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(mode.getWidth()); + virtualSize.setHeight(mode.getHeight()); + } + } + +} diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java new file mode 100644 index 000000000..1723ffee5 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.awt; + +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Frame; +import java.awt.Insets; + +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.WindowImpl; + +import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.newt.event.awt.AWTKeyAdapter; +import com.jogamp.newt.event.awt.AWTMouseAdapter; +import com.jogamp.newt.event.awt.AWTWindowAdapter; + +/** An implementation of the Newt Window class built using the + AWT. This is provided for convenience of porting to platforms + supporting Java SE. */ + +public class WindowDriver extends WindowImpl { + + public WindowDriver() { + this(null); + } + + public static Class[] getCustomConstructorArgumentTypes() { + return new Class[] { Container.class } ; + } + + public WindowDriver(Container container) { + super(); + this.container = container; + if(container instanceof Frame) { + frame = (Frame) container; + } + } + + private boolean owningFrame; + private Container container = null; + private Frame frame = null; // same instance as container, just for impl. convenience + private AWTCanvas canvas; + + protected void requestFocusImpl(boolean reparented) { + container.requestFocus(); + } + + @Override + protected void setTitleImpl(final String title) { + if (frame != null) { + frame.setTitle(title); + } + } + + protected void createNativeImpl() { + if(0!=getParentWindowHandle()) { + throw new RuntimeException("Window parenting not supported in AWT, use AWTWindow(Frame) cstr for wrapping instead"); + } + + if(null==container) { + frame = new Frame(); + container = frame; + owningFrame=true; + } else { + owningFrame=false; + defineSize(container.getWidth(), container.getHeight()); + definePosition(container.getX(), container.getY()); + } + if(null!=frame) { + frame.setTitle(getTitle()); + } + container.setLayout(new BorderLayout()); + canvas = new AWTCanvas(capsRequested, WindowDriver.this.capabilitiesChooser); + + addWindowListener(new LocalWindowListener()); + + new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here + new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here + + // canvas.addComponentListener(listener); + container.add(canvas, BorderLayout.CENTER); + container.setSize(getWidth(), getHeight()); + container.setLocation(getX(), getY()); + new AWTWindowAdapter(this).addTo(container); // fwd all AWT Window events to here + + reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true)); + // throws exception if failed .. + + setWindowHandle(1); // just a marker .. + } + + protected void closeNativeImpl() { + setWindowHandle(0); // just a marker .. + if(null!=container) { + container.setVisible(false); + container.remove(canvas); + container.setEnabled(false); + canvas.setEnabled(false); + } + if(owningFrame && null!=frame) { + frame.dispose(); + owningFrame=false; + frame = null; + } + } + + @Override + public boolean hasDeviceChanged() { + boolean res = canvas.hasDeviceChanged(); + if(res) { + final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration(); + if (null == cfg) { + throw new NativeWindowException("Error Device change null GraphicsConfiguration: "+this); + } + setGraphicsConfiguration(cfg); + + // propagate new info .. + ((ScreenDriver)getScreen()).setAWTGraphicsScreen((AWTGraphicsScreen)cfg.getScreen()); + ((DisplayDriver)getScreen().getDisplay()).setAWTGraphicsDevice((AWTGraphicsDevice)cfg.getScreen().getDevice()); + + ((ScreenDriver)getScreen()).updateVirtualScreenOriginAndSize(); + } + return res; + } + + protected void updateInsetsImpl(javax.media.nativewindow.util.Insets insets) { + Insets contInsets = container.getInsets(); + insets.setLeftWidth(contInsets.left); + insets.setRightWidth(contInsets.right); + insets.setTopHeight(contInsets.top); + insets.setBottomHeight(contInsets.bottom); + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(0 != ( FLAG_CHANGE_DECORATION & flags) && null!=frame) { + if(!container.isDisplayable()) { + frame.setUndecorated(isUndecorated()); + } else { + if(DEBUG_IMPLEMENTATION) { + System.err.println("AWTWindow can't undecorate already created frame"); + } + } + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + container.setVisible(0 != ( FLAG_IS_VISIBLE & flags)); + } + + container.setLocation(x, y); + Insets insets = container.getInsets(); + container.setSize(width + insets.left + insets.right, + height + insets.top + insets.bottom); + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + if( 0 != ( FLAG_IS_VISIBLE & flags ) ) { + if( !hasDeviceChanged() ) { + // oops ?? + final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration(); + if(null == cfg) { + throw new NativeWindowException("Error: !hasDeviceChanged && null == GraphicsConfiguration: "+this); + } + setGraphicsConfiguration(cfg); + } + } + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + java.awt.Point ap = canvas.getLocationOnScreen(); + ap.translate(x, y); + return new Point((int)(ap.getX()+0.5),(int)(ap.getY()+0.5)); + } + + @Override + public Object getWrappedWindow() { + return canvas; + } + + class LocalWindowListener extends com.jogamp.newt.event.WindowAdapter { + @Override + public void windowMoved(com.jogamp.newt.event.WindowEvent e) { + if(null!=container) { + definePosition(container.getX(), container.getY()); + } + } + @Override + public void windowResized(com.jogamp.newt.event.WindowEvent e) { + if(null!=canvas) { + defineSize(canvas.getWidth(), canvas.getHeight()); + } + } + } +} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java deleted file mode 100644 index f08890da6..000000000 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.bcm.egl; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; - -import jogamp.newt.NEWTJNILibLoader; -import jogamp.opengl.egl.EGL; - -import com.jogamp.nativewindow.egl.EGLGraphicsDevice; - -public class Display extends jogamp.newt.DisplayImpl { - - static { - NEWTJNILibLoader.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 createNativeImpl() { - final long handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight); - if (handle == EGL.EGL_NO_DISPLAY) { - throw new NativeWindowException("BC EGL CreateDisplay failed"); - } - aDevice = new EGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, handle, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, null); - } - - protected void closeNativeImpl() { - if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { - DestroyDisplay(aDevice.getHandle()); - } - } - - protected void dispatchMessagesNative() { - // 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/jogamp/newt/driver/bcm/egl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java new file mode 100644 index 000000000..65ca63eec --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.bcm.egl; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import jogamp.newt.NEWTJNILibLoader; +import jogamp.opengl.egl.EGL; + +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; + +public class DisplayDriver extends jogamp.newt.DisplayImpl { + + static { + NEWTJNILibLoader.loadNEWT(); + + if (!WindowDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize BCEGL Window jmethodIDs"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public DisplayDriver() { + } + + protected void createNativeImpl() { + final long handle = CreateDisplay(ScreenDriver.fixedWidth, ScreenDriver.fixedHeight); + if (handle == EGL.EGL_NO_DISPLAY) { + throw new NativeWindowException("BC EGL CreateDisplay failed"); + } + aDevice = new EGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, handle, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, null); + } + + protected void closeNativeImpl() { + if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { + DestroyDisplay(aDevice.getHandle()); + } + } + + protected void dispatchMessagesNative() { + // 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/jogamp/newt/driver/bcm/egl/Screen.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java deleted file mode 100644 index 909444d24..000000000 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.bcm.egl; - -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -public class Screen extends jogamp.newt.ScreenImpl { - - static { - Display.initSingleton(); - } - - - public Screen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { } - - protected int validateScreenIndex(int idx) { - return 0; // only one screen available - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(fixedWidth); // FIXME - virtualSize.setHeight(fixedHeight); // FIXME - } - - //---------------------------------------------------------------------- - // Internals only - // - - static final int fixedWidth = 1920; // FIXME - static final int fixedHeight = 1080; // FIXME -} - diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java new file mode 100644 index 000000000..deb2a534b --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.bcm.egl; + +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +public class ScreenDriver extends jogamp.newt.ScreenImpl { + + static { + DisplayDriver.initSingleton(); + } + + + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { } + + protected int validateScreenIndex(int idx) { + return 0; // only one screen available + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(fixedWidth); // FIXME + virtualSize.setHeight(fixedHeight); // FIXME + } + + //---------------------------------------------------------------------- + // Internals only + // + + static final int fixedWidth = 1920; // FIXME + static final int fixedHeight = 1080; // FIXME +} + diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java deleted file mode 100644 index 87170e4ab..000000000 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.bcm.egl; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.Point; -import javax.media.opengl.GLCapabilitiesImmutable; - -import jogamp.opengl.egl.EGLGraphicsConfiguration; - -public class Window extends jogamp.newt.WindowImpl { - static { - Display.initSingleton(); - } - - public Window() { - } - - protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { - throw new RuntimeException("Window parenting not supported (yet)"); - } - // query a good configuration, however chose the final one by the native queried egl-cfg-id - // after creation at {@link #windowCreated(int, int, int)}. - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - setSizeImpl(getScreen().getWidth(), getScreen().getHeight()); - - setWindowHandle(realizeWindow(true, getWidth(), getHeight())); - if (0 == getWindowHandle()) { - throw new NativeWindowException("Error native Window Handle is null"); - } - } - - protected void closeNativeImpl() { - if(0!=windowHandleClose) { - CloseWindow(getDisplayHandle(), windowHandleClose); - } - } - - protected void requestFocusImpl(boolean reparented) { } - - protected void setSizeImpl(int width, int height) { - if(0!=getWindowHandle()) { - // n/a in BroadcomEGL - System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); - } else { - defineSize(width, height); - } - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if(0!=getWindowHandle()) { - if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { - if( 0 != ( FLAG_IS_FULLSCREEN & flags) ) { - // n/a in BroadcomEGL - System.err.println("setFullscreen n/a in BroadcomEGL"); - return false; - } - } - } - if(width>0 || height>0) { - if(0!=getWindowHandle()) { - // n/a in BroadcomEGL - System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); - } else { - defineSize((width>0)?width:getWidth(), (height>0)?height:getHeight()); - } - } - if(x>=0 || y>=0) { - System.err.println("BCEGL Window.setPositionImpl n/a in BroadcomEGL"); - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return new Point(x,y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop .. - } - - @Override - public boolean surfaceSwap() { - SwapWindow(getDisplayHandle(), getWindowHandle()); - return true; - } - - //---------------------------------------------------------------------- - // 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.err.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+getGraphicsConfiguration()); - } - 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) { - defineSize(width, height); - GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) getGraphicsConfiguration().getRequestedCapabilities(); - final AbstractGraphicsConfiguration cfg = EGLGraphicsConfiguration.create(capsReq, getScreen().getGraphicsScreen(), cfgID); - if (null == cfg) { - throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this); - } - setGraphicsConfiguration(cfg); - if(DEBUG_IMPLEMENTATION) { - System.err.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+cfg); - } - } - - private long windowHandleClose; -} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java new file mode 100644 index 000000000..49d3d98ba --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.bcm.egl; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; +import javax.media.opengl.GLCapabilitiesImmutable; + +import jogamp.opengl.egl.EGLGraphicsConfiguration; + +public class WindowDriver extends jogamp.newt.WindowImpl { + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + protected void createNativeImpl() { + if(0!=getParentWindowHandle()) { + throw new RuntimeException("Window parenting not supported (yet)"); + } + // query a good configuration, however chose the final one by the native queried egl-cfg-id + // after creation at {@link #windowCreated(int, int, int)}. + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + setSizeImpl(getScreen().getWidth(), getScreen().getHeight()); + + setWindowHandle(realizeWindow(true, getWidth(), getHeight())); + if (0 == getWindowHandle()) { + throw new NativeWindowException("Error native Window Handle is null"); + } + } + + protected void closeNativeImpl() { + if(0!=windowHandleClose) { + CloseWindow(getDisplayHandle(), windowHandleClose); + } + } + + protected void requestFocusImpl(boolean reparented) { } + + protected void setSizeImpl(int width, int height) { + if(0!=getWindowHandle()) { + // n/a in BroadcomEGL + System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); + } else { + defineSize(width, height); + } + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(0!=getWindowHandle()) { + if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { + if( 0 != ( FLAG_IS_FULLSCREEN & flags) ) { + // n/a in BroadcomEGL + System.err.println("setFullscreen n/a in BroadcomEGL"); + return false; + } + } + } + if(width>0 || height>0) { + if(0!=getWindowHandle()) { + // n/a in BroadcomEGL + System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); + } else { + defineSize((width>0)?width:getWidth(), (height>0)?height:getHeight()); + } + } + if(x>=0 || y>=0) { + System.err.println("BCEGL Window.setPositionImpl n/a in BroadcomEGL"); + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return new Point(x,y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop .. + } + + @Override + public boolean surfaceSwap() { + SwapWindow(getDisplayHandle(), getWindowHandle()); + return true; + } + + //---------------------------------------------------------------------- + // 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.err.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+getGraphicsConfiguration()); + } + 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) { + defineSize(width, height); + GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) getGraphicsConfiguration().getRequestedCapabilities(); + final AbstractGraphicsConfiguration cfg = EGLGraphicsConfiguration.create(capsReq, getScreen().getGraphicsScreen(), cfgID); + if (null == cfg) { + throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this); + } + setGraphicsConfiguration(cfg); + if(DEBUG_IMPLEMENTATION) { + System.err.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+cfg); + } + } + + private long windowHandleClose; +} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java deleted file mode 100644 index 62af02abb..000000000 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.newt.driver.bcm.vc.iv; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; - -import jogamp.newt.DisplayImpl; -import jogamp.newt.NEWTJNILibLoader; -import jogamp.opengl.egl.EGL; -import jogamp.opengl.egl.EGLDisplayUtil; - -public class Display extends DisplayImpl { - static { - NEWTJNILibLoader.loadNEWT(); - - if (!Display.initIDs()) { - throw new NativeWindowException("Failed to initialize bcm.vc.iv Display jmethodIDs"); - } - if (!Screen.initIDs()) { - throw new NativeWindowException("Failed to initialize bcm.vc.iv Screen jmethodIDs"); - } - if (!Window.initIDs()) { - throw new NativeWindowException("Failed to initialize bcm.vc.iv Window jmethodIDs"); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - - public Display() { - } - - protected void createNativeImpl() { - // FIXME: map name to EGL_*_DISPLAY - aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); - } - - protected void closeNativeImpl() { - aDevice.close(); - } - - protected void dispatchMessagesNative() { - DispatchMessages(); - } - - protected static native boolean initIDs(); - private native void DispatchMessages(); -} - diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java new file mode 100644 index 000000000..08c5c573c --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java @@ -0,0 +1,78 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.bcm.vc.iv; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import jogamp.newt.DisplayImpl; +import jogamp.newt.NEWTJNILibLoader; +import jogamp.opengl.egl.EGL; +import jogamp.opengl.egl.EGLDisplayUtil; + +public class DisplayDriver extends DisplayImpl { + static { + NEWTJNILibLoader.loadNEWT(); + + if (!DisplayDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize bcm.vc.iv Display jmethodIDs"); + } + if (!ScreenDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize bcm.vc.iv Screen jmethodIDs"); + } + if (!WindowDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize bcm.vc.iv Window jmethodIDs"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public DisplayDriver() { + } + + protected void createNativeImpl() { + // FIXME: map name to EGL_*_DISPLAY + aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + } + + protected void closeNativeImpl() { + aDevice.close(); + } + + protected void dispatchMessagesNative() { + DispatchMessages(); + } + + protected static native boolean initIDs(); + private native void DispatchMessages(); +} + diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java deleted file mode 100644 index 484d4bf81..000000000 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.newt.driver.bcm.vc.iv; - -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -import jogamp.newt.ScreenImpl; - -public class Screen extends ScreenImpl { - static { - Display.initSingleton(); - } - - public Screen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - initNative(); - } - - protected void closeNativeImpl() { } - - protected int validateScreenIndex(int idx) { - return 0; // only one screen available - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(cachedWidth); - virtualSize.setHeight(cachedHeight); - } - - protected void setScreenSize(int width, int height) { - cachedWidth = width; - cachedHeight = height; - } - - private static int cachedWidth = 0; - private static int cachedHeight = 0; - - protected static native boolean initIDs(); - protected native void initNative(); -} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java new file mode 100644 index 000000000..787d1a1b4 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java @@ -0,0 +1,73 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.bcm.vc.iv; + +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.ScreenImpl; + +public class ScreenDriver extends ScreenImpl { + static { + DisplayDriver.initSingleton(); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + initNative(); + } + + protected void closeNativeImpl() { } + + protected int validateScreenIndex(int idx) { + return 0; // only one screen available + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(cachedWidth); + virtualSize.setHeight(cachedHeight); + } + + protected void setScreenSize(int width, int height) { + cachedWidth = width; + cachedHeight = height; + } + + private static int cachedWidth = 0; + private static int cachedHeight = 0; + + protected static native boolean initIDs(); + protected native void initNative(); +} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java deleted file mode 100644 index 3d00949de..000000000 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.newt.driver.bcm.vc.iv; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.Point; - -import jogamp.newt.WindowImpl; -import jogamp.newt.driver.linux.LinuxMouseTracker; - -public class Window extends WindowImpl { - private static final String WINDOW_CLASS_NAME = "NewtWindow"; - - static { - Display.initSingleton(); - } - - public Window() { - } - - protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { - throw new RuntimeException("Window parenting not supported (yet)"); - } - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - - nativeWindowHandle = CreateWindow(getWidth(), getHeight()); - if (nativeWindowHandle == 0) { - throw new NativeWindowException("Error creating egl window: "+cfg); - } - setVisible0(nativeWindowHandle, false); - setWindowHandle(nativeWindowHandle); - if (0 == getWindowHandle()) { - throw new NativeWindowException("Error native Window Handle is null"); - } - windowHandleClose = nativeWindowHandle; - addWindowListener(LinuxMouseTracker.getSingleton()); - focusChanged(false, true); - } - - protected void closeNativeImpl() { - removeWindowListener(LinuxMouseTracker.getSingleton()); - - if(0!=windowHandleClose) { - CloseWindow(windowHandleClose, windowUserData); - windowUserData=0; - } - } - - protected void requestFocusImpl(boolean reparented) { - focusChanged(false, true); - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - setVisible0(nativeWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - if(0!=nativeWindowHandle) { - if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { - final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; - setFullScreen0(nativeWindowHandle, fs); - if(fs) { - return true; - } - } - // int _x=(x>=0)?x:this.x; - // int _y=(x>=0)?y:this.y; - width=(width>0)?width:getWidth(); - height=(height>0)?height:getHeight(); - if(width>0 || height>0) { - setSize0(nativeWindowHandle, width, height); - } - if(x>=0 || y>=0) { - System.err.println("setPosition n/a in KD"); - } - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return new Point(x,y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop .. - } - - //---------------------------------------------------------------------- - // Internals only - // - - protected static native boolean initIDs(); - private native long CreateWindow(int width, int height); - 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 long nativeWindowHandle; - private long windowHandleClose; - private long windowUserData; -} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java new file mode 100644 index 000000000..6d4f36964 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -0,0 +1,149 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.bcm.vc.iv; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.WindowImpl; +import jogamp.newt.driver.linux.LinuxMouseTracker; + +public class WindowDriver extends WindowImpl { + private static final String WINDOW_CLASS_NAME = "NewtWindow"; + + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + protected void createNativeImpl() { + if(0!=getParentWindowHandle()) { + throw new RuntimeException("Window parenting not supported (yet)"); + } + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + + nativeWindowHandle = CreateWindow(getWidth(), getHeight()); + if (nativeWindowHandle == 0) { + throw new NativeWindowException("Error creating egl window: "+cfg); + } + setVisible0(nativeWindowHandle, false); + setWindowHandle(nativeWindowHandle); + if (0 == getWindowHandle()) { + throw new NativeWindowException("Error native Window Handle is null"); + } + windowHandleClose = nativeWindowHandle; + addWindowListener(LinuxMouseTracker.getSingleton()); + focusChanged(false, true); + } + + protected void closeNativeImpl() { + removeWindowListener(LinuxMouseTracker.getSingleton()); + + if(0!=windowHandleClose) { + CloseWindow(windowHandleClose, windowUserData); + windowUserData=0; + } + } + + protected void requestFocusImpl(boolean reparented) { + focusChanged(false, true); + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + setVisible0(nativeWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + if(0!=nativeWindowHandle) { + if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { + final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; + setFullScreen0(nativeWindowHandle, fs); + if(fs) { + return true; + } + } + // int _x=(x>=0)?x:this.x; + // int _y=(x>=0)?y:this.y; + width=(width>0)?width:getWidth(); + height=(height>0)?height:getHeight(); + if(width>0 || height>0) { + setSize0(nativeWindowHandle, width, height); + } + if(x>=0 || y>=0) { + System.err.println("setPosition n/a in KD"); + } + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return new Point(x,y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop .. + } + + //---------------------------------------------------------------------- + // Internals only + // + + protected static native boolean initIDs(); + private native long CreateWindow(int width, int height); + 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 long nativeWindowHandle; + private long windowHandleClose; + private long windowUserData; +} diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Display.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Display.java deleted file mode 100644 index 20e151eb3..000000000 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Display.java +++ /dev/null @@ -1,104 +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 jogamp.newt.driver.intel.gdl; - -import jogamp.newt.*; -import javax.media.nativewindow.*; - -public class Display extends jogamp.newt.DisplayImpl { - static int initCounter = 0; - - static { - NEWTJNILibLoader.loadNEWT(); - - if (!Screen.initIDs()) { - throw new NativeWindowException("Failed to initialize GDL Screen jmethodIDs"); - } - if (!Window.initIDs()) { - throw new NativeWindowException("Failed to initialize GDL Window jmethodIDs"); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - - public Display() { - } - - protected void createNativeImpl() { - synchronized(Display.class) { - if(0==initCounter) { - displayHandle = CreateDisplay(); - if(0==displayHandle) { - throw new NativeWindowException("Couldn't initialize GDL Display"); - } - } - initCounter++; - } - aDevice = new DefaultGraphicsDevice(NativeWindowFactory.TYPE_DEFAULT, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, displayHandle); - } - - protected void closeNativeImpl() { - if(0==displayHandle) { - throw new NativeWindowException("displayHandle null; initCnt "+initCounter); - } - synchronized(Display.class) { - if(initCounter>0) { - initCounter--; - if(0==initCounter) { - DestroyDisplay(displayHandle); - } - } - } - } - - protected void dispatchMessagesNative() { - if(0!=displayHandle) { - DispatchMessages(displayHandle, focusedWindow); - } - } - - protected void setFocus(Window focus) { - focusedWindow = focus; - } - - private long displayHandle = 0; - private Window focusedWindow = null; - private native long CreateDisplay(); - private native void DestroyDisplay(long displayHandle); - private native void DispatchMessages(long displayHandle, Window focusedWindow); -} - diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java new file mode 100644 index 000000000..97c384d33 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.intel.gdl; + +import jogamp.newt.*; +import javax.media.nativewindow.*; + +public class DisplayDriver extends jogamp.newt.DisplayImpl { + static int initCounter = 0; + + static { + NEWTJNILibLoader.loadNEWT(); + + if (!ScreenDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize GDL Screen jmethodIDs"); + } + if (!WindowDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize GDL Window jmethodIDs"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public DisplayDriver() { + } + + protected void createNativeImpl() { + synchronized(DisplayDriver.class) { + if(0==initCounter) { + displayHandle = CreateDisplay(); + if(0==displayHandle) { + throw new NativeWindowException("Couldn't initialize GDL Display"); + } + } + initCounter++; + } + aDevice = new DefaultGraphicsDevice(NativeWindowFactory.TYPE_DEFAULT, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, displayHandle); + } + + protected void closeNativeImpl() { + if(0==displayHandle) { + throw new NativeWindowException("displayHandle null; initCnt "+initCounter); + } + synchronized(DisplayDriver.class) { + if(initCounter>0) { + initCounter--; + if(0==initCounter) { + DestroyDisplay(displayHandle); + } + } + } + } + + protected void dispatchMessagesNative() { + if(0!=displayHandle) { + DispatchMessages(displayHandle, focusedWindow); + } + } + + protected void setFocus(WindowDriver focus) { + focusedWindow = focus; + } + + private long displayHandle = 0; + private WindowDriver focusedWindow = null; + private native long CreateDisplay(); + private native void DestroyDisplay(long displayHandle); + private native void DispatchMessages(long displayHandle, WindowDriver focusedWindow); +} + diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java deleted file mode 100644 index 66ad1c691..000000000 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java +++ /dev/null @@ -1,85 +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 jogamp.newt.driver.intel.gdl; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -public class Screen extends jogamp.newt.ScreenImpl { - - static { - Display.initSingleton(); - } - - public Screen() { - } - - protected void createNativeImpl() { - AbstractGraphicsDevice adevice = getDisplay().getGraphicsDevice(); - GetScreenInfo(adevice.getHandle(), screen_idx); - aScreen = new DefaultGraphicsScreen(adevice, screen_idx); - } - - protected void closeNativeImpl() { } - - protected int validateScreenIndex(int idx) { - return 0; // only one screen available - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(cachedWidth); - virtualSize.setHeight(cachedHeight); - } - - //---------------------------------------------------------------------- - // Internals only - // - - protected static native boolean initIDs(); - private native void GetScreenInfo(long displayHandle, int screen_idx); - - // called by GetScreenInfo() .. - private void screenCreated(int width, int height) { - cachedWidth = width; - cachedHeight = height; - } - - private static int cachedWidth = 0; - private static int cachedHeight = 0; -} - diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java new file mode 100644 index 000000000..8eed14dde --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.intel.gdl; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +public class ScreenDriver extends jogamp.newt.ScreenImpl { + + static { + DisplayDriver.initSingleton(); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + AbstractGraphicsDevice adevice = getDisplay().getGraphicsDevice(); + GetScreenInfo(adevice.getHandle(), screen_idx); + aScreen = new DefaultGraphicsScreen(adevice, screen_idx); + } + + protected void closeNativeImpl() { } + + protected int validateScreenIndex(int idx) { + return 0; // only one screen available + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(cachedWidth); + virtualSize.setHeight(cachedHeight); + } + + //---------------------------------------------------------------------- + // Internals only + // + + protected static native boolean initIDs(); + private native void GetScreenInfo(long displayHandle, int screen_idx); + + // called by GetScreenInfo() .. + private void screenCreated(int width, int height) { + cachedWidth = width; + cachedHeight = height; + } + + private static int cachedWidth = 0; + private static int cachedHeight = 0; +} + diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java deleted file mode 100644 index d5c75abd4..000000000 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java +++ /dev/null @@ -1,146 +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 jogamp.newt.driver.intel.gdl; - -import javax.media.nativewindow.*; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.Point; - -public class Window extends jogamp.newt.WindowImpl { - static { - Display.initSingleton(); - } - - public Window() { - } - - static long nextWindowHandle = 1; - - protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { - throw new NativeWindowException("GDL Window does not support window parenting"); - } - final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); - final AbstractGraphicsDevice aDevice = getScreen().getDisplay().getGraphicsDevice(); - - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aDevice, capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, aScreen, VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - - synchronized(Window.class) { - setWindowHandle(nextWindowHandle++); // just a marker - - surfaceHandle = CreateSurface(aDevice.getHandle(), getScreen().getWidth(), getScreen().getHeight(), getX(), getY(), getWidth(), getHeight()); - if (surfaceHandle == 0) { - throw new NativeWindowException("Error creating window"); - } - } - } - - protected void closeNativeImpl() { - if(0!=surfaceHandle) { - synchronized(Window.class) { - CloseSurface(getDisplayHandle(), surfaceHandle); - } - surfaceHandle = 0; - ((Display)getScreen().getDisplay()).setFocus(null); - } - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - Screen screen = (Screen) getScreen(); - - if(width>screen.getWidth()) { - width=screen.getWidth(); - } - if(height>screen.getHeight()) { - height=screen.getHeight(); - } - if((x+width)>screen.getWidth()) { - x=screen.getWidth()-width; - } - if((y+height)>screen.getHeight()) { - y=screen.getHeight()-height; - } - - if(0!=surfaceHandle) { - SetBounds0(surfaceHandle, getScreen().getWidth(), getScreen().getHeight(), x, y, width, height); - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - if(0 != ( FLAG_IS_VISIBLE & flags)) { - ((Display)getScreen().getDisplay()).setFocus(this); - } - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - return true; - } - - protected void requestFocusImpl(boolean reparented) { - ((Display)getScreen().getDisplay()).setFocus(this); - } - - @Override - public final long getSurfaceHandle() { - return surfaceHandle; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return new Point(x,y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop .. - } - - //---------------------------------------------------------------------- - // Internals only - // - - protected static native boolean initIDs(); - private native long CreateSurface(long displayHandle, int scrn_width, int scrn_height, int x, int y, int width, int height); - private native void CloseSurface(long displayHandle, long surfaceHandle); - private native void SetBounds0(long surfaceHandle, int scrn_width, int scrn_height, int x, int y, int width, int height); - - private void updateBounds(int x, int y, int width, int height) { - definePosition(x, y); - defineSize(width, height); - } - - private long surfaceHandle; -} diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java new file mode 100644 index 000000000..98335f192 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.intel.gdl; + +import javax.media.nativewindow.*; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; + +public class WindowDriver extends jogamp.newt.WindowImpl { + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + static long nextWindowHandle = 1; + + protected void createNativeImpl() { + if(0!=getParentWindowHandle()) { + throw new NativeWindowException("GDL Window does not support window parenting"); + } + final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); + final AbstractGraphicsDevice aDevice = getScreen().getDisplay().getGraphicsDevice(); + + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aDevice, capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, aScreen, VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + + synchronized(WindowDriver.class) { + setWindowHandle(nextWindowHandle++); // just a marker + + surfaceHandle = CreateSurface(aDevice.getHandle(), getScreen().getWidth(), getScreen().getHeight(), getX(), getY(), getWidth(), getHeight()); + if (surfaceHandle == 0) { + throw new NativeWindowException("Error creating window"); + } + } + } + + protected void closeNativeImpl() { + if(0!=surfaceHandle) { + synchronized(WindowDriver.class) { + CloseSurface(getDisplayHandle(), surfaceHandle); + } + surfaceHandle = 0; + ((DisplayDriver)getScreen().getDisplay()).setFocus(null); + } + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + ScreenDriver screen = (ScreenDriver) getScreen(); + + if(width>screen.getWidth()) { + width=screen.getWidth(); + } + if(height>screen.getHeight()) { + height=screen.getHeight(); + } + if((x+width)>screen.getWidth()) { + x=screen.getWidth()-width; + } + if((y+height)>screen.getHeight()) { + y=screen.getHeight()-height; + } + + if(0!=surfaceHandle) { + SetBounds0(surfaceHandle, getScreen().getWidth(), getScreen().getHeight(), x, y, width, height); + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + if(0 != ( FLAG_IS_VISIBLE & flags)) { + ((DisplayDriver)getScreen().getDisplay()).setFocus(this); + } + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + return true; + } + + protected void requestFocusImpl(boolean reparented) { + ((DisplayDriver)getScreen().getDisplay()).setFocus(this); + } + + @Override + public final long getSurfaceHandle() { + return surfaceHandle; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return new Point(x,y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop .. + } + + //---------------------------------------------------------------------- + // Internals only + // + + protected static native boolean initIDs(); + private native long CreateSurface(long displayHandle, int scrn_width, int scrn_height, int x, int y, int width, int height); + private native void CloseSurface(long displayHandle, long surfaceHandle); + private native void SetBounds0(long surfaceHandle, int scrn_width, int scrn_height, int x, int y, int width, int height); + + private void updateBounds(int x, int y, int width, int height) { + definePosition(x, y); + defineSize(width, height); + } + + private long surfaceHandle; +} diff --git a/src/newt/classes/jogamp/newt/driver/kd/Display.java b/src/newt/classes/jogamp/newt/driver/kd/Display.java deleted file mode 100644 index a58ad477a..000000000 --- a/src/newt/classes/jogamp/newt/driver/kd/Display.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.kd; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; - -import jogamp.newt.DisplayImpl; -import jogamp.newt.NEWTJNILibLoader; -import jogamp.opengl.egl.EGL; -import jogamp.opengl.egl.EGLDisplayUtil; - -public class Display extends DisplayImpl { - static { - NEWTJNILibLoader.loadNEWT(); - - if (!Window.initIDs()) { - throw new NativeWindowException("Failed to initialize kd.Window jmethodIDs"); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - - public Display() { - } - - protected void createNativeImpl() { - // FIXME: map name to EGL_*_DISPLAY - aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); - } - - protected void closeNativeImpl() { - aDevice.close(); - } - - protected void dispatchMessagesNative() { - DispatchMessages(); - } - - private native void DispatchMessages(); -} - diff --git a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java new file mode 100644 index 000000000..745be5dae --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.kd; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import jogamp.newt.DisplayImpl; +import jogamp.newt.NEWTJNILibLoader; +import jogamp.opengl.egl.EGL; +import jogamp.opengl.egl.EGLDisplayUtil; + +public class DisplayDriver extends DisplayImpl { + static { + NEWTJNILibLoader.loadNEWT(); + + if (!WindowDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize kd.Window jmethodIDs"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public DisplayDriver() { + } + + protected void createNativeImpl() { + // FIXME: map name to EGL_*_DISPLAY + aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + } + + protected void closeNativeImpl() { + aDevice.close(); + } + + protected void dispatchMessagesNative() { + DispatchMessages(); + } + + private native void DispatchMessages(); +} + diff --git a/src/newt/classes/jogamp/newt/driver/kd/Screen.java b/src/newt/classes/jogamp/newt/driver/kd/Screen.java deleted file mode 100644 index 53f5890b2..000000000 --- a/src/newt/classes/jogamp/newt/driver/kd/Screen.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.kd; - -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -import jogamp.newt.ScreenImpl; - -public class Screen extends ScreenImpl { - static { - Display.initSingleton(); - } - - public Screen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { } - - protected int validateScreenIndex(int idx) { - return 0; // only one screen available - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(cachedWidth); - virtualSize.setHeight(cachedHeight); - } - - protected void sizeChanged(int w, int h) { - cachedWidth = w; - cachedHeight = h; - } - - private static int cachedWidth = 0; - private static int cachedHeight = 0; -} diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java new file mode 100644 index 000000000..656bcf5c9 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.kd; + +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.ScreenImpl; + +public class ScreenDriver extends ScreenImpl { + static { + DisplayDriver.initSingleton(); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { } + + protected int validateScreenIndex(int idx) { + return 0; // only one screen available + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(cachedWidth); + virtualSize.setHeight(cachedHeight); + } + + protected void sizeChanged(int w, int h) { + cachedWidth = w; + cachedHeight = h; + } + + private static int cachedWidth = 0; + private static int cachedHeight = 0; +} diff --git a/src/newt/classes/jogamp/newt/driver/kd/Window.java b/src/newt/classes/jogamp/newt/driver/kd/Window.java deleted file mode 100644 index ce65040c3..000000000 --- a/src/newt/classes/jogamp/newt/driver/kd/Window.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.kd; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.VisualIDHolder.VIDType; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.Point; -import javax.media.opengl.GLCapabilitiesImmutable; - -import jogamp.newt.WindowImpl; -import jogamp.opengl.egl.EGLGraphicsConfiguration; - -public class Window extends WindowImpl { - private static final String WINDOW_CLASS_NAME = "NewtWindow"; - - static { - Display.initSingleton(); - } - - public Window() { - } - - protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { - throw new RuntimeException("Window parenting not supported (yet)"); - } - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - - GLCapabilitiesImmutable eglCaps = (GLCapabilitiesImmutable) cfg.getChosenCapabilities(); - int eglConfigID = eglCaps.getVisualID(VIDType.EGL_CONFIG); - long eglConfig = EGLGraphicsConfiguration.EGLConfigId2EGLConfig(getDisplayHandle(), eglConfigID); - - eglWindowHandle = CreateWindow(getDisplayHandle(), eglConfig); - if (eglWindowHandle == 0) { - throw new NativeWindowException("Error creating egl window: "+cfg+", eglConfigID "+eglConfigID+", eglConfig 0x"+Long.toHexString(eglConfig)); - } - setVisible0(eglWindowHandle, false); - setWindowHandle(RealizeWindow(eglWindowHandle)); - if (0 == getWindowHandle()) { - throw new NativeWindowException("Error native Window Handle is null"); - } - windowHandleClose = eglWindowHandle; - } - - protected void closeNativeImpl() { - if(0!=windowHandleClose) { - CloseWindow(windowHandleClose, windowUserData); - windowUserData=0; - } - } - - protected void requestFocusImpl(boolean reparented) { } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - setVisible0(eglWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - if(0!=eglWindowHandle) { - if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { - final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; - setFullScreen0(eglWindowHandle, fs); - if(fs) { - return true; - } - } - // int _x=(x>=0)?x:this.x; - // int _y=(x>=0)?y:this.y; - width=(width>0)?width:getWidth(); - height=(height>0)?height:getHeight(); - if(width>0 || height>0) { - setSize0(eglWindowHandle, width, height); - } - if(x>=0 || y>=0) { - System.err.println("setPosition n/a in KD"); - } - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return new Point(x,y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop .. - } - - //---------------------------------------------------------------------- - // Internals only - // - - protected static native boolean initIDs(); - private native long CreateWindow(long displayHandle, long eglConfig); - 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; - } - - @Override - protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { - if(isFullscreen()) { - ((Screen)getScreen()).sizeChanged(getWidth(), getHeight()); - } - super.sizeChanged(defer, newWidth, newHeight, force); - } - - private long eglWindowHandle; - private long windowHandleClose; - private long windowUserData; -} diff --git a/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java new file mode 100644 index 000000000..c733a3e94 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.kd; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.VisualIDHolder.VIDType; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; +import javax.media.opengl.GLCapabilitiesImmutable; + +import jogamp.newt.WindowImpl; +import jogamp.opengl.egl.EGLGraphicsConfiguration; + +public class WindowDriver extends WindowImpl { + private static final String WINDOW_CLASS_NAME = "NewtWindow"; + + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + protected void createNativeImpl() { + if(0!=getParentWindowHandle()) { + throw new RuntimeException("Window parenting not supported (yet)"); + } + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + + GLCapabilitiesImmutable eglCaps = (GLCapabilitiesImmutable) cfg.getChosenCapabilities(); + int eglConfigID = eglCaps.getVisualID(VIDType.EGL_CONFIG); + long eglConfig = EGLGraphicsConfiguration.EGLConfigId2EGLConfig(getDisplayHandle(), eglConfigID); + + eglWindowHandle = CreateWindow(getDisplayHandle(), eglConfig); + if (eglWindowHandle == 0) { + throw new NativeWindowException("Error creating egl window: "+cfg+", eglConfigID "+eglConfigID+", eglConfig 0x"+Long.toHexString(eglConfig)); + } + setVisible0(eglWindowHandle, false); + setWindowHandle(RealizeWindow(eglWindowHandle)); + if (0 == getWindowHandle()) { + throw new NativeWindowException("Error native Window Handle is null"); + } + windowHandleClose = eglWindowHandle; + } + + protected void closeNativeImpl() { + if(0!=windowHandleClose) { + CloseWindow(windowHandleClose, windowUserData); + windowUserData=0; + } + } + + protected void requestFocusImpl(boolean reparented) { } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + setVisible0(eglWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + if(0!=eglWindowHandle) { + if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { + final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; + setFullScreen0(eglWindowHandle, fs); + if(fs) { + return true; + } + } + // int _x=(x>=0)?x:this.x; + // int _y=(x>=0)?y:this.y; + width=(width>0)?width:getWidth(); + height=(height>0)?height:getHeight(); + if(width>0 || height>0) { + setSize0(eglWindowHandle, width, height); + } + if(x>=0 || y>=0) { + System.err.println("setPosition n/a in KD"); + } + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return new Point(x,y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop .. + } + + //---------------------------------------------------------------------- + // Internals only + // + + protected static native boolean initIDs(); + private native long CreateWindow(long displayHandle, long eglConfig); + 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; + } + + @Override + protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { + if(isFullscreen()) { + ((ScreenDriver)getScreen()).sizeChanged(getWidth(), getHeight()); + } + super.sizeChanged(defer, newWidth, newHeight, force); + } + + private long eglWindowHandle; + private long windowHandleClose; + private long windowUserData; +} diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java new file mode 100644 index 000000000..1a3f14859 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. 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 jogamp.newt.driver.macosx; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; + +import jogamp.newt.DisplayImpl; +import jogamp.newt.NEWTJNILibLoader; + +public class DisplayDriver extends DisplayImpl { + static { + NEWTJNILibLoader.loadNEWT(); + + if(!initNSApplication0()) { + throw new NativeWindowException("Failed to initialize native Application hook"); + } + if(!WindowDriver.initIDs0()) { + throw new NativeWindowException("Failed to initialize jmethodIDs"); + } + if(DEBUG) { + System.err.println("MacDisplay.init App and IDs OK "+Thread.currentThread().getName()); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + public DisplayDriver() { + } + + protected void dispatchMessagesNative() { + // nop + } + + protected void createNativeImpl() { + aDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); + } + + protected void closeNativeImpl() { } + + public static void runNSApplication() { + runNSApplication0(); + } + public static void stopNSApplication() { + stopNSApplication0(); + } + + private static native boolean initNSApplication0(); + private static native void runNSApplication0(); + private static native void stopNSApplication0(); +} + diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java b/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java deleted file mode 100644 index 18f8d9538..000000000 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java +++ /dev/null @@ -1,87 +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 jogamp.newt.driver.macosx; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; - -import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; - -import jogamp.newt.DisplayImpl; -import jogamp.newt.NEWTJNILibLoader; - -public class MacDisplay extends DisplayImpl { - static { - NEWTJNILibLoader.loadNEWT(); - - if(!initNSApplication0()) { - throw new NativeWindowException("Failed to initialize native Application hook"); - } - if(!MacWindow.initIDs0()) { - throw new NativeWindowException("Failed to initialize jmethodIDs"); - } - if(DEBUG) { - System.err.println("MacDisplay.init App and IDs OK "+Thread.currentThread().getName()); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - public MacDisplay() { - } - - protected void dispatchMessagesNative() { - // nop - } - - protected void createNativeImpl() { - aDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); - } - - protected void closeNativeImpl() { } - - public static void runNSApplication() { - runNSApplication0(); - } - public static void stopNSApplication() { - stopNSApplication0(); - } - - private static native boolean initNSApplication0(); - private static native void runNSApplication0(); - private static native void stopNSApplication0(); -} - diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java index 46625f7a9..d39e0027b 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java @@ -1,3 +1,30 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ package jogamp.newt.driver.macosx; import com.jogamp.newt.event.KeyEvent; diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java b/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java deleted file mode 100644 index b9c725fd4..000000000 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2011 JogAmp Community. 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 jogamp.newt.driver.macosx; - -import java.util.List; - -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.Point; - -import jogamp.newt.ScreenImpl; - -import com.jogamp.common.util.IntObjectHashMap; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; - -public class MacScreen extends ScreenImpl { - - // caching native CGDisplayScreenSize() results, since it's ridiculous slow (~6 ms each call) - private static IntObjectHashMap/**/ scrnIdx2Dimension; - - static { - MacDisplay.initSingleton(); - scrnIdx2Dimension = new IntObjectHashMap(); - scrnIdx2Dimension.setKeyNotFoundValue(null); - } - - public MacScreen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { } - - private static native int getWidthImpl0(int scrn_idx); - private static native int getHeightImpl0(int scrn_idx); - - private int[] getScreenModeIdx(int idx) { - // caching native CGDisplayScreenSize() results, since it's ridiculous slow (~6 ms each call) - DimensionImmutable dim = (DimensionImmutable) scrnIdx2Dimension.get(screen_idx); - if(null == dim) { - int[] res = getScreenSizeMM0(screen_idx); - if(null == res || 0 == res.length) { - return null; - } - dim = new Dimension(res[0], res[1]); - scrnIdx2Dimension.put(screen_idx, dim); - } - - int[] modeProps = getScreenMode0(screen_idx, idx, dim.getWidth(), dim.getHeight()); - if (null == modeProps || 0 == modeProps.length) { - return null; - } - if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) { - throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length); - } - return modeProps; - } - - private int nativeModeIdx; - - protected int[] getScreenModeFirstImpl() { - nativeModeIdx = 0; - return getScreenModeNextImpl(); - } - - protected int[] getScreenModeNextImpl() { - int[] modeProps = getScreenModeIdx(nativeModeIdx); - if (null != modeProps && 0 < modeProps.length) { - nativeModeIdx++; - return modeProps; - } - return null; - } - - protected ScreenMode getCurrentScreenModeImpl() { - int[] modeProps = getScreenModeIdx(-1); - if (null != modeProps && 0 < modeProps.length) { - return ScreenModeUtil.streamIn(modeProps, 0); - } - return null; - } - - protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { - final List screenModes = this.getScreenModesOrig(); - final int screenModeIdx = screenModes.indexOf(screenMode); - if(0>screenModeIdx) { - throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); - } - final int nativeModeIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); - return setScreenMode0(screen_idx, nativeModeIdx); - } - - protected int validateScreenIndex(int idx) { - return idx; - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(getWidthImpl0(screen_idx)); - virtualSize.setHeight(getHeightImpl0(screen_idx)); - } - - private native int[] getScreenSizeMM0(int screen_idx); - private native int[] getScreenMode0(int screen_index, int mode_index, int widthMM, int heightMM); - private native boolean setScreenMode0(int screen_index, int mode_idx); -} diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java deleted file mode 100644 index 27d7a1679..000000000 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.macosx; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeWindow; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.MutableSurface; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.InsetsImmutable; -import javax.media.nativewindow.util.Point; -import javax.media.nativewindow.util.PointImmutable; - -import jogamp.newt.WindowImpl; -import jogamp.newt.driver.DriverClearFocus; -import jogamp.newt.driver.DriverUpdatePosition; - -import com.jogamp.newt.event.KeyEvent; - -public class MacWindow extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { - - static { - MacDisplay.initSingleton(); - } - - public MacWindow() { - } - - @Override - protected void createNativeImpl() { - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true)); - if (0 == getWindowHandle()) { - throw new NativeWindowException("Error creating window"); - } - } - - @Override - protected void closeNativeImpl() { - try { - if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.CloseAction "+Thread.currentThread().getName()); } - final long handle = getWindowHandle(); - setWindowHandle(0); - surfaceHandle = 0; - sscSurfaceHandle = 0; - isOffscreenInstance = false; - if (0 != handle) { - close0(handle); - } - } catch (Throwable t) { - if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Warning: closeNative failed - "+Thread.currentThread().getName(), t); - e.printStackTrace(); - } - } - } - - @Override - protected int lockSurfaceImpl() { - if(!isOffscreenInstance) { - return lockSurface0(getWindowHandle()) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY; - } - return LOCK_SUCCESS; - } - - @Override - protected void unlockSurfaceImpl() { - if(!isOffscreenInstance) { - final long h = getWindowHandle(); - if(0 != h) { - unlockSurface0(h); - } - } - } - - @Override - public final long getSurfaceHandle() { - return 0 != sscSurfaceHandle ? sscSurfaceHandle : surfaceHandle; - } - - public void setSurfaceHandle(long surfaceHandle) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle)); - } - sscSurfaceHandle = surfaceHandle; - if (isNativeValid()) { - if (0 != sscSurfaceHandle) { - orderOut0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); - } /** this is done by recreation! - else if (isVisible()){ - orderFront0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); - } */ - } - } - - @Override - protected void setTitleImpl(final String title) { - setTitle0(getWindowHandle(), title); - } - - protected void requestFocusImpl(boolean force) { - if(!isOffscreenInstance) { - requestFocus0(getWindowHandle(), force); - } else { - focusChanged(false, true); - } - } - - public final void clearFocus() { - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow: clearFocus() - requestFocusParent, isOffscreenInstance "+isOffscreenInstance); - } - if(!isOffscreenInstance) { - resignFocus0(getWindowHandle()); - } else { - focusChanged(false, false); - } - } - - public void updatePosition() { - final Point pS = getTopLevelLocationOnScreen(getX(), getY()); - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow: updatePosition() - isOffscreenInstance "+isOffscreenInstance+", new abs pos: pS "+pS); - } - if( !isOffscreenInstance ) { - setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY()); - } // else no offscreen position - // no native event (fullscreen, some reparenting) - super.positionChanged(true, getX(), getY()); - } - - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - final Point pS = getTopLevelLocationOnScreen(x, y); - isOffscreenInstance = 0 != sscSurfaceHandle || isOffscreenInstance(this, this.getParent()); - - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow reconfig: "+x+"/"+y+" -> "+pS+" - "+width+"x"+height+ - ", offscreenInstance "+isOffscreenInstance+ - ", "+getReconfigureFlagsAsString(null, flags)); - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) { - if ( !isOffscreenInstance ) { - orderOut0(getWindowHandle()); - } - // no native event .. - visibleChanged(true, false); - } - if( 0 == getWindowHandle() && 0 != ( FLAG_IS_VISIBLE & flags) || - 0 != ( FLAG_CHANGE_DECORATION & flags) || - 0 != ( FLAG_CHANGE_PARENTING & flags) || - 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { - createWindow(isOffscreenInstance, 0 != getWindowHandle(), pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); - if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; } - } - if(x>=0 && y>=0) { - if( !isOffscreenInstance ) { - setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY()); - } // else no offscreen position - // no native event (fullscreen, some reparenting) - super.positionChanged(true, x, y); - } - if(width>0 && height>0) { - if( !isOffscreenInstance ) { - setContentSize0(getWindowHandle(), width, height); - } // else offscreen size is realized via recreation - // no native event (fullscreen, some reparenting) - sizeChanged(true, width, height, false); // incl. validation (incl. repositioning) - } - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) { - if( !isOffscreenInstance ) { - orderFront0(getWindowHandle()); - } - // no native event .. - visibleChanged(true, true); - } - if( !isOffscreenInstance ) { - setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags)); - } - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - Point p = new Point(x, y); - // min val is 0 - p.setX(Math.max(p.getX(), 0)); - p.setY(Math.max(p.getY(), 0)); - - final NativeWindow parent = getParent(); - if( null != parent && 0 != parent.getWindowHandle() ) { - p.translate(parent.getLocationOnScreen(null)); - } - return p; - } - - private Point getTopLevelLocationOnScreen(int x, int y) { - final InsetsImmutable _insets = getInsets(); // zero if undecorated - // client position -> top-level window position - x -= _insets.getLeftWidth() ; - y -= _insets.getTopHeight() ; - return getLocationOnScreenImpl(x, y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop - using event driven insetsChange(..) - } - - @Override - protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { - if(getWidth() != newWidth || getHeight() != newHeight) { - final Point p0S = getTopLevelLocationOnScreen(getX(), getY()); - setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), p0S.getX(), p0S.getY()); - } - super.sizeChanged(defer, newWidth, newHeight, force); - } - - @Override - protected void positionChanged(boolean defer, int newX, int newY) { - // passed coordinates are in screen position of the client area - if(getWindowHandle()!=0) { - // screen position -> window position - Point absPos = new Point(newX, newY); - final NativeWindow parent = getParent(); - if(null != parent) { - absPos.translate( parent.getLocationOnScreen(null).scale(-1, -1) ); - } - super.positionChanged(defer, absPos.getX(), absPos.getY()); - } - } - - @Override - protected boolean setPointerVisibleImpl(final boolean pointerVisible) { - if( !isOffscreenInstance ) { - return setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible); - } // else may need offscreen solution ? FIXME - return false; - } - - @Override - protected boolean confinePointerImpl(final boolean confine) { - if( !isOffscreenInstance ) { - return confinePointer0(getWindowHandle(), confine); - } // else may need offscreen solution ? FIXME - return false; - } - - @Override - protected void warpPointerImpl(final int x, final int y) { - if( !isOffscreenInstance ) { - warpPointer0(getWindowHandle(), x, y); - } // else may need offscreen solution ? FIXME - } - - @Override - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - // Note that we send the key char for the key code on this - // platform -- we do not get any useful key codes out of the system - final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar); - final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); - if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); - if(valid) { - // only deliver keyChar on key Typed events, harmonizing platform behavior - keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; - super.sendKeyEvent(eventType, modifiers, keyCode2, keyChar); - } - } - - @Override - public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - // Note that we send the key char for the key code on this - // platform -- we do not get any useful key codes out of the system - final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar); - final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); - if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); - if(valid) { - // only deliver keyChar on key Typed events, harmonizing platform behavior - keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode2, keyChar); - } - } - - private int keyDownModifiers = 0; - private int keyDownCode = 0; - - private boolean validateKeyEvent(int eventType, int modifiers, int keyCode) { - switch(eventType) { - case KeyEvent.EVENT_KEY_PRESSED: - keyDownModifiers = modifiers; - keyDownCode = keyCode; - return true; - case KeyEvent.EVENT_KEY_RELEASED: - return keyDownModifiers == modifiers && keyDownCode == keyCode; - case KeyEvent.EVENT_KEY_TYPED: - final boolean matchKeyDown = keyDownModifiers == modifiers && keyDownCode == keyCode; - keyDownModifiers = 0; - keyDownCode = 0; - return matchKeyDown; - default: - throw new NativeWindowException("Unexpected key event type " + eventType); - } - } - - - //---------------------------------------------------------------------- - // Internals only - // - - private void createWindow(final boolean offscreenInstance, final boolean recreate, - final PointImmutable pS, final int width, final int height, - final boolean fullscreen) { - - if(0!=getWindowHandle() && !recreate) { - return; - } - - try { - if(0!=getWindowHandle()) { - // save the view .. close the window - surfaceHandle = changeContentView0(getParentWindowHandle(), getWindowHandle(), 0); - if(recreate && 0==surfaceHandle) { - throw new NativeWindowException("Internal Error - recreate, window but no view"); - } - close0(getWindowHandle()); - setWindowHandle(0); - } else { - surfaceHandle = 0; - } - setWindowHandle(createWindow0(getParentWindowHandle(), - pS.getX(), pS.getY(), width, height, - (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance), - fullscreen, - ((isUndecorated() || offscreenInstance) ? - NSBorderlessWindowMask : - NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask), - NSBackingStoreBuffered, - getScreen().getIndex(), surfaceHandle)); - if (getWindowHandle() == 0) { - throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this); - } - surfaceHandle = contentView0(getWindowHandle()); - if( offscreenInstance ) { - orderOut0(0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle()); - } else { - setTitle0(getWindowHandle(), getTitle()); - } - } catch (Exception ie) { - ie.printStackTrace(); - } - } - - protected static native boolean initIDs0(); - private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h, - boolean opaque, boolean fullscreen, int windowStyle, - int backingStoreType, - int screen_idx, long view); - private native boolean lockSurface0(long window); - private native void unlockSurface0(long window); - private native void requestFocus0(long window, boolean force); - private native void resignFocus0(long window); - /** in case of a child window, it actually only issues orderBack(..) */ - private native void orderOut0(long window); - private native void orderFront0(long window); - private native void close0(long window); - private native void setTitle0(long window, String title); - private native long contentView0(long window); - private native long changeContentView0(long parentWindowOrViewHandle, long window, long view); - private native void setContentSize0(long window, int w, int h); - private native void setFrameTopLeftPoint0(long parentWindowHandle, long window, int x, int y); - private native void setAlwaysOnTop0(long window, boolean atop); - private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y); - private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); - private static native boolean confinePointer0(long windowHandle, boolean confine); - private static native void warpPointer0(long windowHandle, int x, int y); - - // Window styles - private static final int NSBorderlessWindowMask = 0; - private static final int NSTitledWindowMask = 1 << 0; - private static final int NSClosableWindowMask = 1 << 1; - private static final int NSMiniaturizableWindowMask = 1 << 2; - private static final int NSResizableWindowMask = 1 << 3; - - // Window backing store types - private static final int NSBackingStoreRetained = 0; - private static final int NSBackingStoreNonretained = 1; - private static final int NSBackingStoreBuffered = 2; - - private volatile long surfaceHandle = 0; - private long sscSurfaceHandle = 0; - private boolean isOffscreenInstance = false; - -} diff --git a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java new file mode 100644 index 000000000..24e60ba0a --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2011 JogAmp Community. 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 jogamp.newt.driver.macosx; + +import java.util.List; + +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.ScreenImpl; + +import com.jogamp.common.util.IntObjectHashMap; +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + +public class ScreenDriver extends ScreenImpl { + + // caching native CGDisplayScreenSize() results, since it's ridiculous slow (~6 ms each call) + private static IntObjectHashMap/**/ scrnIdx2Dimension; + + static { + DisplayDriver.initSingleton(); + scrnIdx2Dimension = new IntObjectHashMap(); + scrnIdx2Dimension.setKeyNotFoundValue(null); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { } + + private static native int getWidthImpl0(int scrn_idx); + private static native int getHeightImpl0(int scrn_idx); + + private int[] getScreenModeIdx(int idx) { + // caching native CGDisplayScreenSize() results, since it's ridiculous slow (~6 ms each call) + DimensionImmutable dim = (DimensionImmutable) scrnIdx2Dimension.get(screen_idx); + if(null == dim) { + int[] res = getScreenSizeMM0(screen_idx); + if(null == res || 0 == res.length) { + return null; + } + dim = new Dimension(res[0], res[1]); + scrnIdx2Dimension.put(screen_idx, dim); + } + + int[] modeProps = getScreenMode0(screen_idx, idx, dim.getWidth(), dim.getHeight()); + if (null == modeProps || 0 == modeProps.length) { + return null; + } + if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) { + throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length); + } + return modeProps; + } + + private int nativeModeIdx; + + protected int[] getScreenModeFirstImpl() { + nativeModeIdx = 0; + return getScreenModeNextImpl(); + } + + protected int[] getScreenModeNextImpl() { + int[] modeProps = getScreenModeIdx(nativeModeIdx); + if (null != modeProps && 0 < modeProps.length) { + nativeModeIdx++; + return modeProps; + } + return null; + } + + protected ScreenMode getCurrentScreenModeImpl() { + int[] modeProps = getScreenModeIdx(-1); + if (null != modeProps && 0 < modeProps.length) { + return ScreenModeUtil.streamIn(modeProps, 0); + } + return null; + } + + protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { + final List screenModes = this.getScreenModesOrig(); + final int screenModeIdx = screenModes.indexOf(screenMode); + if(0>screenModeIdx) { + throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); + } + final int nativeModeIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); + return setScreenMode0(screen_idx, nativeModeIdx); + } + + protected int validateScreenIndex(int idx) { + return idx; + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(getWidthImpl0(screen_idx)); + virtualSize.setHeight(getHeightImpl0(screen_idx)); + } + + private native int[] getScreenSizeMM0(int screen_idx); + private native int[] getScreenMode0(int screen_index, int mode_index, int widthMM, int heightMM); + private native boolean setScreenMode0(int screen_index, int mode_idx); +} diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java new file mode 100644 index 000000000..ea48569bf --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -0,0 +1,431 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.macosx; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.MutableSurface; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.PointImmutable; + +import jogamp.newt.WindowImpl; +import jogamp.newt.driver.DriverClearFocus; +import jogamp.newt.driver.DriverUpdatePosition; + +import com.jogamp.newt.event.KeyEvent; + +public class WindowDriver extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { + + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + @Override + protected void createNativeImpl() { + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true)); + if (0 == getWindowHandle()) { + throw new NativeWindowException("Error creating window"); + } + } + + @Override + protected void closeNativeImpl() { + try { + if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.CloseAction "+Thread.currentThread().getName()); } + final long handle = getWindowHandle(); + setWindowHandle(0); + surfaceHandle = 0; + sscSurfaceHandle = 0; + isOffscreenInstance = false; + if (0 != handle) { + close0(handle); + } + } catch (Throwable t) { + if(DEBUG_IMPLEMENTATION) { + Exception e = new Exception("Warning: closeNative failed - "+Thread.currentThread().getName(), t); + e.printStackTrace(); + } + } + } + + @Override + protected int lockSurfaceImpl() { + if(!isOffscreenInstance) { + return lockSurface0(getWindowHandle()) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY; + } + return LOCK_SUCCESS; + } + + @Override + protected void unlockSurfaceImpl() { + if(!isOffscreenInstance) { + final long h = getWindowHandle(); + if(0 != h) { + unlockSurface0(h); + } + } + } + + @Override + public final long getSurfaceHandle() { + return 0 != sscSurfaceHandle ? sscSurfaceHandle : surfaceHandle; + } + + public void setSurfaceHandle(long surfaceHandle) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle)); + } + sscSurfaceHandle = surfaceHandle; + if (isNativeValid()) { + if (0 != sscSurfaceHandle) { + orderOut0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); + } /** this is done by recreation! + else if (isVisible()){ + orderFront0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); + } */ + } + } + + @Override + protected void setTitleImpl(final String title) { + setTitle0(getWindowHandle(), title); + } + + protected void requestFocusImpl(boolean force) { + if(!isOffscreenInstance) { + requestFocus0(getWindowHandle(), force); + } else { + focusChanged(false, true); + } + } + + public final void clearFocus() { + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow: clearFocus() - requestFocusParent, isOffscreenInstance "+isOffscreenInstance); + } + if(!isOffscreenInstance) { + resignFocus0(getWindowHandle()); + } else { + focusChanged(false, false); + } + } + + public void updatePosition() { + final Point pS = getTopLevelLocationOnScreen(getX(), getY()); + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow: updatePosition() - isOffscreenInstance "+isOffscreenInstance+", new abs pos: pS "+pS); + } + if( !isOffscreenInstance ) { + setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY()); + } // else no offscreen position + // no native event (fullscreen, some reparenting) + super.positionChanged(true, getX(), getY()); + } + + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + final Point pS = getTopLevelLocationOnScreen(x, y); + isOffscreenInstance = 0 != sscSurfaceHandle || isOffscreenInstance(this, this.getParent()); + + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow reconfig: "+x+"/"+y+" -> "+pS+" - "+width+"x"+height+ + ", offscreenInstance "+isOffscreenInstance+ + ", "+getReconfigureFlagsAsString(null, flags)); + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) { + if ( !isOffscreenInstance ) { + orderOut0(getWindowHandle()); + } + // no native event .. + visibleChanged(true, false); + } + if( 0 == getWindowHandle() && 0 != ( FLAG_IS_VISIBLE & flags) || + 0 != ( FLAG_CHANGE_DECORATION & flags) || + 0 != ( FLAG_CHANGE_PARENTING & flags) || + 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { + createWindow(isOffscreenInstance, 0 != getWindowHandle(), pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); + if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; } + } + if(x>=0 && y>=0) { + if( !isOffscreenInstance ) { + setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY()); + } // else no offscreen position + // no native event (fullscreen, some reparenting) + super.positionChanged(true, x, y); + } + if(width>0 && height>0) { + if( !isOffscreenInstance ) { + setContentSize0(getWindowHandle(), width, height); + } // else offscreen size is realized via recreation + // no native event (fullscreen, some reparenting) + sizeChanged(true, width, height, false); // incl. validation (incl. repositioning) + } + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) { + if( !isOffscreenInstance ) { + orderFront0(getWindowHandle()); + } + // no native event .. + visibleChanged(true, true); + } + if( !isOffscreenInstance ) { + setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags)); + } + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + Point p = new Point(x, y); + // min val is 0 + p.setX(Math.max(p.getX(), 0)); + p.setY(Math.max(p.getY(), 0)); + + final NativeWindow parent = getParent(); + if( null != parent && 0 != parent.getWindowHandle() ) { + p.translate(parent.getLocationOnScreen(null)); + } + return p; + } + + private Point getTopLevelLocationOnScreen(int x, int y) { + final InsetsImmutable _insets = getInsets(); // zero if undecorated + // client position -> top-level window position + x -= _insets.getLeftWidth() ; + y -= _insets.getTopHeight() ; + return getLocationOnScreenImpl(x, y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop - using event driven insetsChange(..) + } + + @Override + protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { + if(getWidth() != newWidth || getHeight() != newHeight) { + final Point p0S = getTopLevelLocationOnScreen(getX(), getY()); + setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), p0S.getX(), p0S.getY()); + } + super.sizeChanged(defer, newWidth, newHeight, force); + } + + @Override + protected void positionChanged(boolean defer, int newX, int newY) { + // passed coordinates are in screen position of the client area + if(getWindowHandle()!=0) { + // screen position -> window position + Point absPos = new Point(newX, newY); + final NativeWindow parent = getParent(); + if(null != parent) { + absPos.translate( parent.getLocationOnScreen(null).scale(-1, -1) ); + } + super.positionChanged(defer, absPos.getX(), absPos.getY()); + } + } + + @Override + protected boolean setPointerVisibleImpl(final boolean pointerVisible) { + if( !isOffscreenInstance ) { + return setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible); + } // else may need offscreen solution ? FIXME + return false; + } + + @Override + protected boolean confinePointerImpl(final boolean confine) { + if( !isOffscreenInstance ) { + return confinePointer0(getWindowHandle(), confine); + } // else may need offscreen solution ? FIXME + return false; + } + + @Override + protected void warpPointerImpl(final int x, final int y) { + if( !isOffscreenInstance ) { + warpPointer0(getWindowHandle(), x, y); + } // else may need offscreen solution ? FIXME + } + + @Override + public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { + // Note that we send the key char for the key code on this + // platform -- we do not get any useful key codes out of the system + final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar); + final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); + if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); + if(valid) { + // only deliver keyChar on key Typed events, harmonizing platform behavior + keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; + super.sendKeyEvent(eventType, modifiers, keyCode2, keyChar); + } + } + + @Override + public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + // Note that we send the key char for the key code on this + // platform -- we do not get any useful key codes out of the system + final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar); + final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); + if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); + if(valid) { + // only deliver keyChar on key Typed events, harmonizing platform behavior + keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode2, keyChar); + } + } + + private int keyDownModifiers = 0; + private int keyDownCode = 0; + + private boolean validateKeyEvent(int eventType, int modifiers, int keyCode) { + switch(eventType) { + case KeyEvent.EVENT_KEY_PRESSED: + keyDownModifiers = modifiers; + keyDownCode = keyCode; + return true; + case KeyEvent.EVENT_KEY_RELEASED: + return keyDownModifiers == modifiers && keyDownCode == keyCode; + case KeyEvent.EVENT_KEY_TYPED: + final boolean matchKeyDown = keyDownModifiers == modifiers && keyDownCode == keyCode; + keyDownModifiers = 0; + keyDownCode = 0; + return matchKeyDown; + default: + throw new NativeWindowException("Unexpected key event type " + eventType); + } + } + + + //---------------------------------------------------------------------- + // Internals only + // + + private void createWindow(final boolean offscreenInstance, final boolean recreate, + final PointImmutable pS, final int width, final int height, + final boolean fullscreen) { + + if(0!=getWindowHandle() && !recreate) { + return; + } + + try { + if(0!=getWindowHandle()) { + // save the view .. close the window + surfaceHandle = changeContentView0(getParentWindowHandle(), getWindowHandle(), 0); + if(recreate && 0==surfaceHandle) { + throw new NativeWindowException("Internal Error - recreate, window but no view"); + } + close0(getWindowHandle()); + setWindowHandle(0); + } else { + surfaceHandle = 0; + } + setWindowHandle(createWindow0(getParentWindowHandle(), + pS.getX(), pS.getY(), width, height, + (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance), + fullscreen, + ((isUndecorated() || offscreenInstance) ? + NSBorderlessWindowMask : + NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask), + NSBackingStoreBuffered, + getScreen().getIndex(), surfaceHandle)); + if (getWindowHandle() == 0) { + throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this); + } + surfaceHandle = contentView0(getWindowHandle()); + if( offscreenInstance ) { + orderOut0(0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle()); + } else { + setTitle0(getWindowHandle(), getTitle()); + } + } catch (Exception ie) { + ie.printStackTrace(); + } + } + + protected static native boolean initIDs0(); + private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h, + boolean opaque, boolean fullscreen, int windowStyle, + int backingStoreType, + int screen_idx, long view); + private native boolean lockSurface0(long window); + private native void unlockSurface0(long window); + private native void requestFocus0(long window, boolean force); + private native void resignFocus0(long window); + /** in case of a child window, it actually only issues orderBack(..) */ + private native void orderOut0(long window); + private native void orderFront0(long window); + private native void close0(long window); + private native void setTitle0(long window, String title); + private native long contentView0(long window); + private native long changeContentView0(long parentWindowOrViewHandle, long window, long view); + private native void setContentSize0(long window, int w, int h); + private native void setFrameTopLeftPoint0(long parentWindowHandle, long window, int x, int y); + private native void setAlwaysOnTop0(long window, boolean atop); + private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y); + private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); + private static native boolean confinePointer0(long windowHandle, boolean confine); + private static native void warpPointer0(long windowHandle, int x, int y); + + // Window styles + private static final int NSBorderlessWindowMask = 0; + private static final int NSTitledWindowMask = 1 << 0; + private static final int NSClosableWindowMask = 1 << 1; + private static final int NSMiniaturizableWindowMask = 1 << 2; + private static final int NSResizableWindowMask = 1 << 3; + + // Window backing store types + private static final int NSBackingStoreRetained = 0; + private static final int NSBackingStoreNonretained = 1; + private static final int NSBackingStoreBuffered = 2; + + private volatile long surfaceHandle = 0; + private long sscSurfaceHandle = 0; + private boolean isOffscreenInstance = false; + +} diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java new file mode 100644 index 000000000..579ec5be8 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.windows; + +import jogamp.nativewindow.windows.RegisteredClass; +import jogamp.nativewindow.windows.RegisteredClassFactory; +import jogamp.newt.DisplayImpl; +import jogamp.newt.NEWTJNILibLoader; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; + +public class DisplayDriver extends DisplayImpl { + + private static final String newtClassBaseName = "_newt_clazz" ; + private static RegisteredClassFactory sharedClassFactory; + + static { + NEWTJNILibLoader.loadNEWT(); + + if (!WindowDriver.initIDs0()) { + throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs"); + } + sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowDriver.getNewtWndProc0()); + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + private RegisteredClass sharedClass; + + public DisplayDriver() { + } + + protected void createNativeImpl() { + sharedClass = sharedClassFactory.getSharedClass(); + aDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); + } + + protected void closeNativeImpl() { + sharedClassFactory.releaseSharedClass(); + } + + protected void dispatchMessagesNative() { + DispatchMessages0(); + } + + protected long getHInstance() { + return sharedClass.getHandle(); + } + + protected String getWindowClassName() { + return sharedClass.getName(); + } + + //---------------------------------------------------------------------- + // Internals only + // + private static native void DispatchMessages0(); +} + diff --git a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java new file mode 100644 index 000000000..948b29460 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.windows; + +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.ScreenImpl; + +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + +public class ScreenDriver extends ScreenImpl { + + static { + DisplayDriver.initSingleton(); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { + } + + private int[] getScreenModeIdx(int idx) { + int[] modeProps = getScreenMode0(screen_idx, idx); + if (null == modeProps || 0 == modeProps.length) { + return null; + } + if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) { + throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length); + } + return modeProps; + } + + private int nativeModeIdx; + + protected int[] getScreenModeFirstImpl() { + nativeModeIdx = 0; + return getScreenModeNextImpl(); + } + + protected int[] getScreenModeNextImpl() { + int[] modeProps = getScreenModeIdx(nativeModeIdx); + if (null != modeProps && 0 < modeProps.length) { + nativeModeIdx++; + return modeProps; + } + return null; + } + + protected ScreenMode getCurrentScreenModeImpl() { + int[] modeProps = getScreenModeIdx(-1); + if (null != modeProps && 0 < modeProps.length) { + return ScreenModeUtil.streamIn(modeProps, 0); + } + return null; + } + + protected boolean setCurrentScreenModeImpl(ScreenMode sm) { + return setScreenMode0(screen_idx, + sm.getMonitorMode().getSurfaceSize().getResolution().getWidth(), + sm.getMonitorMode().getSurfaceSize().getResolution().getHeight(), + sm.getMonitorMode().getSurfaceSize().getBitsPerPixel(), + sm.getMonitorMode().getRefreshRate(), + sm.getRotation()); + } + + protected int validateScreenIndex(int idx) { + return 0; // big-desktop, only one screen available + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(getOriginX0(screen_idx)); + virtualOrigin.setY(getOriginY0(screen_idx)); + virtualSize.setWidth(getWidthImpl0(screen_idx)); + virtualSize.setHeight(getHeightImpl0(screen_idx)); + } + + // Native calls + private native int getOriginX0(int screen_idx); + private native int getOriginY0(int screen_idx); + private native int getWidthImpl0(int scrn_idx); + private native int getHeightImpl0(int scrn_idx); + + private native int[] getScreenMode0(int screen_index, int mode_index); + private native boolean setScreenMode0(int screen_index, int width, int height, int bits, int freq, int rot); +} diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java new file mode 100644 index 000000000..39ea54575 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.windows; + +import jogamp.nativewindow.windows.GDI; +import jogamp.nativewindow.windows.GDIUtil; +import jogamp.newt.WindowImpl; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.Point; + +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.MouseAdapter; +import com.jogamp.newt.event.MouseEvent; + +public class WindowDriver extends WindowImpl { + + private long hmon; + private long hdc; + private long hdc_old; + private long windowHandleClose; + + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + @Override + protected int lockSurfaceImpl() { + if (0 != hdc) { + throw new InternalError("surface not released"); + } + hdc = GDI.GetDC(getWindowHandle()); + hmon = MonitorFromWindow0(getWindowHandle()); + + // return ( 0 == hdc ) ? LOCK_SURFACE_NOT_READY : ( hdc_old != hdc ) ? LOCK_SURFACE_CHANGED : LOCK_SUCCESS ; + if( 0 == hdc ) { + return LOCK_SURFACE_NOT_READY; + } + if( hdc_old == hdc ) { + return LOCK_SUCCESS; + } + if(DEBUG_IMPLEMENTATION) { + System.err.println("WindowsWindow: surface change "+toHexString(hdc_old)+" -> "+toHexString(hdc)); + // Thread.dumpStack(); + } + return LOCK_SURFACE_CHANGED; + } + + @Override + protected void unlockSurfaceImpl() { + if (0 != hdc) { + GDI.ReleaseDC(getWindowHandle(), hdc); + hdc_old = hdc; + hdc=0; + } + } + + @Override + public final long getSurfaceHandle() { + return hdc; + } + + @Override + public boolean hasDeviceChanged() { + if(0!=getWindowHandle()) { + long _hmon = MonitorFromWindow0(getWindowHandle()); + if (hmon != _hmon) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("Info: Window Device Changed "+Thread.currentThread().getName()+ + ", HMON "+toHexString(hmon)+" -> "+toHexString(_hmon)); + // Thread.dumpStack(); + } + hmon = _hmon; + return true; + } + } + return false; + } + + protected void createNativeImpl() { + final ScreenDriver screen = (ScreenDriver) getScreen(); + final DisplayDriver display = (DisplayDriver) screen.getDisplay(); + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + final int flags = getReconfigureFlags(0, true) & + ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; + setWindowHandle(CreateWindow0(display.getHInstance(), display.getWindowClassName(), display.getWindowClassName(), + getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); + if (getWindowHandle() == 0) { + throw new NativeWindowException("Error creating window"); + } + windowHandleClose = getWindowHandle(); + addMouseListener(new MouseTracker()); + + if(DEBUG_IMPLEMENTATION) { + Exception e = new Exception("Info: Window new window handle "+Thread.currentThread().getName()+ + " (Parent HWND "+toHexString(getParentWindowHandle())+ + ") : HWND "+toHexString(getWindowHandle())+", "+Thread.currentThread()); + e.printStackTrace(); + } + } + + class MouseTracker extends MouseAdapter { + public void mouseEntered(MouseEvent e) { + WindowDriver.trackPointerLeave0(WindowDriver.this.getWindowHandle()); + } + } + + protected void closeNativeImpl() { + if(windowHandleClose != 0) { + if (hdc != 0) { + try { + GDI.ReleaseDC(windowHandleClose, hdc); + } catch (Throwable t) { + if(DEBUG_IMPLEMENTATION) { + Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); + e.printStackTrace(); + } + } + } + try { + GDI.SetParent(windowHandleClose, 0); // detach first, experience hang w/ SWT parent + GDI.DestroyWindow(windowHandleClose); + } catch (Throwable t) { + if(DEBUG_IMPLEMENTATION) { + Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); + e.printStackTrace(); + } + } finally { + windowHandleClose = 0; + } + } + hdc = 0; + hdc_old = 0; + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("WindowsWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ + getReconfigureFlagsAsString(null, flags)); + } + + if(0 == ( FLAG_IS_UNDECORATED & flags)) { + final InsetsImmutable i = getInsets(); + + // client position -> top-level window position + x -= i.getLeftWidth() ; + y -= i.getTopHeight() ; + + if(0 top-level window size + width += i.getTotalWidth(); + height += i.getTotalHeight(); + } + } + reconfigureWindow0( getParentWindowHandle(), getWindowHandle(), x, y, width, height, flags); + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + return true; + } + + protected void requestFocusImpl(boolean force) { + requestFocus0(getWindowHandle(), force); + } + + @Override + protected void setTitleImpl(final String title) { + setTitle0(getWindowHandle(), title); + } + + @Override + protected boolean setPointerVisibleImpl(final boolean pointerVisible) { + final Boolean[] res = new Boolean[] { Boolean.FALSE }; + + this.runOnEDTIfAvail(true, new Runnable() { + public void run() { + res[0] = Boolean.valueOf(setPointerVisible0(getWindowHandle(), pointerVisible)); + } + }); + return res[0].booleanValue(); + } + + @Override + protected boolean confinePointerImpl(final boolean confine) { + final Boolean[] res = new Boolean[] { Boolean.FALSE }; + + this.runOnEDTIfAvail(true, new Runnable() { + public void run() { + final Point p0 = getLocationOnScreenImpl(0, 0); + res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine, + p0.getX(), p0.getY(), p0.getX()+getWidth(), p0.getY()+getHeight())); + } + }); + return res[0].booleanValue(); + } + + @Override + protected void warpPointerImpl(final int x, final int y) { + this.runOnEDTIfAvail(true, new Runnable() { + public void run() { + final Point sPos = getLocationOnScreenImpl(x, y); + warpPointer0(getWindowHandle(), sPos.getX(), sPos.getY()); + } + }); + return; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return GDIUtil.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop - using event driven insetsChange(..) + } + + private final int validateKeyCode(int eventType, int keyCode) { + switch(eventType) { + case KeyEvent.EVENT_KEY_PRESSED: + lastPressedKeyCode = keyCode; + break; + case KeyEvent.EVENT_KEY_TYPED: + if(-1==keyCode) { + keyCode = lastPressedKeyCode; + } + lastPressedKeyCode = -1; + break; + } + return keyCode; + } + private int lastPressedKeyCode = 0; + + @Override + public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { + // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform + keyCode = validateKeyCode(eventType, keyCode); + super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + } + + @Override + public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform + keyCode = validateKeyCode(eventType, keyCode); + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); + } + + //---------------------------------------------------------------------- + // Internals only + // + protected static native boolean initIDs0(); + protected static native long getNewtWndProc0(); + + private native long CreateWindow0(long hInstance, String wndClassName, String wndName, + long parentWindowHandle, + int x, int y, int width, int height, boolean autoPosition, int flags); + private native long MonitorFromWindow0(long windowHandle); + private native void reconfigureWindow0(long parentWindowHandle, long windowHandle, + int x, int y, int width, int height, int flags); + private static native void setTitle0(long windowHandle, String title); + private native void requestFocus0(long windowHandle, boolean force); + + private static native boolean setPointerVisible0(long windowHandle, boolean visible); + private static native boolean confinePointer0(long windowHandle, boolean grab, int l, int t, int r, int b); + private static native void warpPointer0(long windowHandle, int x, int y); + private static native void trackPointerLeave0(long windowHandle); +} diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsDisplay.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsDisplay.java deleted file mode 100644 index 225b115e4..000000000 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsDisplay.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.windows; - -import jogamp.nativewindow.windows.RegisteredClass; -import jogamp.nativewindow.windows.RegisteredClassFactory; -import jogamp.newt.DisplayImpl; -import jogamp.newt.NEWTJNILibLoader; -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; - -import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; - -public class WindowsDisplay extends DisplayImpl { - - private static final String newtClassBaseName = "_newt_clazz" ; - private static RegisteredClassFactory sharedClassFactory; - - static { - NEWTJNILibLoader.loadNEWT(); - - if (!WindowsWindow.initIDs0()) { - throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs"); - } - sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowsWindow.getNewtWndProc0()); - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - private RegisteredClass sharedClass; - - public WindowsDisplay() { - } - - protected void createNativeImpl() { - sharedClass = sharedClassFactory.getSharedClass(); - aDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); - } - - protected void closeNativeImpl() { - sharedClassFactory.releaseSharedClass(); - } - - protected void dispatchMessagesNative() { - DispatchMessages0(); - } - - protected long getHInstance() { - return sharedClass.getHandle(); - } - - protected String getWindowClassName() { - return sharedClass.getName(); - } - - //---------------------------------------------------------------------- - // Internals only - // - private static native void DispatchMessages0(); -} - diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java deleted file mode 100644 index f8bce9da3..000000000 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.windows; - -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -import jogamp.newt.ScreenImpl; - -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; - -public class WindowsScreen extends ScreenImpl { - - static { - WindowsDisplay.initSingleton(); - } - - public WindowsScreen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { - } - - private int[] getScreenModeIdx(int idx) { - int[] modeProps = getScreenMode0(screen_idx, idx); - if (null == modeProps || 0 == modeProps.length) { - return null; - } - if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) { - throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length); - } - return modeProps; - } - - private int nativeModeIdx; - - protected int[] getScreenModeFirstImpl() { - nativeModeIdx = 0; - return getScreenModeNextImpl(); - } - - protected int[] getScreenModeNextImpl() { - int[] modeProps = getScreenModeIdx(nativeModeIdx); - if (null != modeProps && 0 < modeProps.length) { - nativeModeIdx++; - return modeProps; - } - return null; - } - - protected ScreenMode getCurrentScreenModeImpl() { - int[] modeProps = getScreenModeIdx(-1); - if (null != modeProps && 0 < modeProps.length) { - return ScreenModeUtil.streamIn(modeProps, 0); - } - return null; - } - - protected boolean setCurrentScreenModeImpl(ScreenMode sm) { - return setScreenMode0(screen_idx, - sm.getMonitorMode().getSurfaceSize().getResolution().getWidth(), - sm.getMonitorMode().getSurfaceSize().getResolution().getHeight(), - sm.getMonitorMode().getSurfaceSize().getBitsPerPixel(), - sm.getMonitorMode().getRefreshRate(), - sm.getRotation()); - } - - protected int validateScreenIndex(int idx) { - return 0; // big-desktop, only one screen available - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(getOriginX0(screen_idx)); - virtualOrigin.setY(getOriginY0(screen_idx)); - virtualSize.setWidth(getWidthImpl0(screen_idx)); - virtualSize.setHeight(getHeightImpl0(screen_idx)); - } - - // Native calls - private native int getOriginX0(int screen_idx); - private native int getOriginY0(int screen_idx); - private native int getWidthImpl0(int scrn_idx); - private native int getHeightImpl0(int scrn_idx); - - private native int[] getScreenMode0(int screen_index, int mode_index); - private native boolean setScreenMode0(int screen_index, int width, int height, int bits, int freq, int rot); -} diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java deleted file mode 100644 index 6a8c81f3d..000000000 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.windows; - -import jogamp.nativewindow.windows.GDI; -import jogamp.nativewindow.windows.GDIUtil; -import jogamp.newt.WindowImpl; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.InsetsImmutable; -import javax.media.nativewindow.util.Point; - -import com.jogamp.newt.event.KeyEvent; -import com.jogamp.newt.event.MouseAdapter; -import com.jogamp.newt.event.MouseEvent; - -public class WindowsWindow extends WindowImpl { - - private long hmon; - private long hdc; - private long hdc_old; - private long windowHandleClose; - - static { - WindowsDisplay.initSingleton(); - } - - public WindowsWindow() { - } - - @Override - protected int lockSurfaceImpl() { - if (0 != hdc) { - throw new InternalError("surface not released"); - } - hdc = GDI.GetDC(getWindowHandle()); - hmon = MonitorFromWindow0(getWindowHandle()); - - // return ( 0 == hdc ) ? LOCK_SURFACE_NOT_READY : ( hdc_old != hdc ) ? LOCK_SURFACE_CHANGED : LOCK_SUCCESS ; - if( 0 == hdc ) { - return LOCK_SURFACE_NOT_READY; - } - if( hdc_old == hdc ) { - return LOCK_SUCCESS; - } - if(DEBUG_IMPLEMENTATION) { - System.err.println("WindowsWindow: surface change "+toHexString(hdc_old)+" -> "+toHexString(hdc)); - // Thread.dumpStack(); - } - return LOCK_SURFACE_CHANGED; - } - - @Override - protected void unlockSurfaceImpl() { - if (0 != hdc) { - GDI.ReleaseDC(getWindowHandle(), hdc); - hdc_old = hdc; - hdc=0; - } - } - - @Override - public final long getSurfaceHandle() { - return hdc; - } - - @Override - public boolean hasDeviceChanged() { - if(0!=getWindowHandle()) { - long _hmon = MonitorFromWindow0(getWindowHandle()); - if (hmon != _hmon) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("Info: Window Device Changed "+Thread.currentThread().getName()+ - ", HMON "+toHexString(hmon)+" -> "+toHexString(_hmon)); - // Thread.dumpStack(); - } - hmon = _hmon; - return true; - } - } - return false; - } - - protected void createNativeImpl() { - final WindowsScreen screen = (WindowsScreen) getScreen(); - final WindowsDisplay display = (WindowsDisplay) screen.getDisplay(); - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - final int flags = getReconfigureFlags(0, true) & - ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; - setWindowHandle(CreateWindow0(display.getHInstance(), display.getWindowClassName(), display.getWindowClassName(), - getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); - if (getWindowHandle() == 0) { - throw new NativeWindowException("Error creating window"); - } - windowHandleClose = getWindowHandle(); - addMouseListener(new MouseTracker()); - - if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Info: Window new window handle "+Thread.currentThread().getName()+ - " (Parent HWND "+toHexString(getParentWindowHandle())+ - ") : HWND "+toHexString(getWindowHandle())+", "+Thread.currentThread()); - e.printStackTrace(); - } - } - - class MouseTracker extends MouseAdapter { - public void mouseEntered(MouseEvent e) { - WindowsWindow.trackPointerLeave0(WindowsWindow.this.getWindowHandle()); - } - } - - protected void closeNativeImpl() { - if(windowHandleClose != 0) { - if (hdc != 0) { - try { - GDI.ReleaseDC(windowHandleClose, hdc); - } catch (Throwable t) { - if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); - e.printStackTrace(); - } - } - } - try { - GDI.SetParent(windowHandleClose, 0); // detach first, experience hang w/ SWT parent - GDI.DestroyWindow(windowHandleClose); - } catch (Throwable t) { - if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); - e.printStackTrace(); - } - } finally { - windowHandleClose = 0; - } - } - hdc = 0; - hdc_old = 0; - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("WindowsWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ - getReconfigureFlagsAsString(null, flags)); - } - - if(0 == ( FLAG_IS_UNDECORATED & flags)) { - final InsetsImmutable i = getInsets(); - - // client position -> top-level window position - x -= i.getLeftWidth() ; - y -= i.getTopHeight() ; - - if(0 top-level window size - width += i.getTotalWidth(); - height += i.getTotalHeight(); - } - } - reconfigureWindow0( getParentWindowHandle(), getWindowHandle(), x, y, width, height, flags); - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - return true; - } - - protected void requestFocusImpl(boolean force) { - requestFocus0(getWindowHandle(), force); - } - - @Override - protected void setTitleImpl(final String title) { - setTitle0(getWindowHandle(), title); - } - - @Override - protected boolean setPointerVisibleImpl(final boolean pointerVisible) { - final Boolean[] res = new Boolean[] { Boolean.FALSE }; - - this.runOnEDTIfAvail(true, new Runnable() { - public void run() { - res[0] = Boolean.valueOf(setPointerVisible0(getWindowHandle(), pointerVisible)); - } - }); - return res[0].booleanValue(); - } - - @Override - protected boolean confinePointerImpl(final boolean confine) { - final Boolean[] res = new Boolean[] { Boolean.FALSE }; - - this.runOnEDTIfAvail(true, new Runnable() { - public void run() { - final Point p0 = getLocationOnScreenImpl(0, 0); - res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine, - p0.getX(), p0.getY(), p0.getX()+getWidth(), p0.getY()+getHeight())); - } - }); - return res[0].booleanValue(); - } - - @Override - protected void warpPointerImpl(final int x, final int y) { - this.runOnEDTIfAvail(true, new Runnable() { - public void run() { - final Point sPos = getLocationOnScreenImpl(x, y); - warpPointer0(getWindowHandle(), sPos.getX(), sPos.getY()); - } - }); - return; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return GDIUtil.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop - using event driven insetsChange(..) - } - - private final int validateKeyCode(int eventType, int keyCode) { - switch(eventType) { - case KeyEvent.EVENT_KEY_PRESSED: - lastPressedKeyCode = keyCode; - break; - case KeyEvent.EVENT_KEY_TYPED: - if(-1==keyCode) { - keyCode = lastPressedKeyCode; - } - lastPressedKeyCode = -1; - break; - } - return keyCode; - } - private int lastPressedKeyCode = 0; - - @Override - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform - keyCode = validateKeyCode(eventType, keyCode); - super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); - } - - @Override - public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform - keyCode = validateKeyCode(eventType, keyCode); - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); - } - - //---------------------------------------------------------------------- - // Internals only - // - protected static native boolean initIDs0(); - protected static native long getNewtWndProc0(); - - private native long CreateWindow0(long hInstance, String wndClassName, String wndName, - long parentWindowHandle, - int x, int y, int width, int height, boolean autoPosition, int flags); - private native long MonitorFromWindow0(long windowHandle); - private native void reconfigureWindow0(long parentWindowHandle, long windowHandle, - int x, int y, int width, int height, int flags); - private static native void setTitle0(long windowHandle, String title); - private native void requestFocus0(long windowHandle, boolean force); - - private static native boolean setPointerVisible0(long windowHandle, boolean visible); - private static native boolean confinePointer0(long windowHandle, boolean grab, int l, int t, int r, int b); - private static native void warpPointer0(long windowHandle, int x, int y); - private static native void trackPointerLeave0(long windowHandle); -} diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java new file mode 100644 index 000000000..714324d63 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.x11; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; + +import com.jogamp.nativewindow.x11.X11GraphicsDevice; + +import jogamp.nativewindow.x11.X11Util; +import jogamp.newt.DisplayImpl; +import jogamp.newt.NEWTJNILibLoader; + +public class DisplayDriver extends DisplayImpl { + + static { + NEWTJNILibLoader.loadNEWT(); + + if ( !initIDs0(X11Util.XERROR_STACKDUMP) ) { + throw new NativeWindowException("Failed to initialize X11Display jmethodIDs"); + } + + if (!WindowDriver.initIDs0()) { + throw new NativeWindowException("Failed to initialize X11Window jmethodIDs"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public DisplayDriver() { + } + + public String validateDisplayName(String name, long handle) { + return X11Util.validateDisplayName(name, handle); + } + + /** + * {@inheritDoc} + * + * We use a private non-shared X11 Display instance for EDT window operations and one for exposed animation, eg. OpenGL. + *

+ * In case {@link X11Util#HAS_XLOCKDISPLAY_BUG} and {@link X11Util#XINITTHREADS_ALWAYS_ENABLED}, + * we use null locking. Even though this seems not to be rational, it gives most stable results on all platforms. + *

+ *

+ * Otherwise we use basic locking via the constructor {@link X11GraphicsDevice#X11GraphicsDevice(long, int, boolean)}, + * since it is possible to share this device via {@link com.jogamp.newt.NewtFactory#createDisplay(String, boolean)}. + *

+ */ + @SuppressWarnings("unused") + protected void createNativeImpl() { + long handle = X11Util.openDisplay(name); + if( 0 == handle ) { + throw new RuntimeException("Error creating display(Win): "+name); + } + if(USE_SEPARATE_DISPLAY_FOR_EDT) { + edtDisplayHandle = X11Util.openDisplay(name); + if( 0 == edtDisplayHandle ) { + X11Util.closeDisplay(handle); + throw new RuntimeException("Error creating display(EDT): "+name); + } + } else { + edtDisplayHandle = handle; + } + try { + CompleteDisplay0(edtDisplayHandle); + } catch(RuntimeException e) { + closeNativeImpl(); + throw e; + } + + // see API doc above! + if(X11Util.XINITTHREADS_ALWAYS_ENABLED && X11Util.HAS_XLOCKDISPLAY_BUG) { + aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock(), false); + } else { + aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, false); + } + } + + protected void closeNativeImpl() { + DisplayRelease0(edtDisplayHandle, javaObjectAtom, windowDeleteAtom); + javaObjectAtom = 0; + windowDeleteAtom = 0; + // closing using ATI driver bug 'same order' + final long handle = getHandle(); + X11Util.closeDisplay(handle); + if(handle != edtDisplayHandle) { + X11Util.closeDisplay(edtDisplayHandle); + } + edtDisplayHandle = 0; + } + + protected void dispatchMessagesNative() { + if(0 != edtDisplayHandle) { + DispatchMessages0(edtDisplayHandle, javaObjectAtom, windowDeleteAtom); + } + } + + protected long getEDTHandle() { return edtDisplayHandle; } + protected long getJavaObjectAtom() { return javaObjectAtom; } + protected long getWindowDeleteAtom() { return windowDeleteAtom; } + + //---------------------------------------------------------------------- + // Internals only + // + private static native boolean initIDs0(boolean debug); + + private native void CompleteDisplay0(long handle); + + private void displayCompleted(long javaObjectAtom, long windowDeleteAtom) { + this.javaObjectAtom=javaObjectAtom; + this.windowDeleteAtom=windowDeleteAtom; + } + private native void DisplayRelease0(long handle, long javaObjectAtom, long windowDeleteAtom); + + private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom); + + /** + * 2011/06/14 libX11 1.4.2 and libxcb 1.7 bug 20708 - Multithreading Issues w/ OpenGL, .. + * https://bugs.freedesktop.org/show_bug.cgi?id=20708 + * https://jogamp.org/bugzilla/show_bug.cgi?id=502 + * Affects: Ubuntu 11.04, OpenSuSE 11, .. + * Workaround: Using a separate X11 Display connection for event dispatching (EDT) + */ + private final boolean USE_SEPARATE_DISPLAY_FOR_EDT = true; + + private long edtDisplayHandle; + + /** X11 Window delete atom marker used on EDT */ + private long windowDeleteAtom; + + /** X11 Window java object property used on EDT */ + private long javaObjectAtom; +} + diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java new file mode 100644 index 000000000..10f6b84da --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -0,0 +1,357 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.x11; + +import java.util.List; + +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import jogamp.nativewindow.x11.X11Util; +import jogamp.newt.DisplayImpl; +import jogamp.newt.DisplayImpl.DisplayRunnable; +import jogamp.newt.ScreenImpl; + +import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + +public class ScreenDriver extends ScreenImpl { + + static { + DisplayDriver.initSingleton(); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + // validate screen index + Long handle = display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Long run(long dpy) { + return new Long(GetScreen0(dpy, screen_idx)); + } } ); + if (handle.longValue() == 0) { + throw new RuntimeException("Error creating screen: " + screen_idx); + } + aScreen = new X11GraphicsScreen((X11GraphicsDevice) getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { + } + + private int[] nrotations; + private int nrotation_index; + private int nres_number; + private int nres_index; + private int[] nrates; + private int nrate_index; + private int nmode_number; + + protected int[] getScreenModeFirstImpl() { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public int[] run(long dpy) { + // initialize iterators and static data + nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); + if(null==nrotations || 0==nrotations.length) { + return null; + } + nrotation_index = 0; + + nres_number = getNumScreenModeResolutions0(dpy, screen_idx); + if(0==nres_number) { + return null; + } + nres_index = 0; + + nrates = getScreenModeRates0(dpy, screen_idx, nres_index); + if(null==nrates || 0==nrates.length) { + return null; + } + nrate_index = 0; + + nmode_number = 0; + + return getScreenModeNextImpl(); + } } ); + } + + protected int[] getScreenModeNextImpl() { + // assemble: w x h x bpp x f x r + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public int[] run(long dpy) { + /** + System.err.println("******** mode: "+nmode_number); + System.err.println("rot "+nrotation_index); + System.err.println("rate "+nrate_index); + System.err.println("res "+nres_index); */ + + int[] res = getScreenModeResolution0(dpy, screen_idx, nres_index); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); + } + int rate = nrates[nrate_index]; + if(0>=rate) { + rate = default_sm_rate; + if(DEBUG) { + System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+default_sm_rate); + } + } + int rotation = nrotations[nrotation_index]; + + int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode + props[i++] = 0; // set later for verification of iterator + props[i++] = res[0]; // width + props[i++] = res[1]; // height + props[i++] = default_sm_bpp; // FIXME + props[i++] = res[2]; // widthmm + props[i++] = res[3]; // heightmm + props[i++] = rate; // rate + props[i++] = rotation; + props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element + + nmode_number++; + + // iteration: r -> f -> bpp -> [w x h] + nrotation_index++; + if(nrotation_index == nrotations.length) { + nrotation_index=0; + nrate_index++; + if(null == nrates || nrate_index == nrates.length){ + nres_index++; + if(nres_index == nres_number) { + // done + nrates=null; + nrotations=null; + return null; + } + + nrates = getScreenModeRates0(dpy, screen_idx, nres_index); + if(null==nrates || 0==nrates.length) { + return null; + } + nrate_index = 0; + } + } + + return props; + } } ); + } + + protected ScreenMode getCurrentScreenModeImpl() { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public ScreenMode run(long dpy) { + long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + if(0 == screenConfigHandle) { + return null; + } + int[] res; + int rate, rot; + try { + int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + if(0==resNumber) { + return null; + } + + int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); + if(0>resIdx) { + return null; + } + if(resIdx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); + } + res = getScreenModeResolution0(dpy, screen_idx, resIdx); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); + } + rate = getCurrentScreenRate0(screenConfigHandle); + if(0>rate) { + return null; + } + rot = getCurrentScreenRotation0(screenConfigHandle); + if(0>rot) { + return null; + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; + int i = 0; + props[i++] = 0; // set later for verification of iterator + props[i++] = res[0]; // width + props[i++] = res[1]; // height + props[i++] = default_sm_bpp; // FIXME + props[i++] = res[2]; // widthmm + props[i++] = res[3]; // heightmm + props[i++] = rate; // rate + props[i++] = rot; + props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count + return ScreenModeUtil.streamIn(props, 0); + } } ); + } + + protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { + final List screenModes = this.getScreenModesOrig(); + final int screenModeIdx = screenModes.indexOf(screenMode); + if(0>screenModeIdx) { + throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); + } + final long t0 = System.currentTimeMillis(); + boolean done = runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Boolean run(long dpy) { + boolean done = false; + long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + if(0 == screenConfigHandle) { + return Boolean.valueOf(done); + } + try { + int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); + if(0>resIdx || resIdx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! 0 < "+resIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); + } + + final int f = screenMode.getMonitorMode().getRefreshRate(); + final int r = screenMode.getRotation(); + + if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resIdx, f, r) ) { + while(!done && System.currentTimeMillis()-t0 < SCREEN_MODE_CHANGE_TIMEOUT) { + done = setCurrentScreenModePollEnd0(dpy, screen_idx, resIdx, f, r); + if(!done) { + try { Thread.sleep(10); } catch (InterruptedException e) { } + } + } + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + return Boolean.valueOf(done); + } + }).booleanValue(); + + if(DEBUG || !done) { + System.err.println("X11Screen.setCurrentScreenModeImpl: TO ("+SCREEN_MODE_CHANGE_TIMEOUT+") reached: "+ + (System.currentTimeMillis()-t0)+"ms; Current: "+getCurrentScreenMode()+"; Desired: "+screenMode); + } + return done; + } + + private class XineramaEnabledQuery implements DisplayImpl.DisplayRunnable { + public Boolean run(long dpy) { + return new Boolean(X11Util.XineramaIsEnabled(dpy)); + } + } + private XineramaEnabledQuery xineramaEnabledQuery = new XineramaEnabledQuery(); + + protected int validateScreenIndex(final int idx) { + if(getDisplay().isNativeValid()) { + return runWithLockedDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx; + } else { + return runWithTempDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx; + } + } + + protected void getVirtualScreenOriginAndSize(final Point virtualOrigin, final Dimension virtualSize) { + display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(getWidth0(dpy, screen_idx)); + virtualSize.setHeight(getHeight0(dpy, screen_idx)); + return null; + } } ); + } + + //---------------------------------------------------------------------- + // Internals only + // + private final T runWithLockedDisplayHandle(DisplayRunnable action) { + return display.runWithLockedDisplayHandle(action); + // return runWithTempDisplayHandle(action); + // return runWithoutLock(action); + } + + private final T runWithTempDisplayHandle(DisplayRunnable action) { + final long displayHandle = X11Util.openDisplay(display.getName()); + if(0 == displayHandle) { + throw new RuntimeException("null device"); + } + T res; + try { + res = action.run(displayHandle); + } finally { + X11Util.closeDisplay(displayHandle); + } + return res; + } + private final T runWithoutLock(DisplayRunnable action) { + return action.run(display.getHandle()); + } + + private static native long GetScreen0(long dpy, int scrn_idx); + + private static native int getWidth0(long display, int scrn_idx); + + private static native int getHeight0(long display, int scrn_idx); + + /** @return int[] { rot1, .. } */ + private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); + + private static native int getNumScreenModeResolutions0(long display, int screen_index); + + /** @return int[] { width, height, widthmm, heightmm } */ + private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); + + private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); + + private static native long getScreenConfiguration0(long display, int screen_index); + private static native void freeScreenConfiguration0(long screenConfiguration); + + private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); + private static native int getCurrentScreenRate0(long screenConfiguration); + private static native int getCurrentScreenRotation0(long screenConfiguration); + + /** needs own Display connection for XRANDR event handling */ + private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); + private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); +} diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java new file mode 100644 index 000000000..97d1ae3db --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.x11; + +import jogamp.nativewindow.x11.X11Lib; +import jogamp.newt.DisplayImpl; +import jogamp.newt.DisplayImpl.DisplayRunnable; +import jogamp.newt.WindowImpl; +import javax.media.nativewindow.*; +import javax.media.nativewindow.VisualIDHolder.VIDType; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.Point; + +import com.jogamp.newt.event.MouseEvent; + +public class WindowDriver extends WindowImpl { + private static final String WINDOW_CLASS_NAME = "NewtWindow"; + private static final int X11_WHEEL_ONE_UP_BUTTON = 4; + private static final int X11_WHEEL_ONE_DOWN_BUTTON = 5; + private static final int X11_WHEEL_TWO_UP_BUTTON = 6; + private static final int X11_WHEEL_TWO_DOWN_BUTTON = 7; + + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + protected void createNativeImpl() { + final ScreenDriver screen = (ScreenDriver) getScreen(); + final DisplayDriver display = (DisplayDriver) screen.getDisplay(); + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested); + final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window.createNativeImpl() factory: "+factory+", chosen config: "+cfg); + } + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + final int visualID = cfg.getVisualID(VIDType.NATIVE); + if(VisualIDHolder.VID_UNDEFINED == visualID) { + throw new NativeWindowException("Chosen Configuration w/o native visual ID: "+cfg); + } + setGraphicsConfiguration(cfg); + final int flags = getReconfigureFlags(0, true) & + ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; + setWindowHandle(CreateWindow0(getParentWindowHandle(), + display.getEDTHandle(), screen.getIndex(), visualID, + display.getJavaObjectAtom(), display.getWindowDeleteAtom(), + getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); + windowHandleClose = getWindowHandle(); + if (0 == windowHandleClose) { + throw new NativeWindowException("Error creating window"); + } + } + + protected void closeNativeImpl() { + if(0!=windowHandleClose && null!=getScreen() ) { + DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + try { + CloseWindow0(display.getEDTHandle(), windowHandleClose, + display.getJavaObjectAtom(), display.getWindowDeleteAtom()); + } catch (Throwable t) { + if(DEBUG_IMPLEMENTATION) { + Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); + e.printStackTrace(); + } + } finally { + windowHandleClose = 0; + } + } + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ + getReconfigureFlagsAsString(null, flags)); + } + if(0 == ( FLAG_IS_UNDECORATED & flags)) { + final InsetsImmutable i = getInsets(); + + // client position -> top-level window position + x -= i.getLeftWidth() ; + y -= i.getTopHeight() ; + } + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + reconfigureWindow0( getDisplayEDTHandle(), getScreenIndex(), + getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), + x, y, width, height, flags); + + return true; + } + + protected void reparentNotify(long newParentWindowHandle) { + if(DEBUG_IMPLEMENTATION) { + final long p0 = getParentWindowHandle(); + System.err.println("Window.reparentNotify ("+getThreadName()+"): "+toHexString(p0)+" -> "+toHexString(newParentWindowHandle)); + } + } + + protected void requestFocusImpl(boolean force) { + requestFocus0(getDisplayEDTHandle(), getWindowHandle(), force); + } + + @Override + protected void setTitleImpl(final String title) { + runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + setTitle0(dpy, getWindowHandle(), title); + return null; + } + }); + } + + @Override + protected boolean setPointerVisibleImpl(final boolean pointerVisible) { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Boolean run(long dpy) { + return Boolean.valueOf(setPointerVisible0(getDisplayEDTHandle(), getWindowHandle(), pointerVisible)); + } + }).booleanValue(); + } + + @Override + protected boolean confinePointerImpl(final boolean confine) { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Boolean run(long dpy) { + return Boolean.valueOf(confinePointer0(getDisplayEDTHandle(), getWindowHandle(), confine)); + } + }).booleanValue(); + } + + @Override + protected void warpPointerImpl(final int x, final int y) { + runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + warpPointer0(getDisplayEDTHandle(), getWindowHandle(), x, y); + return null; + } + }); + } + + protected Point getLocationOnScreenImpl(final int x, final int y) { + // X11Util.GetRelativeLocation: locks display already ! + return X11Lib.GetRelativeLocation( getScreen().getDisplay().getHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop - using event driven insetsChange(..) + } + + protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, + int x, int y, int button, int rotation) { + switch(eventType) { + case MouseEvent.EVENT_MOUSE_PRESSED: + switch(button) { + case X11_WHEEL_ONE_UP_BUTTON: + case X11_WHEEL_ONE_DOWN_BUTTON: + case X11_WHEEL_TWO_UP_BUTTON: + case X11_WHEEL_TWO_DOWN_BUTTON: + // ignore wheel pressed ! + return; + } + break; + case MouseEvent.EVENT_MOUSE_RELEASED: + switch(button) { + case X11_WHEEL_ONE_UP_BUTTON: + eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + button = 1; + rotation = 1; + break; + case X11_WHEEL_ONE_DOWN_BUTTON: + eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + button = 1; + rotation = -1; + break; + case X11_WHEEL_TWO_UP_BUTTON: + eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + button = 2; + rotation = 1; + break; + case X11_WHEEL_TWO_DOWN_BUTTON: + eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + button = 2; + rotation = -1; + break; + } + break; + } + super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotation); + } + + + //---------------------------------------------------------------------- + // Internals only + // + + private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI + private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI + + private final long getDisplayEDTHandle() { + return ((DisplayDriver) getScreen().getDisplay()).getEDTHandle(); + } + private final T runWithLockedDisplayHandle(DisplayRunnable action) { + return ((DisplayImpl) getScreen().getDisplay()).runWithLockedDisplayHandle(action); + // return runWithTempDisplayHandle(action); + } + + protected static native boolean initIDs0(); + + private native long CreateWindow0(long parentWindowHandle, long display, int screen_index, + int visualID, long javaObjectAtom, long windowDeleteAtom, + int x, int y, int width, int height, boolean autoPosition, int flags); + private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom); + private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle, + long windowDeleteAtom, int x, int y, int width, int height, int flags); + private native void requestFocus0(long display, long windowHandle, boolean force); + + private static native void setTitle0(long display, long windowHandle, String title); + private static native long getParentWindow0(long display, long windowHandle); + private static native boolean setPointerVisible0(long display, long windowHandle, boolean visible); + private static native boolean confinePointer0(long display, long windowHandle, boolean grab); + private static native void warpPointer0(long display, long windowHandle, int x, int y); + + private long windowHandleClose; +} diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Display.java b/src/newt/classes/jogamp/newt/driver/x11/X11Display.java deleted file mode 100644 index 8243fcf9d..000000000 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Display.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.x11; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; - -import com.jogamp.nativewindow.x11.X11GraphicsDevice; - -import jogamp.nativewindow.x11.X11Util; -import jogamp.newt.DisplayImpl; -import jogamp.newt.NEWTJNILibLoader; - -public class X11Display extends DisplayImpl { - - static { - NEWTJNILibLoader.loadNEWT(); - - if ( !initIDs0(X11Util.XERROR_STACKDUMP) ) { - throw new NativeWindowException("Failed to initialize X11Display jmethodIDs"); - } - - if (!X11Window.initIDs0()) { - throw new NativeWindowException("Failed to initialize X11Window jmethodIDs"); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - - public X11Display() { - } - - public String validateDisplayName(String name, long handle) { - return X11Util.validateDisplayName(name, handle); - } - - /** - * {@inheritDoc} - * - * We use a private non-shared X11 Display instance for EDT window operations and one for exposed animation, eg. OpenGL. - *

- * In case {@link X11Util#HAS_XLOCKDISPLAY_BUG} and {@link X11Util#XINITTHREADS_ALWAYS_ENABLED}, - * we use null locking. Even though this seems not to be rational, it gives most stable results on all platforms. - *

- *

- * Otherwise we use basic locking via the constructor {@link X11GraphicsDevice#X11GraphicsDevice(long, int, boolean)}, - * since it is possible to share this device via {@link com.jogamp.newt.NewtFactory#createDisplay(String, boolean)}. - *

- */ - @SuppressWarnings("unused") - protected void createNativeImpl() { - long handle = X11Util.openDisplay(name); - if( 0 == handle ) { - throw new RuntimeException("Error creating display(Win): "+name); - } - if(USE_SEPARATE_DISPLAY_FOR_EDT) { - edtDisplayHandle = X11Util.openDisplay(name); - if( 0 == edtDisplayHandle ) { - X11Util.closeDisplay(handle); - throw new RuntimeException("Error creating display(EDT): "+name); - } - } else { - edtDisplayHandle = handle; - } - try { - CompleteDisplay0(edtDisplayHandle); - } catch(RuntimeException e) { - closeNativeImpl(); - throw e; - } - - // see API doc above! - if(X11Util.XINITTHREADS_ALWAYS_ENABLED && X11Util.HAS_XLOCKDISPLAY_BUG) { - aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock(), false); - } else { - aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, false); - } - } - - protected void closeNativeImpl() { - DisplayRelease0(edtDisplayHandle, javaObjectAtom, windowDeleteAtom); - javaObjectAtom = 0; - windowDeleteAtom = 0; - // closing using ATI driver bug 'same order' - final long handle = getHandle(); - X11Util.closeDisplay(handle); - if(handle != edtDisplayHandle) { - X11Util.closeDisplay(edtDisplayHandle); - } - edtDisplayHandle = 0; - } - - protected void dispatchMessagesNative() { - if(0 != edtDisplayHandle) { - DispatchMessages0(edtDisplayHandle, javaObjectAtom, windowDeleteAtom); - } - } - - protected long getEDTHandle() { return edtDisplayHandle; } - protected long getJavaObjectAtom() { return javaObjectAtom; } - protected long getWindowDeleteAtom() { return windowDeleteAtom; } - - //---------------------------------------------------------------------- - // Internals only - // - private static native boolean initIDs0(boolean debug); - - private native void CompleteDisplay0(long handle); - - private void displayCompleted(long javaObjectAtom, long windowDeleteAtom) { - this.javaObjectAtom=javaObjectAtom; - this.windowDeleteAtom=windowDeleteAtom; - } - private native void DisplayRelease0(long handle, long javaObjectAtom, long windowDeleteAtom); - - private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom); - - /** - * 2011/06/14 libX11 1.4.2 and libxcb 1.7 bug 20708 - Multithreading Issues w/ OpenGL, .. - * https://bugs.freedesktop.org/show_bug.cgi?id=20708 - * https://jogamp.org/bugzilla/show_bug.cgi?id=502 - * Affects: Ubuntu 11.04, OpenSuSE 11, .. - * Workaround: Using a separate X11 Display connection for event dispatching (EDT) - */ - private final boolean USE_SEPARATE_DISPLAY_FOR_EDT = true; - - private long edtDisplayHandle; - - /** X11 Window delete atom marker used on EDT */ - private long windowDeleteAtom; - - /** X11 Window java object property used on EDT */ - private long javaObjectAtom; -} - diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java deleted file mode 100644 index 93db854ac..000000000 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.x11; - -import java.util.List; - -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -import jogamp.nativewindow.x11.X11Util; -import jogamp.newt.DisplayImpl; -import jogamp.newt.DisplayImpl.DisplayRunnable; -import jogamp.newt.ScreenImpl; - -import com.jogamp.nativewindow.x11.X11GraphicsDevice; -import com.jogamp.nativewindow.x11.X11GraphicsScreen; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; - -public class X11Screen extends ScreenImpl { - - static { - X11Display.initSingleton(); - } - - public X11Screen() { - } - - protected void createNativeImpl() { - // validate screen index - Long handle = display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Long run(long dpy) { - return new Long(GetScreen0(dpy, screen_idx)); - } } ); - if (handle.longValue() == 0) { - throw new RuntimeException("Error creating screen: " + screen_idx); - } - aScreen = new X11GraphicsScreen((X11GraphicsDevice) getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { - } - - private int[] nrotations; - private int nrotation_index; - private int nres_number; - private int nres_index; - private int[] nrates; - private int nrate_index; - private int nmode_number; - - protected int[] getScreenModeFirstImpl() { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public int[] run(long dpy) { - // initialize iterators and static data - nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); - if(null==nrotations || 0==nrotations.length) { - return null; - } - nrotation_index = 0; - - nres_number = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==nres_number) { - return null; - } - nres_index = 0; - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - - nmode_number = 0; - - return getScreenModeNextImpl(); - } } ); - } - - protected int[] getScreenModeNextImpl() { - // assemble: w x h x bpp x f x r - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public int[] run(long dpy) { - /** - System.err.println("******** mode: "+nmode_number); - System.err.println("rot "+nrotation_index); - System.err.println("rate "+nrate_index); - System.err.println("res "+nres_index); */ - - int[] res = getScreenModeResolution0(dpy, screen_idx, nres_index); - if(null==res || 0==res.length) { - return null; - } - if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); - } - int rate = nrates[nrate_index]; - if(0>=rate) { - rate = default_sm_rate; - if(DEBUG) { - System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+default_sm_rate); - } - } - int rotation = nrotations[nrotation_index]; - - int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; - int i = 0; - props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode - props[i++] = 0; // set later for verification of iterator - props[i++] = res[0]; // width - props[i++] = res[1]; // height - props[i++] = default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rotation; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element - - nmode_number++; - - // iteration: r -> f -> bpp -> [w x h] - nrotation_index++; - if(nrotation_index == nrotations.length) { - nrotation_index=0; - nrate_index++; - if(null == nrates || nrate_index == nrates.length){ - nres_index++; - if(nres_index == nres_number) { - // done - nrates=null; - nrotations=null; - return null; - } - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - } - } - - return props; - } } ); - } - - protected ScreenMode getCurrentScreenModeImpl() { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public ScreenMode run(long dpy) { - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); - if(0 == screenConfigHandle) { - return null; - } - int[] res; - int rate, rot; - try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==resNumber) { - return null; - } - - int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); - if(0>resIdx) { - return null; - } - if(resIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); - } - res = getScreenModeResolution0(dpy, screen_idx, resIdx); - if(null==res || 0==res.length) { - return null; - } - if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); - } - rate = getCurrentScreenRate0(screenConfigHandle); - if(0>rate) { - return null; - } - rot = getCurrentScreenRotation0(screenConfigHandle); - if(0>rot) { - return null; - } - } finally { - freeScreenConfiguration0(screenConfigHandle); - } - int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; - int i = 0; - props[i++] = 0; // set later for verification of iterator - props[i++] = res[0]; // width - props[i++] = res[1]; // height - props[i++] = default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rot; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count - return ScreenModeUtil.streamIn(props, 0); - } } ); - } - - protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { - final List screenModes = this.getScreenModesOrig(); - final int screenModeIdx = screenModes.indexOf(screenMode); - if(0>screenModeIdx) { - throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); - } - final long t0 = System.currentTimeMillis(); - boolean done = runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Boolean run(long dpy) { - boolean done = false; - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); - if(0 == screenConfigHandle) { - return Boolean.valueOf(done); - } - try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); - if(0>resIdx || resIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! 0 < "+resIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); - } - - final int f = screenMode.getMonitorMode().getRefreshRate(); - final int r = screenMode.getRotation(); - - if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resIdx, f, r) ) { - while(!done && System.currentTimeMillis()-t0 < SCREEN_MODE_CHANGE_TIMEOUT) { - done = setCurrentScreenModePollEnd0(dpy, screen_idx, resIdx, f, r); - if(!done) { - try { Thread.sleep(10); } catch (InterruptedException e) { } - } - } - } - } finally { - freeScreenConfiguration0(screenConfigHandle); - } - return Boolean.valueOf(done); - } - }).booleanValue(); - - if(DEBUG || !done) { - System.err.println("X11Screen.setCurrentScreenModeImpl: TO ("+SCREEN_MODE_CHANGE_TIMEOUT+") reached: "+ - (System.currentTimeMillis()-t0)+"ms; Current: "+getCurrentScreenMode()+"; Desired: "+screenMode); - } - return done; - } - - private class XineramaEnabledQuery implements DisplayImpl.DisplayRunnable { - public Boolean run(long dpy) { - return new Boolean(X11Util.XineramaIsEnabled(dpy)); - } - } - private XineramaEnabledQuery xineramaEnabledQuery = new XineramaEnabledQuery(); - - protected int validateScreenIndex(final int idx) { - if(getDisplay().isNativeValid()) { - return runWithLockedDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx; - } else { - return runWithTempDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx; - } - } - - protected void getVirtualScreenOriginAndSize(final Point virtualOrigin, final Dimension virtualSize) { - display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(getWidth0(dpy, screen_idx)); - virtualSize.setHeight(getHeight0(dpy, screen_idx)); - return null; - } } ); - } - - //---------------------------------------------------------------------- - // Internals only - // - private final T runWithLockedDisplayHandle(DisplayRunnable action) { - return display.runWithLockedDisplayHandle(action); - // return runWithTempDisplayHandle(action); - // return runWithoutLock(action); - } - - private final T runWithTempDisplayHandle(DisplayRunnable action) { - final long displayHandle = X11Util.openDisplay(display.getName()); - if(0 == displayHandle) { - throw new RuntimeException("null device"); - } - T res; - try { - res = action.run(displayHandle); - } finally { - X11Util.closeDisplay(displayHandle); - } - return res; - } - private final T runWithoutLock(DisplayRunnable action) { - return action.run(display.getHandle()); - } - - private static native long GetScreen0(long dpy, int scrn_idx); - - private static native int getWidth0(long display, int scrn_idx); - - private static native int getHeight0(long display, int scrn_idx); - - /** @return int[] { rot1, .. } */ - private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); - - private static native int getNumScreenModeResolutions0(long display, int screen_index); - - /** @return int[] { width, height, widthmm, heightmm } */ - private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); - - private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); - - private static native long getScreenConfiguration0(long display, int screen_index); - private static native void freeScreenConfiguration0(long screenConfiguration); - - private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); - private static native int getCurrentScreenRate0(long screenConfiguration); - private static native int getCurrentScreenRotation0(long screenConfiguration); - - /** needs own Display connection for XRANDR event handling */ - private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); - private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); -} diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java deleted file mode 100644 index 5501f5a3c..000000000 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. 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 jogamp.newt.driver.x11; - -import jogamp.nativewindow.x11.X11Lib; -import jogamp.newt.DisplayImpl; -import jogamp.newt.DisplayImpl.DisplayRunnable; -import jogamp.newt.WindowImpl; -import javax.media.nativewindow.*; -import javax.media.nativewindow.VisualIDHolder.VIDType; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.InsetsImmutable; -import javax.media.nativewindow.util.Point; - -import com.jogamp.newt.event.MouseEvent; - -public class X11Window extends WindowImpl { - private static final String WINDOW_CLASS_NAME = "NewtWindow"; - private static final int X11_WHEEL_ONE_UP_BUTTON = 4; - private static final int X11_WHEEL_ONE_DOWN_BUTTON = 5; - private static final int X11_WHEEL_TWO_UP_BUTTON = 6; - private static final int X11_WHEEL_TWO_DOWN_BUTTON = 7; - - static { - X11Display.initSingleton(); - } - - public X11Window() { - } - - protected void createNativeImpl() { - final X11Screen screen = (X11Screen) getScreen(); - final X11Display display = (X11Display) screen.getDisplay(); - final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested); - final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if(DEBUG_IMPLEMENTATION) { - System.err.println("X11Window.createNativeImpl() factory: "+factory+", chosen config: "+cfg); - } - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - final int visualID = cfg.getVisualID(VIDType.NATIVE); - if(VisualIDHolder.VID_UNDEFINED == visualID) { - throw new NativeWindowException("Chosen Configuration w/o native visual ID: "+cfg); - } - setGraphicsConfiguration(cfg); - final int flags = getReconfigureFlags(0, true) & - ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; - setWindowHandle(CreateWindow0(getParentWindowHandle(), - display.getEDTHandle(), screen.getIndex(), visualID, - display.getJavaObjectAtom(), display.getWindowDeleteAtom(), - getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); - windowHandleClose = getWindowHandle(); - if (0 == windowHandleClose) { - throw new NativeWindowException("Error creating window"); - } - } - - protected void closeNativeImpl() { - if(0!=windowHandleClose && null!=getScreen() ) { - X11Display display = (X11Display) getScreen().getDisplay(); - try { - CloseWindow0(display.getEDTHandle(), windowHandleClose, - display.getJavaObjectAtom(), display.getWindowDeleteAtom()); - } catch (Throwable t) { - if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); - e.printStackTrace(); - } - } finally { - windowHandleClose = 0; - } - } - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ - getReconfigureFlagsAsString(null, flags)); - } - if(0 == ( FLAG_IS_UNDECORATED & flags)) { - final InsetsImmutable i = getInsets(); - - // client position -> top-level window position - x -= i.getLeftWidth() ; - y -= i.getTopHeight() ; - } - final X11Display display = (X11Display) getScreen().getDisplay(); - reconfigureWindow0( getDisplayEDTHandle(), getScreenIndex(), - getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), - x, y, width, height, flags); - - return true; - } - - protected void reparentNotify(long newParentWindowHandle) { - if(DEBUG_IMPLEMENTATION) { - final long p0 = getParentWindowHandle(); - System.err.println("Window.reparentNotify ("+getThreadName()+"): "+toHexString(p0)+" -> "+toHexString(newParentWindowHandle)); - } - } - - protected void requestFocusImpl(boolean force) { - requestFocus0(getDisplayEDTHandle(), getWindowHandle(), force); - } - - @Override - protected void setTitleImpl(final String title) { - runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { - setTitle0(dpy, getWindowHandle(), title); - return null; - } - }); - } - - @Override - protected boolean setPointerVisibleImpl(final boolean pointerVisible) { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Boolean run(long dpy) { - return Boolean.valueOf(setPointerVisible0(getDisplayEDTHandle(), getWindowHandle(), pointerVisible)); - } - }).booleanValue(); - } - - @Override - protected boolean confinePointerImpl(final boolean confine) { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Boolean run(long dpy) { - return Boolean.valueOf(confinePointer0(getDisplayEDTHandle(), getWindowHandle(), confine)); - } - }).booleanValue(); - } - - @Override - protected void warpPointerImpl(final int x, final int y) { - runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { - warpPointer0(getDisplayEDTHandle(), getWindowHandle(), x, y); - return null; - } - }); - } - - protected Point getLocationOnScreenImpl(final int x, final int y) { - // X11Util.GetRelativeLocation: locks display already ! - return X11Lib.GetRelativeLocation( getScreen().getDisplay().getHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop - using event driven insetsChange(..) - } - - protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, - int x, int y, int button, int rotation) { - switch(eventType) { - case MouseEvent.EVENT_MOUSE_PRESSED: - switch(button) { - case X11_WHEEL_ONE_UP_BUTTON: - case X11_WHEEL_ONE_DOWN_BUTTON: - case X11_WHEEL_TWO_UP_BUTTON: - case X11_WHEEL_TWO_DOWN_BUTTON: - // ignore wheel pressed ! - return; - } - break; - case MouseEvent.EVENT_MOUSE_RELEASED: - switch(button) { - case X11_WHEEL_ONE_UP_BUTTON: - eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; - button = 1; - rotation = 1; - break; - case X11_WHEEL_ONE_DOWN_BUTTON: - eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; - button = 1; - rotation = -1; - break; - case X11_WHEEL_TWO_UP_BUTTON: - eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; - button = 2; - rotation = 1; - break; - case X11_WHEEL_TWO_DOWN_BUTTON: - eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; - button = 2; - rotation = -1; - break; - } - break; - } - super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotation); - } - - - //---------------------------------------------------------------------- - // Internals only - // - - private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI - private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI - - private final long getDisplayEDTHandle() { - return ((X11Display) getScreen().getDisplay()).getEDTHandle(); - } - private final T runWithLockedDisplayHandle(DisplayRunnable action) { - return ((DisplayImpl) getScreen().getDisplay()).runWithLockedDisplayHandle(action); - // return runWithTempDisplayHandle(action); - } - - protected static native boolean initIDs0(); - - private native long CreateWindow0(long parentWindowHandle, long display, int screen_index, - int visualID, long javaObjectAtom, long windowDeleteAtom, - int x, int y, int width, int height, boolean autoPosition, int flags); - private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom); - private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle, - long windowDeleteAtom, int x, int y, int width, int height, int flags); - private native void requestFocus0(long display, long windowHandle, boolean force); - - private static native void setTitle0(long display, long windowHandle, String title); - private static native long getParentWindow0(long display, long windowHandle); - private static native boolean setPointerVisible0(long display, long windowHandle, boolean visible); - private static native boolean confinePointer0(long display, long windowHandle, boolean grab); - private static native void warpPointer0(long display, long windowHandle, int x, int y); - - private long windowHandleClose; -} diff --git a/src/newt/native/AndroidWindow.c b/src/newt/native/AndroidWindow.c index fa5765672..94695e1d3 100644 --- a/src/newt/native/AndroidWindow.c +++ b/src/newt/native/AndroidWindow.c @@ -9,7 +9,7 @@ #include #include -#include "jogamp_newt_driver_android_AndroidWindow.h" +#include "jogamp_newt_driver_android_WindowDriver.h" #include #include @@ -23,56 +23,56 @@ #endif -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getSurfaceHandle0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_android_WindowDriver_getSurfaceHandle0 (JNIEnv *env, jclass clazz, jobject surface) { ANativeWindow * anw = ANativeWindow_fromSurface(env, surface); return (jlong) (intptr_t) anw; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getSurfaceVisualID0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_WindowDriver_getSurfaceVisualID0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; return (jint) ANativeWindow_getFormat(anw); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_AndroidWindow_setSurfaceVisualID0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_WindowDriver_setSurfaceVisualID0 (JNIEnv *env, jclass clazz, jlong surfaceHandle, jint nativeVisualID) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; ANativeWindow_setBuffersGeometry(anw, 0, 0, nativeVisualID); } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getWidth0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_WindowDriver_getWidth0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; return (jint) ANativeWindow_getWidth(anw); } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getHeight0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_WindowDriver_getHeight0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; return (jint) ANativeWindow_getHeight(anw); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_AndroidWindow_acquire0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_WindowDriver_acquire0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; ANativeWindow_acquire(anw); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_AndroidWindow_release0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_WindowDriver_release0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; ANativeWindow_release(anw); } -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_android_AndroidWindow_initIDs0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_android_WindowDriver_initIDs0 (JNIEnv *env, jclass clazz) { DBG_PRINT( "initIDs ok\n" ); diff --git a/src/newt/native/IntelGDL.c b/src/newt/native/IntelGDL.c index 690e1123d..a3bf101c5 100644 --- a/src/newt/native/IntelGDL.c +++ b/src/newt/native/IntelGDL.c @@ -37,9 +37,9 @@ #include #include -#include "jogamp_newt_driver_intel_gdl_Display.h" -#include "jogamp_newt_driver_intel_gdl_Screen.h" -#include "jogamp_newt_driver_intel_gdl_Window.h" +#include "jogamp_newt_driver_intel_gdl_DisplayDriver.h" +#include "jogamp_newt_driver_intel_gdl_ScreenDriver.h" +#include "jogamp_newt_driver_intel_gdl_WindowDriver.h" #include "MouseEvent.h" #include "KeyEvent.h" @@ -122,7 +122,7 @@ static void JNI_ThrowNew(JNIEnv *env, const char *throwable, const char* message * Display */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Display_DispatchMessages +JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_DisplayDriver_DispatchMessages (JNIEnv *env, jobject obj, jlong displayHandle, jobject focusedWindow) { // FIXME: n/a @@ -137,7 +137,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Display_DispatchMessage } */ } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_intel_gdl_Display_CreateDisplay +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_intel_gdl_DisplayDriver_CreateDisplay (JNIEnv *env, jobject obj) { gdl_ret_t retval; @@ -170,7 +170,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_intel_gdl_Display_CreateDisplay return (jlong) (intptr_t) p_driver_info; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Display_DestroyDisplay +JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_DisplayDriver_DestroyDisplay (JNIEnv *env, jobject obj, jlong displayHandle) { gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle; @@ -189,7 +189,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Display_DestroyDisplay * Screen */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_intel_gdl_Screen_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_intel_gdl_ScreenDriver_initIDs (JNIEnv *env, jclass clazz) { screenCreatedID = (*env)->GetMethodID(env, clazz, "screenCreated", "(II)V"); @@ -201,7 +201,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_intel_gdl_Screen_initIDs return JNI_TRUE; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Screen_GetScreenInfo +JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_ScreenDriver_GetScreenInfo (JNIEnv *env, jobject obj, jlong displayHandle, jint idx) { gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle; @@ -233,7 +233,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Screen_GetScreenInfo * Window */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_intel_gdl_Window_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_intel_gdl_WindowDriver_initIDs (JNIEnv *env, jclass clazz) { updateBoundsID = (*env)->GetMethodID(env, clazz, "updateBounds", "(IIII)V"); @@ -245,7 +245,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_intel_gdl_Window_initIDs return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_intel_gdl_Window_CreateSurface +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_intel_gdl_WindowDriver_CreateSurface (JNIEnv *env, jobject obj, jlong displayHandle, jint scr_width, jint scr_height, jint x, jint y, jint width, jint height) { gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle; @@ -338,7 +338,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_intel_gdl_Window_CreateSurface return (jlong) (intptr_t) plane; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Window_CloseSurface +JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_WindowDriver_CloseSurface (JNIEnv *env, jobject obj, jlong display, jlong surface) { gdl_plane_id_t plane = (gdl_plane_id_t) (intptr_t) surface ; @@ -347,7 +347,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Window_CloseSurface DBG_PRINT("[CloseSurface] plane %d\n", plane); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Window_SetBounds0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_WindowDriver_SetBounds0 (JNIEnv *env, jobject obj, jlong surface, jint scr_width, jint scr_height, jint x, jint y, jint width, jint height) { gdl_plane_id_t plane = (gdl_plane_id_t) (intptr_t) surface ; diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c index bceb86a85..f1d6aecdf 100644 --- a/src/newt/native/KDWindow.c +++ b/src/newt/native/KDWindow.c @@ -44,7 +44,7 @@ #include #include -#include "jogamp_newt_driver_kd_Window.h" +#include "jogamp_newt_driver_kd_WindowDriver.h" #include "MouseEvent.h" #include "KeyEvent.h" @@ -82,7 +82,7 @@ static jmethodID sendKeyEventID = NULL; * Display */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Display_DispatchMessages +JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_DisplayDriver_DispatchMessages (JNIEnv *env, jobject obj) { const KDEvent * evt; @@ -180,7 +180,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Display_DispatchMessages * Window */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_Window_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_WindowDriver_initIDs (JNIEnv *env, jclass clazz) { #ifdef VERBOSE_ON @@ -208,7 +208,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_Window_initIDs return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_Window_CreateWindow +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_WindowDriver_CreateWindow (JNIEnv *env, jobject obj, jlong display, jlong jeglConfig) { EGLDisplay dpy = (EGLDisplay)(intptr_t)display; @@ -236,7 +236,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_Window_CreateWindow return (jlong) (intptr_t) window; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_Window_RealizeWindow +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_WindowDriver_RealizeWindow (JNIEnv *env, jobject obj, jlong window) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -251,7 +251,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_Window_RealizeWindow return (jlong) (intptr_t) nativeWindow; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_kd_Window_CloseWindow +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_kd_WindowDriver_CloseWindow (JNIEnv *env, jobject obj, jlong window, jlong juserData) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -265,11 +265,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_kd_Window_CloseWindow } /* - * Class: jogamp_newt_driver_kd_Window + * Class: jogamp_newt_driver_kd_WindowDriver * Method: setVisible0 * Signature: (JJZ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Window_setVisible0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_WindowDriver_setVisible0 (JNIEnv *env, jobject obj, jlong window, jboolean visible) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -279,7 +279,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Window_setVisible0 (*env)->CallVoidMethod(env, obj, visibleChangedID, JNI_FALSE, visible); // FIXME: or defer=true ? } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Window_setFullScreen0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_WindowDriver_setFullScreen0 (JNIEnv *env, jobject obj, jlong window, jboolean fullscreen) { /** not supported, due to missing NV property .. @@ -296,7 +296,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Window_setFullScreen0 (void)fullscreen; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Window_setSize0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_WindowDriver_setSize0 (JNIEnv *env, jobject obj, jlong window, jint width, jint height) { KDWindow *w = (KDWindow*) (intptr_t) window; diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index bbadc9dd0..e0330a563 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -33,7 +33,7 @@ #import -#import "jogamp_newt_driver_macosx_MacWindow.h" +#import "jogamp_newt_driver_macosx_WindowDriver.h" #import "NewtMacWindow.h" #import "MouseEvent.h" @@ -155,11 +155,11 @@ NS_ENDHANDLER } /* - * Class: jogamp_newt_driver_macosx_MacDisplay + * Class: jogamp_newt_driver_macosx_DisplayDriver * Method: initIDs * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_initNSApplication0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_initNSApplication0 (JNIEnv *env, jclass clazz) { static int initialized = 0; @@ -189,11 +189,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_initNSAppli } /* - * Class: jogamp_newt_driver_macosx_MacDisplay + * Class: jogamp_newt_driver_macosx_DisplayDriver * Method: runNSApplication0 * Signature: ()V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_runNSApplication0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_runNSApplication0 (JNIEnv *env, jclass clazz) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -206,11 +206,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_runNSApplicatio } /* - * Class: jogamp_newt_driver_macosx_MacDisplay + * Class: jogamp_newt_driver_macosx_DisplayDriver * Method: stopNSApplication0 * Signature: ()V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_stopNSApplication0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_stopNSApplication0 (JNIEnv *env, jclass clazz) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -250,11 +250,11 @@ static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx) { } /* - * Class: jogamp_newt_driver_macosx_MacScreen + * Class: jogamp_newt_driver_macosx_ScreenDriver * Method: getWidthImpl * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getWidthImpl0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getWidthImpl0 (JNIEnv *env, jclass clazz, jint screen_idx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -268,11 +268,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getWidthImpl0 } /* - * Class: jogamp_newt_driver_macosx_MacScreen + * Class: jogamp_newt_driver_macosx_ScreenDriver * Method: getHeightImpl * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getHeightImpl0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getHeightImpl0 (JNIEnv *env, jclass clazz, jint screen_idx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -318,11 +318,11 @@ static long GetDictionaryLong(CFDictionaryRef theDict, const void* key) #define ROTMODES_PER_REALMODE 4 /* - * Class: jogamp_newt_driver_macosx_MacScreen + * Class: jogamp_newt_driver_macosx_ScreenDriver * Method: getScreenSizeMM0 * Signature: (I)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getScreenSizeMM0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScreenSizeMM0 (JNIEnv *env, jobject obj, jint scrn_idx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -367,11 +367,11 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getScreenSi } /* - * Class: jogamp_newt_driver_macosx_MacScreen + * Class: jogamp_newt_driver_macosx_ScreenDriver * Method: getScreenMode0 * Signature: (IIII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getScreenMode0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScreenMode0 (JNIEnv *env, jobject obj, jint scrn_idx, jint mode_idx, jint widthMM, jint heightMM) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -459,11 +459,11 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getScreenMo } /* - * Class: jogamp_newt_driver_macosx_MacScreen + * Class: jogamp_newt_driver_macosx_ScreenDriver * Method: setScreenMode0 * Signature: (II)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacScreen_setScreenMode0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_setScreenMode0 (JNIEnv *env, jobject object, jint scrn_idx, jint mode_idx) { jboolean res = JNI_TRUE; @@ -504,11 +504,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacScreen_setScreenMod } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: initIDs * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_initIDs0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0 (JNIEnv *env, jclass clazz) { static int initialized = 0; @@ -519,16 +519,16 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_initIDs0 jclass c; c = (*env)->FindClass(env, ClazzNamePoint); if(NULL==c) { - NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't find %s", ClazzNamePoint); + NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0: can't find %s", ClazzNamePoint); } pointClz = (jclass)(*env)->NewGlobalRef(env, c); (*env)->DeleteLocalRef(env, c); if(NULL==pointClz) { - NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't use %s", ClazzNamePoint); + NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0: can't use %s", ClazzNamePoint); } pointCstr = (*env)->GetMethodID(env, pointClz, ClazzAnyCstrName, ClazzNamePointCstrSignature); if(NULL==pointCstr) { - NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't fetch %s.%s %s", + NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0: can't fetch %s.%s %s", ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature); } @@ -541,11 +541,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_initIDs0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: createWindow0 * Signature: (JIIIIZIIIJ)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow0 (JNIEnv *env, jobject jthis, jlong parent, jint x, jint y, jint w, jint h, jboolean opaque, jboolean fullscreen, jint styleMask, jint bufferingType, jint screen_idx, jlong jview) { @@ -698,11 +698,11 @@ NS_ENDHANDLER /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: close0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_close0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -761,11 +761,11 @@ NS_ENDHANDLER } /* - * Class: Java_jogamp_newt_driver_macosx_MacWindow + * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: lockSurface0 * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_lockSurface0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_lockSurface0 (JNIEnv *env, jclass clazz, jlong window) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); @@ -779,11 +779,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_lockSurface0 } /* - * Class: Java_jogamp_newt_driver_macosx_MacWindow + * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: unlockSurface0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_unlockSurface0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_unlockSurface0 (JNIEnv *env, jclass clazz, jlong window) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); @@ -794,11 +794,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_unlockSurface0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: requestFocus0 * Signature: (JZ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_requestFocus0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_requestFocus0 (JNIEnv *env, jobject window, jlong w, jboolean force) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -819,11 +819,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_requestFocus0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: resignFocus0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_resignFocus0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_resignFocus0 (JNIEnv *env, jobject window, jlong w) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -846,11 +846,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_resignFocus0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: orderFront0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderFront0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_orderFront0 (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -866,11 +866,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderFront0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: orderOut * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderOut0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_orderOut0 (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -891,11 +891,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderOut0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: setTitle0 * Signature: (JLjava/lang/String;)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setTitle0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setTitle0 (JNIEnv *env, jobject unused, jlong window, jstring title) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -913,11 +913,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setTitle0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: contentView * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_contentView0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_contentView0 (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -934,11 +934,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_contentView0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: changeContentView * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_changeContentView0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_changeContentView0 (JNIEnv *env, jobject jthis, jlong parentWindowOrView, jlong window, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -977,11 +977,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_changeContentVi } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: setContentSize * Signature: (JII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setContentSize0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setContentSize0 (JNIEnv *env, jobject unused, jlong window, jint w, jint h) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -998,11 +998,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setContentSize0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: setFrameTopLeftPoint * Signature: (JJII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setFrameTopLeftPoint0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setFrameTopLeftPoint0 (JNIEnv *env, jobject unused, jlong parent, jlong window, jint x, jint y) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -1027,11 +1027,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setFrameTopLeftP } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: setAlwaysOnTop0 * Signature: (JZ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setAlwaysOnTop0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setAlwaysOnTop0 (JNIEnv *env, jobject unused, jlong window, jboolean atop) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -1051,11 +1051,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setAlwaysOnTop0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: getLocationOnScreen0 * Signature: (JII)Ljavax/media/nativewindow/util/Point; */ -JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_MacWindow_getLocationOnScreen0 +JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_getLocationOnScreen0 (JNIEnv *env, jclass unused, jlong win, jint src_x, jint src_y) { NSObject *nsObj = (NSObject*) ((intptr_t) win); @@ -1072,11 +1072,11 @@ JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_MacWindow_getLocationOn } /* - * Class: Java_jogamp_newt_driver_macosx_MacWindow + * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: setPointerVisible0 * Signature: (JZ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setPointerVisible0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerVisible0 (JNIEnv *env, jclass clazz, jlong window, jboolean hasFocus, jboolean mouseVisible) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); @@ -1086,11 +1086,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setPointerVi } /* - * Class: Java_jogamp_newt_driver_macosx_MacWindow + * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: confinePointer0 * Signature: (JZ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_confinePointer0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_confinePointer0 (JNIEnv *env, jclass clazz, jlong window, jboolean confine) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); @@ -1099,11 +1099,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_confinePoint } /* - * Class: Java_jogamp_newt_driver_macosx_MacWindow + * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: warpPointer0 * Signature: (JJII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_warpPointer0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_warpPointer0 (JNIEnv *env, jclass clazz, jlong window, jint x, jint y) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 6d9c04dc3..40252f59b 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -81,9 +81,9 @@ #define DISPLAY_DEVICE_ACTIVE 0x00000001 #endif -#include "jogamp_newt_driver_windows_WindowsDisplay.h" -#include "jogamp_newt_driver_windows_WindowsScreen.h" -#include "jogamp_newt_driver_windows_WindowsWindow.h" +#include "jogamp_newt_driver_windows_DisplayDriver.h" +#include "jogamp_newt_driver_windows_ScreenDriver.h" +#include "jogamp_newt_driver_windows_WindowDriver.h" #include "Window.h" #include "MouseEvent.h" @@ -1011,11 +1011,11 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, } /* - * Class: jogamp_newt_driver_windows_WindowsDisplay + * Class: jogamp_newt_driver_windows_DisplayDriver * Method: DispatchMessages * Signature: ()V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsDisplay_DispatchMessages0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_DisplayDriver_DispatchMessages0 (JNIEnv *env, jclass clazz) { int i = 0; @@ -1040,11 +1040,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsDisplay_DispatchMe } /* - * Class: jogamp_newt_driver_windows_WindowsScreen + * Class: jogamp_newt_driver_windows_ScreenDriver * Method: getOriginX0 * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getOriginX0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getOriginX0 (JNIEnv *env, jobject obj, jint scrn_idx) { if( GetSystemMetrics( SM_CMONITORS) > 1) { @@ -1055,11 +1055,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getOriginX0 } /* - * Class: jogamp_newt_driver_windows_WindowsScreen + * Class: jogamp_newt_driver_windows_ScreenDriver * Method: getOriginY0 * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getOriginY0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getOriginY0 (JNIEnv *env, jobject obj, jint scrn_idx) { if( GetSystemMetrics( SM_CMONITORS ) > 1) { @@ -1070,11 +1070,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getOriginY0 } /* - * Class: jogamp_newt_driver_windows_WindowsScreen + * Class: jogamp_newt_driver_windows_ScreenDriver * Method: getWidthImpl * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getWidthImpl0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getWidthImpl0 (JNIEnv *env, jobject obj, jint scrn_idx) { if( GetSystemMetrics( SM_CMONITORS) > 1) { @@ -1085,11 +1085,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getWidthImp } /* - * Class: jogamp_newt_driver_windows_WindowsScreen + * Class: jogamp_newt_driver_windows_ScreenDriver * Method: getHeightImpl * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getHeightImpl0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getHeightImpl0 (JNIEnv *env, jobject obj, jint scrn_idx) { if( GetSystemMetrics( SM_CMONITORS ) > 1) { @@ -1173,11 +1173,11 @@ static HDC NewtScreen_createDisplayDC(LPCTSTR displayDeviceName) { } /* - * Class: jogamp_newt_driver_windows_WindowsScreen + * Class: jogamp_newt_driver_windows_ScreenDriver * Method: getScreenMode0 * Signature: (II)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getScreenMode0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getScreenMode0 (JNIEnv *env, jobject obj, jint scrn_idx, jint mode_idx) { DISPLAY_DEVICE device; @@ -1246,11 +1246,11 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getScr } /* - * Class: jogamp_newt_driver_windows_WindowsScreen + * Class: jogamp_newt_driver_windows_ScreenDriver * Method: setScreenMode0 * Signature: (IIIIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_setScreenMode0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_setScreenMode0 (JNIEnv *env, jobject object, jint scrn_idx, jint width, jint height, jint bits, jint rate, jint rot) { DISPLAY_DEVICE device; @@ -1283,11 +1283,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_setScre } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: initIDs0 * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_initIDs0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 (JNIEnv *env, jclass clazz) { NewtCommon_init(env); @@ -1324,11 +1324,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_initIDs } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: getNewtWndProc0 * Signature: ()J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_getNewtWndProc0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_getNewtWndProc0 (JNIEnv *env, jclass clazz) { return (jlong) (intptr_t) wndProc; @@ -1366,10 +1366,10 @@ static void NewtWindow_setVisiblePosSize(HWND hwnd, BOOL atop, BOOL visible, } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: CreateWindow */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_CreateWindow0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindow0 (JNIEnv *env, jobject obj, jlong hInstance, jstring jWndClassName, jstring jWndName, jlong parent, @@ -1473,11 +1473,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_CreateWind } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: MonitorFromWindow * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_MonitorFromWindow0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_MonitorFromWindow0 (JNIEnv *env, jobject obj, jlong window) { #if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410 || WINVER >= 0x0500) && !defined(_WIN32_WCE) @@ -1506,11 +1506,11 @@ static jboolean NewtWindows_setFullScreen(jboolean fullscreen) } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: reconfigureWindow0 * Signature: (JJIIIII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_reconfigureWindow0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_reconfigureWindow0 (JNIEnv *env, jobject obj, jlong parent, jlong window, jint x, jint y, jint width, jint height, jint flags) { @@ -1591,11 +1591,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_reconfigure } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: setTitle * Signature: (JLjava/lang/String;)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_setTitle0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_setTitle0 (JNIEnv *env, jclass clazz, jlong window, jstring title) { HWND hwnd = (HWND) (intptr_t) window; @@ -1609,11 +1609,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_setTitle0 } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: requestFocus * Signature: (JZ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_requestFocus0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_requestFocus0 (JNIEnv *env, jobject obj, jlong window, jboolean force) { DBG_PRINT("*** WindowsWindow: RequestFocus0\n"); @@ -1621,11 +1621,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_requestFocu } /* - * Class: Java_jogamp_newt_driver_windows_WindowsWindow + * Class: Java_jogamp_newt_driver_windows_WindowDriver * Method: setPointerVisible0 * Signature: (JJZ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_setPointerVisible0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_setPointerVisible0 (JNIEnv *env, jclass clazz, jlong window, jboolean mouseVisible) { HWND hwnd = (HWND) (intptr_t) window; @@ -1660,11 +1660,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_setPoin } /* - * Class: Java_jogamp_newt_driver_windows_WindowsWindow + * Class: Java_jogamp_newt_driver_windows_WindowDriver * Method: confinePointer0 * Signature: (JJZIIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_confinePointer0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_confinePointer0 (JNIEnv *env, jclass clazz, jlong window, jboolean confine, jint l, jint t, jint r, jint b) { HWND hwnd = (HWND) (intptr_t) window; @@ -1686,11 +1686,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_confine } /* - * Class: Java_jogamp_newt_driver_windows_WindowsWindow + * Class: Java_jogamp_newt_driver_windows_WindowDriver * Method: warpPointer0 * Signature: (JJII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_warpPointer0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_warpPointer0 (JNIEnv *env, jclass clazz, jlong window, jint x, jint y) { DBG_PRINT( "*** WindowsWindow: warpPointer0: %d/%d\n", x, y); @@ -1698,11 +1698,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_warpPointer } /* - * Class: Java_jogamp_newt_driver_windows_WindowsWindow + * Class: Java_jogamp_newt_driver_windows_WindowDriver * Method: trackPointerLeave0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_trackPointerLeave0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_trackPointerLeave0 (JNIEnv *env, jclass clazz, jlong window) { HWND hwnd = (HWND) (intptr_t) window; diff --git a/src/newt/native/X11Common.h b/src/newt/native/X11Common.h index 982255b8a..128b6b6f1 100644 --- a/src/newt/native/X11Common.h +++ b/src/newt/native/X11Common.h @@ -45,9 +45,9 @@ #include -#include "jogamp_newt_driver_x11_X11Screen.h" -#include "jogamp_newt_driver_x11_X11Display.h" -#include "jogamp_newt_driver_x11_X11Window.h" +#include "jogamp_newt_driver_x11_ScreenDriver.h" +#include "jogamp_newt_driver_x11_DisplayDriver.h" +#include "jogamp_newt_driver_x11_WindowDriver.h" #include "Window.h" #include "MouseEvent.h" diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index ce7d9a0e1..3157538c3 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -34,7 +34,7 @@ jclass X11NewtWindowClazz = NULL; jmethodID insetsChangedID = NULL; jmethodID visibleChangedID = NULL; -static const char * const ClazzNameX11NewtWindow = "jogamp/newt/driver/x11/X11Window"; +static const char * const ClazzNameX11NewtWindow = "jogamp/newt/driver/x11/WindowDriver"; static jmethodID displayCompletedID = NULL; @@ -264,11 +264,11 @@ static jint X11InputState2NewtModifiers(unsigned int xstate) { */ /* - * Class: jogamp_newt_driver_x11_X11Display + * Class: jogamp_newt_driver_x11_DisplayDriver * Method: initIDs * Signature: (Z)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Display_initIDs0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 (JNIEnv *env, jclass clazz, jboolean debug) { jclass c; @@ -281,12 +281,12 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Display_initIDs0 if(NULL==X11NewtWindowClazz) { c = (*env)->FindClass(env, ClazzNameX11NewtWindow); if(NULL==c) { - NewtCommon_FatalError(env, "NEWT X11Window: can't find %s", ClazzNameX11NewtWindow); + NewtCommon_FatalError(env, "NEWT X11Display: can't find %s", ClazzNameX11NewtWindow); } X11NewtWindowClazz = (jclass)(*env)->NewGlobalRef(env, c); (*env)->DeleteLocalRef(env, c); if(NULL==X11NewtWindowClazz) { - NewtCommon_FatalError(env, "NEWT X11Window: can't use %s", ClazzNameX11NewtWindow); + NewtCommon_FatalError(env, "NEWT X11Display: can't use %s", ClazzNameX11NewtWindow); } } @@ -331,11 +331,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Display_initIDs0 } /* - * Class: jogamp_newt_driver_x11_X11Display + * Class: jogamp_newt_driver_x11_DisplayDriver * Method: CompleteDisplay * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_CompleteDisplay0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_CompleteDisplay0 (JNIEnv *env, jobject obj, jlong display) { Display * dpy = (Display *)(intptr_t)display; @@ -366,11 +366,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_CompleteDisplay0 } /* - * Class: jogamp_newt_driver_x11_X11Display + * Class: jogamp_newt_driver_x11_DisplayDriver * Method: DisplayRelease0 * Signature: (JJJ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DisplayRelease0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DisplayRelease0 (JNIEnv *env, jobject obj, jlong display, jlong javaObjectAtom, jlong windowDeleteAtom) { Display * dpy = (Display *)(intptr_t)display; @@ -390,11 +390,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DisplayRelease0 } /* - * Class: jogamp_newt_driver_x11_X11Display + * Class: jogamp_newt_driver_x11_DisplayDriver * Method: DispatchMessages * Signature: (JIJJ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0 (JNIEnv *env, jobject obj, jlong display, jlong javaObjectAtom, jlong windowDeleteAtom) { Display * dpy = (Display *) (intptr_t) display; diff --git a/src/newt/native/X11Screen.c b/src/newt/native/X11Screen.c index 698eed89d..334c39727 100644 --- a/src/newt/native/X11Screen.c +++ b/src/newt/native/X11Screen.c @@ -36,11 +36,11 @@ #endif /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: GetScreen * Signature: (JI)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Screen_GetScreen0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_GetScreen0 (JNIEnv *env, jclass clazz, jlong display, jint screen_index) { Display * dpy = (Display *)(intptr_t)display; @@ -60,14 +60,14 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Screen_GetScreen0 return (jlong) (intptr_t) scrn; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getWidth0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getWidth0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display * dpy = (Display *) (intptr_t) display; return (jint) DisplayWidth( dpy, scrn_idx); } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getHeight0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getHeight0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display * dpy = (Display *) (intptr_t) display; @@ -112,11 +112,11 @@ static int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation) { } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getAvailableScreenModeRotations0 * Signature: (JI)I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getAvailableScreenModeRotations0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getAvailableScreenModeRotations0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -162,11 +162,11 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getAvailableSc } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getNumScreenModeResolution0 * Signature: (JI)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeResolutions0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getNumScreenModeResolutions0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -177,7 +177,7 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeRes #endif if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeResolutions0: RANDR not available\n"); + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getNumScreenModeResolutions0: RANDR not available\n"); return 0; } @@ -200,17 +200,17 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeRes } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getScreenModeResolutions0 * Signature: (JII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenModeResolution0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeResolution0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) { Display *dpy = (Display *) (intptr_t) display; if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getScreenModeResolution0: RANDR not available\n"); + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeResolution0: RANDR not available\n"); return (*env)->NewIntArray(env, 0); } @@ -242,17 +242,17 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenModeR } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getScreenModeRates0 * Signature: (JII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenModeRates0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeRates0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) { Display *dpy = (Display *) (intptr_t) display; if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getScreenModeRates0: RANDR not available\n"); + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeRates0: RANDR not available\n"); return (*env)->NewIntArray(env, 0); } @@ -285,11 +285,11 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenModeR } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getScreenConfiguration0 * Signature: (JI)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenConfiguration0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenConfiguration0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -301,7 +301,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenConfigura #endif if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getScreenConfiguration0: RANDR not available\n"); + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getScreenConfiguration0: RANDR not available\n"); return 0; } #ifdef DBG_PERF @@ -320,22 +320,22 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenConfigura } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: freeScreenConfiguration0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Screen_freeScreenConfiguration0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_freeScreenConfiguration0 (JNIEnv *env, jclass clazz, jlong screenConfiguration) { XRRFreeScreenConfigInfo( (XRRScreenConfiguration *) (intptr_t) screenConfiguration ); } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getCurrentScreenRate0 * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRate0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRate0 (JNIEnv *env, jclass clazz, jlong screenConfiguration) { XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; @@ -347,11 +347,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRat } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getCurrentScreenRotation0 * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRotation0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRotation0 (JNIEnv *env, jclass clazz, jlong screenConfiguration) { XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; @@ -364,11 +364,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRot /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getCurrentScreenResolutionIndex0 * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenResolutionIndex0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenResolutionIndex0 (JNIEnv *env, jclass clazz, jlong screenConfiguration) { XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; @@ -383,11 +383,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRes } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: setCurrentScreenModeStart0 * Signature: (JIJIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScreenModeStart0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModeStart0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenConfiguration, jint resMode_idx, jint freq, jint rotation) { Display *dpy = (Display *) (intptr_t) display; @@ -432,11 +432,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScree } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: setCurrentScreenModePollEnd0 * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScreenModePollEnd0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModePollEnd0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) { Display *dpy = (Display *) (intptr_t) display; @@ -445,7 +445,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScree XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_setCurrentScreenModePollEnd0: RANDR not available\n"); + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModePollEnd0: RANDR not available\n"); return JNI_FALSE; } diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index daf9f2b53..59862f463 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -467,11 +467,11 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy, */ /* - * Class: jogamp_newt_driver_x11_X11Window + * Class: jogamp_newt_driver_x11_WindowDriver * Method: initIDs * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_initIDs0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_WindowDriver_initIDs0 (JNIEnv *env, jclass clazz) { return JNI_TRUE; @@ -505,10 +505,10 @@ static void NewtWindows_setPosSize(Display *dpy, Window w, jint x, jint y, jint } /* - * Class: jogamp_newt_driver_x11_X11Window + * Class: jogamp_newt_driver_x11_WindowDriver * Method: CreateWindow */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 (JNIEnv *env, jobject obj, jlong parent, jlong display, jint screen_index, jint visualID, jlong javaObjectAtom, jlong windowDeleteAtom, @@ -666,11 +666,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0 } /* - * Class: jogamp_newt_driver_x11_X11Window + * Class: jogamp_newt_driver_x11_WindowDriver * Method: CloseWindow * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_CloseWindow0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0 (JNIEnv *env, jobject obj, jlong display, jlong window, jlong javaObjectAtom, jlong windowDeleteAtom) { Display * dpy = (Display *) (intptr_t) display; @@ -703,7 +703,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_CloseWindow0 NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); // Drain all events related to this window .. - Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom); + Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom); XDestroyWindow(dpy, w); XSync(dpy, False); @@ -729,11 +729,11 @@ static Bool WaitForReparentNotify( Display *dpy, XEvent *event, XPointer arg ) { */ /* - * Class: jogamp_newt_driver_x11_X11Window + * Class: jogamp_newt_driver_x11_WindowDriver * Method: reconfigureWindow0 * Signature: (JIJJIIIII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_reconfigureWindow0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindow0 (JNIEnv *env, jobject obj, jlong jdisplay, jint screen_index, jlong jparent, jlong jwindow, jlong windowDeleteAtom, jint x, jint y, jint width, jint height, jint flags) @@ -869,33 +869,33 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_reconfigureWindow0 } /* - * Class: jogamp_newt_driver_x11_X11Window + * Class: jogamp_newt_driver_x11_WindowDriver * Method: requestFocus0 * Signature: (JJZ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_requestFocus0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_requestFocus0 (JNIEnv *env, jobject obj, jlong display, jlong window, jboolean force) { NewtWindows_requestFocus ( env, obj, (Display *) (intptr_t) display, (Window)window, force ) ; } /* - * Class: jogamp_newt_driver_x11_X11Window + * Class: jogamp_newt_driver_x11_WindowDriver * Method: getParentWindow0 * Signature: (JJ)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_getParentWindow0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_getParentWindow0 (JNIEnv *env, jclass clazz, jlong display, jlong window) { return (jlong) NewtWindows_getParent ((Display *) (intptr_t) display, (Window)window); } /* - * Class: Java_jogamp_newt_driver_x11_X11Window + * Class: Java_jogamp_newt_driver_x11_WindowDriver * Method: setTitle0 * Signature: (JJLjava/lang/String;)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_setTitle0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_setTitle0 (JNIEnv *env, jclass clazz, jlong display, jlong window, jstring title) { Display * dpy = (Display *) (intptr_t) display; @@ -942,11 +942,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_setTitle0 } /* - * Class: Java_jogamp_newt_driver_x11_X11Window + * Class: Java_jogamp_newt_driver_x11_WindowDriver * Method: setPointerVisible0 * Signature: (JJZ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_setPointerVisible0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_WindowDriver_setPointerVisible0 (JNIEnv *env, jclass clazz, jlong display, jlong window, jboolean mouseVisible) { static char noData[] = { 0,0,0,0,0,0,0,0 }; @@ -976,11 +976,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_setPointerVisib } /* - * Class: Java_jogamp_newt_driver_x11_X11Window + * Class: Java_jogamp_newt_driver_x11_WindowDriver * Method: confinePointer0 * Signature: (JJZ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_confinePointer0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_WindowDriver_confinePointer0 (JNIEnv *env, jclass clazz, jlong display, jlong window, jboolean confine) { Display * dpy = (Display *) (intptr_t) display; @@ -999,11 +999,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_confinePointer0 } /* - * Class: Java_jogamp_newt_driver_x11_X11Window + * Class: Java_jogamp_newt_driver_x11_WindowDriver * Method: warpPointer0 * Signature: (JJII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_warpPointer0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_warpPointer0 (JNIEnv *env, jclass clazz, jlong display, jlong window, jint x, jint y) { Display * dpy = (Display *) (intptr_t) display; diff --git a/src/newt/native/bcm_egl.c b/src/newt/native/bcm_egl.c index 79ebd20e0..9b960d278 100644 --- a/src/newt/native/bcm_egl.c +++ b/src/newt/native/bcm_egl.c @@ -37,7 +37,7 @@ #include #include -#include "jogamp_newt_driver_bcm_egl_Window.h" +#include "jogamp_newt_driver_bcm_egl_WindowDriver.h" #include "MouseEvent.h" #include "KeyEvent.h" @@ -67,7 +67,7 @@ static jmethodID windowCreatedID = NULL; * Display */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Display_DispatchMessages +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_DisplayDriver_DispatchMessages (JNIEnv *env, jobject obj) { // FIXME: n/a @@ -75,7 +75,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Display_DispatchMessages (void) obj; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_Display_CreateDisplay +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_DisplayDriver_CreateDisplay (JNIEnv *env, jobject obj, jint width, jint height) { (void) env; @@ -89,7 +89,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_Display_CreateDisplay return (jlong) (intptr_t) dpy; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Display_DestroyDisplay +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_DisplayDriver_DestroyDisplay (JNIEnv *env, jobject obj, jlong display) { EGLDisplay dpy = (EGLDisplay)(intptr_t)display; @@ -106,7 +106,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Display_DestroyDisplay * Window */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_egl_Window_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_egl_WindowDriver_initIDs (JNIEnv *env, jclass clazz) { windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(III)V"); @@ -118,7 +118,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_egl_Window_initIDs return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_Window_CreateWindow +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_WindowDriver_CreateWindow (JNIEnv *env, jobject obj, jlong display, jboolean chromaKey, jint width, jint height) { EGLDisplay dpy = (EGLDisplay)(intptr_t)display; @@ -162,7 +162,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_Window_CreateWindow return (jlong) (intptr_t) window; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Window_CloseWindow +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_WindowDriver_CloseWindow (JNIEnv *env, jobject obj, jlong display, jlong window) { EGLDisplay dpy = (EGLDisplay) (intptr_t) display; @@ -175,7 +175,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Window_CloseWindow DBG_PRINT( "[CloseWindow] X\n"); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Window_SwapWindow +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_WindowDriver_SwapWindow (JNIEnv *env, jobject obj, jlong display, jlong window) { EGLDisplay dpy = (EGLDisplay) (intptr_t) display; diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index 09ab8a634..e41745e14 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -32,9 +32,9 @@ #include "bcm_vc_iv.h" -#include "jogamp_newt_driver_bcm_vc_iv_Display.h" -#include "jogamp_newt_driver_bcm_vc_iv_Screen.h" -#include "jogamp_newt_driver_bcm_vc_iv_Window.h" +#include "jogamp_newt_driver_bcm_vc_iv_DisplayDriver.h" +#include "jogamp_newt_driver_bcm_vc_iv_ScreenDriver.h" +#include "jogamp_newt_driver_bcm_vc_iv_WindowDriver.h" #define VERBOSE_ON 1 @@ -57,7 +57,7 @@ static jmethodID sendKeyEventID = NULL; * Display */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Display_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_initIDs (JNIEnv *env, jclass clazz) { bcm_host_init(); @@ -66,7 +66,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Display_initIDs return JNI_TRUE; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Display_DispatchMessages +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_DispatchMessages (JNIEnv *env, jobject obj) { } @@ -75,7 +75,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Display_DispatchMessage * Screen */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Screen_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initIDs (JNIEnv *env, jclass clazz) { uint32_t screen_width; @@ -91,7 +91,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Screen_initIDs return JNI_TRUE; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Screen_initNative +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initNative (JNIEnv *env, jobject obj) { uint32_t screen_width; @@ -109,7 +109,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Screen_initNative * Window */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initIDs (JNIEnv *env, jclass clazz) { windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(J)V"); @@ -131,7 +131,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_initIDs return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_CreateWindow +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow (JNIEnv *env, jobject obj, jint width, jint height) { int32_t success = 0; @@ -166,13 +166,13 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_CreateWindow return (jlong) (intptr_t) nativeWindowPtr; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_RealizeWindow +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_RealizeWindow (JNIEnv *env, jobject obj, jlong window) { return (jlong) (intptr_t) 0; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_CloseWindow +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CloseWindow (JNIEnv *env, jobject obj, jlong window, jlong juserData) { EGL_DISPMANX_WINDOW_T * nativeWindowPtr = (EGL_DISPMANX_WINDOW_T *) (intptr_t) window ; @@ -181,21 +181,21 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_CloseWindow } /* - * Class: jogamp_newt_driver_bcm_vc_iv_Window + * Class: jogamp_newt_driver_bcm_vc_iv_WindowDriver * Method: setVisible0 * Signature: (JJZ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_setVisible0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setVisible0 (JNIEnv *env, jobject obj, jlong window, jboolean visible) { } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_setFullScreen0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setFullScreen0 (JNIEnv *env, jobject obj, jlong window, jboolean fullscreen) { } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_setSize0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setSize0 (JNIEnv *env, jobject obj, jlong window, jint width, jint height) { // FIXME RESIZE (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java index 11babf187..89395e309 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java @@ -34,11 +34,11 @@ import java.util.Arrays; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; -import jogamp.newt.driver.android.AndroidWindow; import jogamp.newt.driver.android.NewtBaseActivity; import com.jogamp.common.util.IOUtil; import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.opengl.GLWindow; @@ -55,8 +55,8 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { MouseAdapter toFrontMouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { Object src = e.getSource(); - if(src instanceof AndroidWindow) { - ((AndroidWindow)src).requestFocus(false); + if(src instanceof Window) { + ((Window)src).requestFocus(false); } } }; diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java index a5e5f4ccb..a7fefd838 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java @@ -36,11 +36,11 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; -import jogamp.newt.driver.android.AndroidWindow; import jogamp.newt.driver.android.NewtBaseActivity; import com.jogamp.common.util.IOUtil; import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.opengl.GLWindow; @@ -59,8 +59,8 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { MouseAdapter toFrontMouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { Object src = e.getSource(); - if(src instanceof AndroidWindow) { - ((AndroidWindow)src).requestFocus(false); + if(src instanceof Window) { + ((Window)src).requestFocus(false); } } }; @@ -121,7 +121,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); { final int padding = mPlayerHUD ? 32 : 0; - final android.view.View androidView = ((AndroidWindow)glWindowMain.getDelegatedWindow()).getAndroidView(); + final android.view.View androidView = ((jogamp.newt.driver.android.WindowDriver)glWindowMain.getDelegatedWindow()).getAndroidView(); glWindowMain.setSize(scrn.getWidth()-padding, scrn.getHeight()-padding); glWindowMain.setUndecorated(true); // setContentView(getWindow(), glWindowMain); @@ -168,7 +168,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { viewGroup.post(new Runnable() { public void run() { - final android.view.View androidView = ((AndroidWindow)glWindowHUD.getDelegatedWindow()).getAndroidView(); + final android.view.View androidView = ((jogamp.newt.driver.android.WindowDriver)glWindowHUD.getDelegatedWindow()).getAndroidView(); // addContentView(getWindow(), glWindowHUD, new android.view.ViewGroup.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight())); viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight(), Gravity.TOP|Gravity.LEFT)); registerNEWTWindow(glWindowHUD); -- cgit v1.2.3 From ea7bd4789892f063182fd9970e11cfe9ffa44bea Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 18 Aug 2012 21:07:37 +0200 Subject: Fix missing NEWT driver class name change - regression of a694cadca4ab72481e777222f412f006f973f77e --- src/newt/classes/com/jogamp/newt/util/MainThread.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java index 9c2f2a0b7..5e79e9b49 100644 --- a/src/newt/classes/com/jogamp/newt/util/MainThread.java +++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java @@ -92,7 +92,7 @@ import jogamp.newt.NEWTJNILibLoader; * Which starts 4 threads, each with a window and OpenGL rendering.
*/ public class MainThread { - private static final String MACOSXDisplayClassName = "jogamp.newt.driver.macosx.MacDisplay"; + private static final String MACOSXDisplayClassName = "jogamp.newt.driver.macosx.DisplayDriver"; private static final Platform.OSType osType; private static final boolean isMacOSX; private static final ThreadGroup rootThreadGroup; -- cgit v1.2.3 From ee306d4900c9aad5248d30ce0594f07d2f79bb71 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 19 Aug 2012 11:48:04 +0200 Subject: NEWT Windows.closeNativeImpl(): Remove 'GDI.SetParent(windowHandleClose, 0)' for NewtCanvasSWT workaround - not required anymore --- make/scripts/java-win32-dbg.bat | 4 ++-- make/scripts/java-win32.bat | 4 ++-- make/scripts/tests-x32.bat | 7 ++++++- src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java | 1 - 4 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/java-win32-dbg.bat b/make/scripts/java-win32-dbg.bat index 6f8206721..5735797bf 100755 --- a/make/scripts/java-win32-dbg.bat +++ b/make/scripts/java-win32-dbg.bat @@ -9,9 +9,9 @@ set BLD_DIR=..\%BLD_SUB% set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x32 -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32;%PATH% -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj set LIB_DIR=%FFMPEG_LIB% diff --git a/make/scripts/java-win32.bat b/make/scripts/java-win32.bat index 1d8430280..a4d631075 100755 --- a/make/scripts/java-win32.bat +++ b/make/scripts/java-win32.bat @@ -7,9 +7,9 @@ set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl set BLD_DIR=..\%BLD_SUB% -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\angle\win32;%PATH% -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% set BLD_DIR=..\%BLD_SUB% REM set LIB_DIR=..\..\gluegen\%BLD_SUB%\obj;%BLD_DIR%\lib diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat index 7947759a4..de0785661 100755 --- a/make/scripts/tests-x32.bat +++ b/make/scripts/tests-x32.bat @@ -1,6 +1,7 @@ REM scripts\java-win32-dbg.bat jogamp.newt.awt.opengl.VersionApplet REM scripts\java-win32-dbg.bat com.jogamp.newt.opengl.GLWindow REM scripts\java-win32-dbg.bat javax.media.opengl.awt.GLCanvas +REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn @@ -71,6 +72,10 @@ REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingPr REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GLn %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAWT01GLn $* +REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* +REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT -time 5000 @@ -94,7 +99,7 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMe REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 -scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT %* +REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT %* REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 39ea54575..5dbdeb458 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -163,7 +163,6 @@ public class WindowDriver extends WindowImpl { } } try { - GDI.SetParent(windowHandleClose, 0); // detach first, experience hang w/ SWT parent GDI.DestroyWindow(windowHandleClose); } catch (Throwable t) { if(DEBUG_IMPLEMENTATION) { -- cgit v1.2.3 From 4abaf513bcc91a2d4b3ec4842c532807cbe66167 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 21 Aug 2012 15:55:37 +0200 Subject: Fix/Workaround: For BCM_VC_IV EGL (alpha) configuration Native BCM_VC_IV code CreateWindow() uses the default alpha value setting, which is alpha:8 ! Hence we require to chose alpha from the egl configurations TODO: Properly select the alpha mode in CreateWindow()! This will allow this hack. --- src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index 6d4f36964..7b8d2e958 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -29,6 +29,7 @@ package jogamp.newt.driver.bcm.vc.iv; import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.VisualIDHolder; @@ -52,8 +53,14 @@ public class WindowDriver extends WindowImpl { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); } + // FIXME: Hack - Native BCM_VC_IV code CreateWindow() uses the default alpha value setting, + // which is alpha:8 ! Hence we require to chose alpha from the egl configurations. + // TODO: Properly select the alpha mode in CreateWindow()! This will allow this hack. + final Capabilities capsChosen = (Capabilities) capsRequested.cloneMutable(); + capsChosen.setAlphaBits(1); + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + capsChosen, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } -- cgit v1.2.3 From ab3ec08822e7958943686a7ba5157a4ff314e7ac Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 23 Aug 2012 21:07:55 +0200 Subject: Fix Android/NEWT WindowDriver: Add missing eglDestroySurface() in closeNativeImpl(); Complete visibleChanged() in reconfigureWindowImpl() even if resize or reposition can't be handled Add missing eglDestroySurface() in closeNativeImpl() - missing egl surface destruction leaked it's resource .. Complete visibleChanged() in reconfigureWindowImpl() even if resize or reposition can't be handled - properly detect resize and reposition request, warn if this action cannot be completed but contine w/ workflow -> visibleChanged() - this allows properly handling of setVisible(..) and it's visible-changed detection polling --- .../jogamp/newt/driver/android/WindowDriver.java | 36 ++++++++++++++++------ 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index 8ad11b35f..276b0d070 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -39,6 +39,7 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLException; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; @@ -263,15 +264,24 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { setGraphicsConfiguration(eglConfig); setWindowHandle(surfaceHandle); focusChanged(false, true); - Log.d(MD.TAG, "createNativeImpl X"); + Log.d(MD.TAG, "createNativeImpl X: eglSurfaceHandle 0x"+Long.toHexString(eglSurface)); } @Override protected void closeNativeImpl() { + Log.d(MD.TAG, "closeNativeImpl 0 - surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ + ", eglSurfaceHandle 0x"+Long.toHexString(eglSurface)+ + ", format [a "+androidFormat+", n "+nativeFormat+"], "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - "+Thread.currentThread().getName()); + if(0 != eglSurface) { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice(); + if (!EGL.eglDestroySurface(eglDevice.getHandle(), eglSurface)) { + throw new GLException("Error destroying window surface (eglDestroySurface)"); + } + eglSurface = 0; + } release0(surfaceHandle); surface = null; surfaceHandle = 0; - eglSurface = 0; } @Override @@ -291,25 +301,33 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } } - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + boolean res = true; + if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { Log.d(MD.TAG, "reconfigureWindowImpl.setFullscreen post creation (setContentView()) n/a"); return false; } - if(width>0 || height>0) { + if(getWidth() != width || getHeight() != height) { if(0!=getWindowHandle()) { Log.d(MD.TAG, "reconfigureWindowImpl.setSize n/a"); - return false; + res = false; + } else { + defineSize(width, height); } } - if(x>=0 || y>=0) { - Log.d(MD.TAG, "reconfigureWindowImpl.setPos n/a"); - return false; + if(getX() != x || getY() != y) { + if(0!=getWindowHandle()) { + Log.d(MD.TAG, "reconfigureWindowImpl.setPos n/a"); + res = false; + } else { + definePosition(x, y); + } } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } - return true; + return res; } protected Point getLocationOnScreenImpl(int x, int y) { -- cgit v1.2.3 From 8516fe0358805e8549a96cde785dfa7ac2576e87 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 23 Aug 2012 21:09:23 +0200 Subject: Fix Android Power-suspend and Power-resume NewtBaseActivity onPause()/onResume(): add setVisible(..) allowing recreation and avoid usage of unavail resources - crucial for power suspend/resume, which itself calls activity onPause()/onResume(), this ensures resources are not used onPause(). - Animator suspend is not sufficient due to surfaceRedrawNeeded(..) hook etc .. - iff power suspend leads to surfaceDestroyed(..), recreation is now possible due to setVisible(true) on onResume() even though I have not observed this on Android 2.3 and 4.0.1 Tested on Android 2.3 and Android 4.0.1 --- .../jogamp/newt/driver/android/NewtBaseActivity.java | 15 ++++++++++----- .../opengl/test/android/NEWTGearsES2ActivityLauncher.java | 8 ++++---- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index 91c589beb..28c4da72f 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -265,16 +265,17 @@ public class NewtBaseActivity extends Activity { if(!isDelegatedActivity()) { super.onResume(); } - if(null != animator) { - animator.resume(); - animator.resetFPSCounter(); - } - for(int i=newtWindows.size()-1; i>=0; i--) { + for(int i=0; i Date: Fri, 7 Sep 2012 08:32:31 +0200 Subject: NEWT EDTUtil: Complete AWT and SWT impl. w/ Newt event dequeue thread (NEDT) AWT and SWT impl. use the toolkit thread to deliver toolkit events and to execute task. However, NEWT dispatches event using its own queue for NEWT events. Adding a simple thread to dequeue those. Remove 'EDTUtil.start()', since this is implicit @ invoke(). --- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 10 +- .../classes/com/jogamp/newt/swt/SWTEDTUtil.java | 217 ++++++++++++++++++-- src/newt/classes/com/jogamp/newt/util/EDTUtil.java | 40 +++- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 62 ++++-- src/newt/classes/jogamp/newt/DisplayImpl.java | 9 +- .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 221 ++++++++++++++++++--- .../jogamp/newt/driver/awt/DisplayDriver.java | 10 +- 7 files changed, 477 insertions(+), 92 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index f45b864fa..cada253bc 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -67,9 +67,6 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("Window"); private static final boolean isOSX = NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false); - /** SWT EDTUtil associated w/ parent's SWT Display */ - private final EDTUtil swtEDTUtil; - private final AbstractGraphicsScreen screen; private WindowClosingMode newtChildCloseOp = WindowClosingMode.DISPOSE_ON_CLOSE; @@ -117,8 +114,6 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { public NewtCanvasSWT(final Composite parent, final int style, Window child) { super(parent, style | SWT.NO_BACKGROUND); - swtEDTUtil = new SWTEDTUtil(parent.getDisplay()); - SWTAccessor.setRealized(this, true); clientArea = getClientArea(); @@ -326,8 +321,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { updateSizeCheck(); final int w = clientArea.width; final int h = clientArea.height; - - newtChild.getScreen().getDisplay().setEDTUtil(swtEDTUtil); + + final Display newtDisplay = newtChild.getScreen().getDisplay(); + newtDisplay.setEDTUtil(new SWTEDTUtil(newtDisplay, getDisplay())); newtChild.setSize(w, h); newtChild.reparentWindow(nativeWindow); diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java index 3538caad2..d4b83d891 100644 --- a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java @@ -27,7 +27,9 @@ */ package com.jogamp.newt.swt; -import org.eclipse.swt.widgets.Display; +import java.awt.EventQueue; + +import jogamp.newt.Debug; import com.jogamp.newt.util.EDTUtil; @@ -36,64 +38,243 @@ import com.jogamp.newt.util.EDTUtil; * of the given {@link Display}. */ public class SWTEDTUtil implements EDTUtil { - private final Display swtDisplay; + public static final boolean DEBUG = Debug.debug("EDT"); + + private final Object edtLock = new Object(); // locking the EDT start/stop state + private final ThreadGroup threadGroup; + private final String name; + private final Runnable dispatchMessages; + private final org.eclipse.swt.widgets.Display swtDisplay; + private NewtEventDispatchThread nedt = null; + private int start_iter=0; + private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; - public SWTEDTUtil(Display swtDisplay) { + public SWTEDTUtil(final com.jogamp.newt.Display newtDisplay, org.eclipse.swt.widgets.Display swtDisplay) { + this.threadGroup = Thread.currentThread().getThreadGroup(); + this.name=Thread.currentThread().getName()+"-SWTDisplay-"+newtDisplay.getFQName()+"-EDT-"; + this.dispatchMessages = new Runnable() { + public void run() { + ((jogamp.newt.DisplayImpl) newtDisplay).dispatchMessages(); + } }; this.swtDisplay = swtDisplay; + this.nedt = new NewtEventDispatchThread(threadGroup, name); + this.nedt.setDaemon(true); // don't stop JVM from shutdown .. } - public final Display getDisplay() { + public final org.eclipse.swt.widgets.Display getDisplay() { return swtDisplay; } @Override public long getPollPeriod() { - return 0; + return pollPeriod; } @Override public void setPollPeriod(long ms) { + pollPeriod = ms; } @Override public void reset() { + synchronized(edtLock) { + waitUntilStopped(); + if(DEBUG) { + System.err.println(Thread.currentThread()+": EDT reset - edt: "+nedt); + } + this.nedt = new NewtEventDispatchThread(threadGroup, name); + this.nedt.setDaemon(true); // don't stop JVM from shutdown .. + } } - @Override - public void start() { + private final void startImpl() { + if(nedt.isAlive()) { + throw new RuntimeException("EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); + } + start_iter++; + nedt.setName(name+start_iter); + nedt.shouldStop = false; + if(DEBUG) { + System.err.println(Thread.currentThread()+": EDT START - edt: "+nedt); + // Thread.dumpStack(); + } + nedt.start(); } - + @Override public boolean isCurrentThreadEDT() { return swtDisplay.getThread() == Thread.currentThread(); } + @Override + public final boolean isCurrentThreadNEDT() { + return nedt == Thread.currentThread(); + } + + @Override + public final boolean isCurrentThreadEDTorNEDT() { + final Thread ct = Thread.currentThread(); + return ct == swtDisplay.getThread() || ct == nedt ; + } + @Override public boolean isRunning() { - return true; + return nedt.isRunning() ; // SWT is always running } - + @Override - public void invokeStop(Runnable finalTask) { - swtDisplay.syncExec(finalTask); + public final void invokeStop(Runnable task) { + invokeImpl(true, task, true); } @Override - public void invoke(boolean wait, Runnable task) { + public final void invoke(boolean wait, Runnable task) { + invokeImpl(wait, task, false); + } + + private void invokeImpl(boolean wait, Runnable task, boolean stop) { + if(task == null) { + throw new RuntimeException("Null Runnable"); + } + synchronized(edtLock) { // lock the EDT status + if( nedt.shouldStop ) { + // drop task .. + if(DEBUG) { + System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt); + Thread.dumpStack(); + } + return; + } + // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); + // Thread.dumpStack(); + if(stop) { + nedt.shouldStop = true; + if(DEBUG) { + System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); + // Thread.dumpStack(); + } + } + + // start if should not stop && not started yet + if( !stop && !nedt.isRunning() ) { + startImpl(); + } + } if(wait) { swtDisplay.syncExec(task); } else { swtDisplay.asyncExec(task); } - } + } @Override - public void waitUntilIdle() { - // all sync .. + final public void waitUntilIdle() { + final NewtEventDispatchThread _edt; + synchronized(edtLock) { + _edt = nedt; + } + if(!_edt.isRunning() || EventQueue.isDispatchThread() || _edt == Thread.currentThread()) { + return; + } + try { + swtDisplay.syncExec(new Runnable() { + public void run() { } + }); + } catch (Exception e) { } } @Override - public void waitUntilStopped() { - // all sync .. + final public void waitUntilStopped() { + synchronized(edtLock) { + if(nedt.isRunning() && nedt != Thread.currentThread() ) { + while(nedt.isRunning()) { + try { + edtLock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } } + + class NewtEventDispatchThread extends Thread { + volatile boolean shouldStop = false; + volatile boolean isRunning = false; + Object sync = new Object(); + + public NewtEventDispatchThread(ThreadGroup tg, String name) { + super(tg, name); + } + + final public boolean isRunning() { + return isRunning; + } + + @Override + final public void start() throws IllegalThreadStateException { + isRunning = true; + super.start(); + } + + /** + * Utilizing locking only on tasks and its execution, + * not for event dispatching. + */ + @Override + final public void run() { + if(DEBUG) { + System.err.println(getName()+": EDT run() START "+ getName()); + } + RuntimeException error = null; + try { + do { + // event dispatch + if(!shouldStop) { + // FIXME: Determine whether we require to run the + // delivery of events (dispatch) on AWT-EDT. + // Since the WindowDriver itself delivers all Window related events, + // this shall not be required. + // AWTEDTExecutor.singleton.invoke(true, dispatchMessages); + dispatchMessages.run(); + } + // wait + synchronized(sync) { + if(!shouldStop) { + try { + sync.wait(pollPeriod); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } while(!shouldStop) ; + } catch (Throwable t) { + // handle errors .. + shouldStop = true; + if(t instanceof RuntimeException) { + error = (RuntimeException) t; + } else { + error = new RuntimeException("Within EDT", t); + } + } finally { + if(DEBUG) { + System.err.println(getName()+": EDT run() END "+ getName()+", "+error); + } + synchronized(edtLock) { + isRunning = !shouldStop; + if(!isRunning) { + edtLock.notifyAll(); + } + } + if(DEBUG) { + System.err.println(getName()+": EDT run() EXIT "+ getName()+", exception: "+error); + } + if(null!=error) { + throw error; + } + } // finally + } // run() + } // EventDispatchThread + } diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index 4493e2781..7e19d9de5 100644 --- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -28,6 +28,9 @@ package com.jogamp.newt.util; +import jogamp.newt.DisplayImpl; +import com.jogamp.newt.event.NEWTEvent; + /** * EDT stands for Event Dispatch Thread. *

@@ -63,25 +66,46 @@ public interface EDTUtil { /** * Create a new EDT. One should invoke reset()
- * after invokeStop(..) in case another start() or invoke(..) + * after invokeStop(..) in case another start via invoke(..) * is expected. * - * @see #start() * @see #invoke(boolean, java.lang.Runnable) * @see #invokeStop(java.lang.Runnable) */ public void reset(); /** - * Start the EDT + * Returns true if the current thread is the event dispatch thread (EDT). + *

+ * The EDT is the platform specific thread dispatching toolkit-events + * and executing toolkit-tasks enqueued via {@link #invoke(boolean, Runnable)}. + *

+ *

+ * Usually it is the same thread as used to dequeue informal {@link NEWTEvent}s (NEDT), see {@link #isCurrentThreadNEDT()}, + * however, this may differ, e.g. SWT and AWT implementation. + *

*/ - public void start(); + public boolean isCurrentThreadEDT(); /** - * @return True if the current thread is the EDT thread + * Returns true if the current thread is the internal NEWT event dequeue thread (NEDT). + *

+ * The NEDT is the NEWT thread used to dequeue informal {@link NEWTEvent}s enqueued internally + * via {@link DisplayImpl#enqueueEvent(boolean, NEWTEvent)}. + *

+ *

+ * Usually it is the same thread as the EDT, see {@link #isCurrentThreadEDT()}, + * however, this may differ, e.g. SWT and AWT implementation. + *

*/ - public boolean isCurrentThreadEDT(); - + public boolean isCurrentThreadNEDT(); + + /** + * Returns true if either {@link #isCurrentThreadEDT()} or {@link #isCurrentThreadNEDT()} is true, + * otherwise false. + */ + public boolean isCurrentThreadEDTorNEDT(); + /** * @return True if EDT is running */ @@ -101,9 +125,9 @@ public interface EDTUtil { public void invokeStop(Runnable finalTask); /** + * Shall start the thread if not running.
* Append task to the EDT task queue.
* Wait until execution is finished if wait == true.
- * Shall start the thread if not running.
* Can be issued from within EDT, ie from within an enqueued task.
* * @throws RuntimeException in case EDT is stopped and not {@link #reset()} diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index bdbe96070..18418a8dc 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -49,12 +49,12 @@ import com.jogamp.newt.util.EDTUtil; public class DefaultEDTUtil implements EDTUtil { public static final boolean DEBUG = Debug.debug("EDT"); - private ThreadGroup threadGroup; + private final Object edtLock = new Object(); // locking the EDT start/stop state + private final ThreadGroup threadGroup; + private final String name; + private final Runnable dispatchMessages; private EventDispatchThread edt = null; - private Object edtLock = new Object(); // locking the EDT start/stop state - private String name; - int start_iter=0; - private Runnable dispatchMessages; + private int start_iter=0; private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; public DefaultEDTUtil(ThreadGroup tg, String name, Runnable dispatchMessages) { @@ -65,14 +65,17 @@ public class DefaultEDTUtil implements EDTUtil { this.edt.setDaemon(true); // don't stop JVM from shutdown .. } + @Override final public long getPollPeriod() { return pollPeriod; } + @Override final public void setPollPeriod(long ms) { pollPeriod = ms; } + @Override public final void reset() { synchronized(edtLock) { waitUntilStopped(); @@ -88,36 +91,46 @@ public class DefaultEDTUtil implements EDTUtil { } } - public final void start() { - synchronized(edtLock) { - if(!edt.isRunning() && !edt.shouldStop) { - if(edt.isAlive()) { - throw new RuntimeException("EDT Thread.isAlive(): true, isRunning: "+edt.isRunning()+", edt: "+edt+", tasks: "+edt.tasks.size()); - } - start_iter++; - edt.setName(name+start_iter); - edt.shouldStop = false; - if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT START - edt: "+edt); - // Thread.dumpStack(); - } - edt.start(); - } + private final void startImpl() { + if(edt.isAlive()) { + throw new RuntimeException("EDT Thread.isAlive(): true, isRunning: "+edt.isRunning()+", edt: "+edt+", tasks: "+edt.tasks.size()); } + start_iter++; + edt.setName(name+start_iter); + edt.shouldStop = false; + if(DEBUG) { + System.err.println(Thread.currentThread()+": EDT START - edt: "+edt); + // Thread.dumpStack(); + } + edt.start(); } + @Override public final boolean isCurrentThreadEDT() { - return edt == Thread.currentThread(); + return edt == Thread.currentThread(); // EDT == NEDT + } + + @Override + public final boolean isCurrentThreadNEDT() { + return edt == Thread.currentThread(); // EDT == NEDT } + @Override + public final boolean isCurrentThreadEDTorNEDT() { + return edt == Thread.currentThread(); // EDT == NEDT + } + + @Override public final boolean isRunning() { return edt.isRunning() ; } + @Override public final void invokeStop(Runnable task) { invokeImpl(true, task, true); } + @Override public final void invoke(boolean wait, Runnable task) { invokeImpl(wait, task, false); } @@ -158,8 +171,11 @@ public class DefaultEDTUtil implements EDTUtil { } } } else { + // start if should not stop && not started yet + if( !stop && !edt.isRunning() ) { + startImpl(); + } synchronized(edt.tasks) { - start(); // start if not started yet and !shouldStop wait = wait && edt.isRunning(); rTask = new RunnableTask(task, wait ? rTaskLock : null, @@ -195,6 +211,7 @@ public class DefaultEDTUtil implements EDTUtil { } } + @Override final public void waitUntilIdle() { final EventDispatchThread _edt; synchronized(edtLock) { @@ -215,6 +232,7 @@ public class DefaultEDTUtil implements EDTUtil { } } + @Override final public void waitUntilStopped() { synchronized(edtLock) { if(edt.isRunning() && edt != Thread.currentThread() ) { diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index bac4031f0..bca7f6e5b 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -169,8 +169,7 @@ public abstract class DisplayImpl extends Display { public EDTUtil setEDTUtil(EDTUtil newEDTUtil) { if(null == newEDTUtil) { newEDTUtil = createEDTUtil(); - } - if( newEDTUtil == edtUtil ) { + } else if( newEDTUtil == edtUtil ) { if(DEBUG) { System.err.println("Display.setEDTUtil: "+newEDTUtil+" - keep!"); } @@ -366,7 +365,7 @@ public abstract class DisplayImpl extends Display { DisplayImpl.this.dispatchMessages(); } } - DispatchMessagesRunnable dispatchMessagesRunnable = new DispatchMessagesRunnable(); + protected DispatchMessagesRunnable dispatchMessagesRunnable = new DispatchMessagesRunnable(); final void dispatchMessage(final NEWTEventTask eventTask) { final NEWTEvent event = eventTask.get(); @@ -446,8 +445,8 @@ public abstract class DisplayImpl extends Display { return; } - // can't wait if we are on EDT -> consume right away - if(wait && edtUtil.isCurrentThreadEDT()) { + // can't wait if we are on EDT or NEDT -> consume right away + if(wait && edtUtil.isCurrentThreadEDTorNEDT() ) { dispatchMessage(new NEWTEventTask(e, null)); return; } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 942651187..8771f5c74 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -28,72 +28,239 @@ package jogamp.newt.driver.awt; -import javax.media.opengl.Threading; +import java.awt.EventQueue; import com.jogamp.newt.util.EDTUtil; + +import jogamp.common.awt.AWTEDTExecutor; import jogamp.newt.Debug; public class AWTEDTUtil implements EDTUtil { public static final boolean DEBUG = Debug.debug("EDT"); - - private static AWTEDTUtil singletonMainThread = new AWTEDTUtil(); // one singleton MainThread - public static AWTEDTUtil getSingleton() { - return singletonMainThread; - } + private final Object edtLock = new Object(); // locking the EDT start/stop state + private final ThreadGroup threadGroup; + private final String name; + private final Runnable dispatchMessages; + private NewtEventDispatchThread nedt = null; + private int start_iter=0; + private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; - AWTEDTUtil() { - // package private access .. + public AWTEDTUtil(ThreadGroup tg, String name, Runnable dispatchMessages) { + this.threadGroup = tg; + this.name=Thread.currentThread().getName()+"-"+name+"-EDT-"; + this.dispatchMessages=dispatchMessages; + this.nedt = new NewtEventDispatchThread(threadGroup, name); + this.nedt.setDaemon(true); // don't stop JVM from shutdown .. } + @Override final public long getPollPeriod() { - return 0; + return pollPeriod; } + @Override final public void setPollPeriod(long ms) { - // nop + pollPeriod = ms; } + @Override final public void reset() { - // nop AWT is always running + synchronized(edtLock) { + waitUntilStopped(); + if(DEBUG) { + System.err.println(Thread.currentThread()+": EDT reset - edt: "+nedt); + } + this.nedt = new NewtEventDispatchThread(threadGroup, name); + this.nedt.setDaemon(true); // don't stop JVM from shutdown .. + } } - final public void start() { - // nop AWT is always running + private final void startImpl() { + if(nedt.isAlive()) { + throw new RuntimeException("EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); + } + start_iter++; + nedt.setName(name+start_iter); + nedt.shouldStop = false; + if(DEBUG) { + System.err.println(Thread.currentThread()+": EDT START - edt: "+nedt); + // Thread.dumpStack(); + } + nedt.start(); } + @Override final public boolean isCurrentThreadEDT() { - return Threading.isToolkitThread(); + return EventQueue.isDispatchThread(); } + @Override + public final boolean isCurrentThreadNEDT() { + return nedt == Thread.currentThread(); + } + + @Override + public final boolean isCurrentThreadEDTorNEDT() { + return EventQueue.isDispatchThread() || nedt == Thread.currentThread(); + } + + @Override final public boolean isRunning() { - return true; // AWT is always running + return nedt.isRunning() ; // AWT is always running } - final public void invokeStop(Runnable r) { - invoke(true, r); // AWT is always running + @Override + public final void invokeStop(Runnable task) { + invokeImpl(true, task, true); } - final public void invoke(boolean wait, Runnable r) { - if(r == null) { - return; - } - - Threading.invoke(wait, r, null); + @Override + public final void invoke(boolean wait, Runnable task) { + invokeImpl(wait, task, false); } + + private void invokeImpl(boolean wait, Runnable task, boolean stop) { + if(task == null) { + throw new RuntimeException("Null Runnable"); + } + synchronized(edtLock) { // lock the EDT status + if( nedt.shouldStop ) { + // drop task .. + if(DEBUG) { + System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt); + Thread.dumpStack(); + } + return; + } + // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); + // Thread.dumpStack(); + if(stop) { + nedt.shouldStop = true; + if(DEBUG) { + System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); + // Thread.dumpStack(); + } + } + + // start if should not stop && not started yet + if( !stop && !nedt.isRunning() ) { + startImpl(); + } + } + AWTEDTExecutor.singleton.invoke(wait, task); + } + @Override final public void waitUntilIdle() { - // wait until previous events are processed, at least .. + final NewtEventDispatchThread _edt; + synchronized(edtLock) { + _edt = nedt; + } + if(!_edt.isRunning() || EventQueue.isDispatchThread() || _edt == Thread.currentThread()) { + return; + } try { - Threading.invoke(true, new Runnable() { + AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { } - }, null); + }); } catch (Exception e) { } } + @Override final public void waitUntilStopped() { - // nop: AWT is always running + synchronized(edtLock) { + if(nedt.isRunning() && nedt != Thread.currentThread() ) { + while(nedt.isRunning()) { + try { + edtLock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } } + + class NewtEventDispatchThread extends Thread { + volatile boolean shouldStop = false; + volatile boolean isRunning = false; + Object sync = new Object(); + + public NewtEventDispatchThread(ThreadGroup tg, String name) { + super(tg, name); + } + + final public boolean isRunning() { + return isRunning; + } + + @Override + final public void start() throws IllegalThreadStateException { + isRunning = true; + super.start(); + } + + /** + * Utilizing locking only on tasks and its execution, + * not for event dispatching. + */ + @Override + final public void run() { + if(DEBUG) { + System.err.println(getName()+": EDT run() START "+ getName()); + } + RuntimeException error = null; + try { + do { + // event dispatch + if(!shouldStop) { + // FIXME: Determine whether we require to run the + // delivery of events (dispatch) on AWT-EDT. + // Since the WindowDriver itself delivers all Window related events, + // this shall not be required. + // AWTEDTExecutor.singleton.invoke(true, dispatchMessages); + dispatchMessages.run(); + } + // wait + synchronized(sync) { + if(!shouldStop) { + try { + sync.wait(pollPeriod); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } while(!shouldStop) ; + } catch (Throwable t) { + // handle errors .. + shouldStop = true; + if(t instanceof RuntimeException) { + error = (RuntimeException) t; + } else { + error = new RuntimeException("Within EDT", t); + } + } finally { + if(DEBUG) { + System.err.println(getName()+": EDT run() END "+ getName()+", "+error); + } + synchronized(edtLock) { + isRunning = !shouldStop; + if(!isRunning) { + edtLock.notifyAll(); + } + } + if(DEBUG) { + System.err.println(getName()+": EDT run() EXIT "+ getName()+", exception: "+error); + } + if(null!=error) { + throw error; + } + } // finally + } // run() + } // EventDispatchThread + } diff --git a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java index 39d96585b..70e9ba570 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java @@ -38,6 +38,7 @@ import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.util.EDTUtil; +import jogamp.newt.DefaultEDTUtil; import jogamp.newt.DisplayImpl; public class DisplayDriver extends DisplayImpl { @@ -52,15 +53,12 @@ public class DisplayDriver extends DisplayImpl { aDevice = d; } - protected void closeNativeImpl() { } - - @Override protected EDTUtil createEDTUtil() { final EDTUtil def; if(NewtFactory.useEDT()) { - def = AWTEDTUtil.getSingleton(); + def = new AWTEDTUtil(Thread.currentThread().getThreadGroup(), "AWTDisplay-"+getFQName(), dispatchMessagesRunnable); if(DEBUG) { - System.err.println("AWTDisplay.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName()); + System.err.println("Display.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName()); } } else { def = null; @@ -68,6 +66,8 @@ public class DisplayDriver extends DisplayImpl { return def; } + protected void closeNativeImpl() { } + protected void dispatchMessagesNative() { /* nop */ } } -- cgit v1.2.3 From d22ac65d0f841e4c3698ec817d4ebbfdb7ee25a0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 7 Sep 2012 08:34:32 +0200 Subject: NEWT AWT Driver: Remove flashing (clear background @ update/paint method) ; Proper canvas size and direct events. --- make/scripts/tests.sh | 4 +- .../jogamp/newt/event/awt/AWTWindowAdapter.java | 28 ++++++-- .../classes/jogamp/newt/driver/awt/AWTCanvas.java | 28 +++++++- .../jogamp/newt/driver/awt/WindowDriver.java | 78 +++++++++++++++++----- .../demos/gl2/newt/TestGearsNewtAWTWrapper.java | 20 +++++- 5 files changed, 131 insertions(+), 27 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5668893f7..ce04ae4dc 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -261,7 +261,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT -testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT @@ -331,7 +331,7 @@ testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* #testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* -#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java index 69b0d0482..2d63ca455 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java @@ -28,6 +28,8 @@ package com.jogamp.newt.event.awt; +import java.awt.Dimension; + import jogamp.newt.awt.event.AWTNewtEventFactory; public class AWTWindowAdapter @@ -61,9 +63,9 @@ public class AWTWindowAdapter if(awtComponent instanceof java.awt.Window) { ((java.awt.Window)awtComponent).addWindowListener(this); } - return this; + return this; } - + public AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeFocusListener(this); awtComponent.removeComponentListener(this); @@ -89,6 +91,9 @@ public class AWTWindowAdapter public void focusGained(java.awt.event.FocusEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + if(DEBUG_IMPLEMENTATION) { + System.err.println("AWT: focusGained: "+e+" -> "+event); + } if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowGainedFocus(event); } else { @@ -98,6 +103,9 @@ public class AWTWindowAdapter public void focusLost(java.awt.event.FocusEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + if(DEBUG_IMPLEMENTATION) { + System.err.println("AWT: focusLost: "+e+" -> "+event); + } if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowLostFocus(event); } else { @@ -108,7 +116,19 @@ public class AWTWindowAdapter public void componentResized(java.awt.event.ComponentEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { - System.err.println("AWT: componentResized: "+event); + final java.awt.Component c = e.getComponent(); + final java.awt.Dimension sz = c.getSize(); + final java.awt.Insets insets; + final java.awt.Dimension sz2; + if(c instanceof java.awt.Container) { + insets = ((java.awt.Container)c).getInsets(); + sz2 = new Dimension(sz.width - insets.left - insets.right, + sz.height - insets.top - insets.bottom); + } else { + insets = null; + sz2 = sz; + } + System.err.println("AWT: componentResized: "+sz+" ( "+insets+", "+sz2+" ), "+e+" -> "+event); } if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowResized(event); @@ -120,7 +140,7 @@ public class AWTWindowAdapter public void componentMoved(java.awt.event.ComponentEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { - System.err.println("AWT: componentMoved: "+event); + System.err.println("AWT: componentMoved: "+e+" -> "+event); } if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowMoved(event); diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index b3fdcad41..17eb6a2fb 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -35,6 +35,7 @@ package jogamp.newt.driver.awt; import java.awt.Canvas; +import java.awt.Graphics; import java.awt.GraphicsDevice; import java.awt.GraphicsConfiguration; import java.lang.reflect.Method; @@ -61,14 +62,16 @@ public class AWTCanvas extends Canvas { private GraphicsConfiguration chosen; private AWTGraphicsConfiguration awtConfig; + private WindowDriver newtWindowImpl; private CapabilitiesChooser chooser=null; private CapabilitiesImmutable capabilities; private boolean displayConfigChanged=false; - public AWTCanvas(CapabilitiesImmutable capabilities, CapabilitiesChooser chooser) { + public AWTCanvas(WindowDriver newtWindowImpl, CapabilitiesImmutable capabilities, CapabilitiesChooser chooser) { super(); + this.newtWindowImpl = newtWindowImpl; if(null==capabilities) { throw new NativeWindowException("Capabilities null"); } @@ -80,6 +83,25 @@ public class AWTCanvas extends Canvas { return awtConfig; } + /** + * Overridden from Canvas to prevent the AWT's clearing of the + * canvas from interfering with the OpenGL rendering. + */ + @Override + public void update(Graphics g) { + paint(g); + } + + /** Overridden to cause OpenGL rendering to be performed during + repaint cycles. Subclasses which override this method must call + super.paint() in their paint() method in order to function + properly. + */ + @Override + public void paint(Graphics g) { + newtWindowImpl.windowRepaint(0, 0, getWidth(), getHeight()); + } + public boolean hasDeviceChanged() { boolean res = displayConfigChanged; displayConfigChanged=false; @@ -275,10 +297,10 @@ public class AWTCanvas extends Canvas { private void disableBackgroundErase() { if (!disableBackgroundEraseInitialized) { try { - AccessController.doPrivileged(new PrivilegedAction() { + AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { - Class clazz = getToolkit().getClass(); + Class clazz = getToolkit().getClass(); while (clazz != null && disableBackgroundEraseMethod == null) { try { disableBackgroundEraseMethod = diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index 1723ffee5..bee43a95e 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -36,6 +36,7 @@ package jogamp.newt.driver.awt; import java.awt.BorderLayout; import java.awt.Container; +import java.awt.Dimension; import java.awt.Frame; import java.awt.Insets; @@ -47,6 +48,8 @@ import jogamp.newt.WindowImpl; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowUpdateEvent; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTMouseAdapter; import com.jogamp.newt.event.awt.AWTWindowAdapter; @@ -107,18 +110,18 @@ public class WindowDriver extends WindowImpl { frame.setTitle(getTitle()); } container.setLayout(new BorderLayout()); - canvas = new AWTCanvas(capsRequested, WindowDriver.this.capabilitiesChooser); - - addWindowListener(new LocalWindowListener()); - - new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here - new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here + + canvas = new AWTCanvas(this, capsRequested, WindowDriver.this.capabilitiesChooser); // canvas.addComponentListener(listener); container.add(canvas, BorderLayout.CENTER); - container.setSize(getWidth(), getHeight()); - container.setLocation(getX(), getY()); - new AWTWindowAdapter(this).addTo(container); // fwd all AWT Window events to here + + // via EDT .. + new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here + new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here + + // direct w/o EDT + new AWTWindowAdapter(new LocalWindowListener(), this).addTo(canvas); // fwd all AWT Window events to here reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true)); // throws exception if failed .. @@ -174,20 +177,32 @@ public class WindowDriver extends WindowImpl { frame.setUndecorated(isUndecorated()); } else { if(DEBUG_IMPLEMENTATION) { - System.err.println("AWTWindow can't undecorate already created frame"); + System.err.println(getThreadName()+": AWTWindow can't undecorate already created frame"); } } } + final Dimension szClient = new Dimension(width, height); + canvas.setMinimumSize(szClient); + canvas.setPreferredSize(szClient); + canvas.setSize(szClient); + if(DEBUG_IMPLEMENTATION) { + final Insets insets = container.getInsets(); + final Dimension szContainer = new Dimension(width + insets.left + insets.right, + height + insets.top + insets.bottom); + System.err.println(getThreadName()+": AWTWindow new size: szClient "+szClient+", szCont "+szContainer+", insets "+insets); + } + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + if(null != frame) { + frame.pack(); + } + container.validate(); container.setVisible(0 != ( FLAG_IS_VISIBLE & flags)); } container.setLocation(x, y); - Insets insets = container.getInsets(); - container.setSize(width + insets.left + insets.right, - height + insets.top + insets.bottom); - + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { if( 0 != ( FLAG_IS_VISIBLE & flags ) ) { if( !hasDeviceChanged() ) { @@ -200,6 +215,12 @@ public class WindowDriver extends WindowImpl { } } visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } else { + container.invalidate(); + if(null != frame) { + frame.pack(); + } + container.validate(); } return true; @@ -216,18 +237,41 @@ public class WindowDriver extends WindowImpl { return canvas; } - class LocalWindowListener extends com.jogamp.newt.event.WindowAdapter { + class LocalWindowListener implements com.jogamp.newt.event.WindowListener { @Override public void windowMoved(com.jogamp.newt.event.WindowEvent e) { if(null!=container) { - definePosition(container.getX(), container.getY()); + WindowDriver.this.positionChanged(false, container.getX(), container.getY()); } } @Override public void windowResized(com.jogamp.newt.event.WindowEvent e) { if(null!=canvas) { - defineSize(canvas.getWidth(), canvas.getHeight()); + WindowDriver.this.sizeChanged(false, canvas.getWidth(), canvas.getHeight(), false); + } + } + @Override + public void windowDestroyNotify(WindowEvent e) { + WindowDriver.this.windowDestroyNotify(false); + } + @Override + public void windowDestroyed(WindowEvent e) { + if(isNativeValid()) { + WindowDriver.this.windowDestroyNotify(true); } + + } + @Override + public void windowGainedFocus(WindowEvent e) { + WindowDriver.this.focusChanged(false, true); + } + @Override + public void windowLostFocus(WindowEvent e) { + WindowDriver.this.focusChanged(false, false); + } + @Override + public void windowRepaint(WindowUpdateEvent e) { + WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight()); } } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java index 62914bd4e..cc20cc27e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java @@ -33,6 +33,7 @@ import javax.media.opengl.*; import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -78,8 +79,25 @@ public class TestGearsNewtAWTWrapper extends UITestCase { glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); - glWindow.setSize(width, height); + int div = 3; + glWindow.setSize(width/div, height/div); glWindow.setVisible(true); + glWindow.display(); + Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), + AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); + + div = 2; + glWindow.setSize(width/div, height/div); + glWindow.display(); + Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), + AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); + + div = 1; + glWindow.setSize(width/div, height/div); + glWindow.display(); + Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), + AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); + animator.setUpdateFPSFrames(1, null); animator.start(); -- cgit v1.2.3 From 4dd44b985fe0541be3a3bcd9045d201ed3ca2cc5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 15 Sep 2012 16:54:52 +0200 Subject: Seamless Integration of an FBObject based GLFBODrawable as GLOffscreenAutoDrawable.FBO and as an OffscreenLayerSurface's drawable (OSX) - Fix Bugs 569 and 599 Summary: ========= The new FBObject based GLFBODrawable implementation allows the seamless utilization of FBO offscreen rendering in single buffer, double buffer and MSAA mode. The GLFBODrawable uses a parent drawable based on a dummy surface to allow a GLOffscreenAutoDrawable.FBO creation or a mutable surface supporting an existing offscreen layer surface (OSX CALayer). Offscreen GLDrawable's and GLOffscreenAutoDrawable's can be selected via the GLCapabilities. If simply !onscreen is selected in the caps instance w/o enabling FBO, PBuffer or Bitmap, the factory will automatically choose regarding availability: FBO > PBuffer > Bitmap Double buffering is supported in MSAA more (intrinsic) and explicit in non MSAA. It is preferred when delivering resources (texture id's or framebuffer names) to a shared GLContext. This is demonstrated in (emulates our OSX CALayer implementation): TestFBOOffThreadSharedContextMix2DemosES2NEWT, TestFBOOnThreadSharedContext1DemoES2NEWT and with the OSX JAWT OffscreenLayerSurface itself. FBO is the preferred choice. +++ Offscreen drawables can be resized while maintaining a bound GLContext (e.g. w/ GLAutoDrawable). Previously both, drawable and context, needed to be destroyed and recreated at offscreen resize. Common implementation in GLDrawableHelper is used in the implementations (NEWT's GLWindow, AWT GLCanvas, SWT GLCanvas). +++ Tested: ======= Manually run all unit tests on: - Linux x86_64 NVidia/AMD/Mesa3d(ES) - OSX x86_64 NVidia - Windows x86_64 NVidia - Android arm Mali-400/Tegra-2 No regressions. Disclaimer: =========== This feature is committed almost in one patch. Both previous commits were introducing / fixing the capabilities behavior: 90d45928186f2be99999461cfe45f76a783cc961 9036376b7806a5fc61590bf49404eb71830de92f I have to appologize for the huge size and impact (files and platforms) of this commit however, I could not find a better way to inject this feature in one sane piece. NativeWindow Details: ===================== Complete decoupling of platform impl. detail of surfaces implementing ProxySurface. Used to generalize dummy surfaces and EGL surfaces on top of a native platform surface. - ProxySurface.UpstreamSurfaceHook -> UpstreamSurfaceHook - abstract class ProxySurface -> interface ProxySurface + ProxySurfaceImpl - Misc. implementations JOGL Details: ===================== FBOObject: API Change / Simplification & Usability - Removed reference counter to remove complexity, allow user to choose. - Add 'dispose' flag for detachColorbuffer(..), allowing to keep attachment alive - Fix equals operation of Attachment - Check pre-exising GL errors - Interface Colobuffer gets lifecycle methods - Add static factory methods to create Attachments w/o FBObject instance - Reset: - Clip min size to 1 - Keep alive samplingSink, i.e. don't issue resetMSAATexture2DSink(..). It gets called at syncFramebuffer()/use(..) later on before actual usage. This allows the consumer to utilize the GL_FRONT buffer until (e.g.) swap. - misc bugfixes GLOffscreenAutoDrawable: API Change - Reloc and interfacing - class com.jogamp.opengl.OffscreenAutoDrawable -> javax.media.opengl.* interfaces GLOffscreenAutoDrawable extends GLAutoDrawable GLOffscreenAutoDrawable.FBO extends GLOffscreenAutoDrawable, GLFBODrawable - Added general implementation and FBO specialization - Replacing GLPBuffer (deprecated) .. usable for any offscreen GLDrawable via factory GLAutoDrawable: - Add 'GLDrawable getDelegatedDrawable()' - Refine documentation of setContext(..), remove disclaimer and fixme tags GLDrawableFactory: - Refine API doc and it's selection mechanism for offscreen. - Add createOffscreenDrawable(..) - Add createOffscreenAutoDrawable(..) - Add canCreateFBO(..) - Mark createGLPbuffer(..) deprectated Mark GLPBuffer deprecated New: GLFBODrawable extends GLDrawable GLCanvas (AWT and SWT): Add offscreen resize support w/o GLContext recreation GLAutoDrawableBase .. GLWindow: - Add offscreen resize support w/o GLContext recreation - Remove double swapBuffer call - GLBase/GLContext: - Add: - boolean hasBasicFBOSupport() - boolean hasFullFBOSupport() - int getMaxRenderbufferSamples() - boolean isTextureFormatBGRA8888Available() GLContext: Fix version detection and hasGLSL() - Version detection in setGLFunctionAvailability(..) - Query GL_VERSION ASAP and parse it and compare w/ given major/minor - Use parsed version if valid and lower than given _or_ given is invalid. - Use validated version for caching (procaddr, ..), version number, etc. - Fix hasGLSL() Since 'isGL2ES2()' is true if 'isGL2()' and the latter simply alows GL 1.*, we confine the result to a GL >= 2.0 on desktops. FIXME: May consider GL 1.5 w/ extensions. - return isGL2ES2(); + return isGLES2() || + isGL3() || + isGL2() && ctxMajorVersion>1 ; GLDrawableImpl: - Add 'associateContext(GLContext, boolean)' allowing impl. to have a (weak) reference list of bound context. This is was pulled up from the OSX specific drawable impl. - swapBuffersImpl() -> swapBuffersImpl(boolean doubleBuffered) and call it regardless of single buffering. This is required to propagate this event to impl. properly, i.e. FBODrawable requires a swap notification. - Clarify 'contextMadeCurrent(..)' protocol GLDrawableHelper: - Add resize and recreate offscreen drawable util method - Simplify required init/reshape calls for GLEventListener - GLGraphicsConfigurationUtil: - fixWinAttribBitsAndHwAccel: Reflect sharede context hw-accel bits - OSX has no offscreen bitmap, use pbuffer - use proper offscreen auto selection if offscreen and no modes are set EGL Context/Drawable/DrawableFactory: Abstract native platform code out of base classes - Use EGLWrappedSurface w/ UpstreamSurfaceHook to handle upstream (X11, WGL, ..) lifecycle - in case the EGL resource is hooked up on it. Invisible dummy surfaces: All platforms - size is now reduced to 64x64 and decoupled of actual generic mutable size - fix device lifecycle, no more leaks +++ OSX ==== Enable support for GLFBODrawableImpl in offscreen CALayer mode - NSOpenGLImpl: hooks to calayer native code - calayer code: - allows pbuffer and texures (FBO) - decouple size and draw calls avoiding flickering - enable auto resize of calayer tree MacOSXCGLContext: - NSOpenGLImpl: - Fix false pbuffer 'usage', validate the pointer - If !pbuffer, copy other window mode bits of caps - MacOSXCGLGraphicsConfiguration: - Only assume pbuffer if !onscreen - Remove reference of native pixelformat pointer Native code: - use 'respondsToSelector:' query before calling 'new' methods avoiding an error message where unsuported (prev. OSX versions) - if monitor refresh-rate is queried 0, set to default 60hz - add missing NSAutoreleasePool decoration +++ Android / NEWT: =============== Issue setVisible(..) w/o wait, i.e. queue on EDT, @Android surfaceChanged() callback. Otherwise we could deadlock: setVisible(..) -> EDT -> setVisibleImpl(..) -> 'GL-display'. the latter may may cause havoc while Android-EDT is blocked [until it's return]. --- doc/TODO.txt | 12 - make/build-jogl.xml | 2 +- .../config/jogl/gl-impl-CustomJavaCode-common.java | 20 + make/scripts/java-win64-dbg.bat | 4 +- make/scripts/tests-x64.bat | 45 +- make/scripts/tests.sh | 50 +- make/stub_includes/opengl/macosx-window-system.h | 11 +- src/jogl/classes/com/jogamp/opengl/FBObject.java | 882 +++++++++++++-------- .../com/jogamp/opengl/GLAutoDrawableDelegate.java | 189 +++++ .../classes/com/jogamp/opengl/GLExtensions.java | 3 + .../com/jogamp/opengl/OffscreenAutoDrawable.java | 112 --- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 41 +- .../classes/javax/media/opengl/GLAutoDrawable.java | 38 +- .../javax/media/opengl/GLAutoDrawableDelegate.java | 144 ---- src/jogl/classes/javax/media/opengl/GLBase.java | 38 + src/jogl/classes/javax/media/opengl/GLContext.java | 97 ++- .../javax/media/opengl/GLDrawableFactory.java | 128 ++- .../classes/javax/media/opengl/GLFBODrawable.java | 173 ++++ .../media/opengl/GLOffscreenAutoDrawable.java | 63 ++ src/jogl/classes/javax/media/opengl/GLPbuffer.java | 6 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 119 +-- .../classes/javax/media/opengl/awt/GLJPanel.java | 13 +- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 76 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 175 ++-- .../jogamp/opengl/GLDrawableFactoryImpl.java | 127 +-- .../classes/jogamp/opengl/GLDrawableHelper.java | 185 ++++- src/jogl/classes/jogamp/opengl/GLDrawableImpl.java | 80 +- .../classes/jogamp/opengl/GLFBODrawableImpl.java | 496 ++++++++++-- .../jogamp/opengl/GLGraphicsConfigurationUtil.java | 28 +- .../jogamp/opengl/GLOffscreenAutoDrawableImpl.java | 123 +++ src/jogl/classes/jogamp/opengl/GLPbufferImpl.java | 31 +- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 6 - .../classes/jogamp/opengl/egl/EGLDrawable.java | 135 ++-- .../jogamp/opengl/egl/EGLDrawableFactory.java | 163 +--- .../opengl/egl/EGLDummyUpstreamSurfaceHook.java | 49 ++ .../jogamp/opengl/egl/EGLExternalContext.java | 11 - .../jogamp/opengl/egl/EGLGLCapabilities.java | 5 +- .../opengl/egl/EGLGraphicsConfiguration.java | 9 +- .../jogamp/opengl/egl/EGLOnscreenContext.java | 11 - .../jogamp/opengl/egl/EGLOnscreenDrawable.java | 4 +- .../jogamp/opengl/egl/EGLPbufferContext.java | 10 - .../jogamp/opengl/egl/EGLPbufferDrawable.java | 8 +- .../jogamp/opengl/egl/EGLUpstreamSurfaceHook.java | 145 +++- .../jogamp/opengl/egl/EGLWrappedSurface.java | 26 + .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 716 ++++++++++------- .../opengl/macosx/cgl/MacOSXCGLDrawable.java | 48 +- .../macosx/cgl/MacOSXCGLDrawableFactory.java | 71 +- .../macosx/cgl/MacOSXCGLGraphicsConfiguration.java | 21 +- .../cgl/MacOSXCGLGraphicsConfigurationFactory.java | 2 +- .../macosx/cgl/MacOSXExternalCGLContext.java | 7 +- .../macosx/cgl/MacOSXOnscreenCGLDrawable.java | 4 +- .../opengl/macosx/cgl/MacOSXPbufferCGLContext.java | 1 + .../macosx/cgl/MacOSXPbufferCGLDrawable.java | 42 +- .../windows/wgl/WindowsExternalWGLContext.java | 4 +- .../windows/wgl/WindowsExternalWGLDrawable.java | 4 +- .../opengl/windows/wgl/WindowsWGLDrawable.java | 43 +- .../windows/wgl/WindowsWGLDrawableFactory.java | 58 +- .../wgl/WindowsWGLGraphicsConfiguration.java | 29 +- .../WindowsWGLGraphicsConfigurationFactory.java | 28 +- .../opengl/x11/glx/X11ExternalGLXContext.java | 4 +- .../opengl/x11/glx/X11ExternalGLXDrawable.java | 5 +- .../jogamp/opengl/x11/glx/X11GLXDrawable.java | 7 +- .../opengl/x11/glx/X11GLXDrawableFactory.java | 63 +- .../x11/glx/X11GLXGraphicsConfiguration.java | 6 +- .../glx/X11GLXGraphicsConfigurationFactory.java | 6 +- .../opengl/x11/glx/X11PbufferGLXDrawable.java | 17 +- .../macosx/MacOSXWindowSystemInterface-calayer.m | 665 ++++++++++++++++ .../macosx/MacOSXWindowSystemInterface-pbuffer.m | 494 ------------ .../native/macosx/MacOSXWindowSystemInterface.m | 40 +- .../DelegatedUpstreamSurfaceHookMutableSize.java | 39 + ...elegatedUpstreamSurfaceHookWithSurfaceSize.java | 54 ++ .../UpstreamSurfaceHookMutableSize.java | 45 ++ .../com/jogamp/nativewindow/WrappedSurface.java | 78 -- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 99 ++- .../jogamp/nativewindow/egl/EGLGraphicsDevice.java | 4 +- .../javax/media/nativewindow/NativeSurface.java | 5 +- .../media/nativewindow/OffscreenLayerSurface.java | 3 + .../javax/media/nativewindow/ProxySurface.java | 266 ++----- .../media/nativewindow/UpstreamSurfaceHook.java | 52 ++ .../jogamp/nativewindow/ProxySurfaceImpl.java | 326 ++++++++ .../jogamp/nativewindow/WrappedSurface.java | 95 +++ .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 84 +- .../macosx/OSXDummyUpstreamSurfaceHook.java | 56 ++ .../jogamp/nativewindow/macosx/OSXUtil.java | 15 + .../windows/GDIDummyUpstreamSurfaceHook.java | 50 ++ .../jogamp/nativewindow/windows/GDISurface.java | 34 +- .../x11/X11DummyUpstreamSurfaceHook.java | 60 ++ src/nativewindow/native/macosx/OSXmisc.m | 189 +++-- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 9 + .../classes/com/jogamp/newt/opengl/GLWindow.java | 25 +- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 3 + src/newt/classes/jogamp/newt/OffscreenWindow.java | 31 +- src/newt/classes/jogamp/newt/WindowImpl.java | 34 +- .../jogamp/newt/driver/android/WindowDriver.java | 2 +- .../jogamp/newt/driver/macosx/WindowDriver.java | 24 +- src/newt/native/MacWindow.m | 49 +- .../test/android/MovieCubeActivityLauncher0.java | 2 + .../android/NEWTGraphUI1pActivityLauncher.java | 22 +- .../jogl/acore/TestFBOAutoDrawableDeadlockAWT.java | 128 +++ .../jogl/acore/TestFBOAutoDrawableFactoryNEWT.java | 375 +++++++++ .../test/junit/jogl/acore/TestFBODrawableNEWT.java | 272 ------- .../test/junit/jogl/acore/TestFBOMRTNEWT01.java | 2 +- .../junit/jogl/acore/TestFBOMix2DemosES2NEWT.java | 2 +- ...tFBOOffThreadSharedContextMix2DemosES2NEWT.java | 298 +++++++ .../TestFBOOnThreadSharedContext1DemoES2NEWT.java | 273 +++++++ .../jogl/acore/TestGLAutoDrawableDelegateNEWT.java | 152 ---- ...estGLAutoDrawableDelegateOnOffscrnCapsNEWT.java | 384 +++++++++ .../TestGLAutoDrawableFactoryOffscrnCapsNEWT.java | 317 ++++++++ ...TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java | 328 ++++++++ ...estGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java | 351 ++++++++ ...LAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java | 300 +++++++ .../junit/jogl/acore/TestGLCapabilities01NEWT.java | 266 ------- .../acore/TestGLContextDrawableSwitchNEWT.java | 22 +- .../junit/jogl/acore/TestGLDrawable01NEWT.java | 171 ---- .../jogl/acore/TestGLExtensionQueryOffscreen.java | 19 +- .../jogl/acore/TestNEWTCloseX11DisplayBug565.java | 46 +- .../acore/TestOffscreenLayer01GLCanvasAWT.java | 236 ++++++ .../acore/TestOffscreenLayer02NewtCanvasAWT.java | 233 ++++++ .../junit/jogl/acore/TestPBufferDeadlockAWT.java | 2 + .../junit/jogl/acore/TestSharedContextListAWT.java | 20 +- .../jogl/acore/TestSharedContextListNEWT.java | 20 +- .../jogl/acore/TestSharedContextListNEWT2.java | 14 +- .../jogl/acore/TestSharedContextNewtAWTBug523.java | 17 +- .../jogl/acore/TestSharedContextVBOES1NEWT.java | 20 +- .../jogl/acore/TestSharedContextVBOES2NEWT.java | 20 +- .../jogl/acore/TestSharedContextVBOES2NEWT2.java | 14 +- .../awt/TestBug461FBOSupersamplingSwingAWT.java | 159 ++++ .../TestBug461OffscreenSupersamplingSwingAWT.java | 157 ---- .../TestBug461PBufferSupersamplingSwingAWT.java | 159 ++++ .../junit/jogl/caps/TestMultisampleES1AWT.java | 2 +- .../junit/jogl/caps/TestMultisampleES1NEWT.java | 2 +- .../junit/jogl/caps/TestMultisampleES2NEWT.java | 2 +- .../opengl/test/junit/jogl/demos/es1/GearsES1.java | 6 + .../test/junit/jogl/demos/es1/RedSquareES1.java | 19 +- .../test/junit/jogl/demos/es2/FBOMix2DemosES2.java | 5 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 17 +- .../test/junit/jogl/demos/es2/Mix2TexturesES2.java | 216 +++++ .../test/junit/jogl/demos/es2/RedSquareES2.java | 21 +- .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 27 +- .../opengl/test/junit/jogl/demos/gl2/Gears.java | 13 +- .../jogl/demos/gl2/awt/TestGLJPanelAWTBug450.java | 2 +- .../test/junit/jogl/offscreen/ReadBufferBase.java | 2 +- .../test/junit/jogl/swt/TestNewtCanvasSWTGLn.java | 2 +- .../junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java | 2 +- .../TestGLReadBufferUtilTextureIOWrite01AWT.java | 4 +- .../TestGLReadBufferUtilTextureIOWrite01NEWT.java | 16 +- .../TestGLReadBufferUtilTextureIOWrite02AWT.java | 2 +- .../TestGLReadBufferUtilTextureIOWrite02NEWT.java | 2 +- .../util/texture/TestPNGTextureFromFileAWT.java | 2 +- .../util/texture/TestPNGTextureFromFileNEWT.java | 2 +- .../test/junit/newt/TestFocus01SwingAWTRobot.java | 21 +- .../test/junit/newt/TestFocus02SwingAWTRobot.java | 16 +- .../opengl/test/junit/newt/TestWindows01NEWT.java | 1 - .../parenting/NewtAWTReparentingKeyAdapter.java | 2 +- .../TestParentingOffscreenLayer01GLCanvasAWT.java | 211 ----- ...TestParentingOffscreenLayer02NewtCanvasAWT.java | 221 ------ .../opengl/test/junit/util/AWTRobotUtil.java | 39 +- .../opengl/test/junit/util/NEWTGLContext.java | 4 +- .../jogamp/opengl/test/junit/util/UITestCase.java | 109 ++- 159 files changed, 9357 insertions(+), 4643 deletions(-) create mode 100644 src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java delete mode 100644 src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java delete mode 100644 src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java create mode 100644 src/jogl/classes/javax/media/opengl/GLFBODrawable.java create mode 100644 src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java create mode 100644 src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java create mode 100644 src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java create mode 100644 src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java create mode 100644 src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m delete mode 100644 src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m create mode 100644 src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java create mode 100644 src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java create mode 100644 src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java delete mode 100644 src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java create mode 100644 src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer02NewtCanvasAWT.java (limited to 'src/newt/classes') diff --git a/doc/TODO.txt b/doc/TODO.txt index 20a7a9071..0ce1fd3ac 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -1,13 +1,6 @@ Version 2.0: -- Fix ES2 detection if it fails (no egl pbuffer on nokia es2) ? - SIGG slides / video -- FBO Drawable w/ given NativeSurface - and OSX w/ JAWT - - Bug 569 - - Bug 599 - -- cleanup jocl build/jar/demos -- clean up . in jar names in all docs and tutorials - ES3 / GL 4.3 @@ -15,11 +8,6 @@ Version 2.0: WIP: -- GLPbuffer -> GLOffscreenAutoDrawable - - GLPbuffer GLDrawableFactory.createPbuffer() -> - GLOffscreenAutoDrawable GLDrawableFactory.createOffsceenAutoDrawable() - - Mark both deprecated! - - Optimize/Fix NIO caching of glMapBuffer/glUnmapBuffer - optimize the NIO caching, i.e. memory range, incr. reference count - _remove_ the cached object w/ decr. ref count, remove object diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 40859845c..a72d6c77c 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1375,7 +1375,7 @@ - + diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java index b05ba2643..283a4e623 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-common.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java @@ -50,6 +50,26 @@ return null; } + @Override + public final boolean hasBasicFBOSupport() { + return _context.hasBasicFBOSupport(); + } + + @Override + public final boolean hasFullFBOSupport() { + return _context.hasFullFBOSupport(); + } + + @Override + public final int getMaxRenderbufferSamples() { + return _context.getMaxRenderbufferSamples(); + } + + @Override + public final boolean isTextureFormatBGRA8888Available() { + return _context.isTextureFormatBGRA8888Available(); + } + @Override public final GLContext getContext() { return _context; diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 510ebf4dc..b63438534 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -30,13 +30,15 @@ REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dn REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.NativeLibrary=true" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.ExtensionAvailabilityCache" "-Djogamp.debug.ProcAddressHelper=true" REM set D_ARGS="-Djogl.debug.GraphicsConfiguration" +REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.GLDrawable" "-Dnativewindow.debug.GraphicsConfiguration" REM set D_ARGS="-Djogamp.debug.JNILibLoader=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLProfile=true" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.Lock" "-Djogamp.debug.Lock.TraceLock" -set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" +REM set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" +set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 22cce49aa..a4207b696 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -1,9 +1,9 @@ REM scripts\java-win64-dbg.bat jogamp.newt.awt.opengl.VersionApplet REM scripts\java-win64-dbg.bat com.jogamp.newt.opengl.GLWindow REM scripts\java-win64-dbg.bat javax.media.opengl.awt.GLCanvas -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT $* -scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn @@ -40,13 +40,13 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestP REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT @@ -73,9 +73,9 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.caps.TestMultis REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn %* @@ -96,16 +96,25 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtD REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT +scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* + +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ce04ae4dc..d2e2db375 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -32,7 +32,7 @@ MOSX=0 MOSX_MT=0 uname -a | grep -i Darwin && MOSX=1 if [ $MOSX -eq 1 ] ; then - #export NSZombieEnabled=YES + export NSZombieEnabled=YES MOSX_MT=1 fi @@ -56,11 +56,13 @@ function jrun() { #D_ARGS="-Djogl.disable.opengles" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Dnewt.debug.Window.MouseEvent" #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" + #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.fbo.force.none" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug=all" @@ -208,7 +210,7 @@ function testawtswt() { } # -# newt (testnoawt and testawt) +# core/newt (testnoawt and testawt) # #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* @@ -237,6 +239,26 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* + +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* + +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT + +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* + #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* @@ -331,10 +353,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* #testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* -testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* @@ -376,24 +396,6 @@ testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $* -# -# FBO / .. -# - -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable00NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01bNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable02NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableMix2DemosES2NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* - # # Graph # diff --git a/make/stub_includes/opengl/macosx-window-system.h b/make/stub_includes/opengl/macosx-window-system.h index 47b51a509..c627f67de 100644 --- a/make/stub_includes/opengl/macosx-window-system.h +++ b/make/stub_includes/opengl/macosx-window-system.h @@ -13,6 +13,7 @@ #include #include #include +#include typedef int Bool; @@ -51,12 +52,13 @@ NSOpenGLPixelBuffer* createPBuffer(int renderTarget, int internalFormat, int wid Bool destroyPBuffer(NSOpenGLPixelBuffer* pBuffer); void setContextPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer); void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer, GLenum colorBuffer); +Bool isNSOpenGLPixelBuffer(uint64_t object); -// NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSView* view, Bool opaque); -NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* pbuffer, Bool opaque, int texWidth, int texHeight); +NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, uint32_t texID, Bool opaque, int texWidth, int texHeight); void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval); void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_micros); -void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* glLayer); +void flushNSOpenGLLayerPBuffer(NSOpenGLLayer* layer); +void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* layer, NSOpenGLPixelBuffer* p, uint32_t texID, int texWidth, int texHeight); void releaseNSOpenGLLayer(NSOpenGLLayer *glLayer); void* getProcAddress(const char *procName); @@ -67,6 +69,3 @@ void setSwapInterval(NSOpenGLContext* ctx, int interval); Bool setGammaRamp(int tableSize, float* redRamp, float* greenRamp, float* blueRamp); void resetGammaRamp(); -/* returns the screen refresh rate in Hz */ -int getScreenRefreshRate(int scrn_idx); - diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java index 8a6495e6b..cc0af29a9 100644 --- a/src/jogl/classes/com/jogamp/opengl/FBObject.java +++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java @@ -35,6 +35,7 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2GL3; import javax.media.opengl.GL3; import javax.media.opengl.GLBase; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -61,55 +62,33 @@ public class FBObject { protected static final boolean DEBUG = Debug.debug("FBObject"); private static final boolean forceMinimumFBOSupport = Debug.isPropertyDefined("jogl.fbo.force.min", true); + private static enum DetachAction { NONE, DISPOSE, RECREATE }; + /** - * Returns true if basic FBO support is available, otherwise false. - *

- * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= core 3.0 or implements the extensions - * ARB_ES2_compatibility, ARB_framebuffer_object, EXT_framebuffer_object or OES_framebuffer_object. - *

- *

- * Basic FBO support may only include one color attachment and no multisampling, - * as well as limited internal formats for renderbuffer. - *

- * @see GLContext#hasFBO() - */ - public static final boolean supportsBasicFBO(GL gl) { - return gl.getContext().hasFBO(); - } - - /** - * Returns true if full FBO support is available, otherwise false. - *

- * Full FBO is supported if the context is either GL >= core 3.0 or implements the extensions - * ARB_framebuffer_object, or all of - * EXT_framebuffer_object, EXT_framebuffer_multisample, - * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil. - *

- *

- * Full FBO support includes multiple color attachments and multisampling. - *

+ * Marker interface, denotes a color buffer attachment. + *

Always an instance of {@link Attachment}.

+ *

Either an instance of {@link ColorAttachment} or {@link TextureAttachment}. */ - public static final boolean supportsFullFBO(GL gl) { - return !forceMinimumFBOSupport && - ( gl.isGL3() || // GL >= 3.0 - gl.isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object - - ( gl.isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object* - gl.isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) && - gl.isExtensionAvailable(GLExtensions.EXT_framebuffer_blit) && - gl.isExtensionAvailable(GLExtensions.EXT_packed_depth_stencil) - ) - ) ; - } - - public static final int getMaxSamples(GL gl) { - if( supportsFullFBO(gl) ) { - int[] val = new int[] { 0 } ; - gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0); - return val[0]; - } else { - return 0; - } + public static interface Colorbuffer { + /** + * Initializes the color buffer and set it's parameter, if uninitialized, i.e. name is zero. + * @return true if newly initialized, otherwise false. + * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case. + */ + public boolean initialize(GL gl) throws GLException; + + /** + * Releases the color buffer if initialized, i.e. name is not zero. + * @throws GLException if buffer release fails. + */ + public void free(GL gl) throws GLException; + + /** + * Writes the internal format to the given GLCapabilities object. + * @param caps the destination for format bits + * @param rgba8Avail whether rgba8 is available + */ + public void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail); } /** Common super class of all attachments */ @@ -155,21 +134,89 @@ public class FBObject { private int name; - /** true if resource is initialized by {@link #initialize(GL)}, hence {@link #free(GL)} is allowed to free the GL resources. */ - protected boolean resourceOwner; - - private int initCounter; - protected Attachment(Type type, int iFormat, int width, int height, int name) { this.type = type; this.format = iFormat; this.width = width; this.height = height; this.name = name; - this.resourceOwner = false; - this.initCounter = 0; } + /** + * Writes the internal format to the given GLCapabilities object. + * @param caps the destination for format bits + * @param rgba8Avail whether rgba8 is available + */ + public final void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail) { + final int _format; + switch(format) { + case GL.GL_RGBA: + _format = rgba8Avail ? GL.GL_RGBA8 : GL.GL_RGBA4; + break; + case GL.GL_RGB: + _format = rgba8Avail ? GL.GL_RGB8 : GL.GL_RGB565; + break; + default: + _format = format; + } + switch(_format) { + case GL.GL_RGBA4: + caps.setRedBits(4); + caps.setGreenBits(4); + caps.setBlueBits(4); + caps.setAlphaBits(4); + break; + case GL.GL_RGB5_A1: + caps.setRedBits(5); + caps.setGreenBits(5); + caps.setBlueBits(5); + caps.setAlphaBits(1); + break; + case GL.GL_RGB565: + caps.setRedBits(5); + caps.setGreenBits(6); + caps.setBlueBits(5); + caps.setAlphaBits(0); + break; + case GL.GL_RGB8: + caps.setRedBits(8); + caps.setGreenBits(8); + caps.setBlueBits(8); + caps.setAlphaBits(0); + break; + case GL.GL_RGBA8: + caps.setRedBits(8); + caps.setGreenBits(8); + caps.setBlueBits(8); + caps.setAlphaBits(8); + break; + case GL.GL_DEPTH_COMPONENT16: + caps.setDepthBits(16); + break; + case GL.GL_DEPTH_COMPONENT24: + caps.setDepthBits(24); + break; + case GL.GL_DEPTH_COMPONENT32: + caps.setDepthBits(32); + break; + case GL.GL_STENCIL_INDEX1: + caps.setStencilBits(1); + break; + case GL.GL_STENCIL_INDEX4: + caps.setStencilBits(4); + break; + case GL.GL_STENCIL_INDEX8: + caps.setStencilBits(8); + break; + case GL.GL_DEPTH24_STENCIL8: + caps.setDepthBits(24); + caps.setStencilBits(8); + break; + default: + throw new IllegalArgumentException("format invalid: 0x"+Integer.toHexString(format)); + } + } + /** width of attachment */ public final int getWidth() { return width; } /** height of attachment */ @@ -180,45 +227,31 @@ public class FBObject { public final int getName() { return name; } /* pp */ final void setName(int n) { name = n; } - public final int getInitCounter() { return initCounter; } - /** - * Initializes the attachment buffer and set it's parameter, if uninitialized, i.e. name is zero. - *

Implementation employs an initialization counter, hence it can be paired recursively with {@link #free(GL)}.

- * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case. - */ - public void initialize(GL gl) throws GLException { - initCounter++; - /* - super.initialize(gl); - if(1 == getInitCounter() && 0 == getName() ) { + * Initializes the attachment and set it's parameter, if uninitialized, i.e. name is zero. + *
+            final boolean init = 0 == name;
+            if( init ) {
                 do init ..
-                freeResources = true; // if all OK
             }
-            */
-        }
+            return init;
+         * 
+ * @return true if newly initialized, otherwise false. + * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case. + */ + public abstract boolean initialize(GL gl) throws GLException; /** - * Releases the attachment buffer if initialized, i.e. name is zero. - *

Implementation employs an initialization counter, hence it can be paired recursively with {@link #initialize(GL)}.

- * @throws GLException if buffer release fails. - */ - public void free(GL gl) throws GLException { - /* - if(1 == getInitCounter() && freeResources && .. ) { + * Releases the attachment if initialized, i.e. name is not zero. + *
+            if(0 != name) {
                 do free ..
-            }
-            super.free(gl);
-            */
-            initCounter--;
-            if(0 == initCounter) {
-                resourceOwner = false;
                 name = 0;
             }
-            if(DEBUG) {
-                System.err.println("Attachment.free: "+this);
-            }
-        }
+         * 
+ * @throws GLException if buffer release fails. + */ + public abstract void free(GL gl) throws GLException; /** *

@@ -232,9 +265,9 @@ public class FBObject { if( ! ( o instanceof Attachment ) ) return false; final Attachment a = (Attachment)o; return type == a.type && - format == a.format || - width == a.width || - height== a.height || + format == a.format && + width == a.width && + height== a.height && name == a.name ; } @@ -259,8 +292,7 @@ public class FBObject { public String toString() { return getClass().getSimpleName()+"[type "+type+", format 0x"+Integer.toHexString(format)+", "+width+"x"+height+ - ", name 0x"+Integer.toHexString(name)+", obj 0x"+Integer.toHexString(objectHashCode())+ - ", resOwner "+resourceOwner+", initCount "+initCounter+"]"; + ", name 0x"+Integer.toHexString(name)+", obj 0x"+Integer.toHexString(objectHashCode())+"]"; } public static Type getType(int attachmentPoint, int maxColorAttachments) { @@ -277,7 +309,7 @@ public class FBObject { } } } - + /** Other renderbuffer attachment which maybe a colorbuffer, depth or stencil. */ public static class RenderAttachment extends Attachment { private int samples; @@ -339,14 +371,13 @@ public class FBObject { } @Override - public void initialize(GL gl) throws GLException { - super.initialize(gl); - if( 1 == getInitCounter() && 0 == getName() ) { + public boolean initialize(GL gl) throws GLException { + final boolean init = 0 == getName(); + if( init ) { + int glerr = checkPreGLError(gl); + final int[] name = new int[] { -1 }; gl.glGenRenderbuffers(1, name, 0); - if( 0 == name[0] ) { - throw new GLException("null renderbuffer, "+this); - } setName(name[0]); gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, getName()); @@ -355,43 +386,37 @@ public class FBObject { } else { gl.glRenderbufferStorage(GL.GL_RENDERBUFFER, format, getWidth(), getHeight()); } - int glerr = gl.glGetError(); + glerr = gl.glGetError(); if(GL.GL_NO_ERROR != glerr) { gl.glDeleteRenderbuffers(1, name, 0); setName(0); throw new GLException("GL Error 0x"+Integer.toHexString(glerr)+" while creating "+this); } - resourceOwner = true; if(DEBUG) { System.err.println("Attachment.init: "+this); } } + return init; } @Override public void free(GL gl) { - if(1 == getInitCounter() && resourceOwner && 0 != getName() ) { - final int[] name = new int[] { getName() }; + final int[] name = new int[] { getName() }; + if( 0 != name[0] ) { gl.glDeleteRenderbuffers(1, name, 0); + setName(0); + if(DEBUG) { + System.err.println("Attachment.free: "+this); + } } - super.free(gl); } public String toString() { return getClass().getSimpleName()+"[type "+type+", format 0x"+Integer.toHexString(format)+", samples "+samples+", "+getWidth()+"x"+getHeight()+ - ", name 0x"+Integer.toHexString(getName())+", obj 0x"+Integer.toHexString(objectHashCode())+ - ", resOwner "+resourceOwner+", initCount "+getInitCounter()+"]"; + ", name 0x"+Integer.toHexString(getName())+", obj 0x"+Integer.toHexString(objectHashCode())+"]"; } } - /** - * Marker interface, denotes a color buffer attachment. - *

Always an instance of {@link Attachment}.

- *

Either an instance of {@link ColorAttachment} or {@link TextureAttachment}. - */ - public static interface Colorbuffer { - } - /** Color render buffer attachment */ public static class ColorAttachment extends RenderAttachment implements Colorbuffer { public ColorAttachment(int iFormat, int samples, int width, int height, int name) { @@ -444,9 +469,11 @@ public class FBObject { * @throws GLException if texture generation and setup fails. The just created texture name will be deleted in this case. */ @Override - public void initialize(GL gl) throws GLException { - super.initialize(gl); - if( 1 == getInitCounter() && 0 == getName() ) { + public boolean initialize(GL gl) throws GLException { + final boolean init = 0 == getName(); + if( init ) { + int glerr = checkPreGLError(gl); + final int[] name = new int[] { -1 }; gl.glGenTextures(1, name, 0); if(0 == name[0]) { @@ -468,31 +495,111 @@ public class FBObject { if( 0 < wrapT ) { gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, wrapT); } - int glerr = gl.glGetError(); + glerr = gl.glGetError(); if(GL.GL_NO_ERROR != glerr) { gl.glDeleteTextures(1, name, 0); setName(0); throw new GLException("GL Error 0x"+Integer.toHexString(glerr)+" while creating "+this); } - resourceOwner = true; - } - if(DEBUG) { - System.err.println("Attachment.init: "+this); + if(DEBUG) { + System.err.println("Attachment.init: "+this); + } } + return init; } @Override public void free(GL gl) { - if(1 == getInitCounter() && resourceOwner && 0 != getName() ) { - final int[] name = new int[] { getName() }; + final int[] name = new int[] { getName() }; + if( 0 != name[0] ) { gl.glDeleteTextures(1, name, 0); + setName(0); + if(DEBUG) { + System.err.println("Attachment.free: "+this); + } } - super.free(gl); + } + } + + /** + * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}, + * selecting the texture data type and format automatically. + * + *

Using default min/mag filter {@link GL#GL_NEAREST} and default wrapS/wrapT {@link GL#GL_CLAMP_TO_EDGE}.

+ * + * @param glp the chosen {@link GLProfile} + * @param alpha set to true if you request alpha channel, otherwise false; + * @param width texture width + * @param height texture height + * @return the created and uninitialized color {@link TextureAttachment} + */ + public static final TextureAttachment createColorTextureAttachment(GLProfile glp, boolean alpha, int width, int height) { + return createColorTextureAttachment(glp, alpha, width, height, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); + } + + /** + * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}, + * selecting the texture data type and format automatically. + * + * @param glp the chosen {@link GLProfile} + * @param alpha set to true if you request alpha channel, otherwise false; + * @param width texture width + * @param height texture height + * @param magFilter if > 0 value for {@link GL#GL_TEXTURE_MAG_FILTER} + * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} + * @param wrapS if > 0 value for {@link GL#GL_TEXTURE_WRAP_S} + * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} + * @return the created and uninitialized color {@link TextureAttachment} + */ + public static final TextureAttachment createColorTextureAttachment(GLProfile glp, boolean alpha, int width, int height, + int magFilter, int minFilter, int wrapS, int wrapT) { + final int textureInternalFormat, textureDataFormat, textureDataType; + if(glp.isGLES()) { + textureInternalFormat = alpha ? GL.GL_RGBA : GL.GL_RGB; + textureDataFormat = alpha ? GL.GL_RGBA : GL.GL_RGB; + textureDataType = GL.GL_UNSIGNED_BYTE; + } else { + textureInternalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8; + textureDataFormat = alpha ? GL.GL_BGRA : GL.GL_RGB; + textureDataType = alpha ? GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV : GL.GL_UNSIGNED_BYTE; + } + return createColorTextureAttachment(textureInternalFormat, width, height, textureDataFormat, textureDataType, magFilter, minFilter, wrapS, wrapT); + } + + /** + * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}. + * + * @param internalFormat internalFormat parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} + * @param width texture width + * @param height texture height + * @param dataFormat format parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} + * @param dataType type parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} + * @param magFilter if > 0 value for {@link GL#GL_TEXTURE_MAG_FILTER} + * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} + * @param wrapS if > 0 value for {@link GL#GL_TEXTURE_WRAP_S} + * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} + * @return the created and uninitialized color {@link TextureAttachment} + */ + public static final TextureAttachment createColorTextureAttachment(int internalFormat, int width, int height, int dataFormat, int dataType, + int magFilter, int minFilter, int wrapS, int wrapT) { + return new TextureAttachment(Type.COLOR_TEXTURE, internalFormat, width, height, dataFormat, dataType, + magFilter, minFilter, wrapS, wrapT, 0 /* name */); + } + + private static boolean hasAlpha(int format) { + switch(format) { + case GL.GL_RGBA8: + case GL.GL_RGBA4: + case GL.GL_RGBA: + case GL.GL_BGRA: + case 4: + return true; + default: + return false; } } private boolean initialized; - private boolean basicFBOSupport; private boolean fullFBOSupport; private boolean rgba8Avail; private boolean depth24Avail; @@ -523,6 +630,9 @@ public class FBObject { // private final void validateColorAttachmentPointRange(int point) { + if(!initialized) { + throw new GLException("FBO not initialized"); + } if(maxColorAttachments != colorAttachmentPoints.length) { throw new InternalError("maxColorAttachments "+maxColorAttachments+", array.lenght "+colorAttachmentPoints); } @@ -621,7 +731,6 @@ public class FBObject { this.initialized = false; // TBD @ init - this.basicFBOSupport = false; this.fullFBOSupport = false; this.rgba8Avail = false; this.depth24Avail = false; @@ -657,14 +766,11 @@ public class FBObject { private void init(GL gl, int width, int height, int samples) throws GLException { if(initialized) { throw new GLException("FBO already initialized"); - } - fullFBOSupport = supportsFullFBO(gl); - - if( !fullFBOSupport && !supportsBasicFBO(gl) ) { + } + if( !gl.hasBasicFBOSupport() ) { throw new GLException("FBO not supported w/ context: "+gl.getContext()+", "+this); } - - basicFBOSupport = true; + fullFBOSupport = gl.hasFullFBOSupport(); rgba8Avail = gl.isGL2GL3() || gl.isExtensionAvailable(GLExtensions.OES_rgb8_rgba8); depth24Avail = fullFBOSupport || gl.isExtensionAvailable(GLExtensions.OES_depth24); @@ -680,10 +786,7 @@ public class FBObject { int val[] = new int[1]; - int glerr = gl.glGetError(); - if(DEBUG && GL.GL_NO_ERROR != glerr) { - System.err.println("FBObject.init-preexisting.0 GL Error 0x"+Integer.toHexString(glerr)); - } + int glerr = checkPreGLError(gl); int realMaxColorAttachments = 1; maxColorAttachments = 1; @@ -703,16 +806,7 @@ public class FBObject { colorAttachmentPoints = new Colorbuffer[maxColorAttachments]; colorAttachmentCount = 0; - maxSamples = 0; - if(fullFBOSupport) { - gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0); - glerr = gl.glGetError(); - if(GL.GL_NO_ERROR == glerr) { - maxSamples = val[0]; - } else if(DEBUG) { - System.err.println("FBObject.init-GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr)); - } - } + maxSamples = gl.getMaxRenderbufferSamples(); if(!forceMinimumFBOSupport) { gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0); maxTextureSize = val[0]; @@ -733,10 +827,9 @@ public class FBObject { this.samples = samples <= maxSamples ? samples : maxSamples; if(DEBUG) { - System.err.println("FBObject "+width+"x"+height+", "+samples+" -> "+samples+" samples"); - System.err.println("basicFBOSupport: "+basicFBOSupport); + System.err.println("FBObject "+width+"x"+height+", "+samples+" -> "+this.samples+" samples"); System.err.println("fullFBOSupport: "+fullFBOSupport); - System.err.println("maxColorAttachments: "+maxColorAttachments+"/"+realMaxColorAttachments); + System.err.println("maxColorAttachments: "+maxColorAttachments+"/"+realMaxColorAttachments+" [capped/real]"); System.err.println("maxSamples: "+maxSamples); System.err.println("maxTextureSize: "+maxTextureSize); System.err.println("maxRenderbufferSize: "+maxRenderbufferSize); @@ -761,12 +854,8 @@ public class FBObject { throw new GLException("size "+width+"x"+height+" exceeds on of the maxima [texture "+maxTextureSize+", renderbuffer "+maxRenderbufferSize+"]"); } - if(null != samplesSink) { - // init sampling sink - samplesSink.reset(gl, width, height); - resetMSAATexture2DSink(gl); - } - + resetMSAATexture2DSink(gl); + // generate fbo .. gl.glGenFramebuffers(1, val, 0); fbName = val[0]; @@ -780,7 +869,8 @@ public class FBObject { if(!gl.glIsFramebuffer(fbName)) { checkNoError(gl, GL.GL_INVALID_VALUE, "FBObject Init.isFB"); // throws GLException } - bound = true; + bound = true; + samplesSinkDirty = true; initialized = true; updateStatus(gl); @@ -797,7 +887,7 @@ public class FBObject { * to match the new given parameters. *

*

- * Currently incompatibility and hence recreation is given if + * Incompatibility and hence recreation is forced if * the size or sample count doesn't match for subsequent calls. *

* @@ -820,17 +910,17 @@ public class FBObject { * to match the new given parameters. *

*

- * Currently incompatibility and hence recreation is given if - * the size or sample count doesn't match for subsequent calls. + * Currently incompatibility and hence recreation of the attachments will be performed + * if the size or sample count doesn't match for subsequent calls. *

* *

Leaves the FBO bound state untouched

* * @param gl the current GL context - * @param newWidth - * @param newHeight + * @param newWidth the new width, it's minimum is capped to 1 + * @param newHeight the new height, it's minimum is capped to 1 * @param newSamples if > 0, MSAA will be used, otherwise no multisampling. Will be capped to {@link #getMaxSamples()}. - * @throws GLException in case of an error + * @throws GLException in case of an error, i.e. size too big, etc .. */ public final void reset(GL gl, int newWidth, int newHeight, int newSamples) { if(!initialized) { @@ -841,13 +931,15 @@ public class FBObject { newSamples = newSamples <= maxSamples ? newSamples : maxSamples; // clamp if( newWidth != width || newHeight != height || newSamples != samples ) { + if(0>=newWidth) { newWidth = 1; } + if(0>=newHeight) { newHeight = 1; } if(newWidth > 2 + maxTextureSize || newHeight> 2 + maxTextureSize || newWidth > maxRenderbufferSize || newHeight> maxRenderbufferSize ) { throw new GLException("size "+width+"x"+height+" exceeds on of the maxima [texture "+maxTextureSize+", renderbuffer "+maxRenderbufferSize+"]"); } if(DEBUG) { - System.err.println("FBObject.reset - START - "+this); + System.err.println("FBObject.reset - START - "+width+"x"+height+", "+samples+" -> "+newWidth+"x"+newHeight+", "+newSamples+"; "+this); } final boolean wasBound = isBound(); @@ -856,11 +948,18 @@ public class FBObject { height = newHeight; samples = newSamples; detachAllImpl(gl, true , true); - resetMSAATexture2DSink(gl); - if(wasBound) { - bind(gl); - } else { + /** + * Postpone reset of samplesSink until syncFramebuffer, + * issued at use(..) method (swapBuffer usually initiates it). + * This allows another thread to still use the 'samplesSinkTexture' + * until swapBuffer happens and does not invalidate the GL_FRONT + * FBO (framebuffer & texture). + resetMSAATexture2DSink(gl); + */ + samplesSinkDirty = true; + + if(!wasBound) { unbind(gl); } @@ -870,6 +969,28 @@ public class FBObject { } } + /** + * Writes the internal format of the attachments to the given GLCapabilities object. + * @param caps the destination for format bits + */ + public final void formatToGLCapabilities(GLCapabilities caps) { + caps.setSampleBuffers(samples > 0); + caps.setNumSamples(samples); + caps.setDepthBits(0); + caps.setStencilBits(0); + + final Colorbuffer cb = samples > 0 ? getSamplingSink() : getColorbuffer(0); + if(null != cb) { + cb.formatToGLCapabilities(caps, rgba8Avail); + } + if(null != depth) { + depth.formatToGLCapabilities(caps, rgba8Avail); + } + if(null != stencil && stencil != depth) { + stencil.formatToGLCapabilities(caps, rgba8Avail); + } + } + /** * Note that the status may reflect an incomplete state during transition of attachments. * @return The FB status. {@link GL.GL_FRAMEBUFFER_COMPLETE} if ok, otherwise return GL FBO error state or -1 @@ -954,6 +1075,15 @@ public class FBObject { } } + private static int checkPreGLError(GL gl) { + int glerr = gl.glGetError(); + if(DEBUG && GL.GL_NO_ERROR != glerr) { + System.err.println("Pre-existing GL error: 0x"+Integer.toHexString(glerr)); + Thread.dumpStack(); + } + return glerr; + } + private final boolean checkNoError(GL gl, int err, String exceptionMessage) throws GLException { if(GL.GL_NO_ERROR != err) { if(null != gl) { @@ -974,7 +1104,7 @@ public class FBObject { } /** - * Attaches a Texture2D Color Buffer to this FBO's instance at the given attachment point, + * Attaches a {@link Colorbuffer}, i.e. {@link TextureAttachment}, to this FBO's instance at the given attachment point, * selecting the texture data type and format automatically. * *

Using default min/mag filter {@link GL#GL_NEAREST} and default wrapS/wrapT {@link GL#GL_CLAMP_TO_EDGE}.

@@ -986,13 +1116,15 @@ public class FBObject { * @param alpha set to true if you request alpha channel, otherwise false; * @return TextureAttachment instance describing the new attached texture colorbuffer if bound and configured successfully, otherwise GLException is thrown * @throws GLException in case the texture colorbuffer couldn't be allocated or MSAA has been chosen + * @see #createColorTextureAttachment(GLProfile, boolean, int, int) */ public final TextureAttachment attachTexture2D(GL gl, int attachmentPoint, boolean alpha) throws GLException { - return attachTexture2D(gl, attachmentPoint, alpha, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); + return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, + createColorTextureAttachment(gl.getGLProfile(), alpha, width, height)); } /** - * Attaches a Texture2D Color Buffer to this FBO's instance at the given attachment point, + * Attaches a {@link Colorbuffer}, i.e. {@link TextureAttachment}, to this FBO's instance at the given attachment point, * selecting the texture data type and format automatically. * *

Leaves the FBO bound.

@@ -1006,23 +1138,15 @@ public class FBObject { * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} * @return TextureAttachment instance describing the new attached texture colorbuffer if bound and configured successfully, otherwise GLException is thrown * @throws GLException in case the texture colorbuffer couldn't be allocated or MSAA has been chosen + * @see #createColorTextureAttachment(GLProfile, boolean, int, int, int, int, int, int) */ public final TextureAttachment attachTexture2D(GL gl, int attachmentPoint, boolean alpha, int magFilter, int minFilter, int wrapS, int wrapT) throws GLException { - final int textureInternalFormat, textureDataFormat, textureDataType; - if(gl.isGLES()) { - textureInternalFormat = alpha ? GL.GL_RGBA : GL.GL_RGB; - textureDataFormat = alpha ? GL.GL_RGBA : GL.GL_RGB; - textureDataType = GL.GL_UNSIGNED_BYTE; - } else { - textureInternalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8; - textureDataFormat = alpha ? GL.GL_BGRA : GL.GL_RGB; - textureDataType = alpha ? GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV : GL.GL_UNSIGNED_BYTE; - } - return attachTexture2D(gl, attachmentPoint, textureInternalFormat, textureDataFormat, textureDataType, magFilter, minFilter, wrapS, wrapT); + return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, + createColorTextureAttachment(gl.getGLProfile(), alpha, width, height, magFilter, minFilter, wrapS, wrapT)); } /** - * Attaches a Texture2D Color Buffer to this FBO's instance at the given attachment point. + * Attaches a {@link Colorbuffer}, i.e. {@link TextureAttachment}, to this FBO's instance at the given attachment point. * *

Leaves the FBO bound.

* @@ -1037,66 +1161,33 @@ public class FBObject { * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} * @return TextureAttachment instance describing the new attached texture colorbuffer if bound and configured successfully, otherwise GLException is thrown * @throws GLException in case the texture colorbuffer couldn't be allocated or MSAA has been chosen + * @see #createColorTextureAttachment(int, int, int, int, int, int, int, int, int) */ public final TextureAttachment attachTexture2D(GL gl, int attachmentPoint, int internalFormat, int dataFormat, int dataType, int magFilter, int minFilter, int wrapS, int wrapT) throws GLException { - return attachTexture2D(gl, attachmentPoint, - new TextureAttachment(Type.COLOR_TEXTURE, internalFormat, width, height, dataFormat, dataType, - magFilter, minFilter, wrapS, wrapT, 0 /* name */)); + return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, + createColorTextureAttachment(internalFormat, width, height, dataFormat, dataType, magFilter, minFilter, wrapS, wrapT)); } /** - * Attaches a Texture2D Color Buffer to this FBO's instance at the given attachment point. + * Creates a {@link ColorAttachment}, selecting the format automatically. * - *

- * In case the passed TextureAttachment texA is uninitialized, i.e. it's texture name is zero, - * a new texture name is generated and setup w/ the texture parameter.
- * Otherwise, i.e. texture name is not zero, the passed TextureAttachment texA is - * considered complete and assumed matching this FBO requirement. A GL error may occur is the latter is untrue. - *

- * - *

Leaves the FBO bound.

- * - * @param gl the current GL context - * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] - * @param texA the to be attached {@link TextureAttachment}. Maybe complete or uninitialized, see above. - * @return the passed TextureAttachment texA instance describing the new attached texture colorbuffer if bound and configured successfully, otherwise GLException is thrown - * @throws GLException in case the texture colorbuffer couldn't be allocated or MSAA has been chosen + * @param alpha set to true if you request alpha channel, otherwise false; + * @return uninitialized ColorAttachment instance describing the new attached colorbuffer */ - public final TextureAttachment attachTexture2D(GL gl, int attachmentPoint, TextureAttachment texA) throws GLException { - validateAddColorAttachment(attachmentPoint, texA); - - if(samples>0) { - removeColorAttachment(attachmentPoint, texA); - throw new GLException("Texture2D not supported w/ MSAA. If you have enabled MSAA with exisiting texture attachments, you may want to detach them via detachAllTexturebuffer(gl)."); - } - - texA.initialize(gl); - addColorAttachment(attachmentPoint, texA); - - bind(gl); - - // Set up the color buffer for use as a renderable texture: - gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, - GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, - GL.GL_TEXTURE_2D, texA.getName(), 0); - - if(!ignoreStatus) { - updateStatus(gl); - if(!isStatusValid()) { - detachColorbuffer(gl, attachmentPoint); - throw new GLException("attachTexture2D "+texA+" at "+attachmentPoint+" failed "+getStatusString()+", "+this); - } - } - if(DEBUG) { - System.err.println("FBObject.attachTexture2D: "+this); + public final ColorAttachment createColorAttachment(boolean alpha) { + final int internalFormat; + if( rgba8Avail ) { + internalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8 ; + } else { + internalFormat = alpha ? GL.GL_RGBA4 : GL.GL_RGB565; } - return texA; + return new ColorAttachment(internalFormat, samples, width, height, 0); } - + /** - * Attaches a Color Buffer to this FBO's instance at the given attachment point, + * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment}, to this FBO's instance at the given attachment point, * selecting the format automatically. * *

Leaves the FBO bound.

@@ -1106,19 +1197,14 @@ public class FBObject { * @param alpha set to true if you request alpha channel, otherwise false; * @return ColorAttachment instance describing the new attached colorbuffer if bound and configured successfully, otherwise GLException is thrown * @throws GLException in case the colorbuffer couldn't be allocated + * @see #createColorAttachment(boolean) */ public final ColorAttachment attachColorbuffer(GL gl, int attachmentPoint, boolean alpha) throws GLException { - final int internalFormat; - if( rgba8Avail ) { - internalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8 ; - } else { - internalFormat = alpha ? GL.GL_RGBA4 : GL.GL_RGB565; - } - return attachColorbuffer(gl, attachmentPoint, internalFormat); + return (ColorAttachment) attachColorbuffer(gl, attachmentPoint, createColorAttachment(alpha)); } /** - * Attaches a Color Buffer to this FBO's instance at the given attachment point. + * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment}, to this FBO's instance at the given attachment point. * *

Leaves the FBO bound.

* @@ -1135,46 +1221,80 @@ public class FBObject { throw new IllegalArgumentException("colorformat invalid: 0x"+Integer.toHexString(internalFormat)+", "+this); } - return attachColorbuffer(gl, attachmentPoint, new ColorAttachment(internalFormat, samples, width, height, 0)); + return (ColorAttachment) attachColorbuffer(gl, attachmentPoint, new ColorAttachment(internalFormat, samples, width, height, 0)); } /** - * Attaches a Color Buffer to this FBO's instance at the given attachment point. + * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment}, + * to this FBO's instance at the given attachment point. * + *

+ * If {@link Colorbuffer} is a {@link TextureAttachment} and is uninitialized, i.e. it's texture name is zero, + * a new texture name is generated and setup w/ the texture parameter.
+ * Otherwise, i.e. texture name is not zero, the passed TextureAttachment texA is + * considered complete and assumed matching this FBO requirement. A GL error may occur is the latter is untrue. + *

+ * *

Leaves the FBO bound.

* * @param gl * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] - * @param colA the template for the new {@link ColorAttachment} - * @return ColorAttachment instance describing the new attached colorbuffer if bound and configured successfully, otherwise GLException is thrown - * @throws GLException in case the colorbuffer couldn't be allocated + * @param colbuf the to be attached {@link Colorbuffer} + * @return newly attached {@link Colorbuffer} instance if bound and configured successfully, otherwise GLException is thrown + * @throws GLException in case the colorbuffer couldn't be allocated or MSAA has been chosen in case of a {@link TextureAttachment} */ - public final ColorAttachment attachColorbuffer(GL gl, int attachmentPoint, ColorAttachment colA) throws GLException { - validateAddColorAttachment(attachmentPoint, colA); - - colA.initialize(gl); - addColorAttachment(attachmentPoint, colA); + public final Colorbuffer attachColorbuffer(GL gl, int attachmentPoint, Colorbuffer colbuf) throws GLException { + validateAddColorAttachment(attachmentPoint, colbuf); - bind(gl); + final boolean initializedColorbuf = colbuf.initialize(gl); + addColorAttachment(attachmentPoint, colbuf); - // Attach the color buffer - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, - GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, - GL.GL_RENDERBUFFER, colA.getName()); + bind(gl); - if(!ignoreStatus) { - updateStatus(gl); - if(!isStatusValid()) { - detachColorbuffer(gl, attachmentPoint); - throw new GLException("attachColorbuffer "+colA+" at "+attachmentPoint+" failed "+getStatusString()+", "+this); + if(colbuf instanceof TextureAttachment) { + final TextureAttachment texA = (TextureAttachment) colbuf; + + if(samples>0) { + removeColorAttachment(attachmentPoint, texA); + if(initializedColorbuf) { + texA.free(gl); + } + throw new GLException("Texture2D not supported w/ MSAA. If you have enabled MSAA with exisiting texture attachments, you may want to detach them via detachAllTexturebuffer(gl)."); + } + + // Set up the color buffer for use as a renderable texture: + gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, + GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, + GL.GL_TEXTURE_2D, texA.getName(), 0); + + if(!ignoreStatus) { + updateStatus(gl); + if(!isStatusValid()) { + detachColorbuffer(gl, attachmentPoint, true); + throw new GLException("attachTexture2D "+texA+" at "+attachmentPoint+" failed "+getStatusString()+", "+this); + } + } + } else if(colbuf instanceof ColorAttachment) { + final ColorAttachment colA = (ColorAttachment) colbuf; + + // Attach the color buffer + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, + GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, + GL.GL_RENDERBUFFER, colA.getName()); + + if(!ignoreStatus) { + updateStatus(gl); + if(!isStatusValid()) { + detachColorbuffer(gl, attachmentPoint, true); + throw new GLException("attachColorbuffer "+colA+" at "+attachmentPoint+" failed "+getStatusString()+", "+this); + } } } if(DEBUG) { - System.err.println("FBObject.attachColorbuffer: "+this); + System.err.println("FBObject.attachColorbuffer: [attachmentPoint "+attachmentPoint+", colbuf "+colbuf+"]: "+this); } - return colA; + return colbuf; } - /** * Attaches one depth, stencil or packed-depth-stencil buffer to this FBO's instance, @@ -1355,33 +1475,39 @@ public class FBObject { if(!ignoreStatus) { updateStatus(gl); if( !isStatusValid() ) { - detachRenderbuffer(gl, atype); + detachRenderbuffer(gl, atype, true); throw new GLException("renderbuffer attachment failed: "+this.getStatusString()); } } if(DEBUG) { - System.err.println("FBObject.attachRenderbuffer: "+this); - } + System.err.println("FBObject.attachRenderbuffer: [attachmentType "+atype+"]: "+this); + } } /** + * Detaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment}. *

Leaves the FBO bound!

+ * * @param gl - * @param ca + * @param attachmentPoint + * @param dispose true if the Colorbuffer shall be disposed + * @return the detached Colorbuffer * @throws IllegalArgumentException */ - public final void detachColorbuffer(GL gl, int attachmentPoint) throws IllegalArgumentException { - if(null == detachColorbufferImpl(gl, attachmentPoint, false)) { + public final Colorbuffer detachColorbuffer(GL gl, int attachmentPoint, boolean dispose) throws IllegalArgumentException { + final Colorbuffer res = detachColorbufferImpl(gl, attachmentPoint, dispose ? DetachAction.DISPOSE : DetachAction.NONE); + if(null == res) { throw new IllegalArgumentException("ColorAttachment at "+attachmentPoint+", not attached, "+this); } if(DEBUG) { - System.err.println("FBObject.detachColorbuffer: [attachmentPoint "+attachmentPoint+"]: "+this); + System.err.println("FBObject.detachColorbuffer: [attachmentPoint "+attachmentPoint+", dispose "+dispose+"]: "+res+", "+this); } + return res; } - private final Colorbuffer detachColorbufferImpl(GL gl, int attachmentPoint, boolean recreate) { - final Colorbuffer colbuf = colorAttachmentPoints[attachmentPoint]; // shortcut, don't validate here + private final Colorbuffer detachColorbufferImpl(GL gl, int attachmentPoint, DetachAction detachAction) { + Colorbuffer colbuf = colorAttachmentPoints[attachmentPoint]; // shortcut, don't validate here if(null == colbuf) { return null; @@ -1389,6 +1515,8 @@ public class FBObject { bind(gl); + removeColorAttachment(attachmentPoint, colbuf); + if(colbuf instanceof TextureAttachment) { final TextureAttachment texA = (TextureAttachment) colbuf; if( 0 != texA.getName() ) { @@ -1397,11 +1525,22 @@ public class FBObject { GL.GL_TEXTURE_2D, 0, 0); gl.glBindTexture(GL.GL_TEXTURE_2D, 0); } - texA.free(gl); - removeColorAttachment(attachmentPoint, texA); - if(recreate) { - texA.setSize(width, height); - attachTexture2D(gl, attachmentPoint, texA); + switch(detachAction) { + case DISPOSE: + texA.free(gl); + break; + case RECREATE: + texA.free(gl); + if(samples == 0) { + // stay non MSAA + texA.setSize(width, height); + } else { + // switch to MSAA + colbuf = createColorAttachment(hasAlpha(texA.format)); + } + attachColorbuffer(gl, attachmentPoint, colbuf); + break; + default: } } else if(colbuf instanceof ColorAttachment) { final ColorAttachment colA = (ColorAttachment) colbuf; @@ -1410,12 +1549,30 @@ public class FBObject { GL.GL_COLOR_ATTACHMENT0+attachmentPoint, GL.GL_RENDERBUFFER, 0); } - colA.free(gl); - removeColorAttachment(attachmentPoint, colbuf); - if(recreate) { - colA.setSize(width, height); - colA.setSamples(samples); - attachColorbuffer(gl, attachmentPoint, colA); + switch(detachAction) { + case DISPOSE: + colA.free(gl); + break; + case RECREATE: + colA.free(gl); + if(samples > 0) { + // stay MSAA + colA.setSize(width, height); + colA.setSamples(samples); + } else { + // switch to non MSAA + if(null != samplesSinkTexture) { + colbuf = createColorTextureAttachment(samplesSinkTexture.format, width, height, + samplesSinkTexture.dataFormat, samplesSinkTexture.dataType, + samplesSinkTexture.magFilter, samplesSinkTexture.minFilter, + samplesSinkTexture.wrapS, samplesSinkTexture.wrapT); + } else { + colbuf = createColorTextureAttachment(gl.getGLProfile(), true, width, height); + } + } + attachColorbuffer(gl, attachmentPoint, colbuf); + break; + default: } } return colbuf; @@ -1424,10 +1581,14 @@ public class FBObject { /** * * @param gl + * @param dispose true if the Colorbuffer shall be disposed * @param reqAType {@link Type#DEPTH}, {@link Type#DEPTH} or {@link Type#DEPTH_STENCIL} */ - public final void detachRenderbuffer(GL gl, Attachment.Type atype) throws IllegalArgumentException { - detachRenderbufferImpl(gl, atype, false); + public final void detachRenderbuffer(GL gl, Attachment.Type atype, boolean dispose) throws IllegalArgumentException { + detachRenderbufferImpl(gl, atype, dispose ? DetachAction.DISPOSE : DetachAction.NONE); + if(DEBUG) { + System.err.println("FBObject.detachRenderbuffer: [attachmentType "+atype+", dispose "+dispose+"]: "+this); + } } public final boolean isDepthStencilPackedFormat() { @@ -1439,7 +1600,7 @@ public class FBObject { return res; } - private final void detachRenderbufferImpl(GL gl, Attachment.Type atype, boolean recreate) throws IllegalArgumentException { + private final void detachRenderbufferImpl(GL gl, Attachment.Type atype, DetachAction detachAction) throws IllegalArgumentException { switch ( atype ) { case DEPTH: case STENCIL: @@ -1485,8 +1646,14 @@ public class FBObject { if( 0 != depth.getName() ) { gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, 0); } - depth.free(gl); - if(!recreate) { + switch(detachAction) { + case DISPOSE: + case RECREATE: + depth.free(gl); + break; + default: + } + if(DetachAction.RECREATE != detachAction) { depth = null; } break; @@ -1495,8 +1662,14 @@ public class FBObject { if(0 != stencil.getName()) { gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, 0); } - stencil.free(gl); - if(!recreate) { + switch(detachAction) { + case DISPOSE: + case RECREATE: + stencil.free(gl); + break; + default: + } + if(DetachAction.RECREATE != detachAction) { stencil = null; } break; @@ -1506,9 +1679,15 @@ public class FBObject { gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, 0); gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, 0); } - depth.free(gl); - stencil.free(gl); - if(!recreate) { + switch(detachAction) { + case DISPOSE: + case RECREATE: + depth.free(gl); + stencil.free(gl); + break; + default: + } + if(DetachAction.RECREATE != detachAction) { depth = null; stencil = null; } @@ -1516,14 +1695,15 @@ public class FBObject { default: throw new InternalError("XXX"); } - if(recreate) { + if(DetachAction.RECREATE == detachAction) { attachRenderbufferImpl2(gl, action, format); } } } /** - * Detaches all {@link ColorAttachment}s, {@link TextureAttachment}s and {@link RenderAttachment}s. + * Detaches all {@link ColorAttachment}s, {@link TextureAttachment}s and {@link RenderAttachment}s + * and disposes them. *

Leaves the FBO bound!

*

* An attached sampling sink texture will be detached as well, see {@link #getSamplingSink()}. @@ -1538,7 +1718,8 @@ public class FBObject { } /** - * Detaches all {@link ColorAttachment}s and {@link TextureAttachment}s. + * Detaches all {@link ColorAttachment}s and {@link TextureAttachment}s + * and disposes them. *

Leaves the FBO bound!

*

* An attached sampling sink texture will be detached as well, see {@link #getSamplingSink()}. @@ -1553,7 +1734,7 @@ public class FBObject { } /** - * Detaches all {@link TextureAttachment}s + * Detaches all {@link TextureAttachment}s and disposes them. *

Leaves the FBO bound!

*

* An attached sampling sink texture will be detached as well, see {@link #getSamplingSink()}. @@ -1566,30 +1747,33 @@ public class FBObject { } for(int i=0; i reset try { for(int i=0; i0 ) { throw new InternalError("Non zero ColorAttachments "+this); } if(detachNonColorbuffer) { - detachRenderbufferImpl(gl, Attachment.Type.DEPTH_STENCIL, recreate); + detachRenderbufferImpl(gl, Attachment.Type.DEPTH_STENCIL, recreate ? DetachAction.RECREATE : DetachAction.DISPOSE); } if(ignoreStatus) { // post validate updateStatus(gl); @@ -1651,14 +1835,22 @@ public class FBObject { } private final void resetMSAATexture2DSink(GL gl) throws GLException { + if(null == samplesSink ) { + return; // this is the sample sink! + } if(0 == samples) { // MSAA off - if(null != samplesSink) { + if(samplesSink.initialized) { + // cleanup samplesSink.detachAll(gl); } return; } + if(!samplesSink.initialized) { + samplesSink.init(gl, width, height, 0); + } + boolean sampleSinkSizeMismatch = sampleSinkSizeMismatch(); boolean sampleSinkTexMismatch = sampleSinkTexMismatch(); boolean sampleSinkDepthStencilMismatch = sampleSinkDepthStencilMismatch(); @@ -1692,7 +1884,7 @@ public class FBObject { samplesSinkTexture = samplesSink.attachTexture2D(gl, 0, true); } else if( 0 == samplesSinkTexture.getName() ) { samplesSinkTexture.setSize(width, height); - samplesSink.attachTexture2D(gl, 0, samplesSinkTexture); + samplesSink.attachColorbuffer(gl, 0, samplesSinkTexture); } if( sampleSinkDepthStencilMismatch ) { @@ -1768,6 +1960,17 @@ public class FBObject { bound = false; } } + + /** + * Method simply marks this FBO unbound w/o interfering w/ the bound framebuffer as perfomed by {@link #unbind(GL)}. + *

+ * Only use this method if a subsequent {@link #unbind(GL)}, {@link #use(GL, TextureAttachment)} or {@link #bind(GL)} + * follows on any FBO. + *

+ */ + public final void markUnbound() { + bound = false; + } /** * Returns true if framebuffer object is bound via {@link #bind(GL)}, otherwise false. @@ -1785,49 +1988,54 @@ public class FBObject { public final boolean isBound() { return bound; } /** - * Samples the multisampling colorbuffer (msaa-buffer) to it's sink {@link #getSamplingSink()}. - * - *

The operation is skipped, if no multisampling is used or - * the msaa-buffer has not been flagged dirty by a previous call of {@link #bind(GL)}, - * see {@link #isSamplingBufferDirty()}

- * - *

If full FBO is supported, sets the read and write framebuffer individually to default after sampling, hence not disturbing - * an optional operating MSAA FBO, see {@link GLBase#getDefaultReadFramebuffer()} and {@link GLBase#getDefaultDrawFramebuffer()}

- * - *

In case you intend to employ {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)} + * If multisampling is being used and flagged dirty by a previous call of {@link #bind(GL)} or after initialization, + * the msaa-buffers are sampled to it's sink {@link #getSamplingSink()}. + *

+ * Method also updates the sampling sink configuration (if used). Hence it is recommended to call this + * method after your have initialized the FBO and attached renderbuffer etc for the 1st time. + * Method is called automatically by {@link #use(GL, TextureAttachment)}. + *

+ *

+ * Methos always resets the framebuffer binding to default in the end. + * If full FBO is supported, sets the read and write framebuffer individually to default after sampling, hence not disturbing + * an optional operating MSAA FBO, see {@link GLBase#getDefaultReadFramebuffer()} and {@link GLBase#getDefaultDrawFramebuffer()} + *

+ *

+ * In case you use this FBO w/o the {@link GLFBODrawable} and intend to employ {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)} * you may want to call {@link GL#glBindFramebuffer(int, int) glBindFramebuffer}({@link GL2GL3#GL_READ_FRAMEBUFFER}, {@link #getReadFramebuffer()}); *

- * *

Leaves the FBO unbound.

* * @param gl the current GL context * @param ta {@link TextureAttachment} to use, prev. attached w/ {@link #attachTexture2D(GL, int, boolean, int, int, int, int) attachTexture2D(..)} * @throws IllegalArgumentException */ - public final void syncSamplingBuffer(GL gl) { - unbind(gl); + public final void syncFramebuffer(GL gl) { + markUnbound(); if(samples>0 && samplesSinkDirty) { samplesSinkDirty = false; resetMSAATexture2DSink(gl); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, fbName); gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, samplesSink.getWriteFramebuffer()); - ((GL2GL3)gl).glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, // since MSAA is supported, ugly cast is OK + ((GL2GL3)gl).glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, // since MSAA is supported, casting to GL2GL3 is OK GL.GL_COLOR_BUFFER_BIT, GL.GL_NEAREST); - if(fullFBOSupport) { - // default read/draw buffers, may utilize GLContext/GLDrawable override of - // GLContext.getDefaultDrawFramebuffer() and GLContext.getDefaultReadFramebuffer() - gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, 0); - gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, 0); - } else { - gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer - } + } + if(fullFBOSupport) { + // default read/draw buffers, may utilize GLContext/GLDrawable override of + // GLContext.getDefaultDrawFramebuffer() and GLContext.getDefaultReadFramebuffer() + gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, 0); + gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, 0); + } else { + gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer } } /** * Bind the given texture colorbuffer. * - *

If multisampling is being used, {@link #syncSamplingBuffer(GL)} is being called.

+ *

If using multiple texture units, ensure you call {@link GL#glActiveTexture(int)} first!

+ * + *

{@link #syncFramebuffer(GL)} is being called

* *

Leaves the FBO unbound!

* @@ -1837,11 +2045,7 @@ public class FBObject { */ public final void use(GL gl, TextureAttachment ta) throws IllegalArgumentException { if(null == ta) { throw new IllegalArgumentException("null TextureAttachment, this: "+toString()); } - if(samples > 0 && samplesSinkTexture == ta) { - syncSamplingBuffer(gl); - } else { - unbind(gl); - } + syncFramebuffer(gl); gl.glBindTexture(GL.GL_TEXTURE_2D, ta.getName()); // use it .. } @@ -1855,14 +2059,8 @@ public class FBObject { gl.glBindTexture(GL.GL_TEXTURE_2D, 0); // don't use it } - /** - * Returns true if basic or full FBO is supported, otherwise false. - * @param full true for full FBO supported query, otherwise false for basic FBO support query. - * @see #supportsFullFBO(GL) - * @see #supportsBasicFBO(GL) - * @throws GLException if {@link #init(GL)} hasn't been called. - */ - public final boolean supportsFBO(boolean full) throws GLException { checkInitialized(); return full ? fullFBOSupport : basicFBOSupport; } + /** @see GL#hasFullFBOSupport() */ + public final boolean hasFullFBOSupport() throws GLException { checkInitialized(); return this.fullFBOSupport; } /** * Returns true if renderbuffer accepts internal format {@link GL#GL_RGB8} and {@link GL#GL_RGBA8}, otherwise false. @@ -1878,7 +2076,7 @@ public class FBObject { public final boolean supportsDepth(int bits) throws GLException { checkInitialized(); switch(bits) { - case 16: return basicFBOSupport; + case 16: return true; case 24: return depth24Avail; case 32: return depth32Avail; default: return false; @@ -1913,11 +2111,11 @@ public class FBObject { */ public final int getMaxColorAttachments() throws GLException { checkInitialized(); return maxColorAttachments; } - /** - * Returns the maximum number of samples for multisampling. Maybe zero if multisampling is not supported. - * @throws GLException if {@link #init(GL)} hasn't been called. - */ - public final int getMaxSamples() throws GLException { checkInitialized(); return maxSamples; } + public final int getMaxTextureSize() throws GLException { checkInitialized(); return this.maxTextureSize; } + public final int getMaxRenderbufferSize() throws GLException { checkInitialized(); return this.maxRenderbufferSize; } + + /** @see GL#getMaxRenderbufferSamples() */ + public final int getMaxSamples() throws GLException { checkInitialized(); return this.maxSamples; } /** * Returns true if this instance has been initialized with {@link #reset(GL, int, int)} diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java new file mode 100644 index 000000000..38a8deef8 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java @@ -0,0 +1,189 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; + +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; + +import jogamp.opengl.GLAutoDrawableBase; +import jogamp.opengl.GLContextImpl; +import jogamp.opengl.GLDrawableImpl; + + +/** + * Fully functional {@link GLAutoDrawable} implementation + * utilizing already created created {@link GLDrawable} and {@link GLContext} instances. + *

+ * Since no native windowing system events are being processed, it is recommended + * to handle at least: + *

    + *
  • {@link com.jogamp.newt.event.WindowListener#windowRepaint(com.jogamp.newt.event.WindowUpdateEvent) repaint} using {@link #windowRepaintOp()}
  • + *
  • {@link com.jogamp.newt.event.WindowListener#windowResized(com.jogamp.newt.event.WindowEvent) resize} using {@link #windowResizedOp()}
  • + *
  • {@link com.jogamp.newt.event.WindowListener#windowDestroyNotify(com.jogamp.newt.event.WindowEvent) destroy-notify} using {@link #windowDestroyNotifyOp()}
  • + *
+ *

+ *

+ * See example {@link com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT TestGLAutoDrawableDelegateNEWT}. + *

+ */ +public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAutoDrawable { + /** + * @param drawable a valid and already realized {@link GLDrawable} + * @param context a valid {@link GLContext}, may not be made current (created) yet. + * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. + * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, + * otherwise pass false. Closing the device is required in case + * the drawable is created w/ it's own new instance, e.g. offscreen drawables, + * and no further lifecycle handling is applied. + * @param lock optional custom {@link RecursiveLock}. + */ + public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget, boolean ownDevice, RecursiveLock lock) { + super((GLDrawableImpl)drawable, (GLContextImpl)context, ownDevice); + if(null == drawable) { + throw new IllegalArgumentException("null drawable"); + } + if(null == context) { + throw new IllegalArgumentException("null context"); + } + if(!drawable.isRealized()) { + throw new IllegalArgumentException("drawable not realized"); + } + this.upstreamWidget = upstreamWidget; + this.lock = ( null != lock ) ? lock : LockFactory.createRecursiveLock() ; + } + + // + // expose default methods + // + + /** Default implementation to handle repaint events from the windowing system */ + public final void windowRepaintOp() { + super.defaultWindowRepaintOp(); + } + + /** Implementation to handle resize events from the windowing system. All required locks are being claimed. */ + public final void windowResizedOp(int newWidth, int newHeight) { + super.defaultWindowResizedOp(newWidth, newHeight); + } + + /** + * Implementation to handle destroy notifications from the windowing system. + * + *

+ * If the {@link NativeSurface} does not implement {@link WindowClosingProtocol} + * or {@link WindowClosingMode#DISPOSE_ON_CLOSE} is enabled (default), + * a thread safe destruction is being induced. + *

+ */ + public final void windowDestroyNotifyOp() { + super.defaultWindowDestroyNotifyOp(); + } + + // + // Complete GLAutoDrawable + // + + private Object upstreamWidget; + private final RecursiveLock lock; + + @Override + protected final RecursiveLock getLock() { return lock; } + + @Override + public final Object getUpstreamWidget() { + return upstreamWidget; + } + + /** + * Set the upstream UI toolkit object. + * @see #getUpstreamWidget() + */ + public final void setUpstreamWidget(Object newUpstreamWidget) { + upstreamWidget = newUpstreamWidget; + } + + /** + * {@inheritDoc} + *

+ * This implementation calls {@link #defaultDestroy()}. + *

+ *

+ * User still needs to destroy the upstream window, which details are hidden from this aspect. + * This can be performed by overriding {@link #destroyImplInLock()}. + *

+ */ + @Override + public final void destroy() { + defaultDestroy(); + } + + @Override + protected void destroyImplInLock() { + super.destroyImplInLock(); + } + + @Override + public void display() { + defaultDisplay(); + } + + // + // GLDrawable delegation + // + + @Override + public final GLDrawableFactory getFactory() { + return drawable.getFactory(); + } + + @Override + public final void setRealized(boolean realized) { + } + + @Override + public final void swapBuffers() throws GLException { + defaultSwapBuffers(); + } + + @Override + public String toString() { + return getClass().getSimpleName()+"[ \n\tHelper: " + helper + ", \n\tDrawable: " + drawable + + ", \n\tContext: " + context + ", \n\tUpstreamWidget: "+upstreamWidget+ /** ", \n\tFactory: "+factory+ */ "]"; + } +} diff --git a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java index f7e25fa01..cf81b85ee 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java +++ b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java @@ -72,6 +72,9 @@ public class GLExtensions { public static final String OES_EGL_image_external = "GL_OES_EGL_image_external"; + public static final String ARB_gpu_shader_fp64 = "GL_ARB_gpu_shader_fp64"; + public static final String ARB_shader_objects = "GL_ARB_shader_objects"; + // // Aliased GLX/WGL/.. extensions // diff --git a/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java b/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java deleted file mode 100644 index 4caea03b2..000000000 --- a/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.opengl.GLAutoDrawableDelegate; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLException; - -import jogamp.opengl.GLFBODrawableImpl; - -/** - * Platform-independent class exposing FBO offscreen functionality to - * applications. - *

- * This class distinguishes itself from {@link GLAutoDrawableDelegate} - * with it's {@link #setSize(int, int)} functionality. - *

- */ -public class OffscreenAutoDrawable extends GLAutoDrawableDelegate { - - /** - * @param drawable a valid {@link GLDrawable}, may not be realized yet. - * @param context a valid {@link GLContext}, may not be made current (created) yet. - * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, - * otherwise pass false. Closing the device is required in case - * the drawable is created w/ it's own new instance, e.g. offscreen drawables, - * and no further lifecycle handling is applied. - */ - public OffscreenAutoDrawable(GLDrawable drawable, GLContext context, boolean ownDevice) { - super(drawable, context, null, ownDevice); - } - - /** - * Attempts to resize this offscreen auto drawable, if supported - * by the underlying {@link GLDrawable). - * @param newWidth - * @param newHeight - * @return true if resize was executed, otherwise false. - * @throws GLException in case of an error during the resize operation - */ - public boolean setSize(int newWidth, int newHeight) throws GLException { - boolean done = false; - if(drawable instanceof GLFBODrawableImpl) { - Throwable tFBO = null; - Throwable tGL = null; - context.makeCurrent(); - try { - ((GLFBODrawableImpl)drawable).setSize(context.getGL(), newWidth, newHeight); - done = true; - } catch (Throwable t) { - tFBO = t; - } finally { - try { - context.release(); - } catch (Throwable t) { - tGL = t; - } - } - if(null != tFBO) { - throw new GLException("OffscreenAutoDrawable.setSize(..) GLFBODrawableImpl.setSize(..) exception", tFBO); - } - if(null != tGL) { - throw new GLException("OffscreenAutoDrawable.setSize(..) GLContext.release() exception", tGL); - } - } - if(done) { - this.defaultWindowResizedOp(); - return true; - } - return false; - } - - /** - * If the underlying {@link GLDrawable} is an FBO implementation - * and contains an {#link FBObject}, the same is returned. - * Otherwise returns null. - */ - public FBObject getFBObject() { - if(drawable instanceof GLFBODrawableImpl) { - return ((GLFBODrawableImpl)drawable).getFBObject(); - } - return null; - } -} diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 8d237162c..02f62daec 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.swt; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.opengl.GL; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; @@ -48,6 +49,7 @@ import javax.media.opengl.Threading; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableHelper; +import jogamp.opengl.GLDrawableImpl; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ControlAdapter; @@ -97,8 +99,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final GLCapabilitiesImmutable capsRequested; private final GLCapabilitiesChooser capsChooser; - private volatile GLDrawable drawable; // volatile: avoid locking for read-only access - private GLContext context; + private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access + private GLContextImpl context; /* Native window surface */ private AbstractGraphicsDevice device; @@ -319,7 +321,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } }); } - private final ProxySurface.UpstreamSurfaceHook swtCanvasUpStreamHook = new ProxySurface.UpstreamSurfaceHook() { + private final UpstreamSurfaceHook swtCanvasUpStreamHook = new UpstreamSurfaceHook() { @Override public final void create(ProxySurface s) { /* nop */ } @@ -349,7 +351,27 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) ) { clientArea = nClientArea; // write back new value - sendReshape = true; // Mark for OpenGL reshape next time the control is painted + + GLDrawableImpl _drawable = drawable; + if( null != _drawable ) { + if(DEBUG) { + System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+nClientArea.width+"x"+nClientArea.height+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + } + if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) { + final RecursiveLock _lock = lock; + _lock.lock(); + try { + final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, nClientArea.width, nClientArea.height); + if(_drawable != _drawableNew) { + // write back + drawable = _drawableNew; + } + } finally { + _lock.unlock(); + } + sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock + } + } } } @@ -391,10 +413,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { if(null != proxySurface) { /* Associate a GL surface with the proxy */ - drawable = glFactory.createGLDrawable(proxySurface); + drawable = (GLDrawableImpl) glFactory.createGLDrawable(proxySurface); drawable.setRealized(true); - context = drawable.createContext(shareWith); + context = (GLContextImpl) drawable.createContext(shareWith); } } finally { _lock.unlock(); @@ -455,6 +477,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { return helper.getAutoSwapBufferMode(); } + @Override + public final GLDrawable getDelegatedDrawable() { + return drawable; + } + @Override public GLContext getContext() { return null != drawable ? context : null; @@ -502,7 +529,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { _lock.lock(); try { final GLContext oldCtx = context; - final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + final boolean newCtxCurrent = GLDrawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; if(newCtxCurrent) { context.makeCurrent(); diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index 0b2c664fe..38f1746f9 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -114,6 +114,12 @@ public interface GLAutoDrawable extends GLDrawable { * where you drag the window to another monitor. */ public static final boolean SCREEN_CHANGE_ACTION_ENABLED = Debug.getBooleanProperty("jogl.screenchange.action", true); + /** + * If the implementation uses delegation, return the delegated {@link GLDrawable} instance, + * otherwise return this instance. + */ + public GLDrawable getDelegatedDrawable(); + /** * Returns the context associated with this drawable. The returned * context will be synchronized. @@ -124,23 +130,31 @@ public interface GLAutoDrawable extends GLDrawable { /** * Associate a new context to this drawable and also propagates the context/drawable switch by * calling {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. - * drawable might be an inner GLDrawable instance if using such a delegation pattern, - * or this GLAutoDrawable itself. - *

- * If the old context's drawable was an {@link GLAutoDrawable}, it's reference to the given drawable - * is being cleared by calling - * {@link GLAutoDrawable#setContext(GLContext) ((GLAutoDrawable)oldCtx.getGLDrawable()).setContext(null)}. - *

+ * drawable might be an inner GLDrawable instance if using a delegation pattern, + * or this GLAutoDrawable instance. *

* If the old or new context was current on this thread, it is being released before switching the drawable. * The new context will be made current afterwards, if it was current before. - * However the user shall take extra care that not other thread - * attempts to make this context current. Otherwise a race condition may happen. + * However the user shall take extra care that no other thread + * attempts to make this context current. + *

+ *

+ * Be aware that the old context is still bound to the drawable, + * and that one context can only be bound to one drawable at one time! *

*

- * Disclaimer: Even though the API may allows this functionality in theory, your mileage may vary - * switching the drawable of an already established GLContext, i.e. which is already made current once. - * FIXME: Validate functionality! + * In case you do not intend to use the old context anymore, i.e. + * not assigning it to another drawable, it shall be + * destroyed before setting the new context, i.e.: + *

+            GLContext oldCtx = glad.getContext();
+            if(null != oldCtx) {
+                oldCtx.destroy();
+            }
+            glad.setContext(newCtx);            
+   * 
+ * This is required, since a context must have a valid drawable at all times + * and this API shall not restrict the user in any way. *

* * @param newCtx the new context diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java deleted file mode 100644 index 67e81270d..000000000 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package javax.media.opengl; - -import javax.media.nativewindow.AbstractGraphicsDevice; - -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; - -import jogamp.opengl.Debug; -import jogamp.opengl.GLAutoDrawableBase; -import jogamp.opengl.GLContextImpl; -import jogamp.opengl.GLDrawableImpl; - - -/** - * Fully functional {@link GLAutoDrawable} implementation - * utilizing already created created {@link GLDrawable} and {@link GLContext} instances. - *

- * Since no native windowing system events are being processed, it is recommended - * to handle at least: - *

    - *
  • {@link com.jogamp.newt.event.WindowListener#windowRepaint(com.jogamp.newt.event.WindowUpdateEvent) repaint} using {@link #defaultWindowRepaintOp()}
  • - *
  • {@link com.jogamp.newt.event.WindowListener#windowResized(com.jogamp.newt.event.WindowEvent) resize} using {@link #defaultWindowResizedOp()}
  • - *
  • {@link com.jogamp.newt.event.WindowListener#windowDestroyNotify(com.jogamp.newt.event.WindowEvent) destroy-notify} using {@link #defaultWindowDestroyNotifyOp()}
  • - *
- *

- *

- * See example {@link com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT TestGLAutoDrawableDelegateNEWT}. - *

- */ -public class GLAutoDrawableDelegate extends GLAutoDrawableBase { - public static final boolean DEBUG = Debug.debug("GLAutoDrawableDelegate"); - - /** - * @param drawable a valid {@link GLDrawable}, may not be realized yet. - * @param context a valid {@link GLContext}, may not be made current (created) yet. - * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. - * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, - * otherwise pass false. Closing the device is required in case - * the drawable is created w/ it's own new instance, e.g. offscreen drawables, - * and no further lifecycle handling is applied. - */ - public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget, boolean ownDevice) { - super((GLDrawableImpl)drawable, (GLContextImpl)context, ownDevice); - this.upstreamWidget = null; - } - - // - // expose default methods - // - - public final void windowRepaintOp() { - super.defaultWindowRepaintOp(); - } - - public final void windowResizedOp() { - super.defaultWindowResizedOp(); - } - - public final void windowDestroyNotifyOp() { - super.defaultWindowDestroyNotifyOp(); - } - - // - // Complete GLAutoDrawable - // - - private final RecursiveLock lock = LockFactory.createRecursiveLock(); // instance wide lock - private final Object upstreamWidget; - - @Override - protected final RecursiveLock getLock() { return lock; } - - @Override - public final Object getUpstreamWidget() { - return upstreamWidget; - } - - /** - * {@inheritDoc} - *

- * This implementation calls {@link #defaultDestroy()}. - *

- *

- * User still needs to destroy the upstream window, which details are hidden from this aspect. - * This can be performed by overriding {@link #destroyImplInLock()}. - *

- */ - @Override - public final void destroy() { - defaultDestroy(); - } - - @Override - public void display() { - defaultDisplay(); - } - - // - // GLDrawable delegation - // - - @Override - public final GLDrawableFactory getFactory() { - return drawable.getFactory(); - } - - @Override - public final void setRealized(boolean realized) { - } - - @Override - public final void swapBuffers() throws GLException { - defaultSwapBuffers(); - } - -} diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index f5831a72d..9bcee819a 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -273,6 +273,42 @@ public interface GLBase { */ public boolean isExtensionAvailable(String glExtensionName); + /** + * Returns true if basic FBO support is available, otherwise false. + *

+ * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= core 3.0 or implements the extensions + * GL_ARB_ES2_compatibility, GL_ARB_framebuffer_object, GL_EXT_framebuffer_object or GL_OES_framebuffer_object. + *

+ *

+ * Basic FBO support may only include one color attachment and no multisampling, + * as well as limited internal formats for renderbuffer. + *

+ * @see GLContext#hasBasicFBOSupport() + */ + public boolean hasBasicFBOSupport(); + + /** + * Returns true if full FBO support is available, otherwise false. + *

+ * Full FBO is supported if the context is either GL >= core 3.0 or implements the extensions + * ARB_framebuffer_object, or all of + * EXT_framebuffer_object, EXT_framebuffer_multisample, + * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil. + *

+ *

+ * Full FBO support includes multiple color attachments and multisampling. + *

+ * @see GLContext#hasFullFBOSupport() + */ + public boolean hasFullFBOSupport(); + + /** + * Returns the maximum number of FBO RENDERBUFFER samples + * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. + * @see GLContext#getMaxRenderbufferSamples() + */ + public int getMaxRenderbufferSamples(); + /** * Returns true if the GL context supports non power of two (NPOT) textures, * otherwise false. @@ -284,6 +320,8 @@ public interface GLBase { */ public boolean isNPOTTextureAvailable(); + public boolean isTextureFormatBGRA8888Available(); + /** Provides a platform-independent way to specify the minimum swap interval for buffer swaps. An argument of 0 disables sync-to-vertical-refresh completely, while an argument of 1 diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index c2f94b9af..a5e639c74 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -96,6 +96,9 @@ public abstract class GLContext { */ public static final boolean PROFILE_ALIASING = !Debug.isPropertyDefined("jogl.debug.GLContext.NoProfileAliasing", true); + protected static final boolean FORCE_NO_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.none", true); + protected static final boolean FORCE_MIN_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.min", true); + public static final boolean DEBUG = Debug.debug("GLContext"); public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true); @@ -127,9 +130,9 @@ public abstract class GLContext { /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IMPL_ES2_COMPAT = 1 << 8; - /** Context supports basic FBO, details see {@link #hasFBO()}. + /** Context supports basic FBO, details see {@link #hasBasicFBOSupport()}. * Not a cache key. - * @see #hasFBO() + * @see #hasBasicFBOSupport() * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) */ protected static final int CTX_IMPL_FBO = 1 << 9; @@ -178,11 +181,6 @@ public abstract class GLContext { * and made current afterwards. However the user shall take extra care that not other thread * attempts to make this context current. Otherwise a race condition may happen. *

- *

- * Disclaimer: Even though the API may allows this functionality in theory, your mileage may vary - * switching the drawable of an already established GLContext, i.e. which is already made current once. - * FIXME: Validate functionality! - *

* @param readWrite the read/write drawable for framebuffer operations. * @param setWriteOnly if true and if the current read-drawable differs * from the write-drawable ({@link #setGLReadDrawable(GLDrawable)}), @@ -603,12 +601,23 @@ public abstract class GLContext { /** * @return true if impl. is a hardware rasterizer, otherwise false. + * @see #isHardwareRasterizer(AbstractGraphicsDevice, GLProfile) * @see GLProfile#isHardwareRasterizer() */ public final boolean isHardwareRasterizer() { return 0 == ( ctxOptions & CTX_IMPL_ACCEL_SOFT ) ; } + /** + * @return true if context supports GLSL, i.e. is either {@link #isGLES2()}, {@link #isGL3()} or {@link #isGL2()} and major-version > 1. + * @see GLProfile#hasGLSL() + */ + public final boolean hasGLSL() { + return isGLES2() || + isGL3() || + isGL2() && ctxMajorVersion>1 ; + } + /** * Returns true if basic FBO support is available, otherwise false. *

@@ -620,21 +629,54 @@ public abstract class GLContext { * as well as limited internal formats for renderbuffer. *

* @see #CTX_IMPL_FBO - * @see com.jogamp.opengl.FBObject#supportsBasicFBO(GL) - * @see com.jogamp.opengl.FBObject#supportsFullFBO(GL) */ - public final boolean hasFBO() { + public final boolean hasBasicFBOSupport() { return 0 != ( ctxOptions & CTX_IMPL_FBO ) ; } + /** + * Returns true if full FBO support is available, otherwise false. + *

+ * Full FBO is supported if the context is either GL >= core 3.0 or implements the extensions + * ARB_framebuffer_object, or all of + * EXT_framebuffer_object, EXT_framebuffer_multisample, + * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil. + *

+ *

+ * Full FBO support includes multiple color attachments and multisampling. + *

+ */ + public final boolean hasFullFBOSupport() { + return !FORCE_MIN_FBO_SUPPORT && hasBasicFBOSupport() && + ( isGL3() || // GL >= 3.0 + isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object + ( isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object* + isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) && + isExtensionAvailable(GLExtensions.EXT_framebuffer_blit) && + isExtensionAvailable(GLExtensions.EXT_packed_depth_stencil) + ) + ) ; + } + /** - * @return true if context supports GLSL - * @see GLProfile#hasGLSL() + * Returns the maximum number of FBO RENDERBUFFER samples + * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. */ - public final boolean hasGLSL() { - return isGL2ES2() ; + public final int getMaxRenderbufferSamples() { + if( hasFullFBOSupport() ) { + final GL gl = getGL(); + final int[] val = new int[] { 0 } ; + gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0); + final int glerr = gl.glGetError(); + if(GL.GL_NO_ERROR == glerr) { + return val[0]; + } else if(DEBUG) { + System.err.println("GLContext.getMaxRenderbufferSamples: GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr)); + } + } + return 0; } - + /** Note: The GL impl. may return a const value, ie {@link GLES2#isNPOTTextureAvailable()} always returns true. */ public boolean isNPOTTextureAvailable() { return isGL3() || isGLES2Compatible() || isExtensionAvailable(GLExtensions.ARB_texture_non_power_of_two); @@ -1014,6 +1056,9 @@ public abstract class GLContext { validateProfileBits(profile, "profile"); validateProfileBits(resCtp, "resCtp"); + if(FORCE_NO_FBO_SUPPORT) { + resCtp &= ~CTX_IMPL_FBO ; + } if(DEBUG) { System.err.println("GLContext.mapAvailableGLVersion: "+device+": "+getGLVersion(reqMajor, 0, profile, null)+" -> "+getGLVersion(resMajor, resMinor, resCtp, null)); // Thread.dumpStack(); @@ -1197,17 +1242,35 @@ public abstract class GLContext { * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. *

*

- * FBO support is queried as described in {@link #hasFBO()}. + * FBO support is queried as described in {@link #hasBasicFBOSupport()}. *

* * @param device the device to request whether FBO is available for * @param glp {@link GLProfile} to check for FBO capabilities - * @see GLContext#hasFBO() + * @see GLContext#hasBasicFBOSupport() */ public static final boolean isFBOAvailable(AbstractGraphicsDevice device, GLProfile glp) { return 0 != ( CTX_IMPL_FBO & getAvailableContextProperties(device, glp) ); } + /** + * @return 1 if using a hardware rasterizer, 0 if using a software rasterizer and -1 if not determined yet. + * @see GLContext#isHardwareRasterizer() + * @see GLProfile#isHardwareRasterizer() + */ + public static final int isHardwareRasterizer(AbstractGraphicsDevice device, GLProfile glp) { + final int r; + final int ctp = getAvailableContextProperties(device, glp); + if(0 == ctp) { + r = -1; + } else if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctp ) ) { + r = 1; + } else { + r = 0; + } + return r; + } + /** * @param device the device to request whether the profile is available for * @param reqMajor Key Value either 1, 2, 3 or 4 diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 9fd895c1f..b6e7b0576 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -48,13 +48,16 @@ import java.util.List; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.ReflectionUtil; +import com.jogamp.opengl.GLAutoDrawableDelegate; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.UpstreamSurfaceHook; import jogamp.opengl.Debug; @@ -373,44 +376,63 @@ public abstract class GLDrawableFactory { // Methods to create high-level objects /** - * Returns a GLDrawable according to it's chosen Capabilities,
+ * Returns a GLDrawable according to it's chosen {@link GLCapabilitiesImmutable},
* which determines pixel format, on- and offscreen incl. PBuffer type. *

- * The native platform's chosen Capabilties are referenced within the target - * NativeSurface's AbstractGraphicsConfiguration.

- * - * In case target's {@link javax.media.nativewindow.Capabilities#isOnscreen()} is true,
- * an onscreen GLDrawable will be realized. + * The chosen {@link GLCapabilitiesImmutable} are referenced within the target + * {@link NativeSurface}'s {@link AbstractGraphicsConfiguration}.

+ *

*

- * In case target's {@link javax.media.nativewindow.Capabilities#isOnscreen()} is false,
- * either a Pbuffer drawable is created if target's {@link javax.media.opengl.GLCapabilities#isPBuffer()} is true,
- * or a simple pixmap/bitmap drawable is created. The latter is unlikely to be hardware accelerated.
+ * An onscreen GLDrawable is created if {@link CapabilitiesImmutable#isOnscreen() caps.isOnscreen()} is true. + *

*

- * + * A FBO drawable is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()} + * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true. + *

+ *

+ * A Pbuffer drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()} + * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. + *

+ *

+ * If not onscreen and neither FBO nor Pbuffer is available, + * a simple pixmap/bitmap drawable/surface is created, which is unlikely to be hardware accelerated. + *

+ * * @throws IllegalArgumentException if the passed target is null * @throws GLException if any window system-specific errors caused * the creation of the GLDrawable to fail. * + * @see #canCreateGLPbuffer(AbstractGraphicsDevice) + * @see GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) + * @see javax.media.opengl.GLCapabilities#isOnscreen() + * @see javax.media.opengl.GLCapabilities#isFBO() + * @see javax.media.opengl.GLCapabilities#isPBuffer() * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen) */ public abstract GLDrawable createGLDrawable(NativeSurface target) throws IllegalArgumentException, GLException; - + /** - * Creates a Offscreen GLDrawable incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. + * Creates an {@link GLOffscreenAutoDrawable} incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. *

- * It's {@link AbstractGraphicsConfiguration} is properly set according to the given {@link GLCapabilitiesImmutable}, see below. + * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is realized and it's {@link GLContext} assigned but not yet made current. *

*

- * A FBO drawable is created if both {@link javax.media.opengl.GLCapabilities#isFBO() caps.isFBO()} + * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e. + * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} == true, + * it is auto-configured. The latter will set offscreen and also FBO or Pbuffer, whichever is available in that order. + *

+ *

+ * A FBO based auto drawable, {@link GLOffscreenAutoDrawable.FBO}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()} * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true. *

*

- * A Pbuffer drawable is created if both {@link javax.media.opengl.GLCapabilities#isPBuffer() caps.isPBuffer()} - * and {@link #canCreateGLPbuffer(javax.media.nativewindow.AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. + * A Pbuffer based auto drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()} + * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. *

*

- * If neither FBO nor Pbuffer is available, a simple pixmap/bitmap drawable/surface is created, which is unlikely to be hardware accelerated. + * If neither FBO nor Pbuffer is available, + * a simple pixmap/bitmap auto drawable is created, which is unlikely to be hardware accelerated. *

* * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. @@ -418,17 +440,55 @@ public abstract class GLDrawableFactory { * @param chooser the custom chooser, may be null for default * @param width the requested offscreen width * @param height the requested offscreen height + * @return the created and initialized offscreen {@link GLOffscreenAutoDrawable} instance * - * @return the created offscreen GLDrawable + * @throws GLException if any window system-specific errors caused + * the creation of the Offscreen to fail. + * + * @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) + */ + public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, + GLCapabilitiesImmutable caps, + GLCapabilitiesChooser chooser, + int width, int height, + GLContext shareWith) throws GLException; + /** + * Creates a offscreen {@link GLDrawable} incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. + *

+ * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e. + * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} == true, + * it is auto-configured. The latter will set offscreen and also FBO or Pbuffer, whichever is available in that order. + *

+ *

+ * A resizeable FBO drawable, {@link GLFBODrawable.Resizeable}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()} + * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true. + *

+ *

+ * A Pbuffer drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()} + * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. + *

+ *

+ * If neither FBO nor Pbuffer is available, + * a simple pixmap/bitmap drawable is created, which is unlikely to be hardware accelerated. + *

+ * + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. + * @param caps the requested GLCapabilties + * @param chooser the custom chooser, may be null for default + * @param width the requested offscreen width + * @param height the requested offscreen height + * + * @return the created offscreen {@link GLDrawable} * * @throws GLException if any window system-specific errors caused * the creation of the Offscreen to fail. + * + * @see #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext) */ public abstract GLDrawable createOffscreenDrawable(AbstractGraphicsDevice device, - GLCapabilitiesImmutable capabilities, + GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, - int width, int height) - throws GLException; + int width, int height) throws GLException; /** * Creates a proxy {@link NativeSurface} w/ defined surface handle, i.e. a {@link WrappedSurface} or {@link GDISurface} instance. @@ -458,6 +518,21 @@ public abstract class GLDrawableFactory { long windowHandle, GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream); + /** + * Returns true if it is possible to create an framebuffer object (FBO). + *

+ * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. + *

+ *

+ * FBO support is queried as described in {@link GLContext#hasBasicFBOSupport()}. + *

+ * + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. + * @param glp {@link GLProfile} to check for FBO capabilities + * @see GLContext#hasBasicFBOSupport() + */ + public abstract boolean canCreateFBO(AbstractGraphicsDevice device, GLProfile glp); + /** * Returns true if it is possible to create a GLPbuffer. Some older * graphics cards do not have this capability. @@ -467,7 +542,10 @@ public abstract class GLDrawableFactory { public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device); /** - * Creates a GLPbuffer with the given capabilites and dimensions.

+ * Creates a GLPbuffer {@link GLAutoDrawable} with the given capabilites and dimensions. + *

+ * The GLPbuffer drawable is realized and initialized eagerly. + *

* * See the note in the overview documentation on * context sharing. @@ -479,10 +557,12 @@ public abstract class GLDrawableFactory { * @param initialHeight initial height of pbuffer * @param shareWith a shared GLContext this GLPbuffer shall use * - * @return the new {@link GLPbuffer} specific {@link GLAutoDrawable} + * @return the created and initialized {@link GLPbuffer} instance * * @throws GLException if any window system-specific errors caused * the creation of the GLPbuffer to fail. + * + * @deprecated {@link GLPbuffer} is deprecated, use {@link #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext)} */ public abstract GLPbuffer createGLPbuffer(AbstractGraphicsDevice device, GLCapabilitiesImmutable capabilities, diff --git a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java new file mode 100644 index 000000000..45fd3b686 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java @@ -0,0 +1,173 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package javax.media.opengl; + +import javax.media.nativewindow.NativeWindowException; + +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.TextureAttachment; + +/** + * Platform-independent {@link GLDrawable} specialization, + * exposing {@link FBObject} functionality. + * + *

+ * A {@link GLFBODrawable} is uninitialized until a {@link GLContext} is bound + * and made current the first time. + *

+ * + *

+ * MSAA is used if {@link GLCapabilitiesImmutable#getNumSamples() requested}. + *

+ *

+ * Double buffering is used if {@link GLCapabilitiesImmutable#getDoubleBuffered() requested}. + *

+ *

+ * In MSAA mode, it always uses the implicit 2nd {@link FBObject framebuffer} {@link FBObject#getSamplingSinkFBO() sink}. + * Hence double buffering is always the case w/ MSAA. + *

+ *

+ * In non MSAA a second explicit {@link FBObject framebuffer} is being used. + * This method allows compliance w/ the spec, i.e. read and draw framebuffer selection + * and double buffer usage for e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)}. + * This method also allows usage of both textures seperately. + *

+ *

+ * It would be possible to implement double buffering simply using + * {@link FBObject.TextureAttachment texture attachment}s with one {@link FBObject framebuffer}. + * This would require mode selection and hence complicate the API. Besides, it would + * not support differentiation of read and write framebuffer and hence not be spec compliant. + *

+ *

+ * Actual swapping of the {@link FBObject.TextureAttachment texture}s or {@link FBObject framebuffer} + * is performed either in the {@link #contextMadeCurrent(boolean) context current hook} + * or when {@link #swapBuffersImpl(boolean) swapping buffers}, whatever comes first.
+ *

+ */ +public interface GLFBODrawable extends GLDrawable { + // public enum DoubleBufferMode { NONE, TEXTURE, FBO }; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support + + /** + * @return true if initialized, i.e. a {@link GLContext} is bound and made current once, otherwise false. + */ + public boolean isInitialized(); + + /** + * Notify this instance about upstream size change + * to reconfigure the {@link FBObject}. + * @param gl GL context object bound to this drawable, will be made current during operation. + * A prev. current context will be make current after operation. + * @throws GLException if resize operation failed + */ + void resetSize(GL gl) throws GLException; + + /** + * @return the used texture unit + */ + int getTextureUnit(); + + /** + * + * @param unit the texture unit to be used + */ + void setTextureUnit(int unit); + + /** + * Set a new sample size + * @param gl GL context object bound to this drawable, will be made current during operation. + * A prev. current context will be make current after operation. + * @param newSamples new sample size + * @throws GLException if resetting the FBO failed + */ + void setNumSamples(GL gl, int newSamples) throws GLException; + + /** + * @return the number of sample buffers if using MSAA, otherwise 0 + */ + int getNumSamples(); + + /** + * @return the used {@link DoubleBufferMode} + */ + // DoubleBufferMode getDoubleBufferMode(); // TODO: Add or remove TEXTURE (only) DoubleBufferMode support + + /** + * Sets the {@link DoubleBufferMode}. Must be called before {@link #isInitialized() initialization}, + * otherwise an exception is thrown. + *

+ * This call has no effect is MSAA is selected, since MSAA always forces the mode to {@link DoubleBufferMode#FBO FBO}. + * Also setting the mode to {@link DoubleBufferMode#NONE NONE} where double buffering is {@link GLCapabilitiesImmutable#getDoubleBuffered() requested} + * or setting a double buffering mode w/o {@link GLCapabilitiesImmutable#getDoubleBuffered() request} will be ignored. + *

+ *

+ * Since {@link DoubleBufferMode#TEXTURE TEXTURE} mode is currently not implemented, this method has no effect. + *

+ * @throws GLException if already initialized, see {@link #isInitialized()}. + */ + // void setDoubleBufferMode(DoubleBufferMode mode) throws GLException; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support + + /** + * If MSAA is being used and {@link GL#GL_FRONT} is requested, + * the internal {@link FBObject} {@link FBObject#getSamplingSinkFBO() sample sink} is being returned. + * + * @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names + * @return the named {@link FBObject} + * @throws IllegalArgumentException if an illegal buffer name is being used + */ + FBObject getFBObject(int bufferName) throws IllegalArgumentException; + + /** + * Returns the named texture buffer. + *

+ * If MSAA is being used, only the {@link GL#GL_FRONT} buffer is accessible + * and an exception is being thrown if {@link GL#GL_BACK} is being requested. + *

+ * @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names + * @return the named {@link TextureAttachment} + * @throws IllegalArgumentException if using MSAA and {@link GL#GL_BACK} is requested or an illegal buffer name is being used + */ + FBObject.TextureAttachment getTextureBuffer(int bufferName) throws IllegalArgumentException; + + /** Resizeable {@link GLFBODrawable} specialization */ + public interface Resizeable extends GLFBODrawable { + /** + * Resize this drawable. + *

+ * This drawable is being locked during operation. + *

+ * @param context the {@link GLContext} bound to this drawable, will be made current during operation + * A prev. current context will be make current after operation. + * @param newWidth + * @param newHeight + * @throws NativeWindowException in case the surface could no be locked + * @throws GLException in case an error during the resize operation occurred + */ + void setSize(GLContext context, int newWidth, int newHeight) throws NativeWindowException, GLException; + } +} diff --git a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java new file mode 100644 index 000000000..6fe76a3f4 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java @@ -0,0 +1,63 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package javax.media.opengl; + +import javax.media.nativewindow.NativeWindowException; + +import com.jogamp.opengl.FBObject; + +/** + * Platform-independent {@link GLAutoDrawable} specialization, + * exposing offscreen functionality. + *

+ * This class distinguishes itself from {@link GLAutoDrawable} + * with it's {@link #setSize(int, int)} functionality. + *

+ */ +public interface GLOffscreenAutoDrawable extends GLAutoDrawable { + + /** + * Resize this auto drawable. + * @param newWidth + * @param newHeight + * @throws NativeWindowException in case the surface could no be locked + * @throws GLException in case of an error during the resize operation + */ + void setSize(int newWidth, int newHeight) throws NativeWindowException, GLException; + + /** + * Set the upstream UI toolkit object. + * @see #getUpstreamWidget() + */ + void setUpstreamWidget(Object newUpstreamWidget); + + /** {@link FBObject} based {@link GLOffscreenAutoDrawable} specialization */ + public interface FBO extends GLOffscreenAutoDrawable, GLFBODrawable { + } +} diff --git a/src/jogl/classes/javax/media/opengl/GLPbuffer.java b/src/jogl/classes/javax/media/opengl/GLPbuffer.java index 273a992cf..de7731a3b 100644 --- a/src/jogl/classes/javax/media/opengl/GLPbuffer.java +++ b/src/jogl/classes/javax/media/opengl/GLPbuffer.java @@ -45,7 +45,11 @@ package javax.media.opengl; contains experimental methods for accessing the pbuffer's contents as a texture map and enabling rendering to floating-point frame buffers. These methods are not guaranteed to be supported on all - platforms and may be deprecated in a future release. */ + platforms and may be deprecated in a future release. + + @deprecated Use {@link GLOffscreenAutoDrawable} w/ {@link GLCapabilities#setFBO(boolean)} + via {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext) GLDrawableFactory.createOffscreenAutoDrawable(..)}. + */ public interface GLPbuffer extends GLAutoDrawable { /** Indicates the GL_APPLE_float_pixels extension is being used for this pbuffer. */ diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 033591fe3..329cf9e3f 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -98,6 +98,7 @@ import jogamp.common.awt.AWTEDTExecutor; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableHelper; +import jogamp.opengl.GLDrawableImpl; // FIXME: Subclasses need to call resetGLFunctionAvailability() on their // context whenever the displayChanged() function is called on our @@ -109,6 +110,16 @@ import jogamp.opengl.GLDrawableHelper; interfaces when adding a heavyweight doesn't work either because of Z-ordering or LayoutManager problems. * + *
Offscreen Layer Remarks
+ * + * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} + * maybe called to use an offscreen drawable (FBO or PBuffer) allowing + * the underlying JAWT mechanism to composite the image, if supported. + *

+ * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} + * is being called if {@link GLCapabilitiesImmutable#isOnscreen()} is false. + *

+ * *
Java2D OpenGL Remarks
* * To avoid any conflicts with a potential Java2D OpenGL context,
@@ -145,7 +156,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private final RecursiveLock lock = LockFactory.createRecursiveLock(); private final GLDrawableHelper helper = new GLDrawableHelper(); private AWTGraphicsConfiguration awtConfig; - private volatile GLDrawable drawable; // volatile: avoid locking for read-only access + private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access private volatile JAWTWindow jawtWindow; // the JAWTWindow presentation of this AWT Canvas, bound to the 'drawable' lifecycle private GLContextImpl context; private volatile boolean sendReshape = false; // volatile: maybe written by EDT w/o locking @@ -237,6 +248,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // don't allow the user to change data capsReqUser = (GLCapabilitiesImmutable) capsReqUser.cloneMutable(); } + if(!capsReqUser.isOnscreen()) { + setShallUseOffscreenLayer(true); // trigger offscreen layer - if supported + } if(null==device) { GraphicsConfiguration gc = super.getGraphicsConfiguration(); @@ -451,11 +465,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing /** Overridden to cause OpenGL rendering to be performed during repaint cycles. Subclasses which override this method must call super.paint() in their paint() method in order to function - properly.

- - Overrides: -

paint in class java.awt.Component
*/ - @Override + properly. + */ + @Override public void paint(Graphics g) { if (Beans.isDesignTime()) { // Make GLCanvas behave better in NetBeans GUI builder @@ -544,7 +556,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); jawtWindow.lockSurface(); try { - drawable = GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); + drawable = (GLDrawableImpl) GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); context = (GLContextImpl) drawable.createContext(shareWith); context.setContextCreationFlags(additionalCtxCreationFlags); } finally { @@ -561,13 +573,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if (!Beans.isDesignTime() && 0 < _drawable.getWidth() * _drawable.getHeight() ) { // make sure drawable realization happens on AWT EDT, due to AWTTree lock - AWTEDTExecutor.singleton.invoke(true, setRealizedOnEDTAction); - sendReshape=true; // ensure a reshape is being send .. - if(DEBUG) { - System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString()); - Thread.dumpStack(); + AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction); + if( _drawable.isRealized() ) { + sendReshape=true; // ensure a reshape is being send .. + if(DEBUG) { + System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString()); + Thread.dumpStack(); + } + return true; } - return true; } } return false; @@ -575,7 +589,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private Runnable setRealizedOnEDTAction = new Runnable() { @Override public void run() { - drawable.setRealized(true); + final GLDrawable _drawable = drawable; + if ( null != _drawable && 0 < _drawable.getWidth() * _drawable.getHeight() ) { + _drawable.setRealized(true); + } } }; /**

Overridden to track when this component is removed from a @@ -620,22 +637,37 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @SuppressWarnings("deprecation") @Override public void reshape(int x, int y, int width, int height) { - super.reshape(x, y, width, height); - final GLDrawable _drawable = drawable; - if(null != _drawable && _drawable.isRealized() && !_drawable.getChosenGLCapabilities().isOnscreen()) { - dispose(true); - } else { - sendReshape = true; + synchronized (getTreeLock()) { // super.reshape(..) claims tree lock, so we do extend it's lock over reshape + super.reshape(x, y, width, height); + + GLDrawableImpl _drawable = drawable; + if( null != _drawable ) { + if(DEBUG) { + System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+width+"x"+height+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + } + if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) { + final RecursiveLock _lock = lock; + _lock.lock(); + try { + final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, width, height); + if(_drawable != _drawableNew) { + // write back + drawable = _drawableNew; + } + } finally { + _lock.unlock(); + } + } + sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock + } } } - /** Overrides: -

update in class java.awt.Component
*/ /** * Overridden from Canvas to prevent the AWT's clearing of the * canvas from interfering with the OpenGL rendering. */ - @Override + @Override public void update(Graphics g) { paint(g); } @@ -681,7 +713,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing _lock.lock(); try { final GLContext oldCtx = context; - final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + final boolean newCtxCurrent = GLDrawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; if(newCtxCurrent) { context.makeCurrent(); @@ -692,6 +724,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } + @Override + public final GLDrawable getDelegatedDrawable() { + return drawable; + } + @Override public GLContext getContext() { return context; @@ -866,7 +903,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if(!disposeRegenerate) { if(null != awtConfig) { - disposeAbstractGraphicsDevice(); + AWTEDTExecutor.singleton.invoke(getTreeLock(), true, disposeAbstractGraphicsDeviceActionOnEDT); } awtConfig=null; } @@ -881,7 +918,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } }; - private final Runnable disposeAbstractGraphicsDeviceAction = new Runnable() { + /** + * Disposes the AbstractGraphicsDevice within EDT, + * since resources created (X11: Display), must be destroyed in the same thread, where they have been created. + * + * @see #chooseGraphicsConfiguration(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, java.awt.GraphicsDevice) + */ + private final Runnable disposeAbstractGraphicsDeviceActionOnEDT = new Runnable() { @Override public void run() { if(null != awtConfig) { @@ -900,27 +943,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } }; - - /** - * Disposes the AbstractGraphicsDevice within EDT, - * since resources created (X11: Display), must be destroyed in the same thread, where they have been created. - * - * @see #chooseGraphicsConfiguration(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, java.awt.GraphicsDevice) - */ - private void disposeAbstractGraphicsDevice() { - if( EventQueue.isDispatchThread() || Thread.holdsLock(getTreeLock()) ) { - disposeAbstractGraphicsDeviceAction.run(); - } else { - try { - EventQueue.invokeAndWait(disposeAbstractGraphicsDeviceAction); - } catch (InvocationTargetException e) { - throw new GLException(e.getTargetException()); - } catch (InterruptedException e) { - throw new GLException(e); - } - } - } - + private final Runnable initAction = new Runnable() { @Override public void run() { @@ -1046,7 +1069,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing * @param device * @return the chosen AWTGraphicsConfiguration * - * @see #disposeAbstractGraphicsDevice() + * @see #disposeAbstractGraphicsDeviceActionOnEDT */ private AWTGraphicsConfiguration chooseGraphicsConfiguration(final GLCapabilitiesImmutable capsChosen, final GLCapabilitiesImmutable capsRequested, diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index acb8f2183..6d4a5861f 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -121,7 +121,7 @@ import com.jogamp.opengl.util.GLBuffers; *

*/ -@SuppressWarnings("serial") +@SuppressWarnings({ "serial", "deprecation" }) public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("GLJPanel"); @@ -396,7 +396,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing their reshape() method in order to function properly.

reshape in class java.awt.Component
*/ - @SuppressWarnings("deprecation") @Override public void reshape(int x, int y, int width, int height) { super.reshape(x, y, width, height); @@ -471,7 +470,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return null; } final GLContext oldCtx = backend.getContext(); - final boolean newCtxCurrent = helper.switchContext(backend.getDrawable(), oldCtx, newCtx, additionalCtxCreationFlags); + final boolean newCtxCurrent = GLDrawableHelper.switchContext(backend.getDrawable(), oldCtx, newCtx, additionalCtxCreationFlags); backend.setContext(newCtx); if(newCtxCurrent) { newCtx.makeCurrent(); @@ -480,6 +479,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } + @Override + public final GLDrawable getDelegatedDrawable() { + if (backend == null) { + return null; + } + return backend.getDrawable(); + } + @Override public GLContext getContext() { if (backend == null) { diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index cc4e1b434..07029f143 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -30,16 +30,15 @@ package jogamp.opengl; import java.io.PrintStream; -import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.WindowClosingProtocol; import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; import javax.media.opengl.FPSCounter; import javax.media.opengl.GL; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLAutoDrawableDelegate; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; @@ -49,6 +48,7 @@ import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.opengl.GLAutoDrawableDelegate; import com.jogamp.opengl.util.Animator; @@ -61,38 +61,36 @@ import com.jogamp.opengl.util.Animator; * @see GLWindow */ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { - public static final boolean DEBUG = Debug.debug("GLAutoDrawable"); + public static final boolean DEBUG = GLDrawableImpl.DEBUG; protected final GLDrawableHelper helper = new GLDrawableHelper(); protected final FPSCounterImpl fpsCounter = new FPSCounterImpl(); protected volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access protected GLContextImpl context; - protected final boolean ownDevice; + protected final boolean ownsDevice; protected int additionalCtxCreationFlags = 0; protected volatile boolean sendReshape = false; // volatile: maybe written by WindowManager thread w/o locking protected volatile boolean sendDestroy = false; // volatile: maybe written by WindowManager thread w/o locking /** - * @param drawable a valid {@link GLDrawableImpl}, may not be realized yet. - * @param context a valid {@link GLContextImpl}, may not be made current (created) yet. - * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, - * otherwise pass false. Closing the device is required in case - * the drawable is created w/ it's own new instance, e.g. offscreen drawables, - * and no further lifecycle handling is applied. + * @param drawable upstream {@link GLDrawableImpl} instance, may be null for lazy initialization + * @param context upstream {@link GLContextImpl} instance, may be null for lazy initialization + * @param ownsDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, + * otherwise pass false. Closing the device is required in case + * the drawable is created w/ it's own new instance, e.g. offscreen drawables, + * and no further lifecycle handling is applied. */ - public GLAutoDrawableBase(GLDrawableImpl drawable, GLContextImpl context, boolean ownDevice) { + public GLAutoDrawableBase(GLDrawableImpl drawable, GLContextImpl context, boolean ownsDevice) { this.drawable = drawable; this.context = context; - this.ownDevice = ownDevice; + this.ownsDevice = ownsDevice; resetFPSCounter(); } + /** Returns the recursive lock object of the upstream implementation, which synchronizes multithreaded access. */ protected abstract RecursiveLock getLock(); - /** Returns the delegated GLDrawable */ - public final GLDrawable getDelegatedDrawable() { return drawable; } - /** Default implementation to handle repaint events from the windowing system */ protected final void defaultWindowRepaintOp() { final GLDrawable _drawable = drawable; @@ -103,29 +101,43 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } } - /** Default implementation to handle resize events from the windowing system */ - protected final void defaultWindowResizedOp() { - final GLDrawable _drawable = drawable; + /** Default implementation to handle resize events from the windowing system. All required locks are being claimed. */ + protected final void defaultWindowResizedOp(int newWidth, int newHeight) throws NativeWindowException, GLException { + GLDrawableImpl _drawable = drawable; if( null!=_drawable ) { if(DEBUG) { - System.err.println("GLAutoDrawableBase.sizeChanged: ("+Thread.currentThread().getName()+"): "+getWidth()+"x"+getHeight()+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + System.err.println("GLAutoDrawableBase.sizeChanged: ("+Thread.currentThread().getName()+"): "+newWidth+"x"+newHeight+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + } + if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) { + final RecursiveLock _lock = getLock(); + _lock.lock(); + try { + final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, newWidth, newHeight); + if(_drawable != _drawableNew) { + // write back + _drawable = _drawableNew; + drawable = _drawableNew; + } + } finally { + _lock.unlock(); + } } sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock if( _drawable.isRealized() ) { if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isAnimatorAnimating() ) { display(); } - } + } } } - + /** * Default implementation to handle destroy notifications from the windowing system. * *

* If the {@link NativeSurface} does not implement {@link WindowClosingProtocol} * or {@link WindowClosingMode#DISPOSE_ON_CLOSE} is enabled (default), - * {@link #defaultDestroy()} is being called. + * a thread safe destruction is being induced. *

*/ protected final void defaultWindowDestroyNotifyOp() { @@ -174,7 +186,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { ctrl.resume(); } } else if (null != ns && ns.isSurfaceLockedByOtherThread()) { - // surface is locked by another thread + // Surface is locked by another thread. // Flag that destroy should be performed on the next // attempt to display. sendDestroy = true; // async, but avoiding deadlock @@ -225,7 +237,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } _drawable.setRealized(false); } - if( ownDevice ) { + if( ownsDevice ) { _drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice().close(); } } @@ -238,7 +250,6 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { _lock.lock(); try { if(drawable!=null && context != null) { - drawable.swapBuffers(); helper.invokeGL(drawable, context, defaultSwapAction, defaultInitAction); } } finally { @@ -276,7 +287,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { destroy(); return; } - final RecursiveLock _lock = getLock(); + final RecursiveLock _lock = getLock(); _lock.lock(); try { if( null != context ) { @@ -294,6 +305,11 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { drawable.swapBuffers(); } } ; + @Override + public final GLDrawable getDelegatedDrawable() { + return drawable; + } + @Override public final GLContext getContext() { return context; @@ -305,7 +321,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { lock.lock(); try { final GLContext oldCtx = context; - final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + final boolean newCtxCurrent = GLDrawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; if(newCtxCurrent) { context.makeCurrent(); @@ -529,4 +545,10 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { final GLDrawable _drawable = drawable; return null != _drawable ? _drawable.getHandle() : 0; } + + @Override + public String toString() { + return getClass().getSimpleName()+"[ \n\tHelper: " + helper + ", \n\tDrawable: " + drawable + + ", \n\tContext: " + context + /** ", \n\tWindow: "+window+ ", \n\tFactory: "+factory+ */ "]"; + } } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index e82756022..050c619fd 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -47,6 +47,7 @@ import java.util.Map; import com.jogamp.common.os.DynamicLookupHelper; import com.jogamp.common.util.ReflectionUtil; +import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.FunctionAddressResolver; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLNameResolver; @@ -85,6 +86,7 @@ public abstract class GLContextImpl extends GLContext { private String glRenderer; private String glRendererLowerCase; + private String glVersion; // Tracks creation and initialization of buffer objects to avoid // repeated glGet calls upon glMapBuffer operations @@ -126,6 +128,9 @@ public abstract class GLContextImpl extends GLContext { GLContextShareSet.synchronizeBufferObjectSharing(shareWith, this); this.drawable = drawable; + if(null != drawable) { + drawable.associateContext(this, true); + } this.drawableRead = drawable; this.glDebugHandler = new GLDebugMessageHandler(this); @@ -205,8 +210,10 @@ public abstract class GLContextImpl extends GLContext { if(!setWriteOnly || drawableRead==drawable) { // if !setWriteOnly || !explicitReadDrawable drawableRead = (GLDrawableImpl) readWrite; } - final GLDrawable old = drawable; + final GLDrawableImpl old = drawable; + old.associateContext(this, false); drawable = (GLDrawableImpl) readWrite ; + drawable.associateContext(this, true); if(lockHeld) { makeCurrent(); } @@ -272,7 +279,7 @@ public abstract class GLContextImpl extends GLContext { if( actualRelease ) { if( !inDestruction ) { try { - drawable.contextMadeCurrent(this, false); + contextMadeCurrent(false); } catch (Throwable t) { drawableContextMadeCurrentException = t; } @@ -331,7 +338,8 @@ public abstract class GLContextImpl extends GLContext { makeCurrent(); } try { - drawable.contextRealized(this, false); + contextRealized(false); + drawable.associateContext(this, false); } catch (Throwable t) { drawableContextRealizedException = t; } @@ -514,19 +522,17 @@ public abstract class GLContextImpl extends GLContext { gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ); } - drawable.contextRealized(this, true); + contextRealized(true); if(DEBUG || TRACE_SWITCH) { System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT_NEW - "+lock); } - } else { - drawable.contextMadeCurrent(this, true); - - if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT - "+lock); - } + } else if(TRACE_SWITCH) { + System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT - "+lock); } + contextMadeCurrent(true); + /* FIXME: refactor dependence on Java 2D / JOGL bridge // Try cleaning up any stale server-side OpenGL objects @@ -608,6 +614,20 @@ public abstract class GLContextImpl extends GLContext { } protected abstract void makeCurrentImpl() throws GLException; + /** + * @see GLDrawableImpl#contextRealized(GLContext, boolean) + */ + protected void contextRealized(boolean realized) { + drawable.contextRealized(this, realized); + } + + /** + * @see GLDrawableImpl#contextMadeCurrent(GLContext, boolean) + */ + protected void contextMadeCurrent(boolean current) { + drawable.contextMadeCurrent(this, current); + } + /** * Platform dependent entry point for context creation.
* @@ -934,52 +954,43 @@ public abstract class GLContextImpl extends GLContext { /** * If major > 0 || minor > 0 : Use passed values, determined at creation time - * If major==0 && minor == 0 : Use GL_VERSION * Otherwise .. don't touch .. */ private final void setContextVersion(int major, int minor, int ctp, boolean setVersionString) { - if (0==ctp) { + if ( 0 == ctp ) { throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } - if(major>0 || minor>0) { - if (!GLContext.isValidGLVersion(major, minor)) { - GLException e = new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); - throw e; - } - ctxMajorVersion = major; - ctxMinorVersion = minor; - ctxOptions = ctp; - if(setVersionString) { - ctxVersionString = getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, getGL().glGetString(GL.GL_VERSION)); - } - return; + + if (!GLContext.isValidGLVersion(major, minor)) { + throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } - - if(major==0 && minor==0) { - String versionStr = getGL().glGetString(GL.GL_VERSION); - if(null==versionStr) { - throw new GLException("GL_VERSION is NULL: "+this); - } - ctxOptions = ctp; - - // Set version - GLVersionNumber version = new GLVersionNumber(versionStr); + ctxMajorVersion = major; + ctxMinorVersion = minor; + ctxOptions = ctp; + if(setVersionString) { + ctxVersionString = getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, getGL().glGetString(GL.GL_VERSION)); + } + } + + private static final VersionNumber getGLVersionNumber(int ctp, String glVersionStr) { + if( null != glVersionStr ) { + final GLVersionNumber version = new GLVersionNumber(glVersionStr); if (version.isValid()) { - ctxMajorVersion = version.getMajor(); - ctxMinorVersion = version.getMinor(); - // We cannot promote a non ARB context to >= 3.1, - // reduce it to 3.0 then. - if ( ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=1 ) - && 0 == (ctxOptions & CTX_IS_ARB_CREATED) ) { - ctxMajorVersion = 3; - ctxMinorVersion = 0; - } - if(setVersionString) { - ctxVersionString = getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, versionStr); - } - return; + int major = version.getMajor(); + int minor = version.getMinor(); + // We cannot promote a non ARB context to >= 3.1, + // reduce it to 3.0 then. + if ( 0 == (ctp & CTX_IS_ARB_CREATED) && + ( major > 3 || major == 3 && minor >= 1 ) ) { + major = 3; + minor = 0; + } + if ( GLContext.isValidGLVersion(major, minor) ) { + return new VersionNumber(major, minor, 0); + } } } + return null; } //---------------------------------------------------------------------- @@ -1019,14 +1030,18 @@ public abstract class GLContextImpl extends GLContext { /** * Pbuffer support; given that this is a GLContext associated with a * pbuffer, binds this pbuffer to its texture target. + * @throws GLException if not implemented (default) + * @deprecated use FBO/GLOffscreenAutoDrawable instead of pbuffer */ - public abstract void bindPbufferToTexture(); + public void bindPbufferToTexture() { throw new GLException("not implemented"); } /** * Pbuffer support; given that this is a GLContext associated with a * pbuffer, releases this pbuffer from its texture target. + * @throws GLException if not implemented (default) + * @deprecated use FBO/GLOffscreenAutoDrawable instead of pbuffer */ - public abstract void releasePbufferFromTexture(); + public void releasePbufferFromTexture() { throw new GLException("not implemented"); } public abstract ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3); @@ -1064,7 +1079,7 @@ public abstract class GLContextImpl extends GLContext { table.reset(getDrawableImpl().getGLDynamicLookupHelper() ); } - private final boolean initGLRendererStrings() { + private final boolean initGLRendererAndGLVersionStrings() { final GLDynamicLookupHelper glDynLookupHelper = getDrawableImpl().getGLDynamicLookupHelper(); final long _glGetString = glDynLookupHelper.dynamicLookupFunction("glGetString"); if(0 == _glGetString) { @@ -1083,14 +1098,27 @@ public abstract class GLContextImpl extends GLContext { Thread.dumpStack(); } return false; - } else { - glRenderer = _glRenderer; - glRendererLowerCase = glRenderer.toLowerCase(); - return true; } + glRenderer = _glRenderer; + glRendererLowerCase = glRenderer.toLowerCase(); + + final String _glVersion = glGetStringInt(GL.GL_VERSION, _glGetString); + if(null == _glVersion) { + // FIXME + if(DEBUG) { + System.err.println("Warning: GL_VERSION is NULL."); + Thread.dumpStack(); + } + return false; + } + glVersion = _glVersion; + return true; } } + protected final String getGLVersionString() { + return glVersion; + } protected final String getGLRendererString(boolean lowerCase) { return lowerCase ? glRendererLowerCase : glRenderer; } @@ -1128,17 +1156,44 @@ public abstract class GLContextImpl extends GLContext { final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); - if( !initGLRendererStrings() && DEBUG) { - System.err.println("Warning: intialization of GL renderer strings failed. "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); + { + final boolean initGLRendererAndGLVersionStringsOK = initGLRendererAndGLVersionStrings(); + if(DEBUG) { + if( !initGLRendererAndGLVersionStringsOK ) { + System.err.println("Warning: setGLFunctionAvailability: intialization of GL renderer strings failed. "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); + } else { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Given "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)); + } + } } if(!isCurrentContextHardwareRasterizer()) { ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; } - + + // Pick the version from the GL-version string, + // if smaller _or_ given major == 0. + final VersionNumber glVersionNumber; + { + final VersionNumber setGLVersionNumber = new VersionNumber(major, minor, 0); + final VersionNumber strGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion); + if( null != strGLVersionNumber && ( strGLVersionNumber.compareTo(setGLVersionNumber) <= 0 || 0 == major ) ) { + glVersionNumber = strGLVersionNumber; + major = glVersionNumber.getMajor(); + minor = glVersionNumber.getMinor(); + } else { + glVersionNumber = setGLVersionNumber; + } + } + if ( !GLContext.isValidGLVersion(major, minor) ) { + throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctxProfileBits)+", "+glVersion+", "+glVersionNumber); + } + if( 2 > major ) { // there is no ES2-compat for a profile w/ major < 2 + ctxProfileBits &= ~GLContext.CTX_IMPL_ES2_COMPAT; + } contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits); if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.0 FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.0 validated FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion) + ", "+glVersionNumber); } // @@ -1201,6 +1256,10 @@ public abstract class GLContextImpl extends GLContext { ctxProfileBits |= CTX_IMPL_FBO; } + if(FORCE_NO_FBO_SUPPORT) { + ctxProfileBits &= ~CTX_IMPL_FBO ; + } + // // Set GL Version (complete w/ version string) // diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index e1e253d35..4f965f620 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -48,18 +48,21 @@ import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.MutableSurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; -import javax.media.opengl.GLCapabilities; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; +import javax.media.opengl.GLFBODrawable; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; import com.jogamp.nativewindow.MutableGraphicsConfiguration; +import com.jogamp.nativewindow.DelegatedUpstreamSurfaceHookWithSurfaceSize; +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; /** Extends GLDrawableFactory with a few methods for handling @@ -67,6 +70,7 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration; Independent Bitmaps on Windows, pixmaps on X11). Direct access to these GLDrawables is not supplied directly to end users, though they may be instantiated by the GLJPanel implementation. */ +@SuppressWarnings("deprecation") public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { protected static final boolean DEBUG = GLDrawableImpl.DEBUG; @@ -141,55 +145,53 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(target, true); if(null != ols) { // layered surface -> Offscreen/[FBO|PBuffer] - final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable(); - chosenCapsMod.setOnscreen(false); - chosenCapsMod.setDoubleBuffered(false); - /* if( isFBOAvailable ) { // FIXME JAU: FBO n/a yet - chosenCapsMod.setFBO(true); - } else */ - if( canCreateGLPbuffer(adevice) ) { - chosenCapsMod.setPBuffer(true); - } else { - chosenCapsMod.setFBO(false); - chosenCapsMod.setPBuffer(false); + final boolean isPbufferAvailable = canCreateGLPbuffer(adevice) ; + if(!isPbufferAvailable && !isFBOAvailable) { + throw new GLException("Neither FBO nor Pbuffer is available for "+target); } + final GLCapabilitiesImmutable chosenCapsMod = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(chosenCaps, isFBOAvailable, isPbufferAvailable); config.setChosenCapabilities(chosenCapsMod); + ols.setChosenCapabilities(chosenCapsMod); if(DEBUG) { - System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable -> Offscreen-Layer: "+target); + System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable -> Offscreen-Layer"); + System.err.println("chosenCaps: "+chosenCaps); + System.err.println("chosenCapsMod: "+chosenCapsMod); + System.err.println("OffscreenLayerSurface: **** "+ols); + System.err.println("Target: **** "+target); + Thread.dumpStack(); } if( ! ( target instanceof MutableSurface ) ) { throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen layered surface: "+target); } - if( ((GLCapabilitiesImmutable)config.getRequestedCapabilities()).isFBO() && isFBOAvailable ) { - // FIXME JAU: Need to revise passed MutableSurface to work w/ FBO .. - final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(target); - result = new GLFBODrawableImpl(this, dummyDrawable, target, target.getWidth(), target.getHeight(), 0 /* textureUnit */); + if( chosenCapsMod.isFBO() && isFBOAvailable ) { + // target surface is already a native one + result = createFBODrawableImpl(target, chosenCapsMod, 0); } else { result = createOffscreenDrawableImpl(target); } } else if(chosenCaps.isOnscreen()) { // onscreen + final GLCapabilitiesImmutable chosenCapsMod = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); + config.setChosenCapabilities(chosenCapsMod); if(DEBUG) { System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable: "+target); } result = createOnscreenDrawableImpl(target); } else { // offscreen - final GLCapabilitiesImmutable reqCaps = (GLCapabilitiesImmutable)config.getRequestedCapabilities(); if(DEBUG) { - System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable, FBO req / chosen - avail, PBuffer: "+reqCaps.isFBO()+" / "+chosenCaps.isFBO()+" - "+isFBOAvailable+", "+chosenCaps.isPBuffer()+": "+target); + System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable, FBO chosen / avail, PBuffer: "+ + chosenCaps.isFBO()+" / "+isFBOAvailable+", "+chosenCaps.isPBuffer()+": "+target); } if( ! ( target instanceof MutableSurface ) ) { - throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen: "+target); + throw new IllegalArgumentException("Passed NativeSurface must implement MutableSurface for offscreen: "+target); } - if( reqCaps.isFBO() && isFBOAvailable ) { - // FIXME JAU: Need to revise passed MutableSurface to work w/ FBO .. - final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(target); - result = new GLFBODrawableImpl(this, dummyDrawable, target, target.getWidth(), target.getHeight(), 0 /* textureUnit */); + if( chosenCaps.isFBO() && isFBOAvailable ) { + // need to hook-up a native dummy surface since source may not have + final ProxySurface dummySurface = createDummySurfaceImpl(adevice, true, chosenCaps, null, 64, 64); + dummySurface.setUpstreamSurfaceHook(new DelegatedUpstreamSurfaceHookWithSurfaceSize(dummySurface.getUpstreamSurfaceHook(), target)); + result = createFBODrawableImpl(dummySurface, chosenCaps, 0); } else { - final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable(); - chosenCapsMod.setDoubleBuffered(false); - config.setChosenCapabilities(chosenCapsMod); result = createOffscreenDrawableImpl(target); } } @@ -211,7 +213,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { //--------------------------------------------------------------------------- // - // PBuffer Offscreen GLDrawable construction + // PBuffer Offscreen GLAutoDrawable construction // @Override @@ -239,7 +241,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { GLDrawableImpl drawable = null; device.lock(); try { - drawable = (GLDrawableImpl) createGLDrawable( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, width, height, null) ); + drawable = createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, + new UpstreamSurfaceHookMutableSize(width, height) ) ); if(null != drawable) { drawable.setRealized(true); } @@ -247,10 +250,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { device.unlock(); } - if(null==drawable) { - throw new GLException("Could not create Pbuffer drawable for: "+device+", "+capsChosen+", "+width+"x"+height); - } - return new GLPbufferImpl( drawable, shareWith, true); + return new GLPbufferImpl( drawable, (GLContextImpl) drawable.createContext(shareWith) ); } //--------------------------------------------------------------------------- @@ -258,6 +258,29 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { // Offscreen GLDrawable construction // + public final boolean canCreateFBO(AbstractGraphicsDevice deviceReq, GLProfile glp) { + AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); + if(null == device) { + throw new GLException("No shared device for requested: "+deviceReq); + } + return GLContext.isFBOAvailable(device, glp); + } + + @Override + public GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice deviceReq, + GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, + int width, int height, + GLContext shareWith) { + final GLDrawable drawable = createOffscreenDrawable( deviceReq, capsRequested, chooser, width, height ); + drawable.setRealized(true); + final GLContext context = drawable.createContext(shareWith); + if(drawable instanceof GLFBODrawableImpl) { + return new GLOffscreenAutoDrawableImpl.FBOImpl( (GLFBODrawableImpl)drawable, context, null, null ); + } + return new GLOffscreenAutoDrawableImpl( drawable, context, null, null); + } + @Override public GLDrawable createOffscreenDrawable(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable capsRequested, @@ -274,10 +297,13 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, GLContext.isFBOAvailable(device, capsRequested.getGLProfile()), canCreateGLPbuffer(device)); + if( capsChosen.isFBO() ) { device.lock(); try { - return createFBODrawableImpl(device, capsRequested, chooser, width, height); + final ProxySurface dummySurface = createDummySurfaceImpl(device, true, capsRequested, null, width, height); + final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); + return new GLFBODrawableImpl.ResizeableImpl(this, dummyDrawable, dummySurface, capsChosen, 0); } finally { device.unlock(); } @@ -285,20 +311,17 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { device.lock(); try { - return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, width, height, null) ); + return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, + new UpstreamSurfaceHookMutableSize(width, height) ) ); } finally { device.unlock(); } } - /** Creates a platform independent offscreen FBO GLDrawable implementation */ - protected GLDrawable createFBODrawableImpl(AbstractGraphicsDevice device, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, - int initialWidth, int initialHeight) { - final GLCapabilitiesImmutable dummyCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); - final NativeSurface dummySurface = createDummySurfaceImpl(device, true, dummyCaps, null, 64, 64); + /** Creates a platform independent FBO offscreen GLDrawable */ + protected GLFBODrawable createFBODrawableImpl(NativeSurface dummySurface, GLCapabilitiesImmutable fboCaps, int textureUnit) { final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); - - return new GLFBODrawableImpl(this, dummyDrawable, dummySurface, initialWidth, initialHeight, 0 /* textureUnit */); + return new GLFBODrawableImpl(this, dummyDrawable, dummySurface, fboCaps, textureUnit); } /** Creates a platform dependent offscreen pbuffer/pixmap GLDrawable implementation */ @@ -318,15 +341,13 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @param capsChosen * @param capsRequested * @param chooser the custom chooser, may be null for default - * @param width the initial width - * @param height the initial height - * @param lifecycleHook optional control of the surface's lifecycle + * @param upstreamHook surface size information and optional control of the surface's lifecycle * @return the created {@link MutableSurface} instance w/o defined surface handle */ protected abstract ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook); + GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook); /** * A dummy surface is not visible on screen and will not be used to render directly to, @@ -341,9 +362,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @param width the initial width * @param height the initial height * - * @return the created {@link MutableSurface} instance w/o defined surface handle + * @return the created {@link ProxySurface} instance w/o defined surface handle but platform specific {@link UpstreamSurfaceHook}. */ - public NativeSurface createDummySurface(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, + public ProxySurface createDummySurface(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { final AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); if(null == device) { @@ -369,9 +390,11 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * otherwise device instance is used as-is. * @param requestedCaps * @param chooser the custom chooser, may be null for default - * @param width the initial width - * @param height the initial height - * @return the created {@link MutableSurface} instance w/o defined surface handle + * @param width the initial width as returned by {@link NativeSurface#getWidth()}, not the actual dummy surface width. + * The latter is platform specific and small + * @param height the initial height as returned by {@link NativeSurface#getHeight()}, not the actual dummy surface height, + * The latter is platform specific and small + * @return the created {@link ProxySurface} instance w/o defined surface handle but platform specific {@link UpstreamSurfaceHook}. */ public abstract ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 090c5fe69..bdf0b6d74 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -43,12 +43,19 @@ package jogamp.opengl; import java.util.ArrayList; import java.util.HashSet; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; +import javax.media.opengl.GLFBODrawable; import javax.media.opengl.GLRunnable; import com.jogamp.opengl.util.Animator; @@ -108,24 +115,27 @@ public class GLDrawableHelper { /** * Associate a new context to the drawable and also propagates the context/drawable switch by * calling {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. - *

- * If the old context's drawable was an {@link GLAutoDrawable}, it's reference to the given drawable - * is being cleared by calling - * {@link GLAutoDrawable#setContext(GLContext) ((GLAutoDrawable)oldCtx.getGLDrawable()).setContext(null)}. - *

*

* If the old or new context was current on this thread, it is being released before switching the drawable. *

+ *

+ * Be aware that the old context is still bound to the drawable, + * and that one context can only bound to one drawable at one time! + *

+ *

+ * No locking is being performed on the drawable, caller is required to take care of it. + *

* * @param drawable the drawable which context is changed - * @param newCtx the new context * @param oldCtx the old context - * @return true if the newt context was current, otherwise false + * @param newCtx the new context + * @param newCtxCreationFlags additional creation flags if newCtx is not null and not been created yet, see {@link GLContext#setContextCreationFlags(int)} + * @return true if the new context was current, otherwise false * * @see GLAutoDrawable#setContext(GLContext) */ - public final boolean switchContext(GLDrawable drawable, GLContext oldCtx, GLContext newCtx, int additionalCtxCreationFlags) { - if(null != oldCtx && oldCtx.isCurrent()) { + public static final boolean switchContext(GLDrawable drawable, GLContext oldCtx, GLContext newCtx, int newCtxCreationFlags) { + if( null != oldCtx && oldCtx.isCurrent() ) { oldCtx.release(); } final boolean newCtxCurrent; @@ -134,17 +144,135 @@ public class GLDrawableHelper { if(newCtxCurrent) { newCtx.release(); } - newCtx.setContextCreationFlags(additionalCtxCreationFlags); + newCtx.setContextCreationFlags(newCtxCreationFlags); newCtx.setGLDrawable(drawable, true); // propagate context/drawable switch } else { newCtxCurrent = false; } - if(null!=oldCtx && oldCtx.getGLDrawable() instanceof GLAutoDrawable) { - ((GLAutoDrawable)oldCtx.getGLDrawable()).setContext(null); - } return newCtxCurrent; } + /** + * If the drawable is not realized, OP is a NOP. + *
    + *
  • release context if current
  • + *
  • destroy old drawable
  • + *
  • create new drawable
  • + *
  • attach new drawable to context
  • + *
  • make context current, if it was current
  • + *
+ *

+ * No locking is being performed, caller is required to take care of it. + *

+ * + * @param drawable + * @param context maybe null + * @return the new drawable + */ + public static final GLDrawableImpl recreateGLDrawable(GLDrawableImpl drawable, GLContext context) { + if( ! drawable.isRealized() ) { + return drawable; + } + final boolean contextCurrent = null != context && context.isCurrent(); + final GLDrawableFactory factory = drawable.getFactory(); + final NativeSurface surface = drawable.getNativeSurface(); + final ProxySurface proxySurface = (surface instanceof ProxySurface) ? (ProxySurface)surface : null; + + if(contextCurrent) { + context.release(); + } + + if(null != proxySurface) { + proxySurface.enableUpstreamSurfaceHookLifecycle(false); + } + try { + drawable.setRealized(false); + drawable = (GLDrawableImpl) factory.createGLDrawable(surface); // [2] + drawable.setRealized(true); + } finally { + if(null != proxySurface) { + proxySurface.enableUpstreamSurfaceHookLifecycle(true); + } + } + + if(null != context) { + context.setGLDrawable(drawable, true); // re-association + } + + if(contextCurrent) { + context.makeCurrent(); + } + return drawable; + } + + /** + * Performs resize operation on the given drawable, assuming it is offscreen. + *

+ * The {@link GLDrawableImpl}'s {@link NativeSurface} is being locked during operation. + * In case the holder is an auto drawable or similar, it's lock shall be claimed by the caller. + *

+ *

+ * May recreate the drawable via {@link #recreateGLDrawable(GLDrawableImpl, GLContext)} + * in case of a a pbuffer- or pixmap-drawable. + *

+ *

+ * FBO drawables are resized w/o drawable destruction. + *

+ *

+ * Offscreen resize operation is validated w/ drawable size in the end. + * An exception is thrown if not successful. + *

+ * + * @param drawable + * @param context + * @param newWidth the new width, it's minimum is capped to 1 + * @param newHeight the new height, it's minimum is capped to 1 + * @return the new drawable in case of an pbuffer/pixmap drawable, otherwise the passed drawable is being returned. + * @throws NativeWindowException is drawable is not offscreen or it's surface lock couldn't be claimed + * @throws GLException may be thrown a resize operation + */ + public static final GLDrawableImpl resizeOffscreenDrawable(GLDrawableImpl drawable, GLContext context, int newWidth, int newHeight) + throws NativeWindowException, GLException + { + if(drawable.getChosenGLCapabilities().isOnscreen()) { + throw new NativeWindowException("Drawable is not offscreen: "+drawable); + } + final NativeSurface ns = drawable.getNativeSurface(); + final int lockRes = ns.lockSurface(); + if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { + throw new NativeWindowException("Could not lock surface of drawable: "+drawable); + } + try { + if(0>=newWidth) { newWidth = 1; } + if(0>=newHeight) { newHeight = 1; } + // propagate new size + if(ns instanceof ProxySurface) { + final ProxySurface ps = (ProxySurface) ns; + final UpstreamSurfaceHook ush = ps.getUpstreamSurfaceHook(); + if(ush instanceof UpstreamSurfaceHook.MutableSize) { + ((UpstreamSurfaceHook.MutableSize)ush).setSize(newWidth, newHeight); + } else if(DEBUG) { // we have to assume UpstreamSurfaceHook contains the new size already, hence size check @ bottom + System.err.println("GLDrawableHelper.resizeOffscreenDrawable: Drawable's offscreen ProxySurface n.a. UpstreamSurfaceHook.MutableSize, but "+ush.getClass().getName()+": "+ush); + } + } else if(DEBUG) { // we have to assume surface contains the new size already, hence size check @ bottom + System.err.println("GLDrawableHelper.resizeOffscreenDrawable: Drawable's offscreen surface n.a. ProxySurface, but "+ns.getClass().getName()+": "+ns); + } + if(drawable instanceof GLFBODrawable) { + if( null != context && context.isCreated() ) { + ((GLFBODrawable) drawable).resetSize(context.getGL()); + } + } else { + drawable = GLDrawableHelper.recreateGLDrawable(drawable, context); + } + } finally { + ns.unlockSurface(); + } + if(drawable.getWidth() != newWidth || drawable.getHeight() != newHeight) { + throw new InternalError("Incomplete resize operation: expected "+newWidth+"x"+newHeight+", has: "+drawable); + } + return drawable; + } + public final void addGLEventListener(GLEventListener listener) { addGLEventListener(-1, listener); } @@ -196,15 +324,11 @@ public class GLDrawableHelper { } } - private final boolean init(GLEventListener l, GLAutoDrawable drawable, boolean sendReshape) { - if(listenersToBeInit.remove(l)) { - l.init(drawable); - if(sendReshape) { - reshape(l, drawable, 0, 0, drawable.getWidth(), drawable.getHeight(), true /* setViewport */, false /* checkInit */); - } - return true; + private final void init(GLEventListener l, GLAutoDrawable drawable, boolean sendReshape) { + l.init(drawable); + if(sendReshape) { + reshape(l, drawable, 0, 0, drawable.getWidth(), drawable.getHeight(), true /* setViewport */, false /* checkInit */); } - return false; } /** The default init action to be called once after ctx is being created @ 1st makeCurrent(). */ @@ -214,14 +338,11 @@ public class GLDrawableHelper { for (int i=0; i < _listeners.size(); i++) { final GLEventListener listener = _listeners.get(i) ; - // If make current ctx, invoked by invokGL(..), results in a new ctx, init gets called. + // If make ctx current, invoked by invokGL(..), results in a new ctx, init gets called. // This may happen not just for initial setup, but for ctx recreation due to resource change (drawable/window), - // hence the must always be initialized unconditional. - listenersToBeInit.add(listener); - - if ( ! init( listener, drawable, true /* sendReshape */) ) { - throw new GLException("GLEventListener "+listener+" already initialized: "+drawable); - } + // hence it must be called unconditional, always. + listenersToBeInit.remove(listener); // remove if exist, avoiding dbl init + init( listener, drawable, true /* sendReshape */); } } } @@ -239,7 +360,9 @@ public class GLDrawableHelper { final GLEventListener listener = _listeners.get(i) ; // GLEventListener may need to be init, // in case this one is added after the realization of the GLAutoDrawable - init( listener, drawable, true /* sendReshape */) ; + if( listenersToBeInit.remove(listener) ) { + init( listener, drawable, true /* sendReshape */) ; + } listener.display(drawable); } } @@ -251,7 +374,9 @@ public class GLDrawableHelper { // GLEventListener may need to be init, // in case this one is added after the realization of the GLAutoDrawable synchronized(listenersLock) { - init( listener, drawable, false /* sendReshape */) ; + if( listenersToBeInit.remove(listener) ) { + init( listener, drawable, false /* sendReshape */) ; + } } } if(setViewport) { diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index abf2bf557..311690f1d 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -43,6 +43,7 @@ package jogamp.opengl; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.ProxySurface; +import javax.media.opengl.GL; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; @@ -76,31 +77,46 @@ public abstract class GLDrawableImpl implements GLDrawable { if( !realized ) { return; // destroyed already } - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities(); - if ( caps.getDoubleBuffered() ) { - if(!surface.surfaceSwap()) { - int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release] - if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { - return; + int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release] + if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { + return; + } + try { + if (NativeSurface.LOCK_SURFACE_CHANGED == lockRes) { + updateHandle(); + } + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities(); + if ( caps.getDoubleBuffered() ) { + if(!surface.surfaceSwap()) { + swapBuffersImpl(true); } - try { - if (NativeSurface.LOCK_SURFACE_CHANGED == lockRes) { - updateHandle(); - } - swapBuffersImpl(); - } finally { - unlockSurface(); + } else { + final GLContext ctx = GLContext.getCurrent(); + if(null!=ctx && ctx.getGLDrawable()==this) { + ctx.getGL().glFlush(); } + swapBuffersImpl(false); } - } else { - GLContext ctx = GLContext.getCurrent(); - if(null!=ctx && ctx.getGLDrawable()==this) { - ctx.getGL().glFinish(); - } - } + } finally { + unlockSurface(); + } surface.surfaceUpdated(this, surface, System.currentTimeMillis()); } - protected abstract void swapBuffersImpl(); + + /** + * Platform and implementation depending surface swap. + *

The surface is locked.

+ *

+ * If doubleBuffered is true, + * an actual platform dependent surface swap shall be executed. + *

+ *

+ * If doubleBuffered is false, + * {@link GL#glFlush()} has been called already and + * the implementation may execute implementation specific code. + *

+ */ + protected abstract void swapBuffersImpl(boolean doubleBuffered); public final static String toHexString(long hex) { return "0x" + Long.toHexString(hex); @@ -181,6 +197,9 @@ public abstract class GLDrawableImpl implements GLDrawable { System.err.println(getThreadName() + ": setRealized: "+getClass().getName()+" "+this.realized+" == "+realizedArg); } } + /** + * Platform specific realization of drawable + */ protected abstract void setRealizedImpl(); /** @@ -189,7 +208,7 @@ public abstract class GLDrawableImpl implements GLDrawable { * If realized is true, the context has just been created and made current. *

*

- * If realized is false, the context is still current and will be release and destroyed after this method returns. + * If realized is false, the context is still current and will be released and destroyed after this method returns. *

*

* @see #contextMadeCurrent(GLContext, boolean) @@ -199,18 +218,27 @@ public abstract class GLDrawableImpl implements GLDrawable { /** * Callback for special implementations, allowing GLContext to trigger GL related lifecycle: makeCurrent, release. *

- * Will not be called if {@link #contextRealized(GLContext, boolean)} has been triggered. - *

- *

* If current is true, the context has just been made current. *

*

* If current is false, the context is still current and will be release after this method returns. *

+ *

+ * Note: Will also be called after {@link #contextRealized(GLContext, boolean) contextRealized(ctx, true)} + * but not at context destruction, i.e. {@link #contextRealized(GLContext, boolean) contextRealized(ctx, false)}. + *

* @see #contextRealized(GLContext, boolean) */ protected void contextMadeCurrent(GLContext glc, boolean current) { } + /** + * Callback for special implementations, allowing to associate bound context to this drawable (bound == true) + * or to remove such association (bound == false). + * @param ctx the just bounded or unbounded context + * @param bound if true create an association, otherwise remove it + */ + protected void associateContext(GLContext ctx, boolean bound) { } + /** Callback for special implementations, allowing GLContext to fetch a custom default render framebuffer. Defaults to zero.*/ protected int getDefaultDrawFramebuffer() { return 0; } /** Callback for special implementations, allowing GLContext to fetch a custom default read framebuffer. Defaults to zero. */ @@ -245,8 +273,8 @@ public abstract class GLDrawableImpl implements GLDrawable { public String toString() { return getClass().getSimpleName()+"[Realized "+isRealized()+ ",\n\tFactory "+getFactory()+ - ",\n\thandle "+toHexString(getHandle())+ - ",\n\tWindow "+getNativeSurface()+"]"; + ",\n\tHandle "+toHexString(getHandle())+ + ",\n\tSurface "+getNativeSurface()+"]"; } protected static String getThreadName() { diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index 03bc26cbc..de45466f3 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -1,142 +1,476 @@ package jogamp.opengl; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.opengl.GL; -import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; +import javax.media.opengl.GLFBODrawable; import com.jogamp.nativewindow.MutableGraphicsConfiguration; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.FBObject.Attachment; +import com.jogamp.opengl.FBObject.Colorbuffer; import com.jogamp.opengl.FBObject.TextureAttachment; /** - * Offscreen GLDrawable implementation using framebuffer object (FBO) - * as it's offscreen rendering mechanism. + * {@link FBObject} offscreen GLDrawable implementation, i.e. {@link GLFBODrawable}. + *

+ * It utilizes the context lifecycle hook {@link #contextRealized(GLContext, boolean)} + * to initialize the {@link FBObject} instance. + *

+ *

+ * It utilizes the context current hook {@link #contextMadeCurrent(GLContext, boolean) contextMadeCurrent(context, true)} + * to {@link FBObject#bind(GL) bind} the FBO. + *

+ * See {@link GLFBODrawable} for double buffering details. * * @see GLDrawableImpl#contextRealized(GLContext, boolean) * @see GLDrawableImpl#contextMadeCurrent(GLContext, boolean) * @see GLDrawableImpl#getDefaultDrawFramebuffer() * @see GLDrawableImpl#getDefaultReadFramebuffer() */ -public class GLFBODrawableImpl extends GLDrawableImpl { - final GLDrawableImpl parent; - final FBObject fbo; - int texUnit; - int samplesTexUnit = 0; - int width=0, height=0, samples=0; - - protected GLFBODrawableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, - NativeSurface surface, int initialWidth, int initialHeight, int textureUnit) { +public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { + protected static final boolean DEBUG = GLDrawableImpl.DEBUG || Debug.debug("FBObject"); + + private final GLDrawableImpl parent; + + private boolean initialized; + private int texUnit; + private int samples; + + private FBObject[] fbos; + private int fboIBack; // points to GL_BACK buffer + private int fboIFront; // points to GL_FRONT buffer + private FBObject pendingFBOReset = null; + private boolean fboBound; + private static final int bufferCount = 2; // number of FBOs for double buffering. TODO: Possible to configure! + + // private DoubleBufferMode doubleBufferMode; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support + + private SwapBufferContext swapBufferContext; + + public static interface SwapBufferContext { + public void swapBuffers(boolean doubleBuffered); + } + + protected GLFBODrawableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, NativeSurface surface, + GLCapabilitiesImmutable fboCaps, int textureUnit) { super(factory, surface, false); + this.initialized = false; + + // Replace the chosen caps of dummy-surface w/ it's clone and copied values of orig FBO caps request. + // The dummy-surface has already been configured, hence value replace is OK + // and due to cloning, the native GLCapability portion is being preserved. + final MutableGraphicsConfiguration msConfig = (MutableGraphicsConfiguration) surface.getGraphicsConfiguration(); + final GLCapabilities fboCapsNative = (GLCapabilities) msConfig.getChosenCapabilities().cloneMutable(); + fboCapsNative.copyFrom(fboCaps); + msConfig.setChosenCapabilities(fboCapsNative); + this.parent = parent; this.texUnit = textureUnit; - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); - this.width = initialWidth; - this.height = initialHeight; - this.samples = caps.getNumSamples(); - this.fbo = new FBObject(); + this.samples = fboCaps.getNumSamples(); + + // default .. // TODO: Add or remove TEXTURE (only) DoubleBufferMode support + // this.doubleBufferMode = ( samples > 0 || fboCaps.getDoubleBuffered() ) ? DoubleBufferMode.FBO : DoubleBufferMode.NONE ; + + this.swapBufferContext = null; } - @Override - protected void contextRealized(GLContext glc, boolean realized) { - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); - final GL gl = glc.getGL(); - if(realized) { - fbo.reset(gl, width, height, samples); - samples = fbo.getNumSamples(); // update, maybe capped + private final void initialize(boolean realize, GL gl) { + if(realize) { + final int maxSamples = gl.getMaxRenderbufferSamples(); + samples = samples <= maxSamples ? samples : maxSamples; + + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); + final int fbosN; if(samples > 0) { - fbo.attachColorbuffer(gl, 0, caps.getAlphaBits()>0); + fbosN = 1; + } else if( caps.getDoubleBuffered() ) { + fbosN = bufferCount; } else { - fbo.attachTexture2D(gl, 0, caps.getAlphaBits()>0); + fbosN = 1; } - if( caps.getStencilBits() > 0 ) { - fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, 24); - } else { - fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); + + fbos = new FBObject[fbosN]; + fboIBack = 0; // head + fboIFront = fbos.length - 1; // tail + + for(int i=0; i 0) { + fbos[i].attachColorbuffer(gl, 0, caps.getAlphaBits()>0); + } else { + fbos[i].attachTexture2D(gl, 0, caps.getAlphaBits()>0); + } + if( caps.getStencilBits() > 0 ) { + fbos[i].attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, 24); + } else { + fbos[i].attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); + } } - } else if(null != fbo) { - fbo.destroy(gl); - } - } - - @Override - protected void contextMadeCurrent(GLContext glc, boolean current) { - final GL gl = glc.getGL(); - if(current) { - fbo.bind(gl); + fbos[fboIFront].syncFramebuffer(gl); + fboBound = false; + final GLCapabilities fboCapsNative = (GLCapabilities) surface.getGraphicsConfiguration().getChosenCapabilities(); + fbos[0].formatToGLCapabilities(fboCapsNative); + fboCapsNative.setDoubleBuffered( fboCapsNative.getDoubleBuffered() || samples > 0 ); + + initialized = true; } else { - fbo.unbind(gl); - final TextureAttachment attachment = samples > 0 ? fbo.getSamplingSink() : (TextureAttachment) fbo.getColorbuffer(0) ; - if(null == attachment) { - throw new GLException("Null texture colorbuffer, samples "+samples+", "+fbo.toString()); - } - gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit); - fbo.use(gl, attachment ); - if( samples > 0) { - gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, fbo.getReadFramebuffer()); + initialized = false; + + for(int i=0; i "+newSamples); + } + initialize(false, gl); + samples = newSamples; + initialize(true, gl); + } else { + if(DEBUG) { + System.err.println("GLFBODrawableImpl.reset(): simple reconfig: "+samples+" -> "+newSamples); + } + final int nWidth = getWidth(); + final int nHeight = getHeight(); + samples = newSamples; + pendingFBOReset = ( 1 < fbos.length ) ? fbos[fboIFront] : null; // pending-front reset only w/ double buffering (or zero samples) + for(int i=0; i 0 ) { + res = fbos[0].getSamplingSinkFBO(); + } else { + res = fbos[fboIFront]; + } + break; + case GL.GL_BACK: + res = fbos[fboIBack]; + break; + default: + throw new IllegalArgumentException(illegalBufferName+toHexString(bufferName)); + } + return res; + } + + @Override + public final TextureAttachment getTextureBuffer(int bufferName) throws IllegalArgumentException { + if(!initialized) { + return null; + } + final TextureAttachment res; + switch(bufferName) { + case GL.GL_FRONT: + if( samples > 0 ) { + res = fbos[0].getSamplingSink(); + } else { + res = (TextureAttachment) fbos[fboIFront].getColorbuffer(0); + } + break; + case GL.GL_BACK: + if( samples > 0 ) { + throw new IllegalArgumentException("Cannot access GL_BACK buffer of MSAA FBO: "+this); + } else { + res = (TextureAttachment) fbos[fboIBack].getColorbuffer(0); + } + break; + default: + throw new IllegalArgumentException(illegalBufferName+toHexString(bufferName)); + } + return res; + } + private static final String illegalBufferName = "Only GL_FRONT and GL_BACK buffer are allowed, passed "; + + @Override + public String toString() { + return getClass().getSimpleName()+"[Initialized "+initialized+", realized "+isRealized()+", texUnit "+texUnit+", samples "+samples+ + ",\n\tFactory "+getFactory()+ + ",\n\tHandle "+toHexString(getHandle())+ + ",\n\tCaps "+surface.getGraphicsConfiguration().getChosenCapabilities()+ + ",\n\tfboI back "+fboIBack+", front "+fboIFront+", num "+(initialized ? fbos.length : 0)+ + ",\n\tFBO front read "+getDefaultReadFramebuffer()+", "+getFBObject(GL.GL_FRONT)+ + ",\n\tFBO back write "+getDefaultDrawFramebuffer()+", "+getFBObject(GL.GL_BACK)+ + ",\n\tSurface "+getNativeSurface()+ + "]"; + } + + public static class ResizeableImpl extends GLFBODrawableImpl implements GLFBODrawable.Resizeable { + protected ResizeableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, ProxySurface surface, + GLCapabilitiesImmutable fboCaps, int textureUnit) { + super(factory, parent, surface, fboCaps, textureUnit); + } + + @Override + public final void setSize(GLContext context, int newWidth, int newHeight) throws NativeWindowException, GLException { + if(DEBUG) { + System.err.println("GLFBODrawableImpl.ResizeableImpl setSize: ("+Thread.currentThread().getName()+"): "+newWidth+"x"+newHeight+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + } + int lockRes = lockSurface(); + if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { + throw new NativeWindowException("Could not lock surface: "+this); + } + try { + // propagate new size + final ProxySurface ps = (ProxySurface) getNativeSurface(); + final UpstreamSurfaceHook ush = ps.getUpstreamSurfaceHook(); + if(ush instanceof UpstreamSurfaceHook.MutableSize) { + ((UpstreamSurfaceHook.MutableSize)ush).setSize(newWidth, newHeight); + } else { + throw new InternalError("GLFBODrawableImpl.ResizableImpl's ProxySurface doesn't hold a UpstreamSurfaceHookMutableSize but "+ush.getClass().getName()+", "+ps+", ush"); + } + if( null != context && context.isCreated() ) { + resetSize(context.getGL()); + } + } finally { + unlockSurface(); + } + } + } } diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java index 768fc6892..79f96b64a 100644 --- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java +++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java @@ -28,8 +28,12 @@ package jogamp.opengl; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; + +import com.jogamp.common.os.Platform; public class GLGraphicsConfigurationUtil { public static final String NV_coverage_sample = "NV_coverage_sample"; @@ -119,26 +123,34 @@ public class GLGraphicsConfigurationUtil { return getExclusiveWinAttributeBits(caps.isOnscreen(), caps.isFBO(), caps.isPBuffer(), caps.isBitmap()); } - public static final GLCapabilities setWinAttributeBits(GLCapabilities caps, int winattrbits) { + public static final GLCapabilities fixWinAttribBitsAndHwAccel(AbstractGraphicsDevice device, int winattrbits, GLCapabilities caps) { caps.setBitmap ( 0 != ( BITMAP_BIT & winattrbits ) ); caps.setPBuffer ( 0 != ( PBUFFER_BIT & winattrbits ) ); caps.setFBO ( 0 != ( FBO_BIT & winattrbits ) ); // we reflect availability semantics, hence setting onscreen at last (maybe overwritten above)! - caps.setOnscreen( 0 != ( WINDOW_BIT & winattrbits ) ); - return caps; - } + caps.setOnscreen( 0 != ( WINDOW_BIT & winattrbits ) ); + final int accel = GLContext.isHardwareRasterizer( device, caps.getGLProfile() ); + if(0 == accel && caps.getHardwareAccelerated() ) { + caps.setHardwareAccelerated(false); + } + + return caps; + } + public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) { if( !capsRequested.isOnscreen() ) { return fixOffscreenGLCapabilities(capsRequested, fboAvailable, pbufferAvailable); - } + } /* we maintain the offscreen mode flags in onscreen mode - else { + return fixOnscreenGLCapabilities(capsRequested); + } */ return capsRequested; } public static GLCapabilitiesImmutable fixOnscreenGLCapabilities(GLCapabilitiesImmutable capsRequested) { - if( !capsRequested.isOnscreen() ) { + if( !capsRequested.isOnscreen() || capsRequested.isFBO() || capsRequested.isPBuffer() || capsRequested.isBitmap() ) { // fix caps .. final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); caps2.setBitmap (false); @@ -157,9 +169,11 @@ public class GLGraphicsConfigurationUtil { public static GLCapabilitiesImmutable fixOffscreenGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) { final boolean auto = !capsRequested.isFBO() && !capsRequested.isPBuffer() && !capsRequested.isBitmap() ; + + final boolean requestedPBuffer = capsRequested.isPBuffer() || Platform.getOSType() == Platform.OSType.MACOS ; // no native bitmap for OSX final boolean useFBO = fboAvailable && ( auto || capsRequested.isFBO() ) ; - final boolean usePbuffer = !useFBO && pbufferAvailable && ( auto || capsRequested.isPBuffer() ) ; + final boolean usePbuffer = !useFBO && pbufferAvailable && ( auto || requestedPBuffer ) ; final boolean useBitmap = !useFBO && !usePbuffer && ( auto || capsRequested.isBitmap() ) ; if( capsRequested.isOnscreen() || diff --git a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java new file mode 100644 index 000000000..7701f209f --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java @@ -0,0 +1,123 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.opengl; + +import javax.media.nativewindow.NativeWindowException; +import javax.media.opengl.GL; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLException; +import javax.media.opengl.GLOffscreenAutoDrawable; + +import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.GLAutoDrawableDelegate; + +import jogamp.opengl.GLFBODrawableImpl; + +public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implements GLOffscreenAutoDrawable { + + /** + * @param drawable a valid and already realized {@link GLDrawable} + * @param context a valid {@link GLContext}, may not be made current (created) yet. + * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. + * @param lock optional upstream lock, may be null + */ + public GLOffscreenAutoDrawableImpl(GLDrawable drawable, GLContext context, Object upstreamWidget, RecursiveLock lock) { + super(drawable, context, upstreamWidget, true, lock); + } + + @Override + public void setSize(int newWidth, int newHeight) throws NativeWindowException, GLException { + this.defaultWindowResizedOp(newWidth, newHeight); + } + + public static class FBOImpl extends GLOffscreenAutoDrawableImpl implements GLOffscreenAutoDrawable.FBO { + /** + * @param drawable a valid and already realized {@link GLDrawable} + * @param context a valid {@link GLContext}, may not be made current (created) yet. + * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. + * @param lock optional upstream lock, may be null + */ + public FBOImpl(GLFBODrawableImpl drawable, GLContext context, Object upstreamWidget, RecursiveLock lock) { + super(drawable, context, upstreamWidget, lock); + } + + @Override + public boolean isInitialized() { + return ((GLFBODrawableImpl)drawable).isInitialized(); + } + + @Override + public final int getTextureUnit() { + return ((GLFBODrawableImpl)drawable).getTextureUnit(); + } + + @Override + public final void setTextureUnit(int unit) { + ((GLFBODrawableImpl)drawable).setTextureUnit(unit); + } + + @Override + public final int getNumSamples() { + return ((GLFBODrawableImpl)drawable).getNumSamples(); + } + + @Override + public final void setNumSamples(GL gl, int newSamples) throws GLException { + ((GLFBODrawableImpl)drawable).setNumSamples(gl, newSamples); + windowRepaintOp(); + } + + /** // TODO: Add or remove TEXTURE (only) DoubleBufferMode support + @Override + public DoubleBufferMode getDoubleBufferMode() { + return ((GLFBODrawableImpl)drawable).getDoubleBufferMode(); + } + + @Override + public void setDoubleBufferMode(DoubleBufferMode mode) throws GLException { + ((GLFBODrawableImpl)drawable).setDoubleBufferMode(mode); + } */ + + @Override + public final FBObject getFBObject(int bufferName) { + return ((GLFBODrawableImpl)drawable).getFBObject(bufferName); + } + + public final FBObject.TextureAttachment getTextureBuffer(int bufferName) { + return ((GLFBODrawableImpl)drawable).getTextureBuffer(bufferName); + } + + @Override + public void resetSize(GL gl) throws GLException { + ((GLFBODrawableImpl)drawable).resetSize(gl); + } + } +} diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index 32f4cb696..b438131bc 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -40,9 +40,6 @@ package jogamp.opengl; -import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLPbuffer; @@ -50,36 +47,18 @@ import javax.media.opengl.GLPbuffer; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; -/** Platform-independent class exposing pbuffer functionality to - applications. This class is not exposed in the public API as it - would probably add no value; however it implements the GLDrawable - interface so can be interacted with via its display() method. */ - +@SuppressWarnings("deprecation") public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { private int floatMode; - public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContext sharedContext, boolean ownDevice) { - super(pbufferDrawable, null, ownDevice); // drawable := pbufferDrawable - - GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) - drawable.getNativeSurface().getGraphicsConfiguration().getChosenCapabilities(); - if(caps.isOnscreen()) { - if(caps.isPBuffer()) { - throw new IllegalArgumentException("Error: Given drawable is Onscreen and Pbuffer: "+pbufferDrawable); - } - throw new IllegalArgumentException("Error: Given drawable is Onscreen: "+pbufferDrawable); - } else { - if(!caps.isPBuffer()) { - throw new IllegalArgumentException("Error: Given drawable is not Pbuffer: "+pbufferDrawable); - } - } - context = (GLContextImpl) drawable.createContext(sharedContext); + public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContextImpl pbufferContext) { + super(pbufferDrawable, pbufferContext, true); // drawable := pbufferDrawable, context := pbufferContext } // // pbuffer specifics - // - + // + @Override public void bindTexture() { // Doesn't make much sense to try to do this on the event dispatch diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 03d0d650f..06953a8e1 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -282,12 +282,6 @@ public abstract class EGLContext extends GLContextImpl { return EGL.eglSwapInterval(drawable.getNativeSurface().getDisplayHandle(), interval); } - @Override - public abstract void bindPbufferToTexture(); - - @Override - public abstract void releasePbufferFromTexture(); - // // Accessible .. // diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java index 0dba4bb09..167eebf3a 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java @@ -36,7 +36,8 @@ package jogamp.opengl.egl; -import javax.media.nativewindow.MutableSurface; +import java.nio.IntBuffer; + import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.ProxySurface; @@ -46,10 +47,10 @@ import javax.media.opengl.GLException; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; +import com.jogamp.common.nio.Buffers; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; public abstract class EGLDrawable extends GLDrawableImpl { - private boolean ownEGLSurface = false; // for destruction protected EGLDrawable(EGLDrawableFactory factory, NativeSurface component) throws GLException { super(factory, component, false); @@ -58,21 +59,14 @@ public abstract class EGLDrawable extends GLDrawableImpl { @Override public abstract GLContext createContext(GLContext shareWith); - protected abstract long createSurface(EGLGraphicsConfiguration config, long nativeSurfaceHandle); + protected abstract long createSurface(EGLGraphicsConfiguration config, int width, int height, long nativeSurfaceHandle); - private final void recreateSurface() { - final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) surface.getGraphicsConfiguration(); - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) eglConfig.getScreen().getDevice(); - if(DEBUG) { - System.err.println(getThreadName() + ": createSurface using "+eglConfig); - } - if( EGL.EGL_NO_SURFACE != surface.getSurfaceHandle() ) { - EGL.eglDestroySurface(eglDevice.getHandle(), surface.getSurfaceHandle()); - } + private final long createEGLSurface() { + final EGLWrappedSurface eglws = (EGLWrappedSurface) surface; + final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) eglws.getGraphicsConfiguration(); + final NativeSurface upstreamSurface = eglws.getUpstreamSurface(); - final EGLUpstreamSurfaceHook upstreamHook = (EGLUpstreamSurfaceHook) ((ProxySurface)surface).getUpstreamSurfaceHook(); - final NativeSurface upstreamSurface = upstreamHook.getUpstreamSurface(); - long eglSurface = createSurface(eglConfig, upstreamSurface.getSurfaceHandle()); + long eglSurface = createSurface(eglConfig, eglws.getWidth(), eglws.getHeight(), upstreamSurface.getSurfaceHandle()); int eglError0; if (EGL.EGL_NO_SURFACE == eglSurface) { @@ -86,7 +80,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { if(DEBUG) { System.err.println(getThreadName() + ": Info: Creation of window surface w/ surface handle failed: "+eglConfig+", error "+toHexString(eglError0)+", retry w/ windowHandle"); } - eglSurface = createSurface(eglConfig, nw.getWindowHandle()); + eglSurface = createSurface(eglConfig, eglws.getWidth(), eglws.getHeight(), nw.getWindowHandle()); if (EGL.EGL_NO_SURFACE == eglSurface) { eglError0 = EGL.eglGetError(); } @@ -99,34 +93,53 @@ public abstract class EGLDrawable extends GLDrawableImpl { if (EGL.EGL_NO_SURFACE == eglSurface) { throw new GLException("Creation of window surface failed: "+eglConfig+", "+surface+", error "+toHexString(eglError0)); } - if(DEBUG) { - System.err.println(getThreadName() + ": setSurface using component: handle "+toHexString(surface.getSurfaceHandle())+" -> "+toHexString(eglSurface)); + System.err.println(getThreadName() + ": createEGLSurface handle "+toHexString(eglSurface)); } - - ((MutableSurface)surface).setSurfaceHandle(eglSurface); + return eglSurface; } @Override protected final void updateHandle() { - if(ownEGLSurface) { - recreateSurface(); + final EGLWrappedSurface eglws = (EGLWrappedSurface) surface; + if(DEBUG) { + System.err.println(getThreadName() + ": updateHandle of "+eglws); + } + if( eglws.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + if( EGL.EGL_NO_SURFACE != eglws.getSurfaceHandle() ) { + throw new InternalError("Set surface but claimed to be invalid: "+eglws); + } + eglws.setSurfaceHandle( createEGLSurface() ); + } else if( EGL.EGL_NO_SURFACE == eglws.getSurfaceHandle() ) { + throw new InternalError("Nil surface but claimed to be valid: "+eglws); + } + } + + protected void destroyHandle() { + final EGLWrappedSurface eglws = (EGLWrappedSurface) surface; + if(DEBUG) { + System.err.println(getThreadName() + ": destroyHandle of "+eglws); + } + if( EGL.EGL_NO_SURFACE == eglws.getSurfaceHandle() ) { + throw new InternalError("Nil surface but claimed to be valid: "+eglws); + } + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) eglws.getGraphicsConfiguration().getScreen().getDevice(); + if( eglws.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + EGL.eglDestroySurface(eglDevice.getHandle(), eglws.getSurfaceHandle()); + eglws.setSurfaceHandle(EGL.EGL_NO_SURFACE); } } - protected static boolean isValidEGLSurface(EGLGraphicsDevice eglDevice, NativeSurface surface) { - final long eglDisplayHandle = eglDevice.getHandle(); - if (EGL.EGL_NO_DISPLAY == eglDisplayHandle) { - throw new GLException("Invalid EGL display in EGLGraphicsDevice "+eglDevice); + protected static boolean isValidEGLSurface(long eglDisplayHandle, long surfaceHandle) { + if( 0 == surfaceHandle ) { + return false; } - boolean eglSurfaceValid = 0 != surface.getSurfaceHandle(); - if(eglSurfaceValid) { - int[] tmp = new int[1]; - eglSurfaceValid = EGL.eglQuerySurface(eglDisplayHandle, surface.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0); - if(!eglSurfaceValid) { - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.isValidEGLSurface eglQuerySuface failed: "+toHexString(EGL.eglGetError())+", "+surface); - } + final IntBuffer val = Buffers.newDirectIntBuffer(1); + final boolean eglSurfaceValid = EGL.eglQuerySurface(eglDisplayHandle, surfaceHandle, EGL.EGL_CONFIG_ID, val); + if( !eglSurfaceValid ) { + final int eglErr = EGL.eglGetError(); + if(DEBUG) { + System.err.println(getThreadName() + ": EGLDrawable.isValidEGLSurface eglQuerySuface failed: error "+toHexString(eglErr)+", "+toHexString(surfaceHandle)); } } return eglSurfaceValid; @@ -134,55 +147,19 @@ public abstract class EGLDrawable extends GLDrawableImpl { @Override protected final void setRealizedImpl() { - final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) surface.getGraphicsConfiguration(); - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) eglConfig.getScreen().getDevice(); - if (realized) { - final boolean eglSurfaceValid = isValidEGLSurface(eglDevice, surface); - if(eglSurfaceValid) { - // surface holds valid EGLSurface - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealizedImpl re-using component's EGLSurface: handle "+toHexString(surface.getSurfaceHandle())); - } - ownEGLSurface=false; - } else { - // EGLSurface is ours - subsequent updateHandle() will issue recreateSurface(); - // However .. let's validate the surface object first - if( ! (surface instanceof ProxySurface) ) { - throw new InternalError("surface not ProxySurface: "+surface.getClass().getName()+", "+surface); - } - final ProxySurface.UpstreamSurfaceHook upstreamHook = ((ProxySurface)surface).getUpstreamSurfaceHook(); - if( null == upstreamHook ) { - throw new InternalError("null upstreamHook of: "+surface); - } - if( ! (upstreamHook instanceof EGLUpstreamSurfaceHook) ) { - throw new InternalError("upstreamHook not EGLUpstreamSurfaceHook: Surface: "+surface.getClass().getName()+", "+surface+"; UpstreamHook: "+upstreamHook.getClass().getName()+", "+upstreamHook); - } - if( null == ((EGLUpstreamSurfaceHook)upstreamHook).getUpstreamSurface() ) { - throw new InternalError("null upstream surface"); - } - ownEGLSurface=true; - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealizedImpl owning EGLSurface"); - } - } - } else if (ownEGLSurface && surface.getSurfaceHandle() != EGL.EGL_NO_SURFACE) { - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealized(false): ownSurface "+ownEGLSurface+", "+eglDevice+", eglSurface: "+toHexString(surface.getSurfaceHandle())); - } - // Destroy the window surface - if (!EGL.eglDestroySurface(eglDevice.getHandle(), surface.getSurfaceHandle())) { - throw new GLException("Error destroying window surface (eglDestroySurface)"); - } - ((MutableSurface)surface).setSurfaceHandle(EGL.EGL_NO_SURFACE); + if(DEBUG) { + System.err.println(getThreadName() + ": EGLDrawable.setRealized("+realized+"): NOP - "+surface); } } @Override - protected final void swapBuffersImpl() { - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); - // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers() - if(!EGL.eglSwapBuffers(eglDevice.getHandle(), surface.getSurfaceHandle())) { - throw new GLException("Error swapping buffers, eglError "+toHexString(EGL.eglGetError())+", "+this); + protected final void swapBuffersImpl(boolean doubleBuffered) { + if(doubleBuffered) { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); + // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers() + if(!EGL.eglSwapBuffers(eglDevice.getHandle(), surface.getSurfaceHandle())) { + throw new GLException("Error swapping buffers, eglError "+toHexString(EGL.eglGetError())+", "+this); + } } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 292eb17c8..e98d69140 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -52,8 +52,7 @@ import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; -import javax.media.nativewindow.VisualIDHolder.VIDType; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; @@ -65,6 +64,7 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import jogamp.nativewindow.WrappedSurface; import jogamp.opengl.Debug; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; @@ -76,10 +76,11 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; -import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; public class EGLDrawableFactory extends GLDrawableFactoryImpl { + protected static final boolean DEBUG = GLDrawableFactoryImpl.DEBUG; + /* package */ static final boolean QUERY_EGL_ES = !Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.DontQuery", true); /* package */ static final boolean QUERY_EGL_ES_NATIVE_TK = Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.QueryNativeTK", true); @@ -112,7 +113,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } catch (JogampRuntimeException jre) { /* n/a .. */ } } - defaultDevice = new EGLGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + defaultDevice = new EGLGraphicsDevice(); // FIXME: Probably need to move EGL from a static model // to a dynamic one, where there can be 2 instances @@ -310,6 +311,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { try { final GLCapabilities reqCapsAny = new GLCapabilities(glp); reqCapsAny.setRedBits(5); reqCapsAny.setGreenBits(5); reqCapsAny.setBlueBits(5); reqCapsAny.setAlphaBits(0); + reqCapsAny.setDoubleBuffered(false); final GLCapabilitiesImmutable reqCapsPBuffer = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(reqCapsAny); final List availablePBufferCapsL = getAvailableEGLConfigs(sharedEGLDevice, reqCapsPBuffer); hasPBuffer[0] = availablePBufferCapsL.size() > 0; @@ -324,18 +326,20 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } else { final List capsAnyL = getAvailableEGLConfigs(eglDevice, reqCapsAny); if(capsAnyL.size() > 0) { - final GLCapabilitiesImmutable caps = capsAnyL.get(0); - EGLContext.mapStaticGLESVersion(eglDevice, caps); + final GLCapabilitiesImmutable chosenCaps = capsAnyL.get(0); + EGLContext.mapStaticGLESVersion(eglDevice, chosenCaps); if(eglDevice != adevice) { - EGLContext.mapStaticGLESVersion(adevice, caps); + EGLContext.mapStaticGLESVersion(adevice, chosenCaps); } + final EGLGraphicsDevice adeviceEGLDevice = new EGLGraphicsDevice(adevice.getHandle(), EGL.EGL_NO_DISPLAY, adevice.getConnection(), adevice.getUnitID(), null); + EGLContext.mapStaticGLESVersion(adeviceEGLDevice, chosenCaps); success = true; } if(DEBUG) { System.err.println("EGLDrawableFactory.isEGLContextAvailable() no pbuffer config available, detected !pbuffer config: "+success); EGLGraphicsConfigurationFactory.printCaps("!PBufferCaps", capsAnyL, System.err); } - } + } } else { surface = desktopFactory.createDummySurface(adevice, reqCapsAny, null, 64, 64); // X11, WGL, .. dummy window upstreamSurface = ( surface instanceof ProxySurface ) ? (ProxySurface)surface : null ; @@ -361,6 +365,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if(eglDevice != adevice) { context.mapCurrentAvailableGLVersion(adevice); } + final EGLGraphicsDevice adeviceEGLDevice = new EGLGraphicsDevice(adevice.getHandle(), EGL.EGL_NO_DISPLAY, adevice.getConnection(), adevice.getUnitID(), null); + context.mapCurrentAvailableGLVersion(adeviceEGLDevice); success = true; } else { // Oops .. something is wrong @@ -538,70 +544,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if (target == null) { throw new IllegalArgumentException("Null target"); } - return new EGLOnscreenDrawable(this, getEGLSurface(target)); + return new EGLOnscreenDrawable(this, EGLWrappedSurface.get(target)); } - protected static NativeSurface getEGLSurface(NativeSurface surface) { - AbstractGraphicsConfiguration aConfig = surface.getGraphicsConfiguration(); - AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice(); - if( aDevice instanceof EGLGraphicsDevice && aConfig instanceof EGLGraphicsConfiguration ) { - if(surface instanceof WrappedSurface) { - // already wrapped surface - no wrapped recursion - if(DEBUG) { - System.err.println(getThreadName() + ": getEGLSurface - already wrapped surface - use as-is: "+surface); - } - return surface; - } - if(EGLDrawable.isValidEGLSurface((EGLGraphicsDevice)aDevice, surface)) { - // already in native EGL format - if(DEBUG) { - System.err.println(getThreadName() + ": getEGLSurface - already valid EGL surface - use as-is: "+surface); - } - return surface; - } - } - // create EGL instance out of platform native types - final EGLGraphicsDevice eglDevice; - if( aDevice instanceof EGLGraphicsDevice ) { - eglDevice = (EGLGraphicsDevice) aDevice; - if(DEBUG) { - System.err.println(getThreadName() + ": getEGLSurface - Reusing eglDevice: "+eglDevice); - } - if(0 == eglDevice.getHandle()) { - eglDevice.open(); - } - } else { - eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface); - } - final AbstractGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aConfig.getScreen().getIndex()); - final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities(); - final EGLGraphicsConfiguration eglConfig; - if( aConfig instanceof EGLGraphicsConfiguration ) { - // Config is already in EGL type - reuse .. - final EGLGLCapabilities capsChosen = (EGLGLCapabilities) aConfig.getChosenCapabilities(); - if( 0 == capsChosen.getEGLConfig() ) { - // 'refresh' the native EGLConfig handle - capsChosen.setEGLConfig(EGLGraphicsConfiguration.EGLConfigId2EGLConfig(eglDevice.getHandle(), capsChosen.getEGLConfigID())); - if( 0 == capsChosen.getEGLConfig() ) { - throw new GLException("Refreshing native EGLConfig handle failed with error "+EGLContext.toHexString(EGL.eglGetError())+": "+eglDevice+", "+capsChosen+" of "+aConfig); - } - } - eglConfig = new EGLGraphicsConfiguration(eglScreen, capsChosen, capsRequested, null); - if(DEBUG) { - System.err.println(getThreadName() + ": getEGLSurface - Reusing chosenCaps: "+eglConfig); - } - } else { - eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( - capsRequested, capsRequested, null, eglScreen, aConfig.getVisualID(VIDType.NATIVE), false); - - if (null == eglConfig) { - throw new GLException("Couldn't create EGLGraphicsConfiguration from "+eglScreen); - } else if(DEBUG) { - System.err.println(getThreadName() + ": getEGLSurface - Chosen eglConfig: "+eglConfig); - } - } - return new WrappedSurface(eglConfig, EGL.EGL_NO_SURFACE, surface.getWidth(), surface.getHeight(), new EGLUpstreamSurfaceHook(surface)); - } static String getThreadName() { return Thread.currentThread().getName(); } @Override @@ -615,7 +560,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { throw new GLException("Non pbuffer not yet implemented"); } // PBuffer GLDrawable Creation - return new EGLPbufferDrawable(this, getEGLSurface(target)); + return new EGLPbufferDrawable(this, EGLWrappedSurface.get(target)); } @Override @@ -628,20 +573,24 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { + final boolean ownDevice; final EGLGraphicsDevice device; - if(createNewDevice) { - final EGLGraphicsDevice eglDeviceReq = (EGLGraphicsDevice) deviceReq; - device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID()); + if(createNewDevice || ! ( deviceReq instanceof EGLGraphicsDevice ) ) { + final long nativeDisplayID = ( deviceReq instanceof EGLGraphicsDevice) ? + ( (EGLGraphicsDevice) deviceReq ).getNativeDisplayID() : deviceReq.getHandle() ; + device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(nativeDisplayID, deviceReq.getConnection(), deviceReq.getUnitID()); + ownDevice = true; } else { device = (EGLGraphicsDevice) deviceReq; + ownDevice = false; } final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); final EGLGraphicsConfiguration config = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return new WrappedSurface(config, 0, width, height, lifecycleHook); + return new WrappedSurface(config, 0, upstreamHook, ownDevice); } @Override @@ -649,54 +598,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixDoubleBufferedGLCapabilities( - GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(requestedCaps, false, canCreateGLPbuffer(deviceReq)), - false); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); + GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(requestedCaps, false, canCreateGLPbuffer(deviceReq)), false); + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new EGLDummyUpstreamSurfaceHook(width, height)); } - private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { - @Override - public final void create(ProxySurface s) { - if( EGL.EGL_NO_SURFACE == s.getSurfaceHandle() ) { - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) s.getGraphicsConfiguration().getScreen().getDevice(); - if(0 == eglDevice.getHandle()) { - eglDevice.open(); - s.setImplBitfield(ProxySurface.OWN_DEVICE); - } - createPBufferSurfaceImpl(s, false); - if(DEBUG) { - System.err.println("EGLDrawableFactory.dummySurfaceLifecycleHook.create: "+s); - } - } - } - @Override - public final void destroy(ProxySurface s) { - if( EGL.EGL_NO_SURFACE != s.getSurfaceHandle() ) { - final EGLGraphicsConfiguration config = (EGLGraphicsConfiguration) s.getGraphicsConfiguration(); - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) config.getScreen().getDevice(); - EGL.eglDestroySurface(eglDevice.getHandle(), s.getSurfaceHandle()); - s.setSurfaceHandle(EGL.EGL_NO_SURFACE); - if( 0 != ( ProxySurface.OWN_DEVICE & s.getImplBitfield() ) ) { - eglDevice.close(); - } - if(DEBUG) { - System.err.println("EGLDrawableFactory.dummySurfaceLifecycleHook.create: "+s); - } - } - } - @Override - public final int getWidth(ProxySurface s) { - return s.initialWidth; - } - @Override - public final int getHeight(ProxySurface s) { - return s.initialHeight; - } - @Override - public String toString() { - return "EGLSurfaceLifecycleHook[]"; - } - - }; /** * @param ms {@link MutableSurface} which dimensions and config are being used to create the pbuffer surface. @@ -705,7 +609,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { * @return the passed {@link MutableSurface} which now has the EGL pbuffer surface set as it's handle */ protected static MutableSurface createPBufferSurfaceImpl(MutableSurface ms, boolean useTexture) { - final EGLGraphicsConfiguration config = (EGLGraphicsConfiguration) ms.getGraphicsConfiguration(); + return null; + } + protected static long createPBufferSurfaceImpl(EGLGraphicsConfiguration config, int width, int height, boolean useTexture) { final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) config.getScreen().getDevice(); final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); final int texFormat; @@ -720,15 +626,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { System.out.println("Pbuffer config: " + config); } - final int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(ms.getWidth(), ms.getHeight(), texFormat); + final int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(width, height, texFormat); final long surf = EGL.eglCreatePbufferSurface(eglDevice.getHandle(), config.getNativeConfig(), attrs, 0); if (EGL.EGL_NO_SURFACE==surf) { - throw new GLException("Creation of window surface (eglCreatePbufferSurface) failed, dim "+ms.getWidth()+"x"+ms.getHeight()+", error 0x"+Integer.toHexString(EGL.eglGetError())); + throw new GLException("Creation of window surface (eglCreatePbufferSurface) failed, dim "+width+"x"+height+", "+eglDevice+", "+config+", error 0x"+Integer.toHexString(EGL.eglGetError())); } else if(DEBUG) { System.err.println("PBuffer setSurface result: eglSurface 0x"+Long.toHexString(surf)); } - ms.setSurfaceHandle(surf); - return ms; + return surf; } @Override @@ -737,7 +642,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { final EGLGraphicsDevice device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID()); final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); final EGLGraphicsConfiguration cfg = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); - return new WrappedSurface(cfg, windowHandle, 0, 0, upstream); + return new WrappedSurface(cfg, windowHandle, upstream, true); } @Override diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java new file mode 100644 index 000000000..b172d4f35 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java @@ -0,0 +1,49 @@ +package jogamp.opengl.egl; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; + +public class EGLDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { + /** + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. + * The latter is platform specific and small + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * not the actual dummy surface height, + * The latter is platform specific and small + */ + public EGLDummyUpstreamSurfaceHook(int width, int height) { + super(width, height); + } + + @Override + public final void create(ProxySurface s) { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) s.getGraphicsConfiguration().getScreen().getDevice(); + if(0 == eglDevice.getHandle()) { + eglDevice.open(); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + if( EGL.EGL_NO_SURFACE == s.getSurfaceHandle() ) { + s.setSurfaceHandle( EGLDrawableFactory.createPBufferSurfaceImpl((EGLGraphicsConfiguration)s.getGraphicsConfiguration(), 64, 64, false) ); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); + } + + @Override + public final void destroy(ProxySurface s) { + if( s.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) s.getGraphicsConfiguration().getScreen().getDevice(); + if( EGL.EGL_NO_SURFACE == s.getSurfaceHandle() ) { + throw new InternalError("Owns upstream surface, but no EGL surface: "+s); + } + EGL.eglDestroySurface(eglDevice.getHandle(), s.getSurfaceHandle()); + s.setSurfaceHandle(EGL.EGL_NO_SURFACE); + s.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + } +} diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java index 585638d21..84bd705db 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java @@ -79,15 +79,4 @@ public class EGLExternalContext extends EGLContext { @Override protected void destroyImpl() throws GLException { } - - @Override - public void bindPbufferToTexture() { - throw new GLException("Should not call this"); - } - - @Override - public void releasePbufferFromTexture() { - throw new GLException("Should not call this"); - } - } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java index e513a86cf..f857c6b5c 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java @@ -57,8 +57,8 @@ public class EGLGLCapabilities extends GLCapabilities { this.eglcfg = eglcfg; this.eglcfgid = eglcfgid; if(!isCompatible(glp, renderableType)) { - throw new GLException("Incompatible "+glp+ - " with EGL-RenderableType["+renderableTypeToString(null, renderableType)+"]"); + throw new GLException("Requested GLProfile "+glp+ + " not compatible with EGL-RenderableType["+renderableTypeToString(null, renderableType)+"]"); } this.renderableType = renderableType; this.nativeVisualID = visualID; @@ -131,6 +131,7 @@ public class EGLGLCapabilities extends GLCapabilities { sink = new StringBuilder(); } boolean first=true; + sink.append("0x").append(Integer.toHexString(renderableType)).append(": "); if(0 != (renderableType & EGL.EGL_OPENGL_BIT)) { sink.append("GL"); first=false; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index 8ee98072f..7bf201238 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -211,6 +211,13 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple if(null == glp) { glp = EGLGLCapabilities.getCompatible(device, rType); } + if(!EGLGLCapabilities.isCompatible(glp, rType)) { + if(DEBUG) { + System.err.println("config "+toHexString(config)+": Requested GLProfile "+glp+ + " not compatible with EGL-RenderableType["+EGLGLCapabilities.renderableTypeToString(null, rType)+"]"); + } + return null; + } caps = new EGLGLCapabilities(config, cfgID, visualID, glp, rType); } catch (GLException gle) { if(DEBUG) { @@ -288,7 +295,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple return null; } - return (EGLGLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(caps, drawableTypeBits); + return (EGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, caps); } public static int[] GLCapabilities2AttribList(GLCapabilitiesImmutable caps) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenContext.java index eae47fa92..325ad6142 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenContext.java @@ -41,16 +41,5 @@ public class EGLOnscreenContext extends EGLContext { public EGLOnscreenContext(EGLOnscreenDrawable drawable, GLContext shareWith) { super(drawable, shareWith); } - - @Override - public void bindPbufferToTexture() { - throw new GLException("Should not call this"); - } - - @Override - public void releasePbufferFromTexture() { - throw new GLException("Should not call this"); - } - } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java index d54057775..6440cf1e5 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java @@ -54,8 +54,8 @@ public class EGLOnscreenDrawable extends EGLDrawable { } @Override - protected long createSurface(EGLGraphicsConfiguration config, long nativeSurfaceHandle) { + protected long createSurface(EGLGraphicsConfiguration config, int width, int height, long nativeSurfaceHandle) { return EGL.eglCreateWindowSurface(config.getScreen().getDevice().getHandle(), config.getNativeConfig(), nativeSurfaceHandle, null); - } + } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferContext.java index 7175d516f..bb9eeb892 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferContext.java @@ -46,15 +46,5 @@ public class EGLPbufferContext extends EGLContext { public int getFloatingPointMode() { return 0; // FIXME ?? } - - @Override - public void bindPbufferToTexture() { - throw new GLException("Not yet implemented"); - } - - @Override - public void releasePbufferFromTexture() { - throw new GLException("Not yet implemented"); - } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java index 4a36625bd..eb7e320c8 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java @@ -52,12 +52,8 @@ public class EGLPbufferDrawable extends EGLDrawable { } @Override - protected long createSurface(EGLGraphicsConfiguration config, long nativeSurfaceHandle) { - final MutableSurface ms = (MutableSurface)getNativeSurface(); - if(config != ms.getGraphicsConfiguration()) { - throw new InternalError("Not same: "+config.hashCode()+", "+ms.getGraphicsConfiguration()+": "+config+", "+ms.getGraphicsConfiguration()); - } - return EGLDrawableFactory.createPBufferSurfaceImpl(ms, useTexture).getSurfaceHandle(); + protected long createSurface(EGLGraphicsConfiguration config, int width, int height, long nativeSurfaceHandle) { + return EGLDrawableFactory.createPBufferSurfaceImpl(config, width, height, false); } @Override diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java index 42c6e100e..342c4c417 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java @@ -1,38 +1,163 @@ package jogamp.opengl.egl; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; +import javax.media.nativewindow.VisualIDHolder.VIDType; +import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLException; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; -public class EGLUpstreamSurfaceHook implements ProxySurface.UpstreamSurfaceHook { +public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { + protected static final boolean DEBUG = EGLDrawableFactory.DEBUG; private final NativeSurface upstreamSurface; + private final UpstreamSurfaceHook.MutableSize upstreamSurfaceHookMutableSize; public EGLUpstreamSurfaceHook(NativeSurface upstream) { upstreamSurface = upstream; + if(upstreamSurface instanceof ProxySurface) { + final UpstreamSurfaceHook ush = ((ProxySurface)upstreamSurface).getUpstreamSurfaceHook(); + if(ush instanceof UpstreamSurfaceHook.MutableSize) { + // offscreen NativeSurface w/ MutableSize (default) + upstreamSurfaceHookMutableSize = (UpstreamSurfaceHook.MutableSize) ush; + } else { + upstreamSurfaceHookMutableSize = null; + } + } else { + upstreamSurfaceHookMutableSize = null; + } } public final NativeSurface getUpstreamSurface() { return upstreamSurface; } + static String getThreadName() { return Thread.currentThread().getName(); } + + public final void setSize(int width, int height) { + if(null != upstreamSurfaceHookMutableSize) { + upstreamSurfaceHookMutableSize.setSize(width, height); + } + } + @Override public final void create(ProxySurface surface) { + final String dbgPrefix; + if(DEBUG) { + dbgPrefix = getThreadName() + ": EGLUpstreamSurfaceHook.create("+surface.getClass().getSimpleName()+"): "; + System.err.println(dbgPrefix+this); + } else { + dbgPrefix = null; + } + if(upstreamSurface instanceof ProxySurface) { + // propagate createNotify(..) so upstreamSurface will be created ((ProxySurface)upstreamSurface).createNotify(); - if(NativeSurface.LOCK_SURFACE_NOT_READY >= upstreamSurface.lockSurface()) { - throw new GLException("Could not lock: "+upstreamSurface); + } + + // lock upstreamSurface, so it can be used in case EGLDisplay is derived from it! + if(NativeSurface.LOCK_SURFACE_NOT_READY >= upstreamSurface.lockSurface()) { + throw new GLException("Could not lock: "+upstreamSurface); + } + try { + evalUpstreamSurface(dbgPrefix, surface); + } finally { + upstreamSurface.unlockSurface(); + } + } + + private final void evalUpstreamSurface(String dbgPrefix, ProxySurface surface) { + // + // evaluate nature of upstreamSurface, may create EGL instances if required + // + + boolean isEGLSurfaceValid = true; // assume yes + + final AbstractGraphicsConfiguration aConfig = upstreamSurface.getGraphicsConfiguration(); + final AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice(); + + final EGLGraphicsDevice eglDevice; + if( aDevice instanceof EGLGraphicsDevice ) { + eglDevice = (EGLGraphicsDevice) aDevice; + if(DEBUG) { + System.err.println(dbgPrefix+"Reusing eglDevice: "+eglDevice); + } + if(EGL.EGL_NO_DISPLAY == eglDevice.getHandle()) { + eglDevice.open(); + isEGLSurfaceValid = false; + surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + } else { + eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(upstreamSurface); + isEGLSurfaceValid = false; + surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + + final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities(); + final EGLGraphicsConfiguration eglConfig; + if( aConfig instanceof EGLGraphicsConfiguration ) { + // Config is already in EGL type - reuse .. + final EGLGLCapabilities capsChosen = (EGLGLCapabilities) aConfig.getChosenCapabilities(); + if( !isEGLSurfaceValid || !EGLGraphicsConfiguration.isEGLConfigValid(eglDevice.getHandle(), capsChosen.getEGLConfig()) ) { + // 'refresh' the native EGLConfig handle + capsChosen.setEGLConfig(EGLGraphicsConfiguration.EGLConfigId2EGLConfig(eglDevice.getHandle(), capsChosen.getEGLConfigID())); + if( 0 == capsChosen.getEGLConfig() ) { + throw new GLException("Refreshing native EGLConfig handle failed with error "+EGLContext.toHexString(EGL.eglGetError())+": "+eglDevice+", "+capsChosen+" of "+aConfig); + } + final AbstractGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aConfig.getScreen().getIndex()); + eglConfig = new EGLGraphicsConfiguration(eglScreen, capsChosen, capsRequested, null); + if(DEBUG) { + System.err.println(dbgPrefix+"Refreshing eglConfig: "+eglConfig); + } + isEGLSurfaceValid = false; + } else { + eglConfig = (EGLGraphicsConfiguration) aConfig; + if(DEBUG) { + System.err.println(dbgPrefix+"Reusing eglConfig: "+eglConfig); + } + } + } else { + final AbstractGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aConfig.getScreen().getIndex()); + eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( + capsRequested, capsRequested, null, eglScreen, aConfig.getVisualID(VIDType.NATIVE), false); + + if (null == eglConfig) { + throw new GLException("Couldn't create EGLGraphicsConfiguration from "+eglScreen); + } else if(DEBUG) { + System.err.println(dbgPrefix+"Chosen eglConfig: "+eglConfig); } + isEGLSurfaceValid = false; } - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); - eglDevice.open(); + surface.setGraphicsConfiguration(eglConfig); + + if(isEGLSurfaceValid) { + isEGLSurfaceValid = EGLDrawable.isValidEGLSurface(eglDevice.getHandle(), upstreamSurface.getSurfaceHandle()); + } + if(isEGLSurfaceValid) { + surface.setSurfaceHandle(upstreamSurface.getSurfaceHandle()); + surface.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + if(DEBUG) { + System.err.println(dbgPrefix+"Fin: Already valid EGL surface - use as-is: "+upstreamSurface); + } + } else { + surface.setSurfaceHandle(EGL.EGL_NO_SURFACE); + surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); // create/destroy in EGLDrawable + if(DEBUG) { + System.err.println(dbgPrefix+"Fin: EGL surface n/a - TBD: "+upstreamSurface); + } + } } @Override public final void destroy(ProxySurface surface) { - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); - eglDevice.close(); + if(EGLDrawableFactory.DEBUG) { + System.err.println("EGLUpstreamSurfaceHook.destroy("+surface.getClass().getSimpleName()+"): "+this); + } + surface.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); if(upstreamSurface instanceof ProxySurface) { - upstreamSurface.unlockSurface(); ((ProxySurface)upstreamSurface).destroyNotify(); } } @@ -49,8 +174,8 @@ public class EGLUpstreamSurfaceHook implements ProxySurface.UpstreamSurfaceHook @Override public String toString() { - final String us_s = null != upstreamSurface ? ( upstreamSurface.getClass().getName() + ": " + upstreamSurface ) : "nil"; - return "EGLUpstreamSurfaceHook[upstream: "+us_s+"]"; + final String us_s = null != upstreamSurface ? ( upstreamSurface.getClass().getName() + ": 0x" + Long.toHexString(upstreamSurface.getSurfaceHandle()) ) : "nil"; + return "EGLUpstreamSurfaceHook[ "+ upstreamSurface.getWidth() + "x" + upstreamSurface.getHeight() + ", " + us_s+ "]"; } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java b/src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java new file mode 100644 index 000000000..b36303392 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java @@ -0,0 +1,26 @@ +package jogamp.opengl.egl; + +import javax.media.nativewindow.NativeSurface; + +import jogamp.nativewindow.WrappedSurface; + +public class EGLWrappedSurface extends WrappedSurface { + + public static EGLWrappedSurface get(NativeSurface surface) { + if(surface instanceof EGLWrappedSurface) { + return (EGLWrappedSurface)surface; + } + return new EGLWrappedSurface(surface); + } + + public EGLWrappedSurface(NativeSurface surface) { + super(surface.getGraphicsConfiguration(), EGL.EGL_NO_SURFACE, new EGLUpstreamSurfaceHook(surface), false /* tbd in UpstreamSurfaceHook */); + if(EGLDrawableFactory.DEBUG) { + System.err.println("EGLWrappedSurface.ctor(): "+this); + } + } + + public final NativeSurface getUpstreamSurface() { + return ((EGLUpstreamSurfaceHook)super.getUpstreamSurfaceHook()).getUpstreamSurface(); + } +} diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 55aea3a98..ec29558d1 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -49,6 +49,7 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.ProxySurface; +import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -58,6 +59,7 @@ import javax.media.opengl.GLProfile; import jogamp.nativewindow.macosx.OSXUtil; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableImpl; +import jogamp.opengl.GLFBODrawableImpl; import jogamp.opengl.GLGraphicsConfigurationUtil; import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.GLBackendType; @@ -76,9 +78,11 @@ public abstract class MacOSXCGLContext extends GLContextImpl boolean isNSContext(); long create(long share, int ctp, int major, int minor); boolean destroy(long ctx); + boolean contextRealized(boolean realized); boolean copyImpl(long src, int mask); boolean makeCurrent(long ctx); boolean release(long ctx); + boolean detachPBuffer(); boolean setSwapInterval(int interval); boolean swapBuffers(); } @@ -279,7 +283,24 @@ public abstract class MacOSXCGLContext extends GLContextImpl throw new GLException("Error destroying OpenGL Context: "+this); } } + + @Override + protected void contextRealized(boolean realized) { + // context stuff depends on drawable stuff + if(realized) { + super.contextRealized(true); // 1) init drawable stuff + impl.contextRealized(true); // 2) init context stuff + } else { + impl.contextRealized(false); // 1) free context stuff + super.contextRealized(false); // 2) free drawable stuff + } + } + + /* pp */ void detachPBuffer() { + impl.detachPBuffer(); + } + @Override protected void copyImpl(GLContext source, int mask) throws GLException { if( isNSContext() != ((MacOSXCGLContext)source).isNSContext() ) { @@ -365,16 +386,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl throw new GLException("Should not call this"); } - @Override - public void bindPbufferToTexture() { - throw new GLException("Should not call this"); - } - - @Override - public void releasePbufferFromTexture() { - throw new GLException("Should not call this"); - } - // Support for "mode switching" as described in MacOSXCGLDrawable public void setOpenGLMode(GLBackendType mode) { if (mode == openGLMode) { @@ -421,323 +432,486 @@ public abstract class MacOSXCGLContext extends GLContextImpl // NSOpenGLContext-based implementation class NSOpenGLImpl implements GLBackendImpl { - long nsOpenGLLayer = 0; - long nsOpenGLLayerPFmt = 0; - float screenVSyncTimeout; // microSec - int vsyncTimeout; // microSec - for nsOpenGLLayer mode - - @Override - public boolean isNSContext() { return true; } - - @Override - public long create(long share, int ctp, int major, int minor) { - long ctx = 0; - final long nsViewHandle; - if(drawable instanceof MacOSXCGLDrawable) { - // we allow null here! (special pbuffer case) - nsViewHandle = ((MacOSXCGLDrawable)MacOSXCGLContext.this.drawable).getNSViewHandle(); - } else { - // we only allow a valid NSView here - final long aHandle = drawable.getHandle(); - if( OSXUtil.isNSView(aHandle) ) { - nsViewHandle = aHandle; - } else { - throw new RuntimeException("Anonymous drawable instance's handle not of type NSView: "+drawable.getClass().getName()+", "+drawable); - } - } - final NativeSurface surface = drawable.getNativeSurface(); - final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration(); - final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); - - boolean allowIncompleteView = null != backingLayerHost; - if( !allowIncompleteView && surface instanceof ProxySurface ) { - allowIncompleteView = 0 != ( ProxySurface.INVISIBLE_WINDOW & ((ProxySurface)surface).getImplBitfield() ) ; - } - final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor); - if (pixelFormat == 0) { - if(DEBUG) { - System.err.println("Unable to allocate pixel format with requested GLCapabilities: "+chosenCaps); - } - return 0; - } - config.setChosenPixelFormat(pixelFormat); - int sRefreshRate = CGL.getScreenRefreshRate(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getIndex()); - screenVSyncTimeout = 1000000f / sRefreshRate; - if(DEBUG) { - System.err.println("NS create OSX>=lion "+isLionOrLater); - System.err.println("NS create allowIncompleteView: "+allowIncompleteView); - System.err.println("NS create backingLayerHost: "+backingLayerHost); - System.err.println("NS create share: "+share); - System.err.println("NS create chosenCaps: "+chosenCaps); - System.err.println("NS create pixelFormat: "+toHexString(pixelFormat)); - System.err.println("NS create drawable native-handle: "+toHexString(drawable.getHandle())); - System.err.println("NS create drawable NSView-handle: "+toHexString(nsViewHandle)); - System.err.println("NS create screen refresh-rate: "+sRefreshRate+" hz, "+screenVSyncTimeout+" micros"); - // Thread.dumpStack(); - } - try { - int[] viewNotReady = new int[1]; - // Try to allocate a context with this - ctx = CGL.createContext(share, - nsViewHandle, allowIncompleteView, - pixelFormat, - chosenCaps.isBackgroundOpaque(), - viewNotReady, 0); - if (0 == ctx) { - if(DEBUG) { - System.err.println("NS create failed: viewNotReady: "+ (1 == viewNotReady[0])); - } - return 0; - } + private OffscreenLayerSurface backingLayerHost = null; + private long nsOpenGLLayer = 0; + private long nsOpenGLLayerPFmt = 0; + private float screenVSyncTimeout; // microSec + private int vsyncTimeout; // microSec - for nsOpenGLLayer mode + private int lastWidth=0, lastHeight=0; // allowing to detect size change + private long lastPBufferHandle = 0; // allowing to detect pbuffer recreation + + @Override + public boolean isNSContext() { return true; } + + @Override + public long create(long share, int ctp, int major, int minor) { + long ctx = 0; + final NativeSurface surface = drawable.getNativeSurface(); + final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration(); + final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final long nsViewHandle; + final boolean isPBuffer; + final boolean isFBO; + if(drawable instanceof GLFBODrawableImpl) { + nsViewHandle = 0; + isPBuffer = false; + isFBO = true; + if(DEBUG) { + System.err.println("NS create GLFBODrawableImpl drawable: isFBO "+isFBO+", isPBuffer "+isPBuffer+", "+drawable.getClass().getName()+",\n\t"+drawable); + } + } else if(drawable instanceof MacOSXCGLDrawable) { + // we allow null here! (special pbuffer case) + nsViewHandle = ((MacOSXCGLDrawable)MacOSXCGLContext.this.drawable).getNSViewHandle(); + isPBuffer = CGL.isNSOpenGLPixelBuffer(drawable.getHandle()); + isFBO = false; + if(DEBUG) { + System.err.println("NS create MacOSXCGLDrawable drawable handle isFBO "+isFBO+", isPBuffer "+isPBuffer+", "+drawable.getClass().getName()+",\n\t"+drawable); + } + } else { + // we only allow a valid NSView here + final long drawableHandle = drawable.getHandle(); + final boolean isNSView = OSXUtil.isNSView(drawableHandle); + final boolean isNSWindow = OSXUtil.isNSWindow(drawableHandle); + isPBuffer = CGL.isNSOpenGLPixelBuffer(drawableHandle); + isFBO = false; - if (!chosenCaps.isPBuffer() && !chosenCaps.isBackgroundOpaque()) { - // Set the context opacity - CGL.setContextOpacity(ctx, 0); + if(DEBUG) { + System.err.println("NS create Anonymous drawable handle "+toHexString(drawableHandle)+": isNSView "+isNSView+", isNSWindow "+isNSWindow+", isFBO "+isFBO+", isPBuffer "+isPBuffer+", "+drawable.getClass().getName()+",\n\t"+drawable); + } + if( isNSView ) { + nsViewHandle = drawableHandle; + } else if( isNSWindow ) { + nsViewHandle = OSXUtil.GetNSView(drawableHandle); + } else if( isPBuffer ) { + nsViewHandle = 0; + } else { + throw new RuntimeException("Anonymous drawable instance's handle neither NSView, NSWindow nor PBuffer: "+toHexString(drawableHandle)+", "+drawable.getClass().getName()+",\n\t"+drawable); + } } + backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); + boolean allowIncompleteView = null != backingLayerHost; + if( !allowIncompleteView && surface instanceof ProxySurface ) { + allowIncompleteView = ((ProxySurface)surface).containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE ); + } + long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor); + if (pixelFormat == 0) { + if(DEBUG) { + System.err.println("Unable to allocate pixel format with requested GLCapabilities: "+chosenCaps); + } + return 0; + } GLCapabilities fixedCaps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(chosenCaps.getGLProfile(), pixelFormat); - fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(fixedCaps, chosenCaps.isBackgroundOpaque()); - if(!fixedCaps.isPBuffer()) { + if(chosenCaps.isOnscreen() || !fixedCaps.isPBuffer()) { // not handled, so copy them fixedCaps.setFBO(chosenCaps.isFBO()); + fixedCaps.setPBuffer(chosenCaps.isPBuffer()); fixedCaps.setBitmap(chosenCaps.isBitmap()); fixedCaps.setOnscreen(chosenCaps.isOnscreen()); } - config.setChosenCapabilities(fixedCaps); + fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(fixedCaps, chosenCaps.isBackgroundOpaque()); + int sRefreshRate = OSXUtil.GetScreenRefreshRate(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getIndex()); + screenVSyncTimeout = 1000000f / sRefreshRate; if(DEBUG) { + System.err.println("NS create OSX>=lion "+isLionOrLater); + System.err.println("NS create allowIncompleteView: "+allowIncompleteView); + System.err.println("NS create backingLayerHost: "+backingLayerHost); + System.err.println("NS create share: "+share); + System.err.println("NS create drawable type: "+drawable.getClass().getName()); + System.err.println("NS create drawable handle: isPBuffer "+isPBuffer+", isFBO "+isFBO); + System.err.println("NS create pixelFormat: "+toHexString(pixelFormat)); + System.err.println("NS create chosenCaps: "+chosenCaps); System.err.println("NS create fixedCaps: "+fixedCaps); + System.err.println("NS create drawable native-handle: "+toHexString(drawable.getHandle())); + System.err.println("NS create drawable NSView-handle: "+toHexString(nsViewHandle)); + System.err.println("NS create screen refresh-rate: "+sRefreshRate+" hz, "+screenVSyncTimeout+" micros"); + // Thread.dumpStack(); } if(fixedCaps.isPBuffer()) { - // Must now associate the pbuffer with our newly-created context - CGL.setContextPBuffer(ctx, drawable.getHandle()); + if(!isPBuffer) { + throw new InternalError("fixedCaps is PBuffer, handle not: "+drawable); + } + } else { + if(isPBuffer) { + throw new InternalError("handle is PBuffer, fixedCaps not: "+drawable); + } } - // - // handled layered surface - // + config.setChosenCapabilities(fixedCaps); + /** if(null != backingLayerHost) { - nsOpenGLLayerPFmt = pixelFormat; - pixelFormat = 0; - final int texWidth, texHeight; - if(drawable instanceof MacOSXPbufferCGLDrawable) { - final MacOSXPbufferCGLDrawable osxPDrawable = (MacOSXPbufferCGLDrawable)drawable; - texWidth = osxPDrawable.getTextureWidth(); - texHeight = osxPDrawable.getTextureHeight(); - } else { - texWidth = drawable.getWidth(); - texHeight = drawable.getHeight(); + backingLayerHost.setChosenCapabilities(fixedCaps); + } */ + + try { + int[] viewNotReady = new int[1]; + // Try to allocate a context with this + ctx = CGL.createContext(share, + nsViewHandle, allowIncompleteView, + pixelFormat, + chosenCaps.isBackgroundOpaque(), + viewNotReady, 0); + if (0 == ctx) { + if(DEBUG) { + System.err.println("NS create failed: viewNotReady: "+ (1 == viewNotReady[0])); + } + return 0; } - if(0>=texWidth || 0>=texHeight || !drawable.isRealized()) { - throw new GLException("Drawable not realized yet or invalid texture size, texSize "+texWidth+"x"+texHeight+", "+drawable); + + if(null != backingLayerHost) { + nsOpenGLLayerPFmt = pixelFormat; + pixelFormat = 0; } - nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, drawable.getHandle(), fixedCaps.isBackgroundOpaque(), texWidth, texHeight); - if (DEBUG) { - System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer)+", texSize "+texWidth+"x"+texHeight+", "+drawable); + + if (chosenCaps.isOnscreen() && !chosenCaps.isBackgroundOpaque()) { + // Set the context opacity + CGL.setContextOpacity(ctx, 0); + } + } finally { + if(0!=pixelFormat) { + CGL.deletePixelFormat(pixelFormat); + pixelFormat = 0; } - backingLayerHost.attachSurfaceLayer(nsOpenGLLayer); - setSwapInterval(1); // enabled per default in layered surface - } - } finally { - if(0!=pixelFormat) { - CGL.deletePixelFormat(pixelFormat); - } - } - return ctx; - } - - @Override - public boolean destroy(long ctx) { - if(0 != nsOpenGLLayer) { - final NativeSurface surface = drawable.getNativeSurface(); - if (DEBUG) { - System.err.println("NS destroy nsOpenGLLayer "+toHexString(nsOpenGLLayer)); - } - final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(surface, true); - if(null != ols && ols.isSurfaceLayerAttached()) { - // still having a valid OLS attached to surface (parent OLS could have been removed) - ols.detachSurfaceLayer(); } - CGL.releaseNSOpenGLLayer(nsOpenGLLayer); - CGL.deletePixelFormat(nsOpenGLLayerPFmt); - nsOpenGLLayerPFmt = 0; - nsOpenGLLayer = 0; + return ctx; } - return CGL.deleteContext(ctx, true); - } - - @Override - public boolean copyImpl(long src, int mask) { - CGL.copyContext(contextHandle, src, mask); - return true; - } - @Override - public boolean makeCurrent(long ctx) { - final long cglCtx = CGL.getCGLContext(ctx); - if(0 == cglCtx) { - throw new InternalError("Null CGLContext for: "+this); + @Override + public boolean destroy(long ctx) { + lastPBufferHandle = 0; + return CGL.deleteContext(ctx, true); } - int err = CGL.CGLLockContext(cglCtx); - if(CGL.kCGLNoError == err) { - return CGL.makeCurrentContext(ctx); - } else if(DEBUG) { - System.err.println("NSGL: Could not lock context: err 0x"+Integer.toHexString(err)+": "+this); + + @Override + public boolean contextRealized(boolean realized) { + if( realized ) { + if( null != backingLayerHost ) { + // + // handled layered surface + // + final GLCapabilitiesImmutable chosenCaps = drawable.getChosenGLCapabilities(); + final long ctx = MacOSXCGLContext.this.getHandle(); + final int texID; + final long drawableHandle = drawable.getHandle(); + if(drawable instanceof GLFBODrawableImpl) { + final GLFBODrawableImpl fbod = (GLFBODrawableImpl)drawable; + texID = fbod.getTextureBuffer(GL.GL_FRONT).getName(); + fbod.setSwapBufferContext(new GLFBODrawableImpl.SwapBufferContext() { + public void swapBuffers(boolean doubleBuffered) { + MacOSXCGLContext.NSOpenGLImpl.this.swapBuffers(); + } } ) ; + lastPBufferHandle = 0; + } else if( chosenCaps.isPBuffer() && CGL.isNSOpenGLPixelBuffer(drawableHandle) ) { + texID = 0; + lastPBufferHandle = drawableHandle; + } else { + throw new GLException("BackingLayerHost w/ unknown handle (!FBO, !PBuffer): "+drawable); + } + lastWidth = drawable.getWidth(); + lastHeight = drawable.getHeight(); + if(0>=lastWidth || 0>=lastHeight || !drawable.isRealized()) { + throw new GLException("Drawable not realized yet or invalid texture size, texSize "+lastWidth+"x"+lastHeight+", "+drawable); + } + nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, lastPBufferHandle, texID, chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight); + if (DEBUG) { + System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer)+" w/ pbuffer "+toHexString(lastPBufferHandle)+", texID "+texID+", texSize "+lastWidth+"x"+lastHeight+", "+drawable); + } + backingLayerHost.attachSurfaceLayer(nsOpenGLLayer); + setSwapInterval(1); // enabled per default in layered surface + } else { + lastWidth = drawable.getWidth(); + lastHeight = drawable.getHeight(); + } + } else { + if( 0 != nsOpenGLLayer ) { + final NativeSurface surface = drawable.getNativeSurface(); + if (DEBUG) { + System.err.println("NS destroy nsOpenGLLayer "+toHexString(nsOpenGLLayer)+", "+drawable); + } + final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(surface, true); + if(null != ols && ols.isSurfaceLayerAttached()) { + // still having a valid OLS attached to surface (parent OLS could have been removed) + ols.detachSurfaceLayer(); + } + CGL.releaseNSOpenGLLayer(nsOpenGLLayer); + nsOpenGLLayer = 0; + } + if(0 != nsOpenGLLayerPFmt) { + CGL.deletePixelFormat(nsOpenGLLayerPFmt); + nsOpenGLLayerPFmt = 0; + } + lastPBufferHandle = 0; + } + backingLayerHost = null; + return true; } - return false; - } - @Override - public boolean release(long ctx) { - try { - gl.glFlush(); // w/o glFlush()/glFinish() OSX < 10.7 (NVidia driver) may freeze - } catch (GLException gle) { - if(DEBUG) { - System.err.println("MacOSXCGLContext.NSOpenGLImpl.release: INFO: glFlush() catched exception:"); - gle.printStackTrace(); + private final void validatePBufferConfig(long ctx) { + final GLCapabilitiesImmutable chosenCaps = drawable.getChosenGLCapabilities(); + final long drawableHandle = drawable.getHandle(); + if(chosenCaps.isPBuffer() && CGL.isNSOpenGLPixelBuffer(drawableHandle) && lastPBufferHandle != drawableHandle) { + // Must associate the pbuffer with our newly-created context + lastPBufferHandle = drawableHandle; + if(0 != drawableHandle) { + CGL.setContextPBuffer(ctx, drawableHandle); + } + if(DEBUG) { + System.err.println("NS.validateDrawableConfig bind pbuffer "+toHexString(drawableHandle)+" -> ctx "+toHexString(ctx)); + } } } - final boolean res = CGL.clearCurrentContext(ctx); - final long cglCtx = CGL.getCGLContext(ctx); - if(0 == cglCtx) { - throw new InternalError("Null CGLContext for: "+this); + + /** Returns true if size has been updated, otherwise false (same size). */ + private final boolean validateDrawableSizeConfig(long ctx) { + final int width = drawable.getWidth(); + final int height = drawable.getHeight(); + if( lastWidth != width || lastHeight != height ) { + lastWidth = drawable.getWidth(); + lastHeight = drawable.getHeight(); + if(DEBUG) { + System.err.println("NS.validateDrawableConfig size changed"); + } + return true; + } + return false; } - final int err = CGL.CGLUnlockContext(cglCtx); - if(DEBUG && CGL.kCGLNoError != err) { - System.err.println("CGL: Could not unlock context: err 0x"+Integer.toHexString(err)+": "+this); + + @Override + public boolean copyImpl(long src, int mask) { + CGL.copyContext(contextHandle, src, mask); + return true; } - return res && CGL.kCGLNoError == err; - } - @Override - public boolean setSwapInterval(int interval) { - if(0 != nsOpenGLLayer) { - CGL.setNSOpenGLLayerSwapInterval(nsOpenGLLayer, interval); - vsyncTimeout = interval * (int)screenVSyncTimeout; - if(DEBUG) { System.err.println("NS setSwapInterval: "+vsyncTimeout+" micros"); } + @Override + public boolean makeCurrent(long ctx) { + final long cglCtx = CGL.getCGLContext(ctx); + if(0 == cglCtx) { + throw new InternalError("Null CGLContext for: "+this); + } + int err = CGL.CGLLockContext(cglCtx); + if(CGL.kCGLNoError == err) { + validatePBufferConfig(ctx); // required to handle pbuffer change ASAP + return CGL.makeCurrentContext(ctx); + } else if(DEBUG) { + System.err.println("NSGL: Could not lock context: err 0x"+Integer.toHexString(err)+": "+this); + } + return false; + } + + @Override + public boolean release(long ctx) { + try { + gl.glFlush(); // w/o glFlush()/glFinish() OSX < 10.7 (NVidia driver) may freeze + } catch (GLException gle) { + if(DEBUG) { + System.err.println("MacOSXCGLContext.NSOpenGLImpl.release: INFO: glFlush() catched exception:"); + gle.printStackTrace(); + } + } + final boolean res = CGL.clearCurrentContext(ctx); + final long cglCtx = CGL.getCGLContext(ctx); + if(0 == cglCtx) { + throw new InternalError("Null CGLContext for: "+this); + } + final int err = CGL.CGLUnlockContext(cglCtx); + if(DEBUG && CGL.kCGLNoError != err) { + System.err.println("CGL: Could not unlock context: err 0x"+Integer.toHexString(err)+": "+this); + } + return res && CGL.kCGLNoError == err; } - CGL.setSwapInterval(contextHandle, interval); - return true; - } - @Override - public boolean swapBuffers() { - if( 0 != nsOpenGLLayer ) { - // If v-sync is disabled, frames will be drawn as quickly as possible - // w/o delay but in sync w/ CALayer. Otherwise wait until next swap interval (v-sync). - CGL.waitUntilNSOpenGLLayerIsReady(nsOpenGLLayer, vsyncTimeout); + @Override + public boolean detachPBuffer() { + if(0 != lastPBufferHandle) { + lastPBufferHandle = 0; + if(0 != nsOpenGLLayer) { + CGL.flushNSOpenGLLayerPBuffer(nsOpenGLLayer); // notify invalid pbuffer + } + // CGL.setContextPBuffer(contextHandle, 0); // doesn't work, i.e. not taking nil + } + return true; } - if(CGL.flushBuffer(contextHandle)) { + + @Override + public boolean setSwapInterval(int interval) { if(0 != nsOpenGLLayer) { - // trigger CALayer to update - CGL.setNSOpenGLLayerNeedsDisplay(nsOpenGLLayer); + CGL.setNSOpenGLLayerSwapInterval(nsOpenGLLayer, interval); + vsyncTimeout = interval * (int)screenVSyncTimeout + 1000; // +1ms + if(DEBUG) { System.err.println("NS setSwapInterval: "+vsyncTimeout+" micros"); } } + CGL.setSwapInterval(contextHandle, interval); return true; } - return false; - } + + private int skipSync=0; + + @Override + public boolean swapBuffers() { + final boolean res; + if( 0 != nsOpenGLLayer ) { + if( validateDrawableSizeConfig(contextHandle) ) { + // skip wait-for-vsync for a few frames if size has changed, + // allowing to update the texture IDs ASAP. + skipSync = 10; + } + + final int texID; + final boolean valid; + if(drawable instanceof GLFBODrawableImpl) { + texID = ((GLFBODrawableImpl)drawable).getTextureBuffer(GL.GL_FRONT).getName(); + valid = 0 != texID; + } else { + texID = 0; + valid = 0 != lastPBufferHandle; + } + if(valid) { + if(0 == skipSync) { + // If v-sync is disabled, frames will be drawn as quickly as possible + // w/o delay but in sync w/ CALayer. Otherwise wait until next swap interval (v-sync). + CGL.waitUntilNSOpenGLLayerIsReady(nsOpenGLLayer, vsyncTimeout); + } else { + skipSync--; + } + res = CGL.flushBuffer(contextHandle); + if(res) { + // trigger CALayer to update incl. possible surface change + CGL.setNSOpenGLLayerNeedsDisplay(nsOpenGLLayer, lastPBufferHandle, texID, lastWidth, lastHeight); + } + } else { + res = true; + } + } else { + res = CGL.flushBuffer(contextHandle); + } + return res; + } + } class CGLImpl implements GLBackendImpl { - @Override - public boolean isNSContext() { return false; } - - @Override - public long create(long share, int ctp, int major, int minor) { - long ctx = 0; - MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); - GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); - long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2CGLPixelFormat(chosenCaps, ctp, major, minor); - if (pixelFormat == 0) { - throw new GLException("Unable to allocate pixel format with requested GLCapabilities"); - } - config.setChosenPixelFormat(pixelFormat); - try { - // Create new context - PointerBuffer ctxPB = PointerBuffer.allocateDirect(1); - if (DEBUG) { - System.err.println("Share context for CGL-based pbuffer context is " + toHexString(share)); + @Override + public boolean isNSContext() { return false; } + + @Override + public long create(long share, int ctp, int major, int minor) { + long ctx = 0; + MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); + GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); + long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2CGLPixelFormat(chosenCaps, ctp, major, minor); + if (pixelFormat == 0) { + throw new GLException("Unable to allocate pixel format with requested GLCapabilities"); } - int res = CGL.CGLCreateContext(pixelFormat, share, ctxPB); - if (res != CGL.kCGLNoError) { - throw new GLException("Error code " + res + " while creating context"); - } - if(chosenCaps.isPBuffer()) { - // Attach newly-created context to the pbuffer - res = CGL.CGLSetPBuffer(ctxPB.get(0), drawable.getHandle(), 0, 0, 0); + try { + // Create new context + PointerBuffer ctxPB = PointerBuffer.allocateDirect(1); + if (DEBUG) { + System.err.println("Share context for CGL-based pbuffer context is " + toHexString(share)); + } + int res = CGL.CGLCreateContext(pixelFormat, share, ctxPB); if (res != CGL.kCGLNoError) { - throw new GLException("Error code " + res + " while attaching context to pbuffer"); + throw new GLException("Error code " + res + " while creating context"); } - } - ctx = ctxPB.get(0); - if(0!=ctx) { - if(DEBUG) { - GLCapabilitiesImmutable caps0 = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(pixelFormat); - System.err.println("NS created: "+caps0); + ctx = ctxPB.get(0); + + if (0 != ctx) { + GLCapabilities fixedCaps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(pixelFormat); + fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(fixedCaps, chosenCaps.isBackgroundOpaque()); + if(chosenCaps.isOnscreen() || !fixedCaps.isPBuffer()) { + // not handled, so copy them + fixedCaps.setFBO(chosenCaps.isFBO()); + fixedCaps.setPBuffer(chosenCaps.isPBuffer()); + fixedCaps.setBitmap(chosenCaps.isBitmap()); + fixedCaps.setOnscreen(chosenCaps.isOnscreen()); + } + config.setChosenCapabilities(fixedCaps); + if(DEBUG) { + System.err.println("CGL create fixedCaps: "+fixedCaps); + } + if(fixedCaps.isPBuffer()) { + // Must now associate the pbuffer with our newly-created context + res = CGL.CGLSetPBuffer(ctx, drawable.getHandle(), 0, 0, 0); + if (res != CGL.kCGLNoError) { + throw new GLException("Error code " + res + " while attaching context to pbuffer"); + } + } } + } finally { + CGL.CGLDestroyPixelFormat(pixelFormat); } - } finally { - CGL.CGLDestroyPixelFormat(pixelFormat); + return ctx; } - return ctx; - } - @Override - public boolean destroy(long ctx) { - return CGL.CGLDestroyContext(ctx) == CGL.kCGLNoError; - } + @Override + public boolean destroy(long ctx) { + return CGL.CGLDestroyContext(ctx) == CGL.kCGLNoError; + } - @Override - public boolean copyImpl(long src, int mask) { - CGL.CGLCopyContext(src, contextHandle, mask); - return true; - } + @Override + public boolean contextRealized(boolean realized) { + return true; + } + + @Override + public boolean copyImpl(long src, int mask) { + CGL.CGLCopyContext(src, contextHandle, mask); + return true; + } - @Override - public boolean makeCurrent(long ctx) { - int err = CGL.CGLLockContext(ctx); - if(CGL.kCGLNoError == err) { - err = CGL.CGLSetCurrentContext(ctx); + @Override + public boolean makeCurrent(long ctx) { + int err = CGL.CGLLockContext(ctx); if(CGL.kCGLNoError == err) { - return true; + err = CGL.CGLSetCurrentContext(ctx); + if(CGL.kCGLNoError == err) { + return true; + } else if(DEBUG) { + System.err.println("CGL: Could not make context current: err 0x"+Integer.toHexString(err)+": "+this); + } } else if(DEBUG) { - System.err.println("CGL: Could not make context current: err 0x"+Integer.toHexString(err)+": "+this); + System.err.println("CGL: Could not lock context: err 0x"+Integer.toHexString(err)+": "+this); } - } else if(DEBUG) { - System.err.println("CGL: Could not lock context: err 0x"+Integer.toHexString(err)+": "+this); + return false; } - return false; - } - @Override - public boolean release(long ctx) { - try { - gl.glFlush(); // w/o glFlush()/glFinish() OSX < 10.7 (NVidia driver) may freeze - } catch (GLException gle) { - if(DEBUG) { - System.err.println("MacOSXCGLContext.CGLImpl.release: INFO: glFlush() catched exception:"); - gle.printStackTrace(); + @Override + public boolean release(long ctx) { + try { + gl.glFlush(); // w/o glFlush()/glFinish() OSX < 10.7 (NVidia driver) may freeze + } catch (GLException gle) { + if(DEBUG) { + System.err.println("MacOSXCGLContext.CGLImpl.release: INFO: glFlush() catched exception:"); + gle.printStackTrace(); + } } + int err = CGL.CGLSetCurrentContext(0); + if(DEBUG && CGL.kCGLNoError != err) { + System.err.println("CGL: Could not release current context: err 0x"+Integer.toHexString(err)+": "+this); + } + int err2 = CGL.CGLUnlockContext(ctx); + if(DEBUG && CGL.kCGLNoError != err2) { + System.err.println("CGL: Could not unlock context: err 0x"+Integer.toHexString(err2)+": "+this); + } + return CGL.kCGLNoError == err && CGL.kCGLNoError == err2; + } + + @Override + public boolean detachPBuffer() { + /* Doesn't work, i.e. not taking NULL + final int res = CGL.CGLSetPBuffer(contextHandle, 0, 0, 0, 0); + if (res != CGL.kCGLNoError) { + throw new GLException("Error code " + res + " while detaching context from pbuffer"); + } */ + return true; } - int err = CGL.CGLSetCurrentContext(0); - if(DEBUG && CGL.kCGLNoError != err) { - System.err.println("CGL: Could not release current context: err 0x"+Integer.toHexString(err)+": "+this); + + @Override + public boolean setSwapInterval(int interval) { + int[] lval = new int[] { interval } ; + CGL.CGLSetParameter(contextHandle, CGL.kCGLCPSwapInterval, lval, 0); + return true; } - int err2 = CGL.CGLUnlockContext(ctx); - if(DEBUG && CGL.kCGLNoError != err2) { - System.err.println("CGL: Could not unlock context: err 0x"+Integer.toHexString(err2)+": "+this); + @Override + public boolean swapBuffers() { + return CGL.kCGLNoError == CGL.CGLFlushDrawable(contextHandle); } - return CGL.kCGLNoError == err && CGL.kCGLNoError == err2; - } - - @Override - public boolean setSwapInterval(int interval) { - int[] lval = new int[] { interval } ; - CGL.CGLSetParameter(contextHandle, CGL.kCGLCPSwapInterval, lval, 0); - return true; - } - @Override - public boolean swapBuffers() { - return CGL.kCGLNoError == CGL.CGLFlushDrawable(contextHandle); - } } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index af767f0c3..cc727c8e1 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -42,10 +42,10 @@ package jogamp.opengl.macosx.cgl; import java.lang.ref.WeakReference; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import javax.media.nativewindow.NativeSurface; +import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; @@ -92,7 +92,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { this.id = id; } } - private List> createdContexts = new ArrayList>(); + /* pp */ List> createdContexts = new ArrayList>(); private boolean haveSetOpenGLMode = false; private GLBackendType openGLMode = GLBackendType.NSOPENGL; @@ -110,26 +110,42 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { return GLBackendType.NSOPENGL == openGLMode ? getHandle() : 0; } - protected void registerContext(MacOSXCGLContext ctx) { + @Override + protected void associateContext(GLContext ctx, boolean bound) { // NOTE: we need to keep track of the created contexts in order to // implement swapBuffers() because of how Mac OS X implements its // OpenGL window interface synchronized (createdContexts) { - createdContexts.add(new WeakReference(ctx)); - } + if(bound) { + createdContexts.add(new WeakReference((MacOSXCGLContext)ctx)); + } else { + for(int i=0; i ref = createdContexts.get(i); + final MacOSXCGLContext _ctx = ref.get(); + if( _ctx == null || _ctx == ctx) { + createdContexts.remove(i); + } else { + i++; + } + } + } + } } + @Override - protected final void swapBuffersImpl() { - // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers() - synchronized (createdContexts) { - for (Iterator> iter = createdContexts.iterator(); iter.hasNext(); ) { - WeakReference ref = iter.next(); - MacOSXCGLContext ctx = ref.get(); - if (ctx != null) { - ctx.swapBuffers(); - } else { - iter.remove(); - } + protected final void swapBuffersImpl(boolean doubleBuffered) { + if(doubleBuffered) { + synchronized (createdContexts) { + for(int i=0; i ref = createdContexts.get(i); + final MacOSXCGLContext ctx = ref.get(); + if (ctx != null) { + ctx.swapBuffers(); + i++; + } else { + createdContexts.remove(i); + } + } } } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index 591fafc68..e174d38f4 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -51,7 +51,7 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; @@ -61,7 +61,8 @@ import javax.media.opengl.GLDrawable; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import jogamp.nativewindow.macosx.OSXUtil; +import jogamp.nativewindow.WrappedSurface; +import jogamp.nativewindow.macosx.OSXDummyUpstreamSurfaceHook; import jogamp.opengl.DesktopGLDynamicLookupHelper; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; @@ -71,7 +72,7 @@ import jogamp.opengl.GLGraphicsConfigurationUtil; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.ReflectionUtil; -import com.jogamp.nativewindow.WrappedSurface; +import com.jogamp.nativewindow.MutableGraphicsConfiguration; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.opengl.GLExtensions; @@ -320,9 +321,14 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) { - AbstractGraphicsConfiguration config = target.getGraphicsConfiguration(); - GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final MutableGraphicsConfiguration config = (MutableGraphicsConfiguration) target.getGraphicsConfiguration(); + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); if(!caps.isPBuffer()) { + // Actual implementation is using PBuffer ... + final GLCapabilities modCaps = (GLCapabilities) caps.cloneMutable(); + modCaps.setPBuffer(true); + modCaps.setBitmap(false); + config.setChosenCapabilities(modCaps); return new MacOSXOffscreenCGLDrawable(this, target); } return new MacOSXPbufferCGLDrawable(this, target); @@ -336,7 +342,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final MacOSXGraphicsDevice device; if(createNewDevice) { device = new MacOSXGraphicsDevice(deviceReq.getUnitID()); @@ -348,68 +354,23 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return new WrappedSurface(config, 0, width, height, lifecycleHook); + return new WrappedSurface(config, 0, upstreamHook, createNewDevice); } @Override public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, + new OSXDummyUpstreamSurfaceHook(width, height)); } - private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { - long nsWindow = 0; - @Override - public final void create(ProxySurface s) { - if(0 == nsWindow && 0 == s.getSurfaceHandle()) { - nsWindow = OSXUtil.CreateNSWindow(0, 0, s.getWidth(), s.getHeight()); - if(0 == nsWindow) { - throw new GLException("Error NS window 0"); - } - long nsView = OSXUtil.GetNSView(nsWindow); - if(0 == nsView) { - throw new GLException("Error NS view 0"); - } - s.setSurfaceHandle(nsView); - s.setImplBitfield(ProxySurface.INVISIBLE_WINDOW); - if(DEBUG) { - System.err.println("MacOSXCGLDrawableFactory.dummySurfaceLifecycleHook.create: "+s); - } - } - } - @Override - public final void destroy(ProxySurface s) { - if(0 != nsWindow && 0 != s.getSurfaceHandle()) { - OSXUtil.DestroyNSWindow(nsWindow); - nsWindow = 0; - s.setSurfaceHandle(0); - if(DEBUG) { - System.err.println("MacOSXCGLDrawableFactory.dummySurfaceLifecycleHook.destroy: "+s); - } - } - } - @Override - public final int getWidth(ProxySurface s) { - return s.initialWidth; - } - @Override - public final int getHeight(ProxySurface s) { - return s.initialHeight; - } - - @Override - public String toString() { - return "MacOSXLSurfaceLifecycleHook[]"; - } - - }; @Override protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { final MacOSXGraphicsDevice device = new MacOSXGraphicsDevice(deviceReq.getUnitID()); final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); final MacOSXCGLGraphicsConfiguration config = MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, true); - return new WrappedSurface(config, windowHandle, 0, 0, upstream); + return new WrappedSurface(config, windowHandle, upstream, true); } @Override diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java index 149927160..8866c7ce6 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java @@ -51,23 +51,16 @@ import com.jogamp.common.nio.PointerBuffer; import com.jogamp.nativewindow.MutableGraphicsConfiguration; public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { - long pixelformat; MacOSXCGLGraphicsConfiguration(AbstractGraphicsScreen screen, - GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - long pixelformat) { + GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested) { super(screen, capsChosen, capsRequested); - this.pixelformat=pixelformat; } public Object clone() { return super.clone(); } - void setChosenPixelFormat(long pixelformat) { - this.pixelformat=pixelformat; - } - protected static List getAvailableCapabilities(MacOSXCGLDrawableFactory factory, AbstractGraphicsDevice device) { MacOSXCGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateOSXSharedResource(device); if(null == sharedResource) { @@ -114,11 +107,11 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration break; case CGL.kCGLPFAColorFloat: - ivalues[idx] = caps.getPbufferFloatingPointBuffers() ? 1 : 0; + ivalues[idx] = ( !caps.isOnscreen() && caps.isPBuffer() && caps.getPbufferFloatingPointBuffers() ) ? 1 : 0; break; case CGL.NSOpenGLPFAPixelBuffer: - ivalues[idx] = caps.isPBuffer() ? 1 : 0; + ivalues[idx] = ( !caps.isOnscreen() && caps.isPBuffer() ) ? 1 : 0; break; case CGL.NSOpenGLPFADoubleBuffer: @@ -188,11 +181,11 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration attrs[i++] = CGL.kCGLPFAOpenGLProfile; attrs[i++] = MacOSXCGLContext.GLProfile2CGLOGLProfileValue(ctp, major, minor); } - if(caps.isPBuffer()) { + if(!caps.isOnscreen() && caps.isPBuffer()) { attrs[i++] = CGL.kCGLPFAPBuffer; - } - if (caps.getPbufferFloatingPointBuffers()) { - attrs[i++] = CGL.kCGLPFAColorFloat; + if (caps.getPbufferFloatingPointBuffers()) { + attrs[i++] = CGL.kCGLPFAColorFloat; + } } if (caps.getDoubleBuffered()) { attrs[i++] = CGL.kCGLPFADoubleBuffer; diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java index 13faf7090..43a9d0d1a 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java @@ -96,6 +96,6 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GLGraphicsConfigurati capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(device, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(device) ); - return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested, 0); + return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested); } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java index 6be9e386d..65ed5fc15 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java @@ -49,8 +49,8 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; -import com.jogamp.nativewindow.WrappedSurface; +import jogamp.nativewindow.WrappedSurface; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLContextShareSet; import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.GLBackendType; @@ -62,7 +62,6 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { private MacOSXExternalCGLContext(Drawable drawable, boolean isNSContext, long handle) { super(drawable, null); setOpenGLMode(isNSContext ? GLBackendType.NSOPENGL : GLBackendType.CGL ); - drawable.registerContext(this); this.contextHandle = handle; GLContextShareSet.contextCreated(this); setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT); @@ -108,13 +107,13 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { } AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_MACOSX); - MacOSXCGLGraphicsConfiguration cfg = new MacOSXCGLGraphicsConfiguration(aScreen, caps, caps, pixelFormat); + MacOSXCGLGraphicsConfiguration cfg = new MacOSXCGLGraphicsConfiguration(aScreen, caps, caps); if(0 == currentDrawable) { // set a fake marker stating a valid drawable currentDrawable = 1; } - WrappedSurface ns = new WrappedSurface(cfg, currentDrawable, 64, 64, null); + WrappedSurface ns = new WrappedSurface(cfg, currentDrawable, 64, 64, true); return new MacOSXExternalCGLContext(new Drawable(factory, ns), isNSContext, contextHandle); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java index b1e283ebc..ec9628004 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java @@ -52,9 +52,7 @@ public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable { @Override public GLContext createContext(GLContext shareWith) { - final MacOSXOnscreenCGLContext ctx= new MacOSXOnscreenCGLContext(this, shareWith); - registerContext(ctx); - return ctx; + return new MacOSXOnscreenCGLContext(this, shareWith); } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java index 88886ddd2..7e2d8cf10 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java @@ -39,6 +39,7 @@ import javax.media.opengl.GLPbuffer; import jogamp.opengl.GLContextImpl; +@SuppressWarnings("deprecation") public class MacOSXPbufferCGLContext extends MacOSXCGLContext { // State for render-to-texture and render-to-texture-rectangle support diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 8f2f386af..668e463a2 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -40,6 +40,8 @@ package jogamp.opengl.macosx.cgl; +import java.lang.ref.WeakReference; + import javax.media.nativewindow.DefaultGraphicsConfiguration; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.MutableSurface; @@ -70,9 +72,6 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { // private int textureTarget; // e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_NV // private int texture; // actual texture object - // Note that we can not store this in the NativeSurface because the - // semantic is that contains an NSView - protected long pBuffer; protected int pBufferTexTarget, pBufferTexWidth, pBufferTexHeight; public MacOSXPbufferCGLDrawable(GLDrawableFactory factory, NativeSurface target) { @@ -90,9 +89,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { @Override public GLContext createContext(GLContext shareWith) { - final MacOSXPbufferCGLContext ctx = new MacOSXPbufferCGLContext(this, shareWith); - registerContext(ctx); - return ctx; + return new MacOSXPbufferCGLContext(this, shareWith); } @Override @@ -101,27 +98,34 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { return 0; } - @Override - public long getHandle() { - return pBuffer; - } - protected int getTextureTarget() { return pBufferTexTarget; } protected int getTextureWidth() { return pBufferTexWidth; } protected int getTextureHeight() { return pBufferTexHeight; } protected void destroyPbuffer() { - if (this.pBuffer != 0) { - NativeSurface ns = getNativeSurface(); + final MutableSurface ms = (MutableSurface) getNativeSurface(); + final long pBuffer = ms.getSurfaceHandle(); + if (0 != pBuffer) { + synchronized (createdContexts) { + for(int i=0; i ref = createdContexts.get(i); + final MacOSXCGLContext ctx = ref.get(); + if (ctx != null) { + ctx.detachPBuffer(); + i++; + } else { + createdContexts.remove(i); + } + } + } impl.destroy(pBuffer); - this.pBuffer = 0; - ((MutableSurface)ns).setSurfaceHandle(0); + ms.setSurfaceHandle(0); } } private void createPbuffer() { - final NativeSurface ns = getNativeSurface(); - final DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) ns.getGraphicsConfiguration(); + final MutableSurface ms = (MutableSurface) getNativeSurface(); + final DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) ms.getGraphicsConfiguration(); final GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities(); final GLProfile glProfile = capabilities.getGLProfile(); MacOSXCGLDrawableFactory.SharedResource sr = ((MacOSXCGLDrawableFactory)factory).getOrCreateOSXSharedResource(config.getScreen().getDevice()); @@ -161,7 +165,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { } } - pBuffer = impl.create(pBufferTexTarget, internalFormat, getWidth(), getHeight()); + final long pBuffer = impl.create(pBufferTexTarget, internalFormat, getWidth(), getHeight()); if(DEBUG) { System.err.println("MacOSXPbufferCGLDrawable tex: target "+toHexString(pBufferTexTarget)+ ", pbufferSize "+getWidth()+"x"+getHeight()+ @@ -174,7 +178,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { throw new GLException("pbuffer creation error: CGL.createPBuffer() failed"); } - ((MutableSurface)ns).setSurfaceHandle(pBuffer); + ms.setSurfaceHandle(pBuffer); } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java index 96c1187d3..f6cc2956d 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java @@ -50,8 +50,8 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import com.jogamp.nativewindow.WrappedSurface; +import jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.windows.GDI; import jogamp.opengl.GLContextShareSet; @@ -102,7 +102,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { System.err.println("WindowsExternalWGLContext valid hdc/pfd, retrieved cfg: " + cfg); } } - return new WindowsExternalWGLContext(new Drawable(factory, new WrappedSurface(cfg, hdc, 64, 64, null)), ctx, cfg); + return new WindowsExternalWGLContext(new Drawable(factory, new WrappedSurface(cfg, hdc, 64, 64, true)), ctx, cfg); } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java index 15bd005dc..f8c237c9e 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java @@ -49,10 +49,10 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.GDIUtil; -import com.jogamp.nativewindow.WrappedSurface; public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { @@ -72,7 +72,7 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { final AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); final WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromExternal(factory, hdc, pfdID, glp, aScreen, true); - return new WindowsExternalWGLDrawable(factory, new WrappedSurface(cfg, hdc, 64, 64, null)); + return new WindowsExternalWGLDrawable(factory, new WrappedSurface(cfg, hdc, 64, 64, true)); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java index ca7886e7f..3b3f0c123 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java @@ -73,27 +73,28 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl { } @Override - protected final void swapBuffersImpl() { - // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers() - final long t0; - if (PROFILING) { - t0 = System.currentTimeMillis(); - } else { - t0 = 0; - } - - if (!WGLUtil.SwapBuffers(getHandle()) && (GDI.GetLastError() != GDI.ERROR_SUCCESS)) { - throw new GLException("Error swapping buffers"); - } - - if (PROFILING) { - profilingSwapBuffersTime += System.currentTimeMillis() - t0; - if (++profilingSwapBuffersTicks == PROFILING_TICKS) { - System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + PROFILING_TICKS + " calls (" + - ((float) profilingSwapBuffersTime / (float) PROFILING_TICKS) + " ms/call)"); - profilingSwapBuffersTime = 0; - profilingSwapBuffersTicks = 0; - } + protected final void swapBuffersImpl(boolean doubleBuffered) { + if(doubleBuffered) { + final long t0; + if (PROFILING) { + t0 = System.currentTimeMillis(); + } else { + t0 = 0; + } + + if (!WGLUtil.SwapBuffers(getHandle()) && (GDI.GetLastError() != GDI.ERROR_SUCCESS)) { + throw new GLException("Error swapping buffers"); + } + + if (PROFILING) { + profilingSwapBuffersTime += System.currentTimeMillis() - t0; + if (++profilingSwapBuffersTicks == PROFILING_TICKS) { + System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + PROFILING_TICKS + " calls (" + + ((float) profilingSwapBuffersTime / (float) PROFILING_TICKS) + " ms/call)"); + profilingSwapBuffersTime = 0; + profilingSwapBuffersTicks = 0; + } + } } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 7ea487523..91d5c225a 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -52,7 +52,7 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; @@ -62,9 +62,10 @@ import javax.media.opengl.GLDrawable; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.windows.GDI; +import jogamp.nativewindow.windows.GDIDummyUpstreamSurfaceHook; import jogamp.nativewindow.windows.GDISurface; -import jogamp.nativewindow.windows.GDIUtil; import jogamp.nativewindow.windows.RegisteredClassFactory; import jogamp.opengl.DesktopGLDynamicLookupHelper; import jogamp.opengl.GLContextImpl; @@ -79,7 +80,6 @@ import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.VersionNumber; -import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; import com.jogamp.opengl.GLExtensions; @@ -541,7 +541,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected final ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final WindowsGraphicsDevice device; if(createNewDevice) { device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); @@ -553,7 +553,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return new WrappedSurface(config, 0, width, height, lifecycleHook); + return new WrappedSurface(config, 0, upstreamHook, createNewDevice); } @Override @@ -571,57 +571,15 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+requestedCaps+" on "+screen); } - return new GDISurface(config, 0, width, height, dummySurfaceLifecycleHook); - } - private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { - @Override - public final void create(ProxySurface s) { - final GDISurface ms = (GDISurface)s; - if(0 == ms.getWindowHandle()) { - final long windowHandle = GDIUtil.CreateDummyWindow(0, 0, s.getWidth(), s.getHeight()); - if(0 == windowHandle) { - throw new GLException("Error windowHandle 0, werr: "+GDI.GetLastError()); - } - ms.setWindowHandle(windowHandle); - if(DEBUG) { - System.err.println("WindowsWGLDrawableFactory.dummySurfaceLifecycleHook.create: "+ms); - } - } - } - @Override - public final void destroy(ProxySurface s) { - final GDISurface ms = (GDISurface)s; - if(0 != ms.getWindowHandle()) { - GDI.ShowWindow(ms.getWindowHandle(), GDI.SW_HIDE); - GDIUtil.DestroyDummyWindow(ms.getWindowHandle()); - ms.setWindowHandle(0); - if(DEBUG) { - System.err.println("WindowsWGLDrawableFactory.dummySurfaceLifecycleHook.destroy: "+ms); - } - } - } - @Override - public final int getWidth(ProxySurface s) { - return s.initialWidth; - } - @Override - public final int getHeight(ProxySurface s) { - return s.initialHeight; - } - - @Override - public String toString() { - return "GDISurfaceLifecycleHook[]"; - } - }; - + return new GDISurface(config, 0, new GDIDummyUpstreamSurfaceHook(width, height), createNewDevice); + } @Override protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { final WindowsGraphicsDevice device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); final WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); - return new GDISurface(cfg, windowHandle, 0, 0, upstream); + return new GDISurface(cfg, windowHandle, upstream, true); } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 4d1069e6b..058f4e336 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -107,7 +107,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio if(hasARB) { caps = wglARBPFID2GLCapabilities(sharedResource, device, glp, hdc, pfdID, GLGraphicsConfigurationUtil.ALL_BITS); } else { - caps = PFD2GLCapabilities(glp, hdc, pfdID, GLGraphicsConfigurationUtil.ALL_BITS); + caps = PFD2GLCapabilities(device, glp, hdc, pfdID, GLGraphicsConfigurationUtil.ALL_BITS); } if(null==caps) { throw new GLException("Couldn't choose Capabilities by: HDC 0x"+Long.toHexString(hdc)+ @@ -325,7 +325,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio throw new GLException("wglARBPFID2GLCapabilities: Error getting pixel format attributes for pixel format " + pfdID + " of device context " + toHexString(hdc) + ", werr " + GDI.GetLastError()); } - return AttribList2GLCapabilities(glp, hdc, pfdID, iattributes, niattribs, iresults, winattrbits); + return AttribList2GLCapabilities(device, glp, hdc, pfdID, iattributes, niattribs, iresults, winattrbits); } static int[] wglChoosePixelFormatARB(WindowsWGLDrawableFactory.SharedResource sharedResource, AbstractGraphicsDevice device, @@ -390,7 +390,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio for(int i = 0; i= 1 && ((WindowsWGLContext)sharedResource.getContext()).getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdIDs[i], 0, niattribs, iattributes, 0, iresults, 0) ) { - final GLCapabilitiesImmutable caps = AttribList2GLCapabilities(glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, winattrbits); + final GLCapabilitiesImmutable caps = AttribList2GLCapabilities(device, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, winattrbits); if(null != caps) { bucket.add(caps); if(DEBUG) { @@ -398,7 +398,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio System.err.println("wglARBPFIDs2GLCapabilities: bucket["+i+" -> "+j+"]: "+caps); } } else if(DEBUG) { - GLCapabilitiesImmutable skipped = AttribList2GLCapabilities(glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, GLGraphicsConfigurationUtil.ALL_BITS); + GLCapabilitiesImmutable skipped = AttribList2GLCapabilities(device, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, GLGraphicsConfigurationUtil.ALL_BITS); System.err.println("wglARBPFIDs2GLCapabilities: bucket["+i+" -> skip]: pfdID "+pfdIDs[i]+", "+skipped+", winattr "+GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrbits).toString()); } } else if (DEBUG) { @@ -616,9 +616,9 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio return val; } - static WGLGLCapabilities AttribList2GLCapabilities(final GLProfile glp, - final long hdc, final int pfdID, final int[] iattribs, - final int niattribs, final int[] iresults, final int winattrmask) { + static WGLGLCapabilities AttribList2GLCapabilities(final AbstractGraphicsDevice device, + final GLProfile glp, final long hdc, final int pfdID, + final int[] iattribs, final int niattribs, final int[] iresults, final int winattrmask) { final int allDrawableTypeBits = AttribList2DrawableTypeBits(iattribs, niattribs, iresults); int drawableTypeBits = winattrmask & allDrawableTypeBits; @@ -637,7 +637,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); res.setValuesByARB(iattribs, niattribs, iresults); - return (WGLGLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, drawableTypeBits); + return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } // @@ -672,7 +672,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio return val; } - static WGLGLCapabilities PFD2GLCapabilities(final GLProfile glp, final long hdc, final int pfdID, final int winattrmask) { + static WGLGLCapabilities PFD2GLCapabilities(AbstractGraphicsDevice device, final GLProfile glp, final long hdc, final int pfdID, final int winattrmask) { PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor(hdc, pfdID); if(null == pfd) { return null; @@ -689,21 +689,22 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); res.setValuesByGDI(); - return (WGLGLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, drawableTypeBits ); + return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } - static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(final GLProfile glp, final long hdc, final int pfdID) { + static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(AbstractGraphicsDevice device, final GLProfile glp, final long hdc, final int pfdID) { PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor(hdc, pfdID); - return PFD2GLCapabilitiesNoCheck(glp, pfd, pfdID); + return PFD2GLCapabilitiesNoCheck(device, glp, pfd, pfdID); } - static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(GLProfile glp, PIXELFORMATDESCRIPTOR pfd, int pfdID) { + static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(AbstractGraphicsDevice device, GLProfile glp, PIXELFORMATDESCRIPTOR pfd, int pfdID) { if(null == pfd) { return null; } final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); res.setValuesByGDI(); - return (WGLGLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, PFD2DrawableTypeBits(pfd)); + + return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, PFD2DrawableTypeBits(pfd), res); } static PIXELFORMATDESCRIPTOR GLCapabilities2PFD(GLCapabilitiesImmutable caps, PIXELFORMATDESCRIPTOR pfd) { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index 41c9bba02..d2d1dafc8 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -113,13 +113,14 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } protected static List getAvailableCapabilities(WindowsWGLDrawableFactory factory, AbstractGraphicsDevice device) { - WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResource(device); + final WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResource(device); if(null == sharedResource) { throw new GLException("Shared resource for device n/a: "+device); } - GLDrawableImpl sharedDrawable = sharedResource.getDrawable(); - GLCapabilitiesImmutable capsChosen = sharedDrawable.getChosenGLCapabilities(); - GLContext sharedContext = sharedResource.getContext(); + final GLDrawableImpl sharedDrawable = sharedResource.getDrawable(); + final GLContext sharedContext = sharedResource.getContext(); + final GLProfile glp = GLProfile.getDefault(device); + List availableCaps = null; if ( sharedResource.needsCurrentContext4ARBPFDQueries() ) { @@ -135,10 +136,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat throw new GLException("Error: HDC is null"); } if (sharedResource.hasARBPixelFormat()) { - availableCaps = WindowsWGLGraphicsConfigurationFactory.getAvailableGLCapabilitiesARB(sharedResource, sharedResource.getDevice(), capsChosen.getGLProfile(), hdc); + availableCaps = WindowsWGLGraphicsConfigurationFactory.getAvailableGLCapabilitiesARB(sharedResource, sharedResource.getDevice(), glp, hdc); } if( null == availableCaps || availableCaps.isEmpty() ) { - availableCaps = getAvailableGLCapabilitiesGDI(device, capsChosen.getGLProfile(), hdc); + availableCaps = getAvailableGLCapabilitiesGDI(device, glp, hdc); } } finally { if ( sharedResource.needsCurrentContext4ARBPFDQueries() ) { @@ -165,7 +166,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat int numFormats = pformats.length; List bucket = new ArrayList(numFormats); for (int i = 0; i < numFormats; i++) { - final GLCapabilitiesImmutable caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, hdc, pformats[i], GLGraphicsConfigurationUtil.ALL_BITS); + final GLCapabilitiesImmutable caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pformats[i], GLGraphicsConfigurationUtil.ALL_BITS); if(null != caps) { bucket.add(caps); } @@ -439,7 +440,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat private static boolean updateGraphicsConfigurationGDI(WindowsWGLGraphicsConfiguration config, CapabilitiesChooser chooser, long hdc, boolean extHDC, int[] pformats) { GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - if(capsChosen.isPBuffer()) { + if( !capsChosen.isOnscreen() && capsChosen.isPBuffer() ) { if (DEBUG) { System.err.println("updateGraphicsConfigurationGDI: no pbuffer supported on GDI: " + capsChosen); } @@ -454,6 +455,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat System.err.println("updateGraphicsConfigurationGDI: capsChosen "+capsChosen+", "+GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrmask).toString()); } + AbstractGraphicsDevice device = config.getScreen().getDevice(); int pfdID; // chosen or preset PFD ID WGLGLCapabilities pixelFormatCaps = null; // chosen or preset PFD ID's caps boolean pixelFormatSet = false; // indicates a preset PFD ID [caps] @@ -468,7 +470,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat + ", pixelformat " + pfdID); } pixelFormatSet = true; - pixelFormatCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, hdc, pfdID, winattrmask); + pixelFormatCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pfdID, winattrmask); if(null == pixelFormatCaps) { throw new GLException("Could not map PFD2GLCaps w/ already chosen pfdID "+pfdID); } @@ -480,7 +482,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat List availableCaps = new ArrayList(); for (int i = 0; i < pformats.length; i++) { - final GLCapabilitiesImmutable caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, hdc, pformats[i], winattrmask); + final GLCapabilitiesImmutable caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pformats[i], winattrmask); if(null != caps) { availableCaps.add(caps); if(DEBUG) { @@ -488,7 +490,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> "+j+"]: "+caps); } } else if(DEBUG) { - GLCapabilitiesImmutable skipped = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(glProfile, hdc, pformats[i]); + GLCapabilitiesImmutable skipped = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(device, glProfile, hdc, pformats[i]); System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> skip]: pfdID "+pformats[i]+", "+skipped); } } @@ -505,8 +507,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat recommendedIndex--) { /* nop */ } if(DEBUG && 0 > recommendedIndex) { - final GLCapabilitiesImmutable reqPFDCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(glProfile, pfd, pfdID); - final GLCapabilitiesImmutable chosenCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, hdc, pfdID, winattrmask); + final GLCapabilitiesImmutable reqPFDCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(device, glProfile, pfd, pfdID); + final GLCapabilitiesImmutable chosenCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pfdID, winattrmask); System.err.println("Chosen PFDID "+pfdID+", but not found in available caps (use given pfdIDs "+givenPFormats+", reqPFDCaps "+reqPFDCaps+", chosenCaps: "+chosenCaps); } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index 1f3edbd8a..03a0eefbf 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -48,10 +48,10 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import jogamp.nativewindow.WrappedSurface; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLContextShareSet; -import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.x11.X11GraphicsScreen; public class X11ExternalGLXContext extends X11GLXContext { @@ -105,7 +105,7 @@ public class X11ExternalGLXContext extends X11GLXContext { cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]); } - final WrappedSurface ns = new WrappedSurface(cfg, drawable, w, h, null); + final WrappedSurface ns = new WrappedSurface(cfg, drawable, w, h, true); return new X11ExternalGLXContext(new Drawable(factory, ns), ctx); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java index 8652e2d4a..ac78c6f4a 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java @@ -45,7 +45,8 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import com.jogamp.nativewindow.WrappedSurface; +import jogamp.nativewindow.WrappedSurface; + import com.jogamp.nativewindow.x11.X11GraphicsScreen; @@ -87,7 +88,7 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { System.err.println("X11ExternalGLXDrawable: WARNING: forcing GLX_RGBA_TYPE for newly created contexts (current 0x"+Integer.toHexString(val[0])+")"); } } - return new X11ExternalGLXDrawable(factory, new WrappedSurface(cfg, drawable, w, h, null)); + return new X11ExternalGLXDrawable(factory, new WrappedSurface(cfg, drawable, w, h, true)); } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawable.java index e9912ce9d..8c642777d 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawable.java @@ -69,9 +69,10 @@ public abstract class X11GLXDrawable extends GLDrawableImpl { } @Override - protected final void swapBuffersImpl() { - // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers() - GLX.glXSwapBuffers(getNativeSurface().getDisplayHandle(), getHandle()); + protected final void swapBuffersImpl(boolean doubleBuffered) { + if(doubleBuffered) { + GLX.glXSwapBuffers(getNativeSurface().getDisplayHandle(), getHandle()); + } } //--------------------------------------------------------------------------- diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index bc3e5b793..fb11f8bba 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -49,7 +49,7 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; @@ -59,6 +59,8 @@ import javax.media.opengl.GLDrawable; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import jogamp.nativewindow.WrappedSurface; +import jogamp.nativewindow.x11.X11DummyUpstreamSurfaceHook; import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; import jogamp.opengl.DesktopGLDynamicLookupHelper; @@ -70,7 +72,6 @@ import jogamp.opengl.GLGraphicsConfigurationUtil; import jogamp.opengl.SharedResourceRunner; import com.jogamp.common.util.VersionNumber; -import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; @@ -505,7 +506,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { protected final ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final X11GraphicsDevice device; if(createNewDevice) { // Null X11 locking, due to private non-shared Display handle @@ -518,65 +519,15 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return new WrappedSurface( config, 0, width, height, lifecycleHook); + return new WrappedSurface(config, 0, upstreamHook, createNewDevice); } @Override public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new X11DummyUpstreamSurfaceHook(width, height)); } - private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { - @Override - public final void create(ProxySurface s) { - if( 0 == s.getSurfaceHandle() ) { - final X11GLXGraphicsConfiguration cfg = (X11GLXGraphicsConfiguration) s.getGraphicsConfiguration(); - final X11GraphicsScreen screen = (X11GraphicsScreen) cfg.getScreen(); - final X11GraphicsDevice device = (X11GraphicsDevice) screen.getDevice(); - if(0 == device.getHandle()) { - device.open(); - s.setImplBitfield(ProxySurface.OWN_DEVICE); - } - final long windowHandle = X11Lib.CreateDummyWindow(device.getHandle(), screen.getIndex(), cfg.getXVisualID(), s.getWidth(), s.getHeight()); - if(0 == windowHandle) { - throw new GLException("Creating dummy window failed w/ "+cfg+", "+s.getWidth()+"x"+s.getHeight()); - } - s.setSurfaceHandle(windowHandle); - if(DEBUG) { - System.err.println("X11GLXDrawableFactory.dummySurfaceLifecycleHook.create: "+s); - } - } - } - @Override - public final void destroy(ProxySurface s) { - if(0 != s.getSurfaceHandle()) { - final X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) s.getGraphicsConfiguration(); - final X11GraphicsDevice device = (X11GraphicsDevice) config.getScreen().getDevice(); - X11Lib.DestroyDummyWindow(device.getHandle(), s.getSurfaceHandle()); - s.setSurfaceHandle(0); - if( 0 != ( ProxySurface.OWN_DEVICE & s.getImplBitfield() ) ) { - device.close(); - } - if(DEBUG) { - System.err.println("X11GLXDrawableFactory.dummySurfaceLifecycleHook.destroy: "+s); - } - } - } - @Override - public final int getWidth(ProxySurface s) { - return s.initialWidth; - } - @Override - public final int getHeight(ProxySurface s) { - return s.initialHeight; - } - @Override - public String toString() { - return "X11SurfaceLifecycleHook[]"; - } - }; - @Override protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { @@ -593,7 +544,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if(DEBUG) { System.err.println("X11GLXDrawableFactory.createProxySurfaceImpl 0x"+Long.toHexString(windowHandle)+": "+cfg); } - return new WrappedSurface(cfg, windowHandle, 0, 0, upstream); + return new WrappedSurface(cfg, windowHandle, upstream, true); } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java index 866fcbbe4..96c3c4123 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java @@ -307,7 +307,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem return null; // no RGBA -> color index not supported } - X11GLCapabilities res = new X11GLCapabilities(visualInfo, fbcfg, fbcfgid, glp); + final X11GLCapabilities res = new X11GLCapabilities(visualInfo, fbcfg, fbcfgid, glp); if (isMultisampleAvailable) { res.setSampleBuffers(glXGetFBConfig(display, fbcfg, GLX.GLX_SAMPLE_BUFFERS, tmp, 0) != 0); res.setNumSamples (glXGetFBConfig(display, fbcfg, GLX.GLX_SAMPLES, tmp, 0)); @@ -342,7 +342,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.setPbufferFloatingPointBuffers(glXGetFBConfig(display, fbcfg, GLXExt.GLX_FLOAT_COMPONENTS_NV, tmp, 0) != GL.GL_FALSE); } catch (Exception e) {} - return (X11GLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, drawableTypeBits); + return (X11GLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } private static String glXGetFBConfigErrorCode(int err) { @@ -462,7 +462,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.setAccumBlueBits (glXGetConfig(display, info, GLX.GLX_ACCUM_BLUE_SIZE, tmp, 0)); res.setAccumAlphaBits(glXGetConfig(display, info, GLX.GLX_ACCUM_ALPHA_SIZE, tmp, 0)); - return (X11GLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, drawableTypeBits); + return (X11GLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } private static String glXGetConfigErrorCode(int err) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java index 8086cd26a..431706e24 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -129,9 +129,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } final X11GraphicsScreen sharedScreen = (X11GraphicsScreen) sharedResource.getScreen(); final boolean isMultisampleAvailable = factory.isGLXMultisampleAvailable(sharedScreen.getDevice()); - final X11GLXDrawable sharedDrawable = (X11GLXDrawable) sharedResource.getDrawable(); - final GLCapabilitiesImmutable capsChosen = sharedDrawable.getChosenGLCapabilities(); - final GLProfile glp = capsChosen.getGLProfile(); + final GLProfile glp = GLProfile.getDefault(device); List availableCaps = null; @@ -217,7 +215,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(x11Device, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(x11Device) ); - boolean usePBuffer = capsChosen.isPBuffer(); + boolean usePBuffer = !capsChosen.isOnscreen() && capsChosen.isPBuffer(); X11GLXGraphicsConfiguration res = null; if( factory.isGLXVersionGreaterEqualOneThree(x11Device) ) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java index e1fe2f27e..bba2b3513 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java @@ -81,10 +81,11 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { } private void createPbuffer() { - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration(); - AbstractGraphicsScreen aScreen = config.getScreen(); - AbstractGraphicsDevice aDevice = aScreen.getDevice(); - long display = aDevice.getHandle(); + final MutableSurface ms = (MutableSurface) getNativeSurface(); + final X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) ms.getGraphicsConfiguration(); + final AbstractGraphicsScreen aScreen = config.getScreen(); + final AbstractGraphicsDevice aDevice = aScreen.getDevice(); + final long display = aDevice.getHandle(); if (DEBUG) { System.out.println("Pbuffer config: " + config); @@ -94,8 +95,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { throw new GLException("Null display"); } - NativeSurface ns = getNativeSurface(); - GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); if (chosenCaps.getPbufferRenderToTexture()) { @@ -111,9 +110,9 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { int[] iattributes = new int[7]; iattributes[niattribs++] = GLX.GLX_PBUFFER_WIDTH; - iattributes[niattribs++] = ns.getWidth(); + iattributes[niattribs++] = ms.getWidth(); iattributes[niattribs++] = GLX.GLX_PBUFFER_HEIGHT; - iattributes[niattribs++] = ns.getHeight(); + iattributes[niattribs++] = ms.getHeight(); iattributes[niattribs++] = GLX.GLX_LARGEST_PBUFFER; // exact iattributes[niattribs++] = 0; iattributes[niattribs++] = 0; @@ -125,7 +124,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { } // Set up instance variables - ((MutableSurface)ns).setSurfaceHandle(pbuffer); + ms.setSurfaceHandle(pbuffer); if (DEBUG) { System.err.println("Created pbuffer " + this); diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m new file mode 100644 index 000000000..63323b76d --- /dev/null +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -0,0 +1,665 @@ +#import "MacOSXWindowSystemInterface.h" +#import +#import +#include "timespec.h" + +// +// CADisplayLink only available on iOS >= 3.1, sad, since it's convenient. +// Use CVDisplayLink otherwise. +// +// #define HAS_CADisplayLink 1 +// + +// lock/sync debug output +// +// #define DBG_SYNC 1 +// +#ifdef DBG_SYNC + // #define SYNC_PRINT(...) NSLog(@ ## __VA_ARGS__) + #define SYNC_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) +#else + #define SYNC_PRINT(...) +#endif + +// fps debug output +// +// #define DBG_PERF 1 + +@interface MyNSOpenGLLayer: NSOpenGLLayer +{ +@private + GLfloat gl_texCoords[8]; + +@protected + NSOpenGLContext* parentCtx; + NSOpenGLPixelFormat* parentPixelFmt; + volatile NSOpenGLPixelBuffer* pbuffer; + volatile GLuint textureID; + volatile int texWidth; + volatile int texHeight; +#ifdef HAS_CADisplayLink + CADisplayLink* displayLink; +#else + CVDisplayLinkRef displayLink; +#endif + int tc; + struct timespec tStart; +@public + struct timespec lastWaitTime; + GLint swapInterval; + GLint swapIntervalCounter; + pthread_mutex_t renderLock; + pthread_cond_t renderSignal; + volatile Bool shallDraw; + volatile int newTexWidth; + volatile int newTexHeight; +} + +- (id) setupWithContext: (NSOpenGLContext*) parentCtx + pixelFormat: (NSOpenGLPixelFormat*) pfmt + pbuffer: (NSOpenGLPixelBuffer*) p + texIDArg: (GLuint) texID + opaque: (Bool) opaque + texWidth: (int) texWidth + texHeight: (int) texHeight; + +- (Bool) validateTexSizeWithNewSize; +- (Bool) validateTexSize: (int) _texWidth texHeight: (int) _texHeight; +- (void) setTextureID: (int) _texID; + +- (void) validatePBuffer: (NSOpenGLPixelBuffer*) p; + +- (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat; +- (void)disableAnimation; +- (void)pauseAnimation:(Bool)pause; +- (void)deallocPBuffer; +- (void)releaseLayer; +- (void)dealloc; +- (void)setSwapInterval:(int)interval; +- (void)tick; +- (void)waitUntilRenderSignal: (long) to_micros; +- (Bool)isGLSourceValid; + +@end + +#ifndef HAS_CADisplayLink + +static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink, + const CVTimeStamp *inNow, + const CVTimeStamp *inOutputTime, + CVOptionFlags flagsIn, + CVOptionFlags *flagsOut, + void *displayLinkContext) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*)displayLinkContext; + pthread_mutex_lock(&l->renderLock); + if( 0 < l->swapInterval ) { + l->swapIntervalCounter++; + if( l->swapIntervalCounter >= l->swapInterval ) { + SYNC_PRINT("", (int)l->swapIntervalCounter, l->swapInterval); + l->swapIntervalCounter = 0; + pthread_cond_signal(&l->renderSignal); // wake up vsync + } + } + pthread_mutex_unlock(&l->renderLock); + [pool release]; + return kCVReturnSuccess; +} + +#endif + +static const GLfloat gl_verts[] = { + -1.0, -1.0, + -1.0, 1.0, + 1.0, 1.0, + 1.0, -1.0 +}; + +@implementation MyNSOpenGLLayer + +- (id) setupWithContext: (NSOpenGLContext*) _parentCtx + pixelFormat: (NSOpenGLPixelFormat*) _parentPixelFmt + pbuffer: (NSOpenGLPixelBuffer*) p + texIDArg: (GLuint) texID + opaque: (Bool) opaque + texWidth: (int) _texWidth + texHeight: (int) _texHeight; +{ + pthread_mutexattr_t renderLockAttr; + pthread_mutexattr_init(&renderLockAttr); + pthread_mutexattr_settype(&renderLockAttr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&renderLock, &renderLockAttr); // recursive + pthread_cond_init(&renderSignal, NULL); // no attribute + + { + int i; + for(i=0; i<8; i++) { + gl_texCoords[i] = 0.0f; + } + } + parentCtx = _parentCtx; + parentPixelFmt = _parentPixelFmt; + swapInterval = 1; // defaults to on (as w/ new GL profiles) + swapIntervalCounter = 0; + timespec_now(&lastWaitTime); + shallDraw = NO; + newTexWidth = _texWidth; + newTexHeight = _texHeight; + [self validateTexSizeWithNewSize]; + [self setTextureID: texID]; + + pbuffer = p; + if(NULL != pbuffer) { + [pbuffer retain]; + } + + { + // no animations for add/remove/swap sublayers etc + // doesn't work: [self removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] + [self removeAllAnimations]; + } + + // instantiate a deactivated displayLink +#ifdef HAS_CADisplayLink + displayLink = [[CVDisplayLink displayLinkWithTarget:self selector:@selector(setNeedsDisplay)] retain]; +#else + CVReturn cvres; + { + int allDisplaysMask = 0; + int virtualScreen, accelerated, displayMask; + for (virtualScreen = 0; virtualScreen < [parentPixelFmt numberOfVirtualScreens]; virtualScreen++) { + [parentPixelFmt getValues:&displayMask forAttribute:NSOpenGLPFAScreenMask forVirtualScreen:virtualScreen]; + [parentPixelFmt getValues:&accelerated forAttribute:NSOpenGLPFAAccelerated forVirtualScreen:virtualScreen]; + if (accelerated) { + allDisplaysMask |= displayMask; + } + } + cvres = CVDisplayLinkCreateWithOpenGLDisplayMask(allDisplaysMask, &displayLink); + if(kCVReturnSuccess != cvres) { + DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkCreateWithOpenGLDisplayMask %X failed: %d\n", self, allDisplaysMask, cvres); + displayLink = NULL; + } + } + if(NULL != displayLink) { + cvres = CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, [parentCtx CGLContextObj], [parentPixelFmt CGLPixelFormatObj]); + if(kCVReturnSuccess != cvres) { + DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext failed: %d\n", self, cvres); + displayLink = NULL; + } + } + if(NULL != displayLink) { + cvres = CVDisplayLinkSetOutputCallback(displayLink, renderMyNSOpenGLLayer, self); + if(kCVReturnSuccess != cvres) { + DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetOutputCallback failed: %d\n", self, cvres); + displayLink = NULL; + } + } +#endif + [self pauseAnimation: YES]; + + [self removeAllAnimations]; + [self setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; + [self setNeedsDisplayOnBoundsChange: YES]; + + [self setOpaque: opaque ? YES : NO]; + + if(NULL != pbuffer) { + DBG_PRINT("MyNSOpenGLLayer::init (pbuffer) %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, pbuffer %dx%d -> tex %dx%d, bounds: %lf/%lf %lfx%lf (refcnt %d)\n", + self, parentCtx, parentPixelFmt, pbuffer, opaque, [pbuffer pixelsWide], [pbuffer pixelsHigh], texWidth, texHeight, + lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]); + } else { + DBG_PRINT("MyNSOpenGLLayer::init (texture) %p, ctx %p, pfmt %p, opaque %d, tex[id %d, %dx%d], bounds: %lf/%lf %lfx%lf (refcnt %d)\n", + self, parentCtx, parentPixelFmt, opaque, (int)textureID, texWidth, texHeight, + lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]); + } + return self; +} + +- (Bool) validateTexSizeWithNewSize +{ + return [self validateTexSize: newTexWidth texHeight: newTexHeight]; +} + +- (Bool) validateTexSize: (int) _texWidth texHeight: (int) _texHeight +{ + if(_texHeight != texHeight || _texWidth != texWidth) { + texWidth = _texWidth; + texHeight = _texHeight; + CGRect lRect = [self bounds]; + lRect.origin.x = 0; + lRect.origin.y = 0; + lRect.size.width = texWidth; + lRect.size.height = texHeight; + [self setFrame: lRect]; + + GLfloat texCoordWidth, texCoordHeight; + if(NULL != pbuffer) { + GLenum textureTarget = [pbuffer textureTarget] ; + GLsizei pwidth = [pbuffer pixelsWide]; + GLsizei pheight = [pbuffer pixelsHigh]; + if( GL_TEXTURE_2D == textureTarget ) { + texCoordWidth = (GLfloat)pwidth /(GLfloat)texWidth ; + texCoordHeight = (GLfloat)pheight/(GLfloat)texHeight ; + } else { + texCoordWidth = pwidth; + texCoordHeight = pheight; + } + } else { + texCoordWidth = (GLfloat)1.0f; + texCoordHeight = (GLfloat)1.0f; + } + gl_texCoords[3] = texCoordHeight; + gl_texCoords[5] = texCoordHeight; + gl_texCoords[4] = texCoordWidth; + gl_texCoords[6] = texCoordWidth; + return YES; + } else { + return NO; + } +} + +- (void) setTextureID: (int) _texID +{ + textureID = _texID; +} + +- (void) validatePBuffer: (NSOpenGLPixelBuffer*) p +{ + if( pbuffer != p ) { + DBG_PRINT("MyNSOpenGLLayer::validatePBuffer.0 %p, pbuffer %p, (refcnt %d)\n", self, p, (int)[self retainCount]); + + SYNC_PRINT("{PB-nil}"); + + [self deallocPBuffer]; + + pbuffer = p; + if(NULL != pbuffer) { + [pbuffer retain]; + } + [self setTextureID: 0]; + + shallDraw = NO; + } +} + +/** +- (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask +{ + DBG_PRINT("MyNSOpenGLLayer::openGLPixelFormatForDisplayMask: %p (refcnt %d) - parent-pfmt %p -> new-pfmt %p\n", + self, (int)[self retainCount], parentPixelFmt, parentPixelFmt); + return parentPixelFmt; +} */ + +- (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat +{ + NSOpenGLContext * nctx = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:parentCtx]; + DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat: %p (refcnt %d) - pfmt %p, parent %p -> new-ctx %p\n", + self, (int)[self retainCount], pixelFormat, parentCtx, nctx); + return nctx; +} + +- (void)disableAnimation +{ + DBG_PRINT("MyNSOpenGLLayer::disableAnimation: %p (refcnt %d) - displayLink %p\n", self, (int)[self retainCount], displayLink); + pthread_mutex_lock(&renderLock); + [self setAsynchronous: NO]; + if(NULL != displayLink) { +#ifdef HAS_CADisplayLink + [displayLink setPaused: YES]; + [displayLink release]; +#else + CVDisplayLinkStop(displayLink); + CVDisplayLinkRelease(displayLink); +#endif + displayLink = NULL; + } + pthread_mutex_unlock(&renderLock); +} + +- (void)deallocPBuffer +{ + if(NULL != pbuffer) { + NSOpenGLContext* context = [self openGLContext]; + if(NULL!=context) { + [context makeCurrentContext]; + + DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (with ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)texureID); + + if( 0 != textureID ) { + glDeleteTextures(1, &textureID); + } + [pbuffer release]; + + [context clearDrawable]; + } else { + DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (w/o ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)texureID); + } + pbuffer = NULL; + [self setTextureID: 0]; + } +} + +- (void)releaseLayer +{ + DBG_PRINT("MyNSOpenGLLayer::releaseLayer.0: %p (refcnt %d)\n", self, (int)[self retainCount]); + pthread_mutex_lock(&renderLock); + [self disableAnimation]; + [self deallocPBuffer]; + [self release]; + DBG_PRINT("MyNSOpenGLLayer::releaseLayer.X: %p (refcnt %d)\n", self, (int)[self retainCount]); + pthread_mutex_unlock(&renderLock); +} + +- (void)dealloc +{ + DBG_PRINT("MyNSOpenGLLayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]); + // NSLog(@"MyNSOpenGLLayer::dealloc: %@",[NSThread callStackSymbols]); + + pthread_mutex_lock(&renderLock); + [self disableAnimation]; + [self deallocPBuffer]; + pthread_mutex_unlock(&renderLock); + pthread_cond_destroy(&renderSignal); + pthread_mutex_destroy(&renderLock); + [super dealloc]; + DBG_PRINT("MyNSOpenGLLayer::dealloc.X %p\n", self); +} + +- (Bool)isGLSourceValid +{ + return NULL != pbuffer || 0 != textureID ; +} + +- (void)resizeWithOldSuperlayerSize:(CGSize)size + { + CGRect lRectS = [[self superlayer] bounds]; + + DBG_PRINT("MyNSOpenGLLayer::resizeWithOldSuperlayerSize: %p, texSize %dx%d, bounds: %lfx%lf -> %lfx%lf (refcnt %d)\n", + self, texWidth, texHeight, size.width, size.height, lRectS.size.width, lRectS.size.height, (int)[self retainCount]); + + newTexWidth = lRectS.size.width; + newTexHeight = lRectS.size.height; + shallDraw = YES; + SYNC_PRINT("", newTexWidth, newTexHeight); + + [super resizeWithOldSuperlayerSize: size]; +} + +- (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat + forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp +{ + SYNC_PRINT("", (int)shallDraw); + return shallDraw; +} + +- (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat + forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp +{ + pthread_mutex_unlock(&renderLock); + SYNC_PRINT("<* "); + // NSLog(@"MyNSOpenGLLayer::DRAW: %@",[NSThread callStackSymbols]); + + if( shallDraw && ( NULL != pbuffer || 0 != textureID ) ) { + [context makeCurrentContext]; + + GLenum textureTarget; + + Bool texSizeChanged = [self validateTexSizeWithNewSize]; + + if( NULL != pbuffer ) { + if( texSizeChanged && 0 != textureID ) { + glDeleteTextures(1, &textureID); + [self setTextureID: 0]; + } + textureTarget = [pbuffer textureTarget]; + if( 0 == textureID ) { + glGenTextures(1, &textureID); + glBindTexture(textureTarget, textureID); + glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } else { + glBindTexture(textureTarget, textureID); + } + [context setTextureImageToPixelBuffer: pbuffer colorBuffer: GL_FRONT]; + } else { + textureTarget = GL_TEXTURE_2D; + glBindTexture(textureTarget, textureID); + } + SYNC_PRINT(" %d*>", (int)textureID); + + glEnable(textureTarget); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, gl_verts); + glTexCoordPointer(2, GL_FLOAT, 0, gl_texCoords); + + glDrawArrays(GL_QUADS, 0, 4); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + + glDisable(textureTarget); + glBindTexture(textureTarget, 0); + + [context clearDrawable]; + + [super drawInOpenGLContext: context pixelFormat: pixelFormat forLayerTime: timeInterval displayTime: timeStamp]; + + } else { + // glClear(GL_COLOR_BUFFER_BIT); + // glBlitFramebuffer(0, 0, texWidth, texHeight, + // 0, 0, texWidth, texHeight, + // GL_COLOR_BUFFER_BIT, GL_NEAREST); + SYNC_PRINT(" 0*>"); + } + + #ifdef DBG_PERF + [self tick]; + #endif + shallDraw = NO; + + if( 0 >= swapInterval ) { + pthread_cond_signal(&renderSignal); // wake up !vsync + SYNC_PRINT(""); + } + SYNC_PRINT("<$>\n"); + pthread_mutex_unlock(&renderLock); +} + +- (void)pauseAnimation:(Bool)pause +{ + DBG_PRINT("MyNSOpenGLLayer::pauseAnimation: %d\n", (int)pause); + [self setAsynchronous: NO]; + if(pause) { + if(NULL != displayLink) { + #ifdef HAS_CADisplayLink + [displayLink setPaused: YES]; + #else + CVDisplayLinkStop(displayLink); + #endif + } + } else { + if(NULL != displayLink) { + #ifdef HAS_CADisplayLink + [displayLink setPaused: NO]; + [displayLink setFrameInterval: swapInterval]; + #else + CVDisplayLinkStart(displayLink); + #endif + } + } + tc = 0; + timespec_now(&tStart); +} + +- (void)setSwapInterval:(int)interval +{ + /** + * v-sync doesn't works w/ NSOpenGLLayer's context .. well :( + * Using CVDisplayLink .. see setSwapInterval() below. + * + GLint si; + [context getValues: &si forParameter: NSOpenGLCPSwapInterval]; + if(si != swapInterval) { + DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p setSwapInterval: %d -> %d\n", self, si, swapInterval); + [context setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval]; + } + */ + + pthread_mutex_lock(&renderLock); + DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.0: %d - displayLink %p\n", interval, displayLink); + swapInterval = interval; + swapIntervalCounter = 0; + pthread_mutex_unlock(&renderLock); + + if(0 < swapInterval) { + [self pauseAnimation: NO]; + } else { + [self pauseAnimation: YES]; + } + DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.X: %d\n", interval); +} + +-(void)tick +{ + tc++; + if(tc%60==0) { + struct timespec t1, td; + timespec_now(&t1); + timespec_subtract(&td, &t1, &tStart); + long td_ms = timespec_milliseconds(&td); + fprintf(stderr, "NSOpenGLLayer: %ld ms / %d frames, %ld ms / frame, %f fps\n", + td_ms, tc, td_ms/tc, (tc * 1000.0) / (float)td_ms ); + fflush(NULL); + } +} + +- (void)waitUntilRenderSignal: (long) to_micros +{ + BOOL ready = NO; + int wr = 0; + pthread_mutex_lock(&renderLock); + SYNC_PRINT("{W %ld us", to_micros); + do { + if(0 >= swapInterval) { + ready = YES; + } + if(NO == ready) { + #ifdef DBG_SYNC + struct timespec t0, t1, td, td2; + timespec_now(&t0); + #endif + if(0 < to_micros) { + struct timespec to_abs = lastWaitTime; + timespec_addmicros(&to_abs, to_micros); + #ifdef DBG_SYNC + timespec_subtract(&td, &to_abs, &t0); + fprintf(stderr, ", (%ld) / ", timespec_milliseconds(&td)); + #endif + wr = pthread_cond_timedwait(&renderSignal, &renderLock, &to_abs); + #ifdef DBG_SYNC + timespec_now(&t1); + timespec_subtract(&td, &t1, &t0); + timespec_subtract(&td2, &t1, &lastWaitTime); + fprintf(stderr, "(%ld) / (%ld) ms", timespec_milliseconds(&td), timespec_milliseconds(&td2)); + #endif + } else { + pthread_cond_wait (&renderSignal, &renderLock); + #ifdef DBG_SYNC + timespec_now(&t1); + timespec_subtract(&td, &t1, &t0); + timespec_subtract(&td2, &t1, &lastWaitTime); + fprintf(stderr, "(%ld) / (%ld) ms", timespec_milliseconds(&td), timespec_milliseconds(&td2)); + #endif + } + ready = YES; + } + } while (NO == ready && 0 == wr) ; + SYNC_PRINT("-%d-%d-%d}", shallDraw, wr, ready); + timespec_now(&lastWaitTime); + pthread_mutex_unlock(&renderLock); +} + +@end + +NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, uint32_t texID, Bool opaque, int texWidth, int texHeight) { + // This simply crashes after dealloc() has been called .. ie. ref-count -> 0 too early ? + // However using alloc/init, actual dealloc happens at JAWT destruction, hence too later IMHO. + // return [[MyNSOpenGLLayer layer] setupWithContext:ctx pixelFormat: fmt pbuffer: p texIDArg: (GLuint)texID + // opaque: opaque texWidth: texWidth texHeight: texHeight]; + + return [[[MyNSOpenGLLayer alloc] init] setupWithContext:ctx pixelFormat: fmt pbuffer: p texIDArg: (GLuint)texID + opaque: opaque texWidth: texWidth texHeight: texHeight]; +} + +void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval) { + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + [l setSwapInterval: interval]; + [pool release]; +} + +void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_micros) { + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + [l waitUntilRenderSignal: to_micros]; + [pool release]; +} + +void flushNSOpenGLLayerPBuffer(NSOpenGLLayer* layer) { + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + pthread_mutex_lock(&l->renderLock); + [l validatePBuffer:0]; + pthread_mutex_unlock(&l->renderLock); + + [pool release]; +} + +void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* layer, NSOpenGLPixelBuffer* p, uint32_t texID, int texWidth, int texHeight) { + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + Bool shallDraw; + + pthread_mutex_lock(&l->renderLock); + [l validatePBuffer:p]; + // l->newTexWidth = texWidth; + // l->newTexHeight = texHeight; + [l setTextureID: texID]; + shallDraw = [l isGLSourceValid]; + l->shallDraw = shallDraw; + pthread_mutex_unlock(&l->renderLock); + + SYNC_PRINT("", texWidth, texHeight, l->newTexWidth, l->newTexHeight, (int)shallDraw); + if(shallDraw) { + if ( [NSThread isMainThread] == YES ) { + [l setNeedsDisplay]; + } else { + // don't wait - using doublebuffering + [l performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO]; + } + } + // DBG_PRINT("MyNSOpenGLLayer::setNSOpenGLLayerNeedsDisplay %p\n", l); + [pool release]; +} + +void releaseNSOpenGLLayer(NSOpenGLLayer* layer) { + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.0: %p\n", l); + + if ( [NSThread isMainThread] == YES ) { + [l releaseLayer]; + } else { + [l performSelectorOnMainThread:@selector(releaseLayer) withObject:nil waitUntilDone:NO]; + } + + DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.X: %p\n", l); + [pool release]; +} + diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m deleted file mode 100644 index b81b43e54..000000000 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m +++ /dev/null @@ -1,494 +0,0 @@ -#import "MacOSXWindowSystemInterface.h" -#import -#import -#include "timespec.h" - -// -// CADisplayLink only available on iOS >= 3.1, sad, since it's convenient. -// Use CVDisplayLink otherwise. -// -// #define HAS_CADisplayLink 1 -// - -// lock/sync debug output -// -// #define DBG_SYNC 1 -// -#ifdef DBG_SYNC - // #define SYNC_PRINT(...) NSLog(@ ## __VA_ARGS__) - #define SYNC_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) -#else - #define SYNC_PRINT(...) -#endif - -// fps debug output -// -// #define DBG_PERF 1 - -@interface MyNSOpenGLLayer: NSOpenGLLayer -{ -@protected - NSOpenGLPixelBuffer* pbuffer; - int texWidth; - int texHeight; - GLuint textureID; -#ifdef HAS_CADisplayLink - CADisplayLink* displayLink; -#else - CVDisplayLinkRef displayLink; -#endif - int tc; - struct timespec t0; -@public - struct timespec lastWaitTime; - GLint swapInterval; - GLint swapIntervalCounter; - pthread_mutex_t renderLock; - pthread_cond_t renderSignal; - BOOL shallDraw; -} - -- (id) setupWithContext: (NSOpenGLContext*) ctx - pixelFormat: (NSOpenGLPixelFormat*) pfmt - pbuffer: (NSOpenGLPixelBuffer*) p - opaque: (Bool) opaque - texWidth: (int) texWidth - texHeight: (int) texHeight; - -- (void)deallocTex; -- (void)disableAnimation; -- (void)releaseLayer; -- (void)dealloc; -- (int)getSwapInterval; -- (void)setSwapInterval:(int)interval; -- (void)tick; - -@end - -#ifndef HAS_CADisplayLink - -static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink, - const CVTimeStamp *inNow, - const CVTimeStamp *inOutputTime, - CVOptionFlags flagsIn, - CVOptionFlags *flagsOut, - void *displayLinkContext) -{ - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*)displayLinkContext; - pthread_mutex_lock(&l->renderLock); - #ifdef DBG_PERF - [l tick]; - #endif - if(0 < l->swapInterval) { - l->swapIntervalCounter++; - if(l->swapIntervalCounter>=l->swapInterval) { - l->swapIntervalCounter = 0; - pthread_cond_signal(&l->renderSignal); - SYNC_PRINT("S"); - } - } - pthread_mutex_unlock(&l->renderLock); - [pool release]; - return kCVReturnSuccess; -} - -#endif - -@implementation MyNSOpenGLLayer - -- (id) setupWithContext: (NSOpenGLContext*) _ctx - pixelFormat: (NSOpenGLPixelFormat*) _fmt - pbuffer: (NSOpenGLPixelBuffer*) p - opaque: (Bool) opaque - texWidth: (int) _texWidth - texHeight: (int) _texHeight; -{ - pthread_mutexattr_t renderLockAttr; - pthread_mutexattr_init(&renderLockAttr); - pthread_mutexattr_settype(&renderLockAttr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&renderLock, &renderLockAttr); // recursive - pthread_cond_init(&renderSignal, NULL); // no attribute - - textureID = 0; - swapInterval = 1; // defaults to on (as w/ new GL profiles) - swapIntervalCounter = 0; - timespec_now(&lastWaitTime); - shallDraw = NO; - texWidth = _texWidth; - texHeight = _texHeight; - pbuffer = p; - [pbuffer retain]; - - { - CGRect lRect = CGRectMake(0, 0, texWidth, texHeight); - [self setFrame:lRect]; - - // no animations for add/remove/swap sublayers etc - // doesn't work: [self removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] - [self removeAllAnimations]; - } - - // instantiate a deactivated displayLink -#ifdef HAS_CADisplayLink - displayLink = [[CVDisplayLink displayLinkWithTarget:self selector:@selector(setNeedsDisplay)] retain]; - [displayLink setPaused: YES]; -#else - CVReturn cvres; - { - int allDisplaysMask = 0; - int virtualScreen, accelerated, displayMask; - for (virtualScreen = 0; virtualScreen < [_fmt numberOfVirtualScreens]; virtualScreen++) { - [_fmt getValues:&displayMask forAttribute:NSOpenGLPFAScreenMask forVirtualScreen:virtualScreen]; - [_fmt getValues:&accelerated forAttribute:NSOpenGLPFAAccelerated forVirtualScreen:virtualScreen]; - if (accelerated) { - allDisplaysMask |= displayMask; - } - } - cvres = CVDisplayLinkCreateWithOpenGLDisplayMask(allDisplaysMask, &displayLink); - if(kCVReturnSuccess != cvres) { - DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkCreateWithOpenGLDisplayMask %X failed: %d\n", self, allDisplaysMask, cvres); - displayLink = NULL; - } - } - if(NULL != displayLink) { - cvres = CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, [_ctx CGLContextObj], [_fmt CGLPixelFormatObj]); - if(kCVReturnSuccess != cvres) { - DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext failed: %d\n", self, cvres); - displayLink = NULL; - } - } - if(NULL != displayLink) { - cvres = CVDisplayLinkSetOutputCallback(displayLink, renderMyNSOpenGLLayer, self); - if(kCVReturnSuccess != cvres) { - DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetOutputCallback failed: %d\n", self, cvres); - displayLink = NULL; - } - } - if(NULL != displayLink) { - CVDisplayLinkStop(displayLink); - } -#endif - [self setAsynchronous: YES]; - - [self setNeedsDisplayOnBoundsChange: YES]; - - [self setOpaque: opaque ? YES : NO]; - - CGRect lRect = [self frame]; - DBG_PRINT("MyNSOpenGLLayer::init %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, pbuffer %dx%d -> tex %dx%d, frame: %lf/%lf %lfx%lf (refcnt %d)\n", - self, _ctx, _fmt, pbuffer, opaque, [pbuffer pixelsWide], [pbuffer pixelsHigh], texWidth, texHeight, - lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]); - return self; -} - -- (void)disableAnimation -{ - DBG_PRINT("MyNSOpenGLLayer::disableAnimation: %p (refcnt %d) - displayLink %p\n", self, (int)[self retainCount], displayLink); - pthread_mutex_lock(&renderLock); - [self setAsynchronous: NO]; - if(NULL != displayLink) { -#ifdef HAS_CADisplayLink - [displayLink setPaused: YES]; - [displayLink release]; -#else - CVDisplayLinkStop(displayLink); - CVDisplayLinkRelease(displayLink); -#endif - displayLink = NULL; - } - pthread_mutex_unlock(&renderLock); -} - -- (void)deallocTex -{ - pthread_mutex_lock(&renderLock); - NSOpenGLContext* context = [self openGLContext]; - DBG_PRINT("MyNSOpenGLLayer::deallocTex %p (refcnt %d) - context %p, pbuffer %p\n", self, (int)[self retainCount], context, pbuffer); - if(NULL != pbuffer) { - if(NULL!=context) { - [context makeCurrentContext]; - if(0 != textureID) { - glDeleteTextures(1, &textureID); - textureID = 0; - } - [context clearDrawable]; - } - [pbuffer release]; - pbuffer = NULL; - } - pthread_mutex_unlock(&renderLock); -} - -- (void)releaseLayer -{ - DBG_PRINT("MyNSOpenGLLayer::releaseLayer.0: %p (refcnt %d)\n", self, (int)[self retainCount]); - pthread_mutex_lock(&renderLock); - [self disableAnimation]; - [self deallocTex]; - [self release]; - DBG_PRINT("MyNSOpenGLLayer::releaseLayer.X: %p (refcnt %d)\n", self, (int)[self retainCount]); - pthread_mutex_unlock(&renderLock); -} - -- (void)dealloc -{ - DBG_PRINT("MyNSOpenGLLayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]); - // NSLog(@"MyNSOpenGLLayer::dealloc: %@",[NSThread callStackSymbols]); - - [self disableAnimation]; - [self deallocTex]; - pthread_cond_destroy(&renderSignal); - pthread_mutex_destroy(&renderLock); - [super dealloc]; - DBG_PRINT("MyNSOpenGLLayer::dealloc.X %p\n", self); -} - -- (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat - forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp -{ - // assume both methods 'canDrawInOpenGLContext' and 'drawInOpenGLContext' - // are called from the same thread subsequently - pthread_mutex_lock(&renderLock); - Bool res = NULL != pbuffer && YES == shallDraw; - if(!res) { - SYNC_PRINT("0"); - pthread_mutex_unlock(&renderLock); - } else { - SYNC_PRINT("1"); - } - return res; -} - -- (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat - forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp -{ - [context makeCurrentContext]; - - GLenum textureTarget = [pbuffer textureTarget]; - GLfloat texCoordWidth, texCoordHeight; - { - GLsizei pwidth = [pbuffer pixelsWide]; - GLsizei pheight = [pbuffer pixelsHigh]; - texCoordWidth = textureTarget == GL_TEXTURE_2D ? (GLfloat)pwidth /(GLfloat)texWidth : pwidth; - texCoordHeight = textureTarget == GL_TEXTURE_2D ? (GLfloat)pheight/(GLfloat)texHeight : pheight; - } - Bool texCreated = 0 == textureID; - - if(texCreated) { - glGenTextures(1, &textureID); - - CGRect lRect = [self frame]; - DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p, pbuffer %p %dx%d -> tex %dx%d [%fx%f] id 0x%X target 0x%X, frame: %lf/%lf %lfx%lf (refcnt %d)\n", - self, pbuffer, [pbuffer pixelsWide], [pbuffer pixelsHigh], texWidth, texHeight, texCoordWidth, texCoordHeight, textureID, textureTarget, - lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]); - } - - glBindTexture(textureTarget, textureID); - - /** - if(texCreated) { - // proper tex size setup - glTexImage2D(textureTarget, 0, GL_RGB, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); - } */ - - [context setTextureImageToPixelBuffer: pbuffer colorBuffer: GL_FRONT]; - - glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glEnable(textureTarget); - - static GLfloat verts[] = { - -1.0, -1.0, - -1.0, 1.0, - 1.0, 1.0, - 1.0, -1.0 - }; - - GLfloat tex[] = { - 0.0, 0.0, - 0.0, texCoordHeight, - texCoordWidth, texCoordHeight, - texCoordWidth, 0.0 - }; - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, verts); - glTexCoordPointer(2, GL_FLOAT, 0, tex); - - glDrawArrays(GL_QUADS, 0, 4); - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - - glDisable(textureTarget); - glBindTexture(textureTarget, 0); - - [super drawInOpenGLContext: context pixelFormat: pixelFormat forLayerTime: timeInterval displayTime: timeStamp]; - shallDraw = NO; - if(0 >= swapInterval) { - pthread_cond_signal(&renderSignal); // just to wake up - SYNC_PRINT("s"); - } - SYNC_PRINT("$"); - pthread_mutex_unlock(&renderLock); -} - -- (int)getSwapInterval -{ - return swapInterval; -} - -- (void)setSwapInterval:(int)interval -{ - /** - * v-sync doesn't works w/ NSOpenGLLayer's context .. well :( - * Using CVDisplayLink .. see setSwapInterval() below. - * - GLint si; - [context getValues: &si forParameter: NSOpenGLCPSwapInterval]; - if(si != swapInterval) { - DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p setSwapInterval: %d -> %d\n", self, si, swapInterval); - [context setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval]; - } - } */ - - pthread_mutex_lock(&renderLock); - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.0: %d - displayLink %p\n", interval, displayLink); - swapInterval = interval; - swapIntervalCounter = 0; - pthread_mutex_unlock(&renderLock); - - if(NULL!=displayLink) { - if(0 < swapInterval) { - tc = 0; - timespec_now(&t0); - - [self setAsynchronous: NO]; - #ifdef HAS_CADisplayLink - [displayLink setPaused: NO]; - [displayLink setFrameInterval: interval]; - #else - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.1.b.1\n"); - CVDisplayLinkStart(displayLink); - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.1.b.X\n"); - #endif - } else { - #ifdef HAS_CADisplayLink - [displayLink setPaused: YES]; - #else - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.0.b.1\n"); - CVDisplayLinkStop(displayLink); - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.0.b.X\n"); - #endif - [self setAsynchronous: YES]; - } - } - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.X: %d\n", interval); -} - --(void)tick -{ - tc++; - if(tc%60==0) { - struct timespec t1, td; - timespec_now(&t1); - timespec_subtract(&td, &t1, &t0); - long td_ms = timespec_milliseconds(&td); - fprintf(stderr, "NSOpenGLLayer: %ld ms / %d frames, %ld ms / frame, %f fps\n", - td_ms, tc, td_ms/tc, (tc * 1000.0) / (float)td_ms ); - fflush(NULL); - } -} - -@end - -NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, Bool opaque, int texWidth, int texHeight) { - // This simply crashes after dealloc() has been called .. ie. ref-count -> 0 too early ? - // However using alloc/init, actual dealloc happens at JAWT destruction, hence too later IMHO. - // return [[MyNSOpenGLLayer layer] setupWithContext:ctx pixelFormat: fmt pbuffer: p opaque: opaque texWidth: texWidth texHeight: texHeight]; - - return [[[MyNSOpenGLLayer alloc] init] setupWithContext:ctx pixelFormat: fmt pbuffer: p opaque: opaque texWidth: texWidth texHeight: texHeight]; -} - -void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; - [l setSwapInterval: interval]; -} - -void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_micros) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; - BOOL ready = NO; - int wr = 0; - pthread_mutex_lock(&l->renderLock); - SYNC_PRINT("{"); - do { - if([l getSwapInterval] <= 0) { - ready = !l->shallDraw; - } - if(NO == ready) { - if(0 < to_micros) { - #ifdef DBG_SYNC - struct timespec t0, t1, td, td2; - timespec_now(&t0); - #endif - struct timespec to_abs = l->lastWaitTime; - timespec_addmicros(&to_abs, to_micros); - #ifdef DBG_SYNC - timespec_subtract(&td, &to_abs, &t0); - fprintf(stderr, "(%ld) / ", timespec_milliseconds(&td)); - #endif - wr = pthread_cond_timedwait(&l->renderSignal, &l->renderLock, &to_abs); - #ifdef DBG_SYNC - timespec_now(&t1); - timespec_subtract(&td, &t1, &t0); - timespec_subtract(&td2, &t1, &l->lastWaitTime); - fprintf(stderr, "(%ld) / (%ld) ms", timespec_milliseconds(&td), timespec_milliseconds(&td2)); - #endif - } else { - pthread_cond_wait (&l->renderSignal, &l->renderLock); - } - ready = !l->shallDraw; - } - } while (NO == ready && 0 == wr) ; - SYNC_PRINT("-%d}", ready); - timespec_now(&l->lastWaitTime); - pthread_mutex_unlock(&l->renderLock); -} - -void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* layer) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - pthread_mutex_lock(&l->renderLock); - l->shallDraw = YES; - if ( [NSThread isMainThread] == YES ) { - [l setNeedsDisplay]; - } else { - // can't wait, otherwise we may deadlock AWT - [l performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO]; - } - SYNC_PRINT("."); - pthread_mutex_unlock(&l->renderLock); - // DBG_PRINT("MyNSOpenGLLayer::setNSOpenGLLayerNeedsDisplay %p\n", l); - [pool release]; -} - -void releaseNSOpenGLLayer(NSOpenGLLayer* layer) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.0: %p\n", l); - - if ( [NSThread isMainThread] == YES ) { - [l releaseLayer]; - } else { - [l performSelectorOnMainThread:@selector(releaseLayer) withObject:nil waitUntilDone:NO]; - } - - DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.X: %p\n", l); - [pool release]; -} - diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m index f774f8f4a..becd41bb2 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m @@ -696,6 +696,11 @@ void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* [pool release]; } +Bool isNSOpenGLPixelBuffer(uint64_t object) { + NSObject *nsObj = (NSObject*) (intptr_t) object; + return [nsObj isMemberOfClass:[NSOpenGLPixelBuffer class]]; +} + #include Bool imagesInitialized = false; static char libGLStr[] = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"; @@ -746,38 +751,3 @@ void resetGammaRamp() { CGDisplayRestoreColorSyncSettings(); } -/*** - * The following static functions are copied out of NEWT's OSX impl. - * May need to push code to NativeWindow, to remove duplication. - */ -static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx) { - NSArray *screens = [NSScreen screens]; - if(screen_idx<0) screen_idx=0; - if(screen_idx>=[screens count]) screen_idx=0; - return (NSScreen *) [screens objectAtIndex: screen_idx]; -} -static CGDirectDisplayID NewtScreen_getCGDirectDisplayIDByNSScreen(NSScreen *screen) { - // Mind: typedef uint32_t CGDirectDisplayID; - however, we assume it's 64bit on 64bit ?! - NSDictionary * dict = [screen deviceDescription]; - NSNumber * val = (NSNumber *) [dict objectForKey: @"NSScreenNumber"]; - // [NSNumber integerValue] returns NSInteger which is 32 or 64 bit native size - return (CGDirectDisplayID) [val integerValue]; -} -static long GetDictionaryLong(CFDictionaryRef theDict, const void* key) -{ - long value = 0; - CFNumberRef numRef; - numRef = (CFNumberRef)CFDictionaryGetValue(theDict, key); - if (numRef != NULL) - CFNumberGetValue(numRef, kCFNumberLongType, &value); - return value; -} -#define CGDDGetModeRefreshRate(mode) GetDictionaryLong((mode), kCGDisplayRefreshRate) - -int getScreenRefreshRate(int scrn_idx) { - NSScreen *screen = NewtScreen_getNSScreenByIndex(scrn_idx); - CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen); - CFDictionaryRef mode = CGDisplayCurrentMode(display); - return CGDDGetModeRefreshRate(mode); -} - diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java new file mode 100644 index 000000000..22c95f3dd --- /dev/null +++ b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java @@ -0,0 +1,39 @@ +package com.jogamp.nativewindow; + +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +public class DelegatedUpstreamSurfaceHookMutableSize extends UpstreamSurfaceHookMutableSize { + final UpstreamSurfaceHook upstream; + + /** + * @param upstream optional upstream UpstreamSurfaceHook used for {@link #create(ProxySurface)} and {@link #destroy(ProxySurface)}. + * @param width initial width + * @param height initial height + */ + public DelegatedUpstreamSurfaceHookMutableSize(UpstreamSurfaceHook upstream, int width, int height) { + super(width, height); + this.upstream = upstream; + } + + @Override + public final void create(ProxySurface s) { + if(null != upstream) { + upstream.create(s); + } + } + + @Override + public final void destroy(ProxySurface s) { + if(null != upstream) { + upstream.destroy(s); + } + } + + @Override + public String toString() { + return getClass().getSimpleName()+"[ "+ width + "x" + height + ", " + upstream + "]"; + } + +} + diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java new file mode 100644 index 000000000..85e24582c --- /dev/null +++ b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java @@ -0,0 +1,54 @@ +package com.jogamp.nativewindow; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +public class DelegatedUpstreamSurfaceHookWithSurfaceSize implements UpstreamSurfaceHook { + final UpstreamSurfaceHook upstream; + final NativeSurface surface; + + /** + * @param upstream optional upstream UpstreamSurfaceHook used for {@link #create(ProxySurface)} and {@link #destroy(ProxySurface)}. + * @param surface mandatory {@link NativeSurface} used for {@link #getWidth(ProxySurface)} and {@link #getHeight(ProxySurface)} + */ + public DelegatedUpstreamSurfaceHookWithSurfaceSize(UpstreamSurfaceHook upstream, NativeSurface surface) { + this.upstream = upstream; + this.surface = surface; + if(null == surface) { + throw new IllegalArgumentException("given surface is null"); + } + } + + @Override + public final void create(ProxySurface s) { + if(null != upstream) { + upstream.create(s); + } + } + + @Override + public final void destroy(ProxySurface s) { + if(null != upstream) { + upstream.destroy(s); + } + } + + @Override + public final int getWidth(ProxySurface s) { + return surface.getWidth(); + } + + @Override + public final int getHeight(ProxySurface s) { + return surface.getHeight(); + } + + @Override + public String toString() { + final String us_s = null != surface ? ( surface.getClass().getName() + ": 0x" + Long.toHexString(surface.getSurfaceHandle()) + " " +surface.getWidth() + "x" + surface.getHeight() ) : "nil"; + return getClass().getSimpleName()+"["+upstream+", "+us_s+"]"; + } + +} + diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java new file mode 100644 index 000000000..29c540ac4 --- /dev/null +++ b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java @@ -0,0 +1,45 @@ +package com.jogamp.nativewindow; + +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +public class UpstreamSurfaceHookMutableSize implements UpstreamSurfaceHook.MutableSize { + int width, height; + + /** + * @param width initial width + * @param height initial height + */ + public UpstreamSurfaceHookMutableSize(int width, int height) { + this.width = width; + this.height = height; + } + + @Override + public final void setSize(int width, int height) { + this.width = width; + this.height = height; + } + + @Override + public final int getWidth(ProxySurface s) { + return width; + } + + @Override + public final int getHeight(ProxySurface s) { + return height; + } + @Override + public void create(ProxySurface s) { /* nop */ } + + @Override + public void destroy(ProxySurface s) { /* nop */ } + + @Override + public String toString() { + return getClass().getSimpleName()+"[ "+ width + "x" + height + "]"; + } + +} + diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java deleted file mode 100644 index b7f6ba45d..000000000 --- a/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.nativewindow; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.ProxySurface; - -public class WrappedSurface extends ProxySurface { - protected long surfaceHandle; - - public WrappedSurface(AbstractGraphicsConfiguration cfg, long handle, int initialWidth, int initialHeight, UpstreamSurfaceHook upstream) { - super(cfg, initialWidth, initialHeight, upstream); - surfaceHandle=handle; - } - - @Override - protected void invalidateImpl() { - surfaceHandle = 0; - } - - @Override - public final long getSurfaceHandle() { - return surfaceHandle; - } - - @Override - public final void setSurfaceHandle(long surfaceHandle) { - this.surfaceHandle=surfaceHandle; - } - - @Override - protected final int lockSurfaceImpl() { - return LOCK_SUCCESS; - } - - @Override - protected final void unlockSurfaceImpl() { - } - - @Override - public String toString() { - final UpstreamSurfaceHook ush = getUpstreamSurfaceHook(); - final String ush_s = null != ush ? ( ush.getClass().getName() + ": " + ush ) : "nil"; - - return "WrappedSurface[config " + getPrivateGraphicsConfiguration()+ - ", displayHandle 0x" + Long.toHexString(getDisplayHandle()) + - ", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle()) + - ", size " + getWidth() + "x" + getHeight() + - ", surfaceLock "+surfaceLock+ - ", upstreamSurfaceHook "+ush_s+"]"; - } -} diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index d4b927cf1..a62d08ccf 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -39,12 +39,14 @@ package com.jogamp.nativewindow.awt; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.nativewindow.MutableGraphicsConfiguration; import java.awt.Component; import java.awt.Container; import java.applet.Applet; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; @@ -110,21 +112,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, this.offscreenSurfaceLayer = 0; } - @Override - public void setShallUseOffscreenLayer(boolean v) { - shallUseOffscreenLayer = v; - } - - @Override - public final boolean getShallUseOffscreenLayer() { - return shallUseOffscreenLayer; - } - - @Override - public final boolean isOffscreenLayerSurfaceEnabled() { - return isOffscreenLayerSurface; - } - protected synchronized void invalidate() { invalidateNative(); jawt = null; @@ -136,26 +123,29 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } protected abstract void invalidateNative(); - protected final void updateBounds(JAWT_Rectangle jawtBounds) { - if(DEBUG) { - final Rectangle jb = new Rectangle(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); - if(!bounds.equals(jb)) { + protected final boolean updateBounds(JAWT_Rectangle jawtBounds) { + final Rectangle jb = new Rectangle(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); + final boolean changed = !bounds.equals(jb); + + if(changed) { + if(DEBUG) { System.err.println("JAWTWindow.updateBounds: "+bounds+" -> "+jb); Thread.dumpStack(); } + bounds.setX(jawtBounds.getX()); + bounds.setY(jawtBounds.getY()); + bounds.setWidth(jawtBounds.getWidth()); + bounds.setHeight(jawtBounds.getHeight()); + + if(component instanceof Container) { + java.awt.Insets contInsets = ((Container)component).getInsets(); + insets.setLeftWidth(contInsets.left); + insets.setRightWidth(contInsets.right); + insets.setTopHeight(contInsets.top); + insets.setBottomHeight(contInsets.bottom); + } } - bounds.setX(jawtBounds.getX()); - bounds.setY(jawtBounds.getY()); - bounds.setWidth(jawtBounds.getWidth()); - bounds.setHeight(jawtBounds.getHeight()); - - if(component instanceof Container) { - java.awt.Insets contInsets = ((Container)component).getInsets(); - insets.setLeftWidth(contInsets.left); - insets.setRightWidth(contInsets.right); - insets.setTopHeight(contInsets.top); - insets.setBottomHeight(contInsets.bottom); - } + return changed; } /** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */ @@ -181,9 +171,29 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return jawt; } - /** - * {@inheritDoc} - */ + // + // OffscreenLayerOption + // + + @Override + public void setShallUseOffscreenLayer(boolean v) { + shallUseOffscreenLayer = v; + } + + @Override + public final boolean getShallUseOffscreenLayer() { + return shallUseOffscreenLayer; + } + + @Override + public final boolean isOffscreenLayerSurfaceEnabled() { + return isOffscreenLayerSurface; + } + + // + // OffscreenLayerSurface + // + @Override public final void attachSurfaceLayer(final long layerHandle) throws NativeWindowException { if( !isOffscreenLayerSurfaceEnabled() ) { @@ -205,9 +215,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } protected abstract void attachSurfaceLayerImpl(final long layerHandle); - /** - * {@inheritDoc} - */ @Override public final void detachSurfaceLayer() throws NativeWindowException { if( !isOffscreenLayerSurfaceEnabled() ) { @@ -232,11 +239,21 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } protected abstract void detachSurfaceLayerImpl(final long layerHandle); + protected final long getAttachedSurfaceLayer() { + return offscreenSurfaceLayer; + } + @Override public final boolean isSurfaceLayerAttached() { return 0 != offscreenSurfaceLayer; } + @Override + public final void setChosenCapabilities(CapabilitiesImmutable caps) { + ((MutableGraphicsConfiguration)getGraphicsConfiguration()).setChosenCapabilities(caps); + getPrivateGraphicsConfiguration().setChosenCapabilities(caps); + } + // // SurfaceUpdateListener // @@ -381,7 +398,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, public final AbstractGraphicsConfiguration getGraphicsConfiguration() { return config.getNativeGraphicsConfiguration(); } - + @Override public final long getDisplayHandle() { return getGraphicsConfiguration().getScreen().getDevice().getHandle(); @@ -393,13 +410,13 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override - public int getWidth() { + public final int getWidth() { return component.getWidth(); } @Override - public int getHeight() { - return component.getHeight(); + public final int getHeight() { + return component.getHeight(); } // diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java index 40042ec81..b824350ff 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java @@ -67,8 +67,8 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl * Note that this is not an open connection, ie no native display handle exist. * This constructor exist to setup a default device connection/unit.
*/ - public EGLGraphicsDevice(String connection, int unitID) { - super(NativeWindowFactory.TYPE_EGL, connection, unitID); + public EGLGraphicsDevice() { + super(NativeWindowFactory.TYPE_EGL, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); this.nativeDisplayID[0] = 0 ; // EGL.EGL_DEFAULT_DISPLAY this.eglLifecycleCallback = null; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java index cec7d4ec3..27462ae70 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java @@ -124,8 +124,11 @@ public interface NativeSurface extends SurfaceUpdatedListener { /** * Provide a mechanism to utilize custom (pre-) swap surface * code. This method is called before the render toolkit (e.g. JOGL) - * swaps the buffer/surface. The implementation may itself apply the swapping, + * swaps the buffer/surface if double buffering is enabled. + *

+ * The implementation may itself apply the swapping, * in which case true shall be returned. + *

* * @return true if this method completed swapping the surface, * otherwise false, in which case eg the GLDrawable diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index f7dbc6c27..f9800109c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -50,4 +50,7 @@ public interface OffscreenLayerSurface { /** Returns true if a surface layer is attached, otherwise false. */ public boolean isSurfaceLayerAttached(); + /** Sets the capabilities of this instance, allowing upstream API's to refine it, i.e. OpenGL related settings. */ + public void setChosenCapabilities(CapabilitiesImmutable caps); + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java index 7fc9789c2..395fdc818 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java @@ -1,5 +1,5 @@ /** - * Copyright 2010 JogAmp Community. All rights reserved. + * Copyright 2012 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: @@ -29,242 +29,82 @@ package javax.media.nativewindow; import jogamp.nativewindow.Debug; -import jogamp.nativewindow.SurfaceUpdatedHelper; -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; - -public abstract class ProxySurface implements NativeSurface, MutableSurface { +/** + * Provides a mutable {@link NativeSurface}, i.e. {@link MutableSurface}, while allowing an + * {@link UpstreamSurfaceHook} to influence the lifecycle and information. + * + * @see UpstreamSurfaceHook + * @see MutableSurface + * @see NativeSurface + */ +public interface ProxySurface extends MutableSurface { public static final boolean DEBUG = Debug.debug("ProxySurface"); /** - * Implementation specific bitvalue stating the upstream's {@link AbstractGraphicsDevice} is owned by this {@link ProxySurface}. - * @see #setImplBitfield(int) - * @see #getImplBitfield() + * Implementation specific bit-value stating this {@link ProxySurface} owns the upstream's surface handle + * @see #addUpstreamOptionBits(int) + * @see #getUpstreamOptionBits() */ - public static final int OWN_DEVICE = 1 << 7; + public static final int OPT_PROXY_OWNS_UPSTREAM_SURFACE = 1 << 6; + + /** + * Implementation specific bit-value stating this {@link ProxySurface} owns the upstream's {@link AbstractGraphicsDevice}. + * @see #addUpstreamOptionBits(int) + * @see #getUpstreamOptionBits() + */ + public static final int OPT_PROXY_OWNS_UPSTREAM_DEVICE = 1 << 7; /** * Implementation specific bitvalue stating the upstream's {@link NativeSurface} is an invisible window, i.e. maybe incomplete. - * @see #setImplBitfield(int) - * @see #getImplBitfield() + * @see #addUpstreamOptionBits(int) + * @see #getUpstreamOptionBits() */ - public static final int INVISIBLE_WINDOW = 1 << 8; + public static final int OPT_UPSTREAM_WINDOW_INVISIBLE = 1 << 8; - /** Interface allowing upstream caller to pass lifecycle actions and size info to a {@link ProxySurface} instance. */ - public interface UpstreamSurfaceHook { - /** called within {@link ProxySurface#createNotify()} within lock, before using surface. */ - public void create(ProxySurface s); - /** called within {@link ProxySurface#destroyNotify()} within lock, before clearing fields. */ - public void destroy(ProxySurface s); + /** Allow redefining the AbstractGraphicsConfiguration */ + public void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg); - /** Returns the width of the upstream surface */ - public int getWidth(ProxySurface s); - /** Returns the height of the upstream surface */ - public int getHeight(ProxySurface s); - } + /** Returns the set {@link UpstreamSurfaceHook}, or null if not set. */ + public UpstreamSurfaceHook getUpstreamSurfaceHook(); - private final SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); - private final AbstractGraphicsConfiguration config; // control access due to delegation - private final UpstreamSurfaceHook upstream; - public final int initialWidth; - public final int initialHeight; - private long surfaceHandle_old; - protected RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); - protected long displayHandle; - protected int scrnIndex; - protected int implBitfield; - /** - * @param cfg the {@link AbstractGraphicsConfiguration} to be used - * @param initialWidth the initial width - * @param initialHeight the initial height + * Sets the {@link UpstreamSurfaceHook} and returns the previous value. */ - protected ProxySurface(AbstractGraphicsConfiguration cfg, int initialWidth, int initialHeight, UpstreamSurfaceHook upstream) { - if(null == cfg) { - throw new IllegalArgumentException("null config"); - } - this.config = cfg; - this.upstream = upstream; - this.initialWidth = initialWidth; - this.initialHeight = initialHeight; - this.displayHandle=config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); - this.surfaceHandle_old = 0; - this.implBitfield = 0; - } - - public final UpstreamSurfaceHook getUpstreamSurfaceHook() { return upstream; } + public void setUpstreamSurfaceHook(UpstreamSurfaceHook hook); + + /** + * Enables or disables the {@link UpstreamSurfaceHook} lifecycle functions + * {@link UpstreamSurfaceHook#create(ProxySurface)} and {@link UpstreamSurfaceHook#destroy(ProxySurface)}. + *

+ * Use this for small code blocks where the native resources shall not change, + * i.e. resizing a derived (OpenGL) drawable. + *

+ */ + public void enableUpstreamSurfaceHookLifecycle(boolean enable); /** - * If a valid {@link UpstreamSurfaceHook} instance is passed in the - * {@link ProxySurface#ProxySurface(AbstractGraphicsConfiguration, int, int, UpstreamSurfaceHook) constructor}, * {@link UpstreamSurfaceHook#create(ProxySurface)} is being issued and the proxy surface/window handles shall be set. */ - public void createNotify() { - if(null != upstream) { - upstream.create(this); - } - this.displayHandle=config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); - this.surfaceHandle_old = 0; - } + public void createNotify(); /** - * If a valid {@link UpstreamSurfaceHook} instance is passed in the - * {@link ProxySurface#ProxySurface(AbstractGraphicsConfiguration, int, int, UpstreamSurfaceHook) constructor}, - * {@link UpstreamSurfaceHook#destroy(ProxySurface)} is being issued and all fields are cleared. + * {@link UpstreamSurfaceHook#destroy(ProxySurface)} is being issued and all proxy surface/window handles shall be cleared. */ - public void destroyNotify() { - if(null != upstream) { - upstream.destroy(this); - invalidateImpl(); - } - this.displayHandle = 0; - this.surfaceHandle_old = 0; - } + public void destroyNotify(); - /** - * Must be overridden by implementations allowing having a {@link UpstreamSurfaceHook} being passed. - * @see #destroyNotify() - */ - protected void invalidateImpl() { - throw new InternalError("UpstreamSurfaceHook given, but required method not implemented."); - } + public StringBuilder getUpstreamOptionBits(StringBuilder sink); + public int getUpstreamOptionBits(); - @Override - public final long getDisplayHandle() { - return displayHandle; - } - - protected final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() { - return config; - } - - @Override - public final AbstractGraphicsConfiguration getGraphicsConfiguration() { - return config.getNativeGraphicsConfiguration(); - } - - @Override - public final int getScreenIndex() { - return getGraphicsConfiguration().getScreen().getIndex(); - } - - @Override - public abstract long getSurfaceHandle(); - - @Override - public abstract void setSurfaceHandle(long surfaceHandle); + /** Returns true if the give bit-mask v is set in this instance upstream-option-bits, otherwise false.*/ + public boolean containsUpstreamOptionBits(int v); - @Override - public final int getWidth() { - if(null != upstream) { - return upstream.getWidth(this); - } - return initialWidth; - } - - @Override - public final int getHeight() { - if(null != upstream) { - return upstream.getHeight(this); - } - return initialHeight; - } - - @Override - public boolean surfaceSwap() { - return false; - } - - @Override - public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { - surfaceUpdatedHelper.addSurfaceUpdatedListener(l); - } - - @Override - public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { - surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); - } - - @Override - public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { - surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); - } - - @Override - public void surfaceUpdated(Object updater, NativeSurface ns, long when) { - surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); - } - - @Override - public int lockSurface() throws NativeWindowException, RuntimeException { - surfaceLock.lock(); - int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? - - if ( LOCK_SURFACE_NOT_READY == res ) { - try { - final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); - adevice.lock(); - try { - res = lockSurfaceImpl(); - if(LOCK_SUCCESS == res && surfaceHandle_old != getSurfaceHandle()) { - res = LOCK_SURFACE_CHANGED; - if(DEBUG) { - System.err.println("ProxySurface: surface change 0x"+Long.toHexString(surfaceHandle_old)+" -> 0x"+Long.toHexString(getSurfaceHandle())); - // Thread.dumpStack(); - } - } - } finally { - if (LOCK_SURFACE_NOT_READY >= res) { - adevice.unlock(); - } - } - } finally { - if (LOCK_SURFACE_NOT_READY >= res) { - surfaceLock.unlock(); - } - } - } - return res; - } - - @Override - public final void unlockSurface() { - surfaceLock.validateLocked(); - surfaceHandle_old = getSurfaceHandle(); - - if (surfaceLock.getHoldCount() == 1) { - final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); - try { - unlockSurfaceImpl(); - } finally { - adevice.unlock(); - } - } - surfaceLock.unlock(); - } - - protected abstract int lockSurfaceImpl(); - - protected abstract void unlockSurfaceImpl() ; - - public final void validateSurfaceLocked() { - surfaceLock.validateLocked(); - } - - @Override - public final boolean isSurfaceLockedByOtherThread() { - return surfaceLock.isLockedByOtherThread(); - } - - @Override - public final Thread getSurfaceLockOwner() { - return surfaceLock.getOwner(); - } + /** Add the given bit-mask to this instance upstream-option-bits using bit-or w/ v.*/ + public void addUpstreamOptionBits(int v); - @Override - public abstract String toString(); + /** Clear the given bit-mask from this instance upstream-option-bits using bit-and w/ ~v*/ + public void clearUpstreamOptionBits(int v); - public int getImplBitfield() { return implBitfield; } - public void setImplBitfield(int v) { implBitfield=v; } + public StringBuilder toString(StringBuilder sink); + public String toString(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java b/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java new file mode 100644 index 000000000..6fe2e5364 --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java @@ -0,0 +1,52 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package javax.media.nativewindow; + +/** + * Interface allowing upstream caller to pass lifecycle actions and size info + * to a {@link ProxySurface} instance. + */ +public interface UpstreamSurfaceHook { + /** called within {@link ProxySurface#createNotify()} within lock, before using surface. */ + public void create(ProxySurface s); + /** called within {@link ProxySurface#destroyNotify()} within lock, before clearing fields. */ + public void destroy(ProxySurface s); + + /** Returns the width of the upstream surface, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */ + public int getWidth(ProxySurface s); + /** Returns the height of the upstream surface, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */ + public int getHeight(ProxySurface s); + + /** + * {@link UpstreamSurfaceHook} w/ mutable size, allowing it's {@link ProxySurface} user to resize. + */ + public interface MutableSize extends UpstreamSurfaceHook { + public void setSize(int width, int height); + } +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java new file mode 100644 index 000000000..63f56cbae --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java @@ -0,0 +1,326 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.nativewindow; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.SurfaceUpdatedListener; +import javax.media.nativewindow.UpstreamSurfaceHook; + + +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; + +public abstract class ProxySurfaceImpl implements ProxySurface { + private final SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); + protected long displayHandle; // convenient ref of config.screen.device.handle + private AbstractGraphicsConfiguration config; // control access due to delegation + private UpstreamSurfaceHook upstream; + private long surfaceHandle_old; + private RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); + private int implBitfield; + private boolean upstreamSurfaceHookLifecycleEnabled; + + /** + * @param cfg the {@link AbstractGraphicsConfiguration} to be used + * @param upstream the {@link UpstreamSurfaceHook} to be used + * @param ownsDevice true if this {@link ProxySurface} instance + * owns the {@link AbstractGraphicsConfiguration}'s {@link AbstractGraphicsDevice}, + * otherwise false. Owning the device implies closing it at {@link #destroyNotify()}. + */ + protected ProxySurfaceImpl(AbstractGraphicsConfiguration cfg, UpstreamSurfaceHook upstream, boolean ownsDevice) { + if(null == cfg) { + throw new IllegalArgumentException("null AbstractGraphicsConfiguration"); + } + if(null == upstream) { + throw new IllegalArgumentException("null UpstreamSurfaceHook"); + } + this.config = cfg; + this.displayHandle=config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); + this.upstream = upstream; + this.surfaceHandle_old = 0; + this.implBitfield = 0; + this.upstreamSurfaceHookLifecycleEnabled = true; + if(ownsDevice) { + addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + } + + @Override + public final UpstreamSurfaceHook getUpstreamSurfaceHook() { return upstream; } + + @Override + public void setUpstreamSurfaceHook(UpstreamSurfaceHook hook) { + if(null == hook) { + throw new IllegalArgumentException("null UpstreamSurfaceHook"); + } + upstream = hook; + } + + @Override + public final void enableUpstreamSurfaceHookLifecycle(boolean enable) { + upstreamSurfaceHookLifecycleEnabled = enable; + } + + @Override + public void createNotify() { + if(upstreamSurfaceHookLifecycleEnabled) { + upstream.create(this); + } + this.displayHandle=config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); + this.surfaceHandle_old = 0; + } + + @Override + public void destroyNotify() { + if(upstreamSurfaceHookLifecycleEnabled) { + upstream.destroy(this); + if( containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ) ) { + final AbstractGraphicsDevice aDevice = getGraphicsConfiguration().getScreen().getDevice(); + aDevice.close(); + clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + invalidateImpl(); + } + this.displayHandle = 0; + this.surfaceHandle_old = 0; + } + + /** + * Must be overridden by implementations allowing having a {@link UpstreamSurfaceHook} being passed. + * @see #destroyNotify() + */ + protected void invalidateImpl() { + throw new InternalError("UpstreamSurfaceHook given, but required method not implemented."); + } + + @Override + public final long getDisplayHandle() { + return displayHandle; + } + + protected final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() { + return config; + } + + @Override + public final AbstractGraphicsConfiguration getGraphicsConfiguration() { + return config.getNativeGraphicsConfiguration(); + } + + @Override + public final void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg) { + config = cfg; + } + + @Override + public final int getScreenIndex() { + return getGraphicsConfiguration().getScreen().getIndex(); + } + + @Override + public abstract long getSurfaceHandle(); + + @Override + public abstract void setSurfaceHandle(long surfaceHandle); + + @Override + public final int getWidth() { + return upstream.getWidth(this); + } + + @Override + public final int getHeight() { + return upstream.getHeight(this); + } + + @Override + public boolean surfaceSwap() { + return false; + } + + @Override + public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { + surfaceUpdatedHelper.addSurfaceUpdatedListener(l); + } + + @Override + public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { + surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); + } + + @Override + public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { + surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); + } + + @Override + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { + surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); + } + + @Override + public int lockSurface() throws NativeWindowException, RuntimeException { + surfaceLock.lock(); + int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? + + if ( LOCK_SURFACE_NOT_READY == res ) { + try { + final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); + adevice.lock(); + try { + res = lockSurfaceImpl(); + if(LOCK_SUCCESS == res && surfaceHandle_old != getSurfaceHandle()) { + res = LOCK_SURFACE_CHANGED; + if(DEBUG) { + System.err.println("ProxySurfaceImpl: surface change 0x"+Long.toHexString(surfaceHandle_old)+" -> 0x"+Long.toHexString(getSurfaceHandle())); + // Thread.dumpStack(); + } + } + } finally { + if (LOCK_SURFACE_NOT_READY >= res) { + adevice.unlock(); + } + } + } finally { + if (LOCK_SURFACE_NOT_READY >= res) { + surfaceLock.unlock(); + } + } + } + return res; + } + + @Override + public final void unlockSurface() { + surfaceLock.validateLocked(); + surfaceHandle_old = getSurfaceHandle(); + + if (surfaceLock.getHoldCount() == 1) { + final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); + try { + unlockSurfaceImpl(); + } finally { + adevice.unlock(); + } + } + surfaceLock.unlock(); + } + + protected abstract int lockSurfaceImpl(); + + protected abstract void unlockSurfaceImpl() ; + + public final void validateSurfaceLocked() { + surfaceLock.validateLocked(); + } + + @Override + public final boolean isSurfaceLockedByOtherThread() { + return surfaceLock.isLockedByOtherThread(); + } + + @Override + public final Thread getSurfaceLockOwner() { + return surfaceLock.getOwner(); + } + + public final StringBuilder getUpstreamOptionBits(StringBuilder sink) { + if(null == sink) { + sink = new StringBuilder(); + } + sink.append("UOB[ "); + if(0 == implBitfield) { + sink.append("]"); + return sink; + } + boolean needsOr = false; + if( 0 != ( implBitfield & OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + sink.append("OWNS_SURFACE"); + needsOr = true; + } + if( 0 != ( implBitfield & OPT_PROXY_OWNS_UPSTREAM_DEVICE ) ) { + if(needsOr) { + sink.append(" | "); + } + sink.append("OWNS_DEVICE"); + needsOr = true; + } + if( 0 != ( implBitfield & OPT_UPSTREAM_WINDOW_INVISIBLE ) ) { + if(needsOr) { + sink.append(" | "); + } + sink.append("WINDOW_INVISIBLE"); + needsOr = true; + } + sink.append(" ]"); + return sink; + } + + @Override + public final int getUpstreamOptionBits() { return implBitfield; } + + @Override + public final boolean containsUpstreamOptionBits(int v) { + return v == ( implBitfield & v ) ; + } + + @Override + public final void addUpstreamOptionBits(int v) { implBitfield |= v; } + + @Override + public final void clearUpstreamOptionBits(int v) { implBitfield &= ~v; } + + @Override + public StringBuilder toString(StringBuilder sink) { + if(null == sink) { + sink = new StringBuilder(); + } + sink.append(getUpstreamSurfaceHook()). + append(", displayHandle 0x" + Long.toHexString(getDisplayHandle())). + append(", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle())). + append(", size " + getWidth() + "x" + getHeight()).append(", "); + getUpstreamOptionBits(sink); + sink.append(", surfaceLock "+surfaceLock); + return sink; + } + + @Override + public String toString() { + StringBuilder msg = new StringBuilder(); + msg.append(getClass().getSimpleName()).append("[ "); + toString(msg); + msg.append(" ]"); + return msg.toString(); + } + +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java new file mode 100644 index 000000000..e544bc61a --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java @@ -0,0 +1,95 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.nativewindow; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; + +public class WrappedSurface extends ProxySurfaceImpl { + protected long surfaceHandle; + + /** + * Utilizes a {@link UpstreamSurfaceHook.MutableSize} to hold the size information, + * which is being passed to the {@link ProxySurface} instance. + * + * @param cfg the {@link AbstractGraphicsConfiguration} to be used + * @param handle the wrapped pre-existing native surface handle, maybe 0 if not yet determined + * @param initialWidth + * @param initialHeight + * @param ownsDevice true if this {@link ProxySurface} instance + * owns the {@link AbstractGraphicsConfiguration}'s {@link AbstractGraphicsDevice}, + * otherwise false. Owning the device implies closing it at {@link #destroyNotify()}. + */ + public WrappedSurface(AbstractGraphicsConfiguration cfg, long handle, int initialWidth, int initialHeight, boolean ownsDevice) { + super(cfg, new UpstreamSurfaceHookMutableSize(initialWidth, initialHeight), ownsDevice); + surfaceHandle=handle; + } + + /** + * @param cfg the {@link AbstractGraphicsConfiguration} to be used + * @param handle the wrapped pre-existing native surface handle, maybe 0 if not yet determined + * @param upstream the {@link UpstreamSurfaceHook} to be used + * @param ownsDevice true if this {@link ProxySurface} instance + * owns the {@link AbstractGraphicsConfiguration}'s {@link AbstractGraphicsDevice}, + * otherwise false. + */ + public WrappedSurface(AbstractGraphicsConfiguration cfg, long handle, UpstreamSurfaceHook upstream, boolean ownsDevice) { + super(cfg, upstream, ownsDevice); + surfaceHandle=handle; + } + + @Override + protected void invalidateImpl() { + surfaceHandle = 0; + } + + @Override + public final long getSurfaceHandle() { + return surfaceHandle; + } + + @Override + public final void setSurfaceHandle(long surfaceHandle) { + this.surfaceHandle=surfaceHandle; + } + + @Override + protected final int lockSurfaceImpl() { + return LOCK_SUCCESS; + } + + @Override + protected final void unlockSurfaceImpl() { + } + +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index e81d61e0f..5fd242247 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -51,7 +51,6 @@ import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.util.Point; -import com.jogamp.nativewindow.MutableGraphicsConfiguration; import com.jogamp.nativewindow.awt.JAWTWindow; import jogamp.nativewindow.jawt.JAWT; @@ -71,17 +70,18 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } protected void invalidateNative() { - surfaceHandle=0; + offscreenSurfaceHandle=0; + offscreenSurfaceHandleSet=false; if(isOffscreenLayerSurfaceEnabled()) { if(0 != rootSurfaceLayerHandle) { OSXUtil.DestroyCALayer(rootSurfaceLayerHandle); rootSurfaceLayerHandle = 0; } - if(0 != drawable) { - OSXUtil.DestroyNSWindow(drawable); - drawable = 0; + if(0 != windowHandle) { + OSXUtil.DestroyNSWindow(windowHandle); } } + windowHandle=0; } protected void attachSurfaceLayerImpl(final long layerHandle) { @@ -92,8 +92,14 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.RemoveCASublayer(rootSurfaceLayerHandle, layerHandle); } - public long getSurfaceHandle() { - return isOffscreenLayerSurfaceEnabled() ? surfaceHandle : super.getSurfaceHandle() ; + @Override + public final long getWindowHandle() { + return windowHandle; + } + + @Override + public final long getSurfaceHandle() { + return offscreenSurfaceHandleSet ? offscreenSurfaceHandle : drawable /* super.getSurfaceHandle() */ ; } public void setSurfaceHandle(long surfaceHandle) { @@ -103,7 +109,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if(DEBUG) { System.err.println("MacOSXJAWTWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle)); } - this.surfaceHandle = surfaceHandle; + this.offscreenSurfaceHandle = surfaceHandle; + this.offscreenSurfaceHandleSet = true; } protected JAWT fetchJAWTImpl() throws NativeWindowException { @@ -167,6 +174,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { unlockSurfaceImpl(); return NativeWindow.LOCK_SURFACE_NOT_READY; } else { + windowHandle = OSXUtil.GetNSWindow(drawable); ret = NativeWindow.LOCK_SUCCESS; } } else { @@ -177,36 +185,46 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { * The actual surface/ca-layer shall be created/attached * by the upper framework (JOGL) since they require more information. */ + String errMsg = null; if(0 == drawable) { - drawable = OSXUtil.CreateNSWindow(0, 0, getBounds().getWidth(), getBounds().getHeight()); - if(0 == drawable) { - unlockSurfaceImpl(); - throw new NativeWindowException("Unable to created dummy NSWindow (layered case)"); + windowHandle = OSXUtil.CreateNSWindow(0, 0, 64, 64); + if(0 == windowHandle) { + errMsg = "Unable to create dummy NSWindow (layered case)"; + } else { + drawable = OSXUtil.GetNSView(windowHandle); + if(0 == drawable) { + errMsg = "Null NSView of NSWindow 0x"+Long.toHexString(windowHandle); + } + } + if(null == errMsg) { + // fix caps reflecting offscreen! (no GL available here ..) + Capabilities caps = (Capabilities) getGraphicsConfiguration().getChosenCapabilities().cloneMutable(); + caps.setOnscreen(false); + setChosenCapabilities(caps); } - // fix caps reflecting offscreen! - Capabilities caps = (Capabilities) getPrivateGraphicsConfiguration().getChosenCapabilities().cloneMutable(); - caps.setOnscreen(false); - getPrivateGraphicsConfiguration().setChosenCapabilities(caps); - caps = (Capabilities) getGraphicsConfiguration().getChosenCapabilities().cloneMutable(); - caps.setOnscreen(false); - ((MutableGraphicsConfiguration)getGraphicsConfiguration()).setChosenCapabilities(caps); } - if(0 == rootSurfaceLayerHandle) { - rootSurfaceLayerHandle = OSXUtil.CreateCALayer(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); - if(0 == rootSurfaceLayerHandle) { - OSXUtil.DestroyNSWindow(drawable); - drawable = 0; - unlockSurfaceImpl(); - throw new NativeWindowException("Could not create root CALayer: "+this); + if(null == errMsg) { + if(0 == rootSurfaceLayerHandle) { + rootSurfaceLayerHandle = OSXUtil.CreateCALayer(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); + if(0 == rootSurfaceLayerHandle) { + errMsg = "Could not create root CALayer"; + } else if(!SetJAWTRootSurfaceLayer0(dsi.getBuffer(), rootSurfaceLayerHandle)) { + errMsg = "Could not set JAWT rootSurfaceLayerHandle 0x"+Long.toHexString(rootSurfaceLayerHandle); + } } - if(!SetJAWTRootSurfaceLayer0(dsi.getBuffer(), rootSurfaceLayerHandle)) { + } + if(null != errMsg) { + if(0 != rootSurfaceLayerHandle) { OSXUtil.DestroyCALayer(rootSurfaceLayerHandle); rootSurfaceLayerHandle = 0; - OSXUtil.DestroyNSWindow(drawable); - drawable = 0; - unlockSurfaceImpl(); - throw new NativeWindowException("Could not set JAWT rootSurfaceLayerHandle: "+this); } + if(0 != windowHandle) { + OSXUtil.DestroyNSWindow(windowHandle); + windowHandle = 0; + } + drawable = 0; + unlockSurfaceImpl(); + throw new NativeWindowException(errMsg+": "+this); } ret = NativeWindow.LOCK_SUCCESS; } @@ -264,7 +282,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { private long rootSurfaceLayerHandle = 0; // attached to the JAWT_SurfaceLayer - private long surfaceHandle = 0; + private long windowHandle = 0; + private long offscreenSurfaceHandle = 0; + private boolean offscreenSurfaceHandleSet = false; // Workaround for instance of 4796548 private boolean firstLock = true; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java new file mode 100644 index 000000000..de3206c0c --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java @@ -0,0 +1,56 @@ +package jogamp.nativewindow.macosx; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; + +public class OSXDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { + long nsWindow; + + /** + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. + * The latter is platform specific and small + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * not the actual dummy surface height, + * The latter is platform specific and small + */ + public OSXDummyUpstreamSurfaceHook(int width, int height) { + super(width, height); + nsWindow = 0; + } + + @Override + public final void create(ProxySurface s) { + if(0 == nsWindow && 0 == s.getSurfaceHandle()) { + nsWindow = OSXUtil.CreateNSWindow(0, 0, 64, 64); + if(0 == nsWindow) { + throw new NativeWindowException("Error NS window 0"); + } + long nsView = OSXUtil.GetNSView(nsWindow); + if(0 == nsView) { + throw new NativeWindowException("Error NS view 0"); + } + s.setSurfaceHandle(nsView); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); + } + + @Override + public final void destroy(ProxySurface s) { + if( s.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + if( 0 == nsWindow || 0 == s.getSurfaceHandle() ) { + throw new InternalError("Owns upstream surface, but no OSX view/window: "+s+", nsWindow 0x"+Long.toHexString(nsWindow)); + } + OSXUtil.DestroyNSWindow(nsWindow); + nsWindow = 0; + s.setSurfaceHandle(0); + s.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + } + +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 149ebdf4a..b7a83e133 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -72,6 +72,10 @@ public class OSXUtil { return isNSView0(object); } + public static boolean isNSWindow(long object) { + return isNSWindow0(object); + } + /** * In case the windowOrView is top-level, * you shall set topLevel to true where @@ -114,6 +118,9 @@ public class OSXUtil { public static long GetNSView(long nsWindow) { return GetNSView0(nsWindow); } + public static long GetNSWindow(long nsView) { + return GetNSWindow0(nsView); + } public static long CreateCALayer(int x, int y, int width, int height) { return CreateCALayer0(x, y, width, height); @@ -149,6 +156,11 @@ public class OSXUtil { return IsMainThread0(); } + /** Returns the screen refresh rate in Hz. If unavailable, returns 60Hz. */ + public static int GetScreenRefreshRate(int scrn_idx) { + return GetScreenRefreshRate0(scrn_idx); + } + /*** private static boolean isAWTEDTMainThreadInit = false; private static boolean isAWTEDTMainThread; @@ -172,15 +184,18 @@ public class OSXUtil { private static native boolean initIDs0(); private static native boolean isNSView0(long object); + private static native boolean isNSWindow0(long object); private static native Object GetLocationOnScreen0(long windowOrView, int src_x, int src_y); private static native Object GetInsets0(long windowOrView); private static native long CreateNSWindow0(int x, int y, int width, int height); private static native void DestroyNSWindow0(long nsWindow); private static native long GetNSView0(long nsWindow); + private static native long GetNSWindow0(long nsView); private static native long CreateCALayer0(int x, int y, int width, int height); private static native void AddCASublayer0(long rootCALayer, long subCALayer); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); private static native void RunOnMainThread0(boolean waitUntilDone, Runnable runnable); private static native boolean IsMainThread0(); + private static native int GetScreenRefreshRate0(int scrn_idx); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java new file mode 100644 index 000000000..aa5f3dac5 --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java @@ -0,0 +1,50 @@ +package jogamp.nativewindow.windows; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; + +public class GDIDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { + /** + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. + * The latter is platform specific and small + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * not the actual dummy surface height, + * The latter is platform specific and small + */ + public GDIDummyUpstreamSurfaceHook(int width, int height) { + super(width, height); + } + + @Override + public final void create(ProxySurface s) { + final GDISurface ms = (GDISurface)s; + if(0 == ms.getWindowHandle()) { + final long windowHandle = GDIUtil.CreateDummyWindow(0, 0, 64, 64); + if(0 == windowHandle) { + throw new NativeWindowException("Error windowHandle 0, werr: "+GDI.GetLastError()); + } + ms.setWindowHandle(windowHandle); + ms.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); + } + + @Override + public final void destroy(ProxySurface s) { + final GDISurface ms = (GDISurface)s; + if( ms.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + if( 0 == ms.getWindowHandle() ) { + throw new InternalError("Owns upstream surface, but no GDI window: "+ms); + } + GDI.ShowWindow(ms.getWindowHandle(), GDI.SW_HIDE); + GDIUtil.DestroyDummyWindow(ms.getWindowHandle()); + ms.setWindowHandle(0); + ms.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + } +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java index e368aa6a1..3db2b5fc9 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java @@ -29,9 +29,13 @@ package jogamp.nativewindow.windows; import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.UpstreamSurfaceHook; + +import jogamp.nativewindow.ProxySurfaceImpl; +import jogamp.nativewindow.windows.GDI; /** @@ -40,12 +44,20 @@ import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; * The latter will get and release the HDC. * The size via getWidth()/getHeight() is invalid. */ -public class GDISurface extends ProxySurface { +public class GDISurface extends ProxySurfaceImpl { protected long windowHandle; protected long surfaceHandle; - public GDISurface(AbstractGraphicsConfiguration cfg, long windowHandle, int initialWidth, int initialHeight, UpstreamSurfaceHook upstream) { - super(cfg, initialWidth, initialHeight, upstream); + /** + * @param cfg the {@link AbstractGraphicsConfiguration} to be used + * @param windowHandle the wrapped pre-existing native window handle, maybe 0 if not yet determined + * @param upstream the {@link UpstreamSurfaceHook} to be used + * @param ownsDevice true if this {@link ProxySurface} instance + * owns the {@link AbstractGraphicsConfiguration}'s {@link AbstractGraphicsDevice}, + * otherwise false. Owning the device implies closing it at {@link #destroyNotify()}. + */ + public GDISurface(AbstractGraphicsConfiguration cfg, long windowHandle, UpstreamSurfaceHook upstream, boolean ownsDevice) { + super(cfg, upstream, ownsDevice); this.windowHandle=windowHandle; this.surfaceHandle=0; } @@ -114,18 +126,4 @@ public class GDISurface extends ProxySurface { final public long getSurfaceHandle() { return surfaceHandle; } - - @Override - final public String toString() { - final UpstreamSurfaceHook ush = getUpstreamSurfaceHook(); - final String ush_s = null != ush ? ( ush.getClass().getName() + ": " + ush ) : "nil"; - return getClass().getSimpleName()+"[config "+getPrivateGraphicsConfiguration()+ - ", displayHandle 0x"+Long.toHexString(getDisplayHandle())+ - ", windowHandle 0x"+Long.toHexString(windowHandle)+ - ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+ - ", size "+getWidth()+"x"+getHeight()+ - ", surfaceLock "+surfaceLock+ - ", upstreamSurfaceHook "+ush_s+"]"; - } - } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java new file mode 100644 index 000000000..55a29dd5e --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java @@ -0,0 +1,60 @@ +package jogamp.nativewindow.x11; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +import jogamp.nativewindow.x11.X11Lib; + +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; +import com.jogamp.nativewindow.x11.X11GraphicsConfiguration; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; + +public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { + /** + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. + * The latter is platform specific and small + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * not the actual dummy surface height, + * The latter is platform specific and small + */ + public X11DummyUpstreamSurfaceHook(int width, int height) { + super(width, height); + } + + @Override + public final void create(ProxySurface s) { + final X11GraphicsConfiguration cfg = (X11GraphicsConfiguration) s.getGraphicsConfiguration(); + final X11GraphicsScreen screen = (X11GraphicsScreen) cfg.getScreen(); + final X11GraphicsDevice device = (X11GraphicsDevice) screen.getDevice(); + if(0 == device.getHandle()) { + device.open(); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + if( 0 == s.getSurfaceHandle() ) { + final long windowHandle = X11Lib.CreateDummyWindow(device.getHandle(), screen.getIndex(), cfg.getXVisualID(), 64, 64); + if(0 == windowHandle) { + throw new NativeWindowException("Creating dummy window failed w/ "+cfg); + } + s.setSurfaceHandle(windowHandle); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); + } + + @Override + public final void destroy(ProxySurface s) { + if( s.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + final X11GraphicsDevice device = (X11GraphicsDevice) s.getGraphicsConfiguration().getScreen().getDevice(); + if( 0 == s.getSurfaceHandle() ) { + throw new InternalError("Owns upstream surface, but no X11 window: "+s); + } + X11Lib.DestroyDummyWindow(device.getHandle(), s.getSurfaceHandle()); + s.setSurfaceHandle(0); + s.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + } +} diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 2c853a43d..d6ae7ed31 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -119,6 +119,12 @@ Java_jogamp_nativewindow_macosx_OSXUtil_isNSView0(JNIEnv *env, jclass _unused, j return [nsObj isMemberOfClass:[NSView class]]; } +JNIEXPORT jboolean JNICALL +Java_jogamp_nativewindow_macosx_OSXUtil_isNSWindow0(JNIEnv *env, jclass _unused, jlong object) { + NSObject *nsObj = (NSObject*) (intptr_t) object; + return [nsObj isMemberOfClass:[NSWindow class]]; +} + /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: getLocationOnScreen0 @@ -238,8 +244,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 [myWindow setPreservesContentDuringLiveResize: YES]; // Remove animations NS_DURING + if ( [myWindow respondsToSelector:@selector(setAnimationBehavior:)] ) { // Available >= 10.7 - Removes default animations [myWindow setAnimationBehavior: NSWindowAnimationBehaviorNone]; + } NS_HANDLER NS_ENDHANDLER @@ -278,11 +286,28 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSView0 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); - DBG_PRINT( "contentView0 - window: %p (START)\n", win); - jlong res = (jlong) ((intptr_t) [win contentView]); - DBG_PRINT( "contentView0 - window: %p (END)\n", win); + DBG_PRINT( "GetNSView(window: %p): %p\n", win, (void*) (intptr_t) res); + + [pool release]; + return res; +} + +/* + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: GetNSWindow0 + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 + (JNIEnv *env, jclass unused, jlong view) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSView* v = (NSView*) ((intptr_t) view); + + jlong res = (jlong) ((intptr_t) [v window]); + + DBG_PRINT( "GetNSWindow(view: %p): %p\n", v, (void*) (intptr_t) res); [pool release]; return res; @@ -314,6 +339,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 // no animations for add/remove/swap sublayers etc // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] [layer removeAllAnimations]; + [layer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; + [layer setNeedsDisplayOnBoundsChange: YES]; DBG_PRINT("CALayer::CreateCALayer.1: %p %lf/%lf %lfx%lf\n", layer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); DBG_PRINT("CALayer::CreateCALayer.X: %p (refcnt %d)\n", layer, (int)[layer retainCount]); @@ -357,7 +384,11 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 // no animations for add/remove/swap sublayers etc // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] [rootLayer removeAllAnimations]; + [rootLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; + [rootLayer setNeedsDisplayOnBoundsChange: YES]; [subLayer removeAllAnimations]; + [subLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; + [subLayer setNeedsDisplayOnBoundsChange: YES]; }]; DBG_PRINT("CALayer::AddCASublayer0.X: %p . %p (refcnt %d)\n", rootLayer, subLayer, (int)[subLayer retainCount]); JNF_COCOA_EXIT(env); @@ -404,6 +435,63 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyCALayer0 JNF_COCOA_EXIT(env); } +/* + * Class: Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow + * Method: SetJAWTRootSurfaceLayer0 + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_SetJAWTRootSurfaceLayer0 + (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) +{ + JNF_COCOA_ENTER(env); + JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); + if (NULL == dsi) { + NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); + return JNI_FALSE; + } + CALayer* layer = (CALayer*) (intptr_t) caLayer; + [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + id surfaceLayers = (id )dsi->platformInfo; + DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.0: %p -> %p (refcnt %d)\n", surfaceLayers.layer, layer, (int)[layer retainCount]); + surfaceLayers.layer = layer; // already incr. retain count + DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.X: %p (refcnt %d)\n", layer, (int)[layer retainCount]); + }]; + JNF_COCOA_EXIT(env); + return JNI_TRUE; +} + +/* + * Class: Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow + * Method: UnsetJAWTRootSurfaceLayer0 + * Signature: (JJ)Z +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_UnsetJAWTRootSurfaceLayer0 + (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) +{ + JNF_COCOA_ENTER(env); + JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); + if (NULL == dsi) { + NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); + return JNI_FALSE; + } + CALayer* layer = (CALayer*) (intptr_t) caLayer; + { + id surfaceLayers = (id )dsi->platformInfo; + if(layer != surfaceLayers.layer) { + NativewindowCommon_throwNewRuntimeException(env, "Attached layer %p doesn't match given layer %p\n", surfaceLayers.layer, layer); + return JNI_FALSE; + } + } + // [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + id surfaceLayers = (id )dsi->platformInfo; + DBG_PRINT("CALayer::detachJAWTSurfaceLayer: (%p) %p -> NULL\n", layer, surfaceLayers.layer); + surfaceLayers.layer = NULL; + [layer release]; + // }]; + JNF_COCOA_EXIT(env); + return JNI_TRUE; +} + */ + @interface MainRunnable : NSObject { @@ -489,60 +577,65 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_IsMainThread0 return ( [NSThread isMainThread] == YES ) ? JNI_TRUE : JNI_FALSE ; } -/* - * Class: Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow - * Method: SetJAWTRootSurfaceLayer0 - * Signature: (JJ)Z +/*** + * The following static functions are copied out of NEWT's OSX impl. + * May need to push code to NativeWindow, to remove duplication. */ -JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_SetJAWTRootSurfaceLayer0 - (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) +static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx) { + NSArray *screens = [NSScreen screens]; + if(screen_idx<0) screen_idx=0; + if(screen_idx>=[screens count]) screen_idx=0; + return (NSScreen *) [screens objectAtIndex: screen_idx]; +} +static CGDirectDisplayID NewtScreen_getCGDirectDisplayIDByNSScreen(NSScreen *screen) { + // Mind: typedef uint32_t CGDirectDisplayID; - however, we assume it's 64bit on 64bit ?! + NSDictionary * dict = [screen deviceDescription]; + NSNumber * val = (NSNumber *) [dict objectForKey: @"NSScreenNumber"]; + // [NSNumber integerValue] returns NSInteger which is 32 or 64 bit native size + return (CGDirectDisplayID) [val integerValue]; +} +static long GetDictionaryLong(CFDictionaryRef theDict, const void* key) { - JNF_COCOA_ENTER(env); - JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); - if (NULL == dsi) { - NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); - return JNI_FALSE; - } - CALayer* layer = (CALayer*) (intptr_t) caLayer; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - id surfaceLayers = (id )dsi->platformInfo; - DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.0: %p -> %p (refcnt %d)\n", surfaceLayers.layer, layer, (int)[layer retainCount]); - surfaceLayers.layer = layer; // already incr. retain count - DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.X: %p (refcnt %d)\n", layer, (int)[layer retainCount]); - }]; - JNF_COCOA_EXIT(env); - return JNI_TRUE; + long value = 0; + CFNumberRef numRef; + numRef = (CFNumberRef)CFDictionaryGetValue(theDict, key); + if (numRef != NULL) + CFNumberGetValue(numRef, kCFNumberLongType, &value); + return value; } +#define CGDDGetModeRefreshRate(mode) GetDictionaryLong((mode), kCGDisplayRefreshRate) /* - * Class: Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow - * Method: UnsetJAWTRootSurfaceLayer0 - * Signature: (JJ)Z -JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_UnsetJAWTRootSurfaceLayer0 - (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: GetScreenRefreshRate + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetScreenRefreshRate0 + (JNIEnv *env, jclass unused, jint scrn_idx) { + int res = 0; JNF_COCOA_ENTER(env); - JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); - if (NULL == dsi) { - NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); - return JNI_FALSE; - } - CALayer* layer = (CALayer*) (intptr_t) caLayer; - { - id surfaceLayers = (id )dsi->platformInfo; - if(layer != surfaceLayers.layer) { - NativewindowCommon_throwNewRuntimeException(env, "Attached layer %p doesn't match given layer %p\n", surfaceLayers.layer, layer); - return JNI_FALSE; + // NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSScreen *screen = NewtScreen_getNSScreenByIndex((int)scrn_idx); + DBG_PRINT("GetScreenRefreshRate.0: screen %p\n", (void *)screen); + if(NULL != screen) { + CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen); + DBG_PRINT("GetScreenRefreshRate.1: display %p\n", (void *)display); + if(0 != display) { + CFDictionaryRef mode = CGDisplayCurrentMode(display); + DBG_PRINT("GetScreenRefreshRate.2: mode %p\n", (void *)mode); + if(NULL != mode) { + res = CGDDGetModeRefreshRate(mode); + DBG_PRINT("GetScreenRefreshRate.3: res %d\n", res); + } } } - // [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - id surfaceLayers = (id )dsi->platformInfo; - DBG_PRINT("CALayer::detachJAWTSurfaceLayer: (%p) %p -> NULL\n", layer, surfaceLayers.layer); - surfaceLayers.layer = NULL; - [layer release]; - // }]; + if(0 == res) { + res = 60; // default .. (experienced on OSX 10.6.8) + } + fprintf(stderr, "GetScreenRefreshRate.X: %d\n", res); + // [pool release]; JNF_COCOA_EXIT(env); - return JNI_TRUE; + return res; } - */ diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 6f0028a77..89a749c51 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -68,6 +68,15 @@ import com.jogamp.newt.event.awt.AWTAdapter; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTMouseAdapter; +/** + * AWT {@link java.awt.Canvas Canvas} containing a NEWT {@link Window} using native parenting. + * + *
Offscreen Layer Remarks
+ * + * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} + * maybe called to use an offscreen drawable (FBO or PBuffer) allowing + * the underlying JAWT mechanism to composite the image, if supported. + */ @SuppressWarnings("serial") public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol, OffscreenLayerOption { public static final boolean DEBUG = Debug.debug("Window"); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 0fc1b4e89..a89ccaedb 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -51,6 +51,7 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; @@ -97,7 +98,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind * Constructor. Do not call this directly -- use {@link #create()} instead. */ protected GLWindow(Window window) { - super(null, null, false); + super(null, null, false /* always handle device lifecycle ourselves */); this.window = (WindowImpl) window; this.window.setHandleDestroyNotify(false); window.addWindowListener(new WindowAdapter() { @@ -107,8 +108,8 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } @Override - public void windowResized(WindowEvent e) { - defaultWindowResizedOp(); + public void windowResized(WindowEvent e) { + defaultWindowResizedOp(getWidth(), getHeight()); } @Override @@ -201,11 +202,8 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind @Override public final CapabilitiesImmutable getChosenCapabilities() { - if (drawable == null) { - return window.getChosenCapabilities(); - } - - return drawable.getChosenGLCapabilities(); + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.getChosenGLCapabilities() : window.getChosenCapabilities(); } @Override @@ -536,19 +534,24 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return; } + final boolean done; final RecursiveLock lock = window.getLock(); lock.lock(); // sync: context/drawable could have been recreated/destroyed while animating try { if( null != context ) { // surface is locked/unlocked implicit by context's makeCurrent/release helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction); - } else if( 0 display - setVisible(true); + done = true; + } else { + done = false; } } finally { lock.unlock(); } + if( !done && 0 display + setVisible(true); + } } //---------------------------------------------------------------------- diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index cada253bc..36bc3f28f 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -63,6 +63,9 @@ import com.jogamp.newt.Window; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.util.EDTUtil; +/** + * SWT {@link Canvas} containing a NEWT {@link Window} using native parenting. + */ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("Window"); private static final boolean isOSX = NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false); diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index ba98ca3af..c6c1814f6 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -39,20 +39,16 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; public class OffscreenWindow extends WindowImpl implements MutableSurface { - long surfaceHandle = 0; - ProxySurface.UpstreamSurfaceHook upstreamHook; - ProxySurface dummySurface; + long surfaceHandle; public OffscreenWindow() { - upstreamHook = null; - dummySurface = null; + surfaceHandle = 0; } static long nextWindowHandle = 0x100; // start here - a marker @@ -62,17 +58,6 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { throw new NativeWindowException("Capabilities is onscreen"); } final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); - /** Cannot use OpenGL here .. - if(capsRequested instanceof GLCapabilitiesImmutable) { - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) capsRequested; - if(caps.isFBO() && GLContext.isFBOAvailable(aScreen.getDevice(), caps.getGLProfile()) ) { - final GLDrawableFactoryImpl factory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLCapabilitiesImmutable dummyCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(caps); - final ProxySurface dummySurface = factory.createDummySurfaceImpl(aScreen.getDevice(), false, dummyCaps, null, 64, 64); - upstreamHook = dummySurface.getUpstreamSurfaceHook(); - dummySurface.createNotify(); - } - } */ final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aScreen.getDevice(), capsRequested).chooseGraphicsConfiguration( capsRequested, capsRequested, capabilitiesChooser, aScreen, VisualIDHolder.VID_UNDEFINED); if (null == cfg) { @@ -83,6 +68,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { synchronized(OffscreenWindow.class) { setWindowHandle(nextWindowHandle++); } + visibleChanged(false, true); } protected void closeNativeImpl() { @@ -92,11 +78,6 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { @Override public synchronized void destroy() { super.destroy(); - if(null != dummySurface) { - dummySurface.destroyNotify(); - dummySurface = null; - upstreamHook = null; - } surfaceHandle = 0; } @@ -106,10 +87,6 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { @Override public long getSurfaceHandle() { - if(null != dummySurface) { - return dummySurface.getSurfaceHandle(); - // return upstreamHook.getWidth(); - } return surfaceHandle; } @@ -128,8 +105,8 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { } protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + sizeChanged(false, width, height, false); if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - sizeChanged(false, width, height, false); visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } else { /** diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index ad7195944..c1ac87d38 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -767,11 +767,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - public void setVisible(boolean visible) { + protected void setVisible(boolean wait, boolean visible) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window setVisible: START ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)); } - runOnEDTIfAvail(true, new VisibleAction(visible)); + runOnEDTIfAvail(wait, new VisibleAction(visible)); + } + + public void setVisible(boolean visible) { + setVisible(true, visible); } private class SetSizeAction implements Runnable { @@ -783,21 +787,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public final void run() { - boolean recreate = false; final RecursiveLock _lock = windowLock; _lock.lock(); try { if ( !isFullscreen() && ( getWidth() != width || getHeight() != height ) ) { - recreate = isNativeValid() && !getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window setSize: START "+getWidth()+"x"+getHeight()+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible+", recreate "+recreate); - } - if(recreate) { - // will trigger visibleAction:=2 -> create if wasVisible - final boolean wasVisible = WindowImpl.this.visible; - screen.addReference(); // retain screen - destroyAction.run(); - WindowImpl.this.visible = wasVisible; + System.err.println("Window setSize: START "+getWidth()+"x"+getHeight()+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible); } int visibleAction; // 0 nop, 1 invisible, 2 visible (create) if ( isNativeValid() && 0>=width*height && visible ) { @@ -823,9 +818,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } finally { - if(recreate) { - screen.removeReference(); // bring back ref-count - } _lock.unlock(); } } @@ -940,11 +932,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer */ protected static boolean isOffscreenInstance(NativeWindow cWin, NativeWindow pWin) { boolean ofs = false; - if( null != cWin.getGraphicsConfiguration() ) { - ofs = !cWin.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); + final AbstractGraphicsConfiguration cWinCfg = cWin.getGraphicsConfiguration(); + if( null != cWinCfg ) { + ofs = !cWinCfg.getChosenCapabilities().isOnscreen(); } - if( !ofs && null != pWin && null != pWin.getGraphicsConfiguration() ) { - ofs |= !pWin.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); + if( !ofs && null != pWin ) { + final AbstractGraphicsConfiguration pWinCfg = pWin.getGraphicsConfiguration(); + if( null != pWinCfg ) { + ofs = !pWinCfg.getChosenCapabilities().isOnscreen(); + } } return ofs; } diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index 276b0d070..f18520630 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -428,7 +428,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { getX()+"/"+getY()+" "+nWidth+"x"+nHeight+", visible: "+isVisible()); if(isVisible()) { - setVisible(true); + setVisible(false, true); } } sizeChanged(false, aWidth, aHeight, false); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index ea48569bf..d0c0b8b20 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -117,6 +117,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl return 0 != sscSurfaceHandle ? sscSurfaceHandle : surfaceHandle; } + @Override public void setSurfaceHandle(long surfaceHandle) { if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle)); @@ -170,13 +171,22 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - final Point pS = getTopLevelLocationOnScreen(x, y); - isOffscreenInstance = 0 != sscSurfaceHandle || isOffscreenInstance(this, this.getParent()); + final boolean _isOffscreenInstance = isOffscreenInstance(this, this.getParent()); + isOffscreenInstance = 0 != sscSurfaceHandle || _isOffscreenInstance; + final PointImmutable pS = isOffscreenInstance ? new Point(0, 0) : getTopLevelLocationOnScreen(x, y); if(DEBUG_IMPLEMENTATION) { + final AbstractGraphicsConfiguration cWinCfg = this.getGraphicsConfiguration(); + final NativeWindow pWin = getParent(); + final AbstractGraphicsConfiguration pWinCfg = null != pWin ? pWin.getGraphicsConfiguration() : null; System.err.println("MacWindow reconfig: "+x+"/"+y+" -> "+pS+" - "+width+"x"+height+ - ", offscreenInstance "+isOffscreenInstance+ - ", "+getReconfigureFlagsAsString(null, flags)); + ",\n\t parent type "+(null != pWin ? pWin.getClass().getName() : null)+ + ",\n\t this-chosenCaps "+(null != cWinCfg ? cWinCfg.getChosenCapabilities() : null)+ + ",\n\t parent-chosenCaps "+(null != pWinCfg ? pWinCfg.getChosenCapabilities() : null)+ + ", isOffscreenInstance(sscSurfaceHandle "+toHexString(sscSurfaceHandle)+ + ", ioi: "+_isOffscreenInstance+ + ") -> "+isOffscreenInstance+ + "\n\t, "+getReconfigureFlagsAsString(null, flags)); } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) { @@ -190,7 +200,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl 0 != ( FLAG_CHANGE_DECORATION & flags) || 0 != ( FLAG_CHANGE_PARENTING & flags) || 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { - createWindow(isOffscreenInstance, 0 != getWindowHandle(), pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); + if(isOffscreenInstance) { + createWindow(true, 0 != getWindowHandle(), pS, 64, 64, false); + } else { + createWindow(false, 0 != getWindowHandle(), pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); + } if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; } } if(x>=0 && y>=0) { diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index e0330a563..b9c339285 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -94,7 +94,13 @@ static void changeContentView(JNIEnv *env, jobject javaWindowObject, NSView *pvi if(NULL!=oldNSView) { NS_DURING // Available >= 10.5 - Makes the menubar disapear - if([oldNSView isInFullScreenMode]) { + BOOL iifs; + if ( [oldNSView respondsToSelector:@selector(isInFullScreenMode)] ) { + iifs = [oldNSView isInFullScreenMode]; + } else { + iifs = NO; + } + if(iifs && [oldNSView respondsToSelector:@selector(exitFullScreenModeWithOptions:)] ) { [oldNSView exitFullScreenModeWithOptions: NULL]; } NS_HANDLER @@ -430,6 +436,8 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree if( -1 < mode_idx ) { prop[propIndex++] = mode_idx; } + int refreshRate = CGDDGetModeRefreshRate(mode); + int fRefreshRate = ( 0 < refreshRate ) ? refreshRate : 60; // default .. (experienced on OSX 10.6.8) prop[propIndex++] = 0; // set later for verification of iterator propIndexRes = propIndex; prop[propIndex++] = mWidth; @@ -437,14 +445,14 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree prop[propIndex++] = CGDDGetModeBitsPerPixel(mode); prop[propIndex++] = widthMM; prop[propIndex++] = heightMM; - prop[propIndex++] = CGDDGetModeRefreshRate(mode); + prop[propIndex++] = fRefreshRate; prop[propIndex++] = ccwRot; prop[propIndex - NUM_SCREEN_MODE_PROPERTIES_ALL] = ( -1 < mode_idx ) ? propIndex-1 : propIndex ; // count == NUM_SCREEN_MODE_PROPERTIES_ALL - DBG_PRINT( "getScreenMode0: Mode %d/%d (%d): %dx%d, %d bpp, %dx%d mm, %d Hz, rot %d ccw\n", + DBG_PRINT( "getScreenMode0: Mode %d/%d (%d): %dx%d, %d bpp, %dx%d mm, %d / %d Hz, rot %d ccw\n", (int)mode_idx, (int)numberOfAvailableModesRots, (int)numberOfAvailableModes, (int)prop[propIndexRes+0], (int)prop[propIndexRes+1], (int)prop[propIndexRes+2], - (int)prop[propIndexRes+3], (int)prop[propIndexRes+4], (int)prop[propIndexRes+5], (int)prop[propIndexRes+6]); + (int)prop[propIndexRes+3], (int)prop[propIndexRes+4], (int)prop[propIndexRes+5], refreshRate, (int)prop[propIndexRes+6]); jintArray properties = (*env)->NewIntArray(env, prop_num); if (properties == NULL) { @@ -516,6 +524,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0 if(initialized) return JNI_TRUE; initialized = 1; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + jclass c; c = (*env)->FindClass(env, ClazzNamePoint); if(NULL==c) { @@ -537,7 +547,10 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0 // printf("Going to sleep for 10 seconds\n"); // sleep(10); - return (jboolean) [NewtMacWindow initNatives: env forClass: clazz]; + BOOL res = [NewtMacWindow initNatives: env forClass: clazz]; + [pool release]; + + return (jboolean) res; } /* @@ -602,8 +615,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow // Remove animations for child windows if(NULL != parentWindow) { NS_DURING - // Available >= 10.7 - Removes default animations - [myWindow setAnimationBehavior: NSWindowAnimationBehaviorNone]; + if ( [myWindow respondsToSelector:@selector(setAnimationBehavior:)] ) { + // Available >= 10.7 - Removes default animations + [myWindow setAnimationBehavior: NSWindowAnimationBehaviorNone]; + } NS_HANDLER NS_ENDHANDLER } @@ -658,8 +673,12 @@ NS_ENDHANDLER NS_DURING // concurrent view rendering // Available >= 10.6 - Makes the menubar disapear - [myWindow setAllowsConcurrentViewDrawing: YES]; - [myView setCanDrawConcurrently: YES]; + if ( [myWindow respondsToSelector:@selector(setAllowsConcurrentViewDrawing:)] ) { + [myWindow setAllowsConcurrentViewDrawing: YES]; + } + if ( [myView respondsToSelector:@selector(setCanDrawConcurrently:)] ) { + [myView setCanDrawConcurrently: YES]; + } NS_HANDLER NS_ENDHANDLER @@ -669,7 +688,9 @@ NS_ENDHANDLER NS_DURING // Available >= 10.5 - Makes the menubar disapear if(fullscreen) { - [myView enterFullScreenMode: myScreen withOptions:NULL]; + if ( [myView respondsToSelector:@selector(enterFullScreenMode:withOptions:)] ) { + [myView enterFullScreenMode: myScreen withOptions:NULL]; + } } NS_HANDLER NS_ENDHANDLER @@ -730,7 +751,13 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 NS_DURING if(NULL!=mView) { // Available >= 10.5 - Makes the menubar disapear - if([mView isInFullScreenMode]) { + BOOL iifs; + if ( [mView respondsToSelector:@selector(isInFullScreenMode)] ) { + iifs = [mView isInFullScreenMode]; + } else { + iifs = NO; + } + if(iifs && [mView respondsToSelector:@selector(exitFullScreenModeWithOptions:)] ) { [mView exitFullScreenModeWithOptions: NULL]; } // Note: mWin's release will also release it's mView! diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java index 4f24fc9b8..c4b74c56f 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java @@ -50,6 +50,8 @@ public class MovieCubeActivityLauncher0 extends LauncherUtil.BaseActivityLaunche // props.setProperty("jogamp.debug.NativeLibrary", "true"); // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); // props.setProperty("jogamp.debug.IOUtil", "true"); + // props.setProperty("jogamp.debug.Lock", "true"); + // props.setProperty("jogamp.debug.Lock.TraceLock", "true"); // props.setProperty("nativewindow.debug", "all"); props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); // props.setProperty("jogl.debug", "all"); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java index c75c229a8..576305835 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java @@ -14,23 +14,23 @@ public class NEWTGraphUI1pActivityLauncher extends LauncherUtil.BaseActivityLaun final OrderedProperties props = getProperties(); // props.setProperty("jogamp.debug.JNILibLoader", "true"); // props.setProperty("jogamp.debug.NativeLibrary", "true"); - // properties.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); - // properties.setProperty("jogamp.debug.IOUtil", "true"); - // properties.setProperty("nativewindow.debug", "all"); + // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); + // props.setProperty("jogamp.debug.IOUtil", "true"); + // props.setProperty("nativewindow.debug", "all"); props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); - // properties.setProperty("jogl.debug", "all"); - // properties.setProperty("jogl.debug.GLProfile", "true"); + // props.setProperty("jogl.debug", "all"); + // props.setProperty("jogl.debug.GLProfile", "true"); props.setProperty("jogl.debug.GLDrawable", "true"); props.setProperty("jogl.debug.GLContext", "true"); props.setProperty("jogl.debug.GLSLCode", "true"); props.setProperty("jogl.debug.CapabilitiesChooser", "true"); - // properties.setProperty("jogl.debug.GLSLState", "true"); - // properties.setProperty("jogl.debug.DebugGL", "true"); - // properties.setProperty("jogl.debug.TraceGL", "true"); - // properties.setProperty("newt.debug", "all"); + // props.setProperty("jogl.debug.GLSLState", "true"); + // props.setProperty("jogl.debug.DebugGL", "true"); + // props.setProperty("jogl.debug.TraceGL", "true"); + // props.setProperty("newt.debug", "all"); props.setProperty("newt.debug.Window", "true"); - // properties.setProperty("newt.debug.Window.MouseEvent", "true"); - // properties.setProperty("newt.debug.Window.KeyEvent", "true"); + // props.setProperty("newt.debug.Window.MouseEvent", "true"); + // props.setProperty("newt.debug.Window.KeyEvent", "true"); } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java new file mode 100644 index 000000000..eab1a37e3 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java @@ -0,0 +1,128 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.EventQueue; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.DefaultGLCapabilitiesChooser; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLProfile; + +import jogamp.nativewindow.jawt.JAWTUtil; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.common.util.RunnableTask; +import com.jogamp.opengl.test.junit.util.UITestCase; + +public class TestFBOAutoDrawableDeadlockAWT extends UITestCase { + static GLProfile glp; + static int width, height; + + @BeforeClass + public static void initClass() { + glp = GLProfile.getGL2ES2(); + Assert.assertNotNull( glp ); + width = 512; + height = 512; + } + + protected void runTestGL( GLCapabilities caps ) throws InterruptedException, InvocationTargetException { + final GLOffscreenAutoDrawable fbod = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable( + null, + caps, new DefaultGLCapabilitiesChooser(), + 512, 512, + null + ); + + final boolean[] done = {false}; + final Runnable pbufferCreationAction = new Runnable() { + public void run() { + System.err.println("AA.1"); + fbod.display(); + done[ 0 ] = true; + System.err.println("AA.X"); + } + }; + + EventQueue.invokeAndWait(new Runnable() { + public void run() { + Assert.assertTrue(EventQueue.isDispatchThread()); + JAWTUtil.lockToolkit(); + try { + final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false); + System.err.println("BB.0: "+rTask.getSyncObject()); + synchronized (rTask.getSyncObject()) { + System.err.println("BB.1: "+rTask.getSyncObject()); + new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start(); + try { + System.err.println("BB.2"); + rTask.getSyncObject().wait(); + System.err.println("BB.3"); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + System.err.println("BB.X"); + } + } finally { + JAWTUtil.unlockToolkit(); + } + } + }); + Assert.assertTrue(done[0]); + fbod.destroy(); + } + + @Test(timeout = 2000) // 2s timeout + public void testDeadlock() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities( glp ); + runTestGL( caps ); + } + + static long duration = 500; // ms + + public static void main( String args[] ) { + for ( int i = 0; i < args.length; i++ ) { + if ( args[ i ].equals( "-time" ) ) { + i++; + try { + duration = Integer.parseInt( args[ i ] ); + } + catch ( Exception ex ) { + ex.printStackTrace(); + } + } + } + org.junit.runner.JUnitCore.main( TestFBOAutoDrawableDeadlockAWT.class.getName() ); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java new file mode 100644 index 000000000..2dc547f39 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java @@ -0,0 +1,375 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.test.junit.jogl.demos.es2.FBOMix2DemosES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + *

+ * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. + *

+ *

+ * Extensive FBO reconfiguration (size and sample buffer count) and validation are performed. + *

+ */ +public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { + + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + interface MyGLEventListener extends GLEventListener { + void setMakeSnapshot(); + } + + @Test + public void testGL2ES2_Demo1_SingleBuffer_Normal() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setDoubleBuffered(false); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } + + @Test + public void testGL2ES2_Demo1_DoubleBuffer_Normal() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setDoubleBuffered(true); // default + testGLFBODrawableImpl(caps, new GearsES2(0)); + } + + @Test + public void testGL2ES2_Demo2MSAA4() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, new MultisampleDemoES2(true)); + } + + @Test + public void testGL2ES2_FBODemoMSAA4() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0); + demo.setDoRotation(false); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, demo); + } + + @Test + public void testEGLES2_Demo0Normal() throws InterruptedException { + if( GLProfile.isAvailable(GLProfile.GLES2) ) { + final GLProfile glp = GLProfile.get(GLProfile.GLES2); + final GLCapabilities caps = new GLCapabilities(glp); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } else { + System.err.println("EGL ES2 n/a"); + } + } + + @Test + public void testEGLES2_Demo0MSAA4() throws InterruptedException { + if( GLProfile.isAvailable(GLProfile.GLES2) ) { + final GLProfile glp = GLProfile.get(GLProfile.GLES2); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } else { + System.err.println("EGL ES2 n/a"); + } + } + + void testGLFBODrawableImpl(GLCapabilities caps, GLEventListener demo) throws InterruptedException { + caps.setFBO(true); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLOffscreenAutoDrawable.FBO glad = (GLOffscreenAutoDrawable.FBO) + factory.createOffscreenAutoDrawable(null, caps, null, widthStep*szStep, heightStep*szStep, null); + Assert.assertNotNull(glad); + + System.out.println("Realized GLAD: "+glad); + System.out.println("Realized GLAD: "+glad.getChosenGLCapabilities()); + Assert.assertTrue("FBO drawable is initialized before ctx creation", !glad.isInitialized()); + + glad.display(); // initial display incl. init! + { + final GLContext context = glad.getContext(); + Assert.assertNotNull(context); + Assert.assertTrue(context.isCreated()); + } + Assert.assertTrue("FBO drawable is not initialized after ctx creation", glad.isInitialized()); + + // + // FBO incl. MSAA is fully initialized now + // + + final GLCapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); + System.out.println("Init GLAD: "+glad); + System.out.println("Init GLAD: "+chosenCaps); + + final FBObject fboFront = glad.getFBObject(GL.GL_FRONT); + final FBObject fboBack = glad.getFBObject(GL.GL_BACK); + + System.out.println("Init front FBO: "+fboFront); + System.out.println("Init back FBO: "+fboBack); + + Assert.assertTrue("FBO drawable is not initialized before ctx creation", glad.isInitialized()); + Assert.assertTrue("FBO Front is not initialized before ctx creation", fboFront.isInitialized()); + Assert.assertTrue("FBO Back is not initialized before ctx creation", fboBack.isInitialized()); + + if( chosenCaps.getDoubleBuffered() ) { + Assert.assertTrue("FBO are equal: "+fboFront+" == "+fboBack, !fboFront.equals(fboBack)); + Assert.assertNotSame(fboFront, fboBack); + } else { + Assert.assertTrue("FBO are not equal: "+fboFront+" != "+fboBack, fboFront.equals(fboBack)); + Assert.assertSame(fboFront, fboBack); + } + + final FBObject.TextureAttachment texAttachA, texAttachB; + + texAttachA = glad.getTextureBuffer(GL.GL_FRONT); + if(0==glad.getNumSamples()) { + texAttachB = glad.getTextureBuffer(GL.GL_BACK); + } else { + texAttachB = null; + } + + final FBObject.Colorbuffer colorA, colorB; + final FBObject.RenderAttachment depthA, depthB; + + colorA = fboFront.getColorbuffer(0); + Assert.assertNotNull(colorA); + colorB = fboBack.getColorbuffer(0); + Assert.assertNotNull(colorB); + + depthA = fboFront.getDepthAttachment(); + Assert.assertNotNull(depthA); + depthB = fboBack.getDepthAttachment(); + Assert.assertNotNull(depthB); + + glad.display(); // SWAP_ODD + + if( chosenCaps.getDoubleBuffered() ) { + // double buffer or MSAA + Assert.assertTrue("Color attachments are equal: "+colorB+" == "+colorA, !colorB.equals(colorA)); + Assert.assertNotSame(colorB, colorA); + Assert.assertTrue("Depth attachments are equal: "+depthB+" == "+depthA, !depthB.equals(depthA)); + Assert.assertNotSame(depthB, depthA); + } else { + // single buffer + Assert.assertEquals(colorA, colorB); + Assert.assertSame(colorA, colorB); + Assert.assertEquals(depthA, depthB); + Assert.assertSame(depthA, depthB); + } + + Assert.assertEquals(texAttachA, colorA); + Assert.assertSame(texAttachA, colorA); + if(0==glad.getNumSamples()) { + Assert.assertEquals(texAttachB, colorB); + Assert.assertSame(texAttachB, colorB); + } + + if( chosenCaps.getNumSamples() > 0 ) { + // MSAA + FBObject _fboFront = glad.getFBObject(GL.GL_FRONT); + FBObject _fboBack = glad.getFBObject(GL.GL_BACK); + Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboFront, fboFront.equals(_fboFront)); + Assert.assertSame(fboFront, _fboFront); + Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboBack, fboBack.equals(_fboBack)); + Assert.assertSame(fboBack, _fboBack); + } else if( chosenCaps.getDoubleBuffered() ) { + // real double buffer + FBObject _fboFront = glad.getFBObject(GL.GL_FRONT); + FBObject _fboBack = glad.getFBObject(GL.GL_BACK); + Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboFront, fboBack.equals(_fboFront)); + Assert.assertSame(fboBack, _fboFront); + Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront.equals(_fboBack)); + Assert.assertSame(fboFront, _fboBack); + } else { + // single buffer + FBObject _fboFront = glad.getFBObject(GL.GL_FRONT); + FBObject _fboBack = glad.getFBObject(GL.GL_BACK); + Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboFront, fboFront.equals(_fboFront)); + Assert.assertSame(fboFront, _fboFront); + Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboFront, fboBack.equals(_fboFront)); + Assert.assertSame(fboBack, _fboFront); + Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboBack, fboBack.equals(_fboBack)); + Assert.assertSame(fboBack, _fboBack); + Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront.equals(_fboBack)); + Assert.assertSame(fboFront, _fboBack); + } + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // - SWAP_EVEN + + // 1 - szStep = 2 + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); // - SWAP_ODD + + // 2, 3 (resize + display) + szStep = 1; + glad.setSize(widthStep*szStep, heightStep*szStep); // SWAP_EVEN + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); // - SWAP_ODD + glad.display(); // - SWAP_EVEN + { + // Check whether the attachment reference are still valid! + final FBObject _fboFront = glad.getFBObject(GL.GL_FRONT); + final FBObject _fboBack = glad.getFBObject(GL.GL_BACK); + System.out.println("Resize1.oldFront: "+fboFront); + System.out.println("Resize1.nowFront: "+_fboFront); + System.out.println("Resize1.oldBack : "+fboBack); + System.out.println("Resize1.nowBack : "+_fboBack); + Assert.assertEquals(fboFront, _fboFront); + Assert.assertSame(fboFront, _fboFront); + Assert.assertEquals(fboBack, _fboBack); + Assert.assertSame(fboBack, _fboBack); + + FBObject.Colorbuffer _color = _fboFront.getColorbuffer(0); + Assert.assertNotNull(_color); + Assert.assertEquals(colorA, _color); + Assert.assertSame(colorA, _color); + + FBObject.RenderAttachment _depth = _fboFront.getDepthAttachment(); + System.err.println("Resize1.oldDepth "+depthA); + System.err.println("Resize1.newDepth "+_depth); + Assert.assertNotNull(_depth); + + Assert.assertEquals(depthA, _depth); + Assert.assertSame(depthA, _depth); + _depth = _fboBack.getDepthAttachment(); + Assert.assertNotNull(_depth); + Assert.assertEquals(depthB, _depth); + Assert.assertSame(depthB, _depth); + + _color = _fboFront.getColorbuffer(colorA); + Assert.assertNotNull(_color); + Assert.assertEquals(colorA, _color); + Assert.assertSame(colorA, _color); + } + + // 4, 5 (resize + display) + szStep = 4; + glad.setSize(widthStep*szStep, heightStep*szStep); // SWAP_ODD + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); // - SWAP_EVEN + glad.display(); // - SWAP_ODD + { + // Check whether the attachment reference are still valid! + final FBObject _fboFront = glad.getFBObject(GL.GL_FRONT); + final FBObject _fboBack = glad.getFBObject(GL.GL_BACK); + System.out.println("Resize2.oldFront: "+fboFront); + System.out.println("Resize2.nowFront: "+_fboFront); + System.out.println("Resize2.oldBack : "+fboBack); + System.out.println("Resize2.nowBack : "+_fboBack); + if(chosenCaps.getDoubleBuffered() && 0==chosenCaps.getNumSamples()) { + // real double buffer + Assert.assertEquals(fboBack, _fboFront); + Assert.assertEquals(fboFront, _fboBack); + } else { + // single or MSAA + Assert.assertEquals(fboFront, _fboFront); + Assert.assertEquals(fboBack, _fboBack); + } + + FBObject.Colorbuffer _color = fboBack.getColorbuffer(0); + Assert.assertNotNull(_color); + Assert.assertEquals(colorB, _color); + Assert.assertSame(colorB, _color); + + FBObject.RenderAttachment _depth = fboBack.getDepthAttachment(); + Assert.assertNotNull(_depth); // MSAA back w/ depth + Assert.assertEquals(depthB, _depth); + Assert.assertSame(depthB, _depth); + + _depth = fboFront.getDepthAttachment(); + Assert.assertNotNull(_depth); + Assert.assertEquals(depthA, _depth); + Assert.assertSame(depthA, _depth); + + _color = fboBack.getColorbuffer(colorB); + Assert.assertNotNull(_color); + Assert.assertEquals(colorB, _color); + Assert.assertSame(colorB, _color); + } + + // 6 + 7 (samples + display) + glad.setNumSamples(glad.getGL(), chosenCaps.getNumSamples() > 0 ? 0 : 4); // triggers repaint + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); // actual screenshot + + // 8, 9 (resize + samples + display) + szStep = 3; + glad.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + glad.destroy(); + System.out.println("Fin: "+glad); + } + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestFBOAutoDrawableFactoryNEWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java deleted file mode 100644 index 7977347a7..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java +++ /dev/null @@ -1,272 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import java.io.IOException; - -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; - -import jogamp.opengl.GLFBODrawableImpl; - -import org.junit.Assert; -import org.junit.Test; - -import com.jogamp.opengl.FBObject; -import com.jogamp.opengl.OffscreenAutoDrawable; -import com.jogamp.opengl.test.junit.jogl.demos.es2.FBOMix2DemosES2; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.texture.TextureIO; - -public class TestFBODrawableNEWT extends UITestCase { - - static final int widthStep = 800/4; - static final int heightStep = 600/4; - volatile int szStep = 2; - - @Test - public void testGL2ES2_Demo1Normal() throws InterruptedException { - final GLProfile glp = GLProfile.getGL2ES2(); - final GLCapabilities caps = new GLCapabilities(glp); - testGLFBODrawableImpl(caps, new GearsES2(0)); - } - - @Test - public void testGL2ES2_Demo1MSAA4() throws InterruptedException { - final GLProfile glp = GLProfile.getGL2ES2(); - final GLCapabilities caps = new GLCapabilities(glp); - caps.setSampleBuffers(true); - caps.setNumSamples(4); - testGLFBODrawableImpl(caps, new GearsES2(0)); - } - - @Test - public void testGL2ES2_Demo2Normal() throws InterruptedException { - final GLProfile glp = GLProfile.getGL2ES2(); - final GLCapabilities caps = new GLCapabilities(glp); - testGLFBODrawableImpl(caps, new MultisampleDemoES2(false)); - } - - @Test - public void testGL2ES2_Demo2MSAA4() throws InterruptedException { - final GLProfile glp = GLProfile.getGL2ES2(); - final GLCapabilities caps = new GLCapabilities(glp); - caps.setSampleBuffers(true); - caps.setNumSamples(4); - testGLFBODrawableImpl(caps, new MultisampleDemoES2(true)); - } - - @Test - public void testGL2ES2_FBODemoNormal() throws InterruptedException { - final GLProfile glp = GLProfile.getGL2ES2(); - final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0); - demo.setDoRotation(false); - final GLCapabilities caps = new GLCapabilities(glp); - testGLFBODrawableImpl(caps, demo); - } - - @Test - public void testGL2ES2_FBODemoMSAA4() throws InterruptedException { - final GLProfile glp = GLProfile.getGL2ES2(); - final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0); - demo.setDoRotation(false); - final GLCapabilities caps = new GLCapabilities(glp); - caps.setSampleBuffers(true); - caps.setNumSamples(4); - testGLFBODrawableImpl(caps, demo); - } - - @Test - public void testEGLES2_Demo0Normal() throws InterruptedException { - if( GLProfile.isAvailable(GLProfile.GLES2) ) { - final GLProfile glp = GLProfile.get(GLProfile.GLES2); - final GLCapabilities caps = new GLCapabilities(glp); - testGLFBODrawableImpl(caps, new GearsES2(0)); - } else { - System.err.println("EGL ES2 n/a"); - } - } - - @Test - public void testEGLES2_Demo0MSAA4() throws InterruptedException { - if( GLProfile.isAvailable(GLProfile.GLES2) ) { - final GLProfile glp = GLProfile.get(GLProfile.GLES2); - final GLCapabilities caps = new GLCapabilities(glp); - caps.setSampleBuffers(true); - caps.setNumSamples(4); - testGLFBODrawableImpl(caps, new GearsES2(0)); - } else { - System.err.println("EGL ES2 n/a"); - } - } - - boolean skipShot = false; - - void testGLFBODrawableImpl(GLCapabilities caps, GLEventListener demo) throws InterruptedException { - final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); - caps.setFBO(true); - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLDrawable fboDrawable = factory.createOffscreenDrawable(null, caps, null, widthStep*szStep, heightStep*szStep); - Assert.assertNotNull(fboDrawable); - Assert.assertTrue("Not an FBO Drawable", fboDrawable instanceof GLFBODrawableImpl); - - fboDrawable.setRealized(true); - Assert.assertTrue(fboDrawable.isRealized()); - - final FBObject fbo = ((GLFBODrawableImpl)fboDrawable).getFBObject(); - - System.out.println("Realized: "+fboDrawable); - System.out.println("Realized: "+fboDrawable.getChosenGLCapabilities()); - System.out.println("Realized: "+fbo); - - final GLContext context = fboDrawable.createContext(null); - Assert.assertNotNull(context); - - int res = context.makeCurrent(); - Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); - context.release(); - - System.out.println("Post Create-Ctx: "+fbo); - final FBObject.Colorbuffer colorA = fbo.getColorbuffer(0); - Assert.assertNotNull(colorA); - final FBObject.RenderAttachment depthA = fbo.getDepthAttachment(); - Assert.assertNotNull(depthA); - - final OffscreenAutoDrawable glad = new OffscreenAutoDrawable(fboDrawable, context, true); - - glad.addGLEventListener(demo); - glad.addGLEventListener(new GLEventListener() { - volatile int displayCount=0; - volatile int reshapeCount=0; - public void init(GLAutoDrawable drawable) {} - public void dispose(GLAutoDrawable drawable) {} - public void display(GLAutoDrawable drawable) { - final GL gl = drawable.getGL(); - // System.err.println(Thread.currentThread().getName()+": ** display: "+displayCount+": step "+szStep+" "+drawable.getWidth()+"x"+drawable.getHeight()); - // System.err.println(Thread.currentThread().getName()+": ** FBO-THIS: "+fbo); - // System.err.println(Thread.currentThread().getName()+": ** FBO-SINK: "+fbo.getSamplingSinkFBO()); - // System.err.println(Thread.currentThread().getName()+": ** drawable-read: "+gl.getDefaultReadFramebuffer()); - if(skipShot) { - skipShot=false; - } else { - snapshot(getSimpleTestName("."), displayCount, "msaa"+fbo.getNumSamples(), gl, screenshot, TextureIO.PNG, null); - } - Assert.assertEquals(drawable.getWidth(), widthStep*szStep); - Assert.assertEquals(drawable.getHeight(), heightStep*szStep); - displayCount++; - } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - System.err.println(Thread.currentThread().getName()+": ** reshape: "+reshapeCount+": step "+szStep+" "+width+"x"+height+" - "+drawable.getWidth()+"x"+drawable.getHeight()); - Assert.assertEquals(drawable.getWidth(), widthStep*szStep); - Assert.assertEquals(drawable.getHeight(), heightStep*szStep); - reshapeCount++; - } - }); - - // 0 - szStep = 2 - glad.display(); - - // 1, 2 (resize + display) - szStep = 1; - skipShot=true; - glad.setSize(widthStep*szStep, heightStep*szStep); - glad.display(); - Assert.assertEquals(glad.getWidth(), widthStep*szStep); - Assert.assertEquals(glad.getHeight(), heightStep*szStep); - { - // Check whether the attachment reference are still valid! - FBObject.Colorbuffer _colorA = fbo.getColorbuffer(0); - Assert.assertNotNull(_colorA); - Assert.assertTrue(colorA == _colorA); - Assert.assertTrue(colorA.equals(_colorA)); - FBObject.RenderAttachment _depthA = fbo.getDepthAttachment(); - Assert.assertNotNull(_depthA); - Assert.assertTrue(depthA == _depthA); - Assert.assertTrue(depthA.equals(_depthA)); - - _colorA = fbo.getColorbuffer(colorA); - Assert.assertNotNull(_colorA); - Assert.assertTrue(colorA == _colorA); - Assert.assertTrue(colorA.equals(_colorA)); - } - - // 3, 4 (resize + display) - szStep = 4; - skipShot=true; - glad.setSize(widthStep*szStep, heightStep*szStep); - glad.display(); - Assert.assertEquals(glad.getWidth(), widthStep*szStep); - Assert.assertEquals(glad.getHeight(), heightStep*szStep); - { - // Check whether the attachment reference are still valid! - FBObject.Colorbuffer _colorA = fbo.getColorbuffer(0); - Assert.assertNotNull(_colorA); - Assert.assertTrue(colorA == _colorA); - final FBObject.RenderAttachment _depthA = fbo.getDepthAttachment(); - Assert.assertNotNull(_depthA); - Assert.assertTrue(depthA == _depthA); - - _colorA = fbo.getColorbuffer(colorA); - Assert.assertNotNull(_colorA); - Assert.assertTrue(colorA == _colorA); - } - - // 5 - glad.display(); - Assert.assertEquals(glad.getWidth(), widthStep*szStep); - Assert.assertEquals(glad.getHeight(), heightStep*szStep); - - // 6, 7 (resize + display) - szStep = 3; - skipShot=true; - glad.setSize(widthStep*szStep, heightStep*szStep); - glad.display(); - Assert.assertEquals(glad.getWidth(), widthStep*szStep); - Assert.assertEquals(glad.getHeight(), heightStep*szStep); - - glad.destroy(); - System.out.println("Fin: "+fboDrawable); - - // final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(fboDrawable, context); - } - - public static void main(String args[]) throws IOException { - org.junit.runner.JUnitCore.main(TestFBODrawableNEWT.class.getName()); - } - -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java index f7c83a03b..077baad43 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java @@ -229,7 +229,7 @@ public class TestFBOMRTNEWT01 extends UITestCase { final NativeSurface ns = gl.getContext().getGLReadDrawable().getNativeSurface(); if(last_snap_size[0] != ns.getWidth() && last_snap_size[1] != ns.getHeight()) { gl.glFinish(); // sync .. no swap buffers yet! - snapshot(getSimpleTestName("."), step_i, null, gl, screenshot, TextureIO.PNG, null); // overwrite ok + snapshot(step_i, null, gl, screenshot, TextureIO.PNG, null); // overwrite ok last_snap_size[0] = ns.getWidth(); last_snap_size[1] = ns.getHeight(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java index b384c9327..b3c542c63 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java @@ -106,7 +106,7 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase { if(dw<800) { System.err.println("XXX: "+dw+"x"+dh+", c "+c); if(0 == c%3) { - snapshot(getSimpleTestName("."), i++, "msaa"+demo.getMSAA(), drawable.getGL(), screenshot, TextureIO.PNG, null); + snapshot(i++, "msaa"+demo.getMSAA(), drawable.getGL(), screenshot, TextureIO.PNG, null); } if( 3 == c ) { new Thread() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java new file mode 100644 index 000000000..3ecf89bfc --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java @@ -0,0 +1,298 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.util.QuitAdapter; + +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.FPSAnimator; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.Mix2TexturesES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.SurfaceUpdatedListener; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.AfterClass; +import org.junit.Test; + +/** + * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + *

+ * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. + *

+ *

+ * This test simulates shared off-thread GL context / texture usage, + * where the producer use FBOs and delivers shared textures. + * The receiver blends the shared textures onscreen. + * In detail the test consist of: + *

    + *
  • 2 {@link GLOffscreenAutoDrawable.FBO} double buffered + *
      + *
    • each with their own {@link GLContext}, which is shares the {@link GLWindow} one (see below)
    • + *
    • both run within one {@link FPSAnimator} @ 30fps
    • + *
    • produce a texture
    • + *
    • notify the onscreen renderer about new textureID (swapping double buffer)
    • + *
  • + *
  • 1 onscreen {@link GLWindow} + *
      + *
    • shares it's {@link GLContext} w/ above FBOs
    • + *
    • running within one {@link Animator} at v-sync
    • + *
    • uses the shared FBO textures and blends them onscreen
    • + *
  • + *
+ *

+ */ +public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { + static long duration = 500; // ms + static int swapInterval = 1; + static boolean showFPS = false; + static boolean forceES2 = false; + static boolean mainRun = false; + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); + System.err.println("requested: vsync "+swapInterval+", "+caps); + + final GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval); + if(mainRun) { + glWindow.setSize(512, 512); + } else { + glWindow.setSize(256, 256); + } + // eager initialization of context + glWindow.setVisible(true); + glWindow.display(); + + final int fbod1_texUnit = 0; + final int fbod2_texUnit = 1; + + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + GLCapabilities fbodCaps = (GLCapabilities) caps.cloneMutable(); + // fbodCaps.setDoubleBuffered(false); + + final Mix2TexturesES2 mixerDemo = new Mix2TexturesES2(1, fbod1_texUnit, fbod2_texUnit); + + // FBOD1 + final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO) + factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); + fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen! + fbod1.setTextureUnit(fbod1_texUnit); + { + GearsES2 demo0 = new GearsES2(-1); + fbod1.addGLEventListener(demo0); + demo0.setIgnoreFocus(true); + } + fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { + @Override + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { + mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName()); + } }); + fbod1.display(); // init + System.err.println("FBOD1 "+fbod1); + Assert.assertTrue(fbod1.isInitialized()); + + // FBOD2 + final GLOffscreenAutoDrawable.FBO fbod2 = (GLOffscreenAutoDrawable.FBO) + factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); + fbod2.setTextureUnit(fbod2_texUnit); + fbod2.addGLEventListener(new RedSquareES2(-1)); + fbod2.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { + @Override + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { + mixerDemo.setTexID1(fbod2.getTextureBuffer(GL.GL_FRONT).getName()); + } }); + fbod2.display(); // init + System.err.println("FBOD2 "+fbod2); + Assert.assertTrue(fbod2.isInitialized()); + + // preinit texIDs + mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName()); + mixerDemo.setTexID1(fbod2.getTextureBuffer(GL.GL_FRONT).getName()); + + glWindow.addGLEventListener(mixerDemo); + glWindow.addGLEventListener(new GLEventListener() { + int i=0, c=0; + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + if(mainRun) return; + + final int dw = drawable.getWidth(); + final int dh = drawable.getHeight(); + c++; + + if(dw<800) { + System.err.println("XXX: "+dw+"x"+dh+", c "+c); + if(8 == c) { + snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null); + } + if(9 == c) { + c=0; + new Thread() { + @Override + public void run() { + glWindow.setSize(dw+256, dh+256); + } }.start(); + } + } + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + fbod1.setSize(width, height); + fbod2.setSize(width, height); + } + }); + + final FPSAnimator animator0 = new FPSAnimator(30); + animator0.add(fbod1); + animator0.add(fbod2); + + final Animator animator1 = new Animator(); + animator1.add(glWindow); + + QuitAdapter quitAdapter = new QuitAdapter(); + + //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); + //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + glWindow.addKeyListener(quitAdapter); + glWindow.addWindowListener(quitAdapter); + + glWindow.addWindowListener(new WindowAdapter() { + public void windowResized(WindowEvent e) { + System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + public void windowMoved(WindowEvent e) { + System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + }); + + animator0.start(); + animator1.start(); + // glWindow.setSkipContextReleaseThread(animator.getThread()); + + glWindow.setVisible(true); + + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); + System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); + System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + + animator0.setUpdateFPSFrames(30, showFPS ? System.err : null); + animator1.setUpdateFPSFrames(60, showFPS ? System.err : null); + + while(!quitAdapter.shouldQuit() && animator1.isAnimating() && animator1.getTotalFPSDuration() + * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. + *

+ *

+ * This test simulates shared on-thread GL context / texture usage, + * where the producer uses an FBO and delivers a shared texture. + * The receiver draws the shared texture onscreen. + * In detail the test consist of: + *

    + *
  • 1 {@link GLOffscreenAutoDrawable.FBO} double buffered + *
      + * + *
    • running within common {@link Animator} @ 60fps
    • + *
    • produce a texture
    • + *
    • notify the onscreen renderer about new textureID (swapping double buffer)
    • + *
  • + *
  • 1 onscreen {@link GLWindow} + *
      + *
    • shares it's {@link GLContext} w/ above FBO
    • + *
    • running within common {@link Animator} @ 60fps
    • + *
    • uses the shared FBO texture and draws it onscreen
    • + *
  • + *
+ *

+ */ +public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { + static long duration = 500; // ms + static int swapInterval = 1; + static boolean showFPS = false; + static boolean forceES2 = false; + static boolean mainRun = false; + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); + System.err.println("requested: vsync "+swapInterval+", "+caps); + + final GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval); + if(mainRun) { + glWindow.setSize(512, 512); + } else { + glWindow.setSize(256, 256); + } + // eager initialization of context + glWindow.setVisible(true); + glWindow.display(); + + final int fbod1_texUnit = 0; + + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + GLCapabilities fbodCaps = (GLCapabilities) caps.cloneMutable(); + // fbodCaps.setDoubleBuffered(false); + + final Mix2TexturesES2 mixerDemo = new Mix2TexturesES2(1, fbod1_texUnit, 0); + + // FBOD1 + final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO) + factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); + fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen! + fbod1.setTextureUnit(fbod1_texUnit); + { + GearsES2 demo0 = new GearsES2(-1); + fbod1.addGLEventListener(demo0); + demo0.setIgnoreFocus(true); + } + fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { + @Override + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { + mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName()); + } }); + fbod1.display(); // init + System.err.println("FBOD1 "+fbod1); + Assert.assertTrue(fbod1.isInitialized()); + + // preinit texIDs + mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName()); + + glWindow.addWindowListener(new WindowAdapter() { + @Override + public void windowResized(WindowEvent e) { + fbod1.setSize(glWindow.getWidth(), glWindow.getHeight()); + } + }); + glWindow.addGLEventListener(mixerDemo); + glWindow.addGLEventListener(new GLEventListener() { + int i=0, c=0; + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + if(mainRun) return; + + final int dw = drawable.getWidth(); + final int dh = drawable.getHeight(); + c++; + + if(dw<800) { + System.err.println("XXX: "+dw+"x"+dh+", c "+c); + if(8 == c) { + snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null); + } + if(9 == c) { + c=0; + new Thread() { + @Override + public void run() { + glWindow.setSize(dw+256, dh+256); + } }.start(); + } + } + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + + final Animator animator1 = new Animator(); + animator1.add(fbod1); + animator1.add(glWindow); + + QuitAdapter quitAdapter = new QuitAdapter(); + + //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); + //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + glWindow.addKeyListener(quitAdapter); + glWindow.addWindowListener(quitAdapter); + + glWindow.addWindowListener(new WindowAdapter() { + public void windowResized(WindowEvent e) { + System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + public void windowMoved(WindowEvent e) { + System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + }); + + animator1.start(); + // glWindow.setSkipContextReleaseThread(animator.getThread()); + + glWindow.setVisible(true); + + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); + System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); + System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + + animator1.setUpdateFPSFrames(60, showFPS ? System.err : null); + + while(!quitAdapter.shouldQuit() && animator1.isAnimating() && animator1.getTotalFPSDuration() + * Each test creates a {@link GLDrawable} using the + * {@link GLDrawableFactory#createGLDrawable(javax.media.nativewindow.NativeSurface) factory model}. + * The {@link GLContext} is derived {@link GLDrawable#createContext(GLContext) from the drawable}. + *

+ *

+ * Finally a {@link GLAutoDrawableDelegate} is created with the just created {@link GLDrawable} and {@link GLContext}. + * It is being used to run the {@link GLEventListener}. + *

+ */ +public class TestGLAutoDrawableDelegateOnOffscrnCapsNEWT extends UITestCase { + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + System.out.println("Requested GL Caps: "+reqGLCaps); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); + final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + System.out.println("Expected GL Caps: "+expGLCaps); + // + // Create native windowing resources .. X11/Win/OSX + // + final Window window = NewtFactory.createWindow(reqGLCaps); + Assert.assertNotNull(window); + window.setSize(widthStep*szStep, heightStep*szStep); + window.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); + System.out.println("Window: "+window.getClass().getName()); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = window.getGraphicsConfiguration().getChosenCapabilities(); + System.out.println("Window Caps Pre_GL: "+chosenCaps); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>5); + Assert.assertTrue(chosenCaps.getBlueBits()>5); + Assert.assertTrue(chosenCaps.getRedBits()>5); + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + final GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + System.out.println("Drawable Pre-GL(0): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); + + // + drawable.setRealized(true); + Assert.assertTrue(drawable.isRealized()); + + System.out.println("Window Caps PostGL : "+window.getGraphicsConfiguration().getChosenCapabilities()); + System.out.println("Drawable Post-GL(1): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = drawable.getChosenGLCapabilities(); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>5); + Assert.assertTrue(chosenGLCaps.getBlueBits()>5); + Assert.assertTrue(chosenGLCaps.getRedBits()>5); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); + Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); + Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); + /** Single/Double buffer cannot be checked since result may vary .. + if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { + // dbl buffer may be disabled w/ offscreen pbuffer and bitmap + Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); + } */ + + GLContext context = drawable.createContext(null); + Assert.assertNotNull(context); + int res = context.makeCurrent(); + Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); + context.release(); + + System.out.println("Chosen GL Caps(2): "+drawable.getChosenGLCapabilities()); + System.out.println("Chosen GL CTX (2): "+context.getGLVersion()); + System.out.println("Drawable Post-GL(2): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false, null) { + @Override + protected void destroyImplInLock() { + super.destroyImplInLock(); // destroys drawable/context + window.destroy(); // destroys the actual window, incl. the device + } + }; + + window.addWindowListener(new WindowAdapter() { + @Override + public void windowRepaint(WindowUpdateEvent e) { + glad.windowRepaintOp(); + } + + @Override + public void windowResized(WindowEvent e) { + glad.windowResizedOp(window.getWidth(), window.getHeight()); + } + + @Override + public void windowDestroyNotify(WindowEvent e) { + glad.windowDestroyNotifyOp(); + } + }); + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // initial resize/display + + // 1 - szStep = 2 + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 2, 3 (resize + display) + szStep = 1; + window.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 4, 5 (resize + display) + szStep = 4; + window.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + Thread.sleep(50); + + glad.destroy(); + System.out.println("Fin Drawable: "+drawable); + System.out.println("Fin Window: "+window); + } + + @Test + public void testAvailableInfo() { + GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + f = GLDrawableFactory.getEGLFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + } + + @Test + public void testGL2OnScreenDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OnScreenSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBODblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new Gears(1)); + } + + @Test + public void testGL2OffScreenBitmapSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new Gears(1)); + } + + @Test + public void testES2OnScreenDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OnScreenSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBODblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + /** Not implemented ! + @Test + public void testES2OffScreenBitmapDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GLES2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new GearsES2(1)); + } */ + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java new file mode 100644 index 000000000..544d74aa5 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java @@ -0,0 +1,317 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLProfile; + +import jogamp.opengl.GLGraphicsConfigurationUtil; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + *

+ * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. + *

+ */ +public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase { + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + System.out.println("Requested GL Caps: "+reqGLCaps); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); + final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + System.out.println("Expected GL Caps: "+expGLCaps); + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null); + + Assert.assertNotNull(glad); + System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + Assert.assertTrue(glad.isRealized()); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); + System.out.println("Drawable Caps Pre_GL : "+chosenCaps); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>5); + Assert.assertTrue(chosenCaps.getBlueBits()>5); + Assert.assertTrue(chosenCaps.getRedBits()>5); + + glad.display(); // force native context creation + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities(); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + System.out.println("Chosen GL CTX (1): "+glad.getContext().getGLVersion()); + + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>5); + Assert.assertTrue(chosenGLCaps.getBlueBits()>5); + Assert.assertTrue(chosenGLCaps.getRedBits()>5); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); + Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); + Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); + /** Single/Double buffer cannot be checked since result may vary .. + if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { + // dbl buffer may be disabled w/ offscreen pbuffer and bitmap + Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); + } */ + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // initial resize/display + + // 1 - szStep = 2 + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 2, 3 (resize + display) + szStep = 1; + glad.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 4, 5 (resize + display) + szStep = 4; + glad.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + Thread.sleep(50); + + glad.destroy(); + System.out.println("Fin Drawable: "+glad); + } + + @Test + public void testAvailableInfo() { + GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + f = GLDrawableFactory.getEGLFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + } + + @Test + public void testGL2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBODblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOStencil() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setStencilBits(1); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOStencilMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setStencilBits(1); + reqGLCaps.setSampleBuffers(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new Gears(1)); + } + + @Test + public void testGL2OffScreenBitmapSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new Gears(1)); + } + + @Test + public void testES2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBODblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + /** Not implemented ! + @Test + public void testES2OffScreenBitmapDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GLES2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new GearsES2(1)); + } */ + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryOffscrnCapsNEWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java new file mode 100644 index 000000000..64a75716b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java @@ -0,0 +1,328 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.Dimension; +import java.awt.Frame; +import java.io.IOException; + +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; + +import jogamp.nativewindow.jawt.JAWTUtil; +import jogamp.opengl.GLGraphicsConfigurationUtil; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Tests using a NEWT {@link GLWindow} {@link GLAutoDrawable auto drawable} for on- and offscreen cases. + *

+ * The NEWT {@link GLAutoDrawable} is being used to run the {@link GLEventListener}. + *

+ */ +public class TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT extends UITestCase { + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + static void setGLCanvasSize(final Frame frame, final GLCanvas glc, final int width, final int height) { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + final Dimension new_sz = new Dimension(width, height); + glc.setMinimumSize(new_sz); + glc.setPreferredSize(new_sz); + glc.setSize(new_sz); + frame.pack(); + frame.validate(); + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + static interface MyGLEventListener extends GLEventListener { + void setMakeSnapshot(); + } + + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + if(reqGLCaps.isOnscreen() && JAWTUtil.isOffscreenLayerRequired()) { + System.err.println("onscreen layer n/a"); + return; + } + if(!reqGLCaps.isOnscreen() && !JAWTUtil.isOffscreenLayerSupported()) { + System.err.println("offscreen layer n/a"); + return; + } + System.out.println("Requested GL Caps: "+reqGLCaps); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); + final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + System.out.println("Expected GL Caps: "+expGLCaps); + // + // Create native windowing resources .. X11/Win/OSX + // + final GLCanvas glad = new GLCanvas(reqGLCaps); // will implicit trigger offscreen layer - if !onscreen && supported + Assert.assertNotNull(glad); + Dimension glc_sz = new Dimension(widthStep*szStep, heightStep*szStep); + glad.setMinimumSize(glc_sz); + glad.setPreferredSize(glc_sz); + glad.setSize(glc_sz); + final Frame frame = new Frame(getSimpleTestName(".")); + Assert.assertNotNull(frame); + frame.add(glad); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + + Assert.assertTrue(AWTRobotUtil.waitForVisible(glad, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glad, true)); + System.out.println("Window: "+glad.getClass().getName()); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); + System.out.println("Window Caps Pre_GL: "+chosenCaps); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>5); + Assert.assertTrue(chosenCaps.getBlueBits()>5); + Assert.assertTrue(chosenCaps.getRedBits()>5); + + glad.display(); // force native context creation + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + { + final GLDrawable actualDrawable = glad.getDelegatedDrawable(); + Assert.assertNotNull(actualDrawable); + System.out.println("Drawable Pre-GL(0): "+actualDrawable.getClass().getName()+", "+actualDrawable.getNativeSurface().getClass().getName()); + } + + System.out.println("Window Caps PostGL : "+glad.getChosenGLCapabilities()); + System.out.println("Drawable Post-GL(1): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities(); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>5); + Assert.assertTrue(chosenGLCaps.getBlueBits()>5); + Assert.assertTrue(chosenGLCaps.getRedBits()>5); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); + Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); + Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); + /** Single/Double buffer cannot be checked since result may vary .. + if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { + // dbl buffer may be disabled w/ offscreen pbuffer and bitmap + Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); + } */ + + { + GLContext context = glad.getContext(); + System.out.println("Chosen GL CTX (2): "+context.getGLVersion()); + Assert.assertNotNull(context); + Assert.assertTrue(context.isCreated()); + } + + System.out.println("Chosen GL Caps(2): "+glad.getChosenGLCapabilities()); + System.out.println("Drawable Post-GL(2): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // initial resize/display + + // 1 - szStep = 2 + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 2, 3 (resize + display) + szStep = 1; + setGLCanvasSize(frame, glad, widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + glad.display(); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 4, 5 (resize + display) + szStep = 4; + setGLCanvasSize(frame, glad, widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + glad.display(); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + Thread.sleep(50); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + frame.remove(glad); + frame.dispose(); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + System.out.println("Fin: "+glad); + } + + @Test + public void testAvailableInfo() { + GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + f = GLDrawableFactory.getEGLFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + } + + @Test + public void testGL2OnScreen() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenAuto() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbuffer() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OnScreen() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenAuto() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBOMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbuffer() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java new file mode 100644 index 000000000..37ec44566 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java @@ -0,0 +1,351 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import jogamp.opengl.GLGraphicsConfigurationUtil; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Tests using a NEWT {@link GLWindow} {@link GLAutoDrawable auto drawable} for on- and offscreen cases. + *

+ * The NEWT {@link GLAutoDrawable} is being used to run the {@link GLEventListener}. + *

+ */ +public class TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT extends UITestCase { + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + static interface MyGLEventListener extends GLEventListener { + void setMakeSnapshot(); + } + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + System.out.println("Requested GL Caps: "+reqGLCaps); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); + final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + System.out.println("Expected GL Caps: "+expGLCaps); + // + // Create native windowing resources .. X11/Win/OSX + // + final GLWindow glad = GLWindow.create(reqGLCaps); + Assert.assertNotNull(glad); + glad.setSize(widthStep*szStep, heightStep*szStep); + glad.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(glad, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glad, true)); + System.out.println("Window: "+glad.getClass().getName()); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = glad.getGraphicsConfiguration().getChosenCapabilities(); + System.out.println("Window Caps Pre_GL: "+chosenCaps); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>5); + Assert.assertTrue(chosenCaps.getBlueBits()>5); + Assert.assertTrue(chosenCaps.getRedBits()>5); + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + { + final GLDrawable actualDrawable = glad.getDelegatedDrawable(); + Assert.assertNotNull(actualDrawable); + System.out.println("Drawable Pre-GL(0): "+actualDrawable.getClass().getName()+", "+actualDrawable.getNativeSurface().getClass().getName()); + } + + System.out.println("Window Caps PostGL : "+glad.getGraphicsConfiguration().getChosenCapabilities()); + System.out.println("Drawable Post-GL(1): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities(); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>5); + Assert.assertTrue(chosenGLCaps.getBlueBits()>5); + Assert.assertTrue(chosenGLCaps.getRedBits()>5); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); + Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); + Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); + /** Single/Double buffer cannot be checked since result may vary .. + if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { + // dbl buffer may be disabled w/ offscreen pbuffer and bitmap + Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); + } */ + + glad.display(); + { + GLContext context = glad.getContext(); + System.out.println("Chosen GL CTX (2): "+context.getGLVersion()); + Assert.assertNotNull(context); + Assert.assertTrue(context.isCreated()); + } + + System.out.println("Chosen GL Caps(2): "+glad.getChosenGLCapabilities()); + System.out.println("Drawable Post-GL(2): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // initial resize/display + + // 1 - szStep = 2 + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 2, 3 (resize + display) + szStep = 1; + glad.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 4, 5 (resize + display) + szStep = 4; + glad.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + Thread.sleep(50); + + glad.destroy(); + System.out.println("Fin: "+glad); + } + + @Test + public void testAvailableInfo() { + GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + f = GLDrawableFactory.getEGLFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + } + + @Test + public void testGL2OnScreenDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OnScreenSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBODblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new Gears(1)); + } + + @Test + public void testGL2OffScreenBitmapSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new Gears(1)); + } + + @Test + public void testES2OnScreenDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OnScreenSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBODblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + /** Not implemented ! + @Test + public void testES2OffScreenBitmapDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GLES2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new GearsES2(1)); + } */ + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java new file mode 100644 index 000000000..47fc99844 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java @@ -0,0 +1,300 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; +import java.io.IOException; + +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import jogamp.nativewindow.jawt.JAWTUtil; +import jogamp.opengl.GLGraphicsConfigurationUtil; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Tests using a NEWT {@link GLWindow} {@link GLAutoDrawable auto drawable} for on- and offscreen cases. + *

+ * The NEWT {@link GLAutoDrawable} is being used to run the {@link GLEventListener}. + *

+ */ +public class TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT extends UITestCase { + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + static void setComponentSize(final Frame frame, final Component comp, final int width, final int height) { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + final Dimension new_sz = new Dimension(width, height); + comp.setMinimumSize(new_sz); + comp.setPreferredSize(new_sz); + comp.setSize(new_sz); + frame.pack(); + frame.validate(); + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + static interface MyGLEventListener extends GLEventListener { + void setMakeSnapshot(); + } + + void doTest(boolean offscreenLayer, GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { + System.err.println("onscreen layer n/a"); + return; + } + if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { + System.err.println("offscreen layer n/a"); + return; + } + System.out.println("Requested GL Caps: "+reqGLCaps); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); + final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); + final GLCapabilitiesImmutable expGLCaps = offscreenLayer ? + GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable) : + GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + System.out.println("Expected GL Caps: "+expGLCaps); + + final GLWindow glad = GLWindow.create(reqGLCaps); + Assert.assertNotNull(glad); + + + final NewtCanvasAWT nca = new NewtCanvasAWT(glad); + Assert.assertNotNull(nca); + Dimension size0 = new Dimension(widthStep*szStep, heightStep*szStep); + nca.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported + nca.setPreferredSize(size0); + nca.setMinimumSize(size0); + nca.setSize(size0); + + final Frame frame = new Frame(getSimpleTestName(".")); + Assert.assertNotNull(frame); + frame.add(nca); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + + Assert.assertTrue(AWTRobotUtil.waitForVisible(glad, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glad, true)); + System.out.println("Window: "+glad.getClass().getName()); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); + System.out.println("Window Caps Pre_GL: "+chosenCaps); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>5); + Assert.assertTrue(chosenCaps.getBlueBits()>5); + Assert.assertTrue(chosenCaps.getRedBits()>5); + + glad.display(); // force native context creation + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + { + final GLDrawable actualDrawable = glad.getDelegatedDrawable(); + Assert.assertNotNull(actualDrawable); + System.out.println("Drawable Pre-GL(0): "+actualDrawable.getClass().getName()+", "+actualDrawable.getNativeSurface().getClass().getName()); + } + + System.out.println("Window Caps PostGL : "+glad.getChosenGLCapabilities()); + System.out.println("Drawable Post-GL(1): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities(); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>5); + Assert.assertTrue(chosenGLCaps.getBlueBits()>5); + Assert.assertTrue(chosenGLCaps.getRedBits()>5); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); + Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); + Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); + /** Single/Double buffer cannot be checked since result may vary .. + if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { + // dbl buffer may be disabled w/ offscreen pbuffer and bitmap + Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); + } */ + + { + GLContext context = glad.getContext(); + System.out.println("Chosen GL CTX (2): "+context.getGLVersion()); + Assert.assertNotNull(context); + Assert.assertTrue(context.isCreated()); + } + + System.out.println("Chosen GL Caps(2): "+glad.getChosenGLCapabilities()); + System.out.println("Drawable Post-GL(2): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // initial resize/display + + // 1 - szStep = 2 + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 2, 3 (resize + display) + szStep = 1; + setComponentSize(frame, nca, widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + glad.display(); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 4, 5 (resize + display) + szStep = 4; + setComponentSize(frame, nca, widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + glad.display(); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + Thread.sleep(50); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + frame.remove(nca); + frame.dispose(); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + glad.destroy(); + System.out.println("Fin: "+nca); + System.out.println("Fin: "+glad); + } + + @Test + public void testAvailableInfo() { + GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + f = GLDrawableFactory.getEGLFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + } + + @Test + public void testGL2OnScreenDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + doTest(false, reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenLayerAuto() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + doTest(true, reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setFBO(true); + reqGLCaps.setOnscreen(true); // get native NEWT Window, not OffscreenWindow + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(true, reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbuffer() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setPBuffer(true); + reqGLCaps.setOnscreen(true); // get native NEWT Window, not OffscreenWindow + doTest(true, reqGLCaps, new GearsES2(1)); + } + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java deleted file mode 100644 index cd1107e25..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java +++ /dev/null @@ -1,266 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import java.io.IOException; - -import javax.media.nativewindow.CapabilitiesImmutable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; - -import jogamp.opengl.GLGraphicsConfigurationUtil; - -import org.junit.Assert; -import org.junit.Test; - -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Window; -import com.jogamp.opengl.JoglVersion; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.UITestCase; - -public class TestGLCapabilities01NEWT extends UITestCase { - static final int width = 100; - static final int height = 100; - - boolean checkProfile(String profile) { - if( !GLProfile.isAvailable(profile) ) { - System.err.println("Profile "+profile+" n/a"); - return false; - } - return true; - } - - void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { - System.out.println("Requested GL Caps: "+reqGLCaps); - - final GLCapabilitiesImmutable expGLCaps; - if( GLGraphicsConfigurationUtil.isGLCapabilitiesOffscreenAutoSelection(reqGLCaps) ) { - final GLDrawableFactory f = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); - final boolean fboAvailable = true ; // f.canCreateFBO(null, reqGLCaps.getGLProfile()); - final boolean pbufferAvailable = f.canCreateGLPbuffer(null); - expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); - } else { - expGLCaps = reqGLCaps; - } - System.out.println("Expected GL Caps: "+expGLCaps); - // - // Create native windowing resources .. X11/Win/OSX - // - final Window window = NewtFactory.createWindow(reqGLCaps); - Assert.assertNotNull(window); - window.setSize(width, height); - window.setVisible(true); - Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); - System.out.println("Window: "+window.getClass().getName()); - - // Check caps of NativeWindow config w/o GL - final CapabilitiesImmutable chosenCaps = window.getGraphicsConfiguration().getChosenCapabilities(); - System.out.println("Window Caps Pre_GL: "+chosenCaps); - Assert.assertNotNull(chosenCaps); - Assert.assertTrue(chosenCaps.getGreenBits()>5); - Assert.assertTrue(chosenCaps.getBlueBits()>5); - Assert.assertTrue(chosenCaps.getRedBits()>5); - - // - // Create native OpenGL resources .. XGL/WGL/CGL .. - // equivalent to GLAutoDrawable methods: setVisible(true) - // - final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); - - final GLDrawable drawable = factory.createGLDrawable(window); - Assert.assertNotNull(drawable); - System.out.println("Drawable Pre-GL(0): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); - - // - drawable.setRealized(true); - Assert.assertTrue(drawable.isRealized()); - - System.out.println("Window Caps PostGL : "+window.getGraphicsConfiguration().getChosenCapabilities()); - System.out.println("Drawable Post-GL(1): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); - - // Check caps of GLDrawable after realization - final GLCapabilitiesImmutable chosenGLCaps = drawable.getChosenGLCapabilities(); - System.out.println("Chosen GL Caps(1): "+chosenGLCaps); - Assert.assertNotNull(chosenGLCaps); - Assert.assertTrue(chosenGLCaps.getGreenBits()>5); - Assert.assertTrue(chosenGLCaps.getBlueBits()>5); - Assert.assertTrue(chosenGLCaps.getRedBits()>5); - Assert.assertTrue(chosenGLCaps.getDepthBits()>4); - Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); - Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); - Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); - Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); - if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { - // dbl buffer may be disabled w/ offscreen pbuffer and bitmap - Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); - } - - GLContext context = drawable.createContext(null); - Assert.assertNotNull(context); - int res = context.makeCurrent(); - Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); - context.release(); - - System.out.println("Chosen GL Caps(2): "+drawable.getChosenGLCapabilities()); - System.out.println("Drawable Post-GL(2): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); - - drawable.setRealized(false); - window.destroy(); - } - - @Test - public void testAvailableInfo() { - GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); - if(null != f) { - System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); - } - f = GLDrawableFactory.getEGLFactory(); - if(null != f) { - System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); - } - } - - @Test - public void testGL2OnScreenDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GL2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testGL2OffScreenAutoDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GL2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); - reqGLCaps.setOnscreen(false); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testGL2OffScreenFBODblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GL2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); - reqGLCaps.setOnscreen(false); - reqGLCaps.setFBO(true); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testGL2OffScreenPbufferDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GL2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); - reqGLCaps.setOnscreen(false); - reqGLCaps.setPBuffer(true); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GL2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); - reqGLCaps.setOnscreen(false); - reqGLCaps.setBitmap(true); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testES2OnScreenDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GLES2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testES2OffScreenAutoDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GLES2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); - reqGLCaps.setOnscreen(false); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testES2OffScreenFBODblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GLES2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); - reqGLCaps.setOnscreen(false); - reqGLCaps.setFBO(true); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testES2OffScreenPbufferDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GLES2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); - reqGLCaps.setOnscreen(false); - reqGLCaps.setPBuffer(true); - doTest(reqGLCaps, new GearsES2(1)); - } - - /** Not implemented ! - @Test - public void testES2OffScreenBitmapDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GLES2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); - reqGLCaps.setOnscreen(false); - reqGLCaps.setBitmap(true); - doTest(reqGLCaps, new GearsES2(1)); - } */ - - public static void main(String args[]) throws IOException { - org.junit.runner.JUnitCore.main(TestGLCapabilities01NEWT.class.getName()); - } - -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java index cece4c6d5..4c1130498 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java @@ -39,13 +39,14 @@ import com.jogamp.newt.event.WindowUpdateEvent; import com.jogamp.newt.opengl.GLWindow; import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLAutoDrawableDelegate; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.GLAutoDrawableDelegate; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -81,14 +82,17 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); - GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - GLDrawable drawable = factory.createGLDrawable(window); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLDrawable drawable = factory.createGLDrawable(window); Assert.assertNotNull(drawable); drawable.setRealized(true); Assert.assertTrue(drawable.isRealized()); - final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false) { + final GLContext context = drawable.createContext(null); + Assert.assertNotNull(context); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false, null) { @Override protected void destroyImplInLock() { super.destroyImplInLock(); @@ -104,7 +108,7 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { } @Override public void windowResized(WindowEvent e) { - glad.windowResizedOp(); + glad.windowResizedOp(window.getWidth(), window.getHeight()); } @Override public void windowDestroyNotify(WindowEvent e) { @@ -123,9 +127,13 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter); // no GLContext! GLAutoDrawable glad2 = createGLAutoDrawable(caps, 2*64+width, 64, width+100, height+100, quitAdapter); // no GLContext! - // create single context using glad1 and assign it to glad1 + // create single context using glad1 and assign it to glad1, + // after destroying the prev. context! { - GLContext singleCtx = glad1.createContext(null); + final GLContext oldCtx = glad1.getContext(); + Assert.assertNotNull(oldCtx); + oldCtx.destroy(); + final GLContext singleCtx = glad1.createContext(null); Assert.assertNotNull(singleCtx); int res = singleCtx.makeCurrent(); Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java deleted file mode 100644 index a6e9cfb07..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import java.io.IOException; - -import javax.media.nativewindow.CapabilitiesImmutable; -import javax.media.opengl.GL; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLProfile; - -import org.junit.Assert; -import org.junit.Test; - -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Window; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.UITestCase; - -public class TestGLDrawable01NEWT extends UITestCase { - static final int width = 200, height = 200; - - void doTest(String profile, boolean onscreen, boolean fbo, boolean pbuffer) throws InterruptedException { - if( !GLProfile.isAvailable(profile) ) { - System.err.println("Profile "+profile+" n/a"); - return; - } - - final GLProfile glp = GLProfile.get(profile); - final GLCapabilities reqGLCaps = new GLCapabilities(glp); - - reqGLCaps.setOnscreen(onscreen); - reqGLCaps.setPBuffer(!onscreen && pbuffer); - reqGLCaps.setFBO(!onscreen && fbo); - reqGLCaps.setDoubleBuffered(onscreen); - // System.out.println("Requested: "+caps); - - // - // Create native windowing resources .. X11/Win/OSX - // - Window window = NewtFactory.createWindow(reqGLCaps); - Assert.assertNotNull(window); - window.setSize(width, height); - window.setVisible(true); - AWTRobotUtil.waitForVisible(window, true); - AWTRobotUtil.waitForRealized(window, true); - // System.out.println("Created: "+window); - - // Check caps of NativeWindow config w/o GL - final CapabilitiesImmutable chosenCaps = window.getGraphicsConfiguration().getChosenCapabilities(); - Assert.assertNotNull(chosenCaps); - Assert.assertTrue(chosenCaps.getGreenBits()>5); - Assert.assertTrue(chosenCaps.getBlueBits()>5); - Assert.assertTrue(chosenCaps.getRedBits()>5); - - // - // Create native OpenGL resources .. XGL/WGL/CGL .. - // equivalent to GLAutoDrawable methods: setVisible(true) - // - final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); - - final GLDrawable drawable = factory.createGLDrawable(window); - Assert.assertNotNull(drawable); - // System.out.println("Pre: "+drawable); - // - drawable.setRealized(true); - Assert.assertTrue(drawable.isRealized()); - - // Check caps of GLDrawable after realization - final GLCapabilitiesImmutable chosenGLCaps = drawable.getChosenGLCapabilities(); - Assert.assertNotNull(chosenGLCaps); - Assert.assertTrue(chosenGLCaps.getGreenBits()>5); - Assert.assertTrue(chosenGLCaps.getBlueBits()>5); - Assert.assertTrue(chosenGLCaps.getRedBits()>5); - Assert.assertTrue(chosenGLCaps.getDepthBits()>4); - Assert.assertEquals(reqGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); - Assert.assertEquals(reqGLCaps.isOnscreen(), chosenGLCaps.getDoubleBuffered()); // offscreen shall be !dbl-buffer - // System.out.println("Post: "+drawable); - - GLContext context = drawable.createContext(null); - Assert.assertNotNull(context); - // System.out.println(context); - - int res = context.makeCurrent(); - Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); - - // draw something .. - final GL gl = context.getGL(); - gl.glClearColor(1, 1, 1, 1); - gl.glEnable(GL.GL_DEPTH_TEST); - Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - gl.glViewport(0, 0, width, height); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - - drawable.swapBuffers(); - context.release(); - - Thread.sleep(50); - - context.destroy(); - drawable.setRealized(false); - window.destroy(); - // System.out.println("Final: "+window); - } - - @Test - public void testGL2OnScreen() throws InterruptedException { - doTest(GLProfile.GL2, true, false, false); - } - - @Test - public void testES2OnScreen() throws InterruptedException { - doTest(GLProfile.GLES2, true, false, false); - } - - @Test - public void testGL2PBuffer() throws InterruptedException { - doTest(GLProfile.GL2, false, false, true); - } - - @Test - public void testES2PBuffer() throws InterruptedException { - doTest(GLProfile.GLES2, false, false, true); - } - - // @Test // TODO: FBO-Drawable via createGLDrawable and pre-exisiting NativeSurface - public void testGL2FBO() throws InterruptedException { - doTest(GLProfile.GL2, false, true, false); - } - - // @Test // TODO: FBO-Drawable via createGLDrawable and pre-exisiting NativeSurface - public void testES2FBO() throws InterruptedException { - doTest(GLProfile.GLES2, false, true, false); - } - - public static void main(String args[]) throws IOException { - org.junit.runner.JUnitCore.main(TestGLDrawable01NEWT.class.getName()); - } - -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java index e4245ef11..d4f3fece5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java @@ -32,14 +32,11 @@ import java.util.Collections; import java.util.SortedSet; import java.util.TreeSet; -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLProfile; import jogamp.opengl.GLDrawableFactoryImpl; @@ -77,13 +74,11 @@ public class TestGLExtensionQueryOffscreen { @Test public void testJogl2ExtensionCheck2() { - GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); - GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory(); - GLCapabilitiesChooser glCapsChooser = new DefaultGLCapabilitiesChooser(); - AbstractGraphicsDevice agd = factory.getDefaultDevice(); + final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); - GLAutoDrawable drawable = factory.createGLPbuffer(agd, caps, glCapsChooser, 256, 256, null); - GLContext context = drawable.getContext(); + final GLContext context = drawable.getContext(); context.makeCurrent(); String extensions; try { @@ -94,8 +89,8 @@ public class TestGLExtensionQueryOffscreen { String[] tabExtensions = extensions.split(" "); SortedSet setExtensions = new TreeSet(); Collections.addAll(setExtensions, tabExtensions); - System.out.println("DefaulContext: "+context); - System.out.println("DefaulContext: "+setExtensions); + System.out.println("DefaultContext: "+context); + System.out.println("DefaultContext: "+setExtensions); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java index 33a9b7799..c1b7464e7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java @@ -11,12 +11,14 @@ import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; /** * Tests the closing the device of GLWindow and GLPBuffer in JOGL */ +@SuppressWarnings("deprecation") public class TestNEWTCloseX11DisplayBug565 { @Test @@ -59,7 +61,7 @@ public class TestNEWTCloseX11DisplayBug565 { @Test - public void testX11WindowMemoryLeakOffscreenWindow() throws Exception { + public void testX11WindowMemoryLeakGLPbuffer() throws Exception { GLProfile.initSingleton(); // ensure shared resource runner is done try { for ( int j = 0; j < 10; j++ ) { @@ -100,6 +102,48 @@ public class TestNEWTCloseX11DisplayBug565 { } } + @Test + public void testX11WindowMemoryLeakFBOAutoDrawable() throws Exception { + GLProfile.initSingleton(); // ensure shared resource runner is done + try { + for ( int j = 0; j < 10; j++ ) { + final int open0; + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + open0 = X11Util.getOpenDisplayConnectionNumber(); + } else { + open0 = 0; + } + final GLProfile glp = GLProfile.getDefault( ); + GLCapabilitiesImmutable caps = new GLCapabilities( glp ); + + + GLOffscreenAutoDrawable buffer = GLDrawableFactory.getFactory( glp ).createOffscreenAutoDrawable( + null, + caps, + new DefaultGLCapabilitiesChooser(), + 256, + 256, + null + ); + buffer.display(); + buffer.destroy(); + + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + final int openD = X11Util.getOpenDisplayConnectionNumber() - open0; + if(openD > 0) { + X11Util.dumpOpenDisplayConnections(); + X11Util.dumpPendingDisplayConnections(); + Assert.assertEquals("New display connection didn't close", 0, openD); + } + } + } + } + catch ( Exception e ) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + } + public static void main(String args[]) { org.junit.runner.JUnitCore.main(TestNEWTCloseX11DisplayBug565.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java new file mode 100644 index 000000000..d181800c5 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java @@ -0,0 +1,236 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Frame; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; + +import jogamp.nativewindow.jawt.JAWTUtil; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.common.os.Platform; +import com.jogamp.newt.Window; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { + static boolean useMSAA = false; + static boolean addComp = true; + static int swapInterval = 1; + static boolean shallUseOffscreenPBufferLayer = false; + static boolean noAnimation = false; + static Dimension frameSize0; + static Dimension frameSize1; + static Dimension preferredGLSize; + static long durationPerTest = 1000; + + @BeforeClass + public static void initClass() { + frameSize0 = new Dimension(500,300); + frameSize1 = new Dimension(800,600); + preferredGLSize = new Dimension(400,200); + } + + private void setupFrameAndShow(final Frame f, java.awt.Component comp) throws InterruptedException, InvocationTargetException { + + Container c = new Container(); + c.setLayout(new BorderLayout()); + c.add(new Button("north"), BorderLayout.NORTH); + c.add(new Button("south"), BorderLayout.SOUTH); + c.add(new Button("east"), BorderLayout.EAST); + c.add(new Button("west"), BorderLayout.WEST); + c.add(comp, BorderLayout.CENTER); + + f.setLayout(new BorderLayout()); + f.add(new Button("NORTH"), BorderLayout.NORTH); + f.add(new Button("SOUTH"), BorderLayout.SOUTH); + f.add(new Button("EAST"), BorderLayout.EAST); + f.add(new Button("WEST"), BorderLayout.WEST); + f.add(c, BorderLayout.CENTER); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f.pack(); + f.validate(); + f.setVisible(true); + }}); + } + + private void end(GLAnimatorControl actrl, final Frame f, Window w) throws InterruptedException, InvocationTargetException { + actrl.stop(); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f.dispose(); + } } ); + if(null != w) { + w.destroy(); + } + } + + @Test + public void testInfo00() throws InterruptedException, InvocationTargetException { + System.err.println("Java Version: "+Platform.getJavaVersionNumber()); + System.err.println("OS Version: "+Platform.getOSVersionNumber()); + System.err.println("JAWTUtil.isOffscreenLayerRequired(): "+JAWTUtil.isOffscreenLayerRequired()); + System.err.println("JAWTUtil.isOffscreenLayerSupported(): "+JAWTUtil.isOffscreenLayerSupported()); + } + + @Test + public void testOffscreenLayerGLCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException { + testOffscreenLayerGLCanvas_Impl(true); + } + + private void testOffscreenLayerGLCanvas_Impl(boolean offscreenLayer) throws InterruptedException, InvocationTargetException { + if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { + System.err.println("onscreen layer n/a"); + return; + } + if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { + System.err.println("offscreen layer n/a"); + return; + } + final Frame frame1 = new Frame("AWT Parent Frame"); + + GLCapabilities caps = new GLCapabilities(null); + if(useMSAA) { + caps.setNumSamples(4); + caps.setSampleBuffers(true); + } + if(shallUseOffscreenPBufferLayer) { + caps.setPBuffer(true); + caps.setOnscreen(true); // simulate normal behavior .. + } + final GLCanvas glc = new GLCanvas(caps); + glc.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported + glc.setPreferredSize(preferredGLSize); + glc.setMinimumSize(preferredGLSize); + glc.setSize(preferredGLSize); + + GearsES2 demo1 = new GearsES2(swapInterval); + if(noAnimation) { + demo1.setDoRotation(false); + } + glc.addGLEventListener(demo1); + + frame1.setSize(frameSize0); + setupFrameAndShow(frame1, glc); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glc, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glc, true)); + Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer, + glc.isOffscreenLayerSurfaceEnabled()); + + GLAnimatorControl animator1 = new Animator(glc); + if(!noAnimation) { + animator1.start(); + } + animator1.setUpdateFPSFrames(60, System.err); + + Thread.sleep(durationPerTest/2); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setSize(frameSize1); + frame1.pack(); + frame1.validate(); + }}); + + Thread.sleep(durationPerTest/2); + + end(animator1, frame1, null); + } + + public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { + Assert.assertNotNull(demo); + Assert.assertNotNull(glWindow); + Window window = glWindow.getDelegatedWindow(); + if(debug) { + MiscUtils.setFieldIfExists(demo, "glDebug", true); + MiscUtils.setFieldIfExists(demo, "glTrace", true); + } + if(!MiscUtils.setFieldIfExists(demo, "window", window)) { + MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); + } + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i + * {@link JFrame} . {@link Container}+ . {@link NewtCanvasAWT} . {@link GLWindow} + *

+ *

+ * + Container is the JFrame's implicit root content pane
+ *

+ */ public class TestFocus01SwingAWTRobot extends UITestCase { static int width, height; static long durationPerTest = 10; @@ -125,6 +135,10 @@ public class TestFocus01SwingAWTRobot extends UITestCase { AWTKeyAdapter buttonKA = new AWTKeyAdapter("Button"); button.addKeyListener(buttonKA); eventCountAdapters.add(buttonKA); + AWTMouseAdapter buttonMA = new AWTMouseAdapter("Button"); + button.addMouseListener(buttonMA); + eventCountAdapters.add(buttonMA); + frame1.getContentPane().add(button, BorderLayout.NORTH); frame1.setSize(width, height); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { @@ -158,13 +172,18 @@ public class TestFocus01SwingAWTRobot extends UITestCase { Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); System.err.println("FOCUS AWT Button sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, button, buttonKA); + AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1, + button, buttonMA); + AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2, + button, buttonMA); // Request the AWT focus, which should automatically provide the NEWT window with focus. Thread.sleep(100); // allow event sync System.err.println("FOCUS NEWT Canvas/GLWindow request"); EventCountAdapterUtil.reset(eventCountAdapters); AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonFA); - Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); + Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA, + AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA)); System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java index a0efa53ad..d8a9640c1 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java @@ -56,6 +56,15 @@ import java.io.IOException; import com.jogamp.opengl.test.junit.util.*; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +/** + * Testing focus traversal of an AWT component tree with {@link NewtCanvasAWT} attached. + *

+ * {@link JFrame} . {@link JPanel}+ . {@link Container} . {@link NewtCanvasAWT} . {@link GLWindow} + *

+ *

+ * + JPanel is set as JFrame's root content pane
+ *

+ */ public class TestFocus02SwingAWTRobot extends UITestCase { static int width, height; static long durationPerTest = 10; @@ -85,9 +94,6 @@ public class TestFocus02SwingAWTRobot extends UITestCase { ArrayList eventCountAdapters = new ArrayList(); - /** - * JFrame . JPanel . Container . NewtCanvasAWT . GLWindow - */ GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); GLEventListener demo1 = new GearsES2(); @@ -225,7 +231,9 @@ public class TestFocus02SwingAWTRobot extends UITestCase { System.err.println("FOCUS NEWT Canvas/GLWindow request"); EventCountAdapterUtil.reset(eventCountAdapters); AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthInnerFA); - Assert.assertTrue(AWTRobotUtil.waitForFocusCount(false, newtCanvasAWTFA)); + Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA, + AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA)); + Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); Assert.assertEquals(false, buttonNorthOuterFA.focusGained()); Assert.assertEquals(false, jFrame1FA.focusGained()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java index bf72348f9..e03b5e7d6 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java @@ -33,7 +33,6 @@ import org.junit.BeforeClass; import org.junit.Test; import javax.media.nativewindow.*; -import javax.media.nativewindow.util.Point; import com.jogamp.newt.*; import java.io.IOException; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 473f2f584..f7881615d 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -36,7 +36,7 @@ import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; -class NewtAWTReparentingKeyAdapter extends KeyAdapter { +public class NewtAWTReparentingKeyAdapter extends KeyAdapter { Frame frame; NewtCanvasAWT newtCanvasAWT; GLWindow glWindow; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java deleted file mode 100644 index 4542fa47e..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java +++ /dev/null @@ -1,211 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt.parenting; - -import java.awt.BorderLayout; -import java.awt.Button; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Frame; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -import javax.media.opengl.GLAnimatorControl; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.awt.GLCanvas; - -import jogamp.nativewindow.jawt.JAWTUtil; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.common.os.Platform; -import com.jogamp.newt.Window; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.Animator; - -public class TestParentingOffscreenLayer01GLCanvasAWT extends UITestCase { - static Dimension frameSize0; - static Dimension frameSize1; - static Dimension preferredGLSize; - static Dimension minGLSize; - static long durationPerTest = 1000; - - @BeforeClass - public static void initClass() { - frameSize0 = new Dimension(500,300); - frameSize1 = new Dimension(800,600); - preferredGLSize = new Dimension(400,200); - minGLSize = new Dimension(200,100); - } - - private void setupFrameAndShow(final Frame f, java.awt.Component comp) throws InterruptedException, InvocationTargetException { - - Container c = new Container(); - c.setLayout(new BorderLayout()); - c.add(new Button("north"), BorderLayout.NORTH); - c.add(new Button("south"), BorderLayout.SOUTH); - c.add(new Button("east"), BorderLayout.EAST); - c.add(new Button("west"), BorderLayout.WEST); - c.add(comp, BorderLayout.CENTER); - - f.setLayout(new BorderLayout()); - f.add(new Button("NORTH"), BorderLayout.NORTH); - f.add(new Button("SOUTH"), BorderLayout.SOUTH); - f.add(new Button("EAST"), BorderLayout.EAST); - f.add(new Button("WEST"), BorderLayout.WEST); - f.add(c, BorderLayout.CENTER); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - f.validate(); - f.setVisible(true); - }}); - } - private void end(GLAnimatorControl actrl, final Frame f, Window w) throws InterruptedException, InvocationTargetException { - actrl.stop(); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - f.dispose(); - } } ); - if(null != w) { - w.destroy(); - } - } - - @Test - public void testInfo00() throws InterruptedException, InvocationTargetException { - System.err.println("Java Version: "+Platform.getJavaVersionNumber()); - System.err.println("OS Version: "+Platform.getOSVersionNumber()); - System.err.println("JAWTUtil.isOffscreenLayerRequired(): "+JAWTUtil.isOffscreenLayerRequired()); - System.err.println("JAWTUtil.isOffscreenLayerSupported(): "+JAWTUtil.isOffscreenLayerSupported()); - } - - @Test - public void testOnscreenLayerGLCanvas_Onscreen() throws InterruptedException, InvocationTargetException { - testOffscreenLayerGLCanvas_Impl(false); - } - - @Test - public void testOffscreenLayerGLCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException { - testOffscreenLayerGLCanvas_Impl(true); - } - - private void testOffscreenLayerGLCanvas_Impl(boolean offscreenLayer) throws InterruptedException, InvocationTargetException { - if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { - System.err.println("onscreen layer n/a"); - return; - } - if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { - System.err.println("offscreen layer n/a"); - return; - } - final Frame frame1 = new Frame("AWT Parent Frame"); - - GLCapabilities glCaps = new GLCapabilities(null); - final GLCanvas glc = new GLCanvas(glCaps); - glc.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported - glc.setPreferredSize(preferredGLSize); - glc.setMinimumSize(minGLSize); - - GLEventListener demo1 = new GearsES2(1); - glc.addGLEventListener(demo1); - - frame1.setSize(frameSize0); - setupFrameAndShow(frame1, glc); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glc, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glc, true)); - Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer, - glc.isOffscreenLayerSurfaceEnabled()); - - GLAnimatorControl animator1 = new Animator(glc); - animator1.start(); - - Thread.sleep(durationPerTest/2); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame1.setSize(frameSize1); - frame1.validate(); - }}); - - Thread.sleep(durationPerTest/2); - - end(animator1, frame1, null); - } - - public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { - Assert.assertNotNull(demo); - Assert.assertNotNull(glWindow); - Window window = glWindow.getDelegatedWindow(); - if(debug) { - MiscUtils.setFieldIfExists(demo, "glDebug", true); - MiscUtils.setFieldIfExists(demo, "glTrace", true); - } - if(!MiscUtils.setFieldIfExists(demo, "window", window)) { - MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); - } - } - - static int atoi(String a) { - int i=0; - try { - i = Integer.parseInt(a); - } catch (Exception ex) { ex.printStackTrace(); } - return i; - } - - public static void main(String args[]) throws IOException { - for(int i=0; ivisible within TIME_OUT diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java index 3f989bfa4..a76b67d57 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java @@ -70,8 +70,8 @@ public class NEWTGLContext { Assert.assertNotNull(window); window.setSize(width, height); window.setVisible(true); - AWTRobotUtil.waitForVisible(window, true); - AWTRobotUtil.waitForRealized(window, true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); GLDrawable drawable = factory.createGLDrawable(window); diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java index c07d5b741..c42d9ff62 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java +++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java @@ -29,12 +29,14 @@ package com.jogamp.opengl.test.junit.util; import java.io.File; -import java.io.PrintWriter; -import java.io.StringWriter; +import java.util.Iterator; +import java.util.List; import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLEventListener; import com.jogamp.common.util.locks.SingletonInstance; import com.jogamp.opengl.util.GLReadBufferUtil; @@ -47,6 +49,8 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.Rule; import org.junit.rules.TestName; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.TestClass; public abstract class UITestCase { @@ -58,9 +62,11 @@ public abstract class UITestCase { public static final long SINGLE_INSTANCE_LOCK_TO = 3*60*1000; // wait up to 3 min public static final long SINGLE_INSTANCE_LOCK_POLL = 1000; // poll every 1s - static volatile SingletonInstance singletonInstance; + private static volatile SingletonInstance singletonInstance; - static volatile boolean testSupported = true; + private static volatile boolean testSupported = true; + + private static volatile int maxMethodNameLen = 0; private static final synchronized void initSingletonInstance() { if( null == singletonInstance ) { @@ -77,6 +83,20 @@ public abstract class UITestCase { testSupported = v; } + public int getMaxTestNameLen() { + if(0 == maxMethodNameLen) { + int ml = 0; + final TestClass tc = new TestClass(getClass()); + final List testMethods = tc.getAnnotatedMethods(org.junit.Test.class); + for(Iterator iter=testMethods.iterator(); iter.hasNext(); ) { + final int l = iter.next().getName().length(); + if( ml < l ) { ml = l; } + } + maxMethodNameLen = ml; + } + return maxMethodNameLen; + } + public final String getTestMethodName() { return _unitTestName.getMethodName(); } @@ -120,13 +140,12 @@ public abstract class UITestCase { static final String unsupportedTestMsg = "Test not supported on this platform."; /** - * Takes a snapshot of the drawable's current framebuffer. Example filenames: + * Takes a snapshot of the drawable's current front framebuffer. Example filenames: *
-     * TestFBODrawableNEWT.test01-F_rgba-I_rgba-S0_default-GL2-n0004-0800x0600.png
-     * TestFBODrawableNEWT.test01-F_rgba-I_rgba-S0_default-GL2-n0005-0800x0600.png
+     * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testES2OffScreenFBOSglBuf____-n0001-msaa0-GLES2_-sw-fbobject-Bdbl-Frgb__Irgb_-S00_default-0400x0300.png
+     * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testES2OffScreenPbufferDblBuf-n0003-msaa0-GLES2_-sw-pbuffer_-Bdbl-Frgb__Irgb_-S00_default-0200x0150.png
+     * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testGL2OffScreenPbufferSglBuf-n0003-msaa0-GL2___-hw-pbuffer_-Bone-Frgb__Irgb_-S00_default-0200x0150.png
      * 
- * - * @param simpleTestName will be used as the filename prefix * @param sn sequential number * @param postSNDetail optional detail to be added to the filename after sn * @param gl the current GL context object. It's read drawable is being used as the pixel source and to gather some details which will end up in the filename. @@ -137,30 +156,80 @@ public abstract class UITestCase { * It shall not end with a directory separator, {@link File#separatorChar}. * If null the current working directory is being used. */ - public static void snapshot(String simpleTestName, int sn, String postSNDetail, GL gl, GLReadBufferUtil readBufferUtil, String fileSuffix, String destPath) { + public void snapshot(int sn, String postSNDetail, GL gl, GLReadBufferUtil readBufferUtil, String fileSuffix, String destPath) { if(null == fileSuffix) { fileSuffix = TextureIO.PNG; } - final StringWriter filenameSW = new StringWriter(); - { + final int maxSimpleTestNameLen = getMaxTestNameLen()+getClass().getSimpleName().length()+1; + final String simpleTestName = this.getSimpleTestName("."); + final String filenameBaseName; + { final GLDrawable drawable = gl.getContext().getGLReadDrawable(); final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); + final String accel = caps.getHardwareAccelerated() ? "hw" : "sw" ; + final String scrnm; + if(caps.isOnscreen()) { + scrnm = "onscreen"; + } else if(caps.isFBO()) { + scrnm = "fbobject"; + } else if(caps.isPBuffer()) { + scrnm = "pbuffer_"; + } else if(caps.isBitmap()) { + scrnm = "bitmap__"; + } else { + scrnm = "unknown_"; + } + final String dblb = caps.getDoubleBuffered() ? "dbl" : "one"; final String F_pfmt = readBufferUtil.hasAlpha() ? "rgba" : "rgb_"; final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_"; - final String aaext = caps.getSampleExtension(); final int samples = caps.getNumSamples() ; + final String aaext = caps.getSampleExtension(); postSNDetail = null != postSNDetail ? "-"+postSNDetail : ""; - final PrintWriter pw = new PrintWriter(filenameSW); - pw.printf("%s-n%04d%s-F_%s-I_%s-S%d_%s-%s-%04dx%04d.%s", - simpleTestName, sn, postSNDetail, F_pfmt, pfmt, samples, aaext, drawable.getGLProfile().getName(), - drawable.getWidth(), drawable.getHeight(), fileSuffix); + + filenameBaseName = String.format("%-"+maxSimpleTestNameLen+"s-n%04d%s-%-6s-%s-%s-B%s-F%s_I%s-S%02d_%s-%04dx%04d.%s", + simpleTestName, sn, postSNDetail, drawable.getGLProfile().getName(), accel, + scrnm, dblb, F_pfmt, pfmt, samples, aaext, + drawable.getWidth(), drawable.getHeight(), fileSuffix).replace(' ', '_'); } - final String filename = null != destPath ? destPath + File.separator + filenameSW.toString() : filenameSW.toString(); - System.err.println(Thread.currentThread().getName()+": ** screenshot: "+filename); + final String filename = null != destPath ? destPath + File.separator + filenameBaseName : filenameBaseName; + System.err.println(Thread.currentThread().getName()+": ** screenshot: "+filename+", maxTestNameLen "+maxSimpleTestNameLen+", <"+simpleTestName+">"); gl.glFinish(); // just make sure rendering finished .. if(readBufferUtil.readPixels(gl, false)) { readBufferUtil.write(new File(filename)); } - } + } + + public class SnapshotGLEventListener implements GLEventListener { + private final GLReadBufferUtil screenshot; + private volatile boolean makeShot = false; + private volatile int displayCount=0; + private volatile int reshapeCount=0; + public SnapshotGLEventListener(GLReadBufferUtil screenshot) { + this.screenshot = screenshot; + } + public SnapshotGLEventListener() { + this.screenshot = new GLReadBufferUtil(false, false); + } + + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + System.err.println(Thread.currentThread().getName()+": ** display: "+displayCount+": "+drawable.getWidth()+"x"+drawable.getHeight()+", makeShot "+makeShot); + if(makeShot) { + makeShot=false; + snapshot(displayCount, null, gl, screenshot, TextureIO.PNG, null); + } + displayCount++; + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + System.err.println(Thread.currentThread().getName()+": ** reshape: "+reshapeCount+": "+width+"x"+height+" - "+drawable.getWidth()+"x"+drawable.getHeight()); + reshapeCount++; + } + public void setMakeSnapshot() { + makeShot=true; + } + }; + } -- cgit v1.2.3 From 646714d3dab87396b9a3119bf90ca26e0b1c97ce Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 16 Sep 2012 21:13:51 +0200 Subject: Fix Bug 601: Harmonize order of key events incl. auto-repeat and adding AUTOREPEAT_MASK modifier bit. Refine InputEvent toString(..) and list modifiers by name. As now described in NEWT's KeyEvent: +/** + * Key events are delivered in the following order: + *
    + *
  1. {@link #EVENT_KEY_PRESSED}
  2. + *
  3. {@link #EVENT_KEY_RELEASED}
  4. + *
  5. {@link #EVENT_KEY_TYPED}
  6. + *
+ * In case the native platform does not + * deliver keyboard events in the above order or skip events, + * the NEWT driver will reorder and inject synthetic events if required. + *

+ * Besides regular modifiers like {@link InputEvent##SHIFT_MASK} etc., + * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected. + *

+ */ --- make/scripts/java-win64-dbg.bat | 6 +- make/scripts/tests-x64.bat | 4 +- make/scripts/tests.sh | 6 +- src/newt/classes/com/jogamp/newt/Window.java | 2 + .../classes/com/jogamp/newt/event/InputEvent.java | 82 ++++++++++++++++++---- .../classes/com/jogamp/newt/event/KeyEvent.java | 26 ++++++- .../classes/com/jogamp/newt/event/MouseEvent.java | 12 +++- .../classes/com/jogamp/newt/event/NEWTEvent.java | 10 ++- .../classes/com/jogamp/newt/event/WindowEvent.java | 13 +++- .../com/jogamp/newt/event/WindowUpdateEvent.java | 11 ++- .../jogamp/newt/driver/macosx/WindowDriver.java | 20 ++++++ .../jogamp/newt/driver/windows/WindowDriver.java | 36 ++++++++-- src/newt/native/InputEvent.h | 22 +++--- src/newt/native/X11Display.c | 18 ++++- 14 files changed, 223 insertions(+), 45 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index b63438534..07722c78e 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -38,7 +38,8 @@ REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" -set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Dnewt.debug.Window" +set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" @@ -53,4 +54,5 @@ REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.opengl=true" "-Dsun.awt REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=false" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" -%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win64-dbg.log 2>&1 +REM %J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win64-dbg.log 2>&1 +%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index a4207b696..9ffbcd6d3 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -19,7 +19,7 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLPro REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* @@ -103,7 +103,7 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT -scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 724b7df97..7b39c3fbd 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -123,7 +123,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -263,7 +263,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* @@ -304,7 +304,7 @@ function testawtswt() { #testawt javax.media.opengl.awt.GLCanvas $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index e8537fec5..78e2abc6e 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -245,6 +245,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { String getTitle(); + /** @see #setPointerVisible(boolean) */ boolean isPointerVisible(); /** @@ -256,6 +257,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { */ void setPointerVisible(boolean pointerVisible); + /** @see #confinePointer(boolean) */ boolean isPointerConfined(); /** diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index 819338ccb..148ac5962 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -34,22 +34,31 @@ package com.jogamp.newt.event; +import com.jogamp.newt.Window; + @SuppressWarnings("serial") public abstract class InputEvent extends NEWTEvent { - 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; - public static final int BUTTON4_MASK = 1 << 9; - public static final int BUTTON5_MASK = 1 << 10; - public static final int BUTTON6_MASK = 1 << 11; - public static final int CONFINED_MASK = 1 << 16; - public static final int INVISIBLE_MASK = 1 << 17; + 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; + public static final int BUTTON4_MASK = 1 << 9; + public static final int BUTTON5_MASK = 1 << 10; + public static final int BUTTON6_MASK = 1 << 11; + + /** Event is caused by auto-repeat. */ + public static final int AUTOREPEAT_MASK = 1 << 15; + + /** Pointer is confined, see {@link Window#confinePointer(boolean)}. */ + public static final int CONFINED_MASK = 1 << 16; + + /** Pointer is invisible, see {@link Window#setPointerVisible(boolean)}. */ + public static final int INVISIBLE_MASK = 1 << 17; /** * Returns the corresponding button mask for the given button. @@ -76,30 +85,64 @@ public abstract class InputEvent extends NEWTEvent this.modifiers=modifiers; } + /** Return the modifier bits of this event, e.g. see {@link #SHIFT_MASK} .. etc. */ public int getModifiers() { return modifiers; } + /** {@link #getModifiers()} contains {@link #ALT_MASK}. */ public boolean isAltDown() { return (modifiers&ALT_MASK)!=0; } + /** {@link #getModifiers()} contains {@link #ALT_GRAPH_MASK}. */ public boolean isAltGraphDown() { return (modifiers&ALT_GRAPH_MASK)!=0; } + /** {@link #getModifiers()} contains {@link #CTRL_MASK}. */ public boolean isControlDown() { return (modifiers&CTRL_MASK)!=0; } + /** {@link #getModifiers()} contains {@link #META_MASK}. */ public boolean isMetaDown() { return (modifiers&META_MASK)!=0; } + /** {@link #getModifiers()} contains {@link #SHIFT_MASK}. */ public boolean isShiftDown() { return (modifiers&SHIFT_MASK)!=0; } + /** {@link #getModifiers()} contains {@link #AUTOREPEAT_MASK}. */ + public boolean isAutoRepeat() { + return (modifiers&AUTOREPEAT_MASK)!=0; + } + /** {@link #getModifiers()} contains {@link #CONFINED_MASK}. Pointer is confined, see {@link Window#confinePointer(boolean)}. */ public boolean isConfined() { return (modifiers&CONFINED_MASK)!=0; } + /** {@link #getModifiers()} contains {@link #INVISIBLE_MASK}. Pointer is invisible, see {@link Window#setPointerVisible(boolean)}. */ public boolean isInvisible() { return (modifiers&INVISIBLE_MASK)!=0; } + + public StringBuilder getModifiersString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("["); + boolean isFirst = true; + if(isShiftDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("shift"); } + if(isControlDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("ctrl"); } + if(isMetaDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("meta"); } + if(isAltDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("alt"); } + if(isAltGraphDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("altg"); } + if(isAutoRepeat()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("repeat"); } + for(int i=1; i<=MouseEvent.BUTTON_NUMBER; i++) { + if(isButtonDown(i)) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("button").append(i); } + } + if(isConfined()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("confined"); } + if(isInvisible()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("invisible"); } + sb.append("]"); + + return sb; + } /** * @return Array of pressed mouse buttons [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON6}]. @@ -124,7 +167,18 @@ public abstract class InputEvent extends NEWTEvent } public String toString() { - return "InputEvent[modifiers: 0x"+Integer.toHexString(modifiers)+", "+super.toString()+"]"; + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("InputEvent[modifiers: "); + getModifiersString(sb); + sb.append(", "); + super.toString(sb).append("]"); + return sb; } private final int modifiers; diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 4db661eeb..bd48981da 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -34,6 +34,21 @@ package com.jogamp.newt.event; +/** + * Key events are delivered in the following order: + *
    + *
  1. {@link #EVENT_KEY_PRESSED}
  2. + *
  3. {@link #EVENT_KEY_RELEASED}
  4. + *
  5. {@link #EVENT_KEY_TYPED}
  6. + *
+ * In case the native platform does not + * deliver keyboard events in the above order or skip events, + * the NEWT driver will reorder and inject synthetic events if required. + *

+ * Besides regular modifiers like {@link InputEvent##SHIFT_MASK} etc., + * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected. + *

+ */ @SuppressWarnings("serial") public class KeyEvent extends InputEvent { @@ -54,8 +69,15 @@ public class KeyEvent extends InputEvent } public String toString() { - return "KeyEvent["+getEventTypeString(getEventType())+ - ", code "+keyCode+"("+toHexString(keyCode)+"), char '"+keyChar+"' ("+toHexString((int)keyChar)+"), isActionKey "+isActionKey()+", "+super.toString()+"]"; + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(keyCode).append("(").append(toHexString(keyCode)).append("), char '").append(keyChar).append("' (").append(toHexString((int)keyChar)).append("), isActionKey ").append(isActionKey()).append(", "); + return super.toString(sb).append("]"); } public static String getEventTypeString(int type) { diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index ceaf7d47a..d293d2db7 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -165,7 +165,13 @@ public class MouseEvent extends InputEvent } public String toString() { - StringBuilder sb = new StringBuilder(); + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } sb.append("MouseEvent[").append(getEventTypeString(getEventType())) .append(", ").append(x).append("/").append(y) .append(", button ").append(button).append(", count ") @@ -182,8 +188,8 @@ public class MouseEvent extends InputEvent } sb.append("]"); } - sb.append(", ").append(super.toString()).append("]"); - return sb.toString(); + sb.append(", "); + return super.toString(sb).append("]"); } public static String getEventTypeString(int type) { diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index 3f3817b91..fd5b69ccc 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -151,7 +151,14 @@ public class NEWTEvent extends java.util.EventObject { } public String toString() { - return "NEWTEvent[sys:"+isSystemEvent()+", source:"+getSource().getClass().getName()+", when:"+getWhen()+" d "+(System.currentTimeMillis()-getWhen())+"ms]"; + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + return sb.append("NEWTEvent[sys:").append(isSystemEvent()).append(", source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); } public static String toHexString(int hex) { @@ -161,5 +168,4 @@ public class NEWTEvent extends java.util.EventObject { public static String toHexString(long hex) { return "0x" + Long.toHexString(hex); } - } diff --git a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java index f3d62d8c6..163b51439 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java @@ -39,6 +39,7 @@ package com.jogamp.newt.event; * NEWT will automatically handle component moves and resizes internally, regardless of whether a program is receiving these events or not.
* The actual event semantic, here move and resize, is processed before the event is send.
*/ +@SuppressWarnings("serial") public class WindowEvent extends NEWTEvent { public static final int EVENT_WINDOW_RESIZED = 100; public static final int EVENT_WINDOW_MOVED = 101; @@ -64,8 +65,16 @@ public class WindowEvent extends NEWTEvent { default: return "unknown (" + type + ")"; } } + public String toString() { - return "WindowEvent["+getEventTypeString(getEventType()) + - ", " + super.toString() + "]"; + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("WindowEvent[").append(getEventTypeString(getEventType())).append(", "); + return super.toString(sb).append("]"); } } diff --git a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java index 505939de2..e3f0373ec 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java @@ -30,6 +30,7 @@ package com.jogamp.newt.event; import javax.media.nativewindow.util.Rectangle; +@SuppressWarnings("serial") public class WindowUpdateEvent extends WindowEvent { final Rectangle bounds; @@ -44,6 +45,14 @@ public class WindowUpdateEvent extends WindowEvent { } public String toString() { - return "WindowUpdateEvent["+super.toString()+", "+bounds+"]"; + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("WindowUpdateEvent[").append(bounds).append(", "); + return super.toString(sb).append("]"); } } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index d0c0b8b20..4eeafb244 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -49,6 +49,7 @@ import jogamp.newt.WindowImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; +import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; public class WindowDriver extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { @@ -313,6 +314,14 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); if(valid) { + if(pressedKeyBalance > 1) { + // Auto-Repeat: OSX delivers only PRESSED + // inject auto-repeat RELEASE and TYPED keys _before_ + pressedKeyBalance--; + modifiers |= InputEvent.AUTOREPEAT_MASK; + super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED + super.sendKeyEvent(KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED + } // only deliver keyChar on key Typed events, harmonizing platform behavior keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; super.sendKeyEvent(eventType, modifiers, keyCode2, keyChar); @@ -327,6 +336,14 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); if(valid) { + if(pressedKeyBalance > 1) { + // Auto-Repeat: OSX delivers only PRESSED + // inject auto-repeat RELEASE and TYPED keys _before_ + pressedKeyBalance--; + modifiers |= InputEvent.AUTOREPEAT_MASK; + super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED + super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED + } // only deliver keyChar on key Typed events, harmonizing platform behavior keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; super.enqueueKeyEvent(wait, eventType, modifiers, keyCode2, keyChar); @@ -335,14 +352,17 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private int keyDownModifiers = 0; private int keyDownCode = 0; + private int pressedKeyBalance = 0; private boolean validateKeyEvent(int eventType, int modifiers, int keyCode) { switch(eventType) { case KeyEvent.EVENT_KEY_PRESSED: + pressedKeyBalance++; keyDownModifiers = modifiers; keyDownCode = keyCode; return true; case KeyEvent.EVENT_KEY_RELEASED: + pressedKeyBalance--; return keyDownModifiers == modifiers && keyDownCode == keyCode; case KeyEvent.EVENT_KEY_TYPED: final boolean matchKeyDown = keyDownModifiers == modifiers && keyDownCode == keyCode; diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 5dbdeb458..18cc88472 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; @@ -258,9 +259,14 @@ public class WindowDriver extends WindowImpl { // nop - using event driven insetsChange(..) } - private final int validateKeyCode(int eventType, int keyCode) { + private final int validateKeyCode(int eventType, int modifiers, int keyCode, char keyChar) { switch(eventType) { + case KeyEvent.EVENT_KEY_RELEASED: + pressedKeyBalance--; + lastPressedKeyCode = keyCode; + break; case KeyEvent.EVENT_KEY_PRESSED: + pressedKeyBalance++; lastPressedKeyCode = keyCode; break; case KeyEvent.EVENT_KEY_TYPED: @@ -273,18 +279,40 @@ public class WindowDriver extends WindowImpl { return keyCode; } private int lastPressedKeyCode = 0; + private int pressedKeyBalance = 0; + private int autoRepeat = 0; @Override public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform - keyCode = validateKeyCode(eventType, keyCode); - super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + keyCode = validateKeyCode(eventType, modifiers, keyCode, keyChar); + switch(eventType) { + case KeyEvent.EVENT_KEY_RELEASED: + // reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED + break; + case KeyEvent.EVENT_KEY_PRESSED: + if(pressedKeyBalance > 1) { + // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. + // Since reordering already injects RELEASE, we only need to set the AUTOREPEAT_MASK. + pressedKeyBalance--; + autoRepeat |= InputEvent.AUTOREPEAT_MASK; + } else { + autoRepeat &= ~InputEvent.AUTOREPEAT_MASK; + } + super.sendKeyEvent(eventType, modifiers | autoRepeat, keyCode, (char)-1); + break; + case KeyEvent.EVENT_KEY_TYPED: + modifiers |= autoRepeat; + super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); + super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + break; + } } @Override public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform - keyCode = validateKeyCode(eventType, keyCode); + keyCode = validateKeyCode(eventType, modifiers, keyCode, keyChar); super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); } diff --git a/src/newt/native/InputEvent.h b/src/newt/native/InputEvent.h index b42c06d21..51c56c474 100644 --- a/src/newt/native/InputEvent.h +++ b/src/newt/native/InputEvent.h @@ -34,13 +34,19 @@ #ifndef _INPUT_EVENT_H_ #define _INPUT_EVENT_H_ -#define EVENT_SHIFT_MASK 1 -#define EVENT_CTRL_MASK 2 -#define EVENT_META_MASK 4 -#define EVENT_ALT_MASK 8 -#define EVENT_ALT_GRAPH_MASK 32 -#define EVENT_BUTTON1_MASK (1<<6) -#define EVENT_BUTTON2_MASK (1<<7) -#define EVENT_BUTTON3_MASK (1<<8) +#define EVENT_SHIFT_MASK (1 << 0) +#define EVENT_CTRL_MASK (1 << 1) +#define EVENT_META_MASK (1 << 2) +#define EVENT_ALT_MASK (1 << 3) +#define EVENT_ALT_GRAPH_MASK (1 << 5) +#define EVENT_BUTTON1_MASK (1 << 6) +#define EVENT_BUTTON2_MASK (1 << 7) +#define EVENT_BUTTON3_MASK (1 << 8) +#define EVENT_BUTTON4_MASK (1 << 9) +#define EVENT_BUTTON5_MASK (1 << 10) +#define EVENT_BUTTON6_MASK (1 << 11) +#define EVENT_AUTOREPEAT_MASK (1 << 15) +#define EVENT_CONFINED_MASK (1 << 16) +#define EVENT_INVISIBLE_MASK (1 << 17) #endif diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 3157538c3..84b3a7630 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -400,6 +400,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage Display * dpy = (Display *) (intptr_t) display; Atom wm_delete_atom = (Atom)windowDeleteAtom; int num_events = 100; + int autoRepeatModifiers = 0; if ( NULL == dpy ) { return; @@ -458,6 +459,19 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage switch(evt.type) { case KeyRelease: + if (XEventsQueued(dpy, QueuedAfterReading)) { + XEvent nevt; + XPeekEvent(dpy, &nevt); + + if (nevt.type == KeyPress && nevt.xkey.time == evt.xkey.time && + nevt.xkey.keycode == evt.xkey.keycode) + { + autoRepeatModifiers |= EVENT_AUTOREPEAT_MASK; + } else { + autoRepeatModifiers &= ~EVENT_AUTOREPEAT_MASK; + } + } + // fall through intended case KeyPress: if(XLookupString(&evt.xkey,text,255,&keySym,0)==1) { KeySym lower_return = 0, upper_return = 0; @@ -469,13 +483,13 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage keyChar=0; keySym = X11KeySym2NewtVKey(keySym); } - modifiers = X11InputState2NewtModifiers(evt.xkey.state); + modifiers |= X11InputState2NewtModifiers(evt.xkey.state) | autoRepeatModifiers; break; case ButtonPress: case ButtonRelease: case MotionNotify: - modifiers = X11InputState2NewtModifiers(evt.xbutton.state); + modifiers |= X11InputState2NewtModifiers(evt.xbutton.state); break; default: -- cgit v1.2.3 From 8777a6f0b8d5aa7c97643c68c4641593c6fa2c46 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 16 Sep 2012 21:24:58 +0200 Subject: Complete 646714d3dab87396b9a3119bf90ca26e0b1c97ce / Fix Bug 601: Add missing enqueueKeyEvent(..) in WindowsDriver; Fix API doc typo. --- .../classes/com/jogamp/newt/event/KeyEvent.java | 2 +- .../jogamp/newt/driver/windows/WindowDriver.java | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index bd48981da..7daaeada6 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -45,7 +45,7 @@ package com.jogamp.newt.event; * deliver keyboard events in the above order or skip events, * the NEWT driver will reorder and inject synthetic events if required. *

- * Besides regular modifiers like {@link InputEvent##SHIFT_MASK} etc., + * Besides regular modifiers like {@link InputEvent#SHIFT_MASK} etc., * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected. *

*/ diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 18cc88472..71437c461 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -313,7 +313,27 @@ public class WindowDriver extends WindowImpl { public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform keyCode = validateKeyCode(eventType, modifiers, keyCode, keyChar); - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); + switch(eventType) { + case KeyEvent.EVENT_KEY_RELEASED: + // reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED + break; + case KeyEvent.EVENT_KEY_PRESSED: + if(pressedKeyBalance > 1) { + // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. + // Since reordering already injects RELEASE, we only need to set the AUTOREPEAT_MASK. + pressedKeyBalance--; + autoRepeat |= InputEvent.AUTOREPEAT_MASK; + } else { + autoRepeat &= ~InputEvent.AUTOREPEAT_MASK; + } + super.enqueueKeyEvent(wait, eventType, modifiers | autoRepeat, keyCode, (char)-1); + break; + case KeyEvent.EVENT_KEY_TYPED: + modifiers |= autoRepeat; + super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); + break; + } } //---------------------------------------------------------------------- -- cgit v1.2.3 From 48f033d61dcf6c6d6964457710f6ac273ef4fc58 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 20 Sep 2012 23:18:30 +0200 Subject: NativeWindowFactory/NEWT: Use relative sub-package names in NativeWindowFactory's TYPE_* strings, not NEWT's; NEWTFactory: Use default NEWT package name if rel. 'path'. Use relative sub-package names in NativeWindowFactory's TYPE_* strings, not NEWT's Otherwise NEWT depends solely on NativeWindowFactory strings - Default subpackages denominate a relative path, i.e. start with a dot: '.egl', '.windows', '.x11' - Custom name may be absolute, eg: 'my.company.special.drivers.chip4' NEWTFactory: Use default NEWT package name if relative 'path'. - If NativeWindowFactory type starts w/ dot (rel. path), simply prepend the default NEWT package prefix otherwise use complete package name as-is. --- .../javax/media/nativewindow/NativeWindowFactory.java | 14 +++++++------- src/newt/classes/com/jogamp/newt/NewtFactory.java | 9 ++++++++- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src/newt/classes') diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 89d476a3b..40aaa8a25 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -57,25 +57,25 @@ public abstract class NativeWindowFactory { protected static final boolean DEBUG; /** OpenKODE/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/ - public static final String TYPE_EGL = "jogamp.newt.driver.kd".intern(); + public static final String TYPE_EGL = ".egl".intern(); /** Microsoft Windows type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */ - public static final String TYPE_WINDOWS = "jogamp.newt.driver.windows".intern(); + public static final String TYPE_WINDOWS = ".windows".intern(); /** X11 type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */ - public static final String TYPE_X11 = "jogamp.newt.driver.x11".intern(); + public static final String TYPE_X11 = ".x11".intern(); /** Android/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}.*/ - public static final String TYPE_ANDROID = "jogamp.newt.driver.android".intern(); + public static final String TYPE_ANDROID = ".android".intern(); /** Mac OS X type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */ - public static final String TYPE_MACOSX = "jogamp.newt.driver.macosx".intern(); + public static final String TYPE_MACOSX = ".macosx".intern(); /** Generic AWT type, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */ - public static final String TYPE_AWT = "jogamp.newt.driver.awt".intern(); + public static final String TYPE_AWT = ".awt".intern(); /** Generic DEFAULT type, where platform implementation don't care, as retrieved with {@link #getNativeWindowType(boolean)}. String is canonical via {@link String#intern()}. */ - public static final String TYPE_DEFAULT = "default".intern(); + public static final String TYPE_DEFAULT = ".default".intern(); private static final String nativeWindowingTypePure; // canonical String via String.intern() private static final String nativeWindowingTypeCustom; // canonical String via String.intern() diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 0644c9164..abae94ab6 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -49,6 +49,8 @@ import jogamp.newt.WindowImpl; public class NewtFactory { public static final boolean DEBUG_IMPLEMENTATION = Debug.debug("Window"); + public static final String DRIVER_DEFAULT_ROOT_PACKAGE = "jogamp.newt.driver"; + // Work-around for initialization order problems on Mac OS X // between native Newt and (apparently) Fmod static { @@ -59,7 +61,12 @@ public class NewtFactory { public static Class getCustomClass(String packageName, String classBaseName) { Class clazz = null; if(packageName!=null && classBaseName!=null) { - final String clazzName = packageName + "." + classBaseName ; + final String clazzName; + if( packageName.startsWith(".") ) { + clazzName = DRIVER_DEFAULT_ROOT_PACKAGE + packageName + "." + classBaseName ; + } else { + clazzName = packageName + "." + classBaseName ; + } try { clazz = Class.forName(clazzName); } catch (Throwable t) { -- cgit v1.2.3 From fbe331f013608eb31ff0d8675f4e4c9881c9c48b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 27 Sep 2012 17:33:39 +0200 Subject: Fix Bug 616: X11: Remove XInitThreads() dependency while cleaning up device locking, resulting in a native-lock-free impl. The X11 implementation details of NativeWindow and NEWT used the X11 implicit locking facility XLockDisplay/XUnlockDisplay, enabled via XInitThreads(). The latter useage is complicated within an unsure environment where the initialization point of JOGL is unknown, but XInitThreads() requires to be called once and before any other X11 calls. The solution is simple and thorough, replace native X11 locking w/ 'application level' locking. Following this pattern actually cleans up a pretty messy part of X11 NativeWindow and NEWT, since the generalization of platform independent locking simplifies code. Simply using our RecursiveLock also speeds up locking, since it doesn't require JNI calls down to X11 anymore. It allows us to get rid of X11ToolkitLock and X11JAWTToolkitLock. Using the RecursiveLock also allows us to remove the shortcut of explicitly createing a NullToolkitLocked device for 'private' display connections. All devices use proper locking as claimed in their toolkit util 'requiresToolkitLock()' in X11Util, OSXUtil, .. Further more a bug has been fixed of X11ErrorHandler usage, i.e. we need to keep our handler alive at all times due to async X11 messaging behavior. This allows to remove the redundant code in X11/NEWT. The AbstractGraphicsDevice lifecycle has been fixed as well, i.e. called when closing NEWT's Display for all driver implementations. On the NEWT side the Display's AbstractGraphicsDevice semantics has been clarified, i.e. it's usage for EDT and lifecycle operations. Hence the X11 Display 2nd device for rendering operations has been moved to X11 Window where it belongs - and the X11 Display's default device used for EDT/lifecycle-ops as it should be. This allows running X11/NEWT properly with the default usage, where the Display instance and hence the EDT thread is shared with many Screen and Window. Rendering using NEWT Window is decoupled from it's shared Display lock via it's own native X11 display. Lock free AbstractGraphicsDevice impl. (Windows, OSX, ..) don't require any attention in this regard since they use NullToolkitLock. Tests: ====== This implementation has been tested manually with Mesa3d (soft, Intel), ATI and Nvidia on X11, Windows and OSX w/o any regressions found in any unit test. Issues on ATI: ============== Only on ATI w/o a composite renderer the unit tests expose a driver or WM bug where XCB claims a lack of locking. Setting env. var 'LIBXCB_ALLOW_SLOPPY_LOCK=true' is one workaround if users refuse to enable compositing. We may investigate this issue in more detail later on. --- make/scripts/tests.sh | 50 ++++- .../classes/jogamp/opengl/egl/EGLDisplayUtil.java | 3 +- .../jogamp/opengl/x11/glx/X11GLXContext.java | 37 +--- .../opengl/x11/glx/X11GLXDrawableFactory.java | 13 +- .../jogamp/nativewindow/x11/X11GraphicsDevice.java | 2 +- .../jogamp/nativewindow/x11/X11GraphicsScreen.java | 2 +- .../media/nativewindow/AbstractGraphicsDevice.java | 2 +- .../media/nativewindow/DefaultGraphicsDevice.java | 3 +- .../media/nativewindow/NativeWindowFactory.java | 99 ++------- .../javax/media/nativewindow/ToolkitLock.java | 18 +- .../jogamp/nativewindow/NullToolkitLock.java | 9 + .../jogamp/nativewindow/ResourceToolkitLock.java | 74 +++++++ .../nativewindow/SharedResourceToolkitLock.java | 141 +++++++++++++ .../classes/jogamp/nativewindow/jawt/JAWTUtil.java | 3 + .../nativewindow/jawt/x11/X11JAWTToolkitLock.java | 76 ------- .../nativewindow/jawt/x11/X11JAWTWindow.java | 3 +- .../jogamp/nativewindow/x11/X11ToolkitLock.java | 70 ------ .../classes/jogamp/nativewindow/x11/X11Util.java | 119 ++++------- .../awt/X11AWTGraphicsConfigurationFactory.java | 7 +- src/nativewindow/native/x11/Xmisc.c | 38 ++-- src/newt/classes/com/jogamp/newt/Display.java | 35 ++- src/newt/classes/com/jogamp/newt/NewtFactory.java | 2 +- src/newt/classes/com/jogamp/newt/Screen.java | 2 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 79 ++++--- src/newt/classes/jogamp/newt/ScreenImpl.java | 3 +- src/newt/classes/jogamp/newt/WindowImpl.java | 33 +-- .../jogamp/newt/driver/awt/DisplayDriver.java | 4 +- .../jogamp/newt/driver/bcm/egl/DisplayDriver.java | 2 + .../newt/driver/intel/gdl/DisplayDriver.java | 1 + .../jogamp/newt/driver/macosx/DisplayDriver.java | 4 +- .../jogamp/newt/driver/windows/DisplayDriver.java | 1 + .../jogamp/newt/driver/x11/DisplayDriver.java | 65 ++---- .../jogamp/newt/driver/x11/ScreenDriver.java | 31 ++- .../jogamp/newt/driver/x11/WindowDriver.java | 107 +++++++--- src/newt/native/X11Common.h | 1 - src/newt/native/X11Display.c | 91 -------- src/newt/native/X11Window.c | 10 - .../junit/jogl/acore/InitConcurrentBaseNEWT.java | 219 +++++++++++++++++++ .../junit/jogl/acore/TestInitConcurrent01NEWT.java | 78 +++++++ .../junit/jogl/acore/TestInitConcurrent02NEWT.java | 78 +++++++ .../junit/jogl/acore/TestInitConcurrentNEWT.java | 235 --------------------- 41 files changed, 964 insertions(+), 886 deletions(-) create mode 100644 src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java delete mode 100644 src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTToolkitLock.java delete mode 100644 src/nativewindow/classes/jogamp/nativewindow/x11/X11ToolkitLock.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent02NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8a0a638ba..3dc983072 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -81,6 +81,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Djogl.debug.GLSLState" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.UseCurrentThreadLibLoader" + #D_ARGS="-Djogamp.debug.NativeLibrary" #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading" #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" @@ -100,7 +101,6 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" - #D_ARGS="-Dnewt.debug.EDT -Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.NativeWindow" #D_ARGS="-Dnativewindow.debug.NativeWindow" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" @@ -109,6 +109,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext" + #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnativewindow.debug.X11Util" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock -Dnativewindow.debug.ToolkitLock.TraceLock" @@ -135,7 +136,9 @@ function jrun() { #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas" - #D_ARGS="-Dnativewindow.debug.ToolkitLock.TraceLock" + #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" + #D_ARGS="-Dnativewindow.debug.X11Util.XSync" + #D_ARGS="-Dnativewindow.debug.ToolkitLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" @@ -187,6 +190,8 @@ function jrun() { #export LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64:$LD_LIBRARY_PATH #export LD_LIBRARY_PATH=/usr/lib/mesa:/usr/lib32/mesa:$LD_LIBRARY_PATH #export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/mesa:/usr/lib/i386-linux-gnu/mesa:$LD_LIBRARY_PATH + #export LD_LIBRARY_PATH=`pwd`/lib/external/mesa/x86_64-linux-gnu:$LD_LIBRARY_PATH + #export LD_LIBRARY_PATH=`pwd`/lib/external/mesa/x86_64-linux-gnu/gallium:$LD_LIBRARY_PATH echo echo "Test Start: $*" echo @@ -194,10 +199,10 @@ function jrun() { echo echo $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* #LIBGL_DRIVERS_PATH=/usr/lib/mesa:/usr/lib32/mesa \ - #gdb --args $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* #LIBGL_DEBUG=verbose INTEL_STRICT_CONFORMANCE=1 INTEL_DEBUG="buf bat" \ #LIBGL_DEBUG=verbose MESA_DEBUG=true INTEL_STRICT_CONFORMANCE=1 \ - #LIBGL_DEBUG=verbose MESA_DEBUG=true LIBGL_ALWAYS_SOFTWARE=true \ + #export LIBGL_DEBUG=verbose MESA_DEBUG=true LIBGL_ALWAYS_SOFTWARE=true + #gdb --args $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* echo echo "Test End: $*" @@ -239,7 +244,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* @@ -250,6 +256,38 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +# x11 no XinitThreads() specific tests (regressions, concurrent behavior) ! +# Deadlock: +# com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 - test01 +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* +# com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT - testEachWithAnimatorSharedOffscreen +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* +# +# XCB: +# +# com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT - testShaderState01PerformanceDouble +#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* +# com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT - testWindowParenting02ReparentTop2WinReparentRecreate +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +# com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT - winHopFrame2FrameDirectHop +#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* + +#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* + + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* @@ -322,7 +360,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index ce2e824f5..0a603ab8a 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -71,10 +71,9 @@ public class EGLDisplayUtil { Thread.dumpStack(); } if( eglDisplayCounter.size() > 0) { - EGLDisplayUtil.dumpOpenDisplayConnections(); + dumpOpenDisplayConnections(); } } - return eglDisplayCounter.size(); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index e1e25be67..bdccc1047 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -172,7 +172,6 @@ public abstract class X11GLXContext extends GLContextImpl { glXMakeContextCurrent(display, 0, 0, 0); GLX.glXDestroyContext(display, ctx); } - private static final int ctx_arb_attribs_idx_major = 0; private static final int ctx_arb_attribs_idx_minor = 2; private static final int ctx_arb_attribs_idx_flags = 6; @@ -228,14 +227,14 @@ public abstract class X11GLXContext extends GLContextImpl { X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration(); AbstractGraphicsDevice device = config.getScreen().getDevice(); - long display = device.getHandle(); + final long display = device.getHandle(); try { // critical path, a remote display might not support this command, // hence we need to catch the X11 Error within this block. - X11Lib.XSync(display, false); + X11Util.setX11ErrorHandler(true, DEBUG ? false : true); // make sure X11 error handler is set ctx = _glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs); - X11Lib.XSync(display, false); + if(DEBUG) { X11Lib.XSync(display, false); } } catch (RuntimeException re) { if(DEBUG) { Throwable t = new Throwable(getThreadName()+": Info: X11GLXContext.createContextARBImpl glXCreateContextAttribsARB failed with "+getGLVersion(major, minor, ctp, "@creation"), re); @@ -263,16 +262,6 @@ public abstract class X11GLXContext extends GLContextImpl { @Override protected boolean createImpl(GLContextImpl shareWith) { - // covers the whole context creation loop incl createContextARBImpl and destroyContextARBImpl - X11Util.setX11ErrorHandler(true, DEBUG ? false : true); - try { - return createImplRaw(shareWith); - } finally { - X11Util.setX11ErrorHandler(false, false); - } - } - - private boolean createImplRaw(GLContextImpl shareWith) { boolean direct = true; // try direct always isDirect = false; // fall back @@ -401,14 +390,9 @@ public abstract class X11GLXContext extends GLContextImpl { protected void makeCurrentImpl() throws GLException { long dpy = drawable.getNativeSurface().getDisplayHandle(); - if (GLX.glXGetCurrentContext() != contextHandle) { - X11Util.setX11ErrorHandler(true, DEBUG ? false : true); - try { - if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { - throw new GLException(getThreadName()+": Error making context current: "+this); - } - } finally { - X11Util.setX11ErrorHandler(false, false); + if (GLX.glXGetCurrentContext() != contextHandle) { + if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { + throw new GLException(getThreadName()+": Error making context current: "+this); } } } @@ -416,13 +400,8 @@ public abstract class X11GLXContext extends GLContextImpl { @Override protected void releaseImpl() throws GLException { long display = drawable.getNativeSurface().getDisplayHandle(); - X11Util.setX11ErrorHandler(true, DEBUG ? false : true); - try { - if (!glXMakeContextCurrent(display, 0, 0, 0)) { - throw new GLException(getThreadName()+": Error freeing OpenGL context"); - } - } finally { - X11Util.setX11ErrorHandler(false, false); + if (!glXMakeContextCurrent(display, 0, 0, 0)) { + throw new GLException(getThreadName()+": Error freeing OpenGL context"); } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index ca5cd424b..03c661565 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -47,7 +47,6 @@ import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.nativewindow.VisualIDHolder; @@ -230,11 +229,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { @Override public SharedResourceRunner.Resource createSharedResource(String connection) { - final X11GraphicsDevice sharedDevice = - new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, - true); // own non-shared display connection, w/ locking - // new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, - // NativeWindowFactory.getNullToolkitLock(), true); // own non-shared display connection, w/o locking + final X11GraphicsDevice sharedDevice = new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, true); sharedDevice.lock(); try { final X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, sharedDevice.getDefaultScreen()); @@ -509,8 +504,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final X11GraphicsDevice device; if(createNewDevice) { - // Null X11 locking, due to private non-shared Display handle - device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), NativeWindowFactory.getNullToolkitLock(), true); + // Null X11 resource locking, due to private non-shared Display handle + device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true); } else { device = (X11GraphicsDevice)deviceReq; } @@ -531,7 +526,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { @Override protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { - final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), NativeWindowFactory.getNullToolkitLock(), true); + final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true); final X11GraphicsScreen screen = new X11GraphicsScreen(device, screenIdx); final int xvisualID = X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle); if(VisualIDHolder.VID_UNDEFINED == xvisualID) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index 152384980..2e4099c1b 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -73,7 +73,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl /** * @param display the Display connection - * @param locker custom {@link javax.media.nativewindow.ToolkitLock}, eg to force null locking in NEWT + * @param locker custom {@link javax.media.nativewindow.ToolkitLock}, eg to force null locking w/ private connection * @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int, long, ToolkitLock) */ public X11GraphicsDevice(long display, int unitID, ToolkitLock locker, boolean owner) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java index 5f3c220ca..7ab5bd6aa 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java @@ -63,7 +63,7 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl private static int fetchScreen(X11GraphicsDevice device, int screen) { // It still could be an AWT hold handle .. - if(X11Util.XineramaIsEnabled(device.getHandle())) { + if(X11Util.XineramaIsEnabled(device)) { screen = 0; // Xinerama -> 1 screen } return screen; diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java index 756e4451b..5eaaa6613 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java @@ -131,7 +131,7 @@ public interface AbstractGraphicsDevice extends Cloneable { /** * Optionally closing the device if handle is not null. *

- * The default implementation is a NOP, just setting the handle to null. + * The default implementation {@link ToolkitLock#dispose() dispose} it's {@link ToolkitLock} and sets the handle to null. *

*

* Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java index 583fde07f..b16b0c75c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java @@ -153,6 +153,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice @Override public boolean close() { + toolkitLock.dispose(); if(0 != handle) { handle = 0; return true; @@ -162,7 +163,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice @Override public String toString() { - return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+"]"; + return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", "+toolkitLock+"]"; } /** diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 40aaa8a25..4f4bb629b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -33,7 +33,6 @@ package javax.media.nativewindow; -import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; @@ -43,6 +42,7 @@ import java.util.Map; import jogamp.nativewindow.Debug; import jogamp.nativewindow.NativeWindowFactoryImpl; +import jogamp.nativewindow.ResourceToolkitLock; import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; @@ -93,13 +93,6 @@ public abstract class NativeWindowFactory { private static ToolkitLock jawtUtilJAWTToolkitLock; - public static final String X11JAWTToolkitLockClassName = "jogamp.nativewindow.jawt.x11.X11JAWTToolkitLock" ; - public static final String X11ToolkitLockClassName = "jogamp.nativewindow.x11.X11ToolkitLock" ; - - private static Class x11JAWTToolkitLockClass; - private static Constructor x11JAWTToolkitLockConstructor; - private static Class x11ToolkitLockClass; - private static Constructor x11ToolkitLockConstructor; private static boolean requiresToolkitLock; private static volatile boolean isJVMShuttingDown = false; @@ -266,16 +259,6 @@ public abstract class NativeWindowFactory { // register either our default factory or (if exist) the X11/AWT one -> AWT Component registerFactory(ReflectionUtil.getClass(ReflectionUtil.AWTNames.ComponentClass, false, cl), factory); } - - if( TYPE_X11 == nativeWindowingTypePure ) { - // passing through RuntimeException if not exists intended - x11ToolkitLockClass = ReflectionUtil.getClass(X11ToolkitLockClassName, false, cl); - x11ToolkitLockConstructor = ReflectionUtil.getConstructor(x11ToolkitLockClass, new Class[] { long.class } ); - if( isAWTAvailable() ) { - x11JAWTToolkitLockClass = ReflectionUtil.getClass(X11JAWTToolkitLockClassName, false, cl); - x11JAWTToolkitLockConstructor = ReflectionUtil.getConstructor(x11JAWTToolkitLockClass, new Class[] { long.class } ); - } - } if(DEBUG) { System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock); @@ -300,6 +283,7 @@ public abstract class NativeWindowFactory { GraphicsConfigurationFactory.shutdown(); } shutdownNativeImpl(NativeWindowFactory.class.getClassLoader()); // always re-shutdown + // SharedResourceToolkitLock.shutdown(DEBUG); // not used yet if(DEBUG) { System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.shutdown() END JVM Shutdown "+isJVMShuttingDown); } @@ -358,16 +342,9 @@ public abstract class NativeWindowFactory { /** * Provides the default {@link ToolkitLock} for type, a singleton instance. - *
*

    - *
  • If {@link #initSingleton(boolean) initSingleton( firstUIActionOnProcess := false )}
  • - *
      - *
    • If AWT-type and native-X11-type and AWT-available
    • - *
        - *
      • return {@link #getAWTToolkitLock()}
      • - *
      - *
    - *
  • Otherwise return {@link #getNullToolkitLock()}
  • + *
  • JAWT {@link ToolkitLock} if required and AWT available, otherwise
  • + *
  • {@link jogamp.nativewindow.NullToolkitLock}
  • *
*/ public static ToolkitLock getDefaultToolkitLock(String type) { @@ -390,84 +367,36 @@ public abstract class NativeWindowFactory { /** * Creates the default {@link ToolkitLock} for type and deviceHandle. - *
*
    - *
  • If {@link #initSingleton(boolean) initSingleton( firstUIActionOnProcess := false )}
  • - *
      - *
    • If X11 type
    • - *
        - *
      • return {@link jogamp.nativewindow.x11.X11ToolkitLock}
      • - *
      - *
    - *
  • Otherwise return {@link jogamp.nativewindow.NullToolkitLock}
  • + *
  • {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
  • + *
  • {@link jogamp.nativewindow.NullToolkitLock}
  • *
*/ public static ToolkitLock createDefaultToolkitLock(String type, long deviceHandle) { if( requiresToolkitLock() ) { - if( TYPE_X11 == type ) { - if( 0== deviceHandle ) { - throw new RuntimeException("JAWTUtil.createDefaultToolkitLock() called with NULL device but on X11"); - } - return createX11ToolkitLock(deviceHandle); - } + return ResourceToolkitLock.create(); } return NativeWindowFactoryImpl.getNullToolkitLock(); } /** * Creates the default {@link ToolkitLock} for type and deviceHandle. - *
*
    - *
  • If {@link #initSingleton(boolean) initSingleton( firstUIActionOnProcess := false )}
  • - *
      - *
    • If X11 type
    • - *
        - *
      • If shared-AWT-type and AWT available
      • - *
          - *
        • return {@link jogamp.nativewindow.jawt.x11.X11JAWTToolkitLock}
        • - *
        - *
      • else return {@link jogamp.nativewindow.x11.X11ToolkitLock}
      • - *
      - *
    - *
  • Otherwise return {@link jogamp.nativewindow.NullToolkitLock}
  • + *
  • JAWT {@link ToolkitLock} if required and AWT available,
  • + *
  • {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
  • + *
  • {@link jogamp.nativewindow.NullToolkitLock}
  • *
*/ public static ToolkitLock createDefaultToolkitLock(String type, String sharedType, long deviceHandle) { if( requiresToolkitLock() ) { - if( TYPE_X11 == type ) { - if( 0== deviceHandle ) { - throw new RuntimeException("JAWTUtil.createDefaultToolkitLock() called with NULL device but on X11"); - } - if( TYPE_AWT == sharedType && isAWTAvailable() ) { - return createX11AWTToolkitLock(deviceHandle); - } - return createX11ToolkitLock(deviceHandle); + if( TYPE_AWT == sharedType && isAWTAvailable() ) { + return getAWTToolkitLock(); } + return ResourceToolkitLock.create(); } return NativeWindowFactoryImpl.getNullToolkitLock(); } - - protected static ToolkitLock createX11AWTToolkitLock(long deviceHandle) { - try { - if(DEBUG) { - System.err.println("NativeWindowFactory.createX11AWTToolkitLock(0x"+Long.toHexString(deviceHandle)+")"); - // Thread.dumpStack(); - } - return (ToolkitLock) x11JAWTToolkitLockConstructor.newInstance(new Object[]{new Long(deviceHandle)}); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - - protected static ToolkitLock createX11ToolkitLock(long deviceHandle) { - try { - return (ToolkitLock) x11ToolkitLockConstructor.newInstance(new Object[]{new Long(deviceHandle)}); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - - + /** Returns the appropriate NativeWindowFactory to handle window objects of the given type. The windowClass might be {@link NativeWindow NativeWindow}, in which case the client has diff --git a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java index 30f9660f0..18b7cf5d9 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java @@ -33,12 +33,26 @@ import jogamp.nativewindow.Debug; /** * Marker for a singleton global recursive blocking lock implementation, * optionally locking a native windowing toolkit as well. - *
- * One use case is the AWT locking on X11, see {@link jogamp.nativewindow.jawt.JAWTToolkitLock}. + *

+ * Toolkit locks are created solely via {@link NativeWindowFactory}. + *

+ *

+ * One use case is the AWT locking on X11, see {@link NativeWindowFactory#createDefaultToolkitLock(String, long)}. + *

*/ public interface ToolkitLock { public static final boolean TRACE_LOCK = Debug.isPropertyDefined("nativewindow.debug.ToolkitLock.TraceLock", true); public void lock(); public void unlock(); + + /** + * Dispose this instance. + *

+ * Shall be called when instance is no more required. + *

+ * This allows implementations sharing a lock via resources + * to decrease the reference counter. + */ + public void dispose(); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java index 1af6bf279..e59910138 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java @@ -50,4 +50,13 @@ public class NullToolkitLock implements ToolkitLock { public final void unlock() { if(TRACE_LOCK) { System.err.println("NullToolkitLock.unlock()"); } } + + public final void dispose() { + // nop + } + + public String toString() { + return "NullToolkitLock[]"; + } + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java new file mode 100644 index 000000000..a3b0804fa --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java @@ -0,0 +1,74 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.nativewindow; + +import javax.media.nativewindow.ToolkitLock; + +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; + +/** + * Implementing a resource based recursive {@link javax.media.nativewindow.ToolkitLock}. + *

+ * A resource handle maybe used within a unique object + * and can be synchronized across threads via an instance of ResourceToolkitLock. + *

+ */ +public class ResourceToolkitLock implements ToolkitLock { + public static final boolean DEBUG = Debug.debug("ToolkitLock"); + + public static final ResourceToolkitLock create() { + return new ResourceToolkitLock(); + } + + private final RecursiveLock lock; + + private ResourceToolkitLock() { + this.lock = LockFactory.createRecursiveLock(); + } + + + public final void lock() { + if(TRACE_LOCK) { System.err.println("ResourceToolkitLock.lock()"); } + lock.lock(); + } + + public final void unlock() { + if(TRACE_LOCK) { System.err.println("ResourceToolkitLock.unlock()"); } + lock.unlock(); + } + + public final void dispose() { + // nop + } + + public String toString() { + return "ResourceToolkitLock[obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString()+"]"; + } +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java new file mode 100644 index 000000000..5d7ae8abb --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java @@ -0,0 +1,141 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.nativewindow; + +import java.util.Iterator; + +import javax.media.nativewindow.ToolkitLock; + +import com.jogamp.common.util.LongObjectHashMap; +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; + +/** + * Implementing a shared resource based recursive {@link javax.media.nativewindow.ToolkitLock}. + *

+ * A resource handle maybe used within many objects + * and can be synchronized across threads via an unique instance of SharedResourceToolkitLock. + *

+ *

+ * Implementation holds a synchronized map from handle to reference counted {@link SharedResourceToolkitLock}. + * New elements are added via {@link #get(long)} if new + * and removed via {@link #dispose()} if no more referenced. + *

+ */ +public class SharedResourceToolkitLock implements ToolkitLock { + public static final boolean DEBUG = Debug.debug("ToolkitLock"); + private static final LongObjectHashMap handle2Lock; + static { + handle2Lock = new LongObjectHashMap(); + handle2Lock.setKeyNotFoundValue(null); + } + + /** + * @return number of unclosed EGL Displays.
+ */ + public static int shutdown(boolean verbose) { + if(DEBUG || verbose || handle2Lock.size() > 0 ) { + System.err.println("SharedResourceToolkitLock: Shutdown (open: "+handle2Lock.size()+")"); + if(DEBUG) { + Thread.dumpStack(); + } + if( handle2Lock.size() > 0) { + dumpOpenDisplayConnections(); + } + } + return handle2Lock.size(); + } + + public static void dumpOpenDisplayConnections() { + System.err.println("SharedResourceToolkitLock: Open ResourceToolkitLock's: "+handle2Lock.size()); + int i=0; + for(Iterator iter = handle2Lock.iterator(); iter.hasNext(); i++) { + final LongObjectHashMap.Entry e = iter.next(); + System.err.println("SharedResourceToolkitLock: Open["+i+"]: "+e.value); + } + } + + public static final SharedResourceToolkitLock get(long handle) { + SharedResourceToolkitLock res; + synchronized(handle2Lock) { + res = (SharedResourceToolkitLock) handle2Lock.get(handle); + if( null == res ) { + res = new SharedResourceToolkitLock(handle); + res.refCount++; + handle2Lock.put(handle, res); + if(DEBUG || TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.get() * NEW *: "+res); } + } else { + res.refCount++; + if(DEBUG || TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.get() * EXIST *: "+res); } + } + } + return res; + } + + private final RecursiveLock lock; + private final long handle; + private volatile int refCount; + + private SharedResourceToolkitLock(long handle) { + this.lock = LockFactory.createRecursiveLock(); + this.handle = handle; + this.refCount = 0; + } + + + public final void lock() { + if(TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.lock()"); } + lock.lock(); + } + + public final void unlock() { + if(TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.unlock()"); } + lock.unlock(); + } + + public final void dispose() { + if(0 < refCount) { // volatile OK + synchronized(handle2Lock) { + refCount--; + if(0 == refCount) { + if(DEBUG || TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.dispose() * REMOV *: "+this); } + handle2Lock.remove(handle); + } else { + if(DEBUG || TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.dispose() * DOWN *: "+this); } + } + } + } else { + if(DEBUG || TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.dispose() * NULL *: "+this); } + } + } + + public String toString() { + return "SharedResourceToolkitLock[refCount "+refCount+", handle 0x"+Long.toHexString(handle)+", obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString()+"]"; + } +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index f1e8a786a..7c934b154 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -237,6 +237,9 @@ public class JAWTUtil { public final void unlock() { JAWTUtil.unlockToolkit(); } + public final void dispose() { + // nop + } }; // trigger native AWT toolkit / properties initialization diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTToolkitLock.java deleted file mode 100644 index 743d371b7..000000000 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTToolkitLock.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package jogamp.nativewindow.jawt.x11; - -import jogamp.nativewindow.jawt.*; -import jogamp.nativewindow.x11.X11Lib; -import jogamp.nativewindow.x11.X11Util; -import javax.media.nativewindow.ToolkitLock; - -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; - -/** - * Implementing a recursive {@link javax.media.nativewindow.ToolkitLock} - * utilizing JAWT's AWT lock via {@link JAWTUtil#lockToolkit()} and {@link X11Util#XLockDisplay(long)}. - *
- * This strategy should only be used if AWT is using the underlying native windowing toolkit - * in a not intrinsic thread safe manner, e.g. under X11 where no XInitThreads() call - * is issued before any other X11 usage. This is the current situation for e.g. Webstart or Applets. - */ -public class X11JAWTToolkitLock implements ToolkitLock { - long displayHandle; - RecursiveLock lock; - - public X11JAWTToolkitLock(long displayHandle) { - this.displayHandle = displayHandle; - if(!X11Util.isNativeLockAvailable()) { - lock = LockFactory.createRecursiveLock(); - } - } - - public final void lock() { - if(TRACE_LOCK) { System.err.println("X11JAWTToolkitLock.lock() - native: "+(null==lock)); } - JAWTUtil.lockToolkit(); - if(null == lock) { - X11Lib.XLockDisplay(displayHandle); - } else { - lock.lock(); - } - } - - public final void unlock() { - if(TRACE_LOCK) { System.err.println("X11JAWTToolkitLock.unlock() - native: "+(null==lock)); } - if(null == lock) { - X11Lib.XUnlockDisplay(displayHandle); - } else { - lock.unlock(); - } - JAWTUtil.unlockToolkit(); - } -} diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java index 736718de8..467809284 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java @@ -127,7 +127,8 @@ public class X11JAWTWindow extends JAWTWindow { } protected Point getLocationOnScreenNativeImpl(int x, int y) { - return X11Lib.GetRelativeLocation( getDisplayHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); + // surface is locked and hence the device + return X11Lib.GetRelativeLocation(getDisplayHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); } // Variables for lockSurface/unlockSurface diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11ToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11ToolkitLock.java deleted file mode 100644 index 5166ef577..000000000 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11ToolkitLock.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package jogamp.nativewindow.x11; - -import javax.media.nativewindow.ToolkitLock; - -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; - -/** - * Implementing a recursive {@link javax.media.nativewindow.ToolkitLock} - * utilizing {@link X11Util#XLockDisplay(long)}. - *
- * This strategy should not be used in case XInitThreads() is being used, - * or a higher level toolkit lock is required, ie AWT lock. - */ -public class X11ToolkitLock implements ToolkitLock { - long displayHandle; - RecursiveLock lock; - - public X11ToolkitLock(long displayHandle) { - this.displayHandle = displayHandle; - if(!X11Util.isNativeLockAvailable()) { - lock = LockFactory.createRecursiveLock(); - } - } - - public final void lock() { - if(TRACE_LOCK) { System.err.println("X11ToolkitLock.lock() - native: "+(null==lock)); } - if(null == lock) { - X11Lib.XLockDisplay(displayHandle); - } else { - lock.lock(); - } - } - - public final void unlock() { - if(TRACE_LOCK) { System.err.println("X11ToolkitLock.unlock() - native: "+(null==lock)); } - if(null == lock) { - X11Lib.XUnlockDisplay(displayHandle); - } else { - lock.unlock(); - } - } -} diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 2ea75c7fb..60f54eb3c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -42,8 +42,8 @@ import javax.media.nativewindow.NativeWindowFactory; import jogamp.nativewindow.Debug; import jogamp.nativewindow.NWJNILibLoader; - import com.jogamp.common.util.LongObjectHashMap; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; /** * Contains a thread safe X11 utility to retrieve display connections. @@ -80,25 +80,15 @@ public class X11Util { */ public static final boolean ATI_HAS_XCLOSEDISPLAY_BUG = !Debug.isPropertyDefined("nativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG", true); - /** Value is true, best 'stable' results if always using XInitThreads(). */ - public static final boolean XINITTHREADS_ALWAYS_ENABLED = true; - - /** Value is true, best 'stable' results if not using XLockDisplay/XUnlockDisplay at all. */ - public static final boolean HAS_XLOCKDISPLAY_BUG = true; - public static final boolean DEBUG = Debug.debug("X11Util"); public static final boolean XSYNC_ENABLED = Debug.isPropertyDefined("nativewindow.debug.X11Util.XSync", true); public static final boolean XERROR_STACKDUMP = DEBUG || Debug.isPropertyDefined("nativewindow.debug.X11Util.XErrorStackDump", true); private static final boolean TRACE_DISPLAY_LIFECYCLE = Debug.isPropertyDefined("nativewindow.debug.X11Util.TraceDisplayLifecycle", true); private static String nullDisplayName = null; - private static boolean isX11LockAvailable = false; - private static boolean requiresX11Lock = true; private static volatile boolean isInit = false; private static boolean markAllDisplaysUnclosable = false; // ATI/AMD X11 driver issues - private static int setX11ErrorHandlerRecCount = 0; private static Object setX11ErrorHandlerLock = new Object(); - /** * Called by {@link NativeWindowFactory#initSingleton()} @@ -115,9 +105,7 @@ public class X11Util { throw new NativeWindowException("NativeWindow X11 native library load error."); } - final boolean callXInitThreads = XINITTHREADS_ALWAYS_ENABLED ; - final boolean isXInitThreadsOK = initialize0( callXInitThreads, XERROR_STACKDUMP); - isX11LockAvailable = isXInitThreadsOK && !HAS_XLOCKDISPLAY_BUG ; + final boolean isInitOK = initialize0( XERROR_STACKDUMP ); final long dpy = X11Lib.XOpenDisplay(null); if(0 != dpy) { @@ -134,9 +122,7 @@ public class X11Util { } if(DEBUG) { - System.err.println("X11Util requiresX11Lock "+requiresX11Lock+ - ", XInitThreads [called "+callXInitThreads+", OK "+isXInitThreadsOK+"]"+ - ", isX11LockAvailable "+isX11LockAvailable+ + System.err.println("X11Util init OK "+isInitOK+"]"+ ", X11 Display(NULL) <"+nullDisplayName+">"+ ", XSynchronize Enabled: "+XSYNC_ENABLED); // Thread.dumpStack(); @@ -199,31 +185,14 @@ public class X11Util { } } } - - public static synchronized boolean isNativeLockAvailable() { - return isX11LockAvailable; - } - - public static synchronized boolean requiresToolkitLock() { - return requiresX11Lock; + + public static boolean requiresToolkitLock() { + return true; // JAWT locking: yes, instead of native X11 locking w use a recursive lock. } - + public static void setX11ErrorHandler(boolean onoff, boolean quiet) { synchronized(setX11ErrorHandlerLock) { - if(onoff) { - if(0==setX11ErrorHandlerRecCount) { - setX11ErrorHandler0(true, quiet); - } - setX11ErrorHandlerRecCount++; - } else { - if(0 >= setX11ErrorHandlerRecCount) { - throw new InternalError(); - } - setX11ErrorHandlerRecCount--; - if(0==setX11ErrorHandlerRecCount) { - setX11ErrorHandler0(false, false); - } - } + setX11ErrorHandler0(onoff, quiet); } } @@ -492,52 +461,50 @@ public class X11Util { *******************************/ public static long XOpenDisplay(String arg0) { - NativeWindowFactory.getDefaultToolkitLock().lock(); - try { - long handle = X11Lib.XOpenDisplay(arg0); - if(XSYNC_ENABLED && 0 != handle) { - X11Lib.XSynchronize(handle, true); - } - if(TRACE_DISPLAY_LIFECYCLE) { - System.err.println(Thread.currentThread()+" - X11Util.XOpenDisplay("+arg0+") 0x"+Long.toHexString(handle)); - // Thread.dumpStack(); - } - return handle; - } finally { - NativeWindowFactory.getDefaultToolkitLock().unlock(); + long handle = X11Lib.XOpenDisplay(arg0); + if(XSYNC_ENABLED && 0 != handle) { + X11Lib.XSynchronize(handle, true); + } + if(TRACE_DISPLAY_LIFECYCLE) { + System.err.println(Thread.currentThread()+" - X11Util.XOpenDisplay("+arg0+") 0x"+Long.toHexString(handle)); + // Thread.dumpStack(); } + return handle; } public static int XCloseDisplay(long display) { - NativeWindowFactory.getDefaultToolkitLock().lock(); + if(TRACE_DISPLAY_LIFECYCLE) { + System.err.println(Thread.currentThread()+" - X11Util.XCloseDisplay() 0x"+Long.toHexString(display)); + // Thread.dumpStack(); + } + int res = -1; try { - if(TRACE_DISPLAY_LIFECYCLE) { - System.err.println(Thread.currentThread()+" - X11Util.XCloseDisplay() 0x"+Long.toHexString(display)); - // Thread.dumpStack(); - } - int res = -1; - X11Util.setX11ErrorHandler(true, DEBUG ? false : true); - try { - res = X11Lib.XCloseDisplay(display); - } catch (Exception ex) { - System.err.println("X11Util: Catched Exception:"); - ex.printStackTrace(); - } finally { - X11Util.setX11ErrorHandler(false, false); - } - return res; - } finally { - NativeWindowFactory.getDefaultToolkitLock().unlock(); + res = X11Lib.XCloseDisplay(display); + } catch (Exception ex) { + System.err.println("X11Util: Catched Exception:"); + ex.printStackTrace(); } + return res; } static volatile boolean XineramaFetched = false; static long XineramaLibHandle = 0; static long XineramaQueryFunc = 0; - public static boolean XineramaIsEnabled(long display) { - if(0==display) { - throw new IllegalArgumentException("Display NULL"); + public static boolean XineramaIsEnabled(X11GraphicsDevice device) { + if(null == device) { + throw new IllegalArgumentException("X11 Display device is NULL"); + } + device.lock(); + try { + return XineramaIsEnabled(device.getHandle()); + } finally { + device.unlock(); + } + } + public static boolean XineramaIsEnabled(long displayHandle) { + if( 0 == displayHandle ) { + throw new IllegalArgumentException("X11 Display handle is NULL"); } if(!XineramaFetched) { // volatile: ok synchronized(X11Util.class) { @@ -551,9 +518,9 @@ public class X11Util { } } if(0!=XineramaQueryFunc) { - final boolean res = X11Lib.XineramaIsEnabled(XineramaQueryFunc, display); + final boolean res = X11Lib.XineramaIsEnabled(XineramaQueryFunc, displayHandle); if(DEBUG) { - System.err.println("XineramaIsEnabled: "+res); + System.err.println("XineramaIsEnabled: 0x"+Long.toHexString(displayHandle)+": "+res); } return res; } else if(DEBUG) { @@ -566,7 +533,7 @@ public class X11Util { private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI - private static native boolean initialize0(boolean firstUIActionOnProcess, boolean debug); + private static native boolean initialize0(boolean debug); private static native void shutdown0(); private static native void setX11ErrorHandler0(boolean onoff, boolean quiet); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java index 1de03e8be..b152f0f97 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java @@ -91,7 +91,7 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac final long displayHandleAWT = X11SunJDKReflection.graphicsDeviceGetDisplay(device); final long displayHandle; - boolean owner = false; + final boolean owner; if(0==displayHandleAWT) { displayHandle = X11Util.openDisplay(null); owner = true; @@ -112,9 +112,8 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac System.err.println(getThreadName()+" - X11AWTGraphicsConfigurationFactory: AWT dpy "+displayName+" / "+toHexString(displayHandleAWT)+", create X11 display "+toHexString(displayHandle)); } } - final ToolkitLock lock = owner ? - NativeWindowFactory.getDefaultToolkitLock(NativeWindowFactory.TYPE_AWT) : // own non-shared X11 display connection, no X11 lock - NativeWindowFactory.createDefaultToolkitLock(NativeWindowFactory.TYPE_X11, NativeWindowFactory.TYPE_AWT, displayHandle); + // Global JAWT lock required - No X11 resource locking due to private display connection + final ToolkitLock lock = NativeWindowFactory.getDefaultToolkitLock(NativeWindowFactory.TYPE_AWT); final X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, lock, owner); final X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex()); if(DEBUG) { diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index fcba8580c..afdd413eb 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -178,11 +178,14 @@ static int x11ErrorHandler(Display *dpy, XErrorEvent *e) char threadName[80]; char errCodeStr[80]; char reqCodeStr[80]; - int shallBeDetached = 0; - JNIEnv *jniEnv = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); + JNIEnv *jniEnv = NULL; + if( errorHandlerDebug || errorHandlerThrowException ) { + jniEnv = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); + } (void) NativewindowCommon_GetStaticStringMethod(jniEnv, X11UtilClazz, getCurrentThreadNameID, threadName, sizeof(threadName), "n/a"); + snprintf(errCodeStr, sizeof(errCodeStr), "%d", e->request_code); XGetErrorDatabaseText(dpy, "XRequest", errCodeStr, "Unknown", reqCodeStr, sizeof(reqCodeStr)); XGetErrorText(dpy, e->error_code, errCodeStr, sizeof(errCodeStr)); @@ -191,7 +194,7 @@ static int x11ErrorHandler(Display *dpy, XErrorEvent *e) threadName, e->error_code, errCodeStr, e->display, (int)e->resourceid, (int)e->serial, (int)e->request_code, (int)e->minor_code, reqCodeStr); - if( errorHandlerDebug ) { + if( errorHandlerDebug && NULL != jniEnv ) { (*jniEnv)->CallStaticVoidMethod(jniEnv, X11UtilClazz, dumpStackID); } @@ -246,16 +249,17 @@ static int x11IOErrorHandler(Display *dpy) { const char * dpyName = XDisplayName(NULL); const char * errnoStr = strerror(errno); - char threadName[80]; int shallBeDetached = 0; - JNIEnv *jniEnv = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); - - (void) NativewindowCommon_GetStaticStringMethod(jniEnv, X11UtilClazz, getCurrentThreadNameID, threadName, sizeof(threadName), "n/a"); + JNIEnv *jniEnv = NULL; - fprintf(stderr, "Nativewindow X11 IOError (Thread %s): Display %p (%s): %s\n", threadName, dpy, dpyName, errnoStr); + fprintf(stderr, "Nativewindow X11 IOError: Display %p (%s): %s\n", dpy, dpyName, errnoStr); (*jniEnv)->CallStaticVoidMethod(jniEnv, X11UtilClazz, dumpStackID); + jniEnv = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); if (NULL != jniEnv) { + char threadName[80]; + (void) NativewindowCommon_GetStaticStringMethod(jniEnv, X11UtilClazz, getCurrentThreadNameID, threadName, sizeof(threadName), "n/a"); + NativewindowCommon_FatalError(jniEnv, "Nativewindow X11 IOError (Thread %s): Display %p (%s): %s", threadName, dpy, dpyName, errnoStr); if (shallBeDetached) { @@ -305,6 +309,7 @@ Java_jogamp_nativewindow_x11_X11Util_initialize0(JNIEnv *env, jclass clazz, jboo _initClazzAccess(env); x11IOErrorHandlerEnable(1, env); + NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 1, 0, 0 /* no dpy, no sync */); _initialized=1; if(JNI_TRUE == debug) { fprintf(stderr, "Info: NativeWindow native init passed\n"); @@ -315,6 +320,7 @@ Java_jogamp_nativewindow_x11_X11Util_initialize0(JNIEnv *env, jclass clazz, jboo JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Util_shutdown0(JNIEnv *env, jclass _unused) { + NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 0, 0, 0 /* no dpy, no sync */); x11IOErrorHandlerEnable(0, env); } @@ -347,7 +353,7 @@ Java_jogamp_nativewindow_x11_X11Lib_XGetVisualInfo1__JJLjava_nio_ByteBuffer_2Lja } NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) arg0, 1, 0, 0); _res = XGetVisualInfo((Display *) (intptr_t) arg0, (long) arg1, (XVisualInfo *) _ptr2, (int *) _ptr3); - NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) arg0, 0, 0, 0); + // NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) arg0, 0, 0, 0); count = _ptr3[0]; if (arg3 != NULL) { (*env)->ReleasePrimitiveArrayCritical(env, arg3, _ptr3, 0); @@ -382,7 +388,7 @@ Java_jogamp_nativewindow_x11_X11Lib_GetVisualIDFromWindow(JNIEnv *env, jclass _u } else { r = 0; } - NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); + // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); return r; } @@ -396,7 +402,7 @@ Java_jogamp_nativewindow_x11_X11Lib_DefaultVisualID(JNIEnv *env, jclass _unused, } NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) display, 1, 0, 0); r = (jint) XVisualIDFromVisual( DefaultVisual( (Display*) (intptr_t) display, screen ) ); - NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) display, 0, 0, 0); + // NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) display, 0, 0, 0); return r; } @@ -439,7 +445,7 @@ Java_jogamp_nativewindow_x11_X11Lib_XCloseDisplay__J(JNIEnv *env, jclass _unused } NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 1, 0, 0); _res = XCloseDisplay((Display *) (intptr_t) display); - NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 0, 0, 0); + // NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 0, 0, 0); return _res; } @@ -497,7 +503,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow if (visual==NULL) { - NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); + // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); NativewindowCommon_throwNewRuntimeException(env, "could not query Visual by given VisualID, bail out!"); return 0; } @@ -541,7 +547,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow XSelectInput(dpy, window, 0); // no events - NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); + // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); DBG_PRINT( "X11: [CreateWindow] created window %p on display %p\n", window, dpy); @@ -569,7 +575,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_DestroyDummyWindow XUnmapWindow(dpy, w); XSync(dpy, False); XDestroyWindow(dpy, w); - NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); + // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); } /* @@ -597,7 +603,7 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_x11_X11Lib_GetRelativeLocatio res = XTranslateCoordinates(dpy, src_win, dest_win, src_x, src_y, &dest_x, &dest_y, &child); - NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 0); + // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 0); DBG_PRINT( "X11: GetRelativeLocation0: %p %d/%d -> %p %d/%d - ok: %d\n", (void*)src_win, src_x, src_y, (void*)dest_win, dest_x, dest_y, (int)res); diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 1e9a0e9eb..391bccf3d 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -113,16 +113,22 @@ public abstract class Display { */ public abstract int removeReference(); + /** + * Return the {@link AbstractGraphicsDevice} used for depending resources lifecycle, + * i.e. {@link Screen} and {@link Window}, as well as the event dispatching (EDT). */ public abstract AbstractGraphicsDevice getGraphicsDevice(); /** - * @return the fully qualified Display name, - * which is a key of {@link #getType()} + {@link #getName()} + {@link #getId()} + * Return the handle of the {@link AbstractGraphicsDevice} as returned by {@link #getGraphicsDevice()}. */ - public abstract String getFQName(); - public abstract long getHandle(); + /** + * @return The fully qualified Display name, + * which is a key of {@link #getType()} + {@link #getName()} + {@link #getId()}. + */ + public abstract String getFQName(); + /** * @return this display internal serial id */ @@ -141,6 +147,9 @@ public abstract class Display { */ public abstract String getType(); + /** Return true if this instance is exclusive, i.e. will not be shared. */ + public abstract boolean isExclusive(); + /** * Sets a new {@link EDTUtil} and returns the previous one. *

@@ -183,11 +192,12 @@ public abstract class Display { * * @param type * @param name - * @param fromIndex start index, then increasing until found or end of list * + * @param fromIndex start index, then increasing until found or end of list + * @paran shared if true, only shared instances are found, otherwise also exclusive * @return */ - public static Display getFirstDisplayOf(String type, String name, int fromIndex) { - return getDisplayOfImpl(type, name, fromIndex, 1); + public static Display getFirstDisplayOf(String type, String name, int fromIndex, boolean shared) { + return getDisplayOfImpl(type, name, fromIndex, 1, shared); } /** @@ -195,19 +205,22 @@ public abstract class Display { * @param type * @param name * @param fromIndex start index, then decreasing until found or end of list. -1 is interpreted as size - 1. + * @paran shared if true, only shared instances are found, otherwise also exclusive * @return */ - public static Display getLastDisplayOf(String type, String name, int fromIndex) { - return getDisplayOfImpl(type, name, fromIndex, -1); + public static Display getLastDisplayOf(String type, String name, int fromIndex, boolean shared) { + return getDisplayOfImpl(type, name, fromIndex, -1, shared); } - private static Display getDisplayOfImpl(String type, String name, int fromIndex, int incr) { + private static Display getDisplayOfImpl(String type, String name, int fromIndex, int incr, boolean shared) { synchronized(displayList) { int i = fromIndex >= 0 ? fromIndex : displayList.size() - 1 ; while( ( incr > 0 ) ? i < displayList.size() : i >= 0 ) { Display display = (Display) displayList.get(i); if( display.getType().equals(type) && - display.getName().equals(name) ) { + display.getName().equals(name) && + ( !shared || shared && !display.isExclusive() ) + ) { return display; } i+=incr; diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index abae94ab6..1bf47f4aa 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -305,7 +305,7 @@ public class NewtFactory { * Instantiate a Display entity using the native handle. */ public static Display createDisplay(String type, long handle, boolean reuse) { - return DisplayImpl.create(type, null, handle, false); + return DisplayImpl.create(type, null, handle, reuse); } public static boolean isScreenCompatible(NativeWindow parent, Screen childScreen) { diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index 26f19ad6b..cfbcc988a 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -145,7 +145,7 @@ public abstract class Screen { public abstract Display getDisplay(); /** - * @return the screen fully qualified Screen name, + * @return The screen fully qualified Screen name, * which is a key of {@link com.jogamp.newt.Display#getFQName()} + {@link #getIndex()}. */ public abstract String getFQName(); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index bca7f6e5b..daeb3e886 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -42,6 +42,7 @@ import com.jogamp.newt.event.NEWTEventConsumer; import jogamp.newt.event.NEWTEventTask; import com.jogamp.newt.util.EDTUtil; import java.util.ArrayList; + import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; @@ -66,7 +67,7 @@ public abstract class DisplayImpl extends Display { name = display.validateDisplayName(name, handle); synchronized(displayList) { if(reuse) { - Display display0 = Display.getLastDisplayOf(type, name, -1); + Display display0 = Display.getLastDisplayOf(type, name, -1, true /* shared only */); if(null != display0) { if(DEBUG) { System.err.println("Display.create() REUSE: "+display0+" "+getThreadName()); @@ -74,9 +75,9 @@ public abstract class DisplayImpl extends Display { return display0; } } + display.exclusive = !reuse; display.name = name; display.type=type; - display.destroyWhenUnused=false; display.refCount=0; display.id = serialno++; display.fqname = getFQName(display.type, display.name, display.id); @@ -94,7 +95,7 @@ public abstract class DisplayImpl extends Display { throw new RuntimeException(e); } } - + @Override public boolean equals(Object obj) { if (obj == null) { @@ -116,10 +117,12 @@ public abstract class DisplayImpl extends Display { return true; } + @Override public int hashCode() { return hashCode; } + @Override public synchronized final void createNative() throws NativeWindowException { @@ -148,10 +151,6 @@ public abstract class DisplayImpl extends Display { } } - protected boolean shallRunOnEDT() { - return true; - } - protected EDTUtil createEDTUtil() { final EDTUtil def; if(NewtFactory.useEDT()) { @@ -179,12 +178,7 @@ public abstract class DisplayImpl extends Display { if(DEBUG) { System.err.println("Display.setEDTUtil: "+oldEDTUtil+" -> "+newEDTUtil); } - if(null != oldEDTUtil) { - stopEDT( new Runnable() { public void run() {} } ); - // ready for restart .. - oldEDTUtil.waitUntilStopped(); - oldEDTUtil.reset(); - } + removeEDT( new Runnable() { public void run() {} } ); edtUtil = newEDTUtil; return oldEDTUtil; } @@ -194,16 +188,19 @@ public abstract class DisplayImpl extends Display { return edtUtil; } - private void stopEDT(final Runnable task) { - if( shallRunOnEDT() && null!=edtUtil ) { + private void removeEDT(final Runnable task) { + if(null!=edtUtil) { edtUtil.invokeStop(task); + // ready for restart .. + edtUtil.waitUntilStopped(); + edtUtil.reset(); } else { task.run(); } } public void runOnEDTIfAvail(boolean wait, final Runnable task) { - if( shallRunOnEDT() && null!=edtUtil && !edtUtil.isCurrentThreadEDT()) { + if( null!=edtUtil && !edtUtil.isCurrentThreadEDT()) { edtUtil.invoke(wait, task); } else { task.run(); @@ -212,18 +209,17 @@ public abstract class DisplayImpl extends Display { public boolean validateEDT() { if(0==refCount && null==aDevice && null != edtUtil && edtUtil.isRunning()) { - stopEDT( new Runnable() { + removeEDT( new Runnable() { public void run() { // nop } } ); - edtUtil.waitUntilStopped(); - edtUtil.reset(); return true; } return false; } + @Override public synchronized final void destroy() { if(DEBUG) { dumpDisplayList("Display.destroy("+getFQName()+") BEGIN"); @@ -239,17 +235,13 @@ public abstract class DisplayImpl extends Display { } final AbstractGraphicsDevice f_aDevice = aDevice; final DisplayImpl f_dpy = this; - stopEDT( new Runnable() { + removeEDT( new Runnable() { public void run() { if ( null != f_aDevice ) { f_dpy.closeNativeImpl(); } } } ); - if(null!=edtUtil) { - edtUtil.waitUntilStopped(); - edtUtil.reset(); - } aDevice = null; refCount=0; if(DEBUG) { @@ -290,21 +282,30 @@ public abstract class DisplayImpl extends Display { protected abstract void createNativeImpl(); protected abstract void closeNativeImpl(); + @Override public final int getId() { return id; } + @Override public final String getType() { return type; } + @Override public final String getName() { return name; } + @Override public final String getFQName() { return fqname; } + + @Override + public final boolean isExclusive() { + return exclusive; + } public static final String nilString = "nil" ; @@ -324,9 +325,10 @@ public abstract class DisplayImpl extends Display { sb.append(name); sb.append("-"); sb.append(id); - return sb.toString().intern(); + return sb.toString(); } + @Override public final long getHandle() { if(null!=aDevice) { return aDevice.getHandle(); @@ -334,14 +336,17 @@ public abstract class DisplayImpl extends Display { return 0; } + @Override public final AbstractGraphicsDevice getGraphicsDevice() { return aDevice; } + @Override public synchronized final boolean isNativeValid() { return null != aDevice; } + @Override public boolean isEDTRunning() { if(null!=edtUtil) { return edtUtil.isRunning(); @@ -351,7 +356,7 @@ public abstract class DisplayImpl extends Display { @Override public String toString() { - return "NEWT-Display["+getFQName()+", refCount "+refCount+", hasEDT "+(null!=edtUtil)+", edtRunning "+isEDTRunning()+", "+aDevice+"]"; + return "NEWT-Display["+getFQName()+", excl "+exclusive+", refCount "+refCount+", hasEDT "+(null!=edtUtil)+", edtRunning "+isEDTRunning()+", "+aDevice+"]"; } protected abstract void dispatchMessagesNative(); @@ -403,6 +408,7 @@ public abstract class DisplayImpl extends Display { eventTask.notifyCaller(); } + @Override public void dispatchMessages() { // System.err.println("Display.dispatchMessages() 0 "+this+" "+getThreadName()); if(0==refCount || // no screens @@ -475,20 +481,23 @@ public abstract class DisplayImpl extends Display { public interface DisplayRunnable { T run(long dpy); } - public final T runWithLockedDisplayHandle(DisplayRunnable action) { - final AbstractGraphicsDevice aDevice = getGraphicsDevice(); - if(null == aDevice) { - throw new RuntimeException("null device - not initialized: "+this); - } + public static final T runWithLockedDevice(AbstractGraphicsDevice device, DisplayRunnable action) { T res; - aDevice.lock(); + device.lock(); try { - res = action.run(aDevice.getHandle()); + res = action.run(device.getHandle()); } finally { - aDevice.unlock(); + device.unlock(); } return res; } + public final T runWithLockedDisplayDevice(DisplayRunnable action) { + final AbstractGraphicsDevice device = getGraphicsDevice(); + if(null == device) { + throw new RuntimeException("null device - not initialized: "+this); + } + return runWithLockedDevice(device, action); + } protected EDTUtil edtUtil = null; protected int id; @@ -497,7 +506,7 @@ public abstract class DisplayImpl extends Display { protected String fqname; protected int hashCode; protected int refCount; // number of Display references by Screen - protected boolean destroyWhenUnused; + protected boolean exclusive; // do not share this display, uses NullLock! protected AbstractGraphicsDevice aDevice; } diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index e2c0f746f..1cc53e80e 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -42,7 +42,6 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.util.Dimension; import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.Point; @@ -130,7 +129,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { } } screen.screen_idx = idx; - screen.fqname = (display.getFQName()+idx).intern(); + screen.fqname = display.getFQName()+"-s"+idx; screen.hashCode = screen.fqname.hashCode(); screenList.add(screen); if(DEBUG) { diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index c1ac87d38..79770189b 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -85,7 +85,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private volatile long windowHandle = 0; // lifecycle critical private volatile boolean visible = false; // lifecycle critical private RecursiveLock windowLock = LockFactory.createRecursiveLock(); // Window instance wide lock - private RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); // Surface only lock + private int surfaceLockCount = 0; // surface lock recursion count private ScreenImpl screen; // never null after create - may change reference though (reparent) private boolean screenReferenceAdded = false; @@ -553,10 +553,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final int lockSurface() throws NativeWindowException, RuntimeException { final RecursiveLock _wlock = windowLock; - final RecursiveLock _slock = surfaceLock; _wlock.lock(); - _slock.lock(); - int res = _slock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? + surfaceLockCount++; + int res = ( 1 == surfaceLockCount ) ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? if ( LOCK_SURFACE_NOT_READY == res ) { try { @@ -573,7 +572,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } finally { if (LOCK_SURFACE_NOT_READY >= res) { - _slock.unlock(); _wlock.unlock(); } } @@ -583,12 +581,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final void unlockSurface() { - final RecursiveLock _slock = surfaceLock; final RecursiveLock _wlock = windowLock; - _slock.validateLocked(); _wlock.validateLocked(); - if (_slock.getHoldCount() == 1) { + if ( 1 == surfaceLockCount ) { final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); try { unlockSurfaceImpl(); @@ -596,42 +592,48 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer adevice.unlock(); } } - _slock.unlock(); + surfaceLockCount--; _wlock.unlock(); } @Override public final boolean isSurfaceLockedByOtherThread() { - return surfaceLock.isLockedByOtherThread(); + return windowLock.isLockedByOtherThread(); } @Override public final Thread getSurfaceLockOwner() { - return surfaceLock.getOwner(); + return windowLock.getOwner(); } public final RecursiveLock getLock() { return windowLock; } + @Override public long getSurfaceHandle() { return windowHandle; // default: return window handle } + @Override public boolean surfaceSwap() { return false; } + @Override public final AbstractGraphicsConfiguration getGraphicsConfiguration() { return config.getNativeGraphicsConfiguration(); } - public final long getDisplayHandle() { - return getScreen().getDisplay().getHandle(); + @Override + public long getDisplayHandle() { + // Actually: return getGraphicsConfiguration().getScreen().getDevice().getHandle(); + return screen.getDisplay().getHandle(); // shortcut } + @Override public final int getScreenIndex() { - return getScreen().getIndex(); + return screen.getIndex(); } //---------------------------------------------------------------------- @@ -1554,8 +1556,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer for (int i = 0; i < keyListeners.size(); i++ ) { sb.append(keyListeners.get(i)+", "); } - sb.append("], surfaceLock "+surfaceLock); - sb.append(", windowLock "+windowLock+"]"); + sb.append("], windowLock "+windowLock+"]"); return sb.toString(); } diff --git a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java index 70e9ba570..ead567d82 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java @@ -66,7 +66,9 @@ public class DisplayDriver extends DisplayImpl { return def; } - protected void closeNativeImpl() { } + protected void closeNativeImpl() { + aDevice.close(); + } protected void dispatchMessagesNative() { /* nop */ } } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java index 65ca63eec..cc55c336e 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java @@ -39,6 +39,7 @@ import javax.media.nativewindow.NativeWindowException; import jogamp.newt.NEWTJNILibLoader; import jogamp.opengl.egl.EGL; +import jogamp.opengl.egl.EGLDisplayUtil; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; @@ -72,6 +73,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { DestroyDisplay(aDevice.getHandle()); } + aDevice.close(); } protected void dispatchMessagesNative() { diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java index 97c384d33..e370038d9 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java @@ -84,6 +84,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { } } } + aDevice.close(); } protected void dispatchMessagesNative() { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index 1a3f14859..b49c6b6e0 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -72,7 +72,9 @@ public class DisplayDriver extends DisplayImpl { aDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl() { } + protected void closeNativeImpl() { + aDevice.close(); + } public static void runNSApplication() { runNSApplication0(); diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index 579ec5be8..615f9e63b 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -73,6 +73,7 @@ public class DisplayDriver extends DisplayImpl { protected void closeNativeImpl() { sharedClassFactory.releaseSharedClass(); + aDevice.close(); } protected void dispatchMessagesNative() { diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 714324d63..bff050030 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -36,7 +36,6 @@ package jogamp.newt.driver.x11; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; import com.jogamp.nativewindow.x11.X11GraphicsDevice; @@ -74,71 +73,48 @@ public class DisplayDriver extends DisplayImpl { * {@inheritDoc} * * We use a private non-shared X11 Display instance for EDT window operations and one for exposed animation, eg. OpenGL. - *

- * In case {@link X11Util#HAS_XLOCKDISPLAY_BUG} and {@link X11Util#XINITTHREADS_ALWAYS_ENABLED}, - * we use null locking. Even though this seems not to be rational, it gives most stable results on all platforms. - *

- *

- * Otherwise we use basic locking via the constructor {@link X11GraphicsDevice#X11GraphicsDevice(long, int, boolean)}, - * since it is possible to share this device via {@link com.jogamp.newt.NewtFactory#createDisplay(String, boolean)}. - *

*/ - @SuppressWarnings("unused") protected void createNativeImpl() { + X11Util.setX11ErrorHandler(true, DEBUG ? false : true); // make sure X11 error handler is set long handle = X11Util.openDisplay(name); if( 0 == handle ) { throw new RuntimeException("Error creating display(Win): "+name); } - if(USE_SEPARATE_DISPLAY_FOR_EDT) { - edtDisplayHandle = X11Util.openDisplay(name); - if( 0 == edtDisplayHandle ) { - X11Util.closeDisplay(handle); - throw new RuntimeException("Error creating display(EDT): "+name); - } - } else { - edtDisplayHandle = handle; - } + aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, true); try { - CompleteDisplay0(edtDisplayHandle); + CompleteDisplay0(aDevice.getHandle()); } catch(RuntimeException e) { closeNativeImpl(); throw e; - } - - // see API doc above! - if(X11Util.XINITTHREADS_ALWAYS_ENABLED && X11Util.HAS_XLOCKDISPLAY_BUG) { - aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock(), false); - } else { - aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, false); - } + } } protected void closeNativeImpl() { - DisplayRelease0(edtDisplayHandle, javaObjectAtom, windowDeleteAtom); + DisplayRelease0(aDevice.getHandle(), javaObjectAtom, windowDeleteAtom); javaObjectAtom = 0; windowDeleteAtom = 0; - // closing using ATI driver bug 'same order' - final long handle = getHandle(); - X11Util.closeDisplay(handle); - if(handle != edtDisplayHandle) { - X11Util.closeDisplay(edtDisplayHandle); - } - edtDisplayHandle = 0; + aDevice.close(); // closes X11 display } protected void dispatchMessagesNative() { - if(0 != edtDisplayHandle) { - DispatchMessages0(edtDisplayHandle, javaObjectAtom, windowDeleteAtom); + aDevice.lock(); + try { + final long handle = aDevice.getHandle(); + if(0 != handle) { + DispatchMessages0(handle, javaObjectAtom, windowDeleteAtom); + } + } finally { + aDevice.unlock(); } } - protected long getEDTHandle() { return edtDisplayHandle; } protected long getJavaObjectAtom() { return javaObjectAtom; } protected long getWindowDeleteAtom() { return windowDeleteAtom; } //---------------------------------------------------------------------- // Internals only // + private static native boolean initIDs0(boolean debug); private native void CompleteDisplay0(long handle); @@ -151,17 +127,6 @@ public class DisplayDriver extends DisplayImpl { private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom); - /** - * 2011/06/14 libX11 1.4.2 and libxcb 1.7 bug 20708 - Multithreading Issues w/ OpenGL, .. - * https://bugs.freedesktop.org/show_bug.cgi?id=20708 - * https://jogamp.org/bugzilla/show_bug.cgi?id=502 - * Affects: Ubuntu 11.04, OpenSuSE 11, .. - * Workaround: Using a separate X11 Display connection for event dispatching (EDT) - */ - private final boolean USE_SEPARATE_DISPLAY_FOR_EDT = true; - - private long edtDisplayHandle; - /** X11 Window delete atom marker used on EDT */ private long windowDeleteAtom; diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index 10f6b84da..b09d98e06 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -59,7 +59,7 @@ public class ScreenDriver extends ScreenImpl { protected void createNativeImpl() { // validate screen index - Long handle = display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + Long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Long run(long dpy) { return new Long(GetScreen0(dpy, screen_idx)); } } ); @@ -81,7 +81,7 @@ public class ScreenDriver extends ScreenImpl { private int nmode_number; protected int[] getScreenModeFirstImpl() { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public int[] run(long dpy) { // initialize iterators and static data nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); @@ -110,7 +110,7 @@ public class ScreenDriver extends ScreenImpl { protected int[] getScreenModeNextImpl() { // assemble: w x h x bpp x f x r - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public int[] run(long dpy) { /** System.err.println("******** mode: "+nmode_number); @@ -176,7 +176,7 @@ public class ScreenDriver extends ScreenImpl { } protected ScreenMode getCurrentScreenModeImpl() { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public ScreenMode run(long dpy) { long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); if(0 == screenConfigHandle) { @@ -237,7 +237,7 @@ public class ScreenDriver extends ScreenImpl { throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); } final long t0 = System.currentTimeMillis(); - boolean done = runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + boolean done = runWithTempDisplayHandle( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { boolean done = false; long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); @@ -276,23 +276,21 @@ public class ScreenDriver extends ScreenImpl { return done; } - private class XineramaEnabledQuery implements DisplayImpl.DisplayRunnable { + private DisplayImpl.DisplayRunnable xineramaEnabledQueryWithTemp = new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { return new Boolean(X11Util.XineramaIsEnabled(dpy)); - } - } - private XineramaEnabledQuery xineramaEnabledQuery = new XineramaEnabledQuery(); + } }; protected int validateScreenIndex(final int idx) { if(getDisplay().isNativeValid()) { - return runWithLockedDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx; + return X11Util.XineramaIsEnabled((X11GraphicsDevice)getDisplay().getGraphicsDevice()) ? 0 : idx; } else { - return runWithTempDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx; + return runWithTempDisplayHandle( xineramaEnabledQueryWithTemp ).booleanValue() ? 0 : idx; } } protected void getVirtualScreenOriginAndSize(final Point virtualOrigin, final Dimension virtualSize) { - display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { virtualOrigin.setX(0); virtualOrigin.setY(0); @@ -305,10 +303,8 @@ public class ScreenDriver extends ScreenImpl { //---------------------------------------------------------------------- // Internals only // - private final T runWithLockedDisplayHandle(DisplayRunnable action) { - return display.runWithLockedDisplayHandle(action); - // return runWithTempDisplayHandle(action); - // return runWithoutLock(action); + private final T runWithLockedDisplayDevice(DisplayRunnable action) { + return display.runWithLockedDisplayDevice(action); } private final T runWithTempDisplayHandle(DisplayRunnable action) { @@ -324,9 +320,6 @@ public class ScreenDriver extends ScreenImpl { } return res; } - private final T runWithoutLock(DisplayRunnable action) { - return action.run(display.getHandle()); - } private static native long GetScreen0(long dpy, int scrn_idx); diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 97d1ae3db..aea86a420 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -35,6 +35,7 @@ package jogamp.newt.driver.x11; import jogamp.nativewindow.x11.X11Lib; +import jogamp.nativewindow.x11.X11Util; import jogamp.newt.DisplayImpl; import jogamp.newt.DisplayImpl.DisplayRunnable; import jogamp.newt.WindowImpl; @@ -44,6 +45,8 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; import com.jogamp.newt.event.MouseEvent; public class WindowDriver extends WindowImpl { @@ -63,9 +66,19 @@ public class WindowDriver extends WindowImpl { protected void createNativeImpl() { final ScreenDriver screen = (ScreenDriver) getScreen(); final DisplayDriver display = (DisplayDriver) screen.getDisplay(); + final AbstractGraphicsDevice edtDevice = display.getGraphicsDevice(); + + // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering + final long renderDeviceHandle = X11Util.openDisplay(edtDevice.getConnection()); + if( 0 == renderDeviceHandle ) { + throw new RuntimeException("Error creating display(EDT): "+edtDevice.getConnection()); + } + renderDevice = new X11GraphicsDevice(renderDeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true); + AbstractGraphicsScreen renderScreen = new X11GraphicsScreen((X11GraphicsDevice) renderDevice, screen.getIndex()); + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested); final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + capsRequested, capsRequested, capabilitiesChooser, renderScreen, VisualIDHolder.VID_UNDEFINED); if(DEBUG_IMPLEMENTATION) { System.err.println("X11Window.createNativeImpl() factory: "+factory+", chosen config: "+cfg); } @@ -78,11 +91,16 @@ public class WindowDriver extends WindowImpl { } setGraphicsConfiguration(cfg); final int flags = getReconfigureFlags(0, true) & - ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; - setWindowHandle(CreateWindow0(getParentWindowHandle(), - display.getEDTHandle(), screen.getIndex(), visualID, - display.getJavaObjectAtom(), display.getWindowDeleteAtom(), - getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); + ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; + edtDevice.lock(); + try { + setWindowHandle(CreateWindow0(getParentWindowHandle(), + edtDevice.getHandle(), screen.getIndex(), visualID, + display.getJavaObjectAtom(), display.getWindowDeleteAtom(), + getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); + } finally { + edtDevice.unlock(); + } windowHandleClose = getWindowHandle(); if (0 == windowHandleClose) { throw new NativeWindowException("Error creating window"); @@ -92,8 +110,10 @@ public class WindowDriver extends WindowImpl { protected void closeNativeImpl() { if(0!=windowHandleClose && null!=getScreen() ) { DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + final AbstractGraphicsDevice edtDevice = display.getGraphicsDevice(); + edtDevice.lock(); try { - CloseWindow0(display.getEDTHandle(), windowHandleClose, + CloseWindow0(edtDevice.getHandle(), windowHandleClose, display.getJavaObjectAtom(), display.getWindowDeleteAtom()); } catch (Throwable t) { if(DEBUG_IMPLEMENTATION) { @@ -101,28 +121,47 @@ public class WindowDriver extends WindowImpl { e.printStackTrace(); } } finally { + edtDevice.unlock(); windowHandleClose = 0; } } + if(null != renderDevice) { + renderDevice.close(); // closes X11 display + renderDevice = null; + } } - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + @Override + public long getDisplayHandle() { + // Actually: return getGraphicsConfiguration().getScreen().getDevice().getHandle(); + return renderDevice.getHandle(); // shortcut + } + + protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { if(DEBUG_IMPLEMENTATION) { System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); } + final int _x, _y; if(0 == ( FLAG_IS_UNDECORATED & flags)) { final InsetsImmutable i = getInsets(); // client position -> top-level window position - x -= i.getLeftWidth() ; - y -= i.getTopHeight() ; + _x = x - i.getLeftWidth() ; + _y = y - i.getTopHeight() ; + } else { + _x = x; + _y = y; } final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); - reconfigureWindow0( getDisplayEDTHandle(), getScreenIndex(), - getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), - x, y, width, height, flags); - + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + reconfigureWindow0( dpy, getScreenIndex(), + getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), + _x, _y, width, height, flags); + return null; + } + }); return true; } @@ -133,13 +172,18 @@ public class WindowDriver extends WindowImpl { } } - protected void requestFocusImpl(boolean force) { - requestFocus0(getDisplayEDTHandle(), getWindowHandle(), force); + protected void requestFocusImpl(final boolean force) { + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + requestFocus0(dpy, getWindowHandle(), force); + return null; + } + }); } @Override protected void setTitleImpl(final String title) { - runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { setTitle0(dpy, getWindowHandle(), title); return null; @@ -149,35 +193,38 @@ public class WindowDriver extends WindowImpl { @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { - return Boolean.valueOf(setPointerVisible0(getDisplayEDTHandle(), getWindowHandle(), pointerVisible)); + return Boolean.valueOf(setPointerVisible0(dpy, getWindowHandle(), pointerVisible)); } }).booleanValue(); } @Override protected boolean confinePointerImpl(final boolean confine) { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { - return Boolean.valueOf(confinePointer0(getDisplayEDTHandle(), getWindowHandle(), confine)); + return Boolean.valueOf(confinePointer0(dpy, getWindowHandle(), confine)); } }).booleanValue(); } @Override protected void warpPointerImpl(final int x, final int y) { - runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { - warpPointer0(getDisplayEDTHandle(), getWindowHandle(), x, y); + warpPointer0(dpy, getWindowHandle(), x, y); return null; } }); } protected Point getLocationOnScreenImpl(final int x, final int y) { - // X11Util.GetRelativeLocation: locks display already ! - return X11Lib.GetRelativeLocation( getScreen().getDisplay().getHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public Point run(long dpy) { + return X11Lib.GetRelativeLocation(dpy, getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); + } + } ); } protected void updateInsetsImpl(Insets insets) { @@ -229,16 +276,11 @@ public class WindowDriver extends WindowImpl { //---------------------------------------------------------------------- // Internals only // - private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI - private final long getDisplayEDTHandle() { - return ((DisplayDriver) getScreen().getDisplay()).getEDTHandle(); - } - private final T runWithLockedDisplayHandle(DisplayRunnable action) { - return ((DisplayImpl) getScreen().getDisplay()).runWithLockedDisplayHandle(action); - // return runWithTempDisplayHandle(action); + private final T runWithLockedDisplayDevice(DisplayRunnable action) { + return ((DisplayDriver) getScreen().getDisplay()).runWithLockedDisplayDevice(action); } protected static native boolean initIDs0(); @@ -258,4 +300,5 @@ public class WindowDriver extends WindowImpl { private static native void warpPointer0(long display, long windowHandle, int x, int y); private long windowHandleClose; + private AbstractGraphicsDevice renderDevice; } diff --git a/src/newt/native/X11Common.h b/src/newt/native/X11Common.h index 128b6b6f1..4d1a7b59e 100644 --- a/src/newt/native/X11Common.h +++ b/src/newt/native/X11Common.h @@ -70,7 +70,6 @@ extern jclass X11NewtWindowClazz; extern jmethodID insetsChangedID; extern jmethodID visibleChangedID; -void NewtDisplay_x11ErrorHandlerEnable(JNIEnv * env, Display *dpy, int onoff, int quiet, int sync); jobject getJavaWindowProperty(JNIEnv *env, Display *dpy, Window window, jlong javaObjectAtom, Bool showWarning); Status NewtWindows_getRootAndParent (Display *dpy, Window w, Window * root_return, Window * parent_return); diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 84b3a7630..56c11fab4 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -52,90 +52,6 @@ static jmethodID enqueueKeyEventID = NULL; static jmethodID sendKeyEventID = NULL; static jmethodID requestFocusID = NULL; -static JavaVM *jvmHandle = NULL; -static int jvmVersion = 0; - -static void setupJVMVars(JNIEnv * env) { - if(0 != (*env)->GetJavaVM(env, &jvmHandle)) { - jvmHandle = NULL; - } - jvmVersion = (*env)->GetVersion(env); -} - -static XErrorHandler origErrorHandler = NULL ; -static int errorHandlerQuiet = 0 ; -static int errorHandlerDebug = 0 ; -static int errorHandlerThrowException = 0; - -static int x11ErrorHandler(Display *dpy, XErrorEvent *e) -{ - if(!errorHandlerQuiet) { - const char * errnoStr = strerror(errno); - char threadName[80]; - char errCodeStr[80]; - char reqCodeStr[80]; - - int shallBeDetached = 0; - JNIEnv *jniEnv = NewtCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); - - (void) NewtCommon_GetStaticStringMethod(jniEnv, X11NewtWindowClazz, getCurrentThreadNameID, threadName, sizeof(threadName), "n/a"); - snprintf(errCodeStr, sizeof(errCodeStr), "%d", e->request_code); - XGetErrorDatabaseText(dpy, "XRequest", errCodeStr, "Unknown", reqCodeStr, sizeof(reqCodeStr)); - XGetErrorText(dpy, e->error_code, errCodeStr, sizeof(errCodeStr)); - - fprintf(stderr, "Info: Newt X11 Error (Thread: %s): %d - %s, dpy %p, id %x, # %d: %d:%d %s\n", - threadName, e->error_code, errCodeStr, e->display, (int)e->resourceid, (int)e->serial, - (int)e->request_code, (int)e->minor_code, reqCodeStr); - - if( errorHandlerDebug ) { - (*jniEnv)->CallStaticVoidMethod(jniEnv, X11NewtWindowClazz, dumpStackID); - } - - if(errorHandlerThrowException) { - if(NULL != jniEnv) { - NewtCommon_throwNewRuntimeException(jniEnv, "Newt X11 Error (Thread: %s): %d - %s, dpy %p, id %x, # %d: %d:%d %s\n", - threadName, e->error_code, errCodeStr, e->display, (int)e->resourceid, (int)e->serial, - (int)e->request_code, (int)e->minor_code, reqCodeStr); - } else { - fprintf(stderr, "Nativewindow X11 Error: null JNIEnv"); - #if 0 - if(NULL!=origErrorHandler) { - origErrorHandler(dpy, e); - } - #endif - } - } - fflush(stderr); - - if (NULL != jniEnv && shallBeDetached) { - (*jvmHandle)->DetachCurrentThread(jvmHandle); - } - } - - return 0; -} - -void NewtDisplay_x11ErrorHandlerEnable(JNIEnv * env, Display *dpy, int onoff, int quiet, int sync) { - errorHandlerQuiet = quiet; - if(onoff) { - if(NULL==origErrorHandler) { - setupJVMVars(env); - origErrorHandler = XSetErrorHandler(x11ErrorHandler); - if(sync && NULL!=dpy) { - XSync(dpy, False); - } - } - } else { - if(NULL!=origErrorHandler) { - if(sync && NULL!=dpy) { - XSync(dpy, False); - } - XSetErrorHandler(origErrorHandler); - origErrorHandler = NULL; - } - } -} - /** * Keycode */ @@ -273,9 +189,6 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 { jclass c; - if(debug) { - errorHandlerDebug = 1 ; - } NewtCommon_init(env); if(NULL==X11NewtWindowClazz) { @@ -439,8 +352,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage // DBG_PRINT( "X11: DispatchMessages dpy %p, win %p, Event %d\n", (void*)dpy, (void*)evt.xany.window, (int)evt.type); - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 1, 0, 0); - jwindow = getJavaWindowProperty(env, dpy, evt.xany.window, javaObjectAtom, #ifdef VERBOSE_ON True @@ -449,8 +360,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage #endif ); - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); - if(NULL==jwindow) { fprintf(stderr, "Warning: NEWT X11 DisplayDispatch %p, Couldn't handle event %d for X11 window %p\n", (void*)dpy, evt.type, (void*)evt.xany.window); diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 59862f463..2e16e7cae 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -683,16 +683,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0 DBG_PRINT( "X11: CloseWindow START dpy %p, win %p\n", (void*)dpy, (void*)w); - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 1, 0, 0); - jwindow = getJavaWindowProperty(env, dpy, w, javaObjectAtom, True); if(NULL==jwindow) { - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); NewtCommon_throwNewRuntimeException(env, "could not fetch Java Window object, bail out!"); return; } if ( JNI_FALSE == (*env)->IsSameObject(env, jwindow, obj) ) { - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); NewtCommon_throwNewRuntimeException(env, "Internal Error .. Window global ref not the same!"); return; } @@ -700,7 +696,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0 XSync(dpy, False); XSelectInput(dpy, w, 0); XUnmapWindow(dpy, w); - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); // Drain all events related to this window .. Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom); @@ -761,8 +756,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo fsEWMHFlags |= _NET_WM_ABOVE; // toggle above } - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 1, 0, 0); - DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d, parent %p/%p, win %p, %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d, alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d, tempInvisible %d, fsEWMHFlags %d\n", (void*)dpy, screen_index, (void*) jparent, (void*)parent, (void*)w, x, y, width, height, @@ -779,7 +772,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo ( TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_ALWAYSONTOP(flags) ) ) { Bool enable = TST_FLAG_CHANGE_FULLSCREEN(flags) ? TST_FLAG_IS_FULLSCREEN(flags) : TST_FLAG_IS_ALWAYSONTOP(flags) ; if( NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, enable) ) { - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); #ifdef FS_GRAB_KEYBOARD if(TST_FLAG_CHANGE_FULLSCREEN(flags)) { if(TST_FLAG_IS_FULLSCREEN(flags)) { @@ -863,8 +855,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo #endif } - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); - DBG_PRINT( "X11: reconfigureWindow0 X\n"); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java new file mode 100644 index 000000000..11d1331ed --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java @@ -0,0 +1,219 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; + +import com.jogamp.newt.Display; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +/** + * Concurrent and lock-free initialization and rendering using exclusive NEWT Display EDT instances, or + * concurrent locked initialization and lock-free rendering using a shared NEWT Display EDT instances. + *

+ * Rendering is always lock-free and independent of the EDT. + *

+ */ +public class InitConcurrentBaseNEWT extends UITestCase { + + static final int demoSize = 128; + + static long duration = 300; // ms + + static InsetsImmutable insets = null; + static int scrnHeight, scrnWidth; + static int num_x, num_y; + + @BeforeClass + public static void initClass() { + Window dummyWindow = NewtFactory.createWindow(new Capabilities()); + dummyWindow.setSize(demoSize, demoSize); + dummyWindow.setVisible(true); + Assert.assertEquals(true, dummyWindow.isVisible()); + Assert.assertEquals(true, dummyWindow.isNativeValid()); + insets = dummyWindow.getInsets(); + scrnHeight = dummyWindow.getScreen().getHeight(); + scrnWidth = dummyWindow.getScreen().getWidth(); + num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2; + num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2; + dummyWindow.destroy(); + } + + public class JOGLTask implements Runnable { + private final int id; + private final Object postSync; + private final boolean reuse; + private boolean done = false; + + public JOGLTask(Object postSync, int id, boolean reuse) { + this.postSync = postSync; + this.id = id; + this.reuse = reuse; + } + public void run() { + int x = ( id % num_x ) * ( demoSize + insets.getTotalHeight() ); + int y = ( (id / num_x) % num_y ) * ( demoSize + insets.getTotalHeight() ); + + System.err.println("JOGLTask "+id+": START: "+x+"/"+y+", reuse "+reuse+" - "+Thread.currentThread().getName()); + final Display display = NewtFactory.createDisplay(null, reuse); + final Screen screen = NewtFactory.createScreen(display, 0); + final GLWindow glWindow = GLWindow.create(screen, new GLCapabilities(GLProfile.getDefault())); + Assert.assertNotNull(glWindow); + glWindow.setTitle("Task "+id); + glWindow.setPosition(x + insets.getLeftWidth(), y + insets.getTopHeight() ); + + glWindow.addGLEventListener(new GearsES2(0)); + + Animator animator = new Animator(glWindow); + + glWindow.setSize(demoSize, demoSize); + glWindow.setVisible(true); + animator.setUpdateFPSFrames(60, null); + + System.err.println("JOGLTask "+id+": INITIALIZED: "+", "+display+" - "+Thread.currentThread().getName()); + + animator.start(); + Assert.assertEquals(true, animator.isAnimating()); + Assert.assertEquals(true, glWindow.isVisible()); + Assert.assertEquals(true, glWindow.isNativeValid()); + Assert.assertEquals(true, glWindow.isRealized()); + System.err.println("JOGLTask "+id+": RUNNING: "+Thread.currentThread().getName()); + + while(animator.isAnimating() && animator.getTotalFPSDuration()=0; i--) { + if(!tasks[i].done()) { + return false; + } + } + return true; + } + protected static String doneDump(JOGLTask[] tasks) { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for(int i=0; i0) { + sb.append(", "); + } + sb.append(i).append(": ").append(tasks[i].done()); + } + sb.append("]"); + return sb.toString(); + } + + protected static boolean isDead(Thread[] threads) { + for(int i=threads.length-1; i>=0; i--) { + if(threads[i].isAlive()) { + return false; + } + } + return true; + } + protected static String isAliveDump(Thread[] threads) { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for(int i=0; i0) { + sb.append(", "); + } + sb.append(i).append(": ").append(threads[i].isAlive()); + } + sb.append("]"); + return sb.toString(); + } + + protected void runJOGLTasks(int num, boolean reuse) throws InterruptedException { + final String currentThreadName = Thread.currentThread().getName(); + final Object syncDone = new Object(); + final JOGLTask[] tasks = new JOGLTask[num]; + final Thread[] threads = new Thread[num]; + int i; + for(i=0; i + * Rendering is always lock-free and independent of the EDT, however shared NEWT Display instances + * perform lifecycle actions (window creation etc) with locking. + *

+ */ +public class TestInitConcurrent01NEWT extends InitConcurrentBaseNEWT { + + @Test + public void test02TwoThreads() throws InterruptedException { + runJOGLTasks(2, true); + } + + @Test + public void test02FourThreads() throws InterruptedException { + runJOGLTasks(4, true); + } + + @Test + public void test16SixteenThreads() throws InterruptedException { + if( Platform.getCPUFamily() != Platform.CPUFamily.ARM ) { + runJOGLTasks(16, true); + } else { + runJOGLTasks( 8, true); + } + } + + public static void main(String args[]) throws IOException { + for(int i=0; i + * Rendering is always lock-free and independent of the EDT, however exclusive NEWT Display instances + * perform lifecycle actions (window creation etc) w/o locking. + *

+ */ +public class TestInitConcurrent02NEWT extends InitConcurrentBaseNEWT { + + @Test + public void test02TwoThreads() throws InterruptedException { + runJOGLTasks(2, false); + } + + @Test + public void test02FourThreads() throws InterruptedException { + runJOGLTasks(4, false); + } + + @Test + public void test16SixteenThreads() throws InterruptedException { + if( Platform.getCPUFamily() != Platform.CPUFamily.ARM ) { + runJOGLTasks(16, false); + } else { + runJOGLTasks( 8, false); + } + } + + public static void main(String args[]) throws IOException { + for(int i=0; i=0; i--) { - if(!tasks[i].done()) { - return false; - } - } - return true; - } - protected static String doneDump(JOGLTask[] tasks) { - StringBuilder sb = new StringBuilder(); - sb.append("["); - for(int i=0; i0) { - sb.append(", "); - } - sb.append(i).append(": ").append(tasks[i].done()); - } - sb.append("]"); - return sb.toString(); - } - - protected static boolean isDead(Thread[] threads) { - for(int i=threads.length-1; i>=0; i--) { - if(threads[i].isAlive()) { - return false; - } - } - return true; - } - protected static String isAliveDump(Thread[] threads) { - StringBuilder sb = new StringBuilder(); - sb.append("["); - for(int i=0; i0) { - sb.append(", "); - } - sb.append(i).append(": ").append(threads[i].isAlive()); - } - sb.append("]"); - return sb.toString(); - } - - protected void runJOGLTasks(int num) throws InterruptedException { - final String currentThreadName = Thread.currentThread().getName(); - final Object sync = new Object(); - final JOGLTask[] tasks = new JOGLTask[num]; - final Thread[] threads = new Thread[num]; - int i; - for(i=0; i Date: Fri, 28 Sep 2012 18:52:31 +0200 Subject: NativeWindow/X11 + NEWT/X11: Cache 'isXineramaEnabled()' to reduce X11 server roundtrips. --- .../classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java | 9 +++++++++ .../classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java | 10 +--------- src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java | 9 ++++++--- src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java | 6 ++++-- src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java | 4 ++-- 5 files changed, 22 insertions(+), 16 deletions(-) (limited to 'src/newt/classes') diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index 2e4099c1b..142bb99e3 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.ToolkitLock; public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneable { final boolean handleOwner; + final boolean isXineramaEnabled; /** Constructs a new X11GraphicsDevice corresponding to the given connection and default * {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#getDefaultToolkitLock(String)}.
@@ -56,6 +57,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl public X11GraphicsDevice(String connection, int unitID) { super(NativeWindowFactory.TYPE_X11, connection, unitID); handleOwner = false; + isXineramaEnabled = false; } /** Constructs a new X11GraphicsDevice corresponding to the given native display handle and default @@ -69,6 +71,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl throw new NativeWindowException("null display"); } handleOwner = owner; + isXineramaEnabled = X11Util.XineramaIsEnabled(this); } /** @@ -82,7 +85,9 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl throw new NativeWindowException("null display"); } handleOwner = owner; + isXineramaEnabled = X11Util.XineramaIsEnabled(this); } + private static int getDefaultScreenImpl(long dpy) { return X11Lib.DefaultScreen(dpy); @@ -114,6 +119,10 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl return X11Lib.DefaultVisualID(display, getDefaultScreenImpl(display)); } + public final boolean isXineramaEnabled() { + return isXineramaEnabled; + } + @Override public Object clone() { return super.clone(); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java index 7ab5bd6aa..fa57124fb 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java @@ -48,7 +48,7 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl /** Constructs a new X11GraphicsScreen corresponding to the given native screen index. */ public X11GraphicsScreen(X11GraphicsDevice device, int screen) { - super(device, fetchScreen(device, screen)); + super(device, device.isXineramaEnabled() ? 0 : screen); } public static AbstractGraphicsScreen createScreenDevice(long display, int screenIdx, boolean owner) { @@ -61,14 +61,6 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl return X11Lib.DefaultVisualID(getDevice().getHandle(), getIndex()); } - private static int fetchScreen(X11GraphicsDevice device, int screen) { - // It still could be an AWT hold handle .. - if(X11Util.XineramaIsEnabled(device)) { - screen = 0; // Xinerama -> 1 screen - } - return screen; - } - public Object clone() { return super.clone(); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index bff050030..6e80e966a 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -85,8 +85,8 @@ public class DisplayDriver extends DisplayImpl { CompleteDisplay0(aDevice.getHandle()); } catch(RuntimeException e) { closeNativeImpl(); - throw e; - } + throw e; + } } protected void closeNativeImpl() { @@ -111,6 +111,9 @@ public class DisplayDriver extends DisplayImpl { protected long getJavaObjectAtom() { return javaObjectAtom; } protected long getWindowDeleteAtom() { return windowDeleteAtom; } + /** Returns null if !{@link #isNativeValid()}, otherwise the Boolean value of {@link X11GraphicsDevice#isXineramaEnabled()}. */ + protected Boolean isXineramaEnabled() { return isNativeValid() ? Boolean.valueOf(((X11GraphicsDevice)aDevice).isXineramaEnabled()) : null; } + //---------------------------------------------------------------------- // Internals only // @@ -131,6 +134,6 @@ public class DisplayDriver extends DisplayImpl { private long windowDeleteAtom; /** X11 Window java object property used on EDT */ - private long javaObjectAtom; + private long javaObjectAtom; } diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index b09d98e06..7a3c718c0 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -282,8 +282,10 @@ public class ScreenDriver extends ScreenImpl { } }; protected int validateScreenIndex(final int idx) { - if(getDisplay().isNativeValid()) { - return X11Util.XineramaIsEnabled((X11GraphicsDevice)getDisplay().getGraphicsDevice()) ? 0 : idx; + final DisplayDriver x11Display = (DisplayDriver) getDisplay(); + final Boolean r = x11Display.isXineramaEnabled(); + if( null != r ) { + return r.booleanValue() ? 0 : idx; } else { return runWithTempDisplayHandle( xineramaEnabledQueryWithTemp ).booleanValue() ? 0 : idx; } diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index aea86a420..bde723634 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -74,7 +74,7 @@ public class WindowDriver extends WindowImpl { throw new RuntimeException("Error creating display(EDT): "+edtDevice.getConnection()); } renderDevice = new X11GraphicsDevice(renderDeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true); - AbstractGraphicsScreen renderScreen = new X11GraphicsScreen((X11GraphicsDevice) renderDevice, screen.getIndex()); + final AbstractGraphicsScreen renderScreen = new X11GraphicsScreen(renderDevice, screen.getIndex()); final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested); final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( @@ -300,5 +300,5 @@ public class WindowDriver extends WindowImpl { private static native void warpPointer0(long display, long windowHandle, int x, int y); private long windowHandleClose; - private AbstractGraphicsDevice renderDevice; + private X11GraphicsDevice renderDevice; } -- cgit v1.2.3 From 7c333e3e2574879465719ed968112b27255368d4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 2 Oct 2012 07:28:00 +0200 Subject: Relax Bug 613 workaround of commit 92398025abdabb2fdef0d78edd41e730991a6f94 Utilizing a GlobalToolkitLock in general to lock the display connection results in deadlock situations where locked surfaces signal other [offscreen] surfaces to render. We have to see whether we find a better solution, for now sporadic XCB assertion still happen. But it is preferrable to point to the root cause, then to jumping through hoops to complicate locking or even to deadlock. Locking: - X11GLXGraphicsConfigurationFactory add missing device locking in: - getAvailableCapabilities - chooseGraphicsConfigurationStatic - Newt/X11Window: Discard display events after window close. Relax ATI XCB/threading bug workaround: - ToolkitProperties: requiresGlobalToolkitLock() -> hasThreadingIssues() - NativeWindowFactory: Don't use GlobalToolkitLock in case of 'threadingIssues' the impact is too severe (see above) - NativeWindowFactory: Add getGlobalToolkitLockIfRequired(): To be used for small code blocks. If having 'threadingIssues' a GlobalToolkitLock is returned, otherwise NullToolkitLock. - X11GLXContext: [create/destroy]ContextARBImpl: Use 'NativeWindowFactory.getGlobalToolkitLockIfRequired()' for extra locking Misc Cleanup: - *DrawableFactory createMutableSurface: Also create new device if type is not suitable - *DrawableFactory createDummySurfaceImpl: Pass chosenCaps and use it (preserves orig. requested user caps) --- .../jogamp/opengl/GLDrawableFactoryImpl.java | 9 ++--- .../jogamp/opengl/egl/EGLDrawableFactory.java | 8 ++--- .../macosx/cgl/MacOSXCGLDrawableFactory.java | 9 ++--- .../windows/wgl/WindowsWGLDrawableFactory.java | 13 +++---- .../jogamp/opengl/x11/glx/X11GLXContext.java | 24 +++++++++---- .../opengl/x11/glx/X11GLXDrawableFactory.java | 22 ++++++------ .../glx/X11GLXGraphicsConfigurationFactory.java | 41 ++++++++++++++-------- .../com/jogamp/nativewindow/swt/SWTAccessor.java | 2 +- .../media/nativewindow/NativeWindowFactory.java | 40 ++++++++------------- .../jogamp/nativewindow/GlobalToolkitLock.java | 13 ++++--- .../nativewindow/NativeWindowFactoryImpl.java | 5 --- .../jogamp/nativewindow/ToolkitProperties.java | 8 ++--- .../classes/jogamp/nativewindow/jawt/JAWTUtil.java | 3 -- .../jogamp/nativewindow/macosx/OSXUtil.java | 2 +- .../jogamp/nativewindow/windows/GDIUtil.java | 2 +- .../classes/jogamp/nativewindow/x11/X11Util.java | 10 +++--- .../jogamp/newt/driver/x11/DisplayDriver.java | 2 +- .../jogamp/newt/driver/x11/WindowDriver.java | 2 +- src/newt/native/X11Display.c | 4 +-- src/newt/native/X11Window.c | 2 +- 20 files changed, 113 insertions(+), 108 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index bd2db1b81..0ea565b89 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -188,7 +188,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } if( chosenCaps.isFBO() && isFBOAvailable ) { // need to hook-up a native dummy surface since source may not have - final ProxySurface dummySurface = createDummySurfaceImpl(adevice, true, chosenCaps, null, 64, 64); + final ProxySurface dummySurface = createDummySurfaceImpl(adevice, false, chosenCaps, (GLCapabilitiesImmutable)config.getRequestedCapabilities(), null, 64, 64); dummySurface.setUpstreamSurfaceHook(new DelegatedUpstreamSurfaceHookWithSurfaceSize(dummySurface.getUpstreamSurfaceHook(), target)); result = createFBODrawableImpl(dummySurface, chosenCaps, 0); } else { @@ -299,7 +299,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if( capsChosen.isFBO() ) { device.lock(); try { - final ProxySurface dummySurface = createDummySurfaceImpl(device, true, capsRequested, null, width, height); + final ProxySurface dummySurface = createDummySurfaceImpl(device, true, capsChosen, capsRequested, null, width, height); final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); return new GLFBODrawableImpl.ResizeableImpl(this, dummyDrawable, dummySurface, capsChosen, 0); } finally { @@ -370,7 +370,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } device.lock(); try { - return createDummySurfaceImpl(device, true, requestedCaps, chooser, width, height); + return createDummySurfaceImpl(device, true, requestedCaps, requestedCaps, chooser, width, height); } finally { device.unlock(); } @@ -386,6 +386,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @param device a valid platform dependent target device. * @param createNewDevice if true a new device instance is created using device details, * otherwise device instance is used as-is. + * @param chosenCaps * @param requestedCaps * @param chooser the custom chooser, may be null for default * @param width the initial width as returned by {@link NativeSurface#getWidth()}, not the actual dummy surface width. @@ -395,7 +396,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @return the created {@link ProxySurface} instance w/o defined surface handle but platform specific {@link UpstreamSurfaceHook}. */ public abstract ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, - GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height); + GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height); //--------------------------------------------------------------------------- // diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index a907c4aff..da3907193 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -367,7 +367,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if( hasPBuffer[0] ) { // 2nd case create defaultDevice shared resource using pbuffer surface - surface = createDummySurfaceImpl(eglDevice, false, reqCapsPBuffer, null, 64, 64); // egl pbuffer offscreen + surface = createDummySurfaceImpl(eglDevice, false, reqCapsPBuffer, reqCapsPBuffer, null, 64, 64); // egl pbuffer offscreen upstreamSurface = (ProxySurface)surface; upstreamSurface.createNotify(); deviceFromUpstreamSurface = false; @@ -664,7 +664,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final boolean ownDevice; final EGLGraphicsDevice device; - if(createNewDevice || ! ( deviceReq instanceof EGLGraphicsDevice ) ) { + if( createNewDevice || ! (deviceReq instanceof EGLGraphicsDevice) ) { final long nativeDisplayID = ( deviceReq instanceof EGLGraphicsDevice) ? ( (EGLGraphicsDevice) deviceReq ).getNativeDisplayID() : deviceReq.getHandle() ; device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(nativeDisplayID, deviceReq.getConnection(), deviceReq.getUnitID()); @@ -683,8 +683,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { @Override public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, - GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { - final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOffscreenBitOnly(requestedCaps); // complete validation in EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(..) above + GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { + chosenCaps = GLGraphicsConfigurationUtil.fixOffscreenBitOnly(chosenCaps); // complete validation in EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(..) above return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new EGLDummyUpstreamSurfaceHook(width, height)); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index d59197e1d..ec3156f52 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -226,7 +226,8 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { if (null == glp) { throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice); } - final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, new GLCapabilities(glp), null, 64, 64)); + final GLCapabilitiesImmutable caps = new GLCapabilities(glp); + final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, caps, caps, null, 64, 64)); sharedDrawable.setRealized(true); final MacOSXCGLContext sharedContext = (MacOSXCGLContext) sharedDrawable.createContext(null); @@ -358,7 +359,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final MacOSXGraphicsDevice device; - if(createNewDevice) { + if( createNewDevice || !(deviceReq instanceof MacOSXGraphicsDevice) ) { device = new MacOSXGraphicsDevice(deviceReq.getUnitID()); } else { device = (MacOSXGraphicsDevice)deviceReq; @@ -373,8 +374,8 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { @Override public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, - GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { - final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); + GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { + chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new OSXDummyUpstreamSurfaceHook(width, height)); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 91d5c225a..c6bc61a27 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -318,7 +318,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { if (null == glp) { throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice); } - final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, new GLCapabilities(glp), null, 64, 64)); + final GLCapabilitiesImmutable caps = new GLCapabilities(glp); + final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, caps, caps, null, 64, 64)); sharedDrawable.setRealized(true); final GLContextImpl sharedContext = (GLContextImpl) sharedDrawable.createContext(null); @@ -543,7 +544,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final WindowsGraphicsDevice device; - if(createNewDevice) { + if(createNewDevice || !(deviceReq instanceof WindowsGraphicsDevice)) { device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); } else { device = (WindowsGraphicsDevice)deviceReq; @@ -558,18 +559,18 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { @Override public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, - GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { + GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { final WindowsGraphicsDevice device; - if(createNewDevice) { + if( createNewDevice || !(deviceReq instanceof WindowsGraphicsDevice) ) { device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); } else { device = (WindowsGraphicsDevice)deviceReq; } final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); - final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); + chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); final WindowsWGLGraphicsConfiguration config = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(chosenCaps, requestedCaps, chooser, screen); if(null == config) { - throw new GLException("Choosing GraphicsConfiguration failed w/ "+requestedCaps+" on "+screen); + throw new GLException("Choosing GraphicsConfiguration failed w/ "+chosenCaps+" on "+screen); } return new GDISurface(config, 0, new GDIDummyUpstreamSurfaceHook(width, height), createNewDevice); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index 72ddd2693..f7389d42e 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -48,6 +48,8 @@ import java.util.Map; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.ToolkitLock; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; @@ -180,11 +182,16 @@ public abstract class X11GLXContext extends GLContextImpl { @Override protected void destroyContextARBImpl(long ctx) { - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration(); - long display = config.getScreen().getDevice().getHandle(); - - glXMakeContextCurrent(display, 0, 0, 0); - GLX.glXDestroyContext(display, ctx); + final ToolkitLock tkLock = NativeWindowFactory.getGlobalToolkitLockIfRequired(); + tkLock.lock(); + try { + long display = drawable.getNativeSurface().getDisplayHandle(); + + glXMakeContextCurrent(display, 0, 0, 0); + GLX.glXDestroyContext(display, ctx); + } finally { + tkLock.unlock(); + } } private static final int ctx_arb_attribs_idx_major = 0; private static final int ctx_arb_attribs_idx_minor = 2; @@ -243,6 +250,8 @@ public abstract class X11GLXContext extends GLContextImpl { AbstractGraphicsDevice device = config.getScreen().getDevice(); final long display = device.getHandle(); + final ToolkitLock tkLock = NativeWindowFactory.getGlobalToolkitLockIfRequired(); + tkLock.lock(); try { // critical path, a remote display might not support this command, // hence we need to catch the X11 Error within this block. @@ -253,7 +262,10 @@ public abstract class X11GLXContext extends GLContextImpl { Throwable t = new Throwable(getThreadName()+": Info: X11GLXContext.createContextARBImpl glXCreateContextAttribsARB failed with "+getGLVersion(major, minor, ctp, "@creation"), re); t.printStackTrace(); } + } finally { + tkLock.unlock(); } + if(0!=ctx) { if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), ctx)) { if(DEBUG) { @@ -420,7 +432,7 @@ public abstract class X11GLXContext extends GLContextImpl { @Override protected void destroyImpl() throws GLException { - GLX.glXDestroyContext(drawable.getNativeSurface().getDisplayHandle(), contextHandle); + destroyContextARBImpl(contextHandle); } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 018f6a6ea..e38aabef8 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -229,7 +229,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { @Override public SharedResourceRunner.Resource createSharedResource(String connection) { - final X11GraphicsDevice sharedDevice = new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, true); + final X11GraphicsDevice sharedDevice = new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); sharedDevice.lock(); try { final X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, sharedDevice.getDefaultScreen()); @@ -246,8 +246,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if (null == glp) { throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice); } - - final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, new GLCapabilities(glp), null, 64, 64)); + + final GLCapabilitiesImmutable caps = new GLCapabilities(glp); + final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, caps, caps, null, 64, 64)); sharedDrawable.setRealized(true); final GLContextImpl sharedContext = (GLContextImpl) sharedDrawable.createContext(null); @@ -499,11 +500,10 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final X11GraphicsDevice device; - if(createNewDevice) { - // Null X11 resource locking, due to private non-shared Display handle - device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true); + if( createNewDevice || !(deviceReq instanceof X11GraphicsDevice) ) { + device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true /* owner */); } else { - device = (X11GraphicsDevice)deviceReq; + device = (X11GraphicsDevice) deviceReq; } final X11GraphicsScreen screen = new X11GraphicsScreen(device, device.getDefaultScreen()); final X11GLXGraphicsConfiguration config = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED); @@ -512,17 +512,17 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } return new WrappedSurface(config, 0, upstreamHook, createNewDevice); } - + @Override public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, - GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { - final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); + GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { + chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new X11DummyUpstreamSurfaceHook(width, height)); } @Override protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { - final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true); + final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true /* owner */); final X11GraphicsScreen screen = new X11GraphicsScreen(device, screenIdx); final int xvisualID = X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle); if(VisualIDHolder.VID_UNDEFINED == xvisualID) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java index ef2d3283d..8ac324205 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -127,16 +127,22 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF throw new GLException("Shared resource for device n/a: "+device); } final X11GraphicsScreen sharedScreen = (X11GraphicsScreen) sharedResource.getScreen(); - final boolean isMultisampleAvailable = factory.isGLXMultisampleAvailable(sharedScreen.getDevice()); + final X11GraphicsDevice sharedDevice = (X11GraphicsDevice) sharedScreen.getDevice(); + final boolean isMultisampleAvailable = sharedResource.isGLXMultisampleAvailable(); final GLProfile glp = GLProfile.getDefault(device); List availableCaps = null; - - if( sharedResource.isGLXVersionGreaterEqualOneThree() ) { - availableCaps = getAvailableGLCapabilitiesFBConfig(sharedScreen, glp, isMultisampleAvailable); - } - if( null == availableCaps || availableCaps.isEmpty() ) { - availableCaps = getAvailableGLCapabilitiesXVisual(sharedScreen, glp, isMultisampleAvailable); + + sharedDevice.lock(); + try { + if( sharedResource.isGLXVersionGreaterEqualOneThree() ) { + availableCaps = getAvailableGLCapabilitiesFBConfig(sharedScreen, glp, isMultisampleAvailable); + } + if( null == availableCaps || availableCaps.isEmpty() ) { + availableCaps = getAvailableGLCapabilitiesXVisual(sharedScreen, glp, isMultisampleAvailable); + } + } finally { + sharedDevice.unlock(); } if( null != availableCaps && availableCaps.size() > 1 ) { Collections.sort(availableCaps, XVisualIDComparator); @@ -215,16 +221,21 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, factory, x11Device); final boolean usePBuffer = !capsChosen.isOnscreen() && capsChosen.isPBuffer(); - + X11GLXGraphicsConfiguration res = null; - if( factory.isGLXVersionGreaterEqualOneThree(x11Device) ) { - res = chooseGraphicsConfigurationFBConfig(capsChosen, capsReq, chooser, x11Screen, xvisualID); - } - if(null==res) { - if(usePBuffer) { - throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig for visualID "+toHexString(xvisualID)+", "+capsChosen); + x11Device.lock(); + try { + if( factory.isGLXVersionGreaterEqualOneThree(x11Device) ) { + res = chooseGraphicsConfigurationFBConfig(capsChosen, capsReq, chooser, x11Screen, xvisualID); + } + if(null==res) { + if(usePBuffer) { + throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig for visualID "+toHexString(xvisualID)+", "+capsChosen); + } + res = chooseGraphicsConfigurationXVisual(capsChosen, capsReq, chooser, x11Screen, xvisualID); } - res = chooseGraphicsConfigurationXVisual(capsChosen, capsReq, chooser, x11Screen, xvisualID); + } finally { + x11Device.unlock(); } if(null==res) { throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig and XVisual for visualID "+toHexString(xvisualID)+", "+x11Screen+", "+capsChosen); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 1cc796086..7be747ff5 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -210,7 +210,7 @@ public class SWTAccessor { if( null != OS_gtk_class ) { long widgedHandle = callStaticMethodL2L(OS_GTK_WIDGET_WINDOW, handle); long displayHandle = callStaticMethodL2L(OS_gdk_x11_drawable_get_xdisplay, widgedHandle); - return new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, false); + return new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, false /* owner */); } final String nwt = NativeWindowFactory.getNativeWindowType(false); if( NativeWindowFactory.TYPE_WINDOWS == nwt ) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 1962bcd09..006ee4c97 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -42,6 +42,7 @@ import java.util.HashMap; import java.util.Map; import jogamp.nativewindow.Debug; +import jogamp.nativewindow.GlobalToolkitLock; import jogamp.nativewindow.NativeWindowFactoryImpl; import jogamp.nativewindow.ToolkitProperties; import jogamp.nativewindow.ResourceToolkitLock; @@ -102,7 +103,7 @@ public abstract class NativeWindowFactory { private static ToolkitLock jawtUtilJAWTToolkitLock; private static boolean requiresToolkitLock; - private static boolean requiresGlobalToolkitLock; + private static boolean desktopHasThreadingIssues; private static volatile boolean isJVMShuttingDown = false; @@ -183,15 +184,11 @@ public abstract class NativeWindowFactory { final Boolean res1 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresToolkitLock", null, null, cl); requiresToolkitLock = res1.booleanValue(); - if(requiresToolkitLock) { - final Boolean res2 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresGlobalToolkitLock", null, null, cl); - requiresGlobalToolkitLock = res2.booleanValue(); - } else { - requiresGlobalToolkitLock = false; - } + final Boolean res2 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "hasThreadingIssues", null, null, cl); + desktopHasThreadingIssues = res2.booleanValue(); } else { requiresToolkitLock = false; - requiresGlobalToolkitLock = false; + desktopHasThreadingIssues = false; } } @@ -293,7 +290,7 @@ public abstract class NativeWindowFactory { } if(DEBUG) { - System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock+", requiresGlobalToolkitLock "+requiresGlobalToolkitLock); + System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock+", desktopHasThreadingIssues "+desktopHasThreadingIssues); System.err.println("NativeWindowFactory isAWTAvailable "+isAWTAvailable+", defaultFactory "+factory); } @@ -329,11 +326,6 @@ public abstract class NativeWindowFactory { return requiresToolkitLock; } - /** @return true if the underlying toolkit requires global locking, otherwise false. */ - public static boolean requiresGlobalToolkitLock() { - return requiresGlobalToolkitLock; - } - /** @return true if not headless, AWT Component and NativeWindow's AWT part available */ public static boolean isAWTAvailable() { return isAWTAvailable; } @@ -382,11 +374,15 @@ public abstract class NativeWindowFactory { public static ToolkitLock getNullToolkitLock() { return NativeWindowFactoryImpl.getNullToolkitLock(); } - - public static ToolkitLock getGlobalToolkitLock() { - return NativeWindowFactoryImpl.getGlobalToolkitLock(); - } + /** + * Ony call this for small code segments for desktop w/ threading issues. + * @return {@link GlobalToolkitLock} if desktop has threading issues, otherwise {@link #getNullToolkitLock()} + */ + public static ToolkitLock getGlobalToolkitLockIfRequired() { + return desktopHasThreadingIssues ? GlobalToolkitLock.getSingleton() : getNullToolkitLock(); + } + /** * Provides the system default {@link ToolkitLock} for the default system windowing type. * @see #getNativeWindowType(boolean) @@ -400,7 +396,6 @@ public abstract class NativeWindowFactory { * Provides the default {@link ToolkitLock} for type. *
    *
  • JAWT {@link ToolkitLock} if required and type is of {@link #TYPE_AWT} and AWT available,
  • - *
  • {@link jogamp.nativewindow.GlobalToolkitLock} if required, otherwise
  • *
  • {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
  • *
  • {@link jogamp.nativewindow.NullToolkitLock}
  • *
@@ -410,9 +405,6 @@ public abstract class NativeWindowFactory { if( TYPE_AWT == type && isAWTAvailable() ) { return getAWTToolkitLock(); } - if( requiresGlobalToolkitLock ) { - return NativeWindowFactoryImpl.getGlobalToolkitLock(); - } return ResourceToolkitLock.create(); } return NativeWindowFactoryImpl.getNullToolkitLock(); @@ -422,7 +414,6 @@ public abstract class NativeWindowFactory { * Provides the default {@link ToolkitLock} for type and deviceHandle. *
    *
  • JAWT {@link ToolkitLock} if required and type is of {@link #TYPE_AWT} and AWT available,
  • - *
  • {@link jogamp.nativewindow.GlobalToolkitLock} if required, otherwise
  • *
  • {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
  • *
  • {@link jogamp.nativewindow.NullToolkitLock}
  • *
@@ -432,9 +423,6 @@ public abstract class NativeWindowFactory { if( TYPE_AWT == type && isAWTAvailable() ) { return getAWTToolkitLock(); } - if( requiresGlobalToolkitLock ) { - return NativeWindowFactoryImpl.getGlobalToolkitLock(); - } return ResourceToolkitLock.create(); } return NativeWindowFactoryImpl.getNullToolkitLock(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java index 0c2a1e43f..c9f830811 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java @@ -36,16 +36,19 @@ import com.jogamp.common.util.locks.RecursiveLock; /** * Implementing a global recursive {@link javax.media.nativewindow.ToolkitLock}. *

- * This is the last resort for unstable driver, e.g. proprietary ATI/X11 12.8 and 12.9, - * where multiple X11 display connections to the same connection name are not treated - * thread safe within the GL/X11 driver. + * This is the last resort for unstable driver where multiple X11 display connections + * to the same connection name are not treated thread safe within the GL/X11 driver. *

*/ public class GlobalToolkitLock implements ToolkitLock { private static final RecursiveLock globalLock = LockFactory.createRecursiveLock(); + private static GlobalToolkitLock singleton = new GlobalToolkitLock(); - /** Singleton via {@link NativeWindowFactoryImpl#getGlobalToolkitLock()} */ - protected GlobalToolkitLock() { } + public static final GlobalToolkitLock getSingleton() { + return singleton; + } + + private GlobalToolkitLock() { } @Override public final void lock() { diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java index c35cede77..a3a66b7f1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java @@ -44,16 +44,11 @@ import com.jogamp.common.util.ReflectionUtil.AWTNames; public class NativeWindowFactoryImpl extends NativeWindowFactory { private static final ToolkitLock nullToolkitLock = new NullToolkitLock(); - private static final ToolkitLock globalToolkitLock = new GlobalToolkitLock(); public static ToolkitLock getNullToolkitLock() { return nullToolkitLock; } - public static ToolkitLock getGlobalToolkitLock() { - return globalToolkitLock; - } - // This subclass of NativeWindowFactory handles the case of // NativeWindows being passed in protected NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException { diff --git a/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java b/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java index 2062d1f58..ed23def8f 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java @@ -13,15 +13,11 @@ import javax.media.nativewindow.NativeWindowFactory; public static boolean requiresToolkitLock() {} - public static boolean requiresGlobalToolkitLock() {} + public static boolean hasThreadingIssues() {} * * Above static methods are invoked by {@link NativeWindowFactory#initSingleton()}, * or {@link NativeWindowFactory#shutdown()} via reflection. *

- *

- * If requiresGlobalToolkitLock() == true, then - * requiresToolkitLock() == true shall be valid as well. - *

*/ public interface ToolkitProperties { @@ -46,6 +42,6 @@ public interface ToolkitProperties { /** * Called by {@link NativeWindowFactory#initSingleton()} */ - // boolean requiresGlobalToolkitLock(); + // boolean hasThreadingIssues(); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index 67c64a95c..349da8ee6 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -237,18 +237,15 @@ public class JAWTUtil { jawtToolkitLock = new ToolkitLock() { public final void lock() { - NativeWindowFactory.getGlobalToolkitLock().lock(); JAWTUtil.lockToolkit(); if(TRACE_LOCK) { System.err.println("JAWTToolkitLock.lock()"); } } public final void unlock() { if(TRACE_LOCK) { System.err.println("JAWTToolkitLock.unlock()"); } JAWTUtil.unlockToolkit(); - NativeWindowFactory.getGlobalToolkitLock().unlock(); } @Override public final void validateLocked() throws RuntimeException { - NativeWindowFactory.getGlobalToolkitLock().validateLocked(); JAWTUtil.validateLocked(); } public final void dispose() { diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 481cbbe39..a195f137e 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -76,7 +76,7 @@ public class OSXUtil implements ToolkitProperties { * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ - public static final boolean requiresGlobalToolkitLock() { return false; } + public static final boolean hasThreadingIssues() { return false; } public static boolean isNSView(long object) { return isNSView0(object); diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index 4408a0903..2f4e18359 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -84,7 +84,7 @@ public class GDIUtil implements ToolkitProperties { * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ - public static final boolean requiresGlobalToolkitLock() { return false; } + public static final boolean hasThreadingIssues() { return false; } private static RegisteredClass dummyWindowClass = null; private static Object dummyWindowSync = new Object(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 103995a8d..c771cd67a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -95,7 +95,7 @@ public class X11Util implements ToolkitProperties { private static String nullDisplayName = null; private static volatile boolean isInit = false; private static boolean markAllDisplaysUnclosable = false; // ATI/AMD X11 driver issues - private static boolean requiresGlobalToolkitLock = false; // ATI/AMD X11 driver issues + private static boolean hasThreadingIssues = false; // ATI/AMD X11 driver issues private static Object setX11ErrorHandlerLock = new Object(); private static final String X11_EXTENSION_ATIFGLRXDRI = "ATIFGLRXDRI"; @@ -137,7 +137,7 @@ public class X11Util implements ToolkitProperties { hasX11_EXTENSION_ATIFGLRXDRI = false; hasX11_EXTENSION_ATIFGLEXTENSION = false; } - requiresGlobalToolkitLock = ATI_HAS_MULTITHREADING_BUG && ( hasX11_EXTENSION_ATIFGLRXDRI || hasX11_EXTENSION_ATIFGLEXTENSION ); + hasThreadingIssues = ATI_HAS_MULTITHREADING_BUG && ( hasX11_EXTENSION_ATIFGLRXDRI || hasX11_EXTENSION_ATIFGLEXTENSION ); markAllDisplaysUnclosable = ATI_HAS_XCLOSEDISPLAY_BUG && ( hasX11_EXTENSION_ATIFGLRXDRI || hasX11_EXTENSION_ATIFGLEXTENSION ); if(DEBUG) { @@ -147,7 +147,7 @@ public class X11Util implements ToolkitProperties { ",\n\t X11_EXTENSION_ATIFGLRXDRI " + hasX11_EXTENSION_ATIFGLRXDRI+ ",\n\t X11_EXTENSION_ATIFGLEXTENSION " + hasX11_EXTENSION_ATIFGLEXTENSION+ ",\n\t requiresToolkitLock "+requiresToolkitLock()+ - ",\n\t requiresGlobalToolkitLock "+requiresGlobalToolkitLock()+ + ",\n\t hasThreadingIssues "+hasThreadingIssues()+ ",\n\t markAllDisplaysUnclosable "+getMarkAllDisplaysUnclosable() ); // Thread.dumpStack(); @@ -228,8 +228,8 @@ public class X11Util implements ToolkitProperties { * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ - public static final boolean requiresGlobalToolkitLock() { - return requiresGlobalToolkitLock; // JAWT locking: yes, instead of native X11 locking w use a global lock. + public static final boolean hasThreadingIssues() { + return hasThreadingIssues; // JOGL impl. may utilize special locking "somewhere" } public static void setX11ErrorHandler(boolean onoff, boolean quiet) { diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 6e80e966a..a3230fa62 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -80,7 +80,7 @@ public class DisplayDriver extends DisplayImpl { if( 0 == handle ) { throw new RuntimeException("Error creating display(Win): "+name); } - aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, true); + aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); try { CompleteDisplay0(aDevice.getHandle()); } catch(RuntimeException e) { diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index bde723634..92f174e39 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -73,7 +73,7 @@ public class WindowDriver extends WindowImpl { if( 0 == renderDeviceHandle ) { throw new RuntimeException("Error creating display(EDT): "+edtDevice.getConnection()); } - renderDevice = new X11GraphicsDevice(renderDeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true); + renderDevice = new X11GraphicsDevice(renderDeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); final AbstractGraphicsScreen renderScreen = new X11GraphicsScreen(renderDevice, screen.getIndex()); final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested); diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 56c11fab4..69a115ab1 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -329,10 +329,10 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage char text[255]; // XEventsQueued(dpy, X): - // QueuedAlready : No I/O Flush or system call doesn't work on some cards (eg ATI) ?) + // QueuedAlready == XQLength(): No I/O Flush or system call doesn't work on some cards (eg ATI) ?) // QueuedAfterFlush == XPending(): I/O Flush only if no already queued events are available // QueuedAfterReading : QueuedAlready + if queue==0, attempt to read more .. - if ( 0 >= XPending(dpy) ) { + if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { // DBG_PRINT( "X11: DispatchMessages 0x%X - Leave 1\n", dpy); return; } diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 2e16e7cae..202ad6fff 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -701,7 +701,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0 Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom); XDestroyWindow(dpy, w); - XSync(dpy, False); + XSync(dpy, True); // discard all events now, no more handler (*env)->DeleteGlobalRef(env, jwindow); -- cgit v1.2.3 From 84632ca22d112da45b807299d2b1f5e4f4107695 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 5 Oct 2012 03:27:44 +0200 Subject: Fix SWTEDTUtil bug, where it simply doesn't start by an implicit 'invoke()' - No NewtCanvasSWT resize, nor input event delivery. A new EDTUtil instance is not started automatically. Since SWTEDTUtil is attached to the DisplayImpl later in time, i.e. after it's native creation, there is no EDTUtil.invoke(..) call which started it. The not started SWTEDTUtil could not deliver any events. Fix: Start it explicitly - add API doc comment in Display.setEDTUtil(..) --- make/scripts/tests.sh | 6 +++--- src/newt/classes/com/jogamp/newt/Display.java | 8 ++++++++ src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 9 +++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5d12475a5..affa130fb 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -104,7 +104,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow" - #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT" + D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" @@ -238,7 +238,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -355,7 +355,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* # # newt.awt (testawt) diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 391bccf3d..de1d58068 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -164,6 +164,14 @@ public abstract class Display { * If newEDTUtil is not null and equals the previous one, * null is returned and no change is being made. *

+ *

+ * Note that newEDTUtil will not be started if not done so already, + * to do so you may issue {@link EDTUtil#invoke(boolean, Runnable) invoke} + * on the new EDTUtil: + *

+     *          newEDTUtil.invoke(true, new Runnable() { public void run() { } } );
+     * 
+ *

*/ public abstract EDTUtil setEDTUtil(EDTUtil newEDTUtil); diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 36bc3f28f..74611706a 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -325,8 +325,13 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { final int w = clientArea.width; final int h = clientArea.height; - final Display newtDisplay = newtChild.getScreen().getDisplay(); - newtDisplay.setEDTUtil(new SWTEDTUtil(newtDisplay, getDisplay())); + // set SWT EDT and start it + { + final Display newtDisplay = newtChild.getScreen().getDisplay(); + final EDTUtil edt = new SWTEDTUtil(newtDisplay, getDisplay()); + newtDisplay.setEDTUtil(edt); + edt.invoke(true, new Runnable() { public void run() { } } ); // start EDT + } newtChild.setSize(w, h); newtChild.reparentWindow(nativeWindow); -- cgit v1.2.3 From 8f6233f11693f5e079cfeb6706fe2c37b5b9a6c2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 5 Oct 2012 03:43:03 +0200 Subject: Fix regression of commit fbe331f013608eb31ff0d8675f4e4c9881c9c48b: X11 DisplayDriver dispatchMessagesNative() aDevice NPE at finally The aDevice could be pulled via destroy message, hence add check if null. --- src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index a3230fa62..f3a548a08 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -89,6 +89,7 @@ public class DisplayDriver extends DisplayImpl { } } + @Override protected void closeNativeImpl() { DisplayRelease0(aDevice.getHandle(), javaObjectAtom, windowDeleteAtom); javaObjectAtom = 0; @@ -96,6 +97,7 @@ public class DisplayDriver extends DisplayImpl { aDevice.close(); // closes X11 display } + @Override protected void dispatchMessagesNative() { aDevice.lock(); try { @@ -104,7 +106,9 @@ public class DisplayDriver extends DisplayImpl { DispatchMessages0(handle, javaObjectAtom, windowDeleteAtom); } } finally { - aDevice.unlock(); + if(null != aDevice) { // could be pulled by destroy event + aDevice.unlock(); + } } } -- cgit v1.2.3 From a3cb6bb14f410f67fccf5ccd4cd7ecc66f448389 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 5 Oct 2012 06:31:08 +0200 Subject: Fix Bug 572 (2nd time): GLCanvas.validateGLDrawable() @ display() and reshape() ; GLCanvas.reshape() only if drawble valid ; GLCanvas.validateGLDrawable() also test isDisplayable() ; Fix size validation ; resizeOffscreenDrawable(..) don't validate 'safe' size 1x1 - GLCanvas.validateGLDrawable() @ display() and reshape() To help users using GLCanvas w/ having a realized GLCanvas/Drawable, validateGLDrawable() is also called at reshape(). This shall ensure a valid drawable after even a non AWT-EDT issued first setVisible(). - GLCanvas.reshape() only if drawble valid Otherwise offscreen reshape attempts would happen even on unrealized drawable, which is not necessary. - GLCanvas.validateGLDrawable() also test isDisplayable() To make sure the native peer is valid, also test isDisplayable() - Fix size validation Since we have experienced odd size like 0 x -41 test each component, i.e. 0 < width && 0 < height. This is done through all JOGL/NEWT components. - resizeOffscreenDrawable(..) don't validate 'safe' size 1x1 In case method is called w/ odd size, i.e. 0 x -41, the safe size 1x1 is used. However, we cannot validate this size. Dump WARNING if odd size is detected. --- make/scripts/tests.sh | 6 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 2 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 60 +++++----- .../classes/jogamp/opengl/GLDrawableHelper.java | 11 +- src/newt/classes/com/jogamp/newt/Window.java | 6 +- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 2 +- src/newt/classes/jogamp/newt/WindowImpl.java | 8 +- .../opengl/test/junit/jogl/awt/TestBug572AWT.java | 127 +++++++++++++++++++++ .../jogamp/opengl/test/junit/util/UITestCase.java | 11 +- 9 files changed, 188 insertions(+), 45 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index affa130fb..ed2e238fb 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -137,7 +137,7 @@ function jrun() { #D_ARGS="-Xprof" #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Dnativewindow.debug=all" - #D_ARGS="-Djogl.debug.GLCanvas" + D_ARGS="-Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Dnativewindow.debug.NativeWindow" @@ -317,6 +317,7 @@ function testawtswt() { #testawt javax.media.opengl.awt.GLCanvas $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* @@ -355,7 +356,8 @@ function testawtswt() { #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # # newt.awt (testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 06114431a..24971ff97 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -389,7 +389,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { return false; } final Rectangle nClientArea = clientArea; - if(0 == nClientArea.width * nClientArea.height) { + if(0 >= nClientArea.width || 0 >= nClientArea.height) { return false; } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 335322be9..4bdae7135 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -440,6 +440,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public void display() { + if( !validateGLDrawable() ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: GLCanvas display - skipped GL render, drawable not valid yet"); + } + return; // not yet available .. + } Threading.invoke(true, displayOnEDTAction, getTreeLock()); awtWindowClosingProtocol.addClosingListenerOneShot(); } @@ -489,7 +495,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing (int) ((getHeight() + bounds.getHeight()) / 2)); return; } - if( ! this.helper.isAnimatorAnimating() ) { + if( ! this.helper.isExternalAnimatorAnimating() ) { display(); } } @@ -570,30 +576,29 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( _drawable.isRealized() ) { return true; } - if (!Beans.isDesignTime() && - 0 < _drawable.getWidth() * _drawable.getHeight() ) { - // make sure drawable realization happens on AWT EDT, due to AWTTree lock - AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction); - if( _drawable.isRealized() ) { - sendReshape=true; // ensure a reshape is being send .. - if(DEBUG) { - System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString()); - Thread.dumpStack(); + final RecursiveLock _lock = lock; + _lock.lock(); + try { + if (!Beans.isDesignTime() && isDisplayable() && + 0 < _drawable.getWidth() && 0 < _drawable.getHeight() ) { + // make sure drawable realization happens on AWT EDT, due to AWTTree lock + AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction); + if( _drawable.isRealized() ) { + sendReshape=true; // ensure a reshape is being send .. + if(DEBUG) { + System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString()); + Thread.dumpStack(); + } + return true; } - return true; } + } finally { + _lock.unlock(); } } return false; } - private Runnable setRealizedOnEDTAction = new Runnable() { - @Override - public void run() { - final GLDrawable _drawable = drawable; - if ( null != _drawable && 0 < _drawable.getWidth() * _drawable.getHeight() ) { - _drawable.setRealized(true); - } - } }; + private Runnable setRealizedOnEDTAction = new Runnable() { public void run() { drawable.setRealized(true); } }; /**

Overridden to track when this component is removed from a container. Subclasses which override this method must call @@ -640,11 +645,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing synchronized (getTreeLock()) { // super.reshape(..) claims tree lock, so we do extend it's lock over reshape super.reshape(x, y, width, height); - GLDrawableImpl _drawable = drawable; - if( null != _drawable ) { - if(DEBUG) { - System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+width+"x"+height+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); - } + if(DEBUG) { + System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+width+"x"+height+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + // Thread.dumpStack(); + } + if( validateGLDrawable() ) { + final GLDrawableImpl _drawable = drawable; if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) { final RecursiveLock _lock = lock; _lock.lock(); @@ -984,11 +990,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final RecursiveLock _lock = lock; _lock.lock(); try { - if( validateGLDrawable() ) { - helper.invokeGL(drawable, context, displayAction, initAction); - } else if(DEBUG) { - System.err.println(getThreadName()+": Info: GLCanvas display - skipped GL render, drawable not valid yet"); - } + helper.invokeGL(drawable, context, displayAction, initAction); } finally { _lock.unlock(); } diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 13c387231..d4ff9702c 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -241,9 +241,14 @@ public class GLDrawableHelper { if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { throw new NativeWindowException("Could not lock surface of drawable: "+drawable); } + boolean validateSize = true; try { - if(0>=newWidth) { newWidth = 1; } - if(0>=newHeight) { newHeight = 1; } + if(DEBUG && ( 0>=newWidth || 0>=newHeight) ) { + System.err.println("WARNING: Odd size detected: "+newWidth+"x"+newHeight+", using safe size 1x1. Drawable "+drawable); + Thread.dumpStack(); + } + if(0>=newWidth) { newWidth = 1; validateSize=false; } + if(0>=newHeight) { newHeight = 1; validateSize=false; } // propagate new size if(ns instanceof ProxySurface) { final ProxySurface ps = (ProxySurface) ns; @@ -266,7 +271,7 @@ public class GLDrawableHelper { } finally { ns.unlockSurface(); } - if(drawable.getWidth() != newWidth || drawable.getHeight() != newHeight) { + if( validateSize && ( drawable.getWidth() != newWidth || drawable.getHeight() != newHeight ) ) { throw new InternalError("Incomplete resize operation: expected "+newWidth+"x"+newHeight+", has: "+drawable); } return drawable; diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 78e2abc6e..cc42465f1 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -129,7 +129,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { *

      * if ( 0 == windowHandle && visible ) {
      *   this.visible = visible;
-     *   if( 0 < width*height ) {
+     *   if( 0 < width && 0 < height ) {
      *     createNative();
      *   }
      * } else if ( this.visible != visible ) {
@@ -171,9 +171,9 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
      * 

* Zero size semantics are respected, see {@link #setVisible(boolean)}:
*

-     * if ( 0 != windowHandle && 0 ≥ width*height && visible ) {
+     * if ( visible && 0 != windowHandle && ( 0 ≥ width || 0 ≥ height ) ) {
      *   setVisible(false);
-     * } else if ( 0 == windowHandle && 0 < width*height && visible ) {
+     * } else if ( visible && 0 == windowHandle && 0 < width && 0 < height ) {
      *   setVisible(true);
      * } else {
      *   // as expected ..
diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
index 74611706a..525225804 100644
--- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
+++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
@@ -157,7 +157,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
         }
         updateSizeCheck();
         final Rectangle nClientArea = clientArea;
-        if(0 == nClientArea.width * nClientArea.height) {
+        if(0 >= nClientArea.width || 0 >= nClientArea.height) {        
             return false;
         }
         
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 79770189b..c94ce286b 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -797,10 +797,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                         System.err.println("Window setSize: START "+getWidth()+"x"+getHeight()+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible);
                     }
                     int visibleAction; // 0 nop, 1 invisible, 2 visible (create)
-                    if ( isNativeValid() && 0>=width*height && visible ) {
+                    if ( visible && isNativeValid() && ( 0 >= width || 0 >= height ) ) {
                         visibleAction=1; // invisible
                         defineSize(0, 0);
-                    } else if ( !isNativeValid() && 00);
+        Assert.assertTrue("GLCanvas didn't display", snapshooter.getDisplayCount()>0);
+        
+        // After initial 'setVisible(true)' all AWT manipulation needs to be done
+        // via the AWT EDT, according to the AWT spec.
+
+        Runnable cleanup = new Runnable() {
+            public void run() {
+                System.err.println("cleaning up...");
+                window.setVisible(false);
+                try {
+                    window.removeAll();
+                } catch (Throwable t) {
+                    Assume.assumeNoException(t);
+                    t.printStackTrace();
+                }
+                window.dispose();
+            }
+
+        };
+
+        // AWT / Swing on EDT..
+        SwingUtilities.invokeAndWait(cleanup);
+    }
+
+    @Test
+    public void test01() throws InterruptedException, InvocationTargetException {
+        runTestGL();
+    }
+
+    public static void main(String args[]) {
+        org.junit.runner.JUnitCore.main(TestBug572AWT.class.getName());
+    }
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
index c31555969..741014502 100644
--- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
+++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
@@ -206,6 +206,7 @@ public abstract class UITestCase {
     public class SnapshotGLEventListener implements GLEventListener {
         private final GLReadBufferUtil screenshot;
         private volatile boolean makeShot = false;
+        private volatile boolean makeShotAlways = false;
         private volatile int displayCount=0;
         private volatile int reshapeCount=0;
         public SnapshotGLEventListener(GLReadBufferUtil screenshot) {
@@ -214,13 +215,16 @@ public abstract class UITestCase {
         public SnapshotGLEventListener() {
             this.screenshot = new GLReadBufferUtil(false, false);
         }
+        public int getDisplayCount() { return displayCount; }
+        public int getReshapeCount() { return reshapeCount; }
 
         public void init(GLAutoDrawable drawable) {}
         public void dispose(GLAutoDrawable drawable) {}
         public void display(GLAutoDrawable drawable) {
             final GL gl = drawable.getGL();
-            System.err.println(Thread.currentThread().getName()+": ** display: "+displayCount+": "+drawable.getWidth()+"x"+drawable.getHeight()+", makeShot "+makeShot);
-            if(makeShot) {
+            final boolean _makeShot = makeShot || makeShotAlways;
+            System.err.println(Thread.currentThread().getName()+": ** display: "+displayCount+": "+drawable.getWidth()+"x"+drawable.getHeight()+", makeShot "+_makeShot);
+            if(_makeShot) {
                 makeShot=false;
                 snapshot(displayCount, null, gl, screenshot, TextureIO.PNG, null);
             }
@@ -233,6 +237,9 @@ public abstract class UITestCase {
         public void setMakeSnapshot() {
             makeShot=true;
         }
+        public void setMakeSnapshotAlways(boolean v) {
+            makeShotAlways=v;
+        }
     };
     
 }
-- 
cgit v1.2.3


From 742282292bb115343287a626b35211e81d695bad Mon Sep 17 00:00:00 2001
From: Sven Gothel 
Date: Fri, 5 Oct 2012 06:32:50 +0200
Subject: Use helper.isExternalAnimatorAnimating() instead of
 helper.isAnimatorAnimating() for decision whether to display() now; Minor API
 comments.

---
 src/jogl/classes/javax/media/opengl/GLDrawable.java    | 2 +-
 src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java | 4 ++--
 src/newt/classes/jogamp/newt/DisplayImpl.java          | 1 +
 3 files changed, 4 insertions(+), 3 deletions(-)

(limited to 'src/newt/classes')

diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java
index 10eea2efc..c0910eb0f 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawable.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java
@@ -149,7 +149,7 @@ public interface GLDrawable {
       This object shall be directly associated to the attached {@link NativeSurface}'s
       {@link AbstractGraphicsConfiguration}, and if changes are necessary,
       they should reflect those as well.
-      @return A copy of the queried object.
+      @return The immutable queried instance.
     */
   public GLCapabilitiesImmutable getChosenGLCapabilities();
 
diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java
index d49fc75d9..d76272723 100644
--- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java
+++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java
@@ -95,7 +95,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter {
     protected final void defaultWindowRepaintOp() {
         final GLDrawable _drawable = drawable;
         if( null != _drawable && _drawable.isRealized() ) {
-            if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isAnimatorAnimating() ) {
+            if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isExternalAnimatorAnimating() ) {
                 display();
             }
         }
@@ -124,7 +124,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter {
             }
             sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock
             if( _drawable.isRealized() ) {
-                if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isAnimatorAnimating() ) {
+                if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isExternalAnimatorAnimating() ) {
                     display();
                 }
             }
diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java
index daeb3e886..fbccc5767 100644
--- a/src/newt/classes/jogamp/newt/DisplayImpl.java
+++ b/src/newt/classes/jogamp/newt/DisplayImpl.java
@@ -359,6 +359,7 @@ public abstract class DisplayImpl extends Display {
         return "NEWT-Display["+getFQName()+", excl "+exclusive+", refCount "+refCount+", hasEDT "+(null!=edtUtil)+", edtRunning "+isEDTRunning()+", "+aDevice+"]";
     }
 
+    /** Dispatch native Toolkit messageges */
     protected abstract void dispatchMessagesNative();
 
     private Object eventsLock = new Object();
-- 
cgit v1.2.3


From d10dae464ef9309a92eb9b49323fe1db93c3fc9f Mon Sep 17 00:00:00 2001
From: Sven Gothel 
Date: Mon, 8 Oct 2012 01:22:30 +0200
Subject: Raise NEWT MouseButton Maximum from 6 -> 16 (API Change)

- Button 9 has been reported to be sent by Olamedia

- Rearrange the input bit mask in InputEvent (API Change)

- Raise the max. button number to 16
---
 make/scripts/tests.sh                              |  6 ++---
 .../classes/com/jogamp/newt/event/InputEvent.java  | 28 +++++++++++++---------
 .../classes/com/jogamp/newt/event/MouseEvent.java  | 11 +++++++--
 .../jogamp/newt/driver/x11/WindowDriver.java       |  4 ++--
 src/newt/native/InputEvent.h                       | 25 +++++++++++--------
 5 files changed, 46 insertions(+), 28 deletions(-)

(limited to 'src/newt/classes')

diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index b0a8c78a2..8b4f7dda4 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -131,7 +131,7 @@ function jrun() {
     #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen"
     #D_ARGS="-Dnewt.debug.Window"
     #D_ARGS="-Dnewt.debug.Window.KeyEvent"
-    #D_ARGS="-Dnewt.debug.Window.MouseEvent"
+    D_ARGS="-Dnewt.debug.Window.MouseEvent"
     #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all"
     #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator"
     #D_ARGS="-Dnewt.debug.Window"
@@ -239,7 +239,7 @@ function testawtswt() {
 #testnoawt com.jogamp.newt.opengl.GLWindow $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
+testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $*
@@ -269,7 +269,7 @@ function testawtswt() {
 #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $*
 
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $*
-testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $*
diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java
index 148ac5962..0122bda9a 100644
--- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java
@@ -43,22 +43,28 @@ public abstract class InputEvent extends NEWTEvent
  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;
- public static final int  BUTTON4_MASK     = 1 <<  9;
- public static final int  BUTTON5_MASK     = 1 << 10;
- public static final int  BUTTON6_MASK     = 1 << 11;
+ public static final int  ALT_GRAPH_MASK   = 1 <<  4;
+ 
+ public static final int  BUTTON1_MASK     = 1 <<  5;
+ public static final int  BUTTON2_MASK     = 1 <<  6;
+ public static final int  BUTTON3_MASK     = 1 <<  7;
+ public static final int  BUTTON4_MASK     = 1 <<  8;
+ public static final int  BUTTON5_MASK     = 1 <<  9;
+ public static final int  BUTTON6_MASK     = 1 << 10;
+ public static final int  BUTTON7_MASK     = 1 << 11;
+ public static final int  BUTTON8_MASK     = 1 << 12;
+ public static final int  BUTTON9_MASK     = 1 << 13;
+ 
+ public static final int  BUTTONLAST_MASK  = 1 << 20;  // 16
  
  /** Event is caused by auto-repeat. */
- public static final int  AUTOREPEAT_MASK  = 1 << 15;
+ public static final int  AUTOREPEAT_MASK  = 1 << 29;
  
  /** Pointer is confined, see {@link Window#confinePointer(boolean)}. */
- public static final int  CONFINED_MASK    = 1 << 16;
+ public static final int  CONFINED_MASK    = 1 << 30;
  
  /** Pointer is invisible, see {@link Window#setPointerVisible(boolean)}. */
- public static final int  INVISIBLE_MASK   = 1 << 17;
+ public static final int  INVISIBLE_MASK   = 1 << 31;
 
  /** 
   * Returns the corresponding button mask for the given button.
@@ -70,7 +76,7 @@ public abstract class InputEvent extends NEWTEvent
   */
  public static final int getButtonMask(int button)  {
      if( 0 < button && button <= MouseEvent.BUTTON_NUMBER ) {
-         return 1 << ( 5 + button ) ;
+         return 1 << ( 4 + button ) ;
      }
      return 0;
  }
diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
index d293d2db7..914aaa647 100644
--- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java
@@ -49,8 +49,15 @@ public class MouseEvent extends InputEvent
     public static final int BUTTON5 = 5;
     /** ID for button 6, value 6 */
     public static final int BUTTON6 = 6;
-    /** Number of buttons, value 6 */
-    public static final int BUTTON_NUMBER = 6;
+    /** ID for button 6, value 7 */
+    public static final int BUTTON7 = 7;
+    /** ID for button 6, value 8 */
+    public static final int BUTTON8 = 8;
+    /** ID for button 6, value 9 */
+    public static final int BUTTON9 = 9;
+    
+    /** Maximum number of buttons, value 16 */
+    public static final int BUTTON_NUMBER =  16;
 
     public static final int getClickTimeout() { 
         return 300; 
diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
index 92f174e39..c21cb4b40 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java
@@ -51,9 +51,9 @@ import com.jogamp.newt.event.MouseEvent;
 
 public class WindowDriver extends WindowImpl {
     private static final String WINDOW_CLASS_NAME = "NewtWindow";
-    private static final int X11_WHEEL_ONE_UP_BUTTON = 4;
+    private static final int X11_WHEEL_ONE_UP_BUTTON   = 4;
     private static final int X11_WHEEL_ONE_DOWN_BUTTON = 5;
-    private static final int X11_WHEEL_TWO_UP_BUTTON = 6;
+    private static final int X11_WHEEL_TWO_UP_BUTTON   = 6;
     private static final int X11_WHEEL_TWO_DOWN_BUTTON = 7;
     
     static {
diff --git a/src/newt/native/InputEvent.h b/src/newt/native/InputEvent.h
index 51c56c474..3fa7dbefe 100644
--- a/src/newt/native/InputEvent.h
+++ b/src/newt/native/InputEvent.h
@@ -38,15 +38,20 @@
 #define EVENT_CTRL_MASK       (1 <<  1)
 #define EVENT_META_MASK       (1 <<  2)
 #define EVENT_ALT_MASK        (1 <<  3)
-#define EVENT_ALT_GRAPH_MASK  (1 <<  5)
-#define EVENT_BUTTON1_MASK    (1 <<  6)
-#define EVENT_BUTTON2_MASK    (1 <<  7)
-#define EVENT_BUTTON3_MASK    (1 <<  8)
-#define EVENT_BUTTON4_MASK    (1 <<  9)
-#define EVENT_BUTTON5_MASK    (1 << 10)
-#define EVENT_BUTTON6_MASK    (1 << 11)
-#define EVENT_AUTOREPEAT_MASK (1 << 15)
-#define EVENT_CONFINED_MASK   (1 << 16)
-#define EVENT_INVISIBLE_MASK  (1 << 17)
+#define EVENT_ALT_GRAPH_MASK  (1 <<  4)
+
+#define EVENT_BUTTON1_MASK    (1 <<  5)
+#define EVENT_BUTTON2_MASK    (1 <<  6)
+#define EVENT_BUTTON3_MASK    (1 <<  7)
+#define EVENT_BUTTON4_MASK    (1 <<  8)
+#define EVENT_BUTTON5_MASK    (1 <<  9)
+#define EVENT_BUTTON6_MASK    (1 << 10)
+#define EVENT_BUTTON7_MASK    (1 << 11)
+#define EVENT_BUTTON8_MASK    (1 << 12)
+#define EVENT_BUTTON9_MASK    (1 << 13)
+
+#define EVENT_AUTOREPEAT_MASK (1 << 29)
+#define EVENT_CONFINED_MASK   (1 << 30)
+#define EVENT_INVISIBLE_MASK  (1 << 31)
 
 #endif
-- 
cgit v1.2.3


From 1b327874356130096546533a690deff3b7bc876c Mon Sep 17 00:00:00 2001
From: Sven Gothel 
Date: Wed, 17 Oct 2012 08:08:09 +0200
Subject: Minor NEWT Display/Screen API doc

---
 src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java | 4 ++--
 src/newt/classes/com/jogamp/newt/Display.java          | 6 +++---
 src/newt/classes/com/jogamp/newt/Screen.java           | 8 +++++---
 3 files changed, 10 insertions(+), 8 deletions(-)

(limited to 'src/newt/classes')

diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java
index 057f28487..85156e8a1 100644
--- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java
+++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java
@@ -500,8 +500,8 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter {
     /**
      * @param t the thread for which context release shall be skipped, usually the animation thread,
      *          ie. {@link Animator#getThread()}.
-     * @deprecated this is an experimental feature,
-     *             intended for measuring performance in regards to GL context switch
+     * @deprecated This is an experimental feature,
+     *             intended for measuring performance in regards to GL context switch.
      */
     @Deprecated
     public void setSkipContextReleaseThread(Thread t) {
diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java
index de1d58068..e97dec88d 100644
--- a/src/newt/classes/com/jogamp/newt/Display.java
+++ b/src/newt/classes/com/jogamp/newt/Display.java
@@ -88,7 +88,7 @@ public abstract class Display {
     public abstract boolean isNativeValid();
 
     /**
-     * @return number of references by Screen
+     * @return number of references
      */
     public abstract int getReferenceCount();
 
@@ -96,7 +96,7 @@ public abstract class Display {
      * The 1st call will initiate native creation,
      * since we follow the lazy creation pattern.
      *
-     * @return number of references after adding one
+     * @return number of references post operation
      * @throws NativeWindowException if the native creation failed.
      * @see #removeReference()
      */
@@ -106,7 +106,7 @@ public abstract class Display {
      * The last call may destroy this instance,
      * if {@link #getDestroyWhenUnused()} returns true.
      *
-     * @return number of references after removing one
+     * @return number of references post operation
      * @see #addReference()
      * @see #getDestroyWhenUnused()
      * @see #setDestroyWhenUnused(boolean)
diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java
index cfbcc988a..a09748d52 100644
--- a/src/newt/classes/com/jogamp/newt/Screen.java
+++ b/src/newt/classes/com/jogamp/newt/Screen.java
@@ -89,13 +89,14 @@ public abstract class Screen {
     public abstract boolean isNativeValid();
 
     /**
-     * @return number of references by Window
+     * @return number of references
      */
     public abstract int getReferenceCount();
 
     /**
      * See {@link Display#addReference()}
-     *
+     * 
+     * @return number of references post operation
      * @throws NativeWindowException if the native creation failed.
      * @see #removeReference()
      * @see #setDestroyWhenUnused(boolean)
@@ -105,7 +106,8 @@ public abstract class Screen {
 
     /**
      * See {@link Display#removeReference()}
-     *
+     * 
+     * @return number of references post operation
      * @see #addReference()
      * @see #setDestroyWhenUnused(boolean)
      * @see #getDestroyWhenUnused()
-- 
cgit v1.2.3


From 416c7fc1b90cd7b34c251268bb83ebeea61d17d6 Mon Sep 17 00:00:00 2001
From: Sven Gothel 
Date: Fri, 19 Oct 2012 07:46:31 +0200
Subject: NEWT / BCM-VC-IV: Fix transparency according to given capabilities

Tested manual w/ TestGearsES2NEWT on Raspberry Pi
---
 make/scripts/tests.sh                               |  4 ++--
 .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java  | 17 ++++++++---------
 src/newt/native/bcm_vc_iv.c                         | 21 ++++++++++++++++++---
 .../junit/jogl/demos/es2/newt/TestGearsES2NEWT.java |  8 ++++++++
 4 files changed, 36 insertions(+), 14 deletions(-)

(limited to 'src/newt/classes')

diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 6398fa4cc..85b439437 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -245,7 +245,7 @@ function testawtswt() {
 #testnoawt com.jogamp.newt.opengl.GLWindow $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
+testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $*
@@ -405,7 +405,7 @@ function testawtswt() {
 # Misc Utils
 #
 #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $*
-testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $*
 
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java
index 7b8d2e958..21fbea9ac 100644
--- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java
@@ -53,20 +53,19 @@ public class WindowDriver extends WindowImpl {
         if(0!=getParentWindowHandle()) {
             throw new RuntimeException("Window parenting not supported (yet)");
         }
-        // FIXME: Hack - Native BCM_VC_IV code CreateWindow() uses the default alpha value setting,
-        // which is alpha:8 ! Hence we require to chose alpha from the egl configurations.
-        // TODO: Properly select the alpha mode in CreateWindow()! This will allow this hack. 
-        final Capabilities capsChosen = (Capabilities) capsRequested.cloneMutable();
-        capsChosen.setAlphaBits(1);
         
         final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration(
-                capsChosen, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED);
+                capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED);
         if (null == cfg) {
             throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
         }
+        final Capabilities chosenCaps = (Capabilities) cfg.getChosenCapabilities();
+        // FIXME: Pass along opaque flag, since EGL doesn't determine it
+        if(capsRequested.isBackgroundOpaque() != chosenCaps.isBackgroundOpaque()) {
+            chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque());
+        }
         setGraphicsConfiguration(cfg);
-
-        nativeWindowHandle = CreateWindow(getWidth(), getHeight());
+        nativeWindowHandle = CreateWindow(getWidth(), getHeight(), chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits());
         if (nativeWindowHandle == 0) {
             throw new NativeWindowException("Error creating egl window: "+cfg);
         }
@@ -139,7 +138,7 @@ public class WindowDriver extends WindowImpl {
     //
 
     protected static native boolean initIDs();
-    private        native long CreateWindow(int width, int height);
+    private        native long CreateWindow(int width, int height, boolean opaque, int alphaBits);
     private        native long RealizeWindow(long eglWindowHandle);
     private        native int  CloseWindow(long eglWindowHandle, long userData);
     private        native void setVisible0(long eglWindowHandle, boolean visible);
diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c
index e41745e14..0093da437 100644
--- a/src/newt/native/bcm_vc_iv.c
+++ b/src/newt/native/bcm_vc_iv.c
@@ -101,8 +101,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initNative
     if( graphics_get_display_size(0 /* LCD */, &screen_width, &screen_height) >= 0 ) {
         DBG_PRINT( "BCM.Screen initNative ok %dx%d\n", screen_width, screen_height );
         (*env)->CallVoidMethod(env, obj, setScreenSizeID, (jint) screen_width, (jint) screen_height);
+    } else {
+        DBG_PRINT( "BCM.Screen initNative failed\n" );
     }
-    DBG_PRINT( "BCM.Screen initNative failed\n" );
 }
 
 /**
@@ -132,7 +133,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID
 }
 
 JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow
-  (JNIEnv *env, jobject obj, jint width, jint height)
+  (JNIEnv *env, jobject obj, jint width, jint height, jboolean opaque, jint alphaBits)
 {
    int32_t success = 0;
    VC_RECT_T dst_rect;
@@ -148,12 +149,26 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin
    src_rect.width = width << 16;
    src_rect.height = height << 16;   
 
+   VC_DISPMANX_ALPHA_T dispman_alpha;
+   memset(&dispman_alpha, 0x0, sizeof(VC_DISPMANX_ALPHA_T));
+
+   if( JNI_TRUE == opaque ) {
+       dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS ;
+       dispman_alpha.opacity = 0xFF;
+       dispman_alpha.mask = 0;
+   } else {
+       dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE ;
+       dispman_alpha.opacity = 0xFF;
+       dispman_alpha.mask = 0xFF;
+   }
+
    DISPMANX_DISPLAY_HANDLE_T dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
    DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 );
    DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display,
                                                                          0/*layer*/, &dst_rect, 0/*src*/,
                                                                          &src_rect, DISPMANX_PROTECTION_NONE, 
-                                                                         0 /*alpha TODO*/, 0/*clamp*/, 0/*transform*/);
+                                                                         &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/);
+
    EGL_DISPMANX_WINDOW_T * nativeWindowPtr = calloc(1, sizeof(EGL_DISPMANX_WINDOW_T));  
    nativeWindowPtr->element = dispman_element;
    nativeWindowPtr->width = width;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index a79c924d6..1620985c1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
@@ -75,6 +75,7 @@ public class TestGearsES2NEWT extends UITestCase {
 
     static long duration = 500; // ms
     static boolean opaque = true;
+    static int forceAlpha = -1;
     static boolean undecorated = false;
     static boolean alwaysOnTop = false;
     static boolean fullscreen = false;
@@ -257,6 +258,9 @@ public class TestGearsES2NEWT extends UITestCase {
             System.err.println("Loop "+i+"/"+loops);
             GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
             caps.setBackgroundOpaque(opaque);
+            if(-1 < forceAlpha) {
+                caps.setAlphaBits(forceAlpha); 
+            }
             runTestGL(caps, undecorated);
             if(loop_shutdown) {
                 GLProfile.shutdown();
@@ -274,6 +278,9 @@ public class TestGearsES2NEWT extends UITestCase {
                 duration = MiscUtils.atol(args[i], duration);
             } else if(args[i].equals("-translucent")) {
                 opaque = false;
+            } else if(args[i].equals("-forceAlpha")) {
+                i++;
+                forceAlpha = MiscUtils.atoi(args[i], 0);
             } else if(args[i].equals("-undecorated")) {
                 undecorated = true;
             } else if(args[i].equals("-atop")) {
@@ -328,6 +335,7 @@ public class TestGearsES2NEWT extends UITestCase {
         System.err.println("size "+wsize);
         System.err.println("screen "+screenIdx);
         System.err.println("translucent "+(!opaque));
+        System.err.println("forceAlpha "+forceAlpha);        
         System.err.println("undecorated "+undecorated);
         System.err.println("atop "+alwaysOnTop);
         System.err.println("fullscreen "+fullscreen);
-- 
cgit v1.2.3


From b5d42f14e0efdb117da9c5145d807ed0d7631b97 Mon Sep 17 00:00:00 2001
From: Sven Gothel 
Date: Fri, 19 Oct 2012 17:07:36 +0200
Subject: NEWT ScreenMode Change Failover / Window.setFullscreen() shall use
 current ScreenMode rotated resolution.

ScreenMode Change Failover
  - In case a timeout appears (buggy XRandR),
    double check current ScreenMode in case it has been set.

Window.setFullscreen() shall use current ScreenMode rotated resolution.
  - The Screen's virtual size in not correct!
---
 src/newt/classes/jogamp/newt/ScreenImpl.java | 43 +++++++++++++++++++---------
 src/newt/classes/jogamp/newt/WindowImpl.java |  8 ++++--
 2 files changed, 35 insertions(+), 16 deletions(-)

(limited to 'src/newt/classes')

diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index 1cc53e80e..56d6f67ff 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -277,7 +277,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
     protected void updateVirtualScreenOriginAndSize() {
         getVirtualScreenOriginAndSize(vOrigin, vSize);
         if(DEBUG) {
-            System.err.println("Detected screen origin "+vOrigin+", size "+vSize);
+            System.err.println("Detected virtual screen origin "+vOrigin+", size "+vSize);
         }
     }
 
@@ -321,18 +321,24 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
         return null;
     }
 
+    private final ScreenModeStatus getScreenModeStatus(boolean throwException) {
+        final String key = this.getFQName();
+        final ScreenModeStatus res = ScreenModeStatus.getScreenModeStatus(key);
+        if(null == res & throwException) {
+            throw new InternalError("ScreenModeStatus.getScreenModeStatus("+key+") == null");
+        }
+        return res;
+    }
+    
     public ScreenMode getOriginalScreenMode() {
-        ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName());
+        final ScreenModeStatus sms = getScreenModeStatus(false);
         return ( null != sms ) ? sms.getOriginalScreenMode() : null ;
     }
 
     public ScreenMode getCurrentScreenMode() {
         ScreenMode smU = null;
-        ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName());
-        if(null == sms) {
-            throw new InternalError("ScreenModeStatus.getScreenModeStatus("+this.getFQName()+") == null");            
-        }
-        ScreenMode sm0 = getCurrentScreenModeIntern();
+        final ScreenModeStatus sms = getScreenModeStatus(true);
+        final ScreenMode sm0 = getCurrentScreenModeIntern();
         if(null == sm0) {
             throw new InternalError("getCurrentScreenModeImpl() == null");
         }
@@ -378,12 +384,23 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
                 System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): fireScreenModeChangeNotify() "+smU);
             }
 
-            success = setCurrentScreenModeImpl(smU);                                
-            if(DEBUG) {
-                System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+smU+", success: "+success);
+            success = setCurrentScreenModeImpl(smU);
+            if(success) {
+                if(DEBUG) {
+                    System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+smU+", success(1): "+success);
+                }
+            } else {
+                // 2nd attempt validate!
+                final ScreenMode queriedCurrent = getCurrentScreenMode(); // may fireScreenModeChanged(..) if successful and differs!
+                final ScreenMode smsCurrent = sms.getCurrentScreenMode();
+                success = smsCurrent.hashCode() == smU.hashCode() && queriedCurrent.hashCode() == smU.hashCode() ;
+                if(DEBUG) {
+                    System.err.println("Screen.setCurrentScreenMode.2: queried "+queriedCurrent);
+                    System.err.println("Screen.setCurrentScreenMode.2:     SMS "+smsCurrent);
+                    System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+smU+", success(2): "+success);
+                }
             }
-
-            sms.fireScreenModeChanged(smU, success);                            
+            sms.fireScreenModeChanged(smU, success);
             if(DEBUG) {
                 System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): X.X "+smU+", success: "+success);
             }
@@ -482,7 +499,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
             res = getCurrentScreenModeImpl();
         }
         if(null == res) {
-            if( 0==getWidth()*getHeight() ) {
+            if( 0>=getWidth() || 0>=getHeight() ) {
                 updateVirtualScreenOriginAndSize();
             }
             int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL];
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index c94ce286b..8901411a3 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -1711,6 +1711,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                 // set current state
                 WindowImpl.this.fullscreen = fullscreen;
 
+                final ScreenMode sm = screen.getCurrentScreenMode();
                 int x,y,w,h;
                 
                 if(fullscreen) {
@@ -1720,8 +1721,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                     nfs_height = getHeight();
                     x = screen.getX(); 
                     y = screen.getY();
-                    w = screen.getWidth();
-                    h = screen.getHeight();
+                    w = sm.getRotatedWidth();
+                    h = sm.getRotatedHeight();
                 } else {
                     x = nfs_x;
                     y = nfs_y;
@@ -1743,7 +1744,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                     }
                 }
                 if(DEBUG_IMPLEMENTATION) {
-                    System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+", "+screen);
+                    System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+
+                                       ", virtl-size: "+screen.getWidth()+"x"+screen.getHeight()+", SM "+sm.getRotatedWidth()+"x"+sm.getRotatedHeight());
                 }
 
                 DisplayImpl display = (DisplayImpl) screen.getDisplay();
-- 
cgit v1.2.3


From b008de41549e38aebdfcb7b094046235a8dde72f Mon Sep 17 00:00:00 2001
From: Sven Gothel 
Date: Fri, 26 Oct 2012 16:43:13 +0200
Subject: Fix Bug 601 - Auto-Repeat Behavior: Adding unit tests for typed key
 order w/ and w/o auto repeat. Incl. fix for Windows.

Auto-Repeat tests recognizes whether auto-repeat could be triggered by AWT Robot.
The latter is not possible on Windows, hence manual testing was required on this platform.

Impact: X11, Windows and OSX produce proper key sequence incl. auto-repeat modifier mask.
---
 make/scripts/java-win64-dbg.bat                    |   2 +-
 make/scripts/tests-x64.bat                         |   4 +-
 make/scripts/tests.sh                              |   7 +-
 .../classes/com/jogamp/newt/event/KeyEvent.java    |  11 +
 .../classes/com/jogamp/newt/event/NEWTEvent.java   |   6 +-
 .../jogamp/newt/driver/windows/WindowDriver.java   |  82 +++---
 src/newt/native/X11Display.c                       |   2 +
 .../junit/newt/TestKeyEventAutoRepeatNEWT.java     | 309 +++++++++++++++++++++
 .../test/junit/newt/TestKeyEventOrderNEWT.java     | 219 +++++++++++++++
 .../opengl/test/junit/util/AWTFocusAdapter.java    |  11 +-
 .../opengl/test/junit/util/AWTKeyAdapter.java      |  49 +++-
 .../opengl/test/junit/util/AWTMouseAdapter.java    |  27 +-
 .../opengl/test/junit/util/AWTRobotUtil.java       |  51 +++-
 .../test/junit/util/AWTWindowFocusAdapter.java     |  11 +-
 .../opengl/test/junit/util/EventCountAdapter.java  |   9 +
 .../test/junit/util/InputEventCountAdapter.java    |   5 +
 .../test/junit/util/KeyEventCountAdapter.java      |  38 +++
 .../opengl/test/junit/util/NEWTFocusAdapter.java   |  11 +-
 .../opengl/test/junit/util/NEWTKeyAdapter.java     |  64 ++++-
 .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 103 +++++++
 .../opengl/test/junit/util/NEWTMouseAdapter.java   |  28 +-
 21 files changed, 978 insertions(+), 71 deletions(-)
 create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventAutoRepeatNEWT.java
 create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventOrderNEWT.java
 create mode 100644 src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java
 create mode 100644 src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java

(limited to 'src/newt/classes')

diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat
index 07722c78e..5dc34f42d 100755
--- a/make/scripts/java-win64-dbg.bat
+++ b/make/scripts/java-win64-dbg.bat
@@ -39,7 +39,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC
 REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet"
 REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch"
 REM set D_ARGS="-Dnewt.debug.Window"
-set D_ARGS="-Dnewt.debug.Window.KeyEvent"
+REM set D_ARGS="-Dnewt.debug.Window.KeyEvent"
 REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display"
 REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL"
 REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode"
diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat
index 9ffbcd6d3..f67bda373 100755
--- a/make/scripts/tests-x64.bat
+++ b/make/scripts/tests-x64.bat
@@ -19,7 +19,7 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLPro
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %*
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %*
-scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %*
+REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %*
 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0
 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %*
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %*
@@ -32,6 +32,8 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSi
 
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01AWT
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT
+scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT %*
+REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT %*
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %*
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %*
 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %*
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 0d16ec002..047c0ed63 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -65,7 +65,7 @@ function jrun() {
     #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject"
     #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker"
     #D_ARGS="-Djogl.debug.FBObject"
-    #D_ARGS="-Djogl.debug.GLSLCode"
+    #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL"
     #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode"
     #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState"
     #D_ARGS="-Djogl.debug.FixedFuncPipeline"
@@ -265,7 +265,7 @@ function testawtswt() {
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $*
-testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $*
 
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $*
@@ -274,6 +274,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $*
 
 #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $*
 #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
 
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $*
 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $*
@@ -374,6 +375,8 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $*
 #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug
 #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $*
 #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $*
+#testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $*
+testawt com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT $*
 #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT
 #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $*
 #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $*
diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
index 7daaeada6..b6f4264f5 100644
--- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
+++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
@@ -48,6 +48,17 @@ package com.jogamp.newt.event;
  * Besides regular modifiers like {@link InputEvent#SHIFT_MASK} etc., 
  * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected.
  * 

+ *

+ * Auto-Repeat shall behave as follow: + *

+    D = pressed, U = released, T = typed
+    0 = normal, 1 = auto-repeat
+
+    D(0), [ U(1), T(1), D(1), U(1) T(1) ..], U(0) T(0)
+ * 
+ * The idea is if you mask out auto-repeat in your event listener + * you just get one long pressed key D/U/T triple. + *

*/ @SuppressWarnings("serial") public class KeyEvent extends InputEvent diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index fd5b69ccc..9d8d92ff6 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -161,11 +161,7 @@ public class NEWTEvent extends java.util.EventObject { return sb.append("NEWTEvent[sys:").append(isSystemEvent()).append(", source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); } - public static String toHexString(int hex) { + 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/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 71437c461..c211bac61 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -279,61 +279,73 @@ public class WindowDriver extends WindowImpl { return keyCode; } private int lastPressedKeyCode = 0; + private char lastTypedKeyChar = 0; private int pressedKeyBalance = 0; private int autoRepeat = 0; - @Override - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { + private final void emitKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + if( send ) { + super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + } else { + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); + } + } + + private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", mods "+toHexString(modifiers)); + // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform keyCode = validateKeyCode(eventType, modifiers, keyCode, keyChar); + + // Reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED + // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: - // reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED + if( 0 != autoRepeat ) { + // AR out - send out missing PRESSED + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | autoRepeat, keyCode, lastTypedKeyChar); + } + autoRepeat = 0; + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + if( 0 != lastTypedKeyChar ) { + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, lastTypedKeyChar); + lastTypedKeyChar = 0; + } break; case KeyEvent.EVENT_KEY_PRESSED: - if(pressedKeyBalance > 1) { - // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. - // Since reordering already injects RELEASE, we only need to set the AUTOREPEAT_MASK. + if( pressedKeyBalance > 1 ) { pressedKeyBalance--; - autoRepeat |= InputEvent.AUTOREPEAT_MASK; + if ( 0 == autoRepeat ) { + // AR in - skip already send PRESSED + autoRepeat = InputEvent.AUTOREPEAT_MASK; + } else { + emitKeyEvent(send, wait, eventType, modifiers | autoRepeat, keyCode, (char)-1); + } } else { - autoRepeat &= ~InputEvent.AUTOREPEAT_MASK; + autoRepeat = 0; + emitKeyEvent(send, wait, eventType, modifiers, keyCode, (char)-1); } - super.sendKeyEvent(eventType, modifiers | autoRepeat, keyCode, (char)-1); break; case KeyEvent.EVENT_KEY_TYPED: - modifiers |= autoRepeat; - super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); - super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + if( 0 == autoRepeat ) { + lastTypedKeyChar = keyChar; + } else { + modifiers |= autoRepeat; + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + } break; } } + @Override + public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { + handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); + } + @Override public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform - keyCode = validateKeyCode(eventType, modifiers, keyCode, keyChar); - switch(eventType) { - case KeyEvent.EVENT_KEY_RELEASED: - // reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED - break; - case KeyEvent.EVENT_KEY_PRESSED: - if(pressedKeyBalance > 1) { - // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. - // Since reordering already injects RELEASE, we only need to set the AUTOREPEAT_MASK. - pressedKeyBalance--; - autoRepeat |= InputEvent.AUTOREPEAT_MASK; - } else { - autoRepeat &= ~InputEvent.AUTOREPEAT_MASK; - } - super.enqueueKeyEvent(wait, eventType, modifiers | autoRepeat, keyCode, (char)-1); - break; - case KeyEvent.EVENT_KEY_TYPED: - modifiers |= autoRepeat; - super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); - break; - } + handleKeyEvent(false, wait, eventType, modifiers, keyCode, keyChar); } //---------------------------------------------------------------------- diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index d8202fcde..9f29acc0c 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -381,6 +381,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage } else { autoRepeatModifiers &= ~EVENT_AUTOREPEAT_MASK; } + } else { + autoRepeatModifiers &= ~EVENT_AUTOREPEAT_MASK; } // fall through intended case KeyPress: diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventAutoRepeatNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventAutoRepeatNEWT.java new file mode 100644 index 000000000..22c362dd8 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventAutoRepeatNEWT.java @@ -0,0 +1,309 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + +import org.junit.After; +import org.junit.Assert; +import org.junit.AfterClass; +import org.junit.Assume; +import org.junit.Before; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Robot; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.EventObject; +import java.util.List; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.swing.JFrame; + +import java.io.IOException; + +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.event.InputEvent; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; + +import com.jogamp.opengl.test.junit.util.*; + +/** + * Testing key event order incl. auto-repeat (Bug 601) + * + *

+ * Note Event order: + *

    + *
  1. {@link #EVENT_KEY_PRESSED}
  2. + *
  3. {@link #EVENT_KEY_RELEASED}
  4. + *
  5. {@link #EVENT_KEY_TYPED}
  6. + *
+ *

+ *

+ * Auto-Repeat shall behave as follow: + *

+    D = pressed, U = released, T = typed
+    0 = normal, 1 = auto-repeat
+
+    D(0), [ U(1), T(1), D(1), U(1) T(1) ..], U(0) T(0)
+ * 
+ * + * The idea is if you mask out auto-repeat in your event listener + * you just get one long pressed key D/U/T triple. + */ +public class TestKeyEventAutoRepeatNEWT extends UITestCase { + static int width, height; + static long durationPerTest = 100; + static long awtWaitTimeout = 1000; + + static GLCapabilities glCaps; + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glCaps = new GLCapabilities(null); + } + + @AfterClass + public static void release() { + } + + @Before + public void initTest() { + } + + @After + public void releaseTest() { + } + + @Test + public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException { + GLWindow glWindow = GLWindow.create(glCaps); + glWindow.setSize(width, height); + glWindow.setVisible(true); + + testImpl(glWindow); + + glWindow.destroy(); + } + + @Test + public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { + GLWindow glWindow = GLWindow.create(glCaps); + + // Wrap the window in a canvas. + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); + + // Add the canvas to a frame, and make it all visible. + final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); + frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); + frame1.setSize(width, height); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + } } ); + + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); + + testImpl(glWindow); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(false); + frame1.dispose(); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + glWindow.destroy(); + } + + static void testKeyEventAutoRepeat(Robot robot, NEWTKeyAdapter keyAdapter, int loops, int pressDurationMS) { + System.err.println("KEY Event Auto-Repeat Test: "+loops); + EventObject[][] first = new EventObject[loops][3]; + EventObject[][] last = new EventObject[loops][3]; + + keyAdapter.reset(); + final List keyEvents = keyAdapter.getQueued(); + int firstIdx = 0; + for(int i=0; i + * Note Event order: + *
    + *
  1. {@link #EVENT_KEY_PRESSED}
  2. + *
  3. {@link #EVENT_KEY_RELEASED}
  4. + *
  5. {@link #EVENT_KEY_TYPED}
  6. + *
+ *

+ */ +public class TestKeyEventOrderNEWT extends UITestCase { + static int width, height; + static long durationPerTest = 100; + static long awtWaitTimeout = 1000; + + static GLCapabilities glCaps; + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glCaps = new GLCapabilities(null); + } + + @AfterClass + public static void release() { + } + + @Before + public void initTest() { + } + + @After + public void releaseTest() { + } + + @Test + public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException { + GLWindow glWindow = GLWindow.create(glCaps); + glWindow.setSize(width, height); + glWindow.setVisible(true); + + testImpl(glWindow); + + glWindow.destroy(); + } + + @Test + public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { + GLWindow glWindow = GLWindow.create(glCaps); + + // Wrap the window in a canvas. + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); + + // Add the canvas to a frame, and make it all visible. + final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); + frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); + frame1.setSize(width, height); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + } } ); + + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); + + testImpl(glWindow); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(false); + frame1.dispose(); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + glWindow.destroy(); + } + + static void testKeyEventOrder(Robot robot, NEWTKeyAdapter keyAdapter, int loops) { + System.err.println("KEY Event Order Test: "+loops); + keyAdapter.reset(); + for(int i=0; i0) { focusCount=0; } focusCount--; wasTemporary = e.isTemporary(); - System.err.println("FOCUS AWT LOST "+(wasTemporary?"TEMP":"PERM")+" [fc "+focusCount+"]: "+prefix+", "+e); + if( verbose ) { + System.err.println("FOCUS AWT LOST "+(wasTemporary?"TEMP":"PERM")+" [fc "+focusCount+"]: "+prefix+", "+e); + } } public String toString() { return prefix+"[focusCount "+focusCount +", temp "+wasTemporary+"]"; } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java index 6c0156170..a9fa373b5 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java @@ -29,18 +29,25 @@ package com.jogamp.opengl.test.junit.util; import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; -public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements InputEventCountAdapter { +public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEventCountAdapter { String prefix; - int keyTyped; + int keyPressed, keyReleased, keyTyped; boolean pressed; + List queue = new ArrayList(); + boolean verbose = true; public AWTKeyAdapter(String prefix) { this.prefix = prefix; reset(); } + public void setVerbose(boolean v) { verbose = false; } + public boolean isPressed() { return pressed; } @@ -49,24 +56,54 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements InputEve return keyTyped; } + public int getKeyPressedCount(boolean autoRepeatOnly) { + return keyPressed; + } + + public int getKeyReleasedCount(boolean autoRepeatOnly) { + return keyReleased; + } + + public int getKeyTypedCount(boolean autoRepeatOnly) { + return keyTyped; + } + + public List getQueued() { + return queue; + } + public void reset() { keyTyped = 0; + keyPressed = 0; + keyReleased = 0; pressed = false; + queue.clear(); } public void keyPressed(KeyEvent e) { pressed = true; - System.err.println("KEY AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + keyPressed++; + queue.add(e); + if( verbose ) { + System.err.println("KEY AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + } } public void keyReleased(KeyEvent e) { pressed = false; - System.err.println("KEY AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + keyReleased++; + queue.add(e); + if( verbose ) { + System.err.println("KEY AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + } } public void keyTyped(java.awt.event.KeyEvent e) { - ++keyTyped; - System.err.println("KEY AWT TYPED ["+keyTyped+"]: "+prefix+", "+e); + keyTyped++; + queue.add(e); + if( verbose ) { + System.err.println("KEY AWT TYPED ["+keyTyped+"]: "+prefix+", "+e); + } } public String toString() { return prefix+"[pressed "+pressed+", typed "+keyTyped+"]"; } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java index b94802348..3334f18ea 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java @@ -29,17 +29,24 @@ package com.jogamp.opengl.test.junit.util; import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements InputEventCountAdapter { String prefix; int mouseClicked; boolean pressed; + List queue = new ArrayList(); + boolean verbose = true; public AWTMouseAdapter(String prefix) { this.prefix = prefix; reset(); } + public void setVerbose(boolean v) { verbose = false; } + public boolean isPressed() { return pressed; } @@ -48,24 +55,38 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu return mouseClicked; } + public List getQueued() { + return queue; + } + public void reset() { mouseClicked = 0; pressed = false; + queue.clear(); } public void mousePressed(MouseEvent e) { pressed = true; - System.err.println("MOUSE AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + queue.add(e); + if( verbose ) { + System.err.println("MOUSE AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + } } public void mouseReleased(MouseEvent e) { pressed = false; - System.err.println("MOUSE AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + queue.add(e); + if( verbose ) { + System.err.println("MOUSE AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + } } public void mouseClicked(java.awt.event.MouseEvent e) { mouseClicked+=e.getClickCount(); - System.err.println("MOUSE AWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e); + queue.add(e); + if( verbose ) { + System.err.println("MOUSE AWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e); + } } public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+"]"; } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index 160653cd5..06e172a5d 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -312,7 +312,7 @@ public class AWTRobotUtil { } if(!hasFocus) { System.err.print("*** AWTRobotUtil.assertRequestFocusAndWait() "); - if(gain.focusGained() && !lost.focusLost()) { + if( ( null == gain || gain.focusGained() ) && ( null == lost || !lost.focusLost() ) ) { // be error tolerant here, some impl. may lack focus-lost events (OS X) System.err.println("minor UI failure"); hasFocus = true; @@ -337,7 +337,7 @@ public class AWTRobotUtil { } public static int keyType(int i, Robot robot, int keyCode, - Object obj, InputEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException + Object obj, KeyEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException { int tc = 0; int j; @@ -365,13 +365,26 @@ public class AWTRobotUtil { Assert.assertEquals("Key ("+i+":"+j+") not typed one time", 1, tc); return (int) ( System.currentTimeMillis() - t0 ) ; } + + /** No validation is performed .. */ + public static int keyPress(int i, Robot robot, boolean press, int keyCode, int msDelay) { + final long t0 = System.currentTimeMillis(); + if(press) { + robot.keyPress(keyCode); + } else { + robot.keyRelease(keyCode); + } + robot.delay(msDelay); + + return (int) ( System.currentTimeMillis() - t0 ) ; + } /** * @param keyCode TODO * @param counter shall return the number of keys typed (press + release) */ public static void assertKeyType(Robot robot, int keyCode, int typeCount, - Object obj, InputEventCountAdapter counter) + Object obj, KeyEventCountAdapter counter) throws AWTException, InterruptedException, InvocationTargetException { if(null == robot) { @@ -398,6 +411,38 @@ public class AWTRobotUtil { Assert.assertEquals("Wrong key count", typeCount, counter.getCount()-c0); } + /** + * @param keyCode TODO + * @param counter shall return the number of keys typed (press + release) + */ + public static void assertKeyPress(Robot robot, int keyCode, int typeCount, + Object obj, KeyEventCountAdapter counter) + throws AWTException, InterruptedException, InvocationTargetException { + + if(null == robot) { + robot = new Robot(); + robot.setAutoWaitForIdle(true); + } + + centerMouse(robot, obj, false); + + Assert.assertEquals("Key already pressed", false, counter.isPressed()); + + if(DEBUG) { + System.err.println("**************************************"); + System.err.println("KC0: "+counter); + } + + final int c0 = counter.getCount(); + + for(int i=0; i0) { focusCount=0; } focusCount--; - System.err.println("FOCUS AWT LOST (Window) [fc "+focusCount+"]: "+prefix+", "+e); + if( verbose ) { + System.err.println("FOCUS AWT LOST (Window) [fc "+focusCount+"]: "+prefix+", "+e); + } } public String toString() { return prefix+"[focusCount "+focusCount +"]"; } diff --git a/src/test/com/jogamp/opengl/test/junit/util/EventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/EventCountAdapter.java index 76a1884c8..906e4a7c9 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/EventCountAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/EventCountAdapter.java @@ -28,7 +28,16 @@ package com.jogamp.opengl.test.junit.util; +/** + * Base event count adapter. + *

+ * Instance starts in verbose mode. + *

+ */ public interface EventCountAdapter { void reset(); + + /** Instance starts in verbose mode, call w/ false to disable verbosity. */ + void setVerbose(boolean v); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java index 27f3d7e29..ed7485951 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java @@ -28,8 +28,13 @@ package com.jogamp.opengl.test.junit.util; +import java.util.EventObject; +import java.util.List; + public interface InputEventCountAdapter extends EventCountAdapter { int getCount(); boolean isPressed(); + + public List getQueued(); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java new file mode 100644 index 000000000..832f5ae82 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java @@ -0,0 +1,38 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.util; + +public interface KeyEventCountAdapter extends InputEventCountAdapter { + public int getKeyPressedCount(boolean autoRepeatOnly); + + public int getKeyReleasedCount(boolean autoRepeatOnly); + + public int getKeyTypedCount(boolean autoRepeatOnly); +} + diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java index 27d4abd9c..ccb1bde78 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java @@ -36,12 +36,15 @@ public class NEWTFocusAdapter implements WindowListener, FocusEventCountAdapter String prefix; int focusCount; + boolean verbose = true; public NEWTFocusAdapter(String prefix) { this.prefix = prefix; reset(); } + public void setVerbose(boolean v) { verbose = false; } + public boolean focusLost() { return focusCount<0; } @@ -57,13 +60,17 @@ public class NEWTFocusAdapter implements WindowListener, FocusEventCountAdapter public void windowGainedFocus(WindowEvent e) { if(focusCount<0) { focusCount=0; } focusCount++; - System.err.println("FOCUS NEWT GAINED [fc "+focusCount+"]: "+prefix+", "+e); + if( verbose ) { + System.err.println("FOCUS NEWT GAINED [fc "+focusCount+"]: "+prefix+", "+e); + } } public void windowLostFocus(WindowEvent e) { if(focusCount>0) { focusCount=0; } focusCount--; - System.err.println("FOCUS NEWT LOST [fc "+focusCount+"]: "+prefix+", "+e); + if( verbose ) { + System.err.println("FOCUS NEWT LOST [fc "+focusCount+"]: "+prefix+", "+e); + } } public void windowResized(WindowEvent e) { } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java index 32b392ca8..42235254a 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java @@ -28,19 +28,29 @@ package com.jogamp.opengl.test.junit.util; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; + +import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; -public class NEWTKeyAdapter extends KeyAdapter implements InputEventCountAdapter { +public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { String prefix; - int keyTyped; + int keyPressed, keyReleased, keyTyped; + int keyPressedAR, keyReleasedAR, keyTypedAR; boolean pressed; + List queue = new ArrayList(); + boolean verbose = true; public NEWTKeyAdapter(String prefix) { this.prefix = prefix; reset(); } + + public void setVerbose(boolean v) { verbose = false; } public boolean isPressed() { return pressed; @@ -50,25 +60,67 @@ public class NEWTKeyAdapter extends KeyAdapter implements InputEventCountAdapter return keyTyped; } + public int getKeyPressedCount(boolean autoRepeatOnly) { + return autoRepeatOnly ? keyPressedAR: keyPressed; + } + + public int getKeyReleasedCount(boolean autoRepeatOnly) { + return autoRepeatOnly ? keyReleasedAR: keyReleased; + } + + public int getKeyTypedCount(boolean autoRepeatOnly) { + return autoRepeatOnly ? keyTypedAR: keyTyped; + } + + public List getQueued() { + return queue; + } + public void reset() { keyTyped = 0; + keyPressed = 0; + keyReleased = 0; + keyTypedAR = 0; + keyPressedAR = 0; + keyReleasedAR = 0; pressed = false; + queue.clear(); } public void keyPressed(KeyEvent e) { pressed = true; - System.err.println("NEWT AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + keyPressed++; + if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { + keyPressedAR++; + } + queue.add(e); + if( verbose ) { + System.err.println("NEWT AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + } } public void keyReleased(KeyEvent e) { pressed = false; - System.err.println("NEWT AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + keyReleased++; + if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { + keyReleasedAR++; + } + queue.add(e); + if( verbose ) { + System.err.println("NEWT AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + } } @Override public void keyTyped(KeyEvent e) { - ++keyTyped; - System.err.println("KEY NEWT TYPED ["+keyTyped+"]: "+prefix+", "+e); + keyTyped++; + if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { + keyTypedAR++; + } + queue.add(e); + if( verbose ) { + System.err.println("KEY NEWT TYPED ["+keyTyped+"]: "+prefix+", "+e); + } } public String toString() { return prefix+"[pressed "+pressed+", typed "+keyTyped+"]"; } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java new file mode 100644 index 000000000..dfc96edcb --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java @@ -0,0 +1,103 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.util; + +import java.util.EventObject; +import java.util.List; + +import org.junit.Assert; + +import com.jogamp.newt.event.KeyEvent; + +public class NEWTKeyUtil { + public static void dumpKeyEvents(List keyEvents) { + for(int i=0; i keyEvents) { + int eet = KeyEvent.EVENT_KEY_PRESSED; + for(int i=0; i keyEvents = keyAdapter.getQueued(); + Assert.assertEquals("Key event count not multiple of 3", 0, keyEvents.size()%3); + Assert.assertEquals("Key event count not 3 * press_release_count", 3*expTotalCount, keyEvents.size()); + Assert.assertEquals("Key press count failure", expTotalCount, keyPressed); + Assert.assertEquals("Key press count failure (AR)", expARCount, keyPressedAR); + Assert.assertEquals("Key released count failure", expTotalCount, keyReleased); + Assert.assertEquals("Key released count failure (AR)", expARCount, keyReleasedAR); + Assert.assertEquals("Key typed count failure", expTotalCount, keyTyped); + Assert.assertEquals("Key typed count failure (AR)", expARCount, keyTypedAR); + + // should be true - always, reaching this point - duh! + Assert.assertEquals(expTotalCount-expARCount, keyPressedNR); + Assert.assertEquals(expTotalCount-expARCount, keyReleasedNR); + Assert.assertEquals(expTotalCount-expARCount, keyTypedNR); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java index d98b9ca74..c77462884 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java @@ -28,6 +28,10 @@ package com.jogamp.opengl.test.junit.util; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; + import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; @@ -36,12 +40,16 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda String prefix; int mouseClicked; boolean pressed; + List queue = new ArrayList(); + boolean verbose = true; public NEWTMouseAdapter(String prefix) { this.prefix = prefix; reset(); } + public void setVerbose(boolean v) { verbose = false; } + public boolean isPressed() { return pressed; } @@ -50,24 +58,38 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda return mouseClicked; } + public List getQueued() { + return queue; + } + public void reset() { mouseClicked = 0; pressed = false; + queue.clear(); } public void mousePressed(MouseEvent e) { pressed = true; - System.err.println("MOUSE NEWT PRESSED ["+pressed+"]: "+prefix+", "+e); + queue.add(e); + if( verbose ) { + System.err.println("MOUSE NEWT PRESSED ["+pressed+"]: "+prefix+", "+e); + } } public void mouseReleased(MouseEvent e) { pressed = false; - System.err.println("MOUSE NEWT RELEASED ["+pressed+"]: "+prefix+", "+e); + queue.add(e); + if( verbose ) { + System.err.println("MOUSE NEWT RELEASED ["+pressed+"]: "+prefix+", "+e); + } } public void mouseClicked(MouseEvent e) { mouseClicked+=e.getClickCount(); - System.err.println("MOUSE NEWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e); + queue.add(e); + if( verbose ) { + System.err.println("MOUSE NEWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e); + } } public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+"]"; } -- cgit v1.2.3 From cb32db97634ba10961632a365c1256a8b3472112 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 26 Oct 2012 20:59:53 +0200 Subject: NEWT KeyEvent: Fix intendation --- .../classes/com/jogamp/newt/event/KeyEvent.java | 238 ++++++++++----------- 1 file changed, 119 insertions(+), 119 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index b6f4264f5..ee375d674 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -63,89 +63,89 @@ package com.jogamp.newt.event; @SuppressWarnings("serial") public class KeyEvent extends InputEvent { - public KeyEvent(int eventType, Object source, long when, int modifiers, int keyCode, char keyChar) { - super(eventType, source, when, modifiers); - this.keyCode=keyCode; - this.keyChar=keyChar; - } - - /** Only valid on all platforms at {@link KeyListener#keyTyped(KeyEvent)} */ - public char getKeyChar() { - return keyChar; - } - - /** Always valid. */ - public int getKeyCode() { - return keyCode; - } - - public String toString() { - return toString(null).toString(); - } - - public StringBuilder toString(StringBuilder sb) { - if(null == sb) { - sb = new StringBuilder(); - } - sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(keyCode).append("(").append(toHexString(keyCode)).append("), char '").append(keyChar).append("' (").append(toHexString((int)keyChar)).append("), isActionKey ").append(isActionKey()).append(", "); - return super.toString(sb).append("]"); - } - - public static String getEventTypeString(int type) { - switch(type) { + public KeyEvent(int eventType, Object source, long when, int modifiers, int keyCode, char keyChar) { + super(eventType, source, when, modifiers); + this.keyCode=keyCode; + this.keyChar=keyChar; + } + + /** Only valid on all platforms at {@link KeyListener#keyTyped(KeyEvent)} */ + public char getKeyChar() { + return keyChar; + } + + /** Always valid. */ + public int getKeyCode() { + return keyCode; + } + + public String toString() { + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(keyCode).append("(").append(toHexString(keyCode)).append("), char '").append(keyChar).append("' (").append(toHexString((int)keyChar)).append("), isActionKey ").append(isActionKey()).append(", "); + return super.toString(sb).append("]"); + } + + 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; + + 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; } - return false; - } private final int keyCode; private final char keyChar; @@ -358,73 +358,73 @@ public class KeyEvent extends InputEvent */ /* 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; @@ -460,7 +460,7 @@ public class KeyEvent extends InputEvent * @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; @@ -516,73 +516,73 @@ public class KeyEvent extends InputEvent * @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. @@ -590,18 +590,18 @@ public class KeyEvent extends InputEvent * @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; @@ -609,7 +609,7 @@ public class KeyEvent extends InputEvent /** 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; @@ -631,63 +631,63 @@ public class KeyEvent extends InputEvent */ /* 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. @@ -695,7 +695,7 @@ public class KeyEvent extends InputEvent */ /* 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. @@ -703,7 +703,7 @@ public class KeyEvent extends InputEvent */ /* 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. @@ -744,13 +744,13 @@ public class KeyEvent extends InputEvent 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 -- cgit v1.2.3 From b8588b12e65ee47b5a74d75ea420a5252e0d93bb Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 26 Oct 2012 21:07:32 +0200 Subject: NEWT KeyEvent: Remove invalid version remarks. --- .../classes/com/jogamp/newt/event/KeyEvent.java | 116 +++++++-------------- 1 file changed, 35 insertions(+), 81 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index ee375d674..a8ac70b4d 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -354,74 +354,73 @@ public class KeyEvent extends InputEvent /** * Constant for the F13 function key. - * @since 1.2 + *

F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

*/ - /* 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 + *

F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

*/ public static final int VK_F14 = 0xF001; /** * Constant for the F15 function key. - * @since 1.2 + *

F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

*/ public static final int VK_F15 = 0xF002; /** * Constant for the F16 function key. - * @since 1.2 + *

F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

*/ public static final int VK_F16 = 0xF003; /** * Constant for the F17 function key. - * @since 1.2 + *

F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

*/ public static final int VK_F17 = 0xF004; /** * Constant for the F18 function key. - * @since 1.2 + *

F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

*/ public static final int VK_F18 = 0xF005; /** * Constant for the F19 function key. - * @since 1.2 + *

F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

*/ public static final int VK_F19 = 0xF006; /** * Constant for the F20 function key. - * @since 1.2 + *

F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

*/ public static final int VK_F20 = 0xF007; /** * Constant for the F21 function key. - * @since 1.2 + *

F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

*/ public static final int VK_F21 = 0xF008; /** * Constant for the F22 function key. - * @since 1.2 + *

F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

*/ public static final int VK_F22 = 0xF009; /** * Constant for the F23 function key. - * @since 1.2 + *

F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

*/ public static final int VK_F23 = 0xF00A; /** * Constant for the F24 function key. - * @since 1.2 + *

F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

*/ public static final int VK_F24 = 0xF00B; @@ -436,164 +435,144 @@ public class KeyEvent extends InputEvent /** * 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 */ + /** For European keyboards */ public static final int VK_DEAD_GRAVE = 0x80; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_ACUTE = 0x81; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_CIRCUMFLEX = 0x82; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_TILDE = 0x83; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_MACRON = 0x84; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_BREVE = 0x85; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_ABOVEDOT = 0x86; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_DIAERESIS = 0x87; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_ABOVERING = 0x88; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_DOUBLEACUTE = 0x89; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_CARON = 0x8a; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_CEDILLA = 0x8b; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_OGONEK = 0x8c; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_IOTA = 0x8d; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_VOICED_SOUND = 0x8e; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_DEAD_SEMIVOICED_SOUND = 0x8f; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_AMPERSAND = 0x96; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_ASTERISK = 0x97; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_QUOTEDBL = 0x98; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_LESS = 0x99; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_GREATER = 0xa0; - /** @since 1.2 */ + /** For European keyboards */ public static final int VK_BRACELEFT = 0xa1; - /** @since 1.2 */ + /** For European keyboards */ 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; @@ -627,63 +606,54 @@ public class KeyEvent extends InputEvent /** * 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; @@ -691,7 +661,6 @@ public class KeyEvent extends InputEvent /** * 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; @@ -699,7 +668,6 @@ public class KeyEvent extends InputEvent /** * 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; @@ -707,7 +675,6 @@ public class KeyEvent extends InputEvent /** * 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; @@ -715,51 +682,38 @@ public class KeyEvent extends InputEvent /** * 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; -- cgit v1.2.3 From 2f9c77a347b76bebdadd4bec1ac92aa7ab72365f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 27 Oct 2012 02:48:43 +0200 Subject: Fix Bug 631 and enhance 601: Handle multiple keys (pressed, released, types incl. auto-repeat) - Using keyCode (bit) maps to isPressed and isAutoRepeat, allowing use of multiple keys - Enhance unit test TestKeyEventOrderNEWT w/ injecting variations of 2 diff. keys - Manual tested on X11, Windows and OSX w/ and w/o auto-repeat --- make/scripts/tests-x64.bat | 1 + make/scripts/tests.sh | 5 +- src/newt/classes/jogamp/newt/WindowImpl.java | 25 +++ .../jogamp/newt/driver/macosx/WindowDriver.java | 100 ++++------ .../jogamp/newt/driver/windows/WindowDriver.java | 75 +++---- .../test/junit/newt/TestKeyEventOrderNEWT.java | 22 +- .../newt/TestKeyPressReleaseUnmaskRepeatNEWT.java | 222 +++++++++++++++++++++ .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 8 +- 8 files changed, 350 insertions(+), 108 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestKeyPressReleaseUnmaskRepeatNEWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index f67bda373..21e303dc2 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -34,6 +34,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 047c0ed63..734fa671f 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -375,8 +375,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* -testawt com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT $* +testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 8901411a3..311ed0bbb 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -37,6 +37,7 @@ package jogamp.newt; import java.util.ArrayList; import java.lang.reflect.Method; +import com.jogamp.common.util.IntBitfield; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Display; @@ -2169,6 +2170,30 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // KeyListener/Event Support // + protected IntBitfield keyPressedState = new IntBitfield(KeyEvent.VK_CONTEXT_MENU+1); + protected IntBitfield keyRepeatState = new IntBitfield(KeyEvent.VK_CONTEXT_MENU+1); + + /** + * @param keyCode + * @return 1 if pressed, 0 if not pressed, -1 if not handled. + */ + protected final int isKeyPressed(int keyCode) { + if( 0 <= keyCode && keyCode < keyPressedState.capacity() ) { + return keyPressedState.get(keyCode) ? 1 : 0; + } + return -1; + } + /** + * @param keyCode + * @return 1 if pressed, 0 if not pressed, -1 if not handled. + */ + protected final int isKeyInAutoRepeat(int keyCode) { + if( 0 <= keyCode && keyCode < keyRepeatState.capacity() ) { + return keyRepeatState.get(keyCode) ? 1 : 0; + } + return -1; + } + public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) ); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 4eeafb244..bcdd6b9df 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -306,74 +306,60 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } // else may need offscreen solution ? FIXME } - @Override - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - // Note that we send the key char for the key code on this - // platform -- we do not get any useful key codes out of the system - final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar); - final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); - if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); - if(valid) { - if(pressedKeyBalance > 1) { - // Auto-Repeat: OSX delivers only PRESSED - // inject auto-repeat RELEASE and TYPED keys _before_ - pressedKeyBalance--; - modifiers |= InputEvent.AUTOREPEAT_MASK; - super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED - super.sendKeyEvent(KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED - } - // only deliver keyChar on key Typed events, harmonizing platform behavior - keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; - super.sendKeyEvent(eventType, modifiers, keyCode2, keyChar); + private final void emitKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + if( send ) { + super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + } else { + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); } } - - @Override - public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + + private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { // Note that we send the key char for the key code on this // platform -- we do not get any useful key codes out of the system - final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar); - final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); - if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); - if(valid) { - if(pressedKeyBalance > 1) { - // Auto-Repeat: OSX delivers only PRESSED - // inject auto-repeat RELEASE and TYPED keys _before_ - pressedKeyBalance--; - modifiers |= InputEvent.AUTOREPEAT_MASK; - super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED - super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED - } - // only deliver keyChar on key Typed events, harmonizing platform behavior - keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode2, keyChar); + keyCode = MacKeyUtil.validateKeyCode(keyCode, keyChar); + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode)); } - } - - private int keyDownModifiers = 0; - private int keyDownCode = 0; - private int pressedKeyBalance = 0; - - private boolean validateKeyEvent(int eventType, int modifiers, int keyCode) { + // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED switch(eventType) { - case KeyEvent.EVENT_KEY_PRESSED: - pressedKeyBalance++; - keyDownModifiers = modifiers; - keyDownCode = keyCode; - return true; case KeyEvent.EVENT_KEY_RELEASED: - pressedKeyBalance--; - return keyDownModifiers == modifiers && keyDownCode == keyCode; + if( 1 == isKeyInAutoRepeat(keyCode) ) { + // AR out + keyRepeatState.put(keyCode, false); + } + keyPressedState.put(keyCode, false); + keyChar = (char)-1; + break; + case KeyEvent.EVENT_KEY_PRESSED: + if( 1 == isKeyPressed(keyCode) ) { + if( 0 == isKeyInAutoRepeat(keyCode) ) { + // AR in + keyRepeatState.put(keyCode, true); + } + modifiers |= InputEvent.AUTOREPEAT_MASK; + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED + } else { + keyPressedState.put(keyCode, true); + } + keyChar = (char)-1; + break; case KeyEvent.EVENT_KEY_TYPED: - final boolean matchKeyDown = keyDownModifiers == modifiers && keyDownCode == keyCode; - keyDownModifiers = 0; - keyDownCode = 0; - return matchKeyDown; - default: - throw new NativeWindowException("Unexpected key event type " + eventType); + break; } + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + } + + @Override + public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { + handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); } + @Override + public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + handleKeyEvent(false, wait, eventType, modifiers, keyCode, keyChar); + } //---------------------------------------------------------------------- // Internals only diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index c211bac61..be9f6603e 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; @@ -259,29 +260,10 @@ public class WindowDriver extends WindowImpl { // nop - using event driven insetsChange(..) } - private final int validateKeyCode(int eventType, int modifiers, int keyCode, char keyChar) { - switch(eventType) { - case KeyEvent.EVENT_KEY_RELEASED: - pressedKeyBalance--; - lastPressedKeyCode = keyCode; - break; - case KeyEvent.EVENT_KEY_PRESSED: - pressedKeyBalance++; - lastPressedKeyCode = keyCode; - break; - case KeyEvent.EVENT_KEY_TYPED: - if(-1==keyCode) { - keyCode = lastPressedKeyCode; - } - lastPressedKeyCode = -1; - break; - } - return keyCode; - } + /** We have to regenerate the keyCode for EVENT_KEY_TYPED on this platform. */ private int lastPressedKeyCode = 0; - private char lastTypedKeyChar = 0; - private int pressedKeyBalance = 0; - private int autoRepeat = 0; + /** We have to reorder the native key events to match NEWT's order */ + private IntIntHashMap typedKeyCode2KeyChar = new IntIntHashMap(KeyEvent.VK_CONTEXT_MENU+1); private final void emitKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { if( send ) { @@ -292,47 +274,50 @@ public class WindowDriver extends WindowImpl { } private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", mods "+toHexString(modifiers)); - - // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform - keyCode = validateKeyCode(eventType, modifiers, keyCode, keyChar); - + // final int kc = 0 <= keyCode ? keyCode : lastPressedKeyCode; + // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", key "+toHexString(kc)+", mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(kc)+", repeat "+isKeyInAutoRepeat(kc)); + // Reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED - // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. + // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: - if( 0 != autoRepeat ) { + if( 1 == isKeyInAutoRepeat(keyCode) ) { // AR out - send out missing PRESSED - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | autoRepeat, keyCode, lastTypedKeyChar); + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); + keyRepeatState.put(keyCode, false); } - autoRepeat = 0; - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); - if( 0 != lastTypedKeyChar ) { + keyPressedState.put(keyCode, false); + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + final char lastTypedKeyChar = (char) typedKeyCode2KeyChar.put(keyCode, 0); + if( 0 < lastTypedKeyChar ) { emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, lastTypedKeyChar); - lastTypedKeyChar = 0; } break; case KeyEvent.EVENT_KEY_PRESSED: - if( pressedKeyBalance > 1 ) { - pressedKeyBalance--; - if ( 0 == autoRepeat ) { + lastPressedKeyCode = keyCode; + if( 1 == isKeyPressed(keyCode) ) { + if( 0 == isKeyInAutoRepeat(keyCode) ) { // AR in - skip already send PRESSED - autoRepeat = InputEvent.AUTOREPEAT_MASK; + keyRepeatState.put(keyCode, true); } else { - emitKeyEvent(send, wait, eventType, modifiers | autoRepeat, keyCode, (char)-1); + emitKeyEvent(send, wait, eventType, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); } } else { - autoRepeat = 0; + keyPressedState.put(keyCode, true); emitKeyEvent(send, wait, eventType, modifiers, keyCode, (char)-1); } break; case KeyEvent.EVENT_KEY_TYPED: - if( 0 == autoRepeat ) { - lastTypedKeyChar = keyChar; - } else { - modifiers |= autoRepeat; + if(-1==keyCode) { + keyCode = lastPressedKeyCode; + } + lastPressedKeyCode = -1; + if( 1 == isKeyInAutoRepeat(keyCode) ) { + modifiers |= InputEvent.AUTOREPEAT_MASK; emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + } else { + typedKeyCode2KeyChar.put(keyCode, keyChar); } break; } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventOrderNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventOrderNEWT.java index e0c3005a2..31d9912d1 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventOrderNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventOrderNEWT.java @@ -141,17 +141,33 @@ public class TestKeyEventOrderNEWT extends UITestCase { System.err.println("KEY Event Order Test: "+loops); keyAdapter.reset(); for(int i=0; i keyEvents) { - int eet = KeyEvent.EVENT_KEY_PRESSED; + IntIntHashMap keyCode2NextEvent = new IntIntHashMap(); for(int i=0; i= eet ) { + eet = KeyEvent.EVENT_KEY_PRESSED; + } final int et = e.getEventType(); Assert.assertEquals("Key event not in proper order", eet, et); eet = getNextKeyEventType(et); + keyCode2NextEvent.put(e.getKeyCode(), eet); } } -- cgit v1.2.3 From 70d58b030bdbac98ba592a3a14a84cc0e4941c51 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 27 Oct 2012 04:01:56 +0200 Subject: NEWT KeyEvent (Windows, OSX): Check whether keyCode is tracked before using bitfield, use more IntBitfield.put(..) return value for efficiency. --- make/scripts/tests-x64.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- src/newt/classes/jogamp/newt/WindowImpl.java | 3 +++ .../jogamp/newt/driver/macosx/WindowDriver.java | 23 +++++++++---------- .../jogamp/newt/driver/windows/WindowDriver.java | 26 ++++++++++++---------- 5 files changed, 31 insertions(+), 29 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 21e303dc2..72ee5f666 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -32,9 +32,9 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSi REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 734fa671f..8594bfe2e 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -375,9 +375,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* -testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT $* +testawt com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 311ed0bbb..4f8eb3d3a 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2193,6 +2193,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } return -1; } + protected final boolean isKeyCodeTracked(int keyCode) { + return 0 <= keyCode && keyCode < keyRepeatState.capacity(); + } public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) ); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index bcdd6b9df..e0ea8ea76 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -324,24 +324,21 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: - if( 1 == isKeyInAutoRepeat(keyCode) ) { - // AR out - keyRepeatState.put(keyCode, false); + if( isKeyCodeTracked(keyCode) ) { + keyRepeatState.put(keyCode, false); // prev == true -> AR out + keyPressedState.put(keyCode, false); } - keyPressedState.put(keyCode, false); keyChar = (char)-1; break; case KeyEvent.EVENT_KEY_PRESSED: - if( 1 == isKeyPressed(keyCode) ) { - if( 0 == isKeyInAutoRepeat(keyCode) ) { - // AR in - keyRepeatState.put(keyCode, true); + if( isKeyCodeTracked(keyCode) ) { + if( keyPressedState.put(keyCode, true) ) { + // key was already pressed + keyRepeatState.put(keyCode, true); // prev == false -> AR in + modifiers |= InputEvent.AUTOREPEAT_MASK; + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED } - modifiers |= InputEvent.AUTOREPEAT_MASK; - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED - } else { - keyPressedState.put(keyCode, true); } keyChar = (char)-1; break; diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index be9f6603e..8b57a241d 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -281,12 +281,13 @@ public class WindowDriver extends WindowImpl { // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: - if( 1 == isKeyInAutoRepeat(keyCode) ) { - // AR out - send out missing PRESSED - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); - keyRepeatState.put(keyCode, false); + if( isKeyCodeTracked(keyCode) ) { + if( keyRepeatState.put(keyCode, false) ) { + // AR out - send out missing PRESSED + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); + } + keyPressedState.put(keyCode, false); } - keyPressedState.put(keyCode, false); emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); final char lastTypedKeyChar = (char) typedKeyCode2KeyChar.put(keyCode, 0); if( 0 < lastTypedKeyChar ) { @@ -294,16 +295,17 @@ public class WindowDriver extends WindowImpl { } break; case KeyEvent.EVENT_KEY_PRESSED: - lastPressedKeyCode = keyCode; - if( 1 == isKeyPressed(keyCode) ) { - if( 0 == isKeyInAutoRepeat(keyCode) ) { - // AR in - skip already send PRESSED - keyRepeatState.put(keyCode, true); + lastPressedKeyCode = keyCode; + if( isKeyCodeTracked(keyCode) ) { + if( keyPressedState.put(keyCode, true) ) { + // key was already pressed + if( keyRepeatState.put(keyCode, true) ) { + emitKeyEvent(send, wait, eventType, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); + } // else AR in - skip already send PRESSED } else { - emitKeyEvent(send, wait, eventType, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); + emitKeyEvent(send, wait, eventType, modifiers, keyCode, (char)-1); } } else { - keyPressedState.put(keyCode, true); emitKeyEvent(send, wait, eventType, modifiers, keyCode, (char)-1); } break; -- cgit v1.2.3 From cf9a4e236891ce2f6d9469a017e880eed704dea0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 28 Oct 2012 05:44:24 +0100 Subject: Fix NEWT KeyCode: Basic KeyCode Validation on X11, Windows and OSX - X11: Add VK_QUOTE mapping - OSX: Add single shift, ctrl alt key press; Fix mapping: Command -> Windows, Option -> ALT, add BACK_QUOTE and QUOTE. --- make/scripts/tests-x64.bat | 3 +- make/scripts/tests.sh | 3 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 16 +- .../jogamp/newt/driver/macosx/MacKeyUtil.java | 145 ++++++------ .../jogamp/newt/driver/macosx/WindowDriver.java | 6 +- src/newt/native/NewtMacWindow.h | 4 + src/newt/native/NewtMacWindow.m | 74 +++++- src/newt/native/X11Display.c | 2 + .../opengl/test/junit/newt/TestKeyCodeNEWT.java | 256 +++++++++++++++++++++ .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 64 ++++++ 10 files changed, 472 insertions(+), 101 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestKeyCodeNEWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 72ee5f666..6c9dae729 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -34,7 +34,8 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyCodeNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8594bfe2e..0db48b289 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -377,7 +377,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT $* -testawt com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT $* +testawt com.jogamp.opengl.test.junit.newt.TestKeyCodeNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index a8ac70b4d..8d3d9e88f 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -156,10 +156,10 @@ public class KeyEvent extends InputEvent /* 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_BACK_SPACE = 0x08; // '\b' + public static final int VK_TAB = 0x09; // '\t' + public static final int VK_ENTER = 0x0A; // '\n' public static final int VK_CLEAR = 0x0C; public static final int VK_SHIFT = 0x10; public static final int VK_CONTROL = 0x11; @@ -296,18 +296,10 @@ public class KeyEvent extends InputEvent 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_SEPARATOR = 0x6C; public static final int VK_SUBTRACT = 0x6D; public static final int VK_DECIMAL = 0x6E; diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java index d39e0027b..5966bd30f 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java @@ -162,13 +162,13 @@ public class MacKeyUtil { case kVK_Space: return KeyEvent.VK_SPACE; case kVK_Delete: return KeyEvent.VK_BACK_SPACE; case kVK_Escape: return KeyEvent.VK_ESCAPE; - case kVK_Command: return KeyEvent.VK_ALT; + case kVK_Command: return KeyEvent.VK_WINDOWS; case kVK_Shift: return KeyEvent.VK_SHIFT; case kVK_CapsLock: return KeyEvent.VK_CAPS_LOCK; - case kVK_Option: return KeyEvent.VK_WINDOWS; + case kVK_Option: return KeyEvent.VK_ALT; case kVK_Control: return KeyEvent.VK_CONTROL; case kVK_RightShift: return KeyEvent.VK_SHIFT; - case kVK_RightOption: return KeyEvent.VK_WINDOWS; + case kVK_RightOption: return KeyEvent.VK_ALT; case kVK_RightControl: return KeyEvent.VK_CONTROL; // case kVK_Function: return KeyEvent.VK_F; case kVK_F17: return KeyEvent.VK_F17; @@ -206,78 +206,73 @@ public class MacKeyUtil { case kVK_UpArrow: return KeyEvent.VK_UP; } - if (keyChar == '\r') { - // Turn these into \n - return KeyEvent.VK_ENTER; - } - - if (keyChar >= NSUpArrowFunctionKey && keyChar <= NSModeSwitchFunctionKey) { - switch (keyChar) { - case NSUpArrowFunctionKey: return KeyEvent.VK_UP; - case NSDownArrowFunctionKey: return KeyEvent.VK_DOWN; - case NSLeftArrowFunctionKey: return KeyEvent.VK_LEFT; - case NSRightArrowFunctionKey: return KeyEvent.VK_RIGHT; - case NSF1FunctionKey: return KeyEvent.VK_F1; - case NSF2FunctionKey: return KeyEvent.VK_F2; - case NSF3FunctionKey: return KeyEvent.VK_F3; - case NSF4FunctionKey: return KeyEvent.VK_F4; - case NSF5FunctionKey: return KeyEvent.VK_F5; - case NSF6FunctionKey: return KeyEvent.VK_F6; - case NSF7FunctionKey: return KeyEvent.VK_F7; - case NSF8FunctionKey: return KeyEvent.VK_F8; - case NSF9FunctionKey: return KeyEvent.VK_F9; - case NSF10FunctionKey: return KeyEvent.VK_F10; - case NSF11FunctionKey: return KeyEvent.VK_F11; - case NSF12FunctionKey: return KeyEvent.VK_F12; - case NSF13FunctionKey: return KeyEvent.VK_F13; - case NSF14FunctionKey: return KeyEvent.VK_F14; - case NSF15FunctionKey: return KeyEvent.VK_F15; - case NSF16FunctionKey: return KeyEvent.VK_F16; - case NSF17FunctionKey: return KeyEvent.VK_F17; - case NSF18FunctionKey: return KeyEvent.VK_F18; - case NSF19FunctionKey: return KeyEvent.VK_F19; - case NSF20FunctionKey: return KeyEvent.VK_F20; - case NSF21FunctionKey: return KeyEvent.VK_F21; - case NSF22FunctionKey: return KeyEvent.VK_F22; - case NSF23FunctionKey: return KeyEvent.VK_F23; - case NSF24FunctionKey: return KeyEvent.VK_F24; - case NSInsertFunctionKey: return KeyEvent.VK_INSERT; - case NSDeleteFunctionKey: return KeyEvent.VK_DELETE; - case NSHomeFunctionKey: return KeyEvent.VK_HOME; - case NSBeginFunctionKey: return KeyEvent.VK_BEGIN; - case NSEndFunctionKey: return KeyEvent.VK_END; - case NSPageUpFunctionKey: return KeyEvent.VK_PAGE_UP; - case NSPageDownFunctionKey: return KeyEvent.VK_PAGE_DOWN; - case NSPrintScreenFunctionKey: return KeyEvent.VK_PRINTSCREEN; - case NSScrollLockFunctionKey: return KeyEvent.VK_SCROLL_LOCK; - case NSPauseFunctionKey: return KeyEvent.VK_PAUSE; - // Not handled: - // NSSysReqFunctionKey - // NSBreakFunctionKey - // NSResetFunctionKey - case NSStopFunctionKey: return KeyEvent.VK_STOP; - // Not handled: - // NSMenuFunctionKey - // NSUserFunctionKey - // NSSystemFunctionKey - // NSPrintFunctionKey - // NSClearLineFunctionKey - // NSClearDisplayFunctionKey - // NSInsertLineFunctionKey - // NSDeleteLineFunctionKey - // NSInsertCharFunctionKey - // NSDeleteCharFunctionKey - // NSPrevFunctionKey - // NSNextFunctionKey - // NSSelectFunctionKey - // NSExecuteFunctionKey - // NSUndoFunctionKey - // NSRedoFunctionKey - // NSFindFunctionKey - // NSHelpFunctionKey - // NSModeSwitchFunctionKey - default: break; - } + switch (keyChar) { + case NSUpArrowFunctionKey: return KeyEvent.VK_UP; + case NSDownArrowFunctionKey: return KeyEvent.VK_DOWN; + case NSLeftArrowFunctionKey: return KeyEvent.VK_LEFT; + case NSRightArrowFunctionKey: return KeyEvent.VK_RIGHT; + case NSF1FunctionKey: return KeyEvent.VK_F1; + case NSF2FunctionKey: return KeyEvent.VK_F2; + case NSF3FunctionKey: return KeyEvent.VK_F3; + case NSF4FunctionKey: return KeyEvent.VK_F4; + case NSF5FunctionKey: return KeyEvent.VK_F5; + case NSF6FunctionKey: return KeyEvent.VK_F6; + case NSF7FunctionKey: return KeyEvent.VK_F7; + case NSF8FunctionKey: return KeyEvent.VK_F8; + case NSF9FunctionKey: return KeyEvent.VK_F9; + case NSF10FunctionKey: return KeyEvent.VK_F10; + case NSF11FunctionKey: return KeyEvent.VK_F11; + case NSF12FunctionKey: return KeyEvent.VK_F12; + case NSF13FunctionKey: return KeyEvent.VK_F13; + case NSF14FunctionKey: return KeyEvent.VK_F14; + case NSF15FunctionKey: return KeyEvent.VK_F15; + case NSF16FunctionKey: return KeyEvent.VK_F16; + case NSF17FunctionKey: return KeyEvent.VK_F17; + case NSF18FunctionKey: return KeyEvent.VK_F18; + case NSF19FunctionKey: return KeyEvent.VK_F19; + case NSF20FunctionKey: return KeyEvent.VK_F20; + case NSF21FunctionKey: return KeyEvent.VK_F21; + case NSF22FunctionKey: return KeyEvent.VK_F22; + case NSF23FunctionKey: return KeyEvent.VK_F23; + case NSF24FunctionKey: return KeyEvent.VK_F24; + case NSInsertFunctionKey: return KeyEvent.VK_INSERT; + case NSDeleteFunctionKey: return KeyEvent.VK_DELETE; + case NSHomeFunctionKey: return KeyEvent.VK_HOME; + case NSBeginFunctionKey: return KeyEvent.VK_BEGIN; + case NSEndFunctionKey: return KeyEvent.VK_END; + case NSPageUpFunctionKey: return KeyEvent.VK_PAGE_UP; + case NSPageDownFunctionKey: return KeyEvent.VK_PAGE_DOWN; + case NSPrintScreenFunctionKey: return KeyEvent.VK_PRINTSCREEN; + case NSScrollLockFunctionKey: return KeyEvent.VK_SCROLL_LOCK; + case NSPauseFunctionKey: return KeyEvent.VK_PAUSE; + // Not handled: + // NSSysReqFunctionKey + // NSBreakFunctionKey + // NSResetFunctionKey + case NSStopFunctionKey: return KeyEvent.VK_STOP; + // Not handled: + // NSMenuFunctionKey + // NSUserFunctionKey + // NSSystemFunctionKey + // NSPrintFunctionKey + // NSClearLineFunctionKey + // NSClearDisplayFunctionKey + // NSInsertLineFunctionKey + // NSDeleteLineFunctionKey + // NSInsertCharFunctionKey + // NSDeleteCharFunctionKey + // NSPrevFunctionKey + // NSNextFunctionKey + // NSSelectFunctionKey + // NSExecuteFunctionKey + // NSUndoFunctionKey + // NSRedoFunctionKey + // NSFindFunctionKey + // NSHelpFunctionKey + // NSModeSwitchFunctionKey + case 0x60: return KeyEvent.VK_BACK_QUOTE; // ` + case 0x27: return KeyEvent.VK_QUOTE; // ' + case '\r': return KeyEvent.VK_ENTER; } if ('a' <= keyChar && keyChar <= 'z') { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index e0ea8ea76..bc83f9540 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -314,12 +314,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } - private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int _keyCode, char keyChar) { // Note that we send the key char for the key code on this // platform -- we do not get any useful key codes out of the system - keyCode = MacKeyUtil.validateKeyCode(keyCode, keyChar); + final int keyCode = MacKeyUtil.validateKeyCode(_keyCode, keyChar); if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode)); + System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)); } // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED switch(eventType) { diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index c0912ad3c..29b646fbf 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -111,6 +111,7 @@ BOOL mouseInside; BOOL cursorIsHidden; BOOL realized; + BOOL modsDown[4]; // shift, ctrl, alt/option, win/command NSPoint lastInsideMousePosition; @public int cachedInsets[4]; // l, r, t, b @@ -145,6 +146,7 @@ - (void) setMousePosition:(NSPoint)p; - (void) sendKeyEvent: (NSEvent*) event eventType: (jint) evType; +- (void) sendKeyEvent: (jint) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jint) evType; - (void) sendMouseEvent: (NSEvent*) event eventType: (jint) evType; - (void) focusChanged: (BOOL) gained; @@ -157,6 +159,8 @@ - (void) windowDidResignKey: (NSNotification *) notification; - (void) keyDown: (NSEvent*) theEvent; - (void) keyUp: (NSEvent*) theEvent; +- (void) handleFlagsChanged:(int) keyMask keyIndex: (int) keyIdx keyCode: (int) keyCode modifiers: (NSUInteger) mods; +- (void) flagsChanged: (NSEvent *) theEvent; - (void) mouseEntered: (NSEvent*) theEvent; - (void) mouseExited: (NSEvent*) theEvent; - (void) mouseMoved: (NSEvent*) theEvent; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index b58b99e38..de5f3773c 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -368,6 +368,10 @@ static jmethodID windowRepaintID = NULL; cachedInsets[1] = 0; // r cachedInsets[2] = 0; // t cachedInsets[3] = 0; // b + modsDown[0] = NO; // shift + modsDown[1] = NO; // ctrl + modsDown[2] = NO; // alt + modsDown[3] = NO; // win mouseConfined = NO; mouseVisible = YES; mouseInside = NO; @@ -596,6 +600,14 @@ static jint mods2JavaMods(NSUInteger mods) } - (void) sendKeyEvent: (NSEvent*) event eventType: (jint) evType +{ + jint keyCode = (jint) [event keyCode]; + NSString* chars = [event charactersIgnoringModifiers]; + NSUInteger mods = [event modifierFlags]; + [self sendKeyEvent: keyCode characters: chars modifiers: mods eventType: evType]; +} + +- (void) sendKeyEvent: (jint) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jint) evType { NSView* nsview = [self contentView]; if( ! [nsview isMemberOfClass:[NewtView class]] ) { @@ -616,16 +628,30 @@ static jint mods2JavaMods(NSUInteger mods) } int i; - jint keyCode = (jint) [event keyCode]; - NSString* chars = [event charactersIgnoringModifiers]; - int len = [chars length]; - jint javaMods = mods2JavaMods([event modifierFlags]); - - for (i = 0; i < len; i++) { - // Note: the key code in the NSEvent does not map to anything we can use - jchar keyChar = (jchar) [chars characterAtIndex: i]; + int len = NULL != chars ? [chars length] : 0; + jint javaMods = mods2JavaMods(mods); + + if(len > 0) { + // printable chars + for (i = 0; i < len; i++) { + // Note: the key code in the NSEvent does not map to anything we can use + jchar keyChar = (jchar) [chars characterAtIndex: i]; + + DBG_PRINT("sendKeyEvent: %d/%d char 0x%X, code 0x%X\n", i, len, (int)keyChar, (int)keyCode); + + #ifdef USE_SENDIO_DIRECT + (*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID, + evType, javaMods, keyCode, keyChar); + #else + (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, + evType, javaMods, keyCode, keyChar); + #endif + } + } else { + // non-printable chars + jchar keyChar = (jchar) -1; - DBG_PRINT("sendKeyEvent: %d/%d char 0x%X, code 0x%X\n", i, len, (int)keyChar, (int)keyCode); + DBG_PRINT("sendKeyEvent: code 0x%X\n", (int)keyCode); #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID, @@ -805,6 +831,36 @@ static jint mods2JavaMods(NSUInteger mods) [self sendKeyEvent: theEvent eventType: EVENT_KEY_TYPED]; } +#define kVK_Shift 0x38 +#define kVK_Option 0x3A +#define kVK_Control 0x3B +#define kVK_Command 0x37 + +- (void) handleFlagsChanged:(int) keyMask keyIndex: (int) keyIdx keyCode: (int) keyCode modifiers: (NSUInteger) mods +{ + if ( NO == modsDown[keyIdx] && 0 != ( mods & keyMask ) ) { + modsDown[keyIdx] = YES; + mods &= ~keyMask; + [self sendKeyEvent: keyCode characters: NULL modifiers: mods eventType: EVENT_KEY_TYPED]; + } else if ( YES == modsDown[keyIdx] && 0 == ( mods & keyMask ) ) { + modsDown[keyIdx] = NO; + [self sendKeyEvent: keyCode characters: NULL modifiers: mods eventType: EVENT_KEY_RELEASED]; + [self sendKeyEvent: keyCode characters: NULL modifiers: mods eventType: EVENT_KEY_TYPED]; + } +} + +- (void) flagsChanged:(NSEvent *) theEvent +{ + NSUInteger mods = [theEvent modifierFlags]; + + // BOOL modsDown[4]; // shift, ctrl, alt/option, win/command + + [self handleFlagsChanged: NSShiftKeyMask keyIndex: 0 keyCode: kVK_Shift modifiers: mods]; + [self handleFlagsChanged: NSControlKeyMask keyIndex: 1 keyCode: kVK_Control modifiers: mods]; + [self handleFlagsChanged: NSAlternateKeyMask keyIndex: 2 keyCode: kVK_Option modifiers: mods]; + [self handleFlagsChanged: NSCommandKeyMask keyIndex: 3 keyCode: kVK_Command modifiers: mods]; +} + - (void) mouseEntered: (NSEvent*) theEvent { DBG_PRINT( "mouseEntered: confined %d, visible %d\n", mouseConfined, mouseVisible); diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 9f29acc0c..341455f0f 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -148,6 +148,8 @@ static jint X11KeySym2NewtVKey(KeySym keySym) { return J_VK_HELP; case XK_grave: return J_VK_BACK_QUOTE; + case XK_apostrophe: + return J_VK_QUOTE; } return keySym; } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestKeyCodeNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestKeyCodeNEWT.java new file mode 100644 index 000000000..8af0f0246 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestKeyCodeNEWT.java @@ -0,0 +1,256 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + +import org.junit.After; +import org.junit.Assert; +import org.junit.AfterClass; +import org.junit.Assume; +import org.junit.Before; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Robot; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.swing.JFrame; + +import java.io.IOException; + +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; + +import com.jogamp.opengl.test.junit.util.*; +import com.jogamp.opengl.test.junit.util.NEWTKeyUtil.CodeSeg; + +/** + * Testing key event order incl. auto-repeat (Bug 601) + * + *

+ * Note Event order: + *

    + *
  1. {@link #EVENT_KEY_PRESSED}
  2. + *
  3. {@link #EVENT_KEY_RELEASED}
  4. + *
  5. {@link #EVENT_KEY_TYPED}
  6. + *
+ *

+ */ +public class TestKeyCodeNEWT extends UITestCase { + static int width, height; + static long durationPerTest = 100; + static long awtWaitTimeout = 1000; + + static GLCapabilities glCaps; + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glCaps = new GLCapabilities(null); + } + + @AfterClass + public static void release() { + } + + @Before + public void initTest() { + } + + @After + public void releaseTest() { + } + + @Test + public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException { + GLWindow glWindow = GLWindow.create(glCaps); + glWindow.setSize(width, height); + glWindow.setVisible(true); + + testImpl(glWindow); + + glWindow.destroy(); + } + + // @Test + public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { + GLWindow glWindow = GLWindow.create(glCaps); + + // Wrap the window in a canvas. + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); + + // Add the canvas to a frame, and make it all visible. + final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); + frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); + frame1.setSize(width, height); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + } } ); + + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); + + testImpl(glWindow); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(false); + frame1.dispose(); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + glWindow.destroy(); + } + + static CodeSeg[] codeSegments = new CodeSeg[] { + new CodeSeg(0x008, 0x00a, "bs, tab, cr"), + new CodeSeg(0x010, 0x011, "shift, ctrl"), // single alt n/a on windows + new CodeSeg(0x01B, 0x01B, "esc"), + new CodeSeg(0x020, 0x024, "space, up, down, end, home"), + new CodeSeg(0x025, 0x028, "cursor"), + new CodeSeg(0x02C, 0x02F, ", - . /"), + new CodeSeg(0x030, 0x039, "0 - 9"), + new CodeSeg(0x03B, 0x03B, ";"), + new CodeSeg(0x03D, 0x03D, "="), + new CodeSeg(0x041, 0x05A, "a - z"), + new CodeSeg(0x05B, 0x05D, "[ \\ ]"), + // new CodeSeg(0x060, 0x06B, "numpad1"), // can be mapped to normal keycodes + // new CodeSeg(0x06D, 0x06F, "numpad2"), // can be mapped to normal keycodes + new CodeSeg(0x07F, 0x07F, "del"), + // new CodeSeg(0x090, 0x091, "num lock, scroll lock"), + // new CodeSeg(0x070, 0x07B, "F1 - F12"), + // new CodeSeg(0x09A, 0x09D, "prt ins hlp meta"), + new CodeSeg(0x0C0, 0x0C0, "back quote"), + new CodeSeg(0x0DE, 0x0DE, "quote"), + // new CodeSeg(0x0E0, 0x0E3, "cursor kp"), + // new CodeSeg(0x080, 0x08F, "dead-1"), + // new CodeSeg(0x096, 0x0A2, "& ^ \" < > { }"), + // new CodeSeg(0x200, 0x20D, "extra-2"), // @ ; .. + }; + + static void testKeyCode(Robot robot, NEWTKeyAdapter keyAdapter) { + List> cse = new ArrayList>(); + + for(int i=0; i queue = keyAdapter.getQueued(); + for(int j=0; j < 10 && queue.size() < 3 * codeCount; j++) { // wait until events are collected + robot.delay(100); + } + final ArrayList events = new ArrayList(queue); + cse.add(events); + } + Assert.assertEquals("KeyCode impl. incomplete", true, NEWTKeyUtil.validateKeyCode(codeSegments, cse, true)); + } + + void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { + final Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + + GLEventListener demo1 = new RedSquareES2(); + TestListenerCom01AWT.setDemoFields(demo1, glWindow, false); + glWindow.addGLEventListener(demo1); + + NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); + glWindow1KA.setVerbose(false); + glWindow.addKeyListener(glWindow1KA); + + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true)); + AWTRobotUtil.clearAWTFocus(robot); + + // Continuous animation .. + Animator animator = new Animator(glWindow); + animator.start(); + + Thread.sleep(durationPerTest); // manual testing + + glWindow1KA.reset(); + AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic + // AWTRobotUtil.assertRequestFocusAndWait(robot, glWindow, glWindow, null, null); // by mouse click + + // + // Test the key event order w/o auto-repeat + // + testKeyCode(robot, glWindow1KA); + + // Remove listeners to avoid logging during dispose/destroy. + glWindow.removeKeyListener(glWindow1KA); + + // Shutdown the test. + animator.stop(); + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i keyEvents) { for(int i=0; i> keyEventsList, boolean verbose) { + final List missCodes = new ArrayList(); + int totalCodeCount = 0; + boolean res = true; + for(int i=0; i keyEvents = keyEventsList.get(i); + res &= validateKeyCode(missCodes, codeSeg, keyEvents, verbose); + } + if(verbose) { + System.err.println("*** Total KeyCode Misses "+missCodes.size()+" / "+totalCodeCount+", valid "+res); + for(int i=0; i missCodes, CodeSeg codeSeg, List keyEvents, boolean verbose) { + final int codeCount = codeSeg.max - codeSeg.min + 1; + int misses = 0; + for(int i=0; i Date: Tue, 30 Oct 2012 17:39:31 +0100 Subject: NEWT/OSX getLocationOnScreenImpl(..): Use real OSXUtil.GetLocationOnScreen(..) if onscreen and surface available. --- .../jogamp/newt/driver/macosx/WindowDriver.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index bc83f9540..121c3fa99 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -45,6 +45,7 @@ import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; +import jogamp.nativewindow.macosx.OSXUtil; import jogamp.newt.WindowImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; @@ -149,7 +150,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl public final void clearFocus() { if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow: clearFocus() - requestFocusParent, isOffscreenInstance "+isOffscreenInstance); + System.err.println("MacWindow: clearFocus(), isOffscreenInstance "+isOffscreenInstance); } if(!isOffscreenInstance) { resignFocus0(getWindowHandle()); @@ -236,16 +237,21 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } protected Point getLocationOnScreenImpl(int x, int y) { - Point p = new Point(x, y); + final NativeWindow parent = getParent(); + final boolean useParent = null != parent && 0 != parent.getWindowHandle() ; + + if( !useParent && !isOffscreenInstance && 0 != surfaceHandle) { + return OSXUtil.GetLocationOnScreen(surfaceHandle, true, x, y); + } + + final Point p = new Point(x, y); // min val is 0 p.setX(Math.max(p.getX(), 0)); p.setY(Math.max(p.getY(), 0)); - - final NativeWindow parent = getParent(); - if( null != parent && 0 != parent.getWindowHandle() ) { + if( useParent ) { p.translate(parent.getLocationOnScreen(null)); } - return p; + return p; } private Point getTopLevelLocationOnScreen(int x, int y) { -- cgit v1.2.3 From b62e1d027c289877686d6008ea8dd40e4e1541ec Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 31 Oct 2012 04:04:39 +0100 Subject: Fix NEWT KeyEvent: Deliver keyChar w/ pressed and released; Deliver proper modified flags and modifier-key events; Simplify Windows key handling Preface: Modifier-keys are SHIFT, CTRL, ALT and META and they have a matching modifier-bit. - Simplify Windows key handling - Employ MapVirtualKey(..) for virtual-key to character and scancode to virtual-key mappings, allowing to drop tracking of keyCode to keyChar in java code. This also removes the platform restriction of delivering keyChar at TYPED only. - Deliver keyChar w/ pressed and released - Due to the lift restriction on the Windows platform (see above), we can deliver keyChar w/ all key events on all platforms. - Deliver proper modified flags and modifier-key events All modifier-keys deliver pressed, released and typed events with their modifier-bit set. The above is covered by unit tests, which passed on X11, Windows and OSX (manual test run). --- make/scripts/tests-x64.bat | 5 +- make/scripts/tests.sh | 8 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 111 +++++---- .../jogamp/newt/driver/macosx/WindowDriver.java | 11 +- .../jogamp/newt/driver/windows/WindowDriver.java | 40 +-- src/newt/native/NewtMacWindow.m | 7 +- src/newt/native/WindowsWindow.c | 199 +++++++++------ src/newt/native/X11Display.c | 26 +- .../opengl/test/junit/newt/TestNewtKeyCodeAWT.java | 259 ------------------- .../junit/newt/TestNewtKeyCodeModifiersAWT.java | 275 +++++++++++++++++++++ .../test/junit/newt/TestNewtKeyCodesAWT.java | 246 ++++++++++++++++++ .../junit/newt/TestNewtKeyEventAutoRepeatAWT.java | 25 +- .../test/junit/newt/TestNewtKeyEventOrderAWT.java | 6 +- .../TestNewtKeyPressReleaseUnmaskRepeatAWT.java | 2 +- .../opengl/test/junit/util/AWTKeyAdapter.java | 26 +- .../opengl/test/junit/util/AWTMouseAdapter.java | 20 +- .../opengl/test/junit/util/AWTRobotUtil.java | 14 +- .../test/junit/util/InputEventCountAdapter.java | 3 +- .../opengl/test/junit/util/NEWTKeyAdapter.java | 26 +- .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 46 ++-- .../opengl/test/junit/util/NEWTMouseAdapter.java | 20 +- 21 files changed, 865 insertions(+), 510 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeModifiersAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodesAWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 887af5484..7de5fe51c 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -34,9 +34,10 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventOrderAWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodesAWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 85a7139e0..6c0095c51 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -263,7 +263,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* @@ -376,9 +376,11 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventOrderAWT $* -testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeAWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodesAWT $* +testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 8d3d9e88f..927c9aa85 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -59,6 +59,10 @@ package com.jogamp.newt.event; * The idea is if you mask out auto-repeat in your event listener * you just get one long pressed key D/U/T triple. *

+ *

+ * {@link #isModifierKey() Modifiers keys} will produce regular events (pressed, released and typed), + * however they will not produce Auto-Repeat events itself. + *

*/ @SuppressWarnings("serial") public class KeyEvent extends InputEvent @@ -69,12 +73,12 @@ public class KeyEvent extends InputEvent this.keyChar=keyChar; } - /** Only valid on all platforms at {@link KeyListener#keyTyped(KeyEvent)} */ + /** Returns the character matching the {@link #getKeyCode() virtual key code}, if exist. */ public char getKeyChar() { return keyChar; } - /** Always valid. */ + /** Returns the virtual key code. */ public int getKeyCode() { return keyCode; } @@ -100,49 +104,68 @@ public class KeyEvent extends InputEvent } } - public boolean isActionKey() { + /** Returns true if keyCode represents a modifier key, i.e. one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. */ + public static boolean isModifierKey(int keyCode) { + switch (keyCode) { + case VK_SHIFT: + case VK_CONTROL: + case VK_ALT: + case VK_ALT_GRAPH: + case VK_META: + return true; + default: + return false; + } + } + + /** Returns true if {@link #getKeyCode()} represents a modifier key, i.e. one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. */ + public boolean isModifierKey() { + return isModifierKey(keyCode); + } + + 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; + 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; } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 121c3fa99..5755bdf11 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -324,9 +324,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // Note that we send the key char for the key code on this // platform -- we do not get any useful key codes out of the system final int keyCode = MacKeyUtil.validateKeyCode(_keyCode, keyChar); - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)); - } + // final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); + // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", key 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)+", mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + + // 1:1 Order: OSX and NEWT delivery order is PRESSED, RELEASED and TYPED // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: @@ -334,7 +335,6 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl keyRepeatState.put(keyCode, false); // prev == true -> AR out keyPressedState.put(keyCode, false); } - keyChar = (char)-1; break; case KeyEvent.EVENT_KEY_PRESSED: if( isKeyCodeTracked(keyCode) ) { @@ -342,11 +342,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // key was already pressed keyRepeatState.put(keyCode, true); // prev == false -> AR in modifiers |= InputEvent.AUTOREPEAT_MASK; - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); // RELEASED emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED } } - keyChar = (char)-1; break; case KeyEvent.EVENT_KEY_TYPED: break; diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 8b57a241d..c513b9e84 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,7 +46,6 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; -import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; @@ -260,11 +259,6 @@ public class WindowDriver extends WindowImpl { // nop - using event driven insetsChange(..) } - /** We have to regenerate the keyCode for EVENT_KEY_TYPED on this platform. */ - private int lastPressedKeyCode = 0; - /** We have to reorder the native key events to match NEWT's order */ - private IntIntHashMap typedKeyCode2KeyChar = new IntIntHashMap(KeyEvent.VK_CONTEXT_MENU+1); - private final void emitKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { if( send ) { super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); @@ -274,52 +268,42 @@ public class WindowDriver extends WindowImpl { } private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - // final int kc = 0 <= keyCode ? keyCode : lastPressedKeyCode; - // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", key "+toHexString(kc)+", mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(kc)+", repeat "+isKeyInAutoRepeat(kc)); - + final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); + // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + // Reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: if( isKeyCodeTracked(keyCode) ) { - if( keyRepeatState.put(keyCode, false) ) { + if( keyRepeatState.put(keyCode, false) && !isModifierKeyCode ) { // AR out - send out missing PRESSED - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keyChar); } keyPressedState.put(keyCode, false); } emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); - final char lastTypedKeyChar = (char) typedKeyCode2KeyChar.put(keyCode, 0); - if( 0 < lastTypedKeyChar ) { - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, lastTypedKeyChar); - } + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); break; case KeyEvent.EVENT_KEY_PRESSED: - lastPressedKeyCode = keyCode; if( isKeyCodeTracked(keyCode) ) { if( keyPressedState.put(keyCode, true) ) { // key was already pressed - if( keyRepeatState.put(keyCode, true) ) { - emitKeyEvent(send, wait, eventType, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); - } // else AR in - skip already send PRESSED + if( keyRepeatState.put(keyCode, true) && !isModifierKeyCode ) { + emitKeyEvent(send, wait, eventType, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keyChar); + } // else AR in - skip already send PRESSED ; or ALT } else { - emitKeyEvent(send, wait, eventType, modifiers, keyCode, (char)-1); + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); } } else { - emitKeyEvent(send, wait, eventType, modifiers, keyCode, (char)-1); + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); } break; case KeyEvent.EVENT_KEY_TYPED: - if(-1==keyCode) { - keyCode = lastPressedKeyCode; - } - lastPressedKeyCode = -1; if( 1 == isKeyInAutoRepeat(keyCode) ) { modifiers |= InputEvent.AUTOREPEAT_MASK; - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); - } else { - typedKeyCode2KeyChar.put(keyCode, keyChar); } break; } diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index de5f3773c..b89b5c21d 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -840,12 +840,11 @@ static jint mods2JavaMods(NSUInteger mods) { if ( NO == modsDown[keyIdx] && 0 != ( mods & keyMask ) ) { modsDown[keyIdx] = YES; - mods &= ~keyMask; - [self sendKeyEvent: keyCode characters: NULL modifiers: mods eventType: EVENT_KEY_TYPED]; + [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_PRESSED]; } else if ( YES == modsDown[keyIdx] && 0 == ( mods & keyMask ) ) { modsDown[keyIdx] = NO; - [self sendKeyEvent: keyCode characters: NULL modifiers: mods eventType: EVENT_KEY_RELEASED]; - [self sendKeyEvent: keyCode characters: NULL modifiers: mods eventType: EVENT_KEY_TYPED]; + [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_RELEASED]; + [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_TYPED]; } } diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index bb90a2dce..2152166e4 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -463,87 +463,108 @@ static void BuildDynamicKeyMapTable() } // for each VK_OEM_* } -static jint GetModifiers() { +static jint GetModifiers(BOOL altKeyFlagged, UINT jkey) { jint modifiers = 0; // have to do &0xFFFF to avoid runtime assert caused by compiling with // /RTCcsu - if (HIBYTE((GetKeyState(VK_CONTROL) & 0xFFFF)) != 0) { + if ( HIBYTE((GetKeyState(VK_CONTROL) & 0xFFFF)) != 0 || J_VK_CONTROL == jkey ) { modifiers |= EVENT_CTRL_MASK; } - if (HIBYTE((GetKeyState(VK_SHIFT) & 0xFFFF)) != 0) { + if ( HIBYTE((GetKeyState(VK_SHIFT) & 0xFFFF)) != 0 || J_VK_SHIFT == jkey ) { modifiers |= EVENT_SHIFT_MASK; } - if (HIBYTE((GetKeyState(VK_MENU) & 0xFFFF)) != 0) { + if ( altKeyFlagged || HIBYTE((GetKeyState(VK_MENU) & 0xFFFF)) != 0 || J_VK_ALT == jkey ) { modifiers |= EVENT_ALT_MASK; } - if (HIBYTE((GetKeyState(VK_LBUTTON) & 0xFFFF)) != 0) { + if ( HIBYTE((GetKeyState(VK_LBUTTON) & 0xFFFF)) != 0 ) { modifiers |= EVENT_BUTTON1_MASK; } - if (HIBYTE((GetKeyState(VK_MBUTTON) & 0xFFFF)) != 0) { + if ( HIBYTE((GetKeyState(VK_MBUTTON) & 0xFFFF)) != 0 ) { modifiers |= EVENT_BUTTON2_MASK; } - if (HIBYTE((GetKeyState(VK_RBUTTON) & 0xFFFF)) != 0) { + if ( HIBYTE((GetKeyState(VK_RBUTTON) & 0xFFFF)) != 0 ) { modifiers |= EVENT_BUTTON3_MASK; } return modifiers; } -static int WmChar(JNIEnv *env, jobject window, UINT character, UINT repCnt, - UINT flags, BOOL system) -{ +static BOOL IsAltKeyDown(BYTE flags, BOOL system) { // The Alt modifier is reported in the 29th bit of the lParam, - // i.e., it is the 13th bit of `flags' (which is HIWORD(lParam)). - BOOL alt_is_down = (flags & (1<<13)) != 0; - if (system && alt_is_down) { - if (character == VK_SPACE) { - return 1; - } - } - - if (character == VK_RETURN) { - character = J_VK_ENTER; - } - (*env)->CallVoidMethod(env, window, sendKeyEventID, - (jint) EVENT_KEY_TYPED, - GetModifiers(), - (jint) -1, - (jchar) character); - return 1; + // i.e., it is the 5th bit of `flags' (which is HIBYTE(HIWORD(lParam))). + return system && ( flags & (1<<5) ) != 0; } -UINT WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers) +UINT WindowsKeyToJavaKey(UINT windowsKey) { - int i, j; + int i, j, javaKey = J_VK_UNDEFINED; // for the general case, use a bi-directional table for (i = 0; keyMapTable[i].windowsKey != 0; i++) { if (keyMapTable[i].windowsKey == windowsKey) { - return keyMapTable[i].javaKey; + javaKey = keyMapTable[i].javaKey; } } - for (j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) { - if (dynamicKeyMapTable[j].windowsKey == windowsKey) { - if (dynamicKeyMapTable[j].javaKey != J_VK_UNDEFINED) { - return dynamicKeyMapTable[j].javaKey; - } else { - break; + if( J_VK_UNDEFINED == javaKey ) { + for (j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) { + if (dynamicKeyMapTable[j].windowsKey == windowsKey) { + if (dynamicKeyMapTable[j].javaKey != J_VK_UNDEFINED) { + javaKey = dynamicKeyMapTable[j].javaKey; + } else { + break; + } } } } - return J_VK_UNDEFINED; +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: WindowsKeyToJavaKey 0x%X -> 0x%X\n", windowsKey, javaKey); +#endif + return javaKey; } -static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, UINT repCnt, - UINT flags, BOOL system) -{ +#ifndef MAPVK_VSC_TO_VK + #define MAPVK_VSC_TO_VK 1 +#endif +#ifndef MAPVK_VK_TO_CHAR + #define MAPVK_VK_TO_CHAR 2 +#endif + +static UINT WmVKey2ShiftedChar(UINT wkey, UINT modifiers) { + UINT c = MapVirtualKey(wkey, MAPVK_VK_TO_CHAR); + if( 0 != ( modifiers & EVENT_SHIFT_MASK ) ) { + return islower(c) ? toupper(c) : c; + } + return isupper(c) ? tolower(c) : c; +} + +static int WmChar(JNIEnv *env, jobject window, UINT character, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { + UINT modifiers = 0, jkey = 0, wkey = 0; + + wkey = MapVirtualKey(scanCode, MAPVK_VSC_TO_VK); + jkey = WindowsKeyToJavaKey(wkey); + modifiers = GetModifiers( IsAltKeyDown(flags, system), 0 ); + + if (character == VK_RETURN) { + character = J_VK_ENTER; + } + + (*env)->CallVoidMethod(env, window, sendKeyEventID, + (jint) EVENT_KEY_TYPED, + modifiers, + (jint) jkey, + (jchar) character); + return 1; +} + +static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { UINT modifiers = 0, jkey = 0, character = -1; if (wkey == VK_PROCESSKEY) { return 1; } - modifiers = GetModifiers(); - jkey = WindowsKeyToJavaKey(wkey, modifiers); + jkey = WindowsKeyToJavaKey(wkey); + modifiers = GetModifiers( IsAltKeyDown(flags, system), jkey ); + character = WmVKey2ShiftedChar(wkey, modifiers); /* character = WindowsKeyToJavaChar(wkey, modifiers, SAVE); @@ -562,7 +583,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, UINT repCnt, if (jkey == J_VK_DELETE) { (*env)->CallVoidMethod(env, window, sendKeyEventID, (jint) EVENT_KEY_TYPED, - GetModifiers(), + modifiers, (jint) -1, (jchar) '\177'); } @@ -570,16 +591,16 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, UINT repCnt, return 0; } -static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, UINT repCnt, - UINT flags, BOOL system) -{ +static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { UINT modifiers = 0, jkey = 0, character = -1; if (wkey == VK_PROCESSKEY) { return 1; } - modifiers = GetModifiers(); - jkey = WindowsKeyToJavaKey(wkey, modifiers); + jkey = WindowsKeyToJavaKey(wkey); + modifiers = GetModifiers( IsAltKeyDown(flags, system), jkey ); + character = WmVKey2ShiftedChar(wkey, modifiers); + /* character = WindowsKeyToJavaChar(wkey, modifiers, SAVE); */ @@ -775,21 +796,15 @@ static void WmSize(JNIEnv *env, jobject window, HWND wnd, UINT type) (*env)->CallVoidMethod(env, window, sizeChangedID, JNI_FALSE, w, h, JNI_FALSE); } -static LRESULT CALLBACK wndProc(HWND wnd, UINT message, - WPARAM wParam, LPARAM lParam) -{ +static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT res = 0; int useDefWindowProc = 0; JNIEnv *env = NULL; jobject window = NULL; BOOL isKeyDown = FALSE; WindowUserData * wud; - -#ifdef DEBUG_KEYS - if ( WM_KEYDOWN == message ) { - STD_PRINT("*** WindowsWindow: wndProc window %p, 0x%X %d/%d\n", wnd, message, (int)LOWORD(lParam), (int)HIWORD(lParam)); - } -#endif + WORD repCnt; + BYTE scanCode, flags; #if !defined(__MINGW64__) && ( defined(UNDER_CE) || _MSC_VER <= 1200 ) wud = (WindowUserData *) GetWindowLong(wnd, GWL_USERDATA); @@ -831,26 +846,57 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, break; case WM_SYSCHAR: - useDefWindowProc = WmChar(env, window, wParam, - LOWORD(lParam), HIWORD(lParam), FALSE); + repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); + repCnt = LOWORD(lParam); +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: windProc WM_SYSCHAR sending window %p -> %p, char 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); +#endif + useDefWindowProc = WmChar(env, window, wParam, repCnt, scanCode, flags, TRUE); + break; + + case WM_SYSKEYDOWN: + repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); + repCnt = LOWORD(lParam); +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: windProc WM_SYSKEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); +#endif + useDefWindowProc = WmKeyDown(env, window, wParam, repCnt, scanCode, flags, TRUE); + break; + + case WM_SYSKEYUP: + repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); + repCnt = LOWORD(lParam); +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: windProc WM_SYSKEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); +#endif + useDefWindowProc = WmKeyUp(env, window, wParam, repCnt, scanCode, flags, TRUE); break; case WM_CHAR: - useDefWindowProc = WmChar(env, window, wParam, - LOWORD(lParam), HIWORD(lParam), TRUE); + repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); + repCnt = LOWORD(lParam); +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: windProc WM_CHAR sending window %p -> %p, char 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); +#endif + useDefWindowProc = WmChar(env, window, wParam, repCnt, scanCode, flags, FALSE); break; case WM_KEYDOWN: + repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); + repCnt = LOWORD(lParam); #ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc sending window %p -> %p, 0x%X %d/%d\n", wnd, window, message, (int)LOWORD(lParam), (int)HIWORD(lParam)); + STD_PRINT("*** WindowsWindow: windProc WM_KEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); #endif - useDefWindowProc = WmKeyDown(env, window, wParam, - LOWORD(lParam), HIWORD(lParam), FALSE); + useDefWindowProc = WmKeyDown(env, window, wParam, repCnt, scanCode, flags, FALSE); break; case WM_KEYUP: - useDefWindowProc = WmKeyUp(env, window, wParam, - LOWORD(lParam), HIWORD(lParam), FALSE); + repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); + repCnt = LOWORD(lParam); +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: windProc WM_KEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); +#endif + useDefWindowProc = WmKeyUp(env, window, wParam, repCnt, scanCode, flags, FALSE); break; case WM_SIZE: @@ -873,7 +919,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 1, (jint) 0); useDefWindowProc = 1; @@ -882,7 +928,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, case WM_LBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 1, (jint) 0); useDefWindowProc = 1; @@ -893,7 +939,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 2, (jint) 0); useDefWindowProc = 1; @@ -902,7 +948,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, case WM_MBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 2, (jint) 0); useDefWindowProc = 1; @@ -913,7 +959,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 3, (jint) 0); useDefWindowProc = 1; @@ -922,7 +968,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, case WM_RBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 3, (jint) 0); useDefWindowProc = 1; @@ -931,7 +977,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, case WM_MOUSEMOVE: (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 0, (jint) 0); useDefWindowProc = 1; @@ -956,7 +1002,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, ScreenToClient(wnd, &eventPt); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_WHEEL_MOVED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) eventPt.x, (jint) eventPt.y, (jint) 1, (jint) (GET_WHEEL_DELTA_WPARAM(wParam)/120.0f)); useDefWindowProc = 1; @@ -1035,11 +1081,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_DisplayDriver_DispatchMes // DBG_PRINT("*** WindowsWindow.DispatchMessages0: thread 0x%X - gotOne %d\n", (int)GetCurrentThreadId(), (int)gotOne); if (gotOne) { ++i; -#ifdef DEBUG_KEYS - if(WM_KEYDOWN == msg.message) { - STD_PRINT("*** WindowsWindow: DispatchMessages window %p, 0x%X %d/%d\n", msg.hwnd, msg.message, (int)LOWORD(msg.lParam), (int)HIWORD(msg.lParam)); - } -#endif TranslateMessage(&msg); DispatchMessage(&msg); } diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 89cf75043..3f34a16b6 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -154,24 +154,24 @@ static jint X11KeySym2NewtVKey(KeySym keySym) { return keySym; } -static jint X11InputState2NewtModifiers(unsigned int xstate) { +static jint X11InputState2NewtModifiers(unsigned int xstate, KeySym keySym) { jint modifiers = 0; - if ((ControlMask & xstate) != 0) { + if ( (ControlMask & xstate) != 0 || J_VK_CONTROL == keySym ) { modifiers |= EVENT_CTRL_MASK; } - if ((ShiftMask & xstate) != 0) { + if ( (ShiftMask & xstate) != 0 || J_VK_SHIFT == keySym ) { modifiers |= EVENT_SHIFT_MASK; } - if ((Mod1Mask & xstate) != 0) { + if ( (Mod1Mask & xstate) != 0 || J_VK_ALT == keySym ) { modifiers |= EVENT_ALT_MASK; } - if ((Button1Mask & xstate) != 0) { + if ( (Button1Mask & xstate) != 0 ) { modifiers |= EVENT_BUTTON1_MASK; } - if ((Button2Mask & xstate) != 0) { + if ( (Button2Mask & xstate) != 0 ) { modifiers |= EVENT_BUTTON2_MASK; } - if ((Button3Mask & xstate) != 0) { + if ( (Button3Mask & xstate) != 0 ) { modifiers |= EVENT_BUTTON3_MASK; } @@ -397,13 +397,13 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage keyChar=0; keySym = X11KeySym2NewtVKey(keySym); } - modifiers |= X11InputState2NewtModifiers(evt.xkey.state) | autoRepeatModifiers; + modifiers |= X11InputState2NewtModifiers(evt.xkey.state, keySym) | autoRepeatModifiers; break; case ButtonPress: case ButtonRelease: case MotionNotify: - modifiers |= X11InputState2NewtModifiers(evt.xbutton.state); + modifiers |= X11InputState2NewtModifiers(evt.xbutton.state, 0); break; default: @@ -472,23 +472,23 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage case KeyPress: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_PRESSED, - modifiers, keySym, (jchar) -1); + modifiers, keySym, (jchar) keyChar); #else (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_PRESSED, - modifiers, keySym, (jchar) -1); + modifiers, keySym, (jchar) keyChar); #endif break; case KeyRelease: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED, - modifiers, keySym, (jchar) -1); + modifiers, keySym, (jchar) keyChar); (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED, modifiers, keySym, (jchar) keyChar); #else (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED, - modifiers, keySym, (jchar) -1); + modifiers, keySym, (jchar) keyChar); (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED, modifiers, keySym, (jchar) keyChar); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java deleted file mode 100644 index 37debfcc2..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java +++ /dev/null @@ -1,259 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import org.junit.After; -import org.junit.Assert; -import org.junit.AfterClass; -import org.junit.Assume; -import org.junit.Before; - -import java.awt.AWTException; -import java.awt.BorderLayout; -import java.awt.Robot; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.EventObject; -import java.util.List; - -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.swing.JFrame; - -import java.io.IOException; - -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.newt.awt.NewtCanvasAWT; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; - -import com.jogamp.opengl.test.junit.util.*; -import com.jogamp.opengl.test.junit.util.NEWTKeyUtil.CodeSeg; - -/** - * Testing key event order incl. auto-repeat (Bug 601) - * - *

- * Note Event order: - *

    - *
  1. {@link #EVENT_KEY_PRESSED}
  2. - *
  3. {@link #EVENT_KEY_RELEASED}
  4. - *
  5. {@link #EVENT_KEY_TYPED}
  6. - *
- *

- */ -public class TestNewtKeyCodeAWT extends UITestCase { - static int width, height; - static long durationPerTest = 100; - static long awtWaitTimeout = 1000; - - static GLCapabilities glCaps; - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - glCaps = new GLCapabilities(null); - } - - @AfterClass - public static void release() { - } - - @Before - public void initTest() { - } - - @After - public void releaseTest() { - } - - @Test - public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException { - GLWindow glWindow = GLWindow.create(glCaps); - glWindow.setSize(width, height); - glWindow.setVisible(true); - - testImpl(glWindow); - - glWindow.destroy(); - } - - // @Test - public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { - GLWindow glWindow = GLWindow.create(glCaps); - - // Wrap the window in a canvas. - final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); - - // Add the canvas to a frame, and make it all visible. - final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); - frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); - frame1.setSize(width, height); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame1.setVisible(true); - } } ); - - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); - - testImpl(glWindow); - - try { - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame1.setVisible(false); - frame1.dispose(); - }}); - } catch( Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); - } - glWindow.destroy(); - } - - static CodeSeg[] codeSegments = new CodeSeg[] { - new CodeSeg(0x008, 0x008, "bs"), - // new CodeSeg(0x009, 0x009, "tab"), // TAB functions as focus traversal key - new CodeSeg(0x00a, 0x00a, "cr"), - new CodeSeg(0x010, 0x011, "shift, ctrl"), // single alt n/a on windows - new CodeSeg(0x01B, 0x01B, "esc"), - new CodeSeg(0x020, 0x024, "space, up, down, end, home"), - new CodeSeg(0x025, 0x028, "cursor"), - new CodeSeg(0x02C, 0x02F, ", - . /"), - new CodeSeg(0x030, 0x039, "0 - 9"), - new CodeSeg(0x03B, 0x03B, ";"), - new CodeSeg(0x03D, 0x03D, "="), - new CodeSeg(0x041, 0x05A, "a - z"), - new CodeSeg(0x05B, 0x05D, "[ \\ ]"), - // new CodeSeg(0x060, 0x06B, "numpad1"), // can be mapped to normal keycodes - // new CodeSeg(0x06D, 0x06F, "numpad2"), // can be mapped to normal keycodes - new CodeSeg(0x07F, 0x07F, "del"), - // new CodeSeg(0x090, 0x091, "num lock, scroll lock"), - // new CodeSeg(0x070, 0x07B, "F1 - F12"), - // new CodeSeg(0x09A, 0x09D, "prt ins hlp meta"), - new CodeSeg(0x0C0, 0x0C0, "back quote"), - new CodeSeg(0x0DE, 0x0DE, "quote"), - // new CodeSeg(0x0E0, 0x0E3, "cursor kp"), - // new CodeSeg(0x080, 0x08F, "dead-1"), - // new CodeSeg(0x096, 0x0A2, "& ^ \" < > { }"), - // new CodeSeg(0x200, 0x20D, "extra-2"), // @ ; .. - }; - - static void testKeyCode(Robot robot, NEWTKeyAdapter keyAdapter) { - final List> cse = new ArrayList>(); - final List queue = keyAdapter.getQueued(); - - for(int i=0; i events = new ArrayList(queue); - cse.add(events); - } - Assert.assertEquals("KeyCode impl. incomplete", true, NEWTKeyUtil.validateKeyCode(codeSegments, cse, true)); - } - - void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { - final Robot robot = new Robot(); - robot.setAutoWaitForIdle(true); - - GLEventListener demo1 = new RedSquareES2(); - TestListenerCom01AWT.setDemoFields(demo1, glWindow, false); - glWindow.addGLEventListener(demo1); - - // NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); - // glWindow.addWindowListener(glWindow1FA); - NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); - glWindow1KA.setVerbose(false); - glWindow.addKeyListener(glWindow1KA); - - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true)); - - // Continuous animation .. - Animator animator = new Animator(glWindow); - animator.start(); - - Thread.sleep(durationPerTest); // manual testing - - AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic - AWTRobotUtil.requestFocus(robot, glWindow); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input - glWindow1KA.reset(); - - // - // Test the key event order w/o auto-repeat - // - testKeyCode(robot, glWindow1KA); - - // Remove listeners to avoid logging during dispose/destroy. - glWindow.removeKeyListener(glWindow1KA); - - // Shutdown the test. - animator.stop(); - } - - static int atoi(String a) { - int i=0; - try { - i = Integer.parseInt(a); - } catch (Exception ex) { ex.printStackTrace(); } - return i; - } - - public static void main(String args[]) throws IOException { - for(int i=0; i queue = keyAdapter.getQueued(); + int i=0; + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, 0, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, 0, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, 0, KeyEvent.VK_P); + + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, modifierKey); + } + + static void testKeyCodeAllModifierV1(Robot robot, NEWTKeyAdapter keyAdapter) { + final int m1k = KeyEvent.VK_ALT; + final int m1m = InputEvent.ALT_MASK; + final int m2k = KeyEvent.VK_CONTROL; + final int m2m = InputEvent.CTRL_MASK; + final int m3k = KeyEvent.VK_SHIFT; + final int m3m = InputEvent.SHIFT_MASK; + + keyAdapter.reset(); + AWTRobotUtil.keyPress(0, robot, true, m1k, 10); // press MOD1 + AWTRobotUtil.keyPress(0, robot, true, m2k, 10); // press MOD2 + AWTRobotUtil.keyPress(0, robot, true, m3k, 10); // press MOD3 + AWTRobotUtil.keyPress(0, robot, true, KeyEvent.VK_P, 10); // press P + + AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 100); // release+typed P + AWTRobotUtil.keyPress(0, robot, false, m3k, 10); // release+typed MOD + AWTRobotUtil.keyPress(0, robot, false, m2k, 10); // release+typed MOD + AWTRobotUtil.keyPress(0, robot, false, m1k, 10); // release+typed MOD + + robot.waitForIdle(); + for(int j=0; j < 10 && keyAdapter.getQueueSize() < 3*4; j++) { // wait until events are collected + robot.delay(100); + } + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 3*4, 0); + + final List queue = keyAdapter.getQueued(); + int i=0; + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, m3k); + + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_P); + + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, m3k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m, m2k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m, m1k); + } + + void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { + final Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + + GLEventListener demo1 = new RedSquareES2(); + TestListenerCom01AWT.setDemoFields(demo1, glWindow, false); + glWindow.addGLEventListener(demo1); + + // NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); + // glWindow.addWindowListener(glWindow1FA); + NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); + glWindow1KA.setVerbose(false); + glWindow.addKeyListener(glWindow1KA); + + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true)); + + // Continuous animation .. + Animator animator = new Animator(glWindow); + animator.start(); + + Thread.sleep(durationPerTest); // manual testing + + AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic + AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input + glWindow1KA.reset(); + + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_ALT, InputEvent.ALT_MASK); + + testKeyCodeAllModifierV1(robot, glWindow1KA); + + // Remove listeners to avoid logging during dispose/destroy. + glWindow.removeKeyListener(glWindow1KA); + + // Shutdown the test. + animator.stop(); + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i { }"), + // new CodeSeg(0x200, 0x20D, "extra-2"), // @ ; .. + }; + + static void testKeyCodes(Robot robot, NEWTKeyAdapter keyAdapter) { + final List> cse = new ArrayList>(); + + for(int i=0; i events = new ArrayList(keyAdapter.getQueued()); + cse.add(events); + } + Assert.assertEquals("KeyCode impl. incomplete", true, NEWTKeyUtil.validateKeyCodes(codeSegments, cse, true)); + } + + void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { + final Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + + GLEventListener demo1 = new RedSquareES2(); + TestListenerCom01AWT.setDemoFields(demo1, glWindow, false); + glWindow.addGLEventListener(demo1); + + // NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); + // glWindow.addWindowListener(glWindow1FA); + NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); + glWindow1KA.setVerbose(false); + glWindow.addKeyListener(glWindow1KA); + + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true)); + + // Continuous animation .. + Animator animator = new Animator(glWindow); + animator.start(); + + Thread.sleep(durationPerTest); // manual testing + + AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic + AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input + glWindow1KA.reset(); + + testKeyCodes(robot, glWindow1KA); + + // Remove listeners to avoid logging during dispose/destroy. + glWindow.removeKeyListener(glWindow1KA); + + // Shutdown the test. + animator.stop(); + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i keyEvents = keyAdapter.getQueued(); int firstIdx = 0; for(int i=0; i= minCodeCount ); + Assert.assertTrue("AR Test didn't collect enough key events: required min "+minCodeCount+", received "+(keyAdapter.getQueueSize()-firstIdx)+", "+keyAdapter.getQueued(), + keyAdapter.getQueueSize() >= minCodeCount ); + final List keyEvents = keyAdapter.getQueued(); first[i][0] = (KeyEvent) keyEvents.get(firstIdx+0); first[i][1] = (KeyEvent) keyEvents.get(firstIdx+1); first[i][2] = (KeyEvent) keyEvents.get(firstIdx+2); @@ -184,22 +184,27 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { System.err.println("+++ KEY Event Auto-Repeat END Input Loop: "+i); // add a pair of normal press/release in between auto-repeat! + firstIdx = keyEvents.size(); AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_B, 10); robot.waitForIdle(); AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_B, 250); robot.waitForIdle(); + for(int j=0; j < 10 && keyAdapter.getQueueSize() < firstIdx+3; j++) { // wait until events are collected + robot.delay(100); + } firstIdx = keyEvents.size(); } // dumpKeyEvents(keyEvents); - + final List keyEvents = keyAdapter.getQueued(); NEWTKeyUtil.validateKeyEventOrder(keyEvents); final boolean hasAR = 0 < keyAdapter.getKeyPressedCount(true) ; - Assert.assertEquals("Key event count not multiple of 3", 0, keyEvents.size()%3); - final int expTotal = keyEvents.size()/3; - final int expAR = hasAR ? expTotal - loops - loops : 0; - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, expTotal, expAR); + { + final int expTotal = keyEvents.size(); + final int expAR = hasAR ? expTotal - 3 * 2 * loops : 0; // per loop: 3 for non AR events and 3 for non AR 'B' + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, expTotal, expAR); + } if( !hasAR ) { System.err.println("No AUTO-REPEAT triggered by AWT Robot .. aborting test analysis"); @@ -266,7 +271,7 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { Thread.sleep(durationPerTest); // manual testing AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic - AWTRobotUtil.requestFocus(robot, glWindow); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input + AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input glWindow1KA.reset(); // diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java index 11f552ecb..cf5016173 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java @@ -56,7 +56,7 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; import com.jogamp.opengl.test.junit.util.*; /** - * Testing key event order incl. auto-repeat (Bug 601) + * Testing key event order excl. auto-repeat (Bug 601) * *

* Note Event order: @@ -167,7 +167,7 @@ public class TestNewtKeyEventOrderAWT extends UITestCase { NEWTKeyUtil.validateKeyEventOrder(keyAdapter.getQueued()); - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 6*loops, 0); + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 6*3*loops, 0); } void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { @@ -191,7 +191,7 @@ public class TestNewtKeyEventOrderAWT extends UITestCase { Thread.sleep(durationPerTest); // manual testing AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic - AWTRobotUtil.requestFocus(robot, glWindow); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input + AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input glWindow1KA.reset(); // diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java index 6ebaf2707..c27513905 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java @@ -151,7 +151,7 @@ public class TestNewtKeyPressReleaseUnmaskRepeatAWT extends UITestCase { Thread.sleep(durationPerTest); // manual testing AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic - AWTRobotUtil.requestFocus(robot, glWindow); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input + AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input // Remove listeners to avoid logging during dispose/destroy. glWindow.removeKeyListener(simpleKeyPressRelease); diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java index a9fa373b5..837ba5da1 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java @@ -46,33 +46,37 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent reset(); } - public void setVerbose(boolean v) { verbose = false; } + public synchronized void setVerbose(boolean v) { verbose = false; } - public boolean isPressed() { + public synchronized boolean isPressed() { return pressed; } - public int getCount() { + public synchronized int getCount() { return keyTyped; } - public int getKeyPressedCount(boolean autoRepeatOnly) { + public synchronized int getKeyPressedCount(boolean autoRepeatOnly) { return keyPressed; } - public int getKeyReleasedCount(boolean autoRepeatOnly) { + public synchronized int getKeyReleasedCount(boolean autoRepeatOnly) { return keyReleased; } - public int getKeyTypedCount(boolean autoRepeatOnly) { + public synchronized int getKeyTypedCount(boolean autoRepeatOnly) { return keyTyped; } - public List getQueued() { + public synchronized List getQueued() { return queue; } - public void reset() { + public synchronized int getQueueSize() { + return queue.size(); + } + + public synchronized void reset() { keyTyped = 0; keyPressed = 0; keyReleased = 0; @@ -80,7 +84,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent queue.clear(); } - public void keyPressed(KeyEvent e) { + public synchronized void keyPressed(KeyEvent e) { pressed = true; keyPressed++; queue.add(e); @@ -89,7 +93,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent } } - public void keyReleased(KeyEvent e) { + public synchronized void keyReleased(KeyEvent e) { pressed = false; keyReleased++; queue.add(e); @@ -98,7 +102,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent } } - public void keyTyped(java.awt.event.KeyEvent e) { + public synchronized void keyTyped(java.awt.event.KeyEvent e) { keyTyped++; queue.add(e); if( verbose ) { diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java index 3334f18ea..31362bfa1 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java @@ -45,27 +45,31 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu reset(); } - public void setVerbose(boolean v) { verbose = false; } + public synchronized void setVerbose(boolean v) { verbose = false; } - public boolean isPressed() { + public synchronized boolean isPressed() { return pressed; } - public int getCount() { + public synchronized int getCount() { return mouseClicked; } - public List getQueued() { + public synchronized List getQueued() { return queue; } - public void reset() { + public synchronized int getQueueSize() { + return queue.size(); + } + + public synchronized void reset() { mouseClicked = 0; pressed = false; queue.clear(); } - public void mousePressed(MouseEvent e) { + public synchronized void mousePressed(MouseEvent e) { pressed = true; queue.add(e); if( verbose ) { @@ -73,7 +77,7 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu } } - public void mouseReleased(MouseEvent e) { + public synchronized void mouseReleased(MouseEvent e) { pressed = false; queue.add(e); if( verbose ) { @@ -81,7 +85,7 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu } } - public void mouseClicked(java.awt.event.MouseEvent e) { + public synchronized void mouseClicked(java.awt.event.MouseEvent e) { mouseClicked+=e.getClickCount(); queue.add(e); if( verbose ) { diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index f48033ae0..e64b3208e 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -196,10 +196,20 @@ public class AWTRobotUtil { /** * requestFocus, if robot is valid, use mouse operation, - * otherwise programatic, ie call requestFocus + * otherwise programmatic, ie call requestFocus */ public static void requestFocus(Robot robot, Object obj) throws AWTException, InterruptedException, InvocationTargetException { + requestFocus(robot, obj, true); + } + + /** + * requestFocus, if robot is valid, use mouse operation, + * otherwise programmatic, ie call requestFocus + */ + public static void requestFocus(Robot robot, Object obj, boolean onTitleBarIfWindow) + throws AWTException, InterruptedException, InvocationTargetException { + final Component comp; final com.jogamp.newt.Window win; @@ -226,7 +236,7 @@ public class AWTRobotUtil { } } else { final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK; - centerMouse(robot, obj, true); + centerMouse(robot, obj, onTitleBarIfWindow); robot.waitForIdle(); robot.mousePress(mouseButton); diff --git a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java index ed7485951..c4078436f 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java @@ -35,6 +35,7 @@ public interface InputEventCountAdapter extends EventCountAdapter { int getCount(); boolean isPressed(); - public List getQueued(); + public List getQueued(); + public int getQueueSize(); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java index 42235254a..f19169b42 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java @@ -50,33 +50,37 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { reset(); } - public void setVerbose(boolean v) { verbose = false; } + public synchronized void setVerbose(boolean v) { verbose = false; } - public boolean isPressed() { + public synchronized boolean isPressed() { return pressed; } - public int getCount() { + public synchronized int getCount() { return keyTyped; } - public int getKeyPressedCount(boolean autoRepeatOnly) { + public synchronized int getKeyPressedCount(boolean autoRepeatOnly) { return autoRepeatOnly ? keyPressedAR: keyPressed; } - public int getKeyReleasedCount(boolean autoRepeatOnly) { + public synchronized int getKeyReleasedCount(boolean autoRepeatOnly) { return autoRepeatOnly ? keyReleasedAR: keyReleased; } - public int getKeyTypedCount(boolean autoRepeatOnly) { + public synchronized int getKeyTypedCount(boolean autoRepeatOnly) { return autoRepeatOnly ? keyTypedAR: keyTyped; } - public List getQueued() { + public synchronized List getQueued() { return queue; } - public void reset() { + public synchronized int getQueueSize() { + return queue.size(); + } + + public synchronized void reset() { keyTyped = 0; keyPressed = 0; keyReleased = 0; @@ -87,7 +91,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { queue.clear(); } - public void keyPressed(KeyEvent e) { + public synchronized void keyPressed(KeyEvent e) { pressed = true; keyPressed++; if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { @@ -99,7 +103,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { } } - public void keyReleased(KeyEvent e) { + public synchronized void keyReleased(KeyEvent e) { pressed = false; keyReleased++; if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { @@ -112,7 +116,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { } @Override - public void keyTyped(KeyEvent e) { + public synchronized void keyTyped(KeyEvent e) { keyTyped++; if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { keyTypedAR++; diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java index 95818845e..e090ed4cf 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java @@ -62,14 +62,14 @@ public class NEWTKeyUtil { return "Code 0x"+Integer.toHexString(code)+" != "+event+" // "+description; } } - + public static void dumpKeyEvents(List keyEvents) { for(int i=0; i> keyEventsList, boolean verbose) { + + public static boolean validateKeyCodes(CodeSeg[] codeSegments, List> keyEventsList, boolean verbose) { final List missCodes = new ArrayList(); int totalCodeCount = 0; boolean res = true; @@ -77,7 +77,7 @@ public class NEWTKeyUtil { final CodeSeg codeSeg = codeSegments[i]; totalCodeCount += codeSeg.max - codeSeg.min + 1; final List keyEvents = keyEventsList.get(i); - res &= validateKeyCode(missCodes, codeSeg, keyEvents, verbose); + res &= validateKeyCodes(missCodes, codeSeg, keyEvents, verbose); } if(verbose) { System.err.println("*** Total KeyCode Misses "+missCodes.size()+" / "+totalCodeCount+", valid "+res); @@ -87,7 +87,7 @@ public class NEWTKeyUtil { } return res; } - public static boolean validateKeyCode(List missCodes, CodeSeg codeSeg, List keyEvents, boolean verbose) { + public static boolean validateKeyCodes(List missCodes, CodeSeg codeSeg, List keyEvents, boolean verbose) { final int codeCount = codeSeg.max - codeSeg.min + 1; int misses = 0; for(int i=0; i keyEvents = keyAdapter.getQueued(); Assert.assertEquals("Key event count not multiple of 3", 0, keyEvents.size()%3); - Assert.assertEquals("Key event count not 3 * press_release_count", 3*expTotalCount, keyEvents.size()); - Assert.assertEquals("Key press count failure", expTotalCount, keyPressed); - Assert.assertEquals("Key press count failure (AR)", expARCount, keyPressedAR); - Assert.assertEquals("Key released count failure", expTotalCount, keyReleased); - Assert.assertEquals("Key released count failure (AR)", expARCount, keyReleasedAR); - Assert.assertEquals("Key typed count failure", expTotalCount, keyTyped); - Assert.assertEquals("Key typed count failure (AR)", expARCount, keyTypedAR); + Assert.assertEquals("Key event count not 3 * press_release_count", expTotalCount, keyEvents.size()); + Assert.assertEquals("Key press count failure", expTotalCount/3, keyPressed); + Assert.assertEquals("Key press count failure (AR)", expARCount/3, keyPressedAR); + Assert.assertEquals("Key released count failure", expTotalCount/3, keyReleased); + Assert.assertEquals("Key released count failure (AR)", expARCount/3, keyReleasedAR); + Assert.assertEquals("Key typed count failure", expTotalCount/3, keyTyped); + Assert.assertEquals("Key typed count failure (AR)", expARCount/3, keyTypedAR); // should be true - always, reaching this point - duh! - Assert.assertEquals(expTotalCount-expARCount, keyPressedNR); - Assert.assertEquals(expTotalCount-expARCount, keyReleasedNR); - Assert.assertEquals(expTotalCount-expARCount, keyTypedNR); + Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyPressedNR); + Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyReleasedNR); + Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyTypedNR); } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java index c77462884..644523782 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java @@ -48,27 +48,31 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda reset(); } - public void setVerbose(boolean v) { verbose = false; } + public synchronized void setVerbose(boolean v) { verbose = false; } - public boolean isPressed() { + public synchronized boolean isPressed() { return pressed; } - public int getCount() { + public synchronized int getCount() { return mouseClicked; } - public List getQueued() { + public synchronized List getQueued() { return queue; } - public void reset() { + public synchronized int getQueueSize() { + return queue.size(); + } + + public synchronized void reset() { mouseClicked = 0; pressed = false; queue.clear(); } - public void mousePressed(MouseEvent e) { + public synchronized void mousePressed(MouseEvent e) { pressed = true; queue.add(e); if( verbose ) { @@ -76,7 +80,7 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda } } - public void mouseReleased(MouseEvent e) { + public synchronized void mouseReleased(MouseEvent e) { pressed = false; queue.add(e); if( verbose ) { @@ -84,7 +88,7 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda } } - public void mouseClicked(MouseEvent e) { + public synchronized void mouseClicked(MouseEvent e) { mouseClicked+=e.getClickCount(); queue.add(e); if( verbose ) { -- cgit v1.2.3 From c135d638fe820457977747e3d45960da64038d53 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 31 Oct 2012 21:52:21 +0100 Subject: NEWT Windows KeyEvent: We have to store the keyChar for typed events, since keyChar from pressed/released may be wrong (Uppercase: SHIFT-1, etc ..) Partially reverts commit: b62e1d027c289877686d6008ea8dd40e4e1541ec --- make/scripts/tests-x64.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java | 10 ++++++++++ src/newt/native/WindowsWindow.c | 6 +++--- 4 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 7de5fe51c..c8bc03017 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -19,7 +19,7 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLPro REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* @@ -37,7 +37,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEven REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodesAWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 05409e819..ef64aa7dd 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -246,7 +246,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -276,7 +276,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index c513b9e84..6aac8617c 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; @@ -266,6 +267,9 @@ public class WindowDriver extends WindowImpl { super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); } } + + /** FIXME: We have to store the keyChar for typed events, since keyChar from pressed/released may be wrong (Uppercase: SHIFT-1, etc ..). */ + private IntIntHashMap typedKeyCode2KeyChar = new IntIntHashMap(KeyEvent.VK_CONTEXT_MENU+1); private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); @@ -282,6 +286,10 @@ public class WindowDriver extends WindowImpl { } keyPressedState.put(keyCode, false); } + final int keyCharTyped = typedKeyCode2KeyChar.put(keyCode, 0); + if( 0 != keyCharTyped ) { + keyChar = (char)keyCharTyped; + } emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); break; @@ -304,6 +312,8 @@ public class WindowDriver extends WindowImpl { modifiers |= InputEvent.AUTOREPEAT_MASK; emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + } else if( 0 != keyCode ) { + typedKeyCode2KeyChar.put(keyCode, keyChar); } break; } diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 2152166e4..e3d5cffa0 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -557,7 +557,7 @@ static int WmChar(JNIEnv *env, jobject window, UINT character, WORD repCnt, BYTE } static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { - UINT modifiers = 0, jkey = 0, character = -1; + UINT modifiers = 0, jkey = 0, character = 0; if (wkey == VK_PROCESSKEY) { return 1; } @@ -584,7 +584,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE s (*env)->CallVoidMethod(env, window, sendKeyEventID, (jint) EVENT_KEY_TYPED, modifiers, - (jint) -1, + (jint) 0, (jchar) '\177'); } @@ -592,7 +592,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE s } static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { - UINT modifiers = 0, jkey = 0, character = -1; + UINT modifiers = 0, jkey = 0, character = 0; if (wkey == VK_PROCESSKEY) { return 1; } -- cgit v1.2.3 From 502847f59ef01c78a85e4ee5453a09d9b83d9a5e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 31 Oct 2012 21:58:36 +0100 Subject: NEWT KeyEvent API doc: Document Windows shift+non-uppecase_char, commit c135d638fe820457977747e3d45960da64038d53 --- src/newt/classes/com/jogamp/newt/event/KeyEvent.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 927c9aa85..289aa31f6 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -73,7 +73,14 @@ public class KeyEvent extends InputEvent this.keyChar=keyChar; } - /** Returns the character matching the {@link #getKeyCode() virtual key code}, if exist. */ + /** + * Returns the character matching the {@link #getKeyCode() virtual key code}, if exist. + *

+ * Disclaimer: Only valid on all platforms at {@link KeyListener#keyTyped(KeyEvent)}. + * Precisely, on the Windows platform we currently cannot deliver the proper character + * in case of shifted keys where no uppercase exists, e.g. 'shift + 1' doesn't produce '!'. + *

+ */ public char getKeyChar() { return keyChar; } -- cgit v1.2.3 From 1f33b196d339006d132fc6adafa345913bc08f53 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 13 Nov 2012 16:57:09 +0100 Subject: NewtVersionActivity: Dump information in logcat --- .../jogamp/newt/driver/android/NewtVersionActivity.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java index a49f1648c..4bcbb104d 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java @@ -60,8 +60,10 @@ public class NewtVersionActivity extends NewtBaseActivity { final ScrollView scroller = new ScrollView(getActivity()); scroller.addView(tv); viewGroup.addView(scroller, new android.widget.FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.TOP|Gravity.LEFT)); - - tv.setText(VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+JoglVersion.getInstance()+Platform.NEWLINE); + + final String info1 = VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+JoglVersion.getInstance()+Platform.NEWLINE; + Log.d(MD.TAG, info1); + tv.setText(info1); // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); @@ -82,9 +84,11 @@ public class NewtVersionActivity extends NewtBaseActivity { sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); sb.append("Chosen: ").append(Platform.NEWLINE); sb.append(drawable.getChosenGLCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); + final String info2 = sb.toString(); + Log.d(MD.TAG, info2); viewGroup.post(new Runnable() { public void run() { - tv.append(sb.toString()); + tv.append(info2); viewGroup.removeView(androidGLView); } } ); } -- cgit v1.2.3 From f24844c5e6c57a43df79224f2d3a89e9720726f7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 23 Nov 2012 09:09:17 +0100 Subject: Fix SWTEDTUtil Bug628: Perform NEWT event dispatching on SWT-EDT, due to possible triggered locking action, i.e. display(). Do the same for AWTEDTUtil. This fix actually clarifies the annotated FIXME :) --- make/scripts/tests.sh | 3 ++- src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java | 15 +++++++++------ src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 11 +++++------ 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index fc9b47c69..a732d78fa 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -279,7 +279,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* @@ -372,6 +372,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock $* # # newt.awt (testawt) diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java index d4b83d891..d40aa18cf 100644 --- a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java @@ -231,12 +231,15 @@ public class SWTEDTUtil implements EDTUtil { do { // event dispatch if(!shouldStop) { - // FIXME: Determine whether we require to run the - // delivery of events (dispatch) on AWT-EDT. - // Since the WindowDriver itself delivers all Window related events, - // this shall not be required. - // AWTEDTExecutor.singleton.invoke(true, dispatchMessages); - dispatchMessages.run(); + // EDT invoke thread is SWT-EDT, + // hence dispatching is required to run on SWT-EDT as well. + // Otherwise a deadlock may happen due to dispatched event's + // triggering a locking action. + if ( !swtDisplay.isDisposed() ) { + swtDisplay.syncExec(dispatchMessages); + } else { + dispatchMessages.run(); + } } // wait synchronized(sync) { diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 8771f5c74..6fa053dd3 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -215,12 +215,11 @@ public class AWTEDTUtil implements EDTUtil { do { // event dispatch if(!shouldStop) { - // FIXME: Determine whether we require to run the - // delivery of events (dispatch) on AWT-EDT. - // Since the WindowDriver itself delivers all Window related events, - // this shall not be required. - // AWTEDTExecutor.singleton.invoke(true, dispatchMessages); - dispatchMessages.run(); + // EDT invoke thread is AWT-EDT, + // hence dispatching is required to run on AWT-EDT as well. + // Otherwise a deadlock may happen due to dispatched event's + // triggering a locking action. + AWTEDTExecutor.singleton.invoke(true, dispatchMessages); } // wait synchronized(sync) { -- cgit v1.2.3 From b6fa407d4bf19ef9fe387454b5eeca68853532b9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 25 Nov 2012 14:58:05 +0100 Subject: SWTEDTUtil/AWTEDTUtil: Fix deadlock situation in waitUntilStopped(), etc - wrap task execution (or enqueing) into status-sync 'edtLock' This fixes the disparity w/ DefaultEDTUtil, i.e. aligns it's implementation/semantics. --- .../classes/com/jogamp/newt/swt/SWTEDTUtil.java | 24 ++++++++++++++-------- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 2 +- .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 14 ++++++++----- 3 files changed, 25 insertions(+), 15 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java index d40aa18cf..d08fefa29 100644 --- a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java @@ -154,17 +154,23 @@ public class SWTEDTUtil implements EDTUtil { // Thread.dumpStack(); } } - - // start if should not stop && not started yet - if( !stop && !nedt.isRunning() ) { - startImpl(); + if( isCurrentThreadEDT() ) { + task.run(); + wait = false; // running in same thread (EDT) -> no wait + } else if( swtDisplay.isDisposed() ) { + wait = false; // drop task, SWT disposed + } else { + // start if should not stop && not started yet + if( !stop && !nedt.isRunning() ) { + startImpl(); + } + if(wait) { + swtDisplay.syncExec(task); + } else { + swtDisplay.asyncExec(task); + } } } - if(wait) { - swtDisplay.syncExec(task); - } else { - swtDisplay.asyncExec(task); - } } @Override diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index 18418a8dc..98987ef96 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -150,7 +150,7 @@ public class DefaultEDTUtil implements EDTUtil { System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+edt); Thread.dumpStack(); } - return; + return; } // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); // Thread.dumpStack(); diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 6fa053dd3..01b5ad8a4 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -142,13 +142,17 @@ public class AWTEDTUtil implements EDTUtil { // Thread.dumpStack(); } } - - // start if should not stop && not started yet - if( !stop && !nedt.isRunning() ) { - startImpl(); + if( isCurrentThreadEDT() ) { + task.run(); + wait = false; // running in same thread (EDT) -> no wait + } else { + // start if should not stop && not started yet + if( !stop && !nedt.isRunning() ) { + startImpl(); + } + AWTEDTExecutor.singleton.invoke(wait, task); } } - AWTEDTExecutor.singleton.invoke(wait, task); } @Override -- cgit v1.2.3 From 8cf694c1424277e6358039a964ecd75c54cf9af9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 26 Nov 2012 18:15:59 +0100 Subject: SWTAccessor: OS_gtk_widget_unrealize optional (SWT 4.3) ; decorate PrivilegedAction for static initSingleton block (SWTAccessor, NewtFactory, NativeWindowFactory) --- .../com/jogamp/nativewindow/swt/SWTAccessor.java | 18 +++++++++++++++--- .../javax/media/nativewindow/NativeWindowFactory.java | 19 ++++++++++++++----- src/newt/classes/com/jogamp/newt/NewtFactory.java | 13 +++++++++++-- 3 files changed, 40 insertions(+), 10 deletions(-) (limited to 'src/newt/classes') diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 7be747ff5..fca132f3f 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -30,6 +30,8 @@ package com.jogamp.nativewindow.swt; import com.jogamp.common.os.Platform; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedAction; import org.eclipse.swt.graphics.GCData; import org.eclipse.swt.widgets.Control; @@ -70,7 +72,7 @@ public class SWTAccessor { static final String str_OS_gtk_class = "org.eclipse.swt.internal.gtk.OS"; static final Class OS_gtk_class; static final Method OS_gtk_widget_realize; - static final Method OS_gtk_widget_unrealize; + static final Method OS_gtk_widget_unrealize; // optional (removed in SWT 4.3) static final Method OS_GTK_WIDGET_WINDOW; static final Method OS_gdk_x11_drawable_get_xdisplay; static final Method OS_gdk_x11_drawable_get_xid; @@ -83,6 +85,12 @@ public class SWTAccessor { static { Field f = null; + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + NativeWindowFactory.initSingleton(); // last resort .. + return null; + } } ); + final String nwt = NativeWindowFactory.getNativeWindowType(false); if(NativeWindowFactory.TYPE_MACOSX != nwt ) { @@ -127,14 +135,18 @@ public class SWTAccessor { Method m1=null, m2=null, m3=null, m4=null, m5=null; Class handleType = swt_uses_long_handles ? long.class : int.class ; if( NativeWindowFactory.TYPE_X11 == nwt ) { + // mandatory try { c = ReflectionUtil.getClass(str_OS_gtk_class, false, SWTAccessor.class.getClassLoader()); m1 = c.getDeclaredMethod(str_gtk_widget_realize, handleType); - m2 = c.getDeclaredMethod(str_gtk_widget_unrealize, handleType); m3 = c.getDeclaredMethod(str_GTK_WIDGET_WINDOW, handleType); m4 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xdisplay, handleType); m5 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xid, handleType); } catch (Exception ex) { throw new NativeWindowException(ex); } + // optional + try { + m2 = c.getDeclaredMethod(str_gtk_widget_unrealize, handleType); + } catch (Exception ex) { } } OS_gtk_class = c; OS_gtk_widget_realize = m1; @@ -197,7 +209,7 @@ public class SWTAccessor { public void run() { if(realize) { callStaticMethodL2V(OS_gtk_widget_realize, handle); - } else { + } else if(null != OS_gtk_widget_unrealize) { callStaticMethodL2V(OS_gtk_widget_unrealize, handle); } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 179610b25..d7f28a986 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -148,8 +148,18 @@ public abstract class NativeWindowFactory { } static { - Platform.initSingleton(); - DEBUG = Debug.debug("NativeWindow"); + final boolean[] _DEBUG = new boolean[] { false }; + final String[] _tmp = new String[] { null }; + + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + Platform.initSingleton(); // last resort .. + _DEBUG[0] = Debug.debug("NativeWindow"); + _tmp[0] = Debug.getProperty("nativewindow.ws.name", true); + return null; + } } ) ; + + DEBUG = _DEBUG[0]; if(DEBUG) { System.err.println(Thread.currentThread().getName()+" - Info: NativeWindowFactory."); // Thread.dumpStack(); @@ -157,11 +167,10 @@ public abstract class NativeWindowFactory { // Gather the windowing TK first nativeWindowingTypePure = _getNativeWindowingType(); - final String tmp = Debug.getProperty("nativewindow.ws.name", true); - if(null==tmp || tmp.length()==0) { + if(null==_tmp[0] || _tmp[0].length()==0) { nativeWindowingTypeCustom = nativeWindowingTypePure; } else { - nativeWindowingTypeCustom = tmp.intern(); // canonical representation + nativeWindowingTypeCustom = _tmp[0].intern(); // canonical representation } } diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 1bf47f4aa..b3e904310 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -34,6 +34,9 @@ package com.jogamp.newt; +import java.security.AccessController; +import java.security.PrivilegedAction; + import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; @@ -41,6 +44,8 @@ import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowFactory; +import com.jogamp.common.os.Platform; + import jogamp.newt.Debug; import jogamp.newt.DisplayImpl; import jogamp.newt.ScreenImpl; @@ -54,8 +59,12 @@ public class NewtFactory { // Work-around for initialization order problems on Mac OS X // between native Newt and (apparently) Fmod static { - NativeWindowFactory.initSingleton(); // last resort .. - WindowImpl.init(NativeWindowFactory.getNativeWindowType(true)); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + NativeWindowFactory.initSingleton(); // last resort .. + WindowImpl.init(NativeWindowFactory.getNativeWindowType(true)); + return null; + } } ); } public static Class getCustomClass(String packageName, String classBaseName) { -- cgit v1.2.3 From 17dd761d7c2b224f0505a399bf4ecb18634e9250 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 27 Nov 2012 01:55:10 +0100 Subject: SWTEDTUtil/AWTEDTUtil: Fix deadlock situations ; Cleanup TestNewtCanvasSWTBug628ResizeDeadlock - Fix deadlock situation in waitUntilStopped/Idle(), skip if on AWT/SWT EDT - Use RunnableTask for sync task invocation, don't block AWT/SWT EDT. - Cleanup TestNewtCanvasSWTBug628ResizeDeadlock (works on OSX as well) --- make/scripts/make.jogl.all.win64.bat | 4 +- make/scripts/tests-linux-x64-junit-swt.sh | 7 + make/scripts/tests-macosx64-junit-swt.sh | 7 + make/scripts/tests-win64-junit-swt.bat | 7 + make/scripts/tests-x64-junit-swt.sh | 7 - make/scripts/tests-x64.bat | 3 +- .../classes/com/jogamp/newt/swt/SWTEDTUtil.java | 89 +++++++---- src/newt/classes/jogamp/newt/DisplayImpl.java | 6 +- .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 77 ++++++--- .../swt/TestNewtCanvasSWTBug628ResizeDeadlock.java | 176 ++++++++++++++------- .../test/junit/jogl/swt/TestNewtCanvasSWTGLn.java | 10 +- 11 files changed, 265 insertions(+), 128 deletions(-) create mode 100644 make/scripts/tests-linux-x64-junit-swt.sh create mode 100644 make/scripts/tests-macosx64-junit-swt.sh create mode 100755 make/scripts/tests-win64-junit-swt.bat delete mode 100644 make/scripts/tests-x64-junit-swt.sh (limited to 'src/newt/classes') diff --git a/make/scripts/make.jogl.all.win64.bat b/make/scripts/make.jogl.all.win64.bat index 7355c6a1a..e2b3a6b80 100755 --- a/make/scripts/make.jogl.all.win64.bat +++ b/make/scripts/make.jogl.all.win64.bat @@ -6,8 +6,8 @@ set ANT_PATH=C:\apache-ant-1.8.2 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;%PATH% -set LIB_GEN=%THISDIR%\lib -set CLASSPATH=.;%THISDIR%\build-win64\classes +REM set LIB_GEN=%THISDIR%\lib +REM set CLASSPATH=.;%THISDIR%\build-win64\classes REM -Dc.compiler.debug=true REM -Dsetup.addNativeOpenMAX=true REM -Dsetup.addNativeKD=true diff --git a/make/scripts/tests-linux-x64-junit-swt.sh b/make/scripts/tests-linux-x64-junit-swt.sh new file mode 100644 index 000000000..421791a19 --- /dev/null +++ b/make/scripts/tests-linux-x64-junit-swt.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +SDIR=`dirname $0` + +. $SDIR/make.jogl.all.linux-x86_64.sh -f build-test.xml junit.run.settings junit.run.swt.awt + + diff --git a/make/scripts/tests-macosx64-junit-swt.sh b/make/scripts/tests-macosx64-junit-swt.sh new file mode 100644 index 000000000..2a6ccd63a --- /dev/null +++ b/make/scripts/tests-macosx64-junit-swt.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +SDIR=`dirname $0` + +. $SDIR/make.jogl.all.macosx.sh -f build-test.xml junit.run.settings junit.run.swt.awt + + diff --git a/make/scripts/tests-win64-junit-swt.bat b/make/scripts/tests-win64-junit-swt.bat new file mode 100755 index 000000000..fbcc5d692 --- /dev/null +++ b/make/scripts/tests-win64-junit-swt.bat @@ -0,0 +1,7 @@ +set THISDIR=%cd% + +set SDIR=%~dp0% + +%SDIR%/make.jogl.all.win64.bat -f build-test.xml junit.run.settings junit.run.swt.awt + + diff --git a/make/scripts/tests-x64-junit-swt.sh b/make/scripts/tests-x64-junit-swt.sh deleted file mode 100644 index 421791a19..000000000 --- a/make/scripts/tests-x64-junit-swt.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash - -SDIR=`dirname $0` - -. $SDIR/make.jogl.all.linux-x86_64.sh -f build-test.xml junit.run.settings junit.run.swt.awt - - diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 7dd00eabe..0266f2bb7 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -56,6 +56,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestP REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT @@ -112,7 +113,7 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java index d08fefa29..42e1c9be5 100644 --- a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java @@ -29,8 +29,11 @@ package com.jogamp.newt.swt; import java.awt.EventQueue; +import javax.media.nativewindow.NativeWindowException; + import jogamp.newt.Debug; +import com.jogamp.common.util.RunnableTask; import com.jogamp.newt.util.EDTUtil; /** @@ -136,38 +139,58 @@ public class SWTEDTUtil implements EDTUtil { if(task == null) { throw new RuntimeException("Null Runnable"); } - synchronized(edtLock) { // lock the EDT status - if( nedt.shouldStop ) { - // drop task .. - if(DEBUG) { - System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt); - Thread.dumpStack(); + Throwable throwable = null; + RunnableTask rTask = null; + Object rTaskLock = new Object(); + synchronized(rTaskLock) { // lock the optional task execution + synchronized(edtLock) { // lock the EDT status + if( nedt.shouldStop ) { + // drop task .. + if(DEBUG) { + System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt); + Thread.dumpStack(); + } + return; } - return; - } - // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); - // Thread.dumpStack(); - if(stop) { - nedt.shouldStop = true; - if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); - // Thread.dumpStack(); + // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); + // Thread.dumpStack(); + if(stop) { + nedt.shouldStop = true; + if(DEBUG) { + System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); + // Thread.dumpStack(); + } + } + if( isCurrentThreadEDT() ) { + task.run(); + wait = false; // running in same thread (EDT) -> no wait + } else if( swtDisplay.isDisposed() ) { + wait = false; // drop task, SWT disposed + } else { + // start if should not stop && not started yet + if( !stop && !nedt.isRunning() ) { + startImpl(); + } + rTask = new RunnableTask(task, + wait ? rTaskLock : null, + true /* always catch and report Exceptions, don't disturb EDT */); + swtDisplay.asyncExec(rTask); } } - if( isCurrentThreadEDT() ) { - task.run(); - wait = false; // running in same thread (EDT) -> no wait - } else if( swtDisplay.isDisposed() ) { - wait = false; // drop task, SWT disposed - } else { - // start if should not stop && not started yet - if( !stop && !nedt.isRunning() ) { - startImpl(); + if( wait ) { + try { + rTaskLock.wait(); // free lock, allow execution of rTask + } catch (InterruptedException ie) { + throwable = ie; } - if(wait) { - swtDisplay.syncExec(task); - } else { - swtDisplay.asyncExec(task); + if(null==throwable) { + throwable = rTask.getThrowable(); + } + if(null!=throwable) { + if(throwable instanceof NativeWindowException) { + throw (NativeWindowException)throwable; + } + throw new RuntimeException(throwable); } } } @@ -175,11 +198,12 @@ public class SWTEDTUtil implements EDTUtil { @Override final public void waitUntilIdle() { - final NewtEventDispatchThread _edt; + final NewtEventDispatchThread _nedt; synchronized(edtLock) { - _edt = nedt; + _nedt = nedt; } - if(!_edt.isRunning() || EventQueue.isDispatchThread() || _edt == Thread.currentThread()) { + final Thread ct = Thread.currentThread(); + if(!_nedt.isRunning() || _nedt == ct || swtDisplay.getThread() == ct) { return; } try { @@ -192,7 +216,8 @@ public class SWTEDTUtil implements EDTUtil { @Override final public void waitUntilStopped() { synchronized(edtLock) { - if(nedt.isRunning() && nedt != Thread.currentThread() ) { + final Thread ct = Thread.currentThread(); + if(nedt.isRunning() && nedt != ct && swtDisplay.getThread() != ct) { while(nedt.isRunning()) { try { edtLock.wait(); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index fbccc5767..317535805 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -366,12 +366,10 @@ public abstract class DisplayImpl extends Display { private ArrayList events = new ArrayList(); private volatile boolean haveEvents = false; - class DispatchMessagesRunnable implements Runnable { + final protected Runnable dispatchMessagesRunnable = new Runnable() { public void run() { DisplayImpl.this.dispatchMessages(); - } - } - protected DispatchMessagesRunnable dispatchMessagesRunnable = new DispatchMessagesRunnable(); + } }; final void dispatchMessage(final NEWTEventTask eventTask) { final NEWTEvent event = eventTask.get(); diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 01b5ad8a4..2175f2190 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -30,6 +30,9 @@ package jogamp.newt.driver.awt; import java.awt.EventQueue; +import javax.media.nativewindow.NativeWindowException; + +import com.jogamp.common.util.RunnableTask; import com.jogamp.newt.util.EDTUtil; import jogamp.common.awt.AWTEDTExecutor; @@ -124,33 +127,57 @@ public class AWTEDTUtil implements EDTUtil { if(task == null) { throw new RuntimeException("Null Runnable"); } - synchronized(edtLock) { // lock the EDT status - if( nedt.shouldStop ) { - // drop task .. - if(DEBUG) { - System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt); - Thread.dumpStack(); + Throwable throwable = null; + RunnableTask rTask = null; + Object rTaskLock = new Object(); + synchronized(rTaskLock) { // lock the optional task execution + synchronized(edtLock) { // lock the EDT status + if( nedt.shouldStop ) { + // drop task .. + if(DEBUG) { + System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt); + Thread.dumpStack(); + } + return; } - return; - } - // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); - // Thread.dumpStack(); - if(stop) { - nedt.shouldStop = true; - if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); - // Thread.dumpStack(); + // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); + // Thread.dumpStack(); + if(stop) { + nedt.shouldStop = true; + if(DEBUG) { + System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); + // Thread.dumpStack(); + } + } + if( isCurrentThreadEDT() ) { + task.run(); + wait = false; // running in same thread (EDT) -> no wait + } else { + // start if should not stop && not started yet + if( !stop && !nedt.isRunning() ) { + startImpl(); + } + rTask = new RunnableTask(task, + wait ? rTaskLock : null, + true /* always catch and report Exceptions, don't disturb EDT */); + AWTEDTExecutor.singleton.invoke(false, rTask); } } - if( isCurrentThreadEDT() ) { - task.run(); - wait = false; // running in same thread (EDT) -> no wait - } else { - // start if should not stop && not started yet - if( !stop && !nedt.isRunning() ) { - startImpl(); + if( wait ) { + try { + rTaskLock.wait(); // free lock, allow execution of rTask + } catch (InterruptedException ie) { + throwable = ie; + } + if(null==throwable) { + throwable = rTask.getThrowable(); + } + if(null!=throwable) { + if(throwable instanceof NativeWindowException) { + throw (NativeWindowException)throwable; + } + throw new RuntimeException(throwable); } - AWTEDTExecutor.singleton.invoke(wait, task); } } } @@ -161,7 +188,7 @@ public class AWTEDTUtil implements EDTUtil { synchronized(edtLock) { _edt = nedt; } - if(!_edt.isRunning() || EventQueue.isDispatchThread() || _edt == Thread.currentThread()) { + if(!_edt.isRunning() || _edt == Thread.currentThread() || EventQueue.isDispatchThread()) { return; } try { @@ -174,7 +201,7 @@ public class AWTEDTUtil implements EDTUtil { @Override final public void waitUntilStopped() { synchronized(edtLock) { - if(nedt.isRunning() && nedt != Thread.currentThread() ) { + if(nedt.isRunning() && nedt != Thread.currentThread() && !EventQueue.isDispatchThread()) { while(nedt.isRunning()) { try { edtLock.wait(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java index 3b5c4267e..9c0762c12 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java @@ -35,12 +35,11 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.swt.SWT ; import org.eclipse.swt.layout.FillLayout ; -import org.eclipse.swt.layout.GridData ; -import org.eclipse.swt.layout.GridLayout ; import org.eclipse.swt.widgets.Composite ; import org.eclipse.swt.widgets.Display ; import org.eclipse.swt.widgets.Shell ; +import org.junit.Assume; import org.junit.Test; import javax.media.opengl.GL ; @@ -52,6 +51,7 @@ import javax.media.opengl.GLProfile; import junit.framework.Assert; +import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow ; @@ -142,7 +142,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { //////////////////////////////////////////////////////////////////////////////// static class ResizeThread extends Thread { - boolean shallStop = false; + volatile boolean shallStop = false; private Shell _shell ; private int _n ; @@ -152,6 +152,26 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { _shell = shell ; } + final Runnable resizeAction = new Runnable() { + public void run() + { + System.err.println("[R-i shallStop "+shallStop+", disposed "+_shell.isDisposed()+"]"); + if( shallStop || _shell.isDisposed() ) { + return; + } + try { + if( _n % 2 == 0 ) { + _shell.setSize( 200, 200 ) ; + } else { + _shell.setSize( 400, 450 ) ; + } + } catch (Exception e0) { + e0.printStackTrace(); + Assert.assertTrue("Deadlock @ setSize: "+e0, false); + } + ++_n ; + } }; + public void run() { // The problem was originally observed by grabbing the lower right @@ -162,33 +182,24 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { // This loop simulates rapid resizing by the user by toggling // the shell back-and-forth between two sizes. - while( !shallStop ) + System.err.println("[R-0 shallStop "+shallStop+", disposed "+_shell.isDisposed()+"]"); + + final Display display = _shell.getDisplay(); + + while( !shallStop && !_shell.isDisposed() ) { try { - _shell.getDisplay().asyncExec( new Runnable() - { - public void run() - { - try { - if( _n % 2 == 0 ) { - _shell.setSize( 200, 200 ) ; - } else { - _shell.setSize( 400, 450 ) ; - } - } catch (Exception e0) { - e0.printStackTrace(); - Assert.assertTrue("Deadlock @ setSize: "+e0, false); - } - ++_n ; - } - } ) ; + System.err.println("[R-n shallStop "+shallStop+", disposed "+_shell.isDisposed()+"]"); + display.asyncExec( resizeAction ); + display.wake(); - Thread.sleep( 50L ) ; + Thread.sleep( 50L ) ; } catch( InterruptedException e ) { break ; } } + System.err.println("*R-Exit* shallStop "+shallStop+", disposed "+_shell.isDisposed()); } } @@ -196,50 +207,101 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { static class KeyfireThread extends Thread { - boolean shallStop = false; + volatile boolean shallStop = false; + Display _display; Robot _robot; int _n = 0; - public KeyfireThread(Robot robot) + public KeyfireThread(Robot robot, Display display) { _robot = robot; + _display = display; } public void run() { + System.err.println("[K-0]"); + while( !shallStop ) { try { + System.err.println("[K-"+_n+"]"); AWTRobotUtil.keyPress(_n, _robot, true, KeyEvent.VK_0, 10); AWTRobotUtil.keyPress(_n, _robot, false, KeyEvent.VK_0, 0); Thread.sleep( 40L ) ; + _n++; + if(!_display.isDisposed()) { + _display.wake(); + } } catch( InterruptedException e ) { break ; } } + System.err.println("*K-Exit*"); } } //////////////////////////////////////////////////////////////////////////////// + private volatile boolean shallStop = false; + + static class SWT_DSC { + Display display; + Shell shell; + Composite composite; + + public void init() { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display = new Display(); + Assert.assertNotNull( display ); + }}); + + display.syncExec(new Runnable() { + public void run() { + shell = new Shell( display ); + Assert.assertNotNull( shell ); + shell.setLayout( new FillLayout() ); + composite = new Composite( shell, SWT.NONE ); + composite.setLayout( new FillLayout() ); + Assert.assertNotNull( composite ); + }}); + } + + public void dispose() { + Assert.assertNotNull( display ); + Assert.assertNotNull( shell ); + Assert.assertNotNull( composite ); + try { + display.syncExec(new Runnable() { + public void run() { + composite.dispose(); + shell.dispose(); + }}); + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display.dispose(); + }}); + } + catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + display = null; + shell = null; + composite = null; + } + } + @Test public void test() throws InterruptedException, AWTException, InvocationTargetException { - final int columnCount = 1; - final Display display = new Display() ; - - final Shell shell = new Shell( display ) ; - shell.setLayout( new FillLayout() ) ; - final Robot robot = new Robot(); - Composite composite = new Composite( shell, SWT.NONE ) ; - { - GridLayout layout = new GridLayout() ; - layout.numColumns = columnCount ; - composite.setLayout( layout ) ; - } - + final SWT_DSC dsc = new SWT_DSC(); + dsc.init(); + final GLWindow glWindow; + final NewtCanvasSWT canvas; { final GLProfile gl2Profile = GLProfile.get( GLProfile.GL2 ) ; GLCapabilities caps = new GLCapabilities( gl2Profile ) ; @@ -252,26 +314,30 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { glWindow.display(); } }); - NewtCanvasSWT canvas = NewtCanvasSWT.create( composite, SWT.NO_BACKGROUND, glWindow ) ; - canvas.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, columnCount, 1 ) ) ; + canvas = NewtCanvasSWT.create( dsc.composite, 0, glWindow ) ; } - shell.setText( "NewtCanvasSWT Resize Bug Demo" ) ; - shell.setSize( 400, 450 ) ; - shell.open() ; - + dsc.display.syncExec( new Runnable() { + public void run() { + dsc.shell.setText( "NewtCanvasSWT Resize Bug Demo" ) ; + dsc.shell.setSize( 400, 450 ) ; + dsc.shell.open() ; + } } ); + AWTRobotUtil.requestFocus(robot, glWindow, false); AWTRobotUtil.setMouseToClientLocation(robot, glWindow, 50, 50); + shallStop = false; + final ResizeThread resizer; { - resizer = new ResizeThread( shell ) ; + resizer = new ResizeThread( dsc.shell ) ; resizer.start() ; } final KeyfireThread keyfire; { - keyfire = new KeyfireThread( robot ) ; + keyfire = new KeyfireThread( robot, dsc.display ) ; keyfire.start() ; } @@ -292,18 +358,15 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { { keyfire.join(); } catch( InterruptedException e ) { } - display.syncExec( new Runnable() { - @Override - public void run() { - shell.dispose(); - } } ); + shallStop = true; + dsc.display.wake(); } } ).start(); } - + try { - while( !shell.isDisposed() ) { - if( !display.readAndDispatch() ) { - display.sleep(); + while( !shallStop && !dsc.display.isDisposed() ) { + if( !dsc.display.readAndDispatch() ) { + dsc.display.sleep(); } } } catch (Exception e0) { @@ -311,7 +374,10 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { Assert.assertTrue("Deadlock @ dispatch: "+e0, false); } - display.dispose() ; + System.err.println("NewtCanvasAWT Dispose"); + canvas.dispose(); + + dsc.dispose(); } public static void main( String[] args ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java index 61caa5ef9..396d219b4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java @@ -93,6 +93,9 @@ public class TestNewtCanvasSWTGLn extends UITestCase { public void run() { display = new Display(); Assert.assertNotNull( display ); + }}); + display.syncExec(new Runnable() { + public void run() { shell = new Shell( display ); Assert.assertNotNull( shell ); shell.setLayout( new FillLayout() ); @@ -108,10 +111,13 @@ public class TestNewtCanvasSWTGLn extends UITestCase { Assert.assertNotNull( shell ); Assert.assertNotNull( composite ); try { - SWTAccessor.invoke(true, new Runnable() { + display.syncExec(new Runnable() { public void run() { composite.dispose(); shell.dispose(); + }}); + SWTAccessor.invoke(true, new Runnable() { + public void run() { display.dispose(); }}); } @@ -149,7 +155,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase { final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( composite, 0, postAttach ? null : glWindow1 ); Assert.assertNotNull( canvas1 ); - SWTAccessor.invoke(true, new Runnable() { + display.syncExec( new Runnable() { public void run() { shell.setText( getSimpleTestName(".") ); shell.setSize( 640, 480 ); -- cgit v1.2.3 From 03d74338497130f8100272803cae475043d8ceee Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 29 Nov 2012 00:26:11 +0100 Subject: NewtCanvasSWT: Add DisposeListener --- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 525225804..b56958303 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -49,8 +49,10 @@ import jogamp.nativewindow.macosx.OSXUtil; import jogamp.newt.Debug; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Rectangle; @@ -142,12 +144,23 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } }); - addControlListener(new ControlAdapter() { + addControlListener(new ControlListener() { + @Override + public void controlMoved(ControlEvent e) { + } @Override public void controlResized(final ControlEvent arg0) { updateSizeCheck(); } }); + + addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + NewtCanvasSWT.this.dispose(); + } + }); + } /** assumes nativeWindow == null ! */ @@ -160,7 +173,8 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if(0 >= nClientArea.width || 0 >= nClientArea.height) { return false; } - + screen.getDevice().open(); + /* Native handle for the control, used to associate with GLContext */ final long nativeWindowHandle = SWTAccessor.getWindowHandle(this); final int visualID = SWTAccessor.getNativeVisualID(screen.getDevice(), nativeWindowHandle); @@ -230,6 +244,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { newtChild.destroy(); newtChild = null; } + screen.getDevice().close(); nativeWindow = null; super.dispose(); } -- cgit v1.2.3 From 811e3791b98fea0dfa3b7d301cb532c54df8dc82 Mon Sep 17 00:00:00 2001 From: rhatcher Date: Thu, 29 Nov 2012 09:11:07 -0600 Subject: Fix for JOGL bug 629, and added new unit tests. The change to AWTNewtEventFactory appears to fix the original issue for AWTCanvas instances, and the TestNewtEventModifiersAWTCanvas appears to work ok too. However, there are still issues with NewtCanvasAWT and NewtCanvasSWT instances. These might be problems in the test code, but there's also a good chance there are still issues in the NEWT event delivery infrastructure. For the time being I recommend that only TestNewtEventModifiersAWTCanvas be included in routine unit tests. The tests are defined in TestNewtEventModifiers, and the remaining test classes extend it to define how the window and associated GL drawing surface are created. File ModifierMappings.txt is simply informational, and shows how the modifier bits are laid out between AWT and NEWT. This possibly should have been a spreadsheet. --- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 122 +++- .../test/junit/newt/event/ModifierMappings.txt | 37 ++ .../junit/newt/event/TestNewtEventModifiers.java | 738 +++++++++++++++++++++ .../event/TestNewtEventModifiersAWTCanvas.java | 96 +++ .../event/TestNewtEventModifiersNewtCanvasAWT.java | 111 ++++ .../event/TestNewtEventModifiersNewtCanvasSWT.java | 156 +++++ 6 files changed, 1258 insertions(+), 2 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index cb70da13f..b8ab3176a 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -72,6 +72,58 @@ public class AWTNewtEventFactory { eventTypeAWT2NEWT = map; } + // Define the button state masks we'll check based on what + // the AWT says is available. + + private static int awtButtonMasks[] ; + private static int newtButtonMasks[] ; + + static { + + int numButtonMasks ; + + if (java.awt.Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()) { + numButtonMasks = java.awt.MouseInfo.getNumberOfButtons() ; + } else { + numButtonMasks = 3 ; + } + + if (numButtonMasks > com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER) { + numButtonMasks = com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ; + } + + // There is an assumption in awtModifiers2Newt(int,int,boolean) + // that the awtButtonMasks and newtButtonMasks are peers, i.e. + // a given index refers to the same button in each array. + + awtButtonMasks = new int[numButtonMasks] ; + for (int n = 0 ; n < awtButtonMasks.length ; ++n) { + awtButtonMasks[n] = java.awt.event.InputEvent.getMaskForButton(n+1) ; + } + + newtButtonMasks = new int[numButtonMasks] ; + for (int n = 0 ; n < newtButtonMasks.length ; ++n) { + newtButtonMasks[n] = com.jogamp.newt.event.InputEvent.getButtonMask(n+1) ; + } + } + + /** + * Converts the specified set of AWT event modifiers to the equivalent + * NEWT event modifiers. This method doesn't pay attention to the AWT + * button modifier bits explicitly even though there is a direct + * association in the AWT InputEvent class between BUTTON2_MASK and + * ALT_MASK, and BUTTON3_MASK and META_MASK. Instead the current + * button state is picked up from the bits in the extended modifiers. + * If you need the button bits too, then call + * {@link #awtModifiers2Newt(int,int,boolean)} instead. + * + * @param awtMods + * The AWT event modifiers. + * + * @param mouseHint + * Not used currently. + */ + public static final int awtModifiers2Newt(int awtMods, boolean mouseHint) { int newtMods = 0; if ((awtMods & java.awt.event.InputEvent.SHIFT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; @@ -79,9 +131,75 @@ public class AWTNewtEventFactory { if ((awtMods & java.awt.event.InputEvent.META_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; if ((awtMods & java.awt.event.InputEvent.ALT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK; if ((awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK; + + // The BUTTON1_MASK, BUTTON2_MASK, and BUTTON3_MASK bits are + // being ignored intentionally. The AWT docs say that the + // BUTTON1_DOWN_MASK etc bits in the extended modifiers are + // the preferred place to check current button state. + return newtMods; } + + /** + * Converts the specified set of AWT event modifiers and extended event + * modifiers to the equivalent NEWT event modifiers. + * + * @param awtMods + * The AWT event modifiers. + * + * @param awtModsEx + * The AWT extended event modifiers. + * + * @param mouseHint + * Not used currently. + */ + + public static final int awtModifiers2Newt(final int awtMods, final int awtModsEx, final boolean mouseHint) { + int newtMods = 0; + + //System.err.println( ">>>> AWT modifiers:") ; + //_printAwtModifiers( awtMods, awtModsEx ) ; + //System.err.println( ">>>> END AWT modifiers") ; + + // Bug 629: + // + // AWT defines the notion of "extended modifiers". They put other bits there + // specific to the mouse buttons and say that these are the preferred bits to + // check for mouse button state. This seems to hint that at some point they + // may be the only way to get this info. + + if ((awtModsEx & java.awt.event.InputEvent.SHIFT_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; + if ((awtModsEx & java.awt.event.InputEvent.CTRL_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK; + if ((awtModsEx & java.awt.event.InputEvent.META_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; + if ((awtModsEx & java.awt.event.InputEvent.ALT_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK; + if ((awtModsEx & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK; + for (int n = 0 ; n < awtButtonMasks.length ; ++n) { + if ((awtModsEx & awtButtonMasks[n]) != 0) { + newtMods |= newtButtonMasks[n] ; + } + } + + return newtMods; + } +/* + private static void _printAwtModifiers( int awtMods, int awtModsEx ) { + if( ( awtMods & java.awt.event.InputEvent.SHIFT_MASK ) != 0 ) { System.err.println( "SHIFT" ) ; } + if( ( awtMods & java.awt.event.InputEvent.CTRL_MASK ) != 0 ) { System.err.println( "CTRL" ) ; } + if( ( awtMods & java.awt.event.InputEvent.META_MASK ) != 0 ) { System.err.println( "META" ) ; } + if( ( awtMods & java.awt.event.InputEvent.ALT_MASK ) != 0 ) { System.err.println( "ALT" ) ; } + if( ( awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK ) != 0 ) { System.err.println( "ALT_GRAPH" ) ; } + + if( ( awtModsEx & java.awt.event.InputEvent.SHIFT_DOWN_MASK ) != 0 ) { System.err.println( "SHIFT Ex" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.CTRL_DOWN_MASK ) != 0 ) { System.err.println( "CTRL Ex" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.META_DOWN_MASK ) != 0 ) { System.err.println( "META Ex" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.ALT_DOWN_MASK ) != 0 ) { System.err.println( "ALT Ex" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) != 0 ) { System.err.println( "ALT_GRAPH Ex" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON1" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.BUTTON2_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON2" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.BUTTON3_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON3" ) ; } + } +*/ public static final int awtButton2Newt(int awtButton) { switch (awtButton) { case java.awt.event.MouseEvent.BUTTON1: return com.jogamp.newt.event.MouseEvent.BUTTON1; @@ -124,7 +242,7 @@ public class AWTNewtEventFactory { rotation = -1 * ((java.awt.event.MouseWheelEvent)event).getWheelRotation(); } - int mods = awtModifiers2Newt(event.getModifiers(), true); + int mods = awtModifiers2Newt(event.getModifiers(), event.getModifiersEx(), true); if(null!=newtSource) { if(newtSource.isPointerConfined()) { mods |= InputEvent.CONFINED_MASK; @@ -147,7 +265,7 @@ public class AWTNewtEventFactory { if(0xFFFFFFFF != type) { return new com.jogamp.newt.event.KeyEvent( type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), - awtModifiers2Newt(event.getModifiers(), false), + awtModifiers2Newt(event.getModifiers(), event.getModifiersEx(), false), event.getKeyCode(), event.getKeyChar()); } return null; // no mapping .. diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt b/src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt new file mode 100644 index 000000000..1bd9102b5 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt @@ -0,0 +1,37 @@ +Modifier AWT Constant AWT Bit AWT Ex NEWT Constant NEWT Bit +------------- ------------------------------- ------- ------ ------------------------- -------- +Shift Event.SHIFT_MASK 0 +Ctrl Event.CTRL_MASK 1 +Meta Event.META_MASK 2 +Alt Event.ALT_MASK 3 +Button1 InputEvent.BUTTON1_MASK 4 +Button2 InputEvent.BUTTON2_MASK 3 +Button3 InputEvent.BUTTON3_MASK 2 +Shift Down InputEvent.SHIFT_DOWN_MASK 6 * InputEvent.SHIFT_MASK 0 +Ctrl Down InputEvent.CTRL_DOWN_MASK 7 * InputEvent.CTRL_MASK 1 +Meta Down InputEvent.META_DOWN_MASK 8 * InputEvent.META_MASK 2 +Alt Down InputEvent.ALT_DOWN_MASK 9 * InputEvent.ALT_MASK 3 +Button1 Down InputEvent.BUTTON1_DOWN_MASK 10 * InputEvent.BUTTON1_MASK 5 +Button2 Down InputEvent.BUTTON2_DOWN_MASK 11 * InputEvent.BUTTON2_MASK 6 +Button3 Down InputEvent.BUTTON3_DOWN_MASK 12 * InputEvent.BUTTON3_MASK 7 +AltGraph Down InputEvent.ALT_GRAPH_DOWN_MASK 13 * InputEvent.ALT_GRAPH_MASK 4 +Button4 Down -- 14 * InputEvent.BUTTON4_MASK 8 +Button5 Down -- 15 * InputEvent.BUTTON5_MASK 9 +Button6 Down -- 16 * InputEvent.BUTTON6_MASK 10 +Button7 Down -- 17 * InputEvent.BUTTON7_MASK 11 +Button8 Down -- 18 * InputEvent.BUTTON8_MASK 12 +Button9 Down -- 19 * InputEvent.BUTTON9_MASK 13 +Button10 Down -- 20 * +Button11 Down -- 21 * +Button12 Down -- 22 * +Button13 Down -- 23 * +Button14 Down -- 24 * +Button15 Down -- 25 * +Button16 Down -- 26 * InputEvent.BUTTONLAST_MASK 20 +Button17 Down -- 27 * +Button18 Down -- 28 * +Button19 Down -- 29 * +Button20 Down -- 30 * +Autorepeat -- - InputEvent.AUTOREPEAT_MASK 29 +Confined -- - InputEvent.CONFINED_MASK 30 +Invisible -- - InputEvent.INVISIBLE_MASK 31 diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java new file mode 100644 index 000000000..36185f8ce --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java @@ -0,0 +1,738 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.event ; + +import java.io.PrintStream ; +import java.util.ArrayList ; + +import javax.media.opengl.GL ; +import javax.media.opengl.GL2 ; +import javax.media.opengl.GLAutoDrawable ; +import javax.media.opengl.GLEventListener ; +import javax.media.opengl.GLProfile ; + +import org.junit.After ; +import org.junit.AfterClass ; +import org.junit.Assert ; +import org.junit.Before ; +import org.junit.BeforeClass ; +import org.junit.Test ; + +import com.jogamp.opengl.test.junit.util.UITestCase ; + +/** + * Test whether or not event modifiers are preserved by NEWT. This + * class defines most of the tests, but leaves the type of window + * and canvas up to subclasses. + */ + +public abstract class TestNewtEventModifiers extends UITestCase { + + static + { + GLProfile.initSingleton() ; + } + + // A class to draw something on a canvas. This is only + // here so we can make sure the GL drawing area has + // filled the window. + + public static class BigGreenXGLEventListener implements GLEventListener + { + public void init( GLAutoDrawable drawable ) + { + GL2 gl = drawable.getGL().getGL2() ; + + gl.glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ) ; + + gl.glEnable( GL.GL_LINE_SMOOTH ) ; + gl.glEnable( GL.GL_BLEND ) ; + gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA ) ; + } + + public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ) + { + GL2 gl = drawable.getGL().getGL2() ; + + gl.glViewport( 0, 0, width, height ) ; + + gl.glMatrixMode( GL2.GL_PROJECTION ) ; + gl.glLoadIdentity() ; + gl.glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ) ; + + gl.glMatrixMode( GL2.GL_MODELVIEW ) ; + gl.glLoadIdentity() ; + } + + public void display( GLAutoDrawable drawable ) + { + GL2 gl = drawable.getGL().getGL2() ; + + gl.glClear( GL2.GL_COLOR_BUFFER_BIT ) ; + + gl.glColor4f( 0.0f, 1.0f, 0.0f, 1.0f ) ; + + gl.glBegin( GL.GL_LINES ) ; + { + gl.glVertex2f( -1.0f, 1.0f ) ; + gl.glVertex2f( 1.0f, -1.0f ) ; + + gl.glVertex2f( -1.0f, -1.0f ) ; + gl.glVertex2f( 1.0f, 1.0f ) ; + } + gl.glEnd() ; + } + + public void dispose( GLAutoDrawable drawable ) + { + } + } + + //////////////////////////////////////////////////////////////////////////// + + private static class TestMouseListener implements com.jogamp.newt.event.MouseListener + { + private static final String NO_EVENT_DELIVERY = "no event delivery" ; + + private boolean _modifierCheckEnabled ; + private int _expectedModifiers ; + private ArrayList _failures = new ArrayList() ; + + public void setModifierCheckEnabled( boolean value ) { + _modifierCheckEnabled = value ; + } + + public boolean modifierCheckEnabled() { + return _modifierCheckEnabled ; + } + + /** + * Sets the modifiers the listener should expect, and clears + * out any existing accumulated failures. Normally this kind + * of double duty in a setter might be considered evil, but + * in this test code it's probably ok. + */ + + public void setExpectedModifiers( int value ) { + _expectedModifiers = value ; + + // Assume we will have a failure due to no event delivery. + // If an event is delivered and it's good this assumed + // failure will get cleared out. + + _failures.clear() ; + _failures.add( NO_EVENT_DELIVERY ) ; + } + + private void _checkModifiers( com.jogamp.newt.event.MouseEvent event ) { + + if( _debug ) { + _debugPrintStream.print( " received NEWT " ) ; + _debugPrintStream.print( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ) ; + } + + if( _modifierCheckEnabled ) { + + if( _debug ) { + _debugPrintStream.println( ", checking modifiers..." ) ; + _debugPrintStream.println( " expected NEWT Modifiers:" ) ; + _printModifiers( _expectedModifiers ) ; + _debugPrintStream.println( " current NEWT Modifiers:" ) ; + _printModifiers( event.getModifiers() ) ; + } + + _checkModifierMask( event, com.jogamp.newt.event.InputEvent.SHIFT_MASK ) ; + _checkModifierMask( event, com.jogamp.newt.event.InputEvent.CTRL_MASK ) ; + _checkModifierMask( event, com.jogamp.newt.event.InputEvent.META_MASK ) ; + _checkModifierMask( event, com.jogamp.newt.event.InputEvent.ALT_MASK ) ; + _checkModifierMask( event, com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK ) ; + + for( int n = 0 ; n < _numButtonsToTest ; ++n ) { + _checkModifierMask( event, com.jogamp.newt.event.InputEvent.getButtonMask( n + 1 ) ) ; + } + } else { + if( _debug ) { + _debugPrintStream.println( ", modifier check disabled" ) ; + } + } + } + + private void _checkModifierMask( com.jogamp.newt.event.MouseEvent event, int mask ) { + + // If the "no event delivery" failure is still in the list then + // get rid of it since that obviously isn't true anymore. We + // want to do this whether or not there's an issue with the + // modifiers. + + if( _failures.size() == 1 && _failures.get(0).equals( NO_EVENT_DELIVERY ) ) { + _failures.clear() ; + } + + if( ( event.getModifiers() & mask ) != ( _expectedModifiers & mask ) ) { + _failures.add( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ) ; + } + } + + private void _printModifiers( int modifiers ) { + if( ( modifiers & com.jogamp.newt.event.InputEvent.SHIFT_MASK ) != 0 ) { _debugPrintStream.println( " SHIFT" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.CTRL_MASK ) != 0 ) { _debugPrintStream.println( " CTRL" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.META_MASK ) != 0 ) { _debugPrintStream.println( " META" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.ALT_MASK ) != 0 ) { _debugPrintStream.println( " ALT" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK ) != 0 ) { _debugPrintStream.println( " ALT_GRAPH" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON1_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON1" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON2_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON2" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON3_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON3" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON4_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON4" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON5_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON5" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON6_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON6" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON7_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON7" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON8_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON8" ) ; } + if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON9_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON9" ) ; } + } + + public ArrayList getFailures() { + return _failures ; + } + + public void mouseClicked( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mousePressed( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mouseReleased( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mouseEntered( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mouseExited( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mouseDragged( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mouseMoved( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mouseWheelMoved( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + } + + //////////////////////////////////////////////////////////////////////////// + + protected static final int TEST_FRAME_X = 100 ; + protected static final int TEST_FRAME_Y = 100 ; + + protected static final int TEST_FRAME_WIDTH = 400 ; + protected static final int TEST_FRAME_HEIGHT = 400 ; + + private static final int INITIAL_MOUSE_X = TEST_FRAME_X + ( TEST_FRAME_WIDTH / 2 ) ; + private static final int INITIAL_MOUSE_Y = TEST_FRAME_Y + ( TEST_FRAME_HEIGHT / 2 ) ; + + private static final int MS_ROBOT_SHORT_AUTO_DELAY = 50 ; + private static final int MS_ROBOT_LONG_AUTO_DELAY = 500 ; + + private static boolean _debug = true ; + private static PrintStream _debugPrintStream = System.err ; + + //////////////////////////////////////////////////////////////////////////// + + private static int _numButtonsToTest ; + private static int _awtButtonMasks[] ; + private static int _newtButtonMasks[] ; + + private static java.awt.Robot _robot ; + + protected static TestMouseListener _testMouseListener ; + + //////////////////////////////////////////////////////////////////////////// + + @BeforeClass + public static void beforeClass() throws Exception { + + // Who know how many buttons the AWT will say exist on given platform. + // We'll test the smaller of what NEWT supports and what the + // AWT says is available. + + if( java.awt.Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled() ) { + _numButtonsToTest = java.awt.MouseInfo.getNumberOfButtons() ; + } else { + _numButtonsToTest = 3 ; + } + + // Then again, maybe not: + + // FIXME? - for reasons I'm not quite sure of the AWT MouseEvent + // constructor does some strange things for buttons other than + // 1, 2, and 3. Furthermore, while developing this test it + // appeared that events sent by the robot for buttons 9 and + // up weren't even delivered to the listeners. + // + // So... for now we're only going to test 3 buttons since + // that's the common case. + + _numButtonsToTest = 3 ; + + { + if( _numButtonsToTest > com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + _numButtonsToTest = com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ; + } + + // These two arrays are assumed to be peers, i.e. are the same + // size, and a given index references the same button in + // either array. + + _awtButtonMasks = new int[_numButtonsToTest] ; + + for( int n = 0 ; n < _awtButtonMasks.length ; ++n ) { + _awtButtonMasks[n] = java.awt.event.InputEvent.getMaskForButton( n + 1 ) ; + } + + _newtButtonMasks = new int[_numButtonsToTest] ; + + for( int n = 0 ; n < _newtButtonMasks.length ; ++n ) { + _newtButtonMasks[n] = com.jogamp.newt.event.InputEvent.getButtonMask( n + 1 ) ; + } + } + + _robot = new java.awt.Robot() ; + _robot.setAutoWaitForIdle( true ) ; + _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; + + _testMouseListener = new TestMouseListener() ; + } + + //////////////////////////////////////////////////////////////////////////// + + @Before + public void before() throws Exception { + + _testMouseListener.setModifierCheckEnabled( false ) ; + _robot.setAutoDelay( MS_ROBOT_SHORT_AUTO_DELAY ) ; + + // Make sure all the buttons and modifier keys are released. + + _releaseModifiers() ; + _escape() ; + + // Move the pointer into the window and click once to + // ensure that the test window has focus. + + if( _debug ) { + _debugPrintStream.println( ">>>> Clicking in the window to get focus." ) ; + } + + _robot.mouseMove( INITIAL_MOUSE_X, INITIAL_MOUSE_Y ) ; + _robot.mousePress( java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) ; + _robot.mouseRelease( java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) ; + + _testMouseListener.setModifierCheckEnabled( true ) ; + _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; + + if( _debug ) { + _debugPrintStream.println( ">>>> About to start testing." ) ; + } + } + + //////////////////////////////////////////////////////////////////////////// + + // The approach on all these tests is to tell the test mouse listener what + // modifiers we think it should receive. Then when the events are delivered + // it compares what we told it to expect with what actually showed up and + // complains if there are differences. + // + // As things stand currently the tests below generally work for AWTCanvas + // and fail for everything else. This may point to a flaw in the test + // code, or a flaw in the NEWT stuff; not sure yet. One exception is the + // tests involving ALT and META, which on at least X11 cause the desktop + // to do undesirable stuff while the tests are in progress. So... these + // tests have been commented out for now and probably should be left + // that way. + // + // Due to the fact that a majority of these fail currently for + // everything but AWTCanvas for the time being we probably shouldn't + // run the tests for NewtCanvasAWT and NewtCanvasSWT until we can + // pay more attention to the NEWT event modifier stuff. + + @Test + public void testSingleButtonPressAndRelease() throws Exception { + _doSingleButtonPressAndRelease( 0, 0 ) ; + } + + @Test + public void testSingleButtonPressAndReleaseWithShift() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_SHIFT, java.awt.event.InputEvent.SHIFT_DOWN_MASK ) ; + } + + @Test + public void testSingleButtonPressAndReleaseWithCtrl() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_CONTROL, java.awt.event.InputEvent.CTRL_DOWN_MASK ) ; + } + + // The META and ALT tests get too tied up with functions of the window system on X11, + // so it's probably best to leave them commented out. + + //@Test + //public void testSingleButtonPressAndReleaseWithMeta() throws Exception { + // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_META, java.awt.event.InputEvent.META_DOWN_MASK ) ; + //} + + //@Test + //public void testSingleButtonPressAndReleaseWithAlt() throws Exception { + // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT, java.awt.event.InputEvent.ALT_DOWN_MASK ) ; + //} + + // FIXME - not sure yet what's up with ALT_GRAPH. It appears that this + // modifier didn't make it through, so I had to disable this test else + // it would always fail. + // + // My US keyboard doesn't have an AltGr key, so maybe X is smart + // enough to not let this modifier slip through (?). + + //@Test + //public void testSingleButtonPressAndReleaseWithAltGraph() throws Exception { + // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH, java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) ; + //} + + //////////////////////////////////////////////////////////////////////////// + + @Test + public void testHoldOneButtonAndPressAnother() throws Exception { + _doHoldOneButtonAndPressAnother( 0, 0 ) ; + } + + @Test + public void testPressAllButtonsInSequence() throws Exception { + _doPressAllButtonsInSequence( 0, 0 ) ; + } + + @Test + public void testSingleButtonClickAndDrag() throws Exception { + _doSingleButtonClickAndDrag( 0, 0 ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + private void _doSingleButtonPressAndRelease( final int keyCode, final int keyModifierMask ) throws Exception { + + if( _debug ) { _debugPrintStream.println( "\n>>>> _doSingleButtonPressAndRelease" ) ; } + + _doKeyPress( keyCode ) ; + + for (int n = 0 ; n < _numButtonsToTest ; ++n) { + + int awtButtonMask = _awtButtonMasks[n] ; + + if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; + _robot.mousePress( awtButtonMask ) ; + _checkFailures() ; + + if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; + _robot.mouseRelease( awtButtonMask ) ; + _checkFailures() ; + } + + _doKeyRelease( keyCode ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + private void _doHoldOneButtonAndPressAnother( final int keyCode, final int keyModifierMask ) throws Exception { + + if( _debug ) { _debugPrintStream.println( "\n>>>> _doHoldOneButtonAndPressAnother" ) ; } + + _doKeyPress( keyCode ) ; + + for (int n = 0 ; n < _numButtonsToTest ; ++n) { + + int awtButtonMask = _awtButtonMasks[n] ; + + if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; + _robot.mousePress( awtButtonMask ) ; + _checkFailures() ; + + for (int m = 0 ; m < _numButtonsToTest ; ++m) { + + if( n != m ) { + + if( _debug ) { _debugPrintStream.println( "\n pressing additional button " + ( m + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask | _awtButtonMasks[m] ) ) ; + _robot.mousePress( _awtButtonMasks[m] ) ; + _checkFailures() ; + + if( _debug ) { _debugPrintStream.println( "\n releasing additional button " + ( m + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; + _robot.mouseRelease( _awtButtonMasks[m] ) ; + _checkFailures() ; + } + } + + if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; + _robot.mouseRelease( awtButtonMask ) ; + _checkFailures() ; + } + + _doKeyRelease( keyCode ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + private void _doPressAllButtonsInSequence( final int keyCode, final int keyModifierMask ) throws Exception { + + if( _debug ) { _debugPrintStream.println( "\n>>>> _doPressAllButtonsInSequence" ) ; } + + _doKeyPress( keyCode ) ; + + { + int cumulativeAwtModifiers = 0 ; + + for (int n = 0 ; n < _numButtonsToTest ; ++n) { + + cumulativeAwtModifiers |= _awtButtonMasks[n] ; + + if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | cumulativeAwtModifiers ) ) ; + _robot.mousePress( _awtButtonMasks[n] ) ; + _checkFailures() ; + } + + for (int n = _numButtonsToTest - 1 ; n >= 0 ; --n) { + + cumulativeAwtModifiers &= ~_awtButtonMasks[n] ; + + if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | cumulativeAwtModifiers ) ) ; + _robot.mouseRelease( _awtButtonMasks[n] ) ; + _checkFailures() ; + } + } + + _doKeyRelease( keyCode ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + private void _doSingleButtonClickAndDrag( final int keyCode, final int keyModifierMask ) throws Exception { + + if( _debug ) { _debugPrintStream.println( "\n>>>> _doSingleButtonClickAndDrag" ) ; } + + _doKeyPress( keyCode ) ; + + _testMouseListener.setModifierCheckEnabled( true ) ; + + for (int n = 0 ; n < _numButtonsToTest ; ++n) { + + int awtButtonMask = _awtButtonMasks[n] ; + + if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; + _robot.mousePress( awtButtonMask ) ; + _checkFailures() ; + + // To get a drag we only need to move one pixel. + if( _debug ) { _debugPrintStream.println( "\n moving mouse" ) ; } + _robot.mouseMove( INITIAL_MOUSE_X + 1, INITIAL_MOUSE_Y + 1 ) ; + _checkFailures() ; + + if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; + _robot.mouseRelease( awtButtonMask ) ; + _checkFailures() ; + + _testMouseListener.setModifierCheckEnabled( false ) ; + _robot.mouseMove( INITIAL_MOUSE_X, INITIAL_MOUSE_Y ) ; + _testMouseListener.setModifierCheckEnabled( true ) ; + } + + _doKeyRelease( keyCode ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + private void _doKeyPress( int keyCode ) { + if( keyCode != 0 ) { + boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; + _testMouseListener.setModifierCheckEnabled( false ) ; + _robot.keyPress( keyCode ) ; + _testMouseListener.setModifierCheckEnabled( modifierCheckEnabled ) ; + } + } + + //////////////////////////////////////////////////////////////////////////// + + private void _doKeyRelease( int keyCode ) { + if( keyCode != 0 ) { + boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; + _testMouseListener.setModifierCheckEnabled( false ) ; + _robot.keyRelease( keyCode ) ; + _testMouseListener.setModifierCheckEnabled( modifierCheckEnabled ) ; + } + } + + //////////////////////////////////////////////////////////////////////////// + + private void _checkFailures() { + + ArrayList failures = _testMouseListener.getFailures() ; + + if( _debug ) { + int numFailures = failures.size() ; + if( numFailures == 0 ) { + _debugPrintStream.println( " PASSED" ) ; + } else { + _debugPrintStream.println( " FAILED" ) ; + for( int n = 0 ; n < numFailures ; ++n ) { + _debugPrintStream.print( " " ) ; + _debugPrintStream.println( failures.get(n) ) ; + } + } + } + + Assert.assertTrue( failures.size() == 0 ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + @After + public void after() throws Exception { + + _testMouseListener.setModifierCheckEnabled( false ) ; + + Thread.sleep( 500 ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + @AfterClass + public static void afterClass() throws Exception { + + // Make sure all modifiers are released, otherwise the user's + // desktop can get locked up (ask me how I know this). + + _releaseModifiers() ; + _escape() ; + } + + //////////////////////////////////////////////////////////////////////////// + + private static void _releaseModifiers() { + + if (_robot != null) { + + _robot.setAutoDelay( MS_ROBOT_SHORT_AUTO_DELAY ) ; + + boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; + _testMouseListener.setModifierCheckEnabled( false ) ; + + { + _robot.keyRelease( java.awt.event.KeyEvent.VK_SHIFT ) ; + _robot.keyRelease( java.awt.event.KeyEvent.VK_CONTROL ) ; + _robot.keyRelease( java.awt.event.KeyEvent.VK_META ) ; + _robot.keyRelease( java.awt.event.KeyEvent.VK_ALT ) ; + _robot.keyRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH ) ; + + for (int n = 0 ; n < _awtButtonMasks.length ; ++n) { + _robot.mouseRelease( _awtButtonMasks[n] ) ; + } + } + + _testMouseListener.setModifierCheckEnabled( modifierCheckEnabled ) ; + + _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; + } + } + + private static void _escape() { + if (_robot != null) { + _robot.keyPress( java.awt.event.KeyEvent.VK_ESCAPE ) ; + _robot.keyRelease( java.awt.event.KeyEvent.VK_ESCAPE ) ; + } + } + + //////////////////////////////////////////////////////////////////////////// + + /** + * Brute force method to return the NEWT event modifiers equivalent + * to the specified AWT event extended modifiers. + * + * @param awtExtendedModifiers + * The AWT extended modifiers. + * + * @return + * The equivalent NEWT modifiers. + */ + + private int _getNewtModifiersForAwtExtendedModifiers( int awtExtendedModifiers ) { + + int mask = 0 ; + + if( ( awtExtendedModifiers & java.awt.event.InputEvent.SHIFT_DOWN_MASK ) != 0 ) { + mask |= com.jogamp.newt.event.InputEvent.SHIFT_MASK ; + } + + if( ( awtExtendedModifiers & java.awt.event.InputEvent.CTRL_DOWN_MASK ) != 0 ) { + mask |= com.jogamp.newt.event.InputEvent.CTRL_MASK ; + } + + if( ( awtExtendedModifiers & java.awt.event.InputEvent.META_DOWN_MASK ) != 0 ) { + mask |= com.jogamp.newt.event.InputEvent.META_MASK ; + } + + if( ( awtExtendedModifiers & java.awt.event.InputEvent.ALT_DOWN_MASK ) != 0 ) { + mask |= com.jogamp.newt.event.InputEvent.ALT_MASK ; + } + + if( ( awtExtendedModifiers & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) != 0 ) { + mask |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK ; + } + + for (int n = 0 ; n < _numButtonsToTest ; ++n) { + if ((awtExtendedModifiers & java.awt.event.InputEvent.getMaskForButton(n+1)) != 0) { + mask |= com.jogamp.newt.event.InputEvent.getButtonMask(n+1) ; + } + } + + return mask ; + } + + //////////////////////////////////////////////////////////////////////////// +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java new file mode 100644 index 000000000..3aa016d56 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java @@ -0,0 +1,96 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.event; + +import javax.media.opengl.awt.GLCanvas ; + +import javax.swing.JFrame ; +import javax.swing.SwingUtilities ; +import javax.swing.WindowConstants ; + +import org.junit.AfterClass ; +import org.junit.BeforeClass ; + +import com.jogamp.newt.event.awt.AWTMouseAdapter ; + +/** + * Test whether or not event modifiers are preserved by NEWT when + * the source is an AWT canvas. + */ + +public class TestNewtEventModifiersAWTCanvas extends TestNewtEventModifiers { + + private static JFrame _testFrame ; + + //////////////////////////////////////////////////////////////////////////// + + @BeforeClass + public static void beforeClass() throws Exception { + + TestNewtEventModifiers.beforeClass() ; + + final GLCanvas canvas = new GLCanvas() ; + canvas.addGLEventListener( new BigGreenXGLEventListener() ) ; + new AWTMouseAdapter( _testMouseListener ).addTo( (java.awt.Component)canvas ) ; + + _testFrame = new JFrame( "Event Modifier Test AWTCanvas" ) ; + _testFrame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE ) ; + _testFrame.getContentPane().add( canvas ) ; + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + _testFrame.setBounds( TEST_FRAME_X, TEST_FRAME_Y, TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT ) ; + _testFrame.setVisible( true ) ; + } + }) ; + } + + //////////////////////////////////////////////////////////////////////////// + + @AfterClass + public static void afterClass() throws Exception { + + TestNewtEventModifiers.afterClass() ; + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + _testFrame.dispose() ; + } + }) ; + } + + //////////////////////////////////////////////////////////////////////////// + + public static void main(String args[]) throws Exception { + String testName = TestNewtEventModifiersAWTCanvas.class.getName() ; + org.junit.runner.JUnitCore.main( testName ) ; + } + + //////////////////////////////////////////////////////////////////////////// +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java new file mode 100644 index 000000000..a2c1d3364 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java @@ -0,0 +1,111 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.event ; + +import java.awt.BorderLayout ; + +import javax.media.opengl.GLCapabilities ; +import javax.media.opengl.GLProfile ; + +import javax.swing.JFrame ; +import javax.swing.SwingUtilities ; +import javax.swing.WindowConstants ; + +import org.junit.AfterClass ; +import org.junit.BeforeClass ; + +import com.jogamp.newt.awt.NewtCanvasAWT ; +import com.jogamp.newt.opengl.GLWindow ; + +/** + * Test whether or not event modifiers are preserved by NEWT when + * the canvas is a NewtCanvasAWT. + */ + +public class TestNewtEventModifiersNewtCanvasAWT extends TestNewtEventModifiers { + + private static JFrame _testFrame ; + private static GLWindow _glWindow ; + + //////////////////////////////////////////////////////////////////////////// + + @BeforeClass + public static void beforeClass() throws Exception { + + TestNewtEventModifiers.beforeClass() ; + + SwingUtilities.invokeAndWait( new Runnable() { + public void run() { + + _testFrame = new JFrame( "Event Modifier Test NewtCanvasAWT" ) ; + _testFrame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE ) ; + + { + GLCapabilities caps = new GLCapabilities( GLProfile.getGL2ES2() ) ; + _glWindow = GLWindow.create( caps ) ; + + NewtCanvasAWT canvas = new NewtCanvasAWT( _glWindow ) ; + _testFrame.getContentPane().add( canvas, BorderLayout.CENTER ) ; + + _glWindow.addGLEventListener( new BigGreenXGLEventListener() ) ; + } + + _testFrame.setBounds( TEST_FRAME_X, TEST_FRAME_Y, TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT ) ; + _testFrame.setVisible( true ) ; + } + } ) ; + + _glWindow.addMouseListener( _testMouseListener ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + @AfterClass + public static void afterClass() throws Exception { + + TestNewtEventModifiers.afterClass() ; + + SwingUtilities.invokeAndWait( new Runnable() { + public void run() { + _testFrame.dispose() ; + } + } ) ; + + _glWindow.destroy() ; + } + + //////////////////////////////////////////////////////////////////////////// + + public static void main(String args[]) throws Exception { + String testName = TestNewtEventModifiersNewtCanvasAWT.class.getName() ; + org.junit.runner.JUnitCore.main( testName ) ; + } + + //////////////////////////////////////////////////////////////////////////// +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java new file mode 100644 index 000000000..e6139bb37 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java @@ -0,0 +1,156 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.event; + +import org.eclipse.swt.SWT ; +import org.eclipse.swt.layout.FillLayout ; +import org.eclipse.swt.widgets.Display ; +import org.eclipse.swt.widgets.Shell ; + +import javax.media.opengl.GLCapabilities ; +import javax.media.opengl.GLProfile ; + +import org.junit.AfterClass ; +import org.junit.BeforeClass ; + +import com.jogamp.newt.opengl.GLWindow ; +import com.jogamp.newt.swt.NewtCanvasSWT ; + +/** + * Test whether or not event modifiers preserved by NEWT when + * the canvas is a NewtCanvasSWT. + */ + +public class TestNewtEventModifiersNewtCanvasSWT extends TestNewtEventModifiers { + + private static Shell _testShell ; + private static GLWindow _glWindow ; + private static DisplayThread _displayThread ; + + //////////////////////////////////////////////////////////////////////////// + + private static class DisplayThread extends Thread + { + private Display _display ; + + public DisplayThread() + { + super( "SWT Display Thread" ) ; + } + + public Display getDisplay() { + return _display ; + } + + public void run() { + + _display = new Display() ; + + while( isInterrupted() == false ) { + if( !_display.readAndDispatch() ) { + _display.sleep() ; + } + } + + _display.dispose() ; + } + } + + //////////////////////////////////////////////////////////////////////////// + + @BeforeClass + public static void beforeClass() throws Exception { + + TestNewtEventModifiers.beforeClass() ; + + _displayThread = new DisplayThread() ; + _displayThread.start() ; + + // Wait for the display thread's runnable to get set. + + while( _displayThread.getDisplay() == null ) { + try { Thread.sleep( 10 ) ; } catch( InterruptedException e ) {} + } + + _displayThread.getDisplay().syncExec( new Runnable() { + public void run() { + + _testShell = new Shell( _displayThread.getDisplay() ) ; + _testShell.setText( "Event Modifier Test NewtCanvasSWT" ) ; + _testShell.setLayout( new FillLayout() ) ; + + { + GLCapabilities caps = new GLCapabilities( GLProfile.get( GLProfile.GL2ES2 ) ) ; + _glWindow = GLWindow.create( caps ) ; + + NewtCanvasSWT.create( _testShell, SWT.NO_BACKGROUND, _glWindow ) ; + + _glWindow.addGLEventListener( new BigGreenXGLEventListener() ) ; + } + + _testShell.setBounds( TEST_FRAME_X, TEST_FRAME_Y, TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT ) ; + _testShell.open() ; + } + } ) ; + + _glWindow.addMouseListener( _testMouseListener ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + @AfterClass + public static void afterClass() throws Exception { + + TestNewtEventModifiers.afterClass() ; + + _glWindow.destroy() ; + + _displayThread.getDisplay().syncExec( new Runnable() { + public void run() { + _testShell.dispose() ; + } + } ) ; + + _displayThread.interrupt() ; + + try { + _displayThread.join() ; + } catch( InterruptedException e ) { + } + } + + //////////////////////////////////////////////////////////////////////////// + + public static void main(String args[]) throws Exception { + String testName = TestNewtEventModifiersNewtCanvasSWT.class.getName() ; + org.junit.runner.JUnitCore.main( testName ) ; + } + + //////////////////////////////////////////////////////////////////////////// +} -- cgit v1.2.3 From 9ddbfb35882aa4c361d161ab8aca91ed670a97c8 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 30 Nov 2012 15:02:07 +0100 Subject: Simplify NEWT EDTUtil invoke: To start EDT Runnable maybe null - start EDT even if on EDT thread. DEBUG: Name EDTUtil impl, e.g. Default, AWT and SWT --- src/newt/classes/com/jogamp/newt/Display.java | 6 ++-- .../classes/com/jogamp/newt/swt/SWTEDTUtil.java | 34 ++++++++---------- src/newt/classes/com/jogamp/newt/util/EDTUtil.java | 2 +- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 42 +++++++++++----------- .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 32 ++++++++--------- 5 files changed, 54 insertions(+), 62 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index e97dec88d..4c263a195 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -165,11 +165,11 @@ public abstract class Display { * null is returned and no change is being made. *

*

- * Note that newEDTUtil will not be started if not done so already, - * to do so you may issue {@link EDTUtil#invoke(boolean, Runnable) invoke} + * Note that newEDTUtil will not be started by this method. + * To do so you may issue {@link EDTUtil#invoke(boolean, Runnable) invoke} * on the new EDTUtil: *

-     *          newEDTUtil.invoke(true, new Runnable() { public void run() { } } );
+     *          newEDTUtil.invoke(true, null);
      * 
*

*/ diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java index 42e1c9be5..2203d744a 100644 --- a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java @@ -27,8 +27,6 @@ */ package com.jogamp.newt.swt; -import java.awt.EventQueue; - import javax.media.nativewindow.NativeWindowException; import jogamp.newt.Debug; @@ -83,7 +81,7 @@ public class SWTEDTUtil implements EDTUtil { synchronized(edtLock) { waitUntilStopped(); if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT reset - edt: "+nedt); + System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt); } this.nedt = new NewtEventDispatchThread(threadGroup, name); this.nedt.setDaemon(true); // don't stop JVM from shutdown .. @@ -92,13 +90,13 @@ public class SWTEDTUtil implements EDTUtil { private final void startImpl() { if(nedt.isAlive()) { - throw new RuntimeException("EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); + throw new RuntimeException("SWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); } start_iter++; nedt.setName(name+start_iter); nedt.shouldStop = false; if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT START - edt: "+nedt); + System.err.println(Thread.currentThread()+": SWT-EDT START - edt: "+nedt); // Thread.dumpStack(); } nedt.start(); @@ -136,9 +134,6 @@ public class SWTEDTUtil implements EDTUtil { } private void invokeImpl(boolean wait, Runnable task, boolean stop) { - if(task == null) { - throw new RuntimeException("Null Runnable"); - } Throwable throwable = null; RunnableTask rTask = null; Object rTaskLock = new Object(); @@ -147,7 +142,7 @@ public class SWTEDTUtil implements EDTUtil { if( nedt.shouldStop ) { // drop task .. if(DEBUG) { - System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt); + System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt); Thread.dumpStack(); } return; @@ -157,20 +152,21 @@ public class SWTEDTUtil implements EDTUtil { if(stop) { nedt.shouldStop = true; if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); + System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); // Thread.dumpStack(); } + } else if( !nedt.isRunning() ) { + // start if should not stop && not started yet + startImpl(); } - if( isCurrentThreadEDT() ) { + if( null == task ) { + wait = false; + } else if( isCurrentThreadEDT() ) { task.run(); wait = false; // running in same thread (EDT) -> no wait } else if( swtDisplay.isDisposed() ) { wait = false; // drop task, SWT disposed } else { - // start if should not stop && not started yet - if( !stop && !nedt.isRunning() ) { - startImpl(); - } rTask = new RunnableTask(task, wait ? rTaskLock : null, true /* always catch and report Exceptions, don't disturb EDT */); @@ -255,7 +251,7 @@ public class SWTEDTUtil implements EDTUtil { @Override final public void run() { if(DEBUG) { - System.err.println(getName()+": EDT run() START "+ getName()); + System.err.println(getName()+": SWT-EDT run() START "+ getName()); } RuntimeException error = null; try { @@ -289,11 +285,11 @@ public class SWTEDTUtil implements EDTUtil { if(t instanceof RuntimeException) { error = (RuntimeException) t; } else { - error = new RuntimeException("Within EDT", t); + error = new RuntimeException("Within SWT-EDT", t); } } finally { if(DEBUG) { - System.err.println(getName()+": EDT run() END "+ getName()+", "+error); + System.err.println(getName()+": SWT-EDT run() END "+ getName()+", "+error); } synchronized(edtLock) { isRunning = !shouldStop; @@ -302,7 +298,7 @@ public class SWTEDTUtil implements EDTUtil { } } if(DEBUG) { - System.err.println(getName()+": EDT run() EXIT "+ getName()+", exception: "+error); + System.err.println(getName()+": SWT-EDT run() EXIT "+ getName()+", exception: "+error); } if(null!=error) { throw error; diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index 7e19d9de5..293e13592 100644 --- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -125,7 +125,7 @@ public interface EDTUtil { public void invokeStop(Runnable finalTask); /** - * Shall start the thread if not running.
+ * Shall start the thread if not running, task maybe null for this purpose.
* Append task to the EDT task queue.
* Wait until execution is finished if wait == true.
* Can be issued from within EDT, ie from within an enqueued task.
diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index 98987ef96..b141f9d29 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -81,10 +81,10 @@ public class DefaultEDTUtil implements EDTUtil { waitUntilStopped(); if(DEBUG) { if(edt.tasks.size()>0) { - System.err.println(Thread.currentThread()+": EDT reset, remaining tasks: "+edt.tasks.size()+" - "+edt); + System.err.println(Thread.currentThread()+": Default-EDT reset, remaining tasks: "+edt.tasks.size()+" - "+edt); // Thread.dumpStack(); } - System.err.println(Thread.currentThread()+": EDT reset - edt: "+edt); + System.err.println(Thread.currentThread()+": Default-EDT reset - edt: "+edt); } this.edt = new EventDispatchThread(threadGroup, name); this.edt.setDaemon(true); // don't stop JVM from shutdown .. @@ -93,13 +93,13 @@ public class DefaultEDTUtil implements EDTUtil { private final void startImpl() { if(edt.isAlive()) { - throw new RuntimeException("EDT Thread.isAlive(): true, isRunning: "+edt.isRunning()+", edt: "+edt+", tasks: "+edt.tasks.size()); + throw new RuntimeException("Default-EDT Thread.isAlive(): true, isRunning: "+edt.isRunning()+", edt: "+edt+", tasks: "+edt.tasks.size()); } start_iter++; edt.setName(name+start_iter); edt.shouldStop = false; if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT START - edt: "+edt); + System.err.println(Thread.currentThread()+": Default-EDT START - edt: "+edt); // Thread.dumpStack(); } edt.start(); @@ -136,9 +136,6 @@ public class DefaultEDTUtil implements EDTUtil { } private void invokeImpl(boolean wait, Runnable task, boolean stop) { - if(task == null) { - throw new RuntimeException("Null Runnable"); - } Throwable throwable = null; RunnableTask rTask = null; Object rTaskLock = new Object(); @@ -147,7 +144,7 @@ public class DefaultEDTUtil implements EDTUtil { if( edt.shouldStop ) { // drop task .. if(DEBUG) { - System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+edt); + System.err.println(Thread.currentThread()+": Warning: Default-EDT about (1) to stop, won't enqueue new task: "+edt); Thread.dumpStack(); } return; @@ -157,24 +154,25 @@ public class DefaultEDTUtil implements EDTUtil { if(stop) { edt.shouldStop = true; if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - tasks: "+edt.tasks.size()+" - "+edt); + System.err.println(Thread.currentThread()+": Default-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - tasks: "+edt.tasks.size()+" - "+edt); // Thread.dumpStack(); } + } else if( !edt.isRunning() ) { + // start if should not stop && not started yet + startImpl(); } - if( isCurrentThreadEDT() ) { + if( null == task ) { + wait = false; + } else if( isCurrentThreadEDT() ) { task.run(); wait = false; // running in same thread (EDT) -> no wait if(stop && edt.tasks.size()>0) { - System.err.println("Warning: EDT about (2) to stop, having remaining tasks: "+edt.tasks.size()+" - "+edt); + System.err.println(Thread.currentThread()+": Warning: Default-EDT about (2) to stop, having remaining tasks: "+edt.tasks.size()+" - "+edt); if(DEBUG) { Thread.dumpStack(); } } } else { - // start if should not stop && not started yet - if( !stop && !edt.isRunning() ) { - startImpl(); - } synchronized(edt.tasks) { wait = wait && edt.isRunning(); rTask = new RunnableTask(task, @@ -207,7 +205,7 @@ public class DefaultEDTUtil implements EDTUtil { } } if(DEBUG && stop) { - System.err.println(Thread.currentThread()+": EDT signal STOP X edt: "+edt); + System.err.println(Thread.currentThread()+": Default-EDT signal STOP X edt: "+edt); } } @@ -282,7 +280,7 @@ public class DefaultEDTUtil implements EDTUtil { @Override final public void run() { if(DEBUG) { - System.err.println(getName()+": EDT run() START "+ getName()); + System.err.println(getName()+": Default-EDT run() START "+ getName()); } validateNoRecursiveLocksHold(); RuntimeException error = null; @@ -324,12 +322,12 @@ public class DefaultEDTUtil implements EDTUtil { if(t instanceof RuntimeException) { error = (RuntimeException) t; } else { - error = new RuntimeException("Within EDT", t); + error = new RuntimeException("Within Default-EDT", t); } } finally { if(DEBUG) { RunnableTask rt = ( tasks.size() > 0 ) ? tasks.get(0) : null ; - System.err.println(getName()+": EDT run() END "+ getName()+", tasks: "+tasks.size()+", "+rt+", "+error); + System.err.println(getName()+": Default-EDT run() END "+ getName()+", tasks: "+tasks.size()+", "+rt+", "+error); } synchronized(edtLock) { if(null==error) { @@ -344,9 +342,9 @@ public class DefaultEDTUtil implements EDTUtil { } if(DEBUG) { if(null!=task && task.getAttachment()==null) { - System.err.println(getName()+" Warning: EDT exit: Last task Not Final: "+tasks.size()+", "+task+" - "+edt); + System.err.println(getName()+" Warning: Default-EDT exit: Last task Not Final: "+tasks.size()+", "+task+" - "+edt); } else if(tasks.size()>0) { - System.err.println(getName()+" Warning: EDT exit: Remaining tasks Post Final: "+tasks.size()); + System.err.println(getName()+" Warning: Default-EDT exit: Remaining tasks Post Final: "+tasks.size()); } Thread.dumpStack(); } @@ -358,7 +356,7 @@ public class DefaultEDTUtil implements EDTUtil { } } if(DEBUG) { - System.err.println(getName()+": EDT run() EXIT "+ getName()+", exception: "+error); + System.err.println(getName()+": Default-EDT run() EXIT "+ getName()+", exception: "+error); } if(null!=error) { throw error; diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 2175f2190..cb9bc90b8 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -72,7 +72,7 @@ public class AWTEDTUtil implements EDTUtil { synchronized(edtLock) { waitUntilStopped(); if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT reset - edt: "+nedt); + System.err.println(Thread.currentThread()+": AWT-EDT reset - edt: "+nedt); } this.nedt = new NewtEventDispatchThread(threadGroup, name); this.nedt.setDaemon(true); // don't stop JVM from shutdown .. @@ -81,13 +81,13 @@ public class AWTEDTUtil implements EDTUtil { private final void startImpl() { if(nedt.isAlive()) { - throw new RuntimeException("EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); + throw new RuntimeException("AWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); } start_iter++; nedt.setName(name+start_iter); nedt.shouldStop = false; if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT START - edt: "+nedt); + System.err.println(Thread.currentThread()+": AWT-EDT START - edt: "+nedt); // Thread.dumpStack(); } nedt.start(); @@ -124,9 +124,6 @@ public class AWTEDTUtil implements EDTUtil { } private void invokeImpl(boolean wait, Runnable task, boolean stop) { - if(task == null) { - throw new RuntimeException("Null Runnable"); - } Throwable throwable = null; RunnableTask rTask = null; Object rTaskLock = new Object(); @@ -135,7 +132,7 @@ public class AWTEDTUtil implements EDTUtil { if( nedt.shouldStop ) { // drop task .. if(DEBUG) { - System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt); + System.err.println(Thread.currentThread()+": Warning: AWT-EDT about (1) to stop, won't enqueue new task: "+nedt); Thread.dumpStack(); } return; @@ -145,18 +142,19 @@ public class AWTEDTUtil implements EDTUtil { if(stop) { nedt.shouldStop = true; if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); + System.err.println(Thread.currentThread()+": AWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); // Thread.dumpStack(); } + } else if( !nedt.isRunning() ) { + // start if should not stop && not started yet + startImpl(); } - if( isCurrentThreadEDT() ) { + if( null == task ) { + wait = false; + } else if( isCurrentThreadEDT() ) { task.run(); wait = false; // running in same thread (EDT) -> no wait } else { - // start if should not stop && not started yet - if( !stop && !nedt.isRunning() ) { - startImpl(); - } rTask = new RunnableTask(task, wait ? rTaskLock : null, true /* always catch and report Exceptions, don't disturb EDT */); @@ -239,7 +237,7 @@ public class AWTEDTUtil implements EDTUtil { @Override final public void run() { if(DEBUG) { - System.err.println(getName()+": EDT run() START "+ getName()); + System.err.println(getName()+": AWT-EDT run() START "+ getName()); } RuntimeException error = null; try { @@ -269,11 +267,11 @@ public class AWTEDTUtil implements EDTUtil { if(t instanceof RuntimeException) { error = (RuntimeException) t; } else { - error = new RuntimeException("Within EDT", t); + error = new RuntimeException("Within AWT-EDT", t); } } finally { if(DEBUG) { - System.err.println(getName()+": EDT run() END "+ getName()+", "+error); + System.err.println(getName()+": AWT-EDT run() END "+ getName()+", "+error); } synchronized(edtLock) { isRunning = !shouldStop; @@ -282,7 +280,7 @@ public class AWTEDTUtil implements EDTUtil { } } if(DEBUG) { - System.err.println(getName()+": EDT run() EXIT "+ getName()+", exception: "+error); + System.err.println(getName()+": AWT-EDT run() EXIT "+ getName()+", exception: "+error); } if(null!=error) { throw error; -- cgit v1.2.3 From 4d9f7514ccea1669405a511d054b0fca8eae7550 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 30 Nov 2012 15:28:52 +0100 Subject: Fix NewtCanvasSWT's newtChild usage: Only use set newtChild if it's ready, i.e. SWTEDTUtil set and parented; Recognize pending resize. --- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index b56958303..18036b68b 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -79,6 +79,8 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { private volatile SWTNativeWindow nativeWindow; private volatile Window newtChild = null; + private volatile boolean newtChildReady = false; // ready if SWTEDTUtil is set and newtChild parented + private volatile boolean postSetSize = false; // pending resize /** * Creates an instance using {@link #NewtCanvasSWT(Composite, int, Window)} @@ -137,7 +139,11 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { @Override public void paintControl(final PaintEvent arg0) { if( null != nativeWindow || validateNative() ) { - if( null !=newtChild ) { + if( newtChildReady ) { + if( postSetSize ) { + newtChild.setSize(clientArea.width, clientArea.height); + postSetSize = false; + } newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height); } } @@ -210,8 +216,10 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) ) { clientArea = nClientArea; // write back new value - if( null != newtChild ) { + if( newtChildReady ) { newtChild.setSize(clientArea.width, clientArea.height); + } else { + postSetSize = true; } } } @@ -314,7 +322,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } /* package */ void configureNewtChild(boolean attach) { - + newtChildReady = attach; if( null != newtChild ) { newtChild.setKeyboardFocusHandler(null); if(attach) { @@ -345,9 +353,10 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { final Display newtDisplay = newtChild.getScreen().getDisplay(); final EDTUtil edt = new SWTEDTUtil(newtDisplay, getDisplay()); newtDisplay.setEDTUtil(edt); - edt.invoke(true, new Runnable() { public void run() { } } ); // start EDT + edt.invoke(true, null); // start EDT } + newtChild.setVisible(false); // set invisible to force defineSize(w,h) in WindowImpl since event dispatching might be postponed newtChild.setSize(w, h); newtChild.reparentWindow(nativeWindow); newtChild.setVisible(true); @@ -355,7 +364,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener // force this SWT Canvas to be focus-able, - // since this it is completely covered by the newtChild (z-order). + // since it is completely covered by the newtChild (z-order). setEnabled(true); } else { configureNewtChild(false); @@ -368,7 +377,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } private final void requestFocusNEWTChild() { - if( null != newtChild ) { + if( newtChildReady ) { newtChild.setFocusAction(null); newtChild.requestFocus(); } -- cgit v1.2.3 From 1f360ff73901b0a48f9ee310d8f2e5c4aad1e101 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 30 Nov 2012 15:50:22 +0100 Subject: NEWT WindowImpl: Don't issue native resize if invisible, simply use defineSize(..); Don't set persitent undecorated flag if child window at creation; Use local 'screen' directly. - Don't issue native resize if invisible, simply use defineSize(..) Invisible windows may not promote size change natively, hence simply setting the size via defineSize(..) is appropriate. Latter setVisible(true) will take size into account. - Don't set persitent undecorated flag if child window at creation Even if a window is a child at creation, it maybe reparented to top-level where the default behavior is to be expected. Undecorated top-level window shall require explicit setUndecorated(true). - Use local 'screen' directly. No need to make code more complicate .. --- src/newt/classes/jogamp/newt/WindowImpl.java | 31 ++++++++++++---------------- 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 4f8eb3d3a..5b26c3998 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -173,7 +173,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer window.parentWindowHandle = parentWindowHandle; window.screen = (ScreenImpl) screen; window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable(); - window.setUndecorated(0!=parentWindowHandle); window.instantiationFinished(); return window; } catch (Throwable t) { @@ -804,11 +803,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else if ( visible && !isNativeValid() && 0 < width && 0 < height ) { visibleAction = 2; // visible (create) defineSize(width, height); - } else if ( isNativeValid() ) { + } else if ( visible && isNativeValid() ) { visibleAction = 0; // this width/height will be set by windowChanged, called by the native implementation reconfigureWindowImpl(getX(), getY(), width, height, getReconfigureFlags(0, isVisible())); } else { + // invisible or invalid w/ 0 size visibleAction = 0; defineSize(width, height); } @@ -1045,8 +1045,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(null!=newParentWindowNEWT) { setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); } else { - Screen newScreen = NewtFactory.createCompatibleScreen(newParentWindow, getScreen()); - if( getScreen() != newScreen ) { + final Screen newScreen = NewtFactory.createCompatibleScreen(newParentWindow, screen); + if( screen != newScreen ) { // auto destroy on-the-fly created Screen/Display setScreen( (ScreenImpl) newScreen ); } @@ -1056,14 +1056,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else { operation = ReparentOperation.ACTION_NATIVE_CREATION_PENDING; } - } else if ( forceDestroyCreate || !NewtFactory.isScreenCompatible(newParentWindow, getScreen()) ) { + } else if ( forceDestroyCreate || !NewtFactory.isScreenCompatible(newParentWindow, screen) ) { // Destroy this window, may create a new compatible Screen/Display, // and mark it for creation. destroy(); if(null!=newParentWindowNEWT) { setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); } else { - setScreen( (ScreenImpl) NewtFactory.createCompatibleScreen(newParentWindow, getScreen()) ); + setScreen( (ScreenImpl) NewtFactory.createCompatibleScreen(newParentWindow, screen) ); } operation = ReparentOperation.ACTION_NATIVE_CREATION; } else { @@ -1078,7 +1078,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( null != parentWindow ) { // child -> top // put client to current parent+child position - Point p = getLocationOnScreen(null); + final Point p = getLocationOnScreen(null); x = p.getX(); y = p.getY(); } @@ -1134,7 +1134,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if( ReparentOperation.ACTION_NATIVE_REPARENTING == operation ) { - DisplayImpl display = (DisplayImpl) screen.getDisplay(); + final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date if(wasVisible) { @@ -1566,15 +1566,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public void runOnEDTIfAvail(boolean wait, final Runnable task) { - if(windowLock.isOwner(Thread.currentThread())) { + if( windowLock.isOwner( Thread.currentThread() ) ) { task.run(); } else { - Screen scrn = getScreen(); - if(null==scrn) { - throw new RuntimeException("Null screen of inner class: "+this); - } - DisplayImpl d = (DisplayImpl) scrn.getDisplay(); - d.runOnEDTIfAvail(wait, task); + ( (DisplayImpl) screen.getDisplay() ).runOnEDTIfAvail(wait, task); } } @@ -1899,7 +1894,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event) { if(isNativeValid()) { - ((DisplayImpl)getScreen().getDisplay()).enqueueEvent(wait, event); + ((DisplayImpl)screen.getDisplay()).enqueueEvent(wait, event); } } @@ -1914,7 +1909,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer repaintQueued=true; final boolean discardTO = QUEUED_EVENT_TO <= System.currentTimeMillis()-e.getWhen(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.consumeEvent: "+Thread.currentThread().getName()+" - queued "+e+", discard-to "+discardTO); + System.err.println("Window.consumeEvent: REPAINT "+Thread.currentThread().getName()+" - queued "+e+", discard-to "+discardTO); // Thread.dumpStack(); } return discardTO; // discardTO:=true -> consumed @@ -1930,7 +1925,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( null != windowLock.getOwner() ) { final boolean discardTO = QUEUED_EVENT_TO <= System.currentTimeMillis()-e.getWhen(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.consumeEvent: "+Thread.currentThread().getName()+" - queued "+e+", discard-to "+discardTO); + System.err.println("Window.consumeEvent: RESIZED "+Thread.currentThread().getName()+" - queued "+e+", discard-to "+discardTO); // Thread.dumpStack(); } return discardTO; // discardTO:=true -> consumed -- cgit v1.2.3 From b6f54d1714597ba2799160569b56139277db9e07 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 2 Dec 2012 03:55:08 +0100 Subject: NEWT WindowImpl fixes: surfaceLockCount-- if native lock fails; waitForVisible(.., fastFail:=false); waitForSize(..) @ setSize; reparent definePosition(..); - surfaceLockCount-- if native lock fails In case native lock fails, not only remove the windowLock but also decr. surfaceLockCount (proper roll back) - was a BUG! - waitForVisible(.., fastFail:=false) Don't fail fast if visibility wasn't reached. - waitForSize(..) @ setSize Wait for size change - otherwise an SWT child won't reach desired size. - reparent definePosition(..); Position might not get updated by WM events (SWT parent apparently) - Windows WindowDriver: Cleanup code a bit. --- src/newt/classes/jogamp/newt/WindowImpl.java | 50 ++++++++++++---------- .../jogamp/newt/driver/windows/WindowDriver.java | 14 +++--- 2 files changed, 36 insertions(+), 28 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 5b26c3998..a9294c1ff 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -572,6 +572,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } finally { if (LOCK_SURFACE_NOT_READY >= res) { + surfaceLockCount--; _wlock.unlock(); } } @@ -728,8 +729,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else if(WindowImpl.this.visible != visible) { if(isNativeValid()) { setVisibleImpl(visible, getX(), getY(), getWidth(), getHeight()); - WindowImpl.this.waitForVisible(visible, true); + WindowImpl.this.waitForVisible(visible, false); madeVisible = visible; + } else { + WindowImpl.this.visible = true; } } @@ -807,6 +810,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer visibleAction = 0; // this width/height will be set by windowChanged, called by the native implementation reconfigureWindowImpl(getX(), getY(), width, height, getReconfigureFlags(0, isVisible())); + WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); } else { // invisible or invalid w/ 0 size visibleAction = 0; @@ -1139,8 +1143,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(wasVisible) { setVisibleImpl(false, x, y, width, height); - WindowImpl.this.waitForVisible(false, true); - // some composite WM behave slacky .. give 'em chance to change state -> invisible, + WindowImpl.this.waitForVisible(false, false); + // FIXME: Some composite WM behave slacky .. give 'em chance to change state -> invisible, // even though we do exactly that (KDE+Composite) try { Thread.sleep(100); } catch (InterruptedException e) { } display.dispatchMessagesNative(); // status up2date @@ -1166,6 +1170,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer parentWindowLocked.unlockSurface(); } } + definePosition(x, y); // position might not get updated by WM events (SWT parent apparently) // set visible again if(ok) { @@ -1173,7 +1178,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(wasVisible) { setVisibleImpl(true, x, y, width, height); ok = WindowImpl.this.waitForVisible(true, false); - display.dispatchMessagesNative(); // status up2date if(ok) { ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); } @@ -1202,7 +1206,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparentWindow: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+x+"/"+y+" "+width+"x"+height); + System.err.println("Window.reparentWindow: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } } finally { _lock.unlock(); @@ -1223,7 +1227,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparentWindow: END-X ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+x+"/"+y+" "+width+"x"+height); + System.err.println("Window.reparentWindow: END-X ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } } } @@ -1557,7 +1561,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer for (int i = 0; i < keyListeners.size(); i++ ) { sb.append(keyListeners.get(i)+", "); } - sb.append("], windowLock "+windowLock+"]"); + sb.append("], windowLock "+windowLock+", surfaceLockCount "+surfaceLockCount+"]"); return sb.toString(); } @@ -2425,10 +2429,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private boolean waitForVisible(boolean visible, boolean failFast, long timeOut) { - DisplayImpl display = (DisplayImpl) screen.getDisplay(); + final DisplayImpl display = (DisplayImpl) screen.getDisplay(); + display.dispatchMessagesNative(); // status up2date for(long sleep = timeOut; 0= sleep) { final String msg = "Size/Pos not reached as requested within "+timeOut+"ms : requested "+w+"x"+h+", is "+getWidth()+"x"+getHeight(); if(failFast) { throw new NativeWindowException(msg); @@ -2481,8 +2485,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println(msg); Thread.dumpStack(); } + return false; + } else { + return true; } - return reached; } /** Triggered by implementation's WM events to update the position. */ diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 6aac8617c..2ec88852c 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -71,13 +71,15 @@ public class WindowDriver extends WindowImpl { if (0 != hdc) { throw new InternalError("surface not released"); } - hdc = GDI.GetDC(getWindowHandle()); - hmon = MonitorFromWindow0(getWindowHandle()); + final long hWnd = getWindowHandle(); + hdc = GDI.GetDC(hWnd); // return ( 0 == hdc ) ? LOCK_SURFACE_NOT_READY : ( hdc_old != hdc ) ? LOCK_SURFACE_CHANGED : LOCK_SUCCESS ; if( 0 == hdc ) { return LOCK_SURFACE_NOT_READY; - } + } + hmon = MonitorFromWindow0(hWnd); + if( hdc_old == hdc ) { return LOCK_SUCCESS; } @@ -217,14 +219,14 @@ public class WindowDriver extends WindowImpl { @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { - final Boolean[] res = new Boolean[] { Boolean.FALSE }; + final boolean[] res = new boolean[] { false }; this.runOnEDTIfAvail(true, new Runnable() { public void run() { - res[0] = Boolean.valueOf(setPointerVisible0(getWindowHandle(), pointerVisible)); + res[0] = setPointerVisible0(getWindowHandle(), pointerVisible); } }); - return res[0].booleanValue(); + return res[0]; } @Override -- cgit v1.2.3 From aa4b8c9abbf9529fdbb3c4982895c01f2698451f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 2 Dec 2012 04:09:41 +0100 Subject: NEWT EDTUtil: Simplify running state (default is running @ setEDTUtil()); Simplify DefaultEDTUtil impl. and fix concurrency leak w/ 'shouldStop' --- src/newt/classes/com/jogamp/newt/Display.java | 12 +-- .../classes/com/jogamp/newt/swt/SWTEDTUtil.java | 5 +- src/newt/classes/com/jogamp/newt/util/EDTUtil.java | 3 +- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 99 +++++++++++----------- src/newt/classes/jogamp/newt/DisplayImpl.java | 33 ++++---- .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 5 +- .../junit/newt/TestDisplayLifecycle01NEWT.java | 4 +- 7 files changed, 81 insertions(+), 80 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 4c263a195..993aa33eb 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -158,19 +158,15 @@ public abstract class Display { *

*

* If a previous one exists and it differs from the new one, - * it's being stopped, wait-until-idle and reset to allow restart. + * it's being stopped, wait-until-idle and reset to allow a restart at a later time. *

*

* If newEDTUtil is not null and equals the previous one, - * null is returned and no change is being made. + * no change is being made. *

*

- * Note that newEDTUtil will not be started by this method. - * To do so you may issue {@link EDTUtil#invoke(boolean, Runnable) invoke} - * on the new EDTUtil: - *

-     *          newEDTUtil.invoke(true, null);
-     * 
+ * Note that newEDTUtil will be started by this method, + * if it is not running yet. *

*/ public abstract EDTUtil setEDTUtil(EDTUtil newEDTUtil); diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java index 2203d744a..1c20fe524 100644 --- a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java @@ -150,7 +150,10 @@ public class SWTEDTUtil implements EDTUtil { // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); // Thread.dumpStack(); if(stop) { - nedt.shouldStop = true; + synchronized(nedt.sync) { + nedt.shouldStop = true; + nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) + } if(DEBUG) { System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); // Thread.dumpStack(); diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index 293e13592..0183da592 100644 --- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -113,7 +113,8 @@ public interface EDTUtil { /** * Append the final task to the EDT task queue, - * signals EDT to stop and wait until stopped.
+ * signals EDT to stop and wait until stopped.
+ * task maybe null
* Due to the nature of this method: *
    *
  • All previous queued tasks will be finished.
  • diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index b141f9d29..d8d04e79f 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -135,6 +135,11 @@ public class DefaultEDTUtil implements EDTUtil { invokeImpl(wait, task, false); } + private static Runnable nullTask = new Runnable() { + @Override + public void run() { } + }; + private void invokeImpl(boolean wait, Runnable task, boolean stop) { Throwable throwable = null; RunnableTask rTask = null; @@ -151,39 +156,50 @@ public class DefaultEDTUtil implements EDTUtil { } // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); // Thread.dumpStack(); - if(stop) { - edt.shouldStop = true; - if(DEBUG) { - System.err.println(Thread.currentThread()+": Default-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - tasks: "+edt.tasks.size()+" - "+edt); - // Thread.dumpStack(); + if( isCurrentThreadEDT() ) { + if(null != task) { + task.run(); } - } else if( !edt.isRunning() ) { - // start if should not stop && not started yet - startImpl(); - } - if( null == task ) { - wait = false; - } else if( isCurrentThreadEDT() ) { - task.run(); wait = false; // running in same thread (EDT) -> no wait - if(stop && edt.tasks.size()>0) { - System.err.println(Thread.currentThread()+": Warning: Default-EDT about (2) to stop, having remaining tasks: "+edt.tasks.size()+" - "+edt); - if(DEBUG) { - Thread.dumpStack(); + if(stop) { + edt.shouldStop = true; + if( edt.tasks.size()>0 ) { + System.err.println(Thread.currentThread()+": Warning: Default-EDT about (2) to stop, task executed. Remaining tasks: "+edt.tasks.size()+" - "+edt); + if(DEBUG) { + Thread.dumpStack(); + } } } } else { - synchronized(edt.tasks) { - wait = wait && edt.isRunning(); - rTask = new RunnableTask(task, - wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */); - if(stop) { - rTask.setAttachment(new Boolean(true)); // mark final task + if( !edt.isRunning() ) { + if( !stop ) { + startImpl(); + } else { + // drop task and don't wait + task = null; + System.err.println(Thread.currentThread()+": Warning: Default-EDT is about (3) to stop and stopped already, dropping task. Remaining tasks: "+edt.tasks.size()+" - "+edt); + if(true || DEBUG) { + Thread.dumpStack(); + } + } + } else if(stop && null == task) { + task = nullTask; + } + + if(null != task) { + synchronized(edt.tasks) { + rTask = new RunnableTask(task, + wait ? rTaskLock : null, + true /* always catch and report Exceptions, don't disturb EDT */); + if(stop) { + rTask.setAttachment(new Boolean(true)); // mark final task, will imply shouldStop:=true + } + // append task .. + edt.tasks.add(rTask); + edt.tasks.notifyAll(); } - // append task .. - edt.tasks.add(rTask); - edt.tasks.notifyAll(); + } else { + wait = false; } } } @@ -305,6 +321,9 @@ public class DefaultEDTUtil implements EDTUtil { if(tasks.size()>0) { task = tasks.remove(0); tasks.notifyAll(); + if( null != task.getAttachment() ) { + shouldStop = true; + } } } if(null!=task) { @@ -330,30 +349,8 @@ public class DefaultEDTUtil implements EDTUtil { System.err.println(getName()+": Default-EDT run() END "+ getName()+", tasks: "+tasks.size()+", "+rt+", "+error); } synchronized(edtLock) { - if(null==error) { - synchronized(tasks) { - // drain remaining tasks (stop not on EDT), - // while having tasks and no previous-task, or previous-task is non final - RunnableTask task = null; - while ( ( null == task || task.getAttachment() == null ) && tasks.size() > 0 ) { - task = tasks.remove(0); - task.run(); - tasks.notifyAll(); - } - if(DEBUG) { - if(null!=task && task.getAttachment()==null) { - System.err.println(getName()+" Warning: Default-EDT exit: Last task Not Final: "+tasks.size()+", "+task+" - "+edt); - } else if(tasks.size()>0) { - System.err.println(getName()+" Warning: Default-EDT exit: Remaining tasks Post Final: "+tasks.size()); - } - Thread.dumpStack(); - } - } - } - isRunning = !shouldStop; - if(!isRunning) { - edtLock.notifyAll(); - } + isRunning = false; + edtLock.notifyAll(); } if(DEBUG) { System.err.println(getName()+": Default-EDT run() EXIT "+ getName()+", exception: "+error); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 317535805..20b915cae 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -84,9 +84,8 @@ public abstract class DisplayImpl extends Display { display.hashCode = display.fqname.hashCode(); displayList.add(display); } - if(null == display.edtUtil) { - display.setEDTUtil(null); // device's default if EDT is used, or null - } + display.setEDTUtil(display.edtUtil); // device's default if EDT is used, or null + if(DEBUG) { System.err.println("Display.create() NEW: "+display+" "+getThreadName()); } @@ -166,20 +165,24 @@ public abstract class DisplayImpl extends Display { @Override public EDTUtil setEDTUtil(EDTUtil newEDTUtil) { + final EDTUtil oldEDTUtil = edtUtil; if(null == newEDTUtil) { - newEDTUtil = createEDTUtil(); - } else if( newEDTUtil == edtUtil ) { if(DEBUG) { - System.err.println("Display.setEDTUtil: "+newEDTUtil+" - keep!"); + System.err.println("Display.setEDTUtil(default): "+oldEDTUtil+" -> "+newEDTUtil); + } + edtUtil = createEDTUtil(); + } else if( newEDTUtil != edtUtil ) { + if(DEBUG) { + System.err.println("Display.setEDTUtil(custom): "+oldEDTUtil+" -> "+newEDTUtil); } - return null; // no change + removeEDT( null ); + edtUtil = newEDTUtil; + } else if( DEBUG ) { + System.err.println("Display.setEDTUtil: "+newEDTUtil+" - keep!"); } - final EDTUtil oldEDTUtil = edtUtil; - if(DEBUG) { - System.err.println("Display.setEDTUtil: "+oldEDTUtil+" -> "+newEDTUtil); + if( !edtUtil.isRunning() ) { // start EDT if not running yet + edtUtil.invoke(true, null); } - removeEDT( new Runnable() { public void run() {} } ); - edtUtil = newEDTUtil; return oldEDTUtil; } @@ -209,11 +212,7 @@ public abstract class DisplayImpl extends Display { public boolean validateEDT() { if(0==refCount && null==aDevice && null != edtUtil && edtUtil.isRunning()) { - removeEDT( new Runnable() { - public void run() { - // nop - } - } ); + removeEDT( null ); return true; } return false; diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index cb9bc90b8..27d0f3506 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -140,7 +140,10 @@ public class AWTEDTUtil implements EDTUtil { // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); // Thread.dumpStack(); if(stop) { - nedt.shouldStop = true; + synchronized(nedt.sync) { + nedt.shouldStop = true; + nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) + } if(DEBUG) { System.err.println(Thread.currentThread()+": AWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); // Thread.dumpStack(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java index c9450c2d6..e4867e3fe 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java @@ -89,7 +89,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase { Assert.assertEquals(0,display.getReferenceCount()); Assert.assertEquals(false,display.isNativeValid()); Assert.assertNotNull(display.getEDTUtil()); - Assert.assertEquals(false,display.getEDTUtil().isRunning()); + Assert.assertEquals(true,display.getEDTUtil().isRunning()); Assert.assertEquals(0,screen.getReferenceCount()); Assert.assertEquals(false,screen.isNativeValid()); @@ -201,6 +201,8 @@ public class TestDisplayLifecycle01NEWT extends UITestCase { Assert.assertEquals(false,display.isNativeValid()); Assert.assertNotNull(display.getEDTUtil()); Assert.assertEquals(false,display.getEDTUtil().isRunning()); + display.getEDTUtil().invoke(true, null); + Assert.assertEquals(true,display.getEDTUtil().isRunning()); Assert.assertEquals(0,screen.getReferenceCount()); Assert.assertEquals(false,screen.isNativeValid()); -- cgit v1.2.3 From 571c21df9310d043b08a4a72064617cbe6eee0fa Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 2 Dec 2012 04:14:30 +0100 Subject: SWT GLCanvas/NewtCanvasSWT: Check isVisible() @ validation; NewtCanvasSWT remove just introduced setVisible(false) and adapt to setEDTUtil() changes. ; Enhance Bug 643 unit test: Also test NEWT EDT and pre-visible GLWindow. - SWT GLCanvas/NewtCanvasSWT: Check isVisible() @ validation - NewtCanvasSWT remove just introduced setVisible(false) and adapt to setEDTUtil() changes - Enhance Bug 643 unit test: Also test NEWT EDT and pre-visible GLWindow. --- make/scripts/java-win64-dbg.bat | 1 + .../classes/com/jogamp/opengl/swt/GLCanvas.java | 2 +- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 15 +-- .../swt/TestNewtCanvasSWTBug628ResizeDeadlock.java | 6 +- .../junit/jogl/swt/TestSWTBug643AsyncExec.java | 150 ++++++++++++++------- 5 files changed, 114 insertions(+), 60 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index c7e8ea599..7ececa5e4 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -46,6 +46,7 @@ REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djo REM set D_ARGS="-Djogl.debug.GLContext" "-Dnewt.debug=all" REM set D_ARGS="-Dnewt.debug.Window" "-Dnativewindow.debug.TraceLock" REM set D_ARGS="-Dnativewindow.debug.TraceLock" +REM set D_ARGS="-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Djogl.debug.GLContext" REM set D_ARGS="-Dnewt.debug.Screen" "-Dnewt.debug.EDT" "-Dnativewindow.debug=all" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 38dd71f5e..a080a7045 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -423,7 +423,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /** assumes drawable == null ! */ protected final boolean validateDrawableAndContext() { - if( GLCanvas.this.isDisposed() ) { + if( isDisposed() || !isVisible() ) { return false; } final Rectangle nClientArea = clientArea; diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 18036b68b..5af7afeb3 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -171,7 +171,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { /** assumes nativeWindow == null ! */ protected final boolean validateNative() { - if( isDisposed() ) { + if( isDisposed() || !isVisible() ) { return false; } updateSizeCheck(); @@ -347,22 +347,19 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { updateSizeCheck(); final int w = clientArea.width; final int h = clientArea.height; - + // set SWT EDT and start it { final Display newtDisplay = newtChild.getScreen().getDisplay(); - final EDTUtil edt = new SWTEDTUtil(newtDisplay, getDisplay()); - newtDisplay.setEDTUtil(edt); - edt.invoke(true, null); // start EDT + newtDisplay.setEDTUtil( new SWTEDTUtil(newtDisplay, getDisplay()) ); } - newtChild.setVisible(false); // set invisible to force defineSize(w,h) in WindowImpl since event dispatching might be postponed - newtChild.setSize(w, h); + newtChild.setSize(w, h); newtChild.reparentWindow(nativeWindow); newtChild.setVisible(true); - configureNewtChild(true); + configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener - + // force this SWT Canvas to be focus-able, // since it is completely covered by the newtChild (z-order). setEnabled(true); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java index 834261d22..a0874e609 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java @@ -341,7 +341,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { } { - new Thread(new Runnable() { + final Thread t = new Thread(new Runnable() { @Override public void run() { try { @@ -359,7 +359,9 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { } catch( InterruptedException e ) { } shallStop = true; dsc.display.wake(); - } } ).start(); + } } ); + t.setDaemon(true); + t.start(); } try { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java index ccea76c02..0a47b96eb 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java @@ -50,10 +50,13 @@ import junit.framework.Assert; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.newt.opengl.GLWindow ; import com.jogamp.newt.swt.NewtCanvasSWT ; +import com.jogamp.newt.swt.SWTEDTUtil; import com.jogamp.opengl.swt.GLCanvas; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; //////////////////////////////////////////////////////////////////////////////// @@ -61,69 +64,93 @@ import com.jogamp.opengl.test.junit.util.UITestCase; public class TestSWTBug643AsyncExec extends UITestCase { static int duration = 500; + static boolean useAnimator = false; //////////////////////////////////////////////////////////////////////////////// - static void resetAsyncExecCount() { - synchronized(asyncExecCountSync) { - asyncExecCount=0; + static void resetSWTAndNEWTEDTCounter() { + synchronized(swtCountSync) { + swtCount=0; + } + synchronized(edtCountSync) { + edtCount=0; + } + } + static int incrSWTCount() { + synchronized(swtCountSync) { + swtCount++; + return swtCount; + } + } + static int getSWTCount() { + synchronized(swtCountSync) { + return swtCount; } } - static int incrAsyncExecCount() { - synchronized(asyncExecCountSync) { - asyncExecCount++; - return asyncExecCount; + static int incrNEWTCount() { + synchronized(edtCountSync) { + edtCount++; + return edtCount; } } - static int getAsyncExecCount() { - synchronized(asyncExecCountSync) { - return asyncExecCount; + static int getNEWTCount() { + synchronized(edtCountSync) { + return edtCount; } } - static Object asyncExecCountSync = new Object(); - static int asyncExecCount = 0; + static Object swtCountSync = new Object(); + static int swtCount = 0; + static Object edtCountSync = new Object(); + static int edtCount = 0; //////////////////////////////////////////////////////////////////////////////// - static class AsyncExecFeederThread extends Thread { + static class AsyncExecEDTFeederThread extends Thread { volatile boolean shallStop = false; - private Display display ; - private int n ; + private Display swtDisplay ; + private jogamp.newt.DisplayImpl newtDisplay; + private int swtN, newtN ; - public AsyncExecFeederThread( Display display ) + public AsyncExecEDTFeederThread( Display swtDisplay, com.jogamp.newt.Display newtDisplay ) { super(); - this.display = display ; + this.swtDisplay = swtDisplay ; + this.newtDisplay = (jogamp.newt.DisplayImpl)newtDisplay; } - final Runnable asyncAction = new Runnable() { + final Runnable swtAsyncAction = new Runnable() { public void run() { - ++n ; - System.err.println("[A-i shallStop "+shallStop+", disposed "+display.isDisposed()+"]: Counter[loc "+n+", glob: "+incrAsyncExecCount()+"]"); + ++swtN ; + System.err.println("[SWT A-i shallStop "+shallStop+"]: Counter[loc "+swtN+", glob: "+incrSWTCount()+"]"); + } }; + + final Runnable newtAsyncAction = new Runnable() { + public void run() + { + ++newtN ; + System.err.println("[NEWT A-i shallStop "+shallStop+"]: Counter[loc "+newtN+", glob: "+incrNEWTCount()+"]"); } }; public void run() { - System.err.println("[A-0 shallStop "+shallStop+", disposed "+display.isDisposed()+"]"); - - // final Display d = Display.getDefault(); - final Display d = this.display; + System.err.println("[A-0 shallStop "+shallStop+"]"); - while( !shallStop && !d.isDisposed() ) + while( !shallStop && !swtDisplay.isDisposed() ) { try { - System.err.println("[A-n shallStop "+shallStop+", disposed "+d.isDisposed()+"]"); - d.asyncExec( asyncAction ); - d.wake(); - + swtDisplay.asyncExec( swtAsyncAction ); + if(null != newtDisplay && newtDisplay.isNativeValid() && newtDisplay.getEDTUtil().isRunning()) { + // only perform async exec on valid and already running NEWT EDT! + newtDisplay.runOnEDTIfAvail(false, newtAsyncAction); + } Thread.sleep( 50L ) ; } catch( InterruptedException e ) { break ; } } - System.err.println("*R-Exit* shallStop "+shallStop+", disposed "+d.isDisposed()); + System.err.println("*R-Exit* shallStop "+shallStop); } } @@ -179,12 +206,13 @@ public class TestSWTBug643AsyncExec extends UITestCase { } } - private void testImpl(boolean useJOGLGLCanvas, boolean useNewtCanvasSWT) throws InterruptedException, AWTException, InvocationTargetException { - resetAsyncExecCount(); + private void testImpl(boolean useJOGLGLCanvas, boolean useNewtCanvasSWT, boolean glWindowPreVisible) throws InterruptedException, AWTException, InvocationTargetException { + resetSWTAndNEWTEDTCounter(); final SWT_DSC dsc = new SWT_DSC(); dsc.init(); + final com.jogamp.newt.Display newtDisplay; { final GLProfile gl2Profile = GLProfile.get( GLProfile.GL2 ) ; final GLCapabilities caps = new GLCapabilities( gl2Profile ) ; @@ -192,42 +220,58 @@ public class TestSWTBug643AsyncExec extends UITestCase { final GLAutoDrawable glad; if( useJOGLGLCanvas ) { glad = GLCanvas.create(dsc.composite, 0, caps, null, null); + glad.addGLEventListener( new GearsES2() ) ; + newtDisplay = null; } else if( useNewtCanvasSWT ) { final GLWindow glWindow = GLWindow.create( caps ) ; + glWindow.addGLEventListener( new GearsES2() ) ; + newtDisplay = glWindow.getScreen().getDisplay(); + if( glWindowPreVisible ) { + newtDisplay.setEDTUtil(new SWTEDTUtil(newtDisplay, dsc.display)); // Especially Windows requires creation access via same thread! + glWindow.setVisible(true); + AWTRobotUtil.waitForRealized(glWindow, true); + Thread.sleep(120); // let it render a bit, before consumed by SWT + } glad = glWindow; NewtCanvasSWT.create( dsc.composite, 0, glWindow ) ; } else { throw new InternalError("XXX"); } - glad.addGLEventListener( new GearsES2() ) ; + if(useAnimator) { + Animator animator = new Animator(glad); + animator.start(); + } } + System.err.println("**** Pre Shell Open"); dsc.display.syncExec( new Runnable() { public void run() { dsc.shell.setText( "NewtCanvasSWT Resize Bug Demo" ) ; dsc.shell.setSize( 400, 450 ) ; dsc.shell.open() ; } } ); + System.err.println("**** Post Shell Open"); shallStop = false; + + final int[] counterBeforeExit = new int[] { 0 /* SWT */, 0 /* NEWT */ }; - final int[] ayncExecCountBeforeExit = new int[] { 0 }; - - final AsyncExecFeederThread asyncExecFeeder; + final AsyncExecEDTFeederThread asyncExecFeeder; { - asyncExecFeeder = new AsyncExecFeederThread( dsc.display) ; + asyncExecFeeder = new AsyncExecEDTFeederThread(dsc.display, newtDisplay) ; asyncExecFeeder.start() ; } { - new Thread(new Runnable() { + final Thread t = new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(duration); } catch (InterruptedException e) {} - ayncExecCountBeforeExit[0] = getAsyncExecCount(); + counterBeforeExit[0] = getSWTCount(); + counterBeforeExit[1] = getNEWTCount(); asyncExecFeeder.shallStop = true; try { @@ -235,15 +279,15 @@ public class TestSWTBug643AsyncExec extends UITestCase { } catch( InterruptedException e ) { } shallStop = true; dsc.display.wake(); - } } ).start(); + } } ); + t.setDaemon(true); + t.start(); } try { final Display d = dsc.display; while( !shallStop && !d.isDisposed() ) { - final boolean r = d.readAndDispatch(); - System.err.print(","); - if( !r ) { + if( !d.readAndDispatch() ) { dsc.display.sleep(); } } @@ -256,24 +300,34 @@ public class TestSWTBug643AsyncExec extends UITestCase { dsc.dispose(); - System.err.println("AsyncExecCount before exit: " + ayncExecCountBeforeExit[0]); - Assert.assertTrue("AsyncExecCount not greater zero before dispose!", 0 < ayncExecCountBeforeExit[0]); + System.err.println("EDT Counter before exit: SWT " + counterBeforeExit[0] + ", NEWT "+counterBeforeExit[1]); + Assert.assertTrue("SWT EDT Counter not greater zero before dispose!", 0 < counterBeforeExit[0]); + if( null != newtDisplay ) { + Assert.assertTrue("NEWT EDT Counter not greater zero before dispose!", 0 < counterBeforeExit[1]); + } } @Test public void test01JOGLGLCanvas() throws InterruptedException, AWTException, InvocationTargetException { - testImpl(true /* useJOGLGLCanvas */, false /* useNewtCanvasSWT */); + testImpl(true /* useJOGLGLCanvas */, false /* useNewtCanvasSWT */, false /* glWindowPreVisible */); + } + + @Test + public void test02NewtCanvasSWTSimple() throws InterruptedException, AWTException, InvocationTargetException { + testImpl(false /* useJOGLGLCanvas */, true /* useNewtCanvasSWT */, false /* glWindowPreVisible */); } @Test - public void test02NewtCanvasSWT() throws InterruptedException, AWTException, InvocationTargetException { - testImpl(false /* useJOGLGLCanvas */, true /* useNewtCanvasSWT */); + public void test02NewtCanvasSWTPreVisible() throws InterruptedException, AWTException, InvocationTargetException { + testImpl(false /* useJOGLGLCanvas */, true /* useNewtCanvasSWT */, true /* glWindowPreVisible */); } public static void main( String[] args ) { for(int i=0; i Date: Tue, 4 Dec 2012 07:10:59 +0100 Subject: SWT GLCanvas: Fix sporadic drop of redraw on X11 _and_ allow using custom GLCapabilities on X11 (feature complete) To allow custom GLCapabilities, we had to use native parenting on X11 w/ a new child window. The desired visualID chosen by the users GLCapabilities is passed to the new child window. The redraw drops must be caused by the original GDK or the new child GDK window. Now we use a plain X11 child window similar to NEWT's X11 window and NewtCanvasSWT, which doesn't expose this bug. (Note: SWTAccessor/GLCanvas still contains the uncommented GDK code path for further inspection, if desired) Also added SWTNewtEventFactory to test event handling on the SWT GLCanvas w/ GearsES2. TestSWTJOGLGLCanvas01GLn tests custom GLCapabilities now. SWTEDTUtil has been moved to private: com.jogamp.newt.swt -> jogamp.newt.swt. --- make/build-common.xml | 1 + make/build-newt.xml | 2 +- make/config/nativewindow/x11-CustomJavaCode.java | 5 +- make/scripts/tests-x32.sh | 2 + make/scripts/tests-x64.bat | 4 +- make/scripts/tests.sh | 6 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 350 ++++++++++++++------- .../com/jogamp/nativewindow/swt/SWTAccessor.java | 345 +++++++++++++------- .../x11/X11DummyUpstreamSurfaceHook.java | 4 +- src/nativewindow/native/x11/Xmisc.c | 123 +++++++- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 82 +++-- .../classes/com/jogamp/newt/swt/SWTEDTUtil.java | 313 ------------------ src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java | 313 ++++++++++++++++++ .../jogamp/newt/swt/event/SWTNewtEventFactory.java | 249 +++++++++++++++ .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 8 +- .../swt/TestNewtCanvasSWTBug628ResizeDeadlock.java | 5 +- .../junit/jogl/swt/TestSWTBug643AsyncExec.java | 26 +- .../junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java | 16 +- 18 files changed, 1236 insertions(+), 618 deletions(-) delete mode 100644 src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java create mode 100644 src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java create mode 100644 src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java (limited to 'src/newt/classes') diff --git a/make/build-common.xml b/make/build-common.xml index a718ae09a..414b0eba2 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -428,6 +428,7 @@ + diff --git a/make/build-newt.xml b/make/build-newt.xml index 7b9a51863..c3b51141f 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -112,7 +112,7 @@ value="com/jogamp/newt/awt/** com/jogamp/newt/event/awt/** jogamp/newt/awt/** ${java.part.driver.awt}"/> + value="com/jogamp/newt/swt/** jogamp/newt/swt/**"/> diff --git a/make/config/nativewindow/x11-CustomJavaCode.java b/make/config/nativewindow/x11-CustomJavaCode.java index 8e5da3b2d..4240c5e2f 100644 --- a/make/config/nativewindow/x11-CustomJavaCode.java +++ b/make/config/nativewindow/x11-CustomJavaCode.java @@ -28,8 +28,9 @@ public static native int DefaultVisualID(long display, int screen); - public static native long CreateDummyWindow(long display, int screen_index, int visualID, int width, int height); - public static native void DestroyDummyWindow(long display, long window); + public static native long CreateWindow(long parent, long display, int screen_index, int visualID, int width, int height, boolean input, boolean visible); + public static native void DestroyWindow(long display, long window); + public static native void SetWindowPosSize(long display, long window, int x, int y, int width, int height); public static Point GetRelativeLocation(long display, int screen_index, long src_win, long dest_win, int src_x, int src_y) { return (Point) GetRelativeLocation0(display, screen_index, src_win, dest_win, src_x, src_y); diff --git a/make/scripts/tests-x32.sh b/make/scripts/tests-x32.sh index a3aed84c3..858ed5fd8 100755 --- a/make/scripts/tests-x32.sh +++ b/make/scripts/tests-x32.sh @@ -6,6 +6,8 @@ if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86.sh ] ; then . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86.sh fi +export SWT_CLASSPATH=`pwd`/lib/swt/gtk-linux-x86/swt-debug.jar + . $SDIR/tests.sh `which java` -d32 ../build-x86 $* diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 7a2946d31..db7e27264 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -54,10 +54,10 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestP REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 0669efb37..628ab706b 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -113,7 +113,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow" - #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT" + D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" @@ -370,10 +370,10 @@ function testawtswt() { # #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* -#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* +testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock $* -testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec $* # # newt.awt (testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index a080a7045..0320c63ae 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -29,10 +29,16 @@ package com.jogamp.opengl.swt; import java.util.List; +import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.UpstreamSurfaceHook; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.opengl.GL; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; @@ -48,23 +54,20 @@ import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; import javax.media.opengl.Threading; +import jogamp.nativewindow.x11.X11Util; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableHelper; import jogamp.opengl.GLDrawableImpl; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.ControlListener; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import com.jogamp.common.GlueGenVersion; @@ -73,13 +76,14 @@ import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.swt.SWTAccessor; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.opengl.JoglVersion; /** * Native SWT Canvas implementing GLAutoDrawable - * - *

    Note: To employ custom GLCapabilities, NewtCanvasSWT shall be used instead.

    - * + *

    + * Implementation allows use of custom {@link GLCapabilities}. + *

    */ public class GLCanvas extends Canvas implements GLAutoDrawable { private static final boolean DEBUG = Debug.debug("GLCanvas"); @@ -103,11 +107,15 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final GLCapabilitiesImmutable capsRequested; private final GLCapabilitiesChooser capsChooser; + private volatile Rectangle clientArea; private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access - private GLContextImpl context; + private volatile GLContextImpl context; /* Native window surface */ - private AbstractGraphicsDevice device; + private final boolean useX11GTK; + private volatile long gdkWindow; // either GDK child window .. + private volatile long x11Window; // .. or X11 child window (for GL rendering) + private final AbstractGraphicsScreen screen; /* Construction parameters stored for GLAutoDrawable accessor methods */ private int additionalCtxCreationFlags = 0; @@ -135,7 +143,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public void run() { if (sendReshape) { - helper.reshape(GLCanvas.this, 0, 0, getWidth(), getHeight()); + helper.reshape(GLCanvas.this, 0, 0, clientArea.width, clientArea.height); sendReshape = false; } helper.display(GLCanvas.this); @@ -143,7 +151,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { }; /* Action to make specified context current prior to running displayAction */ - private final Runnable makeCurrentAndDisplayOnEDTAction = new Runnable() { + private final Runnable makeCurrentAndDisplayOnGLAction = new Runnable() { @Override public void run() { final RecursiveLock _lock = lock; @@ -159,13 +167,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { }; /* Swaps buffers, assuming the GLContext is current */ - private final Runnable swapBuffersOnEDTAction = new Runnable() { + private final Runnable swapBuffersOnGLAction = new Runnable() { @Override public void run() { final RecursiveLock _lock = lock; _lock.lock(); try { - if(null != drawable && !GLCanvas.this.isDisposed() ) { + final boolean drawableOK = null != drawable && drawable.isRealized(); + if( drawableOK && !GLCanvas.this.isDisposed() ) { drawable.swapBuffers(); } } finally { @@ -212,10 +221,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { drawable.setRealized(false); drawable = null; } - if (null != device) { - device.close(); - device = null; + if( 0 != x11Window) { + SWTAccessor.destroyX11Window(screen.getDevice(), x11Window); + x11Window = 0; + } else if( 0 != gdkWindow) { + SWTAccessor.destroyGDKWindow(gdkWindow); + gdkWindow = 0; } + screen.getDevice().close(); if (animatorPaused) { animator.resume(); @@ -249,11 +262,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } }; - /** - * Storage for the client area rectangle so that it may be accessed from outside of the SWT thread. - */ - private volatile Rectangle clientArea; - /** * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser, GLContext)} * on the SWT thread. @@ -293,72 +301,80 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * @param style * Optional SWT style bit-field. The {@link SWT#NO_BACKGROUND} bit is set before passing this up to the * Canvas constructor, so OpenGL handles the background. - * @param caps + * @param capsReqUser * Optional GLCapabilities. If not provided, the default capabilities for the default GLProfile for the * graphics device determined by the parent Composite are used. Note that the GLCapabilities that are * actually used may differ based on the capabilities of the graphics device. - * @param chooser + * @param capsChooser * Optional GLCapabilitiesChooser to customize the selection of the used GLCapabilities based on the * requested GLCapabilities, and the available capabilities of the graphics device. * @param shareWith * Optional GLContext to share state (textures, vbos, shaders, etc.) with. */ - public GLCanvas(final Composite parent, final int style, GLCapabilitiesImmutable caps, - final GLCapabilitiesChooser chooser, final GLContext shareWith) { + public GLCanvas(final Composite parent, final int style, GLCapabilitiesImmutable capsReqUser, + final GLCapabilitiesChooser capsChooser, final GLContext shareWith) { /* NO_BACKGROUND required to avoid clearing bg in native SWT widget (we do this in the GL display) */ super(parent, style | SWT.NO_BACKGROUND); GLProfile.initSingleton(); // ensure JOGL is completly initialized SWTAccessor.setRealized(this, true); - + clientArea = GLCanvas.this.getClientArea(); /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). * Note: SWT is owner of the native handle, hence closing operation will be a NOP. */ - device = SWTAccessor.getDevice(this); + final AbstractGraphicsDevice swtDevice = SWTAccessor.getDevice(this); + + useX11GTK = SWTAccessor.useX11GTK(); + if(useX11GTK) { + // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering + final long x11DeviceHandle = X11Util.openDisplay(swtDevice.getConnection()); + if( 0 == x11DeviceHandle ) { + throw new RuntimeException("Error creating display(EDT): "+swtDevice.getConnection()); + } + final AbstractGraphicsDevice x11Device = new X11GraphicsDevice(x11DeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); + screen = SWTAccessor.getScreen(x11Device, -1 /* default */); + } else { + screen = SWTAccessor.getScreen(swtDevice, -1 /* default */); + } /* Select default GLCapabilities if none was provided, otherwise clone provided caps to ensure safety */ - if(null == caps) { - caps = new GLCapabilities(GLProfile.getDefault(device)); + if(null == capsReqUser) { + capsReqUser = new GLCapabilities(GLProfile.getDefault(screen.getDevice())); } - this.capsRequested = caps; - this.capsChooser = chooser; + + this.capsRequested = capsReqUser; + this.capsChooser = capsChooser; this.shareWith = shareWith; // post create .. when ready + gdkWindow = 0; + x11Window = 0; drawable = null; context = null; - /* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */ - /* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */ - addPaintListener(new PaintListener() { - @Override - public void paintControl(final PaintEvent arg0) { - if ( !helper.isAnimatorAnimatingOnOtherThread() ) { - display(); // checks: null != drawable - } - } - }); - - addControlListener(new ControlListener() { - @Override - public void controlMoved(ControlEvent e) { - } - - @Override - public void controlResized(final ControlEvent arg0) { - updateSizeCheck(); - } - }); - - addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - GLCanvas.this.dispose(); - } - }); + final Listener listener = new Listener () { + @Override + public void handleEvent (Event event) { + switch (event.type) { + case SWT.Paint: + displayIfNoAnimatorNoCheck(); + break; + case SWT.Resize: + updateSizeCheck(); + break; + case SWT.Dispose: + GLCanvas.this.dispose(); + break; + } + } + }; + addListener (SWT.Resize, listener); + addListener (SWT.Paint, listener); + addListener (SWT.Dispose, listener); } + private final UpstreamSurfaceHook swtCanvasUpStreamHook = new UpstreamSurfaceHook() { @Override public final void create(ProxySurface s) { /* nop */ } @@ -390,11 +406,13 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { ) { clientArea = nClientArea; // write back new value - GLDrawableImpl _drawable = drawable; - if( null != _drawable ) { - if(DEBUG) { - System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+nClientArea.width+"x"+nClientArea.height+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); - } + final GLDrawableImpl _drawable = drawable; + final boolean drawableOK = null != _drawable && _drawable.isRealized(); + if(DEBUG) { + final long dh = drawableOK ? _drawable.getHandle() : 0; + System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+nClientArea.x+"/"+nClientArea.y+" "+nClientArea.width+"x"+nClientArea.height+" - drawableHandle 0x"+Long.toHexString(dh)); + } + if( drawableOK ) { if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) { final RecursiveLock _lock = lock; _lock.lock(); @@ -407,66 +425,154 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } finally { _lock.unlock(); } - } - sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock - } + } + } + if(0 != x11Window) { + SWTAccessor.resizeX11Window(screen.getDevice(), clientArea, x11Window); + } else if(0 != gdkWindow) { + SWTAccessor.resizeGDKWindow(clientArea, gdkWindow); + } + sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock } } - @Override - public void display() { - if( null != drawable || validateDrawableAndContext() ) { - runInGLThread(makeCurrentAndDisplayOnEDTAction); - } + private boolean isValidAndVisibleOnEDTActionResult; + private final Runnable isValidAndVisibleOnEDTAction = new Runnable() { + @Override + public void run() { + isValidAndVisibleOnEDTActionResult = !GLCanvas.this.isDisposed() && GLCanvas.this.isVisible(); + } }; + + private final boolean isValidAndVisibleOnEDT() { + synchronized(isValidAndVisibleOnEDTAction) { + runOnEDTIfAvail(true, isValidAndVisibleOnEDTAction); + return isValidAndVisibleOnEDTActionResult; + } } - - /** assumes drawable == null ! */ - protected final boolean validateDrawableAndContext() { - if( isDisposed() || !isVisible() ) { + /** assumes drawable == null || !drawable.isRealized() ! Checks of !isDispose() and isVisible() */ + protected final boolean validateDrawableAndContextWithCheck() { + if( !isValidAndVisibleOnEDT() ) { return false; } + return validateDrawableAndContextPostCheck(); + } + + /** assumes drawable == null || !drawable.isRealized() ! No check of !isDispose() and isVisible() */ + protected final boolean validateDrawableAndContextPostCheck() { final Rectangle nClientArea = clientArea; if(0 >= nClientArea.width || 0 >= nClientArea.height) { return false; } + final boolean res; final RecursiveLock _lock = lock; _lock.lock(); try { - final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(capsRequested.getGLProfile()); - - /* Native handle for the control, used to associate with GLContext */ - final long nativeWindowHandle = SWTAccessor.getWindowHandle(this); - - /* Create a NativeWindow proxy for the SWT canvas */ - ProxySurface proxySurface = null; - try { - proxySurface = glFactory.createProxySurface(device, 0 /* screenIdx */, nativeWindowHandle, - capsRequested, capsChooser, swtCanvasUpStreamHook); - } catch (GLException gle) { - // not ready yet .. - if(DEBUG) { System.err.println(gle.getMessage()); } + if(null == drawable) { + createDrawableAndContext(); } - - if(null != proxySurface) { - /* Associate a GL surface with the proxy */ - drawable = (GLDrawableImpl) glFactory.createGLDrawable(proxySurface); + if(null != drawable) { drawable.setRealized(true); - - context = (GLContextImpl) drawable.createContext(shareWith); + res = drawable.isRealized(); + } else { + res = false; } } finally { _lock.unlock(); + } + + if(res) { + sendReshape = true; + if(DEBUG) { + System.err.println("SWT GLCanvas realized! "+this+", "+drawable); + // Thread.dumpStack(); + } } - final boolean res = null != drawable; - if(DEBUG && res) { - System.err.println("SWT GLCanvas realized! "+this+", "+drawable); - Thread.dumpStack(); - } - return res; + return res; + } + + private final void createDrawableAndContext() { + final AbstractGraphicsDevice device = screen.getDevice(); + device.open(); + + final long nativeWindowHandle; + if( useX11GTK ) { + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(device, capsRequested); + final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( + capsRequested, capsRequested, capsChooser, screen, VisualIDHolder.VID_UNDEFINED); + if(DEBUG) { + System.err.println("SWT.GLCanvas.X11 factory: "+factory+", chosen config: "+cfg); + } + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + final int visualID = cfg.getVisualID(VIDType.NATIVE); + if( VisualIDHolder.VID_UNDEFINED != visualID ) { + // gdkWindow = SWTAccessor.createCompatibleGDKChildWindow(this, visualID, clientArea.width, clientArea.height); + // nativeWindowHandle = SWTAccessor.gdk_window_get_xwindow(gdkWindow); + x11Window = SWTAccessor.createCompatibleX11ChildWindow(screen, this, visualID, clientArea.width, clientArea.height); + nativeWindowHandle = x11Window; + } else { + throw new GLException("Could not choose valid visualID: 0x"+Integer.toHexString(visualID)+", "+this); + } + } else { + nativeWindowHandle = SWTAccessor.getWindowHandle(this); + } + final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(capsRequested.getGLProfile()); + + // Create a NativeWindow proxy for the SWT canvas + ProxySurface proxySurface = glFactory.createProxySurface(device, screen.getIndex(), nativeWindowHandle, + capsRequested, capsChooser, swtCanvasUpStreamHook); + // Associate a GL surface with the proxy + drawable = (GLDrawableImpl) glFactory.createGLDrawable(proxySurface); + context = (GLContextImpl) drawable.createContext(shareWith); + context.setContextCreationFlags(additionalCtxCreationFlags); + } + + @Override + public void update() { + // don't paint background etc .. nop avoids flickering + // super.update(); + } + + /** + @Override + public boolean forceFocus() { + final boolean r = super.forceFocus(); + if(r && 0 != gdkWindow) { + SWTGTKUtil.focusGDKWindow(gdkWindow); + } + return r; + } */ + + @Override + public void dispose() { + runInGLThread(disposeOnEDTGLAction); + super.dispose(); + } + + private final void displayIfNoAnimatorNoCheck() { + if ( !helper.isAnimatorAnimatingOnOtherThread() ) { + final boolean drawableOK = null != drawable && drawable.isRealized(); + if( drawableOK || validateDrawableAndContextPostCheck() ) { + runInGLThread(makeCurrentAndDisplayOnGLAction); + } + } } + // + // GL[Auto]Drawable + // + + @Override + public void display() { + final boolean drawableOK = null != drawable && drawable.isRealized(); + if( drawableOK || validateDrawableAndContextWithCheck() ) { + runInGLThread(makeCurrentAndDisplayOnGLAction); + } + } + @Override public final Object getUpstreamWidget() { return this; @@ -692,18 +798,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public void swapBuffers() throws GLException { - runInGLThread(swapBuffersOnEDTAction); - } - - @Override - public void update() { - // don't paint background etc .. nop avoids flickering - } - - @Override - public void dispose() { - runInGLThread(disposeOnEDTGLAction); - super.dispose(); + runInGLThread(swapBuffersOnGLAction); } /** @@ -746,7 +841,32 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } */ action.run(); } + + private void runOnEDTIfAvail(boolean wait, final Runnable action) { + final Display d = isDisposed() ? null : getDisplay(); + if( null == d || d.isDisposed() || d.getThread() == Thread.currentThread() ) { + action.run(); + } else if(wait) { + d.syncExec(action); + } else { + d.asyncExec(action); + } + } + + @Override + public String toString() { + final GLDrawable _drawable = drawable; + final int dw = (null!=_drawable) ? _drawable.getWidth() : -1; + final int dh = (null!=_drawable) ? _drawable.getHeight() : -1; + return "SWT-GLCanvas[Realized "+isRealized()+ + ",\n\t"+((null!=_drawable)?_drawable.getClass().getName():"null-drawable")+ + ",\n\tFactory "+getFactory()+ + ",\n\thandle 0x"+Long.toHexString(getHandle())+ + ",\n\tDrawable size "+dw+"x"+dh+ + ",\n\tSWT size "+getWidth()+"x"+getHeight()+"]"; + } + public static void main(final String[] args) { System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index e208cfb28..eba26c7d3 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -34,6 +34,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import org.eclipse.swt.graphics.GCData; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Control; import javax.media.nativewindow.AbstractGraphicsScreen; @@ -59,12 +60,22 @@ public class SWTAccessor { private static final Field swt_control_handle; private static final boolean swt_uses_long_handles; + private static Object swt_osx_init = new Object(); + private static Field swt_osx_control_view = null; + private static Field swt_osx_view_id = null; + + private static final String nwt; + private static final boolean isOSX; + private static final boolean isWindows; + private static final boolean isX11; + private static final boolean isX11GTK; + // X11/GTK, Windows/GDI, .. private static final String str_handle = "handle"; // OSX/Cocoa - private static final String str_view = "view"; // OSX - private static final String str_id = "id"; // OSX + private static final String str_osx_view = "view"; // OSX + private static final String str_osx_id = "id"; // OSX // static final String str_NSView = "org.eclipse.swt.internal.cocoa.NSView"; private static final Method swt_control_internal_new_GC; @@ -73,9 +84,10 @@ public class SWTAccessor { private static final String str_internal_dispose_GC = "internal_dispose_GC"; private static final String str_OS_gtk_class = "org.eclipse.swt.internal.gtk.OS"; - private static final Class OS_gtk_class; + public static final Class OS_gtk_class; private static final String str_OS_gtk_version = "GTK_VERSION"; - private static final VersionNumber OS_gtk_version; + public static final VersionNumber OS_gtk_version; + private static final Method OS_gtk_widget_realize; private static final Method OS_gtk_widget_unrealize; // optional (removed in SWT 4.3) private static final Method OS_GTK_WIDGET_WINDOW; @@ -85,6 +97,8 @@ public class SWTAccessor { private static final Method OS_gdk_window_get_display; private static final Method OS_gdk_x11_drawable_get_xid; private static final Method OS_gdk_x11_window_get_xid; + private static final Method OS_gdk_window_set_back_pixmap; + private static final String str_gtk_widget_realize = "gtk_widget_realize"; private static final String str_gtk_widget_unrealize = "gtk_widget_unrealize"; private static final String str_GTK_WIDGET_WINDOW = "GTK_WIDGET_WINDOW"; @@ -94,6 +108,7 @@ public class SWTAccessor { private static final String str_gdk_window_get_display = "gdk_window_get_display"; private static final String str_gdk_x11_drawable_get_xid = "gdk_x11_drawable_get_xid"; private static final String str_gdk_x11_window_get_xid = "gdk_x11_window_get_xid"; + private static final String str_gdk_window_set_back_pixmap = "gdk_window_set_back_pixmap"; private static final VersionNumber GTK_VERSION_2_14_0 = new VersionNumber(2, 14, 0); private static final VersionNumber GTK_VERSION_2_24_0 = new VersionNumber(2, 24, 0); @@ -108,23 +123,25 @@ public class SWTAccessor { } static { - Field f = null; - AccessController.doPrivileged(new PrivilegedAction() { public Object run() { NativeWindowFactory.initSingleton(); // last resort .. return null; } } ); - final String nwt = NativeWindowFactory.getNativeWindowType(false); - - if(NativeWindowFactory.TYPE_MACOSX != nwt ) { + nwt = NativeWindowFactory.getNativeWindowType(false); + isOSX = NativeWindowFactory.TYPE_MACOSX == nwt; + isWindows = NativeWindowFactory.TYPE_WINDOWS == nwt; + isX11 = NativeWindowFactory.TYPE_X11 == nwt; + + Field f = null; + if( !isOSX ) { try { f = Control.class.getField(str_handle); } catch (Exception ex) { throw new NativeWindowException(ex); } - } + } swt_control_handle = f; // maybe null ! boolean ulh; @@ -158,31 +175,32 @@ public class SWTAccessor { Class c=null; VersionNumber _gtk_version = new VersionNumber(0, 0, 0); - Method m1=null, m2=null, m3=null, m4=null, m5=null, m6=null, m7=null, m8=null, m9=null; - Class handleType = swt_uses_long_handles ? long.class : int.class ; - if( NativeWindowFactory.TYPE_X11 == nwt ) { + Method m1=null, m2=null, m3=null, m4=null, m5=null, m6=null, m7=null, m8=null, m9=null, ma=null; + final Class handleType = swt_uses_long_handles ? long.class : int.class ; + if( isX11 ) { // mandatory try { c = ReflectionUtil.getClass(str_OS_gtk_class, false, SWTAccessor.class.getClassLoader()); Field field_OS_gtk_version = c.getField(str_OS_gtk_version); _gtk_version = GTK_VERSION(field_OS_gtk_version.getInt(null)); m1 = c.getDeclaredMethod(str_gtk_widget_realize, handleType); - if( _gtk_version.compareTo(GTK_VERSION_2_14_0) < 0 ) { - m3 = c.getDeclaredMethod(str_GTK_WIDGET_WINDOW, handleType); - } else { + if (_gtk_version.compareTo(GTK_VERSION_2_14_0) >= 0) { m4 = c.getDeclaredMethod(str_gtk_widget_get_window, handleType); - } - if( _gtk_version.compareTo(GTK_VERSION_2_24_0) < 0 ) { - m5 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xdisplay, handleType); } else { + m3 = c.getDeclaredMethod(str_GTK_WIDGET_WINDOW, handleType); + } + if (_gtk_version.compareTo(GTK_VERSION_2_24_0) >= 0) { m6 = c.getDeclaredMethod(str_gdk_x11_display_get_xdisplay, handleType); - m7 = c.getDeclaredMethod(str_gdk_window_get_display, handleType); - } - if( _gtk_version.compareTo(GTK_VERSION_3_0_0) < 0 ) { - m8 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xid, handleType); + m7 = c.getDeclaredMethod(str_gdk_window_get_display, handleType); } else { + m5 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xdisplay, handleType); + } + if (_gtk_version.compareTo(GTK_VERSION_3_0_0) >= 0) { m9 = c.getDeclaredMethod(str_gdk_x11_window_get_xid, handleType); + } else { + m8 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xid, handleType); } + ma = c.getDeclaredMethod(str_gdk_window_set_back_pixmap, handleType, handleType, boolean.class); } catch (Exception ex) { throw new NativeWindowException(ex); } // optional try { @@ -200,25 +218,31 @@ public class SWTAccessor { OS_gdk_window_get_display = m7; OS_gdk_x11_drawable_get_xid = m8; OS_gdk_x11_window_get_xid = m9; + OS_gdk_window_set_back_pixmap = ma; + + isX11GTK = isX11 && null != OS_gtk_class; if(DEBUG) { System.err.println("SWTAccessor.: GTK Version: "+OS_gtk_version); } } - - - static Object getIntOrLong(long arg) { + + private static Number getIntOrLong(long arg) { if(swt_uses_long_handles) { return new Long(arg); } return new Integer((int) arg); } - static void callStaticMethodL2V(Method m, long arg) { + private static void callStaticMethodL2V(Method m, long arg) { ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg) }); } - static long callStaticMethodL2L(Method m, long arg) { + private static void callStaticMethodLLZ2V(Method m, long arg0, long arg1, boolean arg3) { + ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg0), getIntOrLong(arg1), Boolean.valueOf(arg3) }); + } + + private static long callStaticMethodL2L(Method m, long arg) { Object o = ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg) }); if(o instanceof Number) { return ((Number)o).longValue(); @@ -226,13 +250,73 @@ public class SWTAccessor { throw new InternalError("SWT method "+m.getName()+" didn't return int or long but "+o.getClass()); } } - + + // + // Public properties + // + public static boolean isUsingLongHandles() { return swt_uses_long_handles; } + public static boolean useX11GTK() { return isX11GTK; } public static VersionNumber GTK_VERSION() { return OS_gtk_version; } + // + // Common GTK + // + + public static long gdk_widget_get_window(long handle) { + final long window; + if (OS_gtk_version.compareTo(GTK_VERSION_2_14_0) >= 0) { + window = callStaticMethodL2L(OS_gtk_widget_get_window, handle); + } else { + window = callStaticMethodL2L(OS_GTK_WIDGET_WINDOW, handle); + } + if(0 == window) { + throw new NativeWindowException("Null gtk-window-handle of SWT handle 0x"+Long.toHexString(handle)); + } + return window; + } + + public static long gdk_window_get_xdisplay(long window) { + final long xdisplay; + if (OS_gtk_version.compareTo(GTK_VERSION_2_24_0) >= 0) { + final long display = callStaticMethodL2L(OS_gdk_window_get_display, window); + if(0 == display) { + throw new NativeWindowException("Null display-handle of gtk-window-handle 0x"+Long.toHexString(window)); + } + xdisplay = callStaticMethodL2L(OS_gdk_x11_display_get_xdisplay, display); + } else { + xdisplay = callStaticMethodL2L(OS_gdk_x11_drawable_get_xdisplay, window); + } + if(0 == xdisplay) { + throw new NativeWindowException("Null x11-display-handle of gtk-window-handle 0x"+Long.toHexString(window)); + } + return xdisplay; + } + + public static long gdk_window_get_xwindow(long window) { + final long xWindow; + if (OS_gtk_version.compareTo(GTK_VERSION_3_0_0) >= 0) { + xWindow = callStaticMethodL2L(OS_gdk_x11_window_get_xid, window); + } else { + xWindow = callStaticMethodL2L(OS_gdk_x11_drawable_get_xid, window); + } + if(0 == xWindow) { + throw new NativeWindowException("Null x11-window-handle of gtk-window-handle 0x"+Long.toHexString(window)); + } + return xWindow; + } + + public static void gdk_window_set_back_pixmap(long window, long pixmap, boolean parent_relative) { + callStaticMethodLLZ2V(OS_gdk_window_set_back_pixmap, window, pixmap, parent_relative); + } + + // + // Common any toolkit + // + /** * @param swtControl the SWT Control to retrieve the native widget-handle from * @return the native widget-handle @@ -240,15 +324,21 @@ public class SWTAccessor { */ public static long getHandle(Control swtControl) throws NativeWindowException { long h = 0; - if(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) { - try { - Field fView = Control.class.getField(str_view); - Object view = fView.get(swtControl); - Field fId = view.getClass().getField(str_id); - h = fId.getLong(view); - } catch (Exception ex) { - throw new NativeWindowException(ex); - } + if( isOSX ) { + synchronized(swt_osx_init) { + try { + if(null == swt_osx_view_id) { + swt_osx_control_view = Control.class.getField(str_osx_view); + Object view = swt_osx_control_view.get(swtControl); + swt_osx_view_id = view.getClass().getField(str_osx_id); + h = swt_osx_view_id.getLong(view); + } else { + h = swt_osx_view_id.getLong( swt_osx_control_view.get(swtControl) ); + } + } catch (Exception ex) { + throw new NativeWindowException(ex); + } + } } else { try { h = swt_control_handle.getLong(swtControl); @@ -283,49 +373,6 @@ public class SWTAccessor { } } - private static long gdk_x11_display_get_xdisplay(long window) { - final long xdisplay; - if ( OS_gtk_version.compareTo(GTK_VERSION_2_24_0) >= 0 ) { - final long display = callStaticMethodL2L(OS_gdk_window_get_display, window); - if(0 == display) { - throw new NativeWindowException("Null display-handle of gtk-window-handle 0x"+Long.toHexString(window)); - } - xdisplay = callStaticMethodL2L(OS_gdk_x11_display_get_xdisplay, display); - } else { - xdisplay = callStaticMethodL2L(OS_gdk_x11_drawable_get_xdisplay, window); - } - if(0 == xdisplay) { - throw new NativeWindowException("Null x11-display-handle of gtk-window-handle 0x"+Long.toHexString(window)); - } - return xdisplay; - } - - private static long gdk_widget_get_window(long handle) { - final long window; - if ( OS_gtk_version.compareTo(GTK_VERSION_2_14_0) >= 0 ) { - window = callStaticMethodL2L(OS_gtk_widget_get_window, handle); - } else { - window = callStaticMethodL2L(OS_GTK_WIDGET_WINDOW, handle); - } - if(0 == window) { - throw new NativeWindowException("Null gtk-window-handle of SWT handle 0x"+Long.toHexString(handle)); - } - return window; - } - - private static long gdk_window_get_xwindow(long window) { - final long xwindow; - if ( OS_gtk_version.compareTo(GTK_VERSION_3_0_0) >= 0 ) { - xwindow = callStaticMethodL2L(OS_gdk_x11_window_get_xid, window); - } else { - xwindow = callStaticMethodL2L(OS_gdk_x11_drawable_get_xid, window); - } - if(0 == xwindow) { - throw new NativeWindowException("Null x11-window-handle of gtk-window-handle 0x"+Long.toHexString(window)); - } - return xwindow; - } - /** * @param swtControl the SWT Control to retrieve the native device handle from * @return the AbstractGraphicsDevice w/ the native device handle @@ -333,43 +380,49 @@ public class SWTAccessor { * @throws UnsupportedOperationException if the windowing system is not supported */ public static AbstractGraphicsDevice getDevice(Control swtControl) throws NativeWindowException, UnsupportedOperationException { - long handle = getHandle(swtControl); - if( null != OS_gtk_class ) { - final long xdisplay0 = gdk_x11_display_get_xdisplay( gdk_widget_get_window( handle ) ); - // final String displayName = X11Lib.XDisplayString(xdisplay0); - // final long xdisplay1 = X11Util.openDisplay(displayName); - // return new X11GraphicsDevice(xdisplay1, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); + final long handle = getHandle(swtControl); + if( isX11GTK ) { + final long xdisplay0 = gdk_window_get_xdisplay( gdk_widget_get_window( handle ) ); return new X11GraphicsDevice(xdisplay0, AbstractGraphicsDevice.DEFAULT_UNIT, false /* owner */); } - final String nwt = NativeWindowFactory.getNativeWindowType(false); - if( NativeWindowFactory.TYPE_WINDOWS == nwt ) { + if( isWindows ) { return new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } - if( NativeWindowFactory.TYPE_MACOSX == nwt ) { + if( isOSX ) { return new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } + /** + * + * @param device + * @param screen -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen + * @return + * @throws UnsupportedOperationException + */ public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) throws UnsupportedOperationException { - if( null != OS_gtk_class ) { - return new X11GraphicsScreen((X11GraphicsDevice)device, screen); + if( isX11 ) { + X11GraphicsDevice x11Device = (X11GraphicsDevice)device; + if(0 > screen) { + screen = x11Device.getDefaultScreen(); + } + return new X11GraphicsScreen(x11Device, screen); + } + if(0 > screen) { + screen = 0; // FIXME: Needs native API utilization } - final String nwt = NativeWindowFactory.getNativeWindowType(false); - if( NativeWindowFactory.TYPE_WINDOWS == nwt || - NativeWindowFactory.TYPE_MACOSX == nwt ) { + if( isWindows || isOSX ) { return new DefaultGraphicsScreen(device, screen); } throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } public static int getNativeVisualID(AbstractGraphicsDevice device, long windowHandle) { - if( null != OS_gtk_class ) { + if( isX11 ) { return X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle); } - final String nwt = NativeWindowFactory.getNativeWindowType(false); - if( NativeWindowFactory.TYPE_WINDOWS == nwt || - NativeWindowFactory.TYPE_MACOSX == nwt ) { + if( isWindows || isOSX ) { return VisualIDHolder.VID_UNDEFINED; } throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); @@ -383,12 +436,13 @@ public class SWTAccessor { */ public static long getWindowHandle(Control swtControl) throws NativeWindowException, UnsupportedOperationException { final long handle = getHandle(swtControl); - if( null != OS_gtk_class ) { + if(0 == handle) { + throw new NativeWindowException("Null SWT handle of SWT control "+swtControl); + } + if( isX11GTK ) { return gdk_window_get_xwindow( gdk_widget_get_window( handle ) ); } - final String nwt = NativeWindowFactory.getNativeWindowType(false); - if( NativeWindowFactory.TYPE_WINDOWS == nwt || - NativeWindowFactory.TYPE_MACOSX == nwt ) { + if( isWindows || isOSX ) { return handle; } throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); @@ -407,7 +461,7 @@ public class SWTAccessor { throw new InternalError("SWT internal_new_GC did not return int or long but "+o[0].getClass()); } } - + public static void disposeGC(final Control swtControl, final long gc, final GCData gcData) { invoke(true, new Runnable() { public void run() { @@ -437,7 +491,7 @@ public class SWTAccessor { * @see Platform#getOSType() */ public static void invoke(boolean wait, Runnable runnable) { - if( Platform.OS_TYPE == Platform.OSType.MACOS ) { + if( isOSX ) { // Use SWT main thread! Only reliable config w/ -XStartOnMainThread !? OSXUtil.RunOnMainThread(wait, runnable); } else { @@ -445,4 +499,85 @@ public class SWTAccessor { } } + // + // Specific X11 GTK ChildWindow - Using plain X11 native parenting (works well) + // + + public static long createCompatibleX11ChildWindow(AbstractGraphicsScreen screen, Control swtControl, int visualID, int width, int height) { + final long handle = getHandle(swtControl); + final long parentWindow = gdk_widget_get_window( handle ); + gdk_window_set_back_pixmap (parentWindow, 0, false); + + final long x11ParentHandle = gdk_window_get_xwindow(parentWindow); + final long x11WindowHandle = X11Lib.CreateWindow(x11ParentHandle, screen.getDevice().getHandle(), screen.getIndex(), visualID, width, height, true, true); + + return x11WindowHandle; + } + + public static void resizeX11Window(AbstractGraphicsDevice device, Rectangle clientArea, long x11Window) { + X11Lib.SetWindowPosSize(device.getHandle(), x11Window, clientArea.x, clientArea.y, clientArea.width, clientArea.height); + } + public static void destroyX11Window(AbstractGraphicsDevice device, long x11Window) { + X11Lib.DestroyWindow(device.getHandle(), x11Window); + } + + // + // Specific X11 SWT/GTK ChildWindow - Using SWT/GTK native parenting (buggy - sporadic resize flickering, sporadic drop of rendering) + // + // FIXME: Need to use reflection for 32bit access as well ! + // + + // public static final int GDK_WA_TYPE_HINT = 1 << 9; + // public static final int GDK_WA_VISUAL = 1 << 6; + + public static long createCompatibleGDKChildWindow(Control swtControl, int visualID, int width, int height) { + return 0; + /** + final long handle = SWTAccessor.getHandle(swtControl); + final long parentWindow = gdk_widget_get_window( handle ); + + final long screen = OS.gdk_screen_get_default (); + final long gdkvisual = OS.gdk_x11_screen_lookup_visual (screen, visualID); + + final GdkWindowAttr attrs = new GdkWindowAttr(); + attrs.width = width > 0 ? width : 1; + attrs.height = height > 0 ? height : 1; + attrs.event_mask = OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK | + OS.GDK_FOCUS_CHANGE_MASK | OS.GDK_POINTER_MOTION_MASK | + OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK | + OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK | + OS.GDK_EXPOSURE_MASK | OS.GDK_VISIBILITY_NOTIFY_MASK | + OS.GDK_POINTER_MOTION_HINT_MASK; + attrs.window_type = OS.GDK_WINDOW_CHILD; + attrs.visual = gdkvisual; + + final long childWindow = OS.gdk_window_new (parentWindow, attrs, OS.GDK_WA_VISUAL|GDK_WA_TYPE_HINT); + OS.gdk_window_set_user_data (childWindow, handle); + OS.gdk_window_set_back_pixmap (parentWindow, 0, false); + + OS.gdk_window_show (childWindow); + OS.gdk_flush(); + return childWindow; */ + } + + public static void showGDKWindow(long gdkWindow) { + /* OS.gdk_window_show (gdkWindow); + OS.gdk_flush(); */ + } + public static void focusGDKWindow(long gdkWindow) { + /* + OS.gdk_window_show (gdkWindow); + OS.gdk_window_focus(gdkWindow, 0); + OS.gdk_flush(); */ + } + public static void resizeGDKWindow(Rectangle clientArea, long gdkWindow) { + /** + OS.gdk_window_move (gdkWindow, clientArea.x, clientArea.y); + OS.gdk_window_resize (gdkWindow, clientArea.width, clientArea.height); + OS.gdk_flush(); */ + } + + public static void destroyGDKWindow(long gdkWindow) { + // OS.gdk_window_destroy (gdkWindow); + } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java index 67a33e55c..827862002 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java @@ -37,7 +37,7 @@ public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); } if( 0 == s.getSurfaceHandle() ) { - final long windowHandle = X11Lib.CreateDummyWindow(device.getHandle(), screen.getIndex(), cfg.getXVisualID(), 64, 64); + final long windowHandle = X11Lib.CreateWindow(0, device.getHandle(), screen.getIndex(), cfg.getXVisualID(), 64, 64, false, false); if(0 == windowHandle) { throw new NativeWindowException("Creating dummy window failed w/ "+cfg); } @@ -59,7 +59,7 @@ public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize } device.lock(); try { - X11Lib.DestroyDummyWindow(device.getHandle(), s.getSurfaceHandle()); + X11Lib.DestroyWindow(device.getHandle(), s.getSurfaceHandle()); s.setSurfaceHandle(0); s.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } finally { diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index c73952693..a8d45f288 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -31,6 +31,8 @@ #include "jogamp_nativewindow_x11_X11Lib.h" #include "jogamp_nativewindow_x11_X11Util.h" +#include + // #define VERBOSE_ON 1 #ifdef VERBOSE_ON @@ -85,6 +87,8 @@ Bool XF86VidModeSetGammaRamp( #define RTLD_DEFAULT NULL #endif +#define X11_MOUSE_EVENT_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask) + static const char * const ClazzNameBuffers = "com/jogamp/common/nio/Buffers"; static const char * const ClazzNameBuffersStaticCstrName = "copyByteBuffer"; static const char * const ClazzNameBuffersStaticCstrSignature = "(Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;"; @@ -436,17 +440,62 @@ Java_jogamp_nativewindow_x11_X11Lib_XCloseDisplay__J(JNIEnv *env, jclass _unused return _res; } +static void NativewindowX11_setNormalWindowEWMH (Display *dpy, Window w) { + Atom _NET_WM_WINDOW_TYPE = XInternAtom( dpy, "_NET_WM_WINDOW_TYPE", False ); + Atom types[1]={0}; + types[0] = XInternAtom( dpy, "_NET_WM_WINDOW_TYPE_NORMAL", False ); + XChangeProperty( dpy, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *)&types, 1); + XSync(dpy, False); +} + +#define DECOR_USE_MWM 1 // works for known WMs +// #define DECOR_USE_EWMH 1 // haven't seen this to work (NORMAL->POPUP, never gets undecorated) + +/* see */ +#define MWM_HINTS_DECORATIONS (1L << 1) +#define PROP_MWM_HINTS_ELEMENTS 5 + +static void NativewindowX11_setDecorations (Display *dpy, Window w, Bool decorated) { + +#ifdef DECOR_USE_MWM + unsigned long mwmhints[PROP_MWM_HINTS_ELEMENTS] = { MWM_HINTS_DECORATIONS, 0, decorated, 0, 0 }; // flags, functions, decorations, input_mode, status + Atom _MOTIF_WM_HINTS = XInternAtom( dpy, "_MOTIF_WM_HINTS", False ); +#endif + +#ifdef DECOR_USE_EWMH + Atom _NET_WM_WINDOW_TYPE = XInternAtom( dpy, "_NET_WM_WINDOW_TYPE", False ); + Atom types[3]={0}; + int ntypes=0; + if(True==decorated) { + types[ntypes++] = XInternAtom( dpy, "_NET_WM_WINDOW_TYPE_NORMAL", False ); + } else { + types[ntypes++] = XInternAtom( dpy, "_NET_WM_WINDOW_TYPE_POPUP_MENU", False ); + } +#endif + +#ifdef DECOR_USE_MWM + XChangeProperty( dpy, w, _MOTIF_WM_HINTS, _MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); +#endif + +#ifdef DECOR_USE_EWMH + XChangeProperty( dpy, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *)&types, ntypes); +#endif + + XSync(dpy, False); +} + /* * Class: jogamp_nativewindow_x11_X11Lib - * Method: CreateDummyWindow - * Signature: (JIIII)J + * Method: CreateWindow + * Signature: (JJIIIIZZ)J */ -JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow - (JNIEnv *env, jclass unused, jlong display, jint screen_index, jint visualID, jint width, jint height) +JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateWindow + (JNIEnv *env, jclass unused, jlong parent, jlong display, jint screen_index, jint visualID, jint width, jint height, jboolean input, jboolean visible) { Display * dpy = (Display *)(intptr_t)display; int scrn_idx = (int)screen_index; - Window windowParent = 0; + Window root = RootWindow(dpy, scrn_idx); + Window windowParent = (Window) parent; Window window = 0; XVisualInfo visualTemplate; @@ -473,6 +522,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 1, 0, 0); scrn = ScreenOfDisplay(dpy, scrn_idx); + if(0==windowParent) { + windowParent = root; + } // try given VisualID on screen memset(&visualTemplate, 0, sizeof(XVisualInfo)); @@ -500,9 +552,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow pVisualQuery=NULL; } - if(0==windowParent) { - windowParent = XRootWindowOfScreen(scrn); - } attrMask = ( CWBackingStore | CWBackingPlanes | CWBackingPixel | CWBackPixmap | CWBorderPixel | CWColormap | CWOverrideRedirect ) ; @@ -514,15 +563,22 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow xswa.backing_store=NotUseful; /* NotUseful, WhenMapped, Always */ xswa.backing_planes=0; /* planes to be preserved if possible */ xswa.backing_pixel=0; /* value to use in restoring planes */ + if( input ) { + xswa.event_mask = X11_MOUSE_EVENT_MASK; + xswa.event_mask |= KeyPressMask | KeyReleaseMask ; + } + if( visible ) { + xswa.event_mask |= FocusChangeMask | SubstructureNotifyMask | StructureNotifyMask | ExposureMask ; + } xswa.colormap = XCreateColormap(dpy, - XRootWindow(dpy, scrn_idx), + windowParent, visual, AllocNone); window = XCreateWindow(dpy, windowParent, - 0, 0, + 0, 0, // only a hint, WM most likely will override width, height, 0, // border width depth, @@ -530,9 +586,25 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow visual, attrMask, &xswa); + if(0==window) { + NativewindowCommon_throwNewRuntimeException(env, "could not create Window, bail out!"); + return 0; + } + + NativewindowX11_setNormalWindowEWMH(dpy, window); + NativewindowX11_setDecorations(dpy, window, False); + + if( visible ) { + XEvent event; + + XMapWindow(dpy, window); + } + XSync(dpy, False); - XSelectInput(dpy, window, 0); // no events + if( !input ) { + XSelectInput(dpy, window, 0); // no events + } // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 0, 1); @@ -544,10 +616,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow /* * Class: jogamp_nativewindow_x11_X11Lib - * Method: DestroyDummyWindow + * Method: DestroyWindow * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_DestroyDummyWindow +JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_DestroyWindow (JNIEnv *env, jclass unused, jlong display, jlong window) { Display * dpy = (Display *)(intptr_t)display; @@ -559,12 +631,37 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_DestroyDummyWindow } NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 1, 0, 0); + XSelectInput(dpy, w, 0); XUnmapWindow(dpy, w); XSync(dpy, False); XDestroyWindow(dpy, w); // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 0, 1); } +JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_SetWindowPosSize + (JNIEnv *env, jclass unused, jlong display, jlong window, jint x, jint y, jint width, jint height) { + Display * dpy = (Display *)(intptr_t)display; + Window w = (Window) window; + XWindowChanges xwc; + int flags = 0; + + memset(&xwc, 0, sizeof(XWindowChanges)); + + if(0<=x && 0<=y) { + flags |= CWX | CWY; + xwc.x=x; + xwc.y=y; + } + + if(0 + * Implementation allows use of custom {@link GLCapabilities}. + *

    */ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("Window"); @@ -126,54 +126,44 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { clientArea = getClientArea(); final AbstractGraphicsDevice device = SWTAccessor.getDevice(this); - screen = SWTAccessor.getScreen(device, 0); + screen = SWTAccessor.getScreen(device, -1 /* default */); nativeWindow = null; if(null != child) { setNEWTChild(child); } - - /* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */ - /* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */ - addPaintListener(new PaintListener() { + + final Listener listener = new Listener () { @Override - public void paintControl(final PaintEvent arg0) { - if( null != nativeWindow || validateNative() ) { - if( newtChildReady ) { - if( postSetSize ) { - newtChild.setSize(clientArea.width, clientArea.height); - postSetSize = false; + public void handleEvent (Event event) { + switch (event.type) { + case SWT.Paint: + if( null != nativeWindow || validateNative() ) { + if( newtChildReady ) { + if( postSetSize ) { + newtChild.setSize(clientArea.width, clientArea.height); + postSetSize = false; + } + newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height); } - newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height); } + break; + case SWT.Resize: + updateSizeCheck(); + break; + case SWT.Dispose: + NewtCanvasSWT.this.dispose(); + break; } } - }); - - addControlListener(new ControlListener() { - @Override - public void controlMoved(ControlEvent e) { - } - @Override - public void controlResized(final ControlEvent arg0) { - updateSizeCheck(); - } - }); - - addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - NewtCanvasSWT.this.dispose(); - } - }); - + }; + addListener (SWT.Resize, listener); + addListener (SWT.Paint, listener); + addListener (SWT.Dispose, listener); } /** assumes nativeWindow == null ! */ protected final boolean validateNative() { - if( isDisposed() || !isVisible() ) { - return false; - } updateSizeCheck(); final Rectangle nClientArea = clientArea; if(0 >= nClientArea.width || 0 >= nClientArea.height) { @@ -216,6 +206,10 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) ) { clientArea = nClientArea; // write back new value + if(DEBUG) { + final long nsh = newtChildReady ? newtChild.getSurfaceHandle() : 0; + System.err.println("NewtCanvasSWT.sizeChanged: ("+Thread.currentThread().getName()+"): newtChildReady "+newtChildReady+", "+nClientArea.x+"/"+nClientArea.y+" "+nClientArea.width+"x"+nClientArea.height+" - surfaceHandle 0x"+Long.toHexString(nsh)); + } if( newtChildReady ) { newtChild.setSize(clientArea.width, clientArea.height); } else { @@ -223,7 +217,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } } } - + @Override public void update() { // don't paint background etc .. nop avoids flickering @@ -261,11 +255,11 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { public NativeWindow getNativeWindow() { return nativeWindow; } public WindowClosingMode getDefaultCloseOperation() { - return newtChildCloseOp; // FIXME + return newtChildCloseOp; // TODO: implement ?! } public WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { - return newtChildCloseOp = op; // FIXME + return newtChildCloseOp = op; // TODO: implement ?! } diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java deleted file mode 100644 index 1c20fe524..000000000 --- a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java +++ /dev/null @@ -1,313 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.newt.swt; - -import javax.media.nativewindow.NativeWindowException; - -import jogamp.newt.Debug; - -import com.jogamp.common.util.RunnableTask; -import com.jogamp.newt.util.EDTUtil; - -/** - * Simple {@link EDTUtil} implementation utilizing the SWT UI thread - * of the given {@link Display}. - */ -public class SWTEDTUtil implements EDTUtil { - public static final boolean DEBUG = Debug.debug("EDT"); - - private final Object edtLock = new Object(); // locking the EDT start/stop state - private final ThreadGroup threadGroup; - private final String name; - private final Runnable dispatchMessages; - private final org.eclipse.swt.widgets.Display swtDisplay; - private NewtEventDispatchThread nedt = null; - private int start_iter=0; - private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; - - public SWTEDTUtil(final com.jogamp.newt.Display newtDisplay, org.eclipse.swt.widgets.Display swtDisplay) { - this.threadGroup = Thread.currentThread().getThreadGroup(); - this.name=Thread.currentThread().getName()+"-SWTDisplay-"+newtDisplay.getFQName()+"-EDT-"; - this.dispatchMessages = new Runnable() { - public void run() { - ((jogamp.newt.DisplayImpl) newtDisplay).dispatchMessages(); - } }; - this.swtDisplay = swtDisplay; - this.nedt = new NewtEventDispatchThread(threadGroup, name); - this.nedt.setDaemon(true); // don't stop JVM from shutdown .. - } - - public final org.eclipse.swt.widgets.Display getDisplay() { - return swtDisplay; - } - - @Override - public long getPollPeriod() { - return pollPeriod; - } - - @Override - public void setPollPeriod(long ms) { - pollPeriod = ms; - } - - @Override - public void reset() { - synchronized(edtLock) { - waitUntilStopped(); - if(DEBUG) { - System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt); - } - this.nedt = new NewtEventDispatchThread(threadGroup, name); - this.nedt.setDaemon(true); // don't stop JVM from shutdown .. - } - } - - private final void startImpl() { - if(nedt.isAlive()) { - throw new RuntimeException("SWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); - } - start_iter++; - nedt.setName(name+start_iter); - nedt.shouldStop = false; - if(DEBUG) { - System.err.println(Thread.currentThread()+": SWT-EDT START - edt: "+nedt); - // Thread.dumpStack(); - } - nedt.start(); - } - - @Override - public boolean isCurrentThreadEDT() { - return swtDisplay.getThread() == Thread.currentThread(); - } - - @Override - public final boolean isCurrentThreadNEDT() { - return nedt == Thread.currentThread(); - } - - @Override - public final boolean isCurrentThreadEDTorNEDT() { - final Thread ct = Thread.currentThread(); - return ct == swtDisplay.getThread() || ct == nedt ; - } - - @Override - public boolean isRunning() { - return nedt.isRunning() ; // SWT is always running - } - - @Override - public final void invokeStop(Runnable task) { - invokeImpl(true, task, true); - } - - @Override - public final void invoke(boolean wait, Runnable task) { - invokeImpl(wait, task, false); - } - - private void invokeImpl(boolean wait, Runnable task, boolean stop) { - Throwable throwable = null; - RunnableTask rTask = null; - Object rTaskLock = new Object(); - synchronized(rTaskLock) { // lock the optional task execution - synchronized(edtLock) { // lock the EDT status - if( nedt.shouldStop ) { - // drop task .. - if(DEBUG) { - System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt); - Thread.dumpStack(); - } - return; - } - // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); - // Thread.dumpStack(); - if(stop) { - synchronized(nedt.sync) { - nedt.shouldStop = true; - nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) - } - if(DEBUG) { - System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); - // Thread.dumpStack(); - } - } else if( !nedt.isRunning() ) { - // start if should not stop && not started yet - startImpl(); - } - if( null == task ) { - wait = false; - } else if( isCurrentThreadEDT() ) { - task.run(); - wait = false; // running in same thread (EDT) -> no wait - } else if( swtDisplay.isDisposed() ) { - wait = false; // drop task, SWT disposed - } else { - rTask = new RunnableTask(task, - wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */); - swtDisplay.asyncExec(rTask); - } - } - if( wait ) { - try { - rTaskLock.wait(); // free lock, allow execution of rTask - } catch (InterruptedException ie) { - throwable = ie; - } - if(null==throwable) { - throwable = rTask.getThrowable(); - } - if(null!=throwable) { - if(throwable instanceof NativeWindowException) { - throw (NativeWindowException)throwable; - } - throw new RuntimeException(throwable); - } - } - } - } - - @Override - final public void waitUntilIdle() { - final NewtEventDispatchThread _nedt; - synchronized(edtLock) { - _nedt = nedt; - } - final Thread ct = Thread.currentThread(); - if(!_nedt.isRunning() || _nedt == ct || swtDisplay.getThread() == ct) { - return; - } - try { - swtDisplay.syncExec(new Runnable() { - public void run() { } - }); - } catch (Exception e) { } - } - - @Override - final public void waitUntilStopped() { - synchronized(edtLock) { - final Thread ct = Thread.currentThread(); - if(nedt.isRunning() && nedt != ct && swtDisplay.getThread() != ct) { - while(nedt.isRunning()) { - try { - edtLock.wait(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - } - } - - class NewtEventDispatchThread extends Thread { - volatile boolean shouldStop = false; - volatile boolean isRunning = false; - Object sync = new Object(); - - public NewtEventDispatchThread(ThreadGroup tg, String name) { - super(tg, name); - } - - final public boolean isRunning() { - return isRunning; - } - - @Override - final public void start() throws IllegalThreadStateException { - isRunning = true; - super.start(); - } - - /** - * Utilizing locking only on tasks and its execution, - * not for event dispatching. - */ - @Override - final public void run() { - if(DEBUG) { - System.err.println(getName()+": SWT-EDT run() START "+ getName()); - } - RuntimeException error = null; - try { - do { - // event dispatch - if(!shouldStop) { - // EDT invoke thread is SWT-EDT, - // hence dispatching is required to run on SWT-EDT as well. - // Otherwise a deadlock may happen due to dispatched event's - // triggering a locking action. - if ( !swtDisplay.isDisposed() ) { - swtDisplay.syncExec(dispatchMessages); - } else { - dispatchMessages.run(); - } - } - // wait - synchronized(sync) { - if(!shouldStop) { - try { - sync.wait(pollPeriod); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - } while(!shouldStop) ; - } catch (Throwable t) { - // handle errors .. - shouldStop = true; - if(t instanceof RuntimeException) { - error = (RuntimeException) t; - } else { - error = new RuntimeException("Within SWT-EDT", t); - } - } finally { - if(DEBUG) { - System.err.println(getName()+": SWT-EDT run() END "+ getName()+", "+error); - } - synchronized(edtLock) { - isRunning = !shouldStop; - if(!isRunning) { - edtLock.notifyAll(); - } - } - if(DEBUG) { - System.err.println(getName()+": SWT-EDT run() EXIT "+ getName()+", exception: "+error); - } - if(null!=error) { - throw error; - } - } // finally - } // run() - } // EventDispatchThread - -} diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java new file mode 100644 index 000000000..7297e5858 --- /dev/null +++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java @@ -0,0 +1,313 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.swt; + +import javax.media.nativewindow.NativeWindowException; + +import jogamp.newt.Debug; + +import com.jogamp.common.util.RunnableTask; +import com.jogamp.newt.util.EDTUtil; + +/** + * Simple {@link EDTUtil} implementation utilizing the SWT UI thread + * of the given {@link Display}. + */ +public class SWTEDTUtil implements EDTUtil { + public static final boolean DEBUG = Debug.debug("EDT"); + + private final Object edtLock = new Object(); // locking the EDT start/stop state + private final ThreadGroup threadGroup; + private final String name; + private final Runnable dispatchMessages; + private final org.eclipse.swt.widgets.Display swtDisplay; + private NewtEventDispatchThread nedt = null; + private int start_iter=0; + private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; + + public SWTEDTUtil(final com.jogamp.newt.Display newtDisplay, org.eclipse.swt.widgets.Display swtDisplay) { + this.threadGroup = Thread.currentThread().getThreadGroup(); + this.name=Thread.currentThread().getName()+"-SWTDisplay-"+newtDisplay.getFQName()+"-EDT-"; + this.dispatchMessages = new Runnable() { + public void run() { + ((jogamp.newt.DisplayImpl) newtDisplay).dispatchMessages(); + } }; + this.swtDisplay = swtDisplay; + this.nedt = new NewtEventDispatchThread(threadGroup, name); + this.nedt.setDaemon(true); // don't stop JVM from shutdown .. + } + + public final org.eclipse.swt.widgets.Display getDisplay() { + return swtDisplay; + } + + @Override + public long getPollPeriod() { + return pollPeriod; + } + + @Override + public void setPollPeriod(long ms) { + pollPeriod = ms; + } + + @Override + public void reset() { + synchronized(edtLock) { + waitUntilStopped(); + if(DEBUG) { + System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt); + } + this.nedt = new NewtEventDispatchThread(threadGroup, name); + this.nedt.setDaemon(true); // don't stop JVM from shutdown .. + } + } + + private final void startImpl() { + if(nedt.isAlive()) { + throw new RuntimeException("SWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); + } + start_iter++; + nedt.setName(name+start_iter); + nedt.shouldStop = false; + if(DEBUG) { + System.err.println(Thread.currentThread()+": SWT-EDT START - edt: "+nedt); + // Thread.dumpStack(); + } + nedt.start(); + } + + @Override + public boolean isCurrentThreadEDT() { + return swtDisplay.getThread() == Thread.currentThread(); + } + + @Override + public final boolean isCurrentThreadNEDT() { + return nedt == Thread.currentThread(); + } + + @Override + public final boolean isCurrentThreadEDTorNEDT() { + final Thread ct = Thread.currentThread(); + return ct == swtDisplay.getThread() || ct == nedt ; + } + + @Override + public boolean isRunning() { + return nedt.isRunning() ; // SWT is always running + } + + @Override + public final void invokeStop(Runnable task) { + invokeImpl(true, task, true); + } + + @Override + public final void invoke(boolean wait, Runnable task) { + invokeImpl(wait, task, false); + } + + private void invokeImpl(boolean wait, Runnable task, boolean stop) { + Throwable throwable = null; + RunnableTask rTask = null; + Object rTaskLock = new Object(); + synchronized(rTaskLock) { // lock the optional task execution + synchronized(edtLock) { // lock the EDT status + if( nedt.shouldStop ) { + // drop task .. + if(DEBUG) { + System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt); + Thread.dumpStack(); + } + return; + } + // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); + // Thread.dumpStack(); + if(stop) { + synchronized(nedt.sync) { + nedt.shouldStop = true; + nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) + } + if(DEBUG) { + System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); + // Thread.dumpStack(); + } + } else if( !nedt.isRunning() ) { + // start if should not stop && not started yet + startImpl(); + } + if( null == task ) { + wait = false; + } else if( isCurrentThreadEDT() ) { + task.run(); + wait = false; // running in same thread (EDT) -> no wait + } else if( swtDisplay.isDisposed() ) { + wait = false; // drop task, SWT disposed + } else { + rTask = new RunnableTask(task, + wait ? rTaskLock : null, + true /* always catch and report Exceptions, don't disturb EDT */); + swtDisplay.asyncExec(rTask); + } + } + if( wait ) { + try { + rTaskLock.wait(); // free lock, allow execution of rTask + } catch (InterruptedException ie) { + throwable = ie; + } + if(null==throwable) { + throwable = rTask.getThrowable(); + } + if(null!=throwable) { + if(throwable instanceof NativeWindowException) { + throw (NativeWindowException)throwable; + } + throw new RuntimeException(throwable); + } + } + } + } + + @Override + final public void waitUntilIdle() { + final NewtEventDispatchThread _nedt; + synchronized(edtLock) { + _nedt = nedt; + } + final Thread ct = Thread.currentThread(); + if(!_nedt.isRunning() || _nedt == ct || swtDisplay.getThread() == ct) { + return; + } + try { + swtDisplay.syncExec(new Runnable() { + public void run() { } + }); + } catch (Exception e) { } + } + + @Override + final public void waitUntilStopped() { + synchronized(edtLock) { + final Thread ct = Thread.currentThread(); + if(nedt.isRunning() && nedt != ct && swtDisplay.getThread() != ct) { + while(nedt.isRunning()) { + try { + edtLock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + } + + class NewtEventDispatchThread extends Thread { + volatile boolean shouldStop = false; + volatile boolean isRunning = false; + Object sync = new Object(); + + public NewtEventDispatchThread(ThreadGroup tg, String name) { + super(tg, name); + } + + final public boolean isRunning() { + return isRunning; + } + + @Override + final public void start() throws IllegalThreadStateException { + isRunning = true; + super.start(); + } + + /** + * Utilizing locking only on tasks and its execution, + * not for event dispatching. + */ + @Override + final public void run() { + if(DEBUG) { + System.err.println(getName()+": SWT-EDT run() START "+ getName()); + } + RuntimeException error = null; + try { + do { + // event dispatch + if(!shouldStop) { + // EDT invoke thread is SWT-EDT, + // hence dispatching is required to run on SWT-EDT as well. + // Otherwise a deadlock may happen due to dispatched event's + // triggering a locking action. + if ( !swtDisplay.isDisposed() ) { + swtDisplay.syncExec(dispatchMessages); + } else { + dispatchMessages.run(); + } + } + // wait + synchronized(sync) { + if(!shouldStop) { + try { + sync.wait(pollPeriod); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } while(!shouldStop) ; + } catch (Throwable t) { + // handle errors .. + shouldStop = true; + if(t instanceof RuntimeException) { + error = (RuntimeException) t; + } else { + error = new RuntimeException("Within SWT-EDT", t); + } + } finally { + if(DEBUG) { + System.err.println(getName()+": SWT-EDT run() END "+ getName()+", "+error); + } + synchronized(edtLock) { + isRunning = !shouldStop; + if(!isRunning) { + edtLock.notifyAll(); + } + } + if(DEBUG) { + System.err.println(getName()+": SWT-EDT run() EXIT "+ getName()+", exception: "+error); + } + if(null!=error) { + throw error; + } + } // finally + } // run() + } // EventDispatchThread + +} diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java new file mode 100644 index 000000000..e238f5d9e --- /dev/null +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -0,0 +1,249 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.swt.event; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; + +import com.jogamp.common.util.IntIntHashMap; +import com.jogamp.newt.event.InputEvent; + +/** + * SWT event translator to NEWT, inclusive dispatch listener. + *

    + * Disclaimer: This code is merely tested and subject to change. + *

    + */ +public class SWTNewtEventFactory { + + protected static final IntIntHashMap eventTypeSWT2NEWT; + + static { + IntIntHashMap map = new IntIntHashMap(); + map.setKeyNotFoundValue(0xFFFFFFFF); + + // map.put(SWT.MouseXXX, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED); + map.put(SWT.MouseDown, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); + map.put(SWT.MouseUp, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); + map.put(SWT.MouseMove, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED); + map.put(SWT.MouseEnter, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED); + map.put(SWT.MouseExit, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED); + // map.put(SWT.MouseXXX, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED); + map.put(SWT.MouseVerticalWheel, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED); + + map.put(SWT.KeyDown, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED); + map.put(SWT.KeyUp, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED); + // map.put(SWT.KeyXXX, com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED); + + eventTypeSWT2NEWT = map; + } + + public static final int swtModifiers2Newt(int awtMods, boolean mouseHint) { + int newtMods = 0; + if ((awtMods & SWT.SHIFT) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; + if ((awtMods & SWT.CTRL) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK; + if ((awtMods & SWT.ALT) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK; + return newtMods; + } + + public static final com.jogamp.newt.event.InputEvent createInputEvent(org.eclipse.swt.widgets.Event event, Object source) { + com.jogamp.newt.event.InputEvent res = createMouseEvent(event, source); + if(null == res) { + res = createKeyEvent(event, source); + } + return res; + } + + public static final com.jogamp.newt.event.MouseEvent createMouseEvent(org.eclipse.swt.widgets.Event event, Object source) { + switch(event.type) { + case SWT.MouseDown: + case SWT.MouseUp: + case SWT.MouseMove: + case SWT.MouseEnter: + case SWT.MouseExit: + case SWT.MouseVerticalWheel: + break; + default: + return null; + } + int type = eventTypeSWT2NEWT.get(event.type); + if(0xFFFFFFFF != type) { + int rotation = 0; + if (SWT.MouseVerticalWheel == event.type) { + // SWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up. + // rotation = -1 * (int) event.rotation; + rotation = (int) event.rotation; + } + + int mods = swtModifiers2Newt(event.stateMask, true); + + if( source instanceof com.jogamp.newt.Window) { + final com.jogamp.newt.Window newtSource = (com.jogamp.newt.Window)source; + if(newtSource.isPointerConfined()) { + mods |= InputEvent.CONFINED_MASK; + } + if(!newtSource.isPointerVisible()) { + mods |= InputEvent.INVISIBLE_MASK; + } + } + + return new com.jogamp.newt.event.MouseEvent( + type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), + mods, event.x, event.y, event.count, event.button, rotation); + } + return null; // no mapping .. + } + + public static final com.jogamp.newt.event.KeyEvent createKeyEvent(org.eclipse.swt.widgets.Event event, Object source) { + switch(event.type) { + case SWT.KeyDown: + case SWT.KeyUp: + break; + default: + return null; + } + int type = eventTypeSWT2NEWT.get(event.type); + if(0xFFFFFFFF != type) { + return new com.jogamp.newt.event.KeyEvent( + type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), + swtModifiers2Newt(event.stateMask, false), + event.keyCode, event.character); + } + return null; // no mapping .. + } + + // + // + // + + int dragButtonDown = 0; + + public SWTNewtEventFactory() { + resetButtonsDown(); + } + + final void resetButtonsDown() { + dragButtonDown = 0; + } + + public final boolean dispatchMouseEvent(org.eclipse.swt.widgets.Event event, Object source, com.jogamp.newt.event.MouseListener l) { + com.jogamp.newt.event.MouseEvent res = createMouseEvent(event, source); + if(null != res) { + if(null != l) { + switch(event.type) { + case SWT.MouseDown: + dragButtonDown = event.button; + l.mousePressed(res); break; + case SWT.MouseUp: + dragButtonDown = 0; + l.mouseReleased(res); + { + final com.jogamp.newt.event.MouseEvent res2 = new com.jogamp.newt.event.MouseEvent( + com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED, + res.getSource(), + res.getWhen(), res.getModifiers(), + res.getX(), res.getY(), res.getClickCount(), + res.getButton(), res.getWheelRotation() ); + l.mouseClicked(res2); + } + break; + case SWT.MouseMove: + if( 0 < dragButtonDown ) { + final com.jogamp.newt.event.MouseEvent res2 = new com.jogamp.newt.event.MouseEvent( + com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED, + res.getSource(), + res.getWhen(), res.getModifiers(), + res.getX(), res.getY(), res.getClickCount(), + dragButtonDown, res.getWheelRotation() ); + l.mouseDragged( res2 ); + } else { + l.mouseMoved(res); + } + break; + case SWT.MouseEnter: + l.mouseEntered(res); + break; + case SWT.MouseExit: + resetButtonsDown(); + l.mouseExited(res); + break; + case SWT.MouseVerticalWheel: + l.mouseWheelMoved(res); + break; + } + } + return true; + } + return false; + } + + public final boolean dispatchKeyEvent(org.eclipse.swt.widgets.Event event, Object source, com.jogamp.newt.event.KeyListener l) { + com.jogamp.newt.event.KeyEvent res = createKeyEvent(event, source); + if(null != res) { + if(null != l) { + switch(event.type) { + case SWT.KeyDown: + l.keyPressed(res); + break; + case SWT.KeyUp: + l.keyReleased(res); + l.keyTyped(res); + break; + } + } + return true; + } + return false; + } + + public final void attachDispatchListener(final org.eclipse.swt.widgets.Control ctrl, final Object source, + final com.jogamp.newt.event.MouseListener ml, + final com.jogamp.newt.event.KeyListener kl) { + final Listener listener = new Listener () { + @Override + public void handleEvent (Event event) { + if( dispatchMouseEvent( event, source, ml ) ) { + return; + } + if( dispatchKeyEvent( event, source, kl ) ) { + return; + } + } }; + ctrl.addListener(SWT.MouseDown, listener); + ctrl.addListener(SWT.MouseUp, listener); + ctrl.addListener(SWT.MouseMove, listener); + ctrl.addListener(SWT.MouseEnter, listener); + ctrl.addListener(SWT.MouseExit, listener); + ctrl.addListener(SWT.MouseVerticalWheel, listener); + ctrl.addListener(SWT.KeyDown, listener); + ctrl.addListener(SWT.KeyUp, listener); + } +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index e9fe9b401..a3023538f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -60,8 +60,8 @@ public class GearsES2 implements GLEventListener { private int swapInterval = 0; private boolean pmvUseBackingArray = true; // the default for PMVMatrix now, since it's faster // private MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter()); - private MouseListener gearsMouse = new GearsMouseAdapter(); - private KeyListener gearsKeys = new GearsKeyAdapter(); + public MouseListener gearsMouse = new GearsMouseAdapter(); + public KeyListener gearsKeys = new GearsKeyAdapter(); private int prevMouseX, prevMouseY; private boolean doRotate = true; @@ -352,6 +352,10 @@ public class GearsES2 implements GLEventListener { window = (Window) source; width=window.getWidth(); height=window.getHeight(); + } else if (source instanceof GLAutoDrawable) { + GLAutoDrawable glad = (GLAutoDrawable) source; + width = glad.getWidth(); + height = glad.getHeight(); } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) { java.awt.Component comp = (java.awt.Component) source; width=comp.getWidth(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java index a0874e609..1f3bf3156 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java @@ -366,8 +366,9 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { try { while( !shallStop && !dsc.display.isDisposed() ) { - if( !dsc.display.readAndDispatch() ) { - dsc.display.sleep(); + if( !dsc.display.readAndDispatch() && !shallStop ) { + // blocks on linux .. dsc.display.sleep(); + Thread.sleep(10); } } } catch (Exception e0) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java index 0a47b96eb..97b3ab243 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java @@ -45,12 +45,13 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities ; import javax.media.opengl.GLProfile; +import jogamp.newt.swt.SWTEDTUtil; +import jogamp.newt.swt.event.SWTNewtEventFactory; import junit.framework.Assert; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.newt.opengl.GLWindow ; import com.jogamp.newt.swt.NewtCanvasSWT ; -import com.jogamp.newt.swt.SWTEDTUtil; import com.jogamp.opengl.swt.GLCanvas; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; @@ -121,15 +122,15 @@ public class TestSWTBug643AsyncExec extends UITestCase { final Runnable swtAsyncAction = new Runnable() { public void run() { - ++swtN ; - System.err.println("[SWT A-i shallStop "+shallStop+"]: Counter[loc "+swtN+", glob: "+incrSWTCount()+"]"); + ++swtN ; incrSWTCount(); + System.err.println("[SWT A-i shallStop "+shallStop+"]: Counter[loc "+swtN+", glob: "+getSWTCount()+"]"); } }; final Runnable newtAsyncAction = new Runnable() { public void run() { - ++newtN ; - System.err.println("[NEWT A-i shallStop "+shallStop+"]: Counter[loc "+newtN+", glob: "+incrNEWTCount()+"]"); + ++newtN ; incrNEWTCount(); + System.err.println("[NEWT A-i shallStop "+shallStop+"]: Counter[loc "+newtN+", glob: "+getNEWTCount()+"]"); } }; public void run() @@ -219,9 +220,13 @@ public class TestSWTBug643AsyncExec extends UITestCase { final GLAutoDrawable glad; if( useJOGLGLCanvas ) { - glad = GLCanvas.create(dsc.composite, 0, caps, null, null); - glad.addGLEventListener( new GearsES2() ) ; - newtDisplay = null; + final GearsES2 demo = new GearsES2(); + final GLCanvas glc = GLCanvas.create(dsc.composite, 0, caps, null, null); + final SWTNewtEventFactory swtNewtEventFactory = new SWTNewtEventFactory(); + swtNewtEventFactory.attachDispatchListener(glc, glc, demo.gearsMouse, demo.gearsKeys); + glc.addGLEventListener( demo ) ; + glad = glc; + newtDisplay = null; } else if( useNewtCanvasSWT ) { final GLWindow glWindow = GLWindow.create( caps ) ; glWindow.addGLEventListener( new GearsES2() ) ; @@ -287,8 +292,9 @@ public class TestSWTBug643AsyncExec extends UITestCase { try { final Display d = dsc.display; while( !shallStop && !d.isDisposed() ) { - if( !d.readAndDispatch() ) { - dsc.display.sleep(); + if( !d.readAndDispatch() && !shallStop ) { + // blocks on linux .. dsc.display.sleep(); + Thread.sleep(10); } } } catch (Exception e0) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java index a5d2c8012..1822d2eaf 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java @@ -50,6 +50,7 @@ import org.junit.Test; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.opengl.swt.GLCanvas; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; @@ -58,10 +59,9 @@ import com.jogamp.opengl.util.texture.TextureIO; /** * Tests that a basic SWT app can open without crashing under different GL profiles. *

    - * Uses JOGL's new SWT GLCanvas. - *

    - *

    - * Note: To employ custom GLCapabilities, NewtCanvasSWT shall be used. + * Uses JOGL's new SWT GLCanvas, + * which allows utilizing custom GLCapability settings, + * independent from the already instantiated SWT visual. *

    *

    * Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/ @@ -188,6 +188,14 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase { runTestAGL( new GLCapabilities(GLProfile.getGL2ES2()), new GearsES2() ); } + @Test + public void test_MultisampleAndAlpha() throws InterruptedException { + GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); + caps.setSampleBuffers(true); + caps.setNumSamples(2); + runTestAGL( caps, new MultisampleDemoES2(true) ); + } + static int atoi(String a) { int i=0; try { -- cgit v1.2.3 From 13168c99ff9e8bf71c83f1be7afee270a3db4074 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 23 Dec 2012 15:36:09 +0100 Subject: Fix commit 811e3791b98fea0dfa3b7d301cb532c54df8dc82: Make AWT usage Java6 clean (was using Java7 stuff); Note: Need to test! --- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 90 +++++++++------------- .../junit/newt/event/TestNewtEventModifiers.java | 39 ++++++++-- 2 files changed, 66 insertions(+), 63 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index b8ab3176a..28174f139 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -34,7 +34,24 @@ import com.jogamp.newt.event.InputEvent; public class AWTNewtEventFactory { protected static final IntIntHashMap eventTypeAWT2NEWT; + + // Define the button state masks we'll check based on what + // the AWT says is available. + private static int awtButtonMasks[] ; + private static int newtButtonMasks[] ; + public static int getAWTButtonMask(int button) { + // return java.awt.event.InputEvent.getMaskForButton(button); // n/a + int m; + switch(button) { + case 1 : m = java.awt.event.InputEvent.BUTTON1_MASK; break; + case 2 : m = java.awt.event.InputEvent.BUTTON2_MASK; break; + case 3 : m = java.awt.event.InputEvent.BUTTON3_MASK; break; + default: m = 0; + } + return m; + } + static { IntIntHashMap map = new IntIntHashMap(); map.setKeyNotFoundValue(0xFFFFFFFF); @@ -70,27 +87,14 @@ public class AWTNewtEventFactory { map.put(java.awt.event.KeyEvent.KEY_TYPED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED); eventTypeAWT2NEWT = map; - } - - // Define the button state masks we'll check based on what - // the AWT says is available. - - private static int awtButtonMasks[] ; - private static int newtButtonMasks[] ; - - static { + + final int numButtonMasks ; - int numButtonMasks ; - - if (java.awt.Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()) { - numButtonMasks = java.awt.MouseInfo.getNumberOfButtons() ; - } else { - numButtonMasks = 3 ; - } - - if (numButtonMasks > com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER) { - numButtonMasks = com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ; - } + // numButtonMasks = java.awt.MouseInfo.getNumberOfButtons() ; + // if (numButtonMasks > com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER) { + // numButtonMasks = com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ; + // } + numButtonMasks = 3 ; // There is an assumption in awtModifiers2Newt(int,int,boolean) // that the awtButtonMasks and newtButtonMasks are peers, i.e. @@ -98,15 +102,16 @@ public class AWTNewtEventFactory { awtButtonMasks = new int[numButtonMasks] ; for (int n = 0 ; n < awtButtonMasks.length ; ++n) { - awtButtonMasks[n] = java.awt.event.InputEvent.getMaskForButton(n+1) ; + awtButtonMasks[n] = getAWTButtonMask(n+1); } newtButtonMasks = new int[numButtonMasks] ; for (int n = 0 ; n < newtButtonMasks.length ; ++n) { newtButtonMasks[n] = com.jogamp.newt.event.InputEvent.getButtonMask(n+1) ; - } + } } + /** * Converts the specified set of AWT event modifiers to the equivalent * NEWT event modifiers. This method doesn't pay attention to the AWT @@ -123,7 +128,6 @@ public class AWTNewtEventFactory { * @param mouseHint * Not used currently. */ - public static final int awtModifiers2Newt(int awtMods, boolean mouseHint) { int newtMods = 0; if ((awtMods & java.awt.event.InputEvent.SHIFT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; @@ -149,57 +153,33 @@ public class AWTNewtEventFactory { * * @param awtModsEx * The AWT extended event modifiers. + * AWT passes mouse button specific bits here and are the preferred way check the mouse button state. * * @param mouseHint * Not used currently. */ - public static final int awtModifiers2Newt(final int awtMods, final int awtModsEx, final boolean mouseHint) { int newtMods = 0; - - //System.err.println( ">>>> AWT modifiers:") ; - //_printAwtModifiers( awtMods, awtModsEx ) ; - //System.err.println( ">>>> END AWT modifiers") ; - - // Bug 629: - // - // AWT defines the notion of "extended modifiers". They put other bits there - // specific to the mouse buttons and say that these are the preferred bits to - // check for mouse button state. This seems to hint that at some point they - // may be the only way to get this info. - if ((awtModsEx & java.awt.event.InputEvent.SHIFT_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; if ((awtModsEx & java.awt.event.InputEvent.CTRL_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK; if ((awtModsEx & java.awt.event.InputEvent.META_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; if ((awtModsEx & java.awt.event.InputEvent.ALT_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK; if ((awtModsEx & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK; + if ((awtModsEx & awtButtonMasks[0]) != 0) newtMods |= newtButtonMasks[0] ; + if ((awtModsEx & awtButtonMasks[1]) != 0) newtMods |= newtButtonMasks[1] ; + if ((awtModsEx & awtButtonMasks[2]) != 0) newtMods |= newtButtonMasks[2] ; + + /** for (int n = 0 ; n < awtButtonMasks.length ; ++n) { if ((awtModsEx & awtButtonMasks[n]) != 0) { newtMods |= newtButtonMasks[n] ; } - } + } */ return newtMods; } -/* - private static void _printAwtModifiers( int awtMods, int awtModsEx ) { - if( ( awtMods & java.awt.event.InputEvent.SHIFT_MASK ) != 0 ) { System.err.println( "SHIFT" ) ; } - if( ( awtMods & java.awt.event.InputEvent.CTRL_MASK ) != 0 ) { System.err.println( "CTRL" ) ; } - if( ( awtMods & java.awt.event.InputEvent.META_MASK ) != 0 ) { System.err.println( "META" ) ; } - if( ( awtMods & java.awt.event.InputEvent.ALT_MASK ) != 0 ) { System.err.println( "ALT" ) ; } - if( ( awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK ) != 0 ) { System.err.println( "ALT_GRAPH" ) ; } - - if( ( awtModsEx & java.awt.event.InputEvent.SHIFT_DOWN_MASK ) != 0 ) { System.err.println( "SHIFT Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.CTRL_DOWN_MASK ) != 0 ) { System.err.println( "CTRL Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.META_DOWN_MASK ) != 0 ) { System.err.println( "META Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.ALT_DOWN_MASK ) != 0 ) { System.err.println( "ALT Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) != 0 ) { System.err.println( "ALT_GRAPH Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON1" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.BUTTON2_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON2" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.BUTTON3_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON3" ) ; } - } -*/ + public static final int awtButton2Newt(int awtButton) { switch (awtButton) { case java.awt.event.MouseEvent.BUTTON1: return com.jogamp.newt.event.MouseEvent.BUTTON1; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java index 36185f8ce..81e1939b9 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java @@ -216,6 +216,23 @@ public abstract class TestNewtEventModifiers extends UITestCase { if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON9_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON9" ) ; } } + private static void _printAwtModifiers( int awtMods, int awtModsEx ) { + if( ( awtMods & java.awt.event.InputEvent.SHIFT_MASK ) != 0 ) { System.err.println( "SHIFT" ) ; } + if( ( awtMods & java.awt.event.InputEvent.CTRL_MASK ) != 0 ) { System.err.println( "CTRL" ) ; } + if( ( awtMods & java.awt.event.InputEvent.META_MASK ) != 0 ) { System.err.println( "META" ) ; } + if( ( awtMods & java.awt.event.InputEvent.ALT_MASK ) != 0 ) { System.err.println( "ALT" ) ; } + if( ( awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK ) != 0 ) { System.err.println( "ALT_GRAPH" ) ; } + + if( ( awtModsEx & java.awt.event.InputEvent.SHIFT_DOWN_MASK ) != 0 ) { System.err.println( "SHIFT Ex" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.CTRL_DOWN_MASK ) != 0 ) { System.err.println( "CTRL Ex" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.META_DOWN_MASK ) != 0 ) { System.err.println( "META Ex" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.ALT_DOWN_MASK ) != 0 ) { System.err.println( "ALT Ex" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) != 0 ) { System.err.println( "ALT_GRAPH Ex" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON1" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.BUTTON2_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON2" ) ; } + if( ( awtModsEx & java.awt.event.InputEvent.BUTTON3_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON3" ) ; } + } + public ArrayList getFailures() { return _failures ; } @@ -282,18 +299,24 @@ public abstract class TestNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// + public static int getAWTButtonMask(int button) { + int m; + switch(button) { + case 1 : m = java.awt.event.InputEvent.BUTTON1_MASK; break; + case 2 : m = java.awt.event.InputEvent.BUTTON2_MASK; break; + case 3 : m = java.awt.event.InputEvent.BUTTON3_MASK; break; + default: throw new IllegalArgumentException("Only buttons 1-3 have a MASK value, requested button "+button); + } + return m; + } + @BeforeClass public static void beforeClass() throws Exception { // Who know how many buttons the AWT will say exist on given platform. // We'll test the smaller of what NEWT supports and what the // AWT says is available. - - if( java.awt.Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled() ) { - _numButtonsToTest = java.awt.MouseInfo.getNumberOfButtons() ; - } else { - _numButtonsToTest = 3 ; - } + // _numButtonsToTest = java.awt.MouseInfo.getNumberOfButtons() ; // Then again, maybe not: @@ -320,7 +343,7 @@ public abstract class TestNewtEventModifiers extends UITestCase { _awtButtonMasks = new int[_numButtonsToTest] ; for( int n = 0 ; n < _awtButtonMasks.length ; ++n ) { - _awtButtonMasks[n] = java.awt.event.InputEvent.getMaskForButton( n + 1 ) ; + _awtButtonMasks[n] = getAWTButtonMask( n + 1 ); } _newtButtonMasks = new int[_numButtonsToTest] ; @@ -726,7 +749,7 @@ public abstract class TestNewtEventModifiers extends UITestCase { } for (int n = 0 ; n < _numButtonsToTest ; ++n) { - if ((awtExtendedModifiers & java.awt.event.InputEvent.getMaskForButton(n+1)) != 0) { + if ((awtExtendedModifiers & getAWTButtonMask(n+1)) != 0) { mask |= com.jogamp.newt.event.InputEvent.getButtonMask(n+1) ; } } -- cgit v1.2.3 From 7ec58d773535e86e413e3c581a5e5bd734cb1269 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 23 Dec 2012 23:33:19 +0100 Subject: Fix 13168c99ff9e8bf71c83f1be7afee270a3db4074 / 811e3791b98fea0dfa3b7d301cb532c54df8dc82: AWT-NEWT Modifier mapping - part-2 AWTNewtEventFactory: - getAWTButtonMask() -> getAWTButtonDownMask() - using proper _DOWN_MASK values (regression of commit 13168c99ff9e8bf71c83f1be7afee270a3db4074) - com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER buttons - adding 'ModifierMappings.txt' to API doc header - remove obsolete 'int awtModifiers2Newt(int awtMods, boolean mouseHint)' - 'int awtButton2Newt(int awtButton)' 1:1 button name mapping Tests: - rename TestNewtEventModifiers -> BaseNewtEventModifiers to avoid being picked up by our junit testing framework. The latter tests all classes starting w/ 'Test*' --- .../classes/com/jogamp/newt/event/InputEvent.java | 2 +- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 205 +++--- .../junit/newt/event/BaseNewtEventModifiers.java | 740 ++++++++++++++++++++ .../test/junit/newt/event/ModifierMappings.txt | 37 - .../junit/newt/event/TestNewtEventModifiers.java | 761 --------------------- .../event/TestNewtEventModifiersAWTCanvas.java | 6 +- .../event/TestNewtEventModifiersNewtCanvasAWT.java | 6 +- .../event/TestNewtEventModifiersNewtCanvasSWT.java | 6 +- 8 files changed, 877 insertions(+), 886 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index 0122bda9a..ad77ec79f 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -70,7 +70,7 @@ public abstract class InputEvent extends NEWTEvent * Returns the corresponding button mask for the given button. *

    * In case the given button lies outside - * of the valid range [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON6}], + * of the valid range [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON_NUMBER}], * null is returned. *

    */ diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index 28174f139..665b7b5ee 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -29,29 +29,58 @@ package jogamp.newt.awt.event; import com.jogamp.common.util.IntIntHashMap; -import com.jogamp.newt.event.InputEvent; +/** + * + *
    AWT Event Modifier Mapping
    + *
    +    Modifier       AWT Constant                     AWT Bit  AWT Ex  NEWT Constant              NEWT Bit
    +    -------------  -------------------------------  -------  ------  -------------------------  --------
    +    Shift          Event.SHIFT_MASK                 0                
    +    Ctrl           Event.CTRL_MASK                  1                
    +    Meta           Event.META_MASK                  2                
    +    Alt            Event.ALT_MASK                   3               
    +    Button1        InputEvent.BUTTON1_MASK          4
    +    Button2        InputEvent.BUTTON2_MASK          3
    +    Button3        InputEvent.BUTTON3_MASK          2
    +    Shift Down     InputEvent.SHIFT_DOWN_MASK       6        *       InputEvent.SHIFT_MASK      0
    +    Ctrl Down      InputEvent.CTRL_DOWN_MASK        7        *       InputEvent.CTRL_MASK       1
    +    Meta Down      InputEvent.META_DOWN_MASK        8        *       InputEvent.META_MASK       2
    +    Alt Down       InputEvent.ALT_DOWN_MASK         9        *       InputEvent.ALT_MASK        3
    +    Button1 Down   InputEvent.BUTTON1_DOWN_MASK     10       *       InputEvent.BUTTON1_MASK    5
    +    Button2 Down   InputEvent.BUTTON2_DOWN_MASK     11       *       InputEvent.BUTTON2_MASK    6
    +    Button3 Down   InputEvent.BUTTON3_DOWN_MASK     12       *       InputEvent.BUTTON3_MASK    7
    +    AltGraph Down  InputEvent.ALT_GRAPH_DOWN_MASK   13       *       InputEvent.ALT_GRAPH_MASK  4
    +    Button4 Down   --                               14       *       InputEvent.BUTTON4_MASK    8
    +    Button5 Down   --                               15       *       InputEvent.BUTTON5_MASK    9
    +    Button6 Down   --                               16       *       InputEvent.BUTTON6_MASK    10
    +    Button7 Down   --                               17       *       InputEvent.BUTTON7_MASK    11
    +    Button8 Down   --                               18       *       InputEvent.BUTTON8_MASK    12
    +    Button9 Down   --                               19       *       InputEvent.BUTTON9_MASK    13
    +    Button10 Down  --                               20       *                                  14
    +    Button11 Down  --                               21       *                                  15
    +    Button12 Down  --                               22       *                                  16
    +    Button13 Down  --                               23       *                                  17
    +    Button14 Down  --                               24       *                                  18
    +    Button15 Down  --                               25       *                                  19
    +    Button16 Down  --                               26       *       InputEvent.BUTTONLAST_MASK 20
    +    Button17 Down  --                               27       *
    +    Button18 Down  --                               28       *
    +    Button19 Down  --                               29       *
    +    Button20 Down  --                               30       *
    +    Autorepeat     --                               -                InputEvent.AUTOREPEAT_MASK 29
    +    Confined       --                               -                InputEvent.CONFINED_MASK   30
    +    Invisible      --                               -                InputEvent.INVISIBLE_MASK  31
    + * 
    + * + */ public class AWTNewtEventFactory { protected static final IntIntHashMap eventTypeAWT2NEWT; - // Define the button state masks we'll check based on what - // the AWT says is available. - private static int awtButtonMasks[] ; - private static int newtButtonMasks[] ; - - public static int getAWTButtonMask(int button) { - // return java.awt.event.InputEvent.getMaskForButton(button); // n/a - int m; - switch(button) { - case 1 : m = java.awt.event.InputEvent.BUTTON1_MASK; break; - case 2 : m = java.awt.event.InputEvent.BUTTON2_MASK; break; - case 3 : m = java.awt.event.InputEvent.BUTTON3_MASK; break; - default: m = 0; - } - return m; - } - + /** zero-based AWT button mask array filled by {@link #getAWTButtonDownMask(int)}, allowing fast lookup. */ + private static int awtButtonDownMasks[] ; + static { IntIntHashMap map = new IntIntHashMap(); map.setKeyNotFoundValue(0xFFFFFFFF); @@ -88,66 +117,77 @@ public class AWTNewtEventFactory { eventTypeAWT2NEWT = map; - final int numButtonMasks ; - - // numButtonMasks = java.awt.MouseInfo.getNumberOfButtons() ; - // if (numButtonMasks > com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER) { - // numButtonMasks = com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ; - // } - numButtonMasks = 3 ; - // There is an assumption in awtModifiers2Newt(int,int,boolean) // that the awtButtonMasks and newtButtonMasks are peers, i.e. // a given index refers to the same button in each array. - awtButtonMasks = new int[numButtonMasks] ; - for (int n = 0 ; n < awtButtonMasks.length ; ++n) { - awtButtonMasks[n] = getAWTButtonMask(n+1); + /* { + Method _getMaskForButtonMethod = null; + try { + _getMaskForButtonMethod = ReflectionUtil.getMethod(java.awt.event.InputEvent.class, "getMaskForButton", int.class); + } catch(Throwable t) {} + getMaskForButtonMethod = _getMaskForButtonMethod; + } */ + + awtButtonDownMasks = new int[com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER] ; // java.awt.MouseInfo.getNumberOfButtons() ; + for (int n = 0 ; n < awtButtonDownMasks.length ; ++n) { + awtButtonDownMasks[n] = getAWTButtonDownMaskImpl(n+1); } - - newtButtonMasks = new int[numButtonMasks] ; - for (int n = 0 ; n < newtButtonMasks.length ; ++n) { - newtButtonMasks[n] = com.jogamp.newt.event.InputEvent.getButtonMask(n+1) ; - } } - + private static int getAWTButtonDownMaskImpl(int button) { + /** + * java.awt.event.InputEvent.getMaskForButton(button); + * + if(null != getMaskForButtonMethod) { + Object r=null; + try { + r = getMaskForButtonMethod.invoke(null, new Integer(button)); + } catch (Throwable t) { } + if(null != r) { + return ((Integer)r).intValue(); + } + } */ + final int m; + switch(button) { + case 0 : m = 0; break; + case 1 : m = java.awt.event.InputEvent.BUTTON1_DOWN_MASK; break; // 1<<10 + case 2 : m = java.awt.event.InputEvent.BUTTON2_DOWN_MASK; break; // 1<<11 + case 3 : m = java.awt.event.InputEvent.BUTTON3_DOWN_MASK; break; // 1<<12 + default: + if( button <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + m = 1 << ( 10 + button ) ; // b4 = 1<<14, b5 = 1<<15, etc + } else { + m = 0; + } + } + return m; + } + /** - * Converts the specified set of AWT event modifiers to the equivalent - * NEWT event modifiers. This method doesn't pay attention to the AWT - * button modifier bits explicitly even though there is a direct - * association in the AWT InputEvent class between BUTTON2_MASK and - * ALT_MASK, and BUTTON3_MASK and META_MASK. Instead the current - * button state is picked up from the bits in the extended modifiers. - * If you need the button bits too, then call - * {@link #awtModifiers2Newt(int,int,boolean)} instead. + *

    + * See AWT event modifier mapping details. + *

    * - * @param awtMods - * The AWT event modifiers. - * - * @param mouseHint - * Not used currently. + * @param button + * @return */ - public static final int awtModifiers2Newt(int awtMods, boolean mouseHint) { - int newtMods = 0; - if ((awtMods & java.awt.event.InputEvent.SHIFT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; - if ((awtMods & java.awt.event.InputEvent.CTRL_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK; - if ((awtMods & java.awt.event.InputEvent.META_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; - if ((awtMods & java.awt.event.InputEvent.ALT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK; - if ((awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK; - - // The BUTTON1_MASK, BUTTON2_MASK, and BUTTON3_MASK bits are - // being ignored intentionally. The AWT docs say that the - // BUTTON1_DOWN_MASK etc bits in the extended modifiers are - // the preferred place to check current button state. - - return newtMods; + public static int getAWTButtonDownMask(int button) { + if( 0 < button && button <= awtButtonDownMasks.length ) { + return awtButtonDownMasks[button-1]; + } else { + return 0; + } } /** * Converts the specified set of AWT event modifiers and extended event * modifiers to the equivalent NEWT event modifiers. * + *

    + * See AWT event modifier mapping details. + *

    + * * @param awtMods * The AWT event modifiers. * @@ -160,33 +200,42 @@ public class AWTNewtEventFactory { */ public static final int awtModifiers2Newt(final int awtMods, final int awtModsEx, final boolean mouseHint) { int newtMods = 0; + + /** Redundant old modifiers .. + if ((awtMods & java.awt.event.InputEvent.SHIFT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; + if ((awtMods & java.awt.event.InputEvent.CTRL_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK; + if ((awtMods & java.awt.event.InputEvent.META_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; + if ((awtMods & java.awt.event.InputEvent.ALT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK; + if ((awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK; */ + if ((awtModsEx & java.awt.event.InputEvent.SHIFT_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; if ((awtModsEx & java.awt.event.InputEvent.CTRL_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK; if ((awtModsEx & java.awt.event.InputEvent.META_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; if ((awtModsEx & java.awt.event.InputEvent.ALT_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK; if ((awtModsEx & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK; - if ((awtModsEx & awtButtonMasks[0]) != 0) newtMods |= newtButtonMasks[0] ; - if ((awtModsEx & awtButtonMasks[1]) != 0) newtMods |= newtButtonMasks[1] ; - if ((awtModsEx & awtButtonMasks[2]) != 0) newtMods |= newtButtonMasks[2] ; - - /** - for (int n = 0 ; n < awtButtonMasks.length ; ++n) { - if ((awtModsEx & awtButtonMasks[n]) != 0) { - newtMods |= newtButtonMasks[n] ; + // The BUTTON1_MASK, BUTTON2_MASK, and BUTTON3_MASK bits are + // being ignored intentionally. The AWT docs say that the + // BUTTON1_DOWN_MASK etc bits in the extended modifiers are + // the preferred place to check current button state. + + if( 0 != awtModsEx ) { + for (int n = 0 ; n < awtButtonDownMasks.length ; ++n) { + if ( (awtModsEx & awtButtonDownMasks[n]) != 0 ) { + newtMods |= com.jogamp.newt.event.InputEvent.getButtonMask(n+1); + } } - } */ + } return newtMods; } public static final int awtButton2Newt(int awtButton) { - switch (awtButton) { - case java.awt.event.MouseEvent.BUTTON1: return com.jogamp.newt.event.MouseEvent.BUTTON1; - case java.awt.event.MouseEvent.BUTTON2: return com.jogamp.newt.event.MouseEvent.BUTTON2; - case java.awt.event.MouseEvent.BUTTON3: return com.jogamp.newt.event.MouseEvent.BUTTON3; + if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + return awtButton; + } else { + return 0; } - return 0; } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) { @@ -225,10 +274,10 @@ public class AWTNewtEventFactory { int mods = awtModifiers2Newt(event.getModifiers(), event.getModifiersEx(), true); if(null!=newtSource) { if(newtSource.isPointerConfined()) { - mods |= InputEvent.CONFINED_MASK; + mods |= com.jogamp.newt.event.InputEvent.CONFINED_MASK; } if(!newtSource.isPointerVisible()) { - mods |= InputEvent.INVISIBLE_MASK; + mods |= com.jogamp.newt.event.InputEvent.INVISIBLE_MASK; } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java new file mode 100644 index 000000000..1dfdc4021 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -0,0 +1,740 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.event ; + +import java.io.PrintStream ; +import java.util.ArrayList ; + +import javax.media.opengl.GL ; +import javax.media.opengl.GL2 ; +import javax.media.opengl.GLAutoDrawable ; +import javax.media.opengl.GLEventListener ; +import javax.media.opengl.GLProfile ; + +import org.junit.After ; +import org.junit.AfterClass ; +import org.junit.Assert ; +import org.junit.Before ; +import org.junit.BeforeClass ; +import org.junit.Test ; + +import com.jogamp.common.os.Platform; +import com.jogamp.newt.event.MouseEvent; +import com.jogamp.opengl.test.junit.util.UITestCase ; + +/** + * Test whether or not event modifiers are preserved by NEWT. This + * class defines most of the tests, but leaves the type of window + * and canvas up to subclasses. + */ + +public abstract class BaseNewtEventModifiers extends UITestCase { + + static + { + GLProfile.initSingleton() ; + } + + // A class to draw something on a canvas. This is only + // here so we can make sure the GL drawing area has + // filled the window. + + public static class BigGreenXGLEventListener implements GLEventListener + { + public void init( GLAutoDrawable drawable ) + { + GL2 gl = drawable.getGL().getGL2() ; + + gl.glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ) ; + + gl.glEnable( GL.GL_LINE_SMOOTH ) ; + gl.glEnable( GL.GL_BLEND ) ; + gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA ) ; + } + + public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ) + { + GL2 gl = drawable.getGL().getGL2() ; + + gl.glViewport( 0, 0, width, height ) ; + + gl.glMatrixMode( GL2.GL_PROJECTION ) ; + gl.glLoadIdentity() ; + gl.glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ) ; + + gl.glMatrixMode( GL2.GL_MODELVIEW ) ; + gl.glLoadIdentity() ; + } + + public void display( GLAutoDrawable drawable ) + { + GL2 gl = drawable.getGL().getGL2() ; + + gl.glClear( GL2.GL_COLOR_BUFFER_BIT ) ; + + gl.glColor4f( 0.0f, 1.0f, 0.0f, 1.0f ) ; + + gl.glBegin( GL.GL_LINES ) ; + { + gl.glVertex2f( -1.0f, 1.0f ) ; + gl.glVertex2f( 1.0f, -1.0f ) ; + + gl.glVertex2f( -1.0f, -1.0f ) ; + gl.glVertex2f( 1.0f, 1.0f ) ; + } + gl.glEnd() ; + } + + public void dispose( GLAutoDrawable drawable ) + { + } + } + + //////////////////////////////////////////////////////////////////////////// + + private static class TestMouseListener implements com.jogamp.newt.event.MouseListener + { + private static final String NO_EVENT_DELIVERY = "no event delivery" ; + + private boolean _modifierCheckEnabled ; + private int _expectedModifiers ; + private ArrayList _failures = new ArrayList() ; + + public void setModifierCheckEnabled( boolean value ) { + _modifierCheckEnabled = value ; + } + + public boolean modifierCheckEnabled() { + return _modifierCheckEnabled ; + } + + /** + * Sets the modifiers the listener should expect, and clears + * out any existing accumulated failures. Normally this kind + * of double duty in a setter might be considered evil, but + * in this test code it's probably ok. + */ + + public void setExpectedModifiers( int value ) { + _expectedModifiers = value ; + + // Assume we will have a failure due to no event delivery. + // If an event is delivered and it's good this assumed + // failure will get cleared out. + + _failures.clear() ; + _failures.add( NO_EVENT_DELIVERY ) ; + } + + private void _checkModifiers( com.jogamp.newt.event.MouseEvent event ) { + + if( _debug ) { + _debugPrintStream.print( " received NEWT " ) ; + _debugPrintStream.print( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ) ; + } + + if( _modifierCheckEnabled ) { + + if( _debug ) { + _debugPrintStream.println( ", checking modifiers..." ) ; + _debugPrintStream.println( " expected NEWT Modifiers:" ) ; + { + final MouseEvent exp = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, null, 0, _expectedModifiers, 0, 0, 1, 1, 0); + _debugPrintStream.println(" "+exp.getModifiersString(null).toString()); + } + _debugPrintStream.println( " current NEWT Modifiers:" ) ; + _debugPrintStream.println(" "+event.getModifiersString(null).toString()); + } + + _checkModifierMask( event, com.jogamp.newt.event.InputEvent.SHIFT_MASK ) ; + _checkModifierMask( event, com.jogamp.newt.event.InputEvent.CTRL_MASK ) ; + _checkModifierMask( event, com.jogamp.newt.event.InputEvent.META_MASK ) ; + _checkModifierMask( event, com.jogamp.newt.event.InputEvent.ALT_MASK ) ; + _checkModifierMask( event, com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK ) ; + + for( int n = 0 ; n < _numButtonsToTest ; ++n ) { + _checkModifierMask( event, com.jogamp.newt.event.InputEvent.getButtonMask( n + 1 ) ) ; + } + } else { + if( _debug ) { + _debugPrintStream.println( ", modifier check disabled" ) ; + } + } + } + + private void _checkModifierMask( com.jogamp.newt.event.MouseEvent event, int mask ) { + + // If the "no event delivery" failure is still in the list then + // get rid of it since that obviously isn't true anymore. We + // want to do this whether or not there's an issue with the + // modifiers. + + if( _failures.size() == 1 && _failures.get(0).equals( NO_EVENT_DELIVERY ) ) { + _failures.clear() ; + } + + if( ( event.getModifiers() & mask ) != ( _expectedModifiers & mask ) ) { + StringBuilder sb = new StringBuilder(); + sb.append( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ).append(": "); + final MouseEvent exp = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, null, 0, _expectedModifiers, 0, 0, 1, 1, 0); + sb.append("Expected:").append(Platform.NEWLINE); + exp.getModifiersString(sb).append(Platform.NEWLINE); + sb.append(", Have: ").append(Platform.NEWLINE); + event.getModifiersString(sb).append(Platform.NEWLINE); + _failures.add( sb.toString() ) ; + } + } + + public ArrayList getFailures() { + return _failures ; + } + + public void mouseClicked( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mousePressed( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mouseReleased( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mouseEntered( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mouseExited( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mouseDragged( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mouseMoved( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + + public void mouseWheelMoved( com.jogamp.newt.event.MouseEvent event ) { + _checkModifiers( event ) ; + } + } + + //////////////////////////////////////////////////////////////////////////// + + protected static final int TEST_FRAME_X = 100 ; + protected static final int TEST_FRAME_Y = 100 ; + + protected static final int TEST_FRAME_WIDTH = 400 ; + protected static final int TEST_FRAME_HEIGHT = 400 ; + + private static final int INITIAL_MOUSE_X = TEST_FRAME_X + ( TEST_FRAME_WIDTH / 2 ) ; + private static final int INITIAL_MOUSE_Y = TEST_FRAME_Y + ( TEST_FRAME_HEIGHT / 2 ) ; + + private static final int MS_ROBOT_SHORT_AUTO_DELAY = 50 ; + private static final int MS_ROBOT_LONG_AUTO_DELAY = 500 ; + + private static boolean _debug = true ; + private static PrintStream _debugPrintStream = System.err ; + + //////////////////////////////////////////////////////////////////////////// + + private static int _numButtonsToTest ; + private static int _awtButtonMasks[] ; + + private static java.awt.Robot _robot ; + + protected static TestMouseListener _testMouseListener ; + + //////////////////////////////////////////////////////////////////////////// + + public static int getAWTButtonMask(int button) { + // Java7: java.awt.event.InputEvent.getMaskForButton( n + 1 ) ; -> using InputEvent.BUTTON1_DOWN_MASK .. etc + // Java6: Only use BUTTON1_MASK, .. + int m; + switch(button) { + case 1 : m = java.awt.event.InputEvent.BUTTON1_MASK; break; + case 2 : m = java.awt.event.InputEvent.BUTTON2_MASK; break; + case 3 : m = java.awt.event.InputEvent.BUTTON3_MASK; break; + default: throw new IllegalArgumentException("Only buttons 1-3 have a MASK value, requested button "+button); + } + return m; + } + + @BeforeClass + public static void beforeClass() throws Exception { + + // Who know how many buttons the AWT will say exist on given platform. + // We'll test the smaller of what NEWT supports and what the + // AWT says is available. + /** Java7: + if( java.awt.Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled() ) { + _numButtonsToTest = java.awt.MouseInfo.getNumberOfButtons() ; + } else { + _numButtonsToTest = 3 ; + } */ + _numButtonsToTest = 3 ; + + // Then again, maybe not: + + // FIXME? - for reasons I'm not quite sure of the AWT MouseEvent + // constructor does some strange things for buttons other than + // 1, 2, and 3. Furthermore, while developing this test it + // appeared that events sent by the robot for buttons 9 and + // up weren't even delivered to the listeners. + // + // So... for now we're only going to test 3 buttons since + // that's the common case _and_ Java6 safe. + + _numButtonsToTest = 3 ; + + { + if( _numButtonsToTest > com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + _numButtonsToTest = com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ; + } + + // These two arrays are assumed to be peers, i.e. are the same + // size, and a given index references the same button in + // either array. + + _awtButtonMasks = new int[_numButtonsToTest] ; + + for( int n = 0 ; n < _awtButtonMasks.length ; ++n ) { + _awtButtonMasks[n] = getAWTButtonMask( n + 1 ); + } + } + + _robot = new java.awt.Robot() ; + _robot.setAutoWaitForIdle( true ) ; + _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; + + _testMouseListener = new TestMouseListener() ; + } + + //////////////////////////////////////////////////////////////////////////// + + @Before + public void before() throws Exception { + + _testMouseListener.setModifierCheckEnabled( false ) ; + _robot.setAutoDelay( MS_ROBOT_SHORT_AUTO_DELAY ) ; + + // Make sure all the buttons and modifier keys are released. + + _releaseModifiers() ; + _escape() ; + + // Move the pointer into the window and click once to + // ensure that the test window has focus. + + if( _debug ) { + _debugPrintStream.println( ">>>> Clicking in the window to get focus." ) ; + } + + _robot.mouseMove( INITIAL_MOUSE_X, INITIAL_MOUSE_Y ) ; + _robot.mousePress( java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) ; + _robot.mouseRelease( java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) ; + + _testMouseListener.setModifierCheckEnabled( true ) ; + _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; + + if( _debug ) { + _debugPrintStream.println( ">>>> About to start testing." ) ; + } + } + + //////////////////////////////////////////////////////////////////////////// + + // The approach on all these tests is to tell the test mouse listener what + // modifiers we think it should receive. Then when the events are delivered + // it compares what we told it to expect with what actually showed up and + // complains if there are differences. + // + // As things stand currently the tests below generally work for AWTCanvas + // and fail for everything else. This may point to a flaw in the test + // code, or a flaw in the NEWT stuff; not sure yet. One exception is the + // tests involving ALT and META, which on at least X11 cause the desktop + // to do undesirable stuff while the tests are in progress. So... these + // tests have been commented out for now and probably should be left + // that way. + // + // Due to the fact that a majority of these fail currently for + // everything but AWTCanvas for the time being we probably shouldn't + // run the tests for NewtCanvasAWT and NewtCanvasSWT until we can + // pay more attention to the NEWT event modifier stuff. + + @Test + public void testSingleButtonPressAndRelease() throws Exception { + _doSingleButtonPressAndRelease( 0, 0 ) ; + } + + @Test + public void testSingleButtonPressAndReleaseWithShift() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_SHIFT, java.awt.event.InputEvent.SHIFT_DOWN_MASK ) ; + } + + @Test + public void testSingleButtonPressAndReleaseWithCtrl() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_CONTROL, java.awt.event.InputEvent.CTRL_DOWN_MASK ) ; + } + + // The META and ALT tests get too tied up with functions of the window system on X11, + // so it's probably best to leave them commented out. + + //@Test + //public void testSingleButtonPressAndReleaseWithMeta() throws Exception { + // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_META, java.awt.event.InputEvent.META_DOWN_MASK ) ; + //} + + //@Test + //public void testSingleButtonPressAndReleaseWithAlt() throws Exception { + // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT, java.awt.event.InputEvent.ALT_DOWN_MASK ) ; + //} + + // FIXME - not sure yet what's up with ALT_GRAPH. It appears that this + // modifier didn't make it through, so I had to disable this test else + // it would always fail. + // + // My US keyboard doesn't have an AltGr key, so maybe X is smart + // enough to not let this modifier slip through (?). + + //@Test + //public void testSingleButtonPressAndReleaseWithAltGraph() throws Exception { + // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH, java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) ; + //} + + //////////////////////////////////////////////////////////////////////////// + + @Test + public void testHoldOneButtonAndPressAnother() throws Exception { + _doHoldOneButtonAndPressAnother( 0, 0 ) ; + } + + @Test + public void testPressAllButtonsInSequence() throws Exception { + _doPressAllButtonsInSequence( 0, 0 ) ; + } + + @Test + public void testSingleButtonClickAndDrag() throws Exception { + _doSingleButtonClickAndDrag( 0, 0 ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + private void _doSingleButtonPressAndRelease( final int keyCode, final int keyModifierMask ) throws Exception { + + if( _debug ) { _debugPrintStream.println( "\n>>>> _doSingleButtonPressAndRelease" ) ; } + + _doKeyPress( keyCode ) ; + + for (int n = 0 ; n < _numButtonsToTest ; ++n) { + + int awtButtonMask = _awtButtonMasks[n] ; + + if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; + _robot.mousePress( awtButtonMask ) ; + _checkFailures() ; + + if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; + _robot.mouseRelease( awtButtonMask ) ; + _checkFailures() ; + } + + _doKeyRelease( keyCode ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + private void _doHoldOneButtonAndPressAnother( final int keyCode, final int keyModifierMask ) throws Exception { + + if( _debug ) { _debugPrintStream.println( "\n>>>> _doHoldOneButtonAndPressAnother" ) ; } + + _doKeyPress( keyCode ) ; + + for (int n = 0 ; n < _numButtonsToTest ; ++n) { + + int awtButtonMask = _awtButtonMasks[n] ; + + if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; + _robot.mousePress( awtButtonMask ) ; + _checkFailures() ; + + for (int m = 0 ; m < _numButtonsToTest ; ++m) { + + if( n != m ) { + + if( _debug ) { _debugPrintStream.println( "\n pressing additional button " + ( m + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask | _awtButtonMasks[m] ) ) ; + _robot.mousePress( _awtButtonMasks[m] ) ; + _checkFailures() ; + + if( _debug ) { _debugPrintStream.println( "\n releasing additional button " + ( m + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; + _robot.mouseRelease( _awtButtonMasks[m] ) ; + _checkFailures() ; + } + } + + if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; + _robot.mouseRelease( awtButtonMask ) ; + _checkFailures() ; + } + + _doKeyRelease( keyCode ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + private void _doPressAllButtonsInSequence( final int keyCode, final int keyModifierMask ) throws Exception { + + if( _debug ) { _debugPrintStream.println( "\n>>>> _doPressAllButtonsInSequence" ) ; } + + _doKeyPress( keyCode ) ; + + { + int cumulativeAwtModifiers = 0 ; + + for (int n = 0 ; n < _numButtonsToTest ; ++n) { + + cumulativeAwtModifiers |= _awtButtonMasks[n] ; + + if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | cumulativeAwtModifiers ) ) ; + _robot.mousePress( _awtButtonMasks[n] ) ; + _checkFailures() ; + } + + for (int n = _numButtonsToTest - 1 ; n >= 0 ; --n) { + + cumulativeAwtModifiers &= ~_awtButtonMasks[n] ; + + if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | cumulativeAwtModifiers ) ) ; + _robot.mouseRelease( _awtButtonMasks[n] ) ; + _checkFailures() ; + } + } + + _doKeyRelease( keyCode ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + private void _doSingleButtonClickAndDrag( final int keyCode, final int keyModifierMask ) throws Exception { + + if( _debug ) { _debugPrintStream.println( "\n>>>> _doSingleButtonClickAndDrag" ) ; } + + _doKeyPress( keyCode ) ; + + _testMouseListener.setModifierCheckEnabled( true ) ; + + for (int n = 0 ; n < _numButtonsToTest ; ++n) { + + int awtButtonMask = _awtButtonMasks[n] ; + + if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; + _robot.mousePress( awtButtonMask ) ; + _checkFailures() ; + + // To get a drag we only need to move one pixel. + if( _debug ) { _debugPrintStream.println( "\n moving mouse" ) ; } + _robot.mouseMove( INITIAL_MOUSE_X + 1, INITIAL_MOUSE_Y + 1 ) ; + _checkFailures() ; + + if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; + _robot.mouseRelease( awtButtonMask ) ; + _checkFailures() ; + + _testMouseListener.setModifierCheckEnabled( false ) ; + _robot.mouseMove( INITIAL_MOUSE_X, INITIAL_MOUSE_Y ) ; + _testMouseListener.setModifierCheckEnabled( true ) ; + } + + _doKeyRelease( keyCode ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + private void _doKeyPress( int keyCode ) { + if( keyCode != 0 ) { + boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; + _testMouseListener.setModifierCheckEnabled( false ) ; + _robot.keyPress( keyCode ) ; + _testMouseListener.setModifierCheckEnabled( modifierCheckEnabled ) ; + } + } + + //////////////////////////////////////////////////////////////////////////// + + private void _doKeyRelease( int keyCode ) { + if( keyCode != 0 ) { + boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; + _testMouseListener.setModifierCheckEnabled( false ) ; + _robot.keyRelease( keyCode ) ; + _testMouseListener.setModifierCheckEnabled( modifierCheckEnabled ) ; + } + } + + //////////////////////////////////////////////////////////////////////////// + + private void _checkFailures() { + + ArrayList failures = _testMouseListener.getFailures() ; + + if( _debug ) { + int numFailures = failures.size() ; + if( numFailures == 0 ) { + _debugPrintStream.println( " PASSED" ) ; + } else { + _debugPrintStream.println( " FAILED" ) ; + for( int n = 0 ; n < numFailures ; ++n ) { + _debugPrintStream.print( " " ) ; + _debugPrintStream.println( failures.get(n) ) ; + } + } + } + + Assert.assertTrue( failures.size() == 0 ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + @After + public void after() throws Exception { + + _testMouseListener.setModifierCheckEnabled( false ) ; + + Thread.sleep( 500 ) ; + } + + //////////////////////////////////////////////////////////////////////////// + + @AfterClass + public static void afterClass() throws Exception { + + // Make sure all modifiers are released, otherwise the user's + // desktop can get locked up (ask me how I know this). + + _releaseModifiers() ; + _escape() ; + } + + //////////////////////////////////////////////////////////////////////////// + + private static void _releaseModifiers() { + + if (_robot != null) { + + _robot.setAutoDelay( MS_ROBOT_SHORT_AUTO_DELAY ) ; + + boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; + _testMouseListener.setModifierCheckEnabled( false ) ; + + { + _robot.keyRelease( java.awt.event.KeyEvent.VK_SHIFT ) ; + _robot.keyRelease( java.awt.event.KeyEvent.VK_CONTROL ) ; + _robot.keyRelease( java.awt.event.KeyEvent.VK_META ) ; + _robot.keyRelease( java.awt.event.KeyEvent.VK_ALT ) ; + _robot.keyRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH ) ; + + for (int n = 0 ; n < _awtButtonMasks.length ; ++n) { + _robot.mouseRelease( _awtButtonMasks[n] ) ; + } + } + + _testMouseListener.setModifierCheckEnabled( modifierCheckEnabled ) ; + + _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; + } + } + + private static void _escape() { + if (_robot != null) { + _robot.keyPress( java.awt.event.KeyEvent.VK_ESCAPE ) ; + _robot.keyRelease( java.awt.event.KeyEvent.VK_ESCAPE ) ; + } + } + + //////////////////////////////////////////////////////////////////////////// + + /** + * Brute force method to return the NEWT event modifiers equivalent + * to the specified AWT event extended modifiers. + * + * @param awtExtendedModifiers + * The AWT extended modifiers. + * + * @return + * The equivalent NEWT modifiers. + */ + + private int _getNewtModifiersForAwtExtendedModifiers( int awtExtendedModifiers ) { + + int mask = 0 ; + + if( ( awtExtendedModifiers & java.awt.event.InputEvent.SHIFT_DOWN_MASK ) != 0 ) { + mask |= com.jogamp.newt.event.InputEvent.SHIFT_MASK ; + } + + if( ( awtExtendedModifiers & java.awt.event.InputEvent.CTRL_DOWN_MASK ) != 0 ) { + mask |= com.jogamp.newt.event.InputEvent.CTRL_MASK ; + } + + if( ( awtExtendedModifiers & java.awt.event.InputEvent.META_DOWN_MASK ) != 0 ) { + mask |= com.jogamp.newt.event.InputEvent.META_MASK ; + } + + if( ( awtExtendedModifiers & java.awt.event.InputEvent.ALT_DOWN_MASK ) != 0 ) { + mask |= com.jogamp.newt.event.InputEvent.ALT_MASK ; + } + + if( ( awtExtendedModifiers & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) != 0 ) { + mask |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK ; + } + + for (int n = 0 ; n < _numButtonsToTest ; ++n) { + if ((awtExtendedModifiers & getAWTButtonMask(n+1)) != 0) { + mask |= com.jogamp.newt.event.InputEvent.getButtonMask(n+1) ; + } + } + + return mask ; + } + + //////////////////////////////////////////////////////////////////////////// +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt b/src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt deleted file mode 100644 index 1bd9102b5..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/ModifierMappings.txt +++ /dev/null @@ -1,37 +0,0 @@ -Modifier AWT Constant AWT Bit AWT Ex NEWT Constant NEWT Bit -------------- ------------------------------- ------- ------ ------------------------- -------- -Shift Event.SHIFT_MASK 0 -Ctrl Event.CTRL_MASK 1 -Meta Event.META_MASK 2 -Alt Event.ALT_MASK 3 -Button1 InputEvent.BUTTON1_MASK 4 -Button2 InputEvent.BUTTON2_MASK 3 -Button3 InputEvent.BUTTON3_MASK 2 -Shift Down InputEvent.SHIFT_DOWN_MASK 6 * InputEvent.SHIFT_MASK 0 -Ctrl Down InputEvent.CTRL_DOWN_MASK 7 * InputEvent.CTRL_MASK 1 -Meta Down InputEvent.META_DOWN_MASK 8 * InputEvent.META_MASK 2 -Alt Down InputEvent.ALT_DOWN_MASK 9 * InputEvent.ALT_MASK 3 -Button1 Down InputEvent.BUTTON1_DOWN_MASK 10 * InputEvent.BUTTON1_MASK 5 -Button2 Down InputEvent.BUTTON2_DOWN_MASK 11 * InputEvent.BUTTON2_MASK 6 -Button3 Down InputEvent.BUTTON3_DOWN_MASK 12 * InputEvent.BUTTON3_MASK 7 -AltGraph Down InputEvent.ALT_GRAPH_DOWN_MASK 13 * InputEvent.ALT_GRAPH_MASK 4 -Button4 Down -- 14 * InputEvent.BUTTON4_MASK 8 -Button5 Down -- 15 * InputEvent.BUTTON5_MASK 9 -Button6 Down -- 16 * InputEvent.BUTTON6_MASK 10 -Button7 Down -- 17 * InputEvent.BUTTON7_MASK 11 -Button8 Down -- 18 * InputEvent.BUTTON8_MASK 12 -Button9 Down -- 19 * InputEvent.BUTTON9_MASK 13 -Button10 Down -- 20 * -Button11 Down -- 21 * -Button12 Down -- 22 * -Button13 Down -- 23 * -Button14 Down -- 24 * -Button15 Down -- 25 * -Button16 Down -- 26 * InputEvent.BUTTONLAST_MASK 20 -Button17 Down -- 27 * -Button18 Down -- 28 * -Button19 Down -- 29 * -Button20 Down -- 30 * -Autorepeat -- - InputEvent.AUTOREPEAT_MASK 29 -Confined -- - InputEvent.CONFINED_MASK 30 -Invisible -- - InputEvent.INVISIBLE_MASK 31 diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java deleted file mode 100644 index 81e1939b9..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiers.java +++ /dev/null @@ -1,761 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt.event ; - -import java.io.PrintStream ; -import java.util.ArrayList ; - -import javax.media.opengl.GL ; -import javax.media.opengl.GL2 ; -import javax.media.opengl.GLAutoDrawable ; -import javax.media.opengl.GLEventListener ; -import javax.media.opengl.GLProfile ; - -import org.junit.After ; -import org.junit.AfterClass ; -import org.junit.Assert ; -import org.junit.Before ; -import org.junit.BeforeClass ; -import org.junit.Test ; - -import com.jogamp.opengl.test.junit.util.UITestCase ; - -/** - * Test whether or not event modifiers are preserved by NEWT. This - * class defines most of the tests, but leaves the type of window - * and canvas up to subclasses. - */ - -public abstract class TestNewtEventModifiers extends UITestCase { - - static - { - GLProfile.initSingleton() ; - } - - // A class to draw something on a canvas. This is only - // here so we can make sure the GL drawing area has - // filled the window. - - public static class BigGreenXGLEventListener implements GLEventListener - { - public void init( GLAutoDrawable drawable ) - { - GL2 gl = drawable.getGL().getGL2() ; - - gl.glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ) ; - - gl.glEnable( GL.GL_LINE_SMOOTH ) ; - gl.glEnable( GL.GL_BLEND ) ; - gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA ) ; - } - - public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ) - { - GL2 gl = drawable.getGL().getGL2() ; - - gl.glViewport( 0, 0, width, height ) ; - - gl.glMatrixMode( GL2.GL_PROJECTION ) ; - gl.glLoadIdentity() ; - gl.glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ) ; - - gl.glMatrixMode( GL2.GL_MODELVIEW ) ; - gl.glLoadIdentity() ; - } - - public void display( GLAutoDrawable drawable ) - { - GL2 gl = drawable.getGL().getGL2() ; - - gl.glClear( GL2.GL_COLOR_BUFFER_BIT ) ; - - gl.glColor4f( 0.0f, 1.0f, 0.0f, 1.0f ) ; - - gl.glBegin( GL.GL_LINES ) ; - { - gl.glVertex2f( -1.0f, 1.0f ) ; - gl.glVertex2f( 1.0f, -1.0f ) ; - - gl.glVertex2f( -1.0f, -1.0f ) ; - gl.glVertex2f( 1.0f, 1.0f ) ; - } - gl.glEnd() ; - } - - public void dispose( GLAutoDrawable drawable ) - { - } - } - - //////////////////////////////////////////////////////////////////////////// - - private static class TestMouseListener implements com.jogamp.newt.event.MouseListener - { - private static final String NO_EVENT_DELIVERY = "no event delivery" ; - - private boolean _modifierCheckEnabled ; - private int _expectedModifiers ; - private ArrayList _failures = new ArrayList() ; - - public void setModifierCheckEnabled( boolean value ) { - _modifierCheckEnabled = value ; - } - - public boolean modifierCheckEnabled() { - return _modifierCheckEnabled ; - } - - /** - * Sets the modifiers the listener should expect, and clears - * out any existing accumulated failures. Normally this kind - * of double duty in a setter might be considered evil, but - * in this test code it's probably ok. - */ - - public void setExpectedModifiers( int value ) { - _expectedModifiers = value ; - - // Assume we will have a failure due to no event delivery. - // If an event is delivered and it's good this assumed - // failure will get cleared out. - - _failures.clear() ; - _failures.add( NO_EVENT_DELIVERY ) ; - } - - private void _checkModifiers( com.jogamp.newt.event.MouseEvent event ) { - - if( _debug ) { - _debugPrintStream.print( " received NEWT " ) ; - _debugPrintStream.print( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ) ; - } - - if( _modifierCheckEnabled ) { - - if( _debug ) { - _debugPrintStream.println( ", checking modifiers..." ) ; - _debugPrintStream.println( " expected NEWT Modifiers:" ) ; - _printModifiers( _expectedModifiers ) ; - _debugPrintStream.println( " current NEWT Modifiers:" ) ; - _printModifiers( event.getModifiers() ) ; - } - - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.SHIFT_MASK ) ; - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.CTRL_MASK ) ; - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.META_MASK ) ; - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.ALT_MASK ) ; - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK ) ; - - for( int n = 0 ; n < _numButtonsToTest ; ++n ) { - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.getButtonMask( n + 1 ) ) ; - } - } else { - if( _debug ) { - _debugPrintStream.println( ", modifier check disabled" ) ; - } - } - } - - private void _checkModifierMask( com.jogamp.newt.event.MouseEvent event, int mask ) { - - // If the "no event delivery" failure is still in the list then - // get rid of it since that obviously isn't true anymore. We - // want to do this whether or not there's an issue with the - // modifiers. - - if( _failures.size() == 1 && _failures.get(0).equals( NO_EVENT_DELIVERY ) ) { - _failures.clear() ; - } - - if( ( event.getModifiers() & mask ) != ( _expectedModifiers & mask ) ) { - _failures.add( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ) ; - } - } - - private void _printModifiers( int modifiers ) { - if( ( modifiers & com.jogamp.newt.event.InputEvent.SHIFT_MASK ) != 0 ) { _debugPrintStream.println( " SHIFT" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.CTRL_MASK ) != 0 ) { _debugPrintStream.println( " CTRL" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.META_MASK ) != 0 ) { _debugPrintStream.println( " META" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.ALT_MASK ) != 0 ) { _debugPrintStream.println( " ALT" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK ) != 0 ) { _debugPrintStream.println( " ALT_GRAPH" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON1_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON1" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON2_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON2" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON3_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON3" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON4_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON4" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON5_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON5" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON6_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON6" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON7_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON7" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON8_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON8" ) ; } - if( ( modifiers & com.jogamp.newt.event.InputEvent.BUTTON9_MASK ) != 0 ) { _debugPrintStream.println( " BUTTON9" ) ; } - } - - private static void _printAwtModifiers( int awtMods, int awtModsEx ) { - if( ( awtMods & java.awt.event.InputEvent.SHIFT_MASK ) != 0 ) { System.err.println( "SHIFT" ) ; } - if( ( awtMods & java.awt.event.InputEvent.CTRL_MASK ) != 0 ) { System.err.println( "CTRL" ) ; } - if( ( awtMods & java.awt.event.InputEvent.META_MASK ) != 0 ) { System.err.println( "META" ) ; } - if( ( awtMods & java.awt.event.InputEvent.ALT_MASK ) != 0 ) { System.err.println( "ALT" ) ; } - if( ( awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK ) != 0 ) { System.err.println( "ALT_GRAPH" ) ; } - - if( ( awtModsEx & java.awt.event.InputEvent.SHIFT_DOWN_MASK ) != 0 ) { System.err.println( "SHIFT Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.CTRL_DOWN_MASK ) != 0 ) { System.err.println( "CTRL Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.META_DOWN_MASK ) != 0 ) { System.err.println( "META Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.ALT_DOWN_MASK ) != 0 ) { System.err.println( "ALT Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) != 0 ) { System.err.println( "ALT_GRAPH Ex" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON1" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.BUTTON2_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON2" ) ; } - if( ( awtModsEx & java.awt.event.InputEvent.BUTTON3_DOWN_MASK ) != 0 ) { System.err.println( "BUTTON3" ) ; } - } - - public ArrayList getFailures() { - return _failures ; - } - - public void mouseClicked( com.jogamp.newt.event.MouseEvent event ) { - _checkModifiers( event ) ; - } - - public void mousePressed( com.jogamp.newt.event.MouseEvent event ) { - _checkModifiers( event ) ; - } - - public void mouseReleased( com.jogamp.newt.event.MouseEvent event ) { - _checkModifiers( event ) ; - } - - public void mouseEntered( com.jogamp.newt.event.MouseEvent event ) { - _checkModifiers( event ) ; - } - - public void mouseExited( com.jogamp.newt.event.MouseEvent event ) { - _checkModifiers( event ) ; - } - - public void mouseDragged( com.jogamp.newt.event.MouseEvent event ) { - _checkModifiers( event ) ; - } - - public void mouseMoved( com.jogamp.newt.event.MouseEvent event ) { - _checkModifiers( event ) ; - } - - public void mouseWheelMoved( com.jogamp.newt.event.MouseEvent event ) { - _checkModifiers( event ) ; - } - } - - //////////////////////////////////////////////////////////////////////////// - - protected static final int TEST_FRAME_X = 100 ; - protected static final int TEST_FRAME_Y = 100 ; - - protected static final int TEST_FRAME_WIDTH = 400 ; - protected static final int TEST_FRAME_HEIGHT = 400 ; - - private static final int INITIAL_MOUSE_X = TEST_FRAME_X + ( TEST_FRAME_WIDTH / 2 ) ; - private static final int INITIAL_MOUSE_Y = TEST_FRAME_Y + ( TEST_FRAME_HEIGHT / 2 ) ; - - private static final int MS_ROBOT_SHORT_AUTO_DELAY = 50 ; - private static final int MS_ROBOT_LONG_AUTO_DELAY = 500 ; - - private static boolean _debug = true ; - private static PrintStream _debugPrintStream = System.err ; - - //////////////////////////////////////////////////////////////////////////// - - private static int _numButtonsToTest ; - private static int _awtButtonMasks[] ; - private static int _newtButtonMasks[] ; - - private static java.awt.Robot _robot ; - - protected static TestMouseListener _testMouseListener ; - - //////////////////////////////////////////////////////////////////////////// - - public static int getAWTButtonMask(int button) { - int m; - switch(button) { - case 1 : m = java.awt.event.InputEvent.BUTTON1_MASK; break; - case 2 : m = java.awt.event.InputEvent.BUTTON2_MASK; break; - case 3 : m = java.awt.event.InputEvent.BUTTON3_MASK; break; - default: throw new IllegalArgumentException("Only buttons 1-3 have a MASK value, requested button "+button); - } - return m; - } - - @BeforeClass - public static void beforeClass() throws Exception { - - // Who know how many buttons the AWT will say exist on given platform. - // We'll test the smaller of what NEWT supports and what the - // AWT says is available. - // _numButtonsToTest = java.awt.MouseInfo.getNumberOfButtons() ; - - // Then again, maybe not: - - // FIXME? - for reasons I'm not quite sure of the AWT MouseEvent - // constructor does some strange things for buttons other than - // 1, 2, and 3. Furthermore, while developing this test it - // appeared that events sent by the robot for buttons 9 and - // up weren't even delivered to the listeners. - // - // So... for now we're only going to test 3 buttons since - // that's the common case. - - _numButtonsToTest = 3 ; - - { - if( _numButtonsToTest > com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { - _numButtonsToTest = com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ; - } - - // These two arrays are assumed to be peers, i.e. are the same - // size, and a given index references the same button in - // either array. - - _awtButtonMasks = new int[_numButtonsToTest] ; - - for( int n = 0 ; n < _awtButtonMasks.length ; ++n ) { - _awtButtonMasks[n] = getAWTButtonMask( n + 1 ); - } - - _newtButtonMasks = new int[_numButtonsToTest] ; - - for( int n = 0 ; n < _newtButtonMasks.length ; ++n ) { - _newtButtonMasks[n] = com.jogamp.newt.event.InputEvent.getButtonMask( n + 1 ) ; - } - } - - _robot = new java.awt.Robot() ; - _robot.setAutoWaitForIdle( true ) ; - _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; - - _testMouseListener = new TestMouseListener() ; - } - - //////////////////////////////////////////////////////////////////////////// - - @Before - public void before() throws Exception { - - _testMouseListener.setModifierCheckEnabled( false ) ; - _robot.setAutoDelay( MS_ROBOT_SHORT_AUTO_DELAY ) ; - - // Make sure all the buttons and modifier keys are released. - - _releaseModifiers() ; - _escape() ; - - // Move the pointer into the window and click once to - // ensure that the test window has focus. - - if( _debug ) { - _debugPrintStream.println( ">>>> Clicking in the window to get focus." ) ; - } - - _robot.mouseMove( INITIAL_MOUSE_X, INITIAL_MOUSE_Y ) ; - _robot.mousePress( java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) ; - _robot.mouseRelease( java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) ; - - _testMouseListener.setModifierCheckEnabled( true ) ; - _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; - - if( _debug ) { - _debugPrintStream.println( ">>>> About to start testing." ) ; - } - } - - //////////////////////////////////////////////////////////////////////////// - - // The approach on all these tests is to tell the test mouse listener what - // modifiers we think it should receive. Then when the events are delivered - // it compares what we told it to expect with what actually showed up and - // complains if there are differences. - // - // As things stand currently the tests below generally work for AWTCanvas - // and fail for everything else. This may point to a flaw in the test - // code, or a flaw in the NEWT stuff; not sure yet. One exception is the - // tests involving ALT and META, which on at least X11 cause the desktop - // to do undesirable stuff while the tests are in progress. So... these - // tests have been commented out for now and probably should be left - // that way. - // - // Due to the fact that a majority of these fail currently for - // everything but AWTCanvas for the time being we probably shouldn't - // run the tests for NewtCanvasAWT and NewtCanvasSWT until we can - // pay more attention to the NEWT event modifier stuff. - - @Test - public void testSingleButtonPressAndRelease() throws Exception { - _doSingleButtonPressAndRelease( 0, 0 ) ; - } - - @Test - public void testSingleButtonPressAndReleaseWithShift() throws Exception { - _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_SHIFT, java.awt.event.InputEvent.SHIFT_DOWN_MASK ) ; - } - - @Test - public void testSingleButtonPressAndReleaseWithCtrl() throws Exception { - _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_CONTROL, java.awt.event.InputEvent.CTRL_DOWN_MASK ) ; - } - - // The META and ALT tests get too tied up with functions of the window system on X11, - // so it's probably best to leave them commented out. - - //@Test - //public void testSingleButtonPressAndReleaseWithMeta() throws Exception { - // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_META, java.awt.event.InputEvent.META_DOWN_MASK ) ; - //} - - //@Test - //public void testSingleButtonPressAndReleaseWithAlt() throws Exception { - // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT, java.awt.event.InputEvent.ALT_DOWN_MASK ) ; - //} - - // FIXME - not sure yet what's up with ALT_GRAPH. It appears that this - // modifier didn't make it through, so I had to disable this test else - // it would always fail. - // - // My US keyboard doesn't have an AltGr key, so maybe X is smart - // enough to not let this modifier slip through (?). - - //@Test - //public void testSingleButtonPressAndReleaseWithAltGraph() throws Exception { - // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH, java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) ; - //} - - //////////////////////////////////////////////////////////////////////////// - - @Test - public void testHoldOneButtonAndPressAnother() throws Exception { - _doHoldOneButtonAndPressAnother( 0, 0 ) ; - } - - @Test - public void testPressAllButtonsInSequence() throws Exception { - _doPressAllButtonsInSequence( 0, 0 ) ; - } - - @Test - public void testSingleButtonClickAndDrag() throws Exception { - _doSingleButtonClickAndDrag( 0, 0 ) ; - } - - //////////////////////////////////////////////////////////////////////////// - - private void _doSingleButtonPressAndRelease( final int keyCode, final int keyModifierMask ) throws Exception { - - if( _debug ) { _debugPrintStream.println( "\n>>>> _doSingleButtonPressAndRelease" ) ; } - - _doKeyPress( keyCode ) ; - - for (int n = 0 ; n < _numButtonsToTest ; ++n) { - - int awtButtonMask = _awtButtonMasks[n] ; - - if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; - _robot.mousePress( awtButtonMask ) ; - _checkFailures() ; - - if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; - _robot.mouseRelease( awtButtonMask ) ; - _checkFailures() ; - } - - _doKeyRelease( keyCode ) ; - } - - //////////////////////////////////////////////////////////////////////////// - - private void _doHoldOneButtonAndPressAnother( final int keyCode, final int keyModifierMask ) throws Exception { - - if( _debug ) { _debugPrintStream.println( "\n>>>> _doHoldOneButtonAndPressAnother" ) ; } - - _doKeyPress( keyCode ) ; - - for (int n = 0 ; n < _numButtonsToTest ; ++n) { - - int awtButtonMask = _awtButtonMasks[n] ; - - if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; - _robot.mousePress( awtButtonMask ) ; - _checkFailures() ; - - for (int m = 0 ; m < _numButtonsToTest ; ++m) { - - if( n != m ) { - - if( _debug ) { _debugPrintStream.println( "\n pressing additional button " + ( m + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask | _awtButtonMasks[m] ) ) ; - _robot.mousePress( _awtButtonMasks[m] ) ; - _checkFailures() ; - - if( _debug ) { _debugPrintStream.println( "\n releasing additional button " + ( m + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; - _robot.mouseRelease( _awtButtonMasks[m] ) ; - _checkFailures() ; - } - } - - if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; - _robot.mouseRelease( awtButtonMask ) ; - _checkFailures() ; - } - - _doKeyRelease( keyCode ) ; - } - - //////////////////////////////////////////////////////////////////////////// - - private void _doPressAllButtonsInSequence( final int keyCode, final int keyModifierMask ) throws Exception { - - if( _debug ) { _debugPrintStream.println( "\n>>>> _doPressAllButtonsInSequence" ) ; } - - _doKeyPress( keyCode ) ; - - { - int cumulativeAwtModifiers = 0 ; - - for (int n = 0 ; n < _numButtonsToTest ; ++n) { - - cumulativeAwtModifiers |= _awtButtonMasks[n] ; - - if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | cumulativeAwtModifiers ) ) ; - _robot.mousePress( _awtButtonMasks[n] ) ; - _checkFailures() ; - } - - for (int n = _numButtonsToTest - 1 ; n >= 0 ; --n) { - - cumulativeAwtModifiers &= ~_awtButtonMasks[n] ; - - if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | cumulativeAwtModifiers ) ) ; - _robot.mouseRelease( _awtButtonMasks[n] ) ; - _checkFailures() ; - } - } - - _doKeyRelease( keyCode ) ; - } - - //////////////////////////////////////////////////////////////////////////// - - private void _doSingleButtonClickAndDrag( final int keyCode, final int keyModifierMask ) throws Exception { - - if( _debug ) { _debugPrintStream.println( "\n>>>> _doSingleButtonClickAndDrag" ) ; } - - _doKeyPress( keyCode ) ; - - _testMouseListener.setModifierCheckEnabled( true ) ; - - for (int n = 0 ; n < _numButtonsToTest ; ++n) { - - int awtButtonMask = _awtButtonMasks[n] ; - - if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; - _robot.mousePress( awtButtonMask ) ; - _checkFailures() ; - - // To get a drag we only need to move one pixel. - if( _debug ) { _debugPrintStream.println( "\n moving mouse" ) ; } - _robot.mouseMove( INITIAL_MOUSE_X + 1, INITIAL_MOUSE_Y + 1 ) ; - _checkFailures() ; - - if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; - _robot.mouseRelease( awtButtonMask ) ; - _checkFailures() ; - - _testMouseListener.setModifierCheckEnabled( false ) ; - _robot.mouseMove( INITIAL_MOUSE_X, INITIAL_MOUSE_Y ) ; - _testMouseListener.setModifierCheckEnabled( true ) ; - } - - _doKeyRelease( keyCode ) ; - } - - //////////////////////////////////////////////////////////////////////////// - - private void _doKeyPress( int keyCode ) { - if( keyCode != 0 ) { - boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; - _testMouseListener.setModifierCheckEnabled( false ) ; - _robot.keyPress( keyCode ) ; - _testMouseListener.setModifierCheckEnabled( modifierCheckEnabled ) ; - } - } - - //////////////////////////////////////////////////////////////////////////// - - private void _doKeyRelease( int keyCode ) { - if( keyCode != 0 ) { - boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; - _testMouseListener.setModifierCheckEnabled( false ) ; - _robot.keyRelease( keyCode ) ; - _testMouseListener.setModifierCheckEnabled( modifierCheckEnabled ) ; - } - } - - //////////////////////////////////////////////////////////////////////////// - - private void _checkFailures() { - - ArrayList failures = _testMouseListener.getFailures() ; - - if( _debug ) { - int numFailures = failures.size() ; - if( numFailures == 0 ) { - _debugPrintStream.println( " PASSED" ) ; - } else { - _debugPrintStream.println( " FAILED" ) ; - for( int n = 0 ; n < numFailures ; ++n ) { - _debugPrintStream.print( " " ) ; - _debugPrintStream.println( failures.get(n) ) ; - } - } - } - - Assert.assertTrue( failures.size() == 0 ) ; - } - - //////////////////////////////////////////////////////////////////////////// - - @After - public void after() throws Exception { - - _testMouseListener.setModifierCheckEnabled( false ) ; - - Thread.sleep( 500 ) ; - } - - //////////////////////////////////////////////////////////////////////////// - - @AfterClass - public static void afterClass() throws Exception { - - // Make sure all modifiers are released, otherwise the user's - // desktop can get locked up (ask me how I know this). - - _releaseModifiers() ; - _escape() ; - } - - //////////////////////////////////////////////////////////////////////////// - - private static void _releaseModifiers() { - - if (_robot != null) { - - _robot.setAutoDelay( MS_ROBOT_SHORT_AUTO_DELAY ) ; - - boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; - _testMouseListener.setModifierCheckEnabled( false ) ; - - { - _robot.keyRelease( java.awt.event.KeyEvent.VK_SHIFT ) ; - _robot.keyRelease( java.awt.event.KeyEvent.VK_CONTROL ) ; - _robot.keyRelease( java.awt.event.KeyEvent.VK_META ) ; - _robot.keyRelease( java.awt.event.KeyEvent.VK_ALT ) ; - _robot.keyRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH ) ; - - for (int n = 0 ; n < _awtButtonMasks.length ; ++n) { - _robot.mouseRelease( _awtButtonMasks[n] ) ; - } - } - - _testMouseListener.setModifierCheckEnabled( modifierCheckEnabled ) ; - - _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; - } - } - - private static void _escape() { - if (_robot != null) { - _robot.keyPress( java.awt.event.KeyEvent.VK_ESCAPE ) ; - _robot.keyRelease( java.awt.event.KeyEvent.VK_ESCAPE ) ; - } - } - - //////////////////////////////////////////////////////////////////////////// - - /** - * Brute force method to return the NEWT event modifiers equivalent - * to the specified AWT event extended modifiers. - * - * @param awtExtendedModifiers - * The AWT extended modifiers. - * - * @return - * The equivalent NEWT modifiers. - */ - - private int _getNewtModifiersForAwtExtendedModifiers( int awtExtendedModifiers ) { - - int mask = 0 ; - - if( ( awtExtendedModifiers & java.awt.event.InputEvent.SHIFT_DOWN_MASK ) != 0 ) { - mask |= com.jogamp.newt.event.InputEvent.SHIFT_MASK ; - } - - if( ( awtExtendedModifiers & java.awt.event.InputEvent.CTRL_DOWN_MASK ) != 0 ) { - mask |= com.jogamp.newt.event.InputEvent.CTRL_MASK ; - } - - if( ( awtExtendedModifiers & java.awt.event.InputEvent.META_DOWN_MASK ) != 0 ) { - mask |= com.jogamp.newt.event.InputEvent.META_MASK ; - } - - if( ( awtExtendedModifiers & java.awt.event.InputEvent.ALT_DOWN_MASK ) != 0 ) { - mask |= com.jogamp.newt.event.InputEvent.ALT_MASK ; - } - - if( ( awtExtendedModifiers & java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) != 0 ) { - mask |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK ; - } - - for (int n = 0 ; n < _numButtonsToTest ; ++n) { - if ((awtExtendedModifiers & getAWTButtonMask(n+1)) != 0) { - mask |= com.jogamp.newt.event.InputEvent.getButtonMask(n+1) ; - } - } - - return mask ; - } - - //////////////////////////////////////////////////////////////////////////// -} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java index 3aa016d56..fd68ace73 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java @@ -44,7 +44,7 @@ import com.jogamp.newt.event.awt.AWTMouseAdapter ; * the source is an AWT canvas. */ -public class TestNewtEventModifiersAWTCanvas extends TestNewtEventModifiers { +public class TestNewtEventModifiersAWTCanvas extends BaseNewtEventModifiers { private static JFrame _testFrame ; @@ -53,7 +53,7 @@ public class TestNewtEventModifiersAWTCanvas extends TestNewtEventModifiers { @BeforeClass public static void beforeClass() throws Exception { - TestNewtEventModifiers.beforeClass() ; + BaseNewtEventModifiers.beforeClass() ; final GLCanvas canvas = new GLCanvas() ; canvas.addGLEventListener( new BigGreenXGLEventListener() ) ; @@ -76,7 +76,7 @@ public class TestNewtEventModifiersAWTCanvas extends TestNewtEventModifiers { @AfterClass public static void afterClass() throws Exception { - TestNewtEventModifiers.afterClass() ; + BaseNewtEventModifiers.afterClass() ; SwingUtilities.invokeAndWait(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java index a2c1d3364..44f116ea1 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java @@ -48,7 +48,7 @@ import com.jogamp.newt.opengl.GLWindow ; * the canvas is a NewtCanvasAWT. */ -public class TestNewtEventModifiersNewtCanvasAWT extends TestNewtEventModifiers { +public class TestNewtEventModifiersNewtCanvasAWT extends BaseNewtEventModifiers { private static JFrame _testFrame ; private static GLWindow _glWindow ; @@ -58,7 +58,7 @@ public class TestNewtEventModifiersNewtCanvasAWT extends TestNewtEventModifiers @BeforeClass public static void beforeClass() throws Exception { - TestNewtEventModifiers.beforeClass() ; + BaseNewtEventModifiers.beforeClass() ; SwingUtilities.invokeAndWait( new Runnable() { public void run() { @@ -89,7 +89,7 @@ public class TestNewtEventModifiersNewtCanvasAWT extends TestNewtEventModifiers @AfterClass public static void afterClass() throws Exception { - TestNewtEventModifiers.afterClass() ; + BaseNewtEventModifiers.afterClass() ; SwingUtilities.invokeAndWait( new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java index e6139bb37..501e0d1bd 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java @@ -47,7 +47,7 @@ import com.jogamp.newt.swt.NewtCanvasSWT ; * the canvas is a NewtCanvasSWT. */ -public class TestNewtEventModifiersNewtCanvasSWT extends TestNewtEventModifiers { +public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers { private static Shell _testShell ; private static GLWindow _glWindow ; @@ -87,7 +87,7 @@ public class TestNewtEventModifiersNewtCanvasSWT extends TestNewtEventModifiers @BeforeClass public static void beforeClass() throws Exception { - TestNewtEventModifiers.beforeClass() ; + BaseNewtEventModifiers.beforeClass() ; _displayThread = new DisplayThread() ; _displayThread.start() ; @@ -127,7 +127,7 @@ public class TestNewtEventModifiersNewtCanvasSWT extends TestNewtEventModifiers @AfterClass public static void afterClass() throws Exception { - TestNewtEventModifiers.afterClass() ; + BaseNewtEventModifiers.afterClass() ; _glWindow.destroy() ; -- cgit v1.2.3 From f3e2467decf2a5ee47cfb458f7071772f39ea9c6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Dec 2012 01:55:55 +0100 Subject: AWT-NEWT Modifier mapping and test: part-3 (NEWT BUTTON MASK always, ..) - AWTNewtEventFactory's awtModifiers2Newt: - always include NEWT BUTTON_MASK (press, release, ..) where AWT doesn't include them at release (it's only a DOWN_MASK). - Test BaseNewtEventModifiers, .. - No need to call super class Before, BeforeClass, .. manually - Use RedSquareES2 as GL demo - Adapt to AWTNewtEventFactory's modifier change above (NEWT BUTTON MASK even at release) - More descriptive error/log text - Added _mandatory_ TestNewtEventModifiersNEWTWindowAWT to test native NEWT behavior. This shall be the golden behavior all translated events shall compare w/. --- make/scripts/tests-x64.bat | 15 ++- make/scripts/tests.sh | 16 ++- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 14 +- .../junit/newt/event/BaseNewtEventModifiers.java | 150 +++++++-------------- .../event/TestNewtEventModifiersAWTCanvas.java | 7 +- .../event/TestNewtEventModifiersNEWTWindowAWT.java | 75 +++++++++++ .../event/TestNewtEventModifiersNewtCanvasAWT.java | 7 +- .../event/TestNewtEventModifiersNewtCanvasSWT.java | 7 +- 8 files changed, 154 insertions(+), 137 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNEWTWindowAWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index d33f5dfdc..7cced0ecc 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -22,7 +22,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug551A REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* @@ -40,11 +40,14 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSi REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventOrderAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodesAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6f6438267..d96acf2e5 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -392,16 +392,20 @@ function testawtswt() { # # newt.awt (testawt) # -testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* +#testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventOrderAWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodesAWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index 665b7b5ee..1a61d0528 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -194,11 +194,8 @@ public class AWTNewtEventFactory { * @param awtModsEx * The AWT extended event modifiers. * AWT passes mouse button specific bits here and are the preferred way check the mouse button state. - * - * @param mouseHint - * Not used currently. */ - public static final int awtModifiers2Newt(final int awtMods, final int awtModsEx, final boolean mouseHint) { + public static final int awtModifiers2Newt(final int awtMods, final int awtModsEx) { int newtMods = 0; /** Redundant old modifiers .. @@ -271,7 +268,9 @@ public class AWTNewtEventFactory { rotation = -1 * ((java.awt.event.MouseWheelEvent)event).getWheelRotation(); } - int mods = awtModifiers2Newt(event.getModifiers(), event.getModifiersEx(), true); + final int newtButton = awtButton2Newt(event.getButton()); + int mods = awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()); + mods |= com.jogamp.newt.event.InputEvent.getButtonMask(newtButton); // always include NEWT BUTTON_MASK if(null!=newtSource) { if(newtSource.isPointerConfined()) { mods |= com.jogamp.newt.event.InputEvent.CONFINED_MASK; @@ -280,11 +279,10 @@ public class AWTNewtEventFactory { mods |= com.jogamp.newt.event.InputEvent.INVISIBLE_MASK; } } - return new com.jogamp.newt.event.MouseEvent( type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), mods, event.getX(), event.getY(), event.getClickCount(), - awtButton2Newt(event.getButton()), rotation); + newtButton, rotation); } return null; // no mapping .. } @@ -294,7 +292,7 @@ public class AWTNewtEventFactory { if(0xFFFFFFFF != type) { return new com.jogamp.newt.event.KeyEvent( type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), - awtModifiers2Newt(event.getModifiers(), event.getModifiersEx(), false), + awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()), event.getKeyCode(), event.getKeyChar()); } return null; // no mapping .. diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index 1dfdc4021..53af603ba 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -31,10 +31,6 @@ package com.jogamp.opengl.test.junit.newt.event ; import java.io.PrintStream ; import java.util.ArrayList ; -import javax.media.opengl.GL ; -import javax.media.opengl.GL2 ; -import javax.media.opengl.GLAutoDrawable ; -import javax.media.opengl.GLEventListener ; import javax.media.opengl.GLProfile ; import org.junit.After ; @@ -44,7 +40,6 @@ import org.junit.Before ; import org.junit.BeforeClass ; import org.junit.Test ; -import com.jogamp.common.os.Platform; import com.jogamp.newt.event.MouseEvent; import com.jogamp.opengl.test.junit.util.UITestCase ; @@ -61,63 +56,6 @@ public abstract class BaseNewtEventModifiers extends UITestCase { GLProfile.initSingleton() ; } - // A class to draw something on a canvas. This is only - // here so we can make sure the GL drawing area has - // filled the window. - - public static class BigGreenXGLEventListener implements GLEventListener - { - public void init( GLAutoDrawable drawable ) - { - GL2 gl = drawable.getGL().getGL2() ; - - gl.glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ) ; - - gl.glEnable( GL.GL_LINE_SMOOTH ) ; - gl.glEnable( GL.GL_BLEND ) ; - gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA ) ; - } - - public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ) - { - GL2 gl = drawable.getGL().getGL2() ; - - gl.glViewport( 0, 0, width, height ) ; - - gl.glMatrixMode( GL2.GL_PROJECTION ) ; - gl.glLoadIdentity() ; - gl.glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ) ; - - gl.glMatrixMode( GL2.GL_MODELVIEW ) ; - gl.glLoadIdentity() ; - } - - public void display( GLAutoDrawable drawable ) - { - GL2 gl = drawable.getGL().getGL2() ; - - gl.glClear( GL2.GL_COLOR_BUFFER_BIT ) ; - - gl.glColor4f( 0.0f, 1.0f, 0.0f, 1.0f ) ; - - gl.glBegin( GL.GL_LINES ) ; - { - gl.glVertex2f( -1.0f, 1.0f ) ; - gl.glVertex2f( 1.0f, -1.0f ) ; - - gl.glVertex2f( -1.0f, -1.0f ) ; - gl.glVertex2f( 1.0f, 1.0f ) ; - } - gl.glEnd() ; - } - - public void dispose( GLAutoDrawable drawable ) - { - } - } - - //////////////////////////////////////////////////////////////////////////// - private static class TestMouseListener implements com.jogamp.newt.event.MouseListener { private static final String NO_EVENT_DELIVERY = "no event delivery" ; @@ -152,34 +90,36 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _failures.add( NO_EVENT_DELIVERY ) ; } - private void _checkModifiers( com.jogamp.newt.event.MouseEvent event ) { + private void _checkModifiers( com.jogamp.newt.event.MouseEvent hasEvent ) { if( _debug ) { _debugPrintStream.print( " received NEWT " ) ; - _debugPrintStream.print( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ) ; + _debugPrintStream.print( com.jogamp.newt.event.MouseEvent.getEventTypeString( hasEvent.getEventType() ) ) ; } if( _modifierCheckEnabled ) { + final MouseEvent expEvent = new MouseEvent(hasEvent.getEventType(), hasEvent.getSource(), hasEvent.getWhen(), _expectedModifiers, + hasEvent.getX(), hasEvent.getY(), hasEvent.getClickCount(), hasEvent.getButton(), hasEvent.getWheelRotation()); + if( _debug ) { _debugPrintStream.println( ", checking modifiers..." ) ; _debugPrintStream.println( " expected NEWT Modifiers:" ) ; { - final MouseEvent exp = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, null, 0, _expectedModifiers, 0, 0, 1, 1, 0); - _debugPrintStream.println(" "+exp.getModifiersString(null).toString()); + _debugPrintStream.println(" "+expEvent.getModifiersString(null).toString()); } _debugPrintStream.println( " current NEWT Modifiers:" ) ; - _debugPrintStream.println(" "+event.getModifiersString(null).toString()); + _debugPrintStream.println(" "+hasEvent.getModifiersString(null).toString()); } - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.SHIFT_MASK ) ; - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.CTRL_MASK ) ; - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.META_MASK ) ; - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.ALT_MASK ) ; - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK ) ; + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.SHIFT_MASK, "shift" ) ; + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.CTRL_MASK, "ctrl" ) ; + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.META_MASK, "meta" ) ; + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.ALT_MASK, "alt" ) ; + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK, "graph" ) ; for( int n = 0 ; n < _numButtonsToTest ; ++n ) { - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.getButtonMask( n + 1 ) ) ; + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.getButtonMask( n + 1 ), "button"+(n+1) ) ; } } else { if( _debug ) { @@ -188,7 +128,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { } } - private void _checkModifierMask( com.jogamp.newt.event.MouseEvent event, int mask ) { + private void _checkModifierMask( com.jogamp.newt.event.MouseEvent expEvent, com.jogamp.newt.event.MouseEvent hasEvent, int mask, String maskS ) { // If the "no event delivery" failure is still in the list then // get rid of it since that obviously isn't true anymore. We @@ -199,15 +139,21 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _failures.clear() ; } - if( ( event.getModifiers() & mask ) != ( _expectedModifiers & mask ) ) { + if( ( hasEvent.getModifiers() & mask ) != ( expEvent.getModifiers() & mask ) ) { StringBuilder sb = new StringBuilder(); - sb.append( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ).append(": "); - final MouseEvent exp = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, null, 0, _expectedModifiers, 0, 0, 1, 1, 0); - sb.append("Expected:").append(Platform.NEWLINE); - exp.getModifiersString(sb).append(Platform.NEWLINE); - sb.append(", Have: ").append(Platform.NEWLINE); - event.getModifiersString(sb).append(Platform.NEWLINE); + sb.append( com.jogamp.newt.event.MouseEvent.getEventTypeString( hasEvent.getEventType() ) ).append(": mask ").append(maskS).append(" 0x").append(Integer.toHexString(mask)); + sb.append(", expected:"); + expEvent.getModifiersString(sb); + sb.append(", have: "); + hasEvent.getModifiersString(sb); _failures.add( sb.toString() ) ; + /** + System.err.println("*** MASK: 0x"+Integer.toHexString(mask)); + System.err.println("*** EXP: "+expEvent); + System.err.println("*** EXP: 0x"+Integer.toHexString(expEvent.getModifiers())); + System.err.println("*** HAS: "+hasEvent); + System.err.println("*** HAS: 0x"+Integer.toHexString(hasEvent.getModifiers())); + throw new RuntimeException(sb.toString()); */ } } @@ -290,7 +236,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { } @BeforeClass - public static void beforeClass() throws Exception { + public static void baseBeforeClass() throws Exception { // Who know how many buttons the AWT will say exist on given platform. // We'll test the smaller of what NEWT supports and what the @@ -342,7 +288,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// @Before - public void before() throws Exception { + public void baseBeforeTest() throws Exception { _testMouseListener.setModifierCheckEnabled( false ) ; _robot.setAutoDelay( MS_ROBOT_SHORT_AUTO_DELAY ) ; @@ -360,8 +306,8 @@ public abstract class BaseNewtEventModifiers extends UITestCase { } _robot.mouseMove( INITIAL_MOUSE_X, INITIAL_MOUSE_Y ) ; - _robot.mousePress( java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) ; - _robot.mouseRelease( java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) ; + _robot.mousePress( java.awt.event.InputEvent.BUTTON1_MASK ); // java7: java.awt.event.InputEvent.BUTTON1_DOWN_MASK + _robot.mouseRelease( java.awt.event.InputEvent.BUTTON1_MASK ) ; // java7: java.awt.event.InputEvent.BUTTON1_DOWN_MASK _testMouseListener.setModifierCheckEnabled( true ) ; _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; @@ -410,14 +356,14 @@ public abstract class BaseNewtEventModifiers extends UITestCase { // so it's probably best to leave them commented out. //@Test - //public void testSingleButtonPressAndReleaseWithMeta() throws Exception { - // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_META, java.awt.event.InputEvent.META_DOWN_MASK ) ; - //} + public void testSingleButtonPressAndReleaseWithMeta() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_META, java.awt.event.InputEvent.META_DOWN_MASK ) ; + } //@Test - //public void testSingleButtonPressAndReleaseWithAlt() throws Exception { - // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT, java.awt.event.InputEvent.ALT_DOWN_MASK ) ; - //} + public void testSingleButtonPressAndReleaseWithAlt() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT, java.awt.event.InputEvent.ALT_DOWN_MASK ) ; + } // FIXME - not sure yet what's up with ALT_GRAPH. It appears that this // modifier didn't make it through, so I had to disable this test else @@ -427,9 +373,9 @@ public abstract class BaseNewtEventModifiers extends UITestCase { // enough to not let this modifier slip through (?). //@Test - //public void testSingleButtonPressAndReleaseWithAltGraph() throws Exception { - // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH, java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) ; - //} + public void testSingleButtonPressAndReleaseWithAltGraph() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH, java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) ; + } //////////////////////////////////////////////////////////////////////////// @@ -466,7 +412,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _checkFailures() ; if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mouseRelease( awtButtonMask ) ; _checkFailures() ; } @@ -501,14 +447,14 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _checkFailures() ; if( _debug ) { _debugPrintStream.println( "\n releasing additional button " + ( m + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask | _awtButtonMasks[m] ) ) ; _robot.mouseRelease( _awtButtonMasks[m] ) ; _checkFailures() ; } } if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mouseRelease( awtButtonMask ) ; _checkFailures() ; } @@ -539,12 +485,12 @@ public abstract class BaseNewtEventModifiers extends UITestCase { for (int n = _numButtonsToTest - 1 ; n >= 0 ; --n) { - cumulativeAwtModifiers &= ~_awtButtonMasks[n] ; - if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | cumulativeAwtModifiers ) ) ; _robot.mouseRelease( _awtButtonMasks[n] ) ; _checkFailures() ; + + cumulativeAwtModifiers &= ~_awtButtonMasks[n] ; } } @@ -576,7 +522,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _checkFailures() ; if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mouseRelease( awtButtonMask ) ; _checkFailures() ; @@ -635,7 +581,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// @After - public void after() throws Exception { + public void baseAfterTest() throws Exception { _testMouseListener.setModifierCheckEnabled( false ) ; @@ -645,7 +591,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// @AfterClass - public static void afterClass() throws Exception { + public static void baseAfterClass() throws Exception { // Make sure all modifiers are released, otherwise the user's // desktop can get locked up (ask me how I know this). diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java index fd68ace73..725dbe97f 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java @@ -38,6 +38,7 @@ import org.junit.AfterClass ; import org.junit.BeforeClass ; import com.jogamp.newt.event.awt.AWTMouseAdapter ; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; /** * Test whether or not event modifiers are preserved by NEWT when @@ -53,10 +54,8 @@ public class TestNewtEventModifiersAWTCanvas extends BaseNewtEventModifiers { @BeforeClass public static void beforeClass() throws Exception { - BaseNewtEventModifiers.beforeClass() ; - final GLCanvas canvas = new GLCanvas() ; - canvas.addGLEventListener( new BigGreenXGLEventListener() ) ; + canvas.addGLEventListener( new RedSquareES2() ) ; new AWTMouseAdapter( _testMouseListener ).addTo( (java.awt.Component)canvas ) ; _testFrame = new JFrame( "Event Modifier Test AWTCanvas" ) ; @@ -76,8 +75,6 @@ public class TestNewtEventModifiersAWTCanvas extends BaseNewtEventModifiers { @AfterClass public static void afterClass() throws Exception { - BaseNewtEventModifiers.afterClass() ; - SwingUtilities.invokeAndWait(new Runnable() { public void run() { _testFrame.dispose() ; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNEWTWindowAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNEWTWindowAWT.java new file mode 100644 index 000000000..d6088e6a2 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNEWTWindowAWT.java @@ -0,0 +1,75 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.event; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.AfterClass ; +import org.junit.BeforeClass ; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; + +/** + * Test whether or not event modifiers are properly delivered by NEWT. + */ +public class TestNewtEventModifiersNEWTWindowAWT extends BaseNewtEventModifiers { + + private static GLWindow glWindow; + + //////////////////////////////////////////////////////////////////////////// + + @BeforeClass + public static void beforeClass() throws Exception { + glWindow = GLWindow.create( new GLCapabilities( GLProfile.getGL2ES2() ) ); + glWindow.setTitle("Event Modifier Test GLWindow"); + glWindow.addGLEventListener( new RedSquareES2() ) ; + glWindow.addMouseListener(_testMouseListener); + glWindow.setSize(TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT); + glWindow.setPosition(TEST_FRAME_X, TEST_FRAME_Y); + glWindow.setVisible(true); + } + + //////////////////////////////////////////////////////////////////////////// + + @AfterClass + public static void afterClass() throws Exception { + glWindow.destroy(); + } + + //////////////////////////////////////////////////////////////////////////// + + public static void main(String args[]) throws Exception { + String testName = TestNewtEventModifiersNEWTWindowAWT.class.getName() ; + org.junit.runner.JUnitCore.main( testName ) ; + } + + //////////////////////////////////////////////////////////////////////////// +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java index 44f116ea1..5590300c7 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java @@ -42,6 +42,7 @@ import org.junit.BeforeClass ; import com.jogamp.newt.awt.NewtCanvasAWT ; import com.jogamp.newt.opengl.GLWindow ; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; /** * Test whether or not event modifiers are preserved by NEWT when @@ -58,8 +59,6 @@ public class TestNewtEventModifiersNewtCanvasAWT extends BaseNewtEventModifiers @BeforeClass public static void beforeClass() throws Exception { - BaseNewtEventModifiers.beforeClass() ; - SwingUtilities.invokeAndWait( new Runnable() { public void run() { @@ -73,7 +72,7 @@ public class TestNewtEventModifiersNewtCanvasAWT extends BaseNewtEventModifiers NewtCanvasAWT canvas = new NewtCanvasAWT( _glWindow ) ; _testFrame.getContentPane().add( canvas, BorderLayout.CENTER ) ; - _glWindow.addGLEventListener( new BigGreenXGLEventListener() ) ; + _glWindow.addGLEventListener( new RedSquareES2() ) ; } _testFrame.setBounds( TEST_FRAME_X, TEST_FRAME_Y, TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT ) ; @@ -89,8 +88,6 @@ public class TestNewtEventModifiersNewtCanvasAWT extends BaseNewtEventModifiers @AfterClass public static void afterClass() throws Exception { - BaseNewtEventModifiers.afterClass() ; - SwingUtilities.invokeAndWait( new Runnable() { public void run() { _testFrame.dispose() ; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java index 501e0d1bd..c0d1690de 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java @@ -41,6 +41,7 @@ import org.junit.BeforeClass ; import com.jogamp.newt.opengl.GLWindow ; import com.jogamp.newt.swt.NewtCanvasSWT ; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; /** * Test whether or not event modifiers preserved by NEWT when @@ -87,8 +88,6 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers @BeforeClass public static void beforeClass() throws Exception { - BaseNewtEventModifiers.beforeClass() ; - _displayThread = new DisplayThread() ; _displayThread.start() ; @@ -111,7 +110,7 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers NewtCanvasSWT.create( _testShell, SWT.NO_BACKGROUND, _glWindow ) ; - _glWindow.addGLEventListener( new BigGreenXGLEventListener() ) ; + _glWindow.addGLEventListener( new RedSquareES2() ) ; } _testShell.setBounds( TEST_FRAME_X, TEST_FRAME_Y, TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT ) ; @@ -127,8 +126,6 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers @AfterClass public static void afterClass() throws Exception { - BaseNewtEventModifiers.afterClass() ; - _glWindow.destroy() ; _displayThread.getDisplay().syncExec( new Runnable() { -- cgit v1.2.3 From 17fde6c517b4ccf91b07c7e86974019bcbfee642 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Dec 2012 08:03:50 +0100 Subject: NEWT peserve 'mouseButtonModMask' to be sent for all mouse- and key events. TODO: NEWT Event Factories. Misc: Cleaned up spacing. On some native OS, the accumulation of pressed button modifier-mask is not available, e.g. OS X. NEWT WindowImpl.doMouseEvent(..), invoked by native NEWT events, will track the pressed mouse button modifier-mask, similar to mouseButtonPressed to synthesize the DRAGGED event. Added NEWT WindowImpl.doKeyEvent(..) to honor the pressed mouse button modifier-mask, i.e. pass it w/ key events as well. TODO: Unify synthesization of NEWT event artifacts as described by the above, allowing NEWT event translation to benefit from same code to gain same semantics. Notable: AWTNewtEventFactory and SWTNewtEventFactory --- src/newt/classes/jogamp/newt/WindowImpl.java | 73 ++++++++++++++++------------ 1 file changed, 43 insertions(+), 30 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index a9294c1ff..6e1059952 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -122,6 +122,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private ArrayList mouseListeners = new ArrayList(); private int mouseButtonPressed = 0; // current pressed mouse button number + private int mouseButtonModMask = 0; // current pressed mouse button modifier mask private long lastMousePressed = 0; // last time when a mouse button was pressed private int lastMouseClickCount = 0; // last mouse button click count private boolean mouseInWindow = false;// mouse entered window - is inside the window (may be synthetic) @@ -1983,9 +1984,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, int x, int y, int button, int rotation) { - if(eventType == MouseEvent.EVENT_MOUSE_ENTERED || - eventType == MouseEvent.EVENT_MOUSE_EXITED) { - if(eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1) { + if( eventType == MouseEvent.EVENT_MOUSE_ENTERED || eventType == MouseEvent.EVENT_MOUSE_EXITED ) { + if( eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1 ) { x = lastMousePosition.getX(); y = lastMousePosition.getY(); } @@ -1993,26 +1993,28 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer x = Math.min(Math.max(x, 0), getWidth()-1); y = Math.min(Math.max(y, 0), getHeight()-1); mouseInWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; - lastMousePressed=0; // clear state - mouseButtonPressed=0; // clear state + lastMousePressed = 0; // clear state + mouseButtonPressed = 0; // clear state + mouseButtonModMask = 0; // clear state } - if(x<0||y<0||x>=getWidth()||y>=getHeight()) { + if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { return; // .. invalid .. } if(DEBUG_MOUSE_EVENT) { System.err.println("doMouseEvent: enqueue "+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+ ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+lastMousePosition); } - long when = System.currentTimeMillis(); + final long when = System.currentTimeMillis(); MouseEvent eEntered = null; if(eventType == MouseEvent.EVENT_MOUSE_MOVED) { if(!mouseInWindow) { mouseInWindow = true; eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, this, when, modifiers, x, y, lastMouseClickCount, button, 0); - lastMousePressed=0; // clear state - mouseButtonPressed=0; // clear state - } else if(lastMousePosition.getX() == x && lastMousePosition.getY()==y) { + lastMousePressed = 0; // clear state + mouseButtonPressed = 0; // clear state + mouseButtonModMask = 0; // clear state + } else if( lastMousePosition.getX() == x && lastMousePosition.getY()==y ) { if(DEBUG_MOUSE_EVENT) { System.err.println("doMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+lastMousePosition); } @@ -2024,61 +2026,63 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( 0 > button || button > MouseEvent.BUTTON_NUMBER ) { throw new NativeWindowException("Invalid mouse button number" + button); } - // Fixes Bug 571: X11 behavior, where the PRESSED button is not included in the native mask. - modifiers |= InputEvent.getButtonMask(button); + modifiers |= InputEvent.getButtonMask(button); // Always add current button to modifier mask (Bug 571) + modifiers |= mouseButtonModMask; // Always add currently pressed mouse buttons to modifier mask MouseEvent eClicked = null; MouseEvent e = null; - if(isPointerConfined()) { + if( isPointerConfined() ) { modifiers |= InputEvent.CONFINED_MASK; } - if(!isPointerVisible()) { + if( !isPointerVisible() ) { modifiers |= InputEvent.INVISIBLE_MASK; } - if(MouseEvent.EVENT_MOUSE_PRESSED==eventType) { - if(when-lastMousePressed0) { + mouseButtonPressed = 0; + mouseButtonModMask &= ~MouseEvent.getButtonMask(button); + } else if( MouseEvent.EVENT_MOUSE_MOVED == eventType ) { + if ( mouseButtonPressed > 0 ) { e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, modifiers, x, y, 1, mouseButtonPressed, 0); } else { e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, 0); } - } else if(MouseEvent.EVENT_MOUSE_WHEEL_MOVED==eventType) { + } else if( MouseEvent.EVENT_MOUSE_WHEEL_MOVED == eventType ) { e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, rotation); } else { e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, 0); } - if(null!=eEntered) { + if( null != eEntered ) { if(DEBUG_MOUSE_EVENT) { System.err.println("doMouseEvent: synthesized MOUSE_ENTERED event: "+eEntered); } doEvent(enqueue, wait, eEntered); } doEvent(enqueue, wait, e); // actual mouse event - if(null!=eClicked) { + if( null != eClicked ) { if(DEBUG_MOUSE_EVENT) { System.err.println("doMouseEvent: synthesized MOUSE_CLICKED event: "+eClicked); } @@ -2197,11 +2201,20 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) ); + doKeyEvent(false, false, eventType, modifiers, keyCode, keyChar); } public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - enqueueEvent(wait, new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) ); + doKeyEvent(true, wait, eventType, modifiers, keyCode, keyChar); + } + + protected void doKeyEvent(boolean enqueue, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + modifiers |= mouseButtonModMask; // Always add currently pressed mouse buttons to modifier mask + if( enqueue ) { + enqueueEvent(wait, new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) ); + } else { + consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) ); + } } public void addKeyListener(KeyListener l) { -- cgit v1.2.3 From a35beb22d712b6da85a794115b19d484a12c8643 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Dec 2012 21:38:40 +0100 Subject: NEWT/Android: Fix NewtBaseActivity.getWindow() recursion if used w/o delegated Activity, i.e. our ActivityLauncher --- src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index 28c4da72f..c2379b648 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -59,8 +59,8 @@ public class NewtBaseActivity extends Activity { } public void setRootActivity(Activity rootActivity) { - this.isDelegatedActivity = true; this.rootActivity = rootActivity; + this.isDelegatedActivity = this != rootActivity; } public final boolean isDelegatedActivity() { @@ -231,7 +231,11 @@ public class NewtBaseActivity extends Activity { @Override public android.view.Window getWindow() { - return getActivity().getWindow(); + if( isDelegatedActivity() ) { + return getActivity().getWindow(); + } else { + return getWindow(); + } } @Override -- cgit v1.2.3 From 796ac5af822f74dd3534f3192f13c398bacd6f07 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 25 Dec 2012 08:27:16 +0100 Subject: NEWT/Android: Fix NewtBaseActivity.getWindow() recursion if used w/o delegated Activity, i.e. our ActivityLauncher (Completes commit a35beb22d712b6da85a794115b19d484a12c8643) --- src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index c2379b648..6bc81a555 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -234,7 +234,7 @@ public class NewtBaseActivity extends Activity { if( isDelegatedActivity() ) { return getActivity().getWindow(); } else { - return getWindow(); + return super.getWindow(); } } -- cgit v1.2.3 From 224fab1b2c71464826594740022fdcbe278867dc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 11 Jan 2013 08:13:24 +0100 Subject: GLAutoDrawable/AnimatorBase: Add ExclusiveContextThread (ECT) feature; AnimatorBase: Add setModeBits/MODE_EXPECT_AWT_RENDERING_THREAD; FPSAnimator: Make transactions deterministic. ExclusiveContextThread (ECT) allows user to dedicate a GLContext to a given thread. Only the ECT will be allowed to claim the GLContext, hence releasing must be done on the ECT itself. The core feature is accessible via GLAutoDrawable, while it can be conveniently enabled and disabled via an AnimatorBase implementation. The latter ensures it's being released on the ECT and waits for the result. Note that ECT cannot be guaranteed to work correctly w/ native (heavyweight) AWT components due to resource locking and AWT-EDT access. This is disabled in all new tests per default and noted on the API doc. Note: 'Animator transaction' == start(), stop(), pause(), resume(). - Add ExclusiveContextThread (ECT) feature - GLAutoDrawable NEW: - Thread setExclusiveContextThread(Thread t) - Thread getExclusiveContextThread() - AnimatorBase NEW: - Thread setExclusiveContext(Thread t) - boolean setExclusiveContext(boolean enable) - boolean isExclusiveContextEnabled() - Thread getExclusiveContextThread() - AnimatorBase: Add setModeBits/MODE_EXPECT_AWT_RENDERING_THREAD Allows user to pre-determine whether AWT rendering is expected before starting the animator. If AWT is excluded, a more simple and transaction correct impl. will be used. - FPSAnimator: Make transactions deterministic. FPSAnimator previously did not ensure whether a transaction was completed. A deterministic transaction is required to utilize ECT. FPSAnimator now uses same mechanism like Animator to ensure completeness, i.e. Condition and 'finishLifecycleAction(..)'. Both are moved to AnimatorBase. Tested manually on Linux/NV, Linux/AMD, Windows/NV and OSX/NV. - All new tests validated correctness. - All new tests shows an performance increase of ~3x w/ single GLWindow, where multiple GLWindows don't show a perf. increase. --- make/scripts/tests-x64.bat | 40 +- make/scripts/tests.sh | 15 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 10 + .../classes/com/jogamp/opengl/util/Animator.java | 187 ++++----- .../com/jogamp/opengl/util/AnimatorBase.java | 458 ++++++++++++++++++--- .../com/jogamp/opengl/util/FPSAnimator.java | 307 ++++++++++---- .../javax/media/opengl/GLAnimatorControl.java | 21 +- .../classes/javax/media/opengl/GLAutoDrawable.java | 45 +- src/jogl/classes/javax/media/opengl/GLContext.java | 8 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 10 + .../classes/javax/media/opengl/awt/GLJPanel.java | 10 + .../classes/jogamp/opengl/GLAutoDrawableBase.java | 30 +- .../classes/jogamp/opengl/GLDrawableHelper.java | 421 ++++++++++++------- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 5 +- .../junit/jogl/acore/ExclusiveContextBase00.java | 420 +++++++++++++++++++ .../jogl/acore/ExclusiveContextBase00AWT.java | 161 ++++++++ .../jogl/acore/ExclusiveContextBase00NEWT.java | 94 +++++ .../junit/jogl/acore/ExclusiveContextBase10.java | 213 ++++++++++ .../jogl/acore/ExclusiveContextBase10AWT.java | 161 ++++++++ .../jogl/acore/ExclusiveContextBase10NEWT.java | 94 +++++ .../junit/jogl/acore/InitConcurrentBaseNEWT.java | 2 +- .../acore/TestExclusiveContext01VSyncAnimAWT.java | 70 ++++ .../acore/TestExclusiveContext01VSyncAnimNEWT.java | 67 +++ .../acore/TestExclusiveContext02FPSAnimAWT.java | 70 ++++ .../acore/TestExclusiveContext02FPSAnimNEWT.java | 67 +++ .../acore/TestExclusiveContext11VSyncAnimNEWT.java | 66 +++ .../acore/TestExclusiveContext12FPSAnimNEWT.java | 67 +++ .../jogl/demos/es1/newt/TestGearsES1NEWT.java | 9 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 87 ++-- .../test/junit/jogl/demos/es2/RedSquareES2.java | 24 +- .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 28 +- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 40 +- 32 files changed, 2815 insertions(+), 492 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase10.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase10AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase10NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext02FPSAnimAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext02FPSAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext11VSyncAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext12FPSAnimNEWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 63a8d57f7..8367228b5 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -13,6 +13,27 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimAWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimAWT %* +scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext11VSyncAnimNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext12FPSAnimNEWT %* + +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* @@ -94,7 +115,7 @@ REM scripts\java-win64-dbg.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps. REM scripts\java-win64-dbg.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT %* REM scripts\java-win64-dbg.bat testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT @@ -122,23 +143,6 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtD REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %* - -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* - -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index f253ed1e2..395546ab9 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -104,6 +104,7 @@ function jrun() { #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLDrawable" @@ -169,7 +170,6 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" - #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" @@ -283,6 +283,14 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimAWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext11VSyncAnimNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext12FPSAnimNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -292,7 +300,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* @@ -302,12 +309,12 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* @@ -455,7 +462,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02AWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 4ba4def9a..80e1aa80d 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -648,6 +648,16 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { return helper.getAnimator(); } + @Override + public final Thread setExclusiveContextThread(Thread t) throws GLException { + return helper.setExclusiveContextThread(t, context); + } + + @Override + public final Thread getExclusiveContextThread() { + return helper.getExclusiveContextThread(); + } + @Override public boolean getAutoSwapBufferMode() { return helper.getAutoSwapBufferMode(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index ddbc66fa3..10f43a0c1 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -41,7 +41,7 @@ package com.jogamp.opengl.util; import javax.media.opengl.GLAutoDrawable; - +import javax.media.opengl.GLException; /**

    An Animator can be attached to one or more {@link GLAutoDrawable}s to drive their display() methods in a loop.

    @@ -57,10 +57,7 @@ import javax.media.opengl.GLAutoDrawable; * Call {@link #stop() } to terminate the animation and it's execution thread. *

    */ -public class Animator extends AnimatorBase { - /** timeout in milliseconds, 15 frames @ 60Hz = 240ms, limiting {@link #finishLifecycleAction(Condition)} */ - private static final long TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION = 15*16; - +public class Animator extends AnimatorBase { protected ThreadGroup threadGroup; private Runnable runnable; private boolean runAsFastAsPossible; @@ -68,6 +65,9 @@ public class Animator extends AnimatorBase { protected boolean pauseIssued; protected volatile boolean stopIssued; + /** + * Creates a new, empty Animator. + */ public Animator() { super(); if(DEBUG) { @@ -75,25 +75,38 @@ public class Animator extends AnimatorBase { } } + /** + * Creates a new Animator w/ an associated ThreadGroup. + */ public Animator(ThreadGroup tg) { super(); - threadGroup = tg; - + setThreadGroup(tg); if(DEBUG) { System.err.println("Animator created, ThreadGroup: "+threadGroup); } } - /** Creates a new Animator for a particular drawable. */ + /** + * Creates a new Animator for a particular drawable. + */ public Animator(GLAutoDrawable drawable) { super(); add(drawable); + if(DEBUG) { + System.err.println("Animator created, w/ "+drawable); + } } - /** Creates a new Animator for a particular drawable. */ + /** + * Creates a new Animator w/ an associated ThreadGroup for a particular drawable. + */ public Animator(ThreadGroup tg, GLAutoDrawable drawable) { - this(tg); + super(); + setThreadGroup(tg); add(drawable); + if(DEBUG) { + System.err.println("Animator created, ThreadGroup: "+threadGroup+" and "+drawable); + } } protected String getBaseName(String prefix) { @@ -114,7 +127,7 @@ public class Animator extends AnimatorBase { stateSync.unlock(); } } - + private final void setIsAnimatingSynced(boolean v) { stateSync.lock(); try { @@ -126,36 +139,39 @@ public class Animator extends AnimatorBase { class MainLoop implements Runnable { public String toString() { - return "[started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+"]"; + return "[started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]"; } public void run() { try { - synchronized (Animator.this) { - if(DEBUG) { - System.err.println("Animator start:" + Thread.currentThread() + ": " + toString()); - } - fpsCounter.resetFPSCounter(); - animThread = Thread.currentThread(); - setIsAnimatingSynced(false); // barrier - Animator.this.notifyAll(); + if(DEBUG) { + System.err.println("Animator start:" + Thread.currentThread() + ": " + toString()); } + fpsCounter.resetFPSCounter(); + animThread = Thread.currentThread(); + setIsAnimatingSynced(false); // barrier + // 'waitForStartedCondition' wake-up is handled below! while (!stopIssued) { synchronized (Animator.this) { - // Don't consume CPU unless there is work to be done and not paused + // Pause; Also don't consume CPU unless there is work to be done and not paused + boolean ectCleared = false; while (!stopIssued && (pauseIssued || drawablesEmpty)) { boolean wasPaused = pauseIssued; if (DEBUG) { System.err.println("Animator pause:" + Thread.currentThread() + ": " + toString()); } + if ( exclusiveContext && !drawablesEmpty && !ectCleared ) { + ectCleared = true; + setDrawablesExclCtxState(false); + display(); // propagate exclusive change! + } setIsAnimatingSynced(false); // barrier Animator.this.notifyAll(); try { Animator.this.wait(); } catch (InterruptedException e) { } - if (wasPaused) { // resume from pause -> reset counter fpsCounter.resetFPSCounter(); @@ -165,9 +181,12 @@ public class Animator extends AnimatorBase { } } if (!stopIssued && !isAnimating) { - // resume from pause or drawablesEmpty, + // Wakes up 'waitForStartedCondition' sync + // - and - + // Resume from pause or drawablesEmpty, // implies !pauseIssued and !drawablesEmpty - setIsAnimatingSynced(true); + setIsAnimatingSynced(true); // barrier + setDrawablesExclCtxState(exclusiveContext); Animator.this.notifyAll(); } } // sync Animator.this @@ -180,6 +199,10 @@ public class Animator extends AnimatorBase { } } } finally { + if( exclusiveContext && !drawablesEmpty ) { + setDrawablesExclCtxState(false); + display(); // propagate exclusive change! + } synchronized (Animator.this) { if(DEBUG) { System.err.println("Animator stop " + Thread.currentThread() + ": " + toString()); @@ -194,18 +217,6 @@ public class Animator extends AnimatorBase { } } - private final boolean isStartedImpl() { - return animThread != null ; - } - public final boolean isStarted() { - stateSync.lock(); - try { - return animThread != null ; - } finally { - stateSync.unlock(); - } - } - private final boolean isAnimatingImpl() { return animThread != null && isAnimating ; } @@ -230,39 +241,19 @@ public class Animator extends AnimatorBase { } } - interface Condition { - /** - * @return true if branching (cont waiting, action), otherwise false - */ - boolean result(); - } - - private synchronized void finishLifecycleAction(Condition condition) { - // It's hard to tell whether the thread which changes the lifecycle has - // dependencies on the Animator's internal thread. Currently we - // use a couple of heuristics to determine whether we should do - // the blocking wait(). - final boolean blocking = impl.blockUntilDone(animThread); - long remaining = blocking ? TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION : 0; - while (remaining>0 && condition.result()) { - long td = System.currentTimeMillis(); - try { - wait(remaining); - } catch (InterruptedException ie) { } - remaining -= (System.currentTimeMillis() - td) ; - } - if(DEBUG) { - if(remaining<0) { - System.err.println("finishLifecycleAction(" + condition.getClass().getName() + "): ++++++ timeout reached ++++++ " + Thread.currentThread().getName()); - } - System.err.println("finishLifecycleAction(" + condition.getClass().getName() + "): finished "+ - "- blocking "+blocking+ - ", waited " + (blocking ? ( TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION - remaining ) : 0 ) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION + - ", started: " + isStartedImpl() +", animating: " + isAnimatingImpl() + - ", paused: " + isPausedImpl() + ", drawables " + drawables.size() + " - " + Thread.currentThread().getName()); + /** + * Set a {@link ThreadGroup} for the {@link #getThread() animation thread}. + * + * @param tg the {@link ThreadGroup} + * @throws GLException if the animator has already been started + */ + public synchronized void setThreadGroup(ThreadGroup tg) throws GLException { + if ( isStartedImpl() ) { + throw new GLException("Animator already started."); } + threadGroup = tg; } - + public synchronized boolean start() { if ( isStartedImpl() ) { return false; @@ -284,74 +275,48 @@ public class Animator extends AnimatorBase { System.err.println("Animator "+ct.getName()+"[daemon "+ct.isDaemon()+"]: starting "+thread.getName()+"[daemon "+thread.isDaemon()+"]"); } thread.start(); - finishLifecycleAction(waitForStartedCondition); - return true; + return finishLifecycleAction(waitForStartedCondition, 0); } - - private class WaitForStartedCondition implements Condition { - public boolean result() { + private final Condition waitForStartedCondition = new Condition() { + public boolean eval() { return !isStartedImpl() || (!drawablesEmpty && !isAnimating) ; - } - } - Condition waitForStartedCondition = new WaitForStartedCondition(); + } }; public synchronized boolean stop() { if ( !isStartedImpl() ) { return false; } stopIssued = true; - notifyAll(); - finishLifecycleAction(waitForStoppedCondition); - return true; + return finishLifecycleAction(waitForStoppedCondition, 0); } - private class WaitForStoppedCondition implements Condition { - public boolean result() { + private final Condition waitForStoppedCondition = new Condition() { + public boolean eval() { return isStartedImpl(); - } - } - Condition waitForStoppedCondition = new WaitForStoppedCondition(); + } }; public synchronized boolean pause() { if ( !isStartedImpl() || pauseIssued ) { return false; } - stateSync.lock(); - try { - pauseIssued = true; - } finally { - stateSync.unlock(); - } - notifyAll(); - finishLifecycleAction(waitForPausedCondition); - return true; + pauseIssued = true; + return finishLifecycleAction(waitForPausedCondition, 0); } - private class WaitForPausedCondition implements Condition { - public boolean result() { + private final Condition waitForPausedCondition = new Condition() { + public boolean eval() { // end waiting if stopped as well return isAnimating && isStartedImpl(); - } - } - Condition waitForPausedCondition = new WaitForPausedCondition(); + } }; public synchronized boolean resume() { if ( !isStartedImpl() || !pauseIssued ) { return false; } - stateSync.lock(); - try { - pauseIssued = false; - } finally { - stateSync.unlock(); - } - notifyAll(); - finishLifecycleAction(waitForResumeCondition); - return true; + pauseIssued = false; + return finishLifecycleAction(waitForResumeCondition, 0); } - private class WaitForResumeCondition implements Condition { - public boolean result() { + private final Condition waitForResumeCondition = new Condition() { + public boolean eval() { // end waiting if stopped as well return !drawablesEmpty && !isAnimating && isStartedImpl(); - } - } - Condition waitForResumeCondition = new WaitForResumeCondition(); + } }; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index 46fc1d991..bda716e97 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -38,6 +38,7 @@ import java.util.ArrayList; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; /** @@ -51,69 +52,174 @@ import javax.media.opengl.GLProfile; */ public abstract class AnimatorBase implements GLAnimatorControl { protected static final boolean DEBUG = Debug.debug("Animator"); - - private static int animatorCount = 0; - + + /** A 1s timeout while waiting for a native action response, limiting {@link #finishLifecycleAction(Condition, long)} */ + protected static final long TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION = 1000; + + protected static final long POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION = 32; // 2 frames @ 60Hz + + /** + * If present in modeBits field and + * {@link GLProfile#isAWTAvailable() AWT is available}, + * implementation is aware of the AWT EDT, otherwise not. + *

    + * This is the default. + *

    + * @see #setModeBits(boolean, int) + */ + public static final int MODE_EXPECT_AWT_RENDERING_THREAD = 1 << 0; + public interface AnimatorImpl { void display(ArrayList drawables, boolean ignoreExceptions, boolean printExceptions); boolean blockUntilDone(Thread thread); } - protected ArrayList drawables = new ArrayList(); - protected boolean drawablesEmpty; + protected int modeBits; protected AnimatorImpl impl; protected String baseName; + + protected ArrayList drawables = new ArrayList(); + protected boolean drawablesEmpty; protected Thread animThread; protected boolean ignoreExceptions; protected boolean printExceptions; + protected boolean exclusiveContext; + protected Thread userExclusiveContextThread; protected FPSCounterImpl fpsCounter = new FPSCounterImpl(); protected RecursiveLock stateSync = LockFactory.createRecursiveLock(); - - /** Creates a new, empty Animator. */ - public AnimatorBase() { - if(GLProfile.isAWTAvailable()) { + + private final static Class awtAnimatorImplClazz; + static { + GLProfile.initSingleton(); + if( GLProfile.isAWTAvailable() ) { + Class clazz; try { - impl = (AnimatorImpl) Class.forName("com.jogamp.opengl.util.AWTAnimatorImpl").newInstance(); - baseName = "AWTAnimator"; - } catch (Exception e) { e.printStackTrace(); } - } - if(null==impl) { - impl = new DefaultAnimatorImpl(); - baseName = "Animator"; - } - synchronized (Animator.class) { - animatorCount++; - baseName = baseName.concat("-"+animatorCount); - drawablesEmpty = true; + clazz = Class.forName("com.jogamp.opengl.util.AWTAnimatorImpl"); + } catch (Exception e) { + clazz = null; + } + awtAnimatorImplClazz = clazz; + } else { + awtAnimatorImplClazz = null; } } + /** + * Creates a new, empty Animator instance + * while expecting an AWT rendering thread if AWT is available. + * + * @see GLProfile#isAWTAvailable() + */ + public AnimatorBase() { + modeBits = MODE_EXPECT_AWT_RENDERING_THREAD; // default! + drawablesEmpty = true; + } + + /** + * Initializes implementation details post setup, + * invoked at {@link #add(GLAutoDrawable)}, {@link #start()}, .. + *

    + * Operation is a NOP if force is false + * and this instance is already initialized. + *

    + * + * @throws GLException if Animator is {@link #isStarted()} + */ + protected void initImpl(boolean force) { + if( force || null == impl ) { + if( 0 != ( MODE_EXPECT_AWT_RENDERING_THREAD & modeBits ) && null != awtAnimatorImplClazz ) { + try { + impl = (AnimatorImpl) awtAnimatorImplClazz.newInstance(); + baseName = getBaseName("AWT"); + } catch (Exception e) { e.printStackTrace(); } + } + if( null == impl ) { + impl = new DefaultAnimatorImpl(); + baseName = getBaseName(""); + } + if(DEBUG) { + System.err.println("Animator.initImpl: baseName "+baseName+", implClazz "+impl.getClass().getName()+" - "+toString()+" - "+Thread.currentThread().getName()); + } + } + } protected abstract String getBaseName(String prefix); - public synchronized void add(GLAutoDrawable drawable) { + /** + * Enables or disables the given bitValues + * in this Animators modeBits. + * @param enable + * @param bitValues + * + * @throws GLException if Animator is {@link #isStarted()} + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + */ + public synchronized void setModeBits(boolean enable, int bitValues) throws GLException { + if( isStarted() ) { + throw new GLException("Animator already started"); + } + final int _oldModeBits = modeBits; + if(enable) { + modeBits |= bitValues; + } else { + modeBits &= ~bitValues; + } + if( _oldModeBits != modeBits ) { + initImpl(true); + } + } + public synchronized int getModeBits() { return modeBits; } + + + @Override + public synchronized void add(final GLAutoDrawable drawable) { if(DEBUG) { - System.err.println("Animator add: "+drawable.hashCode()+" - "+Thread.currentThread().getName()); + System.err.println("Animator add: 0x"+Integer.toHexString(drawable.hashCode())+" - "+toString()+" - "+Thread.currentThread().getName()); } + if( drawables.contains(drawable) ) { + throw new IllegalArgumentException("Drawable already added to animator: "+this+", "+drawable); + } + initImpl(false); boolean paused = pause(); + if( isStarted() ) { + drawable.setExclusiveContextThread( exclusiveContext ? getExclusiveContextThread() : null ); // if already running .. + } drawables.add(drawable); drawablesEmpty = drawables.size() == 0; drawable.setAnimator(this); if(paused) { resume(); } - if(impl.blockUntilDone(animThread)) { - while(isStarted() && !isPaused() && !isAnimating()) { - try { - wait(); - } catch (InterruptedException ie) { } - } + final Condition waitForAnimatingAndECTCondition = new Condition() { + public boolean eval() { + final Thread dect = drawable.getExclusiveContextThread(); + return isStarted() && !isPaused() && !isAnimating() && ( exclusiveContext && null == dect || !exclusiveContext && null != dect ); + } }; + final boolean res = finishLifecycleAction(waitForAnimatingAndECTCondition, 0); + if(DEBUG) { + System.err.println("Animator add: Wait for Animating/ECT OK: "+res+", "+toString()+", dect "+drawable.getExclusiveContextThread()); } notifyAll(); } - public synchronized void remove(GLAutoDrawable drawable) { + @Override + public synchronized void remove(final GLAutoDrawable drawable) { if(DEBUG) { - System.err.println("Animator remove: "+drawable.hashCode()+" - "+Thread.currentThread().getName() + ": "+toString()); + System.err.println("Animator remove: 0x"+Integer.toHexString(drawable.hashCode())+" - "+toString()+" - "+Thread.currentThread().getName()); + } + if( !drawables.contains(drawable) ) { + throw new IllegalArgumentException("Drawable not added to animator: "+this+", "+drawable); + } + + if( exclusiveContext && isAnimating() ) { + drawable.setExclusiveContextThread( null ); + final Condition waitForNullECTCondition = new Condition() { + public boolean eval() { + return null != drawable.getExclusiveContextThread(); + } }; + final boolean res = finishLifecycleAction(waitForNullECTCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); + if(DEBUG) { + System.err.println("Animator remove: Wait for Null-ECT OK: "+res+", "+toString()+", dect "+drawable.getExclusiveContextThread()); + } } boolean paused = pause(); @@ -123,14 +229,202 @@ public abstract class AnimatorBase implements GLAnimatorControl { if(paused) { resume(); } - if(impl.blockUntilDone(animThread)) { - while(isStarted() && drawablesEmpty && isAnimating()) { + final boolean res = finishLifecycleAction(waitForNotAnimatingIfEmptyCondition, 0); + if(DEBUG) { + System.err.println("Animator remove: Wait for !Animating-if-empty OK: "+res+", "+toString()); + } + notifyAll(); + } + private final Condition waitForNotAnimatingIfEmptyCondition = new Condition() { + public boolean eval() { + return isStarted() && drawablesEmpty && isAnimating(); + } }; + + + /** + * Dedicate all {@link GLAutoDrawable}'s context to the given exclusive context thread. + *

    + * The given thread will be exclusive to all {@link GLAutoDrawable}'s context while {@link #isAnimating()}. + *

    + *

    + * If already started and disabling, method waits + * until change is propagated to all {@link GLAutoDrawable} if not + * called from the animator thread or {@link #getExclusiveContextThread() exclusive context thread}. + *

    + *

    + * Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation. + * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas. + *

    + * + * @param enable + * @return previous value + * @see #setExclusiveContext(boolean) + * @see #getExclusiveContextThread() + * @see #isExclusiveContextEnabled() + */ + // @Override + public final Thread setExclusiveContext(Thread t) { + final Thread old; + final boolean enable = null != t; + stateSync.lock(); + try { + old = userExclusiveContextThread; + if( enable && t != animThread ) { // disable: will be cleared at end after propagation && filter out own animThread usae + userExclusiveContextThread=t; + } + } finally { + stateSync.unlock(); + } + setExclusiveContext(enable); + return old; + } + + /** + * Dedicate all {@link GLAutoDrawable}'s context to this animator thread. + *

    + * The given thread will be exclusive to all {@link GLAutoDrawable}'s context while {@link #isAnimating()}. + *

    + *

    + * If already started and disabling, method waits + * until change is propagated to all {@link GLAutoDrawable} if not + * called from the animator thread or {@link #getExclusiveContextThread() exclusive context thread}. + *

    + *

    + * Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation. + * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas. + *

    + * + * @param enable + * @return previous value + * @see #setExclusiveContext(Thread) + * @see #getExclusiveContextThread() + * @see #isExclusiveContextEnabled() + */ + // @Override + public final boolean setExclusiveContext(boolean enable) { + final boolean propagateState; + final boolean oldExclusiveContext; + final Thread _exclusiveContextThread; + synchronized (AnimatorBase.this) { + propagateState = isStarted() && !drawablesEmpty; + _exclusiveContextThread = userExclusiveContextThread; + oldExclusiveContext = exclusiveContext; + exclusiveContext = enable; + if(DEBUG) { + System.err.println("AnimatorBase.setExclusiveContextThread: "+oldExclusiveContext+" -> "+exclusiveContext+", propagateState "+propagateState+", "+this); + } + } + final Thread dECT = enable ? ( null != userExclusiveContextThread ? userExclusiveContextThread : animThread ) : null ; + if( propagateState ) { + setDrawablesExclCtxState(enable); + if( !enable ) { + if( Thread.currentThread() == getThread() || Thread.currentThread() == _exclusiveContextThread ) { + display(); + } else { + final boolean resumed = isAnimating() ? false : resume(); + int counter = 10; + while( 0true, if the exclusive context thread is enabled, otherwise false. + * + * @see #setExclusiveContext(boolean) + * @see #setExclusiveContext(Thread) + */ + // @Override + public final boolean isExclusiveContextEnabled() { + stateSync.lock(); + try { + return exclusiveContext; + } finally { + stateSync.unlock(); + } + } + + /** + * Returns the exclusive context thread if {@link #isExclusiveContextEnabled()} and {@link #isStarted()}, otherwise null. + *

    + * If exclusive context is enabled via {@link #setExclusiveContext(boolean)} + * the {@link #getThread() animator thread} is returned if above conditions are met. + *

    + *

    + * If exclusive context is enabled via {@link #setExclusiveContext(Thread)} + * the user passed thread is returned if above conditions are met. + *

    + * @see #setExclusiveContext(boolean) + * @see #setExclusiveContext(Thread) + */ + // @Override + public final Thread getExclusiveContextThread() { + stateSync.lock(); + try { + return ( isStartedImpl() && exclusiveContext ) ? ( null != userExclusiveContextThread ? userExclusiveContextThread : animThread ) : null ; + } finally { + stateSync.unlock(); + } + } + + /** + * Should be called at {@link #start()} and {@link #stop()} + * from within the animator thread. + *

    + * At {@link #stop()} an additional {@link #display()} call shall be issued + * to allow propagation of releasing the exclusive thread. + *

    + */ + protected final synchronized void setDrawablesExclCtxState(boolean enable) { + if(DEBUG) { + System.err.println("AnimatorBase.setExclusiveContextImpl exlusive "+exclusiveContext+": Enable "+enable+" for "+this+" - "+Thread.currentThread()); + // Thread.dumpStack(); + } + final Thread ect = getExclusiveContextThread(); + for (int i=0; ifalse. + * @param pollPeriod if 0, method will wait until TO is reached or being notified. + * if > 0, method will wait for the given pollPeriod in milliseconds. + * @return true if {@link Condition#eval() waitCondition.eval()} returned false, otherwise false. + */ + protected synchronized boolean finishLifecycleAction(Condition waitCondition, long pollPeriod) { + // It's hard to tell whether the thread which changes the lifecycle has + // dependencies on the Animator's internal thread. Currently we + // use a couple of heuristics to determine whether we should do + // the blocking wait(). + initImpl(false); + final boolean blocking = impl.blockUntilDone(animThread); + long remaining = blocking ? TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION : 0; + if( 0 >= pollPeriod ) { + pollPeriod = remaining; + } + boolean nok = waitCondition.eval(); + while ( nok && remaining>0 ) { + final long t1 = System.currentTimeMillis(); + if( pollPeriod > remaining ) { pollPeriod = remaining; } + notifyAll(); + try { + wait(pollPeriod); + } catch (InterruptedException ie) { } + remaining -= System.currentTimeMillis() - t1 ; + nok = waitCondition.eval(); + } + if(DEBUG || nok) { + if( remaining<=0 && nok ) { + System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): ++++++ timeout reached ++++++ " + Thread.currentThread().getName()); + } + stateSync.lock(); // avoid too many lock/unlock ops + try { + System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): OK "+(!nok)+ + "- pollPeriod "+pollPeriod+", blocking "+blocking+ + ", waited " + (blocking ? ( TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION - remaining ) : 0 ) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION + + " - " + Thread.currentThread().getName()); + System.err.println(" - "+toString()); + } finally { + stateSync.unlock(); + } + if(nok) { + Thread.dumpStack(); + } + } + return !nok; + } + + protected final boolean isStartedImpl() { + return animThread != null ; + } + @Override + public boolean isStarted() { + stateSync.lock(); + try { + return animThread != null ; + } finally { + stateSync.unlock(); + } + } + public String toString() { - return getClass().getName()+"[started "+isStarted()+", animating "+isAnimating()+", paused "+isPaused()+", drawable "+drawables.size()+", totals[dt "+getTotalFPSDuration()+", frames "+getTotalFPSFrames()+", fps "+getTotalFPS()+"]]"; + return getClass().getName()+"[started "+isStarted()+", animating "+isAnimating()+", paused "+isPaused()+", drawable "+drawables.size()+ + ", totals[dt "+getTotalFPSDuration()+", frames "+getTotalFPSFrames()+", fps "+getTotalFPS()+ + "], modeBits "+modeBits+", init'ed "+(null!=impl)+", animThread "+getThread()+", exclCtxThread "+exclusiveContext+"("+getExclusiveContextThread()+")]"; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java index 251792110..bfcab23fd 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java @@ -39,8 +39,11 @@ */ package com.jogamp.opengl.util; -import java.util.*; -import javax.media.opengl.*; +import java.util.Timer; +import java.util.TimerTask; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLException; /** * An Animator subclass which attempts to achieve a target @@ -54,10 +57,12 @@ import javax.media.opengl.*; */ public class FPSAnimator extends AnimatorBase { private Timer timer = null; - private TimerTask task = null; + private MainTask task = null; private int fps; private boolean scheduleAtFixedRate; - private volatile boolean shouldRun; + private boolean isAnimating; // MainTask feedback + private volatile boolean shouldRun; // MainTask trigger + private volatile boolean shouldStop; // MainTask trigger protected String getBaseName(String prefix) { return "FPS" + prefix + "Animator" ; @@ -88,6 +93,7 @@ public class FPSAnimator extends AnimatorBase { value, an initial drawable to animate, and a flag indicating whether to use fixed-rate scheduling. */ public FPSAnimator(GLAutoDrawable drawable, int fps, boolean scheduleAtFixedRate) { + super(); this.fps = fps; if (drawable != null) { add(drawable); @@ -95,133 +101,260 @@ public class FPSAnimator extends AnimatorBase { this.scheduleAtFixedRate = scheduleAtFixedRate; } - public final boolean isStarted() { - stateSync.lock(); - try { - return (timer != null); - } finally { - stateSync.unlock(); + /** + * @param fps + * @throws GLException if the animator has already been started + */ + public final synchronized void setFPS(int fps) throws GLException { + if ( isStartedImpl() ) { + throw new GLException("Animator already started."); } + this.fps = fps; } + public final int getFPS() { return fps; } + + class MainTask extends TimerTask { + private boolean justStarted; + private boolean alreadyStopped; + private boolean alreadyPaused; + + public MainTask() { + } + + public void start(Timer timer) { + fpsCounter.resetFPSCounter(); + shouldRun = true; + shouldStop = false; + + justStarted = true; + alreadyStopped = false; + alreadyPaused = false; + final long period = 0 < fps ? (long) (1000.0f / (float) fps) : 1; // 0 -> 1: IllegalArgumentException: Non-positive period + if (scheduleAtFixedRate) { + timer.scheduleAtFixedRate(this, 0, period); + } else { + timer.schedule(this, 0, period); + } + } + + public boolean isActive() { return !alreadyStopped && !alreadyPaused; } + + public String toString() { + return "Task[thread "+animThread+", stopped "+alreadyStopped+", paused "+alreadyPaused+" shouldRun "+shouldRun+", shouldStop "+shouldStop+" -- started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]"; + } + + public void run() { + if( justStarted ) { + justStarted = false; + synchronized (FPSAnimator.this) { + animThread = Thread.currentThread(); + if(DEBUG) { + System.err.println("FPSAnimator start/resume:" + Thread.currentThread() + ": " + toString()); + } + isAnimating = true; + if( drawablesEmpty ) { + shouldRun = false; // isAnimating:=false @ pause below + } else { + shouldRun = true; + setDrawablesExclCtxState(exclusiveContext); + FPSAnimator.this.notifyAll(); + } + System.err.println("FPSAnimator P1:" + Thread.currentThread() + ": " + toString()); + } + } + if( shouldRun ) { + display(); + } else if( shouldStop ) { // STOP + System.err.println("FPSAnimator P4: "+alreadyStopped+", "+ Thread.currentThread() + ": " + toString()); + this.cancel(); + + if( !alreadyStopped ) { + alreadyStopped = true; + if( exclusiveContext && !drawablesEmpty ) { + setDrawablesExclCtxState(false); + display(); // propagate exclusive change! + } + synchronized (FPSAnimator.this) { + if(DEBUG) { + System.err.println("FPSAnimator stop " + Thread.currentThread() + ": " + toString()); + } + animThread = null; + isAnimating = false; + FPSAnimator.this.notifyAll(); + } + } + } else { + System.err.println("FPSAnimator P5: "+alreadyPaused+", "+ Thread.currentThread() + ": " + toString()); + this.cancel(); + + if( !alreadyPaused ) { // PAUSE + alreadyPaused = true; + if( exclusiveContext && !drawablesEmpty ) { + setDrawablesExclCtxState(false); + display(); // propagate exclusive change! + } + synchronized (FPSAnimator.this) { + if(DEBUG) { + System.err.println("FPSAnimator pause " + Thread.currentThread() + ": " + toString()); + } + isAnimating = false; + FPSAnimator.this.notifyAll(); + } + } + } + } + } + private final boolean isAnimatingImpl() { + return animThread != null && isAnimating ; + } public final boolean isAnimating() { stateSync.lock(); try { - return (timer != null) && (task != null); + return animThread != null && isAnimating ; } finally { stateSync.unlock(); } } + private final boolean isPausedImpl() { + return animThread != null && ( !shouldRun && !shouldStop ) ; + } public final boolean isPaused() { stateSync.lock(); try { - return (timer != null) && (task == null); + return animThread != null && ( !shouldRun && !shouldStop ) ; } finally { stateSync.unlock(); } } - private void startTask() { - if(null != task) { - return; - } - final long period = (long) (1000.0f / (float) fps); - task = new TimerTask() { - public void run() { - if(FPSAnimator.this.shouldRun) { - FPSAnimator.this.animThread = Thread.currentThread(); - // display impl. uses synchronized block on the animator instance - display(); - } - } - }; - - fpsCounter.resetFPSCounter(); - shouldRun = true; - - if (scheduleAtFixedRate) { - timer.scheduleAtFixedRate(task, 0, period); - } else { - timer.schedule(task, 0, period); - } - } - - public synchronized boolean start() { - if (timer != null) { + static int timerNo = 0; + + public synchronized boolean start() { + if ( null != timer || null != task || isStartedImpl() ) { return false; } - stateSync.lock(); - try { - timer = new Timer(); - startTask(); - } finally { - stateSync.unlock(); + timer = new Timer( Thread.currentThread().getName()+"-"+baseName+"-Timer"+(timerNo++) ); + task = new MainTask(); + if(DEBUG) { + System.err.println("FPSAnimator.start() START: "+task+", "+ Thread.currentThread() + ": " + toString()); } - return true; + task.start(timer); + + final boolean res = finishLifecycleAction( drawablesEmpty ? waitForStartedEmptyCondition : waitForStartedAddedCondition, + POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); + if(DEBUG) { + System.err.println("FPSAnimator.start() END: "+task+", "+ Thread.currentThread() + ": " + toString()); + } + if( drawablesEmpty ) { + task.cancel(); + task = null; + } + return res; } + private final Condition waitForStartedAddedCondition = new Condition() { + public boolean eval() { + return !isStartedImpl() || !isAnimating ; + } }; + private final Condition waitForStartedEmptyCondition = new Condition() { + public boolean eval() { + return !isStartedImpl() || isAnimating ; + } }; /** Stops this FPSAnimator. Due to the implementation of the FPSAnimator it is not guaranteed that the FPSAnimator will be completely stopped by the time this method returns. */ public synchronized boolean stop() { - if (timer == null) { + if ( null == timer || !isStartedImpl() ) { return false; + } + if(DEBUG) { + System.err.println("FPSAnimator.stop() START: "+task+", "+ Thread.currentThread() + ": " + toString()); } - stateSync.lock(); - try { + final boolean res; + if( null == task ) { + // start/resume case w/ drawablesEmpty + res = true; + } else { shouldRun = false; - if(null != task) { - task.cancel(); - task = null; - } - if(null != timer) { - timer.cancel(); - timer = null; - } - animThread = null; - try { - final long periodx2 = 2L * (long) (1000.0f / (float) fps); - Thread.sleep(periodx2 > 20L ? periodx2 : 20L); // max(2 x timer period, ~ 1/60), since we can't ctrl stopped threads - } catch (InterruptedException e) { } - } finally { - stateSync.unlock(); + shouldStop = true; + res = finishLifecycleAction(waitForStoppedCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); + } + + if(DEBUG) { + System.err.println("FPSAnimator.stop() END: "+task+", "+ Thread.currentThread() + ": " + toString()); + } + if(null != task) { + task.cancel(); + task = null; } - return true; + if(null != timer) { + timer.cancel(); + timer = null; + } + animThread = null; + return res; } + private final Condition waitForStoppedCondition = new Condition() { + public boolean eval() { + return isStartedImpl(); + } }; public synchronized boolean pause() { - if (timer == null) { + if ( !isStartedImpl() || ( null != task && isPausedImpl() ) ) { return false; } - stateSync.lock(); - try { + if(DEBUG) { + System.err.println("FPSAnimator.pause() START: "+task+", "+ Thread.currentThread() + ": " + toString()); + } + final boolean res; + if( null == task ) { + // start/resume case w/ drawablesEmpty + res = true; + } else { shouldRun = false; - if(null != task) { - task.cancel(); - task = null; - } - animThread = null; - try { - final long periodx2 = 2L * (long) (1000.0f / (float) fps); - Thread.sleep(periodx2 > 20L ? periodx2 : 20L); // max(2 x timer period, ~ 1/60), since we can't ctrl stopped threads - } catch (InterruptedException e) { } - } finally { - stateSync.unlock(); + res = finishLifecycleAction(waitForPausedCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); + } + + if(DEBUG) { + System.err.println("FPSAnimator.pause() END: "+task+", "+ Thread.currentThread() + ": " + toString()); + } + if(null != task) { + task.cancel(); + task = null; } - return true; + return res; } + private final Condition waitForPausedCondition = new Condition() { + public boolean eval() { + // end waiting if stopped as well + return isAnimating && isStartedImpl(); + } }; public synchronized boolean resume() { - if (timer == null) { + if ( null != task || !isStartedImpl() || !isPausedImpl() ) { return false; } - stateSync.lock(); - try { - startTask(); - } finally { - stateSync.unlock(); + if(DEBUG) { + System.err.println("FPSAnimator.resume() START: "+ Thread.currentThread() + ": " + toString()); + } + final boolean res; + if( drawablesEmpty ) { + res = true; + } else { + task = new MainTask(); + task.start(timer); + res = finishLifecycleAction(waitForResumeCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); + } + if(DEBUG) { + System.err.println("FPSAnimator.resume() END: "+task+", "+ Thread.currentThread() + ": " + toString()); } - return true; + return res; } + private final Condition waitForResumeCondition = new Condition() { + public boolean eval() { + // end waiting if stopped as well + return !drawablesEmpty && !isAnimating && isStartedImpl(); + } }; } diff --git a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java index 83e9e22c4..3052b924e 100644 --- a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java +++ b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java @@ -117,7 +117,7 @@ public interface GLAnimatorControl extends FPSCounter { * or in some cases from an implementation-internal thread like the * AWT event queue thread. * - * @return false if if not started or already paused, otherwise true + * @return false if not started, already paused or failed to pause, otherwise true * * @see #resume() * @see #isAnimating() @@ -134,21 +134,32 @@ public interface GLAnimatorControl extends FPSCounter { *

    * If resumed, all counters (time, frames, ..) are reset to zero. * - * @return false if if not started or not paused, otherwise true + * @return false if not started, not paused or unable to resume, otherwise true * * @see #pause() * @see #isAnimating() */ boolean resume(); + /** + * Adds a drawable to this animator's list of rendering drawables.
    + * This allows the animator thread to become active, i.e. {@link #isAnimating()}==true, + * in case the first drawable is added and {@link #isStarted()} and not {@link #isPaused()}.
    + * + * @param drawable the drawable to be added + * @throws IllegalArgumentException if drawable was already added to this animator + */ + void add(GLAutoDrawable drawable); + /** * Removes a drawable from the animator's list of rendering drawables.
    * This method should get called in case a drawable becomes invalid, * and will not be recovered.
    - * This allows the animator thread to become idle in case the last drawable - * has reached it's end of life.
    + * This allows the animator thread to become idle, i.e. {@link #isAnimating()}==false, + * in case the last drawable has reached it's end of life.
    * - * @param drawable the to be removed drawable + * @param drawable the drawable to be removed + * @throws IllegalArgumentException if drawable was not added to this animator */ void remove(GLAutoDrawable drawable); } diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index 0f487f463..a7db3f3fd 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -311,13 +311,13 @@ public interface GLAutoDrawable extends GLDrawable { public GLEventListener removeGLEventListener(GLEventListener listener); /** - *

    * Registers the usage of an animator, an {@link javax.media.opengl.GLAnimatorControl} implementation. - * The animator will be queried whether it's animating, ie periodically issuing {@link #display()} calls or not.


    + * The animator will be queried whether it's animating, ie periodically issuing {@link #display()} calls or not. *

    * This method shall be called by an animator implementation only,
    * e.g. {@link com.jogamp.opengl.util.Animator#add(javax.media.opengl.GLAutoDrawable)}, passing it's control implementation,
    - * and {@link com.jogamp.opengl.util.Animator#remove(javax.media.opengl.GLAutoDrawable)}, passing null.


    + * and {@link com.jogamp.opengl.util.Animator#remove(javax.media.opengl.GLAutoDrawable)}, passing null. + *

    *

    * Impacts {@link #display()} and {@link #invoke(boolean, GLRunnable)} semantics.


    * @@ -340,6 +340,45 @@ public interface GLAutoDrawable extends GLDrawable { */ public GLAnimatorControl getAnimator(); + /** + * Dedicates this instance's {@link GLContext} to the given thread.
    + * The thread will exclusively claim the {@link GLContext} via {@link #display()} and not release it + * until {@link #destroy()} or setExclusiveContextThread(null) has been called. + *

    + * Default non-exclusive behavior is requested via setExclusiveContextThread(null), + * which will cause the next call of {@link #display()} on the exclusive thread to + * release the {@link GLContext}. Only after it's async release, {@link #getExclusiveContextThread()} + * will return null. + *

    + *

    + * To release a previous made exclusive thread, a user issues setExclusiveContextThread(null) + * and may poll {@link #getExclusiveContextThread()} until it returns null, + * while the exclusive thread is still running. + *

    + *

    + * Note: Setting a new exclusive thread without properly releasing a previous one + * will throw an GLException. + *

    + *

    + * Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation. + * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas. + *

    + *

    + * One scenario could be to dedicate the context to the {@link GLAnimatorControl#getThread() animator thread} + * and spare redundant context switches, see {@link com.jogamp.opengl.util.AnimatorBase#setExclusiveContext(boolean)}. + *

    + * @param t the exclusive thread to claim the context, or null for default operation. + * @return previous exclusive context thread + * @throws GLException If an exclusive thread is still active but a new one is attempted to be set + * @see com.jogamp.opengl.util.AnimatorBase#setExclusiveContext(boolean) + */ + public Thread setExclusiveContextThread(Thread t) throws GLException; + + /** + * @see #setExclusiveContextThread(Thread) + */ + public Thread getExclusiveContextThread(); + /** * Enqueues a one-shot {@link GLRunnable}, * which will be executed within the next {@link #display()} call diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 235003c38..461d481a8 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -276,6 +276,9 @@ public abstract class GLContext { /** * Makes this GLContext current on the calling thread. *

    + * Recursive call to {@link #makeCurrent()} and hence {@link #release()} are supported. + *

    + *

    * There are two return values that indicate success and one that * indicates failure. *

    @@ -288,7 +291,7 @@ public abstract class GLContext { *

    *

    * A return value of {@link #CONTEXT_CURRENT} indicates that the context has - * been made currrent, with its previous state restored. + * been made current, with its previous state restored. *

    *

    * If the context could not be made current (for example, because @@ -320,6 +323,9 @@ public abstract class GLContext { /** * Releases control of this GLContext from the current thread. *

    + * Recursive call to {@link #release()} and hence {@link #makeCurrent()} are supported. + *

    + *

    * The drawable's surface is being unlocked at exit, * assumed to be locked by {@link #makeCurrent()}. *

    diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 2f7fef9be..2de86b545 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -741,6 +741,16 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing return helper.getAnimator(); } + @Override + public final Thread setExclusiveContextThread(Thread t) throws GLException { + return helper.setExclusiveContextThread(t, context); + } + + @Override + public final Thread getExclusiveContextThread() { + return helper.getExclusiveContextThread(); + } + @Override public boolean invoke(boolean wait, GLRunnable glRunnable) { return helper.invoke(this, wait, glRunnable); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 23dedaa66..664edb996 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -473,6 +473,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return helper.getAnimator(); } + @Override + public final Thread setExclusiveContextThread(Thread t) throws GLException { + return helper.setExclusiveContextThread(t, getContext()); + } + + @Override + public final Thread getExclusiveContextThread() { + return helper.getExclusiveContextThread(); + } + @Override public boolean invoke(boolean wait, GLRunnable glRunnable) { return helper.invoke(this, wait, glRunnable); diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index cbb7cd699..eadd59559 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -50,7 +50,6 @@ import javax.media.opengl.GLRunnable; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.opengl.GLAutoDrawableDelegate; -import com.jogamp.opengl.util.Animator; /** @@ -406,6 +405,16 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { return helper.getAnimator(); } + @Override + public final Thread setExclusiveContextThread(Thread t) throws GLException { + return helper.setExclusiveContextThread(t, context); + } + + @Override + public final Thread getExclusiveContextThread() { + return helper.getExclusiveContextThread(); + } + @Override public final boolean invoke(boolean wait, GLRunnable glRunnable) { return helper.invoke(this, wait, glRunnable); @@ -532,25 +541,6 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { return null != _drawable ? _drawable.getHeight() : 0; } - /** - * @param t the thread for which context release shall be skipped, usually the animation thread, - * ie. {@link Animator#getThread()}. - * @deprecated This is an experimental feature, - * intended for measuring performance in regards to GL context switch. - */ - @Deprecated - public void setSkipContextReleaseThread(Thread t) { - helper.setSkipContextReleaseThread(t); - } - - /** - * @deprecated see {@link #setSkipContextReleaseThread(Thread)} - */ - @Deprecated - public Thread getSkipContextReleaseThread() { - return helper.getSkipContextReleaseThread(); - } - @Override public final GLCapabilitiesImmutable getChosenGLCapabilities() { final GLDrawable _drawable = drawable; diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index dc5d50cf2..f8c58ee34 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -58,8 +58,6 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLFBODrawable; import javax.media.opengl.GLRunnable; -import com.jogamp.opengl.util.Animator; - /** Encapsulates the implementation of most of the GLAutoDrawable's methods to be able to share it between GLCanvas and GLJPanel. */ public class GLDrawableHelper { @@ -73,7 +71,9 @@ public class GLDrawableHelper { private final Object glRunnablesLock = new Object(); private volatile ArrayList glRunnables = new ArrayList(); private boolean autoSwapBufferMode; - private Thread skipContextReleaseThread; + private volatile Thread exclusiveContextThread; + /** -1 release, 0 nop, 1 claim */ + private volatile int exclusiveContextSwitch; private GLAnimatorControl animatorCtrl; private static Runnable nop = new Runnable() { public void run() {} }; @@ -87,7 +87,8 @@ public class GLDrawableHelper { listenersToBeInit.clear(); } autoSwapBufferMode = true; - skipContextReleaseThread = null; + exclusiveContextThread = null; + exclusiveContextSwitch = 0; synchronized(glRunnablesLock) { glRunnables.clear(); } @@ -112,6 +113,23 @@ public class GLDrawableHelper { return sb.toString(); } + /** + * Since GLContext's {@link GLContext#makeCurrent()} and {@link GLContext#release()} + * is recursive, a call to {@link GLContext#release()} may not natively release the context. + *

    + * This methods continues calling {@link GLContext#release()} until the context has been natively released. + *

    + * @param ctx + */ + public static final void forceNativeRelease(GLContext ctx) { + do { + ctx.release(); + if (DEBUG) { + System.err.println("GLDrawableHelper.forceNativeRelease() -- currentThread "+Thread.currentThread()+" -> "+GLContext.getCurrent()); + } + } while( ctx == GLContext.getCurrent() ); + } + /** * Associate a new context to the drawable and also propagates the context/drawable switch by * calling {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. @@ -767,23 +785,72 @@ public class GLDrawableHelper { return autoSwapBufferMode; } + private final String getExclusiveContextSwitchString() { + return 0 == exclusiveContextSwitch ? "nop" : ( 0 > exclusiveContextSwitch ? "released" : "claimed" ) ; + } + /** - * @param t the thread for which context release shall be skipped, usually the animation thread, - * ie. {@link Animator#getThread()}. - * @deprecated this is an experimental feature, - * intended for measuring performance in regards to GL context switch - * and only being used if {@link #PERF_STATS} is enabled - * by defining property jogl.debug.GLDrawable.PerfStats. + * Dedicates this instance's {@link GLContext} to the given thread.
    + * The thread will exclusively claim the {@link GLContext} via {@link #display()} and not release it + * until {@link #destroy()} or setExclusiveContextThread(null) has been called. + *

    + * Default non-exclusive behavior is requested via setExclusiveContextThread(null), + * which will cause the next call of {@link #display()} on the exclusive thread to + * release the {@link GLContext}. Only after it's async release, {@link #getExclusiveContextThread()} + * will return null. + *

    + *

    + * To release a previous made exclusive thread, a user issues setExclusiveContextThread(null) + * and may poll {@link #getExclusiveContextThread()} until it returns null, + * while the exclusive thread is still running. + *

    + *

    + * Note: Setting a new exclusive thread without properly releasing a previous one + * will throw an GLException. + *

    + *

    + * One scenario could be to dedicate the context to the {@link com.jogamp.opengl.util.AnimatorBase#getThread() animator thread} + * and spare redundant context switches. + *

    + * @param t the exclusive thread to claim the context, or null for default operation. + * @return previous exclusive context thread + * @throws GLException If an exclusive thread is still active but a new one is attempted to be set */ - public final void setSkipContextReleaseThread(Thread t) { - skipContextReleaseThread = t; + public final Thread setExclusiveContextThread(Thread t, GLContext context) throws GLException { + if (DEBUG) { + System.err.println("GLDrawableHelper.setExclusiveContextThread(): START switch "+getExclusiveContextSwitchString()+", thread "+exclusiveContextThread+" -> "+t+" -- currentThread "+Thread.currentThread()); + } + final Thread oldExclusiveContextThread = exclusiveContextThread; + if( exclusiveContextThread == t ) { + exclusiveContextSwitch = 0; // keep + } else if( null == t ) { + exclusiveContextSwitch = -1; // release + } else { + exclusiveContextSwitch = 1; // claim + if( null != exclusiveContextThread ) { + throw new GLException("Release current exclusive Context Thread "+exclusiveContextThread+" first"); + } + if( null != context && GLContext.getCurrent() == context ) { + try { + forceNativeRelease(context); + } catch (Throwable ex) { + ex.printStackTrace(); + throw new GLException(ex); + } + } + exclusiveContextThread = t; + } + if (DEBUG) { + System.err.println("GLDrawableHelper.setExclusiveContextThread(): END switch "+getExclusiveContextSwitchString()+", thread "+exclusiveContextThread+" -- currentThread "+Thread.currentThread()); + } + return oldExclusiveContextThread; } - + /** - * @deprecated see {@link #setSkipContextReleaseThread(Thread)} + * @see #setExclusiveContextThread(Thread, GLContext) */ - public final Thread getSkipContextReleaseThread() { - return skipContextReleaseThread; + public final Thread getExclusiveContextThread() { + return exclusiveContextThread; } private static final ThreadLocal perThreadInitAction = new ThreadLocal(); @@ -828,7 +895,10 @@ public class GLDrawableHelper { * {@link #disposeAllGLEventListener(GLAutoDrawable, boolean) disposeAllGLEventListener(autoDrawable, false)} * with the context made current. *

    - * If destroyContext is true the context is destroyed in the end while holding the lock.
    + * If destroyContext is true the context is destroyed in the end while holding the lock. + *

    + *

    + * If destroyContext is false the context is natively released, i.e. released as often as locked before. *

    * @param autoDrawable * @param context @@ -842,14 +912,15 @@ public class GLDrawableHelper { Runnable lastInitAction = null; if (lastContext != null) { if (lastContext == context) { - lastContext = null; // utilize recursive locking + lastContext = null; } else { + // utilize recursive locking lastInitAction = perThreadInitAction.get(); lastContext.release(); } } - int res = GLContext.CONTEXT_NOT_CURRENT; - + + int res; try { res = context.makeCurrent(); if (GLContext.CONTEXT_NOT_CURRENT != res) { @@ -865,7 +936,7 @@ public class GLDrawableHelper { if(destroyContext) { context.destroy(); } else { - context.release(); + forceNativeRelease(context); } flushGLRunnables(); } catch (Exception e) { @@ -880,136 +951,204 @@ public class GLDrawableHelper { } } } - + private final void invokeGLImpl(final GLDrawable drawable, - final GLContext context, - final Runnable runnable, - final Runnable initAction) { - // Support for recursive makeCurrent() calls as well as calling - // other drawables' display() methods from within another one's - GLContext lastContext = GLContext.getCurrent(); - Runnable lastInitAction = null; - if (lastContext != null) { - if (lastContext == context) { - lastContext = null; // utilize recursive locking - } else { - lastInitAction = perThreadInitAction.get(); - lastContext.release(); - } - } - int res = GLContext.CONTEXT_NOT_CURRENT; - - try { - res = context.makeCurrent(); - if (GLContext.CONTEXT_NOT_CURRENT != res) { - try { - perThreadInitAction.set(initAction); - if (GLContext.CONTEXT_CURRENT_NEW == res) { - if (DEBUG) { - System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); - } - initAction.run(); - } - runnable.run(); - if ( autoSwapBufferMode ) { - drawable.swapBuffers(); - } - } finally { - try { - context.release(); - } catch (Exception e) { - System.err.println("Catched: "+e.getMessage()); - e.printStackTrace(); - } - } - } - } finally { - if (lastContext != null) { - final int res2 = lastContext.makeCurrent(); - if (null != lastInitAction && res2 == GLContext.CONTEXT_CURRENT_NEW) { - lastInitAction.run(); - } - } - } - } - - private final void invokeGLImplStats(final GLDrawable drawable, - final GLContext context, - final Runnable runnable, - final Runnable initAction) { - final Thread currentThread = Thread.currentThread(); - - // Support for recursive makeCurrent() calls as well as calling - // other drawables' display() methods from within another one's - int res = GLContext.CONTEXT_NOT_CURRENT; - GLContext lastContext = GLContext.getCurrent(); - Runnable lastInitAction = null; - if (lastContext != null) { - if (lastContext == context) { - if( currentThread == skipContextReleaseThread ) { - res = GLContext.CONTEXT_CURRENT; - } // else: utilize recursive locking - lastContext = null; - } else { - lastInitAction = perThreadInitAction.get(); - lastContext.release(); - } - } - - long t0 = System.currentTimeMillis(); - long tdA = 0; // makeCurrent - long tdR = 0; // render time - long tdS = 0; // swapBuffers - long tdX = 0; // release - boolean ctxClaimed = false; - boolean ctxReleased = false; - boolean ctxDestroyed = false; - try { - if (res == GLContext.CONTEXT_NOT_CURRENT) { - res = context.makeCurrent(); - ctxClaimed = true; + final GLContext context, + final Runnable runnable, + final Runnable initAction) { + final Thread currentThread = Thread.currentThread(); + + // Exclusive Cases: + // 1: lock - unlock : default + // 2: lock - - : exclusive, not locked yet + // 3: - - - : exclusive, already locked + // 4: - - unlock : ex-exclusive, already locked + final boolean _isExclusiveThread, _releaseExclusiveThread; + if( null != exclusiveContextThread) { + if( currentThread == exclusiveContextThread ) { + _releaseExclusiveThread = 0 > exclusiveContextSwitch; + _isExclusiveThread = !_releaseExclusiveThread; + exclusiveContextSwitch = 0; + } else { + // Exclusive thread usage, but on other thread + return; + } + } else { + _releaseExclusiveThread = false; + _isExclusiveThread = false; } - if (res != GLContext.CONTEXT_NOT_CURRENT) { - perThreadInitAction.set(initAction); - if (res == GLContext.CONTEXT_CURRENT_NEW) { - if (DEBUG) { - System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); + + // Support for recursive makeCurrent() calls as well as calling + // other drawables' display() methods from within another one's + int res = GLContext.CONTEXT_NOT_CURRENT; + GLContext lastContext = GLContext.getCurrent(); + Runnable lastInitAction = null; + if (lastContext != null) { + if (lastContext == context) { + res = GLContext.CONTEXT_CURRENT; + lastContext = null; + } else { + // utilize recursive locking + lastInitAction = perThreadInitAction.get(); + lastContext.release(); } - initAction.run(); - } - tdR = System.currentTimeMillis(); - tdA = tdR - t0; // makeCurrent - runnable.run(); - tdS = System.currentTimeMillis(); - tdR = tdS - tdR; // render time - if (autoSwapBufferMode) { - drawable.swapBuffers(); - tdX = System.currentTimeMillis(); - tdS = tdX - tdS; // swapBuffers - } } - } finally { + try { - if( res != GLContext.CONTEXT_NOT_CURRENT && - (null == skipContextReleaseThread || currentThread != skipContextReleaseThread) ) { - context.release(); - ctxReleased = true; + final boolean releaseContext; + if( GLContext.CONTEXT_NOT_CURRENT == res ) { + res = context.makeCurrent(); + releaseContext = !_isExclusiveThread; + } else { + releaseContext = _releaseExclusiveThread; } - } catch (Exception e) { - System.err.println("Catched: "+e.getMessage()); - e.printStackTrace(); + if (GLContext.CONTEXT_NOT_CURRENT != res) { + try { + perThreadInitAction.set(initAction); + if (GLContext.CONTEXT_CURRENT_NEW == res) { + if (DEBUG) { + System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); + } + initAction.run(); + } + runnable.run(); + if ( autoSwapBufferMode ) { + drawable.swapBuffers(); + } + } finally { + if( _releaseExclusiveThread ) { + exclusiveContextThread = null; + if (DEBUG) { + System.err.println("GLDrawableHelper.invokeGL() - Release ExclusiveContextThread -- currentThread "+Thread.currentThread()); + } + } + if( releaseContext ) { + try { + context.release(); + } catch (Exception e) { + System.err.println("Catched: "+e.getMessage()); + e.printStackTrace(); + } + } + } + } + } finally { + if (lastContext != null) { + final int res2 = lastContext.makeCurrent(); + if (null != lastInitAction && res2 == GLContext.CONTEXT_CURRENT_NEW) { + lastInitAction.run(); + } + } + } + } + + private final void invokeGLImplStats(final GLDrawable drawable, + final GLContext context, + final Runnable runnable, + final Runnable initAction) { + final Thread currentThread = Thread.currentThread(); + + // Exclusive Cases: + // 1: lock - unlock : default + // 2: lock - - : exclusive, not locked yet + // 3: - - - : exclusive, already locked + // 4: - - unlock : ex-exclusive, already locked + final boolean _isExclusiveThread, _releaseExclusiveThread; + if( null != exclusiveContextThread) { + if( currentThread == exclusiveContextThread ) { + _releaseExclusiveThread = 0 > exclusiveContextSwitch; + _isExclusiveThread = !_releaseExclusiveThread; + } else { + // Exclusive thread usage, but on other thread + return; + } + } else { + _releaseExclusiveThread = false; + _isExclusiveThread = false; } - tdX = System.currentTimeMillis() - tdX; // release / destroy + // Support for recursive makeCurrent() calls as well as calling + // other drawables' display() methods from within another one's + int res = GLContext.CONTEXT_NOT_CURRENT; + GLContext lastContext = GLContext.getCurrent(); + Runnable lastInitAction = null; if (lastContext != null) { - final int res2 = lastContext.makeCurrent(); - if (null != lastInitAction && res2 == GLContext.CONTEXT_CURRENT_NEW) { - lastInitAction.run(); - } + if (lastContext == context) { + res = GLContext.CONTEXT_CURRENT; + lastContext = null; + } else { + // utilize recursive locking + lastInitAction = perThreadInitAction.get(); + lastContext.release(); + } } - } - long td = System.currentTimeMillis() - t0; - System.err.println("td0 "+td+"ms, fps "+(1.0/(td/1000.0))+", td-makeCurrent: "+tdA+"ms, td-render "+tdR+"ms, td-swap "+tdS+"ms, td-release "+tdX+"ms, ctx claimed: "+ctxClaimed+", ctx release: "+ctxReleased+", ctx destroyed "+ctxDestroyed); + + long t0 = System.currentTimeMillis(); + long tdA = 0; // makeCurrent + long tdR = 0; // render time + long tdS = 0; // swapBuffers + long tdX = 0; // release + boolean ctxClaimed = false; + boolean ctxReleased = false; + boolean ctxDestroyed = false; + try { + final boolean releaseContext; + if( GLContext.CONTEXT_NOT_CURRENT == res ) { + res = context.makeCurrent(); + releaseContext = !_isExclusiveThread; + ctxClaimed = true; + } else { + releaseContext = _releaseExclusiveThread; + } + if (GLContext.CONTEXT_NOT_CURRENT != res) { + try { + perThreadInitAction.set(initAction); + if (GLContext.CONTEXT_CURRENT_NEW == res) { + if (DEBUG) { + System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); + } + initAction.run(); + } + tdR = System.currentTimeMillis(); + tdA = tdR - t0; // makeCurrent + runnable.run(); + tdS = System.currentTimeMillis(); + tdR = tdS - tdR; // render time + if ( autoSwapBufferMode ) { + drawable.swapBuffers(); + tdX = System.currentTimeMillis(); + tdS = tdX - tdS; // swapBuffers + } + } finally { + if( _releaseExclusiveThread ) { + exclusiveContextSwitch = 0; + exclusiveContextThread = null; + if (DEBUG) { + System.err.println("GLDrawableHelper.invokeGL() - Release ExclusiveContextThread -- currentThread "+Thread.currentThread()); + } + } + if( releaseContext ) { + try { + context.release(); + ctxReleased = true; + } catch (Exception e) { + System.err.println("Catched: "+e.getMessage()); + e.printStackTrace(); + } + } + } + } + } finally { + tdX = System.currentTimeMillis() - tdX; // release / destroy + if (lastContext != null) { + final int res2 = lastContext.makeCurrent(); + if (null != lastInitAction && res2 == GLContext.CONTEXT_CURRENT_NEW) { + lastInitAction.run(); + } + } + } + long td = System.currentTimeMillis() - t0; + System.err.println("td0 "+td+"ms, fps "+(1.0/(td/1000.0))+", td-makeCurrent: "+tdA+"ms, td-render "+tdR+"ms, td-swap "+tdS+"ms, td-release "+tdX+"ms, ctx claimed: "+ctxClaimed+", ctx release: "+ctxReleased+", ctx destroyed "+ctxDestroyed); } } diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 082c01c23..07004503e 100755 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -208,7 +208,10 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { glWindow.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); // glAnimator = new FPSAnimator(canvas, 60); - glAnimator = new Animator(tg, glWindow); + glAnimator = new Animator(); + glAnimator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); // No AWT thread involved! + glAnimator.setThreadGroup(tg); + glAnimator.add(glWindow); glAnimator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, null); } catch (Throwable t) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java new file mode 100644 index 000000000..c6eb3a103 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java @@ -0,0 +1,420 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.AnimatorBase; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; + +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.util.InsetsImmutable; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; + +/** + * ExclusiveContextThread base implementation to test correctness of the ExclusiveContext feature _and_ AnimatorBase. + */ +public abstract class ExclusiveContextBase00 extends UITestCase { + static boolean testExclusiveWithAWT = false; + static final int durationParts = 9; + static long duration = 320 * durationParts; // ms ~ 20 frames + + static boolean showFPS = false; + static int showFPSRate = 100; + + static final int demoSize = 128; + + static InsetsImmutable insets = null; + static int scrnHeight, scrnWidth; + static int num_x, num_y; + + static int swapInterval = 0; + + @BeforeClass + public static void initClass00() { + Window dummyWindow = NewtFactory.createWindow(new Capabilities()); + dummyWindow.setSize(demoSize, demoSize); + dummyWindow.setVisible(true); + Assert.assertEquals(true, dummyWindow.isVisible()); + Assert.assertEquals(true, dummyWindow.isNativeValid()); + insets = dummyWindow.getInsets(); + scrnHeight = dummyWindow.getScreen().getHeight(); + scrnWidth = dummyWindow.getScreen().getWidth(); + num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2; + num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2; + dummyWindow.destroy(); + } + + @AfterClass + public static void releaseClass00() { + } + + protected abstract boolean isAWTTestCase(); + protected abstract Thread getAWTRenderThread(); + protected abstract AnimatorBase createAnimator(); + protected abstract GLAutoDrawable createGLAutoDrawable(String title, int x, int y, int width, int height, GLCapabilitiesImmutable caps); + protected abstract void setGLAutoDrawableVisible(GLAutoDrawable[] glads); + protected abstract void destroyGLAutoDrawableVisible(GLAutoDrawable glad); + + protected void runTestGL(GLCapabilitiesImmutable caps, int drawableCount, boolean exclusive, boolean preAdd, boolean shortenTest) throws InterruptedException { + final boolean useAWTRenderThread = isAWTTestCase(); + if( useAWTRenderThread && exclusive ) { + if( testExclusiveWithAWT ) { + System.err.println("Warning: Testing AWT + Exclusive -> Not advised!"); + } else { + System.err.println("Info: Skip test: AWT + Exclusive!"); + return; + } + } + if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) { + System.err.println("Skip test: AWT + Exclusive -> Not advised!"); + return; + } + final Thread awtRenderThread = getAWTRenderThread(); + final AnimatorBase animator = createAnimator(); + if( !useAWTRenderThread ) { + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + } + final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; + for(int i=0; i0) { + System.err.println("Clearing drawable ECT was done 'later' @ "+(c*20)+"ms, ok "+ok); + } + Assert.assertEquals(true, ok); + } + final Thread t = drawables[i].setExclusiveContextThread(ect); + Assert.assertEquals(null, t); + } + + Thread.sleep(duration/durationParts); // 3 + } + + // Disable/Enable exclusive mode via Animator for all GLAutoDrawable + if(exclusive) { + final Thread ect = animator.getExclusiveContextThread(); + if( useAWTRenderThread ) { + Assert.assertEquals(awtRenderThread, ect); + } else { + Assert.assertEquals(animator.getThread(), ect); + } + + Assert.assertEquals(true, animator.setExclusiveContext(false)); + Assert.assertFalse(animator.isExclusiveContextEnabled()); + for(int i=0; i Platform.getJavaVersionNumber().compareTo(version170); + System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); + System.err.println("OSType "+Platform.getOSType()); + System.err.println("Java Version "+Platform.getJavaVersionNumber()); + + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + awtEDT = Thread.currentThread(); + } } ); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + } + + @AfterClass + public static void releaseClass00AWT() { + } + + @Override + protected boolean isAWTTestCase() { return true; } + + @Override + protected Thread getAWTRenderThread() { + return awtEDT; + } + + @Override + protected GLAutoDrawable createGLAutoDrawable(final String title, final int x, final int y, final int width, final int height, GLCapabilitiesImmutable caps) { + final GLCanvas glCanvas = new GLCanvas(); + + // FIXME: Below AWT layouts freezes OSX/Java7 @ setVisible: Window.setVisible .. CWrapper@NSWindow.isKeyWindow + // final Dimension sz = new Dimension(width, height); + // glCanvas.setMinimumSize(sz); + // glCanvas.setPreferredSize(sz); + // glCanvas.setSize(sz); + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final Frame frame = new Frame(); + frame.setLayout(new BorderLayout()); + frame.setMinimumSize(new Dimension(width, height)); + frame.setBounds(x, y, width, height); + frame.add(glCanvas, BorderLayout.CENTER); + // frame.pack(); + frame.validate(); + if( !osxCALayerAWTModBug ) { + frame.setTitle(title); + } + } }); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + return glCanvas; + } + + protected Frame getFrame(GLAutoDrawable glad) { + Container p = ((Component)glad).getParent(); + while( null != p && !( p instanceof Frame ) ) { + p = p.getParent(); + } + return (Frame)p; + } + + @Override + protected void setGLAutoDrawableVisible(final GLAutoDrawable[] glads) { + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final int count = glads.length; + for(int i=0; i Not advised!"); + } else { + System.err.println("Info: Skip test: AWT + Exclusive!"); + return; + } + } + if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) { + System.err.println("Skip test: AWT + Exclusive -> Not advised!"); + return; + } + final Thread awtRenderThread = getAWTRenderThread(); + final AnimatorBase animator = createAnimator(); + if( !useAWTRenderThread ) { + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + } + final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; + for(int i=0; i Platform.getJavaVersionNumber().compareTo(version170); + System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); + System.err.println("OSType "+Platform.getOSType()); + System.err.println("Java Version "+Platform.getJavaVersionNumber()); + + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + awtEDT = Thread.currentThread(); + } } ); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + } + + @AfterClass + public static void releaseClass00AWT() { + } + + @Override + protected boolean isAWTTestCase() { return true; } + + @Override + protected Thread getAWTRenderThread() { + return awtEDT; + } + + @Override + protected GLAutoDrawable createGLAutoDrawable(final String title, final int x, final int y, final int width, final int height, GLCapabilitiesImmutable caps) { + final GLCanvas glCanvas = new GLCanvas(); + + // FIXME: Below AWT layouts freezes OSX/Java7 @ setVisible: Window.setVisible .. CWrapper@NSWindow.isKeyWindow + // final Dimension sz = new Dimension(width, height); + // glCanvas.setMinimumSize(sz); + // glCanvas.setPreferredSize(sz); + // glCanvas.setSize(sz); + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final Frame frame = new Frame(); + frame.setLayout(new BorderLayout()); + frame.setMinimumSize(new Dimension(width, height)); + frame.setBounds(x, y, width, height); + frame.add(glCanvas, BorderLayout.CENTER); + // frame.pack(); + frame.validate(); + if( !osxCALayerAWTModBug ) { + frame.setTitle(title); + } + } }); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + return glCanvas; + } + + protected Frame getFrame(GLAutoDrawable glad) { + Container p = ((Component)glad).getParent(); + while( null != p && !( p instanceof Frame ) ) { + p = p.getParent(); + } + return (Frame)p; + } + + @Override + protected void setGLAutoDrawableVisible(final GLAutoDrawable[] glads) { + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final int count = glads.length; + for(int i=0; i */ -public class InitConcurrentBaseNEWT extends UITestCase { +public abstract class InitConcurrentBaseNEWT extends UITestCase { static final int demoSize = 128; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimAWT.java new file mode 100644 index 000000000..245d42031 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimAWT.java @@ -0,0 +1,70 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import com.jogamp.opengl.test.junit.util.MiscUtils; + +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.AnimatorBase; + +/** + * ExclusiveContextThread VSync Animator to test correctness of the ExclusiveContext feature _and_ Animator with AWT. + */ +public class TestExclusiveContext01VSyncAnimAWT extends ExclusiveContextBase00AWT { + + @Override + protected AnimatorBase createAnimator() { + return new Animator(); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i Date: Fri, 11 Jan 2013 08:14:49 +0100 Subject: Minor: GLWindow fix size validation; GLContextImpl: Remove hold ctx lock count constraints at destroy. --- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 9 +++------ src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 8a261c21c..36aaeb597 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -325,16 +325,13 @@ public abstract class GLContextImpl extends GLContext { try { // Must hold the lock around the destroy operation to make sure we // don't destroy the context while another thread renders to it. - lock.lock(); // holdCount++ -> 1 - 3 (1: not locked, 2-3: destroy while rendering) + lock.lock(); // holdCount++ -> 1 - n (1: not locked, 2-n: destroy while rendering) if ( lock.getHoldCount() > 2 ) { final String msg = getThreadName() + ": GLContextImpl.destroy: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle); if (DEBUG || TRACE_SWITCH) { System.err.println(msg+" - Lock was hold more than once - makeCurrent/release imbalance: "+lock); Thread.dumpStack(); } - if ( lock.getHoldCount() > 3 ) { - throw new GLException(msg+" - Lock was hold more than twice - makeCurrent/release imbalance: "+lock); - } } try { // release current context @@ -471,7 +468,7 @@ public abstract class GLContextImpl extends GLContext { // and one thread can only have one context current! final GLContext current = getCurrent(); if (current != null) { - if (current == this) { + if (current == this) { // implicit recursive locking! // Assume we don't need to make this context current again // For Mac OS X, however, we need to update the context to track resizes drawableUpdatedNotify(); @@ -1724,7 +1721,7 @@ public abstract class GLContextImpl extends GLContext { public boolean hasWaiters() { return lock.getQueueLength()>0; } - + //--------------------------------------------------------------------------- // Special FBO hook // diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index a89ccaedb..73a4134bd 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -548,7 +548,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } finally { lock.unlock(); } - if( !done && 0 display setVisible(true); } -- cgit v1.2.3 From da14d647581751f3d2f6d651741eaec485e255b5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 14 Jan 2013 05:58:21 +0100 Subject: NEWT-MouseEvent getWheelRotation() API Update - Fixes Bug 659: NEWT Horizontal Scrolling Behavior (OSX, X11, Win32); Bug 639: High-Res Mouse-Wheel - API update 'float getWheelRotation()': Usually a wheel rotation of > 0.0f is up, and < 0.0f is down. Usually a wheel rotations is considered a vertical scroll. If isShiftDown(), a wheel rotations is considered a horizontal scroll, where shift-up = left = > 0.0f, and shift-down = right = < 0.0f. However, on some OS this might be flipped due to the OS default behavior. The latter is true for OS X 10.7 (Lion) for example. The events will be send usually in steps of one, ie. -1.0f and 1.0f. Higher values may result due to fast scrolling. Fractional values may result due to slow scrolling with high resolution devices. The button number refers to the wheel number. - Fix Bug 659: NEWT Horizontal Scrolling Behavior (OSX, X11, Win32) - See new API doc above - X11/Horiz: Keep using button1 and set SHIFT modifier - OSX/Horiz: - PAD: Use highes absolute scrolling value (Axis1/Axis2) and set SHIFT modifier for horizontal scrolling (Axis2) - XXX: Use deltaX for horizontal scrolling, detected by SHIFT modifier. (traditional) - Windows/Horiz: - Add WM_MOUSEHWHEEL support (-> set SHIFT modifier), but it's rarely impl. for trackpads! - Add exp. WM_HSCROLL, but it will only be delivered if windows has WS_HSCROLL, hence dead code! - Android: - Add ACTION_SCROLL (API Level 12), only used if layout is a scroll layout - Using GestureDetector to detect scroll even w/ pointerCount > 2, while: - skipping 1st scroll event (value too high) - skipping other events while in-scroll mode - waiting until all pointers were released before cont. normally - using View config's 1/touchSlope as scale factor - Fix Bug 639: High-Res Mouse-Wheel - getWheelRotation() return value changed: int -> float allowing fractions, see API doc changes above. - Fractions are currently supported natively (API) on - Windows - OSX - Android - AndroidNewtEventFactory ir refactored (requires an instance now) and AndroidNewtEventTranslator (event listener) is pulled our of Android WindowDriver. --- make/resources/android/AndroidManifest-test.xml | 24 +- make/scripts/java-win32-dbg.bat | 1 + make/scripts/java-win64-dbg.bat | 3 +- make/scripts/tests-x32.bat | 6 +- make/scripts/tests-x64.bat | 8 +- make/scripts/tests.sh | 6 +- .../jogamp/nativewindow/windows/GDIUtil.java | 5 +- .../nativewindow/windows/RegisteredClass.java | 5 +- .../windows/RegisteredClassFactory.java | 26 +- src/newt/classes/com/jogamp/newt/NewtFactory.java | 8 +- .../classes/com/jogamp/newt/event/MouseEvent.java | 24 +- src/newt/classes/jogamp/newt/WindowImpl.java | 16 +- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 4 +- .../jogamp/newt/driver/android/WindowDriver.java | 100 +++--- .../android/event/AndroidNewtEventFactory.java | 355 ++++++++++++++++----- .../android/event/AndroidNewtEventTranslator.java | 55 ++++ .../jogamp/newt/driver/windows/DisplayDriver.java | 13 +- .../jogamp/newt/driver/windows/WindowDriver.java | 13 +- .../jogamp/newt/driver/x11/WindowDriver.java | 14 +- .../jogamp/newt/swt/event/SWTNewtEventFactory.java | 4 +- src/newt/native/KDWindow.c | 6 +- src/newt/native/NewtMacWindow.m | 58 ++-- src/newt/native/WindowsWindow.c | 181 +++++++++-- src/newt/native/X11Display.c | 24 +- src/newt/native/X11Event.c | 20 +- src/newt/native/XCBEvent.c | 12 +- src/newt/native/bcm_vc_iv.c | 2 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 29 +- 28 files changed, 750 insertions(+), 272 deletions(-) create mode 100644 src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java (limited to 'src/newt/classes') diff --git a/make/resources/android/AndroidManifest-test.xml b/make/resources/android/AndroidManifest-test.xml index 3c2046df1..0817b3450 100644 --- a/make/resources/android/AndroidManifest-test.xml +++ b/make/resources/android/AndroidManifest-test.xml @@ -18,9 +18,9 @@ android:persistent="false" > - @@ -28,9 +28,9 @@ - @@ -39,9 +39,9 @@ - @@ -49,9 +49,9 @@ - diff --git a/make/scripts/java-win32-dbg.bat b/make/scripts/java-win32-dbg.bat index a4a9e9a5b..1852d9b0c 100755 --- a/make/scripts/java-win32-dbg.bat +++ b/make/scripts/java-win32-dbg.bat @@ -36,6 +36,7 @@ REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" "-Djogl.debug=all" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" +REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Xcheck:jni" "-Xint" "-verbose:jni" set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 239856c84..63c46eee5 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -30,7 +30,7 @@ REM set D_ARGS="-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.NativeLibrary=true" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.ExtensionAvailabilityCache" "-Djogamp.debug.ProcAddressHelper=true" -set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" +REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.GLDrawable" "-Dnativewindow.debug.GraphicsConfiguration" REM set D_ARGS="-Djogamp.debug.JNILibLoader=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLProfile=true" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.Lock" "-Djogamp.debug.Lock.TraceLock" @@ -41,6 +41,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" +REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat index ec6c41f37..adc4ece39 100755 --- a/make/scripts/tests-x32.bat +++ b/make/scripts/tests-x32.bat @@ -1,5 +1,5 @@ REM scripts\java-win32-dbg.bat jogamp.newt.awt.opengl.VersionApplet -scripts\java-win32-dbg.bat com.jogamp.newt.opengl.GLWindow +REM scripts\java-win32-dbg.bat com.jogamp.newt.opengl.GLWindow REM scripts\java-win32-dbg.bat javax.media.opengl.awt.GLCanvas REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* @@ -16,12 +16,14 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt. REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT -time 5000 +REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* +REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 20cb54147..b66f8b8ab 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -22,7 +22,7 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclu REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT %* -scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* @@ -49,11 +49,13 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsReali REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT -time 5000 +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT -time 2000 @@ -146,5 +148,3 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNew REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* - diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 130cf1570..bc379de63 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -165,7 +165,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - #D_ARGS="-Dnewt.debug.Window.MouseEvent" + D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window" @@ -261,7 +261,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* @@ -285,7 +285,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT $* diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index acb4c84da..00741a328 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -34,7 +34,6 @@ import javax.media.nativewindow.NativeWindowFactory; import jogamp.nativewindow.NWJNILibLoader; import jogamp.nativewindow.Debug; import jogamp.nativewindow.ToolkitProperties; -import jogamp.nativewindow.x11.X11Util; public class GDIUtil implements ToolkitProperties { private static final boolean DEBUG = Debug.debug("GDIUtil"); @@ -49,7 +48,7 @@ public class GDIUtil implements ToolkitProperties { */ public static synchronized void initSingleton() { if(!isInit) { - synchronized(X11Util.class) { + synchronized(GDIUtil.class) { if(!isInit) { if(DEBUG) { System.out.println("GDI.initSingleton()"); @@ -92,7 +91,7 @@ public class GDIUtil implements ToolkitProperties { public static long CreateDummyWindow(int x, int y, int width, int height) { synchronized(dummyWindowSync) { dummyWindowClass = dummyWindowClassFactory.getSharedClass(); - return CreateDummyWindow0(dummyWindowClass.getHandle(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height); + return CreateDummyWindow0(dummyWindowClass.getHInstance(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height); } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java index afb3daf7c..949f5d06d 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java @@ -37,7 +37,10 @@ public class RegisteredClass { className = name; } - public final long getHandle() { return hInstance; } + /** Application handle, same as {@link RegisteredClassFactory#getHInstance()}. */ + public final long getHInstance() { return hInstance; } + + /** Unique Window Class Name */ public final String getName() { return className; } @Override diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java index 00bedfc8e..0280b0df7 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java @@ -33,8 +33,17 @@ import java.util.ArrayList; import javax.media.nativewindow.NativeWindowException; public class RegisteredClassFactory { - static final boolean DEBUG = Debug.debug("RegisteredClass"); - private static ArrayList registeredFactories = new ArrayList(); + private static final boolean DEBUG = Debug.debug("RegisteredClass"); + private static final ArrayList registeredFactories; + private static final long hInstance; + + static { + hInstance = GDI.GetApplicationHandle(); + if( 0 == hInstance ) { + throw new NativeWindowException("Error: Null ModuleHandle for Application"); + } + registeredFactories = new ArrayList(); + } private String classBaseName; private long wndProc; @@ -43,7 +52,7 @@ public class RegisteredClassFactory { private int classIter = 0; private int sharedRefCount = 0; private final Object sync = new Object(); - + /** * Release the {@link RegisteredClass} of all {@link RegisteredClassFactory}. */ @@ -53,7 +62,7 @@ public class RegisteredClassFactory { final RegisteredClassFactory rcf = registeredFactories.get(j); synchronized(rcf.sync) { if(null != rcf.sharedClass) { - GDIUtil.DestroyWindowClass(rcf.sharedClass.getHandle(), rcf.sharedClass.getName()); + GDIUtil.DestroyWindowClass(rcf.sharedClass.getHInstance(), rcf.sharedClass.getName()); rcf.sharedClass = null; rcf.sharedRefCount = 0; rcf.classIter = 0; @@ -65,6 +74,9 @@ public class RegisteredClassFactory { } } } + + /** Application handle. */ + public static long getHInstance() { return hInstance; } public RegisteredClassFactory(String classBaseName, long wndProc) { this.classBaseName = classBaseName; @@ -80,10 +92,6 @@ public class RegisteredClassFactory { if( null != sharedClass ) { throw new InternalError("Error ("+sharedRefCount+"): SharedClass not null: "+sharedClass); } - long hInstance = GDI.GetApplicationHandle(); - if( 0 == hInstance ) { - throw new NativeWindowException("Error: Null ModuleHandle for Application"); - } String clazzName = null; boolean registered = false; final int classIterMark = classIter - 1; @@ -121,7 +129,7 @@ public class RegisteredClassFactory { throw new InternalError("Error ("+sharedRefCount+"): SharedClass is null"); } if( 0 == sharedRefCount ) { - GDIUtil.DestroyWindowClass(sharedClass.getHandle(), sharedClass.getName()); + GDIUtil.DestroyWindowClass(sharedClass.getHInstance(), sharedClass.getName()); if(DEBUG) { System.err.println("RegisteredClassFactory releaseSharedClass ("+sharedRefCount+") released: "+sharedClass); } diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index b3e904310..e66b2f624 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -44,8 +44,6 @@ import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowFactory; -import com.jogamp.common.os.Platform; - import jogamp.newt.Debug; import jogamp.newt.DisplayImpl; import jogamp.newt.ScreenImpl; @@ -56,13 +54,15 @@ public class NewtFactory { public static final String DRIVER_DEFAULT_ROOT_PACKAGE = "jogamp.newt.driver"; - // Work-around for initialization order problems on Mac OS X - // between native Newt and (apparently) Fmod static { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { NativeWindowFactory.initSingleton(); // last resort .. + + // Work-around for initialization order problems on Mac OS X + // between native Newt and (apparently) Fmod WindowImpl.init(NativeWindowFactory.getNativeWindowType(true)); + return null; } } ); } diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 914aaa647..e6b3d8a24 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -65,7 +65,7 @@ public class MouseEvent extends InputEvent public MouseEvent(int eventType, Object source, long when, int modifiers, int x, int y, int clickCount, int button, - int rotation) + float rotation) { super(eventType, source, when, modifiers); this.x = new int[]{x}; @@ -79,7 +79,7 @@ public class MouseEvent extends InputEvent public MouseEvent(int eventType, Object source, long when, int modifiers, int[] x, int[] y, float[] pressure, int[] pointerids, int clickCount, int button, - int rotation) + float rotation) { super(eventType, source, when, modifiers); this.x = x; @@ -154,20 +154,29 @@ public class MouseEvent extends InputEvent } /** - * Usually a wheel rotation of > 0 is up, - * and < 0 is down.
    + * Usually a wheel rotation of > 0.0f is up, + * and < 0.0f is down. + *

    + * Usually a wheel rotations is considered a vertical scroll.
    + * If {@link #isShiftDown()}, a wheel rotations is + * considered a horizontal scroll, where shift-up = left = > 0.0f, + * and shift-down = right = < 0.0f. + *

    + *

    * However, on some OS this might be flipped due to the OS default behavior. * The latter is true for OS X 10.7 (Lion) for example. + *

    *

    - * The events will be send usually in steps of one, ie. -1 and 1. + * The events will be send usually in steps of one, ie. -1.0f and 1.0f. * Higher values may result due to fast scrolling. + * Fractional values may result due to slow scrolling with high resolution devices. *

    *

    * The button number refers to the wheel number. *

    * @return */ - public int getWheelRotation() { + public float getWheelRotation() { return wheelRotation; } @@ -212,7 +221,8 @@ public class MouseEvent extends InputEvent default: return "unknown (" + type + ")"; } } - private final int x[], y[], clickCount, button, wheelRotation; + private final int x[], y[], clickCount, button; + private final float wheelRotation; private final float pressure[]; private final int pointerids[]; diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 6e1059952..3c93de5b3 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -133,10 +133,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private ArrayList windowListeners = new ArrayList(); private boolean repaintQueued = false; - // 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 + /** + * 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 + */ public static void init(String type) { if (NativeWindowFactory.TYPE_MACOSX.equals(type)) { try { @@ -1974,16 +1976,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // MouseListener/Event Support // public void sendMouseEvent(int eventType, int modifiers, - int x, int y, int button, int rotation) { + int x, int y, int button, float rotation) { doMouseEvent(false, false, eventType, modifiers, x, y, button, rotation); } public void enqueueMouseEvent(boolean wait, int eventType, int modifiers, - int x, int y, int button, int rotation) { + int x, int y, int button, float rotation) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotation); } protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, - int x, int y, int button, int rotation) { + int x, int y, int button, float rotation) { if( eventType == MouseEvent.EVENT_MOUSE_ENTERED || eventType == MouseEvent.EVENT_MOUSE_EXITED ) { if( eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1 ) { x = lastMousePosition.getX(); diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index 1a61d0528..e0f7af69c 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -262,10 +262,10 @@ public class AWTNewtEventFactory { public static final com.jogamp.newt.event.MouseEvent createMouseEvent(java.awt.event.MouseEvent event, com.jogamp.newt.Window newtSource) { int type = eventTypeAWT2NEWT.get(event.getID()); if(0xFFFFFFFF != type) { - int rotation = 0; + float rotation = 0; if (event instanceof java.awt.event.MouseWheelEvent) { // AWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up. - rotation = -1 * ((java.awt.event.MouseWheelEvent)event).getWheelRotation(); + rotation = -1f * ((java.awt.event.MouseWheelEvent)event).getWheelRotation(); } final int newtButton = awtButton2Newt(event.getButton()); diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index f18520630..281bd9e0f 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -29,7 +29,7 @@ package jogamp.newt.driver.android; import jogamp.common.os.android.StaticContext; -import jogamp.newt.driver.android.event.AndroidNewtEventFactory; +import jogamp.newt.driver.android.event.AndroidNewtEventTranslator; import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.CapabilitiesImmutable; @@ -41,6 +41,7 @@ import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLException; +import com.jogamp.common.os.AndroidVersion; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import jogamp.opengl.egl.EGL; @@ -58,7 +59,6 @@ import android.view.SurfaceHolder; import android.view.SurfaceHolder.Callback2; import android.view.inputmethod.InputMethodManager; import android.view.SurfaceView; -import android.view.View; public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { static { @@ -139,42 +139,6 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return false; } - class AndroidEvents implements View.OnKeyListener, View.OnTouchListener, View.OnFocusChangeListener { - - @Override - public boolean onTouch(View v, android.view.MotionEvent event) { - final com.jogamp.newt.event.MouseEvent[] newtEvents = AndroidNewtEventFactory.createMouseEvents(event, WindowDriver.this); - if(null != newtEvents) { - focusChanged(false, true); - for(int i=0; i[] getCustomConstructorArgumentTypes() { return new Class[] { Context.class } ; } @@ -196,22 +160,33 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { setBrokenFocusChange(true); } + private void setupInputListener(boolean enable) { + Log.d(MD.TAG, "setupInputListener(enable "+enable+") - "+Thread.currentThread().getName()); + + final AndroidNewtEventTranslator eventTranslator = + enable ? new AndroidNewtEventTranslator(this, androidView.getContext(), androidView.getHandler()) : null; + androidView.setOnTouchListener(eventTranslator); + androidView.setOnKeyListener(eventTranslator); + androidView.setOnFocusChangeListener(eventTranslator); + if(AndroidVersion.SDK_INT >= 12) { // API Level 12 + Log.d(MD.TAG, "instantiationFinished() - enable GenericMotionListener - "+Thread.currentThread().getName()); + androidView.setOnGenericMotionListener(eventTranslator); + } + androidView.setClickable(false); + androidView.setFocusable(enable); + androidView.setFocusableInTouchMode(enable); + } + @Override protected void instantiationFinished() { + Log.d(MD.TAG, "instantiationFinished() - "+Thread.currentThread().getName()); + final Context ctx = StaticContext.getContext(); if(null == ctx) { throw new NativeWindowException("No static [Application] Context has been set. Call StaticContext.setContext(Context) first."); } androidView = new MSurfaceView(ctx); - - final AndroidEvents ae = new AndroidEvents(); - androidView.setOnTouchListener(ae); - androidView.setClickable(false); - androidView.setOnKeyListener(ae); - androidView.setOnFocusChangeListener(ae); - androidView.setFocusable(true); - androidView.setFocusableInTouchMode(true); - + final SurfaceHolder sh = androidView.getHolder(); sh.addCallback(WindowDriver.this); sh.setFormat(getFormat(getRequestedCapabilities())); @@ -220,7 +195,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { defineSize(0, 0); } - public SurfaceView getAndroidView() { return androidView; } + public final SurfaceView getAndroidView() { return androidView; } @Override protected boolean canCreateNativeImpl() { @@ -259,11 +234,14 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { if (EGL.EGL_NO_SURFACE==eglSurface) { throw new NativeWindowException("Creation of window surface failed: "+eglConfig+", surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", error "+toHexString(EGL.eglGetError())); } - + // propagate data .. setGraphicsConfiguration(eglConfig); setWindowHandle(surfaceHandle); focusChanged(false, true); + + setupInputListener(true); + Log.d(MD.TAG, "createNativeImpl X: eglSurfaceHandle 0x"+Long.toHexString(eglSurface)); } @@ -272,6 +250,9 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { Log.d(MD.TAG, "closeNativeImpl 0 - surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ ", eglSurfaceHandle 0x"+Long.toHexString(eglSurface)+ ", format [a "+androidFormat+", n "+nativeFormat+"], "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - "+Thread.currentThread().getName()); + + setupInputListener(false); + if(0 != eglSurface) { final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice(); if (!EGL.eglDestroySurface(eglDevice.getHandle(), eglSurface)) { @@ -289,6 +270,19 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return eglSurface; } + /** + *

    + * Accessible protected method! + *

    + * + * {@inheritDoc} + */ + @Override + public void focusChanged(boolean defer, boolean focusGained) { + super.focusChanged(defer, focusGained); + } + + @Override protected void requestFocusImpl(boolean reparented) { if(null != androidView) { Log.d(MD.TAG, "requestFocusImpl: reparented "+reparented); @@ -301,6 +295,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } } + @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { boolean res = true; @@ -330,10 +325,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return res; } + @Override protected Point getLocationOnScreenImpl(int x, int y) { return new Point(x,y); } + @Override protected void updateInsetsImpl(Insets insets) { // nop .. } @@ -367,6 +364,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } private KeyboardVisibleReceiver keyboardVisibleReceiver = new KeyboardVisibleReceiver(); + @Override protected final boolean setKeyboardVisibleImpl(boolean visible) { if(null != androidView) { final InputMethodManager imm = (InputMethodManager) getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); @@ -388,10 +386,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { // Surface Callbacks // + @Override public void surfaceCreated(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceCreated: "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } + @Override public void surfaceChanged(SurfaceHolder aHolder, int aFormat, int aWidth, int aHeight) { Log.d(MD.TAG, "surfaceChanged: f "+nativeFormat+" -> "+aFormat+", "+aWidth+"x"+aHeight+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle)); if(0!=surfaceHandle && androidFormat != aFormat ) { @@ -436,11 +436,13 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { Log.d(MD.TAG, "surfaceChanged: X"); } + @Override public void surfaceDestroyed(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceDestroyed"); windowDestroyNotify(true); // actually too late .. however .. } + @Override public void surfaceRedrawNeeded(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceRedrawNeeded"); windowRepaint(0, 0, getWidth(), getHeight()); diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index d23b5f576..dc1e8aeef 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -28,38 +28,81 @@ package jogamp.newt.driver.android.event; -import java.awt.event.MouseEvent; - -import com.jogamp.common.util.IntIntHashMap; +import com.jogamp.common.os.AndroidVersion; import com.jogamp.newt.Window; import com.jogamp.newt.event.InputEvent; public class AndroidNewtEventFactory { - protected static final IntIntHashMap eventTypeANDROID2NEWT; - - private static final String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" , - "POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" }; + private static final String names[] = { "DOWN" , "UP" , "MOVE", "CANCEL" , "OUTSIDE", // 0 - 4 + "POINTER_DOWN" , "POINTER_UP" , "HOVER_MOVE" , "SCROLL", // 5 - 8 + "HOVER_ENTER", "HOVER_EXIT" // 0 - 10 + }; - static { - IntIntHashMap map = new IntIntHashMap(); - map.setKeyNotFoundValue(0xFFFFFFFF); - - map.put(android.view.MotionEvent.ACTION_DOWN, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); - map.put(android.view.MotionEvent.ACTION_UP, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); - map.put(android.view.MotionEvent.ACTION_CANCEL, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); - map.put(android.view.MotionEvent.ACTION_MOVE, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED); - map.put(android.view.MotionEvent.ACTION_OUTSIDE, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED); - - map.put(android.view.MotionEvent.ACTION_POINTER_DOWN, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); - map.put(android.view.MotionEvent.ACTION_POINTER_UP, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); - - map.put(android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS); - - eventTypeANDROID2NEWT = map; + /** API Level 12: {@link android.view.MotionEvent#ACTION_SCROLL} = {@value} */ + private static final int ACTION_SCROLL = 8; + + private static final int aMotionEventType2Newt(int aType) { + final int nType; + switch( aType ) { + case android.view.MotionEvent.ACTION_DOWN: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; + break; + case android.view.MotionEvent.ACTION_UP: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; + break; + case android.view.MotionEvent.ACTION_MOVE: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED; + break; + case android.view.MotionEvent.ACTION_CANCEL: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; + break; + case android.view.MotionEvent.ACTION_OUTSIDE: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED; + break; + // + case android.view.MotionEvent.ACTION_POINTER_DOWN: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; + break; + case android.view.MotionEvent.ACTION_POINTER_UP: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; + break; + // case ACTION_HOVER_MOVE + case ACTION_SCROLL: // API Level 12 ! + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + break; + // case ACTION_HOVER_ENTER + // case ACTION_HOVER_EXIT + default: + nType = 0xFFFFFFFF; + } + return nType; + } + + private static final int aAccessibilityEventType2Newt(int aType) { + final int nType; + switch( aType ) { + case android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED: + nType = com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; break; + default: + nType = 0xFFFFFFFF; + } + return nType; } - static final int androidKeyCode2Newt(int androidKeyCode) { + private static final int aKeyEventType2NewtEventType(int androidKeyAction) { + switch(androidKeyAction) { + case android.view.KeyEvent.ACTION_DOWN: + case android.view.KeyEvent.ACTION_MULTIPLE: + return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED; + case android.view.KeyEvent.ACTION_UP: + return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED; + default: + return 0; + } + } + + private static final int aKeyCode2NewtKeyCode(int androidKeyCode) { if(android.view.KeyEvent.KEYCODE_0 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_9) { return com.jogamp.newt.event.KeyEvent.VK_0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_0 ) ; } @@ -104,15 +147,7 @@ public class AndroidNewtEventFactory { return 0; } - public static final com.jogamp.newt.event.WindowEvent createWindowEvent(android.view.accessibility.AccessibilityEvent event, com.jogamp.newt.Window newtSource) { - int type = eventTypeANDROID2NEWT.get(event.getEventType()); - if(0xFFFFFFFF != type) { - return new com.jogamp.newt.event.WindowEvent(type, ((null==newtSource)?null:(Object)newtSource), event.getEventTime()); - } - return null; // no mapping .. - } - - static final int androidKeyModifiers2Newt(int androidMods) { + private static final int aKeyModifiers2Newt(int androidMods) { int newtMods = 0; if ((androidMods & android.view.KeyEvent.META_SYM_ON) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; if ((androidMods & android.view.KeyEvent.META_SHIFT_ON) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; @@ -121,29 +156,40 @@ public class AndroidNewtEventFactory { return newtMods; } - private static final int androidKeyAction2NewtEventType(int androidKeyAction) { - switch(androidKeyAction) { - case android.view.KeyEvent.ACTION_DOWN: - case android.view.KeyEvent.ACTION_MULTIPLE: - return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED; - case android.view.KeyEvent.ACTION_UP: - return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED; - default: - return 0; + private final NewtGestureListener gestureListener; + private final android.view.GestureDetector gestureDetector; + private final float touchSlop; + + public AndroidNewtEventFactory(android.content.Context context, android.os.Handler handler) { + gestureListener = new NewtGestureListener(); + gestureDetector = new android.view.GestureDetector(context, gestureListener, handler, false /* ignoreMultitouch */); + gestureDetector.setIsLongpressEnabled(false); // favor scroll event! + final android.view.ViewConfiguration configuration = android.view.ViewConfiguration.get(context); + touchSlop = configuration.getScaledTouchSlop(); + } + + public com.jogamp.newt.event.WindowEvent createWindowEvent(android.view.accessibility.AccessibilityEvent event, com.jogamp.newt.Window newtSource) { + final int aType = event.getEventType(); + final int nType = aAccessibilityEventType2Newt(aType); + + if(0xFFFFFFFF != nType) { + return new com.jogamp.newt.event.WindowEvent(nType, ((null==newtSource)?null:(Object)newtSource), event.getEventTime()); } + return null; // no mapping .. } + - public static final com.jogamp.newt.event.KeyEvent[] createKeyEvents(int keyCode, android.view.KeyEvent event, com.jogamp.newt.Window newtSource) { - final int type = androidKeyAction2NewtEventType(event.getAction()); + public com.jogamp.newt.event.KeyEvent[] createKeyEvents(int keyCode, android.view.KeyEvent event, com.jogamp.newt.Window newtSource) { + final int type = aKeyEventType2NewtEventType(event.getAction()); if(Window.DEBUG_MOUSE_EVENT) { System.err.println("createKeyEvent: type 0x"+Integer.toHexString(type)+", keyCode 0x"+Integer.toHexString(keyCode)+", "+event); } if(0xFFFFFFFF != type) { - final int newtKeyCode = androidKeyCode2Newt(keyCode); + final int newtKeyCode = aKeyCode2NewtKeyCode(keyCode); if(0 != newtKeyCode) { final Object src = (null==newtSource)?null:(Object)newtSource; final long unixTime = System.currentTimeMillis() + ( event.getEventTime() - android.os.SystemClock.uptimeMillis() ); - final int newtMods = androidKeyModifiers2Newt(event.getMetaState()); + final int newtMods = aKeyModifiers2Newt(event.getMetaState()); final com.jogamp.newt.event.KeyEvent ke1 = new com.jogamp.newt.event.KeyEvent( type, src, unixTime, newtMods, newtKeyCode, event.getDisplayLabel()); @@ -161,29 +207,145 @@ public class AndroidNewtEventFactory { return null; } - public static final com.jogamp.newt.event.MouseEvent[] createMouseEvents(android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { + private int gestureScrollPointerDown = 0; + + public com.jogamp.newt.event.MouseEvent[] createMouseEvents(boolean isOnTouchEvent, + android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { if(Window.DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: "+toString(event)); + System.err.println("createMouseEvent: "+toString(event)); } - int type = eventTypeANDROID2NEWT.get(event.getAction()); - if(0xFFFFFFFF != type) { - int rotation = 0; - int clickCount = 1; + + // + // Prefilter Android Event (Gesture, ..) and determine final type + // + final int aType, nType; + float[] rotationXY = null; + int rotationSource = 0; // 1 - Gesture, 2 - ACTION_SCROLL + { + final int pointerCount = event.getPointerCount(); + final boolean gestureEvent = isOnTouchEvent && pointerCount>1 && gestureDetector.onTouchEvent(event); + int _aType = 0xFFFFFFFF; + if( gestureEvent ) { + rotationXY = gestureListener.getScrollDistanceXY(); + if( null != rotationXY) { + final boolean skip = 0 == gestureScrollPointerDown; // skip 1st .. too bug distance + gestureScrollPointerDown = pointerCount; + if( skip ) { + if(Window.DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: GestureEvent Scroll Start - SKIP "+rotationXY[0]+"/"+rotationXY[1]+", gestureScrollPointerDown "+gestureScrollPointerDown); + } + return null; + } + _aType = ACTION_SCROLL; // 8 + rotationSource = 1; + } else { + throw new InternalError("Gesture Internal Error: consumed onTouchEvent, but no result (Scroll)"); + } + } + if( 0xFFFFFFFF == _aType ) { + _aType = event.getActionMasked(); + } + aType = _aType; + nType = aMotionEventType2Newt(aType); + + // + // Check whether events shall be skipped + // + if( !gestureEvent ) { + // Scroll Gesture: Wait for all pointers up - ACTION_UP, ACTION_POINTER_UP + if( 0 < gestureScrollPointerDown ) { + if( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED == nType ) { + gestureScrollPointerDown--; + } + if(Window.DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: !GestureEvent SKIP gestureScrollPointerDown "+gestureScrollPointerDown); + } + return null; + } + } + } + + if(0xFFFFFFFF != nType) { + final int clickCount = 1; int modifiers = 0; - int[] x = new int[event.getPointerCount()]; - int[] y = new int[event.getPointerCount()]; - float[] pressure = new float[event.getPointerCount()]; - int[] pointers = new int[event.getPointerCount()]; - int index = 0; - while(index < event.getPointerCount()) { - x[index] = (int)event.getX(index); - y[index] = (int)event.getY(index); - pressure[index] = event.getPressure(index); - pointers[index] = event.getPointerId(index); - index++; + if( null == rotationXY && AndroidVersion.SDK_INT >= 12 && ACTION_SCROLL == aType ) { // API Level 12 + rotationXY = new float[] { event.getAxisValue(android.view.MotionEvent.AXIS_X), + event.getAxisValue(android.view.MotionEvent.AXIS_Y) }; + rotationSource = 2; } - + + final float rotation; + if( null != rotationXY ) { + final float _rotation; + if( rotationXY[0]*rotationXY[0] > rotationXY[1]*rotationXY[1] ) { + // Horizontal + modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; + _rotation = rotationXY[0]; + } else { + // Vertical + _rotation = rotationXY[1]; + } + rotation = _rotation / touchSlop; + if(Window.DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: Scroll "+rotationXY[0]+"/"+rotationXY[1]+" -> "+_rotation+" / "+touchSlop+" -> "+rotation+" scaled -- mods "+modifiers+", source "+rotationSource); + } + } else { + rotation = 0.0f; + } + + // + // Determine newt-button and whether dedicated pointer is pressed + // + final int pCount; + final int pIndex; + final int button; + switch( aType ) { + case android.view.MotionEvent.ACTION_POINTER_DOWN: + case android.view.MotionEvent.ACTION_POINTER_UP: { + pIndex = event.getActionIndex(); + pCount = 1; + final int b = event.getPointerId(pIndex) + 1; // FIXME: Assumption that Pointer-ID starts w/ 0 ! + if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + button = b; + } else { + button = com.jogamp.newt.event.MouseEvent.BUTTON1; + } + } + break; + default: { + pIndex = 0; + pCount = event.getPointerCount(); // all + button = com.jogamp.newt.event.MouseEvent.BUTTON1; + } + } + + // + // Collect common data + // + final int[] x = new int[pCount]; + final int[] y = new int[pCount]; + final float[] pressure = new float[pCount]; + final int[] pointerIds = new int[pCount]; + { + if(Window.DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: collect ptr-data ["+pIndex+".."+(pIndex+pCount-1)+", "+pCount+"], aType "+aType+", button "+button+", gestureScrollPointerDown "+gestureScrollPointerDown); + } + int i = pIndex; + int j = 0; + while(j < pCount) { + x[j] = (int)event.getX(i); + y[j] = (int)event.getY(i); + pressure[j] = event.getPressure(i); + pointerIds[j] = event.getPointerId(i); + if(Window.DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: ptr-data["+i+" -> "+j+"] "+x[j]+"/"+y[j]+", pressure "+pressure[j]+", id "+pointerIds[j]); + } + i++; + j++; + } + } + if(null!=newtSource) { if(newtSource.isPointerConfined()) { modifiers |= InputEvent.CONFINED_MASK; @@ -195,21 +357,20 @@ public class AndroidNewtEventFactory { final Object src = (null==newtSource)?null:(Object)newtSource; final long unixTime = System.currentTimeMillis() + ( event.getEventTime() - android.os.SystemClock.uptimeMillis() ); - final int button = pointers.length==1 ? MouseEvent.BUTTON1 : 0; final com.jogamp.newt.event.MouseEvent me1 = new com.jogamp.newt.event.MouseEvent( - type, src, unixTime, - modifiers, x, y, pressure, pointers, clickCount, + nType, src, unixTime, + modifiers, x, y, pressure, pointerIds, clickCount, button, rotation); - if(type == com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED) { + if( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED == nType ) { return new com.jogamp.newt.event.MouseEvent[] { me1, new com.jogamp.newt.event.MouseEvent( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED, - src, unixTime, modifiers, x, y, pressure, pointers, clickCount, + src, unixTime, modifiers, x, y, pressure, pointerIds, clickCount, button, rotation) }; } else { - return new com.jogamp.newt.event.MouseEvent[] { me1 }; + return new com.jogamp.newt.event.MouseEvent[] { me1 }; } } return null; // no mapping .. @@ -238,6 +399,58 @@ public class AndroidNewtEventFactory { } sb.append("]" ); return sb.toString(); - } + } + + class NewtGestureListener implements android.view.GestureDetector.OnGestureListener { + private float[] scrollDistance; + + NewtGestureListener() { + scrollDistance = null; + } + + /** Returns non null w/ 2 float values, XY, if storing onScroll's XY distance - otherwise null */ + public float[] getScrollDistanceXY() { + float[] sd = scrollDistance; + scrollDistance = null; + return sd; + } + + // + // Simple feedback + // + + @Override + public void onShowPress(android.view.MotionEvent e) { + } + + @Override + public void onLongPress(android.view.MotionEvent e) { + } + + @Override + public boolean onSingleTapUp(android.view.MotionEvent e) { + return false; + } + + // + // Consumed or not consumed ! + // + + @Override + public boolean onDown(android.view.MotionEvent e) { + return false; + } + + @Override + public boolean onScroll(android.view.MotionEvent e1, android.view.MotionEvent e2, float distanceX, float distanceY) { + scrollDistance = new float[] { distanceX, distanceY }; + return true; + } + + @Override + public boolean onFling(android.view.MotionEvent e1, android.view.MotionEvent e2, float velocityX, float velocityY) { + return false; + } + }; } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java new file mode 100644 index 000000000..ee0c8f8b1 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java @@ -0,0 +1,55 @@ +package jogamp.newt.driver.android.event; + +import jogamp.newt.driver.android.WindowDriver; +import android.view.View; + +public class AndroidNewtEventTranslator implements View.OnKeyListener, View.OnTouchListener, View.OnFocusChangeListener, View.OnGenericMotionListener { + private final WindowDriver newtWindow; + private final AndroidNewtEventFactory factory; + + public AndroidNewtEventTranslator(WindowDriver newtWindow, android.content.Context context, android.os.Handler handler) { + this.newtWindow = newtWindow; + this.factory = new AndroidNewtEventFactory(context, handler); + } + + private final boolean processTouchMotionEvents(View v, android.view.MotionEvent event, boolean isOnTouchEvent) { + final com.jogamp.newt.event.MouseEvent[] newtEvents = factory.createMouseEvents(isOnTouchEvent, event, newtWindow); + if(null != newtEvents) { + newtWindow.focusChanged(false, true); + for(int i=0; iCallVoidMethod(env, javaWindow, sendMouseEventID, (ptr->select==0) ? (jint) EVENT_MOUSE_RELEASED : (jint) EVENT_MOUSE_PRESSED, (jint) 0, - (jint) ptr->x, (jint) ptr->y, 1, 0); + (jint) ptr->x, (jint) ptr->y, 1, 0.0f); } else { DBG_PRINT( "event mouse: src: %d, s:%p, i:0x%X (%d,%d)\n", userData, ptr->select, ptr->index, ptr->x, ptr->y); (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, 0, - (jint) ptr->x, (jint) ptr->y, 0, 0); + (jint) ptr->x, (jint) ptr->y, 0, 0.0f); } } break; @@ -193,7 +193,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_WindowDriver_initIDs sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); if (windowCreatedID == NULL || sizeChangedID == NULL || diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index b89b5c21d..5b826566b 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -36,36 +36,49 @@ #import "KeyEvent.h" #import "MouseEvent.h" -jint GetDeltaY(NSEvent *event, jint javaMods) { - CGFloat deltaY = 0.0; +#include + +static jfloat GetDelta(NSEvent *event, jint javaMods[]) { CGEventRef cgEvent = [event CGEvent]; + CGFloat deltaY = 0.0; + CGFloat deltaX = 0.0; + CGFloat delta = 0.0; if (CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventIsContinuous)) { // mouse pad case - deltaY = - CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis1); - // fprintf(stderr, "WHEEL/PAD: %lf\n", (double)deltaY); + deltaX = CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis2); + deltaY = CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis1); + // fprintf(stderr, "WHEEL/PAD: %lf/%lf - 0x%X\n", (double)deltaX, (double)deltaY, javaMods[0]); + if( fabsf(deltaX) > fabsf(deltaY) ) { + javaMods[0] |= EVENT_SHIFT_MASK; + delta = deltaX; + } else { + delta = deltaY; + } } else { // traditional mouse wheel case + deltaX = [event deltaX]; deltaY = [event deltaY]; - // fprintf(stderr, "WHEEL/TRAD: %lf\n", (double)deltaY); - if (deltaY == 0.0 && (javaMods & EVENT_SHIFT_MASK) != 0) { + // fprintf(stderr, "WHEEL/TRACK: %lf/%lf - 0x%X\n", (double)deltaX, (double)deltaY, javaMods[0]); + if (deltaY == 0.0 && (javaMods[0] & EVENT_SHIFT_MASK) != 0) { // shift+vertical wheel scroll produces horizontal scroll // we convert it to vertical - deltaY = [event deltaX]; + delta = deltaX; + } else { + delta = deltaY; } - if (-1.0 < deltaY && deltaY < 1.0) { - deltaY *= 10.0; + if (-1.0 < delta && delta < 1.0) { + delta *= 10.0; } else { - if (deltaY < 0.0) { - deltaY = deltaY - 0.5f; + if (delta < 0.0) { + delta = delta - 0.5f; } else { - deltaY = deltaY + 0.5f; + delta = delta + 0.5f; } } } - // fprintf(stderr, "WHEEL/res: %d\n", (int)deltaY); - return (jint) deltaY; + // fprintf(stderr, "WHEEL/RES: %lf - 0x%X\n", (double)delta, javaMods[0]); + return (jfloat) delta; } static jmethodID enqueueMouseEventID = NULL; @@ -328,8 +341,8 @@ static jmethodID windowRepaintID = NULL; + (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz { - enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); + enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIIF)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V"); sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); @@ -686,15 +699,16 @@ static jint mods2JavaMods(NSUInteger mods) DBG_PRINT("sendMouseEvent: null JNIEnv\n"); return; } - jint javaMods = mods2JavaMods([event modifierFlags]); + jint javaMods[] = { 0 } ; + javaMods[0] = mods2JavaMods([event modifierFlags]); // convert to 1-based button number (or use zero if no button is involved) // TODO: detect mouse button when mouse wheel scrolled jint javaButtonNum = 0; - jint scrollDeltaY = 0; + jfloat scrollDeltaY = 0.0f; switch ([event type]) { case NSScrollWheel: { - scrollDeltaY = GetDeltaY(event, javaMods); + scrollDeltaY = GetDelta(event, javaMods); javaButtonNum = 1; break; } @@ -727,12 +741,12 @@ static jint mods2JavaMods(NSUInteger mods) #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, javaWindowObject, sendMouseEventID, - evType, javaMods, + evType, javaMods[0], (jint) location.x, (jint) location.y, javaButtonNum, scrollDeltaY); #else (*env)->CallVoidMethod(env, javaWindowObject, enqueueMouseEventID, JNI_FALSE, - evType, javaMods, + evType, javaMods[0], (jint) location.x, (jint) location.y, javaButtonNum, scrollDeltaY); #endif diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index b20717acc..17b93cfce 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -53,9 +53,13 @@ #define WM_MOUSEWHEEL 0x020A #endif //WM_MOUSEWHEEL -#ifndef WHEEL_DELTA -#define WHEEL_DELTA 120 -#endif //WHEEL_DELTA +#ifndef WM_MOUSEHWHEEL +#define WM_MOUSEHWHEEL 0x020E +#endif //WM_MOUSEHWHEEL + +#ifndef WHEEL_DELTAf +#define WHEEL_DELTAf (120.0f) +#endif //WHEEL_DELTAf #ifndef WHEEL_PAGESCROLL #define WHEEL_PAGESCROLL (UINT_MAX) @@ -64,6 +68,23 @@ #ifndef GET_WHEEL_DELTA_WPARAM // defined for (_WIN32_WINNT >= 0x0500) #define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam)) #endif +#ifndef GET_KEYSTATE_WPARAM +#define GET_KEYSTATE_WPARAM(wParam) ((short)LOWORD(wParam)) +#endif + +#ifndef WM_HSCROLL +#define WM_HSCROLL 0x0114 +#endif +#ifndef WM_VSCROLL +#define WM_VSCROLL 0x0115 +#endif + +#ifndef WH_MOUSE +#define WH_MOUSE 7 +#endif +#ifndef WH_MOUSE_LL +#define WH_MOUSE_LL 14 +#endif #ifndef MONITOR_DEFAULTTONULL #define MONITOR_DEFAULTTONULL 0 @@ -796,6 +817,72 @@ static void WmSize(JNIEnv *env, jobject window, HWND wnd, UINT type) (*env)->CallVoidMethod(env, window, sizeChangedID, JNI_FALSE, w, h, JNI_FALSE); } +#ifdef TEST_MOUSE_HOOKS + +static HHOOK hookLLMP; +static HHOOK hookMP; + +static LRESULT CALLBACK HookLowLevelMouseProc (int code, WPARAM wParam, LPARAM lParam) +{ + // if (code == HC_ACTION) + { + const char *msg; + char msg_buff[128]; + switch (wParam) + { + case WM_LBUTTONDOWN: msg = "WM_LBUTTONDOWN"; break; + case WM_LBUTTONUP: msg = "WM_LBUTTONUP"; break; + case WM_MOUSEMOVE: msg = "WM_MOUSEMOVE"; break; + case WM_MOUSEWHEEL: msg = "WM_MOUSEWHEEL"; break; + case WM_MOUSEHWHEEL: msg = "WM_MOUSEHWHEEL"; break; + case WM_RBUTTONDOWN: msg = "WM_RBUTTONDOWN"; break; + case WM_RBUTTONUP: msg = "WM_RBUTTONUP"; break; + default: + sprintf(msg_buff, "Unknown msg: %u", wParam); + msg = msg_buff; + break; + }//switch + + const MSLLHOOKSTRUCT *p = (MSLLHOOKSTRUCT*)lParam; + DBG_PRINT("**** LLMP: Code: 0x%X: %s - %d/%d\n", code, msg, (int)p->pt.x, (int)p->pt.y); + //} else { + // DBG_PRINT("**** LLMP: CODE: 0x%X\n", code); + } + return CallNextHookEx(hookLLMP, code, wParam, lParam); +} + +static LRESULT CALLBACK HookMouseProc (int code, WPARAM wParam, LPARAM lParam) +{ + // if (code == HC_ACTION) + { + const char *msg; + char msg_buff[128]; + switch (wParam) + { + case WM_LBUTTONDOWN: msg = "WM_LBUTTONDOWN"; break; + case WM_LBUTTONUP: msg = "WM_LBUTTONUP"; break; + case WM_MOUSEMOVE: msg = "WM_MOUSEMOVE"; break; + case WM_MOUSEWHEEL: msg = "WM_MOUSEWHEEL"; break; + case WM_MOUSEHWHEEL: msg = "WM_MOUSEHWHEEL"; break; + case WM_RBUTTONDOWN: msg = "WM_RBUTTONDOWN"; break; + case WM_RBUTTONUP: msg = "WM_RBUTTONUP"; break; + default: + sprintf(msg_buff, "Unknown msg: %u", wParam); + msg = msg_buff; + break; + }//switch + + const MOUSEHOOKSTRUCT *p = (MOUSEHOOKSTRUCT*)lParam; + DBG_PRINT("**** MP: Code: 0x%X: %s - hwnd %p, %d/%d\n", code, msg, p->hwnd, (int)p->pt.x, (int)p->pt.y); + //} else { + // DBG_PRINT("**** MP: CODE: 0x%X\n", code); + } + return CallNextHookEx(hookMP, code, wParam, lParam); +} + +#endif + + static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT res = 0; int useDefWindowProc = 0; @@ -817,7 +904,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP env = wud->jenv; window = wud->jinstance; - // DBG_PRINT("*** WindowsWindow: thread 0x%X - window %p -> %p, 0x%X %d/%d\n", (int)GetCurrentThreadId(), wnd, window, message, (int)LOWORD(lParam), (int)HIWORD(lParam)); + // DBG_PRINT("*** WindowsWindow: thread 0x%X - window %p -> %p, msg 0x%X, %d/%d\n", (int)GetCurrentThreadId(), wnd, window, message, (int)LOWORD(lParam), (int)HIWORD(lParam)); if (NULL==window || NULL==env) { return DefWindowProc(wnd, message, wParam, lParam); @@ -921,7 +1008,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_PRESSED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 1, (jint) 0); + (jint) 1, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -930,7 +1017,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_RELEASED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 1, (jint) 0); + (jint) 1, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -941,7 +1028,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_PRESSED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 2, (jint) 0); + (jint) 2, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -950,7 +1037,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_RELEASED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 2, (jint) 0); + (jint) 2, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -961,7 +1048,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_PRESSED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 3, (jint) 0); + (jint) 3, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -970,7 +1057,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_RELEASED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 3, (jint) 0); + (jint) 3, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -979,7 +1066,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_MOVED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 0, (jint) 0); + (jint) 0, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_MOUSELEAVE: @@ -987,24 +1074,64 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_EXITED, 0, (jint) -1, (jint) -1, // fake - (jint) 0, (jint) 0); + (jint) 0, (jfloat) 0.0f); useDefWindowProc = 1; break; // Java synthesizes EVENT_MOUSE_ENTERED - case WM_MOUSEWHEEL: { + case WM_HSCROLL: { // Only delivered if windows has WS_HSCROLL, hence dead code! + int sb = LOWORD(wParam); + int modifiers = GetModifiers( FALSE, 0 ) | EVENT_SHIFT_MASK; + float rotation; + switch(sb) { + case SB_LINELEFT: + rotation = 1.0f; + break; + case SB_PAGELEFT: + rotation = 2.0f; + break; + case SB_LINERIGHT: + rotation = -1.0f; + break; + case SB_PAGERIGHT: + rotation = -1.0f; + break; + } + DBG_PRINT("*** WindowsWindow: WM_HSCROLL 0x%X, rotation %f, mods 0x%X\n", sb, rotation, modifiers); + (*env)->CallVoidMethod(env, window, sendMouseEventID, + (jint) EVENT_MOUSE_WHEEL_MOVED, + modifiers, + (jint) 0, (jint) 0, + (jint) 1, (jfloat) rotation); + useDefWindowProc = 1; + break; + } + case WM_MOUSEHWHEEL: /* tilt */ + case WM_MOUSEWHEEL: /* rotation */ { // need to convert the coordinates to component-relative int x = GET_X_LPARAM(lParam); int y = GET_Y_LPARAM(lParam); + int modifiers = GetModifiers( FALSE, 0 ); + float rotationOrTilt = (float)(GET_WHEEL_DELTA_WPARAM(wParam))/WHEEL_DELTAf; + int vKeys = GET_KEYSTATE_WPARAM(wParam); POINT eventPt; eventPt.x = x; eventPt.y = y; ScreenToClient(wnd, &eventPt); + + if( WM_MOUSEHWHEEL == message ) { + modifiers |= EVENT_SHIFT_MASK; + DBG_PRINT("*** WindowsWindow: WM_MOUSEHWHEEL %d/%d, tilt %f, vKeys 0x%X, mods 0x%X\n", + (int)eventPt.x, (int)eventPt.y, rotationOrTilt, vKeys, modifiers); + } else { + DBG_PRINT("*** WindowsWindow: WM_MOUSEWHEEL %d/%d, rotation %f, vKeys 0x%X, mods 0x%X\n", + (int)eventPt.x, (int)eventPt.y, rotationOrTilt, vKeys, modifiers); + } (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_WHEEL_MOVED, - GetModifiers( FALSE, 0 ), + modifiers, (jint) eventPt.x, (jint) eventPt.y, - (jint) 1, (jint) (GET_WHEEL_DELTA_WPARAM(wParam)/120.0f)); + (jint) 1, (jfloat) rotationOrTilt); useDefWindowProc = 1; break; } @@ -1057,8 +1184,9 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP useDefWindowProc = 1; } - if (useDefWindowProc) + if (useDefWindowProc) { return DefWindowProc(wnd, message, wParam, lParam); + } return res; } @@ -1195,7 +1323,7 @@ static void NewtScreen_scanDisplayDevices() { int i = 0; LPCTSTR name; while(NULL != (name = NewtScreen_getDisplayDeviceName(&device, i))) { - fprintf(stderr, "*** [%d]: <%s> active %d\n", i, name, ( 0 != ( device.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) ); + DBG_PRINT("*** [%d]: <%s> active %d\n", i, name, ( 0 != ( device.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) ); i++; } }*/ @@ -1335,7 +1463,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_setScree * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 - (JNIEnv *env, jclass clazz) + (JNIEnv *env, jclass clazz, jlong hInstance) { NewtCommon_init(env); @@ -1346,8 +1474,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); - enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); + enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIIF)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V"); sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V"); @@ -1367,6 +1495,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 return JNI_FALSE; } BuildDynamicKeyMapTable(); + return JNI_TRUE; } @@ -1412,6 +1541,8 @@ static void NewtWindow_setVisiblePosSize(HWND hwnd, BOOL atop, BOOL visible, UpdateWindow(hwnd); } +#define WS_DEFAULT_STYLES (WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP) + /* * Class: jogamp_newt_driver_windows_WindowDriver * Method: CreateWindow @@ -1425,7 +1556,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo HWND parentWindow = (HWND) (intptr_t) parent; const TCHAR* wndClassName = NULL; const TCHAR* wndName = NULL; - DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_TABSTOP; + DWORD windowStyle = WS_DEFAULT_STYLES | WS_VISIBLE; int x=(int)jx, y=(int)jy; int width=(int)defaultWidth, height=(int)defaultHeight; HWND window = NULL; @@ -1516,6 +1647,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo (*env)->ReleaseStringUTFChars(env, jWndName, wndName); #endif +#ifdef TEST_MOUSE_HOOKS + hookLLMP = SetWindowsHookEx(WH_MOUSE_LL, &HookLowLevelMouseProc, (HINSTANCE) (intptr_t) hInstance, 0); + hookMP = SetWindowsHookEx(WH_MOUSE_LL, &HookMouseProc, (HINSTANCE) (intptr_t) hInstance, 0); + DBG_PRINT("**** LLMP Hook %p, MP Hook %p\n", hookLLMP, hookMP); +#endif + return (jlong) (intptr_t) window; } @@ -1563,7 +1700,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_reconfigureW { HWND hwndP = (HWND) (intptr_t) parent; HWND hwnd = (HWND) (intptr_t) window; - DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN ; + DWORD windowStyle = WS_DEFAULT_STYLES; BOOL styleChange = TST_FLAG_CHANGE_DECORATION(flags) || TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_PARENTING(flags) ; DBG_PRINT( "*** WindowsWindow: reconfigureWindow0 parent %p, window %p, %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d, alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d -> styleChange %d\n", diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 3f34a16b6..85b3a14c7 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -218,8 +218,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 reparentNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "reparentNotify", "(J)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowRepaint", "(ZIIII)V"); - enqueueMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "enqueueMouseEvent", "(ZIIIIII)V"); - sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(IIIIII)V"); + enqueueMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "enqueueMouseEvent", "(ZIIIIIF)V"); + sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(IIIIIF)V"); enqueueKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "enqueueKeyEvent", "(ZIIIC)V"); sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(IIIC)V"); requestFocusID = (*env)->GetMethodID(env, X11NewtWindowClazz, "requestFocus", "(Z)V"); @@ -416,33 +416,33 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_PRESSED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #endif break; case ButtonRelease: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_RELEASED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #endif break; case MotionNotify: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, modifiers, - (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_MOVED, modifiers, - (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/); #endif break; case EnterNotify: @@ -450,11 +450,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_ENTERED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_ENTERED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #endif break; case LeaveNotify: @@ -462,11 +462,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_EXITED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_EXITED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #endif break; case KeyPress: diff --git a/src/newt/native/X11Event.c b/src/newt/native/X11Event.c index 079203400..770f60e8f 100644 --- a/src/newt/native/X11Event.c +++ b/src/newt/native/X11Event.c @@ -103,33 +103,33 @@ void X11EventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_PRESSED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #endif break; case ButtonRelease: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_RELEASED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #endif break; case MotionNotify: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, modifiers, - (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_MOVED, modifiers, - (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/); #endif break; case EnterNotify: @@ -137,11 +137,11 @@ void X11EventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_ENTERED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_ENTERED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #endif break; case LeaveNotify: @@ -149,11 +149,11 @@ void X11EventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_EXITED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_EXITED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #endif break; case KeyPress: diff --git a/src/newt/native/XCBEvent.c b/src/newt/native/XCBEvent.c index 77a3380db..f067f4b7a 100644 --- a/src/newt/native/XCBEvent.c +++ b/src/newt/native/XCBEvent.c @@ -129,11 +129,11 @@ void XCBEventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, modifiers, - (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0 /*rotation*/); + (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_PRESSED, modifiers, - (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0 /*rotation*/); + (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0.0f /*rotation*/); #endif } break; case XCB_BUTTON_RELEASE: { @@ -141,11 +141,11 @@ void XCBEventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, modifiers, - (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0 /*rotation*/); + (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_RELEASED, modifiers, - (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0 /*rotation*/); + (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0.0f /*rotation*/); #endif } break; case XCB_MOTION_NOTIFY: { @@ -153,11 +153,11 @@ void XCBEventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, modifiers, - (jint) _evt->event_x, (jint) _evt->event_y, (jint)0, 0 /*rotation*/); + (jint) _evt->event_x, (jint) _evt->event_y, (jint)0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_MOVED, modifiers, - (jint) _evt->event_x, (jint) _evt->event_y, (jint)0, 0 /*rotation*/); + (jint) _evt->event_x, (jint) _evt->event_y, (jint)0, 0.0f /*rotation*/); #endif } break; case XCB_KEY_PRESS: { diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index 0093da437..bbddf764b 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -117,7 +117,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); if (windowCreatedID == NULL || sizeChangedID == NULL || diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index cc5aae99e..43a393495 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -55,6 +55,7 @@ public class GearsES2 implements GLEventListener { private GLUniformData pmvMatrixUniform = null; private GLUniformData colorU = null; private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; + private float panX = 0.0f, panY = 0.0f; private GearsObjectES2 gear1=null, gear2=null, gear3=null; private float angle = 0.0f; private int swapInterval = 0; @@ -302,6 +303,7 @@ public class GearsES2 implements GLEventListener { st.useProgram(gl, true); pmvMatrix.glPushMatrix(); + pmvMatrix.glTranslatef(panX, panY, 0.0f); pmvMatrix.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); pmvMatrix.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); pmvMatrix.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); @@ -336,7 +338,32 @@ public class GearsES2 implements GLEventListener { } } - class GearsMouseAdapter extends MouseAdapter { + class GearsMouseAdapter implements MouseListener{ + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void mouseWheelMoved(MouseEvent e) { + float r = e.getWheelRotation() * 1.0f; + if( e.isShiftDown() ) { + // horizontal + panX -= r; // positive -> left + } else { + // vertical + panY += r; // positive -> up + } + } + public void mousePressed(MouseEvent e) { prevMouseX = e.getX(); prevMouseY = e.getY(); -- cgit v1.2.3 From 7c1b15bfb00b36e80284701b1ede992b7eb82ef4 Mon Sep 17 00:00:00 2001 From: Xerxes RÃ¥nby Date: Tue, 15 Jan 2013 15:56:31 +0100 Subject: LinuxMouseTracker: Fix inverted Y-axis & missing button release. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xerxes RÃ¥nby --- src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java index 885649d17..b8a326a6c 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java @@ -152,7 +152,7 @@ public class LinuxMouseTracker implements WindowListener { yd=b[2]; x+=xd; - y+=yd; + y-=yd; if(x<0) { x=0; @@ -161,6 +161,7 @@ public class LinuxMouseTracker implements WindowListener { y=0; } + buttonDown = 0; if(lb) { buttonDown = MouseEvent.BUTTON1; } -- cgit v1.2.3 From 50f997557b91a2f014ef0c2ea848c5c326d0cfb2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 19 Jan 2013 07:04:56 +0100 Subject: NEWT/Android: Full Lifecycle for WindowDriver; Using static ViewGroup; AWTRobotUtil: More tolerant for non AWT env.; Fix adb-launch-* - NEWT/Android WindowDriver - Full Lifecycle, remove refs on closeNative() - Respect isFullscreen() - Using static ViewGroup if available and surface not ready, allows running from main() - AWTRobotUtil: More tolerant for non AWT env. - Check for NEWT first - Only use AWT iff available, which allows running on Android - Fix adb-launch-* - Launch main/junit tests --- make/scripts/adb-launch-junit.sh | 82 +++++++ make/scripts/adb-launch-main.sh | 66 +++--- make/scripts/tests.sh | 4 +- src/newt/classes/jogamp/newt/WindowImpl.java | 7 +- .../jogamp/newt/driver/android/WindowDriver.java | 177 +++++++++++---- .../test/android/NEWTGearsES2ActivityLauncher.java | 6 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 1 - .../opengl/test/junit/util/AWTRobotUtil.java | 239 ++++++++++----------- 8 files changed, 367 insertions(+), 215 deletions(-) create mode 100644 make/scripts/adb-launch-junit.sh (limited to 'src/newt/classes') diff --git a/make/scripts/adb-launch-junit.sh b/make/scripts/adb-launch-junit.sh new file mode 100644 index 000000000..e53e76456 --- /dev/null +++ b/make/scripts/adb-launch-junit.sh @@ -0,0 +1,82 @@ +#! /bin/bash + +export HOST_UID=jogamp +# jogamp02 - 10.1.0.122 +export HOST_IP=10.1.0.122 +#export HOST_IP=10.1.0.52 +export HOST_RSYNC_ROOT=PROJECTS/JOGL + +export TARGET_UID=jogamp +#export TARGET_IP=panda02 +export TARGET_IP=jautab03 +export TARGET_ADB_PORT=5555 +export TARGET_ROOT=jogamp-test + +export BUILD_DIR=../build-android-armv6 + +if [ -e /opt-linux-x86/android-sdk-linux_x86 ] ; then + export ANDROID_HOME=/opt-linux-x86/android-sdk-linux_x86 + export PATH=$ANDROID_HOME/platform-tools:$PATH +fi + +#TSTCLASS=jogamp.android.launcher.LauncherUtil +#TSTCLASS=com.jogamp.opengl.test.android.LauncherUtil +#TSTCLASS=com.jogamp.android.launcher.NEWTLauncherMain +#TSTCLASS=com.jogamp.nativewindow.NativeWindowVersion +#TSTCLASS=com.jogamp.opengl.JoglVersion +#TSTCLASS=com.jogamp.newt.NewtVersion +#TSTCLASS=com.jogamp.newt.opengl.GLWindow +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState01NEWT +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 +#TSTCLASS=com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 +#TSTCLASS=com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo02 +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.gl2es1.gears.newt.TestGearsGL2ES1NEWT +TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT + +#D_FLAGS="\&newt.debug=all\&jogl.debug=all\&nativewindow.debug=all" +#D_FLAGS="\&newt.debug=all\&jogl.debug=all" +#D_FLAGS="\&newt.debug=all" + + +M_FLAGS="\&arg=$TSTCLASS\ +\&arg=filtertrace=true\ +\&arg=haltOnError=false\ +\&arg=haltOnFailure=false\ +\&arg=showoutput=true\ +\&arg=outputtoformatters=true\ +\&arg=logfailedtests=true\ +\&arg=logtestlistenerevents=true\ +\&arg=formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter\ +\&arg=formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,/sdcard/$TARGET_ROOT/$TSTCLASS.xml\ +" + +LOGFILE=`basename $0 .sh`.log + +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall jogamp.android.launcher +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall com.jogamp.common +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jogamp-android-launcher.apk +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/gluegen-rt-android-armeabi.apk + +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall javax.media.opengl +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jar/jogl-all-android-armeabi.apk + +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall com.jogamp.opengl.test +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jar/jogl-test-android.apk + +SHELL_CMD="\ +cd /sdcard ; \ +if [ -e $TARGET_ROOT ] ; then rm -r $TARGET_ROOT ; fi ; \ +mkdir $TARGET_ROOT ; cd $TARGET_ROOT ; \ +setprop log.redirect-stdio true ; setprop log.redirect-stderr true ; \ +am kill-all ; \ +am start -W -S -a android.intent.action.MAIN -n jogamp.android.launcher/jogamp.android.launcher.MainLauncher -d launch://jogamp.org/org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner/?pkg=com.jogamp.opengl.test$D_FLAGS$M_FLAGS \ +" + +adb connect $TARGET_IP:$TARGET_ADB_PORT +adb -s $TARGET_IP:$TARGET_ADB_PORT logcat -c +adb -s $TARGET_IP:$TARGET_ADB_PORT shell $SHELL_CMD 2>&1 | tee $LOGFILE +adb -s $TARGET_IP:$TARGET_ADB_PORT logcat -d 2>&1 | tee -a $LOGFILE + diff --git a/make/scripts/adb-launch-main.sh b/make/scripts/adb-launch-main.sh index e40cfeb11..12dcab1e4 100644 --- a/make/scripts/adb-launch-main.sh +++ b/make/scripts/adb-launch-main.sh @@ -2,15 +2,15 @@ export HOST_UID=jogamp # jogamp02 - 10.1.0.122 -#export HOST_IP=10.1.0.122 -export HOST_IP=10.1.0.52 +export HOST_IP=10.1.0.122 +#export HOST_IP=10.1.0.52 export HOST_RSYNC_ROOT=PROJECTS/JOGL export TARGET_UID=jogamp #export TARGET_IP=panda02 -export TARGET_IP=jautab01 +export TARGET_IP=jautab03 export TARGET_ADB_PORT=5555 -export TARGET_ROOT=/data/projects +export TARGET_ROOT=jogamp-test export BUILD_DIR=../build-android-armv6 @@ -36,42 +36,38 @@ fi #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.gl2es1.gears.newt.TestGearsGL2ES1NEWT TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT +#D_FLAGS="\&newt.debug=all\&jogl.debug=all\&nativewindow.debug=all" +#D_FLAGS="\&newt.debug=all\&jogl.debug=all" +D_FLAGS="\&newt.debug=all" + +#Screen: 1280 x 752 +#M_FLAGS="\&arg=-time\&arg=100000\&arg=-width\&arg=1280\&arg=-height\&arg=752" +M_FLAGS="\&arg=-time\&arg=100000\&arg=-fullscreen" + LOGFILE=`basename $0 .sh`.log -RSYNC_EXCLUDES="--delete-excluded \ - --exclude 'build-x86*/' --exclude 'build-linux*/' --exclude 'build-win*/' --exclude 'build-mac*/' \ - --exclude 'classes/' --exclude 'src/' --exclude '.git/' --exclude '*-java-src.zip' \ - --exclude 'gensrc/' --exclude 'doc/' --exclude 'jnlp-files' --exclude 'archive/' \ - --exclude 'android-sdk/' --exclude 'resources/' --exclude 'scripts/' \ - --exclude 'stub_includes/' --exclude 'nbproject/' --exclude '*.log' --exclude '*.zip' --exclude '*.7z' \ - --exclude 'make/lib/external/'" +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall jogamp.android.launcher +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall com.jogamp.common +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jogamp-android-launcher.apk +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/gluegen-rt-android-armeabi.apk -echo "#! /system/bin/sh" > $BUILD_DIR/jogl-targetcommand.sh +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall javax.media.opengl +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jar/jogl-all-android-armeabi.apk -echo "\ -rsync -av --delete --delete-after $RSYNC_EXCLUDES \ - $HOST_UID@$HOST_IP::$HOST_RSYNC_ROOT/gluegen \ - $HOST_UID@$HOST_IP::$HOST_RSYNC_ROOT/jogl \ - $TARGET_ROOT ; \ -cd $TARGET_ROOT/jogl/make ; -export LD_LIBRARY_PATH=/system/lib:$TARGET_ROOT/gluegen/make/$BUILD_DIR/obj:$TARGET_ROOT/jogl/make/$BUILD_DIR/lib ; \ -# export BOOTCLASSPATH=/system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar ; -setprop log.redirect-stdio true ; setprop log.redirect-stderr true ; \ -am start -a android.intent.action.MAIN -n jogamp.android.launcher/jogamp.android.launcher.MainLauncher -d launch://jogamp.org/$TSTCLASS/?pkg=com.jogamp.opengl.test\&newt.debug=all\&jogl.debug=all\&nativewindow.debug=all \ -# \ -#dalvikvm \ -# -Xjnigreflimit:2000 \ -# -cp ../../gluegen/make/$BUILD_DIR/jogamp.android-launcher.apk:../../gluegen/make/lib/ant-junit-all.apk:../../gluegen/make/$BUILD_DIR/gluegen-rt-android-armeabi.apk:$BUILD_DIR/jar/jogl.all-android-armeabi.apk:$BUILD_DIR/jar/jogl.test.apk \ -# -Dgluegen.root=../../gluegen \ -# -Drootrel.build=build-android-armv6 \ -# com.android.internal.util.WithFramework \ -# $TSTCLASS \ -" >> $BUILD_DIR/jogl-targetcommand.sh +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall com.jogamp.opengl.test +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jar/jogl-test-android.apk +SHELL_CMD="\ +cd /sdcard ; \ +if [ -e $TARGET_ROOT ] ; then rm -r $TARGET_ROOT ; fi ; \ +mkdir $TARGET_ROOT ; cd $TARGET_ROOT ; \ +setprop log.redirect-stdio true ; setprop log.redirect-stderr true ; \ +am kill-all ; \ +am start -W -S -a android.intent.action.MAIN -n jogamp.android.launcher/jogamp.android.launcher.MainLauncher -d launch://jogamp.org/$TSTCLASS/?pkg=com.jogamp.opengl.test$D_FLAGS$M_FLAGS \ +" -chmod ugo+x $BUILD_DIR/jogl-targetcommand.sh adb connect $TARGET_IP:$TARGET_ADB_PORT -adb -s $TARGET_IP:$TARGET_ADB_PORT push $BUILD_DIR/jogl-targetcommand.sh $TARGET_ROOT/jogl-targetcommand.sh -adb -s $TARGET_IP:$TARGET_ADB_PORT shell su -c $TARGET_ROOT/jogl-targetcommand.sh 2>&1 | tee $LOGFILE - +adb -s $TARGET_IP:$TARGET_ADB_PORT logcat -c +adb -s $TARGET_IP:$TARGET_ADB_PORT shell $SHELL_CMD 2>&1 | tee $LOGFILE +adb -s $TARGET_IP:$TARGET_ADB_PORT logcat -d 2>&1 | tee -a $LOGFILE diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 46e6c63a9..a2cca3211 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -279,7 +279,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* @@ -295,7 +295,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 3c93de5b3..89c3bada6 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -278,12 +278,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer boolean postParentlockFocus = false; try { if(validateParentWindowHandle()) { - if(screenReferenceAdded) { - throw new InternalError("XXX"); - } - if(canCreateNativeImpl()) { + if( !screenReferenceAdded ) { screen.addReference(); screenReferenceAdded = true; + } + if(canCreateNativeImpl()) { createNativeImpl(); screen.addScreenModeListener(screenModeListenerImpl); setTitleImpl(title); diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index 281bd9e0f..ba5d09759 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -29,6 +29,7 @@ package jogamp.newt.driver.android; import jogamp.common.os.android.StaticContext; +import jogamp.newt.WindowImpl; import jogamp.newt.driver.android.event.AndroidNewtEventTranslator; import javax.media.nativewindow.Capabilities; @@ -43,6 +44,8 @@ import javax.media.opengl.GLException; import com.jogamp.common.os.AndroidVersion; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; +import com.jogamp.newt.Screen; +import com.jogamp.newt.ScreenMode; import jogamp.opengl.egl.EGL; import jogamp.opengl.egl.EGLGraphicsConfiguration; @@ -52,11 +55,14 @@ import android.content.Context; import android.graphics.PixelFormat; import android.os.Bundle; import android.os.IBinder; +import android.os.Looper; import android.os.ResultReceiver; import android.util.Log; +import android.view.Gravity; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceHolder.Callback2; +import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.view.SurfaceView; @@ -65,7 +71,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { DisplayDriver.initSingleton(); } - public static CapabilitiesImmutable fixCaps(boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) { + public static final CapabilitiesImmutable fixCaps(boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) { PixelFormat pf = new PixelFormat(); PixelFormat.getPixelFormatInfo(format, pf); final CapabilitiesImmutable res; @@ -104,7 +110,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return res; } - public static int getFormat(CapabilitiesImmutable rCaps) { + public static final int getFormat(CapabilitiesImmutable rCaps) { int fmt = PixelFormat.UNKNOWN; if(!rCaps.isBackgroundOpaque()) { @@ -130,7 +136,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return fmt; } - public static boolean isAndroidFormatTransparent(int aFormat) { + public static final boolean isAndroidFormatTransparent(int aFormat) { switch (aFormat) { case PixelFormat.TRANSLUCENT: case PixelFormat.TRANSPARENT: @@ -147,8 +153,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { reset(); } - private void reset() { - ownAndroidWindow = false; + private final void reset() { + added2StaticViewGroup = false; androidView = null; nativeFormat = VisualIDHolder.VID_UNDEFINED; androidFormat = VisualIDHolder.VID_UNDEFINED; @@ -157,10 +163,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { surfaceHandle = 0; eglSurface = 0; definePosition(0, 0); // default to 0/0 + defineSize(0, 0); // default size -> TBD ! + setBrokenFocusChange(true); } - private void setupInputListener(boolean enable) { + private final void setupInputListener(final boolean enable) { Log.d(MD.TAG, "setupInputListener(enable "+enable+") - "+Thread.currentThread().getName()); final AndroidNewtEventTranslator eventTranslator = @@ -169,51 +177,104 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { androidView.setOnKeyListener(eventTranslator); androidView.setOnFocusChangeListener(eventTranslator); if(AndroidVersion.SDK_INT >= 12) { // API Level 12 - Log.d(MD.TAG, "instantiationFinished() - enable GenericMotionListener - "+Thread.currentThread().getName()); + Log.d(MD.TAG, "setupInputListener - enable GenericMotionListener - "+Thread.currentThread().getName()); androidView.setOnGenericMotionListener(eventTranslator); } - androidView.setClickable(false); - androidView.setFocusable(enable); - androidView.setFocusableInTouchMode(enable); + if( enable ) { + androidView.post(new Runnable() { + public void run() { + androidView.setClickable(false); + androidView.setFocusable(true); + androidView.setFocusableInTouchMode(true); + } } ); + } } + private final void setupAndroidView(Context ctx) { + androidView = new MSurfaceView(ctx); + + final SurfaceHolder sh = androidView.getHolder(); + sh.addCallback(WindowDriver.this); + sh.setFormat(getFormat(getRequestedCapabilities())); + } + private final void removeAndroidView() { + final SurfaceHolder sh = androidView.getHolder(); + sh.removeCallback(WindowDriver.this); + androidView = null; + } + + public final SurfaceView getAndroidView() { return androidView; } + @Override - protected void instantiationFinished() { + protected final void instantiationFinished() { Log.d(MD.TAG, "instantiationFinished() - "+Thread.currentThread().getName()); - + final Context ctx = StaticContext.getContext(); if(null == ctx) { throw new NativeWindowException("No static [Application] Context has been set. Call StaticContext.setContext(Context) first."); } - androidView = new MSurfaceView(ctx); - - final SurfaceHolder sh = androidView.getHolder(); - sh.addCallback(WindowDriver.this); - sh.setFormat(getFormat(getRequestedCapabilities())); - // default size -> TBD ! - defineSize(0, 0); + if( null != Looper.myLooper() ) { + setupAndroidView(ctx); + } } - public final SurfaceView getAndroidView() { return androidView; } - @Override - protected boolean canCreateNativeImpl() { - final boolean b = 0 != surfaceHandle; - Log.d(MD.TAG, "canCreateNativeImpl: "+b); + protected final boolean canCreateNativeImpl() { + Log.d(MD.TAG, "canCreateNativeImpl.0: surfaceHandle ready "+(0!=surfaceHandle)+" - on thread "+Thread.currentThread().getName()); + if(WindowImpl.DEBUG_IMPLEMENTATION) { + Thread.dumpStack(); + } + + if( isFullscreen() ) { + final Screen screen = getScreen(); + final ScreenMode sm = screen.getCurrentScreenMode(); + definePosition(screen.getX(), screen.getY()); + defineSize(sm.getRotatedWidth(), sm.getRotatedHeight()); + } + + final boolean b; + + if( 0 == surfaceHandle ) { + // Static ViewGroup, i.e. self contained main code + final ViewGroup viewGroup = StaticContext.getContentViewGroup(); + Log.d(MD.TAG, "canCreateNativeImpl: viewGroup "+viewGroup); + if( null != viewGroup && !added2StaticViewGroup ) { + added2StaticViewGroup = true; + viewGroup.post(new Runnable() { + public void run() { + if(null == androidView) { + setupAndroidView( StaticContext.getContext() ); + } + viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(getWidth(), getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); + Log.d(MD.TAG, "canCreateNativeImpl: added to static ViewGroup - on thread "+Thread.currentThread().getName()); + } }); + for(long sleep = TIMEOUT_NATIVEWINDOW; 0 "+aFormat+", "+aWidth+"x"+aHeight+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle)); + public final void surfaceChanged(SurfaceHolder aHolder, int aFormat, int aWidth, int aHeight) { + Log.d(MD.TAG, "surfaceChanged: f "+nativeFormat+" -> "+aFormat+", "+aWidth+"x"+aHeight+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle)+" - on thread "+Thread.currentThread().getName()); + if(WindowImpl.DEBUG_IMPLEMENTATION) { + Thread.dumpStack(); + } if(0!=surfaceHandle && androidFormat != aFormat ) { // re-create Log.d(MD.TAG, "surfaceChanged (destroy old)"); @@ -437,18 +525,21 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } @Override - public void surfaceDestroyed(SurfaceHolder holder) { - Log.d(MD.TAG, "surfaceDestroyed"); + public final void surfaceDestroyed(SurfaceHolder holder) { + Log.d(MD.TAG, "surfaceDestroyed - on thread "+Thread.currentThread().getName()); + if(WindowImpl.DEBUG_IMPLEMENTATION) { + Thread.dumpStack(); + } windowDestroyNotify(true); // actually too late .. however .. } @Override - public void surfaceRedrawNeeded(SurfaceHolder holder) { - Log.d(MD.TAG, "surfaceRedrawNeeded"); + public final void surfaceRedrawNeeded(SurfaceHolder holder) { + Log.d(MD.TAG, "surfaceRedrawNeeded - on thread "+Thread.currentThread().getName()); windowRepaint(0, 0, getWidth(), getHeight()); } - private boolean ownAndroidWindow; + private boolean added2StaticViewGroup; private MSurfaceView androidView; private int nativeFormat; // chosen current native PixelFormat (suitable for EGL) private int androidFormat; // chosen current android PixelFormat (-1, -2 ..) diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java index 415efc7f2..7138ba805 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java @@ -49,7 +49,7 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); // props.setProperty("jogl.debug", "all"); // properties.setProperty("jogl.debug.GLProfile", "true"); - props.setProperty("jogl.debug.GLDrawable", "true"); + // props.setProperty("jogl.debug.GLDrawable", "true"); props.setProperty("jogl.debug.GLContext", "true"); props.setProperty("jogl.debug.GLSLCode", "true"); // props.setProperty("jogl.debug.CapabilitiesChooser", "true"); @@ -57,8 +57,8 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc // props.setProperty("jogl.debug.DebugGL", "true"); // props.setProperty("jogl.debug.TraceGL", "true"); // props.setProperty("newt.debug", "all"); - // props.setProperty("newt.debug.Window", "true"); - // props.setProperty("newt.debug.Window.MouseEvent", "true"); + props.setProperty("newt.debug.Window", "true"); + props.setProperty("newt.debug.Window.MouseEvent", "true"); props.setProperty("newt.debug.Window.KeyEvent", "true"); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 43a393495..74377a5f8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -25,7 +25,6 @@ import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; -import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseListener; import com.jogamp.opengl.test.junit.jogl.demos.GearsObject; diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index 45648bedf..ffc42e318 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -32,13 +32,10 @@ import jogamp.newt.WindowImplAccess; import java.lang.reflect.InvocationTargetException; import java.awt.AWTException; -import java.awt.Component; -import java.awt.EventQueue; -import java.awt.KeyboardFocusManager; import java.awt.Robot; -import java.awt.Toolkit; import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GLDrawable; import javax.media.opengl.awt.GLCanvas; @@ -63,77 +60,69 @@ public class AWTRobotUtil { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { System.err.println("******** clearAWTFocus.0"); - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); }}); robot.delay(ROBOT_DELAY); System.err.println("******** clearAWTFocus.X"); } - public static java.awt.Point getCenterLocation(Object obj, boolean onTitleBarIfWindow) + public static int[] getCenterLocation(Object obj, boolean onTitleBarIfWindow) throws InterruptedException, InvocationTargetException { - Component comp = null; - com.jogamp.newt.Window win = null; - if(obj instanceof com.jogamp.newt.Window) { - win = (com.jogamp.newt.Window) obj; - } else if(obj instanceof Component) { - comp = (Component) obj; + return getCenterLocationNEWT((com.jogamp.newt.Window)obj, onTitleBarIfWindow); + } else if(NativeWindowFactory.isAWTAvailable() && obj instanceof java.awt.Component) { + return getCenterLocationAWT((java.awt.Component)obj, onTitleBarIfWindow); } else { throw new RuntimeException("Neither AWT nor NEWT: "+obj); - } + } + } + private static int[] getCenterLocationNEWT(com.jogamp.newt.Window win, boolean onTitleBarIfWindow) + throws InterruptedException, InvocationTargetException { + javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null); + if( onTitleBarIfWindow ) { + javax.media.nativewindow.util.InsetsImmutable insets = win.getInsets(); + p0.translate(win.getWidth()/2, insets.getTopHeight()/2); + } else { + p0.translate(win.getWidth()/2, win.getHeight()/2); + } + return new int[] { p0.getX(), p0.getY() }; + } + private static int[] getCenterLocationAWT(java.awt.Component comp, boolean onTitleBarIfWindow) + throws InterruptedException, InvocationTargetException { int x0, y0; - if(null!=comp) { - java.awt.Point p0 = comp.getLocationOnScreen(); - java.awt.Rectangle r0 = comp.getBounds(); - if( onTitleBarIfWindow && comp instanceof java.awt.Window) { - java.awt.Window window = (java.awt.Window) comp; - java.awt.Insets insets = window.getInsets(); - y0 = (int) ( p0.getY() + insets.top / 2.0 + .5 ) ; - } else { - y0 = (int) ( p0.getY() + r0.getHeight() / 2.0 + .5 ) ; - } - x0 = (int) ( p0.getX() + r0.getWidth() / 2.0 + .5 ) ; + java.awt.Point p0 = comp.getLocationOnScreen(); + java.awt.Rectangle r0 = comp.getBounds(); + if( onTitleBarIfWindow && comp instanceof java.awt.Window) { + java.awt.Window window = (java.awt.Window) comp; + java.awt.Insets insets = window.getInsets(); + y0 = (int) ( p0.getY() + insets.top / 2.0 + .5 ) ; } else { - javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null); - if( onTitleBarIfWindow ) { - javax.media.nativewindow.util.InsetsImmutable insets = win.getInsets(); - p0.translate(win.getWidth()/2, insets.getTopHeight()/2); - } else { - p0.translate(win.getWidth()/2, win.getHeight()/2); - } - x0 = p0.getX(); - y0 = p0.getY(); + y0 = (int) ( p0.getY() + r0.getHeight() / 2.0 + .5 ) ; } - - return new java.awt.Point(x0, y0); + x0 = (int) ( p0.getX() + r0.getWidth() / 2.0 + .5 ) ; + return new int[] { x0, y0 }; } - public static java.awt.Point getClientLocation(Object obj, int x, int y) + public static int[] getClientLocation(Object obj, int x, int y) throws InterruptedException, InvocationTargetException { - Component comp = null; - com.jogamp.newt.Window win = null; - if(obj instanceof com.jogamp.newt.Window) { - win = (com.jogamp.newt.Window) obj; - } else if(obj instanceof Component) { - comp = (Component) obj; + return getClientLocationNEWT((com.jogamp.newt.Window)obj, x, y); + } else if(NativeWindowFactory.isAWTAvailable() && obj instanceof java.awt.Component) { + return getClientLocationAWT((java.awt.Component)obj, x, y); } else { throw new RuntimeException("Neither AWT nor NEWT: "+obj); - } - - int x0, y0; - if(null!=comp) { - java.awt.Point p0 = comp.getLocationOnScreen(); - x0 = (int) p0.getX() + x; - y0 = (int) p0.getY() + y; - } else { - javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null); - x0 = p0.getX() + x; - y0 = p0.getY() + y; - } - - return new java.awt.Point(x0, y0); + } + } + private static int[] getClientLocationNEWT(com.jogamp.newt.Window win, int x, int y) + throws InterruptedException, InvocationTargetException { + javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null); + return new int[] { p0.getX(), p0.getY() }; + } + private static int[] getClientLocationAWT(java.awt.Component comp, int x, int y) + throws InterruptedException, InvocationTargetException { + java.awt.Point p0 = comp.getLocationOnScreen(); + return new int[] { (int)p0.getX(), (int)p0.getY() }; } /** @@ -154,9 +143,9 @@ public class AWTRobotUtil { robot = new Robot(); robot.setAutoWaitForIdle(true); } - java.awt.Point p0 = getCenterLocation(window, false); - System.err.println("toFront: robot pos: "+p0); - robot.mouseMove( (int) p0.getX(), (int) p0.getY() ); + int[] p0 = getCenterLocation(window, false); + System.err.println("toFront: robot pos: "+p0[0]+"x"+p0[1]); + robot.mouseMove( p0[0], p0[1] ); robot.delay(ROBOT_DELAY); int wait=0; @@ -197,10 +186,10 @@ public class AWTRobotUtil { robot.setAutoWaitForIdle(true); } - java.awt.Point p0 = getCenterLocation(obj, onTitleBarIfWindow); - System.err.println("centerMouse: robot pos: "+p0+", onTitleBarIfWindow: "+onTitleBarIfWindow); + int[] p0 = getCenterLocation(obj, onTitleBarIfWindow); + System.err.println("centerMouse: robot pos: "+p0[0]+"x"+p0[1]+", onTitleBarIfWindow: "+onTitleBarIfWindow); - robot.mouseMove( (int) p0.getX(), (int) p0.getY() ); + robot.mouseMove( p0[0], p0[1] ); robot.delay(ROBOT_DELAY); } @@ -212,19 +201,19 @@ public class AWTRobotUtil { robot.setAutoWaitForIdle(true); } - java.awt.Point p0 = getClientLocation(obj, x, y); + int[] p0 = getClientLocation(obj, x, y); - robot.mouseMove( (int) p0.getX(), (int) p0.getY() ); + robot.mouseMove( p0[0], p0[1] ); robot.delay(ROBOT_DELAY); } public static int getClickTimeout(Object obj) { if(obj instanceof com.jogamp.newt.Window) { return com.jogamp.newt.event.MouseEvent.getClickTimeout(); - } else if(obj instanceof Component) { + } else if(NativeWindowFactory.isAWTAvailable() && obj instanceof java.awt.Component) { if(null == AWT_CLICK_TO) { AWT_CLICK_TO = - (Integer) Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval"); + (Integer) java.awt.Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval"); if(null == AWT_CLICK_TO) { AWT_CLICK_TO = new Integer(500); } @@ -250,32 +239,7 @@ public class AWTRobotUtil { */ public static void requestFocus(Robot robot, Object obj, boolean onTitleBarIfWindow) throws AWTException, InterruptedException, InvocationTargetException { - - final Component comp; - final com.jogamp.newt.Window win; - - if(obj instanceof com.jogamp.newt.Window) { - win = (com.jogamp.newt.Window) obj; - comp = null; - } else if(obj instanceof Component) { - win = null; - comp = (Component) obj; - } else { - throw new RuntimeException("Neither AWT nor NEWT: "+obj); - } - - if(null == robot) { - if(null!=comp) { - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - comp.requestFocus(); - System.err.println("requestFocus: AWT Component"); - }}); - } else { - win.requestFocus(); - System.err.println("requestFocus: NEWT Component"); - } - } else { + if(null != robot) { final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK; centerMouse(robot, obj, onTitleBarIfWindow); @@ -284,9 +248,30 @@ public class AWTRobotUtil { robot.mouseRelease(mouseButton); final int d = getClickTimeout(obj) + 1; robot.delay( d ); - System.err.println("requestFocus: click, d: "+d+" ms"); + System.err.println("requestFocus: click, d: "+d+" ms"); + } else { + if(obj instanceof com.jogamp.newt.Window) { + requestFocusNEWT((com.jogamp.newt.Window) obj, onTitleBarIfWindow); + } else if(NativeWindowFactory.isAWTAvailable() && obj instanceof java.awt.Component) { + requestFocusAWT((java.awt.Component) obj, onTitleBarIfWindow); + } else { + throw new RuntimeException("Neither AWT nor NEWT: "+obj); + } } } + private static void requestFocusNEWT(com.jogamp.newt.Window win, boolean onTitleBarIfWindow) + throws AWTException, InterruptedException, InvocationTargetException { + win.requestFocus(); + System.err.println("requestFocus: NEWT Component"); + } + private static void requestFocusAWT(final java.awt.Component comp, boolean onTitleBarIfWindow) + throws AWTException, InterruptedException, InvocationTargetException { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + comp.requestFocus(); + System.err.println("requestFocus: AWT Component"); + }}); + } public static void requestFocus(Robot robot, Object obj, int x, int y) throws AWTException, InterruptedException, InvocationTargetException { @@ -306,12 +291,12 @@ public class AWTRobotUtil { } public static boolean hasFocus(Object obj) { - if(obj instanceof Component) { - final Component comp = (Component) obj; - final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - return comp == kfm.getPermanentFocusOwner(); - } else if(obj instanceof com.jogamp.newt.Window) { + if(obj instanceof com.jogamp.newt.Window) { return ((com.jogamp.newt.Window) obj).hasFocus(); + } else if(NativeWindowFactory.isAWTAvailable() && obj instanceof java.awt.Component) { + final java.awt.Component comp = (java.awt.Component) obj; + final java.awt.KeyboardFocusManager kfm = java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager(); + return comp == kfm.getPermanentFocusOwner(); } else { throw new RuntimeException("Neither AWT nor NEWT: "+obj); } @@ -323,17 +308,17 @@ public class AWTRobotUtil { */ public static boolean waitForFocus(Object obj) throws InterruptedException { int wait; - if(obj instanceof Component) { - final Component comp = (Component) obj; - final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - for (wait=0; wait Date: Sat, 19 Jan 2013 22:13:34 +0100 Subject: Android/NewtVersionActivity: Dump avail. GLCaps / Use stderr, since log would cap 'em (too long). --- .../classes/com/jogamp/opengl/JoglVersion.java | 31 +++++++++++++++++----- .../newt/driver/android/NewtVersionActivity.java | 5 ++-- 2 files changed, 28 insertions(+), 8 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java index 52721e3f4..4246d74c7 100644 --- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java +++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java @@ -93,6 +93,21 @@ public class JoglVersion extends JogampVersion { return sb; } + public static StringBuilder getAllAvailableCapabilitiesInfo(AbstractGraphicsDevice device, StringBuilder sb) { + if(null==sb) { + sb = new StringBuilder(); + } + if(null == device) { + device = GLProfile.getDefaultDevice(); + } + sb.append(Platform.getNewline()).append(Platform.getNewline()); + sb.append("Desktop Capabilities: ").append(Platform.getNewline()); + getAvailableCapabilitiesInfo(GLDrawableFactory.getDesktopFactory(), device, sb); + sb.append("EGL Capabilities: ").append(Platform.getNewline()); + getAvailableCapabilitiesInfo(GLDrawableFactory.getEGLFactory(), device, sb); + return sb; + } + public static StringBuilder getDefaultOpenGLInfo(AbstractGraphicsDevice device, StringBuilder sb, boolean withCapabilitiesInfo) { if(null==sb) { sb = new StringBuilder(); @@ -107,16 +122,15 @@ public class JoglVersion extends JogampVersion { sb.append("none"); } if(withCapabilitiesInfo) { - sb.append(Platform.getNewline()).append(Platform.getNewline()); - sb.append("Desktop Capabilities: ").append(Platform.getNewline()); - getAvailableCapabilitiesInfo(GLDrawableFactory.getDesktopFactory(), device, sb); - sb.append("EGL Capabilities: ").append(Platform.getNewline()); - getAvailableCapabilitiesInfo(GLDrawableFactory.getEGLFactory(), device, sb); + sb = getAllAvailableCapabilitiesInfo(device, sb); } return sb; } public static StringBuilder getGLInfo(GL gl, StringBuilder sb) { + return getGLInfo(gl, sb, false); + } + public static StringBuilder getGLInfo(GL gl, StringBuilder sb, boolean withCapabilitiesInfo) { AbstractGraphicsDevice device = gl.getContext().getGLDrawable().getNativeSurface() .getGraphicsConfiguration().getScreen().getDevice(); if(null==sb) { @@ -129,7 +143,12 @@ public class JoglVersion extends JogampVersion { GLProfile.glAvailabilityToString(device, sb, "\t", 1); sb.append(Platform.getNewline()); - return getGLStrings(gl, sb); + sb = getGLStrings(gl, sb); + + if( withCapabilitiesInfo ) { + sb = getAllAvailableCapabilitiesInfo(device, sb); + } + return sb; } public static StringBuilder getGLStrings(GL gl, StringBuilder sb) { diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java index 4bcbb104d..de524d54c 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java @@ -79,13 +79,14 @@ public class NewtVersionActivity extends NewtBaseActivity { public void init(GLAutoDrawable drawable) { GL gl = drawable.getGL(); final StringBuffer sb = new StringBuffer(); - sb.append(JoglVersion.getGLInfo(gl, null)).append(Platform.NEWLINE); + sb.append(JoglVersion.getGLInfo(gl, null, true)).append(Platform.NEWLINE); sb.append("Requested: ").append(Platform.NEWLINE); sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); sb.append("Chosen: ").append(Platform.NEWLINE); sb.append(drawable.getChosenGLCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); final String info2 = sb.toString(); - Log.d(MD.TAG, info2); + // Log.d(MD.TAG, info2); // too big! + System.err.println(info2); viewGroup.post(new Runnable() { public void run() { tv.append(info2); -- cgit v1.2.3 From 85d70b7d38885fa8ba6374aa790d5a296acc8ec1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 20 Jan 2013 15:05:02 +0100 Subject: Android: Allow selection of native window formats RGBA8888, RGBX8888 and RGB565; Fix HiSilicon/Vivante/Immersion.16 EGLConfig selection (zero depth buffer @ visualID) - NEWT/Android Fix PixelFormat/NativeWindowFormat/VisualID Selection - Fix allows proper selection of native window formats: RGBA8888, RGBX8888 and RGB565 - Selection is performed in 3 steps: 1) @ Construction (non native): SurfaceHolder.setFormat( getSurfaceHolderFormat( caps ) ) 2) @ Native Surface Creation: getANativeWindowFormat( androidFormat) -> ANativeWindow_setBuffersGeometry(..) Note: The set native format is revalidated, i.e. read out via ANativeWindow_getFormat(..). 3) @ EGL Creation: ANativeWindow_getFormat(..) -> fixCaps(..) - simply fixing the chosen caps. - NEWT GLWindow.GLLifecycleHook.resetCounter: - Also reset GLAnimatorControl's counter, if attached. - NEWT WindowImpl -> GLLifecycleHook.resetCounter() calls issued _after_ operation before unlock(). - JOGL/EGLGraphicsConfigurationFactory - Validate whether the visualID matching EGLConfig depth buffer is suitable. On HiSilicon/Vivante/Immersion.16: Depth buffer w/ matching visualID is zero! - NativeWindow/Capabilities.compareTo: Fix alpha comparison --- make/resources/android/AndroidManifest-test.xml | 20 ++++ make/resources/android/res-test/values/strings.xml | 4 + .../opengl/egl/EGLGraphicsConfiguration.java | 11 +- .../egl/EGLGraphicsConfigurationFactory.java | 12 +- .../javax/media/nativewindow/Capabilities.java | 8 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 4 + src/newt/classes/jogamp/newt/WindowImpl.java | 14 +-- .../jogamp/newt/driver/android/WindowDriver.java | 128 ++++++++++++++------- .../opengl/test/android/NEWTGearsES2Activity.java | 15 ++- .../android/NEWTGearsES2ECTActivityLauncher.java | 75 ++++++++++++ .../NEWTGearsES2RGB565ActivityLauncher.java | 75 ++++++++++++ 11 files changed, 308 insertions(+), 58 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/android/NEWTGearsES2ECTActivityLauncher.java create mode 100644 src/test/com/jogamp/opengl/test/android/NEWTGearsES2RGB565ActivityLauncher.java (limited to 'src/newt/classes') diff --git a/make/resources/android/AndroidManifest-test.xml b/make/resources/android/AndroidManifest-test.xml index 0817b3450..5357d0a18 100644 --- a/make/resources/android/AndroidManifest-test.xml +++ b/make/resources/android/AndroidManifest-test.xml @@ -28,6 +28,26 @@ + + + + + + + + + + + + GearsES1 GearsES2 GearsES2 + Gears565 + Gears565 + GearsECT + GearsECT GearsES2T GearsES2T GraphUI1p diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index 71dfe1d0f..b1ffe608e 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -72,7 +72,14 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple this.chooser = chooser; } - public static EGLGraphicsConfiguration create(GLCapabilitiesImmutable capsRequested, AbstractGraphicsScreen absScreen, int cfgID) { + /** + * @param capsRequested + * @param absScreen + * @param eglConfigID {@link EGL#EGL_CONFIG_ID} for which the config is being created for. + * @return + * @throws GLException if invalid EGL display. + */ + public static EGLGraphicsConfiguration create(GLCapabilitiesImmutable capsRequested, AbstractGraphicsScreen absScreen, int eglConfigID) { final AbstractGraphicsDevice absDevice = absScreen.getDevice(); if(null==absDevice || !(absDevice instanceof EGLGraphicsDevice)) { throw new GLException("GraphicsDevice must be a valid EGLGraphicsDevice"); @@ -81,7 +88,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple if (dpy == EGL.EGL_NO_DISPLAY) { throw new GLException("Invalid EGL display: "+absDevice); } - final long cfg = EGLConfigId2EGLConfig(dpy, cfgID); + final long cfg = EGLConfigId2EGLConfig(dpy, eglConfigID); if(0 < cfg) { final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsRequested); final EGLGLCapabilities caps = EGLConfig2Capabilities((EGLGraphicsDevice)absDevice, capsRequested.getGLProfile(), cfg, winattrmask, false); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index f638ef82b..7e1f8a5a2 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -411,8 +411,13 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if( VisualIDHolder.VID_UNDEFINED != nativeVisualID ) { List removedCaps = new ArrayList(); for(int i=0; i 0 ) ? alphaBits : 1; - final int rgba = redBits * greenBits * blueBits * a; - - final int xa = ( caps.getAlphaBits() ) > 0 ? caps.getAlphaBits() : 1; - final int xrgba = caps.getRedBits() * caps.getGreenBits() * caps.getBlueBits() * xa; + final int rgba = redBits * greenBits * blueBits * ( alphaBits + 1 ); + + final int xrgba = caps.getRedBits() * caps.getGreenBits() * caps.getBlueBits() * ( caps.getAlphaBits() + 1 ); if(rgba > xrgba) { return 1; diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 73a4134bd..96d0f6e3b 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -443,6 +443,10 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind System.err.println("GLWindow.resetCounter() "+WindowImpl.getThreadName()); } GLWindow.this.resetFPSCounter(); + final GLAnimatorControl animator = GLWindow.this.getAnimator(); + if( null != animator ) { + animator.resetFPSCounter(); + } } @Override diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 89c3bada6..88fbfc951 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -707,10 +707,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final RecursiveLock _lock = windowLock; _lock.lock(); try { - if(null!=lifecycleHook) { - lifecycleHook.resetCounter(); - } - if(!visible && null!=childWindows && childWindows.size()>0) { synchronized(childWindowsLock) { for(int i = 0; i < childWindows.size(); i++ ) { @@ -756,6 +752,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("Window setVisible: END ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+WindowImpl.this.visible+", nativeWindowCreated: "+nativeWindowCreated+", madeVisible: "+madeVisible); } } finally { + if(null!=lifecycleHook) { + lifecycleHook.resetCounter(); + } _lock.unlock(); } if( nativeWindowCreated || madeVisible ) { @@ -1014,10 +1013,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("Window.reparent: START ("+getThreadName()+") valid "+isNativeValid()+", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+", visible "+wasVisible+", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow)+", forceDestroyCreate "+forceDestroyCreate+", "+x+"/"+y+" "+width+"x"+height); } - if(null!=lifecycleHook) { - lifecycleHook.resetCounter(); - } - if(null!=newParentWindow) { // reset position to 0/0 within parent space x = 0; @@ -1211,6 +1206,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("Window.reparentWindow: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } } finally { + if(null!=lifecycleHook) { + lifecycleHook.resetCounter(); + } _lock.unlock(); } if(wasVisible) { diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index ba5d09759..a85febca0 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -71,6 +71,82 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { DisplayDriver.initSingleton(); } + /** + * First stage of selecting an Android PixelFormat, + * at construction via {@link SurfaceHolder#setFormat(int)} + * before native realization! + * + * @param rCaps requested Capabilities + * @return An Android PixelFormat number suitable for {@link SurfaceHolder#setFormat(int)}. + */ + public static final int getSurfaceHolderFormat(CapabilitiesImmutable rCaps) { + int fmt = PixelFormat.UNKNOWN; + + if( !rCaps.isBackgroundOpaque() ) { + fmt = PixelFormat.TRANSLUCENT; + } else if( rCaps.getRedBits()<=5 && + rCaps.getGreenBits()<=6 && + rCaps.getBlueBits()<=5 && + rCaps.getAlphaBits()==0 ) { + fmt = PixelFormat.RGB_565; + } else if( rCaps.getAlphaBits()==0 ) { + fmt = PixelFormat.RGB_888; + } else { + fmt = PixelFormat.RGBA_8888; + } + Log.d(MD.TAG, "getSurfaceHolderFormat: requested: "+rCaps); + Log.d(MD.TAG, "getSurfaceHolderFormat: returned: "+fmt); + + return fmt; + } + + + public static final int NATIVE_WINDOW_FORMAT_RGBA_8888 = 1; + public static final int NATIVE_WINDOW_FORMAT_RGBX_8888 = 2; + public static final int NATIVE_WINDOW_FORMAT_RGB_565 = 4; + + /** + * Second stage of selecting an Android PixelFormat, + * at right after native (surface) realization at {@link Callback2#surfaceChanged(SurfaceHolder, int, int, int)}. + * Selection happens via {@link #setSurfaceVisualID0(long, int)} before native EGL creation. + * + * @param androidPixelFormat An Android PixelFormat delivered via {@link Callback2#surfaceChanged(SurfaceHolder, int, int, int)} params. + * @return A native Android PixelFormat number suitable for {@link #setSurfaceVisualID0(long, int)}. + */ + public static final int getANativeWindowFormat(int androidPixelFormat) { + final int nativePixelFormat; + switch(androidPixelFormat) { + case PixelFormat.RGBA_8888: + case PixelFormat.RGBA_5551: + case PixelFormat.RGBA_4444: + nativePixelFormat = NATIVE_WINDOW_FORMAT_RGBA_8888; + break; + + case PixelFormat.RGBX_8888: + case PixelFormat.RGB_888: + nativePixelFormat = NATIVE_WINDOW_FORMAT_RGBX_8888; + break; + + case PixelFormat.RGB_565: + case PixelFormat.RGB_332: + nativePixelFormat = NATIVE_WINDOW_FORMAT_RGB_565; + break; + default: nativePixelFormat = NATIVE_WINDOW_FORMAT_RGBA_8888; + } + Log.d(MD.TAG, "getANativeWindowFormat: android: "+androidPixelFormat+" -> native "+nativePixelFormat); + return nativePixelFormat; + } + + /** + * Final stage of Android PixelFormat operation, + * match the requested Capabilities w/ Android PixelFormat number. + * This is done at native realization @ {@link Callback2#surfaceChanged(SurfaceHolder, int, int, int)}. + * + * @param matchFormatPrecise + * @param format + * @param rCaps requested Capabilities + * @return The fixed Capabilities + */ public static final CapabilitiesImmutable fixCaps(boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) { PixelFormat pf = new PixelFormat(); PixelFormat.getPixelFormatInfo(format, pf); @@ -78,10 +154,10 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { int r, g, b, a; switch(format) { - case PixelFormat.RGBA_8888: r=8; g=8; b=8; a=8; break; - case PixelFormat.RGBX_8888: r=8; g=8; b=8; a=0; break; + case PixelFormat.RGBA_8888: r=8; g=8; b=8; a=8; break; // NATIVE_WINDOW_FORMAT_RGBA_8888 + case PixelFormat.RGBX_8888: r=8; g=8; b=8; a=0; break; // NATIVE_WINDOW_FORMAT_RGBX_8888 case PixelFormat.RGB_888: r=8; g=8; b=8; a=0; break; - case PixelFormat.RGB_565: r=5; g=6; b=5; a=0; break; + case PixelFormat.RGB_565: r=5; g=6; b=5; a=0; break; // NATIVE_WINDOW_FORMAT_RGB_565 case PixelFormat.RGBA_5551: r=5; g=5; b=5; a=1; break; case PixelFormat.RGBA_4444: r=4; g=4; b=4; a=4; break; case PixelFormat.RGB_332: r=3; g=3; b=2; a=0; break; @@ -110,32 +186,6 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return res; } - public static final int getFormat(CapabilitiesImmutable rCaps) { - int fmt = PixelFormat.UNKNOWN; - - if(!rCaps.isBackgroundOpaque()) { - fmt = PixelFormat.TRANSLUCENT; - } else if(rCaps.getRedBits()<=5 && - rCaps.getGreenBits()<=6 && - rCaps.getBlueBits()<=5 && - rCaps.getAlphaBits()==0) { - fmt = PixelFormat.RGB_565; - } - /* else if(rCaps.getRedBits()<=5 && - rCaps.getGreenBits()<=5 && - rCaps.getBlueBits()<=5 && - rCaps.getAlphaBits()==1) { - fmt = PixelFormat.RGBA_5551; // FIXME: Supported ? - } */ - else { - fmt = PixelFormat.RGBA_8888; - } - Log.d(MD.TAG, "getFormat: requested: "+rCaps); - Log.d(MD.TAG, "getFormat: returned: "+fmt); - - return fmt; - } - public static final boolean isAndroidFormatTransparent(int aFormat) { switch (aFormat) { case PixelFormat.TRANSLUCENT: @@ -195,12 +245,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { final SurfaceHolder sh = androidView.getHolder(); sh.addCallback(WindowDriver.this); - sh.setFormat(getFormat(getRequestedCapabilities())); - } - private final void removeAndroidView() { - final SurfaceHolder sh = androidView.getHolder(); - sh.removeCallback(WindowDriver.this); - androidView = null; + sh.setFormat(getSurfaceHolderFormat(getRequestedCapabilities())); } public final SurfaceView getAndroidView() { return androidView; } @@ -287,6 +332,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } final int nativeVisualID = eglConfig.getVisualID(VisualIDHolder.VIDType.NATIVE); Log.d(MD.TAG, "nativeVisualID 0x"+Integer.toHexString(nativeVisualID)); + Log.d(MD.TAG, "requestedCaps: "+eglConfig.getRequestedCapabilities()); + Log.d(MD.TAG, "chosenCaps : "+eglConfig.getChosenCapabilities()); if(VisualIDHolder.VID_UNDEFINED != nativeVisualID) { setSurfaceVisualID0(surfaceHandle, nativeVisualID); } @@ -334,16 +381,11 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { if( null != viewGroup) { viewGroup.post(new Runnable() { public void run() { - if(null == androidView) { - final Context ctx = StaticContext.getContext(); - setupAndroidView(ctx); - } viewGroup.removeView(androidView); Log.d(MD.TAG, "closeNativeImpl: removed from static ViewGroup - on thread "+Thread.currentThread().getName()); } }); } } - removeAndroidView(); } surface = null; @@ -504,7 +546,11 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { surface = aHolder.getSurface(); surfaceHandle = getSurfaceHandle0(surface); acquire0(surfaceHandle); + final int aNativeWindowFormat = getANativeWindowFormat(androidFormat); + setSurfaceVisualID0(surfaceHandle, aNativeWindowFormat); nativeFormat = getSurfaceVisualID0(surfaceHandle); + Log.d(MD.TAG, "surfaceChanged: androidFormat "+androidFormat+" -- (set-native "+aNativeWindowFormat+") --> nativeFormat "+nativeFormat); + final int nWidth = getWidth0(surfaceHandle); final int nHeight = getHeight0(surfaceHandle); capsByFormat = (GLCapabilitiesImmutable) fixCaps(true /* matchFormatPrecise */, nativeFormat, getRequestedCapabilities()); @@ -560,7 +606,9 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { // protected static native boolean initIDs0(); protected static native long getSurfaceHandle0(Surface surface); + /** Return the native window format via ANativeWindow_getFormat(..). */ protected static native int getSurfaceVisualID0(long surfaceHandle); + /** Set the native window format via ANativeWindow_setBuffersGeometry(..). */ protected static native void setSurfaceVisualID0(long surfaceHandle, int nativeVisualID); protected static native int getWidth0(long surfaceHandle); protected static native int getHeight0(long surfaceHandle); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java index 4468868f6..e782ac75f 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java @@ -47,6 +47,9 @@ import android.util.Log; public class NEWTGearsES2Activity extends NewtBaseActivity { static String TAG = "NEWTGearsES2Activity"; + static final String forceRGBA5650 = "demo.force.rgba5650"; + static final String forceECT = "demo.force.ect"; + @Override public void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate - 0"); @@ -54,6 +57,11 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + if( null != System.getProperty(forceRGBA5650) ) { + Log.d(TAG, "forceRGBA5650"); + caps.setRedBits(5); caps.setGreenBits(6); caps.setBlueBits(5); + } + Log.d(TAG, "req caps: "+caps); GLWindow glWindow = GLWindow.create(caps); glWindow.setFullscreen(true); @@ -81,6 +89,11 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { setAnimator(animator); // glWindow.setSkipContextReleaseThread(animator.getThread()); + if( null != System.getProperty(forceECT) ) { + Log.d(TAG, "forceECT"); + animator.setExclusiveContext(true); + } + glWindow.setVisible(true); animator.setUpdateFPSFrames(60, System.err); @@ -88,5 +101,5 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { glWindow.resetFPSCounter(); Log.d(TAG, "onCreate - X"); - } + } } diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ECTActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ECTActivityLauncher.java new file mode 100644 index 000000000..c54aa0fa6 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ECTActivityLauncher.java @@ -0,0 +1,75 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.android; + +import java.util.Arrays; +import java.util.List; + +import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; + +public class NEWTGearsES2ECTActivityLauncher extends LauncherUtil.BaseActivityLauncher { + + static String demo = "com.jogamp.opengl.test.android.NEWTGearsES2Activity"; + // static String[] pkgs = new String[] { "com.jogamp.common", "javax.media.opengl", "com.jogamp.opengl.test" }; + static String[] pkgs = new String[] { "com.jogamp.opengl.test" }; + + @Override + public void init() { + final OrderedProperties props = getProperties(); + // props.setProperty("jogamp.debug.JNILibLoader", "true"); + // props.setProperty("jogamp.debug.NativeLibrary", "true"); + // props.setProperty("jogamp.debug.IOUtil", "true"); + // properties.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); + // props.setProperty("nativewindow.debug", "all"); + props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); + // props.setProperty("jogl.debug", "all"); + // properties.setProperty("jogl.debug.GLProfile", "true"); + // props.setProperty("jogl.debug.GLDrawable", "true"); + props.setProperty("jogl.debug.GLContext", "true"); + props.setProperty("jogl.debug.GLSLCode", "true"); + // props.setProperty("jogl.debug.CapabilitiesChooser", "true"); + // props.setProperty("jogl.debug.GLSLState", "true"); + // props.setProperty("jogl.debug.DebugGL", "true"); + // props.setProperty("jogl.debug.TraceGL", "true"); + // props.setProperty("newt.debug", "all"); + props.setProperty("newt.debug.Window", "true"); + props.setProperty("newt.debug.Window.MouseEvent", "true"); + props.setProperty("newt.debug.Window.KeyEvent", "true"); + + props.setProperty("demo.force.ect", "true"); + } + + @Override + public String getActivityName() { + return demo; + } + @Override + public List getPackages() { + return Arrays.asList(pkgs); + } +} diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2RGB565ActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2RGB565ActivityLauncher.java new file mode 100644 index 000000000..fbd9b0a9c --- /dev/null +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2RGB565ActivityLauncher.java @@ -0,0 +1,75 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.android; + +import java.util.Arrays; +import java.util.List; + +import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; + +public class NEWTGearsES2RGB565ActivityLauncher extends LauncherUtil.BaseActivityLauncher { + + static String demo = "com.jogamp.opengl.test.android.NEWTGearsES2Activity"; + // static String[] pkgs = new String[] { "com.jogamp.common", "javax.media.opengl", "com.jogamp.opengl.test" }; + static String[] pkgs = new String[] { "com.jogamp.opengl.test" }; + + @Override + public void init() { + final OrderedProperties props = getProperties(); + // props.setProperty("jogamp.debug.JNILibLoader", "true"); + // props.setProperty("jogamp.debug.NativeLibrary", "true"); + // props.setProperty("jogamp.debug.IOUtil", "true"); + // properties.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); + // props.setProperty("nativewindow.debug", "all"); + props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); + // props.setProperty("jogl.debug", "all"); + // properties.setProperty("jogl.debug.GLProfile", "true"); + // props.setProperty("jogl.debug.GLDrawable", "true"); + props.setProperty("jogl.debug.GLContext", "true"); + props.setProperty("jogl.debug.GLSLCode", "true"); + // props.setProperty("jogl.debug.CapabilitiesChooser", "true"); + // props.setProperty("jogl.debug.GLSLState", "true"); + // props.setProperty("jogl.debug.DebugGL", "true"); + // props.setProperty("jogl.debug.TraceGL", "true"); + // props.setProperty("newt.debug", "all"); + props.setProperty("newt.debug.Window", "true"); + props.setProperty("newt.debug.Window.MouseEvent", "true"); + props.setProperty("newt.debug.Window.KeyEvent", "true"); + + props.setProperty("demo.force.rgba5650", "true"); + } + + @Override + public String getActivityName() { + return demo; + } + @Override + public List getPackages() { + return Arrays.asList(pkgs); + } +} -- cgit v1.2.3 From b738983638703bb721ee4c9820c8ef43e2252e73 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 24 Jan 2013 17:24:22 +0100 Subject: Bug 665 (part 1) - Allow dis-association of GLContext's GLDrawable .. Changes allowing re-association (incl. null) of GLContext/GLDrawable: - GLAutoDrawable: Refine API doc 'setContext(..)' - GLContext: Refine API doc: 'setGLDrawable(..)' 'getGLDrawable()' - GLContextImpl.setGLDrawable(): Handle null drawable - GLAutoDrawableDelegate/GLAutoDrawableBase: Allow null GLContext - GLDrawableHelper.switchContext(..)/recreateGLDrawable(): Balance GLContext.setGLDrawable(..) calls - New GLEventListenerState, holding state vector [GLEventListener, GLContext, .. ] impl. relocation of all components from/to GLAutoDrawable. - GLDrawableUtil - Using GLEventListenerState for swapGLContextAndAllGLEventListener(..) +++ NEWT Window*: - getDisplayHandle() is 'final', no more 'shortcut' code allowed due to re-association incl. display handle. - close*: - close config's device (was missing) - null config +++ Changes allowing reconfig of Display handle as required to re-associate pre-existing GLContext to a 'window': - AbstractGraphicsDevice: Add isHandleOwner() / clearHandleOwner() - Impl. in X11GraphicsDevice and EGLGraphicsDevice, NOP in DefaultGraphicsDevice - DefaultGraphicsConfiguration add 'setScreen(..)' - MutableGraphicsConfiguration - Make DefaultGraphicsConfiguration.setScreen(..) public - NativeWindowFactory add 'createScreen(String type, AbstractGraphicsDevice device, int screen)' - Refactored from SWTAccessor - NativeWindow x11ErrorHandler: Dump Stack Trace in DEBUG mode, always. --- make/scripts/tests-x64.bat | 3 +- make/scripts/tests.sh | 10 +- .../com/jogamp/opengl/GLAutoDrawableDelegate.java | 8 +- .../com/jogamp/opengl/util/GLDrawableUtil.java | 116 +------ .../classes/javax/media/opengl/GLAutoDrawable.java | 32 +- src/jogl/classes/javax/media/opengl/GLContext.java | 23 +- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 13 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 24 +- .../classes/jogamp/opengl/GLDrawableHelper.java | 31 +- .../jogamp/opengl/GLEventListenerState.java | 267 ++++++++++++++++ .../nativewindow/MutableGraphicsConfiguration.java | 7 + .../jogamp/nativewindow/egl/EGLGraphicsDevice.java | 11 +- .../com/jogamp/nativewindow/swt/SWTAccessor.java | 19 +- .../jogamp/nativewindow/x11/X11GraphicsDevice.java | 12 +- .../AbstractGraphicsConfiguration.java | 3 +- .../media/nativewindow/AbstractGraphicsDevice.java | 12 +- .../media/nativewindow/AbstractGraphicsScreen.java | 2 + .../nativewindow/DefaultGraphicsConfiguration.java | 17 +- .../media/nativewindow/DefaultGraphicsDevice.java | 19 +- .../media/nativewindow/DefaultGraphicsScreen.java | 6 +- .../media/nativewindow/NativeWindowFactory.java | 27 ++ src/nativewindow/native/x11/Xmisc.c | 2 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 18 +- src/newt/classes/jogamp/newt/WindowImpl.java | 9 +- .../jogamp/newt/driver/x11/WindowDriver.java | 10 +- .../acore/TestGLContextDrawableSwitch01NEWT.java | 330 +++++++++++++++++++ .../acore/TestGLContextDrawableSwitch11NEWT.java | 352 +++++++++++++++++++++ .../acore/TestGLContextDrawableSwitchNEWT.java | 310 ------------------ .../test/junit/util/GLEventListenerCounter.java | 65 ++++ 29 files changed, 1222 insertions(+), 536 deletions(-) create mode 100644 src/jogl/classes/jogamp/opengl/GLEventListenerState.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch11NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/util/GLEventListenerCounter.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index b66f8b8ab..8bee4c6dd 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -12,7 +12,8 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 80e418056..9625519b9 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -89,6 +89,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" @@ -105,6 +106,7 @@ function jrun() { #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas" @@ -284,7 +286,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* @@ -303,6 +306,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT $* + #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* @@ -399,7 +405,7 @@ function testawtswt() { # # newt.awt (testawt) # -testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* +#testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java index 38a8deef8..38315dc72 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java @@ -65,7 +65,10 @@ import jogamp.opengl.GLDrawableImpl; public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAutoDrawable { /** * @param drawable a valid and already realized {@link GLDrawable} - * @param context a valid {@link GLContext}, may not be made current (created) yet. + * @param context a valid {@link GLContext}, + * may not have been made current (created) yet, + * may not be associated w/ drawable yet, + * may be null for lazy initialization * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, * otherwise pass false. Closing the device is required in case @@ -78,9 +81,6 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto if(null == drawable) { throw new IllegalArgumentException("null drawable"); } - if(null == context) { - throw new IllegalArgumentException("null context"); - } if(!drawable.isRealized()) { throw new IllegalArgumentException("drawable not realized"); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java index cc81e4820..c03e4bfa4 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java @@ -27,17 +27,14 @@ */ package com.jogamp.opengl.util; -import java.util.ArrayList; -import java.util.List; - import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLRunnable; import jogamp.opengl.Debug; +import jogamp.opengl.GLEventListenerState; /** * Providing utility functions dealing w/ {@link GLDrawable}s, {@link GLAutoDrawable} and their {@link GLEventListener}. @@ -83,7 +80,7 @@ public class GLDrawableUtil { dest.addGLEventListener(listener); if(preserveInitState && initialized) { dest.setGLEventListenerInitState(listener, true); - dest.invoke(false, new ReshapeGLEventListener(listener)); + dest.invoke(false, new GLEventListenerState.ReshapeGLEventListener(listener)); } // else .. !init state is default } @@ -121,108 +118,13 @@ public class GLDrawableUtil { * @param b */ public static final void swapGLContextAndAllGLEventListener(GLAutoDrawable a, GLAutoDrawable b) { - final List aGLCmds = new ArrayList(); - final List bGLCmds = new ArrayList(); - final GLAnimatorControl aAnim = a.getAnimator(); - final GLAnimatorControl bAnim = b.getAnimator(); - final boolean aIsPaused = isAnimatorAnimatingOnOtherThread(aAnim) && aAnim.pause(); - final boolean bIsPaused = isAnimatorAnimatingOnOtherThread(bAnim) && bAnim.pause(); - - // - // remove and cache all GLEventListener and their init-state - // - final int aSz = a.getGLEventListenerCount(); - final GLEventListener[] aGLE = new GLEventListener[aSz]; - final boolean[] aInit = new boolean[aSz]; - for(int i=0; idrawable might be an inner GLDrawable instance if using a delegation pattern, - * or this GLAutoDrawable instance. + * Associate the new context, newtCtx, to this auto-drawable. *

    - * If the old or new context was current on this thread, it is being released before switching the drawable. + * The current context will be dis-associated from this auto-drawable + * via {@link GLContext#setGLDrawable(GLDrawable, boolean) setGLDrawable(null, true);} first. + *

    + *

    + * The new context will be associated with this auto-drawable + * via {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. + *

    + *

    + * If the old or new context was current on this thread, it is being released before switching the association. * The new context will be made current afterwards, if it was current before. * However the user shall take extra care that no other thread * attempts to make this context current. *

    *

    - * Be aware that the old context is still bound to the drawable, - * and that one context can only be bound to one drawable at one time! - *

    - *

    * In case you do not intend to use the old context anymore, i.e. - * not assigning it to another drawable, it shall be - * destroyed before setting the new context, i.e.: + * not assigning it to another drawable, it shall be + * destroyed, i.e.: *

    -            GLContext oldCtx = glad.getContext();
    +            GLContext oldCtx = glad.setContext(newCtx);
                 if(null != oldCtx) {
                     oldCtx.destroy();
                 }
    -            glad.setContext(newCtx);            
        * 
    - * This is required, since a context must have a valid drawable at all times - * and this API shall not restrict the user in any way. *

    * - * @param newCtx the new context - * @return the replaced GLContext, maybe null + * @param newCtx the new context, maybe null for dis-association. + * @return the previous GLContext, maybe null * * @see GLContext#setGLDrawable(GLDrawable, boolean) * @see GLContext#setGLReadDrawable(GLDrawable) diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 455f2d70d..4817add4d 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -217,15 +217,20 @@ public abstract class GLContext { /** * Sets the read/write drawable for framebuffer operations. *

    + * If the arguments reflect the current state of this context + * this method is a no-operation and returns the old and current {@link GLDrawable}. + *

    + *

    * If the context was current on this thread, it is being released before switching the drawable * and made current afterwards. However the user shall take extra care that not other thread * attempts to make this context current. Otherwise a race condition may happen. *

    - * @param readWrite the read/write drawable for framebuffer operations. - * @param setWriteOnly if true and if the current read-drawable differs - * from the write-drawable ({@link #setGLReadDrawable(GLDrawable)}), - * only change the write-drawable. Otherwise set both drawables. - * @return the replaced read/write drawable + * @param readWrite The read/write drawable for framebuffer operations, maybe null to remove association. + * @param setWriteOnly Only change the write-drawable, if setWriteOnly is true and + * if the {@link #getGLReadDrawable() read-drawable} differs + * from the {@link #getGLDrawable() write-drawable}. + * Otherwise set both drawables, read and write. + * @return The previous read/write drawable * * @throws GLException in case null is being passed or * this context is made current on another thread. @@ -239,6 +244,12 @@ public abstract class GLContext { /** * Returns the write-drawable this context uses for framebuffer operations. + *

    + * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)}, + * it equals to the write-drawable (default). + *

    + * @see #setGLDrawable(GLDrawable, boolean) + * @see #setGLReadDrawable(GLDrawable) */ public abstract GLDrawable getGLDrawable(); @@ -259,7 +270,7 @@ public abstract class GLContext { * * @param read the read-drawable for read framebuffer operations. * If null is passed, the default write drawable will be set. - * @return the replaced read-drawable + * @return the previous read-drawable * * @throws GLException in case a read drawable is not supported or * this context is made current on another thread. diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index eadd59559..c20197e72 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -74,8 +74,12 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { protected volatile boolean sendDestroy = false; // volatile: maybe written by WindowManager thread w/o locking /** - * @param drawable upstream {@link GLDrawableImpl} instance, may be null for lazy initialization - * @param context upstream {@link GLContextImpl} instance, may be null for lazy initialization + * @param drawable upstream {@link GLDrawableImpl} instance, + * may be null for lazy initialization + * @param context upstream {@link GLContextImpl} instance, + * may not have been made current (created) yet, + * may not be associated w/ drawable yet, + * may be null for lazy initialization * @param ownsDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, * otherwise pass false. Closing the device is required in case * the drawable is created w/ it's own new instance, e.g. offscreen drawables, @@ -85,6 +89,9 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { this.drawable = drawable; this.context = context; this.ownsDevice = ownsDevice; + if(null != context && null != drawable) { + context.setGLDrawable(drawable, false); + } resetFPSCounter(); } @@ -326,7 +333,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { final GLContext oldCtx = context; final boolean newCtxCurrent = GLDrawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; - if(newCtxCurrent) { + if(newCtxCurrent) { // implies null != newCtx context.makeCurrent(); } return oldCtx; diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index f2c2cfada..2a2b6a8fd 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -203,8 +203,8 @@ public abstract class GLContextImpl extends GLContext { @Override public final GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly) { - if(null==readWrite) { - throw new GLException("Null read/write drawable not allowed"); + if( drawable == readWrite && ( setWriteOnly || drawableRead == readWrite ) ) { + return drawable; // no change. } final boolean lockHeld = lock.isOwner(Thread.currentThread()); if(lockHeld) { @@ -212,16 +212,20 @@ public abstract class GLContextImpl extends GLContext { } else if(lock.isLockedByOtherThread()) { // still could glitch .. throw new GLException("GLContext current by other thread ("+lock.getOwner()+"), operation not allowed."); } - if(!setWriteOnly || drawableRead==drawable) { // if !setWriteOnly || !explicitReadDrawable + if( !setWriteOnly || drawableRead == drawable ) { // if !setWriteOnly || !explicitReadDrawable drawableRead = (GLDrawableImpl) readWrite; } final GLDrawableImpl old = drawable; - old.associateContext(this, false); - drawableRetargeted = null != drawable; + if( null != old ) { + old.associateContext(this, false); + } + drawableRetargeted |= null != drawable && readWrite != drawable; drawable = (GLDrawableImpl) readWrite ; - drawable.associateContext(this, true); - if(lockHeld) { - makeCurrent(); + if( null != drawable ) { + drawable.associateContext(this, true); + if( lockHeld ) { + makeCurrent(); + } } return old; } @@ -334,7 +338,7 @@ public abstract class GLContextImpl extends GLContext { ", surf "+toHexString(drawable.getHandle())+", isShared "+GLContextShareSet.isShared(this)+" - "+lock); } if (contextHandle != 0) { - int lockRes = drawable.lockSurface(); + final int lockRes = drawable.lockSurface(); if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { // this would be odd .. throw new GLException("Surface not ready to lock: "+drawable); @@ -408,7 +412,7 @@ public abstract class GLContextImpl extends GLContext { throw new GLException("Destination OpenGL context has not been created"); } - int lockRes = drawable.lockSurface(); + final int lockRes = drawable.lockSurface(); if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { // this would be odd .. throw new GLException("Surface not ready to lock"); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index f8c58ee34..5d113ff83 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -131,30 +131,36 @@ public class GLDrawableHelper { } /** - * Associate a new context to the drawable and also propagates the context/drawable switch by - * calling {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. - *

    - * If the old or new context was current on this thread, it is being released before switching the drawable. + * Switch {@link GLContext} / {@link GLDrawable} association. + *

    + * Dis-associate oldCtx from drawable + * via {@link GLContext#setGLDrawable(GLDrawable, boolean) oldCtx.setGLDrawable(null, true);}. *

    *

    - * Be aware that the old context is still bound to the drawable, - * and that one context can only bound to one drawable at one time! + * Re-associate newCtx with drawable + * via {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. + *

    + *

    + * If the old or new context was current on this thread, it is being released before switching the drawable. *

    *

    * No locking is being performed on the drawable, caller is required to take care of it. *

    * * @param drawable the drawable which context is changed - * @param oldCtx the old context - * @param newCtx the new context + * @param oldCtx the old context, maybe null. + * @param newCtx the new context, maybe null for dis-association. * @param newCtxCreationFlags additional creation flags if newCtx is not null and not been created yet, see {@link GLContext#setContextCreationFlags(int)} * @return true if the new context was current, otherwise false * * @see GLAutoDrawable#setContext(GLContext) */ public static final boolean switchContext(GLDrawable drawable, GLContext oldCtx, GLContext newCtx, int newCtxCreationFlags) { - if( null != oldCtx && oldCtx.isCurrent() ) { - oldCtx.release(); + if( null != oldCtx ) { + if( oldCtx.isCurrent() ) { + oldCtx.release(); + } + oldCtx.setGLDrawable(null, true); // dis-associate old pair } final boolean newCtxCurrent; if(null!=newCtx) { @@ -163,8 +169,8 @@ public class GLDrawableHelper { newCtx.release(); } newCtx.setContextCreationFlags(newCtxCreationFlags); - newCtx.setGLDrawable(drawable, true); // propagate context/drawable switch - } else { + newCtx.setGLDrawable(drawable, true); // re-associate new pair + } else { newCtxCurrent = false; } return newCtxCurrent; @@ -203,6 +209,7 @@ public class GLDrawableHelper { } context.getGL().glFinish(); context.release(); + context.setGLDrawable(null, true); // dis-associate } if(null != proxySurface) { diff --git a/src/jogl/classes/jogamp/opengl/GLEventListenerState.java b/src/jogl/classes/jogamp/opengl/GLEventListenerState.java new file mode 100644 index 000000000..dea2bc85b --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/GLEventListenerState.java @@ -0,0 +1,267 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.opengl; + +import java.util.ArrayList; +import java.util.List; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; +import javax.media.opengl.GLRunnable; + +import com.jogamp.nativewindow.MutableGraphicsConfiguration; + +/** + * GLEventListenerState is holding {@link GLAutoDrawable} components crucial + * to relocating all its {@link GLEventListener} w/ their operating {@link GLContext}, etc. + * The components are: + *
      + *
    • {@link AbstractGraphicsScreen}
    • + *
    • {@link GLCapabilitiesImmutable}
    • + *
    • {@link GLContext} operating all {@link GLEventListener}
    • + *
    • All {@link GLEventListener}
    • + *
    • All {@link GLEventListener}'s init state
    • + *
    • {@link GLAnimatorControl}
    • + *
    + *

    + * A GLEventListenerState instance can be created while components are {@link #moveFrom(GLAutoDrawable) moved from} a {@link GLAutoDrawable} + * to the new instance, which gains {@link #isOwner() ownership} of the moved components. + *

    + *

    + * A GLEventListenerState instance's components can be {@link #moveTo(GLAutoDrawable) moved to} a {@link GLAutoDrawable}, + * while loosing {@link #isOwner() ownership} of the moved components. + *

    + *

    + */ +public class GLEventListenerState { + private GLEventListenerState(AbstractGraphicsScreen screen, GLCapabilitiesImmutable caps, GLContext context, int count, GLAnimatorControl anim) { + this.screen = screen; + this.caps = caps; + this.context = context; + this.listeners = new GLEventListener[count]; + this.listenersInit = new boolean[count]; + this.anim = anim; + this.owner = true; + } + /** + * Returns true, if this instance is the current owner of the components, + * otherwise false. + *

    + * Ownership is lost if {@link #moveTo(GLAutoDrawable)} is being called successfully + * and all components are transferred to the new {@link GLAutoDrawable}. + *

    + */ + public final boolean isOwner() { return owner; } + + public final int listenerCount() { return listeners.length; } + + public final AbstractGraphicsScreen screen; + public final GLCapabilitiesImmutable caps; + public final GLContext context; + public final GLEventListener[] listeners; + public final boolean[] listenersInit; + public final GLAnimatorControl anim; + + private boolean owner; + + /** + * Last resort to destroy and loose ownership + */ + public void destroy() { + if( owner ) { + final int aSz = listenerCount(); + for(int i=0; i + * Note that all components are removed from the {@link GLAutoDrawable}, + * i.e. the {@link GLContext}, all {@link GLEventListener}. + *

    + *

    + * If the {@link GLAutoDrawable} was added to a {@link GLAnimatorControl}, it is removed + * and the {@link GLAnimatorControl} added to the GLEventListenerState. + *

    + *

    + * The returned GLEventListenerState instance is the {@link #isOwner() owner of the components}. + *

    + * + * @param a {@link GLAutoDrawable} source to move components from + * @return new GLEventListenerState instance {@link #isOwner() owning} moved components. + * + * @see #moveTo(GLAutoDrawable) + */ + public static GLEventListenerState moveFrom(GLAutoDrawable a) { + final int aSz = a.getGLEventListenerCount(); + + // Create new AbstractGraphicsScreen w/ cloned AbstractGraphicsDevice for future GLAutoDrawable + // allowing this AbstractGraphicsDevice to loose ownership -> not closing display/device! + final AbstractGraphicsConfiguration aCfg1 = a.getNativeSurface().getGraphicsConfiguration(); + final GLCapabilitiesImmutable caps1 = (GLCapabilitiesImmutable) aCfg1.getChosenCapabilities(); + final AbstractGraphicsScreen aScreen1 = aCfg1.getScreen(); + final AbstractGraphicsDevice aDevice1 = aScreen1.getDevice(); + final AbstractGraphicsDevice aDevice2 = (AbstractGraphicsDevice) aDevice1.clone(); + final AbstractGraphicsScreen aScreen2 = NativeWindowFactory.createScreen( NativeWindowFactory.getNativeWindowType(false), aDevice2, aScreen1.getIndex() ); + + final GLAnimatorControl aAnim = a.getAnimator(); + if( null != aAnim ) { + aAnim.remove(a); // also handles ECT + } + + final GLEventListenerState glls = new GLEventListenerState(aScreen2, caps1, a.getContext(), aSz, aAnim); + + // + // remove and cache all GLEventListener and their init-state + // + for(int i=0; i + * If the previous {@link GLAutoDrawable} was removed from a {@link GLAnimatorControl} by previous {@link #moveFrom(GLAutoDrawable)}, + * the given {@link GLAutoDrawable} is added to the cached {@link GLAnimatorControl}. + * This operation is skipped, if the given {@link GLAutoDrawable} is already added to a {@link GLAnimatorControl} instance. + *

    + *

    + * Note: After this operation, the GLEventListenerState reference should be released. + *

    + * + * @param a {@link GLAutoDrawable} destination to move GLEventListenerState components to + * + * @throws GLException if the {@link GLAutoDrawable}'s configuration is incompatible, i.e. different {@link GLCapabilitiesImmutable}. + * + * @see #moveFrom(GLAutoDrawable) + * @see #isOwner() + */ + public final void moveTo(GLAutoDrawable a) { + final List aGLCmds = new ArrayList(); + final int aSz = listenerCount(); + + final MutableGraphicsConfiguration aCfg = (MutableGraphicsConfiguration) a.getNativeSurface().getGraphicsConfiguration(); + final GLCapabilitiesImmutable aCaps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); + if( caps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) != aCaps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) ) { + throw new GLException("XXX: Incompatible - Prev Holder: "+caps+", New Holder "+caps); + } + final GLContext prevContext = a.getContext(); + if( null != prevContext) { + prevContext.destroy(); + } + final AbstractGraphicsScreen preScreen = aCfg.getScreen(); + aCfg.setScreen( screen ); + preScreen.getDevice().close(); + a.setContext( context ); + owner = false; + + // + // Trigger GL-Viewport reset and reshape of all initialized GLEventListeners + // + aGLCmds.add(setViewport); + for(int i=0; i= 0 is specific screen * @return - * @throws UnsupportedOperationException */ - public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) throws UnsupportedOperationException { - if( isX11 ) { - X11GraphicsDevice x11Device = (X11GraphicsDevice)device; - if(0 > screen) { - screen = x11Device.getDefaultScreen(); - } - return new X11GraphicsScreen(x11Device, screen); - } - if(0 > screen) { - screen = 0; // FIXME: Needs native API utilization - } - if( isWindows || isOSX ) { - return new DefaultGraphicsScreen(device, screen); - } - throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); + public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) { + return NativeWindowFactory.createScreen(nwt, device, screen); } public static int getNativeVisualID(AbstractGraphicsDevice device, long windowHandle) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index 0f28ca67c..da3b31de4 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -45,7 +45,7 @@ import javax.media.nativewindow.ToolkitLock; */ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneable { - final boolean handleOwner; + /* final */ boolean handleOwner; final boolean isXineramaEnabled; /** Constructs a new X11GraphicsDevice corresponding to the given connection and default @@ -153,5 +153,13 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return super.close(); } + + @Override + public boolean isHandleOwner() { + return handleOwner; + } + @Override + public void clearHandleOwner() { + handleOwner = false; + } } - diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java index ebdaf2fbb..4e45113d4 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java @@ -42,8 +42,9 @@ package javax.media.nativewindow; /** A marker interface describing a graphics configuration, visual, or pixel format in a toolkit-independent manner. */ - public interface AbstractGraphicsConfiguration extends VisualIDHolder, Cloneable { + public Object clone(); + /** * Return the screen this graphics configuration is valid for */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java index 8ecd5242d..585cd1f09 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java @@ -45,7 +45,6 @@ import jogamp.nativewindow.Debug; /** A interface describing a graphics device in a toolkit-independent manner. */ - public interface AbstractGraphicsDevice extends Cloneable { public static final boolean DEBUG = Debug.debug("GraphicsDevice"); @@ -58,6 +57,8 @@ public interface AbstractGraphicsDevice extends Cloneable { /** Default unit id for the 1st device: 0 */ public static int DEFAULT_UNIT = 0; + public Object clone(); + /** * Returns the type of the underlying subsystem, ie * NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, .. @@ -143,10 +144,17 @@ public interface AbstractGraphicsDevice extends Cloneable { *

    * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} - * issue the native close operation or skip it depending on the handles's ownership. + * issue the native close operation or skip it depending on the {@link #isHandleOwner() handles's ownership}. *

    * * @return true if the handle was not null and closing was successful, otherwise false. */ public boolean close(); + + /** + * @return true if instance owns the handle to issue {@link #close()}, otherwise false. + */ + public boolean isHandleOwner(); + + public void clearHandleOwner(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java index eb2cc9120..acb98073b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java @@ -44,6 +44,8 @@ package javax.media.nativewindow; */ public interface AbstractGraphicsScreen extends Cloneable { + public Object clone(); + /** * Return the device this graphics configuration is valid for */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java index a33c3792a..6b23172e1 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java @@ -93,25 +93,26 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics /** * Set the capabilities to a new value. * + *

    * The use case for setting the Capabilities at a later time is - * a change of the graphics device in a multi-screen environment.
    - * + * a change or re-validation of capabilities. + *

    * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen) */ protected void setChosenCapabilities(CapabilitiesImmutable capsChosen) { - capabilitiesChosen = capsChosen; + this.capabilitiesChosen = capsChosen; } /** * Set a new screen. * + *

    * the use case for setting a new screen at a later time is - * a change of the graphics device in a multi-screen environment.
    - * - * A copy of the passed object is being used. + * a change of the graphics device in a multi-screen environment. + *

    */ - final protected void setScreen(DefaultGraphicsScreen screen) { - this.screen = (AbstractGraphicsScreen) screen.clone(); + protected void setScreen(AbstractGraphicsScreen screen) { + this.screen = screen; } @Override diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java index 9288652d9..b3ae4628c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java @@ -37,10 +37,10 @@ import jogamp.nativewindow.NativeWindowFactoryImpl; public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice { private static final String separator = "_"; - private String type; - protected String connection; - protected int unitID; - protected String uniqueID; + private final String type; + protected final String connection; + protected final int unitID; + protected final String uniqueID; protected long handle; protected ToolkitLock toolkitLock; @@ -170,9 +170,18 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice return false; } + @Override + public boolean isHandleOwner() { + return false; + } + + @Override + public void clearHandleOwner() { + } + @Override public String toString() { - return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", "+toolkitLock+"]"; + return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", owner "+isHandleOwner()+", "+toolkitLock+"]"; } /** diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java index f50bd0e14..9fa58c7a3 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java @@ -33,8 +33,8 @@ package javax.media.nativewindow; public class DefaultGraphicsScreen implements Cloneable, AbstractGraphicsScreen { - AbstractGraphicsDevice device; - private int idx; + private final AbstractGraphicsDevice device; + private final int idx; public DefaultGraphicsScreen(AbstractGraphicsDevice device, int idx) { this.device = device; @@ -57,7 +57,7 @@ public class DefaultGraphicsScreen implements Cloneable, AbstractGraphicsScreen public AbstractGraphicsDevice getDevice() { return device; } - + public int getIndex() { return idx; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index d7f28a986..07702c762 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -48,6 +48,10 @@ import jogamp.nativewindow.ResourceToolkitLock; import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; /** Provides a pluggable mechanism for arbitrary window toolkits to adapt their components to the {@link NativeWindow} interface, @@ -428,6 +432,29 @@ public abstract class NativeWindowFactory { return NativeWindowFactoryImpl.getNullToolkitLock(); } + /** + * @param device + * @param screen -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen + * @return newly created AbstractGraphicsScreen of given native type + */ + public static AbstractGraphicsScreen createScreen(String type, AbstractGraphicsDevice device, int screen) { + if( TYPE_X11 == type ) { + final X11GraphicsDevice x11Device = (X11GraphicsDevice)device; + if(0 > screen) { + screen = x11Device.getDefaultScreen(); + } + return new X11GraphicsScreen(x11Device, screen); + } + if(0 > screen) { + screen = 0; // FIXME: Needs native API utilization + } + if( TYPE_AWT == type ) { + final AWTGraphicsDevice awtDevice = (AWTGraphicsDevice) device; + return new AWTGraphicsScreen(awtDevice); + } + return new DefaultGraphicsScreen(device, screen); + } + /** Returns the appropriate NativeWindowFactory to handle window objects of the given type. The windowClass might be {@link NativeWindow NativeWindow}, in which case the client has diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index a8d45f288..017c52df2 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -180,7 +180,7 @@ static int errorHandlerThrowException = 0; static int x11ErrorHandler(Display *dpy, XErrorEvent *e) { - if(!errorHandlerQuiet) { + if( !errorHandlerQuiet || errorHandlerDebug ) { const char * errnoStr = strerror(errno); char errCodeStr[80]; char reqCodeStr[80]; diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 96d0f6e3b..7fccb6622 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -458,24 +458,22 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } else { t0 = 0; } - - /* if (nativeWindowCreated && null != context) { - throw new GLException("InternalError: Native Windows has been just created, but context wasn't destroyed (is not null)"); - } */ - if (null == context && visible && 0 != window.getWindowHandle() && 0 ctx1/draw2, ctx2/draw1. + */ +public class TestGLContextDrawableSwitch01NEWT extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + glp = GLProfile.getGL2ES2(); + caps = new GLCapabilities(glp); + width = 256; + height = 256; + } + + private GLAutoDrawable createGLAutoDrawable(GLCapabilities caps, int x, int y, int width, int height, WindowListener wl) throws InterruptedException { + final Window window = NewtFactory.createWindow(caps); + Assert.assertNotNull(window); + window.setPosition(x, y); + window.setSize(width, height); + window.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); + + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + + drawable.setRealized(true); + Assert.assertTrue(drawable.isRealized()); + + final GLContext context = drawable.createContext(null); + Assert.assertNotNull(context); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false, null) { + @Override + protected void destroyImplInLock() { + super.destroyImplInLock(); + window.destroy(); // destroys the actual window + } + }; + + // add basic window interaction + window.addWindowListener(new WindowAdapter() { + @Override + public void windowRepaint(WindowUpdateEvent e) { + glad.windowRepaintOp(); + } + @Override + public void windowResized(WindowEvent e) { + glad.windowResizedOp(window.getWidth(), window.getHeight()); + } + @Override + public void windowDestroyNotify(WindowEvent e) { + glad.windowDestroyNotifyOp(); + } + }); + window.addWindowListener(wl); + + return glad; + } + + @Test(timeout=30000) + public void testSwitch2WindowSingleContext() throws InterruptedException { + final QuitAdapter quitAdapter = new QuitAdapter(); + + GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter); + GLAutoDrawable glad2 = createGLAutoDrawable(caps, 2*64+width, 64, width+100, height+100, quitAdapter); + + // create single context using glad1 and assign it to glad1, + // destroy the prev. context afterwards. + { + final GLContext newCtx = glad1.createContext(null); + Assert.assertNotNull(newCtx); + final GLContext oldCtx = glad1.setContext(newCtx); + Assert.assertNotNull(oldCtx); + oldCtx.destroy(); + final int res = newCtx.makeCurrent(); + Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); + newCtx.release(); + } + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + GearsES2 gears = new GearsES2(1); + glad1.addGLEventListener(gears); + glad1.addGLEventListener(snapshotGLEventListener); + snapshotGLEventListener.setMakeSnapshot(); + + Animator animator = new Animator(); + animator.add(glad1); + animator.add(glad2); + animator.start(); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + + // switch context _and_ the demo synchronously + GLDrawableUtil.swapGLContextAndAllGLEventListener(glad1, glad2); + + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + glad1.destroy(); + glad2.destroy(); + } + + @Test(timeout=30000) + public void testSwitch2GLWindowOneDemo() throws InterruptedException { + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + final GearsES2 gears = new GearsES2(1); + final QuitAdapter quitAdapter = new QuitAdapter(); + + GLWindow glWindow1 = GLWindow.create(caps); + glWindow1.setTitle("win1"); + glWindow1.setSize(width, height); + glWindow1.setPosition(64, 64); + glWindow1.addGLEventListener(0, gears); + glWindow1.addGLEventListener(snapshotGLEventListener); + glWindow1.addWindowListener(quitAdapter); + + GLWindow glWindow2 = GLWindow.create(caps); + glWindow2.setTitle("win2"); + glWindow2.setSize(width+100, height+100); + glWindow2.setPosition(2*64+width, 64); + glWindow2.addWindowListener(quitAdapter); + + Animator animator = new Animator(); + animator.add(glWindow1); + animator.add(glWindow2); + animator.start(); + + glWindow1.setVisible(true); + glWindow2.setVisible(true); + + snapshotGLEventListener.setMakeSnapshot(); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + + // switch context _and_ the demo synchronously + GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); + + System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + + snapshotGLEventListener.setMakeSnapshot(); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + glWindow1.destroy(); + glWindow2.destroy(); + + } + + @Test(timeout=30000) + public void testSwitch2GLWindowEachWithOwnDemo() throws InterruptedException { + final GearsES2 gears = new GearsES2(1); + final RedSquareES2 rsquare = new RedSquareES2(1); + final QuitAdapter quitAdapter = new QuitAdapter(); + final SnapshotGLEventListener snapshotGLEventListener1 = new SnapshotGLEventListener(); + final SnapshotGLEventListener snapshotGLEventListener2 = new SnapshotGLEventListener(); + + GLWindow glWindow1 = GLWindow.create(caps); + glWindow1.setTitle("win1"); + glWindow1.setSize(width, height); + glWindow1.setPosition(64, 64); + glWindow1.addGLEventListener(0, gears); + glWindow1.addGLEventListener(snapshotGLEventListener1); + glWindow1.addWindowListener(quitAdapter); + + GLWindow glWindow2 = GLWindow.create(caps); + glWindow2.setTitle("win2"); + glWindow2.setSize(width+100, height+100); + glWindow2.setPosition(2*64+width, 64); + glWindow2.addGLEventListener(0, rsquare); + glWindow2.addGLEventListener(snapshotGLEventListener2); + glWindow2.addWindowListener(quitAdapter); + + Animator animator = new Animator(); + animator.add(glWindow1); + animator.add(glWindow2); + animator.start(); + + glWindow1.setVisible(true); + glWindow2.setVisible(true); + + snapshotGLEventListener1.setMakeSnapshot(); + snapshotGLEventListener2.setMakeSnapshot(); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); + System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + snapshotGLEventListener1.setMakeSnapshot(); + snapshotGLEventListener2.setMakeSnapshot(); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + // System.err.println("pre -del-w1: w1: "+glWindow1); + // System.err.println("pre -del-w1: w2: "+glWindow2); + glWindow1.destroy(); + // System.err.println("post-del-w1: w1: "+glWindow1); + // System.err.println("post-del-w1: w2: "+glWindow2); + glWindow2.destroy(); + + } + + // default timing for 2 switches + static long duration = 2200; // ms + static long period = 1000; // ms + + public static void main(String args[]) throws IOException { + for(int i=0; i + * See Bug 665 - https://jogamp.org/bugzilla/show_bug.cgi?id=665. + *

    + */ +public class TestGLContextDrawableSwitch11NEWT extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + glp = GLProfile.getGL2ES2(); + caps = new GLCapabilities(glp); + width = 256; + height = 256; + } + + private GLAutoDrawable createGLAutoDrawable(GLCapabilities caps, int x, int y, int width, int height, WindowListener wl) throws InterruptedException { + final Window window = NewtFactory.createWindow(caps); + Assert.assertNotNull(window); + window.setPosition(x, y); + window.setSize(width, height); + window.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); + + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + + drawable.setRealized(true); + Assert.assertTrue(drawable.isRealized()); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false, null) { + @Override + protected void destroyImplInLock() { + super.destroyImplInLock(); + window.destroy(); // destroys the actual window + } + }; + + // add basic window interaction + window.addWindowListener(new WindowAdapter() { + @Override + public void windowRepaint(WindowUpdateEvent e) { + glad.windowRepaintOp(); + } + @Override + public void windowResized(WindowEvent e) { + glad.windowResizedOp(window.getWidth(), window.getHeight()); + } + @Override + public void windowDestroyNotify(WindowEvent e) { + glad.windowDestroyNotifyOp(); + } + }); + window.addWindowListener(wl); + + return glad; + } + + @Test(timeout=30000) + public void test01() throws InterruptedException { + final QuitAdapter quitAdapter = new QuitAdapter(); + + final GLEventListenerCounter glelCounter = new GLEventListenerCounter(); + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + final Animator animator = new Animator(); + animator.start(); + + final long t0 = System.currentTimeMillis(); + final GLEventListenerState glls1; + + // - create glad1 w/o context + // - create context using glad1 and assign it to glad1 + { + final GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter); + final GLContext context1 = glad1.createContext(null); + glad1.setContext(context1); + animator.add(glad1); + + glad1.addGLEventListener(glelCounter); + glad1.addGLEventListener(new GearsES2(1)); + glad1.addGLEventListener(snapshotGLEventListener); + snapshotGLEventListener.setMakeSnapshot(); + + long t1 = System.currentTimeMillis(); + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/2 ) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + // - dis-associate context from glad1 + // - destroy glad1 + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(0, glelCounter.disposeCount); + Assert.assertEquals(context1, glad1.getContext()); + Assert.assertEquals(3, glad1.getGLEventListenerCount()); + Assert.assertEquals(context1.getGLReadDrawable(), glad1.getDelegatedDrawable()); + Assert.assertEquals(context1.getGLDrawable(), glad1.getDelegatedDrawable()); + + glls1 = GLEventListenerState.moveFrom(glad1); + + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(0, glelCounter.disposeCount); + Assert.assertEquals(context1, glls1.context); + Assert.assertNull(context1.getGLReadDrawable()); + Assert.assertNull(context1.getGLDrawable()); + Assert.assertEquals(3, glls1.listenerCount()); + Assert.assertEquals(true, glls1.isOwner()); + Assert.assertEquals(null, glad1.getContext()); + Assert.assertEquals(0, glad1.getGLEventListenerCount()); + + glad1.destroy(); + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(0, glelCounter.disposeCount); + } + + // - create glad2 w/ survived context + { + final GLAutoDrawable glad2 = createGLAutoDrawable(caps, 2*64+width, 64, width+100, height+100, quitAdapter); + snapshotGLEventListener.setMakeSnapshot(); + + Assert.assertEquals(null, glad2.getContext()); + Assert.assertEquals(0, glad2.getGLEventListenerCount()); + + glls1.moveTo(glad2); + + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(0, glelCounter.disposeCount); + Assert.assertEquals(glls1.context, glad2.getContext()); + Assert.assertEquals(3, glad2.getGLEventListenerCount()); + Assert.assertEquals(glls1.context.getGLReadDrawable(), glad2.getDelegatedDrawable()); + Assert.assertEquals(glls1.context.getGLDrawable(), glad2.getDelegatedDrawable()); + Assert.assertEquals(false, glls1.isOwner()); + + long t1 = System.currentTimeMillis(); + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/1 ) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + glad2.destroy(); + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(1, glelCounter.disposeCount); + } + animator.stop(); + } + + @Test(timeout=30000) + public void test02() throws InterruptedException { + final QuitAdapter quitAdapter = new QuitAdapter(); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + final GLEventListenerCounter glelTracker = new GLEventListenerCounter(); + final Animator animator = new Animator(); + animator.start(); + + final long t0 = System.currentTimeMillis(); + final GLEventListenerState glls1; + + // - create glad1 w/o context + // - create context using glad1 and assign it to glad1 + { + final GLWindow glad1 = GLWindow.create(caps); + glad1.setSize(width, height); + glad1.setPosition(64, 64); + glad1.addWindowListener(quitAdapter); + glad1.setVisible(true); + animator.add(glad1); + + glad1.addGLEventListener(glelTracker); + glad1.addGLEventListener(new GearsES2(1)); + glad1.addGLEventListener(snapshotGLEventListener); + snapshotGLEventListener.setMakeSnapshot(); + + long t1 = System.currentTimeMillis(); + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/2 ) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + // - dis-associate context from glad1 + // - destroy glad1 + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + Assert.assertEquals(0, glelTracker.disposeCount); + Assert.assertEquals(3, glad1.getGLEventListenerCount()); + Assert.assertEquals(glad1.getContext().getGLReadDrawable(), glad1.getDelegatedDrawable()); + Assert.assertEquals(glad1.getContext().getGLDrawable(), glad1.getDelegatedDrawable()); + + final GLContext context1 = glad1.getContext(); + glls1 = GLEventListenerState.moveFrom(glad1); + + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + Assert.assertEquals(0, glelTracker.disposeCount); + Assert.assertEquals(context1, glls1.context); + Assert.assertNull(context1.getGLReadDrawable()); + Assert.assertNull(context1.getGLDrawable()); + Assert.assertEquals(3, glls1.listenerCount()); + Assert.assertEquals(true, glls1.isOwner()); + Assert.assertEquals(null, glad1.getContext()); + Assert.assertEquals(0, glad1.getGLEventListenerCount()); + + glad1.destroy(); + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + Assert.assertEquals(0, glelTracker.disposeCount); + } + + // - create glad2 w/ survived context + { + final GLWindow glad2 = GLWindow.create(caps); + glad2.setSize(width+100, height+100); + glad2.setPosition(2*64+width, 64); + glad2.addWindowListener(quitAdapter); + glad2.setVisible(true); + snapshotGLEventListener.setMakeSnapshot(); + + Assert.assertNotNull(glad2.getContext()); + Assert.assertEquals(0, glad2.getGLEventListenerCount()); + + glls1.moveTo(glad2); + + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + Assert.assertEquals(0, glelTracker.disposeCount); + Assert.assertEquals(glls1.context, glad2.getContext()); + Assert.assertEquals(3, glad2.getGLEventListenerCount()); + Assert.assertEquals(glls1.context.getGLReadDrawable(), glad2.getDelegatedDrawable()); + Assert.assertEquals(glls1.context.getGLDrawable(), glad2.getDelegatedDrawable()); + Assert.assertEquals(false, glls1.isOwner()); + + long t1 = System.currentTimeMillis(); + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/1 ) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + glad2.destroy(); + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + Assert.assertEquals(1, glelTracker.disposeCount); + } + animator.stop(); + } + + // default timing for 2 switches + static long duration = 2200; // ms + + public static void main(String args[]) throws IOException { + for(int i=0; i s) { - s++; - System.err.println(s+" - switch - START "+ ( t1 - t0 )); - - // switch context _and_ the demo synchronously - GLDrawableUtil.swapGLContextAndAllGLEventListener(glad1, glad2); - - System.err.println(s+" - switch - END "+ ( t1 - t0 )); - } - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - animator.stop(); - glad1.destroy(); - glad2.destroy(); - } - - @Test(timeout=30000) - public void testSwitch2GLWindowOneDemo() throws InterruptedException { - GearsES2 gears = new GearsES2(1); - final QuitAdapter quitAdapter = new QuitAdapter(); - - GLWindow glWindow1 = GLWindow.create(caps); - glWindow1.setTitle("win1"); - glWindow1.setSize(width, height); - glWindow1.setPosition(64, 64); - glWindow1.addGLEventListener(0, gears); - glWindow1.addWindowListener(quitAdapter); - - GLWindow glWindow2 = GLWindow.create(caps); - glWindow2.setTitle("win2"); - glWindow2.setSize(width+100, height+100); - glWindow2.setPosition(2*64+width, 64); - glWindow2.addWindowListener(quitAdapter); - - Animator animator = new Animator(); - animator.add(glWindow1); - animator.add(glWindow2); - animator.start(); - - glWindow1.setVisible(true); - glWindow2.setVisible(true); - - int s = 0; - long t0 = System.currentTimeMillis(); - long t1 = t0; - - while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { - if( ( t1 - t0 ) / period > s) { - s++; - System.err.println(s+" - switch - START "+ ( t1 - t0 )); - System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); - System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); - - // switch context _and_ the demo synchronously - GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); - - System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); - System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); - System.err.println(s+" - switch - END "+ ( t1 - t0 )); - } - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - animator.stop(); - glWindow1.destroy(); - glWindow2.destroy(); - - } - - @Test(timeout=30000) - public void testSwitch2GLWindowEachWithOwnDemo() throws InterruptedException { - GearsES2 gears = new GearsES2(1); - RedSquareES2 rsquare = new RedSquareES2(1); - final QuitAdapter quitAdapter = new QuitAdapter(); - - GLWindow glWindow1 = GLWindow.create(caps); - glWindow1.setTitle("win1"); - glWindow1.setSize(width, height); - glWindow1.setPosition(64, 64); - glWindow1.addGLEventListener(0, gears); - glWindow1.addWindowListener(quitAdapter); - - GLWindow glWindow2 = GLWindow.create(caps); - glWindow2.setTitle("win2"); - glWindow2.setSize(width+100, height+100); - glWindow2.setPosition(2*64+width, 64); - glWindow2.addGLEventListener(0, rsquare); - glWindow2.addWindowListener(quitAdapter); - - Animator animator = new Animator(); - animator.add(glWindow1); - animator.add(glWindow2); - animator.start(); - - glWindow1.setVisible(true); - glWindow2.setVisible(true); - - int s = 0; - long t0 = System.currentTimeMillis(); - long t1 = t0; - - while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { - if( ( t1 - t0 ) / period > s) { - s++; - System.err.println(s+" - switch - START "+ ( t1 - t0 )); - System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); - System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); - GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); - System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); - System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); - System.err.println(s+" - switch - END "+ ( t1 - t0 )); - } - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - animator.stop(); - // System.err.println("pre -del-w1: w1: "+glWindow1); - // System.err.println("pre -del-w1: w2: "+glWindow2); - glWindow1.destroy(); - // System.err.println("post-del-w1: w1: "+glWindow1); - // System.err.println("post-del-w1: w2: "+glWindow2); - glWindow2.destroy(); - - } - - // default timing for 2 switches - static long duration = 2200; // ms - static long period = 1000; // ms - - public static void main(String args[]) throws IOException { - for(int i=0; i Date: Sun, 27 Jan 2013 05:48:13 +0100 Subject: Fix regression of commit b738983638703bb721ee4c9820c8ef43e2252e73, possible 'pulling' display's device - check references --- src/newt/classes/jogamp/newt/WindowImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index d033a8794..cb43fae32 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -879,7 +879,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( isNativeValid() ) { screen.removeScreenModeListener(screenModeListenerImpl); closeNativeImpl(); - config.getScreen().getDevice().close(); + final AbstractGraphicsDevice cfgADevice = config.getScreen().getDevice(); + if( cfgADevice != screen.getDisplay().getGraphicsDevice() ) { // don't pull display's device + cfgADevice.close(); // ensure a cfg's device is closed + } setGraphicsConfiguration(null); removeScreenReference(); } -- cgit v1.2.3 From 2f63a43fd6ff9964251c43e248c51bc821f3ecbd Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 28 Jan 2013 16:15:50 +0100 Subject: Add WindowClosingProtocol impact detail on WindowListener.windowDestroyNotify(..) --- src/newt/classes/com/jogamp/newt/event/WindowListener.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/WindowListener.java b/src/newt/classes/com/jogamp/newt/event/WindowListener.java index e841a06cf..011e1f654 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowListener.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowListener.java @@ -34,6 +34,8 @@ package com.jogamp.newt.event; +import javax.media.nativewindow.WindowClosingProtocol; + public interface WindowListener extends NEWTEventListener { /** Window is resized, your application shall respect the new window dimension. A repaint is recommended. */ public void windowResized(WindowEvent e); @@ -41,7 +43,14 @@ public interface WindowListener extends NEWTEventListener { /** Window has been moved. */ public void windowMoved(WindowEvent e); - /** Window will be destroyed. Release of resources is recommended. */ + /** + * Window destruction has been requested. + *

    + * Depending on the {@link WindowClosingProtocol#getDefaultCloseOperation() default close operation}, + * the window maybe destroyed or not. + *

    + * In case the window will be destroyed (see above), release of resources is recommended. + **/ public void windowDestroyNotify(WindowEvent e); /** Window has been destroyed.*/ -- cgit v1.2.3 From 90e136b65a10d8daf8c3a2df6cc193e55a63722c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 29 Jan 2013 21:27:57 +0100 Subject: Fix Bug 678: Deliver key-char value for printable chars on all KeyEventListener (-> On Windows as well) The following is observed, where t0 and t1 refer to subsequent different timestamps: NEWT delivery order: PRESSED (t0), RELEASED (t1) and TYPED (t1) WINDOWS delivery order: PRESSED (t0), TYPED (t0) and RELEASED (t1) Windows Auto-Repeat: PRESSED (t0), TYPED (t0) Hence we changed the event reorder-code in NEWT to trigger NEWT-PRESSED on Windows-TYPED for printable chars, assuring key-char values on all listener callbacks. - KeyEvent.getKeyChar(): Removed disclaimer dedicated for Windows - Keyevent.isActionKey(): Completed for all NEWT non-printable action keys; Added static variant - Keyevent.isPrintableKey(): NEW: returns !isModifierKey(keyCode) && !isActionKey(keyCode) ; With static variant - Windows WindowDriver: - EVENT_KEY_PRESSED handles non-printable chars only - EVENT_KEY_TYPE handles printable chars only - Native: VK_DELETE passes keyCode - Unit tests: Wait for completion 1s -> 2s --- make/scripts/java-win64-dbg.bat | 1 + make/scripts/tests-x64.bat | 6 +- make/scripts/tests.sh | 7 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 142 +++++++++++++++------ .../jogamp/newt/driver/windows/WindowDriver.java | 62 +++++---- src/newt/native/WindowsWindow.c | 2 +- .../newt/event/TestNewtKeyCodeModifiersAWT.java | 4 +- .../test/junit/newt/event/TestNewtKeyCodesAWT.java | 2 +- .../newt/event/TestNewtKeyEventAutoRepeatAWT.java | 2 +- 9 files changed, 151 insertions(+), 77 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 63c46eee5..ee7fe80e7 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -59,3 +59,4 @@ REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2 %J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win64-dbg.log 2>&1 tail java-win64-dbg.log +REM %J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 8bee4c6dd..b4b05d58b 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -12,7 +12,7 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %* @@ -50,7 +50,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsReali REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -67,7 +67,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9625519b9..0aeb54b56 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -106,6 +106,7 @@ function jrun() { #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" @@ -167,7 +168,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -307,7 +308,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* @@ -413,7 +414,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11N #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 289aa31f6..ff67b7f57 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -74,12 +74,7 @@ public class KeyEvent extends InputEvent } /** - * Returns the character matching the {@link #getKeyCode() virtual key code}, if exist. - *

    - * Disclaimer: Only valid on all platforms at {@link KeyListener#keyTyped(KeyEvent)}. - * Precisely, on the Windows platform we currently cannot deliver the proper character - * in case of shifted keys where no uppercase exists, e.g. 'shift + 1' doesn't produce '!'. - *

    + * Returns the character matching the {@link #getKeyCode() virtual key code}. */ public char getKeyChar() { return keyChar; @@ -111,7 +106,12 @@ public class KeyEvent extends InputEvent } } - /** Returns true if keyCode represents a modifier key, i.e. one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. */ + /** + * Returns true if the given keyCode represents a non-printable modifier key. + *

    + * A modifier key is one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. + *

    + */ public static boolean isModifierKey(int keyCode) { switch (keyCode) { case VK_SHIFT: @@ -125,58 +125,116 @@ public class KeyEvent extends InputEvent } } - /** Returns true if {@link #getKeyCode()} represents a modifier key, i.e. one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. */ + /** + * Returns true if {@link #getKeyCode()} represents a non-printable modifier key. + *

    + * See {@link #isModifierKey(int)} for details. + *

    + */ public boolean isModifierKey() { return isModifierKey(keyCode); } - - public boolean isActionKey() { + + /** + * Returns true if the given keyCode represents a non-printable action key, which is not a {@link #isModifierKey(int) modifier key}. + *

    + * An action key is one of {@link #VK_HOME}, {@link #VK_END}, {@link #VK_PAGE_UP}, {@link #VK_PAGE_DOWN}, {@link #VK_UP}, {@link #VK_PAGE_DOWN}, + * {@link #VK_LEFT}, {@link #VK_RIGHT}, {@link #VK_F1}-{@link #VK_F24}, {@link #VK_PRINTSCREEN}, {@link #VK_CAPS_LOCK}, {@link #VK_PAUSE}, + * {@link #VK_INSERT}, {@link #VK_HELP}, {@link #VK_WINDOWS}, etc ... + *

    + */ + public static boolean isActionKey(int keyCode) { + if( ( VK_F1 <= keyCode && keyCode <= VK_F24 ) || + ( VK_ALL_CANDIDATES <= keyCode && keyCode <= VK_INPUT_METHOD_ON_OFF ) || + ( VK_CUT <= keyCode && keyCode <= VK_STOP ) ) { + return true; + } + switch (keyCode) { - case VK_HOME: - case VK_END: + case VK_CANCEL: + case VK_CLEAR: + case VK_PAUSE: + case VK_CAPS_LOCK: + case VK_ESCAPE: case VK_PAGE_UP: case VK_PAGE_DOWN: - case VK_UP: - case VK_DOWN: + case VK_END: + case VK_HOME: case VK_LEFT: + case VK_UP: 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_DOWN: + case VK_DELETE: + case VK_NUM_LOCK: + case VK_SCROLL_LOCK: + case VK_PRINTSCREEN: - case VK_CAPS_LOCK: - case VK_PAUSE: case VK_INSERT: - case VK_HELP: + case VK_META: + case VK_KP_UP: + case VK_KP_DOWN: + case VK_KP_LEFT: + case VK_KP_RIGHT: + + case VK_DEAD_VOICED_SOUND: + case VK_DEAD_SEMIVOICED_SOUND: + case VK_WINDOWS: + case VK_CONTEXT_MENU: + case VK_FINAL: + + case VK_CONVERT: + case VK_NONCONVERT: + case VK_ACCEPT: + case VK_MODECHANGE: + + case VK_KANA: + case VK_KANJI: + + case VK_ALPHANUMERIC: + case VK_KATAKANA: + case VK_HIRAGANA: + case VK_FULL_WIDTH: + case VK_HALF_WIDTH: + case VK_ROMAN_CHARACTERS: + + case VK_COMPOSE: + case VK_BEGIN: + return true; } return false; } + + /** + * Returns true if {@link #getKeyCode() keyCode} represents a non-printable action key, which is not a {@link #isModifierKey(int) modifier key}. + *

    + * See {@link #isActionKey(int)} for details. + *

    + */ + public boolean isActionKey() { + return isActionKey(keyCode); + } + + /** + * Returns true if given keyKode represents a printable character, which is neither a {@link #isModifierKey(int) modifier key} + * nor an {@link #isActionKey(int) action key}. + * Otherwise returns false. + */ + public static boolean isPrintableKey(int keyCode) { + return !isModifierKey(keyCode) && !isActionKey(keyCode); + } + /** + * Returns true if {@link #getKeyCode() keyCode} represents a printable character, which is neither a {@link #isModifierKey(int) modifier key} + * nor an {@link #isActionKey(int) action key}. + * Otherwise returns false. + */ + public boolean isPrintableKey() { + return isPrintableKey(keyCode); + } + private final int keyCode; private final char keyChar; diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index b2e518f45..650958f25 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -273,53 +273,67 @@ public class WindowDriver extends WindowImpl { private IntIntHashMap typedKeyCode2KeyChar = new IntIntHashMap(KeyEvent.VK_CONTEXT_MENU+1); private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); - // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + final boolean isPrintableKey = KeyEvent.isPrintableKey(keyCode); + final boolean isModifierKey = KeyEvent.isModifierKey(keyCode); + // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", printableKey "+isPrintableKey+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); - // Reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED - // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. + // Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0), RELEASED (t1) and TYPED (t1) + // Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0). switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: + final int keyCharTyped = typedKeyCode2KeyChar.put(keyCode, 0); + if( 0 != keyCharTyped ) { + keyChar = (char)keyCharTyped; + } if( isKeyCodeTracked(keyCode) ) { - if( keyRepeatState.put(keyCode, false) && !isModifierKeyCode ) { + if( keyRepeatState.put(keyCode, false) && !isModifierKey ) { // AR out - send out missing PRESSED emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keyChar); } keyPressedState.put(keyCode, false); } - final int keyCharTyped = typedKeyCode2KeyChar.put(keyCode, 0); - if( 0 != keyCharTyped ) { - keyChar = (char)keyCharTyped; - } emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); break; case KeyEvent.EVENT_KEY_PRESSED: - if( isKeyCodeTracked(keyCode) ) { - if( keyPressedState.put(keyCode, true) ) { - // key was already pressed - if( keyRepeatState.put(keyCode, true) && !isModifierKeyCode ) { - emitKeyEvent(send, wait, eventType, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keyChar); - } // else AR in - skip already send PRESSED ; or ALT - } else { - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + // TYPED is delivered right after PRESSED for printable keys and contains the key-char information, + // hence we only deliver non printable keys (action and modifier keys) here. + // Modifier keys shall not AR. + if( !isPrintableKey ) { + if( !handlePressTypedAutoRepeat(isModifierKey, send, wait, modifiers, keyCode, keyChar) ) { + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar); } - } else { - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); } break; case KeyEvent.EVENT_KEY_TYPED: - if( 1 == isKeyInAutoRepeat(keyCode) ) { - modifiers |= InputEvent.AUTOREPEAT_MASK; - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); - } else if( 0 != keyCode ) { + if( isPrintableKey ) { typedKeyCode2KeyChar.put(keyCode, keyChar); + if( !handlePressTypedAutoRepeat(isModifierKey, send, wait, modifiers, keyCode, keyChar) ) { + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar); + } } break; } } + private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, boolean send, boolean wait, int modifiers, int keyCode, char keyChar) { + if( isKeyCodeTracked(keyCode) && keyPressedState.put(keyCode, true) ) { + final boolean preKeyRepeatState = keyRepeatState.put(keyCode, true); + if( !isModifierKey ) { + // AR: Key was already pressed: Either [enter | within] AR mode + modifiers |= InputEvent.AUTOREPEAT_MASK; + if( preKeyRepeatState ) { + // AR: Within AR mode + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar); + } // else { AR: Enter AR mode - skip already send PRESSED ; or ALT } + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); + } + return true; + } + return false; + } + @Override public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 17b93cfce..24d513c68 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -605,7 +605,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE s (*env)->CallVoidMethod(env, window, sendKeyEventID, (jint) EVENT_KEY_TYPED, modifiers, - (jint) 0, + (jint) jkey, (jchar) '\177'); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java index 478f6eb8b..ec06379e0 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java @@ -146,7 +146,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 10); // release+typed P AWTRobotUtil.keyPress(0, robot, false, modifierKey, 100); // release+typed MOD robot.waitForIdle(); - for(int j=0; j < 10 && keyAdapter.getQueueSize() < 3+6; j++) { // wait until events are collected + for(int j=0; j < 20 && keyAdapter.getQueueSize() < 3+6; j++) { // wait until events are collected robot.delay(100); } NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 3+6, 0); @@ -185,7 +185,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { AWTRobotUtil.keyPress(0, robot, false, m1k, 10); // release+typed MOD robot.waitForIdle(); - for(int j=0; j < 10 && keyAdapter.getQueueSize() < 3*4; j++) { // wait until events are collected + for(int j=0; j < 20 && keyAdapter.getQueueSize() < 3*4; j++) { // wait until events are collected robot.delay(100); } NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 3*4, 0); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java index e43072961..ef4b17375 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java @@ -174,7 +174,7 @@ public class TestNewtKeyCodesAWT extends UITestCase { robot.waitForIdle(); } final int codeCount = codeSeg.max - codeSeg.min + 1; - for(int j=0; j < 10 && keyAdapter.getQueueSize() < 3 * codeCount; j++) { // wait until events are collected + for(int j=0; j < 20 && keyAdapter.getQueueSize() < 3 * codeCount; j++) { // wait until events are collected robot.delay(100); } final ArrayList events = new ArrayList(keyAdapter.getQueued()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java index ca612bac6..00fbc0500 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java @@ -189,7 +189,7 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { robot.waitForIdle(); AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_B, 250); robot.waitForIdle(); - for(int j=0; j < 10 && keyAdapter.getQueueSize() < firstIdx+3; j++) { // wait until events are collected + for(int j=0; j < 20 && keyAdapter.getQueueSize() < firstIdx+3; j++) { // wait until events are collected robot.delay(100); } firstIdx = keyEvents.size(); -- cgit v1.2.3 From cedbdb09c00bb2a32cc065cb75590f3571bb7aa1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 30 Jan 2013 20:41:11 +0100 Subject: Fix AWTKeyAdapter: Reorder AWT events to NEWT order - also ensuring TYPED is always sent. This foremost fixes an issue w/ OSX/Java7 and NewtCanvasAWT offscreen CALayer usage, which utilizes AWTKeyAdapter and AWTNewtEventFactory (AWT -> NEWT) key events. --- make/scripts/tests-osx-x64-java7.sh | 2 +- make/scripts/tests-x64-custom.sh | 12 + make/scripts/tests.sh | 8 +- .../com/jogamp/newt/event/awt/AWTKeyAdapter.java | 26 +- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 35 +-- .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 300 +++++++++++++++++++++ 6 files changed, 353 insertions(+), 30 deletions(-) create mode 100755 make/scripts/tests-x64-custom.sh create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests-osx-x64-java7.sh b/make/scripts/tests-osx-x64-java7.sh index 378938167..36eee3255 100755 --- a/make/scripts/tests-osx-x64-java7.sh +++ b/make/scripts/tests-osx-x64-java7.sh @@ -8,6 +8,6 @@ export JAVA_HOME PATH spath=`dirname $0` -. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $* +. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx-java7 $* diff --git a/make/scripts/tests-x64-custom.sh b/make/scripts/tests-x64-custom.sh new file mode 100755 index 000000000..482afbbf2 --- /dev/null +++ b/make/scripts/tests-x64-custom.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +SDIR=`dirname $0` + +#export LD_LIBRARY_PATH=/home/sven/libav/lib:$LD_LIBRARY_PATH + +#if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then +# . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh +#fi + +. $SDIR/tests.sh `which java` -d64 ../build-x86_64 $* + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 0aeb54b56..cd8d37b47 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -168,7 +168,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -266,6 +266,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* @@ -298,8 +299,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -414,6 +413,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java index 7b0f6ba97..64071eed6 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java @@ -30,6 +30,11 @@ package com.jogamp.newt.event.awt; import jogamp.newt.awt.event.AWTNewtEventFactory; +/** + * AWT: + * printable: PRESSED (t0), TYPED (t0), RELEASED (t1) + * non-printable: PRESSED (t0), RELEASED (t1) + */ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListener { public AWTKeyAdapter(com.jogamp.newt.event.KeyListener newtListener) { @@ -54,8 +59,9 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe return this; } + @Override public void keyPressed(java.awt.event.KeyEvent e) { - com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow); + final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, e, newtWindow); if(null!=newtListener) { ((com.jogamp.newt.event.KeyListener)newtListener).keyPressed(event); } else { @@ -63,22 +69,22 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe } } + @Override public void keyReleased(java.awt.event.KeyEvent e) { - com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow); + com.jogamp.newt.event.KeyEvent keyReleaseEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow); + com.jogamp.newt.event.KeyEvent keyTypedEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED, e, newtWindow); if(null!=newtListener) { - ((com.jogamp.newt.event.KeyListener)newtListener).keyReleased(event); + final com.jogamp.newt.event.KeyListener newtKeyListener = (com.jogamp.newt.event.KeyListener)newtListener; + newtKeyListener.keyReleased(keyReleaseEvt); + newtKeyListener.keyTyped(keyTypedEvt); } else { - enqueueEvent(false, event); + enqueueEvent(false, keyReleaseEvt); + enqueueEvent(false, keyTypedEvt); } } + @Override public void keyTyped(java.awt.event.KeyEvent e) { - com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow); - if(null!=newtListener) { - ((com.jogamp.newt.event.KeyListener)newtListener).keyTyped(event); - } else { - enqueueEvent(false, event); - } } } diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index e0f7af69c..e11d79ddc 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -236,32 +236,32 @@ public class AWTNewtEventFactory { } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) { - int type = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != type) { - return new com.jogamp.newt.event.WindowEvent(type, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), System.currentTimeMillis()); + final int newtType = eventTypeAWT2NEWT.get(event.getID()); + if(0xFFFFFFFF != newtType) { + return new com.jogamp.newt.event.WindowEvent(newtType, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), System.currentTimeMillis()); } return null; // no mapping .. } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.ComponentEvent event, com.jogamp.newt.Window newtSource) { - int type = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != type) { - return new com.jogamp.newt.event.WindowEvent(type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); + final int newtType = eventTypeAWT2NEWT.get(event.getID()); + if(0xFFFFFFFF != newtType) { + return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); } return null; // no mapping .. } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.FocusEvent event, com.jogamp.newt.Window newtSource) { - int type = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != type) { - return new com.jogamp.newt.event.WindowEvent(type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); + final int newtType = eventTypeAWT2NEWT.get(event.getID()); + if(0xFFFFFFFF != newtType) { + return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); } return null; // no mapping .. } public static final com.jogamp.newt.event.MouseEvent createMouseEvent(java.awt.event.MouseEvent event, com.jogamp.newt.Window newtSource) { - int type = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != type) { + final int newtType = eventTypeAWT2NEWT.get(event.getID()); + if(0xFFFFFFFF != newtType) { float rotation = 0; if (event instanceof java.awt.event.MouseWheelEvent) { // AWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up. @@ -280,7 +280,7 @@ public class AWTNewtEventFactory { } } return new com.jogamp.newt.event.MouseEvent( - type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), + newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), mods, event.getX(), event.getY(), event.getClickCount(), newtButton, rotation); } @@ -288,15 +288,18 @@ public class AWTNewtEventFactory { } public static final com.jogamp.newt.event.KeyEvent createKeyEvent(java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { - int type = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != type) { + return createKeyEvent(eventTypeAWT2NEWT.get(event.getID()), event, newtSource); + } + + public static final com.jogamp.newt.event.KeyEvent createKeyEvent(int newtType, java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { + if(0xFFFFFFFF != newtType) { return new com.jogamp.newt.event.KeyEvent( - type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), + newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()), event.getKeyCode(), event.getKeyChar()); } return null; // no mapping .. } - + } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java new file mode 100644 index 000000000..5fca50593 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -0,0 +1,300 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.es2.newt; + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import com.jogamp.newt.Display; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.event.KeyAdapter; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.util.QuitAdapter; + +import com.jogamp.opengl.util.Animator; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; + +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.PointImmutable; +import javax.media.nativewindow.util.DimensionImmutable; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLProfile; +import javax.swing.SwingUtilities; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; + +public class TestGearsES2NewtCanvasAWT extends UITestCase { + static int screenIdx = 0; + static PointImmutable wpos; + static DimensionImmutable wsize; + + static long duration = 500; // ms + static boolean opaque = true; + static int forceAlpha = -1; + static boolean fullscreen = false; + static boolean pmvUseBackingArray = true; + static int swapInterval = 1; + static boolean showFPS = false; + static int loops = 1; + static boolean loop_shutdown = false; + static boolean forceES2 = false; + static boolean forceGL3 = false; + static boolean mainRun = false; + static boolean exclusiveContext = false; + + @BeforeClass + public static void initClass() { + if(null == wsize) { + wsize = new Dimension(640, 480); + } + } + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException, InvocationTargetException { + System.err.println("requested: vsync "+swapInterval+", "+caps); + Display dpy = NewtFactory.createDisplay(null); + Screen screen = NewtFactory.createScreen(dpy, screenIdx); + final GLWindow glWindow = GLWindow.create(screen, caps); + Assert.assertNotNull(glWindow); + + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); + + final Frame frame1 = new Frame("AWT Parent Frame"); + frame1.setLayout(new BorderLayout()); + frame1.add(newtCanvasAWT, BorderLayout.CENTER); + frame1.setSize(wsize.getWidth(), wsize.getHeight()); + frame1.setLocation(0, 0); + frame1.setTitle("Gears NewtCanvasAWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval+", size "+wsize+", pos "+wpos); + + final GearsES2 demo = new GearsES2(swapInterval); + demo.setPMVUseBackingArray(pmvUseBackingArray); + glWindow.addGLEventListener(demo); + + Animator animator = new Animator(); + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + animator.setExclusiveContext(exclusiveContext); + + QuitAdapter quitAdapter = new QuitAdapter(); + //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); + //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + glWindow.addKeyListener(quitAdapter); + glWindow.addWindowListener(quitAdapter); + + glWindow.addWindowListener(new WindowAdapter() { + public void windowResized(WindowEvent e) { + System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + public void windowMoved(WindowEvent e) { + System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + }); + + glWindow.addKeyListener(new KeyAdapter() { + public void keyTyped(KeyEvent e) { + if(e.getKeyChar()=='f') { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); + glWindow.setFullscreen(!glWindow.isFullscreen()); + System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } + } + }); + + animator.add(glWindow); + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread()); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + } + }); + + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); + System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); + System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() Date: Thu, 17 Jan 2013 16:35:01 +0100 Subject: Add LinuxEventDeviceTracker used by RaspPi newt/driver/bcm/vc/iv/WindowDriver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xerxes RÃ¥nby --- .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 3 + .../newt/driver/linux/LinuxEventDeviceTracker.java | 406 +++++++++++++++++++++ 2 files changed, 409 insertions(+) create mode 100644 src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index 21fbea9ac..bdef8e6cd 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -37,6 +37,7 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; import jogamp.newt.WindowImpl; +import jogamp.newt.driver.linux.LinuxEventDeviceTracker; import jogamp.newt.driver.linux.LinuxMouseTracker; public class WindowDriver extends WindowImpl { @@ -76,11 +77,13 @@ public class WindowDriver extends WindowImpl { } windowHandleClose = nativeWindowHandle; addWindowListener(LinuxMouseTracker.getSingleton()); + addWindowListener(LinuxEventDeviceTracker.getSingleton()); focusChanged(false, true); } protected void closeNativeImpl() { removeWindowListener(LinuxMouseTracker.getSingleton()); + removeWindowListener(LinuxEventDeviceTracker.getSingleton()); if(0!=windowHandleClose) { CloseWindow(windowHandleClose, windowUserData); diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java new file mode 100644 index 000000000..9fcb40e67 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -0,0 +1,406 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.linux; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; + +import jogamp.newt.WindowImpl; + +import com.jogamp.common.nio.StructAccessor; +import com.jogamp.newt.event.InputEvent; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowListener; +import com.jogamp.newt.event.WindowUpdateEvent; +import com.jogamp.newt.event.KeyEvent; + +/** + * Experimental native event device tracker thread for GNU/Linux + * just reading /dev/input/event* + * within it's own polling thread. + */ + +public class LinuxEventDeviceTracker implements WindowListener { + + private static final LinuxEventDeviceTracker ledt; + + + static { + ledt = new LinuxEventDeviceTracker(); + final Thread t = new Thread(ledt.eventDevicePoller, "NEWT-LinuxEventDeviceTracker"); + t.setDaemon(true); + t.start(); + } + + public static LinuxEventDeviceTracker getSingleton() { + return ledt; + } + + private volatile boolean stop = false; + private WindowImpl focusedWindow = null; + private EventDevicePoller eventDevicePoller = new EventDevicePoller(); + + @Override + public void windowResized(WindowEvent e) { } + + @Override + public void windowMoved(WindowEvent e) { } + + @Override + public void windowDestroyNotify(WindowEvent e) { + Object s = e.getSource(); + if(focusedWindow == s) { + focusedWindow = null; + } + } + + @Override + public void windowDestroyed(WindowEvent e) { } + + @Override + public void windowGainedFocus(WindowEvent e) { + Object s = e.getSource(); + if(s instanceof WindowImpl) { + focusedWindow = (WindowImpl) s; + } + } + + @Override + public void windowLostFocus(WindowEvent e) { + Object s = e.getSource(); + if(focusedWindow == s) { + focusedWindow = null; + } + } + + public static void main(String[] args ){ + LinuxEventDeviceTracker.getSingleton(); + try { + Thread.sleep(30000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void windowRepaint(WindowUpdateEvent e) { } + + class EventDevicePoller implements Runnable { + @Override + public void run() { + final byte[] b = new byte[16]; + /** + * The Linux input event interface. + * http://www.kernel.org/doc/Documentation/input/input.txt + * + * struct input_event { + * struct timeval time; + * unsigned short type; + * unsigned short code; + * unsigned int value; + * }; + */ + ByteBuffer bb = ByteBuffer.wrap(b); + StructAccessor s = new StructAccessor(bb); + final File f = new File("/dev/input/event2"); + f.setReadOnly(); + InputStream fis; + try { + fis = new FileInputStream(f); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return; + } + + int timeSeconds; + int timeSecondFraction; + short type; + short code; + int value; + + int keyCode=KeyEvent.VK_UNDEFINED; + char keyChar=' '; + int eventType=0; + int modifiers=0; + + while(!stop) { + int remaining=16; + while(remaining>0) { + int read = 0; + try { + read = fis.read(b, 0, remaining); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(read<0) { + stop = true; // EOF of event device file !? + } else { + remaining -= read; + } + } + + timeSeconds = s.getIntAt(0); + timeSecondFraction = s.getShortAt(4); + type = s.getShortAt(8); + code = s.getShortAt(10); + value = s.getIntAt(12); + + if(null != focusedWindow) { + /* + * Linux sends Keyboard events in the following order: + * EV_MSC (optional, contains scancode) + * EV_KEY + * SYN_REPORT (sent before next key) + */ + + switch(type) { + case 0: // SYN_REPORT + // Clear + eventType = 0; + keyCode = KeyEvent.VK_UNDEFINED; + keyChar = 0; // Print null for unprintable char. + modifiers = 0; + break; + case 1: // EV_KEY + keyCode = LinuxEVKey2NewtVKey(code); // The device independent code. + keyChar = LinuxEVKey2Unicode(code); // The printable character w/o key modifiers. + switch(value) { + case 0: + modifiers=0; + eventType=KeyEvent.EVENT_KEY_RELEASED; + focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + //Send syntetic typed + focusedWindow.sendKeyEvent(KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, (char) keyChar); + break; + case 1: + eventType=KeyEvent.EVENT_KEY_PRESSED; + focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + break; + case 2: + eventType=KeyEvent.EVENT_KEY_PRESSED; + modifiers=InputEvent.AUTOREPEAT_MASK; + + //Send syntetic autorepeat release + focusedWindow.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); + //Send syntetic typed + focusedWindow.sendKeyEvent(KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); + + focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + break; + } + break; + case 4: // EV_MSC + if(code==4) { // MSC_SCAN + // scancode ignore, linux kernel specific + // keyCode = value; + } + break; + // TODO: handle joystick events + // TODO: handle mouse events + // TODO: handle headphone/hdmi connector events + } + + //System.out.println("[time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); + + } else { + //if(Window.DEBUG_KEY_EVENT) + System.out.println("[time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); + } + } + if(null != fis) { + try { + fis.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + private char LinuxEVKey2Unicode(short EVKey) { + // This is the stuff normally mapped by a system keymap + + switch(EVKey){ + case 17: // w + return 'w'; + case 31: // s + return 's'; + case 30: // a + return 'a'; + case 32: // d + return 'd'; + case 1: // ESC + return 27; + case 28: // Enter + case 96: // Keypad Enter + return '\n'; + case 57: // Space + return ' '; + case 11: // 0 + case 82: // Numpad 0 + return '0'; + case 2: // 1 + case 79: // Numpad 1 + return '1'; + case 3: // 2 + case 80: // Numpad 1 + return '2'; + case 4: // 3 + case 81: // Numpad 3 + return '3'; + case 5: // 4 + case 75: // Numpad 4 + return '4'; + case 6: // 5 + case 76: // Numpad 5 + return '5'; + case 7: // 6 + case 77: // Numpad 6 + return '6'; + case 8: // 7 + case 71: // Numpad 7 + return '7'; + case 9: // 8 + case 72: // Numpad 8 + return '8'; + case 10: // 9 + case 73: // Numpad 9 + return '9'; + + default: + } + + return 0; + } + + static final short KEY_F1 = 59; + static final short KEY_F10 = 68; + static final short KEY_1 = 2; + static final short KEY_0 = 1; + + private int LinuxEVKey2NewtVKey(short EVKey) { + char vkCode = KeyEvent.VK_UNDEFINED; + + // F1 - F10 + if(isLinuxEVKeyWithin(EVKey, KEY_F1, KEY_F10)) + return (EVKey-KEY_F1)+KeyEvent.VK_F1; + + switch(EVKey){ + case 103: // KEY_UP + return KeyEvent.VK_UP; + case 105: // KEY_LEFT + return KeyEvent.VK_LEFT; + case 106: // KEY_RIGHT + return KeyEvent.VK_RIGHT; + case 108: // KEY_DOWN + return KeyEvent.VK_DOWN; + + case 14: // Backspace + return KeyEvent.VK_BACK_SPACE; + case 111: // del + return KeyEvent.VK_DELETE; + + case 17: // w + return KeyEvent.VK_W; + case 31: // s + return KeyEvent.VK_S; + case 30: // a + return KeyEvent.VK_A; + case 32: // d + return KeyEvent.VK_D; + case 1: // ESC + return KeyEvent.VK_ESCAPE; + case 28: // Enter + case 96: // Keypad Enter + return KeyEvent.VK_ENTER; + case 57: // Space + return KeyEvent.VK_SPACE; + case 11: // 0 + return KeyEvent.VK_0; + case 82: // Numpad 0 + return KeyEvent.VK_NUMPAD0; + case 2: // 1 + return KeyEvent.VK_1; + case 79: // Numpad 1 + return KeyEvent.VK_NUMPAD1; + case 3: // 2 + return KeyEvent.VK_2; + case 80: // Numpad 2 + return KeyEvent.VK_NUMPAD2; + case 4: // 3 + return KeyEvent.VK_3; + case 81: // Numpad 3 + return KeyEvent.VK_NUMPAD3; + case 5: // 4 + return KeyEvent.VK_4; + case 75: // Numpad 4 + return KeyEvent.VK_NUMPAD4; + case 6: // 5 + return KeyEvent.VK_5; + case 76: // Numpad 5 + return KeyEvent.VK_NUMPAD5; + case 7: // 6 + return KeyEvent.VK_6; + case 77: // Numpad 6 + return KeyEvent.VK_NUMPAD6; + case 8: // 7 + return KeyEvent.VK_7; + case 71: // Numpad 7 + return KeyEvent.VK_NUMPAD7; + case 9: // 8 + return KeyEvent.VK_8; + case 72: // Numpad 8 + return KeyEvent.VK_NUMPAD8; + case 10: // 9 + return KeyEvent.VK_9; + case 73: // Numpad 9 + return KeyEvent.VK_NUMPAD9; + + default: + //System.out.println("LinuxEVKey2NewtVKey: Unmapped EVKey "+EVKey); + } + + return vkCode; + } + + private boolean isLinuxEVKeyWithin(short eVKey, short min, + short max) { + if((eVKey>=min) && (eVKey<=max)) + return true; + return false; + } + } +} -- cgit v1.2.3 From 8d6438eb6b03013012e3a357d92aa3cd40ee55c0 Mon Sep 17 00:00:00 2001 From: Xerxes RÃ¥nby Date: Wed, 30 Jan 2013 23:49:37 +0100 Subject: LinuxEventDeviceTracker: LinuxEventDeviceManager monitor /dev/input/event* MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The LinuxEventDeviceManager will start new EventDevicePoller threads when more /dev/input/event* files become available. Signed-off-by: Xerxes RÃ¥nby --- .../newt/driver/linux/LinuxEventDeviceTracker.java | 62 ++++++++++++++++++++-- 1 file changed, 58 insertions(+), 4 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index 9fcb40e67..4746c90bf 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -33,6 +33,10 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.lang.Integer; +import java.lang.Runnable; +import java.lang.String; +import java.lang.Thread; import java.nio.ByteBuffer; import jogamp.newt.WindowImpl; @@ -57,7 +61,7 @@ public class LinuxEventDeviceTracker implements WindowListener { static { ledt = new LinuxEventDeviceTracker(); - final Thread t = new Thread(ledt.eventDevicePoller, "NEWT-LinuxEventDeviceTracker"); + final Thread t = new Thread(ledt.eventDeviceManager, "NEWT-LinuxEventDeviceManager"); t.setDaemon(true); t.start(); } @@ -66,9 +70,21 @@ public class LinuxEventDeviceTracker implements WindowListener { return ledt; } - private volatile boolean stop = false; private WindowImpl focusedWindow = null; - private EventDevicePoller eventDevicePoller = new EventDevicePoller(); + private EventDeviceManager eventDeviceManager = new EventDeviceManager(); + + /* + The devices are in /dev/input: + + crw-r--r-- 1 root root 13, 64 Apr 1 10:49 event0 + crw-r--r-- 1 root root 13, 65 Apr 1 10:50 event1 + crw-r--r-- 1 root root 13, 66 Apr 1 10:50 event2 + crw-r--r-- 1 root root 13, 67 Apr 1 10:50 event3 + ... + + And so on up to event31. + */ + private EventDevicePoller[] eventDevicePollers = new EventDevicePoller[32]; @Override public void windowResized(WindowEvent e) { } @@ -116,7 +132,45 @@ public class LinuxEventDeviceTracker implements WindowListener { @Override public void windowRepaint(WindowUpdateEvent e) { } + class EventDeviceManager implements Runnable { + @Override + public void run() { + File f = new File("/dev/input/"); + int number; + for(String path:f.list()){ + if(path.startsWith("event")) { + String stringNumber = path.substring(5); + number = Integer.parseInt(stringNumber); + if(number<32&&number>=0) { + if(eventDevicePollers[number]==null){ + eventDevicePollers[number] = new EventDevicePoller(number); + Thread t = new Thread(eventDevicePollers[number], "NEWT-LinuxEventDeviceTracker-event"+number); + t.setDaemon(true); + t.start(); + } else if(eventDevicePollers[number].stop) { + eventDevicePollers[number]=null; + } + } + } + } + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + class EventDevicePoller implements Runnable { + + private volatile boolean stop = false; + private String eventDeviceName; + + public EventDevicePoller(int eventDeviceNumber){ + this.eventDeviceName="/dev/input/event"+eventDeviceNumber; + } + @Override public void run() { final byte[] b = new byte[16]; @@ -133,7 +187,7 @@ public class LinuxEventDeviceTracker implements WindowListener { */ ByteBuffer bb = ByteBuffer.wrap(b); StructAccessor s = new StructAccessor(bb); - final File f = new File("/dev/input/event2"); + final File f = new File(eventDeviceName); f.setReadOnly(); InputStream fis; try { -- cgit v1.2.3 From ff39f9e5a37020d72af3d4f1ea8fe0b6b6714016 Mon Sep 17 00:00:00 2001 From: Xerxes RÃ¥nby Date: Thu, 31 Jan 2013 00:18:33 +0100 Subject: LinuxEventDeviceTracker: gracefully manage hot-swap of USB devices. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xerxes RÃ¥nby --- .../newt/driver/linux/LinuxEventDeviceTracker.java | 53 ++++++++++++---------- 1 file changed, 29 insertions(+), 24 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index 4746c90bf..96000b401 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -133,31 +133,36 @@ public class LinuxEventDeviceTracker implements WindowListener { public void windowRepaint(WindowUpdateEvent e) { } class EventDeviceManager implements Runnable { + + private volatile boolean stop = false; + @Override public void run() { File f = new File("/dev/input/"); int number; - for(String path:f.list()){ - if(path.startsWith("event")) { - String stringNumber = path.substring(5); - number = Integer.parseInt(stringNumber); - if(number<32&&number>=0) { - if(eventDevicePollers[number]==null){ - eventDevicePollers[number] = new EventDevicePoller(number); - Thread t = new Thread(eventDevicePollers[number], "NEWT-LinuxEventDeviceTracker-event"+number); - t.setDaemon(true); - t.start(); - } else if(eventDevicePollers[number].stop) { - eventDevicePollers[number]=null; + while(!stop){ + for(String path:f.list()){ + if(path.startsWith("event")) { + String stringNumber = path.substring(5); + number = Integer.parseInt(stringNumber); + if(number<32&&number>=0) { + if(eventDevicePollers[number]==null){ + eventDevicePollers[number] = new EventDevicePoller(number); + Thread t = new Thread(eventDevicePollers[number], "NEWT-LinuxEventDeviceTracker-event"+number); + t.setDaemon(true); + t.start(); + } else if(eventDevicePollers[number].stop) { + eventDevicePollers[number]=null; + } } } } - } - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } } } @@ -193,8 +198,7 @@ public class LinuxEventDeviceTracker implements WindowListener { try { fis = new FileInputStream(f); } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + stop=true; return; } @@ -209,6 +213,7 @@ public class LinuxEventDeviceTracker implements WindowListener { int eventType=0; int modifiers=0; + loop: while(!stop) { int remaining=16; while(remaining>0) { @@ -216,11 +221,12 @@ public class LinuxEventDeviceTracker implements WindowListener { try { read = fis.read(b, 0, remaining); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + stop = true; + break loop; } if(read<0) { stop = true; // EOF of event device file !? + break loop; } else { remaining -= read; } @@ -298,10 +304,9 @@ public class LinuxEventDeviceTracker implements WindowListener { try { fis.close(); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } } + stop=true; } private char LinuxEVKey2Unicode(short EVKey) { -- cgit v1.2.3 From 72bf6f4c6bc19aade075f10db4a26e3cf7cfc5ee Mon Sep 17 00:00:00 2001 From: Xerxes RÃ¥nby Date: Thu, 31 Jan 2013 01:43:01 +0100 Subject: LinuxEventDeviceTracker: LinuxEVKey2NewtVKey(EVKey 0-121) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xerxes RÃ¥nby --- .../newt/driver/linux/LinuxEventDeviceTracker.java | 338 ++++++++++++++++----- 1 file changed, 257 insertions(+), 81 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index 96000b401..fdef54d02 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -365,90 +365,266 @@ public class LinuxEventDeviceTracker implements WindowListener { return 0; } - static final short KEY_F1 = 59; - static final short KEY_F10 = 68; - static final short KEY_1 = 2; - static final short KEY_0 = 1; - private int LinuxEVKey2NewtVKey(short EVKey) { char vkCode = KeyEvent.VK_UNDEFINED; - // F1 - F10 - if(isLinuxEVKeyWithin(EVKey, KEY_F1, KEY_F10)) - return (EVKey-KEY_F1)+KeyEvent.VK_F1; - - switch(EVKey){ - case 103: // KEY_UP - return KeyEvent.VK_UP; - case 105: // KEY_LEFT - return KeyEvent.VK_LEFT; - case 106: // KEY_RIGHT - return KeyEvent.VK_RIGHT; - case 108: // KEY_DOWN - return KeyEvent.VK_DOWN; - - case 14: // Backspace - return KeyEvent.VK_BACK_SPACE; - case 111: // del - return KeyEvent.VK_DELETE; - - case 17: // w - return KeyEvent.VK_W; - case 31: // s - return KeyEvent.VK_S; - case 30: // a - return KeyEvent.VK_A; - case 32: // d - return KeyEvent.VK_D; - case 1: // ESC - return KeyEvent.VK_ESCAPE; - case 28: // Enter - case 96: // Keypad Enter - return KeyEvent.VK_ENTER; - case 57: // Space - return KeyEvent.VK_SPACE; - case 11: // 0 - return KeyEvent.VK_0; - case 82: // Numpad 0 - return KeyEvent.VK_NUMPAD0; - case 2: // 1 - return KeyEvent.VK_1; - case 79: // Numpad 1 - return KeyEvent.VK_NUMPAD1; - case 3: // 2 - return KeyEvent.VK_2; - case 80: // Numpad 2 - return KeyEvent.VK_NUMPAD2; - case 4: // 3 - return KeyEvent.VK_3; - case 81: // Numpad 3 - return KeyEvent.VK_NUMPAD3; - case 5: // 4 - return KeyEvent.VK_4; - case 75: // Numpad 4 - return KeyEvent.VK_NUMPAD4; - case 6: // 5 - return KeyEvent.VK_5; - case 76: // Numpad 5 - return KeyEvent.VK_NUMPAD5; - case 7: // 6 - return KeyEvent.VK_6; - case 77: // Numpad 6 - return KeyEvent.VK_NUMPAD6; - case 8: // 7 - return KeyEvent.VK_7; - case 71: // Numpad 7 - return KeyEvent.VK_NUMPAD7; - case 9: // 8 - return KeyEvent.VK_8; - case 72: // Numpad 8 - return KeyEvent.VK_NUMPAD8; - case 10: // 9 - return KeyEvent.VK_9; - case 73: // Numpad 9 - return KeyEvent.VK_NUMPAD9; - - default: + switch(EVKey) { + case 1: // ESC + return KeyEvent.VK_ESCAPE; + case 2: // 1 + return KeyEvent.VK_1; + case 79: // Numpad 1 + return KeyEvent.VK_NUMPAD1; + case 3: // 2 + return KeyEvent.VK_2; + case 80: // Numpad 2 + return KeyEvent.VK_NUMPAD2; + case 4: // 3 + return KeyEvent.VK_3; + case 81: // Numpad 3 + return KeyEvent.VK_NUMPAD3; + case 5: // 4 + return KeyEvent.VK_4; + case 75: // Numpad 4 + return KeyEvent.VK_NUMPAD4; + case 6: // 5 + return KeyEvent.VK_5; + case 76: // Numpad 5 + return KeyEvent.VK_NUMPAD5; + case 7: // 6 + return KeyEvent.VK_6; + case 77: // Numpad 6 + return KeyEvent.VK_NUMPAD6; + case 8: // 7 + return KeyEvent.VK_7; + case 71: // Numpad 7 + return KeyEvent.VK_NUMPAD7; + case 9: // 8 + return KeyEvent.VK_8; + case 72: // Numpad 8 + return KeyEvent.VK_NUMPAD8; + case 10: // 9 + return KeyEvent.VK_9; + case 73: // Numpad 9 + return KeyEvent.VK_NUMPAD9; + case 11: // 0 + return KeyEvent.VK_0; + case 82: // Numpad 0 + return KeyEvent.VK_NUMPAD0; + case 12: + return KeyEvent.VK_MINUS; + case 13: + return KeyEvent.VK_EQUALS; + case 14: // Backspace + return KeyEvent.VK_BACK_SPACE; + + case 15: + return KeyEvent.VK_TAB; + case 16: + return KeyEvent.VK_Q; + case 17: // w + return KeyEvent.VK_W; + case 18: + return KeyEvent.VK_E; + case 19: + return KeyEvent.VK_R; + case 20: + return KeyEvent.VK_T; + case 21: + return KeyEvent.VK_Y; + case 22: + return KeyEvent.VK_U; + case 23: + return KeyEvent.VK_I; + case 24: + return KeyEvent.VK_O; + case 25: + return KeyEvent.VK_P; + case 26: // left brace + return KeyEvent.VK_LEFT_PARENTHESIS; + case 27: // right brace + return KeyEvent.VK_RIGHT_PARENTHESIS; + case 28: // Enter + case 96: // Keypad Enter + return KeyEvent.VK_ENTER; + + case 29: // left ctrl + return KeyEvent.VK_CONTROL; + case 30: // a + return KeyEvent.VK_A; + case 31: // s + return KeyEvent.VK_S; + case 32: // d + return KeyEvent.VK_D; + case 33: + return KeyEvent.VK_F; + case 34: + return KeyEvent.VK_G; + case 35: + return KeyEvent.VK_H; + case 36: + return KeyEvent.VK_J; + case 37: + return KeyEvent.VK_K; + case 38: + return KeyEvent.VK_L; + case 39: + return KeyEvent.VK_SEMICOLON; + case 40: // apostrophe + return KeyEvent.VK_DEAD_ACUTE; + case 41: // grave + return KeyEvent.VK_DEAD_GRAVE; + + case 42: // left shift + return KeyEvent.VK_SHIFT; + case 43: + return KeyEvent.VK_BACK_SLASH; + case 44: + return KeyEvent.VK_Z; + case 45: + return KeyEvent.VK_X; + case 46: + return KeyEvent.VK_C; + case 47: + return KeyEvent.VK_V; + case 48: + return KeyEvent.VK_B; + case 49: + return KeyEvent.VK_N; + case 50: + return KeyEvent.VK_M; + case 51: + return KeyEvent.VK_COMMA; + case 52: // dot + return KeyEvent.VK_PERIOD; + case 53: + return KeyEvent.VK_SLASH; + case 54: + return KeyEvent.VK_SHIFT; + case 55: // kp asterisk + return KeyEvent.VK_ASTERISK; + case 56: // left alt + return KeyEvent.VK_ALT; + case 57: // Space + return KeyEvent.VK_SPACE; + case 58: + return KeyEvent.VK_CAPS_LOCK; + + case 59: + return KeyEvent.VK_F1; + case 60: + return KeyEvent.VK_F2; + case 61: + return KeyEvent.VK_F3; + case 62: + return KeyEvent.VK_F4; + case 63: + return KeyEvent.VK_F5; + case 64: + return KeyEvent.VK_F6; + case 65: + return KeyEvent.VK_F7; + case 66: + return KeyEvent.VK_F8; + case 67: + return KeyEvent.VK_F9; + case 68: + return KeyEvent.VK_F10; + + case 69: + return KeyEvent.VK_NUM_LOCK; + case 70: + return KeyEvent.VK_SCROLL_LOCK; + + case 74: // kp minus + return KeyEvent.VK_MINUS; + case 78: // kp plus + return KeyEvent.VK_PLUS; + case 83: // kp dot + return KeyEvent.VK_PERIOD; + + // TODO: add mappings for japanese special buttons + case 85: // zenkakuhankaku + case 86: // 102nd + return 0; // FIXME + + case 87: + return KeyEvent.VK_F11; + case 88: + return KeyEvent.VK_F12; + + case 89: // ro + return KeyEvent.VK_ROMAN_CHARACTERS; + case 90: // Katakana + return KeyEvent.VK_KATAKANA; + case 91: + return KeyEvent.VK_HIRAGANA; + + case 92: // kenkan + return 0; // FIXME + case 93: // katakana hiragana + return 0; // FIXME + case 94: // mu henkan + return 0; // FIXME + case 95: // kp jp comma + return 0; // FIXME + + case 97: // right ctrl + return KeyEvent.VK_CONTROL; + case 98: // kp slash + return KeyEvent.VK_SLASH; + + case 99: // sysrq + return 0; // FIXME + + case 100: // right alt + return KeyEvent.VK_ALT; + case 101: // linefeed + return 0; // FIXME + case 102: // home + return KeyEvent.VK_HOME; + case 103: // KEY_UP + return KeyEvent.VK_UP; + case 104: + return KeyEvent.VK_PAGE_UP; + case 105: // KEY_LEFT + return KeyEvent.VK_LEFT; + case 106: // KEY_RIGHT + return KeyEvent.VK_RIGHT; + case 107: + return KeyEvent.VK_END; + case 108: // KEY_DOWN + return KeyEvent.VK_DOWN; + case 109: + return KeyEvent.VK_PAGE_DOWN; + case 110: + return KeyEvent.VK_INSERT; + case 111: // del + return KeyEvent.VK_DELETE; + + case 112: // macro + return 0; //FIXME DEAD_MACRON? + case 113: // mute + return 0; //FIXME + case 114: // vol up + return 0; //FIXME + case 115: // vol down + return 0; //FIXME + case 116: // power + return 0; //FIXME + + case 117: // kp equals + return KeyEvent.VK_EQUALS; + case 118: // kp plus minux + return 0; // FIXME + case 119: // pause + return KeyEvent.VK_PAUSE; + case 120: // scale AL compiz scale expose + return 0; + case 121: // kp comma + return KeyEvent.VK_COMMA; + + default: //System.out.println("LinuxEVKey2NewtVKey: Unmapped EVKey "+EVKey); } -- cgit v1.2.3 From f8bc0add2e3d18c397fb2af59e3787baa9dfc771 Mon Sep 17 00:00:00 2001 From: Xerxes RÃ¥nby Date: Thu, 31 Jan 2013 13:42:27 +0100 Subject: LinuxEventDeviceTracker: LinuxEVKey2NewtVKey(EVKey 122-248) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xerxes RÃ¥nby --- .../newt/driver/linux/LinuxEventDeviceTracker.java | 301 +++++++++++++++++++-- 1 file changed, 273 insertions(+), 28 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index fdef54d02..5c2a69142 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -42,6 +42,7 @@ import java.nio.ByteBuffer; import jogamp.newt.WindowImpl; import com.jogamp.common.nio.StructAccessor; +import com.jogamp.newt.Window; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; @@ -120,6 +121,7 @@ public class LinuxEventDeviceTracker implements WindowListener { } public static void main(String[] args ){ + System.setProperty("newt.debug.Window.KeyEvent", "true"); LinuxEventDeviceTracker.getSingleton(); try { Thread.sleep(30000); @@ -293,11 +295,14 @@ public class LinuxEventDeviceTracker implements WindowListener { // TODO: handle headphone/hdmi connector events } - //System.out.println("[time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); + if(Window.DEBUG_KEY_EVENT) { + System.out.println("[time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); + } } else { - //if(Window.DEBUG_KEY_EVENT) - System.out.println("[time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); + if(Window.DEBUG_KEY_EVENT) { + System.out.println("[time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); + } } } if(null != fis) { @@ -546,7 +551,7 @@ public class LinuxEventDeviceTracker implements WindowListener { // TODO: add mappings for japanese special buttons case 85: // zenkakuhankaku case 86: // 102nd - return 0; // FIXME + break; // FIXME case 87: return KeyEvent.VK_F11; @@ -561,13 +566,13 @@ public class LinuxEventDeviceTracker implements WindowListener { return KeyEvent.VK_HIRAGANA; case 92: // kenkan - return 0; // FIXME + break; // FIXME case 93: // katakana hiragana - return 0; // FIXME + break; // FIXME case 94: // mu henkan - return 0; // FIXME + break; // FIXME case 95: // kp jp comma - return 0; // FIXME + break; // FIXME case 97: // right ctrl return KeyEvent.VK_CONTROL; @@ -575,12 +580,12 @@ public class LinuxEventDeviceTracker implements WindowListener { return KeyEvent.VK_SLASH; case 99: // sysrq - return 0; // FIXME + break; // FIXME case 100: // right alt return KeyEvent.VK_ALT; case 101: // linefeed - return 0; // FIXME + break; // FIXME case 102: // home return KeyEvent.VK_HOME; case 103: // KEY_UP @@ -603,39 +608,279 @@ public class LinuxEventDeviceTracker implements WindowListener { return KeyEvent.VK_DELETE; case 112: // macro - return 0; //FIXME DEAD_MACRON? + break; // FIXME DEAD_MACRON? case 113: // mute - return 0; //FIXME + break; // FIXME case 114: // vol up - return 0; //FIXME + break; // FIXME case 115: // vol down - return 0; //FIXME + break; // FIXME case 116: // power - return 0; //FIXME + break; // FIXME case 117: // kp equals return KeyEvent.VK_EQUALS; case 118: // kp plus minux - return 0; // FIXME + break; // FIXME case 119: // pause return KeyEvent.VK_PAUSE; case 120: // scale AL compiz scale expose - return 0; + break; // FIXME case 121: // kp comma return KeyEvent.VK_COMMA; - - default: - //System.out.println("LinuxEVKey2NewtVKey: Unmapped EVKey "+EVKey); + case 122: // hangeul + break; // FIXME + case 123: // hanja + break; // FIXME + case 124: // yen + break; // FIXME + + case 125: // left meta + case 126: // right meta + return KeyEvent.VK_META; + case 127: // compose + return KeyEvent.VK_COMPOSE; + + case 128: // stop + return KeyEvent.VK_STOP; + case 129: // again + return KeyEvent.VK_AGAIN; + case 130: // properties + return KeyEvent.VK_PROPS; + case 131: // undo + return KeyEvent.VK_UNDO; + case 132: // front + break; // FIXME + case 133: // copy + return KeyEvent.VK_COPY; + case 134: // open + break; // FIXME + case 135: // paste + return KeyEvent.VK_PASTE; + case 136: // find + return KeyEvent.VK_FIND; + case 137: // cut + return KeyEvent.VK_CUT; + case 138: // help + return KeyEvent.VK_HELP; + case 139: // menu + break; // FIXME + case 140: // calc + break; // FIXME + case 141: // setup + break; // FIXME + case 142: // sleep + break; // FIXME + case 143: // wakeup + break; // FIXME + case 144: // file + break; // FIXME + case 145: // send file + break; // FIXME + case 146: // delete file + break; // FIXME + case 147: // xfer + break; // FIXME + case 148: // prog1 + break; // FIXME + case 149: // prog2 + break; // FIXME + case 150: // www + break; // FIXME + case 151: // msdos + break; // FIXME + case 152: // coffee + break; // FIXME + case 153: // direction + break; // FIXME + case 154: // cycle windows + break; // FIXME + case 155: // mail + break; // FIXME + case 156: // bookmarks + break; // FIXME + case 157: // computer + break; // FIXME + case 158: // back + break; // FIXME + case 159: // forward + break; // FIXME + case 160: // close cd + break; // FIXME + case 161: // eject cd + break; // FIXME + case 162: // eject close cd + break; // FIXME + case 163: // next song + break; // FIXME + case 164: // play pause + break; // FIXME + case 165: // previous song + break; // FIXME + case 166: // stop cd + break; // FIXME + case 167: // record + break; // FIXME + case 168: // rewind + break; // FIXME + case 169: // phone + break; // FIXME + case 170: // ISO + break; // FIXME + case 171: // config + break; // FIXME + case 172: // home page + break; // FIXME + case 173: // refresh + break; // FIXME + case 174: // exit + break; // FIXME + case 175: // move + break; // FIXME + case 176: // edit + break; // FIXME + case 177: // scroll up + break; // FIXME PAGE_UP? + case 178: // scroll down + break; // FIXME PAGE_DOWN? + case 179: // kp left paren + return KeyEvent.VK_LEFT_PARENTHESIS; + case 180: // kp right paren + return KeyEvent.VK_RIGHT_PARENTHESIS; + case 181: // new + break; // FIXME + case 182: // redo + break; // FIXME + + case 183: // F13 + return KeyEvent.VK_F13; + case 184: // F14 + return KeyEvent.VK_F14; + case 185: // F15 + return KeyEvent.VK_F15; + case 186: // F16 + return KeyEvent.VK_F16; + case 187: // F17 + return KeyEvent.VK_F17; + case 188: // F18 + return KeyEvent.VK_F18; + case 189: // F19 + return KeyEvent.VK_F19; + case 190: // F20 + return KeyEvent.VK_F20; + case 191: // F21 + return KeyEvent.VK_F21; + case 192: // F22 + return KeyEvent.VK_F22; + case 193: // F23 + return KeyEvent.VK_F23; + case 194: // F24 + return KeyEvent.VK_F24; + + case 200: // play cd + break; // FIXME + case 201: // pause cd + break; // FIXME + case 202: // prog 3 + break; // FIXME + case 203: // prog 4 + break; // FIXME + case 204: // dashboard + break; // FIXME + case 205: // suspend + break; // FIXME + case 206: // close + break; // FIXME + case 207: // play + break; // FIXME + case 208: // fast forward + break; // FIXME + case 210: // print + return KeyEvent.VK_PRINTSCREEN; // FIXME ? + case 211: // HP + break; // FIXME + case 212: // camera + break; // FIXME + case 213: // sound + break; // FIXME + case 214: // question + break; // FIXME + case 215: // email + break; // FIXME + case 216: // chat + break; // FIXME + case 217: // search + break; // FIXME + case 218: // connect + break; // FIXME + case 219: // finance + break; // FIXME + case 220: // sport + break; // FIXME + case 221: // shop + break; // FIXME + case 222: // alt erase + break; // FIXME + case 223: // cancel + break; // FIXME + case 224: // brightness down + break; // FIXME + case 225: // brightness up + break; // FIXME + case 226: // media + break; // FIXME + case 227: // switch video mode + break; // FIXME + case 228: // kb dillum toggle + break; // FIXME + case 229: // kb dillum down + break; // FIXME + case 230: // kb dillum up + break; // FIXME + case 231: // send + break; // FIXME + case 232: // reply + break; // FIXME + case 233: // forward mail + break; // FIXME + case 234: // save + break; // FIXME + case 235: // documents + break; // FIXME + case 236: // battery + break; // FIXME + case 237: // bluetooth + break; // FIXME + case 238: // wlan + break; // FIXME + case 239: // UWB + break; // FIXME + case 240: // unknown + return KeyEvent.VK_UNDEFINED; // FIXME ? + case 241: // video next + break; // FIXME + case 242: // video prev + break; // FIXME + case 243: // brightness cycle + break; // FIXME + case 244: // brightness zero + break; // FIXME + case 245: // display off + break; // FIXME + case 246: // wimax + break; // FIXME + case 247: // rf kill radio off + break; // FIXME + case 248: // mic mute + break; // FIXME + + default: } - + + if(Window.DEBUG_KEY_EVENT) { + System.out.println("LinuxEVKey2NewtVKey: Unmapped EVKey "+EVKey); + } return vkCode; } - - private boolean isLinuxEVKeyWithin(short eVKey, short min, - short max) { - if((eVKey>=min) && (eVKey<=max)) - return true; - return false; - } } } -- cgit v1.2.3 From ae89ca7342b8673e38b7d76bff386175e84a9173 Mon Sep 17 00:00:00 2001 From: Xerxes RÃ¥nby Date: Thu, 31 Jan 2013 16:47:06 +0100 Subject: LinuxEventDeviceTracker: Map printable char using KeyEvent.isPrintableKey. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The NEWT VK namespace tries to map keyCodes to its Unicode varianti, make use this quirk. Signed-off-by: Xerxes RÃ¥nby --- .../jogamp/newt/driver/linux/LinuxEventDeviceTracker.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index 5c2a69142..5efce2524 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -258,7 +258,7 @@ public class LinuxEventDeviceTracker implements WindowListener { break; case 1: // EV_KEY keyCode = LinuxEVKey2NewtVKey(code); // The device independent code. - keyChar = LinuxEVKey2Unicode(code); // The printable character w/o key modifiers. + keyChar = NewtVKey2Unicode(keyCode); // The printable character w/o key modifiers. switch(value) { case 0: modifiers=0; @@ -314,6 +314,13 @@ public class LinuxEventDeviceTracker implements WindowListener { stop=true; } + private char NewtVKey2Unicode(int VK){ + if(KeyEvent.isPrintableKey(VK)){ + return (char)VK; + } + return 0; + } + private char LinuxEVKey2Unicode(short EVKey) { // This is the stuff normally mapped by a system keymap -- cgit v1.2.3 From c9a13b31703302f58100af2a3f437ff7cb8fd010 Mon Sep 17 00:00:00 2001 From: Eric Brayet Date: Mon, 28 Jan 2013 14:41:10 +0100 Subject: Fix bug 668 : Android keyboard input was uppercase --- .../jogamp/newt/driver/android/event/AndroidNewtEventFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index dc1e8aeef..55fbbe603 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -192,13 +192,13 @@ public class AndroidNewtEventFactory { final int newtMods = aKeyModifiers2Newt(event.getMetaState()); final com.jogamp.newt.event.KeyEvent ke1 = new com.jogamp.newt.event.KeyEvent( - type, src, unixTime, newtMods, newtKeyCode, event.getDisplayLabel()); + type, src, unixTime, newtMods, newtKeyCode, (char) event.getUnicodeChar()); if( com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED == type ) { return new com.jogamp.newt.event.KeyEvent[] { ke1, new com.jogamp.newt.event.KeyEvent( com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED, - src, unixTime, newtMods, newtKeyCode, event.getDisplayLabel()) }; + src, unixTime, newtMods, newtKeyCode, (char) event.getUnicodeChar()) }; } else { return new com.jogamp.newt.event.KeyEvent[] { ke1 }; } -- cgit v1.2.3 From 2aeff053c55dadafb94bfbba661250e0c96f1fe5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 15 Feb 2013 17:15:49 +0100 Subject: Fix Bug 691 (part-2): Extra '[subLayer release]' is wrong, since 'CGL.releaseNSOpenGLLayer' triggers release - but very late w/ AWT usage. OSXUtil_RemoveCASublayer0's added '[subLayer release]' in commit f6e6fab2a7ddfb5c9b614cb072c27ff697629161 is wrong, since 'CGL.releaseNSOpenGLLayer' actually does trigger it's release. This was not seen w/ AWT tests, since it happens very later. A NewtCanvasAWT test disclosed this error -> removed that extra release call. The culprit for the late release w/ AWT usage was CGL.createNSOpenGLLayer's call in the current thread. Moving it to the Main-Thread fixed the problem. All CALayer lifecycle calls are issued on the Main-Thread now. NSOpenGLLayer's CVDisplayLink OpenGL fitting via 'CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext' is now performed at it's context creation in 'NSOpenGLLayer::openGLContextForPixelFormat'. The 'extra' release of the NSOpenGLLayer's NSOpenGLContext as introduced in commit f6e6fab2a7ddfb5c9b614cb072c27ff697629161 is still valid. --- make/config/jogl/cgl-macosx-CustomJavaCode.java | 22 ++ make/config/jogl/cgl-macosx.cfg | 9 + make/scripts/tests.sh | 11 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 5 +- .../macosx/MacOSXWindowSystemInterface-calayer.m | 25 ++- .../jogamp/nativewindow/macosx/OSXUtil.java | 16 +- src/nativewindow/native/macosx/OSXmisc.m | 119 +++++++++-- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 5 +- .../acore/TestOffscreenLayer01GLCanvasAWT.java | 15 +- .../acore/TestOffscreenLayer02NewtCanvasAWT.java | 16 +- .../jogl/awt/TestGLCanvasAddRemove01SwingAWT.java | 53 ++--- .../awt/TestGLCanvasAddRemove02NewtCanvasAWT.java | 238 +++++++++++++++++++++ .../jogamp/opengl/test/junit/util/UITestCase.java | 11 + 13 files changed, 438 insertions(+), 107 deletions(-) create mode 100644 make/config/jogl/cgl-macosx-CustomJavaCode.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAddRemove02NewtCanvasAWT.java (limited to 'src/newt/classes') diff --git a/make/config/jogl/cgl-macosx-CustomJavaCode.java b/make/config/jogl/cgl-macosx-CustomJavaCode.java new file mode 100644 index 000000000..b9a37d0c6 --- /dev/null +++ b/make/config/jogl/cgl-macosx-CustomJavaCode.java @@ -0,0 +1,22 @@ + +/** + * Creates the NSOpenGLLayer for FBO/PBuffer w/ optional GL3 shader program on Main-Thread + */ +public static long createNSOpenGLLayer(final long ctx, final int gl3ShaderProgramName, final long fmt, final long p, + final int texID, final boolean opaque, final int texWidth, final int texHeight) { + return OSXUtil.RunOnMainThread(true, new Function() { + public Long eval(Object... args) { + return Long.valueOf( createNSOpenGLLayerImpl(ctx, gl3ShaderProgramName, fmt, p, texID, opaque, texWidth, texHeight) ); + } } ).longValue(); +} + +/** + * Releases the NSOpenGLLayer on Main-Thread + */ +public static void releaseNSOpenGLLayer(final long nsOpenGLLayer) { + OSXUtil.RunOnMainThread(true, new Runnable() { + public void run() { + releaseNSOpenGLLayerImpl(nsOpenGLLayer); + } } ); +} + diff --git a/make/config/jogl/cgl-macosx.cfg b/make/config/jogl/cgl-macosx.cfg index 203802d29..98123f605 100644 --- a/make/config/jogl/cgl-macosx.cfg +++ b/make/config/jogl/cgl-macosx.cfg @@ -34,6 +34,13 @@ Opaque long NSOpenGLLayer * CustomCCode #include CustomCCode #include "macosx-window-system.h" +AccessControl createNSOpenGLLayerImpl PRIVATE +AccessControl releaseNSOpenGLLayerImpl PRIVATE +RenameJavaMethod createNSOpenGLLayer createNSOpenGLLayerImpl +RenameJavaMethod releaseNSOpenGLLayer releaseNSOpenGLLayerImpl + +IncludeAs CustomJavaCode CGL cgl-macosx-CustomJavaCode.java + # Implement the first argument to getProcAddress as String instead # of byte[] ArgumentIsString getProcAddress 0 @@ -53,3 +60,5 @@ DropUniqVendorExtensions SGIX DropUniqVendorExtensions SUN DropUniqVendorExtensions WIN +Import com.jogamp.common.util.Function +Import jogamp.nativewindow.macosx.OSXUtil diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 198a8f2e6..5f5248156 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -34,7 +34,7 @@ uname -a | grep -i Darwin && MOSX=1 if [ $MOSX -eq 1 ] ; then echo setup OSX environment vars #export NSZombieEnabled=YES - export NSTraceEvents=YES + #export NSTraceEvents=YES #export OBJC_PRINT_EXCEPTIONS=YES echo NSZombieEnabled $NSZombieEnabled 2>&1 | tee -a java-run.log echo NSTraceEvents $NSTraceEvents 2>&1 | tee -a java-run.log @@ -89,7 +89,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" - #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch -Dnativewindow.debug.JAWT" + #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" @@ -311,6 +311,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove01SwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove02NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* @@ -416,11 +418,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove01SwingAWT $* - #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 0deaa2987..838a0387d 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -709,10 +709,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl // still having a valid OLS attached to surface (parent OLS could have been removed) ols.detachSurfaceLayer(); } - OSXUtil.RunOnMainThread(true, new Runnable() { - public void run() { - CGL.releaseNSOpenGLLayer(nsOpenGLLayer); - } } ); + CGL.releaseNSOpenGLLayer(nsOpenGLLayer); if( null != gl3ShaderProgram ) { gl3ShaderProgram.destroy(MacOSXCGLContext.this.gl.getGL3()); gl3ShaderProgram = null; diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index 4334fc676..8d1286169 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -75,8 +75,11 @@ extern GLboolean glIsVertexArray (GLuint array); - (void)setView:(NSView *)view { DBG_PRINT("MyNSOpenGLContext.setView: this.0 %p, view %p\n", self, view); + // NSLog(@"MyNSOpenGLContext::setView: %@",[NSThread callStackSymbols]); if(NULL != view) { [super setView:view]; + } else { + [self clearDrawable]; } DBG_PRINT("MyNSOpenGLContext.setView.X\n"); } @@ -301,13 +304,6 @@ static const GLfloat gl_verts[] = { displayLink = NULL; } } - if(NULL != displayLink) { - cvres = CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, [parentCtx CGLContextObj], [parentPixelFmt CGLPixelFormatObj]); - if(kCVReturnSuccess != cvres) { - DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext failed: %d\n", self, cvres); - displayLink = NULL; - } - } if(NULL != displayLink) { cvres = CVDisplayLinkSetOutputCallback(displayLink, renderMyNSOpenGLLayer, self); if(kCVReturnSuccess != cvres) { @@ -453,10 +449,20 @@ static const GLfloat gl_verts[] = { - (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat { - DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.0: %p (refcnt %d) - pfmt %p, parent %p\n", - self, (int)[self retainCount], pixelFormat, parentCtx); + DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.0: %p (refcnt %d) - pfmt %p, parent %p, DisplayLink %p\n", + self, (int)[self retainCount], pixelFormat, parentCtx, displayLink); // NSLog(@"MyNSOpenGLLayer::openGLContextForPixelFormat: %@",[NSThread callStackSymbols]); myCtx = [[MyNSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:parentCtx]; +#ifndef HAS_CADisplayLink + if(NULL != displayLink) { + CVReturn cvres; + DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.1: setup DisplayLink %p\n", displayLink); + cvres = CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, [myCtx CGLContextObj], [pixelFormat CGLPixelFormatObj]); + if(kCVReturnSuccess != cvres) { + DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext failed: %d\n", self, cvres); + } + } +#endif DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.X: new-ctx %p\n", myCtx); return myCtx; } @@ -487,7 +493,6 @@ static const GLfloat gl_verts[] = { // [[self openGLContext] release]; if( NULL != myCtx ) { [myCtx release]; - // [myCtx dealloc]; myCtx = NULL; } parentCtx = NULL; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 2e133c22f..b765a68c3 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -136,8 +136,11 @@ public class OSXUtil implements ToolkitProperties { return GetNSWindow0(nsView); } - public static long CreateCALayer(int x, int y, int width, int height) { - return CreateCALayer0(x, y, width, height); + public static long CreateCALayer(final int x, final int y, final int width, final int height) { + return OSXUtil.RunOnMainThread(true, new Function() { + public Long eval(Object... args) { + return Long.valueOf( CreateCALayer0(x, y, width, height) ); + } } ).longValue(); } public static void AddCASublayer(final long rootCALayer, final long subCALayer) { if(0==rootCALayer || 0==subCALayer) { @@ -145,7 +148,7 @@ public class OSXUtil implements ToolkitProperties { } RunOnMainThread(true, new Runnable() { public void run() { - AddCASublayer0(rootCALayer, subCALayer); + AddCASublayer0(rootCALayer, subCALayer); } }); } @@ -205,6 +208,13 @@ public class OSXUtil implements ToolkitProperties { } } + private static Runnable _nop = new Runnable() { public void run() {}; }; + + /** Issues a {@link #RunOnMainThread(boolean, Runnable)} w/ an NOP runnable, while waiting until done. */ + public static void WaitUntilFinish() { + RunOnMainThread(true, _nop); + } + /** * Run on OSX UI main thread. *

    diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 3fa320042..83f3c821f 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -32,6 +32,7 @@ #include #include #include +#import #include "NativewindowCommon.h" #include "jogamp_nativewindow_macosx_OSXUtil.h" @@ -323,6 +324,64 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 return res; } +/** + * Track lifecycle via DBG_PRINT messages, if VERBOSE is enabled! + */ +@interface MyCALayer: CALayer +{ +} +- (id)init; +#ifdef DBG_LIFECYCLE +- (id)retain; +- (oneway void)release; +- (void)dealloc; +#endif + +@end + +@implementation MyCALayer + +- (id)init +{ + DBG_PRINT("MyCALayer.0\n"); + MyCALayer * o = [super init]; + DBG_PRINT("MyNSOpenGLContext.init.X: new %p\n", o); + DBG_PRINT("MyCALayer.0\n"); + return o; +} + +#ifdef DBG_LIFECYCLE + +- (id)retain +{ + DBG_PRINT("MyCALayer::retain.0: %p (refcnt %d)\n", self, (int)[self retainCount]); + // NSLog(@"MyCALayer::retain: %@",[NSThread callStackSymbols]); + id o = [super retain]; + DBG_PRINT("MyCALayer::retain.X: %p (refcnt %d)\n", o, (int)[o retainCount]); + return o; +} + +- (oneway void)release +{ + DBG_PRINT("MyCALayer::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); + // NSLog(@"MyCALayer::release: %@",[NSThread callStackSymbols]); + [super release]; + // DBG_PRINT("MyCALayer::release.X: %p (refcnt %d)\n", self, (int)[self retainCount]); +} + +- (void)dealloc +{ + DBG_PRINT("MyCALayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]); + // NSLog(@"MyCALayer::dealloc: %@",[NSThread callStackSymbols]); + [super dealloc]; + // DBG_PRINT("MyCALayer.dealloc.X: %p\n", self); +} + +#endif + + +@end + /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: CreateCALayer0 @@ -333,7 +392,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - CALayer* layer = [[CALayer alloc] init]; + MyCALayer* layer = [[MyCALayer alloc] init]; DBG_PRINT("CALayer::CreateCALayer.0: root %p %d/%d %dx%d (refcnt %d)\n", layer, (int)x, (int)y, (int)width, (int)height, (int)[layer retainCount]); // avoid zero size if(0 == width) { width = 32; } @@ -349,12 +408,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 // no animations for add/remove/swap sublayers etc // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] [layer removeAllAnimations]; + // [layer addAnimation:nil forKey:kCATransition]; [layer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; [layer setNeedsDisplayOnBoundsChange: YES]; DBG_PRINT("CALayer::CreateCALayer.1: root %p %lf/%lf %lfx%lf\n", layer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); - DBG_PRINT("CALayer::CreateCALayer.X: root %p (refcnt %d)\n", layer, (int)[layer retainCount]); - [pool release]; + DBG_PRINT("CALayer::CreateCALayer.X: root %p (refcnt %d)\n", layer, (int)[layer retainCount]); return (jlong) ((intptr_t) layer); } @@ -367,8 +426,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer) { - JNF_COCOA_ENTER(env); - CALayer* rootLayer = (CALayer*) ((intptr_t) rootCALayer); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer); CGRect lRectRoot = [rootLayer frame]; @@ -385,6 +444,9 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 rootLayer, (int)[rootLayer retainCount], subLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height, (int)[subLayer retainCount]); + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + // simple 1:1 layout ! [subLayer setFrame:lRectRoot]; [rootLayer addSublayer:subLayer]; @@ -392,14 +454,19 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 // no animations for add/remove/swap sublayers etc // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] [rootLayer removeAllAnimations]; + // [rootLayer addAnimation:nil forKey:kCATransition]; [rootLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; [rootLayer setNeedsDisplayOnBoundsChange: YES]; [subLayer removeAllAnimations]; + // [sublayer addAnimation:nil forKey:kCATransition]; [subLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; [subLayer setNeedsDisplayOnBoundsChange: YES]; + + [CATransaction commit]; + + [pool release]; DBG_PRINT("CALayer::AddCASublayer0.X: root %p (refcnt %d) .sub %p (refcnt %d)\n", rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); - JNF_COCOA_EXIT(env); } /* @@ -410,19 +477,26 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RemoveCASublayer0 (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer) { - JNF_COCOA_ENTER(env); - CALayer* rootLayer = (CALayer*) ((intptr_t) rootCALayer); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer); (void)rootLayer; // no warnings DBG_PRINT("CALayer::RemoveCASublayer0.0: root %p (refcnt %d) .sub %p (refcnt %d)\n", rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); + + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + [subLayer removeFromSuperlayer]; - [subLayer release]; + // [subLayer release] is called explicitly, e.g. via CGL.releaseNSOpenGLLayer(..) (MyNSOpenGLLayer::releaseLayer) + + [CATransaction commit]; + + [pool release]; DBG_PRINT("CALayer::RemoveCASublayer0.X: root %p (refcnt %d) .sub %p (refcnt %d)\n", rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); - JNF_COCOA_EXIT(env); } /* @@ -433,14 +507,13 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RemoveCASublayer0 JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyCALayer0 (JNIEnv *env, jclass unused, jlong caLayer) { - JNF_COCOA_ENTER(env); - CALayer* layer = (CALayer*) ((intptr_t) caLayer); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyCALayer* layer = (MyCALayer*) ((intptr_t) caLayer); DBG_PRINT("CALayer::DestroyCALayer0.0: root %p (refcnt %d)\n", layer, (int)[layer retainCount]); - [layer release]; // Var.A - // [layer dealloc]; // Var.B -> SIGSEGV + [layer release]; // Trigger release of root CALayer + [pool release]; DBG_PRINT("CALayer::DestroyCALayer0.X: root %p\n", layer); - JNF_COCOA_EXIT(env); } /* @@ -451,18 +524,18 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyCALayer0 JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_SetJAWTRootSurfaceLayer0 (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) { - JNF_COCOA_ENTER(env); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); if (NULL == dsi) { NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); return JNI_FALSE; } - CALayer* layer = (CALayer*) (intptr_t) caLayer; + MyCALayer* layer = (MyCALayer*) (intptr_t) caLayer; id surfaceLayers = (id )dsi->platformInfo; DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.0: pre %p -> root %p (refcnt %d)\n", surfaceLayers.layer, layer, (int)[layer retainCount]); - surfaceLayers.layer = layer; // already incr. retain count + surfaceLayers.layer = [layer retain]; // Pairs w/ Unset + [pool release]; DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.X: root %p (refcnt %d)\n", layer, (int)[layer retainCount]); - JNF_COCOA_EXIT(env); return JNI_TRUE; } @@ -474,23 +547,23 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_UnsetJAWTRootSurfaceLayer0 (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) { - JNF_COCOA_ENTER(env); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); if (NULL == dsi) { NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); return JNI_FALSE; } - CALayer* layer = (CALayer*) (intptr_t) caLayer; + MyCALayer* layer = (MyCALayer*) (intptr_t) caLayer; id surfaceLayers = (id )dsi->platformInfo; if(layer != surfaceLayers.layer) { NativewindowCommon_throwNewRuntimeException(env, "Attached layer %p doesn't match given layer %p\n", surfaceLayers.layer, layer); return JNI_FALSE; } DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.0: root %p (refcnt %d) -> nil\n", layer, (int)[layer retainCount]); + [layer release]; // Pairs w/ Set surfaceLayers.layer = NULL; - [layer release]; // Var.A + [pool release]; DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.X: root %p (refcnt %d) -> nil\n", layer, (int)[layer retainCount]); - JNF_COCOA_EXIT(env); return JNI_TRUE; } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 89a749c51..6fc5a46ce 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -397,11 +397,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println("NewtCanvasAWT.removeNotify: "+newtChild+", from "+cont); } + // Detach OLS early.. final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); if(null != ols && ols.isSurfaceLayerAttached()) { ols.detachSurfaceLayer(); - } - reparentWindow(false, cont); + } + reparentWindow(false, cont); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached) if(null != jawtWindow) { NewtFactoryAWT.destroyNativeWindow(jawtWindow); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java index 90407166f..8cc094276 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java @@ -33,9 +33,7 @@ import java.awt.Button; import java.awt.Container; import java.awt.Dimension; import java.awt.Frame; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; import java.lang.reflect.InvocationTargetException; import javax.media.opengl.GLAnimatorControl; @@ -70,6 +68,7 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { static Dimension frameSize1; static Dimension preferredGLSize; static long durationPerTest = 1000; + static boolean waitForKey = false; @BeforeClass public static void initClass() { @@ -189,7 +188,10 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { Thread.sleep(durationPerTest/2); - end(animator1, frame1, null); + end(animator1, frame1, null); + if( waitForKey ) { + UITestCase.waitForKey("Continue"); + } } public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { @@ -214,7 +216,6 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { } public static void main(String args[]) throws IOException { - boolean waitForKey = false; for(int i=0; i Press enter to continue"); + try { + System.err.println(stdin.readLine()); + } catch (IOException e) { } + } + static final String unsupportedTestMsg = "Test not supported on this platform."; public String getSnapshotFilename(int sn, String postSNDetail, GLCapabilitiesImmutable caps, int width, int height, boolean sinkHasAlpha, String fileSuffix, String destPath) { -- cgit v1.2.3 From 8edaa9780455b60f6034a78970cab4f516d4b061 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 17 Feb 2013 03:25:34 +0100 Subject: NEWT/OSX: Fix Memory Leak ; Fix Occasional Crash Duer to Lifecycle Ops not on Main-Thread. - Fix Memory Leak - NewtWindow::dealloc -> [NewtView release]: Fixes NewtView leak - NewtView::dealloc -> removeTrackingRect: Removes occasional crash (double free of TrackingRect) - Fix Occasional Crash Duer to Lifecycle Ops not on Main-Thread. Perform OSX WindowDriver ops on Main-Thread: - close0 - changeContentView0 - createWindow0 - Cleaned up AddRemove unit tests, added TestAddRemove03GLWindowNEWT --- make/scripts/tests-osx-x64-java7.sh | 1 - make/scripts/tests-osx-x64.sh | 1 - make/scripts/tests.sh | 9 +- .../jogamp/newt/driver/macosx/WindowDriver.java | 43 +++++-- src/newt/native/MacWindow.m | 31 +++-- src/newt/native/NewtMacWindow.m | 32 +++-- .../acore/TestAddRemove01GLCanvasSwingAWT.java | 35 +++--- .../TestAddRemove02GLWindowNewtCanvasAWT.java | 37 +++--- .../jogl/acore/TestAddRemove03GLWindowNEWT.java | 130 +++++++++++++++++++++ .../awt/TestBug664GLCanvasSetVisibleSwingAWT.java | 4 +- 10 files changed, 248 insertions(+), 75 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove03GLWindowNEWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests-osx-x64-java7.sh b/make/scripts/tests-osx-x64-java7.sh index 378938167..e1b07202b 100755 --- a/make/scripts/tests-osx-x64-java7.sh +++ b/make/scripts/tests-osx-x64-java7.sh @@ -10,4 +10,3 @@ spath=`dirname $0` . $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $* - diff --git a/make/scripts/tests-osx-x64.sh b/make/scripts/tests-osx-x64.sh index 01f3e1bb2..fe2d2c4ec 100755 --- a/make/scripts/tests-osx-x64.sh +++ b/make/scripts/tests-osx-x64.sh @@ -10,4 +10,3 @@ spath=`dirname $0` . $spath/tests.sh /usr/bin/java -d64 ../build-macosx $* - diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 400f3f023..5a7c0f0ec 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -34,8 +34,8 @@ uname -a | grep -i Darwin && MOSX=1 if [ $MOSX -eq 1 ] ; then echo setup OSX environment vars #export NSZombieEnabled=YES - #export NSTraceEvents=YES - #export OBJC_PRINT_EXCEPTIONS=YES + export NSTraceEvents=YES + export OBJC_PRINT_EXCEPTIONS=YES echo NSZombieEnabled $NSZombieEnabled 2>&1 | tee -a java-run.log echo NSTraceEvents $NSTraceEvents 2>&1 | tee -a java-run.log echo OBJC_PRINT_EXCEPTIONS $OBJC_PRINT_EXCEPTIONS 2>&1 | tee -a java-run.log @@ -302,7 +302,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove03GLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -434,7 +435,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT -testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT $* diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 5755bdf11..89d53fbeb 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -50,6 +50,7 @@ import jogamp.newt.WindowImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; +import com.jogamp.common.util.Function; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; @@ -86,7 +87,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl sscSurfaceHandle = 0; isOffscreenInstance = false; if (0 != handle) { - close0(handle); + OSXUtil.RunOnMainThread(true, new Runnable() { + public void run() { + close0( handle ); + } } ); } } catch (Throwable t) { if(DEBUG_IMPLEMENTATION) { @@ -378,24 +382,36 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl try { if(0!=getWindowHandle()) { // save the view .. close the window - surfaceHandle = changeContentView0(getParentWindowHandle(), getWindowHandle(), 0); + surfaceHandle = OSXUtil.RunOnMainThread(true, new Function() { + public Long eval(Object... args) { + return Long.valueOf( + changeContentView0(getParentWindowHandle(), getWindowHandle(), 0) ); + } } ).longValue(); if(recreate && 0==surfaceHandle) { throw new NativeWindowException("Internal Error - recreate, window but no view"); } - close0(getWindowHandle()); + OSXUtil.RunOnMainThread(true, new Runnable() { + public void run() { + close0( getWindowHandle() ); + } } ); setWindowHandle(0); } else { surfaceHandle = 0; } - setWindowHandle(createWindow0(getParentWindowHandle(), - pS.getX(), pS.getY(), width, height, - (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance), - fullscreen, - ((isUndecorated() || offscreenInstance) ? - NSBorderlessWindowMask : - NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask), - NSBackingStoreBuffered, - getScreen().getIndex(), surfaceHandle)); + + setWindowHandle( OSXUtil.RunOnMainThread(true, new Function() { + public Long eval(Object... args) { + return Long.valueOf( + createWindow0( getParentWindowHandle(), + pS.getX(), pS.getY(), width, height, + (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance), + fullscreen, + ( (isUndecorated() || offscreenInstance) ? NSBorderlessWindowMask : + NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask ), + NSBackingStoreBuffered, + getScreen().getIndex(), surfaceHandle) ); + } } ).longValue() ); + if (getWindowHandle() == 0) { throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this); } @@ -411,6 +427,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } protected static native boolean initIDs0(); + /** Must be called on Main-Thread */ private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h, boolean opaque, boolean fullscreen, int windowStyle, int backingStoreType, @@ -422,9 +439,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl /** in case of a child window, it actually only issues orderBack(..) */ private native void orderOut0(long window); private native void orderFront0(long window); + /** Must be called on Main-Thread */ private native void close0(long window); private native void setTitle0(long window, String title); private native long contentView0(long window); + /** Must be called on Main-Thread */ private native long changeContentView0(long parentWindowOrViewHandle, long window, long view); private native void setContentSize0(long window, int w, int h); private native void setFrameTopLeftPoint0(long parentWindowHandle, long window, int x, int y); diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index b9c339285..94363624f 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -553,7 +553,9 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0 return (jboolean) res; } -/* +/** + * Method is called on Main-Thread, hence no special invocation required inside method. + * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: createWindow0 * Signature: (JIIIIZIIIJ)J @@ -706,19 +708,10 @@ NS_ENDHANDLER return (jlong) ((intptr_t) myWindow); } -// Footnote: Our view handling produces random 'Assertion failure' even w/o parenting: -// -// [NSThemeFrame lockFocus], /SourceCache/AppKit/AppKit-1138.23/AppKit.subproj/NSView.m:6053 -// [NSThemeFrame(0x7fe94bc72c80) lockFocus] failed with window=0x7fe94bc445a0, windowNumber=9425, [self isHiddenOrHasHiddenAncestor]=0 -// .. -// AppKit 0x00007fff89621001 -[NSView lockFocus] + 250 -// AppKit 0x00007fff8961eafa -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 3780 -// AppKit 0x00007fff8961793e -[NSView displayIfNeeded] + 1676 -// AppKit 0x00007fff8961707d _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 648 -// - -/* +/** + * Method is called on Main-Thread, hence no special invocation required inside method. + * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: close0 * Signature: (J)V @@ -761,8 +754,6 @@ NS_DURING [mView exitFullScreenModeWithOptions: NULL]; } // Note: mWin's release will also release it's mView! - // [mWin setContentView: nil]; - // [mView release]; } NS_HANDLER NS_ENDHANDLER @@ -770,7 +761,8 @@ NS_ENDHANDLER if(NULL!=pWin) { [mWin detachFromParent: pWin]; } - [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:NO]; + // [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:NO]; + [mWin orderOut: mWin]; DBG_PRINT( "windowClose.1 - %p,%d view %p,%d, parent %p\n", mWin, getRetainCount(mWin), mView, getRetainCount(mView), pWin); @@ -778,7 +770,8 @@ NS_ENDHANDLER // Only release window, if release is not yet in process. // E.g. destroyNotifySent:=true set by NewtMacWindow::windowWillClose(), i.e. window-close was clicked. if(!destroyNotifySent) { - [mWin performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO]; + // [mWin performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO]; + [mWin release]; } DBG_PRINT( "windowClose.X - %p,%d, released %d, view %p,%d, parent %p\n", @@ -960,7 +953,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_contentView0 return res; } -/* +/** + * Method is called on Main-Thread, hence no special invocation required inside method. + * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: changeContentView * Signature: (J)J diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 5b826566b..e69f74dfb 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -107,6 +107,7 @@ static jmethodID windowRepaintID = NULL; - (id)initWithFrame:(NSRect)frameRect { + id res = [super initWithFrame:frameRect]; javaWindowObject = NULL; jvmHandle = NULL; @@ -129,28 +130,35 @@ static jmethodID windowRepaintID = NULL; */ myCursor = NULL; - return [super initWithFrame:frameRect]; + DBG_PRINT("NewtView::create: %p (refcnt %d)\n", res, (int)[res retainCount]); + return res; } - (void) release { + DBG_PRINT("NewtView::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); #ifdef VERBOSE_ON - NSLog(@"NewtView::release\n"); - NSLog(@"%@",[NSThread callStackSymbols]); + // NSLog(@"%@",[NSThread callStackSymbols]); #endif [super release]; } - (void) dealloc { + DBG_PRINT("NewtView::dealloc.0: %p (refcnt %d), ptrTrackingTag %d\n", self, (int)[self retainCount], (int)ptrTrackingTag); if(softLocked) { NSLog(@"NewtView::dealloc: softLock still hold @ dealloc!\n"); } + if(0 != ptrTrackingTag) { + // [self removeCursorRect: ptrRect cursor: myCursor]; + [self removeTrackingRect: ptrTrackingTag]; + ptrTrackingTag = 0; + } pthread_mutex_destroy(&softLockSync); #ifdef VERBOSE_ON - NSLog(@"NewtView::dealloc\n"); - NSLog(@"%@",[NSThread callStackSymbols]); + //NSLog(@"%@",[NSThread callStackSymbols]); #endif + DBG_PRINT("NewtView::dealloc.X: %p\n", self); [super dealloc]; } @@ -390,25 +398,31 @@ static jmethodID windowRepaintID = NULL; mouseInside = NO; cursorIsHidden = NO; realized = YES; + DBG_PRINT("NewtWindow::create: %p (refcnt %d)\n", res, (int)[res retainCount]); return res; } - (void) release { + DBG_PRINT("NewtWindow::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); #ifdef VERBOSE_ON - NSLog(@"NewtWindow::release\n"); - NSLog(@"%@",[NSThread callStackSymbols]); + // NSLog(@"%@",[NSThread callStackSymbols]); #endif [super release]; } - (void) dealloc { + DBG_PRINT("NewtWindow::dealloc.0: %p (refcnt %d)\n", self, (int)[self retainCount]); #ifdef VERBOSE_ON - NSLog(@"NewtWindow::dealloc\n"); - NSLog(@"%@",[NSThread callStackSymbols]); + // NSLog(@"%@",[NSThread callStackSymbols]); #endif + NewtView* mView = (NewtView *)[self contentView]; + if( NULL != mView ) { + [mView release]; + } [super dealloc]; + DBG_PRINT("NewtWindow::dealloc.X: %p\n", self); } - (void) setUnrealized diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java index a14364e05..ce8f9adc8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java @@ -50,13 +50,14 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.UITestCase; public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { static long durationPerTest = 50; static int addRemoveCount = 15; - static boolean shallUseOffscreenFBOLayer = false; + static boolean noOnscreenTest = false; + static boolean noOffscreenTest = false; static boolean shallUseOffscreenPBufferLayer = false; static GLProfile glp; static int width, height; @@ -64,8 +65,8 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { @BeforeClass public static void initClass() { - if(GLProfile.isAvailable(GLProfile.GL2)) { - glp = GLProfile.get(GLProfile.GL2); + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); Assert.assertNotNull(glp); width = 640; height = 480; @@ -139,6 +140,7 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { { for(int i=0; i Date: Tue, 19 Feb 2013 08:00:38 +0100 Subject: Bug 678 (fix), Bug 641 (API + Windows Impl.), Bug 688 (prep): Update NEWT's KeyEvent handling while distinguish keyCode (kbd layout independent) and keySym (kbd layout dependent) API Changes: - Virtual key codes and symbols are of type short. - KeyEvent.keySymbol() shall return a layout dependent value (Bug 641) - Method returns former keyCode() value, which was layout dependent. - Returns 'short' value - KeyEvent.keyCode() returns a short value, instead of int - KeyEvent.keyCode() shall return a layout independent value (Bug 641) - To ease implementation, we only 'require' the scan code to be mapped to a 'US Keyboard layout', which allows reusing layout dependent code while preserving the goal to have a fixed physical key association - Implementation status: - Windows OK - X11 TODO - OSX: 50/50 TODO - Using layout independent 'action keys' - Using layout dependent 'printable keys' - returning above semantics for both, keyCode and keySym - Android 50/50 TODO - Returning the layout independent keyCode - Mapping probably incomplete - KeyEvent.EVENT_KEY_TYPED and KeyListener.keyTyped(KeyEvent) (Bug 688) - Marked DEPRECATED - No more called for auto-repeat events - Synthesized in WindowImpl.consumeKeyEvent(..): No more injection by native- or java driver code - NEWTEvent.eventType: int -> short - field, as well as all method involving eventType changed to short. - NEWTEvent.isSystemEvent: REMOVED - Never used as well as never being implemented properly Internal Changes: - Simplified keyEvent driver code - Especially the Windows native driver's mapping code could be simplified using scanCode and MapVirtualKeyEx - NEWT Event Factories: hashMap -> switch/case Unit Tests: - - Added NewtCanvasAWT Offscreen Layer Tests important to test the AWT -> NEWT translation on OSX/CALayer: - TestNewtKeyCodeModifiersAWT - TestNewtKeyCodesAWT - TestNewtKeyEventAutoRepeatAWT - TestNewtKeyEventOrderAWT - TestNewtKeyPressReleaseUnmaskRepeatAWT --- make/build-test.xml | 38 ++ make/scripts/java-win32-dbg.bat | 1 + make/scripts/make.jogl.all.linux-x86_64.sh | 6 +- make/scripts/tests-x64.bat | 8 +- make/scripts/tests.sh | 7 +- .../classes/com/jogamp/newt/event/InputEvent.java | 10 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 552 ++++++++------- .../classes/com/jogamp/newt/event/KeyListener.java | 18 +- .../classes/com/jogamp/newt/event/MouseEvent.java | 61 +- .../classes/com/jogamp/newt/event/NEWTEvent.java | 72 +- .../classes/com/jogamp/newt/event/WindowEvent.java | 18 +- .../com/jogamp/newt/event/WindowUpdateEvent.java | 2 +- .../com/jogamp/newt/event/awt/AWTKeyAdapter.java | 3 - src/newt/classes/jogamp/newt/WindowImpl.java | 116 ++-- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 110 ++- .../android/event/AndroidNewtEventFactory.java | 100 ++- .../android/event/AndroidNewtEventTranslator.java | 8 +- .../newt/driver/linux/LinuxEventDeviceTracker.java | 33 +- .../newt/driver/linux/LinuxMouseTracker.java | 14 +- .../jogamp/newt/driver/macosx/MacKeyUtil.java | 262 ++++++-- .../jogamp/newt/driver/macosx/WindowDriver.java | 40 +- .../jogamp/newt/driver/windows/WindowDriver.java | 89 +-- .../jogamp/newt/driver/x11/WindowDriver.java | 33 +- .../jogamp/newt/swt/event/SWTNewtEventFactory.java | 52 +- src/newt/native/KDWindow.c | 12 +- src/newt/native/NewtMacWindow.h | 6 +- src/newt/native/NewtMacWindow.m | 36 +- src/newt/native/WindowsWindow.c | 743 ++++++++------------- src/newt/native/X11Display.c | 142 ++-- src/newt/native/bcm_vc_iv.c | 8 +- .../newt/event/TestNewtKeyCodeModifiersAWT.java | 113 ++-- .../test/junit/newt/event/TestNewtKeyCodesAWT.java | 52 +- .../newt/event/TestNewtKeyEventAutoRepeatAWT.java | 21 +- .../junit/newt/event/TestNewtKeyEventOrderAWT.java | 32 +- .../TestNewtKeyPressReleaseUnmaskRepeatAWT.java | 26 +- .../jogamp/opengl/test/junit/util/MiscUtils.java | 16 + .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 136 ++-- 37 files changed, 1578 insertions(+), 1418 deletions(-) (limited to 'src/newt/classes') diff --git a/make/build-test.xml b/make/build-test.xml index 4163e98bb..b3b121049 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -442,6 +442,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/make/scripts/java-win32-dbg.bat b/make/scripts/java-win32-dbg.bat index 1852d9b0c..cb2108b58 100755 --- a/make/scripts/java-win32-dbg.bat +++ b/make/scripts/java-win32-dbg.bat @@ -37,6 +37,7 @@ REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" "-Djogl.debug=all" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" +set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Xcheck:jni" "-Xint" "-verbose:jni" set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" diff --git a/make/scripts/make.jogl.all.linux-x86_64.sh b/make/scripts/make.jogl.all.linux-x86_64.sh index 4642326d5..0bdde6831 100755 --- a/make/scripts/make.jogl.all.linux-x86_64.sh +++ b/make/scripts/make.jogl.all.linux-x86_64.sh @@ -28,6 +28,9 @@ fi # -Dtarget.sourcelevel=1.6 \ # -Dtarget.targetlevel=1.6 \ # -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ +# +# -Dsetup.addNativeOpenMAX=true \ +# -Dsetup.addNativeKD=true \ #LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64 @@ -52,9 +55,6 @@ ant \ -Dtarget.sourcelevel=1.6 \ -Dtarget.targetlevel=1.6 \ -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ - -Djavacdebuglevel="source,lines,vars" \ -Drootrel.build=build-x86_64 \ - -Dsetup.addNativeOpenMAX=true \ - -Dsetup.addNativeKD=true \ $* 2>&1 | tee -a $LOGF diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index b4b05d58b..df855bf56 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -65,14 +65,16 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* + +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5a7c0f0ec..7a65c736a 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -168,7 +168,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -302,7 +302,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove03GLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* @@ -417,8 +417,9 @@ testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanva #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index ad77ec79f..9ef4de2b6 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -86,7 +86,7 @@ public abstract class InputEvent extends NEWTEvent */ public static final Object consumedTag = new Object(); - protected InputEvent(int eventType, Object source, long when, int modifiers) { + protected InputEvent(short eventType, Object source, long when, int modifiers) { super(eventType, source, when); this.modifiers=modifiers; } @@ -154,16 +154,16 @@ public abstract class InputEvent extends NEWTEvent * @return Array of pressed mouse buttons [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON6}]. * If none is down, the resulting array is of length 0. */ - public final int[] getButtonsDown() { + public final short[] getButtonsDown() { int len = 0; for(int i=1; i<=MouseEvent.BUTTON_NUMBER; i++) { - if(isButtonDown(i)) { len++; } + if( isButtonDown(i) ) { len++; } } - int[] res = new int[len]; + short[] res = new short[len]; int j = 0; for(int i=1; i<=MouseEvent.BUTTON_NUMBER; i++) { - if(isButtonDown(i)) { res[j++] = ( MouseEvent.BUTTON1 - 1 ) + i; } + if( isButtonDown(i) ) { res[j++] = (short) ( ( MouseEvent.BUTTON1 - 1 ) + i ); } } return res; } diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index ff67b7f57..f626fec38 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -36,68 +36,123 @@ package com.jogamp.newt.event; /** * Key events are delivered in the following order: - *

      - *
    1. {@link #EVENT_KEY_PRESSED}
    2. - *
    3. {@link #EVENT_KEY_RELEASED}
    4. - *
    5. {@link #EVENT_KEY_TYPED}
    6. - *
    + *

    + * + * + * + * + * + *
    #Event Type Constraints Notes
    1{@link #EVENT_KEY_PRESSED} excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys
    2{@link #EVENT_KEY_RELEASED} excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys
    3{@link #EVENT_KEY_TYPED} only for {@link #isPrintableKey() printable} and non {@link #isAutoRepeat() auto-repeat} keysDeprecated: Use {@link #EVENT_KEY_RELEASED} and apply constraints.
    + *

    * In case the native platform does not * deliver keyboard events in the above order or skip events, * the NEWT driver will reorder and inject synthetic events if required. *

    * Besides regular modifiers like {@link InputEvent#SHIFT_MASK} etc., - * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected. + * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected, following above constraints. *

    *

    * Auto-Repeat shall behave as follow: *

    -    D = pressed, U = released, T = typed
    +    P = pressed, R = released, T = typed
         0 = normal, 1 = auto-repeat
     
    -    D(0), [ U(1), T(1), D(1), U(1) T(1) ..], U(0) T(0)
    +    P(0), [ R(1), P(1), R(1), ..], R(0) T(0)    
      * 
    * The idea is if you mask out auto-repeat in your event listener - * you just get one long pressed key D/U/T triple. + * or catch {@link #EVENT_KEY_TYPED typed} events only, + * you just get one long pressed P/R/T triple for {@link #isPrintableKey() printable} keys. + * {@link #isActionKey() Action} keys would produce one long pressed P/R tuple in case you mask out auto-repeat . + *

    + *

    + * {@link #isActionKey() Action} keys will produce {@link #EVENT_KEY_PRESSED pressed} + * and {@link #EVENT_KEY_RELEASED released} events including {@link #isAutoRepeat() auto-repeat}. + *

    + *

    + * {@link #isPrintableKey() Printable} keys will produce {@link #EVENT_KEY_PRESSED pressed}, + * {@link #EVENT_KEY_RELEASED released} and {@link #EVENT_KEY_TYPED typed} events, the latter is excluded for {@link #isAutoRepeat() auto-repeat} events. *

    *

    - * {@link #isModifierKey() Modifiers keys} will produce regular events (pressed, released and typed), - * however they will not produce Auto-Repeat events itself. + * {@link #isModifierKey() Modifier} keys will produce {@link #EVENT_KEY_PRESSED pressed} + * and {@link #EVENT_KEY_RELEASED released} events excluding {@link #isAutoRepeat() auto-repeat}. + * They will also influence subsequent event's {@link #getModifiers() modifier} bits while pressed. *

    */ @SuppressWarnings("serial") public class KeyEvent extends InputEvent { - public KeyEvent(int eventType, Object source, long when, int modifiers, int keyCode, char keyChar) { + public KeyEvent(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, char keyChar) { super(eventType, source, when, modifiers); this.keyCode=keyCode; + this.keySym=keySym; this.keyChar=keyChar; + { // cache modifier and action flags + byte _flags = 0; + if( isModifierKey(keySym) ) { + _flags |= F_MODIFIER_MASK; + } + if( isActionKey(keySym) ) { + _flags |= F_ACTION_MASK; + } + flags = _flags; + } } /** - * Returns the character matching the {@link #getKeyCode() virtual key code}. + * Returns the UTF-16 character reflecting the {@link #getKeySymbol() key symbol}. + * @see #getKeySymbol() + * @see #getKeyCode() */ - public char getKeyChar() { + public final char getKeyChar() { return keyChar; } - /** Returns the virtual key code. */ - public int getKeyCode() { + /** + * Returns the virtual key symbol reflecting the current keyboard layout. + * @see #getKeyChar() + * @see #getKeyCode() + */ + public final short getKeySymbol() { + return keySym; + } + + /** + * Returns the virtual key code using a fixed mapping to the US keyboard layout. + *

    + * In contrast to {@link #getKeySymbol() key symbol}, key code + * uses a fixed US keyboard layout and therefore is keyboard layout independent. + *

    + *

    + * E.g. virtual key code {@link #VK_Y} denotes the same physical key + * regardless whether keyboard layout QWERTY or + * QWERTZ is active. The {@link #getKeySymbol() key symbol} of the former is + * {@link #VK_Y}, where the latter produces {@link #VK_Y}. + *

    + *

    + * Disclaimer: In case key code is not implemented on your platform (OSX, ..) + * the {@link #getKeySymbol() key symbol} is returned. + *

    + * @see #getKeyChar() + * @see #getKeySymbol() + */ + public final short getKeyCode() { return keyCode; } - public String toString() { + public final String toString() { return toString(null).toString(); } - public StringBuilder toString(StringBuilder sb) { + public final StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); } - sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(keyCode).append("(").append(toHexString(keyCode)).append("), char '").append(keyChar).append("' (").append(toHexString((int)keyChar)).append("), isActionKey ").append(isActionKey()).append(", "); + sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(toHexString(keyCode)).append(", sym ").append(toHexString(keySym)).append(", char '").append(keyChar).append("' (").append(toHexString((short)keyChar)) + .append("), isModifierKey ").append(isModifierKey()).append(", isActionKey ").append(isActionKey()).append(", "); return super.toString(sb).append("]"); } - public static String getEventTypeString(int type) { + public static String getEventTypeString(short type) { switch(type) { case EVENT_KEY_PRESSED: return "EVENT_KEY_PRESSED"; case EVENT_KEY_RELEASED: return "EVENT_KEY_RELEASED"; @@ -107,13 +162,13 @@ public class KeyEvent extends InputEvent } /** - * Returns true if the given keyCode represents a non-printable modifier key. + * Returns true if the given virtualKey represents a modifier key, otherwise false. *

    * A modifier key is one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. *

    */ - public static boolean isModifierKey(int keyCode) { - switch (keyCode) { + public static boolean isModifierKey(short vKey) { + switch (vKey) { case VK_SHIFT: case VK_CONTROL: case VK_ALT: @@ -126,31 +181,36 @@ public class KeyEvent extends InputEvent } /** - * Returns true if {@link #getKeyCode()} represents a non-printable modifier key. + * Returns true if {@link #getKeySymbol() key symbol} represents a modifier key, + * otherwise false. + *

    + * See {@link #isModifierKey(short)} for details. + *

    *

    - * See {@link #isModifierKey(int)} for details. + * Note: Implementation uses a cached value. *

    */ - public boolean isModifierKey() { - return isModifierKey(keyCode); + public final boolean isModifierKey() { + return 0 != ( F_MODIFIER_MASK & flags ) ; } /** - * Returns true if the given keyCode represents a non-printable action key, which is not a {@link #isModifierKey(int) modifier key}. + * Returns true if the given virtualKey represents a non-printable and + * non-{@link #isModifierKey(short) modifier} action key, otherwise false. *

    * An action key is one of {@link #VK_HOME}, {@link #VK_END}, {@link #VK_PAGE_UP}, {@link #VK_PAGE_DOWN}, {@link #VK_UP}, {@link #VK_PAGE_DOWN}, * {@link #VK_LEFT}, {@link #VK_RIGHT}, {@link #VK_F1}-{@link #VK_F24}, {@link #VK_PRINTSCREEN}, {@link #VK_CAPS_LOCK}, {@link #VK_PAUSE}, * {@link #VK_INSERT}, {@link #VK_HELP}, {@link #VK_WINDOWS}, etc ... *

    */ - public static boolean isActionKey(int keyCode) { - if( ( VK_F1 <= keyCode && keyCode <= VK_F24 ) || - ( VK_ALL_CANDIDATES <= keyCode && keyCode <= VK_INPUT_METHOD_ON_OFF ) || - ( VK_CUT <= keyCode && keyCode <= VK_STOP ) ) { + public static boolean isActionKey(short vKey) { + if( ( VK_F1 <= vKey && vKey <= VK_F24 ) || + ( VK_ALL_CANDIDATES <= vKey && vKey <= VK_INPUT_METHOD_ON_OFF ) || + ( VK_CUT <= vKey && vKey <= VK_STOP ) ) { return true; } - switch (keyCode) { + switch (vKey) { case VK_CANCEL: case VK_CLEAR: case VK_PAUSE: @@ -208,600 +268,614 @@ public class KeyEvent extends InputEvent } /** - * Returns true if {@link #getKeyCode() keyCode} represents a non-printable action key, which is not a {@link #isModifierKey(int) modifier key}. + * Returns true if {@link #getKeySymbol() key symbol} represents a non-printable and + * non-{@link #isModifierKey(short) modifier} action key, otherwise false. *

    - * See {@link #isActionKey(int)} for details. + * See {@link #isActionKey(short)} for details. *

    */ - public boolean isActionKey() { - return isActionKey(keyCode); + public final boolean isActionKey() { + return 0 != ( F_ACTION_MASK & flags ) ; } /** - * Returns true if given keyKode represents a printable character, which is neither a {@link #isModifierKey(int) modifier key} - * nor an {@link #isActionKey(int) action key}. + * Returns true if given virtualKey represents a printable character, + * i.e. neither a {@link #isModifierKey(short) modifier key} + * nor an {@link #isActionKey(short) action key}. * Otherwise returns false. */ - public static boolean isPrintableKey(int keyCode) { - return !isModifierKey(keyCode) && !isActionKey(keyCode); + public static boolean isPrintableKey(short vKey) { + return !isModifierKey(vKey) && !isActionKey(vKey); } /** - * Returns true if {@link #getKeyCode() keyCode} represents a printable character, which is neither a {@link #isModifierKey(int) modifier key} - * nor an {@link #isActionKey(int) action key}. + * Returns true if {@link #getKeySymbol() key symbol} represents a printable character, + * i.e. neither a {@link #isModifierKey(short) modifier key} + * nor an {@link #isActionKey(short) action key}. * Otherwise returns false. */ - public boolean isPrintableKey() { - return isPrintableKey(keyCode); + public final boolean isPrintableKey() { + return 0 == ( F_NON_PRINT_MASK & flags ) ; } - private final int keyCode; + private final short keyCode; + private final short keySym; private final 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; + private final byte flags; + private static final byte F_MODIFIER_MASK = 1 << 0; + private static final byte F_ACTION_MASK = 1 << 1; + private static final byte F_NON_PRINT_MASK = F_MODIFIER_MASK | F_ACTION_MASK ; + + /** A key has been pressed, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */ + public static final short EVENT_KEY_PRESSED = 300; + /** A key has been released, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */ + public static final short EVENT_KEY_RELEASED= 301; + /** + * A {@link #isPrintableKey() printable} key has been typed (pressed and released), excluding {@link #isAutoRepeat() auto-repeat}. + * @deprecated Redundant, will be removed soon. Use {@link #EVENT_KEY_RELEASED} and exclude non {@link #isPrintableKey() printable} keys and {@link #isAutoRepeat() auto-repeat}. + */ + public static final short EVENT_KEY_TYPED = 302; /* Virtual key codes. */ - public static final int VK_CANCEL = 0x03; - public static final int VK_BACK_SPACE = 0x08; // '\b' - public static final int VK_TAB = 0x09; // '\t' - public static final int VK_ENTER = 0x0A; // '\n' - 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; + public static final short VK_CANCEL = (short) 0x03; + public static final short VK_BACK_SPACE = (short) 0x08; // '\b' + public static final short VK_TAB = (short) 0x09; // '\t' + public static final short VK_ENTER = (short) 0x0A; // '\n' + public static final short VK_CLEAR = (short) 0x0C; + public static final short VK_SHIFT = (short) 0x10; + public static final short VK_CONTROL = (short) 0x11; + public static final short VK_ALT = (short) 0x12; + public static final short VK_PAUSE = (short) 0x13; + public static final short VK_CAPS_LOCK = (short) 0x14; + public static final short VK_ESCAPE = (short) 0x1B; + public static final short VK_SPACE = (short) 0x20; + public static final short VK_PAGE_UP = (short) 0x21; + public static final short VK_PAGE_DOWN = (short) 0x22; + public static final short VK_END = (short) 0x23; + public static final short VK_HOME = (short) 0x24; /** * Constant for the non-numpad left arrow key. * @see #VK_KP_LEFT */ - public static final int VK_LEFT = 0x25; + public static final short VK_LEFT = (short) 0x25; /** * Constant for the non-numpad up arrow key. * @see #VK_KP_UP */ - public static final int VK_UP = 0x26; + public static final short VK_UP = (short) 0x26; /** * Constant for the non-numpad right arrow key. * @see #VK_KP_RIGHT */ - public static final int VK_RIGHT = 0x27; + public static final short VK_RIGHT = (short) 0x27; /** * Constant for the non-numpad down arrow key. * @see #VK_KP_DOWN */ - public static final int VK_DOWN = 0x28; + public static final short VK_DOWN = (short) 0x28; /** * Constant for the comma key, "," */ - public static final int VK_COMMA = 0x2C; + public static final short VK_COMMA = (short) 0x2C; /** * Constant for the minus key, "-" * @since 1.2 */ - public static final int VK_MINUS = 0x2D; + public static final short VK_MINUS = (short) 0x2D; /** * Constant for the period key, "." */ - public static final int VK_PERIOD = 0x2E; + public static final short VK_PERIOD = (short) 0x2E; /** * Constant for the forward slash key, "/" */ - public static final int VK_SLASH = 0x2F; + public static final short VK_SLASH = (short) 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; + public static final short VK_0 = (short) 0x30; + public static final short VK_1 = (short) 0x31; + public static final short VK_2 = (short) 0x32; + public static final short VK_3 = (short) 0x33; + public static final short VK_4 = (short) 0x34; + public static final short VK_5 = (short) 0x35; + public static final short VK_6 = (short) 0x36; + public static final short VK_7 = (short) 0x37; + public static final short VK_8 = (short) 0x38; + public static final short VK_9 = (short) 0x39; /** * Constant for the semicolon key, ";" */ - public static final int VK_SEMICOLON = 0x3B; + public static final short VK_SEMICOLON = (short) 0x3B; /** * Constant for the equals key, "=" */ - public static final int VK_EQUALS = 0x3D; + public static final short VK_EQUALS = (short) 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; + public static final short VK_A = (short) 0x41; + public static final short VK_B = (short) 0x42; + public static final short VK_C = (short) 0x43; + public static final short VK_D = (short) 0x44; + public static final short VK_E = (short) 0x45; + public static final short VK_F = (short) 0x46; + public static final short VK_G = (short) 0x47; + public static final short VK_H = (short) 0x48; + public static final short VK_I = (short) 0x49; + public static final short VK_J = (short) 0x4A; + public static final short VK_K = (short) 0x4B; + public static final short VK_L = (short) 0x4C; + public static final short VK_M = (short) 0x4D; + public static final short VK_N = (short) 0x4E; + public static final short VK_O = (short) 0x4F; + public static final short VK_P = (short) 0x50; + public static final short VK_Q = (short) 0x51; + public static final short VK_R = (short) 0x52; + public static final short VK_S = (short) 0x53; + public static final short VK_T = (short) 0x54; + public static final short VK_U = (short) 0x55; + public static final short VK_V = (short) 0x56; + public static final short VK_W = (short) 0x57; + public static final short VK_X = (short) 0x58; + public static final short VK_Y = (short) 0x59; + public static final short VK_Z = (short) 0x5A; /** * Constant for the open bracket key, "[" */ - public static final int VK_OPEN_BRACKET = 0x5B; + public static final short VK_OPEN_BRACKET = (short) 0x5B; /** * Constant for the back slash key, "\" */ - public static final int VK_BACK_SLASH = 0x5C; + public static final short VK_BACK_SLASH = (short) 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; + public static final short VK_CLOSE_BRACKET = (short) 0x5D; + + public static final short VK_NUMPAD0 = (short) 0x60; + public static final short VK_NUMPAD1 = (short) 0x61; + public static final short VK_NUMPAD2 = (short) 0x62; + public static final short VK_NUMPAD3 = (short) 0x63; + public static final short VK_NUMPAD4 = (short) 0x64; + public static final short VK_NUMPAD5 = (short) 0x65; + public static final short VK_NUMPAD6 = (short) 0x66; + public static final short VK_NUMPAD7 = (short) 0x67; + public static final short VK_NUMPAD8 = (short) 0x68; + public static final short VK_NUMPAD9 = (short) 0x69; + public static final short VK_MULTIPLY = (short) 0x6A; + public static final short VK_ADD = (short) 0x6B; /** * Constant for the Numpad Separator key. */ - public static final int VK_SEPARATOR = 0x6C; + public static final short VK_SEPARATOR = (short) 0x6C; - 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; + public static final short VK_SUBTRACT = (short) 0x6D; + public static final short VK_DECIMAL = (short) 0x6E; + public static final short VK_DIVIDE = (short) 0x6F; + public static final short VK_DELETE = (short) 0x7F; /* ASCII DEL */ + public static final short VK_NUM_LOCK = (short) 0x90; + public static final short VK_SCROLL_LOCK = (short) 0x91; /** Constant for the F1 function key. */ - public static final int VK_F1 = 0x70; + public static final short VK_F1 = (short) 0x70; /** Constant for the F2 function key. */ - public static final int VK_F2 = 0x71; + public static final short VK_F2 = (short) 0x71; /** Constant for the F3 function key. */ - public static final int VK_F3 = 0x72; + public static final short VK_F3 = (short) 0x72; /** Constant for the F4 function key. */ - public static final int VK_F4 = 0x73; + public static final short VK_F4 = (short) 0x73; /** Constant for the F5 function key. */ - public static final int VK_F5 = 0x74; + public static final short VK_F5 = (short) 0x74; /** Constant for the F6 function key. */ - public static final int VK_F6 = 0x75; + public static final short VK_F6 = (short) 0x75; /** Constant for the F7 function key. */ - public static final int VK_F7 = 0x76; + public static final short VK_F7 = (short) 0x76; /** Constant for the F8 function key. */ - public static final int VK_F8 = 0x77; + public static final short VK_F8 = (short) 0x77; /** Constant for the F9 function key. */ - public static final int VK_F9 = 0x78; + public static final short VK_F9 = (short) 0x78; /** Constant for the F10 function key. */ - public static final int VK_F10 = 0x79; + public static final short VK_F10 = (short) 0x79; /** Constant for the F11 function key. */ - public static final int VK_F11 = 0x7A; + public static final short VK_F11 = (short) 0x7A; /** Constant for the F12 function key. */ - public static final int VK_F12 = 0x7B; + public static final short VK_F12 = (short) 0x7B; /** * Constant for the F13 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F13 = 0xF000; + public static final short VK_F13 = (short) 0xF000; /** * Constant for the F14 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F14 = 0xF001; + public static final short VK_F14 = (short) 0xF001; /** * Constant for the F15 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F15 = 0xF002; + public static final short VK_F15 = (short) 0xF002; /** * Constant for the F16 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F16 = 0xF003; + public static final short VK_F16 = (short) 0xF003; /** * Constant for the F17 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F17 = 0xF004; + public static final short VK_F17 = (short) 0xF004; /** * Constant for the F18 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F18 = 0xF005; + public static final short VK_F18 = (short) 0xF005; /** * Constant for the F19 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F19 = 0xF006; + public static final short VK_F19 = (short) 0xF006; /** * Constant for the F20 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F20 = 0xF007; + public static final short VK_F20 = (short) 0xF007; /** * Constant for the F21 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F21 = 0xF008; + public static final short VK_F21 = (short) 0xF008; /** * Constant for the F22 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F22 = 0xF009; + public static final short VK_F22 = (short) 0xF009; /** * Constant for the F23 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F23 = 0xF00A; + public static final short VK_F23 = (short) 0xF00A; /** * Constant for the F24 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F24 = 0xF00B; + public static final short VK_F24 = (short) 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 short VK_PRINTSCREEN = (short) 0x9A; + public static final short VK_INSERT = (short) 0x9B; + public static final short VK_HELP = (short) 0x9C; + public static final short VK_META = (short) 0x9D; - public static final int VK_BACK_QUOTE = 0xC0; - public static final int VK_QUOTE = 0xDE; + public static final short VK_BACK_QUOTE = (short) 0xC0; + public static final short VK_QUOTE = (short) 0xDE; /** * Constant for the numeric keypad up arrow key. * @see #VK_UP */ - public static final int VK_KP_UP = 0xE0; + public static final short VK_KP_UP = (short) 0xE0; /** * Constant for the numeric keypad down arrow key. * @see #VK_DOWN */ - public static final int VK_KP_DOWN = 0xE1; + public static final short VK_KP_DOWN = (short) 0xE1; /** * Constant for the numeric keypad left arrow key. * @see #VK_LEFT */ - public static final int VK_KP_LEFT = 0xE2; + public static final short VK_KP_LEFT = (short) 0xE2; /** * Constant for the numeric keypad right arrow key. * @see #VK_RIGHT */ - public static final int VK_KP_RIGHT = 0xE3; + public static final short VK_KP_RIGHT = (short) 0xE3; /** For European keyboards */ - public static final int VK_DEAD_GRAVE = 0x80; + public static final short VK_DEAD_GRAVE = (short) 0x80; /** For European keyboards */ - public static final int VK_DEAD_ACUTE = 0x81; + public static final short VK_DEAD_ACUTE = (short) 0x81; /** For European keyboards */ - public static final int VK_DEAD_CIRCUMFLEX = 0x82; + public static final short VK_DEAD_CIRCUMFLEX = (short) 0x82; /** For European keyboards */ - public static final int VK_DEAD_TILDE = 0x83; + public static final short VK_DEAD_TILDE = (short) 0x83; /** For European keyboards */ - public static final int VK_DEAD_MACRON = 0x84; + public static final short VK_DEAD_MACRON = (short) 0x84; /** For European keyboards */ - public static final int VK_DEAD_BREVE = 0x85; + public static final short VK_DEAD_BREVE = (short) 0x85; /** For European keyboards */ - public static final int VK_DEAD_ABOVEDOT = 0x86; + public static final short VK_DEAD_ABOVEDOT = (short) 0x86; /** For European keyboards */ - public static final int VK_DEAD_DIAERESIS = 0x87; + public static final short VK_DEAD_DIAERESIS = (short) 0x87; /** For European keyboards */ - public static final int VK_DEAD_ABOVERING = 0x88; + public static final short VK_DEAD_ABOVERING = (short) 0x88; /** For European keyboards */ - public static final int VK_DEAD_DOUBLEACUTE = 0x89; + public static final short VK_DEAD_DOUBLEACUTE = (short) 0x89; /** For European keyboards */ - public static final int VK_DEAD_CARON = 0x8a; + public static final short VK_DEAD_CARON = (short) 0x8a; /** For European keyboards */ - public static final int VK_DEAD_CEDILLA = 0x8b; + public static final short VK_DEAD_CEDILLA = (short) 0x8b; /** For European keyboards */ - public static final int VK_DEAD_OGONEK = 0x8c; + public static final short VK_DEAD_OGONEK = (short) 0x8c; /** For European keyboards */ - public static final int VK_DEAD_IOTA = 0x8d; + public static final short VK_DEAD_IOTA = (short) 0x8d; /** For European keyboards */ - public static final int VK_DEAD_VOICED_SOUND = 0x8e; + public static final short VK_DEAD_VOICED_SOUND = (short) 0x8e; /** For European keyboards */ - public static final int VK_DEAD_SEMIVOICED_SOUND = 0x8f; + public static final short VK_DEAD_SEMIVOICED_SOUND = (short) 0x8f; /** For European keyboards */ - public static final int VK_AMPERSAND = 0x96; + public static final short VK_AMPERSAND = (short) 0x96; /** For European keyboards */ - public static final int VK_ASTERISK = 0x97; + public static final short VK_ASTERISK = (short) 0x97; /** For European keyboards */ - public static final int VK_QUOTEDBL = 0x98; + public static final short VK_QUOTEDBL = (short) 0x98; /** For European keyboards */ - public static final int VK_LESS = 0x99; + public static final short VK_LESS = (short) 0x99; /** For European keyboards */ - public static final int VK_GREATER = 0xa0; + public static final short VK_GREATER = (short) 0xa0; /** For European keyboards */ - public static final int VK_BRACELEFT = 0xa1; + public static final short VK_BRACELEFT = (short) 0xa1; /** For European keyboards */ - public static final int VK_BRACERIGHT = 0xa2; + public static final short VK_BRACERIGHT = (short) 0xa2; /** * Constant for the "@" key. */ - public static final int VK_AT = 0x0200; + public static final short VK_AT = (short) 0x0200; /** * Constant for the ":" key. */ - public static final int VK_COLON = 0x0201; + public static final short VK_COLON = (short) 0x0201; /** * Constant for the "^" key. */ - public static final int VK_CIRCUMFLEX = 0x0202; + public static final short VK_CIRCUMFLEX = (short) 0x0202; /** * Constant for the "$" key. */ - public static final int VK_DOLLAR = 0x0203; + public static final short VK_DOLLAR = (short) 0x0203; /** * Constant for the Euro currency sign key. */ - public static final int VK_EURO_SIGN = 0x0204; + public static final short VK_EURO_SIGN = (short) 0x0204; /** * Constant for the "!" key. */ - public static final int VK_EXCLAMATION_MARK = 0x0205; + public static final short VK_EXCLAMATION_MARK = (short) 0x0205; /** * Constant for the inverted exclamation mark key. */ - public static final int VK_INVERTED_EXCLAMATION_MARK = 0x0206; + public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0x0206; /** * Constant for the "(" key. */ - public static final int VK_LEFT_PARENTHESIS = 0x0207; + public static final short VK_LEFT_PARENTHESIS = (short) 0x0207; /** * Constant for the "#" key. */ - public static final int VK_NUMBER_SIGN = 0x0208; + public static final short VK_NUMBER_SIGN = (short) 0x0208; /** * Constant for the "+" key. */ - public static final int VK_PLUS = 0x0209; + public static final short VK_PLUS = (short) 0x0209; /** * Constant for the ")" key. */ - public static final int VK_RIGHT_PARENTHESIS = 0x020A; + public static final short VK_RIGHT_PARENTHESIS = (short) 0x020A; /** * Constant for the "_" key. */ - public static final int VK_UNDERSCORE = 0x020B; + public static final short VK_UNDERSCORE = (short) 0x020B; /** * Constant for the Microsoft Windows "Windows" key. * It is used for both the left and right version of the key. */ - public static final int VK_WINDOWS = 0x020C; + public static final short VK_WINDOWS = (short) 0x020C; /** * Constant for the Microsoft Windows Context Menu key. */ - public static final int VK_CONTEXT_MENU = 0x020D; + public static final short VK_CONTEXT_MENU = (short) 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; + public static final short VK_FINAL = (short) 0x0018; /** Constant for the Convert function key. */ /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */ - public static final int VK_CONVERT = 0x001C; + public static final short VK_CONVERT = (short) 0x001C; /** Constant for the Don't Convert function key. */ /* Japanese PC 106 keyboard: muhenkan */ - public static final int VK_NONCONVERT = 0x001D; + public static final short VK_NONCONVERT = (short) 0x001D; /** Constant for the Accept or Commit function key. */ /* Japanese Solaris keyboard: kakutei */ - public static final int VK_ACCEPT = 0x001E; + public static final short VK_ACCEPT = (short) 0x001E; /* not clear what this means - listed in Microsoft Windows API */ - public static final int VK_MODECHANGE = 0x001F; + public static final short VK_MODECHANGE = (short) 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; + public static final short VK_KANA = (short) 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; + public static final short VK_KANJI = (short) 0x0019; /** * Constant for the Alphanumeric function key. */ /* Japanese PC 106 keyboard: eisuu */ - public static final int VK_ALPHANUMERIC = 0x00F0; + public static final short VK_ALPHANUMERIC = (short) 0x00F0; /** * Constant for the Katakana function key. */ /* Japanese PC 106 keyboard: katakana */ - public static final int VK_KATAKANA = 0x00F1; + public static final short VK_KATAKANA = (short) 0x00F1; /** * Constant for the Hiragana function key. */ /* Japanese PC 106 keyboard: hiragana */ - public static final int VK_HIRAGANA = 0x00F2; + public static final short VK_HIRAGANA = (short) 0x00F2; /** * Constant for the Full-Width Characters function key. */ /* Japanese PC 106 keyboard: zenkaku */ - public static final int VK_FULL_WIDTH = 0x00F3; + public static final short VK_FULL_WIDTH = (short) 0x00F3; /** * Constant for the Half-Width Characters function key. */ /* Japanese PC 106 keyboard: hankaku */ - public static final int VK_HALF_WIDTH = 0x00F4; + public static final short VK_HALF_WIDTH = (short) 0x00F4; /** * Constant for the Roman Characters function key. */ /* Japanese PC 106 keyboard: roumaji */ - public static final int VK_ROMAN_CHARACTERS = 0x00F5; + public static final short VK_ROMAN_CHARACTERS = (short) 0x00F5; /** * Constant for the All Candidates function key. */ /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */ - public static final int VK_ALL_CANDIDATES = 0x0100; + public static final short VK_ALL_CANDIDATES = (short) 0x0100; /** * Constant for the Previous Candidate function key. */ /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */ - public static final int VK_PREVIOUS_CANDIDATE = 0x0101; + public static final short VK_PREVIOUS_CANDIDATE = (short) 0x0101; /** * Constant for the Code Input function key. */ /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */ - public static final int VK_CODE_INPUT = 0x0102; + public static final short VK_CODE_INPUT = (short) 0x0102; /** * Constant for the Japanese-Katakana function key. * This key switches to a Japanese input method and selects its Katakana input mode. */ /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */ - public static final int VK_JAPANESE_KATAKANA = 0x0103; + public static final short VK_JAPANESE_KATAKANA = (short) 0x0103; /** * Constant for the Japanese-Hiragana function key. * This key switches to a Japanese input method and selects its Hiragana input mode. */ /* Japanese Macintosh keyboard */ - public static final int VK_JAPANESE_HIRAGANA = 0x0104; + public static final short VK_JAPANESE_HIRAGANA = (short) 0x0104; /** * Constant for the Japanese-Roman function key. * This key switches to a Japanese input method and selects its Roman-Direct input mode. */ /* Japanese Macintosh keyboard */ - public static final int VK_JAPANESE_ROMAN = 0x0105; + public static final short VK_JAPANESE_ROMAN = (short) 0x0105; /** * Constant for the locking Kana function key. * This key locks the keyboard into a Kana layout. */ /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */ - public static final int VK_KANA_LOCK = 0x0106; + public static final short VK_KANA_LOCK = (short) 0x0106; /** * Constant for the input method on/off key. */ /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */ - public static final int VK_INPUT_METHOD_ON_OFF = 0x0107; + public static final short VK_INPUT_METHOD_ON_OFF = (short) 0x0107; /* for Sun keyboards */ - public static final int VK_CUT = 0xFFD1; - public static final int VK_COPY = 0xFFCD; - public static final int VK_PASTE = 0xFFCF; - public static final int VK_UNDO = 0xFFCB; - public static final int VK_AGAIN = 0xFFC9; - public static final int VK_FIND = 0xFFD0; - public static final int VK_PROPS = 0xFFCA; - public static final int VK_STOP = 0xFFC8; + public static final short VK_CUT = (short) 0xFFD1; + public static final short VK_COPY = (short) 0xFFCD; + public static final short VK_PASTE = (short) 0xFFCF; + public static final short VK_UNDO = (short) 0xFFCB; + public static final short VK_AGAIN = (short) 0xFFC9; + public static final short VK_FIND = (short) 0xFFD0; + public static final short VK_PROPS = (short) 0xFFCA; + public static final short VK_STOP = (short) 0xFFC8; /** * Constant for the Compose function key. */ - public static final int VK_COMPOSE = 0xFF20; + public static final short VK_COMPOSE = (short) 0xFF20; /** * Constant for the AltGraph function key. */ - public static final int VK_ALT_GRAPH = 0xFF7E; + public static final short VK_ALT_GRAPH = (short) 0xFF7E; /** * Constant for the Begin key. */ - public static final int VK_BEGIN = 0xFF58; + public static final short VK_BEGIN = (short) 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; + public static final short VK_UNDEFINED = (short) 0x0; } diff --git a/src/newt/classes/com/jogamp/newt/event/KeyListener.java b/src/newt/classes/com/jogamp/newt/event/KeyListener.java index dae343d80..5bca733d3 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyListener.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyListener.java @@ -34,10 +34,22 @@ package com.jogamp.newt.event; +/** + * Listener for {@link KeyEvent}s. + * + * @see KeyEvent + */ public interface KeyListener extends NEWTEventListener { - public void keyPressed(KeyEvent e); - public void keyReleased(KeyEvent e); - public void keyTyped(KeyEvent e) ; + /** A key has been {@link KeyEvent#EVENT_KEY_PRESSED pressed}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */ + public void keyPressed(KeyEvent e); + /** A key has been {@link KeyEvent#EVENT_KEY_RELEASED released}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */ + public void keyReleased(KeyEvent e); + + /** + * A {@link #isPrintableKey() printable} key has been {@link KeyEvent#EVENT_KEY_TYPED typed} (pressed and released), excluding {@link #isAutoRepeat() auto-repeat}. See {@link KeyEvent}. + * @deprecated Redundant, will be removed soon. Use {@link #keyReleased(KeyEvent)} and exclude non {@link #isPrintableKey() printable} keys and {@link #isAutoRepeat() auto-repeat}. + */ + public void keyTyped(KeyEvent e) ; } diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index e6b3d8a24..23549533e 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -38,47 +38,47 @@ package com.jogamp.newt.event; public class MouseEvent extends InputEvent { /** ID for button 1, value 1 */ - public static final int BUTTON1 = 1; + public static final short BUTTON1 = 1; /** ID for button 2, value 2 */ - public static final int BUTTON2 = 2; + public static final short BUTTON2 = 2; /** ID for button 3, value 3 */ - public static final int BUTTON3 = 3; + public static final short BUTTON3 = 3; /** ID for button 4, value 4 */ - public static final int BUTTON4 = 4; + public static final short BUTTON4 = 4; /** ID for button 5, value 5 */ - public static final int BUTTON5 = 5; + public static final short BUTTON5 = 5; /** ID for button 6, value 6 */ - public static final int BUTTON6 = 6; + public static final short BUTTON6 = 6; /** ID for button 6, value 7 */ - public static final int BUTTON7 = 7; + public static final short BUTTON7 = 7; /** ID for button 6, value 8 */ - public static final int BUTTON8 = 8; + public static final short BUTTON8 = 8; /** ID for button 6, value 9 */ - public static final int BUTTON9 = 9; + public static final short BUTTON9 = 9; /** Maximum number of buttons, value 16 */ - public static final int BUTTON_NUMBER = 16; + public static final short BUTTON_NUMBER = 16; - public static final int getClickTimeout() { + public static final short getClickTimeout() { return 300; } - public MouseEvent(int eventType, Object source, long when, - int modifiers, int x, int y, int clickCount, int button, + public MouseEvent(short eventType, Object source, long when, + int modifiers, int x, int y, short clickCount, short button, float rotation) { super(eventType, source, when, modifiers); this.x = new int[]{x}; this.y = new int[]{y}; this.pressure = new float[]{0}; - this.pointerids = new int[]{-1}; + this.pointerids = new short[]{-1}; this.clickCount=clickCount; this.button=button; this.wheelRotation = rotation; } - public MouseEvent(int eventType, Object source, long when, - int modifiers, int[] x, int[] y, float[] pressure, int[] pointerids, int clickCount, int button, + public MouseEvent(short eventType, Object source, long when, + int modifiers, int[] x, int[] y, float[] pressure, short[] pointerids, short clickCount, short button, float rotation) { super(eventType, source, when, modifiers); @@ -107,17 +107,17 @@ public class MouseEvent extends InputEvent * @return the pointer id for the data at index. * return -1 if index not available. */ - public int getPointerId(int index) { + public short getPointerId(int index) { if(index >= pointerids.length) return -1; return pointerids[index]; } - public int getButton() { + public short getButton() { return button; } - public int getClickCount() { + public short getClickCount() { return clickCount; } public int getX() { @@ -208,7 +208,7 @@ public class MouseEvent extends InputEvent return super.toString(sb).append("]"); } - public static String getEventTypeString(int type) { + public static String getEventTypeString(short type) { switch(type) { case EVENT_MOUSE_CLICKED: return "EVENT_MOUSE_CLICKED"; case EVENT_MOUSE_ENTERED: return "EVENT_MOUSE_ENTERED"; @@ -221,17 +221,18 @@ public class MouseEvent extends InputEvent default: return "unknown (" + type + ")"; } } - private final int x[], y[], clickCount, button; + private final int x[], y[];; + private final short clickCount, button; private final float wheelRotation; private final float pressure[]; - private final int pointerids[]; + private final short pointerids[]; - 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; + public static final short EVENT_MOUSE_CLICKED = 200; + public static final short EVENT_MOUSE_ENTERED = 201; + public static final short EVENT_MOUSE_EXITED = 202; + public static final short EVENT_MOUSE_PRESSED = 203; + public static final short EVENT_MOUSE_RELEASED = 204; + public static final short EVENT_MOUSE_MOVED = 205; + public static final short EVENT_MOUSE_DRAGGED = 206; + public static final short EVENT_MOUSE_WHEEL_MOVED = 207; } diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index 9d8d92ff6..b8de6eb18 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -48,81 +48,21 @@ package com.jogamp.newt.event; */ @SuppressWarnings("serial") public class NEWTEvent extends java.util.EventObject { - private final boolean isSystemEvent; - private final int eventType; + private final short eventType; private final long when; private Object attachment; static final boolean DEBUG = false; - // 0: NEWTEvent.java - // 1: InputEvent.java - // 2: KeyEvent.java - // 3: com.jogamp.newt.Window - // 3: com.jogamp.newt.event.awt.AWTNewtEventFactory - // 2: MouseEvent.java - // 3: com.jogamp.newt.Window - // 3: com.jogamp.newt.event.awt.AWTNewtEventFactory - // 1: WindowEvent.java - // 2: com.jogamp.newt.Window - // 2: com.jogamp.newt.event.awt.AWTNewtEventFactory - // - // FIXME: verify the isSystemEvent evaluation - // - static final String WindowClazzName = "com.jogamp.newt.Window" ; - static final String AWTNewtEventFactoryClazzName = "com.jogamp.newt.event.awt.AWTNewtEventFactory" ; - - /** - static final boolean evaluateIsSystemEvent(NEWTEvent event, Throwable t) { - StackTraceElement[] stack = t.getStackTrace(); - if(stack.length==0 || null==stack[0]) { - return false; - } - if(DEBUG) { - for (int i = 0; i < stack.length && i<5; i++) { - System.err.println(i+": " + stack[i].getClassName()+ "." + stack[i].getMethodName()); - } - } - - String clazzName = null; - - if( event instanceof com.jogamp.newt.event.WindowEvent ) { - if ( stack.length > 2 ) { - clazzName = stack[2].getClassName(); - } - } else if( (event instanceof com.jogamp.newt.event.MouseEvent) || - (event instanceof com.jogamp.newt.event.KeyEvent) ) { - if ( stack.length > 3 ) { - clazzName = stack[3].getClassName(); - } - } - - boolean res = null!=clazzName && ( - clazzName.equals(WindowClazzName) || - clazzName.equals(AWTNewtEventFactoryClazzName) ) ; - if(DEBUG) { - System.err.println("system: "+res); - } - return res; - } */ - - protected NEWTEvent(int eventType, Object source, long when) { + protected NEWTEvent(short eventType, Object source, long when) { super(source); - // this.isSystemEvent = evaluateIsSystemEvent(this, new Throwable()); - this.isSystemEvent = false; // FIXME: Need a more efficient way to determine system events this.eventType = eventType; this.when = when; this.attachment=null; } - /** 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() { + public final short getEventType() { return eventType; } @@ -158,10 +98,10 @@ public class NEWTEvent extends java.util.EventObject { if(null == sb) { sb = new StringBuilder(); } - return sb.append("NEWTEvent[sys:").append(isSystemEvent()).append(", source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); + return sb.append("NEWTEvent[source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); } - static String toHexString(int hex) { - return "0x" + Integer.toHexString(hex); + static String toHexString(short hex) { + return "0x" + Integer.toHexString( (int)hex & 0x0000FFFF ); } } diff --git a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java index 163b51439..24b3b380a 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java @@ -41,19 +41,19 @@ package com.jogamp.newt.event; */ @SuppressWarnings("serial") public class WindowEvent extends NEWTEvent { - public static final int EVENT_WINDOW_RESIZED = 100; - public static final int EVENT_WINDOW_MOVED = 101; - public static final int EVENT_WINDOW_DESTROY_NOTIFY = 102; - public static final int EVENT_WINDOW_GAINED_FOCUS = 103; - public static final int EVENT_WINDOW_LOST_FOCUS = 104; - public static final int EVENT_WINDOW_REPAINT = 105; - public static final int EVENT_WINDOW_DESTROYED = 106; + public static final short EVENT_WINDOW_RESIZED = 100; + public static final short EVENT_WINDOW_MOVED = 101; + public static final short EVENT_WINDOW_DESTROY_NOTIFY = 102; + public static final short EVENT_WINDOW_GAINED_FOCUS = 103; + public static final short EVENT_WINDOW_LOST_FOCUS = 104; + public static final short EVENT_WINDOW_REPAINT = 105; + public static final short EVENT_WINDOW_DESTROYED = 106; - public WindowEvent(int eventType, Object source, long when) { + public WindowEvent(short eventType, Object source, long when) { super(eventType, source, when); } - public static String getEventTypeString(int type) { + public static String getEventTypeString(short type) { switch(type) { case EVENT_WINDOW_RESIZED: return "WINDOW_RESIZED"; case EVENT_WINDOW_MOVED: return "WINDOW_MOVED"; diff --git a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java index e3f0373ec..a0f6e2cb4 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java @@ -34,7 +34,7 @@ import javax.media.nativewindow.util.Rectangle; public class WindowUpdateEvent extends WindowEvent { final Rectangle bounds; - public WindowUpdateEvent(int eventType, Object source, long when, Rectangle bounds) + public WindowUpdateEvent(short eventType, Object source, long when, Rectangle bounds) { super(eventType, source, when); this.bounds = bounds; diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java index 64071eed6..1edef347b 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java @@ -72,14 +72,11 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe @Override public void keyReleased(java.awt.event.KeyEvent e) { com.jogamp.newt.event.KeyEvent keyReleaseEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow); - com.jogamp.newt.event.KeyEvent keyTypedEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED, e, newtWindow); if(null!=newtListener) { final com.jogamp.newt.event.KeyListener newtKeyListener = (com.jogamp.newt.event.KeyListener)newtListener; newtKeyListener.keyReleased(keyReleaseEvt); - newtKeyListener.keyTyped(keyTypedEvt); } else { enqueueEvent(false, keyReleaseEvt); - enqueueEvent(false, keyTypedEvt); } } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index cb43fae32..73c0d2754 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -121,10 +121,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private ArrayList childWindows = new ArrayList(); private ArrayList mouseListeners = new ArrayList(); - private int mouseButtonPressed = 0; // current pressed mouse button number - private int mouseButtonModMask = 0; // current pressed mouse button modifier mask + private short mouseButtonPressed = (short)0; // current pressed mouse button number + private int mouseButtonModMask = 0; // current pressed mouse button modifier mask private long lastMousePressed = 0; // last time when a mouse button was pressed - private int lastMouseClickCount = 0; // last mouse button click count + private short lastMouseClickCount = (short)0; // last mouse button click count private boolean mouseInWindow = false;// mouse entered window - is inside the window (may be synthetic) private Point lastMousePosition = new Point(); @@ -1976,17 +1976,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // MouseListener/Event Support // - public void sendMouseEvent(int eventType, int modifiers, - int x, int y, int button, float rotation) { + public void sendMouseEvent(short eventType, int modifiers, + int x, int y, short button, float rotation) { doMouseEvent(false, false, eventType, modifiers, x, y, button, rotation); } - public void enqueueMouseEvent(boolean wait, int eventType, int modifiers, - int x, int y, int button, float rotation) { + public void enqueueMouseEvent(boolean wait, short eventType, int modifiers, + int x, int y, short button, float rotation) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotation); } - protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, - int x, int y, int button, float rotation) { + protected void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, + int x, int y, short button, float rotation) { if( eventType == MouseEvent.EVENT_MOUSE_ENTERED || eventType == MouseEvent.EVENT_MOUSE_EXITED ) { if( eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1 ) { x = lastMousePosition.getX(); @@ -1996,9 +1996,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer x = Math.min(Math.max(x, 0), getWidth()-1); y = Math.min(Math.max(y, 0), getHeight()-1); mouseInWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; - lastMousePressed = 0; // clear state - mouseButtonPressed = 0; // clear state - mouseButtonModMask = 0; // clear state + // clear states + lastMousePressed = 0; + lastMouseClickCount = (short)0; + mouseButtonPressed = 0; + mouseButtonModMask = 0; } if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { return; // .. invalid .. @@ -2013,10 +2015,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(!mouseInWindow) { mouseInWindow = true; eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, this, when, - modifiers, x, y, lastMouseClickCount, button, 0); - lastMousePressed = 0; // clear state - mouseButtonPressed = 0; // clear state - mouseButtonModMask = 0; // clear state + modifiers, x, y, (short)0, (short)0, (short)0); + // clear states + lastMousePressed = 0; + lastMouseClickCount = (short)0; + mouseButtonPressed = 0; + mouseButtonModMask = 0; } else if( lastMousePosition.getX() == x && lastMousePosition.getY()==y ) { if(DEBUG_MOUSE_EVENT) { System.err.println("doMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+lastMousePosition); @@ -2046,7 +2050,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( when - lastMousePressed < MouseEvent.getClickTimeout() ) { lastMouseClickCount++; } else { - lastMouseClickCount=1; + lastMouseClickCount=(short)1; } lastMousePressed = when; mouseButtonPressed = button; @@ -2060,7 +2064,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer eClicked = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, this, when, modifiers, x, y, lastMouseClickCount, button, 0); } else { - lastMouseClickCount = 0; + lastMouseClickCount = (short)0; lastMousePressed = 0; } mouseButtonPressed = 0; @@ -2068,15 +2072,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else if( MouseEvent.EVENT_MOUSE_MOVED == eventType ) { if ( mouseButtonPressed > 0 ) { e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, - modifiers, x, y, 1, mouseButtonPressed, 0); + modifiers, x, y, (short)1, mouseButtonPressed, 0); } else { e = new MouseEvent(eventType, this, when, - modifiers, x, y, 0, button, 0); + modifiers, x, y, (short)0, button, (short)0); } } else if( MouseEvent.EVENT_MOUSE_WHEEL_MOVED == eventType ) { - e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, rotation); + e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotation); } else { - e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, 0); + e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, 0); } if( null != eEntered ) { if(DEBUG_MOUSE_EVENT) { @@ -2203,23 +2207,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return 0 <= keyCode && keyCode < keyRepeatState.capacity(); } - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - doKeyEvent(false, false, eventType, modifiers, keyCode, keyChar); + public void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + // Always add currently pressed mouse buttons to modifier mask + consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); } - public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - doKeyEvent(true, wait, eventType, modifiers, keyCode, keyChar); + public void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + // Always add currently pressed mouse buttons to modifier mask + enqueueEvent(wait, new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); } - protected void doKeyEvent(boolean enqueue, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - modifiers |= mouseButtonModMask; // Always add currently pressed mouse buttons to modifier mask - if( enqueue ) { - enqueueEvent(wait, new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) ); - } else { - consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) ); - } - } - public void addKeyListener(KeyListener l) { addKeyListener(-1, l); } @@ -2290,6 +2287,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return keyListeners.toArray(new KeyListener[keyListeners.size()]); } + @SuppressWarnings("deprecation") private final boolean propagateKeyEvent(KeyEvent e, KeyListener l) { switch(e.getEventType()) { case KeyEvent.EVENT_KEY_PRESSED: @@ -2307,21 +2305,49 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return InputEvent.consumedTag == e.getAttachment(); } + @SuppressWarnings("deprecation") protected void consumeKeyEvent(KeyEvent e) { - boolean consumed; + boolean consumedE = false, consumedTyped = false; + if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { + throw new InternalError("Deprecated KeyEvent.EVENT_KEY_TYPED is synthesized - don't send/enqueue it!"); + } + + // Synthesize deprecated event KeyEvent.EVENT_KEY_TYPED + final KeyEvent eTyped; + if( KeyEvent.EVENT_KEY_RELEASED == e.getEventType() && e.isPrintableKey() && !e.isAutoRepeat() ) { + eTyped = new KeyEvent(KeyEvent.EVENT_KEY_TYPED, e.getSource(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeySymbol(), e.getKeyChar()); + } else { + eTyped = null; + } if(null != keyboardFocusHandler) { - consumed = propagateKeyEvent(e, keyboardFocusHandler); + consumedE = propagateKeyEvent(e, keyboardFocusHandler); if(DEBUG_KEY_EVENT) { - System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumed); + System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumedE); } - } else { - consumed = false; - if(DEBUG_KEY_EVENT) { + if( null != eTyped ) { + consumedTyped = propagateKeyEvent(eTyped, keyboardFocusHandler); + if(DEBUG_KEY_EVENT) { + System.err.println("consumeKeyEvent: "+eTyped+", keyboardFocusHandler consumed: "+consumedTyped); + } + } + } + if(DEBUG_KEY_EVENT) { + if( !consumedE ) { System.err.println("consumeKeyEvent: "+e); } } - for(int i = 0; !consumed && i < keyListeners.size(); i++ ) { - consumed = propagateKeyEvent(e, keyListeners.get(i)); + for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) { + consumedE = propagateKeyEvent(e, keyListeners.get(i)); + } + if( null != eTyped ) { + if(DEBUG_KEY_EVENT) { + if( !consumedTyped ) { + System.err.println("consumeKeyEvent: "+eTyped); + } + } + for(int i = 0; !consumedTyped && i < keyListeners.size(); i++ ) { + consumedTyped = propagateKeyEvent(eTyped, keyListeners.get(i)); + } } } @@ -2329,11 +2355,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // WindowListener/Event Support // public void sendWindowEvent(int eventType) { - consumeWindowEvent( new WindowEvent(eventType, this, System.currentTimeMillis()) ); + consumeWindowEvent( new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); // FIXME } public void enqueueWindowEvent(boolean wait, int eventType) { - enqueueEvent( wait, new WindowEvent(eventType, this, System.currentTimeMillis()) ); + enqueueEvent( wait, new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); // FIXME } public void addWindowListener(WindowListener l) { diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index e11d79ddc..b90c2106e 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -28,8 +28,6 @@ package jogamp.newt.awt.event; -import com.jogamp.common.util.IntIntHashMap; - /** * *
    AWT Event Modifier Mapping
    @@ -76,47 +74,10 @@ import com.jogamp.common.util.IntIntHashMap; */ public class AWTNewtEventFactory { - protected static final IntIntHashMap eventTypeAWT2NEWT; - /** zero-based AWT button mask array filled by {@link #getAWTButtonDownMask(int)}, allowing fast lookup. */ private static int awtButtonDownMasks[] ; static { - IntIntHashMap map = new IntIntHashMap(); - map.setKeyNotFoundValue(0xFFFFFFFF); - // n/a map.put(java.awt.event.WindowEvent.WINDOW_OPENED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_OPENED); - map.put(java.awt.event.WindowEvent.WINDOW_CLOSING, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); - map.put(java.awt.event.WindowEvent.WINDOW_CLOSED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROYED); - // n/a map.put(java.awt.event.WindowEvent.WINDOW_ICONIFIED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_ICONIFIED); - // n/a map.put(java.awt.event.WindowEvent.WINDOW_DEICONIFIED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DEICONIFIED); - map.put(java.awt.event.WindowEvent.WINDOW_ACTIVATED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS); - map.put(java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS); - map.put(java.awt.event.FocusEvent.FOCUS_GAINED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS); - map.put(java.awt.event.WindowEvent.WINDOW_DEACTIVATED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS); - map.put(java.awt.event.WindowEvent.WINDOW_LOST_FOCUS, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS); - map.put(java.awt.event.FocusEvent.FOCUS_LOST, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS); - // n/a map.put(java.awt.event.WindowEvent.WINDOW_STATE_CHANGED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_STATE_CHANGED); - - map.put(java.awt.event.ComponentEvent.COMPONENT_MOVED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_MOVED); - map.put(java.awt.event.ComponentEvent.COMPONENT_RESIZED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_RESIZED); - // n/a map.put(java.awt.event.ComponentEvent.COMPONENT_SHOWN, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_SHOWN); - // n/a map.put(java.awt.event.ComponentEvent.COMPONENT_HIDDEN, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_HIDDEN); - - map.put(java.awt.event.MouseEvent.MOUSE_CLICKED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED); - map.put(java.awt.event.MouseEvent.MOUSE_PRESSED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); - map.put(java.awt.event.MouseEvent.MOUSE_RELEASED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); - map.put(java.awt.event.MouseEvent.MOUSE_MOVED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED); - map.put(java.awt.event.MouseEvent.MOUSE_ENTERED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED); - map.put(java.awt.event.MouseEvent.MOUSE_EXITED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED); - map.put(java.awt.event.MouseEvent.MOUSE_DRAGGED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED); - map.put(java.awt.event.MouseEvent.MOUSE_WHEEL, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED); - - map.put(java.awt.event.KeyEvent.KEY_PRESSED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED); - map.put(java.awt.event.KeyEvent.KEY_RELEASED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED); - map.put(java.awt.event.KeyEvent.KEY_TYPED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED); - - eventTypeAWT2NEWT = map; - // There is an assumption in awtModifiers2Newt(int,int,boolean) // that the awtButtonMasks and newtButtonMasks are peers, i.e. // a given index refers to the same button in each array. @@ -135,6 +96,41 @@ public class AWTNewtEventFactory { } } + public static final short eventTypeAWT2NEWT(int awtType) { + switch( awtType ) { + // n/a case java.awt.event.WindowEvent.WINDOW_OPENED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_OPENED; + case java.awt.event.WindowEvent.WINDOW_CLOSING: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY; + case java.awt.event.WindowEvent.WINDOW_CLOSED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROYED; + // n/a case java.awt.event.WindowEvent.WINDOW_ICONIFIED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_ICONIFIED; + // n/a case java.awt.event.WindowEvent.WINDOW_DEICONIFIED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DEICONIFIED; + case java.awt.event.WindowEvent.WINDOW_ACTIVATED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; + case java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; + case java.awt.event.FocusEvent.FOCUS_GAINED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; + case java.awt.event.WindowEvent.WINDOW_DEACTIVATED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS; + case java.awt.event.WindowEvent.WINDOW_LOST_FOCUS: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS; + case java.awt.event.FocusEvent.FOCUS_LOST: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS; + // n/a case java.awt.event.WindowEvent.WINDOW_STATE_CHANGED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_STATE_CHANGED; + + case java.awt.event.ComponentEvent.COMPONENT_MOVED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_MOVED; + case java.awt.event.ComponentEvent.COMPONENT_RESIZED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_RESIZED; + // n/a case java.awt.event.ComponentEvent.COMPONENT_SHOWN: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_SHOWN; + // n/a case java.awt.event.ComponentEvent.COMPONENT_HIDDEN: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_HIDDEN; + + case java.awt.event.MouseEvent.MOUSE_CLICKED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED; + case java.awt.event.MouseEvent.MOUSE_PRESSED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; + case java.awt.event.MouseEvent.MOUSE_RELEASED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; + case java.awt.event.MouseEvent.MOUSE_MOVED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED; + case java.awt.event.MouseEvent.MOUSE_ENTERED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED; + case java.awt.event.MouseEvent.MOUSE_EXITED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED; + case java.awt.event.MouseEvent.MOUSE_DRAGGED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED; + case java.awt.event.MouseEvent.MOUSE_WHEEL: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + + case java.awt.event.KeyEvent.KEY_PRESSED: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED; + case java.awt.event.KeyEvent.KEY_RELEASED: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED; + } + return (short)0; + } + private static int getAWTButtonDownMaskImpl(int button) { /** * java.awt.event.InputEvent.getMaskForButton(button); @@ -227,48 +223,48 @@ public class AWTNewtEventFactory { return newtMods; } - public static final int awtButton2Newt(int awtButton) { + public static final short awtButton2Newt(int awtButton) { if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { - return awtButton; + return (short)awtButton; } else { - return 0; + return (short)0; } } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) { - final int newtType = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != newtType) { + final short newtType = eventTypeAWT2NEWT(event.getID()); + if( (short)0 != newtType ) { return new com.jogamp.newt.event.WindowEvent(newtType, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), System.currentTimeMillis()); } return null; // no mapping .. } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.ComponentEvent event, com.jogamp.newt.Window newtSource) { - final int newtType = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != newtType) { + final short newtType = eventTypeAWT2NEWT(event.getID()); + if( (short)0 != newtType ) { return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); } return null; // no mapping .. } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.FocusEvent event, com.jogamp.newt.Window newtSource) { - final int newtType = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != newtType) { + final short newtType = eventTypeAWT2NEWT(event.getID()); + if( (short)0 != newtType ) { return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); } return null; // no mapping .. } public static final com.jogamp.newt.event.MouseEvent createMouseEvent(java.awt.event.MouseEvent event, com.jogamp.newt.Window newtSource) { - final int newtType = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != newtType) { + final short newtType = eventTypeAWT2NEWT(event.getID()); + if( (short)0 != newtType ) { float rotation = 0; if (event instanceof java.awt.event.MouseWheelEvent) { // AWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up. rotation = -1f * ((java.awt.event.MouseWheelEvent)event).getWheelRotation(); } - final int newtButton = awtButton2Newt(event.getButton()); + final short newtButton = awtButton2Newt(event.getButton()); int mods = awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()); mods |= com.jogamp.newt.event.InputEvent.getButtonMask(newtButton); // always include NEWT BUTTON_MASK if(null!=newtSource) { @@ -281,25 +277,25 @@ public class AWTNewtEventFactory { } return new com.jogamp.newt.event.MouseEvent( newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), - mods, event.getX(), event.getY(), event.getClickCount(), + mods, event.getX(), event.getY(), (short)event.getClickCount(), newtButton, rotation); } return null; // no mapping .. } public static final com.jogamp.newt.event.KeyEvent createKeyEvent(java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { - return createKeyEvent(eventTypeAWT2NEWT.get(event.getID()), event, newtSource); + return createKeyEvent(eventTypeAWT2NEWT(event.getID()), event, newtSource); } - public static final com.jogamp.newt.event.KeyEvent createKeyEvent(int newtType, java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { - if(0xFFFFFFFF != newtType) { + public static final com.jogamp.newt.event.KeyEvent createKeyEvent(short newtType, java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { + if( (short)0 != newtType ) { + final short keyCode = (short)event.getKeyCode(); return new com.jogamp.newt.event.KeyEvent( newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()), - event.getKeyCode(), event.getKeyChar()); + keyCode, keyCode, event.getKeyChar()); } return null; // no mapping .. } } - diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index dc1e8aeef..22e2cbc51 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -42,78 +42,62 @@ public class AndroidNewtEventFactory { /** API Level 12: {@link android.view.MotionEvent#ACTION_SCROLL} = {@value} */ private static final int ACTION_SCROLL = 8; - private static final int aMotionEventType2Newt(int aType) { - final int nType; + private static final short aMotionEventType2Newt(int aType) { switch( aType ) { case android.view.MotionEvent.ACTION_DOWN: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; case android.view.MotionEvent.ACTION_UP: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; case android.view.MotionEvent.ACTION_MOVE: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED; case android.view.MotionEvent.ACTION_CANCEL: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; case android.view.MotionEvent.ACTION_OUTSIDE: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED; - break; - // + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED; case android.view.MotionEvent.ACTION_POINTER_DOWN: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; case android.view.MotionEvent.ACTION_POINTER_UP: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; // case ACTION_HOVER_MOVE case ACTION_SCROLL: // API Level 12 ! - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED; // case ACTION_HOVER_ENTER // case ACTION_HOVER_EXIT - default: - nType = 0xFFFFFFFF; } - return nType; + return (short)0; } - private static final int aAccessibilityEventType2Newt(int aType) { - final int nType; + private static final short aAccessibilityEventType2Newt(int aType) { switch( aType ) { case android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED: - nType = com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; break; - default: - nType = 0xFFFFFFFF; + return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; } - return nType; + return (short)0; } - private static final int aKeyEventType2NewtEventType(int androidKeyAction) { + private static final short aKeyEventType2NewtEventType(int androidKeyAction) { switch(androidKeyAction) { case android.view.KeyEvent.ACTION_DOWN: case android.view.KeyEvent.ACTION_MULTIPLE: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED; case android.view.KeyEvent.ACTION_UP: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED; - default: - return 0; } + return (short)0; } - private static final int aKeyCode2NewtKeyCode(int androidKeyCode) { + private static final short aKeyCode2NewtKeyCode(int androidKeyCode) { if(android.view.KeyEvent.KEYCODE_0 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_9) { - return com.jogamp.newt.event.KeyEvent.VK_0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_0 ) ; + return (short) ( com.jogamp.newt.event.KeyEvent.VK_0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_0 ) ); } if(android.view.KeyEvent.KEYCODE_A <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_Z) { - return com.jogamp.newt.event.KeyEvent.VK_A + ( androidKeyCode - android.view.KeyEvent.KEYCODE_A ) ; + return (short) ( com.jogamp.newt.event.KeyEvent.VK_A + ( androidKeyCode - android.view.KeyEvent.KEYCODE_A ) ); } if(android.view.KeyEvent.KEYCODE_F1 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_F12) { - return com.jogamp.newt.event.KeyEvent.VK_F1 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_F1 ) ; + return (short) ( com.jogamp.newt.event.KeyEvent.VK_F1 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_F1 ) ); } if(android.view.KeyEvent.KEYCODE_NUMPAD_0 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_NUMPAD_9) { - return com.jogamp.newt.event.KeyEvent.VK_NUMPAD0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_NUMPAD_0 ) ; + return (short) ( com.jogamp.newt.event.KeyEvent.VK_NUMPAD0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_NUMPAD_0 ) ); } switch(androidKeyCode) { case android.view.KeyEvent.KEYCODE_COMMA: return com.jogamp.newt.event.KeyEvent.VK_COMMA; @@ -144,7 +128,7 @@ public class AndroidNewtEventFactory { case android.view.KeyEvent.KEYCODE_CTRL_LEFT: return com.jogamp.newt.event.KeyEvent.VK_CONTROL; case android.view.KeyEvent.KEYCODE_CTRL_RIGHT: return com.jogamp.newt.event.KeyEvent.VK_CONTROL; // ?? } - return 0; + return (short)0; } private static final int aKeyModifiers2Newt(int androidMods) { @@ -170,38 +154,29 @@ public class AndroidNewtEventFactory { public com.jogamp.newt.event.WindowEvent createWindowEvent(android.view.accessibility.AccessibilityEvent event, com.jogamp.newt.Window newtSource) { final int aType = event.getEventType(); - final int nType = aAccessibilityEventType2Newt(aType); + final short nType = aAccessibilityEventType2Newt(aType); - if(0xFFFFFFFF != nType) { + if( (short)0 != nType) { return new com.jogamp.newt.event.WindowEvent(nType, ((null==newtSource)?null:(Object)newtSource), event.getEventTime()); } return null; // no mapping .. } - public com.jogamp.newt.event.KeyEvent[] createKeyEvents(int keyCode, android.view.KeyEvent event, com.jogamp.newt.Window newtSource) { - final int type = aKeyEventType2NewtEventType(event.getAction()); + public com.jogamp.newt.event.KeyEvent createKeyEvent(int keyCode, android.view.KeyEvent event, com.jogamp.newt.Window newtSource) { + final short type = aKeyEventType2NewtEventType(event.getAction()); if(Window.DEBUG_MOUSE_EVENT) { System.err.println("createKeyEvent: type 0x"+Integer.toHexString(type)+", keyCode 0x"+Integer.toHexString(keyCode)+", "+event); } - if(0xFFFFFFFF != type) { - final int newtKeyCode = aKeyCode2NewtKeyCode(keyCode); - if(0 != newtKeyCode) { + if( (short)0 != type) { + final short newtKeyCode = aKeyCode2NewtKeyCode(keyCode); + if( (short)0 != newtKeyCode ) { final Object src = (null==newtSource)?null:(Object)newtSource; final long unixTime = System.currentTimeMillis() + ( event.getEventTime() - android.os.SystemClock.uptimeMillis() ); final int newtMods = aKeyModifiers2Newt(event.getMetaState()); - final com.jogamp.newt.event.KeyEvent ke1 = new com.jogamp.newt.event.KeyEvent( - type, src, unixTime, newtMods, newtKeyCode, event.getDisplayLabel()); - - if( com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED == type ) { - return new com.jogamp.newt.event.KeyEvent[] { ke1, - new com.jogamp.newt.event.KeyEvent( - com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED, - src, unixTime, newtMods, newtKeyCode, event.getDisplayLabel()) }; - } else { - return new com.jogamp.newt.event.KeyEvent[] { ke1 }; - } + return new com.jogamp.newt.event.KeyEvent( + type, src, unixTime, newtMods, newtKeyCode, newtKeyCode, event.getDisplayLabel()); } } return null; @@ -218,7 +193,8 @@ public class AndroidNewtEventFactory { // // Prefilter Android Event (Gesture, ..) and determine final type // - final int aType, nType; + final int aType; + final short nType; float[] rotationXY = null; int rotationSource = 0; // 1 - Gesture, 2 - ACTION_SCROLL { @@ -265,8 +241,8 @@ public class AndroidNewtEventFactory { } } - if(0xFFFFFFFF != nType) { - final int clickCount = 1; + if( (short)0 != nType ) { + final short clickCount = 1; int modifiers = 0; if( null == rotationXY && AndroidVersion.SDK_INT >= 12 && ACTION_SCROLL == aType ) { // API Level 12 @@ -299,7 +275,7 @@ public class AndroidNewtEventFactory { // final int pCount; final int pIndex; - final int button; + final short button; switch( aType ) { case android.view.MotionEvent.ACTION_POINTER_DOWN: case android.view.MotionEvent.ACTION_POINTER_UP: { @@ -307,7 +283,7 @@ public class AndroidNewtEventFactory { pCount = 1; final int b = event.getPointerId(pIndex) + 1; // FIXME: Assumption that Pointer-ID starts w/ 0 ! if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { - button = b; + button = (short)b; } else { button = com.jogamp.newt.event.MouseEvent.BUTTON1; } @@ -326,7 +302,7 @@ public class AndroidNewtEventFactory { final int[] x = new int[pCount]; final int[] y = new int[pCount]; final float[] pressure = new float[pCount]; - final int[] pointerIds = new int[pCount]; + final short[] pointerIds = new short[pCount]; { if(Window.DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: collect ptr-data ["+pIndex+".."+(pIndex+pCount-1)+", "+pCount+"], aType "+aType+", button "+button+", gestureScrollPointerDown "+gestureScrollPointerDown); @@ -337,7 +313,7 @@ public class AndroidNewtEventFactory { x[j] = (int)event.getX(i); y[j] = (int)event.getY(i); pressure[j] = event.getPressure(i); - pointerIds[j] = event.getPointerId(i); + pointerIds[j] = (short)event.getPointerId(i); if(Window.DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: ptr-data["+i+" -> "+j+"] "+x[j]+"/"+y[j]+", pressure "+pressure[j]+", id "+pointerIds[j]); } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java index ee0c8f8b1..2d972f752 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java @@ -38,11 +38,9 @@ public class AndroidNewtEventTranslator implements View.OnKeyListener, View.OnTo @Override public boolean onKey(View v, int keyCode, android.view.KeyEvent event) { - final com.jogamp.newt.event.KeyEvent[] newtEvents = factory.createKeyEvents(keyCode, event, newtWindow); - if(null != newtEvents) { - for(int i=0; i 0x"+Integer.toHexString(keyCode)+", mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + final short keyCode = MacKeyUtil.validateKeyCode(_keyCode, keyChar); + /* { + final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); + System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", key 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)+", mods "+toHexString(modifiers)+ + ", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + } */ // 1:1 Order: OSX and NEWT delivery order is PRESSED, RELEASED and TYPED // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED @@ -346,25 +347,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // key was already pressed keyRepeatState.put(keyCode, true); // prev == false -> AR in modifiers |= InputEvent.AUTOREPEAT_MASK; - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); // RELEASED - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED + super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyCode, keyChar); // RELEASED } } break; - case KeyEvent.EVENT_KEY_TYPED: - break; } - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); - } - - @Override - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); - } - - @Override - public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - handleKeyEvent(false, wait, eventType, modifiers, keyCode, keyChar); + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyCode, keyChar); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 650958f25..475687eb4 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,7 +46,6 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; -import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; @@ -261,87 +260,55 @@ public class WindowDriver extends WindowImpl { // nop - using event driven insetsChange(..) } - private final void emitKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - if( send ) { - super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); - } else { - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); - } + private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, int modifiers, short keyCode, short keySym, char keyChar) { + if( isKeyCodeTracked(keyCode) && keyPressedState.put(keyCode, true) ) { + final boolean preKeyRepeatState = keyRepeatState.put(keyCode, true); + if( !isModifierKey ) { + // AR: Key was already pressed: Either [enter | within] AR mode + modifiers |= InputEvent.AUTOREPEAT_MASK; + if( preKeyRepeatState ) { + // AR: Within AR mode + super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar); + } // else { AR: Enter AR mode - skip already send PRESSED ; or ALT } + super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); + } + return true; + } + return false; } - /** FIXME: We have to store the keyChar for typed events, since keyChar from pressed/released may be wrong (Uppercase: SHIFT-1, etc ..). */ - private IntIntHashMap typedKeyCode2KeyChar = new IntIntHashMap(KeyEvent.VK_CONTEXT_MENU+1); - - private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - final boolean isPrintableKey = KeyEvent.isPrintableKey(keyCode); - final boolean isModifierKey = KeyEvent.isModifierKey(keyCode); - // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", printableKey "+isPrintableKey+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); + @Override + public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + final boolean isModifierKey = KeyEvent.isModifierKey(keySym); + // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+ + // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", printableKey "+KeyEvent.isPrintableKey(keyCode)+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); // Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0), RELEASED (t1) and TYPED (t1) // Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0). switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: - final int keyCharTyped = typedKeyCode2KeyChar.put(keyCode, 0); - if( 0 != keyCharTyped ) { - keyChar = (char)keyCharTyped; - } if( isKeyCodeTracked(keyCode) ) { if( keyRepeatState.put(keyCode, false) && !isModifierKey ) { // AR out - send out missing PRESSED - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keyChar); + super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keySym, keyChar); } keyPressedState.put(keyCode, false); } - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); + super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); break; case KeyEvent.EVENT_KEY_PRESSED: - // TYPED is delivered right after PRESSED for printable keys and contains the key-char information, - // hence we only deliver non printable keys (action and modifier keys) here. - // Modifier keys shall not AR. - if( !isPrintableKey ) { - if( !handlePressTypedAutoRepeat(isModifierKey, send, wait, modifiers, keyCode, keyChar) ) { - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar); - } - } - break; - case KeyEvent.EVENT_KEY_TYPED: - if( isPrintableKey ) { - typedKeyCode2KeyChar.put(keyCode, keyChar); - if( !handlePressTypedAutoRepeat(isModifierKey, send, wait, modifiers, keyCode, keyChar) ) { - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar); - } + if( !handlePressTypedAutoRepeat(isModifierKey, modifiers, keyCode, keySym, keyChar) ) { + super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar); } break; + // case KeyEvent.EVENT_KEY_TYPED: + // break; } } - private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, boolean send, boolean wait, int modifiers, int keyCode, char keyChar) { - if( isKeyCodeTracked(keyCode) && keyPressedState.put(keyCode, true) ) { - final boolean preKeyRepeatState = keyRepeatState.put(keyCode, true); - if( !isModifierKey ) { - // AR: Key was already pressed: Either [enter | within] AR mode - modifiers |= InputEvent.AUTOREPEAT_MASK; - if( preKeyRepeatState ) { - // AR: Within AR mode - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar); - } // else { AR: Enter AR mode - skip already send PRESSED ; or ALT } - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); - } - return true; - } - return false; - } - - @Override - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); - } - @Override - public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - handleKeyEvent(false, wait, eventType, modifiers, keyCode, keyChar); + public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index c55fddd07..8d33d4d73 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -48,6 +48,7 @@ import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; import com.jogamp.newt.event.InputEvent; +import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseEvent; public class WindowDriver extends WindowImpl { @@ -227,8 +228,8 @@ public class WindowDriver extends WindowImpl { } @Override - protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, - int x, int y, int button, float rotation) { + protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, + int x, int y, short button, float rotation) { switch(eventType) { case MouseEvent.EVENT_MOUSE_PRESSED: switch(button) { @@ -270,6 +271,34 @@ public class WindowDriver extends WindowImpl { super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotation); } + @Override + public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + // handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); + final boolean isModifierKey = KeyEvent.isModifierKey(keyCode); + final boolean isAutoRepeat = 0 != ( KeyEvent.AUTOREPEAT_MASK & modifiers ); + // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+ + // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isAutoRepeat+", [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); + + if( !isAutoRepeat || !isModifierKey ) { // ! ( isModifierKey && isAutoRepeat ) + switch(eventType) { + case KeyEvent.EVENT_KEY_PRESSED: + super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar); + break; + + case KeyEvent.EVENT_KEY_RELEASED: + super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); + break; + + // case KeyEvent.EVENT_KEY_TYPED: + // break; + } + } + } + + @Override + public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); + } //---------------------------------------------------------------------- // Internals only diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java index 0fc487e91..1ebb714fa 100644 --- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -32,7 +32,6 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; -import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.event.InputEvent; /** @@ -43,26 +42,22 @@ import com.jogamp.newt.event.InputEvent; */ public class SWTNewtEventFactory { - protected static final IntIntHashMap eventTypeSWT2NEWT; + public static final short eventTypeSWT2NEWT(int swtType) { + switch( swtType ) { + // case SWT.MouseXXX: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED; + case SWT.MouseDown: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; + case SWT.MouseUp: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; + case SWT.MouseMove: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED; + case SWT.MouseEnter: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED; + case SWT.MouseExit: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED; + // case SWT.MouseXXX: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED; + case SWT.MouseVerticalWheel: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED; - static { - IntIntHashMap map = new IntIntHashMap(); - map.setKeyNotFoundValue(0xFFFFFFFF); - - // map.put(SWT.MouseXXX, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED); - map.put(SWT.MouseDown, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); - map.put(SWT.MouseUp, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); - map.put(SWT.MouseMove, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED); - map.put(SWT.MouseEnter, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED); - map.put(SWT.MouseExit, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED); - // map.put(SWT.MouseXXX, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED); - map.put(SWT.MouseVerticalWheel, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED); - - map.put(SWT.KeyDown, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED); - map.put(SWT.KeyUp, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED); - // map.put(SWT.KeyXXX, com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED); - - eventTypeSWT2NEWT = map; + case SWT.KeyDown: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED; + case SWT.KeyUp: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED; + // case SWT.KeyXXX: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED; + } + return (short)0; } public static final int swtModifiers2Newt(int awtMods, boolean mouseHint) { @@ -93,8 +88,8 @@ public class SWTNewtEventFactory { default: return null; } - int type = eventTypeSWT2NEWT.get(event.type); - if(0xFFFFFFFF != type) { + final short type = eventTypeSWT2NEWT(event.type); + if( (short)0 != type ) { float rotation = 0; if (SWT.MouseVerticalWheel == event.type) { // SWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up. @@ -116,7 +111,7 @@ public class SWTNewtEventFactory { return new com.jogamp.newt.event.MouseEvent( type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), - mods, event.x, event.y, event.count, event.button, rotation); + mods, event.x, event.y, (short)event.count, (short)event.button, rotation); } return null; // no mapping .. } @@ -129,12 +124,12 @@ public class SWTNewtEventFactory { default: return null; } - int type = eventTypeSWT2NEWT.get(event.type); - if(0xFFFFFFFF != type) { + final short type = eventTypeSWT2NEWT(event.type); + if( (short)0 != type ) { return new com.jogamp.newt.event.KeyEvent( type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), swtModifiers2Newt(event.stateMask, false), - event.keyCode, event.character); + (short)event.keyCode, (short)event.keyCode, event.character); } return null; // no mapping .. } @@ -143,7 +138,7 @@ public class SWTNewtEventFactory { // // - int dragButtonDown = 0; + short dragButtonDown = 0; public SWTNewtEventFactory() { resetButtonsDown(); @@ -159,7 +154,7 @@ public class SWTNewtEventFactory { if(null != l) { switch(event.type) { case SWT.MouseDown: - dragButtonDown = event.button; + dragButtonDown = (short) event.button; l.mousePressed(res); break; case SWT.MouseUp: dragButtonDown = 0; @@ -214,7 +209,6 @@ public class SWTNewtEventFactory { break; case SWT.KeyUp: l.keyReleased(res); - l.keyTyped(res); break; } } diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c index 3d059c336..cfec60dc1 100644 --- a/src/newt/native/KDWindow.c +++ b/src/newt/native/KDWindow.c @@ -161,14 +161,14 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_DisplayDriver_DispatchMessages if(KD_INPUT_POINTER_SELECT==ptr->index) { DBG_PRINT( "event mouse click: src: %p, s:%d, (%d,%d)\n", userData, ptr->select, ptr->x, ptr->y); (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, - (ptr->select==0) ? (jint) EVENT_MOUSE_RELEASED : (jint) EVENT_MOUSE_PRESSED, + (ptr->select==0) ? (jshort) EVENT_MOUSE_RELEASED : (jshort) EVENT_MOUSE_PRESSED, (jint) 0, - (jint) ptr->x, (jint) ptr->y, 1, 0.0f); + (jint) ptr->x, (jint) ptr->y, (short)1, 0.0f); } else { DBG_PRINT( "event mouse: src: %d, s:%p, i:0x%X (%d,%d)\n", userData, ptr->select, ptr->index, ptr->x, ptr->y); - (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, + (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED, 0, - (jint) ptr->x, (jint) ptr->y, 0, 0.0f); + (jint) ptr->x, (jint) ptr->y, (jshort)0, 0.0f); } } break; @@ -193,8 +193,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_WindowDriver_initIDs sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); - sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V"); + sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(SISSC)V"); if (windowCreatedID == NULL || sizeChangedID == NULL || visibleChangedID == NULL || diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index 29b646fbf..1e4f0c3ba 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -145,9 +145,9 @@ - (void) setMouseConfined:(BOOL)v; - (void) setMousePosition:(NSPoint)p; -- (void) sendKeyEvent: (NSEvent*) event eventType: (jint) evType; -- (void) sendKeyEvent: (jint) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jint) evType; -- (void) sendMouseEvent: (NSEvent*) event eventType: (jint) evType; +- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType; +- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType; +- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType; - (void) focusChanged: (BOOL) gained; - (BOOL) becomeFirstResponder; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index e69f74dfb..66d68d9d2 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -349,10 +349,10 @@ static jmethodID windowRepaintID = NULL; + (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz { - enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIIF)V"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); - enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V"); - sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); + enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZSIIISF)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V"); + enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZSISSC)V"); + sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(SISSC)V"); sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); @@ -626,15 +626,15 @@ static jint mods2JavaMods(NSUInteger mods) return javaMods; } -- (void) sendKeyEvent: (NSEvent*) event eventType: (jint) evType +- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType { - jint keyCode = (jint) [event keyCode]; + jshort keyCode = (jshort) [event keyCode]; NSString* chars = [event charactersIgnoringModifiers]; NSUInteger mods = [event modifierFlags]; [self sendKeyEvent: keyCode characters: chars modifiers: mods eventType: evType]; } -- (void) sendKeyEvent: (jint) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jint) evType +- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType { NSView* nsview = [self contentView]; if( ! [nsview isMemberOfClass:[NewtView class]] ) { @@ -668,10 +668,10 @@ static jint mods2JavaMods(NSUInteger mods) #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID, - evType, javaMods, keyCode, keyChar); + evType, javaMods, keyCode, keyCode, keyChar); #else (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, - evType, javaMods, keyCode, keyChar); + evType, javaMods, keyCode, keyCode, keyChar); #endif } } else { @@ -682,10 +682,10 @@ static jint mods2JavaMods(NSUInteger mods) #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID, - evType, javaMods, keyCode, keyChar); + evType, javaMods, keyCode, keyCode, keyChar); #else (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, - evType, javaMods, keyCode, keyChar); + evType, javaMods, keyCode, keyCode, keyChar); #endif } @@ -694,7 +694,7 @@ static jint mods2JavaMods(NSUInteger mods) } } -- (void) sendMouseEvent: (NSEvent*) event eventType: (jint) evType +- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType { NSView* nsview = [self contentView]; if( ! [nsview isMemberOfClass:[NewtView class]] ) { @@ -718,7 +718,7 @@ static jint mods2JavaMods(NSUInteger mods) // convert to 1-based button number (or use zero if no button is involved) // TODO: detect mouse button when mouse wheel scrolled - jint javaButtonNum = 0; + jshort javaButtonNum = 0; jfloat scrollDeltaY = 0.0f; switch ([event type]) { case NSScrollWheel: { @@ -850,13 +850,12 @@ static jint mods2JavaMods(NSUInteger mods) - (void) keyDown: (NSEvent*) theEvent { - [self sendKeyEvent: theEvent eventType: EVENT_KEY_PRESSED]; + [self sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_PRESSED]; } - (void) keyUp: (NSEvent*) theEvent { - [self sendKeyEvent: theEvent eventType: EVENT_KEY_RELEASED]; - [self sendKeyEvent: theEvent eventType: EVENT_KEY_TYPED]; + [self sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_RELEASED]; } #define kVK_Shift 0x38 @@ -868,11 +867,10 @@ static jint mods2JavaMods(NSUInteger mods) { if ( NO == modsDown[keyIdx] && 0 != ( mods & keyMask ) ) { modsDown[keyIdx] = YES; - [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_PRESSED]; + [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_PRESSED]; } else if ( YES == modsDown[keyIdx] && 0 == ( mods & keyMask ) ) { modsDown[keyIdx] = NO; - [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_RELEASED]; - [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_TYPED]; + [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_RELEASED]; } } diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 24d513c68..05953cb86 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -132,9 +132,7 @@ static jmethodID focusChangedID = NULL; static jmethodID visibleChangedID = NULL; static jmethodID windowDestroyNotifyID = NULL; static jmethodID windowRepaintID = NULL; -static jmethodID enqueueMouseEventID = NULL; static jmethodID sendMouseEventID = NULL; -static jmethodID enqueueKeyEventID = NULL; static jmethodID sendKeyEventID = NULL; static jmethodID requestFocusID = NULL; @@ -146,345 +144,294 @@ typedef struct { } WindowUserData; typedef struct { - UINT javaKey; - UINT windowsKey; + USHORT javaKey; + USHORT windowsKey; + USHORT windowsScanCodeUS; } KeyMapEntry; // Static table, arranged more or less spatially. static KeyMapEntry keyMapTable[] = { // Modifier keys - {J_VK_CAPS_LOCK, VK_CAPITAL}, - {J_VK_SHIFT, VK_SHIFT}, - {J_VK_CONTROL, VK_CONTROL}, - {J_VK_ALT, VK_MENU}, - {J_VK_NUM_LOCK, VK_NUMLOCK}, + {J_VK_CAPS_LOCK, VK_CAPITAL, 0}, + {J_VK_SHIFT, VK_SHIFT, 0}, + {J_VK_SHIFT, VK_LSHIFT, 0}, + {J_VK_SHIFT, VK_RSHIFT, 0}, + {J_VK_CONTROL, VK_CONTROL, 0}, + {J_VK_CONTROL, VK_LCONTROL, 0}, + {J_VK_CONTROL, VK_RCONTROL, 0}, + {J_VK_ALT, VK_MENU, 0}, + {J_VK_ALT, VK_LMENU, 0}, + {J_VK_ALT, VK_RMENU, 0}, + {J_VK_NUM_LOCK, VK_NUMLOCK, 0}, // Miscellaneous Windows keys - {J_VK_WINDOWS, VK_LWIN}, - {J_VK_WINDOWS, VK_RWIN}, - {J_VK_CONTEXT_MENU, VK_APPS}, + {J_VK_WINDOWS, VK_LWIN, 0}, + {J_VK_WINDOWS, VK_RWIN, 0}, + {J_VK_CONTEXT_MENU, VK_APPS, 0}, // Alphabet - {J_VK_A, 'A'}, - {J_VK_B, 'B'}, - {J_VK_C, 'C'}, - {J_VK_D, 'D'}, - {J_VK_E, 'E'}, - {J_VK_F, 'F'}, - {J_VK_G, 'G'}, - {J_VK_H, 'H'}, - {J_VK_I, 'I'}, - {J_VK_J, 'J'}, - {J_VK_K, 'K'}, - {J_VK_L, 'L'}, - {J_VK_M, 'M'}, - {J_VK_N, 'N'}, - {J_VK_O, 'O'}, - {J_VK_P, 'P'}, - {J_VK_Q, 'Q'}, - {J_VK_R, 'R'}, - {J_VK_S, 'S'}, - {J_VK_T, 'T'}, - {J_VK_U, 'U'}, - {J_VK_V, 'V'}, - {J_VK_W, 'W'}, - {J_VK_X, 'X'}, - {J_VK_Y, 'Y'}, - {J_VK_Z, 'Z'}, - {J_VK_0, '0'}, - {J_VK_1, '1'}, - {J_VK_2, '2'}, - {J_VK_3, '3'}, - {J_VK_4, '4'}, - {J_VK_5, '5'}, - {J_VK_6, '6'}, - {J_VK_7, '7'}, - {J_VK_8, '8'}, - {J_VK_9, '9'}, - {J_VK_ENTER, VK_RETURN}, - {J_VK_SPACE, VK_SPACE}, - {J_VK_BACK_SPACE, VK_BACK}, - {J_VK_TAB, VK_TAB}, - {J_VK_ESCAPE, VK_ESCAPE}, - {J_VK_INSERT, VK_INSERT}, - {J_VK_DELETE, VK_DELETE}, - {J_VK_HOME, VK_HOME}, - {J_VK_END, VK_END}, - {J_VK_PAGE_UP, VK_PRIOR}, - {J_VK_PAGE_DOWN, VK_NEXT}, - {J_VK_CLEAR, VK_CLEAR}, // NumPad 5 + {J_VK_A, 'A', 0}, + {J_VK_B, 'B', 0}, + {J_VK_C, 'C', 0}, + {J_VK_D, 'D', 0}, + {J_VK_E, 'E', 0}, + {J_VK_F, 'F', 0}, + {J_VK_G, 'G', 0}, + {J_VK_H, 'H', 0}, + {J_VK_I, 'I', 0}, + {J_VK_J, 'J', 0}, + {J_VK_K, 'K', 0}, + {J_VK_L, 'L', 0}, + {J_VK_M, 'M', 0}, + {J_VK_N, 'N', 0}, + {J_VK_O, 'O', 0}, + {J_VK_P, 'P', 0}, + {J_VK_Q, 'Q', 0}, + {J_VK_R, 'R', 0}, + {J_VK_S, 'S', 0}, + {J_VK_T, 'T', 0}, + {J_VK_U, 'U', 0}, + {J_VK_V, 'V', 0}, + {J_VK_W, 'W', 0}, + {J_VK_X, 'X', 0}, + {J_VK_Y, 'Y', 0}, + {J_VK_Z, 'Z', 0}, + {J_VK_0, '0', 0}, + {J_VK_1, '1', 0}, + {J_VK_2, '2', 0}, + {J_VK_3, '3', 0}, + {J_VK_4, '4', 0}, + {J_VK_5, '5', 0}, + {J_VK_6, '6', 0}, + {J_VK_7, '7', 0}, + {J_VK_8, '8', 0}, + {J_VK_9, '9', 0}, + {J_VK_ENTER, VK_RETURN, 0}, + {J_VK_SPACE, VK_SPACE, 0}, + {J_VK_BACK_SPACE, VK_BACK, 0}, + {J_VK_TAB, VK_TAB, 0}, + {J_VK_ESCAPE, VK_ESCAPE, 0}, + {J_VK_INSERT, VK_INSERT, 0}, + {J_VK_DELETE, VK_DELETE, 0}, + {J_VK_HOME, VK_HOME, 0}, + {J_VK_END, VK_END, 0}, + {J_VK_PAGE_UP, VK_PRIOR, 0}, + {J_VK_PAGE_DOWN, VK_NEXT, 0}, + {J_VK_CLEAR, VK_CLEAR, 0}, // NumPad 5 // NumPad with NumLock off & extended arrows block (triangular) - {J_VK_LEFT, VK_LEFT}, - {J_VK_RIGHT, VK_RIGHT}, - {J_VK_UP, VK_UP}, - {J_VK_DOWN, VK_DOWN}, + {J_VK_LEFT, VK_LEFT, 0}, + {J_VK_RIGHT, VK_RIGHT, 0}, + {J_VK_UP, VK_UP, 0}, + {J_VK_DOWN, VK_DOWN, 0}, // NumPad with NumLock on: numbers - {J_VK_NUMPAD0, VK_NUMPAD0}, - {J_VK_NUMPAD1, VK_NUMPAD1}, - {J_VK_NUMPAD2, VK_NUMPAD2}, - {J_VK_NUMPAD3, VK_NUMPAD3}, - {J_VK_NUMPAD4, VK_NUMPAD4}, - {J_VK_NUMPAD5, VK_NUMPAD5}, - {J_VK_NUMPAD6, VK_NUMPAD6}, - {J_VK_NUMPAD7, VK_NUMPAD7}, - {J_VK_NUMPAD8, VK_NUMPAD8}, - {J_VK_NUMPAD9, VK_NUMPAD9}, + {J_VK_NUMPAD0, VK_NUMPAD0, 0}, + {J_VK_NUMPAD1, VK_NUMPAD1, 0}, + {J_VK_NUMPAD2, VK_NUMPAD2, 0}, + {J_VK_NUMPAD3, VK_NUMPAD3, 0}, + {J_VK_NUMPAD4, VK_NUMPAD4, 0}, + {J_VK_NUMPAD5, VK_NUMPAD5, 0}, + {J_VK_NUMPAD6, VK_NUMPAD6, 0}, + {J_VK_NUMPAD7, VK_NUMPAD7, 0}, + {J_VK_NUMPAD8, VK_NUMPAD8, 0}, + {J_VK_NUMPAD9, VK_NUMPAD9, 0}, // NumPad with NumLock on - {J_VK_MULTIPLY, VK_MULTIPLY}, - {J_VK_ADD, VK_ADD}, - {J_VK_SEPARATOR, VK_SEPARATOR}, - {J_VK_SUBTRACT, VK_SUBTRACT}, - {J_VK_DECIMAL, VK_DECIMAL}, - {J_VK_DIVIDE, VK_DIVIDE}, + {J_VK_MULTIPLY, VK_MULTIPLY, 0}, + {J_VK_ADD, VK_ADD, 0}, + {J_VK_SEPARATOR, VK_SEPARATOR, 0}, + {J_VK_SUBTRACT, VK_SUBTRACT, 0}, + {J_VK_DECIMAL, VK_DECIMAL, 0}, + {J_VK_DIVIDE, VK_DIVIDE, 0}, // Functional keys - {J_VK_F1, VK_F1}, - {J_VK_F2, VK_F2}, - {J_VK_F3, VK_F3}, - {J_VK_F4, VK_F4}, - {J_VK_F5, VK_F5}, - {J_VK_F6, VK_F6}, - {J_VK_F7, VK_F7}, - {J_VK_F8, VK_F8}, - {J_VK_F9, VK_F9}, - {J_VK_F10, VK_F10}, - {J_VK_F11, VK_F11}, - {J_VK_F12, VK_F12}, - {J_VK_F13, VK_F13}, - {J_VK_F14, VK_F14}, - {J_VK_F15, VK_F15}, - {J_VK_F16, VK_F16}, - {J_VK_F17, VK_F17}, - {J_VK_F18, VK_F18}, - {J_VK_F19, VK_F19}, - {J_VK_F20, VK_F20}, - {J_VK_F21, VK_F21}, - {J_VK_F22, VK_F22}, - {J_VK_F23, VK_F23}, - {J_VK_F24, VK_F24}, - - {J_VK_PRINTSCREEN, VK_SNAPSHOT}, - {J_VK_SCROLL_LOCK, VK_SCROLL}, - {J_VK_PAUSE, VK_PAUSE}, - {J_VK_CANCEL, VK_CANCEL}, - {J_VK_HELP, VK_HELP}, + {J_VK_F1, VK_F1, 0}, + {J_VK_F2, VK_F2, 0}, + {J_VK_F3, VK_F3, 0}, + {J_VK_F4, VK_F4, 0}, + {J_VK_F5, VK_F5, 0}, + {J_VK_F6, VK_F6, 0}, + {J_VK_F7, VK_F7, 0}, + {J_VK_F8, VK_F8, 0}, + {J_VK_F9, VK_F9, 0}, + {J_VK_F10, VK_F10, 0}, + {J_VK_F11, VK_F11, 0}, + {J_VK_F12, VK_F12, 0}, + {J_VK_F13, VK_F13, 0}, + {J_VK_F14, VK_F14, 0}, + {J_VK_F15, VK_F15, 0}, + {J_VK_F16, VK_F16, 0}, + {J_VK_F17, VK_F17, 0}, + {J_VK_F18, VK_F18, 0}, + {J_VK_F19, VK_F19, 0}, + {J_VK_F20, VK_F20, 0}, + {J_VK_F21, VK_F21, 0}, + {J_VK_F22, VK_F22, 0}, + {J_VK_F23, VK_F23, 0}, + {J_VK_F24, VK_F24, 0}, + + {J_VK_PRINTSCREEN, VK_SNAPSHOT, 0}, + {J_VK_SCROLL_LOCK, VK_SCROLL, 0}, + {J_VK_PAUSE, VK_PAUSE, 0}, + {J_VK_CANCEL, VK_CANCEL, 0}, + {J_VK_HELP, VK_HELP, 0}, + + // Since we unify mappings via US kbd layout .. this is valid: + {J_VK_SEMICOLON, VK_OEM_1, 0}, // US only ';:' + {J_VK_EQUALS, VK_OEM_PLUS, 0}, // '=+' + {J_VK_COMMA, VK_OEM_COMMA, 0}, // ',<' + {J_VK_MINUS, VK_OEM_MINUS, 0}, // '-_' + {J_VK_PERIOD, VK_OEM_PERIOD, 0}, // '.>' + {J_VK_SLASH, VK_OEM_2, 0}, // US only '/?' + {J_VK_BACK_QUOTE, VK_OEM_3, 0}, // US only '`~' + {J_VK_OPEN_BRACKET, VK_OEM_4, 0}, // US only '[}' + {J_VK_BACK_SLASH, VK_OEM_5, 0}, // US only '\|' + {J_VK_CLOSE_BRACKET, VK_OEM_6, 0}, // US only ']}' + {J_VK_QUOTE, VK_OEM_7, 0}, // US only ''"' + // {J_VK_????, VK_OEM_8, 0}, // varies .. + // {J_VK_????, VK_OEM_102, 0}, // angle-bracket or backslash key on RT 102-key kbd // Japanese /* - {J_VK_CONVERT, VK_CONVERT}, - {J_VK_NONCONVERT, VK_NONCONVERT}, - {J_VK_INPUT_METHOD_ON_OFF, VK_KANJI}, - {J_VK_ALPHANUMERIC, VK_DBE_ALPHANUMERIC}, - {J_VK_KATAKANA, VK_DBE_KATAKANA}, - {J_VK_HIRAGANA, VK_DBE_HIRAGANA}, - {J_VK_FULL_WIDTH, VK_DBE_DBCSCHAR}, - {J_VK_HALF_WIDTH, VK_DBE_SBCSCHAR}, - {J_VK_ROMAN_CHARACTERS, VK_DBE_ROMAN}, + {J_VK_CONVERT, VK_CONVERT, 0}, + {J_VK_NONCONVERT, VK_NONCONVERT, 0}, + {J_VK_INPUT_METHOD_ON_OFF, VK_KANJI, 0}, + {J_VK_ALPHANUMERIC, VK_DBE_ALPHANUMERIC, 0}, + {J_VK_KATAKANA, VK_DBE_KATAKANA, 0}, + {J_VK_HIRAGANA, VK_DBE_HIRAGANA, 0}, + {J_VK_FULL_WIDTH, VK_DBE_DBCSCHAR, 0}, + {J_VK_HALF_WIDTH, VK_DBE_SBCSCHAR, 0}, + {J_VK_ROMAN_CHARACTERS, VK_DBE_ROMAN, 0}, */ - {J_VK_UNDEFINED, 0} + {J_VK_UNDEFINED, 0, 0} }; -/* -Dynamic mapping table for OEM VK codes. This table is refilled -by BuildDynamicKeyMapTable when keyboard layout is switched. -(see NT4 DDK src/input/inc/vkoem.h for OEM VK_ values). -*/ -typedef struct { - // OEM VK codes known in advance - UINT windowsKey; - // depends on input langauge (kbd layout) - UINT javaKey; -} DynamicKeyMapEntry; - -static DynamicKeyMapEntry dynamicKeyMapTable[] = { - {0x00BA, J_VK_UNDEFINED}, // VK_OEM_1 - {0x00BB, J_VK_UNDEFINED}, // VK_OEM_PLUS - {0x00BC, J_VK_UNDEFINED}, // VK_OEM_COMMA - {0x00BD, J_VK_UNDEFINED}, // VK_OEM_MINUS - {0x00BE, J_VK_UNDEFINED}, // VK_OEM_PERIOD - {0x00BF, J_VK_UNDEFINED}, // VK_OEM_2 - {0x00C0, J_VK_UNDEFINED}, // VK_OEM_3 - {0x00DB, J_VK_UNDEFINED}, // VK_OEM_4 - {0x00DC, J_VK_UNDEFINED}, // VK_OEM_5 - {0x00DD, J_VK_UNDEFINED}, // VK_OEM_6 - {0x00DE, J_VK_UNDEFINED}, // VK_OEM_7 - {0x00DF, J_VK_UNDEFINED}, // VK_OEM_8 - {0x00E2, J_VK_UNDEFINED}, // VK_OEM_102 - {0, 0} -}; +#ifndef KLF_ACTIVATE + #define KLF_ACTIVATE 0x00000001 +#endif +#ifndef MAPVK_VK_TO_VSC + #define MAPVK_VK_TO_VSC 0 +#endif +#ifndef MAPVK_VSC_TO_VK + #define MAPVK_VSC_TO_VK 1 +#endif +#ifndef MAPVK_VK_TO_CHAR + #define MAPVK_VK_TO_CHAR 2 +#endif +#ifndef MAPVK_VSC_TO_VK_EX + #define MAPVK_VSC_TO_VK_EX 3 +#endif +#ifndef MAPVK_VK_TO_VSC_EX + #define MAPVK_VK_TO_VSC_EX 4 +#endif -// Auxiliary tables used to fill the above dynamic table. We first -// find the character for the OEM VK code using ::MapVirtualKey and -// then go through these auxiliary tables to map it to Java VK code. +static HKL kbdLayoutUS = 0; +static const LPCSTR US_LAYOUT_NAME = "00000409"; -typedef struct { - WCHAR c; - UINT javaKey; -} CharToVKEntry; - -static const CharToVKEntry charToVKTable[] = { - {L'!', J_VK_EXCLAMATION_MARK}, - {L'"', J_VK_QUOTEDBL}, - {L'#', J_VK_NUMBER_SIGN}, - {L'$', J_VK_DOLLAR}, - {L'&', J_VK_AMPERSAND}, - {L'\'', J_VK_QUOTE}, - {L'(', J_VK_LEFT_PARENTHESIS}, - {L')', J_VK_RIGHT_PARENTHESIS}, - {L'*', J_VK_ASTERISK}, - {L'+', J_VK_PLUS}, - {L',', J_VK_COMMA}, - {L'-', J_VK_MINUS}, - {L'.', J_VK_PERIOD}, - {L'/', J_VK_SLASH}, - {L':', J_VK_COLON}, - {L';', J_VK_SEMICOLON}, - {L'<', J_VK_LESS}, - {L'=', J_VK_EQUALS}, - {L'>', J_VK_GREATER}, - {L'@', J_VK_AT}, - {L'[', J_VK_OPEN_BRACKET}, - {L'\\', J_VK_BACK_SLASH}, - {L']', J_VK_CLOSE_BRACKET}, - {L'^', J_VK_CIRCUMFLEX}, - {L'_', J_VK_UNDERSCORE}, - {L'`', J_VK_BACK_QUOTE}, - {L'{', J_VK_BRACELEFT}, - {L'}', J_VK_BRACERIGHT}, - {0x00A1, J_VK_INVERTED_EXCLAMATION_MARK}, - {0x20A0, J_VK_EURO_SIGN}, // ???? - {0,0} -}; +static BYTE kbdState[256]; +static USHORT spaceScanCode; -// For dead accents some layouts return ASCII punctuation, while some -// return spacing accent chars, so both should be listed. NB: MS docs -// say that conversion routings return spacing accent character, not -// combining. -static const CharToVKEntry charToDeadVKTable[] = { - {L'`', J_VK_DEAD_GRAVE}, - {L'\'', J_VK_DEAD_ACUTE}, - {0x00B4, J_VK_DEAD_ACUTE}, - {L'^', J_VK_DEAD_CIRCUMFLEX}, - {L'~', J_VK_DEAD_TILDE}, - {0x02DC, J_VK_DEAD_TILDE}, - {0x00AF, J_VK_DEAD_MACRON}, - {0x02D8, J_VK_DEAD_BREVE}, - {0x02D9, J_VK_DEAD_ABOVEDOT}, - {L'"', J_VK_DEAD_DIAERESIS}, - {0x00A8, J_VK_DEAD_DIAERESIS}, - {0x02DA, J_VK_DEAD_ABOVERING}, - {0x02DD, J_VK_DEAD_DOUBLEACUTE}, - {0x02C7, J_VK_DEAD_CARON}, // aka hacek - {L',', J_VK_DEAD_CEDILLA}, - {0x00B8, J_VK_DEAD_CEDILLA}, - {0x02DB, J_VK_DEAD_OGONEK}, - {0x037A, J_VK_DEAD_IOTA}, // ASCII ??? - {0x309B, J_VK_DEAD_VOICED_SOUND}, - {0x309C, J_VK_DEAD_SEMIVOICED_SOUND}, - {0,0} -}; +static void InitKeyMapTableScanCode(JNIEnv *env) { + HKL hkl = GetKeyboardLayout(0); + int i; -// ANSI CP identifiers are no longer than this -#define MAX_ACP_STR_LEN 7 + kbdLayoutUS = LoadKeyboardLayout( US_LAYOUT_NAME, 0 /* ? KLF_ACTIVATE ? */ ); + if( 0 == kbdLayoutUS ) { + int lastError = (int) GetLastError(); + kbdLayoutUS = hkl; // use prev. layout .. well + STD_PRINT("Warning: NEWT Windows: LoadKeyboardLayout(US, ..) failed: winErr 0x%X %d\n", lastError, lastError); + } + ActivateKeyboardLayout(hkl, 0); + + spaceScanCode = MapVirtualKeyEx(VK_SPACE, MAPVK_VK_TO_VSC, hkl); + + // Setup keyMapTable's windowsScanCodeUS + for (i = 0; keyMapTable[i].windowsKey != 0; i++) { + USHORT scancode = (USHORT) MapVirtualKeyEx(keyMapTable[i].windowsKey, MAPVK_VK_TO_VSC_EX, kbdLayoutUS); + #ifdef DEBUG_KEYS + if( 0 == scancode ) { + int lastError = (int) GetLastError(); + STD_PRINT("*** WindowsWindow: InitKeyMapTableScanCode: No ScanCode for windows vkey 0x%X (item %d), winErr 0x%X %d\n", + keyMapTable[i].windowsKey, i, lastError, lastError); + } + STD_PRINT("*** WindowsWindow: InitKeyMapTableScanCode: %3.3d windows vkey 0x%X -> scancode 0x%X\n", + i, keyMapTable[i].windowsKey, scancode); + #endif + keyMapTable[i].windowsScanCodeUS = scancode; + } +} + +static void ParseWmVKeyAndScanCode(USHORT winVKey, BYTE winScanCode, BYTE flags, USHORT *outJavaVKeyUS, USHORT *outJavaVKeyXX, USHORT *outUTF16Char) { + wchar_t uniChars[2] = { L'\0', L'\0' }; // uint16_t + USHORT winVKeyUS = 0; + int nUniChars, i, j; + USHORT javaVKeyUS = J_VK_UNDEFINED; + USHORT javaVKeyXX = J_VK_UNDEFINED; -static void BuildDynamicKeyMapTable() -{ HKL hkl = GetKeyboardLayout(0); - // Will need this to reset layout after dead keys. - UINT spaceScanCode = MapVirtualKeyEx(VK_SPACE, 0, hkl); - DynamicKeyMapEntry *dynamic; - - LANGID idLang = LOWORD(GetKeyboardLayout(0)); - UINT codePage; - TCHAR strCodePage[MAX_ACP_STR_LEN]; - // use the LANGID to create a LCID - LCID idLocale = MAKELCID(idLang, SORT_DEFAULT); - // get the ANSI code page associated with this locale - if (GetLocaleInfo(idLocale, LOCALE_IDEFAULTANSICODEPAGE, - strCodePage, sizeof(strCodePage)/sizeof(TCHAR)) > 0 ) - { - codePage = _ttoi(strCodePage); - } else { - codePage = GetACP(); + + // + // winVKey, winScanCode -> UTF16 w/ current KeyboardLayout + // + GetKeyboardState(kbdState); + kbdState[winVKey] |= 0x80; + nUniChars = ToUnicodeEx(winVKey, winScanCode, kbdState, uniChars, 2, 0, hkl); + kbdState[winVKey] &= ~0x80; + + *outUTF16Char = (USHORT)(uniChars[0]); // Note: Even dead key are written in uniChar's .. + + if ( 0 > nUniChars ) { // Dead key + char junkbuf[2] = { '\0', '\0'}; + + // We need to reset layout so that next translation + // is unaffected by the dead status. We do this by + // translating key. + kbdState[VK_SPACE] |= 0x80; + ToAsciiEx(VK_SPACE, spaceScanCode, kbdState, (WORD*)junkbuf, 0, hkl); + kbdState[VK_SPACE] &= ~0x80; } - // Entries in dynamic table that maps between Java VK and Windows - // VK are built in three steps: - // 1. Map windows VK to ANSI character (cannot map to unicode - // directly, since ::ToUnicode is not implemented on win9x) - // 2. Convert ANSI char to Unicode char - // 3. Map Unicode char to Java VK via two auxilary tables. + // Assume extended scan code 0xE0 if extended flags is set (no 0xE1 from WM_KEYUP/WM_KEYDOWN) + USHORT winScanCodeExt = winScanCode; + if( 0 != ( 0x01 & flags ) ) { + winScanCodeExt |= 0xE000; + } - for (dynamic = dynamicKeyMapTable; dynamic->windowsKey != 0; ++dynamic) - { - char cbuf[2] = { '\0', '\0'}; - WCHAR ucbuf[2] = { L'\0', L'\0' }; - int nchars; - UINT scancode; - const CharToVKEntry *charMap; - int nconverted; - WCHAR uc; - BYTE kbdState[256]; - - // Defaults to J_VK_UNDEFINED - dynamic->javaKey = J_VK_UNDEFINED; - - GetKeyboardState(kbdState); - - kbdState[dynamic->windowsKey] |= 0x80; // Press the key. - - // Unpress modifiers, since they are most likely pressed as - // part of the keyboard switching shortcut. - kbdState[VK_CONTROL] &= ~0x80; - kbdState[VK_SHIFT] &= ~0x80; - kbdState[VK_MENU] &= ~0x80; - - scancode = MapVirtualKeyEx(dynamic->windowsKey, 0, hkl); - nchars = ToAsciiEx(dynamic->windowsKey, scancode, kbdState, - (WORD*)cbuf, 0, hkl); - - // Auxiliary table used to map Unicode character to Java VK. - // Will assign a different table for dead keys (below). - charMap = charToVKTable; - - if (nchars < 0) { // Dead key - char junkbuf[2] = { '\0', '\0'}; - // Use a different table for dead chars since different layouts - // return different characters for the same dead key. - charMap = charToDeadVKTable; - - // We also need to reset layout so that next translation - // is unaffected by the dead status. We do this by - // translating key. - kbdState[dynamic->windowsKey] &= ~0x80; - kbdState[VK_SPACE] |= 0x80; - - ToAsciiEx(VK_SPACE, spaceScanCode, kbdState, - (WORD*)junkbuf, 0, hkl); + // + // winVKey, winScanCodeExt -> javaVKeyUS w/ US KeyboardLayout + // + for (i = 0; keyMapTable[i].windowsKey != 0; i++) { + if ( keyMapTable[i].windowsScanCodeUS == winScanCodeExt ) { + javaVKeyUS = keyMapTable[i].javaKey; + winVKeyUS = keyMapTable[i].windowsKey; + break; } + } - nconverted = MultiByteToWideChar(codePage, 0, - cbuf, 1, ucbuf, 2); - - uc = ucbuf[0]; - { - const CharToVKEntry *map; - for (map = charMap; map->c != 0; ++map) { - if (uc == map->c) { - dynamic->javaKey = map->javaKey; - break; - } - } + // + // winVKey -> javaVKeyXX + // + for (i = 0; keyMapTable[i].windowsKey != 0; i++) { + if ( keyMapTable[i].windowsKey == winVKey ) { + javaVKeyXX = keyMapTable[i].javaKey; + break; } + } + + *outJavaVKeyUS = javaVKeyUS; + *outJavaVKeyXX = javaVKeyXX; - } // for each VK_OEM_* +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: ParseWmVKeyAndScanCode winVKey 0x%X, winScanCode 0x%X, winScanCodeExt 0x%X, flags 0x%X -> UTF(0x%X, %c, res %d, sizeof %d), vKeys( US(win 0x%X, java 0x%X), XX(win 0x%X, java 0x%X))\n", + (int)winVKey, (int)winScanCode, winScanCodeExt, (int)flags, + *outUTF16Char, *outUTF16Char, nUniChars, sizeof(uniChars[0]), + winVKeyUS, javaVKeyUS, winVKey, javaVKeyXX); +#endif } -static jint GetModifiers(BOOL altKeyFlagged, UINT jkey) { +static jint GetModifiers(BOOL altKeyFlagged, USHORT jkey) { jint modifiers = 0; // have to do &0xFFFF to avoid runtime assert caused by compiling with // /RTCcsu @@ -516,121 +463,38 @@ static BOOL IsAltKeyDown(BYTE flags, BOOL system) { return system && ( flags & (1<<5) ) != 0; } -UINT WindowsKeyToJavaKey(UINT windowsKey) -{ - int i, j, javaKey = J_VK_UNDEFINED; - // for the general case, use a bi-directional table - for (i = 0; keyMapTable[i].windowsKey != 0; i++) { - if (keyMapTable[i].windowsKey == windowsKey) { - javaKey = keyMapTable[i].javaKey; - } - } - if( J_VK_UNDEFINED == javaKey ) { - for (j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) { - if (dynamicKeyMapTable[j].windowsKey == windowsKey) { - if (dynamicKeyMapTable[j].javaKey != J_VK_UNDEFINED) { - javaKey = dynamicKeyMapTable[j].javaKey; - } else { - break; - } - } - } - } - -#ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: WindowsKeyToJavaKey 0x%X -> 0x%X\n", windowsKey, javaKey); -#endif - return javaKey; -} - -#ifndef MAPVK_VSC_TO_VK - #define MAPVK_VSC_TO_VK 1 -#endif -#ifndef MAPVK_VK_TO_CHAR - #define MAPVK_VK_TO_CHAR 2 -#endif - -static UINT WmVKey2ShiftedChar(UINT wkey, UINT modifiers) { - UINT c = MapVirtualKey(wkey, MAPVK_VK_TO_CHAR); - if( 0 != ( modifiers & EVENT_SHIFT_MASK ) ) { - return islower(c) ? toupper(c) : c; - } - return isupper(c) ? tolower(c) : c; -} - -static int WmChar(JNIEnv *env, jobject window, UINT character, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { - UINT modifiers = 0, jkey = 0, wkey = 0; - - wkey = MapVirtualKey(scanCode, MAPVK_VSC_TO_VK); - jkey = WindowsKeyToJavaKey(wkey); - modifiers = GetModifiers( IsAltKeyDown(flags, system), 0 ); - - if (character == VK_RETURN) { - character = J_VK_ENTER; - } - - (*env)->CallVoidMethod(env, window, sendKeyEventID, - (jint) EVENT_KEY_TYPED, - modifiers, - (jint) jkey, - (jchar) character); - return 1; -} - -static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { - UINT modifiers = 0, jkey = 0, character = 0; +static int WmKeyDown(JNIEnv *env, jobject window, USHORT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { + UINT modifiers = 0; + USHORT javaVKeyUS=0, javaVKeyXX=0, utf16Char=0; if (wkey == VK_PROCESSKEY) { return 1; } - jkey = WindowsKeyToJavaKey(wkey); - modifiers = GetModifiers( IsAltKeyDown(flags, system), jkey ); - character = WmVKey2ShiftedChar(wkey, modifiers); + ParseWmVKeyAndScanCode(wkey, scanCode, flags, &javaVKeyUS, &javaVKeyXX, &utf16Char); -/* - character = WindowsKeyToJavaChar(wkey, modifiers, SAVE); -*/ + modifiers = GetModifiers( IsAltKeyDown(flags, system), javaVKeyXX ); (*env)->CallVoidMethod(env, window, sendKeyEventID, - (jint) EVENT_KEY_PRESSED, - modifiers, - (jint) jkey, - (jchar) character); - - /* windows does not create a WM_CHAR for the Del key - for some reason, so we need to create the KEY_TYPED event on the - WM_KEYDOWN. - */ - if (jkey == J_VK_DELETE) { - (*env)->CallVoidMethod(env, window, sendKeyEventID, - (jint) EVENT_KEY_TYPED, - modifiers, - (jint) jkey, - (jchar) '\177'); - } + (jshort) EVENT_KEY_PRESSED, + (jint) modifiers, (jshort) javaVKeyUS, (jshort) javaVKeyXX, (jchar) utf16Char); return 0; } -static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { - UINT modifiers = 0, jkey = 0, character = 0; +static int WmKeyUp(JNIEnv *env, jobject window, USHORT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { + UINT modifiers = 0; + USHORT javaVKeyUS=0, javaVKeyXX=0, utf16Char=0; if (wkey == VK_PROCESSKEY) { return 1; } - jkey = WindowsKeyToJavaKey(wkey); - modifiers = GetModifiers( IsAltKeyDown(flags, system), jkey ); - character = WmVKey2ShiftedChar(wkey, modifiers); + ParseWmVKeyAndScanCode(wkey, scanCode, flags, &javaVKeyUS, &javaVKeyXX, &utf16Char); -/* - character = WindowsKeyToJavaChar(wkey, modifiers, SAVE); -*/ + modifiers = GetModifiers( IsAltKeyDown(flags, system), javaVKeyXX ); (*env)->CallVoidMethod(env, window, sendKeyEventID, - (jint) EVENT_KEY_RELEASED, - modifiers, - (jint) jkey, - (jchar) character); + (jshort) EVENT_KEY_RELEASED, + (jint) modifiers, (jshort) javaVKeyUS, (jshort) javaVKeyXX, (jchar) utf16Char); return 0; } @@ -933,46 +797,35 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_SYSCHAR: - repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); - repCnt = LOWORD(lParam); -#ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc WM_SYSCHAR sending window %p -> %p, char 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); -#endif - useDefWindowProc = WmChar(env, window, wParam, repCnt, scanCode, flags, TRUE); + useDefWindowProc = 1; break; case WM_SYSKEYDOWN: repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); repCnt = LOWORD(lParam); #ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc WM_SYSKEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); + DBG_PRINT("*** WindowsWindow: windProc WM_SYSKEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); #endif - useDefWindowProc = WmKeyDown(env, window, wParam, repCnt, scanCode, flags, TRUE); + useDefWindowProc = WmKeyDown(env, window, (USHORT)wParam, repCnt, scanCode, flags, TRUE); break; case WM_SYSKEYUP: repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); repCnt = LOWORD(lParam); #ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc WM_SYSKEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); + DBG_PRINT("*** WindowsWindow: windProc WM_SYSKEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); #endif - useDefWindowProc = WmKeyUp(env, window, wParam, repCnt, scanCode, flags, TRUE); + useDefWindowProc = WmKeyUp(env, window, (USHORT)wParam, repCnt, scanCode, flags, TRUE); break; case WM_CHAR: - repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); - repCnt = LOWORD(lParam); -#ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc WM_CHAR sending window %p -> %p, char 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); -#endif - useDefWindowProc = WmChar(env, window, wParam, repCnt, scanCode, flags, FALSE); + useDefWindowProc = 1; break; case WM_KEYDOWN: repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); - repCnt = LOWORD(lParam); #ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc WM_KEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); + DBG_PRINT("*** WindowsWindow: windProc WM_KEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); #endif useDefWindowProc = WmKeyDown(env, window, wParam, repCnt, scanCode, flags, FALSE); break; @@ -981,7 +834,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); repCnt = LOWORD(lParam); #ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc WM_KEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); + DBG_PRINT("*** WindowsWindow: windProc WM_KEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); #endif useDefWindowProc = WmKeyUp(env, window, wParam, repCnt, scanCode, flags, FALSE); break; @@ -1005,19 +858,19 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP DBG_PRINT("*** WindowsWindow: LBUTTONDOWN\n"); (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_PRESSED, + (jshort) EVENT_MOUSE_PRESSED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 1, (jfloat) 0.0f); + (jshort) 1, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_LBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_RELEASED, + (jshort) EVENT_MOUSE_RELEASED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 1, (jfloat) 0.0f); + (jshort) 1, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -1025,19 +878,19 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP DBG_PRINT("*** WindowsWindow: MBUTTONDOWN\n"); (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_PRESSED, + (jshort) EVENT_MOUSE_PRESSED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 2, (jfloat) 0.0f); + (jshort) 2, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_MBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_RELEASED, + (jshort) EVENT_MOUSE_RELEASED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 2, (jfloat) 0.0f); + (jshort) 2, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -1045,36 +898,36 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP DBG_PRINT("*** WindowsWindow: RBUTTONDOWN\n"); (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_PRESSED, + (jshort) EVENT_MOUSE_PRESSED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 3, (jfloat) 0.0f); + (jshort) 3, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_RBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_RELEASED, + (jshort) EVENT_MOUSE_RELEASED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 3, (jfloat) 0.0f); + (jshort) 3, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_MOUSEMOVE: (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_MOVED, + (jshort) EVENT_MOUSE_MOVED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 0, (jfloat) 0.0f); + (jshort) 0, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_MOUSELEAVE: - (*env)->CallVoidMethod(env, window, enqueueMouseEventID, JNI_FALSE, - (jint) EVENT_MOUSE_EXITED, + (*env)->CallVoidMethod(env, window, sendMouseEventID, JNI_FALSE, + (jshort) EVENT_MOUSE_EXITED, 0, (jint) -1, (jint) -1, // fake - (jint) 0, (jfloat) 0.0f); + (jshort) 0, (jfloat) 0.0f); useDefWindowProc = 1; break; // Java synthesizes EVENT_MOUSE_ENTERED @@ -1099,10 +952,10 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP } DBG_PRINT("*** WindowsWindow: WM_HSCROLL 0x%X, rotation %f, mods 0x%X\n", sb, rotation, modifiers); (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_WHEEL_MOVED, + (jshort) EVENT_MOUSE_WHEEL_MOVED, modifiers, (jint) 0, (jint) 0, - (jint) 1, (jfloat) rotation); + (jshort) 1, (jfloat) rotation); useDefWindowProc = 1; break; } @@ -1128,10 +981,10 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (int)eventPt.x, (int)eventPt.y, rotationOrTilt, vKeys, modifiers); } (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_WHEEL_MOVED, + (jshort) EVENT_MOUSE_WHEEL_MOVED, modifiers, (jint) eventPt.x, (jint) eventPt.y, - (jint) 1, (jfloat) rotationOrTilt); + (jshort) 1, (jfloat) rotationOrTilt); useDefWindowProc = 1; break; } @@ -1208,7 +1061,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_DisplayDriver_DispatchMes // DBG_PRINT("*** WindowsWindow.DispatchMessages0: thread 0x%X - gotOne %d\n", (int)GetCurrentThreadId(), (int)gotOne); if (gotOne) { ++i; - TranslateMessage(&msg); + // TranslateMessage(&msg); // No more needed: We translate V_KEY -> UTF Char manually in key up/down DispatchMessage(&msg); } } while (gotOne && i < 100); @@ -1474,10 +1327,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); - enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIIF)V"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); - enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V"); - sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V"); + sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(SISSC)V"); requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V"); if (insetsChangedID == NULL || @@ -1487,14 +1338,12 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 visibleChangedID == NULL || windowDestroyNotifyID == NULL || windowRepaintID == NULL || - enqueueMouseEventID == NULL || sendMouseEventID == NULL || - enqueueKeyEventID == NULL || sendKeyEventID == NULL || requestFocusID == NULL) { return JNI_FALSE; } - BuildDynamicKeyMapTable(); + InitKeyMapTableScanCode(env); return JNI_TRUE; } diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 85b3a14c7..9b11ff0dd 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -28,8 +28,6 @@ #include "X11Common.h" -#define USE_SENDIO_DIRECT 1 - jclass X11NewtWindowClazz = NULL; jmethodID insetsChangedID = NULL; jmethodID visibleChangedID = NULL; @@ -46,9 +44,7 @@ static jmethodID focusChangedID = NULL; static jmethodID reparentNotifyID = NULL; static jmethodID windowDestroyNotifyID = NULL; static jmethodID windowRepaintID = NULL; -static jmethodID enqueueMouseEventID = NULL; static jmethodID sendMouseEventID = NULL; -static jmethodID enqueueKeyEventID = NULL; static jmethodID sendKeyEventID = NULL; static jmethodID requestFocusID = NULL; @@ -59,10 +55,18 @@ static jmethodID requestFocusID = NULL; #define IS_WITHIN(k,a,b) ((a)<=(k)&&(k)<=(b)) static jint X11KeySym2NewtVKey(KeySym keySym) { - if(IS_WITHIN(keySym,XK_F1,XK_F12)) - return (keySym-XK_F1)+J_VK_F1; - if(IS_WITHIN(keySym,XK_KP_0,XK_KP_9)) - return (keySym-XK_KP_0)+J_VK_NUMPAD0; + if( IS_WITHIN( keySym, XK_a, XK_z ) ) { + return ( keySym - XK_a ) + J_VK_A ; + } + if( IS_WITHIN( keySym, XK_0, XK_9 ) ) { + return ( keySym - XK_0 ) + J_VK_0 ; + } + if( IS_WITHIN( keySym, XK_KP_0, XK_KP_9 ) ) { + return ( keySym - XK_KP_0 ) + J_VK_NUMPAD0 ; + } + if( IS_WITHIN( keySym, XK_F1, XK_F12 ) ) { + return ( keySym - XK_F1 ) + J_VK_F1 ; + } switch(keySym) { case XK_Return: @@ -154,15 +158,15 @@ static jint X11KeySym2NewtVKey(KeySym keySym) { return keySym; } -static jint X11InputState2NewtModifiers(unsigned int xstate, KeySym keySym) { +static jint X11InputState2NewtModifiers(unsigned int xstate, int javaVKey) { jint modifiers = 0; - if ( (ControlMask & xstate) != 0 || J_VK_CONTROL == keySym ) { + if ( (ControlMask & xstate) != 0 || J_VK_CONTROL == javaVKey ) { modifiers |= EVENT_CTRL_MASK; } - if ( (ShiftMask & xstate) != 0 || J_VK_SHIFT == keySym ) { + if ( (ShiftMask & xstate) != 0 || J_VK_SHIFT == javaVKey ) { modifiers |= EVENT_SHIFT_MASK; } - if ( (Mod1Mask & xstate) != 0 || J_VK_ALT == keySym ) { + if ( (Mod1Mask & xstate) != 0 || J_VK_ALT == javaVKey ) { modifiers |= EVENT_ALT_MASK; } if ( (Button1Mask & xstate) != 0 ) { @@ -218,10 +222,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 reparentNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "reparentNotify", "(J)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowRepaint", "(ZIIII)V"); - enqueueMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "enqueueMouseEvent", "(ZIIIIIF)V"); - sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(IIIIIF)V"); - enqueueKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "enqueueKeyEvent", "(ZIIIC)V"); - sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(IIIC)V"); + sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(SIIISF)V"); + sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(SISSC)V"); requestFocusID = (*env)->GetMethodID(env, X11NewtWindowClazz, "requestFocus", "(Z)V"); if (displayCompletedID == NULL || @@ -235,9 +237,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 reparentNotifyID == NULL || windowDestroyNotifyID == NULL || windowRepaintID == NULL || - enqueueMouseEventID == NULL || sendMouseEventID == NULL || - enqueueKeyEventID == NULL || sendKeyEventID == NULL || requestFocusID == NULL) { return JNI_FALSE; @@ -328,6 +328,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage jobject jwindow = NULL; XEvent evt; KeySym keySym = 0; + KeyCode keyCode = 0; + jshort javaVKeyUS = 0; + jshort javaVKeyNN = 0; jint modifiers = 0; char keyChar = 0; char text[255]; @@ -386,18 +389,23 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage autoRepeatModifiers &= ~EVENT_AUTOREPEAT_MASK; } // fall through intended - case KeyPress: - if(XLookupString(&evt.xkey,text,255,&keySym,0)==1) { - KeySym lower_return = 0, upper_return = 0; - keyChar=text[0]; - XConvertCase(keySym, &lower_return, &upper_return); - // always return upper case, set modifier masks (SHIFT, ..) - keySym = X11KeySym2NewtVKey(upper_return); - } else { - keyChar=0; - keySym = X11KeySym2NewtVKey(keySym); + case KeyPress: { + KeySym shiftedKeySym; // layout depending keySym w/ SHIFT + + keyCode = evt.xkey.keycode; + keySym = XkbKeycodeToKeysym(dpy, keyCode, 0 /* group */, 0 /* shift level */); // layout depending keySym w/o SHIFT + + if( XLookupString(&evt.xkey, text, 255, &shiftedKeySym, 0) == 1 ) { + keyChar=text[0]; + } + + javaVKeyNN = X11KeySym2NewtVKey(keySym); + javaVKeyUS = javaVKeyNN; // FIXME! + modifiers |= X11InputState2NewtModifiers(evt.xkey.state, javaVKeyNN) | autoRepeatModifiers; + + fprintf(stderr, "NEWT X11 Key: keyCode 0x%X keySym 0x%X (shifted: 0x%X), keyChar '%c', javaVKey[US 0x%X, NN 0x%X]\n", + (int)keyCode, (int)keySym, (int)shiftedKeySym, (int)keyChar, (int)javaVKeyUS, (int)javaVKeyNN); } - modifiers |= X11InputState2NewtModifiers(evt.xkey.state, keySym) | autoRepeatModifiers; break; case ButtonPress: @@ -413,87 +421,39 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage switch(evt.type) { case ButtonPress: (*env)->CallVoidMethod(env, jwindow, requestFocusID, JNI_FALSE); - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, - modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_PRESSED, + (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); - #endif + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jshort) evt.xbutton.button, 0.0f /*rotation*/); break; case ButtonRelease: - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, - modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_RELEASED, + (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); - #endif + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jshort) evt.xbutton.button, 0.0f /*rotation*/); break; case MotionNotify: - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, + (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED, modifiers, - (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_MOVED, - modifiers, - (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/); - #endif + (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jshort) 0, 0.0f /*rotation*/); break; case EnterNotify: DBG_PRINT( "X11: event . EnterNotify call %p %d/%d\n", (void*)evt.xcrossing.window, evt.xcrossing.x, evt.xcrossing.y); - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_ENTERED, - modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_ENTERED, + (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_ENTERED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); - #endif + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jshort) 0, 0.0f /*rotation*/); break; case LeaveNotify: DBG_PRINT( "X11: event . LeaveNotify call %p %d/%d\n", (void*)evt.xcrossing.window, evt.xcrossing.x, evt.xcrossing.y); - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_EXITED, + (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_EXITED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_EXITED, - modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); - #endif + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jshort) 0, 0.0f /*rotation*/); break; case KeyPress: - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_PRESSED, - modifiers, keySym, (jchar) keyChar); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_PRESSED, - modifiers, keySym, (jchar) keyChar); - #endif - + (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jshort) EVENT_KEY_PRESSED, + modifiers, javaVKeyUS, javaVKeyNN, (jchar) keyChar); break; case KeyRelease: - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED, - modifiers, keySym, (jchar) keyChar); - - (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED, - modifiers, keySym, (jchar) keyChar); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED, - modifiers, keySym, (jchar) keyChar); - - (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED, - modifiers, keySym, (jchar) keyChar); - #endif - + (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jshort) EVENT_KEY_RELEASED, + modifiers, javaVKeyUS, javaVKeyNN, (jchar) keyChar); break; case DestroyNotify: DBG_PRINT( "X11: event . DestroyNotify call %p, parent %p, child-event: %d\n", diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index bbddf764b..f3474ee34 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -50,8 +50,6 @@ static jmethodID windowCreatedID = NULL; static jmethodID sizeChangedID = NULL; static jmethodID visibleChangedID = NULL; static jmethodID windowDestroyNotifyID = NULL; -static jmethodID sendMouseEventID = NULL; -static jmethodID sendKeyEventID = NULL; /** * Display @@ -117,14 +115,10 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); - sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); if (windowCreatedID == NULL || sizeChangedID == NULL || visibleChangedID == NULL || - windowDestroyNotifyID == NULL || - sendMouseEventID == NULL || - sendKeyEventID == NULL) { + windowDestroyNotifyID == NULL) { DBG_PRINT( "initIDs failed\n" ); return JNI_FALSE; } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java index ec06379e0..08a181e10 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java @@ -47,6 +47,8 @@ import javax.swing.JFrame; import java.io.IOException; +import jogamp.nativewindow.jawt.JAWTUtil; + import org.junit.BeforeClass; import org.junit.Test; @@ -61,6 +63,11 @@ import com.jogamp.opengl.test.junit.util.*; /** * Testing combinations of key code modifiers of key event. + * + *

    + * Due to limitation of AWT Robot, the test machine needs to have US keyboard enabled, + * even though we do unify VK codes to US keyboard across all layouts. + *

    */ public class TestNewtKeyCodeModifiersAWT extends UITestCase { static int width, height; @@ -99,12 +106,14 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { glWindow.destroy(); } - @Test - public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { + private void testNewtCanvasAWT_Impl(boolean onscreen) throws AWTException, InterruptedException, InvocationTargetException { GLWindow glWindow = GLWindow.create(glCaps); // Wrap the window in a canvas. final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); + if( !onscreen ) { + newtCanvasAWT.setShallUseOffscreenLayer(true); + } // Add the canvas to a frame, and make it all visible. final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); @@ -129,42 +138,63 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } - glWindow.destroy(); + glWindow.destroy(); + } + + @Test + public void test02NewtCanvasAWT_Onscreen() throws AWTException, InterruptedException, InvocationTargetException { + if( JAWTUtil.isOffscreenLayerRequired() ) { + System.err.println("Platform doesn't support onscreen rendering."); + return; + } + testNewtCanvasAWT_Impl(true); } - static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, int modifierKey, int modifierMask) { + @Test + public void test03NewtCanvasAWT_Offsccreen() throws AWTException, InterruptedException, InvocationTargetException { + if( !JAWTUtil.isOffscreenLayerSupported() ) { + System.err.println("Platform doesn't support offscreen rendering."); + return; + } + testNewtCanvasAWT_Impl(false); + } + + @SuppressWarnings("deprecation") + static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, int modifierKey, int modifierMask, int keyCode, char keyCharOnly, char keyCharMod) { keyAdapter.reset(); - AWTRobotUtil.keyPress(0, robot, true, KeyEvent.VK_P, 10); // press P - AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 100); // release+typed P + AWTRobotUtil.keyPress(0, robot, true, keyCode, 10); // press keyCode + AWTRobotUtil.keyPress(0, robot, false, keyCode, 100); // release+typed keyCode robot.waitForIdle(); - for(int j=0; j < 10 && keyAdapter.getQueueSize() < 3; j++) { // wait until events are collected + for(int j=0; j < 40 && keyAdapter.getQueueSize() < 3; j++) { // wait until events are collected robot.delay(100); } AWTRobotUtil.keyPress(0, robot, true, modifierKey, 10); // press MOD - AWTRobotUtil.keyPress(0, robot, true, KeyEvent.VK_P, 10); // press P - AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 10); // release+typed P - AWTRobotUtil.keyPress(0, robot, false, modifierKey, 100); // release+typed MOD + AWTRobotUtil.keyPress(0, robot, true, keyCode, 10); // press keyCode + AWTRobotUtil.keyPress(0, robot, false, keyCode, 10); // release+typed keyCode + AWTRobotUtil.keyPress(0, robot, false, modifierKey, 100); // release MOD robot.waitForIdle(); - for(int j=0; j < 20 && keyAdapter.getQueueSize() < 3+6; j++) { // wait until events are collected + for(int j=0; j < 40 && keyAdapter.getQueueSize() < 3+5; j++) { // wait until events are collected robot.delay(100); } - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 3+6, 0); + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, + 3 /* press-SI */, 3 /* release-SI */, 2 /* typed-SI */, + 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); final List queue = keyAdapter.getQueued(); int i=0; - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, 0, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, 0, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, 0, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, 0, keyCode, keyCharOnly); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, 0, keyCode, keyCharOnly); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, 0, keyCode, keyCharOnly); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, modifierKey); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, keyCode, keyCharMod); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, keyCode, keyCharMod); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, keyCode, keyCharMod); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey, (char)0); } + @SuppressWarnings("deprecation") static void testKeyCodeAllModifierV1(Robot robot, NEWTKeyAdapter keyAdapter) { final int m1k = KeyEvent.VK_ALT; final int m1m = InputEvent.ALT_MASK; @@ -180,32 +210,31 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { AWTRobotUtil.keyPress(0, robot, true, KeyEvent.VK_P, 10); // press P AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 100); // release+typed P - AWTRobotUtil.keyPress(0, robot, false, m3k, 10); // release+typed MOD - AWTRobotUtil.keyPress(0, robot, false, m2k, 10); // release+typed MOD - AWTRobotUtil.keyPress(0, robot, false, m1k, 10); // release+typed MOD + AWTRobotUtil.keyPress(0, robot, false, m3k, 10); // release MOD + AWTRobotUtil.keyPress(0, robot, false, m2k, 10); // release MOD + AWTRobotUtil.keyPress(0, robot, false, m1k, 10); // release MOD robot.waitForIdle(); - for(int j=0; j < 20 && keyAdapter.getQueueSize() < 3*4; j++) { // wait until events are collected + for(int j=0; j < 40 && keyAdapter.getQueueSize() < 4+4+1; j++) { // wait until events are collected robot.delay(100); } - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 3*4, 0); + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, + 4 /* press-SI */, 4 /* release-SI */, 1 /* typed-SI */, + 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); final List queue = keyAdapter.getQueued(); int i=0; - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, m3k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, m3k, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, m3k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m, m2k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m, m1k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k, (char)0); } void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { @@ -233,9 +262,11 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input glWindow1KA.reset(); - testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK); - testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK); - testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_ALT, InputEvent.ALT_MASK); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_1, '1', '!'); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_Y, 'y', 'Y'); // US: Y, DE: Z + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_P, 'p', 'P'); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK, KeyEvent.VK_P, 'p', (char)0); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_ALT, InputEvent.ALT_MASK, KeyEvent.VK_P, 'p', (char)0); testKeyCodeAllModifierV1(robot, glWindow1KA); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java index ef4b17375..b3ba71795 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java @@ -48,10 +48,13 @@ import javax.swing.JFrame; import java.io.IOException; +import jogamp.nativewindow.jawt.JAWTUtil; + import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; @@ -99,12 +102,14 @@ public class TestNewtKeyCodesAWT extends UITestCase { glWindow.destroy(); } - @Test - public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { + private void testNewtCanvasAWT_Impl(boolean onscreen) throws AWTException, InterruptedException, InvocationTargetException { GLWindow glWindow = GLWindow.create(glCaps); // Wrap the window in a canvas. final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); + if( !onscreen ) { + newtCanvasAWT.setShallUseOffscreenLayer(true); + } // Add the canvas to a frame, and make it all visible. final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); @@ -131,7 +136,25 @@ public class TestNewtKeyCodesAWT extends UITestCase { } glWindow.destroy(); } + + @Test + public void test02NewtCanvasAWT_Onscreen() throws AWTException, InterruptedException, InvocationTargetException { + if( JAWTUtil.isOffscreenLayerRequired() ) { + System.err.println("Platform doesn't support onscreen rendering."); + return; + } + testNewtCanvasAWT_Impl(true); + } + @Test + public void test03NewtCanvasAWT_Offsccreen() throws AWTException, InterruptedException, InvocationTargetException { + if( !JAWTUtil.isOffscreenLayerSupported() ) { + System.err.println("Platform doesn't support offscreen rendering."); + return; + } + testNewtCanvasAWT_Impl(false); + } + static CodeSeg[] codeSegments = new CodeSeg[] { new CodeSeg(0x008, 0x008, "bs"), // new CodeSeg(0x009, 0x009, "tab"), // TAB functions as focus traversal key @@ -167,14 +190,29 @@ public class TestNewtKeyCodesAWT extends UITestCase { keyAdapter.reset(); final CodeSeg codeSeg = codeSegments[i]; // System.err.println("*** Segment "+codeSeg.description); - for(int c=codeSeg.min; c<=codeSeg.max; c++) { + int eventCount = 0; + for(short c=codeSeg.min; c<=codeSeg.max; c++) { // System.err.println("*** KeyCode 0x"+Integer.toHexString(c)); - AWTRobotUtil.keyPress(0, robot, true, c, 10); - AWTRobotUtil.keyPress(0, robot, false, c, 100); + try { + AWTRobotUtil.keyPress(0, robot, true, c, 10); + } catch (Exception e) { + System.err.println("Exception @ AWT Robot.PRESS "+MiscUtils.toHexString(c)+" - "+e.getMessage()); + break; + } + eventCount++; + try { + AWTRobotUtil.keyPress(0, robot, false, c, 100); + } catch (Exception e) { + System.err.println("Exception @ AWT Robot.RELEASE "+MiscUtils.toHexString(c)+" - "+e.getMessage()); + break; + } + eventCount++; + if( KeyEvent.isPrintableKey(c) ) { + eventCount++; + } robot.waitForIdle(); } - final int codeCount = codeSeg.max - codeSeg.min + 1; - for(int j=0; j < 20 && keyAdapter.getQueueSize() < 3 * codeCount; j++) { // wait until events are collected + for(int j=0; j < 20 && keyAdapter.getQueueSize() < eventCount; j++) { // wait until events are collected robot.delay(100); } final ArrayList events = new ArrayList(keyAdapter.getQueued()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java index 00fbc0500..d7de4e735 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java @@ -153,6 +153,7 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { glWindow.destroy(); } + @SuppressWarnings("deprecation") static void testKeyEventAutoRepeat(Robot robot, NEWTKeyAdapter keyAdapter, int loops, int pressDurationMS) { System.err.println("KEY Event Auto-Repeat Test: "+loops); EventObject[][] first = new EventObject[loops][3]; @@ -201,9 +202,19 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { final boolean hasAR = 0 < keyAdapter.getKeyPressedCount(true) ; { - final int expTotal = keyEvents.size(); - final int expAR = hasAR ? expTotal - 3 * 2 * loops : 0; // per loop: 3 for non AR events and 3 for non AR 'B' - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, expTotal, expAR); + final int perLoopSI = 2; // per loop: 1 non AR event and 1 for non AR 'B' + final int expSI, expAR; + if( hasAR ) { + expSI = perLoopSI * loops; + expAR = ( keyEvents.size() - expSI*3 ) / 2; // AR: no typed -> 2, SI: typed -> 3 + } else { + expSI = keyEvents.size() / 3; // all typed events + expAR = 0; + } + + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, + expSI /* press-SI */, expSI /* release-SI */, expSI /* typed-SI */, + expAR /* press-AR */, expAR /* release-AR */, 0 /* typed-AR */ ); } if( !hasAR ) { @@ -216,7 +227,7 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { NEWTKeyUtil.dumpKeyEvents(Arrays.asList(first[i])); System.err.println("Auto-Repeat Loop "+i+" - Tail:"); NEWTKeyUtil.dumpKeyEvents(Arrays.asList(last[i])); - } + } for(int i=0; i missCodes, CodeSeg codeSeg, List keyEvents, boolean verbose) { final int codeCount = codeSeg.max - codeSeg.min + 1; int misses = 0; + int evtIdx = 0; for(int i=0; i KEY_PRESSED ! + final short c = (short) ( codeSeg.min + i ); + final KeyEvent e = (KeyEvent) ( evtIdx < keyEvents.size() ? keyEvents.get(evtIdx) : null ); + if( null == e ) { missCodes.add(new CodeEvent(c, codeSeg.description, e)); misses++; + evtIdx++; + } else { + if( c != e.getKeyCode() ) { + missCodes.add(new CodeEvent(c, codeSeg.description, e)); + misses++; + } + if( KeyEvent.isPrintableKey(c) ) { + evtIdx += 3; // w/ TYPED + } else { + evtIdx += 2; + } } } - final boolean res = 3*codeCount == keyEvents.size() && 0 == missCodes.size(); + final boolean res = evtIdx == keyEvents.size() && 0 == missCodes.size(); if(verbose) { System.err.println("+++ Code Segment "+codeSeg.description+", Misses: "+misses+" / "+codeCount+", events "+keyEvents.size()+", valid "+res); } return res; } - public static void validateKeyEvent(KeyEvent e, int eventType, int modifier, int keyCode) { - if(0 <= keyCode) { - Assert.assertTrue("KeyEvent code mismatch, expected 0x"+Integer.toHexString(keyCode)+", has "+e, keyCode == e.getKeyCode()); - } + public static void validateKeyEvent(KeyEvent e, int eventType, int modifier, int keyCode, char keyChar) { if(0 <= eventType) { Assert.assertTrue("KeyEvent type mismatch, expected 0x"+Integer.toHexString(eventType)+", has "+e, eventType == e.getEventType()); } if(0 <= modifier) { Assert.assertTrue("KeyEvent modifier mismatch, expected 0x"+Integer.toHexString(modifier)+", has "+e, modifier == e.getModifiers()); } + if(0 < keyCode) { + Assert.assertTrue("KeyEvent code mismatch, expected 0x"+Integer.toHexString(keyCode)+", has "+e, keyCode == e.getKeyCode()); + } + if(0 < keyChar) { + Assert.assertTrue("KeyEvent char mismatch, expected 0x"+Integer.toHexString(keyChar)+", has "+e, keyChar == e.getKeyChar()); + } } - public static int getNextKeyEventType(int et) { + @SuppressWarnings("deprecation") + public static short getNextKeyEventType(KeyEvent e) { + final int et = e.getEventType(); switch( et ) { case KeyEvent.EVENT_KEY_PRESSED: return KeyEvent.EVENT_KEY_RELEASED; case KeyEvent.EVENT_KEY_RELEASED: - return KeyEvent.EVENT_KEY_TYPED; + return e.isPrintableKey() && !e.isAutoRepeat() ? KeyEvent.EVENT_KEY_TYPED : KeyEvent.EVENT_KEY_PRESSED; case KeyEvent.EVENT_KEY_TYPED: return KeyEvent.EVENT_KEY_PRESSED; default: - Assert.assertTrue("Invalid event type "+et, false); + Assert.assertTrue("Invalid event "+e, false); return 0; - } + } } public static void validateKeyEventOrder(List keyEvents) { @@ -141,45 +158,68 @@ public class NEWTKeyUtil { eet = KeyEvent.EVENT_KEY_PRESSED; } final int et = e.getEventType(); - Assert.assertEquals("Key event not in proper order", eet, et); - eet = getNextKeyEventType(et); + Assert.assertEquals("Key event not in proper order "+i+"/"+keyEvents.size()+" - event "+e, eet, et); + eet = getNextKeyEventType(e); keyCode2NextEvent.put(e.getKeyCode(), eet); } } /** - * * @param keyAdapter - * @param expTotalCount number of key press/release/types events - * @param expARCount number of key press/release/types Auto-Release events + * @param expPressedCountSI number of single key press events + * @param expReleasedCountSI number of single key release events + * @param expTypedCountSI number of single key types events + * @param expPressedCountAR number of auto-repeat key press events + * @param expReleasedCountAR number of auto-repeat key release events + * @param expTypedCountAR number of auto-repeat key types events */ - public static void validateKeyAdapterStats(NEWTKeyAdapter keyAdapter, int expTotalCount, int expARCount) { - final int keyPressed = keyAdapter.getKeyPressedCount(false); + public static void validateKeyAdapterStats(NEWTKeyAdapter keyAdapter, + int expPressedCountSI, int expReleasedCountSI, int expTypedCountSI, + int expPressedCountAR, int expReleasedCountAR, int expTypedCountAR) { + final int expTotalCountSI = expPressedCountSI + expReleasedCountSI + expTypedCountSI; + final int expTotalCountAR = expPressedCountAR + expReleasedCountAR + expTypedCountAR; + final int expTotalCountALL = expTotalCountSI + expTotalCountAR; + + final int keyPressedALL = keyAdapter.getKeyPressedCount(false); final int keyPressedAR = keyAdapter.getKeyPressedCount(true); - final int keyReleased = keyAdapter.getKeyReleasedCount(false); + final int keyReleasedALL = keyAdapter.getKeyReleasedCount(false); final int keyReleasedAR = keyAdapter.getKeyReleasedCount(true); - final int keyTyped = keyAdapter.getKeyTypedCount(false); + final int keyTypedALL = keyAdapter.getKeyTypedCount(false); final int keyTypedAR = keyAdapter.getKeyTypedCount(true); - final int keyPressedNR = keyPressed-keyPressedAR; - final int keyReleasedNR = keyReleased-keyReleasedAR; - final int keyTypedNR = keyTyped-keyTypedAR; - System.err.println("Total Press "+keyPressed +", Release "+keyReleased +", Typed "+keyTyped); - System.err.println("AutoR Press "+keyPressedAR+", Release "+keyReleasedAR+", Typed "+keyTypedAR); - System.err.println("No AR Press "+keyPressedNR+", Release "+keyReleasedNR+", Typed "+keyTypedNR); + + final int keyPressedSI = keyPressedALL-keyPressedAR; + final int keyReleasedSI = keyReleasedALL-keyReleasedAR; + final int keyTypedSI = keyTypedALL-keyTypedAR; + + final int totalCountALL = keyPressedALL + keyReleasedALL + keyTypedALL; + final int totalCountSI = keyPressedSI + keyReleasedSI + keyTypedSI; + final int totalCountAR = keyPressedAR + keyReleasedAR + keyTypedAR; + + System.err.println("Expec Single Press "+expPressedCountSI +", Release "+expReleasedCountSI +", Typed "+expTypedCountSI +", Events "+expTotalCountSI); + System.err.println("Expec AutoRp Press "+expPressedCountAR +", Release "+expReleasedCountAR +", Typed "+expTypedCountAR +", Events "+expTotalCountAR); + + System.err.println("Total Single Press "+keyPressedSI +", Release "+keyReleasedSI +", Typed "+keyTypedSI +", Events "+totalCountSI); + System.err.println("Total AutoRp Press "+keyPressedAR +", Release "+keyReleasedAR +", Typed "+keyTypedAR +", Events "+totalCountAR); + System.err.println("Total ALL Press "+keyPressedALL +", Release "+keyReleasedALL +", Typed "+keyTypedALL+", Events "+totalCountALL); + + Assert.assertEquals("Internal Error: totalSI != totalALL - totalAR", totalCountSI, totalCountALL - totalCountAR); + + Assert.assertEquals("Invalid: Has AR Typed events", 0, keyTypedAR); + Assert.assertEquals("Invalid: Exp AR Typed events", 0, expTypedCountAR); + + Assert.assertEquals("Key press count failure (SI)", expPressedCountSI, keyPressedSI); + Assert.assertEquals("Key released count failure (SI)", expReleasedCountSI, keyReleasedSI); + Assert.assertEquals("Key typed count failure (SI)", expTypedCountSI, keyTypedSI); + + Assert.assertEquals("Key press count failure (AR)", expPressedCountAR, keyPressedAR); + Assert.assertEquals("Key released count failure (AR)", expReleasedCountAR, keyReleasedAR); + + Assert.assertEquals("Key total count failure (SI)", expTotalCountSI, totalCountSI); + Assert.assertEquals("Key total count failure (AR)", expTotalCountAR, totalCountAR); final List keyEvents = keyAdapter.getQueued(); - Assert.assertEquals("Key event count not multiple of 3", 0, keyEvents.size()%3); - Assert.assertEquals("Key event count not 3 * press_release_count", expTotalCount, keyEvents.size()); - Assert.assertEquals("Key press count failure", expTotalCount/3, keyPressed); - Assert.assertEquals("Key press count failure (AR)", expARCount/3, keyPressedAR); - Assert.assertEquals("Key released count failure", expTotalCount/3, keyReleased); - Assert.assertEquals("Key released count failure (AR)", expARCount/3, keyReleasedAR); - Assert.assertEquals("Key typed count failure", expTotalCount/3, keyTyped); - Assert.assertEquals("Key typed count failure (AR)", expARCount/3, keyTypedAR); - // should be true - always, reaching this point - duh! - Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyPressedNR); - Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyReleasedNR); - Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyTypedNR); - } + Assert.assertEquals("Key total count failure (ALL) w/ list sum ", expTotalCountALL, totalCountALL); + Assert.assertEquals("Key total count failure (ALL) w/ list size ", expTotalCountALL, keyEvents.size()); + } } -- cgit v1.2.3 From 7d5c51b635e0795d9b170342bdebe8e7e0bbd01d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 20 Feb 2013 14:29:04 +0100 Subject: NEWT/OSX: Fix 'locationOnScreen' usage and use proper client-area window screen position (Fixes resize -> position) - Tested w/ NEWT GearsES2 and Java6 and Java7 on OSX --- make/build-test.xml | 5 +- .../jogamp/newt/driver/macosx/WindowDriver.java | 73 ++++++++++----------- src/newt/native/MacWindow.m | 74 +++++++++++----------- src/newt/native/NewtMacWindow.h | 5 +- src/newt/native/NewtMacWindow.m | 21 ++++-- 5 files changed, 95 insertions(+), 83 deletions(-) (limited to 'src/newt/classes') diff --git a/make/build-test.xml b/make/build-test.xml index b3b121049..da6e3ec29 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -300,6 +300,7 @@ + @@ -550,7 +551,6 @@ - @@ -609,15 +609,14 @@ - + - diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 1bbbf8a7d..08c7a14c2 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -144,6 +144,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl setTitle0(getWindowHandle(), title); } + @Override protected void requestFocusImpl(boolean force) { if(!isOffscreenInstance) { requestFocus0(getWindowHandle(), force); @@ -152,6 +153,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } + @Override public final void clearFocus() { if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow: clearFocus(), isOffscreenInstance "+isOffscreenInstance); @@ -163,29 +165,34 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } + @Override public void updatePosition() { - final Point pS = getTopLevelLocationOnScreen(getX(), getY()); + final Point pS = getLocationOnScreenImpl(0, 0); if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow: updatePosition() - isOffscreenInstance "+isOffscreenInstance+", new abs pos: pS "+pS); } if( !isOffscreenInstance ) { - setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY()); + setWindowClientTopLeftPoint0(getWindowHandle(), pS.getX(), pS.getY()); } // else no offscreen position // no native event (fullscreen, some reparenting) - super.positionChanged(true, getX(), getY()); - } - + positionChanged(true, pS.getX(), pS.getY()); + } protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { final boolean _isOffscreenInstance = isOffscreenInstance(this, this.getParent()); isOffscreenInstance = 0 != sscSurfaceHandle || _isOffscreenInstance; - final PointImmutable pS = isOffscreenInstance ? new Point(0, 0) : getTopLevelLocationOnScreen(x, y); + final PointImmutable pClientLevelOnSreen; + if( isOffscreenInstance ) { + pClientLevelOnSreen = new Point(0, 0); + } else { + pClientLevelOnSreen = new Point(x, y); + } if(DEBUG_IMPLEMENTATION) { final AbstractGraphicsConfiguration cWinCfg = this.getGraphicsConfiguration(); final NativeWindow pWin = getParent(); final AbstractGraphicsConfiguration pWinCfg = null != pWin ? pWin.getGraphicsConfiguration() : null; - System.err.println("MacWindow reconfig: "+x+"/"+y+" -> "+pS+" - "+width+"x"+height+ + System.err.println("MacWindow reconfig.0: "+x+"/"+y+" -> clientPos "+pClientLevelOnSreen+" - "+width+"x"+height+ ",\n\t parent type "+(null != pWin ? pWin.getClass().getName() : null)+ ",\n\t this-chosenCaps "+(null != cWinCfg ? cWinCfg.getChosenCapabilities() : null)+ ",\n\t parent-chosenCaps "+(null != pWinCfg ? pWinCfg.getChosenCapabilities() : null)+ @@ -207,24 +214,19 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl 0 != ( FLAG_CHANGE_PARENTING & flags) || 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { if(isOffscreenInstance) { - createWindow(true, 0 != getWindowHandle(), pS, 64, 64, false); + createWindow(true, 0 != getWindowHandle(), pClientLevelOnSreen, 64, 64, false); } else { - createWindow(false, 0 != getWindowHandle(), pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); + createWindow(false, 0 != getWindowHandle(), pClientLevelOnSreen, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); } if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; } } - if(x>=0 && y>=0) { + if( width>0 && height>0 && x>=0 && y>=0 ) { if( !isOffscreenInstance ) { - setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY()); - } // else no offscreen position - // no native event (fullscreen, some reparenting) - super.positionChanged(true, x, y); - } - if(width>0 && height>0) { - if( !isOffscreenInstance ) { - setContentSize0(getWindowHandle(), width, height); + // setContentSize0(getWindowHandle(), width, height); + setWindowClientTopLeftPointAndSize0(getWindowHandle(), pClientLevelOnSreen.getX(), pClientLevelOnSreen.getY(), width, height); } // else offscreen size is realized via recreation // no native event (fullscreen, some reparenting) + positionChanged(true, x, y); sizeChanged(true, width, height, false); // incl. validation (incl. repositioning) } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) { @@ -237,6 +239,9 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( !isOffscreenInstance ) { setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags)); } + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow reconfig.X: clientPos "+pClientLevelOnSreen+", "+width+"x"+height+" -> clientPos "+getLocationOnScreenImpl(0, 0)+", topPos "+getTopLevelLocationOnScreen(0, 0)+", insets: "+getInsets()); + } return true; } @@ -270,26 +275,22 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // nop - using event driven insetsChange(..) } - @Override - protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { - if(getWidth() != newWidth || getHeight() != newHeight) { - final Point p0S = getTopLevelLocationOnScreen(getX(), getY()); - setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), p0S.getX(), p0S.getY()); - } - super.sizeChanged(defer, newWidth, newHeight, force); - } - - @Override - protected void positionChanged(boolean defer, int newX, int newY) { + /** Callback for native screen position change event of the client area. */ + protected void screenPositionChanged(boolean defer, int newX, int newY) { // passed coordinates are in screen position of the client area - if(getWindowHandle()!=0) { - // screen position -> window position - Point absPos = new Point(newX, newY); + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow.positionChanged (Screen Pos): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY); + } + if(getWindowHandle()!=0) { final NativeWindow parent = getParent(); - if(null != parent) { + if(null == parent) { + positionChanged(defer, newX, newY); + } else { + // screen position -> rel child window position + Point absPos = new Point(newX, newY); absPos.translate( parent.getLocationOnScreen(null).scale(-1, -1) ); + positionChanged(defer, absPos.getX(), absPos.getY()); } - super.positionChanged(defer, absPos.getX(), absPos.getY()); } } @@ -433,8 +434,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private native long contentView0(long window); /** Must be called on Main-Thread */ private native long changeContentView0(long parentWindowOrViewHandle, long window, long view); - private native void setContentSize0(long window, int w, int h); - private native void setFrameTopLeftPoint0(long parentWindowHandle, long window, int x, int y); + private native void setWindowClientTopLeftPointAndSize0(long window, int x, int y, int w, int h); + private native void setWindowClientTopLeftPoint0(long window, int x, int y); private native void setAlwaysOnTop0(long window, boolean atop); private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y); private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 94363624f..1895b98a5 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -62,14 +62,25 @@ static NSString* jstringToNSString(JNIEnv* env, jstring jstr) return str; } -static void setFrameTopLeftPoint(NSWindow* pWin, NewtMacWindow* mWin, jint x, jint y) { - NSPoint pS = [mWin newtScreenWinPos2OSXScreenPos: NSMakePoint(x, y)]; +static void setWindowClientTopLeftPoint(NewtMacWindow* mWin, jint x, jint y) { + NSPoint pS = [mWin newtAbsClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y)]; [mWin setFrameOrigin: pS]; NSView* mView = [mWin contentView]; [mWin invalidateCursorRectsForView: mView]; } +static void setWindowClientTopLeftPointAndSize(NewtMacWindow* mWin, jint x, jint y, jint width, jint height) { + NSSize sz = NSMakeSize(width, height); + NSPoint pS = [mWin newtAbsClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y) size: sz]; + NSRect rect = { pS, sz }; + [mWin setFrame: rect display:YES]; + + // -> display:YES + // NSView* mView = [mWin contentView]; + // [mWin invalidateCursorRectsForView: mView]; +} + #ifdef VERBOSE_ON static int getRetainCount(NSObject * obj) { return ( NULL == obj ) ? -1 : (int)([obj retainCount]) ; @@ -575,21 +586,21 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow if(screen_idx<0) screen_idx=0; if(screen_idx>=[screens count]) screen_idx=0; NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; - NSRect rect; + NSRect rectWin; if (fullscreen) { styleMask = NSBorderlessWindowMask; - rect = [myScreen frame]; + rectWin = [myScreen frame]; x = 0; y = 0; - w = (jint) (rect.size.width); - h = (jint) (rect.size.height); + w = (jint) (rectWin.size.width); + h = (jint) (rectWin.size.height); } else { - rect = NSMakeRect(x, y, w, h); + rectWin = NSMakeRect(x, y, w, h); } // Allocate the window - NewtMacWindow* myWindow = [[NewtMacWindow alloc] initWithContentRect: rect + NewtMacWindow* myWindow = [[NewtMacWindow alloc] initWithContentRect: rectWin styleMask: (NSUInteger) styleMask backing: (NSBackingStoreType) bufferingType defer: NO @@ -646,7 +657,8 @@ NS_ENDHANDLER // Use given NewtView or allocate an NewtView if NULL if(NULL == myView) { - myView = [[NewtView alloc] initWithFrame: rect] ; + NSRect rectView = NSMakeRect(0, 0, w, h); + myView = [[NewtView alloc] initWithFrame: rectView] ; DBG_PRINT( "createWindow0.%d - use new view: %p,%d\n", dbgIdx++, myView, getRetainCount(myView)); } else { DBG_PRINT( "createWindow0.%d - use given view: %p,%d\n", dbgIdx++, myView, getRetainCount(myView)); @@ -666,7 +678,7 @@ NS_ENDHANDLER } // Immediately re-position the window based on an upper-left coordinate system - setFrameTopLeftPoint(parentWindow, myWindow, x, y); + setWindowClientTopLeftPoint(myWindow, x, y); // force surface creation [myView lockFocus]; @@ -1000,50 +1012,40 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_changeConten /* * Class: jogamp_newt_driver_macosx_WindowDriver - * Method: setContentSize - * Signature: (JII)V + * Method: setWindowClientTopLeftPointAndSize0 + * Signature: (JIIII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setContentSize0 - (JNIEnv *env, jobject unused, jlong window, jint w, jint h) +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setWindowClientTopLeftPointAndSize0 + (JNIEnv *env, jobject unused, jlong window, jint x, jint y, jint w, jint h) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSWindow* win = (NSWindow*) ((intptr_t) window); + NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window); - DBG_PRINT( "setContentSize0 - window: %p (START)\n", win); + DBG_PRINT( "setWindowClientTopLeftPointAndSize - window: %p (START)\n", mWin); - NSSize sz = NSMakeSize(w, h); - [win setContentSize: sz]; + setWindowClientTopLeftPointAndSize(mWin, x, y, w, h); - DBG_PRINT( "setContentSize0 - window: %p (END)\n", win); + DBG_PRINT( "setWindowClientTopLeftPointAndSize - window: %p (END)\n", mWin); [pool release]; } /* * Class: jogamp_newt_driver_macosx_WindowDriver - * Method: setFrameTopLeftPoint - * Signature: (JJII)V + * Method: setWindowClientTopLeftPoint0 + * Signature: (JII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setFrameTopLeftPoint0 - (JNIEnv *env, jobject unused, jlong parent, jlong window, jint x, jint y) +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setWindowClientTopLeftPoint0 + (JNIEnv *env, jobject unused, jlong window, jint x, jint y) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window); - NSObject *nsParentObj = (NSObject*) ((intptr_t) parent); - NSWindow* pWin = NULL; - if( nsParentObj != NULL && [nsParentObj isKindOfClass:[NSWindow class]] ) { - pWin = (NSWindow*) nsParentObj; - } else if( nsParentObj != NULL && [nsParentObj isKindOfClass:[NSView class]] ) { - NSView* pView = (NSView*) nsParentObj; - pWin = [pView window]; - } - - DBG_PRINT( "setFrameTopLeftPoint0 - window: %p, parent %p (START)\n", mWin, pWin); + DBG_PRINT( "setWindowClientTopLeftPoint - window: %p (START)\n", mWin); - setFrameTopLeftPoint(pWin, mWin, x, y); + setWindowClientTopLeftPoint(mWin, x, y); - DBG_PRINT( "setFrameTopLeftPoint0 - window: %p, parent %p (END)\n", mWin, pWin); + DBG_PRINT( "setWindowClientTopLeftPoint - window: %p (END)\n", mWin); [pool release]; } @@ -1129,6 +1131,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_warpPointer0 (JNIEnv *env, jclass clazz, jlong window, jint x, jint y) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); - [mWin setMousePosition: [mWin newtClientWinPos2OSXScreenPos: NSMakePoint(x, y)]]; + [mWin setMousePosition: [mWin newtRelClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y)]]; } diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index 1e4f0c3ba..6d1bcca00 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -134,8 +134,9 @@ - (void) attachToParent: (NSWindow*) parent; - (void) detachFromParent: (NSWindow*) parent; -- (NSPoint) newtScreenWinPos2OSXScreenPos: (NSPoint) p; -- (NSPoint) newtClientWinPos2OSXScreenPos: (NSPoint) p; +- (NSPoint) newtAbsClientTLWinPos2AbsBLScreenPos: (NSPoint) p; +- (NSPoint) newtAbsClientTLWinPos2AbsBLScreenPos: (NSPoint) p size: (NSSize) nsz; +- (NSPoint) newtRelClientTLWinPos2AbsBLScreenPos: (NSPoint) p; - (NSPoint) getLocationOnScreen: (NSPoint) p; - (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 66d68d9d2..282c13fd3 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -356,7 +356,7 @@ static jmethodID windowRepaintID = NULL; sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); - positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZII)V"); + positionChangedID = (*env)->GetMethodID(env, clazz, "screenPositionChanged", "(ZII)V"); focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); @@ -484,19 +484,28 @@ static jmethodID windowRepaintID = NULL; } /** - * p abs screen position w/ top-left origin + * p abs screen position of client-area pos w/ top-left origin, using contentView's client NSSize * returns: abs screen position w/ bottom-left origin */ -- (NSPoint) newtScreenWinPos2OSXScreenPos: (NSPoint) p +- (NSPoint) newtAbsClientTLWinPos2AbsBLScreenPos: (NSPoint) p { NSView* mView = [self contentView]; NSRect mViewFrame = [mView frame]; - int totalHeight = mViewFrame.size.height + cachedInsets[2] + cachedInsets[3]; // height + insets[top+bottom] + return [self newtAbsClientTLWinPos2AbsBLScreenPos: p size: mViewFrame.size]; +} + +/** + * p abs screen position of client-area pos w/ top-left origin, using given client NSSize + * returns: abs screen position w/ bottom-left origin + */ +- (NSPoint) newtAbsClientTLWinPos2AbsBLScreenPos: (NSPoint) p size: (NSSize) nsz +{ + int totalHeight = nsz.height + cachedInsets[3]; // height + insets.bottom NSScreen* screen = [self screen]; NSRect screenFrame = [screen frame]; - return NSMakePoint(screenFrame.origin.x + p.x + cachedInsets[0], + return NSMakePoint(screenFrame.origin.x + p.x, screenFrame.origin.y + screenFrame.size.height - p.y - totalHeight); } @@ -504,7 +513,7 @@ static jmethodID windowRepaintID = NULL; * p rel client window position w/ top-left origin * returns: abs screen position w/ bottom-left origin */ -- (NSPoint) newtClientWinPos2OSXScreenPos: (NSPoint) p +- (NSPoint) newtRelClientTLWinPos2AbsBLScreenPos: (NSPoint) p { NSRect winFrame = [self frame]; -- cgit v1.2.3 From cf3ecdb670c0dfecd1394d5b9d5d5588c1bf71f3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 20 Feb 2013 14:30:50 +0100 Subject: NewtCanvasAWT: Fix size determination, i.e. take newt-child's size into account if no preferred size is given. --- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 6fc5a46ce..195f8af8c 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -432,19 +432,23 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final int w; final int h; if(isPreferredSizeSet()) { + // 1st: Component's PreferedSize java.awt.Dimension d = getPreferredSize(); w = d.width; h = d.height; } else { - final java.awt.Dimension min; + final java.awt.Dimension min1, min2; + // 2nd: Component's Max( Max( comp.min, newt.size ), cont.size ) if(this.isMinimumSizeSet()) { - min = getMinimumSize(); + min1 = getMinimumSize(); } else { - min = new java.awt.Dimension(0, 0); + min1 = new java.awt.Dimension(0, 0); } + min2 = new java.awt.Dimension( Math.max( min1.width, newtChild.getWidth() ), + Math.max( min1.height, newtChild.getHeight() ) ); java.awt.Insets ins = cont.getInsets(); - w = Math.max(min.width, cont.getWidth() - ins.left - ins.right); - h = Math.max(min.height, cont.getHeight() - ins.top - ins.bottom); + w = Math.max(min2.width, cont.getWidth() - ins.left - ins.right); + h = Math.max(min2.height, cont.getHeight() - ins.top - ins.bottom); } setSize(w, h); newtChild.setSize(w, h); @@ -455,7 +459,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto // force this AWT Canvas to be focus-able, // since this it is completely covered by the newtChild (z-order). - setFocusable(true); + setFocusable(true); } else { configureNewtChild(false); newtChild.setVisible(false); -- cgit v1.2.3 From 14b278536e6f8de2ee6254796b89bd27d5419b72 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 20 Feb 2013 21:51:40 +0100 Subject: OSX/Java7/CALayer + JAWT: Partially Fix AWT/NEWT CALayer 'out of sight' bug, where our CALayer is moved out of the visible area - same erroneous behavior for GLCanvas and NewtCanvasAWT - sized-frame: Set framesize and validate() it - sized-component: Set component preferred size and call frame.pack() - added workaround 'OffscreenLayerSurface.layoutSurfaceLayer()' to fix CALayer size, which snaps for: - OK initial size before setVisible: sized-frame and sized-component - OK resize w/ sized-frame - OK manual frame resize - Invisible: w/ sized-component after setVisible() ++ - CALayer-Sublayer (GL) has additional retain/release when added/removed to be on safe side. --- make/scripts/tests.sh | 73 ++++++++++++---------- .../classes/javax/media/opengl/awt/GLCanvas.java | 3 + .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 1 + .../macosx/MacOSXWindowSystemInterface-calayer.m | 24 ++++--- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 15 ++++- .../media/nativewindow/OffscreenLayerSurface.java | 15 +++++ .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 12 +++- .../jogamp/nativewindow/macosx/OSXUtil.java | 30 ++++++++- src/nativewindow/native/macosx/OSXmisc.m | 57 ++++++++++++++++- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 14 ++++- .../jogamp/newt/driver/macosx/WindowDriver.java | 2 +- .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 3 +- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 3 +- .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 3 +- .../demos/es2/newt/TestGearsES2NewtCanvasSWT.java | 9 +-- .../junit/jogl/demos/es2/swt/TestGearsES2SWT.java | 3 +- 16 files changed, 205 insertions(+), 62 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7a65c736a..b3aa39dfc 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -35,7 +35,7 @@ if [ $MOSX -eq 1 ] ; then echo setup OSX environment vars #export NSZombieEnabled=YES export NSTraceEvents=YES - export OBJC_PRINT_EXCEPTIONS=YES + #export OBJC_PRINT_EXCEPTIONS=YES echo NSZombieEnabled $NSZombieEnabled 2>&1 | tee -a java-run.log echo NSTraceEvents $NSTraceEvents 2>&1 | tee -a java-run.log echo OBJC_PRINT_EXCEPTIONS $OBJC_PRINT_EXCEPTIONS 2>&1 | tee -a java-run.log @@ -135,7 +135,6 @@ function jrun() { #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" #D_ARGS="-Dnewt.debug.MainThread" - #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" @@ -167,8 +166,8 @@ function jrun() { #D_ARGS="-Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" - #D_ARGS="-Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -222,9 +221,13 @@ function jrun() { #X_ARGS="-Dnativewindow.ws.name=jogamp.newt.driver.broadcom.egl $X_ARGS" echo CLASSPATH $CLASSPATH if [ $MOSX_MT -eq 1 ] ; then - X_ARGS="-XstartOnFirstThread $X_ARGS" - if [ $swton -eq 0 ] ; then + if [ $awton -eq 0 -a $swton -eq 0 ] ; then + # No AWT, No SWT -> Preserve Main-Thread + X_ARGS="-XstartOnFirstThread $X_ARGS" C_ARG="com.jogamp.newt.util.MainThread" + elif [ $swton -eq 1 ] ; then + # SWT: Only Launch on Main-Thread + X_ARGS="-XstartOnFirstThread $X_ARGS" fi fi echo @@ -255,6 +258,31 @@ function testawtswt() { jrun 1 1 $* 2>&1 | tee -a java-run.log } +# +# demos (any TK, more user driven tests) +# +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* +#testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* +#testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2SWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* +#testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* + # # core/newt (testnoawt and testawt) # @@ -262,13 +290,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.JoglVersion $* #testnoawt com.jogamp.newt.NewtVersion $* #testnoawt com.jogamp.newt.opengl.GLWindow $* -#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* @@ -305,6 +326,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove03GLWindowNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* @@ -326,13 +350,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* + #testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* @@ -373,11 +391,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug664GLCanvasSetVisibleSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* @@ -409,21 +422,19 @@ function testawtswt() { # newt.awt (testawt) # #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* + #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* @@ -469,8 +480,6 @@ testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* # # Texture / TextureUtils @@ -486,8 +495,6 @@ testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01AWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* # # GLSL diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index c9069f9ce..dc4fe955c 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -702,6 +702,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock + if(null != jawtWindow && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { + jawtWindow.layoutSurfaceLayer(); + } } } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 37aca0cd7..9e0174595 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -713,6 +713,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl } } } + backingLayerHost.layoutSurfaceLayer(); } else { lastWidth = drawable.getWidth(); lastHeight = drawable.getHeight(); diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index 55c4ad053..b965accab 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -114,6 +114,7 @@ extern GLboolean glIsVertexArray (GLuint array); - (void)dealloc { CGLContextObj cglCtx = [self CGLContextObj]; + DBG_PRINT("MyNSOpenGLContext::dealloc.0 %p (refcnt %d) - CGL-Ctx %p\n", self, (int)[self retainCount], cglCtx); [self clearDrawable]; if( NULL != cglCtx ) { @@ -537,7 +538,6 @@ static const GLfloat gl_verts[] = { { DBG_PRINT("MyNSOpenGLLayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]); // NSLog(@"MyNSOpenGLLayer::dealloc: %@",[NSThread callStackSymbols]); - [self disableAnimation]; pthread_mutex_lock(&renderLock); [self deallocPBuffer]; @@ -555,13 +555,23 @@ static const GLfloat gl_verts[] = { - (void)resizeWithOldSuperlayerSize:(CGSize)size { - CGRect lRectS = [[self superlayer] bounds]; - - DBG_PRINT("MyNSOpenGLLayer::resizeWithOldSuperlayerSize: %p, texSize %dx%d, bounds: %lfx%lf -> %lf/%lf %lfx%lf (refcnt %d)\n", - self, texWidth, texHeight, size.width, size.height, lRectS.origin.x, lRectS.origin.y, lRectS.size.width, lRectS.size.height, (int)[self retainCount]); + CALayer * superL = [self superlayer]; + CGRect lRectSFrame = [superL frame]; + + DBG_PRINT("MyNSOpenGLLayer::resizeWithOldSuperlayerSize: %p, texSize %dx%d -> size: %lfx%lf ; Super Frame[%lf/%lf %lfx%lf] (refcnt %d)\n", + self, texWidth, texHeight, size.width, size.height, + lRectSFrame.origin.x, lRectSFrame.origin.y, lRectSFrame.size.width, lRectSFrame.size.height, + (int)[self retainCount]); + + // With Java7 our root CALayer's frame gets off-limit -> force 0/0 origin! + if( lRectSFrame.origin.x!=0 || lRectSFrame.origin.y!=0 ) { + lRectSFrame.origin.x = 0; + lRectSFrame.origin.y = 0; + [superL setPosition: lRectSFrame.origin]; + } - newTexWidth = lRectS.size.width; - newTexHeight = lRectS.size.height; + newTexWidth = lRectSFrame.size.width; + newTexHeight = lRectSFrame.size.height; shallDraw = [self isGLSourceValid]; SYNC_PRINT("", newTexWidth, newTexHeight); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 007a917a6..d65f8c231 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -130,7 +130,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(changed) { if(DEBUG) { System.err.println("JAWTWindow.updateBounds: "+bounds+" -> "+jb); - Thread.dumpStack(); + // Thread.dumpStack(); } bounds.setX(jawtBounds.getX()); bounds.setY(jawtBounds.getY()); @@ -205,7 +205,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } try { if(DEBUG) { - System.err.println("JAWTWindow.attachSurfaceHandle(): "+toHexString(layerHandle) + ", bounds "+bounds); + System.err.println("JAWTWindow.attachSurfaceHandle: "+toHexString(layerHandle) + ", bounds "+bounds); } attachSurfaceLayerImpl(layerHandle); offscreenSurfaceLayer = layerHandle; @@ -215,6 +215,17 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } protected abstract void attachSurfaceLayerImpl(final long layerHandle); + @Override + public void layoutSurfaceLayer() throws NativeWindowException { + if( !isOffscreenLayerSurfaceEnabled() ) { + throw new NativeWindowException("Not an offscreen layer surface"); + } + if( 0 != offscreenSurfaceLayer) { + layoutSurfaceLayerImpl(); + } + } + protected void layoutSurfaceLayerImpl() {} + @Override public final void detachSurfaceLayer() throws NativeWindowException { if( !isOffscreenLayerSurfaceEnabled() ) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index ba60a7f38..4885d5a4c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -46,6 +46,21 @@ public interface OffscreenLayerSurface { */ public void attachSurfaceLayer(final long layerHandle) throws NativeWindowException; + /** + * Layout the offscreen layer according to the implementing class's constraints. + *

    + * This method allows triggering a re-layout of the offscreen surface + * in case the implementation requires it. + *

    + *

    + * Call this method if any parent or ancestor's layout has been changed, + * which could affects the layout of this surface. + *

    + * @see #isOffscreenLayerSurfaceEnabled() + * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false + */ + public void layoutSurfaceLayer() throws NativeWindowException; + /** * Detaches a previously attached offscreen layer from this offscreen layer surface. * @see #attachSurfaceLayer(long) diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 9b06cce1a..b25836d3c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -118,10 +118,20 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.AddCASublayer(rootSurfaceLayerHandle, layerHandle); } + protected void layoutSurfaceLayerImpl() { + final long osl = getAttachedSurfaceLayer(); + final int w = getWidth(); + final int h = getHeight(); + if(DEBUG) { + System.err.println("JAWTWindow.fixSurfaceLayerLayout: "+toHexString(osl) + ", bounds "+bounds+", "+w+"x"+h); + } + OSXUtil.FixCALayerPosition(rootSurfaceLayerHandle, osl, w, h); + } + protected void detachSurfaceLayerImpl(final long layerHandle) { OSXUtil.RemoveCASublayer(rootSurfaceLayerHandle, layerHandle); } - + @Override public final long getWindowHandle() { return windowHandle; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index d85d1a84b..5ff451cc0 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -149,7 +149,7 @@ public class OSXUtil implements ToolkitProperties { } /** - * Attach a sub CALayer to the root CALayer on the main-thread. + * Attach a sub CALayer to the root CALayer on the main-thread w/ blocking. *

    * Method will trigger a display * call to the CALayer hierarchy to enforce resource creation if required, e.g. an NSOpenGLContext. @@ -173,7 +173,30 @@ public class OSXUtil implements ToolkitProperties { } /** - * Detach a sub CALayer from the root CALayer on the main-thread. + * Fix root and sub CALayer position to 0/0 on the main-thread w/o blocking. + *

    + * For an unknown reason, on OSX/Java7 our root CALayer's frame position gets corrupted + * and is moved out of 'sight' .. or oddly half way to the upper right corner. + *

    + * + * @param rootCALayer the root surface layer, maybe null. + * @param subCALayer the client surface layer, maybe null. + * @param width the expected width + * @param height the expected height + */ + public static void FixCALayerPosition(final long rootCALayer, final long subCALayer, final int width, final int height) { + if( 0==rootCALayer && 0==subCALayer ) { + return; + } + RunOnMainThread(false, new Runnable() { + public void run() { + FixCALayerPosition0(rootCALayer, subCALayer, width, height); + } + }); + } + + /** + * Detach a sub CALayer from the root CALayer on the main-thread w/ blocking. */ public static void RemoveCASublayer(final long rootCALayer, final long subCALayer) { if(0==rootCALayer || 0==subCALayer) { @@ -186,7 +209,7 @@ public class OSXUtil implements ToolkitProperties { } /** - * Destroy a CALayer on the main-thread. + * Destroy a CALayer on the main-thread w/ blocking. * @see #CreateCALayer(int, int, int, int) */ public static void DestroyCALayer(final long caLayer) { @@ -323,6 +346,7 @@ public class OSXUtil implements ToolkitProperties { private static native long GetNSWindow0(long nsView); private static native long CreateCALayer0(int x, int y, int width, int height); private static native void AddCASublayer0(long rootCALayer, long subCALayer); + private static native void FixCALayerPosition0(long rootCALayer, long subCALayer, int width, int height); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); private static native void RunOnMainThread0(Runnable runnable); diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 4c07b4df7..28e63e875 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -429,11 +429,13 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer); + [subLayer retain]; // Pairs w/ RemoveCASublayer + [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; CGRect lRectRoot = [rootLayer frame]; - DBG_PRINT("CALayer::AddCASublayer0.0: Origin %p frame0: %lf/%lf %lfx%lf\n", + DBG_PRINT("CALayer::AddCASublayer0.0: Origin %p frame0: %lf/%lf %lfx%lf\n", rootLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height); if(lRectRoot.origin.x!=0 || lRectRoot.origin.y!=0) { lRectRoot.origin.x = 0; @@ -474,6 +476,57 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); } +/* + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: FixCALayerPosition0 + * Signature: (JJII)V + */ +JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerPosition0 + (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint width, jint height) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); + CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer); + + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + + if( NULL != rootLayer ) { + CGRect lRect = [rootLayer frame]; + DBG_PRINT("CALayer::FixCALayerPosition0.0: Root Origin %p exp 0/0 %dx%d frame0: %lf/%lf %lfx%lf\n", + rootLayer, width, height, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + if(lRect.origin.x!=0 || lRect.origin.y!=0 || lRect.size.width!=width || lRect.size.height!=height) { + lRect.origin.x = 0; + lRect.origin.y = 0; + lRect.size.width = width; + lRect.size.height = height; + [rootLayer setFrame: lRect]; + DBG_PRINT("CALayer::FixCALayerPosition0.1: Root Origin %p frame*: %lf/%lf %lfx%lf\n", + rootLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + } + } + if( NULL != subLayer ) { + CGRect lRect = [subLayer frame]; + DBG_PRINT("CALayer::FixCALayerPosition0.0: SubL %p exp 0/0 %dx%d frame0: %lf/%lf %lfx%lf\n", + subLayer, width, height, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + if(lRect.origin.x!=0 || lRect.origin.y!=0 || lRect.size.width!=width || lRect.size.height!=height) { + lRect.origin.x = 0; + lRect.origin.y = 0; + lRect.size.width = width; + lRect.size.height = height; + [subLayer setFrame: lRect]; + DBG_PRINT("CALayer::FixCALayerPosition0.1: SubL Origin %p frame*: %lf/%lf %lfx%lf\n", + subLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + } + } + + [CATransaction commit]; + + [pool release]; + DBG_PRINT("CALayer::FixCALayerPosition0.X: root %p (refcnt %d) .sub %p (refcnt %d)\n", + rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); +} + /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: RemoveCASublayer0 @@ -495,7 +548,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RemoveCASublayer0 [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; [subLayer removeFromSuperlayer]; - // [subLayer release] is called explicitly, e.g. via CGL.releaseNSOpenGLLayer(..) (MyNSOpenGLLayer::releaseLayer) + [subLayer release]; // Pairs w/ AddCASublayer [CATransaction commit]; diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 195f8af8c..524917780 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -391,6 +391,18 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto reparentWindow(true, cont); } + @SuppressWarnings("deprecation") + @Override + public void reshape(int x, int y, int width, int height) { + super.reshape(x, y, width, height); + if(DEBUG) { + System.err.println("NewtCanvasAWT.reshape: "+x+"/"+y+" "+width+"x"+height); + } + if(null != jawtWindow && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { + jawtWindow.layoutSurfaceLayer(); + } + } + @Override public void removeNotify() { java.awt.Container cont = AWTMisc.getContainer(this); @@ -459,7 +471,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto // force this AWT Canvas to be focus-able, // since this it is completely covered by the newtChild (z-order). - setFocusable(true); + setFocusable(true); } else { configureNewtChild(false); newtChild.setVisible(false); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 08c7a14c2..f47ca327d 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -227,7 +227,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } // else offscreen size is realized via recreation // no native event (fullscreen, some reparenting) positionChanged(true, x, y); - sizeChanged(true, width, height, false); // incl. validation (incl. repositioning) + sizeChanged(true, width, height, false); } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) { if( !isOffscreenInstance ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java index 8d1ad57b4..447c6b94c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java @@ -77,13 +77,12 @@ public class TestGearsES2AWT extends UITestCase { static int swapInterval = 1; static boolean exclusiveContext = false; static Thread awtEDT; - static Dimension rwsize; + static Dimension rwsize = null; @BeforeClass public static void initClass() { width = 640; height = 480; - rwsize = null; try { EventQueue.invokeAndWait(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 52ce425a8..47891a8df 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -71,7 +71,7 @@ import org.junit.Test; public class TestGearsES2NEWT extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; - static DimensionImmutable wsize, rwsize; + static DimensionImmutable wsize, rwsize=null; static long duration = 500; // ms static boolean opaque = true; @@ -96,7 +96,6 @@ public class TestGearsES2NEWT extends UITestCase { public static void initClass() { if(null == wsize) { wsize = new Dimension(640, 480); - rwsize = null; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java index 035ed624a..f98cb240b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -78,7 +78,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; - static DimensionImmutable wsize, rwsize; + static DimensionImmutable wsize, rwsize = null; static long duration = 500; // ms static boolean opaque = true; @@ -99,7 +99,6 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { public static void initClass() { if(null == wsize) { wsize = new Dimension(640, 480); - rwsize = null; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java index 112a1282d..cb2cf064f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java @@ -73,7 +73,7 @@ import org.junit.Test; public class TestGearsES2NewtCanvasSWT extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; - static DimensionImmutable wsize, rwsize; + static DimensionImmutable wsize, rwsize = null; static long duration = 500; // ms static boolean opaque = true; @@ -93,7 +93,6 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase { public static void initClass() { if(null == wsize) { wsize = new Dimension(640, 480); - rwsize = new Dimension(-1, -1); } } @@ -219,7 +218,7 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase { System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); - if( 0 < rwsize.getWidth() && 0 < rwsize.getHeight() ) { + if( null != rwsize ) { for(int i=0; i<50; i++) { // 500 ms dispatched delay if( !display.readAndDispatch() ) { // blocks on linux .. display.sleep(); @@ -349,7 +348,9 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase { } } wsize = new Dimension(w, h); - rwsize = new Dimension(rw, rh); + if( 0 < rw && 0 < rh ) { + rwsize = new Dimension(rw, rh); + } if(usePos) { wpos = new Point(x, y); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java index 45bd3bb39..08e4ac26a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java @@ -65,7 +65,7 @@ import org.junit.Test; public class TestGearsES2SWT extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; - static DimensionImmutable wsize, rwsize; + static DimensionImmutable wsize, rwsize=null; static long duration = 500; // ms static boolean opaque = true; @@ -85,7 +85,6 @@ public class TestGearsES2SWT extends UITestCase { public static void initClass() { if(null == wsize) { wsize = new Dimension(640, 480); - rwsize = null; } } -- cgit v1.2.3 From af384debfdf354d98e3d0d0c6e0c5cf5a967904e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 22 Feb 2013 04:09:03 +0100 Subject: NEWT/OSX Fix: Child positioning ; NewtCanvasAWT: Change reparent time and use actual component size while setting min/pref. size at setup - NEWT/OSX Fix: Child positioning - If !Offscreen and has-parent: Gather screen location by traversing through parent and set native position (was removed w/ commit 7d5c51b635e0795d9b170342bdebe8e7e0bbd01d since still buggy). - NewtCanvasAWT: Change reparent time and use actual component size while setting min/pref. size at setup - Analog to AWT GLCanvas - validates and reparents at reshape(..), paint(..) and update(..) - reshape(..) also trigers jawtWindow.layoutSurfaceLayer() - --- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 388 ++++++++++++--------- src/newt/classes/jogamp/newt/WindowImpl.java | 62 +++- .../newt/awt/event/AWTParentWindowAdapter.java | 2 +- .../jogamp/newt/driver/macosx/WindowDriver.java | 59 ++-- .../awt/TestBug664GLCanvasSetVisibleSwingAWT.java | 1 + .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 6 +- .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 11 +- .../test/junit/newt/TestFocus01SwingAWTRobot.java | 5 +- .../TestParentingFocusTraversal01AWT.java | 1 + 9 files changed, 325 insertions(+), 210 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 524917780..3503dabd5 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -34,6 +34,7 @@ import java.awt.Canvas; import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.KeyboardFocusManager; +import java.beans.Beans; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.lang.reflect.Method; @@ -84,6 +85,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private JAWTWindow jawtWindow = null; private boolean shallUseOffscreenLayer = false; private Window newtChild = null; + private boolean newtChildAttached = false; private boolean isOnscreen = true; private WindowClosingMode newtChildCloseOp; private AWTAdapter awtAdapter = null; @@ -180,6 +182,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private FocusAction focusAction = new FocusAction(); WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() { + @Override + public void windowResized(WindowEvent e) { + updateLayoutSize(); + } @Override public void windowGainedFocus(WindowEvent arg0) { if( isParent() && !isFullscreen() ) { @@ -292,16 +298,26 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final java.awt.Container cont = AWTMisc.getContainer(this); // remove old one if(null != newtChild) { - reparentWindow( false, cont ); + detachNewtChild( cont ); newtChild = null; } // add new one, reparent only if ready newtChild = newChild; - if( isDisplayable() && null != newChild) { - reparentWindow( true, cont ); - } + + updateLayoutSize(); + // will be done later at paint/display/..: attachNewtChild(cont); + return prevChild; } + + private final void updateLayoutSize() { + if( null != newtChild ) { + // use NEWT child's size for min/pref size! + java.awt.Dimension minSize = new java.awt.Dimension(newtChild.getWidth(), newtChild.getHeight()); + setMinimumSize(minSize); + setPreferredSize(minSize); + } + } /** @return the current NEWT child */ public Window getNEWTChild() { @@ -320,166 +336,54 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto return awtWindowClosingProtocol.setDefaultCloseOperation(op); } - /* package */ void configureNewtChild(boolean attach) { - if(null!=awtAdapter) { - awtAdapter.removeFrom(this); - awtAdapter=null; - } - if(null!=awtMouseAdapter) { - awtMouseAdapter.removeFrom(this); - awtMouseAdapter = null; - } - if(null!=awtKeyAdapter) { - awtKeyAdapter.removeFrom(this); - awtKeyAdapter = null; - } - if(null != keyboardFocusManager) { - keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener); - keyboardFocusManager = null; - } - - if( null != newtChild ) { - newtChild.setKeyboardFocusHandler(null); - if(attach) { - if(null == jawtWindow.getGraphicsConfiguration()) { - throw new InternalError("XXX"); - } - isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); - awtAdapter = new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this); - newtChild.addWindowListener(clearAWTMenusOnNewtFocus); - newtChild.setFocusAction(focusAction); // enable AWT focus traversal - newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); - awtWindowClosingProtocol.addClosingListenerOneShot(); - keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - keyboardFocusManager.addPropertyChangeListener("focusOwner", focusPropertyChangeListener); - if(isOnscreen) { - // onscreen newt child needs to fwd AWT focus - newtChild.setKeyboardFocusHandler(newtFocusTraversalKeyListener); - } else { - // offscreen newt child requires AWT to fwd AWT key/mouse event - awtMouseAdapter = new AWTMouseAdapter(newtChild).addTo(this); - awtKeyAdapter = new AWTKeyAdapter(newtChild).addTo(this); - } - } else { - newtChild.removeWindowListener(clearAWTMenusOnNewtFocus); - newtChild.setFocusAction(null); - newtChild.setDefaultCloseOperation(newtChildCloseOp); - awtWindowClosingProtocol.removeClosingListener(); - } - } - } - @Override public void addNotify() { - - // before native peer is valid: X11 - disableBackgroundErase(); - - // creates the native peer - super.addNotify(); - - // after native peer is valid: Windows - disableBackgroundErase(); - - java.awt.Container cont = AWTMisc.getContainer(this); - if(DEBUG) { - // if ( isShowing() == false ) -> Container was not visible yet. - // if ( isShowing() == true ) -> Container is already visible. - System.err.println("NewtCanvasAWT.addNotify: "+newtChild+", "+this+", visible "+isVisible()+", showing "+isShowing()+ - ", displayable "+isDisplayable()+" -> "+cont); + if( Beans.isDesignTime() ) { + super.addNotify(); + } else { + // before native peer is valid: X11 + disableBackgroundErase(); + + // creates the native peer + super.addNotify(); + + // after native peer is valid: Windows + disableBackgroundErase(); + + jawtWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities()); + jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); + + if(DEBUG) { + // if ( isShowing() == false ) -> Container was not visible yet. + // if ( isShowing() == true ) -> Container is already visible. + System.err.println("NewtCanvasAWT.addNotify: win "+newtWinHandleToHexString(newtChild)+ + ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+ + ", displayable "+isDisplayable()+", cont "+AWTMisc.getContainer(this)); + } } - reparentWindow(true, cont); } - @SuppressWarnings("deprecation") - @Override - public void reshape(int x, int y, int width, int height) { - super.reshape(x, y, width, height); - if(DEBUG) { - System.err.println("NewtCanvasAWT.reshape: "+x+"/"+y+" "+width+"x"+height); - } - if(null != jawtWindow && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { - jawtWindow.layoutSurfaceLayer(); - } - } - @Override public void removeNotify() { - java.awt.Container cont = AWTMisc.getContainer(this); - if(DEBUG) { - System.err.println("NewtCanvasAWT.removeNotify: "+newtChild+", from "+cont); - } - // Detach OLS early.. - final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); - if(null != ols && ols.isSurfaceLayerAttached()) { - ols.detachSurfaceLayer(); - } - reparentWindow(false, cont); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached) - - if(null != jawtWindow) { + if( Beans.isDesignTime() ) { + super.removeNotify(); + } else { + java.awt.Container cont = AWTMisc.getContainer(this); + if(DEBUG) { + System.err.println("NewtCanvasAWT.removeNotify: "+newtChild+", from "+cont); + } + // Detach OLS early.. + final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); + if(null != ols && ols.isSurfaceLayerAttached()) { + ols.detachSurfaceLayer(); + } + detachNewtChild(cont); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached) + NewtFactoryAWT.destroyNativeWindow(jawtWindow); jawtWindow=null; + + super.removeNotify(); } - - super.removeNotify(); - } - - void reparentWindow(boolean add, java.awt.Container cont) { - if(null==newtChild) { - return; // nop - } - if(DEBUG) { - System.err.println("NewtCanvasAWT.reparentWindow.0: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); - } - - newtChild.setFocusAction(null); // no AWT focus traversal .. - if(add) { - if(DEBUG) { - System.err.println("NewtCanvasAWT.reparentWindow: newtChild: "+newtChild); - } - if(null == jawtWindow) { - jawtWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities()); - jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); - } - final int w; - final int h; - if(isPreferredSizeSet()) { - // 1st: Component's PreferedSize - java.awt.Dimension d = getPreferredSize(); - w = d.width; - h = d.height; - } else { - final java.awt.Dimension min1, min2; - // 2nd: Component's Max( Max( comp.min, newt.size ), cont.size ) - if(this.isMinimumSizeSet()) { - min1 = getMinimumSize(); - } else { - min1 = new java.awt.Dimension(0, 0); - } - min2 = new java.awt.Dimension( Math.max( min1.width, newtChild.getWidth() ), - Math.max( min1.height, newtChild.getHeight() ) ); - java.awt.Insets ins = cont.getInsets(); - w = Math.max(min2.width, cont.getWidth() - ins.left - ins.right); - h = Math.max(min2.height, cont.getHeight() - ins.top - ins.bottom); - } - setSize(w, h); - newtChild.setSize(w, h); - newtChild.reparentWindow(jawtWindow); - newtChild.setVisible(true); - configureNewtChild(true); - newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener - - // force this AWT Canvas to be focus-able, - // since this it is completely covered by the newtChild (z-order). - setFocusable(true); - } else { - configureNewtChild(false); - newtChild.setVisible(false); - newtChild.reparentWindow(null); - } - if(DEBUG) { - System.err.println("NewtCanvasAWT.reparentWindow.X: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); - } } /** @@ -489,46 +393,56 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto *
  • Disconnects the NEWT Child from this Canvas NativeWindow, reparent to NULL
  • *
  • Issues destroy() on the NEWT Child
  • *
  • Remove reference to the NEWT Child
  • - *
  • Remove this Canvas from it's parent.
  • * * @see Window#destroy() */ public final void destroy() { - if(null!=newtChild) { + if( null !=newtChild ) { java.awt.Container cont = AWTMisc.getContainer(this); if(DEBUG) { System.err.println("NewtCanvasAWT.destroy(): "+newtChild+", from "+cont); } - configureNewtChild(false); - if(null!=jawtWindow) { - NewtFactoryAWT.destroyNativeWindow(jawtWindow); - jawtWindow=null; - } - newtChild.setVisible(false); - newtChild.reparentWindow(null); + // Detach OLS early.. + final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); + if(null != ols && ols.isSurfaceLayerAttached()) { + ols.detachSurfaceLayer(); + } + detachNewtChild(cont); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached) newtChild.destroy(); newtChild=null; - if(null!=cont) { - cont.remove(this); - } } - } - + } + @Override public void paint(Graphics g) { - awtWindowClosingProtocol.addClosingListenerOneShot(); - if(null!=newtChild) { + if( validateComponent(true, null) ) { newtChild.windowRepaint(0, 0, getWidth(), getHeight()); } } @Override public void update(Graphics g) { - awtWindowClosingProtocol.addClosingListenerOneShot(); - if(null!=newtChild) { + if( validateComponent(true, null) ) { newtChild.windowRepaint(0, 0, getWidth(), getHeight()); } } + @SuppressWarnings("deprecation") + @Override + public void reshape(int x, int y, int width, int height) { + synchronized (getTreeLock()) { // super.reshape(..) claims tree lock, so we do extend it's lock over reshape + super.reshape(x, y, width, height); + if(DEBUG) { + System.err.println("NewtCanvasAWT.reshape: "+x+"/"+y+" "+width+"x"+height); + } + if( validateComponent(true, null) ) { + // newtChild.setSize(width, height); + if(null != jawtWindow && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { + jawtWindow.layoutSurfaceLayer(); + } + } + } + } + private final void requestFocusNEWTChild() { if(null!=newtChild) { newtChild.setFocusAction(null); @@ -573,6 +487,136 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto return res; } + private final boolean validateComponent(boolean attachNewtChild, java.awt.Container cont) { + if( Beans.isDesignTime() || !isDisplayable() ) { + return false; + } + if ( null == newtChild || null == jawtWindow ) { + return false; + } + if( null == cont ) { + cont = AWTMisc.getContainer(this); + } + if( 0 >= getWidth() || 0 >= getHeight() ) { + return false; + } + + awtWindowClosingProtocol.addClosingListenerOneShot(); + + if( attachNewtChild && !newtChildAttached && null != newtChild ) { + attachNewtChild(cont); + } + + return true; + } + + private final void configureNewtChild(boolean attach) { + if(null!=awtAdapter) { + awtAdapter.removeFrom(this); + awtAdapter=null; + } + if(null!=awtMouseAdapter) { + awtMouseAdapter.removeFrom(this); + awtMouseAdapter = null; + } + if(null!=awtKeyAdapter) { + awtKeyAdapter.removeFrom(this); + awtKeyAdapter = null; + } + if(null != keyboardFocusManager) { + keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener); + keyboardFocusManager = null; + } + + if( null != newtChild ) { + newtChild.setKeyboardFocusHandler(null); + if(attach) { + if(null == jawtWindow.getGraphicsConfiguration()) { + throw new InternalError("XXX"); + } + isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); + awtAdapter = new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this); + newtChild.addWindowListener(clearAWTMenusOnNewtFocus); + newtChild.setFocusAction(focusAction); // enable AWT focus traversal + newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); + awtWindowClosingProtocol.addClosingListenerOneShot(); + keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); + keyboardFocusManager.addPropertyChangeListener("focusOwner", focusPropertyChangeListener); + if(isOnscreen) { + // onscreen newt child needs to fwd AWT focus + newtChild.setKeyboardFocusHandler(newtFocusTraversalKeyListener); + } else { + // offscreen newt child requires AWT to fwd AWT key/mouse event + awtMouseAdapter = new AWTMouseAdapter(newtChild).addTo(this); + awtKeyAdapter = new AWTKeyAdapter(newtChild).addTo(this); + } + } else { + newtChild.removeWindowListener(clearAWTMenusOnNewtFocus); + newtChild.setFocusAction(null); + newtChild.setDefaultCloseOperation(newtChildCloseOp); + awtWindowClosingProtocol.removeClosingListener(); + } + } + } + + private final void attachNewtChild(java.awt.Container cont) { + if( null == newtChild || null == jawtWindow || newtChildAttached ) { + return; // nop + } + if(DEBUG) { + // if ( isShowing() == false ) -> Container was not visible yet. + // if ( isShowing() == true ) -> Container is already visible. + System.err.println("NewtCanvasAWT.attachNewtChild.0: win "+newtWinHandleToHexString(newtChild)+ + ", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+ + ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+", displayable "+isDisplayable()+ + ", cont "+cont); + } + + newtChildAttached = true; + newtChild.setFocusAction(null); // no AWT focus traversal .. + if(DEBUG) { + System.err.println("NewtCanvasAWT.attachNewtChild.1: newtChild: "+newtChild); + } + final int w = getWidth(); + final int h = getHeight(); + System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h); + newtChild.setSize(w, h); + newtChild.reparentWindow(jawtWindow); + newtChild.setVisible(true); + configureNewtChild(true); + newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener + + // force this AWT Canvas to be focus-able, + // since this it is completely covered by the newtChild (z-order). + setFocusable(true); + if(DEBUG) { + System.err.println("NewtCanvasAWT.attachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); + } + } + + private final void detachNewtChild(java.awt.Container cont) { + if( null == newtChild || null == jawtWindow || !newtChildAttached ) { + return; // nop + } + if(DEBUG) { + // if ( isShowing() == false ) -> Container was not visible yet. + // if ( isShowing() == true ) -> Container is already visible. + System.err.println("NewtCanvasAWT.detachNewtChild.0: win "+newtWinHandleToHexString(newtChild)+ + ", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+ + ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+", displayable "+isDisplayable()+ + ", cont "+cont); + } + + newtChildAttached = false; + newtChild.setFocusAction(null); // no AWT focus traversal .. + configureNewtChild(false); + newtChild.setVisible(false); + newtChild.reparentWindow(null); + if(DEBUG) { + System.err.println("NewtCanvasAWT.detachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); + } + } + // Disables the AWT's erasing of this Canvas's background on Windows // in Java SE 6. This internal API is not available in previous // releases, but the system property diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 73c0d2754..222a1173c 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -527,9 +527,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected void setTitleImpl(String title) {} /** - * Return screen coordinates of the given coordinates - * or null, in which case a NativeWindow traversal shall being used + * Translates the given window client-area coordinates with top-left origin + * to screen coordinates. + *

    + * Since the position reflects the client area, it does not include the insets. + *

    + *

    + * May return null, in which case the caller shall traverse through the NativeWindow tree * as demonstrated in {@link #getLocationOnScreen(javax.media.nativewindow.util.Point)}. + *

    * * @return if not null, the screen location of the given coordinates */ @@ -644,14 +650,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // public final void destroy() - see below + @Override public final NativeWindow getParent() { return parentWindow; } + @Override public final long getWindowHandle() { return windowHandle; } + @Override public Point getLocationOnScreen(Point storage) { if(isNativeValid()) { Point d; @@ -688,14 +697,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Window // + @Override public final boolean isNativeValid() { return 0 != windowHandle ; } + @Override public final Screen getScreen() { return screen; } - + protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) { reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible)); } @@ -778,7 +789,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } runOnEDTIfAvail(wait, new VisibleAction(visible)); } - + + @Override public void setVisible(boolean visible) { setVisible(true, visible); } @@ -830,9 +842,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + @Override public void setSize(int width, int height) { runOnEDTIfAvail(true, new SetSizeAction(width, height)); } + @Override public void setTopLevelSize(int width, int height) { setSize(width - getInsets().getTotalWidth(), height - getInsets().getTotalHeight()); } @@ -932,6 +946,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private final DestroyAction destroyAction = new DestroyAction(); + @Override public void destroy() { visible = false; // Immediately mark synchronized visibility flag, avoiding possible recreation runOnEDTIfAvail(true, destroyAction); @@ -1253,6 +1268,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private final ReparentActionRecreate reparentActionRecreate = new ReparentActionRecreate(); + @Override public final ReparentOperation reparentWindow(NativeWindow newParent) { return reparentWindow(newParent, false); } @@ -1263,16 +1279,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return reparentAction.getOp(); } + @Override public CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser) { CapabilitiesChooser old = this.capabilitiesChooser; this.capabilitiesChooser = chooser; return old; } + @Override public final CapabilitiesImmutable getChosenCapabilities() { return getGraphicsConfiguration().getChosenCapabilities(); } + @Override public final CapabilitiesImmutable getRequestedCapabilities() { return capsRequested; } @@ -1312,10 +1331,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + @Override public void setUndecorated(boolean value) { runOnEDTIfAvail(true, new DecorationAction(value)); } + @Override public final boolean isUndecorated() { return 0 != parentWindowHandle || undecorated || fullscreen ; } @@ -1355,17 +1376,21 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + @Override public final void setAlwaysOnTop(boolean value) { runOnEDTIfAvail(true, new AlwaysOnTopAction(value)); } + @Override public final boolean isAlwaysOnTop() { return alwaysOnTop; } + @Override public String getTitle() { return title; } + @Override public void setTitle(String title) { if (title == null) { title = ""; @@ -1376,9 +1401,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + @Override public boolean isPointerVisible() { return pointerVisible; } + @Override public void setPointerVisible(boolean pointerVisible) { if(this.pointerVisible != pointerVisible) { boolean setVal = 0 == getWindowHandle(); @@ -1390,10 +1417,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } + @Override public boolean isPointerConfined() { return pointerConfined; } + @Override public void confinePointer(boolean confine) { if(this.pointerConfined != confine) { boolean setVal = 0 == getWindowHandle(); @@ -1417,12 +1446,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + @Override public void warpPointer(int x, int y) { if(0 != getWindowHandle()) { warpPointerImpl(x, y); } } + @Override public final InsetsImmutable getInsets() { if(isUndecorated()) { return Insets.getZero(); @@ -1431,18 +1462,22 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return insets; } + @Override public final int getWidth() { return width; } + @Override public final int getHeight() { return height; } + @Override public final int getX() { return x; } + @Override public final int getY() { return y; } @@ -1468,10 +1503,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer this.width = width; this.height = height; } + @Override public final boolean isVisible() { return visible; } + @Override public final boolean isFullscreen() { return fullscreen; } @@ -1480,6 +1517,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Window // + @Override + public final Window getDelegatedWindow() { + return this; + } + + //---------------------------------------------------------------------- + // WindowImpl + // + /** * If the implementation is capable of detecting a device change * return true and clear the status/reason of the change. @@ -1504,10 +1550,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return null; } - public final Window getDelegatedWindow() { - return this; - } - /** * If set to true, the default value, this NEWT Window implementation will * handle the destruction (ie {@link #destroy()} call) within {@link #windowDestroyNotify(boolean)} implementation.
    @@ -1517,10 +1559,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer handleDestroyNotify = b; } - //---------------------------------------------------------------------- - // WindowImpl - // - /** * Returns the non delegated {@link AbstractGraphicsConfiguration}, * see {@link #getGraphicsConfiguration()}. */ diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index 747e2368e..701d9d60a 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -98,7 +98,7 @@ public class AWTParentWindowAdapter public void run() { int cw = comp.getWidth(); int ch = comp.getHeight(); - if( 0 < cw * ch ) { + if( 0 < cw && 0 < ch ) { if( newtWindow.getWidth() != cw || newtWindow.getHeight() != ch ) { newtWindow.setSize(cw, ch); if(comp.isVisible() != newtWindow.isVisible()) { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index f47ca327d..6e9335f08 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -41,7 +41,6 @@ import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; @@ -167,17 +166,36 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override public void updatePosition() { - final Point pS = getLocationOnScreenImpl(0, 0); - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow: updatePosition() - isOffscreenInstance "+isOffscreenInstance+", new abs pos: pS "+pS); + final long handle = getWindowHandle(); + if( 0 != handle && !isOffscreenInstance ) { + final Point pS = getLocationOnScreenImpl(0, 0); + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow: updatePosition() -> abs child-client-pos: "+pS); + } + setWindowClientTopLeftPoint0(handle, pS.getX(), pS.getY()); + // no native event (fullscreen, some reparenting) + positionChanged(true, pS.getX(), pS.getY()); } - if( !isOffscreenInstance ) { - setWindowClientTopLeftPoint0(getWindowHandle(), pS.getX(), pS.getY()); - } // else no offscreen position - // no native event (fullscreen, some reparenting) - positionChanged(true, pS.getX(), pS.getY()); } + @Override + protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { + final long handle = getWindowHandle(); + if( 0 != handle && !isOffscreenInstance ) { + final NativeWindow parent = getParent(); + final boolean useParent = null != parent && 0 != parent.getWindowHandle() ; + if( useParent && ( getWidth() != newWidth || getHeight() != newHeight ) ) { + final Point p0S = getLocationOnScreenImpl(0, 0); + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow: sizeChanged() "+newWidth+"x"+newHeight+" -> abs child-client-pos "+p0S); + } + setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY()); + } + } + super.sizeChanged(defer, newWidth, newHeight, force); + } + + @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { final boolean _isOffscreenInstance = isOffscreenInstance(this, this.getParent()); isOffscreenInstance = 0 != sscSurfaceHandle || _isOffscreenInstance; @@ -185,7 +203,13 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( isOffscreenInstance ) { pClientLevelOnSreen = new Point(0, 0); } else { - pClientLevelOnSreen = new Point(x, y); + final NativeWindow parent = getParent(); + final boolean useParent = null != parent && 0 != parent.getWindowHandle() ; + if( useParent ) { + pClientLevelOnSreen = getLocationOnScreenImpl(x, y); + } else { + pClientLevelOnSreen = new Point(x, y); + } } if(DEBUG_IMPLEMENTATION) { @@ -200,6 +224,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl ", ioi: "+_isOffscreenInstance+ ") -> "+isOffscreenInstance+ "\n\t, "+getReconfigureFlagsAsString(null, flags)); + Thread.dumpStack(); } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) { @@ -240,11 +265,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags)); } if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow reconfig.X: clientPos "+pClientLevelOnSreen+", "+width+"x"+height+" -> clientPos "+getLocationOnScreenImpl(0, 0)+", topPos "+getTopLevelLocationOnScreen(0, 0)+", insets: "+getInsets()); + System.err.println("MacWindow reconfig.X: clientPos "+pClientLevelOnSreen+", "+width+"x"+height+" -> clientPos "+getLocationOnScreenImpl(0, 0)+", insets: "+getInsets()); } return true; } + @Override protected Point getLocationOnScreenImpl(int x, int y) { final NativeWindow parent = getParent(); final boolean useParent = null != parent && 0 != parent.getWindowHandle() ; @@ -262,15 +288,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } return p; } - - private Point getTopLevelLocationOnScreen(int x, int y) { - final InsetsImmutable _insets = getInsets(); // zero if undecorated - // client position -> top-level window position - x -= _insets.getLeftWidth() ; - y -= _insets.getTopHeight() ; - return getLocationOnScreenImpl(x, y); - } - + + @Override protected void updateInsetsImpl(Insets insets) { // nop - using event driven insetsChange(..) } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java index 52fa83b65..d59bc2230 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java @@ -183,6 +183,7 @@ public class TestBug664GLCanvasSetVisibleSwingAWT extends UITestCase { frameCount = 0; setFrameVisible(top[0], true); Assert.assertTrue("Component didn't become visible", AWTRobotUtil.waitForVisible(glc, true)); + Assert.assertTrue("Component didn't become realized", AWTRobotUtil.waitForRealized(glc, true)); anim.setUpdateFPSFrames(60, null); anim.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java index 447c6b94c..aca2b675c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java @@ -40,6 +40,7 @@ import com.jogamp.newt.event.TraceKeyAdapter; import com.jogamp.newt.event.TraceWindowAdapter; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; @@ -179,7 +180,10 @@ public class TestGearsES2AWT extends UITestCase { public void run() { frame.pack(); frame.setVisible(true); - }}); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true)); + animator.start(); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java index f98cb240b..ad2165301 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -73,7 +73,7 @@ import org.junit.AfterClass; import org.junit.Test; public class TestGearsES2NewtCanvasAWT extends UITestCase { - public enum FrameLayout { None, TextOnBottom, BorderBottom, BorderCenter, BorderCenterSurrounded, DoubleBorderCenterSurrounded }; + public enum FrameLayout { None, TextOnBottom, BorderBottom, BorderBottom2, BorderCenter, BorderCenterSurrounded, DoubleBorderCenterSurrounded }; public enum ResizeBy { GLWindow, Component, Frame }; static int screenIdx = 0; @@ -202,6 +202,11 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { frame.setLayout(new BorderLayout()); frame.add(newtCanvasAWT, BorderLayout.SOUTH); break; + case BorderBottom2: + frame.setLayout(new BorderLayout()); + frame.add(newtCanvasAWT, BorderLayout.SOUTH); + frame.add(new Button("North"), BorderLayout.NORTH); + break; case BorderCenter: frame.setLayout(new BorderLayout()); frame.add(newtCanvasAWT, BorderLayout.CENTER); @@ -287,7 +292,9 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { } frame.setVisible(true); } - }); + }); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true)); animator.setUpdateFPSFrames(60, showFPS ? System.err : null); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java index 5d6218df4..a87cbe0ac 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java @@ -115,7 +115,8 @@ public class TestFocus01SwingAWTRobot extends UITestCase { // Wrap the window in a canvas. final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - + // newtCanvasAWT.setShallUseOffscreenLayer(true); + // Monitor AWT focus and keyboard events. AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT"); newtCanvasAWT.addKeyListener(newtCanvasAWTKA); @@ -146,7 +147,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase { frame1.setVisible(true); } } ); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); AWTRobotUtil.clearAWTFocus(robot); Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, frame1)); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java index d6f1f817a..122138f6d 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java @@ -191,6 +191,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { frame1.setVisible(true); }}); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent()); AWTRobotUtil.clearAWTFocus(robot); Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, frame1)); -- cgit v1.2.3 From 808a9a27a8c1c9e0a6701a8dd81d51f8daa8129d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 28 Feb 2013 00:39:28 +0100 Subject: Fix NEWT/AWT WindowClosing Unit Tests ; Review/Cleanup NEWT WindowClosing mechanism Due to a NEWT WindowClosing event regression cause by NewtCanvasAWT changes a review of our WindowClosing event mechanism was required. Important cleanups are marked w/ '(*)' below. I would have preferred to change the 'WindowListener.windowDestroyNotify(WindowEvent)' method to pass a WindowCloseEvent object exposing more information like toolkit or programmatic destruction and passing whether a 'closing' or 'nop' action will be performed based on the WindowClosingMode. For now I postponed this idea .. since it would change the API again, but may reconsider it after merging the Android 'closing' patch. - InputEvent.consumedTag -> NEWTEvent.consumedTag - Window - (*) Promote setWindowDestroyNotifyAction(Runnable) to public, former WindowImpl.setHandleDestroyNotify(boolean). Using a Runnable action for WindowImpl.windowDestroyNotify(boolean) allows a setting defined alternative for destroy() and gets rid of [ab]using WindowListener.windowDestroyNotify(WindowEvent) for lifecycle actions. Used in: - GLWindow - GLAutoDrawableDelegate impl. - WindowImpl - Respect NEWTEvent.consumedTag for WindowEvents as well - (*) Impl. setHandleDestroyNotify(boolean) (see above) - (*) destroy() simply sends out pre- and post- destruction Window events, where windowDestroyNotify(boolean) sends out the pre-destruction event if NOP. - (*) windowDestroyNotify(boolean) is public now, allowing other impl. details to follow proper destruction using handleDestroyNotify Runnable (-> NewtCanvasAWT). - AWTWindowClosingProtocol: - addClosingListenerOneShot() -> addClosingListener() - calling addClosingListener() at addNotify() - calling removeClosingListener() at removeNotify() - AWTWindowClosingProtocol ctor taking NOP runnable, allowing to send WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY at WindowClosingMode.DO_NOTHING_ON_CLOSE - add/remove listener on AWT-EDT - AWTWindowAdapter - Add 'removeWindowClosingFrom(..)', allowing to remove window closing event fwd. - Also fwd windowClosed in window closing fwd'ing. - NewtCanvasAWT - (*) Utilize AWTWindowClosingProtocol NOP runnable (see above) to fwd closing-NOP event to NEWT - (*) Unify remove/destroy code in destroyImpl(..) - !removeNotify -> destroy NEWT child programatic or as toolkit event - removeNotify || windowClosing -> destroy jawtWindow - (*) Remove AWTWindowAdapter/AWTParentWindowAdapter's windowClosingListener, since we utilize AWTWindowClosingProtocol - DisplayImpl - Adding 'final void dispatchMessage(final NEWTEvent event)' allowing to remove the NEWTEventTask wrapping for no reason in enqueueEvent(..) if on EDT and waiting. --- make/scripts/tests.sh | 5 +- .../com/jogamp/opengl/GLAutoDrawableDelegate.java | 6 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 6 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 5 +- .../nativewindow/awt/AWTWindowClosingProtocol.java | 85 ++++++----- .../javax/media/nativewindow/NativeWindow.java | 3 +- .../media/nativewindow/WindowClosingProtocol.java | 4 + src/newt/classes/com/jogamp/newt/Window.java | 36 ++++- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 83 ++++++----- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 4 +- .../classes/com/jogamp/newt/event/InputEvent.java | 5 - .../classes/com/jogamp/newt/event/NEWTEvent.java | 6 + .../com/jogamp/newt/event/WindowListener.java | 5 +- .../com/jogamp/newt/event/awt/AWTAdapter.java | 7 +- .../jogamp/newt/event/awt/AWTWindowAdapter.java | 20 ++- .../classes/com/jogamp/newt/opengl/GLWindow.java | 14 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 26 ++-- src/newt/classes/jogamp/newt/WindowImpl.java | 72 ++++++---- .../newt/awt/event/AWTParentWindowAdapter.java | 4 +- .../jogamp/newt/driver/awt/WindowDriver.java | 5 +- .../jogl/acore/TestGLAutoDrawableDelegateNEWT.java | 160 +++++++++++++++++++++ ...estGLAutoDrawableDelegateOnOffscrnCapsNEWT.java | 11 +- .../acore/TestGLContextDrawableSwitch01NEWT.java | 9 +- .../acore/TestGLContextDrawableSwitch11NEWT.java | 9 +- .../jogl/acore/TestSharedContextNewtAWTBug523.java | 5 +- .../opengl/test/junit/newt/TestCloseNewtAWT.java | 7 +- .../junit/newt/TestWindowClosingProtocol01AWT.java | 24 ++-- .../newt/TestWindowClosingProtocol02NEWT.java | 12 +- .../newt/TestWindowClosingProtocol03NewtAWT.java | 41 ++++-- .../opengl/test/junit/util/AWTRobotUtil.java | 83 +++++++---- 30 files changed, 539 insertions(+), 223 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7a71932ca..7a43fd3da 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -266,7 +266,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* @@ -330,6 +330,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* @@ -437,7 +438,6 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT -#testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* @@ -448,6 +448,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT +#testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java index 206331ac0..0f0f03ac4 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java @@ -51,12 +51,12 @@ import jogamp.opengl.GLDrawableImpl; * utilizing already created {@link GLDrawable} and {@link GLContext} instances. *

    * Since no native windowing system events are being processed, it is recommended - * to handle at least: + * to handle at least the {@link com.jogamp.newt.event.WindowEvent window events}: *

      *
    • {@link com.jogamp.newt.event.WindowListener#windowRepaint(com.jogamp.newt.event.WindowUpdateEvent) repaint} using {@link #windowRepaintOp()}
    • *
    • {@link com.jogamp.newt.event.WindowListener#windowResized(com.jogamp.newt.event.WindowEvent) resize} using {@link #windowResizedOp()}
    • - *
    • {@link com.jogamp.newt.event.WindowListener#windowDestroyNotify(com.jogamp.newt.event.WindowEvent) destroy-notify} using {@link #windowDestroyNotifyOp()}
    • - *
    + * + * and setup a {@link com.jogamp.newt.Window#setWindowDestroyNotifyAction(Runnable) custom toolkit destruction} issuing {@link #windowDestroyNotifyOp()}. *

    *

    * See example {@link com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT TestGLAutoDrawableDelegateNEWT}. diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index dc4fe955c..94e123b3e 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -176,7 +176,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void run() { GLCanvas.this.destroyImpl( true ); } - }); + }, null); /** Creates a new GLCanvas component with a default set of OpenGL capabilities, using the default OpenGL capabilities selection @@ -460,7 +460,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( isVisible() ) { Threading.invoke(true, displayOnEDTAction, getTreeLock()); } - awtWindowClosingProtocol.addClosingListenerOneShot(); } /** @@ -568,7 +567,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // for all launch flavors (applet/javaws/..) // validateGLDrawable(); } - + awtWindowClosingProtocol.addClosingListener(); + if(DEBUG) { System.err.println(getThreadName()+": Info: addNotify - end: peer: "+getPeer()); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 2b99bb570..6c28c75ab 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -174,7 +174,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing public void run() { GLJPanel.this.destroy(); } - }); + }, null); static { // Force eager initialization of part of the Java2D class since @@ -369,6 +369,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void addNotify() { super.addNotify(); + awtWindowClosingProtocol.addClosingListener(); if (DEBUG) { System.err.println(getThreadName()+": GLJPanel.addNotify()"); } @@ -677,8 +678,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if (!isInitialized) { backend.initialize(); } - - awtWindowClosingProtocol.addClosingListenerOneShot(); } @Override diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java index d78b4ac15..e3f85b948 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java @@ -33,22 +33,31 @@ import java.awt.Window; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; + import javax.media.nativewindow.WindowClosingProtocol; +import jogamp.common.awt.AWTEDTExecutor; import jogamp.nativewindow.awt.AWTMisc; public class AWTWindowClosingProtocol implements WindowClosingProtocol { private Component comp; - private Runnable closingOperation; - private volatile boolean closingListenerSet = false; + private Runnable closingOperationClose; + private Runnable closingOperationNOP; + private boolean closingListenerSet = false; private Object closingListenerLock = new Object(); private WindowClosingMode defaultCloseOperation = WindowClosingMode.DISPOSE_ON_CLOSE; private boolean defaultCloseOperationSetByUser = false; - public AWTWindowClosingProtocol(Component comp, Runnable closingOperation) { + /** + * @param comp mandatory AWT component which AWT Window is being queried by parent traversal + * @param closingOperationClose mandatory closing operation, triggered if windowClosing and {@link WindowClosingMode#DISPOSE_ON_CLOSE} + * @param closingOperationNOP optional closing operation, triggered if windowClosing and {@link WindowClosingMode#DO_NOTHING_ON_CLOSE} + */ + public AWTWindowClosingProtocol(Component comp, Runnable closingOperationClose, Runnable closingOperationNOP) { this.comp = comp; - this.closingOperation = closingOperation; + this.closingOperationClose = closingOperationClose; + this.closingOperationNOP = closingOperationNOP; } class WindowClosingAdapter extends WindowAdapter { @@ -59,54 +68,56 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol { if( WindowClosingMode.DISPOSE_ON_CLOSE == op ) { // we have to issue this call right away, // otherwise the window gets destroyed - closingOperation.run(); + closingOperationClose.run(); + } else if( null != closingOperationNOP ){ + closingOperationNOP.run(); } } } WindowListener windowClosingAdapter = new WindowClosingAdapter(); - final boolean addClosingListenerImpl() { - Window w = AWTMisc.getWindow(comp); - if(null!=w) { - w.addWindowListener(windowClosingAdapter); - return true; - } - return false; - } - /** - * Adds this closing listener to the components Window if exist and only one time.
    - * Hence you may call this method every time to ensure it has been set, - * ie in case the Window parent is not available yet. + * Adds this closing listener to the components Window if exist and only one time. + *

    + * If the closing listener is already added, and {@link IllegalStateException} is thrown. + *

    * - * @return + * @return true if added, otherwise false. + * @throws IllegalStateException */ - public final boolean addClosingListenerOneShot() { - if(!closingListenerSet) { // volatile: ok + public final boolean addClosingListener() throws IllegalStateException { synchronized(closingListenerLock) { - if(!closingListenerSet) { - closingListenerSet=addClosingListenerImpl(); - return closingListenerSet; - } + if(closingListenerSet) { + throw new IllegalStateException("WindowClosingListener already set"); + } + final Window w = AWTMisc.getWindow(comp); + if(null!=w) { + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + w.addWindowListener(windowClosingAdapter); + } } ); + closingListenerSet = true; + return true; + } } - } - return false; + return false; } public final boolean removeClosingListener() { - if(closingListenerSet) { // volatile: ok synchronized(closingListenerLock) { - if(closingListenerSet) { - Window w = AWTMisc.getWindow(comp); - if(null!=w) { - w.removeWindowListener(windowClosingAdapter); - closingListenerSet = false; - return true; - } - } + if(closingListenerSet) { + final Window w = AWTMisc.getWindow(comp); + if(null!=w) { + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + w.removeWindowListener(windowClosingAdapter); + } } ); + closingListenerSet = false; + return true; + } + } } - } - return false; + return false; } /** diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java index 12e202975..a740ebbe0 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java @@ -54,8 +54,7 @@ import javax.media.nativewindow.util.Point; public interface NativeWindow extends NativeSurface { /** - * destroys the window and releases - * windowing related resources. + * Destroys this window incl. releasing all related resources. */ public void destroy(); diff --git a/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java b/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java index 884c916e4..02f68f442 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java +++ b/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java @@ -37,6 +37,10 @@ package javax.media.nativewindow; * this protocol default behavior {@link WindowClosingMode#DISPOSE_ON_CLOSE DISPOSE_ON_CLOSE} shall be used.

    */ public interface WindowClosingProtocol { + + /** + * Window closing mode if triggered by toolkit close operation. + */ public enum WindowClosingMode { /** * Do nothing on native window close operation.
    diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index cc42465f1..ab1eef308 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -28,12 +28,15 @@ package com.jogamp.newt; +import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.MouseListener; import jogamp.newt.Debug; +import jogamp.newt.WindowImpl; + import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindow; @@ -104,20 +107,42 @@ public interface Window extends NativeWindow, WindowClosingProtocol { CapabilitiesImmutable getChosenCapabilities(); /** - * Destroy the Window and it's children, incl. native destruction.
    - * The Window can be recreate via {@link #setVisible(boolean) setVisible(true)}. - *

    Visibility is set to false.

    + * {@inheritDoc} + *

    + * Also iterates through this window's children and destroys them. + *

    + *

    + * Visibility is set to false. + *

    + *

    + * Method sends out {@link WindowEvent#EVENT_WINDOW_DESTROY_NOTIFY pre-} and + * {@link WindowEvent#EVENT_WINDOW_DESTROYED post-} destruction events + * to all of it's {@link WindowListener}. + *

    *

    * This method invokes {@link Screen#removeReference()} after it's own destruction,
    * which will issue {@link Screen#destroy()} if the reference count becomes 0.
    * This destruction sequence shall end up in {@link Display#destroy()}, if all reference counts become 0. *

    + *

    + * The Window can be recreate via {@link #setVisible(boolean) setVisible(true)}. + *

    * @see #destroy() * @see #setVisible(boolean) */ @Override void destroy(); + /** + * Set a custom action handling destruction issued by a {@link WindowImpl#windowDestroyNotify(boolean) toolkit triggered window destroy} + * replacing the default {@link #destroy()} action. + *

    + * The custom action shall call {@link #destroy()} + * but may perform further tasks before and after. + *

    + */ + void setWindowDestroyNotifyAction(Runnable r); + /** * setVisible makes the window and children visible if visible is true, * otherwise the window and children becomes invisible. @@ -383,10 +408,13 @@ public interface Window extends NativeWindow, WindowClosingProtocol { // WindowListener // + /** + * Send a {@link WindowEvent} to all {@link WindowListener}. + * @param eventType a {@link WindowEvent} type, e.g. {@link WindowEvent#EVENT_WINDOW_REPAINT}. + */ public void sendWindowEvent(int eventType); /** - * * Appends the given {@link com.jogamp.newt.event.WindowListener} to the end of * the list. */ diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 3503dabd5..3c10859bf 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -51,6 +51,7 @@ import javax.swing.MenuSelectionManager; import jogamp.nativewindow.awt.AWTMisc; import jogamp.newt.Debug; +import jogamp.newt.WindowImpl; import jogamp.newt.awt.NewtFactoryAWT; import jogamp.newt.awt.event.AWTParentWindowAdapter; import jogamp.newt.driver.DriverClearFocus; @@ -59,9 +60,9 @@ import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.newt.Display; import com.jogamp.newt.Window; -import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; +import com.jogamp.newt.event.NEWTEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; @@ -88,16 +89,22 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private boolean newtChildAttached = false; private boolean isOnscreen = true; private WindowClosingMode newtChildCloseOp; - private AWTAdapter awtAdapter = null; + private AWTParentWindowAdapter awtAdapter = null; private AWTAdapter awtMouseAdapter = null; private AWTAdapter awtKeyAdapter = null; private AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { public void run() { - NewtCanvasAWT.this.destroy(); + NewtCanvasAWT.this.destroyImpl(false /* removeNotify */, true /* windowClosing */); } - }); + }, new Runnable() { + public void run() { + if( newtChild != null ) { + newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); + } + } + } ); /** * Instantiates a NewtCanvas without a NEWT child.
    @@ -209,7 +216,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } public void keyTyped(KeyEvent e) { if(suppress) { - e.setAttachment(InputEvent.consumedTag); + e.setAttachment(NEWTEvent.consumedTag); suppress = false; // reset } } @@ -239,7 +246,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } if(suppress) { - evt.setAttachment(InputEvent.consumedTag); + evt.setAttachment(NEWTEvent.consumedTag); } if(DEBUG) { System.err.println("NewtCanvasAWT.focusKey: XXX: "+ks); @@ -361,27 +368,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto ", displayable "+isDisplayable()+", cont "+AWTMisc.getContainer(this)); } } + awtWindowClosingProtocol.addClosingListener(); } @Override public void removeNotify() { + awtWindowClosingProtocol.removeClosingListener(); + if( Beans.isDesignTime() ) { super.removeNotify(); } else { - java.awt.Container cont = AWTMisc.getContainer(this); - if(DEBUG) { - System.err.println("NewtCanvasAWT.removeNotify: "+newtChild+", from "+cont); - } - // Detach OLS early.. - final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); - if(null != ols && ols.isSurfaceLayerAttached()) { - ols.detachSurfaceLayer(); - } - detachNewtChild(cont); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached) - - NewtFactoryAWT.destroyNativeWindow(jawtWindow); - jawtWindow=null; - + destroyImpl(true /* removeNotify */, false /* windowClosing */); super.removeNotify(); } } @@ -397,20 +394,32 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto * @see Window#destroy() */ public final void destroy() { + destroyImpl(false /* removeNotify */, false /* windowClosing */); + } + + private final void destroyImpl(boolean removeNotify, boolean windowClosing) { if( null !=newtChild ) { java.awt.Container cont = AWTMisc.getContainer(this); if(DEBUG) { - System.err.println("NewtCanvasAWT.destroy(): "+newtChild+", from "+cont); + System.err.println("NewtCanvasAWT.destroy(removeNotify "+removeNotify+", windowClosing "+windowClosing+"): nw "+newtWinHandleToHexString(newtChild)+", from "+cont); } - // Detach OLS early.. - final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); - if(null != ols && ols.isSurfaceLayerAttached()) { - ols.detachSurfaceLayer(); - } - detachNewtChild(cont); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached) - newtChild.destroy(); - newtChild=null; + detachNewtChild(cont); + + if( !removeNotify ) { + final Window cWin = newtChild; + final Window dWin = cWin.getDelegatedWindow(); + newtChild=null; + if( windowClosing && dWin instanceof WindowImpl ) { + ((WindowImpl)dWin).windowDestroyNotify(true); + } else { + cWin.destroy(); + } + } } + if( ( removeNotify || windowClosing ) && null!=jawtWindow) { + NewtFactoryAWT.destroyNativeWindow(jawtWindow); + jawtWindow=null; + } } @Override @@ -501,8 +510,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto return false; } - awtWindowClosingProtocol.addClosingListenerOneShot(); - if( attachNewtChild && !newtChildAttached && null != newtChild ) { attachNewtChild(cont); } @@ -535,11 +542,11 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto throw new InternalError("XXX"); } isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); - awtAdapter = new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this); + awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this); + awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! newtChild.addWindowListener(clearAWTMenusOnNewtFocus); newtChild.setFocusAction(focusAction); // enable AWT focus traversal newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); - awtWindowClosingProtocol.addClosingListenerOneShot(); keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); keyboardFocusManager.addPropertyChangeListener("focusOwner", focusPropertyChangeListener); if(isOnscreen) { @@ -554,7 +561,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.removeWindowListener(clearAWTMenusOnNewtFocus); newtChild.setFocusAction(null); newtChild.setDefaultCloseOperation(newtChildCloseOp); - awtWindowClosingProtocol.removeClosingListener(); } } } @@ -611,7 +617,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.setFocusAction(null); // no AWT focus traversal .. configureNewtChild(false); newtChild.setVisible(false); - newtChild.reparentWindow(null); + + // Detach OLS early.. + final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); + if(null != ols && ols.isSurfaceLayerAttached()) { + ols.detachSurfaceLayer(); + } + newtChild.reparentWindow(null); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached) + if(DEBUG) { System.err.println("NewtCanvasAWT.detachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); } diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 07004503e..c3ad51c96 100755 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -300,9 +300,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { glWindow.reparentWindow(awtParent); } else { glWindow.reparentWindow(null); - if(glClosable) { - glWindow.setDefaultCloseOperation(WindowClosingMode.DISPOSE_ON_CLOSE); - } + glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE ); } } } diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index 9ef4de2b6..4920b59ea 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -81,11 +81,6 @@ public abstract class InputEvent extends NEWTEvent return 0; } - /** Object when attached via {@link #setAttachment(Object)} marks the event consumed, - * ie. stops propagating the event any further to the event listener. - */ - public static final Object consumedTag = new Object(); - protected InputEvent(short eventType, Object source, long when, int modifiers) { super(eventType, source, when); this.modifiers=modifiers; diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index b8de6eb18..6f4561ce6 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -48,6 +48,12 @@ package com.jogamp.newt.event; */ @SuppressWarnings("serial") public class NEWTEvent extends java.util.EventObject { + /** + * Object when attached via {@link #setAttachment(Object)} marks the event consumed, + * ie. stops propagating the event any further to the other event listener. + */ + public static final Object consumedTag = new Object(); + private final short eventType; private final long when; private Object attachment; diff --git a/src/newt/classes/com/jogamp/newt/event/WindowListener.java b/src/newt/classes/com/jogamp/newt/event/WindowListener.java index 011e1f654..dde182510 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowListener.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowListener.java @@ -36,6 +36,7 @@ package com.jogamp.newt.event; import javax.media.nativewindow.WindowClosingProtocol; +/** NEWT {@link WindowEvent} listener. */ public interface WindowListener extends NEWTEventListener { /** Window is resized, your application shall respect the new window dimension. A repaint is recommended. */ public void windowResized(WindowEvent e); @@ -53,7 +54,9 @@ public interface WindowListener extends NEWTEventListener { **/ public void windowDestroyNotify(WindowEvent e); - /** Window has been destroyed.*/ + /** + * Window has been destroyed. + */ public void windowDestroyed(WindowEvent e); /** Window gained focus. */ diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java index 8991203d5..6de2eee45 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java @@ -181,8 +181,13 @@ public abstract class AWTAdapter implements java.util.EventListener /** @see #addTo(java.awt.Component) */ public abstract AWTAdapter removeFrom(java.awt.Component awtComponent); + /** + * Enqueues the event to the {@link #getNewtWindow()} is not null. + */ void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event) { - newtWindow.enqueueEvent(wait, event); + if( null != newtWindow ) { + newtWindow.enqueueEvent(wait, event); + } } } diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java index 2d63ca455..e91bb2f82 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java @@ -66,13 +66,18 @@ public class AWTWindowAdapter return this; } - public AWTAdapter removeFrom(java.awt.Component awtComponent) { - awtComponent.removeFocusListener(this); - awtComponent.removeComponentListener(this); + public AWTAdapter removeWindowClosingFrom(java.awt.Component awtComponent) { java.awt.Window win = getWindow(awtComponent); if( null != win && null != windowClosingListener ) { win.removeWindowListener(windowClosingListener); } + return this; + } + + public AWTAdapter removeFrom(java.awt.Component awtComponent) { + awtComponent.removeFocusListener(this); + awtComponent.removeComponentListener(this); + removeWindowClosingFrom(awtComponent); if(awtComponent instanceof java.awt.Window) { ((java.awt.Window)awtComponent).removeWindowListener(this); } @@ -220,9 +225,16 @@ public class AWTWindowAdapter enqueueEvent(true, event); } } + public void windowClosed(java.awt.event.WindowEvent e) { + com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + if(null!=newtListener) { + ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyed(event); + } else { + enqueueEvent(true, event); + } + } public void windowActivated(java.awt.event.WindowEvent e) { } - public void windowClosed(java.awt.event.WindowEvent e) { } public void windowDeactivated(java.awt.event.WindowEvent e) { } public void windowDeiconified(java.awt.event.WindowEvent e) { } public void windowIconified(java.awt.event.WindowEvent e) { } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 7fccb6622..ce50d95dd 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -100,7 +100,10 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind protected GLWindow(Window window) { super(null, null, false /* always handle device lifecycle ourselves */); this.window = (WindowImpl) window; - this.window.setHandleDestroyNotify(false); + this.window.setWindowDestroyNotifyAction( new Runnable() { + public void run() { + defaultWindowDestroyNotifyOp(); + } } ); window.addWindowListener(new WindowAdapter() { @Override public void windowRepaint(WindowUpdateEvent e) { @@ -112,10 +115,6 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind defaultWindowResizedOp(getWidth(), getHeight()); } - @Override - public void windowDestroyNotify(WindowEvent e) { - defaultWindowDestroyNotifyOp(); - } }); this.window.setLifecycleHook(new GLLifecycleHook()); } @@ -389,6 +388,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind window.destroy(); } + @Override + public void setWindowDestroyNotifyAction(Runnable r) { + window.setWindowDestroyNotifyAction(r); + } + @Override public final void setVisible(boolean visible) { window.setVisible(visible); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 20b915cae..d4842ba2f 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -370,15 +370,8 @@ public abstract class DisplayImpl extends Display { DisplayImpl.this.dispatchMessages(); } }; - final void dispatchMessage(final NEWTEventTask eventTask) { - final NEWTEvent event = eventTask.get(); + final void dispatchMessage(final NEWTEvent event) { try { - if(null == event) { - // Ooops ? - System.err.println("Warning: event of eventTask is NULL"); - Thread.dumpStack(); - return; - } final Object source = event.getSource(); if(source instanceof NEWTEventConsumer) { final NEWTEventConsumer consumer = (NEWTEventConsumer) source ; @@ -396,6 +389,21 @@ public abstract class DisplayImpl extends Display { } else { re = new RuntimeException(t); } + throw re; + } + } + + final void dispatchMessage(final NEWTEventTask eventTask) { + final NEWTEvent event = eventTask.get(); + try { + if(null == event) { + // Ooops ? + System.err.println("Warning: event of eventTask is NULL"); + Thread.dumpStack(); + return; + } + dispatchMessage(event); + } catch (RuntimeException re) { if( eventTask.isCallerWaiting() ) { // propagate exception to caller eventTask.setException(re); @@ -451,7 +459,7 @@ public abstract class DisplayImpl extends Display { // can't wait if we are on EDT or NEDT -> consume right away if(wait && edtUtil.isCurrentThreadEDTorNEDT() ) { - dispatchMessage(new NEWTEventTask(e, null)); + dispatchMessage(e); return; } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 222a1173c..66ca3e07d 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -110,7 +110,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private boolean pointerConfined = false; private LifecycleHook lifecycleHook = null; - private boolean handleDestroyNotify = true; + private Runnable windowDestroyNotifyAction = null; private FocusRunnable focusAction = null; private KeyListener keyboardFocusHandler = null; @@ -864,8 +864,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer _lock.lock(); try { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window DestroyAction() "+getThreadName()); + System.err.println("Window DestroyAction() hasScreen "+(null != screen)+", isNativeValid "+isNativeValid()+" - "+getThreadName()); } + + // send synced destroy-notify notification + sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); + // Childs first .. synchronized(childWindowsLock) { if(childWindows.size()>0) { @@ -875,8 +879,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer while( clonedChildWindows.size() > 0 ) { NativeWindow nw = clonedChildWindows.remove(0); if(nw instanceof WindowImpl) { - ((WindowImpl)nw).sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); - ((WindowImpl)nw).destroy(); + ((WindowImpl)nw).windowDestroyNotify(true); } else { nw.destroy(); } @@ -1549,14 +1552,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public Object getWrappedWindow() { return null; } - - /** - * If set to true, the default value, this NEWT Window implementation will - * handle the destruction (ie {@link #destroy()} call) within {@link #windowDestroyNotify(boolean)} implementation.
    - * If set to false, it's up to the caller/owner to handle destruction within {@link #windowDestroyNotify(boolean)}. - */ - public void setHandleDestroyNotify(boolean b) { - handleDestroyNotify = b; + + @Override + public void setWindowDestroyNotifyAction(Runnable r) { + windowDestroyNotifyAction = r; } /** @@ -2211,7 +2210,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer default: throw new NativeWindowException("Unexpected mouse event type " + e.getEventType()); } - consumed = InputEvent.consumedTag == e.getAttachment(); + consumed = NEWTEvent.consumedTag == e.getAttachment(); } } @@ -2340,7 +2339,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer default: throw new NativeWindowException("Unexpected key event type " + e.getEventType()); } - return InputEvent.consumedTag == e.getAttachment(); + return NEWTEvent.consumedTag == e.getAttachment(); } @SuppressWarnings("deprecation") @@ -2446,7 +2445,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("consumeWindowEvent: "+e+", visible "+isVisible()+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } - for(int i = 0; i < windowListeners.size(); i++ ) { + boolean consumed = false; + for(int i = 0; !consumed && i < windowListeners.size(); i++ ) { WindowListener l = windowListeners.get(i); switch(e.getEventType()) { case WindowEvent.EVENT_WINDOW_RESIZED: @@ -2475,6 +2475,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer new NativeWindowException("Unexpected window event type " + e.getEventType()); } + consumed = NEWTEvent.consumedTag == e.getAttachment(); } } @@ -2615,32 +2616,45 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** - * Triggered by implementation's WM events or programmatically + * Triggered by implementation's WM events or programmatic while respecting {@link #getDefaultCloseOperation()}. * * @param force if true, overrides {@link #setDefaultCloseOperation(WindowClosingMode)} with {@link WindowClosingProtocol#DISPOSE_ON_CLOSE} * and hence force destruction. Otherwise is follows the user settings. * @return true if this window is no more valid and hence has been destroyed, otherwise false. */ - protected boolean windowDestroyNotify(boolean force) { + public boolean windowDestroyNotify(boolean force) { + final WindowClosingMode defMode = getDefaultCloseOperation(); + final WindowClosingMode mode = force ? WindowClosingMode.DISPOSE_ON_CLOSE : defMode; if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.windowDestroyNotify(force: "+force+") START "+getThreadName()+": "+this); - } - if(force) { - setDefaultCloseOperation(WindowClosingMode.DISPOSE_ON_CLOSE); + System.err.println("Window.windowDestroyNotify(force: "+force+", mode "+defMode+" -> "+mode+") "+getThreadName()+": "+this); } - - // send synced destroy notifications - enqueueWindowEvent(true, WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); - - if(handleDestroyNotify && WindowClosingMode.DISPOSE_ON_CLOSE == getDefaultCloseOperation()) { - destroy(); + + if( WindowClosingMode.DISPOSE_ON_CLOSE == mode ) { + if(force) { + setDefaultCloseOperation(mode); + } + try { + if( null == windowDestroyNotifyAction ) { + destroy(); + } else { + windowDestroyNotifyAction.run(); + } + } finally { + if(force) { + setDefaultCloseOperation(defMode); + } + } + } else { + // send synced destroy notifications + sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); } final boolean destroyed = !isNativeValid(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.windowDestroyNotify(force: "+force+") END "+getThreadName()+": destroyed "+destroyed+", "+this); - } + System.err.println("Window.windowDestroyNotify(force: "+force+", mode "+mode+") END "+getThreadName()+": destroyed "+destroyed+", "+this); + } + return destroyed; } diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index 701d9d60a..b348220d6 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -42,9 +42,7 @@ import com.jogamp.newt.event.awt.AWTWindowAdapter; * Specialized parent/client adapter, * where the NEWT child window really gets resized, * and the parent move window event gets discarded. */ -public class AWTParentWindowAdapter - extends AWTWindowAdapter - implements java.awt.event.HierarchyListener +public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt.event.HierarchyListener { NativeWindow downstreamParent; diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index bee43a95e..0172309fb 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -256,10 +256,7 @@ public class WindowDriver extends WindowImpl { } @Override public void windowDestroyed(WindowEvent e) { - if(isNativeValid()) { - WindowDriver.this.windowDestroyNotify(true); - } - + // Not fwd by AWTWindowAdapter, synthesized by NEWT } @Override public void windowGainedFocus(WindowEvent e) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java new file mode 100644 index 000000000..2729d6a5d --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java @@ -0,0 +1,160 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowUpdateEvent; +import com.jogamp.opengl.GLAutoDrawableDelegate; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +/** + * Test using a NEWT {@link Window} for onscreen case. + *

    + * Creates a {@link GLDrawable} using the + * {@link GLDrawableFactory#createGLDrawable(javax.media.nativewindow.NativeSurface) factory model}. + * The {@link GLContext} is derived {@link GLDrawable#createContext(GLContext) from the drawable}. + *

    + *

    + * Finally a {@link GLAutoDrawableDelegate} is created with the just created {@link GLDrawable} and {@link GLContext}. + * It is being used to run the {@link GLEventListener}. + *

    + */ +public class TestGLAutoDrawableDelegateNEWT extends UITestCase { + static long duration = 500; // ms + + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + // + // Create native windowing resources .. X11/Win/OSX + // + final Window window = NewtFactory.createWindow(reqGLCaps); + Assert.assertNotNull(window); + window.setSize(640, 400); + window.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); + System.out.println("Window: "+window.getClass().getName()); + + final GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + drawable.setRealized(true); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, drawable.createContext(null), window, false, null) { + @Override + protected void destroyImplInLock() { + super.destroyImplInLock(); // destroys drawable/context + window.destroy(); // destroys the actual window, incl. the device + } + }; + + window.setWindowDestroyNotifyAction( new Runnable() { + public void run() { + glad.windowDestroyNotifyOp(); + } } ); + + window.addWindowListener(new WindowAdapter() { + @Override + public void windowRepaint(WindowUpdateEvent e) { + glad.windowRepaintOp(); + } + + @Override + public void windowResized(WindowEvent e) { + glad.windowResizedOp(window.getWidth(), window.getHeight()); + } + }); + + glad.addGLEventListener(demo); + + QuitAdapter quitAdapter = new QuitAdapter(); + //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); + //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + window.addKeyListener(quitAdapter); + window.addWindowListener(quitAdapter); + + Animator animator = new Animator(); + animator.setUpdateFPSFrames(60, System.err); + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + animator.add(glad); + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() dispose @@ -90,10 +93,12 @@ public class TestWindowClosingProtocol01AWT extends UITestCase { Thread.sleep(300); - Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false)); // no frame close, but GLCanvas's GL resources will be destroyed + Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false, closingListener)); // no frame close, but GLCanvas's GL resources will be destroyed Thread.sleep(100); Assert.assertEquals(true, frame.isDisplayable()); Assert.assertEquals(true, frame.isVisible()); + Assert.assertEquals(true, closingListener.isWindowClosing()); + Assert.assertEquals(false, closingListener.isWindowClosed()); for (int wait=0; wait dispose @@ -84,9 +84,9 @@ public class TestWindowClosingProtocol02NEWT extends UITestCase { op = glWindow.getDefaultCloseOperation(); Assert.assertEquals(WindowClosingMode.DISPOSE_ON_CLOSE, op); - Assert.assertEquals(true, AWTRobotUtil.closeWindow(glWindow, true)); + Assert.assertEquals(true, AWTRobotUtil.closeWindow(glWindow, true, closingListener)); Assert.assertEquals(false, glWindow.isNativeValid()); - Assert.assertEquals(true, windowClosingListener.isWindowClosing()); + Assert.assertEquals(true, closingListener.isWindowClosing()); } public static void main(String[] args) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java index be3c48fb6..b0a222a5a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java @@ -46,17 +46,19 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil.WindowClosingListener; public class TestWindowClosingProtocol03NewtAWT extends UITestCase { @Test public void testCloseJFrameNewtCanvasAWT() throws InterruptedException, InvocationTargetException { final JFrame frame = new JFrame("testCloseJFrameNewtCanvasAWT"); - + final WindowClosingListener awtClosingListener = AWTRobotUtil.addClosingListener(frame); + GLProfile glp = GLProfile.getGL2ES2(); GLCapabilities caps = new GLCapabilities(glp); final GLWindow glWindow = GLWindow.create(caps); - final AWTRobotUtil.WindowClosingListener windowClosingListener = AWTRobotUtil.addClosingListener(glWindow); + final AWTRobotUtil.WindowClosingListener newtClosingListener = AWTRobotUtil.addClosingListener(glWindow); glWindow.addGLEventListener(new GearsES2()); @@ -81,20 +83,26 @@ public class TestWindowClosingProtocol03NewtAWT extends UITestCase { // // close with op: DO_NOTHING_ON_CLOSE -> NOP / HIDE (default) // - Assert.assertEquals(JFrame.HIDE_ON_CLOSE, frame.getDefaultCloseOperation()); - WindowClosingMode op = newtCanvas.getDefaultCloseOperation(); - Assert.assertEquals(WindowClosingMode.DO_NOTHING_ON_CLOSE, op); + { + Assert.assertEquals(JFrame.HIDE_ON_CLOSE, frame.getDefaultCloseOperation()); + WindowClosingMode op = newtCanvas.getDefaultCloseOperation(); + Assert.assertEquals(WindowClosingMode.DO_NOTHING_ON_CLOSE, op); + } Thread.sleep(300); - Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false)); + Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false, awtClosingListener)); Assert.assertEquals(true, frame.isDisplayable()); Assert.assertEquals(false, frame.isVisible()); Assert.assertEquals(true, newtCanvas.isValid()); Assert.assertEquals(true, newtCanvas.isDisplayable()); Assert.assertEquals(true, glWindow.isNativeValid()); - Assert.assertEquals(true, windowClosingListener.isWindowClosing()); - windowClosingListener.reset(); + Assert.assertEquals(true, awtClosingListener.isWindowClosing()); + Assert.assertEquals(false, awtClosingListener.isWindowClosed()); + Assert.assertEquals(true, newtClosingListener.isWindowClosing()); + Assert.assertEquals(false, newtClosingListener.isWindowClosed()); + awtClosingListener.reset(); + newtClosingListener.reset(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -107,20 +115,25 @@ public class TestWindowClosingProtocol03NewtAWT extends UITestCase { // // close with op (JFrame): DISPOSE_ON_CLOSE -- newtCanvas -- glWindow --> dispose // - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - Assert.assertEquals(JFrame.DISPOSE_ON_CLOSE, frame.getDefaultCloseOperation()); - op = newtCanvas.getDefaultCloseOperation(); - Assert.assertEquals(WindowClosingMode.DISPOSE_ON_CLOSE, op); + { + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + Assert.assertEquals(JFrame.DISPOSE_ON_CLOSE, frame.getDefaultCloseOperation()); + WindowClosingMode op = newtCanvas.getDefaultCloseOperation(); + Assert.assertEquals(WindowClosingMode.DISPOSE_ON_CLOSE, op); + } Thread.sleep(300); - Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, true, awtClosingListener)); Assert.assertEquals(false, frame.isDisplayable()); Assert.assertEquals(false, frame.isVisible()); Assert.assertEquals(false, newtCanvas.isValid()); Assert.assertEquals(false, newtCanvas.isDisplayable()); Assert.assertEquals(false, glWindow.isNativeValid()); - Assert.assertEquals(true, windowClosingListener.isWindowClosing()); + Assert.assertEquals(true, awtClosingListener.isWindowClosing()); + Assert.assertEquals(true, awtClosingListener.isWindowClosed()); + Assert.assertEquals(true, newtClosingListener.isWindowClosing()); + Assert.assertEquals(true, newtClosingListener.isWindowClosed()); } public static void main(String[] args) { diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index ffc42e318..8b46760e1 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.util; +import jogamp.common.awt.AWTEDTExecutor; import jogamp.newt.WindowImplAccess; import java.lang.reflect.InvocationTargetException; @@ -41,6 +42,8 @@ import javax.media.opengl.awt.GLCanvas; import org.junit.Assert; +import com.jogamp.newt.event.WindowEvent; + public class AWTRobotUtil { static final boolean DEBUG = false; @@ -646,16 +649,19 @@ public class AWTRobotUtil { * * @param obj either an AWT Window (Frame, JFrame) or NEWT Window * @param willClose indicating that the window will close, hence this method waits for the window to be closed + * @param wcl the WindowClosingListener to determine whether the AWT or NEWT widget has been closed. It should be attached + * to the widget ASAP before any other listener, e.g. via {@link #addClosingListener(Object)}. + * The WindowClosingListener will be reset before attempting to close the widget. * @return True if the Window is closing and closed (if willClose is true), each within TIME_OUT * @throws InterruptedException */ - public static boolean closeWindow(Object obj, boolean willClose) throws InterruptedException, InvocationTargetException { - WindowClosingListener closingListener = addClosingListener(obj); + public static boolean closeWindow(Object obj, boolean willClose, WindowClosingListener closingListener) throws InterruptedException { + closingListener.reset(); if(obj instanceof java.awt.Window) { final java.awt.Window win = (java.awt.Window) obj; java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit(); final java.awt.EventQueue evtQ = tk.getSystemEventQueue(); - java.awt.EventQueue.invokeAndWait(new Runnable() { + AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { evtQ.postEvent(new java.awt.event.WindowEvent(win, java.awt.event.WindowEvent.WINDOW_CLOSING)); } }); @@ -675,12 +681,15 @@ public class AWTRobotUtil { return wait Date: Thu, 28 Feb 2013 13:31:29 +0100 Subject: Fix Bug 677: NEWT/Android: Add support for Android's KeyEvent.KEYCODE_BACK Original author: Eric Brayet Revised by: Sven Gothel I took the freedom to cleanup the three original patches from https://github.com/Pooouf/jogl.git branch 'bug_677': - 7449d4726633d524a3bb79efffd04cfd0ca25e58 (removed by followup patch!) - 68c739a4f03e46deecdbb71c125b4586aec08d63 (removes previous patch!) - c2813dfc325a1482d18b6fc304e4e483f5633964 Further more I was able to reduce the 'extra' code while utilizing - Window's isKeyboardVisible() and using keyboardVisibilityChanged(false) to update the hidden keyboard state. - Moving the key-handling code to the containing WindowDriver class avoiding passing a reference to the inner view. - Using AndroidNewtEventFactory for NEWT KeyEvent creation +++ - Handle KeyEvent.KEYCODE_BACK w/ jogamp.newt.driver.android.WindowDriver.MSurfaceView.onKeyPreIme(..): if( soft keyboard is up ) [1] Update keyboard visibility state and return NEWT KeyEvent.VK_KEYBOARD_INVISIBLE; else [2] call WindowImpl.windowDestroyNotify(true) [3] then cont. processing, i.e. return false; - Turns out respecting WindowClosingMode might be - too complicated - interfere w/ Android UI behavior - AndroidNewtEventFactory - createKeyEvent - static - adding boolean param 'inclSysKeys', if true, KEYCODE_BACK and KEYCODE_HOME are mapped - Unit tests: GearsES2 + MovieCubeActivity0 shows keyboard if pressure > 0.6f - pressure on Android shall be between [0..1], however we have to figure out badly calibrated touchpads/Android device where we could experience pressure > 2.0f ! - TODO: API documentation of pressure [0..1] --- .../classes/com/jogamp/newt/event/KeyEvent.java | 5 ++ .../classes/com/jogamp/newt/event/NEWTEvent.java | 2 +- .../jogamp/newt/driver/android/WindowDriver.java | 39 +++++++++- .../android/event/AndroidNewtEventFactory.java | 88 ++++++++++++++-------- .../android/event/AndroidNewtEventTranslator.java | 2 +- .../opengl/test/android/MovieCubeActivity0.java | 2 +- .../opengl/test/android/NEWTGearsES2Activity.java | 8 -- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 4 + 8 files changed, 105 insertions(+), 45 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index f626fec38..5117ffe29 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -871,6 +871,11 @@ public class KeyEvent extends InputEvent */ public static final short VK_BEGIN = (short) 0xFF58; + /** + * Constant for Keyboard became invisible, e.g. Android's soft keyboard Back button hit while keyboard is visible. + */ + public static final short VK_KEYBOARD_INVISIBLE = (short) 0xDEAD; + /** * This value is used to indicate that the keyCode is unknown. * KEY_TYPED events do not have a keyCode value; this value diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index 6f4561ce6..17210cef8 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -107,7 +107,7 @@ public class NEWTEvent extends java.util.EventObject { return sb.append("NEWTEvent[source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); } - static String toHexString(short hex) { + public static String toHexString(short hex) { return "0x" + Integer.toHexString( (int)hex & 0x0000FFFF ); } } diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index a85febca0..c5371ae9c 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -30,6 +30,7 @@ package jogamp.newt.driver.android; import jogamp.common.os.android.StaticContext; import jogamp.newt.WindowImpl; +import jogamp.newt.driver.android.event.AndroidNewtEventFactory; import jogamp.newt.driver.android.event.AndroidNewtEventTranslator; import javax.media.nativewindow.Capabilities; @@ -65,6 +66,8 @@ import android.view.SurfaceHolder.Callback2; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.view.SurfaceView; +import android.view.KeyEvent; + public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { static { @@ -573,10 +576,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { @Override public final void surfaceDestroyed(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceDestroyed - on thread "+Thread.currentThread().getName()); - if(WindowImpl.DEBUG_IMPLEMENTATION) { - Thread.dumpStack(); - } windowDestroyNotify(true); // actually too late .. however .. + Thread.dumpStack(); } @Override @@ -585,6 +586,27 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { windowRepaint(0, 0, getWidth(), getHeight()); } + protected boolean handleKeyCodeBack(KeyEvent.DispatcherState state, android.view.KeyEvent event) { + if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { + state.startTracking(event, this); + } else if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled() && state.isTracking(event)) { + if( isKeyboardVisible() ) { + keyboardVisibilityChanged(false); + enqueueAKey2NKeyUpDown(event); + } else { + Log.d(MD.TAG, "handleKeyCodeBack : "+event); + windowDestroyNotify(true); + } + } + return false; // cont. processing + } + private void enqueueAKey2NKeyUpDown(android.view.KeyEvent aEvent) { + final com.jogamp.newt.event.KeyEvent eDown = AndroidNewtEventFactory.createKeyEvent(aEvent, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, this, true); + final com.jogamp.newt.event.KeyEvent eUp = AndroidNewtEventFactory.createKeyEvent(aEvent, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, this, true); + enqueueEvent(false, eDown); + enqueueEvent(false, eUp); + } + private boolean added2StaticViewGroup; private MSurfaceView androidView; private int nativeFormat; // chosen current native PixelFormat (suitable for EGL) @@ -600,6 +622,17 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { setBackgroundDrawable(null); // setBackgroundColor(Color.TRANSPARENT); } + + @Override + public boolean onKeyPreIme(int keyCode, KeyEvent event) { + if ( event.getKeyCode() == KeyEvent.KEYCODE_BACK ) { + final KeyEvent.DispatcherState state = getKeyDispatcherState(); + if (state != null) { + return handleKeyCodeBack(state, event); + } + } + return false; // cont. processing + } } //---------------------------------------------------------------------- // Internals only diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 4f19e9c4d..a9c642d8c 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -31,6 +31,7 @@ package jogamp.newt.driver.android.event; import com.jogamp.common.os.AndroidVersion; import com.jogamp.newt.Window; import com.jogamp.newt.event.InputEvent; +import com.jogamp.newt.event.NEWTEvent; public class AndroidNewtEventFactory { @@ -86,7 +87,7 @@ public class AndroidNewtEventFactory { return (short)0; } - private static final short aKeyCode2NewtKeyCode(int androidKeyCode) { + private static final short aKeyCode2NewtKeyCode(int androidKeyCode, boolean inclSysKeys) { if(android.view.KeyEvent.KEYCODE_0 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_9) { return (short) ( com.jogamp.newt.event.KeyEvent.VK_0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_0 ) ); } @@ -122,11 +123,19 @@ public class AndroidNewtEventFactory { // case android.view.KeyEvent.KEYCODE_MUTE: ?? case android.view.KeyEvent.KEYCODE_PAGE_UP: return com.jogamp.newt.event.KeyEvent.VK_PAGE_UP; case android.view.KeyEvent.KEYCODE_PAGE_DOWN: return com.jogamp.newt.event.KeyEvent.VK_PAGE_DOWN; - // case android.view.KeyEvent.KEYCODE_HOME: return com.jogamp.newt.event.KeyEvent.VK_HOME; - // case android.view.KeyEvent.KEYCODE_BACK: return com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE; case android.view.KeyEvent.KEYCODE_ESCAPE: return com.jogamp.newt.event.KeyEvent.VK_ESCAPE; case android.view.KeyEvent.KEYCODE_CTRL_LEFT: return com.jogamp.newt.event.KeyEvent.VK_CONTROL; case android.view.KeyEvent.KEYCODE_CTRL_RIGHT: return com.jogamp.newt.event.KeyEvent.VK_CONTROL; // ?? + case android.view.KeyEvent.KEYCODE_BACK: + if( inclSysKeys ) { + return com.jogamp.newt.event.KeyEvent.VK_KEYBOARD_INVISIBLE; + } + break; + case android.view.KeyEvent.KEYCODE_HOME: + if( inclSysKeys ) { + return com.jogamp.newt.event.KeyEvent.VK_HOME; + } + break; } return (short)0; } @@ -140,19 +149,7 @@ public class AndroidNewtEventFactory { return newtMods; } - private final NewtGestureListener gestureListener; - private final android.view.GestureDetector gestureDetector; - private final float touchSlop; - - public AndroidNewtEventFactory(android.content.Context context, android.os.Handler handler) { - gestureListener = new NewtGestureListener(); - gestureDetector = new android.view.GestureDetector(context, gestureListener, handler, false /* ignoreMultitouch */); - gestureDetector.setIsLongpressEnabled(false); // favor scroll event! - final android.view.ViewConfiguration configuration = android.view.ViewConfiguration.get(context); - touchSlop = configuration.getScaledTouchSlop(); - } - - public com.jogamp.newt.event.WindowEvent createWindowEvent(android.view.accessibility.AccessibilityEvent event, com.jogamp.newt.Window newtSource) { + public static com.jogamp.newt.event.WindowEvent createWindowEvent(android.view.accessibility.AccessibilityEvent event, com.jogamp.newt.Window newtSource) { final int aType = event.getEventType(); final short nType = aAccessibilityEventType2Newt(aType); @@ -163,25 +160,54 @@ public class AndroidNewtEventFactory { } - public com.jogamp.newt.event.KeyEvent createKeyEvent(int keyCode, android.view.KeyEvent event, com.jogamp.newt.Window newtSource) { - final short type = aKeyEventType2NewtEventType(event.getAction()); - if(Window.DEBUG_MOUSE_EVENT) { - System.err.println("createKeyEvent: type 0x"+Integer.toHexString(type)+", keyCode 0x"+Integer.toHexString(keyCode)+", "+event); + public static com.jogamp.newt.event.KeyEvent createKeyEvent(android.view.KeyEvent aEvent, com.jogamp.newt.Window newtSource, boolean inclSysKeys) { + final com.jogamp.newt.event.KeyEvent res; + final short newtType = aKeyEventType2NewtEventType(aEvent.getAction()); + if( (short)0 != newtType) { + final short newtKeyCode = aKeyCode2NewtKeyCode(aEvent.getKeyCode(), inclSysKeys); + res = createKeyEventImpl(aEvent, newtType, newtKeyCode, newtSource); + } else { + res = null; } - if( (short)0 != type) { - final short newtKeyCode = aKeyCode2NewtKeyCode(keyCode); - if( (short)0 != newtKeyCode ) { - final Object src = (null==newtSource)?null:(Object)newtSource; - final long unixTime = System.currentTimeMillis() + ( event.getEventTime() - android.os.SystemClock.uptimeMillis() ); - final int newtMods = aKeyModifiers2Newt(event.getMetaState()); - - return new com.jogamp.newt.event.KeyEvent( - type, src, unixTime, newtMods, newtKeyCode, newtKeyCode, (char) event.getUnicodeChar()); - } + if(Window.DEBUG_KEY_EVENT) { + System.err.println("createKeyEvent0: "+aEvent+" -> "+res); } - return null; + return res; } + public static com.jogamp.newt.event.KeyEvent createKeyEvent(android.view.KeyEvent aEvent, short newtType, com.jogamp.newt.Window newtSource, boolean inclSysKeys) { + final short newtKeyCode = aKeyCode2NewtKeyCode(aEvent.getKeyCode(), inclSysKeys); + final com.jogamp.newt.event.KeyEvent res = createKeyEventImpl(aEvent, newtType, newtKeyCode, newtSource); + if(Window.DEBUG_KEY_EVENT) { + System.err.println("createKeyEvent1: newtType "+NEWTEvent.toHexString(newtType)+", "+aEvent+" -> "+res); + } + return res; + } + + private static com.jogamp.newt.event.KeyEvent createKeyEventImpl(android.view.KeyEvent aEvent, short newtType, short newtKeyCode, com.jogamp.newt.Window newtSource) { + if( (short)0 != newtType && (short)0 != newtKeyCode ) { + final Object src = null==newtSource ? null : newtSource; + final long unixTime = System.currentTimeMillis() + ( aEvent.getEventTime() - android.os.SystemClock.uptimeMillis() ); + final int newtMods = aKeyModifiers2Newt(aEvent.getMetaState()); + + return new com.jogamp.newt.event.KeyEvent( + newtType, src, unixTime, newtMods, newtKeyCode, newtKeyCode, (char) aEvent.getUnicodeChar()); + } + return null; + } + + private final NewtGestureListener gestureListener; + private final android.view.GestureDetector gestureDetector; + private final float touchSlop; + + public AndroidNewtEventFactory(android.content.Context context, android.os.Handler handler) { + gestureListener = new NewtGestureListener(); + gestureDetector = new android.view.GestureDetector(context, gestureListener, handler, false /* ignoreMultitouch */); + gestureDetector.setIsLongpressEnabled(false); // favor scroll event! + final android.view.ViewConfiguration configuration = android.view.ViewConfiguration.get(context); + touchSlop = configuration.getScaledTouchSlop(); + } + private int gestureScrollPointerDown = 0; public com.jogamp.newt.event.MouseEvent[] createMouseEvents(boolean isOnTouchEvent, diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java index 2d972f752..93735863e 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java @@ -38,7 +38,7 @@ public class AndroidNewtEventTranslator implements View.OnKeyListener, View.OnTo @Override public boolean onKey(View v, int keyCode, android.view.KeyEvent event) { - final com.jogamp.newt.event.KeyEvent newtEvent = factory.createKeyEvent(keyCode, event, newtWindow); + final com.jogamp.newt.event.KeyEvent newtEvent = AndroidNewtEventFactory.createKeyEvent(event, newtWindow, false /* no system keys */); if(null != newtEvent) { newtWindow.enqueueEvent(false, newtEvent); return true; diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java index a30262ee3..0c65b6d53 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java @@ -54,7 +54,7 @@ public class MovieCubeActivity0 extends NewtBaseActivity { MouseAdapter showKeyboardMouseListener = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - if(e.getPressure()>2f) { + if(e.getPressure()>0.6f) { ((com.jogamp.newt.Window) e.getSource()).setKeyboardVisible(true); } } diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java index e782ac75f..931ffdbb2 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java @@ -66,14 +66,6 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { GLWindow glWindow = GLWindow.create(caps); glWindow.setFullscreen(true); setContentView(getWindow(), glWindow); - glWindow.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if(e.getPressure()>2f) { // show Keyboard - ((com.jogamp.newt.Window) e.getSource()).setKeyboardVisible(true); - } - } - }); GearsES2 demo = new GearsES2(-1); // demo.enableAndroidTrace(true); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 74377a5f8..14c6a0cda 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -366,6 +366,10 @@ public class GearsES2 implements GLEventListener { public void mousePressed(MouseEvent e) { prevMouseX = e.getX(); prevMouseY = e.getY(); + Object src = e.getSource(); + if(e.getPressure()>0.6f && src instanceof Window) { // show Keyboard + ((Window) src).setKeyboardVisible(true); + } } public void mouseReleased(MouseEvent e) { -- cgit v1.2.3 From 01fdd5c564dcb8a7d4f8347f71728f8c2b657cb3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 28 Feb 2013 13:33:21 +0100 Subject: NEWT WindowImpl: Cleanup redundancies in destroy() and windowDestroyNotify(boolean) - destroy() - screen is never null! - always attempt to removeScreenReference() - windowDestroyNotify(boolean) - NOP if !isNativeValid() to avoid DESTROY_* events --- src/newt/classes/jogamp/newt/WindowImpl.java | 69 +++++++++++++++------------- 1 file changed, 37 insertions(+), 32 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 66ca3e07d..af0bde179 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -892,21 +892,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer lifecycleHook.destroyActionInLock(); } - if( null != screen ) { - if( isNativeValid() ) { - screen.removeScreenModeListener(screenModeListenerImpl); - closeNativeImpl(); - final AbstractGraphicsDevice cfgADevice = config.getScreen().getDevice(); - if( cfgADevice != screen.getDisplay().getGraphicsDevice() ) { // don't pull display's device - cfgADevice.close(); // ensure a cfg's device is closed - } - setGraphicsConfiguration(null); - removeScreenReference(); - } - Display dpy = screen.getDisplay(); - if(null != dpy) { - dpy.validateEDT(); + if( isNativeValid() ) { + screen.removeScreenModeListener(screenModeListenerImpl); + closeNativeImpl(); + final AbstractGraphicsDevice cfgADevice = config.getScreen().getDevice(); + if( cfgADevice != screen.getDisplay().getGraphicsDevice() ) { // don't pull display's device + cfgADevice.close(); // ensure a cfg's device is closed } + setGraphicsConfiguration(null); + } + removeScreenReference(); + Display dpy = screen.getDisplay(); + if(null != dpy) { + dpy.validateEDT(); } // send synced destroyed notification @@ -2626,33 +2624,40 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final WindowClosingMode defMode = getDefaultCloseOperation(); final WindowClosingMode mode = force ? WindowClosingMode.DISPOSE_ON_CLOSE : defMode; if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.windowDestroyNotify(force: "+force+", mode "+defMode+" -> "+mode+") "+getThreadName()+": "+this); + System.err.println("Window.windowDestroyNotify(isNativeValid: "+isNativeValid()+", force: "+force+", mode "+defMode+" -> "+mode+") "+getThreadName()+": "+this); + // Thread.dumpStack(); } - if( WindowClosingMode.DISPOSE_ON_CLOSE == mode ) { - if(force) { - setDefaultCloseOperation(mode); - } - try { - if( null == windowDestroyNotifyAction ) { - destroy(); - } else { - windowDestroyNotifyAction.run(); - } - } finally { + final boolean destroyed; + + if( isNativeValid() ) { + if( WindowClosingMode.DISPOSE_ON_CLOSE == mode ) { if(force) { - setDefaultCloseOperation(defMode); + setDefaultCloseOperation(mode); } + try { + if( null == windowDestroyNotifyAction ) { + destroy(); + } else { + windowDestroyNotifyAction.run(); + } + } finally { + if(force) { + setDefaultCloseOperation(defMode); + } + } + } else { + // send synced destroy notifications + sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); } + + destroyed = !isNativeValid(); } else { - // send synced destroy notifications - sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); + destroyed = true; } - - final boolean destroyed = !isNativeValid(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.windowDestroyNotify(force: "+force+", mode "+mode+") END "+getThreadName()+": destroyed "+destroyed+", "+this); + System.err.println("Window.windowDestroyNotify(isNativeValid: "+isNativeValid()+", force: "+force+", mode "+mode+") END "+getThreadName()+": destroyed "+destroyed+", "+this); } return destroyed; -- cgit v1.2.3 From b85903ac92be7884e99eb7b85884033d7ea42337 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 28 Feb 2013 15:24:42 +0100 Subject: NEWT: Harmonize MouseEvent Pressure (API Change!) Due to high fluctuation (lack of normalized) pressure values on Android devices, an option to query the normalized value and access to the current known maximum pressure is required. MouseEvent: - getMaxPressure() returning the [self calibrated] known maximum pressure - getPressure(..) -> getPressure(.., boolean normalize) (API Change!) - return normalize ? pressure/maxPressure : pressure; --- .../classes/com/jogamp/newt/event/MouseEvent.java | 63 +++++++++++++++++----- .../android/event/AndroidNewtEventFactory.java | 39 ++++++++++++-- .../opengl/test/android/MovieCubeActivity0.java | 2 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 2 +- 4 files changed, 86 insertions(+), 20 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 23549533e..8ad1f3f24 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -70,7 +70,8 @@ public class MouseEvent extends InputEvent super(eventType, source, when, modifiers); this.x = new int[]{x}; this.y = new int[]{y}; - this.pressure = new float[]{0}; + this.pressure = new float[]{0f}; + this.maxPressure= 1.0f; this.pointerids = new short[]{-1}; this.clickCount=clickCount; this.button=button; @@ -78,8 +79,8 @@ public class MouseEvent extends InputEvent } public MouseEvent(short eventType, Object source, long when, - int modifiers, int[] x, int[] y, float[] pressure, short[] pointerids, short clickCount, short button, - float rotation) + int modifiers, int[] x, int[] y, float[] pressure, float maxPressure, short[] pointerids, short clickCount, + short button, float rotation) { super(eventType, source, when, modifiers); this.x = x; @@ -89,7 +90,11 @@ public class MouseEvent extends InputEvent pointerids.length != y.length) { throw new IllegalArgumentException("All multiple pointer arrays must be of same size"); } + if( 0.0f >= maxPressure ) { + throw new IllegalArgumentException("maxPressure must be > 0.0f"); + } this.pressure = pressure; + this.maxPressure= maxPressure; this.pointerids = pointerids; this.clickCount=clickCount; this.button=button; @@ -129,28 +134,59 @@ public class MouseEvent extends InputEvent } /** - * @return x-coord at index where index refers to the - * data coming from a pointer. + * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] + * @return X-Coord associated with the pointer-index. * @see getPointerId(index) */ public int getX(int index) { return x[index]; } + /** + * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] + * @return Y-Coord associated with the pointer-index. + * @see getPointerId(index) + */ public int getY(int index) { return y[index]; } - public float getPressure(){ - return pressure[0]; + /** + * @param normalized if true, method returns the normalized pressure, i.e. pressure / maxPressure + * @return The pressure associated with the pointer-index 0. + * The value of zero is return if not available. + * @see #getMaxPressure() + */ + public float getPressure(boolean normalized){ + return normalized ? pressure[0] / maxPressure : pressure[0]; + } + + /** + * Returns the maximum pressure known for the input device generating this event. + *

    + * This value may be self calibrating on devices/OS, where no known maximum pressure is known. + * Hence subsequent events may return a higher value. + *

    + *

    + * Self calibrating maximum pressure is performed on: + *

      + *
    • Android
    • + *
    + *

    + */ + public float getMaxPressure() { + return maxPressure; } /** - * @return the pressure associated with the pointer at index. - * the value of zero is return if not available. + * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] + * @param normalized if true, method returns the normalized pressure, i.e. pressure / maxPressure + * @return The pressure associated with the pointer-index. + * The value of zero is return if not available. + * @see #getMaxPressure() */ - public float getPressure(int index){ - return pressure[index]; + public float getPressure(int index, boolean normalized){ + return normalized ? pressure[index] / maxPressure : pressure[index]; } /** @@ -199,8 +235,8 @@ public class MouseEvent extends InputEvent sb.append(", "); } sb.append(pointerids[i]).append(": ") - .append(x[i]).append(" / ").append(y[i]).append(" ") - .append(pressure[i]).append("p"); + .append(x[i]).append("/").append(y[i]).append(", ") + .append("p[").append(pressure[i]).append("/").append(maxPressure).append("=").append(pressure[i]/maxPressure).append("]"); } sb.append("]"); } @@ -225,6 +261,7 @@ public class MouseEvent extends InputEvent private final short clickCount, button; private final float wheelRotation; private final float pressure[]; + private final float maxPressure; private final short pointerids[]; public static final short EVENT_MOUSE_CLICKED = 200; diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index a9c642d8c..1f78bd578 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -196,6 +196,28 @@ public class AndroidNewtEventFactory { return null; } + private static float maxPressure = 0.7f; // experienced maximum value (Amazon HD = 0.8f) + + /** + * Dynamic calibration of maximum MotionEvent pressure, starting from 0.7f + *

    + * Specification says no pressure is 0.0f and + * normal pressure is 1.0f, where > 1.0f denominates very high pressure. + *

    + *

    + * Some devices exceed this spec, or better, most devices do. + *

      + *
    • Asus TF2*: Pressure always > 1.0f
    • + *
    • Amazon HD: Pressure always ≤ 0.8f
    • + *
    + *

    + * + * @return + */ + public static float getMaxPressure() { + return maxPressure; + } + private final NewtGestureListener gestureListener; private final android.view.GestureDetector gestureDetector; private final float touchSlop; @@ -209,13 +231,17 @@ public class AndroidNewtEventFactory { } private int gestureScrollPointerDown = 0; - + public com.jogamp.newt.event.MouseEvent[] createMouseEvents(boolean isOnTouchEvent, android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { if(Window.DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: "+toString(event)); } + if( event.getPressure() > maxPressure ) { + maxPressure = event.getPressure(); + } + // // Prefilter Android Event (Gesture, ..) and determine final type // @@ -340,6 +366,9 @@ public class AndroidNewtEventFactory { y[j] = (int)event.getY(i); pressure[j] = event.getPressure(i); pointerIds[j] = (short)event.getPointerId(i); + if( pressure[j] > maxPressure ) { + maxPressure = pressure[j]; + } if(Window.DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: ptr-data["+i+" -> "+j+"] "+x[j]+"/"+y[j]+", pressure "+pressure[j]+", id "+pointerIds[j]); } @@ -362,15 +391,15 @@ public class AndroidNewtEventFactory { final com.jogamp.newt.event.MouseEvent me1 = new com.jogamp.newt.event.MouseEvent( nType, src, unixTime, - modifiers, x, y, pressure, pointerIds, clickCount, - button, rotation); + modifiers, x, y, pressure, maxPressure, pointerIds, + clickCount, button, rotation); if( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED == nType ) { return new com.jogamp.newt.event.MouseEvent[] { me1, new com.jogamp.newt.event.MouseEvent( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED, - src, unixTime, modifiers, x, y, pressure, pointerIds, clickCount, - button, rotation) }; + src, unixTime, modifiers, x, y, pressure, maxPressure, pointerIds, + clickCount, button, rotation) }; } else { return new com.jogamp.newt.event.MouseEvent[] { me1 }; } diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java index 0c65b6d53..b1ab90a88 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java @@ -54,7 +54,7 @@ public class MovieCubeActivity0 extends NewtBaseActivity { MouseAdapter showKeyboardMouseListener = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - if(e.getPressure()>0.6f) { + if(e.getPressure(true)>0.8f) { ((com.jogamp.newt.Window) e.getSource()).setKeyboardVisible(true); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 14c6a0cda..99df7c102 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -367,7 +367,7 @@ public class GearsES2 implements GLEventListener { prevMouseX = e.getX(); prevMouseY = e.getY(); Object src = e.getSource(); - if(e.getPressure()>0.6f && src instanceof Window) { // show Keyboard + if(e.getPressure(true)>0.8f && src instanceof Window) { // show Keyboard ((Window) src).setKeyboardVisible(true); } } -- cgit v1.2.3 From 33eb58fc25b0e44666f72e5a2abf6e040efba8bf Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 28 Feb 2013 18:40:46 +0100 Subject: Adapt to GlueGen's relocation of AWTEDTExecutor - GlueGen commit 99a50b38f5650fedca0f207e03706ffa9492e50c --- src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 2 +- src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java | 3 ++- src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 2 +- src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 94e123b3e..ebc25e2ad 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -86,6 +86,7 @@ import javax.media.opengl.Threading; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.VersionUtil; +import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; @@ -95,7 +96,6 @@ import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.opengl.JoglVersion; -import jogamp.common.awt.AWTEDTExecutor; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableHelper; diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java index ae8969d07..56f00b370 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java @@ -44,7 +44,8 @@ import java.awt.EventQueue; import javax.media.opengl.GLException; -import jogamp.common.awt.AWTEDTExecutor; +import com.jogamp.common.util.awt.AWTEDTExecutor; + import jogamp.opengl.GLWorkerThread; import jogamp.opengl.ThreadingImpl; import jogamp.opengl.ToolkitThreadingPlugin; diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 27d0f3506..cecb1dd7e 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -33,9 +33,9 @@ import java.awt.EventQueue; import javax.media.nativewindow.NativeWindowException; import com.jogamp.common.util.RunnableTask; +import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.newt.util.EDTUtil; -import jogamp.common.awt.AWTEDTExecutor; import jogamp.newt.Debug; public class AWTEDTUtil implements EDTUtil { diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index 8b46760e1..960145e78 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -28,7 +28,6 @@ package com.jogamp.opengl.test.junit.util; -import jogamp.common.awt.AWTEDTExecutor; import jogamp.newt.WindowImplAccess; import java.lang.reflect.InvocationTargetException; @@ -42,6 +41,7 @@ import javax.media.opengl.awt.GLCanvas; import org.junit.Assert; +import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.newt.event.WindowEvent; public class AWTRobotUtil { -- cgit v1.2.3 From e2506d7663b752f00f0a98f793ebad52e65bd1e3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 13 Mar 2013 07:12:59 +0100 Subject: Bug 665: Allow re-association of GLContext/GLEventListener to a GLDrawable (Part 5) - GLAutoDrawableBase: - Add 'setPreserveGLStateAtDestroy(..)' to preserve the GLEventListenerState at destroy() operation, and impl. details pullGLEventListenerState()/pushGLEventListenerState(). pullGLEventListenerState() is called automatic at destroyImplInLock(), where pushGLEventListenerState() has to be called after drawable realization instead of context creation. - Note/TODO: Method will become public in GLAutoDrawable in general! - NEWT/GLWindow: - Use GLEventListenerState preservation for reparenting case w/ destruction, i.e. keep GLContext/GLEventListener alive while reparenting in recreation mode. Scenario: NewtCanvasAWT Child <-> Top on OSX w/ CALayer --- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 56 ++++++++++++++++++++++ .../classes/com/jogamp/newt/opengl/GLWindow.java | 20 ++++---- src/newt/classes/jogamp/newt/WindowImpl.java | 30 ++++++++---- 3 files changed, 89 insertions(+), 17 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index ad67f8281..cab768e3a 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -68,6 +68,8 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { protected volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access protected GLContextImpl context; + protected boolean preserveGLELSAtDestroy; + protected GLEventListenerState glels; protected final boolean ownsDevice; protected int additionalCtxCreationFlags = 0; protected volatile boolean sendReshape = false; // volatile: maybe written by WindowManager thread w/o locking @@ -88,6 +90,8 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { public GLAutoDrawableBase(GLDrawableImpl drawable, GLContextImpl context, boolean ownsDevice) { this.drawable = drawable; this.context = context; + this.preserveGLELSAtDestroy = false; + this.glels = null; this.ownsDevice = ownsDevice; if(null != context && null != drawable) { context.setGLDrawable(drawable, false); @@ -97,6 +101,54 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { /** Returns the recursive lock object of the upstream implementation, which synchronizes multithreaded access. */ protected abstract RecursiveLock getLock(); + + + /** + * If set to true, the next {@link #destroy()} operation will + * {@link #pullGLEventListenerState() pull} to preserve the {@link GLEventListenerState}. + */ + public final void setPreserveGLStateAtDestroy(boolean value) { + preserveGLELSAtDestroy = value; + } + + /** + * Pulls the {@link GLEventListenerState} from this {@link GLAutoDrawable}. + * + * @return true if the {@link GLEventListenerState} is pulled successfully from this {@link GLAutoDrawable}, + * otherwise false. + * + * @throws IllegalStateException if the {@link GLEventListenerState} is already pulled + * + * @see #pushGLEventListenerState() + */ + protected final boolean pullGLEventListenerState() throws IllegalStateException { + if( null != glels ) { + throw new IllegalStateException("GLEventListenerState already pulled"); + } + if( null != context && context.isCreated() ) { + glels = GLEventListenerState.moveFrom(this); + return null != glels; + } + return false; + } + + /** + * Pushes a previously {@link #pullGLEventListenerState() pulled} {@link GLEventListenerState} to this {@link GLAutoDrawable}. + * + * @return true if the {@link GLEventListenerState} was previously {@link #pullGLEventListenerState() pulled} + * and is pushed successfully to this {@link GLAutoDrawable}, + * otherwise false. + * + * @see #pullGLEventListenerState() + */ + protected final boolean pushGLEventListenerState() { + if( null != glels ) { + glels.moveTo(this); + glels = null; + return true; + } + return false; + } /** Default implementation to handle repaint events from the windowing system */ protected final void defaultWindowRepaintOp() { @@ -229,6 +281,10 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { * In such case call super.destroyImplInLock first.

    */ protected void destroyImplInLock() { + if( preserveGLELSAtDestroy ) { + preserveGLELSAtDestroy = false; + pullGLEventListenerState(); + } if( null != context ) { if( context.isCreated() ) { // Catch dispose GLExceptions by GLEventListener, just 'print' them diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index ce50d95dd..33f136460 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -420,6 +420,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind // Hide methods here .. protected class GLLifecycleHook implements WindowImpl.LifecycleHook { + @Override + public void setPreserveResourcesAtDestroy() { + GLWindow.this.setPreserveGLStateAtDestroy(true); + } + @Override public synchronized void destroyActionPreLock() { // nop @@ -433,7 +438,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind //Exception e1 = new Exception(msg); //e1.printStackTrace(); } - + destroyImplInLock(); if(Window.DEBUG_IMPLEMENTATION) { @@ -479,8 +484,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } drawable = (GLDrawableImpl) factory.createGLDrawable(nw); drawable.setRealized(true); - context = (GLContextImpl) drawable.createContext(sharedContext); - context.setContextCreationFlags(additionalCtxCreationFlags); + + if( !GLWindow.this.pushGLEventListenerState() ) { + context = (GLContextImpl) drawable.createContext(sharedContext); + context.setContextCreationFlags(additionalCtxCreationFlags); + } } if(Window.DEBUG_IMPLEMENTATION) { System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+WindowImpl.getThreadName()+", fin: dt "+ (System.nanoTime()-t0)/1e6 +"ms"); @@ -512,7 +520,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind // private GLContext sharedContext = null; - + @Override protected final RecursiveLock getLock() { return window.getLock(); @@ -570,10 +578,6 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return factory; } - @Override - public final void setRealized(boolean realized) { - } - @Override public final void swapBuffers() throws GLException { defaultSwapBuffers(); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index af0bde179..dfaa55679 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -222,6 +222,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer */ void setVisibleActionPost(boolean visible, boolean nativeWindowCreated); + /** + * Notifies the receiver to preserve resources (GL, ..) + * for the next destroy*() calls (only). + */ + void setPreserveResourcesAtDestroy(); + /** * Invoked before Window destroy action, * allows releasing of resources depending on the native Window.
    @@ -953,6 +959,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer runOnEDTIfAvail(true, destroyAction); } + protected void destroy(boolean preserveResources) { + if( preserveResources && null != WindowImpl.this.lifecycleHook ) { + WindowImpl.this.lifecycleHook.setPreserveResourcesAtDestroy(); + } + destroy(); + } + /** * @param cWin child window, must not be null * @param pWin parent window, may be null @@ -1053,9 +1066,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(null==newParentWindowNEWT) { throw new NativeWindowException("Reparenting with non NEWT Window type only available after it's realized: "+newParentWindow); } - // Destroy this window and use parent's Screen. + // Destroy this window and use parent's Screen, while trying to preserve resources. // It may be created properly when the parent is made visible. - destroy(); + destroy(true); setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); operation = ReparentOperation.ACTION_NATIVE_CREATION_PENDING; } else if(newParentWindow != getParent()) { @@ -1078,9 +1091,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer operation = ReparentOperation.ACTION_NATIVE_CREATION_PENDING; } } else if ( forceDestroyCreate || !NewtFactory.isScreenCompatible(newParentWindow, screen) ) { - // Destroy this window, may create a new compatible Screen/Display, - // and mark it for creation. - destroy(); + // Destroy this window, may create a new compatible Screen/Display, while trying to preserve resources. + destroy(true); if(null!=newParentWindowNEWT) { setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); } else { @@ -1109,8 +1121,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Already Top Window operation = ReparentOperation.ACTION_NOP; } else if( !isNativeValid() || forceDestroyCreate ) { - // Destroy this window and mark it for [pending] creation. - destroy(); + // Destroy this window and mark it for [pending] creation, while trying to preserve resources. + destroy(true); if( 0 < width && 0 < height ) { operation = ReparentOperation.ACTION_NATIVE_CREATION; } else { @@ -1213,11 +1225,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(!ok) { - // native reparent failed -> try creation + // native reparent failed -> try creation, while trying to preserve resources. if(DEBUG_IMPLEMENTATION) { System.err.println("Window.reparent: native reparenting failed ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+" -> "+toHexString(newParentWindowHandle)+" - Trying recreation"); } - destroy(); + destroy(true); operation = ReparentOperation.ACTION_NATIVE_CREATION ; } } -- cgit v1.2.3 From 74019520e8d82d03f5cf95729456717b34060f5d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 13 Mar 2013 07:15:41 +0100 Subject: Minor Changes: EGLDisplayUtil: Add stack trace in DEBUG mode for opened DPYs; JAWTWindow: Add JAWT info in toString() --- src/jogl/classes/javax/media/opengl/GLContext.java | 4 +- .../classes/jogamp/opengl/egl/EGLDisplayUtil.java | 76 +++++++++++++++++----- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 33 ++++++---- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 2 +- 4 files changed, 85 insertions(+), 30 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index c31b76401..05200324d 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -477,12 +477,12 @@ public abstract class GLContext { public abstract GL setGL(GL gl); /** - * Returns the native GL context handle + * Returns the underlying native OpenGL context handle */ public final long getHandle() { return contextHandle; } /** - * Indicates whether the underlying OpenGL context has been created. + * Indicates whether the underlying native OpenGL context has been created. */ public final boolean isCreated() { return 0 != contextHandle; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index 1f6f49f88..f2efb0479 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -38,7 +38,7 @@ import javax.media.opengl.GLException; import jogamp.opengl.Debug; -import com.jogamp.common.util.LongIntHashMap; +import com.jogamp.common.util.LongObjectHashMap; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; /** @@ -54,11 +54,26 @@ import com.jogamp.nativewindow.egl.EGLGraphicsDevice; public class EGLDisplayUtil { protected static final boolean DEBUG = Debug.debug("EGLDisplayUtil"); - static LongIntHashMap eglDisplayCounter; + private static class DpyCounter { + final long eglDisplay; + final Throwable createdStack; + int refCount; + + private DpyCounter(long eglDisplay) { + this.eglDisplay = eglDisplay; + this.refCount = 0; + this.createdStack = DEBUG ? new Throwable() : null; + } + + public String toString() { + return "EGLDisplay[0x"+Long.toHexString(eglDisplay)+": refCnt "+refCount+"]"; + } + } + static final LongObjectHashMap eglDisplayCounter; static { - eglDisplayCounter = new LongIntHashMap(); - eglDisplayCounter.setKeyNotFoundValue(0); + eglDisplayCounter = new LongObjectHashMap(); + eglDisplayCounter.setKeyNotFoundValue(null); } /** @@ -80,9 +95,13 @@ public class EGLDisplayUtil { public static void dumpOpenDisplayConnections() { System.err.println("EGLDisplayUtil: Open EGL Display Connections: "+eglDisplayCounter.size()); int i=0; - for(Iterator iter = eglDisplayCounter.iterator(); iter.hasNext(); i++) { - final LongIntHashMap.Entry e = iter.next(); - System.err.println("EGLDisplayUtil: Open["+i+"]: 0x"+Long.toHexString(e.key)+": refCnt "+e.value); + for(Iterator iter = eglDisplayCounter.iterator(); iter.hasNext(); i++) { + final LongObjectHashMap.Entry e = iter.next(); + final DpyCounter v = (DpyCounter) e.value; + System.err.println("EGLDisplayUtil: Open["+i+"]: 0x"+Long.toHexString(e.key)+": "+v); + if(null != v.createdStack) { + v.createdStack.printStackTrace(); + } } } @@ -108,18 +127,32 @@ public class EGLDisplayUtil { if( EGL.EGL_NO_DISPLAY == eglDisplay) { return false; } - final boolean res; - final int refCnt = eglDisplayCounter.get(eglDisplay) + 1; // 0 + 1 = 1 -> 1st init + final int refCnt; + final DpyCounter d; + { + DpyCounter _d = (DpyCounter) eglDisplayCounter.get(eglDisplay); + if(null == _d) { + _d = new DpyCounter(eglDisplay); + refCnt = 1; // 1st init + } else { + refCnt = _d.refCount + 1; + } + d = _d; + } + final boolean res; if(1==refCnt) { // only initialize once res = EGL.eglInitialize(eglDisplay, major, minor); } else { res = true; - } - if(res) { // map if successfully initialized, only - eglDisplayCounter.put(eglDisplay, refCnt); + } + if(res) { // update refCount and map if successfully initialized, only + d.refCount = refCnt; + if(1 == refCnt) { + eglDisplayCounter.put(eglDisplay, d); + } } if(DEBUG) { - System.err.println("EGLDisplayUtil.eglInitialize2("+EGLContext.toHexString(eglDisplay)+" ...): #"+refCnt+" = "+res); + System.err.println("EGLDisplayUtil.eglInitialize("+EGLContext.toHexString(eglDisplay)+" ...): #"+refCnt+", "+d+" = "+res); // Thread.dumpStack(); } return res; @@ -186,13 +219,24 @@ public class EGLDisplayUtil { return false; } final boolean res; - final int refCnt = eglDisplayCounter.get(eglDisplay) - 1; // 1 - 1 = 0 -> final terminate - if(0==refCnt) { // no terminate if still in use or already terminated + final int refCnt; + final DpyCounter d; + { + DpyCounter _d = (DpyCounter) eglDisplayCounter.get(eglDisplay); + if(null == _d) { + _d = null; + refCnt = -1; // n/a + } else { + refCnt = _d.refCount - 1; // 1 - 1 = 0 -> final terminate + } + d = _d; + } + if( 0 == refCnt ) { // no terminate if still in use or already terminated res = EGL.eglTerminate(eglDisplay); eglDisplayCounter.remove(eglDisplay); } else { if(0 < refCnt) { // no negative refCount - eglDisplayCounter.put(eglDisplay, refCnt); + d.refCount = refCnt; } res = true; } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index d65f8c231..99b629d1a 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -315,13 +315,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected abstract int lockSurfaceImpl() throws NativeWindowException; protected void dumpJAWTInfo() { - if(null != jawt) { - System.err.println("JAWT version: 0x"+Integer.toHexString(jawt.getCachedVersion())+ - ", CA_LAYER: "+ JAWTUtil.isJAWTUsingOffscreenLayer(jawt)+ - ", isLayeredSurface "+isOffscreenLayerSurfaceEnabled()+", bounds "+bounds+", insets "+insets); - } else { - System.err.println("JAWT n/a, bounds "+bounds+", insets "+insets); - } + System.err.println(jawt2String(null).toString()); // Thread.dumpStack(); } @@ -555,15 +549,32 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return component.hasFocus(); } + protected StringBuilder jawt2String(StringBuilder sb) { + if( null == sb ) { + sb = new StringBuilder(); + } + if(null != jawt) { + sb.append("JAWT version: 0x").append(Integer.toHexString(jawt.getCachedVersion())). + append(", CA_LAYER: ").append(JAWTUtil.isJAWTUsingOffscreenLayer(jawt)). + append(", isLayeredSurface ").append(isOffscreenLayerSurfaceEnabled()).append(", bounds ").append(bounds).append(", insets ").append(insets); + } else { + sb.append("JAWT n/a, bounds ").append(bounds).append(", insets ").append(insets); + } + return sb; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("JAWT-Window["+ - "windowHandle "+toHexString(getWindowHandle())+ + sb.append("JAWT-Window["); + jawt2String(sb); + sb.append( ", shallUseOffscreenLayer "+shallUseOffscreenLayer+", isOffscreenLayerSurface "+isOffscreenLayerSurface+ + ", attachedSurfaceLayer "+toHexString(getAttachedSurfaceLayer())+ + ", windowHandle "+toHexString(getWindowHandle())+ ", surfaceHandle "+toHexString(getSurfaceHandle())+ - ", bounds "+bounds+", insets "+insets+ - ", shallUseOffscreenLayer "+shallUseOffscreenLayer+", isOffscreenLayerSurface "+isOffscreenLayerSurface); + ", bounds "+bounds+", insets "+insets + ); if(null!=component) { sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ ", visible "+component.isVisible()); diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 3c10859bf..9d5a878c6 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -416,7 +416,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } } - if( ( removeNotify || windowClosing ) && null!=jawtWindow) { + if( ( removeNotify || windowClosing ) && null!=jawtWindow ) { NewtFactoryAWT.destroyNativeWindow(jawtWindow); jawtWindow=null; } -- cgit v1.2.3 From dd705f1eb14b87b207e375ea0d71e00155a9933f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 14 Mar 2013 11:26:10 +0100 Subject: OSX/CALayer: Simplify FixCALayerLayout()/layoutSurfaceLayer() call, no more need for explicit call - OffscreenLayerSurface.layoutSurfaceLayer() removed, no more required - JAWTWindow adds a ComponentListener, which issues FixCALayerLayout() at resized, moved and shown. - MyNSOpenGLLayer no more requires fix*Size() methods - MyNSOpenGLLayer::setDedicatedSize() need no explicit CATransaction, performed by caller. --- .../classes/javax/media/opengl/awt/GLCanvas.java | 8 ++- .../macosx/MacOSXWindowSystemInterface-calayer.m | 63 +--------------------- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 46 +++++++++++++--- .../media/nativewindow/OffscreenLayerSurface.java | 15 ------ .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 2 +- .../jogamp/nativewindow/macosx/OSXUtil.java | 3 +- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 3 -- 7 files changed, 46 insertions(+), 94 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 63c18db5d..278e2dc37 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -434,8 +434,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing _lock.lock(); try { final GLDrawable _drawable = drawable; - if( null == _drawable || realized && ( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) ) { - return; + if( null == _drawable || realized == _drawable.isRealized() || + realized && ( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) ) { + return; } _drawable.setRealized(realized); if( realized && _drawable.isRealized() ) { @@ -705,9 +706,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock - if(null != jawtWindow && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { - jawtWindow.layoutSurfaceLayer(); - } } } } diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index f93f15241..125ca8af8 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -192,8 +192,6 @@ extern GLboolean glIsVertexArray (GLuint array); - (void) applyNewPBuffer; - (void)setDedicatedSize:(CGSize)size; // @NWDedicatedSize -- (CGRect)fixMyFrame; -- (CGRect)fixSuperPosition; - (id)actionForKey:(NSString *)key ; - (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask; - (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat; @@ -364,14 +362,6 @@ static const GLfloat gl_verts[] = { if(_texHeight != texHeight || _texWidth != texWidth) { texWidth = _texWidth; texHeight = _texHeight; - /** - CGRect lRect = [self bounds]; - lRect.origin.x = 0; - lRect.origin.y = 0; - lRect.size.width = texWidth; - lRect.size.height = texHeight; - [self setFrame: lRect]; */ - CGRect lRect = [self fixMyFrame]; GLfloat texCoordWidth, texCoordHeight; if(NULL != pbuffer) { @@ -394,13 +384,13 @@ static const GLfloat gl_verts[] = { gl_texCoords[4] = texCoordWidth; gl_texCoords[6] = texCoordWidth; #ifdef VERBOSE_ON + CGRect lRect = [self bounds]; DBG_PRINT("MyNSOpenGLLayer::validateTexSize %p -> tex %dx%d, bounds: %lf/%lf %lfx%lf\n", self, texWidth, texHeight, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); #endif return YES; } else { - [self fixMyFrame]; return NO; } } @@ -549,16 +539,11 @@ static const GLfloat gl_verts[] = { DBG_PRINT("MyNSOpenGLLayer::setDedicatedSize: %p, texSize %dx%d <- %lfx%lf\n", self, texWidth, texHeight, size.width, size.height); - [CATransaction begin]; - [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; - dedicatedWidth = size.width; dedicatedHeight = size.height; CGRect rect = CGRectMake(0, 0, dedicatedWidth, dedicatedHeight); [self setFrame: rect]; - - [CATransaction commit]; } - (void) setFrame:(CGRect) frame { @@ -566,52 +551,6 @@ static const GLfloat gl_verts[] = { [super setFrame: rect]; } -- (CGRect)fixMyFrame -{ - CGRect lRect = [self frame]; - - // With Java7 our root CALayer's frame gets off-limit -> force 0/0 origin! - if( lRect.origin.x!=0 || lRect.origin.y!=0 || lRect.size.width!=texWidth || lRect.size.height!=texHeight) { - DBG_PRINT("MyNSOpenGLLayer::fixMyFrame: %p, 0/0 texSize %dx%d -> Frame[%lf/%lf %lfx%lf]\n", - self, texWidth, texHeight, - lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); - - [CATransaction begin]; - [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; - - lRect.origin.x = 0; - lRect.origin.y = 0; - lRect.size.width=texWidth; - lRect.size.height=texHeight; - [self setFrame: lRect]; - - [CATransaction commit]; - } - return lRect; -} - -- (CGRect)fixSuperPosition -{ - CALayer * superL = [self superlayer]; - CGRect lRect = [superL frame]; - - // With Java7 our root CALayer's frame gets off-limit -> force 0/0 origin! - if( lRect.origin.x!=0 || lRect.origin.y!=0 ) { - DBG_PRINT("MyNSOpenGLLayer::fixSuperPosition: %p, 0/0 -> Super Frame[%lf/%lf %lfx%lf]\n", - self, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); - - [CATransaction begin]; - [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; - - lRect.origin.x = 0; - lRect.origin.y = 0; - [superL setPosition: lRect.origin]; - - [CATransaction commit]; - } - return lRect; -} - - (id)actionForKey:(NSString *)key { DBG_PRINT("MyNSOpenGLLayer::actionForKey.0 %p key %s -> NIL\n", self, [key UTF8String]); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 99b629d1a..3e5e629b6 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -43,6 +43,8 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration; import java.awt.Component; import java.awt.Container; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; import java.applet.Applet; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -110,6 +112,25 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, this.component = windowObject; this.isApplet = false; this.offscreenSurfaceLayer = 0; + this.component.addComponentListener(new ComponentListener() { + @Override + public void componentResized(ComponentEvent e) { + layoutSurfaceLayerIfEnabled(); + } + + @Override + public void componentMoved(ComponentEvent e) { + layoutSurfaceLayerIfEnabled(); + } + + @Override + public void componentShown(ComponentEvent e) { + layoutSurfaceLayerIfEnabled(); + } + + @Override + public void componentHidden(ComponentEvent e) { } + }); } protected synchronized void invalidate() { @@ -215,16 +236,27 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } protected abstract void attachSurfaceLayerImpl(final long layerHandle); - @Override - public void layoutSurfaceLayer() throws NativeWindowException { - if( !isOffscreenLayerSurfaceEnabled() ) { - throw new NativeWindowException("Not an offscreen layer surface"); - } - if( 0 != offscreenSurfaceLayer) { + /** + * Layout the offscreen layer according to the implementing class's constraints. + *

    + * This method allows triggering a re-layout of the offscreen surface + * in case the implementation requires it. + *

    + *

    + * Call this method if any parent or ancestor's layout has been changed, + * which could affects the layout of this surface. + *

    + * @see #isOffscreenLayerSurfaceEnabled() + * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false + */ + protected void layoutSurfaceLayerImpl() {} + + private final void layoutSurfaceLayerIfEnabled() throws NativeWindowException { + if( isOffscreenLayerSurfaceEnabled() && 0 != offscreenSurfaceLayer ) { layoutSurfaceLayerImpl(); } } - protected void layoutSurfaceLayerImpl() {} + @Override public final void detachSurfaceLayer() throws NativeWindowException { diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index df3f04f7f..8c02a68bb 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -42,21 +42,6 @@ public interface OffscreenLayerSurface { */ public void attachSurfaceLayer(final long layerHandle) throws NativeWindowException; - /** - * Layout the offscreen layer according to the implementing class's constraints. - *

    - * This method allows triggering a re-layout of the offscreen surface - * in case the implementation requires it. - *

    - *

    - * Call this method if any parent or ancestor's layout has been changed, - * which could affects the layout of this surface. - *

    - * @see #isOffscreenLayerSurfaceEnabled() - * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false - */ - public void layoutSurfaceLayer() throws NativeWindowException; - /** * Detaches a previously attached offscreen layer from this offscreen layer surface. * @see #attachSurfaceLayer(long) diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index c8f758165..758105713 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -117,7 +117,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } protected void attachSurfaceLayerImpl(final long layerHandle) { - OSXUtil.AddCASublayer(rootSurfaceLayerHandle, layerHandle); + OSXUtil.AddCASublayer(rootSurfaceLayerHandle, layerHandle, getWidth(), getHeight()); } protected void layoutSurfaceLayerImpl() { diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 59b42c249..1563a5a8b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -158,13 +158,14 @@ public class OSXUtil implements ToolkitProperties { * @see #CreateCALayer(int, int, int, int) * @see #RemoveCASublayer(long, long) */ - public static void AddCASublayer(final long rootCALayer, final long subCALayer) { + public static void AddCASublayer(final long rootCALayer, final long subCALayer, final int width, final int height) { if(0==rootCALayer || 0==subCALayer) { throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer)); } RunOnMainThread(false, new Runnable() { public void run() { AddCASublayer0(rootCALayer, subCALayer); + FixCALayerLayout0(rootCALayer, subCALayer, width, height); } }); } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 9d5a878c6..d902b0f09 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -445,9 +445,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } if( validateComponent(true, null) ) { // newtChild.setSize(width, height); - if(null != jawtWindow && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { - jawtWindow.layoutSurfaceLayer(); - } } } } -- cgit v1.2.3 From 538a41849192cc09da36eeaa5fa9ae10973d85b7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 14 Mar 2013 17:22:22 +0100 Subject: Fix NEWT WindowImpl reparent-recreate w/ GLEventListenerState: Bug introduced w/ commit e2506d7663b752f00f0a98f793ebad52e65bd1e3 In case a reparent action takes place w/ recreate, only preserve the GLEventListenerState if the window is valid and will become visible again (wasVisible). Also add proper DEBUG log prefix to GLEventListenerState. --- .../com/jogamp/opengl/util/GLEventListenerState.java | 16 ++++++++-------- src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java | 5 ++++- src/newt/classes/jogamp/newt/WindowImpl.java | 17 +++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLEventListenerState.java b/src/jogl/classes/com/jogamp/opengl/util/GLEventListenerState.java index ff250d27f..5b02e1fec 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLEventListenerState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLEventListenerState.java @@ -159,7 +159,7 @@ public class GLEventListenerState { final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); final AbstractGraphicsScreen aScreen2 = cloneScreen(aScreen1); if( DEBUG ) { - System.err.println("X00 NativeSurface: "+aSurface.getClass().getName()+", "+aSurface); + System.err.println("GLEventListenerState.moveFrom.0: "+aSurface.getClass().getName()+", "+aSurface); } aScreen1.getDevice().clearHandleOwner(); // don't close device handle @@ -172,7 +172,7 @@ public class GLEventListenerState { proxyOwnsUpstreamDevice = aProxy.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); final NativeSurface aUpSurface = aProxy.getUpstreamSurface(); if(DEBUG && null != aUpSurface) { - System.err.println("X00 UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface); + System.err.println("GLEventListenerState.moveFrom.1: "+aUpSurface.getClass().getName()+", "+aUpSurface); } if(null != aUpSurface) { final AbstractGraphicsScreen aUpScreen1 = aUpSurface.getGraphicsConfiguration().getScreen(); @@ -181,8 +181,8 @@ public class GLEventListenerState { aUpScreen1.getDevice().clearHandleOwner(); // don't close device handle } if(DEBUG) { - System.err.println("X0X NativeSurface: "+aSurface.getClass().getName()+", "+aSurface); - System.err.println("X0X UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface); + System.err.println("GLEventListenerState.moveFrom.2: "+aSurface.getClass().getName()+", "+aSurface); + System.err.println("GLEventListenerState.moveFrom.3: "+aUpSurface.getClass().getName()+", "+aUpSurface); } } } else { @@ -256,13 +256,13 @@ public class GLEventListenerState { // Set new Screen and close previous one { if( DEBUG ) { - System.err.println("XX0 NativeSurface: "+aSurface.getClass().getName()+", "+aSurface); + System.err.println("GLEventListenerState.moveTo.0: "+aSurface.getClass().getName()+", "+aSurface); } final AbstractGraphicsScreen aScreen1 = aCfg.getScreen(); aCfg.setScreen( screen ); aScreen1.getDevice().close(); if( DEBUG ) { - System.err.println("XXX NativeSurface: "+aSurface.getClass().getName()+", "+aSurface); + System.err.println("GLEventListenerState.moveTo.1: "+aSurface.getClass().getName()+", "+aSurface); } } @@ -276,7 +276,7 @@ public class GLEventListenerState { final MutableGraphicsConfiguration aUpCfg = (MutableGraphicsConfiguration) aUpSurface.getGraphicsConfiguration(); if( null != upstreamScreen ) { if( DEBUG ) { - System.err.println("XX0 UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); + System.err.println("GLEventListenerState.moveTo.2: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); } aUpCfg.getScreen().getDevice().close(); aUpCfg.setScreen( upstreamScreen ); @@ -285,7 +285,7 @@ public class GLEventListenerState { } upstreamSet = true; if( DEBUG ) { - System.err.println("XXX UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); + System.err.println("GLEventListenerState.moveTo.3: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); } } else { throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = false, New-Holder = true"); diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index e6652cfac..592607819 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -109,6 +109,9 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { * {@link #pullGLEventListenerState() pull} to preserve the {@link GLEventListenerState}. */ public final void setPreserveGLStateAtDestroy(boolean value) { + if( DEBUG ) { + System.err.println("GLAutoDrawableBase.setPreserveGLStateAtDestroy: ("+Thread.currentThread().getName()+"): "+preserveGLELSAtDestroy+" -> "+value+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + } preserveGLELSAtDestroy = value; } @@ -283,7 +286,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { */ protected void destroyImplInLock() { if( preserveGLELSAtDestroy ) { - preserveGLELSAtDestroy = false; + setPreserveGLStateAtDestroy(false); pullGLEventListenerState(); } if( null != context ) { diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index dfaa55679..448b192a2 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1066,9 +1066,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(null==newParentWindowNEWT) { throw new NativeWindowException("Reparenting with non NEWT Window type only available after it's realized: "+newParentWindow); } - // Destroy this window and use parent's Screen, while trying to preserve resources. + // Destroy this window and use parent's Screen. // It may be created properly when the parent is made visible. - destroy(true); + destroy(false); setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); operation = ReparentOperation.ACTION_NATIVE_CREATION_PENDING; } else if(newParentWindow != getParent()) { @@ -1091,8 +1091,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer operation = ReparentOperation.ACTION_NATIVE_CREATION_PENDING; } } else if ( forceDestroyCreate || !NewtFactory.isScreenCompatible(newParentWindow, screen) ) { - // Destroy this window, may create a new compatible Screen/Display, while trying to preserve resources. - destroy(true); + // Destroy this window, may create a new compatible Screen/Display, while trying to preserve resources if becoming visible again. + destroy( wasVisible ); if(null!=newParentWindowNEWT) { setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); } else { @@ -1121,8 +1121,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Already Top Window operation = ReparentOperation.ACTION_NOP; } else if( !isNativeValid() || forceDestroyCreate ) { - // Destroy this window and mark it for [pending] creation, while trying to preserve resources. - destroy(true); + // Destroy this window and mark it for [pending] creation. + // If isNativeValid() and becoming visible again - try to preserve resources, i.e. b/c on-/offscreen switch. + destroy( isNativeValid() && wasVisible ); if( 0 < width && 0 < height ) { operation = ReparentOperation.ACTION_NATIVE_CREATION; } else { @@ -1225,11 +1226,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(!ok) { - // native reparent failed -> try creation, while trying to preserve resources. + // native reparent failed -> try creation, while trying to preserve resources if becoming visible again. if(DEBUG_IMPLEMENTATION) { System.err.println("Window.reparent: native reparenting failed ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+" -> "+toHexString(newParentWindowHandle)+" - Trying recreation"); } - destroy(true); + destroy( wasVisible ); operation = ReparentOperation.ACTION_NATIVE_CREATION ; } } -- cgit v1.2.3 From ed911109d40e0fca3b2263a4617f35d475612549 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Mar 2013 03:09:15 +0100 Subject: Adapt to GlueGen commit b1eb7ca6b9d7dec7ff62c1f1e8ef0a0545724d2f: Function- RunnableTask adds PrintStream 'exceptionOut' argument in ctor. --- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 5 +++-- src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 3 ++- src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java | 3 ++- .../opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java | 2 +- .../jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java | 2 +- .../jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java | 3 +-- 6 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index d8d04e79f..3c015d3ec 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -178,7 +178,7 @@ public class DefaultEDTUtil implements EDTUtil { // drop task and don't wait task = null; System.err.println(Thread.currentThread()+": Warning: Default-EDT is about (3) to stop and stopped already, dropping task. Remaining tasks: "+edt.tasks.size()+" - "+edt); - if(true || DEBUG) { + if(DEBUG) { Thread.dumpStack(); } } @@ -190,7 +190,8 @@ public class DefaultEDTUtil implements EDTUtil { synchronized(edt.tasks) { rTask = new RunnableTask(task, wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */); + true /* always catch and report Exceptions, don't disturb EDT */, + wait ? null : System.err); if(stop) { rTask.setAttachment(new Boolean(true)); // mark final task, will imply shouldStop:=true } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index cecb1dd7e..fc9bbb848 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -160,7 +160,8 @@ public class AWTEDTUtil implements EDTUtil { } else { rTask = new RunnableTask(task, wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */); + true /* always catch and report Exceptions, don't disturb EDT */, + wait ? null : System.err); AWTEDTExecutor.singleton.invoke(false, rTask); } } diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java index 7297e5858..2008b5ea4 100644 --- a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java @@ -172,7 +172,8 @@ public class SWTEDTUtil implements EDTUtil { } else { rTask = new RunnableTask(task, wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */); + true /* always catch and report Exceptions, don't disturb EDT */, + wait ? null : System.err); swtDisplay.asyncExec(rTask); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java index eab1a37e3..43415136d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java @@ -80,7 +80,7 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase { Assert.assertTrue(EventQueue.isDispatchThread()); JAWTUtil.lockToolkit(); try { - final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false); + final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false, null); System.err.println("BB.0: "+rTask.getSyncObject()); synchronized (rTask.getSyncObject()) { System.err.println("BB.1: "+rTask.getSyncObject()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java index 90934f1b5..3f97cbc54 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPBufferDeadlockAWT.java @@ -81,7 +81,7 @@ public class TestPBufferDeadlockAWT extends UITestCase { Assert.assertTrue(EventQueue.isDispatchThread()); JAWTUtil.lockToolkit(); try { - final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false); + final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false, null); System.err.println("BB.0: "+rTask.getSyncObject()); synchronized (rTask.getSyncObject()) { System.err.println("BB.1: "+rTask.getSyncObject()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index 4dd3bb98a..05a24272c 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -33,7 +33,6 @@ import java.util.ArrayList ; import javax.media.opengl.GLProfile ; -import org.junit.After; import org.junit.Assert ; import org.junit.BeforeClass ; import org.junit.Test ; @@ -342,7 +341,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { Throwable throwable = null; // final Object sync = new Object(); - final RunnableTask rt = new RunnableTask( testAction, null, true ); + final RunnableTask rt = new RunnableTask( testAction, null, true, System.err ); try { // synchronized(sync) { new Thread(rt, "Test-Thread").start(); -- cgit v1.2.3 From f354fb204d8973453c538dda78a2c82c87be61dc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 19 Mar 2013 00:22:28 +0100 Subject: OSX/CALayer: OSX/CALayer Threading Part3 - Run CALayer ops in a streaming design on main-thread w/o [infinitive] blocking History: Part1 commit 896e8b021b39e9415040a57a1d540d7d24b02db1 (Run CALayer Ops on current thread to avoid blocking) Part2 commit 28c6472335b924080d638b33a28f8f4eedb459b1 (Run CALayer Ops on main-thread w/o blocking) Dependency: GlueGen commit 4becdfa125b07ff969d6540e1112735b53cd15eb (Fix RecursiveLockImpl* Timeout corner case) Part2 misses essential locking of the OpenGL context (and it's surface upfront) while creating the NSOpenGLLayer instance. The latter instantiates a OpenGL context shared w/ JOGL's, hence it cannot be locked. Encapsulating NSOpenGLLayer creation/attachment and it's detachment/release in sub-classes AttachNSOpenGLLayer and DetachNSOpenGLLayer, where instances will be streamed on main-thread. Both tasks are triggered at associateDrawable(boolean bound). The mentioned GL context locking requires disturbs the 'streaming' design considerably in AttachNSOpenGLLayer. It is solved by attempt to acquire the recursive lock of the surface and the context via 'tryLock(maxwait)' w/ screen-vSync-period/2. If the locks could not be acquired completly, the AttachNSOpenGLLayer instance will be re-queued to the main-thread for later execution. Before DetachNSOpenGLLayer is being streamed, it is validated whether AttachNSOpenGLLayer did run. A recursive situation does happen w/ resizing an offscreen pbuffer drawable! Hence extra care is being taken. --- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 2 +- .../classes/jogamp/opengl/GLDrawableHelper.java | 2 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 358 +++++++++++++-------- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 73 ++--- .../media/nativewindow/OffscreenLayerSurface.java | 5 + .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 58 ++-- .../jawt/windows/WindowsJAWTWindow.java | 7 - .../nativewindow/jawt/x11/X11JAWTWindow.java | 7 - .../jogamp/nativewindow/macosx/OSXUtil.java | 64 +++- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 9 +- .../acore/TestAddRemove01GLCanvasSwingAWT.java | 52 ++- .../TestAddRemove02GLWindowNewtCanvasAWT.java | 47 ++- ...TestSwingAWTRobotUsageBeforeJOGLInitBug411.java | 10 +- .../junit/newt/parenting/TestParenting04AWT.java | 4 + 14 files changed, 439 insertions(+), 259 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 4121e8f77..64ade3eff 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -367,7 +367,7 @@ public abstract class GLContextImpl extends GLContext { try { // release current context if(lock.getHoldCount() == 1) { - // needs current context to disable debug handler + // needs current context to call associateDrawable(..) and to disable debug handler makeCurrent(); } try { diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 1caa942ba..9c1cd478b 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -190,7 +190,7 @@ public class GLDrawableHelper { *
  • make context current, if it was current
  • * *

    - * No locking is being performed, caller is required to take care of it. + * Locking is performed via {@link GLContext#makeCurrent()} on the passed context. *

    * * @param drawable diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index f01e03a2f..33893e456 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -71,6 +71,7 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionNumber; +import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; import com.jogamp.opengl.GLExtensions; @@ -461,10 +462,13 @@ public abstract class MacOSXCGLContext extends GLContextImpl // NSOpenGLContext-based implementation class NSOpenGLImpl implements GLBackendImpl { - private long pixelFormat = 0; // lifecycle: [create - destroy] - private volatile long nsOpenGLLayer = 0; // lifecycle: [associateDrawable_true - associateDrawable_false] - private float screenVSyncTimeout = 16666; // microSec - defaults to 1/60s - private volatile int vsyncTimeout = 16666 + 1000; // microSec - for nsOpenGLLayer mode - defaults to 1/60s + 1ms + private OffscreenLayerSurface backingLayerHost = null; + /** lifecycle: [create - destroy] */ + private long pixelFormat = 0; + /** microSec - defaults to 1/60s */ + private int screenVSyncTimeout = 16666; + /** microSec - for nsOpenGLLayer mode - defaults to 1/60s + 1ms */ + private volatile int vsyncTimeout = 16666 + 1000; private int lastWidth=0, lastHeight=0; // allowing to detect size change private boolean needsSetContextPBuffer = false; private ShaderProgram gl3ShaderProgram = null; @@ -562,7 +566,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl } final int sRefreshRate = OSXUtil.GetScreenRefreshRate(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getIndex()); if( 0 < sRefreshRate ) { - screenVSyncTimeout = 1000000f / sRefreshRate; + screenVSyncTimeout = 1000000 / sRefreshRate; } if(DEBUG) { System.err.println("NS create OSX>=lion "+isLionOrLater); @@ -608,32 +612,147 @@ public abstract class MacOSXCGLContext extends GLContextImpl return CGL.deleteContext(ctx, true); } + /** + * NSOpenGLLayer creation and it's attachment is performed on the main-thread w/o [infinite] blocking. + *

    + * Since NSOpenGLLayer creation requires this context for it's shared context creation, + * this method attempts to acquire the surface and context lock with {@link #screenVSyncTimeout}/2 maximum wait time. + * If the surface and context lock could not be acquired, this runnable is being re-queued for later execution. + *

    + *

    + * Hence this method blocks the main-thread only for a short period of time. + *

    + */ + class AttachNSOpenGLLayer implements Runnable { + final OffscreenLayerSurface ols; + final long ctx; + final int shaderProgram; + final long pfmt; + final long pbuffer; + final int texID; + final boolean isOpaque; + final int width; + final int height; + /** Synchronized by instance's monitor */ + long nsOpenGLLayer; + /** Synchronized by instance's monitor */ + boolean valid; + + AttachNSOpenGLLayer(OffscreenLayerSurface ols, long ctx, int shaderProgram, long pfmt, long pbuffer, int texID, boolean isOpaque, int width, int height) { + this.ols = ols; + this.ctx = ctx; + this.shaderProgram = shaderProgram; + this.pfmt = pfmt; + this.pbuffer = pbuffer; + this.texID = texID; + this.isOpaque = isOpaque; + this.width = width; + this.height = height; + this.valid = false; + this.nsOpenGLLayer = 0; + } + + @Override + public void run() { + synchronized(this) { + if( !valid ) { + try { + final int maxwait = screenVSyncTimeout/2000; // TO 1/2 of current screen-vsync in [ms] + final RecursiveLock surfaceLock = ols.getLock(); + if( surfaceLock.tryLock( maxwait ) ) { + try { + if( MacOSXCGLContext.this.lock.tryLock( maxwait ) ) { + try { + nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, shaderProgram, pfmt, pbuffer, texID, isOpaque, width, height); + ols.attachSurfaceLayer(nsOpenGLLayer); + final int currentInterval = MacOSXCGLContext.this.getSwapInterval(); + final int interval = 0 <= currentInterval ? currentInterval : 1; + setSwapIntervalImpl(nsOpenGLLayer, interval); // enabled per default in layered surface + valid = true; + if (DEBUG) { + System.err.println("NSOpenGLLayer.Attach: OK, layer "+toHexString(nsOpenGLLayer)+" w/ pbuffer "+toHexString(pbuffer)+", texID "+texID+", texSize "+lastWidth+"x"+lastHeight+", drawableHandle "+toHexString(drawable.getHandle())+" - "+Thread.currentThread().getName()); + } + } finally { + MacOSXCGLContext.this.lock.unlock(); + } + } + } finally { + surfaceLock.unlock(); + } + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + if( !valid ) { + // could not acquire lock, re-queue + if (DEBUG) { + System.err.println("NSOpenGLLayer.Attach: Re-Queue, drawableHandle "+toHexString(drawable.getHandle())+" - "+Thread.currentThread().getName()); + } + OSXUtil.RunLater(this, 1); + } + } + } + } + } + AttachNSOpenGLLayer attachCALayerCmd = null; + + class DetachNSOpenGLLayer implements Runnable { + final AttachNSOpenGLLayer cmd; + + DetachNSOpenGLLayer(AttachNSOpenGLLayer cmd) { + this.cmd = cmd; + } + @Override + public void run() { + synchronized( cmd ) { + if( cmd.valid ) { + // still having a valid OLS attached to surface (parent OLS could have been removed) + try { + final OffscreenLayerSurface ols = cmd.ols; + final long l = ols.getAttachedSurfaceLayer(); + if( 0 != l ) { + ols.detachSurfaceLayer(); + } + } catch(Throwable t) { + System.err.println("Catched exception @ "+Thread.currentThread().getName()+": "); + t.printStackTrace(); + } + CGL.releaseNSOpenGLLayer(cmd.nsOpenGLLayer); + if(DEBUG) { + System.err.println("NSOpenGLLayer.Detach: OK, layer "+toHexString(cmd.nsOpenGLLayer)+", drawableHandle "+toHexString(drawable.getHandle())+" - "+Thread.currentThread().getName()); + } + cmd.nsOpenGLLayer = 0; + cmd.valid = false; + } else if(DEBUG) { + System.err.println("NSOpenGLLayer.Detach: Skipped "+toHexString(cmd.nsOpenGLLayer)+", drawableHandle "+toHexString(drawable.getHandle())+" - "+Thread.currentThread().getName()); + } + } + } + } + @Override public void associateDrawable(boolean bound) { - final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(drawable.getNativeSurface(), true); + backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(drawable.getNativeSurface(), true); if(DEBUG) { System.err.println("MaxOSXCGLContext.NSOpenGLImpl.associateDrawable: "+bound+", ctx "+toHexString(contextHandle)+", hasBackingLayerHost "+(null!=backingLayerHost)); + // Thread.dumpStack(); } if( bound ) { - if( null != backingLayerHost ) { - if( 0 != nsOpenGLLayer ) { // FIXME: redundant - throw new InternalError("Lifecycle: bound=true, hasBackingLayerHost=true, but 'nsOpenGLLayer' is already/still set local: "+nsOpenGLLayer+", "+this); - } - nsOpenGLLayer = backingLayerHost.getAttachedSurfaceLayer(); - if( 0 != nsOpenGLLayer ) { // FIXME: redundant - throw new InternalError("Lifecycle: bound=true, hasBackingLayerHost=true, but 'nsOpenGLLayer' is already/still set on backingLayerHost: "+nsOpenGLLayer+", "+this); - } + if( null != backingLayerHost ) { + final GLCapabilitiesImmutable chosenCaps; + final long ctx; + final int texID; + final long pbufferHandle; + final int gl3ShaderProgramName; // // handled layered surface // - final GLCapabilitiesImmutable chosenCaps = drawable.getChosenGLCapabilities(); - final long ctx = MacOSXCGLContext.this.getHandle(); - final int texID; + chosenCaps = drawable.getChosenGLCapabilities(); + ctx = MacOSXCGLContext.this.getHandle(); final long drawableHandle = drawable.getHandle(); - final long pbufferHandle; if(drawable instanceof GLFBODrawableImpl) { final GLFBODrawableImpl fbod = (GLFBODrawableImpl)drawable; texID = fbod.getTextureBuffer(GL.GL_FRONT).getName(); @@ -657,7 +776,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl if(0>=lastWidth || 0>=lastHeight || !drawable.isRealized()) { throw new GLException("Drawable not realized yet or invalid texture size, texSize "+lastWidth+"x"+lastHeight+", "+drawable); } - final int gl3ShaderProgramName; if( MacOSXCGLContext.this.isGL3core() ) { if( null == gl3ShaderProgram) { gl3ShaderProgram = createCALayerShader(MacOSXCGLContext.this.gl.getGL3()); @@ -665,88 +783,42 @@ public abstract class MacOSXCGLContext extends GLContextImpl gl3ShaderProgramName = gl3ShaderProgram.program(); } else { gl3ShaderProgramName = 0; - } + } - /** - * NSOpenGLLayer creation and it's attachment is performed on the main w/o blocking, - * due to OSX main-thread requirements. - * Note: It somewhat works from another thread, however, - * GC-dealloc of the 'released' resources would happen very late! - * - * NSOpenGLLayer initialization creates it's own GL ctx sharing - * this ctx, hence we have to lock this ctx in the main-thread. - * - * Locking of this ctx while creation and attachment - * also gives us good means of synchronization, i.e. it will be - * performed after this thread ends it's associateDrawable() [makeCurrent(), setDrawable(..)] - * and before the next display cycle involving makeCurrent(). - */ - OSXUtil.RunOnMainThread(false, new Runnable() { - public void run() { - if (DEBUG) { - System.err.println("NS create nsOpenGLLayer.0 "+Thread.currentThread().getName()); - } - final long cglCtx = CGL.getCGLContext(ctx); - if(0 == cglCtx) { - throw new GLException("Null CGLContext for: "+MacOSXCGLContext.this); - } - if( CGL.kCGLNoError != CGL.CGLLockContext(cglCtx) ) { - throw new GLException("Could not lock CGLContext for: "+MacOSXCGLContext.this); - } - try { - nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, gl3ShaderProgramName, pixelFormat, pbufferHandle, texID, chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight); - if (DEBUG) { - System.err.println("NS create nsOpenGLLayer.2 "+Thread.currentThread().getName()+": "+toHexString(nsOpenGLLayer)+" w/ pbuffer "+toHexString(pbufferHandle)+", texID "+texID+", texSize "+lastWidth+"x"+lastHeight+", "+drawable); - } - backingLayerHost.attachSurfaceLayer(nsOpenGLLayer); - setSwapInterval(1); // enabled per default in layered surface - } catch (Throwable t) { - throw new GLException("createNSOpenGLLayer failed for: "+MacOSXCGLContext.this, t); - } finally { - if(CGL.kCGLNoError != CGL.CGLUnlockContext(cglCtx)) { - throw new GLException("Could not unlock CGLContext for: "+MacOSXCGLContext.this); - } - } - if (DEBUG) { - System.err.println("NS create nsOpenGLLayer.X "+Thread.currentThread().getName()); - } - } - }); - CGL.setContextView(contextHandle, 0); // [ctx clearDrawable] + // All CALayer lifecycle ops are deferred on main-thread + attachCALayerCmd = new AttachNSOpenGLLayer( + backingLayerHost, ctx, gl3ShaderProgramName, pixelFormat, pbufferHandle, texID, + chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight ); + OSXUtil.RunOnMainThread(false, attachCALayerCmd); } else { // -> null == backingLayerHost lastWidth = drawable.getWidth(); lastHeight = drawable.getHeight(); boolean[] isPBuffer = { false }; boolean[] isFBO = { false }; - CGL.setContextView(contextHandle, getNSViewHandle(isPBuffer, isFBO)); // will call [ctx clearDrawable] if view == 0, otherwise [ctx setView: view] if valid + CGL.setContextView(contextHandle, getNSViewHandle(isPBuffer, isFBO)); } } else { // -> !bound - if( 0 != nsOpenGLLayer ) { - if( null == backingLayerHost ) { // FIXME: redundant - throw new InternalError("Lifecycle: bound=false, hasNSOpneGLLayer=true, but 'backingLayerHost' is null local: "+nsOpenGLLayer+", "+this); + if( null != backingLayerHost ) { + final AttachNSOpenGLLayer cmd = attachCALayerCmd; + attachCALayerCmd = null; + if( 0 != cmd.pbuffer ) { + CGL.setContextPBuffer(contextHandle, 0); } - - if (DEBUG) { - System.err.println("NS destroy nsOpenGLLayer "+toHexString(nsOpenGLLayer)+", "+drawable); - } - if( backingLayerHost.isSurfaceLayerAttached() ) { - // still having a valid OLS attached to surface (parent OLS could have been removed) - backingLayerHost.detachSurfaceLayer(); - } - // All CALayer lifecycle calls are deferred on main-thread, so is this. - final long _nsOpenGLLayer = nsOpenGLLayer; - nsOpenGLLayer = 0; - OSXUtil.RunOnMainThread(false, new Runnable() { - public void run() { - CGL.releaseNSOpenGLLayer(_nsOpenGLLayer); - } - }); - if( null != gl3ShaderProgram ) { - gl3ShaderProgram.destroy(MacOSXCGLContext.this.gl.getGL3()); - gl3ShaderProgram = null; + synchronized(cmd) { + if( !cmd.valid ) { + cmd.valid = true; // skip pending creation + } else { + // All CALayer lifecycle ops are deferred on main-thread + OSXUtil.RunOnMainThread(false, new DetachNSOpenGLLayer(cmd)); + if( null != gl3ShaderProgram ) { + gl3ShaderProgram.destroy(MacOSXCGLContext.this.gl.getGL3()); + gl3ShaderProgram = null; + } + } } } - CGL.setContextView(contextHandle, 0); // [ctx clearDrawable] + CGL.clearDrawable(contextHandle); + backingLayerHost = null; } } @@ -832,65 +904,83 @@ public abstract class MacOSXCGLContext extends GLContextImpl @Override public boolean setSwapInterval(int interval) { - if(0 != nsOpenGLLayer) { - CGL.setNSOpenGLLayerSwapInterval(nsOpenGLLayer, interval); + final AttachNSOpenGLLayer cmd = attachCALayerCmd; + if(null != cmd) { + synchronized(cmd) { + if( cmd.valid && 0 != cmd.nsOpenGLLayer) { + setSwapIntervalImpl(cmd.nsOpenGLLayer, interval); + return true; + } + } + } + setSwapIntervalImpl(0, interval); + return true; + } + + private void setSwapIntervalImpl(final long l, int interval) { + if( 0 != l ) { + CGL.setNSOpenGLLayerSwapInterval(l, interval); if( 0 < interval ) { - vsyncTimeout = interval * (int)screenVSyncTimeout + 1000; // +1ms + vsyncTimeout = interval * screenVSyncTimeout + 1000; // +1ms } if(DEBUG) { System.err.println("NS setSwapInterval: "+interval+" -> "+vsyncTimeout+" micros"); } } + if(DEBUG) { System.err.println("CGL setSwapInterval: "+interval); } CGL.setSwapInterval(contextHandle, interval); - return true; } - + private int skipSync=0; @Override public boolean swapBuffers() { - final boolean res; - if( 0 != nsOpenGLLayer ) { - if( validateDrawableSizeConfig(contextHandle) ) { - // skip wait-for-vsync for a few frames if size has changed, - // allowing to update the texture IDs ASAP. - skipSync = 10; - } - - final int texID; - final boolean valid; - final boolean isFBO = drawable instanceof GLFBODrawableImpl; - if( isFBO ){ - texID = ((GLFBODrawableImpl)drawable).getTextureBuffer(GL.GL_FRONT).getName(); - valid = 0 != texID; - } else { - texID = 0; - valid = 0 != drawable.getHandle(); - } - if(valid) { - if(0 == skipSync) { - // If v-sync is disabled, frames will be drawn as quickly as possible w/o delay, - // while still synchronizing w/ CALayer. - // If v-sync is enabled wait until next swap interval (v-sync). - CGL.waitUntilNSOpenGLLayerIsReady(nsOpenGLLayer, vsyncTimeout); - } else { - skipSync--; - } - res = CGL.flushBuffer(contextHandle); - if(res) { - if(isFBO) { - // trigger CALayer to update incl. possible surface change (texture) - CGL.setNSOpenGLLayerNeedsDisplayFBO(nsOpenGLLayer, texID); + final AttachNSOpenGLLayer cmd = attachCALayerCmd; + if(null != cmd) { + synchronized(cmd) { + if( cmd.valid && 0 != cmd.nsOpenGLLayer) { + if( validateDrawableSizeConfig(contextHandle) ) { + // skip wait-for-vsync for a few frames if size has changed, + // allowing to update the texture IDs ASAP. + skipSync = 10; + } + + final boolean res; + final int texID; + final boolean valid; + final boolean isFBO = drawable instanceof GLFBODrawableImpl; + if( isFBO ){ + texID = ((GLFBODrawableImpl)drawable).getTextureBuffer(GL.GL_FRONT).getName(); + valid = 0 != texID; + } else { + texID = 0; + valid = 0 != drawable.getHandle(); + } + if(valid) { + res = CGL.flushBuffer(contextHandle); + if(res) { + if(0 == skipSync) { + // If v-sync is disabled, frames will be drawn as quickly as possible w/o delay, + // while still synchronizing w/ CALayer. + // If v-sync is enabled wait until next swap interval (v-sync). + CGL.waitUntilNSOpenGLLayerIsReady(cmd.nsOpenGLLayer, vsyncTimeout); + } else { + skipSync--; + } + if(isFBO) { + // trigger CALayer to update incl. possible surface change (texture) + CGL.setNSOpenGLLayerNeedsDisplayFBO(cmd.nsOpenGLLayer, texID); + } else { + // trigger CALayer to update incl. possible surface change (new pbuffer handle) + CGL.setNSOpenGLLayerNeedsDisplayPBuffer(cmd.nsOpenGLLayer, drawable.getHandle()); + } + } } else { - // trigger CALayer to update incl. possible surface change (new pbuffer handle) - CGL.setNSOpenGLLayerNeedsDisplayPBuffer(nsOpenGLLayer, drawable.getHandle()); + res = true; } + return res; } - } else { - res = true; } - } else { - res = CGL.flushBuffer(contextHandle); } - return res; + return CGL.flushBuffer(contextHandle); } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 15a0f550f..16d4a07ef 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -85,7 +85,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected long drawable; protected Rectangle bounds; protected Insets insets; - private long offscreenSurfaceLayer; + private volatile long offscreenSurfaceLayer; private long drawable_old; @@ -135,12 +135,12 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected synchronized void invalidate() { if(DEBUG) { - System.err.println("JAWTWindow.invalidate()"); + System.err.println("JAWTWindow.invalidate() - "+Thread.currentThread().getName()); + if( isSurfaceLayerAttached() ) { + System.err.println("OffscreenSurfaceLayer still attached: 0x"+Long.toHexString(offscreenSurfaceLayer)); + } // Thread.dumpStack(); } - if( isSurfaceLayerAttached() ) { - detachSurfaceLayer(); - } invalidateNative(); jawt = null; isOffscreenLayerSurface = false; @@ -227,21 +227,16 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if( !isOffscreenLayerSurfaceEnabled() ) { throw new NativeWindowException("Not an offscreen layer surface"); } - int lockRes = lockSurface(); - if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { - throw new NativeWindowException("Could not lock (offscreen layer): "+this); - } - try { - if(DEBUG) { - System.err.println("JAWTWindow.attachSurfaceHandle: "+toHexString(layerHandle) + ", bounds "+bounds); - } - attachSurfaceLayerImpl(layerHandle); - offscreenSurfaceLayer = layerHandle; - } finally { - unlockSurface(); + if(DEBUG) { + System.err.println("JAWTWindow.attachSurfaceHandle: "+toHexString(layerHandle) + ", bounds "+bounds); } + attachSurfaceLayerImpl(layerHandle); + offscreenSurfaceLayer = layerHandle; + layoutSurfaceLayerImpl(layerHandle, getWidth(), getHeight()); + } + protected void attachSurfaceLayerImpl(final long layerHandle) { + throw new UnsupportedOperationException("offscreen layer not supported"); } - protected abstract void attachSurfaceLayerImpl(final long layerHandle); /** * Layout the offscreen layer according to the implementing class's constraints. @@ -256,38 +251,39 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, * @see #isOffscreenLayerSurfaceEnabled() * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false */ - protected void layoutSurfaceLayerImpl() {} + protected void layoutSurfaceLayerImpl(long layerHandle, int width, int height) {} private final void layoutSurfaceLayerIfEnabled() throws NativeWindowException { if( isOffscreenLayerSurfaceEnabled() && 0 != offscreenSurfaceLayer ) { - layoutSurfaceLayerImpl(); + layoutSurfaceLayerImpl(offscreenSurfaceLayer, getWidth(), getHeight()); } } @Override public final void detachSurfaceLayer() throws NativeWindowException { - if( !isOffscreenLayerSurfaceEnabled() ) { - throw new java.lang.UnsupportedOperationException("Not an offscreen layer surface"); - } if( 0 == offscreenSurfaceLayer) { throw new NativeWindowException("No offscreen layer attached: "+this); } - int lockRes = lockSurface(); - if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { - throw new NativeWindowException("Could not lock (offscreen layer): "+this); - } - try { - if(DEBUG) { - System.err.println("JAWTWindow.detachSurfaceHandle(): osh "+toHexString(offscreenSurfaceLayer)); - } - detachSurfaceLayerImpl(offscreenSurfaceLayer); - offscreenSurfaceLayer = 0; - } finally { - unlockSurface(); + if(DEBUG) { + System.err.println("JAWTWindow.detachSurfaceHandle(): osh "+toHexString(offscreenSurfaceLayer)); } + detachSurfaceLayerImpl(offscreenSurfaceLayer, detachSurfaceLayerNotify); } - protected abstract void detachSurfaceLayerImpl(final long layerHandle); + private final Runnable detachSurfaceLayerNotify = new Runnable() { + @Override + public void run() { + offscreenSurfaceLayer = 0; + } + }; + + /** + * @param detachNotify Runnable to be called before native detachment + */ + protected void detachSurfaceLayerImpl(final long layerHandle, final Runnable detachNotify) { + throw new UnsupportedOperationException("offscreen layer not supported"); + } + @Override public final long getAttachedSurfaceLayer() { @@ -305,6 +301,11 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, getPrivateGraphicsConfiguration().setChosenCapabilities(caps); } + @Override + public final RecursiveLock getLock() { + return surfaceLock; + } + // // SurfaceUpdateListener // diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index 8c02a68bb..1826008ad 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -27,6 +27,8 @@ */ package javax.media.nativewindow; +import com.jogamp.common.util.locks.RecursiveLock; + /** * Interface specifying the offscreen layer surface protocol. */ @@ -60,4 +62,7 @@ public interface OffscreenLayerSurface { /** Sets the capabilities of this instance, allowing upstream API's to refine it, i.e. OpenGL related settings. */ public void setChosenCapabilities(CapabilitiesImmutable caps); + /** Returns the recursive lock object of this surface, which synchronizes multithreaded access. */ + public RecursiveLock getLock(); + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index d11d24664..9f76392a9 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -69,16 +69,18 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } } + @Override protected void invalidateNative() { if(DEBUG) { System.err.println("MacOSXJAWTWindow.invalidateNative(): osh-enabled "+isOffscreenLayerSurfaceEnabled()+ - ", osh-set "+offscreenSurfaceHandleSet+ - ", osh "+toHexString(offscreenSurfaceHandle)+ - ", rsh "+toHexString(rootSurfaceLayer)+ + ", osd-set "+offscreenSurfaceDrawableSet+ + ", osd "+toHexString(offscreenSurfaceDrawable)+ + ", osl "+toHexString(getAttachedSurfaceLayer())+ + ", rsl "+toHexString(rootSurfaceLayer)+ ", wh "+toHexString(windowHandle)+" - "+Thread.currentThread().getName()); } - offscreenSurfaceHandle=0; - offscreenSurfaceHandleSet=false; + offscreenSurfaceDrawable=0; + offscreenSurfaceDrawableSet=false; if( isOffscreenLayerSurfaceEnabled() ) { if(0 != windowHandle) { OSXUtil.DestroyNSWindow(windowHandle); @@ -108,29 +110,41 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { jawt.FreeDrawingSurface(ds); } } - OSXUtil.DestroyCALayer(rootSurfaceLayer); - rootSurfaceLayer = 0; + + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + OSXUtil.DestroyCALayer(rootSurfaceLayer, false); + rootSurfaceLayer = 0; + } + }); } } windowHandle=0; } + @Override protected void attachSurfaceLayerImpl(final long layerHandle) { OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, getWidth(), getHeight()); } - protected void layoutSurfaceLayerImpl() { - final long osl = getAttachedSurfaceLayer(); - final int w = getWidth(); - final int h = getHeight(); + @Override + protected void layoutSurfaceLayerImpl(long layerHandle, int width, int height) { if(DEBUG) { - System.err.println("JAWTWindow.fixSurfaceLayerLayout: "+toHexString(osl) + ", bounds "+bounds+", "+w+"x"+h); + System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", "+width+"x"+height+"; "+this); } - OSXUtil.FixCALayerLayout(rootSurfaceLayer, osl, w, h); + OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, width, height); } - protected void detachSurfaceLayerImpl(final long layerHandle) { - OSXUtil.RemoveCASublayer(rootSurfaceLayer, layerHandle); + @Override + protected void detachSurfaceLayerImpl(final long layerHandle, final Runnable detachNotify) { + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + final long l = MacOSXJAWTWindow.this.getAttachedSurfaceLayer(); + if( 0 != l ) { + detachNotify.run(); + OSXUtil.RemoveCASublayer(rootSurfaceLayer, layerHandle, false); + } + } } ); } @Override @@ -140,7 +154,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { @Override public final long getSurfaceHandle() { - return offscreenSurfaceHandleSet ? offscreenSurfaceHandle : drawable /* super.getSurfaceHandle() */ ; + return offscreenSurfaceDrawableSet ? offscreenSurfaceDrawable : drawable /* super.getSurfaceHandle() */ ; } public void setSurfaceHandle(long surfaceHandle) { @@ -150,8 +164,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if(DEBUG) { System.err.println("MacOSXJAWTWindow.setSurfaceHandle(): "+toHexString(surfaceHandle)); } - this.offscreenSurfaceHandle = surfaceHandle; - this.offscreenSurfaceHandleSet = true; + this.offscreenSurfaceDrawable = surfaceHandle; + this.offscreenSurfaceDrawableSet = true; } protected JAWT fetchJAWTImpl() throws NativeWindowException { @@ -257,7 +271,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } if(null != errMsg) { if(0 != rootSurfaceLayer) { - OSXUtil.DestroyCALayer(rootSurfaceLayer); + OSXUtil.DestroyCALayer(rootSurfaceLayer, true); rootSurfaceLayer = 0; } if(0 != windowHandle) { @@ -329,11 +343,11 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { private JAWT_MacOSXDrawingSurfaceInfo macosxdsi; - private long rootSurfaceLayer = 0; // attached to the JAWT_SurfaceLayer + private volatile long rootSurfaceLayer = 0; // attached to the JAWT_SurfaceLayer private long windowHandle = 0; - private long offscreenSurfaceHandle = 0; - private boolean offscreenSurfaceHandleSet = false; + private long offscreenSurfaceDrawable = 0; + private boolean offscreenSurfaceDrawableSet = false; // Workaround for instance of 4796548 private boolean firstLock = true; diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java index 5d1d43792..905a313d5 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java @@ -64,13 +64,6 @@ public class WindowsJAWTWindow extends JAWTWindow { windowHandle = 0; } - protected void attachSurfaceLayerImpl(final long layerHandle) { - throw new UnsupportedOperationException("offscreen layer not supported"); - } - protected void detachSurfaceLayerImpl(final long layerHandle) { - throw new UnsupportedOperationException("offscreen layer not supported"); - } - protected JAWT fetchJAWTImpl() throws NativeWindowException { return JAWTUtil.getJAWT(false); // no offscreen } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java index 467809284..2e5dc7fb5 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java @@ -59,13 +59,6 @@ public class X11JAWTWindow extends JAWTWindow { protected void invalidateNative() { } - protected void attachSurfaceLayerImpl(final long layerHandle) { - throw new UnsupportedOperationException("offscreen layer not supported"); - } - protected void detachSurfaceLayerImpl(final long layerHandle) { - throw new UnsupportedOperationException("offscreen layer not supported"); - } - protected JAWT fetchJAWTImpl() throws NativeWindowException { return JAWTUtil.getJAWT(false); // no offscreen } diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 703c3d972..4b102be00 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -138,11 +138,15 @@ public class OSXUtil implements ToolkitProperties { /** * Create a CALayer suitable to act as a root CALayer. - * @see #DestroyCALayer(long) + * @see #DestroyCALayer(long, boolean) * @see #AddCASublayer(long, long) */ public static long CreateCALayer(final int x, final int y, final int width, final int height) { - return CreateCALayer0(x, y, width, height); + final long l = CreateCALayer0(x, y, width, height); + if(DEBUG) { + System.err.println("OSXUtil.CreateCALayer: 0x"+Long.toHexString(l)+" - "+Thread.currentThread().getName()); + } + return l; } /** @@ -156,7 +160,7 @@ public class OSXUtil implements ToolkitProperties { * they will be used for creation. *

    * @see #CreateCALayer(int, int, int, int) - * @see #RemoveCASublayer(long, long) + * @see #RemoveCASublayer(long, long, boolean) */ public static void AddCASublayer(final long rootCALayer, final long subCALayer, final int width, final int height) { if(0==rootCALayer || 0==subCALayer) { @@ -164,6 +168,9 @@ public class OSXUtil implements ToolkitProperties { } RunOnMainThread(false, new Runnable() { public void run() { + if(DEBUG) { + System.err.println("OSXUtil.AttachCALayer: 0x"+Long.toHexString(subCALayer)+" - "+Thread.currentThread().getName()); + } AddCASublayer0(rootCALayer, subCALayer, width, height); } }); @@ -193,32 +200,48 @@ public class OSXUtil implements ToolkitProperties { } /** - * Detach a sub CALayer from the root CALayer on the main-thread w/o blocking. + * Detach a sub CALayer from the root CALayer. + * @param onMainThread if true method will be performed on the main-thread w/o blocking. */ - public static void RemoveCASublayer(final long rootCALayer, final long subCALayer) { + public static void RemoveCASublayer(final long rootCALayer, final long subCALayer, boolean onMainThread) { if(0==rootCALayer || 0==subCALayer) { throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer)); } - RunOnMainThread(false, new Runnable() { + final Runnable action = new Runnable() { public void run() { + if(DEBUG) { + System.err.println("OSXUtil.DetachCALayer: 0x"+Long.toHexString(subCALayer)+" - "+Thread.currentThread().getName()); + } RemoveCASublayer0(rootCALayer, subCALayer); - } - }); + } }; + if( onMainThread ) { + RunOnMainThread(false, action); + } else { + action.run(); + } } /** - * Destroy a CALayer on main-thread w/o blocking. + * Destroy a CALayer. + * @param onMainThread if true method will be performed on the main-thread w/o blocking. * @see #CreateCALayer(int, int, int, int) */ - public static void DestroyCALayer(final long caLayer) { + public static void DestroyCALayer(final long caLayer, boolean onMainThread) { if(0==caLayer) { throw new IllegalArgumentException("caLayer 0x"+Long.toHexString(caLayer)); } - RunOnMainThread(false, new Runnable() { + final Runnable action = new Runnable() { public void run() { + if(DEBUG) { + System.err.println("OSXUtil.DestroyCALayer: 0x"+Long.toHexString(caLayer)+" - "+Thread.currentThread().getName()); + } DestroyCALayer0(caLayer); - } - }); + } }; + if( onMainThread ) { + RunOnMainThread(false, action); + } else { + action.run(); + } } /** @@ -238,7 +261,7 @@ public class OSXUtil implements ToolkitProperties { // otherwise we may freeze the OSX main thread. Throwable throwable = null; final Object sync = new Object(); - final RunnableTask rt = new RunnableTask( runnable, waitUntilDone ? sync : null, true ); + final RunnableTask rt = new RunnableTask( runnable, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); synchronized(sync) { RunOnMainThread0(rt); if( waitUntilDone ) { @@ -258,6 +281,16 @@ public class OSXUtil implements ToolkitProperties { } } + /** + * Run later on current OSX thread. + * + * @param runnable + * @param delay delay to run the runnable in milliseconds + */ + public static void RunLater(Runnable runnable, int delay) { + RunLater0(new RunnableTask( runnable, null, true, System.err ), delay); + } + private static Runnable _nop = new Runnable() { public void run() {}; }; /** Issues a {@link #RunOnMainThread(boolean, Runnable)} w/ an NOP runnable, while waiting until done. */ @@ -282,7 +315,7 @@ public class OSXUtil implements ToolkitProperties { // otherwise we may freeze the OSX main thread. Throwable throwable = null; final Object sync = new Object(); - final FunctionTask rt = new FunctionTask( func, waitUntilDone ? sync : null, true ); + final FunctionTask rt = new FunctionTask( func, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); synchronized(sync) { rt.setArgs(args); RunOnMainThread0(rt); @@ -349,6 +382,7 @@ public class OSXUtil implements ToolkitProperties { private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); private static native void RunOnMainThread0(Runnable runnable); + private static native void RunLater0(Runnable runnable, int delay); private static native boolean IsMainThread0(); private static native int GetScreenRefreshRate0(int scrn_idx); } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index d902b0f09..a3c2a5dc8 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -43,9 +43,7 @@ import java.security.PrivilegedAction; import java.util.Set; import javax.media.nativewindow.NativeWindow; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerOption; -import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.WindowClosingProtocol; import javax.swing.MenuSelectionManager; @@ -615,12 +613,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto configureNewtChild(false); newtChild.setVisible(false); - // Detach OLS early.. - final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); - if(null != ols && ols.isSurfaceLayerAttached()) { - ols.detachSurfaceLayer(); - } - newtChild.reparentWindow(null); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached) + newtChild.reparentWindow(null); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer if(DEBUG) { System.err.println("NewtCanvasAWT.detachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java index 48c3c89b3..c2eebbfd8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java @@ -55,13 +55,14 @@ import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { - static long durationPerTest = 50; + static long durationPerTest = 100; static int addRemoveCount = 15; static int pauseEach = 0; static int pauseDuration = 500; static boolean noOnscreenTest = false; static boolean noOffscreenTest = false; - static boolean shallUseOffscreenPBufferLayer = false; + static boolean offscreenPBufferOnly = false; + static boolean offscreenFBOOnly = false; static GLProfile glp; static int width, height; static boolean waitForKey = false; @@ -143,6 +144,9 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { throws AWTException, InterruptedException, InvocationTargetException { + if(waitForKey) { + UITestCase.waitForKey("Start"); + } for(int i=0; i w1. free g1 of w1 canvas2.setNEWTChild(glWindow1); // put g1 -> w2 + frame1.invalidate(); + frame2.invalidate(); frame1.validate(); frame2.validate(); } @@ -176,6 +178,8 @@ public class TestParenting04AWT extends UITestCase { } canvas1.setNEWTChild(glWindow1); canvas2.setNEWTChild(glWindow2); + frame1.invalidate(); + frame2.invalidate(); frame1.validate(); frame2.validate(); } -- cgit v1.2.3 From 81cbcdc8469143587b2044661dd613c798ae02ba Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 19 Mar 2013 00:33:00 +0100 Subject: OSX/NEWT: Following CALayer streaming design, i.e. issue NSWindow/NSView Ops on main-thread w/o blocking; NEWT/WindowImpl: Volatile multithreaded mutable values Similar to commits: 28c6472335b924080d638b33a28f8f4eedb459b1 f354fb204d8973453c538dda78a2c82c87be61dc main-thread operations cannot block main-thread. Luckily we are able to create the NSWindow and NSView instance uninitialized (deferred) on the current thread, while issuing their initialization on the main-thread w/o blocking. Further more a size glitch is fixed, which didn't take the title bar into account. +++ NEWT/WindowImpl: Volatile multithreaded mutable values Since position, size and other attributes might get changes off-thread, these fields needs to be volatile. --- make/scripts/tests.sh | 6 +- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 1 + src/newt/classes/jogamp/newt/WindowImpl.java | 17 +- .../jogamp/newt/driver/macosx/WindowDriver.java | 165 +++++++------ src/newt/native/MacWindow.m | 257 ++++++++++++++------- src/newt/native/NewtMacWindow.h | 18 +- src/newt/native/NewtMacWindow.m | 145 +++++++----- 7 files changed, 376 insertions(+), 233 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8cc3fd84a..71e8ef98d 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -90,6 +90,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" + #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" @@ -268,7 +269,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* @@ -348,8 +349,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch10NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch12AWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* - +#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index 3c015d3ec..651522799 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -332,6 +332,7 @@ public class DefaultEDTUtil implements EDTUtil { validateNoRecursiveLocksHold(); if(!task.hasWaiter() && null != task.getThrowable()) { // at least dump stack-trace in case nobody waits for result + System.err.println("DefaultEDT.run(): Catched exception occured on thread "+Thread.currentThread().getName()+": "+task.toString()); task.getThrowable().printStackTrace(); } } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 448b192a2..c01f880fc 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -82,9 +82,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** Timeout of queued events (repaint and resize) */ static final long QUEUED_EVENT_TO = 1200; // ms - + + // + // Volatile: Multithread Mutable Access + // private volatile long windowHandle = 0; // lifecycle critical private volatile boolean visible = false; // lifecycle critical + private volatile boolean hasFocus = false; + private volatile int width = 128, height = 128; // client-area size w/o insets, default: may be overwritten by user + private volatile int x = 64, y = 64; // client-area pos w/o insets + private volatile Insets insets = new Insets(); // insets of decoration (if top-level && decorated) + private RecursiveLock windowLock = LockFactory.createRecursiveLock(); // Window instance wide lock private int surfaceLockCount = 0; // surface lock recursion count @@ -95,12 +103,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private AbstractGraphicsConfiguration config = null; // control access due to delegation protected CapabilitiesImmutable capsRequested = null; protected CapabilitiesChooser capabilitiesChooser = null; // default null -> default - private boolean fullscreen = false, hasFocus = false, brokenFocusChange = false; - private int width = 128, height = 128; // client-area size w/o insets, default: may be overwritten by user - private int x = 64, y = 64; // client-area pos w/o insets + private boolean fullscreen = false, brokenFocusChange = false; private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user) - private Insets insets = new Insets(); // insets of decoration (if top-level && decorated) - + private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets private NativeWindow nfs_parent = null; // non fullscreen parent, in case explicit reparenting is performed (offscreen) private String title = "Newt Window"; diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 6e9335f08..d3a92e023 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -49,7 +49,6 @@ import jogamp.newt.WindowImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; -import com.jogamp.common.util.Function; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; @@ -86,7 +85,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl sscSurfaceHandle = 0; isOffscreenInstance = false; if (0 != handle) { - OSXUtil.RunOnMainThread(true, new Runnable() { + OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { close0( handle ); } } ); @@ -101,18 +100,31 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected int lockSurfaceImpl() { - if(!isOffscreenInstance) { - return lockSurface0(getWindowHandle()) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY; + /** + * if( isOffscreenInstance ) { + * return LOCK_SUCCESS; + * } + */ + final long w = getWindowHandle(); + final long v = surfaceHandle; + if( 0 != v && 0 != w ) { + return lockSurface0(w, v) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY; } - return LOCK_SUCCESS; + return LOCK_SURFACE_NOT_READY; } @Override protected void unlockSurfaceImpl() { - if(!isOffscreenInstance) { - final long h = getWindowHandle(); - if(0 != h) { - unlockSurface0(h); + /** + * if( isOffscreenInstance ) { + * return; + * } + */ + final long w = getWindowHandle(); + final long v = surfaceHandle; + if(0 != w && 0 != v) { + if( !unlockSurface0(w, v) ) { + throw new NativeWindowException("Failed to unlock surface, probably not locked!"); } } } @@ -130,7 +142,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl sscSurfaceHandle = surfaceHandle; if (isNativeValid()) { if (0 != sscSurfaceHandle) { - orderOut0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); + orderOut0( 0 != getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); } /** this is done by recreation! else if (isVisible()){ orderFront0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); @@ -172,7 +184,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow: updatePosition() -> abs child-client-pos: "+pS); } - setWindowClientTopLeftPoint0(handle, pS.getX(), pS.getY()); + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + setWindowClientTopLeftPoint0(handle, pS.getX(), pS.getY()); + } } ); // no native event (fullscreen, some reparenting) positionChanged(true, pS.getX(), pS.getY()); } @@ -189,14 +204,17 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow: sizeChanged() "+newWidth+"x"+newHeight+" -> abs child-client-pos "+p0S); } - setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY()); + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY()); + } } ); } } super.sizeChanged(defer, newWidth, newHeight, force); } @Override - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, int flags) { final boolean _isOffscreenInstance = isOffscreenInstance(this, this.getParent()); isOffscreenInstance = 0 != sscSurfaceHandle || _isOffscreenInstance; final PointImmutable pClientLevelOnSreen; @@ -224,7 +242,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl ", ioi: "+_isOffscreenInstance+ ") -> "+isOffscreenInstance+ "\n\t, "+getReconfigureFlagsAsString(null, flags)); - Thread.dumpStack(); + // Thread.dumpStack(); } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) { @@ -244,11 +262,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl createWindow(false, 0 != getWindowHandle(), pClientLevelOnSreen, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); } if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; } - } - if( width>0 && height>0 && x>=0 && y>=0 ) { - if( !isOffscreenInstance ) { - // setContentSize0(getWindowHandle(), width, height); - setWindowClientTopLeftPointAndSize0(getWindowHandle(), pClientLevelOnSreen.getX(), pClientLevelOnSreen.getY(), width, height); + } else if( width>0 && height>0 ) { + if( !isOffscreenInstance ) { + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + setWindowClientTopLeftPointAndSize0(getWindowHandle(), pClientLevelOnSreen.getX(), pClientLevelOnSreen.getY(), width, height); + } } ); } // else offscreen size is realized via recreation // no native event (fullscreen, some reparenting) positionChanged(true, x, y); @@ -297,19 +316,25 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl /** Callback for native screen position change event of the client area. */ protected void screenPositionChanged(boolean defer, int newX, int newY) { // passed coordinates are in screen position of the client area - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow.positionChanged (Screen Pos): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY); - } if(getWindowHandle()!=0) { final NativeWindow parent = getParent(); - if(null == parent) { + if( null == parent || isOffscreenInstance ) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow.positionChanged.0 (Screen Pos - TOP): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY); + } positionChanged(defer, newX, newY); } else { // screen position -> rel child window position Point absPos = new Point(newX, newY); - absPos.translate( parent.getLocationOnScreen(null).scale(-1, -1) ); + Point parentOnScreen = parent.getLocationOnScreen(null); + absPos.translate( parentOnScreen.scale(-1, -1) ); + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow.positionChanged.1 (Screen Pos - CHILD): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> absPos "+newX+"/"+newY+", parentOnScreen "+parentOnScreen+" -> "+absPos); + } positionChanged(defer, absPos.getX(), absPos.getY()); } + } else if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow.positionChanged.2 (Screen Pos - IGN): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY); } } @@ -383,65 +408,69 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final PointImmutable pS, final int width, final int height, final boolean fullscreen) { - if(0!=getWindowHandle() && !recreate) { + if( 0 != getWindowHandle() && !recreate ) { return; } try { - if(0!=getWindowHandle()) { - // save the view .. close the window - surfaceHandle = OSXUtil.RunOnMainThread(true, new Function() { - public Long eval(Object... args) { - return Long.valueOf( - changeContentView0(getParentWindowHandle(), getWindowHandle(), 0) ); - } } ).longValue(); - if(recreate && 0==surfaceHandle) { - throw new NativeWindowException("Internal Error - recreate, window but no view"); - } - OSXUtil.RunOnMainThread(true, new Runnable() { - public void run() { - close0( getWindowHandle() ); - } } ); + final long parentWin = getParentWindowHandle(); + if( 0 != getWindowHandle() ) { + final long thisWin = getWindowHandle(); setWindowHandle(0); + + if( 0 == surfaceHandle ) { + throw new NativeWindowException("Internal Error - create w/ window, but no Newt NSView"); + } + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + changeContentView0(parentWin, thisWin, 0); + close0( thisWin ); + } } ); } else { - surfaceHandle = 0; + if( 0 != surfaceHandle ) { + throw new NativeWindowException("Internal Error - create w/o window, but has Newt NSView"); + } + surfaceHandle = createView0(pS.getX(), pS.getY(), width, height, fullscreen, getScreen().getIndex()); + if( 0 == surfaceHandle ) { + throw new NativeWindowException("Could not create native view "+Thread.currentThread().getName()+" "+this); + } } - setWindowHandle( OSXUtil.RunOnMainThread(true, new Function() { - public Long eval(Object... args) { - return Long.valueOf( - createWindow0( getParentWindowHandle(), - pS.getX(), pS.getY(), width, height, - (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance), - fullscreen, - ( (isUndecorated() || offscreenInstance) ? NSBorderlessWindowMask : - NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask ), - NSBackingStoreBuffered, - getScreen().getIndex(), surfaceHandle) ); - } } ).longValue() ); - - if (getWindowHandle() == 0) { - throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this); - } - surfaceHandle = contentView0(getWindowHandle()); - if( offscreenInstance ) { - orderOut0(0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle()); - } else { - setTitle0(getWindowHandle(), getTitle()); + final long newWin = createWindow0( pS.getX(), pS.getY(), width, height, fullscreen, + ( isUndecorated() || offscreenInstance ) ? NSBorderlessWindowMask : + NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask, + NSBackingStoreBuffered, getScreen().getIndex(), surfaceHandle); + if ( newWin == 0 ) { + throw new NativeWindowException("Could not create native window "+Thread.currentThread().getName()+" "+this); } + setWindowHandle( newWin ); + + final boolean isOpaque = getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance; + // Non blocking initialization on main-thread! + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + initWindow0( parentWin, newWin, + pS.getX(), pS.getY(), width, height, + isOpaque, fullscreen, offscreenInstance, getScreen().getIndex(), surfaceHandle); + if( offscreenInstance ) { + orderOut0(0!=parentWin ? parentWin : newWin); + } else { + setTitle0(newWin, getTitle()); + } + } } ); } catch (Exception ie) { ie.printStackTrace(); } } protected static native boolean initIDs0(); + private native long createView0(int x, int y, int w, int h, boolean fullscreen, int screen_idx); + private native long createWindow0(int x, int y, int w, int h, boolean fullscreen, int windowStyle, int backingStoreType, int screen_idx, long view); /** Must be called on Main-Thread */ - private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h, - boolean opaque, boolean fullscreen, int windowStyle, - int backingStoreType, - int screen_idx, long view); - private native boolean lockSurface0(long window); - private native void unlockSurface0(long window); + private native void initWindow0(long parentWindow, long window, int x, int y, int w, int h, + boolean opaque, boolean fullscreen, boolean offscreen, int screen_idx, long view); + private native boolean lockSurface0(long window, long view); + private native boolean unlockSurface0(long window, long view); private native void requestFocus0(long window, boolean force); private native void resignFocus0(long window); /** in case of a child window, it actually only issues orderBack(..) */ @@ -452,7 +481,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private native void setTitle0(long window, String title); private native long contentView0(long window); /** Must be called on Main-Thread */ - private native long changeContentView0(long parentWindowOrViewHandle, long window, long view); + private native void changeContentView0(long parentWindowOrView, long window, long view); private native void setWindowClientTopLeftPointAndSize0(long window, int x, int y, int w, int h); private native void setWindowClientTopLeftPoint0(long window, int x, int y); private native void setAlwaysOnTop0(long window, boolean atop); diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 1895b98a5..db4420b49 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -70,11 +70,18 @@ static void setWindowClientTopLeftPoint(NewtMacWindow* mWin, jint x, jint y) { [mWin invalidateCursorRectsForView: mView]; } -static void setWindowClientTopLeftPointAndSize(NewtMacWindow* mWin, jint x, jint y, jint width, jint height) { - NSSize sz = NSMakeSize(width, height); - NSPoint pS = [mWin newtAbsClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y) size: sz]; - NSRect rect = { pS, sz }; - [mWin setFrame: rect display:YES]; +static void setWindowClientTopLeftPointAndSize(NewtMacWindow* mWin, jint x, jint y, jint width, jint height, BOOL doDisplay) { + DBG_PRINT( "setWindowClientTopLeftPointAndSize.0 - window: %p %d/%d %dx%d\n", + mWin, (int)x, (int)y, (int)width, (int)height); + NSSize clientSZ = NSMakeSize(width, height); + NSPoint pS = [mWin newtAbsClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y) size: clientSZ]; + NSSize topSZ = [mWin newtClientSize2TLSize: clientSZ]; + NSRect rect = { pS, topSZ }; + + DBG_PRINT( "setWindowClientTopLeftPointAndSize.X: %d/%d %dx%d\n", + (int)rect.origin.x, (int)rect.origin.y, (int)rect.size.width, (int)rect.size.height); + + [mWin setFrame: rect display:doDisplay]; // -> display:YES // NSView* mView = [mWin contentView]; @@ -88,21 +95,20 @@ static int getRetainCount(NSObject * obj) { #endif static void changeContentView(JNIEnv *env, jobject javaWindowObject, NSView *pview, NewtMacWindow *win, NewtView *newView) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSView* oldNSView = [win contentView]; - NewtView* oldView = NULL; + NewtView* oldNewtView = NULL; #ifdef VERBOSE_ON int dbgIdx = 1; #endif - if( [oldNSView isMemberOfClass:[NewtView class]] ) { - oldView = (NewtView *) oldNSView; + if( [oldNSView isKindOfClass:[NewtView class]] ) { + oldNewtView = (NewtView *) oldNSView; } DBG_PRINT( "changeContentView.%d win %p, view (%p,%d (%d) -> %p,%d), parent view %p\n", - dbgIdx++, win, oldNSView, getRetainCount(oldNSView), NULL!=oldView, newView, getRetainCount(newView), pview); + dbgIdx++, win, oldNSView, getRetainCount(oldNSView), NULL!=oldNewtView, newView, getRetainCount(newView), pview); - if(NULL!=oldNSView) { + if( NULL!=oldNSView ) { NS_DURING // Available >= 10.5 - Makes the menubar disapear BOOL iifs; @@ -117,20 +123,20 @@ NS_DURING NS_HANDLER NS_ENDHANDLER DBG_PRINT( "changeContentView.%d win %p, view (%p,%d (%d) -> %p,%d)\n", - dbgIdx++, win, oldNSView, getRetainCount(oldNSView), NULL!=oldView, newView, getRetainCount(newView)); + dbgIdx++, win, oldNSView, getRetainCount(oldNSView), NULL!=oldNewtView, newView, getRetainCount(newView)); - if( NULL != oldView ) { - jobject globJavaWindowObject = [oldView getJavaWindowObject]; + if( NULL != oldNewtView ) { + jobject globJavaWindowObject = [oldNewtView getJavaWindowObject]; (*env)->DeleteGlobalRef(env, globJavaWindowObject); - [oldView setJavaWindowObject: NULL]; - [oldView setDestroyNotifySent: false]; + [oldNewtView setJavaWindowObject: NULL]; + [oldNewtView setDestroyNotifySent: false]; } [oldNSView removeFromSuperviewWithoutNeedingDisplay]; } DBG_PRINT( "changeContentView.%d win %p, view (%p,%d -> %p,%d), isHidden %d, isHiddenOrHasHiddenAncestor: %d\n", dbgIdx++, win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView), [newView isHidden], [newView isHiddenOrHasHiddenAncestor]); - if(NULL!=newView) { + if( NULL!=newView ) { jobject globJavaWindowObject = (*env)->NewGlobalRef(env, javaWindowObject); [newView setJavaWindowObject: globJavaWindowObject]; [newView setDestroyNotifySent: false]; @@ -163,12 +169,10 @@ NS_ENDHANDLER dbgIdx++, win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView), [newView isHidden], [newView isHiddenOrHasHiddenAncestor]); // make sure the insets are updated in the java object - [win updateInsets: env]; + [win updateInsets: env jwin:javaWindowObject]; DBG_PRINT( "changeContentView.X win %p, view (%p,%d -> %p,%d)\n", win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView)); - - [pool release]; } /* @@ -565,29 +569,69 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0 } /** - * Method is called on Main-Thread, hence no special invocation required inside method. + * Class: jogamp_newt_driver_macosx_WindowDriver + * Method: createView0 + * Signature: (IIIIZI)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createView0 + (JNIEnv *env, jobject jthis, jint x, jint y, jint w, jint h, + jboolean fullscreen, jint screen_idx) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + DBG_PRINT( "createView0 - %p (this), %d/%d %dx%d, fs %d, screenidx %d (START)\n", + (void*)(intptr_t)jthis, (int)x, (int)y, (int)w, (int)h, (int)fullscreen, (int)screen_idx); + + NSArray *screens = [NSScreen screens]; + if(screen_idx<0) screen_idx=0; + if(screen_idx>=[screens count]) screen_idx=0; + NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; + NSRect rectWin; + + if (fullscreen) { + rectWin = [myScreen frame]; + x = 0; + y = 0; + w = (jint) (rectWin.size.width); + h = (jint) (rectWin.size.height); + } else { + rectWin = NSMakeRect(x, y, w, h); + } + + NSRect rectView = NSMakeRect(0, 0, w, h); + NewtView *myView = [[NewtView alloc] initWithFrame: rectView] ; + DBG_PRINT( "createView0.X.%d - new view: %p\n", myView); + + [pool release]; + + return (jlong) ((intptr_t) myView); +} + +/** + * Method creates a deferred un-initialized Window, hence no special invocation required inside method. * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: createWindow0 - * Signature: (JIIIIZIIIJ)J + * Signature: (IIIIZIIIJ)J */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow0 - (JNIEnv *env, jobject jthis, jlong parent, jint x, jint y, jint w, jint h, jboolean opaque, jboolean fullscreen, jint styleMask, - jint bufferingType, jint screen_idx, jlong jview) + (JNIEnv *env, jobject jthis, jint x, jint y, jint w, jint h, + jboolean fullscreen, jint styleMask, jint bufferingType, jint screen_idx, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtView* myView = (NewtView*) (intptr_t) jview ; - DBG_PRINT( "createWindow0 - %p (this), %p (parent), %d/%d %dx%d, opaque %d, fs %d, style %X, buffType %X, screenidx %d, view %p (START)\n", - (void*)(intptr_t)jthis, (void*)(intptr_t)parent, (int)x, (int)y, (int)w, (int)h, (int) opaque, (int)fullscreen, + DBG_PRINT( "createWindow0 - %p (this), %d/%d %dx%d, fs %d, style %X, buffType %X, screenidx %d, view %p (START)\n", + (void*)(intptr_t)jthis, (int)x, (int)y, (int)w, (int)h, (int)fullscreen, (int)styleMask, (int)bufferingType, (int)screen_idx, myView); + (void)myView; NSArray *screens = [NSScreen screens]; if(screen_idx<0) screen_idx=0; if(screen_idx>=[screens count]) screen_idx=0; NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; - NSRect rectWin; + NSRect rectWin; if (fullscreen) { styleMask = NSBorderlessWindowMask; rectWin = [myScreen frame]; @@ -603,9 +647,54 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow NewtMacWindow* myWindow = [[NewtMacWindow alloc] initWithContentRect: rectWin styleMask: (NSUInteger) styleMask backing: (NSBackingStoreType) bufferingType - defer: NO + defer: YES screen: myScreen isFullscreenWindow: fullscreen]; + + // DBG_PRINT( "createWindow0.1 - %p, isVisible %d\n", myWindow, [myWindow isVisible]); + + DBG_PRINT( "createWindow0.X - %p, isVisible %d\n", myWindow, [myWindow isVisible]); + + [pool release]; + + return (jlong) ((intptr_t) myWindow); +} + +/** + * Method is called on Main-Thread, hence no special invocation required inside method. + * + * Class: jogamp_newt_driver_macosx_WindowDriver + * Method: initWindow0 + * Signature: (JJIIIIZZZIIJ)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initWindow0 + (JNIEnv *env, jobject jthis, jlong parent, jlong window, jint x, jint y, jint w, jint h, + jboolean opaque, jboolean fullscreen, jboolean offscreen, jint screen_idx, jlong jview) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NewtMacWindow* myWindow = (NewtMacWindow*) ((intptr_t) window); + NewtView* myView = (NewtView*) (intptr_t) jview ; + + DBG_PRINT( "initWindow0 - %p (this), %p (parent), %p (window), %d/%d %dx%d, opaque %d, fs %d, offscreen %d, screenidx %d, view %p (START)\n", + (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, (int)x, (int)y, (int)w, (int)h, (int) opaque, (int)fullscreen, + (int)offscreen, (int)screen_idx, myView); + + NSArray *screens = [NSScreen screens]; + if(screen_idx<0) screen_idx=0; + if(screen_idx>=[screens count]) screen_idx=0; + NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; + NSRect rectWin; + + if (fullscreen) { + rectWin = [myScreen frame]; + x = 0; + y = 0; + w = (jint) (rectWin.size.width); + h = (jint) (rectWin.size.height); + } else { + rectWin = NSMakeRect(x, y, w, h); + } + [myWindow setReleasedWhenClosed: YES]; // default [myWindow setPreservesContentDuringLiveResize: NO]; @@ -615,15 +704,15 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow if( nsParentObj != NULL && [nsParentObj isKindOfClass:[NSWindow class]] ) { parentWindow = (NSWindow*) nsParentObj; parentView = [parentWindow contentView]; - DBG_PRINT( "createWindow0 - Parent is NSWindow : %p (win) -> %p (view) \n", parentWindow, parentView); + DBG_PRINT( "initWindow0 - Parent is NSWindow : %p (win) -> %p (view) \n", parentWindow, parentView); } else if( nsParentObj != NULL && [nsParentObj isKindOfClass:[NSView class]] ) { parentView = (NSView*) nsParentObj; parentWindow = [parentView window]; - DBG_PRINT( "createWindow0 - Parent is NSView : %p -(view) > %p (win) \n", parentView, parentWindow); + DBG_PRINT( "initWindow0 - Parent is NSView : %p -(view) > %p (win) \n", parentView, parentWindow); } else { - DBG_PRINT( "createWindow0 - Parent is neither NSWindow nor NSView : %p\n", nsParentObj); + DBG_PRINT( "initWindow0 - Parent is neither NSWindow nor NSView : %p\n", nsParentObj); } - DBG_PRINT( "createWindow0 - is visible.1: %d\n", [myWindow isVisible]); + DBG_PRINT( "initWindow0 - is visible.1: %d\n", [myWindow isVisible]); // Remove animations for child windows if(NULL != parentWindow) { @@ -641,11 +730,11 @@ NS_ENDHANDLER #endif if(opaque) { [myWindow setOpaque: YES]; - DBG_PRINT( "createWindow0.%d\n", dbgIdx++); + DBG_PRINT( "initWindow0.%d\n", dbgIdx++); if (!fullscreen) { [myWindow setShowsResizeIndicator: YES]; } - DBG_PRINT( "createWindow0.%d\n", dbgIdx++); + DBG_PRINT( "initWindow0.%d\n", dbgIdx++); } else { [myWindow setOpaque: NO]; [myWindow setBackgroundColor: [NSColor clearColor]]; @@ -653,36 +742,25 @@ NS_ENDHANDLER // specify we want mouse-moved events [myWindow setAcceptsMouseMovedEvents:YES]; - DBG_PRINT( "createWindow0.%d\n", dbgIdx++); - // Use given NewtView or allocate an NewtView if NULL - if(NULL == myView) { - NSRect rectView = NSMakeRect(0, 0, w, h); - myView = [[NewtView alloc] initWithFrame: rectView] ; - DBG_PRINT( "createWindow0.%d - use new view: %p,%d\n", dbgIdx++, myView, getRetainCount(myView)); - } else { - DBG_PRINT( "createWindow0.%d - use given view: %p,%d\n", dbgIdx++, myView, getRetainCount(myView)); - } - - DBG_PRINT( "createWindow0.%d - %p,%d view %p,%d, isVisible %d\n", + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); // Set the content view changeContentView(env, jthis, parentView, myWindow, myView); - DBG_PRINT( "createWindow0.%d - %p,%d view %p,%d, isVisible %d\n", + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); if(NULL!=parentWindow) { [myWindow attachToParent: parentWindow]; } - // Immediately re-position the window based on an upper-left coordinate system - setWindowClientTopLeftPoint(myWindow, x, y); + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", + dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); - // force surface creation - [myView lockFocus]; - [myView unlockFocus]; + // Immediately re-position the window based on an upper-left coordinate system + setWindowClientTopLeftPointAndSize(myWindow, x, y, w, h, NO); NS_DURING // concurrent view rendering @@ -696,12 +774,24 @@ NS_DURING NS_HANDLER NS_ENDHANDLER + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", + dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + // visible on front - [myWindow orderFront: myWindow]; + if( JNI_FALSE == offscreen ) { + [myWindow orderFront: myWindow]; + } + + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", + dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + + // force surface creation + // [myView lockFocus]; + // [myView unlockFocus]; NS_DURING // Available >= 10.5 - Makes the menubar disapear - if(fullscreen) { + if( fullscreen ) { if ( [myView respondsToSelector:@selector(enterFullScreenMode:withOptions:)] ) { [myView enterFullScreenMode: myScreen withOptions:NULL]; } @@ -713,12 +803,10 @@ NS_ENDHANDLER // right mouse button down events [myView setNextResponder: myWindow]; - DBG_PRINT( "createWindow0 - %p (this), %p (parent): new window: %p, view %p,%d (END)\n", + DBG_PRINT( "initWindow0.X - %p (this), %p (parent): new window: %p, view %p,%d\n", (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView, getRetainCount(myView)); [pool release]; - - return (jlong) ((intptr_t) myWindow); } /** @@ -740,7 +828,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 DBG_PRINT( "windowClose.0 - %p,%d, destroyNotifySent %d, view %p,%d, parent %p\n", mWin, getRetainCount(mWin), destroyNotifySent, mView, getRetainCount(mView), pWin); - [mWin setUnrealized]; + [mWin setRealized: NO]; if(NULL!=mView) { // cleanup view @@ -786,8 +874,7 @@ NS_ENDHANDLER [mWin release]; } - DBG_PRINT( "windowClose.X - %p,%d, released %d, view %p,%d, parent %p\n", - mWin, getRetainCount(mWin), !destroyNotifySent, mView, getRetainCount(mView), pWin); + DBG_PRINT( "windowClose.Xp\n"); [pool release]; } @@ -795,16 +882,16 @@ NS_ENDHANDLER /* * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: lockSurface0 - * Signature: (J)Z + * Signature: (JJ)Z */ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_lockSurface0 - (JNIEnv *env, jclass clazz, jlong window) + (JNIEnv *env, jclass clazz, jlong window, jlong view) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); if(NO == [mWin isRealized]) { return JNI_FALSE; } - NewtView * mView = (NewtView *) [mWin contentView]; + NewtView * mView = (NewtView *) ((intptr_t) view); return [mView softLock] == YES ? JNI_TRUE : JNI_FALSE; /** deadlocks, since we render independent of focus return [mView lockFocusIfCanDraw] == YES ? JNI_TRUE : JNI_FALSE; */ @@ -813,14 +900,15 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_lockSurfa /* * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: unlockSurface0 - * Signature: (J)V + * Signature: (JJ)Z */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_unlockSurface0 - (JNIEnv *env, jclass clazz, jlong window) +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_unlockSurface0 + (JNIEnv *env, jclass clazz, jlong window, jlong view) { - NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); - NewtView * mView = (NewtView *) [mWin contentView]; - [mView softUnlock]; + // NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); + (void) window; + NewtView * mView = (NewtView *) ((intptr_t) view); + return [mView softUnlock] == YES ? JNI_TRUE : JNI_FALSE; /** deadlocks, since we render independent of focus [mView unlockFocus]; */ } @@ -946,7 +1034,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setTitle0 /* * Class: jogamp_newt_driver_macosx_WindowDriver - * Method: contentView + * Method: contentView0 * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_contentView0 @@ -954,12 +1042,16 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_contentView0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); + NSView* nsView = [win contentView]; + NewtView* newtView = NULL; - DBG_PRINT( "contentView0 - window: %p (START)\n", win); + if( [nsView isKindOfClass:[NewtView class]] ) { + newtView = (NewtView *) nsView; + } - jlong res = (jlong) ((intptr_t) [win contentView]); + DBG_PRINT( "contentView0 - window: %p, view: %p, newtView %p\n", win, nsView, newtView); - DBG_PRINT( "contentView0 - window: %p (END)\n", win); + jlong res = (jlong) ((intptr_t) nsView); [pool release]; return res; @@ -970,24 +1062,18 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_contentView0 * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: changeContentView - * Signature: (J)J + * Signature: (J)V */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_changeContentView0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_changeContentView0 (JNIEnv *env, jobject jthis, jlong parentWindowOrView, jlong window, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtView* newView = (NewtView *) ((intptr_t) jview); NewtMacWindow* win = (NewtMacWindow*) ((intptr_t) window); - NSView* oldNSView = [win contentView]; - NewtView* oldView = NULL; - if( [oldNSView isMemberOfClass:[NewtView class]] ) { - oldView = (NewtView *) oldNSView; - } - - DBG_PRINT( "changeContentView0.0 - win %p, view (%p,%d (%d) -> %p,%d)\n", - win, oldNSView, getRetainCount(oldNSView), NULL!=oldView, newView, getRetainCount(newView)); + DBG_PRINT( "changeContentView0.0 - win %p, view (%p,%d)\n", + win, newView, getRetainCount(newView)); NSObject *nsParentObj = (NSObject*) ((intptr_t) parentWindowOrView); NSView* pView = NULL; @@ -1002,12 +1088,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_changeConten changeContentView(env, jthis, pView, win, newView); - DBG_PRINT( "changeContentView0.X - win %p, view (%p,%d (%d) -> %p,%d)\n", - win, oldNSView, getRetainCount(oldNSView), NULL!=oldView, newView, getRetainCount(newView)); + DBG_PRINT( "changeContentView0.X\n"); [pool release]; - - return (jlong) ((intptr_t) oldView); } /* @@ -1023,7 +1106,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setWindowClie DBG_PRINT( "setWindowClientTopLeftPointAndSize - window: %p (START)\n", mWin); - setWindowClientTopLeftPointAndSize(mWin, x, y, w, h); + setWindowClientTopLeftPointAndSize(mWin, x, y, w, h, YES); DBG_PRINT( "setWindowClientTopLeftPointAndSize - window: %p (END)\n", mWin); diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index 6d1bcca00..09f4a1fd3 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -47,6 +47,8 @@ #define DBG_PRINT(...) #endif +// #define DBG_LIFECYCLE 1 + @interface NewtView : NSView { jobject javaWindowObject; @@ -56,16 +58,19 @@ int jvmVersion; volatile BOOL destroyNotifySent; - volatile BOOL softLocked; + volatile int softLockCount; pthread_mutex_t softLockSync; - NSTrackingRectTag ptrTrackingTag; + volatile NSTrackingRectTag ptrTrackingTag; NSRect ptrRect; NSCursor * myCursor; } - (id)initWithFrame:(NSRect)frameRect; + +#ifdef DBG_LIFECYCLE - (void) release; +#endif - (void) dealloc; /* Set during event dispatching cycle */ @@ -87,7 +92,7 @@ - (BOOL) getDestroyNotifySent; - (BOOL) softLock; -- (void) softUnlock; +- (BOOL) softUnlock; - (BOOL) needsDisplay; - (void) displayIfNeeded; @@ -125,18 +130,21 @@ defer: (BOOL) deferCreation screen:(NSScreen *)screen isFullscreenWindow:(BOOL)isfs; +#ifdef DBG_LIFECYCLE - (void) release; +#endif - (void) dealloc; -- (void) setUnrealized; +- (void) setRealized: (BOOL)v; - (BOOL) isRealized; -- (void) updateInsets: (JNIEnv*) env; +- (void) updateInsets: (JNIEnv*) env jwin: (jobject) javaWin; - (void) attachToParent: (NSWindow*) parent; - (void) detachFromParent: (NSWindow*) parent; - (NSPoint) newtAbsClientTLWinPos2AbsBLScreenPos: (NSPoint) p; - (NSPoint) newtAbsClientTLWinPos2AbsBLScreenPos: (NSPoint) p size: (NSSize) nsz; - (NSPoint) newtRelClientTLWinPos2AbsBLScreenPos: (NSPoint) p; +- (NSSize) newtClientSize2TLSize: (NSSize) nsz; - (NSPoint) getLocationOnScreen: (NSPoint) p; - (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 282c13fd3..d7b357349 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -113,7 +113,7 @@ static jmethodID windowRepaintID = NULL; jvmHandle = NULL; jvmVersion = 0; destroyNotifySent = NO; - softLocked = NO; + softLockCount = 0; pthread_mutexattr_t softLockSyncAttr; pthread_mutexattr_init(&softLockSyncAttr); @@ -134,19 +134,21 @@ static jmethodID windowRepaintID = NULL; return res; } +#ifdef DBG_LIFECYCLE - (void) release { DBG_PRINT("NewtView::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); -#ifdef VERBOSE_ON - // NSLog(@"%@",[NSThread callStackSymbols]); -#endif [super release]; } +#endif - (void) dealloc { DBG_PRINT("NewtView::dealloc.0: %p (refcnt %d), ptrTrackingTag %d\n", self, (int)[self retainCount], (int)ptrTrackingTag); - if(softLocked) { +#ifdef DBG_LIFECYCLE + NSLog(@"%@",[NSThread callStackSymbols]); +#endif + if( 0 < softLockCount ) { NSLog(@"NewtView::dealloc: softLock still hold @ dealloc!\n"); } if(0 != ptrTrackingTag) { @@ -155,9 +157,6 @@ static jmethodID windowRepaintID = NULL; ptrTrackingTag = 0; } pthread_mutex_destroy(&softLockSync); -#ifdef VERBOSE_ON - //NSLog(@"%@",[NSThread callStackSymbols]); -#endif DBG_PRINT("NewtView::dealloc.X: %p\n", self); [super dealloc]; } @@ -206,6 +205,7 @@ static jmethodID windowRepaintID = NULL; if(0 != ptrTrackingTag) { // [self removeCursorRect: ptrRect cursor: myCursor]; [self removeTrackingRect: ptrTrackingTag]; + ptrTrackingTag = 0; } ptrRect = [self bounds]; // [self addCursorRect: ptrRect cursor: myCursor]; @@ -230,18 +230,27 @@ static jmethodID windowRepaintID = NULL; - (BOOL) softLock { // DBG_PRINT("*************** softLock.0: %p\n", (void*)pthread_self()); - // NSLog(@"NewtView::softLock: %@",[NSThread callStackSymbols]); - pthread_mutex_lock(&softLockSync); - softLocked = YES; + int err; + if( 0 != ( err = pthread_mutex_lock(&softLockSync) ) ) { + NSLog(@"NewtView::softLock failed: errCode %d - %@", err, [NSThread callStackSymbols]); + return NO; + } + softLockCount++; // DBG_PRINT("*************** softLock.X: %p\n", (void*)pthread_self()); - return softLocked; + return 0 < softLockCount; } -- (void) softUnlock +- (BOOL) softUnlock { // DBG_PRINT("*************** softUnlock: %p\n", (void*)pthread_self()); - softLocked = NO; - pthread_mutex_unlock(&softLockSync); + softLockCount--; + int err; + if( 0 != ( err = pthread_mutex_unlock(&softLockSync) ) ) { + softLockCount++; + NSLog(@"NewtView::softUnlock failed: Not locked by current thread - errCode %d - %@", err, [NSThread callStackSymbols]); + return NO; + } + return YES; } - (BOOL) needsDisplay @@ -398,25 +407,26 @@ static jmethodID windowRepaintID = NULL; mouseInside = NO; cursorIsHidden = NO; realized = YES; - DBG_PRINT("NewtWindow::create: %p (refcnt %d)\n", res, (int)[res retainCount]); + DBG_PRINT("NewtWindow::create: %p, realized %d (refcnt %d)\n", res, realized, (int)[res retainCount]); return res; } +#ifdef DBG_LIFECYCLE - (void) release { DBG_PRINT("NewtWindow::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); -#ifdef VERBOSE_ON // NSLog(@"%@",[NSThread callStackSymbols]); -#endif [super release]; } +#endif - (void) dealloc { DBG_PRINT("NewtWindow::dealloc.0: %p (refcnt %d)\n", self, (int)[self retainCount]); -#ifdef VERBOSE_ON - // NSLog(@"%@",[NSThread callStackSymbols]); +#ifdef DBG_LIFECYCLE + NSLog(@"%@",[NSThread callStackSymbols]); #endif + NewtView* mView = (NewtView *)[self contentView]; if( NULL != mView ) { [mView release]; @@ -425,9 +435,9 @@ static jmethodID windowRepaintID = NULL; DBG_PRINT("NewtWindow::dealloc.X: %p\n", self); } -- (void) setUnrealized +- (void) setRealized: (BOOL)v { - realized = NO; + realized = v; } - (BOOL) isRealized @@ -435,18 +445,8 @@ static jmethodID windowRepaintID = NULL; return realized; } -- (void) updateInsets: (JNIEnv*) env +- (void) updateInsets: (JNIEnv*) env jwin: (jobject) javaWin { - NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { - return; - } - NewtView* view = (NewtView *) nsview; - jobject javaWindowObject = [view getJavaWindowObject]; - if (env==NULL || javaWindowObject == NULL) { - return; - } - NSRect frameRect = [self frame]; NSRect contentRect = [self contentRectForFrameRect: frameRect]; @@ -460,7 +460,9 @@ static jmethodID windowRepaintID = NULL; DBG_PRINT( "updateInsets: [ l %d, r %d, t %d, b %d ]\n", cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]); - (*env)->CallVoidMethod(env, javaWindowObject, insetsChangedID, JNI_FALSE, cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]); + if( NULL != env && NULL != javaWin ) { + (*env)->CallVoidMethod(env, javaWin, insetsChangedID, JNI_FALSE, cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]); + } } - (void) attachToParent: (NSWindow*) parent @@ -502,11 +504,21 @@ static jmethodID windowRepaintID = NULL; { int totalHeight = nsz.height + cachedInsets[3]; // height + insets.bottom + DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: given %d/%d %dx%d, insets bottom %d -> totalHeight %d\n", + (int)p.x, (int)p.y, (int)nsz.width, (int)nsz.height, cachedInsets[3], totalHeight); + NSScreen* screen = [self screen]; NSRect screenFrame = [screen frame]; - return NSMakePoint(screenFrame.origin.x + p.x, - screenFrame.origin.y + screenFrame.size.height - p.y - totalHeight); + DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: screen %d/%d %dx%d\n", + (int)screenFrame.origin.x, (int)screenFrame.origin.y, (int)screenFrame.size.width, (int)screenFrame.size.height); + + NSPoint r = NSMakePoint(screenFrame.origin.x + p.x, + screenFrame.origin.y + screenFrame.size.height - p.y - totalHeight); + + DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: result %d/%d\n", (int)r.x, (int)r.y); + + return r; } /** @@ -524,6 +536,12 @@ static jmethodID windowRepaintID = NULL; winFrame.origin.y + ( mViewFrame.size.height - p.y ) ); // y-flip in view } +- (NSSize) newtClientSize2TLSize: (NSSize) nsz +{ + NSSize topSZ = { nsz.width, nsz.height + cachedInsets[2] + cachedInsets[3] }; // height + insets.top + insets.bottom + return topSZ; +} + /** * y-flips input / output * p rel client window position w/ top-left origin @@ -646,7 +664,7 @@ static jint mods2JavaMods(NSUInteger mods) - (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType { NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { + if( ! [nsview isKindOfClass:[NewtView class]] ) { return; } NewtView* view = (NewtView *) nsview; @@ -706,7 +724,7 @@ static jint mods2JavaMods(NSUInteger mods) - (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType { NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { + if( ! [nsview isKindOfClass:[NewtView class]] ) { return; } NewtView* view = (NewtView *) nsview; @@ -783,7 +801,7 @@ static jint mods2JavaMods(NSUInteger mods) { DBG_PRINT( "focusChanged: gained %d\n", gained); NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { + if( ! [nsview isKindOfClass:[NewtView class]] ) { return; } NewtView* view = (NewtView *) nsview; @@ -981,43 +999,42 @@ static jint mods2JavaMods(NSUInteger mods) - (void)windowDidResize: (NSNotification*) notification { - NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { - return; - } - NewtView* view = (NewtView *) nsview; - jobject javaWindowObject = [view getJavaWindowObject]; - if (javaWindowObject == NULL) { - DBG_PRINT("windowDidResize: null javaWindowObject\n"); - return; - } + JNIEnv* env = NULL; + jobject javaWindowObject = NULL; int shallBeDetached = 0; - JavaVM *jvmHandle = [view getJVMHandle]; - JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached); - if(NULL==env) { - DBG_PRINT("windowDidResize: null JNIEnv\n"); - return; + JavaVM *jvmHandle = NULL; + + NSView* nsview = [self contentView]; + if( [nsview isKindOfClass:[NewtView class]] ) { + NewtView* view = (NewtView *) nsview; + javaWindowObject = [view getJavaWindowObject]; + if (javaWindowObject != NULL) { + jvmHandle = [view getJVMHandle]; + env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached); + } } // update insets on every window resize for lack of better hook place - [self updateInsets: env]; + [self updateInsets: env jwin:javaWindowObject]; - NSRect frameRect = [self frame]; - NSRect contentRect = [self contentRectForFrameRect: frameRect]; + if( NULL != env && NULL != javaWindowObject ) { + NSRect frameRect = [self frame]; + NSRect contentRect = [self contentRectForFrameRect: frameRect]; - (*env)->CallVoidMethod(env, javaWindowObject, sizeChangedID, JNI_FALSE, - (jint) contentRect.size.width, - (jint) contentRect.size.height, JNI_FALSE); + (*env)->CallVoidMethod(env, javaWindowObject, sizeChangedID, JNI_FALSE, + (jint) contentRect.size.width, + (jint) contentRect.size.height, JNI_FALSE); - if (shallBeDetached) { - (*jvmHandle)->DetachCurrentThread(jvmHandle); + if (shallBeDetached) { + (*jvmHandle)->DetachCurrentThread(jvmHandle); + } } } - (void)windowDidMove: (NSNotification*) notification { NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { + if( ! [nsview isKindOfClass:[NewtView class]] ) { return; } NewtView* view = (NewtView *) nsview; @@ -1061,7 +1078,7 @@ static jint mods2JavaMods(NSUInteger mods) [self cursorHide: NO]; NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { + if( ! [nsview isKindOfClass:[NewtView class]] ) { return NO; } NewtView* view = (NewtView *) nsview; -- cgit v1.2.3 From 1a1557cd9e31bd7975d858b7b2d49e586805bba4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 19 Mar 2013 05:27:59 +0100 Subject: OSX/NEWT: NSWindow/NSView Ops on main-thread w/o blocking - Part2 Continues commit 81cbcdc8469143587b2044661dd613c798ae02ba Perform on main-thread invocation from Java, allowing to issue visibleChanged(..) after creation/visible calls. This fixes the 'Visibility not reached ..' regressions. --- .../jogamp/newt/driver/macosx/WindowDriver.java | 112 ++++++++++++++------- src/newt/native/MacWindow.m | 67 ++++++------ 2 files changed, 117 insertions(+), 62 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index d3a92e023..a15c9cded 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -142,23 +142,35 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl sscSurfaceHandle = surfaceHandle; if (isNativeValid()) { if (0 != sscSurfaceHandle) { - orderOut0( 0 != getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + orderOut0( 0 != getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); + } } ); } /** this is done by recreation! else if (isVisible()){ - orderFront0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + orderFront0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); + } } ); } */ } } @Override protected void setTitleImpl(final String title) { - setTitle0(getWindowHandle(), title); + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + setTitle0(getWindowHandle(), title); + } } ); } @Override - protected void requestFocusImpl(boolean force) { + protected void requestFocusImpl(final boolean force) { if(!isOffscreenInstance) { - requestFocus0(getWindowHandle(), force); + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + requestFocus0(getWindowHandle(), force); + } } ); } else { focusChanged(false, true); } @@ -170,7 +182,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl System.err.println("MacWindow: clearFocus(), isOffscreenInstance "+isOffscreenInstance); } if(!isOffscreenInstance) { - resignFocus0(getWindowHandle()); + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + resignFocus0(getWindowHandle()); + } } ); } else { focusChanged(false, false); } @@ -247,41 +262,52 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) { if ( !isOffscreenInstance ) { - orderOut0(getWindowHandle()); + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + orderOut0(getWindowHandle()); + visibleChanged(true, false); + } } ); + } else { + visibleChanged(true, false); } - // no native event .. - visibleChanged(true, false); } if( 0 == getWindowHandle() && 0 != ( FLAG_IS_VISIBLE & flags) || 0 != ( FLAG_CHANGE_DECORATION & flags) || 0 != ( FLAG_CHANGE_PARENTING & flags) || 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { + final boolean setVisible = 0 != ( FLAG_IS_VISIBLE & flags); if(isOffscreenInstance) { - createWindow(true, 0 != getWindowHandle(), pClientLevelOnSreen, 64, 64, false); + createWindow(true, 0 != getWindowHandle(), pClientLevelOnSreen, 64, 64, false, setVisible, false); } else { - createWindow(false, 0 != getWindowHandle(), pClientLevelOnSreen, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); + createWindow(false, 0 != getWindowHandle(), pClientLevelOnSreen, width, height, + 0 != ( FLAG_IS_FULLSCREEN & flags), setVisible, 0 != ( FLAG_IS_ALWAYSONTOP & flags)); + } + } else { + if( width>0 && height>0 ) { + if( !isOffscreenInstance ) { + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + setWindowClientTopLeftPointAndSize0(getWindowHandle(), pClientLevelOnSreen.getX(), pClientLevelOnSreen.getY(), width, height); + } } ); + } // else offscreen size is realized via recreation + // no native event (fullscreen, some reparenting) + positionChanged(true, x, y); + sizeChanged(true, width, height, false); + } + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) { + if( !isOffscreenInstance ) { + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + orderFront0(getWindowHandle()); + visibleChanged(true, true); + } } ); + } else { + visibleChanged(true, true); + } } - if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; } - } else if( width>0 && height>0 ) { if( !isOffscreenInstance ) { - OSXUtil.RunOnMainThread(false, new Runnable() { - public void run() { - setWindowClientTopLeftPointAndSize0(getWindowHandle(), pClientLevelOnSreen.getX(), pClientLevelOnSreen.getY(), width, height); - } } ); - } // else offscreen size is realized via recreation - // no native event (fullscreen, some reparenting) - positionChanged(true, x, y); - sizeChanged(true, width, height, false); - } - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) { - if( !isOffscreenInstance ) { - orderFront0(getWindowHandle()); + setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags)); } - // no native event .. - visibleChanged(true, true); - } - if( !isOffscreenInstance ) { - setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags)); } if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow reconfig.X: clientPos "+pClientLevelOnSreen+", "+width+"x"+height+" -> clientPos "+getLocationOnScreenImpl(0, 0)+", insets: "+getInsets()); @@ -406,11 +432,19 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private void createWindow(final boolean offscreenInstance, final boolean recreate, final PointImmutable pS, final int width, final int height, - final boolean fullscreen) { + final boolean fullscreen, final boolean visible, final boolean alwaysOnTop) { if( 0 != getWindowHandle() && !recreate ) { return; } + + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow.createWindow on thread "+Thread.currentThread().getName()+ + ": offscreen "+offscreenInstance+", recreate "+recreate+ + ", pS "+pS+", "+width+"x"+height+", fullscreen "+fullscreen+", visible "+visible+ + ", alwaysOnTop "+alwaysOnTop); + // Thread.dumpStack(); + } try { final long parentWin = getParentWindowHandle(); @@ -451,12 +485,14 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl public void run() { initWindow0( parentWin, newWin, pS.getX(), pS.getY(), width, height, - isOpaque, fullscreen, offscreenInstance, getScreen().getIndex(), surfaceHandle); + isOpaque, fullscreen, visible, offscreenInstance, getScreen().getIndex(), surfaceHandle); if( offscreenInstance ) { orderOut0(0!=parentWin ? parentWin : newWin); } else { setTitle0(newWin, getTitle()); + setAlwaysOnTop0(getWindowHandle(), alwaysOnTop); } + visibleChanged(true, visible); } } ); } catch (Exception ie) { ie.printStackTrace(); @@ -468,22 +504,30 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private native long createWindow0(int x, int y, int w, int h, boolean fullscreen, int windowStyle, int backingStoreType, int screen_idx, long view); /** Must be called on Main-Thread */ private native void initWindow0(long parentWindow, long window, int x, int y, int w, int h, - boolean opaque, boolean fullscreen, boolean offscreen, int screen_idx, long view); + boolean opaque, boolean fullscreen, boolean visible, boolean offscreen, + int screen_idx, long view); private native boolean lockSurface0(long window, long view); private native boolean unlockSurface0(long window, long view); + /** Must be called on Main-Thread */ private native void requestFocus0(long window, boolean force); + /** Must be called on Main-Thread */ private native void resignFocus0(long window); - /** in case of a child window, it actually only issues orderBack(..) */ + /** Must be called on Main-Thread. In case of a child window, it actually only issues orderBack(..) */ private native void orderOut0(long window); + /** Must be called on Main-Thread */ private native void orderFront0(long window); /** Must be called on Main-Thread */ private native void close0(long window); + /** Must be called on Main-Thread */ private native void setTitle0(long window, String title); private native long contentView0(long window); /** Must be called on Main-Thread */ private native void changeContentView0(long parentWindowOrView, long window, long view); + /** Must be called on Main-Thread */ private native void setWindowClientTopLeftPointAndSize0(long window, int x, int y, int w, int h); + /** Must be called on Main-Thread */ private native void setWindowClientTopLeftPoint0(long window, int x, int y); + /** Must be called on Main-Thread */ private native void setAlwaysOnTop0(long window, boolean atop); private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y); private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index db4420b49..e3f4eae34 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -62,30 +62,36 @@ static NSString* jstringToNSString(JNIEnv* env, jstring jstr) return str; } -static void setWindowClientTopLeftPoint(NewtMacWindow* mWin, jint x, jint y) { +static void setWindowClientTopLeftPoint(NewtMacWindow* mWin, jint x, jint y, BOOL doDisplay) { + DBG_PRINT( "setWindowClientTopLeftPoint.0 - window: %p %d/%d, display %d\n", mWin, (int)x, (int)y, (int)doDisplay); NSPoint pS = [mWin newtAbsClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y)]; + DBG_PRINT( "setWindowClientTopLeftPoint.1: %d/%d\n", (int)pS.x, (int)pS.y); + [mWin setFrameOrigin: pS]; + DBG_PRINT( "setWindowClientTopLeftPoint.X: %d/%d\n", (int)pS.x, (int)pS.y); - NSView* mView = [mWin contentView]; - [mWin invalidateCursorRectsForView: mView]; + if( doDisplay ) { + NSView* mView = [mWin contentView]; + [mWin invalidateCursorRectsForView: mView]; + } } static void setWindowClientTopLeftPointAndSize(NewtMacWindow* mWin, jint x, jint y, jint width, jint height, BOOL doDisplay) { - DBG_PRINT( "setWindowClientTopLeftPointAndSize.0 - window: %p %d/%d %dx%d\n", - mWin, (int)x, (int)y, (int)width, (int)height); + DBG_PRINT( "setWindowClientTopLeftPointAndSize.0 - window: %p %d/%d %dx%d, display %d\n", mWin, (int)x, (int)y, (int)width, (int)height, (int)doDisplay); NSSize clientSZ = NSMakeSize(width, height); NSPoint pS = [mWin newtAbsClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y) size: clientSZ]; NSSize topSZ = [mWin newtClientSize2TLSize: clientSZ]; NSRect rect = { pS, topSZ }; - - DBG_PRINT( "setWindowClientTopLeftPointAndSize.X: %d/%d %dx%d\n", - (int)rect.origin.x, (int)rect.origin.y, (int)rect.size.width, (int)rect.size.height); + DBG_PRINT( "setWindowClientTopLeftPointAndSize.1: %d/%d %dx%d\n", (int)rect.origin.x, (int)rect.origin.y, (int)rect.size.width, (int)rect.size.height); [mWin setFrame: rect display:doDisplay]; + DBG_PRINT( "setWindowClientTopLeftPointAndSize.X: %d/%d %dx%d\n", (int)rect.origin.x, (int)rect.origin.y, (int)rect.size.width, (int)rect.size.height); // -> display:YES - // NSView* mView = [mWin contentView]; - // [mWin invalidateCursorRectsForView: mView]; + // if( doDisplay ) { + // NSView* mView = [mWin contentView]; + // [mWin invalidateCursorRectsForView: mView]; + // } } #ifdef VERBOSE_ON @@ -665,19 +671,19 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: initWindow0 - * Signature: (JJIIIIZZZIIJ)V + * Signature: (JJIIIIZZZZIIJ)V */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initWindow0 (JNIEnv *env, jobject jthis, jlong parent, jlong window, jint x, jint y, jint w, jint h, - jboolean opaque, jboolean fullscreen, jboolean offscreen, jint screen_idx, jlong jview) + jboolean opaque, jboolean fullscreen, jboolean visible, jboolean offscreen, jint screen_idx, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* myWindow = (NewtMacWindow*) ((intptr_t) window); NewtView* myView = (NewtView*) (intptr_t) jview ; - DBG_PRINT( "initWindow0 - %p (this), %p (parent), %p (window), %d/%d %dx%d, opaque %d, fs %d, offscreen %d, screenidx %d, view %p (START)\n", - (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, (int)x, (int)y, (int)w, (int)h, (int) opaque, (int)fullscreen, - (int)offscreen, (int)screen_idx, myView); + DBG_PRINT( "initWindow0 - %p (this), %p (parent), %p (window), %d/%d %dx%d, opaque %d, fs %d, visible %d, offscreen %d, screenidx %d, view %p (START)\n", + (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, (int)x, (int)y, (int)w, (int)h, + (int) opaque, (int)fullscreen, (int)visible, (int)offscreen, (int)screen_idx, myView); NSArray *screens = [NSScreen screens]; if(screen_idx<0) screen_idx=0; @@ -759,15 +765,22 @@ NS_ENDHANDLER DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); - // Immediately re-position the window based on an upper-left coordinate system + // Immediately re-position this window based on an upper-left coordinate system setWindowClientTopLeftPointAndSize(myWindow, x, y, w, h, NO); + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", + dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + NS_DURING // concurrent view rendering // Available >= 10.6 - Makes the menubar disapear if ( [myWindow respondsToSelector:@selector(setAllowsConcurrentViewDrawing:)] ) { [myWindow setAllowsConcurrentViewDrawing: YES]; } + + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", + dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + if ( [myView respondsToSelector:@selector(setCanDrawConcurrently:)] ) { [myView setCanDrawConcurrently: YES]; } @@ -778,7 +791,7 @@ NS_ENDHANDLER dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); // visible on front - if( JNI_FALSE == offscreen ) { + if( JNI_TRUE == visible && JNI_FALSE == offscreen ) { [myWindow orderFront: myWindow]; } @@ -861,7 +874,6 @@ NS_ENDHANDLER if(NULL!=pWin) { [mWin detachFromParent: pWin]; } - // [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:NO]; [mWin orderOut: mWin]; DBG_PRINT( "windowClose.1 - %p,%d view %p,%d, parent %p\n", @@ -870,7 +882,6 @@ NS_ENDHANDLER // Only release window, if release is not yet in process. // E.g. destroyNotifySent:=true set by NewtMacWindow::windowWillClose(), i.e. window-close was clicked. if(!destroyNotifySent) { - // [mWin performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO]; [mWin release]; } @@ -930,8 +941,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_requestFocus0 DBG_PRINT( "requestFocus - window: %p, force %d, hasFocus %d (START)\n", mWin, force, hasFocus); [mWin makeFirstResponder: nil]; - [mWin performSelectorOnMainThread:@selector(orderFrontRegardless) withObject:nil waitUntilDone:NO]; - [mWin performSelectorOnMainThread:@selector(makeKeyWindow) withObject:nil waitUntilDone:NO]; + [mWin orderFrontRegardless]; + [mWin makeKeyWindow]; DBG_PRINT( "requestFocus - window: %p, force %d (END)\n", mWin, force); @@ -954,10 +965,10 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_resignFocus0 DBG_PRINT( "requestFocusParent0 - window: %p, parent %p, hasFocus %d (START)\n", mWin, pWin, hasFocus ); if( hasFocus ) { if(NULL != pWin) { - // [mWin performSelectorOnMainThread:@selector(makeFirstResponder:) withObject:pWin waitUntilDone:NO]; - [pWin performSelectorOnMainThread:@selector(makeKeyWindow) withObject:nil waitUntilDone:NO]; + // [mWin makeFirstResponder: pWin]; + [pWin makeKeyWindow]; } else { - [mWin performSelectorOnMainThread:@selector(resignKeyWindow) withObject:nil waitUntilDone:NO]; + [pWin resignKeyWindow]; } } DBG_PRINT( "requestFocusParent0 - window: %p (END)\n", mWin); @@ -978,7 +989,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_orderFront0 DBG_PRINT( "orderFront0 - window: %p (START)\n", win); - [win performSelectorOnMainThread:@selector(orderFrontRegardless) withObject:nil waitUntilDone:NO]; + [win orderFrontRegardless]; DBG_PRINT( "orderFront0 - window: %p (END)\n", win); @@ -1000,9 +1011,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_orderOut0 DBG_PRINT( "orderOut0 - window: (parent %p) %p (START)\n", pWin, mWin); if(NULL == pWin) { - [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:NO]; + [mWin orderOut: mWin]; } else { - [mWin performSelectorOnMainThread:@selector(orderBack:) withObject:mWin waitUntilDone:NO]; + [mWin orderBack: mWin]; } DBG_PRINT( "orderOut0 - window: (parent %p) %p (END)\n", pWin, mWin); @@ -1126,7 +1137,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setWindowClie DBG_PRINT( "setWindowClientTopLeftPoint - window: %p (START)\n", mWin); - setWindowClientTopLeftPoint(mWin, x, y); + setWindowClientTopLeftPoint(mWin, x, y, YES); DBG_PRINT( "setWindowClientTopLeftPoint - window: %p (END)\n", mWin); -- cgit v1.2.3 From ec50802db11f897a49a6f9e716186c700411ece5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 20 Mar 2013 16:15:04 +0100 Subject: OSX/NEWT: Fix native window parenting freeze, invisible/orderOut0, Position bugs w/ parenting Fix native window parenting freeze: - Pull out setJavaWindowObject(..) of changeContentView(..) to be called seperately, add param for changeContentView(..) to enable/disable setJavaWindowObject() - initWindow0(..): - Call changeContentView(..) w/o setJavaWindowObject() - setJavaWindowObject(..) at end of initialization Fix native window parenting orderOut0: If parent window is invisible or no parent used call orderOut(..), otherwise call orderBack(). Fix updatePosition(..): positionChanged(..) - Position bug w/ parenting - AWT parent passed 0/0 - call positionChanged(..) w/ client-pos instead of screen-pos Fix getLocationOnScreenImpl(..) - Position bug w/ parenting - Position < 0/0 is valid! Misc: - setWindowClientTopLeftPointAndSize0(..), setWindowClientTopLeftPoint0(..): Add 'display' param, deciding whether area should be display (invalidated) --- .../newt/awt/event/AWTParentWindowAdapter.java | 2 +- .../jogamp/newt/driver/DriverUpdatePosition.java | 10 ++- .../jogamp/newt/driver/macosx/WindowDriver.java | 66 ++++++++------- src/newt/native/MacWindow.m | 98 +++++++++++++--------- 4 files changed, 101 insertions(+), 75 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index b348220d6..fa494adca 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -115,7 +115,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt } final Window newtWindow = getNewtWindow(); if(newtWindow.getDelegatedWindow() instanceof DriverUpdatePosition) { - ((DriverUpdatePosition)newtWindow.getDelegatedWindow()).updatePosition(); + ((DriverUpdatePosition)newtWindow.getDelegatedWindow()).updatePosition(0, 0); } } diff --git a/src/newt/classes/jogamp/newt/driver/DriverUpdatePosition.java b/src/newt/classes/jogamp/newt/driver/DriverUpdatePosition.java index bb846c081..2ec327187 100644 --- a/src/newt/classes/jogamp/newt/driver/DriverUpdatePosition.java +++ b/src/newt/classes/jogamp/newt/driver/DriverUpdatePosition.java @@ -4,6 +4,12 @@ package jogamp.newt.driver; * Interface tagging driver requirement of absolute positioning, ie. depend on parent position. */ public interface DriverUpdatePosition { - /** Programmatic update the position */ - void updatePosition(); + /** + * Programmatic update the top-left corner + * of the client area relative to it's parent. + * + * @param x x-component + * @param y y-component + **/ + void updatePosition(int x, int y); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index a15c9cded..653e90e3b 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -191,20 +191,25 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } + private boolean useParent(NativeWindow parent) { return null != parent && 0 != parent.getWindowHandle(); } + @Override - public void updatePosition() { + public void updatePosition(int x, int y) { final long handle = getWindowHandle(); if( 0 != handle && !isOffscreenInstance ) { - final Point pS = getLocationOnScreenImpl(0, 0); + final NativeWindow parent = getParent(); + final boolean useParent = useParent(parent); + final int pX=parent.getX(), pY=parent.getY(); + final Point p0S = getLocationOnScreenImpl(x, y, parent, useParent); if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow: updatePosition() -> abs child-client-pos: "+pS); + System.err.println("MacWindow: updatePosition() parent["+useParent+" "+pX+"/"+pY+"] "+x+"/"+y+" -> "+x+"/"+y+" rel-client-pos, "+p0S+" screen-client-pos"); } OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { - setWindowClientTopLeftPoint0(handle, pS.getX(), pS.getY()); + setWindowClientTopLeftPoint0(handle, p0S.getX(), p0S.getY(), isVisible()); } } ); // no native event (fullscreen, some reparenting) - positionChanged(true, pS.getX(), pS.getY()); + positionChanged(true, x, y); } } @@ -213,15 +218,16 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final long handle = getWindowHandle(); if( 0 != handle && !isOffscreenInstance ) { final NativeWindow parent = getParent(); - final boolean useParent = null != parent && 0 != parent.getWindowHandle() ; + final boolean useParent = useParent(parent); if( useParent && ( getWidth() != newWidth || getHeight() != newHeight ) ) { - final Point p0S = getLocationOnScreenImpl(0, 0); + final int x=getX(), y=getY(); + final Point p0S = getLocationOnScreenImpl(x, y, parent, useParent); if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow: sizeChanged() "+newWidth+"x"+newHeight+" -> abs child-client-pos "+p0S); + System.err.println("MacWindow: sizeChanged() parent["+useParent+" "+x+"/"+y+"] "+getX()+"/"+getY()+" "+newWidth+"x"+newHeight+" -> "+p0S+" screen-client-pos"); } OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { - setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY()); + setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY(), isVisible()); } } ); } } @@ -237,9 +243,9 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl pClientLevelOnSreen = new Point(0, 0); } else { final NativeWindow parent = getParent(); - final boolean useParent = null != parent && 0 != parent.getWindowHandle() ; + final boolean useParent = useParent(parent); if( useParent ) { - pClientLevelOnSreen = getLocationOnScreenImpl(x, y); + pClientLevelOnSreen = getLocationOnScreenImpl(x, y, parent, useParent); } else { pClientLevelOnSreen = new Point(x, y); } @@ -260,7 +266,9 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // Thread.dumpStack(); } - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) { + final boolean setVisible = 0 != ( FLAG_IS_VISIBLE & flags); + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && !setVisible ) { if ( !isOffscreenInstance ) { OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { @@ -271,13 +279,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl visibleChanged(true, false); } } - if( 0 == getWindowHandle() && 0 != ( FLAG_IS_VISIBLE & flags) || + if( 0 == getWindowHandle() && setVisible || 0 != ( FLAG_CHANGE_DECORATION & flags) || 0 != ( FLAG_CHANGE_PARENTING & flags) || 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { - final boolean setVisible = 0 != ( FLAG_IS_VISIBLE & flags); if(isOffscreenInstance) { - createWindow(true, 0 != getWindowHandle(), pClientLevelOnSreen, 64, 64, false, setVisible, false); + createWindow(true, 0 != getWindowHandle(), pClientLevelOnSreen, 64, 64, false, false, false); } else { createWindow(false, 0 != getWindowHandle(), pClientLevelOnSreen, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags), setVisible, 0 != ( FLAG_IS_ALWAYSONTOP & flags)); @@ -287,14 +294,14 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( !isOffscreenInstance ) { OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { - setWindowClientTopLeftPointAndSize0(getWindowHandle(), pClientLevelOnSreen.getX(), pClientLevelOnSreen.getY(), width, height); + setWindowClientTopLeftPointAndSize0(getWindowHandle(), pClientLevelOnSreen.getX(), pClientLevelOnSreen.getY(), width, height, setVisible); } } ); } // else offscreen size is realized via recreation // no native event (fullscreen, some reparenting) positionChanged(true, x, y); sizeChanged(true, width, height, false); } - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) { + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && setVisible ) { if( !isOffscreenInstance ) { OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { @@ -318,18 +325,18 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected Point getLocationOnScreenImpl(int x, int y) { final NativeWindow parent = getParent(); - final boolean useParent = null != parent && 0 != parent.getWindowHandle() ; + final boolean useParent = useParent(parent); + return getLocationOnScreenImpl(x, y, parent, useParent); + } + private Point getLocationOnScreenImpl(final int x, final int y, final NativeWindow parent, final boolean useParent) { if( !useParent && !isOffscreenInstance && 0 != surfaceHandle) { return OSXUtil.GetLocationOnScreen(surfaceHandle, true, x, y); } final Point p = new Point(x, y); - // min val is 0 - p.setX(Math.max(p.getX(), 0)); - p.setY(Math.max(p.getY(), 0)); if( useParent ) { - p.translate(parent.getLocationOnScreen(null)); + p.translate( parent.getLocationOnScreen(null) ); } return p; } @@ -434,10 +441,6 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final PointImmutable pS, final int width, final int height, final boolean fullscreen, final boolean visible, final boolean alwaysOnTop) { - if( 0 != getWindowHandle() && !recreate ) { - return; - } - if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.createWindow on thread "+Thread.currentThread().getName()+ ": offscreen "+offscreenInstance+", recreate "+recreate+ @@ -485,7 +488,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl public void run() { initWindow0( parentWin, newWin, pS.getX(), pS.getY(), width, height, - isOpaque, fullscreen, visible, offscreenInstance, getScreen().getIndex(), surfaceHandle); + isOpaque, fullscreen, visible, getScreen().getIndex(), surfaceHandle); if( offscreenInstance ) { orderOut0(0!=parentWin ? parentWin : newWin); } else { @@ -504,15 +507,14 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private native long createWindow0(int x, int y, int w, int h, boolean fullscreen, int windowStyle, int backingStoreType, int screen_idx, long view); /** Must be called on Main-Thread */ private native void initWindow0(long parentWindow, long window, int x, int y, int w, int h, - boolean opaque, boolean fullscreen, boolean visible, boolean offscreen, - int screen_idx, long view); + boolean opaque, boolean fullscreen, boolean visible, int screen_idx, long view); private native boolean lockSurface0(long window, long view); private native boolean unlockSurface0(long window, long view); /** Must be called on Main-Thread */ private native void requestFocus0(long window, boolean force); /** Must be called on Main-Thread */ private native void resignFocus0(long window); - /** Must be called on Main-Thread. In case of a child window, it actually only issues orderBack(..) */ + /** Must be called on Main-Thread. In case this is a child window and parent is still visible, orderBack(..) is issued instead of orderOut(). */ private native void orderOut0(long window); /** Must be called on Main-Thread */ private native void orderFront0(long window); @@ -524,9 +526,9 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl /** Must be called on Main-Thread */ private native void changeContentView0(long parentWindowOrView, long window, long view); /** Must be called on Main-Thread */ - private native void setWindowClientTopLeftPointAndSize0(long window, int x, int y, int w, int h); + private native void setWindowClientTopLeftPointAndSize0(long window, int x, int y, int w, int h, boolean display); /** Must be called on Main-Thread */ - private native void setWindowClientTopLeftPoint0(long window, int x, int y); + private native void setWindowClientTopLeftPoint0(long window, int x, int y, boolean display); /** Must be called on Main-Thread */ private native void setAlwaysOnTop0(long window, boolean atop); private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y); diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index e3f4eae34..c0552216e 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -100,7 +100,36 @@ static int getRetainCount(NSObject * obj) { } #endif -static void changeContentView(JNIEnv *env, jobject javaWindowObject, NSView *pview, NewtMacWindow *win, NewtView *newView) { +static void setJavaWindowObject(JNIEnv *env, jobject newJavaWindowObject, NewtView *view, BOOL enable) { + DBG_PRINT( "setJavaWindowObject.0: View %p\n", view); + if( !enable) { + jobject globJavaWindowObject = [view getJavaWindowObject]; + if( NULL != globJavaWindowObject ) { + DBG_PRINT( "setJavaWindowObject.1: View %p - Clear old javaWindowObject %p\n", view, globJavaWindowObject); + (*env)->DeleteGlobalRef(env, globJavaWindowObject); + [view setJavaWindowObject: NULL]; + } + } else if( NULL != newJavaWindowObject ) { + DBG_PRINT( "setJavaWindowObject.2: View %p - Set new javaWindowObject %p\n", view, newJavaWindowObject); + jobject globJavaWindowObject = (*env)->NewGlobalRef(env, newJavaWindowObject); + [view setJavaWindowObject: globJavaWindowObject]; + { + JavaVM *jvmHandle = NULL; + int jvmVersion = 0; + + if(0 != (*env)->GetJavaVM(env, &jvmHandle)) { + jvmHandle = NULL; + } else { + jvmVersion = (*env)->GetVersion(env); + } + [view setJVMHandle: jvmHandle]; + [view setJVMVersion: jvmVersion]; + } + } + DBG_PRINT( "setJavaWindowObject.X: View %p\n", view); +} + +static void changeContentView(JNIEnv *env, jobject javaWindowObject, NSView *pview, NewtMacWindow *win, NewtView *newView, BOOL setJavaWindow) { NSView* oldNSView = [win contentView]; NewtView* oldNewtView = NULL; #ifdef VERBOSE_ON @@ -132,10 +161,8 @@ NS_ENDHANDLER dbgIdx++, win, oldNSView, getRetainCount(oldNSView), NULL!=oldNewtView, newView, getRetainCount(newView)); if( NULL != oldNewtView ) { - jobject globJavaWindowObject = [oldNewtView getJavaWindowObject]; - (*env)->DeleteGlobalRef(env, globJavaWindowObject); - [oldNewtView setJavaWindowObject: NULL]; [oldNewtView setDestroyNotifySent: false]; + setJavaWindowObject(env, NULL, oldNewtView, NO); } [oldNSView removeFromSuperviewWithoutNeedingDisplay]; } @@ -143,20 +170,9 @@ NS_ENDHANDLER dbgIdx++, win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView), [newView isHidden], [newView isHiddenOrHasHiddenAncestor]); if( NULL!=newView ) { - jobject globJavaWindowObject = (*env)->NewGlobalRef(env, javaWindowObject); - [newView setJavaWindowObject: globJavaWindowObject]; [newView setDestroyNotifySent: false]; - { - JavaVM *jvmHandle = NULL; - int jvmVersion = 0; - - if(0 != (*env)->GetJavaVM(env, &jvmHandle)) { - jvmHandle = NULL; - } else { - jvmVersion = (*env)->GetVersion(env); - } - [newView setJVMHandle: jvmHandle]; - [newView setJVMVersion: jvmVersion]; + if( setJavaWindow ) { + setJavaWindowObject(env, javaWindowObject, newView, YES); } DBG_PRINT( "changeContentView.%d win %p, view (%p,%d -> %p,%d)\n", @@ -671,19 +687,19 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: initWindow0 - * Signature: (JJIIIIZZZZIIJ)V + * Signature: (JJIIIIZZZIJ)V */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initWindow0 (JNIEnv *env, jobject jthis, jlong parent, jlong window, jint x, jint y, jint w, jint h, - jboolean opaque, jboolean fullscreen, jboolean visible, jboolean offscreen, jint screen_idx, jlong jview) + jboolean opaque, jboolean fullscreen, jboolean visible, jint screen_idx, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* myWindow = (NewtMacWindow*) ((intptr_t) window); NewtView* myView = (NewtView*) (intptr_t) jview ; - DBG_PRINT( "initWindow0 - %p (this), %p (parent), %p (window), %d/%d %dx%d, opaque %d, fs %d, visible %d, offscreen %d, screenidx %d, view %p (START)\n", + DBG_PRINT( "initWindow0 - %p (this), %p (parent), %p (window), %d/%d %dx%d, opaque %d, fs %d, visible %d, screenidx %d, view %p (START)\n", (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, (int)x, (int)y, (int)w, (int)h, - (int) opaque, (int)fullscreen, (int)visible, (int)offscreen, (int)screen_idx, myView); + (int) opaque, (int)fullscreen, (int)visible, (int)screen_idx, myView); NSArray *screens = [NSScreen screens]; if(screen_idx<0) screen_idx=0; @@ -753,7 +769,7 @@ NS_ENDHANDLER dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); // Set the content view - changeContentView(env, jthis, parentView, myWindow, myView); + changeContentView(env, jthis, parentView, myWindow, myView, NO); DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); @@ -762,8 +778,8 @@ NS_ENDHANDLER [myWindow attachToParent: parentWindow]; } - DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", - dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d, visible %d\n", + dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible], visible); // Immediately re-position this window based on an upper-left coordinate system setWindowClientTopLeftPointAndSize(myWindow, x, y, w, h, NO); @@ -791,7 +807,7 @@ NS_ENDHANDLER dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); // visible on front - if( JNI_TRUE == visible && JNI_FALSE == offscreen ) { + if( visible ) { [myWindow orderFront: myWindow]; } @@ -816,6 +832,12 @@ NS_ENDHANDLER // right mouse button down events [myView setNextResponder: myWindow]; + DBG_PRINT( "initWindow0.X - %p (this), %p (parent): new window: %p, view %p,%d\n", + (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView, getRetainCount(myView)); + + [myView setDestroyNotifySent: false]; + setJavaWindowObject(env, jthis, myView, YES); + DBG_PRINT( "initWindow0.X - %p (this), %p (parent): new window: %p, view %p,%d\n", (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView, getRetainCount(myView)); @@ -845,13 +867,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 if(NULL!=mView) { // cleanup view - jobject javaWindowObject = [mView getJavaWindowObject]; [mView setDestroyNotifySent: true]; - if(NULL!=javaWindowObject) { - DBG_PRINT( "windowClose.0: Clear global javaWindowObject reference (%p)\n", javaWindowObject); - (*env)->DeleteGlobalRef(env, javaWindowObject); - [mView setJavaWindowObject: NULL]; - } + setJavaWindowObject(env, NULL, mView, NO); } NS_DURING @@ -1007,10 +1024,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_orderOut0 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* mWin = (NSWindow*) ((intptr_t) window); NSWindow* pWin = [mWin parentWindow]; + BOOL pWinVisible = NULL != pWin ? [pWin isVisible] : 0; - DBG_PRINT( "orderOut0 - window: (parent %p) %p (START)\n", pWin, mWin); + DBG_PRINT( "orderOut0 - window: (parent %p visible %d) %p visible %d (START)\n", pWin, pWinVisible, mWin, [mWin isVisible]); - if(NULL == pWin) { + if( NULL == pWin || !pWinVisible ) { [mWin orderOut: mWin]; } else { [mWin orderBack: mWin]; @@ -1097,7 +1115,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_changeContent } } - changeContentView(env, jthis, pView, win, newView); + changeContentView(env, jthis, pView, win, newView, YES); DBG_PRINT( "changeContentView0.X\n"); @@ -1107,17 +1125,17 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_changeContent /* * Class: jogamp_newt_driver_macosx_WindowDriver * Method: setWindowClientTopLeftPointAndSize0 - * Signature: (JIIII)V + * Signature: (JIIIIZ)V */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setWindowClientTopLeftPointAndSize0 - (JNIEnv *env, jobject unused, jlong window, jint x, jint y, jint w, jint h) + (JNIEnv *env, jobject unused, jlong window, jint x, jint y, jint w, jint h, jboolean display) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window); DBG_PRINT( "setWindowClientTopLeftPointAndSize - window: %p (START)\n", mWin); - setWindowClientTopLeftPointAndSize(mWin, x, y, w, h, YES); + setWindowClientTopLeftPointAndSize(mWin, x, y, w, h, display); DBG_PRINT( "setWindowClientTopLeftPointAndSize - window: %p (END)\n", mWin); @@ -1127,17 +1145,17 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setWindowClie /* * Class: jogamp_newt_driver_macosx_WindowDriver * Method: setWindowClientTopLeftPoint0 - * Signature: (JII)V + * Signature: (JIIZ)V */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setWindowClientTopLeftPoint0 - (JNIEnv *env, jobject unused, jlong window, jint x, jint y) + (JNIEnv *env, jobject unused, jlong window, jint x, jint y, jboolean display) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window); DBG_PRINT( "setWindowClientTopLeftPoint - window: %p (START)\n", mWin); - setWindowClientTopLeftPoint(mWin, x, y, YES); + setWindowClientTopLeftPoint(mWin, x, y, display); DBG_PRINT( "setWindowClientTopLeftPoint - window: %p (END)\n", mWin); -- cgit v1.2.3 From 9dcd8bba63cfbcd6e72c855065cf4dafdbcf037e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 20 Mar 2013 17:23:17 +0100 Subject: OSX/NEWT: Fix visible -> false when closing and reparenting window. This lead to non functional recreational reparenting. OSX recreational reparenting moves the saved GLEventListenerState at destroy to the new dawable/surface, which must be valid. The flaky visible state caused seemingly random reparenting failures. - WindowImpl.ReparentActionRecreate.run() set 'visible:=true', which circumvented OSX to wait for actual realization. - OSX WindowDriver.closeNative(): Issue visibleChanged(true, false); ASAP --- make/scripts/tests.sh | 2 -- src/newt/classes/jogamp/newt/WindowImpl.java | 1 - src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java | 7 ++++--- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7dfca6e6f..60990e3b4 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -352,7 +352,6 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch12AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT @@ -560,7 +559,6 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA # # Freeze -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* # Cut-off top #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index c01f880fc..45100421a 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1275,7 +1275,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final RecursiveLock _lock = windowLock; _lock.lock(); try { - visible = true; if(DEBUG_IMPLEMENTATION) { System.err.println("Window.reparentWindow: ReparentActionRecreate ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+Display.hashCodeNullSafe(parentWindow)); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 653e90e3b..965138ddf 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -80,10 +80,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl try { if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.CloseAction "+Thread.currentThread().getName()); } final long handle = getWindowHandle(); + visibleChanged(true, false); setWindowHandle(0); surfaceHandle = 0; sscSurfaceHandle = 0; - isOffscreenInstance = false; + isOffscreenInstance = false; if (0 != handle) { OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { @@ -284,7 +285,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl 0 != ( FLAG_CHANGE_PARENTING & flags) || 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { if(isOffscreenInstance) { - createWindow(true, 0 != getWindowHandle(), pClientLevelOnSreen, 64, 64, false, false, false); + createWindow(true, 0 != getWindowHandle(), pClientLevelOnSreen, 64, 64, false, setVisible, false); } else { createWindow(false, 0 != getWindowHandle(), pClientLevelOnSreen, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags), setVisible, 0 != ( FLAG_IS_ALWAYSONTOP & flags)); @@ -488,7 +489,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl public void run() { initWindow0( parentWin, newWin, pS.getX(), pS.getY(), width, height, - isOpaque, fullscreen, visible, getScreen().getIndex(), surfaceHandle); + isOpaque, fullscreen, visible && !offscreenInstance, getScreen().getIndex(), surfaceHandle); if( offscreenInstance ) { orderOut0(0!=parentWin ? parentWin : newWin); } else { -- cgit v1.2.3 From 98f6f99ddc6643cfa540d6c85c64c7f8510cc1ea Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 21 Mar 2013 17:38:26 +0100 Subject: NEWTEvent: Add isConsumed() and setConsumed(boolean) methods to simply usage, using the existing consumedTag attachment for compatibility and efficiency. --- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 5 ++- .../classes/com/jogamp/newt/event/NEWTEvent.java | 41 +++++++++++++++++++--- src/newt/classes/jogamp/newt/WindowImpl.java | 10 ++---- 3 files changed, 42 insertions(+), 14 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index a3c2a5dc8..d22e50cb8 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -60,7 +60,6 @@ import com.jogamp.newt.Display; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; -import com.jogamp.newt.event.NEWTEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; @@ -214,7 +213,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } public void keyTyped(KeyEvent e) { if(suppress) { - e.setAttachment(NEWTEvent.consumedTag); + e.setConsumed(true); suppress = false; // reset } } @@ -244,7 +243,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } if(suppress) { - evt.setAttachment(NEWTEvent.consumedTag); + evt.setConsumed(true); } if(DEBUG) { System.err.println("NewtCanvasAWT.focusKey: XXX: "+ks); diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index 17210cef8..67bc73652 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -49,8 +49,7 @@ package com.jogamp.newt.event; @SuppressWarnings("serial") public class NEWTEvent extends java.util.EventObject { /** - * Object when attached via {@link #setAttachment(Object)} marks the event consumed, - * ie. stops propagating the event any further to the other event listener. + * See {@link #setConsumed(boolean)} for description. */ public static final Object consumedTag = new Object(); @@ -86,7 +85,7 @@ public class NEWTEvent extends java.util.EventObject { * @param attachment User application specific object */ public final void setAttachment(Object attachment) { - this.attachment=attachment; + this.attachment = attachment; } /** @@ -95,7 +94,41 @@ public class NEWTEvent extends java.util.EventObject { public final Object getAttachment() { return attachment; } - + + /** + * Returns true if this events has been {@link #setConsumed(boolean) consumed}, + * otherwise false. + * @see #setConsumed(boolean) + */ + public final boolean isConsumed() { + return consumedTag == attachment; + } + + /** + * If consumed is true, this event is marked as consumed, + * ie. the event will not be propagated any further to potential other event listener. + * Otherwise the event will be propagated to other event listener, the default. + *

    + * The event is marked as being consumed while {@link #setAttachment(Object) attaching} + * the {@link #consumedTag}. + *

    + *

    + * Events with platform specific actions will be supressed if marked as consumed. + * Examples are: + *

      + *
    • {@link KeyEvent#VK_ESCAPE} on Android's BACK button w/ Activity::finish()
    • + *
    • {@link KeyEvent#VK_HOME} on Android's HOME button w/ Intend.ACTION_MAIN[Intend.CATEGORY_HOME]
    • + *
    + *

    + */ + public final void setConsumed(boolean consumed) { + if( consumed ) { + setAttachment( consumedTag ); + } else if( consumedTag == attachment ) { + setAttachment( null ); + } + } + public String toString() { return toString(null).toString(); } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 45100421a..e8dc0d7d7 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2194,8 +2194,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_MOUSE_EVENT) { System.err.println("consumeMouseEvent: event: "+e); } - boolean consumed = false; - for(int i = 0; !consumed && i < mouseListeners.size(); i++ ) { + for(int i = 0; !e.isConsumed() && i < mouseListeners.size(); i++ ) { MouseListener l = mouseListeners.get(i); switch(e.getEventType()) { case MouseEvent.EVENT_MOUSE_CLICKED: @@ -2225,7 +2224,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer default: throw new NativeWindowException("Unexpected mouse event type " + e.getEventType()); } - consumed = NEWTEvent.consumedTag == e.getAttachment(); } } @@ -2354,7 +2352,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer default: throw new NativeWindowException("Unexpected key event type " + e.getEventType()); } - return NEWTEvent.consumedTag == e.getAttachment(); + return e.isConsumed(); } @SuppressWarnings("deprecation") @@ -2460,8 +2458,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("consumeWindowEvent: "+e+", visible "+isVisible()+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } - boolean consumed = false; - for(int i = 0; !consumed && i < windowListeners.size(); i++ ) { + for(int i = 0; !e.isConsumed() && i < windowListeners.size(); i++ ) { WindowListener l = windowListeners.get(i); switch(e.getEventType()) { case WindowEvent.EVENT_WINDOW_RESIZED: @@ -2490,7 +2487,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer new NativeWindowException("Unexpected window event type " + e.getEventType()); } - consumed = NEWTEvent.consumedTag == e.getAttachment(); } } -- cgit v1.2.3 From 58ebd43a78491281e2c3b012666220ed47634c7e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 21 Mar 2013 20:40:41 +0100 Subject: NEWT/Android: Fix BACK button implementation, use different KeyCode mappings and allowing native action to be suppressed. - Don't trust soft-kbd visibility state, but perform invisible action. If the latter was successful - soft-kbd was visible before. - Map BACK to VK_KEYBOARD_INVISIBLE and propagate it, if soft-kbd was visible before. No native default action is performed. - Map BACK to VK_ESCAPE event and propagate it, if soft-kbd was invisible _and_ an activity was registered via registerActivity(Activity), i.e. by NewtBaseActivity. Otherwise proceed w/ default action (-> activity.finish()). - If the KeyListener consumed the [EVENT_KEY_RELEASED, VK_ESCAPE] event, it will be suppressed and no default action performed. This allows applications to have a custom 'ESCAPE' or 'BACK' handling. Otherwise (not consumed) the default action is performed. --- .../classes/com/jogamp/newt/event/NEWTEvent.java | 2 +- src/newt/classes/jogamp/newt/WindowImpl.java | 62 +++++++++++++--- .../newt/driver/android/NewtBaseActivity.java | 3 + .../jogamp/newt/driver/android/WindowDriver.java | 86 +++++++++++++++++++--- .../android/event/AndroidNewtEventFactory.java | 17 ++++- 5 files changed, 146 insertions(+), 24 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index 67bc73652..12a2e3dc2 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -137,7 +137,7 @@ public class NEWTEvent extends java.util.EventObject { if(null == sb) { sb = new StringBuilder(); } - return sb.append("NEWTEvent[source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); + return sb.append("NEWTEvent[source:").append(getSource().getClass().getName()).append("consumed ").append(isConsumed()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); } public static String toHexString(short hex) { diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index e8dc0d7d7..e1636ffcd 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1625,6 +1625,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer windowHandle = handle; } + @Override public void runOnEDTIfAvail(boolean wait, final Runnable task) { if( windowLock.isOwner( Thread.currentThread() ) ) { task.run(); @@ -1650,14 +1651,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } }; + @Override public final boolean hasFocus() { return hasFocus; } + @Override public void requestFocus() { requestFocus(true); } + @Override public void requestFocus(boolean wait) { requestFocus(wait /* wait */, false /* skipFocusAction */, brokenFocusChange /* force */); } @@ -1680,6 +1684,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + @Override public void setFocusAction(FocusRunnable focusAction) { this.focusAction = focusAction; } @@ -1704,6 +1709,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer brokenFocusChange = v; } + @Override public void setKeyboardFocusHandler(KeyListener l) { keyboardFocusHandler = l; } @@ -1737,11 +1743,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + @Override public void setPosition(int x, int y) { autoPosition = false; runOnEDTIfAvail(true, new SetPositionAction(x, y)); } + @Override public void setTopLevelPosition(int x, int y) { setPosition(x + getInsets().getLeftWidth(), y + getInsets().getTopHeight()); } @@ -1848,6 +1856,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private final FullScreenAction fullScreenAction = new FullScreenAction(); + @Override public boolean setFullscreen(boolean fullscreen) { synchronized(fullScreenAction) { if( fullScreenAction.init(fullscreen) ) { @@ -1921,12 +1930,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Child Window Management // + @Override public final boolean removeChild(NativeWindow win) { synchronized(childWindowsLock) { return childWindows.remove(win); } } + @Override public final boolean addChild(NativeWindow win) { if (win == null) { return false; @@ -1952,12 +1963,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + @Override public void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event) { if(isNativeValid()) { ((DisplayImpl)screen.getDisplay()).enqueueEvent(wait, event); } } + @Override public boolean consumeEvent(NEWTEvent e) { switch(e.getEventType()) { // special repaint treatment @@ -2009,18 +2022,22 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // SurfaceUpdatedListener Support // + @Override public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { surfaceUpdatedHelper.addSurfaceUpdatedListener(l); } + @Override public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); } + @Override public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); } + @Override public void surfaceUpdated(Object updater, NativeSurface ns, long when) { surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); } @@ -2149,11 +2166,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - + @Override public void addMouseListener(MouseListener l) { addMouseListener(-1, l); } + @Override public void addMouseListener(int index, MouseListener l) { if(l == null) { return; @@ -2167,6 +2185,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer mouseListeners = clonedListeners; } + @Override public void removeMouseListener(MouseListener l) { if (l == null) { return; @@ -2177,6 +2196,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer mouseListeners = clonedListeners; } + @Override public MouseListener getMouseListener(int index) { @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); @@ -2186,6 +2206,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return clonedListeners.get(index); } + @Override public MouseListener[] getMouseListeners() { return mouseListeners.toArray(new MouseListener[mouseListeners.size()]); } @@ -2267,26 +2288,31 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer enqueueEvent(wait, new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); } - public void addKeyListener(KeyListener l) { - addKeyListener(-1, l); - } - + @Override public final void setKeyboardVisible(boolean visible) { if(isNativeValid()) { // We don't skip the impl. if it seems that there is no state change, // since we cannot assume the impl. reliably gives us it's current state. - final boolean n = setKeyboardVisibleImpl(visible); + final boolean ok = setKeyboardVisibleImpl(visible); if(DEBUG_IMPLEMENTATION || DEBUG_KEY_EVENT) { - System.err.println("setKeyboardVisible(native): visible "+keyboardVisible+" -> "+visible +" -> "+n); + System.err.println("setKeyboardVisible(native): visible "+keyboardVisible+" -- op[visible:"+visible +", ok "+ok+"] -> "+(visible && ok)); } - keyboardVisible = n; + keyboardVisibilityChanged( visible && ok ); } else { - keyboardVisible = visible; // earmark for creation + keyboardVisibilityChanged( visible ); // earmark for creation } } + @Override public final boolean isKeyboardVisible() { return keyboardVisible; - } + } + /** + * Returns true if operation was successful, otherwise false. + *

    + * We assume that a failed invisible operation is due to an already invisible keyboard, + * hence even if an invisible operation failed, the keyboard is considered invisible! + *

    + */ protected boolean setKeyboardVisibleImpl(boolean visible) { return false; // nop } @@ -2301,6 +2327,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } protected boolean keyboardVisible = false; + @Override + public void addKeyListener(KeyListener l) { + addKeyListener(-1, l); + } + + @Override public void addKeyListener(int index, KeyListener l) { if(l == null) { return; @@ -2314,6 +2346,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer keyListeners = clonedListeners; } + @Override public void removeKeyListener(KeyListener l) { if (l == null) { return; @@ -2324,6 +2357,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer keyListeners = clonedListeners; } + @Override public KeyListener getKeyListener(int index) { @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) keyListeners.clone(); @@ -2333,6 +2367,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return clonedListeners.get(index); } + @Override public KeyListener[] getKeyListeners() { return keyListeners.toArray(new KeyListener[keyListeners.size()]); } @@ -2404,6 +2439,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // WindowListener/Event Support // + @Override public void sendWindowEvent(int eventType) { consumeWindowEvent( new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); // FIXME } @@ -2412,10 +2448,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer enqueueEvent( wait, new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); // FIXME } + @Override public void addWindowListener(WindowListener l) { addWindowListener(-1, l); } + @Override public void addWindowListener(int index, WindowListener l) throws IndexOutOfBoundsException { @@ -2431,6 +2469,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer windowListeners = clonedListeners; } + @Override public final void removeWindowListener(WindowListener l) { if (l == null) { return; @@ -2441,6 +2480,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer windowListeners = clonedListeners; } + @Override public WindowListener getWindowListener(int index) { @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) windowListeners.clone(); @@ -2450,6 +2490,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return clonedListeners.get(index); } + @Override public WindowListener[] getWindowListeners() { return windowListeners.toArray(new WindowListener[windowListeners.size()]); } @@ -2676,6 +2717,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return destroyed; } + @Override public void windowRepaint(int x, int y, int width, int height) { windowRepaint(false, x, y, width, height); } diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index 6bc81a555..726793768 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -126,6 +126,9 @@ public class NewtBaseActivity extends Activity { * @see #addContentView(android.view.Window, Window, android.view.ViewGroup.LayoutParams) */ public void registerNEWTWindow(Window newtWindow) { + newtWindow = newtWindow.getDelegatedWindow(); + WindowDriver newtAWindow = (WindowDriver)newtWindow; + newtAWindow.registerActivity(getActivity()); newtWindows.add(newtWindow); } diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index c5371ae9c..0a253ff9e 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -47,12 +47,15 @@ import com.jogamp.common.os.AndroidVersion; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import com.jogamp.newt.Screen; import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.event.NEWTEvent; import jogamp.opengl.egl.EGL; import jogamp.opengl.egl.EGLGraphicsConfiguration; import jogamp.opengl.egl.EGLGraphicsConfigurationFactory; +import android.app.Activity; import android.content.Context; +import android.content.Intent; import android.graphics.PixelFormat; import android.os.Bundle; import android.os.IBinder; @@ -205,6 +208,11 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { public WindowDriver() { reset(); } + + public void registerActivity(Activity activity) { + this.activity = activity; + } + protected Activity activity = null; private final void reset() { added2StaticViewGroup = false; @@ -499,14 +507,15 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { if(null != androidView) { final InputMethodManager imm = (InputMethodManager) getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); final IBinder winid = getAndroidView().getWindowToken(); + final boolean result; if(visible) { // Show soft-keyboard: - imm.showSoftInput(androidView, 0, keyboardVisibleReceiver); + result = imm.showSoftInput(androidView, 0, keyboardVisibleReceiver); } else { // hide keyboard : - imm.hideSoftInputFromWindow(winid, 0, keyboardVisibleReceiver); + result = imm.hideSoftInputFromWindow(winid, 0, keyboardVisibleReceiver); } - return visible; + return result; } else { return false; // nop } @@ -588,25 +597,74 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { protected boolean handleKeyCodeBack(KeyEvent.DispatcherState state, android.view.KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { + Log.d(MD.TAG, "handleKeyCodeBack.0 : "+event); state.startTracking(event, this); } else if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled() && state.isTracking(event)) { - if( isKeyboardVisible() ) { - keyboardVisibilityChanged(false); - enqueueAKey2NKeyUpDown(event); + // Since we cannot trust the visibility state 'completly', + // assume an already invisible state if the invisible operation fails. + final boolean wasVisible = setKeyboardVisibleImpl(false); + Log.d(MD.TAG, "handleKeyCodeBack.1 : wasVisible "+wasVisible+": "+event); + keyboardVisibilityChanged(false); + if( wasVisible ) { + // event processed, just send invisible event, no activity.finished() + enqueueAKey2NKeyUpDown(event, com.jogamp.newt.event.KeyEvent.VK_KEYBOARD_INVISIBLE); + return true; + } else if( null != activity ) { + // process event on our own, since we have an activity to call finish() + // and decide in overriden consumeKeyEvent(..) whether we suppress or proceed w/ activity.finish(). + enqueueAKey2NKeyUpDown(event, com.jogamp.newt.event.KeyEvent.VK_ESCAPE); + return true; } else { - Log.d(MD.TAG, "handleKeyCodeBack : "+event); + Log.d(MD.TAG, "handleKeyCodeBack.X1 : "+event); windowDestroyNotify(true); + // -> default BACK action, usually activity.finish() } } - return false; // cont. processing + return false; // continue w/ further processing + } + protected boolean handleKeyCodeHome(KeyEvent.DispatcherState state, android.view.KeyEvent event) { + if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { + Log.d(MD.TAG, "handleKeyCodeHome.0 : "+event); + state.startTracking(event, this); + } else if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled() && state.isTracking(event)) { + Log.d(MD.TAG, "handleKeyCodeHome.1 : "+event); + enqueueAKey2NKeyUpDown(event, com.jogamp.newt.event.KeyEvent.VK_HOME); + return true; // we handle further processing + } + return false; // continue w/ further processing } - private void enqueueAKey2NKeyUpDown(android.view.KeyEvent aEvent) { - final com.jogamp.newt.event.KeyEvent eDown = AndroidNewtEventFactory.createKeyEvent(aEvent, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, this, true); - final com.jogamp.newt.event.KeyEvent eUp = AndroidNewtEventFactory.createKeyEvent(aEvent, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, this, true); + private void enqueueAKey2NKeyUpDown(android.view.KeyEvent aEvent, short newtKeyCode) { + final com.jogamp.newt.event.KeyEvent eDown = AndroidNewtEventFactory.createKeyEvent(aEvent, newtKeyCode, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, this); + final com.jogamp.newt.event.KeyEvent eUp = AndroidNewtEventFactory.createKeyEvent(aEvent, newtKeyCode, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, this); enqueueEvent(false, eDown); enqueueEvent(false, eUp); } + // private GLEventListenerState glels = null; + + @Override + protected void consumeKeyEvent(com.jogamp.newt.event.KeyEvent e) { + super.consumeKeyEvent(e); // consume event, i.e. call all KeyListener + if( com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED == e.getEventType() && !e.isConsumed() ) { + if( com.jogamp.newt.event.KeyEvent.VK_ESCAPE == e.getKeyCode() ) { + Log.d(MD.TAG, "handleKeyCodeBack.X2 : "+e); + activity.finish(); + } else if( com.jogamp.newt.event.KeyEvent.VK_HOME == e.getKeyCode() ) { + Log.d(MD.TAG, "handleKeyCodeHome.X2 : "+e); + triggerHome(); + } + } + } + private void triggerHome() { + Context ctx = StaticContext.getContext(); + if(null == ctx) { + throw new NativeWindowException("No static [Application] Context has been set. Call StaticContext.setContext(Context) first."); + } + Intent showOptions = new Intent(Intent.ACTION_MAIN); + showOptions.addCategory(Intent.CATEGORY_HOME); + ctx.startActivity(showOptions); + } + private boolean added2StaticViewGroup; private MSurfaceView androidView; private int nativeFormat; // chosen current native PixelFormat (suitable for EGL) @@ -625,11 +683,17 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { @Override public boolean onKeyPreIme(int keyCode, KeyEvent event) { + Log.d(MD.TAG, "onKeyPreIme : "+event); if ( event.getKeyCode() == KeyEvent.KEYCODE_BACK ) { final KeyEvent.DispatcherState state = getKeyDispatcherState(); if (state != null) { return handleKeyCodeBack(state, event); } + } else if ( event.getKeyCode() == KeyEvent.KEYCODE_HOME ) { + final KeyEvent.DispatcherState state = getKeyDispatcherState(); + if (state != null) { + return handleKeyCodeHome(state, event); + } } return false; // cont. processing } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 1f78bd578..5d2333c1f 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -110,7 +110,7 @@ public class AndroidNewtEventFactory { case android.view.KeyEvent.KEYCODE_TAB: return com.jogamp.newt.event.KeyEvent.VK_TAB; case android.view.KeyEvent.KEYCODE_SPACE: return com.jogamp.newt.event.KeyEvent.VK_SPACE; case android.view.KeyEvent.KEYCODE_ENTER: return com.jogamp.newt.event.KeyEvent.VK_ENTER; - case android.view.KeyEvent.KEYCODE_DEL: return com.jogamp.newt.event.KeyEvent.VK_DELETE; + case android.view.KeyEvent.KEYCODE_DEL: return com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE; case android.view.KeyEvent.KEYCODE_MINUS: return com.jogamp.newt.event.KeyEvent.VK_MINUS; case android.view.KeyEvent.KEYCODE_EQUALS: return com.jogamp.newt.event.KeyEvent.VK_EQUALS; case android.view.KeyEvent.KEYCODE_LEFT_BRACKET: return com.jogamp.newt.event.KeyEvent.VK_LEFT_PARENTHESIS; @@ -128,11 +128,16 @@ public class AndroidNewtEventFactory { case android.view.KeyEvent.KEYCODE_CTRL_RIGHT: return com.jogamp.newt.event.KeyEvent.VK_CONTROL; // ?? case android.view.KeyEvent.KEYCODE_BACK: if( inclSysKeys ) { - return com.jogamp.newt.event.KeyEvent.VK_KEYBOARD_INVISIBLE; + // Note that manual mapping is performed, based on the keyboard state. + // I.e. we map to VK_KEYBOARD_INVISIBLE if keyboard was visible and now becomes invisible! + // Otherwise we map to VK_ESCAPE, and if not consumed by user, the application will be terminated. + return com.jogamp.newt.event.KeyEvent.VK_ESCAPE; } break; case android.view.KeyEvent.KEYCODE_HOME: if( inclSysKeys ) { + // If not consumed by user, the application will be 'paused', + // i.e. resources (GLEventListener) pulled before surface gets destroyed! return com.jogamp.newt.event.KeyEvent.VK_HOME; } break; @@ -184,6 +189,14 @@ public class AndroidNewtEventFactory { return res; } + public static com.jogamp.newt.event.KeyEvent createKeyEvent(android.view.KeyEvent aEvent, short newtKeyCode, short newtType, com.jogamp.newt.Window newtSource) { + final com.jogamp.newt.event.KeyEvent res = createKeyEventImpl(aEvent, newtType, newtKeyCode, newtSource); + if(Window.DEBUG_KEY_EVENT) { + System.err.println("createKeyEvent2: newtType "+NEWTEvent.toHexString(newtType)+", "+aEvent+" -> "+res); + } + return res; + } + private static com.jogamp.newt.event.KeyEvent createKeyEventImpl(android.view.KeyEvent aEvent, short newtType, short newtKeyCode, com.jogamp.newt.Window newtSource) { if( (short)0 != newtType && (short)0 != newtKeyCode ) { final Object src = null==newtSource ? null : newtSource; -- cgit v1.2.3 From 8b34a0389e07967ce0c2ccc430a7c1d0803c3e51 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 22 Mar 2013 06:33:01 +0100 Subject: NEWT/Android: Remove KeyEvent.KEYCODE_HOME handling, since it doesn't work - i.e. cannot be intercepted this way. --- .../jogamp/newt/driver/android/WindowDriver.java | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index 0a253ff9e..8002c49b3 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -47,7 +47,6 @@ import com.jogamp.common.os.AndroidVersion; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import com.jogamp.newt.Screen; import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.NEWTEvent; import jogamp.opengl.egl.EGL; import jogamp.opengl.egl.EGLGraphicsConfiguration; @@ -622,17 +621,6 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } return false; // continue w/ further processing } - protected boolean handleKeyCodeHome(KeyEvent.DispatcherState state, android.view.KeyEvent event) { - if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { - Log.d(MD.TAG, "handleKeyCodeHome.0 : "+event); - state.startTracking(event, this); - } else if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled() && state.isTracking(event)) { - Log.d(MD.TAG, "handleKeyCodeHome.1 : "+event); - enqueueAKey2NKeyUpDown(event, com.jogamp.newt.event.KeyEvent.VK_HOME); - return true; // we handle further processing - } - return false; // continue w/ further processing - } private void enqueueAKey2NKeyUpDown(android.view.KeyEvent aEvent, short newtKeyCode) { final com.jogamp.newt.event.KeyEvent eDown = AndroidNewtEventFactory.createKeyEvent(aEvent, newtKeyCode, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, this); final com.jogamp.newt.event.KeyEvent eUp = AndroidNewtEventFactory.createKeyEvent(aEvent, newtKeyCode, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, this); @@ -640,8 +628,6 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { enqueueEvent(false, eUp); } - // private GLEventListenerState glels = null; - @Override protected void consumeKeyEvent(com.jogamp.newt.event.KeyEvent e) { super.consumeKeyEvent(e); // consume event, i.e. call all KeyListener @@ -689,11 +675,6 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { if (state != null) { return handleKeyCodeBack(state, event); } - } else if ( event.getKeyCode() == KeyEvent.KEYCODE_HOME ) { - final KeyEvent.DispatcherState state = getKeyDispatcherState(); - if (state != null) { - return handleKeyCodeHome(state, event); - } } return false; // cont. processing } -- cgit v1.2.3 From 3ad03e41a0cda81119c23f350c00b064a4de70c2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 22 Mar 2013 10:29:54 +0100 Subject: Add GLStateKeeper handling GLEventListenerState preservation and restauration for GLAutoDrawable - New GLStateKeeper interface, package com.jogamp.opengl Implemented by: - GLAutoDrawableBase Currently supported by: - NEWT GLWindow - GLEventListenerState package move: com.jogamp.opengl.util -> com.jogamp.opengl --- .../com/jogamp/opengl/GLEventListenerState.java | 375 +++++++++++++++++++++ .../classes/com/jogamp/opengl/GLStateKeeper.java | 87 +++++ .../com/jogamp/opengl/util/GLDrawableUtil.java | 2 + .../jogamp/opengl/util/GLEventListenerState.java | 365 -------------------- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 48 ++- .../classes/com/jogamp/newt/opengl/GLWindow.java | 7 +- src/newt/classes/jogamp/newt/WindowImpl.java | 4 +- .../acore/glels/GLContextDrawableSwitchBase.java | 2 +- .../glels/TestGLContextDrawableSwitch10NEWT.java | 2 +- .../TestGLContextDrawableSwitch11NewtAWT.java | 2 +- .../glels/TestGLContextDrawableSwitch12AWT.java | 2 +- .../TestGLContextDrawableSwitch21Newt2AWT.java | 2 +- 12 files changed, 513 insertions(+), 385 deletions(-) create mode 100644 src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java create mode 100644 src/jogl/classes/com/jogamp/opengl/GLStateKeeper.java delete mode 100644 src/jogl/classes/com/jogamp/opengl/util/GLEventListenerState.java (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java new file mode 100644 index 000000000..5c0954584 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java @@ -0,0 +1,375 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl; + +import java.util.ArrayList; +import java.util.List; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; +import javax.media.opengl.GLRunnable; + +import jogamp.opengl.Debug; + +import com.jogamp.nativewindow.MutableGraphicsConfiguration; + +/** + * GLEventListenerState is holding {@link GLAutoDrawable} components crucial + * to relocating all its {@link GLEventListener} w/ their operating {@link GLContext}, etc. + * The components are: + *
      + *
    • {@link GLContext}
    • + *
    • All {@link GLEventListener}, incl. their init state
    • + *
    • {@link GLAnimatorControl}
    • + *
    • {@link GLCapabilitiesImmutable} for compatibility check
    • + *
    • {@link AbstractGraphicsScreen} for compatibility check and preserving the {@link AbstractGraphicsDevice}
    • + *
    + *

    + * A GLEventListenerState instance can be created while components are {@link #moveFrom(GLAutoDrawable) moved from} a {@link GLAutoDrawable} + * to the new instance, which gains {@link #isOwner() ownership} of the moved components. + *

    + *

    + * A GLEventListenerState instance's components can be {@link #moveTo(GLAutoDrawable) moved to} a {@link GLAutoDrawable}, + * while loosing {@link #isOwner() ownership} of the moved components. + *

    + *

    + */ +public class GLEventListenerState { + private static final boolean DEBUG = Debug.debug("GLDrawable"); + + private GLEventListenerState(AbstractGraphicsScreen upstreamScreen, boolean proxyOwnsUpstreamDevice, AbstractGraphicsScreen screen, GLCapabilitiesImmutable caps, + GLContext context, int count, GLAnimatorControl anim, boolean animStarted) { + this.upstreamScreen = upstreamScreen; + this.proxyOwnsUpstreamDevice = proxyOwnsUpstreamDevice; + this.screen = screen; + this.caps = caps; + this.context = context; + this.listeners = new GLEventListener[count]; + this.listenersInit = new boolean[count]; + this.anim = anim; + this.animStarted = animStarted; + + this.owner = true; + } + /** + * Returns true, if this instance is the current owner of the components, + * otherwise false. + *

    + * Ownership is lost if {@link #moveTo(GLAutoDrawable)} is being called successfully + * and all components are transferred to the new {@link GLAutoDrawable}. + *

    + */ + public final boolean isOwner() { return owner; } + + public final int listenerCount() { return listeners.length; } + + public final AbstractGraphicsScreen upstreamScreen; + public final boolean proxyOwnsUpstreamDevice; + public final AbstractGraphicsScreen screen; + public final GLCapabilitiesImmutable caps; + public final GLContext context; + public final GLEventListener[] listeners; + public final boolean[] listenersInit; + public final GLAnimatorControl anim; + public final boolean animStarted; + + private boolean owner; + + /** + * Last resort to destroy and loose ownership + */ + public void destroy() { + if( owner ) { + final int aSz = listenerCount(); + for(int i=0; i + * Note that all components are removed from the {@link GLAutoDrawable}, + * i.e. the {@link GLContext}, all {@link GLEventListener}. + *

    + *

    + * If the {@link GLAutoDrawable} was added to a {@link GLAnimatorControl}, it is removed + * and the {@link GLAnimatorControl} added to the GLEventListenerState. + *

    + *

    + * The returned GLEventListenerState instance is the {@link #isOwner() owner of the components}. + *

    + * + * @param a {@link GLAutoDrawable} source to move components from + * @return new GLEventListenerState instance {@link #isOwner() owning} moved components. + * + * @see #moveTo(GLAutoDrawable) + */ + public static GLEventListenerState moveFrom(GLAutoDrawable a) { + final int aSz = a.getGLEventListenerCount(); + + // Create new AbstractGraphicsScreen w/ cloned AbstractGraphicsDevice for future GLAutoDrawable + // allowing this AbstractGraphicsDevice to loose ownership -> not closing display/device! + final NativeSurface aSurface = a.getNativeSurface(); + final AbstractGraphicsConfiguration aCfg = aSurface.getGraphicsConfiguration(); + final AbstractGraphicsScreen aScreen1 = aCfg.getScreen(); + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); + final AbstractGraphicsScreen aScreen2 = cloneScreen(aScreen1); + if( DEBUG ) { + System.err.println("GLEventListenerState.moveFrom.0: "+aSurface.getClass().getName()+", "+aSurface); + } + aScreen1.getDevice().clearHandleOwner(); // don't close device handle + + final AbstractGraphicsScreen aUpScreen2; + final boolean proxyOwnsUpstreamDevice; + { + AbstractGraphicsScreen _aUpScreen2=null; + if(aSurface instanceof ProxySurface) { + final ProxySurface aProxy = (ProxySurface)aSurface; + proxyOwnsUpstreamDevice = aProxy.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + final NativeSurface aUpSurface = aProxy.getUpstreamSurface(); + if(DEBUG && null != aUpSurface) { + System.err.println("GLEventListenerState.moveFrom.1: "+aUpSurface.getClass().getName()+", "+aUpSurface); + } + if(null != aUpSurface) { + final AbstractGraphicsScreen aUpScreen1 = aUpSurface.getGraphicsConfiguration().getScreen(); + _aUpScreen2 = cloneScreen(aUpScreen1); + if(null != aUpScreen1) { + aUpScreen1.getDevice().clearHandleOwner(); // don't close device handle + } + if(DEBUG) { + System.err.println("GLEventListenerState.moveFrom.2: "+aSurface.getClass().getName()+", "+aSurface); + System.err.println("GLEventListenerState.moveFrom.3: "+aUpSurface.getClass().getName()+", "+aUpSurface); + } + } + } else { + proxyOwnsUpstreamDevice = false; + } + aUpScreen2=_aUpScreen2; + } + + final GLAnimatorControl aAnim = a.getAnimator(); + final boolean aAnimStarted; + if( null != aAnim ) { + aAnimStarted = aAnim.isStarted(); + aAnim.remove(a); // also handles ECT + } else { + aAnimStarted = false; + } + + final GLEventListenerState glls = new GLEventListenerState(aUpScreen2, proxyOwnsUpstreamDevice, aScreen2, caps, a.getContext(), aSz, aAnim, aAnimStarted); + + // + // remove and cache all GLEventListener and their init-state + // + for(int i=0; i + * If the previous {@link GLAutoDrawable} was removed from a {@link GLAnimatorControl} by previous {@link #moveFrom(GLAutoDrawable)}, + * the given {@link GLAutoDrawable} is added to the cached {@link GLAnimatorControl}. + * This operation is skipped, if the given {@link GLAutoDrawable} is already added to a {@link GLAnimatorControl} instance. + *

    + *

    + * Note: After this operation, the GLEventListenerState reference should be released. + *

    + * + * @param a {@link GLAutoDrawable} destination to move GLEventListenerState components to + * + * @throws GLException if the {@link GLAutoDrawable}'s configuration is incompatible, i.e. different {@link GLCapabilitiesImmutable}. + * + * @see #moveFrom(GLAutoDrawable) + * @see #isOwner() + */ + public final void moveTo(GLAutoDrawable a) { + final List aGLCmds = new ArrayList(); + final int aSz = listenerCount(); + + final NativeSurface aSurface = a.getNativeSurface(); + final MutableGraphicsConfiguration aCfg = (MutableGraphicsConfiguration) aSurface.getGraphicsConfiguration(); + final GLCapabilitiesImmutable aCaps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); + if( caps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) != aCaps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) || + caps.getVisualID(VisualIDHolder.VIDType.NATIVE) != aCaps.getVisualID(VisualIDHolder.VIDType.NATIVE) ) { + throw new GLException("Incompatible Capabilities - Prev-Holder: "+caps+", New-Holder "+caps); + } + // Destroy and remove currently associated GLContext, if any (will be replaced) + a.setContext( null, true ); + final boolean aRealized = a.isRealized(); + if( aRealized ) { + a.setRealized(false); + } + // Set new Screen and close previous one + { + if( DEBUG ) { + System.err.println("GLEventListenerState.moveTo.0: "+aSurface.getClass().getName()+", "+aSurface); + } + final AbstractGraphicsScreen aScreen1 = aCfg.getScreen(); + aCfg.setScreen( screen ); + aScreen1.getDevice().close(); + if( DEBUG ) { + System.err.println("GLEventListenerState.moveTo.1: "+aSurface.getClass().getName()+", "+aSurface); + } + } + + // If using a ProxySurface w/ an upstream surface, set new Screen and close previous one on it + { + boolean upstreamSet = false; + if(aSurface instanceof ProxySurface) { + final ProxySurface aProxy = (ProxySurface)aSurface; + final NativeSurface aUpSurface = aProxy.getUpstreamSurface(); + if(null != aUpSurface) { + final MutableGraphicsConfiguration aUpCfg = (MutableGraphicsConfiguration) aUpSurface.getGraphicsConfiguration(); + if( null != upstreamScreen ) { + if( DEBUG ) { + System.err.println("GLEventListenerState.moveTo.2: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); + } + aUpCfg.getScreen().getDevice().close(); + aUpCfg.setScreen( upstreamScreen ); + if( proxyOwnsUpstreamDevice ) { + aProxy.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + upstreamSet = true; + if( DEBUG ) { + System.err.println("GLEventListenerState.moveTo.3: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); + } + } else { + throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = false, New-Holder = true"); + } + } + } + if( !upstreamSet && null != upstreamScreen ) { + throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = true, New-Holder = false"); + } + } + + if( aRealized ) { + a.setRealized(true); + } + final boolean surfaceLocked = false; // NativeSurface.LOCK_SURFACE_NOT_READY < aSurface.lockSurface(); + try { + a.setContext( context, false ); + } finally { + if( surfaceLocked ) { + aSurface.unlockSurface(); + } + } + owner = false; + + // + // Trigger GL-Viewport reset and reshape of all initialized GLEventListeners + // + aGLCmds.add(setViewport); + for(int i=0; i + * Implementing classes {@link #isGLStatePreservationSupported() may support} preservation + * of the {@link GLContext} state and it's associated {@link GLEventListener}. + *

    + */ +public interface GLStateKeeper { + + /** Listener for preserve and restore notifications. */ + public static interface Listener { + /** Invoked before preservation. */ + void glStatePreserveNotify(GLStateKeeper glsk); + /** Invoked after restoration. */ + void glStateRestored(GLStateKeeper glsk); + } + + /** + * Sets a {@link Listener}, overriding the old one. + * @param l the new {@link Listener}. + * @return the previous {@link Listener}. + */ + public Listener setGLStateKeeperListener(Listener l); + + /** + * @return true if GL state preservation is supported in implementation and on current platform, false otherwise. + * @see #preserveGLStateAtDestroy(boolean) + * @see #getPreservedGLState() + */ + public boolean isGLStatePreservationSupported(); + + /** + * If set to true, the next {@link GLAutoDrawable#destroy()} operation will + * {@link #pullGLEventListenerState() pull} to preserve the {@link GLEventListenerState}. + *

    + * This is a one-shot flag, i.e. after preserving the {@link GLEventListenerState}, + * the flag is cleared. + *

    + *

    + * A preserved {@link GLEventListenerState} will be {@link #pushGLEventListenerState() pushed} + * if realized again. + *

    + * @return true if supported and successful, false otherwise. + * @see #isGLStatePreservationSupported() + * @see #getPreservedGLState() + */ + public boolean preserveGLStateAtDestroy(boolean value); + + /** + * Returns the preserved {@link GLEventListenerState} if preservation was performed, + * otherwise null. + * @see #isGLStatePreservationSupported() + * @see #preserveGLStateAtDestroy(boolean) + */ + public GLEventListenerState getPreservedGLState(); + +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java index 1d68a402a..68d94d2e2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java @@ -33,6 +33,8 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLEventListener; +import com.jogamp.opengl.GLEventListenerState; + import jogamp.opengl.Debug; /** diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLEventListenerState.java b/src/jogl/classes/com/jogamp/opengl/util/GLEventListenerState.java deleted file mode 100644 index 5b02e1fec..000000000 --- a/src/jogl/classes/com/jogamp/opengl/util/GLEventListenerState.java +++ /dev/null @@ -1,365 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.util; - -import java.util.ArrayList; -import java.util.List; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.AbstractGraphicsScreen; -import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.opengl.GLAnimatorControl; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLException; -import javax.media.opengl.GLRunnable; - -import jogamp.opengl.Debug; - -import com.jogamp.nativewindow.MutableGraphicsConfiguration; - -/** - * GLEventListenerState is holding {@link GLAutoDrawable} components crucial - * to relocating all its {@link GLEventListener} w/ their operating {@link GLContext}, etc. - * The components are: - *
      - *
    • {@link GLContext}
    • - *
    • All {@link GLEventListener}, incl. their init state
    • - *
    • {@link GLAnimatorControl}
    • - *
    • {@link GLCapabilitiesImmutable} for compatibility check
    • - *
    • {@link AbstractGraphicsScreen} for compatibility check and preserving the {@link AbstractGraphicsDevice}
    • - *
    - *

    - * A GLEventListenerState instance can be created while components are {@link #moveFrom(GLAutoDrawable) moved from} a {@link GLAutoDrawable} - * to the new instance, which gains {@link #isOwner() ownership} of the moved components. - *

    - *

    - * A GLEventListenerState instance's components can be {@link #moveTo(GLAutoDrawable) moved to} a {@link GLAutoDrawable}, - * while loosing {@link #isOwner() ownership} of the moved components. - *

    - *

    - */ -public class GLEventListenerState { - private static final boolean DEBUG = Debug.debug("GLDrawable"); - - private GLEventListenerState(AbstractGraphicsScreen upstreamScreen, boolean proxyOwnsUpstreamDevice, AbstractGraphicsScreen screen, GLCapabilitiesImmutable caps, - GLContext context, int count, GLAnimatorControl anim) { - this.upstreamScreen = upstreamScreen; - this.proxyOwnsUpstreamDevice = proxyOwnsUpstreamDevice; - this.screen = screen; - this.caps = caps; - this.context = context; - this.listeners = new GLEventListener[count]; - this.listenersInit = new boolean[count]; - this.anim = anim; - this.owner = true; - } - /** - * Returns true, if this instance is the current owner of the components, - * otherwise false. - *

    - * Ownership is lost if {@link #moveTo(GLAutoDrawable)} is being called successfully - * and all components are transferred to the new {@link GLAutoDrawable}. - *

    - */ - public final boolean isOwner() { return owner; } - - public final int listenerCount() { return listeners.length; } - - public final AbstractGraphicsScreen upstreamScreen; - public final boolean proxyOwnsUpstreamDevice; - public final AbstractGraphicsScreen screen; - public final GLCapabilitiesImmutable caps; - public final GLContext context; - public final GLEventListener[] listeners; - public final boolean[] listenersInit; - public final GLAnimatorControl anim; - - private boolean owner; - - /** - * Last resort to destroy and loose ownership - */ - public void destroy() { - if( owner ) { - final int aSz = listenerCount(); - for(int i=0; i - * Note that all components are removed from the {@link GLAutoDrawable}, - * i.e. the {@link GLContext}, all {@link GLEventListener}. - *

    - *

    - * If the {@link GLAutoDrawable} was added to a {@link GLAnimatorControl}, it is removed - * and the {@link GLAnimatorControl} added to the GLEventListenerState. - *

    - *

    - * The returned GLEventListenerState instance is the {@link #isOwner() owner of the components}. - *

    - * - * @param a {@link GLAutoDrawable} source to move components from - * @return new GLEventListenerState instance {@link #isOwner() owning} moved components. - * - * @see #moveTo(GLAutoDrawable) - */ - public static GLEventListenerState moveFrom(GLAutoDrawable a) { - final int aSz = a.getGLEventListenerCount(); - - // Create new AbstractGraphicsScreen w/ cloned AbstractGraphicsDevice for future GLAutoDrawable - // allowing this AbstractGraphicsDevice to loose ownership -> not closing display/device! - final NativeSurface aSurface = a.getNativeSurface(); - final AbstractGraphicsConfiguration aCfg = aSurface.getGraphicsConfiguration(); - final AbstractGraphicsScreen aScreen1 = aCfg.getScreen(); - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); - final AbstractGraphicsScreen aScreen2 = cloneScreen(aScreen1); - if( DEBUG ) { - System.err.println("GLEventListenerState.moveFrom.0: "+aSurface.getClass().getName()+", "+aSurface); - } - aScreen1.getDevice().clearHandleOwner(); // don't close device handle - - final AbstractGraphicsScreen aUpScreen2; - final boolean proxyOwnsUpstreamDevice; - { - AbstractGraphicsScreen _aUpScreen2=null; - if(aSurface instanceof ProxySurface) { - final ProxySurface aProxy = (ProxySurface)aSurface; - proxyOwnsUpstreamDevice = aProxy.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); - final NativeSurface aUpSurface = aProxy.getUpstreamSurface(); - if(DEBUG && null != aUpSurface) { - System.err.println("GLEventListenerState.moveFrom.1: "+aUpSurface.getClass().getName()+", "+aUpSurface); - } - if(null != aUpSurface) { - final AbstractGraphicsScreen aUpScreen1 = aUpSurface.getGraphicsConfiguration().getScreen(); - _aUpScreen2 = cloneScreen(aUpScreen1); - if(null != aUpScreen1) { - aUpScreen1.getDevice().clearHandleOwner(); // don't close device handle - } - if(DEBUG) { - System.err.println("GLEventListenerState.moveFrom.2: "+aSurface.getClass().getName()+", "+aSurface); - System.err.println("GLEventListenerState.moveFrom.3: "+aUpSurface.getClass().getName()+", "+aUpSurface); - } - } - } else { - proxyOwnsUpstreamDevice = false; - } - aUpScreen2=_aUpScreen2; - } - - final GLAnimatorControl aAnim = a.getAnimator(); - if( null != aAnim ) { - aAnim.remove(a); // also handles ECT - } - - final GLEventListenerState glls = new GLEventListenerState(aUpScreen2, proxyOwnsUpstreamDevice, aScreen2, caps, a.getContext(), aSz, aAnim); - - // - // remove and cache all GLEventListener and their init-state - // - for(int i=0; i - * If the previous {@link GLAutoDrawable} was removed from a {@link GLAnimatorControl} by previous {@link #moveFrom(GLAutoDrawable)}, - * the given {@link GLAutoDrawable} is added to the cached {@link GLAnimatorControl}. - * This operation is skipped, if the given {@link GLAutoDrawable} is already added to a {@link GLAnimatorControl} instance. - *

    - *

    - * Note: After this operation, the GLEventListenerState reference should be released. - *

    - * - * @param a {@link GLAutoDrawable} destination to move GLEventListenerState components to - * - * @throws GLException if the {@link GLAutoDrawable}'s configuration is incompatible, i.e. different {@link GLCapabilitiesImmutable}. - * - * @see #moveFrom(GLAutoDrawable) - * @see #isOwner() - */ - public final void moveTo(GLAutoDrawable a) { - final List aGLCmds = new ArrayList(); - final int aSz = listenerCount(); - - final NativeSurface aSurface = a.getNativeSurface(); - final MutableGraphicsConfiguration aCfg = (MutableGraphicsConfiguration) aSurface.getGraphicsConfiguration(); - final GLCapabilitiesImmutable aCaps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); - if( caps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) != aCaps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) || - caps.getVisualID(VisualIDHolder.VIDType.NATIVE) != aCaps.getVisualID(VisualIDHolder.VIDType.NATIVE) ) { - throw new GLException("Incompatible Capabilities - Prev-Holder: "+caps+", New-Holder "+caps); - } - // Destroy and remove currently associated GLContext, if any (will be replaced) - a.setContext( null, true ); - final boolean aRealized = a.isRealized(); - if( aRealized ) { - a.setRealized(false); - } - // Set new Screen and close previous one - { - if( DEBUG ) { - System.err.println("GLEventListenerState.moveTo.0: "+aSurface.getClass().getName()+", "+aSurface); - } - final AbstractGraphicsScreen aScreen1 = aCfg.getScreen(); - aCfg.setScreen( screen ); - aScreen1.getDevice().close(); - if( DEBUG ) { - System.err.println("GLEventListenerState.moveTo.1: "+aSurface.getClass().getName()+", "+aSurface); - } - } - - // If using a ProxySurface w/ an upstream surface, set new Screen and close previous one on it - { - boolean upstreamSet = false; - if(aSurface instanceof ProxySurface) { - final ProxySurface aProxy = (ProxySurface)aSurface; - final NativeSurface aUpSurface = aProxy.getUpstreamSurface(); - if(null != aUpSurface) { - final MutableGraphicsConfiguration aUpCfg = (MutableGraphicsConfiguration) aUpSurface.getGraphicsConfiguration(); - if( null != upstreamScreen ) { - if( DEBUG ) { - System.err.println("GLEventListenerState.moveTo.2: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); - } - aUpCfg.getScreen().getDevice().close(); - aUpCfg.setScreen( upstreamScreen ); - if( proxyOwnsUpstreamDevice ) { - aProxy.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); - } - upstreamSet = true; - if( DEBUG ) { - System.err.println("GLEventListenerState.moveTo.3: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); - } - } else { - throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = false, New-Holder = true"); - } - } - } - if( !upstreamSet && null != upstreamScreen ) { - throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = true, New-Holder = false"); - } - } - - if( aRealized ) { - a.setRealized(true); - } - final boolean surfaceLocked = false; // NativeSurface.LOCK_SURFACE_NOT_READY < aSurface.lockSurface(); - try { - a.setContext( context, false ); - } finally { - if( surfaceLocked ) { - aSurface.unlockSurface(); - } - } - owner = false; - - // - // Trigger GL-Viewport reset and reshape of all initialized GLEventListeners - // - aGLCmds.add(setViewport); - for(int i=0; itrue
    , the next {@link #destroy()} operation will - * {@link #pullGLEventListenerState() pull} to preserve the {@link GLEventListenerState}. - */ - public final void setPreserveGLStateAtDestroy(boolean value) { - if( DEBUG ) { - System.err.println("GLAutoDrawableBase.setPreserveGLStateAtDestroy: ("+Thread.currentThread().getName()+"): "+preserveGLELSAtDestroy+" -> "+value+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + @Override + public final boolean preserveGLStateAtDestroy(boolean value) { + final boolean res = isGLStatePreservationSupported() ? true : false; + if( res ) { + if( DEBUG ) { + System.err.println("GLAutoDrawableBase.setPreserveGLStateAtDestroy: ("+Thread.currentThread().getName()+"): "+preserveGLELSAtDestroy+" -> "+value+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + } + preserveGLELSAtDestroy = value; + } else { + } - preserveGLELSAtDestroy = value; + return res; } + @Override + public boolean isGLStatePreservationSupported() { return false; } + + @Override + public final GLEventListenerState getPreservedGLState() { + return glels; + } + /** * Pulls the {@link GLEventListenerState} from this {@link GLAutoDrawable}. * @@ -130,6 +150,9 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { throw new IllegalStateException("GLEventListenerState already pulled"); } if( null != context && context.isCreated() ) { + if( null!= glStateKeeperListener) { + glStateKeeperListener.glStatePreserveNotify(this); + } glels = GLEventListenerState.moveFrom(this); return null != glels; } @@ -149,6 +172,9 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { if( null != glels ) { glels.moveTo(this); glels = null; + if( null!= glStateKeeperListener) { + glStateKeeperListener.glStateRestored(this); + } return true; } return false; @@ -286,7 +312,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { */ protected void destroyImplInLock() { if( preserveGLELSAtDestroy ) { - setPreserveGLStateAtDestroy(false); + preserveGLStateAtDestroy(false); pullGLEventListenerState(); } if( null != context ) { diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 33f136460..a6c655915 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -421,8 +421,8 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind protected class GLLifecycleHook implements WindowImpl.LifecycleHook { @Override - public void setPreserveResourcesAtDestroy() { - GLWindow.this.setPreserveGLStateAtDestroy(true); + public void preserveGLStateAtDestroy() { + GLWindow.this.preserveGLStateAtDestroy(true); } @Override @@ -567,6 +567,9 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind setVisible(true); } } + + @Override + public final boolean isGLStatePreservationSupported() { return true; } //---------------------------------------------------------------------- // GLDrawable methods diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index e1636ffcd..e5dd783ca 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -231,7 +231,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * Notifies the receiver to preserve resources (GL, ..) * for the next destroy*() calls (only). */ - void setPreserveResourcesAtDestroy(); + void preserveGLStateAtDestroy(); /** * Invoked before Window destroy action, @@ -966,7 +966,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected void destroy(boolean preserveResources) { if( preserveResources && null != WindowImpl.this.lifecycleHook ) { - WindowImpl.this.lifecycleHook.setPreserveResourcesAtDestroy(); + WindowImpl.this.lifecycleHook.preserveGLStateAtDestroy(); } destroy(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java index da86c8741..300b4ec85 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java @@ -44,11 +44,11 @@ import jogamp.nativewindow.jawt.JAWTUtil; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.GLEventListenerState; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.GLEventListenerCounter; import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.GLEventListenerState; import org.junit.Assert; import org.junit.Assume; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch10NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch10NEWT.java index 694b40214..2bba76ee7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch10NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch10NEWT.java @@ -46,8 +46,8 @@ import javax.media.opengl.GLProfile; import com.jogamp.opengl.GLAutoDrawableDelegate; +import com.jogamp.opengl.GLEventListenerState; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.GLEventListenerState; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java index 269af714d..68f74a27a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java @@ -34,8 +34,8 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; +import com.jogamp.opengl.GLEventListenerState; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.GLEventListenerState; import com.jogamp.opengl.test.junit.util.GLEventListenerCounter; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java index 129b2e80e..684208909 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java @@ -35,8 +35,8 @@ import javax.media.opengl.GLProfile; import jogamp.nativewindow.jawt.JAWTUtil; +import com.jogamp.opengl.GLEventListenerState; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.GLEventListenerState; import com.jogamp.opengl.test.junit.util.GLEventListenerCounter; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch21Newt2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch21Newt2AWT.java index 4f21d1626..87057f5a9 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch21Newt2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch21Newt2AWT.java @@ -34,8 +34,8 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; +import com.jogamp.opengl.GLEventListenerState; import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.GLEventListenerState; import com.jogamp.opengl.test.junit.util.GLEventListenerCounter; -- cgit v1.2.3 From 3673964caf2c4ac4efddffb8d7e9c28cce49b48c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 22 Mar 2013 10:31:27 +0100 Subject: NEWT/Android WindowDriver.closeNative0(..): Catch Exception at surface destroy allowing to continue destruction. --- .../classes/jogamp/newt/driver/android/WindowDriver.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index 8002c49b3..8f9ee1c0f 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -376,11 +376,17 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { setupInputListener(false); if(0 != eglSurface) { - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice(); - if (!EGL.eglDestroySurface(eglDevice.getHandle(), eglSurface)) { - throw new GLException("Error destroying window surface (eglDestroySurface)"); + try { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice(); + if (!EGL.eglDestroySurface(eglDevice.getHandle(), eglSurface)) { + throw new GLException("Error destroying window surface (eglDestroySurface)"); + } + } catch (Throwable t) { + Log.d(MD.TAG, "closeNativeImpl: Catch exception "+t.getMessage()); + t.printStackTrace(); + } finally { + eglSurface = 0; } - eglSurface = 0; } release0(surfaceHandle); -- cgit v1.2.3 From d514ecbf052d013ea8c0982c490757678075a9ea Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 22 Mar 2013 13:43:59 +0100 Subject: NEWT/Android (Bug 665): Add Support for GLStateKeeper ; onPause() always destroys ; Recognizing all GLAutoDrawable's GLAnimatorControl for pause/resume ; Use GLAnimatorControl instead of Animator - Add Support for GLStateKeeper If !isFinishing() (HOME button), preserve the GLEventListener if an GLStateKeeper instance - onPause() always destroys onDestroy() is too late, i.e. surfaceDestroyed() already called - Recognizing all GLAutoDrawable's GLAnimatorControl for pause/resume pause/resume the GLAnimatorControl of all GLAutoDrawable instances - Use GLAnimatorControl instead of Animator We used an Animator reference .. duh! Note: The EGL native WindowDriver (Android and BCM.IV) must retain their own copy of EGLGraphicsDevice, which preserves the EGLDisplay handle due to EGLDisplayUtil reference counting per nativeHandleID. --- .../com/jogamp/opengl/GLEventListenerState.java | 36 +++-- .../newt/driver/android/NewtBaseActivity.java | 167 ++++++++++++++++----- .../jogamp/newt/driver/android/ScreenDriver.java | 8 +- .../jogamp/newt/driver/android/WindowDriver.java | 25 ++- .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 17 ++- .../opengl/test/android/MovieCubeActivity0.java | 1 - .../opengl/test/android/MovieSimpleActivity0.java | 1 - .../opengl/test/android/MovieSimpleActivity1.java | 1 - .../opengl/test/android/NEWTElektronActivity.java | 1 - .../opengl/test/android/NEWTGearsES1Activity.java | 1 - .../opengl/test/android/NEWTGearsES2Activity.java | 1 - .../test/android/NEWTGearsES2TransActivity.java | 1 - .../opengl/test/android/NEWTGraphUI1pActivity.java | 1 - .../opengl/test/android/NEWTGraphUI2pActivity.java | 1 - .../test/android/NEWTRedSquareES1Activity.java | 1 - .../test/android/NEWTRedSquareES2Activity.java | 1 - 16 files changed, 188 insertions(+), 76 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java index 5c0954584..2914a1bf9 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java +++ b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java @@ -161,11 +161,12 @@ public class GLEventListenerState { final AbstractGraphicsScreen aScreen1 = aCfg.getScreen(); final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); final AbstractGraphicsScreen aScreen2 = cloneScreen(aScreen1); - if( DEBUG ) { - System.err.println("GLEventListenerState.moveFrom.0: "+aSurface.getClass().getName()+", "+aSurface); - } aScreen1.getDevice().clearHandleOwner(); // don't close device handle - + if( DEBUG ) { + System.err.println("GLEventListenerState.moveFrom.0a: orig 0x"+Integer.toHexString(aScreen1.getDevice().hashCode())+", "+aScreen1.getDevice()); + System.err.println("GLEventListenerState.moveFrom.0b: pres 0x"+Integer.toHexString(aScreen2.getDevice().hashCode())+", "+aScreen2.getDevice()); + System.err.println("GLEventListenerState.moveFrom.1: "+aSurface.getClass().getName()+", "+aSurface); + } final AbstractGraphicsScreen aUpScreen2; final boolean proxyOwnsUpstreamDevice; { @@ -175,7 +176,7 @@ public class GLEventListenerState { proxyOwnsUpstreamDevice = aProxy.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); final NativeSurface aUpSurface = aProxy.getUpstreamSurface(); if(DEBUG && null != aUpSurface) { - System.err.println("GLEventListenerState.moveFrom.1: "+aUpSurface.getClass().getName()+", "+aUpSurface); + System.err.println("GLEventListenerState.moveFrom.2: "+aUpSurface.getClass().getName()+", "+aUpSurface); } if(null != aUpSurface) { final AbstractGraphicsScreen aUpScreen1 = aUpSurface.getGraphicsConfiguration().getScreen(); @@ -184,8 +185,10 @@ public class GLEventListenerState { aUpScreen1.getDevice().clearHandleOwner(); // don't close device handle } if(DEBUG) { - System.err.println("GLEventListenerState.moveFrom.2: "+aSurface.getClass().getName()+", "+aSurface); - System.err.println("GLEventListenerState.moveFrom.3: "+aUpSurface.getClass().getName()+", "+aUpSurface); + System.err.println("GLEventListenerState.moveFrom.3a: up-orig 0x"+Integer.toHexString(aUpScreen1.getDevice().hashCode())+", "+aUpScreen1.getDevice()); + System.err.println("GLEventListenerState.moveFrom.3b: up-pres 0x"+Integer.toHexString(_aUpScreen2.getDevice().hashCode())+", "+_aUpScreen2.getDevice()); + System.err.println("GLEventListenerState.moveFrom.3c: "+aSurface.getClass().getName()+", "+aSurface); + System.err.println("GLEventListenerState.moveFrom.3d: "+aUpSurface.getClass().getName()+", "+aUpSurface); } } } else { @@ -262,14 +265,16 @@ public class GLEventListenerState { } // Set new Screen and close previous one { + final AbstractGraphicsScreen aScreen1 = aCfg.getScreen(); if( DEBUG ) { - System.err.println("GLEventListenerState.moveTo.0: "+aSurface.getClass().getName()+", "+aSurface); + System.err.println("GLEventListenerState.moveTo.0a: orig 0x"+Integer.toHexString(aScreen1.getDevice().hashCode())+", "+aScreen1.getDevice()); + System.err.println("GLEventListenerState.moveTo.0b: pres 0x"+Integer.toHexString(screen.getDevice().hashCode())+", "+screen.getDevice()); } - final AbstractGraphicsScreen aScreen1 = aCfg.getScreen(); aCfg.setScreen( screen ); aScreen1.getDevice().close(); if( DEBUG ) { - System.err.println("GLEventListenerState.moveTo.1: "+aSurface.getClass().getName()+", "+aSurface); + System.err.println("GLEventListenerState.moveTo.1a: orig 0x"+Integer.toHexString(aScreen1.getDevice().hashCode())+", "+aScreen1.getDevice()); + System.err.println("GLEventListenerState.moveTo.1b: pres 0x"+Integer.toHexString(screen.getDevice().hashCode())+", "+screen.getDevice()); } } @@ -282,17 +287,22 @@ public class GLEventListenerState { if(null != aUpSurface) { final MutableGraphicsConfiguration aUpCfg = (MutableGraphicsConfiguration) aUpSurface.getGraphicsConfiguration(); if( null != upstreamScreen ) { + final AbstractGraphicsScreen aUpScreen1 = aUpCfg.getScreen(); if( DEBUG ) { - System.err.println("GLEventListenerState.moveTo.2: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); + System.err.println("GLEventListenerState.moveTo.2a: up-orig 0x"+Integer.toHexString(aUpScreen1.getDevice().hashCode())+", "+aUpScreen1.getDevice()); + System.err.println("GLEventListenerState.moveTo.2b: up-pres 0x"+Integer.toHexString(upstreamScreen.getDevice().hashCode())+", "+upstreamScreen.getDevice()); + System.err.println("GLEventListenerState.moveTo.2c: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); } - aUpCfg.getScreen().getDevice().close(); + aUpScreen1.getDevice().close(); aUpCfg.setScreen( upstreamScreen ); if( proxyOwnsUpstreamDevice ) { aProxy.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); } upstreamSet = true; if( DEBUG ) { - System.err.println("GLEventListenerState.moveTo.3: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); + System.err.println("GLEventListenerState.moveTo.3a: up-orig 0x"+Integer.toHexString(aUpScreen1.getDevice().hashCode())+", "+aUpScreen1.getDevice()); + System.err.println("GLEventListenerState.moveTo.3b: up-pres 0x"+Integer.toHexString(upstreamScreen.getDevice().hashCode())+", "+upstreamScreen.getDevice()); + System.err.println("GLEventListenerState.moveTo.3c: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); } } else { throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = false, New-Holder = true"); diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index 726793768..2ea7a9d84 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -32,9 +32,12 @@ import java.util.List; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.opengl.FPSCounter; +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawable; import com.jogamp.newt.Window; -import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.GLEventListenerState; +import com.jogamp.opengl.GLStateKeeper; import jogamp.newt.driver.android.WindowDriver; @@ -46,12 +49,46 @@ import android.view.WindowManager; public class NewtBaseActivity extends Activity { List newtWindows = new ArrayList(); - Animator animator = null; + List glAutoDrawables = new ArrayList(); + + GLAnimatorControl animator = null; boolean isDelegatedActivity; Activity rootActivity; boolean setThemeCalled = false; + protected void startAnimation(boolean start) { + if(null != animator) { + final boolean res; + if( start ) { + if( animator.isPaused() ) { + res = animator.resume(); + } else { + res = animator.start(); + } + } else { + res = animator.stop(); + } + Log.d(MD.TAG, "Animator global: start "+start+", result "+res); + } + for(int i=0; i * @param androidWindow * @param newtWindow + * @throws IllegalArgumentException if the newtWindow's {@link Window#getDelegatedWindow() delegate} is not an AndroidDriver. + * @see #registerNEWTWindow(Window) * @see #addContentView(android.view.Window, Window, android.view.ViewGroup.LayoutParams) */ - public void setContentView(android.view.Window androidWindow, Window newtWindow) { - newtWindow = newtWindow.getDelegatedWindow(); - if(newtWindow instanceof WindowDriver) { - adaptTheme4Transparency(newtWindow.getRequestedCapabilities()); - layoutForNEWTWindow(androidWindow, newtWindow); - WindowDriver newtAWindow = (WindowDriver)newtWindow; + public void setContentView(final android.view.Window androidWindow, final Window newtWindow) throws IllegalArgumentException { + final Window delegateWindow = newtWindow.getDelegatedWindow(); + if(delegateWindow instanceof WindowDriver) { + adaptTheme4Transparency(delegateWindow.getRequestedCapabilities()); + layoutForNEWTWindow(androidWindow, delegateWindow); + final WindowDriver newtAWindow = (WindowDriver)delegateWindow; androidWindow.setContentView(newtAWindow.getAndroidView()); - registerNEWTWindow(newtAWindow); } else { - throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+newtWindow.getClass()); + throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+newtWindow.getClass().getName()); } + registerNEWTWindow(newtWindow); } /** * This is one of the three registration methods (see below). @@ -102,35 +141,67 @@ public class NewtBaseActivity extends Activity { * @param androidWindow * @param newtWindow * @param params - * @see #setContentView(android.view.Window, Window) + * @throws IllegalArgumentException if the newtWindow's {@link Window#getDelegatedWindow() delegate} is not an AndroidDriver. * @see #registerNEWTWindow(Window) + * @see #setContentView(android.view.Window, Window) */ - public void addContentView(android.view.Window androidWindow, Window newtWindow, android.view.ViewGroup.LayoutParams params) { - newtWindow = newtWindow.getDelegatedWindow(); - if(newtWindow instanceof WindowDriver) { - WindowDriver newtAWindow = (WindowDriver)newtWindow; + public void addContentView(final android.view.Window androidWindow, final Window newtWindow, final android.view.ViewGroup.LayoutParams params) throws IllegalArgumentException { + final Window delegateWindow = newtWindow.getDelegatedWindow(); + if(delegateWindow instanceof WindowDriver) { + final WindowDriver newtAWindow = (WindowDriver)delegateWindow; androidWindow.addContentView(newtAWindow.getAndroidView(), params); - registerNEWTWindow(newtAWindow); } else { - throw new IllegalArgumentException("Given NEWT Window is not an Android Window: "+newtWindow.getClass()); + throw new IllegalArgumentException("Given NEWT Window's Delegate is not an Android Window: "+delegateWindow.getClass().getName()); } + registerNEWTWindow(newtWindow); } /** * This is one of the three registration methods (see below). *

    - * This methods simply registers the given NEWT window to ensure it's destruction at {@link #onDestroy()}. - *

    + * This methods registers the given NEWT window to ensure it's destruction at {@link #onDestroy()}. + *

    + *

    + * If adding a {@link GLAutoDrawable} implementation, the {@link GLAnimatorControl} retrieved by {@link GLAutoDrawable#getAnimator()} + * will be used for {@link #onPause()} and {@link #onResume()}. + *

    + *

    + * If adding a {@link GLAutoDrawable} implementation, the {@link GLEventListenerState} will preserve it's state + * when {@link #onPause()} is being called while not {@link #isFinishing()}. A later {@link #onResume()} will + * reinstate the {@link GLEventListenerState}. + *

    * * @param newtWindow + * @throws IllegalArgumentException if the newtWindow's {@link Window#getDelegatedWindow() delegate} is not an AndroidDriver. * @see #setContentView(android.view.Window, Window) * @see #addContentView(android.view.Window, Window, android.view.ViewGroup.LayoutParams) */ - public void registerNEWTWindow(Window newtWindow) { - newtWindow = newtWindow.getDelegatedWindow(); - WindowDriver newtAWindow = (WindowDriver)newtWindow; - newtAWindow.registerActivity(getActivity()); + public void registerNEWTWindow(final Window newtWindow) throws IllegalArgumentException { + final Window delegateWindow = newtWindow.getDelegatedWindow(); + Log.d(MD.TAG, "registerNEWTWindow: Type "+newtWindow.getClass().getName()+", delegate "+delegateWindow.getClass().getName()); + if(delegateWindow instanceof WindowDriver) { + final WindowDriver newtAWindow = (WindowDriver)delegateWindow; + newtAWindow.registerActivity(getActivity()); + } else { + throw new IllegalArgumentException("Given NEWT Window's Delegate is not an Android Window: "+delegateWindow.getClass().getName()); + } newtWindows.add(newtWindow); + if(newtWindow instanceof GLAutoDrawable) { + glAutoDrawables.add((GLAutoDrawable)newtWindow); + } + if(newtWindow instanceof GLStateKeeper) { + ((GLStateKeeper)newtWindow).setGLStateKeeperListener(glStateKeeperListener); + } } + private final GLStateKeeper.Listener glStateKeeperListener = new GLStateKeeper.Listener() { + @Override + public void glStatePreserveNotify(GLStateKeeper glsk) { + Log.d(MD.TAG, "GLStateKeeper Preserving: 0x"+Integer.toHexString(glsk.hashCode())); + } + @Override + public void glStateRestored(GLStateKeeper glsk) { + Log.d(MD.TAG, "GLStateKeeper Restored: 0x"+Integer.toHexString(glsk.hashCode())); + } + }; /** * Convenient method to set the Android window's flags to fullscreen or size-layout depending on the given NEWT window. @@ -224,7 +295,19 @@ public class NewtBaseActivity extends Activity { } } - public void setAnimator(Animator animator) { + /** + * Setting up a global {@Link GLAnimatorControl} for {@link #onPause()} and {@link #onResume()}. + *

    + * Note that if adding a {@link GLAutoDrawable} implementation via {@link #registerNEWTWindow(Window)}, + * {@link #setContentView(android.view.Window, Window)} or {@link #addContentView(android.view.Window, Window, android.view.ViewGroup.LayoutParams)} + * their {@link GLAnimatorControl} retrieved by {@link GLAutoDrawable#getAnimator()} will be used as well. + * In this case, using this global {@Link GLAnimatorControl} is redundant. + *

    + * @see #registerNEWTWindow(Window) + * @see #setContentView(android.view.Window, Window) + * @see #addContentView(android.view.Window, Window, android.view.ViewGroup.LayoutParams) + */ + public void setAnimator(GLAnimatorControl animator) { this.animator = animator; if(!animator.isStarted()) { animator.start(); @@ -279,23 +362,33 @@ public class NewtBaseActivity extends Activity { ((FPSCounter)win).resetFPSCounter(); } } - if(null != animator) { - animator.resume(); - animator.resetFPSCounter(); - } + startAnimation(true); } @Override public void onPause() { Log.d(MD.TAG, "onPause"); - if(null != animator) { - animator.pause(); + if( !getActivity().isFinishing() ) { + int ok=0, fail=0; + for(int i=0; i0) { - final Window win = newtWindows.remove(newtWindows.size()-1); - win.destroy(); - } + newtWindows.clear(); + glAutoDrawables.clear(); jogamp.common.os.android.StaticContext.clear(); if(!isDelegatedActivity()) { super.onDestroy(); diff --git a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java index 795aac5fb..aee372f01 100644 --- a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java @@ -28,19 +28,19 @@ package jogamp.newt.driver.android; -import javax.media.nativewindow.*; +import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.util.Dimension; import javax.media.nativewindow.util.Point; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; - import android.content.Context; import android.graphics.PixelFormat; import android.util.DisplayMetrics; import android.view.Surface; import android.view.WindowManager; +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + public class ScreenDriver extends jogamp.newt.ScreenImpl { static { diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index 8f9ee1c0f..6f78a6f6b 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -33,8 +33,10 @@ import jogamp.newt.WindowImpl; import jogamp.newt.driver.android.event.AndroidNewtEventFactory; import jogamp.newt.driver.android.event.AndroidNewtEventTranslator; +import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; @@ -49,6 +51,7 @@ import com.jogamp.newt.Screen; import com.jogamp.newt.ScreenMode; import jogamp.opengl.egl.EGL; +import jogamp.opengl.egl.EGLDisplayUtil; import jogamp.opengl.egl.EGLGraphicsConfiguration; import jogamp.opengl.egl.EGLGraphicsConfigurationFactory; @@ -322,7 +325,14 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { @Override protected final void createNativeImpl() { - Log.d(MD.TAG, "createNativeImpl 0 - surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ + // Create own screen/device resource instance allowing independent ownership, + // while still utilizing shared EGL resources. + final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); + final EGLGraphicsDevice aDevice = (EGLGraphicsDevice) aScreen.getDevice(); + final EGLGraphicsDevice eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(aDevice.getNativeDisplayID(), aDevice.getConnection(), aDevice.getUnitID()); + final DefaultGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aScreen.getIndex()); + + Log.d(MD.TAG, "createNativeImpl 0 - eglDevice 0x"+Integer.toHexString(eglDevice.hashCode())+", "+eglDevice+", surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ ", format [a "+androidFormat+", n "+nativeFormat+"], "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - on thread "+Thread.currentThread().getName()); if(0!=getParentWindowHandle()) { @@ -332,11 +342,9 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { throw new InternalError("surfaceHandle null"); } - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice(); final EGLGraphicsConfiguration eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( capsByFormat, (GLCapabilitiesImmutable) getRequestedCapabilities(), - (GLCapabilitiesChooser)capabilitiesChooser, getScreen().getGraphicsScreen(), nativeFormat, - isAndroidFormatTransparent(androidFormat)); + (GLCapabilitiesChooser)capabilitiesChooser, eglScreen, nativeFormat, isAndroidFormatTransparent(androidFormat)); if (eglConfig == null) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } @@ -361,12 +369,14 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { setupInputListener(true); - Log.d(MD.TAG, "createNativeImpl X: eglSurfaceHandle 0x"+Long.toHexString(eglSurface)); + Log.d(MD.TAG, "createNativeImpl X: eglDevice 0x"+Integer.toHexString(eglDevice.hashCode())+", "+eglDevice+", eglSurfaceHandle 0x"+Long.toHexString(eglSurface)); } @Override protected final void closeNativeImpl() { - Log.d(MD.TAG, "closeNativeImpl 0 - surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getGraphicsConfiguration().getScreen().getDevice(); + + Log.d(MD.TAG, "closeNativeImpl 0 - eglDevice 0x"+Integer.toHexString(eglDevice.hashCode())+", "+eglDevice+", surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ ", eglSurfaceHandle 0x"+Long.toHexString(eglSurface)+ ", format [a "+androidFormat+", n "+nativeFormat+"], "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - on thread "+Thread.currentThread().getName()); if(WindowImpl.DEBUG_IMPLEMENTATION) { @@ -377,7 +387,6 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { if(0 != eglSurface) { try { - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice(); if (!EGL.eglDestroySurface(eglDevice.getHandle(), eglSurface)) { throw new GLException("Error destroying window surface (eglDestroySurface)"); } @@ -389,6 +398,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } } release0(surfaceHandle); + + eglDevice.close(); if( null != androidView ) { if( added2StaticViewGroup ) { diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index bdef8e6cd..e820439d0 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -29,16 +29,21 @@ package jogamp.newt.driver.bcm.vc.iv; import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; + import jogamp.newt.WindowImpl; import jogamp.newt.driver.linux.LinuxEventDeviceTracker; import jogamp.newt.driver.linux.LinuxMouseTracker; +import jogamp.opengl.egl.EGLDisplayUtil; public class WindowDriver extends WindowImpl { private static final String WINDOW_CLASS_NAME = "NewtWindow"; @@ -54,9 +59,15 @@ public class WindowDriver extends WindowImpl { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); } + // Create own screen/device resource instance allowing independent ownership, + // while still utilizing shared EGL resources. + final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); + final EGLGraphicsDevice aDevice = (EGLGraphicsDevice) aScreen.getDevice(); + final EGLGraphicsDevice eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(aDevice.getNativeDisplayID(), aDevice.getConnection(), aDevice.getUnitID()); + final DefaultGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aScreen.getIndex()); final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + capsRequested, capsRequested, capabilitiesChooser, eglScreen, VisualIDHolder.VID_UNDEFINED); if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } @@ -82,6 +93,8 @@ public class WindowDriver extends WindowImpl { } protected void closeNativeImpl() { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getGraphicsConfiguration().getScreen().getDevice(); + removeWindowListener(LinuxMouseTracker.getSingleton()); removeWindowListener(LinuxEventDeviceTracker.getSingleton()); @@ -89,6 +102,8 @@ public class WindowDriver extends WindowImpl { CloseWindow(windowHandleClose, windowUserData); windowUserData=0; } + + eglDevice.close(); } protected void requestFocusImpl(boolean reparented) { diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java index b1ab90a88..6aa2a045e 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java @@ -82,7 +82,6 @@ public class MovieCubeActivity0 extends NewtBaseActivity { try { final Animator animator = new Animator(); - setAnimator(animator); // Main final MovieCube demoMain = new MovieCube(urlConnection0, -2.3f, 0f, 0f); diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java index 89395e309..bcff3d5bd 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java @@ -82,7 +82,6 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { try { final Animator animator = new Animator(); - setAnimator(animator); // Main final MovieSimple demoMain = new MovieSimple(urlConnection0); diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java index a7fefd838..cb0fd0720 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java @@ -109,7 +109,6 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { try { final Animator animator = new Animator(); - setAnimator(animator); // Main final MovieSimple demoMain = new MovieSimple(urlConnection0); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java index d1c8f2743..0dead125a 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java @@ -66,7 +66,6 @@ public class NEWTElektronActivity extends NewtBaseActivity { }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); - setAnimator(animator); animator.setUpdateFPSFrames(60, System.err); animator.resetFPSCounter(); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java index c24c3af28..c020413cf 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java @@ -71,7 +71,6 @@ public class NEWTGearsES1Activity extends NewtBaseActivity { }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); - setAnimator(animator); animator.setUpdateFPSFrames(60, System.err); animator.resetFPSCounter(); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java index 931ffdbb2..e45df5eae 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java @@ -78,7 +78,6 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { }); Animator animator = new Animator(glWindow); // animator.setRunAsFastAsPossible(true); - setAnimator(animator); // glWindow.setSkipContextReleaseThread(animator.getThread()); if( null != System.getProperty(forceECT) ) { diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java index 9e50a1be1..18c3cb042 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java @@ -72,7 +72,6 @@ public class NEWTGearsES2TransActivity extends NewtBaseActivity { } }); Animator animator = new Animator(glWindow); - setAnimator(animator); // glWindow.setSkipContextReleaseThread(animator.getThread()); glWindow.setVisible(true); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java index b8bf285c6..bbd4f9f20 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java @@ -69,7 +69,6 @@ public class NEWTGraphUI1pActivity extends NewtBaseActivity { }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); - setAnimator(animator); animator.setUpdateFPSFrames(60, System.err); animator.resetFPSCounter(); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java index 103af1aab..20ba3f484 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java @@ -70,7 +70,6 @@ public class NEWTGraphUI2pActivity extends NewtBaseActivity { }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); - setAnimator(animator); animator.setUpdateFPSFrames(60, System.err); animator.resetFPSCounter(); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java index a394482fc..06ce75ac5 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java @@ -65,7 +65,6 @@ public class NEWTRedSquareES1Activity extends NewtBaseActivity { }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); - setAnimator(animator); animator.setUpdateFPSFrames(60, System.err); animator.resetFPSCounter(); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java index e850b9310..02e2d8f01 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java @@ -70,7 +70,6 @@ public class NEWTRedSquareES2Activity extends NewtBaseActivity { }); Animator animator = new Animator(glWindow); // animator.setRunAsFastAsPossible(true); - setAnimator(animator); // glWindow.setSkipContextReleaseThread(animator.getThread()); glWindow.setVisible(true); -- cgit v1.2.3 From 218b9d88f4ec1d15a46697dd7c5e835660020f99 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 23 Mar 2013 11:17:31 +0100 Subject: NEWT/Android: Fix suspense regression of commit d514ecbf052d013ea8c0982c490757678075a9ea Explicit win.destroy() shall only be called at activity.onDestroy(), - GLStateKeeper preservation is marked at pause, - and the Window's surfaceDestroyed() will also issue destroy() - so it's safe Reason: On Suspense (or power button), application is paused _without_ surfaceDestruction ! --- src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index 2ea7a9d84..ab8fc8ad0 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -200,6 +200,7 @@ public class NewtBaseActivity extends Activity { @Override public void glStateRestored(GLStateKeeper glsk) { Log.d(MD.TAG, "GLStateKeeper Restored: 0x"+Integer.toHexString(glsk.hashCode())); + startAnimation(true); } }; @@ -380,12 +381,11 @@ public class NewtBaseActivity extends Activity { } } } - Log.d(MD.TAG, "GLStateKeeper.Preserving: Total "+glAutoDrawables.size()+", OK "+ok+", Fail "+fail); + Log.d(MD.TAG, "GLStateKeeper.Mark2Preserve: Total "+glAutoDrawables.size()+", OK "+ok+", Fail "+fail); } for(int i=0; i Date: Sun, 24 Mar 2013 05:08:30 +0100 Subject: NEWT/MouseEvent: Refine MultiTouch Event Spec regarding associated 'action' pointer Index; Add PointerType[PointerClass]; Add 'wheelScale' Attribute; - Refine MultiTouch Event Spec regarding associated 'action' pointer Index In case an instance represents multi-touch events, i.e. {@link #getPointerCount()} is > 1, the first data element represents the pointer which triggered the action if individual to one pointer. For example {@link #getX(int) e.getX(0)} at {@link #EVENT_MOUSE_PRESSED} returns the data of the pressed pointer, etc. - Add PointerType[PointerClass] This allows applications to identify the type and it's class [On-/Offscreen] helping to interpret semantics, e.g. wheel-rotate and new wheel-scale - Add 'wheelScale' Attribute Returns the scale used to determine the {@link #getWheelRotation() wheel rotation}, which semantics depends on the {@link #getPointerType() pointer type's} {@link PointerClass}. See API doc for details .. TODO: NEWT/Android changes adopting these changes. --- .../classes/com/jogamp/newt/event/MouseEvent.java | 97 ++++++++++++++++++---- 1 file changed, 82 insertions(+), 15 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 8ad1f3f24..87a9eeb7c 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -34,9 +34,34 @@ package com.jogamp.newt.event; +/** + * Pointer event of type {@link PointerType}. + *

    + * In case an instance represents multi-touch events, i.e. {@link #getPointerCount()} is > 1, + * the first data element represents the pointer which triggered the action if individual to one pointer.
    + * For example {@link #getX(int) e.getX(0)} at {@link #EVENT_MOUSE_PRESSED} returns the data of the pressed pointer, etc. + *

    + */ @SuppressWarnings("serial") public class MouseEvent extends InputEvent { + /** Class of pointer types */ + public static enum PointerClass{ + Offscreen, Onscreen, Undefined; + } + + /** Type of pointer devices */ + public static enum PointerType{ + Mouse(PointerClass.Offscreen), Pen(PointerClass.Onscreen), Touch(PointerClass.Onscreen), Undefined(PointerClass.Undefined); + + public PointerClass getPointerClass() { return pc; } + + private PointerType(PointerClass pc) { + this.pc = pc; + } + PointerClass pc; + } + /** ID for button 1, value 1 */ public static final short BUTTON1 = 1; /** ID for button 2, value 2 */ @@ -62,7 +87,8 @@ public class MouseEvent extends InputEvent public static final short getClickTimeout() { return 300; } - + + /** Constructor for tradition 1-pointer mouse events. */ public MouseEvent(short eventType, Object source, long when, int modifiers, int x, int y, short clickCount, short button, float rotation) @@ -70,17 +96,20 @@ public class MouseEvent extends InputEvent super(eventType, source, when, modifiers); this.x = new int[]{x}; this.y = new int[]{y}; - this.pressure = new float[]{0f}; + this.pressure = constMousePressure; this.maxPressure= 1.0f; - this.pointerids = new short[]{-1}; + this.pointerIDs = constMousePointerIDs; this.clickCount=clickCount; this.button=button; this.wheelRotation = rotation; + this.wheelScale = 1f; + this.pointerTypes = constMousePointerTypes; } + /** Constructor for multi-touch pointer events. */ public MouseEvent(short eventType, Object source, long when, - int modifiers, int[] x, int[] y, float[] pressure, float maxPressure, short[] pointerids, short clickCount, - short button, float rotation) + int modifiers, int[] x, int[] y, float[] pressure, float maxPressure, PointerType pointerTypes[], short[] pointerids, short clickCount, + short button, float rotation, float rotationScale) { super(eventType, source, when, modifiers); this.x = x; @@ -95,10 +124,12 @@ public class MouseEvent extends InputEvent } this.pressure = pressure; this.maxPressure= maxPressure; - this.pointerids = pointerids; + this.pointerIDs = pointerids; this.clickCount=clickCount; this.button=button; this.wheelRotation = rotation; + this.wheelScale = rotationScale; + this.pointerTypes = pointerTypes; } /** @@ -108,14 +139,26 @@ public class MouseEvent extends InputEvent return x.length; } + /** + * @return the {@link PointerType} for the data at index. + * return null if index not available. + */ + public PointerType getPointerType(int index) { + if(index >= pointerIDs.length) { + return null; + } + return pointerTypes[index]; + } + /** * @return the pointer id for the data at index. * return -1 if index not available. */ public short getPointerId(int index) { - if(index >= pointerids.length) + if(index >= pointerIDs.length) { return -1; - return pointerids[index]; + } + return pointerIDs[index]; } public short getButton() { @@ -216,6 +259,23 @@ public class MouseEvent extends InputEvent return wheelRotation; } + /** + * Returns the scale used to determine the {@link #getWheelRotation() wheel rotation}, + * which semantics depends on the {@link #getPointerType() pointer type's} {@link PointerClass}. + *

    + * For {@link PointerClass#Offscreen}, the scale is always 1.0f and denominates + * an abstract value without association to a physical value. + *

    + *

    + * For {@link PointerClass#Onscreen}, the scale varies and denominates + * the divisor of the distance the finger[s] have moved on the screen. + * Hence scale * rotation reproduces the screen distance in pixels the finger[s] have moved. + *

    + */ + public float getWheelScale() { + return wheelScale; + } + public String toString() { return toString(null).toString(); } @@ -227,14 +287,14 @@ public class MouseEvent extends InputEvent sb.append("MouseEvent[").append(getEventTypeString(getEventType())) .append(", ").append(x).append("/").append(y) .append(", button ").append(button).append(", count ") - .append(clickCount).append(", wheel rotation ").append(wheelRotation); - if(pointerids.length>0) { - sb.append(", pointer<").append(pointerids.length).append(">["); - for(int i=0; i0) { + sb.append(", pointer<").append(pointerIDs.length).append(">["); + for(int i=0; i0) { sb.append(", "); } - sb.append(pointerids[i]).append(": ") + sb.append(pointerIDs[i]).append("/").append(pointerTypes[i]).append(": ") .append(x[i]).append("/").append(y[i]).append(", ") .append("p[").append(pressure[i]).append("/").append(maxPressure).append("=").append(pressure[i]/maxPressure).append("]"); } @@ -257,12 +317,19 @@ public class MouseEvent extends InputEvent default: return "unknown (" + type + ")"; } } - private final int x[], y[];; + private final int x[], y[]; + // private final short tiltX[], tiltY[]; // TODO: A generic way for pointer axis information, see Android MotionEvent! private final short clickCount, button; private final float wheelRotation; + private final float wheelScale; private final float pressure[]; private final float maxPressure; - private final short pointerids[]; + private final short pointerIDs[]; + private final PointerType pointerTypes[]; + + private static final float[] constMousePressure = new float[]{0f}; + private static final short[] constMousePointerIDs = new short[]{0}; + private static final PointerType[] constMousePointerTypes = new PointerType[] { PointerType.Mouse }; public static final short EVENT_MOUSE_CLICKED = 200; public static final short EVENT_MOUSE_ENTERED = 201; -- cgit v1.2.3 From 654a678bd7171e81ec947cafa854dad366f5041e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 24 Mar 2013 05:18:34 +0100 Subject: Android/NEWT MouseEvent: Fix Delivery of MultiTouch PRESSED/RELEASE; Fix Detection/Processing of 2-Finger-Scroll Gesture ; GearsES2: Add NEWT based 'zoom' gesture detection. - Fix Delivery of MultiTouch PRESSED/RELEASE Adopting MouseEvent changes of commit 18cb57246372eda72c25a5cd9a69a873bdf09489 - Fix Detection/Processing of 2-Finger-Scroll Gesture Dropping utilization of Android's GestureDetector and implementing our own, which turns out to simplify keeping track of states. Our gesture detection works well w/ user NEWT based gesture detection (-> See GearsES2 zoom and rotate), using following criteria related to Android parameter: - ScaledDoubleTapSlop: - Max 2 finger distance - ScaledTouchSlop: - Min. movement w/ 2 pointer withing ScaledDoubleTapSlop starting 'scroll' mode - Max. change of finger distance in respect to initiating 2-finger distance (2x ScaledTouchSlop) - Max. distance growth in respect to initiating 2-finger distance. - GearsES2: Add NEWT based 'zoom' gesture detection. --- .../android/event/AndroidNewtEventFactory.java | 340 ++++++++++++--------- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 137 +++++++-- 2 files changed, 305 insertions(+), 172 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 5d2333c1f..83d3e7d90 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -28,20 +28,33 @@ package jogamp.newt.driver.android.event; +import jogamp.newt.Debug; +import android.view.MotionEvent; + import com.jogamp.common.os.AndroidVersion; -import com.jogamp.newt.Window; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.NEWTEvent; public class AndroidNewtEventFactory { - - private static final String names[] = { "DOWN" , "UP" , "MOVE", "CANCEL" , "OUTSIDE", // 0 - 4 - "POINTER_DOWN" , "POINTER_UP" , "HOVER_MOVE" , "SCROLL", // 5 - 8 - "HOVER_ENTER", "HOVER_EXIT" // 0 - 10 - }; + private static final boolean DEBUG_MOUSE_EVENT = Debug.debug("Android.MouseEvent"); + private static final boolean DEBUG_KEY_EVENT = Debug.debug("Android.KeyEvent"); /** API Level 12: {@link android.view.MotionEvent#ACTION_SCROLL} = {@value} */ private static final int ACTION_SCROLL = 8; + + private static final com.jogamp.newt.event.MouseEvent.PointerType aToolType2PointerType(int aToolType) { + switch( aToolType ) { + case MotionEvent.TOOL_TYPE_FINGER: + return com.jogamp.newt.event.MouseEvent.PointerType.Touch; + case MotionEvent.TOOL_TYPE_MOUSE: + return com.jogamp.newt.event.MouseEvent.PointerType.Mouse; + case MotionEvent.TOOL_TYPE_STYLUS: + case MotionEvent.TOOL_TYPE_ERASER: + return com.jogamp.newt.event.MouseEvent.PointerType.Pen; + default: + return com.jogamp.newt.event.MouseEvent.PointerType.Undefined; + } + } private static final short aMotionEventType2Newt(int aType) { switch( aType ) { @@ -174,7 +187,7 @@ public class AndroidNewtEventFactory { } else { res = null; } - if(Window.DEBUG_KEY_EVENT) { + if(DEBUG_KEY_EVENT) { System.err.println("createKeyEvent0: "+aEvent+" -> "+res); } return res; @@ -183,7 +196,7 @@ public class AndroidNewtEventFactory { public static com.jogamp.newt.event.KeyEvent createKeyEvent(android.view.KeyEvent aEvent, short newtType, com.jogamp.newt.Window newtSource, boolean inclSysKeys) { final short newtKeyCode = aKeyCode2NewtKeyCode(aEvent.getKeyCode(), inclSysKeys); final com.jogamp.newt.event.KeyEvent res = createKeyEventImpl(aEvent, newtType, newtKeyCode, newtSource); - if(Window.DEBUG_KEY_EVENT) { + if(DEBUG_KEY_EVENT) { System.err.println("createKeyEvent1: newtType "+NEWTEvent.toHexString(newtType)+", "+aEvent+" -> "+res); } return res; @@ -191,7 +204,7 @@ public class AndroidNewtEventFactory { public static com.jogamp.newt.event.KeyEvent createKeyEvent(android.view.KeyEvent aEvent, short newtKeyCode, short newtType, com.jogamp.newt.Window newtSource) { final com.jogamp.newt.event.KeyEvent res = createKeyEventImpl(aEvent, newtType, newtKeyCode, newtSource); - if(Window.DEBUG_KEY_EVENT) { + if(DEBUG_KEY_EVENT) { System.err.println("createKeyEvent2: newtType "+NEWTEvent.toHexString(newtType)+", "+aEvent+" -> "+res); } return res; @@ -231,24 +244,39 @@ public class AndroidNewtEventFactory { return maxPressure; } - private final NewtGestureListener gestureListener; - private final android.view.GestureDetector gestureDetector; - private final float touchSlop; + private final int touchSlop, touchSlop2x, touchSlopSquare, doubleTapSlop, doubleTapSlopSquare; public AndroidNewtEventFactory(android.content.Context context, android.os.Handler handler) { - gestureListener = new NewtGestureListener(); - gestureDetector = new android.view.GestureDetector(context, gestureListener, handler, false /* ignoreMultitouch */); - gestureDetector.setIsLongpressEnabled(false); // favor scroll event! final android.view.ViewConfiguration configuration = android.view.ViewConfiguration.get(context); touchSlop = configuration.getScaledTouchSlop(); + touchSlop2x = 2*touchSlop; + touchSlopSquare = touchSlop * touchSlop; + doubleTapSlop = configuration.getScaledDoubleTapSlop(); + doubleTapSlopSquare = doubleTapSlop * doubleTapSlop; + if(DEBUG_MOUSE_EVENT) { + System.err.println("GestureListener touchSlop (scaled) "+touchSlop); + System.err.println("GestureListener doubleTapSlop (scaled) "+doubleTapSlop); + } } - - private int gestureScrollPointerDown = 0; - + + private static void collectPointerData(MotionEvent e, int eIdx, int dIdx, final int[] x, final int[] y, final float[] pressure, short[] pointerIds, final com.jogamp.newt.event.MouseEvent.PointerType[] pointerTypes) { + x[dIdx] = (int)e.getX(eIdx); + y[dIdx] = (int)e.getY(eIdx); + pressure[dIdx] = e.getPressure(eIdx); + pointerIds[dIdx] = (short)e.getPointerId(eIdx); + if( pressure[dIdx] > maxPressure ) { + maxPressure = pressure[dIdx]; + } + pointerTypes[dIdx] = aToolType2PointerType( e.getToolType(eIdx) ); + if(DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: ptr-data["+eIdx+" -> "+dIdx+"] "+x[dIdx]+"/"+y[dIdx]+", pressure "+pressure[dIdx]+", id "+pointerIds[dIdx]+", type "+pointerTypes[dIdx]); + } + } + public com.jogamp.newt.event.MouseEvent[] createMouseEvents(boolean isOnTouchEvent, android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { - if(Window.DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: "+toString(event)); + if(DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: isOnTouchEvent "+isOnTouchEvent+", "+event); } if( event.getPressure() > maxPressure ) { @@ -261,49 +289,38 @@ public class AndroidNewtEventFactory { final int aType; final short nType; float[] rotationXY = null; - int rotationSource = 0; // 1 - Gesture, 2 - ACTION_SCROLL - { - final int pointerCount = event.getPointerCount(); - final boolean gestureEvent = isOnTouchEvent && pointerCount>1 && gestureDetector.onTouchEvent(event); - int _aType = 0xFFFFFFFF; - if( gestureEvent ) { - rotationXY = gestureListener.getScrollDistanceXY(); - if( null != rotationXY) { - final boolean skip = 0 == gestureScrollPointerDown; // skip 1st .. too bug distance - gestureScrollPointerDown = pointerCount; - if( skip ) { - if(Window.DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: GestureEvent Scroll Start - SKIP "+rotationXY[0]+"/"+rotationXY[1]+", gestureScrollPointerDown "+gestureScrollPointerDown); - } - return null; - } - _aType = ACTION_SCROLL; // 8 - rotationSource = 1; - } else { - throw new InternalError("Gesture Internal Error: consumed onTouchEvent, but no result (Scroll)"); + int rotationSource = 0; // 1 - Gesture, 2 - ACTION_SCROLL + { + final int aType0 = event.getActionMasked(); + if( isOnTouchEvent ) { + boolean action = false; + switch ( aType0 ) { + case MotionEvent.ACTION_DOWN: + action = true; + // fall through intended + case MotionEvent.ACTION_POINTER_DOWN: + gesture2FingerScrl.onDown(event, action); + break; + case MotionEvent.ACTION_UP: + action = true; + // fall through intended + case MotionEvent.ACTION_POINTER_UP: + gesture2FingerScrl.onUp(event, action); + break; + case MotionEvent.ACTION_MOVE: + gesture2FingerScrl.onActionMove(event); + break; } } - if( 0xFFFFFFFF == _aType ) { - _aType = event.getActionMasked(); - } - aType = _aType; - nType = aMotionEventType2Newt(aType); - - // - // Check whether events shall be skipped - // - if( !gestureEvent ) { - // Scroll Gesture: Wait for all pointers up - ACTION_UP, ACTION_POINTER_UP - if( 0 < gestureScrollPointerDown ) { - if( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED == nType ) { - gestureScrollPointerDown--; - } - if(Window.DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: !GestureEvent SKIP gestureScrollPointerDown "+gestureScrollPointerDown); - } - return null; - } + + if( gesture2FingerScrl.isWithinGesture() ) { + rotationXY = gesture2FingerScrl.getScrollDistanceXY(); + aType = ACTION_SCROLL; // 8 + rotationSource = 1; + } else { + aType = aType0; } + nType = aMotionEventType2Newt(aType); } if( (short)0 != nType ) { @@ -317,6 +334,7 @@ public class AndroidNewtEventFactory { } final float rotation; + final float rotationScale = touchSlop; if( null != rotationXY ) { final float _rotation; if( rotationXY[0]*rotationXY[0] > rotationXY[1]*rotationXY[1] ) { @@ -327,9 +345,9 @@ public class AndroidNewtEventFactory { // Vertical _rotation = rotationXY[1]; } - rotation = _rotation / touchSlop; - if(Window.DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: Scroll "+rotationXY[0]+"/"+rotationXY[1]+" -> "+_rotation+" / "+touchSlop+" -> "+rotation+" scaled -- mods "+modifiers+", source "+rotationSource); + rotation = _rotation / rotationScale; + if(DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: Scroll "+rotationXY[0]+"/"+rotationXY[1]+" -> "+_rotation+" / "+rotationScale+" -> "+rotation+" scaled -- mods "+modifiers+", source "+rotationSource); } } else { rotation = 0.0f; @@ -338,14 +356,12 @@ public class AndroidNewtEventFactory { // // Determine newt-button and whether dedicated pointer is pressed // - final int pCount; final int pIndex; final short button; switch( aType ) { case android.view.MotionEvent.ACTION_POINTER_DOWN: case android.view.MotionEvent.ACTION_POINTER_UP: { pIndex = event.getActionIndex(); - pCount = 1; final int b = event.getPointerId(pIndex) + 1; // FIXME: Assumption that Pointer-ID starts w/ 0 ! if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { button = (short)b; @@ -356,10 +372,10 @@ public class AndroidNewtEventFactory { break; default: { pIndex = 0; - pCount = event.getPointerCount(); // all button = com.jogamp.newt.event.MouseEvent.BUTTON1; } } + final int pCount = event.getPointerCount(); // all // // Collect common data @@ -368,25 +384,18 @@ public class AndroidNewtEventFactory { final int[] y = new int[pCount]; final float[] pressure = new float[pCount]; final short[] pointerIds = new short[pCount]; - { - if(Window.DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: collect ptr-data ["+pIndex+".."+(pIndex+pCount-1)+", "+pCount+"], aType "+aType+", button "+button+", gestureScrollPointerDown "+gestureScrollPointerDown); + final com.jogamp.newt.event.MouseEvent.PointerType[] pointerTypes = new com.jogamp.newt.event.MouseEvent.PointerType[pCount]; + if( 0 < pCount ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: collect ptr-data [0.."+(pCount-1)+", count "+pCount+", action "+pIndex+"], aType "+aType+", button "+button+", twoFingerScrollGesture "+gesture2FingerScrl); } - int i = pIndex; - int j = 0; - while(j < pCount) { - x[j] = (int)event.getX(i); - y[j] = (int)event.getY(i); - pressure[j] = event.getPressure(i); - pointerIds[j] = (short)event.getPointerId(i); - if( pressure[j] > maxPressure ) { - maxPressure = pressure[j]; - } - if(Window.DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: ptr-data["+i+" -> "+j+"] "+x[j]+"/"+y[j]+", pressure "+pressure[j]+", id "+pointerIds[j]); + int j = 0; + // Always put action-pointer data at index 0 + collectPointerData(event, pIndex, j++, x, y, pressure, pointerIds, pointerTypes); + for(int i=0; i < pCount; i++) { + if( pIndex != i ) { + collectPointerData(event, i, j++, x, y, pressure, pointerIds, pointerTypes); } - i++; - j++; } } @@ -404,97 +413,136 @@ public class AndroidNewtEventFactory { final com.jogamp.newt.event.MouseEvent me1 = new com.jogamp.newt.event.MouseEvent( nType, src, unixTime, - modifiers, x, y, pressure, maxPressure, pointerIds, - clickCount, button, rotation); + modifiers, x, y, pressure, maxPressure, pointerTypes, pointerIds, + clickCount, button, rotation, rotationScale); if( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED == nType ) { return new com.jogamp.newt.event.MouseEvent[] { me1, new com.jogamp.newt.event.MouseEvent( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED, - src, unixTime, modifiers, x, y, pressure, maxPressure, pointerIds, - clickCount, button, rotation) }; + src, unixTime, modifiers, x, y, pressure, maxPressure, pointerTypes, pointerIds, + clickCount, button, rotation, rotationScale) }; } else { return new com.jogamp.newt.event.MouseEvent[] { me1 }; } } return null; // no mapping .. } - - - public static String toString(android.view.MotionEvent event) { - StringBuilder sb = new StringBuilder(); - int action = event.getAction(); - int actionCode = action & android.view.MotionEvent.ACTION_MASK; - sb.append("ACTION_" ).append(names[actionCode]); - if (actionCode == android.view.MotionEvent.ACTION_POINTER_DOWN - || actionCode == android.view.MotionEvent.ACTION_POINTER_UP) { - sb.append("(pid " ).append( - action >> android.view.MotionEvent.ACTION_POINTER_ID_SHIFT); - sb.append(")" ); - } - sb.append("[" ); - for (int i = 0; i < event.getPointerCount(); i++) { - sb.append("#" ).append(i); - sb.append("(pid " ).append(event.getPointerId(i)); - sb.append(")=" ).append((int) event.getX(i)); - sb.append("," ).append((int) event.getY(i)); - if (i + 1 < event.getPointerCount()) - sb.append(";" ); - } - sb.append("]" ); - return sb.toString(); + + static interface GestureHandler { + /** Returns true if within the gesture */ + public boolean isWithinGesture(); + /** Returns distance of the last consecutive double-tab scrolling. */ + public float[] getScrollDistanceXY(); + + public void onUp(android.view.MotionEvent e, boolean action); + public void onDown(android.view.MotionEvent e, boolean action); + public void onActionMove(android.view.MotionEvent e); } - class NewtGestureListener implements android.view.GestureDetector.OnGestureListener { - private float[] scrollDistance; + /** + * Criteria related to Android parameter: + * - ScaledDoubleTapSlop: + * - Max 2 finger distance + * + * - ScaledTouchSlop: + * - Min. movement w/ 2 pointer withing ScaledDoubleTapSlop starting 'scroll' mode + * - Max. change of finger distance in respect to initiating 2-finger distance (2x ScaledTouchSlop) + * - Max. distance growth in respect to initiating 2-finger distance. + */ + private final GestureHandler gesture2FingerScrl = new GestureHandler() { + private final float[] scrollDistance = new float[] { 0f, 0f }; + private int dStartDist = 0; + private float dDownY = 0; + private float dDownX = 0; + private float dLastY = 0; + private float dLastX = 0; + private int pointerDownCount = 0; + private boolean dDownScroll = false; - NewtGestureListener() { - scrollDistance = null; + public String toString() { + return "Gesture2FingerScrl[in "+dDownScroll+", pc "+pointerDownCount+"]"; } - /** Returns non null w/ 2 float values, XY, if storing onScroll's XY distance - otherwise null */ - public float[] getScrollDistanceXY() { - float[] sd = scrollDistance; - scrollDistance = null; - return sd; + private final int getSquareDistance(float x1, float y1, float x2, float y2) { + final int deltaX = (int) x1 - (int) x2; + final int deltaY = (int) y1 - (int) y2; + return deltaX * deltaX + deltaY * deltaY; } - // - // Simple feedback - // - - @Override - public void onShowPress(android.view.MotionEvent e) { + public boolean isWithinGesture() { + return dDownScroll; } - @Override - public void onLongPress(android.view.MotionEvent e) { + public final float[] getScrollDistanceXY() { + return scrollDistance; } - + @Override - public boolean onSingleTapUp(android.view.MotionEvent e) { - return false; + public void onDown(android.view.MotionEvent e, boolean action) { + pointerDownCount = e.getPointerCount(); + if( 2 == pointerDownCount ) { + final int sqDist = getSquareDistance(e.getX(0), e.getY(0), e.getX(1), e.getY(1)); + final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; + if(DEBUG_MOUSE_EVENT) { + System.err.println(this+".onDown: action "+action+", dist "+Math.sqrt(sqDist)+", distWithin2DTSlop "+isDistWithinDoubleTapSlop+", "+e); + } + if( isDistWithinDoubleTapSlop ) { + dDownX = e.getX(); + dDownY = e.getY(); + dLastX = dDownX; + dLastY = dDownY; + dStartDist = (int)Math.sqrt(sqDist); + } + } } - // - // Consumed or not consumed ! - // - @Override - public boolean onDown(android.view.MotionEvent e) { - return false; + public void onUp(android.view.MotionEvent e, boolean action) { + pointerDownCount = e.getPointerCount(); + if(DEBUG_MOUSE_EVENT) { + System.err.println(this+".onrUp: action "+action+", "+e); + } + if( 2 >= pointerDownCount ) { + dDownScroll = false; + } + pointerDownCount--; // lifted now! + if(!dDownScroll) { + dDownY = 0f; + dDownX = 0f; + dLastY = 0f; + dLastX = 0f; + } } - + @Override - public boolean onScroll(android.view.MotionEvent e1, android.view.MotionEvent e2, float distanceX, float distanceY) { - scrollDistance = new float[] { distanceX, distanceY }; - return true; + public void onActionMove(android.view.MotionEvent e) { + pointerDownCount = e.getPointerCount(); + if( 2 <= pointerDownCount ) { + final int sqDist = getSquareDistance(e.getX(0), e.getY(0), e.getX(1), e.getY(1)); + final int dist = (int)Math.sqrt(sqDist); + final float x = e.getX(); + final float y = e.getY(); + final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; + final boolean isDistDeltaWithinTouchSlop = Math.abs( dStartDist - dist ) <= touchSlop2x && + dist - dStartDist <= touchSlop; + if( !isDistWithinDoubleTapSlop || !isDistDeltaWithinTouchSlop ) { + dDownScroll = false; + } else if( !dDownScroll ) { + final int dX = (int) (x - dDownX); + final int dY = (int) (y - dDownY); + final int d = (dX * dX) + (dY * dY); + dDownScroll = d > touchSlopSquare; + } + scrollDistance[0] = dLastX - x; + scrollDistance[1] = dLastY - y; + dLastX = x; + dLastY = y; + if(DEBUG_MOUSE_EVENT) { + System.err.println(this+".onActionMove: startDist "+dStartDist+", dist "+dist+", distWithin2DTSlop "+isDistWithinDoubleTapSlop+", distDeltaWithinTSlop "+isDistDeltaWithinTouchSlop+", d "+scrollDistance[0]+"/"+scrollDistance[1]+", "+e); + } + } } - - @Override - public boolean onFling(android.view.MotionEvent e1, android.view.MotionEvent e2, float velocityX, float velocityY) { - return false; - } }; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 99df7c102..c239a949b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -54,7 +54,8 @@ public class GearsES2 implements GLEventListener { private GLUniformData pmvMatrixUniform = null; private GLUniformData colorU = null; private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; - private float panX = 0.0f, panY = 0.0f; + private float panX = 0.0f, panY = 0.0f, panZ=0.0f; + private int drawableHeight = 1; private GearsObjectES2 gear1=null, gear2=null, gear3=null; private float angle = 0.0f; private int swapInterval = 0; @@ -63,7 +64,6 @@ public class GearsES2 implements GLEventListener { public MouseListener gearsMouse = new GearsMouseAdapter(); public KeyListener gearsKeys = new GearsKeyAdapter(); - private int prevMouseX, prevMouseY; private boolean doRotate = true; private boolean ignoreFocus = false; private boolean clearBuffers = true; @@ -210,6 +210,9 @@ public class GearsES2 implements GLEventListener { public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { System.err.println(Thread.currentThread()+" GearsES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); + + drawableHeight = height; + // Thread.dumpStack(); GL2ES2 gl = drawable.getGL().getGL2ES2(); @@ -223,10 +226,10 @@ public class GearsES2 implements GLEventListener { if(height>width) { float h = (float)height / (float)width; - pmvMatrix.glFrustumf(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); + pmvMatrix.glFrustumf(-1.0f, 1.0f, -h, h, 5.0f, 200.0f); } else { float h = (float)width / (float)height; - pmvMatrix.glFrustumf(-h, h, -1.0f, 1.0f, 5.0f, 60.0f); + pmvMatrix.glFrustumf(-h, h, -1.0f, 1.0f, 5.0f, 200.0f); } pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); @@ -302,7 +305,7 @@ public class GearsES2 implements GLEventListener { st.useProgram(gl, true); pmvMatrix.glPushMatrix(); - pmvMatrix.glTranslatef(panX, panY, 0.0f); + pmvMatrix.glTranslatef(panX, panY, panZ); pmvMatrix.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); pmvMatrix.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); pmvMatrix.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); @@ -337,7 +340,71 @@ public class GearsES2 implements GLEventListener { } } + interface GestureHandler { + /** Returns true if within the gesture */ + public boolean isWithinGesture(); + /** Returns true if within the gesture */ + public boolean onReleased(MouseEvent e); + /** Returns true if within the gesture */ + public boolean onDragged(MouseEvent e); + } + final GestureHandler gesture2PtrZoom = new GestureHandler() { + private int zoomLastYDist; + private boolean zoomFirstTouch = true; + private boolean zoomMode = false; + + @Override + public boolean isWithinGesture() { + return zoomMode; + } + + @Override + public boolean onReleased(MouseEvent e) { + if( zoomMode && e.getPointerCount()==1 ) { + zoomFirstTouch = true; + zoomMode = false; + System.err.println("panZ.X: "+e); + } + return zoomMode; + } + + @Override + public boolean onDragged(MouseEvent e) { + if( e.getPointerCount() >=2 ) { + // 2 pointers zoom .. [ -15 .. 15 ], range 30 + /** + // Simple 1:1 Zoom: finger-distance to screen-coord + final int dy = Math.abs(e.getY(0)-e.getY(1)); + float scale = (float)dy / (float)drawableHeight; + panZ = 30f * scale - 15f; + System.err.println("panZ: scale "+scale+" ["+dy+"/"+drawableHeight+"] -> "+panZ); + */ + // Diff. 1:1 Zoom: finger-distance to screen-coord + if(zoomFirstTouch) { + zoomLastYDist = Math.abs(e.getY(0)-e.getY(1)); + zoomFirstTouch=false; + zoomMode = true; + System.err.println("panZ: 1st pinch "+zoomLastYDist+", "+e); + } else if( zoomMode ) { + final int dy = Math.abs(e.getY(0)-e.getY(1)); + final int ddy = dy - zoomLastYDist; + + final float incr = ( (float)ddy / (float)drawableHeight ) * 15.0f; + panZ += incr; + if( e.getPointerCount() > 2 ) { + panZ += incr; + } + System.err.println("panZ.1: ddy "+ddy+", incr "+incr+" ["+dy+"/"+drawableHeight+"], dblZoom "+(e.getPointerCount() > 2)+" -> "+panZ); + + zoomLastYDist = dy; + } + } + return zoomMode; + } + }; + class GearsMouseAdapter implements MouseListener{ + private int prevMouseX, prevMouseY; @Override public void mouseClicked(MouseEvent e) { @@ -353,41 +420,58 @@ public class GearsES2 implements GLEventListener { @Override public void mouseWheelMoved(MouseEvent e) { - float r = e.getWheelRotation() * 1.0f; - if( e.isShiftDown() ) { - // horizontal - panX -= r; // positive -> left + float r = e.getWheelRotation() * 0.5f; + if( e.isControlDown() ) { + // alternative zoom + panZ += r; + if( e.isShiftDown() ) { + panZ += r; + } + System.err.println("panZ.2: incr "+r+", dblZoom "+e.isShiftDown()+" -> "+panZ); } else { - // vertical - panY += r; // positive -> up + // panning + if( e.isShiftDown() ) { + // horizontal + panX -= r; // positive -> left + } else { + // vertical + panY += r; // positive -> up + } } } public void mousePressed(MouseEvent e) { - prevMouseX = e.getX(); - prevMouseY = e.getY(); - Object src = e.getSource(); - if(e.getPressure(true)>0.8f && src instanceof Window) { // show Keyboard - ((Window) src).setKeyboardVisible(true); - } + if( !gesture2PtrZoom.isWithinGesture() && e.getPointerCount()==1 ) { + prevMouseX = e.getX(); + prevMouseY = e.getY(); + Object src = e.getSource(); + if(e.getPressure(true)>0.8f && src instanceof Window) { // show Keyboard + ((Window) src).setKeyboardVisible(true); + } + } } public void mouseReleased(MouseEvent e) { + gesture2PtrZoom.onReleased(e); } - public void mouseMoved(MouseEvent e) { - if(e.isConfined()) { - navigate(e); - } else { - // track prev. position so we don't have 'jumps' - // in case we move to confined navigation. - prevMouseX = e.getX(); - prevMouseY = e.getY(); + public void mouseMoved(MouseEvent e) { + if( !gesture2PtrZoom.isWithinGesture() && e.getPointerCount()==1 ) { + if( e.isConfined() ) { + navigate(e); + } else { + // track prev. position so we don't have 'jumps' + // in case we move to confined navigation. + prevMouseX = e.getX(); + prevMouseY = e.getY(); + } } } public void mouseDragged(MouseEvent e) { - navigate(e); + if( !gesture2PtrZoom.onDragged(e) && e.getPointerCount()==1 ) { + navigate(e); + } } private void navigate(MouseEvent e) { @@ -423,6 +507,7 @@ public class GearsES2 implements GLEventListener { } prevMouseX = x; prevMouseY = y; + System.err.println("rotXY.1: "+view_rotx+"/"+view_roty+", source "+e); } } } -- cgit v1.2.3 From ded080fd890c21b54ba1f96d84f9e355711dc88a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 24 Mar 2013 07:08:42 +0100 Subject: Newt/MouseEvent: Add 'float[3] getRotation()', getWheelScale() -> getRotationScale(), refinement of commit 18cb57246372eda72c25a5cd9a69a873bdf09489 Turns out the 'wheel' semantics are not generic enough and confining rotation values to one axis only satisfies the traditional mouse wheel. Widen the definition of 'rotation' and delivering 3-axis if supported. On NEWT/Android, we deliver the 2-axis for example, allowing to rotate around both or scrolling using both directions (-> GearsES2). --- .../classes/com/jogamp/newt/event/MouseEvent.java | 89 ++++++++++++++++++---- .../com/jogamp/newt/event/MouseListener.java | 15 +++- .../android/event/AndroidNewtEventFactory.java | 35 ++++----- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 19 ++--- 4 files changed, 107 insertions(+), 51 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 87a9eeb7c..a40b0aa18 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -52,7 +52,15 @@ public class MouseEvent extends InputEvent /** Type of pointer devices */ public static enum PointerType{ - Mouse(PointerClass.Offscreen), Pen(PointerClass.Onscreen), Touch(PointerClass.Onscreen), Undefined(PointerClass.Undefined); + /** {@link PointerClass#Offscreen} mouse. */ + Mouse(PointerClass.Offscreen), + /** {@link PointerClass#Offscreen} touch pad, usually using fingers. */ + TouchPad(PointerClass.Offscreen), + /** {@link PointerClass#Onscreen} touch screen, usually using fingers. */ + TouchScreen(PointerClass.Onscreen), + /** {@link PointerClass#Onscreen} pen on screen ?. */ + Pen(PointerClass.Onscreen), + Undefined(PointerClass.Undefined); public PointerClass getPointerClass() { return pc; } @@ -101,15 +109,20 @@ public class MouseEvent extends InputEvent this.pointerIDs = constMousePointerIDs; this.clickCount=clickCount; this.button=button; - this.wheelRotation = rotation; - this.wheelScale = 1f; + this.rotationXYZ = new float[] { 0f, 0f, 0f }; + if( isShiftDown() ) { + this.rotationXYZ[0] = rotation; + } else { + this.rotationXYZ[1] = rotation; + } + this.rotationScale = 1f; this.pointerTypes = constMousePointerTypes; } /** Constructor for multi-touch pointer events. */ public MouseEvent(short eventType, Object source, long when, int modifiers, int[] x, int[] y, float[] pressure, float maxPressure, PointerType pointerTypes[], short[] pointerids, short clickCount, - short button, float rotation, float rotationScale) + short button, float[] rotationXYZ, float rotationScale) { super(eventType, source, when, modifiers); this.x = x; @@ -127,8 +140,8 @@ public class MouseEvent extends InputEvent this.pointerIDs = pointerids; this.clickCount=clickCount; this.button=button; - this.wheelRotation = rotation; - this.wheelScale = rotationScale; + this.rotationXYZ = rotationXYZ; + this.rotationScale = rotationScale; this.pointerTypes = pointerTypes; } @@ -252,18 +265,62 @@ public class MouseEvent extends InputEvent *

    *

    * The button number refers to the wheel number. - *

    - * @return + *

    + * @deprecated Use {@link #getRotation()} */ public float getWheelRotation() { - return wheelRotation; + return isShiftDown() ? rotationXYZ[0] : rotationXYZ[1] ; } + /** + * Returns a 3-component float array filled with the values of the rotational axis + * in the following order: horizontal-, vertical- and z-axis. + *

    + * A vertical rotation of > 0.0f is up and < 0.0f is down. + *

    + *

    + * A horizontal rotation of > 0.0f is left and < 0.0f is right. + *

    + *

    + * A z-axis rotation of > 0.0f is back and < 0.0f is front. + *

    + *

    + * However, on some OS this might be flipped due to the OS default behavior. + * The latter is true for OS X 10.7 (Lion) for example. + *

    + *

    + * On PointerClass {@link PointerClass#Onscreen onscreen} devices, i.e. {@link PointerType#TouchScreen touch screens}, + * rotation events are usually produced by a 2-finger movement, where horizontal and vertical rotation values are filled. + *

    + *

    + * On PointerClass {@link PointerClass#Offscreen offscreen} devices, i.e. {@link PointerType#Mouse mouse}, + * either the horizontal or the vertical rotation value is filled. + *

    + *

    + * The {@link InputEvent#SHIFT_MASK} modifier is set in case |horizontal| > |vertical| value.
    + * This can be utilized to implement only one 2d rotation direction, you may use {@link #isShiftDown()} to query it. + *

    + *

    + * In case the pointer type is {@link PointerType#Mouse mouse}, + * events are usually send in steps of one, ie. -1.0f and 1.0f. + * Higher values may result due to fast scrolling. + * Fractional values may result due to slow scrolling with high resolution devices.
    + * Here the button number refers to the wheel number. + *

    + *

    + * In case the pointer type is of class {@link PointerClass#Onscreen}, e.g. {@link PointerType#TouchScreen touch screen}, + * see {@link #getRotationScale()} for semantics. + *

    + */ + public float[] getRotation() { + return rotationXYZ; + } + /** - * Returns the scale used to determine the {@link #getWheelRotation() wheel rotation}, + * Returns the scale used to determine the {@link #getRotation() rotation value}, * which semantics depends on the {@link #getPointerType() pointer type's} {@link PointerClass}. *

    - * For {@link PointerClass#Offscreen}, the scale is always 1.0f and denominates + * For {@link PointerClass#Offscreen}, the scale is usually 1.0f and denominates * an abstract value without association to a physical value. *

    *

    @@ -272,8 +329,8 @@ public class MouseEvent extends InputEvent * Hence scale * rotation reproduces the screen distance in pixels the finger[s] have moved. *

    */ - public float getWheelScale() { - return wheelScale; + public float getRotationScale() { + return rotationScale; } public String toString() { @@ -287,7 +344,7 @@ public class MouseEvent extends InputEvent sb.append("MouseEvent[").append(getEventTypeString(getEventType())) .append(", ").append(x).append("/").append(y) .append(", button ").append(button).append(", count ") - .append(clickCount).append(", wheel rotation ").append(wheelRotation).append(" * ").append(wheelScale); + .append(clickCount).append(", rotation [").append(rotationXYZ[0]).append(", ").append(rotationXYZ[1]).append(", ").append(rotationXYZ[2]).append("] * ").append(rotationScale); if(pointerIDs.length>0) { sb.append(", pointer<").append(pointerIDs.length).append(">["); for(int i=0; i + * Triggered for any rotational pointer events, see + * {@link MouseEvent#getRotation()} and {@link MouseEvent#getRotationScale()}. + *

    + */ public void mouseWheelMoved(MouseEvent e); } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 83d3e7d90..21f552fdb 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -45,7 +45,7 @@ public class AndroidNewtEventFactory { private static final com.jogamp.newt.event.MouseEvent.PointerType aToolType2PointerType(int aToolType) { switch( aToolType ) { case MotionEvent.TOOL_TYPE_FINGER: - return com.jogamp.newt.event.MouseEvent.PointerType.Touch; + return com.jogamp.newt.event.MouseEvent.PointerType.TouchScreen; case MotionEvent.TOOL_TYPE_MOUSE: return com.jogamp.newt.event.MouseEvent.PointerType.Mouse; case MotionEvent.TOOL_TYPE_STYLUS: @@ -288,7 +288,8 @@ public class AndroidNewtEventFactory { // final int aType; final short nType; - float[] rotationXY = null; + final float rotationScale = touchSlop; + final float[] rotationXYZ = new float[] { 0f, 0f, 0f }; int rotationSource = 0; // 1 - Gesture, 2 - ACTION_SCROLL { final int aType0 = event.getActionMasked(); @@ -314,7 +315,9 @@ public class AndroidNewtEventFactory { } if( gesture2FingerScrl.isWithinGesture() ) { - rotationXY = gesture2FingerScrl.getScrollDistanceXY(); + final float[] rot = gesture2FingerScrl.getScrollDistanceXY(); + rotationXYZ[0] = rot[0] / rotationScale; + rotationXYZ[1] = rot[1] / rotationScale; aType = ACTION_SCROLL; // 8 rotationSource = 1; } else { @@ -327,30 +330,20 @@ public class AndroidNewtEventFactory { final short clickCount = 1; int modifiers = 0; - if( null == rotationXY && AndroidVersion.SDK_INT >= 12 && ACTION_SCROLL == aType ) { // API Level 12 - rotationXY = new float[] { event.getAxisValue(android.view.MotionEvent.AXIS_X), - event.getAxisValue(android.view.MotionEvent.AXIS_Y) }; + if( 0 == rotationSource && AndroidVersion.SDK_INT >= 12 && ACTION_SCROLL == aType ) { // API Level 12 + rotationXYZ[0] = event.getAxisValue(android.view.MotionEvent.AXIS_X) / rotationScale; + rotationXYZ[1] = event.getAxisValue(android.view.MotionEvent.AXIS_Y) / rotationScale; rotationSource = 2; } - final float rotation; - final float rotationScale = touchSlop; - if( null != rotationXY ) { - final float _rotation; - if( rotationXY[0]*rotationXY[0] > rotationXY[1]*rotationXY[1] ) { + if( 0 != rotationSource ) { + if( rotationXYZ[0]*rotationXYZ[0] > rotationXYZ[1]*rotationXYZ[1] ) { // Horizontal modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; - _rotation = rotationXY[0]; - } else { - // Vertical - _rotation = rotationXY[1]; } - rotation = _rotation / rotationScale; if(DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: Scroll "+rotationXY[0]+"/"+rotationXY[1]+" -> "+_rotation+" / "+rotationScale+" -> "+rotation+" scaled -- mods "+modifiers+", source "+rotationSource); + System.err.println("createMouseEvent: Scroll "+rotationXYZ[0]+"/"+rotationXYZ[1]+", "+rotationScale+", mods "+modifiers+", source "+rotationSource); } - } else { - rotation = 0.0f; } // @@ -414,14 +407,14 @@ public class AndroidNewtEventFactory { final com.jogamp.newt.event.MouseEvent me1 = new com.jogamp.newt.event.MouseEvent( nType, src, unixTime, modifiers, x, y, pressure, maxPressure, pointerTypes, pointerIds, - clickCount, button, rotation, rotationScale); + clickCount, button, rotationXYZ, rotationScale); if( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED == nType ) { return new com.jogamp.newt.event.MouseEvent[] { me1, new com.jogamp.newt.event.MouseEvent( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED, src, unixTime, modifiers, x, y, pressure, maxPressure, pointerTypes, pointerIds, - clickCount, button, rotation, rotationScale) }; + clickCount, button, rotationXYZ, rotationScale) }; } else { return new com.jogamp.newt.event.MouseEvent[] { me1 }; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index c239a949b..06635f2d5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -420,23 +420,16 @@ public class GearsES2 implements GLEventListener { @Override public void mouseWheelMoved(MouseEvent e) { - float r = e.getWheelRotation() * 0.5f; + float[] rot = e.getRotation(); if( e.isControlDown() ) { // alternative zoom - panZ += r; - if( e.isShiftDown() ) { - panZ += r; - } - System.err.println("panZ.2: incr "+r+", dblZoom "+e.isShiftDown()+" -> "+panZ); + final float incr = e.isShiftDown() ? rot[0] : rot[1] * 0.5f ; + panZ += incr; + System.err.println("panZ.2: incr "+incr+", dblZoom "+e.isShiftDown()+" -> "+panZ); } else { // panning - if( e.isShiftDown() ) { - // horizontal - panX -= r; // positive -> left - } else { - // vertical - panY += r; // positive -> up - } + panX -= rot[0]; // positive -> left + panY += rot[1]; // positive -> up } } -- cgit v1.2.3 From 21cde04129ea241744b95cad8fd0a545d3474b05 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 24 Mar 2013 14:07:11 +0100 Subject: Android/NEWT MouseEvent: Fix Detection/Processing of 2-Finger-Scroll Gesture - Part 2 Multiple tests on different devices disclosed that: - 1 of 2 pointers get disconnected every now and then .. -> Shall tolerate this case - dist-delta within gesture may shrink below doubleTouchSlope -> Remove constraint after gesture detection - Always validate pointer-id GearsES2 - Works quite stable on several devices now - Moved soft-keyboad show to 4-pointer pressed >= 0.7f pressure --- .../android/event/AndroidNewtEventFactory.java | 224 +++++++++++++-------- .../opengl/test/android/MovieCubeActivity0.java | 2 +- .../test/android/NEWTGearsES2ActivityLauncher.java | 1 + .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 15 +- 4 files changed, 154 insertions(+), 88 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 21f552fdb..4c2ed06e8 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -244,12 +244,11 @@ public class AndroidNewtEventFactory { return maxPressure; } - private final int touchSlop, touchSlop2x, touchSlopSquare, doubleTapSlop, doubleTapSlopSquare; + private final int touchSlop, touchSlopSquare, doubleTapSlop, doubleTapSlopSquare; public AndroidNewtEventFactory(android.content.Context context, android.os.Handler handler) { final android.view.ViewConfiguration configuration = android.view.ViewConfiguration.get(context); touchSlop = configuration.getScaledTouchSlop(); - touchSlop2x = 2*touchSlop; touchSlopSquare = touchSlop * touchSlop; doubleTapSlop = configuration.getScaledDoubleTapSlop(); doubleTapSlopSquare = doubleTapSlop * doubleTapSlop; @@ -294,32 +293,31 @@ public class AndroidNewtEventFactory { { final int aType0 = event.getActionMasked(); if( isOnTouchEvent ) { - boolean action = false; switch ( aType0 ) { case MotionEvent.ACTION_DOWN: - action = true; - // fall through intended case MotionEvent.ACTION_POINTER_DOWN: - gesture2FingerScrl.onDown(event, action); + gesture2FingerScrl.onDown(event); break; case MotionEvent.ACTION_UP: - action = true; - // fall through intended case MotionEvent.ACTION_POINTER_UP: - gesture2FingerScrl.onUp(event, action); + gesture2FingerScrl.onUp(event); break; case MotionEvent.ACTION_MOVE: - gesture2FingerScrl.onActionMove(event); + gesture2FingerScrl.onMove(event); break; } } - if( gesture2FingerScrl.isWithinGesture() ) { - final float[] rot = gesture2FingerScrl.getScrollDistanceXY(); - rotationXYZ[0] = rot[0] / rotationScale; - rotationXYZ[1] = rot[1] / rotationScale; - aType = ACTION_SCROLL; // 8 - rotationSource = 1; + if( gesture2FingerScrl.gestureStarted() ) { + if( gesture2FingerScrl.hasGesture(true) ) { + final float[] rot = gesture2FingerScrl.getScrollDistanceXY(); + rotationXYZ[0] = rot[0] / rotationScale; + rotationXYZ[1] = rot[1] / rotationScale; + aType = ACTION_SCROLL; // 8 + rotationSource = 1; + } else { + return new com.jogamp.newt.event.MouseEvent[0]; // skip, but cont. sending events + } } else { aType = aType0; } @@ -342,7 +340,7 @@ public class AndroidNewtEventFactory { modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; } if(DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: Scroll "+rotationXYZ[0]+"/"+rotationXYZ[1]+", "+rotationScale+", mods "+modifiers+", source "+rotationSource); + System.err.println("createMouseEvent: Gesture2FingerScrl Scroll "+rotationXYZ[0]+"/"+rotationXYZ[1]+", "+rotationScale+", mods "+modifiers+", source "+rotationSource); } } @@ -423,38 +421,59 @@ public class AndroidNewtEventFactory { } static interface GestureHandler { - /** Returns true if within the gesture */ - public boolean isWithinGesture(); + /** + * Returns true if last on* command produced a gesture, otherwise false. + * @param clear if true, method clears the gesture flag. + */ + public boolean hasGesture(boolean clear); + /** Returns true if the gesture has started */ + public boolean gestureStarted(); /** Returns distance of the last consecutive double-tab scrolling. */ public float[] getScrollDistanceXY(); - - public void onUp(android.view.MotionEvent e, boolean action); - public void onDown(android.view.MotionEvent e, boolean action); - public void onActionMove(android.view.MotionEvent e); + public void onDown(android.view.MotionEvent e); + public void onUp(android.view.MotionEvent e); + public void onMove(android.view.MotionEvent e); } /** * Criteria related to Android parameter: * - ScaledDoubleTapSlop: - * - Max 2 finger distance + * - Max 2 finger distance to start 'scroll' mode * * - ScaledTouchSlop: * - Min. movement w/ 2 pointer withing ScaledDoubleTapSlop starting 'scroll' mode - * - Max. change of finger distance in respect to initiating 2-finger distance (2x ScaledTouchSlop) - * - Max. distance growth in respect to initiating 2-finger distance. + * - Max. distance growth in respect to initiated 2-finger distance. + * + * - Tolerate temporary lift of 1/2 pointer + * + * - Always validate pointer-id */ private final GestureHandler gesture2FingerScrl = new GestureHandler() { private final float[] scrollDistance = new float[] { 0f, 0f }; - private int dStartDist = 0; - private float dDownY = 0; - private float dDownX = 0; - private float dLastY = 0; - private float dLastX = 0; + private int[] pIds = new int[] { -1, -1 }; + private int startDist = -1; + private float downY = 0; + private float downX = 0; + private float lastY = 0; + private float lastX = 0; private int pointerDownCount = 0; - private boolean dDownScroll = false; + private boolean withinGesture = false; + private boolean hasGesture = false; public String toString() { - return "Gesture2FingerScrl[in "+dDownScroll+", pc "+pointerDownCount+"]"; + return "Gesture2FingerScrl[in "+withinGesture+", has "+hasGesture+", pc "+pointerDownCount+"]"; + } + + private void clear() { + downX = 0f; + downY = 0f; + lastX = 0f; + lastY = 0f; + startDist = -1; + withinGesture = false; + hasGesture = false; + pIds[0] = -1; + pIds[1] = -1; } private final int getSquareDistance(float x1, float y1, float x2, float y2) { @@ -463,76 +482,119 @@ public class AndroidNewtEventFactory { return deltaX * deltaX + deltaY * deltaY; } - public boolean isWithinGesture() { - return dDownScroll; + private int gesturePointers(final android.view.MotionEvent e, final int excludeIndex) { + int j = 0; + for(int i=e.getPointerCount()-1; i>=0; i--) { + if( excludeIndex != i ) { + final int id = e.getPointerId(i); + if( pIds[0] == id || pIds[1] == id ) { + j++; + } + } + } + return j; } + + @Override + public boolean gestureStarted() { + return 0 <= startDist && withinGesture; + } + + @Override + public boolean hasGesture(boolean clear) { + final boolean r = hasGesture; + if( clear ) { + hasGesture = false; + } + return r; + } + @Override public final float[] getScrollDistanceXY() { return scrollDistance; } @Override - public void onDown(android.view.MotionEvent e, boolean action) { + public void onDown(android.view.MotionEvent e) { pointerDownCount = e.getPointerCount(); - if( 2 == pointerDownCount ) { - final int sqDist = getSquareDistance(e.getX(0), e.getY(0), e.getX(1), e.getY(1)); - final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; - if(DEBUG_MOUSE_EVENT) { - System.err.println(this+".onDown: action "+action+", dist "+Math.sqrt(sqDist)+", distWithin2DTSlop "+isDistWithinDoubleTapSlop+", "+e); - } - if( isDistWithinDoubleTapSlop ) { - dDownX = e.getX(); - dDownY = e.getY(); - dLastX = dDownX; - dLastY = dDownY; - dStartDist = (int)Math.sqrt(sqDist); - } + final int gPtr = gesturePointers(e, -1); + if( 2 <= gPtr ) { // pick-up dLast coordinate to cont. gesture after temp loosing 1/2 pointers + lastX = e.getX(0); + lastY = e.getY(0); + } + if(DEBUG_MOUSE_EVENT) { + System.err.println(this+".onDown: gPtr "+gPtr+", "+e); } } @Override - public void onUp(android.view.MotionEvent e, boolean action) { + public void onUp(android.view.MotionEvent e) { pointerDownCount = e.getPointerCount(); - if(DEBUG_MOUSE_EVENT) { - System.err.println(this+".onrUp: action "+action+", "+e); - } - if( 2 >= pointerDownCount ) { - dDownScroll = false; + final int gPtr = gesturePointers(e, e.getActionIndex()); // w/o lifted pointer + if( 1 > gPtr ) { // tolerate lifting 1/2 gesture pointers temporary + clear(); } pointerDownCount--; // lifted now! - if(!dDownScroll) { - dDownY = 0f; - dDownX = 0f; - dLastY = 0f; - dLastX = 0f; + if(DEBUG_MOUSE_EVENT) { + System.err.println(this+".onUp: gPtr "+gPtr+", "+e); } } - + @Override - public void onActionMove(android.view.MotionEvent e) { + public void onMove(android.view.MotionEvent e) { pointerDownCount = e.getPointerCount(); if( 2 <= pointerDownCount ) { - final int sqDist = getSquareDistance(e.getX(0), e.getY(0), e.getX(1), e.getY(1)); - final int dist = (int)Math.sqrt(sqDist); - final float x = e.getX(); - final float y = e.getY(); + final float x0 = e.getX(0); + final float y0 = e.getY(0); + final int sqDist = getSquareDistance(x0, y0, e.getX(1), e.getY(1)); final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; - final boolean isDistDeltaWithinTouchSlop = Math.abs( dStartDist - dist ) <= touchSlop2x && - dist - dStartDist <= touchSlop; - if( !isDistWithinDoubleTapSlop || !isDistDeltaWithinTouchSlop ) { - dDownScroll = false; - } else if( !dDownScroll ) { - final int dX = (int) (x - dDownX); - final int dY = (int) (y - dDownY); - final int d = (dX * dX) + (dY * dY); - dDownScroll = d > touchSlopSquare; + final int dist = (int)Math.sqrt(sqDist); + if( !withinGesture ) { + int gPtr = 0; + if( isDistWithinDoubleTapSlop ) { + if( 0 > startDist ) { + gPtr = 2; + pIds[0] = e.getPointerId(0); + pIds[1] = e.getPointerId(1); + downX = x0; + downY = y0; + lastX = x0; + lastY = y0; + startDist = dist; + } else { + gPtr = gesturePointers(e, -1); + if( 2 <= gPtr ) { + final int dX = (int) (x0 - downX); + final int dY = (int) (y0 - downY); + final int d = (dX * dX) + (dY * dY); + withinGesture = d > touchSlopSquare; + } + } + } + if(DEBUG_MOUSE_EVENT) { + final double dX = x0 - downX; + final double dY = y0 - downY; + final double d = Math.sqrt( (dX * dX) + (dY * dY) ); + System.err.println(this+".onMove.0: mDist "+d+", pStartDist "+dist+", gPtr "+gPtr+", distWithin2DTSlop "+isDistWithinDoubleTapSlop+", dLast "+lastX+"/"+lastY+", "+e); + } } - scrollDistance[0] = dLastX - x; - scrollDistance[1] = dLastY - y; - dLastX = x; - dLastY = y; - if(DEBUG_MOUSE_EVENT) { - System.err.println(this+".onActionMove: startDist "+dStartDist+", dist "+dist+", distWithin2DTSlop "+isDistWithinDoubleTapSlop+", distDeltaWithinTSlop "+isDistDeltaWithinTouchSlop+", d "+scrollDistance[0]+"/"+scrollDistance[1]+", "+e); + if( withinGesture ) { + final int gPtr = gesturePointers(e, -1); + final boolean isDistGrowthWithinTouchSlop = dist - startDist <= touchSlop; + if( 2 > gPtr || !isDistGrowthWithinTouchSlop ) { + clear(); + } else { + scrollDistance[0] = lastX - x0; + scrollDistance[1] = lastY - y0; + lastX = x0; + lastY = y0; + hasGesture = true; + } + if(DEBUG_MOUSE_EVENT) { + System.err.println(this+".onMove.1: pStartDist "+startDist+", pDist "+dist+", gPtr "+gPtr+" ["+pIds[0]+", "+pIds[1]+"]"+ + ", distWithin2DTSlop "+isDistWithinDoubleTapSlop+", distGrowthWithinTSlop "+isDistGrowthWithinTouchSlop+ + ", dLast "+lastX+"/"+lastY+", d "+scrollDistance[0]+"/"+scrollDistance[1]+", "+e); + } } } } diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java index 6aa2a045e..3e61e509c 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java @@ -54,7 +54,7 @@ public class MovieCubeActivity0 extends NewtBaseActivity { MouseAdapter showKeyboardMouseListener = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - if(e.getPressure(true)>0.8f) { + if( e.getPointerCount() == 4 && e.getPressure(true) > 0.7f ) { ((com.jogamp.newt.Window) e.getSource()).setKeyboardVisible(true); } } diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java index 35cf9e7dd..af5b70776 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java @@ -60,6 +60,7 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc props.setProperty("newt.debug.Window", "true"); props.setProperty("newt.debug.Window.MouseEvent", "true"); props.setProperty("newt.debug.Window.KeyEvent", "true"); + // props.setProperty("newt.debug.Android.MouseEvent", "true"); } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 06635f2d5..49f1940dc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -434,12 +434,15 @@ public class GearsES2 implements GLEventListener { } public void mousePressed(MouseEvent e) { - if( !gesture2PtrZoom.isWithinGesture() && e.getPointerCount()==1 ) { - prevMouseX = e.getX(); - prevMouseY = e.getY(); - Object src = e.getSource(); - if(e.getPressure(true)>0.8f && src instanceof Window) { // show Keyboard - ((Window) src).setKeyboardVisible(true); + if( !gesture2PtrZoom.isWithinGesture() ) { + if( e.getPointerCount()==1 ) { + prevMouseX = e.getX(); + prevMouseY = e.getY(); + } else if( e.getPointerCount() == 4 ) { + final Object src = e.getSource(); + if( e.getPressure(true) > 0.7f && src instanceof Window) { // show Keyboard + ((Window) src).setKeyboardVisible(true); + } } } } -- cgit v1.2.3 From 7c397e9915278f529aa38b1f02591b95b9e8c446 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 26 Mar 2013 18:14:13 +0100 Subject: NEWTEvent: Fix toString message - add comma --- src/newt/classes/com/jogamp/newt/event/NEWTEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index 12a2e3dc2..ea96f634f 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -137,7 +137,7 @@ public class NEWTEvent extends java.util.EventObject { if(null == sb) { sb = new StringBuilder(); } - return sb.append("NEWTEvent[source:").append(getSource().getClass().getName()).append("consumed ").append(isConsumed()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); + return sb.append("NEWTEvent[source:").append(getSource().getClass().getName()).append(", consumed ").append(isConsumed()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); } public static String toHexString(short hex) { -- cgit v1.2.3 From a211a2e84e3f69d511a43e8673b6beda779c6a12 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 28 Mar 2013 17:19:24 +0100 Subject: NewtBaseActivity: Perform cleanup() even on onCreate() due to possible call w/ initialized states (App process is killed for memory exhaustion etc) .. even though I was not able to reproduce this case, it will not harm. --- .../newt/driver/android/NewtBaseActivity.java | 65 ++++++++++++++++++---- 1 file changed, 55 insertions(+), 10 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index ab8fc8ad0..3716e3569 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -327,32 +327,40 @@ public class NewtBaseActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { - Log.d(MD.TAG, "onCreate"); + Log.d(MD.TAG, "onCreate.0"); if(!isDelegatedActivity()) { super.onCreate(savedInstanceState); } + // Extraordinary cleanup, for cases of 'onCreate()' calls w/ valid states, + // i.e. w/o having onDestroy() being called. + // Could happened due to spec when App process is killed for memory exhaustion or other reasons. + cleanup(); + jogamp.common.os.android.StaticContext.init(rootActivity.getApplicationContext()); + Log.d(MD.TAG, "onCreate.X"); } @Override public void onStart() { - Log.d(MD.TAG, "onStart"); + Log.d(MD.TAG, "onStart.0"); if(!isDelegatedActivity()) { super.onStart(); } + Log.d(MD.TAG, "onStart.X"); } @Override public void onRestart() { - Log.d(MD.TAG, "onRestart"); + Log.d(MD.TAG, "onRestart.0"); if(!isDelegatedActivity()) { super.onRestart(); } + Log.d(MD.TAG, "onRestart.X"); } @Override public void onResume() { - Log.d(MD.TAG, "onResume"); + Log.d(MD.TAG, "onResume.0"); if(!isDelegatedActivity()) { super.onResume(); } @@ -364,11 +372,12 @@ public class NewtBaseActivity extends Activity { } } startAnimation(true); + Log.d(MD.TAG, "onResume.X"); } @Override public void onPause() { - Log.d(MD.TAG, "onPause"); + Log.d(MD.TAG, "onPause.0"); if( !getActivity().isFinishing() ) { int ok=0, fail=0; for(int i=0; i + * Cleaning and destroying up all preserved GLEventListenerState + * and clearing the preserve-flag of all GLStateKeeper. + *

    + *

    + * Destroying all GLWindow. + *

    + */ + private void cleanup() { + Log.d(MD.TAG, "cleanup.0"); + int glelsKilled = 0, glelsClean = 0; + for(int i=0; i Date: Thu, 28 Mar 2013 23:24:39 +0100 Subject: Adapt to new version scheme, see GlueGen a3f2ef50ad33c58a240a17fcf03e415d772207c3, etc; Fix NewtVersion, NativeWindowVersion and NewtVersionActivityLauncher NewtVersion, NativeWindowVersion: Also search for extension javax.media.opengl (all packaging) NewtVersionActivityLauncher: Use new launcher URI --- make/build-common.xml | 11 +---- make/build-jogl.xml | 9 +++-- make/build-nativewindow.xml | 9 +++-- make/build-newt.xml | 9 +++-- make/build-test.xml | 14 ++++--- make/build.xml | 13 +++--- make/joglversion | 1 + make/joglversion-test | 3 +- make/joglversion-test-android | 3 +- make/scripts/tests.sh | 12 +++--- make/versions.xml | 47 ---------------------- .../jogamp/nativewindow/NativeWindowVersion.java | 8 ++-- src/newt/classes/com/jogamp/newt/NewtVersion.java | 7 ++-- .../android/NewtVersionActivityLauncher.java | 2 +- 14 files changed, 51 insertions(+), 97 deletions(-) delete mode 100644 make/versions.xml (limited to 'src/newt/classes') diff --git a/make/build-common.xml b/make/build-common.xml index f68cc43be..dd33b1683 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -27,8 +27,6 @@ - - - - - - + diff --git a/make/build-jogl.xml b/make/build-jogl.xml index c481eb0f5..ce532c2b4 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -150,7 +150,7 @@ value="com/jogamp/opengl/**/swt/**"/> + value="com/jogamp/opengl/util/texture/** com/jogamp/opengl/util/av/* com/jogamp/opengl/util/packrect/** jogamp/opengl/util/av/** jogamp/opengl/util/jpeg/** jogamp/opengl/util/pngj/**"/> @@ -298,7 +298,7 @@ - + @@ -1551,10 +1551,11 @@ tofile="${build.jogl}/manifest.mf" overwrite="true"> - + + - + diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index d7ef73a46..6a42d72d4 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -149,7 +149,7 @@ - + @@ -794,10 +794,11 @@ tofile="${build.nativewindow}/manifest.mf" overwrite="true"> - + + - + @@ -934,7 +935,7 @@ - + diff --git a/make/build-newt.xml b/make/build-newt.xml index c3b51141f..864e0f93e 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -188,7 +188,7 @@ - + @@ -733,10 +733,11 @@ tofile="${build.newt}/manifest.mf" overwrite="true"> - + + - + @@ -907,7 +908,7 @@ - + diff --git a/make/build-test.xml b/make/build-test.xml index da6e3ec29..dd072bddb 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -78,10 +78,11 @@ tofile="${build.test}/manifest-test.mf" overwrite="true"> - + + - + @@ -114,10 +115,11 @@ tofile="${build.test}/manifest-test-android.mf" overwrite="true"> - + + - + @@ -142,8 +144,8 @@ androidmanifest.path="resources/android/AndroidManifest-test.xml" androidresources.path="resources/android/res-test" jarmanifest.path="${build.test}/manifest-test-android.mf" - version.code="${jogl_int_version}" - version.name="${jogl.version.plus}" /> + version.code="${jogamp.version.int}" + version.name="${jogamp.version}" /> diff --git a/make/build.xml b/make/build.xml index 44adf805f..0c6c97d34 100644 --- a/make/build.xml +++ b/make/build.xml @@ -165,8 +165,8 @@ androidmanifest.path="resources/android/AndroidManifest-jogl.xml" androidresources.path="resources/android/res-jogl" jarmanifest.path="${build.jogl}/manifest.mf" - version.code="${jogl_int_version}" - version.name="${jogl.version.plus}" /> + version.code="${jogamp.version.int}" + version.name="${jogamp.version}" /> @@ -241,10 +241,11 @@ tofile="${archive}/README.txt" overwrite="true"> - + + - + @@ -343,10 +344,10 @@ - + - + diff --git a/make/joglversion b/make/joglversion index bf0220fa0..3dc57cf32 100644 --- a/make/joglversion +++ b/make/joglversion @@ -4,6 +4,7 @@ Specification-Version: @BASEVERSION@ Specification-Vendor: JogAmp Community Implementation-Title: Java Bindings for OpenGL Runtime Environment Implementation-Version: @VERSION@ +Implementation-Build: @BUILD_VERSION@ Implementation-Branch: @SCM_BRANCH@ Implementation-Commit: @SCM_COMMIT@ Implementation-Vendor: JogAmp Community diff --git a/make/joglversion-test b/make/joglversion-test index cee93dbb4..b130bb279 100644 --- a/make/joglversion-test +++ b/make/joglversion-test @@ -2,8 +2,9 @@ Manifest-Version: 1.0 Specification-Title: Test Java Bindings for OpenGL API Specification Specification-Version: @BASEVERSION@ Specification-Vendor: JogAmp Community -Implementation-Title: Test Java Bindings for OpenGL Runtime Environment +Implementation-Title: Test JOGL Runtime Environment Implementation-Version: @VERSION@ +Implementation-Build: @BUILD_VERSION@ Implementation-Branch: @SCM_BRANCH@ Implementation-Commit: @SCM_COMMIT@ Implementation-Vendor: JogAmp Community diff --git a/make/joglversion-test-android b/make/joglversion-test-android index 88c35bed1..153b3c3b9 100644 --- a/make/joglversion-test-android +++ b/make/joglversion-test-android @@ -2,8 +2,9 @@ Manifest-Version: 1.0 Specification-Title: Test Java Bindings for OpenGL API Specification Specification-Version: @BASEVERSION@ Specification-Vendor: JogAmp Community -Implementation-Title: Test Java Bindings for OpenGL Runtime Environment on Android +Implementation-Title: Test JOGL Android Runtime Environment Implementation-Version: @VERSION@ +Implementation-Build: @BUILD_VERSION@ Implementation-Branch: @SCM_BRANCH@ Implementation-Commit: @SCM_COMMIT@ Implementation-Vendor: JogAmp Community diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c5d00fb97..41a06ea90 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -170,7 +170,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -294,7 +294,7 @@ function testawtswt() { # #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* -#testnoawt com.jogamp.newt.NewtVersion $* +testnoawt com.jogamp.newt.NewtVersion $* #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -433,7 +433,7 @@ function testawtswt() { # #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug -testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* @@ -494,8 +494,9 @@ testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* # # Texture / TextureUtils # -#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* @@ -544,9 +545,6 @@ testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* # # regressions # -#Windows -#testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* # osx: #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable02NEWT $* diff --git a/make/versions.xml b/make/versions.xml deleted file mode 100644 index 6256831d3..000000000 --- a/make/versions.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java index 38bd70a90..29f4964c0 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java @@ -31,6 +31,7 @@ package com.jogamp.nativewindow; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.JogampVersion; import com.jogamp.common.util.VersionUtil; + import java.util.jar.Manifest; public class NativeWindowVersion extends JogampVersion { @@ -45,9 +46,10 @@ public class NativeWindowVersion extends JogampVersion { if(null == jogampCommonVersionInfo) { // volatile: ok synchronized(NativeWindowVersion.class) { if( null == jogampCommonVersionInfo ) { - final String packageName = "javax.media.nativewindow"; - final Manifest mf = VersionUtil.getManifest(NativeWindowVersion.class.getClassLoader(), packageName); - jogampCommonVersionInfo = new NativeWindowVersion(packageName, mf); + final String packageName1 = "javax.media.nativewindow"; // atomic packaging - and identity + final String packageName2 = "javax.media.opengl"; // all packaging + final Manifest mf = VersionUtil.getManifest(NativeWindowVersion.class.getClassLoader(), new String[]{ packageName1, packageName2 } ); + jogampCommonVersionInfo = new NativeWindowVersion(packageName1, mf); } } } diff --git a/src/newt/classes/com/jogamp/newt/NewtVersion.java b/src/newt/classes/com/jogamp/newt/NewtVersion.java index 961ffdf6a..9adb7aac5 100644 --- a/src/newt/classes/com/jogamp/newt/NewtVersion.java +++ b/src/newt/classes/com/jogamp/newt/NewtVersion.java @@ -46,9 +46,10 @@ public class NewtVersion extends JogampVersion { if(null == jogampCommonVersionInfo) { // volatile: ok synchronized(NewtVersion.class) { if( null == jogampCommonVersionInfo ) { - final String packageName = "com.jogamp.newt"; - final Manifest mf = VersionUtil.getManifest(NewtVersion.class.getClassLoader(), packageName); - jogampCommonVersionInfo = new NewtVersion(packageName, mf); + final String packageName1 = "com.jogamp.newt"; // atomic packaging - and identity + final String packageName2 = "javax.media.opengl"; // all packaging + final Manifest mf = VersionUtil.getManifest(NativeWindowVersion.class.getClassLoader(), new String[]{ packageName1, packageName2 } ); + jogampCommonVersionInfo = new NewtVersion(packageName1, mf); } } } diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java index cb8799b19..9b3c6e24b 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java @@ -11,7 +11,7 @@ public class NewtVersionActivityLauncher extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtVersionActivity"); + final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtVersionActivity?sys=com.jogamp.common&sys=javax.media.opengl&pkg=com.jogamp.opengl.test"); final Intent intent = new Intent("org.jogamp.launcher.action.LAUNCH_ACTIVITY_NORMAL", uri); Log.d(getClass().getSimpleName(), "Launching Activity: "+intent); startActivity (intent); -- cgit v1.2.3 From 00c65b4a34445d140ca9e6ee531dfa4278b8e770 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 29 Mar 2013 16:34:56 +0100 Subject: NewtBaseActivity: Move setVisible(false) from onPause() -> onStop(), since only onStop() declares invisible status. onPause() could imply other non fullscreen activity on top. --- src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index 3716e3569..76eb890e2 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -392,10 +392,6 @@ public class NewtBaseActivity extends Activity { } Log.d(MD.TAG, "GLStateKeeper.Mark2Preserve: Total "+glAutoDrawables.size()+", OK "+ok+", Fail "+fail); } - for(int i=0; i Date: Wed, 3 Apr 2013 17:19:06 +0200 Subject: NewtCanvasAWT: Cleanup up private method calls; Attach/Detach JAWTWindow's SurfaceUpdateListener to NEWT Window when it gets attached/detached. --- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index d22e50cb8..3d907a86f 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -421,15 +421,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public void paint(Graphics g) { - if( validateComponent(true, null) ) { + if( validateComponent(true) ) { newtChild.windowRepaint(0, 0, getWidth(), getHeight()); } } @Override public void update(Graphics g) { - if( validateComponent(true, null) ) { - newtChild.windowRepaint(0, 0, getWidth(), getHeight()); - } + paint(g); } @SuppressWarnings("deprecation") @@ -440,7 +438,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println("NewtCanvasAWT.reshape: "+x+"/"+y+" "+width+"x"+height); } - if( validateComponent(true, null) ) { + if( validateComponent(true) ) { // newtChild.setSize(width, height); } } @@ -490,22 +488,19 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto return res; } - private final boolean validateComponent(boolean attachNewtChild, java.awt.Container cont) { + private final boolean validateComponent(boolean attachNewtChild) { if( Beans.isDesignTime() || !isDisplayable() ) { return false; } if ( null == newtChild || null == jawtWindow ) { return false; } - if( null == cont ) { - cont = AWTMisc.getContainer(this); - } if( 0 >= getWidth() || 0 >= getHeight() ) { return false; } if( attachNewtChild && !newtChildAttached && null != newtChild ) { - attachNewtChild(cont); + attachNewtChild(); } return true; @@ -559,7 +554,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } - private final void attachNewtChild(java.awt.Container cont) { + private final void attachNewtChild() { if( null == newtChild || null == jawtWindow || newtChildAttached ) { return; // nop } @@ -569,7 +564,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.attachNewtChild.0: win "+newtWinHandleToHexString(newtChild)+ ", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+ ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+", displayable "+isDisplayable()+ - ", cont "+cont); + ", cont "+AWTMisc.getContainer(this)); } newtChildAttached = true; @@ -582,6 +577,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h); newtChild.setSize(w, h); newtChild.reparentWindow(jawtWindow); + newtChild.addSurfaceUpdatedListener(jawtWindow); newtChild.setVisible(true); configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener @@ -607,6 +603,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto ", cont "+cont); } + newtChild.removeSurfaceUpdatedListener(jawtWindow); newtChildAttached = false; newtChild.setFocusAction(null); // no AWT focus traversal .. configureNewtChild(false); -- cgit v1.2.3 From 57bf60b789d89d70a58583a9cc0119317f179c3a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Apr 2013 06:06:50 +0200 Subject: OSX CALayer/NewtCanvasAWT: Force relayout of component (size +1, size -1) when attaching NEWT Child to avoid false CALayer position. --- make/scripts/tests.sh | 30 ++-------- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 23 +++++++- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 5 ++ .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 65 +++++++++++++++++----- .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 7 +-- 5 files changed, 87 insertions(+), 43 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 48fa02a6c..0bd814322 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -272,7 +272,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* @@ -498,7 +498,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareNewtAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTBenchmarkNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* @@ -543,36 +543,18 @@ testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareN #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* # -# osx bugs +# OSX bugs # #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* -# -# regressions -# - -# osx: -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable02NEWT $* +# test rotation change #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* # -# OSX Java6 NEWT +# regressions # -# Freeze - -# Cut-off top -#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* - -# Child too low -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* - -# test rotation change -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT - #linux: # ATI/Linux: XCB Unknown request in queue while dequeuing diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 3d907a86f..d0a4b7e98 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -54,6 +54,8 @@ import jogamp.newt.awt.NewtFactoryAWT; import jogamp.newt.awt.event.AWTParentWindowAdapter; import jogamp.newt.driver.DriverClearFocus; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.newt.Display; @@ -561,7 +563,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { // if ( isShowing() == false ) -> Container was not visible yet. // if ( isShowing() == true ) -> Container is already visible. - System.err.println("NewtCanvasAWT.attachNewtChild.0: win "+newtWinHandleToHexString(newtChild)+ + System.err.println("NewtCanvasAWT.attachNewtChild.0 @ "+Thread.currentThread().getName()+": win "+newtWinHandleToHexString(newtChild)+ ", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+ ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+", displayable "+isDisplayable()+ ", cont "+AWTMisc.getContainer(this)); @@ -575,9 +577,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final int w = getWidth(); final int h = getHeight(); System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h); + newtChild.setVisible(false); newtChild.setSize(w, h); newtChild.reparentWindow(jawtWindow); newtChild.addSurfaceUpdatedListener(jawtWindow); + if( Platform.OSType.MACOS == Platform.getOSType() && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { + AWTEDTExecutor.singleton.invoke(false, forceRelayout); + } newtChild.setVisible(true); configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener @@ -589,6 +595,21 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.attachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); } } + private final Runnable forceRelayout = new Runnable() { + public void run() { + if(DEBUG) { + System.err.println("NewtCanvasAWT.forceRelayout.0"); + } + // Hack to force proper native AWT layout incl. CALayer components on OSX + final java.awt.Component component = NewtCanvasAWT.this; + final int cW = component.getWidth(); + final int cH = component.getHeight(); + component.setSize(cW+1, cH+1); + component.setSize(cW, cH); + if(DEBUG) { + System.err.println("NewtCanvasAWT.forceRelayout.X"); + } + } }; private final void detachNewtChild(java.awt.Container cont) { if( null == newtChild || null == jawtWindow || !newtChildAttached ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 49f1940dc..5e523c780 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -37,6 +37,7 @@ import java.nio.FloatBuffer; import javax.media.nativewindow.NativeWindow; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; @@ -267,6 +268,10 @@ public class GearsES2 implements GLEventListener { } public void display(GLAutoDrawable drawable) { + GLAnimatorControl anim = drawable.getAnimator(); + if( verbose && ( null == anim || !anim.isAnimating() ) ) { + System.err.println(Thread.currentThread()+" GearsES2.display"+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); + } // Turn the gears' teeth if(doRotate) { angle += 2.0f; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java index 64151362b..78ee2f6b5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java @@ -47,6 +47,7 @@ import com.jogamp.opengl.test.junit.util.QuitAdapter; import java.awt.BorderLayout; import java.awt.Button; +import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.EventQueue; @@ -65,7 +66,13 @@ import org.junit.Test; public class TestGearsES2AWT extends UITestCase { public enum FrameLayout { None, TextOnBottom, BorderCenterSurrounded, DoubleBorderCenterSurrounded }; + public enum ResizeBy { Component, Frame }; + + static long duration = 500; // ms static int width, height; + static FrameLayout frameLayout = FrameLayout.None; + static ResizeBy resizeBy = ResizeBy.Component; + static boolean forceES2 = false; static boolean forceGL3 = false; static boolean shallUseOffscreenFBOLayer = false; @@ -79,7 +86,7 @@ public class TestGearsES2AWT extends UITestCase { static boolean exclusiveContext = false; static boolean useAnimator = true; static Thread awtEDT; - static Dimension rwsize = null; + static java.awt.Dimension rwsize = null; @BeforeClass public static void initClass() { @@ -100,13 +107,13 @@ public class TestGearsES2AWT extends UITestCase { public static void releaseClass() { } - static void setGLCanvasSize(final Frame frame, final GLCanvas glc, final Dimension new_sz) { + static void setComponentSize(final Frame frame, final Component comp, final java.awt.Dimension new_sz) { try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - glc.setMinimumSize(new_sz); - glc.setPreferredSize(new_sz); - glc.setSize(new_sz); + comp.setMinimumSize(new_sz); + comp.setPreferredSize(new_sz); + comp.setSize(new_sz); if( null != frame ) { frame.pack(); } @@ -116,14 +123,39 @@ public class TestGearsES2AWT extends UITestCase { Assume.assumeNoException( throwable ); } } + static void setFrameSize(final Frame frame, final boolean frameLayout, final java.awt.Dimension new_sz) { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(new_sz); + if( frameLayout ) { + frame.validate(); + } + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + static void setSize(final ResizeBy resizeBy, final Frame frame, final boolean frameLayout, final Component comp, final java.awt.Dimension new_sz) { + switch( resizeBy ) { + case Component: + setComponentSize(frameLayout ? frame : null, comp, new_sz); + break; + case Frame: + setFrameSize(frame, frameLayout, new_sz); + break; + } + } - protected void runTestGL(GLCapabilities caps, FrameLayout frameLayout) throws InterruptedException, InvocationTargetException { + protected void runTestGL(GLCapabilities caps, final ResizeBy resizeBy, FrameLayout frameLayout) throws InterruptedException, InvocationTargetException { final Frame frame = new Frame("GearsES2 AWT Test"); Assert.assertNotNull(frame); final GLCanvas glCanvas = new GLCanvas(caps); Assert.assertNotNull(glCanvas); - setGLCanvasSize(null, glCanvas, new Dimension(width, height)); + setSize(resizeBy, frame, false, glCanvas, new Dimension(width, height)); switch( frameLayout) { case None: @@ -179,8 +211,12 @@ public class TestGearsES2AWT extends UITestCase { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - frame.pack(); - frame.setVisible(true); + if( ResizeBy.Frame == resizeBy ) { + frame.validate(); + } else { + frame.pack(); + } + frame.setVisible(true); }}); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true)); @@ -197,7 +233,7 @@ public class TestGearsES2AWT extends UITestCase { if( null != rwsize ) { Thread.sleep(500); // 500ms delay - setGLCanvasSize(frame, glCanvas, rwsize); + setSize(resizeBy, frame, true, glCanvas, rwsize); System.err.println("window resize pos/siz: "+glCanvas.getX()+"/"+glCanvas.getY()+" "+glCanvas.getWidth()+"x"+glCanvas.getHeight()); } @@ -263,12 +299,9 @@ public class TestGearsES2AWT extends UITestCase { if(shallUseOffscreenPBufferLayer) { caps.setPBuffer(true); } - runTestGL(caps, frameLayout); + runTestGL(caps, resizeBy, frameLayout); } - static long duration = 500; // ms - static FrameLayout frameLayout = FrameLayout.None; - public static void main(String args[]) { boolean waitForKey = false; int rw=-1, rh=-1; @@ -288,6 +321,9 @@ public class TestGearsES2AWT extends UITestCase { } else if(args[i].equals("-layout")) { i++; frameLayout = FrameLayout.valueOf(args[i]); + } else if(args[i].equals("-resizeBy")) { + i++; + resizeBy = ResizeBy.valueOf(args[i]); } else if(args[i].equals("-es2")) { forceES2 = true; } else if(args[i].equals("-gl3")) { @@ -326,6 +362,7 @@ public class TestGearsES2AWT extends UITestCase { System.err.println("resize "+rwsize); System.err.println("frameLayout "+frameLayout); + System.err.println("resizeBy "+resizeBy); System.err.println("forceES2 "+forceES2); System.err.println("forceGL3 "+forceGL3); System.err.println("swapInterval "+swapInterval); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java index 38eb80be8..3cf8290c7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -80,7 +80,9 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; static DimensionImmutable wsize, rwsize = null; - + static FrameLayout frameLayout = FrameLayout.None; + static ResizeBy resizeBy = ResizeBy.Component; + static long duration = 500; // ms static boolean opaque = true; static int forceAlpha = -1; @@ -401,9 +403,6 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { runTestGL(caps, resizeBy, frameLayout); } - static FrameLayout frameLayout = FrameLayout.None; - static ResizeBy resizeBy = ResizeBy.Component; - public static void main(String args[]) throws IOException { mainRun = true; -- cgit v1.2.3 From d4e840fed236bb139515ec03a4a2ebe1676d3cb1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 5 Apr 2013 03:40:17 +0200 Subject: Bug 707: Fix NEWT EVENT_MOUSE_EXITED not sent on Windows - Regression of commit 85338858f5c58694fa88e77df1386d0556887944 Commit replaced enqueueMouseEventID w/ sendMouseEventID, while not removing the 'jboolean wait' argument. This also lead to staying in DRAGGED mode when mouse left the window. --- .../jogamp/newt/driver/windows/WindowDriver.java | 11 ++++++----- src/newt/native/WindowsWindow.c | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 475687eb4..e7a8d5a33 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -131,18 +131,19 @@ public class WindowDriver extends WindowImpl { setGraphicsConfiguration(cfg); final int flags = getReconfigureFlags(0, true) & ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; - setWindowHandle(CreateWindow0(DisplayDriver.getHInstance(), display.getWindowClassName(), display.getWindowClassName(), - getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); - if (getWindowHandle() == 0) { + final long _windowHandle = CreateWindow0(DisplayDriver.getHInstance(), display.getWindowClassName(), display.getWindowClassName(), + getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags); + if ( 0 == _windowHandle ) { throw new NativeWindowException("Error creating window"); } - windowHandleClose = getWindowHandle(); + setWindowHandle(_windowHandle); + windowHandleClose = _windowHandle; addMouseListener(mouseTracker); if(DEBUG_IMPLEMENTATION) { Exception e = new Exception("Info: Window new window handle "+Thread.currentThread().getName()+ " (Parent HWND "+toHexString(getParentWindowHandle())+ - ") : HWND "+toHexString(getWindowHandle())+", "+Thread.currentThread()); + ") : HWND "+toHexString(_windowHandle)+", "+Thread.currentThread()); e.printStackTrace(); } } diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 05953cb86..aeb860bbc 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -524,14 +524,14 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, HWND hwnd, jb DBG_PRINT("*** WindowsWindow: requestFocus.XX\n"); } -static void NewtWindows_trackPointerLeave(HWND hwnd) { +static BOOL NewtWindows_trackPointerLeave(HWND hwnd) { TRACKMOUSEEVENT tme; memset(&tme, 0, sizeof(TRACKMOUSEEVENT)); tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_LEAVE; tme.hwndTrack = hwnd; tme.dwHoverTime = 0; // we don't use TME_HOVER - TrackMouseEvent(&tme); + return TrackMouseEvent(&tme); } #if 0 @@ -915,6 +915,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_MOUSEMOVE: + DBG_PRINT("*** WindowsWindow: WM_MOUSEMOVE %d/%d\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam)); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED, GetModifiers( FALSE, 0 ), @@ -923,7 +924,8 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP useDefWindowProc = 1; break; case WM_MOUSELEAVE: - (*env)->CallVoidMethod(env, window, sendMouseEventID, JNI_FALSE, + DBG_PRINT("*** WindowsWindow: WM_MOUSELEAVE\n"); + (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_EXITED, 0, (jint) -1, (jint) -1, // fake @@ -1739,7 +1741,14 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_trackPointer (JNIEnv *env, jclass clazz, jlong window) { HWND hwnd = (HWND) (intptr_t) window; - DBG_PRINT( "*** WindowsWindow: trackMouseLeave0\n"); - NewtWindows_trackPointerLeave(hwnd); + BOOL ok = NewtWindows_trackPointerLeave(hwnd); + DBG_PRINT( "*** WindowsWindow: trackMouseLeave0: %d\n", ok); + #ifdef VERBOSE_ON + if(!ok) { + int lastError = (int) GetLastError(); + DBG_PRINT( "*** WindowsWindow: trackMouseLeave0: lastError 0x%X %d\n", lastError, lastError); + } + #endif + (void)ok; } -- cgit v1.2.3 From 4898f582d9303caa7fd1b44438808e86b51c2a3b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 6 Apr 2013 04:47:34 +0200 Subject: Bug 678: Differentiate ALT (left) and ALT_GRAPH (right) on X11, EventDev, Windows and OSX - X11: Memorize pressed Alt_R to decide which 'alt' has to be used for non key modifier fetching - Windows: Only use GetKeyState(..) and compare the US vkey, since int. kbd layout use reduced scancode --- make/scripts/java-win64-dbg.bat | 1 + make/scripts/tests-x64.bat | 4 +-- make/scripts/tests.sh | 7 +++-- .../classes/com/jogamp/newt/event/InputEvent.java | 2 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 5 ++- .../newt/driver/linux/LinuxEventDeviceTracker.java | 2 +- .../jogamp/newt/driver/macosx/MacKeyUtil.java | 2 +- src/newt/native/WindowsWindow.c | 36 ++++++++++++---------- src/newt/native/X11Display.c | 32 ++++++++++++++----- 9 files changed, 58 insertions(+), 33 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 1f712bae7..0dd922dde 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -42,6 +42,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Dnewt.debug.Window" set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" +REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 22f413ef7..d08f40e5c 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -50,7 +50,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsReali REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -96,7 +96,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug6 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index e4ff1f4f4..fd24eb25c 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -170,8 +170,9 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" + #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" @@ -275,7 +276,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* @@ -428,7 +429,7 @@ function testawtswt() { #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* -testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlockAWT $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlockAWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec $* # diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index 4920b59ea..b04ebc1af 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -133,7 +133,7 @@ public abstract class InputEvent extends NEWTEvent if(isControlDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("ctrl"); } if(isMetaDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("meta"); } if(isAltDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("alt"); } - if(isAltGraphDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("altg"); } + if(isAltGraphDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("altgr"); } if(isAutoRepeat()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("repeat"); } for(int i=1; i<=MouseEvent.BUTTON_NUMBER; i++) { if(isButtonDown(i)) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("button").append(i); } diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 5117ffe29..777c9b471 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -325,6 +325,9 @@ public class KeyEvent extends InputEvent public static final short VK_CLEAR = (short) 0x0C; public static final short VK_SHIFT = (short) 0x10; public static final short VK_CONTROL = (short) 0x11; + /** + * Constant for the ALT function key, i.e. left ALT key. + */ public static final short VK_ALT = (short) 0x12; public static final short VK_PAUSE = (short) 0x13; public static final short VK_CAPS_LOCK = (short) 0x14; @@ -862,7 +865,7 @@ public class KeyEvent extends InputEvent public static final short VK_COMPOSE = (short) 0xFF20; /** - * Constant for the AltGraph function key. + * Constant for the ALT_GRAPH function key, i.e. right ALT key. */ public static final short VK_ALT_GRAPH = (short) 0xFF7E; diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index 2c0e6d3dd..bc69c2204 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -586,7 +586,7 @@ public class LinuxEventDeviceTracker implements WindowListener { break; // FIXME case 100: // right alt - return KeyEvent.VK_ALT; + return KeyEvent.VK_ALT_GRAPH; case 101: // linefeed break; // FIXME case 102: // home diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java index c07576901..baa94facd 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java @@ -317,7 +317,7 @@ public class MacKeyUtil { case kVK_Option: return KeyEvent.VK_ALT; case kVK_Control: return KeyEvent.VK_CONTROL; case kVK_RightShift: return KeyEvent.VK_SHIFT; - case kVK_RightOption: return KeyEvent.VK_ALT; + case kVK_RightOption: return KeyEvent.VK_ALT_GRAPH; case kVK_RightControl: return KeyEvent.VK_CONTROL; // case kVK_Function: return KeyEvent.VK_F; case kVK_F17: return KeyEvent.VK_F17; diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index aeb860bbc..7426e5dfe 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -161,7 +161,7 @@ static KeyMapEntry keyMapTable[] = { {J_VK_CONTROL, VK_RCONTROL, 0}, {J_VK_ALT, VK_MENU, 0}, {J_VK_ALT, VK_LMENU, 0}, - {J_VK_ALT, VK_RMENU, 0}, + {J_VK_ALT_GRAPH, VK_RMENU, 0}, {J_VK_NUM_LOCK, VK_NUMLOCK, 0}, // Miscellaneous Windows keys @@ -431,7 +431,7 @@ static void ParseWmVKeyAndScanCode(USHORT winVKey, BYTE winScanCode, BYTE flags, #endif } -static jint GetModifiers(BOOL altKeyFlagged, USHORT jkey) { +static jint GetModifiers(USHORT jkey) { jint modifiers = 0; // have to do &0xFFFF to avoid runtime assert caused by compiling with // /RTCcsu @@ -441,9 +441,12 @@ static jint GetModifiers(BOOL altKeyFlagged, USHORT jkey) { if ( HIBYTE((GetKeyState(VK_SHIFT) & 0xFFFF)) != 0 || J_VK_SHIFT == jkey ) { modifiers |= EVENT_SHIFT_MASK; } - if ( altKeyFlagged || HIBYTE((GetKeyState(VK_MENU) & 0xFFFF)) != 0 || J_VK_ALT == jkey ) { + if ( HIBYTE((GetKeyState(VK_LMENU) & 0xFFFF)) != 0 || J_VK_ALT == jkey ) { modifiers |= EVENT_ALT_MASK; } + if ( HIBYTE((GetKeyState(VK_RMENU) & 0xFFFF)) != 0 || (USHORT)J_VK_ALT_GRAPH == jkey ) { + modifiers |= EVENT_ALT_GRAPH_MASK; + } if ( HIBYTE((GetKeyState(VK_LBUTTON) & 0xFFFF)) != 0 ) { modifiers |= EVENT_BUTTON1_MASK; } @@ -457,11 +460,12 @@ static jint GetModifiers(BOOL altKeyFlagged, USHORT jkey) { return modifiers; } +/** static BOOL IsAltKeyDown(BYTE flags, BOOL system) { // The Alt modifier is reported in the 29th bit of the lParam, // i.e., it is the 5th bit of `flags' (which is HIBYTE(HIWORD(lParam))). return system && ( flags & (1<<5) ) != 0; -} +} */ static int WmKeyDown(JNIEnv *env, jobject window, USHORT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { UINT modifiers = 0; @@ -472,7 +476,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, USHORT wkey, WORD repCnt, BYTE ParseWmVKeyAndScanCode(wkey, scanCode, flags, &javaVKeyUS, &javaVKeyXX, &utf16Char); - modifiers = GetModifiers( IsAltKeyDown(flags, system), javaVKeyXX ); + modifiers = GetModifiers( javaVKeyUS ); (*env)->CallVoidMethod(env, window, sendKeyEventID, (jshort) EVENT_KEY_PRESSED, @@ -490,7 +494,7 @@ static int WmKeyUp(JNIEnv *env, jobject window, USHORT wkey, WORD repCnt, BYTE s ParseWmVKeyAndScanCode(wkey, scanCode, flags, &javaVKeyUS, &javaVKeyXX, &utf16Char); - modifiers = GetModifiers( IsAltKeyDown(flags, system), javaVKeyXX ); + modifiers = GetModifiers( javaVKeyUS ); (*env)->CallVoidMethod(env, window, sendKeyEventID, (jshort) EVENT_KEY_RELEASED, @@ -859,7 +863,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED, - GetModifiers( FALSE, 0 ), + GetModifiers( 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jshort) 1, (jfloat) 0.0f); useDefWindowProc = 1; @@ -868,7 +872,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP case WM_LBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, - GetModifiers( FALSE, 0 ), + GetModifiers( 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jshort) 1, (jfloat) 0.0f); useDefWindowProc = 1; @@ -879,7 +883,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED, - GetModifiers( FALSE, 0 ), + GetModifiers( 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jshort) 2, (jfloat) 0.0f); useDefWindowProc = 1; @@ -888,7 +892,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP case WM_MBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, - GetModifiers( FALSE, 0 ), + GetModifiers( 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jshort) 2, (jfloat) 0.0f); useDefWindowProc = 1; @@ -899,7 +903,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED, - GetModifiers( FALSE, 0 ), + GetModifiers( 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jshort) 3, (jfloat) 0.0f); useDefWindowProc = 1; @@ -908,17 +912,17 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP case WM_RBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, - GetModifiers( FALSE, 0 ), + GetModifiers( 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jshort) 3, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_MOUSEMOVE: - DBG_PRINT("*** WindowsWindow: WM_MOUSEMOVE %d/%d\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam)); + // DBG_PRINT("*** WindowsWindow: WM_MOUSEMOVE %d/%d\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam)); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED, - GetModifiers( FALSE, 0 ), + GetModifiers( 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jshort) 0, (jfloat) 0.0f); useDefWindowProc = 1; @@ -936,7 +940,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP case WM_HSCROLL: { // Only delivered if windows has WS_HSCROLL, hence dead code! int sb = LOWORD(wParam); - int modifiers = GetModifiers( FALSE, 0 ) | EVENT_SHIFT_MASK; + int modifiers = GetModifiers( 0 ) | EVENT_SHIFT_MASK; float rotation; switch(sb) { case SB_LINELEFT: @@ -966,7 +970,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP // need to convert the coordinates to component-relative int x = GET_X_LPARAM(lParam); int y = GET_Y_LPARAM(lParam); - int modifiers = GetModifiers( FALSE, 0 ); + int modifiers = GetModifiers( 0 ); float rotationOrTilt = (float)(GET_WHEEL_DELTA_WPARAM(wParam))/WHEEL_DELTAf; int vKeys = GET_KEYSTATE_WPARAM(wParam); POINT eventPt; diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 9b11ff0dd..d927b8069 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -52,9 +52,11 @@ static jmethodID requestFocusID = NULL; * Keycode */ +// #define DEBUG_KEYS 1 + #define IS_WITHIN(k,a,b) ((a)<=(k)&&(k)<=(b)) -static jint X11KeySym2NewtVKey(KeySym keySym) { +static short X11KeySym2NewtVKey(KeySym keySym) { if( IS_WITHIN( keySym, XK_a, XK_z ) ) { return ( keySym - XK_a ) + J_VK_A ; } @@ -89,8 +91,9 @@ static jint X11KeySym2NewtVKey(KeySym keySym) { case XK_Control_R: return J_VK_CONTROL; case XK_Alt_L: - case XK_Alt_R: return J_VK_ALT; + case XK_Alt_R: + return J_VK_ALT_GRAPH; case XK_Pause: return J_VK_PAUSE; case XK_Caps_Lock: @@ -158,7 +161,9 @@ static jint X11KeySym2NewtVKey(KeySym keySym) { return keySym; } -static jint X11InputState2NewtModifiers(unsigned int xstate, int javaVKey) { +static jboolean altGraphDown = JNI_FALSE; + +static jint X11InputState2NewtModifiers(unsigned int xstate, jshort javaVKey, jboolean keyDown) { jint modifiers = 0; if ( (ControlMask & xstate) != 0 || J_VK_CONTROL == javaVKey ) { modifiers |= EVENT_CTRL_MASK; @@ -166,8 +171,15 @@ static jint X11InputState2NewtModifiers(unsigned int xstate, int javaVKey) { if ( (ShiftMask & xstate) != 0 || J_VK_SHIFT == javaVKey ) { modifiers |= EVENT_SHIFT_MASK; } - if ( (Mod1Mask & xstate) != 0 || J_VK_ALT == javaVKey ) { + if ( J_VK_ALT == javaVKey ) { + altGraphDown = JNI_FALSE; modifiers |= EVENT_ALT_MASK; + } else if ( (short)J_VK_ALT_GRAPH == javaVKey ) { + altGraphDown = keyDown; + modifiers |= EVENT_ALT_GRAPH_MASK; + } else if ( (Mod1Mask & xstate) != 0 ) { + // XK_Alt_L or XK_Alt_R + modifiers |= altGraphDown ? EVENT_ALT_GRAPH_MASK : EVENT_ALT_MASK; } if ( (Button1Mask & xstate) != 0 ) { modifiers |= EVENT_BUTTON1_MASK; @@ -401,17 +413,21 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage javaVKeyNN = X11KeySym2NewtVKey(keySym); javaVKeyUS = javaVKeyNN; // FIXME! - modifiers |= X11InputState2NewtModifiers(evt.xkey.state, javaVKeyNN) | autoRepeatModifiers; + modifiers |= X11InputState2NewtModifiers(evt.xkey.state, javaVKeyNN, evt.type == KeyPress) | autoRepeatModifiers; - fprintf(stderr, "NEWT X11 Key: keyCode 0x%X keySym 0x%X (shifted: 0x%X), keyChar '%c', javaVKey[US 0x%X, NN 0x%X]\n", - (int)keyCode, (int)keySym, (int)shiftedKeySym, (int)keyChar, (int)javaVKeyUS, (int)javaVKeyNN); + #ifdef DEBUG_KEYS + fprintf(stderr, "NEWT X11 Key: keyCode 0x%X keySym 0x%X (shifted: 0x%X), keyChar '%c', javaVKey[US 0x%X, NN 0x%X], xstate 0x%X %u, jmods 0x%X\n", + (int)keyCode, (int)keySym, (int)shiftedKeySym, keyChar, + (int)javaVKeyUS, (int)javaVKeyNN, + (int)evt.xkey.state, (int)evt.xkey.state, (int)modifiers); + #endif } break; case ButtonPress: case ButtonRelease: case MotionNotify: - modifiers |= X11InputState2NewtModifiers(evt.xbutton.state, 0); + modifiers |= X11InputState2NewtModifiers(evt.xbutton.state, 0, JNI_FALSE); break; default: -- cgit v1.2.3 From ed596d9a329f1788979e148a4d09df7815ada527 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 8 Apr 2013 02:47:23 +0200 Subject: Bug 641 NEWT: X11 Deliver keyCode layout independent, keySym layout dependent and UTF-16 keyChar value On X11, the layout dependent keySym was not delivered [1], as well as the UTF-8 to UTF-16 translation was missing [2]. [1] is solved using XLookupString w/o ShiftMask [2] is solved using JNI's NewStringUTF, which takes UTF-8. --- make/scripts/tests.sh | 6 +- .../jogamp/newt/driver/x11/DisplayDriver.java | 16 +++-- .../jogamp/newt/driver/x11/WindowDriver.java | 16 +++-- src/newt/native/X11Display.c | 74 +++++++++++++++++----- src/newt/native/X11Window.c | 4 +- 5 files changed, 83 insertions(+), 33 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index cb8abc8bf..eee4edec0 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -170,7 +170,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -276,7 +276,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* @@ -291,7 +291,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* # diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index f3a548a08..4fe025ec4 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -91,9 +91,10 @@ public class DisplayDriver extends DisplayImpl { @Override protected void closeNativeImpl() { - DisplayRelease0(aDevice.getHandle(), javaObjectAtom, windowDeleteAtom); + DisplayRelease0(aDevice.getHandle(), javaObjectAtom, windowDeleteAtom /*, kbdHandle */); // XKB disabled for now javaObjectAtom = 0; windowDeleteAtom = 0; + // kbdHandle = 0; aDevice.close(); // closes X11 display } @@ -103,7 +104,7 @@ public class DisplayDriver extends DisplayImpl { try { final long handle = aDevice.getHandle(); if(0 != handle) { - DispatchMessages0(handle, javaObjectAtom, windowDeleteAtom); + DispatchMessages0(handle, javaObjectAtom, windowDeleteAtom /*, kbdHandle */); // XKB disabled for now } } finally { if(null != aDevice) { // could be pulled by destroy event @@ -114,6 +115,7 @@ public class DisplayDriver extends DisplayImpl { protected long getJavaObjectAtom() { return javaObjectAtom; } protected long getWindowDeleteAtom() { return windowDeleteAtom; } + // protected long getKbdHandle() { return kbdHandle; } // XKB disabled for now /** Returns null if !{@link #isNativeValid()}, otherwise the Boolean value of {@link X11GraphicsDevice#isXineramaEnabled()}. */ protected Boolean isXineramaEnabled() { return isNativeValid() ? Boolean.valueOf(((X11GraphicsDevice)aDevice).isXineramaEnabled()) : null; } @@ -126,18 +128,22 @@ public class DisplayDriver extends DisplayImpl { private native void CompleteDisplay0(long handle); - private void displayCompleted(long javaObjectAtom, long windowDeleteAtom) { + private void displayCompleted(long javaObjectAtom, long windowDeleteAtom /*, long kbdHandle */) { this.javaObjectAtom=javaObjectAtom; this.windowDeleteAtom=windowDeleteAtom; + // this.kbdHandle = kbdHandle; // XKB disabled for now } - private native void DisplayRelease0(long handle, long javaObjectAtom, long windowDeleteAtom); + private native void DisplayRelease0(long handle, long javaObjectAtom, long windowDeleteAtom /*, long kbdHandle */); // XKB disabled for now - private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom); + private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom /* , long kbdHandle */); // XKB disabled for now /** X11 Window delete atom marker used on EDT */ private long windowDeleteAtom; /** X11 Window java object property used on EDT */ private long javaObjectAtom; + + /** X11 Keyboard handle used on EDT */ + // private long kbdHandle; // XKB disabled for now } diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 8d33d4d73..666d0cb5b 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -116,7 +116,7 @@ public class WindowDriver extends WindowImpl { edtDevice.lock(); try { CloseWindow0(edtDevice.getHandle(), windowHandleClose, - display.getJavaObjectAtom(), display.getWindowDeleteAtom()); + display.getJavaObjectAtom(), display.getWindowDeleteAtom() /* , display.getKbdHandle() */); // XKB disabled for now } catch (Throwable t) { if(DEBUG_IMPLEMENTATION) { Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); @@ -271,13 +271,13 @@ public class WindowDriver extends WindowImpl { super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotation); } - @Override - public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + protected final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar0, String keyString) { // handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); final boolean isModifierKey = KeyEvent.isModifierKey(keyCode); final boolean isAutoRepeat = 0 != ( KeyEvent.AUTOREPEAT_MASK & modifiers ); - // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+ - // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isAutoRepeat+", [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); + final char keyChar = ( null != keyString ) ? keyString.charAt(0) : keyChar0; + // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar0+">/<"+keyChar+">, keyString "+keyString+", mods "+toHexString(modifiers)+ + // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isAutoRepeat+", [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); if( !isAutoRepeat || !isModifierKey ) { // ! ( isModifierKey && isAutoRepeat ) switch(eventType) { @@ -295,6 +295,10 @@ public class WindowDriver extends WindowImpl { } } + @Override + public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); + } @Override public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); @@ -315,7 +319,7 @@ public class WindowDriver extends WindowImpl { private native long CreateWindow0(long parentWindowHandle, long display, int screen_index, int visualID, long javaObjectAtom, long windowDeleteAtom, int x, int y, int width, int height, boolean autoPosition, int flags); - private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom); + private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom /*, long kbdHandle*/ ); // XKB disabled for now private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle, long windowDeleteAtom, int x, int y, int width, int height, int flags); private native void requestFocus0(long display, long windowHandle, boolean force); diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index d927b8069..a2df0d2e2 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -28,6 +28,8 @@ #include "X11Common.h" +// #include // XKB disabled for now + jclass X11NewtWindowClazz = NULL; jmethodID insetsChangedID = NULL; jmethodID visibleChangedID = NULL; @@ -223,6 +225,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 } } + // displayCompletedID = (*env)->GetMethodID(env, clazz, "displayCompleted", "(JJJ)V"); // Variant using XKB displayCompletedID = (*env)->GetMethodID(env, clazz, "displayCompleted", "(JJ)V"); getCurrentThreadNameID = (*env)->GetStaticMethodID(env, X11NewtWindowClazz, "getCurrentThreadName", "()Ljava/lang/String;"); dumpStackID = (*env)->GetStaticMethodID(env, X11NewtWindowClazz, "dumpStack", "()V"); @@ -235,7 +238,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 windowDestroyNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowRepaint", "(ZIIII)V"); sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(SIIISF)V"); - sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(SISSC)V"); + sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(SISSCLjava/lang/String;)V"); requestFocusID = (*env)->GetMethodID(env, X11NewtWindowClazz, "requestFocus", "(Z)V"); if (displayCompletedID == NULL || @@ -270,6 +273,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_CompleteDisplay Display * dpy = (Display *)(intptr_t)display; jlong javaObjectAtom; jlong windowDeleteAtom; + // jlong kbdHandle; // XKB disabled for now if(dpy==NULL) { NewtCommon_FatalError(env, "invalid display connection.."); @@ -288,10 +292,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_CompleteDisplay } // XSetCloseDownMode(dpy, RetainTemporary); // Just a try .. + // kbdHandle = (jlong) (intptr_t) XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd); // XKB disabled for now DBG_PRINT("X11: X11Display_completeDisplay dpy %p\n", dpy); - (*env)->CallVoidMethod(env, obj, displayCompletedID, javaObjectAtom, windowDeleteAtom); + (*env)->CallVoidMethod(env, obj, displayCompletedID, javaObjectAtom, windowDeleteAtom /*, kbdHandle*/); // XKB disabled for now } /* @@ -300,11 +305,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_CompleteDisplay * Signature: (JJJ)V */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DisplayRelease0 - (JNIEnv *env, jobject obj, jlong display, jlong javaObjectAtom, jlong windowDeleteAtom) + (JNIEnv *env, jobject obj, jlong display, jlong javaObjectAtom, jlong windowDeleteAtom /*, jlong kbdHandle*/) { Display * dpy = (Display *)(intptr_t)display; Atom wm_javaobject_atom = (Atom)javaObjectAtom; Atom wm_delete_atom = (Atom)windowDeleteAtom; + // XkbDescPtr kbdDesc = (XkbDescPtr)(intptr_t)kbdHandle; // XKB disabled for now if(dpy==NULL) { NewtCommon_FatalError(env, "invalid display connection.."); @@ -314,6 +320,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DisplayRelease0 (void) wm_javaobject_atom; (void) wm_delete_atom; + // XkbFreeKeyboard(kbdDesc, XkbAllNamesMask, True); // XKB disabled for now + XSync(dpy, True); // discard all pending events DBG_PRINT("X11: X11Display_DisplayRelease dpy %p\n", dpy); } @@ -321,13 +329,14 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DisplayRelease0 /* * Class: jogamp_newt_driver_x11_DisplayDriver * Method: DispatchMessages - * Signature: (JIJJ)V + * Signature: (JJJ)V */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0 - (JNIEnv *env, jobject obj, jlong display, jlong javaObjectAtom, jlong windowDeleteAtom) + (JNIEnv *env, jobject obj, jlong display, jlong javaObjectAtom, jlong windowDeleteAtom /*, jlong kbdHandle*/) { Display * dpy = (Display *) (intptr_t) display; Atom wm_delete_atom = (Atom)windowDeleteAtom; + // XkbDescPtr kbdDesc = (XkbDescPtr)(intptr_t)kbdHandle; // XKB disabled for now int num_events = 100; int autoRepeatModifiers = 0; @@ -335,6 +344,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage return; } + /** XKB disabled for now + if( NULL == kbdDesc) { + NewtCommon_throwNewRuntimeException(env, "NULL kbd handle, bail out!"); + return; + } */ + // Periodically take a break while( num_events > 0 ) { jobject jwindow = NULL; @@ -344,7 +359,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage jshort javaVKeyUS = 0; jshort javaVKeyNN = 0; jint modifiers = 0; - char keyChar = 0; + uint16_t keyChar = 0; + jstring keyString = NULL; char text[255]; // XEventsQueued(dpy, X): @@ -403,23 +419,43 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage // fall through intended case KeyPress: { KeySym shiftedKeySym; // layout depending keySym w/ SHIFT + KeySym unShiftedKeySym; // layout depending keySym w/o SHIFT + unsigned int xkey_state = evt.xkey.state; keyCode = evt.xkey.keycode; - keySym = XkbKeycodeToKeysym(dpy, keyCode, 0 /* group */, 0 /* shift level */); // layout depending keySym w/o SHIFT - if( XLookupString(&evt.xkey, text, 255, &shiftedKeySym, 0) == 1 ) { - keyChar=text[0]; + // Layout depending keySym w/o SHIFT, + // using fixed group 0 (US default layout) + // + // unsigned int mods_rtrn = 0; + // Bool res = XkbTranslateKeyCode (kbdDesc, keyCode, 0, &mods_rtrn, &keySym); // XKB disabled for now + // if( !res ) { + keySym = XkbKeycodeToKeysym(dpy, keyCode, 0 /* group */, 0 /* shift level */); + // } + + text[0] = 0; text[1] = 0; text[2] = 0; + int charCount = XLookupString(&evt.xkey, text, 2, &shiftedKeySym, NULL); + if( 1 == charCount ) { + keyChar = 0x00FF & (uint16_t) (text[0]); + } else if( 2 == charCount ) { + // Example: UTF-16: 00DF, UTF-8: c3 9f, LATIN SMALL LETTER SHARP S + keyChar = ( 0x00FF & (uint16_t)(text[0]) ) << 8 | ( 0x00FF & (uint16_t)(text[1]) ); // UTF-16BE + keyString = (*env)->NewStringUTF(env, text); } - javaVKeyNN = X11KeySym2NewtVKey(keySym); - javaVKeyUS = javaVKeyNN; // FIXME! - modifiers |= X11InputState2NewtModifiers(evt.xkey.state, javaVKeyNN, evt.type == KeyPress) | autoRepeatModifiers; + evt.xkey.state = evt.xkey.state & ~ShiftMask; // clear shift + XLookupString(&evt.xkey, text, 0, &unShiftedKeySym, NULL); + // unShiftedKeySym = XLookupKeysym(&evt.xkey, 0 /* index ? */); + + javaVKeyNN = X11KeySym2NewtVKey(unShiftedKeySym); + javaVKeyUS = X11KeySym2NewtVKey(keySym); + modifiers |= X11InputState2NewtModifiers(xkey_state, javaVKeyNN, evt.type == KeyPress) | autoRepeatModifiers; #ifdef DEBUG_KEYS - fprintf(stderr, "NEWT X11 Key: keyCode 0x%X keySym 0x%X (shifted: 0x%X), keyChar '%c', javaVKey[US 0x%X, NN 0x%X], xstate 0x%X %u, jmods 0x%X\n", - (int)keyCode, (int)keySym, (int)shiftedKeySym, keyChar, + fprintf(stderr, "NEWT X11 Key: keyCode 0x%X keySym 0x%X, (0x%X, shifted: 0x%X), keyChar '%c' 0x%X %d, javaVKey[US 0x%X, NN 0x%X], xstate 0x%X %u, jmods 0x%X\n", + (int)keyCode, (int)keySym, (int) unShiftedKeySym, (int)shiftedKeySym, keyChar, keyChar, charCount, (int)javaVKeyUS, (int)javaVKeyNN, - (int)evt.xkey.state, (int)evt.xkey.state, (int)modifiers); + (int)xkey_state, (int)xkey_state, (int)modifiers); #endif } break; @@ -463,13 +499,17 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage modifiers, (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jshort) 0, 0.0f /*rotation*/); break; + case MappingNotify: + DBG_PRINT( "X11: event . MappingNotify call %p type %d\n", (void*)evt.xmapping.window, evt.xmapping.type); + XRefreshKeyboardMapping(&evt.xmapping); + break; case KeyPress: (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jshort) EVENT_KEY_PRESSED, - modifiers, javaVKeyUS, javaVKeyNN, (jchar) keyChar); + modifiers, javaVKeyUS, javaVKeyNN, (jchar) keyChar, keyString); break; case KeyRelease: (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jshort) EVENT_KEY_RELEASED, - modifiers, javaVKeyUS, javaVKeyNN, (jchar) keyChar); + modifiers, javaVKeyUS, javaVKeyNN, (jchar) keyChar, keyString); break; case DestroyNotify: DBG_PRINT( "X11: event . DestroyNotify call %p, parent %p, child-event: %d\n", diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 202ad6fff..9e96169f5 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -671,7 +671,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 * Signature: (JJ)V */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0 - (JNIEnv *env, jobject obj, jlong display, jlong window, jlong javaObjectAtom, jlong windowDeleteAtom) + (JNIEnv *env, jobject obj, jlong display, jlong window, jlong javaObjectAtom, jlong windowDeleteAtom /*, jlong kbdHandle*/) // XKB disabled for now { Display * dpy = (Display *) (intptr_t) display; Window w = (Window)window; @@ -698,7 +698,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0 XUnmapWindow(dpy, w); // Drain all events related to this window .. - Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom); + Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom /*, kbdHandle */); // XKB disabled for now XDestroyWindow(dpy, w); XSync(dpy, True); // discard all events now, no more handler -- cgit v1.2.3 From 6755fc707672a77025bcde81a47a5e4d93b37fb1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 8 Apr 2013 22:45:22 +0200 Subject: NEWT KeyEvent: More tight definition of isPrintable(), i.e. must have defined keyCode [and keyChar]; VK_KEYBOARD_INVISIBLE -> isActionKey --- .../classes/com/jogamp/newt/event/KeyEvent.java | 36 ++++++++++++++-------- .../android/event/AndroidNewtEventFactory.java | 4 +-- .../newt/driver/linux/LinuxEventDeviceTracker.java | 2 +- 3 files changed, 26 insertions(+), 16 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 777c9b471..a3613fe2e 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -94,6 +94,9 @@ public class KeyEvent extends InputEvent if( isActionKey(keySym) ) { _flags |= F_ACTION_MASK; } + if( 0 == _flags && VK_UNDEFINED != keySym && NULL_CHAR != keyChar ) { + _flags |= F_PRINTABLE_MASK; + } flags = _flags; } } @@ -261,7 +264,7 @@ public class KeyEvent extends InputEvent case VK_COMPOSE: case VK_BEGIN: - + case VK_KEYBOARD_INVISIBLE: return true; } return false; @@ -279,23 +282,26 @@ public class KeyEvent extends InputEvent } /** - * Returns true if given virtualKey represents a printable character, - * i.e. neither a {@link #isModifierKey(short) modifier key} + * Returns true if given virtualKey represents a printable character, + * i.e. a value other than {@link #VK_UNDEFINED} and neither a {@link #isModifierKey(short) modifier key} * nor an {@link #isActionKey(short) action key}. * Otherwise returns false. */ public static boolean isPrintableKey(short vKey) { - return !isModifierKey(vKey) && !isActionKey(vKey); + return VK_UNDEFINED != vKey && !isModifierKey(vKey) && !isActionKey(vKey); } /** - * Returns true if {@link #getKeySymbol() key symbol} represents a printable character, - * i.e. neither a {@link #isModifierKey(short) modifier key} - * nor an {@link #isActionKey(short) action key}. + * Returns true if {@link #getKeySymbol() key symbol} represents a printable character, + * i.e. a value other than {@link #VK_UNDEFINED} and neither a {@link #isModifierKey(short) modifier key} + * nor an {@link #isActionKey(short) action key}. The {@link #getKeyChar() key char} value must also be + * different than {@link #NULL_CHAR}. + *

    * Otherwise returns false. + *

    */ public final boolean isPrintableKey() { - return 0 == ( F_NON_PRINT_MASK & flags ) ; + return 0 != ( F_PRINTABLE_MASK & flags ) ; } private final short keyCode; @@ -304,7 +310,7 @@ public class KeyEvent extends InputEvent private final byte flags; private static final byte F_MODIFIER_MASK = 1 << 0; private static final byte F_ACTION_MASK = 1 << 1; - private static final byte F_NON_PRINT_MASK = F_MODIFIER_MASK | F_ACTION_MASK ; + private static final byte F_PRINTABLE_MASK = 1 << 2; /** A key has been pressed, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */ public static final short EVENT_KEY_PRESSED = 300; @@ -880,10 +886,14 @@ public class KeyEvent extends InputEvent public static final short VK_KEYBOARD_INVISIBLE = (short) 0xDEAD; /** - * 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. + * This value, {@value}, is used to indicate that the keyCode is unknown. */ - public static final short VK_UNDEFINED = (short) 0x0; + public static final short VK_UNDEFINED = (short) 0x0; + + /** + * This value, {@code '\0'}, is used to indicate that the keyChar is unknown or not printable. + */ + public static final char NULL_CHAR = '\0'; + } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 4c2ed06e8..9638e6a7c 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -155,7 +155,7 @@ public class AndroidNewtEventFactory { } break; } - return (short)0; + return com.jogamp.newt.event.KeyEvent.VK_UNDEFINED; } private static final int aKeyModifiers2Newt(int androidMods) { @@ -211,7 +211,7 @@ public class AndroidNewtEventFactory { } private static com.jogamp.newt.event.KeyEvent createKeyEventImpl(android.view.KeyEvent aEvent, short newtType, short newtKeyCode, com.jogamp.newt.Window newtSource) { - if( (short)0 != newtType && (short)0 != newtKeyCode ) { + if( (short)0 != newtType && com.jogamp.newt.event.KeyEvent.VK_UNDEFINED != newtKeyCode ) { final Object src = null==newtSource ? null : newtSource; final long unixTime = System.currentTimeMillis() + ( aEvent.getEventTime() - android.os.SystemClock.uptimeMillis() ); final int newtMods = aKeyModifiers2Newt(aEvent.getMetaState()); diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index bc69c2204..80b1b6687 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -859,7 +859,7 @@ public class LinuxEventDeviceTracker implements WindowListener { case 239: // UWB break; // FIXME case 240: // unknown - return KeyEvent.VK_UNDEFINED; // FIXME ? + return KeyEvent.VK_UNDEFINED; case 241: // video next break; // FIXME case 242: // video prev -- cgit v1.2.3 From d2fc229b844942646fd9a32fc943923a5770a4be Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 8 Apr 2013 23:02:00 +0200 Subject: Bug 641 NEWT/OSX Deliver keySym, derived from the current layout's lower-case UTF-16 character. --- make/build-newt.xml | 5 +- .../classes/com/jogamp/newt/event/UTFKeyUtil.java | 82 ++++++++++++++++++++++ .../jogamp/newt/driver/macosx/WindowDriver.java | 21 ++++-- src/newt/native/KeyEvent.h | 3 +- src/newt/native/NewtMacWindow.m | 77 ++++++++++++++++++-- 5 files changed, 175 insertions(+), 13 deletions(-) create mode 100644 src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java (limited to 'src/newt/classes') diff --git a/make/build-newt.xml b/make/build-newt.xml index 864e0f93e..c601bc120 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -364,6 +364,8 @@ + + @@ -583,7 +585,8 @@ - + + diff --git a/src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java b/src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java new file mode 100644 index 000000000..73afa0993 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java @@ -0,0 +1,82 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.newt.event; + +import com.jogamp.newt.event.KeyEvent; + +public class UTFKeyUtil { + + // + // UTF Key Constants + // + private static final char UTF_Equal = '='; + private static final char UTF_Minus = '-'; + private static final char UTF_RightBracket = ']'; + private static final char UTF_LeftBracket = '['; + private static final char UTF_Quote = '\''; + private static final char UTF_Semicolon = ';'; + private static final char UTF_Backslash = '\\'; + private static final char UTF_Comma = ','; + private static final char UTF_Slash = '/'; + private static final char UTF_Period = '.'; + private static final char UTF_Grave = '`'; // back quote + + /** + * @param keyChar UTF16 value to map. Note: Lower case values are preferred. + * @return {@link KeyEvent} virtual key (VK) value if possible, + * otherwise simply the UTF16 value of type short as a last resort. + */ + public static short utf16ToVKey(char keyChar) { + if( 'a' <= keyChar && keyChar <= 'z' ) { + return (short) ( ( keyChar - 'a' ) + KeyEvent.VK_A ); + } + if( '0' <= keyChar && keyChar <= '9' ) { + return (short) ( ( keyChar - '0' ) + KeyEvent.VK_0 ); + } + switch(keyChar) { + // + // KeyCodes (Layout Dependent) + // + case UTF_Equal: return KeyEvent.VK_EQUALS; + case UTF_Minus: return KeyEvent.VK_MINUS; + case UTF_RightBracket: return KeyEvent.VK_CLOSE_BRACKET; + case UTF_LeftBracket: return KeyEvent.VK_OPEN_BRACKET; + case UTF_Quote: return KeyEvent.VK_QUOTE; + case UTF_Semicolon: return KeyEvent.VK_SEMICOLON; + case UTF_Backslash: return KeyEvent.VK_BACK_SLASH; + case UTF_Comma: return KeyEvent.VK_COMMA; + case UTF_Slash: return KeyEvent.VK_SLASH; + case UTF_Period: return KeyEvent.VK_PERIOD; + case UTF_Grave: return KeyEvent.VK_BACK_QUOTE; // KeyEvent.VK_DEAD_GRAVE + } + if( 'A' <= keyChar && keyChar <= 'Z' ) { + return (short) ( ( keyChar - 'A' ) + KeyEvent.VK_A ); + } + return (short) keyChar; + } +} diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 965138ddf..b1d18e487 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -51,6 +51,7 @@ import jogamp.newt.driver.DriverUpdatePosition; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.UTFKeyUtil; public class WindowDriver extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { @@ -401,13 +402,25 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } @Override - public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short _keyCode, short keySym, char keyChar) { + public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short _keyCode, short _keySym, char keyChar) { + throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); + } + + protected final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short _keyCode, char keyChar, char keySymChar) { // Note that we send the key char for the key code on this // platform -- we do not get any useful key codes out of the system final short keyCode = MacKeyUtil.validateKeyCode(_keyCode, keyChar); + final short keySym; + { + short _keySym = KeyEvent.NULL_CHAR != keySymChar ? UTFKeyUtil.utf16ToVKey(keySymChar) : KeyEvent.VK_UNDEFINED; + keySym = KeyEvent.VK_UNDEFINED != _keySym ? _keySym : keyCode; + } /* { final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); - System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", key 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)+", mods "+toHexString(modifiers)+ + System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+ + ", keyCode 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)+ + ", keySymChar '"+keySymChar+"', 0x"+Integer.toHexString(keySymChar)+" -> 0x"+Integer.toHexString(keySym)+ + ", mods "+toHexString(modifiers)+ ", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); } */ @@ -426,12 +439,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // key was already pressed keyRepeatState.put(keyCode, true); // prev == false -> AR in modifiers |= InputEvent.AUTOREPEAT_MASK; - super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyCode, keyChar); // RELEASED + super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); // RELEASED } } break; } - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyCode, keyChar); + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keySym, keyChar); } //---------------------------------------------------------------------- diff --git a/src/newt/native/KeyEvent.h b/src/newt/native/KeyEvent.h index 0f7b1606b..946b3c904 100644 --- a/src/newt/native/KeyEvent.h +++ b/src/newt/native/KeyEvent.h @@ -33,7 +33,6 @@ #define EVENT_KEY_RELEASED 301 #define EVENT_KEY_TYPED 302 -#define J_CHAR_UNDEFINED 0xFFFF; #define J_VK_ENTER '\n' #define J_VK_BACK_SPACE '\b' #define J_VK_TAB '\t' @@ -221,7 +220,7 @@ #define J_VK_COMPOSE 0xFF20 #define J_VK_ALT_GRAPH 0xFF7E #define J_VK_BEGIN 0xFF58 -#define J_VK_UNDEFINED 0x0 +#define J_VK_UNDEFINED 0x0 #endif diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index a396c104c..005e82d72 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -36,6 +36,9 @@ #import "KeyEvent.h" #import "MouseEvent.h" +#include +#include /* For kVK_ constants, and TIS functions. */ + #include static jfloat GetDelta(NSEvent *event, jint javaMods[]) { @@ -350,12 +353,71 @@ static jmethodID windowRepaintID = NULL; @end +static CFStringRef CKCH_CreateStringForKey(CGKeyCode keyCode, const UCKeyboardLayout *keyboardLayout) { + UInt32 keysDown = 0; + UniChar chars[4]; + UniCharCount realLength; + + UCKeyTranslate(keyboardLayout, keyCode, + kUCKeyActionDisplay, 0, + LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, + &keysDown, sizeof(chars) / sizeof(chars[0]), &realLength, chars); + + return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1); +} + +static CFMutableDictionaryRef CKCH_CreateCodeToCharDict(TISInputSourceRef keyboard) { + CFDataRef layoutData = (CFDataRef) TISGetInputSourceProperty(keyboard, kTISPropertyUnicodeKeyLayoutData); + const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData); + + CFMutableDictionaryRef codeToCharDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 128, NULL, NULL); + if ( NULL != codeToCharDict ) { + intptr_t i; + for (i = 0; i < 128; ++i) { + CFStringRef string = CKCH_CreateStringForKey((CGKeyCode)i, keyboardLayout); + if( NULL != string ) { + CFIndex stringLen = CFStringGetLength (string); + if ( 0 < stringLen ) { + UniChar character = CFStringGetCharacterAtIndex(string, 0); + DBG_PRINT("CKCH: MAP 0x%X -> %c\n", (int)i, character); + CFDictionaryAddValue(codeToCharDict, (const void *)i, (const void *)(intptr_t)character); + } + CFRelease(string); + } + } + } + return codeToCharDict; +} + +static CFMutableDictionaryRef CKCH_USCodeToNNChar = NULL; + +static void CKCH_CreateDictionaries() { + TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + CKCH_USCodeToNNChar = CKCH_CreateCodeToCharDict(currentKeyboard); + CFRelease(currentKeyboard); +} + +static UniChar CKCH_CharForKeyCode(jshort keyCode) { + UniChar rChar = 0; + + if ( NULL != CKCH_USCodeToNNChar ) { + intptr_t code = (intptr_t) keyCode; + intptr_t character = 0; + + if ( CFDictionaryGetValueIfPresent(CKCH_USCodeToNNChar, (void *)code, (const void **)&character) ) { + rChar = (UniChar) character; + DBG_PRINT("CKCH: OK 0x%X -> 0x%X\n", (int)keyCode, (int)rChar); + } + } + return rChar; +} + @implementation NewtMacWindow + (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz { enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZSIIISF)V"); - enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZSISSC)V"); + enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZSISCC)V"); sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); @@ -367,6 +429,7 @@ static jmethodID windowRepaintID = NULL; if (enqueueMouseEventID && enqueueKeyEventID && sizeChangedID && visibleChangedID && insetsChangedID && positionChangedID && focusChangedID && windowDestroyNotifyID && requestFocusID && windowRepaintID) { + CKCH_CreateDictionaries(); return YES; } return NO; @@ -683,21 +746,22 @@ static jint mods2JavaMods(NSUInteger mods) // printable chars for (i = 0; i < len; i++) { // Note: the key code in the NSEvent does not map to anything we can use - jchar keyChar = (jchar) [chars characterAtIndex: i]; + UniChar keyChar = (UniChar) [chars characterAtIndex: i]; + UniChar keySymChar = CKCH_CharForKeyCode(keyCode); - DBG_PRINT("sendKeyEvent: %d/%d char 0x%X, code 0x%X\n", i, len, (int)keyChar, (int)keyCode); + DBG_PRINT("sendKeyEvent: %d/%d code 0x%X, char 0x%X -> keySymChar 0x%X\n", i, len, (int)keyCode, (int)keyChar, (int)keySymChar); (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, - evType, javaMods, keyCode, keyCode, keyChar); + evType, javaMods, keyCode, (jchar)keyChar, (jchar)keySymChar); } } else { // non-printable chars - jchar keyChar = (jchar) -1; + jchar keyChar = (jchar) 0; DBG_PRINT("sendKeyEvent: code 0x%X\n", (int)keyCode); (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, - evType, javaMods, keyCode, keyCode, keyChar); + evType, javaMods, keyCode, keyChar, keyChar); } /* if (shallBeDetached) { @@ -1094,3 +1158,4 @@ static jint mods2JavaMods(NSUInteger mods) } @end + -- cgit v1.2.3 From 09ebc2cd6fdd317134f0afb38174418a6d067d65 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 8 Apr 2013 23:04:49 +0200 Subject: Bug 641 NEWT: Refine definition of keySym, i.e. for printable keys, keySym is the 'unshifted' UTF-16 char value ; Add isPrintable() to toString(). --- src/newt/classes/com/jogamp/newt/event/KeyEvent.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index a3613fe2e..bda60004e 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -112,6 +112,11 @@ public class KeyEvent extends InputEvent /** * Returns the virtual key symbol reflecting the current keyboard layout. + *

    + * For {@link #isPrintableKey() printable keys}, the key symbol is the unshifted + * representation of the {@link #getKeyChar() UTF-16 key char}. + *

    + * @see #isPrintableKey() * @see #getKeyChar() * @see #getKeyCode() */ @@ -151,7 +156,7 @@ public class KeyEvent extends InputEvent sb = new StringBuilder(); } sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(toHexString(keyCode)).append(", sym ").append(toHexString(keySym)).append(", char '").append(keyChar).append("' (").append(toHexString((short)keyChar)) - .append("), isModifierKey ").append(isModifierKey()).append(", isActionKey ").append(isActionKey()).append(", "); + .append("), printable ").append(isPrintableKey()).append(", modifier ").append(isModifierKey()).append(", action ").append(isActionKey()).append(", "); return super.toString(sb).append("]"); } -- cgit v1.2.3 From e9467722e50b3db835228e6d91d7087b39e9d164 Mon Sep 17 00:00:00 2001 From: Xerxes RÃ¥nby Date: Mon, 8 Apr 2013 16:12:02 +0200 Subject: LinuxEventDeviceTracker: shift-modifier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xerxes RÃ¥nby --- .../newt/driver/linux/LinuxEventDeviceTracker.java | 90 +++++++++++++++------- 1 file changed, 63 insertions(+), 27 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index 80b1b6687..26f87111c 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -124,7 +124,9 @@ public class LinuxEventDeviceTracker implements WindowListener { System.setProperty("newt.debug.Window.KeyEvent", "true"); LinuxEventDeviceTracker.getSingleton(); try { - Thread.sleep(30000); + while(true) { + Thread.sleep(1000); + } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -240,7 +242,7 @@ public class LinuxEventDeviceTracker implements WindowListener { code = s.getShortAt(10); value = s.getIntAt(12); - if(null != focusedWindow) { + /* * Linux sends Keyboard events in the following order: * EV_MSC (optional, contains scancode) @@ -254,53 +256,83 @@ public class LinuxEventDeviceTracker implements WindowListener { eventType = 0; keyCode = KeyEvent.VK_UNDEFINED; keyChar = 0; // Print null for unprintable char. - modifiers = 0; + if(Window.DEBUG_KEY_EVENT) { + System.out.println("[SYN_REPORT----]"); + } break; case 1: // EV_KEY keyCode = LinuxEVKey2NewtVKey(code); // The device independent code. - keyChar = NewtVKey2Unicode(keyCode); // The printable character w/o key modifiers. + keyChar = NewtVKey2Unicode(keyCode, modifiers); // The printable character w/ key modifiers. + if(Window.DEBUG_KEY_EVENT) { + System.out.println("[EV_KEY: [time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); + } + switch(value) { case 0: - modifiers=0; eventType=KeyEvent.EVENT_KEY_RELEASED; - focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); + + if(keyCode == KeyEvent.VK_SHIFT){ + System.out.println("release-shift"); + modifiers &= ~InputEvent.SHIFT_MASK; + } + + if(null != focusedWindow) { + focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); + } + if(Window.DEBUG_KEY_EVENT) { + System.out.println("[event released] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); + } break; case 1: eventType=KeyEvent.EVENT_KEY_PRESSED; - focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); + + if(keyCode == KeyEvent.VK_SHIFT){ + modifiers |= InputEvent.SHIFT_MASK; + } + + if(null != focusedWindow) { + focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); + } + if(Window.DEBUG_KEY_EVENT) { + System.out.println("[event pressed] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); + } break; case 2: eventType=KeyEvent.EVENT_KEY_PRESSED; - modifiers=InputEvent.AUTOREPEAT_MASK; - - //Send syntetic autorepeat release - focusedWindow.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyCode, keyChar); - - focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); + modifiers |= InputEvent.AUTOREPEAT_MASK; + if(keyCode == KeyEvent.VK_SHIFT){ + modifiers |= InputEvent.SHIFT_MASK; + } + + if(null != focusedWindow) { + //Send syntetic autorepeat release + focusedWindow.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyCode, keyChar); + + focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); + } + if(Window.DEBUG_KEY_EVENT) { + System.out.println("[event released auto] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); + System.out.println("[event pressed auto] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); + } + modifiers &= ~InputEvent.AUTOREPEAT_MASK; break; } break; case 4: // EV_MSC if(code==4) { // MSC_SCAN // scancode ignore, linux kernel specific - // keyCode = value; } break; // TODO: handle joystick events // TODO: handle mouse events // TODO: handle headphone/hdmi connector events - } - - if(Window.DEBUG_KEY_EVENT) { - System.out.println("[time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); - } - - } else { - if(Window.DEBUG_KEY_EVENT) { - System.out.println("[time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); + default: // Print number. + if(Window.DEBUG_KEY_EVENT) { + System.out.println("TODO EventDevicePoller: [time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); + } } } - } + if(null != fis) { try { fis.close(); @@ -310,9 +342,13 @@ public class LinuxEventDeviceTracker implements WindowListener { stop=true; } - private char NewtVKey2Unicode(short VK){ + private char NewtVKey2Unicode(short VK, int modifiers){ if( KeyEvent.isPrintableKey(VK) ){ - return (char)VK; + if((modifiers & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) { + return (char)VK; + } else { + return (((char)VK) + "").toLowerCase().charAt(0); + } } return 0; } @@ -881,7 +917,7 @@ public class LinuxEventDeviceTracker implements WindowListener { } if(Window.DEBUG_KEY_EVENT) { - System.out.println("LinuxEVKey2NewtVKey: Unmapped EVKey "+EVKey); + System.out.println("TODO LinuxEVKey2NewtVKey: Unmapped EVKey "+EVKey); } return KeyEvent.VK_UNDEFINED; -- cgit v1.2.3 From dc049d5ab60c856576ee7dd58d3cc36da9f9780b Mon Sep 17 00:00:00 2001 From: Xerxes RÃ¥nby Date: Mon, 8 Apr 2013 16:28:49 +0200 Subject: LinuxEventDeviceTracker: 4 space indentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xerxes RÃ¥nby --- .../newt/driver/linux/LinuxEventDeviceTracker.java | 1596 ++++++++++---------- 1 file changed, 798 insertions(+), 798 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index 26f87111c..8651c2551 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -57,21 +57,21 @@ import com.jogamp.newt.event.KeyEvent; public class LinuxEventDeviceTracker implements WindowListener { - private static final LinuxEventDeviceTracker ledt; + private static final LinuxEventDeviceTracker ledt; - static { - ledt = new LinuxEventDeviceTracker(); - final Thread t = new Thread(ledt.eventDeviceManager, "NEWT-LinuxEventDeviceManager"); - t.setDaemon(true); - t.start(); - } + static { + ledt = new LinuxEventDeviceTracker(); + final Thread t = new Thread(ledt.eventDeviceManager, "NEWT-LinuxEventDeviceManager"); + t.setDaemon(true); + t.start(); + } - public static LinuxEventDeviceTracker getSingleton() { - return ledt; - } + public static LinuxEventDeviceTracker getSingleton() { + return ledt; + } - private WindowImpl focusedWindow = null; + private WindowImpl focusedWindow = null; private EventDeviceManager eventDeviceManager = new EventDeviceManager(); /* @@ -85,63 +85,63 @@ public class LinuxEventDeviceTracker implements WindowListener { And so on up to event31. */ - private EventDevicePoller[] eventDevicePollers = new EventDevicePoller[32]; - - @Override - public void windowResized(WindowEvent e) { } - - @Override - public void windowMoved(WindowEvent e) { } - - @Override - public void windowDestroyNotify(WindowEvent e) { - Object s = e.getSource(); - if(focusedWindow == s) { - focusedWindow = null; - } - } - - @Override - public void windowDestroyed(WindowEvent e) { } - - @Override - public void windowGainedFocus(WindowEvent e) { - Object s = e.getSource(); - if(s instanceof WindowImpl) { - focusedWindow = (WindowImpl) s; - } - } - - @Override - public void windowLostFocus(WindowEvent e) { - Object s = e.getSource(); - if(focusedWindow == s) { - focusedWindow = null; - } - } - - public static void main(String[] args ){ - System.setProperty("newt.debug.Window.KeyEvent", "true"); - LinuxEventDeviceTracker.getSingleton(); - try { - while(true) { - Thread.sleep(1000); - } - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Override - public void windowRepaint(WindowUpdateEvent e) { } + private EventDevicePoller[] eventDevicePollers = new EventDevicePoller[32]; + + @Override + public void windowResized(WindowEvent e) { } + + @Override + public void windowMoved(WindowEvent e) { } + + @Override + public void windowDestroyNotify(WindowEvent e) { + Object s = e.getSource(); + if(focusedWindow == s) { + focusedWindow = null; + } + } + + @Override + public void windowDestroyed(WindowEvent e) { } + + @Override + public void windowGainedFocus(WindowEvent e) { + Object s = e.getSource(); + if(s instanceof WindowImpl) { + focusedWindow = (WindowImpl) s; + } + } + + @Override + public void windowLostFocus(WindowEvent e) { + Object s = e.getSource(); + if(focusedWindow == s) { + focusedWindow = null; + } + } + + public static void main(String[] args ){ + System.setProperty("newt.debug.Window.KeyEvent", "true"); + LinuxEventDeviceTracker.getSingleton(); + try { + while(true) { + Thread.sleep(1000); + } + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void windowRepaint(WindowUpdateEvent e) { } class EventDeviceManager implements Runnable { private volatile boolean stop = false; @Override - public void run() { + public void run() { File f = new File("/dev/input/"); int number; while(!stop){ @@ -171,7 +171,7 @@ public class LinuxEventDeviceTracker implements WindowListener { } } - class EventDevicePoller implements Runnable { + class EventDevicePoller implements Runnable { private volatile boolean stop = false; private String eventDeviceName; @@ -180,747 +180,747 @@ public class LinuxEventDeviceTracker implements WindowListener { this.eventDeviceName="/dev/input/event"+eventDeviceNumber; } - @Override - public void run() { - final byte[] b = new byte[16]; - /** - * The Linux input event interface. - * http://www.kernel.org/doc/Documentation/input/input.txt - * - * struct input_event { - * struct timeval time; - * unsigned short type; - * unsigned short code; - * unsigned int value; - * }; - */ - ByteBuffer bb = ByteBuffer.wrap(b); - StructAccessor s = new StructAccessor(bb); - final File f = new File(eventDeviceName); - f.setReadOnly(); - InputStream fis; - try { - fis = new FileInputStream(f); - } catch (FileNotFoundException e) { + @Override + public void run() { + final byte[] b = new byte[16]; + /** + * The Linux input event interface. + * http://www.kernel.org/doc/Documentation/input/input.txt + * + * struct input_event { + * struct timeval time; + * unsigned short type; + * unsigned short code; + * unsigned int value; + * }; + */ + ByteBuffer bb = ByteBuffer.wrap(b); + StructAccessor s = new StructAccessor(bb); + final File f = new File(eventDeviceName); + f.setReadOnly(); + InputStream fis; + try { + fis = new FileInputStream(f); + } catch (FileNotFoundException e) { stop=true; - return; - } + return; + } - int timeSeconds; - int timeSecondFraction; - short type; - short code; - int value; + int timeSeconds; + int timeSecondFraction; + short type; + short code; + int value; - short keyCode=KeyEvent.VK_UNDEFINED; - char keyChar=' '; - short eventType=0; - int modifiers=0; + short keyCode=KeyEvent.VK_UNDEFINED; + char keyChar=' '; + short eventType=0; + int modifiers=0; loop: - while(!stop) { - int remaining=16; - while(remaining>0) { - int read = 0; - try { - read = fis.read(b, 0, remaining); - } catch (IOException e) { - stop = true; - break loop; - } - if(read<0) { - stop = true; // EOF of event device file !? - break loop; - } else { - remaining -= read; - } - } - - timeSeconds = s.getIntAt(0); - timeSecondFraction = s.getShortAt(4); - type = s.getShortAt(8); - code = s.getShortAt(10); - value = s.getIntAt(12); - - - /* - * Linux sends Keyboard events in the following order: - * EV_MSC (optional, contains scancode) - * EV_KEY - * SYN_REPORT (sent before next key) - */ - - switch(type) { - case 0: // SYN_REPORT - // Clear - eventType = 0; - keyCode = KeyEvent.VK_UNDEFINED; - keyChar = 0; // Print null for unprintable char. - if(Window.DEBUG_KEY_EVENT) { - System.out.println("[SYN_REPORT----]"); - } - break; - case 1: // EV_KEY - keyCode = LinuxEVKey2NewtVKey(code); // The device independent code. - keyChar = NewtVKey2Unicode(keyCode, modifiers); // The printable character w/ key modifiers. - if(Window.DEBUG_KEY_EVENT) { - System.out.println("[EV_KEY: [time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); - } - - switch(value) { - case 0: - eventType=KeyEvent.EVENT_KEY_RELEASED; - - if(keyCode == KeyEvent.VK_SHIFT){ - System.out.println("release-shift"); - modifiers &= ~InputEvent.SHIFT_MASK; - } - - if(null != focusedWindow) { - focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); - } - if(Window.DEBUG_KEY_EVENT) { - System.out.println("[event released] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); - } - break; - case 1: - eventType=KeyEvent.EVENT_KEY_PRESSED; - - if(keyCode == KeyEvent.VK_SHIFT){ - modifiers |= InputEvent.SHIFT_MASK; - } - - if(null != focusedWindow) { - focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); - } - if(Window.DEBUG_KEY_EVENT) { - System.out.println("[event pressed] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); - } - break; - case 2: - eventType=KeyEvent.EVENT_KEY_PRESSED; - modifiers |= InputEvent.AUTOREPEAT_MASK; - if(keyCode == KeyEvent.VK_SHIFT){ - modifiers |= InputEvent.SHIFT_MASK; - } - - if(null != focusedWindow) { - //Send syntetic autorepeat release - focusedWindow.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyCode, keyChar); - - focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); - } - if(Window.DEBUG_KEY_EVENT) { - System.out.println("[event released auto] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); - System.out.println("[event pressed auto] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); - } - modifiers &= ~InputEvent.AUTOREPEAT_MASK; - break; - } - break; - case 4: // EV_MSC - if(code==4) { // MSC_SCAN - // scancode ignore, linux kernel specific - } - break; - // TODO: handle joystick events - // TODO: handle mouse events - // TODO: handle headphone/hdmi connector events - default: // Print number. - if(Window.DEBUG_KEY_EVENT) { - System.out.println("TODO EventDevicePoller: [time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); - } - } - } - - if(null != fis) { - try { - fis.close(); - } catch (IOException e) { - } - } + while(!stop) { + int remaining=16; + while(remaining>0) { + int read = 0; + try { + read = fis.read(b, 0, remaining); + } catch (IOException e) { + stop = true; + break loop; + } + if(read<0) { + stop = true; // EOF of event device file !? + break loop; + } else { + remaining -= read; + } + } + + timeSeconds = s.getIntAt(0); + timeSecondFraction = s.getShortAt(4); + type = s.getShortAt(8); + code = s.getShortAt(10); + value = s.getIntAt(12); + + + /* + * Linux sends Keyboard events in the following order: + * EV_MSC (optional, contains scancode) + * EV_KEY + * SYN_REPORT (sent before next key) + */ + + switch(type) { + case 0: // SYN_REPORT + // Clear + eventType = 0; + keyCode = KeyEvent.VK_UNDEFINED; + keyChar = 0; // Print null for unprintable char. + if(Window.DEBUG_KEY_EVENT) { + System.out.println("[SYN_REPORT----]"); + } + break; + case 1: // EV_KEY + keyCode = LinuxEVKey2NewtVKey(code); // The device independent code. + keyChar = NewtVKey2Unicode(keyCode, modifiers); // The printable character w/ key modifiers. + if(Window.DEBUG_KEY_EVENT) { + System.out.println("[EV_KEY: [time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); + } + + switch(value) { + case 0: + eventType=KeyEvent.EVENT_KEY_RELEASED; + + if(keyCode == KeyEvent.VK_SHIFT){ + System.out.println("release-shift"); + modifiers &= ~InputEvent.SHIFT_MASK; + } + + if(null != focusedWindow) { + focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); + } + if(Window.DEBUG_KEY_EVENT) { + System.out.println("[event released] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); + } + break; + case 1: + eventType=KeyEvent.EVENT_KEY_PRESSED; + + if(keyCode == KeyEvent.VK_SHIFT){ + modifiers |= InputEvent.SHIFT_MASK; + } + + if(null != focusedWindow) { + focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); + } + if(Window.DEBUG_KEY_EVENT) { + System.out.println("[event pressed] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); + } + break; + case 2: + eventType=KeyEvent.EVENT_KEY_PRESSED; + modifiers |= InputEvent.AUTOREPEAT_MASK; + if(keyCode == KeyEvent.VK_SHIFT){ + modifiers |= InputEvent.SHIFT_MASK; + } + + if(null != focusedWindow) { + //Send syntetic autorepeat release + focusedWindow.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyCode, keyChar); + + focusedWindow.sendKeyEvent(eventType, modifiers, keyCode, keyCode, keyChar); + } + if(Window.DEBUG_KEY_EVENT) { + System.out.println("[event released auto] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); + System.out.println("[event pressed auto] keyCode: "+keyCode+" keyChar: "+keyChar+ " modifiers: "+modifiers); + } + modifiers &= ~InputEvent.AUTOREPEAT_MASK; + break; + } + break; + case 4: // EV_MSC + if(code==4) { // MSC_SCAN + // scancode ignore, linux kernel specific + } + break; + // TODO: handle joystick events + // TODO: handle mouse events + // TODO: handle headphone/hdmi connector events + default: // Print number. + if(Window.DEBUG_KEY_EVENT) { + System.out.println("TODO EventDevicePoller: [time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); + } + } + } + + if(null != fis) { + try { + fis.close(); + } catch (IOException e) { + } + } stop=true; - } - - private char NewtVKey2Unicode(short VK, int modifiers){ - if( KeyEvent.isPrintableKey(VK) ){ - if((modifiers & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) { - return (char)VK; - } else { - return (((char)VK) + "").toLowerCase().charAt(0); - } - } - return 0; - } - - @SuppressWarnings("unused") + } + + private char NewtVKey2Unicode(short VK, int modifiers) { + if( KeyEvent.isPrintableKey(VK) ) { + if((modifiers & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) { + return (char)VK; + } else { + return (((char)VK) + "").toLowerCase().charAt(0); + } + } + return 0; + } + + @SuppressWarnings("unused") private char LinuxEVKey2Unicode(short EVKey) { - // This is the stuff normally mapped by a system keymap - - switch(EVKey){ - case 17: // w - return 'w'; - case 31: // s - return 's'; - case 30: // a - return 'a'; - case 32: // d - return 'd'; - case 1: // ESC - return 27; - case 28: // Enter - case 96: // Keypad Enter - return '\n'; - case 57: // Space - return ' '; - case 11: // 0 - case 82: // Numpad 0 - return '0'; - case 2: // 1 - case 79: // Numpad 1 - return '1'; - case 3: // 2 - case 80: // Numpad 1 - return '2'; - case 4: // 3 - case 81: // Numpad 3 - return '3'; - case 5: // 4 - case 75: // Numpad 4 - return '4'; - case 6: // 5 - case 76: // Numpad 5 - return '5'; - case 7: // 6 - case 77: // Numpad 6 - return '6'; - case 8: // 7 - case 71: // Numpad 7 - return '7'; - case 9: // 8 - case 72: // Numpad 8 - return '8'; - case 10: // 9 - case 73: // Numpad 9 - return '9'; - - default: - } - - return 0; - } - - private short LinuxEVKey2NewtVKey(short EVKey) { - - switch(EVKey) { - case 1: // ESC - return KeyEvent.VK_ESCAPE; - case 2: // 1 - return KeyEvent.VK_1; - case 79: // Numpad 1 - return KeyEvent.VK_NUMPAD1; - case 3: // 2 - return KeyEvent.VK_2; - case 80: // Numpad 2 - return KeyEvent.VK_NUMPAD2; - case 4: // 3 - return KeyEvent.VK_3; - case 81: // Numpad 3 - return KeyEvent.VK_NUMPAD3; - case 5: // 4 - return KeyEvent.VK_4; - case 75: // Numpad 4 - return KeyEvent.VK_NUMPAD4; - case 6: // 5 - return KeyEvent.VK_5; - case 76: // Numpad 5 - return KeyEvent.VK_NUMPAD5; - case 7: // 6 - return KeyEvent.VK_6; - case 77: // Numpad 6 - return KeyEvent.VK_NUMPAD6; - case 8: // 7 - return KeyEvent.VK_7; - case 71: // Numpad 7 - return KeyEvent.VK_NUMPAD7; - case 9: // 8 - return KeyEvent.VK_8; - case 72: // Numpad 8 - return KeyEvent.VK_NUMPAD8; - case 10: // 9 - return KeyEvent.VK_9; - case 73: // Numpad 9 - return KeyEvent.VK_NUMPAD9; - case 11: // 0 - return KeyEvent.VK_0; - case 82: // Numpad 0 - return KeyEvent.VK_NUMPAD0; - case 12: - return KeyEvent.VK_MINUS; - case 13: - return KeyEvent.VK_EQUALS; - case 14: // Backspace - return KeyEvent.VK_BACK_SPACE; - - case 15: - return KeyEvent.VK_TAB; - case 16: - return KeyEvent.VK_Q; - case 17: // w - return KeyEvent.VK_W; - case 18: - return KeyEvent.VK_E; - case 19: - return KeyEvent.VK_R; - case 20: - return KeyEvent.VK_T; - case 21: - return KeyEvent.VK_Y; - case 22: - return KeyEvent.VK_U; - case 23: - return KeyEvent.VK_I; - case 24: - return KeyEvent.VK_O; - case 25: - return KeyEvent.VK_P; - case 26: // left brace - return KeyEvent.VK_LEFT_PARENTHESIS; - case 27: // right brace - return KeyEvent.VK_RIGHT_PARENTHESIS; - case 28: // Enter - case 96: // Keypad Enter - return KeyEvent.VK_ENTER; - - case 29: // left ctrl - return KeyEvent.VK_CONTROL; - case 30: // a - return KeyEvent.VK_A; - case 31: // s - return KeyEvent.VK_S; - case 32: // d - return KeyEvent.VK_D; - case 33: - return KeyEvent.VK_F; - case 34: - return KeyEvent.VK_G; - case 35: - return KeyEvent.VK_H; - case 36: - return KeyEvent.VK_J; - case 37: - return KeyEvent.VK_K; - case 38: - return KeyEvent.VK_L; - case 39: - return KeyEvent.VK_SEMICOLON; - case 40: // apostrophe - return KeyEvent.VK_DEAD_ACUTE; - case 41: // grave - return KeyEvent.VK_DEAD_GRAVE; - - case 42: // left shift - return KeyEvent.VK_SHIFT; - case 43: - return KeyEvent.VK_BACK_SLASH; - case 44: - return KeyEvent.VK_Z; - case 45: - return KeyEvent.VK_X; - case 46: - return KeyEvent.VK_C; - case 47: - return KeyEvent.VK_V; - case 48: - return KeyEvent.VK_B; - case 49: - return KeyEvent.VK_N; - case 50: - return KeyEvent.VK_M; - case 51: - return KeyEvent.VK_COMMA; - case 52: // dot - return KeyEvent.VK_PERIOD; - case 53: - return KeyEvent.VK_SLASH; - case 54: - return KeyEvent.VK_SHIFT; - case 55: // kp asterisk - return KeyEvent.VK_ASTERISK; - case 56: // left alt - return KeyEvent.VK_ALT; - case 57: // Space - return KeyEvent.VK_SPACE; - case 58: - return KeyEvent.VK_CAPS_LOCK; - - case 59: - return KeyEvent.VK_F1; - case 60: - return KeyEvent.VK_F2; - case 61: - return KeyEvent.VK_F3; - case 62: - return KeyEvent.VK_F4; - case 63: - return KeyEvent.VK_F5; - case 64: - return KeyEvent.VK_F6; - case 65: - return KeyEvent.VK_F7; - case 66: - return KeyEvent.VK_F8; - case 67: - return KeyEvent.VK_F9; - case 68: - return KeyEvent.VK_F10; - - case 69: - return KeyEvent.VK_NUM_LOCK; - case 70: - return KeyEvent.VK_SCROLL_LOCK; - - case 74: // kp minus - return KeyEvent.VK_MINUS; - case 78: // kp plus - return KeyEvent.VK_PLUS; - case 83: // kp dot - return KeyEvent.VK_PERIOD; - - // TODO: add mappings for japanese special buttons - case 85: // zenkakuhankaku - case 86: // 102nd - break; // FIXME - - case 87: - return KeyEvent.VK_F11; - case 88: - return KeyEvent.VK_F12; - - case 89: // ro - return KeyEvent.VK_ROMAN_CHARACTERS; - case 90: // Katakana - return KeyEvent.VK_KATAKANA; - case 91: - return KeyEvent.VK_HIRAGANA; - - case 92: // kenkan - break; // FIXME - case 93: // katakana hiragana - break; // FIXME - case 94: // mu henkan - break; // FIXME - case 95: // kp jp comma - break; // FIXME - - case 97: // right ctrl - return KeyEvent.VK_CONTROL; - case 98: // kp slash - return KeyEvent.VK_SLASH; - - case 99: // sysrq - break; // FIXME - - case 100: // right alt - return KeyEvent.VK_ALT_GRAPH; - case 101: // linefeed - break; // FIXME - case 102: // home - return KeyEvent.VK_HOME; - case 103: // KEY_UP - return KeyEvent.VK_UP; - case 104: - return KeyEvent.VK_PAGE_UP; - case 105: // KEY_LEFT - return KeyEvent.VK_LEFT; - case 106: // KEY_RIGHT - return KeyEvent.VK_RIGHT; - case 107: - return KeyEvent.VK_END; - case 108: // KEY_DOWN - return KeyEvent.VK_DOWN; - case 109: - return KeyEvent.VK_PAGE_DOWN; - case 110: - return KeyEvent.VK_INSERT; - case 111: // del - return KeyEvent.VK_DELETE; - - case 112: // macro - break; // FIXME DEAD_MACRON? - case 113: // mute - break; // FIXME - case 114: // vol up - break; // FIXME - case 115: // vol down - break; // FIXME - case 116: // power - break; // FIXME - - case 117: // kp equals - return KeyEvent.VK_EQUALS; - case 118: // kp plus minux - break; // FIXME - case 119: // pause - return KeyEvent.VK_PAUSE; - case 120: // scale AL compiz scale expose - break; // FIXME - case 121: // kp comma - return KeyEvent.VK_COMMA; - case 122: // hangeul - break; // FIXME - case 123: // hanja - break; // FIXME - case 124: // yen - break; // FIXME - - case 125: // left meta - case 126: // right meta - return KeyEvent.VK_META; - case 127: // compose - return KeyEvent.VK_COMPOSE; - - case 128: // stop - return KeyEvent.VK_STOP; - case 129: // again - return KeyEvent.VK_AGAIN; - case 130: // properties - return KeyEvent.VK_PROPS; - case 131: // undo - return KeyEvent.VK_UNDO; - case 132: // front - break; // FIXME - case 133: // copy - return KeyEvent.VK_COPY; - case 134: // open - break; // FIXME - case 135: // paste - return KeyEvent.VK_PASTE; - case 136: // find - return KeyEvent.VK_FIND; - case 137: // cut - return KeyEvent.VK_CUT; - case 138: // help - return KeyEvent.VK_HELP; - case 139: // menu - break; // FIXME - case 140: // calc - break; // FIXME - case 141: // setup - break; // FIXME - case 142: // sleep - break; // FIXME - case 143: // wakeup - break; // FIXME - case 144: // file - break; // FIXME - case 145: // send file - break; // FIXME - case 146: // delete file - break; // FIXME - case 147: // xfer - break; // FIXME - case 148: // prog1 - break; // FIXME - case 149: // prog2 - break; // FIXME - case 150: // www - break; // FIXME - case 151: // msdos - break; // FIXME - case 152: // coffee - break; // FIXME - case 153: // direction - break; // FIXME - case 154: // cycle windows - break; // FIXME - case 155: // mail - break; // FIXME - case 156: // bookmarks - break; // FIXME - case 157: // computer - break; // FIXME - case 158: // back - break; // FIXME - case 159: // forward - break; // FIXME - case 160: // close cd - break; // FIXME - case 161: // eject cd - break; // FIXME - case 162: // eject close cd - break; // FIXME - case 163: // next song - break; // FIXME - case 164: // play pause - break; // FIXME - case 165: // previous song - break; // FIXME - case 166: // stop cd - break; // FIXME - case 167: // record - break; // FIXME - case 168: // rewind - break; // FIXME - case 169: // phone - break; // FIXME - case 170: // ISO - break; // FIXME - case 171: // config - break; // FIXME - case 172: // home page - break; // FIXME - case 173: // refresh - break; // FIXME - case 174: // exit - break; // FIXME - case 175: // move - break; // FIXME - case 176: // edit - break; // FIXME - case 177: // scroll up - break; // FIXME PAGE_UP? - case 178: // scroll down - break; // FIXME PAGE_DOWN? - case 179: // kp left paren - return KeyEvent.VK_LEFT_PARENTHESIS; - case 180: // kp right paren - return KeyEvent.VK_RIGHT_PARENTHESIS; - case 181: // new - break; // FIXME - case 182: // redo - break; // FIXME - - case 183: // F13 - return KeyEvent.VK_F13; - case 184: // F14 - return KeyEvent.VK_F14; - case 185: // F15 - return KeyEvent.VK_F15; - case 186: // F16 - return KeyEvent.VK_F16; - case 187: // F17 - return KeyEvent.VK_F17; - case 188: // F18 - return KeyEvent.VK_F18; - case 189: // F19 - return KeyEvent.VK_F19; - case 190: // F20 - return KeyEvent.VK_F20; - case 191: // F21 - return KeyEvent.VK_F21; - case 192: // F22 - return KeyEvent.VK_F22; - case 193: // F23 - return KeyEvent.VK_F23; - case 194: // F24 - return KeyEvent.VK_F24; - - case 200: // play cd - break; // FIXME - case 201: // pause cd - break; // FIXME - case 202: // prog 3 - break; // FIXME - case 203: // prog 4 - break; // FIXME - case 204: // dashboard - break; // FIXME - case 205: // suspend - break; // FIXME - case 206: // close - break; // FIXME - case 207: // play - break; // FIXME - case 208: // fast forward - break; // FIXME - case 210: // print - return KeyEvent.VK_PRINTSCREEN; // FIXME ? - case 211: // HP - break; // FIXME - case 212: // camera - break; // FIXME - case 213: // sound - break; // FIXME - case 214: // question - break; // FIXME - case 215: // email - break; // FIXME - case 216: // chat - break; // FIXME - case 217: // search - break; // FIXME - case 218: // connect - break; // FIXME - case 219: // finance - break; // FIXME - case 220: // sport - break; // FIXME - case 221: // shop - break; // FIXME - case 222: // alt erase - break; // FIXME - case 223: // cancel - break; // FIXME - case 224: // brightness down - break; // FIXME - case 225: // brightness up - break; // FIXME - case 226: // media - break; // FIXME - case 227: // switch video mode - break; // FIXME - case 228: // kb dillum toggle - break; // FIXME - case 229: // kb dillum down - break; // FIXME - case 230: // kb dillum up - break; // FIXME - case 231: // send - break; // FIXME - case 232: // reply - break; // FIXME - case 233: // forward mail - break; // FIXME - case 234: // save - break; // FIXME - case 235: // documents - break; // FIXME - case 236: // battery - break; // FIXME - case 237: // bluetooth - break; // FIXME - case 238: // wlan - break; // FIXME - case 239: // UWB - break; // FIXME - case 240: // unknown - return KeyEvent.VK_UNDEFINED; - case 241: // video next - break; // FIXME - case 242: // video prev - break; // FIXME - case 243: // brightness cycle - break; // FIXME - case 244: // brightness zero - break; // FIXME - case 245: // display off - break; // FIXME - case 246: // wimax - break; // FIXME - case 247: // rf kill radio off - break; // FIXME - case 248: // mic mute - break; // FIXME - - default: - } - - if(Window.DEBUG_KEY_EVENT) { - System.out.println("TODO LinuxEVKey2NewtVKey: Unmapped EVKey "+EVKey); - } - + // This is the stuff normally mapped by a system keymap + + switch(EVKey) { + case 17: // w + return 'w'; + case 31: // s + return 's'; + case 30: // a + return 'a'; + case 32: // d + return 'd'; + case 1: // ESC + return 27; + case 28: // Enter + case 96: // Keypad Enter + return '\n'; + case 57: // Space + return ' '; + case 11: // 0 + case 82: // Numpad 0 + return '0'; + case 2: // 1 + case 79: // Numpad 1 + return '1'; + case 3: // 2 + case 80: // Numpad 1 + return '2'; + case 4: // 3 + case 81: // Numpad 3 + return '3'; + case 5: // 4 + case 75: // Numpad 4 + return '4'; + case 6: // 5 + case 76: // Numpad 5 + return '5'; + case 7: // 6 + case 77: // Numpad 6 + return '6'; + case 8: // 7 + case 71: // Numpad 7 + return '7'; + case 9: // 8 + case 72: // Numpad 8 + return '8'; + case 10: // 9 + case 73: // Numpad 9 + return '9'; + + default: + } + + return 0; + } + + private short LinuxEVKey2NewtVKey(short EVKey) { + + switch(EVKey) { + case 1: // ESC + return KeyEvent.VK_ESCAPE; + case 2: // 1 + return KeyEvent.VK_1; + case 79: // Numpad 1 + return KeyEvent.VK_NUMPAD1; + case 3: // 2 + return KeyEvent.VK_2; + case 80: // Numpad 2 + return KeyEvent.VK_NUMPAD2; + case 4: // 3 + return KeyEvent.VK_3; + case 81: // Numpad 3 + return KeyEvent.VK_NUMPAD3; + case 5: // 4 + return KeyEvent.VK_4; + case 75: // Numpad 4 + return KeyEvent.VK_NUMPAD4; + case 6: // 5 + return KeyEvent.VK_5; + case 76: // Numpad 5 + return KeyEvent.VK_NUMPAD5; + case 7: // 6 + return KeyEvent.VK_6; + case 77: // Numpad 6 + return KeyEvent.VK_NUMPAD6; + case 8: // 7 + return KeyEvent.VK_7; + case 71: // Numpad 7 + return KeyEvent.VK_NUMPAD7; + case 9: // 8 + return KeyEvent.VK_8; + case 72: // Numpad 8 + return KeyEvent.VK_NUMPAD8; + case 10: // 9 + return KeyEvent.VK_9; + case 73: // Numpad 9 + return KeyEvent.VK_NUMPAD9; + case 11: // 0 + return KeyEvent.VK_0; + case 82: // Numpad 0 + return KeyEvent.VK_NUMPAD0; + case 12: + return KeyEvent.VK_MINUS; + case 13: + return KeyEvent.VK_EQUALS; + case 14: // Backspace + return KeyEvent.VK_BACK_SPACE; + + case 15: + return KeyEvent.VK_TAB; + case 16: + return KeyEvent.VK_Q; + case 17: // w + return KeyEvent.VK_W; + case 18: + return KeyEvent.VK_E; + case 19: + return KeyEvent.VK_R; + case 20: + return KeyEvent.VK_T; + case 21: + return KeyEvent.VK_Y; + case 22: + return KeyEvent.VK_U; + case 23: + return KeyEvent.VK_I; + case 24: + return KeyEvent.VK_O; + case 25: + return KeyEvent.VK_P; + case 26: // left brace + return KeyEvent.VK_LEFT_PARENTHESIS; + case 27: // right brace + return KeyEvent.VK_RIGHT_PARENTHESIS; + case 28: // Enter + case 96: // Keypad Enter + return KeyEvent.VK_ENTER; + + case 29: // left ctrl + return KeyEvent.VK_CONTROL; + case 30: // a + return KeyEvent.VK_A; + case 31: // s + return KeyEvent.VK_S; + case 32: // d + return KeyEvent.VK_D; + case 33: + return KeyEvent.VK_F; + case 34: + return KeyEvent.VK_G; + case 35: + return KeyEvent.VK_H; + case 36: + return KeyEvent.VK_J; + case 37: + return KeyEvent.VK_K; + case 38: + return KeyEvent.VK_L; + case 39: + return KeyEvent.VK_SEMICOLON; + case 40: // apostrophe + return KeyEvent.VK_DEAD_ACUTE; + case 41: // grave + return KeyEvent.VK_DEAD_GRAVE; + + case 42: // left shift + return KeyEvent.VK_SHIFT; + case 43: + return KeyEvent.VK_BACK_SLASH; + case 44: + return KeyEvent.VK_Z; + case 45: + return KeyEvent.VK_X; + case 46: + return KeyEvent.VK_C; + case 47: + return KeyEvent.VK_V; + case 48: + return KeyEvent.VK_B; + case 49: + return KeyEvent.VK_N; + case 50: + return KeyEvent.VK_M; + case 51: + return KeyEvent.VK_COMMA; + case 52: // dot + return KeyEvent.VK_PERIOD; + case 53: + return KeyEvent.VK_SLASH; + case 54: + return KeyEvent.VK_SHIFT; + case 55: // kp asterisk + return KeyEvent.VK_ASTERISK; + case 56: // left alt + return KeyEvent.VK_ALT; + case 57: // Space + return KeyEvent.VK_SPACE; + case 58: + return KeyEvent.VK_CAPS_LOCK; + + case 59: + return KeyEvent.VK_F1; + case 60: + return KeyEvent.VK_F2; + case 61: + return KeyEvent.VK_F3; + case 62: + return KeyEvent.VK_F4; + case 63: + return KeyEvent.VK_F5; + case 64: + return KeyEvent.VK_F6; + case 65: + return KeyEvent.VK_F7; + case 66: + return KeyEvent.VK_F8; + case 67: + return KeyEvent.VK_F9; + case 68: + return KeyEvent.VK_F10; + + case 69: + return KeyEvent.VK_NUM_LOCK; + case 70: + return KeyEvent.VK_SCROLL_LOCK; + + case 74: // kp minus + return KeyEvent.VK_MINUS; + case 78: // kp plus + return KeyEvent.VK_PLUS; + case 83: // kp dot + return KeyEvent.VK_PERIOD; + + // TODO: add mappings for japanese special buttons + case 85: // zenkakuhankaku + case 86: // 102nd + break; // FIXME + + case 87: + return KeyEvent.VK_F11; + case 88: + return KeyEvent.VK_F12; + + case 89: // ro + return KeyEvent.VK_ROMAN_CHARACTERS; + case 90: // Katakana + return KeyEvent.VK_KATAKANA; + case 91: + return KeyEvent.VK_HIRAGANA; + + case 92: // kenkan + break; // FIXME + case 93: // katakana hiragana + break; // FIXME + case 94: // mu henkan + break; // FIXME + case 95: // kp jp comma + break; // FIXME + + case 97: // right ctrl + return KeyEvent.VK_CONTROL; + case 98: // kp slash + return KeyEvent.VK_SLASH; + + case 99: // sysrq + break; // FIXME + + case 100: // right alt + return KeyEvent.VK_ALT; + case 101: // linefeed + break; // FIXME + case 102: // home + return KeyEvent.VK_HOME; + case 103: // KEY_UP + return KeyEvent.VK_UP; + case 104: + return KeyEvent.VK_PAGE_UP; + case 105: // KEY_LEFT + return KeyEvent.VK_LEFT; + case 106: // KEY_RIGHT + return KeyEvent.VK_RIGHT; + case 107: + return KeyEvent.VK_END; + case 108: // KEY_DOWN + return KeyEvent.VK_DOWN; + case 109: + return KeyEvent.VK_PAGE_DOWN; + case 110: + return KeyEvent.VK_INSERT; + case 111: // del + return KeyEvent.VK_DELETE; + + case 112: // macro + break; // FIXME DEAD_MACRON? + case 113: // mute + break; // FIXME + case 114: // vol up + break; // FIXME + case 115: // vol down + break; // FIXME + case 116: // power + break; // FIXME + + case 117: // kp equals + return KeyEvent.VK_EQUALS; + case 118: // kp plus minux + break; // FIXME + case 119: // pause + return KeyEvent.VK_PAUSE; + case 120: // scale AL compiz scale expose + break; // FIXME + case 121: // kp comma + return KeyEvent.VK_COMMA; + case 122: // hangeul + break; // FIXME + case 123: // hanja + break; // FIXME + case 124: // yen + break; // FIXME + + case 125: // left meta + case 126: // right meta + return KeyEvent.VK_META; + case 127: // compose + return KeyEvent.VK_COMPOSE; + + case 128: // stop + return KeyEvent.VK_STOP; + case 129: // again + return KeyEvent.VK_AGAIN; + case 130: // properties + return KeyEvent.VK_PROPS; + case 131: // undo + return KeyEvent.VK_UNDO; + case 132: // front + break; // FIXME + case 133: // copy + return KeyEvent.VK_COPY; + case 134: // open + break; // FIXME + case 135: // paste + return KeyEvent.VK_PASTE; + case 136: // find + return KeyEvent.VK_FIND; + case 137: // cut + return KeyEvent.VK_CUT; + case 138: // help + return KeyEvent.VK_HELP; + case 139: // menu + break; // FIXME + case 140: // calc + break; // FIXME + case 141: // setup + break; // FIXME + case 142: // sleep + break; // FIXME + case 143: // wakeup + break; // FIXME + case 144: // file + break; // FIXME + case 145: // send file + break; // FIXME + case 146: // delete file + break; // FIXME + case 147: // xfer + break; // FIXME + case 148: // prog1 + break; // FIXME + case 149: // prog2 + break; // FIXME + case 150: // www + break; // FIXME + case 151: // msdos + break; // FIXME + case 152: // coffee + break; // FIXME + case 153: // direction + break; // FIXME + case 154: // cycle windows + break; // FIXME + case 155: // mail + break; // FIXME + case 156: // bookmarks + break; // FIXME + case 157: // computer + break; // FIXME + case 158: // back + break; // FIXME + case 159: // forward + break; // FIXME + case 160: // close cd + break; // FIXME + case 161: // eject cd + break; // FIXME + case 162: // eject close cd + break; // FIXME + case 163: // next song + break; // FIXME + case 164: // play pause + break; // FIXME + case 165: // previous song + break; // FIXME + case 166: // stop cd + break; // FIXME + case 167: // record + break; // FIXME + case 168: // rewind + break; // FIXME + case 169: // phone + break; // FIXME + case 170: // ISO + break; // FIXME + case 171: // config + break; // FIXME + case 172: // home page + break; // FIXME + case 173: // refresh + break; // FIXME + case 174: // exit + break; // FIXME + case 175: // move + break; // FIXME + case 176: // edit + break; // FIXME + case 177: // scroll up + break; // FIXME PAGE_UP? + case 178: // scroll down + break; // FIXME PAGE_DOWN? + case 179: // kp left paren + return KeyEvent.VK_LEFT_PARENTHESIS; + case 180: // kp right paren + return KeyEvent.VK_RIGHT_PARENTHESIS; + case 181: // new + break; // FIXME + case 182: // redo + break; // FIXME + + case 183: // F13 + return KeyEvent.VK_F13; + case 184: // F14 + return KeyEvent.VK_F14; + case 185: // F15 + return KeyEvent.VK_F15; + case 186: // F16 + return KeyEvent.VK_F16; + case 187: // F17 + return KeyEvent.VK_F17; + case 188: // F18 + return KeyEvent.VK_F18; + case 189: // F19 + return KeyEvent.VK_F19; + case 190: // F20 + return KeyEvent.VK_F20; + case 191: // F21 + return KeyEvent.VK_F21; + case 192: // F22 + return KeyEvent.VK_F22; + case 193: // F23 + return KeyEvent.VK_F23; + case 194: // F24 + return KeyEvent.VK_F24; + + case 200: // play cd + break; // FIXME + case 201: // pause cd + break; // FIXME + case 202: // prog 3 + break; // FIXME + case 203: // prog 4 + break; // FIXME + case 204: // dashboard + break; // FIXME + case 205: // suspend + break; // FIXME + case 206: // close + break; // FIXME + case 207: // play + break; // FIXME + case 208: // fast forward + break; // FIXME + case 210: // print + return KeyEvent.VK_PRINTSCREEN; // FIXME ? + case 211: // HP + break; // FIXME + case 212: // camera + break; // FIXME + case 213: // sound + break; // FIXME + case 214: // question + break; // FIXME + case 215: // email + break; // FIXME + case 216: // chat + break; // FIXME + case 217: // search + break; // FIXME + case 218: // connect + break; // FIXME + case 219: // finance + break; // FIXME + case 220: // sport + break; // FIXME + case 221: // shop + break; // FIXME + case 222: // alt erase + break; // FIXME + case 223: // cancel + break; // FIXME + case 224: // brightness down + break; // FIXME + case 225: // brightness up + break; // FIXME + case 226: // media + break; // FIXME + case 227: // switch video mode + break; // FIXME + case 228: // kb dillum toggle + break; // FIXME + case 229: // kb dillum down + break; // FIXME + case 230: // kb dillum up + break; // FIXME + case 231: // send + break; // FIXME + case 232: // reply + break; // FIXME + case 233: // forward mail + break; // FIXME + case 234: // save + break; // FIXME + case 235: // documents + break; // FIXME + case 236: // battery + break; // FIXME + case 237: // bluetooth + break; // FIXME + case 238: // wlan + break; // FIXME + case 239: // UWB + break; // FIXME + case 240: // unknown + return KeyEvent.VK_UNDEFINED; + case 241: // video next + break; // FIXME + case 242: // video prev + break; // FIXME + case 243: // brightness cycle + break; // FIXME + case 244: // brightness zero + break; // FIXME + case 245: // display off + break; // FIXME + case 246: // wimax + break; // FIXME + case 247: // rf kill radio off + break; // FIXME + case 248: // mic mute + break; // FIXME + + default: + } + + if(Window.DEBUG_KEY_EVENT) { + System.out.println("TODO LinuxEVKey2NewtVKey: Unmapped EVKey "+EVKey); + } + return KeyEvent.VK_UNDEFINED; - } - } + } + } } -- cgit v1.2.3 From 578011822abb973800f96a21138c497862cba800 Mon Sep 17 00:00:00 2001 From: Xerxes RÃ¥nby Date: Mon, 8 Apr 2013 22:03:53 +0200 Subject: LinuxEventDeviceTracker: ALT, ALT_GRAPH & CTRL modifiers. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Xerxes RÃ¥nby --- .../newt/driver/linux/LinuxEventDeviceTracker.java | 41 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index 8651c2551..7b8c5eb2a 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -271,9 +271,19 @@ public class LinuxEventDeviceTracker implements WindowListener { case 0: eventType=KeyEvent.EVENT_KEY_RELEASED; - if(keyCode == KeyEvent.VK_SHIFT){ - System.out.println("release-shift"); + switch(keyCode) { + case KeyEvent.VK_SHIFT: modifiers &= ~InputEvent.SHIFT_MASK; + break; + case KeyEvent.VK_ALT: + modifiers &= ~InputEvent.ALT_MASK; + break; + case KeyEvent.VK_ALT_GRAPH: + modifiers &= ~InputEvent.ALT_GRAPH_MASK; + break; + case KeyEvent.VK_CONTROL: + modifiers &= ~InputEvent.CTRL_MASK; + break; } if(null != focusedWindow) { @@ -286,8 +296,19 @@ public class LinuxEventDeviceTracker implements WindowListener { case 1: eventType=KeyEvent.EVENT_KEY_PRESSED; - if(keyCode == KeyEvent.VK_SHIFT){ + switch(keyCode) { + case KeyEvent.VK_SHIFT: modifiers |= InputEvent.SHIFT_MASK; + break; + case KeyEvent.VK_ALT: + modifiers |= InputEvent.ALT_MASK; + break; + case KeyEvent.VK_ALT_GRAPH: + modifiers |= InputEvent.ALT_GRAPH_MASK; + break; + case KeyEvent.VK_CONTROL: + modifiers |= InputEvent.CTRL_MASK; + break; } if(null != focusedWindow) { @@ -300,8 +321,20 @@ public class LinuxEventDeviceTracker implements WindowListener { case 2: eventType=KeyEvent.EVENT_KEY_PRESSED; modifiers |= InputEvent.AUTOREPEAT_MASK; - if(keyCode == KeyEvent.VK_SHIFT){ + + switch(keyCode) { + case KeyEvent.VK_SHIFT: modifiers |= InputEvent.SHIFT_MASK; + break; + case KeyEvent.VK_ALT: + modifiers |= InputEvent.ALT_MASK; + break; + case KeyEvent.VK_ALT_GRAPH: + modifiers |= InputEvent.ALT_GRAPH_MASK; + break; + case KeyEvent.VK_CONTROL: + modifiers |= InputEvent.CTRL_MASK; + break; } if(null != focusedWindow) { -- cgit v1.2.3 From 4bea90974190baa2110c8398b4fe2dccb61e0daa Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Tue, 9 Apr 2013 22:00:47 -0700 Subject: jogl: remove executable bit from some java files and a png Signed-off-by: Harvey Harrison --- .../classes/com/jogamp/gluegen/opengl/GLConfiguration.java | 0 .../jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java | 0 .../gluegen/opengl/nativesig/NativeSignatureEmitter.java | 0 .../nativesig/NativeSignatureJavaMethodBindingEmitter.java | 0 src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java | 0 .../classes/com/jogamp/graph/curve/opengl/GLRegion.java | 0 src/jogl/classes/com/jogamp/opengl/math/Quaternion.java | 0 src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java | 0 .../classes/jogamp/graph/curve/opengl/RegionFactory.java | 0 .../jogamp/graph/curve/opengl/RegionRendererImpl01.java | 0 .../com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java | 0 .../com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 0 .../opengl/test/junit/graph/TestTextRendererNEWT01.java | 0 .../opengl/test/junit/graph/demos/GPURegionNewtDemo01.java | 0 .../jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java | 0 .../opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java | 0 .../opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java | 0 .../opengl/test/junit/jogl/demos/es2/av/MovieCube.java | 0 .../opengl/test/junit/jogl/demos/es2/av/MovieSimple.java | 0 .../test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java | 0 .../test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java | 0 .../test/junit/jogl/util/texture/grayscale_texture.png | Bin 22 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java mode change 100755 => 100644 src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java mode change 100755 => 100644 src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java mode change 100755 => 100644 src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java mode change 100755 => 100644 src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java mode change 100755 => 100644 src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java mode change 100755 => 100644 src/jogl/classes/com/jogamp/opengl/math/Quaternion.java mode change 100755 => 100644 src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java mode change 100755 => 100644 src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java mode change 100755 => 100644 src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java mode change 100755 => 100644 src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java mode change 100755 => 100644 src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java mode change 100755 => 100644 src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java mode change 100755 => 100644 src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java mode change 100755 => 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java mode change 100755 => 100644 src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java mode change 100755 => 100644 src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java mode change 100755 => 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java mode change 100755 => 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java mode change 100755 => 100644 src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java mode change 100755 => 100644 src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java mode change 100755 => 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/grayscale_texture.png (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java old mode 100755 new mode 100644 diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java old mode 100755 new mode 100644 diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java old mode 100755 new mode 100644 diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java old mode 100755 new mode 100644 diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java old mode 100755 new mode 100644 diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java old mode 100755 new mode 100644 diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java old mode 100755 new mode 100644 diff --git a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java old mode 100755 new mode 100644 diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java old mode 100755 new mode 100644 diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java old mode 100755 new mode 100644 diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java old mode 100755 new mode 100644 diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java old mode 100755 new mode 100644 diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT01.java old mode 100755 new mode 100644 diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURegionNewtDemo01.java old mode 100755 new mode 100644 diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java old mode 100755 new mode 100644 diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java old mode 100755 new mode 100644 diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java old mode 100755 new mode 100644 diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java old mode 100755 new mode 100644 diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java old mode 100755 new mode 100644 diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java old mode 100755 new mode 100644 diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java old mode 100755 new mode 100644 diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/grayscale_texture.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/grayscale_texture.png old mode 100755 new mode 100644 -- cgit v1.2.3 From b13868b612689307ebf4e46ee4ede2fd0560e504 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 11 Apr 2013 07:16:19 +0200 Subject: NEWT KeyEvent: Use UTF-16 UniCode for key-code and key-symbol exposing well defined key encoding and simplify usage. Note, we use one collision to reduce key-code range: [0x61 .. 0x78] keyCodes [F1..F24] collide w/ ['a'..'x'] Since keyCode/Sym won't use lower capital a-z, this is a no isssue. KeyEvent: - 'printable' type is being determined by a nonPrintableKeys table, while 'action' type is set in case !printable and !modifier. - public ctor hidden, use create(..) method instead. This allows us to ensure modifier bit are properly set (incl. the keySym one) w/o performance loss. - ctor validates that only one of the type flags is set, printable, modifyable or action. WindowImpl: - Using IntBitfield of 255 bits to track pressed state, while removing the repeat state tracking since it is redundant. The Windows impl. uses a single field to validate whether a key was already repeated or not. - Properly cast keyCode short values to int for tracking! AWTNewtEventFactory, SWTNewtEventFactory: - Add translation of keyCode/Sym from and to NEWT - All tested via: - Newt -> Awt for AWTRobot - OSX CALayer: AWT -> NEWT - SWT tests X11: - Add VK_CONTEXT_MENU mapping (XK_Menu) LinuxEventDeviceTracker: - Fix apostrophe and grave mapping, i.e. to VK_QUOTE and VK_BACK_QUOTE. Adapted all unit tests, especially: - TestNewtKeyCodesAWT: More fine grained keyCode ranges to test using proper keyCode symbols. --- make/scripts/tests-x64.bat | 4 +- make/scripts/tests.sh | 5 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 1062 +++++++++++--------- .../classes/com/jogamp/newt/event/UTFKeyUtil.java | 82 -- src/newt/classes/jogamp/newt/WindowImpl.java | 44 +- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 377 ++++++- .../android/event/AndroidNewtEventFactory.java | 2 +- .../jogamp/newt/driver/awt/DisplayDriver.java | 1 - .../newt/driver/linux/LinuxEventDeviceTracker.java | 6 +- .../jogamp/newt/driver/macosx/WindowDriver.java | 11 +- .../jogamp/newt/driver/windows/WindowDriver.java | 15 +- .../jogamp/newt/swt/event/SWTNewtEventFactory.java | 140 ++- src/newt/native/KeyEvent.h | 388 +++---- src/newt/native/X11Display.c | 2 + .../TestNewtCanvasSWTBug628ResizeDeadlockAWT.java | 4 +- .../newt/event/TestNewtKeyCodeModifiersAWT.java | 97 +- .../test/junit/newt/event/TestNewtKeyCodesAWT.java | 61 +- .../opengl/test/junit/util/AWTRobotUtil.java | 14 + .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 56 +- 19 files changed, 1451 insertions(+), 920 deletions(-) delete mode 100644 src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index d08f40e5c..1f4b23d8c 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -50,7 +50,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsReali REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -65,7 +65,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index eee4edec0..983c27a07 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -92,6 +92,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" #D_ARGS="-Djogl.debug.FixedFuncPipeline" @@ -276,7 +277,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* @@ -444,7 +445,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index bda60004e..45bccf964 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -34,7 +34,11 @@ package com.jogamp.newt.event; +import com.jogamp.common.util.IntBitfield; + /** + *
    KeyEvent Delivery
    + * * Key events are delivered in the following order: *

    * @@ -77,32 +81,84 @@ package com.jogamp.newt.event; * and {@link #EVENT_KEY_RELEASED released} events excluding {@link #isAutoRepeat() auto-repeat}. * They will also influence subsequent event's {@link #getModifiers() modifier} bits while pressed. *

    + * + *
    Unicode Mapping
    + *

    + * {@link #getKeyChar() Key-chars}, as well as + * {@link #isPrintableKey() printable} {@link #getKeyCode() key-codes} and {@link #getKeySymbol() key-symbols} + * use the UTF-16 unicode space w/o collision. + * + *

    + *

    + * Non-{@link #isPrintableKey() printable} {@link #getKeyCode() key-codes} and {@link #getKeySymbol() key-symbols}, + * i.e. {@link #isModifierKey() modifier-} and {@link #isActionKey() action-}keys, + * are mapped to unicode's control and private range and do not collide w/ {@link #isPrintableKey() printable} unicode values + * with the following exception. + *

    + * + *
    Unicode Collision
    + *

    + * The following {@link #getKeyCode() Key-code}s and {@link #getKeySymbol() key-symbol}s collide w/ unicode space:
    + *

    + * + * + *
    unicode range virtual key code unicode character
    [0x61 .. 0x78] [{@link #VK_F1}..{@link #VK_F24}] ['a'..'x']
    + *

    + *

    + * Collision was chosen for {@link #getKeyCode() Key-code} and {@link #getKeySymbol() key-symbol} mapping + * to allow a minimal code range, i.e. [0..255]. + * The reduced code range in turn allows the implementation to utilize fast and small lookup tables, + * e.g. to implement a key-press state tracker. + *

    + *
    + * http://www.utf8-chartable.de/unicode-utf8-table.pl
    + * http://www.unicode.org/Public/5.1.0/ucd/PropList.txt
    + * https://en.wikipedia.org/wiki/Mapping_of_Unicode_characters
    + * https://en.wikipedia.org/wiki/Unicode_control_characters
    + * https://en.wikipedia.org/wiki/Private_Use_%28Unicode%29#Private_Use_Areas
    + * 
    + *

    */ @SuppressWarnings("serial") public class KeyEvent extends InputEvent { - public KeyEvent(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, char keyChar) { - super(eventType, source, when, modifiers); + private KeyEvent(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, int keySymModMask, char keyChar) { + super(eventType, source, when, modifiers | keySymModMask); this.keyCode=keyCode; this.keySym=keySym; this.keyChar=keyChar; { // cache modifier and action flags byte _flags = 0; - if( isModifierKey(keySym) ) { - _flags |= F_MODIFIER_MASK; - } - if( isActionKey(keySym) ) { - _flags |= F_ACTION_MASK; - } - if( 0 == _flags && VK_UNDEFINED != keySym && NULL_CHAR != keyChar ) { + if( isPrintableKey(keySym, false) && isPrintableKey((short)keyChar, true) ) { _flags |= F_PRINTABLE_MASK; + } else { + if( 0 != keySymModMask ) { + _flags |= F_MODIFIER_MASK; + } else { + // A = U - ( P + M ) + _flags |= F_ACTION_MASK; + } } flags = _flags; + + // + // Validate flags + // + final int pma_bits = flags & ( F_PRINTABLE_MASK | F_MODIFIER_MASK | F_ACTION_MASK ) ; + final int pma_count = IntBitfield.getBitCount(pma_bits); + if ( 1 != pma_count ) { + throw new InternalError("Key must be either of type printable, modifier or action - but it is of "+pma_count+" types: "+this); + } } } + + public static KeyEvent create(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, char keyChar) { + return new KeyEvent(eventType, source, when, modifiers, keyCode, keySym, getModifierMask(keySym), keyChar); + } /** - * Returns the UTF-16 character reflecting the {@link #getKeySymbol() key symbol}. + * Returns the UTF-16 character reflecting the {@link #getKeySymbol() key symbol} + * incl. active {@link #isModifierKey() modifiers}. * @see #getKeySymbol() * @see #getKeyCode() */ @@ -113,8 +169,9 @@ public class KeyEvent extends InputEvent /** * Returns the virtual key symbol reflecting the current keyboard layout. *

    - * For {@link #isPrintableKey() printable keys}, the key symbol is the unshifted - * representation of the {@link #getKeyChar() UTF-16 key char}. + * For {@link #isPrintableKey() printable keys}, the key symbol is the {@link #isModifierKey() unmodified} + * representation of the UTF-16 {@link #getKeyChar() key char}.
    + * E.g. symbol [{@link #VK_A}, 'A'] for char 'a'. *

    * @see #isPrintableKey() * @see #getKeyChar() @@ -136,10 +193,6 @@ public class KeyEvent extends InputEvent * QWERTZ is active. The {@link #getKeySymbol() key symbol} of the former is * {@link #VK_Y}, where the latter produces {@link #VK_Y}. *

    - *

    - * Disclaimer: In case key code is not implemented on your platform (OSX, ..) - * the {@link #getKeySymbol() key symbol} is returned. - *

    * @see #getKeyChar() * @see #getKeySymbol() */ @@ -169,6 +222,18 @@ public class KeyEvent extends InputEvent } } + /** + * @param keyChar UTF16 value to map. It is expected that the incoming keyChar value is unshifted and unmodified, + * however, lower case a-z is mapped to {@link KeyEvent#VK_A} - {@link KeyEvent#VK_Z}. + * @return {@link KeyEvent} virtual key (VK) value. + */ + public static short utf16ToVKey(char keyChar) { + if( 'a' <= keyChar && keyChar <= 'z' ) { + return (short) ( ( keyChar - 'a' ) + KeyEvent.VK_A ); + } + return (short) keyChar; + } + /** * Returns true if the given virtualKey represents a modifier key, otherwise false. *

    @@ -188,6 +253,25 @@ public class KeyEvent extends InputEvent } } + /** + * If vKey is a {@link #isModifierKey() modifier key}, method returns the corresponding modifier mask, + * otherwise 0. + */ + public static int getModifierMask(short vKey) { + switch (vKey) { + case VK_SHIFT: + return InputEvent.SHIFT_MASK; + case VK_CONTROL: + return InputEvent.CTRL_MASK; + case VK_ALT: + case VK_ALT_GRAPH: + return InputEvent.ALT_MASK; + case VK_META: + return InputEvent.META_MASK; + } + return 0; + } + /** * Returns true if {@link #getKeySymbol() key symbol} represents a modifier key, * otherwise false. @@ -201,106 +285,67 @@ public class KeyEvent extends InputEvent public final boolean isModifierKey() { return 0 != ( F_MODIFIER_MASK & flags ) ; } - - /** - * Returns true if the given virtualKey represents a non-printable and - * non-{@link #isModifierKey(short) modifier} action key, otherwise false. - *

    - * An action key is one of {@link #VK_HOME}, {@link #VK_END}, {@link #VK_PAGE_UP}, {@link #VK_PAGE_DOWN}, {@link #VK_UP}, {@link #VK_PAGE_DOWN}, - * {@link #VK_LEFT}, {@link #VK_RIGHT}, {@link #VK_F1}-{@link #VK_F24}, {@link #VK_PRINTSCREEN}, {@link #VK_CAPS_LOCK}, {@link #VK_PAUSE}, - * {@link #VK_INSERT}, {@link #VK_HELP}, {@link #VK_WINDOWS}, etc ... - *

    - */ - public static boolean isActionKey(short vKey) { - if( ( VK_F1 <= vKey && vKey <= VK_F24 ) || - ( VK_ALL_CANDIDATES <= vKey && vKey <= VK_INPUT_METHOD_ON_OFF ) || - ( VK_CUT <= vKey && vKey <= VK_STOP ) ) { - return true; - } - - switch (vKey) { - case VK_CANCEL: - case VK_CLEAR: - case VK_PAUSE: - case VK_CAPS_LOCK: - case VK_ESCAPE: - case VK_PAGE_UP: - case VK_PAGE_DOWN: - case VK_END: - case VK_HOME: - case VK_LEFT: - case VK_UP: - case VK_RIGHT: - case VK_DOWN: - case VK_DELETE: - case VK_NUM_LOCK: - case VK_SCROLL_LOCK: - - case VK_PRINTSCREEN: - case VK_INSERT: - case VK_HELP: - case VK_META: - case VK_KP_UP: - case VK_KP_DOWN: - case VK_KP_LEFT: - case VK_KP_RIGHT: - - case VK_DEAD_VOICED_SOUND: - case VK_DEAD_SEMIVOICED_SOUND: - - case VK_WINDOWS: - case VK_CONTEXT_MENU: - case VK_FINAL: - - case VK_CONVERT: - case VK_NONCONVERT: - case VK_ACCEPT: - case VK_MODECHANGE: - - case VK_KANA: - case VK_KANJI: - - case VK_ALPHANUMERIC: - case VK_KATAKANA: - case VK_HIRAGANA: - case VK_FULL_WIDTH: - case VK_HALF_WIDTH: - case VK_ROMAN_CHARACTERS: - - case VK_COMPOSE: - case VK_BEGIN: - case VK_KEYBOARD_INVISIBLE: - return true; - } - return false; - } /** - * Returns true if {@link #getKeySymbol() key symbol} represents a non-printable and - * non-{@link #isModifierKey(short) modifier} action key, otherwise false. + * Returns true if {@link #getKeySymbol() key symbol} represents a non-printable and + * non-{@link #isModifierKey(short) modifier} action key, otherwise false. *

    - * See {@link #isActionKey(short)} for details. + * Hence it is the set A of all keys U w/o printable P and w/o modifiers M: + * A = U - ( P + M ) *

    + * @see #isPrintableKey() + * @see #isModifierKey() */ public final boolean isActionKey() { return 0 != ( F_ACTION_MASK & flags ) ; } - /** - * Returns true if given virtualKey represents a printable character, - * i.e. a value other than {@link #VK_UNDEFINED} and neither a {@link #isModifierKey(short) modifier key} - * nor an {@link #isActionKey(short) action key}. + /** + * Returns true if given uniChar represents a printable character, + * i.e. a value other than {@link #VK_UNDEFINED} and not a control or non-printable private code. + *

    + * A printable character is neither a {@link #isModifierKey(short) modifier key}, nor an {@link #isActionKey(short) action key}. + *

    + *

    * Otherwise returns false. + *

    + *

    + * Distinction of key character and virtual key code is made due to unicode collision. + *

    + * + * @param uniChar the UTF-16 unicode value, which maybe a virtual key code or key character. + * @param isKeyChar true if uniChar is a key character, otherwise a virtual key code */ - public static boolean isPrintableKey(short vKey) { - return VK_UNDEFINED != vKey && !isModifierKey(vKey) && !isActionKey(vKey); + public static boolean isPrintableKey(final short uniChar, final boolean isKeyChar) { + if( VK_UNDEFINED == uniChar ) { + return false; + } + if( !isKeyChar ) { + if( ( nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || + ( nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || + ( nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || + ( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { + return false; + } + + } else { + if( ( nonPrintableKeys[0].inclKeyChar && nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || + ( nonPrintableKeys[1].inclKeyChar && nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || + ( nonPrintableKeys[2].inclKeyChar && nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || + ( nonPrintableKeys[3].inclKeyChar && nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { + return false; + } + } + return true; } /** - * Returns true if {@link #getKeySymbol() key symbol} represents a printable character, - * i.e. a value other than {@link #VK_UNDEFINED} and neither a {@link #isModifierKey(short) modifier key} - * nor an {@link #isActionKey(short) action key}. The {@link #getKeyChar() key char} value must also be - * different than {@link #NULL_CHAR}. + * Returns true if {@link #getKeySymbol() key symbol} and {@link #getKeyChar() key char} + * represents a printable character, i.e. a value other than {@link #VK_UNDEFINED} + * and not a control or non-printable private code. + *

    + * A printable character is neither a {@link #isModifierKey(short) modifier key}, nor an {@link #isActionKey(short) action key}. + *

    *

    * Otherwise returns false. *

    @@ -327,578 +372,599 @@ public class KeyEvent extends InputEvent */ public static final short EVENT_KEY_TYPED = 302; + /** + * This value, {@code '\0'}, is used to indicate that the keyChar is unknown or not printable. + */ + public static final char NULL_CHAR = '\0'; + /* Virtual key codes. */ - public static final short VK_CANCEL = (short) 0x03; - public static final short VK_BACK_SPACE = (short) 0x08; // '\b' - public static final short VK_TAB = (short) 0x09; // '\t' - public static final short VK_ENTER = (short) 0x0A; // '\n' - public static final short VK_CLEAR = (short) 0x0C; - public static final short VK_SHIFT = (short) 0x10; - public static final short VK_CONTROL = (short) 0x11; + public static class NonPrintableRange { + /** min. unicode value, inclusive */ + public short min; + /** max. unicode value, inclusive */ + public short max; + /** true if valid for keyChar values as well, otherwise only valid for keyCode and keySym due to collision. */ + public final boolean inclKeyChar; + private NonPrintableRange(short min, short max, boolean inclKeyChar) { + this.min = min; + this.max = max; + this.inclKeyChar = inclKeyChar; + } + }; + /** Non printable key ranges, currently fixed to an aray of size 4. */ + public final static NonPrintableRange[] nonPrintableKeys = { new NonPrintableRange( (short)0x0000, (short)0x001F, true ), + new NonPrintableRange( (short)0x0061, (short)0x0078, false), + new NonPrintableRange( (short)0x007F, (short)0x009F, true ), + new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) }; + + // + // Unicode: Non printable controls: [0x00 - 0x1F] + // + /** - * Constant for the ALT function key, i.e. left ALT key. + * This value, {@value}, is used to indicate that the keyCode is unknown. */ + public static final short VK_UNDEFINED = (short) 0x0; + + static final short VK_FREE01 = (short) 0x01; + + /** Constant for the HOME function key. ASCII: Start Of Text. */ + public static final short VK_HOME = (short) 0x02; + + /** Constant for the END function key. ASCII: End Of Text. */ + public static final short VK_END = (short) 0x03; + + /** Constant for the END function key. ASCII: End Of Transmission. */ + public static final short VK_FINAL = (short) 0x04; + + /** Constant for the PRINT function key. ASCII: Enquiry. */ + public static final short VK_PRINTSCREEN = (short) 0x05; + + static final short VK_FREE06 = (short) 0x06; + static final short VK_FREE07 = (short) 0x07; + + /** Constant for the BACK SPACE key "\b", matching ASCII. */ + public static final short VK_BACK_SPACE = (short) 0x08; + + /** Constant for the HORIZ TAB key "\t", matching ASCII. */ + public static final short VK_TAB = (short) 0x09; + + /** Constant for the ENTER key, i.e. LINE FEED "\n", matching ASCII. */ + public static final short VK_ENTER = (short) 0x0A; + + /** Constant for the PAGE DOWN function key. ASCII: Vertical Tabulation. */ + public static final short VK_PAGE_DOWN = (short) 0x0B; + + /** Constant for the CLEAR key, i.e. FORM FEED, matching ASCII. */ + public static final short VK_CLEAR = (short) 0x0C; + + static final short VK_FREE0D = (short) 0x0D; + static final short VK_FREE0E = (short) 0x0E; + + /** Constant for the CTRL function key. ASCII: shift-in. */ + public static final short VK_SHIFT = (short) 0x0F; + + /** Constant for the PAGE UP function key. ASCII: Data Link Escape. */ + public static final short VK_PAGE_UP = (short) 0x10; + + /** Constant for the CTRL function key. ASCII: device-ctrl-one. */ + public static final short VK_CONTROL = (short) 0x11; + + /** Constant for the left ALT function key. ASCII: device-ctrl-two. */ public static final short VK_ALT = (short) 0x12; - public static final short VK_PAUSE = (short) 0x13; + + /** Constant for the ALT_GRAPH function key, i.e. right ALT key. ASCII: device-ctrl-three. */ + public static final short VK_ALT_GRAPH = (short) 0x13; + + /** Constant for the CAPS LOCK function key. ASCII: device-ctrl-four. */ public static final short VK_CAPS_LOCK = (short) 0x14; + + static final short VK_FREE15 = (short) 0x15; + + /** Constant for the PAUSE function key. ASCII: sync-idle. */ + public static final short VK_PAUSE = (short) 0x16; + + /** scroll lock key. ASCII: End Of Transmission Block. */ + public static final short VK_SCROLL_LOCK = (short) 0x17; + + /** Constant for the CANCEL function key. ASCII: Cancel. */ + public static final short VK_CANCEL = (short) 0x18; + + static final short VK_FREE19 = (short) 0x19; + + /** Constant for the INSERT function key. ASCII: Substitute. */ + public static final short VK_INSERT = (short) 0x1A; + + /** Constant for the ESCAPE function key. ASCII: Escape. */ public static final short VK_ESCAPE = (short) 0x1B; - public static final short VK_SPACE = (short) 0x20; - public static final short VK_PAGE_UP = (short) 0x21; - public static final short VK_PAGE_DOWN = (short) 0x22; - public static final short VK_END = (short) 0x23; - public static final short VK_HOME = (short) 0x24; + + /** Constant for the Convert function key, Japanese "henkan". ASCII: File Separator. */ + public static final short VK_CONVERT = (short) 0x1C; - /** - * Constant for the non-numpad left arrow key. - * @see #VK_KP_LEFT - */ - public static final short VK_LEFT = (short) 0x25; + /** Constant for the Don't Convert function key, Japanese "muhenkan". ASCII: Group Separator.*/ + public static final short VK_NONCONVERT = (short) 0x1D; - /** - * Constant for the non-numpad up arrow key. - * @see #VK_KP_UP - */ - public static final short VK_UP = (short) 0x26; + /** Constant for the Accept or Commit function key, Japanese "kakutei". ASCII: Record Separator.*/ + public static final short VK_ACCEPT = (short) 0x1E; - /** - * Constant for the non-numpad right arrow key. - * @see #VK_KP_RIGHT - */ - public static final short VK_RIGHT = (short) 0x27; + /** Constant for the Mode Change (?). ASCII: Unit Separator.*/ + public static final short VK_MODECHANGE = (short) 0x1F; - /** - * Constant for the non-numpad down arrow key. - * @see #VK_KP_DOWN - */ - public static final short VK_DOWN = (short) 0x28; + // + // Unicode: Printable [0x20 - 0x7E] + // NOTE: Collision of 'a' - 'x' [0x61 .. 0x78], used for keyCode/keySym Fn function keys + // + + /** Constant for the SPACE function key. ASCII: SPACE. */ + public static final short VK_SPACE = (short) 0x20; + + /** Constant for the "!" key. */ + public static final short VK_EXCLAMATION_MARK = (short) 0x21; - /** - * Constant for the comma key, "," - */ - public static final short VK_COMMA = (short) 0x2C; + /** Constant for the """ key. */ + public static final short VK_QUOTEDBL = (short) 0x22; + + /** Constant for the "#" key. */ + public static final short VK_NUMBER_SIGN = (short) 0x23; - /** - * Constant for the minus key, "-" - * @since 1.2 - */ + /** Constant for the "$" key. */ + public static final short VK_DOLLAR = (short) 0x24; + + /** Constant for the "%" key. */ + public static final short VK_PERCENT = (short) 0x25; + + /** Constant for the "&" key. */ + public static final short VK_AMPERSAND = (short) 0x26; + + /** Constant for the "'" key. */ + public static final short VK_QUOTE = (short) 0x27; + + /** Constant for the "(" key. */ + public static final short VK_LEFT_PARENTHESIS = (short) 0x28; + + /** Constant for the ")" key. */ + public static final short VK_RIGHT_PARENTHESIS = (short) 0x29; + + /** Constant for the "*" key */ + public static final short VK_ASTERISK = (short) 0x2A; + + /** Constant for the "+" key. */ + public static final short VK_PLUS = (short) 0x2B; + + /** Constant for the comma key, "," */ + public static final short VK_COMMA = (short) 0x2C; + + /** Constant for the minus key, "-" */ public static final short VK_MINUS = (short) 0x2D; - /** - * Constant for the period key, "." - */ + /** Constant for the period key, "." */ public static final short VK_PERIOD = (short) 0x2E; - /** - * Constant for the forward slash key, "/" - */ + /** Constant for the forward slash key, "/" */ public static final short VK_SLASH = (short) 0x2F; - /** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */ + /** VK_0 thru VK_9 are the same as UTF16/ASCII '0' thru '9' [0x30 - 0x39] */ public static final short VK_0 = (short) 0x30; + /** See {@link #VK_0}. */ public static final short VK_1 = (short) 0x31; + /** See {@link #VK_0}. */ public static final short VK_2 = (short) 0x32; + /** See {@link #VK_0}. */ public static final short VK_3 = (short) 0x33; + /** See {@link #VK_0}. */ public static final short VK_4 = (short) 0x34; + /** See {@link #VK_0}. */ public static final short VK_5 = (short) 0x35; + /** See {@link #VK_0}. */ public static final short VK_6 = (short) 0x36; + /** See {@link #VK_0}. */ public static final short VK_7 = (short) 0x37; + /** See {@link #VK_0}. */ public static final short VK_8 = (short) 0x38; + /** See {@link #VK_0}. */ public static final short VK_9 = (short) 0x39; - /** - * Constant for the semicolon key, ";" - */ + /** Constant for the ":" key. */ + public static final short VK_COLON = (short) 0x3A; + + /** Constant for the semicolon key, ";" */ public static final short VK_SEMICOLON = (short) 0x3B; - /** - * Constant for the equals key, "=" - */ + /** Constant for the equals key, "<" */ + public static final short VK_LESS = (short) 0x3C; + + /** Constant for the equals key, "=" */ public static final short VK_EQUALS = (short) 0x3D; - /** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */ + /** Constant for the equals key, ">" */ + public static final short VK_GREATER = (short) 0x3E; + + /** Constant for the equals key, "?" */ + public static final short VK_QUESTIONMARK = (short) 0x3F; + + /** Constant for the equals key, "@" */ + public static final short VK_AT = (short) 0x40; + + /** VK_A thru VK_Z are the same as Capital UTF16/ASCII 'A' thru 'Z' (0x41 - 0x5A) */ public static final short VK_A = (short) 0x41; + /** See {@link #VK_A}. */ public static final short VK_B = (short) 0x42; + /** See {@link #VK_A}. */ public static final short VK_C = (short) 0x43; + /** See {@link #VK_A}. */ public static final short VK_D = (short) 0x44; + /** See {@link #VK_A}. */ public static final short VK_E = (short) 0x45; + /** See {@link #VK_A}. */ public static final short VK_F = (short) 0x46; + /** See {@link #VK_A}. */ public static final short VK_G = (short) 0x47; + /** See {@link #VK_A}. */ public static final short VK_H = (short) 0x48; + /** See {@link #VK_A}. */ public static final short VK_I = (short) 0x49; + /** See {@link #VK_A}. */ public static final short VK_J = (short) 0x4A; + /** See {@link #VK_A}. */ public static final short VK_K = (short) 0x4B; + /** See {@link #VK_A}. */ public static final short VK_L = (short) 0x4C; + /** See {@link #VK_A}. */ public static final short VK_M = (short) 0x4D; + /** See {@link #VK_A}. */ public static final short VK_N = (short) 0x4E; + /** See {@link #VK_A}. */ public static final short VK_O = (short) 0x4F; + /** See {@link #VK_A}. */ public static final short VK_P = (short) 0x50; + /** See {@link #VK_A}. */ public static final short VK_Q = (short) 0x51; + /** See {@link #VK_A}. */ public static final short VK_R = (short) 0x52; + /** See {@link #VK_A}. */ public static final short VK_S = (short) 0x53; + /** See {@link #VK_A}. */ public static final short VK_T = (short) 0x54; + /** See {@link #VK_A}. */ public static final short VK_U = (short) 0x55; + /** See {@link #VK_A}. */ public static final short VK_V = (short) 0x56; + /** See {@link #VK_A}. */ public static final short VK_W = (short) 0x57; + /** See {@link #VK_A}. */ public static final short VK_X = (short) 0x58; + /** See {@link #VK_A}. */ public static final short VK_Y = (short) 0x59; + /** See {@link #VK_A}. */ public static final short VK_Z = (short) 0x5A; - /** - * Constant for the open bracket key, "[" - */ + /** Constant for the open bracket key, "[" */ public static final short VK_OPEN_BRACKET = (short) 0x5B; - /** - * Constant for the back slash key, "\" - */ + /**Constant for the back slash key, "\" */ public static final short VK_BACK_SLASH = (short) 0x5C; - /** - * Constant for the close bracket key, "]" - */ + /** Constant for the close bracket key, "]" */ public static final short VK_CLOSE_BRACKET = (short) 0x5D; - public static final short VK_NUMPAD0 = (short) 0x60; - public static final short VK_NUMPAD1 = (short) 0x61; - public static final short VK_NUMPAD2 = (short) 0x62; - public static final short VK_NUMPAD3 = (short) 0x63; - public static final short VK_NUMPAD4 = (short) 0x64; - public static final short VK_NUMPAD5 = (short) 0x65; - public static final short VK_NUMPAD6 = (short) 0x66; - public static final short VK_NUMPAD7 = (short) 0x67; - public static final short VK_NUMPAD8 = (short) 0x68; - public static final short VK_NUMPAD9 = (short) 0x69; - public static final short VK_MULTIPLY = (short) 0x6A; - public static final short VK_ADD = (short) 0x6B; + /** Constant for the "^" key. */ + public static final short VK_CIRCUMFLEX = (short) 0x5E; + /** Constant for the "_" key */ + public static final short VK_UNDERSCORE = (short) 0x5F; + + /** Constant for the "`" key */ + public static final short VK_BACK_QUOTE = (short) 0x60; + + /** Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym. */ + /** - * Constant for the Numpad Separator key. + * Constant for the Fn function keys. + *

    + * F1..F24, i.e. Fn, are mapped from on 0x60+n -> [0x61 .. 0x78]. + *

    + *

    + * Warning: The Fn function keys do collide with unicode characters small 'a' thru 'x'!
    + * See Unicode Collision for details. + *

    */ - public static final short VK_SEPARATOR = (short) 0x6C; + public static final short VK_F1 = (short) ( 0x60+ 1 ); - public static final short VK_SUBTRACT = (short) 0x6D; - public static final short VK_DECIMAL = (short) 0x6E; - public static final short VK_DIVIDE = (short) 0x6F; - public static final short VK_DELETE = (short) 0x7F; /* ASCII DEL */ - public static final short VK_NUM_LOCK = (short) 0x90; - public static final short VK_SCROLL_LOCK = (short) 0x91; + /** Constant for the F2 function key. See {@link #VK_F1}. */ + public static final short VK_F2 = (short) ( 0x60+ 2 ); - /** Constant for the F1 function key. */ - public static final short VK_F1 = (short) 0x70; + /** Constant for the F3 function key. See {@link #VK_F1}. */ + public static final short VK_F3 = (short) ( 0x60+ 3 ); - /** Constant for the F2 function key. */ - public static final short VK_F2 = (short) 0x71; + /** Constant for the F4 function key. See {@link #VK_F1}. */ + public static final short VK_F4 = (short) ( 0x60+ 4 ); - /** Constant for the F3 function key. */ - public static final short VK_F3 = (short) 0x72; + /** Constant for the F5 function key. See {@link #VK_F1}. */ + public static final short VK_F5 = (short) ( 0x60+ 5 ); - /** Constant for the F4 function key. */ - public static final short VK_F4 = (short) 0x73; + /** Constant for the F6 function key. See {@link #VK_F1}. */ + public static final short VK_F6 = (short) ( 0x60+ 6 ); - /** Constant for the F5 function key. */ - public static final short VK_F5 = (short) 0x74; + /** Constant for the F7 function key. See {@link #VK_F1}. */ + public static final short VK_F7 = (short) ( 0x60+ 7 ); - /** Constant for the F6 function key. */ - public static final short VK_F6 = (short) 0x75; + /** Constant for the F8 function key. See {@link #VK_F1}. */ + public static final short VK_F8 = (short) ( 0x60+ 8 ); - /** Constant for the F7 function key. */ - public static final short VK_F7 = (short) 0x76; + /** Constant for the F9 function key. See {@link #VK_F1}. */ + public static final short VK_F9 = (short) ( 0x60+ 9 ); - /** Constant for the F8 function key. */ - public static final short VK_F8 = (short) 0x77; + /** Constant for the F11 function key. See {@link #VK_F1}. */ + public static final short VK_F10 = (short) ( 0x60+10 ); - /** Constant for the F9 function key. */ - public static final short VK_F9 = (short) 0x78; + /** Constant for the F11 function key. See {@link #VK_F1}. */ + public static final short VK_F11 = (short) ( 0x60+11 ); - /** Constant for the F10 function key. */ - public static final short VK_F10 = (short) 0x79; + /** Constant for the F12 function key. See {@link #VK_F1}.*/ + public static final short VK_F12 = (short) ( 0x60+12 ); - /** Constant for the F11 function key. */ - public static final short VK_F11 = (short) 0x7A; + /** Constant for the F13 function key. See {@link #VK_F1}. */ + public static final short VK_F13 = (short) ( 0x60+13 ); - /** Constant for the F12 function key. */ - public static final short VK_F12 = (short) 0x7B; + /** Constant for the F14 function key. See {@link #VK_F1}. */ + public static final short VK_F14 = (short) ( 0x60+14 ); - /** - * Constant for the F13 function key. - *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    - */ - public static final short VK_F13 = (short) 0xF000; + /** Constant for the F15 function key. See {@link #VK_F1}. */ + public static final short VK_F15 = (short) ( 0x60+15 ); - /** - * Constant for the F14 function key. - *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    - */ - public static final short VK_F14 = (short) 0xF001; - - /** - * Constant for the F15 function key. - *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    - */ - public static final short VK_F15 = (short) 0xF002; - - /** - * Constant for the F16 function key. - *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    - */ - public static final short VK_F16 = (short) 0xF003; - - /** - * Constant for the F17 function key. - *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    - */ - public static final short VK_F17 = (short) 0xF004; + /** Constant for the F16 function key. See {@link #VK_F1}. */ + public static final short VK_F16 = (short) ( 0x60+16 ); - /** - * Constant for the F18 function key. - *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    - */ - public static final short VK_F18 = (short) 0xF005; + /** Constant for the F17 function key. See {@link #VK_F1}. */ + public static final short VK_F17 = (short) ( 0x60+17 ); - /** - * Constant for the F19 function key. - *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    - */ - public static final short VK_F19 = (short) 0xF006; + /** Constant for the F18 function key. See {@link #VK_F1}. */ + public static final short VK_F18 = (short) ( 0x60+18 ); - /** - * Constant for the F20 function key. - *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    - */ - public static final short VK_F20 = (short) 0xF007; + /** Constant for the F19 function key. See {@link #VK_F1}. */ + public static final short VK_F19 = (short) ( 0x60+19 ); - /** - * Constant for the F21 function key. - *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    - */ - public static final short VK_F21 = (short) 0xF008; + /** Constant for the F20 function key. See {@link #VK_F1}. */ + public static final short VK_F20 = (short) ( 0x60+20 ); - /** - * Constant for the F22 function key. - *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    - */ - public static final short VK_F22 = (short) 0xF009; + /** Constant for the F21 function key. See {@link #VK_F1}. */ + public static final short VK_F21 = (short) ( 0x60+21 ); - /** - * Constant for the F23 function key. - *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    - */ - public static final short VK_F23 = (short) 0xF00A; + /** Constant for the F22 function key. See {@link #VK_F1}. */ + public static final short VK_F22 = (short) ( 0x60+22 ); - /** - * Constant for the F24 function key. - *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    - */ - public static final short VK_F24 = (short) 0xF00B; + /** Constant for the F23 function key. See {@link #VK_F1}. */ + public static final short VK_F23 = (short) ( 0x60+23 ); - public static final short VK_PRINTSCREEN = (short) 0x9A; - public static final short VK_INSERT = (short) 0x9B; - public static final short VK_HELP = (short) 0x9C; - public static final short VK_META = (short) 0x9D; + /** Constant for the F24 function key. See {@link #VK_F1}. */ + public static final short VK_F24 = (short) ( 0x60+24 ); - public static final short VK_BACK_QUOTE = (short) 0xC0; - public static final short VK_QUOTE = (short) 0xDE; + + /** Constant for the "{" key */ + public static final short VK_LEFT_BRACE = (short) 0x7B; + /** Constant for the "|" key */ + public static final short VK_PIPE = (short) 0x7C; + /** Constant for the "}" key */ + public static final short VK_RIGHT_BRACE = (short) 0x7D; + + /** Constant for the "~" key, matching ASCII */ + public static final short VK_TILDE = (short) 0x7E; + + // + // Unicode: Non printable controls: [0x7F - 0x9F] + // + + /** Constant for the DEL key, matching ASCII. Non printable UTF control. */ + public static final short VK_DELETE = (short) 0x7F; + + /** Numeric keypad VK_NUMPAD0 thru VK_NUMPAD9 are mapped to UTF control (0x80 - 0x89). Non printable UTF control. */ + public static final short VK_NUMPAD0 = (short) 0x80; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD1 = (short) 0x81; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD2 = (short) 0x82; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD3 = (short) 0x83; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD4 = (short) 0x84; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD5 = (short) 0x85; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD6 = (short) 0x86; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD7 = (short) 0x87; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD8 = (short) 0x88; + /** See {@link #VK_NUMPAD0}. */ + public static final short VK_NUMPAD9 = (short) 0x89; + + /** Numeric keypad decimal separator key. Non printable UTF control. */ + public static final short VK_DECIMAL = (short) 0x8A; + + /** Numeric keypad decimal separator key. Non printable UTF control. */ + public static final short VK_SEPARATOR = (short) 0x8B; + + /** Numeric keypad add key. Non printable UTF control. */ + public static final short VK_ADD = (short) 0x8C; - /** - * Constant for the numeric keypad up arrow key. - * @see #VK_UP - */ - public static final short VK_KP_UP = (short) 0xE0; + /** Numeric keypad subtract key. Non printable UTF control. */ + public static final short VK_SUBTRACT = (short) 0x8D; + + /** Numeric keypad multiply key. Non printable UTF control. */ + public static final short VK_MULTIPLY = (short) 0x8E; + + /** Numeric keypad divide key. Non printable UTF control. */ + public static final short VK_DIVIDE = (short) 0x8F; + + /** Numeric keypad num lock key. Non printable UTF control. */ + public static final short VK_NUM_LOCK = (short) 0x90; + + /** Numeric keypad left arrow key, for cursor pad see {@link #VK_LEFT}. Non printable UTF control. */ + public static final short VK_KP_LEFT = (short) 0x91; - /** - * Constant for the numeric keypad down arrow key. - * @see #VK_DOWN - */ - public static final short VK_KP_DOWN = (short) 0xE1; + /** Numeric keypad up arrow key, for cursor pad see {@link #VK_UP}. Non printable UTF control. */ + public static final short VK_KP_UP = (short) 0x92; - /** - * Constant for the numeric keypad left arrow key. - * @see #VK_LEFT - */ - public static final short VK_KP_LEFT = (short) 0xE2; + /** Constant for the numeric keypad right arrow key, for cursor pad see {@link #VK_RIGHT}. Non printable UTF control. */ + public static final short VK_KP_RIGHT = (short) 0x93; + + /** Numeric keypad down arrow key, for cursor pad see {@link #VK_DOWN}. Non printable UTF control. */ + public static final short VK_KP_DOWN = (short) 0x94; - /** - * Constant for the numeric keypad right arrow key. - * @see #VK_RIGHT - */ - public static final short VK_KP_RIGHT = (short) 0xE3; - - /** For European keyboards */ - public static final short VK_DEAD_GRAVE = (short) 0x80; - /** For European keyboards */ - public static final short VK_DEAD_ACUTE = (short) 0x81; - /** For European keyboards */ - public static final short VK_DEAD_CIRCUMFLEX = (short) 0x82; - /** For European keyboards */ - public static final short VK_DEAD_TILDE = (short) 0x83; - /** For European keyboards */ - public static final short VK_DEAD_MACRON = (short) 0x84; - /** For European keyboards */ - public static final short VK_DEAD_BREVE = (short) 0x85; - /** For European keyboards */ - public static final short VK_DEAD_ABOVEDOT = (short) 0x86; - /** For European keyboards */ - public static final short VK_DEAD_DIAERESIS = (short) 0x87; - /** For European keyboards */ - public static final short VK_DEAD_ABOVERING = (short) 0x88; - /** For European keyboards */ - public static final short VK_DEAD_DOUBLEACUTE = (short) 0x89; - /** For European keyboards */ - public static final short VK_DEAD_CARON = (short) 0x8a; - /** For European keyboards */ - public static final short VK_DEAD_CEDILLA = (short) 0x8b; - /** For European keyboards */ - public static final short VK_DEAD_OGONEK = (short) 0x8c; - /** For European keyboards */ - public static final short VK_DEAD_IOTA = (short) 0x8d; - /** For European keyboards */ - public static final short VK_DEAD_VOICED_SOUND = (short) 0x8e; - /** For European keyboards */ - public static final short VK_DEAD_SEMIVOICED_SOUND = (short) 0x8f; - - /** For European keyboards */ - public static final short VK_AMPERSAND = (short) 0x96; - /** For European keyboards */ - public static final short VK_ASTERISK = (short) 0x97; - /** For European keyboards */ - public static final short VK_QUOTEDBL = (short) 0x98; - /** For European keyboards */ - public static final short VK_LESS = (short) 0x99; - - /** For European keyboards */ - public static final short VK_GREATER = (short) 0xa0; - /** For European keyboards */ - public static final short VK_BRACELEFT = (short) 0xa1; - /** For European keyboards */ - public static final short VK_BRACERIGHT = (short) 0xa2; + /** Constant for the cursor-pad left arrow key, for numerical pad see {@link #VK_KP_LEFT}*/ + public static final short VK_LEFT = (short) 0x95; - /** - * Constant for the "@" key. - */ - public static final short VK_AT = (short) 0x0200; + /** Constant for the cursor-pad left arrow key, for numerical pad see {@link #VK_KP_UP}.*/ + public static final short VK_UP = (short) 0x96; - /** - * Constant for the ":" key. - */ - public static final short VK_COLON = (short) 0x0201; + /** Constant for the cursor-pad left arrow key, for numerical pad see {@link #VK_KP_RIGHT}.*/ + public static final short VK_RIGHT = (short) 0x97; - /** - * Constant for the "^" key. - */ - public static final short VK_CIRCUMFLEX = (short) 0x0202; + /** Constant for the cursor-pad left arrow key, for numerical pad see {@link #VK_KP_DOWN}.*/ + public static final short VK_DOWN = (short) 0x98; + + /** Constant for the Context Menu key. */ + public static final short VK_CONTEXT_MENU = (short) 0x99; /** - * Constant for the "$" key. + * Constant for the MS "Windows" function key. + * It is used for both the left and right version of the key. */ - public static final short VK_DOLLAR = (short) 0x0203; + public static final short VK_WINDOWS = (short) 0x9A; - /** - * Constant for the Euro currency sign key. - */ - public static final short VK_EURO_SIGN = (short) 0x0204; + /** Constant for the Meta function key. */ + public static final short VK_META = (short) 0x9B; + + /** Constant for the Help function key. */ + public static final short VK_HELP = (short) 0x9C; + + /** Constant for the Compose function key. */ + public static final short VK_COMPOSE = (short) 0x9D; - /** - * Constant for the "!" key. - */ - public static final short VK_EXCLAMATION_MARK = (short) 0x0205; + /** Constant for the Begin function key. */ + public static final short VK_BEGIN = (short) 0x9E; - /** - * Constant for the inverted exclamation mark key. - */ - public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0x0206; + /** Constant for the Stop function key. */ + public static final short VK_STOP = (short) 0x9F; + + // + // Unicode: Printable [0x00A0 - 0xDFFF] + // + + /** Constant for the inverted exclamation mark key. */ + public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0xA1; + + /** Constant for the Euro currency sign key. */ + public static final short VK_EURO_SIGN = (short) 0x20AC; - /** - * Constant for the "(" key. - */ - public static final short VK_LEFT_PARENTHESIS = (short) 0x0207; + // + // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) + // + + /* for Sun keyboards */ + public static final short VK_CUT = (short) 0xF879; + public static final short VK_COPY = (short) 0xF87A; + public static final short VK_PASTE = (short) 0xF87B; + public static final short VK_UNDO = (short) 0xF87C; + public static final short VK_AGAIN = (short) 0xF87D; + public static final short VK_FIND = (short) 0xF87E; + public static final short VK_PROPS = (short) 0xF87F; - /** - * Constant for the "#" key. - */ - public static final short VK_NUMBER_SIGN = (short) 0x0208; + /* for input method support on Asian Keyboards */ /** - * Constant for the "+" key. + * Constant for the input method on/off key. */ - public static final short VK_PLUS = (short) 0x0209; - + /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */ + public static final short VK_INPUT_METHOD_ON_OFF = (short) 0xF890; + /** - * Constant for the ")" key. + * Constant for the Code Input function key. */ - public static final short VK_RIGHT_PARENTHESIS = (short) 0x020A; + /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */ + public static final short VK_CODE_INPUT = (short) 0xF891; /** - * Constant for the "_" key. + * Constant for the Roman Characters function key. */ - public static final short VK_UNDERSCORE = (short) 0x020B; + /* Japanese PC 106 keyboard: roumaji */ + public static final short VK_ROMAN_CHARACTERS = (short) 0xF892; /** - * Constant for the Microsoft Windows "Windows" key. - * It is used for both the left and right version of the key. + * Constant for the All Candidates function key. */ - public static final short VK_WINDOWS = (short) 0x020C; + /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */ + public static final short VK_ALL_CANDIDATES = (short) 0xF893; /** - * Constant for the Microsoft Windows Context Menu key. + * Constant for the Previous Candidate function key. */ - public static final short VK_CONTEXT_MENU = (short) 0x020D; - - /* for input method support on Asian Keyboards */ - - /* not clear what this means - listed in Microsoft Windows API */ - public static final short VK_FINAL = (short) 0x0018; - - /** Constant for the Convert function key. */ - /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */ - public static final short VK_CONVERT = (short) 0x001C; - - /** Constant for the Don't Convert function key. */ - /* Japanese PC 106 keyboard: muhenkan */ - public static final short VK_NONCONVERT = (short) 0x001D; - - /** Constant for the Accept or Commit function key. */ - /* Japanese Solaris keyboard: kakutei */ - public static final short VK_ACCEPT = (short) 0x001E; - - /* not clear what this means - listed in Microsoft Windows API */ - public static final short VK_MODECHANGE = (short) 0x001F; - - /* replaced by VK_KANA_LOCK for Microsoft Windows and Solaris; - might still be used on other platforms */ - public static final short VK_KANA = (short) 0x0015; - - /* replaced by VK_INPUT_METHOD_ON_OFF for Microsoft Windows and Solaris; - might still be used for other platforms */ - public static final short VK_KANJI = (short) 0x0019; + /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */ + public static final short VK_PREVIOUS_CANDIDATE = (short) 0xF894; /** * Constant for the Alphanumeric function key. */ /* Japanese PC 106 keyboard: eisuu */ - public static final short VK_ALPHANUMERIC = (short) 0x00F0; + public static final short VK_ALPHANUMERIC = (short) 0xF895; /** * Constant for the Katakana function key. */ /* Japanese PC 106 keyboard: katakana */ - public static final short VK_KATAKANA = (short) 0x00F1; + public static final short VK_KATAKANA = (short) 0xF896; /** * Constant for the Hiragana function key. */ /* Japanese PC 106 keyboard: hiragana */ - public static final short VK_HIRAGANA = (short) 0x00F2; + public static final short VK_HIRAGANA = (short) 0xF897; /** * Constant for the Full-Width Characters function key. */ /* Japanese PC 106 keyboard: zenkaku */ - public static final short VK_FULL_WIDTH = (short) 0x00F3; + public static final short VK_FULL_WIDTH = (short) 0xF898; /** * Constant for the Half-Width Characters function key. */ /* Japanese PC 106 keyboard: hankaku */ - public static final short VK_HALF_WIDTH = (short) 0x00F4; - - /** - * Constant for the Roman Characters function key. - */ - /* Japanese PC 106 keyboard: roumaji */ - public static final short VK_ROMAN_CHARACTERS = (short) 0x00F5; - - /** - * Constant for the All Candidates function key. - */ - /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */ - public static final short VK_ALL_CANDIDATES = (short) 0x0100; - - /** - * Constant for the Previous Candidate function key. - */ - /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */ - public static final short VK_PREVIOUS_CANDIDATE = (short) 0x0101; - - /** - * Constant for the Code Input function key. - */ - /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */ - public static final short VK_CODE_INPUT = (short) 0x0102; + public static final short VK_HALF_WIDTH = (short) 0xF89A; /** * Constant for the Japanese-Katakana function key. * This key switches to a Japanese input method and selects its Katakana input mode. */ /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */ - public static final short VK_JAPANESE_KATAKANA = (short) 0x0103; + public static final short VK_JAPANESE_KATAKANA = (short) 0xF89B; /** * Constant for the Japanese-Hiragana function key. * This key switches to a Japanese input method and selects its Hiragana input mode. */ /* Japanese Macintosh keyboard */ - public static final short VK_JAPANESE_HIRAGANA = (short) 0x0104; + public static final short VK_JAPANESE_HIRAGANA = (short) 0xF89C; /** * Constant for the Japanese-Roman function key. * This key switches to a Japanese input method and selects its Roman-Direct input mode. */ /* Japanese Macintosh keyboard */ - public static final short VK_JAPANESE_ROMAN = (short) 0x0105; + public static final short VK_JAPANESE_ROMAN = (short) 0xF89D; /** * Constant for the locking Kana function key. * This key locks the keyboard into a Kana layout. */ /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */ - public static final short VK_KANA_LOCK = (short) 0x0106; - - /** - * Constant for the input method on/off key. - */ - /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */ - public static final short VK_INPUT_METHOD_ON_OFF = (short) 0x0107; - - /* for Sun keyboards */ - public static final short VK_CUT = (short) 0xFFD1; - public static final short VK_COPY = (short) 0xFFCD; - public static final short VK_PASTE = (short) 0xFFCF; - public static final short VK_UNDO = (short) 0xFFCB; - public static final short VK_AGAIN = (short) 0xFFC9; - public static final short VK_FIND = (short) 0xFFD0; - public static final short VK_PROPS = (short) 0xFFCA; - public static final short VK_STOP = (short) 0xFFC8; - - /** - * Constant for the Compose function key. - */ - public static final short VK_COMPOSE = (short) 0xFF20; - - /** - * Constant for the ALT_GRAPH function key, i.e. right ALT key. - */ - public static final short VK_ALT_GRAPH = (short) 0xFF7E; - - /** - * Constant for the Begin key. - */ - public static final short VK_BEGIN = (short) 0xFF58; + public static final short VK_KANA_LOCK = (short) 0xF89F; /** * Constant for Keyboard became invisible, e.g. Android's soft keyboard Back button hit while keyboard is visible. */ - public static final short VK_KEYBOARD_INVISIBLE = (short) 0xDEAD; - - /** - * This value, {@value}, is used to indicate that the keyCode is unknown. - */ - public static final short VK_UNDEFINED = (short) 0x0; - - /** - * This value, {@code '\0'}, is used to indicate that the keyChar is unknown or not printable. - */ - public static final char NULL_CHAR = '\0'; + public static final short VK_KEYBOARD_INVISIBLE = (short) 0xF8FF; } diff --git a/src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java b/src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java deleted file mode 100644 index 73afa0993..000000000 --- a/src/newt/classes/com/jogamp/newt/event/UTFKeyUtil.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.newt.event; - -import com.jogamp.newt.event.KeyEvent; - -public class UTFKeyUtil { - - // - // UTF Key Constants - // - private static final char UTF_Equal = '='; - private static final char UTF_Minus = '-'; - private static final char UTF_RightBracket = ']'; - private static final char UTF_LeftBracket = '['; - private static final char UTF_Quote = '\''; - private static final char UTF_Semicolon = ';'; - private static final char UTF_Backslash = '\\'; - private static final char UTF_Comma = ','; - private static final char UTF_Slash = '/'; - private static final char UTF_Period = '.'; - private static final char UTF_Grave = '`'; // back quote - - /** - * @param keyChar UTF16 value to map. Note: Lower case values are preferred. - * @return {@link KeyEvent} virtual key (VK) value if possible, - * otherwise simply the UTF16 value of type short as a last resort. - */ - public static short utf16ToVKey(char keyChar) { - if( 'a' <= keyChar && keyChar <= 'z' ) { - return (short) ( ( keyChar - 'a' ) + KeyEvent.VK_A ); - } - if( '0' <= keyChar && keyChar <= '9' ) { - return (short) ( ( keyChar - '0' ) + KeyEvent.VK_0 ); - } - switch(keyChar) { - // - // KeyCodes (Layout Dependent) - // - case UTF_Equal: return KeyEvent.VK_EQUALS; - case UTF_Minus: return KeyEvent.VK_MINUS; - case UTF_RightBracket: return KeyEvent.VK_CLOSE_BRACKET; - case UTF_LeftBracket: return KeyEvent.VK_OPEN_BRACKET; - case UTF_Quote: return KeyEvent.VK_QUOTE; - case UTF_Semicolon: return KeyEvent.VK_SEMICOLON; - case UTF_Backslash: return KeyEvent.VK_BACK_SLASH; - case UTF_Comma: return KeyEvent.VK_COMMA; - case UTF_Slash: return KeyEvent.VK_SLASH; - case UTF_Period: return KeyEvent.VK_PERIOD; - case UTF_Grave: return KeyEvent.VK_BACK_QUOTE; // KeyEvent.VK_DEAD_GRAVE - } - if( 'A' <= keyChar && keyChar <= 'Z' ) { - return (short) ( ( keyChar - 'A' ) + KeyEvent.VK_A ); - } - return (short) keyChar; - } -} diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index e5dd783ca..01a58a305 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2251,41 +2251,45 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // KeyListener/Event Support // - protected IntBitfield keyPressedState = new IntBitfield(KeyEvent.VK_CONTEXT_MENU+1); - protected IntBitfield keyRepeatState = new IntBitfield(KeyEvent.VK_CONTEXT_MENU+1); + private static final int keyTrackingRange = 255; + private final IntBitfield keyPressedState = new IntBitfield( keyTrackingRange + 1 ); + + protected final boolean isKeyCodeTracked(final short keyCode) { + return ( 0xFFFF & (int)keyCode ) <= keyTrackingRange; + } /** - * @param keyCode - * @return 1 if pressed, 0 if not pressed, -1 if not handled. + * @param keyCode the keyCode to set pressed state + * @param pressed true if pressed, otherwise false + * @return the previus pressed value */ - protected final int isKeyPressed(int keyCode) { - if( 0 <= keyCode && keyCode < keyPressedState.capacity() ) { - return keyPressedState.get(keyCode) ? 1 : 0; + protected final boolean setKeyPressed(short keyCode, boolean pressed) { + final int v = 0xFFFF & (int)keyCode; + if( v <= keyTrackingRange ) { + return keyPressedState.put(v, pressed); } - return -1; + return false; } /** - * @param keyCode - * @return 1 if pressed, 0 if not pressed, -1 if not handled. + * @param keyCode the keyCode to test pressed state + * @return true if pressed, otherwise false */ - protected final int isKeyInAutoRepeat(int keyCode) { - if( 0 <= keyCode && keyCode < keyRepeatState.capacity() ) { - return keyRepeatState.get(keyCode) ? 1 : 0; + protected final boolean isKeyPressed(short keyCode) { + final int v = 0xFFFF & (int)keyCode; + if( v <= keyTrackingRange ) { + return keyPressedState.get(v); } - return -1; - } - protected final boolean isKeyCodeTracked(int keyCode) { - return 0 <= keyCode && keyCode < keyRepeatState.capacity(); + return false; } public void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask - consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); + consumeKeyEvent( KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); } public void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask - enqueueEvent(wait, new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); + enqueueEvent(wait, KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); } @Override @@ -2400,7 +2404,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Synthesize deprecated event KeyEvent.EVENT_KEY_TYPED final KeyEvent eTyped; if( KeyEvent.EVENT_KEY_RELEASED == e.getEventType() && e.isPrintableKey() && !e.isAutoRepeat() ) { - eTyped = new KeyEvent(KeyEvent.EVENT_KEY_TYPED, e.getSource(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeySymbol(), e.getKeyChar()); + eTyped = KeyEvent.create(KeyEvent.EVENT_KEY_TYPED, e.getSource(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeySymbol(), e.getKeyChar()); } else { eTyped = null; } diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index b90c2106e..ccbdc07bf 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -176,6 +176,14 @@ public class AWTNewtEventFactory { } } + public static final short awtButton2Newt(int awtButton) { + if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + return (short)awtButton; + } else { + return (short)0; + } + } + /** * Converts the specified set of AWT event modifiers and extended event * modifiers to the equivalent NEWT event modifiers. @@ -223,12 +231,365 @@ public class AWTNewtEventFactory { return newtMods; } - public static final short awtButton2Newt(int awtButton) { - if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { - return (short)awtButton; - } else { - return (short)0; + public static short awtKeyCode2NewtKeyCode(final int awtKeyCode) { + final short defNEWTKeyCode = (short)awtKeyCode; + switch (awtKeyCode) { + case java.awt.event.KeyEvent.VK_HOME : return com.jogamp.newt.event.KeyEvent.VK_HOME; + case java.awt.event.KeyEvent.VK_END : return com.jogamp.newt.event.KeyEvent.VK_END; + case java.awt.event.KeyEvent.VK_FINAL : return com.jogamp.newt.event.KeyEvent.VK_FINAL; + case java.awt.event.KeyEvent.VK_PRINTSCREEN : return com.jogamp.newt.event.KeyEvent.VK_PRINTSCREEN; + case java.awt.event.KeyEvent.VK_BACK_SPACE : return com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE; + case java.awt.event.KeyEvent.VK_TAB : return com.jogamp.newt.event.KeyEvent.VK_TAB; + case java.awt.event.KeyEvent.VK_ENTER : return com.jogamp.newt.event.KeyEvent.VK_ENTER; + case java.awt.event.KeyEvent.VK_PAGE_DOWN : return com.jogamp.newt.event.KeyEvent.VK_PAGE_DOWN; + case java.awt.event.KeyEvent.VK_CLEAR : return com.jogamp.newt.event.KeyEvent.VK_CLEAR; + case java.awt.event.KeyEvent.VK_SHIFT : return com.jogamp.newt.event.KeyEvent.VK_SHIFT; + case java.awt.event.KeyEvent.VK_PAGE_UP : return com.jogamp.newt.event.KeyEvent.VK_PAGE_UP; + case java.awt.event.KeyEvent.VK_CONTROL : return com.jogamp.newt.event.KeyEvent.VK_CONTROL; + case java.awt.event.KeyEvent.VK_ALT : return com.jogamp.newt.event.KeyEvent.VK_ALT; + case java.awt.event.KeyEvent.VK_ALT_GRAPH : return com.jogamp.newt.event.KeyEvent.VK_ALT_GRAPH; + case java.awt.event.KeyEvent.VK_CAPS_LOCK : return com.jogamp.newt.event.KeyEvent.VK_CAPS_LOCK; + case java.awt.event.KeyEvent.VK_PAUSE : return com.jogamp.newt.event.KeyEvent.VK_PAUSE; + case java.awt.event.KeyEvent.VK_SCROLL_LOCK : return com.jogamp.newt.event.KeyEvent.VK_SCROLL_LOCK; + case java.awt.event.KeyEvent.VK_CANCEL : return com.jogamp.newt.event.KeyEvent.VK_CANCEL; + case java.awt.event.KeyEvent.VK_INSERT : return com.jogamp.newt.event.KeyEvent.VK_INSERT; + case java.awt.event.KeyEvent.VK_ESCAPE : return com.jogamp.newt.event.KeyEvent.VK_ESCAPE; + case java.awt.event.KeyEvent.VK_CONVERT : return com.jogamp.newt.event.KeyEvent.VK_CONVERT; + case java.awt.event.KeyEvent.VK_NONCONVERT : return com.jogamp.newt.event.KeyEvent.VK_NONCONVERT; + case java.awt.event.KeyEvent.VK_ACCEPT : return com.jogamp.newt.event.KeyEvent.VK_ACCEPT; + case java.awt.event.KeyEvent.VK_MODECHANGE : return com.jogamp.newt.event.KeyEvent.VK_MODECHANGE; + case java.awt.event.KeyEvent.VK_SPACE : return com.jogamp.newt.event.KeyEvent.VK_SPACE; + case java.awt.event.KeyEvent.VK_EXCLAMATION_MARK: return com.jogamp.newt.event.KeyEvent.VK_EXCLAMATION_MARK; + case java.awt.event.KeyEvent.VK_QUOTEDBL : return com.jogamp.newt.event.KeyEvent.VK_QUOTEDBL; + case java.awt.event.KeyEvent.VK_NUMBER_SIGN : return com.jogamp.newt.event.KeyEvent.VK_NUMBER_SIGN; + case java.awt.event.KeyEvent.VK_DOLLAR : return com.jogamp.newt.event.KeyEvent.VK_DOLLAR; + // case 0x25 : return com.jogamp.newt.event.KeyEvent.VK_PERCENT; + case java.awt.event.KeyEvent.VK_AMPERSAND : return com.jogamp.newt.event.KeyEvent.VK_AMPERSAND; + case java.awt.event.KeyEvent.VK_QUOTE : return com.jogamp.newt.event.KeyEvent.VK_QUOTE; + case java.awt.event.KeyEvent.VK_LEFT_PARENTHESIS : return com.jogamp.newt.event.KeyEvent.VK_LEFT_PARENTHESIS; + case java.awt.event.KeyEvent.VK_RIGHT_PARENTHESIS: return com.jogamp.newt.event.KeyEvent.VK_RIGHT_PARENTHESIS; + case java.awt.event.KeyEvent.VK_ASTERISK : return com.jogamp.newt.event.KeyEvent.VK_ASTERISK; + case java.awt.event.KeyEvent.VK_PLUS : return com.jogamp.newt.event.KeyEvent.VK_PLUS; + case java.awt.event.KeyEvent.VK_COMMA : return com.jogamp.newt.event.KeyEvent.VK_COMMA; + case java.awt.event.KeyEvent.VK_MINUS : return com.jogamp.newt.event.KeyEvent.VK_MINUS; + case java.awt.event.KeyEvent.VK_PERIOD : return com.jogamp.newt.event.KeyEvent.VK_PERIOD; + case java.awt.event.KeyEvent.VK_SLASH : return com.jogamp.newt.event.KeyEvent.VK_SLASH; + case java.awt.event.KeyEvent.VK_0 : return com.jogamp.newt.event.KeyEvent.VK_0; + case java.awt.event.KeyEvent.VK_1 : return com.jogamp.newt.event.KeyEvent.VK_1; + case java.awt.event.KeyEvent.VK_2 : return com.jogamp.newt.event.KeyEvent.VK_2; + case java.awt.event.KeyEvent.VK_3 : return com.jogamp.newt.event.KeyEvent.VK_3; + case java.awt.event.KeyEvent.VK_4 : return com.jogamp.newt.event.KeyEvent.VK_4; + case java.awt.event.KeyEvent.VK_5 : return com.jogamp.newt.event.KeyEvent.VK_5; + case java.awt.event.KeyEvent.VK_6 : return com.jogamp.newt.event.KeyEvent.VK_6; + case java.awt.event.KeyEvent.VK_7 : return com.jogamp.newt.event.KeyEvent.VK_7; + case java.awt.event.KeyEvent.VK_8 : return com.jogamp.newt.event.KeyEvent.VK_8; + case java.awt.event.KeyEvent.VK_9 : return com.jogamp.newt.event.KeyEvent.VK_9; + case java.awt.event.KeyEvent.VK_COLON : return com.jogamp.newt.event.KeyEvent.VK_COLON; + case java.awt.event.KeyEvent.VK_SEMICOLON : return com.jogamp.newt.event.KeyEvent.VK_SEMICOLON; + case java.awt.event.KeyEvent.VK_LESS : return com.jogamp.newt.event.KeyEvent.VK_LESS; + case java.awt.event.KeyEvent.VK_EQUALS : return com.jogamp.newt.event.KeyEvent.VK_EQUALS; + case java.awt.event.KeyEvent.VK_GREATER : return com.jogamp.newt.event.KeyEvent.VK_GREATER; + case 0x3f : return com.jogamp.newt.event.KeyEvent.VK_QUESTIONMARK; + case java.awt.event.KeyEvent.VK_AT : return com.jogamp.newt.event.KeyEvent.VK_AT; + case java.awt.event.KeyEvent.VK_A : return com.jogamp.newt.event.KeyEvent.VK_A; + case java.awt.event.KeyEvent.VK_B : return com.jogamp.newt.event.KeyEvent.VK_B; + case java.awt.event.KeyEvent.VK_C : return com.jogamp.newt.event.KeyEvent.VK_C; + case java.awt.event.KeyEvent.VK_D : return com.jogamp.newt.event.KeyEvent.VK_D; + case java.awt.event.KeyEvent.VK_E : return com.jogamp.newt.event.KeyEvent.VK_E; + case java.awt.event.KeyEvent.VK_F : return com.jogamp.newt.event.KeyEvent.VK_F; + case java.awt.event.KeyEvent.VK_G : return com.jogamp.newt.event.KeyEvent.VK_G; + case java.awt.event.KeyEvent.VK_H : return com.jogamp.newt.event.KeyEvent.VK_H; + case java.awt.event.KeyEvent.VK_I : return com.jogamp.newt.event.KeyEvent.VK_I; + case java.awt.event.KeyEvent.VK_J : return com.jogamp.newt.event.KeyEvent.VK_J; + case java.awt.event.KeyEvent.VK_K : return com.jogamp.newt.event.KeyEvent.VK_K; + case java.awt.event.KeyEvent.VK_L : return com.jogamp.newt.event.KeyEvent.VK_L; + case java.awt.event.KeyEvent.VK_M : return com.jogamp.newt.event.KeyEvent.VK_M; + case java.awt.event.KeyEvent.VK_N : return com.jogamp.newt.event.KeyEvent.VK_N; + case java.awt.event.KeyEvent.VK_O : return com.jogamp.newt.event.KeyEvent.VK_O; + case java.awt.event.KeyEvent.VK_P : return com.jogamp.newt.event.KeyEvent.VK_P; + case java.awt.event.KeyEvent.VK_Q : return com.jogamp.newt.event.KeyEvent.VK_Q; + case java.awt.event.KeyEvent.VK_R : return com.jogamp.newt.event.KeyEvent.VK_R; + case java.awt.event.KeyEvent.VK_S : return com.jogamp.newt.event.KeyEvent.VK_S; + case java.awt.event.KeyEvent.VK_T : return com.jogamp.newt.event.KeyEvent.VK_T; + case java.awt.event.KeyEvent.VK_U : return com.jogamp.newt.event.KeyEvent.VK_U; + case java.awt.event.KeyEvent.VK_V : return com.jogamp.newt.event.KeyEvent.VK_V; + case java.awt.event.KeyEvent.VK_W : return com.jogamp.newt.event.KeyEvent.VK_W; + case java.awt.event.KeyEvent.VK_X : return com.jogamp.newt.event.KeyEvent.VK_X; + case java.awt.event.KeyEvent.VK_Y : return com.jogamp.newt.event.KeyEvent.VK_Y; + case java.awt.event.KeyEvent.VK_Z : return com.jogamp.newt.event.KeyEvent.VK_Z; + case java.awt.event.KeyEvent.VK_OPEN_BRACKET : return com.jogamp.newt.event.KeyEvent.VK_OPEN_BRACKET; + case java.awt.event.KeyEvent.VK_BACK_SLASH : return com.jogamp.newt.event.KeyEvent.VK_BACK_SLASH; + case java.awt.event.KeyEvent.VK_CLOSE_BRACKET : return com.jogamp.newt.event.KeyEvent.VK_CLOSE_BRACKET; + case java.awt.event.KeyEvent.VK_CIRCUMFLEX : return com.jogamp.newt.event.KeyEvent.VK_CIRCUMFLEX; + case java.awt.event.KeyEvent.VK_UNDERSCORE : return com.jogamp.newt.event.KeyEvent.VK_UNDERSCORE; + case java.awt.event.KeyEvent.VK_BACK_QUOTE : return com.jogamp.newt.event.KeyEvent.VK_BACK_QUOTE; + case java.awt.event.KeyEvent.VK_F1 : return com.jogamp.newt.event.KeyEvent.VK_F1; + case java.awt.event.KeyEvent.VK_F2 : return com.jogamp.newt.event.KeyEvent.VK_F2; + case java.awt.event.KeyEvent.VK_F3 : return com.jogamp.newt.event.KeyEvent.VK_F3; + case java.awt.event.KeyEvent.VK_F4 : return com.jogamp.newt.event.KeyEvent.VK_F4; + case java.awt.event.KeyEvent.VK_F5 : return com.jogamp.newt.event.KeyEvent.VK_F5; + case java.awt.event.KeyEvent.VK_F6 : return com.jogamp.newt.event.KeyEvent.VK_F6; + case java.awt.event.KeyEvent.VK_F7 : return com.jogamp.newt.event.KeyEvent.VK_F7; + case java.awt.event.KeyEvent.VK_F8 : return com.jogamp.newt.event.KeyEvent.VK_F8; + case java.awt.event.KeyEvent.VK_F9 : return com.jogamp.newt.event.KeyEvent.VK_F9; + case java.awt.event.KeyEvent.VK_F10 : return com.jogamp.newt.event.KeyEvent.VK_F10; + case java.awt.event.KeyEvent.VK_F11 : return com.jogamp.newt.event.KeyEvent.VK_F11; + case java.awt.event.KeyEvent.VK_F12 : return com.jogamp.newt.event.KeyEvent.VK_F12; + case java.awt.event.KeyEvent.VK_F13 : return com.jogamp.newt.event.KeyEvent.VK_F13; + case java.awt.event.KeyEvent.VK_F14 : return com.jogamp.newt.event.KeyEvent.VK_F14; + case java.awt.event.KeyEvent.VK_F15 : return com.jogamp.newt.event.KeyEvent.VK_F15; + case java.awt.event.KeyEvent.VK_F16 : return com.jogamp.newt.event.KeyEvent.VK_F16; + case java.awt.event.KeyEvent.VK_F17 : return com.jogamp.newt.event.KeyEvent.VK_F17; + case java.awt.event.KeyEvent.VK_F18 : return com.jogamp.newt.event.KeyEvent.VK_F18; + case java.awt.event.KeyEvent.VK_F19 : return com.jogamp.newt.event.KeyEvent.VK_F19; + case java.awt.event.KeyEvent.VK_F20 : return com.jogamp.newt.event.KeyEvent.VK_F20; + case java.awt.event.KeyEvent.VK_F21 : return com.jogamp.newt.event.KeyEvent.VK_F21; + case java.awt.event.KeyEvent.VK_F22 : return com.jogamp.newt.event.KeyEvent.VK_F22; + case java.awt.event.KeyEvent.VK_F23 : return com.jogamp.newt.event.KeyEvent.VK_F23; + case java.awt.event.KeyEvent.VK_F24 : return com.jogamp.newt.event.KeyEvent.VK_F24; + case java.awt.event.KeyEvent.VK_BRACELEFT : return com.jogamp.newt.event.KeyEvent.VK_LEFT_BRACE; + case 0x7c : return com.jogamp.newt.event.KeyEvent.VK_PIPE; + case java.awt.event.KeyEvent.VK_BRACERIGHT : return com.jogamp.newt.event.KeyEvent.VK_RIGHT_BRACE; + case java.awt.event.KeyEvent.VK_DEAD_TILDE : return com.jogamp.newt.event.KeyEvent.VK_TILDE; + case java.awt.event.KeyEvent.VK_DELETE : return com.jogamp.newt.event.KeyEvent.VK_DELETE; + case java.awt.event.KeyEvent.VK_NUMPAD0 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD0; + case java.awt.event.KeyEvent.VK_NUMPAD1 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD1; + case java.awt.event.KeyEvent.VK_NUMPAD2 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD2; + case java.awt.event.KeyEvent.VK_NUMPAD3 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD3; + case java.awt.event.KeyEvent.VK_NUMPAD4 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD4; + case java.awt.event.KeyEvent.VK_NUMPAD5 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD5; + case java.awt.event.KeyEvent.VK_NUMPAD6 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD6; + case java.awt.event.KeyEvent.VK_NUMPAD7 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD7; + case java.awt.event.KeyEvent.VK_NUMPAD8 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD8; + case java.awt.event.KeyEvent.VK_NUMPAD9 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD9; + case java.awt.event.KeyEvent.VK_DECIMAL : return com.jogamp.newt.event.KeyEvent.VK_DECIMAL; + case java.awt.event.KeyEvent.VK_SEPARATOR : return com.jogamp.newt.event.KeyEvent.VK_SEPARATOR; + case java.awt.event.KeyEvent.VK_ADD : return com.jogamp.newt.event.KeyEvent.VK_ADD; + case java.awt.event.KeyEvent.VK_SUBTRACT : return com.jogamp.newt.event.KeyEvent.VK_SUBTRACT; + case java.awt.event.KeyEvent.VK_MULTIPLY : return com.jogamp.newt.event.KeyEvent.VK_MULTIPLY; + case java.awt.event.KeyEvent.VK_DIVIDE : return com.jogamp.newt.event.KeyEvent.VK_DIVIDE; + case java.awt.event.KeyEvent.VK_NUM_LOCK : return com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK; + case java.awt.event.KeyEvent.VK_KP_LEFT : return com.jogamp.newt.event.KeyEvent.VK_KP_LEFT; + case java.awt.event.KeyEvent.VK_KP_UP : return com.jogamp.newt.event.KeyEvent.VK_KP_UP; + case java.awt.event.KeyEvent.VK_KP_RIGHT : return com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT; + case java.awt.event.KeyEvent.VK_KP_DOWN : return com.jogamp.newt.event.KeyEvent.VK_KP_DOWN; + case java.awt.event.KeyEvent.VK_LEFT : return com.jogamp.newt.event.KeyEvent.VK_LEFT; + case java.awt.event.KeyEvent.VK_UP : return com.jogamp.newt.event.KeyEvent.VK_UP; + case java.awt.event.KeyEvent.VK_RIGHT : return com.jogamp.newt.event.KeyEvent.VK_RIGHT; + case java.awt.event.KeyEvent.VK_DOWN : return com.jogamp.newt.event.KeyEvent.VK_DOWN; + case java.awt.event.KeyEvent.VK_CONTEXT_MENU : return com.jogamp.newt.event.KeyEvent.VK_CONTEXT_MENU; + case java.awt.event.KeyEvent.VK_WINDOWS : return com.jogamp.newt.event.KeyEvent.VK_WINDOWS; + case java.awt.event.KeyEvent.VK_META : return com.jogamp.newt.event.KeyEvent.VK_META; + case java.awt.event.KeyEvent.VK_HELP : return com.jogamp.newt.event.KeyEvent.VK_HELP; + case java.awt.event.KeyEvent.VK_COMPOSE : return com.jogamp.newt.event.KeyEvent.VK_COMPOSE; + case java.awt.event.KeyEvent.VK_BEGIN : return com.jogamp.newt.event.KeyEvent.VK_BEGIN; + case java.awt.event.KeyEvent.VK_STOP : return com.jogamp.newt.event.KeyEvent.VK_STOP; + case java.awt.event.KeyEvent.VK_INVERTED_EXCLAMATION_MARK: return com.jogamp.newt.event.KeyEvent.VK_INVERTED_EXCLAMATION_MARK; + case java.awt.event.KeyEvent.VK_EURO_SIGN : return com.jogamp.newt.event.KeyEvent.VK_EURO_SIGN; + case java.awt.event.KeyEvent.VK_CUT : return com.jogamp.newt.event.KeyEvent.VK_CUT; + case java.awt.event.KeyEvent.VK_COPY : return com.jogamp.newt.event.KeyEvent.VK_COPY; + case java.awt.event.KeyEvent.VK_PASTE : return com.jogamp.newt.event.KeyEvent.VK_PASTE; + case java.awt.event.KeyEvent.VK_UNDO : return com.jogamp.newt.event.KeyEvent.VK_UNDO; + case java.awt.event.KeyEvent.VK_AGAIN : return com.jogamp.newt.event.KeyEvent.VK_AGAIN; + case java.awt.event.KeyEvent.VK_FIND : return com.jogamp.newt.event.KeyEvent.VK_FIND; + case java.awt.event.KeyEvent.VK_PROPS : return com.jogamp.newt.event.KeyEvent.VK_PROPS; + case java.awt.event.KeyEvent.VK_INPUT_METHOD_ON_OFF: return com.jogamp.newt.event.KeyEvent.VK_INPUT_METHOD_ON_OFF; + case java.awt.event.KeyEvent.VK_CODE_INPUT : return com.jogamp.newt.event.KeyEvent.VK_CODE_INPUT; + case java.awt.event.KeyEvent.VK_ROMAN_CHARACTERS: return com.jogamp.newt.event.KeyEvent.VK_ROMAN_CHARACTERS; + case java.awt.event.KeyEvent.VK_ALL_CANDIDATES: return com.jogamp.newt.event.KeyEvent.VK_ALL_CANDIDATES; + case java.awt.event.KeyEvent.VK_PREVIOUS_CANDIDATE: return com.jogamp.newt.event.KeyEvent.VK_PREVIOUS_CANDIDATE; + case java.awt.event.KeyEvent.VK_ALPHANUMERIC : return com.jogamp.newt.event.KeyEvent.VK_ALPHANUMERIC; + case java.awt.event.KeyEvent.VK_KATAKANA : return com.jogamp.newt.event.KeyEvent.VK_KATAKANA; + case java.awt.event.KeyEvent.VK_HIRAGANA : return com.jogamp.newt.event.KeyEvent.VK_HIRAGANA; + case java.awt.event.KeyEvent.VK_FULL_WIDTH : return com.jogamp.newt.event.KeyEvent.VK_FULL_WIDTH; + case java.awt.event.KeyEvent.VK_HALF_WIDTH : return com.jogamp.newt.event.KeyEvent.VK_HALF_WIDTH; + case java.awt.event.KeyEvent.VK_JAPANESE_KATAKANA: return com.jogamp.newt.event.KeyEvent.VK_JAPANESE_KATAKANA; + case java.awt.event.KeyEvent.VK_JAPANESE_HIRAGANA: return com.jogamp.newt.event.KeyEvent.VK_JAPANESE_HIRAGANA; + case java.awt.event.KeyEvent.VK_JAPANESE_ROMAN: return com.jogamp.newt.event.KeyEvent.VK_JAPANESE_ROMAN; + case java.awt.event.KeyEvent.VK_KANA_LOCK : return com.jogamp.newt.event.KeyEvent.VK_KANA_LOCK; + } + return defNEWTKeyCode; + } + + public static int newtKeyCode2AWTKeyCode(final short newtKeyCode) { + final int defAwtKeyCode = 0xFFFF & (int)newtKeyCode; + switch (newtKeyCode) { + case com.jogamp.newt.event.KeyEvent.VK_HOME : return java.awt.event.KeyEvent.VK_HOME; + case com.jogamp.newt.event.KeyEvent.VK_END : return java.awt.event.KeyEvent.VK_END; + case com.jogamp.newt.event.KeyEvent.VK_FINAL : return java.awt.event.KeyEvent.VK_FINAL; + case com.jogamp.newt.event.KeyEvent.VK_PRINTSCREEN : return java.awt.event.KeyEvent.VK_PRINTSCREEN; + case com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE : return java.awt.event.KeyEvent.VK_BACK_SPACE; + case com.jogamp.newt.event.KeyEvent.VK_TAB : return java.awt.event.KeyEvent.VK_TAB; + case com.jogamp.newt.event.KeyEvent.VK_ENTER : return java.awt.event.KeyEvent.VK_ENTER; + case com.jogamp.newt.event.KeyEvent.VK_PAGE_DOWN : return java.awt.event.KeyEvent.VK_PAGE_DOWN; + case com.jogamp.newt.event.KeyEvent.VK_CLEAR : return java.awt.event.KeyEvent.VK_CLEAR; + case com.jogamp.newt.event.KeyEvent.VK_SHIFT : return java.awt.event.KeyEvent.VK_SHIFT; + case com.jogamp.newt.event.KeyEvent.VK_PAGE_UP : return java.awt.event.KeyEvent.VK_PAGE_UP; + case com.jogamp.newt.event.KeyEvent.VK_CONTROL : return java.awt.event.KeyEvent.VK_CONTROL; + case com.jogamp.newt.event.KeyEvent.VK_ALT : return java.awt.event.KeyEvent.VK_ALT; + // FIXME: On X11 it results to 0xff7e w/ AWTRobot, which is wrong. 0xffea Alt_R is expected AFAIK. + case com.jogamp.newt.event.KeyEvent.VK_ALT_GRAPH : return java.awt.event.KeyEvent.VK_ALT_GRAPH; + case com.jogamp.newt.event.KeyEvent.VK_CAPS_LOCK : return java.awt.event.KeyEvent.VK_CAPS_LOCK; + case com.jogamp.newt.event.KeyEvent.VK_PAUSE : return java.awt.event.KeyEvent.VK_PAUSE; + case com.jogamp.newt.event.KeyEvent.VK_SCROLL_LOCK : return java.awt.event.KeyEvent.VK_SCROLL_LOCK; + case com.jogamp.newt.event.KeyEvent.VK_CANCEL : return java.awt.event.KeyEvent.VK_CANCEL; + case com.jogamp.newt.event.KeyEvent.VK_INSERT : return java.awt.event.KeyEvent.VK_INSERT; + case com.jogamp.newt.event.KeyEvent.VK_ESCAPE : return java.awt.event.KeyEvent.VK_ESCAPE; + case com.jogamp.newt.event.KeyEvent.VK_CONVERT : return java.awt.event.KeyEvent.VK_CONVERT; + case com.jogamp.newt.event.KeyEvent.VK_NONCONVERT : return java.awt.event.KeyEvent.VK_NONCONVERT; + case com.jogamp.newt.event.KeyEvent.VK_ACCEPT : return java.awt.event.KeyEvent.VK_ACCEPT; + case com.jogamp.newt.event.KeyEvent.VK_MODECHANGE : return java.awt.event.KeyEvent.VK_MODECHANGE; + case com.jogamp.newt.event.KeyEvent.VK_SPACE : return java.awt.event.KeyEvent.VK_SPACE; + case com.jogamp.newt.event.KeyEvent.VK_EXCLAMATION_MARK: return java.awt.event.KeyEvent.VK_EXCLAMATION_MARK; + case com.jogamp.newt.event.KeyEvent.VK_QUOTEDBL : return java.awt.event.KeyEvent.VK_QUOTEDBL; + case com.jogamp.newt.event.KeyEvent.VK_NUMBER_SIGN : return java.awt.event.KeyEvent.VK_NUMBER_SIGN; + case com.jogamp.newt.event.KeyEvent.VK_DOLLAR : return java.awt.event.KeyEvent.VK_DOLLAR; + case com.jogamp.newt.event.KeyEvent.VK_PERCENT : return defAwtKeyCode; + case com.jogamp.newt.event.KeyEvent.VK_AMPERSAND : return java.awt.event.KeyEvent.VK_AMPERSAND; + case com.jogamp.newt.event.KeyEvent.VK_QUOTE : return java.awt.event.KeyEvent.VK_QUOTE; + case com.jogamp.newt.event.KeyEvent.VK_LEFT_PARENTHESIS : return java.awt.event.KeyEvent.VK_LEFT_PARENTHESIS; + case com.jogamp.newt.event.KeyEvent.VK_RIGHT_PARENTHESIS: return java.awt.event.KeyEvent.VK_RIGHT_PARENTHESIS; + case com.jogamp.newt.event.KeyEvent.VK_ASTERISK : return java.awt.event.KeyEvent.VK_ASTERISK; + case com.jogamp.newt.event.KeyEvent.VK_PLUS : return java.awt.event.KeyEvent.VK_PLUS; + case com.jogamp.newt.event.KeyEvent.VK_COMMA : return java.awt.event.KeyEvent.VK_COMMA; + case com.jogamp.newt.event.KeyEvent.VK_MINUS : return java.awt.event.KeyEvent.VK_MINUS; + case com.jogamp.newt.event.KeyEvent.VK_PERIOD : return java.awt.event.KeyEvent.VK_PERIOD; + case com.jogamp.newt.event.KeyEvent.VK_SLASH : return java.awt.event.KeyEvent.VK_SLASH; + case com.jogamp.newt.event.KeyEvent.VK_0 : return java.awt.event.KeyEvent.VK_0; + case com.jogamp.newt.event.KeyEvent.VK_1 : return java.awt.event.KeyEvent.VK_1; + case com.jogamp.newt.event.KeyEvent.VK_2 : return java.awt.event.KeyEvent.VK_2; + case com.jogamp.newt.event.KeyEvent.VK_3 : return java.awt.event.KeyEvent.VK_3; + case com.jogamp.newt.event.KeyEvent.VK_4 : return java.awt.event.KeyEvent.VK_4; + case com.jogamp.newt.event.KeyEvent.VK_5 : return java.awt.event.KeyEvent.VK_5; + case com.jogamp.newt.event.KeyEvent.VK_6 : return java.awt.event.KeyEvent.VK_6; + case com.jogamp.newt.event.KeyEvent.VK_7 : return java.awt.event.KeyEvent.VK_7; + case com.jogamp.newt.event.KeyEvent.VK_8 : return java.awt.event.KeyEvent.VK_8; + case com.jogamp.newt.event.KeyEvent.VK_9 : return java.awt.event.KeyEvent.VK_9; + case com.jogamp.newt.event.KeyEvent.VK_COLON : return java.awt.event.KeyEvent.VK_COLON; + case com.jogamp.newt.event.KeyEvent.VK_SEMICOLON : return java.awt.event.KeyEvent.VK_SEMICOLON; + case com.jogamp.newt.event.KeyEvent.VK_LESS : return java.awt.event.KeyEvent.VK_LESS; + case com.jogamp.newt.event.KeyEvent.VK_EQUALS : return java.awt.event.KeyEvent.VK_EQUALS; + case com.jogamp.newt.event.KeyEvent.VK_GREATER : return java.awt.event.KeyEvent.VK_GREATER; + case com.jogamp.newt.event.KeyEvent.VK_QUESTIONMARK : return defAwtKeyCode; + case com.jogamp.newt.event.KeyEvent.VK_AT : return java.awt.event.KeyEvent.VK_AT; + case com.jogamp.newt.event.KeyEvent.VK_A : return java.awt.event.KeyEvent.VK_A; + case com.jogamp.newt.event.KeyEvent.VK_B : return java.awt.event.KeyEvent.VK_B; + case com.jogamp.newt.event.KeyEvent.VK_C : return java.awt.event.KeyEvent.VK_C; + case com.jogamp.newt.event.KeyEvent.VK_D : return java.awt.event.KeyEvent.VK_D; + case com.jogamp.newt.event.KeyEvent.VK_E : return java.awt.event.KeyEvent.VK_E; + case com.jogamp.newt.event.KeyEvent.VK_F : return java.awt.event.KeyEvent.VK_F; + case com.jogamp.newt.event.KeyEvent.VK_G : return java.awt.event.KeyEvent.VK_G; + case com.jogamp.newt.event.KeyEvent.VK_H : return java.awt.event.KeyEvent.VK_H; + case com.jogamp.newt.event.KeyEvent.VK_I : return java.awt.event.KeyEvent.VK_I; + case com.jogamp.newt.event.KeyEvent.VK_J : return java.awt.event.KeyEvent.VK_J; + case com.jogamp.newt.event.KeyEvent.VK_K : return java.awt.event.KeyEvent.VK_K; + case com.jogamp.newt.event.KeyEvent.VK_L : return java.awt.event.KeyEvent.VK_L; + case com.jogamp.newt.event.KeyEvent.VK_M : return java.awt.event.KeyEvent.VK_M; + case com.jogamp.newt.event.KeyEvent.VK_N : return java.awt.event.KeyEvent.VK_N; + case com.jogamp.newt.event.KeyEvent.VK_O : return java.awt.event.KeyEvent.VK_O; + case com.jogamp.newt.event.KeyEvent.VK_P : return java.awt.event.KeyEvent.VK_P; + case com.jogamp.newt.event.KeyEvent.VK_Q : return java.awt.event.KeyEvent.VK_Q; + case com.jogamp.newt.event.KeyEvent.VK_R : return java.awt.event.KeyEvent.VK_R; + case com.jogamp.newt.event.KeyEvent.VK_S : return java.awt.event.KeyEvent.VK_S; + case com.jogamp.newt.event.KeyEvent.VK_T : return java.awt.event.KeyEvent.VK_T; + case com.jogamp.newt.event.KeyEvent.VK_U : return java.awt.event.KeyEvent.VK_U; + case com.jogamp.newt.event.KeyEvent.VK_V : return java.awt.event.KeyEvent.VK_V; + case com.jogamp.newt.event.KeyEvent.VK_W : return java.awt.event.KeyEvent.VK_W; + case com.jogamp.newt.event.KeyEvent.VK_X : return java.awt.event.KeyEvent.VK_X; + case com.jogamp.newt.event.KeyEvent.VK_Y : return java.awt.event.KeyEvent.VK_Y; + case com.jogamp.newt.event.KeyEvent.VK_Z : return java.awt.event.KeyEvent.VK_Z; + case com.jogamp.newt.event.KeyEvent.VK_OPEN_BRACKET : return java.awt.event.KeyEvent.VK_OPEN_BRACKET; + case com.jogamp.newt.event.KeyEvent.VK_BACK_SLASH : return java.awt.event.KeyEvent.VK_BACK_SLASH; + case com.jogamp.newt.event.KeyEvent.VK_CLOSE_BRACKET : return java.awt.event.KeyEvent.VK_CLOSE_BRACKET; + case com.jogamp.newt.event.KeyEvent.VK_CIRCUMFLEX : return java.awt.event.KeyEvent.VK_CIRCUMFLEX; + case com.jogamp.newt.event.KeyEvent.VK_UNDERSCORE : return java.awt.event.KeyEvent.VK_UNDERSCORE; + case com.jogamp.newt.event.KeyEvent.VK_BACK_QUOTE : return java.awt.event.KeyEvent.VK_BACK_QUOTE; + case com.jogamp.newt.event.KeyEvent.VK_F1 : return java.awt.event.KeyEvent.VK_F1; + case com.jogamp.newt.event.KeyEvent.VK_F2 : return java.awt.event.KeyEvent.VK_F2; + case com.jogamp.newt.event.KeyEvent.VK_F3 : return java.awt.event.KeyEvent.VK_F3; + case com.jogamp.newt.event.KeyEvent.VK_F4 : return java.awt.event.KeyEvent.VK_F4; + case com.jogamp.newt.event.KeyEvent.VK_F5 : return java.awt.event.KeyEvent.VK_F5; + case com.jogamp.newt.event.KeyEvent.VK_F6 : return java.awt.event.KeyEvent.VK_F6; + case com.jogamp.newt.event.KeyEvent.VK_F7 : return java.awt.event.KeyEvent.VK_F7; + case com.jogamp.newt.event.KeyEvent.VK_F8 : return java.awt.event.KeyEvent.VK_F8; + case com.jogamp.newt.event.KeyEvent.VK_F9 : return java.awt.event.KeyEvent.VK_F9; + case com.jogamp.newt.event.KeyEvent.VK_F10 : return java.awt.event.KeyEvent.VK_F10; + case com.jogamp.newt.event.KeyEvent.VK_F11 : return java.awt.event.KeyEvent.VK_F11; + case com.jogamp.newt.event.KeyEvent.VK_F12 : return java.awt.event.KeyEvent.VK_F12; + case com.jogamp.newt.event.KeyEvent.VK_F13 : return java.awt.event.KeyEvent.VK_F13; + case com.jogamp.newt.event.KeyEvent.VK_F14 : return java.awt.event.KeyEvent.VK_F14; + case com.jogamp.newt.event.KeyEvent.VK_F15 : return java.awt.event.KeyEvent.VK_F15; + case com.jogamp.newt.event.KeyEvent.VK_F16 : return java.awt.event.KeyEvent.VK_F16; + case com.jogamp.newt.event.KeyEvent.VK_F17 : return java.awt.event.KeyEvent.VK_F17; + case com.jogamp.newt.event.KeyEvent.VK_F18 : return java.awt.event.KeyEvent.VK_F18; + case com.jogamp.newt.event.KeyEvent.VK_F19 : return java.awt.event.KeyEvent.VK_F19; + case com.jogamp.newt.event.KeyEvent.VK_F20 : return java.awt.event.KeyEvent.VK_F20; + case com.jogamp.newt.event.KeyEvent.VK_F21 : return java.awt.event.KeyEvent.VK_F21; + case com.jogamp.newt.event.KeyEvent.VK_F22 : return java.awt.event.KeyEvent.VK_F22; + case com.jogamp.newt.event.KeyEvent.VK_F23 : return java.awt.event.KeyEvent.VK_F23; + case com.jogamp.newt.event.KeyEvent.VK_F24 : return java.awt.event.KeyEvent.VK_F24; + case com.jogamp.newt.event.KeyEvent.VK_LEFT_BRACE : return java.awt.event.KeyEvent.VK_BRACELEFT; + case com.jogamp.newt.event.KeyEvent.VK_PIPE : return defAwtKeyCode; + case com.jogamp.newt.event.KeyEvent.VK_RIGHT_BRACE : return java.awt.event.KeyEvent.VK_BRACERIGHT; + case com.jogamp.newt.event.KeyEvent.VK_TILDE : return java.awt.event.KeyEvent.VK_DEAD_TILDE; + case com.jogamp.newt.event.KeyEvent.VK_DELETE : return java.awt.event.KeyEvent.VK_DELETE; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD0 : return java.awt.event.KeyEvent.VK_NUMPAD0; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD1 : return java.awt.event.KeyEvent.VK_NUMPAD1; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD2 : return java.awt.event.KeyEvent.VK_NUMPAD2; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD3 : return java.awt.event.KeyEvent.VK_NUMPAD3; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD4 : return java.awt.event.KeyEvent.VK_NUMPAD4; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD5 : return java.awt.event.KeyEvent.VK_NUMPAD5; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD6 : return java.awt.event.KeyEvent.VK_NUMPAD6; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD7 : return java.awt.event.KeyEvent.VK_NUMPAD7; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD8 : return java.awt.event.KeyEvent.VK_NUMPAD8; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD9 : return java.awt.event.KeyEvent.VK_NUMPAD9; + case com.jogamp.newt.event.KeyEvent.VK_DECIMAL : return java.awt.event.KeyEvent.VK_DECIMAL; + case com.jogamp.newt.event.KeyEvent.VK_SEPARATOR : return java.awt.event.KeyEvent.VK_SEPARATOR; + case com.jogamp.newt.event.KeyEvent.VK_ADD : return java.awt.event.KeyEvent.VK_ADD; + case com.jogamp.newt.event.KeyEvent.VK_SUBTRACT : return java.awt.event.KeyEvent.VK_SUBTRACT; + case com.jogamp.newt.event.KeyEvent.VK_MULTIPLY : return java.awt.event.KeyEvent.VK_MULTIPLY; + case com.jogamp.newt.event.KeyEvent.VK_DIVIDE : return java.awt.event.KeyEvent.VK_DIVIDE; + case com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK : return java.awt.event.KeyEvent.VK_NUM_LOCK; + case com.jogamp.newt.event.KeyEvent.VK_KP_LEFT : return java.awt.event.KeyEvent.VK_KP_LEFT; + case com.jogamp.newt.event.KeyEvent.VK_KP_UP : return java.awt.event.KeyEvent.VK_KP_UP; + case com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT : return java.awt.event.KeyEvent.VK_KP_RIGHT; + case com.jogamp.newt.event.KeyEvent.VK_KP_DOWN : return java.awt.event.KeyEvent.VK_KP_DOWN; + case com.jogamp.newt.event.KeyEvent.VK_LEFT : return java.awt.event.KeyEvent.VK_LEFT; + case com.jogamp.newt.event.KeyEvent.VK_UP : return java.awt.event.KeyEvent.VK_UP; + case com.jogamp.newt.event.KeyEvent.VK_RIGHT : return java.awt.event.KeyEvent.VK_RIGHT; + case com.jogamp.newt.event.KeyEvent.VK_DOWN : return java.awt.event.KeyEvent.VK_DOWN; + case com.jogamp.newt.event.KeyEvent.VK_CONTEXT_MENU : return java.awt.event.KeyEvent.VK_CONTEXT_MENU; + case com.jogamp.newt.event.KeyEvent.VK_WINDOWS : return java.awt.event.KeyEvent.VK_WINDOWS; + case com.jogamp.newt.event.KeyEvent.VK_META : return java.awt.event.KeyEvent.VK_META; + case com.jogamp.newt.event.KeyEvent.VK_HELP : return java.awt.event.KeyEvent.VK_HELP; + case com.jogamp.newt.event.KeyEvent.VK_COMPOSE : return java.awt.event.KeyEvent.VK_COMPOSE; + case com.jogamp.newt.event.KeyEvent.VK_BEGIN : return java.awt.event.KeyEvent.VK_BEGIN; + case com.jogamp.newt.event.KeyEvent.VK_STOP : return java.awt.event.KeyEvent.VK_STOP; + case com.jogamp.newt.event.KeyEvent.VK_INVERTED_EXCLAMATION_MARK: return java.awt.event.KeyEvent.VK_INVERTED_EXCLAMATION_MARK; + case com.jogamp.newt.event.KeyEvent.VK_EURO_SIGN : return java.awt.event.KeyEvent.VK_EURO_SIGN; + case com.jogamp.newt.event.KeyEvent.VK_CUT : return java.awt.event.KeyEvent.VK_CUT; + case com.jogamp.newt.event.KeyEvent.VK_COPY : return java.awt.event.KeyEvent.VK_COPY; + case com.jogamp.newt.event.KeyEvent.VK_PASTE : return java.awt.event.KeyEvent.VK_PASTE; + case com.jogamp.newt.event.KeyEvent.VK_UNDO : return java.awt.event.KeyEvent.VK_UNDO; + case com.jogamp.newt.event.KeyEvent.VK_AGAIN : return java.awt.event.KeyEvent.VK_AGAIN; + case com.jogamp.newt.event.KeyEvent.VK_FIND : return java.awt.event.KeyEvent.VK_FIND; + case com.jogamp.newt.event.KeyEvent.VK_PROPS : return java.awt.event.KeyEvent.VK_PROPS; + case com.jogamp.newt.event.KeyEvent.VK_INPUT_METHOD_ON_OFF: return java.awt.event.KeyEvent.VK_INPUT_METHOD_ON_OFF; + case com.jogamp.newt.event.KeyEvent.VK_CODE_INPUT : return java.awt.event.KeyEvent.VK_CODE_INPUT; + case com.jogamp.newt.event.KeyEvent.VK_ROMAN_CHARACTERS: return java.awt.event.KeyEvent.VK_ROMAN_CHARACTERS; + case com.jogamp.newt.event.KeyEvent.VK_ALL_CANDIDATES: return java.awt.event.KeyEvent.VK_ALL_CANDIDATES; + case com.jogamp.newt.event.KeyEvent.VK_PREVIOUS_CANDIDATE: return java.awt.event.KeyEvent.VK_PREVIOUS_CANDIDATE; + case com.jogamp.newt.event.KeyEvent.VK_ALPHANUMERIC : return java.awt.event.KeyEvent.VK_ALPHANUMERIC; + case com.jogamp.newt.event.KeyEvent.VK_KATAKANA : return java.awt.event.KeyEvent.VK_KATAKANA; + case com.jogamp.newt.event.KeyEvent.VK_HIRAGANA : return java.awt.event.KeyEvent.VK_HIRAGANA; + case com.jogamp.newt.event.KeyEvent.VK_FULL_WIDTH : return java.awt.event.KeyEvent.VK_FULL_WIDTH; + case com.jogamp.newt.event.KeyEvent.VK_HALF_WIDTH : return java.awt.event.KeyEvent.VK_HALF_WIDTH; + case com.jogamp.newt.event.KeyEvent.VK_JAPANESE_KATAKANA: return java.awt.event.KeyEvent.VK_JAPANESE_KATAKANA; + case com.jogamp.newt.event.KeyEvent.VK_JAPANESE_HIRAGANA: return java.awt.event.KeyEvent.VK_JAPANESE_HIRAGANA; + case com.jogamp.newt.event.KeyEvent.VK_JAPANESE_ROMAN: return java.awt.event.KeyEvent.VK_JAPANESE_ROMAN; + case com.jogamp.newt.event.KeyEvent.VK_KANA_LOCK : return java.awt.event.KeyEvent.VK_KANA_LOCK; } + return defAwtKeyCode; } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) { @@ -289,11 +650,11 @@ public class AWTNewtEventFactory { public static final com.jogamp.newt.event.KeyEvent createKeyEvent(short newtType, java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { if( (short)0 != newtType ) { - final short keyCode = (short)event.getKeyCode(); - return new com.jogamp.newt.event.KeyEvent( + final short newtKeyCode = awtKeyCode2NewtKeyCode( event.getKeyCode() ); + return com.jogamp.newt.event.KeyEvent.create( newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()), - keyCode, keyCode, event.getKeyChar()); + newtKeyCode, newtKeyCode, event.getKeyChar()); } return null; // no mapping .. } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 9638e6a7c..364a348ee 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -216,7 +216,7 @@ public class AndroidNewtEventFactory { final long unixTime = System.currentTimeMillis() + ( aEvent.getEventTime() - android.os.SystemClock.uptimeMillis() ); final int newtMods = aKeyModifiers2Newt(aEvent.getMetaState()); - return new com.jogamp.newt.event.KeyEvent( + return com.jogamp.newt.event.KeyEvent.create( newtType, src, unixTime, newtMods, newtKeyCode, newtKeyCode, (char) aEvent.getUnicodeChar()); } return null; diff --git a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java index ead567d82..4139951aa 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java @@ -38,7 +38,6 @@ import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.util.EDTUtil; -import jogamp.newt.DefaultEDTUtil; import jogamp.newt.DisplayImpl; public class DisplayDriver extends DisplayImpl { diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index 80b1b6687..fc8c5adc6 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -311,7 +311,7 @@ public class LinuxEventDeviceTracker implements WindowListener { } private char NewtVKey2Unicode(short VK){ - if( KeyEvent.isPrintableKey(VK) ){ + if( KeyEvent.isPrintableKey(VK, false) ){ return (char)VK; } return 0; @@ -479,9 +479,9 @@ public class LinuxEventDeviceTracker implements WindowListener { case 39: return KeyEvent.VK_SEMICOLON; case 40: // apostrophe - return KeyEvent.VK_DEAD_ACUTE; + return KeyEvent.VK_QUOTE; case 41: // grave - return KeyEvent.VK_DEAD_GRAVE; + return KeyEvent.VK_BACK_QUOTE; case 42: // left shift return KeyEvent.VK_SHIFT; diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index b1d18e487..bb72350e3 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -51,7 +51,6 @@ import jogamp.newt.driver.DriverUpdatePosition; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; -import com.jogamp.newt.event.UTFKeyUtil; public class WindowDriver extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { @@ -412,7 +411,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final short keyCode = MacKeyUtil.validateKeyCode(_keyCode, keyChar); final short keySym; { - short _keySym = KeyEvent.NULL_CHAR != keySymChar ? UTFKeyUtil.utf16ToVKey(keySymChar) : KeyEvent.VK_UNDEFINED; + short _keySym = KeyEvent.NULL_CHAR != keySymChar ? KeyEvent.utf16ToVKey(keySymChar) : KeyEvent.VK_UNDEFINED; keySym = KeyEvent.VK_UNDEFINED != _keySym ? _keySym : keyCode; } /* { @@ -421,7 +420,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl ", keyCode 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)+ ", keySymChar '"+keySymChar+"', 0x"+Integer.toHexString(keySymChar)+" -> 0x"+Integer.toHexString(keySym)+ ", mods "+toHexString(modifiers)+ - ", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + ", was: pressed "+isKeyPressed(keyCode)+", isModifierKeyCode "+isModifierKeyCode); } */ // 1:1 Order: OSX and NEWT delivery order is PRESSED, RELEASED and TYPED @@ -429,15 +428,13 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: if( isKeyCodeTracked(keyCode) ) { - keyRepeatState.put(keyCode, false); // prev == true -> AR out - keyPressedState.put(keyCode, false); + setKeyPressed(keyCode, false); } break; case KeyEvent.EVENT_KEY_PRESSED: if( isKeyCodeTracked(keyCode) ) { - if( keyPressedState.put(keyCode, true) ) { + if( setKeyPressed(keyCode, true) ) { // key was already pressed - keyRepeatState.put(keyCode, true); // prev == false -> AR in modifiers |= InputEvent.AUTOREPEAT_MASK; super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); // RELEASED } diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index e7a8d5a33..ad7e1e8f3 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -261,13 +261,17 @@ public class WindowDriver extends WindowImpl { // nop - using event driven insetsChange(..) } + private short repeatedKey = KeyEvent.VK_UNDEFINED; + private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, int modifiers, short keyCode, short keySym, char keyChar) { - if( isKeyCodeTracked(keyCode) && keyPressedState.put(keyCode, true) ) { - final boolean preKeyRepeatState = keyRepeatState.put(keyCode, true); + if( setKeyPressed(keyCode, true) ) { + // AR: Key was already pressed: Either [enter | within] AR mode + final boolean withinAR = repeatedKey == keyCode; + repeatedKey = keyCode; if( !isModifierKey ) { // AR: Key was already pressed: Either [enter | within] AR mode modifiers |= InputEvent.AUTOREPEAT_MASK; - if( preKeyRepeatState ) { + if( withinAR ) { // AR: Within AR mode super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar); } // else { AR: Enter AR mode - skip already send PRESSED ; or ALT } @@ -289,11 +293,12 @@ public class WindowDriver extends WindowImpl { switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: if( isKeyCodeTracked(keyCode) ) { - if( keyRepeatState.put(keyCode, false) && !isModifierKey ) { + if( repeatedKey == keyCode && !isModifierKey ) { // AR out - send out missing PRESSED super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keySym, keyChar); } - keyPressedState.put(keyCode, false); + setKeyPressed(keyCode, false); + repeatedKey = KeyEvent.VK_UNDEFINED; } super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); break; diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java index 1ebb714fa..5e240636d 100644 --- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -68,6 +68,141 @@ public class SWTNewtEventFactory { return newtMods; } + public static short swtKeyCode2NewtKeyCode(final int swtKeyCode) { + final short defNEWTKeyCode = (short)swtKeyCode; + switch (swtKeyCode) { + case SWT.HOME : return com.jogamp.newt.event.KeyEvent.VK_HOME; + case SWT.END : return com.jogamp.newt.event.KeyEvent.VK_END; + case SWT.PRINT_SCREEN : return com.jogamp.newt.event.KeyEvent.VK_PRINTSCREEN; + case SWT.BS : return com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE; + case SWT.TAB : return com.jogamp.newt.event.KeyEvent.VK_TAB; + case SWT.LF : return com.jogamp.newt.event.KeyEvent.VK_ENTER; + case SWT.PAGE_DOWN : return com.jogamp.newt.event.KeyEvent.VK_PAGE_DOWN; + case SWT.PAGE_UP : return com.jogamp.newt.event.KeyEvent.VK_PAGE_UP; + case SWT.CONTROL : return com.jogamp.newt.event.KeyEvent.VK_CONTROL; + case SWT.CAPS_LOCK : return com.jogamp.newt.event.KeyEvent.VK_CAPS_LOCK; + case SWT.PAUSE : return com.jogamp.newt.event.KeyEvent.VK_PAUSE; + case SWT.SCROLL_LOCK : return com.jogamp.newt.event.KeyEvent.VK_SCROLL_LOCK; + case SWT.CANCEL : return com.jogamp.newt.event.KeyEvent.VK_CANCEL; + case SWT.INSERT : return com.jogamp.newt.event.KeyEvent.VK_INSERT; + case SWT.ESC : return com.jogamp.newt.event.KeyEvent.VK_ESCAPE; + case SWT.SPACE : return com.jogamp.newt.event.KeyEvent.VK_SPACE; + case SWT.F1 : return com.jogamp.newt.event.KeyEvent.VK_F1; + case SWT.F2 : return com.jogamp.newt.event.KeyEvent.VK_F2; + case SWT.F3 : return com.jogamp.newt.event.KeyEvent.VK_F3; + case SWT.F4 : return com.jogamp.newt.event.KeyEvent.VK_F4; + case SWT.F5 : return com.jogamp.newt.event.KeyEvent.VK_F5; + case SWT.F6 : return com.jogamp.newt.event.KeyEvent.VK_F6; + case SWT.F7 : return com.jogamp.newt.event.KeyEvent.VK_F7; + case SWT.F8 : return com.jogamp.newt.event.KeyEvent.VK_F8; + case SWT.F9 : return com.jogamp.newt.event.KeyEvent.VK_F9; + case SWT.F10 : return com.jogamp.newt.event.KeyEvent.VK_F10; + case SWT.F11 : return com.jogamp.newt.event.KeyEvent.VK_F11; + case SWT.F12 : return com.jogamp.newt.event.KeyEvent.VK_F12; + case SWT.F13 : return com.jogamp.newt.event.KeyEvent.VK_F13; + case SWT.F14 : return com.jogamp.newt.event.KeyEvent.VK_F14; + case SWT.F15 : return com.jogamp.newt.event.KeyEvent.VK_F15; + case SWT.F16 : return com.jogamp.newt.event.KeyEvent.VK_F16; + case SWT.F17 : return com.jogamp.newt.event.KeyEvent.VK_F17; + case SWT.F18 : return com.jogamp.newt.event.KeyEvent.VK_F18; + case SWT.F19 : return com.jogamp.newt.event.KeyEvent.VK_F19; + case SWT.F20 : return com.jogamp.newt.event.KeyEvent.VK_F20; + case SWT.DEL : return com.jogamp.newt.event.KeyEvent.VK_DELETE; + case SWT.KEYPAD_0 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD0; + case SWT.KEYPAD_1 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD1; + case SWT.KEYPAD_2 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD2; + case SWT.KEYPAD_3 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD3; + case SWT.KEYPAD_4 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD4; + case SWT.KEYPAD_5 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD5; + case SWT.KEYPAD_6 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD6; + case SWT.KEYPAD_7 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD7; + case SWT.KEYPAD_8 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD8; + case SWT.KEYPAD_9 : return com.jogamp.newt.event.KeyEvent.VK_NUMPAD9; + case SWT.KEYPAD_DECIMAL: return com.jogamp.newt.event.KeyEvent.VK_DECIMAL; + case SWT.KEYPAD_ADD : return com.jogamp.newt.event.KeyEvent.VK_ADD; + case SWT.KEYPAD_SUBTRACT: return com.jogamp.newt.event.KeyEvent.VK_SUBTRACT; + case SWT.KEYPAD_MULTIPLY: return com.jogamp.newt.event.KeyEvent.VK_MULTIPLY; + case SWT.KEYPAD_DIVIDE : return com.jogamp.newt.event.KeyEvent.VK_DIVIDE; + case SWT.NUM_LOCK : return com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK; + case SWT.ARROW_LEFT : return com.jogamp.newt.event.KeyEvent.VK_LEFT; + case SWT.ARROW_UP : return com.jogamp.newt.event.KeyEvent.VK_UP; + case SWT.ARROW_RIGHT : return com.jogamp.newt.event.KeyEvent.VK_RIGHT; + case SWT.ARROW_DOWN : return com.jogamp.newt.event.KeyEvent.VK_DOWN; + case SWT.HELP : return com.jogamp.newt.event.KeyEvent.VK_HELP; + } + return defNEWTKeyCode; + } + + public static int newtKeyCode2SWTKeyCode(final short newtKeyCode) { + final int defSWTKeyCode = 0xFFFF & (int)newtKeyCode; + switch (newtKeyCode) { + case com.jogamp.newt.event.KeyEvent.VK_HOME : return SWT.HOME; + case com.jogamp.newt.event.KeyEvent.VK_END : return SWT.END; + case com.jogamp.newt.event.KeyEvent.VK_PRINTSCREEN : return SWT.PRINT_SCREEN; + case com.jogamp.newt.event.KeyEvent.VK_BACK_SPACE : return SWT.BS; + case com.jogamp.newt.event.KeyEvent.VK_TAB : return SWT.TAB; + case com.jogamp.newt.event.KeyEvent.VK_ENTER : return SWT.LF; + case com.jogamp.newt.event.KeyEvent.VK_PAGE_DOWN : return SWT.PAGE_DOWN; + case com.jogamp.newt.event.KeyEvent.VK_PAGE_UP : return SWT.PAGE_UP; + case com.jogamp.newt.event.KeyEvent.VK_CONTROL : return SWT.CONTROL; + case com.jogamp.newt.event.KeyEvent.VK_CAPS_LOCK : return SWT.CAPS_LOCK; + case com.jogamp.newt.event.KeyEvent.VK_PAUSE : return SWT.PAUSE; + case com.jogamp.newt.event.KeyEvent.VK_SCROLL_LOCK : return SWT.SCROLL_LOCK; + case com.jogamp.newt.event.KeyEvent.VK_CANCEL : return SWT.CANCEL; + case com.jogamp.newt.event.KeyEvent.VK_INSERT : return SWT.INSERT; + case com.jogamp.newt.event.KeyEvent.VK_ESCAPE : return SWT.ESC; + case com.jogamp.newt.event.KeyEvent.VK_SPACE : return SWT.SPACE; + case com.jogamp.newt.event.KeyEvent.VK_F1 : return SWT.F1; + case com.jogamp.newt.event.KeyEvent.VK_F2 : return SWT.F2; + case com.jogamp.newt.event.KeyEvent.VK_F3 : return SWT.F3; + case com.jogamp.newt.event.KeyEvent.VK_F4 : return SWT.F4; + case com.jogamp.newt.event.KeyEvent.VK_F5 : return SWT.F5; + case com.jogamp.newt.event.KeyEvent.VK_F6 : return SWT.F6; + case com.jogamp.newt.event.KeyEvent.VK_F7 : return SWT.F7; + case com.jogamp.newt.event.KeyEvent.VK_F8 : return SWT.F8; + case com.jogamp.newt.event.KeyEvent.VK_F9 : return SWT.F9; + case com.jogamp.newt.event.KeyEvent.VK_F10 : return SWT.F10; + case com.jogamp.newt.event.KeyEvent.VK_F11 : return SWT.F11; + case com.jogamp.newt.event.KeyEvent.VK_F12 : return SWT.F12; + case com.jogamp.newt.event.KeyEvent.VK_F13 : return SWT.F13; + case com.jogamp.newt.event.KeyEvent.VK_F14 : return SWT.F14; + case com.jogamp.newt.event.KeyEvent.VK_F15 : return SWT.F15; + case com.jogamp.newt.event.KeyEvent.VK_F16 : return SWT.F16; + case com.jogamp.newt.event.KeyEvent.VK_F17 : return SWT.F17; + case com.jogamp.newt.event.KeyEvent.VK_F18 : return SWT.F18; + case com.jogamp.newt.event.KeyEvent.VK_F19 : return SWT.F19; + case com.jogamp.newt.event.KeyEvent.VK_F20 : return SWT.F20; + case com.jogamp.newt.event.KeyEvent.VK_DELETE : return SWT.DEL; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD0 : return SWT.KEYPAD_0; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD1 : return SWT.KEYPAD_1; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD2 : return SWT.KEYPAD_2; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD3 : return SWT.KEYPAD_3; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD4 : return SWT.KEYPAD_4; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD5 : return SWT.KEYPAD_5; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD6 : return SWT.KEYPAD_6; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD7 : return SWT.KEYPAD_7; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD8 : return SWT.KEYPAD_8; + case com.jogamp.newt.event.KeyEvent.VK_NUMPAD9 : return SWT.KEYPAD_9; + case com.jogamp.newt.event.KeyEvent.VK_DECIMAL : return SWT.KEYPAD_DECIMAL; + case com.jogamp.newt.event.KeyEvent.VK_ADD : return SWT.KEYPAD_ADD; + case com.jogamp.newt.event.KeyEvent.VK_SUBTRACT : return SWT.KEYPAD_SUBTRACT; + case com.jogamp.newt.event.KeyEvent.VK_MULTIPLY : return SWT.KEYPAD_MULTIPLY; + case com.jogamp.newt.event.KeyEvent.VK_DIVIDE : return SWT.KEYPAD_DIVIDE; + case com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK : return SWT.NUM_LOCK; + case com.jogamp.newt.event.KeyEvent.VK_KP_LEFT : + case com.jogamp.newt.event.KeyEvent.VK_LEFT : return SWT.ARROW_LEFT; + case com.jogamp.newt.event.KeyEvent.VK_KP_UP : + case com.jogamp.newt.event.KeyEvent.VK_UP : return SWT.ARROW_UP; + case com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT : + case com.jogamp.newt.event.KeyEvent.VK_RIGHT : return SWT.ARROW_RIGHT; + case com.jogamp.newt.event.KeyEvent.VK_KP_DOWN : + case com.jogamp.newt.event.KeyEvent.VK_DOWN : return SWT.ARROW_DOWN; + case com.jogamp.newt.event.KeyEvent.VK_HELP : return SWT.HELP; + } + return defSWTKeyCode; + } + + public static final com.jogamp.newt.event.InputEvent createInputEvent(org.eclipse.swt.widgets.Event event, Object source) { com.jogamp.newt.event.InputEvent res = createMouseEvent(event, source); if(null == res) { @@ -126,10 +261,11 @@ public class SWTNewtEventFactory { } final short type = eventTypeSWT2NEWT(event.type); if( (short)0 != type ) { - return new com.jogamp.newt.event.KeyEvent( + final short newtKeyCode = swtKeyCode2NewtKeyCode( event.keyCode ); + return com.jogamp.newt.event.KeyEvent.create( type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), swtModifiers2Newt(event.stateMask, false), - (short)event.keyCode, (short)event.keyCode, event.character); + newtKeyCode, newtKeyCode, event.character); } return null; // no mapping .. } diff --git a/src/newt/native/KeyEvent.h b/src/newt/native/KeyEvent.h index 946b3c904..7a63b19ce 100644 --- a/src/newt/native/KeyEvent.h +++ b/src/newt/native/KeyEvent.h @@ -33,194 +33,206 @@ #define EVENT_KEY_RELEASED 301 #define EVENT_KEY_TYPED 302 -#define J_VK_ENTER '\n' -#define J_VK_BACK_SPACE '\b' -#define J_VK_TAB '\t' -#define J_VK_CANCEL 0x03 -#define J_VK_CLEAR 0x0C -#define J_VK_SHIFT 0x10 -#define J_VK_CONTROL 0x11 -#define J_VK_ALT 0x12 -#define J_VK_PAUSE 0x13 -#define J_VK_CAPS_LOCK 0x14 -#define J_VK_ESCAPE 0x1B -#define J_VK_SPACE 0x20 -#define J_VK_PAGE_UP 0x21 -#define J_VK_PAGE_DOWN 0x22 -#define J_VK_END 0x23 -#define J_VK_HOME 0x24 -#define J_VK_LEFT 0x25 -#define J_VK_UP 0x26 -#define J_VK_RIGHT 0x27 -#define J_VK_DOWN 0x28 -#define J_VK_COMMA 0x2C -#define J_VK_MINUS 0x2D -#define J_VK_PERIOD 0x2E -#define J_VK_SLASH 0x2F -#define J_VK_0 0x30 -#define J_VK_1 0x31 -#define J_VK_2 0x32 -#define J_VK_3 0x33 -#define J_VK_4 0x34 -#define J_VK_5 0x35 -#define J_VK_6 0x36 -#define J_VK_7 0x37 -#define J_VK_8 0x38 -#define J_VK_9 0x39 -#define J_VK_SEMICOLON 0x3B -#define J_VK_EQUALS 0x3D -#define J_VK_A 0x41 -#define J_VK_B 0x42 -#define J_VK_C 0x43 -#define J_VK_D 0x44 -#define J_VK_E 0x45 -#define J_VK_F 0x46 -#define J_VK_G 0x47 -#define J_VK_H 0x48 -#define J_VK_I 0x49 -#define J_VK_J 0x4A -#define J_VK_K 0x4B -#define J_VK_L 0x4C -#define J_VK_M 0x4D -#define J_VK_N 0x4E -#define J_VK_O 0x4F -#define J_VK_P 0x50 -#define J_VK_Q 0x51 -#define J_VK_R 0x52 -#define J_VK_S 0x53 -#define J_VK_T 0x54 -#define J_VK_U 0x55 -#define J_VK_V 0x56 -#define J_VK_W 0x57 -#define J_VK_X 0x58 -#define J_VK_Y 0x59 -#define J_VK_Z 0x5A -#define J_VK_OPEN_BRACKET 0x5B -#define J_VK_BACK_SLASH 0x5C -#define J_VK_CLOSE_BRACKET 0x5D -#define J_VK_NUMPAD0 0x60 -#define J_VK_NUMPAD1 0x61 -#define J_VK_NUMPAD2 0x62 -#define J_VK_NUMPAD3 0x63 -#define J_VK_NUMPAD4 0x64 -#define J_VK_NUMPAD5 0x65 -#define J_VK_NUMPAD6 0x66 -#define J_VK_NUMPAD7 0x67 -#define J_VK_NUMPAD8 0x68 -#define J_VK_NUMPAD9 0x69 -#define J_VK_MULTIPLY 0x6A -#define J_VK_ADD 0x6B -#define J_VK_SEPARATOR 0x6C -#define J_VK_SUBTRACT 0x6D -#define J_VK_DECIMAL 0x6E -#define J_VK_DIVIDE 0x6F -#define J_VK_DELETE 0x7F /* ASCII DEL */ -#define J_VK_NUM_LOCK 0x90 -#define J_VK_SCROLL_LOCK 0x91 -#define J_VK_F1 0x70 -#define J_VK_F2 0x71 -#define J_VK_F3 0x72 -#define J_VK_F4 0x73 -#define J_VK_F5 0x74 -#define J_VK_F6 0x75 -#define J_VK_F7 0x76 -#define J_VK_F8 0x77 -#define J_VK_F9 0x78 -#define J_VK_F10 0x79 -#define J_VK_F11 0x7A -#define J_VK_F12 0x7B -#define J_VK_F13 0xF000 -#define J_VK_F14 0xF001 -#define J_VK_F15 0xF002 -#define J_VK_F16 0xF003 -#define J_VK_F17 0xF004 -#define J_VK_F18 0xF005 -#define J_VK_F19 0xF006 -#define J_VK_F20 0xF007 -#define J_VK_F21 0xF008 -#define J_VK_F22 0xF009 -#define J_VK_F23 0xF00A -#define J_VK_F24 0xF00B -#define J_VK_PRINTSCREEN 0x9A -#define J_VK_INSERT 0x9B -#define J_VK_HELP 0x9C -#define J_VK_META 0x9D -#define J_VK_BACK_QUOTE 0xC0 -#define J_VK_QUOTE 0xDE -#define J_VK_KP_UP 0xE0 -#define J_VK_KP_DOWN 0xE1 -#define J_VK_KP_LEFT 0xE2 -#define J_VK_KP_RIGHT 0xE3 -#define J_VK_DEAD_GRAVE 0x80 -#define J_VK_DEAD_ACUTE 0x81 -#define J_VK_DEAD_CIRCUMFLEX 0x82 -#define J_VK_DEAD_TILDE 0x83 -#define J_VK_DEAD_MACRON 0x84 -#define J_VK_DEAD_BREVE 0x85 -#define J_VK_DEAD_ABOVEDOT 0x86 -#define J_VK_DEAD_DIAERESIS 0x87 -#define J_VK_DEAD_ABOVERING 0x88 -#define J_VK_DEAD_DOUBLEACUTE 0x89 -#define J_VK_DEAD_CARON 0x8a -#define J_VK_DEAD_CEDILLA 0x8b -#define J_VK_DEAD_OGONEK 0x8c -#define J_VK_DEAD_IOTA 0x8d -#define J_VK_DEAD_VOICED_SOUND 0x8e -#define J_VK_DEAD_SEMIVOICED_SOUND 0x8f -#define J_VK_AMPERSAND 0x96 -#define J_VK_ASTERISK 0x97 -#define J_VK_QUOTEDBL 0x98 -#define J_VK_LESS 0x99 -#define J_VK_GREATER 0xa0 -#define J_VK_BRACELEFT 0xa1 -#define J_VK_BRACERIGHT 0xa2 -#define J_VK_AT 0x0200 -#define J_VK_COLON 0x0201 -#define J_VK_CIRCUMFLEX 0x0202 -#define J_VK_DOLLAR 0x0203 -#define J_VK_EURO_SIGN 0x0204 -#define J_VK_EXCLAMATION_MARK 0x0205 -#define J_VK_INVERTED_EXCLAMATION_MARK 0x0206 -#define J_VK_LEFT_PARENTHESIS 0x0207 -#define J_VK_NUMBER_SIGN 0x0208 -#define J_VK_PLUS 0x0209 -#define J_VK_RIGHT_PARENTHESIS 0x020A -#define J_VK_UNDERSCORE 0x020B -#define J_VK_WINDOWS 0x020C -#define J_VK_CONTEXT_MENU 0x020D -#define J_VK_FINAL 0x0018 -#define J_VK_CONVERT 0x001C -#define J_VK_NONCONVERT 0x001D -#define J_VK_ACCEPT 0x001E -#define J_VK_MODECHANGE 0x001F -#define J_VK_KANA 0x0015 -#define J_VK_KANJI 0x0019 -#define J_VK_ALPHANUMERIC 0x00F0 -#define J_VK_KATAKANA 0x00F1 -#define J_VK_HIRAGANA 0x00F2 -#define J_VK_FULL_WIDTH 0x00F3 -#define J_VK_HALF_WIDTH 0x00F4 -#define J_VK_ROMAN_CHARACTERS 0x00F5 -#define J_VK_ALL_CANDIDATES 0x0100 -#define J_VK_PREVIOUS_CANDIDATE 0x0101 -#define J_VK_CODE_INPUT 0x0102 -#define J_VK_JAPANESE_KATAKANA 0x0103 -#define J_VK_JAPANESE_HIRAGANA 0x0104 -#define J_VK_JAPANESE_ROMAN 0x0105 -#define J_VK_KANA_LOCK 0x0106 -#define J_VK_INPUT_METHOD_ON_OFF 0x0107 -#define J_VK_CUT 0xFFD1 -#define J_VK_COPY 0xFFCD -#define J_VK_PASTE 0xFFCF -#define J_VK_UNDO 0xFFCB -#define J_VK_AGAIN 0xFFC9 -#define J_VK_FIND 0xFFD0 -#define J_VK_PROPS 0xFFCA -#define J_VK_STOP 0xFFC8 -#define J_VK_COMPOSE 0xFF20 -#define J_VK_ALT_GRAPH 0xFF7E -#define J_VK_BEGIN 0xFF58 -#define J_VK_UNDEFINED 0x0 +#define J_VK_UNDEFINED ( 0x0U ) +#define J_VK_HOME ( 0x02U ) +#define J_VK_END ( 0x03U ) +#define J_VK_FINAL ( 0x04U ) +#define J_VK_PRINTSCREEN ( 0x05U ) +#define J_VK_BACK_SPACE ( 0x08U ) +#define J_VK_TAB ( 0x09U ) +#define J_VK_ENTER ( 0x0AU ) +#define J_VK_PAGE_DOWN ( 0x0BU ) +#define J_VK_CLEAR ( 0x0CU ) +#define J_VK_SHIFT ( 0x0FU ) +#define J_VK_PAGE_UP ( 0x10U ) +#define J_VK_CONTROL ( 0x11U ) +#define J_VK_ALT ( 0x12U ) +#define J_VK_ALT_GRAPH ( 0x13U ) +#define J_VK_CAPS_LOCK ( 0x14U ) +#define J_VK_PAUSE ( 0x16U ) +#define J_VK_SCROLL_LOCK ( 0x17U ) +#define J_VK_CANCEL ( 0x18U ) +#define J_VK_INSERT ( 0x1AU ) +#define J_VK_ESCAPE ( 0x1BU ) +#define J_VK_CONVERT ( 0x1CU ) +#define J_VK_NONCONVERT ( 0x1DU ) +#define J_VK_ACCEPT ( 0x1EU ) +#define J_VK_MODECHANGE ( 0x1FU ) + +// +// Unicode: Printable [0x20 - 0x7E] +// + +#define J_VK_SPACE ( 0x20U ) +#define J_VK_EXCLAMATION_MARK ( 0x21U ) +#define J_VK_QUOTEDBL ( 0x22U ) +#define J_VK_NUMBER_SIGN ( 0x23U ) +#define J_VK_DOLLAR ( 0x24U ) +#define J_VK_PERCENT ( 0x25U ) +#define J_VK_AMPERSAND ( 0x26U ) +#define J_VK_QUOTE ( 0x27U ) +#define J_VK_LEFT_PARENTHESIS ( 0x28U ) +#define J_VK_RIGHT_PARENTHESIS ( 0x29U ) +#define J_VK_ASTERISK ( 0x2AU ) +#define J_VK_PLUS ( 0x2BU ) +#define J_VK_COMMA ( 0x2CU ) +#define J_VK_MINUS ( 0x2DU ) +#define J_VK_PERIOD ( 0x2EU ) +#define J_VK_SLASH ( 0x2FU ) +#define J_VK_0 ( 0x30U ) +#define J_VK_1 ( 0x31U ) +#define J_VK_2 ( 0x32U ) +#define J_VK_3 ( 0x33U ) +#define J_VK_4 ( 0x34U ) +#define J_VK_5 ( 0x35U ) +#define J_VK_6 ( 0x36U ) +#define J_VK_7 ( 0x37U ) +#define J_VK_8 ( 0x38U ) +#define J_VK_9 ( 0x39U ) +#define J_VK_COLON ( 0x3AU ) +#define J_VK_SEMICOLON ( 0x3BU ) +#define J_VK_LESS ( 0x3CU ) +#define J_VK_EQUALS ( 0x3DU ) +#define J_VK_GREATER ( 0x3EU ) +#define J_VK_QUESTIONMARK ( 0x3FU ) +#define J_VK_AT ( 0x40U ) +#define J_VK_A ( 0x41U ) +#define J_VK_B ( 0x42U ) +#define J_VK_C ( 0x43U ) +#define J_VK_D ( 0x44U ) +#define J_VK_E ( 0x45U ) +#define J_VK_F ( 0x46U ) +#define J_VK_G ( 0x47U ) +#define J_VK_H ( 0x48U ) +#define J_VK_I ( 0x49U ) +#define J_VK_J ( 0x4AU ) +#define J_VK_K ( 0x4BU ) +#define J_VK_L ( 0x4CU ) +#define J_VK_M ( 0x4DU ) +#define J_VK_N ( 0x4EU ) +#define J_VK_O ( 0x4FU ) +#define J_VK_P ( 0x50U ) +#define J_VK_Q ( 0x51U ) +#define J_VK_R ( 0x52U ) +#define J_VK_S ( 0x53U ) +#define J_VK_T ( 0x54U ) +#define J_VK_U ( 0x55U ) +#define J_VK_V ( 0x56U ) +#define J_VK_W ( 0x57U ) +#define J_VK_X ( 0x58U ) +#define J_VK_Y ( 0x59U ) +#define J_VK_Z ( 0x5AU ) +#define J_VK_OPEN_BRACKET ( 0x5BU ) +#define J_VK_BACK_SLASH ( 0x5CU ) +#define J_VK_CLOSE_BRACKET ( 0x5DU ) +#define J_VK_CIRCUMFLEX ( 0x5EU ) +#define J_VK_UNDERSCORE ( 0x5FU ) +#define J_VK_BACK_QUOTE ( 0x60U ) +#define J_VK_F1 ( 0x60U+ 1U ) +#define J_VK_F2 ( 0x60U+ 2U ) +#define J_VK_F3 ( 0x60U+ 3U ) +#define J_VK_F4 ( 0x60U+ 4U ) +#define J_VK_F5 ( 0x60U+ 5U ) +#define J_VK_F6 ( 0x60U+ 6U ) +#define J_VK_F7 ( 0x60U+ 7U ) +#define J_VK_F8 ( 0x60U+ 8U ) +#define J_VK_F9 ( 0x60U+ 9U ) +#define J_VK_F10 ( 0x60U+10U ) +#define J_VK_F11 ( 0x60U+11U ) +#define J_VK_F12 ( 0x60U+12U ) +#define J_VK_F13 ( 0x60U+13U ) +#define J_VK_F14 ( 0x60U+14U ) +#define J_VK_F15 ( 0x60U+15U ) +#define J_VK_F16 ( 0x60U+16U ) +#define J_VK_F17 ( 0x60U+17U ) +#define J_VK_F18 ( 0x60U+18U ) +#define J_VK_F19 ( 0x60U+19U ) +#define J_VK_F20 ( 0x60U+20U ) +#define J_VK_F21 ( 0x60U+21U ) +#define J_VK_F22 ( 0x60U+22U ) +#define J_VK_F23 ( 0x60U+23U ) +#define J_VK_F24 ( 0x60U+24U ) +#define J_VK_LEFT_BRACE ( 0x7BU ) +#define J_VK_PIPE ( 0x7CU ) +#define J_VK_RIGHT_BRACE ( 0x7DU ) +#define J_VK_TILDE ( 0x7EU ) + +// +// Unicode: Non printable controls: [0x7F - 0x9F] +// + +#define J_VK_DELETE ( 0x7FU ) +#define J_VK_NUMPAD0 ( 0x80U ) +#define J_VK_NUMPAD1 ( 0x81U ) +#define J_VK_NUMPAD2 ( 0x82U ) +#define J_VK_NUMPAD3 ( 0x83U ) +#define J_VK_NUMPAD4 ( 0x84U ) +#define J_VK_NUMPAD5 ( 0x85U ) +#define J_VK_NUMPAD6 ( 0x86U ) +#define J_VK_NUMPAD7 ( 0x87U ) +#define J_VK_NUMPAD8 ( 0x88U ) +#define J_VK_NUMPAD9 ( 0x89U ) +#define J_VK_DECIMAL ( 0x8AU ) +#define J_VK_SEPARATOR ( 0x8BU ) +#define J_VK_ADD ( 0x8CU ) +#define J_VK_SUBTRACT ( 0x8DU ) +#define J_VK_MULTIPLY ( 0x8EU ) +#define J_VK_DIVIDE ( 0x8FU ) +#define J_VK_NUM_LOCK ( 0x90U ) +#define J_VK_KP_LEFT ( 0x91U ) +#define J_VK_KP_UP ( 0x92U ) +#define J_VK_KP_RIGHT ( 0x93U ) +#define J_VK_KP_DOWN ( 0x94U ) +#define J_VK_LEFT ( 0x95U ) +#define J_VK_UP ( 0x96U ) +#define J_VK_RIGHT ( 0x97U ) +#define J_VK_DOWN ( 0x98U ) +#define J_VK_CONTEXT_MENU ( 0x99U ) +#define J_VK_WINDOWS ( 0x9AU ) +#define J_VK_META ( 0x9BU ) +#define J_VK_HELP ( 0x9CU ) +#define J_VK_COMPOSE ( 0x9DU ) +#define J_VK_BEGIN ( 0x9EU ) +#define J_VK_STOP ( 0x9FU ) + + +// +// Unicode: Printable [0x00A0 - 0xDFFF] +// + +#define J_VK_INVERTED_EXCLAMATION_MARK ( 0xA1U ) +#define J_VK_EURO_SIGN ( 0x20ACU ) + +// +// Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) +// + +/* for Sun keyboards */ +#define J_VK_CUT ( 0xF879U ) +#define J_VK_COPY ( 0xF87AU ) +#define J_VK_PASTE ( 0xF87BU ) +#define J_VK_UNDO ( 0xF87CU ) +#define J_VK_AGAIN ( 0xF87DU ) +#define J_VK_FIND ( 0xF87EU ) +#define J_VK_PROPS ( 0xF87FU ) + +/* for input method support on Asian Keyboards */ +#define J_VK_INPUT_METHOD_ON_OFF ( 0xF890U ) +#define J_VK_CODE_INPUT ( 0xF891U ) +#define J_VK_ROMAN_CHARACTERS ( 0xF892U ) +#define J_VK_ALL_CANDIDATES ( 0xF893U ) +#define J_VK_PREVIOUS_CANDIDATE ( 0xF894U ) +#define J_VK_ALPHANUMERIC ( 0xF895U ) +#define J_VK_KATAKANA ( 0xF896U ) +#define J_VK_HIRAGANA ( 0xF897U ) +#define J_VK_FULL_WIDTH ( 0xF898U ) +#define J_VK_HALF_WIDTH ( 0xF89AU ) +#define J_VK_JAPANESE_KATAKANA ( 0xF89BU ) +#define J_VK_JAPANESE_HIRAGANA ( 0xF89CU ) +#define J_VK_JAPANESE_ROMAN ( 0xF89DU ) +#define J_VK_KANA_LOCK ( 0xF89FU ) + +#define J_VK_KEYBOARD_INVISIBLE ( 0xF8FFU ) #endif diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 903188467..56b7251d2 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -99,6 +99,8 @@ static short X11KeySym2NewtVKey(KeySym keySym) { case XK_Super_L: case XK_Super_R: return J_VK_WINDOWS; + case XK_Menu: + return J_VK_CONTEXT_MENU; case XK_Pause: return J_VK_PAUSE; case XK_Caps_Lock: diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java index 7106ed7ce..d1b276105 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java @@ -226,8 +226,8 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase { { try { System.err.println("[K-"+_n+"]"); - AWTRobotUtil.keyPress(_n, _robot, true, KeyEvent.VK_0, 10); - AWTRobotUtil.keyPress(_n, _robot, false, KeyEvent.VK_0, 0); + AWTRobotUtil.newtKeyPress(_n, _robot, true, KeyEvent.VK_0, 10); + AWTRobotUtil.newtKeyPress(_n, _robot, false, KeyEvent.VK_0, 0); Thread.sleep( 40L ) ; _n++; if(!_display.isDisposed()) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java index 08a181e10..b075af977 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java @@ -160,81 +160,90 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { } @SuppressWarnings("deprecation") - static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, int modifierKey, int modifierMask, int keyCode, char keyCharOnly, char keyCharMod) { + static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, short modifierKey, int modifierMask, short keyCode, + char keyCharOnly, char keyCharMod) { keyAdapter.reset(); - AWTRobotUtil.keyPress(0, robot, true, keyCode, 10); // press keyCode - AWTRobotUtil.keyPress(0, robot, false, keyCode, 100); // release+typed keyCode + AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode + AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 100); // release+typed keyCode robot.waitForIdle(); - for(int j=0; j < 40 && keyAdapter.getQueueSize() < 3; j++) { // wait until events are collected + for(int j=0; j < 100 && keyAdapter.getQueueSize() < 3; j++) { // wait until events are collected robot.delay(100); } - AWTRobotUtil.keyPress(0, robot, true, modifierKey, 10); // press MOD - AWTRobotUtil.keyPress(0, robot, true, keyCode, 10); // press keyCode - AWTRobotUtil.keyPress(0, robot, false, keyCode, 10); // release+typed keyCode - AWTRobotUtil.keyPress(0, robot, false, modifierKey, 100); // release MOD + AWTRobotUtil.newtKeyPress(0, robot, true, modifierKey, 10); // press MOD + AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode + AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 10); // release+typed keyCode + AWTRobotUtil.newtKeyPress(0, robot, false, modifierKey, 100); // release MOD robot.waitForIdle(); - for(int j=0; j < 40 && keyAdapter.getQueueSize() < 3+5; j++) { // wait until events are collected + for(int j=0; j < 100 && keyAdapter.getQueueSize() < 3+5; j++) { // wait until events are collected robot.delay(100); } - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - 3 /* press-SI */, 3 /* release-SI */, 2 /* typed-SI */, + final int modTypedCount = KeyEvent.NULL_CHAR != keyCharMod ? 2 : -1 ; // ignore due to mods 'isPrintable' impact. + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, + 3 /* press-SI */, 3 /* release-SI */, modTypedCount /* typed-SI */, 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); - final List queue = keyAdapter.getQueued(); + final List queue = keyAdapter.getQueued(); int i=0; NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, 0, keyCode, keyCharOnly); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, 0, keyCode, keyCharOnly); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, 0, keyCode, keyCharOnly); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey, KeyEvent.NULL_CHAR); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, keyCode, keyCharMod); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, keyCode, keyCharMod); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, keyCode, keyCharMod); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey, (char)0); + KeyEvent e = (KeyEvent) queue.get(i++); + if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { // optional, due to mods 'isPrintable' impact. + NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_TYPED, modifierMask, keyCode, keyCharMod); + e = (KeyEvent) queue.get(i++); + } + NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey, KeyEvent.NULL_CHAR); } @SuppressWarnings("deprecation") static void testKeyCodeAllModifierV1(Robot robot, NEWTKeyAdapter keyAdapter) { - final int m1k = KeyEvent.VK_ALT; - final int m1m = InputEvent.ALT_MASK; - final int m2k = KeyEvent.VK_CONTROL; - final int m2m = InputEvent.CTRL_MASK; - final int m3k = KeyEvent.VK_SHIFT; - final int m3m = InputEvent.SHIFT_MASK; + final short m1k = KeyEvent.VK_ALT; + final int m1m = InputEvent.ALT_MASK; + final short m2k = KeyEvent.VK_CONTROL; + final int m2m = InputEvent.CTRL_MASK; + final short m3k = KeyEvent.VK_SHIFT; + final int m3m = InputEvent.SHIFT_MASK; keyAdapter.reset(); - AWTRobotUtil.keyPress(0, robot, true, m1k, 10); // press MOD1 - AWTRobotUtil.keyPress(0, robot, true, m2k, 10); // press MOD2 - AWTRobotUtil.keyPress(0, robot, true, m3k, 10); // press MOD3 - AWTRobotUtil.keyPress(0, robot, true, KeyEvent.VK_P, 10); // press P + AWTRobotUtil.newtKeyPress(0, robot, true, m1k, 10); // press MOD1 + AWTRobotUtil.newtKeyPress(0, robot, true, m2k, 10); // press MOD2 + AWTRobotUtil.newtKeyPress(0, robot, true, m3k, 10); // press MOD3 + AWTRobotUtil.newtKeyPress(0, robot, true, KeyEvent.VK_1, 10); // press P - AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 100); // release+typed P - AWTRobotUtil.keyPress(0, robot, false, m3k, 10); // release MOD - AWTRobotUtil.keyPress(0, robot, false, m2k, 10); // release MOD - AWTRobotUtil.keyPress(0, robot, false, m1k, 10); // release MOD + AWTRobotUtil.newtKeyPress(0, robot, false, KeyEvent.VK_1, 100); // release+typed P + AWTRobotUtil.newtKeyPress(0, robot, false, m3k, 10); // release MOD + AWTRobotUtil.newtKeyPress(0, robot, false, m2k, 10); // release MOD + AWTRobotUtil.newtKeyPress(0, robot, false, m1k, 10); // release MOD robot.waitForIdle(); - for(int j=0; j < 40 && keyAdapter.getQueueSize() < 4+4+1; j++) { // wait until events are collected + for(int j=0; j < 100 && keyAdapter.getQueueSize() < 4+4+1; j++) { // wait until events are collected robot.delay(100); } NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - 4 /* press-SI */, 4 /* release-SI */, 1 /* typed-SI */, - 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); + 4 /* press-SI */, 4 /* release-SI */, -1 /* typed-SI - ignored, since unknow whether printable w/ all mods */, + 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); final List queue = keyAdapter.getQueued(); int i=0; - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, m3k, (char)0); - - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k, KeyEvent.NULL_CHAR); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k, KeyEvent.NULL_CHAR); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, m3k, KeyEvent.NULL_CHAR); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR); + KeyEvent e = (KeyEvent) queue.get(i++); + if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { // optional, due to mods 'isPrintable' impact. + NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR); + e = (KeyEvent) queue.get(i++); + } + NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k, KeyEvent.NULL_CHAR); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k, KeyEvent.NULL_CHAR); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k, KeyEvent.NULL_CHAR); } void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { @@ -265,8 +274,8 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_1, '1', '!'); testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_Y, 'y', 'Y'); // US: Y, DE: Z testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_P, 'p', 'P'); - testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK, KeyEvent.VK_P, 'p', (char)0); - testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_ALT, InputEvent.ALT_MASK, KeyEvent.VK_P, 'p', (char)0); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK, KeyEvent.VK_1, '1', KeyEvent.NULL_CHAR); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_ALT, InputEvent.ALT_MASK, KeyEvent.VK_1, '1', KeyEvent.NULL_CHAR); testKeyCodeAllModifierV1(robot, glWindow1KA); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java index 277924477..fb42141ea 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java @@ -155,32 +155,35 @@ public class TestNewtKeyCodesAWT extends UITestCase { testNewtCanvasAWT_Impl(false); } + /** Almost all keyCodes reachable w/o modifiers [shift, alt, ..] on US keyboard! */ static CodeSeg[] codeSegments = new CodeSeg[] { - new CodeSeg(0x008, 0x008, "bs"), - // new CodeSeg(0x009, 0x009, "tab"), // TAB functions as focus traversal key - new CodeSeg(0x00a, 0x00a, "cr"), - new CodeSeg(0x010, 0x012, "shift, ctrl, alt"), - new CodeSeg(0x01B, 0x01B, "esc"), - new CodeSeg(0x020, 0x024, "space, up, down, end, home"), - new CodeSeg(0x025, 0x028, "cursor"), - new CodeSeg(0x02C, 0x02F, ", - . /"), - new CodeSeg(0x030, 0x039, "0 - 9"), - new CodeSeg(0x03B, 0x03B, ";"), - new CodeSeg(0x03D, 0x03D, "="), - new CodeSeg(0x041, 0x05A, "a - z"), - new CodeSeg(0x05B, 0x05D, "[ \\ ]"), - // new CodeSeg(0x060, 0x06B, "numpad1"), // can be mapped to normal keycodes - // new CodeSeg(0x06D, 0x06F, "numpad2"), // can be mapped to normal keycodes - new CodeSeg(0x07F, 0x07F, "del"), - // new CodeSeg(0x090, 0x091, "num lock, scroll lock"), - // new CodeSeg(0x070, 0x07B, "F1 - F12"), - // new CodeSeg(0x09A, 0x09D, "prt ins hlp meta"), - new CodeSeg(0x0C0, 0x0C0, "back quote"), - new CodeSeg(0x0DE, 0x0DE, "quote"), - // new CodeSeg(0x0E0, 0x0E3, "cursor kp"), - // new CodeSeg(0x080, 0x08F, "dead-1"), - // new CodeSeg(0x096, 0x0A2, "& ^ \" < > { }"), - // new CodeSeg(0x200, 0x20D, "extra-2"), // @ ; .. + // new CodeSeg(KeyEvent.VK_HOME, KeyEvent.VK_PRINTSCREEN, "home, end, final, prnt"), + new CodeSeg(KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE, "bs"), + // new CodeSeg(KeyEvent.VK_TAB, KeyEvent.VK_TAB, "tab"), // TAB functions as focus traversal key + new CodeSeg(KeyEvent.VK_ENTER, KeyEvent.VK_ENTER, "cr"), + new CodeSeg(KeyEvent.VK_PAGE_DOWN, KeyEvent.VK_PAGE_DOWN, "pg_down"), + new CodeSeg(KeyEvent.VK_SHIFT, KeyEvent.VK_ALT, "shift, pg_up, ctrl, alt"), + // new CodeSeg(KeyEvent.VK_ALT_GRAPH, KeyEvent.VK_ALT_GRAPH, "alt_gr"), // AWT Robot produces 0xff7e on X11 + // new CodeSeg(KeyEvent.VK_SCROLL_LOCK, KeyEvent.VK_SCROLL_LOCK, "scroll lock"), + new CodeSeg(KeyEvent.VK_ESCAPE, KeyEvent.VK_ESCAPE, "esc"), + new CodeSeg(KeyEvent.VK_SPACE, KeyEvent.VK_SPACE, "space"), + new CodeSeg(KeyEvent.VK_QUOTE, KeyEvent.VK_QUOTE, "quote"), + new CodeSeg(KeyEvent.VK_COMMA, KeyEvent.VK_SLASH, ", - . /"), + new CodeSeg(KeyEvent.VK_0, KeyEvent.VK_9, "0 - 9"), + new CodeSeg(KeyEvent.VK_SEMICOLON, KeyEvent.VK_SEMICOLON, ";"), + new CodeSeg(KeyEvent.VK_EQUALS, KeyEvent.VK_EQUALS, "="), + new CodeSeg(KeyEvent.VK_A, KeyEvent.VK_Z, "a - z"), + new CodeSeg(KeyEvent.VK_OPEN_BRACKET, KeyEvent.VK_CLOSE_BRACKET, "[ \\ ]"), + new CodeSeg(KeyEvent.VK_BACK_QUOTE, KeyEvent.VK_BACK_QUOTE, "`"), + new CodeSeg(KeyEvent.VK_F1, KeyEvent.VK_F8, "f1..f8"), + // new CodeSeg(KeyEvent.VK_F1, KeyEvent.VK_F12, "f1..f12"), // f9-f12 may cause some odd desktop functions! + new CodeSeg(KeyEvent.VK_DELETE, KeyEvent.VK_DELETE, "del"), + // new CodeSeg(KeyEvent.VK_NUMPAD0, KeyEvent.VK_NUMPAD9, "numpad0-9"), // can be mapped to normal keycodes + // new CodeSeg(KeyEvent.VK_DECIMAL, KeyEvent.VK_DIVIDE, "numpad ops"), // can be mapped to normal keycodes + // new CodeSeg(KeyEvent.VK_NUM_LOCK, KeyEvent.VK_NUM_LOCK, "num lock"), + // new CodeSeg(KeyEvent.VK_KP_LEFT, KeyEvent.VK_KP_DOWN, "numpad cursor arrows"), + new CodeSeg(KeyEvent.VK_LEFT, KeyEvent.VK_DOWN, "cursor arrows"), + // new CodeSeg(KeyEvent.VK_WINDOWS, KeyEvent.VK_HELP, "windows, meta, hlp"), }; static void testKeyCodes(Robot robot, NEWTKeyAdapter keyAdapter) { @@ -191,23 +194,23 @@ public class TestNewtKeyCodesAWT extends UITestCase { final CodeSeg codeSeg = codeSegments[i]; // System.err.println("*** Segment "+codeSeg.description); int eventCount = 0; - for(short c=codeSeg.min; c<=codeSeg.max; c++) { + for(short c=codeSeg.min; c<=codeSeg.max; c++) { // System.err.println("*** KeyCode 0x"+Integer.toHexString(c)); try { - AWTRobotUtil.keyPress(0, robot, true, c, 10); + AWTRobotUtil.newtKeyPress(0, robot, true, c, 10); } catch (Exception e) { System.err.println("Exception @ AWT Robot.PRESS "+MiscUtils.toHexString(c)+" - "+e.getMessage()); break; } eventCount++; try { - AWTRobotUtil.keyPress(0, robot, false, c, 100); + AWTRobotUtil.newtKeyPress(0, robot, false, c, 100); } catch (Exception e) { System.err.println("Exception @ AWT Robot.RELEASE "+MiscUtils.toHexString(c)+" - "+e.getMessage()); break; } eventCount++; - if( KeyEvent.isPrintableKey(c) ) { + if( KeyEvent.isPrintableKey(c, false) ) { eventCount++; } robot.waitForIdle(); diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index 4195711d6..e128123ed 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -29,6 +29,7 @@ package com.jogamp.opengl.test.junit.util; import jogamp.newt.WindowImplAccess; +import jogamp.newt.awt.event.AWTNewtEventFactory; import java.lang.reflect.InvocationTargetException; import java.awt.AWTException; @@ -449,6 +450,19 @@ public class AWTRobotUtil { return (int) ( System.currentTimeMillis() - t0 ) ; } + /** No validation is performed .. */ + public static int newtKeyPress(int i, Robot robot, boolean press, short newtKeyCode, int msDelay) { + final int keyCode = AWTNewtEventFactory.newtKeyCode2AWTKeyCode(newtKeyCode); + final long t0 = System.currentTimeMillis(); + if(press) { + awtRobotKeyPress(robot, keyCode, msDelay); + } else { + awtRobotKeyRelease(robot, keyCode, msDelay); + } + + return (int) ( System.currentTimeMillis() - t0 ) ; + } + /** * @param keyCode TODO * @param counter shall return the number of keys typed (press + release) diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java index d007d2424..1def57edf 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java @@ -104,7 +104,7 @@ public class NEWTKeyUtil { missCodes.add(new CodeEvent(c, codeSeg.description, e)); misses++; } - if( KeyEvent.isPrintableKey(c) ) { + if( KeyEvent.isPrintableKey(c, false) ) { evtIdx += 3; // w/ TYPED } else { evtIdx += 2; @@ -118,17 +118,17 @@ public class NEWTKeyUtil { return res; } - public static void validateKeyEvent(KeyEvent e, int eventType, int modifier, int keyCode, char keyChar) { + public static void validateKeyEvent(KeyEvent e, short eventType, int modifiers, short keyCode, char keyChar) { if(0 <= eventType) { Assert.assertTrue("KeyEvent type mismatch, expected 0x"+Integer.toHexString(eventType)+", has "+e, eventType == e.getEventType()); } - if(0 <= modifier) { - Assert.assertTrue("KeyEvent modifier mismatch, expected 0x"+Integer.toHexString(modifier)+", has "+e, modifier == e.getModifiers()); + if(0 <= modifiers) { + Assert.assertTrue("KeyEvent modifier mismatch, expected 0x"+Integer.toHexString(modifiers)+", has "+e, modifiers == e.getModifiers()); } - if(0 < keyCode) { + if(KeyEvent.VK_UNDEFINED != keyCode) { Assert.assertTrue("KeyEvent code mismatch, expected 0x"+Integer.toHexString(keyCode)+", has "+e, keyCode == e.getKeyCode()); } - if(0 < keyChar) { + if(KeyEvent.NULL_CHAR != keyChar) { Assert.assertTrue("KeyEvent char mismatch, expected 0x"+Integer.toHexString(keyChar)+", has "+e, keyChar == e.getKeyChar()); } } @@ -168,17 +168,17 @@ public class NEWTKeyUtil { * @param keyAdapter * @param expPressedCountSI number of single key press events * @param expReleasedCountSI number of single key release events - * @param expTypedCountSI number of single key types events + * @param expTypedCountSI number of single key types events, set to -1 to ignore * @param expPressedCountAR number of auto-repeat key press events * @param expReleasedCountAR number of auto-repeat key release events - * @param expTypedCountAR number of auto-repeat key types events + * @param expTypedCountAR number of auto-repeat key types events, set to -1 to ignore */ public static void validateKeyAdapterStats(NEWTKeyAdapter keyAdapter, int expPressedCountSI, int expReleasedCountSI, int expTypedCountSI, int expPressedCountAR, int expReleasedCountAR, int expTypedCountAR) { - final int expTotalCountSI = expPressedCountSI + expReleasedCountSI + expTypedCountSI; - final int expTotalCountAR = expPressedCountAR + expReleasedCountAR + expTypedCountAR; - final int expTotalCountALL = expTotalCountSI + expTotalCountAR; + final int expPressReleaseCountSI = expPressedCountSI + expReleasedCountSI; + final int expPressReleaseCountAR = expPressedCountAR + expReleasedCountAR; + final int expPressReleaseCountALL = expPressReleaseCountSI + expPressReleaseCountAR; final int keyPressedALL = keyAdapter.getKeyPressedCount(false); final int keyPressedAR = keyAdapter.getKeyPressedCount(true); @@ -191,35 +191,39 @@ public class NEWTKeyUtil { final int keyReleasedSI = keyReleasedALL-keyReleasedAR; final int keyTypedSI = keyTypedALL-keyTypedAR; - final int totalCountALL = keyPressedALL + keyReleasedALL + keyTypedALL; - final int totalCountSI = keyPressedSI + keyReleasedSI + keyTypedSI; - final int totalCountAR = keyPressedAR + keyReleasedAR + keyTypedAR; + final int pressReleaseCountALL = keyPressedALL + keyReleasedALL; + final int pressReleaseCountSI = keyPressedSI + keyReleasedSI; + final int pressReleaseCountAR = keyPressedAR + keyReleasedAR; - System.err.println("Expec Single Press "+expPressedCountSI +", Release "+expReleasedCountSI +", Typed "+expTypedCountSI +", Events "+expTotalCountSI); - System.err.println("Expec AutoRp Press "+expPressedCountAR +", Release "+expReleasedCountAR +", Typed "+expTypedCountAR +", Events "+expTotalCountAR); + System.err.println("Expec Single Press "+expPressedCountSI +", Release "+expReleasedCountSI +", Typed "+expTypedCountSI); + System.err.println("Expec AutoRp Press "+expPressedCountAR +", Release "+expReleasedCountAR +", Typed "+expTypedCountAR); - System.err.println("Total Single Press "+keyPressedSI +", Release "+keyReleasedSI +", Typed "+keyTypedSI +", Events "+totalCountSI); - System.err.println("Total AutoRp Press "+keyPressedAR +", Release "+keyReleasedAR +", Typed "+keyTypedAR +", Events "+totalCountAR); - System.err.println("Total ALL Press "+keyPressedALL +", Release "+keyReleasedALL +", Typed "+keyTypedALL+", Events "+totalCountALL); + System.err.println("Total Single Press "+keyPressedSI +", Release "+keyReleasedSI +", Typed "+keyTypedSI +", Events "+pressReleaseCountSI); + System.err.println("Total AutoRp Press "+keyPressedAR +", Release "+keyReleasedAR +", Typed "+keyTypedAR +", Events "+pressReleaseCountAR); + System.err.println("Total ALL Press "+keyPressedALL +", Release "+keyReleasedALL +", Typed "+keyTypedALL+", Events "+pressReleaseCountALL); - Assert.assertEquals("Internal Error: totalSI != totalALL - totalAR", totalCountSI, totalCountALL - totalCountAR); + Assert.assertEquals("Internal Error: pressReleaseSI != pressReleaseALL - pressReleaseAR", pressReleaseCountSI, pressReleaseCountALL - pressReleaseCountAR); Assert.assertEquals("Invalid: Has AR Typed events", 0, keyTypedAR); - Assert.assertEquals("Invalid: Exp AR Typed events", 0, expTypedCountAR); + if( 0 <= expTypedCountAR ) { + Assert.assertEquals("Invalid: Exp AR Typed events", 0, expTypedCountAR); + } Assert.assertEquals("Key press count failure (SI)", expPressedCountSI, keyPressedSI); Assert.assertEquals("Key released count failure (SI)", expReleasedCountSI, keyReleasedSI); - Assert.assertEquals("Key typed count failure (SI)", expTypedCountSI, keyTypedSI); + if( 0 <= expTypedCountSI ) { + Assert.assertEquals("Key typed count failure (SI)", expTypedCountSI, keyTypedSI); + } Assert.assertEquals("Key press count failure (AR)", expPressedCountAR, keyPressedAR); Assert.assertEquals("Key released count failure (AR)", expReleasedCountAR, keyReleasedAR); - Assert.assertEquals("Key total count failure (SI)", expTotalCountSI, totalCountSI); - Assert.assertEquals("Key total count failure (AR)", expTotalCountAR, totalCountAR); + Assert.assertEquals("Key pressRelease count failure (SI)", expPressReleaseCountSI, pressReleaseCountSI); + Assert.assertEquals("Key pressRelease count failure (AR)", expPressReleaseCountAR, pressReleaseCountAR); final List keyEvents = keyAdapter.getQueued(); - Assert.assertEquals("Key total count failure (ALL) w/ list sum ", expTotalCountALL, totalCountALL); - Assert.assertEquals("Key total count failure (ALL) w/ list size ", expTotalCountALL, keyEvents.size()); + Assert.assertEquals("Key pressRelease count failure (ALL) w/ list sum ", expPressReleaseCountALL, pressReleaseCountALL); + Assert.assertEquals("Key total count failure (ALL) w/ list size ", pressReleaseCountALL + keyTypedALL, keyEvents.size()); } } -- cgit v1.2.3 From 294294c2317d1a22406f471c74235315afed86e4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 11 Apr 2013 07:29:02 +0200 Subject: LinuxEventDeviceTracker: Reapply changes from commit b13868b612689307ebf4e46ee4ede2fd0560e504, which got lost via my merge conflict resolution (duh). --- .../classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index 7b8c5eb2a..e68b91d82 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -376,11 +376,11 @@ public class LinuxEventDeviceTracker implements WindowListener { } private char NewtVKey2Unicode(short VK, int modifiers) { - if( KeyEvent.isPrintableKey(VK) ) { + if( KeyEvent.isPrintableKey(VK, true) ) { if((modifiers & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) { return (char)VK; } else { - return (((char)VK) + "").toLowerCase().charAt(0); + return String.valueOf((char)VK).toLowerCase().charAt(0); } } return 0; @@ -548,9 +548,9 @@ public class LinuxEventDeviceTracker implements WindowListener { case 39: return KeyEvent.VK_SEMICOLON; case 40: // apostrophe - return KeyEvent.VK_DEAD_ACUTE; + return KeyEvent.VK_QUOTE; case 41: // grave - return KeyEvent.VK_DEAD_GRAVE; + return KeyEvent.VK_BACK_QUOTE; case 42: // left shift return KeyEvent.VK_SHIFT; -- cgit v1.2.3 From 9d78ea65a6bf1064887bc7524c01a689a1fc2a5c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 13 Apr 2013 08:15:21 +0200 Subject: NEWT/AWT: Fix 'AWT driver' to work w/ OSX CALayer ; WindowImpl: 'Object getWrappedWindow()' -> 'NativeSurface getWrappedSurface()' WindowImpl: 'Object getWrappedWindow()' -> 'NativeSurface getWrappedSurface()' - AWT driver itself instantiates the JAWTWindow for eager initialization at createNative(). Fix 'AWT driver' to work w/ OSX CALayer - See above - size reconfig changed to ease OSX CALayer, i.e. set frame's size if already visible reducing CALayer artefacts. --- make/scripts/tests.sh | 6 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 14 ++- src/newt/classes/jogamp/newt/WindowImpl.java | 10 +- .../classes/jogamp/newt/driver/awt/AWTCanvas.java | 42 +++++++-- .../jogamp/newt/driver/awt/WindowDriver.java | 101 ++++++++++++++------- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 2 +- .../demos/gl2/newt/TestGearsNewtAWTWrapper.java | 68 ++++++++------ 7 files changed, 157 insertions(+), 86 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 35d669a47..a10be0db9 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -171,7 +171,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -290,7 +290,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* +testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* @@ -370,7 +370,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* -testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index a6c655915..de62747be 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -40,7 +40,6 @@ import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; @@ -472,17 +471,16 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind if( ( null != context ) ) { throw new InternalError("GLWindow.LifecycleHook.setVisiblePost: "+WindowImpl.getThreadName()+" - Null drawable, but valid context - "+GLWindow.this); } - final NativeWindow nw; - if (window.getWrappedWindow() != null) { - nw = NativeWindowFactory.getNativeWindow(window.getWrappedWindow(), window.getPrivateGraphicsConfiguration()); - } else { - nw = window; + final NativeSurface ns; + { + final NativeSurface wrapped_ns = window.getWrappedSurface(); + ns = null != wrapped_ns ? wrapped_ns : window; } - final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) nw.getGraphicsConfiguration().getChosenCapabilities(); + final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) ns.getGraphicsConfiguration().getChosenCapabilities(); if(null==factory) { factory = GLDrawableFactory.getFactory(glCaps.getGLProfile()); } - drawable = (GLDrawableImpl) factory.createGLDrawable(nw); + drawable = (GLDrawableImpl) factory.createGLDrawable(ns); drawable.setRealized(true); if( !GLWindow.this.pushGLEventListenerState() ) { diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 01a58a305..bfb450f68 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1562,9 +1562,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return old; } - /** If this Window actually wraps one from another toolkit such as - the AWT, this will return a non-null value. */ - public Object getWrappedWindow() { + /** + * If this Window actually wraps a {@link NativeSurface} from another instance or toolkit, + * it will return such reference. Otherwise returns null. + */ + public NativeSurface getWrappedSurface() { return null; } @@ -1598,7 +1600,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer "\n, Visible "+isVisible()+", focus "+hasFocus()+ "\n, Undecorated "+undecorated+" ("+isUndecorated()+")"+ "\n, AlwaysOnTop "+alwaysOnTop+", Fullscreen "+fullscreen+ - "\n, WrappedWindow "+getWrappedWindow()+ + "\n, WrappedSurface "+getWrappedSurface()+ "\n, ChildWindows "+childWindows.size()); sb.append(", SurfaceUpdatedListeners num "+surfaceUpdatedHelper.size()+" ["); diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index 17eb6a2fb..85cb655d7 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -47,13 +47,15 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.VisualIDHolder; - import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.newt.Window; @SuppressWarnings("serial") @@ -61,17 +63,15 @@ public class AWTCanvas extends Canvas { private GraphicsDevice device; private GraphicsConfiguration chosen; private AWTGraphicsConfiguration awtConfig; - - private WindowDriver newtWindowImpl; + private volatile JAWTWindow jawtWindow=null; // the JAWTWindow presentation of this AWT Canvas, bound to the 'drawable' lifecycle private CapabilitiesChooser chooser=null; private CapabilitiesImmutable capabilities; private boolean displayConfigChanged=false; - public AWTCanvas(WindowDriver newtWindowImpl, CapabilitiesImmutable capabilities, CapabilitiesChooser chooser) { + public AWTCanvas(CapabilitiesImmutable capabilities, CapabilitiesChooser chooser) { super(); - this.newtWindowImpl = newtWindowImpl; if(null==capabilities) { throw new NativeWindowException("Capabilities null"); } @@ -89,7 +89,7 @@ public class AWTCanvas extends Canvas { */ @Override public void update(Graphics g) { - paint(g); + // paint(g); } /** Overridden to cause OpenGL rendering to be performed during @@ -99,7 +99,6 @@ public class AWTCanvas extends Canvas { */ @Override public void paint(Graphics g) { - newtWindowImpl.windowRepaint(0, 0, getWidth(), getHeight()); } public boolean hasDeviceChanged() { @@ -120,8 +119,7 @@ public class AWTCanvas extends Canvas { */ awtConfig = chooseGraphicsConfiguration(capabilities, capabilities, chooser, device); if(Window.DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Info: Created Config: "+awtConfig); - e.printStackTrace(); + System.err.println(getThreadName()+": AWTCanvas.addNotify.0: Created Config: "+awtConfig); } if(null==awtConfig) { throw new NativeWindowException("Error: NULL AWTGraphicsConfiguration"); @@ -137,12 +135,27 @@ public class AWTCanvas extends Canvas { // after native peer is valid: Windows disableBackgroundErase(); + { + jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); + // trigger initialization cycle + jawtWindow.lockSurface(); + jawtWindow.unlockSurface(); + } + GraphicsConfiguration gc = super.getGraphicsConfiguration(); if(null!=gc) { device = gc.getDevice(); } + if(Window.DEBUG_IMPLEMENTATION) { + System.err.println(getThreadName()+": AWTCanvas.addNotify.X"); + } } + public NativeSurface getNativeSurface() { + final JAWTWindow _jawtWindow = jawtWindow; + return (null != _jawtWindow) ? _jawtWindow : null; + } + public void removeNotify() { try { dispose(); @@ -152,6 +165,13 @@ public class AWTCanvas extends Canvas { } private void dispose() { + if( null != jawtWindow ) { + jawtWindow.destroy(); + if(Window.DEBUG_IMPLEMENTATION) { + System.err.println(getThreadName()+": AWTCanvas.disposeJAWTWindowAndAWTDeviceOnEDT(): post JAWTWindow: "+jawtWindow); + } + jawtWindow=null; + } if(null != awtConfig) { AbstractGraphicsDevice adevice = awtConfig.getNativeGraphicsConfiguration().getScreen().getDevice(); String adeviceMsg=null; @@ -160,10 +180,12 @@ public class AWTCanvas extends Canvas { } boolean closed = adevice.close(); if(Window.DEBUG_IMPLEMENTATION) { - System.err.println("AWTCanvas.dispose(): closed GraphicsDevice: "+adeviceMsg+", result: "+closed); + System.err.println(getThreadName()+": AWTCanvas.dispose(): closed GraphicsDevice: "+adeviceMsg+", result: "+closed); } } } + + private String getThreadName() { return Thread.currentThread().getName(); } /** * Overridden to choose a GraphicsConfiguration on a parent container's diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index 0172309fb..cc678e4ef 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -40,6 +40,7 @@ import java.awt.Dimension; import java.awt.Frame; import java.awt.Insets; +import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.util.Point; @@ -111,31 +112,38 @@ public class WindowDriver extends WindowImpl { } container.setLayout(new BorderLayout()); - canvas = new AWTCanvas(this, capsRequested, WindowDriver.this.capabilitiesChooser); + if( null == canvas ) { + canvas = new AWTCanvas(capsRequested, WindowDriver.this.capabilitiesChooser); - // canvas.addComponentListener(listener); - container.add(canvas, BorderLayout.CENTER); + // canvas.addComponentListener(listener); + container.add(canvas, BorderLayout.CENTER); - // via EDT .. - new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here - new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here + // via EDT .. + new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here + new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here - // direct w/o EDT - new AWTWindowAdapter(new LocalWindowListener(), this).addTo(canvas); // fwd all AWT Window events to here + // direct w/o EDT + new AWTWindowAdapter(new LocalWindowListener(), this).addTo(canvas); // fwd all AWT Window events to here + } reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true)); // throws exception if failed .. - setWindowHandle(1); // just a marker .. + final NativeSurface ns = canvas.getNativeSurface(); + if( null != ns ) { + setGraphicsConfiguration( canvas.getAWTGraphicsConfiguration() ); + setWindowHandle( ns.getSurfaceHandle() ); + } } protected void closeNativeImpl() { - setWindowHandle(0); // just a marker .. + setWindowHandle(0); if(null!=container) { container.setVisible(false); container.remove(canvas); container.setEnabled(false); canvas.setEnabled(false); + canvas = null; } if(owningFrame && null!=frame) { frame.dispose(); @@ -172,6 +180,10 @@ public class WindowDriver extends WindowImpl { } protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("AWTWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ + getReconfigureFlagsAsString(null, flags)); + } if(0 != ( FLAG_CHANGE_DECORATION & flags) && null!=frame) { if(!container.isDisplayable()) { frame.setUndecorated(isUndecorated()); @@ -182,26 +194,44 @@ public class WindowDriver extends WindowImpl { } } - final Dimension szClient = new Dimension(width, height); - canvas.setMinimumSize(szClient); - canvas.setPreferredSize(szClient); - canvas.setSize(szClient); - if(DEBUG_IMPLEMENTATION) { + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + if( 0 != ( FLAG_IS_VISIBLE & flags) ) { + final Dimension szClient = new Dimension(width, height); + canvas.setMinimumSize(szClient); + canvas.setPreferredSize(szClient); + if(DEBUG_IMPLEMENTATION) { + final Insets insets = container.getInsets(); + final Dimension szContainer = new Dimension(width + insets.left + insets.right, + height + insets.top + insets.bottom); + System.err.println(getThreadName()+": AWTWindow initial size: szClient "+szClient+", szCont "+szContainer+", insets "+insets); + } + canvas.setSize(szClient); + if(null != frame) { + frame.pack(); + } else { + container.validate(); + } + container.setVisible( true ); + defineSize(width, height); // we are on AWT-EDT .. change values immediately + } else { + container.setVisible( false ); + } + } else if( canvas.getWidth() != width || canvas.getHeight() != height ) { final Insets insets = container.getInsets(); final Dimension szContainer = new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom); - System.err.println(getThreadName()+": AWTWindow new size: szClient "+szClient+", szCont "+szContainer+", insets "+insets); - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - if(null != frame) { - frame.pack(); + if(DEBUG_IMPLEMENTATION) { + final Dimension szClient = new Dimension(width, height); + System.err.println(getThreadName()+": AWTWindow new size: szClient "+szClient+", szCont "+szContainer+", insets "+insets); } - container.validate(); - container.setVisible(0 != ( FLAG_IS_VISIBLE & flags)); + container.setSize(szContainer); + container.validate(); + defineSize(width, height); // we are on AWT-EDT .. change values immediately } - container.setLocation(x, y); + if( container.getX() != x || container.getY() != y ) { + container.setLocation(x, y); + } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { if( 0 != ( FLAG_IS_VISIBLE & flags ) ) { @@ -215,12 +245,6 @@ public class WindowDriver extends WindowImpl { } } visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } else { - container.invalidate(); - if(null != frame) { - frame.pack(); - } - container.validate(); } return true; @@ -233,8 +257,8 @@ public class WindowDriver extends WindowImpl { } @Override - public Object getWrappedWindow() { - return canvas; + public NativeSurface getWrappedSurface() { + return ( null != canvas ) ? canvas.getNativeSurface() : null; } class LocalWindowListener implements com.jogamp.newt.event.WindowListener { @@ -247,7 +271,11 @@ public class WindowDriver extends WindowImpl { @Override public void windowResized(com.jogamp.newt.event.WindowEvent e) { if(null!=canvas) { - WindowDriver.this.sizeChanged(false, canvas.getWidth(), canvas.getHeight(), false); + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window Resized: "+canvas); + } + WindowDriver.this.sizeChanged(false, canvas.getWidth(), canvas.getHeight(), true); + WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight()); } } @Override @@ -268,7 +296,12 @@ public class WindowDriver extends WindowImpl { } @Override public void windowRepaint(WindowUpdateEvent e) { - WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight()); + if(null!=canvas) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window Repaint: "+canvas); + } + WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight()); + } } } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 5e523c780..9bbbbce05 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -270,7 +270,7 @@ public class GearsES2 implements GLEventListener { public void display(GLAutoDrawable drawable) { GLAnimatorControl anim = drawable.getAnimator(); if( verbose && ( null == anim || !anim.isAnimating() ) ) { - System.err.println(Thread.currentThread()+" GearsES2.display"+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); + System.err.println(Thread.currentThread()+" GearsES2.display "+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); } // Turn the gears' teeth if(doRotate) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java index cc20cc27e..0b907d5ee 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java @@ -34,6 +34,7 @@ import javax.media.opengl.*; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -49,6 +50,9 @@ import org.junit.Test; public class TestGearsNewtAWTWrapper extends UITestCase { static GLProfile glp; static int width, height; + static boolean useAnimator = true; + static boolean doResizeTest = true; + static long duration = 500; // ms @BeforeClass public static void initClass() { @@ -73,39 +77,50 @@ public class TestGearsNewtAWTWrapper extends UITestCase { glWindow.addGLEventListener(new GearsES2(1)); - Animator animator = new Animator(glWindow); + Animator animator = useAnimator ? new Animator(glWindow) : null; QuitAdapter quitAdapter = new QuitAdapter(); glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + if( useAnimator ) { + animator.start(); + } + int div = 3; glWindow.setSize(width/div, height/div); glWindow.setVisible(true); - glWindow.display(); - Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), - AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); - - div = 2; - glWindow.setSize(width/div, height/div); - glWindow.display(); - Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), - AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); - - div = 1; - glWindow.setSize(width/div, height/div); - glWindow.display(); - Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), - AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); - - animator.setUpdateFPSFrames(1, null); - animator.start(); + if( doResizeTest ) { + glWindow.display(); + Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), + AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); + Thread.sleep(600); + + div = 2; + glWindow.setSize(width/div, height/div); + glWindow.display(); + Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), + AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); + Thread.sleep(600); + + div = 1; + glWindow.setSize(width/div, height/div); + glWindow.display(); + Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), + AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); + Thread.sleep(600); + } - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() Date: Sun, 14 Apr 2013 03:46:46 +0200 Subject: NEWT/AWT-Wrapper-Driver: Fix MS-Windows Case (Use NativeWindow window handle); Use set size by frame only for OSX/CALayer --- make/scripts/java-win64-dbg.bat | 4 +- make/scripts/tests-x64.bat | 4 +- make/scripts/tests.sh | 3 +- .../classes/jogamp/newt/driver/awt/AWTCanvas.java | 8 +- .../jogamp/newt/driver/awt/WindowDriver.java | 181 ++++++++++++--------- 5 files changed, 112 insertions(+), 88 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 0dd922dde..48653d907 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -39,8 +39,8 @@ REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" -REM set D_ARGS="-Dnewt.debug.Window" -set D_ARGS="-Dnewt.debug.Window.KeyEvent" +set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 237770488..7d1380287 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -47,10 +47,10 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScroll REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a10be0db9..2974658a8 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -177,7 +177,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -317,6 +317,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAO $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index 85cb655d7..9a1632130 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -47,7 +47,7 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.VisualIDHolder; @@ -151,11 +151,15 @@ public class AWTCanvas extends Canvas { } } - public NativeSurface getNativeSurface() { + public NativeWindow getNativeWindow() { final JAWTWindow _jawtWindow = jawtWindow; return (null != _jawtWindow) ? _jawtWindow : null; } + public boolean isOffscreenLayerSurfaceEnabled() { + return null != jawtWindow ? jawtWindow.isOffscreenLayerSurfaceEnabled() : false; + } + public void removeNotify() { try { dispose(); diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index cc678e4ef..c45a5ae3b 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -41,11 +41,14 @@ import java.awt.Frame; import java.awt.Insets; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.util.Point; +import jogamp.nativewindow.awt.AWTMisc; import jogamp.newt.WindowImpl; +import com.jogamp.common.os.Platform; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; @@ -71,25 +74,26 @@ public class WindowDriver extends WindowImpl { public WindowDriver(Container container) { super(); - this.container = container; + this.awtContainer = container; if(container instanceof Frame) { - frame = (Frame) container; + awtFrame = (Frame) container; } } private boolean owningFrame; - private Container container = null; - private Frame frame = null; // same instance as container, just for impl. convenience - private AWTCanvas canvas; + private Container awtContainer = null; + /** same instance as container, just for impl. convenience */ + private Frame awtFrame = null; + private AWTCanvas awtCanvas; protected void requestFocusImpl(boolean reparented) { - container.requestFocus(); + awtContainer.requestFocus(); } @Override protected void setTitleImpl(final String title) { - if (frame != null) { - frame.setTitle(title); + if (awtFrame != null) { + awtFrame.setTitle(title); } } @@ -98,65 +102,66 @@ public class WindowDriver extends WindowImpl { throw new RuntimeException("Window parenting not supported in AWT, use AWTWindow(Frame) cstr for wrapping instead"); } - if(null==container) { - frame = new Frame(); - container = frame; + if(null==awtContainer) { + awtFrame = new Frame(); + awtContainer = awtFrame; owningFrame=true; } else { owningFrame=false; - defineSize(container.getWidth(), container.getHeight()); - definePosition(container.getX(), container.getY()); + defineSize(awtContainer.getWidth(), awtContainer.getHeight()); + definePosition(awtContainer.getX(), awtContainer.getY()); } - if(null!=frame) { - frame.setTitle(getTitle()); + if(null!=awtFrame) { + awtFrame.setTitle(getTitle()); } - container.setLayout(new BorderLayout()); + awtContainer.setLayout(new BorderLayout()); - if( null == canvas ) { - canvas = new AWTCanvas(capsRequested, WindowDriver.this.capabilitiesChooser); + if( null == awtCanvas ) { + awtCanvas = new AWTCanvas(capsRequested, WindowDriver.this.capabilitiesChooser); // canvas.addComponentListener(listener); - container.add(canvas, BorderLayout.CENTER); + awtContainer.add(awtCanvas, BorderLayout.CENTER); // via EDT .. - new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here - new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here + new AWTMouseAdapter(this).addTo(awtCanvas); // fwd all AWT Mouse events to here + new AWTKeyAdapter(this).addTo(awtCanvas); // fwd all AWT Key events to here // direct w/o EDT - new AWTWindowAdapter(new LocalWindowListener(), this).addTo(canvas); // fwd all AWT Window events to here + new AWTWindowAdapter(new LocalWindowListener(), this).addTo(awtCanvas); // fwd all AWT Window events to here } reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true)); // throws exception if failed .. - final NativeSurface ns = canvas.getNativeSurface(); - if( null != ns ) { - setGraphicsConfiguration( canvas.getAWTGraphicsConfiguration() ); - setWindowHandle( ns.getSurfaceHandle() ); + final NativeWindow nw = awtCanvas.getNativeWindow(); + if( null != nw ) { + setGraphicsConfiguration( awtCanvas.getAWTGraphicsConfiguration() ); + setWindowHandle( nw.getWindowHandle() ); } } protected void closeNativeImpl() { setWindowHandle(0); - if(null!=container) { - container.setVisible(false); - container.remove(canvas); - container.setEnabled(false); - canvas.setEnabled(false); - canvas = null; + if(null!=awtContainer) { + awtContainer.setVisible(false); + awtContainer.remove(awtCanvas); + awtContainer.setEnabled(false); + awtCanvas.setEnabled(false); } - if(owningFrame && null!=frame) { - frame.dispose(); + if(owningFrame && null!=awtFrame) { + awtFrame.dispose(); owningFrame=false; - frame = null; } + awtCanvas = null; + awtFrame = null; + awtContainer = null; } @Override public boolean hasDeviceChanged() { - boolean res = canvas.hasDeviceChanged(); + boolean res = awtCanvas.hasDeviceChanged(); if(res) { - final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration(); + final AWTGraphicsConfiguration cfg = awtCanvas.getAWTGraphicsConfiguration(); if (null == cfg) { throw new NativeWindowException("Error Device change null GraphicsConfiguration: "+this); } @@ -172,21 +177,54 @@ public class WindowDriver extends WindowImpl { } protected void updateInsetsImpl(javax.media.nativewindow.util.Insets insets) { - Insets contInsets = container.getInsets(); + Insets contInsets = awtContainer.getInsets(); insets.setLeftWidth(contInsets.left); insets.setRightWidth(contInsets.right); insets.setTopHeight(contInsets.top); insets.setBottomHeight(contInsets.bottom); } + private void setCanvasSizeImpl(int width, int height) { + final Dimension szClient = new Dimension(width, height); + final java.awt.Window awtWindow = AWTMisc.getWindow(awtCanvas); + final Container c= null != awtWindow ? awtWindow : awtContainer; + awtCanvas.setMinimumSize(szClient); + awtCanvas.setPreferredSize(szClient); + if(DEBUG_IMPLEMENTATION) { + final Insets insets = c.getInsets(); + final Dimension szContainer = new Dimension(width + insets.left + insets.right, + height + insets.top + insets.bottom); + System.err.println(getThreadName()+": AWTWindow setCanvasSize: szClient "+szClient+", szCont "+szContainer+", insets "+insets); + } + awtCanvas.setSize(szClient); + awtCanvas.invalidate(); + if(null != awtWindow) { + awtWindow.pack(); + } else { + awtContainer.validate(); + } + } + private void setFrameSizeImpl(int width, int height) { + final Insets insets = awtContainer.getInsets(); + final Dimension szContainer = new Dimension(width + insets.left + insets.right, + height + insets.top + insets.bottom); + if(DEBUG_IMPLEMENTATION) { + final Dimension szClient = new Dimension(width, height); + System.err.println(getThreadName()+": AWTWindow setFrameSize: szClient "+szClient+", szCont "+szContainer+", insets "+insets); + } + awtContainer.setSize(szContainer); + awtCanvas.invalidate(); + awtContainer.validate(); + } + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { if(DEBUG_IMPLEMENTATION) { System.err.println("AWTWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); } - if(0 != ( FLAG_CHANGE_DECORATION & flags) && null!=frame) { - if(!container.isDisplayable()) { - frame.setUndecorated(isUndecorated()); + if(0 != ( FLAG_CHANGE_DECORATION & flags) && null!=awtFrame) { + if(!awtContainer.isDisplayable()) { + awtFrame.setUndecorated(isUndecorated()); } else { if(DEBUG_IMPLEMENTATION) { System.err.println(getThreadName()+": AWTWindow can't undecorate already created frame"); @@ -196,48 +234,29 @@ public class WindowDriver extends WindowImpl { if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { if( 0 != ( FLAG_IS_VISIBLE & flags) ) { - final Dimension szClient = new Dimension(width, height); - canvas.setMinimumSize(szClient); - canvas.setPreferredSize(szClient); - if(DEBUG_IMPLEMENTATION) { - final Insets insets = container.getInsets(); - final Dimension szContainer = new Dimension(width + insets.left + insets.right, - height + insets.top + insets.bottom); - System.err.println(getThreadName()+": AWTWindow initial size: szClient "+szClient+", szCont "+szContainer+", insets "+insets); - } - canvas.setSize(szClient); - if(null != frame) { - frame.pack(); - } else { - container.validate(); - } - container.setVisible( true ); - defineSize(width, height); // we are on AWT-EDT .. change values immediately + setCanvasSizeImpl(width, height); + awtContainer.setVisible( true ); } else { - container.setVisible( false ); + awtContainer.setVisible( false ); } - } else if( canvas.getWidth() != width || canvas.getHeight() != height ) { - final Insets insets = container.getInsets(); - final Dimension szContainer = new Dimension(width + insets.left + insets.right, - height + insets.top + insets.bottom); - if(DEBUG_IMPLEMENTATION) { - final Dimension szClient = new Dimension(width, height); - System.err.println(getThreadName()+": AWTWindow new size: szClient "+szClient+", szCont "+szContainer+", insets "+insets); + } else if( awtCanvas.getWidth() != width || awtCanvas.getHeight() != height ) { + if( Platform.OSType.MACOS == Platform.getOSType() && awtCanvas.isOffscreenLayerSurfaceEnabled() ) { + setFrameSizeImpl(width, height); + } else { + setCanvasSizeImpl(width, height); } - container.setSize(szContainer); - container.validate(); - defineSize(width, height); // we are on AWT-EDT .. change values immediately } + defineSize(width, height); // we are on AWT-EDT .. change values immediately - if( container.getX() != x || container.getY() != y ) { - container.setLocation(x, y); + if( awtContainer.getX() != x || awtContainer.getY() != y ) { + awtContainer.setLocation(x, y); } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { if( 0 != ( FLAG_IS_VISIBLE & flags ) ) { if( !hasDeviceChanged() ) { // oops ?? - final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration(); + final AWTGraphicsConfiguration cfg = awtCanvas.getAWTGraphicsConfiguration(); if(null == cfg) { throw new NativeWindowException("Error: !hasDeviceChanged && null == GraphicsConfiguration: "+this); } @@ -251,30 +270,30 @@ public class WindowDriver extends WindowImpl { } protected Point getLocationOnScreenImpl(int x, int y) { - java.awt.Point ap = canvas.getLocationOnScreen(); + java.awt.Point ap = awtCanvas.getLocationOnScreen(); ap.translate(x, y); return new Point((int)(ap.getX()+0.5),(int)(ap.getY()+0.5)); } @Override public NativeSurface getWrappedSurface() { - return ( null != canvas ) ? canvas.getNativeSurface() : null; + return ( null != awtCanvas ) ? awtCanvas.getNativeWindow() : null; } class LocalWindowListener implements com.jogamp.newt.event.WindowListener { @Override public void windowMoved(com.jogamp.newt.event.WindowEvent e) { - if(null!=container) { - WindowDriver.this.positionChanged(false, container.getX(), container.getY()); + if(null!=awtContainer) { + WindowDriver.this.positionChanged(false, awtContainer.getX(), awtContainer.getY()); } } @Override public void windowResized(com.jogamp.newt.event.WindowEvent e) { - if(null!=canvas) { + if(null!=awtCanvas) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window Resized: "+canvas); + System.err.println("Window Resized: "+awtCanvas); } - WindowDriver.this.sizeChanged(false, canvas.getWidth(), canvas.getHeight(), true); + WindowDriver.this.sizeChanged(false, awtCanvas.getWidth(), awtCanvas.getHeight(), true); WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight()); } } @@ -296,9 +315,9 @@ public class WindowDriver extends WindowImpl { } @Override public void windowRepaint(WindowUpdateEvent e) { - if(null!=canvas) { + if(null!=awtCanvas) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window Repaint: "+canvas); + System.err.println("Window Repaint: "+awtCanvas); } WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight()); } -- cgit v1.2.3 From d173feb60d085399194549102d4b3d77512c3f73 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 18 Apr 2013 08:31:11 +0200 Subject: Bug 721: NEWT/X11 RandR 1.3 Support - Part 1 - Delegate RandR functionality to pluggable impl. for RandR 1.1 and 1.3 (todo) --- make/build-newt.xml | 24 +- make/scripts/tests.sh | 4 +- src/newt/classes/jogamp/newt/ScreenImpl.java | 10 +- .../jogamp/newt/driver/x11/ScreenDriver.java | 225 ++---------- .../jogamp/newt/driver/x11/ScreenRandR.java | 12 + .../jogamp/newt/driver/x11/ScreenRandR11.java | 214 +++++++++++ src/newt/native/X11Common.h | 3 +- src/newt/native/X11Screen.c | 397 +-------------------- src/newt/native/X11Screen.h | 39 ++ src/newt/native/X11ScreenRandR11.c | 232 ++++++++---- 10 files changed, 501 insertions(+), 659 deletions(-) create mode 100644 src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java create mode 100644 src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java create mode 100644 src/newt/native/X11Screen.h (limited to 'src/newt/classes') diff --git a/make/build-newt.xml b/make/build-newt.xml index c601bc120..d728b42c7 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -584,19 +584,20 @@ - - - - - + + + + + - - - - - - + + + + + + + @@ -700,6 +701,7 @@ +
    diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 23dbf3fd0..d9d5cd622 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -289,7 +289,7 @@ function testawtswt() { #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* -testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* @@ -378,7 +378,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 56d6f67ff..1282e5dc5 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -61,11 +61,11 @@ import com.jogamp.newt.util.ScreenModeUtil; public abstract class ScreenImpl extends Screen implements ScreenModeListener { protected static final boolean DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true); - protected static final int default_sm_bpp = 32; - protected static final int default_sm_widthmm = 519; - protected static final int default_sm_heightmm = 324; - protected static final int default_sm_rate = 60; - protected static final int default_sm_rotation = 0; + public static final int default_sm_bpp = 32; + public static final int default_sm_widthmm = 519; + public static final int default_sm_heightmm = 324; + public static final int default_sm_rate = 60; + public static final int default_sm_rotation = 0; protected DisplayImpl display; protected int screen_idx; diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index 7a3c718c0..d94f27371 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -43,10 +43,10 @@ import jogamp.newt.DisplayImpl; import jogamp.newt.DisplayImpl.DisplayRunnable; import jogamp.newt.ScreenImpl; +import com.jogamp.common.util.VersionNumber; import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; public class ScreenDriver extends ScreenImpl { @@ -65,172 +65,63 @@ public class ScreenDriver extends ScreenImpl { } } ); if (handle.longValue() == 0) { throw new RuntimeException("Error creating screen: " + screen_idx); - } - aScreen = new X11GraphicsScreen((X11GraphicsDevice) getDisplay().getGraphicsDevice(), screen_idx); + } + final X11GraphicsDevice x11dev = (X11GraphicsDevice) getDisplay().getGraphicsDevice(); + final long dpy = x11dev.getHandle(); + aScreen = new X11GraphicsScreen(x11dev, screen_idx); + { + int v[] = getRandRVersion0(dpy); + randrVersion = new VersionNumber(v[0], v[1], 0); + } + System.err.println("RandR "+randrVersion); + if( !randrVersion.isZero() ) { + screenRandR = new ScreenRandR11(); + } else { + screenRandR = null; + } } protected void closeNativeImpl() { } - private int[] nrotations; - private int nrotation_index; - private int nres_number; - private int nres_index; - private int[] nrates; - private int nrate_index; - private int nmode_number; - + private VersionNumber randrVersion; + private ScreenRandR screenRandR; + + @Override protected int[] getScreenModeFirstImpl() { + if( null == screenRandR ) { return null; } + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public int[] run(long dpy) { - // initialize iterators and static data - nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); - if(null==nrotations || 0==nrotations.length) { - return null; - } - nrotation_index = 0; - - nres_number = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==nres_number) { - return null; - } - nres_index = 0; - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - - nmode_number = 0; - - return getScreenModeNextImpl(); + return screenRandR.getScreenModeFirstImpl(dpy, screen_idx); } } ); } + @Override protected int[] getScreenModeNextImpl() { + if( null == screenRandR ) { return null; } + // assemble: w x h x bpp x f x r return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public int[] run(long dpy) { - /** - System.err.println("******** mode: "+nmode_number); - System.err.println("rot "+nrotation_index); - System.err.println("rate "+nrate_index); - System.err.println("res "+nres_index); */ - - int[] res = getScreenModeResolution0(dpy, screen_idx, nres_index); - if(null==res || 0==res.length) { - return null; - } - if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); - } - int rate = nrates[nrate_index]; - if(0>=rate) { - rate = default_sm_rate; - if(DEBUG) { - System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+default_sm_rate); - } - } - int rotation = nrotations[nrotation_index]; - - int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; - int i = 0; - props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode - props[i++] = 0; // set later for verification of iterator - props[i++] = res[0]; // width - props[i++] = res[1]; // height - props[i++] = default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rotation; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element - - nmode_number++; - - // iteration: r -> f -> bpp -> [w x h] - nrotation_index++; - if(nrotation_index == nrotations.length) { - nrotation_index=0; - nrate_index++; - if(null == nrates || nrate_index == nrates.length){ - nres_index++; - if(nres_index == nres_number) { - // done - nrates=null; - nrotations=null; - return null; - } - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - } - } - - return props; + return screenRandR.getScreenModeNextImpl(dpy, screen_idx); } } ); } + @Override protected ScreenMode getCurrentScreenModeImpl() { + if( null == screenRandR ) { return null; } + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public ScreenMode run(long dpy) { - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); - if(0 == screenConfigHandle) { - return null; - } - int[] res; - int rate, rot; - try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==resNumber) { - return null; - } - - int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); - if(0>resIdx) { - return null; - } - if(resIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); - } - res = getScreenModeResolution0(dpy, screen_idx, resIdx); - if(null==res || 0==res.length) { - return null; - } - if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); - } - rate = getCurrentScreenRate0(screenConfigHandle); - if(0>rate) { - return null; - } - rot = getCurrentScreenRotation0(screenConfigHandle); - if(0>rot) { - return null; - } - } finally { - freeScreenConfiguration0(screenConfigHandle); - } - int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; - int i = 0; - props[i++] = 0; // set later for verification of iterator - props[i++] = res[0]; // width - props[i++] = res[1]; // height - props[i++] = default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rot; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count - return ScreenModeUtil.streamIn(props, 0); + return screenRandR.getCurrentScreenModeImpl(dpy, screen_idx); } } ); } + @Override protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { + if( null == screenRandR ) { return false; } + final List screenModes = this.getScreenModesOrig(); final int screenModeIdx = screenModes.indexOf(screenMode); if(0>screenModeIdx) { @@ -239,33 +130,8 @@ public class ScreenDriver extends ScreenImpl { final long t0 = System.currentTimeMillis(); boolean done = runWithTempDisplayHandle( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { - boolean done = false; - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); - if(0 == screenConfigHandle) { - return Boolean.valueOf(done); - } - try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); - if(0>resIdx || resIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! 0 < "+resIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); - } - - final int f = screenMode.getMonitorMode().getRefreshRate(); - final int r = screenMode.getRotation(); - - if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resIdx, f, r) ) { - while(!done && System.currentTimeMillis()-t0 < SCREEN_MODE_CHANGE_TIMEOUT) { - done = setCurrentScreenModePollEnd0(dpy, screen_idx, resIdx, f, r); - if(!done) { - try { Thread.sleep(10); } catch (InterruptedException e) { } - } - } - } - } finally { - freeScreenConfiguration0(screenConfigHandle); - } - return Boolean.valueOf(done); + final int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); + return Boolean.valueOf( screenRandR.setCurrentScreenModeImpl(dpy, screen_idx, screenMode, screenModeIdx, resIdx) ); } }).booleanValue(); @@ -328,25 +194,6 @@ public class ScreenDriver extends ScreenImpl { private static native int getWidth0(long display, int scrn_idx); private static native int getHeight0(long display, int scrn_idx); - - /** @return int[] { rot1, .. } */ - private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); - - private static native int getNumScreenModeResolutions0(long display, int screen_index); - - /** @return int[] { width, height, widthmm, heightmm } */ - private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); - - private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); - - private static native long getScreenConfiguration0(long display, int screen_index); - private static native void freeScreenConfiguration0(long screenConfiguration); - private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); - private static native int getCurrentScreenRate0(long screenConfiguration); - private static native int getCurrentScreenRotation0(long screenConfiguration); - - /** needs own Display connection for XRANDR event handling */ - private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); - private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); + private static native int[] getRandRVersion0(long display); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java new file mode 100644 index 000000000..abf20ba59 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java @@ -0,0 +1,12 @@ +package jogamp.newt.driver.x11; + +import com.jogamp.newt.ScreenMode; + +public interface ScreenRandR { + + int[] getScreenModeFirstImpl(final long dpy, final int screen_idx); + int[] getScreenModeNextImpl(final long dpy, final int screen_idx); + ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx); + boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx); + +} diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java new file mode 100644 index 000000000..e8a616b99 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java @@ -0,0 +1,214 @@ +package jogamp.newt.driver.x11; + +import jogamp.newt.ScreenImpl; + +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + +public class ScreenRandR11 implements ScreenRandR { + private static final boolean DEBUG = ScreenDriver.DEBUG; + + private int[] nrotations; + private int nrotation_index; + private int nres_number; + private int nres_index; + private int[] nrates; + private int nrate_index; + private int nmode_number; + + @Override + public int[] getScreenModeFirstImpl(final long dpy, final int screen_idx) { + // initialize iterators and static data + nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); + if(null==nrotations || 0==nrotations.length) { + return null; + } + nrotation_index = 0; + + nres_number = getNumScreenModeResolutions0(dpy, screen_idx); + if(0==nres_number) { + return null; + } + nres_index = 0; + + nrates = getScreenModeRates0(dpy, screen_idx, nres_index); + if(null==nrates || 0==nrates.length) { + return null; + } + nrate_index = 0; + + nmode_number = 0; + + return getScreenModeNextImpl(dpy, screen_idx); + } + + @Override + public int[] getScreenModeNextImpl(final long dpy, final int screen_idx) { + /** + System.err.println("******** mode: "+nmode_number); + System.err.println("rot "+nrotation_index); + System.err.println("rate "+nrate_index); + System.err.println("res "+nres_index); */ + + int[] res = getScreenModeResolution0(dpy, screen_idx, nres_index); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); + } + int rate = nrates[nrate_index]; + if(0>=rate) { + rate = ScreenImpl.default_sm_rate; + if(DEBUG) { + System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+ScreenImpl.default_sm_rate); + } + } + int rotation = nrotations[nrotation_index]; + + int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode + props[i++] = 0; // set later for verification of iterator + props[i++] = res[0]; // width + props[i++] = res[1]; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = res[2]; // widthmm + props[i++] = res[3]; // heightmm + props[i++] = rate; // rate + props[i++] = rotation; + props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element + + nmode_number++; + + // iteration: r -> f -> bpp -> [w x h] + nrotation_index++; + if(nrotation_index == nrotations.length) { + nrotation_index=0; + nrate_index++; + if(null == nrates || nrate_index == nrates.length){ + nres_index++; + if(nres_index == nres_number) { + // done + nrates=null; + nrotations=null; + return null; + } + + nrates = getScreenModeRates0(dpy, screen_idx, nres_index); + if(null==nrates || 0==nrates.length) { + return null; + } + nrate_index = 0; + } + } + + return props; + } + + @Override + public ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx) { + long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + if(0 == screenConfigHandle) { + return null; + } + int[] res; + int rate, rot; + try { + int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + if(0==resNumber) { + return null; + } + + int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); + if(0>resIdx) { + return null; + } + if(resIdx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); + } + res = getScreenModeResolution0(dpy, screen_idx, resIdx); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); + } + rate = getCurrentScreenRate0(screenConfigHandle); + if(0>rate) { + return null; + } + rot = getCurrentScreenRotation0(screenConfigHandle); + if(0>rot) { + return null; + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; + int i = 0; + props[i++] = 0; // set later for verification of iterator + props[i++] = res[0]; // width + props[i++] = res[1]; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = res[2]; // widthmm + props[i++] = res[3]; // heightmm + props[i++] = rate; // rate + props[i++] = rot; + props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count + return ScreenModeUtil.streamIn(props, 0); + } + + @Override + public boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx) { + final long t0 = System.currentTimeMillis(); + boolean done = false; + long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + if(0 == screenConfigHandle) { + return Boolean.valueOf(done); + } + try { + int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + if(0>resolutionIdx || resolutionIdx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! 0 < "+resolutionIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); + } + + final int f = screenMode.getMonitorMode().getRefreshRate(); + final int r = screenMode.getRotation(); + + if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resolutionIdx, f, r) ) { + while(!done && System.currentTimeMillis()-t0 < ScreenImpl.SCREEN_MODE_CHANGE_TIMEOUT) { + done = setCurrentScreenModePollEnd0(dpy, screen_idx, resolutionIdx, f, r); + if(!done) { + try { Thread.sleep(10); } catch (InterruptedException e) { } + } + } + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + return done; + } + + /** @return int[] { rot1, .. } */ + private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); + + private static native int getNumScreenModeResolutions0(long display, int screen_index); + + /** @return int[] { width, height, widthmm, heightmm } */ + private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); + + private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); + + private static native long getScreenConfiguration0(long display, int screen_index); + private static native void freeScreenConfiguration0(long screenConfiguration); + + private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); + private static native int getCurrentScreenRate0(long screenConfiguration); + private static native int getCurrentScreenRotation0(long screenConfiguration); + + /** needs own Display connection for XRANDR event handling */ + private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); + private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); + +} diff --git a/src/newt/native/X11Common.h b/src/newt/native/X11Common.h index 4d1a7b59e..7f35216e3 100644 --- a/src/newt/native/X11Common.h +++ b/src/newt/native/X11Common.h @@ -45,8 +45,9 @@ #include -#include "jogamp_newt_driver_x11_ScreenDriver.h" #include "jogamp_newt_driver_x11_DisplayDriver.h" +#include "jogamp_newt_driver_x11_ScreenDriver.h" +#include "jogamp_newt_driver_x11_ScreenRandR11.h" #include "jogamp_newt_driver_x11_WindowDriver.h" #include "Window.h" diff --git a/src/newt/native/X11Screen.c b/src/newt/native/X11Screen.c index e8a3ca656..69a06aad0 100644 --- a/src/newt/native/X11Screen.c +++ b/src/newt/native/X11Screen.c @@ -29,7 +29,7 @@ // #define VERBOSE_ON 1 // #define DBG_PERF 1 -#include "X11Common.h" +#include "X11Screen.h" #ifdef DBG_PERF #include "timespec.h" @@ -76,7 +76,7 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getHeight0 static int showedRandRVersion = 0; -static Bool NewtScreen_getRANDRVersion(Display *dpy, int *major, int *minor) { +Bool NewtScreen_getRANDRVersion(Display *dpy, int *major, int *minor) { if( 0 == XRRQueryVersion(dpy, major, minor) ) { return False; } @@ -87,12 +87,12 @@ static Bool NewtScreen_getRANDRVersion(Display *dpy, int *major, int *minor) { return True; } -static Bool NewtScreen_hasRANDR(Display *dpy) { +Bool NewtScreen_hasRANDR(Display *dpy) { int major, minor; return NewtScreen_getRANDRVersion(dpy, &major, &minor); } -static int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation) { +int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation) { int rot; if(xrotation == RR_Rotate_0) { rot = 0; @@ -113,386 +113,27 @@ static int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation) { /* * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getAvailableScreenModeRotations0 - * Signature: (JI)I + * Method: GetRandRVersion0 + * Signature: (J)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getAvailableScreenModeRotations0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - int num_rotations = 0; - Rotation cur_rotation, rotations_supported; - int rotations[4]; - int major, minor; - - if(False == NewtScreen_getRANDRVersion(dpy, &major, &minor)) { - fprintf(stderr, "RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - rotations_supported = XRRRotations (dpy, (int)scrn_idx, &cur_rotation); - - if(0 != (rotations_supported & RR_Rotate_0)) { - rotations[num_rotations++] = 0; - } - if(0 != (rotations_supported & RR_Rotate_90)) { - rotations[num_rotations++] = 90; - } - if(0 != (rotations_supported & RR_Rotate_180)) { - rotations[num_rotations++] = 180; - } - if(0 != (rotations_supported & RR_Rotate_270)) { - rotations[num_rotations++] = 270; - } - - jintArray properties = NULL; - - if(num_rotations>0) { - properties = (*env)->NewIntArray(env, num_rotations); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rotations); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rotations, rotations); - } - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getNumScreenModeResolution0 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getNumScreenModeResolutions0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getRandRVersion0 + (JNIEnv *env, jclass clazz, jlong display) { - Display *dpy = (Display *) (intptr_t) display; -#ifdef DBG_PERF - struct timespec t0, t1, td; - long td_ms; - timespec_now(&t0); -#endif - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getNumScreenModeResolutions0: RANDR not available\n"); - return 0; - } - -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getNumScreenModeResolution0.1: %ld ms\n", td_ms); fflush(NULL); -#endif - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getNumScreenModeResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL); -#endif - - DBG_PRINT("getNumScreenModeResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes); - - return num_sizes; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenModeResolutions0 - * Signature: (JII)[I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeResolution0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeResolution0: RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - // Fill the properties in temp jint array - int propIndex = 0; - jint prop[4]; - - prop[propIndex++] = xrrs[(int)resMode_idx].width; - prop[propIndex++] = xrrs[(int)resMode_idx].height; - prop[propIndex++] = xrrs[(int)resMode_idx].mwidth; - prop[propIndex++] = xrrs[(int)resMode_idx].mheight; - - jintArray properties = (*env)->NewIntArray(env, 4); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 4); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, 4, prop); - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenModeRates0 - * Signature: (JII)[I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeRates0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeRates0: RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - int num_rates; - short *rates = XRRRates(dpy, (int)scrn_idx, (int)resMode_idx, &num_rates); - - jint prop[num_rates]; - int i; - for(i=0; iNewIntArray(env, num_rates); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rates); + jintArray jversion = (*env)->NewIntArray(env, 2); + if (jversion == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size 2"); } // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rates, prop); - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenConfiguration0 - * Signature: (JI)J - */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenConfiguration0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)screen_idx); -#ifdef DBG_PERF - struct timespec t0, t1, td; - long td_ms; - timespec_now(&t0); -#endif - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getScreenConfiguration0: RANDR not available\n"); - return 0; - } -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getScreenConfiguration0.1: %ld ms\n", td_ms); fflush(NULL); -#endif - - // get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getScreenConfiguration0.2 (XRRGetScreenInfo): %ld ms\n", td_ms); fflush(NULL); -#endif - - return (jlong) (intptr_t) conf; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: freeScreenConfiguration0 - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_freeScreenConfiguration0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRFreeScreenConfigInfo( (XRRScreenConfiguration *) (intptr_t) screenConfiguration ); -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenRate0 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRate0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; + (*env)->SetIntArrayRegion(env, jversion, 0, 2, version); - short original_rate = XRRConfigCurrentRate(conf); - DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); - - return (jint) original_rate; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenRotation0 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRotation0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - Rotation rotation; - - XRRConfigCurrentConfiguration(conf, &rotation); - - return NewtScreen_XRotation2Degree(env, rotation); -} - - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenResolutionIndex0 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenResolutionIndex0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - - short original_rate = XRRConfigCurrentRate(conf); - - Rotation original_rotation; - SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); - - DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); - return (jint)original_size_id; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: setCurrentScreenModeStart0 - * Signature: (JIJIII)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModeStart0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenConfiguration, jint resMode_idx, jint freq, jint rotation) -{ - Display *dpy = (Display *) (intptr_t) display; - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - Window root = RootWindow(dpy, (int)screen_idx); - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - int rot; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - switch(rotation) { - case 0: - rot = RR_Rotate_0; - break; - case 90: - rot = RR_Rotate_90; - break; - case 180: - rot = RR_Rotate_180; - break; - case 270: - rot = RR_Rotate_270; - break; - default: - NewtCommon_throwNewRuntimeException(env, "Invalid rotation: %d", rotation); - } - - DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", - resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); - - XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); - - XSync(dpy, False); - XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); - XSync(dpy, False); - - return JNI_TRUE; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: setCurrentScreenModePollEnd0 - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModePollEnd0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) -{ - Display *dpy = (Display *) (intptr_t) display; - int randr_event_base, randr_error_base; - XEvent evt; - XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModePollEnd0: RANDR not available\n"); - return JNI_FALSE; - } - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); - - int done = 0; - int rot; - do { - if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { - return; - } - XNextEvent(dpy, &evt); - - switch (evt.type - randr_event_base) { - case RRScreenChangeNotify: - if(0 < scn_event->rotation ) { - rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(1) %p (root %p) resIdx %d rot %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, rot, - scn_event->width, scn_event->height); - // done = scn_event->size_index == resMode_idx; // not reliable .. - done = rot == rotation && - scn_event->width == xrrs[resMode_idx].width && - scn_event->height == xrrs[resMode_idx].height; - } else { - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(0) %p (root %p) resIdx %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, - scn_event->width, scn_event->height); - } - break; - default: - DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); - } - XRRUpdateConfiguration(&evt); - } while(!done); - - XSync(dpy, False); - + return jversion; } diff --git a/src/newt/native/X11Screen.h b/src/newt/native/X11Screen.h new file mode 100644 index 000000000..a5b8e3e70 --- /dev/null +++ b/src/newt/native/X11Screen.h @@ -0,0 +1,39 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#ifndef _X11SCREEN_H +#define _X11SCREEN_H + + +#include "X11Common.h" + +Bool NewtScreen_getRANDRVersion(Display *dpy, int *major, int *minor); +Bool NewtScreen_hasRANDR(Display *dpy); +int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation); + +#endif /* _X11SCREEN_H */ diff --git a/src/newt/native/X11ScreenRandR11.c b/src/newt/native/X11ScreenRandR11.c index bc7d91d20..a457fd47b 100644 --- a/src/newt/native/X11ScreenRandR11.c +++ b/src/newt/native/X11ScreenRandR11.c @@ -26,9 +26,14 @@ * or implied, of JogAmp Community. */ -#include "X11Common.h" +#include "X11Screen.h" -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getAvailableScreenModeRotations0_RandR11 +/* + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getAvailableScreenModeRotations0 + * Signature: (JI)I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getAvailableScreenModeRotations0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -73,30 +78,59 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getAvailabl return properties; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getNumScreenModeResolutions0_RandR11 +/* + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getNumScreenModeResolution0 + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getNumScreenModeResolutions0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); +#ifdef DBG_PERF + struct timespec t0, t1, td; + long td_ms; + timespec_now(&t0); +#endif + if(False == NewtScreen_hasRANDR(dpy)) { + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getNumScreenModeResolutions0: RANDR not available\n"); + return 0; + } + +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getNumScreenModeResolution0.1: %ld ms\n", td_ms); fflush(NULL); +#endif + int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - DBG_PRINT("getNumScreenModeResolutions0: %d\n", num_sizes); +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getNumScreenModeResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL); +#endif + + DBG_PRINT("getNumScreenModeResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes); return num_sizes; } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenModeResolutions0_RandR11 + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getScreenModeResolutions0 * Signature: (JII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeResolution0_RandR11 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeResolution0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) { Display *dpy = (Display *) (intptr_t) display; + if(False == NewtScreen_hasRANDR(dpy)) { + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeResolution0: RANDR not available\n"); + return (*env)->NewIntArray(env, 0); + } + int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions @@ -125,15 +159,20 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenMo } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenModeRates0_RandR11 + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getScreenModeRates0 * Signature: (JII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeRates0_RandR11 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeRates0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) { Display *dpy = (Display *) (intptr_t) display; + if(False == NewtScreen_hasRANDR(dpy)) { + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeRates0: RANDR not available\n"); + return (*env)->NewIntArray(env, 0); + } + int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions @@ -163,100 +202,139 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenMo } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenRate0_RandR11 - * Signature: (JI)I + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getScreenConfiguration0 + * Signature: (JI)J */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRate0_RandR11 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenConfiguration0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) { Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - + Window root = RootWindow(dpy, (int)screen_idx); +#ifdef DBG_PERF + struct timespec t0, t1, td; + long td_ms; + timespec_now(&t0); +#endif + + if(False == NewtScreen_hasRANDR(dpy)) { + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenConfiguration0: RANDR not available\n"); + return 0; + } +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getScreenConfiguration0.1: %ld ms\n", td_ms); fflush(NULL); +#endif + // get current resolutions and frequencies XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - short original_rate = XRRConfigCurrentRate(conf); +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getScreenConfiguration0.2 (XRRGetScreenInfo): %ld ms\n", td_ms); fflush(NULL); +#endif - //free - XRRFreeScreenConfigInfo(conf); + return (jlong) (intptr_t) conf; +} + +/* + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: freeScreenConfiguration0 + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_freeScreenConfiguration0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) +{ + XRRFreeScreenConfigInfo( (XRRScreenConfiguration *) (intptr_t) screenConfiguration ); +} + +/* + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getCurrentScreenRate0 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getCurrentScreenRate0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) +{ + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; + short original_rate = XRRConfigCurrentRate(conf); DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); return (jint) original_rate; } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenRotation0_RandR11 - * Signature: (JI)I + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getCurrentScreenRotation0 + * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRotation0_RandR11 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getCurrentScreenRotation0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) { - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - //get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; Rotation rotation; + XRRConfigCurrentConfiguration(conf, &rotation); - //free - XRRFreeScreenConfigInfo(conf); - return NewtScreen_XRotation2Degree(env, rotation); } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenResolutionIndex0_RandR11 - * Signature: (JI)I + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getCurrentScreenResolutionIndex0 + * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenResolutionIndex0_RandR11 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getCurrentScreenResolutionIndex0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) { - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - // get current resolutions and frequency configuration - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); short original_rate = XRRConfigCurrentRate(conf); Rotation original_rotation; SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); - //free - XRRFreeScreenConfigInfo(conf); - DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); - return (jint)original_size_id; + return (jint)original_size_id; } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: setCurrentScreenModeStart0_RandR11 - * Signature: (JIIII)Z + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: setCurrentScreenModeStart0 + * Signature: (JIJIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModeStart0_RandR11 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_setCurrentScreenModeStart0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenConfiguration, jint resMode_idx, jint freq, jint rotation) { Display *dpy = (Display *) (intptr_t) display; + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; Window root = RootWindow(dpy, (int)screen_idx); int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; int rot; if( 0 > resMode_idx || resMode_idx >= num_sizes ) { NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); } - conf = XRRGetScreenInfo(dpy, root); - - rot = int NewtScreen_Degree2XRotation(env, rotation); + switch(rotation) { + case 0: + rot = RR_Rotate_0; + break; + case 90: + rot = RR_Rotate_90; + break; + case 180: + rot = RR_Rotate_180; + break; + case 270: + rot = RR_Rotate_270; + break; + default: + NewtCommon_throwNewRuntimeException(env, "Invalid rotation: %d", rotation); + } DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); @@ -267,19 +345,15 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentSc XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); XSync(dpy, False); - //free - XRRFreeScreenConfigInfo(conf); - XSync(dpy, False); - return JNI_TRUE; } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: setCurrentScreenModePollEnd0_RandR11 + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: setCurrentScreenModePollEnd0 * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModePollEnd0_RandR11 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_setCurrentScreenModePollEnd0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) { Display *dpy = (Display *) (intptr_t) display; @@ -287,6 +361,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentSc XEvent evt; XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; + if(False == NewtScreen_hasRANDR(dpy)) { + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_setCurrentScreenModePollEnd0: RANDR not available\n"); + return JNI_FALSE; + } + int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions XRRScreenConfiguration *conf; @@ -307,15 +386,22 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentSc switch (evt.type - randr_event_base) { case RRScreenChangeNotify: - rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call %p (root %p) resIdx %d rot %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, rot, - scn_event->width, scn_event->height); - // done = scn_event->size_index == resMode_idx; // not reliable .. - done = rot == rotation && - scn_event->width == xrrs[resMode_idx].width && - scn_event->height == xrrs[resMode_idx].height; + if(0 < scn_event->rotation ) { + rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(1) %p (root %p) resIdx %d rot %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, rot, + scn_event->width, scn_event->height); + // done = scn_event->size_index == resMode_idx; // not reliable .. + done = rot == rotation && + scn_event->width == xrrs[resMode_idx].width && + scn_event->height == xrrs[resMode_idx].height; + } else { + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(0) %p (root %p) resIdx %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, + scn_event->width, scn_event->height); + } break; default: DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); -- cgit v1.2.3 From 03a3f209aff955410e0f3133e73078529c23d3e1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 19 Apr 2013 02:46:48 +0200 Subject: Bug 721: NEWT/X11 RandR 1.3 Support - Part 2 - Rename impl class/files, start RandR13 coding. --- make/build-newt.xml | 5 +- make/scripts/tests.sh | 6 +- src/newt/classes/jogamp/newt/driver/x11/RandR.java | 39 ++ .../classes/jogamp/newt/driver/x11/RandR11.java | 241 ++++++++++++ .../classes/jogamp/newt/driver/x11/RandR13.java | 51 +++ .../jogamp/newt/driver/x11/ScreenDriver.java | 26 +- .../jogamp/newt/driver/x11/ScreenRandR.java | 12 - .../jogamp/newt/driver/x11/ScreenRandR11.java | 214 ----------- src/newt/native/X11Common.h | 3 +- src/newt/native/X11RandR11.c | 386 +++++++++++++++++++ src/newt/native/X11RandR13.c | 408 ++++++++++++++++++++ src/newt/native/X11Screen.c | 21 +- src/newt/native/X11Screen.h | 2 - src/newt/native/X11ScreenRandR11.c | 415 --------------------- src/newt/native/X11ScreenRandR13.c | 372 ------------------ 15 files changed, 1148 insertions(+), 1053 deletions(-) create mode 100644 src/newt/classes/jogamp/newt/driver/x11/RandR.java create mode 100644 src/newt/classes/jogamp/newt/driver/x11/RandR11.java create mode 100644 src/newt/classes/jogamp/newt/driver/x11/RandR13.java delete mode 100644 src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java delete mode 100644 src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java create mode 100644 src/newt/native/X11RandR11.c create mode 100644 src/newt/native/X11RandR13.c delete mode 100644 src/newt/native/X11ScreenRandR11.c delete mode 100644 src/newt/native/X11ScreenRandR13.c (limited to 'src/newt/classes') diff --git a/make/build-newt.xml b/make/build-newt.xml index d728b42c7..862b78422 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -592,7 +592,7 @@ - + @@ -701,7 +701,8 @@ - + + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 62478cdb3..75e5f7fd6 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -340,7 +340,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryES2OffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* @@ -363,7 +363,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBi #testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch10NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch12AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* +##testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT @@ -379,7 +379,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBi #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR.java b/src/newt/classes/jogamp/newt/driver/x11/RandR.java new file mode 100644 index 000000000..485d976ec --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR.java @@ -0,0 +1,39 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.driver.x11; + +import com.jogamp.newt.ScreenMode; + +public interface RandR { + + int[] getScreenModeFirstImpl(final long dpy, final int screen_idx); + int[] getScreenModeNextImpl(final long dpy, final int screen_idx); + ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx); + boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx); + +} diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java new file mode 100644 index 000000000..ee67bd304 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java @@ -0,0 +1,241 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.driver.x11; + +import jogamp.newt.ScreenImpl; + +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + +public class RandR11 implements RandR { + private static final boolean DEBUG = ScreenDriver.DEBUG; + + private int[] nrotations; + private int nrotation_index; + private int nres_number; + private int nres_index; + private int[] nrates; + private int nrate_index; + private int nmode_number; + + @Override + public int[] getScreenModeFirstImpl(final long dpy, final int screen_idx) { + // initialize iterators and static data + nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); + if(null==nrotations || 0==nrotations.length) { + return null; + } + nrotation_index = 0; + + nres_number = getNumScreenModeResolutions0(dpy, screen_idx); + if(0==nres_number) { + return null; + } + nres_index = 0; + + nrates = getScreenModeRates0(dpy, screen_idx, nres_index); + if(null==nrates || 0==nrates.length) { + return null; + } + nrate_index = 0; + + nmode_number = 0; + + return getScreenModeNextImpl(dpy, screen_idx); + } + + @Override + public int[] getScreenModeNextImpl(final long dpy, final int screen_idx) { + /** + System.err.println("******** mode: "+nmode_number); + System.err.println("rot "+nrotation_index); + System.err.println("rate "+nrate_index); + System.err.println("res "+nres_index); */ + + int[] res = getScreenModeResolution0(dpy, screen_idx, nres_index); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); + } + int rate = nrates[nrate_index]; + if(0>=rate) { + rate = ScreenImpl.default_sm_rate; + if(DEBUG) { + System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+ScreenImpl.default_sm_rate); + } + } + int rotation = nrotations[nrotation_index]; + + int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode + props[i++] = 0; // set later for verification of iterator + props[i++] = res[0]; // width + props[i++] = res[1]; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = res[2]; // widthmm + props[i++] = res[3]; // heightmm + props[i++] = rate; // rate + props[i++] = rotation; + props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element + + nmode_number++; + + // iteration: r -> f -> bpp -> [w x h] + nrotation_index++; + if(nrotation_index == nrotations.length) { + nrotation_index=0; + nrate_index++; + if(null == nrates || nrate_index == nrates.length){ + nres_index++; + if(nres_index == nres_number) { + // done + nrates=null; + nrotations=null; + return null; + } + + nrates = getScreenModeRates0(dpy, screen_idx, nres_index); + if(null==nrates || 0==nrates.length) { + return null; + } + nrate_index = 0; + } + } + + return props; + } + + @Override + public ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx) { + long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + if(0 == screenConfigHandle) { + return null; + } + int[] res; + int rate, rot; + try { + int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + if(0==resNumber) { + return null; + } + + int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); + if(0>resIdx) { + return null; + } + if(resIdx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); + } + res = getScreenModeResolution0(dpy, screen_idx, resIdx); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); + } + rate = getCurrentScreenRate0(screenConfigHandle); + if(0>rate) { + return null; + } + rot = getCurrentScreenRotation0(screenConfigHandle); + if(0>rot) { + return null; + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; + int i = 0; + props[i++] = 0; // set later for verification of iterator + props[i++] = res[0]; // width + props[i++] = res[1]; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = res[2]; // widthmm + props[i++] = res[3]; // heightmm + props[i++] = rate; // rate + props[i++] = rot; + props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count + return ScreenModeUtil.streamIn(props, 0); + } + + @Override + public boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx) { + final long t0 = System.currentTimeMillis(); + boolean done = false; + long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + if(0 == screenConfigHandle) { + return Boolean.valueOf(done); + } + try { + int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + if(0>resolutionIdx || resolutionIdx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! 0 < "+resolutionIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); + } + + final int f = screenMode.getMonitorMode().getRefreshRate(); + final int r = screenMode.getRotation(); + + if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resolutionIdx, f, r) ) { + while(!done && System.currentTimeMillis()-t0 < ScreenImpl.SCREEN_MODE_CHANGE_TIMEOUT) { + done = setCurrentScreenModePollEnd0(dpy, screen_idx, resolutionIdx, f, r); + if(!done) { + try { Thread.sleep(10); } catch (InterruptedException e) { } + } + } + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + return done; + } + + /** @return int[] { rot1, .. } */ + private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); + + private static native int getNumScreenModeResolutions0(long display, int screen_index); + + /** @return int[] { width, height, widthmm, heightmm } */ + private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); + + private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); + + private static native long getScreenConfiguration0(long display, int screen_index); + private static native void freeScreenConfiguration0(long screenConfiguration); + + private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); + private static native int getCurrentScreenRate0(long screenConfiguration); + private static native int getCurrentScreenRotation0(long screenConfiguration); + + /** needs own Display connection for XRANDR event handling */ + private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); + private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); + +} diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java new file mode 100644 index 000000000..24c9806af --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java @@ -0,0 +1,51 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.driver.x11; + +import com.jogamp.newt.ScreenMode; + +public class RandR13 implements RandR { + + public int[] getScreenModeFirstImpl(final long dpy, final int screen_idx) { + return null; + } + public int[] getScreenModeNextImpl(final long dpy, final int screen_idx) { + return null; + } + public ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx) { + return null; + } + + public boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx) { + return false; + } + + private static native long getScreenResources0(long display, int screen_index); + private static native void freeScreenResources0(long screenConfiguration); + +} diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index d94f27371..cd8da9b60 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -73,11 +73,13 @@ public class ScreenDriver extends ScreenImpl { int v[] = getRandRVersion0(dpy); randrVersion = new VersionNumber(v[0], v[1], 0); } - System.err.println("RandR "+randrVersion); + if( DEBUG ) { + System.err.println("RandR "+randrVersion); + } if( !randrVersion.isZero() ) { - screenRandR = new ScreenRandR11(); + rAndR = new RandR11(); } else { - screenRandR = null; + rAndR = null; } } @@ -85,42 +87,42 @@ public class ScreenDriver extends ScreenImpl { } private VersionNumber randrVersion; - private ScreenRandR screenRandR; + private RandR rAndR; @Override protected int[] getScreenModeFirstImpl() { - if( null == screenRandR ) { return null; } + if( null == rAndR ) { return null; } return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public int[] run(long dpy) { - return screenRandR.getScreenModeFirstImpl(dpy, screen_idx); + return rAndR.getScreenModeFirstImpl(dpy, screen_idx); } } ); } @Override protected int[] getScreenModeNextImpl() { - if( null == screenRandR ) { return null; } + if( null == rAndR ) { return null; } // assemble: w x h x bpp x f x r return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public int[] run(long dpy) { - return screenRandR.getScreenModeNextImpl(dpy, screen_idx); + return rAndR.getScreenModeNextImpl(dpy, screen_idx); } } ); } @Override protected ScreenMode getCurrentScreenModeImpl() { - if( null == screenRandR ) { return null; } + if( null == rAndR ) { return null; } return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public ScreenMode run(long dpy) { - return screenRandR.getCurrentScreenModeImpl(dpy, screen_idx); + return rAndR.getCurrentScreenModeImpl(dpy, screen_idx); } } ); } @Override protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { - if( null == screenRandR ) { return false; } + if( null == rAndR ) { return false; } final List screenModes = this.getScreenModesOrig(); final int screenModeIdx = screenModes.indexOf(screenMode); @@ -131,7 +133,7 @@ public class ScreenDriver extends ScreenImpl { boolean done = runWithTempDisplayHandle( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { final int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); - return Boolean.valueOf( screenRandR.setCurrentScreenModeImpl(dpy, screen_idx, screenMode, screenModeIdx, resIdx) ); + return Boolean.valueOf( rAndR.setCurrentScreenModeImpl(dpy, screen_idx, screenMode, screenModeIdx, resIdx) ); } }).booleanValue(); diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java deleted file mode 100644 index abf20ba59..000000000 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java +++ /dev/null @@ -1,12 +0,0 @@ -package jogamp.newt.driver.x11; - -import com.jogamp.newt.ScreenMode; - -public interface ScreenRandR { - - int[] getScreenModeFirstImpl(final long dpy, final int screen_idx); - int[] getScreenModeNextImpl(final long dpy, final int screen_idx); - ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx); - boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx); - -} diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java deleted file mode 100644 index e8a616b99..000000000 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java +++ /dev/null @@ -1,214 +0,0 @@ -package jogamp.newt.driver.x11; - -import jogamp.newt.ScreenImpl; - -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; - -public class ScreenRandR11 implements ScreenRandR { - private static final boolean DEBUG = ScreenDriver.DEBUG; - - private int[] nrotations; - private int nrotation_index; - private int nres_number; - private int nres_index; - private int[] nrates; - private int nrate_index; - private int nmode_number; - - @Override - public int[] getScreenModeFirstImpl(final long dpy, final int screen_idx) { - // initialize iterators and static data - nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); - if(null==nrotations || 0==nrotations.length) { - return null; - } - nrotation_index = 0; - - nres_number = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==nres_number) { - return null; - } - nres_index = 0; - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - - nmode_number = 0; - - return getScreenModeNextImpl(dpy, screen_idx); - } - - @Override - public int[] getScreenModeNextImpl(final long dpy, final int screen_idx) { - /** - System.err.println("******** mode: "+nmode_number); - System.err.println("rot "+nrotation_index); - System.err.println("rate "+nrate_index); - System.err.println("res "+nres_index); */ - - int[] res = getScreenModeResolution0(dpy, screen_idx, nres_index); - if(null==res || 0==res.length) { - return null; - } - if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); - } - int rate = nrates[nrate_index]; - if(0>=rate) { - rate = ScreenImpl.default_sm_rate; - if(DEBUG) { - System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+ScreenImpl.default_sm_rate); - } - } - int rotation = nrotations[nrotation_index]; - - int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; - int i = 0; - props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode - props[i++] = 0; // set later for verification of iterator - props[i++] = res[0]; // width - props[i++] = res[1]; // height - props[i++] = ScreenImpl.default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rotation; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element - - nmode_number++; - - // iteration: r -> f -> bpp -> [w x h] - nrotation_index++; - if(nrotation_index == nrotations.length) { - nrotation_index=0; - nrate_index++; - if(null == nrates || nrate_index == nrates.length){ - nres_index++; - if(nres_index == nres_number) { - // done - nrates=null; - nrotations=null; - return null; - } - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - } - } - - return props; - } - - @Override - public ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx) { - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); - if(0 == screenConfigHandle) { - return null; - } - int[] res; - int rate, rot; - try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==resNumber) { - return null; - } - - int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); - if(0>resIdx) { - return null; - } - if(resIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); - } - res = getScreenModeResolution0(dpy, screen_idx, resIdx); - if(null==res || 0==res.length) { - return null; - } - if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); - } - rate = getCurrentScreenRate0(screenConfigHandle); - if(0>rate) { - return null; - } - rot = getCurrentScreenRotation0(screenConfigHandle); - if(0>rot) { - return null; - } - } finally { - freeScreenConfiguration0(screenConfigHandle); - } - int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; - int i = 0; - props[i++] = 0; // set later for verification of iterator - props[i++] = res[0]; // width - props[i++] = res[1]; // height - props[i++] = ScreenImpl.default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rot; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count - return ScreenModeUtil.streamIn(props, 0); - } - - @Override - public boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx) { - final long t0 = System.currentTimeMillis(); - boolean done = false; - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); - if(0 == screenConfigHandle) { - return Boolean.valueOf(done); - } - try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - if(0>resolutionIdx || resolutionIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! 0 < "+resolutionIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); - } - - final int f = screenMode.getMonitorMode().getRefreshRate(); - final int r = screenMode.getRotation(); - - if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resolutionIdx, f, r) ) { - while(!done && System.currentTimeMillis()-t0 < ScreenImpl.SCREEN_MODE_CHANGE_TIMEOUT) { - done = setCurrentScreenModePollEnd0(dpy, screen_idx, resolutionIdx, f, r); - if(!done) { - try { Thread.sleep(10); } catch (InterruptedException e) { } - } - } - } - } finally { - freeScreenConfiguration0(screenConfigHandle); - } - return done; - } - - /** @return int[] { rot1, .. } */ - private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); - - private static native int getNumScreenModeResolutions0(long display, int screen_index); - - /** @return int[] { width, height, widthmm, heightmm } */ - private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); - - private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); - - private static native long getScreenConfiguration0(long display, int screen_index); - private static native void freeScreenConfiguration0(long screenConfiguration); - - private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); - private static native int getCurrentScreenRate0(long screenConfiguration); - private static native int getCurrentScreenRotation0(long screenConfiguration); - - /** needs own Display connection for XRANDR event handling */ - private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); - private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); - -} diff --git a/src/newt/native/X11Common.h b/src/newt/native/X11Common.h index 7f35216e3..e58cdb755 100644 --- a/src/newt/native/X11Common.h +++ b/src/newt/native/X11Common.h @@ -47,7 +47,8 @@ #include "jogamp_newt_driver_x11_DisplayDriver.h" #include "jogamp_newt_driver_x11_ScreenDriver.h" -#include "jogamp_newt_driver_x11_ScreenRandR11.h" +#include "jogamp_newt_driver_x11_RandR11.h" +#include "jogamp_newt_driver_x11_RandR13.h" #include "jogamp_newt_driver_x11_WindowDriver.h" #include "Window.h" diff --git a/src/newt/native/X11RandR11.c b/src/newt/native/X11RandR11.c new file mode 100644 index 000000000..cbf911a38 --- /dev/null +++ b/src/newt/native/X11RandR11.c @@ -0,0 +1,386 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#include "X11Screen.h" + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getAvailableScreenModeRotations0 + * Signature: (JI)I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getAvailableScreenModeRotations0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + int num_rotations = 0; + Rotation cur_rotation, rotations_supported; + int rotations[4]; + int major, minor; + + rotations_supported = XRRRotations (dpy, (int)scrn_idx, &cur_rotation); + + if(0 != (rotations_supported & RR_Rotate_0)) { + rotations[num_rotations++] = 0; + } + if(0 != (rotations_supported & RR_Rotate_90)) { + rotations[num_rotations++] = 90; + } + if(0 != (rotations_supported & RR_Rotate_180)) { + rotations[num_rotations++] = 180; + } + if(0 != (rotations_supported & RR_Rotate_270)) { + rotations[num_rotations++] = 270; + } + + jintArray properties = NULL; + + if(num_rotations>0) { + properties = (*env)->NewIntArray(env, num_rotations); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rotations); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, properties, 0, num_rotations, rotations); + } + + return properties; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getNumScreenModeResolution0 + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getNumScreenModeResolutions0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; +#ifdef DBG_PERF + struct timespec t0, t1, td; + long td_ms; + timespec_now(&t0); +#endif + +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getNumScreenModeResolution0.1: %ld ms\n", td_ms); fflush(NULL); +#endif + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getNumScreenModeResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL); +#endif + + DBG_PRINT("getNumScreenModeResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes); + + return num_sizes; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getScreenModeResolutions0 + * Signature: (JII)[I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenModeResolution0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + // Fill the properties in temp jint array + int propIndex = 0; + jint prop[4]; + + prop[propIndex++] = xrrs[(int)resMode_idx].width; + prop[propIndex++] = xrrs[(int)resMode_idx].height; + prop[propIndex++] = xrrs[(int)resMode_idx].mwidth; + prop[propIndex++] = xrrs[(int)resMode_idx].mheight; + + jintArray properties = (*env)->NewIntArray(env, 4); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 4); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, properties, 0, 4, prop); + + return properties; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getScreenModeRates0 + * Signature: (JII)[I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenModeRates0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + int num_rates; + short *rates = XRRRates(dpy, (int)scrn_idx, (int)resMode_idx, &num_rates); + + jint prop[num_rates]; + int i; + for(i=0; iNewIntArray(env, num_rates); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rates); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, properties, 0, num_rates, prop); + + return properties; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getScreenConfiguration0 + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenConfiguration0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)screen_idx); +#ifdef DBG_PERF + struct timespec t0, t1, td; + long td_ms; + timespec_now(&t0); +#endif + +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getScreenConfiguration0.1: %ld ms\n", td_ms); fflush(NULL); +#endif + + // get current resolutions and frequencies + XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getScreenConfiguration0.2 (XRRGetScreenInfo): %ld ms\n", td_ms); fflush(NULL); +#endif + + return (jlong) (intptr_t) conf; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: freeScreenConfiguration0 + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR11_freeScreenConfiguration0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) +{ + XRRFreeScreenConfigInfo( (XRRScreenConfiguration *) (intptr_t) screenConfiguration ); +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getCurrentScreenRate0 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getCurrentScreenRate0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) +{ + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; + + short original_rate = XRRConfigCurrentRate(conf); + DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); + + return (jint) original_rate; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getCurrentScreenRotation0 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getCurrentScreenRotation0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) +{ + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; + Rotation rotation; + + XRRConfigCurrentConfiguration(conf, &rotation); + + return NewtScreen_XRotation2Degree(env, rotation); +} + + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getCurrentScreenResolutionIndex0 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getCurrentScreenResolutionIndex0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) +{ + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; + + short original_rate = XRRConfigCurrentRate(conf); + + Rotation original_rotation; + SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); + + DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); + return (jint)original_size_id; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: setCurrentScreenModeStart0 + * Signature: (JIJIII)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR11_setCurrentScreenModeStart0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenConfiguration, jint resMode_idx, jint freq, jint rotation) +{ + Display *dpy = (Display *) (intptr_t) display; + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; + Window root = RootWindow(dpy, (int)screen_idx); + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions + int rot; + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + switch(rotation) { + case 0: + rot = RR_Rotate_0; + break; + case 90: + rot = RR_Rotate_90; + break; + case 180: + rot = RR_Rotate_180; + break; + case 270: + rot = RR_Rotate_270; + break; + default: + NewtCommon_throwNewRuntimeException(env, "Invalid rotation: %d", rotation); + } + + DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", + resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); + + XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); + + XSync(dpy, False); + XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); + XSync(dpy, False); + + return JNI_TRUE; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: setCurrentScreenModePollEnd0 + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR11_setCurrentScreenModePollEnd0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +{ + Display *dpy = (Display *) (intptr_t) display; + int randr_event_base, randr_error_base; + XEvent evt; + XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions + XRRScreenConfiguration *conf; + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); + + int done = 0; + int rot; + do { + if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { + return; + } + XNextEvent(dpy, &evt); + + switch (evt.type - randr_event_base) { + case RRScreenChangeNotify: + if(0 < scn_event->rotation ) { + rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(1) %p (root %p) resIdx %d rot %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, rot, + scn_event->width, scn_event->height); + // done = scn_event->size_index == resMode_idx; // not reliable .. + done = rot == rotation && + scn_event->width == xrrs[resMode_idx].width && + scn_event->height == xrrs[resMode_idx].height; + } else { + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(0) %p (root %p) resIdx %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, + scn_event->width, scn_event->height); + } + break; + default: + DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); + } + XRRUpdateConfiguration(&evt); + } while(!done); + + XSync(dpy, False); + +} + diff --git a/src/newt/native/X11RandR13.c b/src/newt/native/X11RandR13.c new file mode 100644 index 000000000..ea72cd35d --- /dev/null +++ b/src/newt/native/X11RandR13.c @@ -0,0 +1,408 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#include "X11Common.h" + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getScreenResources0 + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenResources0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)screen_idx); +#ifdef DBG_PERF + struct timespec t0, t1, td; + long td_ms; + timespec_now(&t0); +#endif + +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getScreenResources0.1: %ld ms\n", td_ms); fflush(NULL); +#endif + + XRRScreenResources *res = XRRGetScreenResourcesCurrent( dpy, root); +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getScreenResources0.2 (XRRScreenResources): %ld ms\n", td_ms); fflush(NULL); +#endif + + return (jlong) (intptr_t) res; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: freeScreenResources0 + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_freeScreenResources0 + (JNIEnv *env, jclass clazz, jlong screenResources) +{ + XRRFreeScreenResources( (XRRScreenResources *) (intptr_t) screenResources ); +} + +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getOrigin0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display * dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + int pos[] = { 0, 0 } ; + + int i; + XRRScreenResources *xrrScreenResources = XRRGetScreenResources(dpy, root); + fprintf(stderr, "XRRScreenResources %p: RRCrtc crtcs %d\n", xrrScreenResources, xrrScreenResources->ncrtc); + for(i=0; incrtc; i++) { + RRCrtc crtc = xrrScreenResources->crtcs[i]; + XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, xrrScreenResources, crtc); + fprintf(stderr, "RRCrtc %d: %d/%d %dx%d\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height); + XRRFreeCrtcInfo(xrrCrtcInfo); + } + + jintArray jpos = (*env)->NewIntArray(env, num_rotations); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 2); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, jpos, 0, 2, pos); + return jpos; +} + +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getAvailableScreenModeRotations0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + int num_rotations = 0; + Rotation cur_rotation, rotations_supported; + int rotations[4]; + int major, minor; + + rotations_supported = XRRRotations (dpy, (int)scrn_idx, &cur_rotation); + + if(0 != (rotations_supported & RR_Rotate_0)) { + rotations[num_rotations++] = 0; + } + if(0 != (rotations_supported & RR_Rotate_90)) { + rotations[num_rotations++] = 90; + } + if(0 != (rotations_supported & RR_Rotate_180)) { + rotations[num_rotations++] = 180; + } + if(0 != (rotations_supported & RR_Rotate_270)) { + rotations[num_rotations++] = 270; + } + + jintArray properties = NULL; + + if(num_rotations>0) { + properties = (*env)->NewIntArray(env, num_rotations); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rotations); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, properties, 0, num_rotations, rotations); + } + + return properties; +} + +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getNumScreenModeResolutions0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + + DBG_PRINT("getNumScreenModeResolutions0: %d\n", num_sizes); + + int i; + XRRScreenResources *xrrScreenResources = XRRGetScreenResources(dpy, root); + fprintf(stderr, "XRRScreenResources %p: RRCrtc crtcs %d\n", xrrScreenResources, xrrScreenResources->ncrtc); + for(i=0; incrtc; i++) { + RRCrtc crtc = xrrScreenResources->crtcs[i]; + XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, xrrScreenResources, crtc); + fprintf(stderr, "RRCrtc %d: %d/%d %dx%d\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height); + XRRFreeCrtcInfo(xrrCrtcInfo); + } + fprintf(stderr, "XRRScreenResources %p: XRRModeInfo modes %d\n", xrrScreenResources, xrrScreenResources->nmode); + for(i=0; inmode; i++) { + XRRModeInfo xrrModeInfo = xrrScreenResources->modes[i]; + fprintf(stderr, "XRRModeInfo %d: %dx%d, %s, %X\n", i, xrrModeInfo.width, xrrModeInfo.height, xrrModeInfo.name, xrrModeInfo.id); + } + XRRFreeScreenResources(xrrScreenResources); + + return num_sizes; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getScreenModeResolutions0 + * Signature: (JII)[I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenModeResolution0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + // Fill the properties in temp jint array + int propIndex = 0; + jint prop[4]; + + prop[propIndex++] = xrrs[(int)resMode_idx].width; + prop[propIndex++] = xrrs[(int)resMode_idx].height; + prop[propIndex++] = xrrs[(int)resMode_idx].mwidth; + prop[propIndex++] = xrrs[(int)resMode_idx].mheight; + + jintArray properties = (*env)->NewIntArray(env, 4); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 4); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, properties, 0, 4, prop); + + return properties; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getScreenModeRates0 + * Signature: (JII)[I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenModeRates0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + int num_rates; + short *rates = XRRRates(dpy, (int)scrn_idx, (int)resMode_idx, &num_rates); + + jint prop[num_rates]; + int i; + for(i=0; iNewIntArray(env, num_rates); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rates); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, properties, 0, num_rates, prop); + + return properties; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getCurrentScreenRate0 + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getCurrentScreenRate0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + + // get current resolutions and frequencies + XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); + short original_rate = XRRConfigCurrentRate(conf); + + //free + XRRFreeScreenConfigInfo(conf); + + DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); + + return (jint) original_rate; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getCurrentScreenRotation0 + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getCurrentScreenRotation0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + + //get current resolutions and frequencies + XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); + + Rotation rotation; + XRRConfigCurrentConfiguration(conf, &rotation); + + //free + XRRFreeScreenConfigInfo(conf); + + return NewtScreen_XRotation2Degree(env, rotation); +} + + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getCurrentScreenResolutionIndex0 + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getCurrentScreenResolutionIndex0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + + // get current resolutions and frequency configuration + XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); + short original_rate = XRRConfigCurrentRate(conf); + + Rotation original_rotation; + SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); + + //free + XRRFreeScreenConfigInfo(conf); + + DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); + return (jint)original_size_id; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: setCurrentScreenModeStart0 + * Signature: (JIIII)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setCurrentScreenModeStart0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)screen_idx); + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions + XRRScreenConfiguration *conf; + int rot; + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + conf = XRRGetScreenInfo(dpy, root); + + rot = int NewtScreen_Degree2XRotation(env, rotation); + + DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", + resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); + + XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); + + XSync(dpy, False); + XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); + XSync(dpy, False); + + //free + XRRFreeScreenConfigInfo(conf); + XSync(dpy, False); + + return JNI_TRUE; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: setCurrentScreenModePollEnd0 + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setCurrentScreenModePollEnd0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +{ + Display *dpy = (Display *) (intptr_t) display; + int randr_event_base, randr_error_base; + XEvent evt; + XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions + XRRScreenConfiguration *conf; + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); + + int done = 0; + int rot; + do { + if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { + return; + } + XNextEvent(dpy, &evt); + + switch (evt.type - randr_event_base) { + case RRScreenChangeNotify: + rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call %p (root %p) resIdx %d rot %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, rot, + scn_event->width, scn_event->height); + // done = scn_event->size_index == resMode_idx; // not reliable .. + done = rot == rotation && + scn_event->width == xrrs[resMode_idx].width && + scn_event->height == xrrs[resMode_idx].height; + break; + default: + DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); + } + XRRUpdateConfiguration(&evt); + } while(!done); + + XSync(dpy, False); + +} + diff --git a/src/newt/native/X11Screen.c b/src/newt/native/X11Screen.c index 69a06aad0..3d4b2a26c 100644 --- a/src/newt/native/X11Screen.c +++ b/src/newt/native/X11Screen.c @@ -74,24 +74,6 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getHeight0 return (jint) DisplayHeight( dpy, scrn_idx); } -static int showedRandRVersion = 0; - -Bool NewtScreen_getRANDRVersion(Display *dpy, int *major, int *minor) { - if( 0 == XRRQueryVersion(dpy, major, minor) ) { - return False; - } - if(0 == showedRandRVersion) { - DBG_PRINT("X11 RandR Version %d.%d\n", *major, *minor); - showedRandRVersion = 1; - } - return True; -} - -Bool NewtScreen_hasRANDR(Display *dpy) { - int major, minor; - return NewtScreen_getRANDRVersion(dpy, &major, &minor); -} - int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation) { int rot; if(xrotation == RR_Rotate_0) { @@ -121,8 +103,7 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getRandRVer { Display * dpy = (Display *)(intptr_t)display; jint version[2]; - Bool res = NewtScreen_getRANDRVersion(dpy, &version[0], &version[1]); - if( False == res ) { + if( 0 == XRRQueryVersion(dpy, &version[0], &version[1] ) ) { version[0] = 0; version[1] = 0; } diff --git a/src/newt/native/X11Screen.h b/src/newt/native/X11Screen.h index a5b8e3e70..1a1440054 100644 --- a/src/newt/native/X11Screen.h +++ b/src/newt/native/X11Screen.h @@ -32,8 +32,6 @@ #include "X11Common.h" -Bool NewtScreen_getRANDRVersion(Display *dpy, int *major, int *minor); -Bool NewtScreen_hasRANDR(Display *dpy); int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation); #endif /* _X11SCREEN_H */ diff --git a/src/newt/native/X11ScreenRandR11.c b/src/newt/native/X11ScreenRandR11.c deleted file mode 100644 index a457fd47b..000000000 --- a/src/newt/native/X11ScreenRandR11.c +++ /dev/null @@ -1,415 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -#include "X11Screen.h" - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getAvailableScreenModeRotations0 - * Signature: (JI)I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getAvailableScreenModeRotations0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - int num_rotations = 0; - Rotation cur_rotation, rotations_supported; - int rotations[4]; - int major, minor; - - if(False == NewtScreen_getRANDRVersion(dpy, &major, &minor)) { - fprintf(stderr, "RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - rotations_supported = XRRRotations (dpy, (int)scrn_idx, &cur_rotation); - - if(0 != (rotations_supported & RR_Rotate_0)) { - rotations[num_rotations++] = 0; - } - if(0 != (rotations_supported & RR_Rotate_90)) { - rotations[num_rotations++] = 90; - } - if(0 != (rotations_supported & RR_Rotate_180)) { - rotations[num_rotations++] = 180; - } - if(0 != (rotations_supported & RR_Rotate_270)) { - rotations[num_rotations++] = 270; - } - - jintArray properties = NULL; - - if(num_rotations>0) { - properties = (*env)->NewIntArray(env, num_rotations); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rotations); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rotations, rotations); - } - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getNumScreenModeResolution0 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getNumScreenModeResolutions0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; -#ifdef DBG_PERF - struct timespec t0, t1, td; - long td_ms; - timespec_now(&t0); -#endif - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getNumScreenModeResolutions0: RANDR not available\n"); - return 0; - } - -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getNumScreenModeResolution0.1: %ld ms\n", td_ms); fflush(NULL); -#endif - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getNumScreenModeResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL); -#endif - - DBG_PRINT("getNumScreenModeResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes); - - return num_sizes; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getScreenModeResolutions0 - * Signature: (JII)[I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeResolution0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeResolution0: RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - // Fill the properties in temp jint array - int propIndex = 0; - jint prop[4]; - - prop[propIndex++] = xrrs[(int)resMode_idx].width; - prop[propIndex++] = xrrs[(int)resMode_idx].height; - prop[propIndex++] = xrrs[(int)resMode_idx].mwidth; - prop[propIndex++] = xrrs[(int)resMode_idx].mheight; - - jintArray properties = (*env)->NewIntArray(env, 4); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 4); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, 4, prop); - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getScreenModeRates0 - * Signature: (JII)[I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeRates0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeRates0: RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - int num_rates; - short *rates = XRRRates(dpy, (int)scrn_idx, (int)resMode_idx, &num_rates); - - jint prop[num_rates]; - int i; - for(i=0; iNewIntArray(env, num_rates); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rates); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rates, prop); - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getScreenConfiguration0 - * Signature: (JI)J - */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenConfiguration0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)screen_idx); -#ifdef DBG_PERF - struct timespec t0, t1, td; - long td_ms; - timespec_now(&t0); -#endif - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenConfiguration0: RANDR not available\n"); - return 0; - } -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getScreenConfiguration0.1: %ld ms\n", td_ms); fflush(NULL); -#endif - - // get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getScreenConfiguration0.2 (XRRGetScreenInfo): %ld ms\n", td_ms); fflush(NULL); -#endif - - return (jlong) (intptr_t) conf; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: freeScreenConfiguration0 - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_freeScreenConfiguration0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRFreeScreenConfigInfo( (XRRScreenConfiguration *) (intptr_t) screenConfiguration ); -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getCurrentScreenRate0 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getCurrentScreenRate0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - - short original_rate = XRRConfigCurrentRate(conf); - DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); - - return (jint) original_rate; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getCurrentScreenRotation0 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getCurrentScreenRotation0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - Rotation rotation; - - XRRConfigCurrentConfiguration(conf, &rotation); - - return NewtScreen_XRotation2Degree(env, rotation); -} - - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getCurrentScreenResolutionIndex0 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getCurrentScreenResolutionIndex0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - - short original_rate = XRRConfigCurrentRate(conf); - - Rotation original_rotation; - SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); - - DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); - return (jint)original_size_id; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: setCurrentScreenModeStart0 - * Signature: (JIJIII)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_setCurrentScreenModeStart0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenConfiguration, jint resMode_idx, jint freq, jint rotation) -{ - Display *dpy = (Display *) (intptr_t) display; - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - Window root = RootWindow(dpy, (int)screen_idx); - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - int rot; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - switch(rotation) { - case 0: - rot = RR_Rotate_0; - break; - case 90: - rot = RR_Rotate_90; - break; - case 180: - rot = RR_Rotate_180; - break; - case 270: - rot = RR_Rotate_270; - break; - default: - NewtCommon_throwNewRuntimeException(env, "Invalid rotation: %d", rotation); - } - - DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", - resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); - - XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); - - XSync(dpy, False); - XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); - XSync(dpy, False); - - return JNI_TRUE; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: setCurrentScreenModePollEnd0 - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_setCurrentScreenModePollEnd0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) -{ - Display *dpy = (Display *) (intptr_t) display; - int randr_event_base, randr_error_base; - XEvent evt; - XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_setCurrentScreenModePollEnd0: RANDR not available\n"); - return JNI_FALSE; - } - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); - - int done = 0; - int rot; - do { - if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { - return; - } - XNextEvent(dpy, &evt); - - switch (evt.type - randr_event_base) { - case RRScreenChangeNotify: - if(0 < scn_event->rotation ) { - rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(1) %p (root %p) resIdx %d rot %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, rot, - scn_event->width, scn_event->height); - // done = scn_event->size_index == resMode_idx; // not reliable .. - done = rot == rotation && - scn_event->width == xrrs[resMode_idx].width && - scn_event->height == xrrs[resMode_idx].height; - } else { - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(0) %p (root %p) resIdx %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, - scn_event->width, scn_event->height); - } - break; - default: - DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); - } - XRRUpdateConfiguration(&evt); - } while(!done); - - XSync(dpy, False); - -} - diff --git a/src/newt/native/X11ScreenRandR13.c b/src/newt/native/X11ScreenRandR13.c deleted file mode 100644 index da90d15c9..000000000 --- a/src/newt/native/X11ScreenRandR13.c +++ /dev/null @@ -1,372 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -#include "X11Common.h" - -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getOrigin0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display * dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - int pos[] = { 0, 0 } ; - - int i; - XRRScreenResources *xrrScreenResources = XRRGetScreenResources(dpy, root); - fprintf(stderr, "XRRScreenResources %p: RRCrtc crtcs %d\n", xrrScreenResources, xrrScreenResources->ncrtc); - for(i=0; incrtc; i++) { - RRCrtc crtc = xrrScreenResources->crtcs[i]; - XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, xrrScreenResources, crtc); - fprintf(stderr, "RRCrtc %d: %d/%d %dx%d\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height); - XRRFreeCrtcInfo(xrrCrtcInfo); - } - - jintArray jpos = (*env)->NewIntArray(env, num_rotations); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 2); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, jpos, 0, 2, pos); - return jpos; -} - -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getAvailableScreenModeRotations0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - int num_rotations = 0; - Rotation cur_rotation, rotations_supported; - int rotations[4]; - int major, minor; - - if(False == NewtScreen_getRANDRVersion(dpy, &major, &minor)) { - fprintf(stderr, "RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - rotations_supported = XRRRotations (dpy, (int)scrn_idx, &cur_rotation); - - if(0 != (rotations_supported & RR_Rotate_0)) { - rotations[num_rotations++] = 0; - } - if(0 != (rotations_supported & RR_Rotate_90)) { - rotations[num_rotations++] = 90; - } - if(0 != (rotations_supported & RR_Rotate_180)) { - rotations[num_rotations++] = 180; - } - if(0 != (rotations_supported & RR_Rotate_270)) { - rotations[num_rotations++] = 270; - } - - jintArray properties = NULL; - - if(num_rotations>0) { - properties = (*env)->NewIntArray(env, num_rotations); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rotations); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rotations, rotations); - } - - return properties; -} - -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getNumScreenModeResolutions0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - DBG_PRINT("getNumScreenModeResolutions0: %d\n", num_sizes); - - int i; - XRRScreenResources *xrrScreenResources = XRRGetScreenResources(dpy, root); - fprintf(stderr, "XRRScreenResources %p: RRCrtc crtcs %d\n", xrrScreenResources, xrrScreenResources->ncrtc); - for(i=0; incrtc; i++) { - RRCrtc crtc = xrrScreenResources->crtcs[i]; - XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, xrrScreenResources, crtc); - fprintf(stderr, "RRCrtc %d: %d/%d %dx%d\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height); - XRRFreeCrtcInfo(xrrCrtcInfo); - } - fprintf(stderr, "XRRScreenResources %p: XRRModeInfo modes %d\n", xrrScreenResources, xrrScreenResources->nmode); - for(i=0; inmode; i++) { - XRRModeInfo xrrModeInfo = xrrScreenResources->modes[i]; - fprintf(stderr, "XRRModeInfo %d: %dx%d, %s, %X\n", i, xrrModeInfo.width, xrrModeInfo.height, xrrModeInfo.name, xrrModeInfo.id); - } - XRRFreeScreenResources(xrrScreenResources); - - return num_sizes; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenModeResolutions0_RandR13 - * Signature: (JII)[I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeResolution0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - // Fill the properties in temp jint array - int propIndex = 0; - jint prop[4]; - - prop[propIndex++] = xrrs[(int)resMode_idx].width; - prop[propIndex++] = xrrs[(int)resMode_idx].height; - prop[propIndex++] = xrrs[(int)resMode_idx].mwidth; - prop[propIndex++] = xrrs[(int)resMode_idx].mheight; - - jintArray properties = (*env)->NewIntArray(env, 4); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 4); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, 4, prop); - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenModeRates0_RandR13 - * Signature: (JII)[I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeRates0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - int num_rates; - short *rates = XRRRates(dpy, (int)scrn_idx, (int)resMode_idx, &num_rates); - - jint prop[num_rates]; - int i; - for(i=0; iNewIntArray(env, num_rates); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rates); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rates, prop); - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenRate0_RandR13 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRate0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - // get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - short original_rate = XRRConfigCurrentRate(conf); - - //free - XRRFreeScreenConfigInfo(conf); - - DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); - - return (jint) original_rate; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenRotation0_RandR13 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRotation0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - //get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - - Rotation rotation; - XRRConfigCurrentConfiguration(conf, &rotation); - - //free - XRRFreeScreenConfigInfo(conf); - - return NewtScreen_XRotation2Degree(env, rotation); -} - - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenResolutionIndex0_RandR13 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenResolutionIndex0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - // get current resolutions and frequency configuration - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - short original_rate = XRRConfigCurrentRate(conf); - - Rotation original_rotation; - SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); - - //free - XRRFreeScreenConfigInfo(conf); - - DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); - return (jint)original_size_id; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: setCurrentScreenModeStart0_RandR13 - * Signature: (JIIII)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModeStart0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)screen_idx); - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - int rot; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - conf = XRRGetScreenInfo(dpy, root); - - rot = int NewtScreen_Degree2XRotation(env, rotation); - - DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", - resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); - - XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); - - XSync(dpy, False); - XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); - XSync(dpy, False); - - //free - XRRFreeScreenConfigInfo(conf); - XSync(dpy, False); - - return JNI_TRUE; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: setCurrentScreenModePollEnd0_RandR13 - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModePollEnd0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) -{ - Display *dpy = (Display *) (intptr_t) display; - int randr_event_base, randr_error_base; - XEvent evt; - XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); - - int done = 0; - int rot; - do { - if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { - return; - } - XNextEvent(dpy, &evt); - - switch (evt.type - randr_event_base) { - case RRScreenChangeNotify: - rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call %p (root %p) resIdx %d rot %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, rot, - scn_event->width, scn_event->height); - // done = scn_event->size_index == resMode_idx; // not reliable .. - done = rot == rotation && - scn_event->width == xrrs[resMode_idx].width && - scn_event->height == xrrs[resMode_idx].height; - break; - default: - DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); - } - XRRUpdateConfiguration(&evt); - } while(!done); - - XSync(dpy, False); - -} - -- cgit v1.2.3 From 6ebf649d1b87944257fe492e0aef842d1b8debc2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 6 May 2013 17:27:09 +0200 Subject: Fix Bug 600 and Bug 721: Adding support for multiple monitors w/ NEWT - Support for all monitor devices and their available modes - X11: Use RandR 1.3 if available - Retrieve information - Changing a monitor device's mode - Support for dedicated and spannig fullscreen - See - TODO: - X11 RandR does _not_ relayout the virtual screen size and neither the CRT's viewport. We may need to relayout them if they were covering a seamless region to achieve same experience! - OSX: No machine to attach a secondary CRT -> TEST! - Tested Manually for Regressions - Linux ARMv6hf (Rasp-Pi/BCM, Panda/X11) - Android (Huawei, Kindle) - Tested Manually and junit: - X11/Linux - NV, ATI-Catalyst w/ 2 CRTs - VBox w/ 4 CRTs - Win/Windows - NV, w/ 2 CRTs - VBox w/ 4 CRTs - X11/OpenIndiana, NV, 1 CRT --- make/build-newt.xml | 1 + make/scripts/java-win64-dbg.bat | 1 + make/scripts/tests-x64.bat | 13 +- make/scripts/tests.sh | 18 +- .../javax/media/nativewindow/util/Dimension.java | 5 + .../javax/media/nativewindow/util/Insets.java | 8 + .../javax/media/nativewindow/util/Point.java | 4 + .../javax/media/nativewindow/util/Rectangle.java | 86 ++- .../nativewindow/util/RectangleImmutable.java | 20 + .../javax/media/nativewindow/util/SurfaceSize.java | 4 +- .../classes/com/jogamp/newt/MonitorDevice.java | 235 ++++++++ src/newt/classes/com/jogamp/newt/MonitorMode.java | 346 ++++++++++++ src/newt/classes/com/jogamp/newt/Screen.java | 93 ++-- src/newt/classes/com/jogamp/newt/ScreenMode.java | 208 ------- src/newt/classes/com/jogamp/newt/Window.java | 38 +- .../com/jogamp/newt/event/MonitorEvent.java | 71 +++ .../com/jogamp/newt/event/MonitorModeListener.java | 37 ++ .../classes/com/jogamp/newt/event/NEWTEvent.java | 7 +- .../classes/com/jogamp/newt/event/OutputEvent.java | 51 ++ .../com/jogamp/newt/event/ScreenModeListener.java | 39 -- .../classes/com/jogamp/newt/opengl/GLWindow.java | 13 + .../classes/com/jogamp/newt/util/MonitorMode.java | 102 ---- .../com/jogamp/newt/util/MonitorModeUtil.java | 247 +++++++++ .../com/jogamp/newt/util/ScreenModeUtil.java | 341 ------------ .../classes/jogamp/newt/MonitorDeviceImpl.java | 147 +++++ src/newt/classes/jogamp/newt/MonitorModeProps.java | 355 ++++++++++++ src/newt/classes/jogamp/newt/OffscreenWindow.java | 13 +- src/newt/classes/jogamp/newt/ScreenImpl.java | 569 ++++++++++---------- src/newt/classes/jogamp/newt/ScreenModeStatus.java | 231 -------- .../classes/jogamp/newt/ScreenMonitorState.java | 195 +++++++ src/newt/classes/jogamp/newt/WindowImpl.java | 201 +++++-- .../jogamp/newt/driver/android/ScreenDriver.java | 99 +++- .../jogamp/newt/driver/android/WindowDriver.java | 16 +- .../jogamp/newt/driver/awt/ScreenDriver.java | 24 +- .../jogamp/newt/driver/bcm/egl/ScreenDriver.java | 56 +- .../jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java | 56 +- .../jogamp/newt/driver/intel/gdl/ScreenDriver.java | 56 +- .../jogamp/newt/driver/kd/ScreenDriver.java | 54 +- .../jogamp/newt/driver/macosx/ScreenDriver.java | 129 ++--- .../jogamp/newt/driver/macosx/WindowDriver.java | 15 +- .../jogamp/newt/driver/windows/ScreenDriver.java | 146 +++-- src/newt/classes/jogamp/newt/driver/x11/RandR.java | 47 +- .../classes/jogamp/newt/driver/x11/RandR11.java | 320 +++++++---- .../classes/jogamp/newt/driver/x11/RandR13.java | 276 +++++++++- .../jogamp/newt/driver/x11/ScreenDriver.java | 146 +++-- src/newt/native/MacWindow.m | 235 ++++---- src/newt/native/NewtMacWindow.h | 1 - src/newt/native/NewtMacWindow.m | 4 +- src/newt/native/ScreenMode.h | 15 +- src/newt/native/Window.h | 17 +- src/newt/native/WindowsWindow.c | 305 ++++++++--- src/newt/native/X11RandR11.c | 44 +- src/newt/native/X11RandR13.c | 597 ++++++++++++--------- src/newt/native/X11Screen.c | 31 +- src/newt/native/X11Screen.h | 1 + src/newt/native/X11Window.c | 18 +- .../opengl/test/android/NEWTElektronActivity.java | 16 +- .../opengl/test/android/NEWTGearsES1Activity.java | 16 +- .../opengl/test/android/NEWTGearsES2Activity.java | 16 +- .../test/android/NEWTGearsES2ActivityLauncher.java | 1 + .../test/android/NEWTGearsES2TransActivity.java | 16 +- .../opengl/test/android/NEWTGraphUI1pActivity.java | 16 +- .../opengl/test/android/NEWTGraphUI2pActivity.java | 16 +- .../test/android/NEWTRedSquareES1Activity.java | 16 +- .../test/android/NEWTRedSquareES2Activity.java | 16 +- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 16 +- .../test/junit/jogl/glsl/TestRulerNEWT01.java | 16 +- .../test/junit/newt/ManualScreenMode03NEWT.java | 32 +- .../test/junit/newt/TestScreenMode00NEWT.java | 119 ++-- .../test/junit/newt/TestScreenMode00bNEWT.java | 24 +- .../test/junit/newt/TestScreenMode01NEWT.java | 133 ++--- .../test/junit/newt/TestScreenMode01aNEWT.java | 212 ++++++++ .../test/junit/newt/TestScreenMode01bNEWT.java | 210 +++++--- .../test/junit/newt/TestScreenMode01cNEWT.java | 249 +++++++++ .../test/junit/newt/TestScreenMode02NEWT.java | 75 +-- 75 files changed, 5159 insertions(+), 2463 deletions(-) create mode 100644 src/newt/classes/com/jogamp/newt/MonitorDevice.java create mode 100644 src/newt/classes/com/jogamp/newt/MonitorMode.java delete mode 100644 src/newt/classes/com/jogamp/newt/ScreenMode.java create mode 100644 src/newt/classes/com/jogamp/newt/event/MonitorEvent.java create mode 100644 src/newt/classes/com/jogamp/newt/event/MonitorModeListener.java create mode 100644 src/newt/classes/com/jogamp/newt/event/OutputEvent.java delete mode 100644 src/newt/classes/com/jogamp/newt/event/ScreenModeListener.java delete mode 100644 src/newt/classes/com/jogamp/newt/util/MonitorMode.java create mode 100644 src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java delete mode 100644 src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java create mode 100644 src/newt/classes/jogamp/newt/MonitorDeviceImpl.java create mode 100644 src/newt/classes/jogamp/newt/MonitorModeProps.java delete mode 100644 src/newt/classes/jogamp/newt/ScreenModeStatus.java create mode 100644 src/newt/classes/jogamp/newt/ScreenMonitorState.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01cNEWT.java (limited to 'src/newt/classes') diff --git a/make/build-newt.xml b/make/build-newt.xml index 862b78422..30c2ddfd1 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -593,6 +593,7 @@ + diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 8669ba8f8..136fe4667 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -52,6 +52,7 @@ REM set D_ARGS="-Dnativewindow.debug.TraceLock" REM set D_ARGS="-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Djogl.debug.GLContext" REM set D_ARGS="-Dnewt.debug.Screen" "-Dnewt.debug.EDT" "-Dnativewindow.debug=all" +REM set D_ARGS="-Dnewt.debug.Screen" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 0133859fd..27ecfb2cc 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -55,7 +55,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsReali REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -106,10 +106,13 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus01Swin REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b53c2f760..c6f69ab74 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -135,6 +135,8 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" + #D_ARGS="-Dnewt.debug.Screen" + #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" @@ -284,7 +286,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* @@ -384,10 +386,12 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT -#testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT $* +#testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* # # awt (testawt) @@ -509,7 +513,9 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # # Texture / TextureUtils # -#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture02AWT $* + #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareNewtAWT $* diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index 0a5a94565..4fae98f08 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -57,7 +57,9 @@ public class Dimension implements Cloneable, DimensionImmutable { } } + @Override public int getWidth() { return width; } + @Override public int getHeight() { return height; } public void setWidth(int width) { @@ -77,10 +79,12 @@ public class Dimension implements Cloneable, DimensionImmutable { return this; } + @Override public String toString() { return new String(width+" x "+height); } + @Override public boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof Dimension) { @@ -91,6 +95,7 @@ public class Dimension implements Cloneable, DimensionImmutable { return false; } + @Override public int hashCode() { // 31 * x == (x << 5) - x int hash = 31 + width; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java index 199ec27cb..f22668f55 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java @@ -57,11 +57,17 @@ public class Insets implements Cloneable, InsetsImmutable { } } + @Override public final int getLeftWidth() { return l; } + @Override public final int getRightWidth() { return r; } + @Override public final int getTotalWidth() { return l + r; } + @Override public final int getTopHeight() { return t; } + @Override public final int getBottomHeight() { return b; } + @Override public final int getTotalHeight() { return t + b; } public void setLeftWidth(int left) { l = left; } @@ -69,6 +75,7 @@ public class Insets implements Cloneable, InsetsImmutable { public void setTopHeight(int top) { t = top; } public void setBottomHeight(int bottom) { b = bottom; } + @Override public boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof Insets) { @@ -79,6 +86,7 @@ public class Insets implements Cloneable, InsetsImmutable { return false; } + @Override public int hashCode() { int sum1 = l + b; int sum2 = t + r; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index c53b16928..8e6caf72b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -54,6 +54,7 @@ public class Point implements Cloneable, PointImmutable { } } + @Override public boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof Point) { @@ -63,14 +64,17 @@ public class Point implements Cloneable, PointImmutable { return false; } + @Override public final int getX() { return x; } + @Override public final int getY() { return y; } + @Override public int hashCode() { // 31 * x == (x << 5) - x int hash = 31 + x; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index 8d6bfe48f..8e6fc8e36 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -28,6 +28,8 @@ package javax.media.nativewindow.util; +import java.util.List; + public class Rectangle implements Cloneable, RectangleImmutable { int x; int y; @@ -57,15 +59,90 @@ public class Rectangle implements Cloneable, RectangleImmutable { } } + @Override public final int getX() { return x; } + @Override public final int getY() { return y; } + @Override public final int getWidth() { return width; } + @Override public final int getHeight() { return height; } - public void setX(int x) { this.x = x; } - public void setY(int y) { this.y = y; } - public void setWidth(int width) { this.width = width; } - public void setHeight(int height) { this.height = height; } + + public final void setX(int x) { this.x = x; } + public final void setY(int y) { this.y = y; } + public final void setWidth(int width) { this.width = width; } + public final void setHeight(int height) { this.height = height; } + @Override + public final RectangleImmutable union(final RectangleImmutable r) { + return union(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight()); + } + @Override + public final RectangleImmutable union(final int rx1, final int ry1, final int rx2, final int ry2) { + final int x1 = Math.min(x, rx1); + final int y1 = Math.min(y, ry1); + final int x2 = Math.max(x + width, rx2); + final int y2 = Math.max(y + height, ry2); + return new Rectangle(x1, y1, x2 - x1, y2 - y1); + } + /** + * Calculates the union of the given rectangles, stores it in this instance and returns this instance. + * @param rectangles given list of rectangles + * @return this instance holding the union of given rectangles. + */ + public final Rectangle union(final List rectangles) { + int x1=Integer.MAX_VALUE, y1=Integer.MAX_VALUE; + int x2=Integer.MIN_VALUE, y2=Integer.MIN_VALUE; + for(int i=rectangles.size()-1; i>=0; i--) { + final RectangleImmutable vp = rectangles.get(i); + x1 = Math.min(x1, vp.getX()); + x2 = Math.max(x2, vp.getX() + vp.getWidth()); + y1 = Math.min(y1, vp.getY()); + y2 = Math.max(y2, vp.getY() + vp.getHeight()); + } + setX(x1); + setY(y1); + setWidth(x2 - x1); + setHeight(y2 - y1); + return this; + } + + @Override + public final RectangleImmutable intersection(RectangleImmutable r) { + return intersection(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight()); + } + @Override + public final RectangleImmutable intersection(final int rx1, final int ry1, final int rx2, final int ry2) { + final int x1 = Math.max(x, rx1); + final int y1 = Math.max(y, ry1); + final int x2 = Math.min(x + width, rx2); + final int y2 = Math.min(y + height, ry2); + final int ix, iy, iwidth, iheight; + if( x2 < x1 ) { + ix = 0; + iwidth = 0; + } else { + ix = x1; + iwidth = x2 - x1; + } + if( y2 < y1 ) { + iy = 0; + iheight = 0; + } else { + iy = y1; + iheight = y2 - y1; + } + return new Rectangle (ix, iy, iwidth, iheight); + } + @Override + public final float coverage(RectangleImmutable r) { + final RectangleImmutable isect = intersection(r); + final float sqI = (float) ( isect.getWidth()*isect.getHeight() ); + final float sqT = (float) ( width*height ); + return sqI / sqT; + } + + @Override public boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof Rectangle) { @@ -76,6 +153,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { return false; } + @Override public int hashCode() { int sum1 = x + height; int sum2 = width + y; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java index d3b43c864..7531989de 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java @@ -41,6 +41,26 @@ public interface RectangleImmutable extends WriteCloneable { int getY(); + /** Returns the union of this rectangle and the given rectangle. */ + RectangleImmutable union(final RectangleImmutable r); + /** Returns the union of this rectangleand the given coordinates. */ + RectangleImmutable union(final int rx1, final int ry1, final int rx2, final int ry2); + /** Returns the intersection of this rectangleand the given rectangle. */ + RectangleImmutable intersection(RectangleImmutable r); + /** Returns the intersection of this rectangleand the given coordinates. */ + RectangleImmutable intersection(final int rx1, final int ry1, final int rx2, final int ry2); + /** + * Returns the coverage of given rectangle w/ this this one, i.e. between 0.0 and 1.0. + *

    + * Coverage is computed by: + *

    +     *    isect = this.intersection(r);
    +     *    coverage = area( isect ) / area( this ) ;
    +     * 
    + *

    + */ + float coverage(RectangleImmutable r); + /** * Checks whether two rect objects are equal. Two instances * of Rectangle are equal if the four integer values diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java index 8f21bc49b..d7e451af8 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java @@ -36,8 +36,8 @@ package javax.media.nativewindow.util; * */ public class SurfaceSize { - DimensionImmutable resolution; - int bitsPerPixel; + final DimensionImmutable resolution; + final int bitsPerPixel; public SurfaceSize(DimensionImmutable resolution, int bitsPerPixel) { if(null==resolution || bitsPerPixel<=0) { diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java new file mode 100644 index 000000000..fbe4d8cf0 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -0,0 +1,235 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.newt; + +import java.util.List; + +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.RectangleImmutable; + +import com.jogamp.common.util.ArrayHashSet; + +/** + * Visual output device, i.e. a CRT, LED ..consisting of it's components:
    + * + *
  • Immutable + *
      + *
    • nativeId
    • + *
    • {@link DimensionImmutable} size in [mm]
    • + *
    • {@link MonitorMode} original mode
    • + *
    • List<MonitorMode> supportedModes
    • + *
  • + *
  • Mutable + *
      + *
    • {@link MonitorMode} current mode
    • + *
    • {@link RectangleImmutable} viewport (rotated)
    • + *
  • + * + */ +public abstract class MonitorDevice { + protected final Screen screen; // backref + protected final int nativeId; // unique monitor device ID + protected final DimensionImmutable sizeMM; // in [mm] + protected final MonitorMode originalMode; + protected final ArrayHashSet supportedModes; // FIXME: May need to support mutable mode, i.e. adding modes on the fly! + protected MonitorMode currentMode; + protected boolean modeChanged; + protected Rectangle viewport; + + protected MonitorDevice(Screen screen, int nativeId, DimensionImmutable sizeMM, Rectangle viewport, MonitorMode currentMode, ArrayHashSet supportedModes) { + this.screen = screen; + this.nativeId = nativeId; + this.sizeMM = sizeMM; + this.originalMode = currentMode; + this.supportedModes = supportedModes; + this.currentMode = currentMode; + this.viewport = viewport; + this.modeChanged = false; + } + + /** Returns the {@link Screen} owning this monitor. */ + public final Screen getScreen() { + return screen; + } + + /** + * Tests equality of two MonitorDevice objects + * by evaluating equality of it's components:
    + *
      + *
    • nativeID
    • + *
    + *
    + */ + public final boolean equals(Object obj) { + if (this == obj) { return true; } + if (obj instanceof MonitorDevice) { + MonitorDevice md = (MonitorDevice)obj; + return md.nativeId == nativeId; + } + return false; + } + + /** + * Returns a combined hash code of it's elements:
    + *
      + *
    • nativeID
    • + *
    + */ + public final int hashCode() { + return nativeId; + } + + /** @return the immutable unique native Id of this monitor device. */ + public final int getId() { return nativeId; } + + /** + * @return the immutable monitor size in millimeters. + */ + public final DimensionImmutable getSizeMM() { + return sizeMM; + } + + /** + * Return the immutable original {@link com.jogamp.newt.MonitorMode}, as used at NEWT initialization. + * @return original {@link MonitorMode} which is element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + */ + public final MonitorMode getOriginalMode() { + return originalMode; + } + + /** + * FIXME: May need to support mutable mode, i.e. adding modes on the fly! + * @return the immutable list of {@link MonitorMode}s supported by this monitor. Use w/ care, it's not a copy! + */ + public final List getSupportedModes() { + return supportedModes.getData(); + } + + /** @return the {@link RectangleImmutable rectangular} portion of the rotated virtual {@link Screen} size represented by this monitor. */ + public final RectangleImmutable getViewport() { + return viewport; + } + + /** Returns true if given coordinates are contained by this {@link #getViewport() viewport}, otherwise false. */ + public final boolean contains(int x, int y) { + return x >= viewport.getX() && + x < viewport.getX() + viewport.getWidth() && + y >= viewport.getY() && + y < viewport.getY() + viewport.getHeight() ; + } + + /** + * Returns the coverage of given rectangle w/ this this {@link #getViewport() viewport}, i.e. between 0.0 and 1.0. + *

    + * Coverage is computed by: + *

    +     *    isect = viewport.intersection(r);
    +     *    coverage = area( isect ) / area( viewport ) ;
    +     * 
    + *

    + */ + public final float coverage(RectangleImmutable r) { + return viewport.coverage(r); + } + + /** + * Returns the union of the given monitor's {@link #getViewport() viewport}. + * @param result storage for result, will be returned + * @param monitors given list of monitors + * @return viewport representing the union of given monitor's viewport. + */ + public static Rectangle unionOfViewports(final Rectangle result, final List monitors) { + int x1=Integer.MAX_VALUE, y1=Integer.MAX_VALUE; + int x2=Integer.MIN_VALUE, y2=Integer.MIN_VALUE; + for(int i=monitors.size()-1; i>=0; i--) { + final RectangleImmutable vp = monitors.get(i).getViewport(); + x1 = Math.min(x1, vp.getX()); + x2 = Math.max(x2, vp.getX() + vp.getWidth()); + y1 = Math.min(y1, vp.getY()); + y2 = Math.max(y2, vp.getY() + vp.getHeight()); + } + result.setX(x1); + result.setY(y1); + result.setWidth(x2 - x1); + result.setHeight(y2 - y1); + return result; + } + + public final boolean isOriginalMode() { + return currentMode.hashCode() == originalMode.hashCode(); + } + + /** + * Returns true if the {@link MonitorMode} + * has been changed programmatic via this API only, otherwise false. + *

    + * Note: We cannot guarantee that we won't interfere w/ another running + * application's screen mode change or vice versa. + *

    + */ + public final boolean isModeChangedByUs() { + return modeChanged && !isOriginalMode(); + } + + /** + * Return the current cached {@link MonitorMode} w/o native query. + *

    + * If {@link MonitorMode}s are not supported for this + * native type {@link com.jogamp.newt.Display#getType()}, it returns one with the current screen size.

    + * + * @return current {@link MonitorMode} which is element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + */ + public final MonitorMode getCurrentMode() { + return currentMode; + } + + /** + * Return the current {@link MonitorMode} including a native query. + *

    + * If {@link MonitorMode}s are not supported for this + * native type {@link com.jogamp.newt.Display#getType()}, it returns one with the current screen size.

    + * + * @return current {@link MonitorMode} which is element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + */ + public abstract MonitorMode queryCurrentMode(); + + /** + * Set the current {@link com.jogamp.newt.MonitorMode}. + * @param mode to be made current, must be element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + * @return true if successful, otherwise false + */ + public abstract boolean setCurrentMode(MonitorMode mode); + + public String toString() { + return "Monitor[Id "+Display.toHexString(nativeId)+", "+sizeMM+" mm, viewport "+viewport+ ", orig "+originalMode+", curr "+currentMode+ + ", modeChanged "+modeChanged+", modeCount "+supportedModes.size()+"]"; + } +} + diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java new file mode 100644 index 000000000..e5b329d47 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java @@ -0,0 +1,346 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.newt; + +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.SurfaceSize; + + +/** Immutable MonitorMode Class, consisting of it's read only components:
    + *
      + *
    • nativeId
    • + *
    • {@link SizeAndRRate}, non rotated surfaceSize and refreshRate
    • + *
    • rotation, measured counter clockwise (CCW)
    • + *
    + * + * Aquire and filter MonitorMode
    + *
      + *
    • A List of read only MonitorModes is being returned by {@link com.jogamp.newt.Screen#getMonitorModes()}.
    • + *
    • You may utilize {@link com.jogamp.newt.util.MonitorModeUtil} to filter and select a desired ScreenMode.
    • + *
    • The current ScreenMode can be obtained via {@link com.jogamp.newt.Screen#getCurrentScreenMode()}.
    • + *
    • The initial original ScreenMode (at startup) can be obtained via {@link com.jogamp.newt.Screen#getOriginalScreenMode()}.
    • + *
    + *
    + * + * Changing ScreenModes
    + * FIXME!!!!! + *
      + *
    • Use {@link com.jogamp.newt.Screen#setCurrentScreenMode(com.jogamp.newt.MonitorMode)}
    • + * to change the current ScreenMode of all Screen's referenced via the full qualified name (FQN) + * {@link com.jogamp.newt.Screen#getFQName()}. + *
    • When the last FQN referenced Screen closes, the original ScreenMode ({@link com.jogamp.newt.Screen#getOriginalScreenMode()}) + * is restored.
    • + *
    + *
    + * Example for changing the ScreenMode: + *
    +        // determine target refresh rate
    +        ScreenMode orig = screen.getOriginalScreenMode();
    +        int freq = orig.getOutputMode().getRefreshRate();
    +
    +        // target resolution
    +        Dimension res = new Dimension(800, 600);
    +
    +        // target rotation
    +        int rot = 0;
    +
    +        // filter available ScreenModes
    +        List screenModes = screen.getScreenModes();
    +        screenModes = ScreenModeUtil.filterByRate(screenModes, freq); // get the nearest ones
    +        screenModes = ScreenModeUtil.filterByRotation(screenModes, rot);
    +        screenModes = ScreenModeUtil.filterByResolution(screenModes, res); // get the nearest ones
    +        screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
    +
    +        // pick 1st one ..
    +        screen.setCurrentScreenMode((ScreenMode) screenModes.get(0)); 
    + * 
    + * + * X11 / AMD just works
    + *
    + * X11 / NVidia difficulties + *
    +    NVidia RANDR RefreshRate Bug
    +        If NVidia's 'DynamicTwinView' is enabled, all refresh rates are
    +        unique, ie consequent numbers starting with the default refresh, ie 50, 51, ..
    +        The only way to workaround it is to disable 'DynamicTwinView'.
    +        Read: http://us.download.nvidia.com/XFree86/Linux-x86/260.19.12/README/configtwinview.html
    +
    +        Check to see if 'DynamicTwinView' is enable:
    +            nvidia-settings -q :0/DynamicTwinview
    +
    +        To disable it (workaround), add the following option to your xorg.conf device section:
    +            Option "DynamicTwinView" "False"
    +
    +    NVidia RANDR Rotation:
    +        To enable it, add the following option to your xorg.conf device section:
    +            Option "RandRRotation" "on"
    + * 
    + * + */ +public class MonitorMode { + /** + * Immutable surfaceSize and refreshRate Class, consisting of it's read only components:
    + *
      + *
    • nativeId
    • + *
    • {@link SurfaceSize} surface memory size
    • + *
    • refresh rate
    • + *
    + */ + public static class SizeAndRRate { + public final SurfaceSize surfaceSize; + public final float refreshRate; + public final int flags; + public final int hashCode; + + public SizeAndRRate(SurfaceSize surfaceSize, float refreshRate, int flags) { + if(null==surfaceSize) { + throw new IllegalArgumentException("surfaceSize must be set ("+surfaceSize+")"); + } + this.surfaceSize=surfaceSize; + this.refreshRate=refreshRate; + this.flags = flags; + this.hashCode = getHashCode(); + } + + private final static String STR_INTERLACE = "Interlace"; + private final static String STR_DOUBLESCAN = "DoubleScan"; + private final static String STR_SEP = ", "; + + public static final StringBuffer flags2String(int flags) { + final StringBuffer sb = new StringBuffer(); + boolean sp = false; + if( 0 != ( flags & FLAG_INTERLACE ) ) { + sb.append(STR_INTERLACE); + sp = true; + } + if( 0 != ( flags & FLAG_DOUBLESCAN ) ) { + if( sp ) { + sb.append(STR_SEP); + } + sb.append(STR_DOUBLESCAN); + sp = true; + } + return sb; + } + public final String toString() { + return new String(surfaceSize+" @ "+refreshRate+" Hz, flags ["+flags2String(flags).toString()+"]"); + } + + /** + * Tests equality of two {@link SizeAndRRate} objects + * by evaluating equality of it's components:
    + *
      + *
    • surfaceSize
    • + *
    • refreshRate
    • + *
    • flags
    • + *
    + */ + public final boolean equals(Object obj) { + if (this == obj) { return true; } + if (obj instanceof SizeAndRRate) { + final SizeAndRRate p = (SizeAndRRate)obj; + return surfaceSize.equals(p.surfaceSize) && + refreshRate == p.refreshRate && + flags == p.flags ; + } + return false; + } + + /** + * Returns a combined hash code of it's elements:
    + *
      + *
    • surfaceSize
    • + *
    • refreshRate
    • + *
    • flags
    • + *
    + */ + public final int hashCode() { + return hashCode; + } + private final int getHashCode() { + // 31 * x == (x << 5) - x + int hash = 31 + surfaceSize.hashCode(); + hash = ((hash << 5) - hash) + (int)(refreshRate*100.0f); + hash = ((hash << 5) - hash) + flags; + return hash; + } + } + + /** zero rotation, compared to normal settings */ + public static final int ROTATE_0 = 0; + + /** 90 degrees CCW rotation */ + public static final int ROTATE_90 = 90; + + /** 180 degrees CCW rotation */ + public static final int ROTATE_180 = 180; + + /** 270 degrees CCW rotation */ + public static final int ROTATE_270 = 270; + + /** Frame is split into two fields. See {@link #getFlags()}. */ + public static final int FLAG_INTERLACE = 1 << 0; + + /** Lines are doubled. See {@link #getFlags()}. */ + public static final int FLAG_DOUBLESCAN = 1 << 1; + + /** The immutable native Id of this instance, which may not be unique. */ + private final int nativeId; + private final SizeAndRRate sizeAndRRate; + private final int rotation; + private final int hashCode; + + public static boolean isRotationValid(int rotation) { + return rotation == MonitorMode.ROTATE_0 || rotation == MonitorMode.ROTATE_90 || + rotation == MonitorMode.ROTATE_180 || rotation == MonitorMode.ROTATE_270 ; + } + + /** + * @param sizeAndRRate the surface size and refresh rate mode + * @param rotation the screen rotation, measured counter clockwise (CCW) + */ + public MonitorMode(int nativeId, SizeAndRRate sizeAndRRate, int rotation) { + if ( !isRotationValid(rotation) ) { + throw new RuntimeException("invalid rotation: "+rotation); + } + this.nativeId = nativeId; + this.sizeAndRRate = sizeAndRRate; + this.rotation = rotation; + this.hashCode = getHashCode(); + } + + /** + * Creates a user instance w/o {@link #getId() identity} to filter our matching modes w/ identity. + *

    + * See {@link com.jogamp.newt.util.MonitorModeUtil} for filter utilities. + *

    + * @param surfaceSize + * @param refreshRate + * @param flags + * @param rotation + */ + public MonitorMode(SurfaceSize surfaceSize, float refreshRate, int flags, int rotation) { + this(0, new SizeAndRRate(surfaceSize, refreshRate, flags), rotation); + } + + /** @return the immutable native Id of this mode, may not be unique, may be 0. */ + public final int getId() { return nativeId; } + + /** Returns the surfaceSize and refreshRate instance. */ + public final SizeAndRRate getSizeAndRRate() { + return sizeAndRRate; + } + + /** Returns the unrotated {@link SurfaceSize} */ + public final SurfaceSize getSurfaceSize() { + return sizeAndRRate.surfaceSize; + } + + public final float getRefreshRate() { + return sizeAndRRate.refreshRate; + } + + /** Returns bitfield w/ flags, i.e. {@link #FLAG_DOUBLESCAN}, {@link #FLAG_INTERLACE}, .. */ + public final int getFlags() { + return sizeAndRRate.flags; + } + + /** Returns the CCW rotation of this mode */ + public final int getRotation() { + return rotation; + } + + /** Returns the rotated screen width, + * derived from getMonitorMode().getSurfaceSize().getResolution() + * and getRotation() + */ + public final int getRotatedWidth() { + return getRotatedWH(true); + } + + /** Returns the rotated screen height, + * derived from getMonitorMode().getSurfaceSize().getResolution() + * and getRotation() + */ + public final int getRotatedHeight() { + return getRotatedWH(false); + } + + public final String toString() { + return "[Id "+Display.toHexString(nativeId)+", " + sizeAndRRate + ", " + rotation + " degr]"; + } + + /** + * Tests equality of two {@link MonitorMode} objects + * by evaluating equality of it's components:
    + *
      + *
    • nativeId
    • + *
    • sizeAndRRate
    • + *
    • rotation
    • + *
    + */ + public final boolean equals(Object obj) { + if (this == obj) { return true; } + if (obj instanceof MonitorMode) { + MonitorMode sm = (MonitorMode)obj; + return sm.nativeId == this.nativeId && + sm.sizeAndRRate.equals(sizeAndRRate) && + sm.rotation == this.rotation ; + } + return false; + } + + /** + * Returns a combined hash code of it's elements:
    + *
      + *
    • nativeId
    • + *
    • sizeAndRRate
    • + *
    • rotation
    • + *
    + */ + public final int hashCode() { + return hashCode; + } + private final int getHashCode() { + // 31 * x == (x << 5) - x + int hash = 31 + getId(); + hash = ((hash << 5) - hash) + sizeAndRRate.hashCode(); + hash = ((hash << 5) - hash) + getRotation(); + return hash; + } + + private final int getRotatedWH(boolean width) { + final DimensionImmutable d = sizeAndRRate.surfaceSize.getResolution(); + final boolean swap = MonitorMode.ROTATE_90 == rotation || MonitorMode.ROTATE_270 == rotation ; + if ( ( width && swap ) || ( !width && !swap ) ) { + return d.getHeight(); + } + return d.getWidth(); + } +} diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index a09748d52..81a62d898 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -27,14 +27,19 @@ */ package com.jogamp.newt; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorModeListener; import jogamp.newt.Debug; import java.util.ArrayList; import java.util.Collection; import java.util.List; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.RectangleImmutable; +/** + * A screen may span multiple {@link MonitorDevice}s representing their combined virtual size. + */ public abstract class Screen { /** @@ -122,25 +127,30 @@ public abstract class Screen { public abstract int getIndex(); /** - * @return the x position of the virtual top-left origin. + * @return the x position of the virtual viewport's top-left origin. */ public abstract int getX(); /** - * @return the y position of the virtual top-left origin. + * @return the y position of the virtual viewport's top-left origin. */ public abstract int getY(); /** - * @return the rotated virtual width. + * @return the rotated virtual viewport's width. */ public abstract int getWidth(); /** - * @return the rotated virtual height. + * @return the rotated virtual viewport's height. */ public abstract int getHeight(); + /** + * @return the rotated virtual viewport, i.e. origin and size. + */ + public abstract RectangleImmutable getViewport(); + /** * @return the associated Display */ @@ -152,48 +162,68 @@ public abstract class Screen { */ public abstract String getFQName(); - /** - * @param sml ScreenModeListener to be added for ScreenMode change events - */ - public abstract void addScreenModeListener(ScreenModeListener sml); - - /** - * @param sml ScreenModeListener to be removed from ScreenMode change events + /** + * Return a list of all available {@link MonitorMode}s for all {@link MonitorDevice}s. + *

    + * If {@link com.jogamp.newt.MonitorMode ScreenMode}s are not supported for this + * native type {@link com.jogamp.newt.Display#getType()}, it returns a list of size one with the current screen size.

    */ - public abstract void removeScreenModeListener(ScreenModeListener sml); + public abstract List getMonitorModes(); /** - * Return a list of available {@link com.jogamp.newt.ScreenMode ScreenMode}s. + * Return a list of all available {@link MonitorDevice}s. *

    - * If {@link com.jogamp.newt.ScreenMode ScreenMode}s are not supported for this + * If {@link com.jogamp.newt.MonitorMode ScreenMode}s are not supported for this * native type {@link com.jogamp.newt.Display#getType()}, it returns a list of size one with the current screen size.

    - * - * @return a shallow copy of the internal immutable {@link com.jogamp.newt.ScreenMode ScreenMode}s. */ - public abstract List getScreenModes(); + public abstract List getMonitorDevices(); /** - * Return the original {@link com.jogamp.newt.ScreenMode}, as used at NEWT initialization. - * @return original ScreenMode which is element of the list {@link #getScreenModes()}. + * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} + * {@link MonitorDevice#coverage(RectangleImmutable) covers} the given rectangle the most. + *

    + * If no coverage is detected the first {@link MonitorDevice} is returned. + *

    */ - public abstract ScreenMode getOriginalScreenMode(); + public final MonitorDevice getMainMonitor(RectangleImmutable r) { + MonitorDevice res = null; + float maxCoverage = Float.MIN_VALUE; + final List monitors = getMonitorDevices(); + for(int i=monitors.size()-1; i>=0; i--) { + final MonitorDevice monitor = monitors.get(i); + final float coverage = monitor.coverage(r); + if( coverage > maxCoverage ) { + maxCoverage = coverage; + res = monitor; + } + } + if( maxCoverage > 0.0f && null != res ) { + return res; + } + return monitors.get(0); + } /** - * Return the current {@link com.jogamp.newt.ScreenMode}. + * Returns the union of all monitor's {@link MonitorDevice#getViewport() viewport}. *

    - * If {@link com.jogamp.newt.ScreenMode ScreenMode}s are not supported for this - * native type {@link com.jogamp.newt.Display#getType()}, it returns one with the current screen size.

    - * - * @return current ScreenMode which is element of the list {@link #getScreenModes()}. + * Should be equal to {@link #getX()}, {@link #getY()}, {@link #getWidth()} and {@link #getHeight()}, + * however, some native toolkits may choose a different virtual screen area. + *

    + * @param result storage for result, will be returned + */ + public final Rectangle unionOfMonitorViewportSize(final Rectangle result) { + return MonitorDevice.unionOfViewports(result, getMonitorDevices()); + } + + /** + * @param sml {@link MonitorModeListener} to be added for {@link MonitorEvent} */ - public abstract ScreenMode getCurrentScreenMode(); + public abstract void addMonitorModeListener(MonitorModeListener sml); /** - * Set the current {@link com.jogamp.newt.ScreenMode}. - * @param screenMode to be made current, must be element of the list {@link #getScreenModes()}. - * @return true if successful, otherwise false + * @param sml {@link MonitorModeListener} to be removed from {@link MonitorEvent} */ - public abstract boolean setCurrentScreenMode(ScreenMode screenMode); + public abstract void removeMonitorModeListener(MonitorModeListener sml); // Global Screens protected static ArrayList screenList = new ArrayList(); @@ -236,6 +266,7 @@ public abstract class Screen { return null; } /** Returns the global display collection */ + @SuppressWarnings("unchecked") public static Collection getAllScreens() { ArrayList list; synchronized(screenList) { diff --git a/src/newt/classes/com/jogamp/newt/ScreenMode.java b/src/newt/classes/com/jogamp/newt/ScreenMode.java deleted file mode 100644 index 1f12217bb..000000000 --- a/src/newt/classes/com/jogamp/newt/ScreenMode.java +++ /dev/null @@ -1,208 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.newt; - -import javax.media.nativewindow.util.DimensionImmutable; - -import com.jogamp.newt.util.MonitorMode; - -/** Immutable ScreenMode Class, consisting of it's read only components:
    - *
      - *
    • {@link com.jogamp.newt.util.MonitorMode}, non rotated values
    • - *
    • rotation, measured counter clockwise (CCW)
    • - *
    - * - * Aquire and filter ScreenModes
    - *
      - *
    • A List of read only ScreenMode's is being returned by {@link com.jogamp.newt.Screen#getScreenModes()}.
    • - *
    • You may utilize {@link com.jogamp.newt.util.ScreenModeUtil} to filter and select a desired ScreenMode.
    • - *
    • The current ScreenMode can be obtained via {@link com.jogamp.newt.Screen#getCurrentScreenMode()}.
    • - *
    • The initial original ScreenMode (at startup) can be obtained via {@link com.jogamp.newt.Screen#getOriginalScreenMode()}.
    • - *
    - *
    - * - * Changing ScreenModes
    - *
      - *
    • Use {@link com.jogamp.newt.Screen#setCurrentScreenMode(com.jogamp.newt.ScreenMode)}
    • - * to change the current ScreenMode of all Screen's referenced via the full qualified name (FQN) - * {@link com.jogamp.newt.Screen#getFQName()}. - *
    • When the last FQN referenced Screen closes, the original ScreenMode ({@link com.jogamp.newt.Screen#getOriginalScreenMode()}) - * is restored.
    • - *
    - *
    - * Example for changing the ScreenMode: - *
    -        // determine target refresh rate
    -        ScreenMode orig = screen.getOriginalScreenMode();
    -        int freq = orig.getMonitorMode().getRefreshRate();
    -
    -        // target resolution
    -        Dimension res = new Dimension(800, 600);
    -
    -        // target rotation
    -        int rot = 0;
    -
    -        // filter available ScreenModes
    -        List screenModes = screen.getScreenModes();
    -        screenModes = ScreenModeUtil.filterByRate(screenModes, freq); // get the nearest ones
    -        screenModes = ScreenModeUtil.filterByRotation(screenModes, rot);
    -        screenModes = ScreenModeUtil.filterByResolution(screenModes, res); // get the nearest ones
    -        screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
    -
    -        // pick 1st one ..
    -        screen.setCurrentScreenMode((ScreenMode) screenModes.get(0)); 
    - * 
    - * - * X11 / AMD just works
    - *
    - * X11 / NVidia difficulties - *
    -    NVidia RANDR RefreshRate Bug
    -        If NVidia's 'DynamicTwinView' is enabled, all refresh rates are
    -        unique, ie consequent numbers starting with the default refresh, ie 50, 51, ..
    -        The only way to workaround it is to disable 'DynamicTwinView'.
    -        Read: http://us.download.nvidia.com/XFree86/Linux-x86/260.19.12/README/configtwinview.html
    -
    -        Check to see if 'DynamicTwinView' is enable:
    -            nvidia-settings -q :0/DynamicTwinview
    -
    -        To disable it (workaround), add the following option to your xorg.conf device section:
    -            Option "DynamicTwinView" "False"
    -
    -    NVidia RANDR Rotation:
    -        To enable it, add the following option to your xorg.conf device section:
    -            Option "RandRRotation" "on"
    - * 
    - * - */ -public class ScreenMode { - /** zero rotation, compared to normal settings */ - public static final int ROTATE_0 = 0; - - /** 90 degrees CCW rotation */ - public static final int ROTATE_90 = 90; - - /** 180 degrees CCW rotation */ - public static final int ROTATE_180 = 180; - - /** 270 degrees CCW rotation */ - public static final int ROTATE_270 = 270; - - MonitorMode monitorMode; - int rotation; - - public static boolean isRotationValid(int rotation) { - return rotation == ScreenMode.ROTATE_0 || rotation == ScreenMode.ROTATE_90 || - rotation == ScreenMode.ROTATE_180 || rotation == ScreenMode.ROTATE_270 ; - } - - /** - * @param monitorMode the monitor mode - * @param rotation the screen rotation, measured counter clockwise (CCW) - */ - public ScreenMode(MonitorMode monitorMode, int rotation) { - if ( !isRotationValid(rotation) ) { - throw new RuntimeException("invalid rotation: "+rotation); - } - this.monitorMode = monitorMode; - this.rotation = rotation; - } - - /** Returns the unrotated MonitorMode */ - public final MonitorMode getMonitorMode() { - return monitorMode; - } - - /** Returns the CCW rotation of this mode */ - public final int getRotation() { - return rotation; - } - - /** Returns the rotated screen width, - * derived from getMonitorMode().getSurfaceSize().getResolution() - * and getRotation() - */ - public final int getRotatedWidth() { - return getRotatedWH(true); - } - - /** Returns the rotated screen height, - * derived from getMonitorMode().getSurfaceSize().getResolution() - * and getRotation() - */ - public final int getRotatedHeight() { - return getRotatedWH(false); - } - - public final String toString() { - return "[ " + getMonitorMode() + ", " + rotation + " degr ]"; - } - - /** - * Tests equality of two ScreenMode objects - * by evaluating equality of it's components:
    - *
      - *
    • monitorMode
    • - *
    • rotation
    • - *
    - *
    - */ - public final boolean equals(Object obj) { - if (this == obj) { return true; } - if (obj instanceof ScreenMode) { - ScreenMode sm = (ScreenMode)obj; - return sm.getMonitorMode().equals(getMonitorMode()) && - sm.getRotation() == this.getRotation() ; - } - return false; - } - - /** - * Returns a combined hash code of it's elements:
    - *
      - *
    • monitorMode
    • - *
    • rotation
    • - *
    - */ - public final int hashCode() { - // 31 * x == (x << 5) - x - int hash = 31 + getMonitorMode().hashCode(); - hash = ((hash << 5) - hash) + getRotation(); - return hash; - } - - private final int getRotatedWH(boolean width) { - final DimensionImmutable d = getMonitorMode().getSurfaceSize().getResolution(); - final boolean swap = ScreenMode.ROTATE_90 == rotation || ScreenMode.ROTATE_270 == rotation ; - if ( ( width && swap ) || ( !width && !swap ) ) { - return d.getHeight(); - } - return d.getWidth(); - } -} diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index ab1eef308..0bebf330a 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -28,6 +28,8 @@ package com.jogamp.newt; +import java.util.List; + import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.KeyListener; @@ -41,6 +43,7 @@ import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.nativewindow.util.RectangleImmutable; /** * Specifying NEWT's Window functionality: @@ -80,10 +83,19 @@ public interface Window extends NativeWindow, WindowClosingProtocol { boolean isNativeValid(); /** - * @return The associated Screen + * @return The associated {@link Screen} */ Screen getScreen(); + /** + * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} + * {@link MonitorDevice#coverage(RectangleImmutable) covers} this window the most. + *

    + * If no coverage is detected the first {@link MonitorDevice} is returned. + *

    + */ + MonitorDevice getMainMonitor(); + /** * Set the CapabilitiesChooser to help determine the native visual type. * @@ -344,8 +356,32 @@ public interface Window extends NativeWindow, WindowClosingProtocol { ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate); + /** + * Enable or disable fullscreen mode for this window. + *

    + * Fullscreen mode is established on the {@link #getMainMonitor() main monitor}. + *

    + * @param fullscreen enable or disable fullscreen mode + * @return success + * @see #setFullscreen(List) + * @see #isFullscreen() + */ boolean setFullscreen(boolean fullscreen); + /** + * Enable fullscreen mode for this window spanning across the given {@link MonitorDevice}s + * or across all {@link MonitorDevice}s. + *

    + * Disable fullscreen via {@link #setFullscreen(boolean)}. + *

    + * @param monitors if null fullscreen will be spanned across all {@link MonitorDevice}s, + * otherwise across the given list of {@link MonitorDevice}. + * @return success + * @see #setFullscreen(boolean) + * @see #isFullscreen() + */ + boolean setFullscreen(List monitors); + boolean isFullscreen(); static interface FocusRunnable { diff --git a/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java b/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java new file mode 100644 index 000000000..c47936a7a --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java @@ -0,0 +1,71 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.newt.event; + +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; + +@SuppressWarnings("serial") +public class MonitorEvent extends OutputEvent { + public static final short EVENT_MONITOR_MODE_CHANGE_NOTIFY = 600; + public static final short EVENT_MONITOR_MODE_CHANGED = 601; + + private final MonitorMode mode; + + public MonitorEvent (short eventType, MonitorDevice source, long when, MonitorMode mode) { + super(eventType, source, when); + this.mode = mode; + } + + /** Returns the {@link #getSource() source}, which is a {@link MonitorDevice}. */ + public final MonitorDevice getMonitor() { return (MonitorDevice)source; } + + public final MonitorMode getMode() { return mode; } + + public static String getEventTypeString(short type) { + switch(type) { + case EVENT_MONITOR_MODE_CHANGE_NOTIFY: return "EVENT_MONITOR_MODE_CHANGE_NOTIFY"; + case EVENT_MONITOR_MODE_CHANGED: return "EVENT_MONITOR_MODE_CHANGED"; + default: return "unknown (" + type + ")"; + } + } + + public final String toString() { + return toString(null).toString(); + } + + public final StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("MonitorEvent[").append(getEventTypeString(getEventType())).append(", source ").append(source) + .append(", mode ").append(mode).append(", "); + return super.toString(sb).append("]"); + } +} diff --git a/src/newt/classes/com/jogamp/newt/event/MonitorModeListener.java b/src/newt/classes/com/jogamp/newt/event/MonitorModeListener.java new file mode 100644 index 000000000..11e23def1 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/MonitorModeListener.java @@ -0,0 +1,37 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.newt.event; + +public interface MonitorModeListener { + /** called before the monitor mode will be changed */ + void monitorModeChangeNotify(MonitorEvent me); + + /** called after the monitor mode has been changed */ + void monitorModeChanged(MonitorEvent me, boolean success); +} diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index ea96f634f..c1bc791d8 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -41,9 +41,10 @@ package com.jogamp.newt.event; * * Event type registry:
    *
      - *
    • WindowEvent 100..10x
    • - *
    • MouseEvent 200..20x
    • - *
    • KeyEvent 300..30x
    • + *
    • WindowEvent 100..10x
    • + *
    • MouseEvent 200..20x
    • + *
    • KeyEvent 300..30x
    • + *
    • MonitorEvent 600..60x
    • *

    */ @SuppressWarnings("serial") diff --git a/src/newt/classes/com/jogamp/newt/event/OutputEvent.java b/src/newt/classes/com/jogamp/newt/event/OutputEvent.java new file mode 100644 index 000000000..86fa95877 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/OutputEvent.java @@ -0,0 +1,51 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.newt.event; + +@SuppressWarnings("serial") +public abstract class OutputEvent extends NEWTEvent +{ + protected OutputEvent(short eventType, Object source, long when) { + super(eventType, source, when); + } + + /** + public String toString() { + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("OutputEvent["); + super.toString(sb).append("]"); + return sb; + } */ +} diff --git a/src/newt/classes/com/jogamp/newt/event/ScreenModeListener.java b/src/newt/classes/com/jogamp/newt/event/ScreenModeListener.java deleted file mode 100644 index 7bca23cfe..000000000 --- a/src/newt/classes/com/jogamp/newt/event/ScreenModeListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.newt.event; - -import com.jogamp.newt.ScreenMode; - -public interface ScreenModeListener { - /** called before the screen mode will be changed */ - void screenModeChangeNotify(ScreenMode sm); - - /** called after the screen mode has been changed */ - void screenModeChanged(ScreenMode sm, boolean success); -} diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index de62747be..1500d48e6 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -34,6 +34,8 @@ package com.jogamp.newt.opengl; +import java.util.List; + import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; @@ -64,6 +66,7 @@ import jogamp.opengl.GLDrawableImpl; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; @@ -224,6 +227,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return window.getScreen(); } + @Override + public final MonitorDevice getMainMonitor() { + return window.getMainMonitor(); + } + @Override public final void setTitle(String title) { window.setTitle(title); @@ -341,6 +349,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final boolean setFullscreen(boolean fullscreen) { return window.setFullscreen(fullscreen); } + + @Override + public boolean setFullscreen(List monitors) { + return window.setFullscreen(monitors); + } @Override public final boolean isFullscreen() { diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorMode.java b/src/newt/classes/com/jogamp/newt/util/MonitorMode.java deleted file mode 100644 index 8104f207a..000000000 --- a/src/newt/classes/com/jogamp/newt/util/MonitorMode.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.newt.util; - -import javax.media.nativewindow.util.*; - -/** Immutable MonitorMode Class, consisting of it's read only components:
    - *
      - *
    • {@link javax.media.nativewindow.util.SurfaceSize} surface memory size
    • - *
    • {@link javax.media.nativewindow.util.DimensionImmutable} size in [mm]
    • - *
    • refresh rate
    • - *
    - */ -public class MonitorMode { - SurfaceSize surfaceSize; - DimensionImmutable screenSizeMM; // in [mm] - int refreshRate; - - public MonitorMode(SurfaceSize surfaceSize, DimensionImmutable screenSizeMM, int refreshRate) { - // Don't validate screenSizeMM and refreshRate, since they may not be supported by the OS - if(null==surfaceSize) { - throw new IllegalArgumentException("surfaceSize must be set ("+surfaceSize+")"); - } - this.surfaceSize=surfaceSize; - this.screenSizeMM=screenSizeMM; - this.refreshRate=refreshRate; - } - - public final SurfaceSize getSurfaceSize() { - return surfaceSize; - } - - public final DimensionImmutable getScreenSizeMM() { - return screenSizeMM; - } - - public final int getRefreshRate() { - return refreshRate; - } - - public final String toString() { - return new String("[ "+surfaceSize+" x "+refreshRate+" Hz, "+screenSizeMM+" mm ]"); - } - - /** - * Checks whether two size objects are equal. Two instances - * of MonitorMode are equal if the three components - * surfaceSize and refreshRate - * are equal. screenSizeMM is kept out intentional to reduce the requirements for finding the current mode. - * @return true if the two dimensions are equal; - * otherwise false. - */ - public final boolean equals(Object obj) { - if (this == obj) { return true; } - if (obj instanceof MonitorMode) { - MonitorMode p = (MonitorMode)obj; - return getSurfaceSize().equals(p.getSurfaceSize()) && - /* getScreenSizeMM().equals(p.getScreenSizeMM()) && */ - getRefreshRate() == p.getRefreshRate() ; - } - return false; - } - - /** - * returns a hash code over surfaceSize and refreshRate. - * screenSizeMM is kept out intentional to reduce the requirements for finding the current mode. - */ - public final int hashCode() { - // 31 * x == (x << 5) - x - int hash = 31 + getSurfaceSize().hashCode(); - /* hash = ((hash << 5) - hash) + getScreenSizeMM().hashCode(); */ - hash = ((hash << 5) - hash) + getRefreshRate(); - return hash; - } -} - diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java new file mode 100644 index 000000000..16ffe754f --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java @@ -0,0 +1,247 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.newt.util; + +import com.jogamp.newt.MonitorMode; + +import java.util.ArrayList; +import java.util.List; +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.SurfaceSize; + +/** + * Convenient {@link com.jogamp.newt.MonitorMode} utility methods, + * filters etc. + */ +public class MonitorModeUtil { + + public static int getIndex(List monitorModes, MonitorMode search) { + return monitorModes.indexOf(search); + } + + public static int getIndexByHashCode(List monitorModes, MonitorMode search) { + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; i monitorModes, MonitorMode.SizeAndRRate sizeAndRate, int modeId, int rotation) { + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; i filterBySurfaceSize(List monitorModes, SurfaceSize surfaceSize) { + final List out = new ArrayList(); + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; null!=monitorModes && i filterByRotation(List monitorModes, int rotation) { + final List out = new ArrayList(); + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; null!=monitorModes && i filterByBpp(List monitorModes, int bitsPerPixel) { + final List out = new ArrayList(); + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; null!=monitorModes && i filterByFlags(List monitorModes, int flags) { + final List out = new ArrayList(); + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; null!=monitorModes && i filterByResolution(List monitorModes, DimensionImmutable resolution) { + final List out = new ArrayList(); + if( null!=monitorModes && monitorModes.size()>0 ) { + final int resolution_sq = resolution.getHeight()*resolution.getWidth(); + int mode_dsq=Integer.MAX_VALUE, mode_dsq_idx=0; + + for (int i=0; null!=monitorModes && i filterByRate(List monitorModes, float refreshRate) { + final List out = new ArrayList(); + if( null!=monitorModes && monitorModes.size()>0 ) { + float mode_dr = Float.MAX_VALUE; + int mode_dr_idx = -1; + for (int i=0; null!=monitorModes && i getHighestAvailableBpp(List monitorModes) { + if( null!=monitorModes && monitorModes.size()>0 ) { + int highest = -1; + for (int i=0; null!=monitorModes && i < monitorModes.size(); i++) { + final MonitorMode mode = monitorModes.get(i); + final int bpp = mode.getSurfaceSize().getBitsPerPixel(); + if (bpp > highest) { + highest = bpp; + } + } + return filterByBpp(monitorModes, highest); + } + return new ArrayList(); + } + + /** + * + * @param monitorModes + * @return modes with highest available refresh rate. May return zero sized list for non. + */ + public static List getHighestAvailableRate(List monitorModes) { + if( null!=monitorModes && monitorModes.size()>0 ) { + float highest = -1; + for (int i=0; null!=monitorModes && i < monitorModes.size(); i++) { + final MonitorMode mode = monitorModes.get(i); + final float rate = mode.getRefreshRate(); + if (rate > highest) { + highest = rate; + } + } + return filterByRate(monitorModes, highest); + } + return new ArrayList(); + } + +} diff --git a/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java b/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java deleted file mode 100644 index 93797c5fb..000000000 --- a/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java +++ /dev/null @@ -1,341 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.newt.util; - -import com.jogamp.common.util.ArrayHashSet; -import com.jogamp.newt.ScreenMode; -import java.util.ArrayList; -import java.util.List; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.SurfaceSize; - -/** - * Convenient {@link com.jogamp.newt.ScreenMode} utility methods, - * filters etc. - */ -public class ScreenModeUtil { - /** WARNING: must be synchronized with ScreenMode.h, native implementation - * 2: width and height - */ - public static final int NUM_RESOLUTION_PROPERTIES = 2; - - /** WARNING: must be synchronized with ScreenMode.h, native implementation - * 1: bpp - */ - public static final int NUM_SURFACE_SIZE_PROPERTIES = 1; - - /** WARNING: must be synchronized with ScreenMode.h, native implementation - * 3: ScreenSizeMM[width, height], refresh-rate - */ - public static final int NUM_MONITOR_MODE_PROPERTIES = 3; - - /** WARNING: must be synchronized with ScreenMode.h, native implementation - * 1: rotation, native_mode_id - */ - public static final int NUM_SCREEN_MODE_PROPERTIES = 1; - - /** WARNING: must be synchronized with ScreenMode.h, native implementation - * count + all the above - */ - public static final int NUM_SCREEN_MODE_PROPERTIES_ALL = 8; - - public static int getIndex(List screenModes, ScreenMode search) { - return screenModes.indexOf(search); - } - - public static int getIndexByHashCode(List screenModes, ScreenMode search) { - for (int i=0; null!=screenModes && i filterByResolution(List screenModes, DimensionImmutable resolution) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - List out = new ArrayList(); - int resolution_sq = resolution.getHeight()*resolution.getWidth(); - int sm_dsq=resolution_sq, sm_dsq_idx=0; - - for (int i=0; null!=screenModes && i0) { - return out; - } - // nearest .. - resolution = screenModes.get(sm_dsq_idx).getMonitorMode().getSurfaceSize().getResolution(); - return filterByResolution(screenModes, resolution); - } - - public static List filterBySurfaceSize(List screenModes, SurfaceSize surfaceSize) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - List out = new ArrayList(); - for (int i=0; null!=screenModes && i0 ? out : null; - } - - public static List filterByRotation(List screenModes, int rotation) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - List out = new ArrayList(); - for (int i=0; null!=screenModes && i0 ? out : null; - } - - public static List filterByBpp(List screenModes, int bitsPerPixel) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - List out = new ArrayList(); - for (int i=0; null!=screenModes && i0 ? out : null; - } - - /** - * - * @param screenModes - * @param refreshRate - * @return modes with nearest refreshRate, or matching ones - */ - public static List filterByRate(List screenModes, int refreshRate) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - int sm_dr = refreshRate; - int sm_dr_idx = -1; - List out = new ArrayList(); - for (int i=0; null!=screenModes && i0) { - return out; - } - refreshRate = screenModes.get(sm_dr_idx).getMonitorMode().getRefreshRate(); - return filterByRate(screenModes, refreshRate); - } - - public static List getHighestAvailableBpp(List screenModes) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - int highest = -1; - for (int i=0; null!=screenModes && i < screenModes.size(); i++) { - ScreenMode sm = screenModes.get(i); - int bpp = sm.getMonitorMode().getSurfaceSize().getBitsPerPixel(); - if (bpp > highest) { - highest = bpp; - } - } - return filterByBpp(screenModes, highest); - } - - public static List getHighestAvailableRate(List screenModes) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - int highest = -1; - for (int i=0; null!=screenModes && i < screenModes.size(); i++) { - ScreenMode sm = screenModes.get(i); - int rate = sm.getMonitorMode().getRefreshRate(); - if (rate > highest) { - highest = rate; - } - } - return filterByRate(screenModes, highest); - } - - /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - public static DimensionImmutable streamInResolution(int[] resolutionProperties, int offset) { - Dimension resolution = new Dimension(resolutionProperties[offset++], resolutionProperties[offset++]); - return resolution; - } - - /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - public static SurfaceSize streamInSurfaceSize(DimensionImmutable resolution, int[] sizeProperties, int offset) { - SurfaceSize surfaceSize = new SurfaceSize(resolution, sizeProperties[offset++]); - return surfaceSize; - } - - /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - public static MonitorMode streamInMonitorMode(SurfaceSize surfaceSize, DimensionImmutable screenSizeMM, int[] monitorProperties, int offset) { - int refreshRate = monitorProperties[offset++]; - return new MonitorMode(surfaceSize, screenSizeMM, refreshRate); - } - - /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - public static ScreenMode streamInScreenMode(MonitorMode monitorMode, int[] modeProperties, int offset) { - int rotation = modeProperties[offset++]; - return new ScreenMode(monitorMode, rotation); - } - - /** - * WARNING: must be synchronized with ScreenMode.h, native implementation - * - * @param modeProperties the input data - * @param offset the offset to the input data - * @return ScreenMode element matching the input modeProperties, - * or null if input could not be processed. - */ - public static ScreenMode streamIn(int[] modeProperties, int offset) { - return streamInImpl(null, null, null, null, null, modeProperties, offset); - } - - /** - * WARNING: must be synchronized with ScreenMode.h, native implementation - * - * @param resolutionPool hash array of unique resolutions, no duplicates - * @param surfaceSizePool hash array of unique SurfaceSize, no duplicates - * @param monitorModePool hash array of unique MonitorMode, no duplicates - * @param screenModePool hash array of unique ScreenMode, no duplicates - * @param modeProperties the input data - * @param offset the offset to the input data - * @return index of the identical (old or new) ScreenMode element in screenModePool, - * matching the input modeProperties, or -1 if input could not be processed. - */ - public static int streamIn(ArrayHashSet resolutionPool, - ArrayHashSet surfaceSizePool, - ArrayHashSet screenSizeMMPool, - ArrayHashSet monitorModePool, - ArrayHashSet screenModePool, - int[] modeProperties, int offset) { - ScreenMode screenMode = streamInImpl(resolutionPool, surfaceSizePool, screenSizeMMPool, monitorModePool, screenModePool, - modeProperties, offset); - return screenModePool.indexOf(screenMode); - } - - - private static ScreenMode streamInImpl(ArrayHashSet resolutionPool, - ArrayHashSet surfaceSizePool, - ArrayHashSet screenSizeMMPool, - ArrayHashSet monitorModePool, - ArrayHashSet screenModePool, - int[] modeProperties, int offset) { - int count = modeProperties[offset]; - if(NUM_SCREEN_MODE_PROPERTIES_ALL != count) { - throw new RuntimeException("NUM_SCREEN_MODE_PROPERTIES should be "+NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+count+", len "+(modeProperties.length-offset)); - } - if(NUM_SCREEN_MODE_PROPERTIES_ALL > modeProperties.length-offset) { - throw new RuntimeException("properties array too short, should be >= "+NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+(modeProperties.length-offset)); - } - offset++; - DimensionImmutable resolution = ScreenModeUtil.streamInResolution(modeProperties, offset); - offset += ScreenModeUtil.NUM_RESOLUTION_PROPERTIES; - if(null!=resolutionPool) { - resolution = resolutionPool.getOrAdd(resolution); - } - - SurfaceSize surfaceSize = ScreenModeUtil.streamInSurfaceSize(resolution, modeProperties, offset); - offset += ScreenModeUtil.NUM_SURFACE_SIZE_PROPERTIES; - if(null!=surfaceSizePool) { - surfaceSize = surfaceSizePool.getOrAdd(surfaceSize); - } - - DimensionImmutable screenSizeMM = ScreenModeUtil.streamInResolution(modeProperties, offset); - offset += ScreenModeUtil.NUM_RESOLUTION_PROPERTIES; - if(null!=screenSizeMMPool) { - screenSizeMM = screenSizeMMPool.getOrAdd(screenSizeMM); - } - - MonitorMode monitorMode = ScreenModeUtil.streamInMonitorMode(surfaceSize, screenSizeMM, modeProperties, offset); - offset += ScreenModeUtil.NUM_MONITOR_MODE_PROPERTIES - ScreenModeUtil.NUM_RESOLUTION_PROPERTIES; - if(null!=monitorModePool) { - monitorMode = monitorModePool.getOrAdd(monitorMode); - } - - ScreenMode screenMode = ScreenModeUtil.streamInScreenMode(monitorMode, modeProperties, offset); - if(null!=screenModePool) { - screenMode = screenModePool.getOrAdd(screenMode); - } - return screenMode; - } - - /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - public static int[] streamOut (ScreenMode screenMode) { - int[] data = new int[NUM_SCREEN_MODE_PROPERTIES_ALL]; - int idx=0; - data[idx++] = NUM_SCREEN_MODE_PROPERTIES_ALL; - data[idx++] = screenMode.getMonitorMode().getSurfaceSize().getResolution().getWidth(); - data[idx++] = screenMode.getMonitorMode().getSurfaceSize().getResolution().getHeight(); - data[idx++] = screenMode.getMonitorMode().getSurfaceSize().getBitsPerPixel(); - data[idx++] = screenMode.getMonitorMode().getScreenSizeMM().getWidth(); - data[idx++] = screenMode.getMonitorMode().getScreenSizeMM().getHeight(); - data[idx++] = screenMode.getMonitorMode().getRefreshRate(); - data[idx++] = screenMode.getRotation(); - if(NUM_SCREEN_MODE_PROPERTIES_ALL != idx) { - throw new InternalError("wrong number of attributes: got "+idx+" != should "+NUM_SCREEN_MODE_PROPERTIES_ALL); - } - return data; - } - -} diff --git a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java new file mode 100644 index 000000000..96daed54a --- /dev/null +++ b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java @@ -0,0 +1,147 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt; + +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.Rectangle; + +import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.Screen; + +public class MonitorDeviceImpl extends MonitorDevice { + + public MonitorDeviceImpl(ScreenImpl screen, int nativeId, DimensionImmutable sizeMM, Rectangle viewport, MonitorMode currentMode, ArrayHashSet supportedModes) { + super(screen, nativeId, sizeMM, viewport, currentMode, supportedModes); + } + + @Override + public final MonitorMode queryCurrentMode() { + final ScreenImpl screenImpl = (ScreenImpl)screen; + final ScreenMonitorState sms = screenImpl.getScreenMonitorStatus(true); + sms.lock(); + try { + final MonitorMode mm0 = screenImpl.queryCurrentMonitorModeIntern(this); + if(null == mm0) { + throw new InternalError("getCurrentMonitorModeIntern() == null"); + } + MonitorMode mmU = supportedModes.get(mm0); // unified instance + if( null == mmU ) { + // add new mode avoiding exception! + mmU = sms.getMonitorModes().getOrAdd(mm0); + mmU = supportedModes.getOrAdd(mmU); + if( Screen.DEBUG ) { + System.err.println("Adding new mode: "+mm0+" -> "+mmU); + } + } + // if mode has changed somehow, update it .. + if( getCurrentMode().hashCode() != mmU.hashCode() ) { + setCurrentModeValue(mmU); + sms.fireScreenModeChanged(this, mmU, true); + } + return mmU; + } finally { + sms.unlock(); + } + } + + @Override + public final boolean setCurrentMode(MonitorMode mode) { + if(Screen.DEBUG) { + System.err.println("Screen.setCurrentScreenMode.0: "+this+" -> "+mode); + } + final ScreenImpl screenImpl = (ScreenImpl)screen; + final ScreenMonitorState sms = screenImpl.getScreenMonitorStatus(true); + sms.lock(); + try { + final MonitorMode mmC = queryCurrentMode(); + final MonitorMode mmU = supportedModes.get(mode); // unify via value hash + if( null == mmU ) { + throw new IllegalArgumentException("Given mode not in set of modes. Current mode "+mode+", "+this); + } + if( mmU.equals( mmC ) ) { + if(Screen.DEBUG) { + System.err.println("Screen.setCurrentScreenMode: 0.0 is-current (skip) "+mmU+" == "+mmC); + } + return true; + } + final long tStart; + if(Screen.DEBUG) { + tStart = System.nanoTime(); + } else { + tStart = 0; + } + + sms.fireScreenModeChangeNotify(this, mmU); + if(Screen.DEBUG) { + System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): fireScreenModeChangeNotify() "+mmU); + } + + boolean success = screenImpl.setCurrentMonitorModeImpl(this, mmU); + if(success) { + if(Screen.DEBUG) { + System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+mmU+", success(1): "+success); + } + } else { + // 2nd attempt validate! + final MonitorMode queriedCurrent = queryCurrentMode(); // may fireScreenModeChanged(..) if successful and differs! + success = queriedCurrent.hashCode() == mmU.hashCode() ; + if(Screen.DEBUG) { + System.err.println("Screen.setCurrentScreenMode.2: queried "+queriedCurrent); + System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+mmU+", success(2): "+success); + } + } + if( success ) { + setCurrentModeValue(mmU); + modeChanged = !isOriginalMode(); + } + sms.fireScreenModeChanged(this, mmU, success); + if(Screen.DEBUG) { + System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): X.X "+this+", success: "+success); + } + return success; + } finally { + sms.unlock(); + } + } + + private final void setCurrentModeValue(MonitorMode currentMode) { + this.currentMode = currentMode; + } + + /* pp */ final void setViewportValue(Rectangle viewport) { + this.viewport = viewport; + } + + /* pp */ ArrayHashSet getSupportedModesImpl() { + return supportedModes; + } + +} \ No newline at end of file diff --git a/src/newt/classes/jogamp/newt/MonitorModeProps.java b/src/newt/classes/jogamp/newt/MonitorModeProps.java new file mode 100644 index 000000000..820807e15 --- /dev/null +++ b/src/newt/classes/jogamp/newt/MonitorModeProps.java @@ -0,0 +1,355 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt; + +import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; + +import java.util.List; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.SurfaceSize; + +import jogamp.newt.MonitorDeviceImpl; +import jogamp.newt.ScreenImpl; + +/** + * Encodes and decodes {@link MonitorMode} and {@link MonitorDevice} properties. + */ +public class MonitorModeProps { + /** WARNING: must be synchronized with ScreenMode.h, native implementation + * 2: width, height + */ + public static final int NUM_RESOLUTION_PROPERTIES = 2; + + /** WARNING: must be synchronized with ScreenMode.h, native implementation + * 1: bpp + */ + public static final int NUM_SURFACE_SIZE_PROPERTIES = 1; + + /** WARNING: must be synchronized with ScreenMode.h, native implementation + * 2: refresh-rate (Hz*100), flags + */ + public static final int NUM_SIZEANDRATE_PROPERTIES = 2; + + /** WARNING: must be synchronized with ScreenMode.h, native implementation + * 2: id, rotation + */ + public static final int NUM_MONITOR_MODE_PROPERTIES = 2; + + /** WARNING: must be synchronized with ScreenMode.h, native implementation + * count + all the above + */ + public static final int NUM_MONITOR_MODE_PROPERTIES_ALL = 8; + + public static final int IDX_MONITOR_MODE_BPP = 1 // count + + MonitorModeProps.NUM_RESOLUTION_PROPERTIES + ; + public static final int IDX_MONITOR_MODE_ROT = 1 // count + + MonitorModeProps.NUM_RESOLUTION_PROPERTIES + + MonitorModeProps.NUM_SURFACE_SIZE_PROPERTIES + + MonitorModeProps.NUM_SIZEANDRATE_PROPERTIES + + 1 // id of MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES + ; + + /** WARNING: must be synchronized with ScreenMode.h, native implementation + * 10: count + id, ScreenSizeMM[width, height], rotated Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ + */ + public static final int MIN_MONITOR_DEVICE_PROPERTIES = 11; + + public static final int IDX_MONITOR_DEVICE_VIEWPORT = 1 // count + + 1 // native mode + + MonitorModeProps.NUM_RESOLUTION_PROPERTIES // sizeMM + ; + + public static class Cache { + public final ArrayHashSet resolutions = new ArrayHashSet(); + public final ArrayHashSet surfaceSizes = new ArrayHashSet(); + public final ArrayHashSet sizeAndRates = new ArrayHashSet(); + public final ArrayHashSet monitorModes = new ArrayHashSet(); + public final ArrayHashSet monitorDevices = new ArrayHashSet(); + } + + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ + private static DimensionImmutable streamInResolution(int[] resolutionProperties, int offset) { + Dimension resolution = new Dimension(resolutionProperties[offset++], resolutionProperties[offset++]); + return resolution; + } + + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ + private static SurfaceSize streamInSurfaceSize(DimensionImmutable resolution, int[] sizeProperties, int offset) { + SurfaceSize surfaceSize = new SurfaceSize(resolution, sizeProperties[offset++]); + return surfaceSize; + } + + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ + private static MonitorMode.SizeAndRRate streamInSizeAndRRate(SurfaceSize surfaceSize, int[] sizeAndRRateProperties, int offset) { + final float refreshRate = sizeAndRRateProperties[offset++]/100.0f; + final int flags = sizeAndRRateProperties[offset++]; + return new MonitorMode.SizeAndRRate(surfaceSize, refreshRate, flags); + } + + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ + private static MonitorMode streamInMonitorMode0(MonitorMode.SizeAndRRate sizeAndRate, int[] modeProperties, int offset) { + final int id = modeProperties[offset++]; + final int rotation = modeProperties[offset++]; + return new MonitorMode(id, sizeAndRate, rotation); + } + + /** + * WARNING: must be synchronized with ScreenMode.h, native implementation + * + * @param mode_idx if not null and cache is given, returns the index of resulting {@link MonitorMode} within {@link Cache#monitorModes}. + * @param cache optional hash arrays of unique {@link MonitorMode} components and {@link MonitorDevice}s, allowing to avoid duplicates + * @param modeProperties the input data + * @param offset the offset to the input data + * @return {@link MonitorMode} of the identical (old or new) element in {@link Cache#monitorModes}, + * matching the input modeProperties, or null if input could not be processed. + */ + public static MonitorMode streamInMonitorMode(int[] mode_idx, Cache cache, + int[] modeProperties, int offset) { + final int count = modeProperties[offset]; + if(NUM_MONITOR_MODE_PROPERTIES_ALL != count) { + throw new RuntimeException("property count should be "+NUM_MONITOR_MODE_PROPERTIES_ALL+", but is "+count+", len "+(modeProperties.length-offset)); + } + if(NUM_MONITOR_MODE_PROPERTIES_ALL > modeProperties.length-offset) { + throw new RuntimeException("properties array too short, should be >= "+NUM_MONITOR_MODE_PROPERTIES_ALL+", is "+(modeProperties.length-offset)); + } + offset++; + DimensionImmutable resolution = MonitorModeProps.streamInResolution(modeProperties, offset); + offset += MonitorModeProps.NUM_RESOLUTION_PROPERTIES; + if(null!=cache) { + resolution = cache.resolutions.getOrAdd(resolution); + } + + SurfaceSize surfaceSize = MonitorModeProps.streamInSurfaceSize(resolution, modeProperties, offset); + offset += MonitorModeProps.NUM_SURFACE_SIZE_PROPERTIES; + if(null!=cache) { + surfaceSize = cache.surfaceSizes.getOrAdd(surfaceSize); + } + + MonitorMode.SizeAndRRate sizeAndRate = MonitorModeProps.streamInSizeAndRRate(surfaceSize, modeProperties, offset); + offset += MonitorModeProps.NUM_SIZEANDRATE_PROPERTIES; + if(null!=cache) { + sizeAndRate = cache.sizeAndRates.getOrAdd(sizeAndRate); + } + + MonitorMode monitorMode = MonitorModeProps.streamInMonitorMode0(sizeAndRate, modeProperties, offset); + if(null!=cache) { + monitorMode = cache.monitorModes.getOrAdd(monitorMode); + } + if( null != mode_idx && null!=cache) { + int _modeIdx = cache.monitorModes.indexOf(monitorMode); + if( 0 > _modeIdx ) { + throw new InternalError("Invalid index of current unified mode "+monitorMode); + } + mode_idx[0] = _modeIdx; + } + return monitorMode; + } + + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ + public static int[] streamOutMonitorMode (MonitorMode monitorMode) { + int[] data = new int[NUM_MONITOR_MODE_PROPERTIES_ALL]; + int idx=0; + data[idx++] = NUM_MONITOR_MODE_PROPERTIES_ALL; + data[idx++] = monitorMode.getSurfaceSize().getResolution().getWidth(); + data[idx++] = monitorMode.getSurfaceSize().getResolution().getHeight(); + data[idx++] = monitorMode.getSurfaceSize().getBitsPerPixel(); + data[idx++] = (int)(monitorMode.getRefreshRate()*100.0f); // Hz*100 + data[idx++] = monitorMode.getFlags(); + data[idx++] = monitorMode.getId(); + data[idx++] = monitorMode.getRotation(); + if(NUM_MONITOR_MODE_PROPERTIES_ALL != idx) { + throw new InternalError("wrong number of attributes: got "+idx+" != should "+NUM_MONITOR_MODE_PROPERTIES_ALL); + } + return data; + } + + /** + * WARNING: must be synchronized with ScreenMode.h, native implementation + *

    + * Note: This variant only works for impl. w/ a unique mode key pair modeId, rotation. + *

    + * @param mode_idx if not null, returns the index of resulting {@link MonitorDevice} within {@link Cache#monitorDevices}. + * @param cache hash arrays of unique {@link MonitorMode} components and {@link MonitorDevice}s, allowing to avoid duplicates + * @param modeProperties the input data + * @param offset the offset to the input data + * @return {@link MonitorDevice} of the identical (old or new) element in {@link Cache#monitorDevices}, + * matching the input modeProperties, or null if input could not be processed. + */ + public static MonitorDevice streamInMonitorDevice(int[] monitor_idx, Cache cache, ScreenImpl screen, int[] monitorProperties, int offset) { + // min 11: count, id, ScreenSizeMM[width, height], Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ + final int count = monitorProperties[offset]; + if(MIN_MONITOR_DEVICE_PROPERTIES > count) { + throw new RuntimeException("property count should be >= "+MIN_MONITOR_DEVICE_PROPERTIES+", but is "+count+", len "+(monitorProperties.length-offset)); + } + if(MIN_MONITOR_DEVICE_PROPERTIES > monitorProperties.length-offset) { + throw new RuntimeException("properties array too short (min), should be >= "+MIN_MONITOR_DEVICE_PROPERTIES+", is "+(monitorProperties.length-offset)); + } + if(count > monitorProperties.length-offset) { + throw new RuntimeException("properties array too short (count), should be >= "+count+", is "+(monitorProperties.length-offset)); + } + final int limit = offset + count; + offset++; + final List allMonitorModes = cache.monitorModes.getData(); + final int id = monitorProperties[offset++]; + final DimensionImmutable sizeMM = streamInResolution(monitorProperties, offset); offset+=NUM_RESOLUTION_PROPERTIES; + final Rectangle viewport = new Rectangle(monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++]); + final MonitorMode currentMode; + { + final int modeId = monitorProperties[offset++]; + final int rotation = monitorProperties[offset++]; + currentMode = getByNativeIdAndRotation(allMonitorModes, modeId, rotation); + } + final ArrayHashSet supportedModes = new ArrayHashSet(); + while( offset < limit ) { + final int modeId = monitorProperties[offset++]; + for (int i=0; i _monitorIdx ) { + throw new InternalError("Invalid index of current unified mode "+monitorDevice); + } + monitor_idx[0] = _monitorIdx; + } + return monitorDevice; + } + private static MonitorMode getByNativeIdAndRotation(List monitorModes, int modeId, int rotation) { + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; i + * This variant expects count to be {@link MIN_MONITOR_DEVICE_PROPERTIES} - 1 - {@link NUM_MONITOR_MODE_PROPERTIES}, + * due to lack of supported mode and current mode. + *

    + * + * @param mode_idx if not null, returns the index of resulting {@link MonitorDevice} within {@link Cache#monitorDevices}. + * @param cache hash arrays of unique {@link MonitorMode} components and {@link MonitorDevice}s, allowing to avoid duplicates + * @param supportedModes pre-assembled list of supported {@link MonitorMode}s from cache. + * @param currentMode pre-fetched current {@link MonitorMode}s from cache. + * @param modeProperties the input data minus supported modes! + * @param offset the offset to the input data + * @return {@link MonitorDevice} of the identical (old or new) element in {@link Cache#monitorDevices}, + * matching the input modeProperties, or null if input could not be processed. + */ + public static MonitorDevice streamInMonitorDevice(int[] monitor_idx, Cache cache, ScreenImpl screen, ArrayHashSet supportedModes, MonitorMode currentMode, int[] monitorProperties, int offset) { + // min 11: count, id, ScreenSizeMM[width, height], Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ + final int count = monitorProperties[offset]; + if(MIN_MONITOR_DEVICE_PROPERTIES - 1 - NUM_MONITOR_MODE_PROPERTIES != count) { + throw new RuntimeException("property count should be == "+(MIN_MONITOR_DEVICE_PROPERTIES-1-NUM_MONITOR_MODE_PROPERTIES)+", but is "+count+", len "+(monitorProperties.length-offset)); + } + if(MIN_MONITOR_DEVICE_PROPERTIES - 1 - NUM_MONITOR_MODE_PROPERTIES > monitorProperties.length-offset) { + throw new RuntimeException("properties array too short (min), should be >= "+(MIN_MONITOR_DEVICE_PROPERTIES-1-NUM_MONITOR_MODE_PROPERTIES)+", is "+(monitorProperties.length-offset)); + } + if(count > monitorProperties.length-offset) { + throw new RuntimeException("properties array too short (count), should be >= "+count+", is "+(monitorProperties.length-offset)); + } + offset++; + final int id = monitorProperties[offset++]; + final DimensionImmutable sizeMM = streamInResolution(monitorProperties, offset); offset+=NUM_RESOLUTION_PROPERTIES; + final Rectangle viewport = new Rectangle(monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++]); + MonitorDevice monitorDevice = new MonitorDeviceImpl(screen, id, sizeMM, viewport, currentMode, supportedModes); + if(null!=cache) { + monitorDevice = cache.monitorDevices.getOrAdd(monitorDevice); + } + if( null != monitor_idx ) { + int _monitorIdx = cache.monitorDevices.indexOf(monitorDevice); + if( 0 > _monitorIdx ) { + throw new InternalError("Invalid index of current unified mode "+monitorDevice); + } + monitor_idx[0] = _monitorIdx; + } + return monitorDevice; + } + + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ + public static int[] streamOutMonitorDevice (MonitorDevice monitorDevice) { + // min 11: count, id, ScreenSizeMM[width, height], Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ + int supportedModeCount = monitorDevice.getSupportedModes().size(); + if( 0 == supportedModeCount ) { + throw new RuntimeException("no supported modes: "+monitorDevice); + } + int[] data = new int[MIN_MONITOR_DEVICE_PROPERTIES + supportedModeCount - 1]; + int idx=0; + data[idx++] = data.length; + data[idx++] = monitorDevice.getId(); + data[idx++] = monitorDevice.getSizeMM().getWidth(); + data[idx++] = monitorDevice.getSizeMM().getHeight(); + data[idx++] = monitorDevice.getViewport().getX(); + data[idx++] = monitorDevice.getViewport().getY(); + data[idx++] = monitorDevice.getViewport().getWidth(); + data[idx++] = monitorDevice.getViewport().getHeight(); + data[idx++] = monitorDevice.getCurrentMode().getId(); + data[idx++] = monitorDevice.getCurrentMode().getRotation(); + final List supportedModes = monitorDevice.getSupportedModes(); + for(int i=0; i monitors) { + return false; // nop + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { sizeChanged(false, width, height, false); if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 1282e5dc5..4d20fdb83 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -43,22 +43,19 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.Point; -import javax.media.nativewindow.util.SurfaceSize; - +import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.RectangleImmutable; import com.jogamp.common.util.ArrayHashSet; -import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; -import com.jogamp.newt.util.MonitorMode; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; -public abstract class ScreenImpl extends Screen implements ScreenModeListener { +public abstract class ScreenImpl extends Screen implements MonitorModeListener { protected static final boolean DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true); public static final int default_sm_bpp = 32; @@ -73,11 +70,11 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { protected int hashCode; protected AbstractGraphicsScreen aScreen; protected int refCount; // number of Screen references by Window - protected Point vOrigin = new Point(0, 0); // virtual top-left origin - protected Dimension vSize = new Dimension(0, 0); // virtual rotated screen size + protected Rectangle vOriginSize = new Rectangle(0, 0, 0, 0); // virtual rotated screen origin and size protected static Dimension usrSize = null; // property values: newt.ws.swidth and newt.ws.sheight protected static volatile boolean usrSizeQueried = false; - private ArrayList referencedScreenModeListener = new ArrayList(); + private ArrayList referencedScreenModeListener = new ArrayList(); + private long tCreated; // creationTime static { @@ -160,10 +157,12 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { return true; } + @Override public int hashCode() { return hashCode; } + @Override public synchronized final void createNative() throws NativeWindowException { @@ -182,8 +181,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { throw new NativeWindowException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen"); } - initScreenModeStatus(); - updateVirtualScreenOriginAndSize(); + initScreenMonitorState(); if(DEBUG) { System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+"), total "+ (System.nanoTime()-tCreated)/1e6 +"ms"); } @@ -191,10 +189,11 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { screensActive++; } } - ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName()); + ScreenMonitorState sms = ScreenMonitorState.getScreenMonitorState(this.getFQName()); sms.addListener(this); } + @Override public synchronized final void destroy() { releaseScreenModeStatus(); @@ -213,6 +212,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { display.removeReference(); } + @Override public synchronized final int addReference() throws NativeWindowException { if(DEBUG) { System.err.println("Screen.addReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount+1)); @@ -227,6 +227,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { return ++refCount; } + @Override public synchronized final int removeReference() { if(DEBUG) { System.err.println("Screen.removeReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount-1)); @@ -240,6 +241,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { return refCount; } + @Override public synchronized final int getReferenceCount() { return refCount; } @@ -259,14 +261,20 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { /** * Stores the virtual origin and virtual rotated screen size. *

    - * This method is called after the ScreenMode has been set, + * This method is called after the ScreenMode has been set or changed, * hence you may utilize it. - *

    - * @param virtualOrigin the store for the virtual origin - * @param virtualSize the store for the virtual rotated size + *

    + *

    + * Default implementation uses the union of all monitor's viewport, + * calculated via {@link #unionOfMonitorViewportSize()}. + *

    + * @param vOriginSize storage for result */ - protected abstract void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize); + protected void calcVirtualScreenOriginAndSize(final Rectangle vOriginSize) { + unionOfMonitorViewportSize(vOriginSize); + } + @Override public final String getFQName() { return fqname; } @@ -275,258 +283,227 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { * Updates the rotated virtual ScreenSize using the native impl. */ protected void updateVirtualScreenOriginAndSize() { - getVirtualScreenOriginAndSize(vOrigin, vSize); - if(DEBUG) { - System.err.println("Detected virtual screen origin "+vOrigin+", size "+vSize); + if(null != usrSize ) { + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(usrSize.getWidth()); + vOriginSize.setHeight(usrSize.getHeight()); + if(DEBUG) { + System.err.println("User virtual screen viewport "+vOriginSize); + } + } else { + calcVirtualScreenOriginAndSize(vOriginSize); + if(DEBUG) { + System.err.println("Detected virtual screen viewport "+vOriginSize); + } } } + @Override public final Display getDisplay() { return display; } + @Override public final int getIndex() { return screen_idx; } + @Override public final AbstractGraphicsScreen getGraphicsScreen() { return aScreen; } + @Override public synchronized final boolean isNativeValid() { return null != aScreen; } - public int getX() { return vOrigin.getX(); } - public int getY() { return vOrigin.getY(); } - - public final int getWidth() { - return (null != usrSize) ? usrSize.getWidth() : vSize.getWidth(); - } - - public final int getHeight() { - return (null != usrSize) ? usrSize.getHeight() : vSize.getHeight(); - } + @Override + public final int getX() { return vOriginSize.getX(); } + @Override + public final int getY() { return vOriginSize.getY(); } + @Override + public final int getWidth() { return vOriginSize.getWidth(); } + @Override + public final int getHeight() { return vOriginSize.getHeight(); } + @Override + public final RectangleImmutable getViewport() { return vOriginSize; } @Override public String toString() { - return "NEWT-Screen["+getFQName()+", idx "+screen_idx+", refCount "+refCount+", "+getWidth()+"x"+getHeight()+", "+aScreen+", "+display+"]"; + return "NEWT-Screen["+getFQName()+", idx "+screen_idx+", refCount "+refCount+", vsize "+vOriginSize+", "+aScreen+", "+display+ + ", monitors: "+getMonitorDevices()+"]"; } - public final List getScreenModes() { - ArrayHashSet screenModes = getScreenModesOrig(); - if(null != screenModes && 0 < screenModes.size()) { - return screenModes.toArrayList(); - } - return null; + // + // MonitorDevice and MonitorMode + // + + /** + * To be implemented by the native specification.
    + * Is called within a thread safe environment.
    + * Is called only to collect the {@link MonitorMode}s and {@link MonitorDevice}s, usually at startup setting up modes.
    + *
    + * WARNING: must be synchronized with + *
      + *
    • {@link MonitorModeProps#NUM_SCREEN_MODE_PROPERTIES} and
    • + *
    • {@link MonitorModeProps#MIN_MONITOR_DEVICE_PROPERTIES}
    • + *
    , i.e. + *
      + *
    • {@link MonitorModeProps#streamInMonitorDevice(int[], jogamp.newt.MonitorModeProps.Cache, ScreenImpl, int[], int)}
    • + *
    • {@link MonitorModeProps#streamInMonitorDevice(int[], jogamp.newt.MonitorModeProps.Cache, ScreenImpl, ArrayHashSet, int[], int)}
    • + *
    • {@link MonitorModeProps#streamInMonitorMode(int[], jogamp.newt.MonitorModeProps.Cache, int[], int)}
    • + *
    + * @param cache memory pool caching the result + */ + protected abstract void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache); + + protected Rectangle getNativeMonitorDeviceViewportImpl(MonitorDevice monitor) { return null; } + + /** + * To be implemented by the native specification.
    + * Is called within a thread safe environment.
    + *

    + * Implementation shall not unify the result w/ monitor's supported modes or a locally + * saved {@link MonitorModeProps.Cache}, since caller will perform such tasks. + *

    + */ + protected abstract MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor); + + /** + * To be implemented by the native specification.
    + * Is called within a thread safe environment.
    + */ + protected abstract boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode); + + @Override + public final List getMonitorModes() { + final ScreenMonitorState sms = getScreenMonitorStatus(false); + return null != sms ? sms.getMonitorModes().getData() : null; + } + + @Override + public final List getMonitorDevices() { + final ScreenMonitorState sms = getScreenMonitorStatus(false); + return null != sms ? sms.getMonitorDevices().getData() : null; } - private final ScreenModeStatus getScreenModeStatus(boolean throwException) { + final ScreenMonitorState getScreenMonitorStatus(boolean throwException) { final String key = this.getFQName(); - final ScreenModeStatus res = ScreenModeStatus.getScreenModeStatus(key); + final ScreenMonitorState res = ScreenMonitorState.getScreenMonitorState(key); if(null == res & throwException) { - throw new InternalError("ScreenModeStatus.getScreenModeStatus("+key+") == null"); + throw new InternalError("ScreenMonitorStatus.getScreenModeStatus("+key+") == null"); } return res; } - public ScreenMode getOriginalScreenMode() { - final ScreenModeStatus sms = getScreenModeStatus(false); - return ( null != sms ) ? sms.getOriginalScreenMode() : null ; - } - - public ScreenMode getCurrentScreenMode() { - ScreenMode smU = null; - final ScreenModeStatus sms = getScreenModeStatus(true); - final ScreenMode sm0 = getCurrentScreenModeIntern(); - if(null == sm0) { - throw new InternalError("getCurrentScreenModeImpl() == null"); + @Override + public void monitorModeChangeNotify(MonitorEvent me) { + if(DEBUG) { + System.err.println("monitorModeChangeNotify: "+me); } - sms.lock(); - try { - smU = sms.getScreenModes().getOrAdd(sm0); // unified instance, maybe new - - // if mode has changed somehow, update it .. - if( sms.getCurrentScreenMode().hashCode() != smU.hashCode() ) { - sms.fireScreenModeChanged(smU, true); - } - } finally { - sms.unlock(); + for(int i=0; i monitors = getMonitorDevices(); + for(int i=monitors.size()-1; i>=0; i--) { + final MonitorDeviceImpl monitor = (MonitorDeviceImpl) monitors.get(i); + final Rectangle newViewport = getNativeMonitorDeviceViewportImpl(monitor); + if( DEBUG ) { + System.err.println("Screen.updateMonitorViewport["+i+"]: "+monitor.getViewport()+" -> "+newViewport); } - - sms.fireScreenModeChangeNotify(smU); - if(DEBUG) { - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): fireScreenModeChangeNotify() "+smU); + if( null != newViewport ) { + monitor.setViewportValue(newViewport); } - - success = setCurrentScreenModeImpl(smU); - if(success) { - if(DEBUG) { - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+smU+", success(1): "+success); - } - } else { - // 2nd attempt validate! - final ScreenMode queriedCurrent = getCurrentScreenMode(); // may fireScreenModeChanged(..) if successful and differs! - final ScreenMode smsCurrent = sms.getCurrentScreenMode(); - success = smsCurrent.hashCode() == smU.hashCode() && queriedCurrent.hashCode() == smU.hashCode() ; - if(DEBUG) { - System.err.println("Screen.setCurrentScreenMode.2: queried "+queriedCurrent); - System.err.println("Screen.setCurrentScreenMode.2: SMS "+smsCurrent); - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+smU+", success(2): "+success); - } - } - sms.fireScreenModeChanged(smU, success); - if(DEBUG) { - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): X.X "+smU+", success: "+success); - } - } finally { - sms.unlock(); - } - return success; + } } - - public void screenModeChangeNotify(ScreenMode sm) { - for(int i=0; i getScreenModesOrig() { - ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName()); - if(null!=sms) { - return sms.getScreenModes(); - } - return null; - } - - /** ScreenModeStatus bridge to native implementation */ - protected final IntIntHashMap getScreenModesIdx2NativeIdx() { - ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName()); - if(null!=sms) { - return sms.getScreenModesIdx2NativeIdx(); - } - return null; - } - - /** - * To be implemented by the native specification.
    - * Is called within a thread safe environment.
    - * Is called only to collect the ScreenModes, usually at startup setting up modes.
    - *
    - * WARNING: must be synchronized with {@link com.jogamp.newt.util.ScreenModeUtil#NUM_SCREEN_MODE_PROPERTIES}, - * ie {@link com.jogamp.newt.util.ScreenModeUtil#streamIn(com.jogamp.common.util.ArrayHashSet, com.jogamp.common.util.ArrayHashSet, com.jogamp.common.util.ArrayHashSet, com.jogamp.common.util.ArrayHashSet, int[], int)}
    - *
    - * Note: Additional 1st element is native mode id. - */ - protected int[] getScreenModeFirstImpl() { - return null; - } - - /** - * To be implemented by the native specification.
    - * Is called within a thread safe environment.
    - * Is called only to collect the ScreenModes, usually at startup setting up modes.
    - *
    - * WARNING: must be synchronized with {@link com.jogamp.newt.util.ScreenModeUtil#NUM_SCREEN_MODE_PROPERTIES}, - * ie {@link com.jogamp.newt.util.ScreenModeUtil#streamIn(com.jogamp.common.util.ArrayHashSet, com.jogamp.common.util.ArrayHashSet, com.jogamp.common.util.ArrayHashSet, com.jogamp.common.util.ArrayHashSet, int[], int)}
    - *
    - * Note: Additional 1st element is native mode id. - */ - protected int[] getScreenModeNextImpl() { - return null; + + private final MonitorMode getVirtualMonitorMode(int modeId) { + final int[] props = new int[MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL]; + int i = 0; + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; + props[i++] = getWidth(); // width + props[i++] = getHeight(); // height + props[i++] = default_sm_bpp; + props[i++] = default_sm_rate * 100; + props[i++] = 0; // flags + props[i++] = modeId; + props[i++] = default_sm_rotation; + if( MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL != i ) { + throw new InternalError("XX"); + } + return MonitorModeProps.streamInMonitorMode(null, null, props, 0); } - - /** - * To be implemented by the native specification.
    - * Is called within a thread safe environment.
    - */ - protected ScreenMode getCurrentScreenModeImpl() { - return null; + + private final MonitorDevice getVirtualMonitorDevice(int monitorId, MonitorMode currentMode) { + int[] props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES]; + int i = 0; + props[i++] = MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES; + props[i++] = monitorId; + props[i++] = default_sm_widthmm; + props[i++] = default_sm_heightmm; + props[i++] = 0; // rotated viewport x + props[i++] = 0; // rotated viewport y + props[i++] = currentMode.getRotatedWidth(); // rotated viewport width + props[i++] = currentMode.getRotatedHeight(); // rotated viewport height + props[i++] = currentMode.getId(); // current mode id + props[i++] = currentMode.getRotation(); + props[i++] = currentMode.getId(); // supported mode id #1 + if( MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES != i ) { + throw new InternalError("XX"); + } + return MonitorModeProps.streamInMonitorDevice(null, null, this, props, 0); } /** - * Utilizes {@link #getCurrentScreenModeImpl()}, if the latter returns null it uses + * Utilizes {@link #getCurrentMonitorModeImpl()}, if the latter returns null it uses * the current screen size and dummy values. */ - protected ScreenMode getCurrentScreenModeIntern() { - ScreenMode res; + protected final MonitorMode queryCurrentMonitorModeIntern(MonitorDevice monitor) { + MonitorMode res; if(DEBUG_TEST_SCREENMODE_DISABLED) { res = null; } else { - res = getCurrentScreenModeImpl(); + res = queryCurrentMonitorModeImpl(monitor); } if(null == res) { if( 0>=getWidth() || 0>=getHeight() ) { updateVirtualScreenOriginAndSize(); } - int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; - int i = 0; - props[i++] = 0; // set later for verification of iterator - props[i++] = getWidth(); // width - props[i++] = getHeight(); // height - props[i++] = default_sm_bpp; - props[i++] = default_sm_widthmm; - props[i++] = default_sm_heightmm; - props[i++] = default_sm_rate; - props[i++] = default_sm_rotation; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count - res = ScreenModeUtil.streamIn(props, 0); + res = getVirtualMonitorMode(monitor.getCurrentMode().getId()); } return res; } - /** - * To be implemented by the native specification.
    - * Is called within a thread safe environment.
    - */ - protected boolean setCurrentScreenModeImpl(ScreenMode screenMode) { - return false; - } - - private ScreenModeStatus initScreenModeStatus() { + private final ScreenMonitorState initScreenMonitorState() { long t0; if(DEBUG) { t0 = System.nanoTime(); @@ -535,138 +512,139 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { t0 = 0; } - ScreenModeStatus sms; - ScreenModeStatus.lockScreenModeStatus(); + boolean vScrnSizeUpdated = false; + ScreenMonitorState sms; + ScreenMonitorState.lockScreenMonitorState(); try { - sms = ScreenModeStatus.getScreenModeStatus(this.getFQName()); - if(null==sms) { - IntIntHashMap screenModesIdx2NativeIdx = new IntIntHashMap(); - final ScreenMode currentSM = getCurrentScreenModeIntern(); - if(null == currentSM) { - throw new InternalError("getCurrentScreenModeImpl() == null"); + sms = ScreenMonitorState.getScreenMonitorState(this.getFQName()); + if(null==sms) { + final MonitorModeProps.Cache cache = new MonitorModeProps.Cache(); + if( 0 >= collectNativeMonitorModes(cache) ) { + updateVirtualScreenOriginAndSize(); + vScrnSizeUpdated = true; + final MonitorMode mode = getVirtualMonitorMode(0); + cache.monitorModes.getOrAdd(mode); + final MonitorDevice monitor = getVirtualMonitorDevice(0, mode); + cache.monitorDevices.getOrAdd(monitor); } - - ArrayHashSet screenModes = collectNativeScreenModes(screenModesIdx2NativeIdx); - screenModes.getOrAdd(currentSM); if(DEBUG) { int i=0; - for(Iterator iter=screenModes.iterator(); iter.hasNext(); i++) { - System.err.println(i+": "+iter.next()); + for(Iterator iMode=cache.monitorModes.iterator(); iMode.hasNext(); i++) { + System.err.println("All["+i+"]: "+iMode.next()); + } + i=0; + for(Iterator iMonitor=cache.monitorDevices.iterator(); iMonitor.hasNext(); i++) { + final MonitorDevice crt = iMonitor.next(); + System.err.println("["+i+"]: "+crt); + int j=0; + for(Iterator iMode=crt.getSupportedModes().iterator(); iMode.hasNext(); j++) { + System.err.println("["+i+"]["+j+"]: "+iMode.next()); + } } } - - sms = new ScreenModeStatus(screenModes, screenModesIdx2NativeIdx); - ScreenMode originalScreenMode0 = screenModes.get(currentSM); // unify via value hash - if(null == originalScreenMode0) { - throw new RuntimeException(currentSM+" could not be hashed from ScreenMode list"); - } - sms.setOriginalScreenMode(originalScreenMode0); - ScreenModeStatus.mapScreenModeStatus(this.getFQName(), sms); + sms = new ScreenMonitorState(cache.monitorDevices, cache.monitorModes); + ScreenMonitorState.mapScreenMonitorState(this.getFQName(), sms); } } finally { - ScreenModeStatus.unlockScreenModeStatus(); + ScreenMonitorState.unlockScreenMonitorState(); } if(DEBUG) { System.err.println("Screen.initScreenModeStatus() END dt "+ (System.nanoTime()-t0)/1e6 +"ms"); } + if( !vScrnSizeUpdated ) { + updateVirtualScreenOriginAndSize(); + } + return sms; } - /** ignores bpp < 15 */ - private ArrayHashSet collectNativeScreenModes(IntIntHashMap screenModesIdx2NativeId) { - ArrayHashSet resolutionPool = new ArrayHashSet(); - ArrayHashSet surfaceSizePool = new ArrayHashSet(); - ArrayHashSet screenSizeMMPool = new ArrayHashSet(); - ArrayHashSet monitorModePool = new ArrayHashSet(); - ArrayHashSet screenModePool = new ArrayHashSet(); - - int[] smProps = null; - int num = 0; - final int idxBpp = 1 // native mode - + 1 // count - + ScreenModeUtil.NUM_RESOLUTION_PROPERTIES - + ScreenModeUtil.NUM_SURFACE_SIZE_PROPERTIES - - 1 ; // index 0 based - do { - if(DEBUG_TEST_SCREENMODE_DISABLED) { - smProps = null; - } else if(0 == num) { - smProps = getScreenModeFirstImpl(); - } else { - smProps = getScreenModeNextImpl(); - } - if(null != smProps && 0 < smProps.length && smProps[idxBpp] >= 15) { - int nativeId = smProps[0]; - int screenModeIdx = ScreenModeUtil.streamIn(resolutionPool, surfaceSizePool, screenSizeMMPool, - monitorModePool, screenModePool, smProps, 1); - if(DEBUG) { - System.err.println("ScreenImpl.collectNativeScreenModes: #"+num+": idx: "+nativeId+" native -> "+screenModeIdx+" newt"); + /** + * Returns the number of successful collected {@link MonitorDevice}s. + *

    + * Collects {@link MonitorDevice}s and {@link MonitorMode}s within the given cache. + *

    + */ + private final int collectNativeMonitorModes(MonitorModeProps.Cache cache) { + if(!DEBUG_TEST_SCREENMODE_DISABLED) { + collectNativeMonitorModesAndDevicesImpl(cache); + } + // filter out insufficient modes + for(int i=cache.monitorModes.size()-1; i>=0; i--) { + final MonitorMode mode = cache.monitorModes.get(i); + if( 16 > mode.getSurfaceSize().getBitsPerPixel() ) { + boolean keep = false; + for(int j=cache.monitorDevices.size()-1; !keep && j>=0; j--) { + final MonitorDevice monitor = cache.monitorDevices.get(j); + keep = monitor.getCurrentMode().equals(mode); } - - if(screenModeIdx >= 0) { - screenModesIdx2NativeId.put(screenModeIdx, nativeId); + if(!keep) { + cache.monitorModes.remove(i); + for(int j=cache.monitorDevices.size()-1; j>=0; j--) { + final MonitorDeviceImpl monitor = (MonitorDeviceImpl) cache.monitorDevices.get(j); + monitor.getSupportedModesImpl().remove(mode); + } } - } else if(DEBUG) { - System.err.println("ScreenImpl.collectNativeScreenModes: #"+num+": smProps: "+(null!=smProps)+ - ", len: "+(null != smProps ? smProps.length : 0)+ - ", bpp: "+(null != smProps && 0 < smProps.length ? smProps[idxBpp] : 0)+ - " - DROPPING"); } - num++; - } while ( null != smProps && 0 < smProps.length ); - - if(DEBUG) { - System.err.println("ScreenImpl.collectNativeScreenModes: ScreenMode number : "+screenModePool.size()); - System.err.println("ScreenImpl.collectNativeScreenModes: MonitorMode number : "+monitorModePool.size()); - System.err.println("ScreenImpl.collectNativeScreenModes: ScreenSizeMM number: "+screenSizeMMPool.size()); - System.err.println("ScreenImpl.collectNativeScreenModes: SurfaceSize number : "+surfaceSizePool.size()); - System.err.println("ScreenImpl.collectNativeScreenModes: Resolution number : "+resolutionPool.size()); } - - return screenModePool; + if( DEBUG ) { + System.err.println("ScreenImpl.collectNativeMonitorModes: MonitorDevice number : "+cache.monitorDevices.size()); + System.err.println("ScreenImpl.collectNativeMonitorModes: MonitorMode number : "+cache.monitorModes.size()); + System.err.println("ScreenImpl.collectNativeMonitorModes: SizeAndRate number : "+cache.sizeAndRates.size()); + System.err.println("ScreenImpl.collectNativeMonitorModes: SurfaceSize number : "+cache.surfaceSizes.size()); + System.err.println("ScreenImpl.collectNativeMonitorModes: Resolution number : "+cache.resolutions.size()); + } + return cache.monitorDevices.size(); } private void releaseScreenModeStatus() { - ScreenModeStatus sms; - ScreenModeStatus.lockScreenModeStatus(); + ScreenMonitorState sms; + ScreenMonitorState.lockScreenMonitorState(); try { - sms = ScreenModeStatus.getScreenModeStatus(getFQName()); + sms = ScreenMonitorState.getScreenMonitorState(getFQName()); if(null != sms) { sms.lock(); try { if(0 == sms.removeListener(this)) { - if(sms.isOriginalModeChangedByOwner()) { - System.err.println("Screen.destroy(): "+sms.getCurrentScreenMode()+" -> "+sms.getOriginalScreenMode()); - try { - setCurrentScreenMode(sms.getOriginalScreenMode()); - } catch (Throwable t) { - // be verbose but continue - t.printStackTrace(); + final ArrayList monitorDevices = sms.getMonitorDevices().getData(); + for(int i=0; i "+sms.getOriginalScreenMode()); - setCurrentScreenModeImpl(sms.getOriginalScreenMode()); - } catch (Throwable t) { - // be quiet .. shutdown + final ArrayList monitorDevices = sms.getMonitorDevices().getData(); + for(int i=0; i screenModes; - private IntIntHashMap screenModesIdx2NativeIdx; - private ScreenMode currentScreenMode; - private ScreenMode originalScreenMode; - private boolean screenModeChangedByOwner; - private ArrayList listener = new ArrayList(); - - private static HashMap screenFQN2ScreenModeStatus = new HashMap(); - private static RecursiveLock screen2ScreenModeStatusLock = LockFactory.createRecursiveLock(); - - protected static void mapScreenModeStatus(String screenFQN, ScreenModeStatus sms) { - screen2ScreenModeStatusLock.lock(); - try { - ScreenModeStatus _sms = screenFQN2ScreenModeStatus.get(screenFQN); - if( null != _sms ) { - throw new RuntimeException("ScreenModeStatus "+_sms+" already mapped to "+screenFQN); - } - screenFQN2ScreenModeStatus.put(screenFQN, sms); - if(DEBUG) { - System.err.println("ScreenModeStatus.map "+screenFQN+" -> "+sms); - } - } finally { - screen2ScreenModeStatusLock.unlock(); - } - } - - /** - * @param screen the prev user - * @return true if mapping is empty, ie no more usage of the mapped ScreenModeStatus - */ - protected static void unmapScreenModeStatus(String screenFQN) { - screen2ScreenModeStatusLock.lock(); - try { - unmapScreenModeStatusUnlocked(screenFQN); - } finally { - screen2ScreenModeStatusLock.unlock(); - } - } - protected static void unmapScreenModeStatusUnlocked(String screenFQN) { - ScreenModeStatus sms = screenFQN2ScreenModeStatus.remove(screenFQN); - if(DEBUG) { - System.err.println("ScreenModeStatus.unmap "+screenFQN+" -> "+sms); - } - } - - protected static ScreenModeStatus getScreenModeStatus(String screenFQN) { - screen2ScreenModeStatusLock.lock(); - try { - return getScreenModeStatusUnlocked(screenFQN); - } finally { - screen2ScreenModeStatusLock.unlock(); - } - } - protected static ScreenModeStatus getScreenModeStatusUnlocked(String screenFQN) { - return screenFQN2ScreenModeStatus.get(screenFQN); - } - - protected static void lockScreenModeStatus() { - screen2ScreenModeStatusLock.lock(); - } - - protected static void unlockScreenModeStatus() { - screen2ScreenModeStatusLock.unlock(); - } - - public ScreenModeStatus(ArrayHashSet screenModes, - IntIntHashMap screenModesIdx2NativeIdx) { - this.screenModes = screenModes; - this.screenModesIdx2NativeIdx = screenModesIdx2NativeIdx; - this.screenModeChangedByOwner = false; - } - - protected final void setOriginalScreenMode(ScreenMode originalScreenMode) { - this.originalScreenMode = originalScreenMode; - this.currentScreenMode = originalScreenMode; - } - - public final ScreenMode getOriginalScreenMode() { - return originalScreenMode; - } - - public final ScreenMode getCurrentScreenMode() { - lock(); - try { - return currentScreenMode; - } finally { - unlock(); - } - } - - /** - * We cannot guarantee that we won't interfere w/ another running - * application's screen mode change. - *

    - * At least we only return true if the owner, ie. the Screen, - * has changed the screen mode and if the original screen mode - * is not current the current one. - *

    - * @return - */ - public final boolean isOriginalModeChangedByOwner() { - lock(); - try { - return screenModeChangedByOwner && !isCurrentModeOriginalMode(); - } finally { - unlock(); - } - } - - protected final boolean isCurrentModeOriginalMode() { - if(null != currentScreenMode && null != originalScreenMode) { - return currentScreenMode.hashCode() == originalScreenMode.hashCode(); - } - return true; - } - - protected final ArrayHashSet getScreenModes() { - return screenModes; - } - - protected final IntIntHashMap getScreenModesIdx2NativeIdx() { - return screenModesIdx2NativeIdx; - } - - protected final int addListener(ScreenModeListener l) { - lock(); - try { - listener.add(l); - if(DEBUG) { - System.err.println("ScreenModeStatus.addListener (size: "+listener.size()+"): "+l); - } - return listener.size(); - } finally { - unlock(); - } - } - - protected final int removeListener(ScreenModeListener l) { - lock(); - try { - if(!listener.remove(l)) { - throw new RuntimeException("ScreenModeListener "+l+" not contained"); - } - if(DEBUG) { - System.err.println("ScreenModeStatus.removeListener (size: "+listener.size()+"): "+l); - } - return listener.size(); - } finally { - unlock(); - } - } - - protected final void fireScreenModeChangeNotify(ScreenMode desiredScreenMode) { - lock(); - try { - for(int i=0; i allMonitors; + private final ArrayHashSet allMonitorModes; + private ArrayList listener = new ArrayList(); + + private static HashMap screenFQN2ScreenMonitorState = new HashMap(); + private static RecursiveLock screen2ScreenMonitorState = LockFactory.createRecursiveLock(); + + protected static void mapScreenMonitorState(String screenFQN, ScreenMonitorState sms) { + screen2ScreenMonitorState.lock(); + try { + ScreenMonitorState _sms = screenFQN2ScreenMonitorState.get(screenFQN); + if( null != _sms ) { + throw new RuntimeException("ScreenMonitorState "+_sms+" already mapped to "+screenFQN); + } + screenFQN2ScreenMonitorState.put(screenFQN, sms); + if(DEBUG) { + System.err.println("ScreenMonitorState.map "+screenFQN+" -> "+sms); + } + } finally { + screen2ScreenMonitorState.unlock(); + } + } + + /** + * @param screen the prev user + * @return true if mapping is empty, ie no more usage of the mapped ScreenMonitorState + */ + protected static void unmapScreenMonitorState(String screenFQN) { + screen2ScreenMonitorState.lock(); + try { + unmapScreenMonitorStateUnlocked(screenFQN); + } finally { + screen2ScreenMonitorState.unlock(); + } + } + protected static void unmapScreenMonitorStateUnlocked(String screenFQN) { + ScreenMonitorState sms = screenFQN2ScreenMonitorState.remove(screenFQN); + if(DEBUG) { + System.err.println("ScreenMonitorState.unmap "+screenFQN+" -> "+sms); + } + } + + protected static ScreenMonitorState getScreenMonitorState(String screenFQN) { + screen2ScreenMonitorState.lock(); + try { + return getScreenMonitorStateUnlocked(screenFQN); + } finally { + screen2ScreenMonitorState.unlock(); + } + } + protected static ScreenMonitorState getScreenMonitorStateUnlocked(String screenFQN) { + return screenFQN2ScreenMonitorState.get(screenFQN); + } + + protected static void lockScreenMonitorState() { + screen2ScreenMonitorState.lock(); + } + + protected static void unlockScreenMonitorState() { + screen2ScreenMonitorState.unlock(); + } + + public ScreenMonitorState(ArrayHashSet allMonitors, + ArrayHashSet allMonitorModes) { + this.allMonitors = allMonitors; + this.allMonitorModes = allMonitorModes; + } + + protected ArrayHashSet getMonitorDevices() { + return allMonitors; + } + + protected ArrayHashSet getMonitorModes() { + return allMonitorModes; + } + + protected final int addListener(MonitorModeListener l) { + lock(); + try { + listener.add(l); + if(DEBUG) { + System.err.println("ScreenMonitorState.addListener (size: "+listener.size()+"): "+l); + } + return listener.size(); + } finally { + unlock(); + } + } + + protected final int removeListener(MonitorModeListener l) { + lock(); + try { + if(!listener.remove(l)) { + throw new RuntimeException("ScreenModeListener "+l+" not contained"); + } + if(DEBUG) { + System.err.println("ScreenMonitorState.removeListener (size: "+listener.size()+"): "+l); + } + return listener.size(); + } finally { + unlock(); + } + } + + protected final MonitorDevice getMonitor(MonitorDevice monitor) { + return allMonitors.get(monitor); + } + + protected final void validateMonitor(MonitorDevice monitor) { + final MonitorDevice md = allMonitors.get(monitor); + if( null == md ) { + throw new InternalError("Monitor unknown: "+monitor); + } + } + + protected final void fireScreenModeChangeNotify(MonitorDevice monitor, MonitorMode desiredMode) { + lock(); + try { + validateMonitor(monitor); + final MonitorEvent me = new MonitorEvent(MonitorEvent.EVENT_MONITOR_MODE_CHANGE_NOTIFY, monitor, System.currentTimeMillis(), desiredMode); + for(int i=0; i default - private boolean fullscreen = false, brokenFocusChange = false; + private boolean fullscreen = false, brokenFocusChange = false; + private List fullscreenMonitors = null; + private boolean fullscreenUseMainMonitor = true; private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user) private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets @@ -294,19 +298,40 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer screenReferenceAdded = true; } if(canCreateNativeImpl()) { + final int wX, wY; + final boolean usePosition; + if( autoPosition ) { + wX = 0; + wY = 0; + usePosition = false; + } else { + wX = getX(); + wY = getY(); + usePosition = true; + } + final long t0 = System.currentTimeMillis(); createNativeImpl(); - screen.addScreenModeListener(screenModeListenerImpl); + screen.addMonitorModeListener(screenModeListenerImpl); setTitleImpl(title); setPointerVisibleImpl(pointerVisible); confinePointerImpl(pointerConfined); setKeyboardVisible(keyboardVisible); - if(waitForVisible(true, false)) { + final long remainingV = waitForVisible(true, false); + if( 0 <= remainingV ) { if(isFullscreen()) { synchronized(fullScreenAction) { fullscreen = false; // trigger a state change - fullScreenAction.init(true); + fullScreenAction.init(true, fullscreenUseMainMonitor, fullscreenMonitors); + fullscreenMonitors = null; // release references ASAP + fullscreenUseMainMonitor = true; fullScreenAction.run(); } + } else { + // Wait until position is reached within tolerances, either auto-position or custom position. + waitForPosition(usePosition, wX, wY, Window.TIMEOUT_NATIVEWINDOW); + } + if (DEBUG_IMPLEMENTATION) { + System.err.println("Window.createNative(): elapsed "+(System.currentTimeMillis()-t0)+" ms"); } postParentlockFocus = true; } @@ -463,8 +488,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public static final int FLAG_HAS_PARENT = 1 << 8; public static final int FLAG_IS_UNDECORATED = 1 << 9; public static final int FLAG_IS_FULLSCREEN = 1 << 10; - public static final int FLAG_IS_ALWAYSONTOP = 1 << 11; - public static final int FLAG_IS_VISIBLE = 1 << 12; + public static final int FLAG_IS_FULLSCREEN_SPAN = 1 << 11; + public static final int FLAG_IS_ALWAYSONTOP = 1 << 12; + public static final int FLAG_IS_VISIBLE = 1 << 13; /** * The native implementation should invoke the referenced java state callbacks @@ -509,6 +535,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } sb.append("FS_"); sb.append(0 != ( FLAG_IS_FULLSCREEN & flags)); + sb.append("_span_"); + sb.append(0 != ( FLAG_IS_FULLSCREEN_SPAN & flags)); sb.append(", "); if( 0 != ( FLAG_CHANGE_DECORATION & flags) ) { @@ -718,6 +746,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return screen; } + @Override + public final MonitorDevice getMainMonitor() { + return screen.getMainMonitor(new Rectangle(getX(), getY(), getWidth(), getHeight())); + } + protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) { reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible)); } @@ -904,7 +937,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if( isNativeValid() ) { - screen.removeScreenModeListener(screenModeListenerImpl); + screen.removeMonitorModeListener(screenModeListenerImpl); closeNativeImpl(); final AbstractGraphicsDevice cfgADevice = config.getScreen().getDevice(); if( cfgADevice != screen.getDisplay().getGraphicsDevice() ) { // don't pull display's device @@ -929,6 +962,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer setWindowHandle(0); visible = false; fullscreen = false; + fullscreenMonitors = null; + fullscreenUseMainMonitor = true; hasFocus = false; parentWindowHandle = 0; @@ -1212,7 +1247,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer display.dispatchMessagesNative(); // status up2date if(wasVisible) { setVisibleImpl(true, x, y, width, height); - ok = WindowImpl.this.waitForVisible(true, false); + ok = 0 <= WindowImpl.this.waitForVisible(true, false); if(ok) { ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); } @@ -1735,6 +1770,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(isNativeValid()) { // this.x/this.y will be set by sizeChanged, triggered by windowing event system reconfigureWindowImpl(x, y, getWidth(), getHeight(), getReconfigureFlags(0, isVisible())); + + // Wait until custom position is reached within tolerances + waitForPosition(true, x, y, Window.TIMEOUT_NATIVEWINDOW); } else { definePosition(x, y); // set pos for createNative(..) } @@ -1758,13 +1796,25 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class FullScreenAction implements Runnable { boolean fullscreen; + List monitors; + boolean useMainMonitor; - private boolean init(boolean fullscreen) { + private boolean init(boolean fullscreen, boolean useMainMonitor, List monitors) { if(isNativeValid()) { this.fullscreen = fullscreen; - return isFullscreen() != fullscreen; + if( isFullscreen() != fullscreen ) { + this.monitors = monitors; + this.useMainMonitor = useMainMonitor; + return true; + } else { + this.monitors = null; + this.useMainMonitor = true; + return false; + } } else { WindowImpl.this.fullscreen = fullscreen; // set current state for createNative(..) + WindowImpl.this.fullscreenMonitors = monitors; + WindowImpl.this.fullscreenUseMainMonitor = useMainMonitor; return false; } } @@ -1777,19 +1827,32 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // set current state WindowImpl.this.fullscreen = fullscreen; - final ScreenMode sm = screen.getCurrentScreenMode(); int x,y,w,h; + final RectangleImmutable viewport; + final int fs_span_flag; if(fullscreen) { + if( null == monitors ) { + if( useMainMonitor ) { + monitors = new ArrayList(); + monitors.add( getMainMonitor() ); + } else { + monitors = getScreen().getMonitorDevices(); + } + } + fs_span_flag = monitors.size() > 1 ? FLAG_IS_FULLSCREEN_SPAN : 0 ; + viewport = MonitorDevice.unionOfViewports(new Rectangle(), monitors); nfs_x = getX(); nfs_y = getY(); nfs_width = getWidth(); nfs_height = getHeight(); - x = screen.getX(); - y = screen.getY(); - w = sm.getRotatedWidth(); - h = sm.getRotatedHeight(); + x = viewport.getX(); + y = viewport.getY(); + w = viewport.getWidth(); + h = viewport.getHeight(); } else { + fs_span_flag = 0; + viewport = null; x = nfs_x; y = nfs_y; w = nfs_width; @@ -1809,9 +1872,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } + monitors = null; // clear references ASAP + useMainMonitor = true; if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ - ", virtl-size: "+screen.getWidth()+"x"+screen.getHeight()+", SM "+sm.getRotatedWidth()+"x"+sm.getRotatedHeight()); + ", virtl-size: "+screen.getWidth()+"x"+screen.getHeight()+", monitorsViewport "+viewport); } DisplayImpl display = (DisplayImpl) screen.getDisplay(); @@ -1831,7 +1896,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer try { reconfigureWindowImpl(x, y, w, h, getReconfigureFlags( ( ( null != parentWindowLocked ) ? FLAG_CHANGE_PARENTING : 0 ) | - FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, wasVisible) ); + fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, wasVisible) ); } finally { if(null!=parentWindowLocked) { parentWindowLocked.unlockSurface(); @@ -1860,8 +1925,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public boolean setFullscreen(boolean fullscreen) { + return setFullscreenImpl(fullscreen, true, null); + } + + @Override + public boolean setFullscreen(List monitors) { + return setFullscreenImpl(true, false, monitors); + } + + private boolean setFullscreenImpl(boolean fullscreen, boolean useMainMonitor, List monitors) { synchronized(fullScreenAction) { - if( fullScreenAction.init(fullscreen) ) { + if( fullScreenAction.init(fullscreen, useMainMonitor, monitors) ) { if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { // enable fullscreen on offscreen instance if(null != parentWindow) { @@ -1887,13 +1961,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return this.fullscreen; } } - - private class ScreenModeListenerImpl implements ScreenModeListener { + + private class ScreenModeListenerImpl implements MonitorModeListener { boolean animatorPaused = false; - public void screenModeChangeNotify(ScreenMode sm) { + public void monitorModeChangeNotify(MonitorEvent me) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.screenModeChangeNotify: "+sm); + System.err.println("Window.screenModeChangeNotify: "+me); } if(null!=lifecycleHook) { @@ -1901,9 +1975,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - public void screenModeChanged(ScreenMode sm, boolean success) { + public void monitorModeChanged(MonitorEvent me, boolean success) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.screenModeChanged: "+sm+", success: "+success); + System.err.println("Window.screenModeChanged: "+me+", success: "+success); } if(success) { @@ -1911,10 +1985,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Didn't pass above notify method. probably detected screen change after it happened. animatorPaused = lifecycleHook.pauseRenderingAction(); } - DimensionImmutable screenSize = sm.getMonitorMode().getSurfaceSize().getResolution(); - if ( getHeight() > screenSize.getHeight() || - getWidth() > screenSize.getWidth() ) { - setSize(screenSize.getWidth(), screenSize.getHeight()); + if( !fullscreen ) { + // FIXME: Need to take all covered monitors into account + final MonitorDevice mainMonitor = getMainMonitor(); + final MonitorDevice eventMonitor = me.getMonitor(); + if( mainMonitor == eventMonitor ) { + final RectangleImmutable rect = new Rectangle(getX(), getY(), getWidth(), getHeight()); + final RectangleImmutable viewport = mainMonitor.getViewport(); + final RectangleImmutable isect = viewport.intersection(rect); + if ( getHeight() > isect.getHeight() || + getWidth() > isect.getWidth() ) { + setSize(isect.getWidth(), isect.getHeight()); + } + } } } @@ -2563,14 +2646,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - private boolean waitForVisible(boolean visible, boolean failFast) { + /** Returns -1 if failed, otherwise remaining time until {@link #TIMEOUT_NATIVEWINDOW}, maybe zero. */ + private long waitForVisible(boolean visible, boolean failFast) { return waitForVisible(visible, failFast, TIMEOUT_NATIVEWINDOW); } - private boolean waitForVisible(boolean visible, boolean failFast, long timeOut) { + /** Returns -1 if failed, otherwise remaining time until timeOut, maybe zero. */ + private long waitForVisible(boolean visible, boolean failFast, long timeOut) { final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date - for(long sleep = timeOut; 0 + * Since WM may not obey our positional request exactly, we allow a tolerance of 2 times insets[left/top], or 64 pixels, whatever is greater. + *

    + */ + private boolean waitForPosition(boolean useCustomPosition, int x, int y, long timeOut) { + final DisplayImpl display = (DisplayImpl) screen.getDisplay(); + final int maxDX, maxDY; + { + final InsetsImmutable insets = getInsets(); + maxDX = Math.max(64, insets.getLeftWidth() * 2); + maxDY = Math.max(64, insets.getTopHeight() * 2); + } + long remaining = timeOut; + boolean ok; + do { + if( useCustomPosition ) { + ok = Math.abs(x - getX()) <= maxDX && Math.abs(y - getY()) <= maxDY ; + } else { + ok = !autoPosition; + } + if( !ok ) { + try { Thread.sleep(10); } catch (InterruptedException ie) {} + display.dispatchMessagesNative(); // status up2date + remaining-=10; + } + } while ( 0getX() || 0>getY()) { diff --git a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java index 6b1283a00..8e584fc58 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java @@ -35,12 +35,15 @@ package jogamp.newt.driver.awt; import java.awt.DisplayMode; +import jogamp.newt.MonitorModeProps.Cache; import jogamp.newt.ScreenImpl; import javax.media.nativewindow.util.Dimension; import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; public class ScreenDriver extends ScreenImpl { public ScreenDriver() { @@ -68,14 +71,19 @@ public class ScreenDriver extends ScreenImpl { return idx; // pass through ... } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - final DisplayMode mode = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice().getDisplayMode(); - if(null != mode) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(mode.getWidth()); - virtualSize.setHeight(mode.getHeight()); - } + @Override + protected void collectNativeMonitorModesAndDevicesImpl(Cache cache) { + final DisplayMode mode = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice().getDisplayMode(); + } + + @Override + protected MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor) { + return null; + } + + @Override + protected boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode) { + return false; } } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java index deb2a534b..afaedffe3 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java @@ -35,8 +35,13 @@ package jogamp.newt.driver.bcm.egl; import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; + +import jogamp.newt.MonitorModeProps; +import jogamp.newt.ScreenImpl; + +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; public class ScreenDriver extends jogamp.newt.ScreenImpl { @@ -58,11 +63,48 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { return 0; // only one screen available } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(fixedWidth); // FIXME - virtualSize.setHeight(fixedHeight); // FIXME + @Override + protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; + props[i++] = fixedWidth; // FIXME + props[i++] = fixedHeight; // FIXME + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = ScreenImpl.default_sm_rate * 100; // FIXME + props[i++] = 0; // flags + props[i++] = 0; // mode_idx + props[i++] = 0; // rotation + final MonitorMode currentMode = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + + props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 - MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES]; + i = 0; + props[i++] = props.length; + props[i++] = 0; // crt_idx + props[i++] = ScreenImpl.default_sm_widthmm; // FIXME + props[i++] = ScreenImpl.default_sm_heightmm; // FIXME + props[i++] = 0; // rotated viewport x + props[i++] = 0; // rotated viewport y + props[i++] = fixedWidth; // FIXME rotated viewport width + props[i++] = fixedHeight; // FIXME rotated viewport height + MonitorModeProps.streamInMonitorDevice(null, cache, this, cache.monitorModes, currentMode, props, 0); + } + + @Override + protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { + return monitor.getSupportedModes().get(0); + } + + @Override + protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { + return false; + } + + protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(fixedWidth); // FIXME + vOriginSize.setHeight(fixedHeight); // FIXME } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java index 787d1a1b4..f7973def8 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java @@ -29,9 +29,12 @@ package jogamp.newt.driver.bcm.vc.iv; import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; + +import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; public class ScreenDriver extends ScreenImpl { @@ -53,13 +56,52 @@ public class ScreenDriver extends ScreenImpl { return 0; // only one screen available } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(cachedWidth); - virtualSize.setHeight(cachedHeight); + @Override + protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; + props[i++] = cachedWidth; // width + props[i++] = cachedHeight; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = ScreenImpl.default_sm_rate * 100; // FIXME + props[i++] = 0; // flags + props[i++] = 0; // mode_idx + props[i++] = 0; // rotation + final MonitorMode currentMode = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + + props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 - MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES]; + i = 0; + props[i++] = props.length; + props[i++] = 0; // crt_idx + props[i++] = ScreenImpl.default_sm_widthmm; // FIXME + props[i++] = ScreenImpl.default_sm_heightmm; // FIXME + props[i++] = 0; // rotated viewport x + props[i++] = 0; // rotated viewport y + props[i++] = cachedWidth; // rotated viewport width + props[i++] = cachedWidth; // rotated viewport height + MonitorModeProps.streamInMonitorDevice(null, cache, this, cache.monitorModes, currentMode, props, 0); + } + + @Override + protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { + return monitor.getSupportedModes().get(0); + } + + @Override + protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { + return false; + } + + @Override + protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(cachedWidth); + vOriginSize.setHeight(cachedHeight); } + /** Called from {@link #initNative()}. */ protected void setScreenSize(int width, int height) { cachedWidth = width; cachedHeight = height; diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java index 8eed14dde..4c47eb0d8 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java @@ -36,8 +36,13 @@ package jogamp.newt.driver.intel.gdl; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; + +import jogamp.newt.MonitorModeProps; +import jogamp.newt.ScreenImpl; + +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; public class ScreenDriver extends jogamp.newt.ScreenImpl { @@ -60,11 +65,48 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { return 0; // only one screen available } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(cachedWidth); - virtualSize.setHeight(cachedHeight); + @Override + protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; + props[i++] = cachedWidth; // width + props[i++] = cachedHeight; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = ScreenImpl.default_sm_rate * 100; // FIXME + props[i++] = 0; // flags + props[i++] = 0; // mode_idx + props[i++] = 0; // rotation + final MonitorMode currentMode = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + + props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 - MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES]; + i = 0; + props[i++] = props.length; + props[i++] = 0; // crt_idx + props[i++] = ScreenImpl.default_sm_widthmm; // FIXME + props[i++] = ScreenImpl.default_sm_heightmm; // FIXME + props[i++] = 0; // rotated viewport x + props[i++] = 0; // rotated viewport y + props[i++] = cachedWidth; // rotated viewport width + props[i++] = cachedWidth; // rotated viewport height + MonitorModeProps.streamInMonitorDevice(null, cache, this, cache.monitorModes, currentMode, props, 0); + } + + @Override + protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { + return monitor.getSupportedModes().get(0); + } + + @Override + protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { + return false; + } + + protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(cachedWidth); + vOriginSize.setHeight(cachedHeight); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java index 656bcf5c9..dc87c3c08 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java @@ -35,9 +35,12 @@ package jogamp.newt.driver.kd; import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; + +import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; public class ScreenDriver extends ScreenImpl { @@ -58,11 +61,48 @@ public class ScreenDriver extends ScreenImpl { return 0; // only one screen available } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(cachedWidth); - virtualSize.setHeight(cachedHeight); + @Override + protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; + props[i++] = cachedWidth; // width + props[i++] = cachedHeight; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = ScreenImpl.default_sm_rate * 100; // FIXME + props[i++] = 0; // flags + props[i++] = 0; // mode_idx + props[i++] = 0; // rotation + final MonitorMode currentMode = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + + props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 - MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES]; + i = 0; + props[i++] = props.length; + props[i++] = 0; // crt_idx + props[i++] = ScreenImpl.default_sm_widthmm; // FIXME + props[i++] = ScreenImpl.default_sm_heightmm; // FIXME + props[i++] = 0; // rotated viewport x + props[i++] = 0; // rotated viewport y + props[i++] = cachedWidth; // rotated viewport width + props[i++] = cachedWidth; // rotated viewport height + MonitorModeProps.streamInMonitorDevice(null, cache, this, cache.monitorModes, currentMode, props, 0); + } + + @Override + protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { + return monitor.getSupportedModes().get(0); + } + + @Override + protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { + return false; + } + + protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(cachedWidth); + vOriginSize.setHeight(cachedHeight); } protected void sizeChanged(int w, int h) { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java index 24e60ba0a..a3bb26731 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java @@ -34,28 +34,19 @@ package jogamp.newt.driver.macosx; -import java.util.List; - import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.Point; +import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; -import com.jogamp.common.util.IntObjectHashMap; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; public class ScreenDriver extends ScreenImpl { - // caching native CGDisplayScreenSize() results, since it's ridiculous slow (~6 ms each call) - private static IntObjectHashMap/**/ scrnIdx2Dimension; - static { DisplayDriver.initSingleton(); - scrnIdx2Dimension = new IntObjectHashMap(); - scrnIdx2Dimension.setKeyNotFoundValue(null); } public ScreenDriver() { @@ -67,77 +58,67 @@ public class ScreenDriver extends ScreenImpl { protected void closeNativeImpl() { } - private static native int getWidthImpl0(int scrn_idx); - private static native int getHeightImpl0(int scrn_idx); - - private int[] getScreenModeIdx(int idx) { - // caching native CGDisplayScreenSize() results, since it's ridiculous slow (~6 ms each call) - DimensionImmutable dim = (DimensionImmutable) scrnIdx2Dimension.get(screen_idx); - if(null == dim) { - int[] res = getScreenSizeMM0(screen_idx); - if(null == res || 0 == res.length) { - return null; - } - dim = new Dimension(res[0], res[1]); - scrnIdx2Dimension.put(screen_idx, dim); - } - - int[] modeProps = getScreenMode0(screen_idx, idx, dim.getWidth(), dim.getHeight()); - if (null == modeProps || 0 == modeProps.length) { - return null; + private MonitorMode getMonitorModeImpl(MonitorModeProps.Cache cache, int crt_idx, int mode_idx) { + final int[] modeProps = getMonitorMode0(crt_idx, mode_idx); + final MonitorMode res; + if (null == modeProps || 0 >= modeProps.length) { + res = null; + } else { + res = MonitorModeProps.streamInMonitorMode(null, cache, modeProps, 0); } - if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) { - throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length); - } - return modeProps; + return res; } - - private int nativeModeIdx; - protected int[] getScreenModeFirstImpl() { - nativeModeIdx = 0; - return getScreenModeNextImpl(); - } - - protected int[] getScreenModeNextImpl() { - int[] modeProps = getScreenModeIdx(nativeModeIdx); - if (null != modeProps && 0 < modeProps.length) { - nativeModeIdx++; - return modeProps; - } - return null; + @Override + protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + int crtIdx = 0; + int modeIdx = 0; + ArrayHashSet supportedModes = new ArrayHashSet(); + do { + final MonitorMode mode = getMonitorModeImpl(cache, crtIdx, modeIdx); + if( null != mode ) { + supportedModes.getOrAdd(mode); + // next mode on same monitor + modeIdx++; + } else if( 0 < modeIdx ) { + // end of monitor modes - got at least one mode + final MonitorMode currentMode = getMonitorModeImpl(cache, crtIdx, -1); + if ( null == currentMode ) { + throw new InternalError("Could not gather current mode of device "+crtIdx+", but gathered "+modeIdx+" modes"); + } + final int[] monitorProps = getMonitorProps0(crtIdx); + if ( null == monitorProps ) { + throw new InternalError("Could not gather device "+crtIdx+", but gathered "+modeIdx+" modes"); + } + // merge monitor-props + supported modes + MonitorModeProps.streamInMonitorDevice(null, cache, this, supportedModes, currentMode, monitorProps, 0); + + // next monitor, 1st mode + supportedModes= new ArrayHashSet(); + crtIdx++; + modeIdx=0; + } else { + // end of monitor + break; + } + } while ( true ); } - protected ScreenMode getCurrentScreenModeImpl() { - int[] modeProps = getScreenModeIdx(-1); - if (null != modeProps && 0 < modeProps.length) { - return ScreenModeUtil.streamIn(modeProps, 0); - } - return null; + @Override + protected MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor) { + return getMonitorModeImpl(null, monitor.getId(), -1); } - protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { - final List screenModes = this.getScreenModesOrig(); - final int screenModeIdx = screenModes.indexOf(screenMode); - if(0>screenModeIdx) { - throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); - } - final int nativeModeIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); - return setScreenMode0(screen_idx, nativeModeIdx); + @Override + protected boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode) { + return setMonitorMode0(monitor.getId(), mode.getId(), mode.getRotation()); } protected int validateScreenIndex(int idx) { - return idx; + return 0; // big-desktop w/ multiple monitor attached, only one screen available } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(getWidthImpl0(screen_idx)); - virtualSize.setHeight(getHeightImpl0(screen_idx)); - } - - private native int[] getScreenSizeMM0(int screen_idx); - private native int[] getScreenMode0(int screen_index, int mode_index, int widthMM, int heightMM); - private native boolean setScreenMode0(int screen_index, int mode_idx); + private native int[] getMonitorProps0(int crt_idx); + private native int[] getMonitorMode0(int crt_index, int mode_idx); + private native boolean setMonitorMode0(int crt_index, int nativeId, int rot); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index bb72350e3..6370782df 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -478,7 +478,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( 0 != surfaceHandle ) { throw new NativeWindowException("Internal Error - create w/o window, but has Newt NSView"); } - surfaceHandle = createView0(pS.getX(), pS.getY(), width, height, fullscreen, getScreen().getIndex()); + surfaceHandle = createView0(pS.getX(), pS.getY(), width, height, fullscreen); if( 0 == surfaceHandle ) { throw new NativeWindowException("Could not create native view "+Thread.currentThread().getName()+" "+this); } @@ -487,7 +487,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final long newWin = createWindow0( pS.getX(), pS.getY(), width, height, fullscreen, ( isUndecorated() || offscreenInstance ) ? NSBorderlessWindowMask : NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask, - NSBackingStoreBuffered, getScreen().getIndex(), surfaceHandle); + NSBackingStoreBuffered, surfaceHandle); if ( newWin == 0 ) { throw new NativeWindowException("Could not create native window "+Thread.currentThread().getName()+" "+this); } @@ -497,9 +497,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // Non blocking initialization on main-thread! OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { - initWindow0( parentWin, newWin, - pS.getX(), pS.getY(), width, height, - isOpaque, fullscreen, visible && !offscreenInstance, getScreen().getIndex(), surfaceHandle); + initWindow0( parentWin, newWin, pS.getX(), pS.getY(), width, height, + isOpaque, fullscreen, visible && !offscreenInstance, surfaceHandle); if( offscreenInstance ) { orderOut0(0!=parentWin ? parentWin : newWin); } else { @@ -514,11 +513,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } protected static native boolean initIDs0(); - private native long createView0(int x, int y, int w, int h, boolean fullscreen, int screen_idx); - private native long createWindow0(int x, int y, int w, int h, boolean fullscreen, int windowStyle, int backingStoreType, int screen_idx, long view); + private native long createView0(int x, int y, int w, int h, boolean fullscreen); + private native long createWindow0(int x, int y, int w, int h, boolean fullscreen, int windowStyle, int backingStoreType, long view); /** Must be called on Main-Thread */ private native void initWindow0(long parentWindow, long window, int x, int y, int w, int h, - boolean opaque, boolean fullscreen, boolean visible, int screen_idx, long view); + boolean opaque, boolean fullscreen, boolean visible, long view); private native boolean lockSurface0(long window, long view); private native boolean unlockSurface0(long window, long view); /** Must be called on Main-Thread */ diff --git a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java index 948b29460..342829691 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java @@ -34,91 +34,143 @@ package jogamp.newt.driver.windows; import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; +import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.Screen; public class ScreenDriver extends ScreenImpl { static { DisplayDriver.initSingleton(); + if( Screen.DEBUG ) { + dumpMonitorInfo0(); + } } public ScreenDriver() { } + @Override protected void createNativeImpl() { aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); } + @Override protected void closeNativeImpl() { } - private int[] getScreenModeIdx(int idx) { - int[] modeProps = getScreenMode0(screen_idx, idx); - if (null == modeProps || 0 == modeProps.length) { + private final String getAdapterName(int crt_idx) { + return getAdapterName0(crt_idx); + } + private final String getActiveMonitorName(String adapterName, int monitor_idx) { + return getActiveMonitorName0(adapterName, monitor_idx); + } + + private final MonitorMode getMonitorModeImpl(MonitorModeProps.Cache cache, String adapterName, int crtModeIdx) { + if( null == adapterName ) { return null; } - if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) { - throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length); + final String activeMonitorName = getActiveMonitorName(adapterName, 0); + final int[] modeProps = null != activeMonitorName ? getMonitorMode0(adapterName, crtModeIdx) : null; + if ( null == modeProps || 0 >= modeProps.length) { + return null; } - return modeProps; + return MonitorModeProps.streamInMonitorMode(null, cache, modeProps, 0); } - private int nativeModeIdx; - - protected int[] getScreenModeFirstImpl() { - nativeModeIdx = 0; - return getScreenModeNextImpl(); - } - - protected int[] getScreenModeNextImpl() { - int[] modeProps = getScreenModeIdx(nativeModeIdx); - if (null != modeProps && 0 < modeProps.length) { - nativeModeIdx++; - return modeProps; + @Override + protected void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + int crtIdx = 0; + ArrayHashSet supportedModes = new ArrayHashSet(); + String adapterName = getAdapterName(crtIdx); + while( null != adapterName ) { + int crtModeIdx = 0; + MonitorMode mode; + do { + mode = getMonitorModeImpl(cache, adapterName, crtModeIdx); + if( null != mode ) { + supportedModes.getOrAdd(mode); + // next mode on same monitor + crtModeIdx++; + } + } while( null != mode); + if( 0 < crtModeIdx ) { + // has at least one mode -> add device + final MonitorMode currentMode = getMonitorModeImpl(cache, adapterName, -1); + if ( null != currentMode ) { // enabled + final int[] monitorProps = getMonitorDevice0(adapterName, crtIdx); + // merge monitor-props + supported modes + MonitorModeProps.streamInMonitorDevice(null, cache, this, supportedModes, currentMode, monitorProps, 0); + + // next monitor, 1st mode + supportedModes= new ArrayHashSet(); + } + } + crtIdx++; + adapterName = getAdapterName(crtIdx); } - return null; } - - protected ScreenMode getCurrentScreenModeImpl() { - int[] modeProps = getScreenModeIdx(-1); - if (null != modeProps && 0 < modeProps.length) { - return ScreenModeUtil.streamIn(modeProps, 0); + + @Override + protected Rectangle getNativeMonitorDeviceViewportImpl(MonitorDevice monitor) { + final String adapterName = getAdapterName(monitor.getId()); + if( null != adapterName ) { + final String activeMonitorName = getActiveMonitorName(adapterName, 0); + if( null != activeMonitorName ) { + final int[] monitorProps = getMonitorDevice0(adapterName, monitor.getId()); + int offset = MonitorModeProps.IDX_MONITOR_DEVICE_VIEWPORT; + return new Rectangle(monitorProps[offset++], monitorProps[offset++], monitorProps[offset++], monitorProps[offset++]); + } } return null; } - protected boolean setCurrentScreenModeImpl(ScreenMode sm) { - return setScreenMode0(screen_idx, - sm.getMonitorMode().getSurfaceSize().getResolution().getWidth(), - sm.getMonitorMode().getSurfaceSize().getResolution().getHeight(), - sm.getMonitorMode().getSurfaceSize().getBitsPerPixel(), - sm.getMonitorMode().getRefreshRate(), - sm.getRotation()); + @Override + protected MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor) { + return getMonitorModeImpl(null, getAdapterName(monitor.getId()), -1); + } + + @Override + protected boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode) { + return setMonitorMode0(monitor.getId(), + -1, -1, // no fixed position! + mode.getSurfaceSize().getResolution().getWidth(), + mode.getSurfaceSize().getResolution().getHeight(), + mode.getSurfaceSize().getBitsPerPixel(), + (int)mode.getRefreshRate(), // simply cut-off, orig is int + mode.getFlags(), + mode.getRotation()); } + @Override protected int validateScreenIndex(int idx) { - return 0; // big-desktop, only one screen available + return 0; // big-desktop w/ multiple monitor attached, only one screen available } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(getOriginX0(screen_idx)); - virtualOrigin.setY(getOriginY0(screen_idx)); - virtualSize.setWidth(getWidthImpl0(screen_idx)); - virtualSize.setHeight(getHeightImpl0(screen_idx)); + @Override + protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { + vOriginSize.setX(getVirtualOriginX0()); + vOriginSize.setY(getVirtualOriginY0()); + vOriginSize.setWidth(getVirtualWidthImpl0()); + vOriginSize.setHeight(getVirtualHeightImpl0()); } // Native calls - private native int getOriginX0(int screen_idx); - private native int getOriginY0(int screen_idx); - private native int getWidthImpl0(int scrn_idx); - private native int getHeightImpl0(int scrn_idx); + private native int getVirtualOriginX0(); + private native int getVirtualOriginY0(); + private native int getVirtualWidthImpl0(); + private native int getVirtualHeightImpl0(); - private native int[] getScreenMode0(int screen_index, int mode_index); - private native boolean setScreenMode0(int screen_index, int width, int height, int bits, int freq, int rot); + private static native void dumpMonitorInfo0(); + private native String getAdapterName0(int crt_index); + private native String getActiveMonitorName0(String adapterName, int crtModeIdx); + private native int[] getMonitorMode0(String adapterName, int crtModeIdx); + private native int[] getMonitorDevice0(String adapterName, int monitor_index); + private native boolean setMonitorMode0(int monitor_index, int x, int y, int width, int height, int bits, int freq, int flags, int rot); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR.java b/src/newt/classes/jogamp/newt/driver/x11/RandR.java index 485d976ec..c569e5fd8 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR.java @@ -27,13 +27,50 @@ */ package jogamp.newt.driver.x11; -import com.jogamp.newt.ScreenMode; +import java.util.List; + +import jogamp.newt.MonitorModeProps; + +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; public interface RandR { - int[] getScreenModeFirstImpl(final long dpy, final int screen_idx); - int[] getScreenModeNextImpl(final long dpy, final int screen_idx); - ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx); - boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx); + void dumpInfo(final long dpy, final int screen_idx); + + /** + * Encapsulate initial device query allowing caching of internal data structures. + * Methods covered: + *
      + *
    • {@link #getMonitorDeviceCount(long, ScreenDriver)}
    • + *
    • {@link #getAvailableRotations(long, ScreenDriver, int)}
    • + *
    • {@link #getMonitorModeProps(long, ScreenDriver, int)}
    • + *
    • {@link #getCurrentMonitorModeProps(long, ScreenDriver, int)
    • + *
    • {@link #getMonitorDeviceProps(long, ScreenDriver, List, int, MonitorMode)}
    • + *
    + *

    + * Above methods may be called w/o begin/end, in which case no + * internal data structures can be cached: + *

    + * @param dpy TODO + * @param screen TODO + * @return TODO + */ + boolean beginInitialQuery(long dpy, ScreenDriver screen); + void endInitialQuery(long dpy, ScreenDriver screen); + int getMonitorDeviceCount(final long dpy, final ScreenDriver screen); + int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_idx); + /** + * + * @param dpy + * @param screen + * @param mode_idx w/o indexing rotation + * @return props w/o actual rotation + */ + int[] getMonitorModeProps(final long dpy, final ScreenDriver screen, final int mode_idx); + int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, MonitorModeProps.Cache cache, final int crt_idx); + int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_idx); + int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx); + boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java index ee67bd304..a938b4064 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java @@ -27,139 +27,257 @@ */ package jogamp.newt.driver.x11; +import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.common.util.VersionNumber; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; public class RandR11 implements RandR { private static final boolean DEBUG = ScreenDriver.DEBUG; - private int[] nrotations; - private int nrotation_index; - private int nres_number; - private int nres_index; - private int[] nrates; - private int nrate_index; - private int nmode_number; + public static VersionNumber version = new VersionNumber(1, 1, 0); + + public static RandR11 createInstance(VersionNumber rAndRVersion) { + if( rAndRVersion.compareTo(version) >= 0 ) { + return new RandR11(); + } + return null; + } + private RandR11() { + } + + @Override + public void dumpInfo(final long dpy, final int screen_idx) { + // NOP + } + + private int widthMM=0, heightMM=0; + private int modeCount = 0; + private int resolutionCount = 0; + private int[][] nrates = null; // [nres_number][nrate_number] + private int[] idx_rate = null, idx_res = null; @Override - public int[] getScreenModeFirstImpl(final long dpy, final int screen_idx) { + public boolean beginInitialQuery(long dpy, ScreenDriver screen) { // initialize iterators and static data - nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); - if(null==nrotations || 0==nrotations.length) { - return null; + final int screen_idx = screen.getIndex(); + resolutionCount = getNumScreenResolutions0(dpy, screen_idx); + if(0==resolutionCount) { + endInitialQuery(dpy, screen); + return false; } - nrotation_index = 0; - nres_number = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==nres_number) { - return null; + nrates = new int[resolutionCount][]; + for(int i=0; i= modeCount ) { + return null; + } + final int screen_idx = screen.getIndex(); + + final int nres_index = idx_res[mode_idx]; + final int nrate_index = idx_rate[mode_idx]; + + final int[] res = getScreenResolution0(dpy, screen_idx, nres_index); if(null==res || 0==res.length) { return null; } if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+resolutionCount); + } + if( res[2] > widthMM ) { + widthMM = res[2]; } - int rate = nrates[nrate_index]; + if( res[3] > heightMM ) { + heightMM = res[3]; + } + + int rate = nrates[nres_index][nrate_index]; if(0>=rate) { rate = ScreenImpl.default_sm_rate; if(DEBUG) { System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+ScreenImpl.default_sm_rate); } } - int rotation = nrotations[nrotation_index]; - int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; int i = 0; - props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode - props[i++] = 0; // set later for verification of iterator + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; props[i++] = res[0]; // width props[i++] = res[1]; // height - props[i++] = ScreenImpl.default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rotation; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element - - nmode_number++; - - // iteration: r -> f -> bpp -> [w x h] - nrotation_index++; - if(nrotation_index == nrotations.length) { - nrotation_index=0; - nrate_index++; - if(null == nrates || nrate_index == nrates.length){ - nres_index++; - if(nres_index == nres_number) { - // done - nrates=null; - nrotations=null; - return null; - } - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - } + props[i++] = ScreenImpl.default_sm_bpp; // bpp n/a in RandR11 + props[i++] = rate*100; // rate (Hz*100) + props[i++] = 0; // flags; + props[i++] = nres_index; + props[i++] = -1; // rotation placeholder; + if( MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL != i ) { + throw new InternalError("XX"); + } + return props; + } + + @Override + public int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, final MonitorModeProps.Cache cache, final int crt_idx) { + if( 0 < crt_idx ) { + // RandR11 only supports 1 CRT + return null; + } + final int[] currentModeProps = getCurrentMonitorModeProps(dpy, screen, crt_idx); + if( null == currentModeProps) { // disabled + return null; + } + final MonitorMode currentMode = MonitorModeProps.streamInMonitorMode(null, cache, currentModeProps, 0); + final int allModesCount = cache.monitorModes.size(); + final int[] props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 + allModesCount]; + int i = 0; + props[i++] = props.length; + props[i++] = crt_idx; + props[i++] = widthMM; + props[i++] = heightMM; + props[i++] = 0; // rotated viewport x + props[i++] = 0; // rotated viewport y + props[i++] = currentMode.getRotatedWidth(); // rotated viewport width + props[i++] = currentMode.getRotatedHeight(); // rotated viewport height + props[i++] = currentMode.getId(); // current mode id + props[i++] = currentMode.getRotation(); + for(int j=0; jnres_idx) { + return null; + } + if(nres_idx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! "+nres_idx+" < "+resNumber); + } + res = getScreenResolution0(dpy, screen_idx, nres_idx); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_idx+"/"+resNumber); + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + int[] props = new int[4]; + int i = 0; + props[i++] = 0; + props[i++] = 0; + props[i++] = res[0]; // width + props[i++] = res[1]; // height + return props; + } + @Override - public ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx) { + public int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx) { + if( 0 < crt_idx ) { + // RandR11 only supports 1 CRT + return null; + } + final int screen_idx = screen.getIndex(); long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); if(0 == screenConfigHandle) { return null; } int[] res; int rate, rot; + final int nres_idx; try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + int resNumber = getNumScreenResolutions0(dpy, screen_idx); if(0==resNumber) { return null; } - int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); - if(0>resIdx) { + nres_idx = getCurrentScreenResolutionIndex0(screenConfigHandle); + if(0>nres_idx) { return null; } - if(resIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); + if(nres_idx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! "+nres_idx+" < "+resNumber); } - res = getScreenModeResolution0(dpy, screen_idx, resIdx); + res = getScreenResolution0(dpy, screen_idx, nres_idx); if(null==res || 0==res.length) { return null; } if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_idx+"/"+resNumber); } rate = getCurrentScreenRate0(screenConfigHandle); if(0>rate) { @@ -172,40 +290,42 @@ public class RandR11 implements RandR { } finally { freeScreenConfiguration0(screenConfigHandle); } - int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; int i = 0; - props[i++] = 0; // set later for verification of iterator + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; props[i++] = res[0]; // width props[i++] = res[1]; // height - props[i++] = ScreenImpl.default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate + props[i++] = ScreenImpl.default_sm_bpp; + props[i++] = rate*100; // rate (Hz*100) + props[i++] = 0; // flags; + props[i++] = nres_idx; // mode_idx; props[i++] = rot; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count - return ScreenModeUtil.streamIn(props, 0); + if( MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL != i ) { + throw new InternalError("XX"); + } + return props; } @Override - public boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx) { + public boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode) { final long t0 = System.currentTimeMillis(); boolean done = false; + final int screen_idx = screen.getIndex(); long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); if(0 == screenConfigHandle) { return Boolean.valueOf(done); } try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - if(0>resolutionIdx || resolutionIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! 0 < "+resolutionIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); - } - - final int f = screenMode.getMonitorMode().getRefreshRate(); - final int r = screenMode.getRotation(); + final int resId = mode.getId(); + if(0>resId || resId>=resolutionCount) { + throw new RuntimeException("Invalid resolution index: ! 0 < "+resId+" < "+resolutionCount+", "+monitor+", "+mode); + } + final int f = (int)mode.getRefreshRate(); // simply cut-off, orig is int + final int r = mode.getRotation(); - if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resolutionIdx, f, r) ) { + if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resId, f, r) ) { while(!done && System.currentTimeMillis()-t0 < ScreenImpl.SCREEN_MODE_CHANGE_TIMEOUT) { - done = setCurrentScreenModePollEnd0(dpy, screen_idx, resolutionIdx, f, r); + done = setCurrentScreenModePollEnd0(dpy, screen_idx, resId, f, r); if(!done) { try { Thread.sleep(10); } catch (InterruptedException e) { } } @@ -218,14 +338,14 @@ public class RandR11 implements RandR { } /** @return int[] { rot1, .. } */ - private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); + private static native int[] getAvailableScreenRotations0(long display, int screen_index); - private static native int getNumScreenModeResolutions0(long display, int screen_index); + private static native int getNumScreenResolutions0(long display, int screen_index); /** @return int[] { width, height, widthmm, heightmm } */ - private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); + private static native int[] getScreenResolution0(long display, int screen_index, int mode_index); - private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); + private static native int[] getScreenRates0(long display, int screen_index, int mode_index); private static native long getScreenConfiguration0(long display, int screen_index); private static native void freeScreenConfiguration0(long screenConfiguration); diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java index 24c9806af..d10591381 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java @@ -27,25 +27,283 @@ */ package jogamp.newt.driver.x11; -import com.jogamp.newt.ScreenMode; +import java.util.Iterator; +import jogamp.newt.MonitorModeProps; + +import com.jogamp.common.util.IntLongHashMap; +import com.jogamp.common.util.VersionNumber; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; + +/** + * Mapping details: + *
    + * MonitorMode.id   == XRR mode-id (not index)
    + * MonitorDevice.id == XRR monitor-idx (not id)
    + * 
    + */ public class RandR13 implements RandR { + private static final boolean DEBUG = ScreenDriver.DEBUG; + + public static VersionNumber version = new VersionNumber(1, 3, 0); - public int[] getScreenModeFirstImpl(final long dpy, final int screen_idx) { + public static RandR13 createInstance(VersionNumber rAndRVersion) { + if( rAndRVersion.compareTo(version) >= 0 ) { + return new RandR13(); + } return null; + } + private RandR13() { + } + + @Override + public void dumpInfo(final long dpy, final int screen_idx) { + long screenResources = getScreenResources0(dpy, screen_idx); + if(0 == screenResources) { + return; + } + try { + dumpInfo0(dpy, screen_idx, screenResources); + } finally { + freeScreenResources0(screenResources); + } + } + + long sessionScreenResources = 0; + IntLongHashMap crtInfoHandleMap = null; + + @Override + public boolean beginInitialQuery(long dpy, ScreenDriver screen) { + final int screen_idx = screen.getIndex(); + sessionScreenResources = getScreenResources0(dpy, screen_idx); + if( 0 != sessionScreenResources ) { + crtInfoHandleMap = new IntLongHashMap(); + crtInfoHandleMap.setKeyNotFoundValue(0); + return true; + } else { + return false; + } + } + + @Override + public void endInitialQuery(long dpy, ScreenDriver screen) { + if( null != crtInfoHandleMap ) { + for(Iterator iter = crtInfoHandleMap.iterator(); iter.hasNext(); ) { + final IntLongHashMap.Entry entry = iter.next(); + freeMonitorInfoHandle0(entry.value); + } + crtInfoHandleMap.clear(); + crtInfoHandleMap = null; + } + if( 0 != sessionScreenResources ) { + freeScreenResources0( sessionScreenResources ); + sessionScreenResources = 0; + } } - public int[] getScreenModeNextImpl(final long dpy, final int screen_idx) { - return null; + + private final long getScreenResourceHandle(final long dpy, final int screen_idx) { + if( 0 != sessionScreenResources ) { + return sessionScreenResources; + } + return getScreenResources0(dpy, screen_idx); + } + private final void releaseScreenResourceHandle(final long screenResourceHandle) { + if( 0 == sessionScreenResources ) { + freeScreenResources0( screenResourceHandle ); + } } - public ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx) { - return null; + + private final long getMonitorInfoHandle(final long dpy, final int screen_idx, long screenResources, final int monitor_idx) { + if( null != crtInfoHandleMap ) { + long h = crtInfoHandleMap.get(monitor_idx); + if( 0 == h ) { + h = getMonitorInfoHandle0(dpy, screen_idx, screenResources, monitor_idx); + crtInfoHandleMap.put(monitor_idx, h); + } + return h; + } else { + return getMonitorInfoHandle0(dpy, screen_idx, screenResources, monitor_idx); + } } + private final void releaseMonitorInfoHandle(final long monitorInfoHandle) { + if( null == crtInfoHandleMap ) { + freeMonitorInfoHandle0(monitorInfoHandle); + } + } - public boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx) { - return false; + @Override + public int getMonitorDeviceCount(final long dpy, final ScreenDriver screen) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + return getMonitorDeviceCount0(screenResources); + } finally { + releaseScreenResourceHandle(screenResources); + } } + @Override + public int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_idx) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_idx); + try { + final int[] availRotations = getAvailableRotations0(monitorInfo); + if(null==availRotations || 0==availRotations.length) { + return null; + } + return availRotations; + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + } finally { + releaseScreenResourceHandle(screenResources); + } + } + + @Override + public int[] getMonitorModeProps(final long dpy, final ScreenDriver screen, final int mode_idx) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + return getMonitorMode0(screenResources, mode_idx); + } finally { + releaseScreenResourceHandle(screenResources); + } + } + + @Override + public int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, MonitorModeProps.Cache cache, final int crt_idx) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_idx); + try { + return getMonitorDevice0(dpy, screenResources, monitorInfo, crt_idx); + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + } finally { + releaseScreenResourceHandle(screenResources); + } + } + + @Override + public int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_idx) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_idx); + try { + return getMonitorViewport0(monitorInfo); + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + } finally { + releaseScreenResourceHandle(screenResources); + } + } + + @Override + public int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_idx); + try { + return getMonitorCurrentMode0(screenResources, monitorInfo); + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + } finally { + releaseScreenResourceHandle(screenResources); + } + } + + @Override + public boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + final boolean res; + try { + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, monitor.getId()); + try { + res = setMonitorMode0(dpy, screenResources, monitorInfo, monitor.getId(), mode.getId(), mode.getRotation(), + -1, -1); // no fixed position! + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + } finally { + releaseScreenResourceHandle(screenResources); + } + /*** + * TODO: Would need a complete re-layout of crt positions, + * which is _not_ implicit by XRandR .. sadly. + * + if( res ) { + updateScreenViewport(dpy, screen, monitor); + } */ + return res; + } + + /** See above .. + private final void updateScreenViewport(final long dpy, final ScreenDriver screen, MonitorDevice monitor) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + RectangleImmutable newViewp = null; + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, monitor.getId()); + try { + final int[] vprops = getMonitorViewport0(monitorInfo); + if( null != vprops ) { + newViewp = new Rectangle(vprops[0], vprops[1], vprops[2], vprops[3]); + } + System.err.println("XXX setScreenViewport: newVp "+newViewp); + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + if( null != newViewp ) { + final List monitors = screen.getMonitorDevices(); + final ArrayList viewports = new ArrayList(); + for(int i=0; i "+newScrnViewp); + setScreenViewport0(dpy, screen_idx, screenResources, newScrnViewp.getX(), newScrnViewp.getY(), newScrnViewp.getWidth(), newScrnViewp.getHeight()); + } + } finally { + dumpInfo0(dpy, screen_idx, screenResources); + releaseScreenResourceHandle(screenResources); + } + } */ + private static native long getScreenResources0(long display, int screen_index); - private static native void freeScreenResources0(long screenConfiguration); + private static native void freeScreenResources0(long screenResources); + private static native void dumpInfo0(long display, int screen_index, long screenResources); + + private static native int getMonitorDeviceCount0(long screenResources); + + private static native long getMonitorInfoHandle0(long display, int screen_index, long screenResources, int monitor_index); + private static native void freeMonitorInfoHandle0(long monitorInfoHandle); + + private static native int[] getAvailableRotations0(long monitorInfo); + private static native int[] getMonitorViewport0(long monitorInfo); + private static native int[] getMonitorCurrentMode0(long monitorInfo); + + private static native int[] getMonitorMode0(long screenResources, int mode_index); + private static native int[] getMonitorCurrentMode0(long screenResources, long monitorInfo); + private static native int[] getMonitorDevice0(long display, long screenResources, long monitorInfo, int monitor_idx); + private static native boolean setMonitorMode0(long display, long screenResources, long monitorInfo, int monitor_idx, int mode_id, int rotation, int x, int y); + private static native boolean setScreenViewport0(long display, int screen_index, long screenResources, int x, int y, int width, int height); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index cd8da9b60..ba22a6ce4 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -33,23 +33,29 @@ */ package jogamp.newt.driver.x11; +import java.util.ArrayList; import java.util.List; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.util.Rectangle; import jogamp.nativewindow.x11.X11Util; +import jogamp.newt.Debug; import jogamp.newt.DisplayImpl; +import jogamp.newt.MonitorModeProps; import jogamp.newt.DisplayImpl.DisplayRunnable; import jogamp.newt.ScreenImpl; +import com.jogamp.common.util.ArrayHashSet; import com.jogamp.common.util.VersionNumber; import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; -import com.jogamp.newt.ScreenMode; - -public class ScreenDriver extends ScreenImpl { +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; +public class ScreenDriver extends ScreenImpl { + protected static final boolean DEBUG_TEST_RANDR13_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableRandR13", true); + static { DisplayDriver.initSingleton(); } @@ -57,12 +63,13 @@ public class ScreenDriver extends ScreenImpl { public ScreenDriver() { } + @Override protected void createNativeImpl() { // validate screen index Long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Long run(long dpy) { return new Long(GetScreen0(dpy, screen_idx)); - } } ); + } } ); if (handle.longValue() == 0) { throw new RuntimeException("Error creating screen: " + screen_idx); } @@ -73,73 +80,116 @@ public class ScreenDriver extends ScreenImpl { int v[] = getRandRVersion0(dpy); randrVersion = new VersionNumber(v[0], v[1], 0); } - if( DEBUG ) { - System.err.println("RandR "+randrVersion); + { + final RandR13 rAndR13 = DEBUG_TEST_RANDR13_DISABLED ? null : RandR13.createInstance(randrVersion); + if( null != rAndR13 ) { + rAndR = rAndR13; + } else { + rAndR = RandR11.createInstance(randrVersion); + } } - if( !randrVersion.isZero() ) { - rAndR = new RandR11(); - } else { - rAndR = null; + if( DEBUG ) { + System.err.println("RandR "+randrVersion+", "+rAndR); + rAndR.dumpInfo(dpy, screen_idx); } } + @Override protected void closeNativeImpl() { } private VersionNumber randrVersion; private RandR rAndR; - + @Override - protected int[] getScreenModeFirstImpl() { - if( null == rAndR ) { return null; } - - return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - public int[] run(long dpy) { - return rAndR.getScreenModeFirstImpl(dpy, screen_idx); - } } ); + protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + if( null == rAndR ) { return; } + final AbstractGraphicsDevice device = getDisplay().getGraphicsDevice(); + device.lock(); + try { + if( rAndR.beginInitialQuery(device.getHandle(), this) ) { + try { + final int crtCount = rAndR.getMonitorDeviceCount(device.getHandle(), this); + + // Gather all available rotations + final ArrayHashSet availableRotations = new ArrayHashSet(); + for(int i = 0; i < crtCount; i++) { + final int[] rotations = rAndR.getAvailableRotations(device.getHandle(), this, i); + if( null != rotations ) { + final List rotationList = new ArrayList(rotations.length); + for(int j=0; j 0 ) { + for(int i = 0; i < crtCount; i++) { + final int[] monitorProps = rAndR.getMonitorDeviceProps(device.getHandle(), this, cache, i); + if( null != monitorProps ) { // enabled + MonitorModeProps.streamInMonitorDevice(null, cache, this, monitorProps, 0); + } + } + } + } finally { + rAndR.endInitialQuery(device.getHandle(), this); + } + } + } finally { + device.unlock(); + } } @Override - protected int[] getScreenModeNextImpl() { - if( null == rAndR ) { return null; } - - // assemble: w x h x bpp x f x r - return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - public int[] run(long dpy) { - return rAndR.getScreenModeNextImpl(dpy, screen_idx); - } } ); + protected Rectangle getNativeMonitorDeviceViewportImpl(MonitorDevice monitor) { + final AbstractGraphicsDevice device = getDisplay().getGraphicsDevice(); + device.lock(); + try { + int[] viewportProps = rAndR.getMonitorDeviceViewport(device.getHandle(), this, monitor.getId()); + return new Rectangle(viewportProps[0], viewportProps[1], viewportProps[2], viewportProps[3]); + } finally { + device.unlock(); + } } - + @Override - protected ScreenMode getCurrentScreenModeImpl() { + protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { if( null == rAndR ) { return null; } - return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - public ScreenMode run(long dpy) { - return rAndR.getCurrentScreenModeImpl(dpy, screen_idx); + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public MonitorMode run(long dpy) { + final int[] currentModeProps = rAndR.getCurrentMonitorModeProps(dpy, ScreenDriver.this, monitor.getId()); + return MonitorModeProps.streamInMonitorMode(null, null, currentModeProps, 0); } } ); } @Override - protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { + protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { if( null == rAndR ) { return false; } - final List screenModes = this.getScreenModesOrig(); - final int screenModeIdx = screenModes.indexOf(screenMode); - if(0>screenModeIdx) { - throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); - } final long t0 = System.currentTimeMillis(); boolean done = runWithTempDisplayHandle( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { - final int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); - return Boolean.valueOf( rAndR.setCurrentScreenModeImpl(dpy, screen_idx, screenMode, screenModeIdx, resIdx) ); + return Boolean.valueOf( rAndR.setCurrentMonitorMode(dpy, ScreenDriver.this, monitor, mode) ); } }).booleanValue(); if(DEBUG || !done) { System.err.println("X11Screen.setCurrentScreenModeImpl: TO ("+SCREEN_MODE_CHANGE_TIMEOUT+") reached: "+ - (System.currentTimeMillis()-t0)+"ms; Current: "+getCurrentScreenMode()+"; Desired: "+screenMode); + (System.currentTimeMillis()-t0)+"ms; "+monitor.getCurrentMode()+" -> "+mode); } return done; } @@ -149,6 +199,7 @@ public class ScreenDriver extends ScreenImpl { return new Boolean(X11Util.XineramaIsEnabled(dpy)); } }; + @Override protected int validateScreenIndex(final int idx) { final DisplayDriver x11Display = (DisplayDriver) getDisplay(); final Boolean r = x11Display.isXineramaEnabled(); @@ -159,13 +210,14 @@ public class ScreenDriver extends ScreenImpl { } } - protected void getVirtualScreenOriginAndSize(final Point virtualOrigin, final Dimension virtualSize) { + @Override + protected void calcVirtualScreenOriginAndSize(final Rectangle vOriginSize) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(getWidth0(dpy, screen_idx)); - virtualSize.setHeight(getHeight0(dpy, screen_idx)); + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(getWidth0(dpy, screen_idx)); + vOriginSize.setHeight(getHeight0(dpy, screen_idx)); return null; } } ); } diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index c0552216e..1c7064a66 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -285,47 +285,32 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_stopNSApplic [pool release]; } -static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx) { +static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx, BOOL cap) { NSArray *screens = [NSScreen screens]; - if(screen_idx<0) screen_idx=0; - if(screen_idx>=[screens count]) screen_idx=0; + if( screen_idx<0 || screen_idx>=[screens count] ) { + if( cap ) { + screen_idx=0; + } else { + return NULL; + } + } return (NSScreen *) [screens objectAtIndex: screen_idx]; } -/* - * Class: jogamp_newt_driver_macosx_ScreenDriver - * Method: getWidthImpl - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getWidthImpl0 - (JNIEnv *env, jclass clazz, jint screen_idx) -{ - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - NSScreen *screen = NewtScreen_getNSScreenByIndex((int)screen_idx); - NSRect rect = [screen frame]; - - [pool release]; - - return (jint) (rect.size.width); -} - -/* - * Class: jogamp_newt_driver_macosx_ScreenDriver - * Method: getHeightImpl - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getHeightImpl0 - (JNIEnv *env, jclass clazz, jint screen_idx) -{ - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - NSScreen *screen = NewtScreen_getNSScreenByIndex((int)screen_idx); - NSRect rect = [screen frame]; - - [pool release]; - - return (jint) (rect.size.height); +static NSScreen * NewtScreen_getNSScreenByCoord(int x, int y) { + NSArray *screens = [NSScreen screens]; + int i; + for(i=[screens count]-1; i>=0; i--) { + NSScreen * screen = (NSScreen *) [screens objectAtIndex: i]; + NSRect frame = [screen frame]; + if( x >= frame.origin.x && + y >= frame.origin.y && + x < frame.origin.x + frame.size.width && + y < frame.origin.y + frame.size.height ) { + return screen; + } + } + return (NSScreen *) [screens objectAtIndex: 0]; } static CGDirectDisplayID NewtScreen_getCGDirectDisplayIDByNSScreen(NSScreen *screen) { @@ -362,11 +347,11 @@ static long GetDictionaryLong(CFDictionaryRef theDict, const void* key) /* * Class: jogamp_newt_driver_macosx_ScreenDriver - * Method: getScreenSizeMM0 + * Method: getMonitorProps0 * Signature: (I)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScreenSizeMM0 - (JNIEnv *env, jobject obj, jint scrn_idx) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonitorProps0 + (JNIEnv *env, jobject obj, jint crt_idx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -376,33 +361,46 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree timespec_now(&t0); #endif - NSScreen *screen = NewtScreen_getNSScreenByIndex((int)scrn_idx); #ifdef DBG_PERF timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "MacScreen_getScreenSizeMM0.1: %ld ms\n", td_ms); fflush(NULL); + fprintf(stderr, "MacScreen_getMonitorProps0.1: %ld ms\n", td_ms); fflush(NULL); #endif - + NSScreen *screen = NewtScreen_getNSScreenByIndex((int)crt_idx, false); + if( NULL == screen ) { + [pool release]; + return NULL; + } CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen); #ifdef DBG_PERF timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "MacScreen_getScreenSizeMM0.2: %ld ms\n", td_ms); fflush(NULL); + fprintf(stderr, "MacScreen_getMonitorProps0.2: %ld ms\n", td_ms); fflush(NULL); #endif - CGSize screenDim = CGDisplayScreenSize(display); + CGSize sizeMM = CGDisplayScreenSize(display); #ifdef DBG_PERF timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "MacScreen_getScreenSizeMM0.3: %ld ms\n", td_ms); fflush(NULL); + fprintf(stderr, "MacScreen_getMonitorProps0.3: %ld ms\n", td_ms); fflush(NULL); #endif - jint prop[ 2 ]; - prop[0] = (jint) screenDim.width; - prop[1] = (jint) screenDim.height; - - jintArray properties = (*env)->NewIntArray(env, 2); + CGRect bounds = CGDisplayBounds (display); + + jsize propCount = MIN_MONITOR_DEVICE_PROPERTIES - 1 - NUM_MONITOR_MODE_PROPERTIES; + jint prop[ propCount ]; + int offset = 0; + prop[offset++] = propCount; + prop[offset++] = crt_idx; + prop[offset++] = (jint) sizeMM.width; + prop[offset++] = (jint) sizeMM.height; + prop[offset++] = (jint) bounds.origin.x; // rotated viewport x + prop[offset++] = (jint) bounds.origin.y; // rotated viewport y + prop[offset++] = (jint) bounds.size.width; // rotated viewport width + prop[offset++] = (jint) bounds.size.height; // rotated viewport height + + jintArray properties = (*env)->NewIntArray(env, propCount); if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size 2"); + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", propCount); } - (*env)->SetIntArrayRegion(env, properties, 0, 2, prop); + (*env)->SetIntArrayRegion(env, properties, 0, propCount, prop); [pool release]; @@ -411,16 +409,19 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree /* * Class: jogamp_newt_driver_macosx_ScreenDriver - * Method: getScreenMode0 - * Signature: (IIII)[I + * Method: getMonitorMode0 + * Signature: (II)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScreenMode0 - (JNIEnv *env, jobject obj, jint scrn_idx, jint mode_idx, jint widthMM, jint heightMM) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonitorMode0 + (JNIEnv *env, jobject obj, jint crt_idx, jint mode_idx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - int prop_num = NUM_SCREEN_MODE_PROPERTIES_ALL; - NSScreen *screen = NewtScreen_getNSScreenByIndex((int)scrn_idx); + NSScreen *screen = NewtScreen_getNSScreenByIndex((int)crt_idx, false); + if( NULL == screen ) { + [pool release]; + return NULL; + } CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen); CFArrayRef availableModes = CGDisplayAvailableModes(display); @@ -429,12 +430,13 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree CFDictionaryRef mode = NULL; int currentCCWRot = (int)CGDisplayRotation(display); jint ccwRot = 0; + int nativeId = 0; #ifdef VERBOSE_ON if(0 >= mode_idx) { // only for current mode (-1) and first mode (scanning) DBG_PRINT( "getScreenMode0: scrn %d (%p, %p), mode %d, avail: %d/%d, current rot %d ccw\n", - (int)scrn_idx, screen, (void*)(intptr_t)display, (int)mode_idx, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots, currentCCWRot); + (int)crt_idx, screen, (void*)(intptr_t)display, (int)mode_idx, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots, currentCCWRot); } #endif @@ -443,16 +445,18 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree DBG_PRINT( "getScreenMode0: end of modes: mode %d, avail: %d/%d\n", (int)mode_idx, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots); [pool release]; - return (*env)->NewIntArray(env, 0); + return NULL; } else if(-1 < mode_idx) { // only at initialization time, where index >= 0 - prop_num++; // add 1st extra prop, mode_idx - mode = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModes, mode_idx / ROTMODES_PER_REALMODE); + nativeId = mode_idx / ROTMODES_PER_REALMODE; ccwRot = mode_idx % ROTMODES_PER_REALMODE * 90; + mode = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModes, nativeId); } else { // current mode mode = CGDisplayCurrentMode(display); ccwRot = currentCCWRot; + CFRange range = CFRangeMake (0, numberOfAvailableModes); + nativeId = CFArrayGetFirstIndexOfValue(availableModes, range, (CFDictionaryRef)mode); } // mode = CGDisplayModeRetain(mode); // 10.6 on CGDisplayModeRef @@ -466,36 +470,30 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree mHeight = tempWidth; } - jint prop[ prop_num ]; + jint prop[ NUM_MONITOR_MODE_PROPERTIES_ALL ]; int propIndex = 0; - int propIndexRes = 0; - if( -1 < mode_idx ) { - prop[propIndex++] = mode_idx; - } int refreshRate = CGDDGetModeRefreshRate(mode); int fRefreshRate = ( 0 < refreshRate ) ? refreshRate : 60; // default .. (experienced on OSX 10.6.8) - prop[propIndex++] = 0; // set later for verification of iterator - propIndexRes = propIndex; + prop[propIndex++] = NUM_MONITOR_MODE_PROPERTIES_ALL; prop[propIndex++] = mWidth; prop[propIndex++] = mHeight; prop[propIndex++] = CGDDGetModeBitsPerPixel(mode); - prop[propIndex++] = widthMM; - prop[propIndex++] = heightMM; - prop[propIndex++] = fRefreshRate; + prop[propIndex++] = fRefreshRate * 100; // Hz*100 + prop[propIndex++] = 0; // flags + prop[propIndex++] = nativeId; prop[propIndex++] = ccwRot; - prop[propIndex - NUM_SCREEN_MODE_PROPERTIES_ALL] = ( -1 < mode_idx ) ? propIndex-1 : propIndex ; // count == NUM_SCREEN_MODE_PROPERTIES_ALL - DBG_PRINT( "getScreenMode0: Mode %d/%d (%d): %dx%d, %d bpp, %dx%d mm, %d / %d Hz, rot %d ccw\n", + DBG_PRINT( "getScreenMode0: Mode %d/%d (%d): %dx%d, %d bpp, %d / %d Hz, nativeId %d, rot %d ccw\n", (int)mode_idx, (int)numberOfAvailableModesRots, (int)numberOfAvailableModes, - (int)prop[propIndexRes+0], (int)prop[propIndexRes+1], (int)prop[propIndexRes+2], - (int)prop[propIndexRes+3], (int)prop[propIndexRes+4], (int)prop[propIndexRes+5], refreshRate, (int)prop[propIndexRes+6]); + (int)prop[1], (int)prop[2], (int)prop[3], + (int)prop[4], refreshRate, (int)prop[6], (int)prop[7]); - jintArray properties = (*env)->NewIntArray(env, prop_num); + jintArray properties = (*env)->NewIntArray(env, NUM_MONITOR_MODE_PROPERTIES_ALL); if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", prop_num); + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", NUM_MONITOR_MODE_PROPERTIES_ALL); } - (*env)->SetIntArrayRegion(env, properties, 0, prop_num, prop); + (*env)->SetIntArrayRegion(env, properties, 0, NUM_MONITOR_MODE_PROPERTIES_ALL, prop); // CGDisplayModeRelease(mode); // 10.6 on CGDisplayModeRef [pool release]; @@ -505,36 +503,47 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree /* * Class: jogamp_newt_driver_macosx_ScreenDriver - * Method: setScreenMode0 - * Signature: (II)Z + * Method: setMonitorMode0 + * Signature: (III)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_setScreenMode0 - (JNIEnv *env, jobject object, jint scrn_idx, jint mode_idx) +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_setMonitorMode0 + (JNIEnv *env, jobject object, jint crt_idx, jint nativeId, jint ccwRot) { jboolean res = JNI_TRUE; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSScreen *screen = NewtScreen_getNSScreenByIndex((int)scrn_idx); + NSScreen *screen = NewtScreen_getNSScreenByIndex((int)crt_idx, false); + if( NULL == screen ) { + [pool release]; + return JNI_FALSE; + } CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen); CFArrayRef availableModes = CGDisplayAvailableModes(display); -#ifdef VERBOSE_ON CFIndex numberOfAvailableModes = CFArrayGetCount(availableModes); +#ifdef VERBOSE_ON CFIndex numberOfAvailableModesRots = ROTMODES_PER_REALMODE * numberOfAvailableModes; #endif - CFDictionaryRef mode = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModes, mode_idx / ROTMODES_PER_REALMODE); - // mode = CGDisplayModeRetain(mode); // 10.6 on CGDisplayModeRef - int ccwRot = mode_idx % ROTMODES_PER_REALMODE * 90; - DBG_PRINT( "setScreenMode0: scrn %d (%p, %p), mode %d, rot %d ccw, avail: %d/%d\n", - (int)scrn_idx, screen, (void*)(intptr_t)display, (int)mode_idx, ccwRot, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots); + DBG_PRINT( "setScreenMode0: scrn %d (%p, %p), nativeID %d, rot %d ccw, avail: %d/%d\n", + (int)crt_idx, screen, (void*)(intptr_t)display, (int)nativeId, ccwRot, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots); + + CFDictionaryRef mode = NULL; - if(ccwRot!=0) { + if( 0 != ccwRot ) { // FIXME: How to rotate the display/screen on OSX programmatically ? DBG_PRINT( "setScreenMode0: Don't know how to rotate screen on OS X: rot %d ccw\n", ccwRot); res = JNI_FALSE; + } else { + if( numberOfAvailableModes <= nativeId ) { + res = JNI_FALSE; + } else { + mode = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModes, nativeId); + // mode = CGDisplayModeRetain(mode); // 10.6 on CGDisplayModeRef + } } - if(JNI_TRUE == res) { + + if( NULL != mode ) { CGError err = CGDisplaySwitchToMode(display, mode); if(kCGErrorSuccess != err) { DBG_PRINT( "setScreenMode0: SetMode failed: %d\n", (int)err); @@ -593,21 +602,18 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0 /** * Class: jogamp_newt_driver_macosx_WindowDriver * Method: createView0 - * Signature: (IIIIZI)J + * Signature: (IIIIZ)J */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createView0 (JNIEnv *env, jobject jthis, jint x, jint y, jint w, jint h, - jboolean fullscreen, jint screen_idx) + jboolean fullscreen) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - DBG_PRINT( "createView0 - %p (this), %d/%d %dx%d, fs %d, screenidx %d (START)\n", - (void*)(intptr_t)jthis, (int)x, (int)y, (int)w, (int)h, (int)fullscreen, (int)screen_idx); + DBG_PRINT( "createView0 - %p (this), %d/%d %dx%d, fs %d (START)\n", + (void*)(intptr_t)jthis, (int)x, (int)y, (int)w, (int)h, (int)fullscreen); - NSArray *screens = [NSScreen screens]; - if(screen_idx<0) screen_idx=0; - if(screen_idx>=[screens count]) screen_idx=0; - NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; + NSScreen *myScreen = NewtScreen_getNSScreenByCoord(x, y); NSRect rectWin; if (fullscreen) { @@ -634,24 +640,21 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createView0 * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: createWindow0 - * Signature: (IIIIZIIIJ)J + * Signature: (IIIIZIIJ)J */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow0 (JNIEnv *env, jobject jthis, jint x, jint y, jint w, jint h, - jboolean fullscreen, jint styleMask, jint bufferingType, jint screen_idx, jlong jview) + jboolean fullscreen, jint styleMask, jint bufferingType, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtView* myView = (NewtView*) (intptr_t) jview ; DBG_PRINT( "createWindow0 - %p (this), %d/%d %dx%d, fs %d, style %X, buffType %X, screenidx %d, view %p (START)\n", (void*)(intptr_t)jthis, (int)x, (int)y, (int)w, (int)h, (int)fullscreen, - (int)styleMask, (int)bufferingType, (int)screen_idx, myView); + (int)styleMask, (int)bufferingType, myView); (void)myView; - NSArray *screens = [NSScreen screens]; - if(screen_idx<0) screen_idx=0; - if(screen_idx>=[screens count]) screen_idx=0; - NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; + NSScreen *myScreen = NewtScreen_getNSScreenByCoord(x, y); NSRect rectWin; if (fullscreen) { @@ -670,7 +673,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow styleMask: (NSUInteger) styleMask backing: (NSBackingStoreType) bufferingType defer: YES - screen: myScreen isFullscreenWindow: fullscreen]; // DBG_PRINT( "createWindow0.1 - %p, isVisible %d\n", myWindow, [myWindow isVisible]); @@ -687,26 +689,23 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: initWindow0 - * Signature: (JJIIIIZZZIJ)V + * Signature: (JJIIIIZZZJ)V */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initWindow0 (JNIEnv *env, jobject jthis, jlong parent, jlong window, jint x, jint y, jint w, jint h, - jboolean opaque, jboolean fullscreen, jboolean visible, jint screen_idx, jlong jview) + jboolean opaque, jboolean fullscreen, jboolean visible, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* myWindow = (NewtMacWindow*) ((intptr_t) window); NewtView* myView = (NewtView*) (intptr_t) jview ; - DBG_PRINT( "initWindow0 - %p (this), %p (parent), %p (window), %d/%d %dx%d, opaque %d, fs %d, visible %d, screenidx %d, view %p (START)\n", + DBG_PRINT( "initWindow0 - %p (this), %p (parent), %p (window), %d/%d %dx%d, opaque %d, fs %d, visible %d, view %p (START)\n", (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, (int)x, (int)y, (int)w, (int)h, - (int) opaque, (int)fullscreen, (int)visible, (int)screen_idx, myView); + (int) opaque, (int)fullscreen, (int)visible, myView); - NSArray *screens = [NSScreen screens]; - if(screen_idx<0) screen_idx=0; - if(screen_idx>=[screens count]) screen_idx=0; - NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; - NSRect rectWin; + NSScreen *myScreen = NewtScreen_getNSScreenByCoord(x, y); + NSRect rectWin; if (fullscreen) { rectWin = [myScreen frame]; x = 0; diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index 09f4a1fd3..c9d53f53b 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -128,7 +128,6 @@ styleMask: (NSUInteger) windowStyle backing: (NSBackingStoreType) bufferingType defer: (BOOL) deferCreation - screen:(NSScreen *)screen isFullscreenWindow:(BOOL)isfs; #ifdef DBG_LIFECYCLE - (void) release; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 005e82d72..35d3ffbc5 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -439,14 +439,12 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { styleMask: (NSUInteger) windowStyle backing: (NSBackingStoreType) bufferingType defer: (BOOL) deferCreation - screen:(NSScreen *)screen isFullscreenWindow:(BOOL)isfs { id res = [super initWithContentRect: contentRect styleMask: windowStyle backing: bufferingType - defer: deferCreation - screen: screen]; + defer: deferCreation]; isFullscreenWindow = isfs; // Why is this necessary? Without it we don't get any of the // delegate methods like resizing and window movement. diff --git a/src/newt/native/ScreenMode.h b/src/newt/native/ScreenMode.h index bb782910e..110f1c493 100644 --- a/src/newt/native/ScreenMode.h +++ b/src/newt/native/ScreenMode.h @@ -33,12 +33,17 @@ #ifndef _SCREEN_MODE_H #define _SCREEN_MODE_H -#define NUM_RESOLUTION_PROPERTIES 2 /* width, height */ -#define NUM_SURFACE_SIZE_PROPERTIES 1 /* bpp */ -#define NUM_MONITOR_MODE_PROPERTIES 3 /* ScreenSizeMM[width, height], refresh-rate */ -#define NUM_SCREEN_MODE_PROPERTIES 1 /* rotation */ +#define NUM_RESOLUTION_PROPERTIES 2 /* width, height */ +#define NUM_SURFACE_SIZE_PROPERTIES 1 /* bpp */ +#define NUM_SIZEANDRATE_PROPERTIES 2 /* refresh-rate, flags */ +#define NUM_MONITOR_MODE_PROPERTIES 2 /* id, rotation */ -#define NUM_SCREEN_MODE_PROPERTIES_ALL 8 /* count + the above */ +#define NUM_MONITOR_MODE_PROPERTIES_ALL 8 /* count + the above */ + +#define MIN_MONITOR_DEVICE_PROPERTIES 11 /* count + id, ScreenSizeMM[width, height], rotated Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ */ + +#define FLAG_INTERLACE ( 1 << 0 ) +#define FLAG_DOUBLESCAN ( 1 << 1 ) #endif diff --git a/src/newt/native/Window.h b/src/newt/native/Window.h index 4755c4fc5..d9ee5fd1f 100644 --- a/src/newt/native/Window.h +++ b/src/newt/native/Window.h @@ -38,8 +38,9 @@ #define FLAG_HAS_PARENT ( 1 << 8 ) #define FLAG_IS_UNDECORATED ( 1 << 9 ) #define FLAG_IS_FULLSCREEN ( 1 << 10 ) -#define FLAG_IS_ALWAYSONTOP ( 1 << 11 ) -#define FLAG_IS_VISIBLE ( 1 << 12 ) +#define FLAG_IS_FULLSCREEN_SPAN ( 1 << 11 ) +#define FLAG_IS_ALWAYSONTOP ( 1 << 12 ) +#define FLAG_IS_VISIBLE ( 1 << 13 ) #define TST_FLAG_CHANGE_PARENTING(f) ( 0 != ( (f) & FLAG_CHANGE_PARENTING ) ) #define TST_FLAG_CHANGE_DECORATION(f) ( 0 != ( (f) & FLAG_CHANGE_DECORATION ) ) @@ -47,11 +48,11 @@ #define TST_FLAG_CHANGE_ALWAYSONTOP(f) ( 0 != ( (f) & FLAG_CHANGE_ALWAYSONTOP ) ) #define TST_FLAG_CHANGE_VISIBILITY(f) ( 0 != ( (f) & FLAG_CHANGE_VISIBILITY ) ) -#define TST_FLAG_HAS_PARENT(f) ( 0 != ( (f) & FLAG_HAS_PARENT ) ) -#define TST_FLAG_IS_UNDECORATED(f) ( 0 != ( (f) & FLAG_IS_UNDECORATED ) ) -#define TST_FLAG_IS_FULLSCREEN(f) ( 0 != ( (f) & FLAG_IS_FULLSCREEN ) ) -#define TST_FLAG_IS_FULLSCREEN(f) ( 0 != ( (f) & FLAG_IS_FULLSCREEN ) ) -#define TST_FLAG_IS_ALWAYSONTOP(f) ( 0 != ( (f) & FLAG_IS_ALWAYSONTOP ) ) -#define TST_FLAG_IS_VISIBLE(f) ( 0 != ( (f) & FLAG_IS_VISIBLE ) ) +#define TST_FLAG_HAS_PARENT(f) ( 0 != ( (f) & FLAG_HAS_PARENT ) ) +#define TST_FLAG_IS_UNDECORATED(f) ( 0 != ( (f) & FLAG_IS_UNDECORATED ) ) +#define TST_FLAG_IS_FULLSCREEN(f) ( 0 != ( (f) & FLAG_IS_FULLSCREEN ) ) +#define TST_FLAG_IS_FULLSCREEN_SPAN(f) ( 0 != ( (f) & FLAG_IS_FULLSCREEN_SPAN ) ) +#define TST_FLAG_IS_ALWAYSONTOP(f) ( 0 != ( (f) & FLAG_IS_ALWAYSONTOP ) ) +#define TST_FLAG_IS_VISIBLE(f) ( 0 != ( (f) & FLAG_IS_VISIBLE ) ) #endif diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 5c1115592..7ede3a20d 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -101,6 +101,9 @@ #ifndef DISPLAY_DEVICE_ACTIVE #define DISPLAY_DEVICE_ACTIVE 0x00000001 #endif +#ifndef DM_INTERLACED +#define DM_INTERLACED 2 +#endif #include "jogamp_newt_driver_windows_DisplayDriver.h" #include "jogamp_newt_driver_windows_ScreenDriver.h" @@ -1116,11 +1119,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_DisplayDriver_DispatchMes /* * Class: jogamp_newt_driver_windows_ScreenDriver - * Method: getOriginX0 - * Signature: (I)I + * Method: getVirtualOriginX0 + * Signature: ()I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getOriginX0 - (JNIEnv *env, jobject obj, jint scrn_idx) +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getVirtualOriginX0 + (JNIEnv *env, jobject obj) { if( GetSystemMetrics( SM_CMONITORS) > 1) { return (jint)GetSystemMetrics(SM_XVIRTUALSCREEN); @@ -1131,11 +1134,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getOriginX0 /* * Class: jogamp_newt_driver_windows_ScreenDriver - * Method: getOriginY0 - * Signature: (I)I + * Method: getVirtualOriginY0 + * Signature: ()I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getOriginY0 - (JNIEnv *env, jobject obj, jint scrn_idx) +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getVirtualOriginY0 + (JNIEnv *env, jobject obj) { if( GetSystemMetrics( SM_CMONITORS ) > 1) { return (jint)GetSystemMetrics(SM_YVIRTUALSCREEN); @@ -1146,11 +1149,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getOriginY0 /* * Class: jogamp_newt_driver_windows_ScreenDriver - * Method: getWidthImpl - * Signature: (I)I + * Method: getVirtualWidthImpl + * Signature: ()I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getWidthImpl0 - (JNIEnv *env, jobject obj, jint scrn_idx) +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getVirtualWidthImpl0 + (JNIEnv *env, jobject obj) { if( GetSystemMetrics( SM_CMONITORS) > 1) { return (jint)GetSystemMetrics(SM_CXVIRTUALSCREEN); @@ -1161,11 +1164,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getWidthImpl /* * Class: jogamp_newt_driver_windows_ScreenDriver - * Method: getHeightImpl - * Signature: (I)I + * Method: getVirtualHeightImpl + * Signature: ()I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getHeightImpl0 - (JNIEnv *env, jobject obj, jint scrn_idx) +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getVirtualHeightImpl0 + (JNIEnv *env, jobject obj) { if( GetSystemMetrics( SM_CMONITORS ) > 1) { return (jint)GetSystemMetrics(SM_CYVIRTUALSCREEN); @@ -1217,65 +1220,137 @@ static int NewtScreen_RotationNewtCCW2NativeCCW(JNIEnv *env, jint newt) { return native; } -/* -static void NewtScreen_scanDisplayDevices() { - DISPLAY_DEVICE device; - int i = 0; - LPCTSTR name; - while(NULL != (name = NewtScreen_getDisplayDeviceName(&device, i))) { - DBG_PRINT("*** [%d]: <%s> active %d\n", i, name, ( 0 != ( device.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) ); - i++; +static LPCTSTR NewtScreen_getAdapterName(DISPLAY_DEVICE * device, int crt_idx) { + memset(device, 0, sizeof(DISPLAY_DEVICE)); + device->cb = sizeof(DISPLAY_DEVICE); + if( FALSE == EnumDisplayDevices(NULL, crt_idx, device, 0) ) { + DBG_PRINT("*** WindowsWindow: getAdapterName.EnumDisplayDevices(crt_idx %d) -> FALSE\n", crt_idx); + return NULL; } -}*/ -static LPCTSTR NewtScreen_getDisplayDeviceName(DISPLAY_DEVICE * device, int scrn_idx) { - device->cb = sizeof(DISPLAY_DEVICE); - if( FALSE == EnumDisplayDevices(NULL, scrn_idx, device, 0) ) { - DBG_PRINT("*** WindowsWindow: getDisplayDeviceName.EnumDisplayDevices(scrn_idx %d) -> FALSE\n", scrn_idx); + if( NULL == device->DeviceName || 0 == _tcslen(device->DeviceName) ) { return NULL; } - if( 0 == ( device->StateFlags & DISPLAY_DEVICE_ACTIVE ) ) { - DBG_PRINT("*** WindowsWindow: !DISPLAY_DEVICE_ACTIVE(scrn_idx %d)\n", scrn_idx); + return device->DeviceName; +} + +static LPCTSTR NewtScreen_getMonitorName(LPCTSTR adapterName, DISPLAY_DEVICE * device, int monitor_idx, BOOL onlyActive) { + memset(device, 0, sizeof(DISPLAY_DEVICE)); + device->cb = sizeof(DISPLAY_DEVICE); + if( 0 == monitor_idx ) { + if( FALSE == EnumDisplayDevices(adapterName, monitor_idx, device, 0) ) { + DBG_PRINT("*** WindowsWindow: getDisplayName.EnumDisplayDevices(monitor_idx %d).adapter -> FALSE\n", monitor_idx); + return NULL; + } + } + + if( onlyActive && 0 == ( device->StateFlags & DISPLAY_DEVICE_ACTIVE ) ) { + DBG_PRINT("*** WindowsWindow: !DISPLAY_DEVICE_ACTIVE(monitor_idx %d).display\n", monitor_idx); + return NULL; + } + if( NULL == device->DeviceName || 0 == _tcslen(device->DeviceName) ) { return NULL; } return device->DeviceName; } +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_dumpMonitorInfo0 + (JNIEnv *env, jclass clazz) +{ + DISPLAY_DEVICE aDevice, dDevice; + int i = 0, j; + LPCTSTR aName, dName; + while(NULL != (aName = NewtScreen_getAdapterName(&aDevice, i))) { + fprintf(stderr, "*** [%d]: <%s> flags 0x%X active %d\n", i, aName, aDevice.StateFlags, ( 0 != ( aDevice.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) ); + j=0; + while(NULL != (dName = NewtScreen_getMonitorName(aName, &dDevice, j, FALSE))) { + fprintf(stderr, "*** [%d][%d]: <%s> flags 0x%X active %d\n", i, j, dName, dDevice.StateFlags, ( 0 != ( dDevice.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) ); + j++; + } + i++; + } +} + static HDC NewtScreen_createDisplayDC(LPCTSTR displayDeviceName) { return CreateDC("DISPLAY", displayDeviceName, NULL, NULL); } /* * Class: jogamp_newt_driver_windows_ScreenDriver - * Method: getScreenMode0 - * Signature: (II)[I + * Method: getAdapterName0 + * Signature: (I)Ljava/lang/String; */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getScreenMode0 - (JNIEnv *env, jobject obj, jint scrn_idx, jint mode_idx) +JNIEXPORT jstring JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getAdapterName0 + (JNIEnv *env, jobject obj, jint crt_idx) { DISPLAY_DEVICE device; - int prop_num = NUM_SCREEN_MODE_PROPERTIES_ALL; - LPCTSTR deviceName = NewtScreen_getDisplayDeviceName(&device, scrn_idx); - if(NULL == deviceName) { - DBG_PRINT("*** WindowsWindow: getScreenMode.getDisplayDeviceName(scrn_idx %d) -> NULL\n", scrn_idx); - return (*env)->NewIntArray(env, 0); + LPCTSTR adapterName = NewtScreen_getAdapterName(&device, crt_idx); + DBG_PRINT("*** WindowsWindow: getAdapterName(crt_idx %d) -> %s, active %d\n", crt_idx, + (NULL==adapterName?"nil":adapterName), 0 == ( device.StateFlags & DISPLAY_DEVICE_ACTIVE )); + if(NULL == adapterName) { + return NULL; } +#ifdef UNICODE + return (*env)->NewString(env, adapterName, wcslen(adapterName)); +#else + return (*env)->NewStringUTF(env, adapterName); +#endif +} + +/* + * Class: jogamp_newt_driver_windows_ScreenDriver + * Method: getActiveMonitorName0 + * Signature: (Ljava/lang/String;I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getActiveMonitorName0 + (JNIEnv *env, jobject obj, jstring jAdapterName, jint monitor_idx) +{ + DISPLAY_DEVICE device; + LPCTSTR monitorName; +#ifdef UNICODE + LPCTSTR adapterName = NewtCommon_GetNullTerminatedStringChars(env, jAdapterName); + monitorName = NewtScreen_getMonitorName(adapterName, &device, monitor_idx, TRUE); + DBG_PRINT("*** WindowsWindow: getMonitorName(%s, monitor_idx %d) -> %s\n", adapterName, monitor_idx, (NULL==monitorName?"nil":monitorName)); + free((void*) adapterName); +#else + LPCTSTR adapterName = (*env)->GetStringUTFChars(env, jAdapterName, NULL); + monitorName = NewtScreen_getMonitorName(adapterName, &device, monitor_idx, TRUE); + DBG_PRINT("*** WindowsWindow: getMonitorName(%s, monitor_idx %d) -> %s\n", adapterName, monitor_idx, (NULL==monitorName?"nil":monitorName)); + (*env)->ReleaseStringUTFChars(env, jAdapterName, adapterName); +#endif + if(NULL == monitorName) { + return NULL; + } +#ifdef UNICODE + return (*env)->NewString(env, monitorName, wcslen(monitorName)); +#else + return (*env)->NewStringUTF(env, monitorName); +#endif +} +/* + * Class: jogamp_newt_driver_windows_ScreenDriver + * Method: getMonitorMode0 + * Signature: (Ljava/lang/String;I)[I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMonitorMode0 + (JNIEnv *env, jobject obj, jstring jAdapterName, jint mode_idx) +{ + DISPLAY_DEVICE device; + LPCTSTR adapterName; + { +#ifdef UNICODE + adapterName = NewtCommon_GetNullTerminatedStringChars(env, jAdapterName); +#else + adapterName = (*env)->GetStringUTFChars(env, jAdapterName, NULL); +#endif + } int devModeID; - int widthmm, heightmm; if(-1 < mode_idx) { - // only at initialization time, where index >= 0 - HDC hdc = NewtScreen_createDisplayDC(deviceName); - widthmm = GetDeviceCaps(hdc, HORZSIZE); - heightmm = GetDeviceCaps(hdc, VERTSIZE); - DeleteDC(hdc); devModeID = (int) mode_idx; - prop_num++; // add 1st extra prop, mode_idx } else { - widthmm = 0; - heightmm = 0; devModeID = ENUM_CURRENT_SETTINGS; } @@ -1283,11 +1358,18 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getScre ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); - if (0 == EnumDisplaySettingsEx(deviceName, devModeID, &dm, ( ENUM_CURRENT_SETTINGS == devModeID ) ? 0 : EDS_ROTATEDMODE)) { - DBG_PRINT("*** WindowsWindow: getScreenMode.EnumDisplaySettingsEx(mode_idx %d/%d) -> NULL\n", mode_idx, devModeID); + int res = EnumDisplaySettingsEx(adapterName, devModeID, &dm, ( ENUM_CURRENT_SETTINGS == devModeID ) ? 0 : EDS_ROTATEDMODE); + DBG_PRINT("*** WindowsWindow: getMonitorMode.EnumDisplaySettingsEx(%s, mode_idx %d/%d) -> %d\n", adapterName, mode_idx, devModeID, res); +#ifdef UNICODE + free((void*) adapterName); +#else + (*env)->ReleaseStringUTFChars(env, jAdapterName, adapterName); +#endif + + if (0 == res) { return (*env)->NewIntArray(env, 0); } - + // swap width and height, since Windows reflects rotated dimension, we don't if (DMDO_90 == dm.dmDisplayOrientation || DMDO_270 == dm.dmDisplayOrientation) { int tempWidth = dm.dmPelsWidth; @@ -1295,43 +1377,110 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getScre dm.dmPelsHeight = tempWidth; } - jint prop[ prop_num ]; + int flags = 0; + if( 0 != ( dm.dmDisplayFlags & DM_INTERLACED ) ) { + flags |= FLAG_INTERLACE; + } + + jint prop[ NUM_MONITOR_MODE_PROPERTIES_ALL ]; int propIndex = 0; - if( -1 < mode_idx ) { - prop[propIndex++] = mode_idx; - } - prop[propIndex++] = 0; // set later for verification of iterator + prop[propIndex++] = NUM_MONITOR_MODE_PROPERTIES_ALL; prop[propIndex++] = dm.dmPelsWidth; prop[propIndex++] = dm.dmPelsHeight; prop[propIndex++] = dm.dmBitsPerPel; - prop[propIndex++] = widthmm; - prop[propIndex++] = heightmm; - prop[propIndex++] = dm.dmDisplayFrequency; + prop[propIndex++] = dm.dmDisplayFrequency * 100; // Hz*100 + prop[propIndex++] = flags; + prop[propIndex++] = 0; // not bound to id prop[propIndex++] = NewtScreen_RotationNativeCCW2NewtCCW(env, dm.dmDisplayOrientation); - prop[propIndex - NUM_SCREEN_MODE_PROPERTIES_ALL] = ( -1 < mode_idx ) ? propIndex-1 : propIndex ; // count == NUM_SCREEN_MODE_PROPERTIES_ALL - jintArray properties = (*env)->NewIntArray(env, prop_num); + jintArray properties = (*env)->NewIntArray(env, NUM_MONITOR_MODE_PROPERTIES_ALL); if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", prop_num); + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", NUM_MONITOR_MODE_PROPERTIES_ALL); } - (*env)->SetIntArrayRegion(env, properties, 0, prop_num, prop); + (*env)->SetIntArrayRegion(env, properties, 0, NUM_MONITOR_MODE_PROPERTIES_ALL, prop); return properties; } /* * Class: jogamp_newt_driver_windows_ScreenDriver - * Method: setScreenMode0 - * Signature: (IIIIII)Z + * Method: getMonitorDevice0 + * Signature: (Ljava/lang/String;I)[I */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_setScreenMode0 - (JNIEnv *env, jobject object, jint scrn_idx, jint width, jint height, jint bits, jint rate, jint rot) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMonitorDevice0 + (JNIEnv *env, jobject obj, jstring jAdapterName, jint monitor_idx) { DISPLAY_DEVICE device; - LPCTSTR deviceName = NewtScreen_getDisplayDeviceName(&device, scrn_idx); - if(NULL == deviceName) { - DBG_PRINT("*** WindowsWindow: setScreenMode.getDisplayDeviceName(scrn_idx %d) -> NULL\n", scrn_idx); + LPCTSTR adapterName; + { +#ifdef UNICODE + adapterName = NewtCommon_GetNullTerminatedStringChars(env, jAdapterName); +#else + adapterName = (*env)->GetStringUTFChars(env, jAdapterName, NULL); +#endif + } + + HDC hdc = NewtScreen_createDisplayDC(adapterName); + int widthmm = GetDeviceCaps(hdc, HORZSIZE); + int heightmm = GetDeviceCaps(hdc, VERTSIZE); + DeleteDC(hdc); + int devModeID = ENUM_CURRENT_SETTINGS; + + DEVMODE dm; + ZeroMemory(&dm, sizeof(dm)); + dm.dmSize = sizeof(dm); + + int res = EnumDisplaySettingsEx(adapterName, devModeID, &dm, 0); + DBG_PRINT("*** WindowsWindow: getMonitorDevice.EnumDisplaySettingsEx(%s, devModeID %d) -> %d\n", adapterName, devModeID, res); +#ifdef UNICODE + free((void*) adapterName); +#else + (*env)->ReleaseStringUTFChars(env, jAdapterName, adapterName); +#endif + if (0 == res) { + return (*env)->NewIntArray(env, 0); + } + + jsize propCount = MIN_MONITOR_DEVICE_PROPERTIES - 1 - NUM_MONITOR_MODE_PROPERTIES; + jint prop[ propCount ]; + int propIndex = 0; + + prop[propIndex++] = propCount; + prop[propIndex++] = monitor_idx; + prop[propIndex++] = widthmm; + prop[propIndex++] = heightmm; + prop[propIndex++] = dm.dmPosition.x; // rotated viewport + prop[propIndex++] = dm.dmPosition.y; // rotated viewport + prop[propIndex++] = dm.dmPelsWidth; // rotated viewport + prop[propIndex++] = dm.dmPelsHeight; // rotated viewport + + jintArray properties = (*env)->NewIntArray(env, propCount); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", propCount); + } + (*env)->SetIntArrayRegion(env, properties, 0, propCount, prop); + + return properties; +} + +/* + * Class: jogamp_newt_driver_windows_ScreenDriver + * Method: setMonitorMode0 + * Signature: (IIIIIIIII)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_setMonitorMode0 + (JNIEnv *env, jobject object, jint monitor_idx, jint x, jint y, jint width, jint height, jint bits, jint rate, jint flags, jint rot) +{ + DISPLAY_DEVICE adapterDevice, monitorDevice; + LPCTSTR adapterName = NewtScreen_getAdapterName(&adapterDevice, monitor_idx); + if(NULL == adapterName) { + DBG_PRINT("*** WindowsWindow: setMonitorMode.getAdapterName(monitor_idx %d) -> NULL\n", monitor_idx); + return JNI_FALSE; + } + LPCTSTR monitorName = NewtScreen_getMonitorName(adapterName, &monitorDevice, 0, TRUE); + if(NULL == monitorName) { + DBG_PRINT("*** WindowsWindow: setMonitorMode.getMonitorName(monitor_idx 0) -> NULL\n"); return JNI_FALSE; } @@ -1339,10 +1488,17 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_setScree // initialize the DEVMODE structure ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); + if( 0 <= x && 0 <= y ) { + dm.dmPosition.x = (int)x; + dm.dmPosition.y = (int)y; + } dm.dmPelsWidth = (int)width; dm.dmPelsHeight = (int)height; dm.dmBitsPerPel = (int)bits; dm.dmDisplayFrequency = (int)rate; + if( 0 != ( flags & FLAG_INTERLACE ) ) { + dm.dmDisplayFlags |= DM_INTERLACED; + } dm.dmDisplayOrientation = NewtScreen_RotationNewtCCW2NativeCCW(env, rot); // swap width and height, since Windows reflects rotated dimension, we don't @@ -1352,9 +1508,12 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_setScree dm.dmPelsHeight = tempWidth; } - dm.dmFields = DM_DISPLAYORIENTATION | DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; + dm.dmFields = DM_DISPLAYORIENTATION | DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS; + if( 0 <= x && 0 <= y ) { + dm.dmFields |= DM_POSITION; + } - return ( DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettings(&dm, 0) ) ? JNI_TRUE : JNI_FALSE ; + return ( DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx(adapterName, &dm, NULL, 0, NULL) ) ? JNI_TRUE : JNI_FALSE ; } /* diff --git a/src/newt/native/X11RandR11.c b/src/newt/native/X11RandR11.c index cbf911a38..81a6726b5 100644 --- a/src/newt/native/X11RandR11.c +++ b/src/newt/native/X11RandR11.c @@ -30,10 +30,10 @@ /* * Class: jogamp_newt_driver_x11_RandR11 - * Method: getAvailableScreenModeRotations0 + * Method: getAvailableScreenRotations0 * Signature: (JI)I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getAvailableScreenModeRotations0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getAvailableScreenRotations0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -75,10 +75,10 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getAvailableScre /* * Class: jogamp_newt_driver_x11_RandR11 - * Method: getNumScreenModeResolution0 + * Method: getNumScreenResolution0 * Signature: (JI)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getNumScreenModeResolutions0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getNumScreenResolutions0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -90,7 +90,7 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getNumScreenModeResol #ifdef DBG_PERF timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getNumScreenModeResolution0.1: %ld ms\n", td_ms); fflush(NULL); + fprintf(stderr, "X11Screen_getNumScreenResolution0.1: %ld ms\n", td_ms); fflush(NULL); #endif int num_sizes; @@ -98,20 +98,20 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getNumScreenModeResol #ifdef DBG_PERF timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getNumScreenModeResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL); + fprintf(stderr, "X11Screen_getNumScreenResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL); #endif - DBG_PRINT("getNumScreenModeResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes); + DBG_PRINT("getNumScreenResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes); return num_sizes; } /* * Class: jogamp_newt_driver_x11_RandR11 - * Method: getScreenModeResolutions0 + * Method: getScreenResolutions0 * Signature: (JII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenModeResolution0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenResolution0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -145,10 +145,10 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenModeRes /* * Class: jogamp_newt_driver_x11_RandR11 - * Method: getScreenModeRates0 + * Method: getScreenRates0 * Signature: (JII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenModeRates0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenRates0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -289,36 +289,20 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR11_setCurrentScreenM int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - int rot; if( 0 > resMode_idx || resMode_idx >= num_sizes ) { NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); } - switch(rotation) { - case 0: - rot = RR_Rotate_0; - break; - case 90: - rot = RR_Rotate_90; - break; - case 180: - rot = RR_Rotate_180; - break; - case 270: - rot = RR_Rotate_270; - break; - default: - NewtCommon_throwNewRuntimeException(env, "Invalid rotation: %d", rotation); - } - DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); + int xrot = NewtScreen_Degree2XRotation(env, rotation); + XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); XSync(dpy, False); - XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); + XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, xrot, (short)freq, CurrentTime); XSync(dpy, False); return JNI_TRUE; diff --git a/src/newt/native/X11RandR13.c b/src/newt/native/X11RandR13.c index ea72cd35d..92c20e893 100644 --- a/src/newt/native/X11RandR13.c +++ b/src/newt/native/X11RandR13.c @@ -38,22 +38,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenResources0 { Display *dpy = (Display *) (intptr_t) display; Window root = RootWindow(dpy, (int)screen_idx); -#ifdef DBG_PERF - struct timespec t0, t1, td; - long td_ms; - timespec_now(&t0); -#endif - -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getScreenResources0.1: %ld ms\n", td_ms); fflush(NULL); -#endif - - XRRScreenResources *res = XRRGetScreenResourcesCurrent( dpy, root); -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getScreenResources0.2 (XRRScreenResources): %ld ms\n", td_ms); fflush(NULL); -#endif + + XRRScreenResources *res = XRRGetScreenResourcesCurrent( dpy, root); // 1.3 + // XRRScreenResources *res = XRRGetScreenResources( dpy, root); // 1.2 return (jlong) (intptr_t) res; } @@ -66,48 +53,166 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenResources0 JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_freeScreenResources0 (JNIEnv *env, jclass clazz, jlong screenResources) { - XRRFreeScreenResources( (XRRScreenResources *) (intptr_t) screenResources ); + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + if( NULL != resources ) { + XRRFreeScreenResources( resources ); + } +} + +#define SAFE_STRING(s) (NULL==s?"":s) + +static void dumpOutputs(const char *prefix, Display *dpy, XRRScreenResources *resources, int noutput, RROutput * outputs) { + int i, j; + fprintf(stderr, "%s %p: Output count %d\n", prefix, resources, noutput); + for(i=0; icrtc, SAFE_STRING(xrrOutputInfo->name), xrrOutputInfo->nameLen, xrrOutputInfo->mm_width, xrrOutputInfo->mm_height, + xrrOutputInfo->ncrtc, xrrOutputInfo->nmode, xrrOutputInfo->npreferred); + for(j=0; jnmode; j++) { + fprintf(stderr, " Output[%d].Mode[%d].id %#lx\n", i, j, xrrOutputInfo->modes[j]); + } + XRRFreeOutputInfo (xrrOutputInfo); + } } -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getOrigin0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +/** Returns vertical refresh rate in hertz */ +static float getVRefresh(XRRModeInfo *mode) { + float rate; + unsigned int vTotal = mode->vTotal; + + if (mode->modeFlags & RR_DoubleScan) { + /* doublescan doubles the number of lines */ + vTotal *= 2; + } + + if (mode->modeFlags & RR_Interlace) { + /* interlace splits the frame into two fields */ + /* the field rate is what is typically reported by monitors */ + vTotal /= 2; + } + + if (mode->hTotal && vTotal) { + rate = ( (float) mode->dotClock / + ( (float) mode->hTotal * (float) vTotal ) + ); + } else { + rate = 0; + } + return rate; +} + + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_dumpInfo0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenResources) { Display * dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); + Window root = RootWindow(dpy, (int)screen_idx); + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; int pos[] = { 0, 0 } ; + int i, j, minWidth, minHeight, maxWidth, maxHeight; - int i; - XRRScreenResources *xrrScreenResources = XRRGetScreenResources(dpy, root); - fprintf(stderr, "XRRScreenResources %p: RRCrtc crtcs %d\n", xrrScreenResources, xrrScreenResources->ncrtc); - for(i=0; incrtc; i++) { - RRCrtc crtc = xrrScreenResources->crtcs[i]; - XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, xrrScreenResources, crtc); - fprintf(stderr, "RRCrtc %d: %d/%d %dx%d\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height); + int vs_width = DisplayWidth(dpy, screen_idx); + int vs_height = DisplayHeight(dpy, screen_idx); + int vs_width_mm = DisplayWidthMM(dpy, screen_idx); + int vs_height_mm = DisplayHeightMM(dpy, screen_idx); + fprintf(stderr, "ScreenVirtualSize: %dx%d %dx%d mm\n", vs_width, vs_height, vs_width_mm, vs_height_mm); + + XRRGetScreenSizeRange (dpy, root, &minWidth, &minHeight, &maxWidth, &maxHeight); + fprintf(stderr, "XRRGetScreenSizeRange: %dx%d .. %dx%d\n", minWidth, minHeight, maxWidth, maxHeight); + + if( NULL == resources ) { + fprintf(stderr, "XRRScreenResources NULL\n"); + return; + } + fprintf(stderr, "XRRScreenResources %p: Crtc count %d\n", resources, resources->ncrtc); + for(i=0; incrtc; i++) { + RRCrtc crtc = resources->crtcs[i]; + XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, resources, crtc); + fprintf(stderr, "Crtc[%d]: %d/%d %dx%d, rot 0x%X, mode.id %#lx\n", + i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height, xrrCrtcInfo->rotations, xrrCrtcInfo->mode); + for(j=0; jnoutput; j++) { + fprintf(stderr, " Crtc[%d].Output[%d].id %#lx\n", i, j, xrrCrtcInfo->outputs[j]); + } XRRFreeCrtcInfo(xrrCrtcInfo); } - jintArray jpos = (*env)->NewIntArray(env, num_rotations); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 2); + dumpOutputs("XRRScreenResources.outputs", dpy, resources, resources->noutput, resources->outputs); + + fprintf(stderr, "XRRScreenResources %p: Mode count %d\n", resources, resources->nmode); + for(i=0; inmode; i++) { + XRRModeInfo *mode = &resources->modes[i]; + + unsigned int dots = mode->hTotal * mode->vTotal; + float refresh = getVRefresh(mode); + fprintf(stderr, "Mode[%d, id %#lx]: %ux%u@%f, name %s\n", i, mode->id, mode->width, mode->height, refresh, SAFE_STRING(mode->name)); } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, jpos, 0, 2, pos); - return jpos; } -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getAvailableScreenModeRotations0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getMonitorDeviceCount0 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDeviceCount0 + (JNIEnv *env, jclass clazz, jlong screenResources) +{ + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + return ( NULL != resources ) ? resources->ncrtc : 0; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getMonitorInfoHandle0 + * Signature: (JIJI)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorInfoHandle0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenResources, jint crt_idx) { Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - int num_rotations = 0; - Rotation cur_rotation, rotations_supported; - int rotations[4]; - int major, minor; + Window root = RootWindow(dpy, (int)screen_idx); + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; - rotations_supported = XRRRotations (dpy, (int)scrn_idx, &cur_rotation); + if( NULL == resources || crt_idx >= resources->ncrtc ) { + return 0; + } + RRCrtc crtc = resources->crtcs[crt_idx]; + XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, resources, crtc); + return (jlong) (intptr_t) xrrCrtcInfo; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: freeMonitorInfoHandle0 + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_freeMonitorInfoHandle0 + (JNIEnv *env, jclass clazz, jlong monitorInfo) +{ + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; + if( NULL != xrrCrtcInfo ) { + XRRFreeCrtcInfo( xrrCrtcInfo ); + } +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getAvailableRotations0 + * Signature: (J)I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getAvailableRotations0 + (JNIEnv *env, jclass clazz, jlong monitorInfo) +{ + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; + if( NULL == xrrCrtcInfo ) { + return NULL; + } + Rotation rotations_supported = xrrCrtcInfo->rotations; + + int num_rotations = 0; + int rotations[4]; if(0 != (rotations_supported & RR_Rotate_0)) { rotations[num_rotations++] = 0; } @@ -120,7 +225,7 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getAvailableScre if(0 != (rotations_supported & RR_Rotate_270)) { rotations[num_rotations++] = 270; } - + jintArray properties = NULL; if(num_rotations>0) { @@ -136,273 +241,275 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getAvailableScre return properties; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getNumScreenModeResolutions0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getMonitorViewport0 + * Signature: (J)[I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorViewport0 + (JNIEnv *env, jclass clazz, jlong monitorInfo) { - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - DBG_PRINT("getNumScreenModeResolutions0: %d\n", num_sizes); + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; - int i; - XRRScreenResources *xrrScreenResources = XRRGetScreenResources(dpy, root); - fprintf(stderr, "XRRScreenResources %p: RRCrtc crtcs %d\n", xrrScreenResources, xrrScreenResources->ncrtc); - for(i=0; incrtc; i++) { - RRCrtc crtc = xrrScreenResources->crtcs[i]; - XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, xrrScreenResources, crtc); - fprintf(stderr, "RRCrtc %d: %d/%d %dx%d\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height); - XRRFreeCrtcInfo(xrrCrtcInfo); + if( NULL == xrrCrtcInfo ) { + // n/a + return NULL; } - fprintf(stderr, "XRRScreenResources %p: XRRModeInfo modes %d\n", xrrScreenResources, xrrScreenResources->nmode); - for(i=0; inmode; i++) { - XRRModeInfo xrrModeInfo = xrrScreenResources->modes[i]; - fprintf(stderr, "XRRModeInfo %d: %dx%d, %s, %X\n", i, xrrModeInfo.width, xrrModeInfo.height, xrrModeInfo.name, xrrModeInfo.id); + + if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { + // disabled + return NULL; } - XRRFreeScreenResources(xrrScreenResources); - return num_sizes; + jsize propCount = 4; + jint prop[ propCount ]; + int propIndex = 0; + + prop[propIndex++] = xrrCrtcInfo->x; + prop[propIndex++] = xrrCrtcInfo->y; + prop[propIndex++] = xrrCrtcInfo->width; + prop[propIndex++] = xrrCrtcInfo->height; + + jintArray properties = (*env)->NewIntArray(env, propCount); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", propCount); + } + (*env)->SetIntArrayRegion(env, properties, 0, propCount, prop); + + return properties; } /* * Class: jogamp_newt_driver_x11_RandR13 - * Method: getScreenModeResolutions0 - * Signature: (JII)[I + * Method: getMonitorMode0 + * Signature: (JI)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenModeResolution0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorMode0 + (JNIEnv *env, jclass clazz, jlong screenResources, jint mode_idx) { - Display *dpy = (Display *) (intptr_t) display; - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + + if( NULL == resources || mode_idx >= resources->nmode ) { + return NULL; + } - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + XRRModeInfo *mode = &resources->modes[mode_idx]; + unsigned int dots = mode->hTotal * mode->vTotal; + int refresh = (int) ( getVRefresh(mode) * 100.0f ); // Hz * 100 + int flags = 0; + if (mode->modeFlags & RR_Interlace) { + flags |= FLAG_INTERLACE; } - - // Fill the properties in temp jint array + if (mode->modeFlags & RR_DoubleScan) { + flags |= FLAG_DOUBLESCAN; + } + + jint prop[ NUM_MONITOR_MODE_PROPERTIES_ALL ]; int propIndex = 0; - jint prop[4]; - - prop[propIndex++] = xrrs[(int)resMode_idx].width; - prop[propIndex++] = xrrs[(int)resMode_idx].height; - prop[propIndex++] = xrrs[(int)resMode_idx].mwidth; - prop[propIndex++] = xrrs[(int)resMode_idx].mheight; - - jintArray properties = (*env)->NewIntArray(env, 4); + + prop[propIndex++] = NUM_MONITOR_MODE_PROPERTIES_ALL; + prop[propIndex++] = mode->width; + prop[propIndex++] = mode->height; + prop[propIndex++] = 32; // TODO: XRandR > 1.4 may support bpp + prop[propIndex++] = refresh; + prop[propIndex++] = flags; + prop[propIndex++] = mode->id; + prop[propIndex++] = -1; // rotation placeholder + + jintArray properties = (*env)->NewIntArray(env, NUM_MONITOR_MODE_PROPERTIES_ALL); if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 4); + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", NUM_MONITOR_MODE_PROPERTIES_ALL); } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, 4, prop); + (*env)->SetIntArrayRegion(env, properties, 0, NUM_MONITOR_MODE_PROPERTIES_ALL, prop); return properties; } /* * Class: jogamp_newt_driver_x11_RandR13 - * Method: getScreenModeRates0 - * Signature: (JII)[I + * Method: getMonitorCurrentMode0 + * Signature: (JJ)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenModeRates0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorCurrentMode0 + (JNIEnv *env, jclass clazz, jlong screenResources, jlong monitorInfo) { - Display *dpy = (Display *) (intptr_t) display; - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + if( NULL == resources || NULL == xrrCrtcInfo ) { + // n/a + return NULL; } - - int num_rates; - short *rates = XRRRates(dpy, (int)scrn_idx, (int)resMode_idx, &num_rates); - - jint prop[num_rates]; + + if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { + // disabled + return NULL; + } + + int modeId = xrrCrtcInfo->mode; + XRRModeInfo *mode = NULL; int i; - for(i=0; inmode; i++) { + XRRModeInfo *imode = &resources->modes[i]; + if( imode->id == modeId ) { + mode = imode; + break; + } } - - jintArray properties = (*env)->NewIntArray(env, num_rates); + if( NULL == mode ) { + // oops .. + return NULL; + } + + unsigned int dots = mode->hTotal * mode->vTotal; + int refresh = (int) ( getVRefresh(mode) * 100.0f ); // Hz * 100 + int flags = 0; + if (mode->modeFlags & RR_Interlace) { + flags |= FLAG_INTERLACE; + } + if (mode->modeFlags & RR_DoubleScan) { + flags |= FLAG_DOUBLESCAN; + } + + jint prop[ NUM_MONITOR_MODE_PROPERTIES_ALL ]; + int propIndex = 0; + + prop[propIndex++] = NUM_MONITOR_MODE_PROPERTIES_ALL; + prop[propIndex++] = mode->width; + prop[propIndex++] = mode->height; + prop[propIndex++] = 32; // TODO: XRandR > 1.4 may support bpp + prop[propIndex++] = refresh; + prop[propIndex++] = flags; + prop[propIndex++] = mode->id; + prop[propIndex++] = NewtScreen_XRotation2Degree(env, xrrCrtcInfo->rotation); + + jintArray properties = (*env)->NewIntArray(env, NUM_MONITOR_MODE_PROPERTIES_ALL); if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rates); + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", NUM_MONITOR_MODE_PROPERTIES_ALL); } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rates, prop); + (*env)->SetIntArrayRegion(env, properties, 0, NUM_MONITOR_MODE_PROPERTIES_ALL, prop); return properties; } /* * Class: jogamp_newt_driver_x11_RandR13 - * Method: getCurrentScreenRate0 - * Signature: (JI)I + * Method: getMonitorDevice0 + * Signature: (JJJJ)[I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getCurrentScreenRate0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDevice0 + (JNIEnv *env, jclass clazz, jlong display, jlong screenResources, jlong monitorInfo, jint crt_idx) { - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - // get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - short original_rate = XRRConfigCurrentRate(conf); + Display * dpy = (Display *) (intptr_t) display; + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; - //free - XRRFreeScreenConfigInfo(conf); - - DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); + if( NULL == resources || NULL == xrrCrtcInfo || crt_idx >= resources->ncrtc ) { + // n/a + return NULL; + } - return (jint) original_rate; -} + if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { + // disabled + return NULL; + } -/* - * Class: jogamp_newt_driver_x11_RandR13 - * Method: getCurrentScreenRotation0 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getCurrentScreenRotation0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - //get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - - Rotation rotation; - XRRConfigCurrentConfiguration(conf, &rotation); + RROutput output = xrrCrtcInfo->outputs[0]; + XRROutputInfo * xrrOutputInfo = XRRGetOutputInfo (dpy, resources, output); + int numModes = xrrOutputInfo->nmode; - //free - XRRFreeScreenConfigInfo(conf); - - return NewtScreen_XRotation2Degree(env, rotation); -} + jsize propCount = MIN_MONITOR_DEVICE_PROPERTIES - 1 + numModes; + jint prop[ propCount ]; + int propIndex = 0; + prop[propIndex++] = propCount; + prop[propIndex++] = crt_idx; + prop[propIndex++] = xrrOutputInfo->mm_width; + prop[propIndex++] = xrrOutputInfo->mm_height; + prop[propIndex++] = xrrCrtcInfo->x; + prop[propIndex++] = xrrCrtcInfo->y; + prop[propIndex++] = xrrCrtcInfo->width; + prop[propIndex++] = xrrCrtcInfo->height; + prop[propIndex++] = xrrCrtcInfo->mode; // current mode id + prop[propIndex++] = NewtScreen_XRotation2Degree(env, xrrCrtcInfo->rotation); + int i; + for(i=0; imodes[i]; + } -/* - * Class: jogamp_newt_driver_x11_RandR13 - * Method: getCurrentScreenResolutionIndex0 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getCurrentScreenResolutionIndex0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - // get current resolutions and frequency configuration - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - short original_rate = XRRConfigCurrentRate(conf); - - Rotation original_rotation; - SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); - - //free - XRRFreeScreenConfigInfo(conf); - - DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); - return (jint)original_size_id; + XRRFreeOutputInfo (xrrOutputInfo); + + jintArray properties = (*env)->NewIntArray(env, propCount); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", propCount); + } + (*env)->SetIntArrayRegion(env, properties, 0, propCount, prop); + + return properties; } /* * Class: jogamp_newt_driver_x11_RandR13 - * Method: setCurrentScreenModeStart0 - * Signature: (JIIII)Z + * Method: setMonitorMode0 + * Signature: (JJJIIIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setCurrentScreenModeStart0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setMonitorMode0 + (JNIEnv *env, jclass clazz, jlong display, jlong screenResources, jlong monitorInfo, jint crt_idx, jint modeId, jint rotation, jint x, jint y) { - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)screen_idx); + Display * dpy = (Display *) (intptr_t) display; + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; + jboolean res = JNI_FALSE; - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - int rot; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + if( NULL == resources || NULL == xrrCrtcInfo || crt_idx >= resources->ncrtc ) { + // n/a + return res; } - conf = XRRGetScreenInfo(dpy, root); - - rot = int NewtScreen_Degree2XRotation(env, rotation); - - DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", - resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); + if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { + // disabled + return res; + } - XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); + if( 0 >= modeId ) { + // oops .. + return res; + } - XSync(dpy, False); - XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); - XSync(dpy, False); + if( 0 > x || 0 > y ) { + x = xrrCrtcInfo->x; + y = xrrCrtcInfo->y; + } - //free - XRRFreeScreenConfigInfo(conf); - XSync(dpy, False); + Status status = XRRSetCrtcConfig( dpy, resources, resources->crtcs[crt_idx], CurrentTime, + x, y, modeId, NewtScreen_Degree2XRotation(env, rotation), + xrrCrtcInfo->outputs, xrrCrtcInfo->noutput ); + res = status == RRSetConfigSuccess; - return JNI_TRUE; + return res; } /* * Class: jogamp_newt_driver_x11_RandR13 - * Method: setCurrentScreenModePollEnd0 - * Signature: (J)Z + * Method: setScreenViewport0 + * Signature: (JIJIIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setCurrentScreenModePollEnd0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setScreenViewport0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenResources, jint x, jint y, jint width, jint height) { - Display *dpy = (Display *) (intptr_t) display; - int randr_event_base, randr_error_base; - XEvent evt; - XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; + Display * dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)screen_idx); + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + jboolean res = JNI_FALSE; - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + if( NULL == resources ) { + // n/a + return JNI_FALSE; } - XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); - - int done = 0; - int rot; - do { - if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { - return; - } - XNextEvent(dpy, &evt); - - switch (evt.type - randr_event_base) { - case RRScreenChangeNotify: - rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call %p (root %p) resIdx %d rot %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, rot, - scn_event->width, scn_event->height); - // done = scn_event->size_index == resMode_idx; // not reliable .. - done = rot == rotation && - scn_event->width == xrrs[resMode_idx].width && - scn_event->height == xrrs[resMode_idx].height; - break; - default: - DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); - } - XRRUpdateConfiguration(&evt); - } while(!done); - - XSync(dpy, False); - + XRRSetScreenSize (dpy, root, width, height, DisplayWidthMM(dpy, screen_idx), DisplayHeightMM(dpy, screen_idx)); + return JNI_TRUE; } + diff --git a/src/newt/native/X11Screen.c b/src/newt/native/X11Screen.c index 3d4b2a26c..152a092c9 100644 --- a/src/newt/native/X11Screen.c +++ b/src/newt/native/X11Screen.c @@ -75,22 +75,41 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getHeight0 } int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation) { - int rot; + int degree; if(xrotation == RR_Rotate_0) { - rot = 0; + degree = 0; } else if(xrotation == RR_Rotate_90) { - rot = 90; + degree = 90; } else if(xrotation == RR_Rotate_180) { - rot = 180; + degree = 180; } else if(xrotation == RR_Rotate_270) { - rot = 270; + degree = 270; } else { NewtCommon_throwNewRuntimeException(env, "invalid native rotation: %d", xrotation); } - return rot; + return degree; +} + +int NewtScreen_Degree2XRotation(JNIEnv *env, int degree) { + int xrot; + if(degree == 0) { + xrot = RR_Rotate_0; + } + else if(degree == 90) { + xrot = RR_Rotate_90; + } + else if(degree == 180) { + xrot = RR_Rotate_180; + } + else if(degree == 270) { + xrot = RR_Rotate_270; + } else { + NewtCommon_throwNewRuntimeException(env, "invalid degree: %d", degree); + } + return xrot; } /* diff --git a/src/newt/native/X11Screen.h b/src/newt/native/X11Screen.h index 1a1440054..c81ee05d5 100644 --- a/src/newt/native/X11Screen.h +++ b/src/newt/native/X11Screen.h @@ -33,5 +33,6 @@ #include "X11Common.h" int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation); +int NewtScreen_Degree2XRotation(JNIEnv *env, int degree); #endif /* _X11SCREEN_H */ diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 9e96169f5..6c5a127b6 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -438,7 +438,7 @@ Status NewtWindows_updateInsets(JNIEnv *env, jobject jwindow, Display *dpy, Wind return 0; // Error } -static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy, Window w, jboolean force) { +static void NewtWindows_requestFocus (Display *dpy, Window w, Bool force) { XWindowAttributes xwa; Window focus_return; int revert_to_return; @@ -447,7 +447,7 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy, XGetInputFocus(dpy, &focus_return, &revert_to_return); DBG_PRINT( "X11: requestFocus dpy %p,win %p, force %d, hasFocus %d\n", dpy, (void*)w, force, focus_return==w); - if( JNI_TRUE==force || focus_return!=w) { + if( True==force || focus_return!=w) { DBG_PRINT( "X11: XRaiseWindow dpy %p, win %p\n", dpy, (void*)w); XRaiseWindow(dpy, w); NewtWindows_setCWAbove(dpy, w); @@ -743,7 +743,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo Bool tempInvisible = ( TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_PARENTING(flags) ) && isVisible ; int fsEWMHFlags = 0; if( TST_FLAG_CHANGE_FULLSCREEN(flags) ) { - fsEWMHFlags |= _NET_WM_FULLSCREEN; + if( !TST_FLAG_IS_FULLSCREEN_SPAN(flags) ) { // doesn't work w/ spanning across monitors + fsEWMHFlags |= _NET_WM_FULLSCREEN; + } if( TST_FLAG_IS_FULLSCREEN(flags) ) { if( TST_FLAG_IS_ALWAYSONTOP(flags) ) { fsEWMHFlags |= _NET_WM_ABOVE; // fs on, above on @@ -756,12 +758,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo fsEWMHFlags |= _NET_WM_ABOVE; // toggle above } - DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d, parent %p/%p, win %p, %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d, alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d, tempInvisible %d, fsEWMHFlags %d\n", + DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d, parent %p/%p, win %p, %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d (span %d), alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d, tempInvisible %d, fsEWMHFlags %d\n", (void*)dpy, screen_index, (void*) jparent, (void*)parent, (void*)w, x, y, width, height, TST_FLAG_CHANGE_PARENTING(flags), TST_FLAG_HAS_PARENT(flags), TST_FLAG_CHANGE_DECORATION(flags), TST_FLAG_IS_UNDECORATED(flags), - TST_FLAG_CHANGE_FULLSCREEN(flags), TST_FLAG_IS_FULLSCREEN(flags), + TST_FLAG_CHANGE_FULLSCREEN(flags), TST_FLAG_IS_FULLSCREEN(flags), TST_FLAG_IS_FULLSCREEN_SPAN(flags), TST_FLAG_CHANGE_ALWAYSONTOP(flags), TST_FLAG_IS_ALWAYSONTOP(flags), TST_FLAG_CHANGE_VISIBILITY(flags), TST_FLAG_IS_VISIBLE(flags), tempInvisible, fsEWMHFlags); @@ -769,9 +771,13 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo // However, we have to consider other cases like reparenting and WM which don't support it. if( fsEWMHFlags && !TST_FLAG_CHANGE_PARENTING(flags) && isVisible && + !TST_FLAG_IS_FULLSCREEN_SPAN(flags) && ( TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_ALWAYSONTOP(flags) ) ) { Bool enable = TST_FLAG_CHANGE_FULLSCREEN(flags) ? TST_FLAG_IS_FULLSCREEN(flags) : TST_FLAG_IS_ALWAYSONTOP(flags) ; if( NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, enable) ) { + if ( TST_FLAG_CHANGE_FULLSCREEN(flags) && !TST_FLAG_IS_FULLSCREEN(flags) ) { // FS off - restore decoration + NewtWindows_setDecorations (dpy, w, TST_FLAG_IS_UNDECORATED(flags) ? False : True); + } #ifdef FS_GRAB_KEYBOARD if(TST_FLAG_CHANGE_FULLSCREEN(flags)) { if(TST_FLAG_IS_FULLSCREEN(flags)) { @@ -866,7 +872,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_requestFocus0 (JNIEnv *env, jobject obj, jlong display, jlong window, jboolean force) { - NewtWindows_requestFocus ( env, obj, (Display *) (intptr_t) display, (Window)window, force ) ; + NewtWindows_requestFocus ( (Display *) (intptr_t) display, (Window)window, JNI_TRUE==force?True:False ) ; } /* diff --git a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java index 0dead125a..88cd9a719 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java @@ -32,8 +32,8 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.ElektronenMultiplizierer; @@ -58,11 +58,13 @@ public class NEWTElektronActivity extends NewtBaseActivity { setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new ElektronenMultiplizierer()); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java index c020413cf..f10cfc11f 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java @@ -32,8 +32,8 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es1.GearsES1; @@ -63,11 +63,13 @@ public class NEWTGearsES1Activity extends NewtBaseActivity { setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GearsES1(-1)); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java index 542912c08..2e9774565 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java @@ -36,10 +36,10 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; -import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.event.MonitorEvent; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -75,11 +75,13 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { GearsES2 demo = new GearsES2(-1); // demo.enableAndroidTrace(true); glWindow.addGLEventListener(demo); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); if( null != System.getProperty(forceKillProcessTest) ) { Log.d(TAG, "forceKillProcessTest"); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java index 5e7a5c489..c87e66189 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java @@ -57,6 +57,7 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc // props.setProperty("jogl.debug.DebugGL", "true"); // props.setProperty("jogl.debug.TraceGL", "true"); // props.setProperty("newt.debug", "all"); + props.setProperty("newt.debug.Screen", "true"); props.setProperty("newt.debug.Window", "true"); props.setProperty("newt.debug.Window.MouseEvent", "true"); props.setProperty("newt.debug.Window.KeyEvent", "true"); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java index 18c3cb042..98e6b7c5f 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java @@ -34,8 +34,8 @@ import jogamp.newt.driver.android.NewtBaseActivity; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -65,11 +65,13 @@ public class NEWTGearsES2TransActivity extends NewtBaseActivity { setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GearsES2(-1)); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); Animator animator = new Animator(glWindow); // glWindow.setSkipContextReleaseThread(animator.getThread()); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java index bbd4f9f20..42db9d8dd 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java @@ -32,8 +32,8 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.graph.demos.GPUUISceneGLListener0A; @@ -61,11 +61,13 @@ public class NEWTGraphUI1pActivity extends NewtBaseActivity { setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GPUUISceneGLListener0A(0)); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java index 20ba3f484..c68de95cc 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java @@ -33,8 +33,8 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; import com.jogamp.graph.curve.Region; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.graph.demos.GPUUISceneGLListener0A; @@ -62,11 +62,13 @@ public class NEWTGraphUI2pActivity extends NewtBaseActivity { setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GPUUISceneGLListener0A(Region.VBAA_RENDERING_BIT)); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java index 06ce75ac5..08fbf643d 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java @@ -32,8 +32,8 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; @@ -57,11 +57,13 @@ public class NEWTRedSquareES1Activity extends NewtBaseActivity { setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new RedSquareES1(-1)); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java index 02e2d8f01..cefdd842b 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java @@ -32,8 +32,8 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; @@ -62,11 +62,13 @@ public class NEWTRedSquareES2Activity extends NewtBaseActivity { final RedSquareES2 demo = new RedSquareES2(-1); // demo.enableAndroidTrace(true); glWindow.addGLEventListener(demo); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); Animator animator = new Animator(glWindow); // animator.setRunAsFastAsPossible(true); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 50f759079..4c6cae501 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -163,13 +163,25 @@ public class TestGearsES2NEWT extends UITestCase { }); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + @Override + public void keyPressed(final KeyEvent e) { + if( e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { final Thread t = glWindow.setExclusiveContextThread(null); System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); - glWindow.setFullscreen(!glWindow.isFullscreen()); + if( glWindow.isFullscreen() ) { + glWindow.setFullscreen( false ); + } else { + if( e.isAltDown() ) { + glWindow.setFullscreen( null ); + } else { + glWindow.setFullscreen( true ); + } + } System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setExclusiveContextThread(t); } }.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java index 98620e0c1..90d4a9c1f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java @@ -28,8 +28,8 @@ package com.jogamp.opengl.test.junit.jogl.glsl; import com.jogamp.common.nio.Buffers; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.MonitorMode; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; @@ -109,11 +109,13 @@ public class TestRulerNEWT01 extends UITestCase { Assert.assertNotNull(winctx); Assert.assertNotNull(winctx.window); Assert.assertNotNull(winctx.window.getScreen()); - ScreenMode sm = winctx.window.getScreen().getCurrentScreenMode(); - Assert.assertNotNull(sm); - System.err.println(sm); - final MonitorMode mmode = sm.getMonitorMode(); - final DimensionImmutable sdim = mmode.getScreenSizeMM(); + final MonitorDevice monitor = winctx.window.getMainMonitor(); + Assert.assertNotNull(monitor); + System.err.println(monitor); + final MonitorMode mmode = monitor.getCurrentMode(); + Assert.assertNotNull(mmode); + System.err.println(mmode); + final DimensionImmutable sdim = monitor.getSizeMM(); final DimensionImmutable spix = mmode.getSurfaceSize().getResolution(); final GLUniformData rulerPixFreq = new GLUniformData("gcu_RulerPixFreq", 2, Buffers.newDirectFloatBuffer(2)); final FloatBuffer rulerPixFreqV = (FloatBuffer) rulerPixFreq.getBuffer(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java index 29ec443f7..a7b65545a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java @@ -35,11 +35,12 @@ import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.Animator; import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; -import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.MonitorMode; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.newt.util.MonitorModeUtil; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.UITestCase; import java.util.List; @@ -72,8 +73,8 @@ public class ManualScreenMode03NEWT extends UITestCase { Screen screen = NewtFactory.createScreen(display, 0); // screen 0 GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - List screenModes = screen.getScreenModes(); - if(null==screenModes) { + List monitorModes = screen.getMonitorModes(); + if(null==monitorModes) { // no support .. System.err.println("Your platform has no ScreenMode change support, sorry"); return; @@ -81,18 +82,21 @@ public class ManualScreenMode03NEWT extends UITestCase { Animator animator = new Animator(window); animator.start(); - ScreenMode smCurrent = screen.getCurrentScreenMode(); - ScreenMode smOrig = screen.getOriginalScreenMode(); - System.err.println("[0] current/orig: "+smCurrent); + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mmCurrent = monitor.queryCurrentMode(); + MonitorMode mmOrig = monitor.getOriginalMode(); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); - screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate()); - screenModes = ScreenModeUtil.filterByRotation(screenModes, 0); - screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601)); - screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - ScreenMode sm = (ScreenMode) screenModes.get(0); - System.err.println("[0] set current: "+sm); - screen.setCurrentScreenMode(sm); + MonitorMode mm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+mm); + monitor.setCurrentMode(mm); System.err.print("[0] post setting .. wait <"); try { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java index 577119bcd..f64cf2eb8 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java @@ -35,18 +35,23 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import com.jogamp.common.util.ArrayHashSet; import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.MonitorMode; import com.jogamp.newt.Screen; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.MonitorMode; -import com.jogamp.newt.util.ScreenModeUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import java.util.Iterator; import java.util.List; import javax.media.nativewindow.util.Dimension; import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.SurfaceSize; +import javax.media.opengl.GLProfile; + +import jogamp.newt.MonitorDeviceImpl; +import jogamp.newt.MonitorModeProps; public class TestScreenMode00NEWT extends UITestCase { static int screenIdx = 0; @@ -59,6 +64,7 @@ public class TestScreenMode00NEWT extends UITestCase { @BeforeClass public static void initClass() { + GLProfile.initSingleton(); // hack to initialize GL for BCM_IV (Rasp.Pi) NativeWindowFactory.initSingleton(); width = 640; height = 480; @@ -66,31 +72,46 @@ public class TestScreenMode00NEWT extends UITestCase { @Test public void testScreenModeInfo00() throws InterruptedException { - DimensionImmutable res = new Dimension(640, 480); - SurfaceSize surfsz = new SurfaceSize(res, 32); - DimensionImmutable mm = new Dimension(500, 400); - MonitorMode mon = new MonitorMode(surfsz, mm, 60); - ScreenMode sm_out = new ScreenMode(mon, 90); - System.err.println("00 out: "+sm_out); - - int[] props = ScreenModeUtil.streamOut(sm_out); - ScreenMode sm_in = ScreenModeUtil.streamIn(props, 0); - System.err.println("00 in : "+sm_in); - - Assert.assertEquals(sm_in.getMonitorMode().getSurfaceSize().getResolution(), - sm_out.getMonitorMode().getSurfaceSize().getResolution()); - - Assert.assertEquals(sm_in.getMonitorMode().getSurfaceSize(), - sm_out.getMonitorMode().getSurfaceSize()); - - Assert.assertEquals(sm_in.getMonitorMode().getScreenSizeMM(), - sm_out.getMonitorMode().getScreenSizeMM()); - - Assert.assertEquals(sm_in.getMonitorMode(), sm_out.getMonitorMode()); - - Assert.assertEquals(sm_in, sm_out); + final DimensionImmutable res = new Dimension(640, 480); + final SurfaceSize surfsz = new SurfaceSize(res, 32); + final MonitorMode modeOut = new MonitorMode(surfsz, 60.0f, 0, 0); + System.err.println("00 out: "+modeOut); + final MonitorModeProps.Cache cache = new MonitorModeProps.Cache(); + cache.monitorModes.add(modeOut); + { + final int[] props = MonitorModeProps.streamOutMonitorMode(modeOut); + final MonitorMode modeIn = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + System.err.println("00 in : "+modeIn); + + Assert.assertEquals(modeOut.getSurfaceSize().getResolution(), modeIn.getSurfaceSize().getResolution()); + + Assert.assertEquals(modeOut.getSurfaceSize(), modeIn.getSurfaceSize()); + + Assert.assertEquals(modeOut.hashCode(), modeIn.hashCode()); + + Assert.assertEquals(modeOut, modeIn); + } - Assert.assertEquals(sm_out.hashCode(), sm_in.hashCode()); + final DimensionImmutable sizeMM = new Dimension(50, 50); + final Rectangle viewport = new Rectangle(0, 0, 1920, 1080); + final ArrayHashSet supportedModes = new ArrayHashSet(); + supportedModes.add(modeOut); + final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, sizeMM, viewport, modeOut, supportedModes); + System.err.println("01 out : "+monOut); + cache.monitorDevices.add(monOut); + { + final int[] props = MonitorModeProps.streamOutMonitorDevice(monOut); + final MonitorDevice monIn = MonitorModeProps.streamInMonitorDevice(null, cache, null, props, 0); + System.err.println("01 in : "+monIn); + + Assert.assertEquals(monOut.getCurrentMode(), monOut.getOriginalMode()); + Assert.assertEquals(monOut.getSupportedModes(), monIn.getSupportedModes()); + Assert.assertEquals(monOut.getViewport(), monIn.getViewport()); + Assert.assertEquals(monOut.getOriginalMode(), monIn.getOriginalMode()); + Assert.assertEquals(monOut.getCurrentMode(), monIn.getCurrentMode()); + Assert.assertEquals(monOut.hashCode(), monIn.hashCode()); + Assert.assertEquals(monOut, monIn); + } } @Test @@ -101,21 +122,37 @@ public class TestScreenMode00NEWT extends UITestCase { Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,screen.getDisplay().isNativeValid()); System.err.println("Screen: "+screen.toString()); - - List screenModes = screen.getScreenModes(); - Assert.assertTrue(screenModes.size()>0); - int i=0; - for(Iterator iter=screenModes.iterator(); iter.hasNext(); i++) { - System.err.println(i+": "+iter.next()); + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + { + int i=0; + for(Iterator iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) { + System.err.println("All["+i+"]: "+iMode.next()); + } + } + + List monitors = screen.getMonitorDevices(); + Assert.assertTrue(monitors.size()>0); + int j=0; + for(Iterator iMonitor=monitors.iterator(); iMonitor.hasNext(); j++) { + MonitorDevice monitor = iMonitor.next(); + System.err.println(j+": "+monitor); + List modes = monitor.getSupportedModes(); + Assert.assertTrue(modes.size()>0); + int i=0; + for(Iterator iMode=modes.iterator(); iMode.hasNext(); i++) { + System.err.println("["+j+"]["+i+"]: "+iMode.next()); + } + Assert.assertTrue(allMonitorModes.containsAll(modes)); + + MonitorMode sm_o = monitor.getOriginalMode(); + Assert.assertNotNull(sm_o); + MonitorMode sm_c = monitor.queryCurrentMode(); + System.err.println("[0] orig : "+sm_o); + System.err.println("[0] current: "+sm_c); + Assert.assertNotNull(sm_c); + Assert.assertEquals(sm_o, sm_c); } - ScreenMode sm_o = screen.getOriginalScreenMode(); - Assert.assertNotNull(sm_o); - ScreenMode sm_c = screen.getCurrentScreenMode(); - Assert.assertNotNull(sm_c); - System.err.println("orig SM: "+sm_o); - System.err.println("curr SM: "+sm_c); - System.err.println("curr sz: "+screen.getWidth()+"x"+screen.getHeight()); - Assert.assertEquals(sm_o, sm_c); screen.removeReference(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java index 75a312686..f4eaec5fa 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java @@ -36,9 +36,10 @@ import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; -import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.MonitorMode; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -81,23 +82,24 @@ public class TestScreenMode00bNEWT extends UITestCase { Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,display.isNativeValid()); - List screenModes = screen.getScreenModes(); + List screenModes = screen.getMonitorModes(); Assert.assertTrue(screenModes.size()>0); int i=0; - for(Iterator iter=screenModes.iterator(); iter.hasNext(); i++) { + for(Iterator iter=screenModes.iterator(); iter.hasNext(); i++) { System.err.println(i+": "+iter.next()); } - ScreenMode sm_o = screen.getOriginalScreenMode(); + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mm_o = monitor.getOriginalMode(); - Assert.assertNotNull(sm_o); - ScreenMode sm_c = screen.getCurrentScreenMode(); - Assert.assertNotNull(sm_c); - System.err.println("orig: "+sm_o); - System.err.println("curr: "+sm_c); + Assert.assertNotNull(mm_o); + MonitorMode mm_c = monitor.queryCurrentMode(); + Assert.assertNotNull(mm_c); + System.err.println("orig: "+mm_o); + System.err.println("curr: "+mm_c); for(i=0; i<50; i++) { - sm_c = screen.getCurrentScreenMode(); - Assert.assertNotNull(sm_c); + mm_c = monitor.queryCurrentMode(); + Assert.assertNotNull(mm_c); System.err.print("."+i); } System.err.println("!"); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java index f253f3b58..78dd9fbc1 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java @@ -40,12 +40,13 @@ import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; -import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.MonitorMode; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.newt.util.MonitorModeUtil; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -149,14 +150,16 @@ public class TestScreenMode01NEWT extends UITestCase { Animator animator = new Animator(window); animator.start(); + final MonitorDevice monitor = window.getMainMonitor(); + Assert.assertEquals(false, window.isFullscreen()); Assert.assertEquals(width, window.getWidth()); Assert.assertEquals(height, window.getHeight()); window.setFullscreen(true); - Assert.assertEquals(true, window.isFullscreen()); - Assert.assertEquals(window.getScreen().getWidth(), window.getWidth()); - Assert.assertEquals(window.getScreen().getHeight(), window.getHeight()); + Assert.assertEquals(true, window.isFullscreen()); + Assert.assertEquals(monitor.getViewport().getWidth(), window.getWidth()); + Assert.assertEquals(monitor.getViewport().getHeight(), window.getHeight()); Thread.sleep(waitTimeShort); @@ -192,45 +195,53 @@ public class TestScreenMode01NEWT extends UITestCase { GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); Assert.assertNotNull(window); - List screenModes = screen.getScreenModes(); - if(screenModes.size()==1) { + MonitorDevice monitor = window.getMainMonitor(); + + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { // no support .. - System.err.println("Your platform has no ScreenMode change support, sorry"); + System.err.println("Your platform has no MonitorMode change support, sorry"); destroyWindow(window); return; } - Assert.assertTrue(screenModes.size()>0); Animator animator = new Animator(window); animator.start(); - ScreenMode smCurrent = screen.getCurrentScreenMode(); - Assert.assertNotNull(smCurrent); - ScreenMode smOrig = screen.getOriginalScreenMode(); - Assert.assertNotNull(smOrig); - Assert.assertEquals(smCurrent, smOrig); - System.err.println("[0] current/orig: "+smCurrent); - - screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate()); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByRotation(screenModes, 0); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601)); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); - screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); - ScreenMode sm = (ScreenMode) screenModes.get(0); + MonitorMode sm = (MonitorMode) monitorModes.get(0); System.err.println("[0] set current: "+sm); - screen.setCurrentScreenMode(sm); - Assert.assertEquals(sm, screen.getCurrentScreenMode()); - Assert.assertNotSame(smOrig, screen.getCurrentScreenMode()); - + monitor.setCurrentMode(sm); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + Thread.sleep(waitTimeLong); // check reset .. @@ -258,15 +269,14 @@ public class TestScreenMode01NEWT extends UITestCase { Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); - smCurrent = screen.getCurrentScreenMode(); - System.err.println("[1] current/orig: "+smCurrent); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); screen.destroy(); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); - Assert.assertNotNull(smCurrent); - Assert.assertEquals(smCurrent, smOrig); - + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); cleanupGL(); } @@ -291,27 +301,30 @@ public class TestScreenMode01NEWT extends UITestCase { Animator animator = new Animator(window); animator.start(); - ScreenMode smCurrent = screen.getCurrentScreenMode(); - Assert.assertNotNull(smCurrent); - ScreenMode smOrig = screen.getOriginalScreenMode(); - Assert.assertNotNull(smOrig); - Assert.assertEquals(smCurrent, smOrig); - System.err.println("[0] current/orig: "+smCurrent); + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); - List screenModes = screen.getScreenModes(); - if(screenModes.size()==1) { + List monitorModes = monitor.getSupportedModes(); + if(monitorModes.size()==1) { // no support .. destroyWindow(window); return; } - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate()); - screenModes = ScreenModeUtil.filterByRotation(screenModes, 0); - screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601)); - screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); - - ScreenMode screenMode = (ScreenMode) screenModes.get(0); - Assert.assertNotNull(screenMode); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + + MonitorMode monitorMode = (MonitorMode) monitorModes.get(0); + Assert.assertNotNull(monitorMode); if(preFS) { System.err.println("[0] set FS pre 0: "+window.isFullscreen()); @@ -321,8 +334,8 @@ public class TestScreenMode01NEWT extends UITestCase { System.err.println("[0] set FS pre X: "+window.isFullscreen()); } - System.err.println("[0] set current: "+screenMode); - screen.setCurrentScreenMode(screenMode); + System.err.println("[0] set current: "+monitorMode); + monitor.setCurrentMode(monitorMode); if(!preFS) { System.err.println("[0] set FS post 0: "+window.isFullscreen()); @@ -358,14 +371,14 @@ public class TestScreenMode01NEWT extends UITestCase { Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); - smCurrent = screen.getCurrentScreenMode(); - System.err.println("[1] current/orig: "+smCurrent); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); screen.destroy(); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); - Assert.assertNotNull(smCurrent); - Assert.assertEquals(smCurrent, smOrig); + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); cleanupGL(); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java new file mode 100644 index 000000000..35390636f --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java @@ -0,0 +1,212 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import java.util.List; +import javax.media.nativewindow.util.Dimension; + +/** + * Documents remedy B) for NV RANDR/GL bug + * + * @see TestScreenMode01NEWT#cleanupGL() + */ +public class TestScreenMode01aNEWT extends UITestCase { + static GLProfile glp; + static int width, height; + + static int waitTimeShort = 2000; + static int waitTimeLong = 2000; + + @BeforeClass + public static void initClass() { + width = 100; + height = 100; + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + static Window createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) { + Assert.assertNotNull(caps); + + GLWindow window = GLWindow.create(screen, caps); + // Window window = NewtFactory.createWindow(screen, caps); + window.setTitle(name); + window.setPosition(x, y); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + Assert.assertNotNull(window); + window.setVisible(true); + return window; + } + + static void destroyWindow(Window window) { + if(null!=window) { + window.destroy(); + } + } + + @Test + public void testScreenModeChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height); + Assert.assertNotNull(window0); + + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + if(allMonitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (all), sorry"); + destroyWindow(window0); + return; + } + + MonitorDevice monitor = window0.getMainMonitor(); + + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (monitor), sorry"); + destroyWindow(window0); + return; + } + Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); + + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+sm); + Assert.assertTrue(monitor.setCurrentMode(sm)); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + + Thread.sleep(waitTimeShort); + + // check manual reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window0.isNativeValid()); + Assert.assertEquals(true,window0.isVisible()); + + screen.addReference(); // keep it alive ! + Assert.assertTrue(monitor.setCurrentMode(mmOrig)); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + Assert.assertNotSame(sm, monitor.getCurrentMode()); + Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); + + destroyWindow(window0); + Assert.assertEquals(false,window0.isVisible()); + Assert.assertEquals(false,window0.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); // alive ! + Assert.assertEquals(true,display.isNativeValid()); + + Thread.sleep(waitTimeShort); + + Window window1 = createWindow(screen, caps, "win1", + width+window0.getInsets().getTotalWidth(), 0, + width, height); + Assert.assertNotNull(window1); + Assert.assertEquals(true,window1.isNativeValid()); + Assert.assertEquals(true,window1.isVisible()); + + Thread.sleep(waitTimeShort); + + destroyWindow(window1); + Assert.assertEquals(false,window1.isNativeValid()); + Assert.assertEquals(false,window1.isVisible()); + + screen.removeReference(); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode01aNEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java index 38612faa8..7e18f396a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java @@ -1,5 +1,5 @@ /** - * Copyright 2010 JogAmp Community. All rights reserved. + * Copyright 2013 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: @@ -29,7 +29,6 @@ package com.jogamp.opengl.test.junit.newt; import java.io.IOException; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -39,34 +38,36 @@ import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; -import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.MonitorMode; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.newt.util.MonitorModeUtil; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; import java.util.List; import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.RectangleImmutable; /** - * Documents remedy B) for NV RANDR/GL bug - * - * @see TestScreenMode01NEWT#cleanupGL() + * Mode change on separate monitors .. */ public class TestScreenMode01bNEWT extends UITestCase { static GLProfile glp; static int width, height; - static int waitTimeShort = 2000; - static int waitTimeLong = 2000; + static long waitTimeShort = 2000; + static long duration = 6000; @BeforeClass public static void initClass() { - width = 100; - height = 100; + width = 200; + height = 200; glp = GLProfile.getDefault(); } @@ -75,7 +76,7 @@ public class TestScreenMode01bNEWT extends UITestCase { Thread.sleep(waitTimeShort); } - static Window createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) { + static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) throws InterruptedException { Assert.assertNotNull(caps); GLWindow window = GLWindow.create(screen, caps); @@ -85,7 +86,9 @@ public class TestScreenMode01bNEWT extends UITestCase { window.setSize(width, height); window.addGLEventListener(new GearsES2()); Assert.assertNotNull(window); + final long t0 = System.currentTimeMillis(); window.setVisible(true); + System.err.println("Time for visible/pos: "+(System.currentTimeMillis()-t0)+" ms"); return window; } @@ -96,93 +99,150 @@ public class TestScreenMode01bNEWT extends UITestCase { } @Test - public void testScreenModeChange01() throws InterruptedException { + public void testScreenModeChangeSingleQ1() throws InterruptedException { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); // trigger creation + try { + RectangleImmutable monitorVp = screen.getMonitorDevices().get(0).getViewport(); + testScreenModeChangeImpl(screen, monitorVp.getX(), monitorVp.getY()); + } finally { + screen.removeReference(); + } + } + + @Test + public void testScreenModeChangeSingleQ2() throws InterruptedException { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); // trigger creation + try { + if( 2 > screen.getMonitorDevices().size() ) { + System.err.println("Test Disabled (1): Monitor count < 2: "+screen); + return; + } + RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport(); + testScreenModeChangeImpl(screen, monitorVp.getX(), monitorVp.getY()); + } finally { + screen.removeReference(); + } + } + + void testScreenModeChangeImpl(final Screen screen, int xpos, int ypos) throws InterruptedException { Thread.sleep(waitTimeShort); - GLCapabilities caps = new GLCapabilities(glp); + final GLCapabilities caps = new GLCapabilities(glp); Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height); + final Display display = screen.getDisplay(); + System.err.println("Test.0: Window screen: "+screen); + + System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport()); + + GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height); Assert.assertNotNull(window0); + System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); - List screenModes = screen.getScreenModes(); - if(screenModes.size()==1) { + final Animator anim = new Animator(window0); + anim.start(); + + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + if(allMonitorModes.size()==1) { // no support .. - System.err.println("Your platform has no ScreenMode change support, sorry"); + System.err.println("Your platform has no MonitorMode change support (all), sorry"); destroyWindow(window0); return; } - Assert.assertTrue(screenModes.size()>0); - - ScreenMode smCurrent = screen.getCurrentScreenMode(); - Assert.assertNotNull(smCurrent); - ScreenMode smOrig = screen.getOriginalScreenMode(); - Assert.assertNotNull(smOrig); - Assert.assertEquals(smCurrent, smOrig); - System.err.println("[0] current/orig: "+smCurrent); - - screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate()); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByRotation(screenModes, 0); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601)); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - - screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - ScreenMode sm = (ScreenMode) screenModes.get(0); - System.err.println("[0] set current: "+sm); - screen.setCurrentScreenMode(sm); - Assert.assertEquals(sm, screen.getCurrentScreenMode()); - Assert.assertNotSame(smOrig, screen.getCurrentScreenMode()); - - Thread.sleep(waitTimeShort); - - // check reset .. + MonitorDevice monitor = window0.getMainMonitor(); + System.err.println("Test.0: Window monitor: "+monitor); + + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (monitor), sorry"); + destroyWindow(window0); + return; + } + Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); + + MonitorMode mmCurrent = monitor.getCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); + System.err.println("[1] set current: "+sm); + Assert.assertTrue(monitor.setCurrentMode(sm)); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current: "+mmCurrent); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + + System.err.println("Test.1: Window screen: "+screen); + System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + System.err.println("Test.1: Window monitor: "+window0.getMainMonitor()); + + Thread.sleep(duration); Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window0.isNativeValid()); Assert.assertEquals(true,window0.isVisible()); - screen.addReference(); // keep it alive ! - screen.setCurrentScreenMode(smOrig); + Assert.assertTrue(monitor.setCurrentMode(mmOrig)); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + Assert.assertNotSame(sm, monitor.getCurrentMode()); + Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); + + System.err.println("Test.2: Window screen: "+screen); + System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + System.err.println("Test.2: Window monitor: "+window0.getMainMonitor()); + Thread.sleep(duration); + anim.stop(); destroyWindow(window0); Assert.assertEquals(false,window0.isVisible()); Assert.assertEquals(false,window0.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); // alive ! Assert.assertEquals(true,display.isNativeValid()); - - Thread.sleep(waitTimeShort); - - Window window1 = createWindow(screen, caps, "win1", - width+window0.getInsets().getTotalWidth(), 0, - width, height); - Assert.assertNotNull(window1); - Assert.assertEquals(true,window1.isNativeValid()); - Assert.assertEquals(true,window1.isVisible()); - - Thread.sleep(waitTimeShort); - - destroyWindow(window1); - Assert.assertEquals(false,window1.isNativeValid()); - Assert.assertEquals(false,window1.isVisible()); - - screen.removeReference(); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); } public static void main(String args[]) throws IOException { + for(int i=0; i screen.getMonitorDevices().size() ) { + System.err.println("Test Disabled (1): Monitor count < 2: "+screen); + return; + } + RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport(); + testScreenFullscreenImpl(screen, monitorVp.getX(), monitorVp.getY(), false, null); + } finally { + screen.removeReference(); + } + } + + @Test + public void testScreenFullscreenSpanQ1Q2() throws InterruptedException { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); // trigger creation + try { + final int crtCount = screen.getMonitorDevices().size(); + if( 2 >= crtCount ) { + System.err.println("Test Disabled (2): Spanning monitor count "+2+" >= screen monitor count: "+screen); + return; + } + final ArrayList monitors = new ArrayList(); + monitors.add(screen.getMonitorDevices().get(0)); // Q1 + monitors.add(screen.getMonitorDevices().get(1)); // Q2 + RectangleImmutable monitorVp = screen.getMonitorDevices().get(0).getViewport(); + testScreenFullscreenImpl(screen, monitorVp.getX()+50, monitorVp.getY()+50, true, monitors); + } finally { + screen.removeReference(); + } + } + + @Test + public void testScreenFullscreenSpanALL() throws InterruptedException { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); // trigger creation + try { + if( 2 > screen.getMonitorDevices().size() ) { + System.err.println("Test Disabled (3): Monitor count < 2: "+screen); + return; + } + RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport(); + testScreenFullscreenImpl(screen, monitorVp.getX()-50, monitorVp.getY()+50, true, null); + } finally { + screen.removeReference(); + } + } + + void testScreenFullscreenImpl(final Screen screen, int xpos, int ypos, boolean spanAcrossMonitors, List monitors) throws InterruptedException { + Thread.sleep(waitTimeShort); + + final GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + final Display display = screen.getDisplay(); + + System.err.println("Test.0: Window screen: "+screen); + + System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport()); + + GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height); + Assert.assertNotNull(window0); + System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + + final Animator anim = new Animator(window0); + anim.start(); + + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + + MonitorDevice monitor = window0.getMainMonitor(); + System.err.println("Test.0: Window monitor: "+monitor); + if( !spanAcrossMonitors ) { + window0.setFullscreen(true); + } else { + window0.setFullscreen(monitors); + } + + monitor = window0.getMainMonitor(); + System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + System.err.println("Test.1: Window monitor: "+monitor.getViewport()); + Rectangle window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getWidth(), window0.getHeight()); + if( !spanAcrossMonitors ) { + Assert.assertEquals(monitor.getViewport(), window0Rect); + } else { + List monitorsUsed = monitors; + if( null == monitorsUsed ) { + monitorsUsed = window0.getScreen().getMonitorDevices(); + } + Rectangle monitorsUsedViewport = MonitorDevice.unionOfViewports(new Rectangle(), monitorsUsed); + Assert.assertEquals(monitorsUsedViewport, window0Rect); + } + + Thread.sleep(duration); + + window0.setFullscreen(false); + + window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getWidth(), window0.getHeight()); + monitor = window0.getMainMonitor(); + System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + System.err.println("Test.2: Window monitor: "+monitor.getViewport()); + + Thread.sleep(duration); + anim.stop(); + destroyWindow(window0); + Assert.assertEquals(false,window0.isVisible()); + Assert.assertEquals(false,window0.isNativeValid()); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i screenModes = screen.getScreenModes(); - if(screenModes.size()==1) { + MonitorDevice monitor = window.getMainMonitor(); + List monitorModes = monitor.getSupportedModes(); + if(monitorModes.size()==1) { // no support .. System.err.println("Your platform has no ScreenMode change support, sorry"); destroyWindow(window); return; } - Assert.assertTrue(screenModes.size()>0); + Assert.assertTrue(monitorModes.size()>0); Animator animator = new Animator(window); animator.start(); - ScreenMode smCurrent = screen.getCurrentScreenMode(); - Assert.assertNotNull(smCurrent); - ScreenMode smOrig = screen.getOriginalScreenMode(); - Assert.assertNotNull(smOrig); - Assert.assertEquals(smCurrent, smOrig); - System.err.println("[0] current/orig: "+smCurrent); - - screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate()); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByRotation(screenModes, 90); - if(null==screenModes) { + MonitorMode mmCurrent = monitor.getCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); + if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { // no rotation support .. System.err.println("Your platform has no rotation support, sorry"); destroyWindow(window); return; } - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601)); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - - ScreenMode sm = (ScreenMode) screenModes.get(0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); System.err.println("[0] set current: "+sm); - screen.setCurrentScreenMode(sm); - Assert.assertEquals(sm, screen.getCurrentScreenMode()); - Assert.assertNotSame(smOrig, screen.getCurrentScreenMode()); + monitor.setCurrentMode(sm); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); Thread.sleep(waitTimeLong); @@ -167,11 +176,11 @@ public class TestScreenMode02NEWT extends UITestCase { Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); - smCurrent = screen.getCurrentScreenMode(); - System.err.println("[1] current/orig: "+smCurrent); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); - Assert.assertNotNull(smCurrent); - Assert.assertEquals(smCurrent, smOrig); + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); screen.destroy(); -- cgit v1.2.3 From 84576bc0b7c5bd9b7554ec02f01786228efdbe07 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 7 May 2013 00:35:08 +0200 Subject: MonitorMode: Fix API doc / comments / names. --- .../classes/com/jogamp/newt/MonitorDevice.java | 30 +++--- src/newt/classes/com/jogamp/newt/MonitorMode.java | 107 +++++++++++---------- src/newt/classes/com/jogamp/newt/Screen.java | 10 +- .../classes/jogamp/newt/MonitorDeviceImpl.java | 24 ++--- src/newt/classes/jogamp/newt/ScreenImpl.java | 32 +++--- .../classes/jogamp/newt/ScreenMonitorState.java | 6 +- src/newt/classes/jogamp/newt/WindowImpl.java | 16 +-- .../jogamp/newt/driver/android/WindowDriver.java | 2 +- .../jogamp/newt/driver/x11/ScreenDriver.java | 2 +- .../test/junit/newt/TestScreenMode01aNEWT.java | 12 +-- 10 files changed, 122 insertions(+), 119 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index fbe4d8cf0..4b0a760a4 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -117,22 +117,26 @@ public abstract class MonitorDevice { } /** - * Return the immutable original {@link com.jogamp.newt.MonitorMode}, as used at NEWT initialization. - * @return original {@link MonitorMode} which is element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + * Returns the immutable original {@link com.jogamp.newt.MonitorMode}, as used at NEWT initialization. + *

    + * The returned {@link MonitorMode} is element of the lists {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + *

    */ public final MonitorMode getOriginalMode() { return originalMode; } /** - * FIXME: May need to support mutable mode, i.e. adding modes on the fly! - * @return the immutable list of {@link MonitorMode}s supported by this monitor. Use w/ care, it's not a copy! + * Returns a list of immutable {@link MonitorMode}s supported by this monitor. + *

    + * Use w/ care, it's not a copy! + *

    */ public final List getSupportedModes() { return supportedModes.getData(); } - /** @return the {@link RectangleImmutable rectangular} portion of the rotated virtual {@link Screen} size represented by this monitor. */ + /** Returns the {@link RectangleImmutable rectangular} portion of the rotated virtual {@link Screen} size represented by this monitor. */ public final RectangleImmutable getViewport() { return viewport; } @@ -199,24 +203,20 @@ public abstract class MonitorDevice { } /** - * Return the current cached {@link MonitorMode} w/o native query. + * Returns the cached current {@link MonitorMode} w/o native query. *

    - * If {@link MonitorMode}s are not supported for this - * native type {@link com.jogamp.newt.Display#getType()}, it returns one with the current screen size.

    - * - * @return current {@link MonitorMode} which is element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + * The returned {@link MonitorMode} is element of the lists {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + *

    */ public final MonitorMode getCurrentMode() { return currentMode; } /** - * Return the current {@link MonitorMode} including a native query. + * Returns the current {@link MonitorMode} resulting from a native query. *

    - * If {@link MonitorMode}s are not supported for this - * native type {@link com.jogamp.newt.Display#getType()}, it returns one with the current screen size.

    - * - * @return current {@link MonitorMode} which is element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + * The returned {@link MonitorMode} is element of the lists {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + *

    */ public abstract MonitorMode queryCurrentMode(); diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java index e5b329d47..914aa880f 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorMode.java +++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java @@ -29,79 +29,84 @@ package com.jogamp.newt; import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.RectangleImmutable; import javax.media.nativewindow.util.SurfaceSize; +import com.jogamp.newt.util.MonitorModeUtil; -/** Immutable MonitorMode Class, consisting of it's read only components:
    + +/** + * Immutable MonitorMode Class, consisting of it's read only components:
    *
      *
    • nativeId
    • - *
    • {@link SizeAndRRate}, non rotated surfaceSize and refreshRate
    • + *
    • {@link SizeAndRRate}, consist out of non rotated {@link #getSurfaceSize() surface size}, {@link #getRefreshRate() refresh rate} and {@link #getFlags() flags}.
    • *
    • rotation, measured counter clockwise (CCW)
    • *
    * * Aquire and filter MonitorMode
    *
      - *
    • A List of read only MonitorModes is being returned by {@link com.jogamp.newt.Screen#getMonitorModes()}.
    • - *
    • You may utilize {@link com.jogamp.newt.util.MonitorModeUtil} to filter and select a desired ScreenMode.
    • - *
    • The current ScreenMode can be obtained via {@link com.jogamp.newt.Screen#getCurrentScreenMode()}.
    • - *
    • The initial original ScreenMode (at startup) can be obtained via {@link com.jogamp.newt.Screen#getOriginalScreenMode()}.
    • + *
    • {@link MonitorDevice} Selection: + *
        + *
      • A List of all {@link MonitorDevice}s is accessible via {@link Screen#getMonitorDevices()}.
      • + *
      • The main monitor used by a windows is accessible via {@link Window#getMainMonitor()}.
      • + *
      • The main monitor covering an arbitrary rectnagle is accessible via {@link Screen#getMainMonitor(RectangleImmutable)}.
      • + *
    • + *
    • The current MonitorMode can be obtained via {@link MonitorDevice#getCurrentMode()}.
    • + *
    • The original MonitorMode can be obtained via {@link MonitorDevice#getOriginalMode()}.
    • + *
    • {@link MonitorMode} Filtering: + *
        + *
      • A {@link MonitorDevice}'s MonitorModes is accessible via {@link MonitorDevice#getSupportedModes()}.
      • + *
      • You may utilize {@link MonitorModeUtil} to filter and select a desired MonitorMode.
      • + *
    • *
    *
    * - * Changing ScreenModes
    - * FIXME!!!!! + * Changing MonitorMode
    *
      - *
    • Use {@link com.jogamp.newt.Screen#setCurrentScreenMode(com.jogamp.newt.MonitorMode)}
    • - * to change the current ScreenMode of all Screen's referenced via the full qualified name (FQN) - * {@link com.jogamp.newt.Screen#getFQName()}. - *
    • When the last FQN referenced Screen closes, the original ScreenMode ({@link com.jogamp.newt.Screen#getOriginalScreenMode()}) - * is restored.
    • + *
    • Use {@link MonitorDevice#setCurrentMode(MonitorMode)} + * to change the current MonitorMode for all {@link Screen}s referenced via the {@link Screen#getFQName() full qualified name (FQN)}.
    • + *
    • The {@link MonitorDevice#getOriginalMode() original mode} is restored when + *
        + *
      • the last FQN referenced Screen closes.
      • + *
      • the JVM shuts down.
      • + *
    • *
    *
    - * Example for changing the ScreenMode: + * Example for changing the MonitorMode: *
    -        // determine target refresh rate
    -        ScreenMode orig = screen.getOriginalScreenMode();
    -        int freq = orig.getOutputMode().getRefreshRate();
    +        // Pick the monitor:
    +        // Either the one used by a window ..
    +        MonitorDevice monitor = window.getMainMonitor();
    +        
    +        // Or arbitrary from the list ..
    +        List allMonitor = getMonitorDevices();
    +        MonitorDevice monitor = allMonitor.get(0);
     
    -        // target resolution
    +        // Current and original modes ..
    +        MonitorMode mmCurrent = monitor.queryCurrentMode();
    +        MonitorMode mmOrig = monitor.getOriginalMode();
    +        
    +        // Target resolution
             Dimension res = new Dimension(800, 600);
     
    -        // target rotation
    -        int rot = 0;
    -
    -        // filter available ScreenModes
    -        List screenModes = screen.getScreenModes();
    -        screenModes = ScreenModeUtil.filterByRate(screenModes, freq); // get the nearest ones
    -        screenModes = ScreenModeUtil.filterByRotation(screenModes, rot);
    -        screenModes = ScreenModeUtil.filterByResolution(screenModes, res); // get the nearest ones
    -        screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
    -
    -        // pick 1st one ..
    -        screen.setCurrentScreenMode((ScreenMode) screenModes.get(0)); 
    - * 
    - * - * X11 / AMD just works
    - *
    - * X11 / NVidia difficulties - *
    -    NVidia RANDR RefreshRate Bug
    -        If NVidia's 'DynamicTwinView' is enabled, all refresh rates are
    -        unique, ie consequent numbers starting with the default refresh, ie 50, 51, ..
    -        The only way to workaround it is to disable 'DynamicTwinView'.
    -        Read: http://us.download.nvidia.com/XFree86/Linux-x86/260.19.12/README/configtwinview.html
    +        // Target refresh rate shall be similar to current one ..
    +        float freq = mmCurrent.getRefreshRate();
     
    -        Check to see if 'DynamicTwinView' is enable:
    -            nvidia-settings -q :0/DynamicTwinview
    +        // Target rotation shall be similar to current one
    +        int rot = mmCurrent.getRotation();
     
    -        To disable it (workaround), add the following option to your xorg.conf device section:
    -            Option "DynamicTwinView" "False"
    +        // Filter criterias sequential out of all available MonitorMode of the chosen MonitorDevice
    +        List monitorModes = monitor.getSupportedModes();
    +        monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc
    +        monitorModes = MonitorModeUtil.filterByRotation(monitorModes, rot);
    +        monitorModes = MonitorModeUtil.filterByResolution(monitorModes, res);
    +        monitorModes = MonitorModeUtil.filterByRate(monitorModes, freq);        
    +        monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes);
     
    -    NVidia RANDR Rotation:
    -        To enable it, add the following option to your xorg.conf device section:
    -            Option "RandRRotation" "on"
    +        // pick 1st one and set to current ..
    +        MonitorMode mm = monitorModes.get(0);
    +        monitor.setCurrentMode(mm);
      * 
    - * */ public class MonitorMode { /** @@ -113,8 +118,11 @@ public class MonitorMode { * */ public static class SizeAndRRate { + /** Non rotated surface size */ public final SurfaceSize surfaceSize; + /** Vertical refresh rate */ public final float refreshRate; + /** Mode bitfield flags, i.e. {@link #FLAG_DOUBLESCAN}, {@link #FLAG_INTERLACE}, .. */ public final int flags; public final int hashCode; @@ -262,6 +270,7 @@ public class MonitorMode { return sizeAndRRate.surfaceSize; } + /** Returns the vertical refresh rate. */ public final float getRefreshRate() { return sizeAndRRate.refreshRate; } diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index 81a62d898..f56aff964 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -163,18 +163,12 @@ public abstract class Screen { public abstract String getFQName(); /** - * Return a list of all available {@link MonitorMode}s for all {@link MonitorDevice}s. - *

    - * If {@link com.jogamp.newt.MonitorMode ScreenMode}s are not supported for this - * native type {@link com.jogamp.newt.Display#getType()}, it returns a list of size one with the current screen size.

    + * Return a list of all {@link MonitorMode}s for all {@link MonitorDevice}s. */ public abstract List getMonitorModes(); /** - * Return a list of all available {@link MonitorDevice}s. - *

    - * If {@link com.jogamp.newt.MonitorMode ScreenMode}s are not supported for this - * native type {@link com.jogamp.newt.Display#getType()}, it returns a list of size one with the current screen size.

    + * Return a list of available {@link MonitorDevice}s. */ public abstract List getMonitorDevices(); diff --git a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java index 96daed54a..db31cc83f 100644 --- a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java +++ b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java @@ -64,7 +64,7 @@ public class MonitorDeviceImpl extends MonitorDevice { // if mode has changed somehow, update it .. if( getCurrentMode().hashCode() != mmU.hashCode() ) { setCurrentModeValue(mmU); - sms.fireScreenModeChanged(this, mmU, true); + sms.fireMonitorModeChanged(this, mmU, true); } return mmU; } finally { @@ -75,7 +75,7 @@ public class MonitorDeviceImpl extends MonitorDevice { @Override public final boolean setCurrentMode(MonitorMode mode) { if(Screen.DEBUG) { - System.err.println("Screen.setCurrentScreenMode.0: "+this+" -> "+mode); + System.err.println("Screen.setCurrentMode.0: "+this+" -> "+mode); } final ScreenImpl screenImpl = (ScreenImpl)screen; final ScreenMonitorState sms = screenImpl.getScreenMonitorStatus(true); @@ -88,7 +88,7 @@ public class MonitorDeviceImpl extends MonitorDevice { } if( mmU.equals( mmC ) ) { if(Screen.DEBUG) { - System.err.println("Screen.setCurrentScreenMode: 0.0 is-current (skip) "+mmU+" == "+mmC); + System.err.println("Screen.setCurrentMode: 0.0 is-current (skip) "+mmU+" == "+mmC); } return true; } @@ -99,32 +99,32 @@ public class MonitorDeviceImpl extends MonitorDevice { tStart = 0; } - sms.fireScreenModeChangeNotify(this, mmU); + sms.fireMonitorModeChangeNotify(this, mmU); if(Screen.DEBUG) { - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): fireScreenModeChangeNotify() "+mmU); + System.err.println("Screen.setCurrentMode ("+(System.nanoTime()-tStart)/1e6+"ms): fireModeChangeNotify() "+mmU); } boolean success = screenImpl.setCurrentMonitorModeImpl(this, mmU); if(success) { if(Screen.DEBUG) { - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+mmU+", success(1): "+success); + System.err.println("Screen.setCurrentMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentModeImpl() "+mmU+", success(1): "+success); } } else { // 2nd attempt validate! - final MonitorMode queriedCurrent = queryCurrentMode(); // may fireScreenModeChanged(..) if successful and differs! + final MonitorMode queriedCurrent = queryCurrentMode(); // may fireModeChanged(..) if successful and differs! success = queriedCurrent.hashCode() == mmU.hashCode() ; if(Screen.DEBUG) { - System.err.println("Screen.setCurrentScreenMode.2: queried "+queriedCurrent); - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+mmU+", success(2): "+success); + System.err.println("Screen.setCurrentMode.2: queried "+queriedCurrent); + System.err.println("Screen.setCurrentMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentModeImpl() "+mmU+", success(2): "+success); } } if( success ) { setCurrentModeValue(mmU); modeChanged = !isOriginalMode(); } - sms.fireScreenModeChanged(this, mmU, success); + sms.fireMonitorModeChanged(this, mmU, success); if(Screen.DEBUG) { - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): X.X "+this+", success: "+success); + System.err.println("Screen.setCurrentMode ("+(System.nanoTime()-tStart)/1e6+"ms): X.X "+this+", success: "+success); } return success; } finally { @@ -144,4 +144,4 @@ public class MonitorDeviceImpl extends MonitorDevice { return supportedModes; } -} \ No newline at end of file +} diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 4d20fdb83..d7bd326fe 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -73,7 +73,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { protected Rectangle vOriginSize = new Rectangle(0, 0, 0, 0); // virtual rotated screen origin and size protected static Dimension usrSize = null; // property values: newt.ws.swidth and newt.ws.sheight protected static volatile boolean usrSizeQueried = false; - private ArrayList referencedScreenModeListener = new ArrayList(); + private ArrayList refMonitorModeListener = new ArrayList(); private long tCreated; // creationTime @@ -181,7 +181,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { throw new NativeWindowException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen"); } - initScreenMonitorState(); + initMonitorState(); if(DEBUG) { System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+"), total "+ (System.nanoTime()-tCreated)/1e6 +"ms"); } @@ -195,7 +195,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { @Override public synchronized final void destroy() { - releaseScreenModeStatus(); + releaseMonitorState(); synchronized(screenList) { screenList.remove(this); @@ -261,7 +261,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { /** * Stores the virtual origin and virtual rotated screen size. *

    - * This method is called after the ScreenMode has been set or changed, + * This method is called after the MonitorMode has been set or changed, * hence you may utilize it. *

    *

    @@ -393,7 +393,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { final String key = this.getFQName(); final ScreenMonitorState res = ScreenMonitorState.getScreenMonitorState(key); if(null == res & throwException) { - throw new InternalError("ScreenMonitorStatus.getScreenModeStatus("+key+") == null"); + throw new InternalError("ScreenMonitorStatus.getMonitorModeStatus("+key+") == null"); } return res; } @@ -403,8 +403,8 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if(DEBUG) { System.err.println("monitorModeChangeNotify: "+me); } - for(int i=0; i + * Invoked for expensive modifications, ie while reparenting and MonitorMode change.
    * No lock is hold when invoked.
    * * @return true is paused, otherwise false. If true {@link #resumeRenderingAction()} shall be issued. @@ -264,7 +264,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer boolean pauseRenderingAction(); /** - * Invoked for expensive modifications, ie while reparenting and ScreenMode change. + * Invoked for expensive modifications, ie while reparenting and MonitorMode change. * No lock is hold when invoked.
    * * @see #pauseRenderingAction() @@ -311,7 +311,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } final long t0 = System.currentTimeMillis(); createNativeImpl(); - screen.addMonitorModeListener(screenModeListenerImpl); + screen.addMonitorModeListener(monitorModeListenerImpl); setTitleImpl(title); setPointerVisibleImpl(pointerVisible); confinePointerImpl(pointerConfined); @@ -937,7 +937,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if( isNativeValid() ) { - screen.removeMonitorModeListener(screenModeListenerImpl); + screen.removeMonitorModeListener(monitorModeListenerImpl); closeNativeImpl(); final AbstractGraphicsDevice cfgADevice = config.getScreen().getDevice(); if( cfgADevice != screen.getDisplay().getGraphicsDevice() ) { // don't pull display's device @@ -1962,12 +1962,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - private class ScreenModeListenerImpl implements MonitorModeListener { + private class MonitorModeListenerImpl implements MonitorModeListener { boolean animatorPaused = false; public void monitorModeChangeNotify(MonitorEvent me) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.screenModeChangeNotify: "+me); + System.err.println("Window.monitorModeChangeNotify: "+me); } if(null!=lifecycleHook) { @@ -1977,7 +1977,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public void monitorModeChanged(MonitorEvent me, boolean success) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.screenModeChanged: "+me+", success: "+success); + System.err.println("Window.monitorModeChanged: "+me+", success: "+success); } if(success) { @@ -2007,7 +2007,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener } } - private final ScreenModeListenerImpl screenModeListenerImpl = new ScreenModeListenerImpl(); + private final MonitorModeListenerImpl monitorModeListenerImpl = new MonitorModeListenerImpl(); diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index 803c7e1de..653cbf945 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -562,7 +562,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { surface=null; } if(getScreen().isNativeValid()) { - // if ScreenMode changed .. trigger ScreenMode event + // if MonitorMode changed .. trigger MonitorMode event final MonitorDevice mainMonitor = getMainMonitor(); mainMonitor.queryCurrentMode(); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index ba22a6ce4..f2836f190 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -188,7 +188,7 @@ public class ScreenDriver extends ScreenImpl { }).booleanValue(); if(DEBUG || !done) { - System.err.println("X11Screen.setCurrentScreenModeImpl: TO ("+SCREEN_MODE_CHANGE_TIMEOUT+") reached: "+ + System.err.println("X11Screen.setCurrentMonitorModeImpl: TO ("+SCREEN_MODE_CHANGE_TIMEOUT+") reached: "+ (System.currentTimeMillis()-t0)+"ms; "+monitor.getCurrentMode()+" -> "+mode); } return done; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java index 96ada3c96..c638058f4 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java @@ -155,13 +155,13 @@ public class TestScreenMode01aNEWT extends UITestCase { Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); - MonitorMode sm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+sm); - Assert.assertTrue(monitor.setCurrentMode(sm)); + MonitorMode mm = monitorModes.get(0); + System.err.println("[0] set current: "+mm); + Assert.assertTrue(monitor.setCurrentMode(mm)); Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertEquals(mm, monitor.getCurrentMode()); Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(sm, monitor.queryCurrentMode()); + Assert.assertEquals(mm, monitor.queryCurrentMode()); Thread.sleep(waitTimeShort); @@ -176,7 +176,7 @@ public class TestScreenMode01aNEWT extends UITestCase { Assert.assertTrue(monitor.setCurrentMode(mmOrig)); Assert.assertFalse(monitor.isModeChangedByUs()); Assert.assertEquals(mmOrig, monitor.getCurrentMode()); - Assert.assertNotSame(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mm, monitor.getCurrentMode()); Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); destroyWindow(window0); -- cgit v1.2.3 From 061ce19983556a751471459a964d886e4d7e3908 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 7 May 2013 01:03:17 +0200 Subject: NEWT Multiple Monitor Mode: Add missing 'collect' impl. for NEWT/AWT impl. --- make/scripts/tests.sh | 4 +- .../jogamp/newt/driver/awt/ScreenDriver.java | 47 ++++++++++++++++++++-- 2 files changed, 45 insertions(+), 6 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a850ed6be..2152aabac 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -294,7 +294,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* +testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* @@ -386,7 +386,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT -testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT $* diff --git a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java index 8e584fc58..126143e1e 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java @@ -34,11 +34,11 @@ package jogamp.newt.driver.awt; import java.awt.DisplayMode; +import java.awt.GraphicsDevice; import jogamp.newt.MonitorModeProps.Cache; +import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; @@ -71,9 +71,48 @@ public class ScreenDriver extends ScreenImpl { return idx; // pass through ... } + private static MonitorMode getModeProps(Cache cache, DisplayMode mode) { + int rate = mode.getRefreshRate(); + if( DisplayMode.REFRESH_RATE_UNKNOWN == rate ) { + rate = ScreenImpl.default_sm_rate; + } + int bpp = mode.getBitDepth(); + if( DisplayMode.BIT_DEPTH_MULTI == bpp ) { + bpp= ScreenImpl.default_sm_bpp; + } + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; + props[i++] = mode.getWidth(); + props[i++] = mode.getHeight(); + props[i++] = bpp; + props[i++] = rate * 100; + props[i++] = 0; // flags + props[i++] = 0; // mode_idx + props[i++] = 0; // rotation + return MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + } + @Override - protected void collectNativeMonitorModesAndDevicesImpl(Cache cache) { - final DisplayMode mode = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice().getDisplayMode(); + protected void collectNativeMonitorModesAndDevicesImpl(Cache cache) { + final GraphicsDevice awtGD = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice(); + final DisplayMode[] awtModes = awtGD.getDisplayModes(); + for(int i=0; i Date: Tue, 7 May 2013 12:51:18 +0200 Subject: NEWT Multiple Monitor Mode: Fix monitorModeChanged(..) event id, WindowImpl.monitorModeChanged(): Resize/position if not fitting into virtual screen viewport. --- make/scripts/tests.sh | 4 ++-- src/newt/classes/jogamp/newt/ScreenMonitorState.java | 2 +- src/newt/classes/jogamp/newt/WindowImpl.java | 15 +++++++++------ src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java | 3 +-- 4 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2152aabac..8221f1da8 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -294,7 +294,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* -testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* @@ -385,7 +385,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT +testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT $* diff --git a/src/newt/classes/jogamp/newt/ScreenMonitorState.java b/src/newt/classes/jogamp/newt/ScreenMonitorState.java index 7cda18521..66e75be16 100644 --- a/src/newt/classes/jogamp/newt/ScreenMonitorState.java +++ b/src/newt/classes/jogamp/newt/ScreenMonitorState.java @@ -176,7 +176,7 @@ public class ScreenMonitorState { lock(); try { validateMonitor(monitor); - final MonitorEvent me = new MonitorEvent(MonitorEvent.EVENT_MONITOR_MODE_CHANGE_NOTIFY, monitor, System.currentTimeMillis(), currentMode); + final MonitorEvent me = new MonitorEvent(MonitorEvent.EVENT_MONITOR_MODE_CHANGED, monitor, System.currentTimeMillis(), currentMode); for(int i=0; i 0 && viewport.getHeight() > 0 ) { // failsafe final RectangleImmutable rect = new Rectangle(getX(), getY(), getWidth(), getHeight()); - final RectangleImmutable viewport = mainMonitor.getViewport(); final RectangleImmutable isect = viewport.intersection(rect); if ( getHeight() > isect.getHeight() || getWidth() > isect.getWidth() ) { - setSize(isect.getWidth(), isect.getHeight()); + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.monitorModeChanged: fit window "+rect+" into screen viewport "+viewport+ + ", due to minimal intersection "+isect); + } + setPosition(viewport.getX(), viewport.getY()); + setSize(viewport.getWidth(), viewport.getHeight()); } } } diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 666d0cb5b..fcc5b2148 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -135,8 +135,7 @@ public class WindowDriver extends WindowImpl { protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { if(DEBUG_IMPLEMENTATION) { - System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ - getReconfigureFlagsAsString(null, flags)); + System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); } final int _x, _y; if(0 == ( FLAG_IS_UNDECORATED & flags)) { -- cgit v1.2.3 From 2344a21587b3053fc2f343087319ee094fe45442 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 7 May 2013 13:34:25 +0200 Subject: NEWT MonitorMode: Refine 081177f2433be50e3b5d46385c2f0f3f96311ed8: Reduce EDT roundtrip when resize/positioning on MonitorMode changed .. --- src/newt/classes/jogamp/newt/WindowImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 9ed4f9ad7..16d252ca3 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1997,7 +1997,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("Window.monitorModeChanged: fit window "+rect+" into screen viewport "+viewport+ ", due to minimal intersection "+isect); } - setPosition(viewport.getX(), viewport.getY()); + definePosition(viewport.getX(), viewport.getY()); // set pos for setVisible(..) or createNative(..) - reduce EDT roundtrip setSize(viewport.getWidth(), viewport.getHeight()); } } -- cgit v1.2.3 From 5e0a5049d873b5896553ee530562c28ffd3fbe0c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 9 May 2013 02:57:09 +0200 Subject: Fix NEWT MultiMonitor Regression: Use case w/o attached monitor, and NPE (Cache) in ScreenImpl.getVirtualMonitorDevice(..). W/ RandR13, we can have a case of an Output/CRT w/o valid modes, indicating a switched off or detached monitor. ScreenImpl.getVirtualMonitorDevice(..) requires a Cache .. due to MonitorModeProps.streamInMonitorDevice(..) --- make/scripts/tests.sh | 6 ++--- src/newt/classes/jogamp/newt/ScreenImpl.java | 29 ++++++++++++++++------ .../jogamp/newt/driver/x11/ScreenDriver.java | 4 ++- 3 files changed, 27 insertions(+), 12 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index da4698a8e..73fa54f38 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -135,7 +135,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" - #D_ARGS="-Dnewt.debug.Screen" + D_ARGS="-Dnewt.debug.Screen" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -284,7 +284,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* @@ -516,7 +516,7 @@ function testawtswt() { # # Texture / TextureUtils # -testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage00NEWT $* diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index d7bd326fe..7edf7b63a 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -446,7 +446,13 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { refMonitorModeListener.remove(sml); } - private final MonitorMode getVirtualMonitorMode(int modeId) { + /** + * + * @param cache optional .. + * @param modeId + * @return + */ + private final MonitorMode getVirtualMonitorMode(MonitorModeProps.Cache cache, int modeId) { final int[] props = new int[MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; @@ -460,10 +466,17 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL != i ) { throw new InternalError("XX"); } - return MonitorModeProps.streamInMonitorMode(null, null, props, 0); + return MonitorModeProps.streamInMonitorMode(null, cache, props, 0); } - - private final MonitorDevice getVirtualMonitorDevice(int monitorId, MonitorMode currentMode) { + + /** + * + * @param cache mandatory ! + * @param monitorId + * @param currentMode + * @return + */ + private final MonitorDevice getVirtualMonitorDevice(MonitorModeProps.Cache cache, int monitorId, MonitorMode currentMode) { int[] props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES]; int i = 0; props[i++] = MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES; @@ -480,7 +493,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES != i ) { throw new InternalError("XX"); } - return MonitorModeProps.streamInMonitorDevice(null, null, this, props, 0); + return MonitorModeProps.streamInMonitorDevice(null, cache, this, props, 0); } /** @@ -498,7 +511,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( 0>=getWidth() || 0>=getHeight() ) { updateVirtualScreenOriginAndSize(); } - res = getVirtualMonitorMode(monitor.getCurrentMode().getId()); + res = getVirtualMonitorMode(null, monitor.getCurrentMode().getId()); } return res; } @@ -522,9 +535,9 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( 0 >= collectNativeMonitorModes(cache) ) { updateVirtualScreenOriginAndSize(); vScrnSizeUpdated = true; - final MonitorMode mode = getVirtualMonitorMode(0); + final MonitorMode mode = getVirtualMonitorMode(cache, 0); cache.monitorModes.getOrAdd(mode); - final MonitorDevice monitor = getVirtualMonitorDevice(0, mode); + final MonitorDevice monitor = getVirtualMonitorDevice(cache, 0, mode); cache.monitorDevices.getOrAdd(monitor); } if(DEBUG) { diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index f2836f190..b8b13939b 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -139,7 +139,9 @@ public class ScreenDriver extends ScreenImpl { if( cache.monitorModes.size() > 0 ) { for(int i = 0; i < crtCount; i++) { final int[] monitorProps = rAndR.getMonitorDeviceProps(device.getHandle(), this, cache, i); - if( null != monitorProps ) { // enabled + if( null != monitorProps && + MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps[0] && // Enabled ? I.e. contains active modes ? + MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps.length ) { MonitorModeProps.streamInMonitorDevice(null, cache, this, monitorProps, 0); } } -- cgit v1.2.3 From 86a5460c5052cdab7b9f6294c46a0b4e30dfa260 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 16 May 2013 21:33:25 +0200 Subject: Fix Bug 723: Remove VK_KP_ numpad key-codes, use general VK_ key-codes; Respect numpad printable keys; Use keySym for numpad if possible. - KeyEvent keyCode/keySym values re-ordered! - Remove VK_KP_ numpad key-codes, use general VK_ key-codes. Numpad cursor keys are not supported on some platforms (Windows), or not configured on most X11 configurations. - Respect numpad printable keys, i.e. don't treat them as non-printable. - Use keySym for numpad if possible. Numpad keys require modifiers, hence X11 and Windows shall return keySym. --- make/scripts/tests-x64.bat | 4 +- make/scripts/tests.sh | 6 +-- .../classes/com/jogamp/newt/event/KeyEvent.java | 61 +++++++++------------- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 12 ++--- .../jogamp/newt/swt/event/SWTNewtEventFactory.java | 4 -- src/newt/native/KeyEvent.h | 20 +++---- src/newt/native/WindowsWindow.c | 42 +++++++++------ src/newt/native/X11Display.c | 24 +++++++-- 8 files changed, 88 insertions(+), 85 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 27ecfb2cc..401e7905b 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -55,7 +55,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsReali REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -109,7 +109,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.nativewindow.TestRec REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8fb6c20c6..4ced71d3d 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -174,7 +174,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -282,9 +282,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 45bccf964..6e63ad3a3 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -327,7 +327,6 @@ public class KeyEvent extends InputEvent ( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { return false; } - } else { if( ( nonPrintableKeys[0].inclKeyChar && nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || ( nonPrintableKeys[1].inclKeyChar && nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || @@ -391,12 +390,14 @@ public class KeyEvent extends InputEvent this.max = max; this.inclKeyChar = inclKeyChar; } - }; - /** Non printable key ranges, currently fixed to an aray of size 4. */ - public final static NonPrintableRange[] nonPrintableKeys = { new NonPrintableRange( (short)0x0000, (short)0x001F, true ), - new NonPrintableRange( (short)0x0061, (short)0x0078, false), - new NonPrintableRange( (short)0x007F, (short)0x009F, true ), - new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) }; + }; + /** Non printable key ranges, currently fixed to an array of size 4. */ + public final static NonPrintableRange[] nonPrintableKeys = { + new NonPrintableRange( (short)0x0000, (short)0x001F, true ), // Unicode: Non printable controls: [0x00 - 0x1F] + new NonPrintableRange( (short)0x0061, (short)0x0078, false), // Small 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym - Re-used for Fn (collision) + new NonPrintableRange( (short)0x008F, (short)0x009F, true ), // Unicode: Non printable controls: [0x7F - 0x9F], Numpad keys [0x7F - 0x8E] are printable! + new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) + }; // // Unicode: Non printable controls: [0x00 - 0x1F] @@ -657,7 +658,7 @@ public class KeyEvent extends InputEvent /** Constant for the "`" key */ public static final short VK_BACK_QUOTE = (short) 0x60; - /** Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym. */ + /** Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym. */ /** * Constant for the Fn function keys. @@ -754,9 +755,11 @@ public class KeyEvent extends InputEvent // // Unicode: Non printable controls: [0x7F - 0x9F] // + // Numpad keys [0x7F - 0x8E] are printable + // - /** Constant for the DEL key, matching ASCII. Non printable UTF control. */ - public static final short VK_DELETE = (short) 0x7F; + /** Numeric keypad decimal separator key. Non printable UTF control. */ + public static final short VK_SEPARATOR = (short) 0x7F; /** Numeric keypad VK_NUMPAD0 thru VK_NUMPAD9 are mapped to UTF control (0x80 - 0x89). Non printable UTF control. */ public static final short VK_NUMPAD0 = (short) 0x80; @@ -782,49 +785,37 @@ public class KeyEvent extends InputEvent /** Numeric keypad decimal separator key. Non printable UTF control. */ public static final short VK_DECIMAL = (short) 0x8A; - /** Numeric keypad decimal separator key. Non printable UTF control. */ - public static final short VK_SEPARATOR = (short) 0x8B; - /** Numeric keypad add key. Non printable UTF control. */ - public static final short VK_ADD = (short) 0x8C; + public static final short VK_ADD = (short) 0x8B; /** Numeric keypad subtract key. Non printable UTF control. */ - public static final short VK_SUBTRACT = (short) 0x8D; + public static final short VK_SUBTRACT = (short) 0x8C; /** Numeric keypad multiply key. Non printable UTF control. */ - public static final short VK_MULTIPLY = (short) 0x8E; + public static final short VK_MULTIPLY = (short) 0x8D; /** Numeric keypad divide key. Non printable UTF control. */ - public static final short VK_DIVIDE = (short) 0x8F; + public static final short VK_DIVIDE = (short) 0x8E; - /** Numeric keypad num lock key. Non printable UTF control. */ - public static final short VK_NUM_LOCK = (short) 0x90; + /** Constant for the DEL key, matching ASCII. Non printable UTF control. */ + public static final short VK_DELETE = (short) 0x93; - /** Numeric keypad left arrow key, for cursor pad see {@link #VK_LEFT}. Non printable UTF control. */ - public static final short VK_KP_LEFT = (short) 0x91; - - /** Numeric keypad up arrow key, for cursor pad see {@link #VK_UP}. Non printable UTF control. */ - public static final short VK_KP_UP = (short) 0x92; - - /** Constant for the numeric keypad right arrow key, for cursor pad see {@link #VK_RIGHT}. Non printable UTF control. */ - public static final short VK_KP_RIGHT = (short) 0x93; + /** Numeric keypad num lock key. Non printable UTF control. */ + public static final short VK_NUM_LOCK = (short) 0x94; - /** Numeric keypad down arrow key, for cursor pad see {@link #VK_DOWN}. Non printable UTF control. */ - public static final short VK_KP_DOWN = (short) 0x94; - - /** Constant for the cursor-pad left arrow key, for numerical pad see {@link #VK_KP_LEFT}*/ + /** Constant for the cursor- or numerical-pad left arrow key. Non printable UTF control. */ public static final short VK_LEFT = (short) 0x95; - /** Constant for the cursor-pad left arrow key, for numerical pad see {@link #VK_KP_UP}.*/ + /** Constant for the cursor- or numerical-pad up arrow key. Non printable UTF control. */ public static final short VK_UP = (short) 0x96; - /** Constant for the cursor-pad left arrow key, for numerical pad see {@link #VK_KP_RIGHT}.*/ + /** Constant for the cursor- or numerical-pad right arrow key. Non printable UTF control. */ public static final short VK_RIGHT = (short) 0x97; - /** Constant for the cursor-pad left arrow key, for numerical pad see {@link #VK_KP_DOWN}.*/ + /** Constant for the cursor- or numerical pad down arrow key. Non printable UTF control. */ public static final short VK_DOWN = (short) 0x98; - /** Constant for the Context Menu key. */ + /** Constant for the Context Menu key. Non printable UTF control. */ public static final short VK_CONTEXT_MENU = (short) 0x99; /** diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index ccbdc07bf..a1aa69e0a 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -369,13 +369,13 @@ public class AWTNewtEventFactory { case java.awt.event.KeyEvent.VK_MULTIPLY : return com.jogamp.newt.event.KeyEvent.VK_MULTIPLY; case java.awt.event.KeyEvent.VK_DIVIDE : return com.jogamp.newt.event.KeyEvent.VK_DIVIDE; case java.awt.event.KeyEvent.VK_NUM_LOCK : return com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK; - case java.awt.event.KeyEvent.VK_KP_LEFT : return com.jogamp.newt.event.KeyEvent.VK_KP_LEFT; - case java.awt.event.KeyEvent.VK_KP_UP : return com.jogamp.newt.event.KeyEvent.VK_KP_UP; - case java.awt.event.KeyEvent.VK_KP_RIGHT : return com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT; - case java.awt.event.KeyEvent.VK_KP_DOWN : return com.jogamp.newt.event.KeyEvent.VK_KP_DOWN; + case java.awt.event.KeyEvent.VK_KP_LEFT : /** Fall through intended .. */ case java.awt.event.KeyEvent.VK_LEFT : return com.jogamp.newt.event.KeyEvent.VK_LEFT; + case java.awt.event.KeyEvent.VK_KP_UP : /** Fall through intended .. */ case java.awt.event.KeyEvent.VK_UP : return com.jogamp.newt.event.KeyEvent.VK_UP; + case java.awt.event.KeyEvent.VK_KP_RIGHT : /** Fall through intended .. */ case java.awt.event.KeyEvent.VK_RIGHT : return com.jogamp.newt.event.KeyEvent.VK_RIGHT; + case java.awt.event.KeyEvent.VK_KP_DOWN : /** Fall through intended .. */ case java.awt.event.KeyEvent.VK_DOWN : return com.jogamp.newt.event.KeyEvent.VK_DOWN; case java.awt.event.KeyEvent.VK_CONTEXT_MENU : return com.jogamp.newt.event.KeyEvent.VK_CONTEXT_MENU; case java.awt.event.KeyEvent.VK_WINDOWS : return com.jogamp.newt.event.KeyEvent.VK_WINDOWS; @@ -550,10 +550,6 @@ public class AWTNewtEventFactory { case com.jogamp.newt.event.KeyEvent.VK_MULTIPLY : return java.awt.event.KeyEvent.VK_MULTIPLY; case com.jogamp.newt.event.KeyEvent.VK_DIVIDE : return java.awt.event.KeyEvent.VK_DIVIDE; case com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK : return java.awt.event.KeyEvent.VK_NUM_LOCK; - case com.jogamp.newt.event.KeyEvent.VK_KP_LEFT : return java.awt.event.KeyEvent.VK_KP_LEFT; - case com.jogamp.newt.event.KeyEvent.VK_KP_UP : return java.awt.event.KeyEvent.VK_KP_UP; - case com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT : return java.awt.event.KeyEvent.VK_KP_RIGHT; - case com.jogamp.newt.event.KeyEvent.VK_KP_DOWN : return java.awt.event.KeyEvent.VK_KP_DOWN; case com.jogamp.newt.event.KeyEvent.VK_LEFT : return java.awt.event.KeyEvent.VK_LEFT; case com.jogamp.newt.event.KeyEvent.VK_UP : return java.awt.event.KeyEvent.VK_UP; case com.jogamp.newt.event.KeyEvent.VK_RIGHT : return java.awt.event.KeyEvent.VK_RIGHT; diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java index 5e240636d..24a5c41de 100644 --- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -189,13 +189,9 @@ public class SWTNewtEventFactory { case com.jogamp.newt.event.KeyEvent.VK_MULTIPLY : return SWT.KEYPAD_MULTIPLY; case com.jogamp.newt.event.KeyEvent.VK_DIVIDE : return SWT.KEYPAD_DIVIDE; case com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK : return SWT.NUM_LOCK; - case com.jogamp.newt.event.KeyEvent.VK_KP_LEFT : case com.jogamp.newt.event.KeyEvent.VK_LEFT : return SWT.ARROW_LEFT; - case com.jogamp.newt.event.KeyEvent.VK_KP_UP : case com.jogamp.newt.event.KeyEvent.VK_UP : return SWT.ARROW_UP; - case com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT : case com.jogamp.newt.event.KeyEvent.VK_RIGHT : return SWT.ARROW_RIGHT; - case com.jogamp.newt.event.KeyEvent.VK_KP_DOWN : case com.jogamp.newt.event.KeyEvent.VK_DOWN : return SWT.ARROW_DOWN; case com.jogamp.newt.event.KeyEvent.VK_HELP : return SWT.HELP; } diff --git a/src/newt/native/KeyEvent.h b/src/newt/native/KeyEvent.h index 7a63b19ce..a182db973 100644 --- a/src/newt/native/KeyEvent.h +++ b/src/newt/native/KeyEvent.h @@ -161,7 +161,7 @@ // Unicode: Non printable controls: [0x7F - 0x9F] // -#define J_VK_DELETE ( 0x7FU ) +#define J_VK_SEPARATOR ( 0x7FU ) #define J_VK_NUMPAD0 ( 0x80U ) #define J_VK_NUMPAD1 ( 0x81U ) #define J_VK_NUMPAD2 ( 0x82U ) @@ -173,16 +173,13 @@ #define J_VK_NUMPAD8 ( 0x88U ) #define J_VK_NUMPAD9 ( 0x89U ) #define J_VK_DECIMAL ( 0x8AU ) -#define J_VK_SEPARATOR ( 0x8BU ) -#define J_VK_ADD ( 0x8CU ) -#define J_VK_SUBTRACT ( 0x8DU ) -#define J_VK_MULTIPLY ( 0x8EU ) -#define J_VK_DIVIDE ( 0x8FU ) -#define J_VK_NUM_LOCK ( 0x90U ) -#define J_VK_KP_LEFT ( 0x91U ) -#define J_VK_KP_UP ( 0x92U ) -#define J_VK_KP_RIGHT ( 0x93U ) -#define J_VK_KP_DOWN ( 0x94U ) +#define J_VK_ADD ( 0x8BU ) +#define J_VK_SUBTRACT ( 0x8CU ) +#define J_VK_MULTIPLY ( 0x8DU ) +#define J_VK_DIVIDE ( 0x8EU ) + +#define J_VK_DELETE ( 0x93U ) +#define J_VK_NUM_LOCK ( 0x94U ) #define J_VK_LEFT ( 0x95U ) #define J_VK_UP ( 0x96U ) #define J_VK_RIGHT ( 0x97U ) @@ -195,7 +192,6 @@ #define J_VK_BEGIN ( 0x9EU ) #define J_VK_STOP ( 0x9FU ) - // // Unicode: Printable [0x00A0 - 0xDFFF] // diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 7ede3a20d..ac0ebf07e 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -219,6 +219,7 @@ static KeyMapEntry keyMapTable[] = { {J_VK_INSERT, VK_INSERT, 0}, {J_VK_DELETE, VK_DELETE, 0}, {J_VK_HOME, VK_HOME, 0}, + // {J_VK_BEGIN, VK_BEGIN, 0}, // not mapped {J_VK_END, VK_END, 0}, {J_VK_PAGE_UP, VK_PRIOR, 0}, {J_VK_PAGE_DOWN, VK_NEXT, 0}, @@ -332,6 +333,8 @@ static KeyMapEntry keyMapTable[] = { #define MAPVK_VK_TO_VSC_EX 4 #endif +#define IS_WITHIN(k,a,b) ((a)<=(k)&&(k)<=(b)) + static HKL kbdLayoutUS = 0; static const LPCSTR US_LAYOUT_NAME = "00000409"; @@ -398,23 +401,6 @@ static void ParseWmVKeyAndScanCode(USHORT winVKey, BYTE winScanCode, BYTE flags, kbdState[VK_SPACE] &= ~0x80; } - // Assume extended scan code 0xE0 if extended flags is set (no 0xE1 from WM_KEYUP/WM_KEYDOWN) - USHORT winScanCodeExt = winScanCode; - if( 0 != ( 0x01 & flags ) ) { - winScanCodeExt |= 0xE000; - } - - // - // winVKey, winScanCodeExt -> javaVKeyUS w/ US KeyboardLayout - // - for (i = 0; keyMapTable[i].windowsKey != 0; i++) { - if ( keyMapTable[i].windowsScanCodeUS == winScanCodeExt ) { - javaVKeyUS = keyMapTable[i].javaKey; - winVKeyUS = keyMapTable[i].windowsKey; - break; - } - } - // // winVKey -> javaVKeyXX // @@ -424,6 +410,28 @@ static void ParseWmVKeyAndScanCode(USHORT winVKey, BYTE winScanCode, BYTE flags, break; } } + if( IS_WITHIN( winVKey, VK_NUMPAD0, VK_DIVIDE ) ) { + // Use modded keySym for keypad for US and NN + winVKeyUS = winVKey; + javaVKeyUS = javaVKeyXX; + } else { + // Assume extended scan code 0xE0 if extended flags is set (no 0xE1 from WM_KEYUP/WM_KEYDOWN) + USHORT winScanCodeExt = winScanCode; + if( 0 != ( 0x01 & flags ) ) { + winScanCodeExt |= 0xE000; + } + + // + // winVKey, winScanCodeExt -> javaVKeyUS w/ US KeyboardLayout + // + for (i = 0; keyMapTable[i].windowsKey != 0; i++) { + if ( keyMapTable[i].windowsScanCodeUS == winScanCodeExt ) { + winVKeyUS = keyMapTable[i].windowsKey; + javaVKeyUS = keyMapTable[i].javaKey; + break; + } + } + } *outJavaVKeyUS = javaVKeyUS; *outJavaVKeyXX = javaVKeyXX; diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 56b7251d2..e2392a113 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -58,6 +58,10 @@ static jmethodID requestFocusID = NULL; #define IS_WITHIN(k,a,b) ((a)<=(k)&&(k)<=(b)) +/** + * QT Reference: + * + */ static short X11KeySym2NewtVKey(KeySym keySym) { if( IS_WITHIN( keySym, XK_a, XK_z ) ) { return ( keySym - XK_a ) + J_VK_A ; @@ -84,8 +88,6 @@ static short X11KeySym2NewtVKey(KeySym keySym) { return J_VK_TAB; case XK_Cancel: return J_VK_CANCEL; - case XK_Clear: - return J_VK_CLEAR; case XK_Shift_L: case XK_Shift_R: return J_VK_SHIFT; @@ -95,6 +97,7 @@ static short X11KeySym2NewtVKey(KeySym keySym) { case XK_Alt_L: return J_VK_ALT; case XK_Alt_R: + case XK_ISO_Level3_Shift: return J_VK_ALT_GRAPH; case XK_Super_L: case XK_Super_R: @@ -119,6 +122,10 @@ static short X11KeySym2NewtVKey(KeySym keySym) { case XK_End: case XK_KP_End: return J_VK_END; + case XK_Begin: + return J_VK_BEGIN; + case XK_KP_Begin: // NumPad 5 - equal behavior w/ QT/Windows + return J_VK_CLEAR; case XK_Home: case XK_KP_Home: return J_VK_HOME; @@ -146,6 +153,7 @@ static short X11KeySym2NewtVKey(KeySym keySym) { return J_VK_DECIMAL; case XK_KP_Divide: return J_VK_DIVIDE; + case XK_Clear: // equal behavior w/ QT case XK_Delete: case XK_KP_Delete: return J_VK_DELETE; @@ -450,7 +458,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage keyString = (*env)->NewStringUTF(env, text); } - if( 0 == keyChar ) { + #ifdef DEBUG_KEYS + fprintf(stderr, "NEWT X11 Key.0: keyCode 0x%X keySym 0x%X, (shifted: 0x%X)\n", + (int)keyCode, (int)keySym, (int) shiftedKeySym); + #endif + if( IS_WITHIN( shiftedKeySym, XK_KP_Space, XK_KP_9 ) ) { + // Use modded keySym for keypad for US and NN + keySym = shiftedKeySym; + unShiftedKeySym = shiftedKeySym; + } else if( 0 == keyChar ) { // Use keyCode's keySym for dead-key (aka modifiers, etc) unShiftedKeySym = keySym; } else if( 0 == ( evt.xkey.state & ShiftCtrlModMask ) ) { @@ -467,7 +483,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage modifiers |= X11InputState2NewtModifiers(xkey_state, javaVKeyNN, evt.type == KeyPress) | autoRepeatModifiers; #ifdef DEBUG_KEYS - fprintf(stderr, "NEWT X11 Key: keyCode 0x%X keySym 0x%X, (0x%X, shifted: 0x%X), keyChar '%c' 0x%X %d, javaVKey[US 0x%X, NN 0x%X], xstate 0x%X %u, jmods 0x%X\n", + fprintf(stderr, "NEWT X11 Key.X: keyCode 0x%X keySym 0x%X, (0x%X, shifted: 0x%X), keyChar '%c' 0x%X %d, javaVKey[US 0x%X, NN 0x%X], xstate 0x%X %u, jmods 0x%X\n", (int)keyCode, (int)keySym, (int) unShiftedKeySym, (int)shiftedKeySym, keyChar, keyChar, charCount, (int)javaVKeyUS, (int)javaVKeyNN, (int)xkey_state, (int)xkey_state, (int)modifiers); -- cgit v1.2.3 From 31e72d2f2d953352b2a8c83368039ecca8139d49 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 16 May 2013 23:53:09 +0200 Subject: NEWT: MouseEvent Ctor: Use proper float[] rotationXYZ and float rotationScale arguments. --- .../classes/com/jogamp/newt/event/MouseEvent.java | 22 +++++++----- src/newt/classes/jogamp/newt/WindowImpl.java | 40 ++++++++++++++-------- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 4 ++- .../jogamp/newt/driver/x11/WindowDriver.java | 20 +++++------ .../jogamp/newt/swt/event/SWTNewtEventFactory.java | 7 ++-- .../junit/newt/event/BaseNewtEventModifiers.java | 3 +- 6 files changed, 59 insertions(+), 37 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index a40b0aa18..18c8285f7 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -92,6 +92,17 @@ public class MouseEvent extends InputEvent /** Maximum number of buttons, value 16 */ public static final short BUTTON_NUMBER = 16; + /** Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods). */ + public static final float[] getRotationXYZ(final float rotationXorY, final int mods) { + final float[] rotationXYZ = new float[] { 0f, 0f, 0f }; + if( 0 != ( mods & InputEvent.SHIFT_MASK ) ) { + rotationXYZ[0] = rotationXorY; + } else { + rotationXYZ[1] = rotationXorY; + } + return rotationXYZ; + } + public static final short getClickTimeout() { return 300; } @@ -99,7 +110,7 @@ public class MouseEvent extends InputEvent /** Constructor for tradition 1-pointer mouse events. */ public MouseEvent(short eventType, Object source, long when, int modifiers, int x, int y, short clickCount, short button, - float rotation) + float[] rotationXYZ, float rotationScale) { super(eventType, source, when, modifiers); this.x = new int[]{x}; @@ -109,13 +120,8 @@ public class MouseEvent extends InputEvent this.pointerIDs = constMousePointerIDs; this.clickCount=clickCount; this.button=button; - this.rotationXYZ = new float[] { 0f, 0f, 0f }; - if( isShiftDown() ) { - this.rotationXYZ[0] = rotation; - } else { - this.rotationXYZ[1] = rotation; - } - this.rotationScale = 1f; + this.rotationXYZ = rotationXYZ; + this.rotationScale = rotationScale; this.pointerTypes = constMousePointerTypes; } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 16d252ca3..805ad08ad 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2133,17 +2133,29 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // MouseListener/Event Support // - public void sendMouseEvent(short eventType, int modifiers, - int x, int y, short button, float rotation) { + public final void sendMouseEvent(short eventType, int modifiers, + int x, int y, short button, float rotation) { doMouseEvent(false, false, eventType, modifiers, x, y, button, rotation); } - public void enqueueMouseEvent(boolean wait, short eventType, int modifiers, - int x, int y, short button, float rotation) { + public final void enqueueMouseEvent(boolean wait, short eventType, int modifiers, + int x, int y, short button, float rotation) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotation); } - + protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, + int x, int y, short button, float rotation) { + this.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); + } + /** + public final void sendMouseEvent(short eventType, int modifiers, + int x, int y, short button, float[] rotationXYZ, float rotationScale) { + doMouseEvent(false, false, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); + } + public final void enqueueMouseEvent(boolean wait, short eventType, int modifiers, + int x, int y, short button, float[] rotationXYZ, float rotationScale) { + doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); + } */ protected void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, - int x, int y, short button, float rotation) { + int x, int y, short button, float[] rotationXYZ, float rotationScale) { if( eventType == MouseEvent.EVENT_MOUSE_ENTERED || eventType == MouseEvent.EVENT_MOUSE_EXITED ) { if( eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1 ) { x = lastMousePosition.getX(); @@ -2172,7 +2184,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(!mouseInWindow) { mouseInWindow = true; eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, this, when, - modifiers, x, y, (short)0, (short)0, (short)0); + modifiers, x, y, (short)0, (short)0, rotationXYZ, rotationScale); // clear states lastMousePressed = 0; lastMouseClickCount = (short)0; @@ -2213,13 +2225,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer mouseButtonPressed = button; mouseButtonModMask |= MouseEvent.getButtonMask(button); e = new MouseEvent(eventType, this, when, - modifiers, x, y, lastMouseClickCount, button, 0); + modifiers, x, y, lastMouseClickCount, button, rotationXYZ, rotationScale); } else if( MouseEvent.EVENT_MOUSE_RELEASED == eventType ) { e = new MouseEvent(eventType, this, when, - modifiers, x, y, lastMouseClickCount, button, 0); + modifiers, x, y, lastMouseClickCount, button, rotationXYZ, rotationScale); if( when - lastMousePressed < MouseEvent.getClickTimeout() ) { eClicked = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, this, when, - modifiers, x, y, lastMouseClickCount, button, 0); + modifiers, x, y, lastMouseClickCount, button, rotationXYZ, rotationScale); } else { lastMouseClickCount = (short)0; lastMousePressed = 0; @@ -2229,15 +2241,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else if( MouseEvent.EVENT_MOUSE_MOVED == eventType ) { if ( mouseButtonPressed > 0 ) { e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, - modifiers, x, y, (short)1, mouseButtonPressed, 0); + modifiers, x, y, (short)1, mouseButtonPressed, rotationXYZ, rotationScale); } else { e = new MouseEvent(eventType, this, when, - modifiers, x, y, (short)0, button, (short)0); + modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); } } else if( MouseEvent.EVENT_MOUSE_WHEEL_MOVED == eventType ) { - e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotation); + e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); } else { - e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, 0); + e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); } if( null != eEntered ) { if(DEBUG_MOUSE_EVENT) { diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index a1aa69e0a..1e15070f8 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -28,6 +28,8 @@ package jogamp.newt.awt.event; +import com.jogamp.newt.event.MouseEvent; + /** * *

    AWT Event Modifier Mapping
    @@ -635,7 +637,7 @@ public class AWTNewtEventFactory { return new com.jogamp.newt.event.MouseEvent( newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), mods, event.getX(), event.getY(), (short)event.getClickCount(), - newtButton, rotation); + newtButton, MouseEvent.getRotationXYZ(rotation, mods), 1f); } return null; // no mapping .. } diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index fcc5b2148..69a09c1f9 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -228,7 +228,7 @@ public class WindowDriver extends WindowImpl { @Override protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, - int x, int y, short button, float rotation) { + int x, int y, short button, float[] rotationXYZ, float rotationScale) { switch(eventType) { case MouseEvent.EVENT_MOUSE_PRESSED: switch(button) { @@ -242,32 +242,32 @@ public class WindowDriver extends WindowImpl { break; case MouseEvent.EVENT_MOUSE_RELEASED: switch(button) { - case X11_WHEEL_ONE_UP_BUTTON: + case X11_WHEEL_ONE_UP_BUTTON: // vertical scroll up eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; button = 1; - rotation = 1; + rotationXYZ[1] = 1; break; - case X11_WHEEL_ONE_DOWN_BUTTON: + case X11_WHEEL_ONE_DOWN_BUTTON: // vertical scroll down eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; button = 1; - rotation = -1; + rotationXYZ[1] = -1; break; - case X11_WHEEL_TWO_UP_BUTTON: // vertical scroll left + case X11_WHEEL_TWO_UP_BUTTON: // horizontal scroll left eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; button = 1; - rotation = 1; + rotationXYZ[0] = 1; modifiers |= InputEvent.SHIFT_MASK; break; - case X11_WHEEL_TWO_DOWN_BUTTON: // vertical scroll right + case X11_WHEEL_TWO_DOWN_BUTTON: // horizontal scroll right eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; button = 1; - rotation = -1; + rotationXYZ[0] = -1; modifiers |= InputEvent.SHIFT_MASK; break; } break; } - super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotation); + super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); } protected final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar0, String keyString) { diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java index 24a5c41de..1e99d1ef7 100644 --- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -33,6 +33,7 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import com.jogamp.newt.event.InputEvent; +import com.jogamp.newt.event.MouseEvent; /** * SWT event translator to NEWT, inclusive dispatch listener. @@ -242,7 +243,7 @@ public class SWTNewtEventFactory { return new com.jogamp.newt.event.MouseEvent( type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), - mods, event.x, event.y, (short)event.count, (short)event.button, rotation); + mods, event.x, event.y, (short)event.count, (short)event.button, MouseEvent.getRotationXYZ(rotation, mods), 1f); } return null; // no mapping .. } @@ -297,7 +298,7 @@ public class SWTNewtEventFactory { res.getSource(), res.getWhen(), res.getModifiers(), res.getX(), res.getY(), res.getClickCount(), - res.getButton(), res.getWheelRotation() ); + res.getButton(), res.getRotation(), res.getRotationScale()); l.mouseClicked(res2); } break; @@ -308,7 +309,7 @@ public class SWTNewtEventFactory { res.getSource(), res.getWhen(), res.getModifiers(), res.getX(), res.getY(), res.getClickCount(), - dragButtonDown, res.getWheelRotation() ); + dragButtonDown, res.getRotation(), res.getRotationScale()); l.mouseDragged( res2 ); } else { l.mouseMoved(res); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index 05a24272c..3a2c4cc81 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -134,7 +134,8 @@ public abstract class BaseNewtEventModifiers extends UITestCase { if( _modifierCheckEnabled ) { final MouseEvent expEvent = new MouseEvent(hasEvent.getEventType(), hasEvent.getSource(), hasEvent.getWhen(), _expectedModifiers, - hasEvent.getX(), hasEvent.getY(), hasEvent.getClickCount(), hasEvent.getButton(), hasEvent.getWheelRotation()); + hasEvent.getX(), hasEvent.getY(), hasEvent.getClickCount(), hasEvent.getButton(), + hasEvent.getRotation(), hasEvent.getRotationScale()); _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.SHIFT_MASK, "shift" ) ; _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.CTRL_MASK, "ctrl" ) ; -- cgit v1.2.3 From 05eef46e33f41f5c234ffb1563fd8f641208fe85 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 11 Jun 2013 16:29:48 +0200 Subject: Adapt to GlueGen commit 1a01dce6c42b398cdd68d405828774a3ab366456 --- make/config/jogl/cg-common-CustomJavaCode.java | 6 +++++- make/config/jogl/cg-common.cfg | 2 ++ make/scripts/tests.sh | 4 ++-- .../classes/com/jogamp/graph/font/FontFactory.java | 8 ++++--- .../font/typecast/TypecastFontConstructor.java | 2 +- src/jogl/classes/jogamp/opengl/Debug.java | 25 ++++++++++------------ .../av/impl/FFMPEGDynamicLibraryBundleInfo.java | 7 +++++- .../classes/jogamp/nativewindow/Debug.java | 24 +++++++++------------ .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 6 ++++-- src/newt/classes/jogamp/newt/Debug.java | 25 ++++++++++------------ 10 files changed, 57 insertions(+), 52 deletions(-) (limited to 'src/newt/classes') diff --git a/make/config/jogl/cg-common-CustomJavaCode.java b/make/config/jogl/cg-common-CustomJavaCode.java index 31d1961fc..cc1fefd1a 100644 --- a/make/config/jogl/cg-common-CustomJavaCode.java +++ b/make/config/jogl/cg-common-CustomJavaCode.java @@ -6,7 +6,11 @@ static { if(null==cgProcAddressTable) { throw new RuntimeException("Couldn't instantiate CgProcAddressTable"); } - cgDynamicLookupHelper = new DynamicLibraryBundle(new CgDynamicLibraryBundleInfo()); + + cgDynamicLookupHelper = AccessController.doPrivileged(new PrivilegedAction() { + public DynamicLibraryBundle run() { + return new DynamicLibraryBundle(new CgDynamicLibraryBundleInfo()); + } } ); if(null==cgDynamicLookupHelper) { throw new RuntimeException("Null CgDynamicLookupHelper"); } diff --git a/make/config/jogl/cg-common.cfg b/make/config/jogl/cg-common.cfg index 35805bf01..d6a5367a6 100644 --- a/make/config/jogl/cg-common.cfg +++ b/make/config/jogl/cg-common.cfg @@ -105,6 +105,8 @@ Import jogamp.opengl.* Import com.jogamp.common.os.DynamicLookupHelper Import com.jogamp.common.os.DynamicLibraryBundle Import com.jogamp.opengl.cg.CgDynamicLibraryBundleInfo +Import java.security.PrivilegedAction +Import java.security.AccessController # # NIODirectOnly directives for routines requiring them for semantic reasons diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 693683827..2a75ffc5b 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -284,7 +284,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* @@ -312,7 +312,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix02NOUI $* -testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix03NOUI $* +#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix03NOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectDoubleNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* diff --git a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java index 33d487355..33a977bba 100644 --- a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java +++ b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java @@ -33,13 +33,15 @@ import java.net.URLConnection; import com.jogamp.common.util.PropertyAccess; import com.jogamp.common.util.ReflectionUtil; -import com.jogamp.common.util.SecurityUtil; import jogamp.graph.font.FontConstructor; import jogamp.graph.font.JavaFontLoader; import jogamp.graph.font.UbuntuFontLoader; public class FontFactory { + public static final String FontConstructorPropKey = "jogamp.graph.font.ctor"; + public static final String DefaultFontConstructor = "jogamp.graph.font.typecast.TypecastFontConstructor"; + /** Ubuntu is the default font family */ public static final int UBUNTU = 0; @@ -54,9 +56,9 @@ public class FontFactory { * "jogamp.graph.font.typecast.TypecastFontFactory" (default) * "jogamp.graph.font.ttf.TTFFontImpl" */ - String fontImplName = PropertyAccess.getProperty("FontImpl", true, SecurityUtil.getCommonAccessControlContext(FontFactory.class)); + String fontImplName = PropertyAccess.getProperty(FontConstructorPropKey, true); if(null == fontImplName) { - fontImplName = "jogamp.graph.font.typecast.TypecastFontConstructor"; + fontImplName = DefaultFontConstructor; } fontConstr = (FontConstructor) ReflectionUtil.createInstance(fontImplName, FontFactory.class.getClassLoader()); } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java index 0f762e79c..8479c08ca 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java @@ -71,7 +71,7 @@ public class TypecastFontConstructor implements FontConstructor { int len=0; Font f = null; try { - tf = IOUtil.createTempFile( "jogl.font", ".ttf", false, null); + tf = IOUtil.createTempFile( "jogl.font", ".ttf", false); len = IOUtil.copyURLConn2File(fconn, tf); if(len==0) { tf.delete(); diff --git a/src/jogl/classes/jogamp/opengl/Debug.java b/src/jogl/classes/jogamp/opengl/Debug.java index 4287c1960..f87f1bb3f 100644 --- a/src/jogl/classes/jogamp/opengl/Debug.java +++ b/src/jogl/classes/jogamp/opengl/Debug.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -39,6 +40,9 @@ package jogamp.opengl; +import java.security.AccessController; +import java.security.PrivilegedAction; + import com.jogamp.common.util.PropertyAccess; /** Helper routines for logging and debugging. */ @@ -49,7 +53,12 @@ public class Debug extends PropertyAccess { private static final boolean debugAll; static { - PropertyAccess.addTrustedPrefix("jogl.", Debug.class); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + PropertyAccess.addTrustedPrefix("jogl."); + return null; + } } ); + verbose = isPropertyDefined("jogl.verbose", true); debugAll = isPropertyDefined("jogl.debug", true); if (verbose) { @@ -60,18 +69,6 @@ public class Debug extends PropertyAccess { } } - public static final boolean isPropertyDefined(final String property, final boolean jnlpAlias) { - return PropertyAccess.isPropertyDefined(property, jnlpAlias, null); - } - - public static String getProperty(final String property, final boolean jnlpAlias) { - return PropertyAccess.getProperty(property, jnlpAlias, null); - } - - public static final boolean getBooleanProperty(final String property, final boolean jnlpAlias) { - return PropertyAccess.getBooleanProperty(property, jnlpAlias, null); - } - public static boolean verbose() { return verbose; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java index 32c863553..883c13f51 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java @@ -28,6 +28,8 @@ package jogamp.opengl.util.av.impl; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -132,7 +134,10 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { static boolean initSingleton() { return ready; } private static boolean initSymbols() { - final DynamicLibraryBundle dl = new DynamicLibraryBundle(new FFMPEGDynamicLibraryBundleInfo()); + final DynamicLibraryBundle dl = AccessController.doPrivileged(new PrivilegedAction() { + public DynamicLibraryBundle run() { + return new DynamicLibraryBundle(new FFMPEGDynamicLibraryBundleInfo()); + } } ); final boolean avutilLoaded = dl.isToolLibLoaded(0); final boolean avformatLoaded = dl.isToolLibLoaded(1); final boolean avcodecLoaded = dl.isToolLibLoaded(2); diff --git a/src/nativewindow/classes/jogamp/nativewindow/Debug.java b/src/nativewindow/classes/jogamp/nativewindow/Debug.java index e07fd1b57..95547c971 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/Debug.java +++ b/src/nativewindow/classes/jogamp/nativewindow/Debug.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -39,6 +40,9 @@ package jogamp.nativewindow; +import java.security.AccessController; +import java.security.PrivilegedAction; + import com.jogamp.common.util.PropertyAccess; /** Helper routines for logging and debugging. */ @@ -49,7 +53,11 @@ public class Debug extends PropertyAccess { private static final boolean debugAll; static { - PropertyAccess.addTrustedPrefix("nativewindow.", Debug.class); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + PropertyAccess.addTrustedPrefix("nativewindow."); + return null; + } } ); verbose = isPropertyDefined("nativewindow.verbose", true); debugAll = isPropertyDefined("nativewindow.debug", true); @@ -61,18 +69,6 @@ public class Debug extends PropertyAccess { } } - public static final boolean isPropertyDefined(final String property, final boolean jnlpAlias) { - return PropertyAccess.isPropertyDefined(property, jnlpAlias, null); - } - - public static String getProperty(final String property, final boolean jnlpAlias) { - return PropertyAccess.getProperty(property, jnlpAlias, null); - } - - public static final boolean getBooleanProperty(final String property, final boolean jnlpAlias) { - return PropertyAccess.getBooleanProperty(property, jnlpAlias, null); - } - public static boolean verbose() { return verbose; } diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index c3ad51c96..091a1a5cf 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -164,12 +164,14 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { // Closing action: back to parent! @Override public void windowDestroyNotify(WindowEvent e) { - if( WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() ) { + if( isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() ) { if(null == glWindow.getParent()) { // we may be called directly by the native EDT new Thread(new Runnable() { public void run() { - glWindow.reparentWindow(awtParent); + if( glWindow.isNativeValid() ) { + glWindow.reparentWindow(awtParent); + } } }).start(); } diff --git a/src/newt/classes/jogamp/newt/Debug.java b/src/newt/classes/jogamp/newt/Debug.java index 3c83da4d9..676d9b758 100644 --- a/src/newt/classes/jogamp/newt/Debug.java +++ b/src/newt/classes/jogamp/newt/Debug.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -39,6 +40,9 @@ package jogamp.newt; +import java.security.AccessController; +import java.security.PrivilegedAction; + import com.jogamp.common.util.PropertyAccess; /** Helper routines for logging and debugging. */ @@ -49,7 +53,12 @@ public class Debug extends PropertyAccess { private static final boolean debugAll; static { - PropertyAccess.addTrustedPrefix("newt.", Debug.class); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + PropertyAccess.addTrustedPrefix("newt."); + return null; + } } ); + verbose = isPropertyDefined("newt.verbose", true); debugAll = isPropertyDefined("newt.debug", true); if (verbose) { @@ -60,18 +69,6 @@ public class Debug extends PropertyAccess { } } - public static final boolean isPropertyDefined(final String property, final boolean jnlpAlias) { - return PropertyAccess.isPropertyDefined(property, jnlpAlias, null); - } - - public static final int getIntProperty(final String property, final boolean jnlpAlias, int defaultValue) { - return PropertyAccess.getIntProperty(property, jnlpAlias, null, defaultValue); - } - - public static final boolean getBooleanProperty(final String property, final boolean jnlpAlias) { - return PropertyAccess.getBooleanProperty(property, jnlpAlias, null); - } - public static boolean verbose() { return verbose; } -- cgit v1.2.3 From 2d83e346b1e737f9efc0e782ddbd2a9be6a4cd35 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 15 Jun 2013 08:14:19 +0200 Subject: AWTGraphicsConfiguration: Allow null capsRequested; NewtCanvasAWT: Avoid NPE @ addNotify() w/o newtChild --- .../com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java | 6 +++++- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/newt/classes') diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java index 2a152ff35..7e3d30a47 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java @@ -74,8 +74,9 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple /** * @param capsChosen if null, capsRequested is copied and aligned - * with the graphics Capabilities of the AWT Component to produce the chosen Capabilities. + * with the graphics {@link Capabilities} of the AWT Component to produce the chosen {@link Capabilities}. * Otherwise the capsChosen is used. + * @param capsRequested if null, default {@link Capabilities} are used, otherwise the given values. */ public static AWTGraphicsConfiguration create(Component awtComp, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) { final GraphicsConfiguration awtGfxConfig = awtComp.getGraphicsConfiguration(); @@ -91,6 +92,9 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple final AWTGraphicsDevice awtDevice = new AWTGraphicsDevice(awtGraphicsDevice, AbstractGraphicsDevice.DEFAULT_UNIT); final AWTGraphicsScreen awtScreen = new AWTGraphicsScreen(awtDevice); + if(null==capsRequested) { + capsRequested = new Capabilities(); + } if(null==capsChosen) { GraphicsConfiguration gc = awtGraphicsDevice.getDefaultConfiguration(); capsChosen = AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capsRequested, gc); diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index d0a4b7e98..32a92ec8b 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -355,8 +355,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto // after native peer is valid: Windows disableBackgroundErase(); - - jawtWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities()); + + jawtWindow = NewtFactoryAWT.getNativeWindow(this, null != newtChild ? newtChild.getRequestedCapabilities() : null); jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); if(DEBUG) { -- cgit v1.2.3 From 8b33170ec6fd3f215976875cb66d746fa1b48f61 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 17 Jun 2013 09:01:23 +0200 Subject: Fix Bug 688: Removal of NEWT KeyEvent.EVENT_KEY_TYPED and KeyListener.keyTyped(KeyEvent) --- make/scripts/tests.sh | 13 ++----- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 11 ++---- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 7 ++-- .../classes/com/jogamp/newt/event/KeyAdapter.java | 2 -- .../classes/com/jogamp/newt/event/KeyEvent.java | 6 ---- .../classes/com/jogamp/newt/event/KeyListener.java | 18 ++++++---- .../com/jogamp/newt/event/TraceKeyAdapter.java | 4 --- src/newt/classes/jogamp/newt/WindowImpl.java | 34 +----------------- src/newt/native/KeyEvent.h | 1 - src/newt/native/X11Event.c | 6 ---- src/newt/native/X11Window.c | 1 - src/newt/native/XCBEvent.c | 6 ---- .../graph/demos/GPURendererListenerBase01.java | 1 - .../graph/demos/GPUTextRendererListenerBase01.java | 10 +++--- .../junit/graph/demos/ui/UIListenerBase01.java | 1 - .../junit/jogl/acore/TestFBOMix2DemosES2NEWT.java | 5 ++- .../test/junit/jogl/caps/TestTranslucencyNEWT.java | 5 ++- .../jogl/demos/es1/newt/TestGearsES1NEWT.java | 5 ++- .../jogl/demos/es1/newt/TestRedSquareES1NEWT.java | 5 ++- .../test/junit/jogl/demos/es2/av/MovieCube.java | 5 ++- .../es2/newt/TestElektronenMultipliziererNEWT.java | 5 ++- .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 5 ++- .../demos/es2/newt/TestGearsES2NewtCanvasSWT.java | 5 ++- .../jogl/demos/es2/newt/TestLandscapeES2NEWT.java | 5 ++- .../es2/newt/TestLandscapeES2NewtCanvasAWT.java | 5 ++- .../jogl/demos/es2/newt/TestRedSquareES2NEWT.java | 5 ++- .../junit/jogl/demos/gl2/newt/TestGearsNEWT.java | 5 ++- .../TestNewtCanvasSWTBug628ResizeDeadlockAWT.java | 5 ++- .../newt/event/TestNewtKeyCodeModifiersAWT.java | 32 ++++++----------- .../test/junit/newt/event/TestNewtKeyCodesAWT.java | 3 -- .../newt/event/TestNewtKeyEventAutoRepeatAWT.java | 21 ++++++------ .../junit/newt/event/TestNewtKeyEventOrderAWT.java | 4 +-- .../TestNewtKeyPressReleaseUnmaskRepeatAWT.java | 5 --- .../test/junit/newt/parenting/KeyAction.java | 5 ++- .../parenting/NewtAWTReparentingKeyAdapter.java | 5 ++- .../TestParentingFocusTraversal01AWT.java | 5 ++- .../opengl/test/junit/util/AWTKeyAdapter.java | 19 ++-------- .../test/junit/util/KeyEventCountAdapter.java | 4 +-- .../opengl/test/junit/util/NEWTKeyAdapter.java | 26 +++----------- .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 40 ++++++---------------- .../jogamp/opengl/test/junit/util/QuitAdapter.java | 6 ++-- 41 files changed, 136 insertions(+), 225 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5fd5d621d..bf8615d6e 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -284,7 +284,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* @@ -438,15 +440,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* -#testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* -#testawt com.jogamp.opengl.test.bugs.Bug735Inv2AppletAWT $* -#testawt com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT $* -#testawt com.jogamp.opengl.test.bugs.Bug735Inv4AWT $* - # # swt (testswt) # @@ -478,7 +471,7 @@ testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 32a92ec8b..692741a88 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -201,8 +201,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto }; class FocusTraversalKeyListener implements KeyListener { - boolean suppress = false; - public void keyPressed(KeyEvent e) { if( isParent() && !isFullscreen() ) { handleKey(e, false); @@ -213,21 +211,16 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto handleKey(e, true); } } - public void keyTyped(KeyEvent e) { - if(suppress) { - e.setConsumed(true); - suppress = false; // reset - } - } void handleKey(KeyEvent evt, boolean onRelease) { if(null == keyboardFocusManager) { throw new InternalError("XXX"); } final AWTKeyStroke ks = AWTKeyStroke.getAWTKeyStroke(evt.getKeyCode(), evt.getModifiers(), onRelease); + boolean suppress = false; if(null != ks) { final Set fwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); - final Set bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); + final Set bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); if(fwdKeys.contains(ks)) { if(DEBUG) { System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()); diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 091a1a5cf..35199dc82 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -288,9 +288,10 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { public void keyPressed(KeyEvent e) { } - public void keyReleased(KeyEvent e) { - } - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='d') { glWindow.setUndecorated(!glWindow.isUndecorated()); } if(e.getKeyChar()=='f') { diff --git a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java index 93c8409b1..42ebea722 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java @@ -35,7 +35,5 @@ public abstract class KeyAdapter implements KeyListener } public void keyReleased(KeyEvent e) { } - public void keyTyped(KeyEvent e) { - } } diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 6e63ad3a3..683a5ca54 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -217,7 +217,6 @@ public class KeyEvent extends InputEvent 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 + ")"; } } @@ -365,11 +364,6 @@ public class KeyEvent extends InputEvent public static final short EVENT_KEY_PRESSED = 300; /** A key has been released, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */ public static final short EVENT_KEY_RELEASED= 301; - /** - * A {@link #isPrintableKey() printable} key has been typed (pressed and released), excluding {@link #isAutoRepeat() auto-repeat}. - * @deprecated Redundant, will be removed soon. Use {@link #EVENT_KEY_RELEASED} and exclude non {@link #isPrintableKey() printable} keys and {@link #isAutoRepeat() auto-repeat}. - */ - public static final short EVENT_KEY_TYPED = 302; /** * This value, {@code '\0'}, is used to indicate that the keyChar is unknown or not printable. diff --git a/src/newt/classes/com/jogamp/newt/event/KeyListener.java b/src/newt/classes/com/jogamp/newt/event/KeyListener.java index 5bca733d3..b3927d81a 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyListener.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyListener.java @@ -43,13 +43,19 @@ public interface KeyListener extends NEWTEventListener { /** A key has been {@link KeyEvent#EVENT_KEY_PRESSED pressed}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */ public void keyPressed(KeyEvent e); - /** A key has been {@link KeyEvent#EVENT_KEY_RELEASED released}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */ - public void keyReleased(KeyEvent e); /** - * A {@link #isPrintableKey() printable} key has been {@link KeyEvent#EVENT_KEY_TYPED typed} (pressed and released), excluding {@link #isAutoRepeat() auto-repeat}. See {@link KeyEvent}. - * @deprecated Redundant, will be removed soon. Use {@link #keyReleased(KeyEvent)} and exclude non {@link #isPrintableKey() printable} keys and {@link #isAutoRepeat() auto-repeat}. - */ - public void keyTyped(KeyEvent e) ; + * A key has been {@link KeyEvent#EVENT_KEY_RELEASED released}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. + *

    + * To simulated the removed keyTyped(KeyEvent e) semantics, + * simply apply the following constraints upfront and bail out if not matched, i.e.: + *

    +        if( !e.isPrintableKey() || e.isAutoRepeat() ) {
    +            return;
    +        }            
    +     * 
    + *

    + */ + public void keyReleased(KeyEvent e); } diff --git a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java index 98ba5a24d..629dc50d7 100644 --- a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java @@ -48,9 +48,5 @@ public class TraceKeyAdapter implements KeyListener { System.err.println(e); if(null!=downstream) { downstream.keyReleased(e); } } - public void keyTyped(KeyEvent e) { - System.err.println(e); - if(null!=downstream) { downstream.keyTyped(e); } - } } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 805ad08ad..dca287c6b 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2476,7 +2476,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return keyListeners.toArray(new KeyListener[keyListeners.size()]); } - @SuppressWarnings("deprecation") private final boolean propagateKeyEvent(KeyEvent e, KeyListener l) { switch(e.getEventType()) { case KeyEvent.EVENT_KEY_PRESSED: @@ -2485,40 +2484,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer case KeyEvent.EVENT_KEY_RELEASED: l.keyReleased(e); break; - case KeyEvent.EVENT_KEY_TYPED: - l.keyTyped(e); - break; default: throw new NativeWindowException("Unexpected key event type " + e.getEventType()); } return e.isConsumed(); } - @SuppressWarnings("deprecation") protected void consumeKeyEvent(KeyEvent e) { - boolean consumedE = false, consumedTyped = false; - if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { - throw new InternalError("Deprecated KeyEvent.EVENT_KEY_TYPED is synthesized - don't send/enqueue it!"); - } - - // Synthesize deprecated event KeyEvent.EVENT_KEY_TYPED - final KeyEvent eTyped; - if( KeyEvent.EVENT_KEY_RELEASED == e.getEventType() && e.isPrintableKey() && !e.isAutoRepeat() ) { - eTyped = KeyEvent.create(KeyEvent.EVENT_KEY_TYPED, e.getSource(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeySymbol(), e.getKeyChar()); - } else { - eTyped = null; - } + boolean consumedE = false; if(null != keyboardFocusHandler) { consumedE = propagateKeyEvent(e, keyboardFocusHandler); if(DEBUG_KEY_EVENT) { System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumedE); } - if( null != eTyped ) { - consumedTyped = propagateKeyEvent(eTyped, keyboardFocusHandler); - if(DEBUG_KEY_EVENT) { - System.err.println("consumeKeyEvent: "+eTyped+", keyboardFocusHandler consumed: "+consumedTyped); - } - } } if(DEBUG_KEY_EVENT) { if( !consumedE ) { @@ -2528,16 +2506,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) { consumedE = propagateKeyEvent(e, keyListeners.get(i)); } - if( null != eTyped ) { - if(DEBUG_KEY_EVENT) { - if( !consumedTyped ) { - System.err.println("consumeKeyEvent: "+eTyped); - } - } - for(int i = 0; !consumedTyped && i < keyListeners.size(); i++ ) { - consumedTyped = propagateKeyEvent(eTyped, keyListeners.get(i)); - } - } } // diff --git a/src/newt/native/KeyEvent.h b/src/newt/native/KeyEvent.h index a182db973..59977d565 100644 --- a/src/newt/native/KeyEvent.h +++ b/src/newt/native/KeyEvent.h @@ -31,7 +31,6 @@ #define EVENT_KEY_PRESSED 300 #define EVENT_KEY_RELEASED 301 -#define EVENT_KEY_TYPED 302 #define J_VK_UNDEFINED ( 0x0U ) #define J_VK_HOME ( 0x02U ) diff --git a/src/newt/native/X11Event.c b/src/newt/native/X11Event.c index 770f60e8f..32a55c67c 100644 --- a/src/newt/native/X11Event.c +++ b/src/newt/native/X11Event.c @@ -170,15 +170,9 @@ void X11EventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED, modifiers, keySym, (jchar) -1); - - (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED, - modifiers, keySym, (jchar) keyChar); #else (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED, modifiers, keySym, (jchar) -1); - - (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED, - modifiers, keySym, (jchar) keyChar); #endif break; diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index e567781cf..3f50f27a4 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -699,7 +699,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0 XGetWindowAttributes(dpy, w, &xwa); // prefetch colormap to be destroyed after window destruction XSelectInput(dpy, w, 0); XUnmapWindow(dpy, w); - XSync(dpy, False); // Drain all events related to this window .. Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom /*, kbdHandle */); // XKB disabled for now diff --git a/src/newt/native/XCBEvent.c b/src/newt/native/XCBEvent.c index f067f4b7a..d02d5a4ba 100644 --- a/src/newt/native/XCBEvent.c +++ b/src/newt/native/XCBEvent.c @@ -176,15 +176,9 @@ void XCBEventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED, modifiers, X11KeySym2NewtVKey(_evt->state), (jchar) keyChar); - - (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED, - modifiers, (jint) -1, (jchar) keyChar); #else (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED, modifiers, X11KeySym2NewtVKey(_evt->state), (jchar) keyChar); - - (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED, - modifiers, (jint) -1, (jchar) keyChar); #endif } break; diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java index 6378c1ee3..4ebb937a0 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java @@ -293,7 +293,6 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { } } } - public void keyTyped(KeyEvent arg0) {} public void keyReleased(KeyEvent arg0) {} } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java index 658d4a4f1..31377025a 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java @@ -295,10 +295,13 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB } } - public void keyTyped(KeyEvent arg0) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(userInput) { - char c = arg0.getKeyChar(); - + char c = e.getKeyChar(); + if(c == 0x0d) { userInput = false; setIgnoreInput(false); @@ -309,6 +312,5 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB } } } - public void keyReleased(KeyEvent arg0) {} } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java index 15daf70cd..c94b63494 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java @@ -317,7 +317,6 @@ public abstract class UIListenerBase01 implements GLEventListener { } } } - public void keyTyped(KeyEvent arg0) {} public void keyReleased(KeyEvent arg0) {} } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java index b3c542c63..87d4df342 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java @@ -152,7 +152,10 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase { }); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } System.err.println("*** "+e); if(e.getKeyChar()=='f') { new Thread() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java index 67e8524a3..f184873be 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java @@ -85,7 +85,10 @@ public class TestTranslucencyNEWT extends UITestCase { final GLWindow f_glWindow = glWindow; glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java index 05cc2aeb0..34fa79b5a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java @@ -84,7 +84,10 @@ public class TestGearsES1NEWT extends UITestCase { final GLWindow f_glWindow = glWindow; glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java index b0e6b2b00..478195c99 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java @@ -82,7 +82,10 @@ public class TestRedSquareES1NEWT extends UITestCase { final GLWindow f_glWindow = glWindow; glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index 7f2713354..b7c4e729e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -82,7 +82,10 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { } private final KeyListener keyAction = new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } System.err.println("MC "+e); int pts0 = mPlayer.getCurrentPosition(); int pts1 = 0; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java index ed308bdfd..e22b00dff 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java @@ -103,7 +103,10 @@ public class TestElektronenMultipliziererNEWT extends UITestCase { final GLWindow f_glWindow = glWindow; glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java index bf47109fa..f12f02c5e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -269,7 +269,10 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { }); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { quitAdapter.enable(false); new Thread() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java index 9d9e3a876..eed2e1267 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java @@ -178,7 +178,10 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase { }); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java index 4ca70d7d3..281ee54f9 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java @@ -80,7 +80,10 @@ public class TestLandscapeES2NEWT extends UITestCase { glWindow.addWindowListener(quitAdapter); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java index c1df18c19..72357dc29 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java @@ -117,7 +117,10 @@ public class TestLandscapeES2NewtCanvasAWT extends UITestCase { }); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { quitAdapter.enable(false); new Thread() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java index 0e5842b23..b880c2f3b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java @@ -93,7 +93,10 @@ public class TestRedSquareES2NEWT extends UITestCase { glWindow.addWindowListener(quitAdapter); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java index 93dc885b6..3c33a4899 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java @@ -83,7 +83,10 @@ public class TestGearsNEWT extends UITestCase { final GLWindow f_glWindow = glWindow; glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java index d1b276105..0f9c50baa 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java @@ -308,7 +308,10 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase { glWindow.addGLEventListener( new BigFlashingX() ) ; glWindow.addKeyListener(new KeyAdapter() { @Override - public void keyTyped(com.jogamp.newt.event.KeyEvent e) { + public void keyReleased(com.jogamp.newt.event.KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } System.err.print("."); glWindow.display(); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java index b075af977..c1b572df3 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java @@ -159,48 +159,40 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { testNewtCanvasAWT_Impl(false); } - @SuppressWarnings("deprecation") static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, short modifierKey, int modifierMask, short keyCode, char keyCharOnly, char keyCharMod) { keyAdapter.reset(); AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode - AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 100); // release+typed keyCode + AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 100); // release keyCode robot.waitForIdle(); - for(int j=0; j < 100 && keyAdapter.getQueueSize() < 3; j++) { // wait until events are collected + for(int j=0; j < 100 && keyAdapter.getQueueSize() < 2; j++) { // wait until events are collected robot.delay(100); } AWTRobotUtil.newtKeyPress(0, robot, true, modifierKey, 10); // press MOD AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode - AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 10); // release+typed keyCode + AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 10); // release keyCode AWTRobotUtil.newtKeyPress(0, robot, false, modifierKey, 100); // release MOD robot.waitForIdle(); - for(int j=0; j < 100 && keyAdapter.getQueueSize() < 3+5; j++) { // wait until events are collected + for(int j=0; j < 100 && keyAdapter.getQueueSize() < 2+4; j++) { // wait until events are collected robot.delay(100); } - final int modTypedCount = KeyEvent.NULL_CHAR != keyCharMod ? 2 : -1 ; // ignore due to mods 'isPrintable' impact. NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - 3 /* press-SI */, 3 /* release-SI */, modTypedCount /* typed-SI */, - 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); + 3 /* press-SI */, 3 /* release-SI */, + 0 /* press-AR */, 0 /* release-AR */ ); final List queue = keyAdapter.getQueued(); int i=0; NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, 0, keyCode, keyCharOnly); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, 0, keyCode, keyCharOnly); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, 0, keyCode, keyCharOnly); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey, KeyEvent.NULL_CHAR); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, keyCode, keyCharMod); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, keyCode, keyCharMod); KeyEvent e = (KeyEvent) queue.get(i++); - if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { // optional, due to mods 'isPrintable' impact. - NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_TYPED, modifierMask, keyCode, keyCharMod); - e = (KeyEvent) queue.get(i++); - } NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey, KeyEvent.NULL_CHAR); } - @SuppressWarnings("deprecation") static void testKeyCodeAllModifierV1(Robot robot, NEWTKeyAdapter keyAdapter) { final short m1k = KeyEvent.VK_ALT; final int m1m = InputEvent.ALT_MASK; @@ -215,18 +207,18 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { AWTRobotUtil.newtKeyPress(0, robot, true, m3k, 10); // press MOD3 AWTRobotUtil.newtKeyPress(0, robot, true, KeyEvent.VK_1, 10); // press P - AWTRobotUtil.newtKeyPress(0, robot, false, KeyEvent.VK_1, 100); // release+typed P + AWTRobotUtil.newtKeyPress(0, robot, false, KeyEvent.VK_1, 100); // release P AWTRobotUtil.newtKeyPress(0, robot, false, m3k, 10); // release MOD AWTRobotUtil.newtKeyPress(0, robot, false, m2k, 10); // release MOD AWTRobotUtil.newtKeyPress(0, robot, false, m1k, 10); // release MOD robot.waitForIdle(); - for(int j=0; j < 100 && keyAdapter.getQueueSize() < 4+4+1; j++) { // wait until events are collected + for(int j=0; j < 100 && keyAdapter.getQueueSize() < 4+4; j++) { // wait until events are collected robot.delay(100); } NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - 4 /* press-SI */, 4 /* release-SI */, -1 /* typed-SI - ignored, since unknow whether printable w/ all mods */, - 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); + 4 /* press-SI */, 4 /* release-SI */, + 0 /* press-AR */, 0 /* release-AR */ ); final List queue = keyAdapter.getQueued(); int i=0; @@ -237,10 +229,6 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR); KeyEvent e = (KeyEvent) queue.get(i++); - if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { // optional, due to mods 'isPrintable' impact. - NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR); - e = (KeyEvent) queue.get(i++); - } NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k, KeyEvent.NULL_CHAR); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k, KeyEvent.NULL_CHAR); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k, KeyEvent.NULL_CHAR); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java index fb42141ea..a5f47e870 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java @@ -210,9 +210,6 @@ public class TestNewtKeyCodesAWT extends UITestCase { break; } eventCount++; - if( KeyEvent.isPrintableKey(c, false) ) { - eventCount++; - } robot.waitForIdle(); } for(int j=0; j < 20 && keyAdapter.getQueueSize() < eventCount; j++) { // wait until events are collected diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java index d7de4e735..f3a5c4aa9 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java @@ -153,7 +153,6 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { glWindow.destroy(); } - @SuppressWarnings("deprecation") static void testKeyEventAutoRepeat(Robot robot, NEWTKeyAdapter keyAdapter, int loops, int pressDurationMS) { System.err.println("KEY Event Auto-Repeat Test: "+loops); EventObject[][] first = new EventObject[loops][3]; @@ -167,8 +166,8 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { robot.waitForIdle(); AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_A, 500); // 1s .. no AR anymore robot.waitForIdle(); - final int minCodeCount = firstIdx + 3; - final int desiredCodeCount = firstIdx + 6; + final int minCodeCount = firstIdx + 2; + final int desiredCodeCount = firstIdx + 4; for(int j=0; j < 10 && keyAdapter.getQueueSize() < desiredCodeCount; j++) { // wait until events are collected robot.delay(100); } @@ -206,15 +205,15 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { final int expSI, expAR; if( hasAR ) { expSI = perLoopSI * loops; - expAR = ( keyEvents.size() - expSI*3 ) / 2; // AR: no typed -> 2, SI: typed -> 3 + expAR = ( keyEvents.size() - expSI*2 ) / 2; // auto-repeat release } else { - expSI = keyEvents.size() / 3; // all typed events + expSI = keyEvents.size() / 2; // all released events expAR = 0; } NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - expSI /* press-SI */, expSI /* release-SI */, expSI /* typed-SI */, - expAR /* press-AR */, expAR /* release-AR */, 0 /* typed-AR */ ); + expSI /* press-SI */, expSI /* release-SI */, + expAR /* press-AR */, expAR /* release-AR */ ); } if( !hasAR ) { @@ -246,17 +245,17 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { e = (KeyEvent) last[i][0]; Assert.assertTrue("last-2 Shall be A, but is "+e, KeyEvent.VK_A == e.getKeyCode() ); - Assert.assertTrue("last-2 Shall be PRESSED, but is "+e, KeyEvent.EVENT_KEY_PRESSED == e.getEventType() ); + Assert.assertTrue("last-2 Shall be RELEASED, but is "+e, KeyEvent.EVENT_KEY_RELEASED == e.getEventType() ); Assert.assertTrue("last-2 Shall be AR, but is "+e, 0 != ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); e = (KeyEvent) last[i][1]; Assert.assertTrue("last-1 Shall be A, but is "+e, KeyEvent.VK_A == e.getKeyCode() ); - Assert.assertTrue("last-1 Shall be RELEASED, but is "+e, KeyEvent.EVENT_KEY_RELEASED == e.getEventType() ); - Assert.assertTrue("last-1 Shall not be AR, but is "+e, 0 == ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); + Assert.assertTrue("last-1 Shall be PRESSED, but is "+e, KeyEvent.EVENT_KEY_PRESSED == e.getEventType() ); + Assert.assertTrue("last-1 Shall be AR, but is "+e, 0 != ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); e = (KeyEvent) last[i][2]; Assert.assertTrue("last-0 Shall be A, but is "+e, KeyEvent.VK_A == e.getKeyCode() ); - Assert.assertTrue("last-0 Shall be TYPED, but is "+e, KeyEvent.EVENT_KEY_TYPED == e.getEventType() ); + Assert.assertTrue("last-2 Shall be RELEASED, but is "+e, KeyEvent.EVENT_KEY_RELEASED == e.getEventType() ); Assert.assertTrue("last-0 Shall not be AR, but is "+e, 0 == ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java index bdf932904..68ccecf6b 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java @@ -191,8 +191,8 @@ public class TestNewtKeyEventOrderAWT extends UITestCase { final int expTotal = 6*loops; // all typed events NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - expTotal /* press-SI */, expTotal /* release-SI */, expTotal /* typed-SI */, - 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); + expTotal /* press-SI */, expTotal /* release-SI */, + 0 /* press-AR */, 0 /* release-AR */ ); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyPressReleaseUnmaskRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyPressReleaseUnmaskRepeatAWT.java index 2a35a15eb..d70259f13 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyPressReleaseUnmaskRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyPressReleaseUnmaskRepeatAWT.java @@ -215,11 +215,6 @@ public class TestNewtKeyPressReleaseUnmaskRepeatAWT extends UITestCase { System.err.println(seq+": "+e); } } - - @Override - public void keyTyped(KeyEvent e) { - } - } public static void main(String args[]) throws IOException { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/KeyAction.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/KeyAction.java index 3313ec65c..0ae94d7af 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/KeyAction.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/KeyAction.java @@ -38,7 +38,10 @@ class KeyAction extends KeyAdapter { this.eventFifo = eventFifo; } - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } eventFifo.put(e); } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 15393e8ea..9d08d8ff4 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -47,7 +47,10 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { this.glWindow = glWindow; } - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='i') { System.err.println(glWindow); } else if(e.getKeyChar()=='d') { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java index a1f07bda6..d340fc280 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java @@ -146,7 +146,10 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { glWindow1.addGLEventListener(demo1); glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); glWindow1.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='c') { System.err.println("Focus Clear"); if(glWindow1.getDelegatedWindow() instanceof DriverClearFocus) { diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java index 837ba5da1..776c3c7eb 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java @@ -36,7 +36,7 @@ import java.util.List; public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEventCountAdapter { String prefix; - int keyPressed, keyReleased, keyTyped; + int keyPressed, keyReleased; boolean pressed; List queue = new ArrayList(); boolean verbose = true; @@ -53,7 +53,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent } public synchronized int getCount() { - return keyTyped; + return keyReleased; } public synchronized int getKeyPressedCount(boolean autoRepeatOnly) { @@ -64,10 +64,6 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent return keyReleased; } - public synchronized int getKeyTypedCount(boolean autoRepeatOnly) { - return keyTyped; - } - public synchronized List getQueued() { return queue; } @@ -77,7 +73,6 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent } public synchronized void reset() { - keyTyped = 0; keyPressed = 0; keyReleased = 0; pressed = false; @@ -102,14 +97,6 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent } } - public synchronized void keyTyped(java.awt.event.KeyEvent e) { - keyTyped++; - queue.add(e); - if( verbose ) { - System.err.println("KEY AWT TYPED ["+keyTyped+"]: "+prefix+", "+e); - } - } - - public String toString() { return prefix+"[pressed "+pressed+", typed "+keyTyped+"]"; } + public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+"]"; } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java index 832f5ae82..1d6d97a17 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java @@ -31,8 +31,6 @@ package com.jogamp.opengl.test.junit.util; public interface KeyEventCountAdapter extends InputEventCountAdapter { public int getKeyPressedCount(boolean autoRepeatOnly); - public int getKeyReleasedCount(boolean autoRepeatOnly); - - public int getKeyTypedCount(boolean autoRepeatOnly); + public int getKeyReleasedCount(boolean autoRepeatOnly); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java index f19169b42..88ed74a3f 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java @@ -39,8 +39,8 @@ import com.jogamp.newt.event.KeyEvent; public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { String prefix; - int keyPressed, keyReleased, keyTyped; - int keyPressedAR, keyReleasedAR, keyTypedAR; + int keyPressed, keyReleased; + int keyPressedAR, keyReleasedAR; boolean pressed; List queue = new ArrayList(); boolean verbose = true; @@ -57,7 +57,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { } public synchronized int getCount() { - return keyTyped; + return keyReleased; } public synchronized int getKeyPressedCount(boolean autoRepeatOnly) { @@ -68,10 +68,6 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { return autoRepeatOnly ? keyReleasedAR: keyReleased; } - public synchronized int getKeyTypedCount(boolean autoRepeatOnly) { - return autoRepeatOnly ? keyTypedAR: keyTyped; - } - public synchronized List getQueued() { return queue; } @@ -81,10 +77,8 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { } public synchronized void reset() { - keyTyped = 0; keyPressed = 0; keyReleased = 0; - keyTypedAR = 0; keyPressedAR = 0; keyReleasedAR = 0; pressed = false; @@ -115,18 +109,6 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { } } - @Override - public synchronized void keyTyped(KeyEvent e) { - keyTyped++; - if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { - keyTypedAR++; - } - queue.add(e); - if( verbose ) { - System.err.println("KEY NEWT TYPED ["+keyTyped+"]: "+prefix+", "+e); - } - } - - public String toString() { return prefix+"[pressed "+pressed+", typed "+keyTyped+"]"; } + public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+"]"; } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java index 1def57edf..990930994 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java @@ -104,11 +104,7 @@ public class NEWTKeyUtil { missCodes.add(new CodeEvent(c, codeSeg.description, e)); misses++; } - if( KeyEvent.isPrintableKey(c, false) ) { - evtIdx += 3; // w/ TYPED - } else { - evtIdx += 2; - } + evtIdx += 2; } } final boolean res = evtIdx == keyEvents.size() && 0 == missCodes.size(); @@ -133,16 +129,13 @@ public class NEWTKeyUtil { } } - @SuppressWarnings("deprecation") public static short getNextKeyEventType(KeyEvent e) { final int et = e.getEventType(); switch( et ) { case KeyEvent.EVENT_KEY_PRESSED: return KeyEvent.EVENT_KEY_RELEASED; case KeyEvent.EVENT_KEY_RELEASED: - return e.isPrintableKey() && !e.isAutoRepeat() ? KeyEvent.EVENT_KEY_TYPED : KeyEvent.EVENT_KEY_PRESSED; - case KeyEvent.EVENT_KEY_TYPED: - return KeyEvent.EVENT_KEY_PRESSED; + return KeyEvent.EVENT_KEY_PRESSED; default: Assert.assertTrue("Invalid event "+e, false); return 0; @@ -168,14 +161,12 @@ public class NEWTKeyUtil { * @param keyAdapter * @param expPressedCountSI number of single key press events * @param expReleasedCountSI number of single key release events - * @param expTypedCountSI number of single key types events, set to -1 to ignore * @param expPressedCountAR number of auto-repeat key press events * @param expReleasedCountAR number of auto-repeat key release events - * @param expTypedCountAR number of auto-repeat key types events, set to -1 to ignore */ public static void validateKeyAdapterStats(NEWTKeyAdapter keyAdapter, - int expPressedCountSI, int expReleasedCountSI, int expTypedCountSI, - int expPressedCountAR, int expReleasedCountAR, int expTypedCountAR) { + int expPressedCountSI, int expReleasedCountSI, + int expPressedCountAR, int expReleasedCountAR) { final int expPressReleaseCountSI = expPressedCountSI + expReleasedCountSI; final int expPressReleaseCountAR = expPressedCountAR + expReleasedCountAR; final int expPressReleaseCountALL = expPressReleaseCountSI + expPressReleaseCountAR; @@ -184,36 +175,25 @@ public class NEWTKeyUtil { final int keyPressedAR = keyAdapter.getKeyPressedCount(true); final int keyReleasedALL = keyAdapter.getKeyReleasedCount(false); final int keyReleasedAR = keyAdapter.getKeyReleasedCount(true); - final int keyTypedALL = keyAdapter.getKeyTypedCount(false); - final int keyTypedAR = keyAdapter.getKeyTypedCount(true); final int keyPressedSI = keyPressedALL-keyPressedAR; final int keyReleasedSI = keyReleasedALL-keyReleasedAR; - final int keyTypedSI = keyTypedALL-keyTypedAR; final int pressReleaseCountALL = keyPressedALL + keyReleasedALL; final int pressReleaseCountSI = keyPressedSI + keyReleasedSI; final int pressReleaseCountAR = keyPressedAR + keyReleasedAR; - System.err.println("Expec Single Press "+expPressedCountSI +", Release "+expReleasedCountSI +", Typed "+expTypedCountSI); - System.err.println("Expec AutoRp Press "+expPressedCountAR +", Release "+expReleasedCountAR +", Typed "+expTypedCountAR); + System.err.println("Expec Single Press "+expPressedCountSI +", Release "+expReleasedCountSI); + System.err.println("Expec AutoRp Press "+expPressedCountAR +", Release "+expReleasedCountAR); - System.err.println("Total Single Press "+keyPressedSI +", Release "+keyReleasedSI +", Typed "+keyTypedSI +", Events "+pressReleaseCountSI); - System.err.println("Total AutoRp Press "+keyPressedAR +", Release "+keyReleasedAR +", Typed "+keyTypedAR +", Events "+pressReleaseCountAR); - System.err.println("Total ALL Press "+keyPressedALL +", Release "+keyReleasedALL +", Typed "+keyTypedALL+", Events "+pressReleaseCountALL); + System.err.println("Total Single Press "+keyPressedSI +", Release "+keyReleasedSI +", Events "+pressReleaseCountSI); + System.err.println("Total AutoRp Press "+keyPressedAR +", Release "+keyReleasedAR +", Events "+pressReleaseCountAR); + System.err.println("Total ALL Press "+keyPressedALL +", Release "+keyReleasedALL +", Events "+pressReleaseCountALL); Assert.assertEquals("Internal Error: pressReleaseSI != pressReleaseALL - pressReleaseAR", pressReleaseCountSI, pressReleaseCountALL - pressReleaseCountAR); - Assert.assertEquals("Invalid: Has AR Typed events", 0, keyTypedAR); - if( 0 <= expTypedCountAR ) { - Assert.assertEquals("Invalid: Exp AR Typed events", 0, expTypedCountAR); - } - Assert.assertEquals("Key press count failure (SI)", expPressedCountSI, keyPressedSI); Assert.assertEquals("Key released count failure (SI)", expReleasedCountSI, keyReleasedSI); - if( 0 <= expTypedCountSI ) { - Assert.assertEquals("Key typed count failure (SI)", expTypedCountSI, keyTypedSI); - } Assert.assertEquals("Key press count failure (AR)", expPressedCountAR, keyPressedAR); Assert.assertEquals("Key released count failure (AR)", expReleasedCountAR, keyReleasedAR); @@ -224,6 +204,6 @@ public class NEWTKeyUtil { final List keyEvents = keyAdapter.getQueued(); Assert.assertEquals("Key pressRelease count failure (ALL) w/ list sum ", expPressReleaseCountALL, pressReleaseCountALL); - Assert.assertEquals("Key total count failure (ALL) w/ list size ", pressReleaseCountALL + keyTypedALL, keyEvents.size()); + Assert.assertEquals("Key total count failure (ALL) w/ list size ", pressReleaseCountALL, keyEvents.size()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/QuitAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/QuitAdapter.java index 59e243171..b5864e39c 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/QuitAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/QuitAdapter.java @@ -47,7 +47,10 @@ public class QuitAdapter extends WindowAdapter implements WindowListener, KeyLis } } - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if( enabled ) { if(e.getKeyChar()=='q') { System.err.println("QUIT Key "+Thread.currentThread()); @@ -56,6 +59,5 @@ public class QuitAdapter extends WindowAdapter implements WindowListener, KeyLis } } public void keyPressed(KeyEvent e) {} - public void keyReleased(KeyEvent e) {} } -- cgit v1.2.3 From bdfb74818aa224bd96a15f232f417e921e0d8f63 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 17 Jun 2013 10:00:23 +0200 Subject: Fix Bug 688: Removal of NEWT KeyEvent.EVENT_KEY_TYPED and KeyListener.keyTyped(KeyEvent) - Part2: API Documentation and Comments --- .../classes/com/jogamp/newt/event/KeyEvent.java | 24 +++++++++------------- .../jogamp/newt/driver/macosx/WindowDriver.java | 4 ++-- .../jogamp/newt/driver/windows/WindowDriver.java | 4 +--- .../jogamp/newt/driver/x11/WindowDriver.java | 3 --- .../jogamp/newt/swt/event/SWTNewtEventFactory.java | 1 - .../newt/event/TestNewtKeyEventAutoRepeatAWT.java | 7 +++---- .../junit/newt/event/TestNewtKeyEventOrderAWT.java | 1 - 7 files changed, 16 insertions(+), 28 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 683a5ca54..ec05a34ad 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -43,9 +43,8 @@ import com.jogamp.common.util.IntBitfield; *

    * * - * - * - * + * + * *
    #Event Type Constraints Notes
    1{@link #EVENT_KEY_PRESSED} excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys
    2{@link #EVENT_KEY_RELEASED} excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys
    3{@link #EVENT_KEY_TYPED} only for {@link #isPrintableKey() printable} and non {@link #isAutoRepeat() auto-repeat} keysDeprecated: Use {@link #EVENT_KEY_RELEASED} and apply constraints.
    1{@link #EVENT_KEY_PRESSED} excluding {@link #isAutoRepeat() auto-repeat}-{@link #isModifierKey() modifier} keys
    2{@link #EVENT_KEY_RELEASED} excluding {@link #isAutoRepeat() auto-repeat}-{@link #isModifierKey() modifier} keys
    *

    * In case the native platform does not @@ -58,27 +57,24 @@ import com.jogamp.common.util.IntBitfield; *

    * Auto-Repeat shall behave as follow: *

    -    P = pressed, R = released, T = typed
    +    P = pressed, R = released
         0 = normal, 1 = auto-repeat
     
    -    P(0), [ R(1), P(1), R(1), ..], R(0) T(0)    
    +    P(0), [ R(1), P(1), R(1), ..], R(0)    
      * 
    * The idea is if you mask out auto-repeat in your event listener - * or catch {@link #EVENT_KEY_TYPED typed} events only, - * you just get one long pressed P/R/T triple for {@link #isPrintableKey() printable} keys. - * {@link #isActionKey() Action} keys would produce one long pressed P/R tuple in case you mask out auto-repeat . + * you just get one long pressed P/R tuple for {@link #isPrintableKey() printable} and {@link #isActionKey() Action} keys. *

    *

    * {@link #isActionKey() Action} keys will produce {@link #EVENT_KEY_PRESSED pressed} * and {@link #EVENT_KEY_RELEASED released} events including {@link #isAutoRepeat() auto-repeat}. *

    *

    - * {@link #isPrintableKey() Printable} keys will produce {@link #EVENT_KEY_PRESSED pressed}, - * {@link #EVENT_KEY_RELEASED released} and {@link #EVENT_KEY_TYPED typed} events, the latter is excluded for {@link #isAutoRepeat() auto-repeat} events. + * {@link #isPrintableKey() Printable} keys will produce {@link #EVENT_KEY_PRESSED pressed} and {@link #EVENT_KEY_RELEASED released} events. *

    *

    - * {@link #isModifierKey() Modifier} keys will produce {@link #EVENT_KEY_PRESSED pressed} - * and {@link #EVENT_KEY_RELEASED released} events excluding {@link #isAutoRepeat() auto-repeat}. + * {@link #isModifierKey() Modifier} keys will produce {@link #EVENT_KEY_PRESSED pressed} and {@link #EVENT_KEY_RELEASED released} events + * excluding {@link #isAutoRepeat() auto-repeat}. * They will also influence subsequent event's {@link #getModifiers() modifier} bits while pressed. *

    * @@ -360,9 +356,9 @@ public class KeyEvent extends InputEvent private static final byte F_ACTION_MASK = 1 << 1; private static final byte F_PRINTABLE_MASK = 1 << 2; - /** A key has been pressed, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */ + /** A key has been pressed, excluding {@link #isAutoRepeat() auto-repeat}-{@link #isModifierKey() modifier} keys. */ public static final short EVENT_KEY_PRESSED = 300; - /** A key has been released, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */ + /** A key has been released, excluding {@link #isAutoRepeat() auto-repeat}-{@link #isModifierKey() modifier} keys. */ public static final short EVENT_KEY_RELEASED= 301; /** diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 6370782df..6aebf0410 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -423,8 +423,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl ", was: pressed "+isKeyPressed(keyCode)+", isModifierKeyCode "+isModifierKeyCode); } */ - // 1:1 Order: OSX and NEWT delivery order is PRESSED, RELEASED and TYPED - // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED + // OSX delivery order is PRESSED (t0), RELEASED (t1) and TYPED (t2) -> NEWT order: PRESSED (t0) and RELEASED (t1) + // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE key _before_ PRESSED switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: if( isKeyCodeTracked(keyCode) ) { diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index ad7e1e8f3..60fc3ec0f 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -288,7 +288,7 @@ public class WindowDriver extends WindowImpl { // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+ // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", printableKey "+KeyEvent.isPrintableKey(keyCode)+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); - // Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0), RELEASED (t1) and TYPED (t1) + // Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0) and RELEASED (t1) // Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0). switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: @@ -307,8 +307,6 @@ public class WindowDriver extends WindowImpl { super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar); } break; - // case KeyEvent.EVENT_KEY_TYPED: - // break; } } diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 69a09c1f9..2eb07e00b 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -287,9 +287,6 @@ public class WindowDriver extends WindowImpl { case KeyEvent.EVENT_KEY_RELEASED: super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); break; - - // case KeyEvent.EVENT_KEY_TYPED: - // break; } } } diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java index 1e99d1ef7..3782a1186 100644 --- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -56,7 +56,6 @@ public class SWTNewtEventFactory { case SWT.KeyDown: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED; case SWT.KeyUp: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED; - // case SWT.KeyXXX: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED; } return (short)0; } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java index f3a5c4aa9..fca1a4d93 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java @@ -68,20 +68,19 @@ import com.jogamp.opengl.test.junit.util.*; *
      *
    1. {@link #EVENT_KEY_PRESSED}
    2. *
    3. {@link #EVENT_KEY_RELEASED}
    4. - *
    5. {@link #EVENT_KEY_TYPED}
    6. *
    *

    *

    * Auto-Repeat shall behave as follow: *

    -    D = pressed, U = released, T = typed
    +    D = pressed, U = released
         0 = normal, 1 = auto-repeat
     
    -    D(0), [ U(1), T(1), D(1), U(1) T(1) ..], U(0) T(0)
    +    D(0), [ U(1), D(1), U(1), D(1) ..], U(0)
      * 
    * * The idea is if you mask out auto-repeat in your event listener - * you just get one long pressed key D/U/T triple. + * you just get one long pressed key D/U tuple. */ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { static int width, height; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java index 68ccecf6b..3a95eacae 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java @@ -65,7 +65,6 @@ import com.jogamp.opengl.test.junit.util.*; *
      *
    1. {@link #EVENT_KEY_PRESSED}
    2. *
    3. {@link #EVENT_KEY_RELEASED}
    4. - *
    5. {@link #EVENT_KEY_TYPED}
    6. *
    *

    */ -- cgit v1.2.3 From f2182cfbf4cf77ba3f53b5b3e1c53e9dd42691a5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 17 Jun 2013 12:59:24 +0200 Subject: Fix regression of 31e72d2f2d953352b2a8c83368039ecca8139d49: Modifier SHIFT needs to be recognized (-> horiz. scroll) --- src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 2eb07e00b..c752977a9 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -241,16 +241,17 @@ public class WindowDriver extends WindowImpl { } break; case MouseEvent.EVENT_MOUSE_RELEASED: + final boolean shiftPressed = 0 != ( modifiers & InputEvent.SHIFT_MASK ); switch(button) { case X11_WHEEL_ONE_UP_BUTTON: // vertical scroll up eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; button = 1; - rotationXYZ[1] = 1; + rotationXYZ[shiftPressed ? 0 : 1] = 1; break; case X11_WHEEL_ONE_DOWN_BUTTON: // vertical scroll down eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; button = 1; - rotationXYZ[1] = -1; + rotationXYZ[shiftPressed ? 0 : 1] = -1; break; case X11_WHEEL_TWO_UP_BUTTON: // horizontal scroll left eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; -- cgit v1.2.3 From 893cf0c8c32edf231dbf418d45d3181532d2402b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 18 Jun 2013 03:10:16 +0200 Subject: JOGLNewtApplet1Run: Defer 'newtCanvasAWT' creation and attachment to applet.start() (only once), working around 'OS X' CALayer positioning bug. The NewtCanvasAWT workaround for the 'OS X' CALayer positioning bug(*) may only work if parent is not only dislayable, but also visible. (*): Workaround resizes the component 2x, forcing a relayout. ++ RequestFocus after setVisibile(true). +++ Clear references to glWindow, newtCanvasAWT @ destroy. --- .../jogamp/newt/awt/applet/JOGLNewtApplet1Run.java | 33 ++++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java index d06aca039..529e8c5ab 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java @@ -94,9 +94,9 @@ import com.jogamp.newt.opengl.GLWindow; public class JOGLNewtApplet1Run extends Applet { public static final boolean DEBUG = JOGLNewtAppletBase.DEBUG; - GLWindow glWindow; - NewtCanvasAWT newtCanvasAWT; - JOGLNewtAppletBase base; + GLWindow glWindow = null; + NewtCanvasAWT newtCanvasAWT = null; + JOGLNewtAppletBase base = null; /** if valid glStandalone:=true (own window) ! */ int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE; boolean glStandalone = false; @@ -108,7 +108,7 @@ public class JOGLNewtApplet1Run extends Applet { if(!(this instanceof Container)) { throw new RuntimeException("This Applet is not a AWT Container"); } - Container container = (Container) this; + final Container container = (Container) this; String glEventListenerClazzName=null; String glProfileName=null; @@ -209,13 +209,6 @@ public class JOGLNewtApplet1Run extends Applet { addKeyListener((KeyListener)glEventListener); } } - if(glStandalone) { - newtCanvasAWT = null; - } else { - newtCanvasAWT = new NewtCanvasAWT(glWindow); - container.add(newtCanvasAWT, BorderLayout.CENTER); - container.validate(); - } } catch (Throwable t) { throw new RuntimeException(t); } @@ -226,11 +219,19 @@ public class JOGLNewtApplet1Run extends Applet { public void start() { if(DEBUG) { - System.err.println("JOGLNewtApplet1Run.start() START"); + System.err.println("JOGLNewtApplet1Run.start() START (isVisible "+isVisible()+", isDisplayable "+isDisplayable()+")"); + } + if( null == newtCanvasAWT && !glStandalone) { + newtCanvasAWT = new NewtCanvasAWT(glWindow); + this.add(newtCanvasAWT, BorderLayout.CENTER); + this.validate(); } - this.validate(); this.setVisible(true); - + if( null != newtCanvasAWT ) { + newtCanvasAWT.requestFocus(); + } else { + glWindow.requestFocus(); + } final java.awt.Point p0 = this.getLocationOnScreen(); if(glStandalone) { glWindow.setSize(glWidth, glHeight); @@ -271,12 +272,14 @@ public class JOGLNewtApplet1Run extends Applet { System.err.println("JOGLNewtApplet1Run.destroy() START"); } glWindow.setVisible(false); // hide 1st - if(!glStandalone) { + if( null != newtCanvasAWT ) { glWindow.reparentWindow(null); // get out of newtCanvasAWT this.remove(newtCanvasAWT); // remove newtCanvasAWT } base.destroy(); // destroy glWindow unrecoverable base=null; + glWindow=null; + newtCanvasAWT=null; if(DEBUG) { System.err.println("JOGLNewtApplet1Run.destroy() END"); } -- cgit v1.2.3 From e3beec5a0b4f696e458e8cc1d653ce9dc628e137 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 18 Jun 2013 04:01:29 +0200 Subject: NewtCanvasAWT: Issue 'setFocusable(..)' at configureNewtChild(..) --- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 692741a88..65b44b141 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -533,6 +533,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); keyboardFocusManager.addPropertyChangeListener("focusOwner", focusPropertyChangeListener); + // force this AWT Canvas to be focus-able, + // since this it is completely covered by the newtChild (z-order). + setFocusable(true); if(isOnscreen) { // onscreen newt child needs to fwd AWT focus newtChild.setKeyboardFocusHandler(newtFocusTraversalKeyListener); @@ -545,6 +548,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.removeWindowListener(clearAWTMenusOnNewtFocus); newtChild.setFocusAction(null); newtChild.setDefaultCloseOperation(newtChildCloseOp); + setFocusable(false); } } } @@ -581,9 +585,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener - // force this AWT Canvas to be focus-able, - // since this it is completely covered by the newtChild (z-order). - setFocusable(true); if(DEBUG) { System.err.println("NewtCanvasAWT.attachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); } -- cgit v1.2.3 From de67cde91cb99e3a1a3b8182b119671d112c553b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 18 Jun 2013 04:06:27 +0200 Subject: Refine 893cf0c8c32edf231dbf418d45d3181532d2402b: Partial revert and issue forceRelayout at end of applet.start(); Cleanup AWTKeyAdapter. Refine 893cf0c8c32edf231dbf418d45d3181532d2402b: Partial revert and issue forceRelayout at end of applet.start(); - Seems the workaround of OSX CALayer positioning bug is timing dependent, i.e. stopped working when disabled DEBUG output. - Move NewtCanvasAWT creation and attachment back to init() - Issue extra forceRelayout (if OSX) at end of start() .. works 'most of the time'. Cleanup AWTKeyAdapter: Adapt code style of keyPressed() to keyReleased(). --- .../jogamp/newt/awt/applet/JOGLNewtApplet1Run.java | 26 +++++++++++++--------- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 9 +++++--- .../com/jogamp/newt/event/awt/AWTKeyAdapter.java | 7 +++--- 3 files changed, 25 insertions(+), 17 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java index 529e8c5ab..e8cd71514 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java @@ -42,6 +42,7 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; +import com.jogamp.common.os.Platform; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; @@ -99,7 +100,6 @@ public class JOGLNewtApplet1Run extends Applet { JOGLNewtAppletBase base = null; /** if valid glStandalone:=true (own window) ! */ int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE; - boolean glStandalone = false; public void init() { if(DEBUG) { @@ -147,7 +147,7 @@ public class JOGLNewtApplet1Run extends Applet { if(null==glEventListenerClazzName) { throw new RuntimeException("No applet parameter 'gl_event_listener_class'"); } - glStandalone = Integer.MAX_VALUE>glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight; + final boolean glStandalone = Integer.MAX_VALUE>glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight; if(DEBUG) { System.err.println("JOGLNewtApplet1Run Configuration:"); System.err.println("glStandalone: "+glStandalone); @@ -209,6 +209,11 @@ public class JOGLNewtApplet1Run extends Applet { addKeyListener((KeyListener)glEventListener); } } + if( !glStandalone ) { + newtCanvasAWT = new NewtCanvasAWT(glWindow); + container.add(newtCanvasAWT, BorderLayout.CENTER); + container.validate(); + } } catch (Throwable t) { throw new RuntimeException(t); } @@ -221,19 +226,13 @@ public class JOGLNewtApplet1Run extends Applet { if(DEBUG) { System.err.println("JOGLNewtApplet1Run.start() START (isVisible "+isVisible()+", isDisplayable "+isDisplayable()+")"); } - if( null == newtCanvasAWT && !glStandalone) { - newtCanvasAWT = new NewtCanvasAWT(glWindow); - this.add(newtCanvasAWT, BorderLayout.CENTER); - this.validate(); - } this.setVisible(true); + final java.awt.Point p0 = this.getLocationOnScreen(); if( null != newtCanvasAWT ) { + newtCanvasAWT.setFocusable(true); newtCanvasAWT.requestFocus(); } else { glWindow.requestFocus(); - } - final java.awt.Point p0 = this.getLocationOnScreen(); - if(glStandalone) { glWindow.setSize(glWidth, glHeight); glWindow.setPosition(p0.x+glXd, p0.y+glYd); } @@ -252,6 +251,13 @@ public class JOGLNewtApplet1Run extends Applet { System.err.println("GLWindow: "+glWindow); } base.start(); + if( null != newtCanvasAWT && Platform.OSType.MACOS == Platform.getOSType() && newtCanvasAWT.isOffscreenLayerSurfaceEnabled() ) { + // force relayout + final int cW = newtCanvasAWT.getWidth(); + final int cH = newtCanvasAWT.getHeight(); + newtCanvasAWT.setSize(cW+1, cH+1); + newtCanvasAWT.setSize(cW, cH); + } if(DEBUG) { System.err.println("JOGLNewtApplet1Run.start() END"); } diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 35199dc82..25ddfad48 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -286,9 +286,8 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { // *********************************************************************************** // *********************************************************************************** - public void keyPressed(KeyEvent e) { - } - public void keyReleased(KeyEvent e) { + @Override + public void keyPressed(KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; } @@ -307,5 +306,9 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { } } } + + @Override + public void keyReleased(KeyEvent e) { + } } diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java index 1edef347b..bef2e5d0f 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java @@ -71,12 +71,11 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe @Override public void keyReleased(java.awt.event.KeyEvent e) { - com.jogamp.newt.event.KeyEvent keyReleaseEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow); + final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow); if(null!=newtListener) { - final com.jogamp.newt.event.KeyListener newtKeyListener = (com.jogamp.newt.event.KeyListener)newtListener; - newtKeyListener.keyReleased(keyReleaseEvt); + ((com.jogamp.newt.event.KeyListener)newtListener).keyReleased(event); } else { - enqueueEvent(false, keyReleaseEvt); + enqueueEvent(false, event); } } -- cgit v1.2.3 From e2c641bfbf9c2796b02edd3ef15444ce58b42be0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 23 Jun 2013 01:01:23 +0200 Subject: NEWT/X11: Proper static initSingleton() sequence. --- src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java | 6 ++---- src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java | 3 +++ src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 4fe025ec4..88d06f69c 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -57,10 +57,8 @@ public class DisplayDriver extends DisplayImpl { } } - public static void initSingleton() { - // just exist to ensure static init has been run - } - + /** Ensure static init has been run. */ + /* pp */static void initSingleton() { } public DisplayDriver() { } diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index b8b13939b..e1373bba5 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -60,6 +60,9 @@ public class ScreenDriver extends ScreenImpl { DisplayDriver.initSingleton(); } + /** Ensure static init has been run. */ + /* pp */static void initSingleton() { } + public ScreenDriver() { } diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index c752977a9..786587d65 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -59,7 +59,7 @@ public class WindowDriver extends WindowImpl { private static final int X11_WHEEL_TWO_DOWN_BUTTON = 7; static { - DisplayDriver.initSingleton(); + ScreenDriver.initSingleton(); } public WindowDriver() { -- cgit v1.2.3 From e5df5210e059ef597c1c05942cf7dcc0327730cd Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 23 Jun 2013 01:02:44 +0200 Subject: GLWindow: Mention GLStateKeeper's GL state preservation in API doc --- src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 1500d48e6..345d92bc1 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -79,11 +79,16 @@ import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.WindowUpdateEvent; import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.GLStateKeeper; /** * An implementation of {@link GLAutoDrawable} and {@link Window} interface, * using a delegated {@link Window} instance, which may be an aggregation (lifecycle: created and destroyed). *

    + * This implementation supports {@link GLStateKeeper GL state preservation}, + * hence {@link #isGLStatePreservationSupported()} returns true. + *

    + *

    * This implementation does not make the OpenGL context current
    * before calling the various input EventListener callbacks, ie {@link com.jogamp.newt.event.MouseListener} etc.
    * This design decision is made in favor of a more performant and simplified @@ -433,8 +438,8 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind protected class GLLifecycleHook implements WindowImpl.LifecycleHook { @Override - public void preserveGLStateAtDestroy() { - GLWindow.this.preserveGLStateAtDestroy(true); + public void preserveGLStateAtDestroy(boolean value) { + GLWindow.this.preserveGLStateAtDestroy(value); } @Override @@ -579,6 +584,12 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } } + /** + * {@inheritDoc} + *

    + * GLWindow supports GL state preservation, hence returns true. + *

    + */ @Override public final boolean isGLStatePreservationSupported() { return true; } -- cgit v1.2.3 From 2d32b056c7b1b6b3d071d79fb4c2d4e9113b59d5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 23 Jun 2013 01:21:30 +0200 Subject: Fix Bug 761 (part 2/2): NEWT registers one customShutdownHook @ NativeWindowFactory.shutdownHook head, allowing proper resource cleanup. 1 WindowImpl.shutdownAll(): - For all instances: - mark invalid (causes any user thread to disregard the window) 2 ScreenImpl.shutdownAll(): - Removed own shutdown-hook! - For all instances: - Reset ScreenMonitorState 3 DisplayImpl.shutdownAll(): - For all instances: - Remove EDT - closeNativeImpl Manually tested on X11 w/ NV and ATI Catalyst (fglrx) - DFLAGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" - java $DFLAGS com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -time 2000 -sysExit testExit - valid arguments for sysExit: testExit, testError, displayExit, displayError --- make/scripts/tests.sh | 6 +-- src/newt/classes/com/jogamp/newt/Display.java | 2 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 45 ++++++++++++++++-- src/newt/classes/jogamp/newt/ScreenImpl.java | 45 ++++++++---------- src/newt/classes/jogamp/newt/WindowImpl.java | 53 ++++++++++++++++++++-- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 46 +++++++++++++++++++ 6 files changed, 158 insertions(+), 39 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 46d7876d3..97fe1d2c9 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -109,7 +109,7 @@ function jrun() { #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" - #D_ARGS="-Dnativewindow.debug.X11Util" + D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" @@ -286,7 +286,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -307,7 +307,7 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 993aa33eb..d6ddd9613 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -178,7 +178,7 @@ public abstract class Display { public abstract void dispatchMessages(); // Global Displays - protected static ArrayList displayList = new ArrayList(); + protected static final ArrayList displayList = new ArrayList(); protected static int displaysActive = 0; public static void dumpDisplayList(String prefix) { diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index d4842ba2f..3edb532db 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -45,10 +45,24 @@ import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; public abstract class DisplayImpl extends Display { private static int serialno = 1; + static { + NativeWindowFactory.addCustomShutdownHook(true /* head */, new Runnable() { + public void run() { + WindowImpl.shutdownAll(); + ScreenImpl.shutdownAll(); + DisplayImpl.shutdownAll(); + } + }); + } + + /** Ensure static init has been run. */ + /* pp */static void initSingleton() { } + private static Class getDisplayClass(String type) throws ClassNotFoundException { @@ -232,11 +246,10 @@ public abstract class DisplayImpl extends Display { if(DEBUG) { System.err.println("Display.destroy(): "+this+" "+getThreadName()); } - final AbstractGraphicsDevice f_aDevice = aDevice; final DisplayImpl f_dpy = this; - removeEDT( new Runnable() { + removeEDT( new Runnable() { // blocks! public void run() { - if ( null != f_aDevice ) { + if ( null != aDevice ) { f_dpy.closeNativeImpl(); } } @@ -247,6 +260,32 @@ public abstract class DisplayImpl extends Display { dumpDisplayList("Display.destroy("+getFQName()+") END"); } } + + /** Maybe utilized at a shutdown hook, impl. does not synchronize, however the EDT removal blocks. */ + /* pp */ static final void shutdownAll() { + final int dCount = displayList.size(); + if(DEBUG) { + dumpDisplayList("Display.shutdownAll "+dCount+" instances, on thread "+getThreadName()); + } + for(int i=0; i0; i++) { // be safe .. + final DisplayImpl d = (DisplayImpl) displayList.remove(0); + if(0 < displaysActive) { + displaysActive--; + } + if(DEBUG) { + System.err.println("Display.shutdownAll["+(i+1)+"/"+dCount+"]: "+d); + } + d.removeEDT( new Runnable() { + public void run() { + if ( null != d.getGraphicsDevice() ) { + d.closeNativeImpl(); + } + } + } ); + d.aDevice = null; + d.refCount=0; + } + } public synchronized final int addReference() { if(DEBUG) { diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 7edf7b63a..f63d1499e 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -34,8 +34,6 @@ package jogamp.newt; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -64,6 +62,13 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { public static final int default_sm_rate = 60; public static final int default_sm_rotation = 0; + static { + DisplayImpl.initSingleton(); + } + + /** Ensure static init has been run. */ + /* pp */static void initSingleton() { } + protected DisplayImpl display; protected int screen_idx; protected String fqname; @@ -77,15 +82,6 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { private long tCreated; // creationTime - static { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - registerShutdownHook(); - return null; - } - }); - } - private static Class getScreenClass(String type) throws ClassNotFoundException { final Class screenClass = NewtFactory.getCustomClass(type, "ScreenDriver"); @@ -660,23 +656,18 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { ScreenMonitorState.unmapScreenMonitorStateUnlocked(getFQName()); } } - private static final void shutdownAll() { - for(int i=0; i < screenList.size(); i++) { - ((ScreenImpl)screenList.get(i)).shutdown(); - } - } - private static synchronized void registerShutdownHook() { - final Thread shutdownHook = new Thread(new Runnable() { - public void run() { - ScreenImpl.shutdownAll(); - } - }); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - Runtime.getRuntime().addShutdownHook(shutdownHook); - return null; + /** pp */ static final void shutdownAll() { + final int sCount = screenList.size(); + if(DEBUG) { + System.err.println("Screen.shutdownAll "+sCount+" instances, on thread "+Display.getThreadName()); + } + for(int i=0; i0; i++) { // be safe .. + final ScreenImpl s = (ScreenImpl) screenList.remove(0); + if(DEBUG) { + System.err.println("Screen.shutdownAll["+(i+1)+"/"+sCount+"]: "+s); } - }); + s.shutdown(); + } } } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index dca287c6b..1ac97b07c 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -82,6 +82,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer { public static final boolean DEBUG_TEST_REPARENT_INCOMPATIBLE = Debug.isPropertyDefined("newt.test.Window.reparent.incompatible", true); + protected static final ArrayList windowList = new ArrayList(); + + static { + ScreenImpl.initSingleton(); + } + + /** Maybe utilized at a shutdown hook, impl. does not synchronize, however the Window destruction and EDT removal blocks. */ + public static final void shutdownAll() { + final int wCount = windowList.size(); + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.shutdownAll "+wCount+" instances, on thread "+getThreadName()); + } + for(int i=0; i0; i++) { // be safe .. + final WindowImpl w = windowList.remove(0); + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.shutdownAll["+(i+1)+"/"+wCount+"]: "+toHexString(w.getWindowHandle())); + } + w.markInvalid(); + } + } + /** Timeout of queued events (repaint and resize) */ static final long QUEUED_EVENT_TO = 1200; // ms @@ -186,6 +207,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer window.screen = (ScreenImpl) screen; window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable(); window.instantiationFinished(); + synchronized( windowList ) { + windowList.add(window); + } return window; } catch (Throwable t) { t.printStackTrace(); @@ -207,12 +231,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer WindowImpl window = (WindowImpl) ReflectionUtil.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ; window.screen = (ScreenImpl) screen; window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable(); + window.instantiationFinished(); + synchronized( windowList ) { + windowList.add(window); + } return window; } catch (Throwable t) { throw new NativeWindowException(t); } } + /** Fast invalidation of instance w/o any blocking function call. */ + private final void markInvalid() { + setWindowHandle(0); + visible = false; + fullscreen = false; + fullscreenMonitors = null; + fullscreenUseMainMonitor = true; + hasFocus = false; + parentWindowHandle = 0; + } + protected final void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg) { config = cfg; } @@ -233,9 +272,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** * Notifies the receiver to preserve resources (GL, ..) - * for the next destroy*() calls (only). + * for the next destroy*() calls (only), if supported and if value is true, otherwise clears preservation flag. + * @param value true to set the one-shot preservation if supported, otherwise clears it. */ - void preserveGLStateAtDestroy(); + void preserveGLStateAtDestroy(boolean value); /** * Invoked before Window destroy action, @@ -995,13 +1035,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public void destroy() { + synchronized( windowList ) { + windowList.remove(this); + } visible = false; // Immediately mark synchronized visibility flag, avoiding possible recreation runOnEDTIfAvail(true, destroyAction); } protected void destroy(boolean preserveResources) { - if( preserveResources && null != WindowImpl.this.lifecycleHook ) { - WindowImpl.this.lifecycleHook.preserveGLStateAtDestroy(); + if( null != lifecycleHook ) { + lifecycleHook.preserveGLStateAtDestroy( preserveResources ); } destroy(); } @@ -1108,7 +1151,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } // Destroy this window and use parent's Screen. // It may be created properly when the parent is made visible. - destroy(false); + destroy( false ); setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); operation = ReparentOperation.ACTION_NATIVE_CREATION_PENDING; } else if(newParentWindow != getParent()) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 0756399c1..a876b5c96 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -90,6 +90,8 @@ public class TestGearsES2NEWT extends UITestCase { static boolean mainRun = false; static boolean exclusiveContext = false; static boolean useAnimator = true; + static enum SysExit { none, testExit, testError, displayExit, displayError }; + static SysExit sysExit = SysExit.none; @BeforeClass public static void initClass() { @@ -272,6 +274,36 @@ public class TestGearsES2NEWT extends UITestCase { Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread()); } + if( SysExit.displayError == sysExit || SysExit.displayExit == sysExit ) { + glWindow.addGLEventListener(new GLEventListener() { + + @Override + public void init(GLAutoDrawable drawable) {} + + @Override + public void dispose(GLAutoDrawable drawable) { } + + @Override + public void display(GLAutoDrawable drawable) { + final GLAnimatorControl anim = drawable.getAnimator(); + if( null != anim && anim.isAnimating() ) { + if( anim.getTotalFPSDuration() >= duration/2 ) { + if( SysExit.displayError == sysExit ) { + throw new Error("test error send from GLEventListener"); + } else if ( SysExit.displayExit == sysExit ) { + System.err.println("exit(0) send from GLEventListener"); + System.exit(0); + } + } + } else { + System.exit(0); + } + } + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + } + glWindow.setVisible(true); if( useAnimator ) { animator.setUpdateFPSFrames(60, showFPS ? System.err : null); @@ -296,6 +328,16 @@ public class TestGearsES2NEWT extends UITestCase { while(!quitAdapter.shouldQuit() && t1-t0= duration/2 ) { + if( SysExit.testError == sysExit || SysExit.testExit == sysExit ) { + if( SysExit.testError == sysExit ) { + throw new Error("test error send from test thread"); + } else if ( SysExit.testExit == sysExit ) { + System.err.println("exit(0) send from test thread"); + System.exit(0); + } + } + } } if( useAnimator ) { @@ -429,6 +471,9 @@ public class TestGearsES2NEWT extends UITestCase { loops = MiscUtils.atoi(args[i], 1); } else if(args[i].equals("-loop-shutdown")) { loop_shutdown = true; + } else if(args[i].equals("-sysExit")) { + i++; + sysExit = SysExit.valueOf(args[i]); } } wsize = new Dimension(w, h); @@ -458,6 +503,7 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("swapInterval "+swapInterval); System.err.println("exclusiveContext "+exclusiveContext); System.err.println("useAnimator "+useAnimator); + System.err.println("sysExitWithin "+sysExit); if(waitForKey) { UITestCase.waitForKey("Start"); -- cgit v1.2.3 From 70bf3a4ec44504b86294a332255aaae8d2e86bf4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 23 Jun 2013 18:55:21 +0200 Subject: Fix NewtCanvasAWT focus traversal for Java7: All unit tests fail w/ Java7, i.e. AWT Component's transferFocus() does nothing if component does not hold the focus. .. this seems to be violating the AWT 'spec' .. however. Workaround: Request focus before transfering it to the next/previous element. --- make/scripts/tests.sh | 9 ++++----- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 12 ++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 97fe1d2c9..eb88ba3ab 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -109,7 +109,7 @@ function jrun() { #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" - D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" + #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" @@ -181,7 +181,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -286,7 +286,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -513,7 +513,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* @@ -523,7 +523,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* #testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* #testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 65b44b141..e5db8fd14 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -223,16 +223,24 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final Set bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); if(fwdKeys.contains(ks)) { if(DEBUG) { - System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()); + System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()); } // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. + if(!hasFocus()) { + // Acquire the AWT focus 1st for proper AWT traversal + NewtCanvasAWT.super.requestFocus(); + } NewtCanvasAWT.this.transferFocus(); suppress = true; } else if(bwdKeys.contains(ks)) { if(DEBUG) { - System.err.println("NewtCanvasAWT.focusKey (bwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()); + System.err.println("NewtCanvasAWT.focusKey (bwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()); } // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. + if(!hasFocus()) { + // Acquire the AWT focus 1st for proper AWT traversal + NewtCanvasAWT.super.requestFocus(); + } NewtCanvasAWT.this.transferFocusBackward(); suppress = true; } -- cgit v1.2.3 From cb7118fc875b6722803e4b11d5681671962a8d3a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 23 Jun 2013 20:15:38 +0200 Subject: Fix NewtCanvasAWT focus traversal for Java7 (Take 2): Commit 70bf3a4ec44504b86294a332255aaae8d2e86bf4 was not sufficient. Commit 70bf3a4ec44504b86294a332255aaae8d2e86bf4 did not work out on Windows. Solution now gathers the next or previous 'to be focused' component, using the FocusTraversalPolicy of the visible/focusable/enabled container. Then we simply request it's focus. Works w/ Java7 on Linux and Windows. --- make/scripts/tests-win.bat | 4 +-- make/scripts/tests-x64-dbg.bat | 3 +- .../classes/jogamp/nativewindow/awt/AWTMisc.java | 39 ++++++++++++++++++++++ .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 19 ++++------- 4 files changed, 50 insertions(+), 15 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index bcec0c5b6..bdef9cc10 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -55,7 +55,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedCon REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -84,7 +84,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenti REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index a370ebfc8..cb40125f2 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -27,7 +27,7 @@ REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" REM set D_ARGS="-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLSLCode" -set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper" "-Djogamp.debug.NativeLibrary" "-Djogamp.debug.NativeLibrary.Lookup" "-Djogamp.debug.JNILibLoader" "-Djogamp.debug.TempJarCache" "-Djogamp.debug.JarUtil" +REM set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper" "-Djogamp.debug.NativeLibrary" "-Djogamp.debug.NativeLibrary.Lookup" "-Djogamp.debug.JNILibLoader" "-Djogamp.debug.TempJarCache" "-Djogamp.debug.JarUtil" REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.NativeLibrary=true" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.ExtensionAvailabilityCache" "-Djogamp.debug.ProcAddressHelper=true" @@ -41,6 +41,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Dnewt.debug.Window" +set D_ARGS="-Dnewt.debug.Window.KeyEvent" "-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index d77cd75ef..2524f107a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -27,6 +27,7 @@ */ package jogamp.nativewindow.awt; +import java.awt.FocusTraversalPolicy; import java.awt.Window; import java.awt.Component; import java.awt.Container; @@ -68,6 +69,44 @@ public class AWTMisc { return (Container) c; } + public static Component getNextFocus(Component comp) { + Container focusContainer = comp.getFocusCycleRootAncestor(); + while ( focusContainer != null && + ( !focusContainer.isShowing() || !focusContainer.isFocusable() || !focusContainer.isEnabled() ) ) + { + comp = focusContainer; + focusContainer = comp.getFocusCycleRootAncestor(); + } + Component next = null; + if (focusContainer != null) { + final FocusTraversalPolicy policy = focusContainer.getFocusTraversalPolicy(); + next = policy.getComponentAfter(focusContainer, comp); + if (next == null) { + next = policy.getDefaultComponent(focusContainer); + } + } + return next; + } + + public static Component getPrevFocus(Component comp) { + Container focusContainer = comp.getFocusCycleRootAncestor(); + while ( focusContainer != null && + ( !focusContainer.isShowing() || !focusContainer.isFocusable() || !focusContainer.isEnabled() ) ) + { + comp = focusContainer; + focusContainer = comp.getFocusCycleRootAncestor(); + } + Component prev = null; + if (focusContainer != null) { + final FocusTraversalPolicy policy = focusContainer.getFocusTraversalPolicy(); + prev = policy.getComponentBefore(focusContainer, comp); + if (prev == null) { + prev = policy.getDefaultComponent(focusContainer); + } + } + return prev; + } + /** * Issue this when your non AWT toolkit gains focus to clear AWT menu path */ diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index e5db8fd14..dd8939e43 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -31,6 +31,7 @@ package com.jogamp.newt.awt; import java.awt.AWTKeyStroke; import java.awt.Canvas; +import java.awt.Component; import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.KeyboardFocusManager; @@ -222,26 +223,20 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final Set fwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); final Set bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); if(fwdKeys.contains(ks)) { + final Component nextFocus = AWTMisc.getNextFocus(NewtCanvasAWT.this); if(DEBUG) { - System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()); + System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()+", nextFocus "+nextFocus); } // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. - if(!hasFocus()) { - // Acquire the AWT focus 1st for proper AWT traversal - NewtCanvasAWT.super.requestFocus(); - } - NewtCanvasAWT.this.transferFocus(); + nextFocus.requestFocus(); suppress = true; } else if(bwdKeys.contains(ks)) { + final Component prevFocus = AWTMisc.getPrevFocus(NewtCanvasAWT.this); if(DEBUG) { - System.err.println("NewtCanvasAWT.focusKey (bwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()); + System.err.println("NewtCanvasAWT.focusKey (bwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()+", prevFocus "+prevFocus); } // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. - if(!hasFocus()) { - // Acquire the AWT focus 1st for proper AWT traversal - NewtCanvasAWT.super.requestFocus(); - } - NewtCanvasAWT.this.transferFocusBackward(); + prevFocus.requestFocus(); suppress = true; } } -- cgit v1.2.3 From 62f9525a9caba51fc4484c2ab47d64b516dc9d43 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Jun 2013 06:50:40 +0200 Subject: Refine cb7118fc875b6722803e4b11d5681671962a8d3a: Unify get next/prev focus component method. --- .../classes/jogamp/nativewindow/awt/AWTMisc.java | 31 +++++++--------------- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 4 +-- 2 files changed, 12 insertions(+), 23 deletions(-) (limited to 'src/newt/classes') diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index 2524f107a..66be82a44 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -69,7 +69,15 @@ public class AWTMisc { return (Container) c; } - public static Component getNextFocus(Component comp) { + /** + * Traverse to the next forward or backward component using the + * container's FocusTraversalPolicy. + * + * @param comp the assumed current focuse component + * @param forward if true, returns the next focus component, otherwise the previous one. + * @return + */ + public static Component getNextFocus(Component comp, boolean forward) { Container focusContainer = comp.getFocusCycleRootAncestor(); while ( focusContainer != null && ( !focusContainer.isShowing() || !focusContainer.isFocusable() || !focusContainer.isEnabled() ) ) @@ -80,7 +88,7 @@ public class AWTMisc { Component next = null; if (focusContainer != null) { final FocusTraversalPolicy policy = focusContainer.getFocusTraversalPolicy(); - next = policy.getComponentAfter(focusContainer, comp); + next = forward ? policy.getComponentAfter(focusContainer, comp) : policy.getComponentBefore(focusContainer, comp); if (next == null) { next = policy.getDefaultComponent(focusContainer); } @@ -88,25 +96,6 @@ public class AWTMisc { return next; } - public static Component getPrevFocus(Component comp) { - Container focusContainer = comp.getFocusCycleRootAncestor(); - while ( focusContainer != null && - ( !focusContainer.isShowing() || !focusContainer.isFocusable() || !focusContainer.isEnabled() ) ) - { - comp = focusContainer; - focusContainer = comp.getFocusCycleRootAncestor(); - } - Component prev = null; - if (focusContainer != null) { - final FocusTraversalPolicy policy = focusContainer.getFocusTraversalPolicy(); - prev = policy.getComponentBefore(focusContainer, comp); - if (prev == null) { - prev = policy.getDefaultComponent(focusContainer); - } - } - return prev; - } - /** * Issue this when your non AWT toolkit gains focus to clear AWT menu path */ diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index dd8939e43..6ba7a1a61 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -223,7 +223,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final Set fwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); final Set bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); if(fwdKeys.contains(ks)) { - final Component nextFocus = AWTMisc.getNextFocus(NewtCanvasAWT.this); + final Component nextFocus = AWTMisc.getNextFocus(NewtCanvasAWT.this, true /* forward */); if(DEBUG) { System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()+", nextFocus "+nextFocus); } @@ -231,7 +231,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto nextFocus.requestFocus(); suppress = true; } else if(bwdKeys.contains(ks)) { - final Component prevFocus = AWTMisc.getPrevFocus(NewtCanvasAWT.this); + final Component prevFocus = AWTMisc.getNextFocus(NewtCanvasAWT.this, false /* forward */); if(DEBUG) { System.err.println("NewtCanvasAWT.focusKey (bwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()+", prevFocus "+prevFocus); } -- cgit v1.2.3 From 0cb4baed987223893d7f68e5f5cbb96987a39cf6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Jun 2013 19:28:05 +0200 Subject: NEWT Windows WindowDriver: Suppress LOCK_SURFACE_CHANGED, no semantics in GLDrawable on Windows. FIXME: Validate against EGL surface creation: ANGLE uses HWND -> fine! --- src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 60fc3ec0f..7a8e683af 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -79,6 +79,11 @@ public class WindowDriver extends WindowImpl { } hmon = MonitorFromWindow0(hWnd); + // Let's not trigger on HDC change, GLDrawableImpl.'s destroy/create is a nop here anyways. + // FIXME: Validate against EGL surface creation: ANGLE uses HWND -> fine! + return LOCK_SUCCESS; + + /** if( hdc_old == hdc ) { return LOCK_SUCCESS; } @@ -86,7 +91,7 @@ public class WindowDriver extends WindowImpl { System.err.println("WindowsWindow: surface change "+toHexString(hdc_old)+" -> "+toHexString(hdc)); // Thread.dumpStack(); } - return LOCK_SURFACE_CHANGED; + return LOCK_SURFACE_CHANGED; */ } @Override -- cgit v1.2.3 From 415f5c29ffae7cf5a26737da38e31cb84b652539 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Jun 2013 19:47:06 +0200 Subject: NEWT: Don't invoke external keyboardFocusHandler for auto-repeat keys (NewtCanvasAWT, ..) .. otherwise an auto repeated key would cause fast focus traversal, not intended. --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- src/newt/classes/com/jogamp/newt/Window.java | 6 +++++- src/newt/classes/jogamp/newt/WindowImpl.java | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 954d1663d..ed0241035 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -87,7 +87,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenti REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* @@ -106,7 +106,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 70139b6c1..c50877d78 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -476,7 +476,7 @@ function testawtswt() { # #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug -testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* @@ -513,7 +513,7 @@ testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* # #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 0bebf330a..f63c03738 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -406,7 +406,11 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * Sets a {@link KeyListener} allowing focus traversal with a covered window toolkit like AWT. *

    * The {@link KeyListener} methods are invoked prior to all other {@link KeyListener}'s - * allowing to suppress the {@link KeyEvent} via the {@link InputEvent#consumedTag}. + * allowing to suppress the {@link KeyEvent} via the {@link InputEvent#consumedTag} + * and to perform focus traversal with a 3rd party toolkit. + *

    + *

    + * The {@link KeyListener} methods are not invoked for {@link KeyEvent#isAutoRepeat() auto-repeat} events. *

    * @param l */ diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 1ac97b07c..6787f0ab3 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2535,15 +2535,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected void consumeKeyEvent(KeyEvent e) { boolean consumedE = false; - if(null != keyboardFocusHandler) { + if( null != keyboardFocusHandler && !e.isAutoRepeat() ) { consumedE = propagateKeyEvent(e, keyboardFocusHandler); if(DEBUG_KEY_EVENT) { - System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumedE); + System.err.println("consumeKeyEvent(kfh): "+e+", keyboardFocusHandler consumed: "+consumedE); } } if(DEBUG_KEY_EVENT) { if( !consumedE ) { - System.err.println("consumeKeyEvent: "+e); + System.err.println("consumeKeyEvent(usr): "+e); } } for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) { -- cgit v1.2.3 From a584e5dd4b40afec3cc04e1ce4abe3eb2f86e04c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 25 Jun 2013 07:02:48 +0200 Subject: NEWT: EDTUtil.invokeStop(..) gets 'wait' argument, allowing non-blocking shutdown. DisplayImpl.shutdownAll(): Don't block. --- src/newt/classes/com/jogamp/newt/util/EDTUtil.java | 14 ++++++++++---- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 4 ++-- src/newt/classes/jogamp/newt/DisplayImpl.java | 18 ++++++++++++++---- .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 4 ++-- src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java | 4 ++-- 5 files changed, 30 insertions(+), 14 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index 0183da592..0df815609 100644 --- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -70,7 +70,7 @@ public interface EDTUtil { * is expected. * * @see #invoke(boolean, java.lang.Runnable) - * @see #invokeStop(java.lang.Runnable) + * @see #invokeStop(boolean, java.lang.Runnable) */ public void reset(); @@ -113,7 +113,12 @@ public interface EDTUtil { /** * Append the final task to the EDT task queue, - * signals EDT to stop and wait until stopped.
    + * signals EDT to stop. + *

    + * If wait is true methods + * blocks until EDT is stopped. + *

    + *

    * task maybe null
    * Due to the nature of this method: *

      @@ -122,8 +127,9 @@ public interface EDTUtil { *
    • Can be issued from within EDT, ie from within an enqueued task.
    • *
    • {@link #reset()} may follow immediately, ie creating a new EDT
    • *
    + *

    */ - public void invokeStop(Runnable finalTask); + public void invokeStop(boolean wait, Runnable finalTask); /** * Shall start the thread if not running, task maybe null for this purpose.
    @@ -143,7 +149,7 @@ public interface EDTUtil { /** * Wait until EDT task is stopped.
    - * No stop action is performed, {@link #invokeStop(java.lang.Runnable)} should be used before. + * No stop action is performed, {@link #invokeStop(boolean, java.lang.Runnable)} should be used before. */ public void waitUntilStopped(); } diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index 651522799..c080e8380 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -126,8 +126,8 @@ public class DefaultEDTUtil implements EDTUtil { } @Override - public final void invokeStop(Runnable task) { - invokeImpl(true, task, true); + public final void invokeStop(boolean wait, Runnable task) { + invokeImpl(wait, task, true); } @Override diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 3edb532db..0d1dcf5ab 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -207,7 +207,7 @@ public abstract class DisplayImpl extends Display { private void removeEDT(final Runnable task) { if(null!=edtUtil) { - edtUtil.invokeStop(task); + edtUtil.invokeStop(true, task); // ready for restart .. edtUtil.waitUntilStopped(); edtUtil.reset(); @@ -261,7 +261,7 @@ public abstract class DisplayImpl extends Display { } } - /** Maybe utilized at a shutdown hook, impl. does not synchronize, however the EDT removal blocks. */ + /** May be utilized at a shutdown hook, impl. does not block. */ /* pp */ static final void shutdownAll() { final int dCount = displayList.size(); if(DEBUG) { @@ -275,13 +275,23 @@ public abstract class DisplayImpl extends Display { if(DEBUG) { System.err.println("Display.shutdownAll["+(i+1)+"/"+dCount+"]: "+d); } - d.removeEDT( new Runnable() { + final Runnable closeNativeTask = new Runnable() { public void run() { if ( null != d.getGraphicsDevice() ) { d.closeNativeImpl(); } } - } ); + }; + final EDTUtil edtUtil = d.getEDTUtil(); + if(null != edtUtil) { + final long coopSleep = edtUtil.getPollPeriod() * 2; + edtUtil.invokeStop(false, closeNativeTask); // don't block + try { + Thread.sleep( coopSleep < 50 ? coopSleep : 50 ); + } catch (InterruptedException e) { } + } else { + closeNativeTask.run(); + } d.aDevice = null; d.refCount=0; } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index fc9bbb848..0cc5ddb3e 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -114,8 +114,8 @@ public class AWTEDTUtil implements EDTUtil { } @Override - public final void invokeStop(Runnable task) { - invokeImpl(true, task, true); + public final void invokeStop(boolean wait, Runnable task) { + invokeImpl(wait, task, true); } @Override diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java index 2008b5ea4..77049a010 100644 --- a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java @@ -124,8 +124,8 @@ public class SWTEDTUtil implements EDTUtil { } @Override - public final void invokeStop(Runnable task) { - invokeImpl(true, task, true); + public final void invokeStop(boolean wait, Runnable task) { + invokeImpl(wait, task, true); } @Override -- cgit v1.2.3 From cc64ad2b1f7904af4e7bd27e927e0bb331db782b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 25 Jun 2013 07:04:17 +0200 Subject: NEWT WindowImpl/GLWindow: @ JVM Shutdown, force stop animation thread w/o blocking. --- .../classes/com/jogamp/newt/opengl/GLWindow.java | 20 ++++++++++++++++++++ src/newt/classes/jogamp/newt/WindowImpl.java | 17 ++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 345d92bc1..25249cee4 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -34,6 +34,8 @@ package com.jogamp.newt.opengl; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.List; import javax.media.nativewindow.AbstractGraphicsConfiguration; @@ -529,6 +531,24 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind savedAnimator.resume(); } } + + @SuppressWarnings("deprecation") + @Override + public void shutdownRenderingAction() { + final GLAnimatorControl anim = GLWindow.this.getAnimator(); + if ( null != anim && anim.isAnimating() ) { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + final Thread animThread = anim.getThread(); + if( null != animThread ) { + try { + animThread.stop(); + } catch(Throwable t) { } + } + return null; + } } ); + } + } } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 6787f0ab3..77ff21061 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -88,7 +88,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ScreenImpl.initSingleton(); } - /** Maybe utilized at a shutdown hook, impl. does not synchronize, however the Window destruction and EDT removal blocks. */ + /** Maybe utilized at a shutdown hook, impl. does not block. */ public static final void shutdownAll() { final int wCount = windowList.size(); if(DEBUG_IMPLEMENTATION) { @@ -99,7 +99,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window.shutdownAll["+(i+1)+"/"+wCount+"]: "+toHexString(w.getWindowHandle())); } - w.markInvalid(); + w.shutdown(); } } @@ -242,7 +242,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** Fast invalidation of instance w/o any blocking function call. */ - private final void markInvalid() { + private final void shutdown() { + if(null!=lifecycleHook) { + lifecycleHook.shutdownRenderingAction(); + } setWindowHandle(0); visible = false; fullscreen = false; @@ -310,6 +313,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @see #pauseRenderingAction() */ void resumeRenderingAction(); + + /** + * Shutdown rendering action (thread) abnormally. + *

    + * Should be called only at shutdown, if necessary. + *

    + */ + void shutdownRenderingAction(); } private boolean createNative() { -- cgit v1.2.3 From 1c717a781702b0decb0c4da71a9dadc2a8255d5b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Jun 2013 03:52:16 +0200 Subject: Add Comparable: Point*, Dimension*, Rectangle*, SurfaceSize* and MonitorMode* ; Sort List in descending order to be well determined. Add Comparable: Point*, Dimension*, Rectangle*, SurfaceSize* and MonitorMode*: - Compare square values - See API doc for order of special semantics (flags, rotation, ..) Sort List in descending order to be well determined: - Removes order by native mode id, give user a reliable natural order. --- make/scripts/tests.sh | 5 +- .../javax/media/nativewindow/util/Dimension.java | 13 +++ .../nativewindow/util/DimensionImmutable.java | 11 +- .../javax/media/nativewindow/util/Point.java | 13 +++ .../media/nativewindow/util/PointImmutable.java | 11 +- .../javax/media/nativewindow/util/Rectangle.java | 25 +++++ .../nativewindow/util/RectangleImmutable.java | 11 +- .../javax/media/nativewindow/util/SurfaceSize.java | 26 ++++- .../classes/com/jogamp/newt/MonitorDevice.java | 4 + src/newt/classes/com/jogamp/newt/MonitorMode.java | 115 +++++++++++++++++++-- src/newt/classes/com/jogamp/newt/Screen.java | 4 + .../com/jogamp/newt/util/MonitorModeUtil.java | 11 ++ src/newt/classes/jogamp/newt/ScreenImpl.java | 8 +- .../test/junit/newt/mm/TestScreenMode00aNEWT.java | 34 +++++- 14 files changed, 271 insertions(+), 20 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 84e536017..5acced4af 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -284,7 +284,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -400,13 +400,14 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowWarpPointer01NEWT $* diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index 4fae98f08..b52414146 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -84,6 +84,19 @@ public class Dimension implements Cloneable, DimensionImmutable { return new String(width+" x "+height); } + @Override + public int compareTo(final DimensionImmutable d) { + final int tsq = width*height; + final int xsq = d.getWidth()*d.getHeight(); + + if(tsq > xsq) { + return 1; + } else if(tsq < xsq) { + return -1; + } + return 0; + } + @Override public boolean equals(Object obj) { if(this == obj) { return true; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java index d14e94c10..22bd3f48b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java @@ -37,12 +37,21 @@ import com.jogamp.common.type.WriteCloneable; *
  • height
  • * */ -public interface DimensionImmutable extends WriteCloneable { +public interface DimensionImmutable extends WriteCloneable, Comparable { int getHeight(); int getWidth(); + /** + *

    + * Compares square of size. + *

    + * {@inheritDoc} + */ + @Override + public int compareTo(final DimensionImmutable d); + /** * Checks whether two dimensions objects are equal. Two instances * of DimensionReadOnly are equal if two components diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index 8e6caf72b..a30d3030e 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -54,6 +54,19 @@ public class Point implements Cloneable, PointImmutable { } } + @Override + public int compareTo(final PointImmutable d) { + final int sq = x*y; + final int xsq = d.getX()*d.getY(); + + if(sq > xsq) { + return 1; + } else if(sq < xsq) { + return -1; + } + return 0; + } + @Override public boolean equals(Object obj) { if(this == obj) { return true; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java index d7eb0e7b4..b00329bb5 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java @@ -32,12 +32,21 @@ package javax.media.nativewindow.util; import com.jogamp.common.type.WriteCloneable; /** Immutable Point interface */ -public interface PointImmutable extends WriteCloneable { +public interface PointImmutable extends WriteCloneable, Comparable { int getX(); int getY(); + /** + *

    + * Compares the square of the position. + *

    + * {@inheritDoc} + */ + @Override + public int compareTo(final PointImmutable d); + /** * Checks whether two points objects are equal. Two instances * of PointReadOnly are equal if the two components diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index 8e6fc8e36..7576f4ec7 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -142,6 +142,31 @@ public class Rectangle implements Cloneable, RectangleImmutable { return sqI / sqT; } + @Override + public int compareTo(final RectangleImmutable d) { + { + final int sq = width*height; + final int xsq = d.getWidth()*d.getHeight(); + + if(sq > xsq) { + return 1; + } else if(sq < xsq) { + return -1; + } + } + { + final int sq = x*y; + final int xsq = d.getX()*d.getY(); + + if(sq > xsq) { + return 1; + } else if(sq < xsq) { + return -1; + } + } + return 0; + } + @Override public boolean equals(Object obj) { if(this == obj) { return true; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java index 7531989de..440d9e000 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java @@ -31,7 +31,7 @@ package javax.media.nativewindow.util; import com.jogamp.common.type.WriteCloneable; /** Immutable Rectangle interface */ -public interface RectangleImmutable extends WriteCloneable { +public interface RectangleImmutable extends WriteCloneable, Comparable { int getHeight(); @@ -61,6 +61,15 @@ public interface RectangleImmutable extends WriteCloneable { */ float coverage(RectangleImmutable r); + /** + *

    + * Compares square of size 1st, if equal the square of position. + *

    + * {@inheritDoc} + */ + @Override + public int compareTo(final RectangleImmutable d); + /** * Checks whether two rect objects are equal. Two instances * of Rectangle are equal if the four integer values diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java index d7e451af8..3084816a5 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java @@ -29,13 +29,14 @@ package javax.media.nativewindow.util; -/** Immutable SurfaceSize Class, consisting of it's read only components:
    +/** + * Immutable SurfaceSize Class, consisting of it's read only components:
    *
      *
    • {@link javax.media.nativewindow.util.DimensionImmutable} size in pixels
    • *
    • bits per pixel
    • *
    */ -public class SurfaceSize { +public class SurfaceSize implements Comparable { final DimensionImmutable resolution; final int bitsPerPixel; @@ -59,6 +60,27 @@ public class SurfaceSize { return new String("[ "+resolution+" x "+bitsPerPixel+" bpp ]"); } + /** + *

    + * Compares {@link DimensionImmutable#compareTo(DimensionImmutable) resolution} 1st, if equal the bitsPerPixel. + *

    + * {@inheritDoc} + */ + @Override + public int compareTo(final SurfaceSize ssz) { + final int rres = resolution.compareTo(ssz.getResolution()); + if( 0 != rres ) { + return rres; + } + final int xbpp = ssz.getBitsPerPixel(); + if(bitsPerPixel > xbpp) { + return 1; + } else if(bitsPerPixel < xbpp) { + return -1; + } + return 0; + } + /** * Checks whether two size objects are equal. Two instances * of SurfaceSize are equal if the two components diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index 4b0a760a4..8bc7f40e3 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -129,6 +129,10 @@ public abstract class MonitorDevice { /** * Returns a list of immutable {@link MonitorMode}s supported by this monitor. *

    + * The list is ordered in descending order, + * see {@link MonitorMode#compareTo(MonitorMode)}. + *

    + *

    * Use w/ care, it's not a copy! *

    */ diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java index 914aa880f..dc7ae2c03 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorMode.java +++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java @@ -28,6 +28,8 @@ package com.jogamp.newt; +import java.util.Comparator; + import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.RectangleImmutable; import javax.media.nativewindow.util.SurfaceSize; @@ -108,22 +110,36 @@ import com.jogamp.newt.util.MonitorModeUtil; monitor.setCurrentMode(mm); * */ -public class MonitorMode { +public class MonitorMode implements Comparable { + + /** Comparator for 2 {@link MonitorMode}s, following comparison order as described in {@link MonitorMode#compareTo(MonitorMode)}, returning the ascending order. */ + public static final Comparator monitorModeComparator = new Comparator() { + public int compare(MonitorMode mm1, MonitorMode mm2) { + return mm1.compareTo(mm2); + } }; + + /** Comparator for 2 {@link MonitorMode}s, following comparison order as described in {@link MonitorMode#compareTo(MonitorMode)}, returning the descending order. */ + public static final Comparator monitorModeComparatorInv = new Comparator() { + public int compare(MonitorMode mm1, MonitorMode mm2) { + return mm2.compareTo(mm1); + } }; + /** - * Immutable surfaceSize and refreshRate Class, consisting of it's read only components:
    + * Immutable surfaceSize, flags and refreshRate Class, consisting of it's read only components:
    *
      *
    • nativeId
    • *
    • {@link SurfaceSize} surface memory size
    • + *
    • flags
    • *
    • refresh rate
    • *
    */ - public static class SizeAndRRate { + public static class SizeAndRRate implements Comparable { /** Non rotated surface size */ public final SurfaceSize surfaceSize; - /** Vertical refresh rate */ - public final float refreshRate; /** Mode bitfield flags, i.e. {@link #FLAG_DOUBLESCAN}, {@link #FLAG_INTERLACE}, .. */ public final int flags; + /** Vertical refresh rate */ + public final float refreshRate; public final int hashCode; public SizeAndRRate(SurfaceSize surfaceSize, float refreshRate, int flags) { @@ -131,8 +147,8 @@ public class MonitorMode { throw new IllegalArgumentException("surfaceSize must be set ("+surfaceSize+")"); } this.surfaceSize=surfaceSize; - this.refreshRate=refreshRate; this.flags = flags; + this.refreshRate=refreshRate; this.hashCode = getHashCode(); } @@ -160,6 +176,49 @@ public class MonitorMode { return new String(surfaceSize+" @ "+refreshRate+" Hz, flags ["+flags2String(flags).toString()+"]"); } + /** + *

    + * Compares {@link SurfaceSize#compareTo(SurfaceSize) surfaceSize} 1st, then {@link #flags}, then {@link #refreshRate}. + *

    + *

    + * Flags are compared as follows: + *

    +         *   NONE > DOUBLESCAN > INTERLACE
    +         * 
    + *

    + *

    + * Refresh rate differences of < 0.01 are considered equal (epsilon). + *

    + * {@inheritDoc} + */ + @Override + public int compareTo(final SizeAndRRate sszr) { + final int rssz = surfaceSize.compareTo(sszr.surfaceSize); + if( 0 != rssz ) { + return rssz; + } + final int tflags = 0 == flags ? Integer.MAX_VALUE : flags; // normalize NONE + final int xflags = 0 == sszr.flags ? Integer.MAX_VALUE : sszr.flags; // normalize NONE + if( tflags == xflags ) { + final float refreshEpsilon = 0.01f; // reasonable sorting granularity of refresh rate + final float drate = refreshRate - sszr.refreshRate; + if( Math.abs(drate) < refreshEpsilon ) { + return 0; + } else if( drate > refreshEpsilon ) { + return 1; + } else { + return -1; + } + } else { + if(tflags > xflags) { + return 1; + } else if(tflags < xflags) { + return -1; + } + return 0; + } + } + /** * Tests equality of two {@link SizeAndRRate} objects * by evaluating equality of it's components:
    @@ -174,8 +233,8 @@ public class MonitorMode { if (obj instanceof SizeAndRRate) { final SizeAndRRate p = (SizeAndRRate)obj; return surfaceSize.equals(p.surfaceSize) && - refreshRate == p.refreshRate && - flags == p.flags ; + flags == p.flags && + refreshRate == p.refreshRate ; } return false; } @@ -184,8 +243,8 @@ public class MonitorMode { * Returns a combined hash code of it's elements:
    *
      *
    • surfaceSize
    • - *
    • refreshRate
    • *
    • flags
    • + *
    • refreshRate
    • *
    */ public final int hashCode() { @@ -194,8 +253,8 @@ public class MonitorMode { private final int getHashCode() { // 31 * x == (x << 5) - x int hash = 31 + surfaceSize.hashCode(); - hash = ((hash << 5) - hash) + (int)(refreshRate*100.0f); hash = ((hash << 5) - hash) + flags; + hash = ((hash << 5) - hash) + (int)(refreshRate*100.0f); return hash; } } @@ -305,6 +364,42 @@ public class MonitorMode { return "[Id "+Display.toHexString(nativeId)+", " + sizeAndRRate + ", " + rotation + " degr]"; } + /** + *

    + * Compares {@link SizeAndRRate#compareTo(SizeAndRRate) sizeAndRRate} 1st, then {@link #rotation}. + *

    + *

    + * Rotation is compared inverted, i.e. 360 - rotation, + * so the lowest rotation reflects a higher value. + *

    + *

    + * Order of comparing MonitorMode: + *

      + *
    • resolution
    • + *
    • bits per pixel
    • + *
    • flags
    • + *
    • refresh rate
    • + *
    • rotation
    • + *
    + *

    + * {@inheritDoc} + */ + @Override + public int compareTo(final MonitorMode mm) { + final int c = sizeAndRRate.compareTo(mm.sizeAndRRate); + if( 0 != c ) { + return c; + } + final int trot = 360 - rotation; // normalize rotation + final int xrot = 360 - mm.rotation; // normalize rotation + if(trot > xrot) { + return 1; + } else if(trot < xrot) { + return -1; + } + return 0; + } + /** * Tests equality of two {@link MonitorMode} objects * by evaluating equality of it's components:
    diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index f56aff964..9b349b527 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -164,6 +164,10 @@ public abstract class Screen { /** * Return a list of all {@link MonitorMode}s for all {@link MonitorDevice}s. + *

    + * The list is ordered in descending order, + * see {@link MonitorMode#compareTo(MonitorMode)}. + *

    */ public abstract List getMonitorModes(); diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java index 16ffe754f..c30b427d6 100644 --- a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java @@ -31,7 +31,9 @@ package com.jogamp.newt.util; import com.jogamp.newt.MonitorMode; import java.util.ArrayList; +import java.util.Collections; import java.util.List; + import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.SurfaceSize; @@ -68,6 +70,15 @@ public class MonitorModeUtil { return null; } + /** Sort the given {@link MonitorMode} collection w/ {@link MonitorMode#compareTo(MonitorMode)} function. */ + public static void sort(List monitorModes, boolean ascendingOrder) { + if( ascendingOrder ) { + Collections.sort(monitorModes); + } else { + Collections.sort(monitorModes, MonitorMode.monitorModeComparatorInv); + } + } + /** * * @param monitorModes diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index f63d1499e..28f3e876c 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -52,6 +52,7 @@ import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.event.MonitorEvent; import com.jogamp.newt.event.MonitorModeListener; +import com.jogamp.newt.util.MonitorModeUtil; public abstract class ScreenImpl extends Screen implements MonitorModeListener { protected static final boolean DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true); @@ -536,6 +537,11 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { final MonitorDevice monitor = getVirtualMonitorDevice(cache, 0, mode); cache.monitorDevices.getOrAdd(monitor); } + // Sort MonitorModes (all and per device) in descending order - default! + MonitorModeUtil.sort(cache.monitorModes.getData(), false /* ascendingOrder*/); + for(Iterator iMonitor=cache.monitorDevices.iterator(); iMonitor.hasNext(); ) { + MonitorModeUtil.sort(iMonitor.next().getSupportedModes(), false /* ascendingOrder*/); + } if(DEBUG) { int i=0; for(Iterator iMode=cache.monitorModes.iterator(); iMode.hasNext(); i++) { @@ -550,7 +556,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { System.err.println("["+i+"]["+j+"]: "+iMode.next()); } } - } + } sms = new ScreenMonitorState(cache.monitorDevices, cache.monitorModes); ScreenMonitorState.mapScreenMonitorState(this.getFQName(), sms); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java index 123199427..7a15971d5 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java @@ -41,7 +41,9 @@ import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.MonitorMode; import com.jogamp.newt.Screen; +import com.jogamp.newt.util.MonitorModeUtil; import com.jogamp.opengl.test.junit.util.UITestCase; + import java.util.Iterator; import java.util.List; import javax.media.nativewindow.util.Dimension; @@ -56,6 +58,9 @@ import jogamp.newt.MonitorModeProps; /** * Validating consistency of MonitorMode data from Screen (all modes) * and from a particular MonitorDevice. + *

    + * Also validates the descending order of the given MonitorMode lists. + *

    */ public class TestScreenMode00aNEWT extends UITestCase { static int screenIdx = 0; @@ -130,8 +135,27 @@ public class TestScreenMode00aNEWT extends UITestCase { Assert.assertTrue(allMonitorModes.size()>0); { int i=0; + MonitorMode mmPre = null; + for(Iterator iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) { + final MonitorMode mm = iMode.next(); + System.err.println(String.format("All-0[%03d]: %s", i, mm)); + if( null != mmPre ) { + Assert.assertTrue("Wrong order", mmPre.compareTo(mm) >= 0); + } + mmPre = mm; + } + } + MonitorModeUtil.sort(allMonitorModes, true /* ascendingOrder*/); + { + int i=0; + MonitorMode mmPre = null; for(Iterator iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) { - System.err.println("All["+i+"]: "+iMode.next()); + final MonitorMode mm = iMode.next(); + System.err.println(String.format("All-1[%03d]: %s", i, mm)); + if( null != mmPre ) { + Assert.assertTrue("Wrong order", mmPre.compareTo(mm) <= 0); + } + mmPre = mm; } } @@ -144,8 +168,14 @@ public class TestScreenMode00aNEWT extends UITestCase { List modes = monitor.getSupportedModes(); Assert.assertTrue(modes.size()>0); int i=0; + MonitorMode mmPre = null; for(Iterator iMode=modes.iterator(); iMode.hasNext(); i++) { - System.err.println("["+j+"]["+i+"]: "+iMode.next()); + final MonitorMode mm = iMode.next(); + System.err.println(String.format("[%02d][%03d]: %s", j, i, mm)); + if( null != mmPre ) { + Assert.assertTrue("Wrong order", mmPre.compareTo(mm) >= 0); + } + mmPre = mm; } Assert.assertTrue(allMonitorModes.containsAll(modes)); -- cgit v1.2.3 From ff0d98e242204f1884cef5924ce30cf23ad3d21f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Jun 2013 03:52:52 +0200 Subject: NewtCanvasAWT: Add missing println if(DEBUG) decoration --- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 6ba7a1a61..e4b5a25c4 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -576,7 +576,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } final int w = getWidth(); final int h = getHeight(); - System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h); + if(DEBUG) { + System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h); + } newtChild.setVisible(false); newtChild.setSize(w, h); newtChild.reparentWindow(jawtWindow); -- cgit v1.2.3 From 6b2571337349eb6eb49ee9b4931d454910800e94 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Jun 2013 14:25:23 +0200 Subject: X11 RandR: Cleanup RandR impl. selection, RandR13 setMode does not require a temp. display connection! --- src/newt/classes/jogamp/newt/driver/x11/RandR.java | 6 ++++++ src/newt/classes/jogamp/newt/driver/x11/RandR11.java | 19 ++++++++----------- src/newt/classes/jogamp/newt/driver/x11/RandR13.java | 17 +++++++---------- .../classes/jogamp/newt/driver/x11/ScreenDriver.java | 19 ++++++++++++++----- 4 files changed, 35 insertions(+), 26 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR.java b/src/newt/classes/jogamp/newt/driver/x11/RandR.java index c569e5fd8..769ebe225 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR.java @@ -31,11 +31,17 @@ import java.util.List; import jogamp.newt.MonitorModeProps; +import com.jogamp.common.util.VersionNumber; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; public interface RandR { + public static final VersionNumber version110 = new VersionNumber(1, 1, 0); + public static final VersionNumber version130 = new VersionNumber(1, 3, 0); + public static final VersionNumber version140 = new VersionNumber(1, 4, 0); + VersionNumber getVersion(); + void dumpInfo(final long dpy, final int screen_idx); /** diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java index a938b4064..58468e112 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java @@ -34,20 +34,17 @@ import com.jogamp.common.util.VersionNumber; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; -public class RandR11 implements RandR { +class RandR11 implements RandR { private static final boolean DEBUG = ScreenDriver.DEBUG; - public static VersionNumber version = new VersionNumber(1, 1, 0); - - public static RandR11 createInstance(VersionNumber rAndRVersion) { - if( rAndRVersion.compareTo(version) >= 0 ) { - return new RandR11(); - } - return null; - } - private RandR11() { + RandR11() { } - + + @Override + public final VersionNumber getVersion() { + return version110; + } + @Override public void dumpInfo(final long dpy, final int screen_idx) { // NOP diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java index d10591381..375cffe42 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java @@ -43,18 +43,15 @@ import com.jogamp.newt.MonitorMode; * MonitorDevice.id == XRR monitor-idx (not id) * */ -public class RandR13 implements RandR { +class RandR13 implements RandR { private static final boolean DEBUG = ScreenDriver.DEBUG; - public static VersionNumber version = new VersionNumber(1, 3, 0); - - public static RandR13 createInstance(VersionNumber rAndRVersion) { - if( rAndRVersion.compareTo(version) >= 0 ) { - return new RandR13(); - } - return null; - } - private RandR13() { + RandR13() { + } + + @Override + public final VersionNumber getVersion() { + return version130; } @Override diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index e1373bba5..19a69a3f9 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -84,11 +84,12 @@ public class ScreenDriver extends ScreenImpl { randrVersion = new VersionNumber(v[0], v[1], 0); } { - final RandR13 rAndR13 = DEBUG_TEST_RANDR13_DISABLED ? null : RandR13.createInstance(randrVersion); - if( null != rAndR13 ) { - rAndR = rAndR13; + if( !DEBUG_TEST_RANDR13_DISABLED && randrVersion.compareTo(RandR.version130) >= 0 ) { + rAndR = new RandR13(); + } else if( randrVersion.compareTo(RandR.version110) >= 0 ) { + rAndR = new RandR11(); } else { - rAndR = RandR11.createInstance(randrVersion); + rAndR = null; } } if( DEBUG ) { @@ -186,7 +187,7 @@ public class ScreenDriver extends ScreenImpl { if( null == rAndR ) { return false; } final long t0 = System.currentTimeMillis(); - boolean done = runWithTempDisplayHandle( new DisplayImpl.DisplayRunnable() { + boolean done = runWithOptTempDisplayHandle( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { return Boolean.valueOf( rAndR.setCurrentMonitorMode(dpy, ScreenDriver.this, monitor, mode) ); } @@ -248,6 +249,14 @@ public class ScreenDriver extends ScreenImpl { return res; } + private final T runWithOptTempDisplayHandle(DisplayRunnable action) { + if( null != rAndR && rAndR.getVersion().compareTo(RandR.version130) >= 0 ) { + return display.runWithLockedDisplayDevice(action); + } else { + return runWithTempDisplayHandle(action); + } + } + private static native long GetScreen0(long dpy, int scrn_idx); private static native int getWidth0(long display, int scrn_idx); -- cgit v1.2.3 From 3a0529c4713206dae130f2b1a6bf68b7a0fb3905 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Jun 2013 14:26:23 +0200 Subject: NEWT Screen ..: Typos / JNI signature --- src/newt/classes/com/jogamp/newt/Screen.java | 2 +- src/newt/native/X11RandR11.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index 9b349b527..cf8145561 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -64,7 +64,7 @@ public abstract class Screen { } /** - * Manual trigger the native creation, if it is not done yet..
    + * Manual trigger the native creation, if not done yet..
    * This is useful to be able to request the {@link javax.media.nativewindow.AbstractGraphicsScreen}, via * {@link #getGraphicsScreen()}.
    * Otherwise the abstract device won't be available before the dependent component (Window) is realized. diff --git a/src/newt/native/X11RandR11.c b/src/newt/native/X11RandR11.c index 81a6726b5..53d01a6fe 100644 --- a/src/newt/native/X11RandR11.c +++ b/src/newt/native/X11RandR11.c @@ -311,7 +311,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR11_setCurrentScreenM /* * Class: jogamp_newt_driver_x11_RandR11 * Method: setCurrentScreenModePollEnd0 - * Signature: (J)Z + * Signature: (JIII)Z */ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR11_setCurrentScreenModePollEnd0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) -- cgit v1.2.3 From 61ee606366f28843287049d01f3f1e2e2139878e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Jun 2013 14:28:41 +0200 Subject: ScreenImpl: Fix ScreenMonitorState add/remove reference, which shall only happen at actual native create and destroy. .. otherwise usage of Screen.createNative() and a later Window creation would cause the ScreenMonitorState having 2 added listener - which in turn disables it's orig mode reset at Screen destruction. --- src/newt/classes/jogamp/newt/ScreenImpl.java | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 28f3e876c..422d5b06c 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -177,7 +177,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if(null == aScreen) { throw new NativeWindowException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen"); } - + initMonitorState(); if(DEBUG) { System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+"), total "+ (System.nanoTime()-tCreated)/1e6 +"ms"); @@ -185,23 +185,22 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { synchronized(screenList) { screensActive++; } + ScreenMonitorState.getScreenMonitorState(this.getFQName()).addListener(this); } - ScreenMonitorState sms = ScreenMonitorState.getScreenMonitorState(this.getFQName()); - sms.addListener(this); } @Override public synchronized final void destroy() { - releaseMonitorState(); - synchronized(screenList) { - screenList.remove(this); - if(0 < screensActive) { - screensActive--; + if( screenList.remove(this) ) { + if(0 < screensActive) { + screensActive--; + } } } if ( null != aScreen ) { + releaseMonitorState(); closeNativeImpl(); aScreen = null; } @@ -217,8 +216,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } if ( 0 == refCount ) { createNative(); - } - if(null == aScreen) { + } else if(null == aScreen) { throw new NativeWindowException("Screen.addReference() (refCount "+refCount+") null AbstractGraphicsScreen"); } return ++refCount; @@ -538,9 +536,9 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { cache.monitorDevices.getOrAdd(monitor); } // Sort MonitorModes (all and per device) in descending order - default! - MonitorModeUtil.sort(cache.monitorModes.getData(), false /* ascendingOrder*/); + MonitorModeUtil.sort(cache.monitorModes.getData(), false ); // descending order for(Iterator iMonitor=cache.monitorDevices.iterator(); iMonitor.hasNext(); ) { - MonitorModeUtil.sort(iMonitor.next().getSupportedModes(), false /* ascendingOrder*/); + MonitorModeUtil.sort(iMonitor.next().getSupportedModes(), false ); // descending order } if(DEBUG) { int i=0; @@ -611,7 +609,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { return cache.monitorDevices.size(); } - private void releaseMonitorState() { + private final void releaseMonitorState() { ScreenMonitorState sms; ScreenMonitorState.lockScreenMonitorState(); try { -- cgit v1.2.3 From bcb80d2b03592e55f0956752958622694185ccb6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Jun 2013 14:47:07 +0200 Subject: MonitorDeviceImpl: No need to nanoTime() .. --- src/newt/classes/jogamp/newt/MonitorDeviceImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java index db31cc83f..43d558515 100644 --- a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java +++ b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java @@ -94,20 +94,20 @@ public class MonitorDeviceImpl extends MonitorDevice { } final long tStart; if(Screen.DEBUG) { - tStart = System.nanoTime(); + tStart = System.currentTimeMillis(); } else { tStart = 0; } sms.fireMonitorModeChangeNotify(this, mmU); if(Screen.DEBUG) { - System.err.println("Screen.setCurrentMode ("+(System.nanoTime()-tStart)/1e6+"ms): fireModeChangeNotify() "+mmU); + System.err.println("Screen.setCurrentMode ("+(System.currentTimeMillis()-tStart)+"ms): fireModeChangeNotify() "+mmU); } - + boolean success = screenImpl.setCurrentMonitorModeImpl(this, mmU); if(success) { if(Screen.DEBUG) { - System.err.println("Screen.setCurrentMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentModeImpl() "+mmU+", success(1): "+success); + System.err.println("Screen.setCurrentMode ("+(System.currentTimeMillis()-tStart)+"ms): setCurrentModeImpl() "+mmU+", success(1): "+success); } } else { // 2nd attempt validate! @@ -115,7 +115,7 @@ public class MonitorDeviceImpl extends MonitorDevice { success = queriedCurrent.hashCode() == mmU.hashCode() ; if(Screen.DEBUG) { System.err.println("Screen.setCurrentMode.2: queried "+queriedCurrent); - System.err.println("Screen.setCurrentMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentModeImpl() "+mmU+", success(2): "+success); + System.err.println("Screen.setCurrentMode ("+(System.currentTimeMillis()-tStart)+"ms): setCurrentModeImpl() "+mmU+", success(2): "+success); } } if( success ) { @@ -124,7 +124,7 @@ public class MonitorDeviceImpl extends MonitorDevice { } sms.fireMonitorModeChanged(this, mmU, success); if(Screen.DEBUG) { - System.err.println("Screen.setCurrentMode ("+(System.nanoTime()-tStart)/1e6+"ms): X.X "+this+", success: "+success); + System.err.println("Screen.setCurrentMode ("+(System.currentTimeMillis()-tStart)+"ms): X.X: success "+success+": "+this); } return success; } finally { -- cgit v1.2.3 From 205a17de1abec614d3d06386f873170fc1691e86 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 2 Jul 2013 15:10:20 +0200 Subject: Fix Bug 770 and 771 Bug 770: X11Window.c: - Request focus _before_ enabling EWMH flags (fullscreen or above) after resize and temporary invisibility. This actually allows us to keep the focus after resize and repositioning! - Set _NET_WM_BYPASS_COMPOSITOR implicit analog to _NET_WM_STATE_FLAG_ABOVE - Clean up _NET_WM_* flag names, avoiding name space collisions, i.e. adding FLAG! - Remove dead _NET_WM_STATE setting via direct window property (not working anyways) - Remove dead code: FS_GRAB_KEYBOARD X11/WindowDriver.java: - Enable _NET_WM_STATE_FLAG_ABOVE temporarily if FLAG_IS_FULLSCREEN && !FLAG_IS_ALWAYSONTOP - Override focusChanged(..) to react on focus lost/gained in case of temporarily enabled _NET_WM_STATE_FLAG_ABOVE. If focus is lost, disable _NET_WM_STATE_FLAG_ABOVE, otherwise re-enable it. WindowImpl.java: - FullscreenAction.run: Always use 'FLAG_IS_FULLSCREEN_SPAN' +++ Bug 771: WindowImpl.java: - Keep fullscreenMonitors and fullscreenUseMainMonitor values intact, allowing them to be tracked. Remove duplicates in FullscreenAction class. - MonitorModeListenerImpl.monitorModeChanged: Add fullscreen path: If the changed monitor is part of fullscreenMonitors, recalculate the viewport union and reset position and fullscreen-size. - MonitorModeListenerImpl: Try to regain focus after successful mode change. --- make/scripts/tests-win.bat | 5 +- make/scripts/tests.sh | 9 +- src/newt/classes/jogamp/newt/WindowImpl.java | 98 +++++++----- .../jogamp/newt/driver/x11/WindowDriver.java | 38 ++++- src/newt/native/X11Window.c | 159 +++++++----------- .../test/junit/newt/mm/TestScreenMode02aNEWT.java | 177 ++++++++++++--------- 6 files changed, 265 insertions(+), 221 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 17ac9c784..a5d368c48 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -61,7 +61,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* @@ -119,7 +119,8 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aN REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02sNEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5acced4af..c0d15b84b 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -135,7 +135,8 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" - #D_ARGS="-Dnewt.debug.Screen" + #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -175,7 +176,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -400,13 +401,13 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 77ff21061..600035bf6 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -372,9 +372,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(isFullscreen()) { synchronized(fullScreenAction) { fullscreen = false; // trigger a state change - fullScreenAction.init(true, fullscreenUseMainMonitor, fullscreenMonitors); - fullscreenMonitors = null; // release references ASAP - fullscreenUseMainMonitor = true; + fullScreenAction.init(true); fullScreenAction.run(); } } else { @@ -892,17 +890,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class SetSizeAction implements Runnable { int width, height; + boolean disregardFS; - private SetSizeAction(int w, int h) { + private SetSizeAction(int w, int h, boolean disregardFS) { this.width = w; this.height = h; + this.disregardFS = disregardFS; } public final void run() { final RecursiveLock _lock = windowLock; _lock.lock(); try { - if ( !isFullscreen() && ( getWidth() != width || getHeight() != height ) ) { + if ( ( disregardFS || !isFullscreen() ) && ( getWidth() != width || getHeight() != height ) ) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window setSize: START "+getWidth()+"x"+getHeight()+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible); } @@ -937,9 +937,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + private void setFullscreenSize(int width, int height) { + runOnEDTIfAvail(true, new SetSizeAction(width, height, true)); + } @Override public void setSize(int width, int height) { - runOnEDTIfAvail(true, new SetSizeAction(width, height)); + runOnEDTIfAvail(true, new SetSizeAction(width, height, false)); } @Override public void setTopLevelSize(int width, int height) { @@ -1850,25 +1853,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class FullScreenAction implements Runnable { boolean fullscreen; - List monitors; - boolean useMainMonitor; - private boolean init(boolean fullscreen, boolean useMainMonitor, List monitors) { + private boolean init(boolean fullscreen) { if(isNativeValid()) { this.fullscreen = fullscreen; - if( isFullscreen() != fullscreen ) { - this.monitors = monitors; - this.useMainMonitor = useMainMonitor; - return true; - } else { - this.monitors = null; - this.useMainMonitor = true; - return false; - } + return isFullscreen() != fullscreen; } else { WindowImpl.this.fullscreen = fullscreen; // set current state for createNative(..) - WindowImpl.this.fullscreenMonitors = monitors; - WindowImpl.this.fullscreenUseMainMonitor = useMainMonitor; return false; } } @@ -1886,16 +1877,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final RectangleImmutable viewport; final int fs_span_flag; if(fullscreen) { - if( null == monitors ) { - if( useMainMonitor ) { - monitors = new ArrayList(); - monitors.add( getMainMonitor() ); + if( null == fullscreenMonitors ) { + if( fullscreenUseMainMonitor ) { + fullscreenMonitors = new ArrayList(); + fullscreenMonitors.add( getMainMonitor() ); } else { - monitors = getScreen().getMonitorDevices(); + fullscreenMonitors = getScreen().getMonitorDevices(); } } - fs_span_flag = monitors.size() > 1 ? FLAG_IS_FULLSCREEN_SPAN : 0 ; - viewport = MonitorDevice.unionOfViewports(new Rectangle(), monitors); + /** + * Bug 770: + * _NET_WM_STATE_FULLSCREEN may result in ConfigureNotify event w/ virtual screen size, instead of monitor-mode size (NV + Fglrx). + * ConfigureNotify reflects the actual size of the window and is being propagated + * to NEWT and the GLEventListener. + * With Mesa/Intel open-source driver, the correct desired monitor mode size is reported + * at least on one test machine here. + * + * Bug 771: Implementation requires not to use _NET_WM_STATE_FULLSCREEN! + */ + // fs_span_flag = monitors.size() > 1 ? FLAG_IS_FULLSCREEN_SPAN : 0 ; + fs_span_flag = FLAG_IS_FULLSCREEN_SPAN; + viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors); nfs_x = getX(); nfs_y = getY(); nfs_width = getWidth(); @@ -1905,6 +1907,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer w = viewport.getWidth(); h = viewport.getHeight(); } else { + fullscreenUseMainMonitor = true; + fullscreenMonitors = null; fs_span_flag = 0; viewport = null; x = nfs_x; @@ -1926,16 +1930,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } - monitors = null; // clear references ASAP - useMainMonitor = true; if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ ", virtl-size: "+screen.getWidth()+"x"+screen.getHeight()+", monitorsViewport "+viewport); } - DisplayImpl display = (DisplayImpl) screen.getDisplay(); + final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date - boolean wasVisible = isVisible(); + final boolean wasVisible = isVisible(); // Lock parentWindow only during reparenting (attempt) final NativeWindow parentWindowLocked; @@ -1963,8 +1965,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer WindowImpl.this.waitForVisible(true, false); display.dispatchMessagesNative(); // status up2date WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); - display.dispatchMessagesNative(); // status up2date - if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs done: " + WindowImpl.this); } @@ -1975,7 +1975,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener } } - private final FullScreenAction fullScreenAction = new FullScreenAction(); + private final FullScreenAction fullScreenAction = new FullScreenAction(); @Override public boolean setFullscreen(boolean fullscreen) { @@ -1989,7 +1989,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private boolean setFullscreenImpl(boolean fullscreen, boolean useMainMonitor, List monitors) { synchronized(fullScreenAction) { - if( fullScreenAction.init(fullscreen, useMainMonitor, monitors) ) { + fullscreenMonitors = monitors; + fullscreenUseMainMonitor = useMainMonitor; + if( fullScreenAction.init(fullscreen) ) { if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { // enable fullscreen on offscreen instance if(null != parentWindow) { @@ -2008,8 +2010,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer nfs_parent = null; } - if(isVisible()) { - requestFocus(true /* wait */, this.fullscreen /* skipFocusAction */, true /* force */); + if( fullscreen && isVisible() ) { // force focus on fullscreen + requestFocus(true /* wait */, true /* skipFocusAction */, true /* force */); } } return this.fullscreen; @@ -2018,10 +2020,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class MonitorModeListenerImpl implements MonitorModeListener { boolean animatorPaused = false; + boolean hadFocus = false; public void monitorModeChangeNotify(MonitorEvent me) { + hadFocus = hasFocus(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.monitorModeChangeNotify: "+me); + System.err.println("Window.monitorModeChangeNotify: hadFocus "+hadFocus+", "+me); } if(null!=lifecycleHook) { @@ -2031,7 +2035,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public void monitorModeChanged(MonitorEvent me, boolean success) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.monitorModeChanged: "+me+", success: "+success); + System.err.println("Window.monitorModeChanged: hadFocus "+hadFocus+", "+me+", success: "+success); } if(success) { @@ -2055,13 +2059,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer setSize(viewport.getWidth(), viewport.getHeight()); } } + } else { + // If changed monitor is part of this fullscreen mode, reset size! (Bug 771) + final MonitorDevice md = me.getMonitor(); + if( fullscreenMonitors.contains(md) ) { + final RectangleImmutable viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors); + if(DEBUG_IMPLEMENTATION) { + final RectangleImmutable rect = new Rectangle(getX(), getY(), getWidth(), getHeight()); + System.err.println("Window.monitorModeChanged: FS Monitor Match: Fit window "+rect+" into new viewport union "+viewport+", provoked by "+md); + } + definePosition(viewport.getX(), viewport.getY()); // set pos for setVisible(..) or createNative(..) - reduce EDT roundtrip + setFullscreenSize(viewport.getWidth(), viewport.getHeight()); + } } } - if(animatorPaused) { lifecycleHook.resumeRenderingAction(); } sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener + if( hadFocus ) { + requestFocus(true); + } } } private final MonitorModeListenerImpl monitorModeListenerImpl = new MonitorModeListenerImpl(); diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 786587d65..aec7f310e 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -133,7 +133,7 @@ public class WindowDriver extends WindowImpl { } } - protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { + protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, int flags) { if(DEBUG_IMPLEMENTATION) { System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); } @@ -148,18 +148,52 @@ public class WindowDriver extends WindowImpl { _x = x; _y = y; } + if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) { + tempAlwaysOnTop = true; + flags |= FLAG_IS_ALWAYSONTOP; + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window reconfig.2: temporary "+getReconfigureFlagsAsString(null, flags)); + } + } else { + tempAlwaysOnTop = false; + } + final int fflags = flags; final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { reconfigureWindow0( dpy, getScreenIndex(), getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), - _x, _y, width, height, flags); + _x, _y, width, height, fflags); return null; } }); return true; } + volatile boolean tempAlwaysOnTop = false; + /** + *

    + * Deal w/ tempAlwaysOnTop. + *

    + * {@inheritDoc} + */ + protected void focusChanged(boolean defer, boolean focusGained) { + if( tempAlwaysOnTop && hasFocus() != focusGained && isNativeValid() ) { + final int flags = getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible()) | ( focusGained ? FLAG_IS_ALWAYSONTOP : 0 ); + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + reconfigureWindow0( dpy, getScreenIndex(), + getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), + getX(), getY(), getWidth(), getHeight(), flags); + return null; + } + }); + } + super.focusChanged(defer, focusGained); + } + + protected void reparentNotify(long newParentWindowHandle) { if(DEBUG_IMPLEMENTATION) { final long p0 = getParentWindowHandle(); diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 3f50f27a4..4a95d0180 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -299,9 +299,8 @@ static void NewtWindows_setNormalWindowEWMH (Display *dpy, Window w) { #define _NET_WM_STATE_REMOVE 0 #define _NET_WM_STATE_ADD 1 - -#define _NET_WM_FULLSCREEN ( 1 << 0 ) -#define _NET_WM_ABOVE ( 1 << 1 ) +#define _NET_WM_STATE_FLAG_FULLSCREEN ( 1 << 0 ) +#define _NET_WM_STATE_FLAG_ABOVE ( 1 << 1 ) /** * Set fullscreen using Extended Window Manager Hints (EWMH) @@ -314,7 +313,9 @@ static void NewtWindows_setNormalWindowEWMH (Display *dpy, Window w) { * and resets it when leaving FS. * The same is assumed for the decoration state. */ -static int NewtWindows_isFullscreenEWMHSupported (Display *dpy, Window w) { +static int NewtWindows_getSupportedStackingEWMHFlags(Display *dpy, Window w) { +#ifdef VERBOSE_ON + // Code doesn't work reliable on KDE4 ... Atom _NET_WM_ALLOWED_ACTIONS = XInternAtom( dpy, "_NET_WM_ALLOWED_ACTIONS", False ); Atom _NET_WM_ACTION_FULLSCREEN = XInternAtom( dpy, "_NET_WM_ACTION_FULLSCREEN", False ); Atom _NET_WM_ACTION_ABOVE = XInternAtom( dpy, "_NET_WM_ACTION_ABOVE", False ); @@ -329,86 +330,75 @@ static int NewtWindows_isFullscreenEWMHSupported (Display *dpy, Window w) { for(i=0; i0) { - XChangeProperty( dpy, w, _NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *)&types, ntypes); - XSync(dpy, False); - res = True; - } - } else { - if(enable) { - NewtWindows_setCWAbove(dpy, w); - } - XEvent xev; - long mask = SubstructureNotifyMask | SubstructureRedirectMask ; - int i=0; - - memset ( &xev, 0, sizeof(xev) ); - - xev.type = ClientMessage; - xev.xclient.window = w; - xev.xclient.message_type = _NET_WM_STATE; - xev.xclient.format = 32; + // _NET_WM_STATE: fullscreen and/or above + if( changeFullscreen || changeAbove ) { + { + // _NET_WM_STATE as event to root window + XEvent xev; + long mask = SubstructureNotifyMask | SubstructureRedirectMask ; + int i=0; - xev.xclient.data.l[i++] = ( True == enable ) ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE ; - if( 0 != ( ( _NET_WM_FULLSCREEN & ewmhMask ) & ewmhFlags ) ) { - xev.xclient.data.l[i++] = _NET_WM_STATE_FULLSCREEN; - } - if( 0 != ( ( _NET_WM_ABOVE & ewmhMask ) & ewmhFlags ) ) { - xev.xclient.data.l[i++] = _NET_WM_STATE_ABOVE; - } - xev.xclient.data.l[3] = 1; //source indication for normal applications + memset ( &xev, 0, sizeof(xev) ); + + xev.type = ClientMessage; + xev.xclient.window = w; + xev.xclient.message_type = _NET_WM_STATE; + xev.xclient.format = 32; + + xev.xclient.data.l[i++] = enable ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE ; + if( changeFullscreen ) { + xev.xclient.data.l[i++] = _NET_WM_STATE_FULLSCREEN; + } + if( changeAbove ) { + xev.xclient.data.l[i++] = _NET_WM_STATE_ABOVE; + } + xev.xclient.data.l[3] = 1; //source indication for normal applications - if(i>0) { XSendEvent ( dpy, root, False, mask, &xev ); - res = True; } + // If ABOVE is changed, also change _NET_WM_BYPASS_COMPOSITOR! + if( changeAbove ) { + Atom _NET_WM_BYPASS_COMPOSITOR = XInternAtom( dpy, "_NET_WM_BYPASS_COMPOSITOR", False ); + unsigned long value = enable ? 1 : 0; + XChangeProperty( dpy, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&value, 1); + } + XSync(dpy, False); + res = True; } - XSync(dpy, False); - DBG_PRINT( "X11: reconfigureWindow0 FULLSCREEN EWMH ON %d, ewmhMask 0x%X, ewmhFlags 0x%X, visible %d: %d\n", - enable, ewmhMask, ewmhFlags, isVisible, res); + DBG_PRINT( "X11: setStackingEWMHFlags ON %d, changeFullscreen %d, changeAbove %d, visible %d: %d\n", + enable, changeFullscreen, changeAbove, isVisible, res); return res; } @@ -657,7 +647,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 NewtWindows_setPosSize(dpy, window, x, y, width, height); if( TST_FLAG_IS_ALWAYSONTOP(flags) ) { - NewtWindows_setFullscreenEWMH(dpy, root, window, _NET_WM_ABOVE, True, True); + NewtWindows_setStackingEWMHFlags(dpy, root, window, _NET_WM_STATE_FLAG_ABOVE, True, True); } } @@ -720,15 +710,6 @@ static Bool WaitForReparentNotify( Display *dpy, XEvent *event, XPointer arg ) { } #endif -/** - * KDE cause lost input focus in fullscreen mode. - * Using 'XGrabKeyboard(..)' would prevent the loss, - * but also would disable WM task switcher etc. - * - * #define FS_GRAB_KEYBOARD 1 - * - */ - /* * Class: jogamp_newt_driver_x11_WindowDriver * Method: reconfigureWindow0 @@ -747,21 +728,22 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo XEvent event; Bool isVisible = !TST_FLAG_CHANGE_VISIBILITY(flags) && TST_FLAG_IS_VISIBLE(flags) ; Bool tempInvisible = ( TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_PARENTING(flags) ) && isVisible ; + // Bool tempInvisible = TST_FLAG_CHANGE_PARENTING(flags) && isVisible ; int fsEWMHFlags = 0; if( TST_FLAG_CHANGE_FULLSCREEN(flags) ) { - if( !TST_FLAG_IS_FULLSCREEN_SPAN(flags) ) { // doesn't work w/ spanning across monitors - fsEWMHFlags |= _NET_WM_FULLSCREEN; + if( !TST_FLAG_IS_FULLSCREEN_SPAN(flags) ) { // doesn't work w/ spanning across monitors. See also Bug 770 & Bug 771 + fsEWMHFlags |= _NET_WM_STATE_FLAG_FULLSCREEN; } if( TST_FLAG_IS_FULLSCREEN(flags) ) { if( TST_FLAG_IS_ALWAYSONTOP(flags) ) { - fsEWMHFlags |= _NET_WM_ABOVE; // fs on, above on - } // else { } // fs on, above off + fsEWMHFlags |= _NET_WM_STATE_FLAG_ABOVE; // fs on, above on + } // else { } // fs on, above off } else if( !TST_FLAG_IS_ALWAYSONTOP(flags) ) { - fsEWMHFlags |= _NET_WM_ABOVE; // fs off, above off - } // else { } // fs off, above on + fsEWMHFlags |= _NET_WM_STATE_FLAG_ABOVE; // fs off, above off + } // else { } // fs off, above on } if( TST_FLAG_CHANGE_ALWAYSONTOP(flags) ) { - fsEWMHFlags |= _NET_WM_ABOVE; // toggle above + fsEWMHFlags |= _NET_WM_STATE_FLAG_ABOVE; // toggle above } DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d, parent %p/%p, win %p, %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d (span %d), alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d, tempInvisible %d, fsEWMHFlags %d\n", @@ -780,21 +762,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo !TST_FLAG_IS_FULLSCREEN_SPAN(flags) && ( TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_ALWAYSONTOP(flags) ) ) { Bool enable = TST_FLAG_CHANGE_FULLSCREEN(flags) ? TST_FLAG_IS_FULLSCREEN(flags) : TST_FLAG_IS_ALWAYSONTOP(flags) ; - if( NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, enable) ) { + if( NewtWindows_setStackingEWMHFlags(dpy, root, w, fsEWMHFlags, isVisible, enable) ) { if ( TST_FLAG_CHANGE_FULLSCREEN(flags) && !TST_FLAG_IS_FULLSCREEN(flags) ) { // FS off - restore decoration NewtWindows_setDecorations (dpy, w, TST_FLAG_IS_UNDECORATED(flags) ? False : True); } - #ifdef FS_GRAB_KEYBOARD - if(TST_FLAG_CHANGE_FULLSCREEN(flags)) { - if(TST_FLAG_IS_FULLSCREEN(flags)) { - XGrabKeyboard(dpy, w, True, GrabModeAsync, GrabModeAsync, CurrentTime); - } else { - XUngrabKeyboard(dpy, CurrentTime); - } - } else if(TST_FLAG_CHANGE_ALWAYSONTOP(flags) && !TST_FLAG_IS_ALWAYSONTOP(flags)) { - XUngrabKeyboard(dpy, CurrentTime); - } - #endif + DBG_PRINT( "X11: reconfigureWindow0 X (fast)\n"); return; } } @@ -808,10 +780,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo if( fsEWMHFlags && ( ( TST_FLAG_CHANGE_FULLSCREEN(flags) && !TST_FLAG_IS_FULLSCREEN(flags) ) || ( TST_FLAG_CHANGE_ALWAYSONTOP(flags) && !TST_FLAG_IS_ALWAYSONTOP(flags) ) ) ) { // FS off - NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, False); - #ifdef FS_GRAB_KEYBOARD - XUngrabKeyboard(dpy, CurrentTime); - #endif + NewtWindows_setStackingEWMHFlags(dpy, root, w, fsEWMHFlags, isVisible, False); } if( TST_FLAG_CHANGE_PARENTING(flags) && !TST_FLAG_HAS_PARENT(flags) ) { @@ -844,9 +813,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo XMapRaised(dpy, w); XIfEvent( dpy, &event, WaitForMapNotify, (XPointer) w ); // no need to notify the java side .. just temp change - } - - if( TST_FLAG_CHANGE_VISIBILITY(flags) ) { + } else if( TST_FLAG_CHANGE_VISIBILITY(flags) ) { if( TST_FLAG_IS_VISIBLE(flags) ) { DBG_PRINT( "X11: reconfigureWindow0 VISIBLE ON\n"); XMapRaised(dpy, w); @@ -859,15 +826,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo if( fsEWMHFlags && ( ( TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags) ) || ( TST_FLAG_CHANGE_ALWAYSONTOP(flags) && TST_FLAG_IS_ALWAYSONTOP(flags) ) ) ) { // FS on - NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, True); - #ifdef FS_GRAB_KEYBOARD - if(TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags)) { - XGrabKeyboard(dpy, w, True, GrabModeAsync, GrabModeAsync, CurrentTime); - } - #endif + NewtWindows_requestFocus (dpy, w, True); + NewtWindows_setStackingEWMHFlags(dpy, root, w, fsEWMHFlags, isVisible, True); } - DBG_PRINT( "X11: reconfigureWindow0 X\n"); + DBG_PRINT( "X11: reconfigureWindow0 X (full)\n"); } /* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java index 37ea499df..54c6bdd6c 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java @@ -55,7 +55,8 @@ import java.util.List; import javax.media.nativewindow.util.Dimension; /** - * Tests MonitorMode change w/ changed rotation. + * Tests MonitorMode change w/ changed rotation, + * w/ and w/o fullscreen, pre and post MonitorMode change. *

    * Also tests MonitorMode reset after last Screen is dereferenced, * i.e. MonitorMode should be reinstated. @@ -75,21 +76,14 @@ public class TestScreenMode02aNEWT extends UITestCase { glp = GLProfile.getDefault(); } - @AfterClass - public static void releaseClass() throws InterruptedException { - Thread.sleep(waitTimeShort); - } - static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { Assert.assertNotNull(caps); caps.setOnscreen(onscreen); GLWindow window = GLWindow.create(screen, caps); window.setSize(width, height); - window.addGLEventListener(new GearsES2()); + window.addGLEventListener(new GearsES2(1)); Assert.assertNotNull(window); - window.setVisible(true); - Assert.assertTrue(window.isVisible()); return window; } @@ -100,9 +94,26 @@ public class TestScreenMode02aNEWT extends UITestCase { } @Test - public void testScreenRotationChange01() throws InterruptedException { - Thread.sleep(waitTimeShort); - + public void testScreenRotationChange01_PreWin() throws InterruptedException { + testScreenRotationChangeImpl(true, true, false); + } + + @Test + public void testScreenRotationChange02_PreFull() throws InterruptedException { + testScreenRotationChangeImpl(true, true, true); + } + + @Test + public void testScreenRotationChange11_PostWin() throws InterruptedException { + testScreenRotationChangeImpl(true, false, false); + } + + @Test + public void testScreenRotationChange12_PostFull() throws InterruptedException { + testScreenRotationChangeImpl(true, false, true); + } + + void testScreenRotationChangeImpl(boolean changeMode, boolean preVis, boolean fullscreen) throws InterruptedException { GLCapabilities caps = new GLCapabilities(glp); Assert.assertNotNull(caps); Display display = NewtFactory.createDisplay(null); // local display @@ -111,60 +122,92 @@ public class TestScreenMode02aNEWT extends UITestCase { Assert.assertNotNull(screen); GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); Assert.assertNotNull(window); - - MonitorDevice monitor = window.getMainMonitor(); - List monitorModes = monitor.getSupportedModes(); - if(monitorModes.size()==1) { - // no support .. - System.err.println("Your platform has no ScreenMode change support, sorry"); - destroyWindow(window); - return; + if( preVis ) { + window.setVisible(true); + if( fullscreen ) { + window.setFullscreen(true); + } + } else { + screen.createNative(); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); } - Assert.assertTrue(monitorModes.size()>0); Animator animator = new Animator(window); animator.start(); - - MonitorMode mmCurrent = monitor.getCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); + + final MonitorDevice monitor = window.getMainMonitor(); + final MonitorMode mmOrig = monitor.getOriginalMode(); Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); - if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { - // no rotation support .. - System.err.println("Your platform has no rotation support, sorry"); - destroyWindow(window); - return; + if(changeMode) { + List monitorModes = monitor.getSupportedModes(); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no ScreenMode change support, sorry"); + destroyWindow(window); + return; + } + Assert.assertTrue(monitorModes.size()>0); + + final MonitorMode mmCurrent = monitor.getCurrentMode(); + Assert.assertNotNull(mmCurrent); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); + if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { + // no rotation support .. + System.err.println("Your platform has no rotation support, sorry"); + destroyWindow(window); + return; + } + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode mm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+mm); + monitor.setCurrentMode(mm); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(mm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(mm, monitor.queryCurrentMode()); } - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - MonitorMode sm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+sm); - monitor.setCurrentMode(sm); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(sm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(sm, monitor.queryCurrentMode()); - + + if( !preVis ) { + window.setVisible(true); + if( fullscreen ) { + window.setFullscreen(true); + } + } + Thread.sleep(waitTimeLong); - - // check reset .. - + + if( !preVis && fullscreen ) { + window.setFullscreen(false); + } + + if(changeMode) { + monitor.setCurrentMode(mmOrig); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + Thread.sleep(waitTimeShort); + } + + if( preVis && fullscreen ) { + window.setFullscreen(false); + } + Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window.isNativeValid()); @@ -178,22 +221,6 @@ public class TestScreenMode02aNEWT extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); - - screen.createNative(); // trigger native re-creation - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - screen.destroy(); - - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); } public static void main(String args[]) throws IOException { -- cgit v1.2.3 From 4c34f5980bddcdc84b10cb3bcbb96b365b9d471e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 2 Jul 2013 19:01:27 +0200 Subject: Fix Bug 767: TAB + BS are considered 'printable' - Compromise of 'editor' view and 'font-definition' view. ENTER not. Fix ENTER code: 0xa -> 0xd ! --- .../classes/com/jogamp/newt/event/KeyEvent.java | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index ec05a34ad..156708779 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -319,14 +319,16 @@ public class KeyEvent extends InputEvent if( ( nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || ( nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || ( nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || - ( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { + ( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) || + ( nonPrintableKeys[4].min <= uniChar && uniChar <= nonPrintableKeys[4].max ) ) { return false; } } else { if( ( nonPrintableKeys[0].inclKeyChar && nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || ( nonPrintableKeys[1].inclKeyChar && nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || ( nonPrintableKeys[2].inclKeyChar && nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || - ( nonPrintableKeys[3].inclKeyChar && nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { + ( nonPrintableKeys[3].inclKeyChar && nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) || + ( nonPrintableKeys[4].inclKeyChar && nonPrintableKeys[4].min <= uniChar && uniChar <= nonPrintableKeys[4].max ) ) { return false; } } @@ -381,9 +383,10 @@ public class KeyEvent extends InputEvent this.inclKeyChar = inclKeyChar; } }; - /** Non printable key ranges, currently fixed to an array of size 4. */ + /** Non printable key ranges, currently fixed to an array of size 5. */ public final static NonPrintableRange[] nonPrintableKeys = { - new NonPrintableRange( (short)0x0000, (short)0x001F, true ), // Unicode: Non printable controls: [0x00 - 0x1F] + new NonPrintableRange( (short)0x0000, (short)0x0007, true ), // Unicode: Non printable controls: [0x00 - 0x07] + new NonPrintableRange( (short)0x000A, (short)0x001F, true ), // Unicode: Non printable controls: [0x0A - 0x1F] new NonPrintableRange( (short)0x0061, (short)0x0078, false), // Small 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym - Re-used for Fn (collision) new NonPrintableRange( (short)0x008F, (short)0x009F, true ), // Unicode: Non printable controls: [0x7F - 0x9F], Numpad keys [0x7F - 0x8E] are printable! new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) @@ -415,14 +418,14 @@ public class KeyEvent extends InputEvent static final short VK_FREE06 = (short) 0x06; static final short VK_FREE07 = (short) 0x07; - /** Constant for the BACK SPACE key "\b", matching ASCII. */ + /** Constant for the BACK SPACE key "\b", matching ASCII. Printable! */ public static final short VK_BACK_SPACE = (short) 0x08; - /** Constant for the HORIZ TAB key "\t", matching ASCII. */ + /** Constant for the HORIZ TAB key "\t", matching ASCII. Printable! */ public static final short VK_TAB = (short) 0x09; - /** Constant for the ENTER key, i.e. LINE FEED "\n", matching ASCII. */ - public static final short VK_ENTER = (short) 0x0A; + /** LINE_FEED "\n", matching ASCII, n/a on keyboard. */ + static final short VK_FREE0A = (short) 0x0A; /** Constant for the PAGE DOWN function key. ASCII: Vertical Tabulation. */ public static final short VK_PAGE_DOWN = (short) 0x0B; @@ -430,7 +433,9 @@ public class KeyEvent extends InputEvent /** Constant for the CLEAR key, i.e. FORM FEED, matching ASCII. */ public static final short VK_CLEAR = (short) 0x0C; - static final short VK_FREE0D = (short) 0x0D; + /** Constant for the ENTER key, i.e. CARRIAGE RETURN, matching ASCII. Non printable! */ + public static final short VK_ENTER = (short) 0x0D; + static final short VK_FREE0E = (short) 0x0E; /** Constant for the CTRL function key. ASCII: shift-in. */ -- cgit v1.2.3 From 3856dcc14f0f27a37930ec3f085746ed91d72cff Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 3 Jul 2013 18:33:15 +0200 Subject: WindowImpl.consumeKeyEvent: Reduce DEBUG println and show println after propagating event to show whether it has been consumed. --- src/newt/classes/jogamp/newt/WindowImpl.java | 16 +++++++++------- .../classes/jogamp/newt/driver/windows/WindowDriver.java | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 600035bf6..f449d185f 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2567,16 +2567,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( null != keyboardFocusHandler && !e.isAutoRepeat() ) { consumedE = propagateKeyEvent(e, keyboardFocusHandler); if(DEBUG_KEY_EVENT) { - System.err.println("consumeKeyEvent(kfh): "+e+", keyboardFocusHandler consumed: "+consumedE); + if( consumedE ) { + System.err.println("consumeKeyEvent(kfh): "+e+", consumed: "+consumedE); + } } } - if(DEBUG_KEY_EVENT) { - if( !consumedE ) { - System.err.println("consumeKeyEvent(usr): "+e); + if( !consumedE ) { + for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) { + consumedE = propagateKeyEvent(e, keyListeners.get(i)); + } + if(DEBUG_KEY_EVENT) { + System.err.println("consumeKeyEvent(usr): "+e+", consumed: "+consumedE); } - } - for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) { - consumedE = propagateKeyEvent(e, keyListeners.get(i)); } } diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 7a8e683af..393445db0 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -291,7 +291,7 @@ public class WindowDriver extends WindowImpl { public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { final boolean isModifierKey = KeyEvent.isModifierKey(keySym); // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+ - // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", printableKey "+KeyEvent.isPrintableKey(keyCode)+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); + // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", printableKey "+KeyEvent.isPrintableKey(keyCode, false)+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); // Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0) and RELEASED (t1) // Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0). -- cgit v1.2.3 From 4e6c2aadd7d652db3ba1f35eef1a3d61d6e692d0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 3 Jul 2013 23:06:43 +0200 Subject: Revise commit 4c34f5980bddcdc84b10cb3bcbb96b365b9d471e (Bug 767): TAB, BS and CR/ENTER are printable for NEWT KeyEvent and font handling. Fix regression. - Original behavior was treating CR/ENTER them as printable, lets keep it this way. - KeyEvent: Query these 3 whitespaces upfront, no need to incl. them in 'nonPrintableKeys'. - Fix regression: Native VK_ENTER was not change in commit 4c34f5980bddcdc84b10cb3bcbb96b365b9d471e. --- make/scripts/tests-win.bat | 4 +-- make/scripts/tests-x64-dbg.bat | 3 +-- make/scripts/tests.sh | 8 +++--- .../classes/com/jogamp/graph/font/FontFactory.java | 13 +++++---- .../classes/com/jogamp/newt/event/KeyEvent.java | 31 +++++++++++++--------- src/newt/native/KeyEvent.h | 2 +- .../graph/demos/GPUTextRendererListenerBase01.java | 30 +++++++++++---------- 7 files changed, 51 insertions(+), 40 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 348b6053a..b0815a5a6 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -61,7 +61,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* @@ -120,7 +120,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bN REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index cb40125f2..d0108fdf8 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -41,8 +41,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Dnewt.debug.Window" -set D_ARGS="-Dnewt.debug.Window.KeyEvent" "-Dnewt.debug.Window" -REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" +set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c0c4764fb..2e741b353 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -176,7 +176,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -206,7 +206,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" - D_ARGS="-Djogl.debug.PNGImage" + #D_ARGS="-Djogl.debug.PNGImage" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" @@ -285,7 +285,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -546,7 +546,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTBenchmarkNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage00NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* diff --git a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java index bbdfc0e9f..d2824b9dc 100644 --- a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java +++ b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java @@ -93,10 +93,13 @@ public class FontFactory { } public static boolean isPrintableChar( char c ) { - Character.UnicodeBlock block = Character.UnicodeBlock.of( c ); - return (!Character.isISOControl(c)) && - c != 0 && - block != null && - block != Character.UnicodeBlock.SPECIALS; + if( Character.isWhitespace(c) ) { + return true; + } + if( 0 == c || Character.isISOControl(c) ) { + return false; + } + final Character.UnicodeBlock block = Character.UnicodeBlock.of( c ); + return block != null && block != Character.UnicodeBlock.SPECIALS; } } diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 156708779..085f598dc 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -312,27 +312,25 @@ public class KeyEvent extends InputEvent * @param isKeyChar true if uniChar is a key character, otherwise a virtual key code */ public static boolean isPrintableKey(final short uniChar, final boolean isKeyChar) { - if( VK_UNDEFINED == uniChar ) { - return false; + if ( VK_BACK_SPACE == uniChar || VK_TAB == uniChar || VK_ENTER == uniChar ) { + return true; } if( !isKeyChar ) { if( ( nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || ( nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || - ( nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || - ( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) || - ( nonPrintableKeys[4].min <= uniChar && uniChar <= nonPrintableKeys[4].max ) ) { + ( nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || + ( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { return false; } } else { if( ( nonPrintableKeys[0].inclKeyChar && nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || ( nonPrintableKeys[1].inclKeyChar && nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || ( nonPrintableKeys[2].inclKeyChar && nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || - ( nonPrintableKeys[3].inclKeyChar && nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) || - ( nonPrintableKeys[4].inclKeyChar && nonPrintableKeys[4].min <= uniChar && uniChar <= nonPrintableKeys[4].max ) ) { + ( nonPrintableKeys[3].inclKeyChar && nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { return false; } } - return true; + return VK_UNDEFINED != uniChar; } /** @@ -383,10 +381,19 @@ public class KeyEvent extends InputEvent this.inclKeyChar = inclKeyChar; } }; - /** Non printable key ranges, currently fixed to an array of size 5. */ + /** + * Non printable key ranges, currently fixed to an array of size 4. + *

    + * Not included, queried upfront: + *

      + *
    • {@link #VK_BACK_SPACE}
    • + *
    • {@link #VK_TAB}
    • + *
    • {@link #VK_ENTER}
    • + *
    + *

    + */ public final static NonPrintableRange[] nonPrintableKeys = { - new NonPrintableRange( (short)0x0000, (short)0x0007, true ), // Unicode: Non printable controls: [0x00 - 0x07] - new NonPrintableRange( (short)0x000A, (short)0x001F, true ), // Unicode: Non printable controls: [0x0A - 0x1F] + new NonPrintableRange( (short)0x0000, (short)0x001F, true ), // Unicode: Non printable controls: [0x00 - 0x1F], see exclusion above new NonPrintableRange( (short)0x0061, (short)0x0078, false), // Small 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym - Re-used for Fn (collision) new NonPrintableRange( (short)0x008F, (short)0x009F, true ), // Unicode: Non printable controls: [0x7F - 0x9F], Numpad keys [0x7F - 0x8E] are printable! new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) @@ -433,7 +440,7 @@ public class KeyEvent extends InputEvent /** Constant for the CLEAR key, i.e. FORM FEED, matching ASCII. */ public static final short VK_CLEAR = (short) 0x0C; - /** Constant for the ENTER key, i.e. CARRIAGE RETURN, matching ASCII. Non printable! */ + /** Constant for the ENTER key, i.e. CARRIAGE RETURN, matching ASCII. Printable! */ public static final short VK_ENTER = (short) 0x0D; static final short VK_FREE0E = (short) 0x0E; diff --git a/src/newt/native/KeyEvent.h b/src/newt/native/KeyEvent.h index 59977d565..c0a366a17 100644 --- a/src/newt/native/KeyEvent.h +++ b/src/newt/native/KeyEvent.h @@ -39,9 +39,9 @@ #define J_VK_PRINTSCREEN ( 0x05U ) #define J_VK_BACK_SPACE ( 0x08U ) #define J_VK_TAB ( 0x09U ) -#define J_VK_ENTER ( 0x0AU ) #define J_VK_PAGE_DOWN ( 0x0BU ) #define J_VK_CLEAR ( 0x0CU ) +#define J_VK_ENTER ( 0x0DU ) #define J_VK_SHIFT ( 0x0FU ) #define J_VK_PAGE_UP ( 0x10U ) #define J_VK_CONTROL ( 0x11U ) diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java index 31377025a..1dc104cbb 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java @@ -269,27 +269,27 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB } public class KeyAction implements KeyListener { - public void keyPressed(KeyEvent arg0) { + public void keyPressed(KeyEvent e) { if(userInput) { return; } - - if(arg0.getKeyCode() == KeyEvent.VK_3) { + final short s = e.getKeySymbol(); + if(s == KeyEvent.VK_3) { fontIncr(10); } - else if(arg0.getKeyCode() == KeyEvent.VK_4) { + else if(s == KeyEvent.VK_4) { fontIncr(-10); } - else if(arg0.getKeyCode() == KeyEvent.VK_H) { + else if(s == KeyEvent.VK_H) { switchHeadBox(); } - else if(arg0.getKeyCode() == KeyEvent.VK_F) { + else if(s == KeyEvent.VK_F) { drawFPS = !drawFPS; } - else if(arg0.getKeyCode() == KeyEvent.VK_SPACE) { + else if(s == KeyEvent.VK_SPACE) { nextFontSet(); } - else if(arg0.getKeyCode() == KeyEvent.VK_I) { + else if(s == KeyEvent.VK_I) { userInput = true; setIgnoreInput(true); } @@ -300,15 +300,17 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB return; } if(userInput) { - char c = e.getKeyChar(); - - if(c == 0x0d) { + final short k = e.getKeySymbol(); + if( KeyEvent.VK_ENTER == k ) { userInput = false; setIgnoreInput(false); - } else if(c == 0x08 && userString.length()>0) { + } else if( KeyEvent.VK_BACK_SPACE == k && userString.length()>0) { userString.deleteCharAt(userString.length()-1); - } else if( font.isPrintableChar( c ) ) { - userString.append(c); + } else { + final char c = e.getKeyChar(); + if( font.isPrintableChar( c ) ) { + userString.append(c); + } } } } -- cgit v1.2.3 From 98ab29dded5d8f8e482b02a8782f1dc87bb3a1a5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 01:41:15 +0200 Subject: Remove deprecated methods. - Quaternion.isEmpty() - Texture.dispose(GL) - GLContext.getGLVersionMajor() / ..Minor() - GLContextImpl.bindPbufferToTexture() / releasePbufferFromTexture() - MouseEvent.getWheelRotation() - --- .../classes/com/jogamp/opengl/math/Quaternion.java | 16 ++----------- .../com/jogamp/opengl/util/texture/Texture.java | 6 ----- src/jogl/classes/javax/media/opengl/GLContext.java | 4 ---- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 20 ++-------------- .../classes/com/jogamp/newt/event/MouseEvent.java | 27 ---------------------- .../junit/graph/demos/GPUUISceneGLListener0A.java | 4 +++- .../jogl/demos/es2/TextureSequenceCubeES2.java | 6 +++-- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 6 +++-- 8 files changed, 15 insertions(+), 74 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java index f1a3f8be2..c6bf44f6d 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java @@ -330,20 +330,8 @@ public class Quaternion { } /** - * Check if this quaternion is empty, ie (0,0,0,1) - * - * @return true if empty, false otherwise - * @deprecated use {@link #isIdentity()} instead - */ - @Deprecated - public boolean isEmpty() { - if (w == 1 && x == 0 && y == 0 && z == 0) - return true; - return false; - } - - /** - * Check if this quaternion represents an identity matrix, for rotation. + * Check if this quaternion represents an identity matrix for rotation, + * , ie (0,0,0,1). * * @return true if it is an identity rep., false otherwise */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java index d6a8090fb..c52999224 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java @@ -289,12 +289,6 @@ public class Texture { gl.glBindTexture(target, texID); } - /** - * @deprecated use {@link #destroy(GL)} - */ - public final void dispose(GL gl) throws GLException { - destroy(gl); - } /** * Destroys the native resources used by this texture object. * diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 84d371ac6..684d0de65 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -671,10 +671,6 @@ public abstract class GLContext { return ctxVersionString; } - /** @deprecated Use {@link #getGLVersionNumber()} */ - public final int getGLVersionMajor() { return ctxVersion.getMajor(); } - /** @deprecated Use {@link #getGLVersionNumber()} */ - public final int getGLVersionMinor() { return ctxVersion.getMinor(); } /** * Returns this context OpenGL version. * @see #getGLSLVersionNumber() diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 8671b045d..f896c95ee 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1098,22 +1098,6 @@ public abstract class GLContextImpl extends GLContext { */ public abstract ProcAddressTable getPlatformExtProcAddressTable(); - /** - * Pbuffer support; given that this is a GLContext associated with a - * pbuffer, binds this pbuffer to its texture target. - * @throws GLException if not implemented (default) - * @deprecated use FBO/GLOffscreenAutoDrawable instead of pbuffer - */ - public void bindPbufferToTexture() { throw new GLException("not implemented"); } - - /** - * Pbuffer support; given that this is a GLContext associated with a - * pbuffer, releases this pbuffer from its texture target. - * @throws GLException if not implemented (default) - * @deprecated use FBO/GLOffscreenAutoDrawable instead of pbuffer - */ - public void releasePbufferFromTexture() { throw new GLException("not implemented"); } - public abstract ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3); /** Maps the given "platform-independent" function name to a real function @@ -1515,8 +1499,8 @@ public abstract class GLContextImpl extends GLContext { int i = 0; final String MesaSP = "Mesa "; - final String MesaRendererAMDsp = " AMD "; - final String MesaRendererIntelsp = "Intel(R)"; + // final String MesaRendererAMDsp = " AMD "; + // final String MesaRendererIntelsp = "Intel(R)"; final boolean hwAccel = 0 == ( ctp & GLContext.CTX_IMPL_ACCEL_SOFT ); final boolean compatCtx = 0 != ( ctp & GLContext.CTX_PROFILE_COMPAT ); final boolean isDriverMesa = glRenderer.contains(MesaSP) || glRenderer.contains("Gallium "); diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 18c8285f7..93bbcc0b9 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -251,33 +251,6 @@ public class MouseEvent extends InputEvent return normalized ? pressure[index] / maxPressure : pressure[index]; } - /** - * Usually a wheel rotation of > 0.0f is up, - * and < 0.0f is down. - *

    - * Usually a wheel rotations is considered a vertical scroll.
    - * If {@link #isShiftDown()}, a wheel rotations is - * considered a horizontal scroll, where shift-up = left = > 0.0f, - * and shift-down = right = < 0.0f. - *

    - *

    - * However, on some OS this might be flipped due to the OS default behavior. - * The latter is true for OS X 10.7 (Lion) for example. - *

    - *

    - * The events will be send usually in steps of one, ie. -1.0f and 1.0f. - * Higher values may result due to fast scrolling. - * Fractional values may result due to slow scrolling with high resolution devices. - *

    - *

    - * The button number refers to the wheel number. - *

    - * @deprecated Use {@link #getRotation()} - */ - public float getWheelRotation() { - return isShiftDown() ? rotationXYZ[0] : rotationXYZ[1] ; - } - /** * Returns a 3-component float array filled with the values of the rotational axis * in the following order: horizontal-, vertical- and z-axis. diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java index f43a933e4..2e8ad02d8 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java @@ -428,7 +428,9 @@ public class GPUUISceneGLListener0A implements GLEventListener { @Override public void mouseWheelMoved(MouseEvent e) { - zoom += 2f*e.getWheelRotation(); + if( !e.isShiftDown() ) { + zoom += 2f*e.getRotation()[0]; + } } } } \ No newline at end of file diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index 25f8740d4..d8e3df5c0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -133,8 +133,10 @@ public class TextureSequenceCubeES2 implements GLEventListener { } } public void mouseWheelMoved(MouseEvent e) { - zoom += e.getWheelRotation()/10f; - System.err.println("zoom: "+zoom); + if( !e.isShiftDown() ) { + zoom += e.getRotation()[0]/10f; + System.err.println("zoom: "+zoom); + } } }; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index e17c9e88b..6b618bd5b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -140,8 +140,10 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { // prevMouseY = y; } public void mouseWheelMoved(MouseEvent e) { - zoom += e.getWheelRotation()/10f; - System.err.println("zoom: "+zoom); + if( !e.isShiftDown() ) { + zoom += e.getRotation()[0]/10f; + System.err.println("zoom: "+zoom); + } } }; -- cgit v1.2.3 From fa6e868a72b8fb3de8c96afbd71ab4d3ad33f6b6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 14:46:28 +0200 Subject: Revisit Bug 770 and Bug 771: Only use FLAG_IS_FULLSCREEN_SPAN if required; At MonitoMode change, reset fullscreen if FLAG_IS_FULLSCREEN_SPAN is supported. - Bug 770: Only use FLAG_IS_FULLSCREEN_SPAN if required - If X11 WindowDriver _and_ virtual-screen-size > fullscreenViewport, - else we still use _NET_WM_STATE_FULLSCREEN on X11! - Bug 771: At MonitoMode change, reset fullscreen if FLAG_IS_FULLSCREEN_SPAN is supported - Since we may still use _NET_WM_STATE_FULLSCREEN on X11: - Pause fullscreen at monitorModeChangeNotify(..) - Resume fullscreen at monitorModeChanged(..) --- make/scripts/tests.sh | 4 +- src/newt/classes/jogamp/newt/ScreenImpl.java | 10 ++-- src/newt/classes/jogamp/newt/WindowImpl.java | 67 ++++++++++++++++------ src/newt/classes/jogamp/newt/driver/x11/RandR.java | 6 +- .../classes/jogamp/newt/driver/x11/RandR11.java | 7 +++ .../classes/jogamp/newt/driver/x11/RandR13.java | 46 +++------------ .../jogamp/newt/driver/x11/ScreenDriver.java | 34 ++++++++--- .../jogamp/newt/driver/x11/WindowDriver.java | 47 +++++++++++---- .../test/junit/newt/mm/TestScreenMode01dNEWT.java | 1 + .../test/junit/newt/mm/TestScreenMode02aNEWT.java | 4 ++ 10 files changed, 142 insertions(+), 84 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 640e6a01d..8137f5f0f 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -406,8 +406,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 422d5b06c..c02f4f288 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -284,12 +284,12 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { vOriginSize.setWidth(usrSize.getWidth()); vOriginSize.setHeight(usrSize.getHeight()); if(DEBUG) { - System.err.println("User virtual screen viewport "+vOriginSize); + System.err.println("Update user virtual screen viewport @ "+Thread.currentThread().getName()+": "+vOriginSize); } } else { calcVirtualScreenOriginAndSize(vOriginSize); if(DEBUG) { - System.err.println("Detected virtual screen viewport "+vOriginSize); + System.err.println("Updated virtual screen viewport @ "+Thread.currentThread().getName()+": "+vOriginSize); } } } @@ -396,7 +396,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { @Override public void monitorModeChangeNotify(MonitorEvent me) { if(DEBUG) { - System.err.println("monitorModeChangeNotify: "+me); + System.err.println("monitorModeChangeNotify @ "+Thread.currentThread().getName()+": "+me); } for(int i=0; i "+newViewport); + System.err.println("Screen.updateMonitorViewport["+i+"] @ "+Thread.currentThread().getName()+": "+monitor.getViewport()+" -> "+newViewport); } if( null != newViewport ) { monitor.setViewportValue(newViewport); @@ -424,7 +424,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { updateVirtualScreenOriginAndSize(); } if(DEBUG) { - System.err.println("monitorModeChanged: success "+success+", "+me); + System.err.println("monitorModeChangeNotify @ "+Thread.currentThread().getName()+": success "+success+", "+me); } for(int i=0; i fullscreenMonitors = null; private boolean fullscreenUseMainMonitor = true; + private boolean fullscreenUseSpanningMode = true; // spanning mode: fake full screen, only on certain platforms private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user) private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets @@ -251,6 +252,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreen = false; fullscreenMonitors = null; fullscreenUseMainMonitor = true; + fullscreenUseSpanningMode = false; hasFocus = false; parentWindowHandle = 0; } @@ -560,6 +562,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @see #positionChanged(boolean,int, int) */ protected abstract boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags); + + /** + * Tests whether a single reconfigure flag is supported by implementation. + *

    + * Default is all but {@link #FLAG_IS_FULLSCREEN_SPAN} + *

    + */ + protected boolean isReconfigureFlagSupported(int changeFlags) { + return 0 == ( changeFlags & FLAG_IS_FULLSCREEN_SPAN ); + } protected int getReconfigureFlags(int changeFlags, boolean visible) { return changeFlags |= ( ( 0 != getParentWindowHandle() ) ? FLAG_HAS_PARENT : 0 ) | @@ -1018,6 +1030,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreen = false; fullscreenMonitors = null; fullscreenUseMainMonitor = true; + fullscreenUseSpanningMode = false; hasFocus = false; parentWindowHandle = 0; @@ -1874,7 +1887,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int x,y,w,h; - final RectangleImmutable viewport; + final RectangleImmutable sviewport = screen.getViewport(); + final RectangleImmutable viewport; final int fs_span_flag; if(fullscreen) { if( null == fullscreenMonitors ) { @@ -1885,19 +1899,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreenMonitors = getScreen().getMonitorDevices(); } } - /** - * Bug 770: - * _NET_WM_STATE_FULLSCREEN may result in ConfigureNotify event w/ virtual screen size, instead of monitor-mode size (NV + Fglrx). - * ConfigureNotify reflects the actual size of the window and is being propagated - * to NEWT and the GLEventListener. - * With Mesa/Intel open-source driver, the correct desired monitor mode size is reported - * at least on one test machine here. - * - * Bug 771: Implementation requires not to use _NET_WM_STATE_FULLSCREEN! - */ - // fs_span_flag = monitors.size() > 1 ? FLAG_IS_FULLSCREEN_SPAN : 0 ; - fs_span_flag = FLAG_IS_FULLSCREEN_SPAN; viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors); + if( isReconfigureFlagSupported(FLAG_IS_FULLSCREEN_SPAN) && + ( fullscreenMonitors.size() > 1 || sviewport.compareTo(viewport) > 0 ) ) { + fullscreenUseSpanningMode = true; + fs_span_flag = FLAG_IS_FULLSCREEN_SPAN; + } else { + fullscreenUseSpanningMode = false; + fs_span_flag = 0; + } nfs_x = getX(); nfs_y = getY(); nfs_width = getWidth(); @@ -1908,6 +1918,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer h = viewport.getHeight(); } else { fullscreenUseMainMonitor = true; + fullscreenUseSpanningMode = false; fullscreenMonitors = null; fs_span_flag = 0; viewport = null; @@ -1932,7 +1943,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ - ", virtl-size: "+screen.getWidth()+"x"+screen.getHeight()+", monitorsViewport "+viewport); + ", virtl-screenSize: "+sviewport+", monitorsViewport "+viewport+ + ", spanning "+fullscreenUseSpanningMode+" @ "+Thread.currentThread().getName()); } final DisplayImpl display = (DisplayImpl) screen.getDisplay(); @@ -1991,6 +2003,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer synchronized(fullScreenAction) { fullscreenMonitors = monitors; fullscreenUseMainMonitor = useMainMonitor; + fullscreenUseSpanningMode = false; if( fullScreenAction.init(fullscreen) ) { if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { // enable fullscreen on offscreen instance @@ -2021,21 +2034,33 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class MonitorModeListenerImpl implements MonitorModeListener { boolean animatorPaused = false; boolean hadFocus = false; + boolean fullscreenPaused = false; + List _fullscreenMonitors = null; + boolean _fullscreenUseMainMonitor = true; public void monitorModeChangeNotify(MonitorEvent me) { hadFocus = hasFocus(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.monitorModeChangeNotify: hadFocus "+hadFocus+", "+me); + System.err.println("Window.monitorModeChangeNotify: hadFocus "+hadFocus+", "+me+" @ "+Thread.currentThread().getName()); } if(null!=lifecycleHook) { animatorPaused = lifecycleHook.pauseRenderingAction(); } + if( fullscreen && isReconfigureFlagSupported(FLAG_IS_FULLSCREEN_SPAN) ) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.monitorModeChangeNotify: FS Pause"); + } + fullscreenPaused = true; + _fullscreenMonitors = fullscreenMonitors; + _fullscreenUseMainMonitor = fullscreenUseMainMonitor; + setFullscreenImpl(false, true, null); + } } public void monitorModeChanged(MonitorEvent me, boolean success) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.monitorModeChanged: hadFocus "+hadFocus+", "+me+", success: "+success); + System.err.println("Window.monitorModeChanged: hadFocus "+hadFocus+", "+me+", success: "+success+" @ "+Thread.currentThread().getName()); } if(success) { @@ -2043,7 +2068,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Didn't pass above notify method. probably detected screen change after it happened. animatorPaused = lifecycleHook.pauseRenderingAction(); } - if( !fullscreen ) { + if( !fullscreen && !fullscreenPaused ) { // Simply move/resize window to fit in virtual screen if required final RectangleImmutable viewport = screen.getViewport(); if( viewport.getWidth() > 0 && viewport.getHeight() > 0 ) { // failsafe @@ -2059,6 +2084,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer setSize(viewport.getWidth(), viewport.getHeight()); } } + } else if( fullscreenPaused ){ + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.monitorModeChanged: FS Restore"); + } + setFullscreenImpl(true, _fullscreenUseMainMonitor, _fullscreenMonitors); + fullscreenPaused = false; + _fullscreenMonitors = null; + _fullscreenUseMainMonitor = true; } else { // If changed monitor is part of this fullscreen mode, reset size! (Bug 771) final MonitorDevice md = me.getMonitor(); diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR.java b/src/newt/classes/jogamp/newt/driver/x11/RandR.java index 769ebe225..e39a6c63a 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR.java @@ -29,6 +29,8 @@ package jogamp.newt.driver.x11; import java.util.List; +import javax.media.nativewindow.util.RectangleImmutable; + import jogamp.newt.MonitorModeProps; import com.jogamp.common.util.VersionNumber; @@ -78,5 +80,7 @@ public interface RandR { int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, MonitorModeProps.Cache cache, final int crt_idx); int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_idx); int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx); - boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode); + boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode); + + public void updateScreenViewport(final long dpy, final ScreenDriver screen, RectangleImmutable viewport); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java index 58468e112..877607f72 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java @@ -27,6 +27,8 @@ */ package jogamp.newt.driver.x11; +import javax.media.nativewindow.util.RectangleImmutable; + import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; @@ -333,6 +335,11 @@ class RandR11 implements RandR { } return done; } + + @Override + public final void updateScreenViewport(final long dpy, final ScreenDriver screen, RectangleImmutable viewport) { + // nop + } /** @return int[] { rot1, .. } */ private static native int[] getAvailableScreenRotations0(long display, int screen_index); diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java index 375cffe42..ac83fc5f2 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java @@ -29,6 +29,8 @@ package jogamp.newt.driver.x11; import java.util.Iterator; +import javax.media.nativewindow.util.RectangleImmutable; + import jogamp.newt.MonitorModeProps; import com.jogamp.common.util.IntLongHashMap; @@ -235,54 +237,20 @@ class RandR13 implements RandR { } finally { releaseScreenResourceHandle(screenResources); } - /*** - * TODO: Would need a complete re-layout of crt positions, - * which is _not_ implicit by XRandR .. sadly. - * - if( res ) { - updateScreenViewport(dpy, screen, monitor); - } */ return res; } - /** See above .. - private final void updateScreenViewport(final long dpy, final ScreenDriver screen, MonitorDevice monitor) { + @Override + public final void updateScreenViewport(final long dpy, final ScreenDriver screen, final RectangleImmutable viewport) { final int screen_idx = screen.getIndex(); final long screenResources = getScreenResourceHandle(dpy, screen_idx); try { - RectangleImmutable newViewp = null; - final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, monitor.getId()); - try { - final int[] vprops = getMonitorViewport0(monitorInfo); - if( null != vprops ) { - newViewp = new Rectangle(vprops[0], vprops[1], vprops[2], vprops[3]); - } - System.err.println("XXX setScreenViewport: newVp "+newViewp); - } finally { - releaseMonitorInfoHandle(monitorInfo); - } - if( null != newViewp ) { - final List monitors = screen.getMonitorDevices(); - final ArrayList viewports = new ArrayList(); - for(int i=0; i "+newScrnViewp); - setScreenViewport0(dpy, screen_idx, screenResources, newScrnViewp.getX(), newScrnViewp.getY(), newScrnViewp.getWidth(), newScrnViewp.getHeight()); - } + setScreenViewport0(dpy, screen_idx, screenResources, viewport.getX(), viewport.getY(), viewport.getWidth(), viewport.getHeight()); } finally { dumpInfo0(dpy, screen_idx, screenResources); releaseScreenResourceHandle(screenResources); - } - } */ + } + } private static native long getScreenResources0(long display, int screen_index); private static native void freeScreenResources0(long screenResources); diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index 19a69a3f9..1335f5697 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -38,6 +38,7 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.RectangleImmutable; import jogamp.nativewindow.x11.X11Util; import jogamp.newt.Debug; @@ -218,14 +219,31 @@ public class ScreenDriver extends ScreenImpl { @Override protected void calcVirtualScreenOriginAndSize(final Rectangle vOriginSize) { - runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(getWidth0(dpy, screen_idx)); - vOriginSize.setHeight(getHeight0(dpy, screen_idx)); - return null; - } } ); + final RectangleImmutable ov = (RectangleImmutable) getViewport().cloneMutable(); + /** + if( null != rAndR && rAndR.getVersion().compareTo(RandR.version130) >= 0 && getMonitorDevices().size()>0 ) { + super.calcVirtualScreenOriginAndSize(vOriginSize); + if( DEBUG ) { + System.err.println("X11Screen.calcVirtualScreenOriginAndSize: UpdatingViewport "+ov+" -> "+vOriginSize); + } + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + rAndR.updateScreenViewport(dpy, ScreenDriver.this, vOriginSize); + return null; + } } ); + } else */ { + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(getWidth0(dpy, screen_idx)); + vOriginSize.setHeight(getHeight0(dpy, screen_idx)); + return null; + } } ); + if( DEBUG ) { + System.err.println("X11Screen.calcVirtualScreenOriginAndSize: Querying X11: "+ov+" -> "+vOriginSize); + } + } } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index aec7f310e..4786ea04f 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -65,6 +65,7 @@ public class WindowDriver extends WindowImpl { public WindowDriver() { } + @Override protected void createNativeImpl() { final ScreenDriver screen = (ScreenDriver) getScreen(); final DisplayDriver display = (DisplayDriver) screen.getDisplay(); @@ -109,6 +110,7 @@ public class WindowDriver extends WindowImpl { } } + @Override protected void closeNativeImpl() { if(0!=windowHandleClose && null!=getScreen() ) { DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); @@ -133,6 +135,18 @@ public class WindowDriver extends WindowImpl { } } + /** + *

    + * X11 Window supports {@link #FLAG_IS_FULLSCREEN_SPAN} + *

    + * {@inheritDoc} + */ + @Override + protected boolean isReconfigureFlagSupported(int changeFlags) { + return true; // all flags! + } + + @Override protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, int flags) { if(DEBUG_IMPLEMENTATION) { System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); @@ -148,14 +162,16 @@ public class WindowDriver extends WindowImpl { _x = x; _y = y; } - if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) { - tempAlwaysOnTop = true; - flags |= FLAG_IS_ALWAYSONTOP; - if(DEBUG_IMPLEMENTATION) { - System.err.println("X11Window reconfig.2: temporary "+getReconfigureFlagsAsString(null, flags)); + if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags ) ) { + if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 != ( FLAG_IS_FULLSCREEN_SPAN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) { + tempFSAlwaysOnTop = true; + flags |= FLAG_IS_ALWAYSONTOP; + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window reconfig.2: temporary "+getReconfigureFlagsAsString(null, flags)); + } + } else { + tempFSAlwaysOnTop = false; } - } else { - tempAlwaysOnTop = false; } final int fflags = flags; final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); @@ -169,7 +185,7 @@ public class WindowDriver extends WindowImpl { }); return true; } - volatile boolean tempAlwaysOnTop = false; + volatile boolean tempFSAlwaysOnTop = false; /** *

    @@ -177,9 +193,13 @@ public class WindowDriver extends WindowImpl { *

    * {@inheritDoc} */ + @Override protected void focusChanged(boolean defer, boolean focusGained) { - if( tempAlwaysOnTop && hasFocus() != focusGained && isNativeValid() ) { + if( tempFSAlwaysOnTop && hasFocus() != focusGained && isNativeValid() ) { final int flags = getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible()) | ( focusGained ? FLAG_IS_ALWAYSONTOP : 0 ); + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window reconfig.3 (focus): temporary "+getReconfigureFlagsAsString(null, flags)); + } final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { @@ -192,8 +212,7 @@ public class WindowDriver extends WindowImpl { } super.focusChanged(defer, focusGained); } - - + protected void reparentNotify(long newParentWindowHandle) { if(DEBUG_IMPLEMENTATION) { final long p0 = getParentWindowHandle(); @@ -201,6 +220,7 @@ public class WindowDriver extends WindowImpl { } } + @Override protected void requestFocusImpl(final boolean force) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { @@ -248,6 +268,7 @@ public class WindowDriver extends WindowImpl { }); } + @Override protected Point getLocationOnScreenImpl(final int x, final int y) { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Point run(long dpy) { @@ -256,6 +277,7 @@ public class WindowDriver extends WindowImpl { } ); } + @Override protected void updateInsetsImpl(Insets insets) { // nop - using event driven insetsChange(..) } @@ -304,7 +326,8 @@ public class WindowDriver extends WindowImpl { } super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); } - + + /** Called by native TK */ protected final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar0, String keyString) { // handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); final boolean isModifierKey = KeyEvent.isModifierKey(keyCode); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java index afb26d75c..c480d1759 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java @@ -328,6 +328,7 @@ public class TestScreenMode01dNEWT extends UITestCase { System.err.println("[0] set FS pre X: "+window.isFullscreen()); } + Thread.sleep(waitTimeShort); System.err.println("[0] set current: "+monitorMode); monitor.setCurrentMode(monitorMode); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java index f261a24a5..f10477333 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java @@ -138,6 +138,8 @@ public class TestScreenMode02aNEWT extends UITestCase { final MonitorMode mmOrig = monitor.getOriginalMode(); Assert.assertNotNull(mmOrig); if(changeMode) { + Thread.sleep(waitTimeShort); + List monitorModes = monitor.getSupportedModes(); if(monitorModes.size()==1) { // no support .. @@ -196,6 +198,8 @@ public class TestScreenMode02aNEWT extends UITestCase { } if(changeMode) { + Thread.sleep(waitTimeShort); + // manual restore! monitor.setCurrentMode(mmOrig); Assert.assertFalse(monitor.isModeChangedByUs()); -- cgit v1.2.3 From 99479bf3197cde8e89c5b499d135417863d521c7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 20:19:35 +0200 Subject: NEWT: Using WeakReferences for global cache of Display, Screen and Window instances; Removing ref. at API destroy() is wrong ; Allow GC to clear .. - Removing ref. at API destroy() is wrong - Since all instances can be recreated, removing ref at destroy() is simply wrong. - Keep weak references until GC collects, i.e. user does not claim them anymore. - Safe for Display, since it holds it's EDT thread. - Window/Screen .. if user abandons reference .. nothing we can do here. - Allow GC to clear .. No need to hold ref loonger than user. --- make/scripts/tests.sh | 5 +- .../opengl/macosx/cgl/MacOSXCGLDrawable.java | 6 +- src/newt/classes/com/jogamp/newt/Display.java | 66 ++++++++++++++++------ src/newt/classes/com/jogamp/newt/Screen.java | 56 ++++++++++++++---- src/newt/classes/jogamp/newt/DisplayImpl.java | 60 ++++++++++---------- src/newt/classes/jogamp/newt/ScreenImpl.java | 29 +++++----- src/newt/classes/jogamp/newt/WindowImpl.java | 33 +++++++---- 7 files changed, 169 insertions(+), 86 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 73012518d..1ba0a36c6 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -136,6 +136,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" @@ -400,14 +401,14 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT +testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index 910158d1f..4bd7bc994 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -117,8 +117,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { createdContexts.add(new WeakReference(osxCtx)); } else { for(int i=0; i ref = createdContexts.get(i); - final MacOSXCGLContext _ctx = ref.get(); + final MacOSXCGLContext _ctx = createdContexts.get(i).get(); if( _ctx == null || _ctx == ctx) { createdContexts.remove(i); } else { @@ -134,8 +133,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { if(doubleBuffered) { synchronized (createdContexts) { for(int i=0; i ref = createdContexts.get(i); - final MacOSXCGLContext ctx = ref.get(); + final MacOSXCGLContext ctx = createdContexts.get(i).get(); if (ctx != null) { ctx.swapBuffers(); i++; diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index d6ddd9613..4f5df6c70 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -31,6 +31,7 @@ package com.jogamp.newt; import com.jogamp.newt.util.EDTUtil; import jogamp.newt.Debug; +import java.lang.ref.WeakReference; import java.util.*; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -178,16 +179,16 @@ public abstract class Display { public abstract void dispatchMessages(); // Global Displays - protected static final ArrayList displayList = new ArrayList(); + protected static final ArrayList> displayList = new ArrayList>(); protected static int displaysActive = 0; public static void dumpDisplayList(String prefix) { synchronized(displayList) { - Iterator i = displayList.iterator(); System.err.println(prefix+" DisplayList[] entries: "+displayList.size()+" - "+getThreadName()); - for(int j=0; i.hasNext(); j++) { - Display d = i.next(); - System.err.println(" ["+j+"] : "+d); + final Iterator> ri = displayList.iterator(); + for(int j=0; ri.hasNext(); j++) { + final Display d = ri.next().get(); + System.err.println(" ["+j+"] : "+d+", GC'ed "+(null==d)); } } } @@ -216,29 +217,62 @@ public abstract class Display { return getDisplayOfImpl(type, name, fromIndex, -1, shared); } - private static Display getDisplayOfImpl(String type, String name, int fromIndex, int incr, boolean shared) { + private static Display getDisplayOfImpl(String type, String name, final int fromIndex, final int incr, boolean shared) { synchronized(displayList) { int i = fromIndex >= 0 ? fromIndex : displayList.size() - 1 ; while( ( incr > 0 ) ? i < displayList.size() : i >= 0 ) { - Display display = (Display) displayList.get(i); - if( display.getType().equals(type) && - display.getName().equals(name) && - ( !shared || shared && !display.isExclusive() ) - ) { - return display; + final Display display = (Display) displayList.get(i).get(); + if( null == display ) { + // Clear GC'ed dead reference entry! + displayList.remove(i); + if( incr < 0 ) { + // decrease + i+=incr; + } // else nop - remove shifted subsequent elements to the left + } else { + if( display.getType().equals(type) && + display.getName().equals(name) && + ( !shared || shared && !display.isExclusive() ) + ) { + return display; + } + i+=incr; } - i+=incr; } } return null; } - + + protected static void addDisplay2List(Display display) { + synchronized(displayList) { + // GC before add + int i=0; + while( i < displayList.size() ) { + if( null == displayList.get(i).get() ) { + displayList.remove(i); + } else { + i++; + } + } + displayList.add(new WeakReference(display)); + } + } + /** Returns the global display collection */ - @SuppressWarnings("unchecked") public static Collection getAllDisplays() { ArrayList list; synchronized(displayList) { - list = (ArrayList) displayList.clone(); + list = new ArrayList(); + int i = 0; + while( i < displayList.size() ) { + final Display d = displayList.get(i).get(); + if( null == d ) { + displayList.remove(i); + } else { + list.add( displayList.get(i).get() ); + i++; + } + } } return list; } diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index cf8145561..f56ee344b 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -29,6 +29,8 @@ package com.jogamp.newt; import com.jogamp.newt.event.MonitorModeListener; import jogamp.newt.Debug; + +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -224,7 +226,7 @@ public abstract class Screen { public abstract void removeMonitorModeListener(MonitorModeListener sml); // Global Screens - protected static ArrayList screenList = new ArrayList(); + protected static final ArrayList> screenList = new ArrayList>(); protected static int screensActive = 0; /** @@ -253,26 +255,60 @@ public abstract class Screen { synchronized(screenList) { int i = fromIndex >= 0 ? fromIndex : screenList.size() - 1 ; while( ( incr > 0 ) ? i < screenList.size() : i >= 0 ) { - Screen screen = (Screen) screenList.get(i); - if( screen.getDisplay().equals(display) && - screen.getIndex() == idx ) { - return screen; + final Screen screen = (Screen) screenList.get(i).get(); + if( null == screen ) { + // Clear GC'ed dead reference entry! + screenList.remove(i); + if( incr < 0 ) { + // decrease + i+=incr; + } // else nop - remove shifted subsequent elements to the left + } else { + if( screen.getDisplay().equals(display) && + screen.getIndex() == idx ) { + return screen; + } + i+=incr; } - i+=incr; } } return null; } - /** Returns the global display collection */ - @SuppressWarnings("unchecked") + + protected static void addScreen2List(Screen screen) { + synchronized(screenList) { + // GC before add + int i=0; + while( i < screenList.size() ) { + if( null == screenList.get(i).get() ) { + screenList.remove(i); + } else { + i++; + } + } + screenList.add(new WeakReference(screen)); + } + } + + /** Returns the global screen collection */ public static Collection getAllScreens() { ArrayList list; synchronized(screenList) { - list = (ArrayList) screenList.clone(); + list = new ArrayList(); + int i = 0; + while( i < screenList.size() ) { + final Screen s = screenList.get(i).get(); + if( null == s ) { + screenList.remove(i); + } else { + list.add( screenList.get(i).get() ); + i++; + } + } } return list; } - + public static int getActiveScreenNumber() { synchronized(screenList) { return screensActive; diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 0d1dcf5ab..bb493cbbd 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -41,6 +41,7 @@ import com.jogamp.newt.event.NEWTEventConsumer; import jogamp.newt.event.NEWTEventTask; import com.jogamp.newt.util.EDTUtil; + import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -96,7 +97,7 @@ public abstract class DisplayImpl extends Display { display.id = serialno++; display.fqname = getFQName(display.type, display.name, display.id); display.hashCode = display.fqname.hashCode(); - displayList.add(display); + Display.addDisplay2List(display); } display.setEDTUtil(display.edtUtil); // device's default if EDT is used, or null @@ -155,11 +156,11 @@ public abstract class DisplayImpl extends Display { if(null==aDevice) { throw new NativeWindowException("Display.createNative() failed to instanciate an AbstractGraphicsDevice"); } - if(DEBUG) { - System.err.println("Display.createNative() END ("+getThreadName()+", "+this+")"); - } synchronized(displayList) { displaysActive++; + if(DEBUG) { + System.err.println("Display.createNative() END ("+getThreadName()+", "+this+", active "+displaysActive+")"); + } } } } @@ -238,13 +239,12 @@ public abstract class DisplayImpl extends Display { dumpDisplayList("Display.destroy("+getFQName()+") BEGIN"); } synchronized(displayList) { - displayList.remove(this); if(0 < displaysActive) { displaysActive--; } - } - if(DEBUG) { - System.err.println("Display.destroy(): "+this+" "+getThreadName()); + if(DEBUG) { + System.err.println("Display.destroy(): "+this+", active "+displaysActive+" "+getThreadName()); + } } final DisplayImpl f_dpy = this; removeEDT( new Runnable() { // blocks! @@ -268,32 +268,34 @@ public abstract class DisplayImpl extends Display { dumpDisplayList("Display.shutdownAll "+dCount+" instances, on thread "+getThreadName()); } for(int i=0; i0; i++) { // be safe .. - final DisplayImpl d = (DisplayImpl) displayList.remove(0); - if(0 < displaysActive) { - displaysActive--; - } + final DisplayImpl d = (DisplayImpl) displayList.remove(0).get(); if(DEBUG) { - System.err.println("Display.shutdownAll["+(i+1)+"/"+dCount+"]: "+d); + System.err.println("Display.shutdownAll["+(i+1)+"/"+dCount+"]: "+d+", GCed "+(null==d)); } - final Runnable closeNativeTask = new Runnable() { - public void run() { - if ( null != d.getGraphicsDevice() ) { - d.closeNativeImpl(); + if( null != d ) { // GC'ed ? + if(0 < displaysActive) { + displaysActive--; + } + final Runnable closeNativeTask = new Runnable() { + public void run() { + if ( null != d.getGraphicsDevice() ) { + d.closeNativeImpl(); + } } + }; + final EDTUtil edtUtil = d.getEDTUtil(); + if(null != edtUtil) { + final long coopSleep = edtUtil.getPollPeriod() * 2; + edtUtil.invokeStop(false, closeNativeTask); // don't block + try { + Thread.sleep( coopSleep < 50 ? coopSleep : 50 ); + } catch (InterruptedException e) { } + } else { + closeNativeTask.run(); } - }; - final EDTUtil edtUtil = d.getEDTUtil(); - if(null != edtUtil) { - final long coopSleep = edtUtil.getPollPeriod() * 2; - edtUtil.invokeStop(false, closeNativeTask); // don't block - try { - Thread.sleep( coopSleep < 50 ? coopSleep : 50 ); - } catch (InterruptedException e) { } - } else { - closeNativeTask.run(); + d.aDevice = null; + d.refCount=0; } - d.aDevice = null; - d.refCount=0; } } diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index c02f4f288..fe9e91b57 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -125,7 +125,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { screen.screen_idx = idx; screen.fqname = display.getFQName()+"-s"+idx; screen.hashCode = screen.fqname.hashCode(); - screenList.add(screen); + Screen.addScreen2List(screen); if(DEBUG) { System.err.println("Screen.create() NEW: "+screen+" "+Display.getThreadName()); } @@ -169,8 +169,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { System.err.println("Screen.createNative() START ("+DisplayImpl.getThreadName()+", "+this+")"); } else { tCreated = 0; - } - + } display.addReference(); createNativeImpl(); @@ -179,11 +178,11 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } initMonitorState(); - if(DEBUG) { - System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+"), total "+ (System.nanoTime()-tCreated)/1e6 +"ms"); - } synchronized(screenList) { screensActive++; + if(DEBUG) { + System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+"), active "+screensActive+", total "+ (System.nanoTime()-tCreated)/1e6 +"ms"); + } } ScreenMonitorState.getScreenMonitorState(this.getFQName()).addListener(this); } @@ -192,10 +191,12 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { @Override public synchronized final void destroy() { synchronized(screenList) { - if( screenList.remove(this) ) { - if(0 < screensActive) { - screensActive--; - } + if(0 < screensActive) { + screensActive--; + } + if(DEBUG) { + System.err.println("Screen.destroy() ("+DisplayImpl.getThreadName()+"): active "+screensActive); + // Thread.dumpStack(); } } @@ -667,11 +668,13 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { System.err.println("Screen.shutdownAll "+sCount+" instances, on thread "+Display.getThreadName()); } for(int i=0; i0; i++) { // be safe .. - final ScreenImpl s = (ScreenImpl) screenList.remove(0); + final ScreenImpl s = (ScreenImpl) screenList.remove(0).get(); if(DEBUG) { - System.err.println("Screen.shutdownAll["+(i+1)+"/"+sCount+"]: "+s); + System.err.println("Screen.shutdownAll["+(i+1)+"/"+sCount+"]: "+s+", GCed "+(null==s)); + } + if( null != s ) { + s.shutdown(); } - s.shutdown(); } } } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 7c4011f34..460763f47 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -36,6 +36,7 @@ package jogamp.newt; import java.util.ArrayList; import java.util.List; +import java.lang.ref.WeakReference; import java.lang.reflect.Method; import com.jogamp.common.util.IntBitfield; @@ -82,7 +83,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer { public static final boolean DEBUG_TEST_REPARENT_INCOMPATIBLE = Debug.isPropertyDefined("newt.test.Window.reparent.incompatible", true); - protected static final ArrayList windowList = new ArrayList(); + protected static final ArrayList> windowList = new ArrayList>(); static { ScreenImpl.initSingleton(); @@ -95,13 +96,28 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("Window.shutdownAll "+wCount+" instances, on thread "+getThreadName()); } for(int i=0; i0; i++) { // be safe .. - final WindowImpl w = windowList.remove(0); + final WindowImpl w = windowList.remove(0).get(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.shutdownAll["+(i+1)+"/"+wCount+"]: "+toHexString(w.getWindowHandle())); + final long wh = null != w ? w.getWindowHandle() : 0; + System.err.println("Window.shutdownAll["+(i+1)+"/"+wCount+"]: "+toHexString(wh)+", GCed "+(null==w)); } w.shutdown(); } } + private static void addWindow2List(WindowImpl window) { + synchronized(windowList) { + // GC before add + int i=0; + while( i < windowList.size() ) { + if( null == windowList.get(i).get() ) { + windowList.remove(i); + } else { + i++; + } + } + windowList.add(new WeakReference(window)); + } + } /** Timeout of queued events (repaint and resize) */ static final long QUEUED_EVENT_TO = 1200; // ms @@ -208,9 +224,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer window.screen = (ScreenImpl) screen; window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable(); window.instantiationFinished(); - synchronized( windowList ) { - windowList.add(window); - } + addWindow2List(window); return window; } catch (Throwable t) { t.printStackTrace(); @@ -233,9 +247,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer window.screen = (ScreenImpl) screen; window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable(); window.instantiationFinished(); - synchronized( windowList ) { - windowList.add(window); - } + addWindow2List(window); return window; } catch (Throwable t) { throw new NativeWindowException(t); @@ -1062,9 +1074,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public void destroy() { - synchronized( windowList ) { - windowList.remove(this); - } visible = false; // Immediately mark synchronized visibility flag, avoiding possible recreation runOnEDTIfAvail(true, destroyAction); } -- cgit v1.2.3 From d4c022b6b0fe7c3553c7ae218758d6e062905e10 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 22:48:02 +0200 Subject: Fix NPE - Regression of commit 99479bf3197cde8e89c5b499d135417863d521c7 --- src/newt/classes/jogamp/newt/WindowImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 460763f47..d24c6ed36 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -101,7 +101,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final long wh = null != w ? w.getWindowHandle() : 0; System.err.println("Window.shutdownAll["+(i+1)+"/"+wCount+"]: "+toHexString(wh)+", GCed "+(null==w)); } - w.shutdown(); + if( null != w ) { + w.shutdown(); + } } } private static void addWindow2List(WindowImpl window) { -- cgit v1.2.3 From feb352145af1643a57eaae99c0342e6f5e0f2a2e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 22:51:01 +0200 Subject: DefaultEDTUtil: If EDT is not started and task is null and wait intended, use nullTask ensuring to wait until EDT started. --- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index c080e8380..f8ee31a06 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -174,6 +174,9 @@ public class DefaultEDTUtil implements EDTUtil { if( !edt.isRunning() ) { if( !stop ) { startImpl(); + if( wait && null == task ) { + task = nullTask; // ensures wait until started + } } else { // drop task and don't wait task = null; @@ -183,7 +186,7 @@ public class DefaultEDTUtil implements EDTUtil { } } } else if(stop && null == task) { - task = nullTask; + task = nullTask; // ensures execution triggering stop } if(null != task) { -- cgit v1.2.3 From 0e8cd28f916d10f3d588114eebc903902675f063 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 23:04:20 +0200 Subject: NEWT WindowImpl: Add little GCed / windowList-size stats at addWindow2List --- src/newt/classes/jogamp/newt/WindowImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index d24c6ed36..2c3c903f1 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -109,15 +109,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private static void addWindow2List(WindowImpl window) { synchronized(windowList) { // GC before add - int i=0; + int i=0, gced=0; while( i < windowList.size() ) { if( null == windowList.get(i).get() ) { + gced++; windowList.remove(i); } else { i++; } } windowList.add(new WeakReference(window)); + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.addWindow2List: GCed "+gced+", size "+windowList.size()); + } } } -- cgit v1.2.3 From c8f7884cad992d327f6acab4d5373c86a1077547 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 5 Jul 2013 02:36:19 +0200 Subject: GLWindow.shutdownRenderingAction: If on anim thread, simply stop ourselves (non-blocking) --- .../classes/com/jogamp/newt/opengl/GLWindow.java | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 25249cee4..286840ed1 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -537,16 +537,21 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public void shutdownRenderingAction() { final GLAnimatorControl anim = GLWindow.this.getAnimator(); if ( null != anim && anim.isAnimating() ) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - final Thread animThread = anim.getThread(); - if( null != animThread ) { - try { - animThread.stop(); - } catch(Throwable t) { } - } - return null; - } } ); + final Thread animThread = anim.getThread(); + if( animThread == Thread.currentThread() ) { + anim.stop(); // on anim thread, non-blocking + } else { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + if( anim.isAnimating() && null != animThread ) { + try { + animThread.stop(); + } catch(Throwable t) { + } + } + return null; + } } ); + } } } } -- cgit v1.2.3 From dec4b02fe4b93028c85de6a56b6af79601042d6e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 5 Jul 2013 11:32:12 +0200 Subject: NEWT Display.create: If reusing an existing instance, ensure EDT is running! --- make/scripts/tests.sh | 7 ++++--- src/newt/classes/jogamp/newt/DisplayImpl.java | 9 +++++---- .../test/junit/newt/parenting/TestParenting01NEWT.java | 18 ++++++++++++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 1ba0a36c6..c4520c8e7 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -150,8 +150,9 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" - #D_ARGS="-Dnativewindow.debug.NativeWindow" + #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" + #D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" @@ -401,7 +402,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT -testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* @@ -514,7 +515,7 @@ testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT # # NEWT Parenting (w/ NEWT, AWT or SWT) # -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index bb493cbbd..09ea05e88 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -77,13 +77,14 @@ public abstract class DisplayImpl extends Display { /** Make sure to reuse a Display with the same name */ public static Display create(String type, String name, final long handle, boolean reuse) { try { - Class displayClass = getDisplayClass(type); - DisplayImpl display = (DisplayImpl) displayClass.newInstance(); + final Class displayClass = getDisplayClass(type); + final DisplayImpl display = (DisplayImpl) displayClass.newInstance(); name = display.validateDisplayName(name, handle); synchronized(displayList) { if(reuse) { - Display display0 = Display.getLastDisplayOf(type, name, -1, true /* shared only */); + final Display display0 = Display.getLastDisplayOf(type, name, -1, true /* shared only */); if(null != display0) { + display0.setEDTUtil(display0.getEDTUtil()); // ensures EDT is running if(DEBUG) { System.err.println("Display.create() REUSE: "+display0+" "+getThreadName()); } @@ -99,7 +100,7 @@ public abstract class DisplayImpl extends Display { display.hashCode = display.fqname.hashCode(); Display.addDisplay2List(display); } - display.setEDTUtil(display.edtUtil); // device's default if EDT is used, or null + display.setEDTUtil(display.edtUtil); // device's default if EDT is used, or null - ensures EDT is running if(DEBUG) { System.err.println("Display.create() NEW: "+display+" "+getThreadName()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java index 15c324e3e..e7fced5d9 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java @@ -673,14 +673,28 @@ public class TestParenting01NEWT extends UITestCase { } public static void main(String args[]) throws IOException { + boolean asMain = false; for(int i=0; i Date: Fri, 5 Jul 2013 22:48:12 +0200 Subject: Fix SWTEDTUtil regression caused by dec4b02fe4b93028c85de6a56b6af79601042d6e, ensuring EDT is running for reused Display instances. Refine EDTUtil semantics of: - reset() - waitUntilStopped() AWTEDTUtil/SWTEDTUtil: Properly signal !running when shutdown SWTEDTUtil: Take SWT isDisposed() into account. --- make/scripts/tests.sh | 6 +-- src/newt/classes/com/jogamp/newt/util/EDTUtil.java | 15 ++++-- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 11 +++-- src/newt/classes/jogamp/newt/DisplayImpl.java | 2 +- .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 25 ++++++---- src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java | 53 +++++++++++++--------- 6 files changed, 70 insertions(+), 42 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c4520c8e7..dbc795992 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -152,7 +152,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" - #D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT" + D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" @@ -461,7 +461,7 @@ function testawtswt() { # #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -#testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* # # awtswt (testawtswt) @@ -515,7 +515,7 @@ function testawtswt() { # # NEWT Parenting (w/ NEWT, AWT or SWT) # -testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index 0df815609..75848785c 100644 --- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -65,14 +65,18 @@ public interface EDTUtil { public void setPollPeriod(long ms); /** - * Create a new EDT. One should invoke reset()
    - * after invokeStop(..) in case another start via invoke(..) - * is expected. + * Resets the stopped EDT, i.e. prepares it for a restart via + * the next invoke(..) call. + *

    + * One must stop the EDT first via {@link #invokeStop(boolean, Runnable)} + * and wait until it's stopped via {@link #waitUntilStopped()}. + *

    * * @see #invoke(boolean, java.lang.Runnable) * @see #invokeStop(boolean, java.lang.Runnable) + * @throws IllegalStateException if stop has not been issued, or EDT is still running (caller thread not being EDT or NEDT). */ - public void reset(); + public void reset() throws IllegalStateException; /** * Returns true if the current thread is the event dispatch thread (EDT). @@ -150,6 +154,9 @@ public interface EDTUtil { /** * Wait until EDT task is stopped.
    * No stop action is performed, {@link #invokeStop(boolean, java.lang.Runnable)} should be used before. + *

    + * If caller thread is EDT or NEDT, this call will not block. + *

    */ public void waitUntilStopped(); } diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index f8ee31a06..ecd94c278 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -76,9 +76,14 @@ public class DefaultEDTUtil implements EDTUtil { } @Override - public final void reset() { - synchronized(edtLock) { - waitUntilStopped(); + public final void reset() throws IllegalStateException { + synchronized(edtLock) { + if( isRunning() ) { + if( !edt.shouldStop ) { + throw new IllegalStateException("EDT stop not issued."); + } + throw new IllegalStateException("EDT still running"); + } if(DEBUG) { if(edt.tasks.size()>0) { System.err.println(Thread.currentThread()+": Default-EDT reset, remaining tasks: "+edt.tasks.size()+" - "+edt); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 09ea05e88..884ddac57 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -208,7 +208,7 @@ public abstract class DisplayImpl extends Display { } private void removeEDT(final Runnable task) { - if(null!=edtUtil) { + if(null!=edtUtil) { edtUtil.invokeStop(true, task); // ready for restart .. edtUtil.waitUntilStopped(); diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 0cc5ddb3e..abd47d17e 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -68,9 +68,18 @@ public class AWTEDTUtil implements EDTUtil { } @Override - final public void reset() { - synchronized(edtLock) { - waitUntilStopped(); + public final void reset() throws IllegalStateException { + synchronized(edtLock) { + final Thread curT = Thread.currentThread(); + final boolean onAWTEDT = EventQueue.isDispatchThread(); + if( nedt.isRunning() ) { + if( !nedt.shouldStop ) { + throw new IllegalStateException("EDT stop not issued."); + } + if( nedt != curT && !onAWTEDT ) { + throw new IllegalStateException("EDT still running: Curr "+curT.getName()+", NEDT "+nedt.getName()+", on AWT-EDT "+onAWTEDT); + } + } if(DEBUG) { System.err.println(Thread.currentThread()+": AWT-EDT reset - edt: "+nedt); } @@ -110,7 +119,7 @@ public class AWTEDTUtil implements EDTUtil { @Override final public boolean isRunning() { - return nedt.isRunning() ; // AWT is always running + return nedt.isRunning() ; } @Override @@ -203,7 +212,7 @@ public class AWTEDTUtil implements EDTUtil { @Override final public void waitUntilStopped() { synchronized(edtLock) { - if(nedt.isRunning() && nedt != Thread.currentThread() && !EventQueue.isDispatchThread()) { + if( nedt.isRunning() && nedt != Thread.currentThread() && !EventQueue.isDispatchThread() ) { while(nedt.isRunning()) { try { edtLock.wait(); @@ -278,10 +287,8 @@ public class AWTEDTUtil implements EDTUtil { System.err.println(getName()+": AWT-EDT run() END "+ getName()+", "+error); } synchronized(edtLock) { - isRunning = !shouldStop; - if(!isRunning) { - edtLock.notifyAll(); - } + isRunning = false; + edtLock.notifyAll(); } if(DEBUG) { System.err.println(getName()+": AWT-EDT run() EXIT "+ getName()+", exception: "+error); diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java index 77049a010..a8e03c510 100644 --- a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java @@ -77,9 +77,19 @@ public class SWTEDTUtil implements EDTUtil { } @Override - public void reset() { - synchronized(edtLock) { - waitUntilStopped(); + public final void reset() throws IllegalStateException { + synchronized(edtLock) { + final Thread curT = Thread.currentThread(); + final Thread swtT = !swtDisplay.isDisposed() ? swtDisplay.getThread() : null; + final boolean onSWTEDT = swtT == curT; + if( nedt.isRunning() ) { + if( !nedt.shouldStop ) { + throw new IllegalStateException("EDT stop not issued."); + } + if( nedt != curT && !onSWTEDT ) { + throw new IllegalStateException("EDT still running: Curr "+curT.getName()+", NEDT "+nedt.getName()+", SWT-EDT "+swtT.getName()); + } + } if(DEBUG) { System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt); } @@ -104,7 +114,7 @@ public class SWTEDTUtil implements EDTUtil { @Override public boolean isCurrentThreadEDT() { - return swtDisplay.getThread() == Thread.currentThread(); + return !swtDisplay.isDisposed() && swtDisplay.getThread() == Thread.currentThread(); } @Override @@ -115,12 +125,12 @@ public class SWTEDTUtil implements EDTUtil { @Override public final boolean isCurrentThreadEDTorNEDT() { final Thread ct = Thread.currentThread(); - return ct == swtDisplay.getThread() || ct == nedt ; + return ( !swtDisplay.isDisposed() && ct == swtDisplay.getThread() ) || ct == nedt ; } @Override public boolean isRunning() { - return nedt.isRunning() ; // SWT is always running + return nedt.isRunning() ; } @Override @@ -142,33 +152,32 @@ public class SWTEDTUtil implements EDTUtil { if( nedt.shouldStop ) { // drop task .. if(DEBUG) { - System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt); - Thread.dumpStack(); + System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt+", isRunning "+nedt.isRunning()); + // Thread.dumpStack(); } return; } // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); // Thread.dumpStack(); if(stop) { + if(DEBUG) { + System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt+", isRunning "+nedt.isRunning()); + } synchronized(nedt.sync) { nedt.shouldStop = true; nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) } - if(DEBUG) { - System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); - // Thread.dumpStack(); - } - } else if( !nedt.isRunning() ) { + } else if( !nedt.isRunning() && !swtDisplay.isDisposed() ) { // start if should not stop && not started yet startImpl(); } if( null == task ) { wait = false; + } else if( swtDisplay.isDisposed() ) { + wait = false; // drop task, SWT disposed } else if( isCurrentThreadEDT() ) { task.run(); wait = false; // running in same thread (EDT) -> no wait - } else if( swtDisplay.isDisposed() ) { - wait = false; // drop task, SWT disposed } else { rTask = new RunnableTask(task, wait ? rTaskLock : null, @@ -203,7 +212,7 @@ public class SWTEDTUtil implements EDTUtil { _nedt = nedt; } final Thread ct = Thread.currentThread(); - if(!_nedt.isRunning() || _nedt == ct || swtDisplay.getThread() == ct) { + if( !_nedt.isRunning() || _nedt == ct || swtDisplay.isDisposed() || swtDisplay.getThread() == ct ) { return; } try { @@ -216,8 +225,10 @@ public class SWTEDTUtil implements EDTUtil { @Override final public void waitUntilStopped() { synchronized(edtLock) { - final Thread ct = Thread.currentThread(); - if(nedt.isRunning() && nedt != ct && swtDisplay.getThread() != ct) { + final Thread curT = Thread.currentThread(); + final Thread swtT = !swtDisplay.isDisposed() ? swtDisplay.getThread() : null; + final boolean onSWTEDT = swtT == curT; + if( nedt.isRunning() && nedt != curT && !onSWTEDT ) { while(nedt.isRunning()) { try { edtLock.wait(); @@ -296,10 +307,8 @@ public class SWTEDTUtil implements EDTUtil { System.err.println(getName()+": SWT-EDT run() END "+ getName()+", "+error); } synchronized(edtLock) { - isRunning = !shouldStop; - if(!isRunning) { - edtLock.notifyAll(); - } + isRunning = false; + edtLock.notifyAll(); } if(DEBUG) { System.err.println(getName()+": SWT-EDT run() EXIT "+ getName()+", exception: "+error); -- cgit v1.2.3 From 453ccee8e3ce90956756d1582852b13f45cd2f38 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 9 Jul 2013 15:04:50 +0200 Subject: NEWT EDTUtil: Exposed weakness of EDTUtil usage due to usage of WeakReference, i.e. higher retention of Display instances. - WeakReference Change 99479bf3197cde8e89c5b499d135417863d521c7 - Refines commits: feb352145af1643a57eaae99c0342e6f5e0f2a2e dec4b02fe4b93028c85de6a56b6af79601042d6e 433e3914324b90c910b018bb7d9d80e814c67123 Reviews EDTUtil API and usage: - less confusing / more determined EDTUtil API - EDTUtil's thread shall only be reset and started when required (-> lazy) - EDTUtil's instance in Display shall be handled thread safe w/o extra blocking - EDTUtil's implementations (Default, SWT and AWT) shall be aligned / similar as much as possible Further note: SWT's EDTUtil (NewtCanvasSWT) shall not use a reused Display instance due to it's custom SWTEDTUtil. We may need to disable the ref. cache if custom EDTUtil (setEDTUtil) is intended (used). --- make/scripts/tests.sh | 6 +- src/newt/classes/com/jogamp/newt/Display.java | 17 +-- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 4 +- src/newt/classes/com/jogamp/newt/util/EDTUtil.java | 43 +++--- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 115 ++++++++------- src/newt/classes/jogamp/newt/DisplayImpl.java | 137 +++++++++++------- .../jogamp/newt/driver/android/DisplayDriver.java | 2 +- .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 130 ++++++++++------- .../jogamp/newt/driver/awt/DisplayDriver.java | 4 +- .../jogamp/newt/driver/bcm/egl/DisplayDriver.java | 2 +- .../newt/driver/bcm/vc/iv/DisplayDriver.java | 2 +- .../newt/driver/intel/gdl/DisplayDriver.java | 2 +- .../jogamp/newt/driver/kd/DisplayDriver.java | 2 +- .../jogamp/newt/driver/macosx/DisplayDriver.java | 2 +- .../jogamp/newt/driver/windows/DisplayDriver.java | 2 +- .../jogamp/newt/driver/x11/DisplayDriver.java | 4 +- src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java | 161 +++++++++++++-------- .../junit/jogl/acore/InitConcurrentBaseNEWT.java | 6 +- .../junit/jogl/acore/TestInitConcurrent01NEWT.java | 11 +- .../junit/jogl/acore/TestInitConcurrent02NEWT.java | 3 +- .../demos/es2/newt/TestGearsES2NewtCanvasSWT.java | 6 +- .../TestNewtCanvasSWTBug628ResizeDeadlockAWT.java | 9 +- .../test/junit/jogl/swt/TestNewtCanvasSWTGLn.java | 10 +- .../junit/jogl/swt/TestSWTBug643AsyncExec.java | 10 +- .../junit/newt/TestDisplayLifecycle01NEWT.java | 19 ++- .../junit/newt/parenting/TestParenting01NEWT.java | 2 +- .../junit/newt/parenting/TestParenting01aSWT.java | 7 +- .../junit/newt/parenting/TestParenting04SWT.java | 10 +- 28 files changed, 434 insertions(+), 294 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index dbc795992..a5ce8d2e9 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -152,7 +152,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" - D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT" + D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" @@ -461,7 +461,7 @@ function testawtswt() { # #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* # # awtswt (testawtswt) @@ -515,7 +515,7 @@ testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* # # NEWT Parenting (w/ NEWT, AWT or SWT) # -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 4f5df6c70..c618405c2 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -154,26 +154,25 @@ public abstract class Display { /** * Sets a new {@link EDTUtil} and returns the previous one. *

    - * If newEDTUtil is null, + * If usrEDTUtil is null, * the device's default EDTUtil is created and used. *

    *

    - * If a previous one exists and it differs from the new one, - * it's being stopped, wait-until-idle and reset to allow a restart at a later time. + * If a previous one exists and it differs from usrEDTUtil, + * it's being stopped, wait-until-idle. *

    *

    - * If newEDTUtil is not null and equals the previous one, + * If usrEDTUtil is not null and equals the previous one, * no change is being made. *

    - *

    - * Note that newEDTUtil will be started by this method, - * if it is not running yet. - *

    */ - public abstract EDTUtil setEDTUtil(EDTUtil newEDTUtil); + public abstract EDTUtil setEDTUtil(EDTUtil usrEDTUtil); public abstract EDTUtil getEDTUtil(); + /** + * @return true if EDT is running and not subject to be stopped, otherwise false. + */ public abstract boolean isEDTRunning(); public abstract void dispatchMessages(); diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index dbe7c0d98..47dfca0f3 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -345,7 +345,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { // set SWT EDT and start it { final Display newtDisplay = newtChild.getScreen().getDisplay(); - newtDisplay.setEDTUtil( new SWTEDTUtil(newtDisplay, getDisplay()) ); + final EDTUtil edtUtil = new SWTEDTUtil(newtDisplay, getDisplay()); + edtUtil.restart(); + newtDisplay.setEDTUtil( edtUtil ); } newtChild.setSize(w, h); diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index 75848785c..e86df2084 100644 --- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -65,18 +65,19 @@ public interface EDTUtil { public void setPollPeriod(long ms); /** - * Resets the stopped EDT, i.e. prepares it for a restart via - * the next invoke(..) call. + * Starts or restarts the EDT. *

    - * One must stop the EDT first via {@link #invokeStop(boolean, Runnable)} - * and wait until it's stopped via {@link #waitUntilStopped()}. + * If the EDT is running, it must be stopped first via {@link #invokeStop(boolean, Runnable)} + * and the caller should wait until it's stopped via {@link #waitUntilStopped()}. *

    - * - * @see #invoke(boolean, java.lang.Runnable) + * + * @return true if EDT has been successfully restarted, otherwise false + * @throws IllegalStateException if EDT is running and not subject to be stopped, i.e. {@link #isRunning()} returns true + * * @see #invokeStop(boolean, java.lang.Runnable) - * @throws IllegalStateException if stop has not been issued, or EDT is still running (caller thread not being EDT or NEDT). + * @see #waitUntilStopped() */ - public void reset() throws IllegalStateException; + public boolean restart() throws IllegalStateException; /** * Returns true if the current thread is the event dispatch thread (EDT). @@ -111,7 +112,7 @@ public interface EDTUtil { public boolean isCurrentThreadEDTorNEDT(); /** - * @return True if EDT is running + * @return True if EDT is running and not subject to be stopped. */ public boolean isRunning(); @@ -129,27 +130,30 @@ public interface EDTUtil { *
  • All previous queued tasks will be finished.
  • *
  • No new tasks are allowed, an Exception is thrown.
  • *
  • Can be issued from within EDT, ie from within an enqueued task.
  • - *
  • {@link #reset()} may follow immediately, ie creating a new EDT
  • + *
  • {@link #restart()} may follow immediately, ie creating a new EDT
  • * *

    + * @return true if task has been executed or queued for later execution, otherwise false */ - public void invokeStop(boolean wait, Runnable finalTask); + public boolean invokeStop(boolean wait, Runnable finalTask); /** - * Shall start the thread if not running, task maybe null for this purpose.
    - * Append task to the EDT task queue.
    - * Wait until execution is finished if wait == true.
    + * Appends task to the EDT task queue if current thread is not EDT, + * otherwise execute task immediately. + *

    + * Wait until execution is finished if wait == true. + *

    * Can be issued from within EDT, ie from within an enqueued task.
    - * - * @throws RuntimeException in case EDT is stopped and not {@link #reset()} + * @return true if task has been executed or queued for later execution, otherwise false */ - public void invoke(boolean wait, Runnable task); + public boolean invoke(boolean wait, Runnable task); /** * Wait until the EDT task queue is empty.
    * The last task may still be in execution when this method returns. + * @return true if waited for idle, otherwise false, i.e. in case of current thread is EDT or NEDT */ - public void waitUntilIdle(); + public boolean waitUntilIdle(); /** * Wait until EDT task is stopped.
    @@ -157,7 +161,8 @@ public interface EDTUtil { *

    * If caller thread is EDT or NEDT, this call will not block. *

    + * @return true if stopped, otherwise false, i.e. in case of current thread is EDT or NEDT */ - public void waitUntilStopped(); + public boolean waitUntilStopped(); } diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index ecd94c278..a229a0512 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -53,7 +53,7 @@ public class DefaultEDTUtil implements EDTUtil { private final ThreadGroup threadGroup; private final String name; private final Runnable dispatchMessages; - private EventDispatchThread edt = null; + private NEDT edt = null; private int start_iter=0; private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; @@ -61,7 +61,7 @@ public class DefaultEDTUtil implements EDTUtil { this.threadGroup = tg; this.name=Thread.currentThread().getName()+"-"+name+"-EDT-"; this.dispatchMessages=dispatchMessages; - this.edt = new EventDispatchThread(threadGroup, name); + this.edt = new NEDT(threadGroup, name); this.edt.setDaemon(true); // don't stop JVM from shutdown .. } @@ -76,36 +76,34 @@ public class DefaultEDTUtil implements EDTUtil { } @Override - public final void reset() throws IllegalStateException { + public final boolean restart() throws IllegalStateException { synchronized(edtLock) { - if( isRunning() ) { - if( !edt.shouldStop ) { - throw new IllegalStateException("EDT stop not issued."); - } - throw new IllegalStateException("EDT still running"); + if( edt.isRunning() ) { + throw new IllegalStateException("EDT still running and not subject to stop. Curr "+Thread.currentThread().getName()+", EDT "+edt.getName()+", isRunning "+edt.isRunning+", shouldStop "+edt.shouldStop); } if(DEBUG) { if(edt.tasks.size()>0) { System.err.println(Thread.currentThread()+": Default-EDT reset, remaining tasks: "+edt.tasks.size()+" - "+edt); - // Thread.dumpStack(); } System.err.println(Thread.currentThread()+": Default-EDT reset - edt: "+edt); } - this.edt = new EventDispatchThread(threadGroup, name); - this.edt.setDaemon(true); // don't stop JVM from shutdown .. + if( edt.getState() != Thread.State.NEW ) { + edt = new NEDT(threadGroup, name); + edt.setDaemon(true); // don't stop JVM from shutdown .. + } + startImpl(); } + return invoke(true, nullTask); } private final void startImpl() { if(edt.isAlive()) { - throw new RuntimeException("Default-EDT Thread.isAlive(): true, isRunning: "+edt.isRunning()+", edt: "+edt+", tasks: "+edt.tasks.size()); + throw new RuntimeException("Default-EDT Thread.isAlive(): true, isRunning: "+edt.isRunning+", shouldStop "+edt.shouldStop+", edt: "+edt+", tasks: "+edt.tasks.size()); } start_iter++; edt.setName(name+start_iter); - edt.shouldStop = false; if(DEBUG) { System.err.println(Thread.currentThread()+": Default-EDT START - edt: "+edt); - // Thread.dumpStack(); } edt.start(); } @@ -131,13 +129,13 @@ public class DefaultEDTUtil implements EDTUtil { } @Override - public final void invokeStop(boolean wait, Runnable task) { - invokeImpl(wait, task, true); + public final boolean invokeStop(boolean wait, Runnable task) { + return invokeImpl(wait, task, true); } @Override - public final void invoke(boolean wait, Runnable task) { - invokeImpl(wait, task, false); + public final boolean invoke(boolean wait, Runnable task) { + return invokeImpl(wait, task, false); } private static Runnable nullTask = new Runnable() { @@ -145,28 +143,26 @@ public class DefaultEDTUtil implements EDTUtil { public void run() { } }; - private void invokeImpl(boolean wait, Runnable task, boolean stop) { + private final boolean invokeImpl(boolean wait, Runnable task, boolean stop) { Throwable throwable = null; RunnableTask rTask = null; - Object rTaskLock = new Object(); + final Object rTaskLock = new Object(); synchronized(rTaskLock) { // lock the optional task execution synchronized(edtLock) { // lock the EDT status if( edt.shouldStop ) { // drop task .. + System.err.println(Thread.currentThread()+": Warning: Default-EDT about (1) to stop, won't enqueue new task: "+edt); if(DEBUG) { - System.err.println(Thread.currentThread()+": Warning: Default-EDT about (1) to stop, won't enqueue new task: "+edt); Thread.dumpStack(); } - return; + return false; } - // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); - // Thread.dumpStack(); if( isCurrentThreadEDT() ) { if(null != task) { task.run(); } wait = false; // running in same thread (EDT) -> no wait - if(stop) { + if( stop ) { edt.shouldStop = true; if( edt.tasks.size()>0 ) { System.err.println(Thread.currentThread()+": Warning: Default-EDT about (2) to stop, task executed. Remaining tasks: "+edt.tasks.size()+" - "+edt); @@ -176,21 +172,19 @@ public class DefaultEDTUtil implements EDTUtil { } } } else { - if( !edt.isRunning() ) { - if( !stop ) { - startImpl(); - if( wait && null == task ) { - task = nullTask; // ensures wait until started + if( !edt.isRunning ) { + if( null != task ) { + if( stop ) { + System.err.println(Thread.currentThread()+": Warning: Default-EDT is about (3) to stop and stopped already, dropping task. Remaining tasks: "+edt.tasks.size()+" - "+edt); + } else { + System.err.println(Thread.currentThread()+": Warning: Default-EDT is not running, dropping task. NEDT "+edt); } - } else { - // drop task and don't wait - task = null; - System.err.println(Thread.currentThread()+": Warning: Default-EDT is about (3) to stop and stopped already, dropping task. Remaining tasks: "+edt.tasks.size()+" - "+edt); if(DEBUG) { Thread.dumpStack(); } } - } else if(stop && null == task) { + return false; + } else if( stop && null == task ) { task = nullTask; // ensures execution triggering stop } @@ -228,23 +222,26 @@ public class DefaultEDTUtil implements EDTUtil { throw new RuntimeException(throwable); } } - } - if(DEBUG && stop) { - System.err.println(Thread.currentThread()+": Default-EDT signal STOP X edt: "+edt); + if(DEBUG) { + if( stop) { + System.err.println(Thread.currentThread()+": Default-EDT signal STOP X edt: "+edt); + } + } + return true; } } @Override - final public void waitUntilIdle() { - final EventDispatchThread _edt; + final public boolean waitUntilIdle() { + final NEDT _edt; synchronized(edtLock) { _edt = edt; } - if(!_edt.isRunning() || _edt == Thread.currentThread()) { - return; + if(!_edt.isRunning || _edt == Thread.currentThread()) { + return false; } synchronized(_edt.tasks) { - while(_edt.isRunning() && _edt.tasks.size()>0) { + while(_edt.isRunning && _edt.tasks.size()>0) { try { _edt.tasks.notifyAll(); _edt.tasks.wait(); @@ -252,35 +249,39 @@ public class DefaultEDTUtil implements EDTUtil { e.printStackTrace(); } } + return true; } } @Override - final public void waitUntilStopped() { + final public boolean waitUntilStopped() { synchronized(edtLock) { - if(edt.isRunning() && edt != Thread.currentThread() ) { - while(edt.isRunning()) { + if(edt.isRunning && edt != Thread.currentThread() ) { + while( edt.isRunning ) { try { edtLock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } + return true; + } else { + return false; } } } - class EventDispatchThread extends Thread { + class NEDT extends Thread { volatile boolean shouldStop = false; volatile boolean isRunning = false; ArrayList tasks = new ArrayList(); // one shot tasks - public EventDispatchThread(ThreadGroup tg, String name) { + public NEDT(ThreadGroup tg, String name) { super(tg, name); } final public boolean isRunning() { - return isRunning; + return isRunning && !shouldStop; } @Override @@ -290,11 +291,9 @@ public class DefaultEDTUtil implements EDTUtil { } private final void validateNoRecursiveLocksHold() { - if(Lock.DEBUG) { - if(LockDebugUtil.getRecursiveLockTrace().size()>0) { - LockDebugUtil.dumpRecursiveLockTrace(System.err); - throw new InternalError("XXX"); - } + if(LockDebugUtil.getRecursiveLockTrace().size()>0) { + LockDebugUtil.dumpRecursiveLockTrace(System.err); + throw new InternalError("XXX"); } } @@ -307,7 +306,9 @@ public class DefaultEDTUtil implements EDTUtil { if(DEBUG) { System.err.println(getName()+": Default-EDT run() START "+ getName()); } - validateNoRecursiveLocksHold(); + if(Lock.DEBUG) { + validateNoRecursiveLocksHold(); + } RuntimeException error = null; try { do { @@ -337,7 +338,9 @@ public class DefaultEDTUtil implements EDTUtil { } if(null!=task) { task.run(); - validateNoRecursiveLocksHold(); + if(Lock.DEBUG) { + validateNoRecursiveLocksHold(); + } if(!task.hasWaiter() && null != task.getThrowable()) { // at least dump stack-trace in case nobody waits for result System.err.println("DefaultEDT.run(): Catched exception occured on thread "+Thread.currentThread().getName()+": "+task.toString()); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 884ddac57..8f792b23c 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -84,7 +84,6 @@ public abstract class DisplayImpl extends Display { if(reuse) { final Display display0 = Display.getLastDisplayOf(type, name, -1, true /* shared only */); if(null != display0) { - display0.setEDTUtil(display0.getEDTUtil()); // ensures EDT is running if(DEBUG) { System.err.println("Display.create() REUSE: "+display0+" "+getThreadName()); } @@ -98,9 +97,9 @@ public abstract class DisplayImpl extends Display { display.id = serialno++; display.fqname = getFQName(display.type, display.name, display.id); display.hashCode = display.fqname.hashCode(); + display.setEDTUtil( display.edtUtil ); // device's default if EDT is used, or null Display.addDisplay2List(display); } - display.setEDTUtil(display.edtUtil); // device's default if EDT is used, or null - ensures EDT is running if(DEBUG) { System.err.println("Display.create() NEW: "+display+" "+getThreadName()); @@ -138,10 +137,10 @@ public abstract class DisplayImpl extends Display { } @Override - public synchronized final void createNative() + public synchronized final void createNative() throws NativeWindowException { - if(null==aDevice) { + if( null == aDevice ) { if(DEBUG) { System.err.println("Display.createNative() START ("+getThreadName()+", "+this+")"); } @@ -154,7 +153,7 @@ public abstract class DisplayImpl extends Display { } catch (Throwable t) { throw new NativeWindowException(t); } - if(null==aDevice) { + if( null == aDevice ) { throw new NativeWindowException("Display.createNative() failed to instanciate an AbstractGraphicsDevice"); } synchronized(displayList) { @@ -180,25 +179,23 @@ public abstract class DisplayImpl extends Display { } @Override - public EDTUtil setEDTUtil(EDTUtil newEDTUtil) { + public synchronized EDTUtil setEDTUtil(final EDTUtil usrEDTUtil) { final EDTUtil oldEDTUtil = edtUtil; - if(null == newEDTUtil) { - if(DEBUG) { - System.err.println("Display.setEDTUtil(default): "+oldEDTUtil+" -> "+newEDTUtil); + final EDTUtil newEDTUtil; + if( null != usrEDTUtil && usrEDTUtil == oldEDTUtil ) { + if( DEBUG ) { + System.err.println("Display.setEDTUtil: "+usrEDTUtil+" - keep!"); } - edtUtil = createEDTUtil(); - } else if( newEDTUtil != edtUtil ) { + newEDTUtil = oldEDTUtil; + } else { if(DEBUG) { - System.err.println("Display.setEDTUtil(custom): "+oldEDTUtil+" -> "+newEDTUtil); + final String msg = ( null == usrEDTUtil ) ? "default" : "custom"; + System.err.println("Display.setEDTUtil("+msg+"): "+oldEDTUtil+" -> "+usrEDTUtil); } - removeEDT( null ); - edtUtil = newEDTUtil; - } else if( DEBUG ) { - System.err.println("Display.setEDTUtil: "+newEDTUtil+" - keep!"); - } - if( !edtUtil.isRunning() ) { // start EDT if not running yet - edtUtil.invoke(true, null); + stopEDT( oldEDTUtil, null ); + newEDTUtil = ( null == usrEDTUtil ) ? createEDTUtil() : usrEDTUtil; } + edtUtil = newEDTUtil; return oldEDTUtil; } @@ -207,29 +204,61 @@ public abstract class DisplayImpl extends Display { return edtUtil; } - private void removeEDT(final Runnable task) { - if(null!=edtUtil) { - edtUtil.invokeStop(true, task); - // ready for restart .. + private static void stopEDT(final EDTUtil edtUtil, final Runnable task) { + if( null != edtUtil ) { + if( edtUtil.isRunning() ) { + final boolean res = edtUtil.invokeStop(true, task); + if( DEBUG ) { + if ( !res ) { + System.err.println("Warning: invokeStop() failed"); + Thread.dumpStack(); + } + } + } edtUtil.waitUntilStopped(); - edtUtil.reset(); - } else { + // ready for restart .. + } else if( null != task ) { task.run(); } } public void runOnEDTIfAvail(boolean wait, final Runnable task) { - if( null!=edtUtil && !edtUtil.isCurrentThreadEDT()) { - edtUtil.invoke(wait, task); + final EDTUtil _edtUtil = edtUtil; + if( null != _edtUtil && !_edtUtil.isCurrentThreadEDT() ) { + if( !_edtUtil.isRunning() ) { // start EDT if not running yet + synchronized( this ) { + if( !_edtUtil.isRunning() ) { // // volatile dbl-checked-locking OK + _edtUtil.restart(); + if( DEBUG ) { + System.err.println("Info: EDT started "+Thread.currentThread().getName()+", "+this); + Thread.dumpStack(); + } + } + } + } + if( !_edtUtil.invoke(wait, task) ) { + if( DEBUG ) { + System.err.println("Warning: invoke(wait "+wait+", ..) on EDT failed .. invoke on current thread "+Thread.currentThread().getName()); + Thread.dumpStack(); + } + task.run(); + } } else { task.run(); } } public boolean validateEDT() { - if(0==refCount && null==aDevice && null != edtUtil && edtUtil.isRunning()) { - removeEDT( null ); - return true; + if( 0==refCount && null == aDevice ) { + final EDTUtil _edtUtil = edtUtil; + if( null != _edtUtil && _edtUtil.isRunning() ) { + synchronized( this ) { + if( null != edtUtil && edtUtil.isRunning() ) { // // volatile dbl-checked-locking OK + stopEDT( edtUtil, null ); + return true; + } + } + } } return false; } @@ -246,17 +275,18 @@ public abstract class DisplayImpl extends Display { if(DEBUG) { System.err.println("Display.destroy(): "+this+", active "+displaysActive+" "+getThreadName()); } - } + } final DisplayImpl f_dpy = this; - removeEDT( new Runnable() { // blocks! + final AbstractGraphicsDevice f_aDevice = aDevice; + aDevice = null; + refCount=0; + stopEDT( edtUtil, new Runnable() { // blocks! public void run() { - if ( null != aDevice ) { - f_dpy.closeNativeImpl(); + if ( null != f_aDevice ) { + f_dpy.closeNativeImpl(f_aDevice); } } } ); - aDevice = null; - refCount=0; if(DEBUG) { dumpDisplayList("Display.destroy("+getFQName()+") END"); } @@ -277,25 +307,28 @@ public abstract class DisplayImpl extends Display { if(0 < displaysActive) { displaysActive--; } + final EDTUtil edtUtil = d.getEDTUtil(); + final AbstractGraphicsDevice f_aDevice = d.aDevice; + d.aDevice = null; + d.refCount=0; final Runnable closeNativeTask = new Runnable() { public void run() { if ( null != d.getGraphicsDevice() ) { - d.closeNativeImpl(); + d.closeNativeImpl(f_aDevice); } } }; - final EDTUtil edtUtil = d.getEDTUtil(); if(null != edtUtil) { final long coopSleep = edtUtil.getPollPeriod() * 2; - edtUtil.invokeStop(false, closeNativeTask); // don't block + if( edtUtil.isRunning() ) { + edtUtil.invokeStop(false, closeNativeTask); // don't block + } try { Thread.sleep( coopSleep < 50 ? coopSleep : 50 ); } catch (InterruptedException e) { } } else { closeNativeTask.run(); } - d.aDevice = null; - d.refCount=0; } } } @@ -331,7 +364,7 @@ public abstract class DisplayImpl extends Display { } protected abstract void createNativeImpl(); - protected abstract void closeNativeImpl(); + protected abstract void closeNativeImpl(AbstractGraphicsDevice aDevice); @Override public final int getId() { @@ -399,15 +432,18 @@ public abstract class DisplayImpl extends Display { @Override public boolean isEDTRunning() { - if(null!=edtUtil) { - return edtUtil.isRunning(); + final EDTUtil _edtUtil = edtUtil; + if( null != _edtUtil ) { + return _edtUtil.isRunning(); } return false; } @Override public String toString() { - return "NEWT-Display["+getFQName()+", excl "+exclusive+", refCount "+refCount+", hasEDT "+(null!=edtUtil)+", edtRunning "+isEDTRunning()+", "+aDevice+"]"; + final EDTUtil _edtUtil = edtUtil; + final boolean _edtUtilRunning = ( null != _edtUtil ) ? _edtUtil.isRunning() : false; + return "NEWT-Display["+getFQName()+", excl "+exclusive+", refCount "+refCount+", hasEDT "+(null!=_edtUtil)+", edtRunning "+_edtUtilRunning+", "+aDevice+"]"; } /** Dispatch native Toolkit messageges */ @@ -500,17 +536,18 @@ public abstract class DisplayImpl extends Display { } public void enqueueEvent(boolean wait, NEWTEvent e) { - if(!isEDTRunning()) { + final EDTUtil _edtUtil = edtUtil; + if( !_edtUtil.isRunning() ) { // oops .. we are already dead if(DEBUG) { - Throwable t = new Throwable("Warning: EDT already stopped: wait:="+wait+", "+e); - t.printStackTrace(); + System.err.println("Warning: EDT already stopped: wait:="+wait+", "+e); + Thread.dumpStack(); } return; } // can't wait if we are on EDT or NEDT -> consume right away - if(wait && edtUtil.isCurrentThreadEDTorNEDT() ) { + if(wait && _edtUtil.isCurrentThreadEDTorNEDT() ) { dispatchMessage(e); return; } @@ -557,7 +594,7 @@ public abstract class DisplayImpl extends Display { return runWithLockedDevice(device, action); } - protected EDTUtil edtUtil = null; + protected volatile EDTUtil edtUtil = null; protected int id; protected String name; protected String type; diff --git a/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java index a367462c4..a2877dba2 100644 --- a/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java @@ -55,7 +55,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index abd47d17e..80c72c008 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -45,7 +45,7 @@ public class AWTEDTUtil implements EDTUtil { private final ThreadGroup threadGroup; private final String name; private final Runnable dispatchMessages; - private NewtEventDispatchThread nedt = null; + private NEDT nedt = null; private int start_iter=0; private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; @@ -53,7 +53,7 @@ public class AWTEDTUtil implements EDTUtil { this.threadGroup = tg; this.name=Thread.currentThread().getName()+"-"+name+"-EDT-"; this.dispatchMessages=dispatchMessages; - this.nedt = new NewtEventDispatchThread(threadGroup, name); + this.nedt = new NEDT(threadGroup, name); this.nedt.setDaemon(true); // don't stop JVM from shutdown .. } @@ -68,33 +68,29 @@ public class AWTEDTUtil implements EDTUtil { } @Override - public final void reset() throws IllegalStateException { + public final boolean restart() throws IllegalStateException { synchronized(edtLock) { - final Thread curT = Thread.currentThread(); - final boolean onAWTEDT = EventQueue.isDispatchThread(); if( nedt.isRunning() ) { - if( !nedt.shouldStop ) { - throw new IllegalStateException("EDT stop not issued."); - } - if( nedt != curT && !onAWTEDT ) { - throw new IllegalStateException("EDT still running: Curr "+curT.getName()+", NEDT "+nedt.getName()+", on AWT-EDT "+onAWTEDT); - } + throw new IllegalStateException("EDT still running and not subject to stop. Curr "+Thread.currentThread().getName()+", NEDT "+nedt.getName()+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop+", on AWT-EDT "+EventQueue.isDispatchThread()); } if(DEBUG) { System.err.println(Thread.currentThread()+": AWT-EDT reset - edt: "+nedt); } - this.nedt = new NewtEventDispatchThread(threadGroup, name); - this.nedt.setDaemon(true); // don't stop JVM from shutdown .. + if( nedt.getState() != Thread.State.NEW ) { + nedt = new NEDT(threadGroup, name); + nedt.setDaemon(true); // don't stop JVM from shutdown .. + } + startImpl(); } + return invoke(true, nullTask); } private final void startImpl() { if(nedt.isAlive()) { - throw new RuntimeException("AWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); + throw new RuntimeException("AWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning+", shouldStop "+nedt.shouldStop+", edt: "+nedt); } start_iter++; nedt.setName(name+start_iter); - nedt.shouldStop = false; if(DEBUG) { System.err.println(Thread.currentThread()+": AWT-EDT START - edt: "+nedt); // Thread.dumpStack(); @@ -123,55 +119,72 @@ public class AWTEDTUtil implements EDTUtil { } @Override - public final void invokeStop(boolean wait, Runnable task) { - invokeImpl(wait, task, true); + public final boolean invokeStop(boolean wait, Runnable task) { + return invokeImpl(wait, task, true); } @Override - public final void invoke(boolean wait, Runnable task) { - invokeImpl(wait, task, false); + public final boolean invoke(boolean wait, Runnable task) { + return invokeImpl(wait, task, false); } - private void invokeImpl(boolean wait, Runnable task, boolean stop) { + private static Runnable nullTask = new Runnable() { + @Override + public void run() { } + }; + + private final boolean invokeImpl(boolean wait, Runnable task, boolean stop) { Throwable throwable = null; RunnableTask rTask = null; - Object rTaskLock = new Object(); + final Object rTaskLock = new Object(); synchronized(rTaskLock) { // lock the optional task execution synchronized(edtLock) { // lock the EDT status if( nedt.shouldStop ) { // drop task .. + System.err.println(Thread.currentThread()+": Warning: AWT-EDT about (1) to stop, won't enqueue new task: "+nedt); if(DEBUG) { - System.err.println(Thread.currentThread()+": Warning: AWT-EDT about (1) to stop, won't enqueue new task: "+nedt); Thread.dumpStack(); } - return; + return false; } - // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); - // Thread.dumpStack(); - if(stop) { - synchronized(nedt.sync) { + if( isCurrentThreadEDT() ) { + if(null != task) { + task.run(); + } + wait = false; // running in same thread (EDT) -> no wait + if(stop) { nedt.shouldStop = true; - nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) } - if(DEBUG) { - System.err.println(Thread.currentThread()+": AWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); - // Thread.dumpStack(); + } else { + if( !nedt.isRunning ) { + if( null != task ) { + if( stop ) { + System.err.println(Thread.currentThread()+": Warning: AWT-EDT is about (3) to stop and stopped already, dropping task. NEDT "+nedt); + } else { + System.err.println(Thread.currentThread()+": Warning: AWT-EDT is not running, dropping task. NEDT "+nedt); + } + if(DEBUG) { + Thread.dumpStack(); + } + } + return false; + } else if( stop ) { + if(DEBUG) { + System.err.println(Thread.currentThread()+": AWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop); + } + synchronized(nedt.sync) { + nedt.shouldStop = true; + nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) + } + } + + if(null != task) { + rTask = new RunnableTask(task, + wait ? rTaskLock : null, + true /* always catch and report Exceptions, don't disturb EDT */, + wait ? null : System.err); + AWTEDTExecutor.singleton.invoke(false, rTask); } - } else if( !nedt.isRunning() ) { - // start if should not stop && not started yet - startImpl(); - } - if( null == task ) { - wait = false; - } else if( isCurrentThreadEDT() ) { - task.run(); - wait = false; // running in same thread (EDT) -> no wait - } else { - rTask = new RunnableTask(task, - wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */, - wait ? null : System.err); - AWTEDTExecutor.singleton.invoke(false, rTask); } } if( wait ) { @@ -190,51 +203,56 @@ public class AWTEDTUtil implements EDTUtil { throw new RuntimeException(throwable); } } + return true; } } @Override - final public void waitUntilIdle() { - final NewtEventDispatchThread _edt; + final public boolean waitUntilIdle() { + final NEDT _edt; synchronized(edtLock) { _edt = nedt; } - if(!_edt.isRunning() || _edt == Thread.currentThread() || EventQueue.isDispatchThread()) { - return; + if(!_edt.isRunning || _edt == Thread.currentThread() || EventQueue.isDispatchThread()) { + return false; } try { AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { } }); } catch (Exception e) { } + return true; } @Override - final public void waitUntilStopped() { + final public boolean waitUntilStopped() { synchronized(edtLock) { - if( nedt.isRunning() && nedt != Thread.currentThread() && !EventQueue.isDispatchThread() ) { - while(nedt.isRunning()) { + if( nedt.isRunning && nedt != Thread.currentThread() && !EventQueue.isDispatchThread() ) { + while( nedt.isRunning ) { try { edtLock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } + return true; + } else { + return false; } } } - class NewtEventDispatchThread extends Thread { + class NEDT extends Thread { volatile boolean shouldStop = false; volatile boolean isRunning = false; Object sync = new Object(); - public NewtEventDispatchThread(ThreadGroup tg, String name) { + public NEDT(ThreadGroup tg, String name) { super(tg, name); } final public boolean isRunning() { - return isRunning; + return isRunning && !shouldStop; } @Override diff --git a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java index 4139951aa..30449f9bc 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java @@ -34,6 +34,8 @@ package jogamp.newt.driver.awt; +import javax.media.nativewindow.AbstractGraphicsDevice; + import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.util.EDTUtil; @@ -65,7 +67,7 @@ public class DisplayDriver extends DisplayImpl { return def; } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java index cc55c336e..112be2b04 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java @@ -69,7 +69,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { aDevice = new EGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, handle, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, null); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { DestroyDisplay(aDevice.getHandle()); } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java index 08c5c573c..4872a9071 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java @@ -64,7 +64,7 @@ public class DisplayDriver extends DisplayImpl { aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java index e370038d9..ee93eb932 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java @@ -72,7 +72,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { aDevice = new DefaultGraphicsDevice(NativeWindowFactory.TYPE_DEFAULT, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, displayHandle); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { if(0==displayHandle) { throw new NativeWindowException("displayHandle null; initCnt "+initCounter); } diff --git a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java index 745be5dae..3cd72e971 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java @@ -64,7 +64,7 @@ public class DisplayDriver extends DisplayImpl { aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index b49c6b6e0..a99bc4f23 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -72,7 +72,7 @@ public class DisplayDriver extends DisplayImpl { aDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index 1b9ec0f25..595d5e952 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -76,7 +76,7 @@ public class DisplayDriver extends DisplayImpl { aDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { sharedClassFactory.releaseSharedClass(); aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 88d06f69c..d911483b0 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -82,13 +82,13 @@ public class DisplayDriver extends DisplayImpl { try { CompleteDisplay0(aDevice.getHandle()); } catch(RuntimeException e) { - closeNativeImpl(); + closeNativeImpl(aDevice); throw e; } } @Override - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { DisplayRelease0(aDevice.getHandle(), javaObjectAtom, windowDeleteAtom /*, kbdHandle */); // XKB disabled for now javaObjectAtom = 0; windowDeleteAtom = 0; diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java index a8e03c510..d46562050 100644 --- a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java @@ -46,7 +46,7 @@ public class SWTEDTUtil implements EDTUtil { private final String name; private final Runnable dispatchMessages; private final org.eclipse.swt.widgets.Display swtDisplay; - private NewtEventDispatchThread nedt = null; + private NEDT nedt = null; private int start_iter=0; private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; @@ -58,7 +58,7 @@ public class SWTEDTUtil implements EDTUtil { ((jogamp.newt.DisplayImpl) newtDisplay).dispatchMessages(); } }; this.swtDisplay = swtDisplay; - this.nedt = new NewtEventDispatchThread(threadGroup, name); + this.nedt = new NEDT(threadGroup, name); this.nedt.setDaemon(true); // don't stop JVM from shutdown .. } @@ -77,34 +77,39 @@ public class SWTEDTUtil implements EDTUtil { } @Override - public final void reset() throws IllegalStateException { + public final boolean restart() throws IllegalStateException { + final boolean swtDisposed = swtDisplay.isDisposed(); synchronized(edtLock) { - final Thread curT = Thread.currentThread(); - final Thread swtT = !swtDisplay.isDisposed() ? swtDisplay.getThread() : null; - final boolean onSWTEDT = swtT == curT; if( nedt.isRunning() ) { - if( !nedt.shouldStop ) { - throw new IllegalStateException("EDT stop not issued."); - } - if( nedt != curT && !onSWTEDT ) { - throw new IllegalStateException("EDT still running: Curr "+curT.getName()+", NEDT "+nedt.getName()+", SWT-EDT "+swtT.getName()); - } + final Thread curT = Thread.currentThread(); + final Thread swtT = !swtDisposed ? swtDisplay.getThread() : null; + final boolean onSWTEDT = swtT == curT; + throw new IllegalStateException("EDT still running and not subject to stop. Curr "+curT.getName()+", NEDT "+nedt.getName()+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop+", SWT-EDT "+swtT.getName()+", on SWT-EDT "+onSWTEDT); } if(DEBUG) { - System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt); + System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt+", swtDisposed (skipping) "+swtDisposed); + } + if( !swtDisposed ) { + if( nedt.getState() != Thread.State.NEW ) { + nedt = new NEDT(threadGroup, name); + nedt.setDaemon(true); // don't stop JVM from shutdown .. + } + startImpl(); } - this.nedt = new NewtEventDispatchThread(threadGroup, name); - this.nedt.setDaemon(true); // don't stop JVM from shutdown .. + } + if( !swtDisposed ) { + return invoke(true, nullTask); + } else { + return false; } } private final void startImpl() { if(nedt.isAlive()) { - throw new RuntimeException("SWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); + throw new RuntimeException("SWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning+", shouldStop "+nedt.shouldStop+", edt: "+nedt); } start_iter++; nedt.setName(name+start_iter); - nedt.shouldStop = false; if(DEBUG) { System.err.println(Thread.currentThread()+": SWT-EDT START - edt: "+nedt); // Thread.dumpStack(); @@ -130,60 +135,89 @@ public class SWTEDTUtil implements EDTUtil { @Override public boolean isRunning() { - return nedt.isRunning() ; + return nedt.isRunning(); } @Override - public final void invokeStop(boolean wait, Runnable task) { - invokeImpl(wait, task, true); + public final boolean invokeStop(boolean wait, Runnable task) { + return invokeImpl(wait, task, true); } @Override - public final void invoke(boolean wait, Runnable task) { - invokeImpl(wait, task, false); + public final boolean invoke(boolean wait, Runnable task) { + return invokeImpl(wait, task, false); } - private void invokeImpl(boolean wait, Runnable task, boolean stop) { + private static Runnable nullTask = new Runnable() { + @Override + public void run() { } + }; + + private final boolean invokeImpl(boolean wait, Runnable task, boolean stop) { Throwable throwable = null; RunnableTask rTask = null; - Object rTaskLock = new Object(); + final Object rTaskLock = new Object(); synchronized(rTaskLock) { // lock the optional task execution synchronized(edtLock) { // lock the EDT status if( nedt.shouldStop ) { // drop task .. if(DEBUG) { - System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt+", isRunning "+nedt.isRunning()); - // Thread.dumpStack(); + System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop); + Thread.dumpStack(); } - return; + return false; } - // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); - // Thread.dumpStack(); - if(stop) { - if(DEBUG) { - System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt+", isRunning "+nedt.isRunning()); + if( swtDisplay.isDisposed() ) { + stop = true; + } + + if( isCurrentThreadEDT() ) { + if(null != task) { + task.run(); } - synchronized(nedt.sync) { + wait = false; // running in same thread (EDT) -> no wait + if( stop ) { nedt.shouldStop = true; - nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) } - } else if( !nedt.isRunning() && !swtDisplay.isDisposed() ) { - // start if should not stop && not started yet - startImpl(); - } - if( null == task ) { - wait = false; - } else if( swtDisplay.isDisposed() ) { - wait = false; // drop task, SWT disposed - } else if( isCurrentThreadEDT() ) { - task.run(); - wait = false; // running in same thread (EDT) -> no wait - } else { - rTask = new RunnableTask(task, - wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */, - wait ? null : System.err); - swtDisplay.asyncExec(rTask); + } else { + if( !nedt.isRunning && !swtDisplay.isDisposed() ) { + if( null != task ) { + if( stop ) { + System.err.println(Thread.currentThread()+": Warning: SWT-EDT is about (3) to stop and stopped already, dropping task. NEDT "+nedt); + } else { + System.err.println(Thread.currentThread()+": Warning: SWT-EDT is not running, dropping task. NEDT "+nedt); + } + if(DEBUG) { + Thread.dumpStack(); + } + } + return false; + } else if( stop ) { + if( nedt.isRunning ) { + if(DEBUG) { + System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop); + } + synchronized(nedt.sync) { + nedt.shouldStop = true; + nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) + } + } + if( swtDisplay.isDisposed() ) { + System.err.println(Thread.currentThread()+": Warning: SWT-EDT is about (3) to stop and stopped already, dropping task. "+nedt); + if(DEBUG) { + Thread.dumpStack(); + } + return false; + } + } + + if( null != task ) { + rTask = new RunnableTask(task, + wait ? rTaskLock : null, + true /* always catch and report Exceptions, don't disturb EDT */, + wait ? null : System.err); + swtDisplay.asyncExec(rTask); + } } } if( wait ) { @@ -202,55 +236,60 @@ public class SWTEDTUtil implements EDTUtil { throw new RuntimeException(throwable); } } + return true; } } @Override - final public void waitUntilIdle() { - final NewtEventDispatchThread _nedt; + final public boolean waitUntilIdle() { + final NEDT _nedt; synchronized(edtLock) { _nedt = nedt; } final Thread ct = Thread.currentThread(); - if( !_nedt.isRunning() || _nedt == ct || swtDisplay.isDisposed() || swtDisplay.getThread() == ct ) { - return; + if( !_nedt.isRunning || _nedt == ct || swtDisplay.isDisposed() || swtDisplay.getThread() == ct ) { + return false; } try { swtDisplay.syncExec(new Runnable() { public void run() { } }); } catch (Exception e) { } + return true; } @Override - final public void waitUntilStopped() { + final public boolean waitUntilStopped() { synchronized(edtLock) { final Thread curT = Thread.currentThread(); final Thread swtT = !swtDisplay.isDisposed() ? swtDisplay.getThread() : null; final boolean onSWTEDT = swtT == curT; - if( nedt.isRunning() && nedt != curT && !onSWTEDT ) { - while(nedt.isRunning()) { + if( nedt.isRunning && nedt != curT && !onSWTEDT ) { + while( nedt.isRunning ) { try { edtLock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } + return true; + } else { + return false; } } } - class NewtEventDispatchThread extends Thread { + class NEDT extends Thread { volatile boolean shouldStop = false; volatile boolean isRunning = false; Object sync = new Object(); - public NewtEventDispatchThread(ThreadGroup tg, String name) { + public NEDT(ThreadGroup tg, String name) { super(tg, name); } final public boolean isRunning() { - return isRunning; + return isRunning && !shouldStop; } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java index f8e6ee5d3..f1bc0ab7a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java @@ -184,6 +184,7 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { } protected void runJOGLTasks(int num, boolean reuse) throws InterruptedException { + System.err.println("InitConcurrentBaseNEWT "+num+" threads, reuse display: "+reuse); final String currentThreadName = Thread.currentThread().getName(); final Object syncDone = new Object(); final JOGLTask[] tasks = new JOGLTask[num]; @@ -198,13 +199,16 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { for(i=0; i */ public class TestInitConcurrent01NEWT extends InitConcurrentBaseNEWT { - static boolean mainRun = false; - + @Test(timeout=180000) // TO 3 min public void test02TwoThreads() throws InterruptedException { runJOGLTasks(2, true); @@ -56,8 +55,7 @@ public class TestInitConcurrent01NEWT extends InitConcurrentBaseNEWT { @Test(timeout=300000) // TO 5 min public void test16SixteenThreads() throws InterruptedException { - if( !mainRun && - Platform.getCPUFamily() != Platform.CPUFamily.ARM && + if( Platform.getCPUFamily() != Platform.CPUFamily.ARM && Platform.getOSType() != Platform.OSType.WINDOWS ) { runJOGLTasks(16, true); } else { @@ -66,11 +64,8 @@ public class TestInitConcurrent01NEWT extends InitConcurrentBaseNEWT { } public static void main(String args[]) throws IOException { - mainRun = true; for(int i=0; i Date: Mon, 15 Jul 2013 13:39:22 +0200 Subject: Add Support for GL 4.3 (Bug 716) and ES 3.0 (Bug 717) ES3 / GL4.3: - Update all EGL, GLX, WGL and GL (desktop and mobile) khronos headers to latest version. - GL3/gl3* -> GL/glcorearb* - Explicitly preserve ES2_compatibility and ES3_compatibility in header, most extension grouping was removed in new headers. - Always load all GLHeader to ensure proper extension association across all profiles. - Unified method signatures - Added GL_EXT_map_buffer_range to core - Using common 'glMapBufferImpl(..)' for all glMapBuffer(..) and glMapBufferRange(..) impl. - Init necessary fields of GL instances via 'finalizeInit()' called by reflection, if exist. This allows removing initialization checks, i.e. for all buffer validations. - BuildStaticGLInfo: Can handle new GL header structure, i.e. one CPP extenstion block incl. define + funcs. - GLJavaMethodBindingEmitter: Simply print the - No GL duplication due to new intermediate interfaces, see below - OO lineare inheritance (Added GL2ES3, GL3ES3 and GL4ES3 intemediates): GLBase - GL - GL2ES2 - GLES2 GLBase - GL - GL2ES2 - GL2GL3 - [ GL2, GL3 ] GLBase - GL - GL2ES2 - GL2ES3 - GL3ES3 - [ GL3 ] GLBase - GL - GL2ES2 - GL2ES3 - GL3ES3 - GL4ES3 - [ GLES3, GL4, .. ] - Expose 'usable' intermediate interfaces GL3ES3 and GL4ES3 in GLBase/GLProfile/GLContext via is*() and get*(). - GLContext*: - isGL3core() is true if [ GL4, GL3, GLES3 ] (added GLES3) - Added ctxProfile argument to allow handling ES versions: - getMaxMajor(..), getMaxMinor(..), isValidGLVersion(..) and decrementGLVersion(..) - mapGLVersions(..) prepared for ES ARB/KHR validation - EGLContext checks ES3 (via old ctx's GL_VERSION) - ExtensionAvailabilityCache adds GL_ES_Version_X_Y for ES. - Prelim tests w/ Mesa 9.1.3 GL Version 3.0 (ES profile, ES2 compat, ES3 compat, FBO, hardware) - OpenGL ES 3.0 Mesa 9.1.3 [GL 3.0.0, vendor 9.1.3 (Mesa 9.1.3)] - TODO: - Use KHR_create_context in EGLContext.createContextARBImpl(..) - More tests (Mobile, ..) +++ Misc: - GLContext*: - Complete glAllocateMemoryNV w/ glFreeMemoryNV. --- make/build-jogl.xml | 189 +- make/config/jogl/gl-common-extensions.cfg | 26 +- make/config/jogl/gl-common.cfg | 173 +- make/config/jogl/gl-desktop.cfg | 5 - make/config/jogl/gl-es1.cfg | 12 - make/config/jogl/gl-es2.cfg | 90 - make/config/jogl/gl-es3.cfg | 98 + make/config/jogl/gl-gl4bc.cfg | 36 +- make/config/jogl/gl-headers.cfg | 3 +- make/config/jogl/gl-if-CustomJavaCode-es3.java | 14 + make/config/jogl/gl-if-CustomJavaCode-gl.java | 8 + make/config/jogl/gl-if-CustomJavaCode-gl2_es2.java | 11 + make/config/jogl/gl-if-CustomJavaCode-gl2_gl3.java | 10 - .../jogl/gl-if-CustomJavaCode-gl_compat.java | 20 + make/config/jogl/gl-if-CustomJavaCode-gles2.java | 3 - make/config/jogl/gl-if-es2.cfg | 30 + make/config/jogl/gl-if-gl-ignores.cfg | 24 +- make/config/jogl/gl-if-gl.cfg | 12 +- make/config/jogl/gl-if-gl2.cfg | 5 +- make/config/jogl/gl-if-gl2_es1.cfg | 33 +- make/config/jogl/gl-if-gl2_es2-ignores.cfg | 48 + make/config/jogl/gl-if-gl2_es2.cfg | 57 +- make/config/jogl/gl-if-gl2_es3-ignores.cfg | 47 + make/config/jogl/gl-if-gl2_es3.cfg | 45 + make/config/jogl/gl-if-gl2_gl3.cfg | 15 +- make/config/jogl/gl-if-gl2es3-subset.cfg | 17 + make/config/jogl/gl-if-gl2gl3-subset.cfg | 18 + make/config/jogl/gl-if-gl3-subset.cfg | 17 - make/config/jogl/gl-if-gl3.cfg | 10 +- make/config/jogl/gl-if-gl3_es3.cfg | 43 + make/config/jogl/gl-if-gl3bc.cfg | 6 + make/config/jogl/gl-if-gl4-ignores.cfg | 2 + make/config/jogl/gl-if-gl4.cfg | 7 + make/config/jogl/gl-if-gl4_es3.cfg | 47 + make/config/jogl/gl-if-luminance-ignore.cfg | 7 + make/config/jogl/gl-impl-CustomCCode-gl4bc.c | 16 + make/config/jogl/gl-impl-CustomCCode-gles1.c | 16 + make/config/jogl/gl-impl-CustomCCode-gles2.c | 25 - make/config/jogl/gl-impl-CustomCCode-gles3.c | 41 + .../config/jogl/gl-impl-CustomJavaCode-common.java | 92 + .../jogl/gl-impl-CustomJavaCode-desktop.java | 148 - make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java | 326 +- make/config/jogl/gl-impl-CustomJavaCode-gles1.java | 80 +- make/config/jogl/gl-impl-CustomJavaCode-gles2.java | 262 - make/config/jogl/gl-impl-CustomJavaCode-gles3.java | 320 + make/config/jogl/gl2_es2-CustomJavaCode.cfg | 13 + make/config/jogl/gl2_es2-common.cfg | 16 +- make/config/jogl/gl2_es3-common.cfg | 9 + make/config/jogl/gl3-common.cfg | 9 + make/config/jogl/gl3-desktop.cfg | 5 - make/config/jogl/gl3-headers.cfg | 14 +- make/config/jogl/gl3ext-headers.cfg | 8 +- make/config/jogl/glx-x11.cfg | 1 - make/scripts/cmpOld2New.sh | 2 +- make/scripts/cmpOld2NewDups.sh | 121 + make/scripts/gluegen-gl.sh | 385 +- make/scripts/make.jogl.all.linux-x86_64.sh | 1 + make/scripts/tests.sh | 6 +- make/stub_includes/egl/EGL/eglext.h | 262 +- make/stub_includes/opengl/GL/gl-platform.h | 80 + make/stub_includes/opengl/GL/gl.h | 740 +- make/stub_includes/opengl/GL/glcorearb.h | 3262 +++ make/stub_includes/opengl/GL/glcorearbext.h | 351 + make/stub_includes/opengl/GL/glext.h | 20385 +++++++++---------- make/stub_includes/opengl/GL/glplatform.h | 67 - make/stub_includes/opengl/GL/glu.h | 252 +- make/stub_includes/opengl/GL/glx.h | 336 +- make/stub_includes/opengl/GL/glxext.h | 1495 +- make/stub_includes/opengl/GL/wglext.h | 1253 +- make/stub_includes/opengl/GL3/gl3.h | 3606 ---- make/stub_includes/opengl/GL3/gl3ext.h | 351 - make/stub_includes/opengl/GL3/glplatform.h | 63 - make/stub_includes/opengl/GLES/gl.h | 4 +- make/stub_includes/opengl/GLES/glext.h | 129 +- make/stub_includes/opengl/GLES2/gl2.h | 8 +- make/stub_includes/opengl/GLES2/gl2ext.h | 689 +- make/stub_includes/opengl/GLES3/gl3.h | 1073 + make/stub_includes/opengl/GLES3/gl3ext.h | 24 + make/stub_includes/opengl/GLES3/gl3platform.h | 30 + make/stub_includes/opengl/GLES3/khrplatform.h | 269 + make/stub_includes/opengl/gl-64bit-types.h | 21 - make/stub_includes/opengl/gl-types.h | 15 + make/stub_includes/opengl/gl2es12.c | 9 - make/stub_includes/opengl/gl3.c | 13 +- make/stub_includes/opengl/gl3bc.c | 13 +- make/stub_includes/opengl/gl4.c | 12 +- make/stub_includes/opengl/gl4bc.c | 13 +- make/stub_includes/opengl/gles3.c | 12 + make/stub_includes/win32/windows.h | 3 + make/stub_includes/x11/window-system1.c | 6 +- .../gluegen/opengl/BuildComposablePipeline.java | 42 +- .../jogamp/gluegen/opengl/BuildStaticGLInfo.java | 79 +- .../com/jogamp/gluegen/opengl/GLConfiguration.java | 61 +- .../gluegen/opengl/GLJavaMethodBindingEmitter.java | 8 +- .../classes/com/jogamp/opengl/GLExtensions.java | 3 +- src/jogl/classes/javax/media/opengl/GLBase.java | 49 +- src/jogl/classes/javax/media/opengl/GLContext.java | 183 +- .../classes/javax/media/opengl/GLDebugMessage.java | 74 +- src/jogl/classes/javax/media/opengl/GLProfile.java | 333 +- .../jogamp/opengl/ExtensionAvailabilityCache.java | 20 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 124 +- .../jogamp/opengl/GLDebugMessageHandler.java | 4 +- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 51 +- .../jogamp/opengl/egl/EGLDrawableFactory.java | 114 +- .../opengl/egl/EGLDynamicLibraryBundleInfo.java | 2 +- .../opengl/egl/EGLES2DynamicLibraryBundleInfo.java | 28 +- .../jogamp/opengl/egl/EGLGLCapabilities.java | 6 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 14 +- .../opengl/windows/wgl/WindowsWGLContext.java | 10 +- .../jogamp/opengl/x11/glx/X11GLXContext.java | 9 +- src/jogl/native/GLDebugMessageHandler.c | 8 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 29 +- .../test/junit/jogl/acore/TestGLDebug00NEWT.java | 13 +- .../test/junit/jogl/acore/TestGLDebug01NEWT.java | 12 +- .../jogl/acore/TestMainVersionGLWindowNEWT.java | 6 +- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 6 + 116 files changed, 20959 insertions(+), 18279 deletions(-) delete mode 100644 make/config/jogl/gl-es2.cfg create mode 100644 make/config/jogl/gl-es3.cfg create mode 100644 make/config/jogl/gl-if-CustomJavaCode-es3.java delete mode 100644 make/config/jogl/gl-if-CustomJavaCode-gl2_gl3.java create mode 100644 make/config/jogl/gl-if-CustomJavaCode-gl_compat.java delete mode 100644 make/config/jogl/gl-if-CustomJavaCode-gles2.java create mode 100644 make/config/jogl/gl-if-es2.cfg create mode 100644 make/config/jogl/gl-if-gl2_es2-ignores.cfg create mode 100644 make/config/jogl/gl-if-gl2_es3-ignores.cfg create mode 100644 make/config/jogl/gl-if-gl2_es3.cfg create mode 100644 make/config/jogl/gl-if-gl2es3-subset.cfg create mode 100644 make/config/jogl/gl-if-gl2gl3-subset.cfg delete mode 100644 make/config/jogl/gl-if-gl3-subset.cfg create mode 100644 make/config/jogl/gl-if-gl3_es3.cfg create mode 100644 make/config/jogl/gl-if-gl4_es3.cfg create mode 100644 make/config/jogl/gl-if-luminance-ignore.cfg delete mode 100644 make/config/jogl/gl-impl-CustomCCode-gles2.c create mode 100644 make/config/jogl/gl-impl-CustomCCode-gles3.c delete mode 100644 make/config/jogl/gl-impl-CustomJavaCode-desktop.java delete mode 100644 make/config/jogl/gl-impl-CustomJavaCode-gles2.java create mode 100644 make/config/jogl/gl-impl-CustomJavaCode-gles3.java create mode 100644 make/config/jogl/gl2_es2-CustomJavaCode.cfg create mode 100644 make/config/jogl/gl2_es3-common.cfg create mode 100644 make/config/jogl/gl3-common.cfg create mode 100644 make/scripts/cmpOld2NewDups.sh create mode 100644 make/stub_includes/opengl/GL/gl-platform.h create mode 100644 make/stub_includes/opengl/GL/glcorearb.h create mode 100644 make/stub_includes/opengl/GL/glcorearbext.h delete mode 100644 make/stub_includes/opengl/GL/glplatform.h delete mode 100644 make/stub_includes/opengl/GL3/gl3.h delete mode 100644 make/stub_includes/opengl/GL3/gl3ext.h delete mode 100644 make/stub_includes/opengl/GL3/glplatform.h create mode 100644 make/stub_includes/opengl/GLES3/gl3.h create mode 100644 make/stub_includes/opengl/GLES3/gl3ext.h create mode 100644 make/stub_includes/opengl/GLES3/gl3platform.h create mode 100644 make/stub_includes/opengl/GLES3/khrplatform.h delete mode 100644 make/stub_includes/opengl/gl-64bit-types.h create mode 100644 make/stub_includes/opengl/gl-types.h delete mode 100644 make/stub_includes/opengl/gl2es12.c create mode 100644 make/stub_includes/opengl/gles3.c (limited to 'src/newt/classes') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 9c017ed62..7b9b8a957 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -140,11 +140,11 @@ - + - + @@ -319,7 +319,11 @@ - + + + + + @@ -381,6 +385,12 @@ + + + + + @@ -398,6 +408,7 @@ + @@ -440,6 +451,20 @@ + + + + + + + + @@ -453,12 +478,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - @@ -527,48 +600,47 @@ - - + + - + emitter="com.jogamp.gluegen.opengl.GLEmitter"> - - + + - + emitter="com.jogamp.gluegen.opengl.GLEmitter"> - - + + - + emitter="com.jogamp.gluegen.opengl.GLEmitter" + debug="false"> - + - - + - + + + @@ -822,12 +883,6 @@ - the classpath reference id then running the task on each header. --> - - - - + + + + + + + + + + + + @@ -936,6 +1007,14 @@ + + + + + + + + @@ -972,7 +1051,7 @@ - + @@ -1013,7 +1092,7 @@ + @@ -1544,6 +1624,7 @@ + @@ -1603,12 +1684,12 @@ + includes="${java.part.egl} ${java.part.es1} ${java.part.es2es3}" + excludes="${java.part.awt} ${java.part.swt} ${java.part.es1.dbg} ${java.part.es2es3.dbg}"/> + includes="${java.part.es1.dbg} ${java.part.es2es3.dbg}"/> diff --git a/make/config/jogl/gl-common-extensions.cfg b/make/config/jogl/gl-common-extensions.cfg index 6631e035d..a723a9fd8 100644 --- a/make/config/jogl/gl-common-extensions.cfg +++ b/make/config/jogl/gl-common-extensions.cfg @@ -20,6 +20,7 @@ DropUniqVendorExtensions WIN # Drop some obsolete or mostly-integrated vendor extensions that the above directives let in # Note that some of these are in LWJGL, so perhaps there is justification for leaving them in +IgnoreExtension GL_APPLE_sync IgnoreExtension GL_APPLE_element_array IgnoreExtension GL_APPLE_vertex_array_object IgnoreExtension GL_ATI_element_array @@ -46,6 +47,7 @@ IgnoreExtension GL_NV_texture_rectangle IgnoreExtension GL_NV_vertex_program # This one would require more work -- has associated GLX and WGL bindings IgnoreExtension GL_NV_present_video +IgnoreExtension GL_OES_fixed_point # For the time being, ignore these extensions which are in the ES 2.0 spec IgnoreExtension GL_NV_framebuffer_vertex_attrib_array @@ -86,25 +88,11 @@ RenameExtensionIntoCore GL_NV_draw_buffers RenameExtensionIntoCore GL_NV_fbo_color_attachments RenameExtensionIntoCore GL_EXT_packed_float RenameExtensionIntoCore GL_EXT_texture_format_BGRA8888 - -# A mess w/ the ES2 definition .. sadly -# RenameExtensionIntoCore GL_EXT_texture_storage -RenameJavaSymbol glTexStorage1DEXT glTexStorage1D -RenameJavaSymbol glTexStorage2DEXT glTexStorage2D -RenameJavaSymbol glTexStorage3DEXT glTexStorage3D -RenameJavaSymbol GL_TEXTURE_IMMUTABLE_FORMAT_EXT GL_TEXTURE_IMMUTABLE_FORMAT -RenameJavaSymbol GL_RGBA32F_EXT GL_RGBA32F -RenameJavaSymbol GL_RGB32F_EXT GL_RGB32F -RenameJavaSymbol GL_ALPHA32F_EXT GL_ALPHA32F_ARB -RenameJavaSymbol GL_LUMINANCE32F_EXT GL_LUMINANCE32F_ARB -RenameJavaSymbol GL_LUMINANCE_ALPHA32F_EXT GL_LUMINANCE_ALPHA32F_ARB -RenameJavaSymbol GL_RGB16F_EXT GL_RGB16F -RenameJavaSymbol GL_ALPHA16F_EXT GL_ALPHA16F_ARB -RenameJavaSymbol GL_LUMINANCE16F_EXT GL_LUMINANCE16F_ARB -RenameJavaSymbol GL_LUMINANCE_ALPHA16F_EXT GL_LUMINANCE_ALPHA16F_ARB -RenameJavaSymbol GL_RGB10_A2_EXT GL_RGB10_A2 -RenameJavaSymbol GL_RGB10_EXT GL_RGB10 - +RenameExtensionIntoCore GL_OES_single_precision +RenameExtensionIntoCore GL_EXT_draw_buffers +RenameExtensionIntoCore GL_EXT_texture_storage +RenameExtensionIntoCore GL_ARB_texture_storage +RenameExtensionIntoCore GL_EXT_map_buffer_range # The following extensions have some differences requiring us to # manually rename some symbols and leave others alone for best diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg index ad0b7d1d0..ddb312075 100644 --- a/make/config/jogl/gl-common.cfg +++ b/make/config/jogl/gl-common.cfg @@ -7,6 +7,19 @@ HierarchicalNativeOutput false RuntimeExceptionType GLException UnsupportedExceptionType GLException +# Inform the glue code generator of the association between #defines +# and functions and the extensions in which they are defined +GLHeader GL/gl.h +GLHeader GL/glext.h +GLHeader GL/glcorearb.h +GLHeader GL/glcorearbext.h +GLHeader GLES/gl.h +GLHeader GLES/glext.h +GLHeader GLES2/gl2.h +GLHeader GLES2/gl2ext.h +GLHeader GLES3/gl3.h +GLHeader GLES3/gl3ext.h + # Imports needed by all glue code Import java.util.* Import javax.media.opengl.* @@ -37,13 +50,17 @@ Ignore glGetVertexAttribPointerv Ignore glGetVertexAttribPointervARB Ignore glGetVertexAttribPointervNV Ignore glTracePointerRangeMESA -Ignore glDebugMessageCallbackARB Ignore glDebugMessageCallbackAMD +Ignore glDebugMessageCallbackARB +Ignore glDebugMessageCallbackKHR +Ignore glDebugMessageCallback -# Manually implement glMapBuffer as the size of the returned buffer +# Manually implement glMapBuffer and glMapBufferRange as the size of the returned buffer # can only be computed by calling another routine ManuallyImplement glMapBuffer ForceProcAddressGen glMapBuffer +ManuallyImplement glMapBufferRange +ForceProcAddressGen glMapBufferRange # Ignore the ATI_map_object_buffer extension for now unless someone # claims they need it, as it will undoubtedly require a similar @@ -249,7 +266,7 @@ RenameExtensionIntoCore GL_EXT_draw_buffers2 RenameExtensionIntoCore GL_ARB_texture_compression_rgtc IgnoreExtension GL_EXT_texture_compression_rgtc -RenameExtensionIntoCore GL_EXT_transform_feedback +IgnoreExtension GL_EXT_transform_feedback IgnoreExtension GL_NV_transform_feedback # gl.h uses GL_ARB_vertex_array_object @@ -277,6 +294,8 @@ IgnoreExtension GL_EXT_texture_buffer_object RenameExtensionIntoCore GL_EXT_texture_rectangle IgnoreExtension GL_NV_texture_rectangle RenameExtensionIntoCore GL_ARB_uniform_buffer_object +# Use Manual definition, otherwise GlueGen uses 'long' type +Ignore GL_INVALID_INDEX # <<< OpenGL 3.1 # >>> OpenGL 3.2 @@ -339,6 +358,17 @@ RenameExtensionIntoCore GL_ARB_viewport_array # Rename extension suffices (if exist) subsumed in OpenGL 4.2 (from OpenGL 4.2 spec, Appendix L.1) # <<< OpenGL 4.2 +# >>> OpenGL 4.3 +# Rename extension suffices (if exist) subsumed in OpenGL 4.3 (from OpenGL 4.3 spec, Appendix ?.1) +RenameExtensionIntoCore GL_ARB_debug_output +# <<< OpenGL 4.3 + +# >>> OpenGL ES 2.0 +# <<< OpenGL ES 2.0 + +# >>> OpenGL ES 3.0 +# <<< OpenGL ES 3.0 + # Ignore a few obsolete versions of extensions that have been subsumed into the core or ARB extensions IgnoreExtension GL_EXT_multisample IgnoreExtension GL_EXT_point_parameters @@ -352,6 +382,8 @@ IgnoreExtension GL_EXT_shader_image_load_store Opaque boolean GLboolean Opaque long GLsync Opaque long GLeglImageOES +Opaque long cl_context +Opaque long cl_event ReturnsString glGetString ReturnsString glGetStringi @@ -421,9 +453,6 @@ NIODirectOnly glExtGetBufferPointervQCOM ReturnValueCapacity wglAllocateMemoryNV {0} ReturnValueCapacity glXAllocateMemoryNV {0} -ReturnValueCapacity glMapBufferRange {2} -ReturnValueCapacity glMapNamedBufferRangeEXT {2} - # Pass arguments to ARB_vertex_program, ARB_fragment_program, # ARB_shader_objects, NV_vertex_program, NV_fragment_program, and # ARB_vertex_shader as Strings @@ -473,7 +502,7 @@ ArgumentIsString glGetFragDataIndex 1 ArgumentIsString glGetSubroutineIndex 2 ArgumentIsString glGetSubroutineUniformLocation 2 -ArgumentIsString glDebugMessageInsertARB 5 +ArgumentIsString glDebugMessageInsert 5 ArgumentIsString glDebugMessageInsertAMD 4 ArgumentIsString glNamedStringARB 2 4 @@ -702,78 +731,122 @@ RangeCheck glDeleteVertexArraysAPPLE 1 {0} # Javadoc for the GL class ClassJavadoc GL /** -ClassJavadoc GL *

    Common interface containing the subset of all profiles, GL3bc, GL3, GL2, GLES1 and GLES2.
    -ClassJavadoc GL * This interface reflects common data types, texture and framebuffer functionality.

    +ClassJavadoc GL *

    Common interface containing the subset of all profiles, GL3bc, GL3, GL2, GLES1 and GLES2.
    +ClassJavadoc GL * This interface reflects common data types, texture and framebuffer functionality.

    ClassJavadoc GL */ ClassJavadoc GL2ES1 /** -ClassJavadoc GL2ES1 *

    -ClassJavadoc GL2ES1 * Interface containing the common subset of GL2 and GLES1.
    -ClassJavadoc GL2ES1 * This interface reflects only the fixed functionality of OpenGL
    -ClassJavadoc GL2ES1 *

    +ClassJavadoc GL2ES1 *

    +ClassJavadoc GL2ES1 * Interface containing the common subset of GL2 and GLES1.
    +ClassJavadoc GL2ES1 * This interface reflects only the fixed functionality of OpenGL
    +ClassJavadoc GL2ES1 *

    ClassJavadoc GL2ES1 */ ClassJavadoc GL2ES2 /** -ClassJavadoc GL2ES2 *

    -ClassJavadoc GL2ES2 * Interface containing the common subset of GL3, GL2 and GLES2.
    -ClassJavadoc GL2ES2 * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL
    -ClassJavadoc GL2ES2 *

    +ClassJavadoc GL2ES2 *

    +ClassJavadoc GL2ES2 * Interface containing the common subset of GL3, GL2 and GLES2.
    +ClassJavadoc GL2ES2 * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL
    +ClassJavadoc GL2ES2 * This interface is almost GLES2 complete.
    +ClassJavadoc GL2ES2 *

    ClassJavadoc GL2ES2 */ +ClassJavadoc GL2ES3 /** +ClassJavadoc GL2ES3 *

    +ClassJavadoc GL2ES3 * Interface containing the common subset of core GL2 and GLES3 (OpenGL ES 3.0).
    +ClassJavadoc GL2ES3 * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL
    +ClassJavadoc GL2ES3 * This interface is not GLES3 complete and merely exist to avoid duplicated definitions.
    +ClassJavadoc GL2ES3 *

    +ClassJavadoc GL2ES3 */ + +ClassJavadoc GL3ES3 /** +ClassJavadoc GL3ES3 *

    +ClassJavadoc GL3ES3 * Interface containing the common subset of core GL3 (OpenGL 3.1+) and GLES3 (OpenGL ES 3.0).
    +ClassJavadoc GL3ES3 * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL
    +ClassJavadoc GL3ES3 * This interface is almost GLES3 complete, but lacks the GL_ARB_ES3_compatibility extension.
    +ClassJavadoc GL3ES3 *

    +ClassJavadoc GL3ES3 */ + +ClassJavadoc GL4ES3 /** +ClassJavadoc GL4ES3 *

    +ClassJavadoc GL4ES3 * Interface containing the common subset of core GL4 (OpenGL 4.0+) and GLES3 (OpenGL ES 3.0).
    +ClassJavadoc GL4ES3 * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL
    +ClassJavadoc GL4ES3 * This interface is GLES3 complete.
    +ClassJavadoc GL4ES3 *

    +ClassJavadoc GL4ES3 */ + ClassJavadoc GL2GL3 /** -ClassJavadoc GL2GL3 *

    -ClassJavadoc GL2GL3 * Interface containing the common subset of core GL3 (OpenGL 3.1+) and GL2 (OpenGL 3.0), -ClassJavadoc GL2GL3 * also known as the OpenGL 3.0 forward compatible, non deprecated subset.
    -ClassJavadoc GL2GL3 * This interface reflects only the programmable shader functionality of desktop OpenGL
    -ClassJavadoc GL2GL3 *

    +ClassJavadoc GL2GL3 *

    +ClassJavadoc GL2GL3 * Interface containing the common subset of core GL3 (OpenGL 3.1) and GL2 (OpenGL 3.0), +ClassJavadoc GL2GL3 * also known as the OpenGL 3.0 forward compatible, non deprecated subset.
    +ClassJavadoc GL2GL3 * This interface reflects only the programmable shader functionality of desktop OpenGL
    +ClassJavadoc GL2GL3 *

    ClassJavadoc GL2GL3 */ ClassJavadoc GL2 /** -ClassJavadoc GL2 *

    +ClassJavadoc GL2 *

    ClassJavadoc GL2 * This interface contains all core desktop OpenGL methods through ClassJavadoc GL2 * version 3.0, inclusive, as well as most of it's extensions defined at the ClassJavadoc GL2 * time of this specification. Early OpenGL extensions whose functionality ClassJavadoc GL2 * was incorporated into core OpenGL by version 3.0, inclusive, are specifically -ClassJavadoc GL2 * excluded.
    +ClassJavadoc GL2 * excluded.
    ClassJavadoc GL2 * Note: OpenGL 3.0 is the last subsumed version in the specification. ClassJavadoc GL2 * You need to use a {@link GL3} or {@link GL3bc} OpenGL 3.1+ context to benefit ClassJavadoc GL2 * from new functionality and versions. -ClassJavadoc GL2 *

    +ClassJavadoc GL2 *

    ClassJavadoc GL2 */ -ClassJavadoc GL3bc /** -ClassJavadoc GL3bc *

    -ClassJavadoc GL3bc * This interface contains the OpenGL 3.x compatibility profile, ie includes all methods -ClassJavadoc GL3bc * as defined in {@link GL2} and {@link GL3}.
    -ClassJavadoc GL3bc *

    -ClassJavadoc GL3bc */ - ClassJavadoc GL3 /** -ClassJavadoc GL3 *

    -ClassJavadoc GL3 * This interface contains all core, forward compatible, OpenGL methods starting from 3.1, -ClassJavadoc GL3 * inclusive, as well as most of it's extensions defined at the time of this specification.
    +ClassJavadoc GL3 *

    +ClassJavadoc GL3 * This interface contains the core, forward compatible, OpenGL methods of GL 3.x, with x >=1, +ClassJavadoc GL3 * as well as most of it's extensions defined at the time of this specification.
    ClassJavadoc GL3 * Note: OpenGL 3.0 forward compatible, non deprecated functionality is included in the -ClassJavadoc GL3 * 3.1 specification, hence the {@link GL2GL3} implemented interface.
    -ClassJavadoc GL3 * Note: OpenGL 3.1 forward compatible no more includes fixed point functionality. -ClassJavadoc GL3 *

    +ClassJavadoc GL3 * 3.1 specification, hence the {@link GL2GL3} implemented interface.
    +ClassJavadoc GL3 * Note: OpenGL 3.1 forward compatible, core profile abandoned fixed point functionality. +ClassJavadoc GL3 *

    ClassJavadoc GL3 */ +ClassJavadoc GL3bc /** +ClassJavadoc GL3bc *

    +ClassJavadoc GL3bc * This interface containing all core and compatibility OpenGL methods of GL 3.x, with x >= 1,
    +ClassJavadoc GL3bc * as well as most of it's extensions defined at the time of this specification. +ClassJavadoc GL3bc *

    +ClassJavadoc GL3bc */ + +ClassJavadoc GL4 /** +ClassJavadoc GL4 *

    +ClassJavadoc GL4 * This interface containing all core OpenGL methods of GL 4.x, with x >= 0,
    +ClassJavadoc GL4 * as well as most of it's extensions defined at the time of this specification. +ClassJavadoc GL4 *

    +ClassJavadoc GL4 */ + +ClassJavadoc GL4bc /** +ClassJavadoc GL4bc *

    +ClassJavadoc GL4bc * This interface containing all core and compatibility OpenGL methods of GL 4.x, with x >= 0,
    +ClassJavadoc GL4bc * as well as most of it's extensions defined at the time of this specification. +ClassJavadoc GL4bc *

    +ClassJavadoc GL4bc */ + ClassJavadoc GLES1 /** -ClassJavadoc GLES1 *

    +ClassJavadoc GLES1 *

    ClassJavadoc GLES1 * This interface contains all core embedded OpenGL methods of ES 1.x, with x >= 0, -ClassJavadoc GLES1 * inclusive, as well as most of it's extensions defined at the -ClassJavadoc GLES1 * time of this specification. -ClassJavadoc GLES1 *

    +ClassJavadoc GLES1 * as well as most of it's extensions defined at the time of this specification. +ClassJavadoc GLES1 *

    ClassJavadoc GLES1 */ ClassJavadoc GLES2 /** -ClassJavadoc GLES2 *

    +ClassJavadoc GLES2 *

    ClassJavadoc GLES2 * This interface contains all core embedded OpenGL methods of ES 2.x, with x >= 0, -ClassJavadoc GLES2 * inclusive, as well as most of it's extensions defined at the -ClassJavadoc GLES2 * time of this specification. -ClassJavadoc GLES2 *

    +ClassJavadoc GLES2 * inclusive, as well as most of it's extensions defined at the time of this specification. +ClassJavadoc GLES2 *

    ClassJavadoc GLES2 */ +ClassJavadoc GLES3 /** +ClassJavadoc GLES3 *

    +ClassJavadoc GLES3 * This interface contains all core embedded OpenGL methods of ES 3.x, with x >= 0, +ClassJavadoc GLES3 * inclusive, as well as most of it's extensions defined at the time of this specification. +ClassJavadoc GLES3 *

    +ClassJavadoc GLES3 */ + # Javadoc for the EGL class ClassJavadoc EGL /** ClassJavadoc EGL * Provides access to the embedded-specific OpenGL vendor extensions. @@ -805,11 +878,3 @@ ClassJavadoc XVisualInfo * extensions. No other access is provided to these dat ClassJavadoc XVisualInfo * this wrapper is not useful to end users, though it is used in the implementation. ClassJavadoc XVisualInfo */ -# Custom code for querying extensions and exposing -# wglAllocateMemoryNV/glXAllocateMemoryNV -CustomJavaCode GL2GL3 /** -CustomJavaCode GL2GL3 * Provides platform-independent access to the wglAllocateMemoryNV / -CustomJavaCode GL2GL3 * glXAllocateMemoryNV extension. -CustomJavaCode GL2GL3 */ -CustomJavaCode GL2GL3 public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3); - diff --git a/make/config/jogl/gl-desktop.cfg b/make/config/jogl/gl-desktop.cfg index a91f5ac5b..244271468 100644 --- a/make/config/jogl/gl-desktop.cfg +++ b/make/config/jogl/gl-desktop.cfg @@ -1,11 +1,6 @@ # This .cfg file provides common options used by the desktop OpenGL # implementation on all platforms. -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -GLHeader GL/gl.h -GLHeader GL/glext.h - #Include gl-desktop-tracker.cfg diff --git a/make/config/jogl/gl-es1.cfg b/make/config/jogl/gl-es1.cfg index 2a7b64dd3..b73b1a731 100644 --- a/make/config/jogl/gl-es1.cfg +++ b/make/config/jogl/gl-es1.cfg @@ -30,13 +30,6 @@ EmitProcAddressTable true ProcAddressTableClassName GLES1ProcAddressTable GetProcAddressTableExpr ((GLES1ProcAddressTable)_context.getGLProcAddressTable()) -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -GLHeader GLES/gl.h -GLHeader GLES/glext.h -GLHeader GL/gl.h -GLHeader GL/glext.h - # 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 @@ -49,11 +42,6 @@ LocalProcAddressCallingConvention __ALL__ GL_APIENTRY # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true -# Ignore certain extensions that will be picked up by the dynamic -# lookup mechanism anyway if they are present -IgnoreExtension GL_OES_fixed_point -IgnoreExtension GL_OES_single_precision - # Add PixelStorei StateTracker # # Add input validation to glPixelStorei, just to be sure. diff --git a/make/config/jogl/gl-es2.cfg b/make/config/jogl/gl-es2.cfg deleted file mode 100644 index 8b6152bd0..000000000 --- a/make/config/jogl/gl-es2.cfg +++ /dev/null @@ -1,90 +0,0 @@ -# This .cfg file is used to generate the GL interface and implementing class. -JavaOutputDir gensrc/classes -NativeOutputDir gensrc/native/jogl/es2 - -ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java -ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java -ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java - -Package javax.media.opengl -Style InterfaceAndImpl -JavaClass GLES2 -#Extends GLES2 GLBase -#Extends GLES2 GL -Extends GLES2 GL2ES2 -ImplPackage jogamp.opengl.es2 -ImplJavaClass GLES2Impl -Implements GLES2Impl GLBase -Implements GLES2Impl GL -Implements GLES2Impl GL2ES2 -HierarchicalNativeOutput false -Include gl-common.cfg -Include gl-common-extensions.cfg -Include gl2_es2-common.cfg - -RenameExtensionIntoCore GL_OES_texture_3D -RenameExtensionIntoCore GL_OES_get_program_binary - -EmitProcAddressTable true -ProcAddressTableClassName GLES2ProcAddressTable -GetProcAddressTableExpr ((GLES2ProcAddressTable)_context.getGLProcAddressTable()) - -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -GLHeader GLES2/gl2.h -GLHeader GLES2/gl2ext.h -GLHeader GL/gl.h -GLHeader GL/glext.h - -# 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 GL_APIENTRY -LocalProcAddressCallingConvention __ALL__ GL_APIENTRY - -# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums -TagNativeBinding true - -# Add PixelStorei StateTracker -# -# Add input validation to glPixelStorei, just to be sure. -CustomJavaCode GLES2Impl 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; } - -IncludeAs CustomJavaCode GLES2 gl-if-CustomJavaCode-gles2.java - -CustomCCode #include /* android */ -CustomCCode /* Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in -CustomCCode "glext.h" are parsed. */ -CustomCCode #define GL_GLEXT_PROTOTYPES - -CustomCCode /* Include the OpenGL headers */ -CustomCCode /* #define GL_APICALL __declspec(dllimport) */ -CustomCCode #include -CustomCCode #include -CustomCCode #include - -IncludeAs CustomJavaCode GLES2Impl gl-impl-CustomJavaCode-common.java -IncludeAs CustomJavaCode GLES2Impl gl-impl-CustomJavaCode-gles2.java -IncludeAs CustomJavaCode GLES2Impl gl-impl-CustomJavaCode-embedded.java -IncludeAs CustomJavaCode GLES2Impl gl-impl-CustomJavaCode-gl2_es2.java -IncludeAs CustomCCode gl-impl-CustomCCode-gles2.c - -Import javax.media.opengl.GLES1 -Import javax.media.opengl.GLES2 -Import javax.media.opengl.GL2 -Import javax.media.opengl.GLArrayData -Import javax.media.opengl.GLUniformData -Import com.jogamp.common.nio.Buffers -Import com.jogamp.opengl.util.GLBuffers -Import java.io.PrintStream - diff --git a/make/config/jogl/gl-es3.cfg b/make/config/jogl/gl-es3.cfg new file mode 100644 index 000000000..997723d01 --- /dev/null +++ b/make/config/jogl/gl-es3.cfg @@ -0,0 +1,98 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl/es3 + +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GLES2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL4ES3.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java + +Package javax.media.opengl +Style InterfaceAndImpl +JavaClass GLES3 +#Extends GLES3 GLBase +#Extends GLES3 GL +#Extends GLES3 GL2ES2 +#Extends GLES3 GL2ES3 +#Extends GLES3 GL3ES3 +Extends GLES3 GLES2 +Extends GLES3 GL4ES3 +ImplPackage jogamp.opengl.es3 +ImplJavaClass GLES3Impl +Implements GLES3Impl GLBase +Implements GLES3Impl GL +Implements GLES3Impl GL2ES2 +Implements GLES3Impl GLES2 +Implements GLES3Impl GL2ES3 +Implements GLES3Impl GL3ES3 +Implements GLES3Impl GL4ES3 +HierarchicalNativeOutput false +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl2_es3-common.cfg +Include gl2_es2-CustomJavaCode.cfg + +ForceExtension GL_ARB_ES3_compatibility + +EmitProcAddressTable true +ProcAddressTableClassName GLES3ProcAddressTable +GetProcAddressTableExpr ((GLES3ProcAddressTable)_context.getGLProcAddressTable()) + +# 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 GL_APIENTRY +LocalProcAddressCallingConvention __ALL__ GL_APIENTRY + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +# Add PixelStorei StateTracker +# +# Add input validation to glPixelStorei, just to be sure. +CustomJavaCode GLES3Impl 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; } + +CustomCCode #include /* android */ +CustomCCode /* Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in +CustomCCode "glext.h" are parsed. */ +CustomCCode #define GL_GLEXT_PROTOTYPES + +CustomCCode /* Include the OpenGL headers */ +CustomCCode /* #define GL_APICALL __declspec(dllimport) */ +CustomCCode #include +CustomCCode #include +CustomCCode #include +CustomCCode #include + +IncludeAs CustomJavaCode GLES3Impl gl-impl-CustomJavaCode-common.java +IncludeAs CustomJavaCode GLES3Impl gl-impl-CustomJavaCode-gles3.java +IncludeAs CustomJavaCode GLES3Impl gl-impl-CustomJavaCode-embedded.java +IncludeAs CustomJavaCode GLES3Impl gl-impl-CustomJavaCode-gl2_es2.java +IncludeAs CustomCCode gl-impl-CustomCCode-gles3.c + +Import javax.media.opengl.GLBase +Import javax.media.opengl.GL +Import javax.media.opengl.GL2ES2 +Import javax.media.opengl.GL2ES3 +Import javax.media.opengl.GL3ES3 +Import javax.media.opengl.GL4ES3 +Import javax.media.opengl.GLES3 +Import javax.media.opengl.GLArrayData +Import javax.media.opengl.GLUniformData +Import com.jogamp.common.nio.Buffers +Import com.jogamp.opengl.util.GLBuffers +Import java.io.PrintStream + diff --git a/make/config/jogl/gl-gl4bc.cfg b/make/config/jogl/gl-gl4bc.cfg index ce6883106..d1bd85641 100644 --- a/make/config/jogl/gl-gl4bc.cfg +++ b/make/config/jogl/gl-gl4bc.cfg @@ -5,6 +5,9 @@ NativeOutputDir gensrc/native/jogl/gl4 ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES1.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL4ES3.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2GL3.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3.java @@ -22,6 +25,9 @@ JavaClass GL4bc #Extends GL4bc GL #Extends GL4bc GL2ES1 #Extends GL4bc GL2ES2 +#Extends GL4bc GL2ES3 +#Extends GL4bc GL3ES3 +#Extends GL4bc GL4ES3 #Extends GL4bc GL2GL3 #Extends GL4bc GL2 #Extends GL4bc GL3 @@ -33,6 +39,9 @@ Implements GL4bcImpl GLBase Implements GL4bcImpl GL Implements GL4bcImpl GL2ES1 Implements GL4bcImpl GL2ES2 +Implements GL4bcImpl GL2ES3 +Implements GL4bcImpl GL3ES3 +Implements GL4bcImpl GL4ES3 Implements GL4bcImpl GL2GL3 Implements GL4bcImpl GL2 Implements GL4bcImpl GL3 @@ -43,7 +52,8 @@ Include gl-common.cfg Include gl-common-extensions.cfg Include gl-desktop.cfg Include gl3-desktop.cfg -Include gl2_es2-common.cfg +Include gl3-common.cfg +Include gl2_es2-CustomJavaCode.cfg # Manually implement glMapNamedBufferEXT as the size of the returned buffer # can only be computed by calling another routine @@ -52,7 +62,7 @@ ForceProcAddressGen glMapNamedBufferEXT JavaEpilogue glNamedBufferDataEXT bufferSizeTracker.setDirectStateBufferSize({0}, this, {1}); # Manuall implement glDebugMessageCallback* using the proc address resolver -ForceProcAddressGen glDebugMessageCallbackARB +ForceProcAddressGen glDebugMessageCallback ForceProcAddressGen glDebugMessageCallbackAMD # Force all of the methods to be emitted using dynamic linking so we @@ -81,18 +91,22 @@ JavaPrologue glPixelStorei glStateTracker.setInt(pname, param); JavaPrologue glGetIntegerv if ( glStateTracker.getInt(pname, params, params_offset) ) { return; } -CustomJavaCode GL4bcImpl public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) { -CustomJavaCode GL4bcImpl glFrustum((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } +JavaPrologue glFrustumf if ( !_context.hasFP32CompatAPI() ) { +JavaPrologue glFrustumf glFrustum((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); +JavaPrologue glFrustumf return; +JavaPrologue glFrustumf } -CustomJavaCode GL4bcImpl public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) { -CustomJavaCode GL4bcImpl glOrtho((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); } +JavaPrologue glOrthof if ( !_context.hasFP32CompatAPI() ) { +JavaPrologue glOrthof glOrtho((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); +JavaPrologue glOrthof return; +JavaPrologue glOrthof } -JavaPrologue glDepthRangef if ( !_context.isGLES2Compatible() ) { +JavaPrologue glDepthRangef if ( !_context.isGLES2Compatible() && !_context.hasFP32CompatAPI() ) { JavaPrologue glDepthRangef glDepthRange( (double)zNear, (double)zFar ); JavaPrologue glDepthRangef return; JavaPrologue glDepthRangef } -JavaPrologue glClearDepthf if ( !_context.isGLES2Compatible() ) { +JavaPrologue glClearDepthf if ( !_context.isGLES2Compatible() && !_context.hasFP32CompatAPI() ) { JavaPrologue glClearDepthf glClearDepth( (double)depth ); JavaPrologue glClearDepthf return; JavaPrologue glClearDepthf } @@ -102,12 +116,16 @@ Include gl3ext-headers.cfg IncludeAs CustomJavaCode GL4bcImpl gl-impl-CustomJavaCode-common.java IncludeAs CustomJavaCode GL4bcImpl gl-impl-CustomJavaCode-gl4bc.java -IncludeAs CustomJavaCode GL4bcImpl gl-impl-CustomJavaCode-desktop.java IncludeAs CustomJavaCode GL4bcImpl gl-impl-CustomJavaCode-gl2_es2.java IncludeAs CustomCCode gl-impl-CustomCCode-gl4bc.c Import javax.media.opengl.GLES1 Import javax.media.opengl.GLES2 +Import javax.media.opengl.GL2ES1 +Import javax.media.opengl.GL2ES2 +Import javax.media.opengl.GL2ES3 +Import javax.media.opengl.GL3ES3 +Import javax.media.opengl.GL4ES3 Import javax.media.opengl.GL2GL3 Import javax.media.opengl.GL2 Import javax.media.opengl.GL3 diff --git a/make/config/jogl/gl-headers.cfg b/make/config/jogl/gl-headers.cfg index b80630c63..62f5e8dd4 100644 --- a/make/config/jogl/gl-headers.cfg +++ b/make/config/jogl/gl-headers.cfg @@ -1,7 +1,6 @@ CustomCCode #include CustomCCode #include /* android */ -CustomCCode /* Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in -CustomCCode "glext.h" are parsed. */ +CustomCCode /** Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. */ CustomCCode #define GL_GLEXT_PROTOTYPES CustomCCode #if defined(_WIN32) CustomCCode #define WIN32_LEAN_AND_MEAN diff --git a/make/config/jogl/gl-if-CustomJavaCode-es3.java b/make/config/jogl/gl-if-CustomJavaCode-es3.java new file mode 100644 index 000000000..0a1c43085 --- /dev/null +++ b/make/config/jogl/gl-if-CustomJavaCode-es3.java @@ -0,0 +1,14 @@ + +/** Part of GL_ARB_uniform_buffer_object */ +public static final int GL_INVALID_INDEX = 0xFFFFFFFF ; + +/** Part of GL_ARB_sync */ +public static final long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFL ; + +/** Part of GL_ARB_shader_image_load_store */ +public static final int GL_ALL_BARRIER_BITS = 0xFFFFFFFF ; + +public boolean glIsPBOPackEnabled(); + +public boolean glIsPBOUnpackEnabled(); + diff --git a/make/config/jogl/gl-if-CustomJavaCode-gl.java b/make/config/jogl/gl-if-CustomJavaCode-gl.java index 9ea4f98b4..f9f33eec9 100644 --- a/make/config/jogl/gl-if-CustomJavaCode-gl.java +++ b/make/config/jogl/gl-if-CustomJavaCode-gl.java @@ -57,3 +57,11 @@ earmarked for ES 3.0 (hence kept in GL while fixing Bug 590) */ public static final int GL_HALF_FLOAT = 0x140B; + /** Part of GL_VERSION_1_4, GL_ES_VERSION_2_0, GL_OES_required_internalformat. */ + public static final int GL_DEPTH_COMPONENT16 = 0x81A5; + /** Part of GL_VERSION_1_0, GL_OES_element_index_uint, GL_ES_VERSION_2_0 */ + public static final int GL_UNSIGNED_INT = 0x1405; + /** Part of GL_VERSION_1_0, GL_ES_VERSION_2_0 */ + public static final int GL_UNSIGNED_SHORT = 0x1403; + + diff --git a/make/config/jogl/gl-if-CustomJavaCode-gl2_es2.java b/make/config/jogl/gl-if-CustomJavaCode-gl2_es2.java index 4522d34c8..5ad235de5 100644 --- a/make/config/jogl/gl-if-CustomJavaCode-gl2_es2.java +++ b/make/config/jogl/gl-if-CustomJavaCode-gl2_es2.java @@ -39,10 +39,21 @@ *
    Calls void {@native glDepthRange}(GLclampd zNear, GLclampd zFar); if no native implementation is available. */ public void glDepthRangef(float zNear, float zFar); + public void glDepthRange(double zNear, double zFar); + /** Entry point to C language function: * void {@native glClearDepthf}(GLclampf depth); *
    Part of GL_ES_VERSION_2_0 and GL_ARB_ES2_compatibility. *
    Calls void {@native glClearDepth}(GLclampd depth); if no native implementation is available. */ public void glClearDepthf(float depth); + public void glClearDepth( double depth ); + + public void glVertexAttribPointer(GLArrayData array); + + public void glUniform(GLUniformData data); + + /** Part of GL_VERSION_1_0, GL_ES_VERSION_2_0, GL_ANGLE_depth_texture */ + public static final int GL_DEPTH_COMPONENT = 0x1902; + /** End: GL_ARB_ES2_compatibility functions, which are part of ES2 core as well */ diff --git a/make/config/jogl/gl-if-CustomJavaCode-gl2_gl3.java b/make/config/jogl/gl-if-CustomJavaCode-gl2_gl3.java deleted file mode 100644 index 97fd6c4a6..000000000 --- a/make/config/jogl/gl-if-CustomJavaCode-gl2_gl3.java +++ /dev/null @@ -1,10 +0,0 @@ - -/** Part of GL_ARB_uniform_buffer_object */ -public static final int GL_INVALID_INDEX = 0xFFFFFFFF ; - -/** Part of GL_ARB_sync */ -public static final long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFL ; - -/** Part of GL_ARB_shader_image_load_store */ -public static final int GL_ALL_BARRIER_BITS = 0xFFFFFFFF ; - diff --git a/make/config/jogl/gl-if-CustomJavaCode-gl_compat.java b/make/config/jogl/gl-if-CustomJavaCode-gl_compat.java new file mode 100644 index 000000000..22ae54cbe --- /dev/null +++ b/make/config/jogl/gl-if-CustomJavaCode-gl_compat.java @@ -0,0 +1,20 @@ + +/** + * Part of GL_NV_vertex_array_range. + *

    + * Provides platform-independent access to the wglAllocateMemoryNV / + * glXAllocateMemoryNV. + *

    + */ +public java.nio.ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority); + +/** + * Part of GL_NV_vertex_array_range. + *

    + * Provides platform-independent access to the wglFreeMemoryNV / + * glXFreeMemoryNV. + *

    + */ +public void glFreeMemoryNV(java.nio.ByteBuffer pointer); + + diff --git a/make/config/jogl/gl-if-CustomJavaCode-gles2.java b/make/config/jogl/gl-if-CustomJavaCode-gles2.java deleted file mode 100644 index ea40f6329..000000000 --- a/make/config/jogl/gl-if-CustomJavaCode-gles2.java +++ /dev/null @@ -1,3 +0,0 @@ - - public static final int GL_NVIDIA_PLATFORM_BINARY_NV = 0x890B; - diff --git a/make/config/jogl/gl-if-es2.cfg b/make/config/jogl/gl-if-es2.cfg new file mode 100644 index 000000000..aabd2d5a7 --- /dev/null +++ b/make/config/jogl/gl-if-es2.cfg @@ -0,0 +1,30 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl/es2 + +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GLES2 +#Extends GLES2 GLBase +#Extends GLES2 GL +Extends GLES2 GL2ES2 +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl2_es2-common.cfg +Include gl2_es2-CustomJavaCode.cfg + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +# dummy procaddress config / force procaddress for comments +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff +ForceProcAddressGen __ALL__ + +CustomJavaCode GLES2 public static final int GL_NVIDIA_PLATFORM_BINARY_NV = 0x890B; + diff --git a/make/config/jogl/gl-if-gl-ignores.cfg b/make/config/jogl/gl-if-gl-ignores.cfg index 25fbd5a6f..e6513cadb 100644 --- a/make/config/jogl/gl-if-gl-ignores.cfg +++ b/make/config/jogl/gl-if-gl-ignores.cfg @@ -13,6 +13,7 @@ DropUniqVendorExtensions IMG DropUniqVendorExtensions QCOM DropUniqVendorExtensions NV DropUniqVendorExtensions VIV +DropUniqVendorExtensions FJ IgnoreExtension GL_EXT_discard_framebuffer IgnoreExtension GL_OES_compressed_paletted_texture @@ -34,11 +35,14 @@ IgnoreExtension GL_EXT_multisampled_render_to_texture IgnoreExtension GL_EXT_framebuffer_multisample IgnoreExtension GL_OES_texture_half_float IgnoreExtension GL_OES_vertex_half_float -# IgnoreExtension GL_EXT_texture_storage IgnoreExtension GL_NV_draw_buffers IgnoreExtension GL_NV_fbo_color_attachments IgnoreExtension GL_OES_vertex_array_object IgnoreExtension GL_OES_texture_3D +IgnoreExtension GL_OES_surfaceless_context +IgnoreExtension GL_OES_required_internalformat +IgnoreExtension GL_EXT_unpack_subimage +IgnoreExtension GL_KHR_debug # includes GL_STATE_RESTORE, which hasn't the QCOM suffix IgnoreExtension GL_QCOM_extended_get @@ -46,12 +50,8 @@ Ignore GL_STATE_RESTORE # above ext mightbe subsumed, ignore the aliased ones Ignore GL_ACTIVE_PROGRAM -Ignore GL_ALPHA16F -Ignore GL_ALPHA32F -Ignore GL_ALPHA8 Ignore GL_ANY_SAMPLES_PASSED Ignore GL_ANY_SAMPLES_PASSED_CONSERVATIVE -Ignore GL_BGRA8 Ignore GL_BGRA8_EXT Ignore GL_BUFFER_OBJECT_EXT Ignore GL_COLOR_ATTACHMENT1 @@ -93,12 +93,6 @@ Ignore GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING Ignore GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT Ignore GL_INT_10_10_10_2 -Ignore GL_LUMINANCE16F -Ignore GL_LUMINANCE32F -Ignore GL_LUMINANCE8 -Ignore GL_LUMINANCE8_ALPHA8 -Ignore GL_LUMINANCE_ALPHA16F -Ignore GL_LUMINANCE_ALPHA32F Ignore GL_MAX_COLOR_ATTACHMENTS Ignore GL_MAX_DRAW_BUFFERS Ignore GL_PROGRAM_OBJECT_EXT @@ -108,15 +102,15 @@ Ignore GL_PROGRAM_SEPARABLE Ignore GL_QUERY_OBJECT_EXT Ignore GL_QUERY_RESULT Ignore GL_QUERY_RESULT_AVAILABLE +Ignore GL_R32F Ignore GL_R16F Ignore GL_R8 Ignore GL_RED Ignore GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES Ignore GL_RG +Ignore GL_RG32F Ignore GL_RG16F Ignore GL_RG8 -Ignore GL_RGB16F -Ignore GL_RGBA16F Ignore GL_SAMPLER_2D_SHADOW Ignore GL_SAMPLER_EXTERNAL_OES Ignore GL_SHADER_BINARY_DMP @@ -530,13 +524,9 @@ Ignore glFogxvOES Ignore glFramebufferVertexAttribArrayNV Ignore glFrustumf Ignore glFrustumfOES -#Ignore glGenerateMipmap -#Ignore glGenerateMipmapOES Ignore glGetActiveAttrib Ignore glGetActiveUniform Ignore glGetAttachedShaders -Ignore glGetClipPlanef -Ignore glGetClipPlanefOES Ignore glGetFixedv Ignore glGetFixedvOES Ignore glGetLightfv diff --git a/make/config/jogl/gl-if-gl.cfg b/make/config/jogl/gl-if-gl.cfg index 89233330a..4137cae8e 100644 --- a/make/config/jogl/gl-if-gl.cfg +++ b/make/config/jogl/gl-if-gl.cfg @@ -10,8 +10,8 @@ HierarchicalNativeOutput false Include gl-common.cfg Include gl-common-extensions.cfg Include gl-if-gl-ignores.cfg -Include gl-if-gl3-ignores.cfg -Include gl-if-gl4-ignores.cfg +Include gl-if-gl2_es2-ignores.cfg +Include gl-if-luminance-ignore.cfg JavaOutputDir gensrc/classes NativeOutputDir gensrc/native/jogl @@ -27,14 +27,6 @@ ProcAddressTableClassName DontGenerateProcAddressTableStuff GetProcAddressTableExpr DontGenerateProcAddressTableStuff ForceProcAddressGen __ALL__ -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined. -# This also gives a better API doc since it includes all extension names. -GLHeader GLES2/gl2.h -GLHeader GLES2/gl2ext.h -GLHeader GL/gl.h -GLHeader GL/glext.h - # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true diff --git a/make/config/jogl/gl-if-gl2.cfg b/make/config/jogl/gl-if-gl2.cfg index c58b73dfd..60efd73af 100644 --- a/make/config/jogl/gl-if-gl2.cfg +++ b/make/config/jogl/gl-if-gl2.cfg @@ -25,6 +25,8 @@ Include gl-desktop.cfg Include gl-if-gl3-ignores.cfg Include gl-if-gl4-ignores.cfg +IncludeAs CustomJavaCode GL2 gl-if-CustomJavaCode-gl_compat.java + # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true @@ -37,8 +39,5 @@ ForceProcAddressGen __ALL__ # Ignore extensions that are already picked up via the GL2ES1 interface IgnoreExtension GL_EXT_point_parameters -CustomJavaCode GL2 public boolean glIsPBOPackEnabled(); -CustomJavaCode GL2 public boolean glIsPBOUnpackEnabled(); - Include gl-headers.cfg diff --git a/make/config/jogl/gl-if-gl2_es1.cfg b/make/config/jogl/gl-if-gl2_es1.cfg index ad8bbea7d..04d78f51e 100644 --- a/make/config/jogl/gl-if-gl2_es1.cfg +++ b/make/config/jogl/gl-if-gl2_es1.cfg @@ -17,6 +17,7 @@ ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/fixedfunc/ HierarchicalNativeOutput false Include gl-common.cfg Include gl-common-extensions.cfg +Include gl-if-luminance-ignore.cfg JavaOutputDir gensrc/classes NativeOutputDir gensrc/native/jogl @@ -39,11 +40,11 @@ IgnoreExtension GL_OES_EGL_image_external IgnoreExtension GL_OES_compressed_ETC1_RGB8_texture IgnoreExtension GL_OES_draw_texture -IgnoreExtension GL_OES_fixed_point IgnoreExtension GL_OES_matrix_get IgnoreExtension GL_OES_point_size_array IgnoreExtension GL_OES_query_matrix IgnoreExtension GL_OES_vertex_half_float +IgnoreExtension GL_OES_matrix_palette IgnoreExtension GL_EXT_debug_marker IgnoreExtension GL_EXT_debug_label @@ -55,11 +56,6 @@ IgnoreExtension GL_QCOM_extended_get Ignore GL_STATE_RESTORE Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET -Ignore glGetFixedv - -# Ignore OES variants of single precision floating point routines -IgnoreExtension GL_OES_single_precision - # Ignore fixed point versions of routines in ES 1.x core Ignore glAlphaFuncx Ignore glClearColorx @@ -68,18 +64,28 @@ Ignore glClipPlanex Ignore glColor4x Ignore glDepthRangex Ignore glFogx +Ignore glFogxv Ignore glFrustumx Ignore glGetClipPlanex +Ignore glGetFixedv +Ignore glGetLightxv +Ignore glGetMaterialxv +Ignore glGetTexEnvxv +Ignore glGetTexParameterxv Ignore glLightModelx +Ignore glLightModelxv Ignore glLightx +Ignore glLightxv Ignore glLineWidthx Ignore glLoadMatrixx Ignore glMaterialx +Ignore glMaterialxv Ignore glMultMatrixx Ignore glMultiTexCoord4x Ignore glNormal3x Ignore glOrthox Ignore glPointParameterx +Ignore glPointParameterxv Ignore glPointSizex Ignore glPolygonOffsetx Ignore glQueryMatrixx @@ -87,21 +93,19 @@ Ignore glRotatex Ignore glSampleCoveragex Ignore glScalex Ignore glTexEnvx +Ignore glTexEnvxv Ignore glTexGenx Ignore glTexParameterx +Ignore glTexParameterxv Ignore glTranslatex #heavy float/double array diff to GL2 Ignore glClipPlanef Ignore ^glGetClipPlanef(OES)? - + #impl diff Ignore ^glEGL.* -Ignore ^gl.*(xv)(OES)? -Ignore glTexGenxOES Ignore GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES -Ignore glLoadPaletteFromModelViewMatrixOES -Ignore glGetFixedv CustomJavaCode GL2ES1 public void glOrtho(double left, double right, double bottom, double top, double near_val, double far_val); CustomJavaCode GL2ES1 public void glFrustum(double left, double right, double bottom, double top, double zNear, double zFar); @@ -112,13 +116,6 @@ ProcAddressTableClassName DontGenerateProcAddressTableStuff GetProcAddressTableExpr DontGenerateProcAddressTableStuff ForceProcAddressGen __ALL__ -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -GLHeader GLES/gl.h -GLHeader GLES/glext.h -GLHeader GL/gl.h -GLHeader GL/glext.h - # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true diff --git a/make/config/jogl/gl-if-gl2_es2-ignores.cfg b/make/config/jogl/gl-if-gl2_es2-ignores.cfg new file mode 100644 index 000000000..f08d8a51b --- /dev/null +++ b/make/config/jogl/gl-if-gl2_es2-ignores.cfg @@ -0,0 +1,48 @@ +# Ignore all ES 2.X only stuff .. +DropUniqVendorExtensions ANGLE +DropUniqVendorExtensions ARM +DropUniqVendorExtensions APPLE +DropUniqVendorExtensions ATI +DropUniqVendorExtensions IMG +DropUniqVendorExtensions QCOM +DropUniqVendorExtensions NV +DropUniqVendorExtensions VIV + +Ignore glEGL.* + +IgnoreExtension GL_AMD_compressed_3DC_texture +IgnoreExtension GL_AMD_compressed_ATC_texture +IgnoreExtension GL_AMD_program_binary_Z400 +IgnoreExtension GL_AMD_performance_monitor + +IgnoreExtension GL_KHR_texture_compression_astc_ldr +IgnoreExtension GL_ANGLE_depth_texture +IgnoreExtension GL_ANGLE_instanced_arrays +IgnoreExtension GL_ANGLE_pack_reverse_row_order +IgnoreExtension GL_ANGLE_program_binary +IgnoreExtension GL_ANGLE_texture_compression_dxt3 +IgnoreExtension GL_ANGLE_texture_compression_dxt5 +IgnoreExtension GL_ANGLE_texture_usage +IgnoreExtension GL_ANGLE_translated_shader_source +IgnoreExtension GL_EXT_debug_label +IgnoreExtension GL_EXT_debug_marker +IgnoreExtension GL_EXT_discard_framebuffer +IgnoreExtension GL_EXT_disjoint_timer_query +IgnoreExtension GL_EXT_draw_buffers +IgnoreExtension GL_EXT_multiview_draw_buffers +IgnoreExtension GL_EXT_multisampled_render_to_texture +IgnoreExtension GL_EXT_shader_framebuffer_fetch +IgnoreExtension GL_FJ_shader_binary_GCCSO +IgnoreExtension GL_OES_compressed_paletted_texture +IgnoreExtension GL_OES_compressed_ETC1_RGB8_texture +IgnoreExtension GL_OES_vertex_array_object +IgnoreExtension GL_OES_vertex_half_float +IgnoreExtension GL_OES_surfaceless_context +IgnoreExtension GL_OES_texture_half_float +IgnoreExtension GL_OES_EGL_image_external + +# includes GL_STATE_RESTORE, which hasn't the QCOM suffix +IgnoreExtension GL_QCOM_extended_get +Ignore GL_STATE_RESTORE + +Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET diff --git a/make/config/jogl/gl-if-gl2_es2.cfg b/make/config/jogl/gl-if-gl2_es2.cfg index 85e799298..0ad140eb2 100644 --- a/make/config/jogl/gl-if-gl2_es2.cfg +++ b/make/config/jogl/gl-if-gl2_es2.cfg @@ -14,45 +14,9 @@ Extends GL2ES2 GL HierarchicalNativeOutput false Include gl-common.cfg Include gl-common-extensions.cfg -Include gl-if-gl3-ignores.cfg -Include gl-if-gl4-ignores.cfg - -RenameExtensionIntoCore GL_OES_texture_3D -RenameExtensionIntoCore GL_OES_get_program_binary - -# Ignore all ES 2.X only stuff .. -DropUniqVendorExtensions AMD -DropUniqVendorExtensions ANGLE -DropUniqVendorExtensions ARM -DropUniqVendorExtensions APPLE -DropUniqVendorExtensions ATI -DropUniqVendorExtensions IMG -DropUniqVendorExtensions QCOM -DropUniqVendorExtensions NV -DropUniqVendorExtensions VIV - -IgnoreExtension GL_EXT_discard_framebuffer -IgnoreExtension GL_OES_compressed_paletted_texture -IgnoreExtension GL_OES_compressed_ETC1_RGB8_texture -IgnoreExtension GL_OES_vertex_array_object -IgnoreExtension GL_OES_texture_half_float -IgnoreExtension GL_OES_vertex_half_float -IgnoreExtension GL_OES_EGL_image_external -IgnoreExtension GL_EXT_debug_marker -IgnoreExtension GL_EXT_debug_label -IgnoreExtension GL_EXT_multisampled_render_to_texture - -# isn't included in GL2 -# includes GL_STATE_RESTORE, which hasn't the QCOM suffix -IgnoreExtension GL_QCOM_extended_get -Ignore GL_STATE_RESTORE -Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET - -# Ignore ^gl.*x(v)?(OES)? -Ignore glEGL.* -#Ignore glFramebufferVertexAttribArrayNV -#Ignore glCoverageOperationNV -#Ignore glCoverageMaskNV +Include gl2_es2-common.cfg +Include gl-if-gl2_es2-ignores.cfg +Include gl-if-luminance-ignore.cfg # Ignore GL_ARB_ES2_compatibility functions for interface code generation # since we need our own javadoc header for a detailed description @@ -62,9 +26,6 @@ Ignore glGetShaderPrecisionFormat Ignore glDepthRangef Ignore glClearDepthf -CustomJavaCode GL2ES2 public void glClearDepth( double depth ); -CustomJavaCode GL2ES2 public void glDepthRange(double zNear, double zFar); - IncludeAs CustomJavaCode GL2ES2 gl-if-CustomJavaCode-gl2_es2.java # dummy procaddress config / force procaddress for comments @@ -73,20 +34,8 @@ ProcAddressTableClassName DontGenerateProcAddressTableStuff GetProcAddressTableExpr DontGenerateProcAddressTableStuff ForceProcAddressGen __ALL__ -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -# This also gives a better API doc since it includes all extension names. -GLHeader GLES2/gl2.h -GLHeader GLES2/gl2ext.h -GLHeader GL/gl.h -GLHeader GL/glext.h - # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true -CustomJavaCode GL2ES2 public void glVertexAttribPointer(GLArrayData array); -CustomJavaCode GL2ES2 public void glUniform(GLUniformData data); -CustomJavaCode GL2ES2 - Import java.io.PrintStream diff --git a/make/config/jogl/gl-if-gl2_es3-ignores.cfg b/make/config/jogl/gl-if-gl2_es3-ignores.cfg new file mode 100644 index 000000000..172857840 --- /dev/null +++ b/make/config/jogl/gl-if-gl2_es3-ignores.cfg @@ -0,0 +1,47 @@ +# Ignore all ES 3.X only stuff .. +DropUniqVendorExtensions ANGLE +DropUniqVendorExtensions ARM +DropUniqVendorExtensions APPLE +DropUniqVendorExtensions ATI +DropUniqVendorExtensions IMG +DropUniqVendorExtensions QCOM +DropUniqVendorExtensions NV +DropUniqVendorExtensions VIV + +Ignore glEGL.* + +IgnoreExtension GL_AMD_compressed_3DC_texture +IgnoreExtension GL_AMD_compressed_ATC_texture +IgnoreExtension GL_AMD_program_binary_Z400 +IgnoreExtension GL_AMD_performance_monitor + +IgnoreExtension GL_ANGLE_depth_texture +IgnoreExtension GL_ANGLE_instanced_arrays +IgnoreExtension GL_ANGLE_pack_reverse_row_order +IgnoreExtension GL_ANGLE_program_binary +IgnoreExtension GL_ANGLE_texture_compression_dxt3 +IgnoreExtension GL_ANGLE_texture_compression_dxt5 +IgnoreExtension GL_ANGLE_texture_usage +IgnoreExtension GL_ANGLE_translated_shader_source +IgnoreExtension GL_EXT_debug_label +IgnoreExtension GL_EXT_debug_marker +IgnoreExtension GL_EXT_discard_framebuffer +IgnoreExtension GL_EXT_disjoint_timer_query +IgnoreExtension GL_EXT_draw_buffers +IgnoreExtension GL_EXT_multisampled_render_to_texture +IgnoreExtension GL_EXT_multiview_draw_buffers +IgnoreExtension GL_EXT_shader_framebuffer_fetch +IgnoreExtension GL_OES_compressed_paletted_texture +IgnoreExtension GL_OES_compressed_ETC1_RGB8_texture +IgnoreExtension GL_OES_vertex_array_object +IgnoreExtension GL_OES_vertex_half_float +IgnoreExtension GL_OES_surfaceless_context +IgnoreExtension GL_OES_texture_half_float +IgnoreExtension GL_OES_EGL_image_external +IgnoreExtension GL_FJ_shader_binary_GCCSO + +# includes GL_STATE_RESTORE, which hasn't the QCOM suffix +IgnoreExtension GL_QCOM_extended_get +Ignore GL_STATE_RESTORE + +Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET diff --git a/make/config/jogl/gl-if-gl2_es3.cfg b/make/config/jogl/gl-if-gl2_es3.cfg new file mode 100644 index 000000000..f44c9b393 --- /dev/null +++ b/make/config/jogl/gl-if-gl2_es3.cfg @@ -0,0 +1,45 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GL2ES3 +#Extends GL2ES3 GLBase +#Extends GL2ES3 GL +Extends GL2ES3 GL2ES2 + +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java + +ExtendedInterfaceSymbolsOnly ../build-temp/gluegen-set/javax/media/opengl/GL2ES3Subset.java + +HierarchicalNativeOutput false +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl2_es3-common.cfg +Include gl-if-gl2_es3-ignores.cfg +Include gl-if-gl4-ignores.cfg +Include gl-if-luminance-ignore.cfg + +IncludeAs CustomJavaCode GL2ES3 gl-if-CustomJavaCode-es3.java + +# +# Same name but different signature .. +# No collisions found .. good! + +# dummy procaddress config / force procaddress for comments +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff +ForceProcAddressGen __ALL__ + +# Also force the calling conventions of the locally generated function +# pointer typedefs for these routines to APIENTRY +LocalProcAddressCallingConvention __ALL__ APIENTRY + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +Import java.io.PrintStream diff --git a/make/config/jogl/gl-if-gl2_gl3.cfg b/make/config/jogl/gl-if-gl2_gl3.cfg index 0c51dfe9c..467919328 100644 --- a/make/config/jogl/gl-if-gl2_gl3.cfg +++ b/make/config/jogl/gl-if-gl2_gl3.cfg @@ -4,21 +4,23 @@ Style InterfaceOnly JavaClass GL2GL3 #Extends GL2GL3 GLBase #Extends GL2GL3 GL -Extends GL2GL3 GL2ES2 +#Extends GL2GL3 GL2ES2 +Extends GL2GL3 GL2ES3 ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES3.java ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java -ExtendedInterfaceSymbolsOnly ../build-temp/gluegen-set/javax/media/opengl/GL3Subset.java +ExtendedInterfaceSymbolsOnly ../build-temp/gluegen-set/javax/media/opengl/GL2GL3Subset.java HierarchicalNativeOutput false Include gl-common.cfg Include gl-common-extensions.cfg Include gl-desktop.cfg +Include gl3-common.cfg Include gl-if-gl4-ignores.cfg - -IncludeAs CustomJavaCode GL2GL3 gl-if-CustomJavaCode-gl2_gl3.java +Include gl-if-luminance-ignore.cfg JavaOutputDir gensrc/classes NativeOutputDir gensrc/native/jogl @@ -33,11 +35,6 @@ ProcAddressTableClassName DontGenerateProcAddressTableStuff GetProcAddressTableExpr DontGenerateProcAddressTableStuff ForceProcAddressGen __ALL__ -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -GLHeader GL/gl.h -GLHeader GL/glext.h - # Also force the calling conventions of the locally generated function # pointer typedefs for these routines to APIENTRY LocalProcAddressCallingConvention __ALL__ APIENTRY diff --git a/make/config/jogl/gl-if-gl2es3-subset.cfg b/make/config/jogl/gl-if-gl2es3-subset.cfg new file mode 100644 index 000000000..3e325e065 --- /dev/null +++ b/make/config/jogl/gl-if-gl2es3-subset.cfg @@ -0,0 +1,17 @@ +# This .cfg file is used to generate the common GL2 ES3 set +JavaOutputDir ../../build-temp/gluegen-set + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GL2ES3Subset +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl2_es3-common.cfg +Include gl-if-gl3-ignores.cfg +Include gl-if-gl4-ignores.cfg + +# dummy procaddress config / force procaddress for comments +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff +ForceProcAddressGen __ALL__ diff --git a/make/config/jogl/gl-if-gl2gl3-subset.cfg b/make/config/jogl/gl-if-gl2gl3-subset.cfg new file mode 100644 index 000000000..ecb384ca3 --- /dev/null +++ b/make/config/jogl/gl-if-gl2gl3-subset.cfg @@ -0,0 +1,18 @@ +# This .cfg file is used to generate the common GL2 GL3 set +JavaOutputDir ../../build-temp/gluegen-set + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GL2GL3Subset +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl3-desktop.cfg +Include gl3-common.cfg +Include gl-if-gl3-ignores.cfg +Include gl-if-gl4-ignores.cfg + +# dummy procaddress config / force procaddress for comments +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff +ForceProcAddressGen __ALL__ diff --git a/make/config/jogl/gl-if-gl3-subset.cfg b/make/config/jogl/gl-if-gl3-subset.cfg deleted file mode 100644 index dae38ec0c..000000000 --- a/make/config/jogl/gl-if-gl3-subset.cfg +++ /dev/null @@ -1,17 +0,0 @@ -# This .cfg file is used to generate the common GL2 GL3 set -JavaOutputDir ../../build-temp/gluegen-set - -Package javax.media.opengl -Style InterfaceOnly -JavaClass GL3Subset -Include gl-common.cfg -Include gl-common-extensions.cfg -Include gl3-desktop.cfg -Include gl-if-gl3-ignores.cfg -Include gl-if-gl4-ignores.cfg - -# dummy procaddress config / force procaddress for comments -EmitProcAddressTable false -ProcAddressTableClassName DontGenerateProcAddressTableStuff -GetProcAddressTableExpr DontGenerateProcAddressTableStuff -ForceProcAddressGen __ALL__ diff --git a/make/config/jogl/gl-if-gl3.cfg b/make/config/jogl/gl-if-gl3.cfg index 649b35165..09f51d6b0 100644 --- a/make/config/jogl/gl-if-gl3.cfg +++ b/make/config/jogl/gl-if-gl3.cfg @@ -4,6 +4,8 @@ NativeOutputDir gensrc/native/jogl/gl3 ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3ES3.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2GL3.java ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java @@ -13,16 +15,14 @@ JavaClass GL3 #Extends GL3 GLBase #Extends GL3 GL #Extends GL3 GL2ES2 +#Extends GL3 GL2ES3 +Extends GL3 GL3ES3 Extends GL3 GL2GL3 ImplPackage jogamp.opengl.gl3 -ImplJavaClass GL3Impl -Implements GL3Impl GLBase -Implements GL3Impl GL -Implements GL3Impl GL2ES2 -Implements GL3Impl GL2GL3 Include gl-common.cfg Include gl-common-extensions.cfg Include gl3-desktop.cfg +Include gl3-common.cfg Include gl-if-gl4-ignores.cfg # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums diff --git a/make/config/jogl/gl-if-gl3_es3.cfg b/make/config/jogl/gl-if-gl3_es3.cfg new file mode 100644 index 000000000..a25d9112a --- /dev/null +++ b/make/config/jogl/gl-if-gl3_es3.cfg @@ -0,0 +1,43 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GL3ES3 +#Extends GL3ES3 GLBase +#Extends GL3ES3 GL +#Extends GL3ES3 GL2ES2 +Extends GL3ES3 GL2ES3 + +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java + +HierarchicalNativeOutput false +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl2_es3-common.cfg +Include gl-if-gl2_es3-ignores.cfg +Include gl-if-gl4-ignores.cfg +Include gl-if-luminance-ignore.cfg + +# +# Same name but different signature .. +# No collisions found .. good! + +# dummy procaddress config / force procaddress for comments +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff +ForceProcAddressGen __ALL__ + +# Also force the calling conventions of the locally generated function +# pointer typedefs for these routines to APIENTRY +LocalProcAddressCallingConvention __ALL__ APIENTRY + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +Import java.io.PrintStream diff --git a/make/config/jogl/gl-if-gl3bc.cfg b/make/config/jogl/gl-if-gl3bc.cfg index f07a9a417..bca3d61e6 100644 --- a/make/config/jogl/gl-if-gl3bc.cfg +++ b/make/config/jogl/gl-if-gl3bc.cfg @@ -5,6 +5,8 @@ NativeOutputDir gensrc/native/jogl/gl3 ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES1.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3ES3.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2GL3.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3.java @@ -20,6 +22,8 @@ JavaClass GL3bc #Extends GL3bc GL #Extends GL3bc GL2ES1 #Extends GL3bc GL2ES2 +#Extends GL3bc GL2ES3 +#Extends GL3bc GL3ES3 #Extends GL3bc GL2GL3 Extends GL3bc GL2 Extends GL3bc GL3 @@ -30,6 +34,8 @@ Include gl-desktop.cfg Include gl3-desktop.cfg Include gl-if-gl4-ignores.cfg +IncludeAs CustomJavaCode GL2 gl-if-CustomJavaCode-gl_compat.java + # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true diff --git a/make/config/jogl/gl-if-gl4-ignores.cfg b/make/config/jogl/gl-if-gl4-ignores.cfg index 4948b64df..619c82924 100644 --- a/make/config/jogl/gl-if-gl4-ignores.cfg +++ b/make/config/jogl/gl-if-gl4-ignores.cfg @@ -9,5 +9,7 @@ IgnoreExtension GL_VERSION_4_0 IgnoreExtension GL_VERSION_4_1 IgnoreExtension GL_VERSION_4_2 +IgnoreExtension GL_VERSION_4_3 +IgnoreExtension GL_VERSION_4_4 IgnoreExtension GL_ARB_shader_precision diff --git a/make/config/jogl/gl-if-gl4.cfg b/make/config/jogl/gl-if-gl4.cfg index 1e920ac7c..4b19b448e 100644 --- a/make/config/jogl/gl-if-gl4.cfg +++ b/make/config/jogl/gl-if-gl4.cfg @@ -4,6 +4,9 @@ NativeOutputDir gensrc/native/jogl/gl4 ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL4ES3.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2GL3.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3.java ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java @@ -14,11 +17,15 @@ JavaClass GL4 #Extends GL4 GLBase #Extends GL4 GL #Extends GL4 GL2ES2 +#Extends GL4 GL2ES3 +#Extends GL4 GL3ES3 #Extends GL4 GL2GL3 +Extends GL4 GL4ES3 Extends GL4 GL3 Include gl-common.cfg Include gl-common-extensions.cfg Include gl3-desktop.cfg +Include gl3-common.cfg # dummy procaddress config / force procaddress for comments EmitProcAddressTable false diff --git a/make/config/jogl/gl-if-gl4_es3.cfg b/make/config/jogl/gl-if-gl4_es3.cfg new file mode 100644 index 000000000..cd9c17f27 --- /dev/null +++ b/make/config/jogl/gl-if-gl4_es3.cfg @@ -0,0 +1,47 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GL4ES3 +#Extends GL4ES3 GLBase +#Extends GL4ES3 GL +#Extends GL4ES3 GL2ES2 +#Extends GL4ES3 GL2ES3 +Extends GL4ES3 GL3ES3 + +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java + +HierarchicalNativeOutput false +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl2_es3-common.cfg +Include gl-if-gl2_es3-ignores.cfg +Include gl-if-luminance-ignore.cfg + +ForceExtension GL_ARB_ES3_compatibility + +# +# Same name but different signature .. +# No collisions found .. good! + +# dummy procaddress config / force procaddress for comments +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff +ForceProcAddressGen __ALL__ + +# Also force the calling conventions of the locally generated function +# pointer typedefs for these routines to APIENTRY +LocalProcAddressCallingConvention __ALL__ APIENTRY + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +Import java.io.PrintStream diff --git a/make/config/jogl/gl-if-luminance-ignore.cfg b/make/config/jogl/gl-if-luminance-ignore.cfg new file mode 100644 index 000000000..4fb79fae9 --- /dev/null +++ b/make/config/jogl/gl-if-luminance-ignore.cfg @@ -0,0 +1,7 @@ +Ignore GL_LUMINANCE16F +Ignore GL_LUMINANCE32F +Ignore GL_LUMINANCE_ALPHA16F +Ignore GL_LUMINANCE_ALPHA32F +Ignore GL_LUMINANCE4_ALPHA4 +Ignore GL_LUMINANCE8 +Ignore GL_LUMINANCE8_ALPHA8 diff --git a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c index d389db298..4ddc27bf2 100644 --- a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c +++ b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c @@ -13,6 +13,22 @@ Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unu return (jlong) (intptr_t) _res; } +/* Java->C glue code: + * Java package: jogamp.opengl.gl4.GL4bcImpl + * Java method: java.nio.ByteBuffer dispatch_glMapBufferRange(int target, long offset, long length, int access) + * C function: void * glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + */ +JNIEXPORT jlong JNICALL +Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glMapBufferRange(JNIEnv *env, jobject _unused, jint target, jlong offset, jlong length, jint access, jlong procAddress) { + typedef void * (APIENTRY*_local_PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + _local_PFNGLMAPBUFFERRANGEPROC ptr_glMapBufferRange; + void * _res; + ptr_glMapBufferRange = (_local_PFNGLMAPBUFFERRANGEPROC) (intptr_t) procAddress; + assert(ptr_glMapBufferRange != NULL); + _res = (* ptr_glMapBufferRange) ((GLenum) target, (GLintptr) offset, (GLsizeiptr) length, (GLbitfield) access); + return (jlong) (intptr_t) _res; +} + /* Java->C glue code: * Java package: jogamp.opengl.gl4.GL4bcImpl * Java method: long dispatch_glMapNamedBufferEXT(int target, int access) diff --git a/make/config/jogl/gl-impl-CustomCCode-gles1.c b/make/config/jogl/gl-impl-CustomCCode-gles1.c index 0155c13f8..88cfe4418 100644 --- a/make/config/jogl/gl-impl-CustomCCode-gles1.c +++ b/make/config/jogl/gl-impl-CustomCCode-gles1.c @@ -14,6 +14,22 @@ Java_jogamp_opengl_es1_GLES1Impl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unu return (jlong) (intptr_t) _res; } +/* Java->C glue code: + * Java package: jogamp.opengl.es1.GLES1Impl + * Java method: java.nio.ByteBuffer dispatch_glMapBufferRange(int target, long offset, long length, int access) + * C function: void * glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + */ +JNIEXPORT jlong JNICALL +Java_jogamp_opengl_es1_GLES1Impl_dispatch_1glMapBufferRange(JNIEnv *env, jobject _unused, jint target, jlong offset, jlong length, jint access, jlong procAddress) { + typedef void * (GL_APIENTRY*_local_PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + _local_PFNGLMAPBUFFERRANGEPROC ptr_glMapBufferRange; + void * _res; + ptr_glMapBufferRange = (_local_PFNGLMAPBUFFERRANGEPROC) (intptr_t) procAddress; + assert(ptr_glMapBufferRange != NULL); + _res = (* ptr_glMapBufferRange) ((GLenum) target, (GLintptr) offset, (GLsizeiptr) length, (GLbitfield) access); + return (jlong) (intptr_t) _res; +} + /* Java->C glue code: * Java package: jogamp.opengl.es1.GLES1Impl * Java method: ByteBuffer newDirectByteBuffer(long addr, long capacity); diff --git a/make/config/jogl/gl-impl-CustomCCode-gles2.c b/make/config/jogl/gl-impl-CustomCCode-gles2.c deleted file mode 100644 index e140df76b..000000000 --- a/make/config/jogl/gl-impl-CustomCCode-gles2.c +++ /dev/null @@ -1,25 +0,0 @@ -typedef GLvoid* (GL_APIENTRY* PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -/* Java->C glue code: - * Java package: jogamp.opengl.es2.GLES2Impl - * Java method: long dispatch_glMapBuffer(int target, int access) - * C function: void * glMapBuffer(GLenum target, GLenum access); - */ -JNIEXPORT jlong JNICALL -Java_jogamp_opengl_es2_GLES2Impl_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: jogamp.opengl.es2.GLES2Impl - * Java method: ByteBuffer newDirectByteBuffer(long addr, long capacity); - * C function: jobject newDirectByteBuffer(jlong addr, jlong capacity); - */ -JNIEXPORT jobject JNICALL -Java_jogamp_opengl_es2_GLES2Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jlong capacity) { - return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); -} diff --git a/make/config/jogl/gl-impl-CustomCCode-gles3.c b/make/config/jogl/gl-impl-CustomCCode-gles3.c new file mode 100644 index 000000000..2f3329bfa --- /dev/null +++ b/make/config/jogl/gl-impl-CustomCCode-gles3.c @@ -0,0 +1,41 @@ +typedef GLvoid* (GL_APIENTRY* PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +/* Java->C glue code: + * Java package: jogamp.opengl.es3.GLES3Impl + * Java method: long dispatch_glMapBuffer(int target, int access) + * C function: void * glMapBuffer(GLenum target, GLenum access); + */ +JNIEXPORT jlong JNICALL +Java_jogamp_opengl_es3_GLES3Impl_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: jogamp.opengl.es3.GLES3Impl + * Java method: java.nio.ByteBuffer dispatch_glMapBufferRange(int target, long offset, long length, int access) + * C function: void * glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + */ +JNIEXPORT jlong JNICALL +Java_jogamp_opengl_es3_GLES3Impl_dispatch_1glMapBufferRange(JNIEnv *env, jobject _unused, jint target, jlong offset, jlong length, jint access, jlong procAddress) { + typedef void * (GL_APIENTRY*_local_PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + _local_PFNGLMAPBUFFERRANGEPROC ptr_glMapBufferRange; + void * _res; + ptr_glMapBufferRange = (_local_PFNGLMAPBUFFERRANGEPROC) (intptr_t) procAddress; + assert(ptr_glMapBufferRange != NULL); + _res = (* ptr_glMapBufferRange) ((GLenum) target, (GLintptr) offset, (GLsizeiptr) length, (GLbitfield) access); + return (jlong) (intptr_t) _res; +} + +/* Java->C glue code: + * Java package: jogamp.opengl.es3.GLES3Impl + * Java method: ByteBuffer newDirectByteBuffer(long addr, long capacity); + * C function: jobject newDirectByteBuffer(jlong addr, jlong capacity); + */ +JNIEXPORT jobject JNICALL +Java_jogamp_opengl_es3_GLES3Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jlong capacity) { + return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); +} diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java index 8e8165fff..4024d8e1a 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-common.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java @@ -118,3 +118,95 @@ return _context.getDefaultReadBuffer(); } + private final HashMap arbMemCache = new HashMap(); + + /** Entry point to C language function: void * {@native glMapBuffer}(GLenum target, GLenum access);
    Part of GL_VERSION_1_5; GL_OES_mapbuffer */ + private final java.nio.ByteBuffer glMapBufferImpl(int target, boolean useRange, long offset, long length, int access, long glProcAddress) { + if (glProcAddress == 0) { + throw new GLException("Method \""+(useRange?"glMapBufferRange":"glMapBuffer")+"\" not available"); + } + final long sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); + if (0 == sz) { + return null; + } + if( !useRange ) { + length = sz; + offset = 0; + } else { + if( length + offset > sz ) { + throw new GLException("Out of range: offset "+offset+" + length "+length+" > size "+sz); + } + if( 0 > length || 0 > offset ) { + throw new GLException("Invalid values: offset "+offset+", length "+length); + } + if( 0 == length ) { + return null; + } + } + final long addr = useRange ? dispatch_glMapBufferRange(target, offset, length, access, glProcAddress) : + dispatch_glMapBuffer(target, access, glProcAddress); + if (0 == addr) { + return null; + } + ByteBuffer buffer; + MemoryObject memObj0 = new MemoryObject(addr, length); // object and key + MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); + if(memObj0 == memObj1) { + // just added .. + if(null != memObj0.getBuffer()) { + throw new InternalError(); + } + buffer = newDirectByteBuffer(addr, length); + Buffers.nativeOrder(buffer); + memObj0.setBuffer(buffer); + } else { + // already mapped + buffer = memObj1.getBuffer(); + if(null == buffer) { + throw new InternalError(); + } + } + buffer.position(0); + return buffer; + } + private native long dispatch_glMapBuffer(int target, int access, long glProcAddress); + private native long dispatch_glMapBufferRange(int target, long offset, long length, int access, long procAddress); + + + /** Entry point to C language function: GLvoid * {@native glMapNamedBufferEXT}(GLuint buffer, GLenum access);
    Part of GL_EXT_direct_state_access */ + private final java.nio.ByteBuffer glMapNamedBufferImpl(int bufferName, int access, long glProcAddress) { + if (glProcAddress == 0) { + throw new GLException("Method \"glMapNamedBufferEXT\" not available"); + } + final long sz = bufferSizeTracker.getDirectStateBufferSize(bufferName, this); + if (0 == sz) { + return null; + } + final long addr = dispatch_glMapNamedBufferEXT(bufferName, access, glProcAddress); + if (0 == addr) { + return null; + } + ByteBuffer buffer; + MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key + MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); + if(memObj0 == memObj1) { + // just added .. + if(null != memObj0.getBuffer()) { + throw new InternalError(); + } + buffer = newDirectByteBuffer(addr, sz); + Buffers.nativeOrder(buffer); + memObj0.setBuffer(buffer); + } else { + // already mapped + buffer = memObj1.getBuffer(); + if(null == buffer) { + throw new InternalError(); + } + } + buffer.position(0); + return buffer; + } + private native long dispatch_glMapNamedBufferEXT(int buffer, int access, long procAddress); + + private native ByteBuffer newDirectByteBuffer(long addr, long capacity); diff --git a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java deleted file mode 100644 index 6a74b80a6..000000000 --- a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java +++ /dev/null @@ -1,148 +0,0 @@ - private int[] imageSizeTemp = new int[1]; - - private final int imageSizeInBytes(int format, int type, int width, int height, int depth, boolean pack) { - return GLBuffers.sizeof(this, imageSizeTemp, format, type, width, height, depth, pack) ; - } - - @Override - public final boolean isGL4bc() { - return _context.isGL4bc(); - } - - @Override - public final boolean isGL4() { - return _context.isGL4(); - } - - @Override - public final boolean isGL3bc() { - return _context.isGL3bc(); - } - - @Override - public final boolean isGL3() { - return _context.isGL3(); - } - - @Override - public final boolean isGL2() { - return _context.isGL2(); - } - - @Override - public final boolean isGL2ES1() { - return _context.isGL2ES1(); - } - - @Override - public final boolean isGL2ES2() { - return _context.isGL2ES2(); - } - - @Override - public final boolean isGLES2Compatible() { - return _context.isGLES2Compatible(); - } - - public final boolean isGL2GL3() { - return _context.isGL2GL3(); - } - - @Override - public final boolean hasGLSL() { - return _context.hasGLSL(); - } - - @Override - public final GL4bc getGL4bc() throws GLException { - if(!isGL4bc()) { - throw new GLException("Not a GL4bc implementation"); - } - return this; - } - - @Override - public final GL4 getGL4() throws GLException { - if(!isGL4()) { - throw new GLException("Not a GL4 implementation"); - } - return this; - } - - @Override - public final GL3bc getGL3bc() throws GLException { - if(!isGL3bc()) { - throw new GLException("Not a GL3bc implementation"); - } - return this; - } - - @Override - public final GL3 getGL3() throws GLException { - if(!isGL3()) { - throw new GLException("Not a GL3 implementation"); - } - return this; - } - - @Override - public final GL2 getGL2() throws GLException { - if(!isGL2()) { - throw new GLException("Not a GL2 implementation"); - } - return this; - } - - @Override - public final GL2ES1 getGL2ES1() throws GLException { - if(!isGL2ES1()) { - throw new GLException("Not a GL2ES1 implementation"); - } - return this; - } - - @Override - public final GL2ES2 getGL2ES2() throws GLException { - if(!isGL2ES2()) { - throw new GLException("Not a GL2ES2 implementation"); - } - return this; - } - - @Override - public final GL2GL3 getGL2GL3() throws GLException { - if(!isGL2GL3()) { - throw new GLException("Not a GL2GL3 implementation"); - } - return this; - } - - @Override - public final boolean isGLES1() { - return false; - } - - @Override - public final boolean isGLES2() { - return false; - } - - @Override - public final boolean isGLES() { - return false; - } - - @Override - public final GLES1 getGLES1() throws GLException { - throw new GLException("Not a GLES1 implementation"); - } - - @Override - public final GLES2 getGLES2() throws GLException { - throw new GLException("Not a GLES2 implementation"); - } - - @Override - public final boolean isNPOTTextureAvailable() { - return _context.isNPOTTextureAvailable(); - } diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index fbe7484c4..cacea322a 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -29,12 +29,223 @@ public GL4bcImpl(GLProfile glp, GLContextImpl context) { this.glProfile = glp; } -/** - * Provides platform-independent access to the wglAllocateMemoryNV / - * glXAllocateMemoryNV extension. - */ -public final java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { - return _context.glAllocateMemoryNV(arg0, arg1, arg2, arg3); +public final void finalizeInit() { + if(null != _context) { + 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"); + haveARBVertexArrayObject = _context.getGLVersionNumber().compareTo(GLContext.Version300) >= 0 || + isExtensionAvailable("GL_ARB_vertex_array_object"); + } else { + haveARBPixelBufferObject = false; + haveEXTPixelBufferObject = false; + haveGL15 = false; + haveGL21 = false; + haveARBVertexBufferObject = false; + haveARBVertexArrayObject = false; + } +} + +private int[] imageSizeTemp = new int[1]; + +private final int imageSizeInBytes(int format, int type, int width, int height, int depth, boolean pack) { + return GLBuffers.sizeof(this, imageSizeTemp, format, type, width, height, depth, pack) ; +} + +@Override +public final boolean isGL4bc() { + return _context.isGL4bc(); +} + +@Override +public final boolean isGL4() { + return _context.isGL4(); +} + +@Override +public final boolean isGL3bc() { + return _context.isGL3bc(); +} + +@Override +public final boolean isGL3() { + return _context.isGL3(); +} + +@Override +public final boolean isGL2() { + return _context.isGL2(); +} + +@Override +public final boolean isGL2ES1() { + return _context.isGL2ES1(); +} + +@Override +public final boolean isGL2ES2() { + return _context.isGL2ES2(); +} + +@Override +public final boolean isGL3ES3() { + return _context.isGL3ES3(); +} + +@Override +public final boolean isGL4ES3() { + return _context.isGL4ES3(); +} + +@Override +public final boolean isGLES2Compatible() { + return _context.isGLES2Compatible(); +} + +@Override +public final boolean isGLES3Compatible() { + return _context.isGLES3Compatible(); +} + +@Override +public final boolean isGL2GL3() { + return _context.isGL2GL3(); +} + +@Override +public final boolean hasGLSL() { + return _context.hasGLSL(); +} + +@Override +public final GL4bc getGL4bc() throws GLException { + if(!isGL4bc()) { + throw new GLException("Not a GL4bc implementation"); + } + return this; +} + +@Override +public final GL4 getGL4() throws GLException { + if(!isGL4()) { + throw new GLException("Not a GL4 implementation"); + } + return this; +} + +@Override +public final GL3bc getGL3bc() throws GLException { + if(!isGL3bc()) { + throw new GLException("Not a GL3bc implementation"); + } + return this; +} + +@Override +public final GL3 getGL3() throws GLException { + if(!isGL3()) { + throw new GLException("Not a GL3 implementation"); + } + return this; +} + +@Override +public final GL2 getGL2() throws GLException { + if(!isGL2()) { + throw new GLException("Not a GL2 implementation"); + } + return this; +} + +@Override +public final GL2ES1 getGL2ES1() throws GLException { + if(!isGL2ES1()) { + throw new GLException("Not a GL2ES1 implementation"); + } + return this; +} + +@Override +public final GL2ES2 getGL2ES2() throws GLException { + if(!isGL2ES2()) { + throw new GLException("Not a GL2ES2 implementation"); + } + return this; +} + +@Override +public final GL3ES3 getGL3ES3() throws GLException { + if(!isGL3ES3()) { + throw new GLException("Not a GL3ES3 implementation"); + } + return this; +} + +@Override +public final GL4ES3 getGL4ES3() throws GLException { + if(!isGL4ES3()) { + throw new GLException("Not a GL4ES3 implementation"); + } + return this; +} + +@Override +public final GL2GL3 getGL2GL3() throws GLException { + if(!isGL2GL3()) { + throw new GLException("Not a GL2GL3 implementation"); + } + return this; +} + +@Override +public final boolean isGLES1() { + return false; +} + +@Override +public final boolean isGLES2() { + return false; +} + +@Override +public final boolean isGLES3() { + return false; +} + +@Override +public final boolean isGLES() { + return false; +} + +@Override +public final GLES1 getGLES1() throws GLException { + throw new GLException("Not a GLES1 implementation"); +} + +@Override +public final GLES2 getGLES2() throws GLException { + throw new GLException("Not a GLES2 implementation"); +} + +@Override +public final GLES3 getGLES3() throws GLException { + throw new GLException("Not a GLES3 implementation"); +} + +@Override +public final boolean isNPOTTextureAvailable() { + return _context.isNPOTTextureAvailable(); +} +@Override +public final java.nio.ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { + return _context.glAllocateMemoryNV(size, readFrequency, writeFrequency, priority); +} + +@Override +public final void glFreeMemoryNV(java.nio.ByteBuffer pointer) { + _context.glFreeMemoryNV(pointer); } // @@ -45,7 +256,6 @@ private final GLBufferSizeTracker bufferSizeTracker; private final GLBufferStateTracker bufferStateTracker; private final GLStateTracker glStateTracker; -private boolean bufferObjectExtensionsInitialized = false; private boolean haveARBPixelBufferObject; private boolean haveEXTPixelBufferObject; private boolean haveGL15; @@ -53,20 +263,6 @@ private boolean haveGL21; private boolean haveARBVertexBufferObject; private boolean haveARBVertexArrayObject; -private final 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"); - haveARBVertexArrayObject = _context.getGLVersionNumber().compareTo(GLContext.Version300) >= 0 || - isExtensionAvailable("GL_ARB_vertex_array_object"); -} - private final boolean checkBufferObject(boolean extensionAvail, boolean allowVAO, boolean enabled, @@ -111,7 +307,6 @@ private final boolean checkBufferObject(boolean extensionAvail, } private final boolean checkArrayVBODisabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL15 || haveARBVertexBufferObject, haveARBVertexArrayObject, // allowVAO false, // enable @@ -120,7 +315,6 @@ private final boolean checkArrayVBODisabled(boolean throwException) { } private final boolean checkArrayVBOEnabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL15 || haveARBVertexBufferObject, haveARBVertexArrayObject, // allowVAO true, // enable @@ -129,7 +323,6 @@ private final boolean checkArrayVBOEnabled(boolean throwException) { } private final boolean checkElementVBODisabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL15 || haveARBVertexBufferObject, haveARBVertexArrayObject, // allowVAO false, // enable @@ -138,7 +331,6 @@ private final boolean checkElementVBODisabled(boolean throwException) { } private final boolean checkElementVBOEnabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL15 || haveARBVertexBufferObject, haveARBVertexArrayObject, // allowVAO true, // enable @@ -147,7 +339,6 @@ private final boolean checkElementVBOEnabled(boolean throwException) { } private final boolean checkUnpackPBODisabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL21 || haveARBPixelBufferObject || haveEXTPixelBufferObject, false, // allowVAO false, // enable @@ -156,7 +347,6 @@ private final boolean checkUnpackPBODisabled(boolean throwException) { } private final boolean checkUnpackPBOEnabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL21 || haveARBPixelBufferObject || haveEXTPixelBufferObject, false, // allowVAO true, // enable @@ -165,7 +355,6 @@ private final boolean checkUnpackPBOEnabled(boolean throwException) { } private final boolean checkPackPBODisabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL21 || haveARBPixelBufferObject || haveEXTPixelBufferObject, false, // allowVAO false, // enable @@ -174,7 +363,6 @@ private final boolean checkPackPBODisabled(boolean throwException) { } private final boolean checkPackPBOEnabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL21 || haveARBPixelBufferObject || haveEXTPixelBufferObject, false, // allowVAO true, // enable @@ -192,87 +380,21 @@ public final boolean glIsPBOUnpackEnabled() { return checkUnpackPBOEnabled(false); } -private final HashMap arbMemCache = new HashMap(); - -/** Entry point to C language function:
    LPVOID glMapBuffer(GLenum target, GLenum access); */ +/** Entry point to C language function: void * {@native glMapBuffer}(GLenum target, GLenum access);
    Part of GL_VERSION_1_5; GL_OES_mapbuffer */ public final 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"); - } - final long sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); - if (0 == sz) { - return null; - } - final long addr = dispatch_glMapBuffer(target, access, __addr_); - if (0 == addr) { - return null; - } - ByteBuffer buffer; - MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key - MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); - if(memObj0 == memObj1) { - // just added .. - if(null != memObj0.getBuffer()) { - throw new InternalError(); - } - buffer = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(buffer); - memObj0.setBuffer(buffer); - } else { - // already mapped - buffer = memObj1.getBuffer(); - if(null == buffer) { - throw new InternalError(); - } - } - buffer.position(0); - return buffer; + return glMapBufferImpl(target, false, 0, 0, access, ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer); } -/** Encapsulates function pointer for OpenGL function
    : LPVOID glMapBuffer(GLenum target, GLenum access); */ -native private long dispatch_glMapBuffer(int target, int access, long glProcAddress); +/** Entry point to C language function: void * {@native glMapBufferRange}(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
    Part of GL_ES_VERSION_3_0, GL_VERSION_3_0; GL_EXT_map_buffer_range */ +public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access) { + return glMapBufferImpl(target, true, offset, length, access, ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange); +} /** Entry point to C language function: GLvoid * {@native glMapNamedBufferEXT}(GLuint buffer, GLenum access);
    Part of GL_EXT_direct_state_access */ public final java.nio.ByteBuffer glMapNamedBufferEXT(int bufferName, int access) { - final long __addr_ = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapNamedBufferEXT; - if (__addr_ == 0) { - throw new GLException("Method \"glMapNamedBufferEXT\" not available"); - } - final long sz = bufferSizeTracker.getDirectStateBufferSize(bufferName, this); - if (0 == sz) { - return null; - } - final long addr = dispatch_glMapNamedBufferEXT(bufferName, access, __addr_); - if (0 == addr) { - return null; - } - ByteBuffer buffer; - MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key - MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); - if(memObj0 == memObj1) { - // just added .. - if(null != memObj0.getBuffer()) { - throw new InternalError(); - } - buffer = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(buffer); - memObj0.setBuffer(buffer); - } else { - // already mapped - buffer = memObj1.getBuffer(); - if(null == buffer) { - throw new InternalError(); - } - } - buffer.position(0); - return buffer; + return glMapNamedBufferImpl(bufferName, access, ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapNamedBufferEXT); } -private native long dispatch_glMapNamedBufferEXT(int buffer, int access, long procAddress); - -native private ByteBuffer newDirectByteBuffer(long addr, long capacity); - @Override public final void glVertexPointer(GLArrayData array) { if(array.getComponentCount()==0) return; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java index 70425689a..2fa83dca6 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java @@ -47,6 +47,11 @@ public final boolean isGLES2() { return false; } +@Override +public final boolean isGLES3() { + return false; +} + @Override public final boolean isGLES() { return true; @@ -62,11 +67,26 @@ public final boolean isGL2ES2() { return false; } +@Override +public final boolean isGL3ES3() { + return false; +} + +@Override +public final boolean isGL4ES3() { + return false; +} + @Override public final boolean isGLES2Compatible() { return false; } +@Override +public final boolean isGLES3Compatible() { + return false; +} + @Override public final boolean isGL2GL3() { return false; @@ -117,6 +137,11 @@ public final GLES2 getGLES2() throws GLException { throw new GLException("Not a GLES2 implementation"); } +@Override +public final GLES3 getGLES3() throws GLException { + throw new GLException("Not a GLES3 implementation"); +} + @Override public final GL2ES1 getGL2ES1() throws GLException { return this; @@ -127,6 +152,16 @@ public final GL2ES2 getGL2ES2() throws GLException { throw new GLException("Not a GL2ES2 implementation"); } +@Override +public final GL3ES3 getGL3ES3() throws GLException { + throw new GLException("Not a GL3ES3 implementation"); +} + +@Override +public final GL4ES3 getGL4ES3() throws GLException { + throw new GLException("Not a GL4ES3 implementation"); +} + @Override public final GL2GL3 getGL2GL3() throws GLException { throw new GLException("Not a GL2GL3 implementation"); @@ -206,48 +241,15 @@ private final boolean checkPackPBOEnabled(boolean throwException) { return false; } -private final HashMap arbMemCache = new HashMap(); - -/** Entry point to C language function:
    LPVOID glMapBuffer(GLenum target, GLenum access); */ +/** Entry point to C language function: void * {@native glMapBuffer}(GLenum target, GLenum access);
    Part of GL_VERSION_1_5; GL_OES_mapbuffer */ public final java.nio.ByteBuffer glMapBuffer(int target, int access) { - final long __addr_ = ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer; - if (__addr_ == 0) { - throw new GLException("Method \"glMapBuffer\" not available"); - } - final long sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); - if (0 == sz) { - return null; - } - final long addr = dispatch_glMapBuffer(target, access, __addr_); - if (0 == addr) { - return null; - } - ByteBuffer buffer; - MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key - MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); - if(memObj0 == memObj1) { - // just added .. - if(null != memObj0.getBuffer()) { - throw new InternalError(); - } - buffer = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(buffer); - memObj0.setBuffer(buffer); - } else { - // already mapped - buffer = memObj1.getBuffer(); - if(null == buffer) { - throw new InternalError(); - } - } - buffer.position(0); - return buffer; + return glMapBufferImpl(target, false, 0, 0, access, ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer); } -/** 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, long capacity); +/** Entry point to C language function: void * {@native glMapBufferRange}(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
    Part of GL_ES_VERSION_3_0, GL_VERSION_3_0; GL_EXT_map_buffer_range */ +public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access) { + return glMapBufferImpl(target, true, offset, length, access, ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange); +} @Override public final void glVertexPointer(GLArrayData array) { diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java deleted file mode 100644 index 37f3f33aa..000000000 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java +++ /dev/null @@ -1,262 +0,0 @@ - -public GLES2Impl(GLProfile glp, GLContextImpl context) { - this._context = context; - if(null != context) { - this.bufferSizeTracker = context.getBufferSizeTracker(); - this.bufferStateTracker = context.getBufferStateTracker(); - this.glStateTracker = context.getGLStateTracker(); - } else { - this.bufferSizeTracker = null; - this.bufferStateTracker = null; - this.glStateTracker = null; - } - this.glProfile = glp; -} - -@Override -public final boolean isGL4bc() { - return false; -} - -@Override -public final boolean isGL4() { - return false; -} - -@Override -public final boolean isGL3bc() { - return false; -} - -@Override -public final boolean isGL3() { - return false; -} - -public final boolean isGL2() { - return false; -} - -@Override -public final boolean isGLES1() { - return false; -} - -@Override -public final boolean isGLES2() { - return true; -} - -@Override -public final boolean isGLES() { - return true; -} - -@Override -public final boolean isGL2ES1() { - return false; -} - -@Override -public final boolean isGL2ES2() { - return true; -} - -@Override -public final boolean isGLES2Compatible() { - return true; -} - -@Override -public final boolean isGL2GL3() { - return false; -} - -@Override -public final boolean hasGLSL() { - return true; -} - -@Override -public boolean isNPOTTextureAvailable() { - return true; -} - -@Override -public final GL4bc getGL4bc() throws GLException { - throw new GLException("Not a GL4bc implementation"); -} - -@Override -public final GL4 getGL4() throws GLException { - throw new GLException("Not a GL4 implementation"); -} - -@Override -public final GL3bc getGL3bc() throws GLException { - throw new GLException("Not a GL3bc implementation"); -} - -@Override -public final GL3 getGL3() throws GLException { - throw new GLException("Not a GL3 implementation"); -} - -@Override -public final GL2 getGL2() throws GLException { - throw new GLException("Not a GL2 implementation"); -} - -@Override -public final GLES1 getGLES1() throws GLException { - throw new GLException("Not a GLES1 implementation"); -} - -@Override -public final GLES2 getGLES2() throws GLException { - return this; -} - -@Override -public final GL2ES1 getGL2ES1() throws GLException { - throw new GLException("Not a GL2ES1 implementation"); -} - -@Override -public final GL2ES2 getGL2ES2() throws GLException { - return this; -} - -@Override -public final GL2GL3 getGL2GL3() throws GLException { - throw new GLException("Not a GL2GL3 implementation"); -} - -// -// Helpers for ensuring the correct amount of texture data -// - -private final GLBufferSizeTracker bufferSizeTracker; -private final GLBufferStateTracker bufferStateTracker; -private final GLStateTracker glStateTracker; - -private final boolean checkBufferObject(boolean enabled, - int state, - String kind, boolean throwException) { - final int buffer = bufferStateTracker.getBoundBufferObject(state, this); - if (enabled) { - if (0 == buffer) { - if(throwException) { - throw new GLException(kind + " must be enabled to call this method"); - } - return false; - } - } else { - if (0 != buffer) { - if(throwException) { - throw new GLException(kind + " must be disabled to call this method"); - } - return false; - } - } - return true; -} - -private final boolean checkArrayVBODisabled(boolean throwException) { - return checkBufferObject(false, // enabled - GL.GL_ARRAY_BUFFER, - "array vertex_buffer_object", throwException); -} - -private final boolean checkArrayVBOEnabled(boolean throwException) { - return checkBufferObject(true, // enabled - GL.GL_ARRAY_BUFFER, - "array vertex_buffer_object", throwException); -} - -private final boolean checkElementVBODisabled(boolean throwException) { - return checkBufferObject(false, // enabled - GL.GL_ELEMENT_ARRAY_BUFFER, - "element vertex_buffer_object", throwException); -} - -private final boolean checkElementVBOEnabled(boolean throwException) { - return checkBufferObject(true, // enabled - GL.GL_ELEMENT_ARRAY_BUFFER, - "element vertex_buffer_object", throwException); -} - -private final boolean checkUnpackPBODisabled(boolean throwException) { - // PBO n/a for ES 1.1 or ES 2.0 - return true; -} - -private final boolean checkUnpackPBOEnabled(boolean throwException) { - // PBO n/a for ES 1.1 or ES 2.0 - return false; -} - -private final boolean checkPackPBODisabled(boolean throwException) { - // PBO n/a for ES 1.1 or ES 2.0 - return true; -} - -private final boolean checkPackPBOEnabled(boolean throwException) { - // PBO n/a for ES 1.1 or ES 2.0 - return false; -} - -private final HashMap arbMemCache = new HashMap(); - -/** Entry point to C language function:
    LPVOID glMapBuffer(GLenum target, GLenum access); */ -@Override -public final java.nio.ByteBuffer glMapBuffer(int target, int access) { - final long __addr_ = ((GLES2ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer; - if (__addr_ == 0) { - throw new GLException("Method \"glMapBuffer\" not available"); - } - final long sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); - if (0 == sz) { - return null; - } - final long addr = dispatch_glMapBuffer(target, access, __addr_); - if (0 == addr) { - return null; - } - ByteBuffer buffer; - MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key - MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); - if(memObj0 == memObj1) { - // just added .. - if(null != memObj0.getBuffer()) { - throw new InternalError(); - } - buffer = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(buffer); - memObj0.setBuffer(buffer); - } else { - // already mapped - buffer = memObj1.getBuffer(); - if(null == buffer) { - throw new InternalError(); - } - } - buffer.position(0); - return buffer; -} - -/** 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, long capacity); - -@Override -public final void glClearDepth(double depth) { - glClearDepthf((float)depth); -} - -@Override -public final void glDepthRange(double zNear, double zFar) { - glDepthRangef((float)zNear, (float)zFar); -} - diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java new file mode 100644 index 000000000..e0b0c6a09 --- /dev/null +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java @@ -0,0 +1,320 @@ + +public GLES3Impl(GLProfile glp, GLContextImpl context) { + this._context = context; + if(null != context) { + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); + } else { + this.bufferSizeTracker = null; + this.bufferStateTracker = null; + this.glStateTracker = null; + } + this.glProfile = glp; + this._isES3 = glp.getImplName() == GLProfile.GLES3; +} + +@Override +public final boolean isGL4bc() { + return false; +} + +@Override +public final boolean isGL4() { + return false; +} + +@Override +public final boolean isGL3bc() { + return false; +} + +@Override +public final boolean isGL3() { + return false; +} + +public final boolean isGL2() { + return false; +} + +@Override +public final boolean isGLES1() { + return false; +} + +@Override +public final boolean isGLES2() { + return true; +} + +@Override +public final boolean isGLES3() { + return _isES3; +} + +@Override +public final boolean isGLES() { + return true; +} + +@Override +public final boolean isGL2ES1() { + return false; +} + +@Override +public final boolean isGL2ES2() { + return true; +} + +@Override +public final boolean isGL3ES3() { + return _isES3; +} + +@Override +public final boolean isGL4ES3() { + return _isES3; +} + +@Override +public final boolean isGLES2Compatible() { + return true; +} + +@Override +public final boolean isGLES3Compatible() { + return _isES3; +} + + +@Override +public final boolean isGL2GL3() { + return false; +} + +@Override +public final boolean hasGLSL() { + return true; +} + +@Override +public boolean isNPOTTextureAvailable() { + return true; +} + +@Override +public final GL4bc getGL4bc() throws GLException { + throw new GLException("Not a GL4bc implementation"); +} + +@Override +public final GL4 getGL4() throws GLException { + throw new GLException("Not a GL4 implementation"); +} + +@Override +public final GL3bc getGL3bc() throws GLException { + throw new GLException("Not a GL3bc implementation"); +} + +@Override +public final GL3 getGL3() throws GLException { + throw new GLException("Not a GL3 implementation"); +} + +@Override +public final GL2 getGL2() throws GLException { + throw new GLException("Not a GL2 implementation"); +} + +@Override +public final GLES1 getGLES1() throws GLException { + throw new GLException("Not a GLES1 implementation"); +} + +@Override +public final GLES2 getGLES2() throws GLException { + return this; +} + +@Override +public final GLES3 getGLES3() throws GLException { + return this; +} + +@Override +public final GL2ES1 getGL2ES1() throws GLException { + throw new GLException("Not a GL2ES1 implementation"); +} + +@Override +public final GL2ES2 getGL2ES2() throws GLException { + return this; +} + +@Override +public final GL3ES3 getGL3ES3() throws GLException { + if(!_isES3) { + throw new GLException("Not a GL3ES3 implementation"); + } + return this; +} + +@Override +public final GL4ES3 getGL4ES3() throws GLException { + if(!_isES3) { + throw new GLException("Not a GL4ES3 implementation"); + } + return this; +} + +@Override +public final GL2GL3 getGL2GL3() throws GLException { + throw new GLException("Not a GL2GL3 implementation"); +} + +// +// Helpers for ensuring the correct amount of texture data +// + +private final boolean _isES3; +private final GLBufferSizeTracker bufferSizeTracker; +private final GLBufferStateTracker bufferStateTracker; +private final GLStateTracker glStateTracker; + +private final boolean checkBufferObject(boolean extensionAvail, + boolean allowVAO, + boolean enabled, + int state, + String kind, boolean throwException) { + if ( !extensionAvail ) { + 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 ( 0 != buffer ) { + return true; + } + if ( allowVAO ) { + buffer = bufferStateTracker.getBoundBufferObject(GLES3.GL_VERTEX_ARRAY_BINDING, this); + if( 0 != buffer && !_context.isDefaultVAO(buffer) ) { + return true; + } + } + if ( throwException ) { + throw new GLException(kind + " must be enabled to call this method"); + } + return false; + } else { + if ( 0 == buffer ) { + return true; + } + if ( throwException ) { + throw new GLException(kind + " must be disabled to call this method"); + } + return false; + } +} + +private final boolean checkArrayVBODisabled(boolean throwException) { + return checkBufferObject(true, + _isES3, // allowVAO + false, // enable + GL.GL_ARRAY_BUFFER, + "array vertex_buffer_object", throwException); +} + +private final boolean checkArrayVBOEnabled(boolean throwException) { + return checkBufferObject(true, + _isES3, // allowVAO + true, // enable + GL.GL_ARRAY_BUFFER, + "array vertex_buffer_object", throwException); +} + +private final boolean checkElementVBODisabled(boolean throwException) { + return checkBufferObject(true, + _isES3, // allowVAO + false, // enable + GL.GL_ELEMENT_ARRAY_BUFFER, + "element vertex_buffer_object", throwException); +} + +private final boolean checkElementVBOEnabled(boolean throwException) { + return checkBufferObject(true, + _isES3, // allowVAO + true, // enable + GL.GL_ELEMENT_ARRAY_BUFFER, + "element vertex_buffer_object", throwException); +} + +private final boolean checkUnpackPBODisabled(boolean throwException) { + return checkBufferObject(_isES3, + false, // allowVAO + false, // enable + GL2.GL_PIXEL_UNPACK_BUFFER, + "unpack pixel_buffer_object", throwException); +} + +private final boolean checkUnpackPBOEnabled(boolean throwException) { + return checkBufferObject(_isES3, + false, // allowVAO + true, // enable + GL2.GL_PIXEL_UNPACK_BUFFER, + "unpack pixel_buffer_object", throwException); +} + +private final boolean checkPackPBODisabled(boolean throwException) { + return checkBufferObject(_isES3, + false, // allowVAO + false, // enable + GL2.GL_PIXEL_PACK_BUFFER, + "pack pixel_buffer_object", throwException); +} + +private final boolean checkPackPBOEnabled(boolean throwException) { + return checkBufferObject(_isES3, + false, // allowVAO + true, // enable + GL2.GL_PIXEL_PACK_BUFFER, + "pack pixel_buffer_object", throwException); +} + +@Override +public final boolean glIsPBOPackEnabled() { + return checkPackPBOEnabled(false); +} + +@Override +public final boolean glIsPBOUnpackEnabled() { + return checkUnpackPBOEnabled(false); +} + +/** Entry point to C language function: void * {@native glMapBuffer}(GLenum target, GLenum access);
    Part of GL_VERSION_1_5; GL_OES_mapbuffer */ +public final java.nio.ByteBuffer glMapBuffer(int target, int access) { + return glMapBufferImpl(target, false, 0, 0, access, ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer); +} + +/** Entry point to C language function: void * {@native glMapBufferRange}(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
    Part of GL_ES_VERSION_3_0, GL_VERSION_3_0; GL_EXT_map_buffer_range */ +public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access) { + return glMapBufferImpl(target, true, offset, length, access, ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange); +} + +@Override +public final void glClearDepth(double depth) { + glClearDepthf((float)depth); +} + +@Override +public final void glDepthRange(double zNear, double zFar) { + glDepthRangef((float)zNear, (float)zFar); +} + diff --git a/make/config/jogl/gl2_es2-CustomJavaCode.cfg b/make/config/jogl/gl2_es2-CustomJavaCode.cfg new file mode 100644 index 000000000..b769f3b29 --- /dev/null +++ b/make/config/jogl/gl2_es2-CustomJavaCode.cfg @@ -0,0 +1,13 @@ + +JavaPrologue glReleaseShaderCompiler if ( !_context.isGLES2Compatible() ) { +JavaPrologue glReleaseShaderCompiler return; +JavaPrologue glReleaseShaderCompiler } + +JavaPrologue glShaderBinary if ( !_context.isGLES2Compatible() ) { +JavaPrologue glShaderBinary throw new GLException("Method \"glShaderBinary\" not available"); +JavaPrologue glShaderBinary } + +JavaPrologue glGetShaderPrecisionFormat if ( !_context.isGLES2Compatible() ) { +JavaPrologue glGetShaderPrecisionFormat throw new GLException("Method \"glGetShaderPrecisionFormat\" not available"); +JavaPrologue glGetShaderPrecisionFormat } + diff --git a/make/config/jogl/gl2_es2-common.cfg b/make/config/jogl/gl2_es2-common.cfg index b769f3b29..2ad7fd3fd 100644 --- a/make/config/jogl/gl2_es2-common.cfg +++ b/make/config/jogl/gl2_es2-common.cfg @@ -1,13 +1,11 @@ -JavaPrologue glReleaseShaderCompiler if ( !_context.isGLES2Compatible() ) { -JavaPrologue glReleaseShaderCompiler return; -JavaPrologue glReleaseShaderCompiler } +RenameExtensionIntoCore GL_KHR_debug +RenameExtensionIntoCore GL_OES_texture_3D +RenameExtensionIntoCore GL_OES_get_program_binary +RenameExtensionIntoCore GL_OES_required_internalformat +RenameExtensionIntoCore GL_EXT_unpack_subimage -JavaPrologue glShaderBinary if ( !_context.isGLES2Compatible() ) { -JavaPrologue glShaderBinary throw new GLException("Method \"glShaderBinary\" not available"); -JavaPrologue glShaderBinary } +ForceExtension GL_EXT_occlusion_query_boolean -JavaPrologue glGetShaderPrecisionFormat if ( !_context.isGLES2Compatible() ) { -JavaPrologue glGetShaderPrecisionFormat throw new GLException("Method \"glGetShaderPrecisionFormat\" not available"); -JavaPrologue glGetShaderPrecisionFormat } +ForceExtension GL_ARB_ES2_compatibility diff --git a/make/config/jogl/gl2_es3-common.cfg b/make/config/jogl/gl2_es3-common.cfg new file mode 100644 index 000000000..b5326b159 --- /dev/null +++ b/make/config/jogl/gl2_es3-common.cfg @@ -0,0 +1,9 @@ + +RenameExtensionIntoCore GL_KHR_debug +RenameExtensionIntoCore GL_OES_texture_3D +IgnoreExtension GL_OES_get_program_binary +RenameExtensionIntoCore GL_OES_required_internalformat +RenameExtensionIntoCore GL_EXT_unpack_subimage + +ForceExtension GL_EXT_occlusion_query_boolean + diff --git a/make/config/jogl/gl3-common.cfg b/make/config/jogl/gl3-common.cfg new file mode 100644 index 000000000..e11c50aa3 --- /dev/null +++ b/make/config/jogl/gl3-common.cfg @@ -0,0 +1,9 @@ + +ForceExtension GL_ARB_debug_output +RenameExtensionIntoCore GL_KHR_debug + +RenameExtensionIntoCore GL_OES_texture_3D +IgnoreExtension GL_OES_get_program_binary +RenameExtensionIntoCore GL_OES_required_internalformat +RenameExtensionIntoCore GL_EXT_unpack_subimage + diff --git a/make/config/jogl/gl3-desktop.cfg b/make/config/jogl/gl3-desktop.cfg index 96e59aa05..4a2c53371 100644 --- a/make/config/jogl/gl3-desktop.cfg +++ b/make/config/jogl/gl3-desktop.cfg @@ -1,11 +1,6 @@ # This .cfg file provides common options used by the desktop OpenGL # implementation on all platforms. -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -GLHeader GL3/gl3.h -GLHeader GL3/gl3ext.h - #Include gl-desktop-tracker.cfg # diff --git a/make/config/jogl/gl3-headers.cfg b/make/config/jogl/gl3-headers.cfg index 8b35a07b4..7ab5099c9 100644 --- a/make/config/jogl/gl3-headers.cfg +++ b/make/config/jogl/gl3-headers.cfg @@ -1,7 +1,6 @@ CustomCCode #include /* android */ -CustomCCode /* Define GL3_PROTOTYPES so that the OpenGL extension prototypes in -CustomCCode "gl3.h" are parsed. */ -CustomCCode #define GL3_PROTOTYPES +CustomCCode /** Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. */ +CustomCCode #define GL_GLEXT_PROTOTYPES CustomCCode #if defined(_WIN32) CustomCCode #define WIN32_LEAN_AND_MEAN CustomCCode #include @@ -9,11 +8,13 @@ CustomCCode #undef WIN32_LEAN_AND_MEAN CustomCCode #include CustomCCode #include CustomCCode #include -CustomCCode #include +CustomCCode #include +CustomCCode #include CustomCCode #elif defined(macosx) CustomCCode #include CustomCCode #include -CustomCCode #include +CustomCCode #include +CustomCCode #include CustomCCode #include CustomCCode /* Provide Windows typedefs */ CustomCCode typedef void* LPVOID; @@ -22,5 +23,6 @@ CustomCCode #elif defined(__unix__) CustomCCode #include CustomCCode #include CustomCCode #include -CustomCCode #include +CustomCCode #include +CustomCCode #include CustomCCode #endif diff --git a/make/config/jogl/gl3ext-headers.cfg b/make/config/jogl/gl3ext-headers.cfg index 5e2c7aa37..24b1ba518 100644 --- a/make/config/jogl/gl3ext-headers.cfg +++ b/make/config/jogl/gl3ext-headers.cfg @@ -1,6 +1,4 @@ CustomCCode #include /* android */ -CustomCCode /* Define GL_GL3EXT_PROTOTYPES so that the OpenGL extension prototypes in -CustomCCode "gl3ext.h" are parsed. */ -CustomCCode #define GL_GL3EXT_PROTOTYPES -CustomCCode #include -CustomCCode #include +CustomCCode /** Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. */ +CustomCCode #define GL_GLEXT_PROTOTYPES +CustomCCode #include diff --git a/make/config/jogl/glx-x11.cfg b/make/config/jogl/glx-x11.cfg index 017b1e00b..5955e0a38 100644 --- a/make/config/jogl/glx-x11.cfg +++ b/make/config/jogl/glx-x11.cfg @@ -20,7 +20,6 @@ NIODirectOnly __ALL__ ForceProcAddressGen __ALL__ LocalProcAddressCallingConvention __ALL__ APIENTRY -AllowNonGLExtensions true EmitProcAddressTable true ProcAddressTableClassName GLXProcAddressTable GetProcAddressTableExpr glxProcAddressTable diff --git a/make/scripts/cmpOld2New.sh b/make/scripts/cmpOld2New.sh index 7d68cfc84..4a121a632 100755 --- a/make/scripts/cmpOld2New.sh +++ b/make/scripts/cmpOld2New.sh @@ -9,7 +9,7 @@ dircmp=cmp-old2new rm -rf $dircmp mkdir -p $dircmp -for i in GL GL2ES1 GL2ES2 GLES1 GLES2 GL2GL3 GL2 GL3 GL3bc GL4 GL4bc ; do +for i in GL GL2ES1 GLES1 GL2ES2 GLES2 GL2ES3 GL2GL3 GL2 GL3ES3 GL3 GL3bc GL4ES3 GLES3 GL4 GL4bc ; do echo echo processing $i awk -f $dirscript/strip-c-comments.awk $dirold/$i.java | sort -u > $dircmp/$i-old.java diff --git a/make/scripts/cmpOld2NewDups.sh b/make/scripts/cmpOld2NewDups.sh new file mode 100644 index 000000000..4d3e1e35a --- /dev/null +++ b/make/scripts/cmpOld2NewDups.sh @@ -0,0 +1,121 @@ +#! /bin/bash + +dircmp=cmp-old2new + +GLFILES="$dircmp/GL2ES1-new.java \ + $dircmp/GLES1-new.java \ + $dircmp/GL2ES2-new.java \ + $dircmp/GLES2-new.java \ + $dircmp/GL3ES3-new.java \ + $dircmp/GL2GL3-new.java \ + $dircmp/GL2-new.java \ + $dircmp/GL3-new.java \ + $dircmp/GL3bc-new.java \ + $dircmp/GL4ES3-new.java \ + $dircmp/GLES3-new.java \ + $dircmp/GL4-new.java \ + $dircmp/GL4bc-new.java \ + $dircmp/GL-new.java" + +GL4FILES="$dircmp/GL2ES2-new.java \ + $dircmp/GL2ES3-new.java \ + $dircmp/GL3ES3-new.java \ + $dircmp/GL3-new.java \ + $dircmp/GL4ES3-new.java \ + $dircmp/GL4-new.java \ + $dircmp/GL-new.java" + +GLES3FILES="$dircmp/GL2ES2-new.java \ + $dircmp/GL2ES3-new.java \ + $dircmp/GL3ES3-new.java \ + $dircmp/GL4ES3-new.java \ + $dircmp/GLES3-new.java \ + $dircmp/GL-new.java" + +GLES1FILES="$dircmp/GL2ES1-new.java \ + $dircmp/GLES1-new.java \ + $dircmp/GL-new.java" + +GLES2FILES="$dircmp/GL2ES2-new.java \ + $dircmp/GLES2-new.java \ + $dircmp/GL-new.java" + +GL2ES2FILES="$dircmp/GL2ES2-new.java \ + $dircmp/GLES2-new.java \ + $dircmp/GL2-new.java \ + $dircmp/GL-new.java" + +GL3ES3FILES="$dircmp/GL2ES2-new.java \ + $dircmp/GL3ES3-new.java \ + $dircmp/GL4ES3-new.java \ + $dircmp/GLES3-new.java \ + $dircmp/GL3-new.java \ + $dircmp/GL4-new.java \ + $dircmp/GL-new.java" + +echo Duplicates GL GL2ES1 GL2ES2 GL2GL3 GL3 GL3bc GL4 GL4bc > $dircmp/GL4Files.dups +cat $GL4FILES | sort | uniq -d >> $dircmp/GL4Files.dups + +echo Duplicates GL GL2ES1 GLES1 > $dircmp/GLES1Files.dups +cat $GLES1FILES | sort | uniq -d >> $dircmp/GLES1Files.dups + +echo Duplicates GL GL2ES2 GLES2 > $dircmp/GLES2Files.dups +cat $GLES2FILES | sort | uniq -d >> $dircmp/GLES2Files.dups + +echo Duplicates GL GL2ES2 GL3ES3 GLES3 > $dircmp/GLES3Files.dups +cat $GLES3FILES | sort | uniq -d >> $dircmp/GLES3Files.dups + +echo Duplicates GL GL2 GL2ES2 GLES2 > $dircmp/GL2ES2Files.dups +cat $GL2ES2FILES | sort | uniq -d >> $dircmp/GL2ES2Files.dups + +echo Duplicates GL GL3 GL2ES2 GL2ES3 GLES3 > $dircmp/GL3ES3Files.dups +cat $GL3ES3FILES | sort | uniq -d >> $dircmp/GL3ES3Files.dups + +## +## + +echo Duplicates GL3ES3 GLES3 > $dircmp/GLES3-GL3ES3.dups +cat $dircmp/GLES3-new.java $dircmp/GL3ES3-new.java | sort | uniq -d >> $dircmp/GLES3-GL3ES3.dups + +echo Diff GL3ES3 GLES3 > $dircmp/GLES3-GL3ES3.diff +diff -Nurdw $dircmp/GLES3-new.java $dircmp/GL3ES3-new.java >> $dircmp/GLES3-GL3ES3.diff + +## +## + +echo Duplicates GL2GL3 GLES3 > $dircmp/GLES3-GL2GL3.dups +cat $dircmp/GLES3-new.java $dircmp/GL2GL3-new.java | sort | uniq -d >> $dircmp/GLES3-GL2GL3.dups + +echo Diff GL2GL3 GLES3 > $dircmp/GLES3-GL2GL3.diff +diff -Nurdw $dircmp/GLES3-new.java $dircmp/GL2GL3-new.java >> $dircmp/GLES3-GL2GL3.diff + +## +## + +echo Duplicates GL2ES2 GLES3 > $dircmp/GLES3-GL2ES2.dups +cat $dircmp/GLES3-new.java $dircmp/GL2ES2-new.java | sort | uniq -d >> $dircmp/GLES3-GL2ES2.dups + +echo Diff GL2ES2 GLES3 > $dircmp/GLES3-GL2ES2.diff +diff -Nurdw $dircmp/GLES3-new.java $dircmp/GL2ES2-new.java >> $dircmp/GLES3-GL2ES2.diff + +## +## + +echo Duplicates GL2GL3 GL3ES3 > $dircmp/GL3ES3-GL2GL3.dups +cat $dircmp/GL3ES3-new.java $dircmp/GL2GL3-new.java | sort | uniq -d >> $dircmp/GL3ES3-GL2GL3.dups + +echo Diff GL2GL3 GL3ES3 > $dircmp/GL3ES3-GL2GL3.diff +diff -Nurdw $dircmp/GL3ES3-new.java $dircmp/GL2GL3-new.java >> $dircmp/GL3ES3-GL2GL3.diff + +## +## + +echo Duplicates GL2ES2 GL3ES3 > $dircmp/GL3ES3-GL2ES2.dups +cat $dircmp/GL3ES3-new.java $dircmp/GL2ES2-new.java | sort | uniq -d >> $dircmp/GL3ES3-GL2ES2.dups + +echo Diff GL2ES2 GL3ES3 > $dircmp/GL3ES3-GL2ES2.diff +diff -Nurdw $dircmp/GL3ES3-new.java $dircmp/GL2ES2-new.java >> $dircmp/GL3ES3-GL2ES2.diff + +## +## + diff --git a/make/scripts/gluegen-gl.sh b/make/scripts/gluegen-gl.sh index d44c7987a..2d40ddcd9 100644 --- a/make/scripts/gluegen-gl.sh +++ b/make/scripts/gluegen-gl.sh @@ -47,6 +47,114 @@ copy_temp } +function gluegen_gl2es1() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-if-gl2_es1.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gles1.c \ + +copy_temp +} + +function gluegen_es1() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-es1.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gles1.c \ + +copy_temp +} + +function gluegen_gl2es2() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-if-gl2_es2.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gles2.c \ + +copy_temp +} + function gluegen_es2() { java \ -classpath \ @@ -84,6 +192,79 @@ copy_temp } +function gluegen_gl3es3() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-if-gl3_es3.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gles3.c \ + +copy_temp + +} +function gluegen_es3() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-es3.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gles3.c \ + +copy_temp + +} + function gluegen_gl2() { java \ -classpath \ @@ -130,7 +311,7 @@ com.jogamp.gluegen.GlueGen \ --dumpCPP \ -O../$rootrel/jogl \ -Ecom.jogamp.gluegen.opengl.GLEmitter \ --C./config/jogl/gl-if-gl3-subset.cfg \ +-C./config/jogl/gl-if-gl2gl3-subset.cfg \ -Istub_includes/jni \ -Istub_includes/jni/macosx \ -Istub_includes/jni/win32 \ @@ -154,6 +335,8 @@ com.jogamp.gluegen.GlueGen \ -I../../gluegen/make/stub_includes/gluegen \ stub_includes/opengl/gl3.c \ +copy_temp + java \ -classpath \ ../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ @@ -189,11 +372,207 @@ stub_includes/opengl/gl2.c \ copy_temp } + +function gluegen_glx() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/glx-x11.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/x11/window-system1.c \ + +copy_temp + +} + +function gluegen_glxext() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/glxext.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/x11/glxext.c \ + +copy_temp + +} + +function gluegen_wgl() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/wgl-win32.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/win32/window-system1.c \ + +copy_temp + +} + +function gluegen_wglext() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/wglext.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/win32/wglext.c \ + +copy_temp + +} + +function gluegen_gl4bc() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-gl4bc.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gl4bc.c \ + +copy_temp + +} + function gluegen_all() { -# gluegen_if_gl +# gluegen_if_gl +# gluegen_gl2es1 +# gluegen_es1 + gluegen_gl2es2 # gluegen_es2 +# gluegen_gl3es3 +# gluegen_es3 # gluegen_gl2 - gluegen_gl2gl3 +# gluegen_gl2gl3 +# gluegen_gl4bc +# gluegen_glx +# gluegen_glxext +# gluegen_wgl +# gluegen_wglext } gluegen_all 2>&1 | tee $(basename $0 .sh).log diff --git a/make/scripts/make.jogl.all.linux-x86_64.sh b/make/scripts/make.jogl.all.linux-x86_64.sh index 2488a7d4c..f59d6eabb 100755 --- a/make/scripts/make.jogl.all.linux-x86_64.sh +++ b/make/scripts/make.jogl.all.linux-x86_64.sh @@ -54,6 +54,7 @@ export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" # BUILD_ARCHIVE=true \ ant \ + -Dc.compiler.debug=true \ $CUSTOMLIBDIR \ -Drootrel.build=build-x86_64 \ $* 2>&1 | tee -a $LOGF diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9cae2ddeb..7484d5afe 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -147,6 +147,8 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" + ##D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil" + ##D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" @@ -289,7 +291,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -330,7 +332,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* diff --git a/make/stub_includes/egl/EGL/eglext.h b/make/stub_includes/egl/EGL/eglext.h index 763403609..769edaa33 100644 --- a/make/stub_includes/egl/EGL/eglext.h +++ b/make/stub_includes/egl/EGL/eglext.h @@ -6,7 +6,7 @@ extern "C" { #endif /* -** Copyright (c) 2007-2012 The Khronos Group Inc. +** Copyright (c) 2007-2013 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -34,8 +34,8 @@ extern "C" { /* Header file version number */ /* Current version at http://www.khronos.org/registry/egl/ */ -/* $Revision: 16473 $ on $Date: 2012-01-04 02:20:48 -0800 (Wed, 04 Jan 2012) $ */ -#define EGL_EGLEXT_VERSION 11 +/* $Revision: 21254 $ on $Date: 2013-04-25 03:11:55 -0700 (Thu, 25 Apr 2013) $ */ +#define EGL_EGLEXT_VERSION 16 #ifndef EGL_KHR_config_attribs #define EGL_KHR_config_attribs 1 @@ -208,12 +208,12 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG typedef void* EGLSyncNV; typedef khronos_utime_nanoseconds_t EGLTimeNV; #ifdef EGL_EGLEXT_PROTOTYPES -EGLSyncNV eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); -EGLBoolean eglDestroySyncNV (EGLSyncNV sync); -EGLBoolean eglFenceNV (EGLSyncNV sync); -EGLint eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); -EGLBoolean eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); -EGLBoolean eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); +EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync); +EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); #endif /* EGL_EGLEXT_PROTOTYPES */ typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); @@ -325,6 +325,86 @@ typedef EGLuint64 (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC)(void); typedef EGLuint64 (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC)(void); #endif +#if KHRONOS_SUPPORT_INT64 /* EGLuint64KHR requires 64-bit uint support */ +#ifndef EGL_KHR_stream +#define EGL_KHR_stream 1 +typedef void* EGLStreamKHR; +typedef khronos_uint64_t EGLuint64KHR; +#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) +#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 +#define EGL_PRODUCER_FRAME_KHR 0x3212 +#define EGL_CONSUMER_FRAME_KHR 0x3213 +#define EGL_STREAM_STATE_KHR 0x3214 +#define EGL_STREAM_STATE_CREATED_KHR 0x3215 +#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 +#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 +#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 +#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 +#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A +#define EGL_BAD_STREAM_KHR 0x321B +#define EGL_BAD_STATE_KHR 0x321C +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_consumer_gltexture +#define EGL_KHR_stream_consumer_gltexture 1 +#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_producer_eglsurface +#define EGL_KHR_stream_producer_eglsurface 1 +#define EGL_STREAM_BIT_KHR 0x0800 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_producer_aldatalocator +#define EGL_KHR_stream_producer_aldatalocator 1 +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_fifo +#define EGL_KHR_stream_fifo 1 +/* reuse EGLTimeKHR */ +#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC +#define EGL_STREAM_TIME_NOW_KHR 0x31FD +#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE +#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif +#endif + #ifndef EGL_EXT_create_context_robustness #define EGL_EXT_create_context_robustness 1 #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF @@ -359,8 +439,170 @@ typedef EGLuint64 (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC)(void); #endif +#ifndef EGL_ANGLE_d3d_share_handle_client_buffer +#define EGL_ANGLE_d3d_share_handle_client_buffer 1 +/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */ +#endif + +#ifndef EGL_KHR_create_context +#define EGL_KHR_create_context 1 +#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION +#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB +#define EGL_CONTEXT_FLAGS_KHR 0x30FC +#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD +#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF +#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 +#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 +#endif + +#ifndef EGL_KHR_surfaceless_context +#define EGL_KHR_surfaceless_context 1 +/* No tokens/entry points, just relaxes an error condition */ +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_cross_process_fd +#define EGL_KHR_stream_cross_process_fd 1 +typedef int EGLNativeFileDescriptorKHR; +#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif +#endif + +#ifndef EGL_EXT_multiview_window +#define EGL_EXT_multiview_window 1 +#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 +#endif + +#ifndef EGL_KHR_wait_sync +#define EGL_KHR_wait_sync 1 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif + +#ifndef EGL_NV_post_convert_rounding +#define EGL_NV_post_convert_rounding 1 +/* No tokens or entry points, just relaxes behavior of SwapBuffers */ +#endif + +#ifndef EGL_NV_native_query +#define EGL_NV_native_query 1 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV( EGLDisplay dpy, EGLNativeDisplayType* display_id); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV( EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType* window); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV( EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType* pixmap); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC)(EGLDisplay dpy, EGLNativeDisplayType *display_id); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#endif + +#ifndef EGL_NV_3dvision_surface +#define EGL_NV_3dvision_surface 1 +#define EGL_AUTO_STEREO_NV 0x3136 +#endif + +#ifndef EGL_ANDROID_framebuffer_target +#define EGL_ANDROID_framebuffer_target 1 +#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 +#endif + +/** FIXME: If desired - need manual binding */ +#if 0 +#ifndef EGL_ANDROID_blob_cache +#define EGL_ANDROID_blob_cache 1 +typedef khronos_ssize_t EGLsizeiANDROID; +typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); +typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC)(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif +#endif + +#ifndef EGL_ANDROID_image_native_buffer +#define EGL_ANDROID_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_ANDROID 0x3140 +#endif + +#ifndef EGL_ANDROID_native_fence_sync +#define EGL_ANDROID_native_fence_sync 1 +#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 +#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 +#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 +#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID( EGLDisplay dpy, EGLSyncKHR); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC)(EGLDisplay dpy, EGLSyncKHR); +#endif + +#ifndef EGL_ANDROID_recordable +#define EGL_ANDROID_recordable 1 +#define EGL_RECORDABLE_ANDROID 0x3142 +#endif + +#ifndef EGL_EXT_buffer_age +#define EGL_EXT_buffer_age 1 +#define EGL_BUFFER_AGE_EXT 0x313D +#endif + +#ifndef EGL_EXT_image_dma_buf_import +#define EGL_EXT_image_dma_buf_import 1 +#define EGL_LINUX_DMA_BUF_EXT 0x3270 +#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 +#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 +#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 +#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 +#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 +#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 +#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 +#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 +#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 +#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A +#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B +#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C +#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D +#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E +#define EGL_ITU_REC601_EXT 0x327F +#define EGL_ITU_REC709_EXT 0x3280 +#define EGL_ITU_REC2020_EXT 0x3281 +#define EGL_YUV_FULL_RANGE_EXT 0x3282 +#define EGL_YUV_NARROW_RANGE_EXT 0x3283 +#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 +#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 +#endif + +#ifndef EGL_ARM_pixmap_multisample_discard +#define EGL_ARM_pixmap_multisample_discard 1 +#define EGL_DISCARD_SAMPLES_ARM 0x3286 +#endif + +#ifndef EGL_EXT_swap_buffers_with_damage +#define EGL_EXT_swap_buffers_with_damage 1 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT( EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)(EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif + + #ifdef __cplusplus } #endif -#endif +#endif /* __eglext_h_ */ diff --git a/make/stub_includes/opengl/GL/gl-platform.h b/make/stub_includes/opengl/GL/gl-platform.h new file mode 100644 index 000000000..58df2cfd3 --- /dev/null +++ b/make/stub_includes/opengl/GL/gl-platform.h @@ -0,0 +1,80 @@ +#ifndef __gl_platform_h_ +#define __gl_platform_h_ + +#if defined(__BEOS__) +#include /* to get some BeOS-isms */ +#endif + +#if !defined(OPENSTEP) && (defined(NeXT) || defined(NeXT_PDO)) +#define OPENSTEP +#endif + +#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) +#define __WIN32__ +#endif + +#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) +# if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ +# define GLAPI __declspec(dllexport) +# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# define GLAPI __declspec(dllimport) +# else /* for use with static link lib build of Win32 edition only */ +# define GLAPI extern +# endif /* _STATIC_MESA support */ +# define APIENTRY __stdcall +#else +/* non-Windows compilation */ +# ifndef GLAPI +# define GLAPI extern +# endif +# define APIENTRY +#endif /* WIN32 / CYGWIN bracket */ + +#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__) +# define PRAGMA_EXPORT_SUPPORTED 1 +#endif + +/* + * WINDOWS: Include windows.h here to define APIENTRY. + * It is also useful when applications include this file by + * including only glut.h, since glut.h depends on windows.h. + * Applications needing to include windows.h with parms other + * than "WIN32_LEAN_AND_MEAN" may include windows.h before + * glut.h or gl.h. + */ +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(__CYGWIN__) +#include +#endif + +#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED +#pragma import on +#endif + +#ifdef CENTERLINE_CLPP +#define signed +#endif + +#if defined(PRAGMA_EXPORT_SUPPORTED) +#pragma export on +#endif + +/** + * The defaults for all .. + */ +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +#endif /* __gl_platform_h_ */ + diff --git a/make/stub_includes/opengl/GL/gl.h b/make/stub_includes/opengl/GL/gl.h index 0fe44172e..f6cfc7920 100644 --- a/make/stub_includes/opengl/GL/gl.h +++ b/make/stub_includes/opengl/GL/gl.h @@ -33,25 +33,9 @@ #ifndef __gl_h_ #define __gl_h_ -/* Function declaration macros - to move into glplatform.h */ -#include "glplatform.h" - -#ifndef GLAPIENTRY -#define GLAPIENTRY -#endif -#ifndef GLAPIENTRYP -#define GLAPIENTRYP GLAPIENTRY* -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -#ifndef APIENTRY -#define APIENTRY GLAPIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP GLAPIENTRYP -#endif +/* Function declaration macros - to move into gl-platform.h */ +#include "gl-platform.h" +#include "gl-types.h" #ifdef __cplusplus extern "C" { @@ -602,438 +586,438 @@ typedef double GLclampd; /* double precision float in [0,1] */ * Miscellaneous */ -GLAPI void GLAPIENTRY glClearIndex( GLfloat c ); +GLAPI void APIENTRY glClearIndex( GLfloat c ); -GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); +GLAPI void APIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); -GLAPI void GLAPIENTRY glClear( GLbitfield mask ); +GLAPI void APIENTRY glClear( GLbitfield mask ); -GLAPI void GLAPIENTRY glIndexMask( GLuint mask ); +GLAPI void APIENTRY glIndexMask( GLuint mask ); -GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); +GLAPI void APIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); -GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref ); +GLAPI void APIENTRY glAlphaFunc( GLenum func, GLclampf ref ); -GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); +GLAPI void APIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); -GLAPI void GLAPIENTRY glLogicOp( GLenum opcode ); +GLAPI void APIENTRY glLogicOp( GLenum opcode ); -GLAPI void GLAPIENTRY glCullFace( GLenum mode ); +GLAPI void APIENTRY glCullFace( GLenum mode ); -GLAPI void GLAPIENTRY glFrontFace( GLenum mode ); +GLAPI void APIENTRY glFrontFace( GLenum mode ); -GLAPI void GLAPIENTRY glPointSize( GLfloat size ); +GLAPI void APIENTRY glPointSize( GLfloat size ); -GLAPI void GLAPIENTRY glLineWidth( GLfloat width ); +GLAPI void APIENTRY glLineWidth( GLfloat width ); -GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern ); +GLAPI void APIENTRY glLineStipple( GLint factor, GLushort pattern ); -GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode ); +GLAPI void APIENTRY glPolygonMode( GLenum face, GLenum mode ); -GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units ); +GLAPI void APIENTRY glPolygonOffset( GLfloat factor, GLfloat units ); -GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask ); +GLAPI void APIENTRY glPolygonStipple( const GLubyte *mask ); -GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask ); +GLAPI void APIENTRY glGetPolygonStipple( GLubyte *mask ); -GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag ); +GLAPI void APIENTRY glEdgeFlag( GLboolean flag ); -GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag ); +GLAPI void APIENTRY glEdgeFlagv( const GLboolean *flag ); -GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation ); +GLAPI void APIENTRY glClipPlane( GLenum plane, const GLdouble *equation ); -GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation ); +GLAPI void APIENTRY glGetClipPlane( GLenum plane, GLdouble *equation ); -GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode ); +GLAPI void APIENTRY glDrawBuffer( GLenum mode ); -GLAPI void GLAPIENTRY glReadBuffer( GLenum mode ); +GLAPI void APIENTRY glReadBuffer( GLenum mode ); -GLAPI void GLAPIENTRY glEnable( GLenum cap ); +GLAPI void APIENTRY glEnable( GLenum cap ); -GLAPI void GLAPIENTRY glDisable( GLenum cap ); +GLAPI void APIENTRY glDisable( GLenum cap ); -GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap ); +GLAPI GLboolean APIENTRY glIsEnabled( GLenum cap ); -GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params ); +GLAPI void APIENTRY glGetBooleanv( GLenum pname, GLboolean *params ); -GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params ); +GLAPI void APIENTRY glGetDoublev( GLenum pname, GLdouble *params ); -GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params ); +GLAPI void APIENTRY glGetFloatv( GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params ); +GLAPI void APIENTRY glGetIntegerv( GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask ); +GLAPI void APIENTRY glPushAttrib( GLbitfield mask ); -GLAPI void GLAPIENTRY glPopAttrib( void ); +GLAPI void APIENTRY glPopAttrib( void ); -GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode ); +GLAPI GLint APIENTRY glRenderMode( GLenum mode ); -GLAPI GLenum GLAPIENTRY glGetError( void ); +GLAPI GLenum APIENTRY glGetError( void ); -GLAPI const GLubyte* GLAPIENTRY glGetString( GLenum name ); +GLAPI const GLubyte* APIENTRY glGetString( GLenum name ); -GLAPI void GLAPIENTRY glFinish( void ); +GLAPI void APIENTRY glFinish( void ); -GLAPI void GLAPIENTRY glFlush( void ); +GLAPI void APIENTRY glFlush( void ); -GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode ); +GLAPI void APIENTRY glHint( GLenum target, GLenum mode ); /* * Depth Buffer */ -GLAPI void GLAPIENTRY glClearDepth( GLclampd depth ); +GLAPI void APIENTRY glClearDepth( GLclampd depth ); -GLAPI void GLAPIENTRY glDepthFunc( GLenum func ); +GLAPI void APIENTRY glDepthFunc( GLenum func ); -GLAPI void GLAPIENTRY glDepthMask( GLboolean flag ); +GLAPI void APIENTRY glDepthMask( GLboolean flag ); -GLAPI void GLAPIENTRY glDepthRange( GLclampd zNear, GLclampd zFar ); +GLAPI void APIENTRY glDepthRange( GLclampd zNear, GLclampd zFar ); /* * Accumulation Buffer */ -GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); +GLAPI void APIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); -GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value ); +GLAPI void APIENTRY glAccum( GLenum op, GLfloat value ); /* * Transformation */ -GLAPI void GLAPIENTRY glMatrixMode( GLenum mode ); +GLAPI void APIENTRY glMatrixMode( GLenum mode ); -GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right, +GLAPI void APIENTRY glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); -GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right, +GLAPI void APIENTRY glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); -GLAPI void GLAPIENTRY glViewport( GLint x, GLint y, +GLAPI void APIENTRY glViewport( GLint x, GLint y, GLsizei width, GLsizei height ); -GLAPI void GLAPIENTRY glPushMatrix( void ); +GLAPI void APIENTRY glPushMatrix( void ); -GLAPI void GLAPIENTRY glPopMatrix( void ); +GLAPI void APIENTRY glPopMatrix( void ); -GLAPI void GLAPIENTRY glLoadIdentity( void ); +GLAPI void APIENTRY glLoadIdentity( void ); -GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m ); -GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m ); +GLAPI void APIENTRY glLoadMatrixd( const GLdouble *m ); +GLAPI void APIENTRY glLoadMatrixf( const GLfloat *m ); -GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m ); -GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m ); +GLAPI void APIENTRY glMultMatrixd( const GLdouble *m ); +GLAPI void APIENTRY glMultMatrixf( const GLfloat *m ); -GLAPI void GLAPIENTRY glRotated( GLdouble angle, +GLAPI void APIENTRY glRotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glRotatef( GLfloat angle, +GLAPI void APIENTRY glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); -GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void APIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void APIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z ); -GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void APIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void APIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); /* * Display Lists */ -GLAPI GLboolean GLAPIENTRY glIsList( GLuint list ); +GLAPI GLboolean APIENTRY glIsList( GLuint list ); -GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range ); +GLAPI void APIENTRY glDeleteLists( GLuint list, GLsizei range ); -GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range ); +GLAPI GLuint APIENTRY glGenLists( GLsizei range ); -GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode ); +GLAPI void APIENTRY glNewList( GLuint list, GLenum mode ); -GLAPI void GLAPIENTRY glEndList( void ); +GLAPI void APIENTRY glEndList( void ); -GLAPI void GLAPIENTRY glCallList( GLuint list ); +GLAPI void APIENTRY glCallList( GLuint list ); -GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type, +GLAPI void APIENTRY glCallLists( GLsizei n, GLenum type, const GLvoid *lists ); -GLAPI void GLAPIENTRY glListBase( GLuint base ); +GLAPI void APIENTRY glListBase( GLuint base ); /* * Drawing Functions */ -GLAPI void GLAPIENTRY glBegin( GLenum mode ); +GLAPI void APIENTRY glBegin( GLenum mode ); -GLAPI void GLAPIENTRY glEnd( void ); +GLAPI void APIENTRY glEnd( void ); -GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y ); -GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y ); -GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y ); -GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y ); +GLAPI void APIENTRY glVertex2d( GLdouble x, GLdouble y ); +GLAPI void APIENTRY glVertex2f( GLfloat x, GLfloat y ); +GLAPI void APIENTRY glVertex2i( GLint x, GLint y ); +GLAPI void APIENTRY glVertex2s( GLshort x, GLshort y ); -GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z ); -GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z ); -GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z ); +GLAPI void APIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void APIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void APIENTRY glVertex3i( GLint x, GLint y, GLint z ); +GLAPI void APIENTRY glVertex3s( GLshort x, GLshort y, GLshort z ); -GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); -GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); -GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w ); -GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); +GLAPI void APIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void APIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void APIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void APIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); -GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glVertex2iv( const GLint *v ); -GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v ); +GLAPI void APIENTRY glVertex2dv( const GLdouble *v ); +GLAPI void APIENTRY glVertex2fv( const GLfloat *v ); +GLAPI void APIENTRY glVertex2iv( const GLint *v ); +GLAPI void APIENTRY glVertex2sv( const GLshort *v ); -GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glVertex3iv( const GLint *v ); -GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v ); +GLAPI void APIENTRY glVertex3dv( const GLdouble *v ); +GLAPI void APIENTRY glVertex3fv( const GLfloat *v ); +GLAPI void APIENTRY glVertex3iv( const GLint *v ); +GLAPI void APIENTRY glVertex3sv( const GLshort *v ); -GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glVertex4iv( const GLint *v ); -GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v ); +GLAPI void APIENTRY glVertex4dv( const GLdouble *v ); +GLAPI void APIENTRY glVertex4fv( const GLfloat *v ); +GLAPI void APIENTRY glVertex4iv( const GLint *v ); +GLAPI void APIENTRY glVertex4sv( const GLshort *v ); -GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); -GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); -GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); -GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz ); -GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz ); +GLAPI void APIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); +GLAPI void APIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); +GLAPI void APIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); +GLAPI void APIENTRY glNormal3i( GLint nx, GLint ny, GLint nz ); +GLAPI void APIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz ); -GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v ); -GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glNormal3iv( const GLint *v ); -GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v ); +GLAPI void APIENTRY glNormal3bv( const GLbyte *v ); +GLAPI void APIENTRY glNormal3dv( const GLdouble *v ); +GLAPI void APIENTRY glNormal3fv( const GLfloat *v ); +GLAPI void APIENTRY glNormal3iv( const GLint *v ); +GLAPI void APIENTRY glNormal3sv( const GLshort *v ); -GLAPI void GLAPIENTRY glIndexd( GLdouble c ); -GLAPI void GLAPIENTRY glIndexf( GLfloat c ); -GLAPI void GLAPIENTRY glIndexi( GLint c ); -GLAPI void GLAPIENTRY glIndexs( GLshort c ); +GLAPI void APIENTRY glIndexd( GLdouble c ); +GLAPI void APIENTRY glIndexf( GLfloat c ); +GLAPI void APIENTRY glIndexi( GLint c ); +GLAPI void APIENTRY glIndexs( GLshort c ); -GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c ); -GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c ); -GLAPI void GLAPIENTRY glIndexiv( const GLint *c ); -GLAPI void GLAPIENTRY glIndexsv( const GLshort *c ); +GLAPI void APIENTRY glIndexdv( const GLdouble *c ); +GLAPI void APIENTRY glIndexfv( const GLfloat *c ); +GLAPI void APIENTRY glIndexiv( const GLint *c ); +GLAPI void APIENTRY glIndexsv( const GLshort *c ); -GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue ); -GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue ); -GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue ); -GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue ); -GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue ); -GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); -GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue ); -GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue ); +GLAPI void APIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue ); +GLAPI void APIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue ); +GLAPI void APIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue ); +GLAPI void APIENTRY glColor3i( GLint red, GLint green, GLint blue ); +GLAPI void APIENTRY glColor3s( GLshort red, GLshort green, GLshort blue ); +GLAPI void APIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); +GLAPI void APIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue ); +GLAPI void APIENTRY glColor3us( GLushort red, GLushort green, GLushort blue ); -GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green, +GLAPI void APIENTRY glColor4b( GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ); -GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green, +GLAPI void APIENTRY glColor4d( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ); -GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green, +GLAPI void APIENTRY glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); -GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green, +GLAPI void APIENTRY glColor4i( GLint red, GLint green, GLint blue, GLint alpha ); -GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green, +GLAPI void APIENTRY glColor4s( GLshort red, GLshort green, GLshort blue, GLshort alpha ); -GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green, +GLAPI void APIENTRY glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ); -GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green, +GLAPI void APIENTRY glColor4ui( GLuint red, GLuint green, GLuint blue, GLuint alpha ); -GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green, +GLAPI void APIENTRY glColor4us( GLushort red, GLushort green, GLushort blue, GLushort alpha ); -GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v ); -GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glColor3iv( const GLint *v ); -GLAPI void GLAPIENTRY glColor3sv( const GLshort *v ); -GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v ); -GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v ); -GLAPI void GLAPIENTRY glColor3usv( const GLushort *v ); - -GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v ); -GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glColor4iv( const GLint *v ); -GLAPI void GLAPIENTRY glColor4sv( const GLshort *v ); -GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v ); -GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v ); -GLAPI void GLAPIENTRY glColor4usv( const GLushort *v ); - - -GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s ); -GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s ); -GLAPI void GLAPIENTRY glTexCoord1i( GLint s ); -GLAPI void GLAPIENTRY glTexCoord1s( GLshort s ); - -GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t ); -GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t ); -GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t ); -GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t ); - -GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); -GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); -GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r ); -GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r ); - -GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); -GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); -GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); -GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); - -GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v ); -GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v ); -GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v ); -GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v ); -GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v ); - - -GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y ); -GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y ); -GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y ); -GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y ); - -GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); -GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z ); -GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z ); - -GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); -GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); -GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); -GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); - -GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v ); -GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v ); -GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v ); -GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v ); - - -GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); -GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); -GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); -GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); - - -GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 ); -GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 ); -GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 ); -GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 ); +GLAPI void APIENTRY glColor3bv( const GLbyte *v ); +GLAPI void APIENTRY glColor3dv( const GLdouble *v ); +GLAPI void APIENTRY glColor3fv( const GLfloat *v ); +GLAPI void APIENTRY glColor3iv( const GLint *v ); +GLAPI void APIENTRY glColor3sv( const GLshort *v ); +GLAPI void APIENTRY glColor3ubv( const GLubyte *v ); +GLAPI void APIENTRY glColor3uiv( const GLuint *v ); +GLAPI void APIENTRY glColor3usv( const GLushort *v ); + +GLAPI void APIENTRY glColor4bv( const GLbyte *v ); +GLAPI void APIENTRY glColor4dv( const GLdouble *v ); +GLAPI void APIENTRY glColor4fv( const GLfloat *v ); +GLAPI void APIENTRY glColor4iv( const GLint *v ); +GLAPI void APIENTRY glColor4sv( const GLshort *v ); +GLAPI void APIENTRY glColor4ubv( const GLubyte *v ); +GLAPI void APIENTRY glColor4uiv( const GLuint *v ); +GLAPI void APIENTRY glColor4usv( const GLushort *v ); + + +GLAPI void APIENTRY glTexCoord1d( GLdouble s ); +GLAPI void APIENTRY glTexCoord1f( GLfloat s ); +GLAPI void APIENTRY glTexCoord1i( GLint s ); +GLAPI void APIENTRY glTexCoord1s( GLshort s ); + +GLAPI void APIENTRY glTexCoord2d( GLdouble s, GLdouble t ); +GLAPI void APIENTRY glTexCoord2f( GLfloat s, GLfloat t ); +GLAPI void APIENTRY glTexCoord2i( GLint s, GLint t ); +GLAPI void APIENTRY glTexCoord2s( GLshort s, GLshort t ); + +GLAPI void APIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); +GLAPI void APIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); +GLAPI void APIENTRY glTexCoord3i( GLint s, GLint t, GLint r ); +GLAPI void APIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r ); + +GLAPI void APIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); +GLAPI void APIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); +GLAPI void APIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); +GLAPI void APIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void APIENTRY glTexCoord1dv( const GLdouble *v ); +GLAPI void APIENTRY glTexCoord1fv( const GLfloat *v ); +GLAPI void APIENTRY glTexCoord1iv( const GLint *v ); +GLAPI void APIENTRY glTexCoord1sv( const GLshort *v ); + +GLAPI void APIENTRY glTexCoord2dv( const GLdouble *v ); +GLAPI void APIENTRY glTexCoord2fv( const GLfloat *v ); +GLAPI void APIENTRY glTexCoord2iv( const GLint *v ); +GLAPI void APIENTRY glTexCoord2sv( const GLshort *v ); + +GLAPI void APIENTRY glTexCoord3dv( const GLdouble *v ); +GLAPI void APIENTRY glTexCoord3fv( const GLfloat *v ); +GLAPI void APIENTRY glTexCoord3iv( const GLint *v ); +GLAPI void APIENTRY glTexCoord3sv( const GLshort *v ); + +GLAPI void APIENTRY glTexCoord4dv( const GLdouble *v ); +GLAPI void APIENTRY glTexCoord4fv( const GLfloat *v ); +GLAPI void APIENTRY glTexCoord4iv( const GLint *v ); +GLAPI void APIENTRY glTexCoord4sv( const GLshort *v ); + + +GLAPI void APIENTRY glRasterPos2d( GLdouble x, GLdouble y ); +GLAPI void APIENTRY glRasterPos2f( GLfloat x, GLfloat y ); +GLAPI void APIENTRY glRasterPos2i( GLint x, GLint y ); +GLAPI void APIENTRY glRasterPos2s( GLshort x, GLshort y ); + +GLAPI void APIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void APIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void APIENTRY glRasterPos3i( GLint x, GLint y, GLint z ); +GLAPI void APIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void APIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void APIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void APIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void APIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void APIENTRY glRasterPos2dv( const GLdouble *v ); +GLAPI void APIENTRY glRasterPos2fv( const GLfloat *v ); +GLAPI void APIENTRY glRasterPos2iv( const GLint *v ); +GLAPI void APIENTRY glRasterPos2sv( const GLshort *v ); + +GLAPI void APIENTRY glRasterPos3dv( const GLdouble *v ); +GLAPI void APIENTRY glRasterPos3fv( const GLfloat *v ); +GLAPI void APIENTRY glRasterPos3iv( const GLint *v ); +GLAPI void APIENTRY glRasterPos3sv( const GLshort *v ); + +GLAPI void APIENTRY glRasterPos4dv( const GLdouble *v ); +GLAPI void APIENTRY glRasterPos4fv( const GLfloat *v ); +GLAPI void APIENTRY glRasterPos4iv( const GLint *v ); +GLAPI void APIENTRY glRasterPos4sv( const GLshort *v ); + + +GLAPI void APIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); +GLAPI void APIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); +GLAPI void APIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); +GLAPI void APIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); + + +GLAPI void APIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 ); +GLAPI void APIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 ); +GLAPI void APIENTRY glRectiv( const GLint *v1, const GLint *v2 ); +GLAPI void APIENTRY glRectsv( const GLshort *v1, const GLshort *v2 ); /* * Lighting */ -GLAPI void GLAPIENTRY glShadeModel( GLenum mode ); +GLAPI void APIENTRY glShadeModel( GLenum mode ); -GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname, +GLAPI void APIENTRY glLightf( GLenum light, GLenum pname, GLfloat param ); +GLAPI void APIENTRY glLighti( GLenum light, GLenum pname, GLint param ); +GLAPI void APIENTRY glLightfv( GLenum light, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname, +GLAPI void APIENTRY glLightiv( GLenum light, GLenum pname, const GLint *params ); -GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname, +GLAPI void APIENTRY glGetLightfv( GLenum light, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname, +GLAPI void APIENTRY glGetLightiv( GLenum light, GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params ); +GLAPI void APIENTRY glLightModelf( GLenum pname, GLfloat param ); +GLAPI void APIENTRY glLightModeli( GLenum pname, GLint param ); +GLAPI void APIENTRY glLightModelfv( GLenum pname, const GLfloat *params ); +GLAPI void APIENTRY glLightModeliv( GLenum pname, const GLint *params ); -GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params ); +GLAPI void APIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param ); +GLAPI void APIENTRY glMateriali( GLenum face, GLenum pname, GLint param ); +GLAPI void APIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); +GLAPI void APIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params ); -GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); +GLAPI void APIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); +GLAPI void APIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode ); +GLAPI void APIENTRY glColorMaterial( GLenum face, GLenum mode ); /* * Raster functions */ -GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor ); +GLAPI void APIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor ); -GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param ); +GLAPI void APIENTRY glPixelStoref( GLenum pname, GLfloat param ); +GLAPI void APIENTRY glPixelStorei( GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param ); +GLAPI void APIENTRY glPixelTransferf( GLenum pname, GLfloat param ); +GLAPI void APIENTRY glPixelTransferi( GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLint mapsize, +GLAPI void APIENTRY glPixelMapfv( GLenum map, GLint mapsize, const GLfloat *values ); -GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLint mapsize, +GLAPI void APIENTRY glPixelMapuiv( GLenum map, GLint mapsize, const GLuint *values ); -GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLint mapsize, +GLAPI void APIENTRY glPixelMapusv( GLenum map, GLint mapsize, const GLushort *values ); -GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); -GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values ); -GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values ); +GLAPI void APIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); +GLAPI void APIENTRY glGetPixelMapuiv( GLenum map, GLuint *values ); +GLAPI void APIENTRY glGetPixelMapusv( GLenum map, GLushort *values ); -GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height, +GLAPI void APIENTRY glBitmap( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap ); -GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y, +GLAPI void APIENTRY glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels ); -GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height, +GLAPI void APIENTRY glDrawPixels( GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); -GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y, +GLAPI void APIENTRY glCopyPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum type ); @@ -1041,13 +1025,13 @@ GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y, * Stenciling */ -GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask ); +GLAPI void APIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask ); -GLAPI void GLAPIENTRY glStencilMask( GLuint mask ); +GLAPI void APIENTRY glStencilMask( GLuint mask ); -GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); +GLAPI void APIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); -GLAPI void GLAPIENTRY glClearStencil( GLint s ); +GLAPI void APIENTRY glClearStencil( GLint s ); @@ -1055,61 +1039,61 @@ GLAPI void GLAPIENTRY glClearStencil( GLint s ); * Texture mapping */ -GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param ); -GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param ); +GLAPI void APIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param ); +GLAPI void APIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param ); +GLAPI void APIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); -GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); +GLAPI void APIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); +GLAPI void APIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); +GLAPI void APIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); -GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); -GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); +GLAPI void APIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); +GLAPI void APIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); +GLAPI void APIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param ); +GLAPI void APIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void APIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params ); +GLAPI void APIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); +GLAPI void APIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params ); -GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); +GLAPI void APIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); +GLAPI void APIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); +GLAPI void APIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname, +GLAPI void APIENTRY glTexParameterfv( GLenum target, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname, +GLAPI void APIENTRY glTexParameteriv( GLenum target, GLenum pname, const GLint *params ); -GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target, +GLAPI void APIENTRY glGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target, +GLAPI void APIENTRY glGetTexParameteriv( GLenum target, GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level, +GLAPI void APIENTRY glGetTexLevelParameterfv( GLenum target, GLint level, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level, +GLAPI void APIENTRY glGetTexLevelParameteriv( GLenum target, GLint level, GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level, +GLAPI void APIENTRY glTexImage1D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); -GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level, +GLAPI void APIENTRY glTexImage2D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); -GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level, +GLAPI void APIENTRY glGetTexImage( GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels ); @@ -1118,85 +1102,85 @@ GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level, * Evaluators */ -GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2, +GLAPI void APIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points ); -GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2, +GLAPI void APIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points ); -GLAPI void GLAPIENTRY glMap2d( GLenum target, +GLAPI void APIENTRY glMap2d( GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points ); -GLAPI void GLAPIENTRY glMap2f( GLenum target, +GLAPI void APIENTRY glMap2f( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points ); -GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v ); -GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v ); -GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v ); +GLAPI void APIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v ); +GLAPI void APIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v ); +GLAPI void APIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v ); -GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u ); -GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u ); +GLAPI void APIENTRY glEvalCoord1d( GLdouble u ); +GLAPI void APIENTRY glEvalCoord1f( GLfloat u ); -GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u ); -GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u ); +GLAPI void APIENTRY glEvalCoord1dv( const GLdouble *u ); +GLAPI void APIENTRY glEvalCoord1fv( const GLfloat *u ); -GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v ); -GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v ); +GLAPI void APIENTRY glEvalCoord2d( GLdouble u, GLdouble v ); +GLAPI void APIENTRY glEvalCoord2f( GLfloat u, GLfloat v ); -GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u ); -GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u ); +GLAPI void APIENTRY glEvalCoord2dv( const GLdouble *u ); +GLAPI void APIENTRY glEvalCoord2fv( const GLfloat *u ); -GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); -GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); +GLAPI void APIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); +GLAPI void APIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); -GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, +GLAPI void APIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2 ); -GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, +GLAPI void APIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2 ); -GLAPI void GLAPIENTRY glEvalPoint1( GLint i ); +GLAPI void APIENTRY glEvalPoint1( GLint i ); -GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j ); +GLAPI void APIENTRY glEvalPoint2( GLint i, GLint j ); -GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); +GLAPI void APIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); -GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); +GLAPI void APIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); /* * Fog */ -GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param ); +GLAPI void APIENTRY glFogf( GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param ); +GLAPI void APIENTRY glFogi( GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params ); +GLAPI void APIENTRY glFogfv( GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params ); +GLAPI void APIENTRY glFogiv( GLenum pname, const GLint *params ); /* * Selection and Feedback */ -GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); +GLAPI void APIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); -GLAPI void GLAPIENTRY glPassThrough( GLfloat token ); +GLAPI void APIENTRY glPassThrough( GLfloat token ); -GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer ); +GLAPI void APIENTRY glSelectBuffer( GLsizei size, GLuint *buffer ); -GLAPI void GLAPIENTRY glInitNames( void ); +GLAPI void APIENTRY glInitNames( void ); -GLAPI void GLAPIENTRY glLoadName( GLuint name ); +GLAPI void APIENTRY glLoadName( GLuint name ); -GLAPI void GLAPIENTRY glPushName( GLuint name ); +GLAPI void APIENTRY glPushName( GLuint name ); -GLAPI void GLAPIENTRY glPopName( void ); +GLAPI void APIENTRY glPopName( void ); #endif /* GL_VERSION_1_0 */ @@ -1296,37 +1280,37 @@ GLAPI void GLAPIENTRY glPopName( void ); #define GL_T2F_C4F_N3F_V3F 0x2A2C #define GL_T4F_C4F_N3F_V4F 0x2A2D -GLAPI void GLAPIENTRY glIndexub( GLubyte c ); -GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); - -GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); -GLAPI void GLAPIENTRY glPopClientAttrib( void ); -GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); -GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); -GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); -GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); -GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); -GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); -GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); -GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); -GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params ); -GLAPI void GLAPIENTRY glArrayElement( GLint i ); -GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); -GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ); -GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride, const GLvoid *pointer ); - -GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures ); -GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures); -GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture ); -GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n, const GLuint *textures, const GLclampf *priorities ); -GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n, const GLuint *textures, GLboolean *residences ); -GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture ); -GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels ); -GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); -GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border ); -GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ); -GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ); -GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ); +GLAPI void APIENTRY glIndexub( GLubyte c ); +GLAPI void APIENTRY glIndexubv( const GLubyte *c ); + +GLAPI void APIENTRY glPushClientAttrib( GLbitfield mask ); +GLAPI void APIENTRY glPopClientAttrib( void ); +GLAPI void APIENTRY glEnableClientState( GLenum cap ); +GLAPI void APIENTRY glDisableClientState( GLenum cap ); +GLAPI void APIENTRY glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); +GLAPI void APIENTRY glNormalPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); +GLAPI void APIENTRY glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); +GLAPI void APIENTRY glIndexPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); +GLAPI void APIENTRY glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); +GLAPI void APIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); +GLAPI void APIENTRY glGetPointerv( GLenum pname, GLvoid **params ); +GLAPI void APIENTRY glArrayElement( GLint i ); +GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); +GLAPI void APIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ); +GLAPI void APIENTRY glInterleavedArrays( GLenum format, GLsizei stride, const GLvoid *pointer ); + +GLAPI void APIENTRY glGenTextures( GLsizei n, GLuint *textures ); +GLAPI void APIENTRY glDeleteTextures( GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glBindTexture( GLenum target, GLuint texture ); +GLAPI void APIENTRY glPrioritizeTextures( GLsizei n, const GLuint *textures, const GLclampf *priorities ); +GLAPI GLboolean APIENTRY glAreTexturesResident( GLsizei n, const GLuint *textures, GLboolean *residences ); +GLAPI GLboolean APIENTRY glIsTexture( GLuint texture ); +GLAPI void APIENTRY glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels ); +GLAPI void APIENTRY glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); +GLAPI void APIENTRY glCopyTexImage1D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border ); +GLAPI void APIENTRY glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ); +GLAPI void APIENTRY glCopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ); +GLAPI void APIENTRY glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ); #endif /* GL_VERSION_1_1 */ diff --git a/make/stub_includes/opengl/GL/glcorearb.h b/make/stub_includes/opengl/GL/glcorearb.h new file mode 100644 index 000000000..9316b48da --- /dev/null +++ b/make/stub_includes/opengl/GL/glcorearb.h @@ -0,0 +1,3262 @@ +#ifndef __glcorearb_h_ +#define __glcorearb_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision$ on $Date$ +*/ + +/* Function declaration macros - to move into gl-platform.h */ +#include "gl-platform.h" +#include "gl-types.h" + +/* glcorearb.h is for use with OpenGL core profile implementations. +** It should should be placed in the same directory as gl.h and +** included as . +** +** glcorearb.h includes only APIs in the latest OpenGL core profile +** implementation together with APIs in newer ARB extensions which +** can be supported by the core profile. It does not, and never will +** include functionality removed from the core profile, such as +** fixed-function vertex and fragment processing. +** +** Do not #include both and either of or +** in the same source file. +*/ + +/* Generated C header for: + * API: gl + * Profile: core + * Versions considered: .* + * Versions emitted: .* + * Default extensions included: glcore + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#endif /* GL_ARB_imaging */ + +#ifndef GL_VERSION_1_0 +#define GL_VERSION_1_0 1 +typedef unsigned int GLenum; +typedef float GLfloat; +typedef int GLint; +typedef int GLsizei; +typedef void GLvoid; +typedef unsigned int GLbitfield; +typedef double GLdouble; +typedef unsigned int GLuint; +typedef unsigned char GLboolean; +typedef unsigned char GLubyte; +typedef void (APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); +typedef void (APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); +typedef void (APIENTRYP PFNGLPOINTSIZEPROC) (GLfloat size); +typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLDRAWBUFFERPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); +typedef void (APIENTRYP PFNGLCLEARDEPTHPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); +typedef void (APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); +typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); +typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); +typedef void (APIENTRYP PFNGLFINISHPROC) (void); +typedef void (APIENTRYP PFNGLFLUSHPROC) (void); +typedef void (APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); +typedef void (APIENTRYP PFNGLLOGICOPPROC) (GLenum opcode); +typedef void (APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); +typedef void (APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); +typedef void (APIENTRYP PFNGLPIXELSTOREFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLREADBUFFERPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *params); +typedef void (APIENTRYP PFNGLGETDOUBLEVPROC) (GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); +typedef void (APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); +typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) (GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); +typedef void (APIENTRYP PFNGLDEPTHRANGEPROC) (GLdouble near, GLdouble far); +typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullFace (GLenum mode); +GLAPI void APIENTRY glFrontFace (GLenum mode); +GLAPI void APIENTRY glHint (GLenum target, GLenum mode); +GLAPI void APIENTRY glLineWidth (GLfloat width); +GLAPI void APIENTRY glPointSize (GLfloat size); +GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode); +GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glDrawBuffer (GLenum mode); +GLAPI void APIENTRY glClear (GLbitfield mask); +GLAPI void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glClearStencil (GLint s); +GLAPI void APIENTRY glClearDepth (GLdouble depth); +GLAPI void APIENTRY glStencilMask (GLuint mask); +GLAPI void APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GLAPI void APIENTRY glDepthMask (GLboolean flag); +GLAPI void APIENTRY glDisable (GLenum cap); +GLAPI void APIENTRY glEnable (GLenum cap); +GLAPI void APIENTRY glFinish (void); +GLAPI void APIENTRY glFlush (void); +GLAPI void APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GLAPI void APIENTRY glLogicOp (GLenum opcode); +GLAPI void APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GLAPI void APIENTRY glDepthFunc (GLenum func); +GLAPI void APIENTRY glPixelStoref (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param); +GLAPI void APIENTRY glReadBuffer (GLenum mode); +GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetBooleanv (GLenum pname, GLboolean *params); +GLAPI void APIENTRY glGetDoublev (GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glGetError (void); +GLAPI void APIENTRY glGetFloatv (GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *params); +GLAPI const GLubyte *APIENTRY glGetString (GLenum name); +GLAPI void APIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap); +GLAPI void APIENTRY glDepthRange (GLdouble near, GLdouble far); +GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_0 */ + +#ifndef GL_VERSION_1_1 +#define GL_VERSION_1_1 1 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_NONE 0 +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_RANGE 0x0B12 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_RANGE 0x0B22 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_VIEWPORT 0x0BA2 +#define GL_DITHER 0x0BD0 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND 0x0BE2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_READ_BUFFER 0x0C02 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_DOUBLE 0x140A +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_CLEAR 0x1500 +#define GL_AND 0x1501 +#define GL_AND_REVERSE 0x1502 +#define GL_COPY 0x1503 +#define GL_AND_INVERTED 0x1504 +#define GL_NOOP 0x1505 +#define GL_XOR 0x1506 +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_EQUIV 0x1509 +#define GL_INVERT 0x150A +#define GL_OR_REVERSE 0x150B +#define GL_COPY_INVERTED 0x150C +#define GL_OR_INVERTED 0x150D +#define GL_NAND 0x150E +#define GL_SET 0x150F +#define GL_TEXTURE 0x1702 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_STENCIL_INDEX 0x1901 +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_REPEAT 0x2901 +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +typedef void (APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, GLvoid **params); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glGetPointerv (GLenum pname, GLvoid **params); +GLAPI void APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTexture (GLuint texture); +#endif +#endif /* GL_VERSION_1_1 */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_2 */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); +#endif +#endif /* GL_VERSION_1_3 */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#include +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid **params); +#endif +#endif /* GL_VERSION_1_5 */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +typedef char GLchar; +typedef short GLshort; +typedef signed char GLbyte; +typedef unsigned short GLushort; +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid **pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif +#endif /* GL_VERSION_2_0 */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_VERSION_2_1 */ + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif +#endif /* GL_VERSION_3_0 */ + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif +#endif /* GL_VERSION_3_1 */ + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif +typedef int64_t GLint64; +typedef struct __GLsync *GLsync; +typedef uint64_t GLuint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); +#endif +#endif /* GL_VERSION_3_2 */ + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif +#endif /* GL_VERSION_3_3 */ + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_VERSION_4_0 */ + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat zNear, GLfloat zFar); +GLAPI void APIENTRY glClearDepthf (GLfloat depth); +#endif /* GL_GLEXT_PROTOTYPES */ +#endif /* GL_ARB_ES2_compatibility */ + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#ifndef GL_ARB_ES2_compatibility +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#endif /* GL_ARB_ES2_compatibility */ +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +#ifndef GL_ARB_ES2_compatibility +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +#endif /* GL_ARB_ES2_compatibility */ +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#ifdef GL_GLEXT_PROTOTYPES +#ifndef GL_ARB_ES2_compatibility +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat zNear, GLfloat zFar); +GLAPI void APIENTRY glClearDepthf (GLfloat depth); +#endif /* GL_ARB_ES2_compatibility */ +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif +#endif /* GL_VERSION_4_1 */ + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#ifndef GL_ARB_ES3_compatibility +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif /* GL_ARB_ES3_compatibility */ +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_LOCAL_WORK_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +typedef struct _cl_context * cl_context; +typedef struct _cl_event * cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (cl_context context, cl_event event, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (cl_context context, cl_event event, GLbitfield flags); +#endif +#endif /* GL_ARB_cl_event */ + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#endif +#endif /* GL_ARB_clear_buffer_object */ + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif +#endif /* GL_ARB_debug_output */ + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif +#endif /* GL_ARB_draw_buffers_blend */ + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +#endif +#endif /* GL_ARB_framebuffer_no_attachments */ + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif +#endif /* GL_ARB_internalformat_query */ + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#endif /* GL_ARB_internalformat_query2 */ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif +#endif /* GL_ARB_robustness */ + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif +#endif /* GL_ARB_sample_shading */ + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ + +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar **path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar **path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif +#endif /* GL_ARB_shading_language_include */ + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_ARB_texture_buffer_range */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_ARB_texture_storage */ + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#endif /* GL_ARB_transform_feedback2 */ + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#endif /* GL_ARB_uniform_buffer_object */ + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#endif /* GL_ARB_viewport_array */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/make/stub_includes/opengl/GL/glcorearbext.h b/make/stub_includes/opengl/GL/glcorearbext.h new file mode 100644 index 000000000..8fab1ddee --- /dev/null +++ b/make/stub_includes/opengl/GL/glcorearbext.h @@ -0,0 +1,351 @@ +#ifndef __glcorearbext_h_ +#define __glcorearbext_h_ 1 + +/* +** Copyright (c) 2010 JogAmp Developer Team +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/** + * This header files contains additional extensions not covered by the + * 'official' khronos glcorearbext.h + */ + +/* + * ------------------------------------------------ + * Everything here and below was added manually + * to the version of glext.h obtained from: + * http://oss.sgi.com/projects/ogl-sample/registry/index.html + * ------------------------------------------------ + * + * Structure is: + * #ifndef GL_EXTENSION_NAME + * Add DEFINES here + * #endif + * #ifndef GL_EXTENSION_NAME + * Add TYPEDEFS here + * #endif + * #ifndef GL_EXTENSION_NAME + * #define GL_EXTENSION_NAME 1 + * #ifdef GL_GLEXT_PROTOTYPES + * Add FUNCTION DECLARATIONS here + * #endif + * FUNCTION POINTER DECLARATIONS NOT NEEDED + * #endif + */ + +/** + * 47. http://www.opengl.org/registry/specs/ARB/geometry_shader4.txt + */ +#ifndef GL_ARB_geometry_shader4 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +#ifndef GL_MAX_VARYING_COMPONENTS +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#endif +#ifndef GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#endif +#endif +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #187 +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +// #363 http://www.opengl.org/registry/specs/AMD/vertex_shader_tessellator.txt +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#endif +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD(GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD(GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #379 http://www.opengl.org/registry/specs/NV/shader_buffer_load.txt +#ifndef GL_NV_shader_buffer_load +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +#endif +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #380 http://www.opengl.org/registry/specs/NV/vertex_buffer_unified_memory.txt +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +#endif +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsEnabled( GLenum cap ); // extra requirement in core GL3 +GLAPI void APIENTRY glEnableClientState( GLenum cap ); // extra requirement in core GL3 +GLAPI void APIENTRY glDisableClientState( GLenum cap ); // extra requirement in core GL3 +GLAPI void APIENTRY glBufferAddressRangeNV(GLenum pname, GLuint index, GLuint64 address, GLsizeiptr length); +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #395 +#ifndef GL_AMD_debug_output +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +#endif +#ifndef GL_AMD_debug_output +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif + +// #401 +#ifndef GL_AMD_depth_clamp_separate +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#endif + +// #402 +#ifndef GL_EXT_texture_sRGB_decode +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#endif + +// #403 +#ifndef GL_NV_texture_multisample +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +#endif +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #404 +#ifndef GL_AMD_blend_minmax_factor +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#endif + +// #405 +#ifndef GL_AMD_sample_positions +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#endif +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#endif + +// #406 +#ifndef GL_EXT_x11_sync_object +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +#endif +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #408 +#ifndef GL_AMD_multi_draw_indirect +#endif +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #409 +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#endif + +// #410 GL_NV_path_rendering ? + +// #411 +#ifndef GL_AMD_pinned_memory +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#endif + +// #413 +#ifndef GL_AMD_stencil_operation_extended +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +#endif +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +#endif /* __glcorearbext_h_ */ + diff --git a/make/stub_includes/opengl/GL/glext.h b/make/stub_includes/opengl/GL/glext.h index 6048075f9..cba6c98fb 100644 --- a/make/stub_includes/opengl/GL/glext.h +++ b/make/stub_includes/opengl/GL/glext.h @@ -1,13 +1,13 @@ #ifndef __glext_h_ -#define __glext_h_ +#define __glext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* -** Copyright (c) 2007-2012 The Khronos Group Inc. -** +** Copyright (c) 2013 The Khronos Group Inc. +** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including @@ -15,10 +15,10 @@ extern "C" { ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are furnished to do so, subject to ** the following conditions: -** +** ** The above copyright notice and this permission notice shall be included ** in all copies or substantial portions of the Materials. -** +** ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -27,78 +27,39 @@ extern "C" { ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision$ on $Date$ +*/ -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated $Date: 2012-01-26 02:44:56 -0800 (Thu, 26 Jan 2012) $ */ -/* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 75 -/* Function declaration macros - to move into glplatform.h */ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ +/* Function declaration macros - to move into gl-platform.h */ +#include "gl-platform.h" +#include "gl-types.h" -#ifndef GL_VERSION_1_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif +#define GL_GLEXT_VERSION 20130615 -#ifndef GL_VERSION_1_2_DEPRECATED -#define GL_RESCALE_NORMAL 0x803A -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#endif +/* Generated C header for: + * API: gl + * Profile: compatibility + * Versions considered: .* + * Versions emitted: 1\.[2-9]|[234]\.[0-9] + * Default extensions included: gl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ #ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +typedef unsigned int GLenum; +typedef int GLsizei; +typedef void GLvoid; +typedef float GLfloat; +typedef int GLint; +typedef unsigned char GLboolean; #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 @@ -110,9 +71,6 @@ extern "C" { #define GL_BLEND_EQUATION 0x8009 #define GL_FUNC_SUBTRACT 0x800A #define GL_FUNC_REVERSE_SUBTRACT 0x800B -#endif - -#ifndef GL_ARB_imaging_DEPRECATED #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 @@ -177,9 +135,135 @@ extern "C" { #define GL_CONSTANT_BORDER 0x8151 #define GL_REPLICATE_BORDER 0x8153 #define GL_CONVOLUTION_BORDER_COLOR 0x8154 +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif +#endif /* GL_ARB_imaging */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #endif +#endif /* GL_VERSION_1_2 */ #ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 #define GL_TEXTURE0 0x84C0 #define GL_TEXTURE1 0x84C1 #define GL_TEXTURE2 0x84C2 @@ -239,9 +323,6 @@ extern "C" { #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 #define GL_CLAMP_TO_BORDER 0x812D -#endif - -#ifndef GL_VERSION_1_3_DEPRECATED #define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 #define GL_MAX_TEXTURE_UNITS 0x84E2 #define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 @@ -279,84 +360,270 @@ extern "C" { #define GL_PREVIOUS 0x8578 #define GL_DOT3_RGB 0x86AE #define GL_DOT3_RGBA 0x86AF -#endif - -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#endif - -#ifndef GL_VERSION_1_4_DEPRECATED -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#endif - -#ifndef GL_VERSION_1_5_DEPRECATED +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif +#endif /* GL_VERSION_1_3 */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#include +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 #define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 #define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 #define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 @@ -378,11 +645,52 @@ extern "C" { #define GL_SRC1_RGB 0x8581 #define GL_SRC2_RGB 0x8582 #define GL_SRC0_ALPHA 0x8588 -#define GL_SRC1_ALPHA 0x8589 #define GL_SRC2_ALPHA 0x858A +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid **params); #endif +#endif /* GL_VERSION_1_5 */ #ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +typedef char GLchar; #define GL_BLEND_EQUATION_RGB 0x8009 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 @@ -463,16 +771,202 @@ extern "C" { #define GL_STENCIL_BACK_REF 0x8CA3 #define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 #define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_VERSION_2_0_DEPRECATED #define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 #define GL_POINT_SPRITE 0x8861 #define GL_COORD_REPLACE 0x8862 #define GL_MAX_TEXTURE_COORDS 0x8871 +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid **pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); #endif +#endif /* GL_VERSION_2_0 */ #ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 #define GL_PIXEL_PACK_BUFFER 0x88EB #define GL_PIXEL_UNPACK_BUFFER 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED @@ -489,9 +983,6 @@ extern "C" { #define GL_SRGB8_ALPHA8 0x8C43 #define GL_COMPRESSED_SRGB 0x8C48 #define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#endif - -#ifndef GL_VERSION_2_1_DEPRECATED #define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F #define GL_SLUMINANCE_ALPHA 0x8C44 #define GL_SLUMINANCE8_ALPHA8 0x8C45 @@ -499,9 +990,24 @@ extern "C" { #define GL_SLUMINANCE8 0x8C47 #define GL_COMPRESSED_SLUMINANCE 0x8C4A #define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); #endif +#endif /* GL_VERSION_2_1 */ #ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 #define GL_COMPARE_REF_TO_TEXTURE 0x884E #define GL_CLIP_DISTANCE0 0x3000 #define GL_CLIP_DISTANCE1 0x3001 @@ -516,11 +1022,9 @@ extern "C" { #define GL_MINOR_VERSION 0x821C #define GL_NUM_EXTENSIONS 0x821D #define GL_CONTEXT_FLAGS 0x821E -#define GL_DEPTH_BUFFER 0x8223 // n/a in spec, but other header files -#define GL_STENCIL_BUFFER 0x8224 // n/a in spec, but other header files #define GL_COMPRESSED_RED 0x8225 #define GL_COMPRESSED_RG 0x8226 -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 #define GL_RGBA32F 0x8814 #define GL_RGB32F 0x8815 #define GL_RGBA16F 0x881A @@ -604,10006 +1108,4758 @@ extern "C" { #define GL_BUFFER_ACCESS_FLAGS 0x911F #define GL_BUFFER_MAP_LENGTH 0x9120 #define GL_BUFFER_MAP_OFFSET 0x9121 -/* Reuse tokens from ARB_depth_buffer_float */ -/* reuse GL_DEPTH_COMPONENT32F */ -/* reuse GL_DEPTH32F_STENCIL8 */ -/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_DEFAULT */ -/* reuse GL_FRAMEBUFFER_UNDEFINED */ -/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ -/* reuse GL_INDEX */ -/* reuse GL_MAX_RENDERBUFFER_SIZE */ -/* reuse GL_DEPTH_STENCIL */ -/* reuse GL_UNSIGNED_INT_24_8 */ -/* reuse GL_DEPTH24_STENCIL8 */ -/* reuse GL_TEXTURE_STENCIL_SIZE */ -/* reuse GL_TEXTURE_RED_TYPE */ -/* reuse GL_TEXTURE_GREEN_TYPE */ -/* reuse GL_TEXTURE_BLUE_TYPE */ -/* reuse GL_TEXTURE_ALPHA_TYPE */ -/* reuse GL_TEXTURE_DEPTH_TYPE */ -/* reuse GL_UNSIGNED_NORMALIZED */ -/* reuse GL_FRAMEBUFFER_BINDING */ -/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_BINDING */ -/* reuse GL_READ_FRAMEBUFFER */ -/* reuse GL_DRAW_FRAMEBUFFER */ -/* reuse GL_READ_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_SAMPLES */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* reuse GL_FRAMEBUFFER_COMPLETE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ -/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ -/* reuse GL_MAX_COLOR_ATTACHMENTS */ -/* reuse GL_COLOR_ATTACHMENT0 */ -/* reuse GL_COLOR_ATTACHMENT1 */ -/* reuse GL_COLOR_ATTACHMENT2 */ -/* reuse GL_COLOR_ATTACHMENT3 */ -/* reuse GL_COLOR_ATTACHMENT4 */ -/* reuse GL_COLOR_ATTACHMENT5 */ -/* reuse GL_COLOR_ATTACHMENT6 */ -/* reuse GL_COLOR_ATTACHMENT7 */ -/* reuse GL_COLOR_ATTACHMENT8 */ -/* reuse GL_COLOR_ATTACHMENT9 */ -/* reuse GL_COLOR_ATTACHMENT10 */ -/* reuse GL_COLOR_ATTACHMENT11 */ -/* reuse GL_COLOR_ATTACHMENT12 */ -/* reuse GL_COLOR_ATTACHMENT13 */ -/* reuse GL_COLOR_ATTACHMENT14 */ -/* reuse GL_COLOR_ATTACHMENT15 */ -/* reuse GL_DEPTH_ATTACHMENT */ -/* reuse GL_STENCIL_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER */ -/* reuse GL_RENDERBUFFER */ -/* reuse GL_RENDERBUFFER_WIDTH */ -/* reuse GL_RENDERBUFFER_HEIGHT */ -/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ -/* reuse GL_STENCIL_INDEX1 */ -/* reuse GL_STENCIL_INDEX4 */ -/* reuse GL_STENCIL_INDEX8 */ -/* reuse GL_STENCIL_INDEX16 */ -/* reuse GL_RENDERBUFFER_RED_SIZE */ -/* reuse GL_RENDERBUFFER_GREEN_SIZE */ -/* reuse GL_RENDERBUFFER_BLUE_SIZE */ -/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ -/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ -/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ -/* reuse GL_MAX_SAMPLES */ -/* Reuse tokens from ARB_framebuffer_sRGB */ -/* reuse GL_FRAMEBUFFER_SRGB */ -/* Reuse tokens from ARB_half_float_vertex */ -/* reuse GL_HALF_FLOAT */ -/* Reuse tokens from ARB_map_buffer_range */ -/* reuse GL_MAP_READ_BIT */ -/* reuse GL_MAP_WRITE_BIT */ -/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ -/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ -/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ -/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ -/* Reuse tokens from ARB_texture_compression_rgtc */ -/* reuse GL_COMPRESSED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_RG_RGTC2 */ -/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ -/* Reuse tokens from ARB_texture_rg */ -/* reuse GL_RG */ -/* reuse GL_RG_INTEGER */ -/* reuse GL_R8 */ -/* reuse GL_R16 */ -/* reuse GL_RG8 */ -/* reuse GL_RG16 */ -/* reuse GL_R16F */ -/* reuse GL_R32F */ -/* reuse GL_RG16F */ -/* reuse GL_RG32F */ -/* reuse GL_R8I */ -/* reuse GL_R8UI */ -/* reuse GL_R16I */ -/* reuse GL_R16UI */ -/* reuse GL_R32I */ -/* reuse GL_R32UI */ -/* reuse GL_RG8I */ -/* reuse GL_RG8UI */ -/* reuse GL_RG16I */ -/* reuse GL_RG16UI */ -/* reuse GL_RG32I */ -/* reuse GL_RG32UI */ -/* Reuse tokens from ARB_vertex_array_object */ -/* reuse GL_VERTEX_ARRAY_BINDING */ -#endif - -#ifndef GL_VERSION_3_0_DEPRECATED -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B -#define GL_ALPHA_INTEGER 0x8D97 -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_TEXTURE_LUMINANCE_TYPE */ -/* reuse GL_TEXTURE_INTENSITY_TYPE */ -#endif - -#ifndef GL_VERSION_3_1 -/* #define GL_SAMPLER_2D_RECT 0x8B63 - we use subsumed GL_ARB_texture_rectangle */ -/* #define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 - we use subsumed GL_ARB_texture_rectangle */ -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_2D_RECT 0x8DCD -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -/* Reuse all tokens from ARB_texture_buffer_object */ -/* Reuse all tokens from ARB_texture_rectangle */ -/* Reuse tokens from GL_EXT_texture_snorm */ -#define GL_PRIMITIVE_RESTART 0x8F9D -#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E -/* Reuse tokens from ARB_copy_buffer */ -/* reuse GL_COPY_READ_BUFFER */ -/* reuse GL_COPY_WRITE_BUFFER */ -/* Reuse tokens from ARB_draw_instanced (none) */ -/* Reuse tokens from ARB_uniform_buffer_object */ -/* reuse GL_UNIFORM_BUFFER */ -/* reuse GL_UNIFORM_BUFFER_BINDING */ -/* reuse GL_UNIFORM_BUFFER_START */ -/* reuse GL_UNIFORM_BUFFER_SIZE */ -/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ -/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ -/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ -/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ -/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ -/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ -/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ -/* reuse GL_UNIFORM_TYPE */ -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_INDEX */ -/* reuse GL_UNIFORM_OFFSET */ -/* reuse GL_UNIFORM_ARRAY_STRIDE */ -/* reuse GL_UNIFORM_MATRIX_STRIDE */ -/* reuse GL_UNIFORM_IS_ROW_MAJOR */ -/* reuse GL_UNIFORM_BLOCK_BINDING */ -/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ -/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_INVALID_INDEX */ -#endif - -#ifndef GL_VERSION_3_2 -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_PROGRAM_POINT_SIZE 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_CONTEXT_PROFILE_MASK 0x9126 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* Reuse tokens from ARB_depth_clamp */ -/* reuse GL_DEPTH_CLAMP */ -/* Reuse tokens from ARB_draw_elements_base_vertex (none) */ -/* Reuse tokens from ARB_fragment_coord_conventions (none) */ -/* Reuse tokens from ARB_provoking_vertex */ -/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -/* Reuse tokens from ARB_seamless_cube_map */ -/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ -/* Reuse tokens from ARB_sync */ -/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ -/* reuse GL_OBJECT_TYPE */ -/* reuse GL_SYNC_CONDITION */ -/* reuse GL_SYNC_STATUS */ -/* reuse GL_SYNC_FLAGS */ -/* reuse GL_SYNC_FENCE */ -/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ -/* reuse GL_UNSIGNALED */ -/* reuse GL_SIGNALED */ -/* reuse GL_ALREADY_SIGNALED */ -/* reuse GL_TIMEOUT_EXPIRED */ -/* reuse GL_CONDITION_SATISFIED */ -/* reuse GL_WAIT_FAILED */ -/* reuse GL_TIMEOUT_IGNORED */ -/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ -/* reuse GL_TIMEOUT_IGNORED */ -/* Reuse tokens from ARB_texture_multisample */ -/* reuse GL_SAMPLE_POSITION */ -/* reuse GL_SAMPLE_MASK */ -/* reuse GL_SAMPLE_MASK_VALUE */ -/* reuse GL_MAX_SAMPLE_MASK_WORDS */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_SAMPLES */ -/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ -/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ -/* reuse GL_MAX_INTEGER_SAMPLES */ -/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ -#endif - -#ifndef GL_VERSION_3_3 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -/* Reuse tokens from ARB_blend_func_extended */ -/* reuse GL_SRC1_COLOR */ -/* reuse GL_ONE_MINUS_SRC1_COLOR */ -/* reuse GL_ONE_MINUS_SRC1_ALPHA */ -/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */ -/* Reuse tokens from ARB_explicit_attrib_location (none) */ -/* Reuse tokens from ARB_occlusion_query2 */ -/* reuse GL_ANY_SAMPLES_PASSED */ -/* Reuse tokens from ARB_sampler_objects */ -/* reuse GL_SAMPLER_BINDING */ -/* Reuse tokens from ARB_shader_bit_encoding (none) */ -/* Reuse tokens from ARB_texture_rgb10_a2ui */ -/* reuse GL_RGB10_A2UI */ -/* Reuse tokens from ARB_texture_swizzle */ -/* reuse GL_TEXTURE_SWIZZLE_R */ -/* reuse GL_TEXTURE_SWIZZLE_G */ -/* reuse GL_TEXTURE_SWIZZLE_B */ -/* reuse GL_TEXTURE_SWIZZLE_A */ -/* reuse GL_TEXTURE_SWIZZLE_RGBA */ -/* Reuse tokens from ARB_timer_query */ -/* reuse GL_TIME_ELAPSED */ -/* reuse GL_TIMESTAMP */ -/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */ -/* reuse GL_INT_2_10_10_10_REV */ -#endif - -#ifndef GL_VERSION_4_0 -/* Reuse all tokens from ARB_sample_shading */ -/* Reuse all tokens from ARB_texture_gather */ -/* Reuse all tokens from ARB_texture_cube_map_array */ -/* Reuse tokens from ARB_texture_query_lod (none) */ -/* Reuse tokens from ARB_draw_buffers_blend (none) */ -/* Reuse tokens from ARB_draw_indirect */ -/* reuse GL_DRAW_INDIRECT_BUFFER */ -/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */ -/* Reuse tokens from ARB_gpu_shader5 */ -/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */ -/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */ -/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ -/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ -/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ -/* reuse GL_MAX_VERTEX_STREAMS */ -/* Reuse tokens from ARB_gpu_shader_fp64 */ -/* reuse GL_DOUBLE_VEC2 */ -/* reuse GL_DOUBLE_VEC3 */ -/* reuse GL_DOUBLE_VEC4 */ -/* reuse GL_DOUBLE_MAT2 */ -/* reuse GL_DOUBLE_MAT3 */ -/* reuse GL_DOUBLE_MAT4 */ -/* reuse GL_DOUBLE_MAT2x3 */ -/* reuse GL_DOUBLE_MAT2x4 */ -/* reuse GL_DOUBLE_MAT3x2 */ -/* reuse GL_DOUBLE_MAT3x4 */ -/* reuse GL_DOUBLE_MAT4x2 */ -/* reuse GL_DOUBLE_MAT4x3 */ -/* Reuse tokens from ARB_shader_subroutine */ -/* reuse GL_ACTIVE_SUBROUTINES */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */ -/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */ -/* reuse GL_MAX_SUBROUTINES */ -/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */ -/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ -/* reuse GL_COMPATIBLE_SUBROUTINES */ -/* Reuse tokens from ARB_tessellation_shader */ -/* reuse GL_PATCHES */ -/* reuse GL_PATCH_VERTICES */ -/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */ -/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */ -/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */ -/* reuse GL_TESS_GEN_MODE */ -/* reuse GL_TESS_GEN_SPACING */ -/* reuse GL_TESS_GEN_VERTEX_ORDER */ -/* reuse GL_TESS_GEN_POINT_MODE */ -/* reuse GL_ISOLINES */ -/* reuse GL_FRACTIONAL_ODD */ -/* reuse GL_FRACTIONAL_EVEN */ -/* reuse GL_MAX_PATCH_VERTICES */ -/* reuse GL_MAX_TESS_GEN_LEVEL */ -/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_PATCH_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */ -/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */ -/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */ -/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_TESS_EVALUATION_SHADER */ -/* reuse GL_TESS_CONTROL_SHADER */ -/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */ -/* Reuse tokens from ARB_transform_feedback2 */ -/* reuse GL_TRANSFORM_FEEDBACK */ -/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ -/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ -/* reuse GL_TRANSFORM_FEEDBACK_BINDING */ -/* Reuse tokens from ARB_transform_feedback3 */ -/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */ -/* reuse GL_MAX_VERTEX_STREAMS */ -#endif - -#ifndef GL_VERSION_4_1 -/* Reuse tokens from ARB_ES2_compatibility */ -/* reuse GL_FIXED */ -/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */ -/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */ -/* reuse GL_LOW_FLOAT */ -/* reuse GL_MEDIUM_FLOAT */ -/* reuse GL_HIGH_FLOAT */ -/* reuse GL_LOW_INT */ -/* reuse GL_MEDIUM_INT */ -/* reuse GL_HIGH_INT */ -/* reuse GL_SHADER_COMPILER */ -/* reuse GL_NUM_SHADER_BINARY_FORMATS */ -/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ -/* reuse GL_MAX_VARYING_VECTORS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ -/* Reuse tokens from ARB_get_program_binary */ -/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ -/* reuse GL_PROGRAM_BINARY_LENGTH */ -/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */ -/* reuse GL_PROGRAM_BINARY_FORMATS */ -/* Reuse tokens from ARB_separate_shader_objects */ -/* reuse GL_VERTEX_SHADER_BIT */ -/* reuse GL_FRAGMENT_SHADER_BIT */ -/* reuse GL_GEOMETRY_SHADER_BIT */ -/* reuse GL_TESS_CONTROL_SHADER_BIT */ -/* reuse GL_TESS_EVALUATION_SHADER_BIT */ -/* reuse GL_ALL_SHADER_BITS */ -/* reuse GL_PROGRAM_SEPARABLE */ -/* reuse GL_ACTIVE_PROGRAM */ -/* reuse GL_PROGRAM_PIPELINE_BINDING */ -/* Reuse tokens from ARB_shader_precision (none) */ -/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */ -/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */ -/* reuse GL_MAX_VIEWPORTS */ -/* reuse GL_VIEWPORT_SUBPIXEL_BITS */ -/* reuse GL_VIEWPORT_BOUNDS_RANGE */ -/* reuse GL_LAYER_PROVOKING_VERTEX */ -/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */ -/* reuse GL_UNDEFINED_VERTEX */ -#endif - -#ifndef GL_VERSION_4_2 -/* Reuse tokens from ARB_base_instance (none) */ -/* Reuse tokens from ARB_shading_language_420pack (none) */ -/* Reuse tokens from ARB_transform_feedback_instanced (none) */ -/* Reuse tokens from ARB_compressed_texture_pixel_storage */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */ -/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */ -/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */ -/* Reuse tokens from ARB_conservative_depth (none) */ -/* Reuse tokens from ARB_internalformat_query */ -/* reuse GL_NUM_SAMPLE_COUNTS */ -/* Reuse tokens from ARB_map_buffer_alignment */ -/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */ -/* Reuse tokens from ARB_shader_atomic_counters */ -/* reuse GL_ATOMIC_COUNTER_BUFFER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_START */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */ -/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */ -/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */ -/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */ -/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */ -/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */ -/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */ -/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */ -/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */ -/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */ -/* Reuse tokens from ARB_shader_image_load_store */ -/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */ -/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */ -/* reuse GL_UNIFORM_BARRIER_BIT */ -/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */ -/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */ -/* reuse GL_COMMAND_BARRIER_BIT */ -/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */ -/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */ -/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */ -/* reuse GL_FRAMEBUFFER_BARRIER_BIT */ -/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */ -/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */ -/* reuse GL_ALL_BARRIER_BITS */ -/* reuse GL_MAX_IMAGE_UNITS */ -/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ -/* reuse GL_IMAGE_BINDING_NAME */ -/* reuse GL_IMAGE_BINDING_LEVEL */ -/* reuse GL_IMAGE_BINDING_LAYERED */ -/* reuse GL_IMAGE_BINDING_LAYER */ -/* reuse GL_IMAGE_BINDING_ACCESS */ -/* reuse GL_IMAGE_1D */ -/* reuse GL_IMAGE_2D */ -/* reuse GL_IMAGE_3D */ -/* reuse GL_IMAGE_2D_RECT */ -/* reuse GL_IMAGE_CUBE */ -/* reuse GL_IMAGE_BUFFER */ -/* reuse GL_IMAGE_1D_ARRAY */ -/* reuse GL_IMAGE_2D_ARRAY */ -/* reuse GL_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_IMAGE_1D */ -/* reuse GL_INT_IMAGE_2D */ -/* reuse GL_INT_IMAGE_3D */ -/* reuse GL_INT_IMAGE_2D_RECT */ -/* reuse GL_INT_IMAGE_CUBE */ -/* reuse GL_INT_IMAGE_BUFFER */ -/* reuse GL_INT_IMAGE_1D_ARRAY */ -/* reuse GL_INT_IMAGE_2D_ARRAY */ -/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_1D */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D */ -/* reuse GL_UNSIGNED_INT_IMAGE_3D */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */ -/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */ -/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */ -/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_IMAGE_SAMPLES */ -/* reuse GL_IMAGE_BINDING_FORMAT */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */ -/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */ -/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */ -/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */ -/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */ -/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */ -/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */ -/* Reuse tokens from ARB_shading_language_packing (none) */ -/* Reuse tokens from ARB_texture_storage */ -/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ -#endif - -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#endif - -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif - -#ifndef GL_ARB_texture_env_add -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -#ifndef GL_ARB_texture_compression -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif - -#ifndef GL_ARB_point_parameters -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - -#ifndef GL_ARB_shadow -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif - -#ifndef GL_ARB_window_pos -#endif - -#ifndef GL_ARB_vertex_program -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif - -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#endif - -#ifndef GL_ARB_point_sprite -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -#ifndef GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#endif - -#ifndef GL_ARB_draw_instanced -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#endif - -#ifndef GL_ARB_framebuffer_object_DEPRECATED -#define GL_INDEX 0x8222 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#endif - -#ifndef GL_ARB_geometry_shader4 -#define GL_LINES_ADJACENCY_ARB 0x000A -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B -#define GL_TRIANGLES_ADJACENCY_ARB 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_HALF_FLOAT 0x140B -#endif - -#ifndef GL_ARB_instanced_arrays -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#endif - -#ifndef GL_ARB_texture_rg -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -/* #define GL_INVALID_INDEX 0xFFFFFFFFu - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#endif - -#ifndef GL_ARB_compatibility -/* ARB_compatibility just defines tokens from core 3.0 */ -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#endif - -#ifndef GL_ARB_shader_texture_lod -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_DEPTH_CLAMP 0x864F -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#endif - -#ifndef GL_ARB_sync -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 -#endif - -#ifndef GL_ARB_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_ARB_draw_buffers_blend -#endif - -#ifndef GL_ARB_sample_shading -#define GL_SAMPLE_SHADING_ARB 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F -#endif - -#ifndef GL_ARB_texture_gather -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F -#endif - -#ifndef GL_ARB_texture_query_lod -#endif - -#ifndef GL_ARB_shading_language_include -#define GL_SHADER_INCLUDE_ARB 0x8DAE -#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 -#define GL_NAMED_STRING_TYPE_ARB 0x8DEA -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F -#endif - -#ifndef GL_ARB_blend_func_extended -#define GL_SRC1_COLOR 0x88F9 -/* reuse GL_SRC1_ALPHA */ -#define GL_ONE_MINUS_SRC1_COLOR 0x88FA -#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB -#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC -#endif - -#ifndef GL_ARB_explicit_attrib_location -#endif - -#ifndef GL_ARB_occlusion_query2 -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#endif - -#ifndef GL_ARB_sampler_objects -#define GL_SAMPLER_BINDING 0x8919 -#endif - -#ifndef GL_ARB_shader_bit_encoding -#endif - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_RGB10_A2UI 0x906F -#endif - -#ifndef GL_ARB_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R 0x8E42 -#define GL_TEXTURE_SWIZZLE_G 0x8E43 -#define GL_TEXTURE_SWIZZLE_B 0x8E44 -#define GL_TEXTURE_SWIZZLE_A 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 -#endif - -#ifndef GL_ARB_timer_query -#define GL_TIME_ELAPSED 0x88BF -#define GL_TIMESTAMP 0x8E28 -#endif - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */ -#define GL_INT_2_10_10_10_REV 0x8D9F -#endif - -#ifndef GL_ARB_draw_indirect -#define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 -#endif - -#ifndef GL_ARB_gpu_shader5 -#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C -#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D -/* reuse GL_MAX_VERTEX_STREAMS */ -#endif - -#ifndef GL_ARB_gpu_shader_fp64 -/* reuse GL_DOUBLE */ -#define GL_DOUBLE_VEC2 0x8FFC -#define GL_DOUBLE_VEC3 0x8FFD -#define GL_DOUBLE_VEC4 0x8FFE -#define GL_DOUBLE_MAT2 0x8F46 -#define GL_DOUBLE_MAT3 0x8F47 -#define GL_DOUBLE_MAT4 0x8F48 -#define GL_DOUBLE_MAT2x3 0x8F49 -#define GL_DOUBLE_MAT2x4 0x8F4A -#define GL_DOUBLE_MAT3x2 0x8F4B -#define GL_DOUBLE_MAT3x4 0x8F4C -#define GL_DOUBLE_MAT4x2 0x8F4D -#define GL_DOUBLE_MAT4x3 0x8F4E -#endif - -#ifndef GL_ARB_shader_subroutine -#define GL_ACTIVE_SUBROUTINES 0x8DE5 -#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 -#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 -#define GL_MAX_SUBROUTINES 0x8DE7 -#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 -#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A -#define GL_COMPATIBLE_SUBROUTINES 0x8E4B -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -#endif - -#ifndef GL_ARB_tessellation_shader -#define GL_PATCHES 0x000E -#define GL_PATCH_VERTICES 0x8E72 -#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 -#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 -#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 -#define GL_TESS_GEN_MODE 0x8E76 -#define GL_TESS_GEN_SPACING 0x8E77 -#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 -#define GL_TESS_GEN_POINT_MODE 0x8E79 -/* reuse GL_TRIANGLES */ -/* reuse GL_QUADS */ -#define GL_ISOLINES 0x8E7A -/* reuse GL_EQUAL */ -#define GL_FRACTIONAL_ODD 0x8E7B -#define GL_FRACTIONAL_EVEN 0x8E7C -/* reuse GL_CCW */ -/* reuse GL_CW */ -#define GL_MAX_PATCH_VERTICES 0x8E7D -#define GL_MAX_TESS_GEN_LEVEL 0x8E7E -#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F -#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 -#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 -#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 -#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 -#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 -#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 -#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 -#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 -#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A -#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C -#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D -#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E -#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 -#define GL_TESS_EVALUATION_SHADER 0x8E87 -#define GL_TESS_CONTROL_SHADER 0x8E88 -#endif - -#ifndef GL_ARB_texture_buffer_object_rgb32 -/* reuse GL_RGB32F */ -/* reuse GL_RGB32UI */ -/* reuse GL_RGB32I */ -#endif - -#ifndef GL_ARB_transform_feedback2 -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#endif - -#ifndef GL_ARB_transform_feedback3 -#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 -#define GL_MAX_VERTEX_STREAMS 0x8E71 -#endif - -#ifndef GL_ARB_ES2_compatibility -#define GL_FIXED 0x140C -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#endif - -#ifndef GL_ARB_get_program_binary -#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -#define GL_PROGRAM_BINARY_LENGTH 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE -#define GL_PROGRAM_BINARY_FORMATS 0x87FF -#endif - -#ifndef GL_ARB_separate_shader_objects -#define GL_VERTEX_SHADER_BIT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#define GL_GEOMETRY_SHADER_BIT 0x00000004 -#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -/* #define GL_ALL_SHADER_BITS 0xFFFFFFFF - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#define GL_PROGRAM_SEPARABLE 0x8258 -#define GL_ACTIVE_PROGRAM 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING 0x825A -#endif - -#ifndef GL_ARB_shader_precision -#endif - -#ifndef GL_ARB_vertex_attrib_64bit -/* reuse GL_RGB32I */ -/* reuse GL_DOUBLE_VEC2 */ -/* reuse GL_DOUBLE_VEC3 */ -/* reuse GL_DOUBLE_VEC4 */ -/* reuse GL_DOUBLE_MAT2 */ -/* reuse GL_DOUBLE_MAT3 */ -/* reuse GL_DOUBLE_MAT4 */ -/* reuse GL_DOUBLE_MAT2x3 */ -/* reuse GL_DOUBLE_MAT2x4 */ -/* reuse GL_DOUBLE_MAT3x2 */ -/* reuse GL_DOUBLE_MAT3x4 */ -/* reuse GL_DOUBLE_MAT4x2 */ -/* reuse GL_DOUBLE_MAT4x3 */ -#endif - -#ifndef GL_ARB_viewport_array -/* reuse GL_SCISSOR_BOX */ -/* reuse GL_VIEWPORT */ -/* reuse GL_DEPTH_RANGE */ -/* reuse GL_SCISSOR_TEST */ -#define GL_MAX_VIEWPORTS 0x825B -#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C -#define GL_VIEWPORT_BOUNDS_RANGE 0x825D -#define GL_LAYER_PROVOKING_VERTEX 0x825E -#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F -#define GL_UNDEFINED_VERTEX 0x8260 -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -#endif - -#ifndef GL_ARB_cl_event -#define GL_SYNC_CL_EVENT_ARB 0x8240 -#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 -#endif - -#ifndef GL_ARB_debug_output -#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 -#define GL_DEBUG_SOURCE_API_ARB 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A -#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B -#define GL_DEBUG_TYPE_ERROR_ARB 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E -#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 -#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 -#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 -#endif - -#ifndef GL_ARB_robustness -/* reuse GL_NO_ERROR */ -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 -#endif - -#ifndef GL_ARB_shader_stencil_export -#endif - -#ifndef GL_ARB_base_instance -#endif - -#ifndef GL_ARB_shading_language_420pack -#endif - -#ifndef GL_ARB_transform_feedback_instanced -#endif - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 -#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 -#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 -#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A -#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B -#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C -#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D -#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E -#endif - -#ifndef GL_ARB_conservative_depth -#endif - -#ifndef GL_ARB_internalformat_query -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#endif - -#ifndef GL_ARB_map_buffer_alignment -#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC -#endif - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 -#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB -#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF -#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 -#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 -#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 -#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 -#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC -#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 -#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA -#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#endif - -#ifndef GL_ARB_shader_image_load_store -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 -#define GL_COMMAND_BARRIER_BIT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 -/* #define GL_ALL_BARRIER_BITS 0xFFFFFFFF - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#define GL_MAX_IMAGE_UNITS 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 -#define GL_IMAGE_BINDING_NAME 0x8F3A -#define GL_IMAGE_BINDING_LEVEL 0x8F3B -#define GL_IMAGE_BINDING_LAYERED 0x8F3C -#define GL_IMAGE_BINDING_LAYER 0x8F3D -#define GL_IMAGE_BINDING_ACCESS 0x8F3E -#define GL_IMAGE_1D 0x904C -#define GL_IMAGE_2D 0x904D -#define GL_IMAGE_3D 0x904E -#define GL_IMAGE_2D_RECT 0x904F -#define GL_IMAGE_CUBE 0x9050 -#define GL_IMAGE_BUFFER 0x9051 -#define GL_IMAGE_1D_ARRAY 0x9052 -#define GL_IMAGE_2D_ARRAY 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 -#define GL_INT_IMAGE_1D 0x9057 -#define GL_INT_IMAGE_2D 0x9058 -#define GL_INT_IMAGE_3D 0x9059 -#define GL_INT_IMAGE_2D_RECT 0x905A -#define GL_INT_IMAGE_CUBE 0x905B -#define GL_INT_IMAGE_BUFFER 0x905C -#define GL_INT_IMAGE_1D_ARRAY 0x905D -#define GL_INT_IMAGE_2D_ARRAY 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C -#define GL_MAX_IMAGE_SAMPLES 0x906D -#define GL_IMAGE_BINDING_FORMAT 0x906E -#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 -#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD -#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#endif - -#ifndef GL_ARB_shading_language_packing -#endif - -#ifndef GL_ARB_texture_storage -#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F -#endif - -#ifndef GL_EXT_abgr -#define GL_ABGR_EXT 0x8000 -#endif - -#ifndef GL_EXT_blend_color -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#endif - -#ifndef GL_EXT_texture -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif - -#ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -#endif - -#ifndef GL_EXT_subtexture -#endif - -#ifndef GL_EXT_copy_texture -#endif - -#ifndef GL_EXT_histogram -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#endif - -#ifndef GL_EXT_convolution -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#endif - -#ifndef GL_SGI_color_matrix -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif - -#ifndef GL_SGI_color_table -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#endif - -#ifndef GL_SGIS_texture4D -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif - -#ifndef GL_EXT_cmyka -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif - -#ifndef GL_EXT_texture_object -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif - -#ifndef GL_SGIS_multisample -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif - -#ifndef GL_EXT_vertex_array -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#endif - -#ifndef GL_EXT_misc_attribute -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif - -#ifndef GL_SGIX_shadow -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif - -#ifndef GL_EXT_blend_logic_op -#endif - -#ifndef GL_SGIX_interlace -#define GL_INTERLACE_SGIX 0x8094 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif - -#ifndef GL_SGIS_texture_select -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif - -#ifndef GL_EXT_point_parameters -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#endif - -#ifndef GL_SGIX_instruments -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif - -#ifndef GL_SGIX_framezoom -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#endif - -#ifndef GL_FfdMaskSGIX -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#endif - -#ifndef GL_SGIX_flush_raster -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif - -#ifndef GL_HP_image_transform -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif - -#ifndef GL_INGR_palette_buffer -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif - -#ifndef GL_EXT_color_subtable -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_LIST_PRIORITY_SGIX 0x8182 -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif - -#ifndef GL_EXT_index_texture -#endif - -#ifndef GL_EXT_index_material -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#endif - -#ifndef GL_EXT_index_func -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#endif - -#ifndef GL_WIN_phong_shading -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif - -#ifndef GL_WIN_specular_fog -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif - -#ifndef GL_EXT_light_texture -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -/* reuse GL_FRAGMENT_DEPTH_EXT */ -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif - -#ifndef GL_SGIX_impact_pixel_texture -#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#endif - -#ifndef GL_EXT_bgra -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif - -#ifndef GL_SGIX_async -#define GL_ASYNC_MARKER_SGIX 0x8329 -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif - -#ifndef GL_INTEL_texture_scissor -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#endif - -#ifndef GL_HP_occlusion_test -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_EXT_secondary_color -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -#endif - -#ifndef GL_EXT_multi_draw_arrays -#endif - -#ifndef GL_EXT_fog_coord -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_FOG_SCALE_SGIX 0x81FC -#define GL_FOG_SCALE_VALUE_SGIX 0x81FD -#endif - -#ifndef GL_SUNX_constant_data -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#endif - -#ifndef GL_SUN_global_alpha -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#endif - -#ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#endif - -#ifndef GL_SUN_vertex -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif - -#ifndef GL_INGR_color_clamp -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INTERLACE_READ_INGR 0x8568 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif - -#ifndef GL_EXT_texture_cube_map -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif - -#ifndef GL_EXT_texture_env_add -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT GL_MODELVIEW -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#endif - -#ifndef GL_NV_register_combiners -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -/* reuse GL_TEXTURE0_ARB */ -/* reuse GL_TEXTURE1_ARB */ -/* reuse GL_ZERO */ -/* reuse GL_NONE */ -/* reuse GL_FOG */ -#endif - -#ifndef GL_NV_fog_distance -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -/* reuse GL_EYE_PLANE */ -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif - -#ifndef GL_NV_blend_square -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif - -#ifndef GL_MESA_resize_buffers -#endif - -#ifndef GL_MESA_window_pos -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_CULL_VERTEX_IBM 103050 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#endif - -#ifndef GL_SGIX_subsample -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif - -#ifndef GL_SGI_depth_pass_instrument -#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif - -#ifndef GL_3DFX_tbuffer -#endif - -#ifndef GL_EXT_multisample -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif - -#ifndef GL_SGIX_resample -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif - -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -#ifndef GL_NV_evaluators -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -#endif - -#ifndef GL_NV_texture_compression_vtc -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif - -#ifndef GL_NV_texture_shader -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif - -#ifndef GL_NV_vertex_program -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif - -#ifndef GL_OML_interlace -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif - -#ifndef GL_OML_subsample -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif - -#ifndef GL_OML_resample -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -#endif - -#ifndef GL_ATI_element_array -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#endif - -#ifndef GL_SUN_mesh_array -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -#ifndef GL_NV_occlusion_query -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif - -#ifndef GL_NV_point_sprite -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif - -#ifndef GL_NV_vertex_program1_1 -#endif - -#ifndef GL_EXT_shadow_funcs -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif - -#ifndef GL_APPLE_element_array -#define GL_ELEMENT_ARRAY_APPLE 0x8A0C -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E -#endif - -#ifndef GL_APPLE_fence -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CLIENT_APPLE 0x85B4 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -#ifndef GL_S3_s3tc -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif - -#ifndef GL_ATI_texture_float -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif - -#ifndef GL_NV_float_buffer -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif - -#ifndef GL_NV_fragment_program -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -#endif - -#ifndef GL_NV_half_float -#define GL_HALF_FLOAT_NV 0x140B -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#endif - -#ifndef GL_NV_primitive_restart -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif - -#ifndef GL_NV_vertex_program2 -#endif - -#ifndef GL_ATI_map_object_buffer -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#endif - -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT 0x8009 -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#endif - -#ifndef GL_MESA_pack_invert -#define GL_PACK_INVERT_MESA 0x8758 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif - -#ifndef GL_NV_fragment_program_option -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif - -#ifndef GL_NV_vertex_program2_option -/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ -/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ -#endif - -#ifndef GL_NV_vertex_program3 -/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#endif - -#ifndef GL_GREMEDY_string_marker -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#endif - -#ifndef GL_EXT_stencil_clear_tag -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 -#endif - -#ifndef GL_EXT_texture_sRGB -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E -#endif - -#ifndef GL_EXT_timer_query -#define GL_TIME_ELAPSED_EXT 0x88BF -#endif - -#ifndef GL_EXT_gpu_program_parameters -#endif - -#ifndef GL_APPLE_flush_buffer_range -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -#endif - -#ifndef GL_NV_gpu_program4 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 -#endif - -#ifndef GL_NV_geometry_program4 -#define GL_LINES_ADJACENCY_EXT 0x000A -#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B -#define GL_TRIANGLES_ADJACENCY_EXT 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -#endif - -#ifndef GL_EXT_geometry_shader4 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ -/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ -/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ -/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 -/* reuse GL_LINES_ADJACENCY_EXT */ -/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ -/* reuse GL_TRIANGLES_ADJACENCY_EXT */ -/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -/* reuse GL_PROGRAM_POINT_SIZE_EXT */ -#endif - -#ifndef GL_NV_vertex_program4 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD -#endif - -#ifndef GL_EXT_gpu_shader4 -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 -#endif - -#ifndef GL_EXT_draw_instanced -#endif - -#ifndef GL_EXT_packed_float -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C -#endif - -#ifndef GL_EXT_texture_array -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -#endif - -#ifndef GL_EXT_texture_buffer_object -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E -#endif - -#ifndef GL_EXT_texture_compression_latc -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 -#endif - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE -#endif - -#ifndef GL_EXT_texture_shared_exponent -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F -#endif - -#ifndef GL_NV_depth_buffer_float -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF -#endif - -#ifndef GL_NV_fragment_program4 -#endif - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#endif - -#ifndef GL_NV_geometry_shader4 -#endif - -#ifndef GL_NV_parameter_buffer_object -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 -#endif - -#ifndef GL_EXT_draw_buffers2 -#endif - -#ifndef GL_NV_transform_feedback -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F -#define GL_LAYER_NV 0x8DAA -#define GL_NEXT_BUFFER_NV -2 -#define GL_SKIP_COMPONENTS4_NV -3 -#define GL_SKIP_COMPONENTS3_NV -4 -#define GL_SKIP_COMPONENTS2_NV -5 -#define GL_SKIP_COMPONENTS1_NV -6 -#endif - -#ifndef GL_EXT_bindable_uniform -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF -#endif - -#ifndef GL_EXT_texture_integer -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E -#endif - -#ifndef GL_GREMEDY_frame_terminator -#endif - -#ifndef GL_NV_conditional_render -#define GL_QUERY_WAIT_NV 0x8E13 -#define GL_QUERY_NO_WAIT_NV 0x8E14 -#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 -#endif - -#ifndef GL_NV_present_video -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B -#endif - -#ifndef GL_EXT_transform_feedback -#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F -#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -#endif - -#ifndef GL_EXT_direct_state_access -#define GL_PROGRAM_MATRIX_EXT 0x8E2D -#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F -#endif - -#ifndef GL_EXT_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_EXT_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 -#endif - -#ifndef GL_NV_explicit_multisample -#define GL_SAMPLE_POSITION_NV 0x8E50 -#define GL_SAMPLE_MASK_NV 0x8E51 -#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 -#endif - -#ifndef GL_NV_transform_feedback2 -#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 -#endif - -#ifndef GL_ATI_meminfo -#define GL_VBO_FREE_MEMORY_ATI 0x87FB -#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC -#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD -#endif - -#ifndef GL_AMD_performance_monitor -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 -#endif - -#ifndef GL_AMD_texture_texture4 -#endif - -#ifndef GL_AMD_vertex_shader_tesselator -#define GL_SAMPLER_BUFFER_AMD 0x9001 -#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define GL_TESSELLATION_MODE_AMD 0x9004 -#define GL_TESSELLATION_FACTOR_AMD 0x9005 -#define GL_DISCRETE_AMD 0x9006 -#define GL_CONTINUOUS_AMD 0x9007 -#endif - -#ifndef GL_EXT_provoking_vertex -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D -#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E -#define GL_PROVOKING_VERTEX_EXT 0x8E4F -#endif - -#ifndef GL_EXT_texture_snorm -#define GL_ALPHA_SNORM 0x9010 -#define GL_LUMINANCE_SNORM 0x9011 -#define GL_LUMINANCE_ALPHA_SNORM 0x9012 -#define GL_INTENSITY_SNORM 0x9013 -#define GL_ALPHA8_SNORM 0x9014 -#define GL_LUMINANCE8_SNORM 0x9015 -#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 -#define GL_INTENSITY8_SNORM 0x9017 -#define GL_ALPHA16_SNORM 0x9018 -#define GL_LUMINANCE16_SNORM 0x9019 -#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A -#define GL_INTENSITY16_SNORM 0x901B -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#endif - -#ifndef GL_AMD_draw_buffers_blend -#endif - -#ifndef GL_APPLE_texture_range -#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 -#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#define GL_STORAGE_PRIVATE_APPLE 0x85BD -/* reuse GL_STORAGE_CACHED_APPLE */ -/* reuse GL_STORAGE_SHARED_APPLE */ -#endif - -#ifndef GL_APPLE_float_pixels -#define GL_HALF_APPLE 0x140B -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#define GL_COLOR_FLOAT_APPLE 0x8A0F -#endif - -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 -#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 -#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 -#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 -#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 -#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 -#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 -#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 -#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 -#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 -#endif - -#ifndef GL_APPLE_aux_depth_stencil -#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 -#endif - -#ifndef GL_APPLE_object_purgeable -#define GL_BUFFER_OBJECT_APPLE 0x85B3 -#define GL_RELEASED_APPLE 0x8A19 -#define GL_VOLATILE_APPLE 0x8A1A -#define GL_RETAINED_APPLE 0x8A1B -#define GL_UNDEFINED_APPLE 0x8A1C -#define GL_PURGEABLE_APPLE 0x8A1D -#endif - -#ifndef GL_APPLE_row_bytes -#define GL_PACK_ROW_BYTES_APPLE 0x8A15 -#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 -#endif - -#ifndef GL_APPLE_rgb_422 -#define GL_RGB_422_APPLE 0x8A1F -/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */ -/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */ -#endif - -#ifndef GL_NV_video_capture -#define GL_VIDEO_BUFFER_NV 0x9020 -#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 -#define GL_FIELD_UPPER_NV 0x9022 -#define GL_FIELD_LOWER_NV 0x9023 -#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 -#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 -#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 -#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 -#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 -#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 -#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A -#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B -#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C -#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D -#define GL_PARTIAL_SUCCESS_NV 0x902E -#define GL_SUCCESS_NV 0x902F -#define GL_FAILURE_NV 0x9030 -#define GL_YCBYCR8_422_NV 0x9031 -#define GL_YCBAYCR8A_4224_NV 0x9032 -#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 -#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 -#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 -#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 -#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 -#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 -#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 -#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A -#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B -#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C -#endif - -#ifndef GL_NV_copy_image -#endif - -#ifndef GL_EXT_separate_shader_objects -#define GL_ACTIVE_PROGRAM_EXT 0x8B8D -#endif - -#ifndef GL_NV_parameter_buffer_object2 -#endif - -#ifndef GL_NV_shader_buffer_load -#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D -#define GL_GPU_ADDRESS_NV 0x8F34 -#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 -#endif - -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E -#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F -#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 -#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 -#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 -#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 -#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 -#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 -#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 -#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 -#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 -#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 -#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A -#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B -#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C -#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D -#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E -#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F -#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 -#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 -#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 -#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 -#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 -#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 -#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 -#endif - -#ifndef GL_NV_texture_barrier -#endif - -#ifndef GL_AMD_shader_stencil_export -#endif - -#ifndef GL_AMD_seamless_cubemap_per_texture -/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS_ARB */ -#endif - -#ifndef GL_AMD_conservative_depth -#endif - -#ifndef GL_EXT_shader_image_load_store -#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 -#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A -#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B -#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C -#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D -#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E -#define GL_IMAGE_1D_EXT 0x904C -#define GL_IMAGE_2D_EXT 0x904D -#define GL_IMAGE_3D_EXT 0x904E -#define GL_IMAGE_2D_RECT_EXT 0x904F -#define GL_IMAGE_CUBE_EXT 0x9050 -#define GL_IMAGE_BUFFER_EXT 0x9051 -#define GL_IMAGE_1D_ARRAY_EXT 0x9052 -#define GL_IMAGE_2D_ARRAY_EXT 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 -#define GL_INT_IMAGE_1D_EXT 0x9057 -#define GL_INT_IMAGE_2D_EXT 0x9058 -#define GL_INT_IMAGE_3D_EXT 0x9059 -#define GL_INT_IMAGE_2D_RECT_EXT 0x905A -#define GL_INT_IMAGE_CUBE_EXT 0x905B -#define GL_INT_IMAGE_BUFFER_EXT 0x905C -#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D -#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C -#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D -#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 -#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 -/* #define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#endif - -#ifndef GL_EXT_vertex_attrib_64bit -/* reuse GL_DOUBLE */ -#define GL_DOUBLE_VEC2_EXT 0x8FFC -#define GL_DOUBLE_VEC3_EXT 0x8FFD -#define GL_DOUBLE_VEC4_EXT 0x8FFE -#define GL_DOUBLE_MAT2_EXT 0x8F46 -#define GL_DOUBLE_MAT3_EXT 0x8F47 -#define GL_DOUBLE_MAT4_EXT 0x8F48 -#define GL_DOUBLE_MAT2x3_EXT 0x8F49 -#define GL_DOUBLE_MAT2x4_EXT 0x8F4A -#define GL_DOUBLE_MAT3x2_EXT 0x8F4B -#define GL_DOUBLE_MAT3x4_EXT 0x8F4C -#define GL_DOUBLE_MAT4x2_EXT 0x8F4D -#define GL_DOUBLE_MAT4x3_EXT 0x8F4E -#endif - -#ifndef GL_NV_gpu_program5 -#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C -#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F -#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 -#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 -#endif - -#ifndef GL_NV_gpu_shader5 -#define GL_INT64_NV 0x140E -#define GL_UNSIGNED_INT64_NV 0x140F -#define GL_INT8_NV 0x8FE0 -#define GL_INT8_VEC2_NV 0x8FE1 -#define GL_INT8_VEC3_NV 0x8FE2 -#define GL_INT8_VEC4_NV 0x8FE3 -#define GL_INT16_NV 0x8FE4 -#define GL_INT16_VEC2_NV 0x8FE5 -#define GL_INT16_VEC3_NV 0x8FE6 -#define GL_INT16_VEC4_NV 0x8FE7 -#define GL_INT64_VEC2_NV 0x8FE9 -#define GL_INT64_VEC3_NV 0x8FEA -#define GL_INT64_VEC4_NV 0x8FEB -#define GL_UNSIGNED_INT8_NV 0x8FEC -#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED -#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE -#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF -#define GL_UNSIGNED_INT16_NV 0x8FF0 -#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 -#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 -#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 -#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 -#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 -#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 -#define GL_FLOAT16_NV 0x8FF8 -#define GL_FLOAT16_VEC2_NV 0x8FF9 -#define GL_FLOAT16_VEC3_NV 0x8FFA -#define GL_FLOAT16_VEC4_NV 0x8FFB -/* reuse GL_PATCHES */ -#endif - -#ifndef GL_NV_shader_buffer_store -#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 -/* reuse GL_READ_WRITE */ -/* reuse GL_WRITE_ONLY */ -#endif - -#ifndef GL_NV_tessellation_program5 -#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 -#define GL_TESS_CONTROL_PROGRAM_NV 0x891E -#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F -#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 -#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 -#endif - -#ifndef GL_NV_vertex_attrib_integer_64bit -/* reuse GL_INT64_NV */ -/* reuse GL_UNSIGNED_INT64_NV */ -#endif - -#ifndef GL_NV_multisample_coverage -#define GL_COVERAGE_SAMPLES_NV 0x80A9 -#define GL_COLOR_SAMPLES_NV 0x8E20 -#endif - -#ifndef GL_AMD_name_gen_delete -#define GL_DATA_BUFFER_AMD 0x9151 -#define GL_PERFORMANCE_MONITOR_AMD 0x9152 -#define GL_QUERY_OBJECT_AMD 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 -#define GL_SAMPLER_OBJECT_AMD 0x9155 -#endif - -#ifndef GL_AMD_debug_output -#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 -#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 -#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 -#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A -#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B -#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C -#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D -#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E -#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F -#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 -#endif - -#ifndef GL_NV_vdpau_interop -#define GL_SURFACE_STATE_NV 0x86EB -#define GL_SURFACE_REGISTERED_NV 0x86FD -#define GL_SURFACE_MAPPED_NV 0x8700 -#define GL_WRITE_DISCARD_NV 0x88BE -#endif - -#ifndef GL_AMD_transform_feedback3_lines_triangles -#endif - -#ifndef GL_AMD_depth_clamp_separate -#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E -#define GL_DEPTH_CLAMP_FAR_AMD 0x901F -#endif - -#ifndef GL_EXT_texture_sRGB_decode -#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 -#define GL_DECODE_EXT 0x8A49 -#define GL_SKIP_DECODE_EXT 0x8A4A -#endif - -#ifndef GL_NV_texture_multisample -#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 -#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 -#endif - -#ifndef GL_AMD_blend_minmax_factor -#define GL_FACTOR_MIN_AMD 0x901C -#define GL_FACTOR_MAX_AMD 0x901D -#endif - -#ifndef GL_AMD_sample_positions -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F -#endif - -#ifndef GL_EXT_x11_sync_object -#define GL_SYNC_X11_FENCE_EXT 0x90E1 -#endif - -#ifndef GL_AMD_multi_draw_indirect -#endif - -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB -#endif - -#ifndef GL_AMD_pinned_memory -#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 -#endif - -#ifndef GL_AMD_stencil_operation_extended -#define GL_SET_AMD 0x874A -#define GL_REPLACE_VALUE_AMD 0x874B -#define GL_STENCIL_OP_VALUE_AMD 0x874C -#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D -#endif - - -/*************************************************************/ - -#include -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for program/shader text and shader object handles */ -typedef char GLcharARB; -typedef unsigned int GLhandleARB; -#endif - -/* GL type for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#include "gl-64bit-types.h" - -#ifndef GL_ARB_cl_event -/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event -struct _cl_context; -struct _cl_event; - */ -#endif - -#ifndef GL_ARB_debug_output -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif - -#ifndef GL_AMD_debug_output -typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif - -#ifndef GL_NV_vdpau_interop -typedef GLintptr GLvdpauSurfaceNV; -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GLAPI void APIENTRY glBlendEquation (GLenum mode); -GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_2_DEPRECATED -#define GL_VERSION_1_2_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogram (GLenum target); -GLAPI void APIENTRY glResetMinmax (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum texture); -GLAPI void APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_3_DEPRECATED -#define GL_VERSION_1_3_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClientActiveTexture (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_VERSION_1_4_DEPRECATED -#define GL_VERSION_1_4_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordf (GLfloat coord); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); -GLAPI void APIENTRY glFogCoordd (GLdouble coord); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2iv (const GLint *v); -GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); -GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3iv (const GLint *v); -GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQuery (GLuint id); -GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQuery (GLenum target); -GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); -GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); -GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); -GLAPI void APIENTRY glCompileShader (GLuint shader); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum type); -GLAPI void APIENTRY glDeleteProgram (GLuint program); -GLAPI void APIENTRY glDeleteShader (GLuint shader); -GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgram (GLuint program); -GLAPI GLboolean APIENTRY glIsShader (GLuint shader); -GLAPI void APIENTRY glLinkProgram (GLuint program); -GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -GLAPI void APIENTRY glUseProgram (GLuint program); -GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glValidateProgram (GLuint program); -GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 -/* OpenGL 3.0 also reuses entry points from these extensions: */ -/* ARB_framebuffer_object */ -/* ARB_map_buffer_range */ -/* ARB_vertex_array_object */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); -GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); -GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedback (void); -GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); -GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRender (void); -GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); -GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); -GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); -GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); -GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -#endif - -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 -/* OpenGL 3.1 also reuses entry points from these extensions: */ -/* ARB_copy_buffer */ -/* ARB_uniform_buffer_object */ -/* ARB_draw_instanced */ -/* ARB_texture_buffer_object */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); -#endif - -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 -/* OpenGL 3.2 also reuses entry points from these extensions: */ -/* ARB_draw_elements_base_vertex */ -/* ARB_provoking_vertex */ -/* ARB_sync */ -/* ARB_texture_multisample */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); -GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif - -#ifndef GL_VERSION_3_3 -#define GL_VERSION_3_3 1 -/* OpenGL 3.3 also reuses entry points from these extensions: */ -/* ARB_blend_func_extended */ -/* ARB_sampler_objects */ -/* ARB_explicit_attrib_location, but it has none */ -/* ARB_occlusion_query2 (no entry points) */ -/* ARB_shader_bit_encoding (no entry points) */ -/* ARB_texture_rgb10_a2ui (no entry points) */ -/* ARB_texture_swizzle (no entry points) */ -/* ARB_timer_query */ -/* ARB_vertex_type_2_10_10_10_rev */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); -#endif - -#ifndef GL_VERSION_4_0 -#define GL_VERSION_4_0 1 -/* OpenGL 4.0 also reuses entry points from these extensions: */ -/* ARB_texture_query_lod (no entry points) */ -/* ARB_draw_indirect */ -/* ARB_gpu_shader5 (no entry points) */ -/* ARB_gpu_shader_fp64 */ -/* ARB_shader_subroutine */ -/* ARB_tessellation_shader */ -/* ARB_texture_buffer_object_rgb32 (no entry points) */ -/* ARB_texture_cube_map_array (no entry points) */ -/* ARB_texture_gather (no entry points) */ -/* ARB_transform_feedback2 */ -/* ARB_transform_feedback3 */ -/* Susume ARB_sample_shading */ -/* Susume ARB_draw_buffers_blend */ -#endif - -#ifndef GL_VERSION_4_1 -#define GL_VERSION_4_1 1 -/* OpenGL 4.1 reuses entry points from these extensions: */ -/* ARB_ES2_compatibility */ -/* ARB_get_program_binary */ -/* ARB_separate_shader_objects */ -/* ARB_shader_precision (no entry points) */ -/* ARB_vertex_attrib_64bit */ -/* ARB_viewport_array */ -#endif - -#ifndef GL_VERSION_4_2 -#define GL_VERSION_4_2 1 -/* OpenGL 4.2 reuses entry points from these extensions: */ -/* ARB_base_instance */ -/* ARB_shading_language_420pack (no entry points) */ -/* ARB_transform_feedback_instanced */ -/* ARB_compressed_texture_pixel_storage (no entry points) */ -/* ARB_conservative_depth (no entry points) */ -/* ARB_internalformat_query */ -/* ARB_map_buffer_alignment (no entry points) */ -/* ARB_shader_atomic_counters */ -/* ARB_shader_image_load_store */ -/* ARB_shading_language_packing (no entry points) */ -/* ARB_texture_storage */ -#endif - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#endif - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLclampf value, GLboolean invert); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); -#endif - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#endif - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#endif - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); -GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); -GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); -GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); -GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); -GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); -GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); -GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); -GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glVertexBlendARB (GLint count); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#endif - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#endif - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#endif - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#endif - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); -GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); -GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQueryARB (GLenum target); -GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -#endif - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 -#endif - -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmap (GLenum target); -GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 -#endif - -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); -GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 -#endif - -#ifndef GL_ARB_instanced_arrays -#define GL_ARB_instanced_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 -#endif - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArray (GLuint array); -GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_ARB_uniform_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); -GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); -GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif - -#ifndef GL_ARB_compatibility -#define GL_ARB_compatibility 1 -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_ARB_copy_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif - -#ifndef GL_ARB_shader_texture_lod -#define GL_ARB_shader_texture_lod 1 -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp 1 -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#define GL_ARB_draw_elements_base_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#define GL_ARB_fragment_coord_conventions 1 -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_ARB_provoking_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertex (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map 1 -#endif - -#ifndef GL_ARB_sync -#define GL_ARB_sync 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); -GLAPI GLboolean APIENTRY glIsSync (GLsync sync); -GLAPI void APIENTRY glDeleteSync (GLsync sync); -GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); -typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); -typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); -typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_ARB_texture_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); -#endif - -#ifndef GL_ARB_vertex_array_bgra -#define GL_ARB_vertex_array_bgra 1 -#endif - -#ifndef GL_ARB_draw_buffers_blend -#define GL_ARB_draw_buffers_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif - -#ifndef GL_ARB_sample_shading -#define GL_ARB_sample_shading 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShadingARB (GLclampf value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_ARB_texture_cube_map_array 1 -#endif - -#ifndef GL_ARB_texture_gather -#define GL_ARB_texture_gather 1 -#endif - -#ifndef GL_ARB_texture_query_lod -#define GL_ARB_texture_query_lod 1 -#endif - -#ifndef GL_ARB_shading_language_include -#define GL_ARB_shading_language_include 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); -GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); -typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_ARB_texture_compression_bptc 1 -#endif - -#ifndef GL_ARB_blend_func_extended -#define GL_ARB_blend_func_extended 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); -#endif - -#ifndef GL_ARB_explicit_attrib_location -#define GL_ARB_explicit_attrib_location 1 -#endif - -#ifndef GL_ARB_occlusion_query2 -#define GL_ARB_occlusion_query2 1 -#endif - -#ifndef GL_ARB_sampler_objects -#define GL_ARB_sampler_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); -GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); -GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); -GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); -GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); -GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); -GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); -GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); -typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); -typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); -typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_bit_encoding -#define GL_ARB_shader_bit_encoding 1 -#endif - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_ARB_texture_rgb10_a2ui 1 -#endif - -#ifndef GL_ARB_texture_swizzle -#define GL_ARB_texture_swizzle 1 -#endif - -#ifndef GL_ARB_timer_query -#define GL_ARB_timer_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); -GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); -#endif - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -#define GL_ARB_vertex_type_2_10_10_10_rev 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif - -#ifndef GL_ARB_draw_indirect -#define GL_ARB_draw_indirect 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); -GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); -#endif - -#ifndef GL_ARB_gpu_shader5 -#define GL_ARB_gpu_shader5 1 -#endif - -#ifndef GL_ARB_gpu_shader_fp64 -#define GL_ARB_gpu_shader_fp64 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); -GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); -#endif - -#ifndef GL_ARB_shader_subroutine -#define GL_ARB_shader_subroutine 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); -GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); -GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); -typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif - -#ifndef GL_ARB_tessellation_shader -#define GL_ARB_tessellation_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); -GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); -#endif - -#ifndef GL_ARB_texture_buffer_object_rgb32 -#define GL_ARB_texture_buffer_object_rgb32 1 -#endif - -#ifndef GL_ARB_transform_feedback2 -#define GL_ARB_transform_feedback2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedback (void); -GLAPI void APIENTRY glResumeTransformFeedback (void); -GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); -#endif - -#ifndef GL_ARB_transform_feedback3 -#define GL_ARB_transform_feedback3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); -GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); -GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); -GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); -typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_ES2_compatibility -#define GL_ARB_ES2_compatibility 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReleaseShaderCompiler (void); -GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); -GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -GLAPI void APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); -GLAPI void APIENTRY glClearDepthf (GLclampf depth); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); -typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); -typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f); -typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLclampf d); -#endif - -#ifndef GL_ARB_get_program_binary -#define GL_ARB_get_program_binary 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); -GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); -#endif - -#ifndef GL_ARB_separate_shader_objects -#define GL_ARB_separate_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); -GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* *strings); -GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); -GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); -GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); -GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); -GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); -GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); -typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* *strings); -typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); -typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif - -#ifndef GL_ARB_vertex_attrib_64bit -#define GL_ARB_vertex_attrib_64bit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); -#endif - -#ifndef GL_ARB_viewport_array -#define GL_ARB_viewport_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); -GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); -GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLclampd *v); -GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLclampd n, GLclampd f); -GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f); -typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); -#endif - -#ifndef GL_ARB_cl_event -#define GL_ARB_cl_event 1 -#ifdef GL_GLEXT_PROTOTYPES -/* GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); */ -GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (void * context, void * event, GLbitfield flags); -#endif /* GL_GLEXT_PROTOTYPES */ -/* typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); */ -typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (void * context, void * event, GLbitfield flags); -#endif - -#ifndef GL_ARB_debug_output -#define GL_ARB_debug_output 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif - -#ifndef GL_ARB_robustness -#define GL_ARB_robustness 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); -GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); -GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); -GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); -GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); -GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); -GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); -GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); -GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); -GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); -typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); -typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); -typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); -typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); -typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); -typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); -typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif - -#ifndef GL_ARB_shader_stencil_export -#define GL_ARB_shader_stencil_export 1 -#endif - -#ifndef GL_ARB_base_instance -#define GL_ARB_base_instance 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); -#endif - -#ifndef GL_ARB_shading_language_420pack -#define GL_ARB_shading_language_420pack 1 -#endif - -#ifndef GL_ARB_transform_feedback_instanced -#define GL_ARB_transform_feedback_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount); -GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); -#endif - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_ARB_compressed_texture_pixel_storage 1 -#endif - -#ifndef GL_ARB_conservative_depth -#define GL_ARB_conservative_depth 1 -#endif - -#ifndef GL_ARB_internalformat_query -#define GL_ARB_internalformat_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif - -#ifndef GL_ARB_map_buffer_alignment -#define GL_ARB_map_buffer_alignment 1 -#endif - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ARB_shader_atomic_counters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_shader_image_load_store -#define GL_ARB_shader_image_load_store 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); -#endif - -#ifndef GL_ARB_shading_language_packing -#define GL_ARB_shading_language_packing 1 -#endif - -#ifndef GL_ARB_texture_storage -#define GL_ARB_texture_storage 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#endif - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#endif - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#endif - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogramEXT (GLenum target); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#endif - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 -#endif - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#endif - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#endif - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); -GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#endif - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#endif - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint i); -GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); -GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params); -GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#endif - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#endif - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#endif - -#ifndef GL_SGIX_texture_select -#define GL_SGIX_texture_select 1 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#endif - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#endif - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#endif - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#endif - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#endif - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); -GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); -GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#endif - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); -GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#endif - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#endif - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); -GLAPI void APIENTRY glTextureLightEXT (GLenum pname); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#endif - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#endif - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); #endif +#endif /* GL_VERSION_3_0 */ -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer); -GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -#endif - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); #endif +#endif /* GL_VERSION_3_1 */ -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif +typedef int64_t GLint64; +typedef struct __GLsync *GLsync; +typedef uint64_t GLuint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); #endif +#endif /* GL_VERSION_3_2 */ -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); #endif +#endif /* GL_VERSION_3_3 */ -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); #endif +#endif /* GL_VERSION_4_0 */ -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat zNear, GLfloat zFar); +GLAPI void APIENTRY glClearDepthf (GLfloat depth); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif +#endif /* GL_ARB_ES2_compatibility */ -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#ifndef GL_ARB_ES2_compatibility +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#endif /* GL_ARB_ES2_compatibility */ +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +#ifndef GL_ARB_ES2_compatibility +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +#endif /* GL_ARB_ES2_compatibility */ +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifndef GL_ARB_ES2_compatibility +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat zNear, GLfloat zFar); +GLAPI void APIENTRY glClearDepthf (GLfloat depth); +#endif /* GL_ARB_ES2_compatibility */ +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); #endif +#endif /* GL_VERSION_4_1 */ -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#ifndef GL_ARB_ES3_compatibility +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif /* GL_ARB_ES3_compatibility */ +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_LOCAL_WORK_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_DISPLAY_LIST 0x82E7 +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#endif +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +typedef struct _cl_context * cl_context; +typedef struct _cl_event * cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (cl_context context, cl_event event, GLbitfield flags); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); -GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); -GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); -GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (cl_context context, cl_event event, GLbitfield flags); #endif +#endif /* GL_ARB_cl_event */ -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_SGIX_fog_scale 1 -#endif - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); #endif +#endif /* GL_ARB_clear_buffer_object */ -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); #endif +#endif /* GL_ARB_color_buffer_float */ -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif /* GL_ARB_compatibility */ -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); #endif +#endif /* GL_ARB_debug_output */ -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif /* GL_ARB_depth_texture */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); #endif +#endif /* GL_ARB_draw_buffers */ -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); #endif +#endif /* GL_ARB_draw_buffers_blend */ -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#endif +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#endif +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); #endif +#endif /* GL_ARB_draw_instanced */ -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#endif +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#endif +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif /* GL_ARB_fragment_program */ + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif /* GL_ARB_fragment_program_shadow */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif /* GL_ARB_fragment_shader */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); #endif +#endif /* GL_ARB_framebuffer_no_attachments */ -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); #endif +#endif /* GL_ARB_geometry_shader4 */ -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); #endif +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#define GL_HALF_FLOAT_ARB 0x140B +#endif /* GL_ARB_half_float_pixel */ -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); #endif +#endif /* GL_ARB_instanced_arrays */ -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); #endif +#endif /* GL_ARB_internalformat_query */ -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#endif +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#endif /* GL_ARB_internalformat_query2 */ -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#endif +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#endif +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); #endif +#endif /* GL_ARB_matrix_palette */ -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#endif +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); #endif +#endif /* GL_ARB_multisample */ -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); #endif +#endif /* GL_ARB_multitexture */ -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); #endif +#endif /* GL_ARB_occlusion_query */ -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#endif +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#endif +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); #endif +#endif /* GL_ARB_point_parameters */ -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif /* GL_ARB_point_sprite */ -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#endif +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#endif +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#endif +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); #endif +#endif /* GL_ARB_robustness */ -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#endif +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); #endif +#endif /* GL_ARB_sample_shading */ -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#endif +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); -#endif +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#endif +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#endif +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); -GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); -GLAPI void APIENTRY glFinishFenceNV (GLuint fence); -GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#endif +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; #endif - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 +typedef char GLcharARB; +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); #endif +#endif /* GL_ARB_shader_objects */ -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#endif +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#endif +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#endif +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#endif +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif /* GL_ARB_shader_texture_lod */ -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); -GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); -GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); -GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#endif +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif /* GL_ARB_shading_language_100 */ -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#endif +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar **path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar **path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); #endif +#endif /* GL_ARB_shading_language_include */ -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#endif +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#endif +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif /* GL_ARB_shadow */ -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#endif +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif /* GL_ARB_shadow_ambient */ -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); #endif +#endif /* GL_ARB_texture_buffer_object */ -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); #endif +#endif /* GL_ARB_texture_buffer_range */ -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); -GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img); #endif +#endif /* GL_ARB_texture_compression */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif /* GL_ARB_texture_cube_map */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif /* GL_ARB_texture_env_add */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif /* GL_ARB_texture_env_combine */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif /* GL_ARB_texture_env_crossbar */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif /* GL_ARB_texture_env_dot3 */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif /* GL_ARB_texture_float */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif /* GL_ARB_texture_rectangle */ -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#endif +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#endif +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); -GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); -GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr); -GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); -GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); -GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); -GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); -GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); -GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); -GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); -GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); -GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #endif +#endif /* GL_ARB_texture_storage */ -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); -GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); -GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#endif +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#endif +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#endif /* GL_ARB_transform_feedback2 */ -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#endif +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#endif +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); #endif +#endif /* GL_ARB_transpose_matrix */ -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#endif +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#endif /* GL_ARB_uniform_buffer_object */ -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#endif +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); #endif +#endif /* GL_ARB_vertex_blend */ -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +typedef ptrdiff_t GLsizeiptrARB; +typedef ptrdiff_t GLintptrARB; +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid **params); #endif +#endif /* GL_ARB_vertex_buffer_object */ -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid **pointer); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); #endif +#endif /* GL_ARB_vertex_program */ -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); #endif +#endif /* GL_ARB_vertex_shader */ -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#endif +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#endif +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#endif /* GL_ARB_viewport_array */ -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); #endif +#endif /* GL_ARB_window_pos */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); +typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x); +typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); +GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); +GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); +GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); +GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex2bOES (GLbyte x); +GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); +#endif +#endif /* GL_OES_byte_coordinates */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +typedef GLint GLfixed; +#define GL_FIXED_OES 0x140C +typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); +typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); +typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); +typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); +typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); +typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); +typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); +typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); +typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); +typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); +typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); +typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); +typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); +typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); +typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); +typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); +typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); +typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); +typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); +GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); +GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); +GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); +GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glLineWidthxOES (GLfixed width); +GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glPointSizexOES (GLfixed size); +GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert); +GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); +GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); +GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); +GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); +GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); +GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); +GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); +GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); +GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); +GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glIndexxOES (GLfixed component); +GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); +GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); +GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); +GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); +GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glPassThroughxOES (GLfixed token); +GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); +GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); +GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); +GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); +GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); +GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); +GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glVertex2xOES (GLfixed x); +GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); +#endif +#endif /* GL_OES_fixed_point */ + +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif +#endif /* GL_OES_query_matrix */ -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#endif +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif /* GL_OES_read_format */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +typedef float GLclampf; +typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearDepthfOES (GLfloat depth); +GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GLAPI void APIENTRY glDepthRangefOES (GLfloat zNear, GLfloat zFar); +GLAPI void APIENTRY glFrustumfOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +GLAPI void APIENTRY glOrthofOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +#endif +#endif /* GL_OES_single_precision */ -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#endif +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif /* GL_3DFX_multisample */ -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); #endif +#endif /* GL_3DFX_tbuffer */ -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -/* This is really a WGL extension, but defines some associated GL enums. - * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. - */ -#endif +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif /* GL_3DFX_texture_compression_FXT1 */ -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_AMD_blend_minmax_factor */ + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif /* GL_AMD_conservative_depth */ + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); #endif +#endif /* GL_AMD_debug_output */ -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif /* GL_AMD_depth_clamp_separate */ + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); #endif +#endif /* GL_AMD_draw_buffers_blend */ -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 +#ifndef GL_AMD_interleaved_elements +#define GL_AMD_interleaved_elements 1 +#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 +#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 +typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); #endif +#endif /* GL_AMD_interleaved_elements */ -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); #endif +#endif /* GL_AMD_multi_draw_indirect */ -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); #endif +#endif /* GL_AMD_name_gen_delete */ -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, GLvoid *pointer); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); #endif +#endif /* GL_AMD_performance_monitor */ -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif /* GL_AMD_pinned_memory */ + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif /* GL_AMD_query_buffer_object */ + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); #endif +#endif /* GL_AMD_sample_positions */ -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#endif +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif /* GL_AMD_seamless_cubemap_per_texture */ -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif /* GL_AMD_shader_stencil_export */ + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif /* GL_AMD_shader_trinary_minmax */ + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 +typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif +#endif /* GL_AMD_sparse_texture */ -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); #endif +#endif /* GL_AMD_stencil_operation_extended */ -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif /* GL_AMD_texture_texture4 */ -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#endif +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif /* GL_AMD_transform_feedback3_lines_triangles */ -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif /* GL_AMD_vertex_shader_layer */ -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); #endif +#endif /* GL_AMD_vertex_shader_tessellator */ -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#endif +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif /* GL_AMD_vertex_shader_viewport_index */ -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif /* GL_APPLE_aux_depth_stencil */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif /* GL_APPLE_client_storage */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); #endif +#endif /* GL_APPLE_element_array */ -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); #endif +#endif /* GL_APPLE_fence */ -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#endif +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif /* GL_APPLE_float_pixels */ -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); #endif +#endif /* GL_APPLE_flush_buffer_range */ -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); #endif +#endif /* GL_APPLE_object_purgeable */ -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#endif +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif /* GL_APPLE_rgb_422 */ -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif /* GL_APPLE_row_bytes */ -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif /* GL_APPLE_specular_vector */ -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid **params); #endif +#endif /* GL_APPLE_texture_range */ -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif /* GL_APPLE_transform_hint */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); #endif +#endif /* GL_APPLE_vertex_array_object */ -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); #endif +#endif /* GL_APPLE_vertex_array_range */ -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); #endif +#endif /* GL_APPLE_vertex_program_evaluators */ -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85B9 +#endif /* GL_APPLE_ycbcr_422 */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); #endif +#endif /* GL_ATI_draw_buffers */ -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); #endif +#endif /* GL_ATI_element_array */ -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif +#endif /* GL_ATI_envmap_bumpmap */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); #endif +#endif /* GL_ATI_fragment_shader */ -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); #endif +#endif /* GL_ATI_map_object_buffer */ -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif /* GL_ATI_meminfo */ -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); -#endif +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif /* GL_ATI_pixel_format_float */ -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); #endif +#endif /* GL_ATI_pn_triangles */ -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); -GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); #endif +#endif /* GL_ATI_separate_stencil */ -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); -#endif +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif /* GL_ATI_text_fragment_shader */ -#ifndef GL_NV_vertex_program4 -#define GL_NV_vertex_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); -#endif +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif /* GL_ATI_texture_env_combine3 */ -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -#endif +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif /* GL_ATI_texture_float */ -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif /* GL_ATI_texture_mirror_once */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); #endif +#endif /* GL_ATI_vertex_array_object */ -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); #endif +#endif /* GL_ATI_vertex_attrib_array_object */ -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); #endif +#endif /* GL_ATI_vertex_streams */ -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 -#endif +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif /* GL_EXT_422_pixels */ -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 -#endif +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#define GL_ABGR_EXT 0x8000 +#endif /* GL_EXT_abgr */ -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 -#endif +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif /* GL_EXT_bgra */ -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); -GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -#endif - -#ifndef GL_NV_fragment_program4 -#define GL_NV_fragment_program4 1 +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); #endif +#endif /* GL_EXT_bindable_uniform */ -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 -#endif - -#ifndef GL_NV_geometry_shader4 -#define GL_NV_geometry_shader4 1 +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #endif +#endif /* GL_EXT_blend_color */ -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); #endif +#endif /* GL_EXT_blend_equation_separate */ -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); -GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #endif +#endif /* GL_EXT_blend_func_separate */ -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif /* GL_EXT_blend_logic_op */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_BLEND_EQUATION_EXT 0x8009 +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackNV (void); -GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); -GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); -GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); -GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); #endif +#endif /* GL_EXT_blend_minmax */ -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif /* GL_EXT_blend_subtract */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif /* GL_EXT_clip_volume_hint */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif /* GL_EXT_cmyka */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); -GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); -GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); -typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #endif +#endif /* GL_EXT_color_subtable */ -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); -GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); #endif +#endif /* GL_EXT_compiled_vertex_array */ -#ifndef GL_GREMEDY_frame_terminator -#define GL_GREMEDY_frame_terminator 1 +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); #endif +#endif /* GL_EXT_convolution */ -#ifndef GL_NV_conditional_render -#define GL_NV_conditional_render 1 +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRenderNV (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); #endif +#endif /* GL_EXT_coordinate_frame */ -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); -GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #endif +#endif /* GL_EXT_copy_texture */ -#ifndef GL_EXT_transform_feedback -#define GL_EXT_transform_feedback 1 +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackEXT (void); -GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); #endif +#endif /* GL_EXT_cull_vertex */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +typedef double GLclampd; +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif +#endif /* GL_EXT_depth_bounds_test */ #ifndef GL_EXT_direct_state_access #define GL_EXT_direct_state_access 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); -GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); -GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); -GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); -GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); -GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data); -GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img); -GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img); -GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); -GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string); -GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); -GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); -GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); -GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params); -GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); -GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); -GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); -GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); -GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); -GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); -GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); @@ -10619,10 +5875,8 @@ typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); @@ -10643,29 +5897,7 @@ typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); @@ -10682,9 +5914,36 @@ typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum ta typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); -typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid **data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); @@ -10699,32 +5958,17 @@ typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texuni typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); @@ -10750,6 +5994,16 @@ typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); @@ -10758,20 +6012,33 @@ typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint l typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); -typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, GLvoid **params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); @@ -10784,688 +6051,4760 @@ typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, GLvoid **param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLvoid **param); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid **data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid **params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, GLvoid **params); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, GLvoid **param); +GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLvoid **param); +GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#endif +#endif /* GL_EXT_draw_buffers2 */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif +#endif /* GL_EXT_draw_range_elements */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif +#endif /* GL_EXT_fog_coord */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_framebuffer_multisample */ + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif +#endif /* GL_EXT_framebuffer_object */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif /* GL_EXT_framebuffer_sRGB */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif +#endif /* GL_EXT_geometry_shader4 */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif +#endif /* GL_EXT_gpu_program_parameters */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif +#endif /* GL_EXT_gpu_shader4 */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif +#endif /* GL_EXT_histogram */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif /* GL_EXT_index_array_formats */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif +#endif /* GL_EXT_index_func */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_index_material */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif /* GL_EXT_index_texture */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_light_texture */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif /* GL_EXT_misc_attribute */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif +#endif /* GL_EXT_multisample */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif /* GL_EXT_packed_depth_stencil */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif /* GL_EXT_packed_float */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif /* GL_EXT_packed_pixels */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_paletted_texture */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif /* GL_EXT_pixel_buffer_object */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_pixel_transform */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif /* GL_EXT_pixel_transform_color_table */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_EXT_point_parameters */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif +#endif /* GL_EXT_polygon_offset */ + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif +#endif /* GL_EXT_provoking_vertex */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif /* GL_EXT_rescale_normal */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif +#endif /* GL_EXT_secondary_color */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif /* GL_EXT_separate_specular_color */ + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif +#endif /* GL_EXT_shader_image_load_store */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif /* GL_EXT_shadow_funcs */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif /* GL_EXT_shared_texture_palette */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif +#endif /* GL_EXT_stencil_clear_tag */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif +#endif /* GL_EXT_stencil_two_side */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_stencil_wrap */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif +#endif /* GL_EXT_subtexture */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif /* GL_EXT_texture */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif +#endif /* GL_EXT_texture3D */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +#endif /* GL_EXT_texture_array */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_EXT_texture_buffer_object */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif /* GL_EXT_texture_compression_latc */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif /* GL_EXT_texture_cube_map */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif /* GL_EXT_texture_env_add */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif /* GL_EXT_texture_env_combine */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif /* GL_EXT_texture_env_dot3 */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif +#endif /* GL_EXT_texture_integer */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif /* GL_EXT_texture_lod_bias */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif /* GL_EXT_texture_mirror_clamp */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif +#endif /* GL_EXT_texture_object */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif +#endif /* GL_EXT_texture_perturb_normal */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_sRGB */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif /* GL_EXT_texture_shared_exponent */ + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +#endif /* GL_EXT_texture_snorm */ + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif /* GL_EXT_texture_swizzle */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +#define GL_TIME_ELAPSED_EXT 0x88BF +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_EXT_timer_query */ + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar **varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar **varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif +#endif /* GL_EXT_transform_feedback */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid **params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid **params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif +#endif /* GL_EXT_vertex_array */ + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif /* GL_EXT_vertex_array_bgra */ + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif +#endif /* GL_EXT_vertex_attrib_64bit */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid **data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid **data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif +#endif /* GL_EXT_vertex_shader */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif +#endif /* GL_EXT_vertex_weighting */ + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif +#endif /* GL_EXT_x11_sync_object */ + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif +#endif /* GL_GREMEDY_frame_terminator */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string); +#endif +#endif /* GL_GREMEDY_string_marker */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif /* GL_HP_convolution_border_modes */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_HP_image_transform */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif /* GL_HP_occlusion_test */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif /* GL_HP_texture_lighting */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#define GL_CULL_VERTEX_IBM 103050 +#endif /* GL_IBM_cull_vertex */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei primcount, GLint modestride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei primcount, GLint modestride); +#endif +#endif /* GL_IBM_multimode_draw_arrays */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif /* GL_IBM_rasterpos_clip */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 +typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif +#endif /* GL_IBM_static_data */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif /* GL_IBM_texture_mirrored_repeat */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +#endif +#endif /* GL_IBM_vertex_array_lists */ + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_INGR_blend_func_separate */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif /* GL_INGR_color_clamp */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#define GL_INTERLACE_READ_INGR 0x8568 +#endif /* GL_INGR_interlace_read */ + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 +typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); +typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, const GLint *stride, const GLenum *layout); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); +GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); +GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, const GLint *stride, const GLenum *layout); +#endif +#endif /* GL_INTEL_map_texture */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid **pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid **pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid **pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid **pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid **pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid **pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid **pointer); +#endif +#endif /* GL_INTEL_parallel_arrays */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif /* GL_MESAX_texture_stack */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#define GL_PACK_INVERT_MESA 0x8758 +#endif /* GL_MESA_pack_invert */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif +#endif /* GL_MESA_resize_buffers */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif +#endif /* GL_MESA_window_pos */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif /* GL_MESA_ycbcr_texture */ + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); +GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif +#endif /* GL_NVX_conditional_render */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif /* GL_NV_blend_square */ + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif /* GL_NV_compute_program5 */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif /* GL_NV_copy_depth_to_color */ + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_NV_copy_image */ + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif /* GL_NV_deep_texture3D */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864F +#endif /* GL_NV_depth_clamp */ + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 +typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif +#endif /* GL_NV_draw_texture */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif +#endif /* GL_NV_evaluators */ + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif +#endif /* GL_NV_explicit_multisample */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif /* GL_NV_float_buffer */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#endif /* GL_NV_fog_distance */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif +#endif /* GL_NV_fragment_program */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif /* GL_NV_fragment_program2 */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif /* GL_NV_fragment_program4 */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif /* GL_NV_fragment_program_option */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_NV_geometry_program4 */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif /* GL_NV_geometry_shader4 */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif +#endif /* GL_NV_gpu_program4 */ + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif +#endif /* GL_NV_gpu_program5 */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140B +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif +#endif /* GL_NV_half_float */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif /* GL_NV_light_max_exponent */ + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#endif /* GL_NV_multisample_coverage */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif /* GL_NV_multisample_filter_hint */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_occlusion_query */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif /* GL_NV_packed_depth_stencil */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif +#endif /* GL_NV_parameter_buffer_object */ + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif /* GL_NV_parameter_buffer_object2 */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif +#endif /* GL_NV_pixel_data_range */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif +#endif /* GL_NV_point_sprite */ + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_NV_present_video */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif +#endif /* GL_NV_primitive_restart */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_register_combiners */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif +#endif /* GL_NV_register_combiners2 */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_shader_buffer_load */ + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ + +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif /* GL_NV_shader_storage_buffer_object */ + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif /* GL_NV_tessellation_program5 */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif /* GL_NV_texgen_emboss */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif /* GL_NV_texgen_reflection */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif +#endif /* GL_NV_texture_barrier */ + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif /* GL_NV_texture_compression_vtc */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif /* GL_NV_texture_env_combine4 */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif /* GL_NV_texture_expand_normal */ + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif +#endif /* GL_NV_texture_multisample */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif /* GL_NV_texture_rectangle */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif /* GL_NV_texture_shader */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif /* GL_NV_texture_shader2 */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif /* GL_NV_texture_shader3 */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif +#endif /* GL_NV_transform_feedback */ + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif +#endif /* GL_NV_transform_feedback2 */ + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +typedef GLintptr GLvdpauSurfaceNV; +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif +#endif /* GL_NV_vdpau_interop */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer); +#endif +#endif /* GL_NV_vertex_array_range */ + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif /* GL_NV_vertex_array_range2 */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif +#endif /* GL_NV_vertex_buffer_unified_memory */ + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid **pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); #endif +#endif /* GL_NV_vertex_program */ -#ifndef GL_EXT_vertex_array_bgra -#define GL_EXT_vertex_array_bgra 1 -#endif +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif /* GL_NV_vertex_program1_1 */ -#ifndef GL_EXT_texture_swizzle -#define GL_EXT_texture_swizzle 1 -#endif +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif /* GL_NV_vertex_program2 */ -#ifndef GL_NV_explicit_multisample -#define GL_NV_explicit_multisample 1 +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif /* GL_NV_vertex_program2_option */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif /* GL_NV_vertex_program3 */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); -GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); -typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); #endif +#endif /* GL_NV_vertex_program4 */ -#ifndef GL_NV_transform_feedback2 -#define GL_NV_transform_feedback2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedbackNV (void); -GLAPI void APIENTRY glResumeTransformFeedbackNV (void); -GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); #endif +#endif /* GL_NV_video_capture */ -#ifndef GL_ATI_meminfo -#define GL_ATI_meminfo 1 -#endif +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif /* GL_OML_interlace */ -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif /* GL_OML_resample */ -#ifndef GL_AMD_texture_texture4 -#define GL_AMD_texture_texture4 1 -#endif +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif /* GL_OML_subsample */ -#ifndef GL_AMD_vertex_shader_tesselator -#define GL_AMD_vertex_shader_tesselator 1 +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); -GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); #endif +#endif /* GL_PGI_misc_hints */ -#ifndef GL_EXT_provoking_vertex -#define GL_EXT_provoking_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); -#endif +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif /* GL_PGI_vertex_hints */ -#ifndef GL_EXT_texture_snorm -#define GL_EXT_texture_snorm 1 -#endif +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif /* GL_REND_screen_coordinates */ -#ifndef GL_AMD_draw_buffers_blend -#define GL_AMD_draw_buffers_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#endif +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 +#endif /* GL_S3_s3tc */ -#ifndef GL_APPLE_texture_range -#define GL_APPLE_texture_range 1 +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer); -GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels 1 +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); #endif +#endif /* GL_SGIS_detail_texture */ -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_APPLE_vertex_program_evaluators 1 +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); #endif +#endif /* GL_SGIS_fog_function */ -#ifndef GL_APPLE_aux_depth_stencil -#define GL_APPLE_aux_depth_stencil 1 -#endif +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif /* GL_SGIS_generate_mipmap */ -#ifndef GL_APPLE_object_purgeable -#define GL_APPLE_object_purgeable 1 +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); #endif +#endif /* GL_SGIS_multisample */ -#ifndef GL_APPLE_row_bytes -#define GL_APPLE_row_bytes 1 +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); #endif +#endif /* GL_SGIS_pixel_texture */ -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 -#endif +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif /* GL_SGIS_point_line_texgen */ -#ifndef GL_NV_video_capture -#define GL_NV_video_capture 1 +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); #endif +#endif /* GL_SGIS_point_parameters */ -#ifndef GL_NV_copy_image -#define GL_NV_copy_image 1 +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); #endif +#endif /* GL_SGIS_sharpen_texture */ -#ifndef GL_EXT_separate_shader_objects -#define GL_EXT_separate_shader_objects 1 +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); -GLAPI void APIENTRY glActiveProgramEXT (GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); -typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); #endif +#endif /* GL_SGIS_texture4D */ -#ifndef GL_NV_parameter_buffer_object2 -#define GL_NV_parameter_buffer_object2 1 -#endif +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif /* GL_SGIS_texture_border_clamp */ -#ifndef GL_NV_shader_buffer_load -#define GL_NV_shader_buffer_load 1 +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); -GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); -GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); -GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); -GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); -GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); -GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); -GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); -GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); -GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); -GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); -typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); -typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); -typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); -typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); #endif +#endif /* GL_SGIS_texture_color_mask */ -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_NV_vertex_buffer_unified_memory 1 +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif /* GL_SGIS_texture_edge_clamp */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); -GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); #endif +#endif /* GL_SGIS_texture_filter4 */ -#ifndef GL_NV_texture_barrier -#define GL_NV_texture_barrier 1 +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif /* GL_SGIS_texture_lod */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif /* GL_SGIS_texture_select */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#define GL_ASYNC_MARKER_SGIX 0x8329 +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureBarrierNV (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); #endif +#endif /* GL_SGIX_async */ -#ifndef GL_AMD_shader_stencil_export -#define GL_AMD_shader_stencil_export 1 -#endif +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif /* GL_SGIX_async_histogram */ -#ifndef GL_AMD_seamless_cubemap_per_texture -#define GL_AMD_seamless_cubemap_per_texture 1 -#endif +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif /* GL_SGIX_async_pixel */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif /* GL_SGIX_blend_alpha_minmax */ -#ifndef GL_AMD_conservative_depth -#define GL_AMD_conservative_depth 1 -#endif +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif /* GL_SGIX_calligraphic_fragment */ -#ifndef GL_EXT_shader_image_load_store -#define GL_EXT_shader_image_load_store 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); -#endif +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif /* GL_SGIX_clipmap */ -#ifndef GL_EXT_vertex_attrib_64bit -#define GL_EXT_vertex_attrib_64bit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -#endif +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif /* GL_SGIX_convolution_accuracy */ -#ifndef GL_NV_gpu_program5 -#define GL_NV_gpu_program5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); -#endif +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif /* GL_SGIX_depth_pass_instrument */ -#ifndef GL_NV_gpu_shader5 -#define GL_NV_gpu_shader5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); -GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); -GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); -GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); -GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); -GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif /* GL_SGIX_depth_texture */ -#ifndef GL_NV_shader_buffer_store -#define GL_NV_shader_buffer_store 1 +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); #endif +#endif /* GL_SGIX_flush_raster */ -#ifndef GL_NV_tessellation_program5 -#define GL_NV_tessellation_program5 1 -#endif +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif /* GL_SGIX_fog_offset */ -#ifndef GL_NV_vertex_attrib_integer_64bit -#define GL_NV_vertex_attrib_integer_64bit 1 +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); -GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); -GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); #endif +#endif /* GL_SGIX_fragment_lighting */ -#ifndef GL_NV_multisample_coverage -#define GL_NV_multisample_coverage 1 +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); #endif +#endif /* GL_SGIX_framezoom */ -#ifndef GL_AMD_name_gen_delete -#define GL_AMD_name_gen_delete 1 +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); -GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); -GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); -typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); -typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params); #endif +#endif /* GL_SGIX_igloo_interface */ -#ifndef GL_AMD_debug_output -#define GL_AMD_debug_output 1 +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); #endif +#endif /* GL_SGIX_instruments */ -#ifndef GL_NV_vdpau_interop -#define GL_NV_vdpau_interop 1 +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#define GL_INTERLACE_SGIX 0x8094 +#endif /* GL_SGIX_interlace */ + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif /* GL_SGIX_ir_instrument1 */ + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#define GL_LIST_PRIORITY_SGIX 0x8182 +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); -GLAPI void APIENTRY glVDPAUFiniNV (void); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); -GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); -typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); -typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); #endif +#endif /* GL_SGIX_list_priority */ -#ifndef GL_AMD_transform_feedback3_lines_triangles -#define GL_AMD_transform_feedback3_lines_triangles 1 +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); #endif +#endif /* GL_SGIX_pixel_texture */ -#ifndef GL_AMD_depth_clamp_separate -#define GL_AMD_depth_clamp_separate 1 +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif /* GL_SGIX_pixel_tiles */ + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); #endif +#endif /* GL_SGIX_polynomial_ffd */ -#ifndef GL_EXT_texture_sRGB_decode -#define GL_EXT_texture_sRGB_decode 1 +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); #endif +#endif /* GL_SGIX_reference_plane */ -#ifndef GL_NV_texture_multisample -#define GL_NV_texture_multisample 1 +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif /* GL_SGIX_resample */ + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif /* GL_SGIX_scalebias_hint */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif /* GL_SGIX_shadow */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif /* GL_SGIX_shadow_ambient */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_sprite */ + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif /* GL_SGIX_subsample */ + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); #endif +#endif /* GL_SGIX_tag_sample_buffer */ + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif /* GL_SGIX_texture_add_env */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif /* GL_SGIX_texture_coordinate_clamp */ + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif /* GL_SGIX_texture_lod_bias */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif /* GL_SGIX_texture_multi_buffer */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif /* GL_SGIX_texture_scale_bias */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif /* GL_SGIX_vertex_preclip */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif /* GL_SGIX_ycrcb */ + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif /* GL_SGIX_ycrcb_subsample */ -#ifndef GL_AMD_blend_minmax_factor -#define GL_AMD_blend_minmax_factor 1 -#endif +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif /* GL_SGIX_ycrcba */ -#ifndef GL_AMD_sample_positions -#define GL_AMD_sample_positions 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); -#endif +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif /* GL_SGI_color_matrix */ -#ifndef GL_EXT_x11_sync_object -#define GL_EXT_x11_sync_object 1 +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); #endif +#endif /* GL_SGI_color_table */ -#ifndef GL_AMD_multi_draw_indirect -#define GL_AMD_multi_draw_indirect 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -#endif +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif /* GL_SGI_texture_color_table */ -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); #endif +#endif /* GL_SUNX_constant_data */ -#ifndef GL_AMD_pinned_memory -#define GL_AMD_pinned_memory 1 -#endif +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif /* GL_SUN_convolution_border_modes */ -#ifndef GL_AMD_stencil_operation_extended -#define GL_AMD_stencil_operation_extended 1 +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); #endif +#endif /* GL_SUN_global_alpha */ - -#ifndef GL_EXT_Cg_shader -#define GL_CG_VERTEX_SHADER_EXT 0x890E -#define GL_CG_FRAGMENT_SHADER_EXT 0x890F -#endif -#ifndef GL_EXT_Cg_shader -#define GL_EXT_Cg_shader 1 +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); #endif +#endif /* GL_SUN_mesh_array */ -/** - * We rename EXT_texture_rectangle into core, - * so ARB_texture_rectangle will remain intact. - */ -#ifndef GL_EXT_texture_rectangle -#define GL_TEXTURE_RECTANGLE_EXT 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8 -#define GL_SAMPLER_2D_RECT_EXT 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_EXT 0x8B64 -#endif -#ifndef GL_EXT_texture_rectangle -#define GL_EXT_texture_rectangle 1 -#endif +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif /* GL_SUN_slice_accum */ -#ifndef GL_APPLE_pixel_buffer -#define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10 -#endif -#ifndef GL_APPLE_pixel_buffer -#define GL_APPLE_pixel_buffer 1 +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid **pointer); #endif +#endif /* GL_SUN_triangle_list */ -#ifndef GL_APPLE_flush_render -#define GL_APPLE_flush_render 1 +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRenderAPPLE(void); -GLAPI void APIENTRY glFinishRenderAPPLE(void); -GLAPI void APIENTRY glSwapAPPLE(void); -#endif -typedef void (APIENTRY * PFNGLFLUSHRENDERAPPLEPROC) (void); -typedef void (APIENTRY * PFNGLFINISHRENDERAPPLEPROC) (void); -typedef void (APIENTRY * PFNGLSWAPAPPLEPROC) (void); +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); #endif +#endif /* GL_SUN_vertex */ +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif /* GL_WIN_phong_shading */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif /* GL_WIN_specular_fog */ #ifdef __cplusplus } diff --git a/make/stub_includes/opengl/GL/glplatform.h b/make/stub_includes/opengl/GL/glplatform.h deleted file mode 100644 index 5d42943d7..000000000 --- a/make/stub_includes/opengl/GL/glplatform.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef __glplatform_h_ -#define __glplatform_h_ - -#if defined(__BEOS__) -#include /* to get some BeOS-isms */ -#endif - -#if !defined(OPENSTEP) && (defined(NeXT) || defined(NeXT_PDO)) -#define OPENSTEP -#endif - -#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) -#define __WIN32__ -#endif - -#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) -# if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ -# define GLAPI __declspec(dllexport) -# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ -# define GLAPI __declspec(dllimport) -# else /* for use with static link lib build of Win32 edition only */ -# define GLAPI extern -# endif /* _STATIC_MESA support */ -# define GLAPIENTRY __stdcall -#else -/* non-Windows compilation */ -# ifndef GLAPI -# define GLAPI extern -# endif -# define GLAPIENTRY -#endif /* WIN32 / CYGWIN bracket */ - -#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__) -# define PRAGMA_EXPORT_SUPPORTED 1 -#endif - -/* - * WINDOWS: Include windows.h here to define APIENTRY. - * It is also useful when applications include this file by - * including only glut.h, since glut.h depends on windows.h. - * Applications needing to include windows.h with parms other - * than "WIN32_LEAN_AND_MEAN" may include windows.h before - * glut.h or gl.h. - */ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(__CYGWIN__) -#include -#endif - -#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED -#pragma import on -#endif - -#ifdef CENTERLINE_CLPP -#define signed -#endif - -#if defined(PRAGMA_EXPORT_SUPPORTED) -#pragma export on -#endif - -#endif /* __glplatform_h_ */ - diff --git a/make/stub_includes/opengl/GL/glu.h b/make/stub_includes/opengl/GL/glu.h index e3a16f304..758ba11ba 100644 --- a/make/stub_includes/opengl/GL/glu.h +++ b/make/stub_includes/opengl/GL/glu.h @@ -48,12 +48,14 @@ #include -#ifndef GLAPIENTRY -#define GLAPIENTRY +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY* #endif - #ifndef GLAPI -#define GLAPI +#define GLAPI extern #endif #ifdef __cplusplus @@ -280,133 +282,133 @@ typedef GLUtesselator GLUtriangulatorObj; #define GLU_TESS_MAX_COORD 1.0e150 /* Internal convenience typedefs */ -typedef void (GLAPIENTRY *_GLUfuncptr)(); +typedef void (APIENTRY *_GLUfuncptr)(); #endif /* GLX_VERSION_1_X */ #ifndef GLU_VERSION_1_X #define GLU_VERSION_1_X 1 -GLAPI void GLAPIENTRY gluBeginCurve (GLUnurbs* nurb); -GLAPI void GLAPIENTRY gluBeginPolygon (GLUtesselator* tess); -GLAPI void GLAPIENTRY gluBeginSurface (GLUnurbs* nurb); -GLAPI void GLAPIENTRY gluBeginTrim (GLUnurbs* nurb); -GLAPI GLint GLAPIENTRY gluBuild1DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); -GLAPI GLint GLAPIENTRY gluBuild1DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data); -GLAPI GLint GLAPIENTRY gluBuild2DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); -GLAPI GLint GLAPIENTRY gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data); -GLAPI GLint GLAPIENTRY gluBuild3DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); -GLAPI GLint GLAPIENTRY gluBuild3DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); -GLAPI GLboolean GLAPIENTRY gluCheckExtension (const GLubyte *extName, const GLubyte *extString); -GLAPI void GLAPIENTRY gluCylinder (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks); -GLAPI void GLAPIENTRY gluDeleteNurbsRenderer (GLUnurbs* nurb); -GLAPI void GLAPIENTRY gluDeleteQuadric (GLUquadric* quad); -GLAPI void GLAPIENTRY gluDeleteTess (GLUtesselator* tess); -GLAPI void GLAPIENTRY gluDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops); -GLAPI void GLAPIENTRY gluEndCurve (GLUnurbs* nurb); -GLAPI void GLAPIENTRY gluEndPolygon (GLUtesselator* tess); -GLAPI void GLAPIENTRY gluEndSurface (GLUnurbs* nurb); -GLAPI void GLAPIENTRY gluEndTrim (GLUnurbs* nurb); -GLAPI const GLubyte * GLAPIENTRY gluErrorString (GLenum error); -GLAPI void GLAPIENTRY gluGetNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat* data); -GLAPI const GLubyte * GLAPIENTRY gluGetString (GLenum name); -GLAPI void GLAPIENTRY gluGetTessProperty (GLUtesselator* tess, GLenum which, GLdouble* data); -GLAPI void GLAPIENTRY gluLoadSamplingMatrices (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view); -GLAPI void GLAPIENTRY gluLookAt (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ); -GLAPI GLUnurbs* GLAPIENTRY gluNewNurbsRenderer (void); -GLAPI GLUquadric* GLAPIENTRY gluNewQuadric (void); -GLAPI GLUtesselator* GLAPIENTRY gluNewTess (void); -GLAPI void GLAPIENTRY gluNextContour (GLUtesselator* tess, GLenum type); -GLAPI void GLAPIENTRY gluNurbsCallback (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc); -GLAPI void GLAPIENTRY gluNurbsCallbackData (GLUnurbs* nurb, GLvoid* userData); -GLAPI void GLAPIENTRY gluNurbsCallbackDataEXT (GLUnurbs* nurb, GLvoid* userData); -GLAPI void GLAPIENTRY gluNurbsCurve (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type); -GLAPI void GLAPIENTRY gluNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat value); -GLAPI void GLAPIENTRY gluNurbsSurface (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type); -GLAPI void GLAPIENTRY gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top); -GLAPI void GLAPIENTRY gluPartialDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep); -GLAPI void GLAPIENTRY gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); -GLAPI void GLAPIENTRY gluPickMatrix (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport); -GLAPI GLint GLAPIENTRY gluProject (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ); -GLAPI void GLAPIENTRY gluPwlCurve (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type); -GLAPI void GLAPIENTRY gluQuadricCallback (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc); -GLAPI void GLAPIENTRY gluQuadricDrawStyle (GLUquadric* quad, GLenum draw); -GLAPI void GLAPIENTRY gluQuadricNormals (GLUquadric* quad, GLenum normal); -GLAPI void GLAPIENTRY gluQuadricOrientation (GLUquadric* quad, GLenum orientation); -GLAPI void GLAPIENTRY gluQuadricTexture (GLUquadric* quad, GLboolean texture); -GLAPI GLint GLAPIENTRY gluScaleImage (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut); -GLAPI void GLAPIENTRY gluSphere (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks); -GLAPI void GLAPIENTRY gluTessBeginContour (GLUtesselator* tess); -GLAPI void GLAPIENTRY gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data); -GLAPI void GLAPIENTRY gluTessCallback (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc); -GLAPI void GLAPIENTRY gluTessEndContour (GLUtesselator* tess); -GLAPI void GLAPIENTRY gluTessEndPolygon (GLUtesselator* tess); -GLAPI void GLAPIENTRY gluTessNormal (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ); -GLAPI void GLAPIENTRY gluTessProperty (GLUtesselator* tess, GLenum which, GLdouble data); -GLAPI void GLAPIENTRY gluTessVertex (GLUtesselator* tess, GLdouble *location, GLvoid* data); -GLAPI GLint GLAPIENTRY gluUnProject (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ); -GLAPI GLint GLAPIENTRY gluUnProject4 (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW); - - -typedef void (GLAPIENTRY * PFNGLUBEGINCURVEPROC) (GLUnurbs* nurb); -typedef void (GLAPIENTRY * PFNGLUBEGINPOLYGONPROC) (GLUtesselator* tess); -typedef void (GLAPIENTRY * PFNGLUBEGINSURFACEPROC) (GLUnurbs* nurb); -typedef void (GLAPIENTRY * PFNGLUBEGINTRIMPROC) (GLUnurbs* nurb); -typedef GLint (GLAPIENTRY * PFNGLUBUILD1DMIPMAPLEVELSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); -typedef GLint (GLAPIENTRY * PFNGLUBUILD1DMIPMAPSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data); -typedef GLint (GLAPIENTRY * PFNGLUBUILD2DMIPMAPLEVELSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); -typedef GLint (GLAPIENTRY * PFNGLUBUILD2DMIPMAPSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data); -typedef GLint (GLAPIENTRY * PFNGLUBUILD3DMIPMAPLEVELSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); -typedef GLint (GLAPIENTRY * PFNGLUBUILD3DMIPMAPSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); -typedef GLboolean (GLAPIENTRY * PFNGLUCHECKEXTENSIONPROC) (const GLubyte *extName, const GLubyte *extString); -typedef void (GLAPIENTRY * PFNGLUCYLINDERPROC) (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks); -typedef void (GLAPIENTRY * PFNGLUDELETENURBSRENDERERPROC) (GLUnurbs* nurb); -typedef void (GLAPIENTRY * PFNGLUDELETEQUADRICPROC) (GLUquadric* quad); -typedef void (GLAPIENTRY * PFNGLUDELETETESSPROC) (GLUtesselator* tess); -typedef void (GLAPIENTRY * PFNGLUDISKPROC) (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops); -typedef void (GLAPIENTRY * PFNGLUENDCURVEPROC) (GLUnurbs* nurb); -typedef void (GLAPIENTRY * PFNGLUENDPOLYGONPROC) (GLUtesselator* tess); -typedef void (GLAPIENTRY * PFNGLUENDSURFACEPROC) (GLUnurbs* nurb); -typedef void (GLAPIENTRY * PFNGLUENDTRIMPROC) (GLUnurbs* nurb); -typedef const GLubyte * (GLAPIENTRY * PFNGLUERRORSTRINGPROC) (GLenum error); -typedef void (GLAPIENTRY * PFNGLUGETNURBSPROPERTYPROC) (GLUnurbs* nurb, GLenum property, GLfloat* data); -typedef const GLubyte * (GLAPIENTRY * PFNGLUGETSTRINGPROC) (GLenum name); -typedef void (GLAPIENTRY * PFNGLUGETTESSPROPERTYPROC) (GLUtesselator* tess, GLenum which, GLdouble* data); -typedef void (GLAPIENTRY * PFNGLULOADSAMPLINGMATRICESPROC) (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view); -typedef void (GLAPIENTRY * PFNGLULOOKATPROC) (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ); -typedef GLUnurbs* (GLAPIENTRY * PFNGLUNEWNURBSRENDERERPROC) (void); -typedef GLUquadric* (GLAPIENTRY * PFNGLUNEWQUADRICPROC) (void); -typedef GLUtesselator* (GLAPIENTRY * PFNGLUNEWTESSPROC) (void); -typedef void (GLAPIENTRY * PFNGLUNEXTCONTOURPROC) (GLUtesselator* tess, GLenum type); -typedef void (GLAPIENTRY * PFNGLUNURBSCALLBACKPROC) (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc); -typedef void (GLAPIENTRY * PFNGLUNURBSCALLBACKDATAPROC) (GLUnurbs* nurb, GLvoid* userData); -typedef void (GLAPIENTRY * PFNGLUNURBSCALLBACKDATAEXTPROC) (GLUnurbs* nurb, GLvoid* userData); -typedef void (GLAPIENTRY * PFNGLUNURBSCURVEPROC) (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type); -typedef void (GLAPIENTRY * PFNGLUNURBSPROPERTYPROC) (GLUnurbs* nurb, GLenum property, GLfloat value); -typedef void (GLAPIENTRY * PFNGLUNURBSSURFACEPROC) (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type); -typedef void (GLAPIENTRY * PFNGLUORTHO2DPROC) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top); -typedef void (GLAPIENTRY * PFNGLUPARTIALDISKPROC) (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep); -typedef void (GLAPIENTRY * PFNGLUPERSPECTIVEPROC) (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); -typedef void (GLAPIENTRY * PFNGLUPICKMATRIXPROC) (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport); -typedef GLint (GLAPIENTRY * PFNGLUPROJECTPROC) (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ); -typedef void (GLAPIENTRY * PFNGLUPWLCURVEPROC) (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type); -typedef void (GLAPIENTRY * PFNGLUQUADRICCALLBACKPROC) (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc); -typedef void (GLAPIENTRY * PFNGLUQUADRICDRAWSTYLEPROC) (GLUquadric* quad, GLenum draw); -typedef void (GLAPIENTRY * PFNGLUQUADRICNORMALSPROC) (GLUquadric* quad, GLenum normal); -typedef void (GLAPIENTRY * PFNGLUQUADRICORIENTATIONPROC) (GLUquadric* quad, GLenum orientation); -typedef void (GLAPIENTRY * PFNGLUQUADRICTEXTUREPROC) (GLUquadric* quad, GLboolean texture); -typedef GLint (GLAPIENTRY * PFNGLUSCALEIMAGEPROC) (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut); -typedef void (GLAPIENTRY * PFNGLUSPHEREPROC) (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks); -typedef void (GLAPIENTRY * PFNGLUTESSBEGINCONTOURPROC) (GLUtesselator* tess); -typedef void (GLAPIENTRY * PFNGLUTESSBEGINPOLYGONPROC) (GLUtesselator* tess, GLvoid* data); -typedef void (GLAPIENTRY * PFNGLUTESSCALLBACKPROC) (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc); -typedef void (GLAPIENTRY * PFNGLUTESSENDCONTOURPROC) (GLUtesselator* tess); -typedef void (GLAPIENTRY * PFNGLUTESSENDPOLYGONPROC) (GLUtesselator* tess); -typedef void (GLAPIENTRY * PFNGLUTESSNORMALPROC) (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ); -typedef void (GLAPIENTRY * PFNGLUTESSPROPERTYPROC) (GLUtesselator* tess, GLenum which, GLdouble data); -typedef void (GLAPIENTRY * PFNGLUTESSVERTEXPROC) (GLUtesselator* tess, GLdouble *location, GLvoid* data); -typedef GLint (GLAPIENTRY * PFNGLUUNPROJECTPROC) (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ); -typedef GLint (GLAPIENTRY * PFNGLUUNPROJECT4PROC) (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW); +GLAPI void APIENTRY gluBeginCurve (GLUnurbs* nurb); +GLAPI void APIENTRY gluBeginPolygon (GLUtesselator* tess); +GLAPI void APIENTRY gluBeginSurface (GLUnurbs* nurb); +GLAPI void APIENTRY gluBeginTrim (GLUnurbs* nurb); +GLAPI GLint APIENTRY gluBuild1DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); +GLAPI GLint APIENTRY gluBuild1DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data); +GLAPI GLint APIENTRY gluBuild2DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); +GLAPI GLint APIENTRY gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data); +GLAPI GLint APIENTRY gluBuild3DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); +GLAPI GLint APIENTRY gluBuild3DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +GLAPI GLboolean APIENTRY gluCheckExtension (const GLubyte *extName, const GLubyte *extString); +GLAPI void APIENTRY gluCylinder (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks); +GLAPI void APIENTRY gluDeleteNurbsRenderer (GLUnurbs* nurb); +GLAPI void APIENTRY gluDeleteQuadric (GLUquadric* quad); +GLAPI void APIENTRY gluDeleteTess (GLUtesselator* tess); +GLAPI void APIENTRY gluDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops); +GLAPI void APIENTRY gluEndCurve (GLUnurbs* nurb); +GLAPI void APIENTRY gluEndPolygon (GLUtesselator* tess); +GLAPI void APIENTRY gluEndSurface (GLUnurbs* nurb); +GLAPI void APIENTRY gluEndTrim (GLUnurbs* nurb); +GLAPI const GLubyte * APIENTRY gluErrorString (GLenum error); +GLAPI void APIENTRY gluGetNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat* data); +GLAPI const GLubyte * APIENTRY gluGetString (GLenum name); +GLAPI void APIENTRY gluGetTessProperty (GLUtesselator* tess, GLenum which, GLdouble* data); +GLAPI void APIENTRY gluLoadSamplingMatrices (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view); +GLAPI void APIENTRY gluLookAt (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ); +GLAPI GLUnurbs* APIENTRY gluNewNurbsRenderer (void); +GLAPI GLUquadric* APIENTRY gluNewQuadric (void); +GLAPI GLUtesselator* APIENTRY gluNewTess (void); +GLAPI void APIENTRY gluNextContour (GLUtesselator* tess, GLenum type); +GLAPI void APIENTRY gluNurbsCallback (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc); +GLAPI void APIENTRY gluNurbsCallbackData (GLUnurbs* nurb, GLvoid* userData); +GLAPI void APIENTRY gluNurbsCallbackDataEXT (GLUnurbs* nurb, GLvoid* userData); +GLAPI void APIENTRY gluNurbsCurve (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type); +GLAPI void APIENTRY gluNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat value); +GLAPI void APIENTRY gluNurbsSurface (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type); +GLAPI void APIENTRY gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top); +GLAPI void APIENTRY gluPartialDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep); +GLAPI void APIENTRY gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY gluPickMatrix (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport); +GLAPI GLint APIENTRY gluProject (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ); +GLAPI void APIENTRY gluPwlCurve (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type); +GLAPI void APIENTRY gluQuadricCallback (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc); +GLAPI void APIENTRY gluQuadricDrawStyle (GLUquadric* quad, GLenum draw); +GLAPI void APIENTRY gluQuadricNormals (GLUquadric* quad, GLenum normal); +GLAPI void APIENTRY gluQuadricOrientation (GLUquadric* quad, GLenum orientation); +GLAPI void APIENTRY gluQuadricTexture (GLUquadric* quad, GLboolean texture); +GLAPI GLint APIENTRY gluScaleImage (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut); +GLAPI void APIENTRY gluSphere (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks); +GLAPI void APIENTRY gluTessBeginContour (GLUtesselator* tess); +GLAPI void APIENTRY gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data); +GLAPI void APIENTRY gluTessCallback (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc); +GLAPI void APIENTRY gluTessEndContour (GLUtesselator* tess); +GLAPI void APIENTRY gluTessEndPolygon (GLUtesselator* tess); +GLAPI void APIENTRY gluTessNormal (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ); +GLAPI void APIENTRY gluTessProperty (GLUtesselator* tess, GLenum which, GLdouble data); +GLAPI void APIENTRY gluTessVertex (GLUtesselator* tess, GLdouble *location, GLvoid* data); +GLAPI GLint APIENTRY gluUnProject (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ); +GLAPI GLint APIENTRY gluUnProject4 (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW); + + +typedef void (APIENTRYP PFNGLUBEGINCURVEPROC) (GLUnurbs* nurb); +typedef void (APIENTRYP PFNGLUBEGINPOLYGONPROC) (GLUtesselator* tess); +typedef void (APIENTRYP PFNGLUBEGINSURFACEPROC) (GLUnurbs* nurb); +typedef void (APIENTRYP PFNGLUBEGINTRIMPROC) (GLUnurbs* nurb); +typedef GLint (APIENTRYP PFNGLUBUILD1DMIPMAPLEVELSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); +typedef GLint (APIENTRYP PFNGLUBUILD1DMIPMAPSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data); +typedef GLint (APIENTRYP PFNGLUBUILD2DMIPMAPLEVELSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); +typedef GLint (APIENTRYP PFNGLUBUILD2DMIPMAPSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data); +typedef GLint (APIENTRYP PFNGLUBUILD3DMIPMAPLEVELSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); +typedef GLint (APIENTRYP PFNGLUBUILD3DMIPMAPSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +typedef GLboolean (APIENTRYP PFNGLUCHECKEXTENSIONPROC) (const GLubyte *extName, const GLubyte *extString); +typedef void (APIENTRYP PFNGLUCYLINDERPROC) (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks); +typedef void (APIENTRYP PFNGLUDELETENURBSRENDERERPROC) (GLUnurbs* nurb); +typedef void (APIENTRYP PFNGLUDELETEQUADRICPROC) (GLUquadric* quad); +typedef void (APIENTRYP PFNGLUDELETETESSPROC) (GLUtesselator* tess); +typedef void (APIENTRYP PFNGLUDISKPROC) (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops); +typedef void (APIENTRYP PFNGLUENDCURVEPROC) (GLUnurbs* nurb); +typedef void (APIENTRYP PFNGLUENDPOLYGONPROC) (GLUtesselator* tess); +typedef void (APIENTRYP PFNGLUENDSURFACEPROC) (GLUnurbs* nurb); +typedef void (APIENTRYP PFNGLUENDTRIMPROC) (GLUnurbs* nurb); +typedef const GLubyte * (APIENTRYP PFNGLUERRORSTRINGPROC) (GLenum error); +typedef void (APIENTRYP PFNGLUGETNURBSPROPERTYPROC) (GLUnurbs* nurb, GLenum property, GLfloat* data); +typedef const GLubyte * (APIENTRYP PFNGLUGETSTRINGPROC) (GLenum name); +typedef void (APIENTRYP PFNGLUGETTESSPROPERTYPROC) (GLUtesselator* tess, GLenum which, GLdouble* data); +typedef void (APIENTRYP PFNGLULOADSAMPLINGMATRICESPROC) (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view); +typedef void (APIENTRYP PFNGLULOOKATPROC) (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ); +typedef GLUnurbs* (APIENTRYP PFNGLUNEWNURBSRENDERERPROC) (void); +typedef GLUquadric* (APIENTRYP PFNGLUNEWQUADRICPROC) (void); +typedef GLUtesselator* (APIENTRYP PFNGLUNEWTESSPROC) (void); +typedef void (APIENTRYP PFNGLUNEXTCONTOURPROC) (GLUtesselator* tess, GLenum type); +typedef void (APIENTRYP PFNGLUNURBSCALLBACKPROC) (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc); +typedef void (APIENTRYP PFNGLUNURBSCALLBACKDATAPROC) (GLUnurbs* nurb, GLvoid* userData); +typedef void (APIENTRYP PFNGLUNURBSCALLBACKDATAEXTPROC) (GLUnurbs* nurb, GLvoid* userData); +typedef void (APIENTRYP PFNGLUNURBSCURVEPROC) (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type); +typedef void (APIENTRYP PFNGLUNURBSPROPERTYPROC) (GLUnurbs* nurb, GLenum property, GLfloat value); +typedef void (APIENTRYP PFNGLUNURBSSURFACEPROC) (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type); +typedef void (APIENTRYP PFNGLUORTHO2DPROC) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top); +typedef void (APIENTRYP PFNGLUPARTIALDISKPROC) (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep); +typedef void (APIENTRYP PFNGLUPERSPECTIVEPROC) (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLUPICKMATRIXPROC) (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport); +typedef GLint (APIENTRYP PFNGLUPROJECTPROC) (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ); +typedef void (APIENTRYP PFNGLUPWLCURVEPROC) (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type); +typedef void (APIENTRYP PFNGLUQUADRICCALLBACKPROC) (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc); +typedef void (APIENTRYP PFNGLUQUADRICDRAWSTYLEPROC) (GLUquadric* quad, GLenum draw); +typedef void (APIENTRYP PFNGLUQUADRICNORMALSPROC) (GLUquadric* quad, GLenum normal); +typedef void (APIENTRYP PFNGLUQUADRICORIENTATIONPROC) (GLUquadric* quad, GLenum orientation); +typedef void (APIENTRYP PFNGLUQUADRICTEXTUREPROC) (GLUquadric* quad, GLboolean texture); +typedef GLint (APIENTRYP PFNGLUSCALEIMAGEPROC) (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut); +typedef void (APIENTRYP PFNGLUSPHEREPROC) (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks); +typedef void (APIENTRYP PFNGLUTESSBEGINCONTOURPROC) (GLUtesselator* tess); +typedef void (APIENTRYP PFNGLUTESSBEGINPOLYGONPROC) (GLUtesselator* tess, GLvoid* data); +typedef void (APIENTRYP PFNGLUTESSCALLBACKPROC) (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc); +typedef void (APIENTRYP PFNGLUTESSENDCONTOURPROC) (GLUtesselator* tess); +typedef void (APIENTRYP PFNGLUTESSENDPOLYGONPROC) (GLUtesselator* tess); +typedef void (APIENTRYP PFNGLUTESSNORMALPROC) (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ); +typedef void (APIENTRYP PFNGLUTESSPROPERTYPROC) (GLUtesselator* tess, GLenum which, GLdouble data); +typedef void (APIENTRYP PFNGLUTESSVERTEXPROC) (GLUtesselator* tess, GLdouble *location, GLvoid* data); +typedef GLint (APIENTRYP PFNGLUUNPROJECTPROC) (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ); +typedef GLint (APIENTRYP PFNGLUUNPROJECT4PROC) (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW); #endif /* GLU_VERSION_1_X */ diff --git a/make/stub_includes/opengl/GL/glx.h b/make/stub_includes/opengl/GL/glx.h index 67225e043..a74cd23e8 100644 --- a/make/stub_includes/opengl/GL/glx.h +++ b/make/stub_includes/opengl/GL/glx.h @@ -56,17 +56,8 @@ extern "C" { #endif - /* For some reason gcc ignores #undef directives for these definitions when placed outside this file, - which are necessary when including both glx.h and glxext.h as is necessary to compile - X11GLImpl_JNI.c. Looks like a bug; couldn't boil down a smaller test case. - gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110) -#define GLX_VERSION_1_1 1 -#define GLX_VERSION_1_2 1 -#define GLX_VERSION_1_3 1 -#define GLX_VERSION_1_4 1 - */ - -#ifndef GLX_VERSION_1_X +#ifndef GLX_VERSION_1_0 +#define GLX_VERSION_1_0 1 #define GLX_EXTENSION_NAME "GLX" @@ -103,100 +94,9 @@ extern "C" { #define GLX_BAD_VALUE 6 #define GLX_BAD_ENUM 7 - -/* - * GLX 1.1 and later: - */ -#define GLX_VENDOR 1 -#define GLX_VERSION 2 -#define GLX_EXTENSIONS 3 - - -/* - * GLX 1.3 and later: - */ -#define GLX_CONFIG_CAVEAT 0x20 -#define GLX_DONT_CARE 0xFFFFFFFF -#define GLX_SLOW_CONFIG 0x8001 -#define GLX_NON_CONFORMANT_CONFIG 0x800D -#define GLX_X_VISUAL_TYPE 0x22 -#define GLX_TRANSPARENT_TYPE 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE 0x24 -#define GLX_TRANSPARENT_RED_VALUE 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 -#define GLX_MAX_PBUFFER_WIDTH 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT 0x8017 -#define GLX_MAX_PBUFFER_PIXELS 0x8018 -#define GLX_PRESERVED_CONTENTS 0x801B -#define GLX_LARGEST_PBUFFER 0x801C -#define GLX_WIDTH 0x801D -#define GLX_HEIGHT 0x801E -#define GLX_EVENT_MASK 0x801F -#define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_FBCONFIG_ID 0x8013 -#define GLX_VISUAL_ID 0x800B -#define GLX_WINDOW_BIT 0x00000001 -#define GLX_PIXMAP_BIT 0x00000002 -#define GLX_PBUFFER_BIT 0x00000004 -#define GLX_AUX_BUFFERS_BIT 0x00000010 -#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 -#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 -#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 -#define GLX_DEPTH_BUFFER_BIT 0x00000020 -#define GLX_STENCIL_BUFFER_BIT 0x00000040 -#define GLX_ACCUM_BUFFER_BIT 0x00000080 -#define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_RENDER_TYPE 0x8011 -#define GLX_X_RENDERABLE 0x8012 -#define GLX_NONE 0x8000 -#define GLX_TRUE_COLOR 0x8002 -#define GLX_DIRECT_COLOR 0x8003 -#define GLX_PSEUDO_COLOR 0x8004 -#define GLX_STATIC_COLOR 0x8005 -#define GLX_GRAY_SCALE 0x8006 -#define GLX_STATIC_GRAY 0x8007 -#define GLX_TRANSPARENT_RGB 0x8008 -#define GLX_TRANSPARENT_INDEX 0x8009 -#define GLX_RGBA_TYPE 0x8014 -#define GLX_COLOR_INDEX_TYPE 0x8015 -#define GLX_COLOR_INDEX_BIT 0x00000002 -#define GLX_RGBA_BIT 0x00000001 -#define GLX_SCREEN 0x800C -#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 -#define GLX_DAMAGED 0x8020 -#define GLX_SAVED 0x8021 -#define GLX_WINDOW 0x8022 -#define GLX_PBUFFER 0x8023 -#define GLX_PBUFFER_HEIGHT 0x8040 -#define GLX_PBUFFER_WIDTH 0x8041 - - -/* - * GLX 1.4 and later: - */ -#define GLX_SAMPLE_BUFFERS 0x186a0 /*100000*/ -#define GLX_SAMPLES 0x186a1 /*100001*/ - - - typedef struct __GLXcontextRec *GLXContext; typedef XID GLXPixmap; typedef XID GLXDrawable; -/* GLX 1.3 and later */ -typedef struct __GLXFBConfigRec *GLXFBConfig; -typedef XID GLXFBConfigID; -typedef XID GLXContextID; -typedef XID GLXWindow; -typedef XID GLXPbuffer; - -#endif /* GLX_VERSION_1_X */ - - -#ifndef GLX_VERSION_1_X -#define GLX_VERSION_1_X 1 extern XVisualInfo* glXChooseVisual( Display *dpy, int screen, int *attribList ); @@ -239,226 +139,58 @@ extern void glXWaitX( void ); extern void glXUseXFont( Font font, int first, int count, int list ); +#endif /* GLX_VERSION_1_0 */ -/* GLX 1.1 and later */ -extern const char *glXQueryExtensionsString( Display *dpy, int screen ); - -extern const char *glXQueryServerString( Display *dpy, int screen, int name ); - -extern const char *glXGetClientString( Display *dpy, int name ); - - -/* GLX 1.2 and later */ -extern Display *glXGetCurrentDisplay( void ); - - -/* GLX 1.3 and later */ -extern GLXFBConfig *glXChooseFBConfig( Display *dpy, int screen, - const int *attribList, int *nitems ); - -extern int glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config, - int attribute, int *value ); - -extern GLXFBConfig *glXGetFBConfigs( Display *dpy, int screen, - int *nelements ); - -extern XVisualInfo *glXGetVisualFromFBConfig( Display *dpy, - GLXFBConfig config ); - -extern GLXWindow glXCreateWindow( Display *dpy, GLXFBConfig config, - Window win, const int *attribList ); - -extern void glXDestroyWindow( Display *dpy, GLXWindow window ); - -extern GLXPixmap glXCreatePixmap( Display *dpy, GLXFBConfig config, - Pixmap pixmap, const int *attribList ); - -extern void glXDestroyPixmap( Display *dpy, GLXPixmap pixmap ); - -extern GLXPbuffer glXCreatePbuffer( Display *dpy, GLXFBConfig config, - const int *attribList ); - -extern void glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf ); - -extern void glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute, - unsigned int *value ); - -extern GLXContext glXCreateNewContext( Display *dpy, GLXFBConfig config, - int renderType, GLXContext shareList, - Bool direct ); - -extern Bool glXMakeContextCurrent( Display *dpy, GLXDrawable draw, - GLXDrawable read, GLXContext ctx ); - -extern GLXDrawable glXGetCurrentReadDrawable( void ); - -extern int glXQueryContext( Display *dpy, GLXContext ctx, int attribute, - int *value ); -extern void glXSelectEvent( Display *dpy, GLXDrawable drawable, - unsigned long mask ); +#ifndef GLX_VERSION_1_1 +#define GLX_VERSION_1_1 1 -extern void glXGetSelectedEvent( Display *dpy, GLXDrawable drawable, - unsigned long *mask ); - -/* GLX 1.4 and later */ -extern void (*glXGetProcAddress(const GLubyte *procname))(); - -#endif /* GLX_VERSION_1_X */ - -#ifndef GLX_GLXEXT_LEGACY - -#include - -#else - - -/* - * 28. GLX_EXT_visual_info extension - */ -#ifndef GLX_EXT_visual_info -#define GLX_EXT_visual_info 1 - -#define GLX_X_VISUAL_TYPE_EXT 0x22 -#define GLX_TRANSPARENT_TYPE_EXT 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 -#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 -#define GLX_TRUE_COLOR_EXT 0x8002 -#define GLX_DIRECT_COLOR_EXT 0x8003 -#define GLX_PSEUDO_COLOR_EXT 0x8004 -#define GLX_STATIC_COLOR_EXT 0x8005 -#define GLX_GRAY_SCALE_EXT 0x8006 -#define GLX_STATIC_GRAY_EXT 0x8007 -#define GLX_NONE_EXT 0x8000 -#define GLX_TRANSPARENT_RGB_EXT 0x8008 -#define GLX_TRANSPARENT_INDEX_EXT 0x8009 - -#endif /* 28. GLX_EXT_visual_info extension */ - - - -/* - * 41. GLX_SGI_video_sync - */ -#ifndef GLX_SGI_video_sync -#define GLX_SGI_video_sync 1 - -extern int glXGetVideoSyncSGI(unsigned int *count); -extern int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count); - -#endif /* GLX_SGI_video_sync */ - - - -/* - * 42. GLX_EXT_visual_rating - */ -#ifndef GLX_EXT_visual_rating -#define GLX_EXT_visual_rating 1 - -#define GLX_VISUAL_CAVEAT_EXT 0x20 -/*#define GLX_NONE_EXT 0x8000*/ -#define GLX_SLOW_VISUAL_EXT 0x8001 -#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D - -#endif /* GLX_EXT_visual_rating */ - - - -/* - * 47. GLX_EXT_import_context - */ -#ifndef GLX_EXT_import_context -#define GLX_EXT_import_context 1 - -#define GLX_SHARE_CONTEXT_EXT 0x800A -#define GLX_VISUAL_ID_EXT 0x800B -#define GLX_SCREEN_EXT 0x800C +#define GLX_VENDOR 1 +#define GLX_VERSION 2 +#define GLX_EXTENSIONS 3 -extern void glXFreeContextEXT(Display *dpy, GLXContext context); +extern const char *glXQueryExtensionsString( Display *dpy, int screen ); -extern GLXContextID glXGetContextIDEXT(const GLXContext context); +extern const char *glXQueryServerString( Display *dpy, int screen, int name ); -extern Display *glXGetCurrentDisplayEXT(void); +extern const char *glXGetClientString( Display *dpy, int name ); -extern GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID); +#endif /* GLX_VERSION_1_1 */ -extern int glXQueryContextInfoEXT(Display *dpy, GLXContext context, - int attribute,int *value); -#endif /* GLX_EXT_import_context */ +#ifndef GLX_VERSION_1_2 +#define GLX_VERSION_1_2 1 +extern Display *glXGetCurrentDisplay( void ); +#endif /* GLX_VERSION_1_2 */ -/* - * 215. GLX_MESA_copy_sub_buffer +/** + * We require 'glXGetProcAddress' and 'glXGetProcAddressARB' + * to be available in GLX, rather than GLXExt. */ -#ifndef GLX_MESA_copy_sub_buffer -#define GLX_MESA_copy_sub_buffer 1 - -extern void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable, - int x, int y, int width, int height ); - +#ifndef GLX_VERSION_1_4 +#define GLX_VERSION_1_4 1 + +typedef void ( *__GLXextFuncPtr)(void); +#define GLX_SAMPLE_BUFFERS 100000 +#define GLX_SAMPLES 100001 +typedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); +#ifdef GL_GLEXT_PROTOTYPES +__GLXextFuncPtr glXGetProcAddress (const GLubyte *procName); #endif +#endif /* GLX_VERSION_1_4 */ - - -/* - * 216. GLX_MESA_pixmap_colormap - */ -#ifndef GLX_MESA_pixmap_colormap -#define GLX_MESA_pixmap_colormap 1 - -extern GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual, - Pixmap pixmap, Colormap cmap ); - -#endif /* GLX_MESA_pixmap_colormap */ - - - -/* - * 217. GLX_MESA_release_buffers - */ -#ifndef GLX_MESA_release_buffers -#define GLX_MESA_release_buffers 1 - -extern Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d ); - -#endif /* GLX_MESA_release_buffers */ - - - -/* - * 218. GLX_MESA_set_3dfx_mode - */ -#ifndef GLX_MESA_set_3dfx_mode -#define GLX_MESA_set_3dfx_mode 1 - -#define GLX_3DFX_WINDOW_MODE_MESA 0x1 -#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 - -extern Bool glXSet3DfxModeMESA( int mode ); - -#endif /* GLX_MESA_set_3dfx_mode */ - - - -/* - * ARB 2. GLX_ARB_get_proc_address - */ #ifndef GLX_ARB_get_proc_address #define GLX_ARB_get_proc_address 1 - -extern void (*glXGetProcAddressARB(const GLubyte *procName))(); - +typedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName); +#ifdef GL_GLEXT_PROTOTYPES +__GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName); +#endif #endif /* GLX_ARB_get_proc_address */ - -#endif /* GLX_GLXEXT_LEGACY */ +#include #ifdef __cplusplus } diff --git a/make/stub_includes/opengl/GL/glxext.h b/make/stub_includes/opengl/GL/glxext.h index 3d85521b9..c4805b7d4 100644 --- a/make/stub_includes/opengl/GL/glxext.h +++ b/make/stub_includes/opengl/GL/glxext.h @@ -1,885 +1,858 @@ #ifndef __glxext_h_ -#define __glxext_h_ +#define __glxext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** NOTE: The Original Code (as defined below) has been licensed to Sun -** Microsystems, Inc. ("Sun") under the SGI Free Software License B -** (Version 1.1), shown above ("SGI License"). Pursuant to Section -** 3.2(3) of the SGI License, Sun is distributing the Covered Code to -** you under an alternative license ("Alternative License"). This -** Alternative License includes all of the provisions of the SGI License -** except that Section 2.2 and 11 are omitted. Any differences between -** the Alternative License and the SGI License are offered solely by Sun -** and not by SGI. +** Copyright (c) 2013 The Khronos Group Inc. ** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: This software was created using the -** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has -** not been independently verified as being compliant with the OpenGL(R) -** version 1.2.1 Specification. +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision$ on $Date$ */ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glxext.h last updated 2009/01/08 */ -/* Current version at http://www.opengl.org/registry/ */ -#define GLX_GLXEXT_VERSION 21 +#define GLX_GLXEXT_VERSION 20130614 -#ifndef GLX_ARB_multisample -#define GLX_SAMPLE_BUFFERS_ARB 100000 -#define GLX_SAMPLES_ARB 100001 -#endif +/* Generated C header for: + * API: glx + * Versions considered: .* + * Versions emitted: 1\.[3-9] + * Default extensions included: glx + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ -#ifndef GLX_ARB_fbconfig_float -#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 -#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 -#endif +#ifndef GLX_VERSION_1_3 +#define GLX_VERSION_1_3 1 +typedef struct __GLXFBConfigRec *GLXFBConfig; +typedef XID GLXWindow; +typedef XID GLXPbuffer; +#define GLX_WINDOW_BIT 0x00000001 +#define GLX_PIXMAP_BIT 0x00000002 +#define GLX_PBUFFER_BIT 0x00000004 +#define GLX_RGBA_BIT 0x00000001 +#define GLX_COLOR_INDEX_BIT 0x00000002 +#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 +#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 +#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 +#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 +#define GLX_AUX_BUFFERS_BIT 0x00000010 +#define GLX_DEPTH_BUFFER_BIT 0x00000020 +#define GLX_STENCIL_BUFFER_BIT 0x00000040 +#define GLX_ACCUM_BUFFER_BIT 0x00000080 +#define GLX_CONFIG_CAVEAT 0x20 +#define GLX_X_VISUAL_TYPE 0x22 +#define GLX_TRANSPARENT_TYPE 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE 0x24 +#define GLX_TRANSPARENT_RED_VALUE 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 +#define GLX_DONT_CARE 0xFFFFFFFF +#define GLX_NONE 0x8000 +#define GLX_SLOW_CONFIG 0x8001 +#define GLX_TRUE_COLOR 0x8002 +#define GLX_DIRECT_COLOR 0x8003 +#define GLX_PSEUDO_COLOR 0x8004 +#define GLX_STATIC_COLOR 0x8005 +#define GLX_GRAY_SCALE 0x8006 +#define GLX_STATIC_GRAY 0x8007 +#define GLX_TRANSPARENT_RGB 0x8008 +#define GLX_TRANSPARENT_INDEX 0x8009 +#define GLX_VISUAL_ID 0x800B +#define GLX_SCREEN 0x800C +#define GLX_NON_CONFORMANT_CONFIG 0x800D +#define GLX_DRAWABLE_TYPE 0x8010 +#define GLX_RENDER_TYPE 0x8011 +#define GLX_X_RENDERABLE 0x8012 +#define GLX_FBCONFIG_ID 0x8013 +#define GLX_RGBA_TYPE 0x8014 +#define GLX_COLOR_INDEX_TYPE 0x8015 +#define GLX_MAX_PBUFFER_WIDTH 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT 0x8017 +#define GLX_MAX_PBUFFER_PIXELS 0x8018 +#define GLX_PRESERVED_CONTENTS 0x801B +#define GLX_LARGEST_PBUFFER 0x801C +#define GLX_WIDTH 0x801D +#define GLX_HEIGHT 0x801E +#define GLX_EVENT_MASK 0x801F +#define GLX_DAMAGED 0x8020 +#define GLX_SAVED 0x8021 +#define GLX_WINDOW 0x8022 +#define GLX_PBUFFER 0x8023 +#define GLX_PBUFFER_HEIGHT 0x8040 +#define GLX_PBUFFER_WIDTH 0x8041 +typedef GLXFBConfig *( *PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); +typedef GLXFBConfig *( *PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); +typedef int ( *PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); +typedef XVisualInfo *( *PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); +typedef GLXWindow ( *PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); +typedef void ( *PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); +typedef GLXPixmap ( *PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); +typedef void ( *PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); +typedef GLXPbuffer ( *PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); +typedef void ( *PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); +typedef void ( *PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); +typedef GLXContext ( *PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +typedef Bool ( *PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +typedef GLXDrawable ( *PFNGLXGETCURRENTREADDRAWABLEPROC) (void); +typedef int ( *PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); +typedef void ( *PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); +typedef void ( *PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); +#ifdef GL_GLEXT_PROTOTYPES +GLXFBConfig *glXGetFBConfigs (Display *dpy, int screen, int *nelements); +GLXFBConfig *glXChooseFBConfig (Display *dpy, int screen, const int *attrib_list, int *nelements); +int glXGetFBConfigAttrib (Display *dpy, GLXFBConfig config, int attribute, int *value); +XVisualInfo *glXGetVisualFromFBConfig (Display *dpy, GLXFBConfig config); +GLXWindow glXCreateWindow (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); +void glXDestroyWindow (Display *dpy, GLXWindow win); +GLXPixmap glXCreatePixmap (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); +void glXDestroyPixmap (Display *dpy, GLXPixmap pixmap); +GLXPbuffer glXCreatePbuffer (Display *dpy, GLXFBConfig config, const int *attrib_list); +void glXDestroyPbuffer (Display *dpy, GLXPbuffer pbuf); +void glXQueryDrawable (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); +GLXContext glXCreateNewContext (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +Bool glXMakeContextCurrent (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +GLXDrawable glXGetCurrentReadDrawable (void); +int glXQueryContext (Display *dpy, GLXContext ctx, int attribute, int *value); +void glXSelectEvent (Display *dpy, GLXDrawable draw, unsigned long event_mask); +void glXGetSelectedEvent (Display *dpy, GLXDrawable draw, unsigned long *event_mask); +#endif +#endif /* GLX_VERSION_1_3 */ + +#ifndef GLX_VERSION_1_4 +#define GLX_VERSION_1_4 1 +typedef void ( *__GLXextFuncPtr)(void); +#define GLX_SAMPLE_BUFFERS 100000 +#define GLX_SAMPLES 100001 +typedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); +#ifdef GL_GLEXT_PROTOTYPES +__GLXextFuncPtr glXGetProcAddress (const GLubyte *procName); +#endif +#endif /* GLX_VERSION_1_4 */ #ifndef GLX_ARB_create_context -#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define GLX_ARB_create_context 1 +#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define GLX_CONTEXT_FLAGS_ARB 0x2094 +typedef GLXContext ( *PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GLXContext glXCreateContextAttribsARB (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); +#endif +#endif /* GLX_ARB_create_context */ + +#ifndef GLX_ARB_create_context_profile +#define GLX_ARB_create_context_profile 1 +#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define GLX_CONTEXT_FLAGS_ARB 0x2094 -#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 -#endif +#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 +#endif /* GLX_ARB_create_context_profile */ #ifndef GLX_ARB_create_context_robustness -#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 -#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#endif +#define GLX_ARB_create_context_robustness 1 +#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif /* GLX_ARB_create_context_robustness */ -#ifndef GLX_EXT_create_context_es2_profile -#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 -#endif - -#ifndef GLX_SGIS_multisample -#define GLX_SAMPLE_BUFFERS_SGIS 100000 -#define GLX_SAMPLES_SGIS 100001 -#endif - -#ifndef GLX_EXT_visual_info -#define GLX_X_VISUAL_TYPE_EXT 0x22 -#define GLX_TRANSPARENT_TYPE_EXT 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 -#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 -#define GLX_NONE_EXT 0x8000 -#define GLX_TRUE_COLOR_EXT 0x8002 -#define GLX_DIRECT_COLOR_EXT 0x8003 -#define GLX_PSEUDO_COLOR_EXT 0x8004 -#define GLX_STATIC_COLOR_EXT 0x8005 -#define GLX_GRAY_SCALE_EXT 0x8006 -#define GLX_STATIC_GRAY_EXT 0x8007 -#define GLX_TRANSPARENT_RGB_EXT 0x8008 -#define GLX_TRANSPARENT_INDEX_EXT 0x8009 -#endif +#ifndef GLX_ARB_fbconfig_float +#define GLX_ARB_fbconfig_float 1 +#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 +#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 +#endif /* GLX_ARB_fbconfig_float */ -#ifndef GLX_SGI_swap_control -#endif +#ifndef GLX_ARB_framebuffer_sRGB +#define GLX_ARB_framebuffer_sRGB 1 +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 +#endif /* GLX_ARB_framebuffer_sRGB */ -#ifndef GLX_SGI_video_sync -#endif - -#ifndef GLX_SGI_make_current_read +#ifndef GLX_ARB_get_proc_address +#define GLX_ARB_get_proc_address 1 +typedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName); +#ifdef GL_GLEXT_PROTOTYPES +__GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName); #endif +#endif /* GLX_ARB_get_proc_address */ -#ifndef GLX_SGIX_video_source -#endif +#ifndef GLX_ARB_multisample +#define GLX_ARB_multisample 1 +#define GLX_SAMPLE_BUFFERS_ARB 100000 +#define GLX_SAMPLES_ARB 100001 +#endif /* GLX_ARB_multisample */ -#ifndef GLX_EXT_visual_rating -#define GLX_VISUAL_CAVEAT_EXT 0x20 -#define GLX_SLOW_VISUAL_EXT 0x8001 -#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D -/* reuse GLX_NONE_EXT */ -#endif +#ifndef GLX_ARB_robustness_application_isolation +#define GLX_ARB_robustness_application_isolation 1 +#define GLX_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 +#endif /* GLX_ARB_robustness_application_isolation */ -#ifndef GLX_EXT_import_context -#define GLX_SHARE_CONTEXT_EXT 0x800A -#define GLX_VISUAL_ID_EXT 0x800B -#define GLX_SCREEN_EXT 0x800C -#endif +#ifndef GLX_ARB_robustness_share_group_isolation +#define GLX_ARB_robustness_share_group_isolation 1 +#endif /* GLX_ARB_robustness_share_group_isolation */ -#ifndef GLX_SGIX_fbconfig -#define GLX_WINDOW_BIT_SGIX 0x00000001 -#define GLX_PIXMAP_BIT_SGIX 0x00000002 -#define GLX_RGBA_BIT_SGIX 0x00000001 -#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 -#define GLX_DRAWABLE_TYPE_SGIX 0x8010 -#define GLX_RENDER_TYPE_SGIX 0x8011 -#define GLX_X_RENDERABLE_SGIX 0x8012 -#define GLX_FBCONFIG_ID_SGIX 0x8013 -#define GLX_RGBA_TYPE_SGIX 0x8014 -#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 -/* reuse GLX_SCREEN_EXT */ -#endif +#ifndef GLX_ARB_vertex_buffer_object +#define GLX_ARB_vertex_buffer_object 1 +#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095 +#endif /* GLX_ARB_vertex_buffer_object */ -#ifndef GLX_SGIX_pbuffer -#define GLX_PBUFFER_BIT_SGIX 0x00000004 -#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 -#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 -#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 -#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 -#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 -#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 -#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 -#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 -#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 -#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 -#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 -#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 -#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A -#define GLX_PRESERVED_CONTENTS_SGIX 0x801B -#define GLX_LARGEST_PBUFFER_SGIX 0x801C -#define GLX_WIDTH_SGIX 0x801D -#define GLX_HEIGHT_SGIX 0x801E -#define GLX_EVENT_MASK_SGIX 0x801F -#define GLX_DAMAGED_SGIX 0x8020 -#define GLX_SAVED_SGIX 0x8021 -#define GLX_WINDOW_SGIX 0x8022 -#define GLX_PBUFFER_SGIX 0x8023 -#endif +#ifndef GLX_3DFX_multisample +#define GLX_3DFX_multisample 1 +#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 +#define GLX_SAMPLES_3DFX 0x8051 +#endif /* GLX_3DFX_multisample */ + +#ifndef GLX_AMD_gpu_association +#define GLX_AMD_gpu_association 1 +#define GLX_GPU_VENDOR_AMD 0x1F00 +#define GLX_GPU_RENDERER_STRING_AMD 0x1F01 +#define GLX_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define GLX_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define GLX_GPU_RAM_AMD 0x21A3 +#define GLX_GPU_CLOCK_AMD 0x21A4 +#define GLX_GPU_NUM_PIPES_AMD 0x21A5 +#define GLX_GPU_NUM_SIMD_AMD 0x21A6 +#define GLX_GPU_NUM_RB_AMD 0x21A7 +#define GLX_GPU_NUM_SPI_AMD 0x21A8 +#endif /* GLX_AMD_gpu_association */ + +#ifndef GLX_EXT_buffer_age +#define GLX_EXT_buffer_age 1 +#define GLX_BACK_BUFFER_AGE_EXT 0x20F4 +#endif /* GLX_EXT_buffer_age */ -#ifndef GLX_SGI_cushion -#endif +#ifndef GLX_EXT_create_context_es2_profile +#define GLX_EXT_create_context_es2_profile 1 +#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif /* GLX_EXT_create_context_es2_profile */ -#ifndef GLX_SGIX_video_resize -#define GLX_SYNC_FRAME_SGIX 0x00000000 -#define GLX_SYNC_SWAP_SGIX 0x00000001 -#endif +#ifndef GLX_EXT_create_context_es_profile +#define GLX_EXT_create_context_es_profile 1 +#define GLX_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#endif /* GLX_EXT_create_context_es_profile */ -#ifndef GLX_SGIX_dmbuffer -#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024 -#endif +#ifndef GLX_EXT_fbconfig_packed_float +#define GLX_EXT_fbconfig_packed_float 1 +#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 +#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 +#endif /* GLX_EXT_fbconfig_packed_float */ -#ifndef GLX_SGIX_swap_group -#endif +#ifndef GLX_EXT_framebuffer_sRGB +#define GLX_EXT_framebuffer_sRGB 1 +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 +#endif /* GLX_EXT_framebuffer_sRGB */ -#ifndef GLX_SGIX_swap_barrier -#endif +#ifndef GLX_EXT_import_context +#define GLX_EXT_import_context 1 +typedef XID GLXContextID; +#define GLX_SHARE_CONTEXT_EXT 0x800A +#define GLX_VISUAL_ID_EXT 0x800B +#define GLX_SCREEN_EXT 0x800C +typedef Display *( *PFNGLXGETCURRENTDISPLAYEXTPROC) (void); +typedef int ( *PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value); +typedef GLXContextID ( *PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); +typedef GLXContext ( *PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID); +typedef void ( *PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context); +#ifdef GL_GLEXT_PROTOTYPES +Display *glXGetCurrentDisplayEXT (void); +int glXQueryContextInfoEXT (Display *dpy, GLXContext context, int attribute, int *value); +GLXContextID glXGetContextIDEXT (const GLXContext context); +GLXContext glXImportContextEXT (Display *dpy, GLXContextID contextID); +void glXFreeContextEXT (Display *dpy, GLXContext context); +#endif +#endif /* GLX_EXT_import_context */ + +#ifndef GLX_EXT_swap_control +#define GLX_EXT_swap_control 1 +#define GLX_SWAP_INTERVAL_EXT 0x20F1 +#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 +typedef void ( *PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, int interval); +#ifdef GL_GLEXT_PROTOTYPES +void glXSwapIntervalEXT (Display *dpy, GLXDrawable drawable, int interval); +#endif +#endif /* GLX_EXT_swap_control */ + +#ifndef GLX_EXT_swap_control_tear +#define GLX_EXT_swap_control_tear 1 +#define GLX_LATE_SWAPS_TEAR_EXT 0x20F3 +#endif /* GLX_EXT_swap_control_tear */ -#ifndef GLX_SGIS_blended_overlay -#define GLX_BLENDED_RGBA_SGIS 0x8025 -#endif +#ifndef GLX_EXT_texture_from_pixmap +#define GLX_EXT_texture_from_pixmap 1 +#define GLX_TEXTURE_1D_BIT_EXT 0x00000001 +#define GLX_TEXTURE_2D_BIT_EXT 0x00000002 +#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 +#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 +#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 +#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 +#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 +#define GLX_Y_INVERTED_EXT 0x20D4 +#define GLX_TEXTURE_FORMAT_EXT 0x20D5 +#define GLX_TEXTURE_TARGET_EXT 0x20D6 +#define GLX_MIPMAP_TEXTURE_EXT 0x20D7 +#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 +#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 +#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA +#define GLX_TEXTURE_1D_EXT 0x20DB +#define GLX_TEXTURE_2D_EXT 0x20DC +#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD +#define GLX_FRONT_LEFT_EXT 0x20DE +#define GLX_FRONT_RIGHT_EXT 0x20DF +#define GLX_BACK_LEFT_EXT 0x20E0 +#define GLX_BACK_RIGHT_EXT 0x20E1 +#define GLX_FRONT_EXT 0x20DE +#define GLX_BACK_EXT 0x20E0 +#define GLX_AUX0_EXT 0x20E2 +#define GLX_AUX1_EXT 0x20E3 +#define GLX_AUX2_EXT 0x20E4 +#define GLX_AUX3_EXT 0x20E5 +#define GLX_AUX4_EXT 0x20E6 +#define GLX_AUX5_EXT 0x20E7 +#define GLX_AUX6_EXT 0x20E8 +#define GLX_AUX7_EXT 0x20E9 +#define GLX_AUX8_EXT 0x20EA +#define GLX_AUX9_EXT 0x20EB +typedef void ( *PFNGLXBINDTEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list); +typedef void ( *PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer); +#ifdef GL_GLEXT_PROTOTYPES +void glXBindTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list); +void glXReleaseTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer); +#endif +#endif /* GLX_EXT_texture_from_pixmap */ -#ifndef GLX_SGIS_shared_multisample -#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 -#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 -#endif +#ifndef GLX_EXT_visual_info +#define GLX_EXT_visual_info 1 +#define GLX_X_VISUAL_TYPE_EXT 0x22 +#define GLX_TRANSPARENT_TYPE_EXT 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 +#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 +#define GLX_NONE_EXT 0x8000 +#define GLX_TRUE_COLOR_EXT 0x8002 +#define GLX_DIRECT_COLOR_EXT 0x8003 +#define GLX_PSEUDO_COLOR_EXT 0x8004 +#define GLX_STATIC_COLOR_EXT 0x8005 +#define GLX_GRAY_SCALE_EXT 0x8006 +#define GLX_STATIC_GRAY_EXT 0x8007 +#define GLX_TRANSPARENT_RGB_EXT 0x8008 +#define GLX_TRANSPARENT_INDEX_EXT 0x8009 +#endif /* GLX_EXT_visual_info */ -#ifndef GLX_SUN_get_transparent_index -#endif +#ifndef GLX_EXT_visual_rating +#define GLX_EXT_visual_rating 1 +#define GLX_VISUAL_CAVEAT_EXT 0x20 +#define GLX_SLOW_VISUAL_EXT 0x8001 +#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D +#endif /* GLX_EXT_visual_rating */ + +#ifndef GLX_INTEL_swap_event +#define GLX_INTEL_swap_event 1 +#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000 +#define GLX_EXCHANGE_COMPLETE_INTEL 0x8180 +#define GLX_COPY_COMPLETE_INTEL 0x8181 +#define GLX_FLIP_COMPLETE_INTEL 0x8182 +#endif /* GLX_INTEL_swap_event */ -#ifndef GLX_3DFX_multisample -#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 -#define GLX_SAMPLES_3DFX 0x8051 +#ifndef GLX_MESA_agp_offset +#define GLX_MESA_agp_offset 1 +typedef unsigned int ( *PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +unsigned int glXGetAGPOffsetMESA (const void *pointer); #endif +#endif /* GLX_MESA_agp_offset */ #ifndef GLX_MESA_copy_sub_buffer +#define GLX_MESA_copy_sub_buffer 1 +typedef void ( *PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height); +#ifdef GL_GLEXT_PROTOTYPES +void glXCopySubBufferMESA (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height); #endif +#endif /* GLX_MESA_copy_sub_buffer */ #ifndef GLX_MESA_pixmap_colormap +#define GLX_MESA_pixmap_colormap 1 +typedef GLXPixmap ( *PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); +#ifdef GL_GLEXT_PROTOTYPES +GLXPixmap glXCreateGLXPixmapMESA (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); #endif +#endif /* GLX_MESA_pixmap_colormap */ #ifndef GLX_MESA_release_buffers +#define GLX_MESA_release_buffers 1 +typedef Bool ( *PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable); +#ifdef GL_GLEXT_PROTOTYPES +Bool glXReleaseBuffersMESA (Display *dpy, GLXDrawable drawable); #endif +#endif /* GLX_MESA_release_buffers */ #ifndef GLX_MESA_set_3dfx_mode -#define GLX_3DFX_WINDOW_MODE_MESA 0x1 -#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 -#endif - -#ifndef GLX_SGIX_visual_select_group -#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 -#endif - -#ifndef GLX_OML_swap_method -#define GLX_SWAP_METHOD_OML 0x8060 -#define GLX_SWAP_EXCHANGE_OML 0x8061 -#define GLX_SWAP_COPY_OML 0x8062 -#define GLX_SWAP_UNDEFINED_OML 0x8063 +#define GLX_MESA_set_3dfx_mode 1 +#define GLX_3DFX_WINDOW_MODE_MESA 0x1 +#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 +typedef Bool ( *PFNGLXSET3DFXMODEMESAPROC) (int mode); +#ifdef GL_GLEXT_PROTOTYPES +Bool glXSet3DfxModeMESA (int mode); #endif +#endif /* GLX_MESA_set_3dfx_mode */ -#ifndef GLX_OML_sync_control +#ifndef GLX_NV_copy_image +#define GLX_NV_copy_image 1 +typedef void ( *PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +void glXCopyImageSubDataNV (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); #endif +#endif /* GLX_NV_copy_image */ #ifndef GLX_NV_float_buffer -#define GLX_FLOAT_COMPONENTS_NV 0x20B0 -#endif - -#ifndef GLX_SGIX_hyperpipe -#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 -#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 -#define GLX_BAD_HYPERPIPE_SGIX 92 -#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 -#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 -#define GLX_PIPE_RECT_SGIX 0x00000001 -#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 -#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 -#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 -#define GLX_HYPERPIPE_ID_SGIX 0x8030 -#endif - -#ifndef GLX_MESA_agp_offset -#endif - - -/*************************************************************/ - -typedef void (*__GLXextFuncPtr)(void); - -#ifndef GLX_ARB_get_proc_address -#define GLX_ARB_get_proc_address 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern __GLXextFuncPtr glXGetProcAddress (const GLubyte *); -extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); -typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName); -#endif - - -#ifndef GLX_SGIX_video_source -typedef XID GLXVideoSourceSGIX; -#endif +#define GLX_NV_float_buffer 1 +#define GLX_FLOAT_COMPONENTS_NV 0x20B0 +#endif /* GLX_NV_float_buffer */ -#ifndef GLX_SGIX_fbconfig -typedef XID GLXFBConfigIDSGIX; -typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; -#endif +#ifndef GLX_NV_multisample_coverage +#define GLX_NV_multisample_coverage 1 +#define GLX_COVERAGE_SAMPLES_NV 100001 +#define GLX_COLOR_SAMPLES_NV 0x20B3 +#endif /* GLX_NV_multisample_coverage */ -#ifndef GLX_SGIX_pbuffer -typedef XID GLXPbufferSGIX; -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came for SendEvent request */ - Display *display; /* display the event was read from */ - GLXDrawable drawable; /* i.d. of Drawable */ - int event_type; /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */ - int draw_type; /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */ - unsigned int mask; /* mask indicating which buffers are affected*/ - int x, y; - int width, height; - int count; /* if nonzero, at least this many more */ -} GLXBufferClobberEventSGIX; +#ifndef GLX_NV_present_video +#define GLX_NV_present_video 1 +#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0 +typedef unsigned int *( *PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements); +typedef int ( *PFNGLXBINDVIDEODEVICENVPROC) (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +unsigned int *glXEnumerateVideoDevicesNV (Display *dpy, int screen, int *nelements); +int glXBindVideoDeviceNV (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); #endif +#endif /* GLX_NV_present_video */ #ifndef GLX_NV_swap_group -#endif - -#ifndef GLX_NV_video_out -/* - * GLXVideoDeviceNV is an opaque handle to a video device (part of the - * GLX_NV_video_out extension). - */ +#define GLX_NV_swap_group 1 +typedef Bool ( *PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint group); +typedef Bool ( *PFNGLXBINDSWAPBARRIERNVPROC) (Display *dpy, GLuint group, GLuint barrier); +typedef Bool ( *PFNGLXQUERYSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier); +typedef Bool ( *PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers); +typedef Bool ( *PFNGLXQUERYFRAMECOUNTNVPROC) (Display *dpy, int screen, GLuint *count); +typedef Bool ( *PFNGLXRESETFRAMECOUNTNVPROC) (Display *dpy, int screen); +#ifdef GL_GLEXT_PROTOTYPES +Bool glXJoinSwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint group); +Bool glXBindSwapBarrierNV (Display *dpy, GLuint group, GLuint barrier); +Bool glXQuerySwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier); +Bool glXQueryMaxSwapGroupsNV (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers); +Bool glXQueryFrameCountNV (Display *dpy, int screen, GLuint *count); +Bool glXResetFrameCountNV (Display *dpy, int screen); +#endif +#endif /* GLX_NV_swap_group */ + +#ifndef GLX_NV_video_capture +#define GLX_NV_video_capture 1 +typedef XID GLXVideoCaptureDeviceNV; +#define GLX_DEVICE_ID_NV 0x20CD +#define GLX_UNIQUE_ID_NV 0x20CE +#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF +typedef int ( *PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device); +typedef GLXVideoCaptureDeviceNV *( *PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display *dpy, int screen, int *nelements); +typedef void ( *PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device); +typedef int ( *PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value); +typedef void ( *PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device); +#ifdef GL_GLEXT_PROTOTYPES +int glXBindVideoCaptureDeviceNV (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device); +GLXVideoCaptureDeviceNV *glXEnumerateVideoCaptureDevicesNV (Display *dpy, int screen, int *nelements); +void glXLockVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device); +int glXQueryVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value); +void glXReleaseVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device); +#endif +#endif /* GLX_NV_video_capture */ + +#ifndef GLX_NV_video_output +#define GLX_NV_video_output 1 typedef unsigned int GLXVideoDeviceNV; - -/* glXBindVideoImageNV iVideoBuffer values (NV_video_out) */ -#define GLX_VIDEO_OUT_COLOR_NV 0x20C3 -#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4 -#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5 -#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 - -/* glXSendPbufferToVideoNV iBufferType values (NV_video_out) */ -#define GLX_VIDEO_OUT_FRAME_NV 0x20C8 -#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9 -#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA +#define GLX_VIDEO_OUT_COLOR_NV 0x20C3 +#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4 +#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5 +#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define GLX_VIDEO_OUT_FRAME_NV 0x20C8 +#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9 +#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA #define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB #define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC -#endif - -#ifndef GLX_EXT_fbconfig_packed_float -#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 -#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 -#endif - -#ifndef GLX_EXT_framebuffer_sRGB -#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 -#endif - -#ifndef GLX_EXT_texture_from_pixmap -/* New glXGetFBConfigAttrib tokens */ -#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 -#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 -#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 -#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 -#define GLX_Y_INVERTED_EXT 0x20D4 - -/* New glXCreatePixmap attributes and glXQueryDrawable attributes */ -#define GLX_TEXTURE_FORMAT_EXT 0x20D5 -#define GLX_TEXTURE_TARGET_EXT 0x20D6 -#define GLX_MIPMAP_TEXTURE_EXT 0x20D7 - -/* Values for GLX_TEXTURE_FORMAT_EXT */ -#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 -#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 -#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA - -/* Bits for GLX_BIND_TO_TEXTURE_TARGETS_EXT mask */ -#define GLX_TEXTURE_1D_BIT_EXT 0x00000001 -#define GLX_TEXTURE_2D_BIT_EXT 0x00000002 -#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 - -/* Values for GLX_TEXTURE_TARGET_EXT */ -#define GLX_TEXTURE_1D_EXT 0x20DB -#define GLX_TEXTURE_2D_EXT 0x20DC -#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD +typedef int ( *PFNGLXGETVIDEODEVICENVPROC) (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice); +typedef int ( *PFNGLXRELEASEVIDEODEVICENVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice); +typedef int ( *PFNGLXBINDVIDEOIMAGENVPROC) (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer); +typedef int ( *PFNGLXRELEASEVIDEOIMAGENVPROC) (Display *dpy, GLXPbuffer pbuf); +typedef int ( *PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock); +typedef int ( *PFNGLXGETVIDEOINFONVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#ifdef GL_GLEXT_PROTOTYPES +int glXGetVideoDeviceNV (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice); +int glXReleaseVideoDeviceNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice); +int glXBindVideoImageNV (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer); +int glXReleaseVideoImageNV (Display *dpy, GLXPbuffer pbuf); +int glXSendPbufferToVideoNV (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock); +int glXGetVideoInfoNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif +#endif /* GLX_NV_video_output */ /* - * Values for the buffer parameter of glXBindTexImageEXT and - * glXReleaseTexImageEXT - */ -#define GLX_FRONT_LEFT_EXT 0x20DE -#define GLX_FRONT_RIGHT_EXT 0x20DF -#define GLX_BACK_LEFT_EXT 0x20E0 -#define GLX_BACK_RIGHT_EXT 0x20E1 -#define GLX_FRONT_EXT GLX_FRONT_LEFT_EXT -#define GLX_BACK_EXT GLX_BACK_LEFT_EXT -#define GLX_AUX0_EXT 0x20E2 -#define GLX_AUX1_EXT 0x20E3 -#define GLX_AUX2_EXT 0x20E4 -#define GLX_AUX3_EXT 0x20E5 -#define GLX_AUX4_EXT 0x20E6 -#define GLX_AUX5_EXT 0x20E7 -#define GLX_AUX6_EXT 0x20E8 -#define GLX_AUX7_EXT 0x20E9 -#define GLX_AUX8_EXT 0x20EA -#define GLX_AUX9_EXT 0x20EB - -#endif + * GLX_NV_vertex_array_range is not a real extension name... + */ +#ifndef GLX_NV_vertex_array_range +#define GLX_NV_vertex_array_range 1 +typedef GLvoid* ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +extern GLvoid* glXAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +extern void glXFreeMemoryNV (GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +#endif /* GLX_NV_vertex_array_range */ -#ifndef GLX_NV_multisample_coverage -#define GLX_COVERAGE_SAMPLES_NV GLX_SAMPLES_ARB -#define GLX_COLOR_SAMPLES_NV 0x20B3 -#endif +#ifndef GLX_OML_swap_method +#define GLX_OML_swap_method 1 +#define GLX_SWAP_METHOD_OML 0x8060 +#define GLX_SWAP_EXCHANGE_OML 0x8061 +#define GLX_SWAP_COPY_OML 0x8062 +#define GLX_SWAP_UNDEFINED_OML 0x8063 +#endif /* GLX_OML_swap_method */ -/* Define int32_t and int64_t types for UST/MSC */ +#ifndef GLX_OML_sync_control +#define GLX_OML_sync_control 1 #ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glxext.h, so must be protected */ +/* This code block is duplicated in glext.h, so must be protected */ #define GLEXT_64_TYPES_DEFINED -#include "gl-64bit-types.h" -#endif +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GLX_OML_sync_control extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif +typedef Bool ( *PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc); +typedef Bool ( *PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); +typedef int64_t ( *PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); +typedef Bool ( *PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); +typedef Bool ( *PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); +#ifdef GL_GLEXT_PROTOTYPES +Bool glXGetSyncValuesOML (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc); +Bool glXGetMscRateOML (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); +int64_t glXSwapBuffersMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); +Bool glXWaitForMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); +Bool glXWaitForSbcOML (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); +#endif +#endif /* GLX_OML_sync_control */ -#ifndef GLX_ARB_get_proc_address -/* Moved to glx.h */ -#endif - -#ifndef GLX_ARB_multisample -#define GLX_ARB_multisample 1 -#endif - -#ifndef GLX_ARB_fbconfig_float -#define GLX_ARB_fbconfig_float 1 -#endif - -#ifndef GLX_ARB_create_context -#define GLX_ARB_create_context 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXContext glXCreateContextAttribsARB (Display *, GLXFBConfig, GLXContext, Bool, const int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); -#endif +#ifndef GLX_SGIS_blended_overlay +#define GLX_SGIS_blended_overlay 1 +#define GLX_BLENDED_RGBA_SGIS 0x8025 +#endif /* GLX_SGIS_blended_overlay */ #ifndef GLX_SGIS_multisample #define GLX_SGIS_multisample 1 -#endif - -#ifndef GLX_EXT_visual_info -#define GLX_EXT_visual_info 1 -#endif - -#ifndef GLX_MESA_swap_control -#define GLX_MESA_swap_control 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXSwapIntervalMESA(unsigned int interval); -extern int glXGetSwapIntervalMESA(void); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXSWAPINTERVALMESAPROC)(unsigned int interval); -typedef int ( * PFNGLXGETSWAPINTERVALMESAPROC)(void); -#endif - -#ifndef GLX_SGI_swap_control -#define GLX_SGI_swap_control 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXSwapIntervalSGI (int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); -#endif - -#ifndef GLX_SGI_video_sync -#define GLX_SGI_video_sync 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXGetVideoSyncSGI (unsigned int *); -extern int glXWaitVideoSyncSGI (int, int, unsigned int *); -extern int glXGetRefreshRateSGI(unsigned int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count); -typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count); -typedef int ( * PFNGLXGETREFRESHRATESGIPROC) (unsigned int *); -#endif - -#ifndef GLX_SGI_make_current_read -#define GLX_SGI_make_current_read 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXMakeCurrentReadSGI (Display *, GLXDrawable, GLXDrawable, GLXContext); -extern GLXDrawable glXGetCurrentReadDrawableSGI (void); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); -typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); -#endif - -#ifndef GLX_SGIX_video_source -#define GLX_SGIX_video_source 1 -#ifdef _VL_H -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *, int, VLServer, VLPath, int, VLNode); -extern void glXDestroyGLXVideoSourceSGIX (Display *, GLXVideoSourceSGIX); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXVideoSourceSGIX ( * PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode); -typedef void ( * PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource); -#endif /* _VL_H */ -#endif - -#ifndef GLX_EXT_visual_rating -#define GLX_EXT_visual_rating 1 -#endif - -#ifndef GLX_EXT_import_context -#define GLX_EXT_import_context 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Display * glXGetCurrentDisplayEXT (void); -extern int glXQueryContextInfoEXT (Display *, GLXContext, int, int *); -extern GLXContextID glXGetContextIDEXT (const GLXContext); -extern GLXContext glXImportContextEXT (Display *, GLXContextID); -extern void glXFreeContextEXT (Display *, GLXContext); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Display * ( * PFNGLXGETCURRENTDISPLAYEXTPROC) (void); -typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value); -typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); -typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID); -typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context); -#endif - -#ifndef GLX_SGIX_fbconfig -#define GLX_SGIX_fbconfig 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXGetFBConfigAttribSGIX (Display *, GLXFBConfigSGIX, int, int *); -extern GLXFBConfigSGIX * glXChooseFBConfigSGIX (Display *, int, int *, int *); -extern GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *, GLXFBConfigSGIX, Pixmap); -extern GLXContext glXCreateContextWithConfigSGIX (Display *, GLXFBConfigSGIX, int, GLXContext, Bool); -extern XVisualInfo * glXGetVisualFromFBConfigSGIX (Display *, GLXFBConfigSGIX); -extern GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *, XVisualInfo *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value); -typedef GLXFBConfigSGIX * ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements); -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap); -typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct); -typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config); -typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis); -#endif - -#ifndef GLX_SGIX_pbuffer -#define GLX_SGIX_pbuffer 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *); -extern void glXDestroyGLXPbufferSGIX (Display *, GLXPbufferSGIX); -extern int glXQueryGLXPbufferSGIX (Display *, GLXPbufferSGIX, int, unsigned int *); -extern void glXSelectEventSGIX (Display *, GLXDrawable, unsigned long); -extern void glXGetSelectedEventSGIX (Display *, GLXDrawable, unsigned long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXPbufferSGIX ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); -typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf); -typedef int ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); -typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask); -typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask); -#endif - -#ifndef GLX_SGI_cushion -#define GLX_SGI_cushion 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXCushionSGI (Display *, Window, float); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion); -#endif +#define GLX_SAMPLE_BUFFERS_SGIS 100000 +#define GLX_SAMPLES_SGIS 100001 +#endif /* GLX_SGIS_multisample */ -#ifndef GLX_SGIX_video_resize -#define GLX_SGIX_video_resize 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXBindChannelToWindowSGIX (Display *, int, int, Window); -extern int glXChannelRectSGIX (Display *, int, int, int, int, int, int); -extern int glXQueryChannelRectSGIX (Display *, int, int, int *, int *, int *, int *); -extern int glXQueryChannelDeltasSGIX (Display *, int, int, int *, int *, int *, int *); -extern int glXChannelRectSyncSGIX (Display *, int, int, GLenum); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window); -typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h); -typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); -typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h); -typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype); -#endif +#ifndef GLX_SGIS_shared_multisample +#define GLX_SGIS_shared_multisample 1 +#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 +#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 +#endif /* GLX_SGIS_shared_multisample */ +#if 0 /* Disabled: DMparams and DMbuffer undefined */ #ifndef GLX_SGIX_dmbuffer #define GLX_SGIX_dmbuffer 1 -#ifdef _DM_BUFFER_H_ -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXAssociateDMPbufferSGIX (Display *, GLXPbufferSGIX, DMparams *, DMbuffer); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer); -#endif /* _DM_BUFFER_H_ */ -#endif - -#ifndef GLX_SGIX_swap_group -#define GLX_SGIX_swap_group 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXJoinSwapGroupSGIX (Display *, GLXDrawable, GLXDrawable); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); -#endif - -#ifndef GLX_SGIX_swap_barrier -#define GLX_SGIX_swap_barrier 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXBindSwapBarrierSGIX (Display *, GLXDrawable, int); -extern Bool glXQueryMaxSwapBarriersSGIX (Display *, int, int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); -typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); -#endif - -#ifndef GLX_SUN_get_transparent_index -#define GLX_SUN_get_transparent_index 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Status glXGetTransparentIndexSUN (Display *, Window, Window, long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); -#endif - -#ifndef GLX_MESA_copy_sub_buffer -#define GLX_MESA_copy_sub_buffer 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXCopySubBufferMESA (Display *, GLXDrawable, int, int, int, int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height); -#endif - -#ifndef GLX_MESA_pixmap_colormap -#define GLX_MESA_pixmap_colormap 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXPixmap glXCreateGLXPixmapMESA (Display *, XVisualInfo *, Pixmap, Colormap); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); -#endif - -#ifndef GLX_MESA_release_buffers -#define GLX_MESA_release_buffers 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXReleaseBuffersMESA (Display *, GLXDrawable); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable); -#endif - -#ifndef GLX_MESA_set_3dfx_mode -#define GLX_MESA_set_3dfx_mode 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXSet3DfxModeMESA (int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXSET3DFXMODEMESAPROC) (int mode); -#endif - -#ifndef GLX_SGIX_visual_select_group -#define GLX_SGIX_visual_select_group 1 -#endif - -#ifndef GLX_OML_swap_method -#define GLX_OML_swap_method 1 +typedef XID GLXPbufferSGIX; +#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024 +typedef Bool ( *PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer); +#ifdef GL_GLEXT_PROTOTYPES +Bool glXAssociateDMPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer); #endif - -#ifndef GLX_OML_sync_control -#define GLX_OML_sync_control 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXGetSyncValuesOML (Display *, GLXDrawable, int64_t *, int64_t *, int64_t *); -extern Bool glXGetMscRateOML (Display *, GLXDrawable, int32_t *, int32_t *); -extern int64_t glXSwapBuffersMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t); -extern Bool glXWaitForMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t, int64_t *, int64_t *, int64_t *); -extern Bool glXWaitForSbcOML (Display *, GLXDrawable, int64_t, int64_t *, int64_t *, int64_t *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc); -typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); -typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); -typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); -typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); -#endif - -#ifndef GLX_NV_float_buffer -#define GLX_NV_float_buffer 1 +#endif /* GLX_SGIX_dmbuffer */ #endif +#ifndef GLX_SGIX_fbconfig +#define GLX_SGIX_fbconfig 1 +typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; +#define GLX_WINDOW_BIT_SGIX 0x00000001 +#define GLX_PIXMAP_BIT_SGIX 0x00000002 +#define GLX_RGBA_BIT_SGIX 0x00000001 +#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 +#define GLX_DRAWABLE_TYPE_SGIX 0x8010 +#define GLX_RENDER_TYPE_SGIX 0x8011 +#define GLX_X_RENDERABLE_SGIX 0x8012 +#define GLX_FBCONFIG_ID_SGIX 0x8013 +#define GLX_RGBA_TYPE_SGIX 0x8014 +#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 +typedef int ( *PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value); +typedef GLXFBConfigSGIX *( *PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements); +typedef GLXPixmap ( *PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap); +typedef GLXContext ( *PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct); +typedef XVisualInfo *( *PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config); +typedef GLXFBConfigSGIX ( *PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis); +#ifdef GL_GLEXT_PROTOTYPES +int glXGetFBConfigAttribSGIX (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value); +GLXFBConfigSGIX *glXChooseFBConfigSGIX (Display *dpy, int screen, int *attrib_list, int *nelements); +GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap); +GLXContext glXCreateContextWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct); +XVisualInfo *glXGetVisualFromFBConfigSGIX (Display *dpy, GLXFBConfigSGIX config); +GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *dpy, XVisualInfo *vis); +#endif +#endif /* GLX_SGIX_fbconfig */ + +#if 0 #ifndef GLX_SGIX_hyperpipe #define GLX_SGIX_hyperpipe 1 - typedef struct { char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; int networkId; } GLXHyperpipeNetworkSGIX; - typedef struct { char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; int channel; - unsigned int - participationType; + unsigned int participationType; int timeSlice; } GLXHyperpipeConfigSGIX; - typedef struct { char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; int srcXOrigin, srcYOrigin, srcWidth, srcHeight; int destXOrigin, destYOrigin, destWidth, destHeight; } GLXPipeRect; - typedef struct { char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; int XOrigin, YOrigin, maxHeight, maxWidth; } GLXPipeRectLimits; +#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 +#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 +#define GLX_BAD_HYPERPIPE_SGIX 92 +#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 +#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 +#define GLX_PIPE_RECT_SGIX 0x00000001 +#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 +#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 +#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 +#define GLX_HYPERPIPE_ID_SGIX 0x8030 +typedef GLXHyperpipeNetworkSGIX *( *PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); +typedef int ( *PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); +typedef GLXHyperpipeConfigSGIX *( *PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); +typedef int ( *PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); +typedef int ( *PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); +typedef int ( *PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); +typedef int ( *PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); +typedef int ( *PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); +#ifdef GL_GLEXT_PROTOTYPES +GLXHyperpipeNetworkSGIX *glXQueryHyperpipeNetworkSGIX (Display *dpy, int *npipes); +int glXHyperpipeConfigSGIX (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); +GLXHyperpipeConfigSGIX *glXQueryHyperpipeConfigSGIX (Display *dpy, int hpId, int *npipes); +int glXDestroyHyperpipeConfigSGIX (Display *dpy, int hpId); +int glXBindHyperpipeSGIX (Display *dpy, int hpId); +int glXQueryHyperpipeBestAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); +int glXHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList); +int glXQueryHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); +#endif +#endif /* GLX_SGIX_hyperpipe */ +#endif /* NOPE - GLX_SGIX_hyperpipe */ -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXHyperpipeNetworkSGIX * glXQueryHyperpipeNetworkSGIX (Display *, int *); -extern int glXHyperpipeConfigSGIX (Display *, int, int, GLXHyperpipeConfigSGIX *, int *); -extern GLXHyperpipeConfigSGIX * glXQueryHyperpipeConfigSGIX (Display *, int, int *); -extern int glXDestroyHyperpipeConfigSGIX (Display *, int); -extern int glXBindHyperpipeSGIX (Display *, int); -extern int glXQueryHyperpipeBestAttribSGIX (Display *, int, int, int, void *, void *); -extern int glXHyperpipeAttribSGIX (Display *, int, int, int, void *); -extern int glXQueryHyperpipeAttribSGIX (Display *, int, int, int, void *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); -typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); -typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); -typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); -typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); -typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); -typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); -typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); -#endif +#ifndef GLX_SGIX_pbuffer +#define GLX_SGIX_pbuffer 1 +#define GLX_PBUFFER_BIT_SGIX 0x00000004 +#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 +#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 +#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 +#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 +#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 +#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 +#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 +#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 +#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 +#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 +#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 +#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 +#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A +#define GLX_PRESERVED_CONTENTS_SGIX 0x801B +#define GLX_LARGEST_PBUFFER_SGIX 0x801C +#define GLX_WIDTH_SGIX 0x801D +#define GLX_HEIGHT_SGIX 0x801E +#define GLX_EVENT_MASK_SGIX 0x801F +#define GLX_DAMAGED_SGIX 0x8020 +#define GLX_SAVED_SGIX 0x8021 +#define GLX_WINDOW_SGIX 0x8022 +#define GLX_PBUFFER_SGIX 0x8023 -#ifndef GLX_MESA_agp_offset -#define GLX_MESA_agp_offset 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern unsigned int glXGetAGPOffsetMESA (const void *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer); +#ifndef GLX_SGIX_dmbuffer +typedef XID GLXPbufferSGIX; #endif -/* - * GLX_NV_vertex_array_range is not a real extension name... - */ -#ifndef GLX_NV_vertex_array_range -#define GLX_NV_vertex_array_range 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLvoid* glXAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -extern void glXFreeMemoryNV (GLvoid *pointer); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLvoid* ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer); +typedef GLXPbufferSGIX ( *PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); +typedef void ( *PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf); +typedef int ( *PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); +typedef void ( *PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask); +typedef void ( *PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask); +#ifdef GL_GLEXT_PROTOTYPES +GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); +void glXDestroyGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf); +int glXQueryGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); +void glXSelectEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long mask); +void glXGetSelectedEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long *mask); #endif +#endif /* GLX_SGIX_pbuffer */ -#ifndef GLX_NV_swap_group -#define GLX_NV_swap_group 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXJoinSwapGroupNV(Display *dpy, GLXDrawable drawable, - GLuint group); - -extern Bool glXBindSwapBarrierNV(Display *dpy, GLuint group, GLuint barrier); - -extern Bool glXQuerySwapGroupNV(Display *dpy, GLXDrawable drawable, - GLuint *group, GLuint *barrier); - -extern Bool glXQueryMaxSwapGroupsNV(Display *dpy, int screen, - GLuint *maxGroups, GLuint *maxBarriers); - -extern Bool glXQueryFrameCountNV(Display *dpy, int screen, GLuint *count); - -extern Bool glXResetFrameCountNV(Display *dpy, int screen); +#ifndef GLX_SGIX_swap_barrier +#define GLX_SGIX_swap_barrier 1 +typedef void ( *PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); +typedef Bool ( *PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); +#ifdef GL_GLEXT_PROTOTYPES +void glXBindSwapBarrierSGIX (Display *dpy, GLXDrawable drawable, int barrier); +Bool glXQueryMaxSwapBarriersSGIX (Display *dpy, int screen, int *max); #endif -typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, - GLXDrawable drawable, - GLuint group); - -typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display *dpy, - GLuint group, - GLuint barrier); - -typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display *dpy, - GLXDrawable drawable, - GLuint *group, - GLuint *barrier); +#endif /* GLX_SGIX_swap_barrier */ -typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display *dpy, - int screen, - GLuint *maxGroups, - GLuint *maxBarriers); - -typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display *dpy, - int screen, - GLuint *count); - -typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display *dpy, int screen); +#ifndef GLX_SGIX_swap_group +#define GLX_SGIX_swap_group 1 +typedef void ( *PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); +#ifdef GL_GLEXT_PROTOTYPES +void glXJoinSwapGroupSGIX (Display *dpy, GLXDrawable drawable, GLXDrawable member); #endif +#endif /* GLX_SGIX_swap_group */ -#ifndef GLX_NV_video_out -#define GLX_NV_video_out 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXGetVideoDeviceNV(Display *dpy, int screen, int numVideoDevices, - GLXVideoDeviceNV *pVideoDevice); - -extern int glXReleaseVideoDeviceNV(Display *dpy, int screen, - GLXVideoDeviceNV VideoDevice); - -extern int glXBindVideoImageNV(Display *dpy, GLXVideoDeviceNV VideoDevice, - GLXPbuffer pbuf, int iVideoBuffer); - -extern int glXReleaseVideoImageNV(Display *dpy, GLXPbuffer pbuf); - -extern int glXSendPbufferToVideoNV(Display *dpy, GLXPbuffer pbuf, - int iBufferType, - unsigned long *pulCounterPbuffer, - GLboolean bBlock); - -extern int glXGetVideoInfoNV(Display *dpy, int screen, - GLXVideoDeviceNV VideoDevice, - unsigned long *pulCounterOutputPbuffer, - unsigned long *pulCounterOutputVideo); +#ifndef GLX_SGIX_video_resize +#define GLX_SGIX_video_resize 1 +#define GLX_SYNC_FRAME_SGIX 0x00000000 +#define GLX_SYNC_SWAP_SGIX 0x00000001 +typedef int ( *PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window); +typedef int ( *PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h); +typedef int ( *PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); +typedef int ( *PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h); +typedef int ( *PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype); +#ifdef GL_GLEXT_PROTOTYPES +int glXBindChannelToWindowSGIX (Display *display, int screen, int channel, Window window); +int glXChannelRectSGIX (Display *display, int screen, int channel, int x, int y, int w, int h); +int glXQueryChannelRectSGIX (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); +int glXQueryChannelDeltasSGIX (Display *display, int screen, int channel, int *x, int *y, int *w, int *h); +int glXChannelRectSyncSGIX (Display *display, int screen, int channel, GLenum synctype); +#endif +#endif /* GLX_SGIX_video_resize */ + +#if 0 /* Disabled: VLServer and VLPath and VLNode undefined */ +#ifndef GLX_SGIX_video_source +#define GLX_SGIX_video_source 1 +typedef XID GLXVideoSourceSGIX; +typedef GLXVideoSourceSGIX ( *PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode); +typedef void ( *PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource); +#ifdef GL_GLEXT_PROTOTYPES +GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode); +void glXDestroyGLXVideoSourceSGIX (Display *dpy, GLXVideoSourceSGIX glxvideosource); #endif -typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display *dpy, - int screen, - int numVideoDevices, - GLXVideoDeviceNV *pVideoDevice); - -typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display *dpy, - int screen, - GLXVideoDeviceNV VideoDevice); - -typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display *dpy, - GLXVideoDeviceNV VideoDevice, - GLXPbuffer pbuf, - int iVideoBuffer); - -typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display *dpy, - GLXPbuffer pbuf); - -typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display *dpy, - GLXPbuffer pbuf, - int iBufferType, - unsigned long *pulCounterPbuffer, - GLboolean bBlock); - -typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display *dpy, int screen, - GLXVideoDeviceNV VideoDevice, - unsigned long *pulCounterOutputPbuffer, - unsigned long *pulCounterOutputVideo); +#endif /* GLX_SGIX_video_source */ #endif -#ifndef GLX_EXT_fbconfig_packed_float -#define GLX_EXT_fbconfig_packed_float 1 +#ifndef GLX_SGIX_visual_select_group +#define GLX_SGIX_visual_select_group 1 +#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 +#endif /* GLX_SGIX_visual_select_group */ + +#ifndef GLX_SGI_cushion +#define GLX_SGI_cushion 1 +typedef void ( *PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion); +#ifdef GL_GLEXT_PROTOTYPES +void glXCushionSGI (Display *dpy, Window window, float cushion); #endif +#endif /* GLX_SGI_cushion */ -#ifndef GLX_EXT_framebuffer_sRGB -#define GLX_EXT_framebuffer_sRGB 1 +#ifndef GLX_SGI_make_current_read +#define GLX_SGI_make_current_read 1 +typedef Bool ( *PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +typedef GLXDrawable ( *PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +Bool glXMakeCurrentReadSGI (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +GLXDrawable glXGetCurrentReadDrawableSGI (void); #endif +#endif /* GLX_SGI_make_current_read */ -#ifndef GLX_EXT_texture_from_pixmap -#define GLX_EXT_texture_from_pixmap -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, - int buffer, const int *attrib_list); -extern void glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, - int buffer); -#endif -typedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display *dpy, - GLXDrawable drawable, - int buffer, - const int *attrib_list); -typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, - GLXDrawable drawable, - int buffer); +#ifndef GLX_SGI_swap_control +#define GLX_SGI_swap_control 1 +typedef int ( *PFNGLXSWAPINTERVALSGIPROC) (int interval); +#ifdef GL_GLEXT_PROTOTYPES +int glXSwapIntervalSGI (int interval); #endif +#endif /* GLX_SGI_swap_control */ -#ifndef GLX_NV_present_video -#define GLX_NV_present_video 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern unsigned int* glXEnumerateVideoDevicesNV(Display *dpy, - int screen, - int *nelements); -extern int glXBindVideoDeviceNV(Display *dpy, - unsigned int video_slot, - unsigned int video_device, - const int *attrib_list); -#endif -typedef unsigned int* ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, - int screen, - int *nelements); -typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display *dpy, - unsigned int video_slot, - unsigned int video_device, - const int *attrib_list); +#ifndef GLX_SGI_video_sync +#define GLX_SGI_video_sync 1 +typedef int ( *PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count); +typedef int ( *PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count); +#ifdef GL_GLEXT_PROTOTYPES +int glXGetVideoSyncSGI (unsigned int *count); +int glXWaitVideoSyncSGI (int divisor, int remainder, unsigned int *count); #endif +#endif /* GLX_SGI_video_sync */ -#ifndef GLX_NV_multisample_coverage -#define GLX_NV_multisample_coverage 1 +#ifndef GLX_SUN_get_transparent_index +#define GLX_SUN_get_transparent_index 1 +typedef Status ( *PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); +#ifdef GL_GLEXT_PROTOTYPES +Status glXGetTransparentIndexSUN (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); #endif +#endif /* GLX_SUN_get_transparent_index */ #ifdef __cplusplus } #endif -#endif // __glxext_h_ +#endif diff --git a/make/stub_includes/opengl/GL/wglext.h b/make/stub_includes/opengl/GL/wglext.h index a34c63c43..ed5d6a7db 100644 --- a/make/stub_includes/opengl/GL/wglext.h +++ b/make/stub_includes/opengl/GL/wglext.h @@ -1,47 +1,39 @@ #ifndef __wglext_h_ -#define __wglext_h_ +#define __wglext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** NOTE: The Original Code (as defined below) has been licensed to Sun -** Microsystems, Inc. ("Sun") under the SGI Free Software License B -** (Version 1.1), shown above ("SGI License"). Pursuant to Section -** 3.2(3) of the SGI License, Sun is distributing the Covered Code to -** you under an alternative license ("Alternative License"). This -** Alternative License includes all of the provisions of the SGI License -** except that Section 2.2 and 11 are omitted. Any differences between -** the Alternative License and the SGI License are offered solely by Sun -** and not by SGI. +** Copyright (c) 2013 The Khronos Group Inc. ** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: This software was created using the -** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has -** not been independently verified as being compliant with the OpenGL(R) -** version 1.2.1 Specification. +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision$ on $Date$ */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -49,591 +41,505 @@ extern "C" { #include #endif -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number */ -/* wglext.h last updated 2006/08/17 */ -/* Current version at http://www.opengl.org/registry/ */ -#define WGL_WGLEXT_VERSION 8 - -#ifndef WGL_ARB_buffer_region -#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 -#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 -#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 -#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 -#endif - -#ifndef WGL_ARB_multisample -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 -#endif - -#ifndef WGL_ARB_extensions_string -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#endif - -#ifndef WGL_ARB_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 -#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 -#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define WGL_TEXTURE_FORMAT_ARB 0x2072 -#define WGL_TEXTURE_TARGET_ARB 0x2073 -#define WGL_MIPMAP_TEXTURE_ARB 0x2074 -#define WGL_TEXTURE_RGB_ARB 0x2075 -#define WGL_TEXTURE_RGBA_ARB 0x2076 -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 -#define WGL_TEXTURE_1D_ARB 0x2079 -#define WGL_TEXTURE_2D_ARB 0x207A -#define WGL_MIPMAP_LEVEL_ARB 0x207B -#define WGL_CUBE_MAP_FACE_ARB 0x207C -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 -#define WGL_FRONT_LEFT_ARB 0x2083 -#define WGL_FRONT_RIGHT_ARB 0x2084 -#define WGL_BACK_LEFT_ARB 0x2085 -#define WGL_BACK_RIGHT_ARB 0x2086 -#define WGL_AUX0_ARB 0x2087 -#define WGL_AUX1_ARB 0x2088 -#define WGL_AUX2_ARB 0x2089 -#define WGL_AUX3_ARB 0x208A -#define WGL_AUX4_ARB 0x208B -#define WGL_AUX5_ARB 0x208C -#define WGL_AUX6_ARB 0x208D -#define WGL_AUX7_ARB 0x208E -#define WGL_AUX8_ARB 0x208F -#define WGL_AUX9_ARB 0x2090 -#endif +#define WGL_WGLEXT_VERSION 20130614 -#ifndef WGL_ARB_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 -#endif - -#ifndef WGL_ARB_create_context -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define ERROR_INVALID_VERSION_ARB 0x2095 -#endif - -#ifndef WGL_ARB_create_context_robustness -#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 -#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#endif - -#ifndef WGL_EXT_create_context_es2_profile -#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 -#endif - -#ifndef WGL_EXT_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 -#define WGL_DRAW_TO_WINDOW_EXT 0x2001 -#define WGL_DRAW_TO_BITMAP_EXT 0x2002 -#define WGL_ACCELERATION_EXT 0x2003 -#define WGL_NEED_PALETTE_EXT 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 -#define WGL_SWAP_METHOD_EXT 0x2007 -#define WGL_NUMBER_OVERLAYS_EXT 0x2008 -#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 -#define WGL_TRANSPARENT_EXT 0x200A -#define WGL_TRANSPARENT_VALUE_EXT 0x200B -#define WGL_SHARE_DEPTH_EXT 0x200C -#define WGL_SHARE_STENCIL_EXT 0x200D -#define WGL_SHARE_ACCUM_EXT 0x200E -#define WGL_SUPPORT_GDI_EXT 0x200F -#define WGL_SUPPORT_OPENGL_EXT 0x2010 -#define WGL_DOUBLE_BUFFER_EXT 0x2011 -#define WGL_STEREO_EXT 0x2012 -#define WGL_PIXEL_TYPE_EXT 0x2013 -#define WGL_COLOR_BITS_EXT 0x2014 -#define WGL_RED_BITS_EXT 0x2015 -#define WGL_RED_SHIFT_EXT 0x2016 -#define WGL_GREEN_BITS_EXT 0x2017 -#define WGL_GREEN_SHIFT_EXT 0x2018 -#define WGL_BLUE_BITS_EXT 0x2019 -#define WGL_BLUE_SHIFT_EXT 0x201A -#define WGL_ALPHA_BITS_EXT 0x201B -#define WGL_ALPHA_SHIFT_EXT 0x201C -#define WGL_ACCUM_BITS_EXT 0x201D -#define WGL_ACCUM_RED_BITS_EXT 0x201E -#define WGL_ACCUM_GREEN_BITS_EXT 0x201F -#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 -#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 -#define WGL_DEPTH_BITS_EXT 0x2022 -#define WGL_STENCIL_BITS_EXT 0x2023 -#define WGL_AUX_BUFFERS_EXT 0x2024 -#define WGL_NO_ACCELERATION_EXT 0x2025 -#define WGL_GENERIC_ACCELERATION_EXT 0x2026 -#define WGL_FULL_ACCELERATION_EXT 0x2027 -#define WGL_SWAP_EXCHANGE_EXT 0x2028 -#define WGL_SWAP_COPY_EXT 0x2029 -#define WGL_SWAP_UNDEFINED_EXT 0x202A -#define WGL_TYPE_RGBA_EXT 0x202B -#define WGL_TYPE_COLORINDEX_EXT 0x202C -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_DRAW_TO_PBUFFER_EXT 0x202D -#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E -#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 -#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 -#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 -#define WGL_PBUFFER_LARGEST_EXT 0x2033 -#define WGL_PBUFFER_WIDTH_EXT 0x2034 -#define WGL_PBUFFER_HEIGHT_EXT 0x2035 -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_DEPTH_FLOAT_EXT 0x2040 -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 -#define WGL_SAMPLES_3DFX 0x2061 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_SAMPLE_BUFFERS_EXT 0x2041 -#define WGL_SAMPLES_EXT 0x2042 -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 -#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 -#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 -#endif - -#ifndef WGL_I3D_gamma -#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E -#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F -#endif - -#ifndef WGL_I3D_genlock -#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 -#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 -#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 -#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 -#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 -#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 -#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A -#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B -#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 -#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 -#endif - -#ifndef WGL_I3D_swap_frame_lock -#endif - -#ifndef WGL_NV_render_depth_texture -#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 -#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 -#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 -#define WGL_DEPTH_COMPONENT_NV 0x20A7 -#endif - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 -#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 -#define WGL_RGBA_FLOAT_MODE_ATI 0x8820 -#define WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_FLOAT_COMPONENTS_NV 0x20B0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 -#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 -#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 -#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 -#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 -#endif - -#ifndef WGL_3DL_stereo_control -#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 -#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 -#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 -#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 -#endif - -#ifndef WGL_NV_swap_group -#endif - -#ifndef WGL_NV_gpu_affinity -#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 -#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 -#endif - -/*************************************************************/ - -/* NOTE: following DECLARE_HANDLE macros have to be elided (PCPP - doesn't support them); effects placed in stub_includes/win32/windows.h */ -#ifndef SKIP_WGL_HANDLE_DEFINITIONS -#ifndef WGL_ARB_pbuffer -DECLARE_HANDLE(HPBUFFERARB); -#endif -#ifndef WGL_EXT_pbuffer -DECLARE_HANDLE(HPBUFFEREXT); -#endif -#endif /* !SKIP_WGL_HANDLE_DEFINITIONS */ - -#ifndef WGL_NV_gpu_affinity -#ifndef SKIP_WGL_HANDLE_DEFINITIONS -DECLARE_HANDLE(HGPUNV); -#endif /* !SKIP_WGL_HANDLE_DEFINITIONS */ -typedef struct _GPU_DEVICE { - DWORD cb; - CHAR DeviceName[32]; - CHAR DeviceString[128]; - DWORD Flags; - RECT rcVirtualScreen; -} GPU_DEVICE, *PGPU_DEVICE; -#endif +/* Generated C header for: + * API: wgl + * Versions considered: .* + * Versions emitted: _nomatch_^ + * Default extensions included: wgl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ #ifndef WGL_ARB_buffer_region #define WGL_ARB_buffer_region 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HANDLE WINAPI wglCreateBufferRegionARB (HDC, int, UINT); -extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE); -extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE, int, int, int, int); -extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE, int, int, int, int, int, int); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#ifdef GL_GLEXT_PROTOTYPES +HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); +VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); +BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); +BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); #endif +#endif /* WGL_ARB_buffer_region */ -#ifndef WGL_ARB_multisample -#define WGL_ARB_multisample 1 -#endif +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context 1 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define ERROR_INVALID_VERSION_ARB 0x2095 +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); +#ifdef GL_GLEXT_PROTOTYPES +HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); +#endif +#endif /* WGL_ARB_create_context */ + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile 1 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define ERROR_INVALID_PROFILE_ARB 0x2096 +#endif /* WGL_ARB_create_context_profile */ + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness 1 +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif /* WGL_ARB_create_context_robustness */ #ifndef WGL_ARB_extensions_string #define WGL_ARB_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringARB (HDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +#ifdef GL_GLEXT_PROTOTYPES +const char *WINAPI wglGetExtensionsStringARB (HDC hdc); #endif +#endif /* WGL_ARB_extensions_string */ -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC, int, int, UINT, const int *, int *); -extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC, int, int, UINT, const int *, FLOAT *); -extern BOOL WINAPI wglChoosePixelFormatARB (HDC, const int *, const FLOAT *, UINT, int *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#endif /* WGL_ARB_framebuffer_sRGB */ #ifndef WGL_ARB_make_current_read #define WGL_ARB_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentARB (HDC, HDC, HGLRC); -extern HDC WINAPI wglGetCurrentReadDCARB (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCARB (void); #endif +#endif /* WGL_ARB_make_current_read */ + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif /* WGL_ARB_multisample */ #ifndef WGL_ARB_pbuffer #define WGL_ARB_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC, int, int, int, const int *); -extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB); -extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB, HDC); -extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB); -extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB, int, int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#ifndef SKIP_WGL_HANDLE_DEFINITIONS +DECLARE_HANDLE(HPBUFFERARB); +#endif /* SKIP_WGL_HANDLE_DEFINITIONS */ +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#ifdef GL_GLEXT_PROTOTYPES +HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); +int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); +BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_ARB_pbuffer */ + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); #endif +#endif /* WGL_ARB_pixel_format */ + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif /* WGL_ARB_pixel_format_float */ #ifndef WGL_ARB_render_texture #define WGL_ARB_render_texture 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB, int); -extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB, int); -extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB, const int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); #endif +#endif /* WGL_ARB_render_texture */ -#ifndef WGL_ARB_pixel_format_float -#define WGL_ARB_pixel_format_float 1 -#endif +#ifndef WGL_ARB_robustness_application_isolation +#define WGL_ARB_robustness_application_isolation 1 +#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 +#endif /* WGL_ARB_robustness_application_isolation */ -#ifndef WGL_ARB_create_context -#define WGL_ARB_create_context 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HGLRC WINAPI wglCreateContextAttribsARB(HDC hDC, HGLRC hshareContext, const int *attribList); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hshareContext, const int *attribList); -#endif +#ifndef WGL_ARB_robustness_share_group_isolation +#define WGL_ARB_robustness_share_group_isolation 1 +#endif /* WGL_ARB_robustness_share_group_isolation */ + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 +#endif /* WGL_3DFX_multisample */ + +#ifndef WGL_3DL_stereo_control +#define WGL_3DL_stereo_control 1 +#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 +#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 +#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 +#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 +typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); +#endif +#endif /* WGL_3DL_stereo_control */ + +#ifndef WGL_AMD_gpu_association +#define WGL_AMD_gpu_association 1 +#define WGL_GPU_VENDOR_AMD 0x1F00 +#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 +#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define WGL_GPU_RAM_AMD 0x21A3 +#define WGL_GPU_CLOCK_AMD 0x21A4 +#define WGL_GPU_NUM_PIPES_AMD 0x21A5 +#define WGL_GPU_NUM_SIMD_AMD 0x21A6 +#define WGL_GPU_NUM_RB_AMD 0x21A7 +#define WGL_GPU_NUM_SPI_AMD 0x21A8 +typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); +typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); +typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); +typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); +typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); +typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); +INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data); +UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); +HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); +HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); +BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); +BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); +HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); +VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* WGL_AMD_gpu_association */ + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#endif /* WGL_ATI_pixel_format_float */ + +#ifndef WGL_EXT_create_context_es2_profile +#define WGL_EXT_create_context_es2_profile 1 +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es2_profile */ + +#ifndef WGL_EXT_create_context_es_profile +#define WGL_EXT_create_context_es_profile 1 +#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es_profile */ + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 +#define WGL_DEPTH_FLOAT_EXT 0x2040 +#endif /* WGL_EXT_depth_float */ #ifndef WGL_EXT_display_color_table #define WGL_EXT_display_color_table 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort); -extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *, GLuint); -extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort); -extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +#ifdef GL_GLEXT_PROTOTYPES +GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); +GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); +GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); +VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); #endif +#endif /* WGL_EXT_display_color_table */ #ifndef WGL_EXT_extensions_string #define WGL_EXT_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +const char *WINAPI wglGetExtensionsStringEXT (void); #endif +#endif /* WGL_EXT_extensions_string */ + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_EXT_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 +#endif /* WGL_EXT_framebuffer_sRGB */ #ifndef WGL_EXT_make_current_read #define WGL_EXT_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentEXT (HDC, HDC, HGLRC); -extern HDC WINAPI wglGetCurrentReadDCEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCEXT (void); #endif +#endif /* WGL_EXT_make_current_read */ + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 +#endif /* WGL_EXT_multisample */ #ifndef WGL_EXT_pbuffer #define WGL_EXT_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC, int, int, int, const int *); -extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT); -extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT, HDC); -extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT); -extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT, int, int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#ifndef SKIP_WGL_HANDLE_DEFINITIONS +DECLARE_HANDLE(HPBUFFEREXT); +#endif /* SKIP_WGL_HANDLE_DEFINITIONS */ +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#ifdef GL_GLEXT_PROTOTYPES +HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); +int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); +BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); #endif +#endif /* WGL_EXT_pbuffer */ #ifndef WGL_EXT_pixel_format #define WGL_EXT_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC, int, int, UINT, int *, int *); -extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC, int, int, UINT, int *, FLOAT *); -extern BOOL WINAPI wglChoosePixelFormatEXT (HDC, const int *, const FLOAT *, UINT, int *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); #endif +#endif /* WGL_EXT_pixel_format */ + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_EXT_pixel_format_packed_float 1 +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 +#endif /* WGL_EXT_pixel_format_packed_float */ #ifndef WGL_EXT_swap_control #define WGL_EXT_swap_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglSwapIntervalEXT (int); -extern int WINAPI wglGetSwapIntervalEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglSwapIntervalEXT (int interval); +int WINAPI wglGetSwapIntervalEXT (void); #endif +#endif /* WGL_EXT_swap_control */ -#ifndef WGL_EXT_depth_float -#define WGL_EXT_depth_float 1 -#endif - -#ifndef WGL_NV_vertex_array_range -#define WGL_NV_vertex_array_range 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern void* WINAPI wglAllocateMemoryNV (GLsizei, GLfloat, GLfloat, GLfloat); -extern void WINAPI wglFreeMemoryNV (void *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_3DFX_multisample 1 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_EXT_multisample 1 -#endif - -#ifndef WGL_OML_sync_control -#define WGL_OML_sync_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetSyncValuesOML (HDC, INT64 *, INT64 *, INT64 *); -extern BOOL WINAPI wglGetMscRateOML (HDC, INT32 *, INT32 *); -extern INT64 WINAPI wglSwapBuffersMscOML (HDC, INT64, INT64, INT64); -extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC, int, INT64, INT64, INT64); -extern BOOL WINAPI wglWaitForMscOML (HDC, INT64, INT64, INT64, INT64 *, INT64 *, INT64 *); -extern BOOL WINAPI wglWaitForSbcOML (HDC, INT64, INT64 *, INT64 *, INT64 *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); -typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); -#endif +#ifndef WGL_EXT_swap_control_tear +#define WGL_EXT_swap_control_tear 1 +#endif /* WGL_EXT_swap_control_tear */ #ifndef WGL_I3D_digital_video_control #define WGL_I3D_digital_video_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC, int, int *); -extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC, int, const int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); #endif +#endif /* WGL_I3D_digital_video_control */ #ifndef WGL_I3D_gamma #define WGL_I3D_gamma 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC, int, int *); -extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC, int, const int *); -extern BOOL WINAPI wglGetGammaTableI3D (HDC, int, USHORT *, USHORT *, USHORT *); -extern BOOL WINAPI wglSetGammaTableI3D (HDC, int, const USHORT *, const USHORT *, const USHORT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); +BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); #endif +#endif /* WGL_I3D_gamma */ #ifndef WGL_I3D_genlock #define WGL_I3D_genlock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableGenlockI3D (HDC); -extern BOOL WINAPI wglDisableGenlockI3D (HDC); -extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC, BOOL *); -extern BOOL WINAPI wglGenlockSourceI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSampleRateI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC, UINT *); -extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC, UINT *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); @@ -646,108 +552,283 @@ typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate) typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); -#endif +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglEnableGenlockI3D (HDC hDC); +BOOL WINAPI wglDisableGenlockI3D (HDC hDC); +BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); +BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); +BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); +BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); +BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); +BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); +BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); +BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); +BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); +BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#endif +#endif /* WGL_I3D_genlock */ #ifndef WGL_I3D_image_buffer #define WGL_I3D_image_buffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern LPVOID WINAPI wglCreateImageBufferI3D (HDC, DWORD, UINT); -extern BOOL WINAPI wglDestroyImageBufferI3D (HDC, LPVOID); -extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC, const HANDLE *, const LPVOID *, const DWORD *, UINT); -extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC, const LPVOID *, UINT); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); +#ifdef GL_GLEXT_PROTOTYPES +LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); +BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); +BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); #endif +#endif /* WGL_I3D_image_buffer */ #ifndef WGL_I3D_swap_frame_lock #define WGL_I3D_swap_frame_lock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableFrameLockI3D (void); -extern BOOL WINAPI wglDisableFrameLockI3D (void); -extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *); -extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglEnableFrameLockI3D (void); +BOOL WINAPI wglDisableFrameLockI3D (void); +BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); +BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); #endif +#endif /* WGL_I3D_swap_frame_lock */ #ifndef WGL_I3D_swap_frame_usage #define WGL_I3D_swap_frame_usage 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetFrameUsageI3D (float *); -extern BOOL WINAPI wglBeginFrameTrackingI3D (void); -extern BOOL WINAPI wglEndFrameTrackingI3D (void); -extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *, DWORD *, float *); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_ATI_pixel_format_float 1 -#endif +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); +BOOL WINAPI wglBeginFrameTrackingI3D (void); +BOOL WINAPI wglEndFrameTrackingI3D (void); +BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#endif +#endif /* WGL_I3D_swap_frame_usage */ + +#ifndef WGL_NV_DX_interop +#define WGL_NV_DX_interop 1 +#define WGL_ACCESS_READ_ONLY_NV 0x00000000 +#define WGL_ACCESS_READ_WRITE_NV 0x00000001 +#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 +typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); +typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); +typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); +typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); +typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); +HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); +BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); +HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); +BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); +BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +#endif +#endif /* WGL_NV_DX_interop */ + +#ifndef WGL_NV_DX_interop2 +#define WGL_NV_DX_interop2 1 +#endif /* WGL_NV_DX_interop2 */ + +#ifndef WGL_NV_copy_image +#define WGL_NV_copy_image 1 +typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* WGL_NV_copy_image */ #ifndef WGL_NV_float_buffer #define WGL_NV_float_buffer 1 -#endif +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 +#endif /* WGL_NV_float_buffer */ + +#ifndef WGL_NV_gpu_affinity +#define WGL_NV_gpu_affinity 1 +#ifndef SKIP_WGL_HANDLE_DEFINITIONS +DECLARE_HANDLE(HGPUNV); +#endif /* SKIP_WGL_HANDLE_DEFINITIONS */ +struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; +}; +typedef struct _GPU_DEVICE *PGPU_DEVICE; +#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 +#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 +typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); +typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); +typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); +BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); +BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +BOOL WINAPI wglDeleteDCNV (HDC hdc); +#endif +#endif /* WGL_NV_gpu_affinity */ + +#ifndef WGL_NV_multisample_coverage +#define WGL_NV_multisample_coverage 1 +#define WGL_COVERAGE_SAMPLES_NV 0x2042 +#define WGL_COLOR_SAMPLES_NV 0x20B9 +#endif /* WGL_NV_multisample_coverage */ + +#ifndef WGL_NV_present_video +#define WGL_NV_present_video 1 +#ifndef SKIP_WGL_HANDLE_DEFINITIONS +DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); +#endif /* SKIP_WGL_HANDLE_DEFINITIONS */ +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 +typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); +#ifdef GL_GLEXT_PROTOTYPES +int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); +#endif +#endif /* WGL_NV_present_video */ + +#ifndef WGL_NV_render_depth_texture +#define WGL_NV_render_depth_texture 1 +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 +#endif /* WGL_NV_render_depth_texture */ + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_NV_render_texture_rectangle 1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 +#endif /* WGL_NV_render_texture_rectangle */ #ifndef WGL_NV_swap_group #define WGL_NV_swap_group 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglJoinSwapGroupNV(HDC hDC, GLuint group); -extern BOOL WINAPI wglBindSwapBarrierNV(GLuint group, GLuint barrier); -extern BOOL WINAPI wglQuerySwapGroupNV(HDC hDC, GLuint *group, GLuint *barrier); -extern BOOL WINAPI wglQueryMaxSwapGroupsNV(HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); -extern BOOL WINAPI wglQueryFrameCountNV(HDC hDC, GLuint *count); -extern BOOL WINAPI wglResetFrameCountNV(HDC hDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); +BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); +BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); +BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); +BOOL WINAPI wglResetFrameCountNV (HDC hDC); #endif +#endif /* WGL_NV_swap_group */ -#ifndef WGL_NV_gpu_affinity -#define WGL_NV_gpu_affinity 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnumGpusNV (UINT iIndex, HGPUNV *hGpu); -extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iIndex, PGPU_DEVICE pGpuDevice); -extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *pGpuList); -extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iIndex, HGPUNV *hGpu); -extern BOOL WINAPI wglDeleteDCNV (HDC hAffinityDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iIndex, HGPUNV *hGpu); -typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iIndex, PGPU_DEVICE pGpuDevice); -typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *pGpuList); -typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iIndex, HGPUNV *hGpu); -typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hAffinityDC); -#endif - -/* - * ----------------------------------------------------------- - * Everything here and below was added manually - * by ckline and kbr to the version of wglext.h obtained from: - * http://oss.sgi.com/projects/ogl-sample/registry/index.html - * ----------------------------------------------------------- - */ - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_NV_render_texture_rectangle 1 +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 +typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +void WINAPI wglFreeMemoryNV (void *pointer); #endif +#endif /* WGL_NV_vertex_array_range */ -#ifndef WGL_NV_render_depth_texture -#define WGL_NV_render_depth_texture 1 -#endif +#ifndef WGL_NV_video_capture +#define WGL_NV_video_capture 1 +#ifndef SKIP_WGL_HANDLE_DEFINITIONS +DECLARE_HANDLE(HVIDEOINPUTDEVICENV); +#endif /* SKIP_WGL_HANDLE_DEFINITIONS */ +#define WGL_UNIQUE_ID_NV 0x20CE +#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF +typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#endif +#endif /* WGL_NV_video_capture */ + +#ifndef WGL_NV_video_output +#define WGL_NV_video_output 1 +#ifndef SKIP_WGL_HANDLE_DEFINITIONS +DECLARE_HANDLE(HPVIDEODEV); +#endif /* SKIP_WGL_HANDLE_DEFINITIONS */ +#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 +#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 +#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 +#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 +#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 +#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 +#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define WGL_VIDEO_OUT_FRAME 0x20C8 +#define WGL_VIDEO_OUT_FIELD_1 0x20C9 +#define WGL_VIDEO_OUT_FIELD_2 0x20CA +#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB +#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC +typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); +typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); +BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif +#endif /* WGL_NV_video_output */ +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 +typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); +typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); +INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#endif +#endif /* WGL_OML_sync_control */ #ifdef __cplusplus } diff --git a/make/stub_includes/opengl/GL3/gl3.h b/make/stub_includes/opengl/GL3/gl3.h deleted file mode 100644 index d66d49d91..000000000 --- a/make/stub_includes/opengl/GL3/gl3.h +++ /dev/null @@ -1,3606 +0,0 @@ -#ifndef __gl3_h_ -#define __gl3_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007-2012 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* This is a draft release of gl3.h, a header for use with OpenGL 3.1, and - * 3.2 and later core profile implementations. The current version is - * available at http://www.opengl.org/registry/ . Please don't package - * gl3.h for release with other software until it's out of draft status. - * The structure of the file may change significantly, and the details - * will probably change slightly as we make sure exactly the right set - * of interfaces is included. - * - * gl3.h last updated on $Date: 2012-01-26 02:57:23 -0800 (Thu, 26 Jan 2012) $ - * - * RELEASE NOTES - 2012/01/26 - * - * gl3.h should be placed under a directory 'GL3' and included as - * ''. - * - * gl3.h is supposed to only include APIs in a OpenGL 3.1 (without - * GL_ARB_compatibility) or OpenGL 3.2-4.2 (inclusive) core profile - * implementation, as well as interfaces for newer ARB extensions which - * can be supported by the core profile. It does not, and never will - * include functionality removed from the core profile, such as - * fixed-function vertex and fragment processing. - * - * Implementations of OpenGL 3.1 supporting the optional - * GL_ARB_compatibility extension continue to provide that functionality, - * as do implementations of the OpenGL 3.2+ compatibility profiles, and - * source code requiring it should use the traditional and - * headers instead of . - * - * It is not possible to #include both and either of - * or in the same source file. - * - * We welcome feedback on gl3.h. Please register for the Khronos Bugzilla - * (www.khronos.org/bugzilla) and file issues there under product - * "OpenGL", category "Registry". Feedback on the opengl.org forums - * may not be responded to in a timely fashion. - */ - -/* Function declaration macros - to move into glplatform.h */ -#include "glplatform.h" - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/* Base GL types */ - -typedef unsigned int GLenum; -typedef unsigned char GLboolean; -typedef unsigned int GLbitfield; -typedef signed char GLbyte; -typedef short GLshort; -typedef int GLint; -typedef int GLsizei; -typedef unsigned char GLubyte; -typedef unsigned short GLushort; -typedef unsigned int GLuint; -typedef unsigned short GLhalf; -typedef float GLfloat; -typedef float GLclampf; -typedef double GLdouble; -typedef double GLclampd; -typedef void GLvoid; - -/*************************************************************/ - -#ifndef GL_VERSION_1_1 -/* AttribMask */ -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 -/* Boolean */ -#define GL_FALSE 0 -#define GL_TRUE 1 -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -/* AlphaFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -/* BlendingFactorSrc */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* DrawBufferMode */ -#define GL_NONE 0 -#define GL_FRONT_LEFT 0x0400 -#define GL_FRONT_RIGHT 0x0401 -#define GL_BACK_LEFT 0x0402 -#define GL_BACK_RIGHT 0x0403 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_LEFT 0x0406 -#define GL_RIGHT 0x0407 -#define GL_FRONT_AND_BACK 0x0408 -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_OUT_OF_MEMORY 0x0505 -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 -/* GetPName */ -#define GL_POINT_SIZE 0x0B11 -#define GL_POINT_SIZE_RANGE 0x0B12 -#define GL_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_LINE_SMOOTH 0x0B20 -#define GL_LINE_WIDTH 0x0B21 -#define GL_LINE_WIDTH_RANGE 0x0B22 -#define GL_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_POLYGON_SMOOTH 0x0B41 -#define GL_CULL_FACE 0x0B44 -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_TEST 0x0B71 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_TEST 0x0B90 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_VIEWPORT 0x0BA2 -#define GL_DITHER 0x0BD0 -#define GL_BLEND_DST 0x0BE0 -#define GL_BLEND_SRC 0x0BE1 -#define GL_BLEND 0x0BE2 -#define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_COLOR_LOGIC_OP 0x0BF2 -#define GL_DRAW_BUFFER 0x0C01 -#define GL_READ_BUFFER 0x0C02 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_DOUBLEBUFFER 0x0C32 -#define GL_STEREO 0x0C33 -#define GL_LINE_SMOOTH_HINT 0x0C52 -#define GL_POLYGON_SMOOTH_HINT 0x0C53 -#define GL_UNPACK_SWAP_BYTES 0x0CF0 -#define GL_UNPACK_LSB_FIRST 0x0CF1 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_SWAP_BYTES 0x0D00 -#define GL_PACK_LSB_FIRST 0x0D01 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_TEXTURE_1D 0x0DE0 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_POINT 0x2A01 -#define GL_POLYGON_OFFSET_LINE 0x2A02 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_1D 0x8068 -#define GL_TEXTURE_BINDING_2D 0x8069 -/* GetTextureParameter */ -#define GL_TEXTURE_WIDTH 0x1000 -#define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#define GL_TEXTURE_BORDER_COLOR 0x1004 -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_DOUBLE 0x140A -/* LogicOp */ -#define GL_CLEAR 0x1500 -#define GL_AND 0x1501 -#define GL_AND_REVERSE 0x1502 -#define GL_COPY 0x1503 -#define GL_AND_INVERTED 0x1504 -#define GL_NOOP 0x1505 -#define GL_XOR 0x1506 -#define GL_OR 0x1507 -#define GL_NOR 0x1508 -#define GL_EQUIV 0x1509 -#define GL_INVERT 0x150A -#define GL_OR_REVERSE 0x150B -#define GL_COPY_INVERTED 0x150C -#define GL_OR_INVERTED 0x150D -#define GL_NAND 0x150E -#define GL_SET 0x150F -/* MatrixMode (for gl3.h, FBO attachment type) */ -#define GL_TEXTURE 0x1702 -/* PixelCopyType */ -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 -/* PixelFormat */ -#define GL_STENCIL_INDEX 0x1901 -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_RED 0x1903 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -/* PolygonMode */ -#define GL_POINT 0x1B00 -#define GL_LINE 0x1B01 -#define GL_FILL 0x1B02 -/* StencilOp */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 -/* TextureMinFilter */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -/* TextureTarget */ -#define GL_PROXY_TEXTURE_1D 0x8063 -#define GL_PROXY_TEXTURE_2D 0x8064 -/* TextureWrapMode */ -#define GL_REPEAT 0x2901 -/* PixelInternalFormat */ -#define GL_R3_G3_B2 0x2A10 -#define GL_RGB4 0x804F -#define GL_RGB5 0x8050 -#define GL_RGB8 0x8051 -#define GL_RGB10 0x8052 -#define GL_RGB12 0x8053 -#define GL_RGB16 0x8054 -#define GL_RGBA2 0x8055 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_RGBA12 0x805A -#define GL_RGBA16 0x805B -#endif - -#ifndef GL_VERSION_1_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif - -#ifndef GL_ARB_imaging -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#endif - -#ifndef GL_VERSION_1_3 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#endif - -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#endif - -#ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_VERSION_2_1 -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#endif - -#ifndef GL_VERSION_3_0 -#define GL_COMPARE_REF_TO_TEXTURE 0x884E -#define GL_CLIP_DISTANCE0 0x3000 -#define GL_CLIP_DISTANCE1 0x3001 -#define GL_CLIP_DISTANCE2 0x3002 -#define GL_CLIP_DISTANCE3 0x3003 -#define GL_CLIP_DISTANCE4 0x3004 -#define GL_CLIP_DISTANCE5 0x3005 -#define GL_CLIP_DISTANCE6 0x3006 -#define GL_CLIP_DISTANCE7 0x3007 -#define GL_MAX_CLIP_DISTANCES 0x0D32 -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_CONTEXT_FLAGS 0x821E -#define GL_DEPTH_BUFFER 0x8223 // n/a in spec, but other header files -#define GL_STENCIL_BUFFER 0x8224 // n/a in spec, but other header files -#define GL_COMPRESSED_RED 0x8225 -#define GL_COMPRESSED_RG 0x8226 -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 -#define GL_RGBA32F 0x8814 -#define GL_RGB32F 0x8815 -#define GL_RGBA16F 0x881A -#define GL_RGB16F 0x881B -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_CLAMP_READ_COLOR 0x891C -#define GL_FIXED_ONLY 0x891D -#define GL_MAX_VARYING_COMPONENTS 0x8B4B -#define GL_TEXTURE_1D_ARRAY 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define GL_R11F_G11F_B10F 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define GL_RGB9_E5 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define GL_PRIMITIVES_GENERATED 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define GL_RASTERIZER_DISCARD 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define GL_INTERLEAVED_ATTRIBS 0x8C8C -#define GL_SEPARATE_ATTRIBS 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define GL_RGBA32UI 0x8D70 -#define GL_RGB32UI 0x8D71 -#define GL_RGBA16UI 0x8D76 -#define GL_RGB16UI 0x8D77 -#define GL_RGBA8UI 0x8D7C -#define GL_RGB8UI 0x8D7D -#define GL_RGBA32I 0x8D82 -#define GL_RGB32I 0x8D83 -#define GL_RGBA16I 0x8D88 -#define GL_RGB16I 0x8D89 -#define GL_RGBA8I 0x8D8E -#define GL_RGB8I 0x8D8F -#define GL_RED_INTEGER 0x8D94 -#define GL_GREEN_INTEGER 0x8D95 -#define GL_BLUE_INTEGER 0x8D96 -#define GL_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_BGR_INTEGER 0x8D9A -#define GL_BGRA_INTEGER 0x8D9B -#define GL_SAMPLER_1D_ARRAY 0x8DC0 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define GL_UNSIGNED_INT_VEC2 0x8DC6 -#define GL_UNSIGNED_INT_VEC3 0x8DC7 -#define GL_UNSIGNED_INT_VEC4 0x8DC8 -#define GL_INT_SAMPLER_1D 0x8DC9 -#define GL_INT_SAMPLER_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define GL_QUERY_WAIT 0x8E13 -#define GL_QUERY_NO_WAIT 0x8E14 -#define GL_QUERY_BY_REGION_WAIT 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 -#define GL_BUFFER_ACCESS_FLAGS 0x911F -#define GL_BUFFER_MAP_LENGTH 0x9120 -#define GL_BUFFER_MAP_OFFSET 0x9121 -/* Reuse tokens from ARB_depth_buffer_float */ -/* reuse GL_DEPTH_COMPONENT32F */ -/* reuse GL_DEPTH32F_STENCIL8 */ -/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_DEFAULT */ -/* reuse GL_FRAMEBUFFER_UNDEFINED */ -/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ -/* reuse GL_INDEX */ -/* reuse GL_MAX_RENDERBUFFER_SIZE */ -/* reuse GL_DEPTH_STENCIL */ -/* reuse GL_UNSIGNED_INT_24_8 */ -/* reuse GL_DEPTH24_STENCIL8 */ -/* reuse GL_TEXTURE_STENCIL_SIZE */ -/* reuse GL_TEXTURE_RED_TYPE */ -/* reuse GL_TEXTURE_GREEN_TYPE */ -/* reuse GL_TEXTURE_BLUE_TYPE */ -/* reuse GL_TEXTURE_ALPHA_TYPE */ -/* reuse GL_TEXTURE_DEPTH_TYPE */ -/* reuse GL_UNSIGNED_NORMALIZED */ -/* reuse GL_FRAMEBUFFER_BINDING */ -/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_BINDING */ -/* reuse GL_READ_FRAMEBUFFER */ -/* reuse GL_DRAW_FRAMEBUFFER */ -/* reuse GL_READ_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_SAMPLES */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* reuse GL_FRAMEBUFFER_COMPLETE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ -/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ -/* reuse GL_MAX_COLOR_ATTACHMENTS */ -/* reuse GL_COLOR_ATTACHMENT0 */ -/* reuse GL_COLOR_ATTACHMENT1 */ -/* reuse GL_COLOR_ATTACHMENT2 */ -/* reuse GL_COLOR_ATTACHMENT3 */ -/* reuse GL_COLOR_ATTACHMENT4 */ -/* reuse GL_COLOR_ATTACHMENT5 */ -/* reuse GL_COLOR_ATTACHMENT6 */ -/* reuse GL_COLOR_ATTACHMENT7 */ -/* reuse GL_COLOR_ATTACHMENT8 */ -/* reuse GL_COLOR_ATTACHMENT9 */ -/* reuse GL_COLOR_ATTACHMENT10 */ -/* reuse GL_COLOR_ATTACHMENT11 */ -/* reuse GL_COLOR_ATTACHMENT12 */ -/* reuse GL_COLOR_ATTACHMENT13 */ -/* reuse GL_COLOR_ATTACHMENT14 */ -/* reuse GL_COLOR_ATTACHMENT15 */ -/* reuse GL_DEPTH_ATTACHMENT */ -/* reuse GL_STENCIL_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER */ -/* reuse GL_RENDERBUFFER */ -/* reuse GL_RENDERBUFFER_WIDTH */ -/* reuse GL_RENDERBUFFER_HEIGHT */ -/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ -/* reuse GL_STENCIL_INDEX1 */ -/* reuse GL_STENCIL_INDEX4 */ -/* reuse GL_STENCIL_INDEX8 */ -/* reuse GL_STENCIL_INDEX16 */ -/* reuse GL_RENDERBUFFER_RED_SIZE */ -/* reuse GL_RENDERBUFFER_GREEN_SIZE */ -/* reuse GL_RENDERBUFFER_BLUE_SIZE */ -/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ -/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ -/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ -/* reuse GL_MAX_SAMPLES */ -/* Reuse tokens from ARB_framebuffer_sRGB */ -/* reuse GL_FRAMEBUFFER_SRGB */ -/* Reuse tokens from ARB_half_float_vertex */ -/* reuse GL_HALF_FLOAT */ -/* Reuse tokens from ARB_map_buffer_range */ -/* reuse GL_MAP_READ_BIT */ -/* reuse GL_MAP_WRITE_BIT */ -/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ -/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ -/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ -/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ -/* Reuse tokens from ARB_texture_compression_rgtc */ -/* reuse GL_COMPRESSED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_RG_RGTC2 */ -/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ -/* Reuse tokens from ARB_texture_rg */ -/* reuse GL_RG */ -/* reuse GL_RG_INTEGER */ -/* reuse GL_R8 */ -/* reuse GL_R16 */ -/* reuse GL_RG8 */ -/* reuse GL_RG16 */ -/* reuse GL_R16F */ -/* reuse GL_R32F */ -/* reuse GL_RG16F */ -/* reuse GL_RG32F */ -/* reuse GL_R8I */ -/* reuse GL_R8UI */ -/* reuse GL_R16I */ -/* reuse GL_R16UI */ -/* reuse GL_R32I */ -/* reuse GL_R32UI */ -/* reuse GL_RG8I */ -/* reuse GL_RG8UI */ -/* reuse GL_RG16I */ -/* reuse GL_RG16UI */ -/* reuse GL_RG32I */ -/* reuse GL_RG32UI */ -/* Reuse tokens from ARB_vertex_array_object */ -/* reuse GL_VERTEX_ARRAY_BINDING */ -#endif - -#ifndef GL_VERSION_3_1 -/* #define GL_SAMPLER_2D_RECT 0x8B63 - we use subsumed GL_ARB_texture_rectangle */ -/* #define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 - we use subsumed GL_ARB_texture_rectangle */ -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_2D_RECT 0x8DCD -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -/* Reuse all tokens from ARB_texture_buffer_object */ -/* Reuse all tokens from ARB_texture_rectangle */ -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART 0x8F9D -#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E -/* Reuse tokens from ARB_copy_buffer */ -/* reuse GL_COPY_READ_BUFFER */ -/* reuse GL_COPY_WRITE_BUFFER */ -/* Reuse tokens from ARB_draw_instanced (none) */ -/* Reuse tokens from ARB_uniform_buffer_object */ -/* reuse GL_UNIFORM_BUFFER */ -/* reuse GL_UNIFORM_BUFFER_BINDING */ -/* reuse GL_UNIFORM_BUFFER_START */ -/* reuse GL_UNIFORM_BUFFER_SIZE */ -/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ -/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ -/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ -/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ -/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ -/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ -/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ -/* reuse GL_UNIFORM_TYPE */ -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_INDEX */ -/* reuse GL_UNIFORM_OFFSET */ -/* reuse GL_UNIFORM_ARRAY_STRIDE */ -/* reuse GL_UNIFORM_MATRIX_STRIDE */ -/* reuse GL_UNIFORM_IS_ROW_MAJOR */ -/* reuse GL_UNIFORM_BLOCK_BINDING */ -/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ -/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_INVALID_INDEX */ -#endif - -#ifndef GL_VERSION_3_2 -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_PROGRAM_POINT_SIZE 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_CONTEXT_PROFILE_MASK 0x9126 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* Reuse tokens from ARB_depth_clamp */ -/* reuse GL_DEPTH_CLAMP */ -/* Reuse tokens from ARB_draw_elements_base_vertex (none) */ -/* Reuse tokens from ARB_fragment_coord_conventions (none) */ -/* Reuse tokens from ARB_provoking_vertex */ -/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -/* Reuse tokens from ARB_seamless_cube_map */ -/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ -/* Reuse tokens from ARB_sync */ -/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ -/* reuse GL_OBJECT_TYPE */ -/* reuse GL_SYNC_CONDITION */ -/* reuse GL_SYNC_STATUS */ -/* reuse GL_SYNC_FLAGS */ -/* reuse GL_SYNC_FENCE */ -/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ -/* reuse GL_UNSIGNALED */ -/* reuse GL_SIGNALED */ -/* reuse GL_ALREADY_SIGNALED */ -/* reuse GL_TIMEOUT_EXPIRED */ -/* reuse GL_CONDITION_SATISFIED */ -/* reuse GL_WAIT_FAILED */ -/* reuse GL_TIMEOUT_IGNORED */ -/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ -/* reuse GL_TIMEOUT_IGNORED */ -/* Reuse tokens from ARB_texture_multisample */ -/* reuse GL_SAMPLE_POSITION */ -/* reuse GL_SAMPLE_MASK */ -/* reuse GL_SAMPLE_MASK_VALUE */ -/* reuse GL_MAX_SAMPLE_MASK_WORDS */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_SAMPLES */ -/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ -/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ -/* reuse GL_MAX_INTEGER_SAMPLES */ -/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ -#endif - -#ifndef GL_VERSION_3_3 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -/* Reuse tokens from ARB_blend_func_extended */ -/* reuse GL_SRC1_COLOR */ -/* reuse GL_ONE_MINUS_SRC1_COLOR */ -/* reuse GL_ONE_MINUS_SRC1_ALPHA */ -/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */ -/* Reuse tokens from ARB_explicit_attrib_location (none) */ -/* Reuse tokens from ARB_occlusion_query2 */ -/* reuse GL_ANY_SAMPLES_PASSED */ -/* Reuse tokens from ARB_sampler_objects */ -/* reuse GL_SAMPLER_BINDING */ -/* Reuse tokens from ARB_shader_bit_encoding (none) */ -/* Reuse tokens from ARB_texture_rgb10_a2ui */ -/* reuse GL_RGB10_A2UI */ -/* Reuse tokens from ARB_texture_swizzle */ -/* reuse GL_TEXTURE_SWIZZLE_R */ -/* reuse GL_TEXTURE_SWIZZLE_G */ -/* reuse GL_TEXTURE_SWIZZLE_B */ -/* reuse GL_TEXTURE_SWIZZLE_A */ -/* reuse GL_TEXTURE_SWIZZLE_RGBA */ -/* Reuse tokens from ARB_timer_query */ -/* reuse GL_TIME_ELAPSED */ -/* reuse GL_TIMESTAMP */ -/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */ -/* reuse GL_INT_2_10_10_10_REV */ -#endif - -#ifndef GL_VERSION_4_0 -/* Reuse all tokens from ARB_sample_shading */ -/* Reuse all tokens from ARB_texture_gather */ -/* Reuse all tokens from ARB_texture_cube_map_array */ -/* Reuse tokens from ARB_texture_query_lod (none) */ -/* Reuse tokens from ARB_draw_buffers_blend (none) */ -/* Reuse tokens from ARB_draw_indirect */ -/* reuse GL_DRAW_INDIRECT_BUFFER */ -/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */ -/* Reuse tokens from ARB_gpu_shader5 */ -/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */ -/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */ -/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ -/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ -/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ -/* reuse GL_MAX_VERTEX_STREAMS */ -/* Reuse tokens from ARB_gpu_shader_fp64 */ -/* reuse GL_DOUBLE_VEC2 */ -/* reuse GL_DOUBLE_VEC3 */ -/* reuse GL_DOUBLE_VEC4 */ -/* reuse GL_DOUBLE_MAT2 */ -/* reuse GL_DOUBLE_MAT3 */ -/* reuse GL_DOUBLE_MAT4 */ -/* reuse GL_DOUBLE_MAT2x3 */ -/* reuse GL_DOUBLE_MAT2x4 */ -/* reuse GL_DOUBLE_MAT3x2 */ -/* reuse GL_DOUBLE_MAT3x4 */ -/* reuse GL_DOUBLE_MAT4x2 */ -/* reuse GL_DOUBLE_MAT4x3 */ -/* Reuse tokens from ARB_shader_subroutine */ -/* reuse GL_ACTIVE_SUBROUTINES */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */ -/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */ -/* reuse GL_MAX_SUBROUTINES */ -/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */ -/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ -/* reuse GL_COMPATIBLE_SUBROUTINES */ -/* Reuse tokens from ARB_tessellation_shader */ -/* reuse GL_PATCHES */ -/* reuse GL_PATCH_VERTICES */ -/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */ -/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */ -/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */ -/* reuse GL_TESS_GEN_MODE */ -/* reuse GL_TESS_GEN_SPACING */ -/* reuse GL_TESS_GEN_VERTEX_ORDER */ -/* reuse GL_TESS_GEN_POINT_MODE */ -/* reuse GL_ISOLINES */ -/* reuse GL_FRACTIONAL_ODD */ -/* reuse GL_FRACTIONAL_EVEN */ -/* reuse GL_MAX_PATCH_VERTICES */ -/* reuse GL_MAX_TESS_GEN_LEVEL */ -/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_PATCH_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */ -/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */ -/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */ -/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_TESS_EVALUATION_SHADER */ -/* reuse GL_TESS_CONTROL_SHADER */ -/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */ -/* Reuse tokens from ARB_transform_feedback2 */ -/* reuse GL_TRANSFORM_FEEDBACK */ -/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ -/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ -/* reuse GL_TRANSFORM_FEEDBACK_BINDING */ -/* Reuse tokens from ARB_transform_feedback3 */ -/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */ -/* reuse GL_MAX_VERTEX_STREAMS */ -#endif - -#ifndef GL_VERSION_4_1 -/* Reuse tokens from ARB_ES2_compatibility */ -/* reuse GL_FIXED */ -/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */ -/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */ -/* reuse GL_LOW_FLOAT */ -/* reuse GL_MEDIUM_FLOAT */ -/* reuse GL_HIGH_FLOAT */ -/* reuse GL_LOW_INT */ -/* reuse GL_MEDIUM_INT */ -/* reuse GL_HIGH_INT */ -/* reuse GL_SHADER_COMPILER */ -/* reuse GL_NUM_SHADER_BINARY_FORMATS */ -/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ -/* reuse GL_MAX_VARYING_VECTORS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ -/* Reuse tokens from ARB_get_program_binary */ -/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ -/* reuse GL_PROGRAM_BINARY_LENGTH */ -/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */ -/* reuse GL_PROGRAM_BINARY_FORMATS */ -/* Reuse tokens from ARB_separate_shader_objects */ -/* reuse GL_VERTEX_SHADER_BIT */ -/* reuse GL_FRAGMENT_SHADER_BIT */ -/* reuse GL_GEOMETRY_SHADER_BIT */ -/* reuse GL_TESS_CONTROL_SHADER_BIT */ -/* reuse GL_TESS_EVALUATION_SHADER_BIT */ -/* reuse GL_ALL_SHADER_BITS */ -/* reuse GL_PROGRAM_SEPARABLE */ -/* reuse GL_ACTIVE_PROGRAM */ -/* reuse GL_PROGRAM_PIPELINE_BINDING */ -/* Reuse tokens from ARB_shader_precision (none) */ -/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */ -/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */ -/* reuse GL_MAX_VIEWPORTS */ -/* reuse GL_VIEWPORT_SUBPIXEL_BITS */ -/* reuse GL_VIEWPORT_BOUNDS_RANGE */ -/* reuse GL_LAYER_PROVOKING_VERTEX */ -/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */ -/* reuse GL_UNDEFINED_VERTEX */ -#endif - -#ifndef GL_VERSION_4_2 -/* Reuse tokens from ARB_base_instance (none) */ -/* Reuse tokens from ARB_shading_language_420pack (none) */ -/* Reuse tokens from ARB_transform_feedback_instanced (none) */ -/* Reuse tokens from ARB_compressed_texture_pixel_storage */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */ -/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */ -/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */ -/* Reuse tokens from ARB_conservative_depth (none) */ -/* Reuse tokens from ARB_internalformat_query */ -/* reuse GL_NUM_SAMPLE_COUNTS */ -/* Reuse tokens from ARB_map_buffer_alignment */ -/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */ -/* Reuse tokens from ARB_shader_atomic_counters */ -/* reuse GL_ATOMIC_COUNTER_BUFFER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_START */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */ -/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */ -/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */ -/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */ -/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */ -/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */ -/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */ -/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */ -/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */ -/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */ -/* Reuse tokens from ARB_shader_image_load_store */ -/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */ -/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */ -/* reuse GL_UNIFORM_BARRIER_BIT */ -/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */ -/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */ -/* reuse GL_COMMAND_BARRIER_BIT */ -/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */ -/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */ -/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */ -/* reuse GL_FRAMEBUFFER_BARRIER_BIT */ -/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */ -/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */ -/* reuse GL_ALL_BARRIER_BITS */ -/* reuse GL_MAX_IMAGE_UNITS */ -/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ -/* reuse GL_IMAGE_BINDING_NAME */ -/* reuse GL_IMAGE_BINDING_LEVEL */ -/* reuse GL_IMAGE_BINDING_LAYERED */ -/* reuse GL_IMAGE_BINDING_LAYER */ -/* reuse GL_IMAGE_BINDING_ACCESS */ -/* reuse GL_IMAGE_1D */ -/* reuse GL_IMAGE_2D */ -/* reuse GL_IMAGE_3D */ -/* reuse GL_IMAGE_2D_RECT */ -/* reuse GL_IMAGE_CUBE */ -/* reuse GL_IMAGE_BUFFER */ -/* reuse GL_IMAGE_1D_ARRAY */ -/* reuse GL_IMAGE_2D_ARRAY */ -/* reuse GL_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_IMAGE_1D */ -/* reuse GL_INT_IMAGE_2D */ -/* reuse GL_INT_IMAGE_3D */ -/* reuse GL_INT_IMAGE_2D_RECT */ -/* reuse GL_INT_IMAGE_CUBE */ -/* reuse GL_INT_IMAGE_BUFFER */ -/* reuse GL_INT_IMAGE_1D_ARRAY */ -/* reuse GL_INT_IMAGE_2D_ARRAY */ -/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_1D */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D */ -/* reuse GL_UNSIGNED_INT_IMAGE_3D */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */ -/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */ -/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */ -/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_IMAGE_SAMPLES */ -/* reuse GL_IMAGE_BINDING_FORMAT */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */ -/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */ -/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */ -/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */ -/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */ -/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */ -/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */ -/* Reuse tokens from ARB_shading_language_packing (none) */ -/* Reuse tokens from ARB_texture_storage */ -/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_HALF_FLOAT 0x140B -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#endif - -#ifndef GL_ARB_texture_rg -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -/* #define GL_INVALID_INDEX 0xFFFFFFFFu - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_DEPTH_CLAMP 0x864F -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#endif - -#ifndef GL_ARB_sync -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 -#endif - -#ifndef GL_ARB_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_ARB_draw_buffers_blend -#endif - -#ifndef GL_ARB_sample_shading -#define GL_SAMPLE_SHADING_ARB 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F -#endif - -#ifndef GL_ARB_texture_gather -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F -#endif - -#ifndef GL_ARB_texture_query_lod -#endif - -#ifndef GL_ARB_shading_language_include -#define GL_SHADER_INCLUDE_ARB 0x8DAE -#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 -#define GL_NAMED_STRING_TYPE_ARB 0x8DEA -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F -#endif - -#ifndef GL_ARB_blend_func_extended -#define GL_SRC1_COLOR 0x88F9 -/* reuse GL_SRC1_ALPHA */ -#define GL_ONE_MINUS_SRC1_COLOR 0x88FA -#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB -#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC -#endif - -#ifndef GL_ARB_explicit_attrib_location -#endif - -#ifndef GL_ARB_occlusion_query2 -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#endif - -#ifndef GL_ARB_sampler_objects -#define GL_SAMPLER_BINDING 0x8919 -#endif - -#ifndef GL_ARB_shader_bit_encoding -#endif - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_RGB10_A2UI 0x906F -#endif - -#ifndef GL_ARB_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R 0x8E42 -#define GL_TEXTURE_SWIZZLE_G 0x8E43 -#define GL_TEXTURE_SWIZZLE_B 0x8E44 -#define GL_TEXTURE_SWIZZLE_A 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 -#endif - -#ifndef GL_ARB_timer_query -#define GL_TIME_ELAPSED 0x88BF -#define GL_TIMESTAMP 0x8E28 -#endif - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */ -#define GL_INT_2_10_10_10_REV 0x8D9F -#endif - -#ifndef GL_ARB_draw_indirect -#define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 -#endif - -#ifndef GL_ARB_gpu_shader5 -#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C -#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D -/* reuse GL_MAX_VERTEX_STREAMS */ -#endif - -#ifndef GL_ARB_gpu_shader_fp64 -/* reuse GL_DOUBLE */ -#define GL_DOUBLE_VEC2 0x8FFC -#define GL_DOUBLE_VEC3 0x8FFD -#define GL_DOUBLE_VEC4 0x8FFE -#define GL_DOUBLE_MAT2 0x8F46 -#define GL_DOUBLE_MAT3 0x8F47 -#define GL_DOUBLE_MAT4 0x8F48 -#define GL_DOUBLE_MAT2x3 0x8F49 -#define GL_DOUBLE_MAT2x4 0x8F4A -#define GL_DOUBLE_MAT3x2 0x8F4B -#define GL_DOUBLE_MAT3x4 0x8F4C -#define GL_DOUBLE_MAT4x2 0x8F4D -#define GL_DOUBLE_MAT4x3 0x8F4E -#endif - -#ifndef GL_ARB_shader_subroutine -#define GL_ACTIVE_SUBROUTINES 0x8DE5 -#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 -#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 -#define GL_MAX_SUBROUTINES 0x8DE7 -#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 -#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A -#define GL_COMPATIBLE_SUBROUTINES 0x8E4B -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -#endif - -#ifndef GL_ARB_tessellation_shader -#define GL_PATCHES 0x000E -#define GL_PATCH_VERTICES 0x8E72 -#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 -#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 -#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 -#define GL_TESS_GEN_MODE 0x8E76 -#define GL_TESS_GEN_SPACING 0x8E77 -#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 -#define GL_TESS_GEN_POINT_MODE 0x8E79 -/* reuse GL_TRIANGLES */ -/* reuse GL_QUADS */ -#define GL_ISOLINES 0x8E7A -/* reuse GL_EQUAL */ -#define GL_FRACTIONAL_ODD 0x8E7B -#define GL_FRACTIONAL_EVEN 0x8E7C -/* reuse GL_CCW */ -/* reuse GL_CW */ -#define GL_MAX_PATCH_VERTICES 0x8E7D -#define GL_MAX_TESS_GEN_LEVEL 0x8E7E -#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F -#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 -#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 -#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 -#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 -#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 -#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 -#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 -#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 -#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A -#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C -#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D -#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E -#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 -#define GL_TESS_EVALUATION_SHADER 0x8E87 -#define GL_TESS_CONTROL_SHADER 0x8E88 -#endif - -#ifndef GL_ARB_texture_buffer_object_rgb32 -/* reuse GL_RGB32F */ -/* reuse GL_RGB32UI */ -/* reuse GL_RGB32I */ -#endif - -#ifndef GL_ARB_transform_feedback2 -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#endif - -#ifndef GL_ARB_transform_feedback3 -#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 -#define GL_MAX_VERTEX_STREAMS 0x8E71 -#endif - -#ifndef GL_ARB_ES2_compatibility -#define GL_FIXED 0x140C -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#endif - -#ifndef GL_ARB_get_program_binary -#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -#define GL_PROGRAM_BINARY_LENGTH 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE -#define GL_PROGRAM_BINARY_FORMATS 0x87FF -#endif - -#ifndef GL_ARB_separate_shader_objects -#define GL_VERTEX_SHADER_BIT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#define GL_GEOMETRY_SHADER_BIT 0x00000004 -#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -/* #define GL_ALL_SHADER_BITS 0xFFFFFFFF - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#define GL_PROGRAM_SEPARABLE 0x8258 -#define GL_ACTIVE_PROGRAM 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING 0x825A -#endif - -#ifndef GL_ARB_shader_precision -#endif - -#ifndef GL_ARB_vertex_attrib_64bit -/* reuse GL_RGB32I */ -/* reuse GL_DOUBLE_VEC2 */ -/* reuse GL_DOUBLE_VEC3 */ -/* reuse GL_DOUBLE_VEC4 */ -/* reuse GL_DOUBLE_MAT2 */ -/* reuse GL_DOUBLE_MAT3 */ -/* reuse GL_DOUBLE_MAT4 */ -/* reuse GL_DOUBLE_MAT2x3 */ -/* reuse GL_DOUBLE_MAT2x4 */ -/* reuse GL_DOUBLE_MAT3x2 */ -/* reuse GL_DOUBLE_MAT3x4 */ -/* reuse GL_DOUBLE_MAT4x2 */ -/* reuse GL_DOUBLE_MAT4x3 */ -#endif - -#ifndef GL_ARB_viewport_array -/* reuse GL_SCISSOR_BOX */ -/* reuse GL_VIEWPORT */ -/* reuse GL_DEPTH_RANGE */ -/* reuse GL_SCISSOR_TEST */ -#define GL_MAX_VIEWPORTS 0x825B -#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C -#define GL_VIEWPORT_BOUNDS_RANGE 0x825D -#define GL_LAYER_PROVOKING_VERTEX 0x825E -#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F -#define GL_UNDEFINED_VERTEX 0x8260 -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -#endif - -#ifndef GL_ARB_cl_event -#define GL_SYNC_CL_EVENT_ARB 0x8240 -#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 -#endif - -#ifndef GL_ARB_debug_output -#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 -#define GL_DEBUG_SOURCE_API_ARB 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A -#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B -#define GL_DEBUG_TYPE_ERROR_ARB 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E -#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 -#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 -#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 -#endif - -#ifndef GL_ARB_robustness -/* reuse GL_NO_ERROR */ -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 -#endif - -#ifndef GL_ARB_shader_stencil_export -#endif - -#ifndef GL_ARB_base_instance -#endif - -#ifndef GL_ARB_shading_language_420pack -#endif - -#ifndef GL_ARB_transform_feedback_instanced -#endif - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 -#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 -#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 -#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A -#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B -#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C -#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D -#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E -#endif - -#ifndef GL_ARB_conservative_depth -#endif - -#ifndef GL_ARB_internalformat_query -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#endif - -#ifndef GL_ARB_map_buffer_alignment -#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC -#endif - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 -#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB -#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF -#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 -#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 -#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 -#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 -#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC -#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 -#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA -#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#endif - -#ifndef GL_ARB_shader_image_load_store -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 -#define GL_COMMAND_BARRIER_BIT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 -/* #define GL_ALL_BARRIER_BITS 0xFFFFFFFF - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#define GL_MAX_IMAGE_UNITS 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 -#define GL_IMAGE_BINDING_NAME 0x8F3A -#define GL_IMAGE_BINDING_LEVEL 0x8F3B -#define GL_IMAGE_BINDING_LAYERED 0x8F3C -#define GL_IMAGE_BINDING_LAYER 0x8F3D -#define GL_IMAGE_BINDING_ACCESS 0x8F3E -#define GL_IMAGE_1D 0x904C -#define GL_IMAGE_2D 0x904D -#define GL_IMAGE_3D 0x904E -#define GL_IMAGE_2D_RECT 0x904F -#define GL_IMAGE_CUBE 0x9050 -#define GL_IMAGE_BUFFER 0x9051 -#define GL_IMAGE_1D_ARRAY 0x9052 -#define GL_IMAGE_2D_ARRAY 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 -#define GL_INT_IMAGE_1D 0x9057 -#define GL_INT_IMAGE_2D 0x9058 -#define GL_INT_IMAGE_3D 0x9059 -#define GL_INT_IMAGE_2D_RECT 0x905A -#define GL_INT_IMAGE_CUBE 0x905B -#define GL_INT_IMAGE_BUFFER 0x905C -#define GL_INT_IMAGE_1D_ARRAY 0x905D -#define GL_INT_IMAGE_2D_ARRAY 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C -#define GL_MAX_IMAGE_SAMPLES 0x906D -#define GL_IMAGE_BINDING_FORMAT 0x906E -#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 -#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD -#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#endif - -#ifndef GL_ARB_shading_language_packing -#endif - -#ifndef GL_ARB_texture_storage -#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F -#endif - - -/*************************************************************/ - -#include -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for program/shader text and shader object handles */ -typedef char GLcharARB; -typedef unsigned int GLhandleARB; -#endif - -/* GL type for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#include "gl-64bit-types.h" - -#ifndef GL_ARB_cl_event -/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event -struct _cl_context; -struct _cl_event; - */ -#endif - -#ifndef GL_ARB_debug_output -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif - -#ifndef GL_NV_vdpau_interop -typedef GLintptr GLvdpauSurfaceNV; -#endif - -#ifndef GL_VERSION_1_0 -#define GL_VERSION_1_0 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glCullFace (GLenum mode); -GLAPI void APIENTRY glFrontFace (GLenum mode); -GLAPI void APIENTRY glHint (GLenum target, GLenum mode); -GLAPI void APIENTRY glLineWidth (GLfloat width); -GLAPI void APIENTRY glPointSize (GLfloat size); -GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode); -GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glDrawBuffer (GLenum mode); -GLAPI void APIENTRY glClear (GLbitfield mask); -GLAPI void APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GLAPI void APIENTRY glClearStencil (GLint s); -GLAPI void APIENTRY glClearDepth (GLclampd depth); -GLAPI void APIENTRY glStencilMask (GLuint mask); -GLAPI void APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -GLAPI void APIENTRY glDepthMask (GLboolean flag); -GLAPI void APIENTRY glDisable (GLenum cap); -GLAPI void APIENTRY glEnable (GLenum cap); -GLAPI void APIENTRY glFinish (void); -GLAPI void APIENTRY glFlush (void); -GLAPI void APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); -GLAPI void APIENTRY glLogicOp (GLenum opcode); -GLAPI void APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); -GLAPI void APIENTRY glDepthFunc (GLenum func); -GLAPI void APIENTRY glPixelStoref (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param); -GLAPI void APIENTRY glReadBuffer (GLenum mode); -GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void APIENTRY glGetBooleanv (GLenum pname, GLboolean *params); -GLAPI void APIENTRY glGetDoublev (GLenum pname, GLdouble *params); -GLAPI GLenum APIENTRY glGetError (void); -GLAPI void APIENTRY glGetFloatv (GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *params); -GLAPI const GLubyte * APIENTRY glGetString (GLenum name); -GLAPI void APIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap); -GLAPI void APIENTRY glDepthRange (GLclampd zNear, GLclampd zFar); -GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); -typedef void (APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); -typedef void (APIENTRYP PFNGLPOINTSIZEPROC) (GLfloat size); -typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLDRAWBUFFERPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); -typedef void (APIENTRYP PFNGLCLEARDEPTHPROC) (GLclampd depth); -typedef void (APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); -typedef void (APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -typedef void (APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); -typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); -typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); -typedef void (APIENTRYP PFNGLFINISHPROC) (void); -typedef void (APIENTRYP PFNGLFLUSHPROC) (void); -typedef void (APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); -typedef void (APIENTRYP PFNGLLOGICOPPROC) (GLenum opcode); -typedef void (APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); -typedef void (APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); -typedef void (APIENTRYP PFNGLPIXELSTOREFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLREADBUFFERPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *params); -typedef void (APIENTRYP PFNGLGETDOUBLEVPROC) (GLenum pname, GLdouble *params); -typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); -typedef void (APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params); -typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); -typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) (GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); -typedef void (APIENTRYP PFNGLDEPTHRANGEPROC) (GLclampd near, GLclampd far); -typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_1 -#define GL_VERSION_1_1 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); -GLAPI void APIENTRY glGetPointerv (GLenum pname, GLvoid* *params); -GLAPI void APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); -GLAPI void APIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture); -GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); -GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures); -GLAPI GLboolean APIENTRY glIsTexture (GLuint texture); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GLAPI void APIENTRY glBlendEquation (GLenum mode); -GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum texture); -GLAPI void APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQuery (GLuint id); -GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQuery (GLenum target); -GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); -GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); -GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); -GLAPI void APIENTRY glCompileShader (GLuint shader); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum type); -GLAPI void APIENTRY glDeleteProgram (GLuint program); -GLAPI void APIENTRY glDeleteShader (GLuint shader); -GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgram (GLuint program); -GLAPI GLboolean APIENTRY glIsShader (GLuint shader); -GLAPI void APIENTRY glLinkProgram (GLuint program); -GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -GLAPI void APIENTRY glUseProgram (GLuint program); -GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glValidateProgram (GLuint program); -GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 -/* OpenGL 3.0 also reuses entry points from these extensions: */ -/* ARB_framebuffer_object */ -/* ARB_map_buffer_range */ -/* ARB_vertex_array_object */ -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); -GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); -GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedback (void); -GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); -GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRender (void); -GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); -GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); -GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); -GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); -GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -#endif - -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 -/* OpenGL 3.1 also reuses entry points from these extensions: */ -/* ARB_copy_buffer */ -/* ARB_uniform_buffer_object */ -/* ARB_draw_instanced */ -/* ARB_texture_buffer_object */ -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); -#endif - -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 -/* OpenGL 3.2 also reuses entry points from these extensions: */ -/* ARB_draw_elements_base_vertex */ -/* ARB_provoking_vertex */ -/* ARB_sync */ -/* ARB_texture_multisample */ -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); -GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif - -#ifndef GL_VERSION_3_3 -#define GL_VERSION_3_3 1 -/* OpenGL 3.3 also reuses entry points from these extensions: */ -/* ARB_blend_func_extended */ -/* ARB_sampler_objects */ -/* ARB_explicit_attrib_location, but it has none */ -/* ARB_occlusion_query2 (no entry points) */ -/* ARB_shader_bit_encoding (no entry points) */ -/* ARB_texture_rgb10_a2ui (no entry points) */ -/* ARB_texture_swizzle (no entry points) */ -/* ARB_timer_query */ -/* ARB_vertex_type_2_10_10_10_rev */ -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); -#endif - -#ifndef GL_VERSION_4_0 -#define GL_VERSION_4_0 1 -/* OpenGL 4.0 also reuses entry points from these extensions: */ -/* ARB_texture_query_lod (no entry points) */ -/* ARB_draw_indirect */ -/* ARB_gpu_shader5 (no entry points) */ -/* ARB_gpu_shader_fp64 */ -/* ARB_shader_subroutine */ -/* ARB_tessellation_shader */ -/* ARB_texture_buffer_object_rgb32 (no entry points) */ -/* ARB_texture_cube_map_array (no entry points) */ -/* ARB_texture_gather (no entry points) */ -/* ARB_transform_feedback2 */ -/* ARB_transform_feedback3 */ -/* Susume ARB_sample_shading */ -/* Susume ARB_draw_buffers_blend */ -#endif - -#ifndef GL_VERSION_4_1 -#define GL_VERSION_4_1 1 -/* OpenGL 4.1 also reuses entry points from these extensions: */ -/* ARB_ES2_compatibility */ -/* ARB_get_program_binary */ -/* ARB_separate_shader_objects */ -/* ARB_shader_precision (no entry points) */ -/* ARB_vertex_attrib_64bit */ -/* ARB_viewport_array */ -#endif - -#ifndef GL_VERSION_4_2 -#define GL_VERSION_4_2 1 -/* OpenGL 4.2 reuses entry points from these extensions: */ -/* ARB_base_instance */ -/* ARB_shading_language_420pack (no entry points) */ -/* ARB_transform_feedback_instanced */ -/* ARB_compressed_texture_pixel_storage (no entry points) */ -/* ARB_conservative_depth (no entry points) */ -/* ARB_internalformat_query */ -/* ARB_map_buffer_alignment (no entry points) */ -/* ARB_shader_atomic_counters */ -/* ARB_shader_image_load_store */ -/* ARB_shading_language_packing (no entry points) */ -/* ARB_texture_storage */ -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 -#ifdef GL3_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmap (GLenum target); -GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif /* GL3_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 -#ifdef GL3_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); -#endif /* GL3_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 -#endif - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBindVertexArray (GLuint array); -GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_ARB_uniform_buffer_object 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); -GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); -GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_ARB_copy_buffer 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp 1 -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#define GL_ARB_draw_elements_base_vertex 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#define GL_ARB_fragment_coord_conventions 1 -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_ARB_provoking_vertex 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glProvokingVertex (GLenum mode); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map 1 -#endif - -#ifndef GL_ARB_sync -#define GL_ARB_sync 1 -#ifdef GL3_PROTOTYPES -GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); -GLAPI GLboolean APIENTRY glIsSync (GLsync sync); -GLAPI void APIENTRY glDeleteSync (GLsync sync); -GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif /* GL3_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); -typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); -typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); -typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_ARB_texture_multisample 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); -#endif - -#ifndef GL_ARB_vertex_array_bgra -#define GL_ARB_vertex_array_bgra 1 -#endif - -#ifndef GL_ARB_draw_buffers_blend -#define GL_ARB_draw_buffers_blend 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif - -#ifndef GL_ARB_sample_shading -#define GL_ARB_sample_shading 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glMinSampleShadingARB (GLclampf value); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_ARB_texture_cube_map_array 1 -#endif - -#ifndef GL_ARB_texture_gather -#define GL_ARB_texture_gather 1 -#endif - -#ifndef GL_ARB_texture_query_lod -#define GL_ARB_texture_query_lod 1 -#endif - -#ifndef GL_ARB_shading_language_include -#define GL_ARB_shading_language_include 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); -GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); -typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_ARB_texture_compression_bptc 1 -#endif - -#ifndef GL_ARB_blend_func_extended -#define GL_ARB_blend_func_extended 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); -#endif - -#ifndef GL_ARB_explicit_attrib_location -#define GL_ARB_explicit_attrib_location 1 -#endif - -#ifndef GL_ARB_occlusion_query2 -#define GL_ARB_occlusion_query2 1 -#endif - -#ifndef GL_ARB_sampler_objects -#define GL_ARB_sampler_objects 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); -GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); -GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); -GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); -GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); -GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); -GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); -GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); -typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); -typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); -typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_bit_encoding -#define GL_ARB_shader_bit_encoding 1 -#endif - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_ARB_texture_rgb10_a2ui 1 -#endif - -#ifndef GL_ARB_texture_swizzle -#define GL_ARB_texture_swizzle 1 -#endif - -#ifndef GL_ARB_timer_query -#define GL_ARB_timer_query 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); -GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); -#endif - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -#define GL_ARB_vertex_type_2_10_10_10_rev 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif - -#ifndef GL_ARB_draw_indirect -#define GL_ARB_draw_indirect 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); -GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); -#endif - -#ifndef GL_ARB_gpu_shader5 -#define GL_ARB_gpu_shader5 1 -#endif - -#ifndef GL_ARB_gpu_shader_fp64 -#define GL_ARB_gpu_shader_fp64 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); -GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); -#endif - -#ifndef GL_ARB_shader_subroutine -#define GL_ARB_shader_subroutine 1 -#ifdef GL3_PROTOTYPES -GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); -GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); -GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif /* GL3_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); -typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif - -#ifndef GL_ARB_tessellation_shader -#define GL_ARB_tessellation_shader 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); -GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); -#endif - -#ifndef GL_ARB_texture_buffer_object_rgb32 -#define GL_ARB_texture_buffer_object_rgb32 1 -#endif - -#ifndef GL_ARB_transform_feedback2 -#define GL_ARB_transform_feedback2 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedback (void); -GLAPI void APIENTRY glResumeTransformFeedback (void); -GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); -#endif - -#ifndef GL_ARB_transform_feedback3 -#define GL_ARB_transform_feedback3 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); -GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); -GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); -GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); -typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_ES2_compatibility -#define GL_ARB_ES2_compatibility 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glReleaseShaderCompiler (void); -GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); -GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -GLAPI void APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); -GLAPI void APIENTRY glClearDepthf (GLclampf depth); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); -typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); -typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f); -typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLclampf d); -#endif - -#ifndef GL_ARB_get_program_binary -#define GL_ARB_get_program_binary 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); -GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); -#endif - -#ifndef GL_ARB_separate_shader_objects -#define GL_ARB_separate_shader_objects 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); -GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* *strings); -GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); -GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); -GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); -GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); -GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); -GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); -typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* *strings); -typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); -typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif - -#ifndef GL_ARB_vertex_attrib_64bit -#define GL_ARB_vertex_attrib_64bit 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); -#endif - -#ifndef GL_ARB_viewport_array -#define GL_ARB_viewport_array 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); -GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); -GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLclampd *v); -GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLclampd n, GLclampd f); -GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f); -typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); -#endif - -#ifndef GL_ARB_cl_event -#define GL_ARB_cl_event 1 -#ifdef GL3_PROTOTYPES -/* GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); */ -GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (void * context, void * event, GLbitfield flags); -#endif /* GL3_PROTOTYPES */ -/* typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); */ -typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (void * context, void * event, GLbitfield flags); -#endif - -#ifndef GL_ARB_debug_output -#define GL_ARB_debug_output 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif - -#ifndef GL_ARB_robustness -#define GL_ARB_robustness 1 -#ifdef GL3_PROTOTYPES -GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); -GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); -GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); -GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); -GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); -GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); -GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); -GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); -GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); -GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif /* GL3_PROTOTYPES */ -typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); -typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); -typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); -typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); -typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); -typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); -typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); -typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif - -#ifndef GL_ARB_shader_stencil_export -#define GL_ARB_shader_stencil_export 1 -#endif - -#ifndef GL_ARB_base_instance -#define GL_ARB_base_instance 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); -#endif - -#ifndef GL_ARB_shading_language_420pack -#define GL_ARB_shading_language_420pack 1 -#endif - -#ifndef GL_ARB_transform_feedback_instanced -#define GL_ARB_transform_feedback_instanced 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount); -GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); -#endif - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_ARB_compressed_texture_pixel_storage 1 -#endif - -#ifndef GL_ARB_conservative_depth -#define GL_ARB_conservative_depth 1 -#endif - -#ifndef GL_ARB_internalformat_query -#define GL_ARB_internalformat_query 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif - -#ifndef GL_ARB_map_buffer_alignment -#define GL_ARB_map_buffer_alignment 1 -#endif - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ARB_shader_atomic_counters 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_shader_image_load_store -#define GL_ARB_shader_image_load_store 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); -#endif - -#ifndef GL_ARB_shading_language_packing -#define GL_ARB_shading_language_packing 1 -#endif - -#ifndef GL_ARB_texture_storage -#define GL_ARB_texture_storage 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E -#endif -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#endif - -/** - * Convenient names only .. actually subsumed into core - */ -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#endif -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -/** - * We rename EXT_texture_rectangle into core, - * so ARB_texture_rectangle will remain intact. - */ -#ifndef GL_EXT_texture_rectangle -#define GL_TEXTURE_RECTANGLE_EXT 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8 -#define GL_SAMPLER_2D_RECT_EXT 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_EXT 0x8B64 -#endif -#ifndef GL_EXT_texture_rectangle -#define GL_EXT_texture_rectangle 1 -#endif - -#ifndef GL_ARB_draw_instanced -#endif -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/make/stub_includes/opengl/GL3/gl3ext.h b/make/stub_includes/opengl/GL3/gl3ext.h deleted file mode 100644 index 8b05499c2..000000000 --- a/make/stub_includes/opengl/GL3/gl3ext.h +++ /dev/null @@ -1,351 +0,0 @@ -#ifndef __gl3ext_h_ -#define __gl3ext_h_ - -/* -** Copyright (c) 2010 JogAmp Developer Team -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/** - * This header files contains additional extensions not covered by the - * 'official' khronos gl3.h - */ - -/* - * ------------------------------------------------ - * Everything here and below was added manually - * to the version of glext.h obtained from: - * http://oss.sgi.com/projects/ogl-sample/registry/index.html - * ------------------------------------------------ - * - * Structure is: - * #ifndef GL_EXTENSION_NAME - * Add DEFINES here - * #endif - * #ifndef GL_EXTENSION_NAME - * Add TYPEDEFS here - * #endif - * #ifndef GL_EXTENSION_NAME - * #define GL_EXTENSION_NAME 1 - * #ifdef GL_GL3EXT_PROTOTYPES - * Add FUNCTION DECLARATIONS here - * #endif - * FUNCTION POINTER DECLARATIONS NOT NEEDED - * #endif - */ - -/** - * 47. http://www.opengl.org/registry/specs/ARB/geometry_shader4.txt - */ -#ifndef GL_ARB_geometry_shader4 -#define GL_LINES_ADJACENCY_ARB 0x000A -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B -#define GL_TRIANGLES_ADJACENCY_ARB 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 -#ifndef GL_MAX_VARYING_COMPONENTS -#define GL_MAX_VARYING_COMPONENTS 0x8B4B -#endif -#ifndef GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#endif -#endif -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); -GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #187 -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -// #363 http://www.opengl.org/registry/specs/AMD/vertex_shader_tessellator.txt -#ifndef GL_AMD_vertex_shader_tessellator -#define GL_SAMPLER_BUFFER_AMD 0x9001 -#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define GL_DISCRETE_AMD 0x9006 -#define GL_CONTINUOUS_AMD 0x9007 -#define GL_TESSELLATION_MODE_AMD 0x9004 -#define GL_TESSELLATION_FACTOR_AMD 0x9005 -#endif -#ifndef GL_AMD_vertex_shader_tessellator -#define GL_AMD_vertex_shader_tessellator 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glTessellationFactorAMD(GLfloat factor); -GLAPI void APIENTRY glTessellationModeAMD(GLenum mode); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #379 http://www.opengl.org/registry/specs/NV/shader_buffer_load.txt -#ifndef GL_NV_shader_buffer_load -#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D -#define GL_GPU_ADDRESS_NV 0x8F34 -#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 -#endif -#ifndef GL_NV_shader_buffer_load -#define GL_NV_shader_buffer_load 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); -GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); -GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); -GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); -GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); -GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); -GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); -GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); -GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); -GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); -GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #380 http://www.opengl.org/registry/specs/NV/vertex_buffer_unified_memory.txt -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E -#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F -#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 -#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 -#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 -#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 -#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 -#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 -#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 -#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 -#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 -#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 -#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A -#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B -#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C -#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D -#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E -#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F -#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 -#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 -#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 -#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 -#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 -#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 -#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 -#endif -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_NV_vertex_buffer_unified_memory 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsEnabled( GLenum cap ); // extra requirement in core GL3 -GLAPI void APIENTRY glEnableClientState( GLenum cap ); // extra requirement in core GL3 -GLAPI void APIENTRY glDisableClientState( GLenum cap ); // extra requirement in core GL3 -GLAPI void APIENTRY glBufferAddressRangeNV(GLenum pname, GLuint index, GLuint64 address, GLsizeiptr length); -GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); -GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #395 -#ifndef GL_AMD_debug_output -#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 -#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 -#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 -#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A -#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B -#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C -#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D -#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E -#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F -#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 -#endif -#ifndef GL_AMD_debug_output -typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif -#ifndef GL_AMD_debug_output -#define GL_AMD_debug_output 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#endif /* GL_GL3EXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#endif - -// #401 -#ifndef GL_AMD_depth_clamp_separate -#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E -#define GL_DEPTH_CLAMP_FAR_AMD 0x901F -#endif -#ifndef GL_AMD_depth_clamp_separate -#define GL_AMD_depth_clamp_separate 1 -#endif - -// #402 -#ifndef GL_EXT_texture_sRGB_decode -#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 -#define GL_DECODE_EXT 0x8A49 -#define GL_SKIP_DECODE_EXT 0x8A4A -#endif -#ifndef GL_EXT_texture_sRGB_decode -#define GL_EXT_texture_sRGB_decode 1 -#endif - -// #403 -#ifndef GL_NV_texture_multisample -#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 -#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 -#endif -#ifndef GL_NV_texture_multisample -#define GL_NV_texture_multisample 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #404 -#ifndef GL_AMD_blend_minmax_factor -#define GL_FACTOR_MIN_AMD 0x901C -#define GL_FACTOR_MAX_AMD 0x901D -#endif -#ifndef GL_AMD_blend_minmax_factor -#define GL_AMD_blend_minmax_factor 1 -#endif - -// #405 -#ifndef GL_AMD_sample_positions -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F -#endif -#ifndef GL_AMD_sample_positions -#define GL_AMD_sample_positions 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); -#endif /* GL_GL3EXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); -#endif - -// #406 -#ifndef GL_EXT_x11_sync_object -#define GL_SYNC_X11_FENCE_EXT 0x90E1 -#endif -#ifndef GL_EXT_x11_sync_object -#define GL_EXT_x11_sync_object 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #408 -#ifndef GL_AMD_multi_draw_indirect -#endif -#ifndef GL_AMD_multi_draw_indirect -#define GL_AMD_multi_draw_indirect 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #409 -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB -#endif -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_EXT_framebuffer_multisample_blit_scaled 1 -#endif - -// #410 GL_NV_path_rendering ? - -// #411 -#ifndef GL_AMD_pinned_memory -#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 -#endif -#ifndef GL_AMD_pinned_memory -#define GL_AMD_pinned_memory 1 -#endif - -// #413 -#ifndef GL_AMD_stencil_operation_extended -#define GL_SET_AMD 0x874A -#define GL_REPLACE_VALUE_AMD 0x874B -#define GL_STENCIL_OP_VALUE_AMD 0x874C -#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D -#endif -#ifndef GL_AMD_stencil_operation_extended -#define GL_AMD_stencil_operation_extended 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -#endif /* __gl3ext_h_ */ - diff --git a/make/stub_includes/opengl/GL3/glplatform.h b/make/stub_includes/opengl/GL3/glplatform.h deleted file mode 100644 index 958d95cb1..000000000 --- a/make/stub_includes/opengl/GL3/glplatform.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef __glplatform_h_ -#define __glplatform_h_ - -#if !defined(OPENSTEP) && (defined(NeXT) || defined(NeXT_PDO)) -#define OPENSTEP -#endif - -#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) -#define __WIN32__ -#endif - -#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) -# if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ -# define GLAPI __declspec(dllexport) -# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ -# define GLAPI __declspec(dllimport) -# else /* for use with static link lib build of Win32 edition only */ -# define GLAPI extern -# endif /* _STATIC_MESA support */ -# define APIENTRY __stdcall -#else -/* non-Windows compilation */ -# ifndef GLAPI -# define GLAPI extern -# endif -# define APIENTRY -#endif /* WIN32 / CYGWIN bracket */ - -#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__) -# define PRAGMA_EXPORT_SUPPORTED 1 -#endif - -/* - * WINDOWS: Include windows.h here to define APIENTRY. - * It is also useful when applications include this file by - * including only glut.h, since glut.h depends on windows.h. - * Applications needing to include windows.h with parms other - * than "WIN32_LEAN_AND_MEAN" may include windows.h before - * glut.h or gl.h. - */ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(__CYGWIN__) -#include -#endif - -#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED -#pragma import on -#endif - -#ifdef CENTERLINE_CLPP -#define signed -#endif - -#if defined(PRAGMA_EXPORT_SUPPORTED) -#pragma export on -#endif - -#endif /* __glplatform_h_ */ - diff --git a/make/stub_includes/opengl/GLES/gl.h b/make/stub_includes/opengl/GLES/gl.h index 0d152474b..198bd4d5c 100644 --- a/make/stub_includes/opengl/GLES/gl.h +++ b/make/stub_includes/opengl/GLES/gl.h @@ -599,7 +599,7 @@ typedef khronos_ssize_t GLsizeiptr; /* Available only in Common profile */ GL_API void GL_APIENTRY glAlphaFunc (GLenum func, GLclampf ref); GL_API void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_API void GL_APIENTRY glClearDepthf (GLclampf depth); +GL_API void GL_APIENTRY glClearDepthf (GLfloat depth); GL_API void GL_APIENTRY glClipPlanef (GLenum plane, const GLfloat *equation); GL_API void GL_APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GL_API void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); @@ -608,7 +608,7 @@ GL_API void GL_APIENTRY glFogfv (GLenum pname, const GLfloat *params); GL_API void GL_APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); /* FIXME: GlueGen generates incorrect code for this one */ /* GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat eqn[4]); */ -GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, const GLfloat * eqn); +GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat *equation); GL_API void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *params); GL_API void GL_APIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); GL_API void GL_APIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); diff --git a/make/stub_includes/opengl/GLES/glext.h b/make/stub_includes/opengl/GLES/glext.h index b3d6b712b..7a0a718ca 100644 --- a/make/stub_includes/opengl/GLES/glext.h +++ b/make/stub_includes/opengl/GLES/glext.h @@ -1,7 +1,7 @@ #ifndef __glext_h_ #define __glext_h_ -/* $Revision: 16481 $ on $Date:: 2012-01-04 10:43:56 -0800 #$ */ +/* $Revision: 20798 $ on $Date:: 2013-03-07 01:19:34 -0800 #$ */ #ifdef __cplusplus extern "C" { @@ -166,6 +166,9 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_DEPTH24_STENCIL8_OES 0x88F0 #endif +/* GL_OES_required_internalformat */ +/* No new tokens introduced by this extension. */ + /* GL_OES_rgb8_rgba8 */ #ifndef GL_OES_rgb8_rgba8 #define GL_RGB8_OES 0x8051 @@ -241,7 +244,7 @@ typedef struct __GLeglImageOES *GLeglImageOES; * APPLE extension tokens *------------------------------------------------------------------------*/ -/* GL_APPLE_texture_2D_limited_npot */ +/* GL_APPLE_copy_texture_levels */ /* No new tokens introduced by this extension. */ /* GL_APPLE_framebuffer_multisample */ @@ -255,6 +258,41 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA #endif +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync + +/* These types are defined with reference to + * in the Apple extension spec, but here we use the Khronos + * portable types in khrplatform.h, and assume those types + * are always defined. + * If any other extensions using these types are defined, + * the typedefs must move out of this block and be shared. + */ +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef struct __GLsync *GLsync; + +#define GL_SYNC_OBJECT_APPLE 0x8A53 +#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 +#define GL_OBJECT_TYPE_APPLE 0x9112 +#define GL_SYNC_CONDITION_APPLE 0x9113 +#define GL_SYNC_STATUS_APPLE 0x9114 +#define GL_SYNC_FLAGS_APPLE 0x9115 +#define GL_SYNC_FENCE_APPLE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 +#define GL_UNSIGNALED_APPLE 0x9118 +#define GL_SIGNALED_APPLE 0x9119 +#define GL_ALREADY_SIGNALED_APPLE 0x911A +#define GL_TIMEOUT_EXPIRED_APPLE 0x911B +#define GL_CONDITION_SATISFIED_APPLE 0x911C +#define GL_WAIT_FAILED_APPLE 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 +#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull +#endif + +/* GL_APPLE_texture_2D_limited_npot */ +/* No new tokens introduced by this extension. */ + /* GL_APPLE_texture_format_BGRA8888 */ #ifndef GL_APPLE_texture_format_BGRA8888 #define GL_BGRA_EXT 0x80E1 @@ -289,12 +327,23 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_STENCIL_EXT 0x1802 #endif +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_MAP_READ_BIT_EXT 0x0001 +#define GL_MAP_WRITE_BIT_EXT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 +#endif + /* GL_EXT_multisampled_render_to_texture */ #ifndef GL_EXT_multisampled_render_to_texture #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C -#define GL_RENDERBUFFER_SAMPLES_EXT 0x9133 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x9134 -#define GL_MAX_SAMPLES_EXT 0x9135 +/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */ +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 #endif /* GL_EXT_multi_draw_arrays */ @@ -354,10 +403,10 @@ typedef struct __GLeglImageOES *GLeglImageOES; /* GL_EXT_texture_storage */ #ifndef GL_EXT_texture_storage #define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F -#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA8_EXT 0x803C #define GL_LUMINANCE8_EXT 0x8040 #define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_RGBA32F_EXT 0x8814 +#define GL_RGBA32F_EXT 0x8814 #define GL_RGB32F_EXT 0x8815 #define GL_ALPHA32F_EXT 0x8816 #define GL_LUMINANCE32F_EXT 0x8818 @@ -367,7 +416,7 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_ALPHA16F_EXT 0x881C #define GL_LUMINANCE16F_EXT 0x881E #define GL_LUMINANCE_ALPHA16F_EXT 0x881F -#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGB10_A2_EXT 0x8059 #define GL_RGB10_EXT 0x8052 #define GL_BGRA8_EXT 0x93A1 #endif @@ -776,6 +825,11 @@ typedef void (GL_APIENTRYP PFNGLWEIGHTPOINTEROESPROC) (GLint size, GLenum type, #define GL_OES_packed_depth_stencil 1 #endif +/* GL_OES_required_internalformat */ +#ifndef GL_OES_required_internalformat +#define GL_OES_required_internalformat 1 +#endif + /* GL_OES_query_matrix */ #ifndef GL_OES_query_matrix #define GL_OES_query_matrix 1 @@ -801,8 +855,8 @@ GL_API void GL_APIENTRY glDepthRangefOES (GLclampf zNear, GLclampf zFar); GL_API void GL_APIENTRY glFrustumfOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); GL_API void GL_APIENTRY glOrthofOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); GL_API void GL_APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); -GL_API void GL_APIENTRY glGetClipPlanefOES (GLenum pname, GLfloat eqn[4]); -GL_API void GL_APIENTRY glClearDepthfOES (GLclampf depth); +GL_API void GL_APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +GL_API void GL_APIENTRY glClearDepthfOES (GLfloat depth); #endif typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf zNear, GLclampf zFar); typedef void (GL_APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); @@ -900,9 +954,13 @@ typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); * APPLE extension functions *------------------------------------------------------------------------*/ -/* GL_APPLE_texture_2D_limited_npot */ -#ifndef GL_APPLE_texture_2D_limited_npot -#define GL_APPLE_texture_2D_limited_npot 1 +/* GL_APPLE_copy_texture_levels */ +#ifndef GL_APPLE_copy_texture_levels +#define GL_APPLE_copy_texture_levels 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif +typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); #endif /* GL_APPLE_framebuffer_multisample */ @@ -916,6 +974,32 @@ typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); #endif +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync +#define GL_APPLE_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); +GL_API GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); +GL_API void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); +GL_API GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_API void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_API void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); +GL_API void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + +/* GL_APPLE_texture_2D_limited_npot */ +#ifndef GL_APPLE_texture_2D_limited_npot +#define GL_APPLE_texture_2D_limited_npot 1 +#endif + /* GL_APPLE_texture_format_BGRA8888 */ #ifndef GL_APPLE_texture_format_BGRA8888 #define GL_APPLE_texture_format_BGRA8888 1 @@ -953,6 +1037,17 @@ GL_API void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttac typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); #endif +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_EXT_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_API void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); +#endif +typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + /* GL_EXT_multisampled_render_to_texture */ #ifndef GL_EXT_multisampled_render_to_texture #define GL_EXT_multisampled_render_to_texture 1 @@ -968,10 +1063,10 @@ typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum #ifndef GL_EXT_multi_draw_arrays #define GL_EXT_multi_draw_arrays 1 #ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei); GL_API void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); #endif @@ -1076,8 +1171,8 @@ typedef void (GL_APIENTRYP PFNGLCLIPPLANEXIMGPROC) (GLenum p, const GLfixed *eqn GL_API void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); #endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); #endif /*------------------------------------------------------------------------* diff --git a/make/stub_includes/opengl/GLES2/gl2.h b/make/stub_includes/opengl/GLES2/gl2.h index 5c6d5f03e..89babc98d 100644 --- a/make/stub_includes/opengl/GLES2/gl2.h +++ b/make/stub_includes/opengl/GLES2/gl2.h @@ -1,7 +1,7 @@ #ifndef __gl2_h_ #define __gl2_h_ -/* $Revision: 16803 $ on $Date:: 2012-02-02 09:49:18 -0800 #$ */ +/* $Revision: 20555 $ on $Date:: 2013-02-12 14:32:47 -0800 #$ */ #include @@ -494,7 +494,7 @@ GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr off GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); +GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat depth); GL_APICALL void GL_APIENTRY glClearStencil (GLint s); GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); @@ -534,7 +534,7 @@ GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); -GL_APICALL int GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); GL_APICALL GLenum GL_APIENTRY glGetError (void); @@ -553,7 +553,7 @@ GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum p GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); -GL_APICALL int GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); diff --git a/make/stub_includes/opengl/GLES2/gl2ext.h b/make/stub_includes/opengl/GLES2/gl2ext.h index 04c0a64e9..b658fc8ba 100644 --- a/make/stub_includes/opengl/GLES2/gl2ext.h +++ b/make/stub_includes/opengl/GLES2/gl2ext.h @@ -1,7 +1,7 @@ #ifndef __gl2ext_h_ #define __gl2ext_h_ -/* $Revision: 16619 $ on $Date:: 2012-01-18 10:00:14 -0800 #$ */ +/* $Revision: 22161 $ on $Date:: 2013-06-25 08:17:27 -0700 #$ */ #ifdef __cplusplus extern "C" { @@ -16,6 +16,20 @@ extern "C" { # define GL_APIENTRYP GL_APIENTRY* #endif +/* New types shared by several extensions */ + +#ifndef __gl3_h_ +/* These are defined with respect to in the + * Apple extension spec, but they are also used by non-APPLE + * extensions, and in the Khronos header we use the Khronos + * portable types in khrplatform.h, which must be defined. + */ +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef struct __GLsync *GLsync; +#endif + + /*------------------------------------------------------------------------* * OES extension tokens *------------------------------------------------------------------------*/ @@ -94,6 +108,25 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_DEPTH24_STENCIL8_OES 0x88F0 #endif +/* GL_OES_required_internalformat */ +#ifndef GL_OES_required_internalformat +#define GL_ALPHA8_OES 0x803C +#define GL_DEPTH_COMPONENT16_OES 0x81A5 +/* reuse GL_DEPTH_COMPONENT24_OES */ +/* reuse GL_DEPTH24_STENCIL8_OES */ +/* reuse GL_DEPTH_COMPONENT32_OES */ +#define GL_LUMINANCE4_ALPHA4_OES 0x8043 +#define GL_LUMINANCE8_ALPHA8_OES 0x8045 +#define GL_LUMINANCE8_OES 0x8040 +#define GL_RGBA4_OES 0x8056 +#define GL_RGB5_A1_OES 0x8057 +#define GL_RGB565_OES 0x8D62 +/* reuse GL_RGB8_OES */ +/* reuse GL_RGBA8_OES */ +/* reuse GL_RGB10_EXT */ +/* reuse GL_RGB10_A2_EXT */ +#endif + /* GL_OES_rgb8_rgba8 */ #ifndef GL_OES_rgb8_rgba8 #define GL_RGB8_OES 0x8051 @@ -115,6 +148,10 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_STENCIL_INDEX4_OES 0x8D47 #endif +#ifndef GL_OES_surfaceless_context +#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 +#endif + /* GL_OES_texture_3D */ #ifndef GL_OES_texture_3D #define GL_TEXTURE_WRAP_R_OES 0x8072 @@ -156,6 +193,85 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_INT_10_10_10_2_OES 0x8DF7 #endif +/*------------------------------------------------------------------------* + * KHR extension tokens + *------------------------------------------------------------------------*/ + +#ifndef GL_KHR_debug +typedef void (GL_APIENTRYP GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245 +#define GL_DEBUG_SOURCE_API_KHR 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A +#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B +#define GL_DEBUG_TYPE_ERROR_KHR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250 +#define GL_DEBUG_TYPE_OTHER_KHR 0x8251 +#define GL_DEBUG_TYPE_MARKER_KHR 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D +#define GL_BUFFER_KHR 0x82E0 +#define GL_SHADER_KHR 0x82E1 +#define GL_PROGRAM_KHR 0x82E2 +#define GL_QUERY_KHR 0x82E3 +/* PROGRAM_PIPELINE only in GL */ +#define GL_SAMPLER_KHR 0x82E6 +/* DISPLAY_LIST only in GL */ +#define GL_MAX_LABEL_LENGTH_KHR 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147 +#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148 +#define GL_DEBUG_OUTPUT_KHR 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002 +#define GL_STACK_OVERFLOW_KHR 0x0503 +#define GL_STACK_UNDERFLOW_KHR 0x0504 +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif + /*------------------------------------------------------------------------* * AMD extension tokens *------------------------------------------------------------------------*/ @@ -193,6 +309,18 @@ typedef struct __GLeglImageOES *GLeglImageOES; * ANGLE extension tokens *------------------------------------------------------------------------*/ +/* GL_ANGLE_depth_texture */ +#ifndef GL_ANGLE_depth_texture +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_UNSIGNED_INT 0x1405 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif + /* GL_ANGLE_framebuffer_blit */ #ifndef GL_ANGLE_framebuffer_blit #define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 @@ -208,16 +336,48 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_MAX_SAMPLES_ANGLE 0x8D57 #endif +/* GL_ANGLE_instanced_arrays */ +#ifndef GL_ANGLE_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE +#endif + +/* GL_ANGLE_pack_reverse_row_order */ +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 +#endif + +/* GL_ANGLE_program_binary */ +#ifndef GL_ANGLE_program_binary +#define GL_PROGRAM_BINARY_ANGLE 0x93A6 +#endif + +/* GL_ANGLE_texture_compression_dxt3 */ +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 +#endif + +/* GL_ANGLE_texture_compression_dxt5 */ +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 +#endif + +/* GL_ANGLE_texture_usage */ +#ifndef GL_ANGLE_texture_usage +#define GL_TEXTURE_USAGE_ANGLE 0x93A2 +#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 +#endif + +/* GL_ANGLE_translated_shader_source */ +#ifndef GL_ANGLE_translated_shader_source +#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 +#endif + /*------------------------------------------------------------------------* * APPLE extension tokens *------------------------------------------------------------------------*/ -/* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_rgb_422 -#define GL_RGB_422_APPLE 0x8A1F -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif +/* GL_APPLE_copy_texture_levels */ +/* No new tokens introduced by this extension. */ /* GL_APPLE_framebuffer_multisample */ #ifndef GL_APPLE_framebuffer_multisample @@ -230,6 +390,34 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA #endif +/* GL_APPLE_rgb_422 */ +#ifndef GL_APPLE_rgb_422 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync + +#define GL_SYNC_OBJECT_APPLE 0x8A53 +#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 +#define GL_OBJECT_TYPE_APPLE 0x9112 +#define GL_SYNC_CONDITION_APPLE 0x9113 +#define GL_SYNC_STATUS_APPLE 0x9114 +#define GL_SYNC_FLAGS_APPLE 0x9115 +#define GL_SYNC_FENCE_APPLE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 +#define GL_UNSIGNALED_APPLE 0x9118 +#define GL_SIGNALED_APPLE 0x9119 +#define GL_ALREADY_SIGNALED_APPLE 0x911A +#define GL_TIMEOUT_EXPIRED_APPLE 0x911B +#define GL_CONDITION_SATISFIED_APPLE 0x911C +#define GL_WAIT_FAILED_APPLE 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 +#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull +#endif + /* GL_APPLE_texture_format_BGRA8888 */ #ifndef GL_APPLE_texture_format_BGRA8888 #define GL_BGRA_EXT 0x80E1 @@ -244,6 +432,11 @@ typedef struct __GLeglImageOES *GLeglImageOES; * ARM extension tokens *------------------------------------------------------------------------*/ +/* GL_ARM_mali_program_binary */ +#ifndef GL_ARM_mali_program_binary +#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61 +#endif + /* GL_ARM_mali_shader_binary */ #ifndef GL_ARM_mali_shader_binary #define GL_MALI_SHADER_BINARY_ARM 0x8F60 @@ -292,12 +485,80 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_STENCIL_EXT 0x1802 #endif +#ifndef GL_EXT_disjoint_timer_query +#define GL_QUERY_COUNTER_BITS_EXT 0x8864 +#define GL_CURRENT_QUERY_EXT 0x8865 +#define GL_QUERY_RESULT_EXT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 +#define GL_TIME_ELAPSED_EXT 0x88BF +#define GL_TIMESTAMP_EXT 0x8E28 +#define GL_GPU_DISJOINT_EXT 0x8FBB +#endif + +#ifndef GL_EXT_draw_buffers +#define GL_EXT_draw_buffers 1 +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_MAX_DRAW_BUFFERS_EXT 0x8824 +#define GL_DRAW_BUFFER0_EXT 0x8825 +#define GL_DRAW_BUFFER1_EXT 0x8826 +#define GL_DRAW_BUFFER2_EXT 0x8827 +#define GL_DRAW_BUFFER3_EXT 0x8828 +#define GL_DRAW_BUFFER4_EXT 0x8829 +#define GL_DRAW_BUFFER5_EXT 0x882A +#define GL_DRAW_BUFFER6_EXT 0x882B +#define GL_DRAW_BUFFER7_EXT 0x882C +#define GL_DRAW_BUFFER8_EXT 0x882D +#define GL_DRAW_BUFFER9_EXT 0x882E +#define GL_DRAW_BUFFER10_EXT 0x882F +#define GL_DRAW_BUFFER11_EXT 0x8830 +#define GL_DRAW_BUFFER12_EXT 0x8831 +#define GL_DRAW_BUFFER13_EXT 0x8832 +#define GL_DRAW_BUFFER14_EXT 0x8833 +#define GL_DRAW_BUFFER15_EXT 0x8834 +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#endif + +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_MAP_READ_BIT_EXT 0x0001 +#define GL_MAP_WRITE_BIT_EXT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 +#endif + /* GL_EXT_multisampled_render_to_texture */ #ifndef GL_EXT_multisampled_render_to_texture #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C -#define GL_RENDERBUFFER_SAMPLES_EXT 0x9133 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x9134 -#define GL_MAX_SAMPLES_EXT 0x9135 +/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */ +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +/* GL_EXT_multiview_draw_buffers */ +#ifndef GL_EXT_multiview_draw_buffers +#define GL_COLOR_ATTACHMENT_EXT 0x90F0 +#define GL_MULTIVIEW_EXT 0x90F1 +#define GL_DRAW_BUFFER_EXT 0x0C01 +#define GL_READ_BUFFER_EXT 0x0C02 +#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 #endif /* GL_EXT_multi_draw_arrays */ @@ -341,6 +602,11 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A #endif +/* GL_EXT_shader_framebuffer_fetch */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif + /* GL_EXT_shader_texture_lod */ /* No new tokens introduced by this extension. */ @@ -397,13 +663,19 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_LUMINANCE32F_EXT 0x8818 // -> ARB #define GL_LUMINANCE_ALPHA32F_EXT 0x8819 // -> ARB /* reuse GL_RGBA16F_EXT */ -#define GL_RGB16F_EXT 0x881B // remove EXT (duplicate in GL_EXT_color_buffer_half_float) -#define GL_ALPHA16F_EXT 0x881C // -> ARB -#define GL_LUMINANCE16F_EXT 0x881E // -> ARB -#define GL_LUMINANCE_ALPHA16F_EXT 0x881F // -> ARB -#define GL_RGB10_A2_EXT 0x8059 // remove EXT -#define GL_RGB10_EXT 0x8052 // remove EXT -#define GL_BGRA8_EXT 0x93A1 // keep +/* reuse GL_RGB16F_EXT */ +#define GL_ALPHA16F_EXT 0x881C +#define GL_LUMINANCE16F_EXT 0x881E +#define GL_LUMINANCE_ALPHA16F_EXT 0x881F +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGB10_EXT 0x8052 +#define GL_BGRA8_EXT 0x93A1 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#define GL_R32F_EXT 0x822E +#define GL_RG32F_EXT 0x8230 +#define GL_R16F_EXT 0x822D +#define GL_RG16F_EXT 0x822F #endif /* GL_EXT_texture_type_2_10_10_10_REV */ @@ -413,9 +685,9 @@ typedef struct __GLeglImageOES *GLeglImageOES; /* GL_EXT_unpack_subimage */ #ifndef GL_EXT_unpack_subimage -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 +#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 #endif /*------------------------------------------------------------------------* @@ -427,6 +699,15 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_SHADER_BINARY_DMP 0x9250 #endif +/*------------------------------------------------------------------------* + * FJ extension tokens + *------------------------------------------------------------------------*/ + +/* GL_FJ_shader_binary_GCCSO */ +#ifndef GL_FJ_shader_binary_GCCSO +#define GL_GCCSO_SHADER_BINARY_FJ 0x9260 +#endif + /*------------------------------------------------------------------------* * IMG extension tokens *------------------------------------------------------------------------*/ @@ -455,6 +736,12 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 #endif +/* GL_IMG_texture_compression_pvrtc2 */ +#ifndef GL_IMG_texture_compression_pvrtc2 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 +#endif + /* GL_IMG_multisampled_render_to_texture */ #ifndef GL_IMG_multisampled_render_to_texture #define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 @@ -484,7 +771,7 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 #define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 #define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 -#define GL_COVERAGE_BUFFER_BIT_NV 0x8000 +#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000 #endif /* GL_NV_depth_nonlinear */ @@ -529,6 +816,9 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_COLOR_ATTACHMENT15_NV 0x8CEF #endif +/* GL_NV_draw_instanced */ +/* No new tokens introduced by this extension. */ + /* GL_NV_fbo_color_attachments */ #ifndef GL_NV_fbo_color_attachments #define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF @@ -542,6 +832,29 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_FENCE_CONDITION_NV 0x84F4 #endif +/* GL_NV_framebuffer_blit */ +#ifndef GL_NV_framebuffer_blit +#define GL_READ_FRAMEBUFFER_NV 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA +#endif + +/* GL_NV_framebuffer_multisample */ +#ifndef GL_NV_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56 +#define GL_MAX_SAMPLES_NV 0x8D57 +#endif + +/* GL_NV_generate_mipmap_sRGB */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_instanced_arrays */ +#ifndef GL_NV_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE +#endif + /* GL_NV_read_buffer */ #ifndef GL_NV_read_buffer #define GL_READ_BUFFER_NV 0x0C02 @@ -559,6 +872,36 @@ typedef struct __GLeglImageOES *GLeglImageOES; /* GL_NV_read_stencil */ /* No new tokens introduced by this extension. */ +/* GL_NV_shadow_samplers_array */ +#ifndef GL_NV_shadow_samplers_array +#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4 +#endif + +/* GL_NV_shadow_samplers_cube */ +#ifndef GL_NV_shadow_samplers_cube +#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 +#endif + +/* GL_NV_sRGB_formats */ +#ifndef GL_NV_sRGB_formats +#define GL_SLUMINANCE_NV 0x8C46 +#define GL_SLUMINANCE_ALPHA_NV 0x8C44 +#define GL_SRGB8_NV 0x8C41 +#define GL_SLUMINANCE8_NV 0x8C47 +#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F +#define GL_ETC1_SRGB8_NV 0x88EE +#endif + +/* GL_NV_texture_border_clamp */ +#ifndef GL_NV_texture_border_clamp +#define GL_TEXTURE_BORDER_COLOR_NV 0x1004 +#define GL_CLAMP_TO_BORDER_NV 0x812D +#endif + /* GL_NV_texture_compression_s3tc_update */ /* No new tokens introduced by this extension. */ @@ -576,6 +919,14 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_ALPHA_TEST_REF_QCOM 0x0BC2 #endif +/* GL_QCOM_binning_control */ +#ifndef GL_QCOM_binning_control +#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 +#define GL_CPU_OPTIMIZED_QCOM 0x8FB1 +#define GL_GPU_OPTIMIZED_QCOM 0x8FB2 +#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 +#endif + /* GL_QCOM_driver_control */ /* No new tokens introduced by this extension. */ @@ -746,6 +1097,11 @@ typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum #define GL_OES_packed_depth_stencil 1 #endif +/* GL_OES_required_internalformat */ +#ifndef GL_OES_required_internalformat +#define GL_OES_required_internalformat 1 +#endif + /* GL_OES_rgb8_rgba8 */ #ifndef GL_OES_rgb8_rgba8 #define GL_OES_rgb8_rgba8 1 @@ -766,18 +1122,22 @@ typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum #define GL_OES_stencil4 1 #endif +#ifndef GL_OES_surfaceless_context +#define GL_OES_surfaceless_context 1 +#endif + /* GL_OES_texture_3D */ #ifndef GL_OES_texture_3D #define GL_OES_texture_3D 1 #ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); #endif -typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); @@ -835,6 +1195,43 @@ typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); #define GL_OES_vertex_type_10_10_10_2 1 #endif +/*------------------------------------------------------------------------* + * KHR extension functions + *------------------------------------------------------------------------*/ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam); +GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void); +GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params); +#endif +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam); +typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void); +typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, void **params); +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif + + /*------------------------------------------------------------------------* * AMD extension functions *------------------------------------------------------------------------*/ @@ -887,6 +1284,11 @@ typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monito * ANGLE extension functions *------------------------------------------------------------------------*/ +/* GL_ANGLE_depth_texture */ +#ifndef GL_ANGLE_depth_texture +#define GL_ANGLE_depth_texture 1 +#endif + /* GL_ANGLE_framebuffer_blit */ #ifndef GL_ANGLE_framebuffer_blit #define GL_ANGLE_framebuffer_blit 1 @@ -905,13 +1307,62 @@ GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #endif +#ifndef GL_ANGLE_instanced_arrays +#define GL_ANGLE_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); +#endif + +/* GL_ANGLE_pack_reverse_row_order */ +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_ANGLE_pack_reverse_row_order 1 +#endif + +/* GL_ANGLE_program_binary */ +#ifndef GL_ANGLE_program_binary +#define GL_ANGLE_program_binary 1 +#endif + +/* GL_ANGLE_texture_compression_dxt3 */ +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_ANGLE_texture_compression_dxt3 1 +#endif + +/* GL_ANGLE_texture_compression_dxt5 */ +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_ANGLE_texture_compression_dxt5 1 +#endif + +/* GL_ANGLE_texture_usage */ +#ifndef GL_ANGLE_texture_usage +#define GL_ANGLE_texture_usage 1 +#endif + +#ifndef GL_ANGLE_translated_shader_source +#define GL_ANGLE_translated_shader_source 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); +#endif +typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); +#endif + /*------------------------------------------------------------------------* * APPLE extension functions *------------------------------------------------------------------------*/ -/* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 +/* GL_APPLE_copy_texture_levels */ +#ifndef GL_APPLE_copy_texture_levels +#define GL_APPLE_copy_texture_levels 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif +typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); #endif /* GL_APPLE_framebuffer_multisample */ @@ -925,6 +1376,32 @@ typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); #endif +/* GL_APPLE_rgb_422 */ +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#endif + +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync +#define GL_APPLE_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + /* GL_APPLE_texture_format_BGRA8888 */ #ifndef GL_APPLE_texture_format_BGRA8888 #define GL_APPLE_texture_format_BGRA8888 1 @@ -939,6 +1416,11 @@ typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); * ARM extension functions *------------------------------------------------------------------------*/ +/* GL_ARM_mali_program_binary */ +#ifndef GL_ARM_mali_program_binary +#define GL_ARM_mali_program_binary 1 +#endif + /* GL_ARM_mali_shader_binary */ #ifndef GL_ARM_mali_shader_binary #define GL_ARM_mali_shader_binary 1 @@ -996,6 +1478,53 @@ GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numA typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); #endif +#ifndef GL_EXT_disjoint_timer_query +#define GL_EXT_disjoint_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target); +GL_APICALL void GL_APIENTRY glQueryCounterEXT (GLuint id, GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#endif /* GL_EXT_disjoint_timer_query */ + +#ifndef GL_EXT_draw_buffers +#define GL_EXT_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs); +#endif /* GL_EXT_draw_buffers */ + +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_EXT_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); +#endif +typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + /* GL_EXT_multisampled_render_to_texture */ #ifndef GL_EXT_multisampled_render_to_texture #define GL_EXT_multisampled_render_to_texture 1 @@ -1007,13 +1536,26 @@ typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum t typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); #endif +/* GL_EXT_multiview_draw_buffers */ +#ifndef GL_EXT_multiview_draw_buffers +#define GL_EXT_multiview_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index); +GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices); +GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data); +#endif +typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data); +#endif + #ifndef GL_EXT_multi_draw_arrays #define GL_EXT_multi_draw_arrays 1 #ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei); GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); #endif @@ -1125,6 +1667,11 @@ typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); #endif +/* GL_EXT_shader_framebuffer_fetch */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#endif + /* GL_EXT_shader_texture_lod */ #ifndef GL_EXT_shader_texture_lod #define GL_EXT_shader_texture_lod 1 @@ -1198,6 +1745,15 @@ typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum #define GL_DMP_shader_binary 1 #endif +/*------------------------------------------------------------------------* + * FJ extension functions + *------------------------------------------------------------------------*/ + +/* GL_FJ_shader_binary_GCCSO */ +#ifndef GL_FJ_shader_binary_GCCSO +#define GL_FJ_shader_binary_GCCSO 1 +#endif + /*------------------------------------------------------------------------* * IMG extension functions *------------------------------------------------------------------------*/ @@ -1222,6 +1778,11 @@ typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum #define GL_IMG_texture_compression_pvrtc 1 #endif +/* GL_IMG_texture_compression_pvrtc2 */ +#ifndef GL_IMG_texture_compression_pvrtc2 +#define GL_IMG_texture_compression_pvrtc2 1 +#endif + /* GL_IMG_multisampled_render_to_texture */ #ifndef GL_IMG_multisampled_render_to_texture #define GL_IMG_multisampled_render_to_texture 1 @@ -1229,8 +1790,8 @@ typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); #endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); #endif /*------------------------------------------------------------------------* @@ -1262,6 +1823,17 @@ GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs); typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs); #endif +/* GL_NV_draw_instanced */ +#ifndef GL_NV_draw_instanced +#define GL_NV_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif +typedef void (GL_APIENTRYP PFNDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + /* GL_NV_fbo_color_attachments */ #ifndef GL_NV_fbo_color_attachments #define GL_NV_fbo_color_attachments 1 @@ -1288,6 +1860,38 @@ typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); #endif +/* GL_NV_framebuffer_blit */ +#ifndef GL_NV_framebuffer_blit +#define GL_NV_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferNV (int srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +typedef void (GL_APIENTRYP PFNBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +/* GL_NV_framebuffer_multisample */ +#ifndef GL_NV_framebuffer_multisample +#define GL_NV_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +typedef void (GL_APIENTRYP PFNRENDERBUFFERSTORAGEMULTISAMPLENVPROC) ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +/* GL_NV_generate_mipmap_sRGB */ +#ifndef GL_NV_generate_mipmap_sRGB +#define GL_NV_generate_mipmap_sRGB 1 +#endif + +/* GL_NV_instanced_arrays */ +#ifndef GL_NV_instanced_arrays +#define GL_NV_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor); +#endif +typedef void (GL_APIENTRYP PFNVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor); +#endif + /* GL_NV_read_buffer */ #ifndef GL_NV_read_buffer #define GL_NV_read_buffer 1 @@ -1317,6 +1921,26 @@ typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode); #define GL_NV_read_stencil 1 #endif +/* GL_NV_shadow_samplers_array */ +#ifndef GL_NV_shadow_samplers_array +#define GL_NV_shadow_samplers_array 1 +#endif + +/* GL_NV_shadow_samplers_cube */ +#ifndef GL_NV_shadow_samplers_cube +#define GL_NV_shadow_samplers_cube 1 +#endif + +/* GL_NV_sRGB_formats */ +#ifndef GL_NV_sRGB_formats +#define GL_NV_sRGB_formats 1 +#endif + +/* GL_NV_texture_border_clamp */ +#ifndef GL_NV_texture_border_clamp +#define GL_NV_texture_border_clamp 1 +#endif + /* GL_NV_texture_compression_s3tc_update */ #ifndef GL_NV_texture_compression_s3tc_update #define GL_NV_texture_compression_s3tc_update 1 @@ -1340,6 +1964,11 @@ GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref); typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref); #endif +/* GL_QCOM_binning_control */ +#ifndef GL_QCOM_binning_control +#define GL_QCOM_binning_control 1 +#endif + /* GL_QCOM_driver_control */ #ifndef GL_QCOM_driver_control #define GL_QCOM_driver_control 1 diff --git a/make/stub_includes/opengl/GLES3/gl3.h b/make/stub_includes/opengl/GLES3/gl3.h new file mode 100644 index 000000000..dc0409f54 --- /dev/null +++ b/make/stub_includes/opengl/GLES3/gl3.h @@ -0,0 +1,1073 @@ +#ifndef __gl3_h_ +#define __gl3_h_ + +/* + * gl3.h last updated on $Date: 2013-02-12 14:37:24 -0800 (Tue, 12 Feb 2013) $ + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007-2013 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/*------------------------------------------------------------------------- + * Data type definitions + *-----------------------------------------------------------------------*/ + +/* OpenGL ES 2.0 */ + +typedef void GLvoid; +typedef char GLchar; +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef khronos_int8_t GLbyte; +typedef short GLshort; +typedef int GLint; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef khronos_float_t GLfloat; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_intptr_t GLintptr; +typedef khronos_ssize_t GLsizeiptr; + +/* OpenGL ES 3.0 */ + +typedef unsigned short GLhalf; +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef struct __GLsync *GLsync; + +/*------------------------------------------------------------------------- + * Token definitions + *-----------------------------------------------------------------------*/ + +/* OpenGL ES 2.0 */ +#ifndef GL_ES_VERSION_2_0 + +/* ClearBufferMask */ +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 + +/* Boolean */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* BeginMode */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 + +/* BlendingFactorDest */ +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 + +/* BlendingFactorSrc */ +/* GL_ZERO */ +/* GL_ONE */ +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +/* GL_SRC_ALPHA */ +/* GL_ONE_MINUS_SRC_ALPHA */ +/* GL_DST_ALPHA */ +/* GL_ONE_MINUS_DST_ALPHA */ + +/* BlendEquationSeparate */ +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ +#define GL_BLEND_EQUATION_ALPHA 0x883D + +/* BlendSubtract */ +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B + +/* Separate Blend Functions */ +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 + +/* Buffer Objects */ +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 + +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 + +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 + +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 + +/* CullFaceMode */ +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 + +/* DepthFunction */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* EnableCap */ +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 + +/* ErrorCode */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 + +/* FrontFaceDirection */ +#define GL_CW 0x0900 +#define GL_CCW 0x0901 + +/* GetPName */ +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +/* GL_SCISSOR_TEST */ +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +/* GL_POLYGON_OFFSET_FILL */ +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB + +/* GetTextureParameter */ +/* GL_TEXTURE_MAG_FILTER */ +/* GL_TEXTURE_MIN_FILTER */ +/* GL_TEXTURE_WRAP_S */ +/* GL_TEXTURE_WRAP_T */ + +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 + +/* HintMode */ +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* HintTarget */ +#define GL_GENERATE_MIPMAP_HINT 0x8192 + +/* DataType */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C + +/* PixelFormat */ +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A + +/* PixelType */ +/* GL_UNSIGNED_BYTE */ +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 + +/* Shaders */ +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D + +/* StencilFunction */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 + +/* StencilOp */ +/* GL_ZERO */ +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 + +/* StringName */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* TextureMagFilter */ +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 + +/* TextureMinFilter */ +/* GL_NEAREST */ +/* GL_LINEAR */ +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 + +/* TextureParameterName */ +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 + +/* TextureTarget */ +/* GL_TEXTURE_2D */ +#define GL_TEXTURE 0x1702 + +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C + +/* TextureUnit */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 + +/* TextureWrapMode */ +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 + +/* Uniform Types */ +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 + +/* Vertex Arrays */ +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F + +/* Read Format */ +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B + +/* Shader Source */ +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA + +/* Shader Binary */ +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 + +/* Shader Precision-Specified Types */ +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 + +/* Framebuffer Object. */ +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 + +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 + +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 + +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 + +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 + +#define GL_NONE 0 + +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD + +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 + +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 + +#endif /* GL_ES_VERSION_2_0 */ + +/* OpenGL ES 3.0 */ +#ifndef GL_ES_VERSION_3_0 + +#define GL_READ_BUFFER 0x0C02 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_RED 0x1903 +#define GL_RGB8 0x8051 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_RG8 0x822B +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_COPY_READ_BUFFER_BINDING GL_COPY_READ_BUFFER +#define GL_COPY_WRITE_BUFFER_BINDING GL_COPY_WRITE_BUFFER +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_INT_2_10_10_10_REV 0x8D9F +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF + +#endif /* GL_ES_VERSION_3_0 */ + +/* OpenGL ES 2.0 */ +#ifndef GL_ES_VERSION_2_0 +#define GL_ES_VERSION_2_0 1 + +/*------------------------------------------------------------------------- + * Entrypoint definitions + *-----------------------------------------------------------------------*/ + +/* OpenGL ES 2.0 */ + +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat depth); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat zNear, GLfloat zFar); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); +GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); + +#endif /* GL_ES_VERSION_2_0 */ + +/* OpenGL ES 3.0 */ +#ifndef GL_ES_VERSION_3_0 +#define GL_ES_VERSION_3_0 1 + +GL_APICALL void GL_APIENTRY glReadBuffer (GLenum mode); +GL_APICALL void GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices); +GL_APICALL void GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glGenQueries (GLsizei n, GLuint* ids); +GL_APICALL void GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint* ids); +GL_APICALL GLboolean GL_APIENTRY glIsQuery (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQuery (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQuery (GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint* params); +GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid** params); +GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum* bufs); +GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GL_APICALL void* GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GL_APICALL void GL_APIENTRY glBindVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint* arrays); +GL_APICALL void GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint* arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint* data); +GL_APICALL void GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GL_APICALL void GL_APIENTRY glEndTransformFeedback (void); +GL_APICALL void GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode); +GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name); +GL_APICALL void GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); +GL_APICALL void GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint* params); +GL_APICALL void GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint* v); +GL_APICALL void GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint* v); +GL_APICALL void GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint* params); +GL_APICALL GLint GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glUniform1ui (GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint* value); +GL_APICALL void GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint* value); +GL_APICALL void GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint* value); +GL_APICALL void GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint* value); +GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint* value); +GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint* value); +GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat* value); +GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GL_APICALL const GLubyte* GL_APIENTRY glGetStringi (GLenum name, GLuint index); +GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices); +GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params); +GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar* uniformBlockName); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName); +GL_APICALL void GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +GL_APICALL void GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instanceCount); +GL_APICALL void GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount); +GL_APICALL GLsync GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSync (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSync (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64v (GLenum pname, GLint64* params); +GL_APICALL void GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values); +GL_APICALL void GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64* data); +GL_APICALL void GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64* params); +GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint* samplers); +GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint* samplers); +GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler); +GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint* param); +GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat* param); +GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GL_APICALL void GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint* ids); +GL_APICALL void GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint* ids); +GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback (GLuint id); +GL_APICALL void GL_APIENTRY glPauseTransformFeedback (void); +GL_APICALL void GL_APIENTRY glResumeTransformFeedback (void); +GL_APICALL void GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary); +GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length); +GL_APICALL void GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments); +GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params); + +#endif /* GL_ES_VERSION_3_0 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/make/stub_includes/opengl/GLES3/gl3ext.h b/make/stub_includes/opengl/GLES3/gl3ext.h new file mode 100644 index 000000000..4d4ea96c4 --- /dev/null +++ b/make/stub_includes/opengl/GLES3/gl3ext.h @@ -0,0 +1,24 @@ +#ifndef __gl3ext_h_ +#define __gl3ext_h_ + +/* $Revision: 17809 $ on $Date:: 2012-05-14 08:03:36 -0700 #$ */ + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/* OpenGL ES 3 Extensions + * + * After an OES extension's interactions with OpenGl ES 3.0 have been documented, + * its tokens and function definitions should be added to this file in a manner + * that does not conflict with gl2ext.h or gl3.h. + * + * Tokens and function definitions for extensions that have become standard + * features in OpenGL ES 3.0 will not be added to this file. + * + * Applications using OpenGL-ES-2-only extensions should include gl2ext.h + */ + +#endif /* __gl3ext_h_ */ + diff --git a/make/stub_includes/opengl/GLES3/gl3platform.h b/make/stub_includes/opengl/GLES3/gl3platform.h new file mode 100644 index 000000000..1bd1a850f --- /dev/null +++ b/make/stub_includes/opengl/GLES3/gl3platform.h @@ -0,0 +1,30 @@ +#ifndef __gl3platform_h_ +#define __gl3platform_h_ + +/* $Revision: 18437 $ on $Date:: 2012-07-08 23:31:39 -0700 #$ */ + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/* Platform-specific types and definitions for OpenGL ES 3.X gl3.h + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) + * by filing a bug against product "OpenGL-ES" component "Registry". + */ + +#include + +#ifndef GL_APICALL +#define GL_APICALL KHRONOS_APICALL +#endif + +#ifndef GL_APIENTRY +#define GL_APIENTRY KHRONOS_APIENTRY +#endif + +#endif /* __gl3platform_h_ */ diff --git a/make/stub_includes/opengl/GLES3/khrplatform.h b/make/stub_includes/opengl/GLES3/khrplatform.h new file mode 100644 index 000000000..8ec0d199f --- /dev/null +++ b/make/stub_includes/opengl/GLES3/khrplatform.h @@ -0,0 +1,269 @@ +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $ + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by sending them to the public Khronos Bugzilla + * (http://khronos.org/bugzilla) by filing a bug against product + * "Khronos (general)" component "Registry". + * + * A predefined template which fills in some of the bug fields can be + * reached using http://tinyurl.com/khrplatform-h-bugreport, but you + * must create a Bugzilla login first. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(_WIN32) && !defined(__SCITECH_SNAP__) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ diff --git a/make/stub_includes/opengl/gl-64bit-types.h b/make/stub_includes/opengl/gl-64bit-types.h deleted file mode 100644 index f40eeae55..000000000 --- a/make/stub_includes/opengl/gl-64bit-types.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __gl_64bit_types_h_ -#define __gl_64bit_types_h_ - -#include - -#ifdef KHRONOS_SUPPORT_INT64 - - #ifndef GL_EXT_timer_query - typedef khronos_int64_t GLint64EXT; - typedef khronos_uint64_t GLuint64EXT; - #endif - - #ifndef GL_ARB_sync - typedef khronos_int64_t GLint64; - typedef khronos_uint64_t GLuint64; - typedef struct __GLsync *GLsync; - #endif - -#endif /* KHRONOS_SUPPORT_INT64 */ - -#endif /* __gl_64bit_types_h_ */ diff --git a/make/stub_includes/opengl/gl-types.h b/make/stub_includes/opengl/gl-types.h new file mode 100644 index 000000000..e7e869708 --- /dev/null +++ b/make/stub_includes/opengl/gl-types.h @@ -0,0 +1,15 @@ +#ifndef __gl_types_h_ +#define __gl_types_h_ + +#include + +#define GLEXT_64_TYPES_DEFINED 1 + +typedef khronos_int64_t GLint64EXT; +typedef khronos_uint64_t GLuint64EXT; + +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef struct __GLsync *GLsync; + +#endif /* __gl_types_h_ */ diff --git a/make/stub_includes/opengl/gl2es12.c b/make/stub_includes/opengl/gl2es12.c deleted file mode 100644 index 514393f0b..000000000 --- a/make/stub_includes/opengl/gl2es12.c +++ /dev/null @@ -1,9 +0,0 @@ -#define GLAPI - -// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in -// "glext.h" are parsed. -#define GL_GLEXT_PROTOTYPES - -#include -#include - diff --git a/make/stub_includes/opengl/gl3.c b/make/stub_includes/opengl/gl3.c index ff035e40b..e145bf41d 100644 --- a/make/stub_includes/opengl/gl3.c +++ b/make/stub_includes/opengl/gl3.c @@ -1,13 +1,8 @@ #define GLAPI -// Define GL3_PROTOTYPES so that the OpenGL prototypes in -// "gl3.h" are parsed. -#define GL3_PROTOTYPES +// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. +#define GL_GLEXT_PROTOTYPES -// Define GL_GL3EXT_PROTOTYPES so that the OpenGL extension prototypes in -// "gl3ext.h" are parsed. -#define GL_GL3EXT_PROTOTYPES - -#include -#include +#include +#include diff --git a/make/stub_includes/opengl/gl3bc.c b/make/stub_includes/opengl/gl3bc.c index eed7c9c26..a40fe13c1 100644 --- a/make/stub_includes/opengl/gl3bc.c +++ b/make/stub_includes/opengl/gl3bc.c @@ -1,19 +1,10 @@ #define GLAPI -// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in -// "glext.h" are parsed. +// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. #define GL_GLEXT_PROTOTYPES #include #include -// Define GL3_PROTOTYPES so that the OpenGL prototypes in -// "gl3.h" are parsed. -#define GL3_PROTOTYPES - -// Define GL_GL3EXT_PROTOTYPES so that the OpenGL extension prototypes in -// "gl3ext.h" are parsed. -#define GL_GL3EXT_PROTOTYPES - -#include +#include diff --git a/make/stub_includes/opengl/gl4.c b/make/stub_includes/opengl/gl4.c index 3a3adf0f4..e145bf41d 100644 --- a/make/stub_includes/opengl/gl4.c +++ b/make/stub_includes/opengl/gl4.c @@ -1,12 +1,8 @@ #define GLAPI -// Define GL3_PROTOTYPES so that the OpenGL prototypes in -// "gl3.h" are parsed. -#define GL3_PROTOTYPES +// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. +#define GL_GLEXT_PROTOTYPES -// Define GL_GL3EXT_PROTOTYPES so that the OpenGL extension prototypes in -// "gl3ext.h" are parsed. -#define GL_GL3EXT_PROTOTYPES +#include +#include -#include -#include diff --git a/make/stub_includes/opengl/gl4bc.c b/make/stub_includes/opengl/gl4bc.c index eed7c9c26..a40fe13c1 100644 --- a/make/stub_includes/opengl/gl4bc.c +++ b/make/stub_includes/opengl/gl4bc.c @@ -1,19 +1,10 @@ #define GLAPI -// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in -// "glext.h" are parsed. +// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. #define GL_GLEXT_PROTOTYPES #include #include -// Define GL3_PROTOTYPES so that the OpenGL prototypes in -// "gl3.h" are parsed. -#define GL3_PROTOTYPES - -// Define GL_GL3EXT_PROTOTYPES so that the OpenGL extension prototypes in -// "gl3ext.h" are parsed. -#define GL_GL3EXT_PROTOTYPES - -#include +#include diff --git a/make/stub_includes/opengl/gles3.c b/make/stub_includes/opengl/gles3.c new file mode 100644 index 000000000..3d2ad8c75 --- /dev/null +++ b/make/stub_includes/opengl/gles3.c @@ -0,0 +1,12 @@ +#define GL_APICALL +#define GL_APIENTRY + +// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in +// "glext.h" are parsed. +#define GL_GLEXT_PROTOTYPES + +#include +#include + +/** We assume ES2 extensions maybe avail on ES3 .. */ +#include diff --git a/make/stub_includes/win32/windows.h b/make/stub_includes/win32/windows.h index 51ebbdcce..f7b141e31 100644 --- a/make/stub_includes/win32/windows.h +++ b/make/stub_includes/win32/windows.h @@ -46,4 +46,7 @@ typedef __int32 HRESULT; typedef HANDLE HPBUFFERARB; typedef HANDLE HPBUFFEREXT; typedef HANDLE HGPUNV; +typedef HANDLE HVIDEOOUTPUTDEVICENV; +typedef HANDLE HVIDEOINPUTDEVICENV; +typedef HANDLE HPVIDEODEV; diff --git a/make/stub_includes/x11/window-system1.c b/make/stub_includes/x11/window-system1.c index e718aee97..a06f39dae 100644 --- a/make/stub_includes/x11/window-system1.c +++ b/make/stub_includes/x11/window-system1.c @@ -1,6 +1,6 @@ -// Define GLX_GLXEXT_PROTOTYPES so that the OpenGL GLX extension prototypes in -// "glxext.h" are parsed. -#define GLX_GLXEXT_PROTOTYPES +// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in +// "glext.h" are parsed. +#define GL_GLEXT_PROTOTYPES #include #include diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 5334d45cf..b9096df3c 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -71,7 +71,7 @@ public class BuildComposablePipeline { // Only desktop OpenGL has immediate mode glBegin / glEnd private boolean hasImmediateMode; // Desktop OpenGL and GLES1 have GL_STACK_OVERFLOW and GL_STACK_UNDERFLOW errors - private boolean hasStackOverflow; + private boolean hasGL2ES1StackOverflow; public static Class getClass(String name) { Class clazz = null; @@ -155,7 +155,7 @@ public class BuildComposablePipeline { } try { - hasStackOverflow = + hasGL2ES1StackOverflow = hasImmediateMode && (classToComposeAround.getField("GL_STACK_OVERFLOW") != null); } catch (Exception e) { } @@ -602,13 +602,9 @@ public class BuildComposablePipeline { * Emits one of the isGL* methods. */ protected void emitGLIsMethod(PrintWriter output, String type) { + output.println(" @Override"); output.println(" public boolean is" + type + "() {"); - Class clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); - if (clazz.isAssignableFrom(baseInterfaceClass)) { - output.println(" return true;"); - } else { - output.println(" return false;"); - } + output.println(" return " + getDownstreamObjectName() + ".is" + type + "();"); output.println(" }"); } @@ -624,28 +620,24 @@ public class BuildComposablePipeline { emitGLIsMethod(output, "GL2"); emitGLIsMethod(output, "GLES1"); emitGLIsMethod(output, "GLES2"); + emitGLIsMethod(output, "GLES3"); emitGLIsMethod(output, "GL2ES1"); emitGLIsMethod(output, "GL2ES2"); + emitGLIsMethod(output, "GL3ES3"); + emitGLIsMethod(output, "GL4ES3"); emitGLIsMethod(output, "GL2GL3"); - output.println(" public boolean isGLES() {"); - output.println(" return isGLES2() || isGLES1();"); - output.println(" }"); - output.println(" public boolean isGLES2Compatible() {"); - output.println(" return " + getDownstreamObjectName() + ".isGLES2Compatible();"); - output.println(" }"); + emitGLIsMethod(output, "GLES"); + emitGLIsMethod(output, "GLES2Compatible"); + emitGLIsMethod(output, "GLES3Compatible"); } /** * Emits one of the getGL* methods. */ protected void emitGLGetMethod(PrintWriter output, String type) { + output.println(" @Override"); output.println(" public javax.media.opengl." + type + " get" + type + "() {"); - Class clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); - if (clazz.isAssignableFrom(baseInterfaceClass)) { - output.println(" return this;"); - } else { - output.println(" throw new GLException(\"Not a " + type + " implementation\");"); - } + output.println(" return " + getDownstreamObjectName() + ".get" + type + "();"); output.println(" }"); } @@ -661,9 +653,13 @@ public class BuildComposablePipeline { emitGLGetMethod(output, "GL2"); emitGLGetMethod(output, "GLES1"); emitGLGetMethod(output, "GLES2"); + emitGLGetMethod(output, "GLES3"); emitGLGetMethod(output, "GL2ES1"); emitGLGetMethod(output, "GL2ES2"); + emitGLGetMethod(output, "GL3ES3"); + emitGLGetMethod(output, "GL4ES3"); emitGLGetMethod(output, "GL2GL3"); + output.println(" @Override"); output.println(" public GLProfile getGLProfile() {"); output.println(" return " + getDownstreamObjectName() + ".getGLProfile();"); output.println(" }"); @@ -870,9 +866,9 @@ public class BuildComposablePipeline { output.println(" case GL_INVALID_ENUM: buf.append(\"GL_INVALID_ENUM \"); break;"); output.println(" case GL_INVALID_VALUE: buf.append(\"GL_INVALID_VALUE \"); break;"); output.println(" case GL_INVALID_OPERATION: buf.append(\"GL_INVALID_OPERATION \"); break;"); - if (hasStackOverflow) { - output.println(" case GL_STACK_OVERFLOW: buf.append(\"GL_STACK_OVERFLOW \"); break;"); - output.println(" case GL_STACK_UNDERFLOW: buf.append(\"GL_STACK_UNDERFLOW \"); break;"); + if (hasGL2ES1StackOverflow) { + output.println(" case GL2ES1.GL_STACK_OVERFLOW: buf.append(\"GL_STACK_OVERFLOW \"); break;"); + output.println(" case GL2ES1.GL_STACK_UNDERFLOW: buf.append(\"GL_STACK_UNDERFLOW \"); break;"); } output.println(" case GL_OUT_OF_MEMORY: buf.append(\"GL_OUT_OF_MEMORY \"); break;"); output.println(" case GL_NO_ERROR: throw new InternalError(\"Should not be treating GL_NO_ERROR as error\");"); diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java index 482d35cae..5298cc357 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java @@ -106,14 +106,21 @@ import java.util.regex.Pattern; public class BuildStaticGLInfo { // Handles function pointer - protected static int funcIdentifierGroup = 10; + protected static final int funcIdentifierGroup = 9; protected static Pattern funcPattern = - Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)((unsigned|const)\\s+)?(\\w+)(\\s*\\*)?(\\s+)(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)"); + Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)((unsigned|const)\\s+)?(\\w+)(\\s+\\*\\s*|\\s*\\*\\s+|\\s+)?(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)"); protected static Pattern associationPattern = Pattern.compile("\\#ifndef ([CEW]?GL[XU]?_[A-Za-z0-9_]+)(.*)"); - protected static int defineIdentifierGroup = 1; + protected static Pattern ifPattern = + Pattern.compile("\\#if(.*)"); + protected static Pattern elsePattern = + Pattern.compile("\\#(elif|else)(.*)"); + protected static Pattern endifPattern = + Pattern.compile("\\#endif(.*)"); + + protected static final int defineIdentifierGroup = 1; protected static Pattern definePattern = Pattern.compile("\\#define ([CEW]?GL[XU]?_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)(.*)"); @@ -194,38 +201,62 @@ public class BuildStaticGLInfo { BufferedReader reader = new BufferedReader(new FileReader(cHeaderFilePath)); String line, activeAssociation = null; Matcher m = null; + int block = 0; while ((line = reader.readLine()) != null) { - int type = 0; // 1-define, 2-function - // see if we're inside a #ifndef GL_XXX block and matching a function - if (activeAssociation != null) { + int type = 0; // 1-define, 2-function + if ( 0 < block ) { // inside a #ifndef GL_XXX block and matching a function, if block > 0 String identifier = null; - if ((m = funcPattern.matcher(line)).matches()) { - identifier = m.group(funcIdentifierGroup).trim(); - type = 2; - } else if ((m = definePattern.matcher(line)).matches()) { - identifier = m.group(defineIdentifierGroup).trim(); - type = 1; - } else if (line.startsWith("#endif")) { - if (DEBUG) { - System.err.println("END ASSOCIATION BLOCK: <" + activeAssociation + ">"); + if( 2 >= block ) { // not within sub-blocks > 2, i.e. further typedefs + if ((m = funcPattern.matcher(line)).matches()) { + identifier = m.group(funcIdentifierGroup).trim(); + type = 2; + } else if ((m = definePattern.matcher(line)).matches()) { + identifier = m.group(defineIdentifierGroup).trim(); + type = 1; } - activeAssociation = null; } - if ((identifier != null) - && (activeAssociation != null) - && // Handles #ifndef GL_... #define GL_... - !identifier.equals(activeAssociation)) { + if ( identifier != null && + activeAssociation != null && + !identifier.equals(activeAssociation) // Handles #ifndef GL_... #define GL_... + ) + { addAssociation(identifier, activeAssociation); if (DEBUG) { - System.err.println(" ADDING ASSOCIATION: <" + identifier + "> <" + activeAssociation + "> ; type " + type); + System.err.println("<"+block+"> ADDING ASSOCIATION: <" + identifier + "> <" + activeAssociation + "> ; type " + type); + } + } else { + if ((m = ifPattern.matcher(line)).matches()) { + final String comment = m.group(1).trim(); + block++; + if (DEBUG) { + System.err.println("<"+block+"> BEGIN IF BLOCK: <" + comment + ">"); + } + } else if ((m = elsePattern.matcher(line)).matches()) { + final String comment = m.group(1).trim(); + if (DEBUG) { + System.err.println("<"+block+"> ELSE BLOCK: <" + comment + ">"); + } + } else if ((m = endifPattern.matcher(line)).matches()) { + final String comment = m.group(1).trim(); + block--; + if( 0 == block ) { + if (DEBUG) { + System.err.println("<"+block+"> END ASSOCIATION BLOCK: <" + activeAssociation + " <-> " + comment + ">"); + } + activeAssociation = null; + } else { + if (DEBUG) { + System.err.println("<"+block+"> END IF BLOCK: <" + comment + ">"); + } + } } } - } else if ((m = associationPattern.matcher(line)).matches()) { + } else if ((m = associationPattern.matcher(line)).matches()) { // found a new #ifndef GL_XXX block activeAssociation = m.group(1).trim(); - + block++; if (DEBUG) { - System.err.println("BEGIN ASSOCIATION BLOCK: <" + activeAssociation + ">"); + System.err.println("<"+block+"> BEGIN ASSOCIATION BLOCK: <" + activeAssociation + ">"); } } } diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java index ba025e18c..d4dca715b 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java @@ -61,6 +61,7 @@ public class GLConfiguration extends ProcAddressConfiguration { // The following data members support ignoring an entire extension at a time private List glHeaders = new ArrayList(); private Set ignoredExtensions = new HashSet(); + private Set forcedExtensions = new HashSet(); private Set extensionsRenamedIntoCore = new HashSet(); private BuildStaticGLInfo glInfo; @@ -90,6 +91,9 @@ public class GLConfiguration extends ProcAddressConfiguration { if (cmd.equalsIgnoreCase("IgnoreExtension")) { String sym = readString("IgnoreExtension", tok, filename, lineNo); ignoredExtensions.add(sym); + } else if (cmd.equalsIgnoreCase("ForceExtension")) { + String sym = readString("ForceExtension", tok, filename, lineNo); + forcedExtensions.add(sym); } else if (cmd.equalsIgnoreCase("RenameExtensionIntoCore")) { String sym = readString("RenameExtensionIntoCore", tok, filename, lineNo); extensionsRenamedIntoCore.add(sym); @@ -202,16 +206,21 @@ public class GLConfiguration extends ProcAddressConfiguration { for (String str : ignoredExtensions) { System.err.println("\t" + str); } + System.err.println("GL Forced extensions: "); + for (String str : forcedExtensions) { + System.err.println("\t" + str); + } super.dumpIgnores(); } protected boolean shouldIgnoreExtension(String symbol, boolean criteria) { if (criteria && glInfo != null) { - Set extensionNames = glInfo.getExtension(symbol); - if(null!=extensionNames) { - for(Iterator i=extensionNames.iterator(); i.hasNext(); ) { - String extensionName = i.next(); - if (extensionName != null && ignoredExtensions.contains(extensionName)) { + final Set extensionNames = glInfo.getExtension(symbol); + if( null != extensionNames ) { + boolean ignoredExtension = false; + for(Iterator i=extensionNames.iterator(); !ignoredExtension && i.hasNext(); ) { + final String extensionName = i.next(); + if ( extensionName != null && ignoredExtensions.contains(extensionName) ) { if (DEBUG_IGNORES) { System.err.print("Ignore symbol <" + symbol + "> of extension <" + extensionName + ">"); if(extensionNames.size()==1) { @@ -220,9 +229,26 @@ public class GLConfiguration extends ProcAddressConfiguration { System.err.println(", WARNING MULTIPLE OCCURENCE: "+extensionNames); } } - return true; + ignoredExtension = true; + } + } + if( ignoredExtension ) { + ignoredExtension = !shouldForceExtension( symbol, true, symbol ); + if( ignoredExtension ) { + final Set origSymbols = getRenamedJavaSymbols( symbol ); + if(null != origSymbols) { + for(String origSymbol : origSymbols) { + if( shouldForceExtension( origSymbol, true, symbol ) ) { + ignoredExtension = false; + break; + } + } + } } } + if( ignoredExtension ) { + return true; + } } boolean isGLEnum = GLNameResolver.isGLEnumeration(symbol); boolean isGLFunc = GLNameResolver.isGLFunction(symbol); @@ -240,6 +266,29 @@ public class GLConfiguration extends ProcAddressConfiguration { } return false; } + + public boolean shouldForceExtension(final String symbol, final boolean criteria, final String renamedSymbol) { + if (criteria && glInfo != null) { + final Set extensionNames = glInfo.getExtension(symbol); + if( null != extensionNames ) { + for(Iterator i=extensionNames.iterator(); i.hasNext(); ) { + final String extensionName = i.next(); + if ( extensionName != null && forcedExtensions.contains(extensionName) ) { + if (DEBUG_IGNORES) { + System.err.print("Not Ignore symbol <" + symbol + " -> " + renamedSymbol + "> of extension <" + extensionName + ">"); + if(extensionNames.size()==1) { + System.err.println(", single ."); + } else { + System.err.println(", WARNING MULTIPLE OCCURENCE: "+extensionNames); + } + } + return true; + } + } + } + } + return false; + } @Override public boolean shouldIgnoreInInterface(String symbol) { diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java index 016674338..fdfaee8a6 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java @@ -43,6 +43,7 @@ import com.jogamp.gluegen.CommentEmitter; import com.jogamp.gluegen.JavaEmitter; import com.jogamp.gluegen.JavaMethodBindingEmitter; import com.jogamp.gluegen.MethodBinding; +import com.jogamp.gluegen.cgram.types.FunctionSymbol; import com.jogamp.gluegen.cgram.types.Type; import com.jogamp.gluegen.procaddress.ProcAddressJavaMethodBindingEmitter; @@ -103,11 +104,14 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit @Override protected void emitBindingCSignature(MethodBinding binding, PrintWriter writer) { - super.emitBindingCSignature(binding, writer); - String symbolRenamed = binding.getName(); StringBuilder newComment = new StringBuilder(); + final FunctionSymbol funcSym = binding.getCSymbol(); + writer.print(" "); + writer.print(funcSym.getType().toString(symbolRenamed, tagNativeBinding)); + writer.print(" "); + newComment.append("
    Part of "); if (0 == glEmitter.addExtensionsOfSymbols2Buffer(newComment, ", ", "; ", symbolRenamed, binding.getAliasedNames())) { if (glEmitter.getGLConfig().getAllowNonGLExtensions()) { diff --git a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java index c0666d153..14f4be96a 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java +++ b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java @@ -51,6 +51,7 @@ public class GLExtensions { public static final String NV_fbo_color_attachments = "GL_NV_fbo_color_attachments"; public static final String ARB_ES2_compatibility = "GL_ARB_ES2_compatibility"; + public static final String ARB_ES3_compatibility = "GL_ARB_ES3_compatibility"; public static final String EXT_abgr = "GL_EXT_abgr"; public static final String OES_rgb8_rgba8 = "GL_OES_rgb8_rgba8"; @@ -69,7 +70,7 @@ public class GLExtensions { public static final String NV_texture_compression_vtc = "GL_NV_texture_compression_vtc"; public static final String SGIS_generate_mipmap = "GL_SGIS_generate_mipmap"; public static final String OES_read_format = "GL_OES_read_format"; - + public static final String OES_single_precision = "GL_OES_single_precision"; public static final String OES_EGL_image_external = "GL_OES_EGL_image_external"; public static final String ARB_gpu_shader_fp64 = "GL_ARB_gpu_shader_fp64"; diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index 74c1b9609..49c5bf72d 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -130,6 +130,16 @@ public interface GLBase { */ public boolean isGLES2(); + /** + * Indicates whether this GL object conforms to the OpenGL ES2 ≥ 3.0 profile. + *

    + * Remark: ES3 compatible desktop profiles are not included. + * To query whether core ES3 functionality is provided, use {@link #isGLES3Compatible()}. + *

    + * @see #isGLES3Compatible() + */ + public boolean isGLES3(); + /** * Indicates whether this GL object conforms to one of the OpenGL ES profiles, * see {@link #isGLES1()} and {@link #isGLES2()}. @@ -146,6 +156,21 @@ public interface GLBase { */ public boolean isGL2ES2(); + /** + * Indicates whether this GL object conforms to a GL3ES3 compatible profile. + */ + public boolean isGL3ES3(); + + /** + * Indicates whether this GL object conforms to a GL4ES3 compatible profile. + */ + public boolean isGL4ES3(); + + /** + * Indicates whether this GL object conforms to a GL2GL3 compatible profile. + */ + public boolean isGL2GL3(); + /** * Indicates whether this GL object is compatible with the core OpenGL ES2 functionality. * @return true if this context is an ES2 context or implements @@ -154,9 +179,11 @@ public interface GLBase { public boolean isGLES2Compatible(); /** - * Indicates whether this GL object conforms to a GL2GL3 compatible profile. + * Indicates whether this GL object is compatible with the core OpenGL ES3 functionality. + * @return true if this context is an ES3 context or implements + * the extension GL_ARB_ES3_compatibility, otherwise false */ - public boolean isGL2GL3(); + public boolean isGLES3Compatible(); /** Indicates whether this GL object supports GLSL. */ public boolean hasGLSL(); @@ -209,6 +236,12 @@ public interface GLBase { */ public GLES2 getGLES2() throws GLException; + /** + * Casts this object to the GLES3 interface. + * @throws GLException if this GLObject is not a GLES3 implementation + */ + public GLES3 getGLES3() throws GLException; + /** * Casts this object to the GL2ES1 interface. * @throws GLException if this GLObject is not a GL2ES1 implementation @@ -221,6 +254,18 @@ public interface GLBase { */ public GL2ES2 getGL2ES2() throws GLException; + /** + * Casts this object to the GL3ES3 interface. + * @throws GLException if this GLObject is not a GL3ES3 implementation + */ + public GL3ES3 getGL3ES3() throws GLException; + + /** + * Casts this object to the GL4ES3 interface. + * @throws GLException if this GLObject is not a GL3ES3 implementation + */ + public GL4ES3 getGL4ES3() throws GLException; + /** * Casts this object to the GL2GL3 interface. * @throws GLException if this GLObject is not a GL2GL3 implementation diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index daede5ac0..b27db18af 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -142,6 +142,13 @@ public abstract class GLContext { protected static final VersionNumber Version800 = new VersionNumber(8, 0, 0); + // + // Cached keys, bits [0..15] + // + + /** Cached bit mask covering bits [0..15], i.e. {@value}. */ + protected static final int CTX_IMPL_CACHE_MASK = 0x0000FFFF; + /** ARB_create_context related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IS_ARB_CREATED = 1 << 0; /** ARB_create_context related: desktop compatibility profile. Cache key value. See {@link #isGLCompatibilityProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ @@ -154,20 +161,36 @@ public abstract class GLContext { protected static final int CTX_OPTION_FORWARD = 1 << 4; /** ARB_create_context related: flag debug. Cache key value. See {@link #setContextCreationFlags(int)}, {@link GLAutoDrawable#setContextCreationFlags(int)}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ public static final int CTX_OPTION_DEBUG = 1 << 5; + /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. See {@link #isHardwareRasterizer()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ + protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 6; + // + // Non cached keys, bits [16..31] + // + /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ - protected static final int CTX_IMPL_ES2_COMPAT = 1 << 8; + protected static final int CTX_IMPL_ES2_COMPAT = 1 << 16; - /** Context supports basic FBO, details see {@link #hasBasicFBOSupport()}. + /** GL_ARB_ES3_compatibility implementation related: Context is compatible w/ ES3. Not a cache key. See {@link #isGLES3Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ + protected static final int CTX_IMPL_ES3_COMPAT = 1 << 17; + + /** + * Context supports basic FBO, details see {@link #hasBasicFBOSupport()}. * Not a cache key. * @see #hasBasicFBOSupport() * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) */ - protected static final int CTX_IMPL_FBO = 1 << 9; - - /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. See {@link #isHardwareRasterizer()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ - protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 15; + protected static final int CTX_IMPL_FBO = 1 << 18; + /** + * Context supports OES_single_precision, fp32, fixed function point (FFP) compatibility entry points, + * see {@link #hasFP32CompatAPI()}. + * Not a cache key. + * @see #hasFP32CompatAPI() + * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) + */ + protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 19; + private static final ThreadLocal currentContext = new ThreadLocal(); private final HashMap attachedObjects = new HashMap(); @@ -778,10 +801,18 @@ public abstract class GLContext { /** * @return true if this context is an ES2 context or implements - * the extension GL_ARB_ES2_compatibility, otherwise false + * the extension GL_ARB_ES3_compatibility or GL_ARB_ES2_compatibility, otherwise false */ public final boolean isGLES2Compatible() { - return 0 != ( ctxOptions & CTX_IMPL_ES2_COMPAT ) ; + return 0 != ( ctxOptions & ( CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ) ) ; + } + + /** + * @return true if this context is an ES3 context or implements + * the extension GL_ARB_ES3_compatibility, otherwise false + */ + public final boolean isGLES3Compatible() { + return 0 != ( ctxOptions & CTX_IMPL_ES3_COMPAT ) ; } /** @@ -819,6 +850,15 @@ public abstract class GLContext { return 0 != ( ctxOptions & CTX_IMPL_FBO ) ; } + /** + * Returns true if OES_single_precision, fp32, fixed function point (FFP) compatibility entry points available, + * otherwise false. + * @see #CTX_IMPL_FP32_COMPAT_API + */ + public final boolean hasFP32CompatAPI() { + return 0 != ( ctxOptions & CTX_IMPL_FP32_COMPAT_API ) ; + } + /** * Returns true if full FBO support is available, otherwise false. *

    @@ -895,28 +935,30 @@ public abstract class GLContext { /** @see GLProfile#isGL3bc() */ public final boolean isGL3bc() { - return ctxVersion.compareTo(Version310) >= 0 - && 0 != (ctxOptions & CTX_IS_ARB_CREATED) - && 0 != (ctxOptions & CTX_PROFILE_COMPAT); + return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && + 0 != (ctxOptions & CTX_PROFILE_COMPAT) && + ctxVersion.compareTo(Version310) >= 0 ; } /** @see GLProfile#isGL3() */ public final boolean isGL3() { - return ctxVersion.compareTo(Version310) >= 0 - && 0 != (ctxOptions & CTX_IS_ARB_CREATED) - && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); + return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && + 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)) && + ctxVersion.compareTo(Version310) >= 0 ; } - /** Indicates whether this profile is capable of GL3 (core only). GL3 starts w/ OpenGL 3.1

    Includes [ GL4, GL3 ].

    */ + /** Indicates whether this profile is capable of GL3 (core only). GL3 starts w/ OpenGL 3.1

    Includes [ GL4, GL3, GLES3 ].

    */ public final boolean isGL3core() { - return ctxVersion.compareTo(Version310) >= 0 - && 0 != (ctxOptions & CTX_IS_ARB_CREATED) - && 0 != (ctxOptions & CTX_PROFILE_CORE); + return ( 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ) || + ( 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) && + 0 != ( ctxOptions & CTX_PROFILE_CORE ) && + ctxVersion.compareTo(Version310) >= 0 + ) ; } /** @see GLProfile#isGL2() */ public final boolean isGL2() { - return ctxVersion.getMajor()>=1 && 0!=(ctxOptions & CTX_PROFILE_COMPAT); + return 0 != ( ctxOptions & CTX_PROFILE_COMPAT ) && ctxVersion.getMajor()>=1 ; } /** @see GLProfile#isGL2GL3() */ @@ -926,12 +968,17 @@ public abstract class GLContext { /** @see GLProfile#isGLES1() */ public final boolean isGLES1() { - return ctxVersion.getMajor() == 1 && 0 != ( ctxOptions & CTX_PROFILE_ES ) ; + return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 1 ; } /** @see GLProfile#isGLES2() */ public final boolean isGLES2() { - return ctxVersion.getMajor() == 2 && 0 != ( ctxOptions & CTX_PROFILE_ES ) ; + return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 2 ; + } + + /** @see GLProfile#isGLES3() */ + public final boolean isGLES3() { + return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ; } /** @see GLProfile#isGLES() */ @@ -941,12 +988,22 @@ public abstract class GLContext { /** @see GLProfile#isGL2ES1() */ public final boolean isGL2ES1() { - return isGL2() || isGLES1() ; + return isGLES1() || isGL2(); } /** @see GLProfile#isGL2ES2() */ public final boolean isGL2ES2() { - return isGL2GL3() || isGLES2() ; + return isGLES2() || isGL2GL3(); + } + + /** @see GLProfile#isGL3ES3() */ + public final boolean isGL3ES3() { + return isGL4ES3() || isGL3(); + } + + /** @see GLProfile#isGL4ES3() */ + public final boolean isGL4ES3() { + return isGL4() || isGLES3() ; } /** @@ -1157,45 +1214,73 @@ public abstract class GLContext { /* 1.*/ { 0, 1, 2, 3, 4, 5 }, /* 2.*/ { 0, 1 }, /* 3.*/ { 0, 1, 2, 3 }, - /* 4.*/ { 0, 1, 2 } }; // FIXME add 4.3 ! + /* 4.*/ { 0, 1, 2, 3 } }; - private static final int GL_VERSIONS_VALID[][] = { + public static final int ES_VERSIONS[][] = { /* 0.*/ { -1 }, - /* 1.*/ { 0, 1, 2, 3, 4, 5 }, - /* 2.*/ { 0, 1 }, - /* 3.*/ { 0, 1, 2, 3 }, - /* 4.*/ { 0, 1, 2, 3, 4 } }; // 4.4 coming up soon ? + /* 1.*/ { 0, 1 }, + /* 2.*/ { 0 }, + /* 3.*/ { 0 } }; - public static final int getMaxMajor() { - return GL_VERSIONS.length-1; + public static final int getMaxMajor(int ctxProfile) { + return ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ? ES_VERSIONS.length-1 : 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 int getMaxMinor(int ctxProfile, int major) { + if( 1>major ) { + return -1; + } + if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) { + if( major>=ES_VERSIONS.length ) return -1; + return ES_VERSIONS[major].length-1; + } else { + if( 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_VALID.length) return false; - if(0>minor || minor>=GL_VERSIONS_VALID[major].length) return false; + public static final boolean isValidGLVersion(int ctxProfile, int major, int minor) { + if( 1>major || 0>minor ) { + return false; + } + if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) { + if( major>=ES_VERSIONS.length) return false; + if( minor>=ES_VERSIONS[major].length) return false; + } else { + if( major>=GL_VERSIONS.length) return false; + if( minor>=GL_VERSIONS[major].length) return false; + } return true; } - public static final boolean decrementGLVersion(int major[], int minor[]) { + public static final boolean decrementGLVersion(int ctxProfile, 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; + if( !isValidGLVersion(ctxProfile, m, n) ) { + return false; + } // decrement .. n -= 1; if(n < 0) { - m -= 1; - n = GL_VERSIONS[m].length-1; + if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) { + if( m >= 3) { + m -= 1; + } else { + m = 0; // major decr [1,2] -> 0 + } + n = ES_VERSIONS[m].length-1; + } else { + m -= 1; + n = GL_VERSIONS[m].length-1; + } + } + if( !isValidGLVersion(ctxProfile, m, n) ) { + return false; } - if(!isValidGLVersion(m, n)) return false; major[0]=m; minor[0]=n; @@ -1299,9 +1384,9 @@ public abstract class GLContext { } } - protected static StringBuffer dumpAvailableGLVersions(StringBuffer sb) { + protected static StringBuilder dumpAvailableGLVersions(StringBuilder sb) { if(null == sb) { - sb = new StringBuffer(); + sb = new StringBuilder(); } synchronized(deviceVersionAvailable) { final Set keys = deviceVersionAvailable.keySet(); @@ -1524,6 +1609,10 @@ public abstract class GLContext { return isGLVersionAvailable(device, 2, GLContext.CTX_PROFILE_ES, isHardware); } + public static boolean isGLES3Available(AbstractGraphicsDevice device, boolean isHardware[]) { + return isGLVersionAvailable(device, 3, GLContext.CTX_PROFILE_ES, isHardware); + } + public static boolean isGL4bcAvailable(AbstractGraphicsDevice device, boolean isHardware[]) { return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT, isHardware); } @@ -1552,13 +1641,15 @@ public abstract class GLContext { sb.append(minor); sb.append(" ("); needColon = appendString(sb, "ES profile", needColon, 0 != ( CTX_PROFILE_ES & ctp )); - needColon = appendString(sb, "Compatibility profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp )); + needColon = appendString(sb, "Compat profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp )); needColon = appendString(sb, "Core profile", needColon, 0 != ( CTX_PROFILE_CORE & ctp )); needColon = appendString(sb, "forward", needColon, 0 != ( CTX_OPTION_FORWARD & ctp )); needColon = appendString(sb, "arb", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp )); needColon = appendString(sb, "debug", needColon, 0 != ( CTX_OPTION_DEBUG & ctp )); - needColon = appendString(sb, "ES2 compatible", needColon, 0 != ( CTX_IMPL_ES2_COMPAT & ctp )); + needColon = appendString(sb, "ES2 compat", needColon, 0 != ( CTX_IMPL_ES2_COMPAT & ctp )); + needColon = appendString(sb, "ES3 compat", needColon, 0 != ( CTX_IMPL_ES3_COMPAT & ctp )); needColon = appendString(sb, "FBO", needColon, 0 != ( CTX_IMPL_FBO & ctp )); + needColon = appendString(sb, "FP32 compat-api", needColon, 0 != ( CTX_IMPL_FP32_COMPAT_API & ctp )); if( 0 != ( CTX_IMPL_ACCEL_SOFT & ctp ) ) { needColon = appendString(sb, "software", needColon, true); } else { diff --git a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java index 3ab0683c6..f8959e653 100644 --- a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java +++ b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java @@ -73,8 +73,8 @@ public class GLDebugMessage { // AMD category == ARB source/type switch(amdDbgCategory) { case GL2GL3.GL_DEBUG_CATEGORY_API_ERROR_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_API_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_ERROR_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_API; + dbgType = GL2GL3.GL_DEBUG_TYPE_ERROR; break; // @@ -82,18 +82,18 @@ public class GLDebugMessage { // case GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; break; case GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; break; case GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_APPLICATION; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; break; @@ -102,24 +102,24 @@ public class GLDebugMessage { // case GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; + dbgType = GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR; break; case GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; + dbgType = GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR; break; case GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_PERFORMANCE_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; + dbgType = GL2GL3.GL_DEBUG_TYPE_PERFORMANCE; break; case GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD: default: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; } return new GLDebugMessage(source, when, dbgSource, dbgType, dbgId, dbgSeverity, dbgMsg); @@ -127,24 +127,24 @@ public class GLDebugMessage { public static int translateARB2AMDCategory(int dbgSource, int dbgType) { switch (dbgSource) { - case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB: + case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM: return GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD; - case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER_ARB: + case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER: return GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD; - case GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB: + case GL2GL3.GL_DEBUG_SOURCE_APPLICATION: return GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD; } switch(dbgType) { - case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: + case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD; - case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB: + case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD; - case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE_ARB: + case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE: return GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD; } @@ -204,33 +204,33 @@ public class GLDebugMessage { public static String getDbgSourceString(int dbgSource) { switch(dbgSource) { - case GL2GL3.GL_DEBUG_SOURCE_API_ARB: return "GL API"; - case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER_ARB: return "GLSL or extension compiler"; - case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB: return "Native Windowing binding"; - case GL2GL3.GL_DEBUG_SOURCE_THIRD_PARTY_ARB: return "Third party"; - case GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB: return "Application"; - case GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB: return "generic"; + case GL2GL3.GL_DEBUG_SOURCE_API: return "GL API"; + case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER: return "GLSL or extension compiler"; + case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "Native Windowing binding"; + case GL2GL3.GL_DEBUG_SOURCE_THIRD_PARTY: return "Third party"; + case GL2GL3.GL_DEBUG_SOURCE_APPLICATION: return "Application"; + case GL2GL3.GL_DEBUG_SOURCE_OTHER: return "generic"; default: return "Unknown (" + toHexString(dbgSource) + ")"; } } public static String getDbgTypeString(int dbgType) { switch(dbgType) { - case GL2GL3.GL_DEBUG_TYPE_ERROR_ARB: return "Error"; - case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: return "Warning: marked for deprecation"; - case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB: return "Warning: undefined behavior"; - case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE_ARB: return "Warning: implementation dependent performance"; - case GL2GL3.GL_DEBUG_TYPE_PORTABILITY_ARB: return "Warning: vendor-specific extension use"; - case GL2GL3.GL_DEBUG_TYPE_OTHER_ARB: return "Warning: generic"; + case GL2GL3.GL_DEBUG_TYPE_ERROR: return "Error"; + case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "Warning: marked for deprecation"; + case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return "Warning: undefined behavior"; + case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE: return "Warning: implementation dependent performance"; + case GL2GL3.GL_DEBUG_TYPE_PORTABILITY: return "Warning: vendor-specific extension use"; + case GL2GL3.GL_DEBUG_TYPE_OTHER: return "Warning: generic"; default: return "Unknown (" + toHexString(dbgType) + ")"; } } public static String getDbgSeverityString(int dbgSeverity) { switch(dbgSeverity) { - case GL2GL3.GL_DEBUG_SEVERITY_HIGH_ARB: return "High: dangerous undefined behavior"; - case GL2GL3.GL_DEBUG_SEVERITY_MEDIUM_ARB: return "Medium: Severe performance/deprecation/other warnings"; - case GL2GL3.GL_DEBUG_SEVERITY_LOW_ARB: return "Low: Performance warnings (redundancy/undefined)"; + case GL2GL3.GL_DEBUG_SEVERITY_HIGH: return "High: dangerous undefined behavior"; + case GL2GL3.GL_DEBUG_SEVERITY_MEDIUM: return "Medium: Severe performance/deprecation/other warnings"; + case GL2GL3.GL_DEBUG_SEVERITY_LOW: return "Low: Performance warnings (redundancy/undefined)"; default: return "Unknown (" + toHexString(dbgSeverity) + ")"; } } diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 1b6af22d4..17d9019da 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -132,7 +132,7 @@ public class GLProfile { ReflectionUtil.createInstance(getGLImplBaseClassName(GL4bc)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); } catch (Throwable t) {} try { - ReflectionUtil.createInstance(getGLImplBaseClassName(GLES2)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); + ReflectionUtil.createInstance(getGLImplBaseClassName(GLES3)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); } catch (Throwable t) {} try { ReflectionUtil.createInstance(getGLImplBaseClassName(GLES1)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); @@ -165,7 +165,7 @@ public class GLProfile { initLock.unlock(); } if(DEBUG) { - if( justInitialized && ( hasGL234Impl || hasGLES1Impl || hasGLES2Impl ) ) { + if( justInitialized && ( hasGL234Impl || hasGLES1Impl || hasGLES3Impl ) ) { System.err.println(JoglVersion.getDefaultOpenGLInfo(defaultDevice, null, true)); } } @@ -298,6 +298,24 @@ public class GLProfile { glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_CORE); } + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4ES3").append(indent); + } else { + sb.append(", GL4ES3 "); + } + sb.append(isAvailableImpl(map, GL4ES3)); + + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES3").append(indent); + } else { + sb.append(", GLES3 "); + } + avail=isAvailableImpl(map, GLES3); + sb.append(avail); + if(avail) { + glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_ES); + } + if(useIndent) { doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL3bc").append(indent); } else { @@ -332,39 +350,39 @@ public class GLProfile { } if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent); } else { - sb.append(", GL2ES1 "); + sb.append(", GL2ES2 "); } - sb.append(isAvailableImpl(map, GL2ES1)); + sb.append(isAvailableImpl(map, GL2ES2)); if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES1").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent); } else { - sb.append(", GLES1 "); + sb.append(", GLES2 "); } - avail=isAvailableImpl(map, GLES1); + avail=isAvailableImpl(map, GLES2); sb.append(avail); if(avail) { - glAvailabilityToString(device, sb.append(" "), 1, GLContext.CTX_PROFILE_ES); + glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES); } if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent); } else { - sb.append(", GL2ES2 "); + sb.append(", GL2ES1 "); } - sb.append(isAvailableImpl(map, GL2ES2)); + sb.append(isAvailableImpl(map, GL2ES1)); if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES1").append(indent); } else { - sb.append(", GLES2 "); + sb.append(", GLES1 "); } - avail=isAvailableImpl(map, GLES2); + avail=isAvailableImpl(map, GLES1); sb.append(avail); if(avail) { - glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES); + glAvailabilityToString(device, sb.append(" "), 1, GLContext.CTX_PROFILE_ES); } if(useIndent) { @@ -437,6 +455,9 @@ public class GLProfile { /** The embedded OpenGL profile ES 2.x, with x >= 0 */ public static final String GLES2 = "GLES2"; + /** The embedded OpenGL profile ES 3.x, with x >= 0 */ + public static final String GLES3 = "GLES3"; + /** The intersection of the desktop GL2 and embedded ES1 profile */ public static final String GL2ES1 = "GL2ES1"; @@ -446,6 +467,9 @@ public class GLProfile { /** The intersection of the desktop GL3 and GL2 profile */ public static final String GL2GL3 = "GL2GL3"; + /** The intersection of the desktop GL4 and ES3 profile */ + public static final String GL4ES3 = "GL4ES3"; + /** The default profile, used for the device default profile map */ private static final String GL_DEFAULT = "GL_DEFAULT"; @@ -456,62 +480,66 @@ public class GLProfile { *

    This includes the generic subset profiles GL2GL3, GL2ES2 and GL2ES1.

    * *
      - *
    • GL4bc - *
    • GL3bc - *
    • GL2 - *
    • GL4 - *
    • GL3 - *
    • GL2GL3 - *
    • GLES2 - *
    • GL2ES2 - *
    • GLES1 - *
    • GL2ES1 + *
    • GL4bc
    • + *
    • GL3bc
    • + *
    • GL2
    • + *
    • GL4
    • + *
    • GL3
    • + *
    • GLES3
    • + *
    • GL4ES3
    • + *
    • GL2GL3
    • + *
    • GLES2
    • + *
    • GL2ES2
    • + *
    • GLES1
    • + *
    • GL2ES1
    • *
    * */ - public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL4bc, GL3bc, GL2, GL4, GL3, GL2GL3, GLES2, GL2ES2, GLES1, GL2ES1 }; - + public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL4bc, GL3bc, GL2, GL4, GL3, GLES3, GL4ES3, GL2GL3, GLES2, GL2ES2, GLES1, GL2ES1 }; + /** * Order of maximum profiles. * *
      - *
    • GL4bc - *
    • GL4 - *
    • GL3bc - *
    • GL3 - *
    • GL2 - *
    • GLES2 - *
    • GLES1 + *
    • GL4bc
    • + *
    • GL4
    • + *
    • GL3bc
    • + *
    • GL3
    • + *
    • GLES3
    • + *
    • GL2
    • + *
    • GLES2
    • + *
    • GLES1
    • *
    * */ - public static final String[] GL_PROFILE_LIST_MAX = new String[] { GL4bc, GL4, GL3bc, GL3, GL2, GLES2, GLES1 }; + public static final String[] GL_PROFILE_LIST_MAX = new String[] { GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GLES2, GLES1 }; /** * Order of minimum profiles. * *
      - *
    • GLES1 - *
    • GLES2 - *
    • GL2 - *
    • GL3 - *
    • GL3bc - *
    • GL4 - *
    • GL4bc + *
    • GLES1
    • + *
    • GLES2
    • + *
    • GL2
    • + *
    • GLES3
    • + *
    • GL3
    • + *
    • GL3bc
    • + *
    • GL4
    • + *
    • GL4bc
    • *
    * */ - public static final String[] GL_PROFILE_LIST_MIN = new String[] { GLES1, GLES2, GL2, GL3, GL3bc, GL4, GL4bc }; + public static final String[] GL_PROFILE_LIST_MIN = new String[] { GLES1, GLES2, GL2, GLES3, GL3, GL3bc, GL4, GL4bc }; /** * Order of minimum original desktop profiles. * *
      - *
    • GL2 - *
    • GL3bc - *
    • GL4bc - *
    • GL3 - *
    • GL4 + *
    • GL2
    • + *
    • GL3bc
    • + *
    • GL4bc
    • + *
    • GL3
    • + *
    • GL4
    • *
    * */ @@ -521,10 +549,10 @@ public class GLProfile { * Order of maximum fixed function profiles * *
      - *
    • GL4bc - *
    • GL3bc - *
    • GL2 - *
    • GLES1 + *
    • GL4bc
    • + *
    • GL3bc
    • + *
    • GL2
    • + *
    • GLES1
    • *
    * */ @@ -534,28 +562,30 @@ public class GLProfile { * Order of maximum programmable shader profiles * *
      - *
    • GL4bc - *
    • GL4 - *
    • GL3bc - *
    • GL3 - *
    • GL2 - *
    • GLES2 + *
    • GL4bc
    • + *
    • GL4
    • + *
    • GL3bc
    • + *
    • GL3
    • + *
    • GLES3
    • + *
    • GL2
    • + *
    • GLES2
    • *
    * */ - public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER = new String[] { GL4bc, GL4, GL3bc, GL3, GL2, GLES2 }; + public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER = new String[] { GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GLES2 }; /** * Order of maximum programmable shader core only profiles * *
      - *
    • GL4 - *
    • GL3 - *
    • GLES2 + *
    • GL4
    • + *
    • GL3
    • + *
    • GLES3
    • + *
    • GLES2
    • *
    * */ - public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER_CORE = new String[] { GL4, GL3, GLES2 }; + public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER_CORE = new String[] { GL4, GL3, GLES3, GLES2 }; /** 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} @@ -754,6 +784,36 @@ public class GLProfile { return get(defaultDevice, GL2ES2).getImpl(); } + /** + * Returns the GL4ES3 profile implementation, hence compatible w/ GL4ES3.
    + * It returns: + *
    +     *   GLProfile.get(device, GLProfile.GL4ES3).getImpl());
    +     * 
    + *

    Selection favors hardware rasterizer.

    + * + * @throws GLException if no GL4ES3 compatible profile is available for the default device. + * @see #isGL4ES3() + * @see #get(AbstractGraphicsDevice, String) + * @see #getImpl() + */ + public static GLProfile getGL4ES3(AbstractGraphicsDevice device) + throws GLException + { + return get(device, GL4ES3).getImpl(); + } + + /** + * Calls {@link #getGL4ES3(AbstractGraphicsDevice)} using the default device. + *

    Selection favors hardware rasterizer.

    + * @see #getGL4ES3(AbstractGraphicsDevice) + */ + public static GLProfile getGL4ES3() + throws GLException + { + return get(defaultDevice, GL4ES3).getImpl(); + } + /** * Returns the GL2GL3 profile implementation, hence compatible w/ GL2GL3.
    * It returns: @@ -872,13 +932,20 @@ public class GLProfile { return GLES1.equals(profileImpl); } - /** Indicates whether the native OpenGL ES2 profile is in use. - * This requires an EGL or ES2 compatible interface. + /** Indicates whether the native OpenGL ES3 or ES2 profile is in use. + * This requires an EGL, ES3 or ES2 compatible interface. */ public static boolean usesNativeGLES2(String profileImpl) { - return GLES2.equals(profileImpl); + return GLES3.equals(profileImpl) || GLES2.equals(profileImpl); } + /** Indicates whether the native OpenGL ES2 profile is in use. + * This requires an EGL, ES3 compatible interface. + */ + public static boolean usesNativeGLES3(String profileImpl) { + return GLES3.equals(profileImpl); + } + /** Indicates whether either of the native OpenGL ES profiles are in use. */ public static boolean usesNativeGLES(String profileImpl) { return usesNativeGLES2(profileImpl) || usesNativeGLES1(profileImpl); @@ -937,8 +1004,8 @@ public class GLProfile { } private static final String getGLImplBaseClassName(String profileImpl) { - if( GLES2 == profileImpl ) { - return "jogamp.opengl.es2.GLES2"; + if( GLES2 == profileImpl || GLES3 == profileImpl ) { + return "jogamp.opengl.es3.GLES3"; } else if( GLES1 == profileImpl ) { return "jogamp.opengl.es1.GLES1"; } else if ( GL4bc == profileImpl || @@ -1035,14 +1102,19 @@ public class GLProfile { return GLES1 == profile; } - /** Indicates whether this profile is capable of GLES2.

    Includes [ GLES2 ].

    */ + /** Indicates whether this profile is capable of GLES2.

    Includes [ GLES3, GLES2 ].

    */ public final boolean isGLES2() { - return GLES2 == profile; + return GLES3 == profile || GLES2 == profile; } - /** Indicates whether this profile is capable of GLES.

    Includes [ GLES1, GLES2 ].

    */ + /** Indicates whether this profile is capable of GLES3.

    Includes [ GLES3 ].

    */ + public final boolean isGLES3() { + return GLES3 == profile; + } + + /** Indicates whether this profile is capable of GLES.

    Includes [ GLES3, GLES1, GLES2 ].

    */ public final boolean isGLES() { - return GLES2 == profile || GLES1 == profile; + return GLES3 == profile || GLES2 == profile || GLES1 == profile; } /** Indicates whether this profile is capable of GL2ES1.

    Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].

    */ @@ -1050,17 +1122,27 @@ public class GLProfile { return GL2ES1 == profile || isGLES1() || isGL2(); } - /** Indicates whether this profile is capable os GL2GL3.

    Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].

    */ + /** Indicates whether this profile is capable of GL2GL3.

    Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].

    */ public final boolean isGL2GL3() { return GL2GL3 == profile || isGL3() || isGL2(); } - - /** Indicates whether this profile is capable os GL2ES2.

    Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3, GL2ES2, GLES2 ].

    */ + + /** Indicates whether this profile is capable of GL2ES2.

    Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GL2GL3, GL2ES2, GLES2 ].

    */ public final boolean isGL2ES2() { return GL2ES2 == profile || isGLES2() || isGL2GL3(); } - /** Indicates whether this profile supports GLSL, ie. {@link #isGL2ES2()}. */ + /** Indicates whether this profile is capable of GL3ES3.

    Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].

    */ + public final boolean isGL3ES3() { + return isGL4ES3() || isGL3(); + } + + /** Indicates whether this profile is capable of GL4ES3.

    Includes [ GL4bc, GL4, GLES3 ].

    */ + public final boolean isGL4ES3() { + return GL4ES3 == profile || isGLES3() || isGL4(); + } + + /** Indicates whether this profile supports GLSL, i.e. {@link #isGL2ES2()}. */ public final boolean hasGLSL() { return isGL2ES2() ; } @@ -1072,7 +1154,12 @@ public class GLProfile { /** Indicates whether this profile uses the native OpenGL ES2 implementations. */ public final boolean usesNativeGLES2() { - return GLES2 == getImplName(); + return GLES3 == getImplName() || GLES2 == getImplName(); + } + + /** Indicates whether this profile uses the native OpenGL ES2 implementations. */ + public final boolean usesNativeGLES3() { + return GLES3 == getImplName(); } /** Indicates whether this profile uses either of the native OpenGL ES implementations. */ @@ -1117,8 +1204,8 @@ public class GLProfile { public boolean isValidArrayDataType(int index, int comps, int type, boolean isVertexAttribPointer, boolean throwException) { - String arrayName = getGLArrayName(index); - if(isGLES1()) { + final String arrayName = getGLArrayName(index); + if( isGLES1() ) { if(isVertexAttribPointer) { if(throwException) { throw new GLException("Illegal array type for "+arrayName+" on profile GLES1: VertexAttribPointer"); @@ -1201,7 +1288,7 @@ public class GLProfile { } break; } - } else if(isGLES2()) { + } else if( isGLES2() ) { // simply ignore !isVertexAttribPointer case, since it is simulated anyway .. switch(type) { case GL.GL_UNSIGNED_BYTE: @@ -1386,7 +1473,7 @@ public class GLProfile { private static /*final*/ boolean hasDesktopGLFactory; private static /*final*/ boolean hasGL234Impl; private static /*final*/ boolean hasEGLFactory; - private static /*final*/ boolean hasGLES2Impl; + private static /*final*/ boolean hasGLES3Impl; private static /*final*/ boolean hasGLES1Impl; private static /*final*/ GLDrawableFactoryImpl eglFactory = null; @@ -1419,7 +1506,7 @@ public class GLProfile { // depends on hasEGLFactory hasGLES1Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.es1.GLES1Impl", classloader); - hasGLES2Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.es2.GLES2Impl", classloader); + hasGLES3Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.es3.GLES3Impl", classloader); // // Iteration of desktop GL availability detection @@ -1471,8 +1558,8 @@ public class GLProfile { eglFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactoryImpl(GLES2); if(null != eglFactory) { hasEGLFactory = true; - // update hasGLES1Impl, hasGLES2Impl based on EGL - hasGLES2Impl = null!=eglFactory.getGLDynamicLookupHelper(2) && hasGLES2Impl; + // update hasGLES1Impl, hasGLES3Impl based on EGL + hasGLES3Impl = null!=eglFactory.getGLDynamicLookupHelper(2) && hasGLES3Impl; hasGLES1Impl = null!=eglFactory.getGLDynamicLookupHelper(1) && hasGLES1Impl; } } catch (LinkageError le) { @@ -1493,7 +1580,7 @@ public class GLProfile { final AbstractGraphicsDevice defaultEGLDevice; if(null == eglFactory) { - hasGLES2Impl = false; + hasGLES3Impl = false; hasGLES1Impl = false; defaultEGLDevice = null; if(DEBUG) { @@ -1532,7 +1619,7 @@ public class GLProfile { System.err.println("GLProfile.init hasGL234Impl "+hasGL234Impl); System.err.println("GLProfile.init hasEGLFactory "+hasEGLFactory); System.err.println("GLProfile.init hasGLES1Impl "+hasGLES1Impl); - System.err.println("GLProfile.init hasGLES2Impl "+hasGLES2Impl); + System.err.println("GLProfile.init hasGLES3Impl "+hasGLES3Impl); System.err.println("GLProfile.init defaultDevice "+defaultDevice); System.err.println("GLProfile.init defaultDevice Desktop "+defaultDesktopDevice); System.err.println("GLProfile.init defaultDevice EGL "+defaultEGLDevice); @@ -1609,8 +1696,8 @@ public class GLProfile { final boolean deviceIsEGLCompatible = hasEGLFactory && eglFactory.getIsDeviceCompatible(device); - // also test GLES1 and GLES2 on desktop, since we have implementations / emulations available. - if( deviceIsEGLCompatible && ( hasGLES2Impl || hasGLES1Impl ) ) { + // also test GLES1, GLES2 and GLES3 on desktop, since we have implementations / emulations available. + if( deviceIsEGLCompatible && ( hasGLES3Impl || hasGLES1Impl ) ) { // 1st pretend we have all EGL profiles .. computeProfileMap(device, false /* desktopCtxUndef*/, true /* esCtxUndef */); @@ -1629,7 +1716,7 @@ public class GLProfile { // but it seems even EGL.eglInitialize(eglDisplay, null, null) // fails in some scenarios (eg VirtualBox 4.1.6) w/ EGL error 0x3001 (EGL_NOT_INITIALIZED). hasEGLFactory = false; - hasGLES2Impl = false; + hasGLES3Impl = false; hasGLES1Impl = false; } if (DEBUG) { @@ -1647,7 +1734,7 @@ public class GLProfile { System.err.println("GLProfile: desktoplFactory "+desktopFactory); System.err.println("GLProfile: eglFactory "+eglFactory); System.err.println("GLProfile: hasGLES1Impl "+hasGLES1Impl); - System.err.println("GLProfile: hasGLES2Impl "+hasGLES2Impl); + System.err.println("GLProfile: hasGLES3Impl "+hasGLES3Impl); } } @@ -1725,18 +1812,18 @@ public class GLProfile { final boolean isHardwareRasterizer[] = new boolean[1]; GLProfile defaultGLProfileAny = null; GLProfile defaultGLProfileHW = null; - HashMap _mappedProfiles = new HashMap(GL_PROFILE_LIST_ALL.length + 1 /* default */); + final HashMap _mappedProfiles = new HashMap(GL_PROFILE_LIST_ALL.length + 1 /* default */); for(int i=0; i profileImpl "+profileImpl+" !!! not mapped "); } glProfile = new GLProfile(profile, _mglp, isHardwareRasterizer[0]); } @@ -1744,12 +1831,12 @@ public class GLProfile { if (DEBUG) { System.err.println("GLProfile.init map "+glProfile+" on device "+device.getConnection()); } - if(null==defaultGLProfileHW && isHardwareRasterizer[0]) { + if( null == defaultGLProfileHW && isHardwareRasterizer[0] ) { defaultGLProfileHW=glProfile; if (DEBUG) { System.err.println("GLProfile.init map defaultHW "+glProfile+" on device "+device.getConnection()); } - } else if(null==defaultGLProfileAny) { + } else if( null == defaultGLProfileAny ) { defaultGLProfileAny=glProfile; if (DEBUG) { System.err.println("GLProfile.init map defaultAny "+glProfile+" on device "+device.getConnection()); @@ -1761,9 +1848,9 @@ public class GLProfile { } } } - if(null!=defaultGLProfileHW) { + if( null != defaultGLProfileHW ) { _mappedProfiles.put(GL_DEFAULT, defaultGLProfileHW); - } else if(null!=defaultGLProfileAny) { + } else if( null != defaultGLProfileAny ) { _mappedProfiles.put(GL_DEFAULT, defaultGLProfileAny); } setProfileMap(device, _mappedProfiles); @@ -1805,23 +1892,18 @@ public class GLProfile { } } else if (GL2ES2.equals(profile)) { final boolean es2HardwareRasterizer[] = new boolean[1]; - final boolean gles2Available = hasGLES2Impl && ( esCtxUndef || GLContext.isGLES2Available(device, es2HardwareRasterizer) ); + final boolean gles2Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, es2HardwareRasterizer) ); final boolean gles2HWAvailable = gles2Available && es2HardwareRasterizer[0] ; if(hasGL234Impl) { if(!isOSX) { - if(GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { - if(!gles2HWAvailable || isHardwareRasterizer[0]) { - return GL4bc; - } - } if(GLContext.isGL4Available(device, isHardwareRasterizer)) { if(!gles2HWAvailable || isHardwareRasterizer[0]) { return GL4; } } - if(GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) { + if(GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { if(!gles2HWAvailable || isHardwareRasterizer[0]) { - return GL3bc; + return GL4bc; } } if(GLContext.isGL3Available(device, isHardwareRasterizer)) { @@ -1829,6 +1911,11 @@ public class GLProfile { return GL3; } } + if(GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) { + if(!gles2HWAvailable || isHardwareRasterizer[0]) { + return GL3bc; + } + } } if(desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer)) { if(!gles2HWAvailable || isHardwareRasterizer[0]) { @@ -1840,6 +1927,26 @@ public class GLProfile { isHardwareRasterizer[0] = es2HardwareRasterizer[0]; return GLES2; } + } else if (GL4ES3.equals(profile)) { + final boolean es3HardwareRasterizer[] = new boolean[1]; + final boolean gles3Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, es3HardwareRasterizer) ); + final boolean gles3HWAvailable = gles3Available && es3HardwareRasterizer[0] ; + if(hasGL234Impl) { + if(GLContext.isGL4Available(device, isHardwareRasterizer)) { + if(!gles3HWAvailable || isHardwareRasterizer[0]) { + return GL4; + } + } + if(GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { + if(!gles3HWAvailable || isHardwareRasterizer[0]) { + return GL4bc; + } + } + } + if(gles3Available) { + isHardwareRasterizer[0] = es3HardwareRasterizer[0]; + return GLES3; + } } else if(GL2GL3.equals(profile)) { if(hasGL234Impl) { if(!isOSX && GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { @@ -1864,7 +1971,9 @@ public class GLProfile { return GL3; } else if(GL2.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer))) { return GL2; - } else if(GLES2.equals(profile) && hasGLES2Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) { + } else if(GLES3.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, isHardwareRasterizer))) { + return GLES3; + } else if(GLES2.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) { return GLES2; } else if(GLES1.equals(profile) && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, isHardwareRasterizer))) { return GLES1; diff --git a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java index 7c7ea1508..94acf93b0 100644 --- a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java +++ b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java @@ -219,17 +219,17 @@ final class ExtensionAvailabilityCache { System.err.println(getThreadName() + ":ExtensionAvailabilityCache: ALL EXTENSIONS: "+availableExtensionCache.size()); } - if(!context.isGLES()) { - final VersionNumber version = context.getGLVersionNumber(); - int major[] = new int[] { version.getMajor() }; - int minor[] = new int[] { version.getMinor() }; - while (GLContext.isValidGLVersion(major[0], minor[0])) { - availableExtensionCache.add("GL_VERSION_" + major[0] + "_" + minor[0]); - if (DEBUG) { - System.err.println(getThreadName() + ":ExtensionAvailabilityCache: Added GL_VERSION_" + major[0] + "_" + minor[0] + " to known extensions"); - } - if(!GLContext.decrementGLVersion(major, minor)) break; + final int ctxOptions = context.getCtxOptions(); + final VersionNumber version = context.getGLVersionNumber(); + int major[] = new int[] { version.getMajor() }; + int minor[] = new int[] { version.getMinor() }; + while (GLContext.isValidGLVersion(ctxOptions, major[0], minor[0])) { + final String GL_XX_VERSION = ( context.isGLES() ? "GL_ES_VERSION_" : "GL_VERSION_" ) + major[0] + "_" + minor[0]; + availableExtensionCache.add(GL_XX_VERSION); + if (DEBUG) { + System.err.println(getThreadName() + ":ExtensionAvailabilityCache: Added "+GL_XX_VERSION+" to known extensions"); } + if(!GLContext.decrementGLVersion(ctxOptions, major, minor)) break; } // put a dummy var in here so that the cache is no longer empty even if diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index f896c95ee..18e136815 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -40,6 +40,7 @@ package jogamp.opengl; +import java.lang.reflect.Method; import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.security.AccessController; @@ -66,6 +67,7 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; +import javax.media.opengl.GL2ES3; import javax.media.opengl.GL2GL3; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -396,9 +398,10 @@ public abstract class GLContextImpl extends GLContext { associateDrawableException = t; } if ( 0 != defaultVAO ) { - int[] tmp = new int[] { defaultVAO }; - gl.getGL2GL3().glBindVertexArray(0); - gl.getGL2GL3().glDeleteVertexArrays(1, tmp, 0); + final int[] tmp = new int[] { defaultVAO }; + final GL2ES3 gl3es3 = gl.getGL3ES3(); + gl3es3.glBindVertexArray(0); + gl3es3.glDeleteVertexArrays(1, tmp, 0); defaultVAO = 0; } glDebugHandler.enable(false); @@ -640,9 +643,10 @@ public abstract class GLContextImpl extends GLContext { // to avoid INVALID_OPERATION at VertexAttribPointer. // More clear is GL 4.3 core spec: 10.4 (p 307). final int[] tmp = new int[1]; - gl.getGL2GL3().glGenVertexArrays(1, tmp, 0); + final GL2ES3 gl3es3 = gl.getGL3ES3(); + gl3es3.glGenVertexArrays(1, tmp, 0); defaultVAO = tmp[0]; - gl.getGL2GL3().glBindVertexArray(defaultVAO); + gl3es3.glBindVertexArray(defaultVAO); } } finally { if (null != shareWith) { @@ -836,6 +840,7 @@ public abstract class GLContextImpl extends GLContext { boolean hasGL2 = false; boolean hasGL4 = false; boolean hasGL3 = false; + boolean hasES3 = false; // Even w/ PROFILE_ALIASING, try to use true core GL profiles // ensuring proper user behavior across platforms due to different feature sets! @@ -904,6 +909,13 @@ public abstract class GLContextImpl extends GLContext { resetStates(); // clean this context states, since creation was temporary } } + if(!hasES3) { + hasES3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_ES); // ES3 + success |= hasES3; + if(hasES3) { + resetStates(); // clean this context states, since creation was temporary + } + } if(success) { // only claim GL versions set [and hence detected] if ARB context creation was successful GLContext.setAvailableGLVersionsSet(device); @@ -925,12 +937,7 @@ public abstract class GLContextImpl extends GLContext { **/ private final boolean createContextARBMapVersionsAvailable(int reqMajor, int reqProfile) { long _context; - int ctp = CTX_IS_ARB_CREATED; - if(CTX_PROFILE_COMPAT == reqProfile) { - ctp |= CTX_PROFILE_COMPAT ; - } else { - ctp |= CTX_PROFILE_CORE ; - } + int ctp = CTX_IS_ARB_CREATED | reqProfile; // To ensure GL profile compatibility within the JOGL application // we always try to map against the highest GL version, @@ -940,10 +947,10 @@ public abstract class GLContextImpl extends GLContext { int major[] = new int[1]; int minor[] = new int[1]; if( 4 == reqMajor ) { - majorMax=4; minorMax=GLContext.getMaxMinor(majorMax); + majorMax=4; minorMax=GLContext.getMaxMinor(ctp, majorMax); majorMin=4; minorMin=0; } else if( 3 == reqMajor ) { - majorMax=3; minorMax=GLContext.getMaxMinor(majorMax); + majorMax=3; minorMax=GLContext.getMaxMinor(ctp, majorMax); majorMin=3; minorMin=1; } else /* if( glp.isGL2() ) */ { // our minimum desktop OpenGL runtime requirements are 1.1, @@ -1003,7 +1010,7 @@ public abstract class GLContextImpl extends GLContext { minor[0]=minorMax; long _context=0; - while ( GLContext.isValidGLVersion(major[0], minor[0]) && + while ( GLContext.isValidGLVersion(ctxOptionFlags, major[0], minor[0]) && ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) ) { if (DEBUG) { System.err.println(getThreadName() + ": createContextARBVersions: share "+share+", direct "+direct+", version "+major[0]+"."+minor[0]); @@ -1019,7 +1026,7 @@ public abstract class GLContextImpl extends GLContext { } } - if(!GLContext.decrementGLVersion(major, minor)) { + if(!GLContext.decrementGLVersion(ctxOptionFlags, major, minor)) { break; } } @@ -1040,11 +1047,11 @@ public abstract class GLContextImpl extends GLContext { throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } - if (!GLContext.isValidGLVersion(major, minor)) { + if (!GLContext.isValidGLVersion(ctp, major, minor)) { throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } ctxVersion = new VersionNumber(major, minor, 0); - ctxVersionString = getGLVersion(major, minor, ctxOptions, glVersion); + ctxVersionString = getGLVersion(major, minor, ctp, glVersion); ctxVendorVersion = glVendorVersion; ctxOptions = ctp; if(useGL) { @@ -1087,6 +1094,27 @@ public abstract class GLContextImpl extends GLContext { */ return gl; } + + /** + * Finalizes GL instance initialization after this context has been initialized. + *

    + * Method calls 'void finalizeInit()' of instance 'gl' as retrieved by reflection, if exist. + *

    + */ + private void finalizeInit(GL gl) { + Method finalizeInit = null; + try { + finalizeInit = ReflectionUtil.getMethod(gl.getClass(), "finalizeInit", new Class[]{ }); + } catch ( Throwable t ) { + if(DEBUG) { + System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); + t.printStackTrace(); + } + } + if( null != finalizeInit ) { + ReflectionUtil.callMethod(gl, finalizeInit, new Object[]{ }); + } + } public final ProcAddressTable getGLProcAddressTable() { return glProcAddressTable; @@ -1097,8 +1125,24 @@ public abstract class GLContextImpl extends GLContext { * ie for GLXExt, EGLExt, .. */ public abstract ProcAddressTable getPlatformExtProcAddressTable(); + + /** + * Part of GL_NV_vertex_array_range. + *

    + * Provides platform-independent access to the wglAllocateMemoryNV / + * glXAllocateMemoryNV. + *

    + */ + public abstract ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority); - public abstract ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3); + /** + * Part of GL_NV_vertex_array_range. + *

    + * Provides platform-independent access to the wglFreeMemoryNV / + * glXFreeMemoryNV. + *

    + */ + public abstract void glFreeMemoryNV(ByteBuffer pointer); /** Maps the given "platform-independent" function name to a real function name. Currently this is only used to map "glAllocateMemoryNV" and @@ -1208,7 +1252,7 @@ public abstract class GLContextImpl extends GLContext { int[] major = new int[] { version.getMajor() }; int[] minor = new int[] { version.getMinor() }; limitNonARBContextVersion(major, minor, ctp); - if ( GLContext.isValidGLVersion(major[0], minor[0]) ) { + if ( GLContext.isValidGLVersion(ctp, major[0], minor[0]) ) { return new VersionNumber(major[0], minor[0], 0); } } @@ -1244,6 +1288,11 @@ public abstract class GLContextImpl extends GLContext { } } + protected final int getCtxOptions() { + return ctxOptions; + } + + /** * Sets the OpenGL implementation class and * the cache of which GL functions are available for calling through this @@ -1275,7 +1324,7 @@ public abstract class GLContextImpl extends GLContext { return true; // already done and not forced } - if ( 0 < major && !GLContext.isValidGLVersion(major, minor) ) { + if ( 0 < major && !GLContext.isValidGLVersion(ctxProfileBits, major, minor) ) { throw new GLException("Invalid GL Version Request "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); } @@ -1336,7 +1385,7 @@ public abstract class GLContextImpl extends GLContext { } // Only validate if a valid int version was fetched, otherwise cont. w/ version-string method -> 3.0 > Version || Version > MAX! - if ( GLContext.isValidGLVersion(glIntMajor[0], glIntMinor[0]) ) { + if ( GLContext.isValidGLVersion(ctxProfileBits, glIntMajor[0], glIntMinor[0]) ) { if( glIntMajor[0] major ) { // there is no ES2-compat for a profile w/ major < 2 - ctxProfileBits &= ~GLContext.CTX_IMPL_ES2_COMPAT; + if( 2 > major ) { // there is no ES2/3-compat for a profile w/ major < 2 + ctxProfileBits &= ~ ( GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_ES3_COMPAT ) ; } final VersionNumberString vendorVersion = GLVersionNumber.createVendorVersion(glVersion); @@ -1468,13 +1517,28 @@ public abstract class GLContextImpl extends GLContext { } } - if( ( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) && major >= 2 ) || isExtensionAvailable(GLExtensions.ARB_ES2_compatibility) ) { + if( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) ) { + if( major >= 3 ) { + ctxProfileBits |= CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ; + ctxProfileBits |= CTX_IMPL_FBO; + } else if( major >= 2 ) { + ctxProfileBits |= CTX_IMPL_ES2_COMPAT; + ctxProfileBits |= CTX_IMPL_FBO; + } + } else if( isExtensionAvailable( GLExtensions.ARB_ES3_compatibility ) ) { + ctxProfileBits |= CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ; + ctxProfileBits |= CTX_IMPL_FBO; + } else if( isExtensionAvailable( GLExtensions.ARB_ES2_compatibility ) ) { ctxProfileBits |= CTX_IMPL_ES2_COMPAT; ctxProfileBits |= CTX_IMPL_FBO; } else if( hasFBOImpl(major, ctxProfileBits, extensionAvailability) ) { ctxProfileBits |= CTX_IMPL_FBO; } + if( ( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) && major == 1 ) || isExtensionAvailable(GLExtensions.OES_single_precision) ) { + ctxProfileBits |= CTX_IMPL_FP32_COMPAT_API; + } + if(FORCE_NO_FBO_SUPPORT) { ctxProfileBits &= ~CTX_IMPL_FBO ; } @@ -1484,6 +1548,8 @@ public abstract class GLContextImpl extends GLContext { // setContextVersion(major, minor, ctxProfileBits, vendorVersion, true); + finalizeInit(gl); + setDefaultSwapInterval(); final int glErrX = gl.glGetError(); // clear GL error, maybe caused by above operations @@ -1813,7 +1879,7 @@ public abstract class GLContextImpl extends GLContext { protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits) { // remove non-key values - ctxProfileBits &= ~( GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) ; + ctxProfileBits &= CTX_IMPL_CACHE_MASK; return device.getUniqueID() + "-" + toHexString(composeBits(major, minor, ctxProfileBits)); } @@ -1998,7 +2064,7 @@ public abstract class GLContextImpl extends GLContext { public final int getContextCreationFlags() { return additionalCtxCreationFlags; } - + @Override public final void setContextCreationFlags(int flags) { if(!isCreated()) { @@ -2041,7 +2107,7 @@ public abstract class GLContextImpl extends GLContext { @Override public final void glDebugMessageControl(int source, int type, int severity, int count, IntBuffer ids, boolean enabled) { if(glDebugHandler.isExtensionARB()) { - gl.getGL2GL3().glDebugMessageControlARB(source, type, severity, count, ids, enabled); + gl.getGL2GL3().glDebugMessageControl(source, type, severity, count, ids, enabled); } else if(glDebugHandler.isExtensionAMD()) { gl.getGL2GL3().glDebugMessageEnableAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, count, ids, enabled); } @@ -2050,7 +2116,7 @@ public abstract class GLContextImpl extends GLContext { @Override public final void glDebugMessageControl(int source, int type, int severity, int count, int[] ids, int ids_offset, boolean enabled) { if(glDebugHandler.isExtensionARB()) { - gl.getGL2GL3().glDebugMessageControlARB(source, type, severity, count, ids, ids_offset, enabled); + gl.getGL2GL3().glDebugMessageControl(source, type, severity, count, ids, ids_offset, enabled); } else if(glDebugHandler.isExtensionAMD()) { gl.getGL2GL3().glDebugMessageEnableAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, count, ids, ids_offset, enabled); } @@ -2060,7 +2126,7 @@ public abstract class GLContextImpl extends GLContext { public final void glDebugMessageInsert(int source, int type, int id, int severity, String buf) { final int len = (null != buf) ? buf.length() : 0; if(glDebugHandler.isExtensionARB()) { - gl.getGL2GL3().glDebugMessageInsertARB(source, type, id, severity, len, buf); + gl.getGL2GL3().glDebugMessageInsert(source, type, id, severity, len, buf); } else if(glDebugHandler.isExtensionAMD()) { gl.getGL2GL3().glDebugMessageInsertAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, id, len, buf); } diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java index 10cdd512e..9ecaca75d 100644 --- a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java +++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java @@ -224,9 +224,9 @@ public class GLDebugMessageHandler { private final void setSynchronousImpl() { if(isExtensionARB()) { if(synchronous) { - ctx.getGL().glEnable(GL2GL3.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + ctx.getGL().glEnable(GL2GL3.GL_DEBUG_OUTPUT_SYNCHRONOUS); } else { - ctx.getGL().glDisable(GL2GL3.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + ctx.getGL().glDisable(GL2GL3.GL_DEBUG_OUTPUT_SYNCHRONOUS); } if(DEBUG) { System.err.println("GLDebugMessageHandler: synchronous "+synchronous); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index b54ed6599..e7977e3fb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -171,7 +171,7 @@ public class EGLContext extends GLContextImpl { try { // might be unavailable on EGL < 1.2 - if(!EGL.eglBindAPI(EGL.EGL_OPENGL_ES_API)) { + if( !EGL.eglBindAPI(EGL.EGL_OPENGL_ES_API) ) { throw new GLException("Catched: eglBindAPI to ES failed , error "+toHexString(EGL.eglGetError())); } } catch (GLException glex) { @@ -188,18 +188,21 @@ public class EGLContext extends GLContextImpl { } final IntBuffer contextAttrsNIO; + final int contextVersionReq, contextVersionAttr; { - final int[] contextAttrs = new int[] { - EGL.EGL_CONTEXT_CLIENT_VERSION, -1, - EGL.EGL_NONE - }; - if (glProfile.usesNativeGLES2()) { - contextAttrs[1] = 2; - } else if (glProfile.usesNativeGLES1()) { - contextAttrs[1] = 1; + if ( glProfile.usesNativeGLES3() ) { + contextVersionReq = 3; + contextVersionAttr = 2; + } else if ( glProfile.usesNativeGLES2() ) { + contextVersionReq = 2; + contextVersionAttr = 2; + } else if ( glProfile.usesNativeGLES1() ) { + contextVersionReq = 1; + contextVersionAttr = 1; } else { throw new GLException("Error creating OpenGL context - invalid GLProfile: "+glProfile); } + final int[] contextAttrs = new int[] { EGL.EGL_CONTEXT_CLIENT_VERSION, contextVersionAttr, EGL.EGL_NONE }; contextAttrsNIO = Buffers.newDirectIntBuffer(contextAttrs); } contextHandle = EGL.eglCreateContext(eglDisplay, eglConfig, shareWithHandle, contextAttrsNIO); @@ -219,8 +222,7 @@ public class EGLContext extends GLContextImpl { throw new GLException("Error making context " + toHexString(contextHandle) + " current: error code " + toHexString(EGL.eglGetError())); } - setGLFunctionAvailability(true, glProfile.usesNativeGLES2() ? 2 : 1, 0, CTX_PROFILE_ES, false); - return true; + return setGLFunctionAvailability(true, contextVersionReq, 0, CTX_PROFILE_ES, contextVersionReq>=3); // strict match for es >= 3 } @Override @@ -292,16 +294,25 @@ public class EGLContext extends GLContextImpl { final GLProfile glp = caps.getGLProfile(); final int[] reqMajorCTP = new int[2]; GLContext.getRequestMajorAndCompat(glp, reqMajorCTP); - if(glp.isGLES() && reqMajorCTP[0] >= 2) { - reqMajorCTP[1] |= GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; + if( glp.isGLES() ) { + if( reqMajorCTP[0] >= 3 ) { + reqMajorCTP[1] |= GLContext.CTX_IMPL_ES3_COMPAT | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; + } else if( reqMajorCTP[0] >= 2 ) { + reqMajorCTP[1] |= GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; + } } - if(!caps.getHardwareAccelerated()) { + if( !caps.getHardwareAccelerated() ) { reqMajorCTP[1] |= GLContext.CTX_IMPL_ACCEL_SOFT; } mapStaticGLVersion(device, reqMajorCTP[0], 0, reqMajorCTP[1]); } - /* pp */ static void mapStaticGLESVersion(AbstractGraphicsDevice device, int major) { - int ctp = ( 2 == major ) ? ( GLContext.CTX_PROFILE_ES | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) : ( GLContext.CTX_PROFILE_ES ); + /* pp */ static void mapStaticGLESVersion(AbstractGraphicsDevice device, final int major) { + int ctp = GLContext.CTX_PROFILE_ES; + if( major >= 3 ) { + ctp |= GLContext.CTX_IMPL_ES3_COMPAT | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; + } else if( major >= 2 ) { + ctp |= GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; + } mapStaticGLVersion(device, major, 0, ctp); } /* pp */ static void mapStaticGLVersion(AbstractGraphicsDevice device, int major, int minor, int ctp) { @@ -343,9 +354,13 @@ public class EGLContext extends GLContextImpl { throw new GLException("Not yet implemented"); } - @Override - public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { + public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { + throw new GLException("Should not call this"); + } + + @Override + public final void glFreeMemoryNV(ByteBuffer pointer) { throw new GLException("Should not call this"); } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 79d1fad62..465c8fa80 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -91,10 +91,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { private static final boolean isANGLE(GLDynamicLookupHelper dl) { if(Platform.OSType.WINDOWS == Platform.OS_TYPE) { - final boolean r = dl.isFunctionAvailable("eglQuerySurfacePointerANGLE") || - dl.isFunctionAvailable("glBlitFramebufferANGLE") || - dl.isFunctionAvailable("glRenderbufferStorageMultisampleANGLE"); - return r; + return dl.isFunctionAvailable("eglQuerySurfacePointerANGLE") || + dl.isFunctionAvailable("glBlitFramebufferANGLE") || + dl.isFunctionAvailable("glRenderbufferStorageMultisampleANGLE"); } else { return false; } @@ -253,8 +252,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { String key = keyI.next(); SharedResource sr = sharedMap.get(key); System.err.println("EGLDrawableFactory.map["+i+"] "+key+" -> "+sr.getDevice()+", "+ - "es1 [avail "+sr.wasES1ContextCreated+", pbuffer "+sr.hasPBufferES1+", quirks "+sr.rendererQuirksES1+", ctp "+EGLContext.getGLVersion(1, 0, sr.ctpES1, null)+"], "+ - "es2 [avail "+sr.wasES2ContextCreated+", pbuffer "+sr.hasPBufferES2+", quirks "+sr.rendererQuirksES2+", ctp "+EGLContext.getGLVersion(2, 0, sr.ctpES2, null)+"]"); + "es1 [avail "+sr.wasES1ContextCreated+", pbuffer "+sr.hasPBufferES1+", quirks "+sr.rendererQuirksES1+", ctp "+EGLContext.getGLVersion(1, 0, sr.ctpES1, null)+"], "+ + "es2/3 [es2 "+sr.wasES2ContextCreated+", es3 "+sr.wasES3ContextCreated+", [pbuffer "+sr.hasPBufferES3ES2+", quirks "+sr.rendererQuirksES3ES2+", ctp "+EGLContext.getGLVersion(2, 0, sr.ctpES3ES2, null)+"]]"); } ; } @@ -271,38 +270,45 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { private final EGLGraphicsDevice device; // private final EGLContext contextES1; // private final EGLContext contextES2; - private final GLRendererQuirks rendererQuirksES1; - private final GLRendererQuirks rendererQuirksES2; - private final int ctpES1; - private final int ctpES2; + // private final EGLContext contextES3; private final boolean wasES1ContextCreated; private final boolean wasES2ContextCreated; + private final boolean wasES3ContextCreated; + private final GLRendererQuirks rendererQuirksES1; + private final GLRendererQuirks rendererQuirksES3ES2; + private final int ctpES1; + private final int ctpES3ES2; private final boolean hasPBufferES1; - private final boolean hasPBufferES2; + private final boolean hasPBufferES3ES2; SharedResource(EGLGraphicsDevice dev, boolean wasContextES1Created, boolean hasPBufferES1, GLRendererQuirks rendererQuirksES1, int ctpES1, - boolean wasContextES2Created, boolean hasPBufferES2, GLRendererQuirks rendererQuirksES2, int ctpES2) { + boolean wasContextES2Created, boolean wasContextES3Created, + boolean hasPBufferES3ES2, GLRendererQuirks rendererQuirksES3ES2, int ctpES3ES2) { this.device = dev; // this.contextES1 = ctxES1; - // this.contextES2 = ctxES2; + this.wasES1ContextCreated = wasContextES1Created; + this.hasPBufferES1= hasPBufferES1; this.rendererQuirksES1 = rendererQuirksES1; - this.rendererQuirksES2 = rendererQuirksES2; this.ctpES1 = ctpES1; - this.ctpES2 = ctpES2; - this.wasES1ContextCreated = wasContextES1Created; + + // this.contextES2 = ctxES2; + // this.contextES3 = ctxES3; this.wasES2ContextCreated = wasContextES2Created; - this.hasPBufferES1= hasPBufferES1; - this.hasPBufferES2= hasPBufferES2; + this.wasES3ContextCreated = wasContextES3Created; + this.hasPBufferES3ES2= hasPBufferES3ES2; + this.rendererQuirksES3ES2 = rendererQuirksES3ES2; + this.ctpES3ES2 = ctpES3ES2; } @Override public final boolean isValid() { - return wasES1ContextCreated || wasES2ContextCreated; + return wasES1ContextCreated || wasES2ContextCreated || wasES3ContextCreated; } @Override public final EGLGraphicsDevice getDevice() { return device; } // final EGLContext getContextES1() { return contextES1; } // final EGLContext getContextES2() { return contextES2; } + // final EGLContext getContextES3() { return contextES3; } @Override public AbstractGraphicsScreen getScreen() { @@ -318,7 +324,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } @Override public GLRendererQuirks getRendererQuirks() { - return null != rendererQuirksES2 ? rendererQuirksES2 : rendererQuirksES1 ; + return null != rendererQuirksES3ES2 ? rendererQuirksES3ES2 : rendererQuirksES1 ; } } @@ -353,18 +359,30 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { boolean[] hasPBuffer, GLRendererQuirks[] rendererQuirks, int[] ctp) { final String profileString; switch( esProfile ) { + case 3: + profileString = GLProfile.GLES3; break; + case 2: + profileString = GLProfile.GLES2; break; case 1: profileString = GLProfile.GLES1; break; - case 2: default: - profileString = GLProfile.GLES2; break; + throw new GLException("Invalid ES profile number "+esProfile); } if ( !GLProfile.isAvailable(adevice, profileString) ) { + if( DEBUG ) { + System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: "+profileString+" n/a on "+adevice); + } return false; } final GLProfile glp = GLProfile.get(adevice, profileString) ; final GLDrawableFactoryImpl desktopFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getDesktopFactory(); final boolean mapsADeviceToDefaultDevice = !QUERY_EGL_ES_NATIVE_TK || null == desktopFactory || adevice instanceof EGLGraphicsDevice ; + if( DEBUG ) { + System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: "+profileString+" ( "+esProfile+" ), "+ + "defaultSharedResourceSet "+(null!=defaultSharedResource)+", mapsADeviceToDefaultDevice "+mapsADeviceToDefaultDevice+ + " (QUERY_EGL_ES_NATIVE_TK "+QUERY_EGL_ES_NATIVE_TK+", hasDesktopFactory "+(null != desktopFactory)+ + ", isEGLGraphicsDevice "+(adevice instanceof EGLGraphicsDevice)+")"); + } EGLGraphicsDevice eglDevice = null; NativeSurface surface = null; @@ -387,16 +405,29 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if( adevice != defaultDevice ) { if(null == defaultSharedResource) { return false; - } + } switch(esProfile) { + case 3: + if( !defaultSharedResource.wasES3ContextCreated ) { + return false; + } + rendererQuirks[0] = defaultSharedResource.rendererQuirksES3ES2; + ctp[0] = defaultSharedResource.ctpES3ES2; + break; + case 2: + if( !defaultSharedResource.wasES2ContextCreated ) { + return false; + } + rendererQuirks[0] = defaultSharedResource.rendererQuirksES3ES2; + ctp[0] = defaultSharedResource.ctpES3ES2; + break; case 1: + if( !defaultSharedResource.wasES1ContextCreated ) { + return false; + } rendererQuirks[0] = defaultSharedResource.rendererQuirksES1; ctp[0] = defaultSharedResource.ctpES1; break; - case 2: - rendererQuirks[0] = defaultSharedResource.rendererQuirksES2; - ctp[0] = defaultSharedResource.ctpES2; - break; } EGLContext.mapStaticGLVersion(adevice, esProfile, 0, ctp[0]); return true; @@ -421,7 +452,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { success = true; } if(DEBUG) { - System.err.println("EGLDrawableFactory.isEGLContextAvailable() no pbuffer config available, detected !pbuffer config: "+success); + System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig() no pbuffer config available, detected !pbuffer config: "+success); EGLGraphicsConfigurationFactory.printCaps("!PBufferCaps", capsAnyL, System.err); } } @@ -457,13 +488,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } else { // Oops .. something is wrong if(DEBUG) { - System.err.println("EGLDrawableFactory.isEGLContextAvailable: "+eglDevice+", "+context.getGLVersion()+" - VERSION is null, dropping availability!"); + System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: "+eglDevice+", "+context.getGLVersion()+" - VERSION is null, dropping availability!"); } } } } catch (GLException gle) { if (DEBUG) { - System.err.println("EGLDrawableFactory.createShared: INFO: context create/makeCurrent failed"); + System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: INFO: context create/makeCurrent failed"); gle.printStackTrace(); } } finally { @@ -557,14 +588,15 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { private SharedResource createEGLSharedResourceImpl(AbstractGraphicsDevice adevice) { final boolean madeCurrentES1; final boolean madeCurrentES2; + final boolean madeCurrentES3; boolean[] hasPBufferES1 = new boolean[] { false }; - boolean[] hasPBufferES2 = new boolean[] { false }; + boolean[] hasPBufferES3ES2 = new boolean[] { false }; // EGLContext[] eglCtxES1 = new EGLContext[] { null }; // EGLContext[] eglCtxES2 = new EGLContext[] { null }; GLRendererQuirks[] rendererQuirksES1 = new GLRendererQuirks[] { null }; - GLRendererQuirks[] rendererQuirksES2 = new GLRendererQuirks[] { null }; + GLRendererQuirks[] rendererQuirksES3ES2 = new GLRendererQuirks[] { null }; int[] ctpES1 = new int[] { -1 }; - int[] ctpES2 = new int[] { -1 }; + int[] ctpES3ES2 = new int[] { -1 }; if (DEBUG) { @@ -577,9 +609,16 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { madeCurrentES1 = false; } if( null != eglES2DynamicLookupHelper ) { - madeCurrentES2 = mapAvailableEGLESConfig(adevice, 2, hasPBufferES2, rendererQuirksES2, ctpES2); + madeCurrentES3 = mapAvailableEGLESConfig(adevice, 3, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); + if( madeCurrentES3 ) { + madeCurrentES2 = true; + EGLContext.mapStaticGLVersion(adevice, 2, 0, ctpES3ES2[0]); + } else { + madeCurrentES2 = mapAvailableEGLESConfig(adevice, 2, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); + } } else { madeCurrentES2 = false; + madeCurrentES3 = false; } if( !EGLContext.getAvailableGLVersionsSet(adevice) ) { @@ -589,10 +628,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } if( hasX11 ) { handleDontCloseX11DisplayQuirk(rendererQuirksES1[0]); - handleDontCloseX11DisplayQuirk(rendererQuirksES2[0]); + handleDontCloseX11DisplayQuirk(rendererQuirksES3ES2[0]); } final SharedResource sr = new SharedResource(defaultDevice, madeCurrentES1, hasPBufferES1[0], rendererQuirksES1[0], ctpES1[0], - madeCurrentES2, hasPBufferES2[0], rendererQuirksES2[0], ctpES2[0]); + madeCurrentES2, madeCurrentES3, hasPBufferES3ES2[0], rendererQuirksES3ES2[0], ctpES3ES2[0]); synchronized(sharedMap) { sharedMap.put(adevice.getUniqueID(), sr); @@ -600,7 +639,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if (DEBUG) { System.err.println("EGLDrawableFactory.createShared: devices: queried nativeTK "+QUERY_EGL_ES_NATIVE_TK+", adevice " + adevice + ", defaultDevice " + defaultDevice); System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1 + ", hasPBuffer "+hasPBufferES1[0]); - System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer "+hasPBufferES2[0]); + System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer "+hasPBufferES3ES2[0]); + System.err.println("EGLDrawableFactory.createShared: context ES3: " + madeCurrentES3 + ", hasPBuffer "+hasPBufferES3ES2[0]); dumpMap(); } return sr; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java index 9f4a4d2c2..778f0cb38 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java @@ -39,7 +39,7 @@ import jogamp.opengl.*; * Abstract implementation of the DynamicLookupHelper for EGL, * which decouples it's dependencies to EGLDrawable. * - * Currently two implementations exist, one for ES1 and one for ES2. + * Currently two implementations exist, one for ES1 and one for ES3 and ES2. */ public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundleInfo { static final List glueLibNames; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java index d83acdb6b..0d20fd4e8 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java @@ -30,6 +30,11 @@ package jogamp.opengl.egl; import java.util.*; +/** + *

    + * Covering ES3 and ES2. + *

    + */ public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo { protected EGLES2DynamicLibraryBundleInfo() { super(); @@ -40,18 +45,33 @@ public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundl { final List libsGL = new ArrayList(); - // this is the default lib name, according to the spec + // ES3: This is the default lib name, according to the spec + libsGL.add("libGLESv3.so.3"); + + // ES3: Try these as well, if spec fails + libsGL.add("libGLESv3.so"); + libsGL.add("GLESv3"); + + // ES3: Alternative names + libsGL.add("GLES30"); + + // ES3: For windows distributions using the 'unlike' lib prefix + // where our tool does not add it. + libsGL.add("libGLESv3"); + libsGL.add("libGLES30"); + + // ES2: This is the default lib name, according to the spec libsGL.add("libGLESv2.so.2"); - // try these as well, if spec fails + // ES2: Try these as well, if spec fails libsGL.add("libGLESv2.so"); libsGL.add("GLESv2"); - // alternative names + // ES2: Alternative names libsGL.add("GLES20"); libsGL.add("GLESv2_CM"); - // for windows distributions using the 'unlike' lib prefix + // ES2: For windows distributions using the 'unlike' lib prefix // where our tool does not add it. libsGL.add("libGLESv2"); libsGL.add("libGLESv2_CM"); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java index f857c6b5c..b61624d79 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java @@ -101,12 +101,16 @@ public class EGLGLCapabilities extends GLCapabilities { if(null == glp) { return true; } - if(0 != (renderableType & EGL.EGL_OPENGL_ES_BIT) && glp.usesNativeGLES1()) { + /** FIXME: EGLExt.EGL_OPENGL_ES3_BIT_KHR OK ? */ + if(0 != (renderableType & EGLExt.EGL_OPENGL_ES3_BIT_KHR) && glp.usesNativeGLES3()) { return true; } if(0 != (renderableType & EGL.EGL_OPENGL_ES2_BIT) && glp.usesNativeGLES2()) { return true; } + if(0 != (renderableType & EGL.EGL_OPENGL_ES_BIT) && glp.usesNativeGLES1()) { + return true; + } if(0 != (renderableType & EGL.EGL_OPENGL_BIT) && !glp.usesNativeGLES()) { return true; } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 6b086ce44..9b163ae5b 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -52,7 +52,7 @@ import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.ProxySurface; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; -import javax.media.opengl.GL3; +import javax.media.opengl.GL3ES3; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -142,7 +142,7 @@ public class MacOSXCGLContext extends GLContextImpl private static final String shaderBasename = "texture01_xxx"; - private static ShaderProgram createCALayerShader(GL3 gl) { + private static ShaderProgram createCALayerShader(GL3ES3 gl) { // Create & Link the shader program final ShaderProgram sp = new ShaderProgram(); final ShaderCode vp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, MacOSXCGLContext.class, @@ -420,11 +420,17 @@ public class MacOSXCGLContext extends GLContextImpl } @Override - public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { + public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { // FIXME: apparently the Apple extension doesn't require a custom memory allocator throw new GLException("Not yet implemented"); } + @Override + public final void glFreeMemoryNV(ByteBuffer pointer) { + // FIXME: apparently the Apple extension doesn't require a custom memory allocator + throw new GLException("Not yet implemented"); + } + @Override protected final void updateGLXProcAddressTable() { final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); @@ -846,7 +852,7 @@ public class MacOSXCGLContext extends GLContextImpl } if( MacOSXCGLContext.this.isGL3core() ) { if( null == gl3ShaderProgram) { - gl3ShaderProgram = createCALayerShader(MacOSXCGLContext.this.gl.getGL3()); + gl3ShaderProgram = createCALayerShader(MacOSXCGLContext.this.gl.getGL3ES3()); } gl3ShaderProgramName = gl3ShaderProgram.program(); } else { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index 94153d96d..b8979c91e 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -563,7 +563,13 @@ public class WindowsWGLContext extends GLContextImpl { } @Override - public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { - return getWGLExt().wglAllocateMemoryNV(arg0, arg1, arg2, arg3); + public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { + return getWGLExt().wglAllocateMemoryNV(size, readFrequency, writeFrequency, priority); } + + @Override + public final void glFreeMemoryNV(ByteBuffer pointer) { + getWGLExt().wglFreeMemoryNV(pointer); + } + } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index c37bcee50..5536ecd6a 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -633,10 +633,15 @@ public class X11GLXContext extends GLContextImpl { } @Override - public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { - return getGLXExt().glXAllocateMemoryNV(arg0, arg1, arg2, arg3); + public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { + return getGLXExt().glXAllocateMemoryNV(size, readFrequency, writeFrequency, priority); } + @Override + public final void glFreeMemoryNV(ByteBuffer pointer) { + getGLXExt().glXFreeMemoryNV(pointer); + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/src/jogl/native/GLDebugMessageHandler.c b/src/jogl/native/GLDebugMessageHandler.c index fea9d90ce..2e9d6033a 100644 --- a/src/jogl/native/GLDebugMessageHandler.c +++ b/src/jogl/native/GLDebugMessageHandler.c @@ -21,11 +21,11 @@ static jmethodID glDebugMessageARB = NULL; // int source, int type, int id, int severity, String msg static jmethodID glDebugMessageAMD = NULL; // int id, int category, int severity, String msg -typedef void (GLAPIENTRY* _local_PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); -typedef void (GLAPIENTRY* _local_GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +typedef void (APIENTRY* _local_PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef void (APIENTRY* _local_GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -typedef void (GLAPIENTRY* _local_PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, const GLvoid *userParam); -typedef void (GLAPIENTRY* _local_GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +typedef void (APIENTRY* _local_PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, const GLvoid *userParam); +typedef void (APIENTRY* _local_GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); /* * Class: jogamp_opengl_GLDebugMessageHandler diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 286840ed1..537b32355 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -830,14 +830,41 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind * A most simple JOGL AWT test entry */ public static void main(String args[]) { + boolean forceES2 = false; + boolean forceES3 = false; + boolean forceGL3 = false; + if( null != args ) { + for(int i=0; i Date: Mon, 15 Jul 2013 13:39:44 +0200 Subject: StringBuffer -> StringBuilder --- src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java | 4 ++-- src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java | 4 ++-- src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java | 4 ++-- src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java | 4 ++-- src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java | 4 ++-- src/nativewindow/classes/javax/media/nativewindow/Capabilities.java | 2 +- .../classes/javax/media/nativewindow/CapabilitiesImmutable.java | 2 +- src/newt/classes/com/jogamp/newt/MonitorMode.java | 4 ++-- src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java index b0fc7f332..2bd45e3e4 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java @@ -189,9 +189,9 @@ public class GLPixelBuffer { private boolean disposed = false; - public StringBuffer toString(StringBuffer sb) { + public StringBuilder toString(StringBuilder sb) { if(null == sb) { - sb = new StringBuffer(); + sb = new StringBuilder(); } sb.append(pixelAttributes).append(", dim ").append(width).append("x").append(height).append("x").append(depth).append(", pack ").append(pack) .append(", disposed ").append(disposed).append(", valid ").append(isValid()).append(", buffer[sz [bytes ").append(byteSize).append(", elemSize ").append(bufferElemSize).append(", ").append(buffer).append("]"); diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java index aceb609a1..df1bbdf26 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java @@ -109,7 +109,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { super.dispose(); } - public StringBuffer toString(StringBuffer sb) { + public StringBuilder toString(StringBuilder sb) { sb = super.toString(sb); sb.append(", allowRowStride ").append(allowRowStride).append(", image [").append(image.getWidth()).append("x").append(image.getHeight()).append(", ").append(image.toString()).append("]"); return sb; @@ -225,4 +225,4 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { } } } -} \ No newline at end of file +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java index 066b2054d..d18fd4bae 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java @@ -249,10 +249,10 @@ public class ShaderUtil { for(int i = source.length - 1; i>=0; i--) { final CharSequence csq = source[i]; if(csq instanceof String) { - // if ShaderCode.create(.. mutableStringBuffer == false ) + // if ShaderCode.create(.. mutableStringBuilder == false ) tmp[i] = (String) csq; } else { - // if ShaderCode.create(.. mutableStringBuffer == true ) + // if ShaderCode.create(.. mutableStringBuilder == true ) tmp[i] = source[i].toString(); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index 6b41c0bc8..9f951d5da 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -75,7 +75,7 @@ import javax.media.opengl.GL; // in case a fixed lookup function is being chosen, replace the name in our code rsFp.replaceInShaderSource(myTextureLookupName, texLookupFuncName); - // Cache the TextureSequence shader details in StringBuffer: + // Cache the TextureSequence shader details in StringBuilder: final StringBuilder sFpIns = new StringBuilder(); // .. declaration of the texture sampler using the implementation specific type @@ -217,4 +217,4 @@ public interface TextureSequence { * @throws IllegalStateException if instance is not initialized */ public String getTextureLookupFragmentShaderImpl() throws IllegalStateException ; -} \ No newline at end of file +} diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java index 4444e9d63..bf2d3fa47 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java @@ -80,7 +80,7 @@ public class WGLGLCapabilities extends GLCapabilities { public static final String PFD2String(PIXELFORMATDESCRIPTOR pfd, int pfdID) { final int dwFlags = pfd.getDwFlags(); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); boolean sep = false; if( 0 != (GDI.PFD_DRAW_TO_WINDOW & dwFlags ) ) { @@ -270,4 +270,4 @@ public class WGLGLCapabilities extends GLCapabilities { sink.append(": "); return super.toString(sink); } -} \ No newline at end of file +} diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java index 8e83eda33..f2a8e2394 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java +++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java @@ -366,7 +366,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { return msg.toString(); } - /** Return a textual representation of this object's on/off screen state. Use the given StringBuffer [optional]. */ + /** Return a textual representation of this object's on/off screen state. Use the given StringBuilder [optional]. */ protected StringBuilder onoffScreenToString(StringBuilder sink) { if(null == sink) { sink = new StringBuilder(); diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java index b801ab457..85659f286 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java @@ -130,7 +130,7 @@ public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, C @Override int hashCode(); - /** Return a textual representation of this object. Use the given StringBuffer [optional]. */ + /** Return a textual representation of this object. Use the given StringBuilder [optional]. */ StringBuilder toString(StringBuilder sink); /** Returns a textual representation of this object. */ diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java index dc7ae2c03..218cd8bd5 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorMode.java +++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java @@ -156,8 +156,8 @@ public class MonitorMode implements Comparable { private final static String STR_DOUBLESCAN = "DoubleScan"; private final static String STR_SEP = ", "; - public static final StringBuffer flags2String(int flags) { - final StringBuffer sb = new StringBuffer(); + public static final StringBuilder flags2String(int flags) { + final StringBuilder sb = new StringBuilder(); boolean sp = false; if( 0 != ( flags & FLAG_INTERLACE ) ) { sb.append(STR_INTERLACE); diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java index de524d54c..9f6210269 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java @@ -78,7 +78,7 @@ public class NewtVersionActivity extends NewtBaseActivity { glWindow.addGLEventListener(new GLEventListener() { public void init(GLAutoDrawable drawable) { GL gl = drawable.getGL(); - final StringBuffer sb = new StringBuffer(); + final StringBuilder sb = new StringBuilder(); sb.append(JoglVersion.getGLInfo(gl, null, true)).append(Platform.NEWLINE); sb.append("Requested: ").append(Platform.NEWLINE); sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); -- cgit v1.2.3 From 1a20ef3aa1dc9acedd7da0475ee19d4c40b18498 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 16 Jul 2013 20:46:42 +0200 Subject: Redefine: isGLES3Compatible() and isGL4ES3(), i.e. allow GL4ES3 usage in case proper ES3_compat is given. isGLES3Compatible() and isGL4ES3() of GLBase _and_ GLContext includes [ GL >= 4.3, GL >= 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]. Tested GL 'aliasing' w/ TestGLProfile01NEWT, i.e. isGL*() and getGL*(). --- src/jogl/classes/javax/media/opengl/GLBase.java | 14 +++- src/jogl/classes/javax/media/opengl/GLContext.java | 45 ++++++++++-- src/jogl/classes/javax/media/opengl/GLProfile.java | 85 +++++++++++++--------- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 5 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 70 ++++++++++++++---- .../test/junit/jogl/acore/TestGLProfile01NEWT.java | 69 ++++++++++++++++++ 6 files changed, 224 insertions(+), 64 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index 3e578dc68..f1853351f 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -174,7 +174,8 @@ public interface GLBase { public boolean isGL3ES3(); /** - * Indicates whether this GL object conforms to a GL4ES3 compatible profile. + * Returns true if this GL object conforms to a GL4ES3 compatible profile, i.e. if {@link #isGLES3Compatible()} returns true. + *

    Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]

    * @see GLContext#isGL4ES3() */ public boolean isGL4ES3(); @@ -213,8 +214,13 @@ public interface GLBase { /** * Indicates whether this GL object is compatible with the core OpenGL ES3 functionality. - * @return true if this context is an ES3 context or implements - * the extension GL_ARB_ES3_compatibility, otherwise false + *

    + * Return true if the underlying context is an ES3 context or implements + * the extension GL_ARB_ES3_compatibility, otherwise false. + *

    + *

    + * Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ] + *

    * @see GLContext#isGLES3Compatible() */ public boolean isGLES3Compatible(); @@ -319,7 +325,7 @@ public interface GLBase { /** * Casts this object to the GL4ES3 interface. - * @throws GLException if this object is not a GL3ES3 implementation + * @throws GLException if this object is not a GL4ES3 implementation */ public GL4ES3 getGL4ES3() throws GLException; diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index c3e82e6ee..0cf04d119 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -140,6 +140,9 @@ public abstract class GLContext { /** Version 3.2. As an OpenGL version, it qualifies for geometry shader */ public static final VersionNumber Version320 = new VersionNumber(3, 2, 0); + /** Version 4.3. As an OpenGL version, it qualifies for GL_ARB_ES3_compatibility */ + public static final VersionNumber Version430 = new VersionNumber(4, 3, 0); + protected static final VersionNumber Version800 = new VersionNumber(8, 0, 0); // @@ -822,8 +825,11 @@ public abstract class GLContext { } /** - * @return true if this context is an ES3 context or implements - * the extension GL_ARB_ES3_compatibility, otherwise false + * Return true if this context is an ES3 context or implements + * the extension GL_ARB_ES3_compatibility, otherwise false. + *

    + * Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ] + *

    */ public final boolean isGLES3Compatible() { return 0 != ( ctxOptions & CTX_IMPL_ES3_COMPAT ) ; @@ -1115,11 +1121,12 @@ public abstract class GLContext { } /** - * Indicates whether this profile is capable of GL4ES3.

    Includes [ GL4bc, GL4, GLES3 ].

    - * @see GLProfile#isGL4ES3() + * Returns true if this profile is capable of GL4ES3, i.e. if {@link #isGLES3Compatible()} returns true. + *

    Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]

    + * @see GLProfile#isGL4ES3() */ public final boolean isGL4ES3() { - return isGL4() || isGLES3() ; + return isGLES3Compatible() ; } /** @@ -1598,9 +1605,9 @@ public abstract class GLContext { */ protected static final void getRequestMajorAndCompat(final GLProfile glp, int[/*2*/] reqMajorCTP) { final GLProfile glpImpl = glp.getImpl(); - if(glpImpl.isGL4()) { + if( glpImpl.isGL4() ) { reqMajorCTP[0]=4; - } else if (glpImpl.isGL3()) { + } else if ( glpImpl.isGL3() || glpImpl.isGLES3() ) { reqMajorCTP[0]=3; } else if (glpImpl.isGLES1()) { reqMajorCTP[0]=1; @@ -1729,6 +1736,30 @@ public abstract class GLContext { return isGLVersionAvailable(device, 3, GLContext.CTX_PROFILE_ES, isHardware); } + /** + * Returns true if a ES3 compatible profile is available, + * i.e. either a ≥ 4.3 context or a ≥ 3.1 context supporting GL_ARB_ES3_compatibility, + * otherwise false. + *

    + * Includes [ GL4 > 4.3, GL3 > 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]. + *

    + */ + public static final boolean isGLES3CompatibleAvailable(AbstractGraphicsDevice device) { + int major[] = { 0 }; + int minor[] = { 0 }; + int ctp[] = { 0 }; + boolean ok; + + ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_CORE, major, minor, ctp); + if( !ok ) { + ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_COMPAT, major, minor, ctp); + } + if( !ok ) { + ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_ES, major, minor, ctp); + } + return 0 != ( ctp[0] & CTX_IMPL_ES3_COMPAT ); + } + public static boolean isGL4bcAvailable(AbstractGraphicsDevice device, boolean isHardware[]) { return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT, isHardware); } diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index c2a24e975..51b822449 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -298,13 +298,6 @@ public class GLProfile { glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_CORE); } - if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4ES3").append(indent); - } else { - sb.append(", GL4ES3 "); - } - sb.append(isAvailableImpl(map, GL4ES3)); - if(useIndent) { doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES3").append(indent); } else { @@ -349,13 +342,6 @@ public class GLProfile { glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_COMPAT); } - if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent); - } else { - sb.append(", GL2ES2 "); - } - sb.append(isAvailableImpl(map, GL2ES2)); - if(useIndent) { doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent); } else { @@ -367,13 +353,6 @@ public class GLProfile { glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES); } - if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent); - } else { - sb.append(", GL2ES1 "); - } - sb.append(isAvailableImpl(map, GL2ES1)); - if(useIndent) { doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES1").append(indent); } else { @@ -385,6 +364,27 @@ public class GLProfile { glAvailabilityToString(device, sb.append(" "), 1, GLContext.CTX_PROFILE_ES); } + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4ES3").append(indent); + } else { + sb.append(", GL4ES3 "); + } + sb.append(isAvailableImpl(map, GL4ES3)); + + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent); + } else { + sb.append(", GL2ES2 "); + } + sb.append(isAvailableImpl(map, GL2ES2)); + + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent); + } else { + sb.append(", GL2ES1 "); + } + sb.append(isAvailableImpl(map, GL2ES1)); + if(useIndent) { indentCount--; doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Profiles"); @@ -1922,24 +1922,37 @@ public class GLProfile { return GLES2; } } else if (GL4ES3.equals(profile)) { - final boolean es3HardwareRasterizer[] = new boolean[1]; - final boolean gles3Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, es3HardwareRasterizer) ); - final boolean gles3HWAvailable = gles3Available && es3HardwareRasterizer[0] ; - if(hasGL234Impl) { - if(GLContext.isGL4Available(device, isHardwareRasterizer)) { - if(!gles3HWAvailable || isHardwareRasterizer[0]) { - return GL4; + final boolean gles3CompatAvail = GLContext.isGLES3CompatibleAvailable(device); + if( desktopCtxUndef || esCtxUndef || gles3CompatAvail ) { + final boolean es3HardwareRasterizer[] = new boolean[1]; + final boolean gles3Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, es3HardwareRasterizer) ); + final boolean gles3HWAvailable = gles3Available && es3HardwareRasterizer[0] ; + if(hasGL234Impl) { + if(GLContext.isGL4Available(device, isHardwareRasterizer)) { + if(!gles3HWAvailable || isHardwareRasterizer[0]) { + return GL4; + } } - } - if(GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { - if(!gles3HWAvailable || isHardwareRasterizer[0]) { - return GL4bc; + if( GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { + if(!gles3HWAvailable || isHardwareRasterizer[0]) { + return GL4bc; + } + } + if(GLContext.isGL3Available(device, isHardwareRasterizer)) { + if(!gles3HWAvailable || isHardwareRasterizer[0]) { + return GL3; + } + } + if( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) { + if(!gles3HWAvailable || isHardwareRasterizer[0]) { + return GL3bc; + } } } - } - if(gles3Available) { - isHardwareRasterizer[0] = es3HardwareRasterizer[0]; - return GLES3; + if(gles3Available) { + isHardwareRasterizer[0] = es3HardwareRasterizer[0]; + return GLES3; + } } } else if(GL2GL3.equals(profile)) { if(hasGL234Impl) { diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 5da60597e..6f4f6f271 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1536,7 +1536,10 @@ public abstract class GLContextImpl extends GLContext { ctxProfileBits |= CTX_IMPL_ES2_COMPAT; ctxProfileBits |= CTX_IMPL_FBO; } - } else if( isExtensionAvailable( GLExtensions.ARB_ES3_compatibility ) ) { + } else if( ( major > 4 || major == 4 && minor >= 3 ) || + ( ( major > 3 || major == 3 && minor >= 1 ) && isExtensionAvailable( GLExtensions.ARB_ES3_compatibility ) ) ) { + // See GLContext.isGLES3CompatibleAvailable(..)/isGLES3Compatible() + // Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ] ctxProfileBits |= CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ; ctxProfileBits |= CTX_IMPL_FBO; } else if( isExtensionAvailable( GLExtensions.ARB_ES2_compatibility ) ) { diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 537b32355..e85d67dea 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -49,6 +49,8 @@ import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; import javax.media.opengl.FPSCounter; import javax.media.opengl.GL; +import javax.media.opengl.GL3; +import javax.media.opengl.GL4ES3; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; @@ -56,6 +58,8 @@ import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLES2; +import javax.media.opengl.GLES3; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -830,23 +834,38 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind * A most simple JOGL AWT test entry */ public static void main(String args[]) { - boolean forceES2 = false; - boolean forceES3 = false; - boolean forceGL3 = false; - if( null != args ) { - for(int i=0; i GL4"); + } + if( gl.isGL4bc() ) { + Assert.assertNotNull( gl.getGL4bc() ); + System.err.println("GL Mapping "+glp+" -> GL4bc"); + } + if( gl.isGL3() ) { + Assert.assertNotNull( gl.getGL3() ); + System.err.println("GL Mapping "+glp+" -> GL3"); + } + if( gl.isGL3bc() ) { + Assert.assertNotNull( gl.getGL3bc() ); + System.err.println("GL Mapping "+glp+" -> GL3bc"); + } + if( gl.isGLES3() ) { + Assert.assertNotNull( gl.getGLES3() ); + System.err.println("GL Mapping "+glp+" -> GLES3"); + } + if( gl.isGLES2() ) { + Assert.assertNotNull( gl.getGLES2() ); + System.err.println("GL Mapping "+glp+" -> GLES2"); + } + if( gl.isGL4ES3() ) { + Assert.assertNotNull( gl.getGL4ES3() ); + System.err.println("GL Mapping "+glp+" -> GL4ES3"); + } + if( gl.isGL2ES2() ) { + Assert.assertNotNull( gl.getGL2ES2() ); + System.err.println("GL Mapping "+glp+" -> GL2ES2"); + } + if( gl.isGL2ES1() ) { + Assert.assertNotNull( gl.getGL2ES1() ); + System.err.println("GL Mapping "+glp+" -> GL2ES1"); + } + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + } + + public void display(GLAutoDrawable drawable) { + } + + public void dispose(GLAutoDrawable drawable) { + } + }); glWindow.setSize(128, 128); glWindow.setVisible(true); -- cgit v1.2.3 From 8ac3f344aded383ca9a3083a877af7bfdf6e1e48 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 17 Jul 2013 04:27:13 +0200 Subject: Remedy for Bug 782: Issue Debug.initSingleton() or Debug.debug(..) before calling 'PropertyAccess.isPropertyDefined(propName, default)' through Debug class. Calling 'Debug.isPropertyDefined(propName, default)' may be 'optimized' to 'PropertyAccess.isPropertyDefined(propName, default)', which would skip the modules Debug's class initialization. Iff that happens, an AccessControlException may happen, due to requesting an insecure property, since modules own Debug class has not been added it's trusted prefixes from within it's init block yet. This seems to be a bug of the JVM .. to me, however .. the above description is the only able to explain the issue at hand. +++ Fix calls Debug class own static methods, either Debug.initSingleton() or Debug.debug(), before calling 'isPropertyDefined(propName, default)'. +++ Also mark Debug class static methods final! +++ --- src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java | 13 ++++++++++--- .../classes/com/jogamp/opengl/util/awt/TextRenderer.java | 7 ++++++- .../classes/com/jogamp/opengl/util/glsl/ShaderState.java | 9 +++++++-- .../javax/media/opengl/DefaultGLCapabilitiesChooser.java | 7 ++++++- src/jogl/classes/javax/media/opengl/GLContext.java | 8 ++++---- src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 12 +++++++++--- src/jogl/classes/jogamp/opengl/Debug.java | 9 ++++++--- src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java | 10 ++++++++-- src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java | 8 +++++++- src/jogl/classes/jogamp/opengl/GLDrawableHelper.java | 7 ++++++- src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java | 10 ++++++++-- src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java | 7 ++++++- .../opengl/util/glsl/fixedfunc/FixedFuncPipeline.java | 8 +++++++- src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java | 1 + .../jogamp/opengl/windows/wgl/WindowsWGLDrawable.java | 8 +++++++- .../media/nativewindow/DefaultCapabilitiesChooser.java | 7 ++++++- src/nativewindow/classes/jogamp/nativewindow/Debug.java | 9 ++++++--- .../classes/jogamp/nativewindow/x11/X11Util.java | 3 ++- src/newt/classes/jogamp/newt/Debug.java | 9 ++++++--- src/newt/classes/jogamp/newt/ScreenImpl.java | 7 ++++++- src/newt/classes/jogamp/newt/WindowImpl.java | 11 +++++++---- src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java | 5 ++++- 22 files changed, 135 insertions(+), 40 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java index 27ce7d8ec..dc96cb5f2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java @@ -48,9 +48,16 @@ import com.jogamp.opengl.util.glsl.ShaderState; *

    */ public class ImmModeSink { - protected static final boolean DEBUG_BEGIN_END = Debug.isPropertyDefined("jogl.debug.ImmModeSink.BeginEnd", true); - protected static final boolean DEBUG_DRAW = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Draw", true); - protected static final boolean DEBUG_BUFFER = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Buffer", true); + protected static final boolean DEBUG_BEGIN_END; + protected static final boolean DEBUG_DRAW; + protected static final boolean DEBUG_BUFFER; + + static { + Debug.initSingleton(); + DEBUG_BEGIN_END = Debug.isPropertyDefined("jogl.debug.ImmModeSink.BeginEnd", true); + DEBUG_DRAW = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Draw", true); + DEBUG_BUFFER = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Buffer", true); + } public static final int GL_QUADS = 0x0007; // Needs data manipulation on ES1/ES2 public static final int GL_QUAD_STRIP = 0x0008; diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java index 1735fcddd..c67141525 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java @@ -128,7 +128,12 @@ import jogamp.opengl.Debug; @author Kenneth Russell */ public class TextRenderer { - private static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.TextRenderer", true); + private static final boolean DEBUG; + + static { + Debug.initSingleton(); + DEBUG = Debug.isPropertyDefined("jogl.debug.TextRenderer", true); + } // These are occasionally useful for more in-depth debugging private static final boolean DISABLE_GLYPH_CACHE = false; diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java index 968391976..8e7781f07 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java @@ -55,8 +55,13 @@ import com.jogamp.opengl.util.GLArrayDataEditable; * and can be retrieved via {@link #getShaderState(GL)}. *

    */ -public class ShaderState { - public static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLSLState", true); +public class ShaderState { + public static final boolean DEBUG; + + static { + Debug.initSingleton(); + DEBUG = Debug.isPropertyDefined("jogl.debug.GLSLState", true); + } public ShaderState() { } diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java index b052769ca..b0f3da8e4 100644 --- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java +++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java @@ -85,8 +85,13 @@ import jogamp.opengl.Debug; */ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { - private static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.CapabilitiesChooser", true); + private static final boolean DEBUG; + static { + Debug.initSingleton(); + DEBUG = Debug.isPropertyDefined("jogl.debug.CapabilitiesChooser", true); + } + private final static int NO_SCORE = -9999999; private final static int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000; private final static int OPAQUE_MISMATCH_PENALTY = 750; diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index f36061c13..aa5fca2c2 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -73,6 +73,10 @@ import com.jogamp.opengl.GLRendererQuirks; refer to a given context. */ public abstract class GLContext { + public static final boolean DEBUG = Debug.debug("GLContext"); + public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true); + public static final boolean DEBUG_TRACE_SWITCH = DEBUG || TRACE_SWITCH; + /** * If true (default), bootstrapping the available GL profiles * will use the highest compatible GL context for each profile, @@ -102,10 +106,6 @@ public abstract class GLContext { protected static final boolean FORCE_NO_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.none", true); protected static final boolean FORCE_MIN_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.min", true); - public static final boolean DEBUG = Debug.debug("GLContext"); - public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true); - public static final boolean DEBUG_TRACE_SWITCH = DEBUG || TRACE_SWITCH; - /** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */ public static final boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true); /** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */ diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index d3f20b2e5..2a23defbe 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -138,9 +138,9 @@ import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.SingleAWTGLPixelBufferProvide @SuppressWarnings("serial") public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosingProtocol { - private static final boolean DEBUG = Debug.debug("GLJPanel"); - private static final boolean DEBUG_VIEWPORT = Debug.isPropertyDefined("jogl.debug.GLJPanel.Viewport", true); - private static final boolean USE_GLSL_TEXTURE_RASTERIZER = !Debug.isPropertyDefined("jogl.gljpanel.noglsl", true); + private static final boolean DEBUG; + private static final boolean DEBUG_VIEWPORT; + private static final boolean USE_GLSL_TEXTURE_RASTERIZER; /** Indicates whether the Java 2D OpenGL pipeline is requested by user. */ private static final boolean java2dOGLEnabledByProp; @@ -152,11 +152,17 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private static boolean java2DGLPipelineOK; static { + Debug.initSingleton(); + DEBUG = Debug.debug("GLJPanel"); + DEBUG_VIEWPORT = Debug.isPropertyDefined("jogl.debug.GLJPanel.Viewport", true); + USE_GLSL_TEXTURE_RASTERIZER = !Debug.isPropertyDefined("jogl.gljpanel.noglsl", true); + boolean enabled = false; final String sVal = System.getProperty("sun.java2d.opengl"); if( null != sVal ) { enabled = Boolean.valueOf(sVal); } + Debug.initSingleton(); java2dOGLEnabledByProp = enabled && !Debug.isPropertyDefined("jogl.gljpanel.noogl", true); enabled = false; diff --git a/src/jogl/classes/jogamp/opengl/Debug.java b/src/jogl/classes/jogamp/opengl/Debug.java index f87f1bb3f..b88a09b71 100644 --- a/src/jogl/classes/jogamp/opengl/Debug.java +++ b/src/jogl/classes/jogamp/opengl/Debug.java @@ -68,16 +68,19 @@ public class Debug extends PropertyAccess { System.err.println("JOGL implementation vendor " + p.getImplementationVendor()); } } + + /** Ensures static init block has been issues, i.e. if calling through to {@link PropertyAccess#isPropertyDefined(String, boolean)}. */ + public static final void initSingleton() {} - public static boolean verbose() { + public static final boolean verbose() { return verbose; } - public static boolean debugAll() { + public static final boolean debugAll() { return debugAll; } - public static boolean debug(String subcomponent) { + public static final boolean debug(String subcomponent) { return debugAll() || isPropertyDefined("jogl.debug." + subcomponent, true); } } diff --git a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java index 78ab7cc93..17646cc7b 100644 --- a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java +++ b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java @@ -87,6 +87,13 @@ import com.jogamp.common.util.IntLongHashMap; */ public class GLBufferSizeTracker { + protected static final boolean DEBUG; + + static { + Debug.initSingleton(); + DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferSizeTracker", true); + } + // Map from buffer names to sizes. // Note: should probably have some way of shrinking this map, but // can't just make it a WeakHashMap because nobody holds on to the @@ -95,8 +102,7 @@ public class GLBufferSizeTracker { // pattern of buffer objects indicates that the fact that this map // never shrinks is probably not that bad. private IntLongHashMap bufferSizeMap; - protected static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferSizeTracker", true); - + public GLBufferSizeTracker() { bufferSizeMap = new IntLongHashMap(); bufferSizeMap.setKeyNotFoundValue(0xFFFFFFFFFFFFFFFFL); diff --git a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java index 7f5316fbd..890c82c90 100644 --- a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java +++ b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java @@ -76,7 +76,13 @@ import com.jogamp.common.util.IntIntHashMap; */ public class GLBufferStateTracker { - protected static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferStateTracker", true); + protected static final boolean DEBUG; + + static { + Debug.initSingleton(); + DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferStateTracker", true); + } + // Maps binding targets to buffer objects. A null value indicates // that the binding is unknown. A zero value indicates that it is // known that no buffer is bound to the target, according to the diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 8be910c1a..5418fbaf3 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -62,8 +62,13 @@ import javax.media.opengl.GLRunnable; methods to be able to share it between GLAutoDrawable implementations like GLAutoDrawableBase, GLCanvas and GLJPanel. */ public class GLDrawableHelper { /** true if property jogl.debug.GLDrawable.PerfStats is defined. */ - private static final boolean PERF_STATS = Debug.isPropertyDefined("jogl.debug.GLDrawable.PerfStats", true); + private static final boolean PERF_STATS; + static { + Debug.initSingleton(); + PERF_STATS = Debug.isPropertyDefined("jogl.debug.GLDrawable.PerfStats", true); + } + protected static final boolean DEBUG = GLDrawableImpl.DEBUG; private final Object listenersLock = new Object(); private final ArrayList listeners = new ArrayList(); diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index 27024d4e1..3833e6852 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -37,8 +37,14 @@ import com.jogamp.opengl.JoglVersion; * @see GLDrawableImpl#getDefaultReadFramebuffer() */ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { - protected static final boolean DEBUG = GLDrawableImpl.DEBUG || Debug.debug("FBObject"); - protected static final boolean DEBUG_SWAP = Debug.isPropertyDefined("jogl.debug.FBObject.Swap", true); + protected static final boolean DEBUG; + protected static final boolean DEBUG_SWAP; + + static { + Debug.initSingleton(); + DEBUG = GLDrawableImpl.DEBUG || Debug.debug("FBObject"); + DEBUG_SWAP = Debug.isPropertyDefined("jogl.debug.FBObject.Swap", true); + } private final GLDrawableImpl parent; private GLCapabilitiesImmutable origParentChosenCaps; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 9c1cc7fc4..5d99e3eba 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -84,7 +84,12 @@ import com.jogamp.opengl.GLRendererQuirks; public class EGLDrawableFactory extends GLDrawableFactoryImpl { protected static final boolean DEBUG = GLDrawableFactoryImpl.DEBUG; // allow package access - /* package */ static final boolean QUERY_EGL_ES_NATIVE_TK = Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.QueryNativeTK", true); + /* package */ static final boolean QUERY_EGL_ES_NATIVE_TK; + + static { + Debug.initSingleton(); + QUERY_EGL_ES_NATIVE_TK = Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.QueryNativeTK", true); + } private static GLDynamicLookupHelper eglES1DynamicLookupHelper = null; private static GLDynamicLookupHelper eglES2DynamicLookupHelper = null; diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java index f4f20ac7c..2e924cbfb 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java @@ -66,7 +66,13 @@ import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode; *

    */ public class FixedFuncPipeline { - protected static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.FixedFuncPipeline", true); + protected static final boolean DEBUG; + + static { + Debug.initSingleton(); + DEBUG = Debug.isPropertyDefined("jogl.debug.FixedFuncPipeline", true); + } + /** The maximum texture units which could be used, depending on {@link ShaderSelectionMode}. */ public static final int MAX_TEXTURE_UNITS = 8; public static final int MAX_LIGHTS = 8; diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java index f1598d580..3e788d286 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java @@ -51,6 +51,7 @@ public class WGLUtil { public static final boolean USE_WGLVersion_Of_5WGLGDIFuncSet; static { + Debug.initSingleton(); USE_WGLVersion_Of_5WGLGDIFuncSet = Debug.isPropertyDefined("jogl.windows.useWGLVersionOf5WGLGDIFuncSet", true); if(USE_WGLVersion_Of_5WGLGDIFuncSet) { System.err.println("Use WGL version of 5 WGL/GDI functions."); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java index 8b8cb2052..741e671eb 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java @@ -51,7 +51,13 @@ import jogamp.opengl.GLDynamicLookupHelper; public abstract class WindowsWGLDrawable extends GLDrawableImpl { - private static final boolean PROFILING = Debug.isPropertyDefined("jogl.debug.GLDrawable.profiling", true); + private static final boolean PROFILING; + + static { + Debug.initSingleton(); + PROFILING = Debug.isPropertyDefined("jogl.debug.GLDrawable.profiling", true); + } + private static final int PROFILING_TICKS = 200; private int profilingSwapBuffersTicks; private long profilingSwapBuffersTime; diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java index 744c7e6d5..4f07bca9b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java @@ -66,8 +66,13 @@ import jogamp.nativewindow.Debug; */ public class DefaultCapabilitiesChooser implements CapabilitiesChooser { - private static final boolean DEBUG = Debug.isPropertyDefined("nativewindow.debug.CapabilitiesChooser", true); + private static final boolean DEBUG; + static { + Debug.initSingleton(); + DEBUG = Debug.isPropertyDefined("nativewindow.debug.CapabilitiesChooser", true); + } + private final static int NO_SCORE = -9999999; private final static int COLOR_MISMATCH_PENALTY_SCALE = 36; diff --git a/src/nativewindow/classes/jogamp/nativewindow/Debug.java b/src/nativewindow/classes/jogamp/nativewindow/Debug.java index 95547c971..c5e316364 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/Debug.java +++ b/src/nativewindow/classes/jogamp/nativewindow/Debug.java @@ -69,15 +69,18 @@ public class Debug extends PropertyAccess { } } - public static boolean verbose() { + /** Ensures static init block has been issues, i.e. if calling through to {@link PropertyAccess#isPropertyDefined(String, boolean)}. */ + public static final void initSingleton() {} + + public static final boolean verbose() { return verbose; } - public static boolean debugAll() { + public static final boolean debugAll() { return debugAll; } - public static boolean debug(String subcomponent) { + public static final boolean debug(String subcomponent) { return debugAll() || isPropertyDefined("nativewindow.debug." + subcomponent, true); } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index bbc58b73a..78e432b7f 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -53,6 +53,8 @@ import com.jogamp.nativewindow.x11.X11GraphicsDevice; * Contains a thread safe X11 utility to retrieve display connections. */ public class X11Util implements ToolkitProperties { + public static final boolean DEBUG = Debug.debug("X11Util"); + /** * See Bug 515 - https://jogamp.org/bugzilla/show_bug.cgi?id=515 *

    @@ -92,7 +94,6 @@ public class X11Util implements ToolkitProperties { */ public static final boolean ATI_HAS_MULTITHREADING_BUG = !Debug.isPropertyDefined("nativewindow.debug.X11Util.ATI_HAS_NO_MULTITHREADING_BUG", true); - public static final boolean DEBUG = Debug.debug("X11Util"); public static final boolean XSYNC_ENABLED = Debug.isPropertyDefined("nativewindow.debug.X11Util.XSync", true); public static final boolean XERROR_STACKDUMP = DEBUG || Debug.isPropertyDefined("nativewindow.debug.X11Util.XErrorStackDump", true); private static final boolean TRACE_DISPLAY_LIFECYCLE = Debug.isPropertyDefined("nativewindow.debug.X11Util.TraceDisplayLifecycle", true); diff --git a/src/newt/classes/jogamp/newt/Debug.java b/src/newt/classes/jogamp/newt/Debug.java index 676d9b758..4b0a98216 100644 --- a/src/newt/classes/jogamp/newt/Debug.java +++ b/src/newt/classes/jogamp/newt/Debug.java @@ -69,15 +69,18 @@ public class Debug extends PropertyAccess { } } - public static boolean verbose() { + /** Ensures static init block has been issues, i.e. if calling through to {@link PropertyAccess#isPropertyDefined(String, boolean)}. */ + public static final void initSingleton() {} + + public static final boolean verbose() { return verbose; } - public static boolean debugAll() { + public static final boolean debugAll() { return debugAll; } - public static boolean debug(String subcomponent) { + public static final boolean debug(String subcomponent) { return debugAll() || isPropertyDefined("newt.debug." + subcomponent, true); } } diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index fe9e91b57..5ffa2ebbf 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -55,7 +55,12 @@ import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.util.MonitorModeUtil; public abstract class ScreenImpl extends Screen implements MonitorModeListener { - protected static final boolean DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true); + protected static final boolean DEBUG_TEST_SCREENMODE_DISABLED; + + static { + Debug.initSingleton(); + DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true); + } public static final int default_sm_bpp = 32; public static final int default_sm_widthmm = 519; diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 2c3c903f1..caa461e41 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -81,14 +81,17 @@ import jogamp.nativewindow.SurfaceUpdatedHelper; public abstract class WindowImpl implements Window, NEWTEventConsumer { - public static final boolean DEBUG_TEST_REPARENT_INCOMPATIBLE = Debug.isPropertyDefined("newt.test.Window.reparent.incompatible", true); - - protected static final ArrayList> windowList = new ArrayList>(); + public static final boolean DEBUG_TEST_REPARENT_INCOMPATIBLE; static { + Debug.initSingleton(); + DEBUG_TEST_REPARENT_INCOMPATIBLE = Debug.isPropertyDefined("newt.test.Window.reparent.incompatible", true); + ScreenImpl.initSingleton(); } - + + protected static final ArrayList> windowList = new ArrayList>(); + /** Maybe utilized at a shutdown hook, impl. does not block. */ public static final void shutdownAll() { final int wCount = windowList.size(); diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index 1335f5697..f37556dd7 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -55,9 +55,12 @@ import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; public class ScreenDriver extends ScreenImpl { - protected static final boolean DEBUG_TEST_RANDR13_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableRandR13", true); + protected static final boolean DEBUG_TEST_RANDR13_DISABLED; static { + Debug.initSingleton(); + DEBUG_TEST_RANDR13_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableRandR13", true); + DisplayDriver.initSingleton(); } -- cgit v1.2.3 From b6be013a0e9dd570b4da42dbe8d88cc509a6aa99 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 10 Aug 2013 08:44:00 +0200 Subject: MouseEvent API doc: Add W3C PointerEvent Reference --- src/newt/classes/com/jogamp/newt/event/MouseEvent.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 93bbcc0b9..8533a37c6 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -37,6 +37,9 @@ package com.jogamp.newt.event; /** * Pointer event of type {@link PointerType}. *

    + * http://www.w3.org/Submission/pointer-events/#pointerevent-interface + *

    + *

    * In case an instance represents multi-touch events, i.e. {@link #getPointerCount()} is > 1, * the first data element represents the pointer which triggered the action if individual to one pointer.
    * For example {@link #getX(int) e.getX(0)} at {@link #EVENT_MOUSE_PRESSED} returns the data of the pressed pointer, etc. -- cgit v1.2.3 From a7024efba2fb3731d0a67df187c258edf2b33f0d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 30 Aug 2013 17:31:56 +0200 Subject: GLWindow: Shorten API-doc references --- src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index e85d67dea..30c51218b 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -63,6 +63,7 @@ import javax.media.opengl.GLES3; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import javax.media.opengl.GLRunnable; import jogamp.newt.WindowImpl; import jogamp.opengl.GLAutoDrawableBase; @@ -80,6 +81,7 @@ import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.event.NEWTEvent; import com.jogamp.newt.event.NEWTEventConsumer; +import com.jogamp.newt.event.NEWTEventListener; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; @@ -96,12 +98,12 @@ import com.jogamp.opengl.GLStateKeeper; *

    *

    * This implementation does not make the OpenGL context current
    - * before calling the various input EventListener callbacks, ie {@link com.jogamp.newt.event.MouseListener} etc.
    + * before calling the various input EventListener callbacks, ie {@link MouseListener} etc.
    * This design decision is made in favor of a more performant and simplified * implementation. Also the event dispatcher shall be implemented OpenGL agnostic.
    - * To be able to use OpenGL commands from within such input {@link com.jogamp.newt.event.NEWTEventListener},
    - * you can inject {@link javax.media.opengl.GLRunnable} objects - * via {@link #invoke(boolean, javax.media.opengl.GLRunnable)} to the OpenGL command stream.
    + * To be able to use OpenGL commands from within such input {@link NEWTEventListener},
    + * you can inject {@link GLRunnable} objects + * via {@link #invoke(boolean, GLRunnable)} to the OpenGL command stream.
    *

    */ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter { -- cgit v1.2.3 From 32171ee45370a9c6dacb582c39d51d0ff17911f1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 2 Sep 2013 07:05:11 +0200 Subject: Animator/GLWindow: Catch 'ThreadDeath/Throwable' and dump info in DEBUG mode (cosmetic change only); Typo in comment; TestSharedContextListNEWT2: Stop animator. --- src/jogl/classes/com/jogamp/opengl/util/Animator.java | 5 +++++ .../jogamp/opengl/x11/glx/X11GLXDrawableFactory.java | 2 +- src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 4 ++++ .../junit/jogl/acore/TestSharedContextListNEWT2.java | 17 +++++++++++------ 4 files changed, 21 insertions(+), 7 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index ac2b24117..80d980492 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -201,6 +201,11 @@ public class Animator extends AnimatorBase { Thread.yield(); } } + } catch( ThreadDeath td) { + if(DEBUG) { + System.err.println("Animator Catched: "+td.getClass().getName()+": "+td.getMessage()); + td.printStackTrace(); + } } finally { if( exclusiveContext && !drawablesEmpty ) { setDrawablesExclCtxState(false); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 52069b88f..91beddb02 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -337,7 +337,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if (null != sr.context) { // may cause JVM SIGSEGV: - sr.context.destroy(); // will also pull the dummy MutuableSurface + sr.context.destroy(); // will also pull the dummy MutableSurface sr.context = null; } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 30c51218b..45ab2a44c 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -553,6 +553,10 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind try { animThread.stop(); } catch(Throwable t) { + if( DEBUG ) { + System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); + t.printStackTrace(); + } } } return null; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java index 6b1da870a..0d1f58c1e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java @@ -118,12 +118,13 @@ public class TestSharedContextListNEWT2 extends UITestCase { @Test(timeout=10000) public void test01() throws InterruptedException { initShared(); - GLWindow f1 = runTestGL(new Animator(), 0, 0, true, false); - InsetsImmutable insets = f1.getInsets(); - GLWindow f2 = runTestGL(new Animator(), f1.getX()+width+insets.getTotalWidth(), - f1.getY()+0, true, false); - GLWindow f3 = runTestGL(new Animator(), f1.getX()+0, - f1.getY()+height+insets.getTotalHeight(), true, false); + + final GLWindow f1 = runTestGL(new Animator(), 0, 0, true, false); + final InsetsImmutable insets = f1.getInsets(); + final GLWindow f2 = runTestGL(new Animator(), f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, true, false); + final GLWindow f3 = runTestGL(new Animator(), f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), true, false); try { Thread.sleep(duration); @@ -134,6 +135,10 @@ public class TestSharedContextListNEWT2 extends UITestCase { f1.destroy(); f2.destroy(); f3.destroy(); + + f1.getAnimator().stop(); + f2.getAnimator().stop(); + f3.getAnimator().stop(); releaseShared(); } -- cgit v1.2.3 From 14eab8af439e6e7ce7ee08a9ca13fec3f3a80d25 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 2 Sep 2013 21:01:10 +0200 Subject: Fix Bug 810: Adding Julien Gouesse's fix while moved the new 'addNativeJarLibsJoglCfg(..)' to GlueGen, commit c0ead6fa10280f8076704726d59f482b183fd77e --- src/jogl/classes/javax/media/opengl/GLProfile.java | 8 ++---- .../jogamp/nativewindow/NWJNILibLoader.java | 30 +++++++++----------- src/newt/classes/jogamp/newt/NEWTJNILibLoader.java | 32 +++++++++------------- 3 files changed, 28 insertions(+), 42 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 51b822449..e3078271e 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -143,16 +143,12 @@ public class GLProfile { if(TempJarCache.isInitialized()) { final ClassLoader cl = GLProfile.class.getClassLoader(); - // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-.jar - // or: nativewindow-core.jar -> nativewindow-natives-.jar, - // jogl-core.jar -> jogl-natives-.jar, - // (newt-core.jar -> newt-natives-.jar)? (if available) final String newtFactoryClassName = "com.jogamp.newt.NewtFactory"; final Class[] classesFromJavaJars = new Class[] { NWJNILibLoader.class, GLProfile.class, null }; if( ReflectionUtil.isClassAvailable(newtFactoryClassName, cl) ) { classesFromJavaJars[2] = ReflectionUtil.getClass(newtFactoryClassName, false, cl); } - JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all", new String[] { "-noawt", "-mobile", "-core" } ); + JNILibLoaderBase.addNativeJarLibsJoglCfg(classesFromJavaJars); } initProfilesForDefaultDevices(); return null; @@ -170,7 +166,7 @@ public class GLProfile { } } } - + /** * Trigger eager initialization of GLProfiles for the given device, * in case it isn't done yet. diff --git a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java index 6c15f9a2b..1a106b1b9 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java @@ -36,21 +36,17 @@ import com.jogamp.common.jvm.JNILibLoaderBase; import com.jogamp.common.os.Platform; import com.jogamp.common.util.cache.TempJarCache; -public class NWJNILibLoader extends JNILibLoaderBase { - - public static boolean loadNativeWindow(final String ossuffix) { - return AccessController.doPrivileged(new PrivilegedAction() { - public Boolean run() { - Platform.initSingleton(); - final String libName = "nativewindow_"+ossuffix ; - if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) { - // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-.jar - // or: nativewindow-core.jar -> nativewindow-natives-.jar - addNativeJarLibs(new Class[] { NWJNILibLoader.class }, "-all", new String[] { "-noawt", "-mobile", "-core" } ); - } - return new Boolean(loadLibrary(libName, false, NWJNILibLoader.class.getClassLoader())); - } - }).booleanValue(); - } - +public class NWJNILibLoader extends JNILibLoaderBase { + public static boolean loadNativeWindow(final String ossuffix) { + return AccessController.doPrivileged(new PrivilegedAction() { + public Boolean run() { + Platform.initSingleton(); + final String libName = "nativewindow_"+ossuffix ; + if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) { + JNILibLoaderBase.addNativeJarLibsJoglCfg(new Class[] { NWJNILibLoader.class }); + } + return Boolean.valueOf(loadLibrary(libName, false, NWJNILibLoader.class.getClassLoader())); + } + }).booleanValue(); + } } diff --git a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java index bc0eb7531..bc12bf3ee 100644 --- a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java +++ b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java @@ -48,23 +48,17 @@ import com.jogamp.common.jvm.JNILibLoaderBase; import com.jogamp.common.os.Platform; import com.jogamp.common.util.cache.TempJarCache; -public class NEWTJNILibLoader extends JNILibLoaderBase { - - public static void loadNEWT() { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - Platform.initSingleton(); - final String libName = "newt"; - if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) { - // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-.jar - // or: nativewindow-core.jar -> nativewindow-natives-.jar, - // newt-core.jar -> newt-natives-.jar - JNILibLoaderBase.addNativeJarLibs(new Class[] { NWJNILibLoader.class, NEWTJNILibLoader.class }, "-all", new String[] { "-noawt", "-mobile", "-core" } ); - } - loadLibrary(libName, false, NEWTJNILibLoader.class.getClassLoader()); - return null; - } - }); - } - +public class NEWTJNILibLoader extends JNILibLoaderBase { + public static boolean loadNEWT() { + return AccessController.doPrivileged(new PrivilegedAction() { + public Boolean run() { + Platform.initSingleton(); + final String libName = "newt"; + if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) { + JNILibLoaderBase.addNativeJarLibsJoglCfg(new Class[] { NWJNILibLoader.class, NEWTJNILibLoader.class }); + } + return Boolean.valueOf(loadLibrary(libName, false, NEWTJNILibLoader.class.getClassLoader())); + } + }).booleanValue(); + } } -- cgit v1.2.3 From fb6440fb6e4fac31d03799d5cf804d02c78f2c38 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 8 Sep 2013 19:26:20 +0200 Subject: NewtCanvasAWT: Implement AWTPrintLifecycle and hence support for AWT printing. Note: Same bug existing as w/ GLCanvas, i.e. 'GLDrawableUtil.swapGLContextAndAllGLEventListener(gladPre, gladNew)': If 'gladPre' is onscreen and using MSAA (on NV/GLX), the ctx cannot be made current in it's new 'gladNew' location. Same workaround applied, i.e. use onscreen drawable while printing. --- make/scripts/tests.sh | 5 +- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 166 +++++++++++++- .../jogl/tile/TestTiledPrintingGearsNewtAWT.java | 241 +++++++++++++++++++++ 3 files changed, 408 insertions(+), 4 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2b7a2563e..a23ea46d6 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -329,8 +329,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index e4b5a25c4..2127c4096 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -32,9 +32,12 @@ package com.jogamp.newt.awt; import java.awt.AWTKeyStroke; import java.awt.Canvas; import java.awt.Component; +import java.awt.EventQueue; import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.KeyboardFocusManager; +import java.awt.RenderingHints; import java.beans.Beans; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -46,6 +49,12 @@ import java.util.Set; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.OffscreenLayerOption; import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.AWTPrintLifecycle; import javax.swing.MenuSelectionManager; import jogamp.nativewindow.awt.AWTMisc; @@ -54,6 +63,7 @@ import jogamp.newt.WindowImpl; import jogamp.newt.awt.NewtFactoryAWT; import jogamp.newt.awt.event.AWTParentWindowAdapter; import jogamp.newt.driver.DriverClearFocus; +import jogamp.opengl.awt.AWTTilePainter; import com.jogamp.common.os.Platform; import com.jogamp.common.util.awt.AWTEDTExecutor; @@ -69,6 +79,8 @@ import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.awt.AWTAdapter; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTMouseAdapter; +import com.jogamp.opengl.util.GLDrawableUtil; +import com.jogamp.opengl.util.TileRenderer; /** * AWT {@link java.awt.Canvas Canvas} containing a NEWT {@link Window} using native parenting. @@ -80,7 +92,7 @@ import com.jogamp.newt.event.awt.AWTMouseAdapter; * the underlying JAWT mechanism to composite the image, if supported. */ @SuppressWarnings("serial") -public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol, OffscreenLayerOption { +public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol, OffscreenLayerOption, AWTPrintLifecycle { public static final boolean DEBUG = Debug.debug("Window"); private JAWTWindow jawtWindow = null; @@ -419,7 +431,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public void paint(Graphics g) { - if( validateComponent(true) ) { + if( validateComponent(true) && !printActive ) { newtChild.windowRepaint(0, 0, getWidth(), getHeight()); } } @@ -441,7 +453,155 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } } + + private static final int PRINT_TILE_SIZE = 512; + private volatile boolean printActive = false; + private boolean printUseAA = false; + private GLAnimatorControl printAnimator = null; + private GLAutoDrawable printGLAD = null; + private AWTTilePainter printAWTTiles = null; + + @Override + public void setupPrint(Graphics2D g2d, double scaleMatX, double scaleMatY) { + if( !validateComponent(true) ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); + } + return; // not yet available .. + } + if( !isVisible() ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); + } + return; // not yet available .. + } + printActive = true; + final RenderingHints rHints = g2d.getRenderingHints(); + { + final Object _useAA = rHints.get(RenderingHints.KEY_ANTIALIASING); + printUseAA = null != _useAA && ( _useAA == RenderingHints.VALUE_ANTIALIAS_DEFAULT || _useAA == RenderingHints.VALUE_ANTIALIAS_ON ); + } + if( DEBUG ) { + System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", useAA "+printUseAA+", printAnimator "+printAnimator); + AWTTilePainter.dumpHintsAndScale(g2d); + } + final int componentCount = isOpaque() ? 3 : 4; + final TileRenderer printRenderer = new TileRenderer(); + printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); + AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); + } + private final Runnable setupPrintOnEDT = new Runnable() { + @Override + public void run() { + final GLAutoDrawable glad; + if( null != newtChild && newtChild instanceof GLAutoDrawable ) { + glad = (GLAutoDrawable)newtChild; + } else { + if( DEBUG ) { + System.err.println("AWT print.setup exit, newtChild not a GLAutoDrawable: "+newtChild); + } + printAWTTiles = null; + printActive = false; + return; + } + printAnimator = glad.getAnimator(); + if( null != printAnimator ) { + printAnimator.remove(glad); + } + final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); + final GLProfile glp = caps.getGLProfile(); + if( caps.getSampleBuffers() ) { + // bug / issue w/ swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX + printGLAD = glad; + } else { + caps.setDoubleBuffered(false); + caps.setOnscreen(false); + if( printUseAA && !caps.getSampleBuffers() ) { + if ( !glp.isGL2ES3() ) { + if( DEBUG ) { + System.err.println("Ignore MSAA due to gl-profile < GL2ES3"); + } + printUseAA = false; + } else { + caps.setSampleBuffers(true); + caps.setNumSamples(8); + } + } + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, PRINT_TILE_SIZE, PRINT_TILE_SIZE, null); + GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); + } + + printAWTTiles.renderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); + printAWTTiles.renderer.attachToAutoDrawable(printGLAD); + if( DEBUG ) { + System.err.println("AWT print.setup "+printAWTTiles); + System.err.println("AWT print.setup AA "+printUseAA+", "+caps); + System.err.println("AWT print.setup "+printGLAD); + } + } + }; + + @Override + public void releasePrint() { + if( !printActive || null == printGLAD ) { + throw new IllegalStateException("setupPrint() not called"); + } + // sendReshape = false; // clear reshape flag + AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, releasePrintOnEDT); + newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener + } + private final Runnable releasePrintOnEDT = new Runnable() { + @Override + public void run() { + if( DEBUG ) { + System.err.println("AWT print.release "+printAWTTiles); + } + final GLAutoDrawable glad = (GLAutoDrawable)newtChild; + printAWTTiles.dispose(); + printAWTTiles= null; + if( printGLAD != glad ) { + GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, glad); + printGLAD.destroy(); + } + printGLAD = null; + if( null != printAnimator ) { + printAnimator.add(glad); + printAnimator = null; + } + printActive = false; + } + }; + + @Override + public void print(Graphics graphics) { + if( !printActive || null == printGLAD ) { + throw new IllegalStateException("setupPrint() not called"); + } + if(DEBUG && !EventQueue.isDispatchThread()) { + System.err.println(getThreadName()+": Warning: GLCanvas print - not called from AWT-EDT"); + // we cannot dispatch print on AWT-EDT due to printing internal locking .. + } + + final Graphics2D g2d = (Graphics2D)graphics; + printAWTTiles.setupGraphics2DAndClipBounds(g2d); + try { + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); + } + do { + tileRenderer.display(); + } while ( !tileRenderer.eot() ); + } finally { + printAWTTiles.resetGraphics2D(); + } + if( DEBUG ) { + System.err.println("AWT print.X: "+printAWTTiles); + } + } + private final void requestFocusNEWTChild() { if(null!=newtChild) { newtChild.setFocusAction(null); @@ -685,6 +845,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } } + + protected static String getThreadName() { return Thread.currentThread().getName(); } static String newtWinHandleToHexString(Window w) { return null != w ? toHexString(w.getWindowHandle()) : "nil"; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java new file mode 100644 index 000000000..820b62743 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java @@ -0,0 +1,241 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.tile; + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.print.PageFormat; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.event.TraceKeyAdapter; +import com.jogamp.newt.event.TraceWindowAdapter; +import com.jogamp.newt.event.awt.AWTKeyAdapter; +import com.jogamp.newt.event.awt.AWTWindowAdapter; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.util.Animator; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { + + static boolean waitForKey = false; + /** only when run manually .. */ + static boolean allow600dpi = false; + static GLProfile glp; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2)) { + glp = GLProfile.get(GLProfile.GL2); + Assert.assertNotNull(glp); + width = 640; + height = 480; + } else { + setTestSupported(false); + } + // Runtime.getRuntime().traceInstructions(true); + // Runtime.getRuntime().traceMethodCalls(true); + } + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL(GLCapabilities caps) throws InterruptedException, InvocationTargetException { + final GLWindow glad = GLWindow.create(caps); + Assert.assertNotNull(glad); + + final NewtCanvasAWT canvas = new NewtCanvasAWT(glad); + Assert.assertNotNull(canvas); + Dimension glc_sz = new Dimension(width, height); + canvas.setMinimumSize(glc_sz); + canvas.setPreferredSize(glc_sz); + canvas.setSize(glc_sz); + + final Gears gears = new Gears(); + glad.addGLEventListener(gears); + + final Frame frame = new Frame("Newt/AWT Print"); + Assert.assertNotNull(frame); + + final ActionListener print72DPIAction = new ActionListener() { + public void actionPerformed(ActionEvent e) { + doPrintManual(frame, 72, false); + } }; + final ActionListener print300DPIAction = new ActionListener() { + public void actionPerformed(ActionEvent e) { + doPrintManual(frame, 300, false); + } }; + final ActionListener print600DPIAction = new ActionListener() { + public void actionPerformed(ActionEvent e) { + doPrintManual(frame, 600, false); + } }; + final Button print72DPIButton = new Button("72dpi"); + print72DPIButton.addActionListener(print72DPIAction); + final Button print300DPIButton = new Button("300dpi"); + print300DPIButton.addActionListener(print300DPIAction); + final Button print600DPIButton = new Button("600dpi"); + print600DPIButton.addActionListener(print600DPIAction); + + frame.setLayout(new BorderLayout()); + Panel printPanel = new Panel(); + printPanel.add(print72DPIButton); + printPanel.add(print300DPIButton); + printPanel.add(print600DPIButton); + Panel southPanel = new Panel(); + southPanel.add(new Label("South")); + Panel eastPanel = new Panel(); + eastPanel.add(new Label("East")); + Panel westPanel = new Panel(); + westPanel.add(new Label("West")); + frame.add(printPanel, BorderLayout.NORTH); + frame.add(canvas, BorderLayout.CENTER); + frame.add(southPanel, BorderLayout.SOUTH); + frame.add(eastPanel, BorderLayout.EAST); + frame.add(westPanel, BorderLayout.WEST); + frame.setTitle("Tiles Newt/AWT Print Test"); + + Animator animator = new Animator(glad); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(canvas); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(canvas, true)); + + animator.setUpdateFPSFrames(60, System.err); + animator.start(); + + boolean printDone = false; + while(!quitAdapter.shouldQuit() && animator.isAnimating() && ( 0 == duration || animator.getTotalFPSDuration() Date: Sun, 8 Sep 2013 19:51:21 +0200 Subject: AWTPrintLifecycle: Add DEFAULT_PRINT_TILE_SIZE (512); Remove unused imports. --- src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java | 3 +++ src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 7 +------ src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 7 +------ src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 3 +-- 4 files changed, 6 insertions(+), 14 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java b/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java index 301e18722..1a4c5bac0 100644 --- a/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java +++ b/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java @@ -70,6 +70,9 @@ import jogamp.nativewindow.awt.AWTMisc; */ public interface AWTPrintLifecycle { + public static final int DEFAULT_PRINT_TILE_SIZE = 512; + + /** * Shall be called before {@link Component#print(Graphics)}. *

    diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 8745a8d24..047c94b58 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -54,16 +54,12 @@ import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.awt.EventQueue; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; -import java.util.Map.Entry; -import java.util.Set; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.OffscreenLayerOption; @@ -728,7 +724,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing paint(g); } - private static final int PRINT_TILE_SIZE = 512; private volatile boolean printActive = false; private boolean printUseAA = false; private GLAnimatorControl printAnimator = null; @@ -793,7 +788,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, PRINT_TILE_SIZE, PRINT_TILE_SIZE, null); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 44586d45b..c97d1e24f 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -49,16 +49,12 @@ import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.beans.Beans; import java.nio.IntBuffer; -import java.util.Iterator; import java.util.List; -import java.util.Set; -import java.util.Map.Entry; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; @@ -501,7 +497,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } - private static final int PRINT_TILE_SIZE = 512; private volatile boolean printActive = false; private boolean printUseAA = false; private GLAnimatorControl printAnimator = null; @@ -565,7 +560,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing caps.setSampleBuffers(true); caps.setNumSamples(8); final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, PRINT_TILE_SIZE, PRINT_TILE_SIZE, null); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); } } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 2127c4096..02bc17c79 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -454,7 +454,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } - private static final int PRINT_TILE_SIZE = 512; private volatile boolean printActive = false; private boolean printUseAA = false; private GLAnimatorControl printAnimator = null; @@ -528,7 +527,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, PRINT_TILE_SIZE, PRINT_TILE_SIZE, null); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); } -- cgit v1.2.3 From 597ca0edc8ba536e82494b56bd1bbd6f8290efa6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 10 Sep 2013 23:06:38 +0200 Subject: AWT Printing: AWTTilePainter needs to handle null clip! --- src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 2 +- src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 2 +- src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java | 16 ++++++++++------ src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 047c94b58..23898ba8c 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -845,7 +845,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing sendReshape = false; // clear reshape flag final Graphics2D g2d = (Graphics2D)graphics; - printAWTTiles.setupGraphics2DAndClipBounds(g2d); + printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); try { final TileRenderer tileRenderer = printAWTTiles.renderer; if( DEBUG ) { diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index c97d1e24f..84e3c39b4 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -620,7 +620,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing handleReshape = false; // ditto final Graphics2D g2d = (Graphics2D)graphics; - printAWTTiles.setupGraphics2DAndClipBounds(g2d); + printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); try { final TileRenderer tileRenderer = printAWTTiles.renderer; if( DEBUG ) { diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index 9aa6f3395..d316a6523 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -119,15 +119,17 @@ public class AWTTilePainter { * and {@link TileRenderer#setTileOffset(int, int) tile offset} according the * the {@link Graphics2D#getClipBounds() graphics clip bounds}. *

    - * @param g2d + * @param g2d Graphics2D instance used for transform and clipping + * @param width width of the AWT component in case clipping is null + * @param height height of the AWT component in case clipping is null */ - public void setupGraphics2DAndClipBounds(Graphics2D g2d) { + public void setupGraphics2DAndClipBounds(Graphics2D g2d, int width, int height) { this.g2d = g2d; saveAT = g2d.getTransform(); g2d.scale(scaleMatX, scaleMatY); final Rectangle gClipOrig = g2d.getClipBounds(); - final Rectangle gClip = new Rectangle(gClipOrig); + final Rectangle gClip = null == gClipOrig ? new Rectangle(0, 0, width, height) : new Rectangle(gClipOrig); if( 0 > gClip.x ) { gClip.width += gClip.x; gClip.x = 0; @@ -237,9 +239,11 @@ public class AWTTilePainter { System.err.println("XXX tile-post.X clip "+oClip+" -> "+g2d.getClip()); g2d.setColor(Color.BLACK); g2d.drawRect(pX, pYf, tWidth, tHeight); - final Rectangle r = oClip.getBounds(); - g2d.setColor(Color.YELLOW); - g2d.drawRect(r.x, r.y, r.width, r.height); + if( null != oClip ) { + final Rectangle r = oClip.getBounds(); + g2d.setColor(Color.YELLOW); + g2d.drawRect(r.x, r.y, r.width, r.height); + } System.err.println("XXX tile-post.X "+renderer); System.err.println("XXX tile-post.X dst-img "+dstImage.getWidth()+"x"+dstImage.getHeight()+" -> "+pX+"/"+pYf); } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 02bc17c79..87ec5e9c1 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -584,7 +584,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } final Graphics2D g2d = (Graphics2D)graphics; - printAWTTiles.setupGraphics2DAndClipBounds(g2d); + printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); try { final TileRenderer tileRenderer = printAWTTiles.renderer; if( DEBUG ) { -- cgit v1.2.3 From 52f348c1a58e12c16bea87cf6951be344b8663ed Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 13 Sep 2013 19:47:12 +0200 Subject: AWTTilePainter: Fix null clip-rect (consider scaling); Fix non GL-oriented drawable, skip vertical flip and use 1:1 y-coord. --- .../classes/javax/media/opengl/awt/GLCanvas.java | 2 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 1 + .../classes/jogamp/opengl/awt/AWTTilePainter.java | 86 ++++++++++++++-------- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 2 +- 4 files changed, 58 insertions(+), 33 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 23898ba8c..4e0fdba5d 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -791,7 +791,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); } - + printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); printAWTTiles.renderer.attachToAutoDrawable(printGLAD); if( DEBUG ) { diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 84e3c39b4..02f4e54a7 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -564,6 +564,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); } } + printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); printAWTTiles.renderer.attachToAutoDrawable(printGLAD); if( DEBUG ) { diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index d316a6523..0ff733457 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -61,6 +61,7 @@ public class AWTTilePainter { public final double scaleMatX, scaleMatY; public final boolean verbose; + public boolean flipVertical; private AWTGLPixelBuffer tBuffer = null; private BufferedImage vFlipImage = null; private Graphics2D g2d = null; @@ -102,11 +103,16 @@ public class AWTTilePainter { this.scaleMatX = scaleMatX; this.scaleMatY = scaleMatY; this.verbose = verbose; + this.flipVertical = true; this.renderer.setRowOrder(TileRenderer.TR_TOP_TO_BOTTOM); } public String toString() { return renderer.toString(); } + public void setIsGLOriented(boolean v) { + flipVertical = v; + } + /** * Caches the {@link Graphics2D} instance for rendering. *

    @@ -126,23 +132,30 @@ public class AWTTilePainter { public void setupGraphics2DAndClipBounds(Graphics2D g2d, int width, int height) { this.g2d = g2d; saveAT = g2d.getTransform(); + final Rectangle gClipOrig = g2d.getClipBounds(); + if( null == gClipOrig ) { + g2d.setClip(0, 0, width, height); + } g2d.scale(scaleMatX, scaleMatY); - final Rectangle gClipOrig = g2d.getClipBounds(); - final Rectangle gClip = null == gClipOrig ? new Rectangle(0, 0, width, height) : new Rectangle(gClipOrig); - if( 0 > gClip.x ) { - gClip.width += gClip.x; - gClip.x = 0; + final Rectangle gClipScaled = g2d.getClipBounds(); + if( 0 > gClipScaled.x ) { + gClipScaled.width += gClipScaled.x; + gClipScaled.x = 0; } - if( 0 > gClip.y ) { - gClip.height += gClip.y; - gClip.y = 0; + if( 0 > gClipScaled.y ) { + gClipScaled.height += gClipScaled.y; + gClipScaled.y = 0; } if( verbose ) { - System.err.println("AWT print.0: "+gClipOrig+" -> "+gClip); + System.err.println("AWT print.0: "+gClipOrig+" -> "+gClipScaled); + } + renderer.setImageSize(gClipScaled.width, gClipScaled.height); + renderer.setTileOffset(gClipScaled.x, gClipScaled.y); + if( null == gClipOrig ) { + // reset + g2d.setClip(null); } - renderer.setImageSize(gClip.width, gClip.height); - renderer.setTileOffset(gClip.x, gClip.y); } /** See {@ #setupGraphics2DAndClipBounds(Graphics2D)}. */ @@ -169,8 +182,7 @@ public class AWTTilePainter { final GLEventListener preTileGLEL = new GLEventListener() { @Override - public void init(GLAutoDrawable drawable) { - } + public void init(GLAutoDrawable drawable) {} @Override public void dispose(GLAutoDrawable drawable) {} @Override @@ -183,7 +195,11 @@ public class AWTTilePainter { final GLPixelAttributes pixelAttribs = printBufferProvider.getAttributes(gl, componentCount); tBuffer = printBufferProvider.allocate(gl, pixelAttribs, tWidth, tHeight, 1, true, 0); renderer.setTileBuffer(tBuffer); - vFlipImage = new BufferedImage(tBuffer.width, tBuffer.height, tBuffer.image.getType()); + if( flipVertical ) { + vFlipImage = new BufferedImage(tBuffer.width, tBuffer.height, tBuffer.image.getType()); + } else { + vFlipImage = null; + } } if( verbose ) { System.err.println("XXX tile-pre "+renderer); @@ -208,29 +224,37 @@ public class AWTTilePainter { // but that's the software rendering path which is very slow anyway. final int tWidth = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH); final int tHeight = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT); - // final BufferedImage dstImage = printBuffer.image; - final BufferedImage srcImage = tBuffer.image; - final BufferedImage dstImage = vFlipImage; - final int[] src = ((DataBufferInt) srcImage.getRaster().getDataBuffer()).getData(); - final int[] dst = ((DataBufferInt) dstImage.getRaster().getDataBuffer()).getData(); - final int incr = tBuffer.width; - int srcPos = 0; - int destPos = (tHeight - 1) * tBuffer.width; - for (; destPos >= 0; srcPos += incr, destPos -= incr) { - System.arraycopy(src, srcPos, dst, destPos, incr); + final BufferedImage dstImage; + if( flipVertical ) { + final BufferedImage srcImage = tBuffer.image; + dstImage = vFlipImage; + final int[] src = ((DataBufferInt) srcImage.getRaster().getDataBuffer()).getData(); + final int[] dst = ((DataBufferInt) dstImage.getRaster().getDataBuffer()).getData(); + final int incr = tBuffer.width; + int srcPos = 0; + int destPos = (tHeight - 1) * tBuffer.width; + for (; destPos >= 0; srcPos += incr, destPos -= incr) { + System.arraycopy(src, srcPos, dst, destPos, incr); + } + } else { + dstImage = tBuffer.image; } // Draw resulting image in one shot final int tRows = renderer.getParam(TileRenderer.TR_ROWS); final int tRow = renderer.getParam(TileRenderer.TR_CURRENT_ROW); final int pX = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); final int pYf; - if( tRow == tRows - 1 ) { - tTopRowHeight = tHeight; - pYf = 0; - } else if( tRow == tRows - 2 ){ - pYf = tTopRowHeight; + if( flipVertical ) { + if( tRow == tRows - 1 ) { + tTopRowHeight = tHeight; + pYf = 0; + } else if( tRow == tRows - 2 ){ + pYf = tTopRowHeight; + } else { + pYf = ( tRows - 2 - tRow ) * tHeight + tTopRowHeight; + } } else { - pYf = ( tRows - 2 - tRow ) * tHeight + tTopRowHeight; + pYf = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); } final Shape oClip = g2d.getClip(); g2d.clipRect(pX, pYf, tWidth, tHeight); @@ -245,7 +269,7 @@ public class AWTTilePainter { g2d.drawRect(r.x, r.y, r.width, r.height); } System.err.println("XXX tile-post.X "+renderer); - System.err.println("XXX tile-post.X dst-img "+dstImage.getWidth()+"x"+dstImage.getHeight()+" -> "+pX+"/"+pYf); + System.err.println("XXX tile-post.X dst-img "+dstImage.getWidth()+"x"+dstImage.getHeight()+", y-flip "+flipVertical+" -> "+pX+"/"+pYf); } g2d.setClip(oClip); } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 87ec5e9c1..cdf47cbb3 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -530,7 +530,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); } - + printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); printAWTTiles.renderer.attachToAutoDrawable(printGLAD); if( DEBUG ) { -- cgit v1.2.3 From c2ce31e11eefcf1b900c0e9b41264f5d5566dc46 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 15 Sep 2013 23:27:16 +0200 Subject: Fix AWT printing issues w/ overlapping and/or non-opaque contents ; Change AWTPrintLifecycle's lifecycle - AWTPrintLifecycle: - Should decorate: PrinterJob.print(..), instead of within Printable.print(..) { .. container.printAll(..); .. } This is due to AWT print implementation, i.e. AWT will issue Printable.print(..) multiple times for 'overlapping' or non-opaque elements! - Move from javax.media.opengl.awt -> com.jogamp.nativewindow.awt - Make _interface_ AWT agnostic, i.e. remove Graphics2D from 'setup(..)' - Add 'int numSamples' to 'setup(..)' to determine the number of samples - AWTTilePrinter: - Use double precision when scaling image-size and clip-rect, then round them to integer values. Otherwise AWT will use the bounding box for the clipping-rectangular. - Clip negative portion of clip-rect, this removes redundant overpaints, as well as increasing the tile count due to the increased clipping-size. - Clip the image-size in the tile-renderer according to the clip-rect. - DEBUG_TILES: Dump tiles to file - Use sub-image of final BuffereImage instead of adding another clipping region. This might increase performance if no clip-rect has been set. TODO: TestTiledPrintingGearsSwingAWT overlapping tests exposes a 'off by one' bug of the first layer's background! Note: The GL content seems to be correct though - maybe it's simply an AWT rounding error .. --- .../javax/media/opengl/awt/AWTPrintLifecycle.java | 162 ------------------ .../classes/javax/media/opengl/awt/GLCanvas.java | 33 ++-- .../classes/javax/media/opengl/awt/GLJPanel.java | 47 ++--- .../classes/jogamp/opengl/awt/AWTTilePainter.java | 189 ++++++++++++++++----- .../jogamp/nativewindow/awt/AWTPrintLifecycle.java | 168 ++++++++++++++++++ .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 63 +++---- .../junit/jogl/tile/TestTiledPrintingGearsAWT.java | 14 +- .../jogl/tile/TestTiledPrintingGearsNewtAWT.java | 14 +- .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 73 ++++++-- .../test/junit/jogl/tile/TiledPrintingAWTBase.java | 123 ++++++++------ 10 files changed, 501 insertions(+), 385 deletions(-) delete mode 100644 src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java create mode 100644 src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java b/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java deleted file mode 100644 index 1a4c5bac0..000000000 --- a/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java +++ /dev/null @@ -1,162 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package javax.media.opengl.awt; - -import javax.media.opengl.GLAutoDrawable; -import java.awt.Component; -import java.awt.Container; -import java.awt.Graphics; -import java.awt.Graphics2D; - -import jogamp.nativewindow.awt.AWTMisc; - -/** - * Interface describing print lifecycle to support AWT printing - * on AWT {@link GLAutoDrawable}s. - *

    Implementations
    - *

    - * Implementing {@link GLAutoDrawable} classes based on AWT - * supporting {@link Component#print(Graphics)} shall implement this interface. - *

    - *
    Usage
    - *

    - * Users attempting to print an AWT {@link Container} containing {@link AWTPrintLifecycle} elements - * shall consider decorating the {@link Container#printAll(Graphics)} call with
    - * {@link #setupPrint(Graphics2D, double, double) setupPrint(..)} and {@link #releasePrint()} - * on all {@link AWTPrintLifecycle} elements in the {@link Container}.
    - * To minimize this burden, a user can use {@link Context#setupPrint(Container, Graphics2D, double, double) Context.setupPrint(..)}: - *

    - *  Graphics2D g2d;
    - *  Frame frame;
    - *  double scaleGLMatXY = 72.0/glDPI;
    - *  ...
    -    final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, g2d, scaleGLMatXY, scaleGLMatXY);
    -    try {
    -       AWTEDTExecutor.singleton.invoke(true, new Runnable() {
    -            public void run() {
    -                frame.printAll(g2d);
    -           } });
    -    } finally {
    -       ctx.releasePrint();
    -    }
    - * 
    - * 
    - *

    - */ -public interface AWTPrintLifecycle { - - public static final int DEFAULT_PRINT_TILE_SIZE = 512; - - - /** - * Shall be called before {@link Component#print(Graphics)}. - *

    - * See Usage. - *

    - * @param g2d the {@link Graphics2D} instance, which will be used for printing. - * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels - * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels - */ - void setupPrint(Graphics2D g2d, double scaleMatX, double scaleMatY); - - /** - * Shall be called after very last {@link Component#print(Graphics)}. - *

    - * See Usage. - *

    - */ - void releasePrint(); - - /** - * Convenient {@link AWTPrintLifecycle} context simplifying calling {@link AWTPrintLifecycle#setupPrint(Graphics2D, double, double) setupPrint(..)} - * and {@link AWTPrintLifecycle#releasePrint()} on all {@link AWTPrintLifecycle} elements of a {@link Container}. - *

    - * See Usage. - *

    - */ - public static class Context { - /** - *

    - * See Usage. - *

    - * - * @param c container to be traversed through to perform {@link AWTPrintLifecycle#setupPrint(Graphics2D, double, double) setupPrint(..)} on all {@link AWTPrintLifecycle} elements. - * @param g2d the {@link Graphics2D} instance, which will be used for printing. - * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels - * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels - * @return the context - */ - public static Context setupPrint(Container c, Graphics2D g2d, double scaleMatX, double scaleMatY) { - final Context t = new Context(c, g2d, scaleMatX, scaleMatY); - t.setupPrint(c); - return t; - } - - /** - *

    - * See Usage. - *

    - */ - public void releasePrint() { - count = AWTMisc.performAction(cont, AWTPrintLifecycle.class, releaseAction); - } - - /** - * @return count of performed actions of last {@link #setupPrint(Container, Graphics2D, double, double) setupPrint(..)} or {@link #releasePrint()}. - */ - public int getCount() { return count; } - - private final Container cont; - private final Graphics2D g2d; - private final double scaleMatX; - private final double scaleMatY; - private int count; - - private final AWTMisc.ComponentAction setupAction = new AWTMisc.ComponentAction() { - @Override - public void run(Component c) { - ((AWTPrintLifecycle)c).setupPrint(g2d, scaleMatX, scaleMatY); - } }; - private final AWTMisc.ComponentAction releaseAction = new AWTMisc.ComponentAction() { - @Override - public void run(Component c) { - ((AWTPrintLifecycle)c).releasePrint(); - } }; - - private Context(Container c, Graphics2D g2d, double scaleMatX, double scaleMatY) { - this.cont = c; - this.g2d = g2d; - this.scaleMatX = scaleMatX; - this.scaleMatY = scaleMatY; - this.count = 0; - } - private void setupPrint(Container c) { - count = AWTMisc.performAction(c, AWTPrintLifecycle.class, setupAction); - } - } -} diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 4e0fdba5d..a519e33bb 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -53,7 +53,6 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; -import java.awt.RenderingHints; import java.awt.geom.Rectangle2D; import java.awt.EventQueue; @@ -94,6 +93,7 @@ import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.nativewindow.awt.AWTPrintLifecycle; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.opengl.JoglVersion; @@ -725,13 +725,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } private volatile boolean printActive = false; - private boolean printUseAA = false; + private int printNumSamples = 0; private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @Override - public void setupPrint(Graphics2D g2d, double scaleMatX, double scaleMatY) { + public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) { if( !validateGLDrawable() ) { if(DEBUG) { System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable not valid yet"); @@ -746,14 +746,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } printActive = true; sendReshape = false; // clear reshape flag - final RenderingHints rHints = g2d.getRenderingHints(); - { - final Object _useAA = rHints.get(RenderingHints.KEY_ANTIALIASING); - printUseAA = null != _useAA && ( _useAA == RenderingHints.VALUE_ANTIALIAS_DEFAULT || _useAA == RenderingHints.VALUE_ANTIALIAS_ON ); - } + printNumSamples = AWTTilePainter.getNumSamples(numSamples, getChosenGLCapabilities()); if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", useAA "+printUseAA+", printAnimator "+printAnimator); - AWTTilePainter.dumpHintsAndScale(g2d); + System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", numSamples "+numSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); @@ -769,23 +764,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printAnimator.remove(GLCanvas.this); } final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); - final GLProfile glp = caps.getGLProfile(); if( caps.getSampleBuffers() ) { - // bug / issue w/ swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX + // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX printGLAD = GLCanvas.this; } else { caps.setDoubleBuffered(false); caps.setOnscreen(false); - if( printUseAA && !caps.getSampleBuffers() ) { - if ( !glp.isGL2ES3() ) { - if( DEBUG ) { - System.err.println("Ignore MSAA due to gl-profile < GL2ES3"); - } - printUseAA = false; - } else { - caps.setSampleBuffers(true); - caps.setNumSamples(8); - } + if( printNumSamples != caps.getNumSamples() ) { + caps.setSampleBuffers(0 < printNumSamples); + caps.setNumSamples(printNumSamples); } final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); @@ -796,7 +783,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printAWTTiles.renderer.attachToAutoDrawable(printGLAD); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); - System.err.println("AWT print.setup AA "+printUseAA+", "+caps); + System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); System.err.println("AWT print.setup "+printGLAD); } } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 02f4e54a7..f0c6b7beb 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -48,7 +48,6 @@ import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; -import java.awt.RenderingHints; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; @@ -90,6 +89,7 @@ import jogamp.opengl.awt.Java2D; import jogamp.opengl.util.glsl.GLSLTextureRaster; import com.jogamp.common.util.awt.AWTEDTExecutor; +import com.jogamp.nativewindow.awt.AWTPrintLifecycle; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; @@ -424,7 +424,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing createAndInitializeBackend(); } - if (!isInitialized) { + if (!isInitialized || printActive) { return; } @@ -498,13 +498,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } private volatile boolean printActive = false; - private boolean printUseAA = false; + private int printNumSamples = 0; private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @Override - public void setupPrint(Graphics2D g2d, double scaleMatX, double scaleMatY) { + public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) { if (!isInitialized) { if(DEBUG) { System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable not valid yet"); @@ -520,14 +520,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printActive = true; sendReshape = false; // clear reshape flag handleReshape = false; // ditto - final RenderingHints rHints = g2d.getRenderingHints(); - { - final Object _useAA = rHints.get(RenderingHints.KEY_ANTIALIASING); - printUseAA = null != _useAA && ( _useAA == RenderingHints.VALUE_ANTIALIAS_DEFAULT || _useAA == RenderingHints.VALUE_ANTIALIAS_ON ); - } + printNumSamples = AWTTilePainter.getNumSamples(numSamples, getChosenGLCapabilities()); if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", useAA "+printUseAA+", printAnimator "+printAnimator); - AWTTilePainter.dumpHintsAndScale(g2d); + System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", numSamples "+numSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); @@ -546,30 +541,21 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printGLAD = GLJPanel.this; // default: re-use final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); - final GLProfile glp = caps.getGLProfile(); - if( printUseAA && !caps.getSampleBuffers() ) { - if ( !glp.isGL2ES3() ) { - if( DEBUG ) { - System.err.println("Ignore MSAA due to gl-profile < GL2ES3"); - } - printUseAA = false; - } else { - // MSAA FBO .. - caps.setDoubleBuffered(false); - caps.setOnscreen(false); - caps.setSampleBuffers(true); - caps.setNumSamples(8); - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); - GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); - } + if( printNumSamples != caps.getNumSamples() ) { + caps.setDoubleBuffered(false); + caps.setOnscreen(false); + caps.setSampleBuffers(0 < printNumSamples); + caps.setNumSamples(printNumSamples); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); + GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); } printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); printAWTTiles.renderer.attachToAutoDrawable(printGLAD); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); - System.err.println("AWT print.setup AA "+printUseAA+", "+caps); + System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); System.err.println("AWT print.setup "+printGLAD); } } @@ -624,9 +610,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); try { final TileRenderer tileRenderer = printAWTTiles.renderer; - if( DEBUG ) { - System.err.println("AWT print.0: "+tileRenderer); - } do { if( printGLAD != GLJPanel.this ) { tileRenderer.display(); diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index 0ff733457..b16273b35 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -33,16 +33,25 @@ import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; +import java.io.File; +import java.io.IOException; +import java.util.Arrays; import java.util.Iterator; import java.util.Set; import java.util.Map.Entry; +import javax.imageio.ImageIO; +import javax.media.nativewindow.util.DimensionImmutable; import javax.media.opengl.GL; import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLEventListener; +import jogamp.opengl.Debug; + import com.jogamp.opengl.util.TileRenderer; import com.jogamp.opengl.util.TileRendererBase; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; @@ -56,6 +65,8 @@ import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider; *

    */ public class AWTTilePainter { + private static final boolean DEBUG_TILES = Debug.debug("TileRenderer"); + public final TileRenderer renderer; public final int componentCount; public final double scaleMatX, scaleMatY; @@ -76,8 +87,28 @@ public class AWTTilePainter { System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); } final AffineTransform aTrans = g2d.getTransform(); + System.err.println(" type "+aTrans.getType()); System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); + System.err.println(" mat "+aTrans); + } + + /** + * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param caps used capabilties + * @return resulting number of samples, 0 if disabled + */ + public static int getNumSamples(int numSamples, GLCapabilitiesImmutable caps) { + if( 0 > numSamples ) { + return 0; + } else if( 0 < numSamples ) { + if ( !caps.getGLProfile().isGL2ES3() ) { + return 0; + } + return Math.max(caps.getNumSamples(), numSamples); + } else { + return caps.getNumSamples(); + } } /** @@ -104,7 +135,6 @@ public class AWTTilePainter { this.scaleMatY = scaleMatY; this.verbose = verbose; this.flipVertical = true; - this.renderer.setRowOrder(TileRenderer.TR_TOP_TO_BOTTOM); } public String toString() { return renderer.toString(); } @@ -113,6 +143,25 @@ public class AWTTilePainter { flipVertical = v; } + private static Rectangle getRoundedRect(Rectangle2D r) { + if( null == r ) { return null; } + return new Rectangle((int)Math.round(r.getX()), (int)Math.round(r.getY()), + (int)Math.round(r.getWidth()), (int)Math.round(r.getHeight())); + } + private static Rectangle clipNegative(Rectangle in) { + if( null == in ) { return null; } + final Rectangle out = new Rectangle(in); + if( 0 > out.x ) { + out.width += out.x; + out.x = 0; + } + if( 0 > out.y ) { + out.height += out.y; + out.y = 0; + } + return out; + } + /** * Caches the {@link Graphics2D} instance for rendering. *

    @@ -132,31 +181,49 @@ public class AWTTilePainter { public void setupGraphics2DAndClipBounds(Graphics2D g2d, int width, int height) { this.g2d = g2d; saveAT = g2d.getTransform(); - final Rectangle gClipOrig = g2d.getClipBounds(); - if( null == gClipOrig ) { - g2d.setClip(0, 0, width, height); + final Rectangle gClipOrigR; + final Rectangle2D dClipOrig, dImageSizeOrig; // double precision for scaling + // setup original rectangles + { + gClipOrigR = g2d.getClipBounds(); + final Rectangle gClipOrig = clipNegative(gClipOrigR); + dClipOrig = null != gClipOrig ? new Rectangle2D.Double(gClipOrig.getX(), gClipOrig.getY(), gClipOrig.getWidth(), gClipOrig.getHeight()) : null; + dImageSizeOrig = new Rectangle2D.Double(0, 0, width, height); } - g2d.scale(scaleMatX, scaleMatY); - - final Rectangle gClipScaled = g2d.getClipBounds(); - if( 0 > gClipScaled.x ) { - gClipScaled.width += gClipScaled.x; - gClipScaled.x = 0; + final Rectangle2D dClipScaled, dImageSizeScaled; // double precision for scaling + // retrieve scaled image-size and clip-bounds + { + g2d.setClip(dImageSizeOrig); + g2d.scale(scaleMatX, scaleMatY); + dImageSizeScaled = (Rectangle2D) g2d.getClip(); + if( null == dClipOrig ) { + g2d.setClip(null); + dClipScaled = (Rectangle2D) dImageSizeScaled.clone(); + } else { + g2d.setTransform(saveAT); // reset + g2d.setClip(dClipOrig); + g2d.scale(scaleMatX, scaleMatY); + dClipScaled = (Rectangle2D) g2d.getClip(); + } } - if( 0 > gClipScaled.y ) { - gClipScaled.height += gClipScaled.y; - gClipScaled.y = 0; + final Rectangle iClipScaled = getRoundedRect(dClipScaled); + final Rectangle iImageSizeScaled = getRoundedRect(dImageSizeScaled); + scaledYOffset = iClipScaled.y; + renderer.setImageSize(iImageSizeScaled.width, iImageSizeScaled.height); + renderer.clipImageSize(iClipScaled.width, iClipScaled.height); + final int clipH = Math.min(iImageSizeScaled.height, iClipScaled.height); + if( flipVertical ) { + renderer.setTileOffset(iClipScaled.x, iImageSizeScaled.height - ( iClipScaled.y + clipH )); + } else { + renderer.setTileOffset(iClipScaled.x, iClipScaled.y); } if( verbose ) { - System.err.println("AWT print.0: "+gClipOrig+" -> "+gClipScaled); - } - renderer.setImageSize(gClipScaled.width, gClipScaled.height); - renderer.setTileOffset(gClipScaled.x, gClipScaled.y); - if( null == gClipOrig ) { - // reset - g2d.setClip(null); + System.err.println("AWT print.0: image "+dImageSizeOrig + " -> " + dImageSizeScaled + " -> " + iImageSizeScaled); + System.err.println("AWT print.0: clip "+gClipOrigR + " -> " + dClipOrig + " -> " + dClipScaled + " -> " + iClipScaled); + System.err.println("AWT print.0: "+renderer); } } + private int scaledYOffset; /** See {@ #setupGraphics2DAndClipBounds(Graphics2D)}. */ public void resetGraphics2D() { @@ -208,28 +275,55 @@ public class AWTTilePainter { @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} }; + static int _counter = 0; final GLEventListener postTileGLEL = new GLEventListener() { - int tTopRowHeight = 0; @Override public void init(GLAutoDrawable drawable) { - tTopRowHeight = 0; } @Override public void dispose(GLAutoDrawable drawable) {} @Override public void display(GLAutoDrawable drawable) { + final DimensionImmutable cis = renderer.getClippedImageSize(); + final int tWidth = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH); + final int tHeight = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT); + final int pX = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); + final int pY = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); + final int pYOff = renderer.getParam(TileRenderer.TR_TILE_Y_OFFSET); + final int pYf; + if( flipVertical ) { + pYf = cis.getHeight() - ( pY - pYOff + tHeight ) + scaledYOffset; + } else { + pYf = pY; + } + // Copy temporary data into raster of BufferedImage for faster // blitting Note that we could avoid this copy in the cases // where !offscreenDrawable.isGLOriented(), // but that's the software rendering path which is very slow anyway. - final int tWidth = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH); - final int tHeight = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT); final BufferedImage dstImage; + if( DEBUG_TILES ) { + final String fname = String.format("file_%03d_0_tile_[%02d][%02d]_sz_%03dx%03d_pos0_%03d_%03d_yOff_%03d_pos1_%03d_%03d.png", + _counter, + renderer.getParam(TileRenderer.TR_CURRENT_COLUMN), renderer.getParam(TileRenderer.TR_CURRENT_ROW), + tWidth, tHeight, + pX, pY, pYOff, pX, pYf).replace(' ', '_'); + System.err.println("XXX file "+fname); + final File fout = new File(fname); + try { + ImageIO.write(tBuffer.image, "png", fout); + } catch (IOException e) { + e.printStackTrace(); + } + } if( flipVertical ) { final BufferedImage srcImage = tBuffer.image; dstImage = vFlipImage; final int[] src = ((DataBufferInt) srcImage.getRaster().getDataBuffer()).getData(); final int[] dst = ((DataBufferInt) dstImage.getRaster().getDataBuffer()).getData(); + if( DEBUG_TILES ) { + Arrays.fill(dst, 0x55); + } final int incr = tBuffer.width; int srcPos = 0; int destPos = (tHeight - 1) * tBuffer.width; @@ -239,28 +333,31 @@ public class AWTTilePainter { } else { dstImage = tBuffer.image; } - // Draw resulting image in one shot - final int tRows = renderer.getParam(TileRenderer.TR_ROWS); - final int tRow = renderer.getParam(TileRenderer.TR_CURRENT_ROW); - final int pX = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); - final int pYf; - if( flipVertical ) { - if( tRow == tRows - 1 ) { - tTopRowHeight = tHeight; - pYf = 0; - } else if( tRow == tRows - 2 ){ - pYf = tTopRowHeight; - } else { - pYf = ( tRows - 2 - tRow ) * tHeight + tTopRowHeight; + if( DEBUG_TILES ) { + final String fname = String.format("file_%03d_1_tile_[%02d][%02d]_sz_%03dx%03d_pos0_%03d_%03d_yOff_%03d_pos1_%03d_%03d.png", + _counter, + renderer.getParam(TileRenderer.TR_CURRENT_COLUMN), renderer.getParam(TileRenderer.TR_CURRENT_ROW), + tWidth, tHeight, + pX, pY, pYOff, pX, pYf).replace(' ', '_'); + System.err.println("XXX file "+fname); + final File fout = new File(fname); + try { + ImageIO.write(dstImage, "png", fout); + } catch (IOException e) { + e.printStackTrace(); } - } else { - pYf = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); - } + _counter++; + } + // Draw resulting image in one shot final Shape oClip = g2d.getClip(); - g2d.clipRect(pX, pYf, tWidth, tHeight); - g2d.drawImage(dstImage, pX, pYf, dstImage.getWidth(), dstImage.getHeight(), null); // Null ImageObserver since image data is ready. + // g2d.clipRect(pX, pYf, tWidth, tHeight); + final BufferedImage outImage = dstImage.getSubimage(0, 0, tWidth, tHeight); // instead of clipping + final boolean drawDone = g2d.drawImage(outImage, pX, pYf, null); // Null ImageObserver since image data is ready. + // final boolean drawDone = g2d.drawImage(dstImage, pX, pYf, dstImage.getWidth(), dstImage.getHeight(), null); // Null ImageObserver since image data is ready. if( verbose ) { - System.err.println("XXX tile-post.X clip "+oClip+" -> "+g2d.getClip()); + System.err.println("XXX tile-post.X clippedImageSize "+cis); + System.err.println("XXX tile-post.X pYf "+cis.getHeight()+" - ( "+pY+" - "+pYOff+" + "+tHeight+" ) "+scaledYOffset+" = "+ pYf); + System.err.println("XXX tile-post.X clip "+oClip+" + "+pX+" / [pY "+pY+", pYOff "+pYOff+", pYf "+pYf+"] "+tWidth+"x"+tHeight+" -> "+g2d.getClip()); g2d.setColor(Color.BLACK); g2d.drawRect(pX, pYf, tWidth, tHeight); if( null != oClip ) { @@ -269,9 +366,11 @@ public class AWTTilePainter { g2d.drawRect(r.x, r.y, r.width, r.height); } System.err.println("XXX tile-post.X "+renderer); - System.err.println("XXX tile-post.X dst-img "+dstImage.getWidth()+"x"+dstImage.getHeight()+", y-flip "+flipVertical+" -> "+pX+"/"+pYf); + System.err.println("XXX tile-post.X dst-img "+dstImage.getWidth()+"x"+dstImage.getHeight()); + System.err.println("XXX tile-post.X out-img "+outImage.getWidth()+"x"+dstImage.getHeight()); + System.err.println("XXX tile-post.X y-flip "+flipVertical+" -> "+pX+"/"+pYf+", drawDone "+drawDone); } - g2d.setClip(oClip); + // g2d.setClip(oClip); } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java new file mode 100644 index 000000000..a54f6bac6 --- /dev/null +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java @@ -0,0 +1,168 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.nativewindow.awt; + +import java.awt.Component; +import java.awt.Container; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.print.PrinterJob; + +import jogamp.nativewindow.awt.AWTMisc; + +/** + * Interface describing print lifecycle to support AWT printing, + * e.g. on AWT {@link javax.media.opengl.GLAutoDrawable GLAutoDrawable}s. + *

    Implementations
    + *

    + * Implementing {@link javax.media.opengl.GLAutoDrawable GLAutoDrawable} classes based on AWT + * supporting {@link Component#print(Graphics)} shall implement this interface. + *

    + *
    Usage
    + *

    + * Users attempting to print an AWT {@link Container} containing {@link AWTPrintLifecycle} elements + * shall consider decorating the {@link Container#printAll(Graphics)} call with
    + * {@link #setupPrint(double, double, int) setupPrint(..)} and {@link #releasePrint()} + * on all {@link AWTPrintLifecycle} elements in the {@link Container}.
    + * To minimize this burden, a user can use {@link Context#setupPrint(Container, double, double, int) Context.setupPrint(..)}: + *

    + *  Graphics2D g2d;
    + *  Container cont;
    + *  double scaleGLMatXY = 72.0/glDPI;
    + *  int numSamples = 0; // leave multisampling as-is
    + *  PrinterJob job;
    + *  ...
    +    final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(cont, scaleGLMatXY, scaleGLMatXY, numSamples);
    +    try {
    +       AWTEDTExecutor.singleton.invoke(true, new Runnable() {
    +            public void run() {
    +                try {
    +                    job.print();
    +                } catch (PrinterException ex) {
    +                    ex.printStackTrace();
    +                }
    +           } });
    +    } finally {
    +       ctx.releasePrint();
    +    }
    + * 
    + * 
    + *

    + */ +public interface AWTPrintLifecycle { + + public static final int DEFAULT_PRINT_TILE_SIZE = 512; + + + /** + * Shall be called before {@link PrinterJob#print()}. + *

    + * See Usage. + *

    + * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels + * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels + * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + */ + void setupPrint(double scaleMatX, double scaleMatY, int numSamples); + + /** + * Shall be called after {@link PrinterJob#print()}. + *

    + * See Usage. + *

    + */ + void releasePrint(); + + /** + * Convenient {@link AWTPrintLifecycle} context simplifying calling {@link AWTPrintLifecycle#setupPrint(double, double, int) setupPrint(..)} + * and {@link AWTPrintLifecycle#releasePrint()} on all {@link AWTPrintLifecycle} elements of a {@link Container}. + *

    + * See Usage. + *

    + */ + public static class Context { + /** + *

    + * See Usage. + *

    + * + * @param c container to be traversed through to perform {@link AWTPrintLifecycle#setupPrint(double, double, int) setupPrint(..)} on all {@link AWTPrintLifecycle} elements. + * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels + * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels + * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @return the context + */ + public static Context setupPrint(Container c, double scaleMatX, double scaleMatY, int numSamples) { + final Context t = new Context(c, scaleMatX, scaleMatY, numSamples); + t.setupPrint(c); + return t; + } + + /** + *

    + * See Usage. + *

    + */ + public void releasePrint() { + count = AWTMisc.performAction(cont, AWTPrintLifecycle.class, releaseAction); + } + + /** + * @return count of performed actions of last {@link #setupPrint(Container, double, double, int) setupPrint(..)} or {@link #releasePrint()}. + */ + public int getCount() { return count; } + + private final Container cont; + private final double scaleMatX; + private final double scaleMatY; + private final int numSamples; + private int count; + + private final AWTMisc.ComponentAction setupAction = new AWTMisc.ComponentAction() { + @Override + public void run(Component c) { + ((AWTPrintLifecycle)c).setupPrint(scaleMatX, scaleMatY, numSamples); + } }; + private final AWTMisc.ComponentAction releaseAction = new AWTMisc.ComponentAction() { + @Override + public void run(Component c) { + ((AWTPrintLifecycle)c).releasePrint(); + } }; + + private Context(Container c, double scaleMatX, double scaleMatY, int numSamples) { + this.cont = c; + this.scaleMatX = scaleMatX; + this.scaleMatY = scaleMatY; + this.numSamples = numSamples; + this.count = 0; + } + private void setupPrint(Container c) { + count = AWTMisc.performAction(c, AWTPrintLifecycle.class, setupAction); + } + } +} diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index cdf47cbb3..a2d4eb7f0 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -37,7 +37,6 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.KeyboardFocusManager; -import java.awt.RenderingHints; import java.beans.Beans; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -53,8 +52,6 @@ import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLProfile; -import javax.media.opengl.awt.AWTPrintLifecycle; import javax.swing.MenuSelectionManager; import jogamp.nativewindow.awt.AWTMisc; @@ -67,6 +64,7 @@ import jogamp.opengl.awt.AWTTilePainter; import com.jogamp.common.os.Platform; import com.jogamp.common.util.awt.AWTEDTExecutor; +import com.jogamp.nativewindow.awt.AWTPrintLifecycle; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.newt.Display; @@ -455,13 +453,20 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } private volatile boolean printActive = false; - private boolean printUseAA = false; + private int printNumSamples = 0; private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; + private final GLAutoDrawable getGLAD() { + if( null != newtChild && newtChild instanceof GLAutoDrawable ) { + return (GLAutoDrawable)newtChild; + } + return null; + } + @Override - public void setupPrint(Graphics2D g2d, double scaleMatX, double scaleMatY) { + public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) { if( !validateComponent(true) ) { if(DEBUG) { System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); @@ -474,15 +479,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } return; // not yet available .. } - printActive = true; - final RenderingHints rHints = g2d.getRenderingHints(); - { - final Object _useAA = rHints.get(RenderingHints.KEY_ANTIALIASING); - printUseAA = null != _useAA && ( _useAA == RenderingHints.VALUE_ANTIALIAS_DEFAULT || _useAA == RenderingHints.VALUE_ANTIALIAS_ON ); + final GLAutoDrawable glad = getGLAD(); + if( null == glad ) { + if( DEBUG ) { + System.err.println("AWT print.setup exit, newtChild not a GLAutoDrawable: "+newtChild); + } + return; } + printActive = true; + printNumSamples = AWTTilePainter.getNumSamples(numSamples, glad.getChosenGLCapabilities()); if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", useAA "+printUseAA+", printAnimator "+printAnimator); - AWTTilePainter.dumpHintsAndScale(g2d); + System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", numSamples "+numSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); @@ -492,39 +499,21 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final Runnable setupPrintOnEDT = new Runnable() { @Override public void run() { - final GLAutoDrawable glad; - if( null != newtChild && newtChild instanceof GLAutoDrawable ) { - glad = (GLAutoDrawable)newtChild; - } else { - if( DEBUG ) { - System.err.println("AWT print.setup exit, newtChild not a GLAutoDrawable: "+newtChild); - } - printAWTTiles = null; - printActive = false; - return; - } + final GLAutoDrawable glad = getGLAD(); printAnimator = glad.getAnimator(); if( null != printAnimator ) { printAnimator.remove(glad); } final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); - final GLProfile glp = caps.getGLProfile(); if( caps.getSampleBuffers() ) { - // bug / issue w/ swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX + // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX printGLAD = glad; } else { caps.setDoubleBuffered(false); caps.setOnscreen(false); - if( printUseAA && !caps.getSampleBuffers() ) { - if ( !glp.isGL2ES3() ) { - if( DEBUG ) { - System.err.println("Ignore MSAA due to gl-profile < GL2ES3"); - } - printUseAA = false; - } else { - caps.setSampleBuffers(true); - caps.setNumSamples(8); - } + if( printNumSamples != caps.getNumSamples() ) { + caps.setSampleBuffers(0 < printNumSamples); + caps.setNumSamples(printNumSamples); } final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); @@ -535,7 +524,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto printAWTTiles.renderer.attachToAutoDrawable(printGLAD); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); - System.err.println("AWT print.setup AA "+printUseAA+", "+caps); + System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); System.err.println("AWT print.setup "+printGLAD); } } @@ -557,7 +546,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( DEBUG ) { System.err.println("AWT print.release "+printAWTTiles); } - final GLAutoDrawable glad = (GLAutoDrawable)newtChild; + final GLAutoDrawable glad = getGLAD(); printAWTTiles.dispose(); printAWTTiles= null; if( printGLAD != glad ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java index 322d2d1b5..908a89a32 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java @@ -115,15 +115,15 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 72, false); + doPrintManual(frame, 72, 0); } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 300, false); + doPrintManual(frame, 300, -1); } }; final ActionListener print600DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 600, false); + doPrintManual(frame, 600, -1); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); @@ -176,15 +176,15 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { Thread.sleep(200); if( !printDone ) { printDone = true; - doPrintAuto(frame, PageFormat.LANDSCAPE, null, 72, false); + doPrintAuto(frame, PageFormat.LANDSCAPE, null, 72, 0); waitUntilPrintJobsIdle(); - doPrintAuto(frame, PageFormat.LANDSCAPE, null, 72, true); + doPrintAuto(frame, PageFormat.LANDSCAPE, null, 72, 8); waitUntilPrintJobsIdle(); // No AA needed for 300 dpi and greater :) - doPrintAuto(frame, PageFormat.LANDSCAPE, null, 300, false); + doPrintAuto(frame, PageFormat.LANDSCAPE, null, 300, -1); waitUntilPrintJobsIdle(); if( allow600dpi ) { - doPrintAuto(frame, PageFormat.LANDSCAPE, null, 600, false); + doPrintAuto(frame, PageFormat.LANDSCAPE, null, 600, -1); waitUntilPrintJobsIdle(); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java index f7f856676..c695febbe 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java @@ -120,15 +120,15 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 72, false); + doPrintManual(frame, 72, 0); } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 300, false); + doPrintManual(frame, 300, -1); } }; final ActionListener print600DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 600, false); + doPrintManual(frame, 600, -1); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); @@ -181,15 +181,15 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { Thread.sleep(200); if( !printDone ) { printDone = true; - doPrintAuto(frame, PageFormat.LANDSCAPE, null, 72, false); + doPrintAuto(frame, PageFormat.LANDSCAPE, null, 72, 0); waitUntilPrintJobsIdle(); - doPrintAuto(frame, PageFormat.LANDSCAPE, null, 72, true); + doPrintAuto(frame, PageFormat.LANDSCAPE, null, 72, 8); waitUntilPrintJobsIdle(); // No AA needed for 300 dpi and greater :) - doPrintAuto(frame, PageFormat.LANDSCAPE, null, 300, false); + doPrintAuto(frame, PageFormat.LANDSCAPE, null, 300, -1); waitUntilPrintJobsIdle(); if( allow600dpi ) { - doPrintAuto(frame, PageFormat.LANDSCAPE, null, 600, false); + doPrintAuto(frame, PageFormat.LANDSCAPE, null, 600, -1); waitUntilPrintJobsIdle(); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java index da577ea1d..9c5d6bf8b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java @@ -45,7 +45,11 @@ import java.lang.reflect.InvocationTargetException; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLJPanel; +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JFrame; +import javax.swing.JLayeredPane; import javax.swing.JPanel; import javax.swing.SwingUtilities; @@ -93,40 +97,67 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { public static void releaseClass() { } - protected void runTestGL(GLCapabilities caps) throws InterruptedException, InvocationTargetException { - final Dimension glc_sz = new Dimension(width/2, height); + protected void runTestGL(GLCapabilities caps, boolean layered) throws InterruptedException, InvocationTargetException { + final int layerStepX = width/6, layerStepY = height/6; + final Dimension glc_sz = new Dimension(layered ? width - 2*layerStepX : width/2, layered ? height - 2*layerStepY : height); final GLJPanel glJPanel1 = new GLJPanel(caps); Assert.assertNotNull(glJPanel1); glJPanel1.setMinimumSize(glc_sz); glJPanel1.setPreferredSize(glc_sz); - glJPanel1.setSize(glc_sz); + if( layered ) { + glJPanel1.setBounds(layerStepX/2, layerStepY/2, glc_sz.width, glc_sz.height); + } else { + glJPanel1.setBounds(0, 0, glc_sz.width, glc_sz.height); + } glJPanel1.addGLEventListener(new Gears()); final GLJPanel glJPanel2 = new GLJPanel(caps); Assert.assertNotNull(glJPanel2); glJPanel2.setMinimumSize(glc_sz); glJPanel2.setPreferredSize(glc_sz); - glJPanel2.setSize(glc_sz); + if( layered ) { + glJPanel2.setBounds(3*layerStepY, 2*layerStepY, glc_sz.width, glc_sz.height); + } else { + glJPanel2.setBounds(0, 0, glc_sz.width, glc_sz.height); + } glJPanel2.addGLEventListener(new RedSquareES2()); + // glJPanel2.addGLEventListener(new Gears()); - final JPanel demoPanel = new JPanel(); - demoPanel.add(glJPanel1); - demoPanel.add(glJPanel2); + final JComponent demoPanel; + if( layered ) { + glJPanel1.setOpaque(true); + glJPanel2.setOpaque(false); + final Dimension lsz = new Dimension(width, height); + demoPanel = new JLayeredPane(); + demoPanel.setMinimumSize(lsz); + demoPanel.setPreferredSize(lsz); + demoPanel.setBounds(0, 0, lsz.width, lsz.height); + demoPanel.setBorder(BorderFactory.createTitledBorder("Layered Pane")); + demoPanel.add(glJPanel1, JLayeredPane.DEFAULT_LAYER); + demoPanel.add(glJPanel2, Integer.valueOf(1)); + final JButton tb = new JButton("On Top"); + tb.setBounds(4*layerStepY, 3*layerStepY, 100, 50); + demoPanel.add(tb, Integer.valueOf(2)); + } else { + demoPanel = new JPanel(); + demoPanel.add(glJPanel1); + demoPanel.add(glJPanel2); + } final JFrame frame = new JFrame("Swing Print"); Assert.assertNotNull(frame); final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 72, false); + doPrintManual(frame, 72, 0); } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 300, false); + doPrintManual(frame, 300, -1); } }; final ActionListener print600DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 600, false); + doPrintManual(frame, 600, -1); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); @@ -182,20 +213,19 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { Thread.sleep(200); if( !printDone ) { printDone = true; - doPrintAuto(frame, PageFormat.LANDSCAPE, null, 72, false); + doPrintAuto(frame, PageFormat.LANDSCAPE, null, 72, 0); waitUntilPrintJobsIdle(); - doPrintAuto(frame, PageFormat.LANDSCAPE, null, 72, true); + doPrintAuto(frame, PageFormat.LANDSCAPE, null, 72, 8); waitUntilPrintJobsIdle(); // No AA needed for 300 dpi and greater :) - doPrintAuto(frame, PageFormat.LANDSCAPE, null, 300, false); + doPrintAuto(frame, PageFormat.LANDSCAPE, null, 300, -1); waitUntilPrintJobsIdle(); if( allow600dpi ) { - doPrintAuto(frame, PageFormat.LANDSCAPE, null, 600, false); + doPrintAuto(frame, PageFormat.LANDSCAPE, null, 600, -1); waitUntilPrintJobsIdle(); } } } - // try { Thread.sleep(4000); } catch (InterruptedException e) { } // time to finish print jobs .. FIXME ?? Assert.assertNotNull(frame); Assert.assertNotNull(glJPanel1); @@ -220,15 +250,22 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { @Test public void test01_Onscreen_aa0() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); - runTestGL(caps); + runTestGL(caps, false); + } + + @Test + public void test01_Onscreen_aa0_layered() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + caps.setAlphaBits(8); + runTestGL(caps, true); } @Test public void test02_Onscreen_aa8() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); caps.setSampleBuffers(true); - caps.setNumSamples(8); // FIXME - runTestGL(caps); + caps.setNumSamples(8); + runTestGL(caps, false); } static long duration = 500; // ms diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java index ec216a95e..c23d51c51 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java @@ -28,11 +28,10 @@ package com.jogamp.opengl.test.junit.jogl.tile; -import java.awt.Frame; +import java.awt.Container; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; -import java.awt.RenderingHints; import java.awt.print.PageFormat; import java.awt.print.Paper; import java.awt.print.Printable; @@ -41,7 +40,6 @@ import java.awt.print.PrinterJob; import java.io.FileNotFoundException; import java.io.FileOutputStream; -import javax.media.opengl.awt.AWTPrintLifecycle; import javax.print.StreamPrintService; import javax.print.StreamPrintServiceFactory; import javax.print.attribute.HashPrintRequestAttributeSet; @@ -53,6 +51,7 @@ import org.junit.Assert; import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.nativewindow.awt.AWTPrintLifecycle; import com.jogamp.opengl.test.junit.util.UITestCase; /** @@ -97,11 +96,7 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab public static final double A0_HEIGHT_INCH = A0_WIDTH_MM / MM_PER_INCH; */ /** Helper to pass desired Frame to print! **/ - private Frame frame; - /** Helper to pass desired DPI value ! **/ - private int glDPI = 72; - /** Helper to pass desired AA hint ! **/ - private boolean printAA = false; + private Container printContainer; private RecursiveLock lockPrinting = LockFactory.createRecursiveLock(); @@ -155,9 +150,9 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab /** * See: 'Scaling of Frame and GL content' in Class description! */ - final Insets frameInsets = frame.getInsets(); - final int frameWidth = frame.getWidth(); - final int frameHeight= frame.getHeight(); + final Insets frameInsets = printContainer.getInsets(); + final int frameWidth = printContainer.getWidth(); + final int frameHeight= printContainer.getHeight(); final double scaleComp72; { final int frameBorderW = frameInsets.left + frameInsets.right; @@ -166,32 +161,21 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab final double sy = pf.getImageableHeight() / ( frameHeight + frameBorderH ); scaleComp72 = Math.min(sx, sy); } - final double scaleGLMatXY = 72.0 / glDPI; System.err.println("PRINT thread "+Thread.currentThread().getName()); - System.err.println("PRINT DPI: "+glDPI+", AA "+printAA+", scaleGL "+scaleGLMatXY+", scaleComp72 "+scaleComp72+ + System.err.println("PRINT DPI: scaleComp72 "+scaleComp72+ ", frame: border "+frameInsets+", size "+frameWidth+"x"+frameHeight); - final Graphics2D printG2D = (Graphics2D)g; - final Graphics2D g2d = printG2D; - + final Graphics2D g2d = (Graphics2D)g; + System.err.println("PRINT at.pre: "+g2d.getTransform()); g2d.translate(pf.getImageableX(), pf.getImageableY()); g2d.scale(scaleComp72, scaleComp72); - - if( printAA ) { - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - } - final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, g2d, scaleGLMatXY, scaleGLMatXY); - try { - System.err.println("PRINT AWTPrintLifecycle.setup.count "+ctx.getCount()); - AWTEDTExecutor.singleton.invoke(true, new Runnable() { - public void run() { - frame.printAll(g2d); - } - }); - } finally { - ctx.releasePrint(); - System.err.println("PRINT AWTPrintLifecycle.release.count "+ctx.getCount()); - } + System.err.println("PRINT at.post: "+g2d.getTransform()); + + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + printContainer.printAll(g2d); + } + }); /* tell the caller that this page is part of the printed document */ return PAGE_EXISTS; @@ -207,7 +191,15 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab super(); } - public void doPrintAuto(Frame frame, int pOrientation, Paper paper, int dpi, boolean antialiasing) { + /** + * + * @param cont + * @param pOrientation + * @param paper + * @param dpi + * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + */ + public void doPrintAuto(Container cont, int pOrientation, Paper paper, int dpi, int numSamples) { lock.lock(); try { final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); @@ -224,12 +216,12 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab StreamPrintServiceFactory[] factories = PrinterJob.lookupStreamPrintServices(pdfMimeType); if (factories.length > 0) { - final String fname = getPrintFilename(dpi, antialiasing, "pdf"); + final String fname = getPrintFilename(dpi, numSamples, "pdf"); System.err.println("doPrint: dpi "+dpi+", "+fname); FileOutputStream outstream; try { outstream = new FileOutputStream(fname); - Assert.assertTrue(doPrintAutoImpl(frame, pj, factories[0].getPrintService(outstream), pOrientation, paper, dpi, antialiasing)); + Assert.assertTrue(doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, dpi, numSamples)); } catch (FileNotFoundException e) { Assert.assertNull("Unexpected exception", e); } @@ -239,12 +231,12 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab factories = PrinterJob.lookupStreamPrintServices(psMimeType); if (factories.length > 0) { - final String fname = getPrintFilename(dpi, antialiasing, "ps"); + final String fname = getPrintFilename(dpi, numSamples, "ps"); System.err.println("doPrint: dpi "+dpi+", "+fname); FileOutputStream outstream; try { outstream = new FileOutputStream(fname); - Assert.assertTrue(doPrintAutoImpl(frame, pj, factories[0].getPrintService(outstream), pOrientation, paper, dpi, antialiasing)); + Assert.assertTrue(doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, dpi, numSamples)); } catch (FileNotFoundException e) { Assert.assertNull("Unexpected exception", e); } @@ -255,18 +247,14 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab lock.unlock(); } } - private String getPrintFilename(int dpi, boolean antialiasing, String suffix) { + private String getPrintFilename(int dpi, int numSamples, String suffix) { final int maxSimpleTestNameLen = getMaxTestNameLen()+getClass().getSimpleName().length()+1; final String simpleTestName = getSimpleTestName("."); - final String sAA = antialiasing ? "aa_" : "raw"; - return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-dpi%03d-%s.%s", simpleTestName, printCount, dpi, sAA, suffix).replace(' ', '_'); + return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-dpi%03d-aa%d.%s", simpleTestName, printCount, dpi, numSamples, suffix).replace(' ', '_'); } - private boolean doPrintAutoImpl(Frame frame, PrinterJob job, + private boolean doPrintAutoImpl(Container cont, PrinterJob job, StreamPrintService ps, int pOrientation, Paper paper, int dpi, - boolean antialiasing) { - this.frame = frame; - glDPI = dpi; - printAA = antialiasing; + int numSamples) { boolean ok = true; try { PageFormat pageFormat = job.defaultPage(); @@ -280,7 +268,7 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab pageFormat.setOrientation(pOrientation); // PageFormat.LANDSCAPE or PageFormat.PORTRAIT job.setPrintService(ps); job.setPrintable(this, pageFormat); - job.print(); + doPrintImpl(cont, job, dpi, numSamples); } catch (PrinterException pe) { pe.printStackTrace(); ok = false; @@ -288,25 +276,52 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab return ok; } - public void doPrintManual(Frame frame, int dpi, boolean antialiasing) { + /** + * + * @param cont + * @param dpi + * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + */ + public void doPrintManual(Container cont, int dpi, int numSamples) { lock.lock(); try { - this.frame = frame; - glDPI = dpi; - printAA = antialiasing; PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(this); boolean ok = job.printDialog(); if (ok) { + doPrintImpl(cont, job, dpi, numSamples); + } + } finally { + lock.unlock(); + } + } + + /** + * + * @param cont + * @param job + * @param dpi + * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + */ + private void doPrintImpl(final Container cont, final PrinterJob job, final int dpi, final int numSamples) { + printContainer = cont; + final double scaleGLMatXY = 72.0 / dpi; + System.err.println("PRINT DPI: "+dpi+", AA "+numSamples+", scaleGL "+scaleGLMatXY); + final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(printContainer, scaleGLMatXY, scaleGLMatXY, numSamples); + System.err.println("PRINT AWTPrintLifecycle.setup.count "+ctx.getCount()); + try { + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { try { job.print(); } catch (PrinterException ex) { ex.printStackTrace(); } - } - } finally { - lock.unlock(); - } + } }); + } finally { + ctx.releasePrint(); + System.err.println("PRINT AWTPrintLifecycle.release.count "+ctx.getCount()); + } } /** Wait for idle .. simply acquiring all locks and releasing them. */ -- cgit v1.2.3 From 988da6f30322176b8301d17709f5461c35a01e19 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 17 Sep 2013 16:09:10 +0200 Subject: AWT Printing: Move init-test of setupPrint(..) to AWT-EDT Runnable ; GLJPanel: Attempt to initialize if not done yet (similar to GLCanvas) --- .../classes/javax/media/opengl/awt/GLCanvas.java | 37 ++++++++-------- .../classes/javax/media/opengl/awt/GLJPanel.java | 41 ++++++++++-------- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 50 ++++++++++++---------- 3 files changed, 70 insertions(+), 58 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index a519e33bb..c43f218df 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -732,24 +732,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) { - if( !validateGLDrawable() ) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable not valid yet"); - } - return; // not yet available .. - } - if( !isVisible() ) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable visible"); - } - return; // not yet available .. - } printActive = true; - sendReshape = false; // clear reshape flag - printNumSamples = AWTTilePainter.getNumSamples(numSamples, getChosenGLCapabilities()); - if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", numSamples "+numSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); - } + printNumSamples = numSamples; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); @@ -758,12 +742,31 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private final Runnable setupPrintOnEDT = new Runnable() { @Override public void run() { + if( !validateGLDrawable() ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable not valid yet"); + } + printActive = false; + return; // not yet available .. + } + if( !isVisible() ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable visible"); + } + printActive = false; + return; // not yet available .. + } sendReshape = false; // clear reshape flag printAnimator = helper.getAnimator(); if( null != printAnimator ) { printAnimator.remove(GLCanvas.this); } final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); + final int reqNumSamples = printNumSamples; + printNumSamples = AWTTilePainter.getNumSamples(reqNumSamples, caps); + if( DEBUG ) { + System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+", numSamples "+reqNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); + } if( caps.getSampleBuffers() ) { // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX printGLAD = GLCanvas.this; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index f0c6b7beb..c66fba70b 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -505,25 +505,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) { - if (!isInitialized) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable not valid yet"); - } - return; // not yet available .. - } - if( !isVisible() ) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable visible"); - } - return; // not yet available .. - } printActive = true; - sendReshape = false; // clear reshape flag - handleReshape = false; // ditto - printNumSamples = AWTTilePainter.getNumSamples(numSamples, getChosenGLCapabilities()); - if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", numSamples "+numSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); - } + printNumSamples = numSamples; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); @@ -532,6 +515,23 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final Runnable setupPrintOnEDT = new Runnable() { @Override public void run() { + if (backend == null || !isInitialized) { + createAndInitializeBackend(); + } + if (!isInitialized) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable not valid yet"); + } + printActive = false; + return; // not yet available .. + } + if( !isVisible() ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable visible"); + } + printActive = false; + return; // not yet available .. + } sendReshape = false; // clear reshape flag handleReshape = false; // ditto printAnimator = helper.getAnimator(); @@ -541,6 +541,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printGLAD = GLJPanel.this; // default: re-use final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); + final int reqNumSamples = printNumSamples; + printNumSamples = AWTTilePainter.getNumSamples(reqNumSamples, caps); + if( DEBUG ) { + System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+", numSamples "+reqNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); + } if( printNumSamples != caps.getNumSamples() ) { caps.setDoubleBuffered(false); caps.setOnscreen(false); diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index a2d4eb7f0..64e9bb0f6 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -467,30 +467,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) { - if( !validateComponent(true) ) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); - } - return; // not yet available .. - } - if( !isVisible() ) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); - } - return; // not yet available .. - } - final GLAutoDrawable glad = getGLAD(); - if( null == glad ) { - if( DEBUG ) { - System.err.println("AWT print.setup exit, newtChild not a GLAutoDrawable: "+newtChild); - } - return; - } printActive = true; - printNumSamples = AWTTilePainter.getNumSamples(numSamples, glad.getChosenGLCapabilities()); - if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", numSamples "+numSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); - } + printNumSamples = numSamples; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); @@ -499,12 +477,38 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final Runnable setupPrintOnEDT = new Runnable() { @Override public void run() { + if( !validateComponent(true) ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); + } + printActive = false; + return; // not yet available .. + } + if( !isVisible() ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); + } + printActive = false; + return; // not yet available .. + } final GLAutoDrawable glad = getGLAD(); + if( null == glad ) { + if( DEBUG ) { + System.err.println("AWT print.setup exit, newtChild not a GLAutoDrawable: "+newtChild); + } + printActive = false; + return; + } printAnimator = glad.getAnimator(); if( null != printAnimator ) { printAnimator.remove(glad); } final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); + final int reqNumSamples = printNumSamples; + printNumSamples = AWTTilePainter.getNumSamples(reqNumSamples, caps); + if( DEBUG ) { + System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+", numSamples "+reqNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); + } if( caps.getSampleBuffers() ) { // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX printGLAD = glad; -- cgit v1.2.3 From 8a4a64e1a3e9beb09580ba95fe85026abf2ff106 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 19 Sep 2013 03:21:15 +0200 Subject: AWTTilePainter.setupGraphics2DAndClipBounds(): Use 'Shape getClip()'; Use double precicion clip bounds 'all the way'; Explicitly scale image and clip w/ current scaled transform. - Use 'Shape getClip()' Don't assume Rectangle2D, but use Shape's getBounds2D() - Use double precicion clip bounds 'all the way' Remove rounding error on clip bounds w/ start value, which was _not_ using doubles. - Explicitly scale image and clip w/ current scaled transform. Instead of abusing Graphics2D's clip shape to scale image size and clip-area, explicitly use transform both bounding boxes into transformed space, scale space and transform out (inversion). A possible NoninvertibleTransformException will be thrown while Graphics2D has not been modified. --- .../classes/javax/media/opengl/awt/GLCanvas.java | 32 ++++++---- .../classes/javax/media/opengl/awt/GLJPanel.java | 28 +++++---- .../classes/jogamp/opengl/awt/AWTTilePainter.java | 73 +++++++++++++--------- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 24 ++++--- 4 files changed, 93 insertions(+), 64 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index c43f218df..1ab30547a 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -53,6 +53,7 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; +import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.Rectangle2D; import java.awt.EventQueue; @@ -835,21 +836,26 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing sendReshape = false; // clear reshape flag final Graphics2D g2d = (Graphics2D)graphics; - printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); try { - final TileRenderer tileRenderer = printAWTTiles.renderer; - if( DEBUG ) { - System.err.println("AWT print.0: "+tileRenderer); - } - do { - if( printGLAD != GLCanvas.this ) { - tileRenderer.display(); - } else { - Threading.invoke(true, displayOnEDTAction, getTreeLock()); + printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); + try { + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); } - } while ( !tileRenderer.eot() ); - } finally { - printAWTTiles.resetGraphics2D(); + do { + if( printGLAD != GLCanvas.this ) { + tileRenderer.display(); + } else { + Threading.invoke(true, displayOnEDTAction, getTreeLock()); + } + } while ( !tileRenderer.eot() ); + } finally { + printAWTTiles.resetGraphics2D(); + } + } catch (NoninvertibleTransformException nte) { + System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); + nte.printStackTrace(); } if( DEBUG ) { System.err.println("AWT print.X: "+printAWTTiles); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index c66fba70b..e9d1b38d2 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -48,6 +48,7 @@ import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; +import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; @@ -612,18 +613,23 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing handleReshape = false; // ditto final Graphics2D g2d = (Graphics2D)graphics; - printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); try { - final TileRenderer tileRenderer = printAWTTiles.renderer; - do { - if( printGLAD != GLJPanel.this ) { - tileRenderer.display(); - } else { - backend.doPlainPaint(); - } - } while ( !tileRenderer.eot() ); - } finally { - printAWTTiles.resetGraphics2D(); + printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); + try { + final TileRenderer tileRenderer = printAWTTiles.renderer; + do { + if( printGLAD != GLJPanel.this ) { + tileRenderer.display(); + } else { + backend.doPlainPaint(); + } + } while ( !tileRenderer.eot() ); + } finally { + printAWTTiles.resetGraphics2D(); + } + } catch (NoninvertibleTransformException nte) { + System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); + nte.printStackTrace(); } if( DEBUG ) { System.err.println("AWT print.X: "+printAWTTiles); diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index f3aba3902..0b24fadae 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -33,6 +33,7 @@ import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.geom.AffineTransform; +import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; @@ -148,18 +149,22 @@ public class AWTTilePainter { return new Rectangle((int)Math.round(r.getX()), (int)Math.round(r.getY()), (int)Math.round(r.getWidth()), (int)Math.round(r.getHeight())); } - private static Rectangle clipNegative(Rectangle in) { + private static Rectangle2D getClipBounds2D(Graphics2D g) { + final Shape shape = g.getClip(); + return null != shape ? shape.getBounds2D() : null; + } + private static Rectangle2D clipNegative(Rectangle2D in) { if( null == in ) { return null; } - final Rectangle out = new Rectangle(in); - if( 0 > out.x ) { - out.width += out.x; - out.x = 0; + double x=in.getX(), y=in.getY(), width=in.getWidth(), height=in.getHeight(); + if( 0 > x ) { + width += x; + x = 0; } - if( 0 > out.y ) { - out.height += out.y; - out.y = 0; + if( 0 > y ) { + height += y; + y = 0; } - return out; + return new Rectangle2D.Double(x, y, width, height); } /** @@ -177,35 +182,37 @@ public class AWTTilePainter { * @param g2d Graphics2D instance used for transform and clipping * @param width width of the AWT component in case clipping is null * @param height height of the AWT component in case clipping is null + * @throws NoninvertibleTransformException if the {@link Graphics2D}'s {@link AffineTransform} {@link AffineTransform#invert() inversion} fails. + * Since inversion is tested before scaling the given {@link Graphics2D}, caller shall ignore the whole term. */ - public void setupGraphics2DAndClipBounds(Graphics2D g2d, int width, int height) { + public void setupGraphics2DAndClipBounds(Graphics2D g2d, int width, int height) throws NoninvertibleTransformException { this.g2d = g2d; saveAT = g2d.getTransform(); - final Rectangle gClipOrigR; - final Rectangle2D dClipOrig, dImageSizeOrig; // double precision for scaling - // setup original rectangles - { - gClipOrigR = g2d.getClipBounds(); - final Rectangle gClipOrig = clipNegative(gClipOrigR); - dClipOrig = null != gClipOrig ? new Rectangle2D.Double(gClipOrig.getX(), gClipOrig.getY(), gClipOrig.getWidth(), gClipOrig.getHeight()) : null; - dImageSizeOrig = new Rectangle2D.Double(0, 0, width, height); - } - final Rectangle2D dClipScaled, dImageSizeScaled; // double precision for scaling - // retrieve scaled image-size and clip-bounds + // We use double precision for scaling + // + // Setup original rectangles + final Rectangle2D dClipOrigR = getClipBounds2D(g2d); + final Rectangle2D dClipOrig = clipNegative(dClipOrigR); + final Rectangle2D dImageSizeOrig = new Rectangle2D.Double(0, 0, width, height); + + // Retrieve scaled image-size and clip-bounds + final Rectangle2D dImageSizeScaled, dClipScaled; { - g2d.setClip(dImageSizeOrig); - g2d.scale(scaleMatX, scaleMatY); - dImageSizeScaled = (Rectangle2D) g2d.getClip(); + final AffineTransform scaledATI; + { + final AffineTransform scaledAT = g2d.getTransform(); + scaledAT.scale(scaleMatX, scaleMatY); + scaledATI = scaledAT.createInverse(); // -> NoninvertibleTransformException + } + Shape s0 = saveAT.createTransformedShape(dImageSizeOrig); // user in + dImageSizeScaled = scaledATI.createTransformedShape(s0).getBounds2D(); // scaled out if( null == dClipOrig ) { - g2d.setClip(null); dClipScaled = (Rectangle2D) dImageSizeScaled.clone(); } else { - g2d.setTransform(saveAT); // reset - g2d.setClip(dClipOrig); - g2d.scale(scaleMatX, scaleMatY); - dClipScaled = (Rectangle2D) g2d.getClip(); + s0 = saveAT.createTransformedShape(dClipOrig); // user in + dClipScaled = scaledATI.createTransformedShape(s0).getBounds2D(); // scaled out } - } + } final Rectangle iClipScaled = getRoundedRect(dClipScaled); final Rectangle iImageSizeScaled = getRoundedRect(dImageSizeScaled); scaledYOffset = iClipScaled.y; @@ -213,9 +220,13 @@ public class AWTTilePainter { renderer.clipImageSize(iClipScaled.width, iClipScaled.height); final int clipH = Math.min(iImageSizeScaled.height, iClipScaled.height); renderer.setTileOffset(iClipScaled.x, iImageSizeScaled.height - ( iClipScaled.y + clipH )); + + // Scale actual Grahics2D matrix + g2d.scale(scaleMatX, scaleMatY); + if( verbose ) { System.err.println("AWT print.0: image "+dImageSizeOrig + " -> " + dImageSizeScaled + " -> " + iImageSizeScaled); - System.err.println("AWT print.0: clip "+gClipOrigR + " -> " + dClipOrig + " -> " + dClipScaled + " -> " + iClipScaled); + System.err.println("AWT print.0: clip "+dClipOrigR + " -> " + dClipOrig + " -> " + dClipScaled + " -> " + iClipScaled); System.err.println("AWT print.0: "+renderer); } } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 64e9bb0f6..374a80325 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -37,6 +37,7 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.KeyboardFocusManager; +import java.awt.geom.NoninvertibleTransformException; import java.beans.Beans; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -577,17 +578,22 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } final Graphics2D g2d = (Graphics2D)graphics; - printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); try { - final TileRenderer tileRenderer = printAWTTiles.renderer; - if( DEBUG ) { - System.err.println("AWT print.0: "+tileRenderer); + printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); + try { + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); + } + do { + tileRenderer.display(); + } while ( !tileRenderer.eot() ); + } finally { + printAWTTiles.resetGraphics2D(); } - do { - tileRenderer.display(); - } while ( !tileRenderer.eot() ); - } finally { - printAWTTiles.resetGraphics2D(); + } catch (NoninvertibleTransformException nte) { + System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); + nte.printStackTrace(); } if( DEBUG ) { System.err.println("AWT print.X: "+printAWTTiles); -- cgit v1.2.3 From c5bec6b8f5c33a812338dcbe8994546bddf0508b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 22 Sep 2013 02:35:11 +0200 Subject: Fix Bug 840: DefaultEDTUtil.restart() shall only reuse ThreadGroup (tg) is not destroyed, otherwise use current thread's tg. With jdk7u40, when re-launching a NEWT applet (JOGLNewtApplet1Run), i.e. via browser back and forth, the following exception happens: java.lang.RuntimeException: java.lang.IllegalThreadStateException at com.jogamp.newt.awt.applet.JOGLNewtApplet1Run.init(JOGLNewtApplet1Run.java:218) at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.IllegalThreadStateException at java.lang.ThreadGroup.addUnstarted(Unknown Source) at java.lang.Thread.init(Unknown Source) at java.lang.Thread.(Unknown Source) at jogamp.newt.DefaultEDTUtil$NEDT.(DefaultEDTUtil.java:280) at jogamp.newt.DefaultEDTUtil.restart(DefaultEDTUtil.java:91) at jogamp.newt.DisplayImpl.runOnEDTIfAvail(DisplayImpl.java:231) at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:1758) at jogamp.newt.WindowImpl.setUndecorated(WindowImpl.java:1477) at com.jogamp.newt.opengl.GLWindow.setUndecorated(GLWindow.java:278) at com.jogamp.newt.awt.applet.JOGLNewtApplet1Run.init(JOGLNewtApplet1Run.java:188) ... 3 more This is due to 7u40's changed ThreadGroup (tg) lifecycle, i.e. the tg is destroyed. In such case, DefaultEDTUtil.restart() shall use the current threads tg. --- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index a229a0512..5794d4ae9 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -38,6 +38,7 @@ package jogamp.newt; import java.util.ArrayList; + import javax.media.nativewindow.NativeWindowException; import jogamp.common.util.locks.LockDebugUtil; @@ -50,7 +51,7 @@ public class DefaultEDTUtil implements EDTUtil { public static final boolean DEBUG = Debug.debug("EDT"); private final Object edtLock = new Object(); // locking the EDT start/stop state - private final ThreadGroup threadGroup; + private /* final */ ThreadGroup threadGroup; private final String name; private final Runnable dispatchMessages; private NEDT edt = null; @@ -88,6 +89,10 @@ public class DefaultEDTUtil implements EDTUtil { System.err.println(Thread.currentThread()+": Default-EDT reset - edt: "+edt); } if( edt.getState() != Thread.State.NEW ) { + if( null != threadGroup && threadGroup.isDestroyed() ) { + // best thing we can do is to use this thread's TG + threadGroup = Thread.currentThread().getThreadGroup(); + } edt = new NEDT(threadGroup, name); edt.setDaemon(true); // don't stop JVM from shutdown .. } -- cgit v1.2.3 From 4b5435c68c3f12d62dadb395957362eceacfb25c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 24 Sep 2013 23:13:16 +0200 Subject: Bug 816: Fix OSX CALayer 'quirks' for AWT 1.7.0_40 - See JAWTUtil JAWT_OSX_CALAYER_QUIRK_SIZE and JAWT_OSX_CALAYER_QUIRK_POSITION. - Provide quirk bits for OSX CALayer depending on used JVM/AWT and act accordingly. - TestBug816OSXCALayerPosAWT: Add resize by frame --- .../macosx/MacOSXWindowSystemInterface-calayer.m | 76 ++++++----- .../classes/jogamp/nativewindow/jawt/JAWTUtil.java | 76 ++++++++++- .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 14 +- .../jogamp/nativewindow/macosx/OSXUtil.java | 26 ++-- .../native/macosx/NativeWindowProtocols.h | 21 ++- src/nativewindow/native/macosx/OSXmisc.m | 143 +++++++++++++-------- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 5 +- .../jogamp/newt/awt/applet/JOGLNewtApplet1Run.java | 7 +- .../junit/jogl/awt/TestBug816OSXCALayerPosAWT.java | 120 +++++++++++++---- 9 files changed, 355 insertions(+), 133 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index 046171efc..d15c8e038 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -150,7 +150,7 @@ extern GLboolean glIsVertexArray (GLuint array); @end -@interface MyNSOpenGLLayer: NSOpenGLLayer +@interface MyNSOpenGLLayer: NSOpenGLLayer { @private GLfloat gl_texCoords[8]; @@ -166,8 +166,8 @@ extern GLboolean glIsVertexArray (GLuint array); NSOpenGLPixelFormat* parentPixelFmt; int texWidth; int texHeight; - volatile int dedicatedWidth; - volatile int dedicatedHeight; + volatile Bool dedicatedFrameSet; + volatile CGRect dedicatedFrame; volatile NSOpenGLPixelBuffer* pbuffer; volatile GLuint textureID; volatile NSOpenGLPixelBuffer* newPBuffer; @@ -206,14 +206,14 @@ extern GLboolean glIsVertexArray (GLuint array); - (Bool)isGLSourceValid; - (void) setGLEnabled: (Bool) enable; -- (Bool) validateTexSizeWithDedicatedSize; +- (Bool) validateTexSize: (CGRect) lRect; - (void) setTextureID: (int) _texID; - (Bool) isSamePBuffer: (NSOpenGLPixelBuffer*) p; - (void) setNewPBuffer: (NSOpenGLPixelBuffer*)p; - (void) applyNewPBuffer; -- (void)setDedicatedSize:(CGSize)size; // @NWDedicatedSize +- (void)setDedicatedFrame:(CGRect)frame quirks:(int)quirks; // @NWDedicatedFrame - (void) setFrame:(CGRect) frame; - (id)actionForKey:(NSString *)key ; - (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask; @@ -300,9 +300,9 @@ static const GLfloat gl_verts[] = { timespec_now(&lastWaitTime); shallDraw = NO; isGLEnabled = YES; - dedicatedWidth = _texWidth; - dedicatedHeight = _texHeight; - [self validateTexSizeWithDedicatedSize]; + dedicatedFrameSet = NO; + dedicatedFrame = CGRectMake(0, 0, _texWidth, _texHeight); + [self validateTexSize: dedicatedFrame]; [self setTextureID: texID]; newPBuffer = NULL; @@ -383,11 +383,16 @@ static const GLfloat gl_verts[] = { isGLEnabled = enable; } -- (Bool) validateTexSizeWithDedicatedSize +- (Bool) validateTexSize: (CGRect) lRect { - if( dedicatedHeight != texHeight || dedicatedWidth != texWidth ) { - texWidth = dedicatedWidth; - texHeight = dedicatedHeight; + const int lRectW = (int) (lRect.size.width + 0.5f); + const int lRectH = (int) (lRect.size.height + 0.5f); + Bool changed; + + if( lRectH != texHeight || lRectW != texWidth ) { + texWidth = lRectW; + texHeight = lRectH; + changed = YES; GLfloat texCoordWidth, texCoordHeight; if(NULL != pbuffer) { @@ -409,16 +414,16 @@ static const GLfloat gl_verts[] = { gl_texCoords[5] = texCoordHeight; gl_texCoords[4] = texCoordWidth; gl_texCoords[6] = texCoordWidth; -#ifdef VERBOSE_ON - CGRect lRect = [self bounds]; - DBG_PRINT("MyNSOpenGLLayer::validateTexSize %p -> tex %dx%d, bounds: %lf/%lf %lfx%lf\n", + #ifdef VERBOSE_ON + DBG_PRINT("MyNSOpenGLLayer::validateTexSize %p -> tex %dx%d, bounds: %lf/%lf %lfx%lf (%dx%d), dedicatedFrame set:%d %lf/%lf %lfx%lf\n", self, texWidth, texHeight, - lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); -#endif - return YES; + lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, lRectW, lRectH, + dedicatedFrameSet, dedicatedFrame.origin.x, dedicatedFrame.origin.y, dedicatedFrame.size.width, dedicatedFrame.size.height); + #endif } else { - return NO; + changed = NO; } + return changed; } - (void) setTextureID: (int) _texID @@ -560,21 +565,30 @@ static const GLfloat gl_verts[] = { return NULL != pbuffer || NULL != newPBuffer || 0 != textureID ; } -// @NWDedicatedSize -- (void)setDedicatedSize:(CGSize)size { - DBG_PRINT("MyNSOpenGLLayer::setDedicatedSize: %p, texSize %dx%d <- %lfx%lf\n", - self, texWidth, texHeight, size.width, size.height); - - dedicatedWidth = size.width; - dedicatedHeight = size.height; +// @NWDedicatedFrame +- (void)setDedicatedFrame:(CGRect)dFrame quirks:(int)quirks { + CGRect lRect = [self frame]; + Bool dedicatedFramePosSet = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & quirks ); + Bool dedicatedFrameSizeSet = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & quirks ); + dedicatedFrameSet = dedicatedFramePosSet || dedicatedFrameSizeSet; + dedicatedFrame = dFrame; - CGRect rect = CGRectMake(0, 0, dedicatedWidth, dedicatedHeight); - [super setFrame: rect]; + DBG_PRINT("MyNSOpenGLLayer::setDedicatedFrame: Quirks [%d, pos %d, size %d], %p, texSize %dx%d, %lf/%lf %lfx%lf -> %lf/%lf %lfx%lf\n", + quirks, dedicatedFramePosSet, dedicatedFrameSizeSet, self, texWidth, texHeight, + lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, + dFrame.origin.x, dFrame.origin.y, dFrame.size.width, dFrame.size.height); + + if( dedicatedFrameSet ) { + [super setFrame: dedicatedFrame]; + } } - (void) setFrame:(CGRect) frame { - CGRect rect = CGRectMake(0, 0, dedicatedWidth, dedicatedHeight); - [super setFrame: rect]; + if( dedicatedFrameSet ) { + [super setFrame: dedicatedFrame]; + } else { + [super setFrame: frame]; + } } - (id)actionForKey:(NSString *)key @@ -622,7 +636,7 @@ static const GLfloat gl_verts[] = { GLenum textureTarget; - Bool texSizeChanged = [self validateTexSizeWithDedicatedSize]; + Bool texSizeChanged = [self validateTexSize: ( dedicatedFrameSet ? dedicatedFrame : [self bounds] ) ]; if( texSizeChanged ) { [context update]; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index 1f5d33746..b663f90b7 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -68,7 +68,7 @@ public class JAWTUtil { public static final VersionNumber JAWT_MacOSXCALayerMinVersion = new VersionNumber(10,6,4); /** OSX JAWT CALayer required with Java >= 1.7.0 (implies OS X >= 10.7 */ - public static final VersionNumber JAWT_MacOSXCALayerRequiredForJavaVersion = new VersionNumber(1,7,0); + public static final VersionNumber JAWT_MacOSXCALayerRequiredForJavaVersion = Platform.Version17; // See whether we're running in headless mode private static final boolean headlessMode; @@ -98,18 +98,84 @@ public class JAWTUtil { * Returns true if this platform's JAWT implementation supports offscreen layer. */ public static boolean isOffscreenLayerSupported() { - return Platform.OS_TYPE == Platform.OSType.MACOS && - Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0; + return Platform.OS_TYPE == Platform.OSType.MACOS && + Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0; } /** * Returns true if this platform's JAWT implementation requires using offscreen layer. */ public static boolean isOffscreenLayerRequired() { - return Platform.OS_TYPE == Platform.OSType.MACOS && - Platform.JAVA_VERSION_NUMBER.compareTo(JAWT_MacOSXCALayerRequiredForJavaVersion)>=0; + return Platform.OS_TYPE == Platform.OSType.MACOS && + Platform.JAVA_VERSION_NUMBER.compareTo(JAWT_MacOSXCALayerRequiredForJavaVersion)>=0; } + /** + * CALayer size needs to be set using the AWT component size. + *

    + * As of today, we have to overwrite the CALayer size + * w/ the AWT component one since programmatic resize leads to differences. + *

    + *

    + * Hence this flag is always enabled. + *

    + *

    + * Sync w/ NativeWindowProtocols.h + *

    + */ + public static final int JAWT_OSX_CALAYER_QUIRK_SIZE = 1 << 0; + + /** + * CALayer position needs to be set to zero. + *

    + * Normally we have to set the root-calayer's position to 0/0 + * and leave client-calayer's position in it's desired place. + * With pre AWT 1.7.0_40, the client-calayer's position has to + * be set to zero as well. + *

    + *

    + * Further more a re-layout seems to be required in this case, + * i.e. a programmatic forced resize +1 and it's inverted resize -1. + *

    + *

    + * Hence this flag is enabled w/ AWT < 1.7.0_40. + *

    + *

    + * Sync w/ NativeWindowProtocols.h + *

    + */ + public static final int JAWT_OSX_CALAYER_QUIRK_POSITION = 1 << 1; + + /** + * Returns bitfield of required JAWT OSX CALayer quirks to mediate AWT impl. bugs. + *

    + * Returns zero, if platform is not {@link Platform.OSType#MACOS} + * or not supporting CALayer, i.e. OSX < 10.6.4. + *

    + *

    + * Otherwise includes + *

      + *
    • {@link #JAWT_OSX_CALAYER_QUIRK_SIZE} (always)
    • + *
    • {@link #JAWT_OSX_CALAYER_QUIRK_POSITION} if JVM < 1.7.0_40
    • + *
    + *

    + */ + public static int getOSXCALayerQuirks() { + int res = 0; + if( Platform.OS_TYPE == Platform.OSType.MACOS && + Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0 ) { + + /** Knowing impl. all expose the SIZE bug */ + res |= JAWT_OSX_CALAYER_QUIRK_SIZE; + + final int c = Platform.JAVA_VERSION_NUMBER.compareTo(Platform.Version17); + if( c < 0 || c == 0 && Platform.JAVA_VERSION_UPDATE < 40 ) { + res |= JAWT_OSX_CALAYER_QUIRK_POSITION; + } + } + return res; + } + /** * @param useOffscreenLayerIfAvailable * @return diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 080504a5c..666f895f4 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -49,6 +49,7 @@ import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.awt.JAWTWindow; @@ -105,16 +106,19 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { protected void attachSurfaceLayerImpl(final long layerHandle) { OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { - OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, getWidth(), getHeight()); + OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, getWidth(), getHeight(), JAWTUtil.getOSXCALayerQuirks()); } } ); } @Override protected void layoutSurfaceLayerImpl(long layerHandle, int width, int height) { - if(DEBUG) { - System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", "+width+"x"+height+"; "+this); + final int caLayerQuirks = JAWTUtil.getOSXCALayerQuirks(); + if( 0 != caLayerQuirks ) { + if(DEBUG) { + System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", "+width+"x"+height+", caLayerQuirks "+caLayerQuirks+"; "+this); + } + OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, width, height, caLayerQuirks); } - OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, width, height); } @Override @@ -240,7 +244,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { public void run() { String errMsg = null; if(0 == rootSurfaceLayer && 0 != jawtSurfaceLayersHandle) { - rootSurfaceLayer = OSXUtil.CreateCALayer(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); + rootSurfaceLayer = OSXUtil.CreateCALayer(bounds.getWidth(), bounds.getHeight()); if(0 == rootSurfaceLayer) { errMsg = "Could not create root CALayer"; } else { diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 1a90c095d..de24a76db 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -141,8 +141,8 @@ public class OSXUtil implements ToolkitProperties { * @see #DestroyCALayer(long) * @see #AddCASublayer(long, long) */ - public static long CreateCALayer(final int x, final int y, final int width, final int height) { - final long l = CreateCALayer0(x, y, width, height); + public static long CreateCALayer(final int width, final int height) { + final long l = CreateCALayer0(width, height); if(DEBUG) { System.err.println("OSXUtil.CreateCALayer: 0x"+Long.toHexString(l)+" - "+Thread.currentThread().getName()); } @@ -159,17 +159,18 @@ public class OSXUtil implements ToolkitProperties { * Hence it is important that related resources are not locked if * they will be used for creation. *

    - * @see #CreateCALayer(int, int, int, int) + * @param caLayerQuirks TODO + * @see #CreateCALayer(int, int) * @see #RemoveCASublayer(long, long, boolean) */ - public static void AddCASublayer(final long rootCALayer, final long subCALayer, final int width, final int height) { + public static void AddCASublayer(final long rootCALayer, final long subCALayer, final int width, final int height, final int caLayerQuirks) { if(0==rootCALayer || 0==subCALayer) { throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer)); } if(DEBUG) { - System.err.println("OSXUtil.AttachCALayer: 0x"+Long.toHexString(subCALayer)+" - "+Thread.currentThread().getName()); + System.err.println("OSXUtil.AttachCALayer: caLayerQuirks "+caLayerQuirks+", 0x"+Long.toHexString(subCALayer)+" - "+Thread.currentThread().getName()); } - AddCASublayer0(rootCALayer, subCALayer, width, height); + AddCASublayer0(rootCALayer, subCALayer, width, height, caLayerQuirks); } /** @@ -187,12 +188,13 @@ public class OSXUtil implements ToolkitProperties { * @param subCALayer the client surface layer, maybe null. * @param width the expected width * @param height the expected height + * @param caLayerQuirks TODO */ - public static void FixCALayerLayout(final long rootCALayer, final long subCALayer, final int width, final int height) { + public static void FixCALayerLayout(final long rootCALayer, final long subCALayer, final int width, final int height, final int caLayerQuirks) { if( 0==rootCALayer && 0==subCALayer ) { return; } - FixCALayerLayout0(rootCALayer, subCALayer, width, height); + FixCALayerLayout0(rootCALayer, subCALayer, width, height, caLayerQuirks); } /** @@ -210,7 +212,7 @@ public class OSXUtil implements ToolkitProperties { /** * Destroy a CALayer. - * @see #CreateCALayer(int, int, int, int) + * @see #CreateCALayer(int, int) */ public static void DestroyCALayer(final long caLayer) { if(0==caLayer) { @@ -354,9 +356,9 @@ public class OSXUtil implements ToolkitProperties { private static native void DestroyNSWindow0(long nsWindow); private static native long GetNSView0(long nsWindow); private static native long GetNSWindow0(long nsView); - private static native long CreateCALayer0(int x, int y, int width, int height); - private static native void AddCASublayer0(long rootCALayer, long subCALayer, int width, int height); - private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, int width, int height); + private static native long CreateCALayer0(int width, int height); + private static native void AddCASublayer0(long rootCALayer, long subCALayer, int width, int height, int caLayerQuirks); + private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, int width, int height, int caLayerQuirks); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); private static native void RunOnMainThread0(Runnable runnable); diff --git a/src/nativewindow/native/macosx/NativeWindowProtocols.h b/src/nativewindow/native/macosx/NativeWindowProtocols.h index b91a50dfd..73c8e65c5 100644 --- a/src/nativewindow/native/macosx/NativeWindowProtocols.h +++ b/src/nativewindow/native/macosx/NativeWindowProtocols.h @@ -25,10 +25,27 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ + +#ifndef NATIVEWINDOWPROTOCOLS_H +#define NATIVEWINDOWPROTOCOLS_H 1 +/** + * CALayer size needs to be set using the AWT component size. + * See detailed description in JAWTUtil.java and sync w/ changed. + */ +#define NW_DEDICATEDFRAME_QUIRK_SIZE ( 1 << 0 ) + +/** + * CALayer position needs to be set to zero. + * See detailed description in JAWTUtil.java and sync w/ changed. + */ +#define NW_DEDICATEDFRAME_QUIRK_POSITION ( 1 << 1 ) + #import -@protocol NWDedicatedSize -- (void)setDedicatedSize:(CGSize)size; +@protocol NWDedicatedFrame +- (void)setDedicatedFrame:(CGRect)dFrame quirks:(int)quirks; @end +#endif /* NATIVEWINDOWPROTOCOLS_H_ */ + diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 688ef79b8..afe3b3868 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -395,23 +395,23 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: CreateCALayer0 - * Signature: (IIII)J + * Signature: (II)J */ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 - (JNIEnv *env, jclass unused, jint x, jint y, jint width, jint height) + (JNIEnv *env, jclass unused, jint width, jint height) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; MyCALayer* layer = [[MyCALayer alloc] init]; - DBG_PRINT("CALayer::CreateCALayer.0: root %p %d/%d %dx%d (refcnt %d)\n", layer, (int)x, (int)y, (int)width, (int)height, (int)[layer retainCount]); + DBG_PRINT("CALayer::CreateCALayer.0: root %p 0/0 %dx%d (refcnt %d)\n", layer, (int)width, (int)height, (int)[layer retainCount]); // avoid zero size if(0 == width) { width = 32; } if(0 == height) { height = 32; } // initial dummy size ! CGRect lRect = [layer frame]; - lRect.origin.x = x; - lRect.origin.y = y; + lRect.origin.x = 0; + lRect.origin.y = 0; lRect.size.width = width; lRect.size.height = height; [layer setFrame: lRect]; @@ -428,45 +428,79 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 return (jlong) ((intptr_t) layer); } -static void FixCALayerLayout0(MyCALayer* rootLayer, CALayer* subLayer, jint width, jint height) { +static void FixCALayerLayout0(MyCALayer* rootLayer, CALayer* subLayer, jint width, jint height, jint caLayerQuirks, jboolean force) { if( NULL != rootLayer ) { CGRect lRect = [rootLayer frame]; - if(lRect.origin.x!=0 || lRect.origin.y!=0 || lRect.size.width!=width || lRect.size.height!=height) { - DBG_PRINT("CALayer::FixCALayerLayout0.0: Root %p frame %lf/%lf %lfx%lf -> 0/0 %dx%d\n", - rootLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)width, (int)height); - lRect.origin.x = 0; - lRect.origin.y = 0; - lRect.size.width = width; - lRect.size.height = height; + int posQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & caLayerQuirks ) && ( lRect.origin.x!=0 || lRect.origin.y!=0 ); + int sizeQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & caLayerQuirks ) && ( lRect.size.width!=width || lRect.size.height!=height ); + CGFloat _x, _y, _w, _h; + // force root -> 0/0 + _x = 0; + _y = 0; + posQuirk |= 8; + if( sizeQuirk ) { + _w = width; + _h = height; + } else { + _w = lRect.size.width; + _h = lRect.size.height; + } + DBG_PRINT("CALayer::FixCALayerLayout0.0: Quirks [%d, pos %d, size %d], Root %p frame %lf/%lf %lfx%lf, usr %dx%d -> %lf/%lf %lfx%lf\n", + caLayerQuirks, posQuirk, sizeQuirk, rootLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, + width, height, _x, _y, _w, _h); + if( posQuirk || sizeQuirk ) { + lRect.origin.x = _x; + lRect.origin.y = _y; + lRect.size.width = _w; + lRect.size.height = _h; [rootLayer setFrame: lRect]; } } if( NULL != subLayer ) { CGRect lRect = [subLayer frame]; - if(lRect.origin.x!=0 || lRect.origin.y!=0 || lRect.size.width!=width || lRect.size.height!=height) { - DBG_PRINT("CALayer::FixCALayerLayout0.0: SubL %p frame %lf/%lf %lfx%lf -> 0/0 %dx%d\n", - subLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)width, (int)height); - lRect.origin.x = 0; - lRect.origin.y = 0; - lRect.size.width = width; - lRect.size.height = height; - if( [subLayer conformsToProtocol:@protocol(NWDedicatedSize)] ) { - CALayer * subLayerDS = (CALayer *) subLayer; - [subLayerDS setDedicatedSize: lRect.size]; + int sizeQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & caLayerQuirks ) && ( lRect.size.width!=width || lRect.size.height!=height ); + CGFloat _x, _y, _w, _h; + int posQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & caLayerQuirks ) && ( lRect.origin.x!=0 || lRect.origin.y!=0 ); + if( posQuirk ) { + _x = 0; + _y = 0; + } else { + // sub always rel to root + _x = lRect.origin.x; + _y = lRect.origin.y; + } + if( sizeQuirk ) { + _w = width; + _h = height; + } else { + _w = lRect.size.width; + _h = lRect.size.height; + } + DBG_PRINT("CALayer::FixCALayerLayout1.0: Quirks [%d, pos %d, size %d], SubL %p frame %lf/%lf %lfx%lf, usr %dx%d -> %lf/%lf %lfx%lf\n", + caLayerQuirks, posQuirk, sizeQuirk, subLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, + width, height, _x, _y, _w, _h); + if( force || posQuirk || sizeQuirk ) { + lRect.origin.x = _x; + lRect.origin.y = _y; + lRect.size.width = _w; + lRect.size.height = _h; + if( [subLayer conformsToProtocol:@protocol(NWDedicatedFrame)] ) { + CALayer * subLayerDS = (CALayer *) subLayer; + [subLayerDS setDedicatedFrame: lRect quirks: caLayerQuirks]; } else { [subLayer setFrame: lRect]; } - } + } } } /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: AddCASublayer0 - * Signature: (JJII)V + * Signature: (JJIIIII)V */ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 - (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint width, jint height) + (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint width, jint height, jint caLayerQuirks) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); @@ -479,20 +513,23 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 [subLayer retain]; // Pairs w/ RemoveCASublayer CGRect lRectRoot = [rootLayer frame]; - DBG_PRINT("CALayer::AddCASublayer0.0: Origin %p frame0: %lf/%lf %lfx%lf\n", - rootLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height); - if(lRectRoot.origin.x!=0 || lRectRoot.origin.y!=0) { - lRectRoot.origin.x = 0; - lRectRoot.origin.y = 0; - [rootLayer setFrame: lRectRoot]; - DBG_PRINT("CALayer::AddCASublayer0.1: Origin %p frame*: %lf/%lf %lfx%lf\n", - rootLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height); + int posQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & caLayerQuirks ); + int sizeQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & caLayerQuirks ); + + DBG_PRINT("CALayer::AddCASublayer0.0: Quirks [%d, pos %d, size %d], Root %p (refcnt %d), Sub %p (refcnt %d), frame0: %lf/%lf %lfx%lf\n", + caLayerQuirks, posQuirk, sizeQuirk, rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount], + lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height); + + CGPoint origin = lRectRoot.origin; // save + // force root to 0/0 + lRectRoot.origin.x = 0; + lRectRoot.origin.y = 0; + [rootLayer setFrame: lRectRoot]; + + // simple 1:1 layout rel. to root-layer ! + if( !posQuirk ) { + lRectRoot.origin = origin; } - DBG_PRINT("CALayer::AddCASublayer0.2: root %p (refcnt %d) .sub %p %lf/%lf %lfx%lf (refcnt %d)\n", - rootLayer, (int)[rootLayer retainCount], - subLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height, (int)[subLayer retainCount]); - - // simple 1:1 layout ! [subLayer setFrame:lRectRoot]; [rootLayer addSublayer:subLayer]; @@ -507,7 +544,9 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 [subLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; [subLayer setNeedsDisplayOnBoundsChange: YES]; - FixCALayerLayout0(rootLayer, subLayer, width, height); + if( 0 != caLayerQuirks ) { + FixCALayerLayout0(rootLayer, subLayer, width, height, caLayerQuirks, JNI_TRUE); + } [CATransaction commit]; @@ -519,23 +558,25 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: FixCALayerLayout0 - * Signature: (JJII)V + * Signature: (JJIIIII)V */ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerLayout0 - (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint width, jint height) + (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint width, jint height, int caLayerQuirks) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); - CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer); + if( 0 != caLayerQuirks ) { + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); + CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer); - [CATransaction begin]; - [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; - FixCALayerLayout0(rootLayer, subLayer, width, height); + FixCALayerLayout0(rootLayer, subLayer, width, height, caLayerQuirks, JNI_FALSE); - [CATransaction commit]; + [CATransaction commit]; - [pool release]; + [pool release]; + } } /* @@ -807,7 +848,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RunLater0 /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: IsMainThread0 - * Signature: (V)V + * Signature: (V)Z */ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_IsMainThread0 (JNIEnv *env, jclass unused) diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 374a80325..eadb69ec2 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -56,6 +56,7 @@ import javax.media.opengl.GLDrawableFactory; import javax.swing.MenuSelectionManager; import jogamp.nativewindow.awt.AWTMisc; +import jogamp.nativewindow.jawt.JAWTUtil; import jogamp.newt.Debug; import jogamp.newt.WindowImpl; import jogamp.newt.awt.NewtFactoryAWT; @@ -63,7 +64,6 @@ import jogamp.newt.awt.event.AWTParentWindowAdapter; import jogamp.newt.driver.DriverClearFocus; import jogamp.opengl.awt.AWTTilePainter; -import com.jogamp.common.os.Platform; import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.nativewindow.awt.AWTPrintLifecycle; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; @@ -741,7 +741,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.setSize(w, h); newtChild.reparentWindow(jawtWindow); newtChild.addSurfaceUpdatedListener(jawtWindow); - if( Platform.OSType.MACOS == Platform.getOSType() && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { + if( jawtWindow.isOffscreenLayerSurfaceEnabled() && + 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) { AWTEDTExecutor.singleton.invoke(false, forceRelayout); } newtChild.setVisible(true); diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java index e8cd71514..83a129455 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java @@ -42,7 +42,8 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; -import com.jogamp.common.os.Platform; +import jogamp.nativewindow.jawt.JAWTUtil; + import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; @@ -251,7 +252,9 @@ public class JOGLNewtApplet1Run extends Applet { System.err.println("GLWindow: "+glWindow); } base.start(); - if( null != newtCanvasAWT && Platform.OSType.MACOS == Platform.getOSType() && newtCanvasAWT.isOffscreenLayerSurfaceEnabled() ) { + if( null != newtCanvasAWT && + newtCanvasAWT.isOffscreenLayerSurfaceEnabled() && + 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) { // force relayout final int cW = newtCanvasAWT.getWidth(); final int cH = newtCanvasAWT.getHeight(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java index f929b4d14..48340aa75 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java @@ -36,6 +36,7 @@ import javax.media.opengl.awt.GLCanvas; import javax.swing.BoxLayout; import javax.swing.JFrame; +import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.newt.event.awt.AWTWindowAdapter; import com.jogamp.newt.event.TraceWindowAdapter; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -71,7 +72,7 @@ import org.junit.runners.MethodSorters; public class TestBug816OSXCALayerPosAWT extends UITestCase { public enum FrameLayout { None, Flow, DoubleBorderCenterSurrounded, Box }; - static long duration = 500; // ms + static long duration = 1600; // ms static int width, height; static boolean forceES2 = false; @@ -102,7 +103,7 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase { static void setComponentSize(final Frame frame, final Component comp1, final java.awt.Dimension new_sz1, final Component comp2, final java.awt.Dimension new_sz2) { try { - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + AWTEDTExecutor.singleton.invoke(true /* wait */, new Runnable() { public void run() { comp1.setMinimumSize(new_sz1); comp1.setPreferredSize(new_sz1); @@ -121,9 +122,23 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase { Assume.assumeNoException( throwable ); } } + static void setFrameSize(final Frame frame, final boolean frameLayout, final java.awt.Dimension new_sz) { + try { + AWTEDTExecutor.singleton.invoke(true /* wait */, new Runnable() { + public void run() { + frame.setSize(new_sz); + if( frameLayout ) { + frame.validate(); + } + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } - protected void runTestGL(GLCapabilities caps, FrameLayout frameLayout, final boolean twoCanvas) throws InterruptedException, InvocationTargetException { - final JFrame frame = new JFrame("Bug861 AWT Test"); + protected void runTestGL(GLCapabilities caps, FrameLayout frameLayout, final boolean twoCanvas, final boolean resizeByComp) throws InterruptedException, InvocationTargetException { + final JFrame frame = new JFrame("Bug861: "+this.getTestMethodName()); Assert.assertNotNull(frame); final Container framePane = frame.getContentPane(); @@ -138,6 +153,7 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase { } final Dimension glcDim = new Dimension(width/2, height); + final Dimension frameDim = new Dimension(twoCanvas ? width + 64: width/2 + 64, height + 64); setComponentSize(null, glCanvas1, glcDim, glCanvas2, glcDim); @@ -148,7 +164,7 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase { break; case Flow: { final Container c = new Container(); - c.setLayout(new FlowLayout()); + c.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); c.add(glCanvas1); if( twoCanvas ) { c.add(glCanvas2); @@ -209,8 +225,12 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - frame.pack(); - frame.setVisible(true); + if( resizeByComp ) { + frame.pack(); + } else { + setFrameSize(frame, true, frameDim); + } + frame.setVisible(true); }}); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); @@ -229,8 +249,13 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase { } Thread.sleep(Math.max(1000, duration/2)); - final Dimension rwsizeHalf = new Dimension(rwsize.width/2, rwsize.height); - setComponentSize(frame, glCanvas1, rwsizeHalf, glCanvas2, rwsizeHalf); + final Dimension compRSizeHalf = new Dimension(rwsize.width/2, rwsize.height); + final Dimension frameRSizeHalf = new Dimension(twoCanvas ? rwsize.width + 64: rwsize.width/2 + 64, rwsize.height + 64); + if( resizeByComp ) { + setComponentSize(frame, glCanvas1, compRSizeHalf, glCanvas2, compRSizeHalf); + } else { + setFrameSize(frame, true, frameRSizeHalf); + } System.err.println("resize canvas1 pos/siz: "+glCanvas1.getX()+"/"+glCanvas1.getY()+" "+glCanvas1.getWidth()+"x"+glCanvas1.getHeight()); if( twoCanvas ) { System.err.println("resize canvas2 pos/siz: "+glCanvas2.getX()+"/"+glCanvas2.getY()+" "+glCanvas2.getWidth()+"x"+glCanvas2.getHeight()); @@ -276,52 +301,101 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase { } @Test - public void test00_None_One() throws InterruptedException, InvocationTargetException { + public void test00_Compo_None_One() throws InterruptedException, InvocationTargetException { if( testNum != -1 && testNum != 0 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.None, false); + runTestGL(caps, FrameLayout.None, false /* twoCanvas */, true /* resizeByComp */); } @Test - public void test01_Flow_One() throws InterruptedException, InvocationTargetException { + public void test01_Compo_Flow_One() throws InterruptedException, InvocationTargetException { if( testNum != -1 && testNum != 1 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Flow, false); + runTestGL(caps, FrameLayout.Flow, false /* twoCanvas */, true /* resizeByComp */); } @Test - public void test02_DblBrd_One() throws InterruptedException, InvocationTargetException { + public void test02_Compo_DblBrd_One() throws InterruptedException, InvocationTargetException { if( testNum != -1 && testNum != 2 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, false); + runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, false /* twoCanvas */, true /* resizeByComp */); } @Test - public void test03_Box_One() throws InterruptedException, InvocationTargetException { + public void test03_Compo_Box_One() throws InterruptedException, InvocationTargetException { if( testNum != -1 && testNum != 3 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Box, false); + runTestGL(caps, FrameLayout.Box, false /* twoCanvas */, true /* resizeByComp */); } @Test - public void test04_Flow_Two() throws InterruptedException, InvocationTargetException { + public void test04_Compo_Flow_Two() throws InterruptedException, InvocationTargetException { if( testNum != -1 && testNum != 4 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Flow, true); + runTestGL(caps, FrameLayout.Flow, true/* twoCanvas */, true /* resizeByComp */); } @Test - public void test05_DblBrd_Two() throws InterruptedException, InvocationTargetException { + public void test05_Compo_DblBrd_Two() throws InterruptedException, InvocationTargetException { if( testNum != -1 && testNum != 5 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, true); + runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, true/* twoCanvas */, true /* resizeByComp */); } @Test - public void test06_Box_Two() throws InterruptedException, InvocationTargetException { + public void test06_Compo_Box_Two() throws InterruptedException, InvocationTargetException { if( testNum != -1 && testNum != 6 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Box, true); + runTestGL(caps, FrameLayout.Box, true/* twoCanvas */, true /* resizeByComp */); + } + + @Test + public void test10_Frame_None_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 10 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.None, false /* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test11_Frame_Flow_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 11 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Flow, false /* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test12_Frame_DblBrd_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 12 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, false /* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test13_Frame_Box_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 13 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Box, false /* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test14_Frame_Flow_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 14 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Flow, true/* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test15_Frame_DblBrd_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 15 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, true/* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test16_Frame_Box_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 16 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Box, true/* twoCanvas */, false /* resizeByComp */); } static int testNum = -1; -- cgit v1.2.3 From 4ef53cf2ae509a625795bfa3a8982ce75e24e83a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 27 Sep 2013 07:13:24 +0200 Subject: TileRenderer*: TileRendererNotify -> TileRendererListener w/ clarifying functionality (reshapeTile(..), ..); Only process GLEventListener impl. TileRendererListener; attachToAutoDrawable -> attachAutoDrawable, etc. -TileRendererNotify -> TileRendererListener - Added methods: - void reshapeTile(TileRendererBase tr,int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight); - void startTileRendering(TileRendererBase tr); - void endTileRendering(TileRendererBase tr); allowing to clarify user code and API specification, i.e. TR only processes GLEventListener which impl. TileRendererListener. This also allows simplifying the API doc, while having a more descriptive reshape method focusing solely on tile rendering. Further more, the start/end TR methods allow certain GL related actions while the context is current before and after iterating through the tiles. This is even used for RandomTileRenderer (one tile only), to allow to reuse same TileRendererListener for diff TRs. - Fix language, attach and detach usage was vice versa. We do attach an GLAutoDrawable to a TR - attachToAutoDrawable -> attachAutoDrawable - detachFromAutoDrawable -> detachAutoDrawable - Adapted unit tests. --- .../com/jogamp/opengl/util/RandomTileRenderer.java | 2 +- .../com/jogamp/opengl/util/TileRenderer.java | 4 +- .../com/jogamp/opengl/util/TileRendererBase.java | 221 +++++++++++++++------ .../classes/javax/media/opengl/awt/GLCanvas.java | 2 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 2 +- .../classes/jogamp/opengl/awt/AWTTilePainter.java | 6 +- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 2 +- .../test/junit/jogl/demos/es1/RedSquareES1.java | 58 ++++-- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 64 +++--- .../test/junit/jogl/demos/es2/RedSquareES2.java | 56 ++++-- .../opengl/test/junit/jogl/demos/gl2/Gears.java | 59 +++--- .../tile/TestRandomTiledRendering2GL2NEWT.java | 4 +- .../jogl/tile/TestRandomTiledRendering3GL2AWT.java | 4 +- .../junit/jogl/tile/TestTiledRendering2NEWT.java | 4 +- 14 files changed, 320 insertions(+), 168 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java index 03b782ff8..dcf229716 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java @@ -201,7 +201,7 @@ public class RandomTileRenderer extends TileRendererBase { /** * Rendering one tile, by simply calling {@link GLAutoDrawable#display()}. * - * @throws IllegalStateException if no {@link GLAutoDrawable} is {@link #attachToAutoDrawable(GLAutoDrawable) attached} + * @throws IllegalStateException if no {@link GLAutoDrawable} is {@link #attachAutoDrawable(GLAutoDrawable) attached} * or imageSize is not set */ public void display(int tX, int tY, int tWidth, int tHeight) throws IllegalStateException { diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java index 266909470..7c57627e9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java @@ -137,7 +137,7 @@ public class TileRenderer extends TileRendererBase { private int rowOrder = TR_BOTTOM_TO_TOP; private int rows; private int columns; - private int currentTile = -1; + private int currentTile = -1; private int currentRow; private int currentColumn; private int offsetX; @@ -269,6 +269,8 @@ public class TileRenderer extends TileRendererBase { assert rows >= 0; } + /* pp */ final int getCurrentTile() { return currentTile; } + /** * Returns true if all tiles have been rendered or {@link #setup()} * has not been called, otherwise false. diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index 74e1df316..5b3644f59 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -67,9 +67,9 @@ import jogamp.opengl.Debug; * after calling {@link #beginTile(GL)}, See {@link #beginTile(GL)}. *

    *

    - * If {@link #attachToAutoDrawable(GLAutoDrawable) attaching to} an {@link GLAutoDrawable}, - * the {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int)} method - * is being called after {@link #beginTile(GL)}. + * If {@link #attachAutoDrawable(GLAutoDrawable) attaching to} an {@link GLAutoDrawable}, + * the {@link TileRendererListener#reshapeTile(TileRendererBase, int, int, int, int, int, int)} method + * is being called after {@link #beginTile(GL)} for each rendered tile. * It's implementation shall reshape the PMV matrix according to {@link #beginTile(GL)}. *

    *
    GL Profile Requirement
    @@ -118,15 +118,97 @@ public abstract class TileRendererBase { /* pp */ static final boolean DEBUG = Debug.debug("TileRenderer"); /** - * Notifies {@link GLEventListener} implementing this interface - * that the owning {@link GLAutoDrawable} is {@link TileRendererBase#attachToAutoDrawable(GLAutoDrawable) attached} - * to a tile renderer or {@link TileRendererBase#detachFromAutoDrawable() detached} from it. + * Listener for tile renderer events, intended to extend {@link GLEventListener} implementations, + * enabling tile rendering via {@link TileRendererBase#attachAutoDrawable(GLAutoDrawable)}. */ - public static interface TileRendererNotify { - /** The owning {@link GLAutoDrawable} is {@link TileRendererBase#attachToAutoDrawable(GLAutoDrawable) attached} to a {@link TileRendererBase}. */ + public static interface TileRendererListener { + /** + * The owning {@link GLAutoDrawable} is {@link TileRendererBase#attachAutoDrawable(GLAutoDrawable) attached} + * to the given {@link TileRendererBase} instance. + *

    + * The {@link GLContext} of the {@link TileRendererBase}'s {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable} + * is not current. + *

    + * @param tr the associated {@link TileRendererBase} + * @see TileRendererBase#getAttachedDrawable() + */ public void addTileRendererNotify(TileRendererBase tr); - /** The owning {@link GLAutoDrawable} is {@link TileRendererBase#detachFromAutoDrawable() detached} from a {@link TileRendererBase}. */ + + /** + * The owning {@link GLAutoDrawable} is {@link TileRendererBase#detachAutoDrawable() detached} + * from the given {@link TileRendererBase} instance. + *

    + * The {@link GLContext} of the {@link TileRendererBase}'s {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable} + * is not current. + *

    + * @param tr the disassociated {@link TileRendererBase} + * @see TileRendererBase#getAttachedDrawable() + */ public void removeTileRendererNotify(TileRendererBase tr); + + /** + * Called by the {@link TileRendererBase} during tile-rendering via an + * {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable}'s + * {@link GLAutoDrawable#display()} call for each tile before {@link #display(GLAutoDrawable)}. + *

    + * The PMV Matrix shall be reshaped + * according to the given + *

      + *
    • current tile-position
    • + *
    • current tile-size
    • + *
    • final image-size
    • + *
    + * The GL viewport is already set to origin 0/0 and the current tile-size.
    + * See details in {@link TileRendererBase#beginTile(GL)}.
    + *

    + *

    + * The {@link GLContext} of the {@link TileRendererBase}'s {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable} + * is current. + *

    + * @param tr the issuing {@link TileRendererBase} + * @param tileX the {@link TileRendererBase#TR_CURRENT_TILE_X_POS current tile's x-pos} + * @param tileY the {@link TileRendererBase#TR_CURRENT_TILE_Y_POS current tile's y-pos} + * @param tileWidth the {@link TileRendererBase#TR_CURRENT_TILE_WIDTH current tile's width} + * @param tileHeight the {@link TileRendererBase#TR_CURRENT_TILE_HEIGHT current tile's height} + * @param imageWidth the {@link TileRendererBase#TR_IMAGE_WIDTH final image width} + * @param imageHeight the {@link TileRendererBase#TR_IMAGE_HEIGHT final image height} + * @see TileRendererBase#getAttachedDrawable() + */ + public void reshapeTile(TileRendererBase tr, + int tileX, int tileY, int tileWidth, int tileHeight, + int imageWidth, int imageHeight); + + /** + * Called by the {@link TileRendererBase} during tile-rendering + * after {@link TileRendererBase#beginTile(GL)} and before {@link #reshapeTile(TileRendererBase, int, int, int, int, int, int) reshapeTile(..)}. + *

    + * If {@link TileRendererBase} is of type {@link TileRenderer}, + * method is called for the first tile of all tiles.
    + * Otherwise, i.e. {@link RandomTileRenderer}, method is called for each particular tile. + *

    + *

    + * The {@link GLContext} of the {@link TileRenderer}'s {@link TileRenderer#getAttachedDrawable() attached} {@link GLAutoDrawable} + * is current. + *

    + * @param tr the issuing {@link TileRendererBase} + */ + public void startTileRendering(TileRendererBase tr); + + /** + * Called by the {@link TileRenderer} during tile-rendering + * after {@link TileRendererBase#endTile(GL)} and {@link GLAutoDrawable#swapBuffers()}. + *

    + * If {@link TileRendererBase} is of type {@link TileRenderer}, + * method is called for the last tile of all tiles.
    + * Otherwise, i.e. {@link RandomTileRenderer}, method is called for each particular tile. + *

    + *

    + * The {@link GLContext} of the {@link TileRenderer}'s {@link TileRenderer#getAttachedDrawable() attached} {@link GLAutoDrawable} + * is current. + *

    + * @param tr the issuing {@link TileRendererBase} + */ + public void endTileRendering(TileRendererBase tr); } protected final Dimension imageSize = new Dimension(0, 0); @@ -246,13 +328,13 @@ public abstract class TileRendererBase { *
      *
    • x 0
    • *
    • y 0
    • - *
    • {@link #TR_CURRENT_TILE_WIDTH tile width}
    • - *
    • {@link #TR_CURRENT_TILE_HEIGHT tile height}
    • + *
    • {@link #TR_CURRENT_TILE_WIDTH current tile's width}
    • + *
    • {@link #TR_CURRENT_TILE_HEIGHT current tile's height}
    • *
    - *
  • {@link #TR_CURRENT_TILE_X_POS tile x-pos}
  • - *
  • {@link #TR_CURRENT_TILE_Y_POS tile y-pos}
  • - *
  • {@link #TR_IMAGE_WIDTH image width}
  • - *
  • {@link #TR_IMAGE_HEIGHT image height}
  • + *
  • {@link #TR_CURRENT_TILE_X_POS current tile's x-pos}
  • + *
  • {@link #TR_CURRENT_TILE_Y_POS current tile's y-pos}
  • + *
  • {@link #TR_IMAGE_WIDTH final image width}
  • + *
  • {@link #TR_IMAGE_HEIGHT final image height}
  • * *

    *

    @@ -311,12 +393,12 @@ public abstract class TileRendererBase { } /** - * Attaches this renderer to the {@link GLAutoDrawable}. + * Attaches the given {@link GLAutoDrawable} to this tile renderer. + *

    + * The {@link GLAutoDrawable}'s original {@link GLEventListener} are moved to this tile renderer. + *

    *

    - * The {@link GLAutoDrawable}'s original {@link GLEventListener} are moved to this tile renderer.
    - * It is highly recommended that the original {@link GLEventListener} implement - * {@link TileRendererNotify}, so they get {@link TileRendererNotify#addTileRendererNotify(TileRendererBase) notified} - * about this event. + * {@link GLEventListeners} not implementing {@link TileRendererListener} are ignored while tile rendering. *

    *

    * The {@link GLAutoDrawable}'s {@link GLAutoDrawable#getAutoSwapBufferMode() auto-swap mode} is cached @@ -324,15 +406,15 @@ public abstract class TileRendererBase { * see {@link #reqPreSwapBuffers(GLCapabilitiesImmutable)}. *

    *

    - * This tile renderer's {@link GLEventListener} is then added to handle the tile rendering, - * replacing the original {@link GLEventListener}.
    - * This {@link GLEventListener#display(GLAutoDrawable) display} implementations issues: + * This tile renderer's internal {@link GLEventListener} is then added to the attached {@link GLAutoDrawable} + * to handle the tile rendering, replacing the original {@link GLEventListener}.
    + * It's {@link GLEventListener#display(GLAutoDrawable) display} implementations issues: *

      *
    • Optional {@link #setGLEventListener(GLEventListener, GLEventListener) pre-glel}.{@link GLEventListener#display(GLAutoDrawable) display(..)}
    • *
    • {@link #beginTile(GL)}
    • - *
    • for all original {@link GLEventListener}: + *
    • for all original {@link TileRendererListener}: *
        - *
      • {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(0, 0, tile-width, tile-height)}
      • + *
      • {@link TileRendererListener#reshapeTile(TileRendererBase, int, int, int, int, int, int) reshapeTile(tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight)}
      • *
      • {@link GLEventListener#display(GLAutoDrawable) display(autoDrawable)}
      • *
    • *
    • if ( {@link #reqPreSwapBuffers(GLCapabilitiesImmutable) pre-swap} ) { {@link GLAutoDrawable#swapBuffers() swapBuffers()} }
    • @@ -342,16 +424,6 @@ public abstract class TileRendererBase { *
    *

    *

    - * The PMV Matrix shall be reshaped in the - * original {@link GLEventListener}'s {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method - * according to the tile-position, -size and image-size
    - * The {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method is called for each tile - * w/ the current viewport of tile-size, where the tile-position and image-size can be retrieved by this tile renderer, - * see details in {@link #beginTile(GL)}.
    - * The original {@link GLEventListener} implementing {@link TileRendererNotify} is aware of this - * tile renderer instance. - *

    - *

    * Consider using {@link #setGLEventListener(GLEventListener, GLEventListener)} to add pre- and post * hooks to be performed on this renderer {@link GLEventListener}.
    * The pre-hook is able to allocate memory and setup parameters, since it's called before {@link #beginTile(GL)}.
    @@ -359,13 +431,15 @@ public abstract class TileRendererBase { * since it's called after {@link #endTile(GL)}. *

    *

    - * Call {@link #detachFromAutoDrawable()} to remove this renderer from the {@link GLAutoDrawable} + * Call {@link #detachAutoDrawable()} to remove the attached {@link GLAutoDrawable} from this tile renderer * and to restore it's original {@link GLEventListener}. *

    - * @param glad + * @param glad the {@link GLAutoDrawable} to attach. * @throws IllegalStateException if an {@link GLAutoDrawable} is already attached + * @see #getAttachedDrawable() + * @see #detachAutoDrawable() */ - public void attachToAutoDrawable(GLAutoDrawable glad) throws IllegalStateException { + public final void attachAutoDrawable(GLAutoDrawable glad) throws IllegalStateException { if( null != this.glad ) { throw new IllegalStateException("GLAutoDrawable already attached"); } @@ -379,9 +453,9 @@ public abstract class TileRendererBase { listenersInit[i] = glad.getGLEventListenerInitState(l); listeners[i] = glad.removeGLEventListener( l ); final boolean trn; - if( listeners[i] instanceof TileRendererNotify ) { + if( listeners[i] instanceof TileRendererListener ) { trn = true; - ((TileRendererNotify)listeners[i]).addTileRendererNotify(this); + ((TileRendererListener)listeners[i]).addTileRendererNotify(this); } else { trn = false; } @@ -399,25 +473,34 @@ public abstract class TileRendererBase { } } - /** - * Detaches this renderer from the {@link GLAutoDrawable}. - *

    - * It is highly recommended that the original {@link GLEventListener} implement - * {@link TileRendererNotify}, so they get {@link TileRendererNotify#removeTileRendererNotify(TileRendererBase) notified} - * about this event. - *

    + /** + * Returns a previously {@link #attachAutoDrawable(GLAutoDrawable) attached} {@link GLAutoDrawable}, + * null if none is attached. *

    - * See {@link #attachToAutoDrawable(GLAutoDrawable)}. + * If called from {@link TileRendererListener#addTileRendererNotify(TileRendererBase)} + * or {@link TileRendererListener#removeTileRendererNotify(TileRendererBase)}, method returns the + * just attached or soon to be detached {@link GLAutoDrawable}. *

    + * @see #attachAutoDrawable(GLAutoDrawable) + * @see #detachAutoDrawable() + */ + public final GLAutoDrawable getAttachedDrawable() { + return glad; + } + + /** + * Detaches the given {@link GLAutoDrawable} from this tile renderer. + * @see #attachAutoDrawable(GLAutoDrawable) + * @see #getAttachedDrawable() */ - public void detachFromAutoDrawable() { + public final void detachAutoDrawable() { if( null != glad ) { glad.removeGLEventListener(tiledGLEL); final int aSz = listenersInit.length; for(int i=0; i * Sets the renderer to {@link TileRenderer#TR_TOP_TO_BOTTOM} row order. @@ -241,11 +241,11 @@ public class AWTTilePainter { } /** - * Disposes resources and {@link TileRenderer#detachFromAutoDrawable() detaches} + * Disposes resources and {@link TileRenderer#detachAutoDrawable() detaches} * the {@link TileRenderer}'s {@link GLAutoDrawable}. */ public void dispose() { - renderer.detachFromAutoDrawable(); // tile-renderer -> printGLAD + renderer.detachAutoDrawable(); // tile-renderer -> printGLAD g2d = null; if( null != tBuffer ) { tBuffer.dispose(); diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index eadb69ec2..b2a4ef7d3 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -526,7 +526,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); - printAWTTiles.renderer.attachToAutoDrawable(printGLAD); + printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java index 05332c614..811e91886 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java @@ -1,7 +1,9 @@ package com.jogamp.opengl.test.junit.jogl.demos.es1; import com.jogamp.common.nio.Buffers; + import java.nio.*; + import javax.media.opengl.*; import javax.media.opengl.fixedfunc.GLMatrixFunc; import javax.media.opengl.fixedfunc.GLPointerFunc; @@ -10,7 +12,7 @@ import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.util.TileRendererBase; import com.jogamp.opengl.util.glsl.fixedfunc.*; -public class RedSquareES1 implements GLEventListener, TileRendererBase.TileRendererNotify { +public class RedSquareES1 implements GLEventListener, TileRendererBase.TileRendererListener { public static boolean oneThread = false; public static boolean useAnimator = false; @@ -37,15 +39,26 @@ public class RedSquareES1 implements GLEventListener, TileRendererBase.TileRende this.swapInterval = 1; } + @Override public void addTileRendererNotify(TileRendererBase tr) { tileRendererInUse = tr; doRotateBeforePrinting = doRotate; setDoRotation(false); } + @Override public void removeTileRendererNotify(TileRendererBase tr) { tileRendererInUse = null; setDoRotation(doRotateBeforePrinting); } + @Override + public void startTileRendering(TileRendererBase tr) { + System.err.println("RedSquareES1.startTileRendering: "+tr); + } + @Override + public void endTileRendering(TileRendererBase tr) { + System.err.println("RedSquareES1.endTileRendering: "+tr); + } + public void setDoRotation(boolean rotate) { this.doRotate = rotate; } public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) { this.forceFFPEmu = forceFFPEmu; @@ -64,6 +77,7 @@ public class RedSquareES1 implements GLEventListener, TileRendererBase.TileRende private FloatBuffer colors; private FloatBuffer vertices; + @Override public void init(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" RedSquareES1.init ..."); GL _gl = drawable.getGL(); @@ -122,33 +136,31 @@ public class RedSquareES1 implements GLEventListener, TileRendererBase.TileRende System.err.println(Thread.currentThread()+" RedSquareES1.init FIN"); } + @Override public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { - System.err.println(Thread.currentThread()+" RedSquareES1.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(glad.getHandle())+", tileRendererInUse "+tileRendererInUse); - GL2ES1 gl = glad.getGL().getGL2ES1(); - gl.setSwapInterval(swapInterval); + final GL2ES1 gl = glad.getGL().getGL2ES1(); + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); + } + reshapeImpl(gl, x, y, width, height, width, height); + } + + @Override + public void reshapeTile(TileRendererBase tr, + int tileX, int tileY, int tileWidth, int tileHeight, + int imageWidth, int imageHeight) { + final GL2ES1 gl = tr.getAttachedDrawable().getGL().getGL2ES1(); + gl.setSwapInterval(0); + reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); + } + + void reshapeImpl(GL2ES1 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { + System.err.println(Thread.currentThread()+" RedSquareES1.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", tileRendererInUse "+tileRendererInUse); // Set location in front of camera gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glLoadIdentity(); - final int tileWidth = width; - final int tileHeight = height; - final int tileX, tileY, imageWidth, imageHeight; - if( null == tileRendererInUse ) { - if(-1 != swapInterval) { - gl.setSwapInterval(swapInterval); - } - tileX = 0; - tileY = 0; - imageWidth = width; - imageHeight = height; - } else { - gl.setSwapInterval(0); - tileX = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); - tileY = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); - imageWidth = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_WIDTH); - imageHeight = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_HEIGHT); - } // compute projection parameters 'normal' perspective final float fovy=45f; final float aspect2 = ( (float) imageWidth / (float) imageHeight ) / aspect; @@ -174,6 +186,7 @@ public class RedSquareES1 implements GLEventListener, TileRendererBase.TileRende System.err.println(Thread.currentThread()+" RedSquareES1.reshape FIN"); } + @Override public void display(GLAutoDrawable drawable) { curTime = System.currentTimeMillis(); GL2ES1 gl = drawable.getGL().getGL2ES1(); @@ -202,6 +215,7 @@ public class RedSquareES1 implements GLEventListener, TileRendererBase.TileRende gl.glDisableClientState(GLPointerFunc.GL_COLOR_ARRAY); } + @Override public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" RedSquareES1.dispose ... "); GL2ES1 gl = drawable.getGL().getGL2ES1(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 273d5c4e9..bea761a35 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -34,6 +34,7 @@ import com.jogamp.opengl.util.TileRendererBase; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; + import java.nio.FloatBuffer; import javax.media.nativewindow.NativeWindow; @@ -49,7 +50,7 @@ import javax.media.opengl.GLUniformData; * GearsES2.java
    * @author Brian Paul (converted to Java by Ron Cemer and Sven Gothel)

    */ -public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererNotify { +public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererListener { private final FloatBuffer lightPos = Buffers.newDirectFloatBuffer( new float[] { 5.0f, 5.0f, 10.0f } ); private ShaderState st = null; @@ -84,15 +85,25 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN this.swapInterval = 1; } + @Override public void addTileRendererNotify(TileRendererBase tr) { tileRendererInUse = tr; doRotateBeforePrinting = doRotate; setDoRotation(false); } + @Override public void removeTileRendererNotify(TileRendererBase tr) { tileRendererInUse = null; setDoRotation(doRotateBeforePrinting); } + @Override + public void startTileRendering(TileRendererBase tr) { + System.err.println("GearsES2.startTileRendering: "+tr); + } + @Override + public void endTileRendering(TileRendererBase tr) { + System.err.println("GearsES2.endTileRendering: "+tr); + } public void setIgnoreFocus(boolean v) { ignoreFocus = v; } public void setDoRotation(boolean rotate) { this.doRotate = rotate; } @@ -136,6 +147,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN public GearsObjectES2 getGear3() { return gear3; } + @Override public void init(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES2.init: tileRendererInUse "+tileRendererInUse); final GL2ES2 gl = drawable.getGL().getGL2ES2(); @@ -233,18 +245,29 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN System.err.println(Thread.currentThread()+" GearsES2.init FIN"); } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - final GL2ES2 gl = drawable.getGL().getGL2ES2(); + @Override + public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { + final GL2ES2 gl = glad.getGL().getGL2ES2(); + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); + } + reshapeImpl(gl, x, y, width, height, width, height); + } + + @Override + public void reshapeTile(TileRendererBase tr, + int tileX, int tileY, int tileWidth, int tileHeight, + int imageWidth, int imageHeight) { + final GL2ES2 gl = tr.getAttachedDrawable().getGL().getGL2ES2(); + gl.setSwapInterval(0); + reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); + } + + void reshapeImpl(GL2ES2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers(); - System.err.println(Thread.currentThread()+" GearsES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); - - drawableHeight = height; + System.err.println(Thread.currentThread()+" GearsES2.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); + drawableHeight = imageHeight; - // Thread.dumpStack(); - - if(-1 != swapInterval) { - gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) - } if( !gl.hasGLSL() ) { return; } @@ -253,23 +276,6 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); pmvMatrix.glLoadIdentity(); - final int tileWidth = width; - final int tileHeight = height; - final int tileX, tileY, imageWidth, imageHeight; - if( null == tileRendererInUse ) { - gl.setSwapInterval(swapInterval); - tileX = 0; - tileY = 0; - imageWidth = width; - imageHeight = height; - } else { - gl.setSwapInterval(0); - tileX = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); - tileY = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); - imageWidth = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_WIDTH); - imageHeight = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_HEIGHT); - } - // compute projection parameters 'normal' float left, right, bottom, top; if( imageHeight > imageWidth ) { @@ -312,6 +318,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN } // private boolean useAndroidDebug = false; + @Override public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES2.dispose: tileRendererInUse "+tileRendererInUse); final Object upstreamWidget = drawable.getUpstreamWidget(); @@ -339,6 +346,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN System.err.println(Thread.currentThread()+" GearsES2.dispose FIN"); } + @Override public void display(GLAutoDrawable drawable) { GLAnimatorControl anim = drawable.getAnimator(); if( verbose && ( null == anim || !anim.isAnimating() ) ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index 40e9876ea..715a97d63 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -34,13 +34,14 @@ import com.jogamp.opengl.util.TileRendererBase; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; + import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLUniformData; -public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRendererNotify { +public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRendererListener { private ShaderState st; private PMVMatrix pmvMatrix; private GLUniformData pmvMatrixUniform; @@ -62,19 +63,31 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende this.swapInterval = 1; } + @Override public void addTileRendererNotify(TileRendererBase tr) { tileRendererInUse = tr; doRotateBeforePrinting = doRotate; setDoRotation(false); } + @Override public void removeTileRendererNotify(TileRendererBase tr) { tileRendererInUse = null; setDoRotation(doRotateBeforePrinting); } + @Override + public void startTileRendering(TileRendererBase tr) { + System.err.println("RedSquareES2.startTileRendering: "+tr); + } + @Override + public void endTileRendering(TileRendererBase tr) { + System.err.println("RedSquareES2.endTileRendering: "+tr); + } + public void setAspect(float aspect) { this.aspect = aspect; } public void setDoRotation(boolean rotate) { this.doRotate = rotate; } public void setClearBuffers(boolean v) { clearBuffers = v; } + @Override public void init(GLAutoDrawable glad) { System.err.println(Thread.currentThread()+" RedSquareES2.init: tileRendererInUse "+tileRendererInUse); final GL2ES2 gl = glad.getGL().getGL2ES2(); @@ -138,6 +151,7 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende System.err.println(Thread.currentThread()+" RedSquareES2.init FIN"); } + @Override public void display(GLAutoDrawable glad) { long t1 = System.currentTimeMillis(); @@ -174,10 +188,27 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende st.useProgram(gl, false); } + @Override public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { - System.err.println(Thread.currentThread()+" RedSquareES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(glad.getHandle())+", tileRendererInUse "+tileRendererInUse); - // Thread.dumpStack(); final GL2ES2 gl = glad.getGL().getGL2ES2(); + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); + } + reshapeImpl(gl, x, y, width, height, width, height); + } + + @Override + public void reshapeTile(TileRendererBase tr, + int tileX, int tileY, int tileWidth, int tileHeight, + int imageWidth, int imageHeight) { + final GL2ES2 gl = tr.getAttachedDrawable().getGL().getGL2ES2(); + gl.setSwapInterval(0); + reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); + } + + void reshapeImpl(GL2ES2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { + System.err.println(Thread.currentThread()+" RedSquareES2.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", tileRendererInUse "+tileRendererInUse); + // Thread.dumpStack(); if( !gl.hasGLSL() ) { return; } @@ -187,24 +218,6 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); pmvMatrix.glLoadIdentity(); - final int tileWidth = width; - final int tileHeight = height; - final int tileX, tileY, imageWidth, imageHeight; - if( null == tileRendererInUse ) { - if(-1 != swapInterval) { - gl.setSwapInterval(swapInterval); - } - tileX = 0; - tileY = 0; - imageWidth = width; - imageHeight = height; - } else { - gl.setSwapInterval(0); - tileX = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); - tileY = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); - imageWidth = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_WIDTH); - imageHeight = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_HEIGHT); - } // compute projection parameters 'normal' perspective final float fovy=45f; final float aspect2 = ( (float) imageWidth / (float) imageHeight ) / aspect; @@ -233,6 +246,7 @@ public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRende System.err.println(Thread.currentThread()+" RedSquareES2.reshape FIN"); } + @Override public void dispose(GLAutoDrawable glad) { System.err.println(Thread.currentThread()+" RedSquareES2.dispose: tileRendererInUse "+tileRendererInUse); final GL2ES2 gl = glad.getGL().getGL2ES2(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java index 110dfb779..74089c2fd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java @@ -26,7 +26,7 @@ import com.jogamp.opengl.util.TileRendererBase; * * This version is equal to Brian Paul's version 1.2 1999/10/21 */ -public class Gears implements GLEventListener, TileRendererBase.TileRendererNotify { +public class Gears implements GLEventListener, TileRendererBase.TileRendererListener { private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; private int gear1=0, gear2=0, gear3=0; private float angle = 0.0f; @@ -49,15 +49,25 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti this.swapInterval = 1; } + @Override public void addTileRendererNotify(TileRendererBase tr) { tileRendererInUse = tr; doRotateBeforePrinting = doRotate; setDoRotation(false); } + @Override public void removeTileRendererNotify(TileRendererBase tr) { tileRendererInUse = null; setDoRotation(doRotateBeforePrinting); } + @Override + public void startTileRendering(TileRendererBase tr) { + System.err.println("Gears.startTileRendering: "+tr); + } + @Override + public void endTileRendering(TileRendererBase tr) { + System.err.println("Gears.endTileRendering: "+tr); + } public void setDoRotation(boolean rotate) { doRotate = rotate; } public void setVerbose(boolean v) { verbose = v; } @@ -83,6 +93,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti */ public int getGear3() { return gear3; } + @Override public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); @@ -154,14 +165,31 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti gl.glEnable(GL2.GL_NORMALIZE); } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - GL2 gl = drawable.getGL().getGL2(); - this.reshape(gl, x, y, width, height); + @Override + public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { + final GL2 gl = glad.getGL().getGL2(); + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); + } + reshapeImpl(gl, x, y, width, height, width, height); } - + public void reshape(GL2 gl, int x, int y, int width, int height) { + reshapeImpl(gl, x, y, width, height, width, height); + } + + @Override + public void reshapeTile(TileRendererBase tr, + int tileX, int tileY, int tileWidth, int tileHeight, + int imageWidth, int imageHeight) { + final GL2 gl = tr.getAttachedDrawable().getGL().getGL2(); + gl.setSwapInterval(0); + reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); + } + + void reshapeImpl(GL2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers(); - System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); + System.err.println(Thread.currentThread()+" Gears.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); if( msaa ) { gl.glEnable(GL.GL_MULTISAMPLE); @@ -171,23 +199,6 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti gl.glLoadIdentity(); - final int tileWidth = width; - final int tileHeight = height; - final int tileX, tileY, imageWidth, imageHeight; - if( null == tileRendererInUse ) { - gl.setSwapInterval(swapInterval); - tileX = 0; - tileY = 0; - imageWidth = width; - imageHeight = height; - } else { - gl.setSwapInterval(0); - tileX = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); - tileY = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); - imageWidth = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_WIDTH); - imageHeight = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_HEIGHT); - } - // compute projection parameters 'normal' float left, right, bottom, top; if( imageHeight > imageWidth ) { @@ -228,6 +239,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti } } + @Override public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" Gears.dispose: tileRendererInUse "+tileRendererInUse); try { @@ -241,6 +253,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti setGears(0, 0, 0); } + @Override public void display(GLAutoDrawable drawable) { // Get the GL corresponding to the drawable we are animating GL2 gl = drawable.getGL().getGL2(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java index 09817a27f..d539b5e55 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java @@ -107,7 +107,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { // Initialize the tile rendering library final RandomTileRenderer renderer = new RandomTileRenderer(); - renderer.attachToAutoDrawable(glad); + renderer.attachAutoDrawable(glad); renderer.setImageSize(imageWidth, imageHeight); final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; @@ -146,7 +146,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { } } - renderer.detachFromAutoDrawable(); + renderer.detachAutoDrawable(); // Restore viewport and Gear's PMV matrix // .. even though we close the demo, this is for documentation! diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java index 16f11d85b..7d3f1f622 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java @@ -196,7 +196,7 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { } catch (IOException e) { e.printStackTrace(); } - renderer.detachFromAutoDrawable(); + renderer.detachAutoDrawable(); System.err.println("XXX post-display detached: "+renderer); drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); glad.getGLEventListener(0).reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); @@ -224,7 +224,7 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { signalTileRenderer = false; // tile rendering ! System.err.println("XXX START TILE RENDERING"); - renderer.attachToAutoDrawable(glad); + renderer.attachAutoDrawable(glad); } Thread.sleep(100); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java index 26ac34d5a..f0819a43d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java @@ -188,7 +188,7 @@ public class TestTiledRendering2NEWT extends UITestCase { final TileRenderer renderer = new TileRenderer(); renderer.setImageSize(imageWidth, imageHeight); renderer.setTileSize(glad.getWidth(), glad.getHeight(), 0); - renderer.attachToAutoDrawable(glad); + renderer.attachAutoDrawable(glad); final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; final boolean[] flipVertically = { false }; @@ -219,7 +219,7 @@ public class TestTiledRendering2NEWT extends UITestCase { renderer.display(); } while ( !renderer.eot() ); - renderer.detachFromAutoDrawable(); + renderer.detachAutoDrawable(); // Restore viewport and Gear's PMV matrix // .. even though we close the demo, this is for documentation! -- cgit v1.2.3 From c943c8cfc39df64ec6682722e86a54c538d3497b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 28 Sep 2013 01:48:45 +0200 Subject: Fix AWT Printing: Use delegated GLDrawable's size for tile-size instead of AWT-GLAD's size, since the latter uses AWT's component size. .. the AWT component size could have been modified after setupPrinting(..). The AWT-GLAD getWidth() and getHeight() is implemented by AWT's component and hence may not reflect the actual GLDrawable size while printing. --- src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 9 ++++----- src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 6 ++++-- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 7 +++++-- 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index b7c8c42f9..379d9cdfe 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -44,7 +44,6 @@ import java.beans.Beans; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; - import java.awt.Canvas; import java.awt.Color; import java.awt.FontMetrics; @@ -55,7 +54,6 @@ import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.Rectangle2D; - import java.awt.EventQueue; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; @@ -70,7 +68,6 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; - import javax.media.opengl.GL; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; @@ -782,13 +779,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); } + final GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); - printAWTTiles.renderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); + printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); - System.err.println("AWT print.setup "+printGLAD); + System.err.println("AWT print.setup printGLAD: "+printGLAD.getWidth()+"x"+printGLAD.getHeight()+", "+printGLAD); + System.err.println("AWT print.setup printDraw: "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+", "+printDrawable); } } }; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index e52317041..c639da367 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -557,13 +557,15 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); } + final GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); - printAWTTiles.renderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); + printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); - System.err.println("AWT print.setup "+printGLAD); + System.err.println("AWT print.setup printGLAD: "+printGLAD.getWidth()+"x"+printGLAD.getHeight()+", "+printGLAD); + System.err.println("AWT print.setup printDraw: "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+", "+printDrawable); } } }; diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index b2a4ef7d3..b069daacd 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -52,6 +52,7 @@ import javax.media.nativewindow.WindowClosingProtocol; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.swing.MenuSelectionManager; @@ -524,13 +525,15 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); } + final GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); - printAWTTiles.renderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); + printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); - System.err.println("AWT print.setup "+printGLAD); + System.err.println("AWT print.setup printGLAD: "+printGLAD.getWidth()+"x"+printGLAD.getHeight()+", "+printGLAD); + System.err.println("AWT print.setup printDraw: "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+", "+printDrawable); } } }; -- cgit v1.2.3 From fe284b515d984198fdbe702837809f181625a457 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 28 Sep 2013 04:03:04 +0200 Subject: AWT Printing: releasePrint() issue reshape from AWT-EDT; GLJPanel: Issue 'handleReshape' if panelSize/awtSize mismatch, otherwise 'sendReshape' and exception if offscreen size doesn't match panelSize. --- .../classes/javax/media/opengl/awt/GLCanvas.java | 4 +-- .../classes/javax/media/opengl/awt/GLJPanel.java | 40 ++++++++++++++++------ .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 1 - .../test/junit/jogl/tile/TiledPrintingAWTBase.java | 13 +++++++ 4 files changed, 44 insertions(+), 14 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 379d9cdfe..f86a6a347 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -799,8 +799,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } sendReshape = false; // clear reshape flag AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, releasePrintOnEDT); - sendReshape = true; // trigger reshape, i.e. gl-viewport and -listener - this component might got resized! - display(); } private final Runnable releasePrintOnEDT = new Runnable() { @Override @@ -819,7 +817,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printAnimator.add(GLCanvas.this); printAnimator = null; } + sendReshape = true; // trigger reshape, i.e. gl-viewport and -listener - this component might got resized! printActive = false; + display(); } }; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index c639da367..01270dd4f 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -434,14 +434,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // involve destroying the pbuffer (current context) and // re-creating it -- tricky to do properly while the context is // current - if (handleReshape) { - handleReshape = false; - sendReshape = handleReshape(); - } - - if( isVisible() && !printActive ) { - updater.setGraphics(g); - backend.doPaintComponent(g); + if( !printActive ) { + if (handleReshape) { + handleReshape = false; + sendReshape = handleReshape(); + } + + if( isVisible() ) { + updater.setGraphics(g); + backend.doPaintComponent(g); + } } } @@ -578,10 +580,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing sendReshape = false; // clear reshape flag handleReshape = false; // ditto AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, releasePrintOnEDT); - sendReshape = true; // trigger reshape, i.e. gl-viewport and -listener - this component might got resized! - handleReshape = true; // ditto - display(); } + private final Runnable releasePrintOnEDT = new Runnable() { @Override public void run() { @@ -599,7 +599,22 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printAnimator.add(GLJPanel.this); printAnimator = null; } + + // trigger reshape, i.e. gl-viewport and -listener - this component might got resized! + final int awtWidth = GLJPanel.this.getWidth(); + final int awtHeight= GLJPanel.this.getHeight(); + if( panelWidth != awtWidth || panelHeight != awtHeight ) { + if ( true || DEBUG ) { + System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0: reshape " +panelWidth+"x"+panelHeight + " -> " + awtWidth+"x"+awtHeight); + } + reshapeWidth = awtWidth; + reshapeHeight = awtHeight; + handleReshape = true; // complete resize, sendReshape will be set later + } else { + sendReshape = true; // only GL reshape + } printActive = false; + display(); } }; @@ -1415,6 +1430,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: panelSize "+panelWidth+"x"+panelHeight); } } + if( offscreenDrawable.getWidth() != panelWidth || offscreenDrawable.getHeight() != panelHeight ) { + throw new InternalError("OffscreenDrawable panelSize mismatch (reshape missed): panelSize "+panelWidth+"x"+panelHeight+" != drawable "+offscreenDrawable.getWidth()+"x"+offscreenDrawable.getHeight()+", on thread "+getThreadName()); + } final IntBuffer readBackInts; if( !flipVertical || null != glslTextureRaster ) { diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index b069daacd..55f5f0533 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -546,7 +546,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto // sendReshape = false; // clear reshape flag AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, releasePrintOnEDT); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener - } private final Runnable releasePrintOnEDT = new Runnable() { @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java index 8393cf978..1ec748805 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java @@ -177,6 +177,8 @@ public abstract class TiledPrintingAWTBase extends UITestCase { } } + static final boolean resizeAfterSetupPrint = false; + private void doPrintImpl(final PrintableBase printable) { final double scaleGLMatXY = 72.0 / printable.dpi; System.err.println("PRINTable: "+printable.getClass().getSimpleName()); @@ -187,7 +189,18 @@ public abstract class TiledPrintingAWTBase extends UITestCase { AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { try { + final int w = printable.cont.getWidth(); + final int h = printable.cont.getHeight(); + if( resizeAfterSetupPrint ) { + printable.cont.setSize(w+64, h+64); + printable.cont.validate(); + } printable.job.print(); + if( resizeAfterSetupPrint ) { + printable.cont.repaint(); + printable.cont.setSize(w, h); + printable.cont.validate(); + } } catch (PrinterException ex) { ex.printStackTrace(); } -- cgit v1.2.3 From 61e47c5683ef038d8684bce56714ae0a514dd697 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 4 Oct 2013 21:08:45 +0200 Subject: Bug 816/848: Cleanup test applet layout/size ; Note Bug 848: Not reproducible after restart of OSX test machine! --- jnlp-files/jogl-applet-bug816_glcanvas02.html | 32 -------- jnlp-files/jogl-applet-bug816_glcanvas02a.html | 32 ++++++++ jnlp-files/jogl-applet-bug816_glcanvas02b.html | 32 ++++++++ jnlp-files/jogl-applet-bug848_glcanvas01.html | 4 +- jnlp-files/jogl-test-applets.html | 4 +- .../jogamp/newt/awt/applet/JOGLNewtApplet1Run.java | 6 +- .../jogl/demos/es2/awt/Bug816AppletGLCanvas02.java | 80 ------------------- .../demos/es2/awt/Bug816AppletGLCanvas02a.java | 89 ++++++++++++++++++++++ .../demos/es2/awt/Bug816AppletGLCanvas02b.java | 89 ++++++++++++++++++++++ .../jogl/demos/es2/awt/Bug848AppletGLCanvas01.java | 14 +++- 10 files changed, 261 insertions(+), 121 deletions(-) delete mode 100644 jnlp-files/jogl-applet-bug816_glcanvas02.html create mode 100644 jnlp-files/jogl-applet-bug816_glcanvas02a.html create mode 100644 jnlp-files/jogl-applet-bug816_glcanvas02b.html delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02a.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02b.java (limited to 'src/newt/classes') diff --git a/jnlp-files/jogl-applet-bug816_glcanvas02.html b/jnlp-files/jogl-applet-bug816_glcanvas02.html deleted file mode 100644 index f4958ec1b..000000000 --- a/jnlp-files/jogl-applet-bug816_glcanvas02.html +++ /dev/null @@ -1,32 +0,0 @@ - - - -Bug816 OSX CALayer Pos - Box Layout - - - -

    -Bug816 OSX CALayer Pos - Box Layout -

    - -

    - - - - - - Sorry, no Java support detected. - - - -

    - - diff --git a/jnlp-files/jogl-applet-bug816_glcanvas02a.html b/jnlp-files/jogl-applet-bug816_glcanvas02a.html new file mode 100644 index 000000000..79fb22d76 --- /dev/null +++ b/jnlp-files/jogl-applet-bug816_glcanvas02a.html @@ -0,0 +1,32 @@ + + + +Bug816 OSX CALayer Pos - Box Layout + + + +

    +Bug816 OSX CALayer Pos - Box Layout +

    + +

    + + + + + + Sorry, no Java support detected. + + + +

    + + diff --git a/jnlp-files/jogl-applet-bug816_glcanvas02b.html b/jnlp-files/jogl-applet-bug816_glcanvas02b.html new file mode 100644 index 000000000..eb05e84a5 --- /dev/null +++ b/jnlp-files/jogl-applet-bug816_glcanvas02b.html @@ -0,0 +1,32 @@ + + + +Bug816 OSX CALayer Pos - Grid Layout + + + +

    +Bug816 OSX CALayer Pos - Grid Layout +

    + +

    + + + + + + Sorry, no Java support detected. + + + +

    + + diff --git a/jnlp-files/jogl-applet-bug848_glcanvas01.html b/jnlp-files/jogl-applet-bug848_glcanvas01.html index bc6e90dc2..99fa6aa4d 100644 --- a/jnlp-files/jogl-applet-bug848_glcanvas01.html +++ b/jnlp-files/jogl-applet-bug848_glcanvas01.html @@ -11,14 +11,14 @@ Bug 848: Applet on OSX w/ CALayer and 2 or more GLCanvas may 'crash'.

    + width="1024" height="664"> 01: Custom bounds within applet -
  • 02: Box layout within applet
  • +
  • 02a: Box layout within applet
  • +
  • 02b: Grid layout within applet
  • Misc Issues
  • diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java index 83a129455..c7153840f 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java @@ -252,9 +252,9 @@ public class JOGLNewtApplet1Run extends Applet { System.err.println("GLWindow: "+glWindow); } base.start(); - if( null != newtCanvasAWT && - newtCanvasAWT.isOffscreenLayerSurfaceEnabled() && - 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) { + if( null != newtCanvasAWT && + newtCanvasAWT.isOffscreenLayerSurfaceEnabled() && + 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) { // force relayout final int cW = newtCanvasAWT.getWidth(); final int cH = newtCanvasAWT.getHeight(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java deleted file mode 100644 index 161f05c8d..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.jogl.demos.es2.awt; - -import java.applet.Applet; - -import javax.media.opengl.GLAnimatorControl; -import javax.media.opengl.awt.GLCanvas; -import javax.swing.BoxLayout; - -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.util.Animator; - -/** - * Bug 816: OSX CALayer Positioning Bug. - *

    - * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 - *

    - *

    - * Test uses a box layout within the Applet. - *

    - */ -@SuppressWarnings("serial") -public class Bug816AppletGLCanvas02 extends Applet { - GLAnimatorControl animator; - - @Override - public void init() { - System.err.println("GearsApplet: init() - begin"); - animator = new Animator(); - new BoxLayout(this, BoxLayout.X_AXIS); - setSize(600, 300); - add(createCanvas()); - add(createCanvas()); - System.err.println("GearsApplet: init() - end"); - } - - private GLCanvas createCanvas() { - GLCanvas canvas = new GLCanvas(); - canvas.addGLEventListener(new GearsES2(1)); - canvas.setSize(300, 300); - animator.add(canvas); - return canvas; - } - - @Override - public void start() { - animator.start(); - } - - @Override - public void stop() { - animator.stop(); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02a.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02a.java new file mode 100644 index 000000000..3bbb423fd --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02a.java @@ -0,0 +1,89 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es2.awt; + +import java.applet.Applet; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.BoxLayout; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.util.Animator; + +/** + * Bug 816: OSX CALayer Positioning Bug. + *

    + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

    + *

    + * Test uses a box layout within the Applet. + *

    + */ +@SuppressWarnings("serial") +public class Bug816AppletGLCanvas02a extends Applet { + GLAnimatorControl animator; + boolean added = false; + + @Override + public void init() { + System.err.println("GearsApplet: init() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + animator = new Animator(); + new BoxLayout(this, BoxLayout.X_AXIS); + setSize(664, 364); + add(createCanvas()); + add(createCanvas()); + System.err.println("GearsApplet: init() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + } + + private GLCanvas createCanvas() { + GLCanvas canvas = new GLCanvas(); + canvas.addGLEventListener(new GearsES2(1)); + canvas.setSize(300, 300); + animator.add(canvas); + return canvas; + } + + String currentThreadName() { + return Thread.currentThread().getName(); + } + + @Override + public void start() { + System.err.println("GearsApplet: start() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + animator.start(); + animator.setUpdateFPSFrames(60, System.err); + System.err.println("GearsApplet: start() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + } + + @Override + public void stop() { + System.err.println("GearsApplet: stop() - [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + animator.stop(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02b.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02b.java new file mode 100644 index 000000000..87a7ea4f5 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02b.java @@ -0,0 +1,89 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es2.awt; + +import java.applet.Applet; +import java.awt.GridLayout; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.awt.GLCanvas; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.util.Animator; + +/** + * Bug 816: OSX CALayer Positioning Bug. + *

    + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

    + *

    + * Test uses a grid layout within the Applet. + *

    + */ +@SuppressWarnings("serial") +public class Bug816AppletGLCanvas02b extends Applet { + GLAnimatorControl animator; + boolean added = false; + + @Override + public void init() { + System.err.println("GearsApplet: init() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + animator = new Animator(); + this.setLayout(new GridLayout(1, 2)); + setSize(664, 364); + add(createCanvas()); + add(createCanvas()); + System.err.println("GearsApplet: init() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + } + + private GLCanvas createCanvas() { + GLCanvas canvas = new GLCanvas(); + canvas.addGLEventListener(new GearsES2(1)); + canvas.setSize(300, 300); + animator.add(canvas); + return canvas; + } + + String currentThreadName() { + return Thread.currentThread().getName(); + } + + @Override + public void start() { + System.err.println("GearsApplet: start() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + animator.start(); + animator.setUpdateFPSFrames(60, System.err); + System.err.println("GearsApplet: start() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + } + + @Override + public void stop() { + System.err.println("GearsApplet: stop() - [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + animator.stop(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug848AppletGLCanvas01.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug848AppletGLCanvas01.java index 7b7b4e4c4..89e31cfe9 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug848AppletGLCanvas01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug848AppletGLCanvas01.java @@ -50,16 +50,16 @@ public class Bug848AppletGLCanvas01 extends Applet { @Override public void init() { - System.err.println("GearsApplet: init() - begin"); + System.err.println("GearsApplet: init() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); new BoxLayout(this, BoxLayout.X_AXIS); - setSize(900, 600); + setSize(1024, 664); add(createCanvas()); add(createCanvas()); add(createCanvas()); add(createCanvas()); add(createCanvas()); add(createCanvas()); - System.err.println("GearsApplet: init() - end"); + System.err.println("GearsApplet: init() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); } private GLCanvas createCanvas() { @@ -70,15 +70,23 @@ public class Bug848AppletGLCanvas01 extends Applet { return canvas; } + String currentThreadName() { + return Thread.currentThread().getName(); + } + @Override public void start() { + System.err.println("GearsApplet: start() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); for (GLAnimatorControl control : animators) { control.start(); + control.setUpdateFPSFrames(60, System.err); } + System.err.println("GearsApplet: start() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); } @Override public void stop() { + System.err.println("GearsApplet: stop() - [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); for (GLAnimatorControl control : animators) { control.stop(); } -- cgit v1.2.3 From 929cae9a5ba01a382d17387ff289d74ee029f090 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 7 Oct 2013 07:41:30 +0200 Subject: NEWT/Fullscreen (Bug 836): Exit re-parenting fullscreen w/ [invisible-exit-visible] (-> like reparent); Always force focus; X11: Always use ALWAYSONTOP. - Remove unused 'fullscreenUseSpanningMode' state - Exit re-parenting fullscreen w/ [invisible-exit-visible] (-> like reparent) solves X11 issue, where the NEWT window doesn't 'return to it's parent'. Probably also fixes Bug 836! - Always force focus when enter and exit FS - X11: Always use ALWAYSONTOP No reason to behave different (spanning and normal-fs) --- make/scripts/tests.sh | 6 +-- src/newt/classes/jogamp/newt/WindowImpl.java | 53 +++++++++++++--------- .../jogamp/newt/driver/x11/WindowDriver.java | 2 +- 3 files changed, 36 insertions(+), 25 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 81f89d531..5c693f33c 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -144,7 +144,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Screen" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -298,7 +298,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -457,7 +457,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index caa461e41..a2338b93d 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -154,7 +154,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private boolean fullscreen = false, brokenFocusChange = false; private List fullscreenMonitors = null; private boolean fullscreenUseMainMonitor = true; - private boolean fullscreenUseSpanningMode = true; // spanning mode: fake full screen, only on certain platforms private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user) private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets @@ -273,7 +272,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreen = false; fullscreenMonitors = null; fullscreenUseMainMonitor = true; - fullscreenUseSpanningMode = false; hasFocus = false; parentWindowHandle = 0; } @@ -1051,7 +1049,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreen = false; fullscreenMonitors = null; fullscreenUseMainMonitor = true; - fullscreenUseSpanningMode = false; hasFocus = false; parentWindowHandle = 0; @@ -1903,6 +1900,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // set current state WindowImpl.this.fullscreen = fullscreen; + final int oldX = getX(); + final int oldY = getY(); + final int oldWidth = getWidth(); + final int oldHeight = getHeight(); + int x,y,w,h; final RectangleImmutable sviewport = screen.getViewport(); @@ -1920,23 +1922,20 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors); if( isReconfigureFlagSupported(FLAG_IS_FULLSCREEN_SPAN) && ( fullscreenMonitors.size() > 1 || sviewport.compareTo(viewport) > 0 ) ) { - fullscreenUseSpanningMode = true; fs_span_flag = FLAG_IS_FULLSCREEN_SPAN; } else { - fullscreenUseSpanningMode = false; fs_span_flag = 0; } - nfs_x = getX(); - nfs_y = getY(); - nfs_width = getWidth(); - nfs_height = getHeight(); + nfs_x = oldX; + nfs_y = oldY; + nfs_width = oldWidth; + nfs_height = oldHeight; x = viewport.getX(); y = viewport.getY(); w = viewport.getWidth(); h = viewport.getHeight(); } else { fullscreenUseMainMonitor = true; - fullscreenUseSpanningMode = false; fullscreenMonitors = null; fs_span_flag = 0; viewport = null; @@ -1962,16 +1961,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ ", virtl-screenSize: "+sviewport+", monitorsViewport "+viewport+ - ", spanning "+fullscreenUseSpanningMode+" @ "+Thread.currentThread().getName()); + ", spanning "+(0!=fs_span_flag)+" @ "+Thread.currentThread().getName()); } final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date final boolean wasVisible = isVisible(); - + // Lock parentWindow only during reparenting (attempt) final NativeWindow parentWindowLocked; if( null != parentWindow ) { + if(wasVisible && !fullscreen) { // fullscreen-off -> !visible first (fixes unsuccessful return to parent window) + setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight); + WindowImpl.this.waitForVisible(false, false); + // FIXME: Some composite WM behave slacky .. give 'em chance to change state -> invisible, + // even though we do exactly that (KDE+Composite) + try { Thread.sleep(100); } catch (InterruptedException e) { } + display.dispatchMessagesNative(); // status up2date + } parentWindowLocked = parentWindow; if( NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindowLocked.lockSurface() ) { throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow); @@ -1982,7 +1989,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer try { reconfigureWindowImpl(x, y, w, h, getReconfigureFlags( ( ( null != parentWindowLocked ) ? FLAG_CHANGE_PARENTING : 0 ) | - fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, wasVisible) ); + fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, isVisible()) ); } finally { if(null!=parentWindowLocked) { parentWindowLocked.unlockSurface(); @@ -1992,11 +1999,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(wasVisible) { setVisibleImpl(true, x, y, w, h); - WindowImpl.this.waitForVisible(true, false); - display.dispatchMessagesNative(); // status up2date - WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); + boolean ok = 0 <= WindowImpl.this.waitForVisible(true, false); + if(ok) { + ok = WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); + } + if(ok) { + requestFocusInt(fullscreen /* skipFocusAction */); + display.dispatchMessagesNative(); // status up2date + } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window fs done: " + WindowImpl.this); + System.err.println("Window fs done: ok " + ok + ", " + WindowImpl.this); } } } finally { @@ -2021,13 +2033,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer synchronized(fullScreenAction) { fullscreenMonitors = monitors; fullscreenUseMainMonitor = useMainMonitor; - fullscreenUseSpanningMode = false; if( fullScreenAction.init(fullscreen) ) { if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { // enable fullscreen on offscreen instance if(null != parentWindow) { nfs_parent = parentWindow; - reparentWindow(null, true); + reparentWindow(null, true /* forceDestroyCreate */); } else { throw new InternalError("Offscreen instance w/o parent unhandled"); } @@ -2037,11 +2048,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(!fullScreenAction.fsOn() && null != nfs_parent) { // disable fullscreen on offscreen instance - reparentWindow(nfs_parent, true); + reparentWindow(nfs_parent, true /* forceDestroyCreate */); nfs_parent = null; } - if( fullscreen && isVisible() ) { // force focus on fullscreen + if( isVisible() ) { // force focus requestFocus(true /* wait */, true /* skipFocusAction */, true /* force */); } } diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 4786ea04f..806dd270c 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -163,7 +163,7 @@ public class WindowDriver extends WindowImpl { _y = y; } if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags ) ) { - if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 != ( FLAG_IS_FULLSCREEN_SPAN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) { + if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) { tempFSAlwaysOnTop = true; flags |= FLAG_IS_ALWAYSONTOP; if(DEBUG_IMPLEMENTATION) { -- cgit v1.2.3 From c2a4905ec926362a08f486a68d428fb139821df1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 7 Oct 2013 07:47:12 +0200 Subject: NEWT/OSX (Bug 836): Lifecycle operations performed on main-thread must be synchronized (wait-until-done) Wait-until-done (main thread): - WindowDriver.close0(..) - WindowDriver.initWindow0(..) Otherwise a re-queued operation (i.e. CALayer attachment) will mixup the order .. Experienced w/ fullscreen exit. --- .../jogamp/newt/driver/macosx/WindowDriver.java | 27 +++++----- src/newt/native/MacWindow.m | 59 +++++++++++++--------- 2 files changed, 48 insertions(+), 38 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 6aebf0410..d973c9005 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -86,7 +86,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl sscSurfaceHandle = 0; isOffscreenInstance = false; if (0 != handle) { - OSXUtil.RunOnMainThread(false, new Runnable() { + OSXUtil.RunOnMainThread(true, new Runnable() { public void run() { close0( handle ); } } ); @@ -452,27 +452,28 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final PointImmutable pS, final int width, final int height, final boolean fullscreen, final boolean visible, final boolean alwaysOnTop) { + final long parentWinHandle = getParentWindowHandle(); + final long preWinHandle = getWindowHandle(); + if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.createWindow on thread "+Thread.currentThread().getName()+ ": offscreen "+offscreenInstance+", recreate "+recreate+ ", pS "+pS+", "+width+"x"+height+", fullscreen "+fullscreen+", visible "+visible+ - ", alwaysOnTop "+alwaysOnTop); + ", alwaysOnTop "+alwaysOnTop+", preWinHandle "+toHexString(preWinHandle)+", parentWin "+toHexString(parentWinHandle)+ + ", surfaceHandle "+toHexString(surfaceHandle)); // Thread.dumpStack(); } try { - final long parentWin = getParentWindowHandle(); - if( 0 != getWindowHandle() ) { - final long thisWin = getWindowHandle(); + if( 0 != preWinHandle ) { setWindowHandle(0); - if( 0 == surfaceHandle ) { throw new NativeWindowException("Internal Error - create w/ window, but no Newt NSView"); } - OSXUtil.RunOnMainThread(false, new Runnable() { + OSXUtil.RunOnMainThread(true, new Runnable() { public void run() { - changeContentView0(parentWin, thisWin, 0); - close0( thisWin ); + changeContentView0(parentWinHandle, preWinHandle, 0); + close0( preWinHandle ); } } ); } else { if( 0 != surfaceHandle ) { @@ -494,13 +495,13 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl setWindowHandle( newWin ); final boolean isOpaque = getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance; - // Non blocking initialization on main-thread! - OSXUtil.RunOnMainThread(false, new Runnable() { + // Blocking initialization on main-thread! + OSXUtil.RunOnMainThread(true, new Runnable() { public void run() { - initWindow0( parentWin, newWin, pS.getX(), pS.getY(), width, height, + initWindow0( parentWinHandle, newWin, pS.getX(), pS.getY(), width, height, isOpaque, fullscreen, visible && !offscreenInstance, surfaceHandle); if( offscreenInstance ) { - orderOut0(0!=parentWin ? parentWin : newWin); + orderOut0(0!=parentWinHandle ? parentWinHandle : newWin); } else { setTitle0(newWin, getTitle()); setAlwaysOnTop0(getWindowHandle(), alwaysOnTop); diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 1c7064a66..f8988cf15 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -764,27 +764,27 @@ NS_ENDHANDLER // specify we want mouse-moved events [myWindow setAcceptsMouseMovedEvents:YES]; - DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", - dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n", + dbgIdx++, myWindow, myView, [myWindow isVisible]); // Set the content view changeContentView(env, jthis, parentView, myWindow, myView, NO); - DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", - dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n", + dbgIdx++, myWindow, myView, [myWindow isVisible]); if(NULL!=parentWindow) { [myWindow attachToParent: parentWindow]; } - DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d, visible %d\n", - dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible], visible); + DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d, visible %d\n", + dbgIdx++, myWindow, myView, [myWindow isVisible], visible); // Immediately re-position this window based on an upper-left coordinate system setWindowClientTopLeftPointAndSize(myWindow, x, y, w, h, NO); - DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", - dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n", + dbgIdx++, myWindow, myView, [myWindow isVisible]); NS_DURING // concurrent view rendering @@ -793,8 +793,8 @@ NS_DURING [myWindow setAllowsConcurrentViewDrawing: YES]; } - DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", - dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n", + dbgIdx++, myWindow, myView, [myWindow isVisible]); if ( [myView respondsToSelector:@selector(setCanDrawConcurrently:)] ) { [myView setCanDrawConcurrently: YES]; @@ -802,16 +802,16 @@ NS_DURING NS_HANDLER NS_ENDHANDLER - DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", - dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n", + dbgIdx++, myWindow, myView, [myWindow isVisible]); // visible on front if( visible ) { [myWindow orderFront: myWindow]; } - DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", - dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n", + dbgIdx++, myWindow, myView, [myWindow isVisible]); // force surface creation // [myView lockFocus]; @@ -831,16 +831,18 @@ NS_ENDHANDLER // right mouse button down events [myView setNextResponder: myWindow]; - DBG_PRINT( "initWindow0.X - %p (this), %p (parent): new window: %p, view %p,%d\n", - (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView, getRetainCount(myView)); + DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n", + dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView); [myView setDestroyNotifySent: false]; setJavaWindowObject(env, jthis, myView, YES); - DBG_PRINT( "initWindow0.X - %p (this), %p (parent): new window: %p, view %p,%d\n", - (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView, getRetainCount(myView)); + DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n", + dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView); [pool release]; + DBG_PRINT( "initWindow0.X - %p (this), %p (parent): new window: %p, view %p\n", + (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView); } /** @@ -857,14 +859,23 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window); NewtView* mView = (NewtView *)[mWin contentView]; NSWindow* pWin = [mWin parentWindow]; - BOOL destroyNotifySent = (NULL != mView) ? [mView getDestroyNotifySent] : false; + BOOL destroyNotifySent, isNSView, isNewtView; + if( NULL != mView ) { + isNSView = [mView isKindOfClass:[NSView class]]; + isNewtView = [mView isKindOfClass:[NewtView class]]; + destroyNotifySent = isNewtView ? [mView getDestroyNotifySent] : false; + } else { + isNSView = false; + isNewtView = false; + destroyNotifySent = false; + } - DBG_PRINT( "windowClose.0 - %p,%d, destroyNotifySent %d, view %p,%d, parent %p\n", - mWin, getRetainCount(mWin), destroyNotifySent, mView, getRetainCount(mView), pWin); + DBG_PRINT( "windowClose.0 - %p, destroyNotifySent %d, view %p [isNSView %d, isNewtView %d], parent %p\n", + mWin, destroyNotifySent, mView, isNSView, isNewtView, pWin); [mWin setRealized: NO]; - if(NULL!=mView) { + if( isNewtView ) { // cleanup view [mView setDestroyNotifySent: true]; setJavaWindowObject(env, NULL, mView, NO); @@ -892,8 +903,7 @@ NS_ENDHANDLER } [mWin orderOut: mWin]; - DBG_PRINT( "windowClose.1 - %p,%d view %p,%d, parent %p\n", - mWin, getRetainCount(mWin), mView, getRetainCount(mView), pWin); + DBG_PRINT( "windowClose.1 - %p view %p, parent %p\n", mWin, mView, pWin); // Only release window, if release is not yet in process. // E.g. destroyNotifySent:=true set by NewtMacWindow::windowWillClose(), i.e. window-close was clicked. @@ -953,7 +963,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_requestFocus0 #ifdef VERBOSE_ON BOOL hasFocus = [mWin isKeyWindow]; #endif - DBG_PRINT( "requestFocus - window: %p, force %d, hasFocus %d (START)\n", mWin, force, hasFocus); [mWin makeFirstResponder: nil]; -- cgit v1.2.3 From 88291cd5e20fc8b172f1d78a683be7d2bdec807a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 9 Oct 2013 01:53:53 +0200 Subject: NEWT/OSX (Bug 836): Only WindowDriver.initWindow0(..) operation on main-thread must be synchronized (wait-until-done) - Leave WindowDriver.close0(..) w/o sync --- .../jogamp/newt/driver/macosx/WindowDriver.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index d973c9005..08638d868 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -86,7 +86,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl sscSurfaceHandle = 0; isOffscreenInstance = false; if (0 != handle) { - OSXUtil.RunOnMainThread(true, new Runnable() { + OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { close0( handle ); } } ); @@ -159,14 +159,17 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected void setTitleImpl(final String title) { - OSXUtil.RunOnMainThread(false, new Runnable() { - public void run() { - setTitle0(getWindowHandle(), title); - } } ); + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + setTitle0(getWindowHandle(), title); + } } ); } @Override protected void requestFocusImpl(final boolean force) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow: requestFocusImpl(), isOffscreenInstance "+isOffscreenInstance); + } if(!isOffscreenInstance) { OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { @@ -414,13 +417,15 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl short _keySym = KeyEvent.NULL_CHAR != keySymChar ? KeyEvent.utf16ToVKey(keySymChar) : KeyEvent.VK_UNDEFINED; keySym = KeyEvent.VK_UNDEFINED != _keySym ? _keySym : keyCode; } - /* { + /** + { final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+ ", keyCode 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)+ ", keySymChar '"+keySymChar+"', 0x"+Integer.toHexString(keySymChar)+" -> 0x"+Integer.toHexString(keySym)+ ", mods "+toHexString(modifiers)+ - ", was: pressed "+isKeyPressed(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + ", was: pressed "+isKeyPressed(keyCode)+", isModifierKeyCode "+isModifierKeyCode+ + ", nativeValid "+isNativeValid()+", isOffscreen "+isOffscreenInstance); } */ // OSX delivery order is PRESSED (t0), RELEASED (t1) and TYPED (t2) -> NEWT order: PRESSED (t0) and RELEASED (t1) @@ -470,7 +475,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( 0 == surfaceHandle ) { throw new NativeWindowException("Internal Error - create w/ window, but no Newt NSView"); } - OSXUtil.RunOnMainThread(true, new Runnable() { + OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { changeContentView0(parentWinHandle, preWinHandle, 0); close0( preWinHandle ); -- cgit v1.2.3 From 56502090ba5c2e0c266666a4ba3ddd501e9ad95f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 9 Oct 2013 02:10:19 +0200 Subject: NEWT Display: Issue EDTUtil.start() at runOnEDTIfAvail(..) even if on EDT, which is to be stopped. This case appears on e.g. OSX/CALayer (offscreen) reparenting using recreation (onscreen <-> offscreen), i.e. display destroy/create is performed on EDT. Misc Cleanup: - Rename EDTUtil: restart() -> start() - Rename Display: validateEDT() -> validateEDTStopped() - Simplify Display.setEDTUtil(..): Remove need for redundant 'newEDTUtil' local var. - Simplify Display.runOnEDTIfAvail(..): edtUtil is never null --- src/newt/classes/com/jogamp/newt/Display.java | 2 +- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 2 +- src/newt/classes/com/jogamp/newt/util/EDTUtil.java | 10 ++-- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 6 ++- src/newt/classes/jogamp/newt/DisplayImpl.java | 54 ++++++++++------------ .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 2 +- src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java | 2 +- .../junit/newt/TestDisplayLifecycle01NEWT.java | 2 +- 8 files changed, 40 insertions(+), 40 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index c618405c2..382a5d583 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -78,7 +78,7 @@ public abstract class Display { * Stop the running EDT in case this display is destroyed already.
    * @return true if EDT has been stopped (destroyed but running), otherwise false. */ - public abstract boolean validateEDT(); + public abstract boolean validateEDTStopped(); /** * @return true if the native display handle is valid and ready to operate, diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 47dfca0f3..2fa83e0e2 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -346,7 +346,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { { final Display newtDisplay = newtChild.getScreen().getDisplay(); final EDTUtil edtUtil = new SWTEDTUtil(newtDisplay, getDisplay()); - edtUtil.restart(); + edtUtil.start(); newtDisplay.setEDTUtil( edtUtil ); } diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index e86df2084..52ca95682 100644 --- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -65,10 +65,10 @@ public interface EDTUtil { public void setPollPeriod(long ms); /** - * Starts or restarts the EDT. + * Starts the EDT after it's creation or after {@link #invokeStop(boolean, Runnable) stopping}. *

    - * If the EDT is running, it must be stopped first via {@link #invokeStop(boolean, Runnable)} - * and the caller should wait until it's stopped via {@link #waitUntilStopped()}. + * If the EDT is running, it must be {@link #invokeStop(boolean, Runnable) stopped} first + * and the caller should wait {@link #waitUntilStopped() until it's stopped}. *

    * * @return true if EDT has been successfully restarted, otherwise false @@ -77,7 +77,7 @@ public interface EDTUtil { * @see #invokeStop(boolean, java.lang.Runnable) * @see #waitUntilStopped() */ - public boolean restart() throws IllegalStateException; + public boolean start() throws IllegalStateException; /** * Returns true if the current thread is the event dispatch thread (EDT). @@ -130,7 +130,7 @@ public interface EDTUtil { *
  • All previous queued tasks will be finished.
  • *
  • No new tasks are allowed, an Exception is thrown.
  • *
  • Can be issued from within EDT, ie from within an enqueued task.
  • - *
  • {@link #restart()} may follow immediately, ie creating a new EDT
  • + *
  • {@link #start()} may follow immediately, ie creating a new EDT
  • * *

    * @return true if task has been executed or queued for later execution, otherwise false diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index 5794d4ae9..3d1037ad5 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -77,7 +77,7 @@ public class DefaultEDTUtil implements EDTUtil { } @Override - public final boolean restart() throws IllegalStateException { + public final boolean start() throws IllegalStateException { synchronized(edtLock) { if( edt.isRunning() ) { throw new IllegalStateException("EDT still running and not subject to stop. Curr "+Thread.currentThread().getName()+", EDT "+edt.getName()+", isRunning "+edt.isRunning+", shouldStop "+edt.shouldStop); @@ -135,6 +135,10 @@ public class DefaultEDTUtil implements EDTUtil { @Override public final boolean invokeStop(boolean wait, Runnable task) { + if(DEBUG) { + System.err.println(Thread.currentThread()+": Default-EDT.invokeStop wait "+wait); + Thread.dumpStack(); + } return invokeImpl(wait, task, true); } diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 8f792b23c..0f47c87a0 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -170,7 +170,7 @@ public abstract class DisplayImpl extends Display { if(NewtFactory.useEDT()) { def = new DefaultEDTUtil(Thread.currentThread().getThreadGroup(), "Display-"+getFQName(), dispatchMessagesRunnable); if(DEBUG) { - System.err.println("Display.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName()); + System.err.println("Display.createEDTUtil("+getFQName()+"): "+def.getClass().getName()); } } else { def = null; @@ -181,21 +181,18 @@ public abstract class DisplayImpl extends Display { @Override public synchronized EDTUtil setEDTUtil(final EDTUtil usrEDTUtil) { final EDTUtil oldEDTUtil = edtUtil; - final EDTUtil newEDTUtil; if( null != usrEDTUtil && usrEDTUtil == oldEDTUtil ) { if( DEBUG ) { System.err.println("Display.setEDTUtil: "+usrEDTUtil+" - keep!"); } - newEDTUtil = oldEDTUtil; - } else { - if(DEBUG) { - final String msg = ( null == usrEDTUtil ) ? "default" : "custom"; - System.err.println("Display.setEDTUtil("+msg+"): "+oldEDTUtil+" -> "+usrEDTUtil); - } - stopEDT( oldEDTUtil, null ); - newEDTUtil = ( null == usrEDTUtil ) ? createEDTUtil() : usrEDTUtil; + return oldEDTUtil; + } + if(DEBUG) { + final String msg = ( null == usrEDTUtil ) ? "default" : "custom"; + System.err.println("Display.setEDTUtil("+msg+"): "+oldEDTUtil+" -> "+usrEDTUtil); } - edtUtil = newEDTUtil; + stopEDT( oldEDTUtil, null ); + edtUtil = ( null == usrEDTUtil ) ? createEDTUtil() : usrEDTUtil; return oldEDTUtil; } @@ -224,31 +221,30 @@ public abstract class DisplayImpl extends Display { public void runOnEDTIfAvail(boolean wait, final Runnable task) { final EDTUtil _edtUtil = edtUtil; - if( null != _edtUtil && !_edtUtil.isCurrentThreadEDT() ) { - if( !_edtUtil.isRunning() ) { // start EDT if not running yet - synchronized( this ) { - if( !_edtUtil.isRunning() ) { // // volatile dbl-checked-locking OK - _edtUtil.restart(); - if( DEBUG ) { - System.err.println("Info: EDT started "+Thread.currentThread().getName()+", "+this); - Thread.dumpStack(); - } + if( !_edtUtil.isRunning() ) { // start EDT if not running yet + synchronized( this ) { + if( !_edtUtil.isRunning() ) { // // volatile dbl-checked-locking OK + if( DEBUG ) { + System.err.println("Info: EDT start "+Thread.currentThread().getName()+", "+this); + Thread.dumpStack(); } + _edtUtil.start(); } } - if( !_edtUtil.invoke(wait, task) ) { - if( DEBUG ) { - System.err.println("Warning: invoke(wait "+wait+", ..) on EDT failed .. invoke on current thread "+Thread.currentThread().getName()); - Thread.dumpStack(); - } - task.run(); + } + if( !_edtUtil.isCurrentThreadEDT() ) { + if( _edtUtil.invoke(wait, task) ) { + return; // done + } + if( DEBUG ) { + System.err.println("Warning: invoke(wait "+wait+", ..) on EDT failed .. invoke on current thread "+Thread.currentThread().getName()); + Thread.dumpStack(); } - } else { - task.run(); } + task.run(); } - public boolean validateEDT() { + public boolean validateEDTStopped() { if( 0==refCount && null == aDevice ) { final EDTUtil _edtUtil = edtUtil; if( null != _edtUtil && _edtUtil.isRunning() ) { diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 80c72c008..02f4be0cd 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -68,7 +68,7 @@ public class AWTEDTUtil implements EDTUtil { } @Override - public final boolean restart() throws IllegalStateException { + public final boolean start() throws IllegalStateException { synchronized(edtLock) { if( nedt.isRunning() ) { throw new IllegalStateException("EDT still running and not subject to stop. Curr "+Thread.currentThread().getName()+", NEDT "+nedt.getName()+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop+", on AWT-EDT "+EventQueue.isDispatchThread()); diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java index d46562050..6024195e3 100644 --- a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java @@ -77,7 +77,7 @@ public class SWTEDTUtil implements EDTUtil { } @Override - public final boolean restart() throws IllegalStateException { + public final boolean start() throws IllegalStateException { final boolean swtDisposed = swtDisplay.isDisposed(); synchronized(edtLock) { if( nedt.isRunning() ) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java index a3ea9ad3e..b007f57f3 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestDisplayLifecycle01NEWT.java @@ -208,7 +208,7 @@ public class TestDisplayLifecycle01NEWT extends UITestCase { final EDTUtil edtUtil = display.getEDTUtil(); Assert.assertNotNull(edtUtil); Assert.assertEquals(false,edtUtil.isRunning()); - edtUtil.restart(); + edtUtil.start(); edtUtil.invoke(true, null); Assert.assertEquals(true,edtUtil.isRunning()); edtUtil.invokeStop(true, null); -- cgit v1.2.3 From 8be1fc983e584082b9960b4da19c56af5834d08e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 9 Oct 2013 05:24:45 +0200 Subject: NEWT Reparent/Fullscreen: Fixes X11 unsuccessful return to parent window; Add reparentWindow(..) top-level position arguments; Misc - Fixes X11 unsuccessful return to parent window On X11 when returning to parent window (-> CHILD), we have to set the window invisible and wait for the result. Otherwise it sometimes happens that the WM's reparent operation fails, i.e. the window won't become a child of desired parent and is positioned randomly. - Add reparentWindow(..) top-level position arguments .. allows bringing the child-window to top-level w/ a desired position. Otherwise the window would be positioned elsewhere as a top-level as the plain reparenting operation. X11 needs to set position and size _after_ making the window visible, otherwise WM may ignore the XConfigureWindow request. - Reparent recreate shall always store the desired position and size On OSX/CALayer when recreation is being used, we need to store the pos/size for later creation. - Tests: Use 'NewtAWTReparentingKeyAdapter' where possible (reparent/fullscreen) instead of duplicating such code. NewtAWTReparentingKeyAdapter: Performs reparenting and fullscreen operations off-thread (i.e. not on AWT/NEW EDT) while decorating the action w/ revoking/restoring the ExclusiveContextThread (ECT). Manually tested 'TestGearsES2NewtCanvasAWT' reparenting and fullscreen on X11, Windows and OSX/CALayer w/ JDK 7u40 successful. --- make/scripts/tests-x64-dbg.bat | 4 +- make/scripts/tests.sh | 3 +- src/newt/classes/com/jogamp/newt/Window.java | 19 +++- .../classes/com/jogamp/newt/opengl/GLWindow.java | 4 +- src/newt/classes/jogamp/newt/WindowImpl.java | 95 ++++++++++-------- src/newt/native/X11Window.c | 6 +- .../acore/TestOffscreenLayer02NewtCanvasAWT.java | 2 +- .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 53 +--------- .../es2/newt/TestLandscapeES2NewtCanvasAWT.java | 53 +--------- .../parenting/NewtAWTReparentingKeyAdapter.java | 111 ++++++++++++++------- .../junit/newt/parenting/TestParenting01NEWT.java | 8 +- .../junit/newt/parenting/TestParenting03AWT.java | 4 +- .../TestParentingFocusTraversal01AWT.java | 2 +- 13 files changed, 170 insertions(+), 194 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 3447605c7..c1a14c1a2 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -48,8 +48,8 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" "-Djogl.debug.TileRenderer.PNG" -set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" -REM set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" +set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5c693f33c..4bafdf15d 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -144,7 +144,6 @@ function jrun() { #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Screen" - D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -194,6 +193,8 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index f63c03738..8a43ef153 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -351,10 +351,27 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * @param newParent The new parent NativeWindow. If null, this Window becomes a top level window. * * @return The issued reparent action type (strategy) as defined in Window.ReparentAction + * @see #reparentWindow(NativeWindow, int, int, boolean) */ ReparentOperation reparentWindow(NativeWindow newParent); - ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate); + /** + * Change this window's parent window.
    + *

    + * In case the old parent is not null and a Window, + * this window is removed from it's list of children.
    + * In case the new parent is not null and a Window, + * this window is added to it's list of children.

    + * + * @param newParent The new parent NativeWindow. If null, this Window becomes a top level window. + * @param x new top-level position, use -1 for default position. + * @param y new top-level position, use -1 for default position. + * @param forceDestroyCreate if true, uses re-creation strategy for reparenting, default is false. + * + * @return The issued reparent action type (strategy) as defined in Window.ReparentAction + * @see #reparentWindow(NativeWindow) + */ + ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate); /** * Enable or disable fullscreen mode for this window. diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 45ab2a44c..eace0f2af 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -390,8 +390,8 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } @Override - public final ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate) { - return window.reparentWindow(newParent, forceDestroyCreate); + public final ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate) { + return window.reparentWindow(newParent, x, y, forceDestroyCreate); } @Override diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index a2338b93d..300ca5c3f 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -414,7 +414,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(postParentlockFocus) { // harmonize focus behavior for all platforms: focus on creation - requestFocusInt(isFullscreen() /* skipFocusAction */); + requestFocusInt(isFullscreen() /* skipFocusAction if fullscreen */); ((DisplayImpl) screen.getDisplay()).dispatchMessagesNative(); // status up2date } if(DEBUG_IMPLEMENTATION) { @@ -1033,7 +1033,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer removeScreenReference(); Display dpy = screen.getDisplay(); if(null != dpy) { - dpy.validateEDT(); + dpy.validateEDTStopped(); } // send synced destroyed notification @@ -1112,12 +1112,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private class ReparentAction implements Runnable { - NativeWindow newParentWindow; + final NativeWindow newParentWindow; + final int topLevelX, topLevelY; boolean forceDestroyCreate; ReparentOperation operation; - private ReparentAction(NativeWindow newParentWindow, boolean forceDestroyCreate) { + private ReparentAction(NativeWindow newParentWindow, int topLevelX, int topLevelY, boolean forceDestroyCreate) { this.newParentWindow = newParentWindow; + this.topLevelX = topLevelX; + this.topLevelY = topLevelY; this.forceDestroyCreate = forceDestroyCreate | DEBUG_TEST_REPARENT_INCOMPATIBLE; this.operation = ReparentOperation.ACTION_INVALID; // ensure it's set } @@ -1144,10 +1147,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private void reparent() { // mirror pos/size so native change notification can get overwritten - int x = getX(); - int y = getY(); - int width = getWidth(); - int height = getHeight(); + final int oldX = getX(); + final int oldY = getY(); + final int oldWidth = getWidth(); + final int oldHeight = getHeight(); + final int x, y; + int width = oldWidth; + int height = oldHeight; boolean wasVisible; final RecursiveLock _lock = windowLock; @@ -1168,10 +1174,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer long newParentWindowHandle = 0 ; if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparent: START ("+getThreadName()+") valid "+isNativeValid()+", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+", visible "+wasVisible+", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow)+", forceDestroyCreate "+forceDestroyCreate+", "+x+"/"+y+" "+width+"x"+height); + System.err.println("Window.reparent: START ("+getThreadName()+") valid "+isNativeValid()+", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+", visible "+wasVisible+", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow)+", forceDestroyCreate "+forceDestroyCreate); } if(null!=newParentWindow) { + // REPARENT TO CHILD WINDOW + // reset position to 0/0 within parent space x = 0; y = 0; @@ -1233,12 +1241,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer operation = ReparentOperation.ACTION_NOP; } } else { - if( null != parentWindow ) { + // REPARENT TO TOP-LEVEL WINDOW + if( 0 <= topLevelX && 0 <= topLevelY ) { + x = topLevelX; + y = topLevelY; + } else if( null != parentWindow ) { // child -> top // put client to current parent+child position final Point p = getLocationOnScreen(null); x = p.getX(); y = p.getY(); + } else { + x = oldX; + y = oldY; } // Case: Top Window @@ -1264,18 +1279,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if ( ReparentOperation.ACTION_INVALID == operation ) { throw new NativeWindowException("Internal Error: reparentAction not set"); } - + + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.reparent: ACTION ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" new parentWindowHandle "+toHexString(newParentWindowHandle)+", reparentAction "+operation+", pos/size "+x+"/"+y+" "+width+"x"+height+", visible "+wasVisible); + } + if( ReparentOperation.ACTION_NOP == operation ) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparent: NO CHANGE ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" new parentWindowHandle "+toHexString(newParentWindowHandle)+", visible "+wasVisible); - } return; } - if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparent: ACTION ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" new parentWindowHandle "+toHexString(newParentWindowHandle)+", reparentAction "+operation+", visible "+wasVisible); - } - // rearrange window tree if(null!=parentWindow && parentWindow instanceof Window) { ((Window)parentWindow).removeChild(WindowImpl.this); @@ -1285,19 +1297,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ((Window)parentWindow).addChild(WindowImpl.this); } - if( ReparentOperation.ACTION_NATIVE_CREATION_PENDING == operation ) { - // make size and position persistent for proper recreation - definePosition(x, y); - defineSize(width, height); - return; - } - if( ReparentOperation.ACTION_NATIVE_REPARENTING == operation ) { final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date - if(wasVisible) { - setVisibleImpl(false, x, y, width, height); + // TOP -> CLIENT: !visible first (fixes X11 unsuccessful return to parent window) + if( null != parentWindow && wasVisible && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { + setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight); WindowImpl.this.waitForVisible(false, false); // FIXME: Some composite WM behave slacky .. give 'em chance to change state -> invisible, // even though we do exactly that (KDE+Composite) @@ -1337,7 +1343,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); } if(ok) { - requestFocusInt(false /* skipFocusAction */); + requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */); display.dispatchMessagesNative(); // status up2date } } @@ -1358,6 +1364,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer destroy( wasVisible ); operation = ReparentOperation.ACTION_NATIVE_CREATION ; } + } else { + // Case + // ACTION_NATIVE_CREATION + // ACTION_NATIVE_CREATION_PENDING; + + // make size and position persistent for proper [re]creation + definePosition(x, y); + defineSize(width, height); } if(DEBUG_IMPLEMENTATION) { @@ -1398,7 +1412,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window.reparentWindow: ReparentActionRecreate ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+Display.hashCodeNullSafe(parentWindow)); } - setVisible(true); // native creation + setVisibleActionImpl(true); // native creation + requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */); } finally { _lock.unlock(); } @@ -1408,11 +1423,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final ReparentOperation reparentWindow(NativeWindow newParent) { - return reparentWindow(newParent, false); + return reparentWindow(newParent, -1, -1, false); } - public ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate) { - final ReparentAction reparentAction = new ReparentAction(newParent, forceDestroyCreate); + @Override + public ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate) { + final ReparentAction reparentAction = new ReparentAction(newParent, x, y, forceDestroyCreate); runOnEDTIfAvail(true, reparentAction); return reparentAction.getOp(); } @@ -1800,7 +1816,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private void requestFocusInt(boolean skipFocusAction) { if( skipFocusAction || !focusAction() ) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.RequestFocusInt: forcing - ("+getThreadName()+"): "+hasFocus+" -> true - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); + System.err.println("Window.RequestFocusInt: forcing - ("+getThreadName()+"): skipFocusAction "+skipFocusAction+", focus "+hasFocus+" -> true - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); } requestFocusImpl(true); } @@ -1971,7 +1987,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Lock parentWindow only during reparenting (attempt) final NativeWindow parentWindowLocked; if( null != parentWindow ) { - if(wasVisible && !fullscreen) { // fullscreen-off -> !visible first (fixes unsuccessful return to parent window) + // fullscreen off: !visible first (fixes X11 unsuccessful return to parent window) + if( !fullscreen && wasVisible && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight); WindowImpl.this.waitForVisible(false, false); // FIXME: Some composite WM behave slacky .. give 'em chance to change state -> invisible, @@ -2004,7 +2021,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ok = WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); } if(ok) { - requestFocusInt(fullscreen /* skipFocusAction */); + requestFocusInt(fullscreen /* skipFocusAction if fullscreen */); display.dispatchMessagesNative(); // status up2date } if(DEBUG_IMPLEMENTATION) { @@ -2038,7 +2055,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // enable fullscreen on offscreen instance if(null != parentWindow) { nfs_parent = parentWindow; - reparentWindow(null, true /* forceDestroyCreate */); + reparentWindow(null, -1, -1, true /* forceDestroyCreate */); } else { throw new InternalError("Offscreen instance w/o parent unhandled"); } @@ -2048,13 +2065,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(!fullScreenAction.fsOn() && null != nfs_parent) { // disable fullscreen on offscreen instance - reparentWindow(nfs_parent, true /* forceDestroyCreate */); + reparentWindow(nfs_parent, -1, -1, true /* forceDestroyCreate */); nfs_parent = null; } - - if( isVisible() ) { // force focus - requestFocus(true /* wait */, true /* skipFocusAction */, true /* force */); - } } return this.fullscreen; } diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index e6e300d2e..f195c5616 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -817,11 +817,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo if( TST_FLAG_IS_VISIBLE(flags) ) { DBG_PRINT( "X11: reconfigureWindow0 VISIBLE ON\n"); XMapRaised(dpy, w); + XSync(dpy, False); + // WM may disregard pos/size XConfigureWindow requests for invisible windows! + DBG_PRINT( "X11: reconfigureWindow0 setPosSize.2 %d/%d %dx%d\n", x, y, width, height); + NewtWindows_setPosSize(dpy, w, x, y, width, height); } else { DBG_PRINT( "X11: reconfigureWindow0 VISIBLE OFF\n"); XUnmapWindow(dpy, w); + XSync(dpy, False); } - XSync(dpy, False); } if( fsEWMHFlags && ( ( TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags) ) || diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java index cea104e2f..5335d858e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java @@ -162,7 +162,7 @@ public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase { } setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); frame1.setSize(frameSize0); setupFrameAndShow(frame1, newtCanvasAWT1); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java index 3fc1eb61d..5d091bb6d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -42,8 +42,6 @@ import com.jogamp.newt.Display; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.awt.NewtCanvasAWT; -import com.jogamp.newt.event.KeyAdapter; -import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; @@ -51,17 +49,14 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; - import com.jogamp.opengl.util.Animator; - import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.newt.parenting.NewtAWTReparentingKeyAdapter; import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; import javax.media.nativewindow.util.DimensionImmutable; - import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLProfile; @@ -271,50 +266,8 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { } }); - glWindow.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent e) { - if( !e.isPrintableKey() || e.isAutoRepeat() ) { - return; - } - if(e.getKeyChar()=='f') { - quitAdapter.enable(false); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); - glWindow.setFullscreen(!glWindow.isFullscreen()); - System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); - glWindow.setExclusiveContextThread(t); - quitAdapter.clear(); - quitAdapter.enable(true); - } }.start(); - } else if(e.getKeyChar()=='r') { - quitAdapter.enable(false); - if(glWindow.getParent()==null) { - System.err.println("XXX glWin to home"); - glWindow.reparentWindow(newtCanvasAWT.getNativeWindow()); - } else { - final InsetsImmutable nInsets = glWindow.getInsets(); - java.awt.Insets aInsets = frame.getInsets(); - System.err.println("XXX glWin to TOP - insets " + nInsets + ", " + aInsets); - glWindow.reparentWindow(null); - int dx, dy; - if(nInsets.getTotalHeight()==0) { - dx = aInsets.left; - dy = aInsets.top; - } else { - dx = nInsets.getLeftWidth(); - dy = nInsets.getTopHeight(); - } - glWindow.setPosition(frame.getX()+frame.getWidth()+dx, frame.getY()+dy); - } - glWindow.requestFocus(); - quitAdapter.clear(); - quitAdapter.enable(true); - } - } - }); - + glWindow.addKeyListener(new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow, quitAdapter)); + if( useAnimator ) { animator.add(glWindow); animator.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java index 37172822b..adc2b23ae 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java @@ -36,23 +36,18 @@ import com.jogamp.newt.Display; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.awt.NewtCanvasAWT; -import com.jogamp.newt.event.KeyAdapter; -import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; - import com.jogamp.opengl.util.Animator; - import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; +import com.jogamp.opengl.test.junit.newt.parenting.NewtAWTReparentingKeyAdapter; import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.DimensionImmutable; - import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLProfile; @@ -119,50 +114,8 @@ public class TestLandscapeES2NewtCanvasAWT extends UITestCase { } }); - glWindow.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent e) { - if( !e.isPrintableKey() || e.isAutoRepeat() ) { - return; - } - if(e.getKeyChar()=='f') { - quitAdapter.enable(false); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); - glWindow.setFullscreen(!glWindow.isFullscreen()); - System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); - glWindow.setExclusiveContextThread(t); - quitAdapter.clear(); - quitAdapter.enable(true); - } }.start(); - } else if(e.getKeyChar()=='r') { - quitAdapter.enable(false); - if(glWindow.getParent()==null) { - System.err.println("XXX glWin to home"); - glWindow.reparentWindow(newtCanvasAWT.getNativeWindow()); - } else { - final InsetsImmutable nInsets = glWindow.getInsets(); - java.awt.Insets aInsets = frame.getInsets(); - System.err.println("XXX glWin to TOP - insets " + nInsets + ", " + aInsets); - glWindow.reparentWindow(null); - int dx, dy; - if(nInsets.getTotalHeight()==0) { - dx = aInsets.left; - dy = aInsets.top; - } else { - dx = nInsets.getLeftWidth(); - dy = nInsets.getTopHeight(); - } - glWindow.setPosition(frame.getX()+frame.getWidth()+dx, frame.getY()+dy); - } - glWindow.requestFocus(); - quitAdapter.clear(); - quitAdapter.enable(true); - } - } - }); - + glWindow.addKeyListener(new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow, quitAdapter)); + if( useAnimator ) { animator.add(glWindow); animator.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 9d08d8ff4..4bf1f95c3 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -35,33 +35,58 @@ import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.util.QuitAdapter; public class NewtAWTReparentingKeyAdapter extends KeyAdapter { - Frame frame; - NewtCanvasAWT newtCanvasAWT; - GLWindow glWindow; + final Frame frame; + final NewtCanvasAWT newtCanvasAWT; + final GLWindow glWindow; + final QuitAdapter quitAdapter; - public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow) { + public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow, QuitAdapter quitAdapter) { this.frame = frame; this.newtCanvasAWT = newtCanvasAWT; this.glWindow = glWindow; + this.quitAdapter = quitAdapter; } public void keyReleased(KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; } - if(e.getKeyChar()=='i') { + if( e.getKeySymbol() == KeyEvent.VK_I ) { System.err.println(glWindow); - } else if(e.getKeyChar()=='d') { - glWindow.setUndecorated(!glWindow.isUndecorated()); - } else if(e.getKeyChar()=='f') { - glWindow.setFullscreen(!glWindow.isFullscreen()); - } else if(e.getKeyChar()=='l') { + } else if( e.getKeySymbol() == KeyEvent.VK_L ) { javax.media.nativewindow.util.Point p0 = newtCanvasAWT.getNativeWindow().getLocationOnScreen(null); javax.media.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null); System.err.println("NewtCanvasAWT position: "+p0+", "+p1); - } else if(e.getKeyChar()=='p') { + } else if( e.getKeySymbol() == KeyEvent.VK_D ) { + glWindow.setUndecorated(!glWindow.isUndecorated()); + } else if( e.getKeySymbol() == KeyEvent.VK_S ) { + if(glWindow.getParent()==null) { + System.err.println("XXX glWin to 100/100"); + glWindow.setPosition(100, 100); + } else { + System.err.println("XXX glWin to 0/0"); + glWindow.setPosition(0, 0); + } + } else if( e.getKeySymbol() == KeyEvent.VK_F ) { + if( null != quitAdapter ) { + quitAdapter.enable(false); + } + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); + glWindow.setFullscreen(!glWindow.isFullscreen()); + System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); + glWindow.setExclusiveContextThread(t); + if( null != quitAdapter ) { + quitAdapter.clear(); + quitAdapter.enable(true); + } + } }.start(); + } else if( e.getKeySymbol() == KeyEvent.VK_P ) { new Thread() { public void run() { if(glWindow.getAnimator().isPaused()) { @@ -71,34 +96,44 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { } } }.run(); - } else if(e.getKeyChar()=='r') { - if(glWindow.getParent()==null) { - System.err.println("XXX glWin to home"); - glWindow.reparentWindow(newtCanvasAWT.getNativeWindow()); - } else { - final InsetsImmutable nInsets = glWindow.getInsets(); - java.awt.Insets aInsets = frame.getInsets(); - System.err.println("XXX glWin to TOP - insets " + nInsets + ", " + aInsets); - glWindow.reparentWindow(null); - int dx, dy; - if(nInsets.getTotalHeight()==0) { - dx = aInsets.left; - dy = aInsets.top; - } else { - dx = nInsets.getLeftWidth(); - dy = nInsets.getTopHeight(); - } - glWindow.setPosition(frame.getX()+frame.getWidth()+dx, frame.getY()+dy); - } - glWindow.requestFocus(); - } else if(e.getKeyChar()=='s') { - if(glWindow.getParent()==null) { - System.err.println("XXX glWin to 100/100"); - glWindow.setPosition(100, 100); - } else { - System.err.println("XXX glWin to 0/0"); - glWindow.setPosition(0, 0); + } else if( e.getKeySymbol() == KeyEvent.VK_R ) { + if( null != quitAdapter ) { + quitAdapter.enable(false); } + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + if(glWindow.getParent()==null) { + System.err.println("XXX glWin to HOME"); + glWindow.reparentWindow(newtCanvasAWT.getNativeWindow()); + } else { + if( null != frame ) { + final InsetsImmutable nInsets = glWindow.getInsets(); + final java.awt.Insets aInsets = frame.getInsets(); + int dx, dy; + if( nInsets.getTotalHeight()==0 ) { + dx = aInsets.left; + dy = aInsets.top; + } else { + dx = nInsets.getLeftWidth(); + dy = nInsets.getTopHeight(); + } + final int topLevelX = frame.getX()+frame.getWidth()+dx; + final int topLevelY = frame.getY()+dy; + System.err.println("XXX glWin to TOP.1 "+topLevelX+"/"+topLevelY+" - insets " + nInsets + ", " + aInsets); + glWindow.reparentWindow(null, topLevelX, topLevelY, false); + } else { + System.err.println("XXX glWin to TOP.0"); + glWindow.reparentWindow(null); + } + } + glWindow.requestFocus(); + glWindow.setExclusiveContextThread(t); + if( null != quitAdapter ) { + quitAdapter.clear(); + quitAdapter.enable(true); + } + } }.start(); } } } \ No newline at end of file diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java index 41a6b77fa..1f19241d8 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java @@ -379,7 +379,7 @@ public class TestParenting01NEWT extends UITestCase { // glWindow2 -- child --> glWindow1: compatible Assert.assertEquals(true, glWindow2.isVisible()); System.err.println("Frames(1) "+glWindow2.getTotalFPSFrames()); - reparentAction = glWindow2.reparentWindow(glWindow1, reparentRecreate); + reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentRecreate); System.err.println("Frames(2) "+glWindow2.getTotalFPSFrames()); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); @@ -405,7 +405,7 @@ public class TestParenting01NEWT extends UITestCase { // glWindow2 --> top Assert.assertEquals(true, glWindow2.isVisible()); - reparentAction = glWindow2.reparentWindow(null, reparentRecreate); + reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentRecreate); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); @@ -567,7 +567,7 @@ public class TestParenting01NEWT extends UITestCase { switch(state) { case 0: Assert.assertEquals(true, glWindow2.isVisible()); - reparentAction = glWindow2.reparentWindow(null, reparentRecreate); + reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentRecreate); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); @@ -582,7 +582,7 @@ public class TestParenting01NEWT extends UITestCase { break; case 1: Assert.assertEquals(true, glWindow2.isVisible()); - reparentAction = glWindow2.reparentWindow(glWindow1, reparentRecreate); + reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentRecreate); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java index 60c2b702c..30ee0f129 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java @@ -88,7 +88,7 @@ public class TestParenting03AWT extends UITestCase { GLEventListener demo1 = new GearsES2(1); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); GLAnimatorControl animator1 = new Animator(glWindow1); animator1.start(); @@ -104,7 +104,7 @@ public class TestParenting03AWT extends UITestCase { GLEventListener demo2 = new GearsES2(1); setDemoFields(demo2, glWindow2, false); glWindow2.addGLEventListener(demo2); - glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2)); + glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2, null)); animator2 = new Animator(glWindow2); animator2.start(); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java index 58dafba15..693dd1448 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java @@ -147,7 +147,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { GLEventListener demo1 = new GearsES2(1); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); glWindow1.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { -- cgit v1.2.3 From 9997ce1f19accc2ef6b8568b5e3ba877710bef01 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 9 Oct 2013 05:29:08 +0200 Subject: NewtCanvasAWT Focus Traversal: Remove AWT's requestFocus*() overrides in favor of FocusPropertyChangeListener requestFocusNEWTChild() The AWT's requestFocus*() overrides were intended to receive the AWT focus (default) and clear it afterwards to forward the focus to the NEWT component -> requestFocusNEWTChild(). This can be achieved simply by using our FocusPropertyChangeListener and invoking requestFocusNEWTChild() when receiving the focus on the NewtCanvasAWT component. --- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 64 ++++++---------------- .../TestParentingFocusTraversal01AWT.java | 6 +- 2 files changed, 21 insertions(+), 49 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 55f5f0533..86faea35f 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -272,10 +272,15 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.FocusProperty: "+evt.getPropertyName()+", src "+evt.getSource()+", "+oldF+" -> "+newF+", isParent "+isParent+", isFS "+isFullscreen); } if(isParent && !isFullscreen) { - if(oldF == NewtCanvasAWT.this && newF == null) { + if(newF == NewtCanvasAWT.this) { + if(DEBUG) { + System.err.println("NewtCanvasAWT.FocusProperty: AWT focus -> NEWT focus traversal"); + } + requestFocusNEWTChild(); + } else if(oldF == NewtCanvasAWT.this && newF == null) { // focus traversal to NEWT - NOP if(DEBUG) { - System.err.println("NewtCanvasAWT.FocusProperty: NEWT focus traversal"); + System.err.println("NewtCanvasAWT.FocusProperty: NEWT focus"); } } else if(null != newF && newF != NewtCanvasAWT.this) { // focus traversal to another AWT component @@ -292,6 +297,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final FocusPropertyChangeListener focusPropertyChangeListener = new FocusPropertyChangeListener(); private volatile KeyboardFocusManager keyboardFocusManager = null; + private final void requestFocusNEWTChild() { + if(null!=newtChild) { + newtChild.setFocusAction(null); + if(isOnscreen) { + KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + } + newtChild.requestFocus(); + newtChild.setFocusAction(focusAction); + } + } + /** * Sets a new NEWT child, provoking reparenting. *

    @@ -602,50 +618,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } - private final void requestFocusNEWTChild() { - if(null!=newtChild) { - newtChild.setFocusAction(null); - if(isOnscreen) { - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); - } - newtChild.requestFocus(); - newtChild.setFocusAction(focusAction); - } - } - - @Override - public void requestFocus() { - super.requestFocus(); - requestFocusNEWTChild(); - } - - @Override - public boolean requestFocus(boolean temporary) { - final boolean res = super.requestFocus(temporary); - if(res) { - requestFocusNEWTChild(); - } - return res; - } - - @Override - public boolean requestFocusInWindow() { - final boolean res = super.requestFocusInWindow(); - if(res) { - requestFocusNEWTChild(); - } - return res; - } - - @Override - public boolean requestFocusInWindow(boolean temporary) { - final boolean res = super.requestFocusInWindow(temporary); - if(res) { - requestFocusNEWTChild(); - } - return res; - } - private final boolean validateComponent(boolean attachNewtChild) { if( Beans.isDesignTime() || !isDisplayable() ) { return false; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java index 693dd1448..ff540408a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java @@ -249,7 +249,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { Assert.assertEquals(true, glWindow1FA.focusLost()); Thread.sleep(durationPerTest/numFocus); - // direct AWT request focus + System.err.println("Test: Direct NewtCanvasAWT focus"); try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { @@ -262,7 +262,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { Assert.assertEquals(true, bWestFA.focusLost()); Thread.sleep(durationPerTest/numFocus); - // direct AWT request focus + System.err.println("Test: Direct AWT Button-West focus"); try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { @@ -275,7 +275,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { Assert.assertEquals(true, glWindow1FA.focusLost()); Thread.sleep(durationPerTest/numFocus); - // direct NEWT request focus + System.err.println("Test: Direct NEWT-Child request focus"); glWindow1.requestFocus(); Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); Assert.assertEquals(true, glWindow1FA.focusGained()); -- cgit v1.2.3 From e96b2d648e7d69b95325fb6b80c6eb508e1e8a14 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 9 Oct 2013 17:12:33 +0200 Subject: NEWT Reparent/Fullscreen: Add 'waitForPosition(..)' when reparenting or back from fullscreen; JOGLNewtAppletBase: Reparent to pos 32/32, trying to avoid browser window focus/top stealing on X11. --- make/scripts/make.jogl.all.macosx-clang.sh | 1 + make/scripts/make.jogl.all.macosx-java7.sh | 22 ---------------------- make/scripts/make.jogl.all.macosx.sh | 1 + make/scripts/tests.sh | 4 ++-- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 13 ++++++++++++- src/newt/classes/jogamp/newt/WindowImpl.java | 12 +++++++++--- .../es2/awt/Bug816AppletOSXCALayerPos03a.java | 1 - 7 files changed, 25 insertions(+), 29 deletions(-) delete mode 100755 make/scripts/make.jogl.all.macosx-java7.sh (limited to 'src/newt/classes') diff --git a/make/scripts/make.jogl.all.macosx-clang.sh b/make/scripts/make.jogl.all.macosx-clang.sh index af9f1e1fe..eb633f5a6 100755 --- a/make/scripts/make.jogl.all.macosx-clang.sh +++ b/make/scripts/make.jogl.all.macosx-clang.sh @@ -5,6 +5,7 @@ if [ -e /opt-share/etc/profile.ant ] ; then fi JAVA_HOME=`/usr/libexec/java_home -version 1.7` +#JAVA_HOME=`/usr/libexec/java_home -version 1.6` PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH diff --git a/make/scripts/make.jogl.all.macosx-java7.sh b/make/scripts/make.jogl.all.macosx-java7.sh deleted file mode 100755 index ee82bbc91..000000000 --- a/make/scripts/make.jogl.all.macosx-java7.sh +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/sh - -if [ -e /opt-share/etc/profile.ant ] ; then - . /opt-share/etc/profile.ant -fi - - -# -Dc.compiler.debug=true \ -# -Djavacdebug="true" \ -# -Djavacdebuglevel="source,lines,vars" \ -# - -JAVA_HOME=`/usr/libexec/java_home -version 1.7` -PATH=$JAVA_HOME/bin:$PATH -export JAVA_HOME PATH - -#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" -export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" - -ant \ - -Drootrel.build=build-macosx-java7 \ - $* 2>&1 | tee make.jogl.all.macosx-java7.log diff --git a/make/scripts/make.jogl.all.macosx.sh b/make/scripts/make.jogl.all.macosx.sh index c80b41d1d..0c7fd7842 100755 --- a/make/scripts/make.jogl.all.macosx.sh +++ b/make/scripts/make.jogl.all.macosx.sh @@ -5,6 +5,7 @@ if [ -e /opt-share/etc/profile.ant ] ; then fi JAVA_HOME=`/usr/libexec/java_home -version 1.7` +#JAVA_HOME=`/usr/libexec/java_home -version 1.6` PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9ca5374e4..023d37d74 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -299,7 +299,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -456,7 +456,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cAWT $* diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 25ddfad48..1004adb8e 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -33,6 +33,7 @@ import java.security.PrivilegedAction; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; +import javax.media.nativewindow.util.InsetsImmutable; import javax.media.opengl.FPSCounter; import javax.media.opengl.GL; import javax.media.opengl.GLAutoDrawable; @@ -301,7 +302,17 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { if(null == glWindow.getParent()) { glWindow.reparentWindow(awtParent); } else { - glWindow.reparentWindow(null); + final InsetsImmutable insets = glWindow.getInsets(); + final int x, y; + if ( 0 >= insets.getTopHeight() ) { + // fail safe .. + x = 32; + y = 32; + } else { + x = insets.getLeftWidth(); + y = insets.getTopHeight(); + } + glWindow.reparentWindow(null, x, y, false /* forceDestroyCreate */); glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE ); } } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 300ca5c3f..b7357863f 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1342,6 +1342,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(ok) { ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); } + if(ok) { + ok = WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); + } if(ok) { requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */); display.dispatchMessagesNative(); // status up2date @@ -1375,7 +1378,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparentWindow: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); + System.err.println("Window.reparent: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } } finally { if(null!=lifecycleHook) { @@ -1399,7 +1402,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparentWindow: END-X ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); + System.err.println("Window.reparent: END-X ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } } } @@ -1410,7 +1413,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer _lock.lock(); try { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparentWindow: ReparentActionRecreate ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+Display.hashCodeNullSafe(parentWindow)); + System.err.println("Window.reparent: ReparentActionRecreate ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+Display.hashCodeNullSafe(parentWindow)); } setVisibleActionImpl(true); // native creation requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */); @@ -2020,6 +2023,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(ok) { ok = WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); } + if(ok && !fullscreen) { + ok = WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); + } if(ok) { requestFocusInt(fullscreen /* skipFocusAction if fullscreen */); display.dispatchMessagesNative(); // status up2date diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java index a70625129..a0ce938fe 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java @@ -29,7 +29,6 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.awt; import java.applet.Applet; import java.awt.BorderLayout; -import java.awt.Button; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLCapabilities; -- cgit v1.2.3 From 2634ce35031be322cb355e4d6055aace6a2c0619 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 12 Oct 2013 19:00:15 +0200 Subject: Bug 859: Let TileRenderer detect zero columns and rows in eot() where beginTile() throws an EOT IllegalStateException to avoid division by zero --- make/scripts/tests.sh | 4 +- .../com/jogamp/opengl/util/RandomTileRenderer.java | 23 +++++- .../com/jogamp/opengl/util/TileRenderer.java | 95 ++++++++++++++++------ .../com/jogamp/opengl/util/TileRendererBase.java | 41 +++++++++- .../classes/javax/media/opengl/awt/GLCanvas.java | 32 +++++--- .../classes/javax/media/opengl/awt/GLJPanel.java | 29 ++++--- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 24 ++++-- .../opengl/test/junit/jogl/demos/gl2/Gears.java | 23 +++--- .../jogl/tile/TestTiledRendering1GL2NEWT.java | 93 ++++++++++++++++++--- .../junit/jogl/tile/TestTiledRendering2NEWT.java | 4 +- 10 files changed, 282 insertions(+), 86 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index eb8a119a7..4b96bd470 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -306,7 +306,7 @@ function testawtswt() { #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* @@ -336,7 +336,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java index 8fc7916c7..a2b7ba343 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java @@ -96,7 +96,28 @@ public class RandomTileRenderer extends TileRendererBase { /** * {@inheritDoc} - * @throws IllegalStateException if image-size or tileRect has not been set + * + *

    + * end of tiling is never reached w/ {@link RandomRileRenderer}, + * i.e. method always returns false. + *

    + */ + @Override + public final boolean eot() { return false; } + + /** + * {@inheritDoc} + * + * Reset internal states of {@link RandomTileRenderer} are: none. + */ + @Override + public final void reset() { } + + /** + * {@inheritDoc} + * + * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or + * {@link #setTileRect(int, int, int, int) tile-rect} has not been set. */ @Override public final void beginTile(GL gl) throws IllegalStateException, GLException { diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java index f126eb7f5..deab8bc3e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java @@ -101,7 +101,7 @@ public class TileRenderer extends TileRendererBase { */ public static final int TR_COLUMNS = 15; /** - * The current tile number. See {@link #getParam(int)}. + * The current tile number. Has value -1 if {@link #eot()}. See {@link #getParam(int)}. */ public static final int TR_CURRENT_TILE_NUM = 16; /** @@ -132,12 +132,13 @@ public class TileRenderer extends TileRendererBase { private final Dimension tileSize = new Dimension(DEFAULT_TILE_WIDTH, DEFAULT_TILE_HEIGHT); private final Dimension tileSizeNB = new Dimension(DEFAULT_TILE_WIDTH - 2 * DEFAULT_TILE_BORDER, DEFAULT_TILE_HEIGHT - 2 * DEFAULT_TILE_BORDER); - protected Dimension imageClippingDim = null; // not set - default + private boolean isInit = false; + private Dimension imageClippingDim = null; // not set - default private int tileBorder = DEFAULT_TILE_BORDER; private int rowOrder = TR_BOTTOM_TO_TOP; private int rows; private int columns; - private int currentTile = -1; + private int currentTile = 0; private int currentRow; private int currentColumn; private int offsetX; @@ -157,6 +158,18 @@ public class TileRenderer extends TileRendererBase { super(); } + /** + * {@inheritDoc} + *

    + * Implementation {@link #reset()} internal states. + *

    + */ + @Override + public final void setImageSize(int width, int height) { + super.setImageSize(width, height); + reset(); + } + /** * Clips the image-size this tile-renderer iterates through, * which can be retrieved via {@link #getClippedImageSize()}. @@ -164,7 +177,7 @@ public class TileRenderer extends TileRendererBase { * Original image-size stored in this tile-renderer is unmodified. *

    *

    - * Method resets internal state and {@link #TR_ROWS} {@link #TR_COLUMNS} count. + * Implementation {@link #reset()} internal states. *

    * * @param width The image-clipping.width @@ -178,7 +191,7 @@ public class TileRenderer extends TileRendererBase { imageClippingDim.setWidth(width); imageClippingDim.setHeight(height); } - setup(); + reset(); } /** @@ -210,7 +223,7 @@ public class TileRenderer extends TileRendererBase { * effective size of the tile depends on the border size, ie ( * width - 2*border ) * ( height - 2 * border ) *

    - * Method resets internal state and {@link #TR_ROWS} {@link #TR_COLUMNS} count. + * Implementation {@link #reset()} internal states. *

    * * @param width @@ -236,7 +249,7 @@ public class TileRenderer extends TileRendererBase { tileSize.setHeight( height ); tileSizeNB.setWidth( width - 2 * border ); tileSizeNB.setHeight( height - 2 * border ); - setup(); + reset(); } /** @@ -251,32 +264,43 @@ public class TileRenderer extends TileRendererBase { } /** - * Sets up the number of rows and columns needed + * {@inheritDoc} + * + * Reset internal states of {@link TileRenderer} are: + *
      + *
    • {@link #TR_ROWS}
    • + *
    • {@link #TR_COLUMNS}
    • + *
    • {@link #TR_CURRENT_COLUMN}
    • + *
    • {@link #TR_CURRENT_ROW}
    • + *
    • {@link #TR_CURRENT_TILE_NUM}
    • + *
    • {@link #TR_CURRENT_TILE_X_POS}
    • + *
    • {@link #TR_CURRENT_TILE_Y_POS}
    • + *
    • {@link #TR_CURRENT_TILE_WIDTH}
    • + *
    • {@link #TR_CURRENT_TILE_HEIGHT}
    • + *
    */ - private final void setup() throws IllegalStateException { + @Override + public final void reset() { final DimensionImmutable clippedImageSize = getClippedImageSize(); columns = ( clippedImageSize.getWidth() + tileSizeNB.getWidth() - 1 ) / tileSizeNB.getWidth(); rows = ( clippedImageSize.getHeight() + tileSizeNB.getHeight() - 1 ) / tileSizeNB.getHeight(); + currentRow = 0; + currentColumn = 0; currentTile = 0; currentTileXPos = 0; currentTileYPos = 0; currentTileWidth = 0; currentTileHeight = 0; - currentRow = 0; - currentColumn = 0; assert columns >= 0; assert rows >= 0; + + beginCalled = false; + isInit = true; } /* pp */ final int getCurrentTile() { return currentTile; } - /** - * Returns true if all tiles have been rendered or {@link #setup()} - * has not been called, otherwise false. - */ - public final boolean eot() { return 0 > currentTile; } - @Override public final int getParam(int pname) { switch (pname) { @@ -341,16 +365,41 @@ public class TileRenderer extends TileRendererBase { return 0 < imageSize.getWidth() && 0 < imageSize.getHeight(); } + /** + * {@inheritDoc} + * + *

    + * end of tiling is reached w/ {@link TileRenderer}, if at least one of the following is true: + *

      + *
    • all tiles have been rendered, i.e. {@link #TR_CURRENT_TILE_NUM} is -1
    • + *
    • no tiles to render, i.e. {@link #TR_COLUMNS} or {@link #TR_ROWS} is 0
    • + *
    + *

    + */ + @Override + public final boolean eot() { + if ( !isInit ) { // ensure at least one reset-call + reset(); + } + return 0 > currentTile || 0 >= columns*rows; + } + + /** + * {@inheritDoc} + * + * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or + * {@link #eot() end-of-tiling} has been reached. + */ @Override public final void beginTile( GL gl ) throws IllegalStateException, GLException { if( !isSetup() ) { - throw new IllegalStateException("Image size has not been set"); + throw new IllegalStateException("Image size has not been set: "+this); } - validateGL(gl); - if (currentTile <= 0) { - setup(); + if ( eot() ) { + throw new IllegalStateException("EOT reached: "+this); } - + validateGL(gl); + /* which tile (by row and column) we're about to render */ if (rowOrder == TR_BOTTOM_TO_TOP) { currentRow = currentTile / columns; @@ -390,7 +439,7 @@ public class TileRenderer extends TileRendererBase { gl.glViewport( 0, 0, tW, tH ); if( DEBUG ) { - System.err.println("TileRenderer.begin.X: "+this.toString()); + System.err.println("TileRenderer.begin: "+this.toString()); } // Do not forget to issue: diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index f15c79f68..d6c36aa14 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -241,6 +241,7 @@ public abstract class TileRendererBase { tileDetails(sb); sb.append("], image[size "+imageSize+", buffer "+hashStr(imageBuffer)+"], glad["+ gladListenerCount+" listener, pre "+(null!=glEventListenerPre)+", post "+(null!=glEventListenerPost)+", preSwap "+gladRequiresPreSwap+"]"); + sb.append(", isSetup "+isSetup()); return sb; } public String toString() { @@ -284,7 +285,7 @@ public abstract class TileRendererBase { * @param width The width of the final image * @param height The height of the final image */ - public final void setImageSize(int width, int height) { + public void setImageSize(int width, int height) { imageSize.setWidth(width); imageSize.setHeight(height); } @@ -320,6 +321,27 @@ public abstract class TileRendererBase { */ public abstract boolean isSetup(); + /** + * Returns true if end of tiling has been reached, otherwise false. + *

    + * end of tiling criteria is implementation specific and may never be reached. + *

    + *

    + * User needs to {@link #reset()} tiling after reaching end of tiling + * before calling {@link #beginTile(GL)} again. + *

    + */ + public abstract boolean eot(); + + /** + * Method resets implementation's internal state to start of tiling + * as required for {@link #beginTile(GL)} if {@link #eot() end of tiling} has been reached. + *

    + * Implementation is a nop where {@link #eot() end of tiling} is never reached. + *

    + */ + public abstract void reset(); + /** * Begins rendering a tile. *

    @@ -351,10 +373,19 @@ public abstract class TileRendererBase { *

    * User has to comply with the GL profile requirement. *

    + *

    + * If {@link #eot() end of tiling} has been reached, + * user needs to {@link #reset()} tiling before calling this method. + *

    * * @param gl The gl context - * @throws IllegalStateException if image-size has not been set + * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} is undefined, + * an {@link #isSetup() implementation related setup} has not be performed + * or {@ link #eot()} has been reached. See implementing classes. * @throws GLException if {@link #setImageBuffer(GLPixelBuffer) image buffer} is used but gl instance is < {@link GL2ES3} + * @see #isSetup() + * @see #eot() + * @see #reset() */ public abstract void beginTile(GL gl) throws IllegalStateException, GLException; @@ -594,6 +625,12 @@ public abstract class TileRendererBase { } return; } + if( eot() ) { + if( DEBUG ) { + System.err.println("TileRenderer.glel.display: EOT: "+TileRendererBase.this); + } + return; + } final GL gl = drawable.getGL(); beginTile(gl); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index f86a6a347..20dd802fb 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -837,20 +837,26 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final Graphics2D g2d = (Graphics2D)graphics; try { printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); - try { - final TileRenderer tileRenderer = printAWTTiles.renderer; - if( DEBUG ) { - System.err.println("AWT print.0: "+tileRenderer); - } - do { - if( printGLAD != GLCanvas.this ) { - tileRenderer.display(); - } else { - Threading.invoke(true, displayOnEDTAction, getTreeLock()); + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); + } + if( !tileRenderer.eot() ) { + try { + do { + if( printGLAD != GLCanvas.this ) { + tileRenderer.display(); + } else { + Threading.invoke(true, displayOnEDTAction, getTreeLock()); + } + } while ( !tileRenderer.eot() ); + if( DEBUG ) { + System.err.println("AWT print.1: "+printAWTTiles); } - } while ( !tileRenderer.eot() ); - } finally { - printAWTTiles.resetGraphics2D(); + } finally { + tileRenderer.reset(); + printAWTTiles.resetGraphics2D(); + } } } catch (NoninvertibleTransformException nte) { System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index fb39143b4..673f22aff 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -646,17 +646,26 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing final Graphics2D g2d = (Graphics2D)graphics; try { printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); - try { - final TileRenderer tileRenderer = printAWTTiles.renderer; - do { - if( printGLAD != GLJPanel.this ) { - tileRenderer.display(); - } else { - backend.doPlainPaint(); + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); + } + if( !tileRenderer.eot() ) { + try { + do { + if( printGLAD != GLJPanel.this ) { + tileRenderer.display(); + } else { + backend.doPlainPaint(); + } + } while ( !tileRenderer.eot() ); + if( DEBUG ) { + System.err.println("AWT print.1: "+printAWTTiles); } - } while ( !tileRenderer.eot() ); - } finally { - printAWTTiles.resetGraphics2D(); + } finally { + tileRenderer.reset(); + printAWTTiles.resetGraphics2D(); + } } } catch (NoninvertibleTransformException nte) { System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 86faea35f..73b3bc368 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -598,16 +598,22 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final Graphics2D g2d = (Graphics2D)graphics; try { printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); - try { - final TileRenderer tileRenderer = printAWTTiles.renderer; - if( DEBUG ) { - System.err.println("AWT print.0: "+tileRenderer); + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); + } + if( !tileRenderer.eot() ) { + try { + do { + tileRenderer.display(); + } while ( !tileRenderer.eot() ); + if( DEBUG ) { + System.err.println("AWT print.1: "+printAWTTiles); + } + tileRenderer.reset(); + } finally { + printAWTTiles.resetGraphics2D(); } - do { - tileRenderer.display(); - } while ( !tileRenderer.eot() ); - } finally { - printAWTTiles.resetGraphics2D(); } } catch (NoninvertibleTransformException nte) { System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java index 74089c2fd..031d6a1c1 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java @@ -97,11 +97,6 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); - System.err.println(Thread.currentThread()+" Gears.init: tileRendererInUse "+tileRendererInUse); - System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); - System.err.println("INIT GL IS: " + gl.getClass().getName()); - System.err.println(JoglVersion.getGLStrings(gl, null, false).toString()); - init(gl); final Object upstreamWidget = drawable.getUpstreamWidget(); @@ -122,6 +117,14 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList float green[] = { 0.0f, 0.8f, 0.2f, 0.7f }; float blue[] = { 0.2f, 0.2f, 1.0f, 0.7f }; + System.err.println(Thread.currentThread()+" Gears.init: tileRendererInUse "+tileRendererInUse); + if(verbose) { + System.err.println("GearsES2 init on "+Thread.currentThread()); + System.err.println("Chosen GLCapabilities: " + gl.getContext().getGLDrawable().getChosenGLCapabilities()); + System.err.println("INIT GL IS: " + gl.getClass().getName()); + System.err.println(JoglVersion.getGLStrings(gl, null, false).toString()); + } + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0); gl.glEnable(GL2.GL_CULL_FACE); gl.glEnable(GL2.GL_LIGHTING); @@ -171,11 +174,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList if(-1 != swapInterval) { gl.setSwapInterval(swapInterval); } - reshapeImpl(gl, x, y, width, height, width, height); - } - - public void reshape(GL2 gl, int x, int y, int width, int height) { - reshapeImpl(gl, x, y, width, height, width, height); + reshape(gl, x, y, width, height, width, height); } @Override @@ -184,10 +183,10 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList int imageWidth, int imageHeight) { final GL2 gl = tr.getAttachedDrawable().getGL().getGL2(); gl.setSwapInterval(0); - reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); + reshape(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); } - void reshapeImpl(GL2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { + public void reshape(GL2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers(); System.err.println(Thread.currentThread()+" Gears.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java index c38140ce0..e0fabc3cc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java @@ -46,7 +46,6 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import org.junit.Assert; @@ -67,11 +66,6 @@ import org.junit.runners.MethodSorters; public class TestTiledRendering1GL2NEWT extends UITestCase { static long duration = 500; // ms - @Test - public void test01() throws IOException { - doTest(); - } - static class DrawableContext { DrawableContext(GLDrawable d, GLContext glc) { this.d = d; @@ -102,7 +96,8 @@ public class TestTiledRendering1GL2NEWT extends UITestCase { } } - void doTest() throws GLException, IOException { + @Test + public void test01() throws IOException { GLProfile glp = GLProfile.getMaxFixedFunc(true); GLCapabilities caps = new GLCapabilities(glp); caps.setOnscreen(false); @@ -132,15 +127,19 @@ public class TestTiledRendering1GL2NEWT extends UITestCase { flipVertically[0] = false; final Gears gears = new Gears(); + gears.setVerbose(false); gears.init(gl); gears.addTileRendererNotify(renderer); - do { - renderer.beginTile(dc.glc.getGL().getGL2ES3()); - gears.reshape(gl, 0, 0, renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT)); + while( !renderer.eot() ) { + renderer.beginTile(gl); + gears.reshape(gl, + renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS), + renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT), + renderer.getParam(TileRendererBase.TR_IMAGE_WIDTH), renderer.getParam(TileRendererBase.TR_IMAGE_HEIGHT)); gears.display(gl); - renderer.endTile(dc.glc.getGL().getGL2ES3()); - } while ( !renderer.eot() ); + renderer.endTile(gl); + } gears.removeTileRendererNotify(renderer); destroyDrawableContext(dc); @@ -160,6 +159,76 @@ public class TestTiledRendering1GL2NEWT extends UITestCase { TextureIO.write(textureData, file); } + @Test + public void test02_EOT_01() throws IOException { + GLProfile glp = GLProfile.getMaxFixedFunc(true); + GLCapabilities caps = new GLCapabilities(glp); + caps.setOnscreen(false); + + final int maxTileSize = 256; + DrawableContext dc = createDrawableAndCurrentCtx(caps, maxTileSize, maxTileSize); + final GL2 gl = dc.glc.getGL().getGL2(); + + // Fix the image size for now + final int imageWidth = dc.d.getWidth() * 6; + final int imageHeight = dc.d.getHeight() * 4; + + // Initialize the tile rendering library + final TileRenderer renderer = new com.jogamp.opengl.util.TileRenderer(); + renderer.setTileSize(dc.d.getWidth(), dc.d.getHeight(), 0); + + IllegalStateException ise = null; + try { + renderer.beginTile(gl); // Image size has not been set + } catch (IllegalStateException _ise) { + ise = _ise; + System.err.println("Expected "+ise.getClass().getSimpleName()+": "+ise.getMessage()); + } + Assert.assertNotNull("TileRenderer.beginTile: Image-size exception missing", ise); + + renderer.setImageSize(imageWidth, imageHeight); + + renderer.clipImageSize(0, 0); + try { + renderer.beginTile(gl); // EOT reached (1) + } catch (IllegalStateException _ise) { + ise = _ise; + System.err.println("Expected "+ise.getClass().getSimpleName()+": "+ise.getMessage()); + } + Assert.assertNotNull("TileRenderer.beginTile: EOT (1) exception missing", ise); + + renderer.clipImageSize(imageWidth, imageHeight); // back to full size + + final Gears gears = new Gears(); + gears.setVerbose(false); + gears.init(gl); + + gears.addTileRendererNotify(renderer); + int numTiles = 0; + while( !renderer.eot() ) { + renderer.beginTile(gl); + gears.reshape(gl, + renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS), + renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT), + renderer.getParam(TileRendererBase.TR_IMAGE_WIDTH), renderer.getParam(TileRendererBase.TR_IMAGE_HEIGHT)); + gears.display(gl); + renderer.endTile(gl); + numTiles++; + } + try { + renderer.beginTile(gl); // EOT reached (2) + } catch (IllegalStateException _ise) { + ise = _ise; + System.err.println("Expected "+ise.getClass().getSimpleName()+": "+ise.getMessage()); + } + Assert.assertNotNull("TileRenderer.beginTile: EOT (2) exception missing", ise); + gears.removeTileRendererNotify(renderer); + + Assert.assertTrue("TileRenderer not rendered more than one tile but "+numTiles, numTiles > 1); + + destroyDrawableContext(dc); + } + public static void main(String args[]) { for(int i=0; i Date: Tue, 15 Oct 2013 15:36:03 +0200 Subject: Bug 861 - NEWT: Unify MouseEvent Processing incl. gesture processing We processed MouseEvents within NEWT as follows: sendMouseEvent/enqueueMouseEvent -> doMouseEvent, - called by native code to be delivered via consumeMouseEvent (now or later) - events are validated (move/drag, boundaries) - missing events are synthesized (click, enter, ..) as well as in several factories, i.e.: - AWTNewtEventFactory (1:1) - AndroidNewtEventFactory - synthesized events .. (click, ..) - android typed gesture detection (drag -> 1 finger scroll..) The latter enqueues events do Window/Display directly to be consumed by WindowImpl. Then users may have their own gesture detection etc. +++ This change unifies mouse/pointer event processing within NEWT within consumeEvent(..) which represents a common entry point. Gesture processing is now realized w/ a public API - GestureHandler - GestureHandler.GestureListener - GestureHandler.GesureEvent which supplies: - default impl. of optional gesture handlers (scroll, .. - default: enabled) - public API to add/remove gesture-handler and -listener +++ This allows our impl. to scale better in support of more multiple pointer devices (-> Win7/Win8, X11, ..). --- make/scripts/tests.sh | 6 +- src/newt/classes/com/jogamp/newt/Window.java | 62 ++- .../jogamp/newt/event/DoubleTapScrollGesture.java | 346 +++++++++++++ .../com/jogamp/newt/event/GestureHandler.java | 143 ++++++ .../classes/com/jogamp/newt/event/InputEvent.java | 8 + .../classes/com/jogamp/newt/event/MouseEvent.java | 238 +++++++-- .../classes/com/jogamp/newt/event/NEWTEvent.java | 1 + .../com/jogamp/newt/event/PinchToZoomGesture.java | 217 ++++++++ .../classes/com/jogamp/newt/opengl/GLWindow.java | 34 ++ src/newt/classes/jogamp/newt/WindowImpl.java | 555 +++++++++++++++++---- .../android/event/AndroidNewtEventFactory.java | 301 ++--------- .../android/event/AndroidNewtEventTranslator.java | 15 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 124 ++--- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 6 +- 14 files changed, 1531 insertions(+), 525 deletions(-) create mode 100644 src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java create mode 100644 src/newt/classes/com/jogamp/newt/event/GestureHandler.java create mode 100644 src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index fa44190c0..84f487c38 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -187,7 +187,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - #D_ARGS="-Dnewt.debug.Window.MouseEvent" + D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -299,7 +299,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -479,7 +479,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug694ScaleImageUnpackBufferSizeAWT $* -testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug365TextureGenerateMipMaps $* +#testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug365TextureGenerateMipMaps $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 8a43ef153..02727353f 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -30,12 +30,14 @@ package com.jogamp.newt; import java.util.List; +import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.MouseListener; + import jogamp.newt.Debug; import jogamp.newt.WindowImpl; @@ -553,15 +555,12 @@ public interface Window extends NativeWindow, WindowClosingProtocol { // /** - * - * Appends the given {@link com.jogamp.newt.event.MouseListener} to the end of - * the list. + * Appends the given {@link MouseListener} to the end of the list. */ void addMouseListener(MouseListener l); /** - * - * Inserts the given {@link com.jogamp.newt.event.MouseListener} at the + * Inserts the given {@link MouseListener} at the * specified position in the list.
    * * @param index Position where the listener will be inserted. @@ -572,10 +571,61 @@ public interface Window extends NativeWindow, WindowClosingProtocol { */ void addMouseListener(int index, MouseListener l); + /** + * Removes the given {@link MouseListener} from the list. + */ void removeMouseListener(MouseListener l); + /** + * Returns the {@link MouseListener} from the list at the given index. + */ MouseListener getMouseListener(int index); + /** + * Returns all {@link MouseListener} + */ MouseListener[] getMouseListeners(); - + + /** Enable or disable default {@link GestureHandler}. Default is enabled. */ + void setDefaultGesturesEnabled(boolean enable); + /** Return true if default {@link GestureHandler} are enabled. */ + boolean areDefaultGesturesEnabled(); + /** + * Appends the given {@link GestureHandler} to the end of the list. + */ + void addGestureHandler(GestureHandler gh); + /** + * Inserts the given {@link GestureHandler} at the + * specified position in the list.
    + * + * @param index Position where the listener will be inserted. + * Should be within (0 <= index && index <= size()). + * An index value of -1 is interpreted as the end of the list, size(). + * @param l The listener object to be inserted + * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index <= size()), or -1 + */ + void addGestureHandler(int index, GestureHandler gh); + /** + * Removes the given {@link GestureHandler} from the list. + */ + void removeGestureHandler(GestureHandler gh); + /** + * Appends the given {@link GestureHandler.GestureListener} to the end of the list. + */ + void addGestureListener(GestureHandler.GestureListener gl); + /** + * Inserts the given {@link GestureHandler.GestureListener} at the + * specified position in the list.
    + * + * @param index Position where the listener will be inserted. + * Should be within (0 <= index && index <= size()). + * An index value of -1 is interpreted as the end of the list, size(). + * @param l The listener object to be inserted + * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index <= size()), or -1 + */ + void addGestureListener(int index, GestureHandler.GestureListener gl); + /** + * Removes the given {@link GestureHandler.GestureListener} from the list. + */ + void removeGestureListener(GestureHandler.GestureListener gl); } diff --git a/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java b/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java new file mode 100644 index 000000000..bc67cbee6 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java @@ -0,0 +1,346 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.newt.event; + +import jogamp.newt.Debug; + +/** + * 2 pointer scroll/rotate gesture handler processing {@link MouseEvent}s + * while producing {@link MouseEvent#EVENT_MOUSE_WHEEL_MOVED} events if gesture is completed. + *

    + * Criteria related to parameters: + *

    + *    - doubleTapSlop (scaled in pixels):
    + *       - Max 2 finger distance to start 'scroll' mode
    + *       - Max. distance diff of current 2-pointer middle and initiated 2-pointer middle.
    + *
    + *    - touchSlop (scaled in pixels):
    + *       - Min. movement w/ 2 pointer within ScaledDoubleTapSlop starting 'scroll' mode
    + *       
    + *    - Avoid computation if not within gesture, especially for MOVE/DRAG
    + *    
    + *    - Only allow gesture to start with PRESS
    + *    
    + *    - Leave gesture completely with RELEASE of both/all fingers, or dist-diff exceeds doubleTapSlop 
    + *    
    + *    - Tolerate temporary lift 1 of 2 pointer
    + *    
    + *     - Always validate pointer-id
    + * 
    + *

    + * Implementation uses a n-state to get detect gesture: + *

    + * + * + * + * + * + * + * + *
    from to action
    NONE 1PRESS 1-pointer-pressed
    1PRESS 2PRESS_T 2-pointer-pressed within doubleTapSlope
    2PRESS_T SCROLL 2-pointer dragged, dist-diff within doubleTapSlop and scrollLen >= scrollSlop
    2PRESS_C SCROLL 2-pointer dragged, dist-diff within doubleTapSlop
    SCROLL SCROLL 2-pointer dragged, dist-diff within doubleTapSlop
    + * State ST_2PRESS_C merely exist to pick up gesture after one pointer has been lost temporarily. + *

    + *

    + * {@link #isWithinGesture()} returns gestureState >= 2PRESS_C + *

    + */ +public class DoubleTapScrollGesture implements GestureHandler { + /** Scroll threshold in pixels (fallback), defaults to 16 pixels. Can be overriden by integer property newt.event.scroll_slop_pixel.*/ + public static final int SCROLL_SLOP_PIXEL; + /** Two pointer 'double tap' slop in pixels (fallback), defaults to 104 pixels. Can be overriden by integer property newt.event.double_tap_slop_pixel.*/ + public static final int DOUBLE_TAP_SLOP_PIXEL; + + /** Scroll threshold in millimeter, defaults to 3 mm. Can be overriden by integer property newt.event.scroll_slop_mm.*/ + public static final float SCROLL_SLOP_MM; + /** Two pointer 'double tap' slop in millimeter, defaults to 20 mm. Can be overriden by integer property newt.event.double_tap_slop_mm.*/ + public static final float DOUBLE_TAP_SLOP_MM; + + static { + Debug.initSingleton(); + + SCROLL_SLOP_PIXEL = Debug.getIntProperty("newt.event.scroll_slop_pixel", true, 16); + DOUBLE_TAP_SLOP_PIXEL = Debug.getIntProperty("newt.event.double_tap_slop_pixel", true, 104); + SCROLL_SLOP_MM = Debug.getIntProperty("newt.event.scroll_slop_mm", true, 3); + DOUBLE_TAP_SLOP_MM = Debug.getIntProperty("newt.event.double_tap_slop_mm", true, 20); + } + + private static final int ST_NONE = 0; + private static final int ST_1PRESS = 1; + private static final int ST_2PRESS_T = 2; + private static final int ST_2PRESS_C = 3; + private static final int ST_SCROLL = 4; + + private final int scrollSlop, scrollSlopSquare, doubleTapSlop, doubleTapSlopSquare; + private final float[] scrollDistance = new float[] { 0f, 0f }; + private int[] pIds = new int[] { -1, -1 }; + /** See class docu */ + private int gestureState; + private int sqStartDist; + private int lastX, lastY; + private int pointerDownCount; + private MouseEvent hitGestureEvent; + + private static final int getSquareDistance(float x1, float y1, float x2, float y2) { + final int deltaX = (int) x1 - (int) x2; + final int deltaY = (int) y1 - (int) y2; + return deltaX * deltaX + deltaY * deltaY; + } + + private int gesturePointers(final MouseEvent e, final int excludeIndex) { + int j = 0; + for(int i=e.getPointerCount()-1; i>=0; i--) { + if( excludeIndex != i ) { + final int id = e.getPointerId(i); + if( pIds[0] == id || pIds[1] == id ) { + j++; + } + } + } + return j; + } + + /** + * scaledScrollSlop < scaledDoubleTapSlop + * @param scaledScrollSlop Distance a pointer can wander before we think the user is scrolling in pixels. + * @param scaledDoubleTapSlop Distance in pixels between the first touch and second touch to still be considered a double tap. + */ + public DoubleTapScrollGesture(int scaledScrollSlop, int scaledDoubleTapSlop) { + scrollSlop = scaledScrollSlop; + scrollSlopSquare = scaledScrollSlop * scaledScrollSlop; + doubleTapSlop = scaledDoubleTapSlop; + doubleTapSlopSquare = scaledDoubleTapSlop * scaledDoubleTapSlop; + pointerDownCount = 0; + clear(true); + if(DEBUG) { + System.err.println("DoubleTapScroll scrollSlop (scaled) "+scrollSlop); + System.err.println("DoubleTapScroll doubleTapSlop (scaled) "+doubleTapSlop); + } + } + + public String toString() { + return "DoubleTapScroll[state "+gestureState+", in "+isWithinGesture()+", has "+(null!=hitGestureEvent)+", pc "+pointerDownCount+"]"; + } + + @Override + public void clear(boolean clearStarted) { + scrollDistance[0] = 0f; + scrollDistance[1] = 0f; + hitGestureEvent = null; + if( clearStarted ) { + gestureState = ST_NONE; + sqStartDist = 0; + pIds[0] = -1; + pIds[1] = -1; + lastX = 0; + lastY = 0; + } + } + + @Override + public boolean isWithinGesture() { + return ST_2PRESS_C <= gestureState; + } + + @Override + public boolean hasGesture() { + return null != hitGestureEvent; + } + + @Override + public InputEvent getGestureEvent() { + if( null != hitGestureEvent ) { + final MouseEvent ge = hitGestureEvent; + int modifiers = ge.getModifiers(); + final float[] rotationXYZ = ge.getRotation(); + rotationXYZ[0] = scrollDistance[0] / scrollSlop; + rotationXYZ[1] = scrollDistance[1] / scrollSlop; + if( rotationXYZ[0]*rotationXYZ[0] > rotationXYZ[1]*rotationXYZ[1] ) { + // Horizontal scroll -> SHIFT + modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; + } + return new MouseEvent(MouseEvent.EVENT_MOUSE_WHEEL_MOVED, ge.getSource(), ge.getWhen(), modifiers, + ge.getAllPointerTypes(), ge.getAllPointerIDs(), + ge.getAllX(), ge.getAllY(), ge.getAllPressures(), ge.getMaxPressure(), + ge.getButton(), ge.getClickCount(), rotationXYZ, scrollSlop); + } + return null; + } + + public final float[] getScrollDistanceXY() { + return scrollDistance; + } + + @Override + public boolean process(final InputEvent in) { + if( null != hitGestureEvent || !(in instanceof MouseEvent) ) { + return true; + } + final MouseEvent pe = (MouseEvent)in; + if( pe.getPointerType(0).getPointerClass() != MouseEvent.PointerClass.Onscreen ) { + return false; + } + pointerDownCount = pe.getPointerCount(); + final int eventType = pe.getEventType(); + final int x0 = pe.getX(0); + final int y0 = pe.getY(0); + switch ( eventType ) { + case MouseEvent.EVENT_MOUSE_PRESSED: { + int gPtr = 0; + if( ST_NONE == gestureState && 1 == pointerDownCount ) { + pIds[0] = pe.getPointerId(0); + pIds[1] = -1; + gestureState = ST_1PRESS; + } else if( ST_NONE < gestureState && 2 == pointerDownCount && 1 == gesturePointers(pe, 0) /* w/o pressed pointer */ ) { + final int x1 = pe.getX(1); + final int y1 = pe.getY(1); + final int xm = (x0+x1)/2; + final int ym = (y0+y1)/2; + + if( ST_1PRESS == gestureState ) { + final int sqDist = getSquareDistance(x0, y0, x1, y1); + final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; + if( isDistWithinDoubleTapSlop ) { + // very first 2-finger touch-down + gPtr = 2; + pIds[0] = pe.getPointerId(0); + pIds[1] = pe.getPointerId(1); + lastX = xm; + lastY = ym; + sqStartDist = sqDist; + gestureState = ST_2PRESS_T; + } + if(DEBUG) { + final int dist = (int)Math.round(Math.sqrt(sqDist)); + System.err.println(this+".pressed.1: dist "+dist+", gPtr "+gPtr+", distWithin2DTSlop "+isDistWithinDoubleTapSlop+", last "+lastX+"/"+lastY+", "+pe); + } + } else if( ST_2PRESS_C == gestureState ) { // pick up gesture after temp loosing one pointer + gPtr = gesturePointers(pe, -1); + if( 2 == gPtr ) { + // same pointers re-touch-down + lastX = xm; + lastY = ym; + } else { + // other 2 pointers .. should rarely happen! + clear(true); + } + } + } + if(DEBUG) { + System.err.println(this+".pressed: gPtr "+gPtr+", this "+lastX+"/"+lastY+", "+pe); + } + } break; + + case MouseEvent.EVENT_MOUSE_RELEASED: { + pointerDownCount--; // lifted + final int gPtr = gesturePointers(pe, 0); // w/o lifted pointer + if ( 1 == gPtr ) { + // tolerate lifting 1 of 2 gesture pointers temporary + gestureState = ST_2PRESS_C; + } else if( 0 == gPtr ) { + // all lifted + clear(true); + } + if(DEBUG) { + System.err.println(this+".released: gPtr "+gPtr+", "+pe); + } + } break; + + case MouseEvent.EVENT_MOUSE_DRAGGED: { + if( 2 == pointerDownCount && ST_1PRESS < gestureState ) { + final int gPtr = gesturePointers(pe, -1); + if( 2 == gPtr ) { + // same pointers + final int x1 = pe.getX(1); + final int y1 = pe.getY(1); + final int xm = (x0+x1)/2; + final int ym = (y0+y1)/2; + final int sqDist = getSquareDistance(x0, y0, x1, y1); + final boolean isDistDiffWithinDoubleTapSlop = Math.abs(sqDist - sqStartDist) <= doubleTapSlopSquare; + if( isDistDiffWithinDoubleTapSlop ) { + switch( gestureState ) { + case ST_2PRESS_T: { + final int sqScrollLen = getSquareDistance(lastX, lastY, xm, ym); + if( sqScrollLen > scrollSlopSquare ) { // min. scrolling threshold reached + gestureState = ST_SCROLL; + } + } break; + + case ST_2PRESS_C: + gestureState = ST_SCROLL; + break; + + case ST_SCROLL: + scrollDistance[0] = lastX - xm; + scrollDistance[1] = lastY - ym; + hitGestureEvent = pe; + break; + } + if(DEBUG) { + final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; + final int dist = (int)Math.round(Math.sqrt(sqDist)); + final int sqScrollLen = getSquareDistance(lastX, lastY, xm, ym); + final int scrollLen = (int)Math.round(Math.sqrt(sqScrollLen)); + System.err.println(this+".dragged.1: pDist "+dist+", scrollLen "+scrollLen+", gPtr "+gPtr+" ["+pIds[0]+", "+pIds[1]+"]"+ + ", diffDistWithinTapSlop "+isDistDiffWithinDoubleTapSlop+ + ", distWithin2DTSlop "+isDistWithinDoubleTapSlop+ + ", this "+xm+"/"+ym+", last "+lastX+"/"+lastY+", d "+scrollDistance[0]+"/"+scrollDistance[1]); + } + } else { + // distance too big .. + if(DEBUG) { + final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; + final int dist = (int)Math.round(Math.sqrt(sqDist)); + final int startDist = (int)Math.round(Math.sqrt(sqStartDist)); + System.err.println(this+".dragged.X1: pDist "+dist+", distStart "+startDist+", gPtr "+gPtr+" ["+pIds[0]+", "+pIds[1]+"]"+ + ", diffDistWithinTapSlop "+isDistDiffWithinDoubleTapSlop+ + ", distWithin2DTSlop "+isDistWithinDoubleTapSlop+ + ", this "+xm+"/"+ym+", last "+lastX+"/"+lastY+", d "+scrollDistance[0]+"/"+scrollDistance[1]); + } + clear(true); + } + if( ST_2PRESS_T < gestureState ) { + // state ST_2PRESS_T waits for min scroll threshold ! + lastX = xm; + lastY = ym; + } + } else { + // other 2 pointers .. should rarely happen! + if(DEBUG) { + System.err.println(this+".dragged.X2: gPtr "+gPtr+" ["+pIds[0]+", "+pIds[1]+"]"+ + ", last "+lastX+"/"+lastY+", d "+scrollDistance[0]+"/"+scrollDistance[1]); + } + clear(true); + } + } + } break; + + default: + } + return null != hitGestureEvent; + } +} diff --git a/src/newt/classes/com/jogamp/newt/event/GestureHandler.java b/src/newt/classes/com/jogamp/newt/event/GestureHandler.java new file mode 100644 index 000000000..2c8f29bb7 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/GestureHandler.java @@ -0,0 +1,143 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.newt.event; + +import jogamp.newt.Debug; + +/** + * Generic gesture handler interface designed to allow pass-through + * filtering of {@link InputEvent}s. + *

    + * To avoid negative impact on event processing, + * implementation shall restrict computation as much as possible + * and only within it's appropriate gesture states. + *

    + *

    + * To allow custom user events, other than the normal {@link InputEvent}s, + * a user may return a {@link GestureEvent} in it's implementation. + *

    + */ +public interface GestureHandler { + public static final boolean DEBUG = Debug.debug("Window.MouseEvent"); + + /** A custom gesture event */ + @SuppressWarnings("serial") + public static class GestureEvent extends InputEvent { + /** A gesture has been detected. */ + public static final short EVENT_GESTURE_DETECTED = 400; + + private final GestureHandler handler; + + /** + * Creates a gesture event with default type {@link #EVENT_GESTURE_DETECTED}. + * + * @param source + * @param when + * @param modifiers + * @param handler + */ + public GestureEvent(Object source, long when, int modifiers, GestureHandler handler) { + super(EVENT_GESTURE_DETECTED, source, when, modifiers); + this.handler = handler; + } + + /** + * Creates a gesture event with custom event_type ! + * @param event_type must lie within [400..599] + * @param source + * @param when + * @param modifiers + * @param handler + */ + public GestureEvent(short event_type, Object source, long when, int modifiers, GestureHandler handler) { + super(event_type, source, when, modifiers); + this.handler = handler; + } + + /** Return the {@link GestureHandler}, which produced the event. */ + public final GestureHandler getHandler() { return handler; } + } + + /** + * Listener for {@link GestureEvent}s. + * + * @see GestureEvent + */ + public static interface GestureListener extends NEWTEventListener + { + /** {@link GestureHandler} {@link GestureHandler#hasGesture() has detected} the gesture. */ + public void gestureDetected(GestureEvent gh); + } + + /** + * Clears state of handler, i.e. resets all states incl. previous detected gesture. + * @param clearStarted if true, also clears {@link #isWithinGesture() started} state, + * otherwise stay within gesture - if appropriate. + * Staying within a gesture allows fluent continuous gesture sequence, + * e.g. for scrolling. + */ + public void clear(boolean clearStarted); + + /** + * Returns true if a previous {@link #process(InputEvent)} command produced a gesture, + * which has not been {@link #clear(boolean) cleared}. + * Otherwise returns false. + */ + public boolean hasGesture(); + + /** + * Returns the corresponding {@link InputEvent} for the gesture as detected by + * a previous {@link #process(InputEvent)}, which has not been {@link #clear(boolean) cleared}. + * Otherwise returns null. + *

    + * Only implemented for gestures mapping to {@link InputEvent}s. + *

    + */ + public InputEvent getGestureEvent(); + + /** + * Returns true if within a gesture as detected by a previous {@link #process(InputEvent)} command, + * which has not been {@link #clear(boolean) cleared}. + * Otherwise returns false. + */ + public boolean isWithinGesture(); + + /** + * Process the given {@link InputEvent} and returns true if it produced the gesture. + * Otherwise returns false. + *

    + * If a gesture was already detected previously and has not been cleared, + * method does not process the event and returns true. + *

    + *

    + * Besides validation of the event's details, + * the handler may also validate the {@link InputEvent.InputClass} and/or {@link InputEvent.InputType}. + *

    + */ + public boolean process(InputEvent e); +} diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index b04ebc1af..7712b77e7 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -39,6 +39,14 @@ import com.jogamp.newt.Window; @SuppressWarnings("serial") public abstract class InputEvent extends NEWTEvent { + /** Interface marking class of input types */ + public static interface InputClass { + } + + /** Interface marking type of input devices */ + public static interface InputType { + } + public static final int SHIFT_MASK = 1 << 0; public static final int CTRL_MASK = 1 << 1; public static final int META_MASK = 1 << 2; diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 8533a37c6..2c137ab77 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -40,8 +40,8 @@ package com.jogamp.newt.event; * http://www.w3.org/Submission/pointer-events/#pointerevent-interface *

    *

    - * In case an instance represents multi-touch events, i.e. {@link #getPointerCount()} is > 1, - * the first data element represents the pointer which triggered the action if individual to one pointer.
    + * In case an instance represents a multiple-pointer event, i.e. {@link #getPointerCount()} is > 1, + * the first data element of the multiple-pointer fields represents the pointer which triggered the action.
    * For example {@link #getX(int) e.getX(0)} at {@link #EVENT_MOUSE_PRESSED} returns the data of the pressed pointer, etc. *

    */ @@ -49,12 +49,12 @@ package com.jogamp.newt.event; public class MouseEvent extends InputEvent { /** Class of pointer types */ - public static enum PointerClass{ + public static enum PointerClass implements InputEvent.InputClass { Offscreen, Onscreen, Undefined; } /** Type of pointer devices */ - public static enum PointerType{ + public static enum PointerType implements InputEvent.InputType { /** {@link PointerClass#Offscreen} mouse. */ Mouse(PointerClass.Offscreen), /** {@link PointerClass#Offscreen} touch pad, usually using fingers. */ @@ -110,7 +110,7 @@ public class MouseEvent extends InputEvent return 300; } - /** Constructor for tradition 1-pointer mouse events. */ + /** Constructor for traditional one-pointer event. */ public MouseEvent(short eventType, Object source, long when, int modifiers, int x, int y, short clickCount, short button, float[] rotationXYZ, float rotationScale) @@ -120,25 +120,48 @@ public class MouseEvent extends InputEvent this.y = new int[]{y}; this.pressure = constMousePressure; this.maxPressure= 1.0f; - this.pointerIDs = constMousePointerIDs; + this.pointerID = constMousePointerIDs; this.clickCount=clickCount; this.button=button; this.rotationXYZ = rotationXYZ; this.rotationScale = rotationScale; - this.pointerTypes = constMousePointerTypes; + this.pointerType = constMousePointerTypes; } - /** Constructor for multi-touch pointer events. */ - public MouseEvent(short eventType, Object source, long when, - int modifiers, int[] x, int[] y, float[] pressure, float maxPressure, PointerType pointerTypes[], short[] pointerids, short clickCount, - short button, float[] rotationXYZ, float rotationScale) + /** + * Constructor for a multiple-pointer event. + *

    + * First element of multiple-pointer arrays represents the pointer which triggered the event! + *

    + * + * @param eventType + * @param source + * @param when + * @param modifiers + * @param pointerType PointerType for each pointer (multiple pointer) + * @param pointerID Pointer ID for each pointer (multiple pointer) + * @param x X-axis for each pointer (multiple pointer) + * @param y Y-axis for each pointer (multiple pointer) + * @param pressure Pressure for each pointer (multiple pointer) + * @param maxPressure Maximum pointer pressure for all pointer + * @param button Corresponding mouse-button + * @param clickCount Mouse-button click-count + * @param rotationXYZ Rotation of all axis + * @param rotationScale Rotation scale + */ + public MouseEvent(short eventType, Object source, long when, int modifiers, + PointerType pointerType[], short[] pointerID, + int[] x, int[] y, float[] pressure, float maxPressure, + short button, short clickCount, float[] rotationXYZ, float rotationScale) { super(eventType, source, when, modifiers); this.x = x; this.y = y; - if(pointerids.length != pressure.length || - pointerids.length != x.length || - pointerids.length != y.length) { + final int pointerCount = pointerType.length; + if(pointerCount != pointerID.length || + pointerCount != x.length || + pointerCount != y.length || + pointerCount != pressure.length) { throw new IllegalArgumentException("All multiple pointer arrays must be of same size"); } if( 0.0f >= maxPressure ) { @@ -146,55 +169,148 @@ public class MouseEvent extends InputEvent } this.pressure = pressure; this.maxPressure= maxPressure; - this.pointerIDs = pointerids; + this.pointerID = pointerID; this.clickCount=clickCount; this.button=button; this.rotationXYZ = rotationXYZ; this.rotationScale = rotationScale; - this.pointerTypes = pointerTypes; + this.pointerType = pointerType; + } + + public MouseEvent createVariant(short newEventType) { + return new MouseEvent(newEventType, source, getWhen(), getModifiers(), pointerType, pointerID, + x, y, pressure, maxPressure, button, clickCount, rotationXYZ, rotationScale); + } + + /** + * Factory for a multiple-pointer event. + *

    + * The index for the element of multiple-pointer arrays represents the pointer which triggered the event + * is passed via actionIdx. + *

    + * + * @param eventType + * @param source + * @param when + * @param modifiers + * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event + * @param pointerType PointerType for each pointer (multiple pointer) + * @param pointerID Pointer ID for each pointer (multiple pointer) + * @param x X-axis for each pointer (multiple pointer) + * @param y Y-axis for each pointer (multiple pointer) + * @param pressure Pressure for each pointer (multiple pointer) + * @param maxPressure Maximum pointer pressure for all pointer + * @param button Corresponding mouse-button + * @param clickCount Mouse-button click-count + * @param rotationXYZ Rotation of all axis + * @param rotationScale Rotation scale + */ + public static MouseEvent create(short eventType, Object source, long when, int modifiers, + int actionIdx, PointerType pointerType[], short[] pointerID, + int[] x, int[] y, float[] pressure, float maxPressure, + short button, short clickCount, float[] rotationXYZ, float rotationScale) { + if( 0 <= actionIdx && actionIdx < pointerType.length) { + if( 0 < actionIdx ) { + { + final PointerType aType = pointerType[actionIdx]; + pointerType[actionIdx] = pointerType[0]; + pointerType[0] = aType; + } + { + final short s = pointerID[actionIdx]; + pointerID[actionIdx] = pointerID[0]; + pointerID[0] = s; + } + { + int s = x[actionIdx]; + x[actionIdx] = x[0]; + x[0] = s; + s = y[actionIdx]; + y[actionIdx] = y[0]; + y[0] = s; + } + { + final float aPress = pressure[actionIdx]; + pressure[actionIdx] = pressure[0]; + pressure[0] = aPress; + } + } + return new MouseEvent(eventType, source, when, modifiers, + pointerType, pointerID, x, y, pressure, maxPressure, + button, clickCount, rotationXYZ, rotationScale); + } + throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pointerType.length-1)+"]"); } /** * @return the count of pointers involved in this event */ - public int getPointerCount() { - return x.length; + public final int getPointerCount() { + return pointerType.length; } /** * @return the {@link PointerType} for the data at index. * return null if index not available. */ - public PointerType getPointerType(int index) { - if(index >= pointerIDs.length) { + public final PointerType getPointerType(int index) { + if(0 > index || index >= pointerType.length) { return null; } - return pointerTypes[index]; + return pointerType[index]; + } + + /** + * @return array of all {@link PointerType}s for all pointers + */ + public final PointerType[] getAllPointerTypes() { + return pointerType; } /** - * @return the pointer id for the data at index. + * @return the pointer id for the given index. * return -1 if index not available. */ - public short getPointerId(int index) { - if(index >= pointerIDs.length) { + public final short getPointerId(int index) { + if(0 > index || index >= pointerID.length) { return -1; } - return pointerIDs[index]; + return pointerID[index]; } - public short getButton() { + /** + * @return the pointer index for the given pointer id. + * return -1 if id not available. + */ + public final int getPointerIdx(short id) { + for(int i=pointerID.length-1; i>=0; i--) { + if( pointerID[i] == id ) { + return i; + } + } + return -1; + } + + /** + * @return array of all pointer IDs for all pointers + */ + public final short[] getAllPointerIDs() { + return pointerID; + } + + public final short getButton() { return button; } - public short getClickCount() { + public final short getClickCount() { return clickCount; } - public int getX() { + + public final int getX() { return x[0]; } - public int getY() { + public final int getY() { return y[0]; } @@ -203,7 +319,7 @@ public class MouseEvent extends InputEvent * @return X-Coord associated with the pointer-index. * @see getPointerId(index) */ - public int getX(int index) { + public final int getX(int index) { return x[index]; } @@ -212,20 +328,41 @@ public class MouseEvent extends InputEvent * @return Y-Coord associated with the pointer-index. * @see getPointerId(index) */ - public int getY(int index) { + public final int getY(int index) { return y[index]; } + /** + * @return array of all X-Coords for all pointers + */ + public final int[] getAllX() { + return x; + } + + /** + * @return array of all Y-Coords for all pointers + */ + public final int[] getAllY() { + return y; + } + /** * @param normalized if true, method returns the normalized pressure, i.e. pressure / maxPressure * @return The pressure associated with the pointer-index 0. * The value of zero is return if not available. * @see #getMaxPressure() */ - public float getPressure(boolean normalized){ + public final float getPressure(boolean normalized){ return normalized ? pressure[0] / maxPressure : pressure[0]; } + /** + * @return array of all raw, un-normalized pressures for all pointers + */ + public final float[] getAllPressures() { + return pressure; + } + /** * Returns the maximum pressure known for the input device generating this event. *

    @@ -239,7 +376,7 @@ public class MouseEvent extends InputEvent * *

    */ - public float getMaxPressure() { + public final float getMaxPressure() { return maxPressure; } @@ -250,7 +387,7 @@ public class MouseEvent extends InputEvent * The value of zero is return if not available. * @see #getMaxPressure() */ - public float getPressure(int index, boolean normalized){ + public final float getPressure(int index, boolean normalized){ return normalized ? pressure[index] / maxPressure : pressure[index]; } @@ -294,7 +431,7 @@ public class MouseEvent extends InputEvent * see {@link #getRotationScale()} for semantics. *

    */ - public float[] getRotation() { + public final float[] getRotation() { return rotationXYZ; } @@ -311,15 +448,15 @@ public class MouseEvent extends InputEvent * Hence scale * rotation reproduces the screen distance in pixels the finger[s] have moved. *

    */ - public float getRotationScale() { + public final float getRotationScale() { return rotationScale; } - public String toString() { + public final String toString() { return toString(null).toString(); } - public StringBuilder toString(StringBuilder sb) { + public final StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); } @@ -327,13 +464,13 @@ public class MouseEvent extends InputEvent .append(", ").append(x).append("/").append(y) .append(", button ").append(button).append(", count ") .append(clickCount).append(", rotation [").append(rotationXYZ[0]).append(", ").append(rotationXYZ[1]).append(", ").append(rotationXYZ[2]).append("] * ").append(rotationScale); - if(pointerIDs.length>0) { - sb.append(", pointer<").append(pointerIDs.length).append(">["); - for(int i=0; i0) { + sb.append(", pointer<").append(pointerID.length).append(">["); + for(int i=0; i0) { sb.append(", "); } - sb.append(pointerIDs[i]).append("/").append(pointerTypes[i]).append(": ") + sb.append(pointerID[i]).append("/").append(pointerType[i]).append(": ") .append(x[i]).append("/").append(y[i]).append(", ") .append("p[").append(pressure[i]).append("/").append(maxPressure).append("=").append(pressure[i]/maxPressure).append("]"); } @@ -356,15 +493,24 @@ public class MouseEvent extends InputEvent default: return "unknown (" + type + ")"; } } - private final int x[], y[]; + + /** PointerType for each pointer (multiple pointer) */ + private final PointerType pointerType[]; + /** Pointer-ID for each pointer (multiple pointer) */ + private final short pointerID[]; + /** X-axis for each pointer (multiple pointer) */ + private final int x[]; + /** Y-axis for each pointer (multiple pointer) */ + private final int y[]; + /** Pressure for each pointer (multiple pointer) */ + private final float pressure[]; // private final short tiltX[], tiltY[]; // TODO: A generic way for pointer axis information, see Android MotionEvent! private final short clickCount, button; + /** Rotation around the X, Y and X axis */ private final float[] rotationXYZ; + /** Rotation scale */ private final float rotationScale; - private final float pressure[]; private final float maxPressure; - private final short pointerIDs[]; - private final PointerType pointerTypes[]; private static final float[] constMousePressure = new float[]{0f}; private static final short[] constMousePointerIDs = new short[]{0}; diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index c1bc791d8..02bb4f929 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -44,6 +44,7 @@ package com.jogamp.newt.event; *
  • WindowEvent 100..10x
  • *
  • MouseEvent 200..20x
  • *
  • KeyEvent 300..30x
  • + *
  • GestureEvent 400..5xx
  • *
  • MonitorEvent 600..60x
  • *
    */ diff --git a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java new file mode 100644 index 000000000..3a34c6253 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java @@ -0,0 +1,217 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.newt.event; + +import javax.media.nativewindow.NativeSurface; + +import jogamp.newt.Debug; + +/** + * 2 pointer zoom, a.k.a. pinch to zoom, gesture handler processing {@link MouseEvent}s + * while producing {@link ZoomEvent}s if gesture is completed. + *

    + * Zoom value lies within [0..2], with 1 as 1:1. + *

    + *
    + *   - choosing the smallest surface edge (width/height -> x/y)
    + *   - tolerating other fingers to be pressed and hence user to add functionality (scale, ..)
    + * 
    + */ +public class PinchToZoomGesture implements GestureHandler { + public static final boolean DEBUG = Debug.debug("Window.MouseEvent"); + + /** A {@link GestureHandler.GestureEvent} denominating zoom. */ + @SuppressWarnings("serial") + public static class ZoomEvent extends GestureEvent { + private final MouseEvent pe; + private final float zoom; + public ZoomEvent(Object source, long when, int modifiers, GestureHandler handler, MouseEvent pe, float zoom) { + super(source, when, modifiers, handler); + this.pe = pe; + this.zoom = zoom; + } + /** Triggering {@link MouseEvent} */ + public final MouseEvent getTrigger() { return pe; } + /** Zoom value lies within [0..2], with 1 as 1:1. */ + public final float getZoom() { return zoom; } + } + + private final NativeSurface surface; + private float zoom; + private int zoomLastEdgeDist; + private boolean zoomFirstTouch; + private boolean zoomMode; + private ZoomEvent zoomEvent; + private short[] pIds = new short[] { -1, -1 }; + + public PinchToZoomGesture(NativeSurface surface) { + clear(true); + this.surface = surface; + this.zoom = 1f; + } + + public String toString() { + return "PinchZoom[1stTouch "+zoomFirstTouch+", in "+isWithinGesture()+", has "+(null!=zoomEvent)+", zoom "+zoom+"]"; + } + + private int gesturePointers(final MouseEvent e, final int excludeIndex) { + int j = 0; + for(int i=e.getPointerCount()-1; i>=0; i--) { + if( excludeIndex != i ) { + final int id = e.getPointerId(i); + if( pIds[0] == id || pIds[1] == id ) { + j++; + } + } + } + return j; + } + + @Override + public void clear(boolean clearStarted) { + zoomEvent = null; + if( clearStarted ) { + zoomLastEdgeDist = 0; + zoomFirstTouch = true; + zoomMode = false; + pIds[0] = -1; + pIds[1] = -1; + } + } + + @Override + public boolean isWithinGesture() { + return zoomMode; + } + + @Override + public boolean hasGesture() { + return null != zoomEvent; + } + + @Override + public InputEvent getGestureEvent() { + return zoomEvent; + } + + /** Zoom value lies within [0..2], with 1 as 1:1. */ + public final float getZoom() { + return zoom; + } + /** Set zoom value within [0..2], with 1 as 1:1. */ + public final void setZoom(float zoom) { + this.zoom=zoom; + } + + @Override + public boolean process(final InputEvent in) { + if( null != zoomEvent || !(in instanceof MouseEvent) ) { + return true; + } + final MouseEvent pe = (MouseEvent)in; + if( pe.getPointerType(0).getPointerClass() != MouseEvent.PointerClass.Onscreen ) { + return false; + } + + final int pointerDownCount = pe.getPointerCount(); + final int eventType = pe.getEventType(); + final boolean useY = surface.getWidth() >= surface.getHeight(); // use smallest dimension + switch ( eventType ) { + case MouseEvent.EVENT_MOUSE_PRESSED: { + if( 1 == pointerDownCount ) { + pIds[0] = pe.getPointerId(0); + pIds[1] = -1; + } else if ( 2 <= pointerDownCount ) { // && 1 == gesturePointers(pe, 0) /* w/o pressed pointer */) { + pIds[0] = pe.getPointerId(0); + pIds[1] = pe.getPointerId(1); + } + if(DEBUG) { + System.err.println("XXX1: id0 "+pIds[0]+" -> idx0 "+0+", id1 "+pIds[1]+" -> idx1 "+1); + System.err.println(this+".pressed: down "+pointerDownCount+", gPtr "+gesturePointers(pe, -1)+", event "+pe); + } + } break; + + case MouseEvent.EVENT_MOUSE_RELEASED: { + final int gPtr = gesturePointers(pe, 0); // w/o lifted pointer + if ( 1 == gPtr ) { + zoomFirstTouch = true; + zoomMode = false; + } else if( 0 == gPtr ) { + // all lifted + clear(true); + } + if(DEBUG) { + System.err.println(this+".released: down "+pointerDownCount+", gPtr "+gPtr+", event "+pe); + } + } break; + + case MouseEvent.EVENT_MOUSE_DRAGGED: { + if( 2 <= pointerDownCount ) { + final int gPtr = gesturePointers(pe, -1); + if( 2 == gPtr ) { + // same pointers + final int p0Idx = pe.getPointerIdx(pIds[0]); + final int p1Idx = pe.getPointerIdx(pIds[1]); + final int edge0 = useY ? pe.getY(p0Idx) : pe.getX(p0Idx); + final int edge1 = useY ? pe.getY(p1Idx) : pe.getX(p1Idx); + // Diff. 1:1 Zoom: finger-distance to screen-coord + if(zoomFirstTouch) { + zoomLastEdgeDist = Math.abs(edge0-edge1); + zoomFirstTouch=false; + zoomMode = true; + } else if( zoomMode ) { + final int d = Math.abs(edge0-edge1); + final int dd = d - zoomLastEdgeDist; + final float screenEdge = useY ? surface.getHeight() : surface.getWidth(); + final float incr = (float)dd / screenEdge; // [-1..1] + if(DEBUG) { + System.err.println("XXX2: id0 "+pIds[0]+" -> idx0 "+p0Idx+", id1 "+pIds[1]+" -> idx1 "+p1Idx); + System.err.println("XXX3: d "+d+", ld "+zoomLastEdgeDist+", dd "+dd+", screen "+screenEdge+" -> incr "+incr+", zoom "+zoom+" -> "+(zoom+incr)); + } + zoom += incr; + // clip value + if( 2f < zoom ) { + zoom = 2f; + } else if( 0 > zoom ) { + zoom = 0; + } + zoomLastEdgeDist = d; + zoomEvent = new ZoomEvent(pe.getSource(), pe.getWhen(), pe.getModifiers(), this, pe, zoom); + } + } + if(DEBUG) { + System.err.println(this+".dragged: down "+pointerDownCount+", gPtr "+gPtr+", event "+pe); + } + } + } break; + + default: + } + return null != zoomEvent; + } +} diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index eace0f2af..cae1a06a2 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -77,6 +77,7 @@ import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; +import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.event.NEWTEvent; @@ -774,6 +775,39 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return window.getMouseListeners(); } + @Override + public void setDefaultGesturesEnabled(boolean enable) { + window.setDefaultGesturesEnabled(enable); + } + @Override + public boolean areDefaultGesturesEnabled() { + return window.areDefaultGesturesEnabled(); + } + @Override + public final void addGestureHandler(GestureHandler gh) { + window.addGestureHandler(gh); + } + @Override + public final void addGestureHandler(int index, GestureHandler gh) { + window.addGestureHandler(index, gh); + } + @Override + public final void removeGestureHandler(GestureHandler gh) { + window.removeGestureHandler(gh); + } + @Override + public final void addGestureListener(GestureHandler.GestureListener gl) { + window.addGestureListener(-1, gl); + } + @Override + public final void addGestureListener(int index, GestureHandler.GestureListener gl) { + window.addGestureListener(index, gl); + } + @Override + public final void removeGestureListener(GestureHandler.GestureListener gl) { + window.removeGestureListener(gl); + } + //---------------------------------------------------------------------- // NativeWindow completion // diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index b7357863f..66ce46ed0 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -48,6 +48,8 @@ import com.jogamp.newt.Screen; import com.jogamp.newt.Window; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.newt.event.DoubleTapScrollGesture; +import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; @@ -60,6 +62,7 @@ import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.WindowUpdateEvent; +import com.jogamp.newt.event.MouseEvent.PointerType; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -71,6 +74,7 @@ import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; @@ -176,13 +180,41 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private ArrayList childWindows = new ArrayList(); private ArrayList mouseListeners = new ArrayList(); - private short mouseButtonPressed = (short)0; // current pressed mouse button number - private int mouseButtonModMask = 0; // current pressed mouse button modifier mask - private long lastMousePressed = 0; // last time when a mouse button was pressed - private short lastMouseClickCount = (short)0; // last mouse button click count - private boolean mouseInWindow = false;// mouse entered window - is inside the window (may be synthetic) - private Point lastMousePosition = new Point(); - + + private static class PointerState0 { + /** current pressed mouse button number */ + private short buttonPressed = (short)0; + /** current pressed mouse button modifier mask */ + private int buttonModMask = 0; + /** last time when a mouse button was pressed */ + private long lastButtonPressTime = 0; + /** last mouse button click count */ + private short lastButtonClickCount = (short)0; + /** mouse entered window - is inside the window (may be synthetic) */ + private boolean insideWindow = false; + /** last mouse-move position */ + private Point lastMovePosition = new Point(); + } + private static class PointerState1 { + /** current pressed mouse button number */ + private short buttonPressed = (short)0; + /** last time when a mouse button was pressed */ + private long lastButtonPressTime = 0; + /** mouse entered window - is inside the window (may be synthetic) */ + private boolean insideWindow = false; + /** last mouse-move position */ + private Point lastMovePosition = new Point(); + } + /** doMouseEvent */ + private PointerState0 pState0 = new PointerState0(); + /** consumeMouseEvent */ + private PointerState1 pState1 = new PointerState1(); + private boolean defaultGestureHandlerEnabled = true; + private DoubleTapScrollGesture gesture2PtrTouchScroll = null; + private ArrayList pointerGestureHandler = new ArrayList(); + + private ArrayList gestureListeners = new ArrayList(); + private ArrayList keyListeners = new ArrayList(); private ArrayList windowListeners = new ArrayList(); @@ -1754,6 +1786,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer for (int i = 0; i < mouseListeners.size(); i++ ) { sb.append(mouseListeners.get(i)+", "); } + sb.append("], PointerGestures default "+defaultGestureHandlerEnabled+", custom "+pointerGestureHandler.size()+" ["); + for (int i = 0; i < pointerGestureHandler.size(); i++ ) { + sb.append(pointerGestureHandler.get(i)+", "); + } sb.append("], KeyListeners num "+keyListeners.size()+" ["); for (int i = 0; i < keyListeners.size(); i++ ) { sb.append(keyListeners.get(i)+", "); @@ -2166,7 +2202,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private final MonitorModeListenerImpl monitorModeListenerImpl = new MonitorModeListenerImpl(); - //---------------------------------------------------------------------- // Child Window Management // @@ -2286,17 +2321,22 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // MouseListener/Event Support // + + // + // Native MouseEvents pre-processed to be enqueued or consumed directly + // + public final void sendMouseEvent(short eventType, int modifiers, int x, int y, short button, float rotation) { - doMouseEvent(false, false, eventType, modifiers, x, y, button, rotation); + doMouseEvent(false, false, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } public final void enqueueMouseEvent(boolean wait, short eventType, int modifiers, int x, int y, short button, float rotation) { - doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotation); + doMouseEvent(true, wait, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, int x, int y, short button, float rotation) { - this.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); + doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } /** public final void sendMouseEvent(short eventType, int modifiers, @@ -2309,57 +2349,73 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } */ protected void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, int x, int y, short button, float[] rotationXYZ, float rotationScale) { - if( eventType == MouseEvent.EVENT_MOUSE_ENTERED || eventType == MouseEvent.EVENT_MOUSE_EXITED ) { - if( eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1 ) { - x = lastMousePosition.getX(); - y = lastMousePosition.getY(); - } - // clip coordinates to window dimension - x = Math.min(Math.max(x, 0), getWidth()-1); - y = Math.min(Math.max(y, 0), getHeight()-1); - mouseInWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; - // clear states - lastMousePressed = 0; - lastMouseClickCount = (short)0; - mouseButtonPressed = 0; - mouseButtonModMask = 0; - } - if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { - return; // .. invalid .. - } - if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: enqueue "+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+ - ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+lastMousePosition); + if( 0 > button || button > MouseEvent.BUTTON_NUMBER ) { + throw new NativeWindowException("Invalid mouse button number" + button); } + + // + // Remove redundant events, determine ENTERED state and reset states if applicable + // final long when = System.currentTimeMillis(); - MouseEvent eEntered = null; - if(eventType == MouseEvent.EVENT_MOUSE_MOVED) { - if(!mouseInWindow) { - mouseInWindow = true; - eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, this, when, - modifiers, x, y, (short)0, (short)0, rotationXYZ, rotationScale); + switch( eventType ) { + case MouseEvent.EVENT_MOUSE_EXITED: + if( x==-1 && y==-1 ) { + x = pState0.lastMovePosition.getX(); + y = pState0.lastMovePosition.getY(); + } + // Fall through intended! + + case MouseEvent.EVENT_MOUSE_ENTERED: + // clip coordinates to window dimension + x = Math.min(Math.max(x, 0), getWidth()-1); + y = Math.min(Math.max(y, 0), getHeight()-1); + pState0.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; // clear states - lastMousePressed = 0; - lastMouseClickCount = (short)0; - mouseButtonPressed = 0; - mouseButtonModMask = 0; - } else if( lastMousePosition.getX() == x && lastMousePosition.getY()==y ) { - if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+lastMousePosition); + pState0.lastButtonPressTime = 0; + pState0.lastButtonClickCount = (short)0; + pState0.buttonPressed = 0; + pState0.buttonModMask = 0; + break; + + case MouseEvent.EVENT_MOUSE_MOVED: + case MouseEvent.EVENT_MOUSE_DRAGGED: + if( pState0.insideWindow && pState0.lastMovePosition.getX() == x && pState0.lastMovePosition.getY() == y ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("doMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+pState0.lastMovePosition); + } + return; // skip same position } - return; // skip same position + pState0.lastMovePosition.setX(x); + pState0.lastMovePosition.setY(y); + + // Fall through intended ! + + default: + if(!pState0.insideWindow) { + pState0.insideWindow = true; + + // clear states + pState0.lastButtonPressTime = 0; + pState0.lastButtonClickCount = (short)0; + pState0.buttonPressed = 0; + pState0.buttonModMask = 0; + } + } + + if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("doMouseEvent: drop: "+MouseEvent.getEventTypeString(eventType)+ + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+pState0.lastMovePosition); } - lastMousePosition.setX(x); - lastMousePosition.setY(y); + return; // .. invalid .. } - if( 0 > button || button > MouseEvent.BUTTON_NUMBER ) { - throw new NativeWindowException("Invalid mouse button number" + button); + if(DEBUG_MOUSE_EVENT) { + System.err.println("doMouseEvent: enqueue "+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+ + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+pState0.lastMovePosition); } + modifiers |= InputEvent.getButtonMask(button); // Always add current button to modifier mask (Bug 571) - modifiers |= mouseButtonModMask; // Always add currently pressed mouse buttons to modifier mask - - MouseEvent eClicked = null; - MouseEvent e = null; + modifiers |= pState0.buttonModMask; // Always add currently pressed mouse buttons to modifier mask if( isPointerConfined() ) { modifiers |= InputEvent.CONFINED_MASK; @@ -2368,64 +2424,86 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer modifiers |= InputEvent.INVISIBLE_MASK; } - if( MouseEvent.EVENT_MOUSE_PRESSED == eventType ) { - if( when - lastMousePressed < MouseEvent.getClickTimeout() ) { - lastMouseClickCount++; - } else { - lastMouseClickCount=(short)1; - } - lastMousePressed = when; - mouseButtonPressed = button; - mouseButtonModMask |= MouseEvent.getButtonMask(button); - e = new MouseEvent(eventType, this, when, - modifiers, x, y, lastMouseClickCount, button, rotationXYZ, rotationScale); - } else if( MouseEvent.EVENT_MOUSE_RELEASED == eventType ) { - e = new MouseEvent(eventType, this, when, - modifiers, x, y, lastMouseClickCount, button, rotationXYZ, rotationScale); - if( when - lastMousePressed < MouseEvent.getClickTimeout() ) { - eClicked = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, this, when, - modifiers, x, y, lastMouseClickCount, button, rotationXYZ, rotationScale); - } else { - lastMouseClickCount = (short)0; - lastMousePressed = 0; - } - mouseButtonPressed = 0; - mouseButtonModMask &= ~MouseEvent.getButtonMask(button); - } else if( MouseEvent.EVENT_MOUSE_MOVED == eventType ) { - if ( mouseButtonPressed > 0 ) { - e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, - modifiers, x, y, (short)1, mouseButtonPressed, rotationXYZ, rotationScale); - } else { + final MouseEvent e; + + switch( eventType ) { + case MouseEvent.EVENT_MOUSE_PRESSED: + if( when - pState0.lastButtonPressTime < MouseEvent.getClickTimeout() ) { + pState0.lastButtonClickCount++; + } else { + pState0.lastButtonClickCount=(short)1; + } + pState0.lastButtonPressTime = when; + pState0.buttonPressed = button; + pState0.buttonModMask |= MouseEvent.getButtonMask(button); e = new MouseEvent(eventType, this, when, - modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); - } - } else if( MouseEvent.EVENT_MOUSE_WHEEL_MOVED == eventType ) { - e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); - } else { - e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); - } - if( null != eEntered ) { - if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: synthesized MOUSE_ENTERED event: "+eEntered); - } - doEvent(enqueue, wait, eEntered); + modifiers, x, y, pState0.lastButtonClickCount, button, rotationXYZ, rotationScale); + break; + case MouseEvent.EVENT_MOUSE_RELEASED: + e = new MouseEvent(eventType, this, when, + modifiers, x, y, pState0.lastButtonClickCount, button, rotationXYZ, rotationScale); + if( when - pState0.lastButtonPressTime >= MouseEvent.getClickTimeout() ) { + pState0.lastButtonClickCount = (short)0; + pState0.lastButtonPressTime = 0; + } + pState0.buttonPressed = 0; + pState0.buttonModMask &= ~MouseEvent.getButtonMask(button); + break; + case MouseEvent.EVENT_MOUSE_MOVED: + if ( pState0.buttonPressed > 0 ) { + e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, + modifiers, x, y, (short)1, pState0.buttonPressed, rotationXYZ, rotationScale); + } else { + e = new MouseEvent(eventType, this, when, + modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); + } + break; + default: + e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); } doEvent(enqueue, wait, e); // actual mouse event - if( null != eClicked ) { - if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: synthesized MOUSE_CLICKED event: "+eClicked); - } - doEvent(enqueue, wait, eClicked); - } } + /** + * Send multiple-pointer event directly to be consumed + *

    + * The index for the element of multiple-pointer arrays represents the pointer which triggered the event + * is passed via actionIdx. + *

    + * + * @param eventType + * @param source + * @param when + * @param modifiers + * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event + * @param pointerType PointerType for each pointer (multiple pointer) + * @param pointerID Pointer ID for each pointer (multiple pointer) + * @param x X-axis for each pointer (multiple pointer) + * @param y Y-axis for each pointer (multiple pointer) + * @param pressure Pressure for each pointer (multiple pointer) + * @param maxPressure Maximum pointer pressure for all pointer + * @param button Corresponding mouse-button + * @param clickCount Mouse-button click-count + * @param rotationXYZ Rotation of all axis + * @param rotationScale Rotation scale + */ + public void sendMouseEvent(short eventType, Object source, long when, int modifiers, + int actionIdx, PointerType pointerType[], short[] pointerID, + int[] x, int[] y, float[] pressure, float maxPressure, + short button, short clickCount, float[] rotationXYZ, float rotationScale) { + final MouseEvent pe = MouseEvent.create(eventType, source, when, modifiers, actionIdx, + pointerType, pointerID, x, y, pressure, maxPressure, button, clickCount, + rotationXYZ, rotationScale); + consumeMouseEvent(pe); + } + @Override - public void addMouseListener(MouseListener l) { + public final void addMouseListener(MouseListener l) { addMouseListener(-1, l); } @Override - public void addMouseListener(int index, MouseListener l) { + public final void addMouseListener(int index, MouseListener l) { if(l == null) { return; } @@ -2439,7 +2517,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void removeMouseListener(MouseListener l) { + public final void removeMouseListener(MouseListener l) { if (l == null) { return; } @@ -2450,7 +2528,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public MouseListener getMouseListener(int index) { + public final MouseListener getMouseListener(int index) { @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); if(0>index) { @@ -2460,14 +2538,273 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public MouseListener[] getMouseListeners() { + public final MouseListener[] getMouseListeners() { return mouseListeners.toArray(new MouseListener[mouseListeners.size()]); } - protected void consumeMouseEvent(MouseEvent e) { + @Override + public final void setDefaultGesturesEnabled(boolean enable) { + defaultGestureHandlerEnabled = enable; + } + @Override + public final boolean areDefaultGesturesEnabled() { + return defaultGestureHandlerEnabled; + } + + @Override + public final void addGestureHandler(GestureHandler gh) { + addGestureHandler(-1, gh); + } + @Override + public final void addGestureHandler(int index, GestureHandler gh) { + if(gh == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList cloned = (ArrayList) pointerGestureHandler.clone(); + if(0>index) { + index = cloned.size(); + } + cloned.add(index, gh); + pointerGestureHandler = cloned; + } + @Override + public final void removeGestureHandler(GestureHandler gh) { + if (gh == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList cloned = (ArrayList) pointerGestureHandler.clone(); + cloned.remove(gh); + pointerGestureHandler = cloned; + } + @Override + public final void addGestureListener(GestureHandler.GestureListener gl) { + addGestureListener(-1, gl); + } + @Override + public final void addGestureListener(int index, GestureHandler.GestureListener gl) { + if(gl == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList cloned = (ArrayList) gestureListeners.clone(); + if(0>index) { + index = cloned.size(); + } + cloned.add(index, gl); + gestureListeners = cloned; + } + @Override + public final void removeGestureListener(GestureHandler.GestureListener gl) { + if (gl == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList cloned = (ArrayList) gestureListeners.clone(); + cloned.remove(gl); + gestureListeners= cloned; + } + + private static int step(int lower, int edge, int value) { + return value < edge ? lower : value; + } + + /** + * Consume the {@link MouseEvent}, i.e. + *
    +     *   - validate
    +     *   - handle gestures
    +     *   - synthesize events if applicable (like gestures)
    +     *   - dispatch event to listener
    +     * 
    + */ + protected void consumeMouseEvent(MouseEvent pe) { + final int x = pe.getX(); + final int y = pe.getY(); + + if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.drop: "+pe); + } + return; // .. invalid .. + } if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent: event: "+e); + System.err.println("consumeMouseEvent.in: "+pe); } + + // + // - Remove redundant events + // - Determine ENTERED/EXITED state + // - synthesize ENTERED event + // - fix MOVED/DRAGGED event + // - Reset states if applicable + // + final long when = pe.getWhen(); + int eventType = pe.getEventType(); + final MouseEvent eEntered; + switch( eventType ) { + case MouseEvent.EVENT_MOUSE_EXITED: + case MouseEvent.EVENT_MOUSE_ENTERED: + pState1.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; + // clear states + pState1.lastButtonPressTime = 0; + pState1.buttonPressed = 0; + eEntered = null; + break; + + case MouseEvent.EVENT_MOUSE_MOVED: + if ( pState1.buttonPressed > 0 ) { + pe = pe.createVariant(MouseEvent.EVENT_MOUSE_DRAGGED); + eventType = pe.getEventType(); + } + // Fall through intended ! + case MouseEvent.EVENT_MOUSE_DRAGGED: + if( pState1.insideWindow && pState1.lastMovePosition.getX() == x && pState1.lastMovePosition.getY() == y ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+pState1.lastMovePosition); + } + return; // skip same position + } + pState1.lastMovePosition.setX(x); + pState1.lastMovePosition.setY(y); + // Fall through intended ! + default: + if(!pState1.insideWindow) { + pState1.insideWindow = true; + eEntered = pe.createVariant(MouseEvent.EVENT_MOUSE_ENTERED); + // clear states + pState1.lastButtonPressTime = 0; + pState1.buttonPressed = 0; + } else { + eEntered = null; + } + } + if( null != eEntered ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.send.0: "+eEntered); + } + dispatchMouseEvent(eEntered); + } + + // + // Handle Default Gestures + // + if( defaultGestureHandlerEnabled && + pe.getPointerType(0).getPointerClass() == MouseEvent.PointerClass.Onscreen ) + { + if( null == gesture2PtrTouchScroll ) { + final int scaledScrollSlop; + final int scaledDoubleTapSlop; + final MonitorDevice monitor = getMainMonitor(); + if ( null != monitor ) { + final DimensionImmutable mm = monitor.getSizeMM(); + final float pixWPerMM = (float)monitor.getCurrentMode().getRotatedWidth() / (float)mm.getWidth(); + final float pixHPerMM = (float)monitor.getCurrentMode().getRotatedHeight() / (float)mm.getHeight(); + final float pixPerMM = Math.min(pixHPerMM, pixWPerMM); + scaledScrollSlop = Math.round(DoubleTapScrollGesture.SCROLL_SLOP_MM * pixPerMM); + scaledDoubleTapSlop = Math.round(DoubleTapScrollGesture.DOUBLE_TAP_SLOP_MM * pixPerMM); + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.gscroll: scrollSlop "+scaledScrollSlop+", doubleTapSlop "+scaledDoubleTapSlop+", pixPerMM "+pixPerMM+", "+monitor); + } + } else { + scaledScrollSlop = DoubleTapScrollGesture.SCROLL_SLOP_PIXEL; + scaledDoubleTapSlop = DoubleTapScrollGesture.DOUBLE_TAP_SLOP_PIXEL; + } + gesture2PtrTouchScroll = new DoubleTapScrollGesture(step(DoubleTapScrollGesture.SCROLL_SLOP_PIXEL, DoubleTapScrollGesture.SCROLL_SLOP_PIXEL/2, scaledScrollSlop), + step(DoubleTapScrollGesture.DOUBLE_TAP_SLOP_PIXEL, DoubleTapScrollGesture.DOUBLE_TAP_SLOP_PIXEL/2, scaledDoubleTapSlop)); + } + if( gesture2PtrTouchScroll.process(pe) ) { + pe = (MouseEvent) gesture2PtrTouchScroll.getGestureEvent(); + gesture2PtrTouchScroll.clear(false); + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.gscroll: "+pe); + } + dispatchMouseEvent(pe); + return; + } + if( gesture2PtrTouchScroll.isWithinGesture() ) { + return; // within gesture .. need more input .. + } + } + // + // Handle Custom Gestures + // + { + final int pointerGestureHandlerCount = pointerGestureHandler.size(); + if( pointerGestureHandlerCount > 0 ) { + boolean withinGesture = false; + for(int i = 0; !pe.isConsumed() && i < pointerGestureHandlerCount; i++ ) { + final GestureHandler gh = pointerGestureHandler.get(i); + if( gh.process(pe) ) { + final InputEvent ieG = gh.getGestureEvent(); + gh.clear(false); + if( ieG instanceof MouseEvent ) { + dispatchMouseEvent((MouseEvent)ieG); + } else if( ieG instanceof GestureHandler.GestureEvent) { + final GestureHandler.GestureEvent ge = (GestureHandler.GestureEvent) ieG; + for(int j = 0; !ge.isConsumed() && j < gestureListeners.size(); j++ ) { + gestureListeners.get(j).gestureDetected(ge); + } + } + return; + } + withinGesture |= gh.isWithinGesture(); + } + if( withinGesture ) { + return; + } + } + } + + // + // Synthesize mouse click + // + final MouseEvent eClicked; + switch( eventType ) { + case MouseEvent.EVENT_MOUSE_PRESSED: + if( 1 == pe.getPointerCount() ) { + pState1.lastButtonPressTime = when; + } + pState1.buttonPressed = pe.getButton(); + eClicked = null; + break; + case MouseEvent.EVENT_MOUSE_RELEASED: + if( 1 == pe.getPointerCount() && when - pState1.lastButtonPressTime < MouseEvent.getClickTimeout() ) { + eClicked = pe.createVariant(MouseEvent.EVENT_MOUSE_CLICKED); + } else { + eClicked = null; + pState1.lastButtonPressTime = 0; + } + pState1.buttonPressed = 0; + break; + case MouseEvent.EVENT_MOUSE_CLICKED: + // ignore - synthesized here .. + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent: drop recv'ed (synth here) "+pe); + } + pe = null; + eClicked = null; + break; + default: + eClicked = null; + } + + if( null != pe ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.send.1: "+pe); + } + dispatchMouseEvent(pe); // actual mouse event + } + if( null != eClicked ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.send.2: "+eClicked); + } + dispatchMouseEvent(eClicked); + } + } + + private final void dispatchMouseEvent(MouseEvent e) { for(int i = 0; !e.isConsumed() && i < mouseListeners.size(); i++ ) { MouseListener l = mouseListeners.get(i); switch(e.getEventType()) { @@ -2537,12 +2874,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask - consumeKeyEvent( KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); + consumeKeyEvent( KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState0.buttonModMask, keyCode, keySym, keyChar) ); } public void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask - enqueueEvent(wait, KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); + enqueueEvent(wait, KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState0.buttonModMask, keyCode, keySym, keyChar) ); } @Override diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 364a348ee..0e76db374 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -59,19 +59,16 @@ public class AndroidNewtEventFactory { private static final short aMotionEventType2Newt(int aType) { switch( aType ) { case android.view.MotionEvent.ACTION_DOWN: + case android.view.MotionEvent.ACTION_POINTER_DOWN: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; case android.view.MotionEvent.ACTION_UP: + case android.view.MotionEvent.ACTION_POINTER_UP: + case android.view.MotionEvent.ACTION_CANCEL: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; case android.view.MotionEvent.ACTION_MOVE: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED; - case android.view.MotionEvent.ACTION_CANCEL: - return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; case android.view.MotionEvent.ACTION_OUTSIDE: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED; - case android.view.MotionEvent.ACTION_POINTER_DOWN: - return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; - case android.view.MotionEvent.ACTION_POINTER_UP: - return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; // case ACTION_HOVER_MOVE case ACTION_SCROLL: // API Level 12 ! return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED; @@ -244,18 +241,15 @@ public class AndroidNewtEventFactory { return maxPressure; } - private final int touchSlop, touchSlopSquare, doubleTapSlop, doubleTapSlopSquare; - + private final int touchSlop; public AndroidNewtEventFactory(android.content.Context context, android.os.Handler handler) { final android.view.ViewConfiguration configuration = android.view.ViewConfiguration.get(context); touchSlop = configuration.getScaledTouchSlop(); - touchSlopSquare = touchSlop * touchSlop; - doubleTapSlop = configuration.getScaledDoubleTapSlop(); - doubleTapSlopSquare = doubleTapSlop * doubleTapSlop; + final int doubleTapSlop = configuration.getScaledDoubleTapSlop(); if(DEBUG_MOUSE_EVENT) { - System.err.println("GestureListener touchSlop (scaled) "+touchSlop); - System.err.println("GestureListener doubleTapSlop (scaled) "+doubleTapSlop); - } + System.err.println("AndroidNewtEventFactory scrollSlop (scaled) "+touchSlop); + System.err.println("AndroidNewtEventFactory doubleTapSlop (scaled) "+doubleTapSlop); + } } private static void collectPointerData(MotionEvent e, int eIdx, int dIdx, final int[] x, final int[] y, final float[] pressure, short[] pointerIds, final com.jogamp.newt.event.MouseEvent.PointerType[] pointerTypes) { @@ -272,8 +266,8 @@ public class AndroidNewtEventFactory { } } - public com.jogamp.newt.event.MouseEvent[] createMouseEvents(boolean isOnTouchEvent, - android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { + public com.jogamp.newt.event.MouseEvent createMouseEvents(boolean isOnTouchEvent, + android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: isOnTouchEvent "+isOnTouchEvent+", "+event); } @@ -285,67 +279,17 @@ public class AndroidNewtEventFactory { // // Prefilter Android Event (Gesture, ..) and determine final type // - final int aType; - final short nType; + final int aType = event.getActionMasked(); + final short nType = aMotionEventType2Newt(aType); final float rotationScale = touchSlop; final float[] rotationXYZ = new float[] { 0f, 0f, 0f }; - int rotationSource = 0; // 1 - Gesture, 2 - ACTION_SCROLL - { - final int aType0 = event.getActionMasked(); - if( isOnTouchEvent ) { - switch ( aType0 ) { - case MotionEvent.ACTION_DOWN: - case MotionEvent.ACTION_POINTER_DOWN: - gesture2FingerScrl.onDown(event); - break; - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_POINTER_UP: - gesture2FingerScrl.onUp(event); - break; - case MotionEvent.ACTION_MOVE: - gesture2FingerScrl.onMove(event); - break; - } - } - - if( gesture2FingerScrl.gestureStarted() ) { - if( gesture2FingerScrl.hasGesture(true) ) { - final float[] rot = gesture2FingerScrl.getScrollDistanceXY(); - rotationXYZ[0] = rot[0] / rotationScale; - rotationXYZ[1] = rot[1] / rotationScale; - aType = ACTION_SCROLL; // 8 - rotationSource = 1; - } else { - return new com.jogamp.newt.event.MouseEvent[0]; // skip, but cont. sending events - } - } else { - aType = aType0; - } - nType = aMotionEventType2Newt(aType); - } if( (short)0 != nType ) { final short clickCount = 1; int modifiers = 0; - if( 0 == rotationSource && AndroidVersion.SDK_INT >= 12 && ACTION_SCROLL == aType ) { // API Level 12 - rotationXYZ[0] = event.getAxisValue(android.view.MotionEvent.AXIS_X) / rotationScale; - rotationXYZ[1] = event.getAxisValue(android.view.MotionEvent.AXIS_Y) / rotationScale; - rotationSource = 2; - } - - if( 0 != rotationSource ) { - if( rotationXYZ[0]*rotationXYZ[0] > rotationXYZ[1]*rotationXYZ[1] ) { - // Horizontal - modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; - } - if(DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: Gesture2FingerScrl Scroll "+rotationXYZ[0]+"/"+rotationXYZ[1]+", "+rotationScale+", mods "+modifiers+", source "+rotationSource); - } - } - // - // Determine newt-button and whether dedicated pointer is pressed + // Determine SDK 12 SCROLL, newt-button and whether dedicated pointer is pressed // final int pIndex; final short button; @@ -361,6 +305,22 @@ public class AndroidNewtEventFactory { } } break; + + case ACTION_SCROLL: + if( AndroidVersion.SDK_INT >= 12 ) { // API Level 12 + rotationXYZ[0] = event.getAxisValue(android.view.MotionEvent.AXIS_X) / rotationScale; + rotationXYZ[1] = event.getAxisValue(android.view.MotionEvent.AXIS_Y) / rotationScale; + + if( rotationXYZ[0]*rotationXYZ[0] > rotationXYZ[1]*rotationXYZ[1] ) { + // Horizontal + modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; + } + if(DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: SDK-12 Scroll "+rotationXYZ[0]+"/"+rotationXYZ[1]+", "+rotationScale+", mods "+modifiers); + } + } + // Fall through intended! + default: { pIndex = 0; button = com.jogamp.newt.event.MouseEvent.BUTTON1; @@ -378,9 +338,9 @@ public class AndroidNewtEventFactory { final com.jogamp.newt.event.MouseEvent.PointerType[] pointerTypes = new com.jogamp.newt.event.MouseEvent.PointerType[pCount]; if( 0 < pCount ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: collect ptr-data [0.."+(pCount-1)+", count "+pCount+", action "+pIndex+"], aType "+aType+", button "+button+", twoFingerScrollGesture "+gesture2FingerScrl); + System.err.println("createMouseEvent: collect ptr-data [0.."+(pCount-1)+", count "+pCount+", action "+pIndex+"], aType "+aType+", button "+button); } - int j = 0; + int j = 0; // Always put action-pointer data at index 0 collectPointerData(event, pIndex, j++, x, y, pressure, pointerIds, pointerTypes); for(int i=0; i < pCount; i++) { @@ -402,202 +362,11 @@ public class AndroidNewtEventFactory { final Object src = (null==newtSource)?null:(Object)newtSource; final long unixTime = System.currentTimeMillis() + ( event.getEventTime() - android.os.SystemClock.uptimeMillis() ); - final com.jogamp.newt.event.MouseEvent me1 = new com.jogamp.newt.event.MouseEvent( - nType, src, unixTime, - modifiers, x, y, pressure, maxPressure, pointerTypes, pointerIds, - clickCount, button, rotationXYZ, rotationScale); - - if( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED == nType ) { - return new com.jogamp.newt.event.MouseEvent[] { me1, - new com.jogamp.newt.event.MouseEvent( - com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED, - src, unixTime, modifiers, x, y, pressure, maxPressure, pointerTypes, pointerIds, - clickCount, button, rotationXYZ, rotationScale) }; - } else { - return new com.jogamp.newt.event.MouseEvent[] { me1 }; - } - } + return new com.jogamp.newt.event.MouseEvent(nType, src, unixTime, + modifiers, pointerTypes, pointerIds, x, y, pressure, maxPressure, + button, clickCount, rotationXYZ, rotationScale); + } return null; // no mapping .. } - - static interface GestureHandler { - /** - * Returns true if last on* command produced a gesture, otherwise false. - * @param clear if true, method clears the gesture flag. - */ - public boolean hasGesture(boolean clear); - /** Returns true if the gesture has started */ - public boolean gestureStarted(); - /** Returns distance of the last consecutive double-tab scrolling. */ - public float[] getScrollDistanceXY(); - public void onDown(android.view.MotionEvent e); - public void onUp(android.view.MotionEvent e); - public void onMove(android.view.MotionEvent e); - } - - /** - * Criteria related to Android parameter: - * - ScaledDoubleTapSlop: - * - Max 2 finger distance to start 'scroll' mode - * - * - ScaledTouchSlop: - * - Min. movement w/ 2 pointer withing ScaledDoubleTapSlop starting 'scroll' mode - * - Max. distance growth in respect to initiated 2-finger distance. - * - * - Tolerate temporary lift of 1/2 pointer - * - * - Always validate pointer-id - */ - private final GestureHandler gesture2FingerScrl = new GestureHandler() { - private final float[] scrollDistance = new float[] { 0f, 0f }; - private int[] pIds = new int[] { -1, -1 }; - private int startDist = -1; - private float downY = 0; - private float downX = 0; - private float lastY = 0; - private float lastX = 0; - private int pointerDownCount = 0; - private boolean withinGesture = false; - private boolean hasGesture = false; - - public String toString() { - return "Gesture2FingerScrl[in "+withinGesture+", has "+hasGesture+", pc "+pointerDownCount+"]"; - } - - private void clear() { - downX = 0f; - downY = 0f; - lastX = 0f; - lastY = 0f; - startDist = -1; - withinGesture = false; - hasGesture = false; - pIds[0] = -1; - pIds[1] = -1; - } - - private final int getSquareDistance(float x1, float y1, float x2, float y2) { - final int deltaX = (int) x1 - (int) x2; - final int deltaY = (int) y1 - (int) y2; - return deltaX * deltaX + deltaY * deltaY; - } - - private int gesturePointers(final android.view.MotionEvent e, final int excludeIndex) { - int j = 0; - for(int i=e.getPointerCount()-1; i>=0; i--) { - if( excludeIndex != i ) { - final int id = e.getPointerId(i); - if( pIds[0] == id || pIds[1] == id ) { - j++; - } - } - } - return j; - } - - @Override - public boolean gestureStarted() { - return 0 <= startDist && withinGesture; - } - - @Override - public boolean hasGesture(boolean clear) { - final boolean r = hasGesture; - if( clear ) { - hasGesture = false; - } - return r; - } - - @Override - public final float[] getScrollDistanceXY() { - return scrollDistance; - } - - @Override - public void onDown(android.view.MotionEvent e) { - pointerDownCount = e.getPointerCount(); - final int gPtr = gesturePointers(e, -1); - if( 2 <= gPtr ) { // pick-up dLast coordinate to cont. gesture after temp loosing 1/2 pointers - lastX = e.getX(0); - lastY = e.getY(0); - } - if(DEBUG_MOUSE_EVENT) { - System.err.println(this+".onDown: gPtr "+gPtr+", "+e); - } - } - - @Override - public void onUp(android.view.MotionEvent e) { - pointerDownCount = e.getPointerCount(); - final int gPtr = gesturePointers(e, e.getActionIndex()); // w/o lifted pointer - if( 1 > gPtr ) { // tolerate lifting 1/2 gesture pointers temporary - clear(); - } - pointerDownCount--; // lifted now! - if(DEBUG_MOUSE_EVENT) { - System.err.println(this+".onUp: gPtr "+gPtr+", "+e); - } - } - - @Override - public void onMove(android.view.MotionEvent e) { - pointerDownCount = e.getPointerCount(); - if( 2 <= pointerDownCount ) { - final float x0 = e.getX(0); - final float y0 = e.getY(0); - final int sqDist = getSquareDistance(x0, y0, e.getX(1), e.getY(1)); - final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; - final int dist = (int)Math.sqrt(sqDist); - if( !withinGesture ) { - int gPtr = 0; - if( isDistWithinDoubleTapSlop ) { - if( 0 > startDist ) { - gPtr = 2; - pIds[0] = e.getPointerId(0); - pIds[1] = e.getPointerId(1); - downX = x0; - downY = y0; - lastX = x0; - lastY = y0; - startDist = dist; - } else { - gPtr = gesturePointers(e, -1); - if( 2 <= gPtr ) { - final int dX = (int) (x0 - downX); - final int dY = (int) (y0 - downY); - final int d = (dX * dX) + (dY * dY); - withinGesture = d > touchSlopSquare; - } - } - } - if(DEBUG_MOUSE_EVENT) { - final double dX = x0 - downX; - final double dY = y0 - downY; - final double d = Math.sqrt( (dX * dX) + (dY * dY) ); - System.err.println(this+".onMove.0: mDist "+d+", pStartDist "+dist+", gPtr "+gPtr+", distWithin2DTSlop "+isDistWithinDoubleTapSlop+", dLast "+lastX+"/"+lastY+", "+e); - } - } - if( withinGesture ) { - final int gPtr = gesturePointers(e, -1); - final boolean isDistGrowthWithinTouchSlop = dist - startDist <= touchSlop; - if( 2 > gPtr || !isDistGrowthWithinTouchSlop ) { - clear(); - } else { - scrollDistance[0] = lastX - x0; - scrollDistance[1] = lastY - y0; - lastX = x0; - lastY = y0; - hasGesture = true; - } - if(DEBUG_MOUSE_EVENT) { - System.err.println(this+".onMove.1: pStartDist "+startDist+", pDist "+dist+", gPtr "+gPtr+" ["+pIds[0]+", "+pIds[1]+"]"+ - ", distWithin2DTSlop "+isDistWithinDoubleTapSlop+", distGrowthWithinTSlop "+isDistGrowthWithinTouchSlop+ - ", dLast "+lastX+"/"+lastY+", d "+scrollDistance[0]+"/"+scrollDistance[1]+", "+e); - } - } - } - } - }; } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java index 93735863e..df52208df 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java @@ -13,13 +13,16 @@ public class AndroidNewtEventTranslator implements View.OnKeyListener, View.OnTo } private final boolean processTouchMotionEvents(View v, android.view.MotionEvent event, boolean isOnTouchEvent) { - final com.jogamp.newt.event.MouseEvent[] newtEvents = factory.createMouseEvents(isOnTouchEvent, event, newtWindow); - if(null != newtEvents) { - newtWindow.focusChanged(false, true); - for(int i=0; i [-30f .. 30f] + } + }; @Override public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { @@ -266,7 +284,6 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL void reshapeImpl(GL2ES2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers(); System.err.println(Thread.currentThread()+" GearsES2.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); - drawableHeight = imageHeight; if( !gl.hasGLSL() ) { return; @@ -326,6 +343,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL final Window window = (Window) upstreamWidget; window.removeMouseListener(gearsMouse); window.removeKeyListener(gearsKeys); + window.removeGestureHandler(pinchToZoomGesture); + pinchToZoomGesture = null; + window.removeGestureListener(pinchToZoomListener); } final GL2ES2 gl = drawable.getGL().getGL2ES2(); if( !gl.hasGLSL() ) { @@ -432,69 +452,6 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL } } - interface GestureHandler { - /** Returns true if within the gesture */ - public boolean isWithinGesture(); - /** Returns true if within the gesture */ - public boolean onReleased(MouseEvent e); - /** Returns true if within the gesture */ - public boolean onDragged(MouseEvent e); - } - final GestureHandler gesture2PtrZoom = new GestureHandler() { - private int zoomLastYDist; - private boolean zoomFirstTouch = true; - private boolean zoomMode = false; - - @Override - public boolean isWithinGesture() { - return zoomMode; - } - - @Override - public boolean onReleased(MouseEvent e) { - if( zoomMode && e.getPointerCount()==1 ) { - zoomFirstTouch = true; - zoomMode = false; - System.err.println("panZ.X: "+e); - } - return zoomMode; - } - - @Override - public boolean onDragged(MouseEvent e) { - if( e.getPointerCount() >=2 ) { - // 2 pointers zoom .. [ -15 .. 15 ], range 30 - /** - // Simple 1:1 Zoom: finger-distance to screen-coord - final int dy = Math.abs(e.getY(0)-e.getY(1)); - float scale = (float)dy / (float)drawableHeight; - panZ = 30f * scale - 15f; - System.err.println("panZ: scale "+scale+" ["+dy+"/"+drawableHeight+"] -> "+panZ); - */ - // Diff. 1:1 Zoom: finger-distance to screen-coord - if(zoomFirstTouch) { - zoomLastYDist = Math.abs(e.getY(0)-e.getY(1)); - zoomFirstTouch=false; - zoomMode = true; - System.err.println("panZ: 1st pinch "+zoomLastYDist+", "+e); - } else if( zoomMode ) { - final int dy = Math.abs(e.getY(0)-e.getY(1)); - final int ddy = dy - zoomLastYDist; - - final float incr = ( (float)ddy / (float)drawableHeight ) * 15.0f; - panZ += incr; - if( e.getPointerCount() > 2 ) { - panZ += incr; - } - System.err.println("panZ.1: ddy "+ddy+", incr "+incr+" ["+dy+"/"+drawableHeight+"], dblZoom "+(e.getPointerCount() > 2)+" -> "+panZ); - - zoomLastYDist = dy; - } - } - return zoomMode; - } - }; - class GearsMouseAdapter implements MouseListener{ private int prevMouseX, prevMouseY; @@ -526,40 +483,33 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL } public void mousePressed(MouseEvent e) { - if( !gesture2PtrZoom.isWithinGesture() ) { - if( e.getPointerCount()==1 ) { - prevMouseX = e.getX(); - prevMouseY = e.getY(); - } else if( e.getPointerCount() == 4 ) { - final Object src = e.getSource(); - if( e.getPressure(true) > 0.7f && src instanceof Window) { // show Keyboard - ((Window) src).setKeyboardVisible(true); - } + if( e.getPointerCount()==1 ) { + prevMouseX = e.getX(); + prevMouseY = e.getY(); + } else if( e.getPointerCount() == 4 ) { + final Object src = e.getSource(); + if( e.getPressure(true) > 0.7f && src instanceof Window) { // show Keyboard + ((Window) src).setKeyboardVisible(true); } } } public void mouseReleased(MouseEvent e) { - gesture2PtrZoom.onReleased(e); } public void mouseMoved(MouseEvent e) { - if( !gesture2PtrZoom.isWithinGesture() && e.getPointerCount()==1 ) { - if( e.isConfined() ) { - navigate(e); - } else { - // track prev. position so we don't have 'jumps' - // in case we move to confined navigation. - prevMouseX = e.getX(); - prevMouseY = e.getY(); - } + if( e.isConfined() ) { + navigate(e); + } else { + // track prev. position so we don't have 'jumps' + // in case we move to confined navigation. + prevMouseX = e.getX(); + prevMouseY = e.getY(); } } public void mouseDragged(MouseEvent e) { - if( !gesture2PtrZoom.onDragged(e) && e.getPointerCount()==1 ) { - navigate(e); - } + navigate(e); } private void navigate(MouseEvent e) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index fe2c0f31a..74be176da 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -266,8 +266,10 @@ public class TestGearsES2NEWT extends UITestCase { }); glWindow.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { - glWindow.setFullscreen(!glWindow.isFullscreen()); - System.err.println("setFullscreen: "+glWindow.isFullscreen()); + if(e.getClickCount() == 2 && e.getPointerCount() == 1) { + glWindow.setFullscreen(!glWindow.isFullscreen()); + System.err.println("setFullscreen: "+glWindow.isFullscreen()); + } } }); -- cgit v1.2.3 From a05b87a369441d9ef38f97929f866b3d4ced0e57 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 15 Oct 2013 17:04:35 +0200 Subject: AWTPrintLifecycle.setupPrint(..): Add optional tileWidth and tileHeight, allowing user to set custom tile size for performance evaluation/tweak --- make/scripts/tests.sh | 4 +-- .../classes/javax/media/opengl/awt/GLCanvas.java | 27 +++++++++----- .../classes/javax/media/opengl/awt/GLJPanel.java | 29 +++++++++------ .../classes/jogamp/opengl/awt/AWTTilePainter.java | 21 ++++++----- .../jogamp/nativewindow/awt/AWTPrintLifecycle.java | 30 ++++++++++------ .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 27 +++++++++----- .../test/junit/jogl/tile/OffscreenPrintable.java | 7 ++-- .../test/junit/jogl/tile/OnscreenPrintable.java | 8 +++-- .../opengl/test/junit/jogl/tile/PrintableBase.java | 8 ++++- .../junit/jogl/tile/TestTiledPrintingGearsAWT.java | 25 +++++++------ .../jogl/tile/TestTiledPrintingGearsNewtAWT.java | 25 +++++++------ .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 31 +++++++++------- .../jogl/tile/TestTiledPrintingGearsSwingAWT2.java | 8 ++--- .../tile/TestTiledPrintingNIOImageSwingAWT.java | 2 +- .../test/junit/jogl/tile/TiledPrintingAWTBase.java | 42 ++++++++++++++-------- 15 files changed, 187 insertions(+), 107 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 84f487c38..a302666f7 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -299,7 +299,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -333,7 +333,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 20dd802fb..b9576b8d6 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -723,18 +723,16 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } private volatile boolean printActive = false; - private int printNumSamples = 0; private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @Override - public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) { + public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { printActive = true; - printNumSamples = numSamples; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); - printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); + printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG); AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); } private final Runnable setupPrintOnEDT = new Runnable() { @@ -760,10 +758,18 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printAnimator.remove(GLCanvas.this); } final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); - final int reqNumSamples = printNumSamples; - printNumSamples = AWTTilePainter.getNumSamples(reqNumSamples, caps); + final int printNumSamples = printAWTTiles.getNumSamples(caps); + GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); + final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); + final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || + printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); + final boolean reqNewGLAD = !caps.getSampleBuffers(); // reqNewGLADSamples || reqNewGLADSize ; if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+", numSamples "+reqNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); + System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ + ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ + ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ + ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ + ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } if( caps.getSampleBuffers() ) { // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX @@ -776,10 +782,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing caps.setNumSamples(printNumSamples); } final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, + null); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); + printDrawable = printGLAD.getDelegatedDrawable(); } - final GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 673f22aff..1ec0ad7bc 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -510,18 +510,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } private volatile boolean printActive = false; - private int printNumSamples = 0; private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @Override - public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) { + public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { printActive = true; - printNumSamples = numSamples; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); - printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); + printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG); AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); } private final Runnable setupPrintOnEDT = new Runnable() { @@ -553,21 +551,32 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printGLAD = GLJPanel.this; // default: re-use final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); - final int reqNumSamples = printNumSamples; - printNumSamples = AWTTilePainter.getNumSamples(reqNumSamples, caps); + final int printNumSamples = printAWTTiles.getNumSamples(caps); + GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); + final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); + final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || + printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); + final boolean reqNewGLAD = reqNewGLADSamples || reqNewGLADSize ; if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+", numSamples "+reqNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); + System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ + ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ + ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ + ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ + ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } - if( printNumSamples != caps.getNumSamples() ) { + if( reqNewGLAD ) { caps.setDoubleBuffered(false); caps.setOnscreen(false); caps.setSampleBuffers(0 < printNumSamples); caps.setNumSamples(printNumSamples); final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, + null); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); + printDrawable = printGLAD.getDelegatedDrawable(); } - final GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index 0600d99f5..9bdceff48 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -71,6 +71,7 @@ public class AWTTilePainter { public final TileRenderer renderer; public final int componentCount; public final double scaleMatX, scaleMatY; + public final int customTileWidth, customTileHeight, customNumSamples; public final boolean verbose; public boolean flipVertical; @@ -99,18 +100,16 @@ public class AWTTilePainter { } /** - * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples - * @param caps used capabilties - * @return resulting number of samples, 0 if disabled + * @return resulting number of samples by comparing w/ {@link #customNumSamples} and the caps-config, 0 if disabled */ - public static int getNumSamples(int numSamples, GLCapabilitiesImmutable caps) { - if( 0 > numSamples ) { + public int getNumSamples(GLCapabilitiesImmutable caps) { + if( 0 > customNumSamples ) { return 0; - } else if( 0 < numSamples ) { + } else if( 0 < customNumSamples ) { if ( !caps.getGLProfile().isGL2ES3() ) { return 0; } - return Math.max(caps.getNumSamples(), numSamples); + return Math.max(caps.getNumSamples(), customNumSamples); } else { return caps.getNumSamples(); } @@ -130,14 +129,20 @@ public class AWTTilePainter { * @param componentCount * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels + * @param numSamples custom multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param verbose */ - public AWTTilePainter(TileRenderer renderer, int componentCount, double scaleMatX, double scaleMatY, boolean verbose) { + public AWTTilePainter(TileRenderer renderer, int componentCount, double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight, boolean verbose) { this.renderer = renderer; this.renderer.setGLEventListener(preTileGLEL, postTileGLEL); this.componentCount = componentCount; this.scaleMatX = scaleMatX; this.scaleMatY = scaleMatY; + this.customNumSamples = numSamples; + this.customTileWidth= tileWidth; + this.customTileHeight = tileHeight; this.verbose = verbose; this.flipVertical = true; } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java index 65e5ab3f0..e5290aee1 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java @@ -47,9 +47,9 @@ import jogamp.nativewindow.awt.AWTMisc; *

    * Users attempting to print an AWT {@link Container} containing {@link AWTPrintLifecycle} elements * shall consider decorating the {@link Container#printAll(Graphics)} call with
    - * {@link #setupPrint(double, double, int) setupPrint(..)} and {@link #releasePrint()} + * {@link #setupPrint(double, double, int, int, int) setupPrint(..)} and {@link #releasePrint()} * on all {@link AWTPrintLifecycle} elements in the {@link Container}.
    - * To minimize this burden, a user can use {@link Context#setupPrint(Container, double, double, int) Context.setupPrint(..)}: + * To minimize this burden, a user can use {@link Context#setupPrint(Container, double, double, int, int, int) Context.setupPrint(..)}: *

      *  Container cont;
      *  double scaleGLMatXY = 72.0/glDPI;
    @@ -75,7 +75,7 @@ import jogamp.nativewindow.awt.AWTMisc;
      */
     public interface AWTPrintLifecycle {
     
    -    public static final int DEFAULT_PRINT_TILE_SIZE = 512;
    +    public static final int DEFAULT_PRINT_TILE_SIZE = 1024;
         
         
         /**
    @@ -86,8 +86,10 @@ public interface AWTPrintLifecycle {
          * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels
          * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels
          * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples 
    +     * @param tileWidth custom tile width for {@link com.jogamp.opengl.util.TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
    +     * @param tileHeight custom tile height for {@link com.jogamp.opengl.util.TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
          */
    -    void setupPrint(double scaleMatX, double scaleMatY, int numSamples);
    +    void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight);
         
         /**
          * Shall be called after {@link PrinterJob#print()}.
    @@ -98,7 +100,7 @@ public interface AWTPrintLifecycle {
         void releasePrint();
     
         /**
    -     * Convenient {@link AWTPrintLifecycle} context simplifying calling {@link AWTPrintLifecycle#setupPrint(double, double, int) setupPrint(..)}
    +     * Convenient {@link AWTPrintLifecycle} context simplifying calling {@link AWTPrintLifecycle#setupPrint(double, double, int, int, int) setupPrint(..)}
          * and {@link AWTPrintLifecycle#releasePrint()} on all {@link AWTPrintLifecycle} elements of a {@link Container}.
          * 

    * See Usage. @@ -110,14 +112,16 @@ public interface AWTPrintLifecycle { * See Usage. *

    * - * @param c container to be traversed through to perform {@link AWTPrintLifecycle#setupPrint(double, double, int) setupPrint(..)} on all {@link AWTPrintLifecycle} elements. + * @param c container to be traversed through to perform {@link AWTPrintLifecycle#setupPrint(double, double, int, int, int) setupPrint(..)} on all {@link AWTPrintLifecycle} elements. * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @return the context */ - public static Context setupPrint(Container c, double scaleMatX, double scaleMatY, int numSamples) { - final Context t = new Context(c, scaleMatX, scaleMatY, numSamples); + public static Context setupPrint(Container c, double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { + final Context t = new Context(c, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight); t.setupPrint(c); return t; } @@ -132,7 +136,7 @@ public interface AWTPrintLifecycle { } /** - * @return count of performed actions of last {@link #setupPrint(Container, double, double, int) setupPrint(..)} or {@link #releasePrint()}. + * @return count of performed actions of last {@link #setupPrint(Container, double, double, int, int, int) setupPrint(..)} or {@link #releasePrint()}. */ public int getCount() { return count; } @@ -140,12 +144,14 @@ public interface AWTPrintLifecycle { private final double scaleMatX; private final double scaleMatY; private final int numSamples; + private final int tileWidth; + private final int tileHeight; private int count; private final AWTMisc.ComponentAction setupAction = new AWTMisc.ComponentAction() { @Override public void run(Component c) { - ((AWTPrintLifecycle)c).setupPrint(scaleMatX, scaleMatY, numSamples); + ((AWTPrintLifecycle)c).setupPrint(scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight); } }; private final AWTMisc.ComponentAction releaseAction = new AWTMisc.ComponentAction() { @Override @@ -153,11 +159,13 @@ public interface AWTPrintLifecycle { ((AWTPrintLifecycle)c).releasePrint(); } }; - private Context(Container c, double scaleMatX, double scaleMatY, int numSamples) { + private Context(Container c, double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { this.cont = c; this.scaleMatX = scaleMatX; this.scaleMatY = scaleMatY; this.numSamples = numSamples; + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; this.count = 0; } private void setupPrint(Container c) { diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 73b3bc368..767533d40 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -471,7 +471,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } private volatile boolean printActive = false; - private int printNumSamples = 0; private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @@ -484,12 +483,11 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } @Override - public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) { + public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { printActive = true; - printNumSamples = numSamples; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); - printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); + printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG); AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); } private final Runnable setupPrintOnEDT = new Runnable() { @@ -522,10 +520,18 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto printAnimator.remove(glad); } final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); - final int reqNumSamples = printNumSamples; - printNumSamples = AWTTilePainter.getNumSamples(reqNumSamples, caps); + final int printNumSamples = printAWTTiles.getNumSamples(caps); + GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); + final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); + final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || + printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); + final boolean reqNewGLAD = !caps.getSampleBuffers(); // reqNewGLADSamples || reqNewGLADSize ; if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+", numSamples "+reqNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); + System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ + ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ + ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ + ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ + ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } if( caps.getSampleBuffers() ) { // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX @@ -538,10 +544,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto caps.setNumSamples(printNumSamples); } final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, + null); GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); + printDrawable = printGLAD.getDelegatedDrawable(); } - final GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java index bd526419c..78fdde3ee 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java @@ -45,6 +45,7 @@ import javax.imageio.ImageIO; import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.nativewindow.awt.DirectDataBufferInt; +import com.jogamp.opengl.util.TileRenderer; /** * {@link Printable} implementation using NIO {@link DirectDataBufferInt} {@link BufferedImage} @@ -64,11 +65,13 @@ public class OffscreenPrintable extends PrintableBase implements Printable { * @param printContainer * @param printDPI * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param imageType AWT BufferedImage type (must be one of the integer types) * @param pngFilename TODO */ - public OffscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples, int imageType, String pngFilename) { - super(job, printContainer, printDPI, numSamples); + public OffscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples, int tileWidth, int tileHeight, int imageType, String pngFilename) { + super(job, printContainer, printDPI, numSamples, tileWidth, tileHeight); this.imageType = imageType; this.pngFilename = pngFilename; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java index 7e8bac295..6f73ef2b4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java @@ -39,6 +39,7 @@ import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import com.jogamp.common.util.awt.AWTEDTExecutor; +import com.jogamp.opengl.util.TileRenderer; /** *
    Scaling of Frame and GL content
    @@ -66,11 +67,14 @@ public class OnscreenPrintable extends PrintableBase implements Printable { * @param printContainer * @param printDPI * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. */ - public OnscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples) { - super(job, printContainer, printDPI, numSamples); + public OnscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples, int tileWidth, int tileHeight) { + super(job, printContainer, printDPI, numSamples, tileWidth, tileHeight); } + @Override public int print(Graphics g, PageFormat pf, int page) throws PrinterException { if (page > 0) { // We have only one page, and 'page' is zero-based diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java index 830ded960..dd9de60c3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java @@ -33,6 +33,7 @@ import java.awt.print.PrinterJob; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.opengl.util.TileRenderer; /** * Base {@link Printable} implementation class. @@ -58,6 +59,7 @@ public abstract class PrintableBase implements Printable { public final Container cont; public final int dpi; public final int numSamples; + public final int tileWidth, tileHeight; protected final RecursiveLock lockPrinting = LockFactory.createRecursiveLock(); /** @@ -66,12 +68,16 @@ public abstract class PrintableBase implements Printable { * @param printContainer * @param printDPI * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. */ - public PrintableBase(PrinterJob job, Container printContainer, int printDPI, int numSamples) { + public PrintableBase(PrinterJob job, Container printContainer, int printDPI, int numSamples, int tileWidth, int tileHeight) { this.job = job; this.cont = printContainer; this.dpi = printDPI; this.numSamples = numSamples; + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; } /** Wait for idle .. simply acquiring all locks and releasing them. */ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java index 4883df501..30e0ba4e6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java @@ -116,15 +116,15 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 72, 0); + doPrintManual(frame, 72, 0, -1, -1); } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 300, -1); + doPrintManual(frame, 300, -1, -1, -1); } }; final ActionListener print600DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 600, -1); + doPrintManual(frame, 600, -1, -1, -1); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); @@ -178,36 +178,41 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { if( !printDone ) { printDone = true; { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, 2048, 2048, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, true/* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, true/* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } if( allow600dpi ) { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java index a256d964f..ec1d7b1d6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java @@ -121,15 +121,15 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 72, 0); + doPrintManual(frame, 72, 0, -1, -1); } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 300, -1); + doPrintManual(frame, 300, -1, -1, -1); } }; final ActionListener print600DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 600, -1); + doPrintManual(frame, 600, -1, -1, -1); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); @@ -183,36 +183,41 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { if( !printDone ) { printDone = true; { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, 2048, 2048, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } if( allow600dpi ) { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java index f1759798b..72cb219ab 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java @@ -152,15 +152,15 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 72, 0); + doPrintManual(frame, 72, 0, -1, -1); } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 300, -1); + doPrintManual(frame, 300, -1, -1, -1); } }; final ActionListener print600DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 600, -1); + doPrintManual(frame, 600, -1, -1, -1); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); @@ -217,51 +217,56 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { if( !printDone ) { printDone = true; { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, 2048, 2048, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_RGB /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_BGR /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_RGB /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_BGR /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } if( allow600dpi ) { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java index d18def075..2d4973d6b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java @@ -142,15 +142,15 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 72, 0); + doPrintManual(frame, 72, 0, -1, -1); } }; final ActionListener print150DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 150, -1); + doPrintManual(frame, 150, -1, -1, -1); } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 300, -1); + doPrintManual(frame, 300, -1, -1, -1); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); @@ -220,7 +220,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { printDone = true; { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.PORTRAIT, null, -1 /* offscreen-type */, 150, -1, false); + final PrintableBase p = doPrintAuto(frame, PageFormat.PORTRAIT, null, -1 /* offscreen-type */, 150, -1, -1, -1, false); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java index 0fe08ebc2..b51bfae87 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java @@ -128,7 +128,7 @@ public class TestTiledPrintingNIOImageSwingAWT extends UITestCase { g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); // frame.paintAll(g2d); - final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, 1.0/scaleComp72, 1.0/scaleComp72, 0); + final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, 1.0/scaleComp72, 1.0/scaleComp72, 0, -1, -1); try { frame.printAll(g2d); } finally { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java index e6179aa95..4e9d4bdbe 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java @@ -51,11 +51,13 @@ import jogamp.nativewindow.awt.AWTMisc; import org.junit.Assert; +import com.jogamp.common.os.Platform; import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.awt.AWTPrintLifecycle; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.TileRenderer; /** * Base unit test class implementing @@ -79,9 +81,12 @@ public abstract class TiledPrintingAWTBase extends UITestCase { * @param offscrnImageType if < 0 onscreen, otherwise integer BufferedImage type * @param dpi * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param resizeWithinPrintTest TODO */ - public PrintableBase doPrintAuto(Container cont, int pOrientation, Paper paper, int offscrnImageType, int dpi, int numSamples, boolean resizeWithinPrintTest) { + public PrintableBase doPrintAuto(Container cont, int pOrientation, Paper paper, + int offscrnImageType, int dpi, int numSamples, int tileWidth, int tileHeight, boolean resizeWithinPrintTest) { lock.lock(); try { final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); @@ -98,12 +103,13 @@ public abstract class TiledPrintingAWTBase extends UITestCase { StreamPrintServiceFactory[] factories = PrinterJob.lookupStreamPrintServices(pdfMimeType); if (factories.length > 0) { - final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, "pdf", resizeWithinPrintTest); + final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, tileWidth, tileHeight, "pdf", resizeWithinPrintTest); System.err.println("doPrint: dpi "+dpi+", "+fname); FileOutputStream outstream; try { outstream = new FileOutputStream(fname); - return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples, resizeWithinPrintTest); + return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, + offscrnImageType, dpi, numSamples, tileWidth, tileHeight, resizeWithinPrintTest); } catch (FileNotFoundException e) { Assert.assertNull("Unexpected exception", e); } @@ -112,12 +118,12 @@ public abstract class TiledPrintingAWTBase extends UITestCase { factories = PrinterJob.lookupStreamPrintServices(psMimeType); if (factories.length > 0) { - final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, "ps", resizeWithinPrintTest); + final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, tileWidth, tileHeight, "ps", resizeWithinPrintTest); System.err.println("doPrint: dpi "+dpi+", "+fname); FileOutputStream outstream; try { outstream = new FileOutputStream(fname); - return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples, resizeWithinPrintTest); + return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples, tileWidth, tileHeight, resizeWithinPrintTest); } catch (FileNotFoundException e) { Assert.assertNull("Unexpected exception", e); } @@ -128,17 +134,17 @@ public abstract class TiledPrintingAWTBase extends UITestCase { lock.unlock(); } } - private String getPrintFilename(int offscrnImageType, int dpi, int numSamples, String suffix, boolean resizeWithinPrintTest) { + private String getPrintFilename(int offscrnImageType, int dpi, int numSamples, int tileWidth, int tileHeight, String suffix, boolean resizeWithinPrintTest) { final int maxSimpleTestNameLen = getMaxTestNameLen()+getClass().getSimpleName().length()+1; final String simpleTestName = getSimpleTestName("."); final String onoffscrn = 0 > offscrnImageType ? "on_screen" : "offscrn_"+offscrnImageType; final String aa = 0 <= numSamples ? "aa"+numSamples : "aaN"; - return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-%s-dpi%03d-%s-resize%d.%s", - simpleTestName, printCount, onoffscrn, dpi, aa, resizeWithinPrintTest?1:0, suffix).replace(' ', '_'); + return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-%s-dpi%03d-%s-tSz%04dx%04d-resize%d.%s", + simpleTestName, printCount, onoffscrn, dpi, aa, tileWidth, tileHeight, resizeWithinPrintTest?1:0, suffix).replace(' ', '_'); } private PrintableBase doPrintAutoImpl(Container cont, PrinterJob job, StreamPrintService ps, int pOrientation, Paper paper, - int offscrnImageType, int dpi, int numSamples, boolean resizeWithinPrintTest) { + int offscrnImageType, int dpi, int numSamples, int tileWidth, int tileHeight, boolean resizeWithinPrintTest) { try { PageFormat pageFormat = job.defaultPage(); if( null != paper ) { @@ -152,9 +158,9 @@ public abstract class TiledPrintingAWTBase extends UITestCase { job.setPrintService(ps); final PrintableBase printable; if( 0 < offscrnImageType ) { - printable = new OffscreenPrintable(job, cont, dpi, numSamples, offscrnImageType, getPrintFilename(offscrnImageType, dpi, numSamples, "png", resizeWithinPrintTest)); + printable = new OffscreenPrintable(job, cont, dpi, numSamples, tileWidth, tileHeight, offscrnImageType, getPrintFilename(offscrnImageType, dpi, numSamples, tileWidth, tileHeight, "png", resizeWithinPrintTest)); } else { - printable = new OnscreenPrintable(job, cont, dpi, numSamples); + printable = new OnscreenPrintable(job, cont, dpi, numSamples, tileWidth, tileHeight); } printable.job.setPrintable(printable, pageFormat); doPrintImpl(printable, resizeWithinPrintTest); @@ -166,15 +172,16 @@ public abstract class TiledPrintingAWTBase extends UITestCase { } /** - * * @param cont * @param dpi * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. */ - public PrintableBase doPrintManual(Container cont, int dpi, int numSamples) { + public PrintableBase doPrintManual(Container cont, int dpi, int numSamples, int tileWidth, int tileHeight) { lock.lock(); try { - final OnscreenPrintable printable = new OnscreenPrintable(PrinterJob.getPrinterJob(), cont, dpi, numSamples); + final OnscreenPrintable printable = new OnscreenPrintable(PrinterJob.getPrinterJob(), cont, dpi, numSamples, tileWidth, tileHeight); printable.job.setPrintable(printable); boolean ok = printable.job.printDialog(); if (ok) { @@ -207,10 +214,13 @@ public abstract class TiledPrintingAWTBase extends UITestCase { final double scaleGLMatXY = 72.0 / printable.dpi; System.err.println("PRINTable: "+printable.getClass().getSimpleName()); System.err.println("PRINT DPI: "+printable.dpi+", AA "+printable.numSamples+", scaleGL "+scaleGLMatXY); - final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(printable.cont, scaleGLMatXY, scaleGLMatXY, printable.numSamples); + final AWTPrintLifecycle.Context ctx = + AWTPrintLifecycle.Context.setupPrint(printable.cont, scaleGLMatXY, scaleGLMatXY, + printable.numSamples, printable.tileWidth, printable.tileHeight); System.err.println("PRINT AWTPrintLifecycle.setup.count "+ctx.getCount()); final int w = printable.cont.getWidth(); final int h = printable.cont.getHeight(); + final long t0 = Platform.currentTimeMillis(); try { AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { @@ -230,6 +240,8 @@ public abstract class TiledPrintingAWTBase extends UITestCase { } }); } finally { ctx.releasePrint(); + final long td = Platform.currentTimeMillis() - t0; + System.err.println("PRINT Duration "+td+" ms"); if( resizeWithinPrintTest ) { AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { -- cgit v1.2.3 From b831ebadcaea1eea7370f7ec0bffc59eaba7a5ba Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 16 Oct 2013 14:28:27 +0200 Subject: Add efficient set(..all..) to Dimension, Insets, Point and Rectangle of NativeWindow's util types. --- .../classes/com/jogamp/opengl/util/TileRenderer.java | 9 +++------ .../classes/com/jogamp/opengl/util/TileRendererBase.java | 3 +-- .../classes/com/jogamp/nativewindow/awt/JAWTWindow.java | 12 +++--------- .../classes/javax/media/nativewindow/util/Dimension.java | 16 ++++++++++------ .../classes/javax/media/nativewindow/util/Insets.java | 11 +++++++---- .../classes/javax/media/nativewindow/util/Point.java | 11 ++++++----- .../classes/javax/media/nativewindow/util/Rectangle.java | 11 +++++++---- .../classes/jogamp/nativewindow/macosx/OSXUtil.java | 3 +-- src/newt/classes/com/jogamp/newt/MonitorDevice.java | 5 +---- src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 3 +-- src/newt/classes/jogamp/newt/OffscreenWindow.java | 3 +-- src/newt/classes/jogamp/newt/ScreenImpl.java | 5 +---- .../classes/jogamp/newt/driver/awt/WindowDriver.java | 7 ++----- .../classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java | 5 +---- .../jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java | 5 +---- .../jogamp/newt/driver/intel/gdl/ScreenDriver.java | 5 +---- src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java | 5 +---- .../classes/jogamp/newt/driver/windows/ScreenDriver.java | 5 +---- .../classes/jogamp/newt/driver/x11/ScreenDriver.java | 5 +---- 19 files changed, 50 insertions(+), 79 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java index deab8bc3e..999db77a9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java @@ -188,8 +188,7 @@ public class TileRenderer extends TileRendererBase { if( null == imageClippingDim ) { imageClippingDim = new Dimension(width, height); } else { - imageClippingDim.setWidth(width); - imageClippingDim.setHeight(height); + imageClippingDim.set(width, height); } reset(); } @@ -245,10 +244,8 @@ public class TileRenderer extends TileRendererBase { throw new IllegalArgumentException("Tile size must be > 0x0 minus 2*border"); } tileBorder = border; - tileSize.setWidth( width ); - tileSize.setHeight( height ); - tileSizeNB.setWidth( width - 2 * border ); - tileSizeNB.setHeight( height - 2 * border ); + tileSize.set( width, height ); + tileSizeNB.set( width - 2 * border, height - 2 * border ); reset(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index d6c36aa14..0553d5673 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -286,8 +286,7 @@ public abstract class TileRendererBase { * @param height The height of the final image */ public void setImageSize(int width, int height) { - imageSize.setWidth(width); - imageSize.setHeight(height); + imageSize.set(width, height); } /** @see #setImageSize(int, int) */ diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 6e198d961..38a46f214 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -243,17 +243,11 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, System.err.println("JAWTWindow.updateBounds: "+bounds+" -> "+jb); // Thread.dumpStack(); } - bounds.setX(jawtBounds.getX()); - bounds.setY(jawtBounds.getY()); - bounds.setWidth(jawtBounds.getWidth()); - bounds.setHeight(jawtBounds.getHeight()); + bounds.set(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); if(component instanceof Container) { - java.awt.Insets contInsets = ((Container)component).getInsets(); - insets.setLeftWidth(contInsets.left); - insets.setRightWidth(contInsets.right); - insets.setTopHeight(contInsets.top); - insets.setBottomHeight(contInsets.bottom); + final java.awt.Insets contInsets = ((Container)component).getInsets(); + insets.set(contInsets.left, contInsets.right, contInsets.top, contInsets.bottom); } } return changed; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index b52414146..17b4930c5 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -58,22 +58,26 @@ public class Dimension implements Cloneable, DimensionImmutable { } @Override - public int getWidth() { return width; } + public final int getWidth() { return width; } @Override - public int getHeight() { return height; } + public final int getHeight() { return height; } - public void setWidth(int width) { + public final void set(int width, int height) { + this.width = width; + this.height = height; + } + public final void setWidth(int width) { this.width = width; } - public void setHeight(int height) { + public final void setHeight(int height) { this.height = height; } - public Dimension scale(int s) { + public final Dimension scale(int s) { width *= s; height *= s; return this; } - public Dimension add(Dimension pd) { + public final Dimension add(Dimension pd) { width += pd.width ; height += pd.height ; return this; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java index f22668f55..942c12c2b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java @@ -70,10 +70,13 @@ public class Insets implements Cloneable, InsetsImmutable { @Override public final int getTotalHeight() { return t + b; } - public void setLeftWidth(int left) { l = left; } - public void setRightWidth(int right) { r = right; } - public void setTopHeight(int top) { t = top; } - public void setBottomHeight(int bottom) { b = bottom; } + public final void set(int left, int right, int top, int bottom) { + l = left; r = right; t = top; b = bottom; + } + public final void setLeftWidth(int left) { l = left; } + public final void setRightWidth(int right) { r = right; } + public final void setTopHeight(int top) { t = top; } + public final void setBottomHeight(int bottom) { b = bottom; } @Override public boolean equals(Object obj) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index a30d3030e..4c233bb16 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -99,22 +99,23 @@ public class Point implements Cloneable, PointImmutable { return new String( x + " / " + y ); } - public void setX(int x) { this.x = x; } - public void setY(int y) { this.y = y; } + public final void set(int x, int y) { this.x = x; this.y = y; } + public final void setX(int x) { this.x = x; } + public final void setY(int y) { this.y = y; } - public Point translate(Point pd) { + public final Point translate(Point pd) { x += pd.x ; y += pd.y ; return this; } - public Point translate(int dx, int dy) { + public final Point translate(int dx, int dy) { x += dx ; y += dy ; return this; } - public Point scale(int sx, int sy) { + public final Point scale(int sx, int sy) { x *= sx ; y *= sy ; return this; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index 7576f4ec7..bbbfa2932 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -68,6 +68,12 @@ public class Rectangle implements Cloneable, RectangleImmutable { @Override public final int getHeight() { return height; } + public final void set(int x, int y, int width, int height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } public final void setX(int x) { this.x = x; } public final void setY(int y) { this.y = y; } public final void setWidth(int width) { this.width = width; } @@ -100,10 +106,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { y1 = Math.min(y1, vp.getY()); y2 = Math.max(y2, vp.getY() + vp.getHeight()); } - setX(x1); - setY(y1); - setWidth(x2 - x1); - setHeight(y2 - y1); + set(x1, y1, x2 - x1, y2 - y1); return this; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index dc32bd58c..0d498fa54 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -113,8 +113,7 @@ public class OSXUtil implements ToolkitProperties { if(topLevel) { // top-level position -> client window position final Insets insets = GetInsets(windowOrView); - los.setX(los.getX() + insets.getLeftWidth()); - los.setY(los.getY() + insets.getTopHeight()); + los.set(los.getX() + insets.getLeftWidth(), los.getY() + insets.getTopHeight()); } return los; } diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index 8bc7f40e3..42ac34240 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -183,10 +183,7 @@ public abstract class MonitorDevice { y1 = Math.min(y1, vp.getY()); y2 = Math.max(y2, vp.getY() + vp.getHeight()); } - result.setX(x1); - result.setY(y1); - result.setWidth(x2 - x1); - result.setHeight(y2 - y1); + result.set(x1, y1, x2 - x1, y2 - y1); return result; } diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 2fa83e0e2..a2135273b 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -497,8 +497,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if( isOSX ) { final Point los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); // top-level position -> client window position - los.setX(los.getX() + insets.getLeftWidth()); - los.setY(los.getY() + insets.getTopHeight()); + los.set(los.getX() + insets.getLeftWidth(), los.getY() + insets.getTopHeight()); if(null!=point) { return point.translate(los); } else { diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index 911d371d5..0a302d76b 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -132,8 +132,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { @Override public Point getLocationOnScreen(Point storage) { if(null!=storage) { - storage.setX(0); - storage.setY(0); + storage.set(0, 0); return storage; } return new Point(0,0); diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 5ffa2ebbf..7068d7464 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -285,10 +285,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { */ protected void updateVirtualScreenOriginAndSize() { if(null != usrSize ) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(usrSize.getWidth()); - vOriginSize.setHeight(usrSize.getHeight()); + vOriginSize.set(0, 0, usrSize.getWidth(), usrSize.getHeight()); if(DEBUG) { System.err.println("Update user virtual screen viewport @ "+Thread.currentThread().getName()+": "+vOriginSize); } diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index c45a5ae3b..77daa556f 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -177,11 +177,8 @@ public class WindowDriver extends WindowImpl { } protected void updateInsetsImpl(javax.media.nativewindow.util.Insets insets) { - Insets contInsets = awtContainer.getInsets(); - insets.setLeftWidth(contInsets.left); - insets.setRightWidth(contInsets.right); - insets.setTopHeight(contInsets.top); - insets.setBottomHeight(contInsets.bottom); + final Insets contInsets = awtContainer.getInsets(); + insets.set(contInsets.left, contInsets.right, contInsets.top, contInsets.bottom); } private void setCanvasSizeImpl(int width, int height) { diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java index afaedffe3..abe2908b0 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java @@ -101,10 +101,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { } protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(fixedWidth); // FIXME - vOriginSize.setHeight(fixedHeight); // FIXME + vOriginSize.set(0, 0, fixedWidth, fixedHeight); // FIXME } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java index f7973def8..be99052d7 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java @@ -95,10 +95,7 @@ public class ScreenDriver extends ScreenImpl { @Override protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(cachedWidth); - vOriginSize.setHeight(cachedHeight); + vOriginSize.set(0, 0, cachedWidth, cachedHeight); } /** Called from {@link #initNative()}. */ diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java index 4c47eb0d8..27b776562 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java @@ -103,10 +103,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { } protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(cachedWidth); - vOriginSize.setHeight(cachedHeight); + vOriginSize.set(0, 0, cachedWidth, cachedHeight); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java index dc87c3c08..f893275ca 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java @@ -99,10 +99,7 @@ public class ScreenDriver extends ScreenImpl { } protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(cachedWidth); - vOriginSize.setHeight(cachedHeight); + vOriginSize.set(0, 0, cachedWidth, cachedHeight); } protected void sizeChanged(int w, int h) { diff --git a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java index 342829691..621091320 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java @@ -155,10 +155,7 @@ public class ScreenDriver extends ScreenImpl { @Override protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { - vOriginSize.setX(getVirtualOriginX0()); - vOriginSize.setY(getVirtualOriginY0()); - vOriginSize.setWidth(getVirtualWidthImpl0()); - vOriginSize.setHeight(getVirtualHeightImpl0()); + vOriginSize.set(getVirtualOriginX0(), getVirtualOriginY0(), getVirtualWidthImpl0(), getVirtualHeightImpl0()); } // Native calls diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index f37556dd7..c01d899f8 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -237,10 +237,7 @@ public class ScreenDriver extends ScreenImpl { } else */ { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(getWidth0(dpy, screen_idx)); - vOriginSize.setHeight(getHeight0(dpy, screen_idx)); + vOriginSize.set(0, 0, getWidth0(dpy, screen_idx), getHeight0(dpy, screen_idx)); return null; } } ); if( DEBUG ) { -- cgit v1.2.3 From 56322e1cf41bbb5bcc097164fb3ddcc0061c1c73 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 04:56:31 +0200 Subject: MouseEvent: Clarify 'Multiple-Pointer' w/ button[mask] semantics, ; InputEvent: getButtonDownCount() and isAnyButtonDown(); - Clarify 'Multiple-Pointer' w/ button[mask] semantics - Pointer IDs start w/ 0 and are consecutive numbers. - 'button' == triggering pointer-ID - buttonMask in modifiers show pressed button _and_ pointer-IDs - deprecated BUTTON_NUMBER -> use BUTTON_COUNT (name semantics) --- .../classes/com/jogamp/newt/event/InputEvent.java | 55 ++++++++++++--- .../classes/com/jogamp/newt/event/MouseEvent.java | 80 ++++++++++++++++------ .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 6 +- .../opengl/test/android/MovieCubeActivity0.java | 2 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 2 +- .../junit/newt/event/BaseNewtEventModifiers.java | 4 +- 6 files changed, 110 insertions(+), 39 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index 7712b77e7..1bd67efa5 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -34,6 +34,7 @@ package com.jogamp.newt.event; +import com.jogamp.common.util.IntBitfield; import com.jogamp.newt.Window; @SuppressWarnings("serial") @@ -63,7 +64,8 @@ public abstract class InputEvent extends NEWTEvent public static final int BUTTON8_MASK = 1 << 12; public static final int BUTTON9_MASK = 1 << 13; - public static final int BUTTONLAST_MASK = 1 << 20; // 16 + public static final int BUTTONLAST_MASK = 1 << 20; // 16 buttons + public static final int BUTTONALL_MASK = 0xffff << 5 ; // 16 buttons /** Event is caused by auto-repeat. */ public static final int AUTOREPEAT_MASK = 1 << 29; @@ -78,12 +80,12 @@ public abstract class InputEvent extends NEWTEvent * Returns the corresponding button mask for the given button. *

    * In case the given button lies outside - * of the valid range [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON_NUMBER}], + * of the valid range [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON_COUNT}], * null is returned. *

    */ public static final int getButtonMask(int button) { - if( 0 < button && button <= MouseEvent.BUTTON_NUMBER ) { + if( 0 < button && button <= MouseEvent.BUTTON_COUNT ) { return 1 << ( 4 + button ) ; } return 0; @@ -143,7 +145,7 @@ public abstract class InputEvent extends NEWTEvent if(isAltDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("alt"); } if(isAltGraphDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("altgr"); } if(isAutoRepeat()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("repeat"); } - for(int i=1; i<=MouseEvent.BUTTON_NUMBER; i++) { + for(int i=1; i<=MouseEvent.BUTTON_COUNT; i++) { if(isButtonDown(i)) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("button").append(i); } } if(isConfined()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("confined"); } @@ -154,26 +156,59 @@ public abstract class InputEvent extends NEWTEvent } /** + * See also {@link MouseEvent}'s section about Multiple-Pointer Events. * @return Array of pressed mouse buttons [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON6}]. * If none is down, the resulting array is of length 0. */ public final short[] getButtonsDown() { - int len = 0; - for(int i=1; i<=MouseEvent.BUTTON_NUMBER; i++) { - if( isButtonDown(i) ) { len++; } - } + final int len = getButtonDownCount(); - short[] res = new short[len]; + final short[] res = new short[len]; int j = 0; - for(int i=1; i<=MouseEvent.BUTTON_NUMBER; i++) { + for(int i=1; i<=MouseEvent.BUTTON_COUNT; i++) { if( isButtonDown(i) ) { res[j++] = (short) ( ( MouseEvent.BUTTON1 - 1 ) + i ); } } return res; } + /** + * See also {@link MouseEvent}'s section about Multiple-Pointer Events. + * @param button the button to test + * @return true if the given button is down + */ public final boolean isButtonDown(int button) { return ( modifiers & getButtonMask(button) ) != 0; } + + /** + * Returns the number of pressed buttons by counting the set bits: + *
    +  *     getBitCount(modifiers & BUTTONALL_MASK);
    +  * 
    + *

    + * See also {@link MouseEvent}'s section about Multiple-Pointer Events. + *

    + * @see IntBitfield#getBitCount(int) + * @see #BUTTONALL_MASK + */ + public final int getButtonDownCount() { + return IntBitfield.getBitCount(modifiers & BUTTONALL_MASK); + } + + /** + * Returns true if at least one button is pressed, otherwise false: + *
    +  *     0 != ( modifiers & BUTTONALL_MASK )
    +  * 
    + *

    + * See also {@link MouseEvent}'s section about Multiple-Pointer Events. + *

    + * @see IntBitfield#getBitCount(int) + * @see #BUTTONALL_MASK + */ + public final boolean isAnyButtonDown() { + return 0 != ( modifiers & BUTTONALL_MASK ); + } public String toString() { return toString(null).toString(); diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 2c137ab77..4e13d63fe 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -37,13 +37,24 @@ package com.jogamp.newt.event; /** * Pointer event of type {@link PointerType}. *

    + * The historical misleading class name may change in the future to PointerEvent. + *

    + *

    * http://www.w3.org/Submission/pointer-events/#pointerevent-interface *

    + *
    Multiple-Pointer Events
    *

    * In case an instance represents a multiple-pointer event, i.e. {@link #getPointerCount()} is > 1, - * the first data element of the multiple-pointer fields represents the pointer which triggered the action.
    + * the first data element of the multiple-pointer fields represents the pointer triggering this event.
    * For example {@link #getX(int) e.getX(0)} at {@link #EVENT_MOUSE_PRESSED} returns the data of the pressed pointer, etc. *

    + *

    + * If representing a multiple-pointer event, the {@link #getButton() button number} is equal to the first {@link #getPointerId(int) pointer ID} + * triggering the event and the {@link InputEvent#BUTTON1_MASK button mask bits} in the {@link #getModifiers() modifiers} + * field represents the pressed pointer IDs.
    + * Hence users can query the pressed button count as well as the pressed pointer count via {@link InputEvent#getButtonDownCount()} + * or use the simple query {@link InputEvent#isAnyButtonDown()}. + *

    */ @SuppressWarnings("serial") public class MouseEvent extends InputEvent @@ -93,8 +104,14 @@ public class MouseEvent extends InputEvent public static final short BUTTON9 = 9; /** Maximum number of buttons, value 16 */ - public static final short BUTTON_NUMBER = 16; + public static final short BUTTON_COUNT = 16; + /** + * Maximum number of buttons, value 16. + * @deprecated Use {@link #BUTTON_COUNT} .. semantics. + */ + public static final short BUTTON_NUMBER = 16; + /** Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods). */ public static final float[] getRotationXYZ(final float rotationXorY, final int mods) { final float[] rotationXYZ = new float[] { 0f, 0f, 0f }; @@ -132,14 +149,17 @@ public class MouseEvent extends InputEvent * Constructor for a multiple-pointer event. *

    * First element of multiple-pointer arrays represents the pointer which triggered the event! - *

    + *

    + *

    + * See details for multiple-pointer events. + *

    * * @param eventType * @param source * @param when * @param modifiers * @param pointerType PointerType for each pointer (multiple pointer) - * @param pointerID Pointer ID for each pointer (multiple pointer) + * @param pointerID Pointer ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. * @param x X-axis for each pointer (multiple pointer) * @param y Y-axis for each pointer (multiple pointer) * @param pressure Pressure for each pointer (multiple pointer) @@ -185,9 +205,13 @@ public class MouseEvent extends InputEvent /** * Factory for a multiple-pointer event. *

    - * The index for the element of multiple-pointer arrays represents the pointer which triggered the event - * is passed via actionIdx. + * The index for the multiple-pointer fields representing the triggering pointer is passed via actionIdx. + * If actionIdx is not 0, all multiple-pointer fields values of index 0 + * and actionIdx are swapped so that the pointer-index 0 will represent the triggering pointer. *

    + *

    + * See details for multiple-pointer events. + *

    * * @param eventType * @param source @@ -195,7 +219,7 @@ public class MouseEvent extends InputEvent * @param modifiers * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event * @param pointerType PointerType for each pointer (multiple pointer) - * @param pointerID Pointer ID for each pointer (multiple pointer) + * @param pointerID Pointer ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. * @param x X-axis for each pointer (multiple pointer) * @param y Y-axis for each pointer (multiple pointer) * @param pressure Pressure for each pointer (multiple pointer) @@ -269,7 +293,7 @@ public class MouseEvent extends InputEvent /** * @return the pointer id for the given index. - * return -1 if index not available. + * return -1 if index not available. IDs start w/ 0 and are consecutive numbers. */ public final short getPointerId(int index) { if(0 > index || index >= pointerID.length) { @@ -292,16 +316,22 @@ public class MouseEvent extends InputEvent } /** - * @return array of all pointer IDs for all pointers + * @return array of all pointer IDs for all pointers. IDs start w/ 0 and are consecutive numbers. */ public final short[] getAllPointerIDs() { return pointerID; } + /** + * Returns the button number, e.g. [{@link #BUTTON1}..{@link #BUTTON_COUNT}-1]. + *

    + * See details for multiple-pointer events. + *

    + */ public final short getButton() { return button; } - + public final short getClickCount() { return clickCount; } @@ -315,6 +345,7 @@ public class MouseEvent extends InputEvent } /** + * See details for multiple-pointer events. * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] * @return X-Coord associated with the pointer-index. * @see getPointerId(index) @@ -324,6 +355,7 @@ public class MouseEvent extends InputEvent } /** + * See details for multiple-pointer events. * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] * @return Y-Coord associated with the pointer-index. * @see getPointerId(index) @@ -333,6 +365,7 @@ public class MouseEvent extends InputEvent } /** + * See details for multiple-pointer events. * @return array of all X-Coords for all pointers */ public final int[] getAllX() { @@ -340,6 +373,7 @@ public class MouseEvent extends InputEvent } /** + * See details for multiple-pointer events. * @return array of all Y-Coords for all pointers */ public final int[] getAllY() { @@ -357,6 +391,19 @@ public class MouseEvent extends InputEvent } /** + * See details for multiple-pointer events. + * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] + * @param normalized if true, method returns the normalized pressure, i.e. pressure / maxPressure + * @return The pressure associated with the pointer-index. + * The value of zero is return if not available. + * @see #getMaxPressure() + */ + public final float getPressure(int index, boolean normalized){ + return normalized ? pressure[index] / maxPressure : pressure[index]; + } + + /** + * See details for multiple-pointer events. * @return array of all raw, un-normalized pressures for all pointers */ public final float[] getAllPressures() { @@ -380,17 +427,6 @@ public class MouseEvent extends InputEvent return maxPressure; } - /** - * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] - * @param normalized if true, method returns the normalized pressure, i.e. pressure / maxPressure - * @return The pressure associated with the pointer-index. - * The value of zero is return if not available. - * @see #getMaxPressure() - */ - public final float getPressure(int index, boolean normalized){ - return normalized ? pressure[index] / maxPressure : pressure[index]; - } - /** * Returns a 3-component float array filled with the values of the rotational axis * in the following order: horizontal-, vertical- and z-axis. @@ -496,7 +532,7 @@ public class MouseEvent extends InputEvent /** PointerType for each pointer (multiple pointer) */ private final PointerType pointerType[]; - /** Pointer-ID for each pointer (multiple pointer) */ + /** Pointer-ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. */ private final short pointerID[]; /** X-axis for each pointer (multiple pointer) */ private final int x[]; diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index 1e15070f8..d71ad175b 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -92,7 +92,7 @@ public class AWTNewtEventFactory { getMaskForButtonMethod = _getMaskForButtonMethod; } */ - awtButtonDownMasks = new int[com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER] ; // java.awt.MouseInfo.getNumberOfButtons() ; + awtButtonDownMasks = new int[com.jogamp.newt.event.MouseEvent.BUTTON_COUNT] ; // java.awt.MouseInfo.getNumberOfButtons() ; for (int n = 0 ; n < awtButtonDownMasks.length ; ++n) { awtButtonDownMasks[n] = getAWTButtonDownMaskImpl(n+1); } @@ -153,7 +153,7 @@ public class AWTNewtEventFactory { case 2 : m = java.awt.event.InputEvent.BUTTON2_DOWN_MASK; break; // 1<<11 case 3 : m = java.awt.event.InputEvent.BUTTON3_DOWN_MASK; break; // 1<<12 default: - if( button <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + if( button <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { m = 1 << ( 10 + button ) ; // b4 = 1<<14, b5 = 1<<15, etc } else { m = 0; @@ -179,7 +179,7 @@ public class AWTNewtEventFactory { } public static final short awtButton2Newt(int awtButton) { - if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { return (short)awtButton; } else { return (short)0; diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java index 3d83bfd2c..ec8fa1000 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java @@ -61,7 +61,7 @@ public class MovieCubeActivity0 extends NewtBaseActivity { MouseAdapter showKeyboardMouseListener = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { - if( e.getPointerCount() == 4 && e.getPressure(true) > 0.7f ) { + if( e.getPointerCount() == 4 && e.getPressure(0, true) > 0.7f ) { ((com.jogamp.newt.Window) e.getSource()).setKeyboardVisible(true); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 50037ebf3..53c813563 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -488,7 +488,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL prevMouseY = e.getY(); } else if( e.getPointerCount() == 4 ) { final Object src = e.getSource(); - if( e.getPressure(true) > 0.7f && src instanceof Window) { // show Keyboard + if( e.getPressure(0, true) > 0.7f && src instanceof Window) { // show Keyboard ((Window) src).setKeyboardVisible(true); } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index da09757c5..44d6a2dec 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -300,8 +300,8 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _numButtonsToTest = 3 ; { - if( _numButtonsToTest > com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { - _numButtonsToTest = com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ; + if( _numButtonsToTest > com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { + _numButtonsToTest = com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ; } // These two arrays are assumed to be peers, i.e. are the same -- cgit v1.2.3 From 40863632d1428de015099b5967e5136425e99f25 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 05:25:59 +0200 Subject: Int -> Enum using EnumClass.values()[ordinal] instead of for-loop - FFMPEGNatives's Enums and new MouseEvent.PointerType.valueOf(int) --- .../jogamp/opengl/util/av/impl/FFMPEGNatives.java | 16 ++++++++-------- src/newt/classes/com/jogamp/newt/event/MouseEvent.java | 18 ++++++++++++++---- 2 files changed, 22 insertions(+), 12 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java index 77cf4ff77..89c15b905 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java @@ -93,10 +93,10 @@ interface FFMPEGNatives { COUNT; ///< Number of sample formats. public static SampleFormat valueOf(int i) { - for (SampleFormat fmt : SampleFormat.values()) { - if(fmt.ordinal() == i) { - return fmt; - } + // ordinal = enumValue.ordinal(), reverse: enumValue = EnumClass.values()[ordinal] + final SampleFormat[] all = SampleFormat.values(); + if( 0 <= i && i < all.length ) { + return all[i]; } return null; } @@ -247,10 +247,10 @@ interface FFMPEGNatives { COUNT ///< number of pixel formats in this list ; public static PixelFormat valueOf(int i) { - for (PixelFormat fmt : PixelFormat.values()) { - if(fmt.ordinal() == i) { - return fmt; - } + // ordinal = enumValue.ordinal(), reverse: enumValue = EnumClass.values()[ordinal] + final PixelFormat[] all = PixelFormat.values(); + if( 0 <= i && i < all.length ) { + return all[i]; } return null; } diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 4e13d63fe..fd5e27bdd 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -66,18 +66,28 @@ public class MouseEvent extends InputEvent /** Type of pointer devices */ public static enum PointerType implements InputEvent.InputType { - /** {@link PointerClass#Offscreen} mouse. */ + /** {@link PointerClass#Offscreen} mouse. Ordinal 0. */ Mouse(PointerClass.Offscreen), - /** {@link PointerClass#Offscreen} touch pad, usually using fingers. */ + /** {@link PointerClass#Offscreen} touch pad, usually using fingers. Ordinal 1. */ TouchPad(PointerClass.Offscreen), - /** {@link PointerClass#Onscreen} touch screen, usually using fingers. */ + /** {@link PointerClass#Onscreen} touch screen, usually using fingers. Ordinal 2. */ TouchScreen(PointerClass.Onscreen), - /** {@link PointerClass#Onscreen} pen on screen ?. */ + /** {@link PointerClass#Onscreen} pen usually on screen? Ordinal 3. FIXME*/ Pen(PointerClass.Onscreen), + /** {@link PointerClass#Undefined} ?. Ordinal 4. */ Undefined(PointerClass.Undefined); public PointerClass getPointerClass() { return pc; } + public static PointerType valueOf(int i) { + // ordinal = enumValue.ordinal(), reverse: enumValue = EnumClass.values()[ordinal] + final PointerType[] all = PointerType.values(); + if( 0 <= i && i < all.length ) { + return all[i]; + } + return null; + } + private PointerType(PointerClass pc) { this.pc = pc; } -- cgit v1.2.3 From a90bf31f8747dd38c61d518f8af4d4d4a64a8e90 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 07:56:20 +0200 Subject: NEWT PointerEvent: Unify event processing in new doPointerEvent(..) and consumePointerEvent(..) - Unifies native mouse and Android's pointer event, ready for Win7 touch Unify event processing in new doPointerEvent(..), which is also invoked from doMouseEvent(..), and consumePointerEvent(). doPointerEvent(..): Validates and modifies event data and finally creates the event, where consumePointerEvent(..) calls gesture handlers and may synthesize events. Unifies native mouse and Android's pointer event, ready for Win7 touch. AndroidNewtEventFactory calls doPointerEvent(..) directly. Removed lots of duplicated pointer event handling code. --- make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64-dbg.bat | 4 +- make/scripts/tests.sh | 4 +- .../classes/com/jogamp/newt/event/MouseEvent.java | 98 ++--- src/newt/classes/jogamp/newt/WindowImpl.java | 409 ++++++++++++--------- .../android/event/AndroidNewtEventFactory.java | 64 ++-- .../android/event/AndroidNewtEventTranslator.java | 14 +- 7 files changed, 303 insertions(+), 294 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index b3029f94c..099768f7c 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -58,14 +58,14 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledR REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index c1a14c1a2..bab911e37 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -49,9 +49,9 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" "-Djogl.debug.TileRenderer.PNG" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" -set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" -REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" +set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a302666f7..129b0deab 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -301,7 +301,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -333,7 +333,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index fd5e27bdd..cb9e7a290 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -145,9 +145,17 @@ public class MouseEvent extends InputEvent super(eventType, source, when, modifiers); this.x = new int[]{x}; this.y = new int[]{y}; - this.pressure = constMousePressure; + switch(eventType) { + case EVENT_MOUSE_CLICKED: + case EVENT_MOUSE_PRESSED: + case EVENT_MOUSE_DRAGGED: + this.pressure = constMousePressure1; + break; + default: + this.pressure = constMousePressure0; + } this.maxPressure= 1.0f; - this.pointerID = constMousePointerIDs; + this.pointerID = new short[] { (short)(button - 1) }; this.clickCount=clickCount; this.button=button; this.rotationXYZ = rotationXYZ; @@ -212,70 +220,6 @@ public class MouseEvent extends InputEvent x, y, pressure, maxPressure, button, clickCount, rotationXYZ, rotationScale); } - /** - * Factory for a multiple-pointer event. - *

    - * The index for the multiple-pointer fields representing the triggering pointer is passed via actionIdx. - * If actionIdx is not 0, all multiple-pointer fields values of index 0 - * and actionIdx are swapped so that the pointer-index 0 will represent the triggering pointer. - *

    - *

    - * See details for multiple-pointer events. - *

    - * - * @param eventType - * @param source - * @param when - * @param modifiers - * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event - * @param pointerType PointerType for each pointer (multiple pointer) - * @param pointerID Pointer ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. - * @param x X-axis for each pointer (multiple pointer) - * @param y Y-axis for each pointer (multiple pointer) - * @param pressure Pressure for each pointer (multiple pointer) - * @param maxPressure Maximum pointer pressure for all pointer - * @param button Corresponding mouse-button - * @param clickCount Mouse-button click-count - * @param rotationXYZ Rotation of all axis - * @param rotationScale Rotation scale - */ - public static MouseEvent create(short eventType, Object source, long when, int modifiers, - int actionIdx, PointerType pointerType[], short[] pointerID, - int[] x, int[] y, float[] pressure, float maxPressure, - short button, short clickCount, float[] rotationXYZ, float rotationScale) { - if( 0 <= actionIdx && actionIdx < pointerType.length) { - if( 0 < actionIdx ) { - { - final PointerType aType = pointerType[actionIdx]; - pointerType[actionIdx] = pointerType[0]; - pointerType[0] = aType; - } - { - final short s = pointerID[actionIdx]; - pointerID[actionIdx] = pointerID[0]; - pointerID[0] = s; - } - { - int s = x[actionIdx]; - x[actionIdx] = x[0]; - x[0] = s; - s = y[actionIdx]; - y[actionIdx] = y[0]; - y[0] = s; - } - { - final float aPress = pressure[actionIdx]; - pressure[actionIdx] = pressure[0]; - pressure[0] = aPress; - } - } - return new MouseEvent(eventType, source, when, modifiers, - pointerType, pointerID, x, y, pressure, maxPressure, - button, clickCount, rotationXYZ, rotationScale); - } - throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pointerType.length-1)+"]"); - } - /** * @return the count of pointers involved in this event */ @@ -528,15 +472,15 @@ public class MouseEvent extends InputEvent public static String getEventTypeString(short 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 + ")"; + 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 + ")"; } } @@ -558,8 +502,8 @@ public class MouseEvent extends InputEvent private final float rotationScale; private final float maxPressure; - private static final float[] constMousePressure = new float[]{0f}; - private static final short[] constMousePointerIDs = new short[]{0}; + private static final float[] constMousePressure0 = new float[]{0f}; + private static final float[] constMousePressure1 = new float[]{1f}; private static final PointerType[] constMousePointerTypes = new PointerType[] { PointerType.Mouse }; public static final short EVENT_MOUSE_CLICKED = 200; diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 66ce46ed0..b0df2d894 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -135,6 +135,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** Timeout of queued events (repaint and resize) */ static final long QUEUED_EVENT_TO = 1200; // ms + private static final int[] constMousePointerTypes = new int[] { PointerType.Mouse.ordinal() }; + // // Volatile: Multithread Mutable Access // @@ -181,34 +183,50 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private ArrayList mouseListeners = new ArrayList(); + /** from event passing: {@link WindowImpl#consumePointerEvent(MouseEvent)}. */ private static class PointerState0 { - /** current pressed mouse button number */ - private short buttonPressed = (short)0; - /** current pressed mouse button modifier mask */ - private int buttonModMask = 0; - /** last time when a mouse button was pressed */ - private long lastButtonPressTime = 0; - /** last mouse button click count */ - private short lastButtonClickCount = (short)0; /** mouse entered window - is inside the window (may be synthetic) */ - private boolean insideWindow = false; - /** last mouse-move position */ - private Point lastMovePosition = new Point(); - } - private static class PointerState1 { - /** current pressed mouse button number */ - private short buttonPressed = (short)0; + boolean insideWindow = false; + /** last time when a mouse button was pressed */ - private long lastButtonPressTime = 0; - /** mouse entered window - is inside the window (may be synthetic) */ - private boolean insideWindow = false; - /** last mouse-move position */ - private Point lastMovePosition = new Point(); + long lastButtonPressTime = 0; + + void clearButton() { + lastButtonPressTime = 0; + } } - /** doMouseEvent */ private PointerState0 pState0 = new PointerState0(); - /** consumeMouseEvent */ + + /** from direct input: {@link WindowImpl#doPointerEvent(boolean, boolean, int[], short, int, int, short[], int[], int[], float[], float, float[], float)}. */ + private static class PointerState1 extends PointerState0 { + /** current pressed mouse button number */ + short buttonPressed = (short)0; + /** current pressed mouse button modifier mask */ + int buttonPressedMask = 0; + /** last mouse button click count */ + short lastButtonClickCount = (short)0; + + final void clearButton() { + super.clearButton(); + lastButtonPressTime = 0; + lastButtonClickCount = (short)0; + buttonPressed = 0; + buttonPressedMask = 0; + } + + /** last pointer-move position for 8 touch-down pointers */ + final Point[] movePositions = new Point[] { + new Point(), new Point(), new Point(), new Point(), + new Point(), new Point(), new Point(), new Point() }; + final Point getMovePosition(int id) { + if( 0 <= id && id < movePositions.length ) { + return movePositions[id]; + } + return null; + } + } private PointerState1 pState1 = new PointerState1(); + private boolean defaultGestureHandlerEnabled = true; private DoubleTapScrollGesture gesture2PtrTouchScroll = null; private ArrayList pointerGestureHandler = new ArrayList(); @@ -2247,7 +2265,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public boolean consumeEvent(NEWTEvent e) { + public final boolean consumeEvent(NEWTEvent e) { switch(e.getEventType()) { // special repaint treatment case WindowEvent.EVENT_WINDOW_REPAINT: @@ -2288,7 +2306,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else if(e instanceof KeyEvent) { consumeKeyEvent((KeyEvent)e); } else if(e instanceof MouseEvent) { - consumeMouseEvent((MouseEvent)e); + consumePointerEvent((MouseEvent)e); } else { throw new NativeWindowException("Unexpected NEWTEvent type " + e); } @@ -2347,21 +2365,115 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int x, int y, short button, float[] rotationXYZ, float rotationScale) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); } */ + + /** + * Send mouse event (one-pointer) either to be directly consumed or to be enqueued + * + * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, + * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. + * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. + */ protected void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, int x, int y, short button, float[] rotationXYZ, float rotationScale) { - if( 0 > button || button > MouseEvent.BUTTON_NUMBER ) { + if( 0 > button || button > MouseEvent.BUTTON_COUNT ) { throw new NativeWindowException("Invalid mouse button number" + button); + } else if( 0 == button ) { + button = 1; + } + doPointerEvent(enqueue, wait, constMousePointerTypes, eventType, modifiers, + 0 /*actionIdx*/, new short[] { (short)(button-1) }, + new int[]{x}, new int[]{y}, new float[]{0f} /*pressure*/, 1f /*maxPressure*/, + rotationXYZ, rotationScale); + } + + /** + * Send multiple-pointer event either to be directly consumed or to be enqueued + *

    + * The index for the element of multiple-pointer arrays represents the pointer which triggered the event + * is passed via actionIdx. + *

    + * + * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, + * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. + * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. + * @param pTypesOrdinal {@link MouseEvent.PointerType#ordinal()} for each pointer (multiple pointer) + * @param eventType + * @param modifiers + * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event + * @param pID Pointer ID for each pointer (multiple pointer), we assume pointerID's starts w/ 0 + * @param pX X-axis for each pointer (multiple pointer) + * @param pY Y-axis for each pointer (multiple pointer) + * @param pPressure Pressure for each pointer (multiple pointer) + * @param maxPressure Maximum pointer pressure for all pointer + */ + public void doPointerEvent(boolean enqueue, boolean wait, + int[] pTypesOrdinal, short eventType, int modifiers, + int actionIdx, short[] pID, + int[] pX, int[] pY, float[] pPressure, float maxPressure, + float[] rotationXYZ, float rotationScale) { + final long when = System.currentTimeMillis(); + final int pointerCount = pTypesOrdinal.length; + + if( 0 > actionIdx || actionIdx >= pointerCount) { + throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pointerCount-1)+"]"); + } + if( 0 < actionIdx ) { + // swap values to make idx 0 the triggering pointer + { + final int aType = pTypesOrdinal[actionIdx]; + pTypesOrdinal[actionIdx] = pTypesOrdinal[0]; + pTypesOrdinal[0] = aType; + } + { + final short s = pID[actionIdx]; + pID[actionIdx] = pID[0]; + pID[0] = s; + } + { + int s = pX[actionIdx]; + pX[actionIdx] = pX[0]; + pX[0] = s; + s = pY[actionIdx]; + pY[actionIdx] = pY[0]; + pY[0] = s; + } + { + final float aPress = pPressure[actionIdx]; + pPressure[actionIdx] = pPressure[0]; + pPressure[0] = aPress; + } + } + final PointerType[] pointerType = new PointerType[pointerCount]; + for(int i=pointerCount-1; i>=0; i--) { + pointerType[i] = PointerType.valueOf(pTypesOrdinal[i]); + } + final short id = pID[0]; + final short button; + { + final int b = id + 1; + if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { + button = (short)b; + } else { + button = com.jogamp.newt.event.MouseEvent.BUTTON1; + } } // - // Remove redundant events, determine ENTERED state and reset states if applicable + // - Determine ENTERED/EXITED state + // - Remove redundant move/drag events + // - Reset states if applicable // - final long when = System.currentTimeMillis(); + int x = pX[0]; + int y = pY[0]; + final Point movePositionP0 = pState1.getMovePosition(id); switch( eventType ) { case MouseEvent.EVENT_MOUSE_EXITED: - if( x==-1 && y==-1 ) { - x = pState0.lastMovePosition.getX(); - y = pState0.lastMovePosition.getY(); + if( null != movePositionP0 ) { + if( x==-1 && y==-1 ) { + x = movePositionP0.getX(); + y = movePositionP0.getY(); + } + movePositionP0.set(0, 0); } // Fall through intended! @@ -2369,54 +2481,46 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // clip coordinates to window dimension x = Math.min(Math.max(x, 0), getWidth()-1); y = Math.min(Math.max(y, 0), getHeight()-1); - pState0.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; - // clear states - pState0.lastButtonPressTime = 0; - pState0.lastButtonClickCount = (short)0; - pState0.buttonPressed = 0; - pState0.buttonModMask = 0; + pState1.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; + pState1.clearButton(); break; case MouseEvent.EVENT_MOUSE_MOVED: case MouseEvent.EVENT_MOUSE_DRAGGED: - if( pState0.insideWindow && pState0.lastMovePosition.getX() == x && pState0.lastMovePosition.getY() == y ) { - if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+pState0.lastMovePosition); + if( null != movePositionP0 ) { + if( pState1.insideWindow && movePositionP0.getX() == x && movePositionP0.getY() == y ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("doMouseEvent: skip "+MouseEvent.getEventTypeString(eventType)+" w/ same position: "+movePositionP0); + } + return; // skip same position } - return; // skip same position + movePositionP0.set(x, y); } - pState0.lastMovePosition.setX(x); - pState0.lastMovePosition.setY(y); // Fall through intended ! default: - if(!pState0.insideWindow) { - pState0.insideWindow = true; - - // clear states - pState0.lastButtonPressTime = 0; - pState0.lastButtonClickCount = (short)0; - pState0.buttonPressed = 0; - pState0.buttonModMask = 0; + if(!pState1.insideWindow) { + pState1.insideWindow = true; + pState1.clearButton(); } } if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { if(DEBUG_MOUSE_EVENT) { System.err.println("doMouseEvent: drop: "+MouseEvent.getEventTypeString(eventType)+ - ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+pState0.lastMovePosition); + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); } return; // .. invalid .. } if(DEBUG_MOUSE_EVENT) { System.err.println("doMouseEvent: enqueue "+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+ - ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+pState0.lastMovePosition); + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); } - - modifiers |= InputEvent.getButtonMask(button); // Always add current button to modifier mask (Bug 571) - modifiers |= pState0.buttonModMask; // Always add currently pressed mouse buttons to modifier mask + modifiers |= InputEvent.getButtonMask(button); // Always add current button to modifier mask (Bug 571) + modifiers |= pState1.buttonPressedMask; // Always add currently pressed mouse buttons to modifier mask + if( isPointerConfined() ) { modifiers |= InputEvent.CONFINED_MASK; } @@ -2424,78 +2528,79 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer modifiers |= InputEvent.INVISIBLE_MASK; } - final MouseEvent e; - + pX[0] = x; + pY[0] = y; + + // + // - Determine CLICK COUNT + // - Ignore sent CLICKED + // - Track buttonPressed incl. buttonPressedMask + // - Fix MOVED/DRAGGED event + // + final MouseEvent e; switch( eventType ) { + case MouseEvent.EVENT_MOUSE_CLICKED: + e = null; + break; + case MouseEvent.EVENT_MOUSE_PRESSED: - if( when - pState0.lastButtonPressTime < MouseEvent.getClickTimeout() ) { - pState0.lastButtonClickCount++; + if( 0 >= pPressure[0] ) { + pPressure[0] = maxPressure; + } + pState1.buttonPressedMask |= InputEvent.getButtonMask(button); + if( 1 == pointerCount ) { + if( when - pState1.lastButtonPressTime < MouseEvent.getClickTimeout() ) { + pState1.lastButtonClickCount++; + } else { + pState1.lastButtonClickCount=(short)1; + } + pState1.lastButtonPressTime = when; + pState1.buttonPressed = button; + e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, button, pState1.lastButtonClickCount, rotationXYZ, rotationScale); } else { - pState0.lastButtonClickCount=(short)1; + e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); } - pState0.lastButtonPressTime = when; - pState0.buttonPressed = button; - pState0.buttonModMask |= MouseEvent.getButtonMask(button); - e = new MouseEvent(eventType, this, when, - modifiers, x, y, pState0.lastButtonClickCount, button, rotationXYZ, rotationScale); break; case MouseEvent.EVENT_MOUSE_RELEASED: - e = new MouseEvent(eventType, this, when, - modifiers, x, y, pState0.lastButtonClickCount, button, rotationXYZ, rotationScale); - if( when - pState0.lastButtonPressTime >= MouseEvent.getClickTimeout() ) { - pState0.lastButtonClickCount = (short)0; - pState0.lastButtonPressTime = 0; - } - pState0.buttonPressed = 0; - pState0.buttonModMask &= ~MouseEvent.getButtonMask(button); + if( 1 == pointerCount ) { + e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, button, pState1.lastButtonClickCount, rotationXYZ, rotationScale); + if( when - pState1.lastButtonPressTime >= MouseEvent.getClickTimeout() ) { + pState1.lastButtonClickCount = (short)0; + pState1.lastButtonPressTime = 0; + } + pState1.buttonPressed = 0; + } else { + e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); + } + pState1.buttonPressedMask &= ~InputEvent.getButtonMask(button); + if( null != movePositionP0 ) { + movePositionP0.set(0, 0); + } break; case MouseEvent.EVENT_MOUSE_MOVED: - if ( pState0.buttonPressed > 0 ) { - e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, - modifiers, x, y, (short)1, pState0.buttonPressed, rotationXYZ, rotationScale); + if ( 0 != pState1.buttonPressedMask ) { // any button or pointer move -> drag + e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, pState1.buttonPressed, (short)1, rotationXYZ, rotationScale); } else { - e = new MouseEvent(eventType, this, when, - modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); + e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, button, (short)0, rotationXYZ, rotationScale); } break; + case MouseEvent.EVENT_MOUSE_DRAGGED: + if( 0 >= pPressure[0] ) { + pPressure[0] = maxPressure; + } + // Fall through intended! default: - e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); + e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, button, (short)0, rotationXYZ, rotationScale); } doEvent(enqueue, wait, e); // actual mouse event } - - /** - * Send multiple-pointer event directly to be consumed - *

    - * The index for the element of multiple-pointer arrays represents the pointer which triggered the event - * is passed via actionIdx. - *

    - * - * @param eventType - * @param source - * @param when - * @param modifiers - * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event - * @param pointerType PointerType for each pointer (multiple pointer) - * @param pointerID Pointer ID for each pointer (multiple pointer) - * @param x X-axis for each pointer (multiple pointer) - * @param y Y-axis for each pointer (multiple pointer) - * @param pressure Pressure for each pointer (multiple pointer) - * @param maxPressure Maximum pointer pressure for all pointer - * @param button Corresponding mouse-button - * @param clickCount Mouse-button click-count - * @param rotationXYZ Rotation of all axis - * @param rotationScale Rotation scale - */ - public void sendMouseEvent(short eventType, Object source, long when, int modifiers, - int actionIdx, PointerType pointerType[], short[] pointerID, - int[] x, int[] y, float[] pressure, float maxPressure, - short button, short clickCount, float[] rotationXYZ, float rotationScale) { - final MouseEvent pe = MouseEvent.create(eventType, source, when, modifiers, actionIdx, - pointerType, pointerID, x, y, pressure, maxPressure, button, clickCount, - rotationXYZ, rotationScale); - consumeMouseEvent(pe); - } @Override public final void addMouseListener(MouseListener l) { @@ -2619,25 +2724,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * - dispatch event to listener * */ - protected void consumeMouseEvent(MouseEvent pe) { - final int x = pe.getX(); - final int y = pe.getY(); + private final void consumePointerEvent(MouseEvent pe) { + int x = pe.getX(); + int y = pe.getY(); - if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { - if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent.drop: "+pe); - } - return; // .. invalid .. - } if(DEBUG_MOUSE_EVENT) { System.err.println("consumeMouseEvent.in: "+pe); } // - // - Remove redundant events // - Determine ENTERED/EXITED state - // - synthesize ENTERED event - // - fix MOVED/DRAGGED event + // - Synthesize ENTERED event // - Reset states if applicable // final long when = pe.getWhen(); @@ -2646,36 +2743,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer switch( eventType ) { case MouseEvent.EVENT_MOUSE_EXITED: case MouseEvent.EVENT_MOUSE_ENTERED: - pState1.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; - // clear states - pState1.lastButtonPressTime = 0; - pState1.buttonPressed = 0; + // clip coordinates to window dimension + x = Math.min(Math.max(x, 0), getWidth()-1); + y = Math.min(Math.max(y, 0), getHeight()-1); + pState0.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; + pState0.clearButton(); eEntered = null; break; - case MouseEvent.EVENT_MOUSE_MOVED: - if ( pState1.buttonPressed > 0 ) { - pe = pe.createVariant(MouseEvent.EVENT_MOUSE_DRAGGED); - eventType = pe.getEventType(); - } - // Fall through intended ! - case MouseEvent.EVENT_MOUSE_DRAGGED: - if( pState1.insideWindow && pState1.lastMovePosition.getX() == x && pState1.lastMovePosition.getY() == y ) { - if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+pState1.lastMovePosition); - } - return; // skip same position - } - pState1.lastMovePosition.setX(x); - pState1.lastMovePosition.setY(y); - // Fall through intended ! default: - if(!pState1.insideWindow) { - pState1.insideWindow = true; + if(!pState0.insideWindow) { + pState0.insideWindow = true; + pState0.clearButton(); eEntered = pe.createVariant(MouseEvent.EVENT_MOUSE_ENTERED); - // clear states - pState1.lastButtonPressTime = 0; - pState1.buttonPressed = 0; } else { eEntered = null; } @@ -2685,6 +2765,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("consumeMouseEvent.send.0: "+eEntered); } dispatchMouseEvent(eEntered); + } else if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.drop: "+pe); + } + return; // .. invalid .. } // @@ -2758,25 +2843,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } // - // Synthesize mouse click - // + // - Synthesize mouse CLICKED + // - Ignore sent CLICKED + // final MouseEvent eClicked; switch( eventType ) { case MouseEvent.EVENT_MOUSE_PRESSED: if( 1 == pe.getPointerCount() ) { - pState1.lastButtonPressTime = when; + pState0.lastButtonPressTime = when; } - pState1.buttonPressed = pe.getButton(); eClicked = null; break; case MouseEvent.EVENT_MOUSE_RELEASED: - if( 1 == pe.getPointerCount() && when - pState1.lastButtonPressTime < MouseEvent.getClickTimeout() ) { + if( 1 == pe.getPointerCount() && when - pState0.lastButtonPressTime < MouseEvent.getClickTimeout() ) { eClicked = pe.createVariant(MouseEvent.EVENT_MOUSE_CLICKED); } else { eClicked = null; - pState1.lastButtonPressTime = 0; + pState0.lastButtonPressTime = 0; } - pState1.buttonPressed = 0; break; case MouseEvent.EVENT_MOUSE_CLICKED: // ignore - synthesized here .. @@ -2874,12 +2958,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask - consumeKeyEvent( KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState0.buttonModMask, keyCode, keySym, keyChar) ); + consumeKeyEvent( KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState1.buttonPressedMask, keyCode, keySym, keyChar) ); } public void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask - enqueueEvent(wait, KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState0.buttonModMask, keyCode, keySym, keyChar) ); + enqueueEvent(wait, KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState1.buttonPressedMask, keyCode, keySym, keyChar) ); } @Override @@ -2980,7 +3064,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return e.isConsumed(); } - protected void consumeKeyEvent(KeyEvent e) { + private final void consumeKeyEvent(KeyEvent e) { boolean consumedE = false; if( null != keyboardFocusHandler && !e.isAutoRepeat() ) { consumedE = propagateKeyEvent(e, keyboardFocusHandler); @@ -3059,7 +3143,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return windowListeners.toArray(new WindowListener[windowListeners.size()]); } - protected void consumeWindowEvent(WindowEvent e) { + private final void consumeWindowEvent(WindowEvent e) { if(DEBUG_IMPLEMENTATION) { System.err.println("consumeWindowEvent: "+e+", visible "+isVisible()+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } @@ -3266,10 +3350,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else if ( (left != insets.getLeftWidth() || right != insets.getRightWidth() || top != insets.getTopHeight() || bottom != insets.getBottomHeight() ) ) { - insets.setLeftWidth(left); - insets.setRightWidth(right); - insets.setTopHeight(top); - insets.setBottomHeight(bottom); + insets.set(left, right, top, bottom); if(DEBUG_IMPLEMENTATION) { System.err.println("Window.insetsChanged: (defer: "+defer+") "+insets); } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 0e76db374..23c32993f 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -252,22 +252,22 @@ public class AndroidNewtEventFactory { } } - private static void collectPointerData(MotionEvent e, int eIdx, int dIdx, final int[] x, final int[] y, final float[] pressure, short[] pointerIds, final com.jogamp.newt.event.MouseEvent.PointerType[] pointerTypes) { - x[dIdx] = (int)e.getX(eIdx); - y[dIdx] = (int)e.getY(eIdx); - pressure[dIdx] = e.getPressure(eIdx); - pointerIds[dIdx] = (short)e.getPointerId(eIdx); - if( pressure[dIdx] > maxPressure ) { - maxPressure = pressure[dIdx]; + private static void collectPointerData(MotionEvent e, int idx, final int[] x, final int[] y, final float[] pressure, short[] pointerIds, final int[] pointerTypes) { + x[idx] = (int)e.getX(idx); + y[idx] = (int)e.getY(idx); + pressure[idx] = e.getPressure(idx); + pointerIds[idx] = (short)e.getPointerId(idx); + if( pressure[idx] > maxPressure ) { + maxPressure = pressure[idx]; } - pointerTypes[dIdx] = aToolType2PointerType( e.getToolType(eIdx) ); + pointerTypes[idx] = aToolType2PointerType( e.getToolType(idx) ).ordinal(); if(DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: ptr-data["+eIdx+" -> "+dIdx+"] "+x[dIdx]+"/"+y[dIdx]+", pressure "+pressure[dIdx]+", id "+pointerIds[dIdx]+", type "+pointerTypes[dIdx]); + System.err.println("createMouseEvent: ptr-data["+idx+"] "+x[idx]+"/"+y[idx]+", pressure "+pressure[idx]+", id "+pointerIds[idx]+", type "+pointerTypes[idx]); } } - public com.jogamp.newt.event.MouseEvent createMouseEvents(boolean isOnTouchEvent, - android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { + public boolean sendPointerEvent(boolean enqueue, boolean wait, boolean setFocusOnDown, boolean isOnTouchEvent, + android.view.MotionEvent event, jogamp.newt.driver.android.WindowDriver newtSource) { if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: isOnTouchEvent "+isOnTouchEvent+", "+event); } @@ -285,7 +285,6 @@ public class AndroidNewtEventFactory { final float[] rotationXYZ = new float[] { 0f, 0f, 0f }; if( (short)0 != nType ) { - final short clickCount = 1; int modifiers = 0; // @@ -298,7 +297,7 @@ public class AndroidNewtEventFactory { case android.view.MotionEvent.ACTION_POINTER_UP: { pIndex = event.getActionIndex(); final int b = event.getPointerId(pIndex) + 1; // FIXME: Assumption that Pointer-ID starts w/ 0 ! - if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { button = (short)b; } else { button = com.jogamp.newt.event.MouseEvent.BUTTON1; @@ -328,6 +327,15 @@ public class AndroidNewtEventFactory { } final int pCount = event.getPointerCount(); // all + switch( aType ) { + case android.view.MotionEvent.ACTION_DOWN: + case android.view.MotionEvent.ACTION_POINTER_DOWN: + modifiers |= InputEvent.getButtonMask(button); + if( setFocusOnDown ) { + newtSource.focusChanged(false, true); + } + } + // // Collect common data // @@ -335,38 +343,20 @@ public class AndroidNewtEventFactory { final int[] y = new int[pCount]; final float[] pressure = new float[pCount]; final short[] pointerIds = new short[pCount]; - final com.jogamp.newt.event.MouseEvent.PointerType[] pointerTypes = new com.jogamp.newt.event.MouseEvent.PointerType[pCount]; + final int[] pointerTypes = new int[pCount]; if( 0 < pCount ) { if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: collect ptr-data [0.."+(pCount-1)+", count "+pCount+", action "+pIndex+"], aType "+aType+", button "+button); } - int j = 0; - // Always put action-pointer data at index 0 - collectPointerData(event, pIndex, j++, x, y, pressure, pointerIds, pointerTypes); for(int i=0; i < pCount; i++) { - if( pIndex != i ) { - collectPointerData(event, i, j++, x, y, pressure, pointerIds, pointerTypes); - } + collectPointerData(event, i, x, y, pressure, pointerIds, pointerTypes); } } - - if(null!=newtSource) { - if(newtSource.isPointerConfined()) { - modifiers |= InputEvent.CONFINED_MASK; - } - if(!newtSource.isPointerVisible()) { - modifiers |= InputEvent.INVISIBLE_MASK; - } - } - - final Object src = (null==newtSource)?null:(Object)newtSource; - final long unixTime = System.currentTimeMillis() + ( event.getEventTime() - android.os.SystemClock.uptimeMillis() ); - - return new com.jogamp.newt.event.MouseEvent(nType, src, unixTime, - modifiers, pointerTypes, pointerIds, x, y, pressure, maxPressure, - button, clickCount, rotationXYZ, rotationScale); + newtSource.doPointerEvent(enqueue, wait, pointerTypes, nType, modifiers, + pIndex, pointerIds, x, y, pressure, maxPressure, rotationXYZ, rotationScale); + return true; } - return null; // no mapping .. + return false; // no mapping .. } } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java index df52208df..5a4743f73 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java @@ -13,16 +13,10 @@ public class AndroidNewtEventTranslator implements View.OnKeyListener, View.OnTo } private final boolean processTouchMotionEvents(View v, android.view.MotionEvent event, boolean isOnTouchEvent) { - final com.jogamp.newt.event.MouseEvent newtEvent = factory.createMouseEvents(isOnTouchEvent, event, newtWindow); - if(null != newtEvent) { - switch( event.getActionMasked() ) { - case android.view.MotionEvent.ACTION_DOWN: - case android.view.MotionEvent.ACTION_POINTER_DOWN: - newtWindow.focusChanged(false, true); - break; - } - newtWindow.enqueueEvent(false, newtEvent); - try { Thread.sleep((long) (100.0F/3.0F)); } // 33 ms + final boolean eventSent = factory.sendPointerEvent(true /*enqueue*/, false /*wait*/, true /*setFocusOnDown*/, + isOnTouchEvent, event, newtWindow); + if( eventSent ) { + try { Thread.sleep((long) (100.0F/3.0F)); } // 33 ms - FIXME ?? catch(InterruptedException e) { } return true; // consumed/handled, further interest in events } -- cgit v1.2.3 From c9837ef133ff3465d9b06f1907a7a320181ec97c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 07:57:02 +0200 Subject: PinchToZoomGesture: Validate pointer-IDs, skip if invalid. --- .../com/jogamp/newt/event/PinchToZoomGesture.java | 50 +++++++++++----------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java index 3a34c6253..eceea053d 100644 --- a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java +++ b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java @@ -177,31 +177,33 @@ public class PinchToZoomGesture implements GestureHandler { // same pointers final int p0Idx = pe.getPointerIdx(pIds[0]); final int p1Idx = pe.getPointerIdx(pIds[1]); - final int edge0 = useY ? pe.getY(p0Idx) : pe.getX(p0Idx); - final int edge1 = useY ? pe.getY(p1Idx) : pe.getX(p1Idx); - // Diff. 1:1 Zoom: finger-distance to screen-coord - if(zoomFirstTouch) { - zoomLastEdgeDist = Math.abs(edge0-edge1); - zoomFirstTouch=false; - zoomMode = true; - } else if( zoomMode ) { - final int d = Math.abs(edge0-edge1); - final int dd = d - zoomLastEdgeDist; - final float screenEdge = useY ? surface.getHeight() : surface.getWidth(); - final float incr = (float)dd / screenEdge; // [-1..1] - if(DEBUG) { - System.err.println("XXX2: id0 "+pIds[0]+" -> idx0 "+p0Idx+", id1 "+pIds[1]+" -> idx1 "+p1Idx); - System.err.println("XXX3: d "+d+", ld "+zoomLastEdgeDist+", dd "+dd+", screen "+screenEdge+" -> incr "+incr+", zoom "+zoom+" -> "+(zoom+incr)); - } - zoom += incr; - // clip value - if( 2f < zoom ) { - zoom = 2f; - } else if( 0 > zoom ) { - zoom = 0; + if( 0 <= p0Idx && 0 <= p1Idx ) { + final int edge0 = useY ? pe.getY(p0Idx) : pe.getX(p0Idx); + final int edge1 = useY ? pe.getY(p1Idx) : pe.getX(p1Idx); + // Diff. 1:1 Zoom: finger-distance to screen-coord + if(zoomFirstTouch) { + zoomLastEdgeDist = Math.abs(edge0-edge1); + zoomFirstTouch=false; + zoomMode = true; + } else if( zoomMode ) { + final int d = Math.abs(edge0-edge1); + final int dd = d - zoomLastEdgeDist; + final float screenEdge = useY ? surface.getHeight() : surface.getWidth(); + final float incr = (float)dd / screenEdge; // [-1..1] + if(DEBUG) { + System.err.println("XXX2: id0 "+pIds[0]+" -> idx0 "+p0Idx+", id1 "+pIds[1]+" -> idx1 "+p1Idx); + System.err.println("XXX3: d "+d+", ld "+zoomLastEdgeDist+", dd "+dd+", screen "+screenEdge+" -> incr "+incr+", zoom "+zoom+" -> "+(zoom+incr)); + } + zoom += incr; + // clip value + if( 2f < zoom ) { + zoom = 2f; + } else if( 0 > zoom ) { + zoom = 0; + } + zoomLastEdgeDist = d; + zoomEvent = new ZoomEvent(pe.getSource(), pe.getWhen(), pe.getModifiers(), this, pe, zoom); } - zoomLastEdgeDist = d; - zoomEvent = new ZoomEvent(pe.getSource(), pe.getWhen(), pe.getModifiers(), this, pe, zoom); } } if(DEBUG) { -- cgit v1.2.3 From 202834f148e0eb8c435af02850085d582b3006a4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 17:25:38 +0200 Subject: Refine Int -> Enum conversion (commit 40863632d1428de015099b5967e5136425e99f25), throw IllegalArgumentException if ordinal is out-of-range. Add API doc. - FFMPEGNatives - MouseEvent.PointerType --- .../jogamp/opengl/util/av/impl/FFMPEGNatives.java | 40 ++++++++++++++++------ .../classes/com/jogamp/newt/event/MouseEvent.java | 35 ++++++++++++++++--- 2 files changed, 59 insertions(+), 16 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java index 89c15b905..8e08c23fa 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java @@ -92,13 +92,22 @@ interface FFMPEGNatives { COUNT; ///< Number of sample formats. - public static SampleFormat valueOf(int i) { - // ordinal = enumValue.ordinal(), reverse: enumValue = EnumClass.values()[ordinal] + /** + * Returns the matching SampleFormat value corresponding to the given SampleFormat's integer ordinal. + *
    +         *   given:
    +         *     ordinal = enumValue.ordinal()
    +         *   reverse:
    +         *     enumValue = EnumClass.values()[ordinal]
    +         * 
    + * @throws IllegalArgumentException if the given ordinal is out of range, i.e. not within [ 0 .. SampleFormat.values().length-1 ] + */ + public static SampleFormat valueOf(int ordinal) throws IllegalArgumentException { final SampleFormat[] all = SampleFormat.values(); - if( 0 <= i && i < all.length ) { - return all[i]; + if( 0 <= ordinal && ordinal < all.length ) { + return all[ordinal]; } - return null; + throw new IllegalArgumentException("Ordinal "+ordinal+" out of range of SampleFormat.values()[0.."+(all.length-1)+"]"); } }; @@ -246,13 +255,22 @@ interface FFMPEGNatives { GBRP16LE, ///< planar GBR 4:4:4 48bpp, little endian COUNT ///< number of pixel formats in this list ; - public static PixelFormat valueOf(int i) { - // ordinal = enumValue.ordinal(), reverse: enumValue = EnumClass.values()[ordinal] + /** + * Returns the matching PixelFormat value corresponding to the given PixelFormat's integer ordinal. + *
    +         *   given:
    +         *     ordinal = enumValue.ordinal()
    +         *   reverse:
    +         *     enumValue = EnumClass.values()[ordinal]
    +         * 
    + * @throws IllegalArgumentException if the given ordinal is out of range, i.e. not within [ 0 .. PixelFormat.values().length-1 ] + */ + public static PixelFormat valueOf(int ordinal) throws IllegalArgumentException { final PixelFormat[] all = PixelFormat.values(); - if( 0 <= i && i < all.length ) { - return all[i]; + if( 0 <= ordinal && ordinal < all.length ) { + return all[ordinal]; } - return null; + throw new IllegalArgumentException("Ordinal "+ordinal+" out of range of PixelFormat.values()[0.."+(all.length-1)+"]"); } } -} +} \ No newline at end of file diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index cb9e7a290..85c65b39c 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -79,13 +79,38 @@ public class MouseEvent extends InputEvent public PointerClass getPointerClass() { return pc; } - public static PointerType valueOf(int i) { - // ordinal = enumValue.ordinal(), reverse: enumValue = EnumClass.values()[ordinal] + /** + * Returns the matching PointerType value corresponding to the given PointerType's integer ordinal. + *
    +         *   given:
    +         *     ordinal = enumValue.ordinal()
    +         *   reverse:
    +         *     enumValue = EnumClass.values()[ordinal]
    +         * 
    + * @throws IllegalArgumentException if the given ordinal is out of range, i.e. not within [ 0 .. PointerType.values().length-1 ] + */ + public static PointerType valueOf(int ordinal) throws IllegalArgumentException { final PointerType[] all = PointerType.values(); - if( 0 <= i && i < all.length ) { - return all[i]; + if( 0 <= ordinal && ordinal < all.length ) { + return all[ordinal]; } - return null; + throw new IllegalArgumentException("Ordinal "+ordinal+" out of range of PointerType.values()[0.."+(all.length-1)+"]"); + } + + /** + * Returns the PointerType array of matching PointerType values corresponding to the given PointerType's integer ordinal values. + *

    + * See {@link #valueOf(int)}. + *

    + * @throws IllegalArgumentException if one of the given ordinal values is out of range, i.e. not within [ 0 .. PointerType.values().length-1 ] + */ + public static PointerType[] valuesOf(int[] ordinals) throws IllegalArgumentException { + final int count = ordinals.length; + final PointerType[] types = new PointerType[count]; + for(int i=count-1; i>=0; i--) { + types[i] = PointerType.valueOf(ordinals[i]); + } + return types; } private PointerType(PointerClass pc) { -- cgit v1.2.3 From 8815245ebb9efc6d49052ff1fb34a3ee6ecfcc6b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 17:57:31 +0200 Subject: NEWT Multiple-Pointer API: Use PointerType[] instead of ordinal int[], implementer can use PointerType.valuesOf(int[] ordinals) to convert. Enhanced API doc. Methods 'final' --- src/newt/classes/jogamp/newt/WindowImpl.java | 144 +++++++++++++++------ .../android/event/AndroidNewtEventFactory.java | 10 +- 2 files changed, 108 insertions(+), 46 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index b0df2d894..656bca6bc 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -39,6 +39,7 @@ import java.util.List; import java.lang.ref.WeakReference; import java.lang.reflect.Method; +import com.jogamp.common.util.ArrayHashSet; import com.jogamp.common.util.IntBitfield; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.newt.MonitorDevice; @@ -135,7 +136,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** Timeout of queued events (repaint and resize) */ static final long QUEUED_EVENT_TO = 1200; // ms - private static final int[] constMousePointerTypes = new int[] { PointerType.Mouse.ordinal() }; + private static final PointerType[] constMousePointerTypes = new PointerType[] { PointerType.Mouse }; // // Volatile: Multithread Mutable Access @@ -197,7 +198,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private PointerState0 pState0 = new PointerState0(); - /** from direct input: {@link WindowImpl#doPointerEvent(boolean, boolean, int[], short, int, int, short[], int[], int[], float[], float, float[], float)}. */ + /** from direct input: {@link WindowImpl#doPointerEvent(boolean, boolean, int[], short, int, int, boolean, short[], int[], int[], float[], float, float[], float)}. */ private static class PointerState1 extends PointerState0 { /** current pressed mouse button number */ short buttonPressed = (short)0; @@ -227,6 +228,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private PointerState1 pState1 = new PointerState1(); + /** pointer names -> pointer ID (consecutive index, starting w/ 0) */ + private final ArrayHashSet pName2pID = new ArrayHashSet(); + private boolean defaultGestureHandlerEnabled = true; private DoubleTapScrollGesture gesture2PtrTouchScroll = null; private ArrayList pointerGestureHandler = new ArrayList(); @@ -2374,16 +2378,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. */ protected void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, - int x, int y, short button, float[] rotationXYZ, float rotationScale) { + int x, int y, short button, final float[] rotationXYZ, float rotationScale) { if( 0 > button || button > MouseEvent.BUTTON_COUNT ) { throw new NativeWindowException("Invalid mouse button number" + button); } else if( 0 == button ) { button = 1; } doPointerEvent(enqueue, wait, constMousePointerTypes, eventType, modifiers, - 0 /*actionIdx*/, new short[] { (short)(button-1) }, - new int[]{x}, new int[]{y}, new float[]{0f} /*pressure*/, 1f /*maxPressure*/, - rotationXYZ, rotationScale); + 0 /*actionIdx*/, new short[] { (short)(button-1) }, + new int[]{x}, new int[]{y}, new float[]{0f} /*pressure*/, + 1f /*maxPressure*/, rotationXYZ, rotationScale); } /** @@ -2391,62 +2395,118 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer *

    * The index for the element of multiple-pointer arrays represents the pointer which triggered the event * is passed via actionIdx. - *

    + *

    + *

    + * The given pointer names, pNames, are mapped to consecutive pointer IDs starting w/ 0 + * using a hash-map if normalPNames is false. + * Otherwise a simple int to short type cast is performed. + *

    * * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. - * @param pTypesOrdinal {@link MouseEvent.PointerType#ordinal()} for each pointer (multiple pointer) + * @param pTypes {@link MouseEvent.PointerType} for each pointer (multiple pointer) * @param eventType * @param modifiers * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event - * @param pID Pointer ID for each pointer (multiple pointer), we assume pointerID's starts w/ 0 + * @param normalPNames see pName below. + * @param pNames Pointer name for each pointer (multiple pointer). + * We assume consecutive pointer names starting w/ 0 if normalPIDs is true. + * Otherwise we hash-map the values during state pressed to retrieve the normal ID. * @param pX X-axis for each pointer (multiple pointer) * @param pY Y-axis for each pointer (multiple pointer) * @param pPressure Pressure for each pointer (multiple pointer) * @param maxPressure Maximum pointer pressure for all pointer */ - public void doPointerEvent(boolean enqueue, boolean wait, - int[] pTypesOrdinal, short eventType, int modifiers, - int actionIdx, short[] pID, - int[] pX, int[] pY, float[] pPressure, float maxPressure, - float[] rotationXYZ, float rotationScale) { + public final void doPointerEvent(boolean enqueue, boolean wait, + final PointerType[] pTypes, short eventType, int modifiers, + int actionIdx, boolean normalPNames, final int[] pNames, + final int[] pX, final int[] pY, float[] pPressure, + float maxPressure, final float[] rotationXYZ, final float rotationScale) { + final int pCount = pNames.length; + final short[] pIDs = new short[pCount]; + for(int i=0; i short idx + final Integer pNameI0 = new Integer(pNames[i]); + final Integer pNameI1 = pName2pID.getOrAdd(pNameI0); + final short pID = (short)pName2pID.indexOf(pNameI1); + pIDs[i] = pID; + if(DEBUG_MOUSE_EVENT) { + final boolean reuse = pNameI0 == pNameI1; + System.err.println("PointerName2ID[sz "+pName2pID.size()+"]: "+(reuse?"Reused":"Added")+" "+pNameI0+" : "+pID); + } + if( MouseEvent.EVENT_MOUSE_RELEASED == eventType ) { + pName2pID.remove(pNameI1); + if(DEBUG_MOUSE_EVENT) { + System.err.println("PointerName2ID[sz "+pName2pID.size()+"]: Removed "+pNameI1+" : "+pID); + } + } + } else { + // simple type cast + pIDs[i] = (short)pNames[i]; + } + } + doPointerEvent(enqueue, wait, pTypes, eventType, modifiers, actionIdx, pIDs, + pX, pY, pPressure, maxPressure, rotationXYZ, rotationScale); + } + + /** + * Send multiple-pointer event either to be directly consumed or to be enqueued + *

    + * The index for the element of multiple-pointer arrays represents the pointer which triggered the event + * is passed via actionIdx. + *

    + * + * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, + * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. + * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. + * @param pTypes {@link MouseEvent.PointerType} for each pointer (multiple pointer) + * @param eventType + * @param modifiers + * @param pActionIdx index of multiple-pointer arrays representing the pointer which triggered the event + * @param pID Pointer ID for each pointer (multiple pointer). We assume consecutive pointerIDs starting w/ 0. + * @param pX X-axis for each pointer (multiple pointer) + * @param pY Y-axis for each pointer (multiple pointer) + * @param pPressure Pressure for each pointer (multiple pointer) + * @param maxPressure Maximum pointer pressure for all pointer + */ + public final void doPointerEvent(boolean enqueue, boolean wait, + final PointerType[] pTypes, short eventType, int modifiers, + int pActionIdx, final short[] pID, final int[] pX, final int[] pY, final float[] pPressure, + float maxPressure, final float[] rotationXYZ, float rotationScale) { final long when = System.currentTimeMillis(); - final int pointerCount = pTypesOrdinal.length; + final int pCount = pTypes.length; - if( 0 > actionIdx || actionIdx >= pointerCount) { - throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pointerCount-1)+"]"); + if( 0 > pActionIdx || pActionIdx >= pCount) { + throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pCount-1)+"]"); } - if( 0 < actionIdx ) { + if( 0 < pActionIdx ) { // swap values to make idx 0 the triggering pointer { - final int aType = pTypesOrdinal[actionIdx]; - pTypesOrdinal[actionIdx] = pTypesOrdinal[0]; - pTypesOrdinal[0] = aType; + final PointerType aType = pTypes[pActionIdx]; + pTypes[pActionIdx] = pTypes[0]; + pTypes[0] = aType; } { - final short s = pID[actionIdx]; - pID[actionIdx] = pID[0]; + final short s = pID[pActionIdx]; + pID[pActionIdx] = pID[0]; pID[0] = s; } { - int s = pX[actionIdx]; - pX[actionIdx] = pX[0]; + int s = pX[pActionIdx]; + pX[pActionIdx] = pX[0]; pX[0] = s; - s = pY[actionIdx]; - pY[actionIdx] = pY[0]; + s = pY[pActionIdx]; + pY[pActionIdx] = pY[0]; pY[0] = s; } { - final float aPress = pPressure[actionIdx]; - pPressure[actionIdx] = pPressure[0]; + final float aPress = pPressure[pActionIdx]; + pPressure[pActionIdx] = pPressure[0]; pPressure[0] = aPress; } } - final PointerType[] pointerType = new PointerType[pointerCount]; - for(int i=pointerCount-1; i>=0; i--) { - pointerType[i] = PointerType.valueOf(pTypesOrdinal[i]); - } final short id = pID[0]; final short button; { @@ -2548,7 +2608,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer pPressure[0] = maxPressure; } pState1.buttonPressedMask |= InputEvent.getButtonMask(button); - if( 1 == pointerCount ) { + if( 1 == pCount ) { if( when - pState1.lastButtonPressTime < MouseEvent.getClickTimeout() ) { pState1.lastButtonClickCount++; } else { @@ -2556,16 +2616,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } pState1.lastButtonPressTime = when; pState1.buttonPressed = button; - e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, pState1.lastButtonClickCount, rotationXYZ, rotationScale); } else { - e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); } break; case MouseEvent.EVENT_MOUSE_RELEASED: - if( 1 == pointerCount ) { - e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + if( 1 == pCount ) { + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, pState1.lastButtonClickCount, rotationXYZ, rotationScale); if( when - pState1.lastButtonPressTime >= MouseEvent.getClickTimeout() ) { pState1.lastButtonClickCount = (short)0; @@ -2573,7 +2633,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } pState1.buttonPressed = 0; } else { - e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); } pState1.buttonPressedMask &= ~InputEvent.getButtonMask(button); @@ -2583,10 +2643,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer break; case MouseEvent.EVENT_MOUSE_MOVED: if ( 0 != pState1.buttonPressedMask ) { // any button or pointer move -> drag - e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, modifiers, pointerType, pID, + e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, pState1.buttonPressed, (short)1, rotationXYZ, rotationScale); } else { - e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)0, rotationXYZ, rotationScale); } break; @@ -2596,7 +2656,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } // Fall through intended! default: - e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)0, rotationXYZ, rotationScale); } doEvent(enqueue, wait, e); // actual mouse event diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 23c32993f..e5d667f3e 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -33,6 +33,7 @@ import android.view.MotionEvent; import com.jogamp.common.os.AndroidVersion; import com.jogamp.newt.event.InputEvent; +import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.NEWTEvent; public class AndroidNewtEventFactory { @@ -252,7 +253,8 @@ public class AndroidNewtEventFactory { } } - private static void collectPointerData(MotionEvent e, int idx, final int[] x, final int[] y, final float[] pressure, short[] pointerIds, final int[] pointerTypes) { + private static void collectPointerData(MotionEvent e, int idx, final int[] x, final int[] y, final float[] pressure, + final short[] pointerIds, final MouseEvent.PointerType[] pointerTypes) { x[idx] = (int)e.getX(idx); y[idx] = (int)e.getY(idx); pressure[idx] = e.getPressure(idx); @@ -260,14 +262,14 @@ public class AndroidNewtEventFactory { if( pressure[idx] > maxPressure ) { maxPressure = pressure[idx]; } - pointerTypes[idx] = aToolType2PointerType( e.getToolType(idx) ).ordinal(); + pointerTypes[idx] = aToolType2PointerType( e.getToolType(idx) ); if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: ptr-data["+idx+"] "+x[idx]+"/"+y[idx]+", pressure "+pressure[idx]+", id "+pointerIds[idx]+", type "+pointerTypes[idx]); } } public boolean sendPointerEvent(boolean enqueue, boolean wait, boolean setFocusOnDown, boolean isOnTouchEvent, - android.view.MotionEvent event, jogamp.newt.driver.android.WindowDriver newtSource) { + android.view.MotionEvent event, jogamp.newt.driver.android.WindowDriver newtSource) { if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: isOnTouchEvent "+isOnTouchEvent+", "+event); } @@ -343,7 +345,7 @@ public class AndroidNewtEventFactory { final int[] y = new int[pCount]; final float[] pressure = new float[pCount]; final short[] pointerIds = new short[pCount]; - final int[] pointerTypes = new int[pCount]; + final MouseEvent.PointerType[] pointerTypes = new MouseEvent.PointerType[pCount]; if( 0 < pCount ) { if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: collect ptr-data [0.."+(pCount-1)+", count "+pCount+", action "+pIndex+"], aType "+aType+", button "+button); -- cgit v1.2.3 From d9fba0ea89ae71ce29fb528593fee24707b896ad Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 18:02:07 +0200 Subject: Regression of commit a90bf31f8747dd38c61d518f8af4d4d4a64a8e90: 'consumeEvent(Event ..)' must be protected and non-final Overriding by impl. class allowed. --- src/newt/classes/jogamp/newt/WindowImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 656bca6bc..dcb811b97 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2784,7 +2784,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * - dispatch event to listener * */ - private final void consumePointerEvent(MouseEvent pe) { + protected void consumePointerEvent(MouseEvent pe) { int x = pe.getX(); int y = pe.getY(); @@ -3124,7 +3124,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return e.isConsumed(); } - private final void consumeKeyEvent(KeyEvent e) { + protected void consumeKeyEvent(KeyEvent e) { boolean consumedE = false; if( null != keyboardFocusHandler && !e.isAutoRepeat() ) { consumedE = propagateKeyEvent(e, keyboardFocusHandler); @@ -3203,7 +3203,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return windowListeners.toArray(new WindowListener[windowListeners.size()]); } - private final void consumeWindowEvent(WindowEvent e) { + protected void consumeWindowEvent(WindowEvent e) { if(DEBUG_IMPLEMENTATION) { System.err.println("consumeWindowEvent: "+e+", visible "+isVisible()+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } -- cgit v1.2.3 From 0eceb7df4b04a183a738474c0d7f4be41b6bcc0c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 19:37:31 +0200 Subject: WindowImpl.doPointerEvent(..) Simplify pointer name->ID mapping, fix DEBUG. --- src/newt/classes/jogamp/newt/WindowImpl.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index dcb811b97..624ac4df4 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2428,18 +2428,20 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer for(int i=0; i short idx - final Integer pNameI0 = new Integer(pNames[i]); - final Integer pNameI1 = pName2pID.getOrAdd(pNameI0); + final int sz0 = pName2pID.size(); + final Integer pNameI1 = pName2pID.getOrAdd(Integer.valueOf(pNames[i])); final short pID = (short)pName2pID.indexOf(pNameI1); pIDs[i] = pID; if(DEBUG_MOUSE_EVENT) { - final boolean reuse = pNameI0 == pNameI1; - System.err.println("PointerName2ID[sz "+pName2pID.size()+"]: "+(reuse?"Reused":"Added")+" "+pNameI0+" : "+pID); + final int sz1 = pName2pID.size(); + if( sz0 != sz1 ) { + System.err.println("PointerName2ID[sz "+sz1+"]: Map "+pNameI1+" == "+pID); + } } if( MouseEvent.EVENT_MOUSE_RELEASED == eventType ) { pName2pID.remove(pNameI1); if(DEBUG_MOUSE_EVENT) { - System.err.println("PointerName2ID[sz "+pName2pID.size()+"]: Removed "+pNameI1+" : "+pID); + System.err.println("PointerName2ID[sz "+pName2pID.size()+"]: Unmap "+pNameI1+" == "+pID); } } } else { -- cgit v1.2.3 From 5b96486da0bcd09d5355f89ec551140e508b567c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 20:03:04 +0200 Subject: Bug 800: Add Windows 7 Touch Event Support for NEWT Native: - WindowUserData tracks: - window size - mouse inside - pointer touch-down count and flags whether multiple-touch is supported. - Suppress WM_*BUTTON* events if within TOUCH operations, e.g. fingers are pressed, or if event is determined as TOUCH (0 != GetMessageExtraInfo()) - MOUSEMOVE issues NewtWindows_trackPointerLeave(..) directly if no TOUCH operation is in process. Removes need for MouseListener on Java side. - TOUCH events are send as follows: - PRIMARY first - 1 MOVE 2nd (if not sent already) - UP/DOWN (if not sent already) We only send max. one MOVE event, since Win7 / Win8 assignes MOVE per default, even if no actual move happened. Hence a single MOVE event shall suffice and is compatible w/ e.g. Android (AFAIK). - TOUCH pointer names are mapped to consecutive IDs on the java side. --- .../jogamp/newt/driver/windows/WindowDriver.java | 45 ++- src/newt/native/WindowsWindow.c | 435 ++++++++++++++++----- 2 files changed, 368 insertions(+), 112 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 393445db0..b2e175415 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,10 +46,12 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.VersionNumber; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; -import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.MouseEvent.PointerType; public class WindowDriver extends WindowImpl { @@ -134,16 +136,17 @@ public class WindowDriver extends WindowImpl { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } setGraphicsConfiguration(cfg); + final VersionNumber winVer = Platform.getOSVersionNumber(); final int flags = getReconfigureFlags(0, true) & ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; final long _windowHandle = CreateWindow0(DisplayDriver.getHInstance(), display.getWindowClassName(), display.getWindowClassName(), + winVer.getMajor(), winVer.getMinor(), getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags); if ( 0 == _windowHandle ) { throw new NativeWindowException("Error creating window"); } setWindowHandle(_windowHandle); windowHandleClose = _windowHandle; - addMouseListener(mouseTracker); if(DEBUG_IMPLEMENTATION) { Exception e = new Exception("Info: Window new window handle "+Thread.currentThread().getName()+ @@ -152,11 +155,6 @@ public class WindowDriver extends WindowImpl { e.printStackTrace(); } } - private MouseAdapter mouseTracker = new MouseAdapter() { - public void mouseEntered(MouseEvent e) { - WindowDriver.trackPointerLeave0(WindowDriver.this.getWindowHandle()); - } - }; protected void closeNativeImpl() { if(windowHandleClose != 0) { @@ -266,6 +264,33 @@ public class WindowDriver extends WindowImpl { // nop - using event driven insetsChange(..) } + // + // PointerEvent Handling + // + /** + * Send multiple-pointer {@link MouseEvent.PointerType#TouchScreen} event to be directly consumed + *

    + * Assumes non normal pointer names and rotation/scroll will be determined by a gesture handler. + *

    + *

    + * See {@link #doPointerEvent(boolean, boolean, PointerType[], short, int, int, boolean, int[], int[], int[], float[], float, float[], float)} + * for details. + *

    + */ + public final void sendTouchScreenEvent(short eventType, int modifiers, + int pActionIdx, int[] pNames, + int[] pX, int[] pY, float[] pPressure, float maxPressure) { + final int pCount = pNames.length; + final MouseEvent.PointerType[] pTypes = new MouseEvent.PointerType[pCount]; + for(int i=pCount-1; i>=0; i--) { pTypes[i] = PointerType.TouchScreen; } + doPointerEvent(false /*enqueue*/, false /*wait*/, + pTypes, eventType, modifiers, pActionIdx, false /*normalPNames*/, pNames, + pX, pY, pPressure, maxPressure, new float[] { 0f, 0f, 0f} /*rotationXYZ*/, 1f/*rotationScale*/); + } + + // + // KeyEvent Handling + // private short repeatedKey = KeyEvent.VK_UNDEFINED; private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, int modifiers, short keyCode, short keySym, char keyChar) { @@ -326,9 +351,8 @@ public class WindowDriver extends WindowImpl { protected static native long getNewtWndProc0(); protected static native boolean initIDs0(long hInstance); - private native long CreateWindow0(long hInstance, String wndClassName, String wndName, - long parentWindowHandle, - int x, int y, int width, int height, boolean autoPosition, int flags); + private native long CreateWindow0(long hInstance, String wndClassName, String wndName, int winMajor, int winMinor, + long parentWindowHandle, int x, int y, int width, int height, boolean autoPosition, int flags); private native long MonitorFromWindow0(long windowHandle); private native void reconfigureWindow0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height, int flags); @@ -338,5 +362,4 @@ public class WindowDriver extends WindowImpl { private static native boolean setPointerVisible0(long windowHandle, boolean visible); private static native boolean confinePointer0(long windowHandle, boolean grab, int l, int t, int r, int b); private static native void warpPointer0(long windowHandle, int x, int y); - private static native void trackPointerLeave0(long windowHandle); } diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 4ef2459e8..ec7f5dbab 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -32,6 +32,16 @@ * */ +// +// Min. required version Windows 7 (For WM_TOUCH) +// +#if WINVER < 0x0601 +#error WINVER must be >= 0x0601 +#endif +#if _WIN32_WINNT < 0x0601 +#error _WIN32_WINNT must be >= 0x0601 +#endif + #include #include #include @@ -86,6 +96,13 @@ #define WH_MOUSE_LL 14 #endif +#ifndef WM_TOUCH +#define WM_TOUCH 0x0240 +#endif +#ifndef TOUCH_COORD_TO_PIXEL +#define TOUCH_COORD_TO_PIXEL(l) (l/100) +#endif + #ifndef MONITOR_DEFAULTTONULL #define MONITOR_DEFAULTTONULL 0 #endif @@ -136,6 +153,7 @@ static jmethodID visibleChangedID = NULL; static jmethodID windowDestroyNotifyID = NULL; static jmethodID windowRepaintID = NULL; static jmethodID sendMouseEventID = NULL; +static jmethodID sendTouchScreenEventID = NULL; static jmethodID sendKeyEventID = NULL; static jmethodID requestFocusID = NULL; @@ -144,8 +162,15 @@ static RECT* UpdateInsets(JNIEnv *env, jobject window, HWND hwnd); typedef struct { JNIEnv* jenv; jobject jinstance; + /* client size width */ + int width; + /* client size height */ + int height; /** Tristate: -1 HIDE, 0 NOP, 1 SHOW */ int setPointerVisible; + int mouseInside; + int touchDownCount; + int supportsMTouch; } WindowUserData; typedef struct { @@ -544,14 +569,22 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, HWND hwnd, jb DBG_PRINT("*** WindowsWindow: requestFocus.XX\n"); } -static BOOL NewtWindows_trackPointerLeave(HWND hwnd) { +static void NewtWindows_trackPointerLeave(HWND hwnd) { TRACKMOUSEEVENT tme; memset(&tme, 0, sizeof(TRACKMOUSEEVENT)); tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_LEAVE; tme.hwndTrack = hwnd; tme.dwHoverTime = 0; // we don't use TME_HOVER - return TrackMouseEvent(&tme); + BOOL ok = TrackMouseEvent(&tme); + DBG_PRINT( "*** WindowsWindow: trackPointerLeave: %d\n", ok); + #ifdef VERBOSE_ON + if(!ok) { + int lastError = (int) GetLastError(); + DBG_PRINT( "*** WindowsWindow: trackPointerLeave: lastError 0x%X %d\n", lastError, lastError); + } + #endif + (void)ok; } #if 0 @@ -676,11 +709,11 @@ static RECT* UpdateInsets(JNIEnv *env, jobject window, HWND hwnd) #endif -static void WmSize(JNIEnv *env, jobject window, HWND wnd, UINT type) +static void WmSize(JNIEnv *env, WindowUserData * wud, HWND wnd, UINT type) { RECT rc; - int w, h; BOOL isVisible = IsWindowVisible(wnd); + jobject window = wud->jinstance; if (type == SIZE_MINIMIZED) { // TODO: deal with minimized window sizing @@ -693,12 +726,12 @@ static void WmSize(JNIEnv *env, jobject window, HWND wnd, UINT type) GetClientRect(wnd, &rc); // we report back the dimensions of the client area - w = (int) ( rc.right - rc.left ); - h = (int) ( rc.bottom - rc.top ); + wud->width = (int) ( rc.right - rc.left ); + wud->height = (int) ( rc.bottom - rc.top ); - DBG_PRINT("*** WindowsWindow: WmSize window %p, %dx%d, visible %d\n", (void*)wnd, w, h, isVisible); + DBG_PRINT("*** WindowsWindow: WmSize window %p, %dx%d, visible %d\n", (void*)wnd, wud->width, wud->height, isVisible); - (*env)->CallVoidMethod(env, window, sizeChangedID, JNI_FALSE, w, h, JNI_FALSE); + (*env)->CallVoidMethod(env, window, sizeChangedID, JNI_FALSE, wud->width, wud->height, JNI_FALSE); } #ifdef TEST_MOUSE_HOOKS @@ -792,6 +825,39 @@ static BOOL SafeShowCursor(BOOL show) { return b; } +static void sendTouchScreenEvent(JNIEnv *env, jobject window, + short eventType, int modifiers, int actionIdx, + int count, jint* pointerNames, jint* x, jint* y, jfloat* pressure, float maxPressure) { + jintArray jNames = (*env)->NewIntArray(env, count); + if (jNames == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array (names) of size %d", count); + } + (*env)->SetIntArrayRegion(env, jNames, 0, count, pointerNames); + + jintArray jX = (*env)->NewIntArray(env, count); + if (jX == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array (x) of size %d", count); + } + (*env)->SetIntArrayRegion(env, jX, 0, count, x); + + jintArray jY = (*env)->NewIntArray(env, count); + if (jY == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array (y) of size %d", count); + } + (*env)->SetIntArrayRegion(env, jY, 0, count, y); + + jfloatArray jPressure = (*env)->NewFloatArray(env, count); + if (jPressure == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate float array (pressure) of size %d", count); + } + (*env)->SetFloatArrayRegion(env, jPressure, 0, count, pressure); + + (*env)->CallVoidMethod(env, window, sendTouchScreenEventID, + (jshort)eventType, (jint)modifiers, (jint)actionIdx, + jNames, jX, jY, jPressure, (jfloat)maxPressure); +} + + static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT res = 0; int useDefWindowProc = 0; @@ -885,7 +951,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_SIZE: - WmSize(env, window, wnd, (UINT)wParam); + WmSize(env, wud, wnd, (UINT)wParam); break; case WM_SETTINGCHANGE: @@ -899,83 +965,139 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; - case WM_LBUTTONDOWN: - DBG_PRINT("*** WindowsWindow: LBUTTONDOWN\n"); - (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); - (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jshort) EVENT_MOUSE_PRESSED, - GetModifiers( 0 ), - (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jshort) 1, (jfloat) 0.0f); - useDefWindowProc = 1; + case WM_LBUTTONDOWN: { + BOOL isMouse = 0 == GetMessageExtraInfo(); + DBG_PRINT("*** WindowsWindow: WM_LBUTTONDOWN %d/%d [%dx%d] inside %d, isMouse %d, tDown %d\n", + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + wud->width, wud->height, wud->mouseInside, isMouse, wud->touchDownCount); + if( isMouse ) { + wud->mouseInside = 1; + (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); + (*env)->CallVoidMethod(env, window, sendMouseEventID, + (jshort) EVENT_MOUSE_PRESSED, + GetModifiers( 0 ), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + (jshort) 1, (jfloat) 0.0f); + useDefWindowProc = 1; + } + } break; - case WM_LBUTTONUP: - (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jshort) EVENT_MOUSE_RELEASED, - GetModifiers( 0 ), - (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jshort) 1, (jfloat) 0.0f); - useDefWindowProc = 1; + case WM_LBUTTONUP: { + BOOL isMouse = 0 == GetMessageExtraInfo(); + DBG_PRINT("*** WindowsWindow: WM_LBUTTONUP %d/%d [%dx%d] inside %d, isMouse %d, tDown %d\n", + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + wud->width, wud->height, wud->mouseInside, isMouse, wud->touchDownCount); + if( isMouse ) { + wud->mouseInside = 1; + (*env)->CallVoidMethod(env, window, sendMouseEventID, + (jshort) EVENT_MOUSE_RELEASED, + GetModifiers( 0 ), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + (jshort) 1, (jfloat) 0.0f); + useDefWindowProc = 1; + } + } break; - case WM_MBUTTONDOWN: - DBG_PRINT("*** WindowsWindow: MBUTTONDOWN\n"); - (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); - (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jshort) EVENT_MOUSE_PRESSED, - GetModifiers( 0 ), - (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jshort) 2, (jfloat) 0.0f); - useDefWindowProc = 1; + case WM_MBUTTONDOWN: { + BOOL isMouse = 0 == GetMessageExtraInfo(); + DBG_PRINT("*** WindowsWindow: WM_MBUTTONDOWN %d/%d [%dx%d] inside %d, isMouse %d, tDown %d\n", + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + wud->width, wud->height, wud->mouseInside, isMouse, wud->touchDownCount); + if( isMouse ) { + wud->mouseInside = 1; + (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); + (*env)->CallVoidMethod(env, window, sendMouseEventID, + (jshort) EVENT_MOUSE_PRESSED, + GetModifiers( 0 ), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + (jshort) 2, (jfloat) 0.0f); + useDefWindowProc = 1; + } + } break; - case WM_MBUTTONUP: - (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jshort) EVENT_MOUSE_RELEASED, - GetModifiers( 0 ), - (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jshort) 2, (jfloat) 0.0f); - useDefWindowProc = 1; + case WM_MBUTTONUP: { + BOOL isMouse = 0 == GetMessageExtraInfo(); + DBG_PRINT("*** WindowsWindow: WM_MBUTTONUP %d/%d [%dx%d] inside %d, isMouse %d, tDown %d\n", + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + wud->width, wud->height, wud->mouseInside, isMouse, wud->touchDownCount); + if( isMouse ) { + wud->mouseInside = 1; + (*env)->CallVoidMethod(env, window, sendMouseEventID, + (jshort) EVENT_MOUSE_RELEASED, + GetModifiers( 0 ), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + (jshort) 2, (jfloat) 0.0f); + useDefWindowProc = 1; + } + } break; - case WM_RBUTTONDOWN: - DBG_PRINT("*** WindowsWindow: RBUTTONDOWN\n"); - (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); - (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jshort) EVENT_MOUSE_PRESSED, - GetModifiers( 0 ), - (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jshort) 3, (jfloat) 0.0f); - useDefWindowProc = 1; + case WM_RBUTTONDOWN: { + BOOL isMouse = 0 == GetMessageExtraInfo(); + DBG_PRINT("*** WindowsWindow: WM_RBUTTONDOWN: %d/%d [%dx%d] inside %d, isMouse %d, tDown %d\n", + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + wud->width, wud->height, wud->mouseInside, isMouse, wud->touchDownCount); + if( isMouse ) { + wud->mouseInside = 1; + (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); + (*env)->CallVoidMethod(env, window, sendMouseEventID, + (jshort) EVENT_MOUSE_PRESSED, + GetModifiers( 0 ), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + (jshort) 3, (jfloat) 0.0f); + useDefWindowProc = 1; + } + } break; - case WM_RBUTTONUP: - (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jshort) EVENT_MOUSE_RELEASED, - GetModifiers( 0 ), - (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jshort) 3, (jfloat) 0.0f); - useDefWindowProc = 1; + case WM_RBUTTONUP: { + BOOL isMouse = 0 == GetMessageExtraInfo(); + DBG_PRINT("*** WindowsWindow: WM_RBUTTONUP %d/%d [%dx%d] inside %d, isMouse %d, tDown %d\n", + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + wud->width, wud->height, wud->mouseInside, isMouse, wud->touchDownCount); + if( isMouse ) { + wud->mouseInside = 1; + (*env)->CallVoidMethod(env, window, sendMouseEventID, + (jshort) EVENT_MOUSE_RELEASED, + GetModifiers( 0 ), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + (jshort) 3, (jfloat) 0.0f); + useDefWindowProc = 1; + } + } break; - case WM_MOUSEMOVE: - // DBG_PRINT("*** WindowsWindow: WM_MOUSEMOVE %d/%d\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam)); - (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jshort) EVENT_MOUSE_MOVED, - GetModifiers( 0 ), - (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jshort) 0, (jfloat) 0.0f); - useDefWindowProc = 1; + case WM_MOUSEMOVE: { + wud->mouseInside = 1; + DBG_PRINT("*** WindowsWindow: WM_MOUSEMOVE %d/%d [%dx%d] inside %d, tDown %d\n", + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + wud->width, wud->height, wud->mouseInside, wud->touchDownCount); + if( wud->touchDownCount == 0 ) { + NewtWindows_trackPointerLeave(wnd); + (*env)->CallVoidMethod(env, window, sendMouseEventID, + (jshort) EVENT_MOUSE_MOVED, + GetModifiers( 0 ), + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + (jshort) 0, (jfloat) 0.0f); + } + useDefWindowProc = 1; + } break; - case WM_MOUSELEAVE: - DBG_PRINT("*** WindowsWindow: WM_MOUSELEAVE\n"); - (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jshort) EVENT_MOUSE_EXITED, - 0, - (jint) -1, (jint) -1, // fake - (jshort) 0, (jfloat) 0.0f); - useDefWindowProc = 1; + case WM_MOUSELEAVE: { + wud->mouseInside = 0; + DBG_PRINT("*** WindowsWindow: WM_MOUSELEAVE %d/%d [%dx%d] inside %d, tDown %d\n", + (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), + wud->width, wud->height, wud->mouseInside, wud->touchDownCount); + (*env)->CallVoidMethod(env, window, sendMouseEventID, + (jshort) EVENT_MOUSE_EXITED, + 0, + (jint) -1, (jint) -1, // fake + (jshort) 0, (jfloat) 0.0f); + useDefWindowProc = 1; + } break; // Java synthesizes EVENT_MOUSE_ENTERED @@ -1036,6 +1158,116 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; } + case WM_TOUCH: if( wud->supportsMTouch ) { + UINT cInputs = LOWORD(wParam); + // DBG_PRINT("*** WindowsWindow: WM_TOUCH window %p, cInputs %d\n", wnd, cInputs); + HTOUCHINPUT hTouch = (HTOUCHINPUT)lParam; + PTOUCHINPUT pInputs = (PTOUCHINPUT) calloc(cInputs, sizeof(TOUCHINPUT)); + if (NULL != pInputs) { + if (GetTouchInputInfo(hTouch, cInputs, pInputs, sizeof(TOUCHINPUT))) { + UINT i; + short eventType[cInputs]; + jint modifiers = GetModifiers( 0 ); + jint actionIdx = -1; + jint pointerNames[cInputs]; + jint x[cInputs], y[cInputs]; + jfloat pressure[cInputs]; + jfloat maxPressure = 1.0F; // FIXME: n/a on windows ? + + for (i=0; i < cInputs; i++) { + PTOUCHINPUT pTi = & pInputs[i]; + int inside; + POINT eventPt; + int isDown = pTi->dwFlags & TOUCHEVENTF_DOWN; + int isUp = pTi->dwFlags & TOUCHEVENTF_UP; + int isMove = pTi->dwFlags & TOUCHEVENTF_MOVE; + + int isPrim = pTi->dwFlags & TOUCHEVENTF_PRIMARY; + int isNoCoalesc = pTi->dwFlags & TOUCHEVENTF_NOCOALESCE; + + #ifdef VERBOSE_ON + const char * touchAction; + if( isDown ) { + touchAction = "down"; + } else if( isUp ) { + touchAction = "_up_"; + } else if( isMove ) { + touchAction = "move"; + } else { + touchAction = "undf"; + } + #endif + + pointerNames[i] = (jint)pTi->dwID; + eventPt.x = TOUCH_COORD_TO_PIXEL(pTi->x); + eventPt.y = TOUCH_COORD_TO_PIXEL(pTi->y); + ScreenToClient(wnd, &eventPt); + x[i] = (jint)eventPt.x; + y[i] = (jint)eventPt.y; + pressure[i] = 1.0F; // FIXME: n/a on windows ? + if(isDown) { + eventType[i] = (jshort) EVENT_MOUSE_PRESSED; + } else if(isUp) { + eventType[i] = (jshort) EVENT_MOUSE_RELEASED; + } else if(isMove) { + eventType[i] = (jshort) EVENT_MOUSE_MOVED; + } else { + eventType[i] = (jshort) 0; + } + if(isPrim) { + actionIdx = (jint)i; + } + inside = 0 <= x[i] && 0 <= y[i] && x[i] < wud->width && y[i] < wud->height; + + #ifdef VERBOSE_ON + DBG_PRINT("*** WindowsWindow: WM_TOUCH[%d/%d].%s name 0x%x, prim %d, nocoalsc %d, %d/%d [%dx%d] inside %d/%d, tDown %d\n", + (i+1), cInputs, touchAction, (int)(pTi->dwID), isPrim, isNoCoalesc, x[i], y[i], wud->width, wud->height, inside, wud->mouseInside, wud->touchDownCount); + #endif + } + int sentCount = 0, updownCount=0, moveCount=0; + // Primary first, if available! + if( 0 <= actionIdx ) { + sendTouchScreenEvent(env, window, eventType[actionIdx], modifiers, actionIdx, + cInputs, pointerNames, x, y, pressure, maxPressure); + sentCount++; + } + // 1 Move second .. + for (i=0; i < cInputs; i++) { + short et = eventType[i]; + if( (jshort) EVENT_MOUSE_MOVED == et ) { + if( i != actionIdx && 0 == moveCount ) { + sendTouchScreenEvent(env, window, et, modifiers, i, + cInputs, pointerNames, x, y, pressure, maxPressure); + sentCount++; + } + moveCount++; + } + } + // Up and downs last + for (i=0; i < cInputs; i++) { + short et = eventType[i]; + if( (jshort) EVENT_MOUSE_MOVED != et ) { + if( i != actionIdx ) { + sendTouchScreenEvent(env, window, et, modifiers, i, + cInputs, pointerNames, x, y, pressure, maxPressure); + sentCount++; + } + updownCount++; + } + } + DBG_PRINT("*** WindowsWindow: WM_TOUCH.summary pCount %d, prim %d, updown %d, move %d, sent %d\n", + cInputs, actionIdx, updownCount, moveCount, sentCount); + + // Message processed - close it + CloseTouchInputHandle(hTouch); + } else { + useDefWindowProc = 1; + } + free(pInputs); + } + break; + } + case WM_SETFOCUS: DBG_PRINT("*** WindowsWindow: WM_SETFOCUS window %p, lost %p\n", wnd, (HWND)wParam); (*env)->CallVoidMethod(env, window, focusChangedID, JNI_FALSE, JNI_TRUE); @@ -1044,6 +1276,8 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP case WM_KILLFOCUS: DBG_PRINT("*** WindowsWindow: WM_KILLFOCUS window %p, received %p\n", wnd, (HWND)wParam); + wud->touchDownCount=0; + wud->mouseInside=0; (*env)->CallVoidMethod(env, window, focusChangedID, JNI_FALSE, JNI_FALSE); useDefWindowProc = 1; break; @@ -1060,7 +1294,6 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP case WM_PAINT: { RECT r; - useDefWindowProc = 0; if (GetUpdateRect(wnd, &r, FALSE /* do not erase background */)) { // clear the whole client area and issue repaint for it, w/o looping through erase background ValidateRect(wnd, NULL); // clear all! @@ -1075,7 +1308,6 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP case WM_ERASEBKGND: // ignore erase background (*env)->CallVoidMethod(env, window, windowRepaintID, JNI_FALSE, 0, 0, -1, -1); - useDefWindowProc = 0; res = 1; // return 1 == done, OpenGL, etc .. erases the background, hence we claim to have just done this break; case WM_SETCURSOR : @@ -1089,7 +1321,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP useDefWindowProc = visibilityChangeSuccessful ? 1 : 0; DBG_PRINT("*** WindowsWindow: WM_SETCURSOR requested visibility: %d success: %d\n", wud->setPointerVisible, visibilityChangeSuccessful); wud->setPointerVisible = 0; - useDefWindowProc = 0; // own signal, consumed + // own signal, consumed } else { useDefWindowProc = 1; // NOP for us, allow parent to act } @@ -1545,6 +1777,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V"); + sendTouchScreenEventID = (*env)->GetMethodID(env, clazz, "sendTouchScreenEvent", "(SII[I[I[I[FF)V"); sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(SISSC)V"); requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V"); @@ -1556,6 +1789,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 windowDestroyNotifyID == NULL || windowRepaintID == NULL || sendMouseEventID == NULL || + sendTouchScreenEventID == NULL || sendKeyEventID == NULL || requestFocusID == NULL) { return JNI_FALSE; @@ -1615,9 +1849,8 @@ static void NewtWindow_setVisiblePosSize(HWND hwnd, BOOL atop, BOOL visible, */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindow0 (JNIEnv *env, jobject obj, - jlong hInstance, jstring jWndClassName, jstring jWndName, - jlong parent, - jint jx, jint jy, jint defaultWidth, jint defaultHeight, jboolean autoPosition, jint flags) + jlong hInstance, jstring jWndClassName, jstring jWndName, jint winMajor, jint winMinor, + jlong parent, jint jx, jint jy, jint defaultWidth, jint defaultHeight, jboolean autoPosition, jint flags) { HWND parentWindow = (HWND) (intptr_t) parent; const TCHAR* wndClassName = NULL; @@ -1659,8 +1892,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo (HINSTANCE) (intptr_t) hInstance, NULL); - DBG_PRINT("*** WindowsWindow: CreateWindow thread 0x%X, parent %p, window %p, %d/%d %dx%d, undeco %d, alwaysOnTop %d, autoPosition %d\n", - (int)GetCurrentThreadId(), parentWindow, window, x, y, width, height, + DBG_PRINT("*** WindowsWindow: CreateWindow thread 0x%X, win %d.%d parent %p, window %p, %d/%d %dx%d, undeco %d, alwaysOnTop %d, autoPosition %d\n", + (int)GetCurrentThreadId(), winMajor, winMinor, parentWindow, window, x, y, width, height, TST_FLAG_IS_UNDECORATED(flags), TST_FLAG_IS_ALWAYSONTOP(flags), autoPosition); if (NULL == window) { @@ -1671,7 +1904,24 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo WindowUserData * wud = (WindowUserData *) malloc(sizeof(WindowUserData)); wud->jinstance = (*env)->NewGlobalRef(env, obj); wud->jenv = env; + wud->width = width; + wud->height = height; wud->setPointerVisible = 0; + wud->mouseInside = 0; + wud->touchDownCount = 0; + wud->supportsMTouch = 0; + if ( winMajor > 6 || ( winMajor == 6 && winMinor >= 1 ) ) { + int value = GetSystemMetrics(SM_DIGITIZER); + if (value & NID_READY) { /* ready */ + if (value & NID_MULTI_INPUT) { /* multitouch */ + wud->supportsMTouch = 1; + } + if (value & NID_INTEGRATED_TOUCH) { /* Integrated touch */ + } + } + } + DBG_PRINT("*** WindowsWindow: CreateWindow supportsMTouch %d\n", wud->supportsMTouch); + #if !defined(__MINGW64__) && ( defined(UNDER_CE) || _MSC_VER <= 1200 ) SetWindowLong(window, GWL_USERDATA, (intptr_t) wud); #else @@ -1704,6 +1954,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo NewtWindow_setVisiblePosSize(window, TST_FLAG_IS_ALWAYSONTOP(flags), TRUE, x, y, width, height); } + if( wud->supportsMTouch ) { + RegisterTouchWindow(window, 0); + } } #ifdef UNICODE @@ -1930,23 +2183,3 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_warpPointer0 SetCursorPos(x, y); } -/* - * Class: Java_jogamp_newt_driver_windows_WindowDriver - * Method: trackPointerLeave0 - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_trackPointerLeave0 - (JNIEnv *env, jclass clazz, jlong window) -{ - HWND hwnd = (HWND) (intptr_t) window; - BOOL ok = NewtWindows_trackPointerLeave(hwnd); - DBG_PRINT( "*** WindowsWindow: trackMouseLeave0: %d\n", ok); - #ifdef VERBOSE_ON - if(!ok) { - int lastError = (int) GetLastError(); - DBG_PRINT( "*** WindowsWindow: trackMouseLeave0: lastError 0x%X %d\n", lastError, lastError); - } - #endif - (void)ok; -} - -- cgit v1.2.3 From 119133e89831fc837015b3f6fd7b258077c93d46 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 22:58:13 +0200 Subject: WindowImpl: Fix DEBUG output's method name of doPointerEvent and consumePointerEvent --- src/newt/classes/jogamp/newt/WindowImpl.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 624ac4df4..3f59da553 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2552,7 +2552,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( null != movePositionP0 ) { if( pState1.insideWindow && movePositionP0.getX() == x && movePositionP0.getY() == y ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: skip "+MouseEvent.getEventTypeString(eventType)+" w/ same position: "+movePositionP0); + System.err.println("doPointerEvent: skip "+MouseEvent.getEventTypeString(eventType)+" w/ same position: "+movePositionP0); } return; // skip same position } @@ -2570,13 +2570,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: drop: "+MouseEvent.getEventTypeString(eventType)+ + System.err.println("doPointerEvent: drop: "+MouseEvent.getEventTypeString(eventType)+ ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); } return; // .. invalid .. } if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: enqueue "+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+ + System.err.println("doPointerEvent: enqueue "+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+ ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); } @@ -2791,7 +2791,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int y = pe.getY(); if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent.in: "+pe); + System.err.println("consumePointerEvent.in: "+pe); } // @@ -2824,12 +2824,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if( null != eEntered ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent.send.0: "+eEntered); + System.err.println("consumePointerEvent.send.0: "+eEntered); } dispatchMouseEvent(eEntered); } else if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent.drop: "+pe); + System.err.println("consumePointerEvent.drop: "+pe); } return; // .. invalid .. } @@ -2852,7 +2852,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer scaledScrollSlop = Math.round(DoubleTapScrollGesture.SCROLL_SLOP_MM * pixPerMM); scaledDoubleTapSlop = Math.round(DoubleTapScrollGesture.DOUBLE_TAP_SLOP_MM * pixPerMM); if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent.gscroll: scrollSlop "+scaledScrollSlop+", doubleTapSlop "+scaledDoubleTapSlop+", pixPerMM "+pixPerMM+", "+monitor); + System.err.println("consumePointerEvent.gscroll: scrollSlop "+scaledScrollSlop+", doubleTapSlop "+scaledDoubleTapSlop+", pixPerMM "+pixPerMM+", "+monitor); } } else { scaledScrollSlop = DoubleTapScrollGesture.SCROLL_SLOP_PIXEL; @@ -2865,7 +2865,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer pe = (MouseEvent) gesture2PtrTouchScroll.getGestureEvent(); gesture2PtrTouchScroll.clear(false); if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent.gscroll: "+pe); + System.err.println("consumePointerEvent.gscroll: "+pe); } dispatchMouseEvent(pe); return; @@ -2927,7 +2927,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer case MouseEvent.EVENT_MOUSE_CLICKED: // ignore - synthesized here .. if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent: drop recv'ed (synth here) "+pe); + System.err.println("consumePointerEvent: drop recv'ed (synth here) "+pe); } pe = null; eClicked = null; @@ -2938,13 +2938,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( null != pe ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent.send.1: "+pe); + System.err.println("consumePointerEvent.send.1: "+pe); } dispatchMouseEvent(pe); // actual mouse event } if( null != eClicked ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent.send.2: "+eClicked); + System.err.println("consumePointerEvent.send.2: "+eClicked); } dispatchMouseEvent(eClicked); } -- cgit v1.2.3 From 77b0adbdb6e361e4d5d6ca31432e8fc625d02b24 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 18 Oct 2013 01:21:46 +0200 Subject: AWTPrintLifecycle.setupPrint(..): Fix regression of commit a05b87a369441d9ef38f97929f866b3d4ced0e57: NULL printGLAD of GLCanvas and NewtCanvasAWT We have to pre-init printGLAD w/ current GLAD (similiar w/ GLJPanel). Also properly define reqNewGLAD: reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); where '!caps.getSampleBuffers() && ( .. )' is due to Bug 830, swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX does not work. --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 13 +++++++------ src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 14 ++++++++------ 3 files changed, 17 insertions(+), 14 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 84f487c38..1884c7c1b 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -299,7 +299,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -335,7 +335,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* # diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index b9576b8d6..6828beb10 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -757,24 +757,25 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( null != printAnimator ) { printAnimator.remove(GLCanvas.this); } + printGLAD = GLCanvas.this; // _not_ default, shall be replaced by offscreen GLAD final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); final int printNumSamples = printAWTTiles.getNumSamples(caps); GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); - final boolean reqNewGLAD = !caps.getSampleBuffers(); // reqNewGLADSamples || reqNewGLADSize ; + final boolean reqNewGLADOnscrn = caps.isOnscreen(); + // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context. + // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX + final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); if( DEBUG ) { - System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ + System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } - if( caps.getSampleBuffers() ) { - // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX - printGLAD = GLCanvas.this; - } else { + if( reqNewGLAD ) { caps.setDoubleBuffered(false); caps.setOnscreen(false); if( printNumSamples != caps.getNumSamples() ) { diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 767533d40..13affdf49 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -519,24 +519,26 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( null != printAnimator ) { printAnimator.remove(glad); } + printGLAD = glad; // _not_ default, shall be replaced by offscreen GLAD final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); final int printNumSamples = printAWTTiles.getNumSamples(caps); GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); - final boolean reqNewGLAD = !caps.getSampleBuffers(); // reqNewGLADSamples || reqNewGLADSize ; + final boolean reqNewGLADOnscrn = caps.isOnscreen(); + + // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context. + // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX + final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); if( DEBUG ) { - System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ + System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } - if( caps.getSampleBuffers() ) { - // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX - printGLAD = glad; - } else { + if( reqNewGLAD ) { caps.setDoubleBuffered(false); caps.setOnscreen(false); if( printNumSamples != caps.getNumSamples() ) { -- cgit v1.2.3 From 2ebf1bf35928e35ded6e38df64dee7aa578ae3c7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 18 Oct 2013 02:27:33 +0200 Subject: MouseEvent: Clarify button-number and pointer-ID relation incl. case 'no button/pointer', i.e. button == 0, pointer-ID == -1 doPointerEvent: - allow id==-1 -> button==0 for no button, i.e. mouse move doMouseEvent: - keep button 0 value, i.e. map to pointer-ID -1 --- make/scripts/tests.sh | 4 +- .../classes/com/jogamp/newt/event/MouseEvent.java | 83 ++++++++++++++++++---- src/newt/classes/jogamp/newt/WindowImpl.java | 14 ++-- 3 files changed, 78 insertions(+), 23 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 1884c7c1b..99c19c9ad 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -335,7 +335,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* # @@ -523,7 +523,7 @@ testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 85c65b39c..57dd7e68c 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -49,9 +49,21 @@ package com.jogamp.newt.event; * For example {@link #getX(int) e.getX(0)} at {@link #EVENT_MOUSE_PRESSED} returns the data of the pressed pointer, etc. *

    *

    - * If representing a multiple-pointer event, the {@link #getButton() button number} is equal to the first {@link #getPointerId(int) pointer ID} + * A {@link #getButton() button value} of 0 denotes no button activity, i.e. {@link PointerType#Mouse} move. + *

    + *

    + * A {@link #getPointerId(int) pointer-ID} of -1 denotes no pointer/button activity, i.e. {@link PointerType#Mouse} move. + *

    + *

    + * {@link #getButton() Button values} are mapped from and to {@link #getPointerId(int) pointer-IDs} as follows: + * + * getPointerId(0) == getButton() - 1 + * . + *

    + *

    + * If representing a multiple-pointer event, the {@link #getButton() button number} is mapped to the first {@link #getPointerId(int) pointer ID} * triggering the event and the {@link InputEvent#BUTTON1_MASK button mask bits} in the {@link #getModifiers() modifiers} - * field represents the pressed pointer IDs.
    + * field represent the pressed pointer IDs.
    * Hence users can query the pressed button count as well as the pressed pointer count via {@link InputEvent#getButtonDownCount()} * or use the simple query {@link InputEvent#isAnyButtonDown()}. *

    @@ -162,7 +174,21 @@ public class MouseEvent extends InputEvent return 300; } - /** Constructor for traditional one-pointer event. */ + /** + * Constructor for traditional one-pointer event. + * + * @param eventType + * @param source + * @param when + * @param modifiers + * @param x X-axis + * @param y Y-axis + * @param clickCount Mouse-button click-count + * @param button button number, e.g. [{@link #BUTTON1}..{@link #BUTTON_COUNT}-1]. + * A button value of 0 denotes no button activity, i.e. {@link PointerType#Mouse} move. + * @param rotationXYZ Rotation of all axis + * @param rotationScale Rotation scale + */ public MouseEvent(short eventType, Object source, long when, int modifiers, int x, int y, short clickCount, short button, float[] rotationXYZ, float rotationScale) @@ -203,6 +229,7 @@ public class MouseEvent extends InputEvent * @param modifiers * @param pointerType PointerType for each pointer (multiple pointer) * @param pointerID Pointer ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. + * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move. * @param x X-axis for each pointer (multiple pointer) * @param y Y-axis for each pointer (multiple pointer) * @param pressure Pressure for each pointer (multiple pointer) @@ -246,6 +273,7 @@ public class MouseEvent extends InputEvent } /** + * See details for multiple-pointer events. * @return the count of pointers involved in this event */ public final int getPointerCount() { @@ -253,8 +281,8 @@ public class MouseEvent extends InputEvent } /** - * @return the {@link PointerType} for the data at index. - * return null if index not available. + * See details for multiple-pointer events. + * @return the {@link PointerType} for the data at index or null if index not available. */ public final PointerType getPointerType(int index) { if(0 > index || index >= pointerType.length) { @@ -264,6 +292,7 @@ public class MouseEvent extends InputEvent } /** + * See details for multiple-pointer events. * @return array of all {@link PointerType}s for all pointers */ public final PointerType[] getAllPointerTypes() { @@ -271,8 +300,16 @@ public class MouseEvent extends InputEvent } /** - * @return the pointer id for the given index. - * return -1 if index not available. IDs start w/ 0 and are consecutive numbers. + * Return the pointer id for the given index or -1 if index not available. + *

    + * IDs start w/ 0 and are consecutive numbers. + *

    + *

    + * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move. + *

    + *

    + * See details for multiple-pointer events. + *

    */ public final short getPointerId(int index) { if(0 > index || index >= pointerID.length) { @@ -282,19 +319,22 @@ public class MouseEvent extends InputEvent } /** - * @return the pointer index for the given pointer id. - * return -1 if id not available. + * See details for multiple-pointer events. + * @return the pointer index for the given pointer id or -1 if id not available. */ public final int getPointerIdx(short id) { - for(int i=pointerID.length-1; i>=0; i--) { - if( pointerID[i] == id ) { - return i; + if( id >= 0 ) { + for(int i=pointerID.length-1; i>=0; i--) { + if( pointerID[i] == id ) { + return i; + } } } return -1; } /** + * See details for multiple-pointer events. * @return array of all pointer IDs for all pointers. IDs start w/ 0 and are consecutive numbers. */ public final short[] getAllPointerIDs() { @@ -304,6 +344,9 @@ public class MouseEvent extends InputEvent /** * Returns the button number, e.g. [{@link #BUTTON1}..{@link #BUTTON_COUNT}-1]. *

    + * A button value of 0 denotes no button activity, i.e. {@link PointerType#Mouse} move. + *

    + *

    * See details for multiple-pointer events. *

    */ @@ -511,7 +554,12 @@ public class MouseEvent extends InputEvent /** PointerType for each pointer (multiple pointer) */ private final PointerType pointerType[]; - /** Pointer-ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. */ + /** + * Pointer-ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. + *

    + * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move. + *

    + */ private final short pointerID[]; /** X-axis for each pointer (multiple pointer) */ private final int x[]; @@ -520,7 +568,14 @@ public class MouseEvent extends InputEvent /** Pressure for each pointer (multiple pointer) */ private final float pressure[]; // private final short tiltX[], tiltY[]; // TODO: A generic way for pointer axis information, see Android MotionEvent! - private final short clickCount, button; + private final short clickCount; + /** + * Returns the button number, e.g. [{@link #BUTTON1}..{@link #BUTTON_COUNT}-1]. + *

    + * A button value of 0 denotes no button activity, i.e. {@link PointerType#Mouse} move. + *

    + */ + private final short button; /** Rotation around the X, Y and X axis */ private final float[] rotationXYZ; /** Rotation scale */ diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 3f59da553..a35d89408 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2381,8 +2381,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int x, int y, short button, final float[] rotationXYZ, float rotationScale) { if( 0 > button || button > MouseEvent.BUTTON_COUNT ) { throw new NativeWindowException("Invalid mouse button number" + button); - } else if( 0 == button ) { - button = 1; } doPointerEvent(enqueue, wait, constMousePointerTypes, eventType, modifiers, 0 /*actionIdx*/, new short[] { (short)(button-1) }, @@ -2467,7 +2465,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param eventType * @param modifiers * @param pActionIdx index of multiple-pointer arrays representing the pointer which triggered the event - * @param pID Pointer ID for each pointer (multiple pointer). We assume consecutive pointerIDs starting w/ 0. + * @param pID Pointer ID for each pointer (multiple pointer). We assume consecutive pointerIDs starting w/ 0. + * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move. * @param pX X-axis for each pointer (multiple pointer) * @param pY Y-axis for each pointer (multiple pointer) * @param pPressure Pressure for each pointer (multiple pointer) @@ -2513,7 +2512,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final short button; { final int b = id + 1; - if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { + if( 0 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { // we allow id==-1 -> button==0 for no button, i.e. mouse move button = (short)b; } else { button = com.jogamp.newt.event.MouseEvent.BUTTON1; @@ -2580,7 +2579,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); } - modifiers |= InputEvent.getButtonMask(button); // Always add current button to modifier mask (Bug 571) + final int buttonMask = InputEvent.getButtonMask(button); + modifiers |= buttonMask; // Always add current button to modifier mask (Bug 571) modifiers |= pState1.buttonPressedMask; // Always add currently pressed mouse buttons to modifier mask if( isPointerConfined() ) { @@ -2609,7 +2609,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( 0 >= pPressure[0] ) { pPressure[0] = maxPressure; } - pState1.buttonPressedMask |= InputEvent.getButtonMask(button); + pState1.buttonPressedMask |= buttonMask; if( 1 == pCount ) { if( when - pState1.lastButtonPressTime < MouseEvent.getClickTimeout() ) { pState1.lastButtonClickCount++; @@ -2638,7 +2638,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); } - pState1.buttonPressedMask &= ~InputEvent.getButtonMask(button); + pState1.buttonPressedMask &= ~buttonMask; if( null != movePositionP0 ) { movePositionP0.set(0, 0); } -- cgit v1.2.3 From 5e9c02bce7b241a0bf95c8abca9a91cd25e51ed3 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Thu, 17 Oct 2013 22:27:27 -0700 Subject: jogl: remove all trailing whitespace Signed-off-by: Harvey Harrison --- .../com/jogamp/audio/windows/waveout/Audio.java | 10 +- .../com/jogamp/audio/windows/waveout/Mixer.java | 12 +- .../jogamp/audio/windows/waveout/SoundBuffer.java | 10 +- .../com/jogamp/audio/windows/waveout/Track.java | 12 +- .../com/jogamp/audio/windows/waveout/Vec3f.java | 10 +- .../gluegen/opengl/BuildComposablePipeline.java | 18 +- .../jogamp/gluegen/opengl/BuildStaticGLInfo.java | 38 +- .../com/jogamp/gluegen/opengl/GLConfiguration.java | 28 +- .../com/jogamp/gluegen/opengl/GLEmitter.java | 34 +- .../gluegen/opengl/GLJavaMethodBindingEmitter.java | 16 +- .../jogamp/gluegen/opengl/ant/StaticGLGenTask.java | 72 +- .../opengl/nativesig/NativeSignatureEmitter.java | 18 +- .../NativeSignatureJavaMethodBindingEmitter.java | 26 +- .../gluegen/runtime/opengl/GLNameResolver.java | 20 +- .../runtime/opengl/GLProcAddressResolver.java | 10 +- .../com/jogamp/graph/curve/OutlineShape.java | 124 ++-- .../classes/com/jogamp/graph/curve/Region.java | 68 +- .../com/jogamp/graph/curve/opengl/GLRegion.java | 42 +- .../jogamp/graph/curve/opengl/RegionRenderer.java | 24 +- .../com/jogamp/graph/curve/opengl/RenderState.java | 32 +- .../com/jogamp/graph/curve/opengl/Renderer.java | 84 +-- .../jogamp/graph/curve/opengl/TextRenderer.java | 60 +- .../com/jogamp/graph/curve/tess/Triangulation.java | 2 +- .../com/jogamp/graph/curve/tess/Triangulator.java | 12 +- src/jogl/classes/com/jogamp/graph/font/Font.java | 34 +- .../classes/com/jogamp/graph/font/FontFactory.java | 20 +- .../classes/com/jogamp/graph/font/FontSet.java | 16 +- .../classes/com/jogamp/graph/geom/Outline.java | 36 +- .../classes/com/jogamp/graph/geom/Triangle.java | 10 +- src/jogl/classes/com/jogamp/graph/geom/Vertex.java | 22 +- .../com/jogamp/graph/geom/opengl/SVertex.java | 40 +- src/jogl/classes/com/jogamp/opengl/FBObject.java | 786 ++++++++++----------- .../com/jogamp/opengl/GLAutoDrawableDelegate.java | 56 +- .../com/jogamp/opengl/GLEventListenerState.java | 118 ++-- .../classes/com/jogamp/opengl/GLExtensions.java | 22 +- .../com/jogamp/opengl/GLRendererQuirks.java | 64 +- .../classes/com/jogamp/opengl/GLStateKeeper.java | 38 +- .../opengl/GenericGLCapabilitiesChooser.java | 10 +- .../classes/com/jogamp/opengl/JoglVersion.java | 40 +- .../opengl/cg/CgDynamicLibraryBundleInfo.java | 24 +- .../classes/com/jogamp/opengl/cg/CgException.java | 14 +- .../classes/com/jogamp/opengl/math/FixedPoint.java | 12 +- .../classes/com/jogamp/opengl/math/FloatUtil.java | 88 +-- .../classes/com/jogamp/opengl/math/Quaternion.java | 38 +- .../classes/com/jogamp/opengl/math/VectorUtil.java | 46 +- .../com/jogamp/opengl/math/Vert2fImmutable.java | 4 +- .../com/jogamp/opengl/math/geom/AABBox.java | 84 +-- .../com/jogamp/opengl/math/geom/Frustum.java | 82 +-- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 134 ++-- .../com/jogamp/opengl/util/AWTAnimatorImpl.java | 10 +- .../classes/com/jogamp/opengl/util/Animator.java | 34 +- .../com/jogamp/opengl/util/AnimatorBase.java | 106 +-- .../jogamp/opengl/util/DefaultAnimatorImpl.java | 10 +- .../com/jogamp/opengl/util/FPSAnimator.java | 66 +- .../com/jogamp/opengl/util/GLArrayDataClient.java | 80 +-- .../jogamp/opengl/util/GLArrayDataEditable.java | 28 +- .../com/jogamp/opengl/util/GLArrayDataServer.java | 122 ++-- .../com/jogamp/opengl/util/GLArrayDataWrapper.java | 112 +-- .../classes/com/jogamp/opengl/util/GLBuffers.java | 388 +++++----- .../com/jogamp/opengl/util/GLDrawableUtil.java | 50 +- .../com/jogamp/opengl/util/GLPixelBuffer.java | 126 ++-- .../jogamp/opengl/util/GLPixelStorageModes.java | 48 +- .../com/jogamp/opengl/util/GLReadBufferUtil.java | 62 +- src/jogl/classes/com/jogamp/opengl/util/Gamma.java | 14 +- .../com/jogamp/opengl/util/ImmModeSink.java | 382 +++++----- .../classes/com/jogamp/opengl/util/PMVMatrix.java | 276 ++++---- .../com/jogamp/opengl/util/RandomTileRenderer.java | 56 +- .../classes/com/jogamp/opengl/util/TGAWriter.java | 16 +- .../com/jogamp/opengl/util/TileRenderer.java | 78 +- .../com/jogamp/opengl/util/TileRendererBase.java | 148 ++-- .../classes/com/jogamp/opengl/util/TimeFrameI.java | 30 +- .../com/jogamp/opengl/util/av/AudioSink.java | 188 ++--- .../jogamp/opengl/util/av/AudioSinkFactory.java | 10 +- .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 192 ++--- .../opengl/util/av/GLMediaPlayerFactory.java | 12 +- .../jogamp/opengl/util/awt/AWTGLPixelBuffer.java | 78 +- .../opengl/util/awt/AWTGLReadBufferUtil.java | 12 +- .../com/jogamp/opengl/util/awt/ImageUtil.java | 26 +- .../com/jogamp/opengl/util/awt/Overlay.java | 14 +- .../com/jogamp/opengl/util/awt/Screenshot.java | 28 +- .../com/jogamp/opengl/util/awt/TextRenderer.java | 12 +- .../jogamp/opengl/util/awt/TextureRenderer.java | 28 +- .../com/jogamp/opengl/util/gl2/BitmapCharRec.java | 18 +- .../com/jogamp/opengl/util/gl2/BitmapFontRec.java | 18 +- .../com/jogamp/opengl/util/gl2/CoordRec.java | 18 +- .../classes/com/jogamp/opengl/util/gl2/GLUT.java | 52 +- .../com/jogamp/opengl/util/gl2/GLUTBitmap8x13.java | 14 +- .../com/jogamp/opengl/util/gl2/GLUTBitmap9x15.java | 14 +- .../opengl/util/gl2/GLUTBitmapHelvetica10.java | 14 +- .../opengl/util/gl2/GLUTBitmapHelvetica12.java | 14 +- .../opengl/util/gl2/GLUTBitmapHelvetica18.java | 14 +- .../opengl/util/gl2/GLUTBitmapTimesRoman10.java | 14 +- .../opengl/util/gl2/GLUTBitmapTimesRoman24.java | 14 +- .../opengl/util/gl2/GLUTStrokeMonoRoman.java | 14 +- .../jogamp/opengl/util/gl2/GLUTStrokeRoman.java | 14 +- .../com/jogamp/opengl/util/gl2/StrokeCharRec.java | 18 +- .../com/jogamp/opengl/util/gl2/StrokeFontRec.java | 18 +- .../com/jogamp/opengl/util/gl2/StrokeRec.java | 20 +- .../com/jogamp/opengl/util/glsl/ShaderCode.java | 208 +++--- .../com/jogamp/opengl/util/glsl/ShaderProgram.java | 42 +- .../com/jogamp/opengl/util/glsl/ShaderState.java | 232 +++--- .../com/jogamp/opengl/util/glsl/ShaderUtil.java | 54 +- .../opengl/util/glsl/fixedfunc/FixedFuncUtil.java | 12 +- .../util/glsl/fixedfunc/ShaderSelectionMode.java | 18 +- .../jogamp/opengl/util/glsl/sdk/CompileShader.java | 4 +- .../opengl/util/packrect/BackingStoreManager.java | 14 +- .../com/jogamp/opengl/util/packrect/Level.java | 16 +- .../com/jogamp/opengl/util/packrect/LevelSet.java | 16 +- .../com/jogamp/opengl/util/packrect/Rect.java | 16 +- .../jogamp/opengl/util/packrect/RectVisitor.java | 14 +- .../opengl/util/packrect/RectanglePacker.java | 16 +- .../com/jogamp/opengl/util/texture/Texture.java | 86 +-- .../jogamp/opengl/util/texture/TextureCoords.java | 16 +- .../jogamp/opengl/util/texture/TextureData.java | 94 +-- .../com/jogamp/opengl/util/texture/TextureIO.java | 74 +- .../opengl/util/texture/TextureSequence.java | 120 ++-- .../jogamp/opengl/util/texture/TextureState.java | 52 +- .../opengl/util/texture/awt/AWTTextureData.java | 28 +- .../opengl/util/texture/awt/AWTTextureIO.java | 18 +- .../jogamp/opengl/util/texture/spi/DDSImage.java | 22 +- .../jogamp/opengl/util/texture/spi/JPEGImage.java | 40 +- .../opengl/util/texture/spi/LEDataInputStream.java | 22 +- .../util/texture/spi/LEDataOutputStream.java | 14 +- .../util/texture/spi/NetPbmTextureWriter.java | 36 +- .../jogamp/opengl/util/texture/spi/PNGImage.java | 66 +- .../jogamp/opengl/util/texture/spi/SGIImage.java | 38 +- .../jogamp/opengl/util/texture/spi/TGAImage.java | 34 +- .../opengl/util/texture/spi/TextureProvider.java | 14 +- .../opengl/util/texture/spi/TextureWriter.java | 14 +- .../util/texture/spi/awt/IIOTextureProvider.java | 14 +- .../util/texture/spi/awt/IIOTextureWriter.java | 16 +- src/jogl/classes/javax/media/opengl/DebugGL2.java | 2 +- src/jogl/classes/javax/media/opengl/DebugGL3.java | 2 +- .../classes/javax/media/opengl/DebugGL3bc.java | 2 +- src/jogl/classes/javax/media/opengl/DebugGL4.java | 2 +- .../classes/javax/media/opengl/DebugGLES2.java | 2 +- .../media/opengl/DefaultGLCapabilitiesChooser.java | 32 +- .../classes/javax/media/opengl/FPSCounter.java | 32 +- .../javax/media/opengl/GLAnimatorControl.java | 16 +- .../classes/javax/media/opengl/GLArrayData.java | 20 +- .../classes/javax/media/opengl/GLAutoDrawable.java | 120 ++-- src/jogl/classes/javax/media/opengl/GLBase.java | 108 +-- .../classes/javax/media/opengl/GLCapabilities.java | 16 +- .../javax/media/opengl/GLCapabilitiesChooser.java | 16 +- .../media/opengl/GLCapabilitiesImmutable.java | 10 +- src/jogl/classes/javax/media/opengl/GLContext.java | 320 ++++----- .../javax/media/opengl/GLDebugListener.java | 8 +- .../classes/javax/media/opengl/GLDebugMessage.java | 114 +-- .../classes/javax/media/opengl/GLDrawable.java | 22 +- .../javax/media/opengl/GLDrawableFactory.java | 152 ++-- .../javax/media/opengl/GLEventListener.java | 22 +- .../classes/javax/media/opengl/GLException.java | 14 +- .../classes/javax/media/opengl/GLFBODrawable.java | 76 +- .../media/opengl/GLOffscreenAutoDrawable.java | 20 +- src/jogl/classes/javax/media/opengl/GLPbuffer.java | 4 +- .../javax/media/opengl/GLPipelineFactory.java | 22 +- src/jogl/classes/javax/media/opengl/GLProfile.java | 282 ++++---- .../classes/javax/media/opengl/GLRunnable.java | 20 +- .../classes/javax/media/opengl/GLRunnable2.java | 14 +- .../classes/javax/media/opengl/GLUniformData.java | 14 +- src/jogl/classes/javax/media/opengl/Threading.java | 52 +- src/jogl/classes/javax/media/opengl/TraceGL2.java | 2 +- src/jogl/classes/javax/media/opengl/TraceGL3.java | 2 +- .../classes/javax/media/opengl/TraceGL3bc.java | 2 +- src/jogl/classes/javax/media/opengl/TraceGL4.java | 2 +- .../classes/javax/media/opengl/TraceGLES2.java | 2 +- .../javax/media/opengl/awt/ComponentEvents.java | 14 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 104 +-- .../classes/javax/media/opengl/awt/GLJPanel.java | 192 ++--- .../javax/media/opengl/fixedfunc/GLMatrixFunc.java | 18 +- .../media/opengl/fixedfunc/GLPointerFunc.java | 2 +- .../media/opengl/fixedfunc/GLPointerFuncUtil.java | 10 +- .../jogamp/graph/curve/opengl/RegionFactory.java | 20 +- .../graph/curve/opengl/RegionRendererImpl01.java | 24 +- .../jogamp/graph/curve/opengl/RenderStateImpl.java | 14 +- .../graph/curve/opengl/TextRendererImpl01.java | 26 +- .../jogamp/graph/curve/opengl/VBORegion2PES2.java | 178 ++--- .../jogamp/graph/curve/opengl/VBORegionSPES2.java | 34 +- .../graph/curve/opengl/shader/AttributeNames.java | 12 +- .../graph/curve/opengl/shader/UniformNames.java | 2 +- .../jogamp/graph/curve/tess/CDTriangulator2D.java | 30 +- .../jogamp/graph/curve/tess/GraphOutline.java | 10 +- .../jogamp/graph/curve/tess/GraphVertex.java | 12 +- .../classes/jogamp/graph/curve/tess/HEdge.java | 12 +- src/jogl/classes/jogamp/graph/curve/tess/Loop.java | 30 +- .../jogamp/graph/curve/text/GlyphShape.java | 20 +- .../jogamp/graph/curve/text/GlyphString.java | 58 +- src/jogl/classes/jogamp/graph/font/FontInt.java | 2 +- .../classes/jogamp/graph/font/JavaFontLoader.java | 46 +- .../jogamp/graph/font/UbuntuFontLoader.java | 36 +- .../jogamp/graph/font/typecast/TypecastFont.java | 56 +- .../font/typecast/TypecastFontConstructor.java | 10 +- .../jogamp/graph/font/typecast/TypecastGlyph.java | 88 +-- .../graph/font/typecast/TypecastHMetrics.java | 14 +- .../graph/font/typecast/TypecastRenderer.java | 26 +- .../graph/font/typecast/ot/Disassembler.java | 8 +- .../jogamp/graph/font/typecast/ot/Fixed.java | 4 +- .../jogamp/graph/font/typecast/ot/Mnemonic.java | 8 +- .../jogamp/graph/font/typecast/ot/OTFont.java | 36 +- .../graph/font/typecast/ot/OTFontCollection.java | 4 +- .../jogamp/graph/font/typecast/ot/OTGlyph.java | 8 +- .../graph/font/typecast/ot/mac/ResourceData.java | 2 +- .../graph/font/typecast/ot/mac/ResourceFile.java | 10 +- .../graph/font/typecast/ot/mac/ResourceHeader.java | 6 +- .../graph/font/typecast/ot/mac/ResourceMap.java | 10 +- .../font/typecast/ot/mac/ResourceReference.java | 12 +- .../graph/font/typecast/ot/mac/ResourceType.java | 10 +- .../graph/font/typecast/ot/table/BaseTable.java | 98 +-- .../graph/font/typecast/ot/table/CffTable.java | 122 ++-- .../graph/font/typecast/ot/table/Charstring.java | 2 +- .../font/typecast/ot/table/CharstringType2.java | 18 +- .../graph/font/typecast/ot/table/ClassDef.java | 8 +- .../font/typecast/ot/table/ClassDefFormat1.java | 8 +- .../font/typecast/ot/table/ClassDefFormat2.java | 8 +- .../graph/font/typecast/ot/table/CmapFormat.java | 14 +- .../graph/font/typecast/ot/table/CmapFormat0.java | 2 +- .../graph/font/typecast/ot/table/CmapFormat2.java | 28 +- .../graph/font/typecast/ot/table/CmapFormat4.java | 4 +- .../graph/font/typecast/ot/table/CmapFormat6.java | 4 +- .../font/typecast/ot/table/CmapFormatUnknown.java | 6 +- .../font/typecast/ot/table/CmapIndexEntry.java | 2 +- .../graph/font/typecast/ot/table/CmapTable.java | 10 +- .../graph/font/typecast/ot/table/Coverage.java | 2 +- .../graph/font/typecast/ot/table/CvtTable.java | 12 +- .../graph/font/typecast/ot/table/Device.java | 8 +- .../font/typecast/ot/table/DirectoryEntry.java | 4 +- .../graph/font/typecast/ot/table/DsigEntry.java | 14 +- .../graph/font/typecast/ot/table/DsigTable.java | 12 +- .../graph/font/typecast/ot/table/FeatureList.java | 8 +- .../font/typecast/ot/table/FeatureRecord.java | 2 +- .../graph/font/typecast/ot/table/FpgmTable.java | 12 +- .../graph/font/typecast/ot/table/GaspRange.java | 12 +- .../graph/font/typecast/ot/table/GaspTable.java | 14 +- .../typecast/ot/table/GlyfCompositeDescript.java | 2 +- .../graph/font/typecast/ot/table/GlyfDescript.java | 2 +- .../font/typecast/ot/table/GlyfSimpleDescript.java | 4 +- .../graph/font/typecast/ot/table/GlyfTable.java | 6 +- .../font/typecast/ot/table/GlyphDescription.java | 24 +- .../graph/font/typecast/ot/table/GposTable.java | 4 +- .../graph/font/typecast/ot/table/GsubTable.java | 20 +- .../graph/font/typecast/ot/table/HdmxTable.java | 20 +- .../graph/font/typecast/ot/table/HeadTable.java | 4 +- .../graph/font/typecast/ot/table/HheaTable.java | 12 +- .../jogamp/graph/font/typecast/ot/table/ID.java | 4 +- .../graph/font/typecast/ot/table/KernSubtable.java | 12 +- .../typecast/ot/table/KernSubtableFormat0.java | 10 +- .../typecast/ot/table/KernSubtableFormat2.java | 8 +- .../graph/font/typecast/ot/table/KernTable.java | 14 +- .../graph/font/typecast/ot/table/KerningPair.java | 8 +- .../graph/font/typecast/ot/table/LangSys.java | 10 +- .../font/typecast/ot/table/LangSysRecord.java | 2 +- .../graph/font/typecast/ot/table/Ligature.java | 4 +- .../typecast/ot/table/LigatureSubstFormat1.java | 2 +- .../graph/font/typecast/ot/table/LocaTable.java | 10 +- .../graph/font/typecast/ot/table/Lookup.java | 2 +- .../graph/font/typecast/ot/table/LookupList.java | 8 +- .../typecast/ot/table/LookupSubtableFactory.java | 4 +- .../graph/font/typecast/ot/table/LtshTable.java | 16 +- .../graph/font/typecast/ot/table/MaxpTable.java | 14 +- .../graph/font/typecast/ot/table/NameRecord.java | 18 +- .../graph/font/typecast/ot/table/NameTable.java | 14 +- .../graph/font/typecast/ot/table/Os2Table.java | 14 +- .../graph/font/typecast/ot/table/Panose.java | 26 +- .../graph/font/typecast/ot/table/PcltTable.java | 14 +- .../graph/font/typecast/ot/table/PostTable.java | 18 +- .../graph/font/typecast/ot/table/PrepTable.java | 12 +- .../graph/font/typecast/ot/table/Program.java | 8 +- .../graph/font/typecast/ot/table/RangeRecord.java | 2 +- .../graph/font/typecast/ot/table/Script.java | 6 +- .../graph/font/typecast/ot/table/ScriptList.java | 12 +- .../graph/font/typecast/ot/table/ScriptRecord.java | 4 +- .../font/typecast/ot/table/SignatureBlock.java | 10 +- .../graph/font/typecast/ot/table/SingleSubst.java | 2 +- .../font/typecast/ot/table/SingleSubstFormat1.java | 2 +- .../font/typecast/ot/table/SingleSubstFormat2.java | 2 +- .../graph/font/typecast/ot/table/TTCHeader.java | 12 +- .../jogamp/graph/font/typecast/ot/table/Table.java | 12 +- .../font/typecast/ot/table/TableDirectory.java | 2 +- .../font/typecast/ot/table/TableException.java | 6 +- .../graph/font/typecast/ot/table/TableFactory.java | 10 +- .../graph/font/typecast/ot/table/VdmxTable.java | 40 +- .../graph/font/typecast/ot/table/VheaTable.java | 2 +- .../graph/font/typecast/t2/T2Interpreter.java | 146 ++-- .../graph/font/typecast/tt/engine/Interpreter.java | 4 +- .../jogamp/graph/geom/plane/AffineTransform.java | 50 +- .../classes/jogamp/graph/geom/plane/Crossing.java | 26 +- .../classes/jogamp/graph/geom/plane/Path2D.java | 42 +- src/jogl/classes/jogamp/opengl/Debug.java | 20 +- .../opengl/DesktopGLDynamicLibraryBundleInfo.java | 14 +- .../opengl/DesktopGLDynamicLookupHelper.java | 10 +- .../jogamp/opengl/ExtensionAvailabilityCache.java | 38 +- src/jogl/classes/jogamp/opengl/FPSCounterImpl.java | 50 +- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 144 ++-- .../classes/jogamp/opengl/GLBufferSizeTracker.java | 18 +- .../jogamp/opengl/GLBufferStateTracker.java | 30 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 296 ++++---- .../classes/jogamp/opengl/GLContextShareSet.java | 50 +- .../jogamp/opengl/GLDebugMessageHandler.java | 126 ++-- .../jogamp/opengl/GLDrawableFactoryImpl.java | 58 +- .../classes/jogamp/opengl/GLDrawableHelper.java | 198 +++--- src/jogl/classes/jogamp/opengl/GLDrawableImpl.java | 64 +- .../jogamp/opengl/GLDynamicLibraryBundleInfo.java | 18 +- .../jogamp/opengl/GLDynamicLookupHelper.java | 10 +- .../classes/jogamp/opengl/GLFBODrawableImpl.java | 142 ++-- .../jogamp/opengl/GLGraphicsConfigurationUtil.java | 60 +- .../jogamp/opengl/GLOffscreenAutoDrawableImpl.java | 42 +- src/jogl/classes/jogamp/opengl/GLPbufferImpl.java | 16 +- src/jogl/classes/jogamp/opengl/GLRunnableTask.java | 28 +- src/jogl/classes/jogamp/opengl/GLStateTracker.java | 52 +- .../classes/jogamp/opengl/GLVersionNumber.java | 20 +- src/jogl/classes/jogamp/opengl/GLWorkerThread.java | 24 +- src/jogl/classes/jogamp/opengl/GLXExtensions.java | 4 +- .../jogamp/opengl/ListenerSyncedImplStub.java | 12 +- src/jogl/classes/jogamp/opengl/ProjectFloat.java | 120 ++-- .../jogamp/opengl/SharedResourceRunner.java | 44 +- src/jogl/classes/jogamp/opengl/ThreadingImpl.java | 38 +- .../jogamp/opengl/ToolkitThreadingPlugin.java | 16 +- .../jogamp/opengl/awt/AWTThreadingPlugin.java | 16 +- .../classes/jogamp/opengl/awt/AWTTilePainter.java | 74 +- src/jogl/classes/jogamp/opengl/awt/AWTUtil.java | 16 +- src/jogl/classes/jogamp/opengl/awt/Java2D.java | 46 +- .../classes/jogamp/opengl/awt/VersionApplet.java | 6 +- .../egl/DesktopES2DynamicLibraryBundleInfo.java | 26 +- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 20 +- .../classes/jogamp/opengl/egl/EGLDisplayUtil.java | 62 +- .../classes/jogamp/opengl/egl/EGLDrawable.java | 20 +- .../jogamp/opengl/egl/EGLDrawableFactory.java | 136 ++-- .../opengl/egl/EGLDummyUpstreamSurfaceHook.java | 12 +- .../opengl/egl/EGLDynamicLibraryBundleInfo.java | 30 +- .../opengl/egl/EGLES1DynamicLibraryBundleInfo.java | 28 +- .../opengl/egl/EGLES2DynamicLibraryBundleInfo.java | 38 +- .../opengl/egl/EGLGraphicsConfiguration.java | 58 +- .../egl/EGLGraphicsConfigurationFactory.java | 68 +- .../jogamp/opengl/egl/EGLOnscreenDrawable.java | 4 +- .../jogamp/opengl/egl/EGLUpstreamSurfaceHook.java | 50 +- .../jogamp/opengl/egl/EGLWrappedSurface.java | 10 +- .../classes/jogamp/opengl/gl2/ProjectDouble.java | 92 +-- .../classes/jogamp/opengl/glu/GLUquadricImpl.java | 82 +-- src/jogl/classes/jogamp/opengl/glu/Glue.java | 16 +- .../classes/jogamp/opengl/glu/error/Error.java | 16 +- .../opengl/glu/gl2/nurbs/GL2CurveEvaluator.java | 2 +- .../opengl/glu/gl2/nurbs/GLUgl2nurbsImpl.java | 38 +- .../jogamp/opengl/glu/mipmap/BuildMipmap.java | 198 +++--- .../classes/jogamp/opengl/glu/mipmap/Extract.java | 8 +- .../jogamp/opengl/glu/mipmap/Extract1010102.java | 24 +- .../jogamp/opengl/glu/mipmap/Extract1555rev.java | 24 +- .../opengl/glu/mipmap/Extract2101010rev.java | 24 +- .../jogamp/opengl/glu/mipmap/Extract233rev.java | 18 +- .../jogamp/opengl/glu/mipmap/Extract332.java | 18 +- .../jogamp/opengl/glu/mipmap/Extract4444.java | 24 +- .../jogamp/opengl/glu/mipmap/Extract4444rev.java | 24 +- .../jogamp/opengl/glu/mipmap/Extract5551.java | 24 +- .../jogamp/opengl/glu/mipmap/Extract565.java | 24 +- .../jogamp/opengl/glu/mipmap/Extract565rev.java | 24 +- .../jogamp/opengl/glu/mipmap/Extract8888.java | 24 +- .../jogamp/opengl/glu/mipmap/Extract8888rev.java | 24 +- .../jogamp/opengl/glu/mipmap/ExtractFloat.java | 14 +- .../jogamp/opengl/glu/mipmap/ExtractPrimitive.java | 8 +- .../jogamp/opengl/glu/mipmap/ExtractSByte.java | 14 +- .../jogamp/opengl/glu/mipmap/ExtractSInt.java | 14 +- .../jogamp/opengl/glu/mipmap/ExtractSShort.java | 14 +- .../jogamp/opengl/glu/mipmap/ExtractUByte.java | 14 +- .../jogamp/opengl/glu/mipmap/ExtractUInt.java | 14 +- .../jogamp/opengl/glu/mipmap/ExtractUShort.java | 14 +- .../jogamp/opengl/glu/mipmap/HalveImage.java | 276 ++++---- .../classes/jogamp/opengl/glu/mipmap/Image.java | 120 ++-- .../classes/jogamp/opengl/glu/mipmap/Mipmap.java | 200 +++--- .../opengl/glu/mipmap/PixelStorageModes.java | 14 +- .../jogamp/opengl/glu/mipmap/ScaleInternal.java | 364 +++++----- .../jogamp/opengl/glu/mipmap/Type_Widget.java | 80 +-- src/jogl/classes/jogamp/opengl/glu/nurbs/Arc.java | 18 +- .../jogamp/opengl/glu/nurbs/ArcSdirSorter.java | 2 +- .../jogamp/opengl/glu/nurbs/ArcTdirSorter.java | 2 +- .../classes/jogamp/opengl/glu/nurbs/Backend.java | 2 +- src/jogl/classes/jogamp/opengl/glu/nurbs/Bin.java | 2 +- .../classes/jogamp/opengl/glu/nurbs/Breakpt.java | 4 +- .../jogamp/opengl/glu/nurbs/CArrayOfArcs.java | 32 +- .../jogamp/opengl/glu/nurbs/CArrayOfBreakpts.java | 22 +- .../jogamp/opengl/glu/nurbs/CArrayOfFloats.java | 32 +- .../opengl/glu/nurbs/CArrayOfQuiltspecs.java | 28 +- .../classes/jogamp/opengl/glu/nurbs/Curve.java | 6 +- .../classes/jogamp/opengl/glu/nurbs/Flist.java | 6 +- .../classes/jogamp/opengl/glu/nurbs/Knotspec.java | 20 +- .../jogamp/opengl/glu/nurbs/Knotvector.java | 14 +- .../classes/jogamp/opengl/glu/nurbs/Mapdesc.java | 12 +- .../jogamp/opengl/glu/nurbs/O_nurbscurve.java | 2 +- .../classes/jogamp/opengl/glu/nurbs/Patchlist.java | 2 +- .../classes/jogamp/opengl/glu/nurbs/Property.java | 6 +- .../jogamp/opengl/glu/nurbs/Renderhints.java | 2 +- .../jogamp/opengl/glu/nurbs/Subdivider.java | 6 +- .../jogamp/opengl/glu/nurbs/TrimVertex.java | 4 +- .../jogamp/opengl/glu/registry/Registry.java | 14 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 144 ++-- .../opengl/macosx/cgl/MacOSXCGLDrawable.java | 10 +- .../macosx/cgl/MacOSXCGLDrawableFactory.java | 28 +- .../cgl/MacOSXCGLDynamicLibraryBundleInfo.java | 18 +- .../macosx/cgl/MacOSXCGLGraphicsConfiguration.java | 44 +- .../cgl/MacOSXCGLGraphicsConfigurationFactory.java | 18 +- .../macosx/cgl/MacOSXPbufferCGLDrawable.java | 4 +- .../MacOSXAWTCGLGraphicsConfigurationFactory.java | 12 +- .../classes/jogamp/opengl/util/GLArrayHandler.java | 24 +- .../jogamp/opengl/util/GLArrayHandlerFlat.java | 14 +- .../opengl/util/GLArrayHandlerInterleaved.java | 20 +- .../jogamp/opengl/util/GLDataArrayHandler.java | 10 +- .../jogamp/opengl/util/GLFixedArrayHandler.java | 16 +- .../opengl/util/GLFixedArrayHandlerFlat.java | 8 +- .../jogamp/opengl/util/GLVBOArrayHandler.java | 10 +- .../jogamp/opengl/util/av/EGLMediaPlayerImpl.java | 46 +- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 284 ++++---- .../jogamp/opengl/util/av/JavaSoundAudioSink.java | 70 +- .../jogamp/opengl/util/av/NullAudioSink.java | 54 +- .../jogamp/opengl/util/av/NullGLMediaPlayer.java | 44 +- .../av/impl/FFMPEGDynamicLibraryBundleInfo.java | 118 ++-- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 174 ++--- .../jogamp/opengl/util/av/impl/FFMPEGNatives.java | 92 +-- .../opengl/util/av/impl/FFMPEGStaticNatives.java | 10 +- .../opengl/util/av/impl/FFMPEGv08Natives.java | 10 +- .../opengl/util/av/impl/FFMPEGv09Natives.java | 10 +- .../opengl/util/av/impl/FFMPEGv10Natives.java | 10 +- .../opengl/util/av/impl/OMXGLMediaPlayer.java | 48 +- .../jogamp/opengl/util/glsl/GLSLArrayHandler.java | 24 +- .../opengl/util/glsl/GLSLArrayHandlerFlat.java | 10 +- .../util/glsl/GLSLArrayHandlerInterleaved.java | 18 +- .../jogamp/opengl/util/glsl/GLSLTextureRaster.java | 70 +- .../opengl/util/glsl/fixedfunc/FixedFuncHook.java | 60 +- .../util/glsl/fixedfunc/FixedFuncPipeline.java | 236 +++---- .../jogamp/opengl/util/jpeg/JPEGDecoder.java | 132 ++-- .../jogamp/opengl/util/pngj/FilterType.java | 2 +- .../classes/jogamp/opengl/util/pngj/ImageInfo.java | 2 +- .../classes/jogamp/opengl/util/pngj/ImageLine.java | 30 +- .../jogamp/opengl/util/pngj/ImageLineHelper.java | 8 +- .../jogamp/opengl/util/pngj/ImageLines.java | 8 +- .../jogamp/opengl/util/pngj/PngHelperInternal.java | 2 +- .../classes/jogamp/opengl/util/pngj/PngReader.java | 56 +- .../classes/jogamp/opengl/util/pngj/PngWriter.java | 28 +- .../jogamp/opengl/util/pngj/PngjException.java | 4 +- .../opengl/util/pngj/PngjExceptionInternal.java | 4 +- .../opengl/util/pngj/chunks/ChunkHelper.java | 14 +- .../util/pngj/chunks/ChunkLoadBehaviour.java | 2 +- .../opengl/util/pngj/chunks/ChunkPredicate.java | 2 +- .../jogamp/opengl/util/pngj/chunks/ChunksList.java | 12 +- .../util/pngj/chunks/ChunksListForWrite.java | 6 +- .../jogamp/opengl/util/pngj/chunks/PngChunk.java | 2 +- .../opengl/util/pngj/chunks/PngChunkBKGD.java | 6 +- .../opengl/util/pngj/chunks/PngChunkMultiple.java | 4 +- .../opengl/util/pngj/chunks/PngChunkSBIT.java | 2 +- .../opengl/util/pngj/chunks/PngChunkTRNS.java | 2 +- .../opengl/util/pngj/chunks/PngMetadata.java | 10 +- .../opengl/windows/wgl/WGLGLCapabilities.java | 8 +- .../classes/jogamp/opengl/windows/wgl/WGLUtil.java | 22 +- .../windows/wgl/WindowsBitmapWGLDrawable.java | 4 +- .../windows/wgl/WindowsExternalWGLContext.java | 2 +- .../windows/wgl/WindowsPbufferWGLDrawable.java | 6 +- .../opengl/windows/wgl/WindowsWGLContext.java | 10 +- .../opengl/windows/wgl/WindowsWGLDrawable.java | 8 +- .../windows/wgl/WindowsWGLDrawableFactory.java | 30 +- .../wgl/WindowsWGLDynamicLibraryBundleInfo.java | 14 +- .../wgl/WindowsWGLGraphicsConfiguration.java | 72 +- .../WindowsWGLGraphicsConfigurationFactory.java | 42 +- .../WindowsAWTWGLGraphicsConfigurationFactory.java | 22 +- .../classes/jogamp/opengl/x11/glx/GLXUtil.java | 44 +- .../opengl/x11/glx/X11ExternalGLXContext.java | 6 +- .../opengl/x11/glx/X11ExternalGLXDrawable.java | 2 +- .../jogamp/opengl/x11/glx/X11GLXContext.java | 18 +- .../opengl/x11/glx/X11GLXDrawableFactory.java | 30 +- .../x11/glx/X11GLXDynamicLibraryBundleInfo.java | 22 +- .../x11/glx/X11GLXGraphicsConfiguration.java | 60 +- .../glx/X11GLXGraphicsConfigurationFactory.java | 46 +- .../DelegatedUpstreamSurfaceHookMutableSize.java | 6 +- ...elegatedUpstreamSurfaceHookWithSurfaceSize.java | 8 +- .../nativewindow/MutableGraphicsConfiguration.java | 4 +- .../jogamp/nativewindow/NativeWindowVersion.java | 10 +- .../UpstreamSurfaceHookMutableSize.java | 10 +- .../nativewindow/awt/AWTGraphicsConfiguration.java | 26 +- .../jogamp/nativewindow/awt/AWTGraphicsDevice.java | 14 +- .../jogamp/nativewindow/awt/AWTGraphicsScreen.java | 14 +- .../jogamp/nativewindow/awt/AWTPrintLifecycle.java | 26 +- .../nativewindow/awt/AWTWindowClosingProtocol.java | 2 +- .../nativewindow/awt/DirectDataBufferInt.java | 62 +- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 52 +- .../jogamp/nativewindow/egl/EGLGraphicsDevice.java | 30 +- .../nativewindow/macosx/MacOSXGraphicsDevice.java | 10 +- .../com/jogamp/nativewindow/swt/SWTAccessor.java | 164 ++--- .../windows/WindowsGraphicsDevice.java | 12 +- .../nativewindow/x11/X11GraphicsConfiguration.java | 16 +- .../jogamp/nativewindow/x11/X11GraphicsDevice.java | 30 +- .../jogamp/nativewindow/x11/X11GraphicsScreen.java | 12 +- .../AbstractGraphicsConfiguration.java | 16 +- .../media/nativewindow/AbstractGraphicsDevice.java | 46 +- .../media/nativewindow/AbstractGraphicsScreen.java | 16 +- .../javax/media/nativewindow/Capabilities.java | 46 +- .../media/nativewindow/CapabilitiesChooser.java | 16 +- .../media/nativewindow/CapabilitiesImmutable.java | 8 +- .../nativewindow/DefaultCapabilitiesChooser.java | 24 +- .../nativewindow/DefaultGraphicsConfiguration.java | 18 +- .../media/nativewindow/DefaultGraphicsDevice.java | 34 +- .../media/nativewindow/DefaultGraphicsScreen.java | 12 +- .../nativewindow/GraphicsConfigurationFactory.java | 84 +-- .../javax/media/nativewindow/MutableSurface.java | 4 +- .../javax/media/nativewindow/NativeSurface.java | 40 +- .../media/nativewindow/NativeWindowException.java | 14 +- .../media/nativewindow/NativeWindowFactory.java | 134 ++-- .../media/nativewindow/OffscreenLayerOption.java | 12 +- .../media/nativewindow/OffscreenLayerSurface.java | 22 +- .../javax/media/nativewindow/ProxySurface.java | 60 +- .../media/nativewindow/SurfaceUpdatedListener.java | 12 +- .../javax/media/nativewindow/ToolkitLock.java | 14 +- .../media/nativewindow/UpstreamSurfaceHook.java | 18 +- .../javax/media/nativewindow/VisualIDHolder.java | 36 +- .../media/nativewindow/WindowClosingProtocol.java | 4 +- .../javax/media/nativewindow/util/Dimension.java | 18 +- .../nativewindow/util/DimensionImmutable.java | 4 +- .../javax/media/nativewindow/util/Insets.java | 18 +- .../media/nativewindow/util/InsetsImmutable.java | 4 +- .../javax/media/nativewindow/util/Point.java | 8 +- .../media/nativewindow/util/PointImmutable.java | 6 +- .../javax/media/nativewindow/util/Rectangle.java | 28 +- .../nativewindow/util/RectangleImmutable.java | 10 +- .../javax/media/nativewindow/util/SurfaceSize.java | 18 +- .../classes/jogamp/nativewindow/Debug.java | 16 +- .../DefaultGraphicsConfigurationFactoryImpl.java | 10 +- .../jogamp/nativewindow/GlobalToolkitLock.java | 14 +- .../jogamp/nativewindow/NWJNILibLoader.java | 12 +- .../nativewindow/NativeWindowFactoryImpl.java | 16 +- .../jogamp/nativewindow/NullToolkitLock.java | 10 +- .../jogamp/nativewindow/ProxySurfaceImpl.java | 42 +- .../jogamp/nativewindow/ResourceToolkitLock.java | 8 +- .../nativewindow/SharedResourceToolkitLock.java | 18 +- .../jogamp/nativewindow/SurfaceUpdatedHelper.java | 22 +- .../jogamp/nativewindow/ToolkitProperties.java | 20 +- .../jogamp/nativewindow/WrappedSurface.java | 10 +- .../classes/jogamp/nativewindow/awt/AWTMisc.java | 20 +- .../jogamp/nativewindow/jawt/JAWTJNILibLoader.java | 24 +- .../classes/jogamp/nativewindow/jawt/JAWTUtil.java | 112 +-- .../nativewindow/jawt/JAWT_PlatformInfo.java | 14 +- .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 82 +-- .../jawt/windows/Win32SunJDKReflection.java | 14 +- .../jawt/windows/WindowsJAWTWindow.java | 16 +- .../nativewindow/jawt/x11/X11JAWTWindow.java | 18 +- .../nativewindow/jawt/x11/X11SunJDKReflection.java | 14 +- .../macosx/OSXDummyUpstreamSurfaceHook.java | 14 +- .../jogamp/nativewindow/macosx/OSXUtil.java | 94 +-- .../windows/GDIDummyUpstreamSurfaceHook.java | 18 +- .../jogamp/nativewindow/windows/GDISurface.java | 14 +- .../jogamp/nativewindow/windows/GDIUtil.java | 36 +- .../nativewindow/windows/RegisteredClass.java | 2 +- .../windows/RegisteredClassFactory.java | 16 +- .../x11/X11DummyUpstreamSurfaceHook.java | 14 +- .../x11/X11GraphicsConfigurationFactory.java | 16 +- .../classes/jogamp/nativewindow/x11/X11Util.java | 94 +-- .../awt/X11AWTGraphicsConfigurationFactory.java | 36 +- src/newt/classes/com/jogamp/newt/Display.java | 32 +- .../classes/com/jogamp/newt/MonitorDevice.java | 46 +- src/newt/classes/com/jogamp/newt/MonitorMode.java | 84 +-- src/newt/classes/com/jogamp/newt/NewtFactory.java | 24 +- src/newt/classes/com/jogamp/newt/NewtVersion.java | 10 +- src/newt/classes/com/jogamp/newt/Screen.java | 34 +- src/newt/classes/com/jogamp/newt/Window.java | 32 +- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 158 ++--- .../jogamp/newt/awt/applet/JOGLNewtApplet1Run.java | 24 +- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 22 +- .../jogamp/newt/event/DoubleTapScrollGesture.java | 66 +- .../com/jogamp/newt/event/GestureHandler.java | 60 +- .../classes/com/jogamp/newt/event/InputEvent.java | 56 +- .../classes/com/jogamp/newt/event/KeyAdapter.java | 10 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 256 +++---- .../classes/com/jogamp/newt/event/KeyListener.java | 22 +- .../com/jogamp/newt/event/MonitorEvent.java | 12 +- .../com/jogamp/newt/event/MouseAdapter.java | 10 +- .../classes/com/jogamp/newt/event/MouseEvent.java | 164 ++--- .../com/jogamp/newt/event/MouseListener.java | 20 +- .../classes/com/jogamp/newt/event/NEWTEvent.java | 30 +- .../com/jogamp/newt/event/NEWTEventConsumer.java | 14 +- .../com/jogamp/newt/event/NEWTEventFiFo.java | 10 +- .../com/jogamp/newt/event/NEWTEventListener.java | 12 +- .../classes/com/jogamp/newt/event/OutputEvent.java | 2 +- .../com/jogamp/newt/event/PinchToZoomGesture.java | 48 +- .../com/jogamp/newt/event/TraceKeyAdapter.java | 10 +- .../com/jogamp/newt/event/TraceMouseAdapter.java | 10 +- .../com/jogamp/newt/event/TraceWindowAdapter.java | 10 +- .../com/jogamp/newt/event/WindowAdapter.java | 10 +- .../classes/com/jogamp/newt/event/WindowEvent.java | 16 +- .../com/jogamp/newt/event/WindowListener.java | 18 +- .../com/jogamp/newt/event/WindowUpdateEvent.java | 10 +- .../com/jogamp/newt/event/awt/AWTAdapter.java | 36 +- .../com/jogamp/newt/event/awt/AWTKeyAdapter.java | 12 +- .../com/jogamp/newt/event/awt/AWTMouseAdapter.java | 12 +- .../jogamp/newt/event/awt/AWTWindowAdapter.java | 24 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 38 +- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 130 ++-- src/newt/classes/com/jogamp/newt/util/EDTUtil.java | 30 +- .../classes/com/jogamp/newt/util/MainThread.java | 90 +-- .../com/jogamp/newt/util/MonitorModeUtil.java | 18 +- src/newt/classes/jogamp/newt/Debug.java | 18 +- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 36 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 66 +- .../classes/jogamp/newt/MonitorDeviceImpl.java | 28 +- src/newt/classes/jogamp/newt/MonitorModeProps.java | 44 +- src/newt/classes/jogamp/newt/NEWTJNILibLoader.java | 16 +- src/newt/classes/jogamp/newt/OffscreenWindow.java | 28 +- src/newt/classes/jogamp/newt/ScreenImpl.java | 98 +-- .../classes/jogamp/newt/ScreenMonitorState.java | 18 +- src/newt/classes/jogamp/newt/WindowImpl.java | 554 +++++++-------- .../classes/jogamp/newt/awt/NewtFactoryAWT.java | 16 +- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 74 +- .../newt/awt/event/AWTParentWindowAdapter.java | 20 +- .../jogamp/newt/driver/DriverClearFocus.java | 6 +- .../jogamp/newt/driver/DriverUpdatePosition.java | 8 +- .../classes/jogamp/newt/driver/awt/AWTCanvas.java | 40 +- .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 32 +- .../jogamp/newt/driver/awt/DisplayDriver.java | 16 +- .../jogamp/newt/driver/awt/ScreenDriver.java | 28 +- .../jogamp/newt/driver/awt/WindowDriver.java | 50 +- .../jogamp/newt/driver/bcm/egl/DisplayDriver.java | 12 +- .../jogamp/newt/driver/bcm/egl/ScreenDriver.java | 20 +- .../jogamp/newt/driver/bcm/egl/WindowDriver.java | 22 +- .../newt/driver/bcm/vc/iv/DisplayDriver.java | 10 +- .../jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java | 22 +- .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 30 +- .../newt/driver/intel/gdl/DisplayDriver.java | 12 +- .../jogamp/newt/driver/intel/gdl/ScreenDriver.java | 22 +- .../jogamp/newt/driver/intel/gdl/WindowDriver.java | 18 +- .../jogamp/newt/driver/kd/DisplayDriver.java | 12 +- .../jogamp/newt/driver/kd/ScreenDriver.java | 26 +- .../jogamp/newt/driver/kd/WindowDriver.java | 22 +- .../newt/driver/linux/LinuxEventDeviceTracker.java | 16 +- .../newt/driver/linux/LinuxMouseTracker.java | 46 +- .../jogamp/newt/driver/macosx/DisplayDriver.java | 18 +- .../jogamp/newt/driver/macosx/MacKeyUtil.java | 38 +- .../jogamp/newt/driver/macosx/ScreenDriver.java | 32 +- .../jogamp/newt/driver/macosx/WindowDriver.java | 126 ++-- .../jogamp/newt/driver/windows/DisplayDriver.java | 18 +- .../jogamp/newt/driver/windows/ScreenDriver.java | 28 +- .../jogamp/newt/driver/windows/WindowDriver.java | 90 +-- .../jogamp/newt/driver/x11/DisplayDriver.java | 28 +- src/newt/classes/jogamp/newt/driver/x11/RandR.java | 22 +- .../classes/jogamp/newt/driver/x11/RandR11.java | 66 +- .../classes/jogamp/newt/driver/x11/RandR13.java | 60 +- .../jogamp/newt/driver/x11/ScreenDriver.java | 68 +- .../jogamp/newt/driver/x11/WindowDriver.java | 92 +-- .../classes/jogamp/newt/event/NEWTEventTask.java | 10 +- src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java | 46 +- .../jogamp/newt/swt/event/SWTNewtEventFactory.java | 48 +- 643 files changed, 12269 insertions(+), 12269 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/Audio.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/Audio.java index 2b51be164..83f5e4ebd 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/Audio.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/Audio.java @@ -1,21 +1,21 @@ /* * 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 diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java index 60972873e..0a502c123 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java @@ -1,21 +1,21 @@ /* * 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 @@ -344,7 +344,7 @@ public class Mixer { e.printStackTrace(); } } - + if (directByteBufferConstructor != null) { try { return (ByteBuffer) diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java index c45430d23..01346553c 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java @@ -1,21 +1,21 @@ /* * 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 diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/Track.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/Track.java index b57bf1dc6..98a787478 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/Track.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/Track.java @@ -1,21 +1,21 @@ /* * 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 @@ -151,7 +151,7 @@ public class Track { // These are only for use by the Mixer private float leftGain; private float rightGain; - + void setLeftGain(float leftGain) { this.leftGain = leftGain; } diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/Vec3f.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/Vec3f.java index 1afdaf081..0726e5762 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/Vec3f.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/Vec3f.java @@ -1,21 +1,21 @@ /* * 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 diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index b04f35230..8429fbcfd 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -67,7 +67,7 @@ public class BuildComposablePipeline { * By extra command-line argument: prolog_xor_downstream. *

    * If true, either prolog (if exist) is called or downstream's method, but not both. - * By default, both methods would be called. + * By default, both methods would be called. *

    *

    Default: false

    */ @@ -81,7 +81,7 @@ public class BuildComposablePipeline { *

    Default: false

    */ public static final int GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS = 1 << 4; - + int mode; private String outputDir; private String outputPackage; diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java index 5298cc357..a5a26d18f 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -68,7 +68,7 @@ import java.util.regex.Pattern; *
    * *
    -   * 
    +   *
        * #ifndef GL_XXXX
        * GLAPI   glFuncName()
        * #endif GL_XXXX
    @@ -78,7 +78,7 @@ import java.util.regex.Pattern;
        * For example, if it parses the following data:
        *
        * 
    -   * 
    +   *
        * #ifndef GL_VERSION_1_3
        * GLAPI void APIENTRY glActiveTexture (GLenum);
        * GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *);
    @@ -89,7 +89,7 @@ import java.util.regex.Pattern;
        * GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
        * GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
        * #endif
    -   * 
    +   *
        * 
    * * It will associate @@ -105,7 +105,7 @@ import java.util.regex.Pattern; * */ public class BuildStaticGLInfo { - // Handles function pointer + // Handles function pointer protected static final int funcIdentifierGroup = 9; protected static Pattern funcPattern = Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)((unsigned|const)\\s+)?(\\w+)(\\s+\\*\\s*|\\s*\\*\\s+|\\s+)?(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)"); @@ -119,7 +119,7 @@ public class BuildStaticGLInfo { Pattern.compile("\\#(elif|else)(.*)"); protected static Pattern endifPattern = Pattern.compile("\\#endif(.*)"); - + protected static final int defineIdentifierGroup = 1; protected static Pattern definePattern = Pattern.compile("\\#define ([CEW]?GL[XU]?_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)(.*)"); @@ -203,7 +203,7 @@ public class BuildStaticGLInfo { Matcher m = null; int block = 0; while ((line = reader.readLine()) != null) { - int type = 0; // 1-define, 2-function + int type = 0; // 1-define, 2-function if ( 0 < block ) { // inside a #ifndef GL_XXX block and matching a function, if block > 0 String identifier = null; if( 2 >= block ) { // not within sub-blocks > 2, i.e. further typedefs @@ -216,9 +216,9 @@ public class BuildStaticGLInfo { } } if ( identifier != null && - activeAssociation != null && - !identifier.equals(activeAssociation) // Handles #ifndef GL_... #define GL_... - ) + activeAssociation != null && + !identifier.equals(activeAssociation) // Handles #ifndef GL_... #define GL_... + ) { addAssociation(identifier, activeAssociation); if (DEBUG) { @@ -243,7 +243,7 @@ public class BuildStaticGLInfo { if (DEBUG) { System.err.println("<"+block+"> END ASSOCIATION BLOCK: <" + activeAssociation + " <-> " + comment + ">"); } - activeAssociation = null; + activeAssociation = null; } else { if (DEBUG) { System.err.println("<"+block+"> END IF BLOCK: <" + comment + ">"); @@ -251,7 +251,7 @@ public class BuildStaticGLInfo { } } } - } else if ((m = associationPattern.matcher(line)).matches()) { + } else if ((m = associationPattern.matcher(line)).matches()) { // found a new #ifndef GL_XXX block activeAssociation = m.group(1).trim(); block++; @@ -387,7 +387,7 @@ public class BuildStaticGLInfo { declarationToExtensionMap.put(identifier, extensions); } extensions.add(association); - + Set identifiers = extensionToDeclarationMap.get(association); if (identifiers == null) { identifiers = new HashSet(); diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java index a00b19abc..f1a32fa9c 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -241,7 +241,7 @@ public class GLConfiguration extends ProcAddressConfiguration { } } if( ignoredExtension ) { - ignoredExtension = !shouldForceExtension( symbol, true, symbol ); + ignoredExtension = !shouldForceExtension( symbol, true, symbol ); if( ignoredExtension ) { final Set origSymbols = getRenamedJavaSymbols( symbol ); if(null != origSymbols) { @@ -251,7 +251,7 @@ public class GLConfiguration extends ProcAddressConfiguration { break; } } - } + } } } if( ignoredExtension ) { @@ -274,7 +274,7 @@ public class GLConfiguration extends ProcAddressConfiguration { } return false; } - + public boolean shouldForceExtension(final String symbol, final boolean criteria, final String renamedSymbol) { if (criteria && glInfo != null) { final Set extensionNames = glInfo.getExtension(symbol); @@ -292,7 +292,7 @@ public class GLConfiguration extends ProcAddressConfiguration { } return true; } - } + } } } return false; @@ -343,9 +343,9 @@ public class GLConfiguration extends ProcAddressConfiguration { public boolean isBufferObjectFunction(String name) { return (getBufferObjectKind(name) != null); } - - public boolean isBufferObjectOnly(String name) { - return bufferObjectOnly.contains(name); + + public boolean isBufferObjectOnly(String name) { + return bufferObjectOnly.contains(name); } /** Parses any GL headers specified in the configuration file for diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java index fa95049cc..1af632682 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -125,7 +125,7 @@ public class GLEmitter extends ProcAddressEmitter { } if(JavaConfiguration.DEBUG_RENAMES) { System.err.println("RenameExtensionIntoCore: "+extension+" END>"); - } + } } } @@ -279,7 +279,7 @@ public class GLEmitter extends ProcAddressEmitter { int j=0; while( j < bindings.size() ) { final MethodBinding cur = bindings.get(j); - + // Some of these routines (glBitmap) take strongly-typed // primitive pointers as arguments which are expanded into // non-void* arguments @@ -306,7 +306,7 @@ public class GLEmitter extends ProcAddressEmitter { // Now need to flag this MethodBinding so that we generate the // correct flags in the emitters later bufferObjectMethodBindings.put(result, result); - + if( bufferObjectOnly ) { bindings.remove(j); } else { @@ -397,7 +397,7 @@ public class GLEmitter extends ProcAddressEmitter { } private int addExtensionListOfAliasedSymbols2Buffer(BuildStaticGLInfo glInfo, StringBuilder buf, String sep1, String sep2, String name, Collection exclude) { int num = 0; - if(null != name) { + if(null != name) { num += addExtensionListOfSymbol2Buffer(glInfo, buf, sep1, name); // extensions of given name boolean needsSep2 = 0 origNames = cfg.getRenamedJavaSymbols(name); @@ -406,7 +406,7 @@ public class GLEmitter extends ProcAddressEmitter { if(!exclude.contains(origName)) { if (needsSep2) { buf.append(sep2); // diff-name seperator - } + } int num2 = addExtensionListOfSymbol2Buffer(glInfo, buf, sep1, origName); // extensions of orig-name needsSep2 = num col) { BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); if (null == glInfo) { @@ -469,16 +469,16 @@ public class GLEmitter extends ProcAddressEmitter { /** * {@inheritDoc} - */ + */ @Override protected void endProcAddressTable() throws Exception { PrintWriter w = tableWriter; - + w.println(" @Override"); w.println(" protected boolean isFunctionAvailableImpl(String functionNameUsr) throws IllegalArgumentException {"); w.println(" final String functionNameBase = "+GLNameResolver.class.getName()+".normalizeVEN(com.jogamp.gluegen.runtime.opengl.GLNameResolver.normalizeARB(functionNameUsr, true), true);"); w.println(" final String addressFieldNameBase = \"" + PROCADDRESS_VAR_PREFIX + "\" + functionNameBase;"); - w.println(" final int funcNamePermNum = "+GLNameResolver.class.getName()+".getFuncNamePermutationNumber(functionNameBase);"); + w.println(" final int funcNamePermNum = "+GLNameResolver.class.getName()+".getFuncNamePermutationNumber(functionNameBase);"); w.println(" final java.lang.reflect.Field addressField = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {"); w.println(" public final java.lang.reflect.Field run() {"); w.println(" java.lang.reflect.Field addressField = null;"); @@ -510,7 +510,7 @@ public class GLEmitter extends ProcAddressEmitter { w.println(" \"function\", e);"); w.println(" }"); w.println(" }"); - + w.println(" @Override"); w.println(" public long getAddressFor(String functionNameUsr) throws SecurityException, IllegalArgumentException {"); w.println(" SecurityUtil.checkAllLinkPermission();"); diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java index fdfaee8a6..389d35f99 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -111,7 +111,7 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit writer.print(" "); writer.print(funcSym.getType().toString(symbolRenamed, tagNativeBinding)); writer.print(" "); - + newComment.append("
    Part of "); if (0 == glEmitter.addExtensionsOfSymbols2Buffer(newComment, ", ", "; ", symbolRenamed, binding.getAliasedNames())) { if (glEmitter.getGLConfig().getAllowNonGLExtensions()) { diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java b/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java index e3e7cb970..b98f17117 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java @@ -55,13 +55,13 @@ import org.apache.tools.ant.util.JavaEnvUtils; /** *

    An ANT {@link org.apache.tools.ant.Task} * for using {@link com.jogamp.gluegen.opengl.BuildStaticGLInfo}.

    - * + * *

    Usage:

    *
    -    <staticglgen package="[generated files package]" 
    +    <staticglgen package="[generated files package]"
                         headers="[file pattern of GL headers]"
                         outputdir="[directory to output the generated files]" />
    - * 
    + *
    * * @author Rob Grzywinski rgrzywinski@yahoo.com */ @@ -72,7 +72,7 @@ public class StaticGLGenTask extends Task *

    The {@link com.jogamp.gluegen.opengl.BuildStaticGLInfo} classname.

    */ private static final String GL_GEN = "com.jogamp.gluegen.opengl.BuildStaticGLInfo"; - + // ========================================================================= /** *

    The {@link org.apache.tools.ant.types.CommandlineJava} that is used @@ -90,12 +90,12 @@ public class StaticGLGenTask extends Task *

    The output directory.

    */ private String outputDirectory; - + /** *

    The {@link org.apache.tools.ant.types.FileSet} of GL headers.

    */ private FileSet headerSet = new FileSet(); - + // ========================================================================= /** *

    Create and add the VM and classname to {@link org.apache.tools.ant.types.CommandlineJava}.

    @@ -104,7 +104,7 @@ public class StaticGLGenTask extends Task { // create the CommandlineJava that will be used to call BuildStaticGLInfo glgenCommandline = new CommandlineJava(); - + // set the VM and classname in the commandline glgenCommandline.setVm(JavaEnvUtils.getJreExecutable("java")); glgenCommandline.setClassname(GL_GEN); @@ -114,7 +114,7 @@ public class StaticGLGenTask extends Task // ANT getters and setters /** *

    Set the package name for the generated files. This is called by ANT.

    - * + * * @param packageName the name of the package for the generated files */ public void setPackage(String packageName) @@ -125,12 +125,12 @@ public class StaticGLGenTask extends Task /** *

    Set the output directory. This is called by ANT.

    - * + * * @param directory the output directory */ public void setOutputDir(String directory) { - log( ("Setting output directory to: " + directory), + log( ("Setting output directory to: " + directory), Project.MSG_VERBOSE); this.outputDirectory = directory; } @@ -138,7 +138,7 @@ public class StaticGLGenTask extends Task /** *

    Add a header file to the list. This is called by ANT for a nested * element.

    - * + * * @return {@link org.apache.tools.ant.types.PatternSet.NameEntry} */ public PatternSet.NameEntry createHeader() @@ -149,7 +149,7 @@ public class StaticGLGenTask extends Task /** *

    Add a header file to the list. This is called by ANT for a nested * element.

    - * + * * @return {@link org.apache.tools.ant.types.PatternSet.NameEntry} */ public PatternSet.NameEntry createHeadersFile() @@ -171,7 +171,7 @@ public class StaticGLGenTask extends Task /** *

    Add an optional classpath that defines the location of {@link com.jogamp.gluegen.opengl.BuildStaticGLInfo} * and BuildStaticGLInfo's dependencies.

    - * + * * @returns {@link org.apache.tools.ant.types.Path} */ public Path createClasspath() @@ -183,23 +183,23 @@ public class StaticGLGenTask extends Task /** *

    Run the task. This involves validating the set attributes, creating * the command line to be executed and finally executing the command.

    - * + * * @see org.apache.tools.ant.Task#execute() */ - public void execute() - throws BuildException + public void execute() + throws BuildException { // validate that all of the required attributes have been set validateAttributes(); - + // TODO: add logic to determine if the generated file needs to be // regenerated - + // add the attributes to the CommandlineJava addAttributes(); log(glgenCommandline.describeCommand(), Project.MSG_VERBOSE); - + // execute the command and throw on error final int error = execute(glgenCommandline.getCommandline()); if(error == 1) @@ -208,11 +208,11 @@ public class StaticGLGenTask extends Task /** *

    Ensure that the user specified all required arguments.

    - * - * @throws BuildException if there are required arguments that are not + * + * @throws BuildException if there are required arguments that are not * present or not valid */ - private void validateAttributes() + private void validateAttributes() throws BuildException { // validate that the package name is set @@ -223,29 +223,29 @@ public class StaticGLGenTask extends Task // TODO: switch to file and ensure that it exists if(!isValid(outputDirectory)) throw new BuildException("Invalid output directory name: " + outputDirectory); - + // TODO: validate that there are headers set } /** *

    Is the specified string valid? A valid string is non-null * and has a non-zero length.

    - * + * * @param string the string to be tested for validity * @return true if the string is valid. false - * otherwise. + * otherwise. */ private boolean isValid(String string) { // check for null if(string == null) return false; - + // ensure that the string has a non-zero length // NOTE: must trim() to remove leading and trailing whitespace if(string.trim().length() < 1) return false; - + // the string is valid return true; } @@ -258,10 +258,10 @@ public class StaticGLGenTask extends Task { // add the package name glgenCommandline.createArgument().setValue(packageName); - + // add the output directory name glgenCommandline.createArgument().setValue(outputDirectory); - + // add the header -files- from the FileSet headerSet.setDir(getProject().getBaseDir()); DirectoryScanner directoryScanner = headerSet.getDirectoryScanner(getProject()); @@ -272,25 +272,25 @@ public class StaticGLGenTask extends Task } } - /** - *

    Execute {@link com.jogamp.gluegen.opengl.BuildStaticGLInfo} in a + /** + *

    Execute {@link com.jogamp.gluegen.opengl.BuildStaticGLInfo} in a * forked JVM.

    - * + * * @throws BuildException */ - private int execute(String[] command) + private int execute(String[] command) throws BuildException { // create the object that will perform the command execution Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, - Project.MSG_WARN), + Project.MSG_WARN), null); - + // set the project and command line execute.setAntRun(project); execute.setCommandline(command); execute.setWorkingDirectory( project.getBaseDir() ); - + // execute the command try { diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java index adb1c2ae0..4ac9ae3f3 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -55,8 +55,8 @@ import java.util.Set; /** * Emitter producing NativeSignature attributes. - * - * Review: This Package/Class is not used and subject to be deleted. + * + * Review: This Package/Class is not used and subject to be deleted. */ public class NativeSignatureEmitter extends GLEmitter { diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java index e98478b6e..a17657382 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -182,14 +182,14 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding // Always emit outgoing "this" argument writer.print("long "); - writer.print(javaThisArgumentName()); + writer.print(javaThisArgumentName()); ++numEmitted; needComma = true; } for (int i = 0; i < binding.getNumArguments(); i++) { JavaType type = binding.getJavaArgumentType(i); - if (type.isVoid()) { + if (type.isVoid()) { // Make sure this is the only param to the method; if it isn't, // there's something wrong with our parsing of the headers. if (binding.getNumArguments() != 1) { @@ -198,7 +198,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding "multi-argument function \"" + binding + "\""); } continue; - } + } if (type.isJNIEnv() || binding.isArgumentThisPointer(i)) { // Don't need to expose these at the Java level @@ -229,7 +229,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding if (type.isNIOBuffer()) { writer.print(", int " + byteOffsetArgName(i)); } else if (type.isNIOBufferArray()) { - writer.print(", int[] " + + writer.print(", int[] " + byteOffsetArrayArgName(i)); } } @@ -246,7 +246,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding writer.print(" "); JavaType returnType = binding.getJavaReturnType(); boolean needsResultAssignment = false; - + if (!returnType.isVoid()) { if (returnType.isCompoundTypeWrapper() || returnType.isNIOByteBuffer()) { @@ -375,7 +375,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding // there's something wrong with our parsing of the headers. assert(binding.getNumArguments() == 1); continue; - } + } if (needComma) { writer.print(", "); diff --git a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLNameResolver.java b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLNameResolver.java index 92554776a..9b57a2f2d 100644 --- a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLNameResolver.java +++ b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLNameResolver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * 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.gluegen.runtime.opengl; @@ -43,12 +43,12 @@ public class GLNameResolver { //GL_XYZ : GL_XYZ, GL_GL2_XYZ, GL_ARB_XYZ, GL_OES_XYZ, GL_OML_XYZ // // Pass-1 Unify ARB extensions with the same value - // Pass-2 Unify vendor extensions, + // Pass-2 Unify vendor extensions, // if exist as an ARB extension with the same value. // Pass-3 Emit public static final String[] extensionsARB = { "ARB", "GL2", "OES", "KHR", "OML" }; - public static final String[] extensionsVEN = { "3DFX", + public static final String[] extensionsVEN = { "3DFX", "AMD", "ANGLE", "ARM", @@ -158,7 +158,7 @@ public class GLNameResolver { return str; } public static final boolean isExtension(String str, boolean isGLFunc) { - return isExtension(extensionsARB, str, isGLFunc) || + return isExtension(extensionsARB, str, isGLFunc) || isExtension(extensionsVEN, str, isGLFunc); } diff --git a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java index 9775de491..f8406075c 100644 --- a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java +++ b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /* * Created on Saturday, April 24 2010 16:44 */ diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java index a3749788b..cb2885e0f 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java +++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java @@ -42,13 +42,13 @@ import com.jogamp.opengl.math.geom.AABBox; /** A Generic shape objects which is defined by a list of Outlines. * This Shape can be transformed to Triangulations. * The list of triangles generated are render-able by a Region object. - * The triangulation produced by this Shape will define the + * The triangulation produced by this Shape will define the * closed region defined by the outlines. - * + * * One or more OutlineShape Object can be associated to a region * this is left as a high-level representation of the Objects. For * optimizations, flexibility requirements for future features. - * + * *

    * Example to creating an Outline Shape: *
    @@ -60,18 +60,18 @@ import com.jogamp.opengl.math.geom.AABBox;
           addVertex(...)
           addVertex(...)
      * 
    - * - * The above will create two outlines each with three vertices. By adding these two outlines to + * + * The above will create two outlines each with three vertices. By adding these two outlines to * the OutlineShape, we are stating that the combination of the two outlines represent the shape. *
    - * - * To specify that the shape is curved at a region, the on-curve flag should be set to false + * + * To specify that the shape is curved at a region, the on-curve flag should be set to false * for the vertex that is in the middle of the curved region (if the curved region is defined by 3 * vertices (quadratic curve). *
    - * In case the curved region is defined by 4 or more vertices the middle vertices should both have + * In case the curved region is defined by 4 or more vertices the middle vertices should both have * the on-curve flag set to false. - * + * *
    Example:
    *
           addVertex(0,0, true);
    @@ -79,16 +79,16 @@ import com.jogamp.opengl.math.geom.AABBox;
           addVertex(1,1, false);
           addVertex(1,0, true);
      * 
    - * - * The above snippet defines a cubic nurbs curve where (0,1 and 1,1) + * + * The above snippet defines a cubic nurbs curve where (0,1 and 1,1) * do not belong to the final rendered shape. - * + * * Implementation Notes:
    *
      *
    • The first vertex of any outline belonging to the shape should be on-curve
    • *
    • Intersections between off-curved parts of the outline is not handled
    • *
    - * + * * @see Outline * @see Region */ @@ -104,21 +104,21 @@ public class OutlineShape implements Comparable { VerticesState(int state){ this.state = state; } - } + } public static final int DIRTY_BOUNDS = 1 << 0; private final Vertex.Factory vertexFactory; private VerticesState outlineState; - /** The list of {@link Outline}s that are part of this + /** The list of {@link Outline}s that are part of this * outline shape. */ private ArrayList outlines; private AABBox bbox; /** dirty bits DIRTY_BOUNDS */ - private int dirtyBits; + private int dirtyBits; /** Create a new Outline based Shape */ @@ -128,7 +128,7 @@ public class OutlineShape implements Comparable { this.outlines.add(new Outline()); this.outlineState = VerticesState.UNDEFINED; this.bbox = new AABBox(); - this.dirtyBits = 0; + this.dirtyBits = 0; } /** Clears all data and reset all states as if this instance was newly created */ @@ -137,7 +137,7 @@ public class OutlineShape implements Comparable { outlines.add(new Outline()); outlineState = VerticesState.UNDEFINED; bbox.reset(); - dirtyBits = 0; + dirtyBits = 0; } /** Returns the associated vertex factory of this outline shape @@ -149,10 +149,10 @@ public class OutlineShape implements Comparable { return outlines.size(); } - /** Add a new empty {@link Outline} + /** Add a new empty {@link Outline} * to the end of this shape's outline list. *

    If the {@link #getLastOutline()} is empty already, no new one will be added.

    - * + * * After a call to this function all new vertices added * will belong to the new outline */ @@ -164,26 +164,26 @@ public class OutlineShape implements Comparable { /** Appends the {@link Outline} element to the end, * ensuring a clean tail. - * + * *

    A clean tail is ensured, no double empty Outlines are produced * and a pre-existing empty outline will be replaced with the given one.

    - * + * * @param outline Outline object to be added - * @throws NullPointerException if the {@link Outline} element is null + * @throws NullPointerException if the {@link Outline} element is null */ public void addOutline(Outline outline) throws NullPointerException { addOutline(outlines.size(), outline); } /** Insert the {@link Outline} element at the given {@code position}. - * + * *

    If the {@code position} indicates the end of this list, * a clean tail is ensured, no double empty Outlines are produced * and a pre-existing empty outline will be replaced with the given one.

    - * + * * @param position of the added Outline * @param outline Outline object to be added - * @throws NullPointerException if the {@link Outline} element is null + * @throws NullPointerException if the {@link Outline} element is null * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getOutlineNumber()) */ public void addOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException { @@ -213,7 +213,7 @@ public class OutlineShape implements Comparable { * using {@link #addOutline(Outline)} for each element. *

    Closes the current last outline via {@link #closeLastOutline()} before adding the new ones.

    * @param outlineShape OutlineShape elements to be added. - * @throws NullPointerException if the {@link OutlineShape} is null + * @throws NullPointerException if the {@link OutlineShape} is null * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getOutlineNumber()) */ public void addOutlineShape(OutlineShape outlineShape) throws NullPointerException { @@ -228,10 +228,10 @@ public class OutlineShape implements Comparable { /** Replaces the {@link Outline} element at the given {@code position}. *

    Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it.

    - * + * * @param position of the replaced Outline - * @param outline replacement Outline object - * @throws NullPointerException if the {@link Outline} element is null + * @param outline replacement Outline object + * @throws NullPointerException if the {@link Outline} element is null * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber()) */ public void setOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException { @@ -244,7 +244,7 @@ public class OutlineShape implements Comparable { /** Removes the {@link Outline} element at the given {@code position}. *

    Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it.

    - * + * * @param position of the to be removed Outline * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber()) */ @@ -261,15 +261,15 @@ public class OutlineShape implements Comparable { return outlines.get(outlines.size()-1); } - /** @return the {@code Outline} at {@code position} + /** @return the {@code Outline} at {@code position} * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getOutlineNumber()) */ public Outline getOutline(int position) throws IndexOutOfBoundsException { return outlines.get(position); - } + } /** Adds a vertex to the last open outline in the - * shape. + * shape. * @param v the vertex to be added to the OutlineShape */ public final void addVertex(Vertex v) { @@ -280,9 +280,9 @@ public class OutlineShape implements Comparable { } } - /** Adds a vertex to the last open outline in the shape. - * at {@code position} - * @param position indx at which the vertex will be added + /** Adds a vertex to the last open outline in the shape. + * at {@code position} + * @param position indx at which the vertex will be added * @param v the vertex to be added to the OutlineShape */ public final void addVertex(int position, Vertex v) { @@ -295,7 +295,7 @@ public class OutlineShape implements Comparable { /** Add a 2D {@link Vertex} to the last outline by defining the coordniate attribute * of the vertex. The 2D vertex will be represented as Z=0. - * + * * @param x the x coordinate * @param y the y coordniate * @param onCurve flag if this vertex is on the final curve or defines a curved region @@ -317,10 +317,10 @@ public class OutlineShape implements Comparable { addVertex(vertexFactory.create(x, y, z, onCurve)); } - /** Add a vertex to the last outline by passing a float array and specifying the - * offset and length in which. The attributes of the vertex are located. + /** Add a vertex to the last outline by passing a float array and specifying the + * offset and length in which. The attributes of the vertex are located. * The attributes should be continuous (stride = 0). - * Attributes which value are not set (when length less than 3) + * Attributes which value are not set (when length less than 3) * are set implicitly to zero. * @param coordsBuffer the coordinate array where the vertex attributes are to be picked from * @param offset the offset in the buffer to the x coordinate @@ -330,11 +330,11 @@ public class OutlineShape implements Comparable { */ public final void addVertex(float[] coordsBuffer, int offset, int length, boolean onCurve) { addVertex(vertexFactory.create(coordsBuffer, offset, length, onCurve)); - } + } /** Closes the last outline in the shape. *

    If last vertex is not equal to first vertex. - * A new temp vertex is added at the end which + * A new temp vertex is added at the end which * is equal to the first.

    */ public void closeLastOutline() { @@ -351,7 +351,7 @@ public class OutlineShape implements Comparable { /** Ensure the outlines represent * the specified destinationType. * and removes all overlaps in boundary triangles - * @param destinationType the target outline's vertices state. Currently only + * @param destinationType the target outline's vertices state. Currently only * {@link OutlineShape.VerticesState#QUADRATIC_NURBS} are supported. */ public void transformOutlines(VerticesState destinationType) { @@ -371,7 +371,7 @@ public class OutlineShape implements Comparable { float[] v2 = VectorUtil.mid(v1, v3); //drop off-curve vertex to image on the curve - b.setCoord(v2, 0, 3); + b.setCoord(v2, 0, 3); b.setOnCurve(true); outline.addVertex(index, vertexFactory.create(v1, 0, 3, false)); @@ -379,19 +379,19 @@ public class OutlineShape implements Comparable { } /** Check overlaps between curved triangles - * first check if any vertex in triangle a is in triangle b + * first check if any vertex in triangle a is in triangle b * second check if edges of triangle a intersect segments of triangle b * if any of the two tests is true we divide current triangle * and add the other to the list of overlaps - * + * * Loop until overlap array is empty. (check only in first pass) */ - private void checkOverlaps() { + private void checkOverlaps() { ArrayList overlaps = new ArrayList(3); int count = getOutlineNumber(); boolean firstpass = true; do { - for (int cc = 0; cc < count; cc++) { + for (int cc = 0; cc < count; cc++) { final Outline outline = getOutline(cc); int vertexCount = outline.getVertexCount(); for(int i=0; i < outline.getVertexCount(); i++) { @@ -429,7 +429,7 @@ public class OutlineShape implements Comparable { private Vertex checkTriOverlaps(Vertex a, Vertex b, Vertex c) { int count = getOutlineNumber(); - for (int cc = 0; cc < count; cc++) { + for (int cc = 0; cc < count; cc++) { final Outline outline = getOutline(cc); int vertexCount = outline.getVertexCount(); for(int i=0; i < vertexCount; i++) { @@ -451,7 +451,7 @@ public class OutlineShape implements Comparable { return current; } - if(VectorUtil.tri2SegIntersection(a, b, c, prevV, current) + if(VectorUtil.tri2SegIntersection(a, b, c, prevV, current) || VectorUtil.tri2SegIntersection(a, b, c, current, nextV) || VectorUtil.tri2SegIntersection(a, b, c, prevV, nextV)) { return current; @@ -463,7 +463,7 @@ public class OutlineShape implements Comparable { private void transformOutlines2Quadratic() { int count = getOutlineNumber(); - for (int cc = 0; cc < count; cc++) { + for (int cc = 0; cc < count; cc++) { final Outline outline = getOutline(cc); int vertexCount = outline.getVertexCount(); @@ -471,13 +471,13 @@ public class OutlineShape implements Comparable { final Vertex currentVertex = outline.getVertex(i); final Vertex nextVertex = outline.getVertex((i+1)%vertexCount); if ( !currentVertex.isOnCurve() && !nextVertex.isOnCurve() ) { - final float[] newCoords = VectorUtil.mid(currentVertex.getCoord(), + final float[] newCoords = VectorUtil.mid(currentVertex.getCoord(), nextVertex.getCoord()); final Vertex v = vertexFactory.create(newCoords, 0, 3, true); i++; vertexCount++; outline.addVertex(i, v); - } + } } if(vertexCount <= 0) { outlines.remove(outline); @@ -487,7 +487,7 @@ public class OutlineShape implements Comparable { } if( vertexCount > 0 ) { - if(VectorUtil.checkEquality(outline.getVertex(0).getCoord(), + if(VectorUtil.checkEquality(outline.getVertex(0).getCoord(), outline.getLastVertex().getCoord())) { outline.removeVertex(vertexCount-1); } @@ -508,7 +508,7 @@ public class OutlineShape implements Comparable { } } - /** @return the list of concatenated vertices associated with all + /** @return the list of concatenated vertices associated with all * {@code Outline}s of this object */ public ArrayList getVertices() { @@ -551,7 +551,7 @@ public class OutlineShape implements Comparable { } /** Compare two outline shapes with Bounding Box area - * as criteria. + * as criteria. * @see java.lang.Comparable#compareTo(java.lang.Object) */ public final int compareTo(OutlineShape outline) { @@ -579,12 +579,12 @@ public class OutlineShape implements Comparable { validateBoundingBox(); } return bbox; - } + } /** * @param obj the Object to compare this OutlineShape with - * @return true if {@code obj} is an OutlineShape, not null, - * same outlineState, equal bounds and equal outlines in the same order + * @return true if {@code obj} is an OutlineShape, not null, + * same outlineState, equal bounds and equal outlines in the same order */ public boolean equals(Object obj) { if( obj == this) { @@ -592,7 +592,7 @@ public class OutlineShape implements Comparable { } if( null == obj || !(obj instanceof OutlineShape) ) { return false; - } + } final OutlineShape o = (OutlineShape) obj; if(getOutlineState() != o.getOutlineState()) { return false; @@ -625,5 +625,5 @@ public class OutlineShape implements Comparable { o.outlines.add(outlines.get(i).clone()); } return o; - } + } } diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java index 8b6d000fa..a9779523a 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/Region.java +++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java @@ -38,48 +38,48 @@ import com.jogamp.opengl.math.geom.AABBox; /** Abstract Outline shape GL representation * define the method an OutlineShape(s) is * binded rendered. - * + * * @see GLRegion */ public abstract class Region { - + /** Debug flag for region impl (graph.curve) */ public static final boolean DEBUG = Debug.debug("graph.curve"); - + public static final boolean DEBUG_INSTANCE = false; - /** View based Anti-Aliasing, A Two pass region rendering, slower - * and more resource hungry (FBO), but AA is perfect. - * Otherwise the default fast one pass MSAA region rendering is being used. + /** View based Anti-Aliasing, A Two pass region rendering, slower + * and more resource hungry (FBO), but AA is perfect. + * Otherwise the default fast one pass MSAA region rendering is being used. */ public static final int VBAA_RENDERING_BIT = 1 << 0; /** Use non uniform weights [0.0 .. 1.9] for curve region rendering. - * Otherwise the default weight 1.0 for uniform curve region rendering is being applied. + * Otherwise the default weight 1.0 for uniform curve region rendering is being applied. */ public static final int VARIABLE_CURVE_WEIGHT_BIT = 1 << 1; public static final int TWO_PASS_DEFAULT_TEXTURE_UNIT = 0; private final int renderModes; - private boolean dirty = true; - protected int numVertices = 0; + private boolean dirty = true; + protected int numVertices = 0; protected final AABBox box = new AABBox(); protected ArrayList triangles = new ArrayList(); protected ArrayList vertices = new ArrayList(); - public static boolean isVBAA(int renderModes) { - return 0 != ( renderModes & Region.VBAA_RENDERING_BIT ); + public static boolean isVBAA(int renderModes) { + return 0 != ( renderModes & Region.VBAA_RENDERING_BIT ); } /** Check if render mode capable of non uniform weights - * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, - * {@link Region#VBAA_RENDERING_BIT} + * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, + * {@link Region#VBAA_RENDERING_BIT} * @return true of capable of non uniform weights */ - public static boolean isNonUniformWeight(int renderModes) { - return 0 != ( renderModes & Region.VARIABLE_CURVE_WEIGHT_BIT ); + public static boolean isNonUniformWeight(int renderModes) { + return 0 != ( renderModes & Region.VARIABLE_CURVE_WEIGHT_BIT ); } protected Region(int regionRenderModes) { @@ -87,28 +87,28 @@ public abstract class Region { } /** Get current Models - * @return bit-field of render modes + * @return bit-field of render modes */ - public final int getRenderModes() { - return renderModes; + public final int getRenderModes() { + return renderModes; } /** Check if current Region is using VBAA * @return true if capable of two pass rendering - VBAA */ - public boolean isVBAA() { - return Region.isVBAA(renderModes); + public boolean isVBAA() { + return Region.isVBAA(renderModes); } - /** Check if current instance uses non uniform weights + /** Check if current instance uses non uniform weights * @return true if capable of nonuniform weights */ - public boolean isNonUniformWeight() { - return Region.isNonUniformWeight(renderModes); + public boolean isNonUniformWeight() { + return Region.isNonUniformWeight(renderModes); } /** Get the current number of vertices associated - * with this region. This number is not necessary equal to + * with this region. This number is not necessary equal to * the OGL bound number of vertices. * @return vertices count */ @@ -117,10 +117,10 @@ public abstract class Region { } /** Adds a {@link Triangle} object to the Region - * This triangle will be bound to OGL objects + * This triangle will be bound to OGL objects * on the next call to {@code update} * @param tri a triangle object - * + * * @see update(GL2ES2) */ public void addTriangle(Triangle tri) { @@ -129,10 +129,10 @@ public abstract class Region { } /** Adds a list of {@link Triangle} objects to the Region - * These triangles are to be binded to OGL objects + * These triangles are to be binded to OGL objects * on the next call to {@code update} * @param tris an arraylist of triangle objects - * + * * @see update(GL2ES2) */ public void addTriangles(ArrayList tris) { @@ -141,10 +141,10 @@ public abstract class Region { } /** Adds a {@link Vertex} object to the Region - * This vertex will be bound to OGL objects + * This vertex will be bound to OGL objects * on the next call to {@code update} * @param vert a vertex objects - * + * * @see update(GL2ES2) */ public void addVertex(Vertex vert) { @@ -154,10 +154,10 @@ public abstract class Region { } /** Adds a list of {@link Vertex} objects to the Region - * These vertices are to be binded to OGL objects + * These vertices are to be binded to OGL objects * on the next call to {@code update} * @param verts an arraylist of vertex objects - * + * * @see update(GL2ES2) */ public void addVertices(ArrayList verts) { @@ -175,10 +175,10 @@ public abstract class Region { } /** Check if this region is dirty. A region is marked dirty - * when new Vertices, Triangles, and or Lines are added after a + * when new Vertices, Triangles, and or Lines are added after a * call to update() * @return true if region is Dirty, false otherwise - * + * * @see update(GL2ES2) */ public final boolean isDirty() { diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java index 63713887b..dfb7a95b3 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java @@ -41,32 +41,32 @@ import jogamp.graph.curve.opengl.RegionFactory; /** A GLRegion is the OGL binding of one or more OutlineShapes * Defined by its vertices and generated triangles. The Region - * defines the final shape of the OutlineShape(s), which shall produced a shaded + * defines the final shape of the OutlineShape(s), which shall produced a shaded * region on the screen. - * - * Implementations of the GLRegion shall take care of the OGL + * + * Implementations of the GLRegion shall take care of the OGL * binding of the depending on its context, profile. - * + * * @see Region, RegionFactory, OutlineShape */ -public abstract class GLRegion extends Region { - +public abstract class GLRegion extends Region { + /** Create an ogl {@link GLRegion} defining the list of {@link OutlineShape}. * Combining the Shapes into single buffers. * @return the resulting Region inclusive the generated region */ public static GLRegion create(OutlineShape[] outlineShapes, int renderModes) { final GLRegion region = RegionFactory.create(renderModes); - + int numVertices = region.getNumVertices(); - + for(int index=0; index triangles = outlineShape.triangulate(); region.addTriangles(triangles); - + ArrayList vertices = outlineShape.getVertices(); for(int pos=0; pos < vertices.size(); pos++){ Vertex vert = vertices.get(pos); @@ -74,42 +74,42 @@ public abstract class GLRegion extends Region { } region.addVertices(vertices); } - + return region; } - /** + /** * Create an ogl {@link GLRegion} defining this {@link OutlineShape} * @return the resulting Region. */ public static GLRegion create(OutlineShape outlineShape, int renderModes) { final GLRegion region = RegionFactory.create(renderModes); - + outlineShape.transformOutlines(OutlineShape.VerticesState.QUADRATIC_NURBS); ArrayList triangles = (ArrayList) outlineShape.triangulate(); ArrayList vertices = (ArrayList) outlineShape.getVertices(); region.addVertices(vertices); region.addTriangles(triangles); return region; - } - + } + protected GLRegion(int renderModes) { super(renderModes); } - + /** Updates a graph region by updating the ogl related * objects for use in rendering if {@link #isDirty()}. - *

    Allocates the ogl related data and initializes it the 1st time.

    + *

    Allocates the ogl related data and initializes it the 1st time.

    *

    Called by {@link #draw(GL2ES2, RenderState, int, int, int)}.

    * @param rs TODO */ protected abstract void update(GL2ES2 gl, RenderState rs); - + /** Delete and clean the associated OGL * objects */ public abstract void destroy(GL2ES2 gl, RenderState rs); - + /** Renders the associated OGL objects specifying * current width/hight of window for multi pass rendering * of the region. @@ -117,13 +117,13 @@ public abstract class GLRegion extends Region { * @param rs the RenderState to be used * @param vp_width current screen width * @param vp_height current screen height - * @param texWidth desired texture width for multipass-rendering. + * @param texWidth desired texture width for multipass-rendering. * The actual used texture-width is written back when mp rendering is enabled, otherwise the store is untouched. */ public final void draw(GL2ES2 gl, RenderState rs, int vp_width, int vp_height, int[/*1*/] texWidth) { update(gl, rs); drawImpl(gl, rs, vp_width, vp_height, texWidth); } - + protected abstract void drawImpl(GL2ES2 gl, RenderState rs, int vp_width, int vp_height, int[/*1*/] texWidth); } diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java index 2f078d7bb..f7d4bfd2f 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java @@ -35,26 +35,26 @@ import com.jogamp.graph.curve.Region; public abstract class RegionRenderer extends Renderer { - /** + /** * Create a Hardware accelerated Region Renderer. - * @param rs the used {@link RenderState} - * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, {@link Region#VBAA_RENDERING_BIT} + * @param rs the used {@link RenderState} + * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, {@link Region#VBAA_RENDERING_BIT} * @return an instance of Region Renderer */ public static RegionRenderer create(RenderState rs, int renderModes) { return new jogamp.graph.curve.opengl.RegionRendererImpl01(rs, renderModes); } - + protected RegionRenderer(RenderState rs, int renderModes) { super(rs, renderModes); } - - + + /** Render an {@link OutlineShape} in 3D space at the position provided * the triangles of the shapes will be generated, if not yet generated * @param region the OutlineShape to Render. - * @param position the initial translation of the outlineShape. - * @param texWidth desired texture width for multipass-rendering. + * @param position the initial translation of the outlineShape. + * @param texWidth desired texture width for multipass-rendering. * The actual used texture-width is written back when mp rendering is enabled, otherwise the store is untouched. * @throws Exception if HwRegionRenderer not initialized */ @@ -65,10 +65,10 @@ public abstract class RegionRenderer extends Renderer { if( !areRenderModesCompatible(region) ) { throw new GLException("Incompatible render modes, : region modes "+region.getRenderModes()+ " doesn't contain renderer modes "+this.getRenderModes()); - } + } drawImpl(gl, region, position, texWidth); } - + /** * Usually just dispatched the draw call to the Region's draw implementation, * e.g. {@link com.jogamp.graph.curve.opengl.GLRegion#draw(GL2ES2, RenderState, int, int, int[]) GLRegion#draw(GL2ES2, RenderState, int, int, int[])}. @@ -79,6 +79,6 @@ public abstract class RegionRenderer extends Renderer { protected void destroyImpl(GL2ES2 gl) { // nop } - - + + } diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java index 5e305d664..9c833fd24 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java @@ -40,7 +40,7 @@ import com.jogamp.opengl.util.glsl.ShaderState; public abstract class RenderState { private static final String thisKey = "jogamp.graph.curve.RenderState" ; - + public static RenderState createRenderState(ShaderState st, Vertex.Factory pointFactory) { return new RenderStateImpl(st, pointFactory); } @@ -48,42 +48,42 @@ public abstract class RenderState { public static RenderState createRenderState(ShaderState st, Vertex.Factory pointFactory, PMVMatrix pmvMatrix) { return new RenderStateImpl(st, pointFactory, pmvMatrix); } - + public static final RenderState getRenderState(GL2ES2 gl) { return (RenderState) gl.getContext().getAttachedObject(thisKey); } - + protected final ShaderState st; protected final Vertex.Factory vertexFactory; protected final PMVMatrix pmvMatrix; - protected final GLUniformData gcu_PMVMatrix; - + protected final GLUniformData gcu_PMVMatrix; + protected RenderState(ShaderState st, Vertex.Factory vertexFactory, PMVMatrix pmvMatrix) { this.st = st; this.vertexFactory = vertexFactory; - this.pmvMatrix = pmvMatrix; + this.pmvMatrix = pmvMatrix; this.gcu_PMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, pmvMatrix.glGetPMvMatrixf()); - st.ownUniform(gcu_PMVMatrix); + st.ownUniform(gcu_PMVMatrix); } - + public final ShaderState getShaderState() { return st; } public final Vertex.Factory getVertexFactory() { return vertexFactory; } public final PMVMatrix pmvMatrix() { return pmvMatrix; } public final GLUniformData getPMVMatrix() { return gcu_PMVMatrix; } - + public void destroy(GL2ES2 gl) { st.destroy(gl); } - + public abstract GLUniformData getWeight(); public abstract GLUniformData getAlpha(); public abstract GLUniformData getColorStatic(); // public abstract GLUniformData getStrength(); - + public final RenderState attachTo(GL2ES2 gl) { return (RenderState) gl.getContext().attachObject(thisKey, this); } - + public final boolean detachFrom(GL2ES2 gl) { RenderState _rs = (RenderState) gl.getContext().getAttachedObject(thisKey); if(_rs == this) { @@ -91,8 +91,8 @@ public abstract class RenderState { return true; } return false; - } - + } + public StringBuilder toString(StringBuilder sb, boolean alsoUnlocated) { if(null==sb) { sb = new StringBuilder(); @@ -104,8 +104,8 @@ public abstract class RenderState { return sb; } - + public String toString() { return toString(null, false).toString(); - } + } } diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java index 998129551..c642fb652 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java @@ -52,8 +52,8 @@ public abstract class Renderer { protected int vp_height; protected boolean initialized; protected final RenderState rs; - private boolean vboSupported = false; - + private boolean vboSupported = false; + public final boolean isInitialized() { return initialized; } public final int getWidth() { return vp_width; } @@ -62,29 +62,29 @@ public abstract class Renderer { public float getWeight() { return rs.getWeight().floatValue(); } public float getAlpha() { return rs.getAlpha().floatValue(); } public final PMVMatrix getMatrix() { return rs.pmvMatrix(); } - + /** * Implementation shall load, compile and link the shader program and leave it active. * @param gl referencing the current GLContext to which the ShaderState is bound to * @return */ protected abstract boolean initShaderProgram(GL2ES2 gl); - + protected abstract void destroyImpl(GL2ES2 gl); - + /** - * @param rs the used {@link RenderState} + * @param rs the used {@link RenderState} * @param renderModes bit-field of modes */ protected Renderer(RenderState rs, int renderModes) { this.rs = rs; this.renderModes = renderModes; } - + public final int getRenderModes() { return renderModes; } - + public boolean usesVariableCurveWeight() { return Region.isNonUniformWeight(renderModes); } /** @@ -93,17 +93,17 @@ public abstract class Renderer { */ public final boolean areRenderModesCompatible(Region region) { final int cleanRenderModes = getRenderModes() & ( Region.VARIABLE_CURVE_WEIGHT_BIT ); - return cleanRenderModes == ( region.getRenderModes() & cleanRenderModes ); + return cleanRenderModes == ( region.getRenderModes() & cleanRenderModes ); } - + public final boolean isVBOSupported() { return vboSupported; } - - /** + + /** * Initialize shader and bindings for GPU based rendering bound to the given GL object's GLContext * if not initialized yet. *

    Leaves the renderer enabled, ie ShaderState.

    *

    Shall be called by a {@code draw()} method, e.g. {@link RegionRenderer#draw(GL2ES2, Region, float[], int)}

    - * + * * @param gl referencing the current GLContext to which the ShaderState is bound to * @throws GLException if initialization failed */ @@ -117,48 +117,48 @@ public abstract class Renderer { gl.isFunctionAvailable("glDrawElements") && gl.isFunctionAvailable("glVertexAttribPointer") && gl.isFunctionAvailable("glDeleteBuffers"); - + if(DEBUG) { System.err.println("TextRendererImpl01: VBO Supported = " + isVBOSupported()); } - + if(!vboSupported){ throw new GLException("VBO not supported"); } - + rs.attachTo(gl); - + gl.glEnable(GL2ES2.GL_BLEND); gl.glBlendFunc(GL2ES2.GL_SRC_ALPHA, GL2ES2.GL_ONE_MINUS_SRC_ALPHA); // FIXME: alpha blending stage ? - + initialized = initShaderProgram(gl); if(!initialized) { throw new GLException("Shader initialization failed"); } - + if(!rs.getShaderState().uniform(gl, rs.getPMVMatrix())) { throw new GLException("Error setting PMVMatrix in shader: "+rs.getShaderState()); } - + if( Region.isNonUniformWeight( getRenderModes() ) ) { if(!rs.getShaderState().uniform(gl, rs.getWeight())) { throw new GLException("Error setting weight in shader: "+rs.getShaderState()); } } - + if(!rs.getShaderState().uniform(gl, rs.getAlpha())) { throw new GLException("Error setting global alpha in shader: "+rs.getShaderState()); - } - + } + if(!rs.getShaderState().uniform(gl, rs.getColorStatic())) { throw new GLException("Error setting global color in shader: "+rs.getShaderState()); - } + } } - public final void flushCache(GL2ES2 gl) { + public final void flushCache(GL2ES2 gl) { // FIXME: REMOVE ! } - + public void destroy(GL2ES2 gl) { if(!initialized){ if(DEBUG_INSTANCE) { @@ -169,13 +169,13 @@ public abstract class Renderer { rs.getShaderState().useProgram(gl, false); destroyImpl(gl); rs.destroy(gl); - initialized = false; + initialized = false; } - + public final RenderState getRenderState() { return rs; } public final ShaderState getShaderState() { return rs.getShaderState(); } - - public final void enable(GL2ES2 gl, boolean enable) { + + public final void enable(GL2ES2 gl, boolean enable) { rs.getShaderState().useProgram(gl, enable); } @@ -188,7 +188,7 @@ public abstract class Renderer { rs.getShaderState().uniform(gl, rs.getWeight()); } } - + public void setAlpha(GL2ES2 gl, float alpha_t) { rs.getAlpha().setData(alpha_t); if(null != gl && rs.getShaderState().inUse()) { @@ -199,11 +199,11 @@ public abstract class Renderer { public void getColorStatic(GL2ES2 gl, float[] rgb) { FloatBuffer fb = (FloatBuffer) rs.getColorStatic().getBuffer(); - rgb[0] = fb.get(0); - rgb[1] = fb.get(1); - rgb[2] = fb.get(2); + rgb[0] = fb.get(0); + rgb[1] = fb.get(1); + rgb[2] = fb.get(2); } - + public void setColorStatic(GL2ES2 gl, float r, float g, float b){ FloatBuffer fb = (FloatBuffer) rs.getColorStatic().getBuffer(); fb.put(0, r); @@ -213,7 +213,7 @@ public abstract class Renderer { rs.getShaderState().uniform(gl, rs.getColorStatic()); } } - + public void rotate(GL2ES2 gl, float angle, float x, float y, float z) { rs.pmvMatrix().glRotatef(angle, x, y, z); updateMatrix(gl); @@ -223,7 +223,7 @@ public abstract class Renderer { rs.pmvMatrix().glTranslatef(x, y, z); updateMatrix(gl); } - + public void scale(GL2ES2 gl, float x, float y, float z) { rs.pmvMatrix().glScalef(x, y, z); updateMatrix(gl); @@ -261,15 +261,15 @@ public abstract class Renderer { p.glLoadIdentity(); p.glOrthof(0, width, 0, height, near, far); updateMatrix(gl); - return true; + return true; } protected String getVertexShaderName() { return "curverenderer" + getImplVersion(); } - + protected String getFragmentShaderName() { - final String version = getImplVersion(); + final String version = getImplVersion(); final String pass = Region.isVBAA(renderModes) ? "-2pass" : "-1pass" ; final String weight = Region.isNonUniformWeight(renderModes) ? "-weight" : "" ; return "curverenderer" + version + pass + weight; @@ -277,7 +277,7 @@ public abstract class Renderer { // FIXME: Really required to have sampler2D def. precision ? If not, we can drop getFragmentShaderPrecision(..) and use default ShaderCode .. public static final String es2_precision_fp = "\nprecision mediump float;\nprecision mediump int;\nprecision mediump sampler2D;\n"; - + protected String getFragmentShaderPrecision(GL2ES2 gl) { if( gl.isGLES2() ) { return es2_precision_fp; @@ -287,7 +287,7 @@ public abstract class Renderer { } return null; } - + protected String getImplVersion() { return "01"; } diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java index 8dc41b0c0..f6ce852d8 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java @@ -38,28 +38,28 @@ import jogamp.graph.curve.text.GlyphString; import com.jogamp.graph.font.Font; public abstract class TextRenderer extends Renderer { - /** + /** * Create a Hardware accelerated Text Renderer. - * @param rs the used {@link RenderState} + * @param rs the used {@link RenderState} * @param renderModes either {@link com.jogamp.graph.curve.opengl.GLRegion#SINGLE_PASS} or {@link com.jogamp.graph.curve.Region#VBAA_RENDERING_BIT} */ public static TextRenderer create(RenderState rs, int renderModes) { return new jogamp.graph.curve.opengl.TextRendererImpl01(rs, renderModes); } - + protected TextRenderer(RenderState rs, int type) { super(rs, type); } - + /** Render the String in 3D space wrt to the font provided at the position provided * the outlines will be generated, if not yet generated * @param gl the current GL state * @param font {@link Font} to be used - * @param str text to be rendered - * @param position the lower left corner of the string + * @param str text to be rendered + * @param position the lower left corner of the string * @param fontSize font size - * @param texWidth desired texture width for multipass-rendering. + * @param texWidth desired texture width for multipass-rendering. * The actual used texture-width is written back when mp rendering is enabled, otherwise the store is untouched. * @throws Exception if TextRenderer not initialized */ @@ -77,11 +77,11 @@ public abstract class TextRenderer extends Renderer { if(DEBUG_INSTANCE) { System.err.println("createString: "+getCacheSize()+"/"+getCacheLimit()+" - "+Font.NAME_UNIQUNAME + " - " + str + " - " + size); } - final GlyphString glyphString = GlyphString.createString(null, rs.getVertexFactory(), font, size, str); - glyphString.createRegion(gl, renderModes); + final GlyphString glyphString = GlyphString.createString(null, rs.getVertexFactory(), font, size, str); + glyphString.createRegion(gl, renderModes); return glyphString; } - + /** FIXME public void flushCache(GL2ES2 gl) { Iterator iterator = stringCacheMap.values().iterator(); @@ -89,10 +89,10 @@ public abstract class TextRenderer extends Renderer { GlyphString glyphString = iterator.next(); glyphString.destroy(gl, rs); } - stringCacheMap.clear(); + stringCacheMap.clear(); stringCacheArray.clear(); } */ - + @Override protected void destroyImpl(GL2ES2 gl) { // fluchCache(gl) already called @@ -101,42 +101,42 @@ public abstract class TextRenderer extends Renderer { GlyphString glyphString = iterator.next(); glyphString.destroy(gl, rs); } - stringCacheMap.clear(); + stringCacheMap.clear(); stringCacheArray.clear(); } - + /** *

    Sets the cache limit for reusing GlyphString's and their Region. * Default is {@link #DEFAULT_CACHE_LIMIT}, -1 unlimited, 0 turns cache off, >0 limited

    - * + * *

    The cache will be validate when the next string rendering happens.

    - * + * * @param newLimit new cache size - * + * * @see #DEFAULT_CACHE_LIMIT */ public final void setCacheLimit(int newLimit ) { stringCacheLimit = newLimit; } - + /** * Sets the cache limit, see {@link #setCacheLimit(int)} and validates the cache. - * + * * @see #setCacheLimit(int) - * + * * @param gl current GL used to remove cached objects if required * @param newLimit new cache size */ public final void setCacheLimit(GL2ES2 gl, int newLimit ) { stringCacheLimit = newLimit; validateCache(gl, 0); } - + /** * @return the current cache limit */ public final int getCacheLimit() { return stringCacheLimit; } - - /** + + /** * @return the current utilized cache size, <= {@link #getCacheLimit()} */ public final int getCacheSize() { return stringCacheArray.size(); } - + protected final void validateCache(GL2ES2 gl, int space) { if ( getCacheLimit() > 0 ) { while ( getCacheSize() + space > getCacheLimit() ) { @@ -144,7 +144,7 @@ public abstract class TextRenderer extends Renderer { } } } - + protected final GlyphString getCachedGlyphString(Font font, String str, int fontSize) { return stringCacheMap.get(getKey(font, str, fontSize)); } @@ -160,13 +160,13 @@ public abstract class TextRenderer extends Renderer { } /// else overwrite is nop .. } } - + protected final void removeCachedGlyphString(GL2ES2 gl, Font font, String str, int fontSize) { final String key = getKey(font, str, fontSize); GlyphString glyphString = stringCacheMap.remove(key); if(null != glyphString) { glyphString.destroy(gl, rs); - } + } stringCacheArray.remove(key); } @@ -177,7 +177,7 @@ public abstract class TextRenderer extends Renderer { glyphString.destroy(gl, rs); } } - + protected final String getKey(Font font, String str, int fontSize) { final StringBuilder sb = new StringBuilder(); return font.getName(sb, Font.NAME_UNIQUNAME) @@ -186,8 +186,8 @@ public abstract class TextRenderer extends Renderer { /** Default cache limit, see {@link #setCacheLimit(int)} */ public static final int DEFAULT_CACHE_LIMIT = 256; - + private HashMap stringCacheMap = new HashMap(DEFAULT_CACHE_LIMIT); private ArrayList stringCacheArray = new ArrayList(DEFAULT_CACHE_LIMIT); - private int stringCacheLimit = DEFAULT_CACHE_LIMIT; + private int stringCacheLimit = DEFAULT_CACHE_LIMIT; } \ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/graph/curve/tess/Triangulation.java b/src/jogl/classes/com/jogamp/graph/curve/tess/Triangulation.java index 7728efcaf..ae2849536 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/tess/Triangulation.java +++ b/src/jogl/classes/com/jogamp/graph/curve/tess/Triangulation.java @@ -33,7 +33,7 @@ import jogamp.graph.curve.tess.CDTriangulator2D; public class Triangulation { /** Create a new instance of a triangulation. - * Currently only a modified version of Constraint Delaunay + * Currently only a modified version of Constraint Delaunay * is implemented. * @return instance of a triangulator * @see Triangulator diff --git a/src/jogl/classes/com/jogamp/graph/curve/tess/Triangulator.java b/src/jogl/classes/com/jogamp/graph/curve/tess/Triangulator.java index 1ffaccebc..4e8c400e0 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/tess/Triangulator.java +++ b/src/jogl/classes/com/jogamp/graph/curve/tess/Triangulator.java @@ -36,32 +36,32 @@ import com.jogamp.graph.geom.Triangle; /** Interface to the triangulation algorithms provided * A triangulation of 2D outlines where you can * provides an easy one or more outlines to be triangulated - * + * * example usage: * addCurve(o1); * addCurve(o2); * addCurve(o3); * generate(); * reset(); - * + * * @see Outline * @see Triangulation */ public interface Triangulator { - + /** Add a curve to the list of Outlines * describing the shape * @param outline a bounding {@link Outline} */ public void addCurve(Outline outline); - - /** Generate the triangulation of the provided + + /** Generate the triangulation of the provided * List of {@link Outline}s * @return an arraylist of {@link Triangle}s resembling the * final shape. */ public ArrayList generate(); - + /** Reset the triangulation to initial state * Clearing cached data */ diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java index 64a3a3e6c..82211da92 100644 --- a/src/jogl/classes/com/jogamp/graph/font/Font.java +++ b/src/jogl/classes/com/jogamp/graph/font/Font.java @@ -31,10 +31,10 @@ import com.jogamp.opengl.math.geom.AABBox; /** * Interface wrapper for font implementation. - * + * * TrueType Font Specification: * http://developer.apple.com/fonts/ttrefman/rm06/Chap6.html - * + * * TrueType Font Table Introduction: * http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08 */ @@ -50,22 +50,22 @@ public interface Font { public static final int NAME_VERSION = 5; public static final int NAME_MANUFACTURER = 8; public static final int NAME_DESIGNER = 9; - - + + /** * Metrics for font - * + * * Depending on the font's direction, horizontal or vertical, * the following tables shall be used: - * + * * Vertical http://developer.apple.com/fonts/TTRefMan/RM06/Chap6vhea.html * Horizontal http://developer.apple.com/fonts/TTRefMan/RM06/Chap6hhea.html */ - public interface Metrics { + public interface Metrics { float getAscent(float pixelSize); float getDescent(float pixelSize); float getLineGap(float pixelSize); - float getMaxExtend(float pixelSize); + float getMaxExtend(float pixelSize); float getScale(float pixelSize); AABBox getBBox(float pixelSize); } @@ -74,12 +74,12 @@ public interface Font { * Glyph for font */ public interface Glyph { - // reserved special glyph IDs + // reserved special glyph IDs // http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08#ba57949e public static final int ID_UNKNOWN = 0; public static final int ID_CR = 2; public static final int ID_SPACE = 3; - + public Font getFont(); public char getSymbol(); public AABBox getBBox(float pixelSize); @@ -89,25 +89,25 @@ public interface Font { public String getName(int nameIndex); public StringBuilder getName(StringBuilder string, int nameIndex); - + /** Shall return the family and subfamily name, separated a dash. *

    {@link #getName(StringBuilder, int)} w/ {@link #NAME_FAMILY} and {@link #NAME_SUBFAMILY}

    *

    Example: "{@code Ubuntu-Regular}"

    */ public StringBuilder getFullFamilyName(StringBuilder buffer); - + public StringBuilder getAllNames(StringBuilder string, String separator); - + public float getAdvanceWidth(int i, float pixelSize); public Metrics getMetrics(); public Glyph getGlyph(char symbol); public int getNumGlyphs(); - + public float getStringWidth(CharSequence string, float pixelSize); public float getStringHeight(CharSequence string, float pixelSize); public AABBox getStringBounds(CharSequence string, float pixelSize); - - public boolean isPrintableChar( char c ); - + + public boolean isPrintableChar( char c ); + /** Shall return {@link #getFullFamilyName()} */ public String toString(); } \ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java index d2824b9dc..884662e6e 100644 --- a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java +++ b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java @@ -49,13 +49,13 @@ import jogamp.graph.font.UbuntuFontLoader; public class FontFactory { private static final String FontConstructorPropKey = "jogamp.graph.font.ctor"; private static final String DefaultFontConstructor = "jogamp.graph.font.typecast.TypecastFontConstructor"; - + /** Ubuntu is the default font family */ public static final int UBUNTU = 0; - + /** Java fonts are optional */ public static final int JAVA = 1; - + private static final FontConstructor fontConstr; static { @@ -63,18 +63,18 @@ public class FontFactory { * For example: * "jogamp.graph.font.typecast.TypecastFontFactory" (default) * "jogamp.graph.font.ttf.TTFFontImpl" - */ + */ String fontImplName = PropertyAccess.getProperty(FontConstructorPropKey, true); if(null == fontImplName) { fontImplName = DefaultFontConstructor; } fontConstr = (FontConstructor) ReflectionUtil.createInstance(fontImplName, FontFactory.class.getClassLoader()); } - + public static final FontSet getDefault() { return get(UBUNTU); } - + public static final FontSet get(int font) { switch (font) { case JAVA: @@ -83,15 +83,15 @@ public class FontFactory { return UbuntuFontLoader.get(); } } - + public static final Font get(File file) throws IOException { return fontConstr.create(file); } public static final Font get(final URLConnection conn) throws IOException { return fontConstr.create(conn); - } - + } + public static boolean isPrintableChar( char c ) { if( Character.isWhitespace(c) ) { return true; @@ -101,5 +101,5 @@ public class FontFactory { } final Character.UnicodeBlock block = Character.UnicodeBlock.of( c ); return block != null && block != Character.UnicodeBlock.SPECIALS; - } + } } diff --git a/src/jogl/classes/com/jogamp/graph/font/FontSet.java b/src/jogl/classes/com/jogamp/graph/font/FontSet.java index d376922ab..17b8b2136 100644 --- a/src/jogl/classes/com/jogamp/graph/font/FontSet.java +++ b/src/jogl/classes/com/jogamp/graph/font/FontSet.java @@ -34,29 +34,29 @@ public interface FontSet { /** Font family REGULAR **/ public static final int FAMILY_REGULAR = 0; - + /** Font family LIGHT **/ public static final int FAMILY_LIGHT = 1; - + /** Font family MEDIUM **/ public static final int FAMILY_MEDIUM = 2; - + /** Font family CONDENSED **/ public static final int FAMILY_CONDENSED = 3; - + /** Font family MONO **/ public static final int FAMILY_MONOSPACED = 4; - + /** SERIF style/family bit flag. Fallback to Sans Serif. */ public static final int STYLE_SERIF = 1 << 1; - + /** BOLD style bit flag */ public static final int STYLE_BOLD = 1 << 2; - + /** ITALIC style bit flag */ public static final int STYLE_ITALIC = 1 << 3; Font getDefault() throws IOException ; - + Font get(int family, int stylebits) throws IOException ; } diff --git a/src/jogl/classes/com/jogamp/graph/geom/Outline.java b/src/jogl/classes/com/jogamp/graph/geom/Outline.java index 12c45860b..dfa6a8635 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Outline.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Outline.java @@ -36,12 +36,12 @@ import com.jogamp.opengl.math.geom.AABBox; /** Define a single continuous stroke by control vertices. - * The vertices define the shape of the region defined by this + * The vertices define the shape of the region defined by this * outline. The Outline can contain a list of off-curve and on-curve * vertices which define curved regions. - * + * * Note: An outline should be closed to be rendered as a region. - * + * * @see OutlineShape, Region */ public class Outline implements Cloneable, Comparable { @@ -55,7 +55,7 @@ public class Outline implements Cloneable, Comparable { * An outline can contain off Curve vertices which define curved * regions in the outline. */ - public Outline() { + public Outline() { } public final int getVertexCount() { @@ -64,7 +64,7 @@ public class Outline implements Cloneable, Comparable { /** Appends a vertex to the outline loop/strip. * @param vertex Vertex to be added - * @throws NullPointerException if the {@link Vertex} element is null + * @throws NullPointerException if the {@link Vertex} element is null */ public final void addVertex(Vertex vertex) throws NullPointerException { addVertex(vertices.size(), vertex); @@ -73,7 +73,7 @@ public class Outline implements Cloneable, Comparable { /** Insert the {@link Vertex} element at the given {@code position} to the outline loop/strip. * @param position of the added Vertex * @param vertex Vertex object to be added - * @throws NullPointerException if the {@link Vertex} element is null + * @throws NullPointerException if the {@link Vertex} element is null * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position > getVertexNumber()) */ public final void addVertex(int position, Vertex vertex) throws NullPointerException, IndexOutOfBoundsException { @@ -88,10 +88,10 @@ public class Outline implements Cloneable, Comparable { /** Replaces the {@link Vertex} element at the given {@code position}. *

    Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it.

    - * + * * @param position of the replaced Vertex - * @param vertex replacement Vertex object - * @throws NullPointerException if the {@link Outline} element is null + * @param vertex replacement Vertex object + * @throws NullPointerException if the {@link Outline} element is null * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getVertexNumber()) */ public final void setVertex(int position, Vertex vertex) throws NullPointerException, IndexOutOfBoundsException { @@ -112,12 +112,12 @@ public class Outline implements Cloneable, Comparable { /** Removes the {@link Vertex} element at the given {@code position}. *

    Sets the bounding box dirty, hence a next call to {@link #getBounds()} will validate it.

    - * + * * @param position of the to be removed Vertex * @throws IndexOutOfBoundsException if position is out of range (position < 0 || position >= getVertexNumber()) */ public final Vertex removeVertex(int position) throws IndexOutOfBoundsException { - dirtyBBox = true; + dirtyBBox = true; return vertices.remove(position); } @@ -139,7 +139,7 @@ public class Outline implements Cloneable, Comparable { /** * Use the given outline loop/strip. *

    Validates the bounding box.

    - * + * * @param vertices the new outline loop/strip */ public final void setVertices(ArrayList vertices) { @@ -152,7 +152,7 @@ public class Outline implements Cloneable, Comparable { } /** define if this outline is closed or not. - * if set to closed, checks if the last vertex is + * if set to closed, checks if the last vertex is * equal to the first vertex. If not Equal adds a * vertex at the end to the list. * @param closed @@ -170,7 +170,7 @@ public class Outline implements Cloneable, Comparable { } /** Compare two outlines with Bounding Box area - * as criteria. + * as criteria. * @see java.lang.Comparable#compareTo(java.lang.Object) */ public final int compareTo(Outline outline) { @@ -198,11 +198,11 @@ public class Outline implements Cloneable, Comparable { validateBoundingBox(); } return bbox; - } + } /** * @param obj the Object to compare this Outline with - * @return true if {@code obj} is an Outline, not null, equals bounds and equal vertices in the same order + * @return true if {@code obj} is an Outline, not null, equals bounds and equal vertices in the same order */ public boolean equals(Object obj) { if( obj == this) { @@ -210,7 +210,7 @@ public class Outline implements Cloneable, Comparable { } if( null == obj || !(obj instanceof Outline) ) { return false; - } + } final Outline o = (Outline) obj; if(getVertexCount() != o.getVertexCount()) { return false; @@ -240,5 +240,5 @@ public class Outline implements Cloneable, Comparable { o.vertices.add(vertices.get(i).clone()); } return o; - } + } } diff --git a/src/jogl/classes/com/jogamp/graph/geom/Triangle.java b/src/jogl/classes/com/jogamp/graph/geom/Triangle.java index fb34de221..bd0900495 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Triangle.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Triangle.java @@ -48,11 +48,11 @@ public class Triangle { public Vertex[] getVertices() { return vertices; } - + public boolean isEdgesBoundary() { return boundaryEdges[0] || boundaryEdges[1] || boundaryEdges[2]; } - + public boolean isVerticesBoundary() { return boundaryVertices[0] || boundaryVertices[1] || boundaryVertices[2]; } @@ -60,11 +60,11 @@ public class Triangle { public void setEdgesBoundary(boolean[] boundary) { this.boundaryEdges = boundary; } - + public boolean[] getEdgeBoundary() { return boundaryEdges; } - + public boolean[] getVerticesBoundary() { return boundaryVertices; } @@ -72,7 +72,7 @@ public class Triangle { public void setVerticesBoundary(boolean[] boundaryVertices) { this.boundaryVertices = boundaryVertices; } - + public String toString() { return "Tri ID: " + id + "\n" + vertices[0] + "\n" + vertices[1] + "\n" + vertices[2]; } diff --git a/src/jogl/classes/com/jogamp/graph/geom/Vertex.java b/src/jogl/classes/com/jogamp/graph/geom/Vertex.java index e3df86de1..40048235e 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Vertex.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Vertex.java @@ -30,7 +30,7 @@ package com.jogamp.graph.geom; import com.jogamp.opengl.math.Vert3fImmutable; /** - * A Vertex with custom memory layout using custom factory. + * A Vertex with custom memory layout using custom factory. */ public interface Vertex extends Vert3fImmutable, Cloneable { @@ -39,16 +39,16 @@ public interface Vertex extends Vert3fImmutable, Cloneable { T create(float x, float y, float z, boolean onCurve); - T create(float[] coordsBuffer, int offset, int length, boolean onCurve); + T create(float[] coordsBuffer, int offset, int length, boolean onCurve); } - + void setCoord(float x, float y, float z); /** * @see System#arraycopy(Object, int, Object, int, int) for thrown IndexOutOfBoundsException */ void setCoord(float[] coordsBuffer, int offset, int length); - + void setX(float x); void setY(float y); @@ -60,24 +60,24 @@ public interface Vertex extends Vert3fImmutable, Cloneable { void setOnCurve(boolean onCurve); int getId(); - + void setId(int id); - + float[] getTexCoord(); - + void setTexCoord(float s, float t); - + /** * @see System#arraycopy(Object, int, Object, int, int) for thrown IndexOutOfBoundsException */ void setTexCoord(float[] texCoordsBuffer, int offset, int length); - + /** * @param obj the Object to compare this Vertex with - * @return true if {@code obj} is a Vertex and not null, on-curve flag is equal and has same vertex- and tex-coords. + * @return true if {@code obj} is a Vertex and not null, on-curve flag is equal and has same vertex- and tex-coords. */ boolean equals(Object obj); - + /** * @return deep clone of this Vertex */ diff --git a/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java b/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java index 97e438b63..6b07688a7 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java +++ b/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java @@ -39,11 +39,11 @@ public class SVertex implements Vertex { protected float[] coord = new float[3]; protected boolean onCurve; private float[] texCoord = new float[2]; - + static final Factory factory = new Factory(); - - public static Factory factory() { return factory; } - + + public static Factory factory() { return factory; } + public static class Factory implements Vertex.Factory { public SVertex create() { return new SVertex(); @@ -55,9 +55,9 @@ public class SVertex implements Vertex { public SVertex create(float[] coordsBuffer, int offset, int length, boolean onCurve) { return new SVertex(coordsBuffer, offset, length, onCurve); - } + } } - + public SVertex() { } @@ -65,19 +65,19 @@ public class SVertex implements Vertex { setCoord(x, y, z); setOnCurve(onCurve); } - + public SVertex(float[] coordsBuffer, int offset, int length, boolean onCurve) { setCoord(coordsBuffer, offset, length); setOnCurve(onCurve); } - - public SVertex(float[] coordsBuffer, int offset, int length, + + public SVertex(float[] coordsBuffer, int offset, int length, float[] texCoordsBuffer, int offsetTC, int lengthTC, boolean onCurve) { setCoord(coordsBuffer, offset, length); setTexCoord(texCoordsBuffer, offsetTC, lengthTC); setOnCurve(onCurve); } - + public final void setCoord(float x, float y, float z) { this.coord[0] = x; this.coord[1] = y; @@ -87,12 +87,12 @@ public class SVertex implements Vertex { public final void setCoord(float[] coordsBuffer, int offset, int length) { System.arraycopy(coordsBuffer, offset, coord, 0, length); } - + @Override public int getCoordCount() { return 3; } - + @Override public final float[] getCoord() { return coord; @@ -133,11 +133,11 @@ public class SVertex implements Vertex { public final int getId(){ return id; } - + public final void setId(int id){ this.id = id; } - + public boolean equals(Object obj) { if( obj == this) { return true; @@ -146,12 +146,12 @@ public class SVertex implements Vertex { return false; } final Vertex v = (Vertex) obj; - return this == v || - isOnCurve() == v.isOnCurve() && + return this == v || + isOnCurve() == v.isOnCurve() && VectorUtil.checkEqualityVec2(getTexCoord(), v.getTexCoord()) && VectorUtil.checkEquality(getCoord(), v.getCoord()) ; } - + public final float[] getTexCoord() { return texCoord; } @@ -164,16 +164,16 @@ public class SVertex implements Vertex { public final void setTexCoord(float[] texCoordsBuffer, int offset, int length) { System.arraycopy(texCoordsBuffer, offset, texCoord, 0, length); } - + /** * @return deep clone of this Vertex, but keeping the id blank */ public SVertex clone(){ return new SVertex(this.coord, 0, 3, this.texCoord, 0, 2, this.onCurve); } - + public String toString() { - return "[ID: " + id + ", onCurve: " + onCurve + + return "[ID: " + id + ", onCurve: " + onCurve + ": p " + coord[0] + ", " + coord[1] + ", " + coord[2] + ", t " + texCoord[0] + ", " + texCoord[1] + "]"; } diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java index 7060bb7d1..c78b2b83d 100644 --- a/src/jogl/classes/com/jogamp/opengl/FBObject.java +++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java @@ -46,7 +46,7 @@ import com.jogamp.opengl.FBObject.Attachment.Type; /** * Core utility class simplifying usage of framebuffer objects (FBO) - * with all {@link GLProfile}s. + * with all {@link GLProfile}s. *

    * Supports on-the-fly reconfiguration of dimension and multisample buffers via {@link #reset(GL, int, int, int, boolean)} * while preserving the {@link Attachment} references. @@ -55,50 +55,50 @@ import com.jogamp.opengl.FBObject.Attachment.Type; * Integrates default read/write framebuffers via {@link GLContext#getDefaultReadFramebuffer()} and {@link GLContext#getDefaultReadFramebuffer()}, * which is being hooked at {@link GL#glBindFramebuffer(int, int)} when the default (zero) framebuffer is selected. *

    - * + * *

    FIXME: Implement support for {@link Type#DEPTH_TEXTURE}, {@link Type#STENCIL_TEXTURE} .

    */ public class FBObject { protected static final boolean DEBUG = Debug.debug("FBObject"); private static final boolean FBOResizeQuirk = false; - + private static enum DetachAction { NONE, DISPOSE, RECREATE }; - - /** + + /** * Marker interface, denotes a color buffer attachment. *

    Always an instance of {@link Attachment}.

    - *

    Either an instance of {@link ColorAttachment} or {@link TextureAttachment}. + *

    Either an instance of {@link ColorAttachment} or {@link TextureAttachment}. */ - public static interface Colorbuffer { - /** + public static interface Colorbuffer { + /** * Initializes the color buffer and set it's parameter, if uninitialized, i.e. name is zero. * @return true if newly initialized, otherwise false. - * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case. + * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case. */ public boolean initialize(GL gl) throws GLException; - - /** + + /** * Releases the color buffer if initialized, i.e. name is not zero. - * @throws GLException if buffer release fails. + * @throws GLException if buffer release fails. */ public void free(GL gl) throws GLException; - + /** * Writes the internal format to the given GLCapabilities object. * @param caps the destination for format bits * @param rgba8Avail whether rgba8 is available */ - public void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail); + public void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail); } - + /** Common super class of all attachments */ public static abstract class Attachment { - public enum Type { + public enum Type { NONE, DEPTH, STENCIL, DEPTH_STENCIL, COLOR, COLOR_TEXTURE, DEPTH_TEXTURE, STENCIL_TEXTURE; - - /** + + /** * Returns {@link #COLOR}, {@link #DEPTH}, {@link #STENCIL} or {@link #DEPTH_STENCIL} - * @throws IllegalArgumentException if format cannot be handled. + * @throws IllegalArgumentException if format cannot be handled. */ public static Type determine(int format) throws IllegalArgumentException { switch(format) { @@ -120,20 +120,20 @@ public class FBObject { return Type.DEPTH_STENCIL; default: throw new IllegalArgumentException("format invalid: "+toHexString(format)); - } + } } }; - + /** immutable type [{@link #COLOR}, {@link #DEPTH}, {@link #STENCIL}, {@link #COLOR_TEXTURE}, {@link #DEPTH_TEXTURE}, {@link #STENCIL_TEXTURE} ] */ public final Type type; - + /** immutable the internal format */ public final int format; - + private int width, height; - + private int name; - + protected Attachment(Type type, int iFormat, int width, int height, int name) { this.type = type; this.format = iFormat; @@ -141,18 +141,18 @@ public class FBObject { this.height = height; this.name = name; } - + /** * Writes the internal format to the given GLCapabilities object. * @param caps the destination for format bits * @param rgba8Avail whether rgba8 is available */ - public final void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail) { + public final void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail) { final int _format; switch(format) { case GL.GL_RGBA: case 4: - _format = rgba8Avail ? GL.GL_RGBA8 : GL.GL_RGBA4; + _format = rgba8Avail ? GL.GL_RGBA8 : GL.GL_RGBA4; break; case GL.GL_RGB: case 3: @@ -191,7 +191,7 @@ public class FBObject { caps.setGreenBits(8); caps.setBlueBits(8); caps.setAlphaBits(8); - break; + break; case GL.GL_DEPTH_COMPONENT16: caps.setDepthBits(16); break; @@ -218,18 +218,18 @@ public class FBObject { throw new IllegalArgumentException("format invalid: "+toHexString(format)); } } - + /** width of attachment */ public final int getWidth() { return width; } /** height of attachment */ public final int getHeight() { return height; } /* pp */ final void setSize(int w, int h) { width = w; height = h; } - + /** buffer name [1..max], maybe a texture or renderbuffer name, depending on type. */ - public final int getName() { return name; } + public final int getName() { return name; } /* pp */ final void setName(int n) { name = n; } - - /** + + /** * Initializes the attachment and set it's parameter, if uninitialized, i.e. name is zero. *

                 final boolean init = 0 == name;
    @@ -239,11 +239,11 @@ public class FBObject {
                 return init;
              * 
    * @return true if newly initialized, otherwise false. - * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case. + * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case. */ public abstract boolean initialize(GL gl) throws GLException; - - /** + + /** * Releases the attachment if initialized, i.e. name is not zero. *
                 if(0 != name) {
    @@ -251,10 +251,10 @@ public class FBObject {
                     name = 0;
                 }
              * 
    - * @throws GLException if buffer release fails. + * @throws GLException if buffer release fails. */ public abstract void free(GL gl) throws GLException; - + /** *

    * Comparison by {@link #type}, {@link #format}, {@link #width}, {@link #height} and {@link #name}. @@ -272,7 +272,7 @@ public class FBObject { height== a.height && name == a.name ; } - + /** *

    * Hashed by {@link #type}, {@link #format}, {@link #width}, {@link #height} and {@link #name}. @@ -289,14 +289,14 @@ public class FBObject { hash = ((hash << 5) - hash) + name; return hash; } - + int objectHashCode() { return super.hashCode(); } - + public String toString() { return getClass().getSimpleName()+"[type "+type+", format "+toHexString(format)+", "+width+"x"+height+ "; name "+toHexString(name)+", obj "+toHexString(objectHashCode())+"]"; } - + public static Type getType(int attachmentPoint, int maxColorAttachments) { if( GL.GL_COLOR_ATTACHMENT0 <= attachmentPoint && attachmentPoint < GL.GL_COLOR_ATTACHMENT0+maxColorAttachments ) { return Type.COLOR; @@ -304,9 +304,9 @@ public class FBObject { switch(attachmentPoint) { case GL.GL_DEPTH_ATTACHMENT: return Type.DEPTH; - case GL.GL_STENCIL_ATTACHMENT: + case GL.GL_STENCIL_ATTACHMENT: return Type.STENCIL; - default: + default: throw new IllegalArgumentException("Invalid attachment point "+toHexString(attachmentPoint)); } } @@ -315,7 +315,7 @@ public class FBObject { /** Other renderbuffer attachment which maybe a colorbuffer, depth or stencil. */ public static class RenderAttachment extends Attachment { private int samples; - + /** * @param type allowed types are {@link Type#DEPTH_STENCIL} {@link Type#DEPTH}, {@link Type#STENCIL} or {@link Type#COLOR} * @param iFormat @@ -328,11 +328,11 @@ public class FBObject { super(validateType(type), iFormat, width, height, name); this.samples = samples; } - + /** number of samples, or zero for no multisampling */ public final int getSamples() { return samples; } /* pp */ final void setSamples(int s) { samples = s; } - + private static Type validateType(Type type) { switch(type) { case DEPTH_STENCIL: @@ -340,11 +340,11 @@ public class FBObject { case STENCIL: case COLOR: return type; - default: + default: throw new IllegalArgumentException("Invalid type: "+type); } } - + /** *

    * Comparison by {@link #type}, {@link #format}, {@link #samples}, {@link #width}, {@link #height} and {@link #name}. @@ -358,7 +358,7 @@ public class FBObject { return super.equals(o) && samples == ((RenderAttachment)o).samples; } - + /** *

    * Hashed by {@link #type}, {@link #format}, {@link #samples}, {@link #width}, {@link #height} and {@link #name}. @@ -378,14 +378,14 @@ public class FBObject { final boolean init = 0 == getName(); if( init ) { checkPreGLError(gl); - + final int[] name = new int[] { -1 }; gl.glGenRenderbuffers(1, name, 0); setName(name[0]); - + gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, getName()); if( samples > 0 ) { - ((GL2GL3)gl).glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, samples, format, getWidth(), getHeight()); + ((GL2GL3)gl).glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, samples, format, getWidth(), getHeight()); } else { gl.glRenderbufferStorage(GL.GL_RENDERBUFFER, format, getWidth(), getHeight()); } @@ -401,7 +401,7 @@ public class FBObject { } return init; } - + @Override public void free(GL gl) { final int[] name = new int[] { getName() }; @@ -413,20 +413,20 @@ public class FBObject { setName(0); } } - + public String toString() { return getClass().getSimpleName()+"[type "+type+", format "+toHexString(format)+", samples "+samples+", "+getWidth()+"x"+getHeight()+ ", name "+toHexString(getName())+", obj "+toHexString(objectHashCode())+"]"; } } - + /** Color render buffer attachment */ public static class ColorAttachment extends RenderAttachment implements Colorbuffer { public ColorAttachment(int iFormat, int samples, int width, int height, int name) { super(Type.COLOR, iFormat, samples, width, height, name); - } + } } - + /** Texture attachment */ public static class TextureAttachment extends Attachment implements Colorbuffer { /** details of the texture setup */ @@ -445,7 +445,7 @@ public class FBObject { * @param wrapT * @param name */ - public TextureAttachment(Type type, int iFormat, int width, int height, int dataFormat, int dataType, + public TextureAttachment(Type type, int iFormat, int width, int height, int dataFormat, int dataType, int magFilter, int minFilter, int wrapS, int wrapT, int name) { super(validateType(type), iFormat, width, height, name); this.dataFormat = dataFormat; @@ -455,35 +455,35 @@ public class FBObject { this.wrapS = wrapS; this.wrapT = wrapT; } - + private static Type validateType(Type type) { switch(type) { case COLOR_TEXTURE: case DEPTH_TEXTURE: case STENCIL_TEXTURE: return type; - default: + default: throw new IllegalArgumentException("Invalid type: "+type); } } - - /** + + /** * Initializes the texture and set it's parameter, if uninitialized, i.e. name is zero. - * @throws GLException if texture generation and setup fails. The just created texture name will be deleted in this case. + * @throws GLException if texture generation and setup fails. The just created texture name will be deleted in this case. */ @Override public boolean initialize(GL gl) throws GLException { final boolean init = 0 == getName(); if( init ) { checkPreGLError(gl); - - final int[] name = new int[] { -1 }; + + final int[] name = new int[] { -1 }; gl.glGenTextures(1, name, 0); if(0 == name[0]) { throw new GLException("null texture, "+this); } setName(name[0]); - + gl.glBindTexture(GL.GL_TEXTURE_2D, name[0]); if( 0 < magFilter ) { gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, magFilter); @@ -495,7 +495,7 @@ public class FBObject { gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, wrapS); } if( 0 < wrapT ) { - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, wrapT); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, wrapT); } boolean preTexImage2D = true; int glerr = gl.glGetError(); @@ -534,50 +534,50 @@ public class FBObject { "; min/mag "+toHexString(minFilter)+"/"+toHexString(magFilter)+ ", wrap S/T "+toHexString(wrapS)+"/"+toHexString(wrapT)+ "; name "+toHexString(getName())+", obj "+toHexString(objectHashCode())+"]"; - } + } } static String toHexString(int v) { return "0x"+Integer.toHexString(v); } - + /** - * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}, + * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}, * selecting the texture data type and format automatically. - * + * *

    Using default min/mag filter {@link GL#GL_NEAREST} and default wrapS/wrapT {@link GL#GL_CLAMP_TO_EDGE}.

    - * + * * @param glp the chosen {@link GLProfile} * @param alpha set to true if you request alpha channel, otherwise false; - * @param width texture width + * @param width texture width * @param height texture height * @return the created and uninitialized color {@link TextureAttachment} */ public static final TextureAttachment createColorTextureAttachment(GLProfile glp, boolean alpha, int width, int height) { return createColorTextureAttachment(glp, alpha, width, height, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); } - + /** - * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}, + * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}, * selecting the texture data type and format automatically. - * + * * @param glp the chosen {@link GLProfile} * @param alpha set to true if you request alpha channel, otherwise false; - * @param width texture width + * @param width texture width * @param height texture height * @param magFilter if > 0 value for {@link GL#GL_TEXTURE_MAG_FILTER} - * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} + * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} * @param wrapS if > 0 value for {@link GL#GL_TEXTURE_WRAP_S} * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} * @return the created and uninitialized color {@link TextureAttachment} */ - public static final TextureAttachment createColorTextureAttachment(GLProfile glp, boolean alpha, int width, int height, + public static final TextureAttachment createColorTextureAttachment(GLProfile glp, boolean alpha, int width, int height, int magFilter, int minFilter, int wrapS, int wrapT) { final int textureInternalFormat, textureDataFormat, textureDataType; - if(glp.isGLES()) { + if(glp.isGLES()) { textureInternalFormat = alpha ? GL.GL_RGBA : GL.GL_RGB; textureDataFormat = alpha ? GL.GL_RGBA : GL.GL_RGB; textureDataType = GL.GL_UNSIGNED_BYTE; - } else { + } else { textureInternalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8; // textureInternalFormat = alpha ? GL.GL_RGBA : GL.GL_RGB; // textureInternalFormat = alpha ? 4 : 3; @@ -586,27 +586,27 @@ public class FBObject { } return createColorTextureAttachment(textureInternalFormat, width, height, textureDataFormat, textureDataType, magFilter, minFilter, wrapS, wrapT); } - + /** - * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}. + * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}. * * @param internalFormat internalFormat parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} - * @param width texture width + * @param width texture width * @param height texture height * @param dataFormat format parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} * @param dataType type parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} * @param magFilter if > 0 value for {@link GL#GL_TEXTURE_MAG_FILTER} - * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} + * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} * @param wrapS if > 0 value for {@link GL#GL_TEXTURE_WRAP_S} * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} * @return the created and uninitialized color {@link TextureAttachment} */ public static final TextureAttachment createColorTextureAttachment(int internalFormat, int width, int height, int dataFormat, int dataType, int magFilter, int minFilter, int wrapS, int wrapT) { - return new TextureAttachment(Type.COLOR_TEXTURE, internalFormat, width, height, dataFormat, dataType, + return new TextureAttachment(Type.COLOR_TEXTURE, internalFormat, width, height, dataFormat, dataType, magFilter, minFilter, wrapS, wrapT, 0 /* name */); } - + private static boolean hasAlpha(int format) { switch(format) { case GL.GL_RGBA8: @@ -619,7 +619,7 @@ public class FBObject { return false; } } - + private boolean initialized; private boolean fullFBOSupport; private boolean rgba8Avail; @@ -629,7 +629,7 @@ public class FBObject { private boolean stencil04Avail; private boolean stencil08Avail; private boolean stencil16Avail; - private boolean packedDepthStencilAvail; + private boolean packedDepthStencilAvail; private int maxColorAttachments, maxSamples, maxTextureSize, maxRenderbufferSize; private int width, height, samples; @@ -639,21 +639,21 @@ public class FBObject { private boolean bound; private int colorAttachmentCount; - private Colorbuffer[] colorAttachmentPoints; // colorbuffer attachment points + private Colorbuffer[] colorAttachmentPoints; // colorbuffer attachment points private RenderAttachment depth, stencil; // depth and stencil maybe equal in case of packed-depth-stencil private FBObject samplingSink; // MSAA sink - private TextureAttachment samplingSinkTexture; + private TextureAttachment samplingSinkTexture; private boolean samplingSinkDirty; // // ColorAttachment helper .. // - + private final void validateColorAttachmentPointRange(int point) { if(!initialized) { throw new GLException("FBO not initialized"); - } + } if(maxColorAttachments != colorAttachmentPoints.length) { throw new InternalError("maxColorAttachments "+maxColorAttachments+", array.lenght "+colorAttachmentPoints); } @@ -661,14 +661,14 @@ public class FBObject { throw new IllegalArgumentException("attachment point out of range: "+point+", should be within [0.."+(maxColorAttachments-1)+"], "+this); } } - + private final void validateAddColorAttachment(int point, Colorbuffer ca) { validateColorAttachmentPointRange(point); if( null != colorAttachmentPoints[point] ) { throw new IllegalArgumentException("Cannot attach "+ca+", attachment point already in use by "+colorAttachmentPoints[point]+", "+this); - } + } } - + private final void addColorAttachment(int point, Colorbuffer ca) { validateColorAttachmentPointRange(point); final Colorbuffer c = colorAttachmentPoints[point]; @@ -678,7 +678,7 @@ public class FBObject { colorAttachmentPoints[point] = ca; colorAttachmentCount++; } - + private final void removeColorAttachment(int point, Colorbuffer ca) { validateColorAttachmentPointRange(point); final Colorbuffer c = colorAttachmentPoints[point]; @@ -688,20 +688,20 @@ public class FBObject { colorAttachmentPoints[point] = null; colorAttachmentCount--; } - + /** * Return the {@link Colorbuffer} attachment at attachmentPoint if it is attached to this FBO, otherwise null. - * + * * @see #attachColorbuffer(GL, boolean) * @see #attachColorbuffer(GL, boolean) * @see #attachTexture2D(GL, int, boolean, int, int, int, int) - * @see #attachTexture2D(GL, int, int, int, int, int, int, int, int) + * @see #attachTexture2D(GL, int, int, int, int, int, int, int, int) */ public final Colorbuffer getColorbuffer(int attachmentPoint) { - validateColorAttachmentPointRange(attachmentPoint); + validateColorAttachmentPointRange(attachmentPoint); return colorAttachmentPoints[attachmentPoint]; } - + /** * Finds the passed {@link Colorbuffer} within the valid range of attachment points * using reference comparison only. @@ -709,36 +709,36 @@ public class FBObject { * Note: Slow. Implementation uses a logN array search to save resources, i.e. not using a HashMap. *

    * @param ca the {@link Colorbuffer} to look for. - * @return -1 if the {@link Colorbuffer} could not be found, otherwise [0..{@link #getMaxColorAttachments()}-1] + * @return -1 if the {@link Colorbuffer} could not be found, otherwise [0..{@link #getMaxColorAttachments()}-1] */ public final int getColorbufferAttachmentPoint(Colorbuffer ca) { for(int i=0; ireference only. - * + * *

    * Note: Slow. Uses {@link #getColorbufferAttachmentPoint(Colorbuffer)} to determine it's attachment point * to be used for {@link #getColorbuffer(int)} *

    - * + * * @see #attachColorbuffer(GL, boolean) * @see #attachColorbuffer(GL, boolean) * @see #attachTexture2D(GL, int, boolean, int, int, int, int) - * @see #attachTexture2D(GL, int, int, int, int, int, int, int, int) + * @see #attachTexture2D(GL, int, int, int, int, int, int, int, int) */ public final Colorbuffer getColorbuffer(Colorbuffer ca) { final int p = getColorbufferAttachmentPoint(ca); return p>=0 ? getColorbuffer(p) : null; } - + /** * Creates an uninitialized FBObject instance. *

    @@ -747,7 +747,7 @@ public class FBObject { */ public FBObject() { this.initialized = false; - + // TBD @ init this.fullFBOSupport = false; this.rgba8Avail = false; @@ -762,7 +762,7 @@ public class FBObject { this.maxSamples=-1; this.maxTextureSize = 0; this.maxRenderbufferSize = 0; - + this.width = 0; this.height = 0; this.samples = 0; @@ -770,17 +770,17 @@ public class FBObject { this.ignoreStatus = false; this.fbName = 0; this.bound = false; - + this.colorAttachmentPoints = null; // at init .. this.colorAttachmentCount = 0; this.depth = null; - this.stencil = null; - + this.stencil = null; + this.samplingSink = null; this.samplingSinkTexture = null; this.samplingSinkDirty = true; } - + private void init(GL gl, int width, int height, int samples) throws GLException { if(initialized) { throw new GLException("FBO already initialized"); @@ -788,8 +788,8 @@ public class FBObject { if( !gl.hasBasicFBOSupport() ) { throw new GLException("FBO not supported w/ context: "+gl.getContext()+", "+this); } - fullFBOSupport = gl.hasFullFBOSupport(); - + fullFBOSupport = gl.hasFullFBOSupport(); + rgba8Avail = gl.isGL2GL3() || gl.isExtensionAvailable(GLExtensions.OES_rgb8_rgba8); depth24Avail = fullFBOSupport || gl.isExtensionAvailable(GLExtensions.OES_depth24); depth32Avail = fullFBOSupport || gl.isExtensionAvailable(GLExtensions.OES_depth32); @@ -797,15 +797,15 @@ public class FBObject { stencil04Avail = fullFBOSupport || gl.isExtensionAvailable(GLExtensions.OES_stencil4); stencil08Avail = fullFBOSupport || gl.isExtensionAvailable(GLExtensions.OES_stencil8); stencil16Avail = fullFBOSupport; - + packedDepthStencilAvail = fullFBOSupport || gl.isExtensionAvailable(GLExtensions.OES_packed_depth_stencil) || gl.isExtensionAvailable(GLExtensions.EXT_packed_depth_stencil) ; - + final boolean NV_fbo_color_attachments = gl.isExtensionAvailable(GLExtensions.NV_fbo_color_attachments); - + int val[] = new int[1]; - + checkPreGLError(gl); int realMaxColorAttachments = 1; @@ -818,24 +818,24 @@ public class FBObject { } catch (GLException gle) { gle.printStackTrace(); } } maxColorAttachments = realMaxColorAttachments <= 8 ? realMaxColorAttachments : 8; // cap to limit array size - + colorAttachmentPoints = new Colorbuffer[maxColorAttachments]; colorAttachmentCount = 0; - + maxSamples = gl.getMaxRenderbufferSamples(); gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0); maxTextureSize = val[0]; gl.glGetIntegerv(GL.GL_MAX_RENDERBUFFER_SIZE, val, 0); maxRenderbufferSize = val[0]; - + checkPreGLError(gl); - + if( 0 >= width ) { width = 1; } if( 0 >= height ) { height = 1; } this.width = width; this.height = height; this.samples = samples <= maxSamples ? samples : maxSamples; - + if(DEBUG) { System.err.println("FBObject "+width+"x"+height+", "+samples+" -> "+this.samples+" samples"); System.err.println("fullFBOSupport: "+fullFBOSupport); @@ -856,16 +856,16 @@ public class FBObject { System.err.println(JoglVersion.getGLStrings(gl, null).toString()); System.err.println(gl.getContext()); } - + checkNoError(null, gl.glGetError(), "FBObject Init.pre"); // throws GLException if error - + if(width > 2 + maxTextureSize || height> 2 + maxTextureSize || width > maxRenderbufferSize || height> maxRenderbufferSize ) { throw new GLException("size "+width+"x"+height+" exceeds on of the maxima [texture "+maxTextureSize+", renderbuffer "+maxRenderbufferSize+"]"); } resetSamplingSink(gl); - + // generate fbo .. gl.glGenFramebuffers(1, val, 0); fbName = val[0]; @@ -874,15 +874,15 @@ public class FBObject { } // bind fbo .. - gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, fbName); - checkNoError(gl, gl.glGetError(), "FBObject Init.bindFB"); // throws GLException if error + gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, fbName); + checkNoError(gl, gl.glGetError(), "FBObject Init.bindFB"); // throws GLException if error if(!gl.glIsFramebuffer(fbName)) { checkNoError(gl, GL.GL_INVALID_VALUE, "FBObject Init.isFB"); // throws GLException } bound = true; samplingSinkDirty = true; initialized = true; - + vStatus = GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; // always incomplete w/o attachments! if(DEBUG) { System.err.println("FBObject.init(): "+this); @@ -900,9 +900,9 @@ public class FBObject { * Incompatibility and hence recreation is forced if * the size or sample count doesn't match for subsequent calls. *

    - * + * *

    Leaves the FBO bound state untouched

    - * + * * @param gl the current GL context * @param newWidth * @param newHeight @@ -911,7 +911,7 @@ public class FBObject { public final void reset(GL gl, int newWidth, int newHeight) { reset(gl, newWidth, newHeight, 0, false); } - + /** * Initializes or resets this FBO's instance. *

    @@ -920,21 +920,21 @@ public class FBObject { * to match the new given parameters. *

    *

    - * Currently incompatibility and hence recreation of the attachments will be performed + * Currently incompatibility and hence recreation of the attachments will be performed * if the size or sample count doesn't match for subsequent calls. *

    - * + * *

    Leaves the FBO bound state untouched

    - * + * * @param gl the current GL context * @param newWidth the new width, it's minimum is capped to 1 * @param newHeight the new height, it's minimum is capped to 1 * @param newSamples if > 0, MSAA will be used, otherwise no multisampling. Will be capped to {@link #getMaxSamples()}. - * @param resetSamplingSink true calls {@link #resetSamplingSink(GL)} immediatly. + * @param resetSamplingSink true calls {@link #resetSamplingSink(GL)} immediatly. * false postpones resetting the sampling sink until {@link #use(GL, TextureAttachment)} or {@link #syncSamplingSink(GL)}, - * allowing to use the samples sink's FBO and texture until then. The latter is useful to benefit - * from implicit double buffering while resetting the sink just before it's being used, eg. at swap-buffer. - * + * allowing to use the samples sink's FBO and texture until then. The latter is useful to benefit + * from implicit double buffering while resetting the sink just before it's being used, eg. at swap-buffer. + * * @throws GLException in case of an error, i.e. size too big, etc .. */ public final void reset(GL gl, int newWidth, int newHeight, int newSamples, boolean resetSamplingSink) { @@ -942,9 +942,9 @@ public class FBObject { init(gl, newWidth, newHeight, newSamples); return; } - + newSamples = newSamples <= maxSamples ? newSamples : maxSamples; // clamp - + if( newWidth != width || newHeight != height || newSamples != samples ) { if( 0 >= newWidth ) { newWidth = 1; } if( 0 >= newHeight ) { newHeight = 1; } @@ -952,39 +952,39 @@ public class FBObject { newWidth > maxRenderbufferSize || newHeight > maxRenderbufferSize ) { throw new GLException("size "+width+"x"+height+" exceeds on of the maxima [texture "+maxTextureSize+", renderbuffer "+maxRenderbufferSize+"]"); } - + if(DEBUG) { System.err.println("FBObject.reset - START - "+width+"x"+height+", "+samples+" -> "+newWidth+"x"+newHeight+", "+newSamples+"; "+this); - } - + } + final boolean wasBound = isBound(); - + width = newWidth; height = newHeight; samples = newSamples; - + if(0 < samples && null == samplingSink ) { // needs valid samplingSink for detach*() -> bind() samplingSink = new FBObject(); samplingSink.init(gl, width, height, 0); } - detachAllImpl(gl, true , true); + detachAllImpl(gl, true , true); if(resetSamplingSink) { resetSamplingSink(gl); } - + samplingSinkDirty = true; if(!wasBound) { unbind(gl); } - + if(DEBUG) { System.err.println("FBObject.reset - END - "+this); } - } + } } - + /** * Writes the internal format of the attachments to the given GLCapabilities object. * @param caps the destination for format bits @@ -994,11 +994,11 @@ public class FBObject { caps.setNumSamples(samples); caps.setDepthBits(0); caps.setStencilBits(0); - + final Colorbuffer cb = samples > 0 ? getSamplingSink() : getColorbuffer(0); if(null != cb) { cb.formatToGLCapabilities(caps, rgba8Avail); - } + } if(null != depth) { depth.formatToGLCapabilities(caps, rgba8Avail); } @@ -1006,11 +1006,11 @@ public class FBObject { stencil.formatToGLCapabilities(caps, rgba8Avail); } } - - /** + + /** * Note that the status may reflect an incomplete state during transition of attachments. * @return The FB status. {@link GL.GL_FRAMEBUFFER_COMPLETE} if ok, otherwise return GL FBO error state or -1 - * @see #validateStatus() + * @see #validateStatus() */ public final int getStatus() { return vStatus; @@ -1020,15 +1020,15 @@ public class FBObject { public final String getStatusString() { return getStatusString(vStatus); } - + public static final String getStatusString(int fbStatus) { switch(fbStatus) { case -1: return "NOT A FBO"; - + case GL.GL_FRAMEBUFFER_COMPLETE: return "OK"; - + case GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: return("FBO incomplete attachment\n"); case GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: @@ -1043,21 +1043,21 @@ public class FBObject { return("FBO missing read buffer"); case GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: return("FBO missing multisample buffer"); - case GL3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: + case GL3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: return("FBO missing layer targets"); - + case GL.GL_FRAMEBUFFER_UNSUPPORTED: return("Unsupported FBO format"); case GL2GL3.GL_FRAMEBUFFER_UNDEFINED: return("FBO undefined"); - + case 0: return("FBO implementation fault"); default: return("FBO incomplete, implementation ERROR "+toHexString(fbStatus)); } } - + /** * The status may even be valid if incomplete during transition of attachments. * @see #getStatus() @@ -1066,7 +1066,7 @@ public class FBObject { switch(vStatus) { case GL.GL_FRAMEBUFFER_COMPLETE: return true; - + case GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: case GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: case GL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: @@ -1079,29 +1079,29 @@ public class FBObject { // we are in transition return true; } - + case GL.GL_FRAMEBUFFER_UNSUPPORTED: case GL2GL3.GL_FRAMEBUFFER_UNDEFINED: - - case 0: + + case 0: default: if(DEBUG) { - System.err.println("Framebuffer " + fbName + " is incomplete, status = " + toHexString(vStatus) + + System.err.println("Framebuffer " + fbName + " is incomplete, status = " + toHexString(vStatus) + " : " + getStatusString(vStatus)); } return false; } } - + private static int checkPreGLError(GL gl) { int glerr = gl.glGetError(); if(DEBUG && GL.GL_NO_ERROR != glerr) { System.err.println("Pre-existing GL error: "+toHexString(glerr)); Thread.dumpStack(); } - return glerr; + return glerr; } - + private final boolean checkNoError(GL gl, int err, String exceptionMessage) throws GLException { if(GL.GL_NO_ERROR != err) { if(null != gl) { @@ -1118,17 +1118,17 @@ public class FBObject { private final void checkInitialized() throws GLException { if(!initialized) { throw new GLException("FBO not initialized, call init(GL) first."); - } + } } - + /** * Attaches a {@link Colorbuffer}, i.e. {@link TextureAttachment}, to this FBO's instance at the given attachment point, * selecting the texture data type and format automatically. - * + * *

    Using default min/mag filter {@link GL#GL_NEAREST} and default wrapS/wrapT {@link GL#GL_CLAMP_TO_EDGE}.

    - * + * *

    Leaves the FBO bound.

    - * + * * @param gl the current GL context * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] * @param alpha set to true if you request alpha channel, otherwise false; @@ -1140,18 +1140,18 @@ public class FBObject { return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, createColorTextureAttachment(gl.getGLProfile(), alpha, width, height)); } - + /** * Attaches a {@link Colorbuffer}, i.e. {@link TextureAttachment}, to this FBO's instance at the given attachment point, * selecting the texture data type and format automatically. - * + * *

    Leaves the FBO bound.

    - * + * * @param gl the current GL context * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] * @param alpha set to true if you request alpha channel, otherwise false; * @param magFilter if > 0 value for {@link GL#GL_TEXTURE_MAG_FILTER} - * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} + * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} * @param wrapS if > 0 value for {@link GL#GL_TEXTURE_WRAP_S} * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} * @return TextureAttachment instance describing the new attached texture colorbuffer if bound and configured successfully, otherwise GLException is thrown @@ -1162,19 +1162,19 @@ public class FBObject { return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, createColorTextureAttachment(gl.getGLProfile(), alpha, width, height, magFilter, minFilter, wrapS, wrapT)); } - + /** * Attaches a {@link Colorbuffer}, i.e. {@link TextureAttachment}, to this FBO's instance at the given attachment point. - * + * *

    Leaves the FBO bound.

    - * + * * @param gl the current GL context * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] * @param internalFormat internalFormat parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} * @param dataFormat format parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} * @param dataType type parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} * @param magFilter if > 0 value for {@link GL#GL_TEXTURE_MAG_FILTER} - * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} + * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} * @param wrapS if > 0 value for {@link GL#GL_TEXTURE_WRAP_S} * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} * @return TextureAttachment instance describing the new attached texture colorbuffer if bound and configured successfully, otherwise GLException is thrown @@ -1187,10 +1187,10 @@ public class FBObject { return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, createColorTextureAttachment(internalFormat, width, height, dataFormat, dataType, magFilter, minFilter, wrapS, wrapT)); } - + /** * Creates a {@link ColorAttachment}, selecting the format automatically. - * + * * @param alpha set to true if you request alpha channel, otherwise false; * @return uninitialized ColorAttachment instance describing the new attached colorbuffer */ @@ -1203,13 +1203,13 @@ public class FBObject { } return new ColorAttachment(internalFormat, samples, width, height, 0); } - + /** * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment}, to this FBO's instance at the given attachment point, * selecting the format automatically. - * + * *

    Leaves the FBO bound.

    - * + * * @param gl the current GL context * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] * @param alpha set to true if you request alpha channel, otherwise false; @@ -1220,15 +1220,15 @@ public class FBObject { public final ColorAttachment attachColorbuffer(GL gl, int attachmentPoint, boolean alpha) throws GLException { return (ColorAttachment) attachColorbuffer(gl, attachmentPoint, createColorAttachment(alpha)); } - + /** * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment}, to this FBO's instance at the given attachment point. - * + * *

    Leaves the FBO bound.

    - * + * * @param gl the current GL context * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] - * @param internalFormat usually {@link GL#GL_RGBA4}, {@link GL#GL_RGB5_A1}, {@link GL#GL_RGB565}, {@link GL#GL_RGB8} or {@link GL#GL_RGBA8} + * @param internalFormat usually {@link GL#GL_RGBA4}, {@link GL#GL_RGB5_A1}, {@link GL#GL_RGB565}, {@link GL#GL_RGB8} or {@link GL#GL_RGBA8} * @return ColorAttachment instance describing the new attached colorbuffer if bound and configured successfully, otherwise GLException is thrown * @throws GLException in case the colorbuffer couldn't be allocated * @throws IllegalArgumentException if internalFormat doesn't reflect a colorbuffer @@ -1238,28 +1238,28 @@ public class FBObject { if( Attachment.Type.COLOR != atype ) { throw new IllegalArgumentException("colorformat invalid: "+toHexString(internalFormat)+", "+this); } - + return (ColorAttachment) attachColorbuffer(gl, attachmentPoint, new ColorAttachment(internalFormat, samples, width, height, 0)); } - + /** - * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment}, + * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment}, * to this FBO's instance at the given attachment point. - * + * *

    * If {@link Colorbuffer} is a {@link TextureAttachment} and is uninitialized, i.e. it's texture name is zero, * a new texture name is generated and setup w/ the texture parameter.
    * Otherwise, i.e. texture name is not zero, the passed TextureAttachment texA is - * considered complete and assumed matching this FBO requirement. A GL error may occur is the latter is untrue. + * considered complete and assumed matching this FBO requirement. A GL error may occur is the latter is untrue. *

    - * + * *

    Leaves the FBO bound.

    - * + * * @param gl * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] - * @param colbuf the to be attached {@link Colorbuffer} + * @param colbuf the to be attached {@link Colorbuffer} * @return newly attached {@link Colorbuffer} instance if bound and configured successfully, otherwise GLException is thrown - * @throws GLException in case the colorbuffer couldn't be allocated or MSAA has been chosen in case of a {@link TextureAttachment} + * @throws GLException in case the colorbuffer couldn't be allocated or MSAA has been chosen in case of a {@link TextureAttachment} */ public final Colorbuffer attachColorbuffer(GL gl, int attachmentPoint, Colorbuffer colbuf) throws GLException { bind(gl); @@ -1268,13 +1268,13 @@ public class FBObject { private final Colorbuffer attachColorbufferImpl(GL gl, int attachmentPoint, Colorbuffer colbuf) throws GLException { validateAddColorAttachment(attachmentPoint, colbuf); - + final boolean initializedColorbuf = colbuf.initialize(gl); addColorAttachment(attachmentPoint, colbuf); - + if(colbuf instanceof TextureAttachment) { final TextureAttachment texA = (TextureAttachment) colbuf; - + if(samples>0) { removeColorAttachment(attachmentPoint, texA); if(initializedColorbuf) { @@ -1282,14 +1282,14 @@ public class FBObject { } throw new GLException("Texture2D not supported w/ MSAA. If you have enabled MSAA with exisiting texture attachments, you may want to detach them via detachAllTexturebuffer(gl)."); } - + // Set up the color buffer for use as a renderable texture: gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, GL.GL_TEXTURE_2D, texA.getName(), 0); - + if(!ignoreStatus) { - updateStatus(gl); + updateStatus(gl); if(!isStatusValid()) { detachColorbuffer(gl, attachmentPoint, true); throw new GLException("attachTexture2D "+texA+" at "+attachmentPoint+" failed "+getStatusString()+", "+this); @@ -1297,12 +1297,12 @@ public class FBObject { } } else if(colbuf instanceof ColorAttachment) { final ColorAttachment colA = (ColorAttachment) colbuf; - + // Attach the color buffer - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, - GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, + GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, GL.GL_RENDERBUFFER, colA.getName()); - + if(!ignoreStatus) { updateStatus(gl); if(!isStatusValid()) { @@ -1316,7 +1316,7 @@ public class FBObject { } return colbuf; } - + /** * Attaches one depth, stencil or packed-depth-stencil buffer to this FBO's instance, * selecting the internalFormat automatically. @@ -1325,30 +1325,30 @@ public class FBObject { *

    *

    * In case the desired type or bit-number is not supported, the next available one is chosen. - *

    + *

    *

    * Use {@link #getDepthAttachment()} and/or {@link #getStencilAttachment()} to retrieve details * about the attached buffer. The details cannot be returned, since it's possible 2 buffers * are being created, depth and stencil. *

    - * + * *

    Leaves the FBO bound.

    - * + * * @param gl - * @param atype either {@link Type#DEPTH}, {@link Type#STENCIL} or {@link Type#DEPTH_STENCIL} + * @param atype either {@link Type#DEPTH}, {@link Type#STENCIL} or {@link Type#DEPTH_STENCIL} * @param reqBits desired bits for depth or -1 for default (24 bits) * @throws GLException in case the renderbuffer couldn't be allocated or one is already attached. * @throws IllegalArgumentException * @see #getDepthAttachment() * @see #getStencilAttachment() */ - public final void attachRenderbuffer(GL gl, Attachment.Type atype, int reqBits) throws GLException, IllegalArgumentException { + public final void attachRenderbuffer(GL gl, Attachment.Type atype, int reqBits) throws GLException, IllegalArgumentException { if( 0 > reqBits ) { reqBits = 24; - } + } final int internalFormat; int internalStencilFormat = -1; - + switch ( atype ) { case DEPTH: if( 32 <= reqBits && depth32Avail ) { @@ -1356,10 +1356,10 @@ public class FBObject { } else if( 24 <= reqBits && depth24Avail ) { internalFormat = GL.GL_DEPTH_COMPONENT24; } else { - internalFormat = GL.GL_DEPTH_COMPONENT16; + internalFormat = GL.GL_DEPTH_COMPONENT16; } break; - + case STENCIL: if( 16 <= reqBits && stencil16Avail ) { internalFormat = GL2GL3.GL_STENCIL_INDEX16; @@ -1370,10 +1370,10 @@ public class FBObject { } else if( 1 <= reqBits && stencil01Avail ) { internalFormat = GL.GL_STENCIL_INDEX1; } else { - throw new GLException("stencil buffer n/a"); + throw new GLException("stencil buffer n/a"); } break; - + case DEPTH_STENCIL: if( packedDepthStencilAvail ) { internalFormat = GL.GL_DEPTH24_STENCIL8; @@ -1381,7 +1381,7 @@ public class FBObject { if( 24 <= reqBits && depth24Avail ) { internalFormat = GL.GL_DEPTH_COMPONENT24; } else { - internalFormat = GL.GL_DEPTH_COMPONENT16; + internalFormat = GL.GL_DEPTH_COMPONENT16; } if( stencil08Avail ) { internalStencilFormat = GL.GL_STENCIL_INDEX8; @@ -1397,17 +1397,17 @@ public class FBObject { default: throw new IllegalArgumentException("only depth/stencil types allowed, was "+atype+", "+this); } - + attachRenderbufferImpl(gl, atype, internalFormat); - + if(0<=internalStencilFormat) { attachRenderbufferImpl(gl, Attachment.Type.STENCIL, internalStencilFormat); } } - + /** * Attaches one depth, stencil or packed-depth-stencil buffer to this FBO's instance, - * depending on the internalFormat. + * depending on the internalFormat. *

    * Stencil and depth buffer can be attached only once. *

    @@ -1416,9 +1416,9 @@ public class FBObject { * about the attached buffer. The details cannot be returned, since it's possible 2 buffers * are being created, depth and stencil. *

    - * + * *

    Leaves the FBO bound.

    - * + * * @param gl the current GL context * @param internalFormat {@link GL#GL_DEPTH_COMPONENT16}, {@link GL#GL_DEPTH_COMPONENT24}, {@link GL#GL_DEPTH_COMPONENT32}, * {@link GL#GL_STENCIL_INDEX1}, {@link GL#GL_STENCIL_INDEX4}, {@link GL#GL_STENCIL_INDEX8} @@ -1435,19 +1435,19 @@ public class FBObject { } attachRenderbufferImpl(gl, atype, internalFormat); } - + protected final void attachRenderbufferImpl(GL gl, Attachment.Type atype, int internalFormat) throws GLException { if( null != depth && ( Attachment.Type.DEPTH == atype || Attachment.Type.DEPTH_STENCIL == atype ) ) { throw new GLException("FBO depth buffer already attached (rb "+depth+"), type is "+atype+", "+toHexString(internalFormat)+", "+this); - } + } if( null != stencil && ( Attachment.Type.STENCIL== atype || Attachment.Type.DEPTH_STENCIL == atype ) ) { throw new GLException("FBO stencil buffer already attached (rb "+stencil+"), type is "+atype+", "+toHexString(internalFormat)+", "+this); } bind(gl); - + attachRenderbufferImpl2(gl, atype, internalFormat); } - + private final void attachRenderbufferImpl2(GL gl, Attachment.Type atype, int internalFormat) throws GLException { if( Attachment.Type.DEPTH == atype ) { if(null == depth) { @@ -1486,10 +1486,10 @@ public class FBObject { } else if( Attachment.Type.STENCIL == atype ) { gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, stencil.getName()); } else if( Attachment.Type.DEPTH_STENCIL == atype ) { - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, depth.getName()); + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, depth.getName()); gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, stencil.getName()); } - + if(!ignoreStatus) { updateStatus(gl); if( !isStatusValid() ) { @@ -1500,13 +1500,13 @@ public class FBObject { if(DEBUG) { System.err.println("FBObject.attachRenderbuffer.X: [attachmentType "+atype+", iformat "+toHexString(internalFormat)+"]: "+this); - } + } } - + /** - * Detaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment}. + * Detaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment}. *

    Leaves the FBO bound!

    - * + * * @param gl * @param attachmentPoint * @param dispose true if the Colorbuffer shall be disposed @@ -1515,26 +1515,26 @@ public class FBObject { */ public final Colorbuffer detachColorbuffer(GL gl, int attachmentPoint, boolean dispose) throws IllegalArgumentException { bind(gl); - + final Colorbuffer res = detachColorbufferImpl(gl, attachmentPoint, dispose ? DetachAction.DISPOSE : DetachAction.NONE); if(null == res) { - throw new IllegalArgumentException("ColorAttachment at "+attachmentPoint+", not attached, "+this); + throw new IllegalArgumentException("ColorAttachment at "+attachmentPoint+", not attached, "+this); } if(DEBUG) { System.err.println("FBObject.detachColorbuffer.X: [attachmentPoint "+attachmentPoint+", dispose "+dispose+"]: "+res+", "+this); } return res; } - + private final Colorbuffer detachColorbufferImpl(GL gl, int attachmentPoint, DetachAction detachAction) { Colorbuffer colbuf = colorAttachmentPoints[attachmentPoint]; // shortcut, don't validate here - + if(null == colbuf) { return null; } - + removeColorAttachment(attachmentPoint, colbuf); - + if(colbuf instanceof TextureAttachment) { final TextureAttachment texA = (TextureAttachment) colbuf; if( 0 != texA.getName() ) { @@ -1553,7 +1553,7 @@ public class FBObject { if(DetachAction.RECREATE == detachAction) { if(samples == 0) { // stay non MSAA - texA.setSize(width, height); + texA.setSize(width, height); } else { // switch to MSAA colbuf = createColorAttachment(hasAlpha(texA.format)); @@ -1563,8 +1563,8 @@ public class FBObject { } else if(colbuf instanceof ColorAttachment) { final ColorAttachment colA = (ColorAttachment) colbuf; if( 0 != colA.getName() ) { - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, - GL.GL_COLOR_ATTACHMENT0+attachmentPoint, + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, + GL.GL_COLOR_ATTACHMENT0+attachmentPoint, GL.GL_RENDERBUFFER, 0); switch(detachAction) { case DISPOSE: @@ -1582,9 +1582,9 @@ public class FBObject { } else { // switch to non MSAA if(null != samplingSinkTexture) { - colbuf = createColorTextureAttachment(samplingSinkTexture.format, width, height, - samplingSinkTexture.dataFormat, samplingSinkTexture.dataType, - samplingSinkTexture.magFilter, samplingSinkTexture.minFilter, + colbuf = createColorTextureAttachment(samplingSinkTexture.format, width, height, + samplingSinkTexture.dataFormat, samplingSinkTexture.dataType, + samplingSinkTexture.magFilter, samplingSinkTexture.minFilter, samplingSinkTexture.wrapS, samplingSinkTexture.wrapT); } else { colbuf = createColorTextureAttachment(gl.getGLProfile(), true, width, height); @@ -1595,15 +1595,15 @@ public class FBObject { } return colbuf; } - + private final void freeAllColorbufferImpl(GL gl) { for(int i=0; iLeaves the FBO bound, if initialized!

    *

    * An attached sampling sink texture will be detached as well, see {@link #getSamplingSink()}. - *

    + *

    * @param gl the current GL context */ public final void detachAll(GL gl) { if(null != samplingSink) { samplingSink.detachAll(gl); - } + } detachAllImpl(gl, true/* detachNonColorbuffer */, false /* recreate */); } - - /** - * Detaches all {@link ColorAttachment}s and {@link TextureAttachment}s + + /** + * Detaches all {@link ColorAttachment}s and {@link TextureAttachment}s * and disposes them. *

    Leaves the FBO bound, if initialized!

    *

    * An attached sampling sink texture will be detached as well, see {@link #getSamplingSink()}. - *

    + *

    * @param gl the current GL context */ public final void detachAllColorbuffer(GL gl) { if(null != samplingSink) { samplingSink.detachAllColorbuffer(gl); - } + } detachAllImpl(gl, false/* detachNonColorbuffer */, false /* recreate */); } - - /** + + /** * Detaches all {@link TextureAttachment}s and disposes them. *

    Leaves the FBO bound, if initialized!

    *

    * An attached sampling sink texture will be detached as well, see {@link #getSamplingSink()}. - *

    + *

    * @param gl the current GL context */ public final void detachAllTexturebuffer(GL gl) { @@ -1826,7 +1826,7 @@ public class FBObject { if(null != samplingSink) { samplingSink.detachAllTexturebuffer(gl); } - bind(gl); + bind(gl); for(int i=0; i0 ) { throw new InternalError("Non zero ColorAttachments "+this); } - + if(detachNonColorbuffer) { detachRenderbufferImpl(gl, Attachment.Type.DEPTH_STENCIL, recreate ? DetachAction.RECREATE : DetachAction.DISPOSE); } @@ -1888,7 +1888,7 @@ public class FBObject { System.err.println("FBObject.detachAll.X: [resetNonColorbuffer "+detachNonColorbuffer+", recreate "+recreate+"]: "+this); } } - + /** * @param gl the current GL context */ @@ -1903,9 +1903,9 @@ public class FBObject { if( null != samplingSink && samplingSink.isInitialized() ) { samplingSink.destroy(gl); } - + detachAllImpl(gl, true /* detachNonColorbuffer */, false /* recreate */); - + // cache FB names, preset exposed to zero, // braking ties w/ GL/GLContext link to getReadFramebuffer()/getWriteFramebuffer() final int fb_cache = fbName; @@ -1915,7 +1915,7 @@ public class FBObject { if(0!=fb_cache) { name[0] = fb_cache; gl.glDeleteFramebuffers(1, name, 0); - } + } initialized = false; bound = false; if(DEBUG) { @@ -1933,14 +1933,14 @@ public class FBObject { final boolean depthMismatch = ( null != depth && null == samplingSink.depth ) || ( null != depth && null != samplingSink.depth && depth.format != samplingSink.depth.format ); - + final boolean stencilMismatch = ( null != stencil && null == samplingSink.stencil ) || ( null != stencil && null != samplingSink.stencil && - stencil.format != samplingSink.stencil.format ); - - return depthMismatch || stencilMismatch; + stencil.format != samplingSink.stencil.format ); + + return depthMismatch || stencilMismatch; } - + /** * Manually reset the MSAA sampling sink, if used. *

    @@ -1948,7 +1948,7 @@ public class FBObject { * a new sampling sink is being created. *

    *

    - * Automatically called by {@link #reset(GL, int, int, int, boolean)} + * Automatically called by {@link #reset(GL, int, int, int, boolean)} * and {@link #syncSamplingSink(GL)}. *

    *

    @@ -1967,58 +1967,58 @@ public class FBObject { } return; } - + if(null == samplingSink ) { samplingSink = new FBObject(); } - + if(!samplingSink.initialized) { samplingSink.init(gl, width, height, 0); } - + boolean sampleSinkSizeMismatch = sampleSinkSizeMismatch(); boolean sampleSinkTexMismatch = sampleSinkTexMismatch(); boolean sampleSinkDepthStencilMismatch = sampleSinkDepthStencilMismatch(); - + /** if(DEBUG) { System.err.println("FBObject.resetSamplingSink.0: \n\tTHIS "+this+",\n\tSINK "+samplesSink+ "\n\t size "+sampleSinkSizeMismatch +", tex "+sampleSinkTexMismatch +", depthStencil "+sampleSinkDepthStencilMismatch); } */ - + if(!sampleSinkSizeMismatch && !sampleSinkTexMismatch && !sampleSinkDepthStencilMismatch) { - // all properties match .. - return; + // all properties match .. + return; } - + unbind(gl); - + if(DEBUG) { System.err.println("FBObject.resetSamplingSink: BEGIN\n\tTHIS "+this+",\n\tSINK "+samplingSink+ "\n\t size "+sampleSinkSizeMismatch +", tex "+sampleSinkTexMismatch +", depthStencil "+sampleSinkDepthStencilMismatch); } - + if( sampleSinkDepthStencilMismatch ) { samplingSink.detachAllRenderbuffer(gl); } - + if( sampleSinkSizeMismatch ) { samplingSink.reset(gl, width, height); } - + if(null == samplingSinkTexture) { samplingSinkTexture = samplingSink.attachTexture2D(gl, 0, true); } else if( 0 == samplingSinkTexture.getName() ) { samplingSinkTexture.setSize(width, height); samplingSink.attachColorbuffer(gl, 0, samplingSinkTexture); } - + if( sampleSinkDepthStencilMismatch ) { samplingSink.attachRenderbuffer(gl, depth.format); if( null != stencil && !isDepthStencilPackedFormat() ) { samplingSink.attachRenderbuffer(gl, stencil.format); } - } - + } + sampleSinkSizeMismatch = sampleSinkSizeMismatch(); sampleSinkTexMismatch = sampleSinkTexMismatch(); sampleSinkDepthStencilMismatch = sampleSinkDepthStencilMismatch(); @@ -2026,21 +2026,21 @@ public class FBObject { throw new InternalError("Samples sink mismatch after reset: \n\tTHIS "+this+",\n\t SINK "+samplingSink+ "\n\t size "+sampleSinkSizeMismatch +", tex "+sampleSinkTexMismatch +", depthStencil "+sampleSinkDepthStencilMismatch); } - + if(DEBUG) { System.err.println("FBObject.resetSamplingSink: END\n\tTHIS "+this+",\n\tSINK "+samplingSink+ "\n\t size "+sampleSinkSizeMismatch +", tex "+sampleSinkTexMismatch +", depthStencil "+sampleSinkDepthStencilMismatch); } } - + /** * Setting this FBO sampling sink. * @param newSamplingSink the new FBO sampling sink to use, or null to remove current sampling sink - * @return the previous sampling sink or null if none was attached + * @return the previous sampling sink or null if none was attached * @throws GLException if this FBO doesn't use MSAA or the given sink uses MSAA itself */ public FBObject setSamplingSink(FBObject newSamplingSink) throws GLException { - final FBObject prev = samplingSink; + final FBObject prev = samplingSink; if( null == newSamplingSink) { samplingSink = null; samplingSinkTexture = null; @@ -2056,14 +2056,14 @@ public class FBObject { samplingSinkDirty = true; return prev; } - - /** + + /** * Bind this FBO, i.e. bind write framebuffer to {@link #getWriteFramebuffer()}. - * - *

    If multisampling is used, it sets the read framebuffer to the sampling sink {@link #getWriteFramebuffer()}, + * + *

    If multisampling is used, it sets the read framebuffer to the sampling sink {@link #getWriteFramebuffer()}, * if full FBO is supported.

    - * - *

    + * + *

    * In case you have attached more than one color buffer, * you may want to setup {@link GL2GL3#glDrawBuffers(int, int[], int)}. *

    @@ -2079,7 +2079,7 @@ public class FBObject { gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, getReadFramebuffer()); } else { // one for all - gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, getWriteFramebuffer()); + gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, getWriteFramebuffer()); } bound = true; @@ -2087,29 +2087,29 @@ public class FBObject { } } - /** + /** * Unbind this FBO, i.e. bind read and write framebuffer to default, see {@link GLBase#getDefaultDrawFramebuffer()}. - * - *

    If full FBO is supported, sets the read and write framebuffer individually to default, hence not disturbing + * + *

    If full FBO is supported, sets the read and write framebuffer individually to default, hence not disturbing * an optional operating MSAA FBO, see {@link GLBase#getDefaultReadFramebuffer()} and {@link GLBase#getDefaultDrawFramebuffer()}

    - * + * * @param gl the current GL context * @throws GLException */ public final void unbind(GL gl) throws GLException { if(bound) { if(fullFBOSupport) { - // default read/draw buffers, may utilize GLContext/GLDrawable override of + // default read/draw buffers, may utilize GLContext/GLDrawable override of // GLContext.getDefaultDrawFramebuffer() and GLContext.getDefaultReadFramebuffer() gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, 0); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, 0); } else { - gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer + gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer } bound = false; } } - + /** * Method simply marks this FBO unbound w/o interfering w/ the bound framebuffer as perfomed by {@link #unbind(GL)}. *

    @@ -2121,22 +2121,22 @@ public class FBObject { bound = false; } - /** + /** * Returns true if framebuffer object is bound via {@link #bind(GL)}, otherwise false. *

    * Method verifies the bound state via {@link GL#getBoundFramebuffer(int)}. *

    * @param gl the current GL context */ - public final boolean isBound(GL gl) { + public final boolean isBound(GL gl) { bound = bound && fbName != gl.getBoundFramebuffer(GL.GL_FRAMEBUFFER) ; return bound; } - + /** Returns true if framebuffer object is bound via {@link #bind(GL)}, otherwise false. */ public final boolean isBound() { return bound; } - - /** + + /** * If multisampling is being used and flagged dirty by a previous call of {@link #bind(GL)} or after initialization, * the msaa-buffers are sampled to it's sink {@link #getSamplingSink()}. *

    @@ -2147,7 +2147,7 @@ public class FBObject { *

    *

    * Method always resets the framebuffer binding to default in the end. - * If full FBO is supported, sets the read and write framebuffer individually to default after sampling, hence not disturbing + * If full FBO is supported, sets the read and write framebuffer individually to default after sampling, hence not disturbing * an optional operating MSAA FBO, see {@link GLBase#getDefaultReadFramebuffer()} and {@link GLBase#getDefaultDrawFramebuffer()} *

    *

    @@ -2155,10 +2155,10 @@ public class FBObject { * you may want to call {@link GL#glBindFramebuffer(int, int) glBindFramebuffer}({@link GL2GL3#GL_READ_FRAMEBUFFER}, {@link #getReadFramebuffer()}); *

    *

    Leaves the FBO unbound.

    - * + * * @param gl the current GL context * @param ta {@link TextureAttachment} to use, prev. attached w/ {@link #attachTexture2D(GL, int, boolean, int, int, int, int) attachTexture2D(..)} - * @throws IllegalArgumentException + * @throws IllegalArgumentException */ public final void syncSamplingSink(GL gl) { markUnbound(); @@ -2170,30 +2170,30 @@ public class FBObject { gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, samplingSink.getWriteFramebuffer()); ((GL2GL3)gl).glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, // since MSAA is supported, casting to GL2GL3 is OK GL.GL_COLOR_BUFFER_BIT, GL.GL_NEAREST); - checkNoError(null, gl.glGetError(), "FBObject syncSampleSink"); // throws GLException if error + checkNoError(null, gl.glGetError(), "FBObject syncSampleSink"); // throws GLException if error } if(fullFBOSupport) { - // default read/draw buffers, may utilize GLContext/GLDrawable override of + // default read/draw buffers, may utilize GLContext/GLDrawable override of // GLContext.getDefaultDrawFramebuffer() and GLContext.getDefaultReadFramebuffer() gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, 0); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, 0); } else { - gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer + gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer } } - - /** + + /** * Bind the given texture colorbuffer. - * + * *

    If using multiple texture units, ensure you call {@link GL#glActiveTexture(int)} first!

    - * + * *

    {@link #syncSamplingSink(GL)} is being called

    - * + * *

    Leaves the FBO unbound!

    - * + * * @param gl the current GL context * @param ta {@link TextureAttachment} to use, prev. attached w/ {@link #attachTexture2D(GL, int, boolean, int, int, int, int) attachTexture2D(..)} - * @throws IllegalArgumentException + * @throws IllegalArgumentException */ public final void use(GL gl, TextureAttachment ta) throws IllegalArgumentException { if(null == ta) { throw new IllegalArgumentException("Null TextureAttachment, this: "+toString()); } @@ -2201,26 +2201,26 @@ public class FBObject { gl.glBindTexture(GL.GL_TEXTURE_2D, ta.getName()); // use it .. } - /** + /** * Unbind texture, ie bind 'non' texture 0 - * + * *

    Leaves the FBO unbound.

    - */ + */ public final void unuse(GL gl) { unbind(gl); gl.glBindTexture(GL.GL_TEXTURE_2D, 0); // don't use it } - /** @see GL#hasFullFBOSupport() */ + /** @see GL#hasFullFBOSupport() */ public final boolean hasFullFBOSupport() throws GLException { checkInitialized(); return this.fullFBOSupport; } - - /** + + /** * Returns true if renderbuffer accepts internal format {@link GL#GL_RGB8} and {@link GL#GL_RGBA8}, otherwise false. * @throws GLException if {@link #init(GL)} hasn't been called. */ public final boolean supportsRGBA8() throws GLException { checkInitialized(); return rgba8Avail; } - - /** + + /** * Returns true if {@link GL#GL_DEPTH_COMPONENT16}, {@link GL#GL_DEPTH_COMPONENT24} or {@link GL#GL_DEPTH_COMPONENT32} is supported, otherwise false. * @param bits 16, 24 or 32 bits * @throws GLException if {@link #init(GL)} hasn't been called. @@ -2228,14 +2228,14 @@ public class FBObject { public final boolean supportsDepth(int bits) throws GLException { checkInitialized(); switch(bits) { - case 16: return true; + case 16: return true; case 24: return depth24Avail; case 32: return depth32Avail; - default: return false; + default: return false; } } - - /** + + /** * Returns true if {@link GL#GL_STENCIL_INDEX1}, {@link GL#GL_STENCIL_INDEX4}, {@link GL#GL_STENCIL_INDEX8} or {@link GL2GL3#GL_STENCIL_INDEX16} is supported, otherwise false. * @param bits 1, 4, 8 or 16 bits * @throws GLException if {@link #init(GL)} hasn't been called. @@ -2243,34 +2243,34 @@ public class FBObject { public final boolean supportsStencil(int bits) throws GLException { checkInitialized(); switch(bits) { - case 1: return stencil01Avail; + case 1: return stencil01Avail; case 4: return stencil04Avail; case 8: return stencil08Avail; case 16: return stencil16Avail; - default: return false; + default: return false; } } - - /** + + /** * Returns true if {@link GL#GL_DEPTH24_STENCIL8} is supported, otherwise false. * @throws GLException if {@link #init(GL)} hasn't been called. */ public final boolean supportsPackedDepthStencil() throws GLException { checkInitialized(); return packedDepthStencilAvail; } - + /** * Returns the maximum number of colorbuffer attachments. * @throws GLException if {@link #init(GL)} hasn't been called. */ public final int getMaxColorAttachments() throws GLException { checkInitialized(); return maxColorAttachments; } - + public final int getMaxTextureSize() throws GLException { checkInitialized(); return this.maxTextureSize; } public final int getMaxRenderbufferSize() throws GLException { checkInitialized(); return this.maxRenderbufferSize; } - + /** @see GL#getMaxRenderbufferSamples() */ public final int getMaxSamples() throws GLException { checkInitialized(); return this.maxSamples; } - + /** - * Returns true if this instance has been initialized with {@link #reset(GL, int, int)} + * Returns true if this instance has been initialized with {@link #reset(GL, int, int)} * or {@link #reset(GL, int, int, int, boolean)}, otherwise false */ public final boolean isInitialized() { return initialized; } @@ -2283,43 +2283,43 @@ public class FBObject { /** Returns the framebuffer name to render to. */ public final int getWriteFramebuffer() { return fbName; } /** Returns the framebuffer name to read from. Depending on multisampling, this may be a different framebuffer. */ - public final int getReadFramebuffer() { return ( samples > 0 ) ? samplingSink.getReadFramebuffer() : fbName; } - public final int getDefaultReadBuffer() { return GL.GL_COLOR_ATTACHMENT0; } + public final int getReadFramebuffer() { return ( samples > 0 ) ? samplingSink.getReadFramebuffer() : fbName; } + public final int getDefaultReadBuffer() { return GL.GL_COLOR_ATTACHMENT0; } /** Return the number of color/texture attachments */ public final int getColorAttachmentCount() { return colorAttachmentCount; } - /** Return the stencil {@link RenderAttachment} attachment, if exist. Maybe share the same {@link Attachment#getName()} as {@link #getDepthAttachment()}, if packed depth-stencil is being used. */ + /** Return the stencil {@link RenderAttachment} attachment, if exist. Maybe share the same {@link Attachment#getName()} as {@link #getDepthAttachment()}, if packed depth-stencil is being used. */ public final RenderAttachment getStencilAttachment() { return stencil; } - /** Return the depth {@link RenderAttachment} attachment. Maybe share the same {@link Attachment#getName()} as {@link #getStencilAttachment()}, if packed depth-stencil is being used. */ + /** Return the depth {@link RenderAttachment} attachment. Maybe share the same {@link Attachment#getName()} as {@link #getStencilAttachment()}, if packed depth-stencil is being used. */ public final RenderAttachment getDepthAttachment() { return depth; } - - /** Return the complete multisampling {@link FBObject} sink, if using multisampling. */ + + /** Return the complete multisampling {@link FBObject} sink, if using multisampling. */ public final FBObject getSamplingSinkFBO() { return samplingSink; } - - /** Return the multisampling {@link TextureAttachment} sink, if using multisampling. */ + + /** Return the multisampling {@link TextureAttachment} sink, if using multisampling. */ public final TextureAttachment getSamplingSink() { return samplingSinkTexture; } - /** - * Returns true if the multisampling colorbuffer (msaa-buffer) + /** + * Returns true if the multisampling colorbuffer (msaa-buffer) * has been flagged dirty by a previous call of {@link #bind(GL)}, * otherwise false. */ public final boolean isSamplingBufferDirty() { return samplingSinkDirty; } - + int objectHashCode() { return super.hashCode(); } - + public final String toString() { - final String caps = null != colorAttachmentPoints ? Arrays.asList(colorAttachmentPoints).toString() : null ; + final String caps = null != colorAttachmentPoints ? Arrays.asList(colorAttachmentPoints).toString() : null ; return "FBO[name r/w "+fbName+"/"+getReadFramebuffer()+", init "+initialized+", bound "+bound+", size "+width+"x"+height+ ", samples "+samples+"/"+maxSamples+", depth "+depth+", stencil "+stencil+ ", color attachments: "+colorAttachmentCount+"/"+maxColorAttachments+ ": "+caps+", msaa-sink "+samplingSinkTexture+", hasSamplesSink "+(null != samplingSink)+ ", state "+getStatusString()+", obj "+toHexString(objectHashCode())+"]"; } - + private final void updateStatus(GL gl) { if( 0 == fbName ) { vStatus = -1; } else { vStatus = gl.glCheckFramebufferStatus(GL.GL_FRAMEBUFFER); } - } + } } diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java index bec05a0bd..ce58d29c1 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -58,14 +58,14 @@ import jogamp.opengl.GLDrawableImpl; * * and setup a {@link com.jogamp.newt.Window#setWindowDestroyNotifyAction(Runnable) custom toolkit destruction} issuing {@link #windowDestroyNotifyOp()}. *

    - *

    + *

    * See example {@link com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT TestGLAutoDrawableDelegateNEWT}. *

    */ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAutoDrawable { /** * @param drawable a valid {@link GLDrawable}, may not be {@link GLDrawable#isRealized() realized} yet. - * @param context a valid {@link GLContext}, + * @param context a valid {@link GLContext}, * may not have been made current (created) yet, * may not be associated w/ drawable yet, * may be null for lazy initialization @@ -84,7 +84,7 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto this.upstreamWidget = upstreamWidget; this.lock = ( null != lock ) ? lock : LockFactory.createRecursiveLock() ; } - + // // expose default methods // @@ -93,40 +93,40 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto public final void windowRepaintOp() { super.defaultWindowRepaintOp(); } - + /** Implementation to handle resize events from the windowing system. All required locks are being claimed. */ public final void windowResizedOp(int newWidth, int newHeight) { super.defaultWindowResizedOp(newWidth, newHeight); } - - /** + + /** * Implementation to handle destroy notifications from the windowing system. - * + * *

    - * If the {@link NativeSurface} does not implement {@link WindowClosingProtocol} + * If the {@link NativeSurface} does not implement {@link WindowClosingProtocol} * or {@link WindowClosingMode#DISPOSE_ON_CLOSE} is enabled (default), * a thread safe destruction is being induced. - *

    + *

    */ public final void windowDestroyNotifyOp() { super.defaultWindowDestroyNotifyOp(); } - + // // Complete GLAutoDrawable // - + private Object upstreamWidget; private final RecursiveLock lock; - + @Override protected final RecursiveLock getLock() { return lock; } - + @Override public final Object getUpstreamWidget() { return upstreamWidget; } - + /** * Set the upstream UI toolkit object. * @see #getUpstreamWidget() @@ -134,7 +134,7 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto public final void setUpstreamWidget(Object newUpstreamWidget) { upstreamWidget = newUpstreamWidget; } - + /** * {@inheritDoc} *

    @@ -142,7 +142,7 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto *

    *

    * User still needs to destroy the upstream window, which details are hidden from this aspect. - * This can be performed by overriding {@link #destroyImplInLock()}. + * This can be performed by overriding {@link #destroyImplInLock()}. *

    */ @Override @@ -154,29 +154,29 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto protected void destroyImplInLock() { super.destroyImplInLock(); } - + @Override - public void display() { + public void display() { defaultDisplay(); } - + // // GLDrawable delegation // - + @Override public final GLDrawableFactory getFactory() { return drawable.getFactory(); } - + @Override public final void swapBuffers() throws GLException { defaultSwapBuffers(); } - + @Override public String toString() { return getClass().getSimpleName()+"[ \n\tHelper: " + helper + ", \n\tDrawable: " + drawable + ", \n\tContext: " + context + ", \n\tUpstreamWidget: "+upstreamWidget+ /** ", \n\tFactory: "+factory+ */ "]"; - } + } } diff --git a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java index 21dafecb1..1b4187668 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java +++ b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -48,7 +48,7 @@ import jogamp.opengl.Debug; import com.jogamp.nativewindow.MutableGraphicsConfiguration; /** - * GLEventListenerState is holding {@link GLAutoDrawable} components crucial + * GLEventListenerState is holding {@link GLAutoDrawable} components crucial * to relocating all its {@link GLEventListener} w/ their operating {@link GLContext}, etc. * The components are: *
      @@ -69,8 +69,8 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration; */ public class GLEventListenerState { private static final boolean DEBUG = Debug.debug("GLDrawable") || Debug.debug("GLEventListenerState"); - - private GLEventListenerState(AbstractGraphicsDevice upstreamDevice, boolean proxyOwnsUpstreamDevice, AbstractGraphicsDevice device, + + private GLEventListenerState(AbstractGraphicsDevice upstreamDevice, boolean proxyOwnsUpstreamDevice, AbstractGraphicsDevice device, GLCapabilitiesImmutable caps, GLContext context, int count, GLAnimatorControl anim, boolean animStarted) { this.upstreamDevice = upstreamDevice; @@ -82,19 +82,19 @@ public class GLEventListenerState { this.listenersInit = new boolean[count]; this.anim = anim; this.animStarted = animStarted; - + this.owner = true; } /** - * Returns true, if this instance is the current owner of the components, + * Returns true, if this instance is the current owner of the components, * otherwise false. *

      * Ownership is lost if {@link #moveTo(GLAutoDrawable)} is being called successfully - * and all components are transferred to the new {@link GLAutoDrawable}. + * and all components are transferred to the new {@link GLAutoDrawable}. *

      */ public final boolean isOwner() { return owner; } - + public final int listenerCount() { return listeners.length; } public final AbstractGraphicsDevice upstreamDevice; @@ -103,10 +103,10 @@ public class GLEventListenerState { public final GLCapabilitiesImmutable caps; public final GLContext context; public final GLEventListener[] listeners; - public final boolean[] listenersInit; + public final boolean[] listenersInit; public final GLAnimatorControl anim; public final boolean animStarted; - + private boolean owner; /** @@ -127,25 +127,25 @@ public class GLEventListenerState { private static AbstractGraphicsDevice cloneDevice(AbstractGraphicsDevice aDevice) { return (AbstractGraphicsDevice) aDevice.clone(); } - + /** - * Moves all GLEventListenerState components from the given {@link GLAutoDrawable} + * Moves all GLEventListenerState components from the given {@link GLAutoDrawable} * to a newly created instance. *

      * Note that all components are removed from the {@link GLAutoDrawable}, * i.e. the {@link GLContext}, all {@link GLEventListener}. *

      - *

      + *

      * If the {@link GLAutoDrawable} was added to a {@link GLAnimatorControl}, it is removed * and the {@link GLAnimatorControl} added to the GLEventListenerState. *

      *

      - * The returned GLEventListenerState instance is the {@link #isOwner() owner of the components}. + * The returned GLEventListenerState instance is the {@link #isOwner() owner of the components}. *

      - * + * * @param a {@link GLAutoDrawable} source to move components from * @return new GLEventListenerState instance {@link #isOwner() owning} moved components. - * + * * @see #moveTo(GLAutoDrawable) */ public static GLEventListenerState moveFrom(GLAutoDrawable a) { @@ -154,16 +154,16 @@ public class GLEventListenerState { if( null != aAnim ) { aAnimStarted = aAnim.isStarted(); aAnim.remove(a); // also handles ECT - } else { + } else { aAnimStarted = false; } - + final GLEventListenerState glls; final NativeSurface aSurface = a.getNativeSurface(); final boolean surfaceLocked = false; // NativeSurface.LOCK_SURFACE_NOT_READY < aSurface.lockSurface(); try { final int aSz = a.getGLEventListenerCount(); - + // Create new AbstractGraphicsScreen w/ cloned AbstractGraphicsDevice for future GLAutoDrawable // allowing this AbstractGraphicsDevice to loose ownership -> not closing display/device! final AbstractGraphicsConfiguration aCfg = aSurface.getGraphicsConfiguration(); @@ -171,7 +171,7 @@ public class GLEventListenerState { final AbstractGraphicsDevice aDevice1 = aCfg.getScreen().getDevice(); final AbstractGraphicsDevice aDevice2 = cloneDevice(aDevice1); aDevice1.clearHandleOwner(); // don't close device handle - if( DEBUG ) { + if( DEBUG ) { System.err.println("GLEventListenerState.moveFrom.0a: orig 0x"+Integer.toHexString(aDevice1.hashCode())+", "+aDevice1); System.err.println("GLEventListenerState.moveFrom.0b: pres 0x"+Integer.toHexString(aDevice2.hashCode())+", "+aDevice2); System.err.println("GLEventListenerState.moveFrom.1: "+aSurface.getClass().getName()/*+", "+aSurface*/); @@ -203,9 +203,9 @@ public class GLEventListenerState { } aUpDevice2 = _aUpDevice2; } - - glls = new GLEventListenerState(aUpDevice2, proxyOwnsUpstreamDevice, aDevice2, caps, a.getContext(), aSz, aAnim, aAnimStarted); - + + glls = new GLEventListenerState(aUpDevice2, proxyOwnsUpstreamDevice, aDevice2, caps, a.getContext(), aSz, aAnim, aAnimStarted); + // // remove and cache all GLEventListener and their init-state // @@ -213,41 +213,41 @@ public class GLEventListenerState { final GLEventListener l = a.getGLEventListener(0); glls.listenersInit[i] = a.getGLEventListenerInitState(l); glls.listeners[i] = a.removeGLEventListener( l ); - } - + } + // // trigger glFinish to sync GL ctx // a.invoke(true, glFinish); - + a.setContext( null, false ); - + } finally { if( surfaceLocked ) { aSurface.unlockSurface(); } - } - + } + return glls; } /** - * Moves all GLEventListenerState components to the given {@link GLAutoDrawable} + * Moves all GLEventListenerState components to the given {@link GLAutoDrawable} * from this instance, while loosing {@link #isOwner() ownership}. - *

      + *

      * If the previous {@link GLAutoDrawable} was removed from a {@link GLAnimatorControl} by previous {@link #moveFrom(GLAutoDrawable)}, * the given {@link GLAutoDrawable} is added to the cached {@link GLAnimatorControl}. - * This operation is skipped, if the given {@link GLAutoDrawable} is already added to a {@link GLAnimatorControl} instance. + * This operation is skipped, if the given {@link GLAutoDrawable} is already added to a {@link GLAnimatorControl} instance. *

      *

      - * Note: After this operation, the GLEventListenerState reference should be released. + * Note: After this operation, the GLEventListenerState reference should be released. *

      - * + * * @param a {@link GLAutoDrawable} destination to move GLEventListenerState components to - * + * * * @throws GLException if this preserved {@link AbstractGraphicsDevice} is incompatible w/ the given destination one. - * + * * @see #moveFrom(GLAutoDrawable) * @see #isOwner() */ @@ -261,22 +261,22 @@ public class GLEventListenerState { if( aPaused ) { aAnim.resume(); } - } else { + } else { aPaused = false; } - + final List aGLCmds = new ArrayList(); final int aSz = listenerCount(); - + final NativeSurface aSurface = a.getNativeSurface(); final boolean surfaceLocked = false; // NativeSurface.LOCK_SURFACE_NOT_READY < aSurface.lockSurface(); final boolean aRealized; try { - + final MutableGraphicsConfiguration aCfg = (MutableGraphicsConfiguration) aSurface.getGraphicsConfiguration(); /** final GLCapabilitiesImmutable aCaps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); - if( caps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) != aCaps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) || + if( caps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) != aCaps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) || caps.getVisualID(VisualIDHolder.VIDType.NATIVE) != aCaps.getVisualID(VisualIDHolder.VIDType.NATIVE) ) { throw new GLException("Incompatible Capabilities - Prev-Holder: "+caps+", New-Holder "+caps); } */ @@ -285,8 +285,8 @@ public class GLEventListenerState { if( !aDevice1.getUniqueID().equals( aDevice2.getUniqueID() ) ) { throw new GLException("Incompatible devices: Preserved <"+aDevice2.getUniqueID()+">, target <"+aDevice1.getUniqueID()+">"); } - - // collect optional upstream surface info + + // collect optional upstream surface info final ProxySurface aProxy; final NativeSurface aUpSurface; if(aSurface instanceof ProxySurface) { @@ -302,8 +302,8 @@ public class GLEventListenerState { } if( null==aUpSurface && null != upstreamDevice ) { throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = true, New-Holder = false"); - } - + } + // Destroy and remove currently associated GLContext, if any (will be replaced) a.setContext( null, true ); aRealized = a.isRealized(); @@ -311,7 +311,7 @@ public class GLEventListenerState { // Unrealize due to device dependencies of an upstream surface, e.g. EGLUpstreamSurfaceHook a.getDelegatedDrawable().setRealized(false); } - + // Set new Screen and close previous one { if( DEBUG ) { @@ -319,13 +319,13 @@ public class GLEventListenerState { System.err.println("GLEventListenerState.moveTo.0b: pres 0x"+Integer.toHexString(aDevice2.hashCode())+", "+aDevice2); } DefaultGraphicsDevice.swapDeviceHandleAndOwnership(aDevice1, aDevice2); - aDevice2.close(); + aDevice2.close(); if( DEBUG ) { System.err.println("GLEventListenerState.moveTo.1a: orig 0x"+Integer.toHexString(aDevice1.hashCode())+", "+aDevice1); System.err.println("GLEventListenerState.moveTo.1b: pres 0x"+Integer.toHexString(aDevice2.hashCode())+", "+aDevice2); } } - + // If using a ProxySurface w/ an upstream surface, set new Screen and close previous one on it if( null != aUpSurface ) { final MutableGraphicsConfiguration aUpCfg = (MutableGraphicsConfiguration) aUpSurface.getGraphicsConfiguration(); @@ -339,9 +339,9 @@ public class GLEventListenerState { System.err.println("GLEventListenerState.moveTo.2a: up-orig 0x"+Integer.toHexString(aUpDevice1.hashCode())+", "+aUpDevice1); System.err.println("GLEventListenerState.moveTo.2b: up-pres 0x"+Integer.toHexString(aUpDevice2.hashCode())+", "+aUpDevice2); System.err.println("GLEventListenerState.moveTo.2c: "+aUpSurface.getClass().getName()/*+", "+aUpSurface+", "*/+aProxy.getUpstreamOptionBits(null).toString()); - } + } DefaultGraphicsDevice.swapDeviceHandleAndOwnership(aUpDevice1, aUpDevice2); - aUpDevice2.close(); + aUpDevice2.close(); if( proxyOwnsUpstreamDevice ) { aProxy.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); } @@ -354,7 +354,7 @@ public class GLEventListenerState { throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = false, New-Holder = true"); } } - + if( aRealized && null != aUpSurface ) { a.getDelegatedDrawable().setRealized(true); } @@ -369,7 +369,7 @@ public class GLEventListenerState { } } owner = false; - + // // Trigger GL-Viewport reset and reshape of all initialized GLEventListeners // @@ -389,7 +389,7 @@ public class GLEventListenerState { a.setGLEventListenerInitState(l, listenersInit[i]); listeners[i] = null; } - + if( hasAnimator ) { // prefer already bound animator aAnim.add(a); @@ -410,7 +410,7 @@ public class GLEventListenerState { public boolean run(GLAutoDrawable drawable) { drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); return true; - } + } }; public static GLRunnable glFinish = new GLRunnable() { @@ -418,7 +418,7 @@ public class GLEventListenerState { public boolean run(GLAutoDrawable drawable) { drawable.getGL().glFinish(); return true; - } + } }; public static class ReshapeGLEventListener implements GLRunnable { @@ -430,6 +430,6 @@ public class GLEventListenerState { public boolean run(GLAutoDrawable drawable) { listener.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); return true; - } + } } } diff --git a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java index 14f4be96a..c7aadcd14 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java +++ b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java @@ -28,17 +28,17 @@ package com.jogamp.opengl; /** - * Class holding OpenGL extension strings, commonly used by JOGL's implementation. + * Class holding OpenGL extension strings, commonly used by JOGL's implementation. */ public class GLExtensions { public static final String VERSION_1_2 = "GL_VERSION_1_2"; public static final String VERSION_1_4 = "GL_VERSION_1_4"; public static final String VERSION_1_5 = "GL_VERSION_1_5"; public static final String VERSION_2_0 = "GL_VERSION_2_0"; - + public static final String ARB_debug_output = "GL_ARB_debug_output"; public static final String AMD_debug_output = "GL_AMD_debug_output"; - + public static final String ARB_framebuffer_object = "GL_ARB_framebuffer_object"; public static final String OES_framebuffer_object = "GL_OES_framebuffer_object"; public static final String EXT_framebuffer_object = "GL_EXT_framebuffer_object"; @@ -49,17 +49,17 @@ public class GLExtensions { public static final String OES_depth32 = "GL_OES_depth32"; public static final String OES_packed_depth_stencil = "GL_OES_packed_depth_stencil"; public static final String NV_fbo_color_attachments = "GL_NV_fbo_color_attachments"; - + public static final String ARB_ES2_compatibility = "GL_ARB_ES2_compatibility"; public static final String ARB_ES3_compatibility = "GL_ARB_ES3_compatibility"; - + public static final String EXT_abgr = "GL_EXT_abgr"; public static final String OES_rgb8_rgba8 = "GL_OES_rgb8_rgba8"; public static final String OES_stencil1 = "GL_OES_stencil1"; public static final String OES_stencil4 = "GL_OES_stencil4"; public static final String OES_stencil8 = "GL_OES_stencil8"; public static final String APPLE_float_pixels = "GL_APPLE_float_pixels"; - + public static final String ARB_texture_non_power_of_two = "GL_ARB_texture_non_power_of_two"; public static final String ARB_texture_rectangle = "GL_ARB_texture_rectangle"; public static final String EXT_texture_rectangle = "GL_EXT_texture_rectangle"; @@ -72,15 +72,15 @@ public class GLExtensions { public static final String OES_read_format = "GL_OES_read_format"; public static final String OES_single_precision = "GL_OES_single_precision"; public static final String OES_EGL_image_external = "GL_OES_EGL_image_external"; - + public static final String ARB_gpu_shader_fp64 = "GL_ARB_gpu_shader_fp64"; - public static final String ARB_shader_objects = "GL_ARB_shader_objects"; + public static final String ARB_shader_objects = "GL_ARB_shader_objects"; public static final String ARB_geometry_shader4 = "GL_ARB_geometry_shader4"; - + // // Aliased GLX/WGL/.. extensions // - - public static final String ARB_pixel_format = "GL_ARB_pixel_format"; + + public static final String ARB_pixel_format = "GL_ARB_pixel_format"; public static final String ARB_pbuffer = "GL_ARB_pbuffer"; } diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index 6ef1e0805..ee77f8d2d 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -29,20 +29,20 @@ package com.jogamp.opengl; import java.util.List; -/** - * GLRendererQuirks contains information of known bugs of various GL renderer. +/** + * GLRendererQuirks contains information of known bugs of various GL renderer. * This information allows us to workaround them. *

      * Using centralized quirk identifier enables us to - * locate code dealing w/ it and hence eases it's maintenance. + * locate code dealing w/ it and hence eases it's maintenance. *

      *

      * Some GL_VENDOR and GL_RENDERER strings are - * listed here . + * listed here . *

      */ public class GLRendererQuirks { - /** + /** * Crashes XServer when using double buffered PBuffer with GL_RENDERER: *
        *
      • Mesa DRI Intel(R) Sandybridge Desktop
      • @@ -52,23 +52,23 @@ public class GLRendererQuirks { * For now, it is safe to disable it w/ hw-acceleration. */ public static final int NoDoubleBufferedPBuffer = 0; - + /** On Windows no double buffered bitmaps are guaranteed to be available. */ public static final int NoDoubleBufferedBitmap = 1; /** Crashes application when trying to set EGL swap interval on Android 4.0.3 / Pandaboard ES / PowerVR SGX 540 */ public static final int NoSetSwapInterval = 2; - + /** No offscreen bitmap available, currently true for JOGL's OSX implementation. */ public static final int NoOffscreenBitmap = 3; - + /** SIGSEGV on setSwapInterval() after changing the context's drawable w/ 'Mesa 8.0.4' dri2SetSwapInterval/DRI2 (soft & intel) */ public static final int NoSetSwapIntervalPostRetarget = 4; /** GLSL discard command leads to undefined behavior or won't get compiled if being used. Appears to have happened on Nvidia Tegra2, but seems to be fine now. FIXME: Constrain version. */ public static final int GLSLBuggyDiscard = 5; - - /** + + /** * Non compliant GL context due to a buggy implementation not suitable for use. *

        * Currently, Mesa >= 9.1.3 (may extend back as far as 9.0) OpenGL 3.1 compatibility @@ -82,19 +82,19 @@ public class GLRendererQuirks { *

      *

      *

      - * It still has to be verified whether the AMD OpenGL 3.1 core driver is compliant enought. + * It still has to be verified whether the AMD OpenGL 3.1 core driver is compliant enought. */ public static final int GLNonCompliant = 6; - + /** * The OpenGL Context needs a glFlush() before releasing it, otherwise driver may freeze: *

        *
      • OSX < 10.7.3 - NVidia Driver. Bug 533 and Bug 548 @ https://jogamp.org/bugzilla/.
      • - *
      + *
    */ public static final int GLFlushBeforeRelease = 7; - - /** + + /** * Closing X11 displays may cause JVM crashes or X11 errors with some buggy drivers * while being used in concert w/ OpenGL. *

    @@ -123,14 +123,14 @@ public class GLRendererQuirks { *

    */ public static final int DontCloseX11Display = 8; - + /** - * Need current GL Context when calling new ARB pixel format query functions, + * Need current GL Context when calling new ARB pixel format query functions, * otherwise driver crashes the VM. *

    * Drivers known exposing such bug: *

      - *
    • ATI proprietary Catalyst driver on Windows version ≤ XP. + *
    • ATI proprietary Catalyst driver on Windows version ≤ XP. * TODO: Validate if bug actually relates to 'old' ATI Windows drivers for old GPU's like X300 * regardless of the Windows version.
    • *
    @@ -139,7 +139,7 @@ public class GLRendererQuirks { *

    */ public static final int NeedCurrCtx4ARBPixFmtQueries = 9; - + /** * Need current GL Context when calling new ARB CreateContext function, * otherwise driver crashes the VM. @@ -159,14 +159,14 @@ public class GLRendererQuirks { *

    */ public static final int NeedCurrCtx4ARBCreateContext = 10; - + /** * No full FBO support, i.e. not compliant w/ - *
      + *
        *
      • GL_ARB_framebuffer_object
      • - *
      • EXT_framebuffer_object
      • - *
      • EXT_framebuffer_multisample
      • - *
      • EXT_framebuffer_blit
      • + *
      • EXT_framebuffer_object
      • + *
      • EXT_framebuffer_multisample
      • + *
      • EXT_framebuffer_blit
      • *
      • EXT_packed_depth_stencil
      • *
      . * Drivers known exposing such bug: @@ -180,18 +180,18 @@ public class GLRendererQuirks { * Quirk can also be enabled via property: jogl.fbo.force.min. */ public static final int NoFullFBOSupport = 11; - + /** * GLSL is not compliant or even not stable (crash) *
        *
      • OSX < 10.7.0 (?) - NVidia Driver. Bug 818 @ https://jogamp.org/bugzilla/.
      • - *
      + *
    */ public static final int GLSLNonCompliant = 12; - + /** Number of quirks known. */ public static final int COUNT = 13; - + private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard", "GLNonCompliant", "GLFlushBeforeRelease", "DontCloseX11Display", @@ -218,7 +218,7 @@ public class GLRendererQuirks { bitmask |= 1 << quirk; } _bitmask = bitmask; - } + } /** * @param quirks a list of valid quirks @@ -233,7 +233,7 @@ public class GLRendererQuirks { } _bitmask = bitmask; } - + /** * @param quirk the quirk to be tested * @return true if quirk exist, otherwise false @@ -261,7 +261,7 @@ public class GLRendererQuirks { sb.append("]"); return sb; } - + public final String toString() { return toString(null).toString(); } @@ -273,7 +273,7 @@ public class GLRendererQuirks { public static void validateQuirk(int quirk) throws IllegalArgumentException { if( !( 0 <= quirk && quirk < COUNT ) ) { throw new IllegalArgumentException("Quirks must be in range [0.."+COUNT+"[, but quirk: "+quirk); - } + } } /** diff --git a/src/jogl/classes/com/jogamp/opengl/GLStateKeeper.java b/src/jogl/classes/com/jogamp/opengl/GLStateKeeper.java index 321d4ee57..b98c4431d 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLStateKeeper.java +++ b/src/jogl/classes/com/jogamp/opengl/GLStateKeeper.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -31,12 +31,12 @@ package com.jogamp.opengl; * Interface adding a {@link GLEventListenerState} protocol to {@link GLAutoDrawable}s * or other self-contained compound types combining {@link GLDrawable}, {@link GLContext} and {@link GLEventListener}. *

    - * Implementing classes {@link #isGLStatePreservationSupported() may support} preservation - * of the {@link GLContext} state and it's associated {@link GLEventListener}. - *

    + * Implementing classes {@link #isGLStatePreservationSupported() may support} preservation + * of the {@link GLContext} state and it's associated {@link GLEventListener}. + *

    */ public interface GLStateKeeper { - + /** Listener for preserve and restore notifications. */ public static interface Listener { /** Invoked before preservation. */ @@ -44,14 +44,14 @@ public interface GLStateKeeper { /** Invoked after restoration. */ void glStateRestored(GLStateKeeper glsk); } - - /** + + /** * Sets a {@link Listener}, overriding the old one. * @param l the new {@link Listener}. * @return the previous {@link Listener}. */ public Listener setGLStateKeeperListener(Listener l); - + /** * @return true if GL state preservation is supported in implementation and on current platform, false otherwise. * @see #preserveGLStateAtDestroy(boolean) @@ -59,7 +59,7 @@ public interface GLStateKeeper { * @see #clearPreservedGLState() */ public boolean isGLStatePreservationSupported(); - + /** * If set to true, the next {@link GLAutoDrawable#destroy()} operation will * {@link #pullGLEventListenerState() pull} to preserve the {@link GLEventListenerState}. @@ -68,8 +68,8 @@ public interface GLStateKeeper { * the flag is cleared. *

    *

    - * A preserved {@link GLEventListenerState} will be {@link #pushGLEventListenerState() pushed} - * if realized again. + * A preserved {@link GLEventListenerState} will be {@link #pushGLEventListenerState() pushed} + * if realized again. *

    * @return true if supported and successful, false otherwise. * @see #isGLStatePreservationSupported() @@ -77,21 +77,21 @@ public interface GLStateKeeper { * @see #clearPreservedGLState() */ public boolean preserveGLStateAtDestroy(boolean value); - + /** * Returns the preserved {@link GLEventListenerState} if preservation was performed, - * otherwise null. + * otherwise null. * @see #isGLStatePreservationSupported() * @see #preserveGLStateAtDestroy(boolean) * @see #clearPreservedGLState() */ public GLEventListenerState getPreservedGLState(); - + /** * Clears the preserved {@link GLEventListenerState} from this {@link GLStateKeeper}, without destroying it. - * + * * @return the preserved and cleared {@link GLEventListenerState} if preservation was performed, - * otherwise null. + * otherwise null. * @see #isGLStatePreservationSupported() * @see #preserveGLStateAtDestroy(boolean) * @see #getPreservedGLState() diff --git a/src/jogl/classes/com/jogamp/opengl/GenericGLCapabilitiesChooser.java b/src/jogl/classes/com/jogamp/opengl/GenericGLCapabilitiesChooser.java index 73ec10886..3693f647a 100644 --- a/src/jogl/classes/com/jogamp/opengl/GenericGLCapabilitiesChooser.java +++ b/src/jogl/classes/com/jogamp/opengl/GenericGLCapabilitiesChooser.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -37,7 +37,7 @@ import javax.media.opengl.DefaultGLCapabilitiesChooser; * otherwise uses {@link DefaultGLCapabilitiesChooser} implementation. */ public class GenericGLCapabilitiesChooser extends DefaultGLCapabilitiesChooser { - + @Override public int chooseCapabilities(final CapabilitiesImmutable desired, final List available, diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java index 1f0189aa3..1f715c21a 100644 --- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java +++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl; import com.jogamp.common.GlueGenVersion; @@ -90,16 +90,16 @@ public class JoglVersion extends JogampVersion { sb.append("\tnone").append(Platform.getNewline()); } sb.append(Platform.getNewline()); - return sb; + return sb; } - + public static StringBuilder getAllAvailableCapabilitiesInfo(AbstractGraphicsDevice device, StringBuilder sb) { if(null==sb) { sb = new StringBuilder(); } if(null == device) { device = GLProfile.getDefaultDevice(); - } + } sb.append(Platform.getNewline()).append(Platform.getNewline()); sb.append("Desktop Capabilities: ").append(Platform.getNewline()); getAvailableCapabilitiesInfo(GLDrawableFactory.getDesktopFactory(), device, sb); @@ -107,7 +107,7 @@ public class JoglVersion extends JogampVersion { getAvailableCapabilitiesInfo(GLDrawableFactory.getEGLFactory(), device, sb); return sb; } - + public static StringBuilder getDefaultOpenGLInfo(AbstractGraphicsDevice device, StringBuilder sb, boolean withCapabilitiesInfo) { if(null==sb) { sb = new StringBuilder(); @@ -126,7 +126,7 @@ public class JoglVersion extends JogampVersion { } return sb; } - + public static StringBuilder getGLInfo(GL gl, StringBuilder sb) { return getGLInfo(gl, sb, false); } @@ -136,26 +136,26 @@ public class JoglVersion extends JogampVersion { if(null==sb) { sb = new StringBuilder(); } - + sb.append(VersionUtil.SEPERATOR).append(Platform.getNewline()); sb.append(device.getClass().getSimpleName()).append("[type ") .append(device.getType()).append(", connection ").append(device.getConnection()).append("]: ").append(Platform.getNewline()); - GLProfile.glAvailabilityToString(device, sb, "\t", 1); + GLProfile.glAvailabilityToString(device, sb, "\t", 1); sb.append(Platform.getNewline()); sb = getGLStrings(gl, sb, withCapabilitiesAndExtensionInfo); - + if( withCapabilitiesAndExtensionInfo ) { - sb = getAllAvailableCapabilitiesInfo(device, sb); + sb = getAllAvailableCapabilitiesInfo(device, sb); } return sb; } - + public static StringBuilder getGLStrings(GL gl, StringBuilder sb) { return getGLStrings(gl, sb, true); } - - public static StringBuilder getGLStrings(GL gl, StringBuilder sb, boolean withExtensions) { + + public static StringBuilder getGLStrings(GL gl, StringBuilder sb, boolean withExtensions) { if(null==sb) { sb = new StringBuilder(); } @@ -175,7 +175,7 @@ public class JoglVersion extends JogampVersion { sb.append("GL_RENDERER ").append(gl.glGetString(GL.GL_RENDERER)); sb.append(Platform.getNewline()); sb.append("GL_VERSION ").append(gl.glGetString(GL.GL_VERSION)); - sb.append(Platform.getNewline()); + sb.append(Platform.getNewline()); sb.append("GLSL ").append(gl.hasGLSL()).append(", has-compiler-func: ").append(gl.isFunctionAvailable("glCompileShader")); if(gl.hasGLSL()) { sb.append(", version: ").append(gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION)).append(" / ").append(ctx.getGLSLVersionNumber()); @@ -200,7 +200,7 @@ public class JoglVersion extends JogampVersion { return sb; } - public StringBuilder getBriefOSGLBuildInfo(GL gl, StringBuilder sb) { + public StringBuilder getBriefOSGLBuildInfo(GL gl, StringBuilder sb) { if(null==sb) { sb = new StringBuilder(); } @@ -216,7 +216,7 @@ public class JoglVersion extends JogampVersion { sb.append(Platform.getNewline()); return sb; } - + public static void main(String args[]) { System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); diff --git a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java index ca4846939..8d2d07d58 100644 --- a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.cg; import com.jogamp.common.jvm.JNILibLoaderBase; @@ -45,15 +45,15 @@ public final class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInf AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Platform.initSingleton(); - + if(TempJarCache.isInitialized()) { // only: jogl-cg.jar -> jogl-cg-natives-.jar [atomic JAR files only] - JNILibLoaderBase.addNativeJarLibs(new Class[] { CgDynamicLibraryBundleInfo.class }, null, null ); + JNILibLoaderBase.addNativeJarLibs(new Class[] { CgDynamicLibraryBundleInfo.class }, null, null ); } return null; } }); - + glueLibNames = new ArrayList(); // glueLibNames.addAll(getGlueLibNamesPreload()); glueLibNames.add("jogl_cg"); @@ -76,7 +76,7 @@ public final class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInf *

    * Returns false. *

    - */ + */ @Override public final boolean shallLookupGlobal() { return false; } @@ -91,7 +91,7 @@ public final class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInf public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) { return 0; } - + @Override public final boolean useToolGetProcAdressFirst(String funcName) { return false; @@ -103,7 +103,7 @@ public final class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInf final List libsCg = new ArrayList(); libsCg.add("Cg"); libsList.add(libsCg); - + final List libsCgGL = new ArrayList(); libsCgGL.add("CgGL"); libsList.add(libsCgGL); @@ -119,7 +119,7 @@ public final class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInf @Override public final RunnableExecutor getLibLoaderExecutor() { return DynamicLibraryBundle.getDefaultRunnableExecutor(); - } + } } diff --git a/src/jogl/classes/com/jogamp/opengl/cg/CgException.java b/src/jogl/classes/com/jogamp/opengl/cg/CgException.java index 8bfd9e23e..3e42f4d70 100644 --- a/src/jogl/classes/com/jogamp/opengl/cg/CgException.java +++ b/src/jogl/classes/com/jogamp/opengl/cg/CgException.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/math/FixedPoint.java b/src/jogl/classes/com/jogamp/opengl/math/FixedPoint.java index e0acfec28..b7dbf183f 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/FixedPoint.java +++ b/src/jogl/classes/com/jogamp/opengl/math/FixedPoint.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,7 +28,7 @@ * 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.opengl.math; diff --git a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java index f3f44f15a..191a83241 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/math/FloatUtil.java @@ -40,7 +40,7 @@ import com.jogamp.common.os.Platform; *

    * Derived from ProjectFloat.java - Created 11-jan-2004 *

    - * + * * @author Erik Duijs * @author Kenneth Russell * @author Sven Gothel @@ -95,7 +95,7 @@ public class FloatUtil { m.put(ZERO_MATRIX); m.position(oldPos); } - + /** * @param a 4x4 matrix in column-major order * @param b 4x4 matrix in column-major order @@ -111,7 +111,7 @@ public class FloatUtil { d[d_off+i+3*4] = ai0 * b[b_off+0+3*4] + ai1 * b[b_off+1+3*4] + ai2 * b[b_off+2+3*4] + ai3 * b[b_off+3+3*4] ; } } - + /** * @param a 4x4 matrix in column-major order (also result) * @param b 4x4 matrix in column-major order @@ -127,7 +127,7 @@ public class FloatUtil { a[a_off_i+3*4] = ai0 * b[b_off+0+3*4] + ai1 * b[b_off+1+3*4] + ai2 * b[b_off+2+3*4] + ai3 * b[b_off+3+3*4] ; } } - + /** * @param a 4x4 matrix in column-major order * @param b 4x4 matrix in column-major order @@ -151,7 +151,7 @@ public class FloatUtil { * @param d result a*b in column-major order */ public static final void multMatrixf(final FloatBuffer a, final float[] b, int b_off, FloatBuffer d) { - final int aP = a.position(); + final int aP = a.position(); final int dP = d.position(); for (int i = 0; i < 4; i++) { // one row in column-major order @@ -162,13 +162,13 @@ public class FloatUtil { d.put(dP+i+3*4 , ai0 * b[b_off+0+3*4] + ai1 * b[b_off+1+3*4] + ai2 * b[b_off+2+3*4] + ai3 * b[b_off+3+3*4] ); } } - + /** * @param a 4x4 matrix in column-major order (also result) * @param b 4x4 matrix in column-major order */ public static final void multMatrixf(final FloatBuffer a, final float[] b, int b_off) { - final int aP = a.position(); + final int aP = a.position(); for (int i = 0; i < 4; i++) { // one row in column-major order final int aP_i = aP+i; @@ -186,7 +186,7 @@ public class FloatUtil { * @param d result a*b in column-major order */ public static final void multMatrixf(final FloatBuffer a, final FloatBuffer b, FloatBuffer d) { - final int aP = a.position(); + final int aP = a.position(); final int bP = b.position(); final int dP = d.position(); for (int i = 0; i < 4; i++) { @@ -198,13 +198,13 @@ public class FloatUtil { d.put(dP+i+3*4 , ai0 * b.get(bP+0+3*4) + ai1 * b.get(bP+1+3*4) + ai2 * b.get(bP+2+3*4) + ai3 * b.get(bP+3+3*4) ); } } - + /** * @param a 4x4 matrix in column-major order (also result) * @param b 4x4 matrix in column-major order */ public static final void multMatrixf(final FloatBuffer a, final FloatBuffer b) { - final int aP = a.position(); + final int aP = a.position(); final int bP = b.position(); for (int i = 0; i < 4; i++) { // one row in column-major order @@ -216,14 +216,14 @@ public class FloatUtil { a.put(aP_i+3*4 , ai0 * b.get(bP+0+3*4) + ai1 * b.get(bP+1+3*4) + ai2 * b.get(bP+2+3*4) + ai3 * b.get(bP+3+3*4) ); } } - + /** * @param a 4x4 matrix in column-major order * @param b 4x4 matrix in column-major order * @param d result a*b in column-major order */ public static final void multMatrixf(final FloatBuffer a, final FloatBuffer b, float[] d, int d_off) { - final int aP = a.position(); + final int aP = a.position(); final int bP = b.position(); for (int i = 0; i < 4; i++) { // one row in column-major order @@ -234,7 +234,7 @@ public class FloatUtil { d[d_off+i+3*4] = ai0 * b.get(bP+0+3*4) + ai1 * b.get(bP+1+3*4) + ai2 * b.get(bP+2+3*4) + ai3 * b.get(bP+3+3*4) ; } } - + /** * Normalize vector * @@ -242,7 +242,7 @@ public class FloatUtil { */ public static final void normalize(float[] v) { float r = (float) Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); - + if ( r == 0.0 || r == 1.0) { return; } @@ -265,7 +265,7 @@ public class FloatUtil { float r = (float) Math.sqrt(v.get(0+vPos) * v.get(0+vPos) + v.get(1+vPos) * v.get(1+vPos) + v.get(2+vPos) * v.get(2+vPos)); - + if ( r == 0.0 || r == 1.0) { return; } @@ -341,7 +341,7 @@ public class FloatUtil { v_in[3] * m_in[3*4+i]; } } - + /** * @param m_in 4x4 matrix in column-major order * @param v_in 4-component column-vector @@ -355,10 +355,10 @@ public class FloatUtil { v_in[0+v_in_off] * m_in.get(0*4+i+matrixPos) + v_in[1+v_in_off] * m_in.get(1*4+i+matrixPos) + v_in[2+v_in_off] * m_in.get(2*4+i+matrixPos) + - v_in[3+v_in_off] * m_in.get(3*4+i+matrixPos); + v_in[3+v_in_off] * m_in.get(3*4+i+matrixPos); } } - + /** * @param m_in 4x4 matrix in column-major order * @param v_in 4-component column-vector @@ -372,10 +372,10 @@ public class FloatUtil { v_in[0] * m_in.get(0*4+i+matrixPos) + v_in[1] * m_in.get(1*4+i+matrixPos) + v_in[2] * m_in.get(2*4+i+matrixPos) + - v_in[3] * m_in.get(3*4+i+matrixPos); + v_in[3] * m_in.get(3*4+i+matrixPos); } } - + /** * @param m_in 4x4 matrix in column-major order * @param v_in 4-component column-vector @@ -395,7 +395,7 @@ public class FloatUtil { } } - /** + /** * @param sb optional passed StringBuilder instance to be used * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} * @param a mxn matrix (rows x columns) @@ -403,7 +403,7 @@ public class FloatUtil { * @param rows * @param columns * @param rowMajorOrder if true floats are layed out in row-major-order, otherwise column-major-order (OpenGL) - * @param row row number to print + * @param row row number to print * @return matrix row string representation */ public static StringBuilder matrixRowToString(StringBuilder sb, String f, FloatBuffer a, int aOffset, int rows, int columns, boolean rowMajorOrder, int row) { @@ -413,17 +413,17 @@ public class FloatUtil { final int a0 = aOffset + a.position(); if(rowMajorOrder) { for(int c=0; ca's current position @@ -469,14 +469,14 @@ public class FloatUtil { for(int i=0; ia's current position @@ -493,14 +493,14 @@ public class FloatUtil { for(int i=0; ia's current position @@ -521,14 +521,14 @@ public class FloatUtil { matrixRowToString(sb, f, a, aOffset, rows, columns, rowMajorOrder, i); sb.append("=?= "); matrixRowToString(sb, f, b, bOffset, rows, columns, rowMajorOrder, i); - sb.append("]").append(Platform.getNewline()); + sb.append("]").append(Platform.getNewline()); } return sb; } - /** + /** * @param sb optional passed StringBuilder instance to be used - * @param rowPrefix optional prefix for each row + * @param rowPrefix optional prefix for each row * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} * @param a 4x4 matrix in column major order (OpenGL) * @param aOffset offset to a's current position @@ -549,11 +549,11 @@ public class FloatUtil { matrixRowToString(sb, f, a, aOffset, rows, columns, rowMajorOrder, i); sb.append("=?= "); matrixRowToString(sb, f, b, bOffset, rows, columns, rowMajorOrder, i); - sb.append("]").append(Platform.getNewline()); + sb.append("]").append(Platform.getNewline()); } return sb; } - + public static final float E = 2.7182818284590452354f; public static final float PI = 3.14159265358979323846f; @@ -569,5 +569,5 @@ public class FloatUtil { public static float acos(float a) { return (float) java.lang.Math.acos(a); } public static float sqrt(float a) { return (float) java.lang.Math.sqrt(a); } - + } \ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java index c6bf44f6d..78cbb18cf 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Quaternion.java @@ -33,7 +33,7 @@ public class Quaternion { public Quaternion() { setIdentity(); } - + public Quaternion(Quaternion q) { x = q.x; y = q.y; @@ -50,7 +50,7 @@ public class Quaternion { /** * Constructor to create a rotation based quaternion from two vectors - * + * * @param vector1 * @param vector2 */ @@ -59,7 +59,7 @@ public class Quaternion { final float[] cross = VectorUtil.cross(vector1, vector2); fromAxis(cross, theta); } - + /*** * Constructor to create a rotation based quaternion from axis vector and angle * @param vector axis vector @@ -69,10 +69,10 @@ public class Quaternion { public Quaternion(float[] vector, float angle) { fromAxis(vector, angle); } - + /*** * Initialize this quaternion with given axis vector and rotation angle - * + * * @param vector axis vector * @param angle rotation angle (rads) */ @@ -88,7 +88,7 @@ public class Quaternion { /** * Transform the rotational quaternion to axis based rotation angles - * + * * @return new float[4] with ,theta,Rx,Ry,Rz */ public float[] toAxis() { @@ -135,7 +135,7 @@ public class Quaternion { /** * Add a quaternion - * + * * @param q quaternion */ public void add(Quaternion q) { @@ -146,7 +146,7 @@ public class Quaternion { /** * Subtract a quaternion - * + * * @param q quaternion */ public void subtract(Quaternion q) { @@ -157,7 +157,7 @@ public class Quaternion { /** * Divide a quaternion by a constant - * + * * @param n a float to divide by */ public void divide(float n) { @@ -168,7 +168,7 @@ public class Quaternion { /** * Multiply this quaternion by the param quaternion - * + * * @param q a quaternion to multiply with */ public void mult(Quaternion q) { @@ -186,7 +186,7 @@ public class Quaternion { /** * Multiply a quaternion by a constant - * + * * @param n a float constant */ public void mult(float n) { @@ -194,10 +194,10 @@ public class Quaternion { y *= n; z *= n; } - + /*** * Rotate given vector by this quaternion - * + * * @param vector input vector * @return rotated vector */ @@ -250,7 +250,7 @@ public class Quaternion { /** * Transform this quaternion to a 4x4 column matrix representing the * rotation - * + * * @return new float[16] column matrix 4x4 */ public float[] toMatrix() { @@ -287,7 +287,7 @@ public class Quaternion { * See http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/ * quaternions/slerp/ *

    - * + * * @param a initial quaternion * @param b target quaternion * @param t float between 0 and 1 representing interp. @@ -332,13 +332,13 @@ public class Quaternion { /** * Check if this quaternion represents an identity matrix for rotation, * , ie (0,0,0,1). - * + * * @return true if it is an identity rep., false otherwise */ public boolean isIdentity() { return w == 1 && x == 0 && y == 0 && z == 0; } - + /*** * Set this quaternion to identity (x=0,y=0,z=0,w=1) */ @@ -349,7 +349,7 @@ public class Quaternion { /** * compute the quaternion from a 3x3 column matrix - * + * * @param m 3x3 column matrix */ public void setFromMatrix(float[] m) { @@ -386,7 +386,7 @@ public class Quaternion { /** * Check if the the 3x3 matrix (param) is in fact an affine rotational * matrix - * + * * @param m 3x3 column matrix * @return true if representing a rotational matrix, false otherwise */ diff --git a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java index 0033afeaa..508f1aafd 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java @@ -39,7 +39,7 @@ public class VectorUtil { Winding(int dir) { this.dir = dir; } - } + } public static final int COLLINEAR = 0; @@ -119,15 +119,15 @@ public class VectorUtil { /** Column Matrix Vector multiplication * @param colMatrix column matrix (4x4) * @param vec vector(x,y,z) - * @return result new float[3] + * @return result new float[3] */ public static float[] colMatrixVectorMult(float[] colMatrix, float[] vec) { final float[] out = new float[3]; - out[0] = vec[0]*colMatrix[0] + vec[1]*colMatrix[4] + vec[2]*colMatrix[8] + colMatrix[12]; - out[1] = vec[0]*colMatrix[1] + vec[1]*colMatrix[5] + vec[2]*colMatrix[9] + colMatrix[13]; - out[2] = vec[0]*colMatrix[2] + vec[1]*colMatrix[6] + vec[2]*colMatrix[10] + colMatrix[14]; + out[0] = vec[0]*colMatrix[0] + vec[1]*colMatrix[4] + vec[2]*colMatrix[8] + colMatrix[12]; + out[1] = vec[0]*colMatrix[1] + vec[1]*colMatrix[5] + vec[2]*colMatrix[9] + colMatrix[13]; + out[2] = vec[0]*colMatrix[2] + vec[1]*colMatrix[6] + vec[2]*colMatrix[10] + colMatrix[14]; return out; } @@ -135,15 +135,15 @@ public class VectorUtil { /** Matrix Vector multiplication * @param rawMatrix column matrix (4x4) * @param vec vector(x,y,z) - * @return result new float[3] + * @return result new float[3] */ public static float[] rowMatrixVectorMult(float[] rawMatrix, float[] vec) { final float[] out = new float[3]; - out[0] = vec[0]*rawMatrix[0] + vec[1]*rawMatrix[1] + vec[2]*rawMatrix[2] + rawMatrix[3]; - out[1] = vec[0]*rawMatrix[4] + vec[1]*rawMatrix[5] + vec[2]*rawMatrix[6] + rawMatrix[7]; - out[2] = vec[0]*rawMatrix[8] + vec[1]*rawMatrix[9] + vec[2]*rawMatrix[10] + rawMatrix[11]; + out[0] = vec[0]*rawMatrix[0] + vec[1]*rawMatrix[1] + vec[2]*rawMatrix[2] + rawMatrix[3]; + out[1] = vec[0]*rawMatrix[4] + vec[1]*rawMatrix[5] + vec[2]*rawMatrix[6] + rawMatrix[7]; + out[2] = vec[0]*rawMatrix[8] + vec[1]*rawMatrix[9] + vec[2]*rawMatrix[10] + rawMatrix[11]; return out; } @@ -157,7 +157,7 @@ public class VectorUtil { { return (p1+p2)/2.0f; } - + /** Calculate the midpoint of two points * @param p1 first point * @param p2 second point @@ -172,7 +172,7 @@ public class VectorUtil { return midPoint; } - + /** Compute the norm of a vector * @param vec vector * @return vorm @@ -181,7 +181,7 @@ public class VectorUtil { { return FloatUtil.sqrt(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]); } - + /** Compute distance between 2 points * @param p0 a ref point on the line * @param vec vector representing the direction of the line @@ -216,7 +216,7 @@ public class VectorUtil { */ public static boolean checkEqualityVec2(float[] v1, float[] v2) { - return Float.compare(v1[0], v2[0]) == 0 && + return Float.compare(v1[0], v2[0]) == 0 && Float.compare(v1[1], v2[1]) == 0 ; } @@ -261,7 +261,7 @@ public class VectorUtil { * @param b triangle vertex 2 * @param c triangle vertex 3 * @param d vertex in question - * @return true if the vertex d is inside the circle defined by the + * @return true if the vertex d is inside the circle defined by the * vertices a, b, c. from paper by Guibas and Stolfi (1985). */ public static boolean inCircle(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d){ @@ -282,8 +282,8 @@ public class VectorUtil { return (b.getX() - a.getX()) * (c.getY() - a.getY()) - (b.getY() - a.getY())*(c.getX() - a.getX()); } - /** Check if a vertex is in triangle using - * barycentric coordinates computation. + /** Check if a vertex is in triangle using + * barycentric coordinates computation. * @param a first triangle vertex * @param b second triangle vertex * @param c third triangle vertex @@ -291,7 +291,7 @@ public class VectorUtil { * @return true if p is in triangle (a, b, c), false otherwise. */ public static boolean vertexInTriangle(float[] a, float[] b, float[] c, float[] p){ - // Compute vectors + // Compute vectors final float[] ac = computeVector(a, c); //v0 final float[] ab = computeVector(a, b); //v1 final float[] ap = computeVector(a, p); //v2 @@ -362,13 +362,13 @@ public class VectorUtil { * @param b vertex 2 of first segment * @param c vertex 1 of second segment * @param d vertex 2 of second segment - * @return the intersection coordinates if the segments intersect, otherwise - * returns null + * @return the intersection coordinates if the segments intersect, otherwise + * returns null */ public static float[] seg2SegIntersection(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d) { final float determinant = (a.getX()-b.getX())*(c.getY()-d.getY()) - (a.getY()-b.getY())*(c.getX()-d.getX()); - if (determinant == 0) + if (determinant == 0) return null; final float alpha = (a.getX()*b.getY()-a.getY()*b.getX()); @@ -389,13 +389,13 @@ public class VectorUtil { * @param b vertex 2 of first line * @param c vertex 1 of second line * @param d vertex 2 of second line - * @return the intersection coordinates if the lines intersect, otherwise - * returns null + * @return the intersection coordinates if the lines intersect, otherwise + * returns null */ public static float[] line2lineIntersection(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d) { final float determinant = (a.getX()-b.getX())*(c.getY()-d.getY()) - (a.getY()-b.getY())*(c.getX()-d.getX()); - if (determinant == 0) + if (determinant == 0) return null; final float alpha = (a.getX()*b.getY()-a.getY()*b.getX()); diff --git a/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java b/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java index 13349884c..ec90b401f 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java +++ b/src/jogl/classes/com/jogamp/opengl/math/Vert2fImmutable.java @@ -33,7 +33,7 @@ public interface Vert2fImmutable { float getY(); int getCoordCount(); - + float[] getCoord(); - + } diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java index b6e8ede2e..f1880a61b 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java +++ b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java @@ -32,23 +32,23 @@ import com.jogamp.opengl.math.VectorUtil; /** * Axis Aligned Bounding Box. Defined by two 3D coordinates (low and high) - * The low being the the lower left corner of the box, and the high being the upper + * The low being the the lower left corner of the box, and the high being the upper * right corner of the box. - * + * */ public class AABBox implements Cloneable { private float[] low = new float[3]; private float[] high = new float[3]; private float[] center = new float[3]; - /** Create a Axis Aligned bounding box (AABBox) + /** Create a Axis Aligned bounding box (AABBox) * where the low and and high MAX float Values. */ public AABBox() { reset(); } - /** Create an AABBox specifying the coordinates + /** Create an AABBox specifying the coordinates * of the low and high * @param lx min x-coordinate * @param ly min y-coordnate @@ -61,7 +61,7 @@ public class AABBox implements Cloneable { float hx, float hy, float hz) { setSize(lx, ly, lz, hx, hy, hz); } - + /** Create a AABBox defining the low and high * @param low min xyz-coordinates * @param high max xyz-coordinates @@ -78,27 +78,27 @@ public class AABBox implements Cloneable { center[1] = 0f; center[2] = 0f; } - + /** Get the max xyz-coordinates * @return a float array containing the max xyz coordinates */ public final float[] getHigh() { return high; } - + private final void setHigh(float hx, float hy, float hz) { this.high[0] = hx; this.high[1] = hy; this.high[2] = hz; } - + /** Get the min xyz-coordinates * @return a float array containing the min xyz coordinates */ public final float[] getLow() { return low; } - + private final void setLow(float lx, float ly, float lz) { this.low[0] = lx; this.low[1] = ly; @@ -111,10 +111,10 @@ public class AABBox implements Cloneable { center[2] = (high[2] + low[2])/2; } - /** - * Set size of the AABBox specifying the coordinates + /** + * Set size of the AABBox specifying the coordinates * of the low and high. - * + * * @param lx min x-coordinate * @param ly min y-coordnate * @param lz min z-coordinate @@ -123,7 +123,7 @@ public class AABBox implements Cloneable { * @param hz max z-coordinate */ public final void setSize(float lx, float ly, float lz, - float hx, float hy, float hz) { + float hx, float hy, float hz) { this.low[0] = lx; this.low[1] = ly; this.low[2] = lz; @@ -132,7 +132,7 @@ public class AABBox implements Cloneable { this.high[2] = hz; computeCenter(); } - + /** Resize the AABBox to encapsulate another AABox * @param newBox AABBox to be encapsulated in */ @@ -160,12 +160,12 @@ public class AABBox implements Cloneable { } /** Resize the AABBox to encapsulate the passed - * xyz-coordinates. + * xyz-coordinates. * @param x x-axis coordinate value * @param y y-axis coordinate value * @param z z-axis coordinate value */ - public final void resize(float x, float y, float z) { + public final void resize(float x, float y, float z) { /** test low */ if (x < low[0]) low[0] = x; @@ -181,12 +181,12 @@ public class AABBox implements Cloneable { high[1] = y; if (z > high[2]) high[2] = z; - + computeCenter(); } /** Resize the AABBox to encapsulate the passed - * xyz-coordinates. + * xyz-coordinates. * @param xyz xyz-axis coordinate values * @param offset of the array */ @@ -210,7 +210,7 @@ public class AABBox implements Cloneable { } return true; } - + /** Check if the xyz coordinates are bounded/contained * by this AABBox. * @param x x-axis coordinate value @@ -231,7 +231,7 @@ public class AABBox implements Cloneable { } return true; } - + /** Check if there is a common region between this AABBox and the passed * 2D region irrespective of z range * @param x lower left x-coord @@ -244,13 +244,13 @@ public class AABBox implements Cloneable { if (w <= 0 || h <= 0) { return false; } - + final float _w = getWidth(); - final float _h = getHeight(); + final float _h = getHeight(); if (_w <= 0 || _h <= 0) { return false; } - + final float x0 = getMinX(); final float y0 = getMinY(); return (x + w > x0 && @@ -259,8 +259,8 @@ public class AABBox implements Cloneable { y < y0 + _h); } - - /** Get the size of the Box where the size is represented by the + + /** Get the size of the Box where the size is represented by the * length of the vector between low and high. * @return a float representing the size of the AABBox */ @@ -283,16 +283,16 @@ public class AABBox implements Cloneable { diffH[0] = high[0] - center[0]; diffH[1] = high[1] - center[1]; diffH[2] = high[2] - center[2]; - + diffH = VectorUtil.scale(diffH, size); - + float[] diffL = new float[3]; diffL[0] = low[0] - center[0]; diffL[1] = low[1] - center[1]; diffL[2] = low[2] - center[2]; - + diffL = VectorUtil.scale(diffL, size); - + high = VectorUtil.vectorAdd(center, diffH); low = VectorUtil.vectorAdd(center, diffL); } @@ -300,43 +300,43 @@ public class AABBox implements Cloneable { public final float getMinX() { return low[0]; } - + public final float getMinY() { return low[1]; } - + public final float getMinZ() { return low[2]; } - + public final float getMaxX() { return high[0]; } - + public final float getMaxY() { return high[1]; } - + public final float getMaxZ() { return high[2]; } - + public final float getWidth(){ return high[0] - low[0]; } - + public final float getHeight() { return high[1] - low[1]; } - + public final float getDepth() { return high[2] - low[2]; } - + public final AABBox clone() { return new AABBox(this.low, this.high); } - + public final boolean equals(Object obj) { if( obj == this ) { return true; @@ -344,11 +344,11 @@ public class AABBox implements Cloneable { if( null == obj || !(obj instanceof AABBox) ) { return false; } - final AABBox other = (AABBox) obj; - return VectorUtil.checkEquality(low, other.low) && + final AABBox other = (AABBox) obj; + return VectorUtil.checkEquality(low, other.low) && VectorUtil.checkEquality(high, other.high) ; } - + public final String toString() { return "[ "+low[0]+"/"+low[1]+"/"+low[1]+" .. "+high[0]+"/"+high[0]+"/"+high[0]+", ctr "+ center[0]+"/"+center[1]+"/"+center[1]+" ]"; diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java b/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java index 93e68a1d6..fb311083f 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java +++ b/src/jogl/classes/com/jogamp/opengl/math/geom/Frustum.java @@ -30,11 +30,11 @@ package com.jogamp.opengl.math.geom; import com.jogamp.common.os.Platform; /** - * Providing frustum {@link #getPlanes() planes} derived by different inputs + * Providing frustum {@link #getPlanes() planes} derived by different inputs * ({@link #updateByPMV(float[], int) P*MV}, ..) - * used to {@link #classifySphere(float[], float) classify objects} and to test + * used to {@link #classifySphere(float[], float) classify objects} and to test * whether they are {@link #isOutside(AABBox) outside}. - * + * *

    * Extracting the world-frustum planes from the P*Mv: *

    @@ -54,7 +54,7 @@ import com.jogamp.common.os.Platform;
      * Lighthouse3d.com
      * http://www.lighthouse3d.com/tutorials/view-frustum-culling/
      * 
    - * + * * Fundamentals about Planes, Half-Spaces and Frustum-Culling:
    *
      * Planes and Half-Spaces,  Max Wagner 
    @@ -69,7 +69,7 @@ import com.jogamp.common.os.Platform;
     public class Frustum {
         /** Normalized planes[l, r, b, t, n, f] */
     	protected Plane[] planes = new Plane[6];
    -	
    +
     	/**
     	 * Creates an undefined instance w/o calculating the frustum.
     	 * 

    @@ -83,35 +83,35 @@ public class Frustum { planes[i] = new Plane(); } } - - /** + + /** * Plane equation := dot(n, x - p) = 0 -> ax + bc + cx + d == 0 *

    * In order to work w/ {@link Frustum#isOutside(AABBox) isOutside(..)} methods, * the normals have to point to the inside of the frustum. - *

    + *

    */ public static class Plane { /** Normal of the plane */ public final float[] n = new float[3]; - + /** Distance to origin */ public float d; - /** + /** * Return signed distance of plane to given point. *
      *
    • If dist < 0 , then the point p lies in the negative halfspace.
    • *
    • If dist = 0 , then the point p lies in the plane.
    • *
    • If dist > 0 , then the point p lies in the positive halfspace.
    • - *
    + * * A plane cuts 3D space into 2 half spaces. *

    * Positive halfspace is where the plane’s normals vector points into. - *

    + *

    *

    * Negative halfspace is the other side of the plane, i.e. *-1 - *

    + *

    **/ public final float distanceTo(float x, float y, float z) { return n[0] * x + n[1] * y + n[2] * z + d; @@ -121,13 +121,13 @@ public class Frustum { public final float distanceTo(float[] p) { return n[0] * p[0] + n[1] * p[1] + n[2] * p[2] + d; } - + @Override public String toString() { return "Plane[ [ " + n[0] + ", " + n[1] + ", " + n[2] + " ], " + d + "]"; } } - + /** Index for left plane: {@value} */ public static final int LEFT = 0; /** Index for right plane: {@value} */ @@ -140,7 +140,7 @@ public class Frustum { public static final int NEAR = 4; /** Index for far plane: {@value} */ public static final int FAR = 5; - + /** * {@link Plane}s are ordered in the returned array as follows: *
      @@ -154,17 +154,17 @@ public class Frustum { *

      * {@link Plane}'s normals are pointing to the inside of the frustum * in order to work w/ {@link #isOutside(AABBox) isOutside(..)} methods. - *

      - * - * @return array of normalized {@link Plane}s, order see above. + *

      + * + * @return array of normalized {@link Plane}s, order see above. */ public final Plane[] getPlanes() { return planes; } - + /** * Copy the given src planes into this this instance's planes. * @param src the 6 source planes */ - public final void updateByPlanes(Plane[] src) { + public final void updateByPlanes(Plane[] src) { for (int i = 0; i < 6; ++i) { final Plane p0 = planes[i]; final float[] p0_n = p0.n; @@ -176,7 +176,7 @@ public class Frustum { p0.d = p1.d; } } - + /** * Calculate the frustum planes in world coordinates * using the passed float[16] as premultiplied P*MV (column major order). @@ -185,7 +185,7 @@ public class Frustum { * as required by this class. *

      */ - public void updateByPMV(float[] pmv, int pmv_off) { + public void updateByPMV(float[] pmv, int pmv_off) { // Left: a = m41 + m11, b = m42 + m12, c = m43 + m13, d = m44 + m14 - [1..4] row-major // Left: a = m30 + m00, b = m31 + m01, c = m32 + m02, d = m33 + m03 - [0..3] row-major { @@ -264,11 +264,11 @@ public class Frustum { p.d /= invl; } } - + private static final boolean isOutsideImpl(Plane p, AABBox box) { final float[] low = box.getLow(); final float[] high = box.getHigh(); - + if ( p.distanceTo(low[0], low[1], low[2]) > 0.0f || p.distanceTo(high[0], low[1], low[2]) > 0.0f || p.distanceTo(low[0], high[1], low[2]) > 0.0f || @@ -298,19 +298,19 @@ public class Frustum { // We make no attempt to determine whether it's fully inside or not. return false; } - - + + public static enum Location { OUTSIDE, INSIDE, INTERSECT }; - + /** * Check to see if a point is outside, inside or on a plane of the frustum. - * + * * @param p the point * @return {@link Location} of point related to frustum planes */ public final Location classifyPoint(float[] p) { Location res = Location.INSIDE; - + for (int i = 0; i < 6; ++i) { final float d = planes[i].distanceTo(p); if ( d < 0.0f ) { @@ -321,43 +321,43 @@ public class Frustum { } return res; } - + /** * Check to see if a point is outside of the frustum. - * + * * @param p the point * @return true if outside of the frustum, otherwise inside or on a plane */ public final boolean isPointOutside(float[] p) { return Location.OUTSIDE == classifyPoint(p); } - + /** * Check to see if a sphere is outside, intersecting or inside of the frustum. - * + * * @param p center of the sphere * @param radius radius of the sphere * @return {@link Location} of point related to frustum planes */ public final Location classifySphere(float[] p, float radius) { Location res = Location.INSIDE; // fully inside - + for (int i = 0; i < 6; ++i) { final float d = planes[i].distanceTo(p); - if ( d < -radius ) { + if ( d < -radius ) { // fully outside return Location.OUTSIDE; } else if (d < radius ) { // intersecting res = Location.INTERSECT; } - } + } return res; } - + /** * Check to see if a sphere is outside of the frustum. - * + * * @param p center of the sphere * @param radius radius of the sphere * @return true if outside of the frustum, otherwise inside or intersecting @@ -365,7 +365,7 @@ public class Frustum { public final boolean isSphereOutside(float[] p, float radius) { return Location.OUTSIDE == classifySphere(p, radius); } - + public StringBuilder toString(StringBuilder sb) { if( null == sb ) { sb = new StringBuilder(); @@ -380,7 +380,7 @@ public class Frustum { .append("]"); return sb; } - + @Override public String toString() { return toString(null).toString(); diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index ff764d849..33941a407 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -102,11 +102,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* GL Stuff */ private final RecursiveLock lock = LockFactory.createRecursiveLock(); private final GLDrawableHelper helper = new GLDrawableHelper(); - + private final GLContext shareWith; private final GLCapabilitiesImmutable capsRequested; - private final GLCapabilitiesChooser capsChooser; - + private final GLCapabilitiesChooser capsChooser; + private volatile Rectangle clientArea; private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access private volatile GLContextImpl context; @@ -156,7 +156,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public void run() { final RecursiveLock _lock = lock; _lock.lock(); - try { + try { if( !GLCanvas.this.isDisposed() ) { helper.invokeGL(drawable, context, displayAction, initAction); } @@ -215,7 +215,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { gle.printStackTrace(); } } - context = null; + context = null; } if ( null != drawable ) { drawable.setRealized(false); @@ -261,11 +261,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } } }; - - /** - * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser, GLContext)} + + /** + * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser, GLContext)} * on the SWT thread. - * + * * @param parent * Required (non-null) parent Composite. * @param style @@ -284,7 +284,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { */ public static GLCanvas create(final Composite parent, final int style, final GLCapabilitiesImmutable caps, final GLCapabilitiesChooser chooser, final GLContext shareWith) { - final GLCanvas[] res = new GLCanvas[] { null }; + final GLCanvas[] res = new GLCanvas[] { null }; parent.getDisplay().syncExec(new Runnable() { public void run() { res[0] = new GLCanvas( parent, style, caps, chooser, shareWith ); @@ -319,22 +319,22 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { GLProfile.initSingleton(); // ensure JOGL is completly initialized SWTAccessor.setRealized(this, true); - + clientArea = GLCanvas.this.getClientArea(); - /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). + /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). * Note: SWT is owner of the native handle, hence closing operation will be a NOP. */ final AbstractGraphicsDevice swtDevice = SWTAccessor.getDevice(this); - + useX11GTK = SWTAccessor.useX11GTK(); if(useX11GTK) { - // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering + // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering final long x11DeviceHandle = X11Util.openDisplay(swtDevice.getConnection()); if( 0 == x11DeviceHandle ) { throw new RuntimeException("Error creating display(EDT): "+swtDevice.getConnection()); } final AbstractGraphicsDevice x11Device = new X11GraphicsDevice(x11DeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); - screen = SWTAccessor.getScreen(x11Device, -1 /* default */); + screen = SWTAccessor.getScreen(x11Device, -1 /* default */); } else { screen = SWTAccessor.getScreen(swtDevice, -1 /* default */); } @@ -343,7 +343,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { if(null == capsReqUser) { capsReqUser = new GLCapabilities(GLProfile.getDefault(screen.getDevice())); } - + this.capsRequested = capsReqUser; this.capsChooser = capsChooser; this.shareWith = shareWith; @@ -353,7 +353,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { x11Window = 0; drawable = null; context = null; - + final Listener listener = new Listener () { @Override public void handleEvent (Event event) { @@ -374,7 +374,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { addListener (SWT.Paint, listener); addListener (SWT.Dispose, listener); } - + private final UpstreamSurfaceHook swtCanvasUpStreamHook = new UpstreamSurfaceHook() { @Override public final void create(ProxySurface s) { /* nop */ } @@ -401,11 +401,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { protected final void updateSizeCheck() { final Rectangle oClientArea = clientArea; final Rectangle nClientArea = GLCanvas.this.getClientArea(); - if ( nClientArea != null && + if ( nClientArea != null && ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) ) { clientArea = nClientArea; // write back new value - + final GLDrawableImpl _drawable = drawable; final boolean drawableOK = null != _drawable && _drawable.isRealized(); if(DEBUG) { @@ -419,14 +419,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { try { final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, nClientArea.width, nClientArea.height); if(_drawable != _drawableNew) { - // write back + // write back drawable = _drawableNew; } } finally { _lock.unlock(); } - } - } + } + } if(0 != x11Window) { SWTAccessor.resizeX11Window(screen.getDevice(), clientArea, x11Window); } else if(0 != gdkWindow) { @@ -435,36 +435,36 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock } } - + private boolean isValidAndVisibleOnEDTActionResult; private final Runnable isValidAndVisibleOnEDTAction = new Runnable() { @Override - public void run() { + public void run() { isValidAndVisibleOnEDTActionResult = !GLCanvas.this.isDisposed() && GLCanvas.this.isVisible(); } }; - + private final boolean isValidAndVisibleOnEDT() { synchronized(isValidAndVisibleOnEDTAction) { runOnEDTIfAvail(true, isValidAndVisibleOnEDTAction); return isValidAndVisibleOnEDTActionResult; } } - + /** assumes drawable == null || !drawable.isRealized() ! Checks of !isDispose() and isVisible() */ protected final boolean validateDrawableAndContextWithCheck() { if( !isValidAndVisibleOnEDT() ) { return false; } - return validateDrawableAndContextPostCheck(); + return validateDrawableAndContextPostCheck(); } - + /** assumes drawable == null || !drawable.isRealized() ! No check of !isDispose() and isVisible() */ protected final boolean validateDrawableAndContextPostCheck() { final Rectangle nClientArea = clientArea; if(0 >= nClientArea.width || 0 >= nClientArea.height) { return false; } - + final boolean res; final RecursiveLock _lock = lock; _lock.lock(); @@ -480,18 +480,18 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } } finally { _lock.unlock(); - } - + } + if(res) { sendReshape = true; if(DEBUG) { System.err.println("SWT GLCanvas realized! "+this+", "+drawable); // Thread.dumpStack(); - } + } } - return res; + return res; } - + private final void createDrawableAndContext() { final AbstractGraphicsDevice device = screen.getDevice(); device.open(); @@ -503,14 +503,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { capsRequested, capsRequested, capsChooser, screen, VisualIDHolder.VID_UNDEFINED); if(DEBUG) { System.err.println("SWT.GLCanvas.X11 factory: "+factory+", chosen config: "+cfg); - } + } if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } final int visualID = cfg.getVisualID(VIDType.NATIVE); if( VisualIDHolder.VID_UNDEFINED != visualID ) { // gdkWindow = SWTAccessor.createCompatibleGDKChildWindow(this, visualID, clientArea.width, clientArea.height); - // nativeWindowHandle = SWTAccessor.gdk_window_get_xwindow(gdkWindow); + // nativeWindowHandle = SWTAccessor.gdk_window_get_xwindow(gdkWindow); x11Window = SWTAccessor.createCompatibleX11ChildWindow(screen, this, visualID, clientArea.width, clientArea.height); nativeWindowHandle = x11Window; } else { @@ -520,16 +520,16 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { nativeWindowHandle = SWTAccessor.getWindowHandle(this); } final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(capsRequested.getGLProfile()); - + // Create a NativeWindow proxy for the SWT canvas - ProxySurface proxySurface = glFactory.createProxySurface(device, screen.getIndex(), nativeWindowHandle, + ProxySurface proxySurface = glFactory.createProxySurface(device, screen.getIndex(), nativeWindowHandle, capsRequested, capsChooser, swtCanvasUpStreamHook); // Associate a GL surface with the proxy drawable = (GLDrawableImpl) glFactory.createGLDrawable(proxySurface); context = (GLContextImpl) drawable.createContext(shareWith); - context.setContextCreationFlags(additionalCtxCreationFlags); + context.setContextCreationFlags(additionalCtxCreationFlags); } - + @Override public void update() { // don't paint background etc .. nop avoids flickering @@ -543,13 +543,13 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { if(r && 0 != gdkWindow) { SWTGTKUtil.focusGDKWindow(gdkWindow); } - return r; + return r; } */ - + @Override public void dispose() { runInGLThread(disposeOnEDTGLAction); - super.dispose(); + super.dispose(); } private final void displayIfNoAnimatorNoCheck() { @@ -557,14 +557,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { final boolean drawableOK = null != drawable && drawable.isRealized(); if( drawableOK || validateDrawableAndContextPostCheck() ) { runInGLThread(makeCurrentAndDisplayOnGLAction); - } + } } } - + // // GL[Auto]Drawable // - + @Override public void display() { final boolean drawableOK = null != drawable && drawable.isRealized(); @@ -577,7 +577,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public final Object getUpstreamWidget() { return this; } - + @Override public int getWidth() { return clientArea.width; @@ -593,7 +593,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { final GLDrawable _drawable = drawable; return null != _drawable ? _drawable.isGLOriented() : true; } - + @Override public void addGLEventListener(final GLEventListener listener) { helper.addGLEventListener(listener); @@ -608,29 +608,29 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public int getGLEventListenerCount() { return helper.getGLEventListenerCount(); } - + @Override public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException { return helper.getGLEventListener(index); } - + @Override public boolean getGLEventListenerInitState(GLEventListener listener) { return helper.getGLEventListenerInitState(listener); } - + @Override public void setGLEventListenerInitState(GLEventListener listener, boolean initialized) { helper.setGLEventListenerInitState(listener, initialized); } - + @Override public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove) { final DisposeGLEventListenerAction r = new DisposeGLEventListenerAction(listener, remove); runInGLThread(r); return r.listener; } - + @Override public GLEventListener removeGLEventListener(final GLEventListener listener) { return helper.removeGLEventListener(listener); @@ -673,7 +673,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public final GLDrawable getDelegatedDrawable() { return drawable; } - + @Override public GLContext getContext() { return null != drawable ? context : null; @@ -694,12 +694,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public boolean invoke(final boolean wait, final GLRunnable runnable) { return helper.invoke(this, wait, runnable); } - + @Override public boolean invoke(final boolean wait, final List runnables) { return helper.invoke(this, wait, runnables); } - + @Override public void setAnimator(final GLAnimatorControl arg0) throws GLException { helper.setAnimator(arg0); @@ -714,7 +714,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx) { final RecursiveLock _lock = lock; _lock.lock(); - try { + try { final GLContext oldCtx = context; GLDrawableHelper.switchContext(drawable, oldCtx, destroyPrevCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; @@ -761,7 +761,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { - final GLDrawable _drawable = drawable; + final GLDrawable _drawable = drawable; return null != _drawable ? (GLCapabilitiesImmutable)_drawable.getChosenGLCapabilities() : null; } @@ -771,7 +771,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * @return Non-null GLCapabilities. */ public GLCapabilitiesImmutable getRequestedGLCapabilities() { - final GLDrawable _drawable = drawable; + final GLDrawable _drawable = drawable; return null != _drawable ? (GLCapabilitiesImmutable)_drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities() : null; } @@ -788,7 +788,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public long getHandle() { - final GLDrawable _drawable = drawable; + final GLDrawable _drawable = drawable; return (_drawable != null) ? _drawable.getHandle() : 0; } @@ -827,12 +827,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { *
        * *
      • Current thread
      • - *
      + *
    * - * The current thread seems to be valid for all platforms, + * The current thread seems to be valid for all platforms, * since no SWT lifecycle tasks are being performed w/ this call. * Only GL task, which are independent from the SWT threading model. - * + * * @see Platform#AWT_AVAILABLE * @see Platform#getOSType() */ @@ -854,8 +854,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } */ action.run(); } - - private void runOnEDTIfAvail(boolean wait, final Runnable action) { + + private void runOnEDTIfAvail(boolean wait, final Runnable action) { final Display d = isDisposed() ? null : getDisplay(); if( null == d || d.isDisposed() || d.getThread() == Thread.currentThread() ) { action.run(); @@ -879,7 +879,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { ",\n\tDrawable size "+dw+"x"+dh+ ",\n\tSWT size "+getWidth()+"x"+getHeight()+"]"; } - + public static void main(final String[] args) { System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); diff --git a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java index 8de178e49..80289acf3 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index 80d980492..cdfb73b21 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -57,7 +57,7 @@ import javax.media.opengl.GLException; * Call {@link #stop() } to terminate the animation and it's execution thread. *

    */ -public class Animator extends AnimatorBase { +public class Animator extends AnimatorBase { protected ThreadGroup threadGroup; private Runnable runnable; private boolean runAsFastAsPossible; @@ -75,7 +75,7 @@ public class Animator extends AnimatorBase { } } - /** + /** * Creates a new Animator w/ an associated ThreadGroup. */ public Animator(ThreadGroup tg) { @@ -86,7 +86,7 @@ public class Animator extends AnimatorBase { } } - /** + /** * Creates a new Animator for a particular drawable. */ public Animator(GLAutoDrawable drawable) { @@ -97,7 +97,7 @@ public class Animator extends AnimatorBase { } } - /** + /** * Creates a new Animator w/ an associated ThreadGroup for a particular drawable. */ public Animator(ThreadGroup tg, GLAutoDrawable drawable) { @@ -127,7 +127,7 @@ public class Animator extends AnimatorBase { stateSync.unlock(); } } - + private final void setIsAnimatingSynced(boolean v) { stateSync.lock(); try { @@ -185,7 +185,7 @@ public class Animator extends AnimatorBase { } if (!stopIssued && !isAnimating) { // Wakes up 'waitForStartedCondition' sync - // - and - + // - and - // Resume from pause or drawablesEmpty, // implies !pauseIssued and !drawablesEmpty setIsAnimatingSynced(true); // barrier @@ -251,7 +251,7 @@ public class Animator extends AnimatorBase { /** * Set a {@link ThreadGroup} for the {@link #getThread() animation thread}. - * + * * @param tg the {@link ThreadGroup} * @throws GLException if the animator has already been started */ @@ -261,7 +261,7 @@ public class Animator extends AnimatorBase { } threadGroup = tg; } - + public synchronized boolean start() { if ( isStartedImpl() ) { return false; @@ -277,7 +277,7 @@ public class Animator extends AnimatorBase { } else { thread = new Thread(threadGroup, runnable, threadName); } - thread.setDaemon(false); // force to be non daemon, regardless of parent thread + thread.setDaemon(false); // force to be non daemon, regardless of parent thread if(DEBUG) { final Thread ct = Thread.currentThread(); System.err.println("Animator "+ct.getName()+"[daemon "+ct.isDaemon()+"]: starting "+thread.getName()+"[daemon "+thread.isDaemon()+"]"); @@ -288,7 +288,7 @@ public class Animator extends AnimatorBase { private final Condition waitForStartedCondition = new Condition() { public boolean eval() { return !isStartedImpl() || (!drawablesEmpty && !isAnimating) ; - } }; + } }; public synchronized boolean stop() { if ( !isStartedImpl() ) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index ef92100ad..b447a339b 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -52,14 +52,14 @@ import javax.media.opengl.GLProfile; */ public abstract class AnimatorBase implements GLAnimatorControl { protected static final boolean DEBUG = Debug.debug("Animator"); - + /** A 1s timeout while waiting for a native action response, limiting {@link #finishLifecycleAction(Condition, long)} */ protected static final long TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION = 1000; - + protected static final long POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION = 32; // 2 frames @ 60Hz - + /** - * If present in modeBits field and + * If present in modeBits field and * {@link GLProfile#isAWTAvailable() AWT is available}, * implementation is aware of the AWT EDT, otherwise not. *

    @@ -67,8 +67,8 @@ public abstract class AnimatorBase implements GLAnimatorControl { *

    * @see #setModeBits(boolean, int) */ - public static final int MODE_EXPECT_AWT_RENDERING_THREAD = 1 << 0; - + public static final int MODE_EXPECT_AWT_RENDERING_THREAD = 1 << 0; + public interface AnimatorImpl { void display(ArrayList drawables, boolean ignoreExceptions, boolean printExceptions); boolean blockUntilDone(Thread thread); @@ -77,7 +77,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { protected int modeBits; protected AnimatorImpl impl; protected String baseName; - + protected ArrayList drawables = new ArrayList(); protected boolean drawablesEmpty; protected Thread animThread; @@ -85,10 +85,10 @@ public abstract class AnimatorBase implements GLAnimatorControl { protected boolean printExceptions; protected boolean exclusiveContext; protected Thread userExclusiveContextThread; - protected FPSCounterImpl fpsCounter = new FPSCounterImpl(); + protected FPSCounterImpl fpsCounter = new FPSCounterImpl(); protected RecursiveLock stateSync = LockFactory.createRecursiveLock(); - - private final static Class awtAnimatorImplClazz; + + private final static Class awtAnimatorImplClazz; static { GLProfile.initSingleton(); if( GLProfile.isAWTAvailable() ) { @@ -96,7 +96,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { try { clazz = Class.forName("com.jogamp.opengl.util.AWTAnimatorImpl"); } catch (Exception e) { - clazz = null; + clazz = null; } awtAnimatorImplClazz = clazz; } else { @@ -105,29 +105,29 @@ public abstract class AnimatorBase implements GLAnimatorControl { } /** - * Creates a new, empty Animator instance + * Creates a new, empty Animator instance * while expecting an AWT rendering thread if AWT is available. - * + * * @see GLProfile#isAWTAvailable() */ public AnimatorBase() { - modeBits = MODE_EXPECT_AWT_RENDERING_THREAD; // default! + modeBits = MODE_EXPECT_AWT_RENDERING_THREAD; // default! drawablesEmpty = true; } - + private static final boolean useAWTAnimatorImpl(int modeBits) { return 0 != ( MODE_EXPECT_AWT_RENDERING_THREAD & modeBits ) && null != awtAnimatorImplClazz; } - + /** * Initializes implementation details post setup, * invoked at {@link #add(GLAutoDrawable)}, {@link #start()}, .. *

    - * Operation is a NOP if force is false + * Operation is a NOP if force is false * and this instance is already initialized. - *

    - * - * @throws GLException if Animator is {@link #isStarted()} + *

    + * + * @throws GLException if Animator is {@link #isStarted()} */ protected synchronized void initImpl(boolean force) { if( force || null == impl ) { @@ -153,8 +153,8 @@ public abstract class AnimatorBase implements GLAnimatorControl { * in this Animators modeBits. * @param enable * @param bitValues - * - * @throws GLException if Animator is {@link #isStarted()} and {@link #MODE_EXPECT_AWT_RENDERING_THREAD} about to change + * + * @throws GLException if Animator is {@link #isStarted()} and {@link #MODE_EXPECT_AWT_RENDERING_THREAD} about to change * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD */ public synchronized void setModeBits(boolean enable, int bitValues) throws GLException { @@ -172,8 +172,8 @@ public abstract class AnimatorBase implements GLAnimatorControl { } } public synchronized int getModeBits() { return modeBits; } - - + + @Override public synchronized void add(final GLAutoDrawable drawable) { if(DEBUG) { @@ -190,7 +190,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { drawables.add(drawable); drawablesEmpty = drawables.size() == 0; drawable.setAnimator(this); - if( isPaused() ) { // either paused by pause() above, or if previously drawablesEmpty==true + if( isPaused() ) { // either paused by pause() above, or if previously drawablesEmpty==true resume(); } final Condition waitForAnimatingAndECTCondition = new Condition() { @@ -213,7 +213,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { if( !drawables.contains(drawable) ) { throw new IllegalArgumentException("Drawable not added to animator: "+this+", "+drawable); } - + if( exclusiveContext && isAnimating() ) { drawable.setExclusiveContextThread( null ); final Condition waitForNullECTCondition = new Condition() { @@ -244,7 +244,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { return isStarted() && drawablesEmpty && isAnimating(); } }; - + /** * Dedicate all {@link GLAutoDrawable}'s context to the given exclusive context thread. *

    @@ -252,14 +252,14 @@ public abstract class AnimatorBase implements GLAnimatorControl { *

    *

    * If already started and disabling, method waits - * until change is propagated to all {@link GLAutoDrawable} if not + * until change is propagated to all {@link GLAutoDrawable} if not * called from the animator thread or {@link #getExclusiveContextThread() exclusive context thread}. *

    *

    * Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation. * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas. *

    - * + * * @param enable * @return previous value * @see #setExclusiveContext(boolean) @@ -272,7 +272,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { final boolean enable = null != t; stateSync.lock(); try { - old = userExclusiveContextThread; + old = userExclusiveContextThread; if( enable && t != animThread ) { // disable: will be cleared at end after propagation && filter out own animThread usae userExclusiveContextThread=t; } @@ -282,7 +282,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { setExclusiveContext(enable); return old; } - + /** * Dedicate all {@link GLAutoDrawable}'s context to this animator thread. *

    @@ -290,14 +290,14 @@ public abstract class AnimatorBase implements GLAnimatorControl { *

    *

    * If already started and disabling, method waits - * until change is propagated to all {@link GLAutoDrawable} if not + * until change is propagated to all {@link GLAutoDrawable} if not * called from the animator thread or {@link #getExclusiveContextThread() exclusive context thread}. *

    *

    * Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation. * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas. *

    - * + * * @param enable * @return previous value * @see #setExclusiveContext(Thread) @@ -349,24 +349,24 @@ public abstract class AnimatorBase implements GLAnimatorControl { System.err.println("AnimatorBase.setExclusiveContextThread: all-GLAD Ok: "+validateDrawablesExclCtxState(dECT)+", "+this); } return oldExclusiveContext; - } - + } + /** * Returns true, if the exclusive context thread is enabled, otherwise false. - * + * * @see #setExclusiveContext(boolean) * @see #setExclusiveContext(Thread) */ // @Override - public final boolean isExclusiveContextEnabled() { + public final boolean isExclusiveContextEnabled() { stateSync.lock(); try { - return exclusiveContext; + return exclusiveContext; } finally { stateSync.unlock(); } } - + /** * Returns the exclusive context thread if {@link #isExclusiveContextEnabled()} and {@link #isStarted()}, otherwise null. *

    @@ -381,7 +381,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { * @see #setExclusiveContext(Thread) */ // @Override - public final Thread getExclusiveContextThread() { + public final Thread getExclusiveContextThread() { stateSync.lock(); try { return ( isStartedImpl() && exclusiveContext ) ? ( null != userExclusiveContextThread ? userExclusiveContextThread : animThread ) : null ; @@ -389,7 +389,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { stateSync.unlock(); } } - + /** * Should be called at {@link #start()} and {@link #stop()} * from within the animator thread. @@ -407,7 +407,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { for (int i=0; ifalse. - * @param pollPeriod if 0, method will wait until TO is reached or being notified. + * @param pollPeriod if 0, method will wait until TO is reached or being notified. * if > 0, method will wait for the given pollPeriod in milliseconds. * @return true if {@link Condition#eval() waitCondition.eval()} returned false, otherwise false. */ @@ -545,11 +545,11 @@ public abstract class AnimatorBase implements GLAnimatorControl { if( remaining<=0 && nok ) { System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): ++++++ timeout reached ++++++ " + getThreadName()); } - stateSync.lock(); // avoid too many lock/unlock ops + stateSync.lock(); // avoid too many lock/unlock ops try { System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): OK "+(!nok)+ "- pollPeriod "+pollPeriod+", blocking "+blocking+ - ", waited " + (blocking ? ( TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION - remaining ) : 0 ) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION + + ", waited " + (blocking ? ( TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION - remaining ) : 0 ) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION + " - " + getThreadName()); System.err.println(" - "+toString()); } finally { diff --git a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java index bbd2951b9..0477e1903 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java index 7613efec6..b48169c27 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -45,10 +45,10 @@ import java.util.TimerTask; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLException; -/** +/** * An Animator subclass which attempts to achieve a target * frames-per-second rate to avoid using all CPU time. The target FPS - * is only an estimate and is not guaranteed. + * is only an estimate and is not guaranteed. *

    * The Animator execution thread does not run as a daemon thread, * so it is able to keep an application from terminating.
    @@ -105,45 +105,45 @@ public class FPSAnimator extends AnimatorBase { * @param fps * @throws GLException if the animator has already been started */ - public final synchronized void setFPS(int fps) throws GLException { + public final synchronized void setFPS(int fps) throws GLException { if ( isStartedImpl() ) { throw new GLException("Animator already started."); } - this.fps = fps; + this.fps = fps; } public final int getFPS() { return fps; } - + class MainTask extends TimerTask { private boolean justStarted; private boolean alreadyStopped; private boolean alreadyPaused; - + public MainTask() { } - + public void start(Timer timer) { fpsCounter.resetFPSCounter(); shouldRun = true; shouldStop = false; - + justStarted = true; alreadyStopped = false; alreadyPaused = false; - final long period = 0 < fps ? (long) (1000.0f / (float) fps) : 1; // 0 -> 1: IllegalArgumentException: Non-positive period + final long period = 0 < fps ? (long) (1000.0f / (float) fps) : 1; // 0 -> 1: IllegalArgumentException: Non-positive period if (scheduleAtFixedRate) { timer.scheduleAtFixedRate(this, 0, period); } else { timer.schedule(this, 0, period); } } - + public boolean isActive() { return !alreadyStopped && !alreadyPaused; } - + public String toString() { return "Task[thread "+animThread+", stopped "+alreadyStopped+", paused "+alreadyPaused+" shouldRun "+shouldRun+", shouldStop "+shouldStop+" -- started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]"; } - + public void run() { if( justStarted ) { justStarted = false; @@ -167,8 +167,8 @@ public class FPSAnimator extends AnimatorBase { display(); } else if( shouldStop ) { // STOP System.err.println("FPSAnimator P4: "+alreadyStopped+", "+ Thread.currentThread() + ": " + toString()); - this.cancel(); - + this.cancel(); + if( !alreadyStopped ) { alreadyStopped = true; if( exclusiveContext && !drawablesEmpty ) { @@ -184,23 +184,23 @@ public class FPSAnimator extends AnimatorBase { FPSAnimator.this.notifyAll(); } } - } else { + } else { System.err.println("FPSAnimator P5: "+alreadyPaused+", "+ Thread.currentThread() + ": " + toString()); this.cancel(); - + if( !alreadyPaused ) { // PAUSE alreadyPaused = true; if( exclusiveContext && !drawablesEmpty ) { setDrawablesExclCtxState(false); display(); // propagate exclusive change! } - synchronized (FPSAnimator.this) { + synchronized (FPSAnimator.this) { if(DEBUG) { System.err.println("FPSAnimator pause " + Thread.currentThread() + ": " + toString()); } isAnimating = false; FPSAnimator.this.notifyAll(); - } + } } } } @@ -230,7 +230,7 @@ public class FPSAnimator extends AnimatorBase { } static int timerNo = 0; - + public synchronized boolean start() { if ( null != timer || null != task || isStartedImpl() ) { return false; @@ -241,8 +241,8 @@ public class FPSAnimator extends AnimatorBase { System.err.println("FPSAnimator.start() START: "+task+", "+ Thread.currentThread() + ": " + toString()); } task.start(timer); - - final boolean res = finishLifecycleAction( drawablesEmpty ? waitForStartedEmptyCondition : waitForStartedAddedCondition, + + final boolean res = finishLifecycleAction( drawablesEmpty ? waitForStartedEmptyCondition : waitForStartedAddedCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); if(DEBUG) { System.err.println("FPSAnimator.start() END: "+task+", "+ Thread.currentThread() + ": " + toString()); @@ -256,11 +256,11 @@ public class FPSAnimator extends AnimatorBase { private final Condition waitForStartedAddedCondition = new Condition() { public boolean eval() { return !isStartedImpl() || !isAnimating ; - } }; + } }; private final Condition waitForStartedEmptyCondition = new Condition() { public boolean eval() { return !isStartedImpl() || isAnimating ; - } }; + } }; /** Stops this FPSAnimator. Due to the implementation of the FPSAnimator it is not guaranteed that the FPSAnimator will be @@ -268,7 +268,7 @@ public class FPSAnimator extends AnimatorBase { public synchronized boolean stop() { if ( null == timer || !isStartedImpl() ) { return false; - } + } if(DEBUG) { System.err.println("FPSAnimator.stop() START: "+task+", "+ Thread.currentThread() + ": " + toString()); } @@ -281,7 +281,7 @@ public class FPSAnimator extends AnimatorBase { shouldStop = true; res = finishLifecycleAction(waitForStoppedCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); } - + if(DEBUG) { System.err.println("FPSAnimator.stop() END: "+task+", "+ Thread.currentThread() + ": " + toString()); } @@ -316,7 +316,7 @@ public class FPSAnimator extends AnimatorBase { shouldRun = false; res = finishLifecycleAction(waitForPausedCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); } - + if(DEBUG) { System.err.println("FPSAnimator.pause() END: "+task+", "+ Thread.currentThread() + ": " + toString()); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java index e0bbbc33c..2d685a1a8 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java @@ -53,13 +53,13 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * and starting with a new created Buffer object with initialElementCount size * * On profiles GL2 and ES1 the fixed function pipeline behavior is as expected. - * On profile ES2 the fixed function emulation will transform these calls to + * On profile ES2 the fixed function emulation will transform these calls to * EnableVertexAttribArray and VertexAttribPointer calls, * and a predefined vertex attribute variable name will be chosen. - * - * The default name mapping will be used, + * + * The default name mapping will be used, * see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}. - * + * * @param index The GL array index * @param comps The array component number * @param dataType The array index GL data type @@ -67,7 +67,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * @param initialElementCount * * @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int) - */ + */ public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int initialElementCount) throws GLException { @@ -82,13 +82,13 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * and starting with a given Buffer object incl it's stride * * On profiles GL2 and ES1 the fixed function pipeline behavior is as expected. - * On profile ES2 the fixed function emulation will transform these calls to + * On profile ES2 the fixed function emulation will transform these calls to * EnableVertexAttribArray and VertexAttribPointer calls, * and a predefined vertex attribute variable name will be chosen. - * - * The default name mapping will be used, + * + * The default name mapping will be used, * see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}. - * + * * @param index The GL array index * @param comps The array component number * @param dataType The array index GL data type @@ -97,8 +97,8 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData * @param buffer the user define data * * @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int) - */ - public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int stride, + */ + public static GLArrayDataClient createFixed(int index, int comps, int dataType, boolean normalized, int stride, Buffer buffer) throws GLException { @@ -111,13 +111,13 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData /** * Create a client side buffer object, using a custom GLSL array attribute name * and starting with a new created Buffer object with initialElementCount size - * @param name The custom name for the GL attribute. + * @param name The custom name for the GL attribute. * @param comps The array component number * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized * @param initialElementCount */ - public static GLArrayDataClient createGLSL(String name, int comps, + public static GLArrayDataClient createGLSL(String name, int comps, int dataType, boolean normalized, int initialElementCount) throws GLException { @@ -130,7 +130,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData /** * Create a client side buffer object, using a custom GLSL array attribute name * and starting with a given Buffer object incl it's stride - * @param name The custom name for the GL attribute. + * @param name The custom name for the GL attribute. * @param comps The array component number * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized @@ -157,8 +157,8 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData } } } - - // + + // // Data read access // @@ -167,7 +167,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData @Override public final boolean sealed() { return sealed; } - + @Override public final boolean enabled() { return bufferEnabled; } @@ -195,10 +195,10 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData seal(seal); enableBuffer(gl, seal); } - + @Override public void enableBuffer(GL gl, boolean enable) { - if( enableBufferAlways || bufferEnabled != enable ) { + if( enableBufferAlways || bufferEnabled != enable ) { if(enable) { checkSeal(true); // init/generate VBO name if not done yet @@ -208,7 +208,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData bufferEnabled = enable; } } - + @Override public boolean bindBuffer(GL gl, boolean bind) { if(bind) { @@ -218,7 +218,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData } return glArrayHandler.bindBuffer(gl, bind); } - + @Override public void setEnableAlways(boolean always) { enableBufferAlways = always; @@ -328,15 +328,15 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData ", isVertexAttribute "+isVertexAttribute+ ", usesGLSL "+usesGLSL+ ", usesShaderState "+(null!=shaderState)+ - ", dataType 0x"+Integer.toHexString(componentType)+ - ", bufferClazz "+componentClazz+ + ", dataType 0x"+Integer.toHexString(componentType)+ + ", bufferClazz "+componentClazz+ ", elements "+getElementCount()+ - ", components "+components+ + ", components "+components+ ", stride "+strideB+"b "+strideL+"c"+ - ", initialElementCount "+initialElementCount+ - ", sealed "+sealed+ - ", bufferEnabled "+bufferEnabled+ - ", bufferWritten "+bufferWritten+ + ", initialElementCount "+initialElementCount+ + ", sealed "+sealed+ + ", bufferEnabled "+bufferEnabled+ + ", bufferWritten "+bufferWritten+ ", buffer "+buffer+ ", alive "+alive+ "]"; @@ -345,16 +345,16 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData // non public matters protected final boolean growBufferIfNecessary(int spare) { - if(buffer==null || buffer.remaining()enable is true, + * Enables the buffer if enable is true, * and transfers the data if required. * In case {@link #isVBO() VBO is used}, it is bound accordingly for the data transfer and association, * i.e. it issued {@link #bindBuffer(GL, boolean)}. - * The VBO buffer is unbound when the method returns. + * The VBO buffer is unbound when the method returns. *

    - * Disables the buffer if enable is false. + * Disables the buffer if enable is false. *

    - * + * *

    The action will only be executed, - * if the internal enable state differs, + * if the internal enable state differs, * or 'setEnableAlways' was called with 'true'. - * + * *

    It is up to the user to enable/disable the array properly, * ie in case of multiple data sets for the same vertex attribute (VA). * Meaning in such case usage of one set while expecting another one @@ -68,7 +68,7 @@ public interface GLArrayDataEditable extends GLArrayData { public void enableBuffer(GL gl, boolean enable); /** - * if bind is true and the data uses {@link #isVBO() VBO}, + * if bind is true and the data uses {@link #isVBO() VBO}, * the latter will be bound and data written to the GPU if required. *

    * If bind is false and the data uses {@link #isVBO() VBO}, @@ -79,11 +79,11 @@ public interface GLArrayDataEditable extends GLArrayData { * to be bounded and written while keeping the VBO bound. The latter is in contrast to {@link #enableBuffer(GL, boolean)}, * which leaves the VBO unbound, since it's not required for vertex attributes or pointers. *

    - * + * * @param gl current GL object - * @param bind true if VBO shall be bound and data written, - * otherwise clear VBO binding. - * @return true if data uses VBO and action was performed, otherwise false + * @param bind true if VBO shall be bound and data written, + * otherwise clear VBO binding. + * @return true if data uses VBO and action was performed, otherwise false */ public boolean bindBuffer(GL gl, boolean bind); @@ -92,7 +92,7 @@ public interface GLArrayDataEditable extends GLArrayData { * * The default is 'false' * - * This is useful when you mix up + * This is useful when you mix up * GLArrayData usage with conventional GL array calls * or in case of a buggy GL VBO implementation. * @@ -117,7 +117,7 @@ public interface GLArrayDataEditable extends GLArrayData { * ie position:=limit and limit:=capacity.

    * * @see #seal(boolean) - */ + */ public void seal(boolean seal); public void rewind(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java index 7e7d27b36..80639c5c7 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java @@ -57,13 +57,13 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * and starting with a given Buffer object incl it's stride * * On profiles GL2 and ES1 the fixed function pipeline behavior is as expected. - * On profile ES2 the fixed function emulation will transform these calls to + * On profile ES2 the fixed function emulation will transform these calls to * EnableVertexAttribArray and VertexAttribPointer calls, * and a predefined vertex attribute variable name will be chosen. - * - * The default name mapping will be used, + * + * The default name mapping will be used, * see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}. - * + * * @param index The GL array index * @param comps The array component number * @param dataType The array index GL data type @@ -90,13 +90,13 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * and starting with a new created Buffer object with initialElementCount size * * On profiles GL2 and ES1 the fixed function pipeline behavior is as expected. - * On profile ES2 the fixed function emulation will transform these calls to + * On profile ES2 the fixed function emulation will transform these calls to * EnableVertexAttribArray and VertexAttribPointer calls, * and a predefined vertex attribute variable name will be chosen. - * - * The default name mapping will be used, + * + * The default name mapping will be used, * see {@link GLPointerFuncUtil#getPredefinedArrayIndexName(int)}. - * + * * @param index The GL array index * @param comps The array component number * @param dataType The array index GL data type @@ -106,7 +106,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * * @see javax.media.opengl.GLContext#getPredefinedArrayIndexName(int) */ - public static GLArrayDataServer createFixed(int index, int comps, int dataType, boolean normalized, int initialElementCount, + public static GLArrayDataServer createFixed(int index, int comps, int dataType, boolean normalized, int initialElementCount, int vboUsage) throws GLException { @@ -120,7 +120,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE /** * Create a VBO, using a custom GLSL array attribute name * and starting with a new created Buffer object with initialElementCount size - * @param name The custom name for the GL attribute + * @param name The custom name for the GL attribute * @param comps The array component number * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized @@ -128,20 +128,20 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ public static GLArrayDataServer createGLSL(String name, int comps, - int dataType, boolean normalized, int initialElementCount, int vboUsage) - throws GLException + int dataType, boolean normalized, int initialElementCount, int vboUsage) + throws GLException { GLArrayDataServer ads = new GLArrayDataServer(); GLArrayHandler glArrayHandler = new GLSLArrayHandler(ads); ads.init(name, -1, comps, dataType, normalized, 0, null, initialElementCount, true, glArrayHandler, 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); return ads; - } - + } + /** * Create a VBO, using a custom GLSL array attribute name * and starting with a given Buffer object incl it's stride - * @param name The custom name for the GL attribute + * @param name The custom name for the GL attribute * @param comps The array component number * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized @@ -151,7 +151,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE */ public static GLArrayDataServer createGLSL(String name, int comps, int dataType, boolean normalized, int stride, Buffer buffer, - int vboUsage) + int vboUsage) throws GLException { GLArrayDataServer ads = new GLArrayDataServer(); @@ -160,12 +160,12 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); return ads; } - + /** * Create a VBO data object for any target w/o render pipeline association, ie {@link GL#GL_ELEMENT_ARRAY_BUFFER}. - * + * * Hence no index, name for a fixed function pipeline nor vertex attribute is given. - * + * * @param comps The array component number * @param dataType The array index GL data type * @param stride @@ -187,16 +187,16 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE /** * Create a VBO data object for any target w/o render pipeline association, ie {@link GL#GL_ELEMENT_ARRAY_BUFFER}. - * + * * Hence no index, name for a fixed function pipeline nor vertex attribute is given. - * + * * @param comps The array component number * @param dataType The array index GL data type * @param initialElementCount * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} * @param vboTarget {@link GL#GL_ELEMENT_ARRAY_BUFFER}, .. */ - public static GLArrayDataServer createData(int comps, int dataType, int initialElementCount, + public static GLArrayDataServer createData(int comps, int dataType, int initialElementCount, int vboUsage, int vboTarget) throws GLException { @@ -207,19 +207,19 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE return ads; } - + /** * Create a VBO for fixed function interleaved array data * starting with a new created Buffer object with initialElementCount size. *

    User needs to configure the interleaved segments via {@link #addFixedSubArray(int, int, int)}.

    - * + * * @param comps The total number of all interleaved components. * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized - * @param initialElementCount + * @param initialElementCount * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createFixedInterleaved(int comps, int dataType, boolean normalized, int initialElementCount, + public static GLArrayDataServer createFixedInterleaved(int comps, int dataType, boolean normalized, int initialElementCount, int vboUsage) throws GLException { @@ -239,7 +239,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * The memory of the the interleaved array is being used.

    *

    * Must be called before using the array, eg: {@link #seal(boolean)}, {@link #putf(float)}, ..

    - * + * * @param index The GL array index, maybe -1 if vboTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER} * @param comps This interleaved array segment's component number * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER} @@ -250,32 +250,32 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")"); } if(usesGLSL) { - throw new GLException("buffer uses GLSL"); + throw new GLException("buffer uses GLSL"); } final GLArrayDataWrapper ad = GLArrayDataWrapper.createFixed( - index, comps, getComponentType(), - getNormalized(), getStride(), getBuffer(), + index, comps, getComponentType(), + getNormalized(), getStride(), getBuffer(), getVBOName(), interleavedOffset, getVBOUsage(), vboTarget); ad.setVBOEnabled(isVBO()); interleavedOffset += comps * getComponentSizeInBytes(); - if(GL.GL_ARRAY_BUFFER == vboTarget) { + if(GL.GL_ARRAY_BUFFER == vboTarget) { glArrayHandler.addSubHandler(new GLFixedArrayHandlerFlat(ad)); } return ad; } - + /** * Create a VBO for GLSL interleaved array data * starting with a new created Buffer object with initialElementCount size. *

    User needs to configure the interleaved segments via {@link #addGLSLSubArray(int, int, int)}.

    - * + * * @param comps The total number of all interleaved components. * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized - * @param initialElementCount + * @param initialElementCount * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} */ - public static GLArrayDataServer createGLSLInterleaved(int comps, int dataType, boolean normalized, int initialElementCount, + public static GLArrayDataServer createGLSLInterleaved(int comps, int dataType, boolean normalized, int initialElementCount, int vboUsage) throws GLException { @@ -285,7 +285,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); return ads; } - + /** * Configure a segment of this GLSL interleaved array (see {@link #createGLSLInterleaved(int, int, boolean, int, int)}). *

    @@ -305,20 +305,20 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE throw new GLException("Interleaved offset > total components ("+iOffC+" > "+getComponentCount()+")"); } if(!usesGLSL) { - throw new GLException("buffer uses fixed function"); + throw new GLException("buffer uses fixed function"); } final GLArrayDataWrapper ad = GLArrayDataWrapper.createGLSL( - name, comps, getComponentType(), - getNormalized(), getStride(), getBuffer(), - getVBOName(), interleavedOffset, getVBOUsage(), vboTarget); + name, comps, getComponentType(), + getNormalized(), getStride(), getBuffer(), + getVBOName(), interleavedOffset, getVBOUsage(), vboTarget); ad.setVBOEnabled(isVBO()); interleavedOffset += comps * getComponentSizeInBytes(); - if(GL.GL_ARRAY_BUFFER == vboTarget) { + if(GL.GL_ARRAY_BUFFER == vboTarget) { glArrayHandler.addSubHandler(new GLSLArrayHandlerFlat(ad)); } return ad; } - + // // Data matters GLArrayData // @@ -341,15 +341,15 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE } // - // data matters + // data matters // /** - * Convenient way do disable the VBO behavior and + * Convenient way do disable the VBO behavior and * switch to client side data one * Only possible if buffer is defined. */ - public void setVBOEnabled(boolean vboUsage) { + public void setVBOEnabled(boolean vboUsage) { checkSeal(false); super.setVBOEnabled(vboUsage); } @@ -361,22 +361,22 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE ", isVertexAttribute "+isVertexAttribute+ ", usesGLSL "+usesGLSL+ ", usesShaderState "+(null!=shaderState)+ - ", dataType 0x"+Integer.toHexString(componentType)+ - ", bufferClazz "+componentClazz+ + ", dataType 0x"+Integer.toHexString(componentType)+ + ", bufferClazz "+componentClazz+ ", elements "+getElementCount()+ - ", components "+components+ + ", components "+components+ ", stride "+strideB+"b "+strideL+"c"+ ", initialElementCount "+initialElementCount+ - ", vboEnabled "+vboEnabled+ - ", vboName "+vboName+ - ", vboUsage 0x"+Integer.toHexString(vboUsage)+ - ", vboTarget 0x"+Integer.toHexString(vboTarget)+ - ", vboOffset "+vboOffset+ - ", sealed "+sealed+ - ", bufferEnabled "+bufferEnabled+ - ", bufferWritten "+bufferWritten+ - ", buffer "+buffer+ - ", alive "+alive+ + ", vboEnabled "+vboEnabled+ + ", vboName "+vboName+ + ", vboUsage 0x"+Integer.toHexString(vboUsage)+ + ", vboTarget 0x"+Integer.toHexString(vboTarget)+ + ", vboOffset "+vboOffset+ + ", sealed "+sealed+ + ", bufferEnabled "+bufferEnabled+ + ", bufferWritten "+bufferWritten+ + ", buffer "+buffer+ + ", alive "+alive+ "]"; } @@ -384,7 +384,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE // non public matters .. // - protected void init(String name, int index, int comps, int dataType, boolean normalized, + protected void init(String name, int index, int comps, int dataType, boolean normalized, int stride, Buffer data, int initialElementCount, boolean isVertexAttribute, GLArrayHandler glArrayHandler, int vboName, long vboOffset, int vboUsage, int vboTarget, boolean usesGLSL) @@ -407,7 +407,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE } } } - - private int interleavedOffset = 0; + + private int interleavedOffset = 0; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java index f8b17501e..290f47a6d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataWrapper.java @@ -49,7 +49,7 @@ public class GLArrayDataWrapper implements GLArrayData { /** * Create a VBO, using a predefined fixed function array index, wrapping the given data. - * + * * @param index The GL array index * @param comps The array component number * @param dataType The array index GL data type @@ -61,23 +61,23 @@ public class GLArrayDataWrapper implements GLArrayData { * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} * @param vboTarget {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER} * @return the new create instance - * + * * @throws GLException */ - public static GLArrayDataWrapper createFixed(int index, int comps, int dataType, boolean normalized, int stride, + public static GLArrayDataWrapper createFixed(int index, int comps, int dataType, boolean normalized, int stride, Buffer buffer, int vboName, long vboOffset, int vboUsage, int vboTarget) throws GLException { GLArrayDataWrapper adc = new GLArrayDataWrapper(); - adc.init(null, index, comps, dataType, normalized, stride, buffer, false, + adc.init(null, index, comps, dataType, normalized, stride, buffer, false, vboName, vboOffset, vboUsage, vboTarget); return adc; } /** * Create a VBO, using a custom GLSL array attribute name, wrapping the given data. - * - * @param name The custom name for the GL attribute, maybe null if gpuBufferTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER} + * + * @param name The custom name for the GL attribute, maybe null if gpuBufferTarget is {@link GL#GL_ELEMENT_ARRAY_BUFFER} * @param comps The array component number * @param dataType The array index GL data type * @param normalized Whether the data shall be normalized @@ -90,7 +90,7 @@ public class GLArrayDataWrapper implements GLArrayData { * @return the new create instance * @throws GLException */ - public static GLArrayDataWrapper createGLSL(String name, int comps, int dataType, boolean normalized, int stride, + public static GLArrayDataWrapper createGLSL(String name, int comps, int dataType, boolean normalized, int stride, Buffer buffer, int vboName, long vboOffset, int vboUsage, int vboTarget) throws GLException { @@ -102,8 +102,8 @@ public class GLArrayDataWrapper implements GLArrayData { /** * Validates this instance's parameter. Called automatically by {@link GLArrayDataClient} and {@link GLArrayDataServer}. - * {@link GLArrayDataWrapper} does not validate it's instance by itself. - * + * {@link GLArrayDataWrapper} does not validate it's instance by itself. + * * @param glp the GLProfile to use * @param throwException whether to throw an exception if this instance has invalid parameter or not * @return true if this instance has invalid parameter, otherwise false @@ -113,7 +113,7 @@ public class GLArrayDataWrapper implements GLArrayData { if(throwException) { throw new GLException("Instance !alive "+this); } - return false; + return false; } if(this.isVertexAttribute() && !glp.hasGLSL()) { if(throwException) { @@ -123,13 +123,13 @@ public class GLArrayDataWrapper implements GLArrayData { } return glp.isValidArrayDataType(getIndex(), getComponentCount(), getComponentType(), isVertexAttribute(), throwException); } - + @Override public void associate(Object obj, boolean enable) { // nop } - - // + + // // Data read access // @@ -150,14 +150,14 @@ public class GLArrayDataWrapper implements GLArrayData { location = gl.glGetAttribLocation(program, name); return location; } - + @Override public final int setLocation(GL2ES2 gl, int program, int location) { this.location = location; gl.glBindAttribLocation(program, location, name); return location; } - + @Override public final String getName() { return name; } @@ -172,10 +172,10 @@ public class GLArrayDataWrapper implements GLArrayData { @Override public final int getVBOUsage() { return vboEnabled?vboUsage:0; } - + @Override public final int getVBOTarget() { return vboEnabled?vboTarget:0; } - + @Override public final Buffer getBuffer() { return buffer; } @@ -187,19 +187,19 @@ public class GLArrayDataWrapper implements GLArrayData { @Override public final int getComponentSizeInBytes() { return componentByteSize; } - + @Override public final int getElementCount() { if(null==buffer) return 0; return ( buffer.position()==0 ) ? ( buffer.limit() / components ) : ( buffer.position() / components ) ; } - + @Override public final int getSizeInBytes() { if(null==buffer) return 0; - return ( buffer.position()==0 ) ? ( buffer.limit() * componentByteSize ) : ( buffer.position() * componentByteSize ) ; + return ( buffer.position()==0 ) ? ( buffer.limit() * componentByteSize ) : ( buffer.position() * componentByteSize ) ; } - + @Override public final boolean getNormalized() { return normalized; } @@ -223,18 +223,18 @@ public class GLArrayDataWrapper implements GLArrayData { ", index "+index+ ", location "+location+ ", isVertexAttribute "+isVertexAttribute+ - ", dataType 0x"+Integer.toHexString(componentType)+ - ", bufferClazz "+componentClazz+ + ", dataType 0x"+Integer.toHexString(componentType)+ + ", bufferClazz "+componentClazz+ ", elements "+getElementCount()+ - ", components "+components+ + ", components "+components+ ", stride "+strideB+"b "+strideL+"c"+ - ", buffer "+buffer+ - ", vboEnabled "+vboEnabled+ - ", vboName "+vboName+ - ", vboUsage 0x"+Integer.toHexString(vboUsage)+ - ", vboTarget 0x"+Integer.toHexString(vboTarget)+ - ", vboOffset "+vboOffset+ - ", alive "+alive+ + ", buffer "+buffer+ + ", vboEnabled "+vboEnabled+ + ", vboName "+vboName+ + ", vboUsage 0x"+Integer.toHexString(vboUsage)+ + ", vboTarget 0x"+Integer.toHexString(vboTarget)+ + ", vboOffset "+vboOffset+ + ", alive "+alive+ "]"; } @@ -252,12 +252,12 @@ public class GLArrayDataWrapper implements GLArrayData { return IntBuffer.class; case GL.GL_FLOAT: return FloatBuffer.class; - default: + default: throw new GLException("Given OpenGL data type not supported: "+dataType); } } - @Override + @Override public void setName(String newName) { location = -1; name = newName; @@ -267,7 +267,7 @@ public class GLArrayDataWrapper implements GLArrayData { * Enable or disable use of VBO. * Only possible if a VBO buffer name is defined. * @see #setVBOName(int) - */ + */ public void setVBOEnabled(boolean vboEnabled) { this.vboEnabled=vboEnabled; } @@ -275,31 +275,31 @@ public class GLArrayDataWrapper implements GLArrayData { /** * Set the VBO buffer name, if valid (!= 0) enable use of VBO, * otherwise (==0) disable VBO usage. - * + * * @see #setVBOEnabled(boolean) - */ + */ public void setVBOName(int vboName) { this.vboName=vboName; setVBOEnabled(0!=vboName); } - /** + /** * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} - */ - public void setVBOUsage(int vboUsage) { - this.vboUsage = vboUsage; + */ + public void setVBOUsage(int vboUsage) { + this.vboUsage = vboUsage; } - - /** + + /** * @param vboTarget either {@link GL#GL_ARRAY_BUFFER} or {@link GL#GL_ELEMENT_ARRAY_BUFFER} - */ + */ public void setVBOTarget(int vboTarget) { this.vboTarget = vboTarget; - } + } - protected void init(String name, int index, int components, int componentType, - boolean normalized, int stride, Buffer data, - boolean isVertexAttribute, + protected void init(String name, int index, int components, int componentType, + boolean normalized, int stride, Buffer data, + boolean isVertexAttribute, int vboName, long vboOffset, int vboUsage, int vboTarget) throws GLException { @@ -307,19 +307,19 @@ public class GLArrayDataWrapper implements GLArrayData { this.index = index; this.location = -1; // We can't have any dependence on the FixedFuncUtil class here for build bootstrapping reasons - + if( GL.GL_ELEMENT_ARRAY_BUFFER == vboTarget ) { // OK .. } else if( ( 0 == vboUsage && 0 == vboTarget ) || GL.GL_ARRAY_BUFFER == vboTarget ) { - // Set/Check name .. - Required for GLSL case. Validation and debug-name for FFP. + // Set/Check name .. - Required for GLSL case. Validation and debug-name for FFP. this.name = ( null == name ) ? GLPointerFuncUtil.getPredefinedArrayIndexName(index) : name ; if(null == this.name ) { throw new GLException("Not a valid array buffer index: "+index); - } + } } else if( 0 < vboTarget ) { throw new GLException("Invalid GPUBuffer target: 0x"+Integer.toHexString(vboTarget)); } - + this.componentType = componentType; componentClazz = getBufferClass(componentType); if( GLBuffers.isGLTypeFixedPoint(componentType) ) { @@ -329,7 +329,7 @@ public class GLArrayDataWrapper implements GLArrayData { } componentByteSize = GLBuffers.sizeOfGLType(componentType); if(0 > componentByteSize) { - throw new GLException("Given componentType not supported: "+componentType+":\n\t"+this); + throw new GLException("Given componentType not supported: "+componentType+":\n\t"+this); } if(0 >= components) { throw new GLException("Invalid number of components: " + components); @@ -348,7 +348,7 @@ public class GLArrayDataWrapper implements GLArrayData { this.vboName= vboName; this.vboEnabled= 0 != vboName ; this.vboOffset=vboOffset; - + switch(vboUsage) { case 0: // nop case GL.GL_STATIC_DRAW: @@ -356,7 +356,7 @@ public class GLArrayDataWrapper implements GLArrayData { case GL2ES2.GL_STREAM_DRAW: break; default: - throw new GLException("invalid gpuBufferUsage: "+vboUsage+":\n\t"+this); + throw new GLException("invalid gpuBufferUsage: "+vboUsage+":\n\t"+this); } switch(vboTarget) { case 0: // nop @@ -367,7 +367,7 @@ public class GLArrayDataWrapper implements GLArrayData { throw new GLException("invalid gpuBufferTarget: "+vboTarget+":\n\t"+this); } this.vboUsage=vboUsage; - this.vboTarget=vboTarget; + this.vboTarget=vboTarget; this.alive=true; } @@ -390,6 +390,6 @@ public class GLArrayDataWrapper implements GLArrayData { protected int vboName; protected boolean vboEnabled; protected int vboUsage; - protected int vboTarget; + protected int vboTarget; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java index 6bdea4518..418d7fa81 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -52,7 +52,7 @@ import com.jogamp.common.nio.Buffers; /** * Utility routines for dealing with direct buffers. - * + * * @author Kenneth Russel, et.al. */ public class GLBuffers extends Buffers { @@ -72,11 +72,11 @@ public class GLBuffers extends Buffers { case GL.GL_UNSIGNED_INT: case GL2.GL_HILO16_NV: return false; - + } return true; } - + /** * @param glType GL primitive type * @return false if one of GL primitive floating point types, otherwise true @@ -92,19 +92,19 @@ public class GLBuffers extends Buffers { case GLES2.GL_HALF_FLOAT_OES: case GL2GL3.GL_DOUBLE: return false; - + default: return true; - } + } } - + /** * @param glType shall be one of (31)
    * GL_BYTE, GL_UNSIGNED_BYTE,
    * GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
    *
    * GL_SHORT, GL_UNSIGNED_SHORT,
    - * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
    + * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
    * GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
    * GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
    * GL_UNSIGNED_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
    @@ -112,16 +112,16 @@ public class GLBuffers extends Buffers { *
    * GL_FIXED, GL_INT
    * GL_UNSIGNED_INT, GL_UNSIGNED_INT_8_8_8_8,
    - * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
    + * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
    * GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_24_8,
    - * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
    + * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
    * GL_HILO16_NV, GL_SIGNED_HILO16_NV
    *
    * GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV
    *
    - * GL_FLOAT, GL_DOUBLE
    - * - * @return -1 if glType is unhandled, otherwise the actual value > 0 + * GL_FLOAT, GL_DOUBLE
    + * + * @return -1 if glType is unhandled, otherwise the actual value > 0 */ public static final int sizeOfGLType(int glType) { switch (glType) { // 29 @@ -131,7 +131,7 @@ public class GLBuffers extends Buffers { case GL2GL3.GL_UNSIGNED_BYTE_3_3_2: case GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV: return SIZEOF_BYTE; - + case GL.GL_SHORT: case GL.GL_UNSIGNED_SHORT: case GL.GL_UNSIGNED_SHORT_5_6_5: @@ -145,40 +145,40 @@ public class GLBuffers extends Buffers { case GL.GL_HALF_FLOAT: case GLES2.GL_HALF_FLOAT_OES: return SIZEOF_SHORT; - + case GL.GL_FIXED: case GL2ES2.GL_INT: case GL.GL_UNSIGNED_INT: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV: case GL2GL3.GL_UNSIGNED_INT_10_10_10_2: - case GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV: + case GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV: case GL2GL3.GL_UNSIGNED_INT_24_8: case GL2GL3.GL_UNSIGNED_INT_10F_11F_11F_REV: case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV: case GL2.GL_HILO16_NV: case GL2.GL_SIGNED_HILO16_NV: return SIZEOF_INT; - + case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: return SIZEOF_LONG; - + case GL.GL_FLOAT: return SIZEOF_FLOAT; - + case GL2GL3.GL_DOUBLE: return SIZEOF_DOUBLE; } return -1; } - + /** * @param glType shall be one of (31)
    * GL_BYTE, GL_UNSIGNED_BYTE,
    * GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
    *
    * GL_SHORT, GL_UNSIGNED_SHORT,
    - * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
    + * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
    * GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
    * GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
    * GL_UNSIGNED_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
    @@ -186,16 +186,16 @@ public class GLBuffers extends Buffers { *
    * GL_FIXED, GL_INT
    * GL_UNSIGNED_INT, GL_UNSIGNED_INT_8_8_8_8,
    - * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
    + * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
    * GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_24_8,
    - * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
    + * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
    * GL_HILO16_NV, GL_SIGNED_HILO16_NV
    *
    * GL_FLOAT_32_UNSIGNED_INT_24_8_REV
    *
    - * GL_FLOAT, GL_DOUBLE
    - * - * @return null if glType is unhandled, otherwise the new Buffer object + * GL_FLOAT, GL_DOUBLE
    + * + * @return null if glType is unhandled, otherwise the new Buffer object */ public static final Buffer newDirectGLBuffer(int glType, int numElements) { switch (glType) { // 29 @@ -204,7 +204,7 @@ public class GLBuffers extends Buffers { case GL2GL3.GL_UNSIGNED_BYTE_3_3_2: case GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV: return newDirectByteBuffer(numElements); - + case GL.GL_SHORT: case GL.GL_UNSIGNED_SHORT: case GL.GL_UNSIGNED_SHORT_5_6_5: @@ -218,7 +218,7 @@ public class GLBuffers extends Buffers { case GL.GL_HALF_FLOAT: case GLES2.GL_HALF_FLOAT_OES: return newDirectShortBuffer(numElements); - + case GL.GL_FIXED: case GL2ES2.GL_INT: case GL.GL_UNSIGNED_INT: @@ -232,13 +232,13 @@ public class GLBuffers extends Buffers { case GL2.GL_HILO16_NV: case GL2.GL_SIGNED_HILO16_NV: return newDirectIntBuffer(numElements); - + case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: return newDirectLongBuffer(numElements); - + case GL.GL_FLOAT: return newDirectFloatBuffer(numElements); - + case GL2.GL_DOUBLE: return newDirectDoubleBuffer(numElements); } @@ -251,7 +251,7 @@ public class GLBuffers extends Buffers { * GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
    *
    * GL_SHORT, GL_UNSIGNED_SHORT,
    - * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
    + * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
    * GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
    * GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
    * GL_UNSIGNED_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
    @@ -259,15 +259,15 @@ public class GLBuffers extends Buffers { *
    * GL_FIXED, GL_INT
    * GL_UNSIGNED_INT, GL_UNSIGNED_INT_8_8_8_8,
    - * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
    + * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
    * GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_24_8,
    - * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
    + * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
    * GL_HILO16_NV, GL_SIGNED_HILO16_NV
    *
    * GL_FLOAT_32_UNSIGNED_INT_24_8_REV
    *
    - * GL_FLOAT, GL_DOUBLE
    - * @return null if glType is unhandled or parent is null or bufLen is 0, otherwise the new Buffer object + * GL_FLOAT, GL_DOUBLE
    + * @return null if glType is unhandled or parent is null or bufLen is 0, otherwise the new Buffer object */ public static final Buffer sliceGLBuffer(ByteBuffer parent, int bytePos, int byteLen, int glType) { if (parent == null || byteLen == 0) { @@ -275,11 +275,11 @@ public class GLBuffers extends Buffers { } final int parentPos = parent.position(); final int parentLimit = parent.limit(); - + parent.position(bytePos); parent.limit(bytePos + byteLen); Buffer res = null; - + switch (glType) { // 29 case GL.GL_BYTE: case GL.GL_UNSIGNED_BYTE: @@ -287,7 +287,7 @@ public class GLBuffers extends Buffers { case GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV: res = parent.slice().order(parent.order()); // slice and duplicate may change byte order break; - + case GL.GL_SHORT: case GL.GL_UNSIGNED_SHORT: case GL.GL_UNSIGNED_SHORT_5_6_5: @@ -302,7 +302,7 @@ public class GLBuffers extends Buffers { case GLES2.GL_HALF_FLOAT_OES: res = parent.slice().order(parent.order()).asShortBuffer(); // slice and duplicate may change byte order break; - + case GL.GL_FIXED: case GL2GL3.GL_INT: case GL2ES2.GL_UNSIGNED_INT: @@ -317,15 +317,15 @@ public class GLBuffers extends Buffers { case GL2.GL_SIGNED_HILO16_NV: res = parent.slice().order(parent.order()).asIntBuffer(); // slice and duplicate may change byte order break; - + case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: res = parent.slice().order(parent.order()).asLongBuffer(); // slice and duplicate may change byte order break; - + case GL.GL_FLOAT: res = parent.slice().order(parent.order()).asFloatBuffer(); // slice and duplicate may change byte order break; - + case GL2.GL_DOUBLE: res = parent.slice().order(parent.order()).asDoubleBuffer(); // slice and duplicate may change byte order break; @@ -338,29 +338,29 @@ public class GLBuffers extends Buffers { gl.glGetIntegerv(pname, tmp, 0); return tmp[0]; } - - /** + + /** * Returns the number of bytes required to read/write a memory buffer via OpenGL * using the current GL pixel storage state and the given parameters. - * + * *

    This method is security critical, hence it throws an exception (fail-fast) - * in case of an invalid alignment. In case we forgot to handle - * proper values, please contact the maintainer.

    - * + * in case of an invalid alignment. In case we forgot to handle + * proper values, please contact the maintainer.

    + * * @param gl the current GL object - * + * * @param tmp a pass through integer array of size >= 1 used to store temp data (performance) - * + * * @param bytesPerPixel bytes per pixel, i.e. via {@link #bytesPerPixel(int, int)}. * @param width in pixels * @param height in pixels * @param depth in pixels - * @param pack true for read mode GPU -> CPU (pack), otherwise false for write mode CPU -> GPU (unpack) + * @param pack true for read mode GPU -> CPU (pack), otherwise false for write mode CPU -> GPU (unpack) * @return required minimum size of the buffer in bytes * @throws GLException if alignment is invalid. Please contact the maintainer if this is our bug. */ - public static final int sizeof(GL gl, int tmp[], - int bytesPerPixel, int width, int height, int depth, + public static final int sizeof(GL gl, int tmp[], + int bytesPerPixel, int width, int height, int depth, boolean pack) { int rowLength = 0; int skipRows = 0; @@ -368,31 +368,31 @@ public class GLBuffers extends Buffers { int alignment = 1; int imageHeight = 0; int skipImages = 0; - - if (pack) { + + if (pack) { alignment = glGetInteger(gl, GL.GL_PACK_ALIGNMENT, tmp); if(gl.isGL2GL3()) { rowLength = glGetInteger(gl, GL2GL3.GL_PACK_ROW_LENGTH, tmp); - skipRows = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_ROWS, tmp); + skipRows = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_ROWS, tmp); skipPixels = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_PIXELS, tmp); - if (depth > 1) { - imageHeight = glGetInteger(gl, GL2GL3.GL_PACK_IMAGE_HEIGHT, tmp); + if (depth > 1) { + imageHeight = glGetInteger(gl, GL2GL3.GL_PACK_IMAGE_HEIGHT, tmp); skipImages = glGetInteger(gl, GL2GL3.GL_PACK_SKIP_IMAGES, tmp); } } - } else { + } else { alignment = glGetInteger(gl, GL.GL_UNPACK_ALIGNMENT, tmp); - if(gl.isGL2GL3 ()) { - rowLength = glGetInteger(gl, GL2GL3.GL_UNPACK_ROW_LENGTH, tmp); - skipRows = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_ROWS, tmp); + if(gl.isGL2GL3 ()) { + rowLength = glGetInteger(gl, GL2GL3.GL_UNPACK_ROW_LENGTH, tmp); + skipRows = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_ROWS, tmp); skipPixels = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_PIXELS, tmp); - if (depth > 1) { - imageHeight = glGetInteger(gl, GL2GL3.GL_UNPACK_IMAGE_HEIGHT, tmp); + if (depth > 1) { + imageHeight = glGetInteger(gl, GL2GL3.GL_UNPACK_IMAGE_HEIGHT, tmp); skipImages = glGetInteger(gl, GL2GL3.GL_UNPACK_SKIP_IMAGES, tmp); } } } - + // Try to deal somewhat correctly with potentially invalid values width = Math.max(0, width ); height = Math.max(1, height); // min 1D @@ -401,13 +401,13 @@ public class GLBuffers extends Buffers { skipPixels = Math.max(0, skipPixels); alignment = Math.max(1, alignment); skipImages = Math.max(0, skipImages); - + imageHeight = ( imageHeight > 0 ) ? imageHeight : height; rowLength = ( rowLength > 0 ) ? rowLength : width; - + int rowLengthInBytes = rowLength * bytesPerPixel; int skipBytes = skipPixels * bytesPerPixel; - + switch(alignment) { case 1: break; @@ -423,71 +423,71 @@ public class GLBuffers extends Buffers { if (remainder > 0) { skipBytes += alignment - remainder; } - } + } break; default: - throw new GLException("Invalid alignment "+alignment+", must be 2**n (1,2,4,8). Pls notify the maintainer in case this is our bug."); + throw new GLException("Invalid alignment "+alignment+", must be 2**n (1,2,4,8). Pls notify the maintainer in case this is our bug."); } - + /** * skipImages, depth, skipPixels and skipRows are static offsets. * * skipImages and depth are in multiples of image size. * * skipBytes and rowLengthInBytes are aligned - * - * rowLengthInBytes is the aligned byte offset + * + * rowLengthInBytes is the aligned byte offset * from line n to line n+1 at the same x-axis position. */ return skipBytes + // aligned skipPixels * bpp - ( skipImages + depth - 1 ) * imageHeight * rowLengthInBytes + // aligned whole images + ( skipImages + depth - 1 ) * imageHeight * rowLengthInBytes + // aligned whole images ( skipRows + height - 1 ) * rowLengthInBytes + // aligned lines - width * bytesPerPixel; // last line + width * bytesPerPixel; // last line } - - /** + + /** * Returns the number of bytes required to read/write a memory buffer via OpenGL * using the current GL pixel storage state and the given parameters. - * + * *

    This method is security critical, hence it throws an exception (fail-fast) - * in case either the format, type or alignment is unhandled. In case we forgot to handle - * proper values, please contact the maintainer.

    - * + * in case either the format, type or alignment is unhandled. In case we forgot to handle + * proper values, please contact the maintainer.

    + * *

    See {@link #bytesPerPixel(int, int)}.

    - * + * * @param gl the current GL object - * + * * @param tmp a pass through integer array of size >= 1 used to store temp data (performance) - * - * @param format must be one of (27)
    - * GL_COLOR_INDEX GL_STENCIL_INDEX
    - * GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
    - * GL_RED GL_RED_INTEGER
    - * GL_GREEN GL_GREEN_INTEGER
    - * GL_BLUE GL_BLUE_INTEGER
    - * GL_ALPHA GL_LUMINANCE (12)
    - *
    + * + * @param format must be one of (27)
    + * GL_COLOR_INDEX GL_STENCIL_INDEX
    + * GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
    + * GL_RED GL_RED_INTEGER
    + * GL_GREEN GL_GREEN_INTEGER
    + * GL_BLUE GL_BLUE_INTEGER
    + * GL_ALPHA GL_LUMINANCE (12)
    + *
    * GL_LUMINANCE_ALPHA GL_RG
    - * GL_RG_INTEGER GL_HILO_NV
    - * GL_SIGNED_HILO_NV (5)
    - *
    - * GL_YCBCR_422_APPLE
    - *
    - * GL_RGB GL_RGB_INTEGER
    - * GL_BGR GL_BGR_INTEGER (4)
    - *
    - * GL_RGBA GL_RGBA_INTEGER
    + * GL_RG_INTEGER GL_HILO_NV
    + * GL_SIGNED_HILO_NV (5)
    + *
    + * GL_YCBCR_422_APPLE
    + *
    + * GL_RGB GL_RGB_INTEGER
    + * GL_BGR GL_BGR_INTEGER (4)
    + *
    + * GL_RGBA GL_RGBA_INTEGER
    * GL_BGRA GL_BGRA_INTEGER
    - * GL_ABGR_EXT (5)
    - * - * @param type must be one of (32)
    - * GL_BITMAP,
    + * GL_ABGR_EXT (5)
    + * + * @param type must be one of (32)
    + * GL_BITMAP,
    * GL_BYTE, GL_UNSIGNED_BYTE,
    * GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
    *
    * GL_SHORT, GL_UNSIGNED_SHORT,
    - * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
    + * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
    * GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
    * GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
    * GL_UNSIGNED_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
    @@ -495,70 +495,70 @@ public class GLBuffers extends Buffers { *
    * GL_FIXED, GL_INT
    * GL_UNSIGNED_INT, GL_UNSIGNED_INT_8_8_8_8,
    - * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
    + * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
    * GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_24_8,
    - * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
    + * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
    * GL_HILO16_NV, GL_SIGNED_HILO16_NV
    *
    * GL_FLOAT_32_UNSIGNED_INT_24_8_REV
    *
    - * GL_FLOAT, GL_DOUBLE
    - * + * GL_FLOAT, GL_DOUBLE
    + * * @param width in pixels * @param height in pixels * @param depth in pixels - * @param pack true for read mode GPU -> CPU, otherwise false for write mode CPU -> GPU + * @param pack true for read mode GPU -> CPU, otherwise false for write mode CPU -> GPU * @return required minimum size of the buffer in bytes * @throws GLException if format, type or alignment is not handled. Please contact the maintainer if this is our bug. */ - public static final int sizeof(GL gl, int tmp[], + public static final int sizeof(GL gl, int tmp[], int format, int type, int width, int height, int depth, boolean pack) throws GLException { if (width < 0) return 0; if (height < 0) return 0; if (depth < 0) return 0; - + final int bytesPerPixel = bytesPerPixel(format, type); return sizeof(gl, tmp, bytesPerPixel, width, height, depth, pack); } - - /** + + /** * Returns the number of bytes required for one pixel with the the given OpenGL format and type. - * + * *

    This method is security critical, hence it throws an exception (fail-fast) - * in case either the format, type or alignment is unhandled. In case we forgot to handle - * proper values, please contact the maintainer.

    - * + * in case either the format, type or alignment is unhandled. In case we forgot to handle + * proper values, please contact the maintainer.

    + * *

    See {@link #componentCount(int)}.

    - * - * @param format must be one of (27)
    - * GL_COLOR_INDEX GL_STENCIL_INDEX
    - * GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
    - * GL_RED GL_RED_INTEGER
    - * GL_GREEN GL_GREEN_INTEGER
    - * GL_BLUE GL_BLUE_INTEGER
    - * GL_ALPHA GL_LUMINANCE (12)
    - *
    + * + * @param format must be one of (27)
    + * GL_COLOR_INDEX GL_STENCIL_INDEX
    + * GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
    + * GL_RED GL_RED_INTEGER
    + * GL_GREEN GL_GREEN_INTEGER
    + * GL_BLUE GL_BLUE_INTEGER
    + * GL_ALPHA GL_LUMINANCE (12)
    + *
    * GL_LUMINANCE_ALPHA GL_RG
    - * GL_RG_INTEGER GL_HILO_NV
    - * GL_SIGNED_HILO_NV (5)
    - *
    - * GL_YCBCR_422_APPLE
    - *
    - * GL_RGB GL_RGB_INTEGER
    - * GL_BGR GL_BGR_INTEGER (4)
    - *
    - * GL_RGBA GL_RGBA_INTEGER
    + * GL_RG_INTEGER GL_HILO_NV
    + * GL_SIGNED_HILO_NV (5)
    + *
    + * GL_YCBCR_422_APPLE
    + *
    + * GL_RGB GL_RGB_INTEGER
    + * GL_BGR GL_BGR_INTEGER (4)
    + *
    + * GL_RGBA GL_RGBA_INTEGER
    * GL_BGRA GL_BGRA_INTEGER
    - * GL_ABGR_EXT (5)
    - * - * @param type must be one of (32)
    - * GL_BITMAP,
    + * GL_ABGR_EXT (5)
    + * + * @param type must be one of (32)
    + * GL_BITMAP,
    * GL_BYTE, GL_UNSIGNED_BYTE,
    * GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
    *
    * GL_SHORT, GL_UNSIGNED_SHORT,
    - * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
    + * GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV,
    * GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV,
    * GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
    * GL_UNSIGNED_SHORT_8_8_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE,
    @@ -566,15 +566,15 @@ public class GLBuffers extends Buffers { *
    * GL_FIXED, GL_INT
    * GL_UNSIGNED_INT, GL_UNSIGNED_INT_8_8_8_8,
    - * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
    + * GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
    * GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_24_8,
    - * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
    + * GL_UNSIGNED_INT_10F_11F_11F_REV, GL_UNSIGNED_INT_5_9_9_9_REV
    * GL_HILO16_NV, GL_SIGNED_HILO16_NV
    *
    * GL_FLOAT_32_UNSIGNED_INT_24_8_REV
    *
    - * GL_FLOAT, GL_DOUBLE
    - * + * GL_FLOAT, GL_DOUBLE
    + * * @return required size of one pixel in bytes * @throws GLException if format or type alignment is not handled. Please contact the maintainer if this is our bug. */ @@ -582,14 +582,14 @@ public class GLBuffers extends Buffers { int compSize = 0; int compCount = componentCount(format); - + switch (type) /* 30 */ { case GL2.GL_BITMAP: if (GL2.GL_COLOR_INDEX == format || GL2GL3.GL_STENCIL_INDEX == format) { compSize = 1; } case GL.GL_BYTE: - case GL.GL_UNSIGNED_BYTE: + case GL.GL_UNSIGNED_BYTE: compSize = 1; break; case GL.GL_SHORT: @@ -607,7 +607,7 @@ public class GLBuffers extends Buffers { case GL2GL3.GL_DOUBLE: compSize = 8; break; - + case GL2GL3.GL_UNSIGNED_BYTE_3_3_2: case GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV: compSize = 1; @@ -630,7 +630,7 @@ public class GLBuffers extends Buffers { case GL2.GL_SIGNED_HILO16_NV: compSize = 2; compCount = 2; - break; + break; case GL2GL3.GL_UNSIGNED_INT_8_8_8_8: case GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV: case GL2GL3.GL_UNSIGNED_INT_10_10_10_2: @@ -640,52 +640,52 @@ public class GLBuffers extends Buffers { case GL2GL3.GL_UNSIGNED_INT_5_9_9_9_REV: compSize = 4; compCount = 1; - break; + break; case GL2GL3.GL_FLOAT_32_UNSIGNED_INT_24_8_REV: compSize = 8; compCount = 1; - break; - + break; + default: throw new GLException("type 0x"+Integer.toHexString(type)+"/"+"format 0x"+Integer.toHexString(format)+" not supported [yet], pls notify the maintainer in case this is our bug."); - } + } return compCount * compSize; } - - /** + + /** * Returns the number of components required for the given OpenGL format. - * + * *

    This method is security critical, hence it throws an exception (fail-fast) - * in case either the format, type or alignment is unhandled. In case we forgot to handle - * proper values, please contact the maintainer.

    - * - * @param format must be one of (27)
    - * GL_COLOR_INDEX GL_STENCIL_INDEX
    - * GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
    - * GL_RED GL_RED_INTEGER
    - * GL_GREEN GL_GREEN_INTEGER
    - * GL_BLUE GL_BLUE_INTEGER
    - * GL_ALPHA GL_LUMINANCE (12)
    - *
    + * in case either the format, type or alignment is unhandled. In case we forgot to handle + * proper values, please contact the maintainer.

    + * + * @param format must be one of (27)
    + * GL_COLOR_INDEX GL_STENCIL_INDEX
    + * GL_DEPTH_COMPONENT GL_DEPTH_STENCIL
    + * GL_RED GL_RED_INTEGER
    + * GL_GREEN GL_GREEN_INTEGER
    + * GL_BLUE GL_BLUE_INTEGER
    + * GL_ALPHA GL_LUMINANCE (12)
    + *
    * GL_LUMINANCE_ALPHA GL_RG
    - * GL_RG_INTEGER GL_HILO_NV
    - * GL_SIGNED_HILO_NV (5)
    - *
    - * GL_YCBCR_422_APPLE
    - *
    - * GL_RGB GL_RGB_INTEGER
    - * GL_BGR GL_BGR_INTEGER (4)
    - *
    - * GL_RGBA GL_RGBA_INTEGER
    + * GL_RG_INTEGER GL_HILO_NV
    + * GL_SIGNED_HILO_NV (5)
    + *
    + * GL_YCBCR_422_APPLE
    + *
    + * GL_RGB GL_RGB_INTEGER
    + * GL_BGR GL_BGR_INTEGER (4)
    + *
    + * GL_RGBA GL_RGBA_INTEGER
    * GL_BGRA GL_BGRA_INTEGER
    - * GL_ABGR_EXT (5)
    - * + * GL_ABGR_EXT (5)
    + * * @return number of components required for the given OpenGL format * @throws GLException if format is not handled. Please contact the maintainer if this is our bug. */ public static final int componentCount(int format) throws GLException { final int compCount; - + switch (format) /* 26 */ { case GL2.GL_COLOR_INDEX: case GL2GL3.GL_STENCIL_INDEX: @@ -711,10 +711,10 @@ public class GLBuffers extends Buffers { case GL.GL_RGB: case GL2GL3.GL_RGB_INTEGER: case GL2GL3.GL_BGR: - case GL2GL3.GL_BGR_INTEGER: + case GL2GL3.GL_BGR_INTEGER: compCount = 3; break; - case GL2.GL_YCBCR_422_APPLE: + case GL2.GL_YCBCR_422_APPLE: compCount = 3; break; case GL.GL_RGBA: @@ -724,16 +724,16 @@ public class GLBuffers extends Buffers { case GL2.GL_ABGR_EXT: compCount = 4; break; - /* FIXME ?? + /* FIXME ?? case GL.GL_HILO_NV: elements = 2; - break; */ + break; */ default: throw new GLException("format 0x"+Integer.toHexString(format)+" not supported [yet], pls notify the maintainer in case this is our bug."); } return compCount; } - + public static final int getNextPowerOf2(int number) { if (((number-1) & number) == 0) { //ex: 8 -> 0b1000; 8-1=7 -> 0b0111; 0b1000&0b0111 == 0 @@ -745,8 +745,8 @@ public class GLBuffers extends Buffers { power++; } return (1<src to dest. * If preserveInitState is true, it's initialized state is preserved @@ -86,7 +86,7 @@ public class GLDrawableUtil { dest.invoke(false, new GLEventListenerState.ReshapeGLEventListener(listener)); } // else .. !init state is default } - + /** * Moves all {@link GLEventListener} from {@link GLAutoDrawable} src to dest. * If preserveInitState is true, it's initialized state is preserved @@ -113,12 +113,12 @@ public class GLDrawableUtil { /** * Swaps the {@link GLContext} and all {@link GLEventListener} between {@link GLAutoDrawable} a and b, * while preserving it's initialized state, resets the GL-Viewport and issuing {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(..)}. - *

    - * The {@link GLAutoDrawable} to {@link GLAnimatorControl} association - * is also swapped. + *

    + * The {@link GLAutoDrawable} to {@link GLAnimatorControl} association + * is also swapped. *

    *

    - * If an {@link GLAnimatorControl} is being attached to {@link GLAutoDrawable} a or b + * If an {@link GLAnimatorControl} is being attached to {@link GLAutoDrawable} a or b * and the current thread is different than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation. *

    * @param a @@ -128,31 +128,31 @@ public class GLDrawableUtil { public static final void swapGLContextAndAllGLEventListener(GLAutoDrawable a, GLAutoDrawable b) { final GLEventListenerState gllsA = GLEventListenerState.moveFrom(a); final GLEventListenerState gllsB = GLEventListenerState.moveFrom(b); - + gllsA.moveTo(b); gllsB.moveTo(a); } - - /** - * Swaps the {@link GLContext} of given {@link GLAutoDrawable} - * and {@link GLAutoDrawable#disposeGLEventListener(GLEventListener, boolean) disposes} + + /** + * Swaps the {@link GLContext} of given {@link GLAutoDrawable} + * and {@link GLAutoDrawable#disposeGLEventListener(GLEventListener, boolean) disposes} * each {@link GLEventListener} w/o removing it. *

    * The GL-Viewport is reset and {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(..)} issued implicit. - *

    + *

    *

    - * If an {@link GLAnimatorControl} is being attached to GLAutoDrawable src or dest and the current thread is different + * If an {@link GLAnimatorControl} is being attached to GLAutoDrawable src or dest and the current thread is different * than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation. *

    * @param src * @param dest */ - public static final void swapGLContext(GLAutoDrawable src, GLAutoDrawable dest) { + public static final void swapGLContext(GLAutoDrawable src, GLAutoDrawable dest) { final GLAnimatorControl aAnim = src.getAnimator(); - final GLAnimatorControl bAnim = dest.getAnimator(); + final GLAnimatorControl bAnim = dest.getAnimator(); final boolean aIsPaused = isAnimatorAnimatingOnOtherThread(aAnim) && aAnim.pause(); final boolean bIsPaused = isAnimatorAnimatingOnOtherThread(bAnim) && bAnim.pause(); - + for(int i = src.getGLEventListenerCount() - 1; 0 <= i; i--) { src.disposeGLEventListener(src.getGLEventListener(i), false); } @@ -160,12 +160,12 @@ public class GLDrawableUtil { dest.disposeGLEventListener(dest.getGLEventListener(i), false); } dest.setContext( src.setContext( dest.getContext(), false ), false ); - + src.invoke(true, GLEventListenerState.setViewport); dest.invoke(true, GLEventListenerState.setViewport); - + if(aIsPaused) { aAnim.resume(); } if(bIsPaused) { bAnim.resume(); } } - + } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java index 71e284101..f0c6be44f 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -39,78 +39,78 @@ import javax.media.opengl.GLException; import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.util.texture.TextureData; -/** +/** * OpenGL pixel data buffer, allowing user to provide buffers via their {@link GLPixelBufferProvider} implementation. *

    * {@link GLPixelBufferProvider} produces a {@link GLPixelBuffer}. - *

    + *

    *

    * You may use {@link #defaultProviderNoRowStride}. *

    */ public class GLPixelBuffer { - - /** Allows user to interface with another toolkit to define {@link GLPixelAttributes} and memory buffer to produce {@link TextureData}. */ + + /** Allows user to interface with another toolkit to define {@link GLPixelAttributes} and memory buffer to produce {@link TextureData}. */ public static interface GLPixelBufferProvider { /** Allow {@link GL2ES3#GL_PACK_ROW_LENGTH}, or {@link GL2ES2#GL_UNPACK_ROW_LENGTH}. */ boolean getAllowRowStride(); - + /** Called first to determine {@link GLPixelAttributes}. */ GLPixelAttributes getAttributes(GL gl, int componentCount); - - /** + + /** * Allocates a new {@link GLPixelBuffer} object. *

    * Being called to gather the initial {@link GLPixelBuffer}, * or a new replacement {@link GLPixelBuffer} if {@link GLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. *

    *

    - * The minimum required {@link Buffer#remaining() remaining} byte size equals to minByteSize, if > 0, + * The minimum required {@link Buffer#remaining() remaining} byte size equals to minByteSize, if > 0, * otherwise utilize {@link GLBuffers#sizeof(GL, int[], int, int, int, int, int, boolean)} * to calculate it. *

    - * + * * @param gl the corresponding current GL context object * @param pixelAttributes the desired {@link GLPixelAttributes} * @param width in pixels * @param height in pixels * @param depth in pixels * @param pack true for read mode GPU -> CPU, otherwise false for write mode CPU -> GPU - * @param minByteSize if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore. + * @param minByteSize if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore. */ GLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize); } - /** Single {@link GLPixelBuffer} provider. */ + /** Single {@link GLPixelBuffer} provider. */ public static interface SingletonGLPixelBufferProvider extends GLPixelBufferProvider { - /** Return the last {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated} {@link GLPixelBuffer} w/ {@link GLPixelAttributes#componentCount}. */ + /** Return the last {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated} {@link GLPixelBuffer} w/ {@link GLPixelAttributes#componentCount}. */ GLPixelBuffer getSingleBuffer(GLPixelAttributes pixelAttributes); - /** + /** * Initializes the single {@link GLPixelBuffer} w/ a given size, if not yet {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated}. * @return the newly initialized single {@link GLPixelBuffer}, or null if already allocated. */ - GLPixelBuffer initSingleton(int componentCount, int width, int height, int depth, boolean pack); + GLPixelBuffer initSingleton(int componentCount, int width, int height, int depth, boolean pack); } public static class DefaultGLPixelBufferProvider implements GLPixelBufferProvider { private final boolean allowRowStride; - + /** - * @param allowRowStride If true, allow row-stride, otherwise not. + * @param allowRowStride If true, allow row-stride, otherwise not. * See {@link #getAllowRowStride()} and {@link GLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. */ public DefaultGLPixelBufferProvider(boolean allowRowStride) { - this.allowRowStride = allowRowStride; + this.allowRowStride = allowRowStride; } - + @Override public boolean getAllowRowStride() { return allowRowStride; } - + @Override public GLPixelAttributes getAttributes(GL gl, int componentCount) { final GLContext ctx = gl.getContext(); final int dFormat, dType; - + if( 1 == componentCount ) { if( gl.isGL3ES3() ) { // RED is supported on ES3 and >= GL3 [core]; ALPHA is deprecated on core @@ -122,7 +122,7 @@ public class GLPixelBuffer { dType = GL.GL_UNSIGNED_BYTE; } else if( 3 == componentCount ) { dFormat = GL.GL_RGB; - dType = GL.GL_UNSIGNED_BYTE; + dType = GL.GL_UNSIGNED_BYTE; } else if( 4 == componentCount ) { int _dFormat = ctx.getDefaultPixelDataFormat(); final int dComps = GLBuffers.componentCount(_dFormat); @@ -131,14 +131,14 @@ public class GLPixelBuffer { dType = ctx.getDefaultPixelDataType(); } else { dFormat = GL.GL_RGBA; - dType = GL.GL_UNSIGNED_BYTE; + dType = GL.GL_UNSIGNED_BYTE; } } else { throw new GLException("Unsupported componentCount "+componentCount+", contact maintainer to enhance"); } return new GLPixelAttributes(componentCount, dFormat, dType); } - + /** * {@inheritDoc} *

    @@ -148,7 +148,7 @@ public class GLPixelBuffer { @Override public GLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { if( minByteSize > 0 ) { - return new GLPixelBuffer(pixelAttributes, width, height, depth, pack, Buffers.newDirectByteBuffer(minByteSize), getAllowRowStride()); + return new GLPixelBuffer(pixelAttributes, width, height, depth, pack, Buffers.newDirectByteBuffer(minByteSize), getAllowRowStride()); } else { int[] tmp = { 0 }; final int byteSize = GLBuffers.sizeof(gl, tmp, pixelAttributes.bytesPerPixel, width, height, depth, pack); @@ -156,26 +156,26 @@ public class GLPixelBuffer { } } } - - /** + + /** * Default {@link GLPixelBufferProvider} with {@link GLPixelBufferProvider#getAllowRowStride()} == false, * utilizing best match for {@link GLPixelAttributes} * and {@link GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocating} a {@link ByteBuffer}. */ public static GLPixelBufferProvider defaultProviderNoRowStride = new DefaultGLPixelBufferProvider(false); - - /** + + /** * Default {@link GLPixelBufferProvider} with {@link GLPixelBufferProvider#getAllowRowStride()} == true, * utilizing best match for {@link GLPixelAttributes} * and {@link GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocating} a {@link ByteBuffer}. */ public static GLPixelBufferProvider defaultProviderWithRowStride = new DefaultGLPixelBufferProvider(true); - - /** Pixel attributes. */ + + /** Pixel attributes. */ public static class GLPixelAttributes { - /** Undefined instance of {@link GLPixelAttributes}, having componentCount:=0, format:=0 and type:= 0. */ + /** Undefined instance of {@link GLPixelAttributes}, having componentCount:=0, format:=0 and type:= 0. */ public static final GLPixelAttributes UNDEF = new GLPixelAttributes(0, 0, 0, false); - + /** Pixel source component count, i.e. number of meaningful components. */ public final int componentCount; /** The OpenGL pixel data format */ @@ -184,7 +184,7 @@ public class GLPixelBuffer { public final int type; /** The OpenGL pixel size in bytes */ public final int bytesPerPixel; - + /** * Deriving {@link #componentCount} via GL dataFormat, i.e. {@link GLBuffers#componentCount(int)} if > 0. * @param dataFormat GL data format @@ -194,7 +194,7 @@ public class GLPixelBuffer { this(0 < dataFormat ? GLBuffers.componentCount(dataFormat) : 0, dataFormat, dataType); } /** - * Using user specified source {@link #componentCount}. + * Using user specified source {@link #componentCount}. * @param componentCount source component count * @param dataFormat GL data format * @param dataType GL data type @@ -220,7 +220,7 @@ public class GLPixelBuffer { return "PixelAttributes[comp "+componentCount+", fmt 0x"+Integer.toHexString(format)+", type 0x"+Integer.toHexString(type)+", bytesPerPixel "+bytesPerPixel+"]"; } } - + /** The {@link GLPixelAttributes}. */ public final GLPixelAttributes pixelAttributes; /** Width in pixels. */ @@ -233,22 +233,22 @@ public class GLPixelBuffer { public final boolean pack; /** Byte size of the buffer. Actually the number of {@link Buffer#remaining()} bytes when passed in ctor. */ public final int byteSize; - /** - * Buffer holding the pixel data. If {@link #rewind()}, it holds byteSize {@link Buffer#remaining()} bytes. + /** + * Buffer holding the pixel data. If {@link #rewind()}, it holds byteSize {@link Buffer#remaining()} bytes. *

    * By default the {@link Buffer} is a {@link ByteBuffer}, due to {@link DefProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int)}. * However, other {@link GLPixelBufferProvider} may utilize different {@link Buffer} types. *

    - */ + */ public final Buffer buffer; /** Buffer element size in bytes. */ public final int bufferElemSize; - + /** Allow {@link GL2ES3#GL_PACK_ROW_LENGTH}, or {@link GL2ES2#GL_UNPACK_ROW_LENGTH}. See {@link #requiresNewBuffer(GL, int, int, int)}. */ public final boolean allowRowStride; - + private boolean disposed = false; - + public StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); @@ -272,7 +272,7 @@ public class GLPixelBuffer { * @param allowRowStride If true, allow row-stride, otherwise not. See {@link #requiresNewBuffer(GL, int, int, int)}. */ public GLPixelBuffer(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, Buffer buffer, boolean allowRowStride) { - this.pixelAttributes = pixelAttributes; + this.pixelAttributes = pixelAttributes; this.width = width; this.height = height; this.depth = depth; @@ -282,15 +282,15 @@ public class GLPixelBuffer { this.bufferElemSize = Buffers.sizeOfBufferElem(buffer); this.allowRowStride = allowRowStride; } - + /** Allow {@link GL2ES3#GL_PACK_ROW_LENGTH}, or {@link GL2ES2#GL_UNPACK_ROW_LENGTH}. */ public final boolean getAllowRowStride() { return allowRowStride; } - + /** Is not {@link #dispose() disposed} and has {@link #byteSize} > 0. */ public boolean isValid() { return !disposed && 0 < byteSize; } - + /** See {@link Buffer#rewind()}. */ public Buffer rewind() { return buffer.rewind(); @@ -300,40 +300,40 @@ public class GLPixelBuffer { public int position() { return buffer.position() * bufferElemSize; } - + /** Sets the byte position of the {@link #buffer}. */ public Buffer position(int bytePos) { return buffer.position( bytePos / bufferElemSize ); } - + /** Returns the byte capacity of the {@link #buffer}. */ public int capacity() { return buffer.capacity() * bufferElemSize; } - + /** Returns the byte limit of the {@link #buffer}. */ public int limit() { return buffer.limit() * bufferElemSize; } - + /** See {@link Buffer#flip()}. */ public Buffer flip() { - return buffer.flip(); + return buffer.flip(); } - + /** See {@link Buffer#clear()}. */ public Buffer clear() { - return buffer.clear(); + return buffer.clear(); } - - /** + + /** * Returns true, if {@link #isValid() invalid} or implementation requires a new buffer based on the new size * due to pixel alignment or byte size, otherwise false. *

    * It is assumed that pixelAttributes, depth and pack stays the same! *

    *

    - * The minimum required byte size equals to minByteSize, if > 0, + * The minimum required byte size equals to minByteSize, if > 0, * otherwise {@link GLBuffers#sizeof(GL, int[], int, int, int, int, int, boolean) GLBuffers.sizeof(..)} * is being used to calculate it. This value is referred to newByteSize. *

    @@ -341,16 +341,16 @@ public class GLPixelBuffer { * If {@link #allowRowStride} = false, * method returns true if the newByteSize > currentByteSize * or the newWidth != currentWidth. - *

    + *

    *

    * If {@link #allowRowStride} = true, see {@link GLPixelBufferProvider#getAllowRowStride()}, - * method returns true only if the newByteSize > currentByteSize. + * method returns true only if the newByteSize > currentByteSize. * Assuming user utilizes the row-stride when dealing w/ the data, i.e. {@link GL2ES3#GL_PACK_ROW_LENGTH}. *

    * @param gl the corresponding current GL context object * @param newWidth new width in pixels * @param newHeight new height in pixels - * @param newByteSize if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore. + * @param newByteSize if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore. * @see GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) */ public boolean requiresNewBuffer(GL gl, int newWidth, int newHeight, int newByteSize) { @@ -366,7 +366,7 @@ public class GLPixelBuffer { } return byteSize < newByteSize || width != newWidth; } - + /** Dispose resources. See {@link #isValid()}. */ public void dispose() { disposed = true; diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java index f512a3aae..1c6e97450 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelStorageModes.java @@ -46,35 +46,35 @@ public class GLPixelStorageModes { /** Create instance w/o {@link #save(GL)} */ public GLPixelStorageModes() {} - + /** Create instance w/ {@link #save(GL)} */ public GLPixelStorageModes(GL gl) { save(gl); } - + /** * Sets the {@link GL#GL_PACK_ALIGNMENT}. - *

    + *

    * Saves the pixel storage modes if not saved yet. *

    */ public final void setPackAlignment(GL gl, int packAlignment) { save(gl); - gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, packAlignment); + gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, packAlignment); } /** * Sets the {@link GL#GL_UNPACK_ALIGNMENT}. - *

    + *

    * Saves the pixel storage modes if not saved yet. *

    */ public final void setUnpackAlignment(GL gl, int unpackAlignment) { save(gl); - gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, unpackAlignment); + gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, unpackAlignment); } - + /** - * Sets the {@link GL#GL_PACK_ALIGNMENT} and {@link GL#GL_UNPACK_ALIGNMENT}. - *

    + * Sets the {@link GL#GL_PACK_ALIGNMENT} and {@link GL#GL_UNPACK_ALIGNMENT}. + *

    * Saves the pixel storage modes if not saved yet. *

    */ @@ -82,32 +82,32 @@ public class GLPixelStorageModes { setPackAlignment(gl, packAlignment); setUnpackAlignment(gl, unpackAlignment); } - + /** * Sets the {@link GL2ES3#GL_PACK_ROW_LENGTH}. - *

    + *

    * Saves the pixel storage modes if not saved yet. *

    */ public final void setPackRowLength(GL2ES3 gl, int packRowLength) { save(gl); - gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, packRowLength); + gl.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, packRowLength); } /** * Sets the {@link GL2ES2#GL_UNPACK_ROW_LENGTH}. - *

    + *

    * Saves the pixel storage modes if not saved yet. *

    */ public final void setUnpackRowLength(GL2ES2 gl, int unpackRowLength) { save(gl); - gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, unpackRowLength); + gl.glPixelStorei(GL2ES2.GL_UNPACK_ROW_LENGTH, unpackRowLength); } - + /** * Sets the {@link GL2ES3#GL_PACK_ROW_LENGTH} and {@link GL2ES2#GL_UNPACK_ROW_LENGTH}. - *

    + *

    * Saves the pixel storage modes if not saved yet. *

    */ @@ -115,7 +115,7 @@ public class GLPixelStorageModes { setPackRowLength(gl, packRowLength); setUnpackRowLength(gl, unpackRowLength); } - + /** * Save the pixel storage mode, if not saved yet. *

    @@ -126,8 +126,8 @@ public class GLPixelStorageModes { if(saved) { return; } - - if(gl.isGL2GL3()) { + + if(gl.isGL2GL3()) { if(gl.isGL2()) { gl.getGL2().glPushClientAttrib(GL2.GL_CLIENT_PIXEL_STORE_BIT); } else { @@ -154,7 +154,7 @@ public class GLPixelStorageModes { // embedded deals with pack/unpack alignment only gl.glGetIntegerv(GL2ES2.GL_PACK_ALIGNMENT, savedAlignment, 0); gl.glGetIntegerv(GL2ES2.GL_UNPACK_ALIGNMENT, savedAlignment, 1); - } + } saved = true; } @@ -166,8 +166,8 @@ public class GLPixelStorageModes { if(!saved) { throw new GLException("pixel storage modes not saved"); } - - if(gl.isGL2GL3()) { + + if(gl.isGL2GL3()) { if(gl.isGL2()) { gl.getGL2().glPopClientAttrib(); } else { @@ -186,9 +186,9 @@ public class GLPixelStorageModes { // embedded deals with pack/unpack alignment only gl.glPixelStorei(GL2ES2.GL_PACK_ALIGNMENT, savedAlignment[0]); gl.glPixelStorei(GL2ES2.GL_UNPACK_ALIGNMENT, savedAlignment[1]); - } + } saved = false; - } + } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java index 65d1b6906..b942c9ab2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.util; import java.io.File; @@ -51,45 +51,45 @@ import com.jogamp.opengl.util.texture.TextureIO; */ public class GLReadBufferUtil { protected final GLPixelBufferProvider pixelBufferProvider; - protected final int componentCount, alignment; + protected final int componentCount, alignment; protected final Texture readTexture; - protected final GLPixelStorageModes psm; - + protected final GLPixelStorageModes psm; + protected GLPixelBuffer readPixelBuffer = null; protected TextureData readTextureData = null; /** - * @param alpha true for RGBA readPixels, otherwise RGB readPixels. Disclaimer: Alpha maybe forced on ES platforms! + * @param alpha true for RGBA readPixels, otherwise RGB readPixels. Disclaimer: Alpha maybe forced on ES platforms! * @param write2Texture true if readPixel's TextureData shall be written to a 2d Texture */ public GLReadBufferUtil(boolean alpha, boolean write2Texture) { this(GLPixelBuffer.defaultProviderNoRowStride, alpha, write2Texture); } - + public GLReadBufferUtil(GLPixelBufferProvider pixelBufferProvider, boolean alpha, boolean write2Texture) { this.pixelBufferProvider = pixelBufferProvider; this.componentCount = alpha ? 4 : 3 ; - this.alignment = alpha ? 4 : 1 ; + this.alignment = alpha ? 4 : 1 ; this.readTexture = write2Texture ? new Texture(GL.GL_TEXTURE_2D) : null ; this.psm = new GLPixelStorageModes(); } - + /** Returns the {@link GLPixelBufferProvider} used by this instance. */ public GLPixelBufferProvider getPixelBufferProvider() { return pixelBufferProvider; } - + public boolean isValid() { return null!=readTextureData && null!=readPixelBuffer && readPixelBuffer.isValid(); } - + public boolean hasAlpha() { return 4 == componentCount ? true : false ; } - + public GLPixelStorageModes getGLPixelStorageModes() { return psm; } - + /** * Returns the {@link GLPixelBuffer}, created and filled by {@link #readPixels(GLAutoDrawable, boolean)}. */ public GLPixelBuffer getPixelBuffer() { return readPixelBuffer; } - + /** * rewind the raw pixel ByteBuffer */ @@ -99,7 +99,7 @@ public class GLReadBufferUtil { * @return the resulting TextureData, filled by {@link #readPixels(GLAutoDrawable, boolean)} */ public TextureData getTextureData() { return readTextureData; } - + /** * @return the Texture object filled by {@link #readPixels(GLAutoDrawable, boolean)}, * if this instance writes to a 2d Texture, otherwise null. @@ -121,27 +121,27 @@ public class GLReadBufferUtil { /** * Read the drawable's pixels to TextureData and Texture, if requested at construction. - * + * * @param gl the current GL context object. It's read drawable is being used as the pixel source. * @param mustFlipVertically indicates whether to flip the data vertically or not. * The context's drawable {@link GLDrawable#isGLOriented()} state * is taken into account. * Vertical flipping is propagated to TextureData * and handled in a efficient manner there (TextureCoordinates and TextureIO writer). - * + * * @see #GLReadBufferUtil(boolean, boolean) */ public boolean readPixels(GL gl, boolean mustFlipVertically) { return readPixels(gl, 0, 0, 0, 0, mustFlipVertically); } - + /** * Read the drawable's pixels to TextureData and Texture, if requested at construction. - * + * * @param gl the current GL context object. It's read drawable is being used as the pixel source. * @param inX readPixel x offset * @param inY readPixel y offset - * @param inWidth optional readPixel width value, used if [1 .. drawable.width], otherwise using drawable.width + * @param inWidth optional readPixel width value, used if [1 .. drawable.width], otherwise using drawable.width * @param inHeight optional readPixel height, used if [1 .. drawable.height], otherwise using drawable.height * @param mustFlipVertically indicates whether to flip the data vertically or not. * The context's drawable {@link GLDrawable#isGLOriented()} state @@ -174,17 +174,17 @@ public class GLReadBufferUtil { } else { height= inHeight; } - + final boolean flipVertically; if( drawable.isGLOriented() ) { flipVertically = mustFlipVertically; } else { flipVertically = !mustFlipVertically; } - + final int tmp[] = new int[1]; final int readPixelSize = GLBuffers.sizeof(gl, tmp, pixelAttribs.bytesPerPixel, width, height, 1, true); - + boolean newData = false; if( null == readPixelBuffer || readPixelBuffer.requiresNewBuffer(gl, width, height, readPixelSize) ) { readPixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, width, height, 1, true, readPixelSize); @@ -194,9 +194,9 @@ public class GLReadBufferUtil { gl.getGLProfile(), internalFormat, width, height, - 0, + 0, pixelAttribs, - false, false, + false, false, flipVertically, readPixelBuffer.buffer, null /* Flusher */); @@ -230,13 +230,13 @@ public class GLReadBufferUtil { " "+width+"x"+height+ ", "+pixelAttribs+ ", "+readPixelBuffer+", sz "+readPixelSize); - res = false; + res = false; } if(res && null != readTexture) { if(newData) { readTexture.updateImage(gl, readTextureData); } else { - readTexture.updateSubImage(gl, readTextureData, 0, + readTexture.updateSubImage(gl, readTextureData, 0, 0, 0, // src offset 0, 0, // dst offset width, height); @@ -248,7 +248,7 @@ public class GLReadBufferUtil { return res; } - public void dispose(GL gl) { + public void dispose(GL gl) { if(null != readTexture) { readTexture.destroy(gl); readTextureData = null; diff --git a/src/jogl/classes/com/jogamp/opengl/util/Gamma.java b/src/jogl/classes/com/jogamp/opengl/util/Gamma.java index c649d1c6a..966781906 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Gamma.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Gamma.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java index 111e2509e..697b7cca0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java @@ -34,28 +34,28 @@ import com.jogamp.opengl.util.glsl.ShaderState; * to be either rendered directly via {@link #glEnd(GL)} or to be added to an internal display list * via {@link #glEnd(GL, boolean) glEnd(gl, false)} for deferred rendering via {@link #draw(GL, boolean)}. *

    - *
    Buffer storage and it's creation via {@link #createFixed(int, int, int, int, int, int, int, int, int, int) createFixed(..)} - * and {@link #createGLSL(int, int, int, int, int, int, int, int, int, int, ShaderState) createGLSL(..)}
    + *
    Buffer storage and it's creation via {@link #createFixed(int, int, int, int, int, int, int, int, int, int) createFixed(..)} + * and {@link #createGLSL(int, int, int, int, int, int, int, int, int, int, ShaderState) createGLSL(..)}
    *

    - * If unsure whether colors, normals and textures will be used, + * If unsure whether colors, normals and textures will be used, * simply add them with an expected component count. * This implementation will only render buffers which are being filled.
    * The buffer growing implementation will only grow the exceeded buffers, unused buffers are not resized. *

    *

    - * Note: Optional types, i.e. color, must be either not used or used w/ the same element count as vertex, etc. + * Note: Optional types, i.e. color, must be either not used or used w/ the same element count as vertex, etc. * This is a semantic constraint, same as in the original OpenGL spec. *

    */ public class ImmModeSink { protected static final boolean DEBUG_BEGIN_END; - protected static final boolean DEBUG_DRAW; + protected static final boolean DEBUG_DRAW; protected static final boolean DEBUG_BUFFER; - + static { Debug.initSingleton(); DEBUG_BEGIN_END = Debug.isPropertyDefined("jogl.debug.ImmModeSink.BeginEnd", true); - DEBUG_DRAW = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Draw", true); + DEBUG_DRAW = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Draw", true); DEBUG_BUFFER = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Buffer", true); } @@ -68,7 +68,7 @@ public class ImmModeSink { *

    * See buffer storage details. *

    - * + * * @param initialElementCount initial buffer size, if subsequent mutable operations are about to exceed the buffer size, the buffer will grow about the initial size. * @param vComps mandatory vertex component count, should be 2, 3 or 4. * @param vDataType mandatory vertex data type, e.g. {@link GL#GL_FLOAT} @@ -78,17 +78,17 @@ public class ImmModeSink { * @param nDataType optional normal data type, e.g. {@link GL#GL_FLOAT} * @param tComps optional texture-coordinate component count, may be 0, 2 or 3 * @param tDataType optional texture-coordinate data type, e.g. {@link GL#GL_FLOAT} - * @param glBufferUsage VBO usage parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, + * @param glBufferUsage VBO usage parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, * set to 0 for no VBO usage */ - public static ImmModeSink createFixed(int initialElementCount, + public static ImmModeSink createFixed(int initialElementCount, int vComps, int vDataType, int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, + int nComps, int nDataType, + int tComps, int tDataType, int glBufferUsage) { - return new ImmModeSink(initialElementCount, - vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, + return new ImmModeSink(initialElementCount, + vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, false, glBufferUsage, null, 0); } @@ -97,7 +97,7 @@ public class ImmModeSink { *

    * See buffer storage details. *

    - * + * * @param initialElementCount initial buffer size, if subsequent mutable operations are about to exceed the buffer size, the buffer will grow about the initial size. * @param vComps mandatory vertex component count, should be 2, 3 or 4. * @param vDataType mandatory vertex data type, e.g. {@link GL#GL_FLOAT} @@ -107,21 +107,21 @@ public class ImmModeSink { * @param nDataType optional normal data type, e.g. {@link GL#GL_FLOAT} * @param tComps optional texture-coordinate component count, may be 0, 2 or 3 * @param tDataType optional texture-coordinate data type, e.g. {@link GL#GL_FLOAT} - * @param glBufferUsage VBO usage parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, + * @param glBufferUsage VBO usage parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, * set to 0 for no VBO usage * @param st ShaderState to locate the vertex attributes * @see #draw(GL, boolean) * @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean) * @see com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState() */ - public static ImmModeSink createGLSL(int initialElementCount, + public static ImmModeSink createGLSL(int initialElementCount, int vComps, int vDataType, int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, + int nComps, int nDataType, + int tComps, int tDataType, int glBufferUsage, ShaderState st) { - return new ImmModeSink(initialElementCount, - vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, + return new ImmModeSink(initialElementCount, + vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, true, glBufferUsage, st, 0); } @@ -130,7 +130,7 @@ public class ImmModeSink { *

    * See buffer storage details. *

    - * + * * @param initialElementCount initial buffer size, if subsequent mutable operations are about to exceed the buffer size, the buffer will grow about the initial size. * @param vComps mandatory vertex component count, should be 2, 3 or 4. * @param vDataType mandatory vertex data type, e.g. {@link GL#GL_FLOAT} @@ -140,24 +140,24 @@ public class ImmModeSink { * @param nDataType optional normal data type, e.g. {@link GL#GL_FLOAT} * @param tComps optional texture-coordinate component count, may be 0, 2 or 3 * @param tDataType optional texture-coordinate data type, e.g. {@link GL#GL_FLOAT} - * @param glBufferUsage VBO usage parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, + * @param glBufferUsage VBO usage parameter for {@link GL#glBufferData(int, long, Buffer, int)}, e.g. {@link GL#GL_STATIC_DRAW}, * set to 0 for no VBO usage * @param shaderProgram shader-program name to locate the vertex attributes * @see #draw(GL, boolean) * @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean) * @see com.jogamp.opengl.util.glsl.ShaderState#getCurrentShaderState() */ - public static ImmModeSink createGLSL(int initialElementCount, + public static ImmModeSink createGLSL(int initialElementCount, int vComps, int vDataType, int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, + int nComps, int nDataType, + int tComps, int tDataType, int glBufferUsage, int shaderProgram) { - return new ImmModeSink(initialElementCount, - vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, + return new ImmModeSink(initialElementCount, + vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, true, glBufferUsage, null, shaderProgram); } - + public void destroy(GL gl) { destroyList(gl); @@ -346,7 +346,7 @@ public class ImmModeSink { public final void glColor3ub(byte x, byte y, byte z) { vboSet.glColor3ub(x,y,z); } - + public final void glColor4b(byte x, byte y, byte z, byte a) { vboSet.glColor4b(x,y,z,a); } @@ -354,7 +354,7 @@ public class ImmModeSink { public final void glColor4ub(byte x, byte y, byte z, byte a) { vboSet.glColor4ub(x,y,z,a); } - + public final void glTexCoord2b(byte x, byte y) { vboSet.glTexCoord2b(x,y); } @@ -363,26 +363,26 @@ public class ImmModeSink { vboSet.glTexCoord3b(x,y,z); } - protected ImmModeSink(int initialElementCount, - int vComps, int vDataType, - int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, + protected ImmModeSink(int initialElementCount, + int vComps, int vDataType, + int cComps, int cDataType, + int nComps, int nDataType, + int tComps, int tDataType, boolean useGLSL, int glBufferUsage, ShaderState st, int shaderProgram) { - vboSet = new VBOSet(initialElementCount, - vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, + vboSet = new VBOSet(initialElementCount, + vComps, vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, useGLSL, glBufferUsage, st, shaderProgram); this.vboSetList = new ArrayList(); } - + public boolean getUseVBO() { return vboSet.getUseVBO(); } - + /** * Returns the additional element count if buffer resize is required. * @see #setResizeElementCount(int) */ public int getResizeElementCount() { return vboSet.getResizeElementCount(); } - + /** * Sets the additional element count if buffer resize is required, * defaults to initialElementCount of factory method. @@ -390,7 +390,7 @@ public class ImmModeSink { * @see #createGLSL(int, int, int, int, int, int, int, int, int, int, ShaderState) */ public void setResizeElementCount(int v) { vboSet.setResizeElementCount(v); } - + private void destroyList(GL gl) { for(int i=0; i vboSetList; protected static class VBOSet { - protected VBOSet (int initialElementCount, - int vComps, int vDataType, - int cComps, int cDataType, - int nComps, int nDataType, - int tComps, int tDataType, + protected VBOSet (int initialElementCount, + int vComps, int vDataType, + int cComps, int cDataType, + int nComps, int nDataType, + int tComps, int tDataType, boolean useGLSL, int glBufferUsage, ShaderState st, int shaderProgram) { // final .. this.glBufferUsage=glBufferUsage; @@ -415,7 +415,7 @@ public class ImmModeSink { this.useGLSL=useGLSL; this.shaderState = st; this.shaderProgram = shaderProgram; - + if(useGLSL && null == shaderState && 0 == shaderProgram) { throw new IllegalArgumentException("Using GLSL but neither a valid shader-program nor ShaderState has been passed!"); } @@ -436,9 +436,9 @@ public class ImmModeSink { this.tDataType=tDataType; this.tDataTypeSigned=GLBuffers.isSignedGLType(tDataType); this.tComps=tComps; - this.tCompsBytes=tComps * GLBuffers.sizeOfGLType(tDataType); + this.tCompsBytes=tComps * GLBuffers.sizeOfGLType(tDataType); this.vboName = 0; - + this.vCount=0; this.cCount=0; this.nCount=0; @@ -447,9 +447,9 @@ public class ImmModeSink { this.cElems=0; this.nElems=0; this.tElems=0; - + this.pageSize = Platform.getMachineDescription().pageSizeInBytes(); - + reallocateBuffer(initialElementCount); rewind(); @@ -465,30 +465,30 @@ public class ImmModeSink { protected int getResizeElementCount() { return resizeElementCount; } protected void setResizeElementCount(int v) { resizeElementCount=v; } - + protected boolean getUseVBO() { return useVBO; } - + protected final VBOSet regenerate(GL gl) { - return new VBOSet(initialElementCount, vComps, - vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, + return new VBOSet(initialElementCount, vComps, + vDataType, cComps, cDataType, nComps, nDataType, tComps, tDataType, useGLSL, glBufferUsage, shaderState, shaderProgram); } protected void checkSeal(boolean test) throws GLException { if(0==mode) { - throw new GLException("No mode set yet, call glBegin(mode) first:\n\t"+this); + throw new GLException("No mode set yet, call glBegin(mode) first:\n\t"+this); } if(sealed!=test) { if(test) { - throw new GLException("Not Sealed yet, call glEnd() first:\n\t"+this); + throw new GLException("Not Sealed yet, call glEnd() first:\n\t"+this); } else { - throw new GLException("Already Sealed, can't modify VBO after glEnd():\n\t"+this); + throw new GLException("Already Sealed, can't modify VBO after glEnd():\n\t"+this); } } } private boolean usingShaderProgram = false; - + protected void useShaderProgram(GL2ES2 gl, boolean force) { if( force || !usingShaderProgram ) { if(null != shaderState) { @@ -499,19 +499,19 @@ public class ImmModeSink { usingShaderProgram = true; } } - + protected void draw(GL gl, Buffer indices, boolean disableBufferAfterDraw, int i) { enableBuffer(gl, true); - + if(null != shaderState || 0 != shaderProgram) { useShaderProgram(gl.getGL2ES2(), false); } - + if(DEBUG_DRAW) { System.err.println("ImmModeSink.draw["+i+"].0 (disableBufferAfterDraw: "+disableBufferAfterDraw+"):\n\t"+this); } - + if (buffer!=null) { if(null==indices) { if ( GL_QUADS == mode && !gl.isGL2() ) { @@ -523,7 +523,7 @@ public class ImmModeSink { } } else { // FIXME: Impl. VBO usage .. or unroll. - if( !gl.getContext().isCPUDataSourcingAvail() ) { + if( !gl.getContext().isCPUDataSourcingAvail() ) { throw new GLException("CPU data sourcing n/a w/ "+gl.getContext()); } final int type; @@ -538,23 +538,23 @@ public class ImmModeSink { } final int idxLen = indices.remaining(); final int idx0 = indices.position(); - + if ( GL_QUADS == mode && !gl.isGL2() ) { if( GL.GL_UNSIGNED_BYTE == type ) { final ByteBuffer b = (ByteBuffer) indices; for (int j = 0; j < idxLen; j++) { gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x000000ff & b.get(idx0+j)), 4); - } + } } else if( GL.GL_UNSIGNED_SHORT == type ){ final ShortBuffer b = (ShortBuffer) indices; for (int j = 0; j < idxLen; j++) { gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x0000ffff & b.get(idx0+j)), 4); - } + } } else { final IntBuffer b = (IntBuffer) indices; for (int j = 0; j < idxLen; j++) { gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0xffffffff & b.get(idx0+j)), 4); - } + } } } else { ((GL2ES1)gl).glDrawElements(mode, idxLen, type, indices); @@ -566,7 +566,7 @@ public class ImmModeSink { if(disableBufferAfterDraw) { enableBuffer(gl, false); } - + if(DEBUG_DRAW) { System.err.println("ImmModeSink.draw["+i+"].X (disableBufferAfterDraw: "+disableBufferAfterDraw+")"); } @@ -592,7 +592,7 @@ public class ImmModeSink { public void glVertex2b(byte x, byte y) { checkSeal(false); growBuffer(VERTEX); - if(vComps>0) + if(vComps>0) Buffers.putNb(vertexArray, vDataTypeSigned, x, true); if(vComps>1) Buffers.putNb(vertexArray, vDataTypeSigned, y, true); @@ -614,7 +614,7 @@ public class ImmModeSink { growBuffer(VERTEX); if(vComps>0) Buffers.putNs(vertexArray, vDataTypeSigned, x, true); - if(vComps>1) + if(vComps>1) Buffers.putNs(vertexArray, vDataTypeSigned, y, true); countAndPadding(VERTEX, vComps-2); } @@ -623,16 +623,16 @@ public class ImmModeSink { growBuffer(VERTEX); if(vComps>0) Buffers.putNs(vertexArray, vDataTypeSigned, x, true); - if(vComps>1) + if(vComps>1) Buffers.putNs(vertexArray, vDataTypeSigned, y, true); - if(vComps>2) + if(vComps>2) Buffers.putNs(vertexArray, vDataTypeSigned, z, true); countAndPadding(VERTEX, vComps-3); } public void glVertex2f(float x, float y) { checkSeal(false); growBuffer(VERTEX); - if(vComps>0) + if(vComps>0) Buffers.putNf(vertexArray, vDataTypeSigned, x); if(vComps>1) Buffers.putNf(vertexArray, vDataTypeSigned, y); @@ -641,11 +641,11 @@ public class ImmModeSink { public void glVertex3f(float x, float y, float z) { checkSeal(false); growBuffer(VERTEX); - if(vComps>0) + if(vComps>0) Buffers.putNf(vertexArray, vDataTypeSigned, x); if(vComps>1) Buffers.putNf(vertexArray, vDataTypeSigned, y); - if(vComps>2) + if(vComps>2) Buffers.putNf(vertexArray, vDataTypeSigned, z); countAndPadding(VERTEX, vComps-3); } @@ -653,33 +653,33 @@ public class ImmModeSink { public void glNormal3b(byte x, byte y, byte z) { checkSeal(false); growBuffer(NORMAL); - if(nComps>0) + if(nComps>0) Buffers.putNb(normalArray, nDataTypeSigned, x, true); - if(nComps>1) + if(nComps>1) Buffers.putNb(normalArray, nDataTypeSigned, y, true); - if(nComps>2) + if(nComps>2) Buffers.putNb(normalArray, nDataTypeSigned, z, true); countAndPadding(NORMAL, nComps-3); } public void glNormal3s(short x, short y, short z) { checkSeal(false); growBuffer(NORMAL); - if(nComps>0) + if(nComps>0) Buffers.putNs(normalArray, nDataTypeSigned, x, true); - if(nComps>1) + if(nComps>1) Buffers.putNs(normalArray, nDataTypeSigned, y, true); - if(nComps>2) + if(nComps>2) Buffers.putNs(normalArray, nDataTypeSigned, z, true); countAndPadding(NORMAL, nComps-3); } public void glNormal3f(float x, float y, float z) { checkSeal(false); growBuffer(NORMAL); - if(nComps>0) + if(nComps>0) Buffers.putNf(normalArray, nDataTypeSigned, x); if(nComps>1) Buffers.putNf(normalArray, nDataTypeSigned, y); - if(nComps>2) + if(nComps>2) Buffers.putNf(normalArray, nDataTypeSigned, z); countAndPadding(NORMAL, nComps-3); } @@ -687,96 +687,96 @@ public class ImmModeSink { public void glColor3b(byte r, byte g, byte b) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNb(colorArray, cDataTypeSigned, r, true); - if(cComps>1) + if(cComps>1) Buffers.putNb(colorArray, cDataTypeSigned, g, true); - if(cComps>2) + if(cComps>2) Buffers.putNb(colorArray, cDataTypeSigned, b, true); countAndPadding(COLOR, cComps-3); } public void glColor3ub(byte r, byte g, byte b) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNb(colorArray, cDataTypeSigned, r, false); - if(cComps>1) + if(cComps>1) Buffers.putNb(colorArray, cDataTypeSigned, g, false); - if(cComps>2) + if(cComps>2) Buffers.putNb(colorArray, cDataTypeSigned, b, false); countAndPadding(COLOR, cComps-3); } public void glColor4b(byte r, byte g, byte b, byte a) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNb(colorArray, cDataTypeSigned, r, true); - if(cComps>1) + if(cComps>1) Buffers.putNb(colorArray, cDataTypeSigned, g, true); - if(cComps>2) + if(cComps>2) Buffers.putNb(colorArray, cDataTypeSigned, b, true); - if(cComps>3) + if(cComps>3) Buffers.putNb(colorArray, cDataTypeSigned, a, true); countAndPadding(COLOR, cComps-4); } public void glColor4ub(byte r, byte g, byte b, byte a) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNb(colorArray, cDataTypeSigned, r, false); - if(cComps>1) + if(cComps>1) Buffers.putNb(colorArray, cDataTypeSigned, g, false); - if(cComps>2) + if(cComps>2) Buffers.putNb(colorArray, cDataTypeSigned, b, false); - if(cComps>3) + if(cComps>3) Buffers.putNb(colorArray, cDataTypeSigned, a, false); countAndPadding(COLOR, cComps-4); } public void glColor3s(short r, short g, short b) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNs(colorArray, cDataTypeSigned, r, true); - if(cComps>1) + if(cComps>1) Buffers.putNs(colorArray, cDataTypeSigned, g, true); - if(cComps>2) + if(cComps>2) Buffers.putNs(colorArray, cDataTypeSigned, b, true); countAndPadding(COLOR, cComps-3); } public void glColor4s(short r, short g, short b, short a) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNs(colorArray, cDataTypeSigned, r, true); - if(cComps>1) + if(cComps>1) Buffers.putNs(colorArray, cDataTypeSigned, g, true); - if(cComps>2) + if(cComps>2) Buffers.putNs(colorArray, cDataTypeSigned, b, true); - if(cComps>3) + if(cComps>3) Buffers.putNs(colorArray, cDataTypeSigned, a, true); countAndPadding(COLOR, cComps-4); } public void glColor3f(float r, float g, float b) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNf(colorArray, cDataTypeSigned, r); - if(cComps>1) + if(cComps>1) Buffers.putNf(colorArray, cDataTypeSigned, g); - if(cComps>2) + if(cComps>2) Buffers.putNf(colorArray, cDataTypeSigned, b); countAndPadding(COLOR, cComps-3); } public void glColor4f(float r, float g, float b, float a) { checkSeal(false); growBuffer(COLOR); - if(cComps>0) + if(cComps>0) Buffers.putNf(colorArray, cDataTypeSigned, r); - if(cComps>1) + if(cComps>1) Buffers.putNf(colorArray, cDataTypeSigned, g); - if(cComps>2) + if(cComps>2) Buffers.putNf(colorArray, cDataTypeSigned, b); - if(cComps>3) + if(cComps>3) Buffers.putNf(colorArray, cDataTypeSigned, a); countAndPadding(COLOR, cComps-4); } @@ -784,60 +784,60 @@ public class ImmModeSink { public void glTexCoord2b(byte x, byte y) { checkSeal(false); growBuffer(TEXTCOORD); - if(tComps>0) + if(tComps>0) Buffers.putNb(textCoordArray, tDataTypeSigned, x, true); - if(tComps>1) + if(tComps>1) Buffers.putNb(textCoordArray, tDataTypeSigned, y, true); countAndPadding(TEXTCOORD, tComps-2); } public void glTexCoord3b(byte x, byte y, byte z) { checkSeal(false); growBuffer(TEXTCOORD); - if(tComps>0) + if(tComps>0) Buffers.putNb(textCoordArray, tDataTypeSigned, x, true); - if(tComps>1) + if(tComps>1) Buffers.putNb(textCoordArray, tDataTypeSigned, y, true); - if(tComps>2) + if(tComps>2) Buffers.putNb(textCoordArray, tDataTypeSigned, z, true); countAndPadding(TEXTCOORD, tComps-3); } public void glTexCoord2s(short x, short y) { checkSeal(false); growBuffer(TEXTCOORD); - if(tComps>0) + if(tComps>0) Buffers.putNs(textCoordArray, tDataTypeSigned, x, true); - if(tComps>1) + if(tComps>1) Buffers.putNs(textCoordArray, tDataTypeSigned, y, true); countAndPadding(TEXTCOORD, tComps-2); } public void glTexCoord3s(short x, short y, short z) { checkSeal(false); growBuffer(TEXTCOORD); - if(tComps>0) + if(tComps>0) Buffers.putNs(textCoordArray, tDataTypeSigned, x, true); - if(tComps>1) + if(tComps>1) Buffers.putNs(textCoordArray, tDataTypeSigned, y, true); - if(tComps>2) + if(tComps>2) Buffers.putNs(textCoordArray, tDataTypeSigned, z, true); countAndPadding(TEXTCOORD, tComps-3); } public void glTexCoord2f(float x, float y) { checkSeal(false); growBuffer(TEXTCOORD); - if(tComps>0) + if(tComps>0) Buffers.putNf(textCoordArray, tDataTypeSigned, x); - if(tComps>1) + if(tComps>1) Buffers.putNf(textCoordArray, tDataTypeSigned, y); countAndPadding(TEXTCOORD, tComps-2); } public void glTexCoord3f(float x, float y, float z) { checkSeal(false); growBuffer(TEXTCOORD); - if(tComps>0) + if(tComps>0) Buffers.putNf(textCoordArray, tDataTypeSigned, x); - if(tComps>1) + if(tComps>1) Buffers.putNf(textCoordArray, tDataTypeSigned, y); - if(tComps>2) + if(tComps>2) Buffers.putNf(textCoordArray, tDataTypeSigned, z); countAndPadding(TEXTCOORD, tComps-3); } @@ -864,20 +864,20 @@ public class ImmModeSink { shaderProgram = program; glslLocationSet = false; // enforce location reset! } - + /** * @param gl * @return true if all locations for all used arrays are found (min 1 array), otherwise false. - * Also sets 'glslLocationSet' to the return value! + * Also sets 'glslLocationSet' to the return value! */ private boolean resetGLSLArrayLocation(GL2ES2 gl) { int iA = 0; int iL = 0; - + if(null != vArrayData) { iA++; if( vArrayData.setLocation(gl, shaderProgram) >= 0 ) { - iL++; + iL++; } } if(null != cArrayData) { @@ -901,7 +901,7 @@ public class ImmModeSink { glslLocationSet = iA == iL; return glslLocationSet; } - + public void destroy(GL gl) { reset(gl); @@ -931,7 +931,7 @@ public class ImmModeSink { this.vElems=0; this.cElems=0; this.nElems=0; - this.tElems=0; + this.tElems=0; } public void seal(GL glObj, boolean seal) @@ -1016,20 +1016,20 @@ public class ImmModeSink { } } else { gl.glBufferData(GL.GL_ARRAY_BUFFER, buffer.limit(), buffer, glBufferUsage); - bufferWrittenOnce = true; - } + bufferWrittenOnce = true; + } } - + private void enableBufferFixed(GL gl, boolean enable) { GL2ES1 glf = gl.getGL2ES1(); - + final boolean useV = vComps>0 && vElems>0 ; final boolean useC = cComps>0 && cElems>0 ; final boolean useN = nComps>0 && nElems>0 ; final boolean useT = tComps>0 && tElems>0 ; - + if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableFixed.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); + System.err.println("ImmModeSink.enableFixed.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); } if(enable) { @@ -1038,7 +1038,7 @@ public class ImmModeSink { throw new InternalError("Using VBO but no vboName"); } glf.glBindBuffer(GL.GL_ARRAY_BUFFER, vboName); - + if(!bufferWritten) { writeBuffer(gl); } @@ -1051,7 +1051,7 @@ public class ImmModeSink { glf.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY); glf.glVertexPointer(vArrayData); } else { - glf.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY); + glf.glDisableClientState(GLPointerFunc.GL_VERTEX_ARRAY); } } if(useC) { @@ -1082,24 +1082,24 @@ public class ImmModeSink { if(enable && useVBO) { gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); } - + if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableFixed.X "); + System.err.println("ImmModeSink.enableFixed.X "); } } private void enableBufferGLSLShaderState(GL gl, boolean enable) { GL2ES2 glsl = gl.getGL2ES2(); - + final boolean useV = vComps>0 && vElems>0 ; final boolean useC = cComps>0 && cElems>0 ; final boolean useN = nComps>0 && nElems>0 ; final boolean useT = tComps>0 && tElems>0 ; - + if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableGLSL.A.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); + System.err.println("ImmModeSink.enableGLSL.A.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); } - + if(enable) { if(useVBO) { if(0 == vboName) { @@ -1110,9 +1110,9 @@ public class ImmModeSink { writeBuffer(gl); } } - bufferWritten=true; + bufferWritten=true; } - + if(useV) { if(enable) { shaderState.enableVertexAttribArray(glsl, vArrayData); @@ -1144,30 +1144,30 @@ public class ImmModeSink { } else { shaderState.disableVertexAttribArray(glsl, tArrayData); } - } + } glslLocationSet = true; // ShaderState does set the location implicit - + if(enable && useVBO) { glsl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); } - + if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableGLSL.A.X "); + System.err.println("ImmModeSink.enableGLSL.A.X "); } } private void enableBufferGLSLSimple(GL gl, boolean enable) { GL2ES2 glsl = gl.getGL2ES2(); - + final boolean useV = vComps>0 && vElems>0 ; final boolean useC = cComps>0 && cElems>0 ; final boolean useN = nComps>0 && nElems>0 ; final boolean useT = tComps>0 && tElems>0 ; - + if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableGLSL.B.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); + System.err.println("ImmModeSink.enableGLSL.B.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); } - + if(!glslLocationSet) { if( !resetGLSLArrayLocation(glsl) ) { if(DEBUG_DRAW) { @@ -1180,7 +1180,7 @@ public class ImmModeSink { return; } } - + if(enable) { if(useVBO) { if(0 == vboName) { @@ -1226,28 +1226,28 @@ public class ImmModeSink { glsl.glDisableVertexAttribArray(tArrayData.getLocation()); } } - + if(enable && useVBO) { glsl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); } - + if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableGLSL.B.X "); + System.err.println("ImmModeSink.enableGLSL.B.X "); } } - + public String toString() { - final String glslS = useGLSL ? + final String glslS = useGLSL ? ", useShaderState "+(null!=shaderState)+ ", shaderProgram "+shaderProgram+ ", glslLocationSet "+glslLocationSet : ""; - - return "VBOSet[mode "+mode+ - ", modeOrig "+modeOrig+ + + return "VBOSet[mode "+mode+ + ", modeOrig "+modeOrig+ ", use/count "+getElemUseCountStr()+ - ", sealed "+sealed+ + ", sealed "+sealed+ ", sealedGL "+sealedGL+ - ", bufferEnabled "+bufferEnabled+ + ", bufferEnabled "+bufferEnabled+ ", bufferWritten "+bufferWritten+" (once "+bufferWrittenOnce+")"+ ", useVBO "+useVBO+", vboName "+vboName+ ", useGLSL "+useGLSL+ @@ -1264,7 +1264,7 @@ public class ImmModeSink { protected String getElemUseCountStr() { return "[v "+vElems+"/"+vCount+", c "+cElems+"/"+cCount+", n "+nElems+"/"+nCount+", t "+tElems+"/"+tCount+"]"; } - + protected boolean fitElementInBuffer(int type) { final int addElems = 1; switch (type) { @@ -1280,20 +1280,20 @@ public class ImmModeSink { throw new InternalError("XXX"); } } - + protected boolean reallocateBuffer(int addElems) { final int vAdd = addElems - ( vCount - vElems ); final int cAdd = addElems - ( cCount - cElems ); final int nAdd = addElems - ( nCount - nElems ); final int tAdd = addElems - ( tCount - tElems ); - + if( 0>=vAdd && 0>=cAdd && 0>=nAdd && 0>=tAdd) { if(DEBUG_BUFFER) { System.err.println("ImmModeSink.realloc: "+getElemUseCountStr()+" + "+addElems+" -> NOP"); } return false; } - + if(DEBUG_BUFFER) { System.err.println("ImmModeSink.realloc: "+getElemUseCountStr()+" + "+addElems); } @@ -1301,20 +1301,20 @@ public class ImmModeSink { cCount += cAdd; nCount += nAdd; tCount += tAdd; - + final int vBytes = vCount * vCompsBytes; final int cBytes = cCount * cCompsBytes; final int nBytes = nCount * nCompsBytes; final int tBytes = tCount * tCompsBytes; - + buffer = Buffers.newDirectByteBuffer( vBytes + cBytes + nBytes + tBytes ); vOffset = 0; - + if(vBytes>0) { vertexArray = GLBuffers.sliceGLBuffer(buffer, vOffset, vBytes, vDataType); } else { vertexArray = null; - } + } cOffset=vOffset+vBytes; if(cBytes>0) { @@ -1341,36 +1341,36 @@ public class ImmModeSink { buffer.flip(); if(vComps>0) { - vArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, vComps, + vArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_VERTEX_ARRAY, vComps, vDataType, GLBuffers.isGLTypeFixedPoint(vDataType), 0, vertexArray, 0, vOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER); } else { vArrayData = null; } if(cComps>0) { - cArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_COLOR_ARRAY, cComps, + cArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_COLOR_ARRAY, cComps, cDataType, GLBuffers.isGLTypeFixedPoint(cDataType), 0, colorArray, 0, cOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER); } else { cArrayData = null; } if(nComps>0) { - nArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_NORMAL_ARRAY, nComps, + nArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_NORMAL_ARRAY, nComps, nDataType, GLBuffers.isGLTypeFixedPoint(nDataType), 0, normalArray, 0, nOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER); } else { nArrayData = null; } if(tComps>0) { - tArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_TEXTURE_COORD_ARRAY, tComps, + tArrayData = GLArrayDataWrapper.createFixed(GLPointerFunc.GL_TEXTURE_COORD_ARRAY, tComps, tDataType, GLBuffers.isGLTypeFixedPoint(tDataType), 0, textCoordArray, 0, tOffset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER); } else { tArrayData = null; } - + bufferWrittenOnce = false; // new buffer data storage size! - + if(DEBUG_BUFFER) { System.err.println("ImmModeSink.realloc.X: "+this.toString()); Thread.dumpStack(); @@ -1384,7 +1384,7 @@ public class ImmModeSink { if( !fitElementInBuffer(type) ) { // save olde values .. final Buffer _vertexArray=vertexArray, _colorArray=colorArray, _normalArray=normalArray, _textCoordArray=textCoordArray; - + if ( reallocateBuffer(resizeElementCount) ) { if(null!=_vertexArray) { _vertexArray.flip(); @@ -1416,7 +1416,7 @@ public class ImmModeSink { * vec4 v = vec4(0, 0, 0, 1); * vec4 c = vec4(0, 0, 0, 1); *

    - * + * * @param type * @param fill */ @@ -1426,7 +1426,7 @@ public class ImmModeSink { final Buffer dest; final boolean dSigned; final int e; // either 0 or 1 - + switch (type) { case VERTEX: dest = vertexArray; @@ -1459,7 +1459,7 @@ public class ImmModeSink { while( fill > e ) { fill--; - Buffers.putNf(dest, dSigned, 0f); + Buffers.putNf(dest, dSigned, 0f); } if( fill > 0 ) { // e == 1, add missing '1f end component' Buffers.putNf(dest, dSigned, 1f); @@ -1480,18 +1480,18 @@ public class ImmModeSink { private static final int NORMAL = 2; private static final int TEXTCOORD = 3; - private int vCount, cCount, nCount, tCount; // number of elements fit in each buffer + private int vCount, cCount, nCount, tCount; // number of elements fit in each buffer private int vOffset, cOffset, nOffset, tOffset; // offset of specific array in common buffer private int vElems, cElems, nElems, tElems; // number of used elements in each buffer - private final int vComps, cComps, nComps, tComps; // number of components for each elements [2, 3, 4] - private final int vCompsBytes, cCompsBytes, nCompsBytes, tCompsBytes; // byte size of all components + private final int vComps, cComps, nComps, tComps; // number of components for each elements [2, 3, 4] + private final int vCompsBytes, cCompsBytes, nCompsBytes, tCompsBytes; // byte size of all components private final int vDataType, cDataType, nDataType, tDataType; private final boolean vDataTypeSigned, cDataTypeSigned, nDataTypeSigned, tDataTypeSigned; private final int pageSize; private Buffer vertexArray, colorArray, normalArray, textCoordArray; private GLArrayDataWrapper vArrayData, cArrayData, nArrayData, tArrayData; - private boolean sealed, sealedGL; + private boolean sealed, sealedGL; private boolean bufferEnabled, bufferWritten, bufferWrittenOnce; private boolean glslLocationSet; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index 58151856f..b4a0156e9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2011 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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.opengl.util; @@ -55,22 +55,22 @@ import com.jogamp.opengl.math.geom.Frustum; * regarding the projection (P), modelview (Mv) matrix operation * which is specified in {@link GLMatrixFunc}. *

    - * Further more, PMVMatrix provides the {@link #glGetMviMatrixf() inverse modelview matrix (Mvi)} and + * Further more, PMVMatrix provides the {@link #glGetMviMatrixf() inverse modelview matrix (Mvi)} and * {@link #glGetMvitMatrixf() inverse transposed modelview matrix (Mvit)}. * {@link Frustum} is also provided by {@link #glGetFrustum()}. * To keep these derived values synchronized after mutable Mv operations like {@link #glRotatef(float, float, float, float) glRotatef(..)} - * in {@link #glMatrixMode(int) glMatrixMode}({@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}), - * users have to call {@link #update()} before using Mvi and Mvit. + * in {@link #glMatrixMode(int) glMatrixMode}({@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}), + * users have to call {@link #update()} before using Mvi and Mvit. *

    *

    - * All matrices are provided in column-major order, - * as specified in the OpenGL fixed function pipeline, i.e. compatibility profile. + * All matrices are provided in column-major order, + * as specified in the OpenGL fixed function pipeline, i.e. compatibility profile. *

    *

    - * PMVMatrix can supplement {@link GL2ES2} applications w/ the + * PMVMatrix can supplement {@link GL2ES2} applications w/ the * lack of the described matrix functionality. *

    - *
    Matrix storage details
    + *
    Matrix storage details
    *

    * All matrices use a common FloatBuffer storage * and are a {@link Buffers#slice2Float(Buffer, float[], int, int) sliced} representation of it. @@ -78,11 +78,11 @@ import com.jogamp.opengl.math.geom.Frustum; * depending how the instance if {@link #PMVMatrix(boolean) being constructed}. *

    *

    - * Note: - *

      + * Note: + *
        *
      • The matrix is a {@link Buffers#slice2Float(Buffer, float[], int, int) sliced part } of a host matrix and it's start position has been {@link FloatBuffer#mark() marked}.
      • *
      • Use {@link FloatBuffer#reset() reset()} to rewind it to it's start position after relative operations, like {@link FloatBuffer#get() get()}.
      • - *
      • If using absolute operations like {@link FloatBuffer#get(int) get(int)}, use it's {@link FloatBuffer#reset() reset} {@link FloatBuffer#position() position} as it's offset.
      • + *
      • If using absolute operations like {@link FloatBuffer#get(int) get(int)}, use it's {@link FloatBuffer#reset() reset} {@link FloatBuffer#position() position} as it's offset.
      • *
      *

      */ @@ -96,20 +96,20 @@ public class PMVMatrix implements GLMatrixFunc { public static final int MODIFIED_TEXTURE = 1 << 2; /** Bit value stating all is modified */ public static final int MODIFIED_ALL = MODIFIED_PROJECTION | MODIFIED_MODELVIEW | MODIFIED_TEXTURE ; - + /** Bit value stating a dirty {@link #glGetMviMatrixf() inverse modelview matrix (Mvi)}. */ public static final int DIRTY_INVERSE_MODELVIEW = 1 << 0; /** Bit value stating a dirty {@link #glGetMvitMatrixf() inverse transposed modelview matrix (Mvit)}. */ - public static final int DIRTY_INVERSE_TRANSPOSED_MODELVIEW = 1 << 1; + public static final int DIRTY_INVERSE_TRANSPOSED_MODELVIEW = 1 << 1; /** Bit value stating a dirty {@link #glGetFrustum() frustum}. */ - public static final int DIRTY_FRUSTUM = 1 << 2; + public static final int DIRTY_FRUSTUM = 1 << 2; /** Bit value stating all is dirty */ public static final int DIRTY_ALL = DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM; - + /** - * @param matrixModeName One of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} + * @param matrixModeName One of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} * @return true if the given matrix-mode name is valid, otherwise false. - */ + */ public static final boolean isMatrixModeName(final int matrixModeName) { switch(matrixModeName) { case GL_MODELVIEW_MATRIX: @@ -121,9 +121,9 @@ public class PMVMatrix implements GLMatrixFunc { } /** - * @param matrixModeName One of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} + * @param matrixModeName One of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} * @return The corresponding matrix-get name, one of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX} - */ + */ public static final int matrixModeName2MatrixGetName(final int matrixModeName) { switch(matrixModeName) { case GL_MODELVIEW: @@ -138,9 +138,9 @@ public class PMVMatrix implements GLMatrixFunc { } /** - * @param matrixGetName One of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX} + * @param matrixGetName One of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX} * @return true if the given matrix-get name is valid, otherwise false. - */ + */ public static final boolean isMatrixGetName(final int matrixGetName) { switch(matrixGetName) { case GL_MATRIX_MODE: @@ -155,7 +155,7 @@ public class PMVMatrix implements GLMatrixFunc { /** * @param matrixGetName One of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX} * @return The corresponding matrix-mode name, one of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} - */ + */ public static final int matrixGetName2MatrixModeName(final int matrixGetName) { switch(matrixGetName) { case GL_MODELVIEW_MATRIX: @@ -168,18 +168,18 @@ public class PMVMatrix implements GLMatrixFunc { throw new GLException("unsupported matrixGetName: "+matrixGetName); } } - - /** + + /** * @param sb optional passed StringBuilder instance to be used * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} * @param a 4x4 matrix in column major order (OpenGL) * @return matrix string representation */ public static StringBuilder matrixToString(StringBuilder sb, String f, FloatBuffer a) { - return FloatUtil.matrixToString(sb, null, f, a, 0, 4, 4, false); + return FloatUtil.matrixToString(sb, null, f, a, 0, 4, 4, false); } - - /** + + /** * @param sb optional passed StringBuilder instance to be used * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} * @param a 4x4 matrix in column major order (OpenGL) @@ -187,33 +187,33 @@ public class PMVMatrix implements GLMatrixFunc { * @return side by side representation */ public static StringBuilder matrixToString(StringBuilder sb, String f, FloatBuffer a, FloatBuffer b) { - return FloatUtil.matrixToString(sb, null, f, a, 0, b, 0, 4, 4, false); + return FloatUtil.matrixToString(sb, null, f, a, 0, b, 0, 4, 4, false); } - + /** * Creates an instance of PMVMatrix {@link #PMVMatrix(boolean) PMVMatrix(boolean useBackingArray)}, - * with useBackingArray = true. + * with useBackingArray = true. */ public PMVMatrix() { this(true); } - + /** * Creates an instance of PMVMatrix. - * + * * @param useBackingArray true for non direct NIO Buffers with guaranteed backing array, * which allows faster access in Java computation. *

      false for direct NIO buffers w/o a guaranteed backing array. * In most Java implementations, direct NIO buffers have no backing array - * and hence the Java computation will be throttled down by direct IO get/put - * operations.

      + * and hence the Java computation will be throttled down by direct IO get/put + * operations.

      *

      Depending on the application, ie. whether the Java computation or - * JNI invocation and hence native data transfer part is heavier, + * JNI invocation and hence native data transfer part is heavier, * this flag shall be set to true or false

      . */ public PMVMatrix(boolean useBackingArray) { this.usesBackingArray = useBackingArray; - + // I Identity // T Texture // P Projection @@ -228,24 +228,24 @@ public class PMVMatrix implements GLMatrixFunc { matrixBuffer = Buffers.newDirectByteBuffer( ( 6*16 + ProjectFloat.getRequiredFloatBufferSize() ) * Buffers.SIZEOF_FLOAT ); matrixBuffer.mark(); } - + matrixIdent = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 0*16, 1*16); // I matrixTex = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 1*16, 1*16); // T - matrixPMvMvit = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 4*16); // P + Mv + Mvi + Mvit + matrixPMvMvit = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 4*16); // P + Mv + Mvi + Mvit matrixPMvMvi = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 3*16); // P + Mv + Mvi matrixPMv = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 2*16); // P + Mv matrixP = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 2*16, 1*16); // P matrixMv = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 3*16, 1*16); // Mv matrixMvi = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 4*16, 1*16); // Mvi matrixMvit = Buffers.slice2Float(matrixBuffer, matrixBufferArray, 5*16, 1*16); // Mvit - + projectFloat = new ProjectFloat(matrixBuffer, matrixBufferArray, 6*16); - + if(null != matrixBuffer) { matrixBuffer.reset(); - } + } FloatUtil.makeIdentityf(matrixIdent); - + vec3f = new float[3]; matrixMult = new float[16]; matrixTrans = new float[16]; @@ -263,7 +263,7 @@ public class PMVMatrix implements GLMatrixFunc { matrixTStack = new FloatStack( 0, 2*16); // growSize: GL-min size (2) matrixPStack = new FloatStack( 0, 2*16); // growSize: GL-min size (2) matrixMvStack= new FloatStack( 0, 16*16); // growSize: half GL-min size (32) - + // default values and mode glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -275,22 +275,22 @@ public class PMVMatrix implements GLMatrixFunc { dirtyBits = DIRTY_ALL; requestMask = 0; matrixMode = GL_MODELVIEW; - + mulPMV = null; frustum = null; } /** @see #PMVMatrix(boolean) */ - public final boolean usesBackingArray() { return usesBackingArray; } - + public final boolean usesBackingArray() { return usesBackingArray; } + public final void destroy() { if(null!=projectFloat) { projectFloat.destroy(); projectFloat=null; } matrixBuffer=null; - matrixBuffer=null; matrixPMvMvit=null; matrixPMvMvi=null; matrixPMv=null; - matrixP=null; matrixTex=null; matrixMv=null; matrixMvi=null; matrixMvit=null; + matrixBuffer=null; matrixPMvMvit=null; matrixPMvMvi=null; matrixPMv=null; + matrixP=null; matrixTex=null; matrixMv=null; matrixMvi=null; matrixMvit=null; vec3f = null; matrixMult = null; @@ -299,7 +299,7 @@ public class PMVMatrix implements GLMatrixFunc { matrixScale = null; matrixOrtho = null; matrixFrustum = null; - + if(null!=matrixPStack) { matrixPStack=null; } @@ -314,13 +314,13 @@ public class PMVMatrix implements GLMatrixFunc { } } - + /** Returns the current matrix-mode, one of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE}. */ public final int glGetMatrixMode() { return matrixMode; } - /** + /** * Returns the {@link GLMatrixFunc#GL_TEXTURE_MATRIX texture matrix} (T). *

      * See matrix storage details. @@ -330,7 +330,7 @@ public class PMVMatrix implements GLMatrixFunc { return matrixTex; } - /** + /** * Returns the {@link GLMatrixFunc#GL_PROJECTION_MATRIX projection matrix} (P). *

      * See matrix storage details. @@ -340,7 +340,7 @@ public class PMVMatrix implements GLMatrixFunc { return matrixP; } - /** + /** * Returns the {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mv). *

      * See matrix storage details. @@ -350,7 +350,7 @@ public class PMVMatrix implements GLMatrixFunc { return matrixMv; } - /** + /** * Returns the inverse {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvi). *

      * Method enables the Mvi matrix update, and performs it's update w/o clearing the modified bits. @@ -367,7 +367,7 @@ public class PMVMatrix implements GLMatrixFunc { return matrixMvi; } - /** + /** * Returns the inverse transposed {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvit). *

      * Method enables the Mvit matrix update, and performs it's update w/o clearing the modified bits. @@ -383,9 +383,9 @@ public class PMVMatrix implements GLMatrixFunc { updateImpl(false); return matrixMvit; } - - /** - * Returns 2 matrices within one FloatBuffer: {@link #glGetPMatrixf() P} and {@link #glGetMvMatrixf() Mv}. + + /** + * Returns 2 matrices within one FloatBuffer: {@link #glGetPMatrixf() P} and {@link #glGetMvMatrixf() Mv}. *

      * See matrix storage details. *

      @@ -393,9 +393,9 @@ public class PMVMatrix implements GLMatrixFunc { public final FloatBuffer glGetPMvMatrixf() { return matrixPMv; } - - /** - * Returns 3 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv} and {@link #glGetMviMatrixf() Mvi}. + + /** + * Returns 3 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv} and {@link #glGetMviMatrixf() Mvi}. *

      * Method enables the Mvi matrix update, and performs it's update w/o clearing the modified bits. *

      @@ -410,9 +410,9 @@ public class PMVMatrix implements GLMatrixFunc { updateImpl(false); return matrixPMvMvi; } - - /** - * Returns 4 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv}, {@link #glGetMviMatrixf() Mvi} and {@link #glGetMvitMatrixf() Mvit}. + + /** + * Returns 4 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv}, {@link #glGetMviMatrixf() Mvi} and {@link #glGetMvitMatrixf() Mvit}. *

      * Method enables the Mvi and Mvit matrix update, and performs it's update w/o clearing the modified bits. *

      @@ -427,14 +427,14 @@ public class PMVMatrix implements GLMatrixFunc { updateImpl(false); return matrixPMvMvit; } - + /** Returns the frustum, derived from projection * modelview */ public Frustum glGetFrustum() { requestMask |= DIRTY_FRUSTUM; updateImpl(false); return frustum; } - + /* * @return the matrix of the current matrix-mode */ @@ -443,7 +443,7 @@ public class PMVMatrix implements GLMatrixFunc { } /** - * @param matrixName Either a matrix-get-name, i.e. + * @param matrixName Either a matrix-get-name, i.e. * {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX}, * or a matrix-mode-name, i.e. * {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} @@ -462,10 +462,10 @@ public class PMVMatrix implements GLMatrixFunc { return matrixTex; default: throw new GLException("unsupported matrixName: "+matrixName); - } + } } - // + // // GLMatrixFunc implementation // @@ -494,7 +494,7 @@ public class PMVMatrix implements GLMatrixFunc { } params.position(pos); } - + @Override public final void glGetFloatv(int matrixGetName, float[] params, int params_offset) { if(matrixGetName==GL_MATRIX_MODE) { @@ -505,7 +505,7 @@ public class PMVMatrix implements GLMatrixFunc { matrix.reset(); } } - + @Override public final void glGetIntegerv(int pname, IntBuffer params) { int pos = params.position(); @@ -516,7 +516,7 @@ public class PMVMatrix implements GLMatrixFunc { } params.position(pos); } - + @Override public final void glGetIntegerv(int pname, int[] params, int params_offset) { if(pname==GL_MATRIX_MODE) { @@ -537,12 +537,12 @@ public class PMVMatrix implements GLMatrixFunc { matrixP.put(values, offset, 16); matrixP.reset(); dirtyBits |= DIRTY_FRUSTUM ; - modifiedBits |= MODIFIED_PROJECTION; + modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { matrixTex.put(values, offset, 16); matrixTex.reset(); modifiedBits |= MODIFIED_TEXTURE; - } + } } @Override @@ -557,12 +557,12 @@ public class PMVMatrix implements GLMatrixFunc { matrixP.put(m); matrixP.reset(); dirtyBits |= DIRTY_FRUSTUM ; - modifiedBits |= MODIFIED_PROJECTION; + modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { matrixTex.put(m); matrixTex.reset(); modifiedBits |= MODIFIED_TEXTURE; - } + } m.position(spos); } @@ -584,9 +584,9 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glPushMatrix() { - if(matrixMode==GL_MODELVIEW) { + if(matrixMode==GL_MODELVIEW) { matrixMvStack.putOnTop(matrixMv, 16); - matrixMv.reset(); + matrixMv.reset(); } else if(matrixMode==GL_PROJECTION) { matrixPStack.putOnTop(matrixP, 16); matrixP.reset(); @@ -612,8 +612,8 @@ public class PMVMatrix implements GLMatrixFunc { matrixTex.put(matrixIdent); matrixTex.reset(); modifiedBits |= MODIFIED_TEXTURE; - } - matrixIdent.reset(); + } + matrixIdent.reset(); } @Override @@ -629,7 +629,7 @@ public class PMVMatrix implements GLMatrixFunc { } else if(matrixMode==GL.GL_TEXTURE) { FloatUtil.multMatrixf(matrixTex, m); modifiedBits |= MODIFIED_TEXTURE; - } + } } @Override @@ -645,12 +645,12 @@ public class PMVMatrix implements GLMatrixFunc { } else if(matrixMode==GL.GL_TEXTURE) { FloatUtil.multMatrixf(matrixTex, m, m_offset); modifiedBits |= MODIFIED_TEXTURE; - } + } } @Override public final void glTranslatef(final float x, final float y, final float z) { - // Translation matrix: + // Translation matrix: // 1 0 0 x // 0 1 0 y // 0 0 1 z @@ -665,7 +665,7 @@ public class PMVMatrix implements GLMatrixFunc { public final void glRotatef(final float angdeg, float x, float y, float z) { final float angrad = angdeg * (float) Math.PI / 180.0f; final float c = (float)Math.cos(angrad); - final float ic= 1.0f - c; + final float ic= 1.0f - c; final float s = (float)Math.sin(angrad); vec3f[0]=x; vec3f[1]=y; vec3f[2]=z; @@ -700,7 +700,7 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glScalef(final float x, final float y, final float z) { - // Scale matrix: + // Scale matrix: // x 0 0 0 // 0 y 0 0 // 0 0 z 0 @@ -714,7 +714,7 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glOrthof(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) { - // Ortho matrix: + // Ortho matrix: // 2/dx 0 0 tx // 0 2/dy 0 ty // 0 0 2/dz tz @@ -744,7 +744,7 @@ public class PMVMatrix implements GLMatrixFunc { if(left==right || top==bottom) { throw new GLException("GL_INVALID_VALUE: top,bottom and left,right must not be equal"); } - // Frustum matrix: + // Frustum matrix: // 2*zNear/dx 0 A 0 // 0 2*zNear/dy B 0 // 0 0 C D @@ -774,7 +774,7 @@ public class PMVMatrix implements GLMatrixFunc { // // Extra functionality // - + /** * {@link #glMultMatrixf(FloatBuffer) Multiply} the {@link #glGetMatrixMode() current matrix} with the perspective/frustum matrix. */ @@ -787,7 +787,7 @@ public class PMVMatrix implements GLMatrixFunc { } /** - * {@link #glMultMatrixf(FloatBuffer) Multiply} and {@link #glTranslatef(float, float, float) translate} the {@link #glGetMatrixMode() current matrix} + * {@link #glMultMatrixf(FloatBuffer) Multiply} and {@link #glTranslatef(float, float, float) translate} the {@link #glGetMatrixMode() current matrix} * with the eye, object and orientation. */ public final void gluLookAt(float eyex, float eyey, float eyez, @@ -798,7 +798,7 @@ public class PMVMatrix implements GLMatrixFunc { /** * Map object coordinates to window coordinates. - * + * * @param objx * @param objy * @param objz @@ -815,20 +815,20 @@ public class PMVMatrix implements GLMatrixFunc { return projectFloat.gluProject(objx, objy, objz, matrixMv.array(), matrixMv.position(), matrixP.array(), matrixP.position(), - viewport, viewport_offset, + viewport, viewport_offset, win_pos, win_pos_offset); } else { return projectFloat.gluProject(objx, objy, objz, matrixMv, matrixP, - viewport, viewport_offset, + viewport, viewport_offset, win_pos, win_pos_offset); } } /** * Map window coordinates to object coordinates. - * + * * @param winx * @param winy * @param winz @@ -845,23 +845,23 @@ public class PMVMatrix implements GLMatrixFunc { return projectFloat.gluUnProject(winx, winy, winz, matrixMv.array(), matrixMv.position(), matrixP.array(), matrixP.position(), - viewport, viewport_offset, + viewport, viewport_offset, obj_pos, obj_pos_offset); } else { return projectFloat.gluUnProject(winx, winy, winz, matrixMv, matrixP, - viewport, viewport_offset, + viewport, viewport_offset, obj_pos, obj_pos_offset); - } + } } - + public final void gluPickMatrix(float x, float y, float deltaX, float deltaY, int[] viewport, int viewport_offset) { projectFloat.gluPickMatrix(this, x, y, deltaX, deltaY, viewport, viewport_offset); } - + public StringBuilder toString(StringBuilder sb, String f) { if(null == sb) { sb = new StringBuilder(); @@ -874,8 +874,8 @@ public class PMVMatrix implements GLMatrixFunc { final boolean frustumReq = 0 != (DIRTY_FRUSTUM & requestMask); final boolean modP = 0 != ( MODIFIED_PROJECTION & modifiedBits ); final boolean modMv = 0 != ( MODIFIED_MODELVIEW & modifiedBits ); - final boolean modT = 0 != ( MODIFIED_TEXTURE & modifiedBits ); - + final boolean modT = 0 != ( MODIFIED_TEXTURE & modifiedBits ); + sb.append("PMVMatrix[backingArray ").append(this.usesBackingArray()); sb.append(", modified[P ").append(modP).append(", Mv ").append(modMv).append(", T ").append(modT); sb.append("], dirty/req[Mvi ").append(mviDirty).append("/").append(mviReq).append(", Mvit ").append(mvitDirty).append("/").append(mvitReq).append(", Frustum ").append(frustumDirty).append("/").append(frustumReq); @@ -887,28 +887,28 @@ public class PMVMatrix implements GLMatrixFunc { matrixToString(sb, f, matrixTex); if( 0 != ( requestMask & DIRTY_INVERSE_MODELVIEW ) ) { sb.append(", Inverse Modelview").append(Platform.NEWLINE); - matrixToString(sb, f, matrixMvi); + matrixToString(sb, f, matrixMvi); } if( 0 != ( requestMask & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) { sb.append(", Inverse Transposed Modelview").append(Platform.NEWLINE); - matrixToString(sb, f, matrixMvit); + matrixToString(sb, f, matrixMvit); } sb.append("]"); return sb; } - + public String toString() { return toString(null, "%10.5f").toString(); } - /** + /** * Returns the modified bits due to mutable operations.. *

      * A modified bit is set, if the corresponding matrix had been modified by a mutable operation * since last {@link #update()} or {@link #getModifiedBits(boolean) getModifiedBits(true)} call. *

      * @param clear if true, clears the modified bits, otherwise leaves them untouched. - * + * * @see #MODIFIED_PROJECTION * @see #MODIFIED_MODELVIEW * @see #MODIFIED_TEXTURE @@ -920,16 +920,16 @@ public class PMVMatrix implements GLMatrixFunc { } return r; } - - /** + + /** * Returns the dirty bits due to mutable operations. *

      * A dirty bit is set , if the corresponding matrix had been modified by a mutable operation * since last {@link #update()} call. The latter clears the dirty state only if the dirty matrix (Mvi or Mvit) or {@link Frustum} - * has been requested by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * has been requested by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} * or {@link #glGetFrustum() Frustum get} methods. *

      - * + * * @deprecated Function is exposed for debugging purposes only. * @see #DIRTY_INVERSE_MODELVIEW * @see #DIRTY_INVERSE_TRANSPOSED_MODELVIEW @@ -944,12 +944,12 @@ public class PMVMatrix implements GLMatrixFunc { return dirtyBits; } - /** + /** * Returns the request bit mask, which uses bit values equal to the dirty mask. *

      - * The request bit mask is set by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * The request bit mask is set by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} * or {@link #glGetFrustum() Frustum get} methods. - *

      + *

      * * @deprecated Function is exposed for debugging purposes only. * @see #clearAllUpdateRequests() @@ -965,16 +965,16 @@ public class PMVMatrix implements GLMatrixFunc { public final int getRequestMask() { return requestMask; } - - + + /** * Clears all {@link #update()} requests of the Mvi and Mvit matrix and Frustum - * after it has been enabled by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * after it has been enabled by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} * or {@link #glGetFrustum() Frustum get} methods. *

      * Allows user to disable subsequent Mvi, Mvit and {@link Frustum} updates if no more required. - *

      - * + *

      + * * @see #glGetMviMatrixf() * @see #glGetMvitMatrixf() * @see #glGetPMvMviMatrixf() @@ -983,14 +983,14 @@ public class PMVMatrix implements GLMatrixFunc { * @see #getRequestMask() */ public final void clearAllUpdateRequests() { - requestMask &= ~DIRTY_ALL; + requestMask &= ~DIRTY_ALL; } - + /** * Update the derived {@link #glGetMviMatrixf() inverse modelview (Mvi)}, - * {@link #glGetMvitMatrixf() inverse transposed modelview (Mvit)} matrices and {@link Frustum} - * if they are dirty and they were requested - * by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * {@link #glGetMvitMatrixf() inverse transposed modelview (Mvit)} matrices and {@link Frustum} + * if they are dirty and they were requested + * by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} * or {@link #glGetFrustum() Frustum get} methods. *

      * The Mvi and Mvit matrices and {@link Frustum} are considered dirty, if their corresponding @@ -999,7 +999,7 @@ public class PMVMatrix implements GLMatrixFunc { *

      * Method should be called manually in case mutable operations has been called * and caller operates on already fetched references, i.e. not calling - * {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} * or {@link #glGetFrustum() Frustum get} etc anymore. *

      *

      @@ -1007,12 +1007,12 @@ public class PMVMatrix implements GLMatrixFunc { * which are set by any mutable operation. The modified bits have no impact * on this method, but the return value. *

      - * - * @return true if any matrix has been modified since last update call or + * + * @return true if any matrix has been modified since last update call or * if the derived matrices Mvi and Mvit or {@link Frustum} were updated, otherwise false. * In other words, method returns true if any matrix used by the caller must be updated, * e.g. uniforms in a shader program. - * + * * @see #getModifiedBits(boolean) * @see #MODIFIED_PROJECTION * @see #MODIFIED_MODELVIEW @@ -1035,7 +1035,7 @@ public class PMVMatrix implements GLMatrixFunc { if(clearModBits) { modifiedBits = 0; } - + if( 0 != ( dirtyBits & ( DIRTY_FRUSTUM & requestMask ) ) ) { if( null == frustum ) { frustum = new Frustum(); @@ -1046,7 +1046,7 @@ public class PMVMatrix implements GLMatrixFunc { dirtyBits &= ~DIRTY_FRUSTUM; mod = true; } - + if( 0 == ( dirtyBits & requestMask ) ) { return mod; // nothing more requested which may have been dirty } @@ -1061,9 +1061,9 @@ public class PMVMatrix implements GLMatrixFunc { } return setMviMvitNIODirectAccess() || mod; } - + // - // private + // private // private int nioBackupArraySupported = 0; // -1 not supported, 0 - TBD, 1 - supported private final String msgCantComputeInverse = "Invalid source Mv matrix, can't compute inverse"; @@ -1080,7 +1080,7 @@ public class PMVMatrix implements GLMatrixFunc { res = true; } if( 0 != ( requestMask & ( dirtyBits & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) ) { // only if requested & dirty - // transpose matrix + // transpose matrix final float[] _matrixMvit = matrixMvit.array(); final int _matrixMvitOffset = matrixMvit.position(); for (int i = 0; i < 4; i++) { @@ -1093,7 +1093,7 @@ public class PMVMatrix implements GLMatrixFunc { } return res; } - + private final boolean setMviMvitNIODirectAccess() { boolean res = false; if( 0 != ( dirtyBits & DIRTY_INVERSE_MODELVIEW ) ) { // only if dirt; always requested at this point, see update() @@ -1104,7 +1104,7 @@ public class PMVMatrix implements GLMatrixFunc { res = true; } if( 0 != ( requestMask & ( dirtyBits & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) ) { // only if requested & dirty - // transpose matrix + // transpose matrix for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { matrixMvit.put(j+i*4, matrixMvi.get(i+j*4)); diff --git a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java index a2b7ba343..b00866dd9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -35,14 +35,14 @@ import javax.media.opengl.GLException; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; /** - * Variation of {@link TileRenderer} w/o using fixed tiles but arbitrary rectangular regions. + * Variation of {@link TileRenderer} w/o using fixed tiles but arbitrary rectangular regions. *

      * See {@link TileRendererBase} for details. *

      */ public class RandomTileRenderer extends TileRendererBase { private boolean tileRectSet = false; - + /** * Creates a new TileRenderer object */ @@ -72,15 +72,15 @@ public class RandomTileRenderer extends TileRendererBase { /** * Set the tile rectangle for the subsequent rendering calls. - * - * @throws IllegalArgumentException is tile x/y are < 0 or tile size is <= 0x0 + * + * @throws IllegalArgumentException is tile x/y are < 0 or tile size is <= 0x0 */ public void setTileRect(int tX, int tY, int tWidth, int tHeight) throws IllegalStateException, IllegalArgumentException { if( 0 > tX || 0 > tX ) { - throw new IllegalArgumentException("Tile pos must be >= 0/0"); + throw new IllegalArgumentException("Tile pos must be >= 0/0"); } if( 0 >= tWidth || 0 >= tHeight ) { - throw new IllegalArgumentException("Tile size must be > 0x0"); + throw new IllegalArgumentException("Tile size must be > 0x0"); } this.currentTileXPos = tX; this.currentTileYPos = tY; @@ -88,57 +88,57 @@ public class RandomTileRenderer extends TileRendererBase { this.currentTileHeight = tHeight; tileRectSet = true; } - + @Override public final boolean isSetup() { return 0 < imageSize.getWidth() && 0 < imageSize.getHeight() && tileRectSet; } - + /** * {@inheritDoc} - * - *

      + * + *

      * end of tiling is never reached w/ {@link RandomRileRenderer}, * i.e. method always returns false. *

      */ @Override public final boolean eot() { return false; } - + /** * {@inheritDoc} - * + * * Reset internal states of {@link RandomTileRenderer} are: none. */ @Override public final void reset() { } - + /** * {@inheritDoc} - * - * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or + * + * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or * {@link #setTileRect(int, int, int, int) tile-rect} has not been set. */ @Override public final void beginTile(GL gl) throws IllegalStateException, GLException { if( 0 >= imageSize.getWidth() || 0 >= imageSize.getHeight() ) { - throw new IllegalStateException("Image size has not been set"); + throw new IllegalStateException("Image size has not been set"); } if( !tileRectSet ) { throw new IllegalStateException("tileRect has not been set"); } validateGL(gl); - + gl.glViewport( 0, 0, currentTileWidth, currentTileHeight ); - + if( DEBUG ) { System.err.println("TileRenderer.begin.X: "+this.toString()); } - + // Do not forget to issue: // reshape( 0, 0, tW, tH ); // which shall reflect tile renderer fileds: currentTileXPos, currentTileYPos and imageSize - + beginCalled = true; } @@ -148,7 +148,7 @@ public class RandomTileRenderer extends TileRendererBase { throw new IllegalStateException("beginTile(..) has not been called"); } validateGL(gl); - + // be sure OpenGL rendering is finished gl.glFlush(); @@ -220,13 +220,13 @@ public class RandomTileRenderer extends TileRendererBase { /* restore previous glPixelStore values */ psm.restore(gl); - + beginCalled = false; } - + /** * Rendering one tile, by simply calling {@link GLAutoDrawable#display()}. - * + * * @throws IllegalStateException if no {@link GLAutoDrawable} is {@link #attachAutoDrawable(GLAutoDrawable) attached} * or imageSize is not set */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java b/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java index b949f0e39..47d56bcb1 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TGAWriter.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2005 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 @@ -28,7 +28,7 @@ * 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. @@ -46,7 +46,7 @@ import java.nio.channels.*; * class; can also be used in conjunction with the {@link com.jogamp.opengl.util.gl2.TileRenderer} class. */ public class TGAWriter { - + private static final int TARGA_HEADER_SIZE = 18; private FileChannel ch; @@ -91,7 +91,7 @@ public class TGAWriter { image.put(14, (byte) (height & 0xFF)); // height image.put(15, (byte) (height >> 8)); // height image.put(16, (byte) pixelSize); // pixel size - + // go to image data position image.position(TARGA_HEADER_SIZE); // jogl needs a sliced buffer diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java index 999db77a9..7f86b14c6 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,18 +20,18 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. - * + * * --------------------- - * + * * Based on Brian Paul's tile rendering library, found * at http://www.mesa3d.org/brianp/TR.html. - * - * Copyright (C) 1997-2005 Brian Paul. - * Licensed under BSD-compatible terms with permission of the author. + * + * Copyright (C) 1997-2005 Brian Paul. + * Licensed under BSD-compatible terms with permission of the author. * See LICENSE.txt for license information. */ package com.jogamp.opengl.util; @@ -60,7 +60,7 @@ import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; *

      * See {@link TileRendererBase} for details. *

      - * + * * @author ryanm, sgothel */ public class TileRenderer extends TileRendererBase { @@ -150,7 +150,7 @@ public class TileRenderer extends TileRendererBase { .append("rowOrder "+rowOrder+", offset/size "+offsetX+"/"+offsetY+" "+tileSize.getWidth()+"x"+tileSize.getHeight()+" brd "+tileBorder+", "); return super.tileDetails(sb); } - + /** * Creates a new TileRenderer object */ @@ -169,7 +169,7 @@ public class TileRenderer extends TileRendererBase { super.setImageSize(width, height); reset(); } - + /** * Clips the image-size this tile-renderer iterates through, * which can be retrieved via {@link #getClippedImageSize()}. @@ -179,7 +179,7 @@ public class TileRenderer extends TileRendererBase { *

      * Implementation {@link #reset()} internal states. *

      - * + * * @param width The image-clipping.width * @param height The image-clipping.height * @see #getClippedImageSize() @@ -208,7 +208,7 @@ public class TileRenderer extends TileRendererBase { * {@link #TR_IMAGE_CLIPPING_HEIGHT}. *

      */ - public final DimensionImmutable getClippedImageSize() { + public final DimensionImmutable getClippedImageSize() { if( null != imageClippingDim ) { return new Dimension(Math.min(imageClippingDim.getWidth(), imageSize.getWidth()), Math.min(imageClippingDim.getHeight(), imageSize.getHeight()) ); @@ -224,7 +224,7 @@ public class TileRenderer extends TileRendererBase { *

      * Implementation {@link #reset()} internal states. *

      - * + * * @param width * The width of the tiles. Must not be larger than the GL * context @@ -238,10 +238,10 @@ public class TileRenderer extends TileRendererBase { */ public final void setTileSize(int width, int height, int border) { if( 0 > border ) { - throw new IllegalArgumentException("Tile border must be >= 0"); + throw new IllegalArgumentException("Tile border must be >= 0"); } if( 2 * border >= width || 2 * border >= height ) { - throw new IllegalArgumentException("Tile size must be > 0x0 minus 2*border"); + throw new IllegalArgumentException("Tile size must be > 0x0 minus 2*border"); } tileBorder = border; tileSize.set( width, height ); @@ -249,7 +249,7 @@ public class TileRenderer extends TileRendererBase { reset(); } - /** + /** * Sets an xy offset for the resulting tiles * {@link TileRendererBase#TR_CURRENT_TILE_X_POS x-pos} and {@link TileRendererBase#TR_CURRENT_TILE_Y_POS y-pos}. * @see #TR_TILE_X_OFFSET @@ -259,12 +259,12 @@ public class TileRenderer extends TileRendererBase { offsetX = xoff; offsetY = yoff; } - + /** * {@inheritDoc} - * + * * Reset internal states of {@link TileRenderer} are: - *
        + *
          *
        • {@link #TR_ROWS}
        • *
        • {@link #TR_COLUMNS}
        • *
        • {@link #TR_CURRENT_COLUMN}
        • @@ -291,13 +291,13 @@ public class TileRenderer extends TileRendererBase { assert columns >= 0; assert rows >= 0; - + beginCalled = false; isInit = true; } /* pp */ final int getCurrentTile() { return currentTile; } - + @Override public final int getParam(int pname) { switch (pname) { @@ -346,7 +346,7 @@ public class TileRenderer extends TileRendererBase { /** * Sets the order of row traversal, default is {@link #TR_BOTTOM_TO_TOP}. - * + * * @param order The row traversal order, must be either {@link #TR_TOP_TO_BOTTOM} or {@link #TR_BOTTOM_TO_TOP}. */ public final void setRowOrder(int order) { @@ -361,11 +361,11 @@ public class TileRenderer extends TileRendererBase { public final boolean isSetup() { return 0 < imageSize.getWidth() && 0 < imageSize.getHeight(); } - + /** * {@inheritDoc} - * - *

          + * + *

          * end of tiling is reached w/ {@link TileRenderer}, if at least one of the following is true: *

            *
          • all tiles have been rendered, i.e. {@link #TR_CURRENT_TILE_NUM} is -1
          • @@ -378,13 +378,13 @@ public class TileRenderer extends TileRendererBase { if ( !isInit ) { // ensure at least one reset-call reset(); } - return 0 > currentTile || 0 >= columns*rows; + return 0 > currentTile || 0 >= columns*rows; } - + /** * {@inheritDoc} - * - * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or + * + * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or * {@link #eot() end-of-tiling} has been reached. */ @Override @@ -396,7 +396,7 @@ public class TileRenderer extends TileRendererBase { throw new IllegalStateException("EOT reached: "+this); } validateGL(gl); - + /* which tile (by row and column) we're about to render */ if (rowOrder == TR_BOTTOM_TO_TOP) { currentRow = currentTile / columns; @@ -434,11 +434,11 @@ public class TileRenderer extends TileRendererBase { currentTileHeight = tH; gl.glViewport( 0, 0, tW, tH ); - + if( DEBUG ) { System.err.println("TileRenderer.begin: "+this.toString()); } - + // Do not forget to issue: // reshape( 0, 0, tW, tH ); // which shall reflect tile renderer tiles: currentTileXPos, currentTileYPos and imageSize @@ -454,7 +454,7 @@ public class TileRenderer extends TileRendererBase { // be sure OpenGL rendering is finished gl.glFlush(); - + // save current glPixelStore values psm.save(gl); psm.setPackAlignment(gl, 1); @@ -467,13 +467,13 @@ public class TileRenderer extends TileRendererBase { } else { gl2es3 = null; readBuffer = 0; // undef. probably default: GL_FRONT (single buffering) GL_BACK (double buffering) - } + } if( DEBUG ) { System.err.println("TileRenderer.end.0: readBuffer 0x"+Integer.toHexString(readBuffer)+", "+this.toString()); } - + final int tmp[] = new int[1]; - + if( tileBuffer != null ) { final GLPixelAttributes pixelAttribs = tileBuffer.pixelAttributes; final int srcX = tileBorder; @@ -527,7 +527,7 @@ public class TileRenderer extends TileRendererBase { psm.restore(gl); beginCalled = false; - + /* increment tile counter, return 1 if more tiles left to render */ currentTile++; if( currentTile >= rows * columns ) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index 0553d5673..ff7cc5516 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,18 +20,18 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. - * + * * --------------------- - * + * * Based on Brian Paul's tile rendering library, found * at http://www.mesa3d.org/brianp/TR.html. - * - * Copyright (C) 1997-2005 Brian Paul. - * Licensed under BSD-compatible terms with permission of the author. + * + * Copyright (C) 1997-2005 Brian Paul. + * Licensed under BSD-compatible terms with permission of the author. * See LICENSE.txt for license information. */ package com.jogamp.opengl.util; @@ -66,17 +66,17 @@ import jogamp.opengl.Debug; * The PMV matrix needs to be reshaped in user code * after calling {@link #beginTile(GL)}, See {@link #beginTile(GL)}. *

            - *

            + *

            * If {@link #attachAutoDrawable(GLAutoDrawable) attaching to} an {@link GLAutoDrawable}, * the {@link TileRendererListener#reshapeTile(TileRendererBase, int, int, int, int, int, int)} method * is being called after {@link #beginTile(GL)} for each rendered tile. - * It's implementation shall reshape the PMV matrix according to {@link #beginTile(GL)}. + * It's implementation shall reshape the PMV matrix according to {@link #beginTile(GL)}. *

            *
            GL Profile Requirement
            *

            - * Note that {@link #setImageBuffer(GLPixelBuffer) image buffer} can only be used + * Note that {@link #setImageBuffer(GLPixelBuffer) image buffer} can only be used * in conjunction w/ a {@link GL} instance ≥ {@link GL2ES3} passed to {@link #beginTile(GL)} and {@link #endTile(GL)}.
            - * This is due to setting up the {@link GL2ES3#GL_PACK_ROW_LENGTH pack row length} + * This is due to setting up the {@link GL2ES3#GL_PACK_ROW_LENGTH pack row length} * for an {@link #setImageSize(int, int) image width} != tile-width, which usually is the case.
            * Hence a {@link GLException} is thrown in both methods, * if using an {@link #setImageBuffer(GLPixelBuffer) image buffer} @@ -86,7 +86,7 @@ import jogamp.opengl.Debug; * Further more, reading back of MSAA buffers is only supported since {@link GL2ES3} * since it requires to set the {@link GL2ES3#glReadBuffer(int) read-buffer}. *

            - * + * * @author ryanm, sgothel */ public abstract class TileRendererBase { @@ -114,16 +114,16 @@ public abstract class TileRendererBase { * The height of the current tile. See {@link #getParam(int)}. */ public static final int TR_CURRENT_TILE_HEIGHT = 6; - + /* pp */ static final boolean DEBUG = Debug.debug("TileRenderer"); - - /** + + /** * Listener for tile renderer events, intended to extend {@link GLEventListener} implementations, * enabling tile rendering via {@link TileRendererBase#attachAutoDrawable(GLAutoDrawable)}. */ public static interface TileRendererListener { - /** - * The owning {@link GLAutoDrawable} is {@link TileRendererBase#attachAutoDrawable(GLAutoDrawable) attached} + /** + * The owning {@link GLAutoDrawable} is {@link TileRendererBase#attachAutoDrawable(GLAutoDrawable) attached} * to the given {@link TileRendererBase} instance. *

            * The {@link GLContext} of the {@link TileRendererBase}'s {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable} @@ -133,9 +133,9 @@ public abstract class TileRendererBase { * @see TileRendererBase#getAttachedDrawable() */ public void addTileRendererNotify(TileRendererBase tr); - - /** - * The owning {@link GLAutoDrawable} is {@link TileRendererBase#detachAutoDrawable() detached} + + /** + * The owning {@link GLAutoDrawable} is {@link TileRendererBase#detachAutoDrawable() detached} * from the given {@link TileRendererBase} instance. *

            * The {@link GLContext} of the {@link TileRendererBase}'s {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable} @@ -145,10 +145,10 @@ public abstract class TileRendererBase { * @see TileRendererBase#getAttachedDrawable() */ public void removeTileRendererNotify(TileRendererBase tr); - - /** + + /** * Called by the {@link TileRendererBase} during tile-rendering via an - * {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable}'s + * {@link TileRendererBase#getAttachedDrawable() attached} {@link GLAutoDrawable}'s * {@link GLAutoDrawable#display()} call for each tile before {@link #display(GLAutoDrawable)}. *

            * The PMV Matrix shall be reshaped @@ -175,14 +175,14 @@ public abstract class TileRendererBase { * @see TileRendererBase#getAttachedDrawable() */ public void reshapeTile(TileRendererBase tr, - int tileX, int tileY, int tileWidth, int tileHeight, + int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight); /** - * Called by the {@link TileRendererBase} during tile-rendering + * Called by the {@link TileRendererBase} during tile-rendering * after {@link TileRendererBase#beginTile(GL)} and before {@link #reshapeTile(TileRendererBase, int, int, int, int, int, int) reshapeTile(..)}. *

            - * If {@link TileRendererBase} is of type {@link TileRenderer}, + * If {@link TileRendererBase} is of type {@link TileRenderer}, * method is called for the first tile of all tiles.
            * Otherwise, i.e. {@link RandomTileRenderer}, method is called for each particular tile. *

            @@ -193,12 +193,12 @@ public abstract class TileRendererBase { * @param tr the issuing {@link TileRendererBase} */ public void startTileRendering(TileRendererBase tr); - + /** * Called by the {@link TileRenderer} during tile-rendering * after {@link TileRendererBase#endTile(GL)} and {@link GLAutoDrawable#swapBuffers()}. *

            - * If {@link TileRendererBase} is of type {@link TileRenderer}, + * If {@link TileRendererBase} is of type {@link TileRenderer}, * method is called for the last tile of all tiles.
            * Otherwise, i.e. {@link RandomTileRenderer}, method is called for each particular tile. *

            @@ -210,7 +210,7 @@ public abstract class TileRendererBase { */ public void endTileRendering(TileRendererBase tr); } - + protected final Dimension imageSize = new Dimension(0, 0); protected final GLPixelStorageModes psm = new GLPixelStorageModes(); protected GLPixelBuffer imageBuffer; @@ -249,24 +249,24 @@ public abstract class TileRendererBase { return getClass().getSimpleName()+ "["+toString(sb).toString()+"]"; } - + protected TileRendererBase() { } /** * Gets the parameters of this TileRenderer object - * + * * @param pname The parameter name that is to be retrieved * @return the value of the parameter * @throws IllegalArgumentException if pname is not handled */ public abstract int getParam(int pname) throws IllegalArgumentException; - + /** * Specify a buffer the tiles to be copied to. This is not * necessary for the creation of the final image, but useful if you * want to inspect each tile in turn. - * + * * @param buffer The buffer itself. Must be large enough to contain a random tile */ public final void setTileBuffer(GLPixelBuffer buffer) { @@ -281,7 +281,7 @@ public abstract class TileRendererBase { /** * Sets the desired size of the final image - * + * * @param width The width of the final image * @param height The height of the final image */ @@ -294,7 +294,7 @@ public abstract class TileRendererBase { /** * Sets the buffer in which to store the final image - * + * * @param buffer the buffer itself, must be large enough to hold the final image */ public final void setImageBuffer(GLPixelBuffer buffer) { @@ -310,16 +310,16 @@ public abstract class TileRendererBase { /* pp */ final void validateGL(GL gl) throws GLException { if( imageBuffer != null && !gl.isGL2ES3()) { throw new GLException("Using image-buffer w/ inssufficient GL context: "+gl.getContext().getGLVersion()+", "+gl.getGLProfile()); - } + } } - - /** + + /** * Returns true if this instance is setup properly, i.e. {@link #setImageSize(int, int)} .., * and ready for {@link #beginTile(GL)}. * Otherwise returns false. */ public abstract boolean isSetup(); - + /** * Returns true if end of tiling has been reached, otherwise false. *

            @@ -331,7 +331,7 @@ public abstract class TileRendererBase { *

            */ public abstract boolean eot(); - + /** * Method resets implementation's internal state to start of tiling * as required for {@link #beginTile(GL)} if {@link #eot() end of tiling} has been reached. @@ -340,7 +340,7 @@ public abstract class TileRendererBase { *

            */ public abstract void reset(); - + /** * Begins rendering a tile. *

            @@ -367,7 +367,7 @@ public abstract class TileRendererBase { *

            *

            * Use shall render the scene afterwards, concluded with a call to - * this renderer {@link #endTile(GL)}. + * this renderer {@link #endTile(GL)}. *

            *

            * User has to comply with the GL profile requirement. @@ -376,10 +376,10 @@ public abstract class TileRendererBase { * If {@link #eot() end of tiling} has been reached, * user needs to {@link #reset()} tiling before calling this method. *

            - * + * * @param gl The gl context * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} is undefined, - * an {@link #isSetup() implementation related setup} has not be performed + * an {@link #isSetup() implementation related setup} has not be performed * or {@ link #eot()} has been reached. See implementing classes. * @throws GLException if {@link #setImageBuffer(GLPixelBuffer) image buffer} is used but gl instance is < {@link GL2ES3} * @see #isSetup() @@ -387,7 +387,7 @@ public abstract class TileRendererBase { * @see #reset() */ public abstract void beginTile(GL gl) throws IllegalStateException, GLException; - + /** * Must be called after rendering the scene, * see {@link #beginTile(GL)}. @@ -399,13 +399,13 @@ public abstract class TileRendererBase { *

            * User has to comply with the GL profile requirement. *

            - * + * * @param gl the gl context * @throws IllegalStateException if beginTile(gl) has not been called * @throws GLException if {@link #setImageBuffer(GLPixelBuffer) image buffer} is used but gl instance is < {@link GL2ES3} */ public abstract void endTile( GL gl ) throws IllegalStateException, GLException; - + /** * Determines whether the chosen {@link GLCapabilitiesImmutable} * requires a pre-{@link GLDrawable#swapBuffers() swap-buffers} @@ -417,18 +417,18 @@ public abstract class TileRendererBase { * Here {@link GLDrawable#swapBuffers() swap-buffers} shall happen after calling {@link #endTile(GL)}, the default. *

            *

            - * However, multisampling offscreen {@link GLFBODrawable}s + * However, multisampling offscreen {@link GLFBODrawable}s * utilize {@link GLDrawable#swapBuffers() swap-buffers} to downsample * the multisamples into the readable sampling sink. - * In this case, we require a {@link GLDrawable#swapBuffers() swap-buffers} before calling {@link #endTile(GL)}. - *

            - * @param chosenCaps the chosen {@link GLCapabilitiesImmutable} + * In this case, we require a {@link GLDrawable#swapBuffers() swap-buffers} before calling {@link #endTile(GL)}. + *

            + * @param chosenCaps the chosen {@link GLCapabilitiesImmutable} * @return chosenCaps.isFBO() && chosenCaps.getSampleBuffers() */ public final boolean reqPreSwapBuffers(GLCapabilitiesImmutable chosenCaps) { return chosenCaps.isFBO() && chosenCaps.getSampleBuffers(); } - + /** * Attaches the given {@link GLAutoDrawable} to this tile renderer. *

            @@ -440,17 +440,17 @@ public abstract class TileRendererBase { *

            * The {@link GLAutoDrawable}'s {@link GLAutoDrawable#getAutoSwapBufferMode() auto-swap mode} is cached * and set to false, since {@link GLAutoDrawable#swapBuffers() swapBuffers()} maybe issued before {@link #endTile(GL)}, - * see {@link #reqPreSwapBuffers(GLCapabilitiesImmutable)}. + * see {@link #reqPreSwapBuffers(GLCapabilitiesImmutable)}. *

            *

            - * This tile renderer's internal {@link GLEventListener} is then added to the attached {@link GLAutoDrawable} + * This tile renderer's internal {@link GLEventListener} is then added to the attached {@link GLAutoDrawable} * to handle the tile rendering, replacing the original {@link GLEventListener}.
            * It's {@link GLEventListener#display(GLAutoDrawable) display} implementations issues: *

              *
            • Optional {@link #setGLEventListener(GLEventListener, GLEventListener) pre-glel}.{@link GLEventListener#display(GLAutoDrawable) display(..)}
            • *
            • {@link #beginTile(GL)}
            • *
            • for all original {@link TileRendererListener}: - *
                + *
                  *
                • {@link TileRendererListener#reshapeTile(TileRendererBase, int, int, int, int, int, int) reshapeTile(tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight)}
                • *
                • {@link GLEventListener#display(GLAutoDrawable) display(autoDrawable)}
                • *
                @@ -468,7 +468,7 @@ public abstract class TileRendererBase { * since it's called after {@link #endTile(GL)}. *

                *

                - * Call {@link #detachAutoDrawable()} to remove the attached {@link GLAutoDrawable} from this tile renderer + * Call {@link #detachAutoDrawable()} to remove the attached {@link GLAutoDrawable} from this tile renderer * and to restore it's original {@link GLEventListener}. *

                * @param glad the {@link GLAutoDrawable} to attach. @@ -481,7 +481,7 @@ public abstract class TileRendererBase { throw new IllegalStateException("GLAutoDrawable already attached"); } this.glad = glad; - + final int aSz = glad.getGLEventListenerCount(); listeners = new GLEventListener[aSz]; listenersInit = new boolean[aSz]; @@ -510,11 +510,11 @@ public abstract class TileRendererBase { } } - /** - * Returns a previously {@link #attachAutoDrawable(GLAutoDrawable) attached} {@link GLAutoDrawable}, + /** + * Returns a previously {@link #attachAutoDrawable(GLAutoDrawable) attached} {@link GLAutoDrawable}, * null if none is attached. *

                - * If called from {@link TileRendererListener#addTileRendererNotify(TileRendererBase)} + * If called from {@link TileRendererListener#addTileRendererNotify(TileRendererBase)} * or {@link TileRendererListener#removeTileRendererNotify(TileRendererBase)}, method returns the * just attached or soon to be detached {@link GLAutoDrawable}. *

                @@ -522,9 +522,9 @@ public abstract class TileRendererBase { * @see #detachAutoDrawable() */ public final GLAutoDrawable getAttachedDrawable() { - return glad; + return glad; } - + /** * Detaches the given {@link GLAutoDrawable} from this tile renderer. * @see #attachAutoDrawable(GLAutoDrawable) @@ -547,16 +547,16 @@ public abstract class TileRendererBase { System.err.println("TileRenderer: detached: "+glad); System.err.println("TileRenderer: "+glad.getChosenGLCapabilities()); } - + listeners = null; listenersInit = null; glad = null; } } - + /** * Set {@link GLEventListener} for pre- and post operations when used w/ - * {@link #attachAutoDrawable(GLAutoDrawable)} + * {@link #attachAutoDrawable(GLAutoDrawable)} * for each {@link GLEventListener} callback. * @param preTile the pre operations * @param postTile the post operations @@ -565,10 +565,10 @@ public abstract class TileRendererBase { glEventListenerPre = preTile; glEventListenerPost = postTile; } - + /** * Rendering one tile, by simply calling {@link GLAutoDrawable#display()}. - * + * * @throws IllegalStateException if no {@link GLAutoDrawable} is {@link #attachAutoDrawable(GLAutoDrawable) attached} * or imageSize is not set */ @@ -578,10 +578,10 @@ public abstract class TileRendererBase { } glad.display(); } - + private final GLEventListener tiledGLEL = new GLEventListener() { final TileRenderer tileRenderer = TileRendererBase.this instanceof TileRenderer ? (TileRenderer) TileRendererBase.this : null; - + @Override public void init(GLAutoDrawable drawable) { if( null != glEventListenerPre ) { @@ -642,13 +642,13 @@ public abstract class TileRendererBase { if( null == tileRenderer || 0 == tileRenderer.getCurrentTile() ) { tl.startTileRendering(TileRendererBase.this); } - tl.reshapeTile(TileRendererBase.this, + tl.reshapeTile(TileRendererBase.this, currentTileXPos, currentTileYPos, currentTileWidth, currentTileHeight, imageSize.getWidth(), imageSize.getHeight()); l.display(drawable); } } - + if( gladRequiresPreSwap ) { glad.swapBuffers(); endTile(gl); @@ -662,7 +662,7 @@ public abstract class TileRendererBase { if( l instanceof TileRendererListener ) { ((TileRendererListener)l).endTileRendering(TileRendererBase.this); } - } + } } if( null != glEventListenerPost ) { glEventListenerPost.reshape(drawable, 0, 0, currentTileWidth, currentTileHeight); diff --git a/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java b/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java index e2bca010c..45f5d2694 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,51 +20,51 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ package com.jogamp.opengl.util; -/** +/** * Integer time frame in milliseconds, maybe specialized for texture/video, audio, .. animated content. *

                * Type and value range has been chosen to suit embedded CPUs * and characteristics of audio / video streaming and animations. - * Milliseconds of type integer with a maximum value of {@link Integer#MAX_VALUE} + * Milliseconds of type integer with a maximum value of {@link Integer#MAX_VALUE} * will allow tracking time up 2,147,483.647 seconds or * 24 days 20 hours 31 minutes and 23 seconds. *

                *

                * Milliseconds granularity is also more than enough to deal with A-V synchronization, * where the threshold usually lies within 22ms. - *

                + *

                *

                * Milliseconds granularity for displaying video frames might seem inaccurate * for each single frame, i.e. 60Hz != 16ms, however, accumulated values diminish - * this error and vertical sync is achieved by build-in V-Sync of the video drivers. + * this error and vertical sync is achieved by build-in V-Sync of the video drivers. *

                */ public class TimeFrameI { /** Constant marking an invalid PTS, i.e. Integer.MIN_VALUE == 0x80000000 == {@value}. Sync w/ native code. */ public static final int INVALID_PTS = 0x80000000; - + /** Constant marking the end of the stream PTS, i.e. Integer.MIN_VALUE - 1 == 0x7FFFFFFF == {@value}. Sync w/ native code. */ - public static final int END_OF_STREAM_PTS = 0x7FFFFFFF; + public static final int END_OF_STREAM_PTS = 0x7FFFFFFF; protected int pts; protected int duration; - + public TimeFrameI() { pts = INVALID_PTS; - duration = 0; + duration = 0; } public TimeFrameI(int pts, int duration) { this.pts = pts; - this.duration = duration; + this.duration = duration; } - + /** Get this frame's presentation timestamp (PTS) in milliseconds. */ public final int getPTS() { return pts; } /** Set this frame's presentation timestamp (PTS) in milliseconds. */ @@ -73,7 +73,7 @@ public class TimeFrameI { public final int getDuration() { return duration; } /** Set this frame's duration in milliseconds. */ public final void setDuration(int duration) { this.duration = duration; } - + public String toString() { return "TimeFrame[pts " + pts + " ms, l " + duration + " ms]"; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java index 8751fc816..dffdfae8e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -35,10 +35,10 @@ import jogamp.opengl.Debug; public interface AudioSink { public static final boolean DEBUG = Debug.debug("AudioSink"); - + /** Default frame duration in millisecond, i.e. 1 frame per {@value} ms. */ public static final int DefaultFrameDuration = 32; - + /** Initial audio queue size in milliseconds. {@value} ms, i.e. 16 frames per 32 ms. See {@link #init(AudioFormat, float, int, int, int)}.*/ public static final int DefaultInitialQueueSize = 16 * 32; // 512 ms /** Audio queue grow size in milliseconds. {@value} ms, i.e. 16 frames per 32 ms. See {@link #init(AudioFormat, float, int, int, int)}.*/ @@ -47,7 +47,7 @@ public interface AudioSink { public static final int DefaultQueueLimitWithVideo = 96 * 32; // 3072 ms /** Audio queue limit w/o video in milliseconds. {@value} ms, i.e. 32 frames per 32 ms. See {@link #init(AudioFormat, float, int, int, int)}.*/ public static final int DefaultQueueLimitAudioOnly = 32 * 32; // 1024 ms - + /** * Specifies the linear audio PCM format. */ @@ -78,7 +78,7 @@ public interface AudioSink { } } } - + /** Sample rate in Hz (1/s). */ public final int sampleRate; /** Sample size in bits. */ @@ -91,36 +91,36 @@ public interface AudioSink { /** Planar or packed samples. If planar, each channel has their own data buffer. If packed, channel data is interleaved in one buffer. */ public final boolean planar; public final boolean littleEndian; - - + + // // Time <-> Bytes // - - /** - * Returns the byte size of the given milliseconds + + /** + * Returns the byte size of the given milliseconds * according to {@link #sampleSize}, {@link #channelCount} and {@link #sampleRate}. *

                * Time -> Byte Count - *

                + *

                */ public final int getDurationsByteSize(int millisecs) { final int bytesPerSample = sampleSize >>> 3; // /8 return millisecs * ( channelCount * bytesPerSample * ( sampleRate / 1000 ) ); } - - /** - * Returns the duration in milliseconds of the given byte count - * according to {@link #sampleSize}, {@link #channelCount} and {@link #sampleRate}. + + /** + * Returns the duration in milliseconds of the given byte count + * according to {@link #sampleSize}, {@link #channelCount} and {@link #sampleRate}. *

                * Byte Count -> Time - *

                + *

                */ public final int getBytesDuration(int byteCount) { final int bytesPerSample = sampleSize >>> 3; // /8 - return byteCount / ( channelCount * bytesPerSample * ( sampleRate / 1000 ) ); + return byteCount / ( channelCount * bytesPerSample * ( sampleRate / 1000 ) ); } - + /** * Returns the duration in milliseconds of the given sample count per frame and channel * according to the {@link #sampleRate}, i.e. @@ -129,13 +129,13 @@ public interface AudioSink { *
    *

    * Sample Count -> Time - *

    + *

    * @param sampleCount sample count per frame and channel */ public final float getSamplesDuration(int sampleCount) { return ( 1000f * (float) sampleCount ) / (float)sampleRate; } - + /** * Returns the rounded frame count of the given milliseconds and frame duration. *
    @@ -147,36 +147,36 @@ public interface AudioSink {
              * 

    *

    * Frame Time -> Frame Count - *

    + *

    * @param millisecs time in milliseconds * @param frameDuration duration per frame in milliseconds. */ public final int getFrameCount(int millisecs, float frameDuration) { return Math.max(1, (int) ( (float)millisecs / frameDuration + 0.5f )); } - + /** * Returns the byte size of given sample count - * according to the {@link #sampleSize}, i.e.: + * according to the {@link #sampleSize}, i.e.: *
              *  sampleCount * ( sampleSize / 8 )
              * 
    *

    - * Note: To retrieve the byte size for all channels, + * Note: To retrieve the byte size for all channels, * you need to pre-multiply sampleCount with {@link #channelCount}. *

    *

    * Sample Count -> Byte Count - *

    + *

    * @param sampleCount sample count */ public final int getSamplesByteCount(int sampleCount) { return sampleCount * ( sampleSize >>> 3 ); } - + /** * Returns the sample count of given byte count - * according to the {@link #sampleSize}, i.e.: + * according to the {@link #sampleSize}, i.e.: *
              *  ( byteCount * 8 ) / sampleSize
              * 
    @@ -186,24 +186,24 @@ public interface AudioSink { *

    *

    * Byte Count -> Sample Count - *

    + *

    * @param sampleCount sample count */ public final int getBytesSampleCount(int byteCount) { return ( byteCount << 3 ) / sampleSize; } - - public String toString() { + + public String toString() { return "AudioDataFormat[sampleRate "+sampleRate+", sampleSize "+sampleSize+", channelCount "+channelCount+ ", signed "+signed+", fixedP "+fixedP+", "+(planar?"planar":"packed")+", "+(littleEndian?"little":"big")+"-endian]"; } } - /** Default {@link AudioFormat}, [type PCM, sampleRate 44100, sampleSize 16, channelCount 2, signed, fixedP, !planar, littleEndian]. */ - public static final AudioFormat DefaultFormat = new AudioFormat(44100, 16, 2, true /* signed */, + /** Default {@link AudioFormat}, [type PCM, sampleRate 44100, sampleSize 16, channelCount 2, signed, fixedP, !planar, littleEndian]. */ + public static final AudioFormat DefaultFormat = new AudioFormat(44100, 16, 2, true /* signed */, true /* fixed point */, false /* planar */, true /* littleEndian */); - + public static abstract class AudioFrame extends TimeFrameI { protected int byteSize; - + public AudioFrame() { this.byteSize = 0; } @@ -211,19 +211,19 @@ public interface AudioSink { super(pts, duration); this.byteSize=byteCount; } - + /** Get this frame's size in bytes. */ public final int getByteSize() { return byteSize; } /** Set this frame's size in bytes. */ public final void setByteSize(int size) { this.byteSize=size; } - - public String toString() { + + public String toString() { return "AudioFrame[pts " + pts + " ms, l " + duration + " ms, "+byteSize + " bytes]"; } } public static class AudioDataFrame extends AudioFrame { protected final ByteBuffer data; - + public AudioDataFrame(int pts, int duration, ByteBuffer bytes, int byteCount) { super(pts, duration, byteCount); if( byteCount > bytes.remaining() ) { @@ -231,62 +231,62 @@ public interface AudioSink { } this.data=bytes; } - + /** Get this frame's data. */ public final ByteBuffer getData() { return data; } - - public String toString() { + + public String toString() { return "AudioDataFrame[pts " + pts + " ms, l " + duration + " ms, "+byteSize + " bytes, " + data + "]"; } } - - /** + + /** * Returns the initialized state of this instance. *

    * The initialized state is affected by this instance * overall availability, i.e. after instantiation, * as well as by {@link #destroy()}. - *

    + *

    */ public boolean isInitialized(); /** Returns the playback speed. */ public float getPlaySpeed(); - - /** + + /** * Sets the playback speed. *

    * To simplify test, play speed is normalized, i.e. - *

      - *
    • 1.0f: if Math.abs(1.0f - rate) < 0.01f
    • + *
        + *
      • 1.0f: if Math.abs(1.0f - rate) < 0.01f
      • *
      *

      - * @return true if successful, otherwise false, i.e. due to unsupported value range of implementation. + * @return true if successful, otherwise false, i.e. due to unsupported value range of implementation. */ public boolean setPlaySpeed(float s); - + /** Returns the volume. */ public float getVolume(); - - /** + + /** * Sets the volume [0f..1f]. *

      * To simplify test, volume is normalized, i.e. - *

        - *
      • 0.0f: if Math.abs(v) < 0.01f
      • - *
      • 1.0f: if Math.abs(1.0f - v) < 0.01f
      • + *
          + *
        • 0.0f: if Math.abs(v) < 0.01f
        • + *
        • 1.0f: if Math.abs(1.0f - v) < 0.01f
        • *
        *

        - * @return true if successful, otherwise false, i.e. due to unsupported value range of implementation. + * @return true if successful, otherwise false, i.e. due to unsupported value range of implementation. */ public boolean setVolume(float v); - - /** + + /** * Returns the preferred {@link AudioFormat} by this sink. *

        - * The preferred format is guaranteed to be supported + * The preferred format is guaranteed to be supported * and shall reflect this sinks most native format, - * i.e. best performance w/o data conversion. + * i.e. best performance w/o data conversion. *

        *

        * Known {@link #AudioFormat} attributes considered by implementations: @@ -295,20 +295,20 @@ public interface AudioSink { *

      *

      * @see #initSink(AudioFormat) - * @see #isSupported(AudioFormat) + * @see #isSupported(AudioFormat) */ public AudioFormat getPreferredFormat(); - + /** Return the maximum number of supported channels. */ public int getMaxSupportedChannels(); - + /** * Returns true if the given format is supported by the sink, otherwise false. * @see #initSink(AudioFormat) - * @see #getPreferredFormat() + * @see #getPreferredFormat() */ public boolean isSupported(AudioFormat format); - + /** * Initializes the sink. *

      @@ -319,7 +319,7 @@ public interface AudioSink { * beforehand and try to find a suitable supported one. * {@link #getPreferredFormat()} and {@link #getMaxSupportedChannels()} may help. *

      - * @param requestedFormat the requested {@link AudioFormat}. + * @param requestedFormat the requested {@link AudioFormat}. * @param frameDuration average or fixed frame duration in milliseconds * helping a caching {@link AudioFrame} based implementation to determine the frame count in the queue. * See {@link #DefaultFrameDuration}. @@ -328,31 +328,31 @@ public interface AudioSink { * @param queueLimit maximum time in milliseconds the queue can hold (and grow), see {@link #DefaultQueueLimitWithVideo} and {@link #DefaultQueueLimitAudioOnly}. * @return true if successful, otherwise false */ - public boolean init(AudioFormat requestedFormat, float frameDuration, + public boolean init(AudioFormat requestedFormat, float frameDuration, int initialQueueSize, int queueGrowAmount, int queueLimit); - + /** * Returns true, if {@link #play()} has been requested and the sink is still playing, * otherwise false. */ public boolean isPlaying(); - - /** + + /** * Play buffers queued via {@link #enqueueData(AudioFrame)} from current internal position. * If no buffers are yet queued or the queue runs empty, playback is being continued when buffers are enqueued later on. * @see #enqueueData(AudioFrame) - * @see #pause() + * @see #pause() */ public void play(); - - /** + + /** * Pause playing buffers while keeping enqueued data incl. it's internal position. * @see #play() * @see #flush() * @see #enqueueData(AudioFrame) */ public void pause(); - + /** * Flush all queued buffers, implies {@link #pause()}. *

      @@ -363,28 +363,28 @@ public interface AudioSink { * @see #enqueueData(AudioFrame) */ public void flush(); - + /** Destroys this instance, i.e. closes all streams and devices allocated. */ public void destroy(); - - /** - * Returns the number of allocated buffers as requested by + + /** + * Returns the number of allocated buffers as requested by * {@link #init(AudioFormat, float, int, int, int)}. */ public int getFrameCount(); /** @return the current enqueued frames count since {@link #init(AudioFormat, float, int, int, int)}. */ public int getEnqueuedFrameCount(); - - /** + + /** * Returns the current number of frames queued for playing. *

      * {@link #init(AudioFormat, float, int, int, int)} must be called first. *

      */ public int getQueuedFrameCount(); - - /** + + /** * Returns the current number of bytes queued for playing. *

      * {@link #init(AudioFormat, float, int, int, int)} must be called first. @@ -392,28 +392,28 @@ public interface AudioSink { */ public int getQueuedByteCount(); - /** + /** * Returns the current queued frame time in milliseconds for playing. *

      * {@link #init(AudioFormat, float, int, int, int)} must be called first. *

      */ public int getQueuedTime(); - - /** + + /** * Return the current audio presentation timestamp (PTS) in milliseconds. */ public int getPTS(); - - /** + + /** * Returns the current number of frames in the sink available for writing. *

      * {@link #init(AudioFormat, float, int, int, int)} must be called first. *

      */ public int getFreeFrameCount(); - - /** + + /** * Enqueue the remaining bytes of the given {@link AudioDataFrame}'s direct ByteBuffer to this sink. *

      * The data must comply with the chosen {@link AudioFormat} as returned by {@link #initSink(AudioFormat)}. @@ -426,8 +426,8 @@ public interface AudioSink { * to reuse specialized {@link AudioFrame} instances. */ public AudioFrame enqueueData(AudioDataFrame audioDataFrame); - - /** + + /** * Enqueue byteCount bytes of the remaining bytes of the given NIO {@link ByteBuffer} to this sink. *

      * The data must comply with the chosen {@link AudioFormat} as returned by {@link #initSink(AudioFormat)}. diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java index a6a14f7dd..2cfd40df7 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -58,7 +58,7 @@ public class AudioSinkFactory { if( audioSink.isInitialized() ) { return audioSink; } - } catch (Throwable t) { + } catch (Throwable t) { if(AudioSink.DEBUG) { System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); t.printStackTrace(); } } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 74036a3f7..db6f5fdee 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -49,9 +49,9 @@ import com.jogamp.opengl.util.TimeFrameI; * using the appropriate stream id's. *

      *

      - * Camera input can be selected using the {@link #CameraInputScheme} URI. + * Camera input can be selected using the {@link #CameraInputScheme} URI. *

      - * + * *
      StreamWorker Decoding Thread
      *

      * Most of the stream processing is performed on the decoding thread, a.k.a. StreamWorker: @@ -61,7 +61,7 @@ import com.jogamp.opengl.util.TimeFrameI; *

    • Caught exceptions on the decoding thread are delivered as {@link StreamException}s.
    • *
    * StreamWorker generates it's own {@link GLContext}, shared with the one passed to {@link #initGL(GL)}. - * The shared {@link GLContext} allows the decoding thread to push the video frame data directly into + * The shared {@link GLContext} allows the decoding thread to push the video frame data directly into * the designated {@link TextureFrame}, later returned via {@link #getNextTexture(GL)} and used by the user. *

    * StreamWorker Error Handling @@ -71,12 +71,12 @@ import com.jogamp.opengl.util.TimeFrameI; *

    *

    * An occurring {@link StreamException} triggers a {@link GLMediaEventListener#EVENT_CHANGE_ERR EVENT_CHANGE_ERR} event, - * which can be listened to via {@link GLMediaEventListener#attributesChanged(GLMediaPlayer, int, long)}. + * which can be listened to via {@link GLMediaEventListener#attributesChanged(GLMediaPlayer, int, long)}. *

    *

    - * An occurred {@link StreamException} can be read via {@link #getStreamException()}. + * An occurred {@link StreamException} can be read via {@link #getStreamException()}. *

    - * + * *

    *
    GLMediaPlayer Lifecycle
    *

    @@ -94,7 +94,7 @@ import com.jogamp.opengl.util.TimeFrameI; * {@link #destroy(GL)} ANY {@link State#Uninitialized Uninitialized} {@link GLMediaEventListener#EVENT_CHANGE_UNINIT EVENT_CHANGE_UNINIT} * *

    - * + * *
    Audio and video Stream IDs
    *

    * @@ -110,7 +110,7 @@ import com.jogamp.opengl.util.TimeFrameI; *
  • {@link jogamp.opengl.util.av.NullGLMediaPlayer}
  • *
  • {@link jogamp.opengl.util.av.impl.OMXGLMediaPlayer}
  • *
  • {@link jogamp.opengl.util.av.impl.FFMPEGMediaPlayer}
  • - *
  • {@link jogamp.opengl.android.av.AndroidGLMediaPlayerAPI14}
  • + *
  • {@link jogamp.opengl.android.av.AndroidGLMediaPlayerAPI14}
  • * *

    *

    @@ -127,7 +127,7 @@ import com.jogamp.opengl.util.TimeFrameI; * Timestamp type and value range has been chosen to suit embedded CPUs * and characteristics of audio and video streaming. See {@link TimeFrameI}. *

    - * + * *
    Audio and video synchronization
    *

    * The class follows a passive A/V synchronization pattern. @@ -158,7 +158,7 @@ import com.jogamp.opengl.util.TimeFrameI; *

  • Film: +22ms and -22ms. audio ahead video / audio after video.
  • * *

    - * + * *
    Test Streams
    *

    *

    @@ -185,16 +185,16 @@ import com.jogamp.opengl.util.TimeFrameI; public interface GLMediaPlayer extends TextureSequence { public static final boolean DEBUG = Debug.debug("GLMediaPlayer"); public static final boolean DEBUG_NATIVE = Debug.debug("GLMediaPlayer.Native"); - + /** Minimum texture count, value {@value}. */ public static final int TEXTURE_COUNT_MIN = 4; - + /** Constant {@value} for mute or not available. See Audio and video Stream IDs. */ public static final int STREAM_ID_NONE = -2; /** Constant {@value} for auto or unspecified. See Audio and video Stream IDs. */ public static final int STREAM_ID_AUTO = -1; - - /** + + /** * {@link URI#getScheme() URI scheme} name {@value} for camera input. E.g. camera:/0 * for the 1st camera device. *

    @@ -203,7 +203,7 @@ public interface GLMediaPlayer extends TextureSequence { *

    *

    * The ID is usually an integer value indexing the camera - * ranging from [0..max-number]. + * ranging from [0..max-number]. *

    *

    * The {@link URI#getRawQuery() URI query} is used to pass options to the camera @@ -220,7 +220,7 @@ public interface GLMediaPlayer extends TextureSequence { * w/ authority: [user-info@]host[:port] * Note: 'path' starts w/ fwd slash * - *

    + *

    */ public static final String CameraInputScheme = "camera"; /** Camera property {@value}, size as string, e.g. 1280x720, hd720. May not be supported on all platforms. See {@link #CameraInputScheme}. */ @@ -231,10 +231,10 @@ public interface GLMediaPlayer extends TextureSequence { public static final String CameraPropHeight = "height"; /** Camera property {@value}. See {@link #CameraInputScheme}. */ public static final String CameraPropRate = "rate"; - + /** Maximum video frame async of {@value} milliseconds. */ public static final int MAXIMUM_VIDEO_ASYNC = 22; - + /** * A StreamException encapsulates a caught exception in the decoder thread, a.k.a StreamWorker, * see See StreamWorker Error Handling. @@ -248,15 +248,15 @@ public interface GLMediaPlayer extends TextureSequence { super(message, cause); } } - + /** * {@inheritDoc} *

    * See {@link TexSeqEventListener} for semantics and usage. *

    - */ + */ public interface GLMediaEventListener extends TexSeqEventListener { - + /** State changed to {@link State#Initialized}. See Lifecycle.*/ static final int EVENT_CHANGE_INIT = 1<<0; /** State changed to {@link State#Uninitialized}. See Lifecycle.*/ @@ -269,7 +269,7 @@ public interface GLMediaPlayer extends TextureSequence { static final int EVENT_CHANGE_EOS = 1<<4; /** An error occurred, e.g. during off-thread initialization. See {@link StreamException} and Lifecycle. */ static final int EVENT_CHANGE_ERR = 1<<5; - + /** Stream video id change. */ static final int EVENT_CHANGE_VID = 1<<16; /** Stream audio id change. */ @@ -284,55 +284,55 @@ public interface GLMediaPlayer extends TextureSequence { static final int EVENT_CHANGE_LENGTH = 1<<21; /** Stream codec change. */ static final int EVENT_CHANGE_CODEC = 1<<22; - + /** - * @param mp the event source + * @param mp the event source * @param event_mask the changes attributes - * @param when system time in msec. + * @param when system time in msec. */ - public void attributesChanged(GLMediaPlayer mp, int event_mask, long when); + public void attributesChanged(GLMediaPlayer mp, int event_mask, long when); } - + /** * See Lifecycle. */ public enum State { /** Uninitialized player, no resources shall be hold. */ Uninitialized(0), - /** Stream has been initialized, user may play or call {@link #initGL(GL)}. */ - Initialized(1), + /** Stream has been initialized, user may play or call {@link #initGL(GL)}. */ + Initialized(1), /** Stream is playing. */ Playing(2), /** Stream is pausing. */ Paused(3); - + public final int id; State(int id){ this.id = id; } } - + public int getTextureCount(); - + /** Returns the texture target used by implementation. */ public int getTextureTarget(); /** Sets the texture unit. Defaults to 0. */ public void setTextureUnit(int u); - + /** Sets the texture min-mag filter, defaults to {@link GL#GL_NEAREST}. */ public void setTextureMinMagFilter(int[] minMagFilter); /** Sets the texture min-mag filter, defaults to {@link GL#GL_CLAMP_TO_EDGE}. */ public void setTextureWrapST(int[] wrapST); - - /** + + /** * Issues asynchronous stream initialization. *

    * Lifecycle: {@link State#Uninitialized} -> {@link State#Initialized}1 or {@link State#Uninitialized} *

    *

    - * {@link State#Initialized} is reached asynchronous, + * {@link State#Initialized} is reached asynchronous, * i.e. user gets notified via {@link GLMediaEventListener#attributesChanged(GLMediaPlayer, int, long) attributesChanges(..)}. *

    *

    @@ -344,7 +344,7 @@ public interface GLMediaPlayer extends TextureSequence { *

    *

    * Muted video can be achieved by passing {@link #STREAM_ID_NONE} to vid, - * in which case textureCount is ignored as well as the passed GL object of the subsequent {@link #initGL(GL)} call. + * in which case textureCount is ignored as well as the passed GL object of the subsequent {@link #initGL(GL)} call. *

    * @param streamLoc the stream location * @param vid video stream id, see audio and video Stream IDs @@ -352,41 +352,41 @@ public interface GLMediaPlayer extends TextureSequence { * @param textureCount desired number of buffered textures to be decoded off-thread, will be validated by implementation. * The minimum value is {@link #TEXTURE_COUNT_MIN}. * Ignored if video is muted. - * @throws IllegalStateException if not invoked in {@link State#Uninitialized} + * @throws IllegalStateException if not invoked in {@link State#Uninitialized} * @throws IllegalArgumentException if arguments are invalid */ public void initStream(URI streamLoc, int vid, int aid, int textureCount) throws IllegalStateException, IllegalArgumentException; - + /** * Returns the {@link StreamException} caught in the decoder thread, or null. * @see GLMediaEventListener#EVENT_CHANGE_ERR * @see StreamException */ public StreamException getStreamException(); - - /** + + /** * Initializes OpenGL related resources. *

    * Lifecycle: {@link State#Initialized} -> {@link State#Paused} or {@link State#Initialized} *

    * Argument gl is ignored if video is muted, see {@link #initStream(URI, int, int, int)}. - * + * * @param gl current GL object. Maybe null, for audio only. - * @throws IllegalStateException if not invoked in {@link State#Initialized}. + * @throws IllegalStateException if not invoked in {@link State#Initialized}. * @throws StreamException forwarded from the off-thread stream initialization * @throws GLException in case of difficulties to initialize the GL resources */ public void initGL(GL gl) throws IllegalStateException, StreamException, GLException; - - /** + + /** * If implementation uses a {@link AudioSink}, it's instance will be returned. - *

    - * The {@link AudioSink} instance is available after {@link #initStream(URI, int, int, int)}, + *

    + * The {@link AudioSink} instance is available after {@link #initStream(URI, int, int, int)}, * if used by implementation. - *

    + *

    */ public AudioSink getAudioSink(); - + /** * Releases the GL and stream resources. *

    @@ -399,11 +399,11 @@ public interface GLMediaPlayer extends TextureSequence { * Sets the playback speed. *

    * To simplify test, play speed is normalized, i.e. - *

      - *
    • 1.0f: if Math.abs(1.0f - rate) < 0.01f
    • + *
        + *
      • 1.0f: if Math.abs(1.0f - rate) < 0.01f
      • *
      *

      - * @return true if successful, otherwise false, i.e. due to unsupported value range of implementation. + * @return true if successful, otherwise false, i.e. due to unsupported value range of implementation. */ public boolean setPlaySpeed(float rate); @@ -414,18 +414,18 @@ public interface GLMediaPlayer extends TextureSequence { * Sets the audio volume, [0f..1f]. *

      * To simplify test, volume is normalized, i.e. - *

        - *
      • 0.0f: if Math.abs(v) < 0.01f
      • - *
      • 1.0f: if Math.abs(1.0f - v) < 0.01f
      • + *
          + *
        • 0.0f: if Math.abs(v) < 0.01f
        • + *
        • 1.0f: if Math.abs(1.0f - v) < 0.01f
        • *
        *

        - * @return true if successful, otherwise false, i.e. due to unsupported value range of implementation. + * @return true if successful, otherwise false, i.e. due to unsupported value range of implementation. */ public boolean setAudioVolume(float v); - + /** Returns the audio volume. */ public float getAudioVolume(); - + /** * Starts or resumes the StreamWorker decoding thread. *

        @@ -441,9 +441,9 @@ public interface GLMediaPlayer extends TextureSequence { *

        *

        * If a new frame is desired after the next {@link #play()} call, - * e.g. to make a snapshot of a camera input stream, + * e.g. to make a snapshot of a camera input stream, * flush shall be set to true. - *

        + *

        * @param flush if true flushes the video and audio buffers, otherwise keep them intact. */ public State pause(boolean flush); @@ -454,10 +454,10 @@ public interface GLMediaPlayer extends TextureSequence { *

        * Allowed in state {@link State#Playing} and {@link State#Paused}, otherwise ignored, * see Lifecycle. - *

        - * - * @param msec absolute desired time position in milliseconds - * @return time current position in milliseconds, after seeking to the desired position + *

        + * + * @param msec absolute desired time position in milliseconds + * @return time current position in milliseconds, after seeking to the desired position **/ public int seek(int msec); @@ -466,39 +466,39 @@ public interface GLMediaPlayer extends TextureSequence { * @return the current state, either {@link State#Uninitialized}, {@link State#Initialized}, {@link State#Playing} or {@link State#Paused} */ public State getState(); - + /** * Return the video stream id, see audio and video Stream IDs. */ public int getVID(); - + /** * Return the audio stream id, see audio and video Stream IDs. */ public int getAID(); - + /** - * @return the current decoded frame count since {@link #play()} and {@link #seek(int)} + * @return the current decoded frame count since {@link #play()} and {@link #seek(int)} * as increased by {@link #getNextTexture(GL)} or the decoding thread. */ public int getDecodedFrameCount(); - + /** - * @return the current presented frame count since {@link #play()} and {@link #seek(int)} + * @return the current presented frame count since {@link #play()} and {@link #seek(int)} * as increased by {@link #getNextTexture(GL)} for new frames. */ public int getPresentedFrameCount(); - + /** - * @return current video presentation timestamp (PTS) in milliseconds of {@link #getLastTexture()} + * @return current video presentation timestamp (PTS) in milliseconds of {@link #getLastTexture()} **/ public int getVideoPTS(); - + /** - * @return current audio presentation timestamp (PTS) in milliseconds. + * @return current audio presentation timestamp (PTS) in milliseconds. **/ public int getAudioPTS(); - + /** * {@inheritDoc} *

        @@ -511,7 +511,7 @@ public interface GLMediaPlayer extends TextureSequence { /** * {@inheritDoc} - * + * *

        * In case the current state is not {@link State#Playing}, {@link #getLastTexture()} is returned. *

        @@ -519,25 +519,25 @@ public interface GLMediaPlayer extends TextureSequence { * See audio and video synchronization. *

        * @throws IllegalStateException if not invoked in {@link State#Paused} or {@link State#Playing} - * + * * @see #addEventListener(GLMediaEventListener) * @see GLMediaEventListener#newFrameAvailable(GLMediaPlayer, TextureFrame, long) */ @Override public TextureSequence.TextureFrame getNextTexture(GL gl) throws IllegalStateException; - + /** Return the stream location, as set by {@link #initStream(URI, int, int, int)}. */ public URI getURI(); /** * Warning: Optional information, may not be supported by implementation. - * @return the code of the video stream, if available + * @return the code of the video stream, if available */ public String getVideoCodec(); /** * Warning: Optional information, may not be supported by implementation. - * @return the code of the audio stream, if available + * @return the code of the audio stream, if available */ public String getAudioCodec(); @@ -557,25 +557,25 @@ public interface GLMediaPlayer extends TextureSequence { * @return total duration of stream in msec. */ public int getDuration(); - + /** * Warning: Optional information, may not be supported by implementation. - * @return the overall bitrate of the stream. + * @return the overall bitrate of the stream. */ public long getStreamBitrate(); /** * Warning: Optional information, may not be supported by implementation. - * @return video bitrate + * @return video bitrate */ public int getVideoBitrate(); - + /** * Warning: Optional information, may not be supported by implementation. - * @return the audio bitrate + * @return the audio bitrate */ public int getAudioBitrate(); - + /** * Warning: Optional information, may not be supported by implementation. * @return the framerate of the video @@ -583,10 +583,10 @@ public interface GLMediaPlayer extends TextureSequence { public float getFramerate(); /** - * Returns true if the video frame is oriented in + * Returns true if the video frame is oriented in * OpenGL's coordinate system, origin at bottom left. *

        - * Otherwise returns false, i.e. + * Otherwise returns false, i.e. * video frame is oriented origin at top left. *

        *

        @@ -594,14 +594,14 @@ public interface GLMediaPlayer extends TextureSequence { * but user shall not rely on. *

        *

        - * false GL orientation leads to + * false GL orientation leads to * {@link Texture#getMustFlipVertically()} == true, * as reflected by all {@link TextureFrame}'s {@link Texture}s - * retrieved via {@link #getLastTexture()} or {@link #getNextTexture(GL)}. + * retrieved via {@link #getLastTexture()} or {@link #getNextTexture(GL)}. *

        */ public boolean isGLOriented(); - + /** Returns the width of the video. */ public int getWidth(); @@ -613,7 +613,7 @@ public interface GLMediaPlayer extends TextureSequence { /** Returns a string represantation of this player's performance values. */ public String getPerfString(); - + /** Adds a {@link GLMediaEventListener} to this player. */ public void addEventListener(GLMediaEventListener l); diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java index c7e1ab5e6..248e265f5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -36,7 +36,7 @@ public class GLMediaPlayerFactory { private static final String FFMPEGMediaPlayerClazzName = "jogamp.opengl.util.av.impl.FFMPEGMediaPlayer"; private static final String OMXGLMediaPlayerClazzName = "jogamp.opengl.util.av.impl.OMXGLMediaPlayer"; private static final String isAvailableMethodName = "isAvailable"; - + public static GLMediaPlayer createDefault() { final ClassLoader cl = GLMediaPlayerFactory.class.getClassLoader(); GLMediaPlayer sink = create(cl, OMXGLMediaPlayerClazzName); @@ -54,7 +54,7 @@ public class GLMediaPlayerFactory { public static GLMediaPlayer createNull() { return new NullGLMediaPlayer(); } - + public static GLMediaPlayer create(final ClassLoader cl, String implName) { try { if(((Boolean)ReflectionUtil.callStaticMethod(implName, isAvailableMethodName, null, null, cl)).booleanValue()) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java index 9d2ef6572..fb2bdbbcb 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -41,22 +41,22 @@ import javax.media.opengl.GL; import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.util.GLPixelBuffer; -/** - * AWT {@link GLPixelBuffer} backed by an {@link BufferedImage} of type +/** + * AWT {@link GLPixelBuffer} backed by an {@link BufferedImage} of type * {@link BufferedImage#TYPE_INT_ARGB} or {@link BufferedImage#TYPE_INT_RGB}. *

        * Implementation uses an array backed {@link IntBuffer}. *

        *

        - * {@link AWTGLPixelBuffer} can be produced via {@link AWTGLPixelBufferProvider}'s - * {@link AWTGLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocate(..)}. + * {@link AWTGLPixelBuffer} can be produced via {@link AWTGLPixelBufferProvider}'s + * {@link AWTGLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocate(..)}. *

        *

        * See {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)} for {@link #allowRowStride} details. *

        *

        * If using allowRowStride == true, user may needs to get the {@link #getAlignedImage(int, int) aligned image} - * since {@link #requiresNewBuffer(GL, int, int, int)} will allow different width in this case. + * since {@link #requiresNewBuffer(GL, int, int, int)} will allow different width in this case. *

        */ public class AWTGLPixelBuffer extends GLPixelBuffer { @@ -65,9 +65,9 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { /** The underlying {@link BufferedImage}. */ public final BufferedImage image; - + /** - * + * * @param pixelAttributes the desired {@link GLPixelAttributes} * @param width in pixels * @param height in pixels @@ -76,26 +76,26 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { * @param image the AWT image * @param buffer the backing array * @param allowRowStride If true, allow row-stride, otherwise not. See {@link #requiresNewBuffer(GL, int, int, int)}. - * If true, user shall decide whether to use a {@link #getAlignedImage(int, int) width-aligned image}. + * If true, user shall decide whether to use a {@link #getAlignedImage(int, int) width-aligned image}. */ - public AWTGLPixelBuffer(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, BufferedImage image, + public AWTGLPixelBuffer(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, BufferedImage image, Buffer buffer, boolean allowRowStride) { super(pixelAttributes, width, height, depth, pack, buffer, allowRowStride); this.image = image; } - + @Override public void dispose() { image.flush(); super.dispose(); } - + /** * Returns a width- and height-aligned image representation sharing data w/ {@link #image}. * @param width * @param height * @return - * @throws IllegalArgumentException if requested size exceeds image size + * @throws IllegalArgumentException if requested size exceeds image size */ public BufferedImage getAlignedImage(int width, int height) throws IllegalArgumentException { if( width * height > image.getWidth() * image.getHeight() ) { @@ -111,12 +111,12 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { final WritableRaster raster = image.getRaster(); final DataBuffer dataBuffer = raster.getDataBuffer(); final SinglePixelPackedSampleModel sppsm0 = (SinglePixelPackedSampleModel) raster.getSampleModel(); - final SinglePixelPackedSampleModel sppsm1 = new SinglePixelPackedSampleModel(dataBuffer.getDataType(), + final SinglePixelPackedSampleModel sppsm1 = new SinglePixelPackedSampleModel(dataBuffer.getDataType(), width, height, width /* scanLineStride */, sppsm0.getBitMasks()); final WritableRaster raster1 = WritableRaster.createWritableRaster(sppsm1, dataBuffer, null); return new BufferedImage (cm, raster1, cm.isAlphaPremultiplied(), null); } - + public StringBuilder toString(StringBuilder sb) { sb = super.toString(sb); sb.append(", allowRowStride ").append(allowRowStride).append(", image [").append(image.getWidth()).append("x").append(image.getHeight()).append(", ").append(image.toString()).append("]"); @@ -125,29 +125,29 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { public String toString() { return "AWTGLPixelBuffer["+toString(null).toString()+"]"; } - + /** * Provider for {@link AWTGLPixelBuffer} instances. */ public static class AWTGLPixelBufferProvider implements GLPixelBufferProvider { private final boolean allowRowStride; - + /** - * @param allowRowStride If true, allow row-stride, otherwise not. + * @param allowRowStride If true, allow row-stride, otherwise not. * See {@link #getAllowRowStride()} and {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. - * If true, user shall decide whether to use a {@link AWTGLPixelBuffer#getAlignedImage(int, int) width-aligned image}. + * If true, user shall decide whether to use a {@link AWTGLPixelBuffer#getAlignedImage(int, int) width-aligned image}. */ public AWTGLPixelBufferProvider(boolean allowRowStride) { - this.allowRowStride = allowRowStride; + this.allowRowStride = allowRowStride; } @Override public boolean getAllowRowStride() { return allowRowStride; } - + @Override public GLPixelAttributes getAttributes(GL gl, int componentCount) { return 4 == componentCount ? awtPixelAttributesIntRGBA4 : awtPixelAttributesIntRGB3; } - + /** * {@inheritDoc} *

        @@ -162,28 +162,28 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { return new AWTGLPixelBuffer(pixelAttributes, width, height, depth, pack, image, ibuffer, allowRowStride); } } - + /** * Provider for singleton {@link AWTGLPixelBuffer} instances. *

        * Provider instance holds the last {@link AWTGLPixelBuffer} instance * {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated}. - * A new {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocation} + * A new {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocation} * will return same instance, if a new buffer is not {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int) required}. - * The latter is true if size are compatible, hence allowRowStride should be enabled, if possible. + * The latter is true if size are compatible, hence allowRowStride should be enabled, if possible. *

        - */ + */ public static class SingleAWTGLPixelBufferProvider extends AWTGLPixelBufferProvider implements SingletonGLPixelBufferProvider { private AWTGLPixelBuffer singleRGBA4 = null; private AWTGLPixelBuffer singleRGB3 = null; - + /** * @param allowRowStride If true, allow row-stride, otherwise not. See {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. */ public SingleAWTGLPixelBufferProvider(boolean allowRowStride) { super(allowRowStride); } - + /** * {@inheritDoc} *

        @@ -194,7 +194,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { public AWTGLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { if( 4 == pixelAttributes.componentCount ) { if( null == singleRGBA4 || singleRGBA4.requiresNewBuffer(gl, width, height, minByteSize) ) { - singleRGBA4 = allocateImpl(pixelAttributes, width, height, depth, pack, minByteSize); + singleRGBA4 = allocateImpl(pixelAttributes, width, height, depth, pack, minByteSize); } return singleRGBA4; } else { @@ -204,33 +204,33 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { return singleRGB3; } } - + private AWTGLPixelBuffer allocateImpl(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { final BufferedImage image = new BufferedImage(width, height, 4 == pixelAttributes.componentCount ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB); final int[] readBackIntBuffer = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); final Buffer ibuffer = IntBuffer.wrap( readBackIntBuffer ); return new AWTGLPixelBuffer(pixelAttributes, width, height, depth, pack, image, ibuffer, getAllowRowStride()); } - - /** Return the last {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated} {@link AWTGLPixelBuffer} w/ {@link GLPixelAttributes#componentCount}. */ + + /** Return the last {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated} {@link AWTGLPixelBuffer} w/ {@link GLPixelAttributes#componentCount}. */ public AWTGLPixelBuffer getSingleBuffer(GLPixelAttributes pixelAttributes) { return 4 == pixelAttributes.componentCount ? singleRGBA4 : singleRGB3; } - - /** + + /** * Initializes the single {@link AWTGLPixelBuffer} w/ a given size, if not yet {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated}. * @return the newly initialized single {@link AWTGLPixelBuffer}, or null if already allocated. */ public AWTGLPixelBuffer initSingleton(int componentCount, int width, int height, int depth, boolean pack) { if( 4 == componentCount ) { if( null != singleRGBA4 ) { - return null; + return null; } singleRGBA4 = allocateImpl(AWTGLPixelBuffer.awtPixelAttributesIntRGBA4, width, height, depth, pack, 0); return singleRGBA4; } else { if( null != singleRGB3 ) { - return null; + return null; } singleRGB3 = allocateImpl(AWTGLPixelBuffer.awtPixelAttributesIntRGB3, width, height, depth, pack, 0); return singleRGB3; diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java index e85f04092..f5d31a132 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -42,7 +42,7 @@ import com.jogamp.opengl.util.GLReadBufferUtil; public class AWTGLReadBufferUtil extends GLReadBufferUtil { /** * {@inheritDoc} - * + * * @param alpha */ public AWTGLReadBufferUtil(GLProfile glp, boolean alpha) { @@ -50,7 +50,7 @@ public class AWTGLReadBufferUtil extends GLReadBufferUtil { } public AWTGLPixelBuffer getAWTGLPixelBuffer() { return (AWTGLPixelBuffer)this.getPixelBuffer(); } - + public BufferedImage readPixelsToBufferedImage(GL gl, boolean awtOrientation) { return readPixelsToBufferedImage(gl, 0, 0, 0, 0, awtOrientation); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/ImageUtil.java b/src/jogl/classes/com/jogamp/opengl/util/awt/ImageUtil.java index a3139b16a..df3cc4a39 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/ImageUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/ImageUtil.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -54,7 +54,7 @@ public class ImageUtil { WritableRaster raster = image.getRaster(); Object scanline1 = null; Object scanline2 = null; - + for (int i = 0; i < image.getHeight() / 2; i++) { scanline1 = raster.getDataElements(0, i, image.getWidth(), 1, scanline1); scanline2 = raster.getDataElements(0, image.getHeight() - i - 1, image.getWidth(), 1, scanline2); @@ -97,21 +97,21 @@ public class ImageUtil { if (thumbWidth > image.getWidth()) { throw new IllegalArgumentException("Thumbnail width must be greater than image width"); } - + if (thumbWidth == image.getWidth()) { return image; } - + float ratio = (float) image.getWidth() / (float) image.getHeight(); int width = image.getWidth(); BufferedImage thumb = image; - + do { width /= 2; if (width < thumbWidth) { width = thumbWidth; } - + BufferedImage temp = createCompatibleImage(width, (int) (width / ratio)); Graphics2D g2 = temp.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, @@ -120,7 +120,7 @@ public class ImageUtil { g2.dispose(); thumb = temp; } while (width != thumbWidth); - + return thumb; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java b/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java index 73d694cd9..931f59869 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/Overlay.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2006 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java b/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java index 2ffc27260..f686b672a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/Screenshot.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2013 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -56,18 +56,18 @@ import com.jogamp.opengl.GLExtensions; import com.jogamp.opengl.util.GLPixelStorageModes; import com.jogamp.opengl.util.TGAWriter; -/** +/** * Utilities for taking screenshots of OpenGL applications. - * @deprecated Please consider using {@link com.jogamp.opengl.util.GLReadBufferUtil}, - * which is AWT independent and does not require a CPU based vertical image flip + * @deprecated Please consider using {@link com.jogamp.opengl.util.GLReadBufferUtil}, + * which is AWT independent and does not require a CPU based vertical image flip * in case drawable {@link GLDrawable#isGLOriented() is in OpenGL orientation}. - * Further more you may use {@link AWTGLReadBufferUtil} to read out + * Further more you may use {@link AWTGLReadBufferUtil} to read out * the framebuffer into a BufferedImage for further AWT processing. */ public class Screenshot { private Screenshot() {} - /** + /** * Takes a fast screenshot of the current OpenGL drawable to a Targa * file. Requires the OpenGL context for the desired drawable to be * current. Takes the screenshot from the last assigned read buffer, @@ -94,7 +94,7 @@ public class Screenshot { writeToTargaFile(file, width, height, false); } - /** + /** * Takes a fast screenshot of the current OpenGL drawable to a Targa * file. Requires the OpenGL context for the desired drawable to be * current. Takes the screenshot from the last assigned read buffer, @@ -122,7 +122,7 @@ public class Screenshot { writeToTargaFile(file, 0, 0, width, height, alpha); } - /** + /** * Takes a fast screenshot of the current OpenGL drawable to a Targa * file. Requires the OpenGL context for the desired drawable to be * current. Takes the screenshot from the last assigned read buffer, @@ -410,5 +410,5 @@ public class Screenshot { if (!gl.isExtensionAvailable(GLExtensions.EXT_abgr)) { throw new IllegalArgumentException("Saving alpha channel requires GL_EXT_abgr"); } - } + } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java index c67141525..6e504c089 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java @@ -129,7 +129,7 @@ import jogamp.opengl.Debug; */ public class TextRenderer { private static final boolean DEBUG; - + static { Debug.initSingleton(); DEBUG = Debug.isPropertyDefined("jogl.debug.TextRenderer", true); @@ -200,10 +200,10 @@ public class TextRenderer { // Debugging purposes only private boolean debugged; Pipelined_QuadRenderer mPipelinedQuadRenderer; - + //emzic: added boolean flag private boolean useVertexArrays = true; - + //emzic: added boolean flag private boolean isExtensionAvailable_GL_VERSION_1_5; private boolean checkFor_isExtensionAvailable_GL_VERSION_1_5; @@ -707,7 +707,7 @@ public class TextRenderer { /** * emzic: here the call to glBindBuffer crashes on certain graphicscard/driver combinations * this is why the ugly try-catch block has been added, which falls back to the old textrenderer - * + * * @param ortho * @throws GLException */ @@ -891,7 +891,7 @@ public class TextRenderer { data.markUsed(); Rectangle2D origRect = data.origRect(); - + // Align the leftmost point of the baseline to the (x, y, z) coordinate requested renderer.draw3DRect(x - (scaleFactor * data.origOriginX()), y - (scaleFactor * ((float) origRect.getHeight() - data.origOriginY())), z, @@ -1715,7 +1715,7 @@ public class TextRenderer { return glyph; } } - + private static class CharacterCache { private CharacterCache() { } diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextureRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextureRenderer.java index 922fc69c1..26e1eb041 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextureRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextureRenderer.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -407,7 +407,7 @@ public class TextureRenderer { this.a = a; gl.glColor4f(this.r, this.g, this.b, this.a); - } + } private float[] compArray; /** Changes the current color of this TextureRenderer to the @@ -437,7 +437,7 @@ public class TextureRenderer { @param screenx the on-screen x coordinate at which to draw the rectangle @param screeny the on-screen y coordinate (relative to lower left) at which to draw the rectangle - + @throws GLException If an OpenGL context is not current when this method is called */ public void drawOrthoRect(int screenx, int screeny) throws GLException { @@ -459,7 +459,7 @@ public class TextureRenderer { rectangle to draw @param width the width of the rectangle to draw @param height the height of the rectangle to draw - + @throws GLException If an OpenGL context is not current when this method is called */ public void drawOrthoRect(int screenx, int screeny, @@ -490,7 +490,7 @@ public class TextureRenderer { @param height the height in texels of the rectangle to draw @param scaleFactor the scale factor to apply (multiplicatively) to the size of the drawn rectangle - + @throws GLException If an OpenGL context is not current when this method is called */ public void draw3DRect(float x, float y, float z, @@ -518,7 +518,7 @@ public class TextureRenderer { OpenGL texture to the screen, if the application intends to draw them as a flat overlay on to the screen. Must be used if {@link #beginOrthoRendering} is used to set up the rendering stage for - this overlay. + this overlay. @throws GLException If an OpenGL context is not current when this method is called */ @@ -552,7 +552,7 @@ public class TextureRenderer { private void beginRendering(boolean ortho, int width, int height, boolean disableDepthTestForOrtho) { GL2 gl = GLContext.getCurrentGL().getGL2(); - int attribBits = + int attribBits = GL2.GL_ENABLE_BIT | GL2.GL_TEXTURE_BIT | GL2.GL_COLOR_BUFFER_BIT | (ortho ? (GL2.GL_DEPTH_BUFFER_BIT | GL2.GL_TRANSFORM_BIT) : 0); gl.glPushAttrib(attribBits); @@ -622,7 +622,7 @@ public class TextureRenderer { // Infer the internal format if not an intensity texture int internalFormat = (intensity ? GL2.GL_INTENSITY : 0); - int imageType = + int imageType = (intensity ? BufferedImage.TYPE_BYTE_GRAY : (alpha ? BufferedImage.TYPE_INT_ARGB_PRE : BufferedImage.TYPE_INT_RGB)); image = new BufferedImage(width, height, imageType); diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapCharRec.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapCharRec.java index 34685e1b2..e8df6aaec 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapCharRec.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapCharRec.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -41,8 +41,8 @@ package com.jogamp.opengl.util.gl2; /* Copyright (c) Mark J. Kilgard, 1994, 1998. */ -/* This program is freely distributable without licensing fees - and is provided without guarantee or warrantee expressed or +/* This program is freely distributable without licensing fees + and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. */ class BitmapCharRec { diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapFontRec.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapFontRec.java index 18f7d3b28..d4ee12b32 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapFontRec.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/BitmapFontRec.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -41,8 +41,8 @@ package com.jogamp.opengl.util.gl2; /* Copyright (c) Mark J. Kilgard, 1994, 1998. */ -/* This program is freely distributable without licensing fees - and is provided without guarantee or warrantee expressed or +/* This program is freely distributable without licensing fees + and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. */ class BitmapFontRec { diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/CoordRec.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/CoordRec.java index 9ad95ec03..5e26e0d14 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/CoordRec.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/CoordRec.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -41,8 +41,8 @@ package com.jogamp.opengl.util.gl2; /* Copyright (c) Mark J. Kilgard, 1994, 1998. */ -/* This program is freely distributable without licensing fees - and is provided without guarantee or warrantee expressed or +/* This program is freely distributable without licensing fees + and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. */ class CoordRec { diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUT.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUT.java index 010ce6699..42529f3f1 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUT.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUT.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -163,7 +163,7 @@ public class GLUT { public void glutSolidCylinder(double radius, double height, int slices, int stacks) { GL2 gl = GLUgl2.getCurrentGL2(); - + // Prepare table of points for drawing end caps double [] x = new double[slices]; double [] y = new double[slices]; @@ -174,7 +174,7 @@ public class GLUT { x[i] = Math.cos(angle) * radius; y[i] = Math.sin(angle) * radius; } - + // Draw bottom cap gl.glBegin(GL2.GL_TRIANGLE_FAN); gl.glNormal3d(0,0,-1); @@ -184,7 +184,7 @@ public class GLUT { } gl.glVertex3d(x[0], y[0], 0); gl.glEnd(); - + // Draw top cap gl.glBegin(GL2.GL_TRIANGLE_FAN); gl.glNormal3d(0,0,1); @@ -194,7 +194,7 @@ public class GLUT { } gl.glVertex3d(x[0], y[0], height); gl.glEnd(); - + // Draw walls quadObjInit(glu); glu.gluQuadricDrawStyle(quadObj, GLU.GLU_FILL); @@ -262,7 +262,7 @@ public class GLUT { /** * Renders the teapot as a solid shape of the specified size. The teapot is * created in a way that replicates the C GLUT implementation. - * + * * @param scale * the factor by which to scale the teapot */ @@ -278,7 +278,7 @@ public class GLUT { * instead of the y=-1 plane). Both surface normals and texture coordinates * for the teapot are generated. The teapot is generated with OpenGL * evaluators. - * + * * @param scale * the factor by which to scale the teapot * @param cStyle @@ -292,14 +292,14 @@ public class GLUT { /** * Renders the teapot as a wireframe shape of the specified size. The teapot * is created in a way that replicates the C GLUT implementation. - * + * * @param scale * the factor by which to scale the teapot */ public void glutWireTeapot(double scale) { glutWireTeapot(scale, true); } - + /** * Renders the teapot as a wireframe shape of the specified size. The teapot * can either be created in a way that is backward-compatible with the @@ -308,7 +308,7 @@ public class GLUT { * plane, instead of the y=-1 plane). Both surface normals and texture * coordinates for the teapot are generated. The teapot is generated with * OpenGL evaluators. - * + * * @param scale * the factor by which to scale the teapot * @param cStyle @@ -356,7 +356,7 @@ public class GLUT { int[] skiprows = new int[1]; int[] skippixels = new int[1]; int[] alignment = new int[1]; - beginBitmap(gl, + beginBitmap(gl, swapbytes, lsbfirst, rowlength, @@ -367,7 +367,7 @@ public class GLUT { for (int i = 0; i < len; i++) { bitmapCharacterImpl(gl, font, string.charAt(i)); } - endBitmap(gl, + endBitmap(gl, swapbytes, lsbfirst, rowlength, @@ -502,7 +502,7 @@ public class GLUT { gl.glEnd( ); } } - + /** This function draws a solid-shaded dodecahedron whose facets are rhombic and @@ -522,7 +522,7 @@ public class GLUT { } gl.glEnd( ); } - + //---------------------------------------------------------------------- // Internals only below this point // @@ -879,7 +879,7 @@ public class GLUT { } /* rhombic dodecahedron data: */ - + private static final double rdod_r[][] = { { 0.0, 0.0, 1.0 }, @@ -897,7 +897,7 @@ public class GLUT { { 0.000000000000, -0.707106781187, -0.5 }, { 0.0, 0.0, -1.0 } }; - + private static final int rdod_v[][] = { { 0, 1, 5, 2 }, @@ -913,7 +913,7 @@ public class GLUT { { 7, 11, 13, 12 }, { 8, 12, 13, 9 } }; - + private static final double rdod_n[][] = { { 0.353553390594, 0.353553390594, 0.5 }, @@ -929,7 +929,7 @@ public class GLUT { { -0.353553390594, -0.353553390594, -0.5 }, { 0.353553390594, -0.353553390594, -0.5 } }; - + /* tetrahedron data: */ private static final float T = 1.73205080756887729f; @@ -1124,7 +1124,7 @@ public class GLUT { float[] r = new float[4*4*3]; float[] s = new float[4*4*3]; int i, j, k, l; - + gl.glPushAttrib(GL2.GL_ENABLE_BIT | GL2.GL_EVAL_BIT | GL2.GL_POLYGON_BIT); gl.glEnable(GL2.GL_AUTO_NORMAL); gl.glEnable(GL2.GL_NORMALIZE); @@ -1183,7 +1183,7 @@ public class GLUT { gl.glPopMatrix(); gl.glPopAttrib(); } - + private static void evaluateTeapotMesh(GL2 gl, int grid, int type, diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmap8x13.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmap8x13.java index 07ded652a..c24483777 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmap8x13.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmap8x13.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmap9x15.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmap9x15.java index 5d357f3f7..62af3b631 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmap9x15.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmap9x15.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapHelvetica10.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapHelvetica10.java index b9c7e6e50..5f06d697e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapHelvetica10.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapHelvetica10.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapHelvetica12.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapHelvetica12.java index bc86f6216..8326d6461 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapHelvetica12.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapHelvetica12.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapHelvetica18.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapHelvetica18.java index 1b2e69ba4..cb11f6bec 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapHelvetica18.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapHelvetica18.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapTimesRoman10.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapTimesRoman10.java index f753b56f7..17cbd0796 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapTimesRoman10.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapTimesRoman10.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapTimesRoman24.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapTimesRoman24.java index 073e6e673..9cc2bdc3a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapTimesRoman24.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTBitmapTimesRoman24.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeMonoRoman.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeMonoRoman.java index b8296924e..3587ca992 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeMonoRoman.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeMonoRoman.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeRoman.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeRoman.java index 94fa1c4fd..cf51ddd3c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeRoman.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/GLUTStrokeRoman.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeCharRec.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeCharRec.java index af3d538ae..515212f0e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeCharRec.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeCharRec.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -41,8 +41,8 @@ package com.jogamp.opengl.util.gl2; /* Copyright (c) Mark J. Kilgard, 1994, 1998. */ -/* This program is freely distributable without licensing fees - and is provided without guarantee or warrantee expressed or +/* This program is freely distributable without licensing fees + and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. */ class StrokeCharRec { diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeFontRec.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeFontRec.java index d3195f24d..5335c8523 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeFontRec.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeFontRec.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -41,8 +41,8 @@ package com.jogamp.opengl.util.gl2; /* Copyright (c) Mark J. Kilgard, 1994, 1998. */ -/* This program is freely distributable without licensing fees - and is provided without guarantee or warrantee expressed or +/* This program is freely distributable without licensing fees + and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. */ class StrokeFontRec { diff --git a/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeRec.java b/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeRec.java index 8796e8b08..b0c91c696 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeRec.java +++ b/src/jogl/classes/com/jogamp/opengl/util/gl2/StrokeRec.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -41,14 +41,14 @@ package com.jogamp.opengl.util.gl2; /* Copyright (c) Mark J. Kilgard, 1994, 1998. */ -/* This program is freely distributable without licensing fees - and is provided without guarantee or warrantee expressed or +/* This program is freely distributable without licensing fees + and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. */ class StrokeRec { public int num_coords; public CoordRec[] coord; - + public StrokeRec(int num_coords, CoordRec[] coord) { this.num_coords = num_coords; diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index edc3d2677..68c1d0fec 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -62,7 +62,7 @@ import com.jogamp.common.util.VersionNumber; * A documented example of how to use this code is available * {@link #create(GL2ES2, int, Class, String, String, String, boolean) here} and * {@link #create(GL2ES2, int, int, Class, String, String[], String, String) here}. - *

        + *

        */ public class ShaderCode { public static final boolean DEBUG = Debug.debug("GLSLCode"); @@ -70,22 +70,22 @@ public class ShaderCode { /** Unique resource suffix for {@link GL2ES2#GL_VERTEX_SHADER} in source code: vp */ public static final String SUFFIX_VERTEX_SOURCE = "vp" ; - + /** Unique resource suffix for {@link GL2ES2#GL_VERTEX_SHADER} in binary: bvp */ public static final String SUFFIX_VERTEX_BINARY = "bvp" ; - + /** Unique resource suffix for {@link GL3#GL_GEOMETRY_SHADER} in source code: gp */ public static final String SUFFIX_GEOMETRY_SOURCE = "gp" ; - + /** Unique resource suffix for {@link GL3#GL_GEOMETRY_SHADER} in binary: bgp */ public static final String SUFFIX_GEOMETRY_BINARY = "bgp" ; - + /** Unique resource suffix for {@link GL2ES2#GL_FRAGMENT_SHADER} in source code: fp */ public static final String SUFFIX_FRAGMENT_SOURCE = "fp" ; - + /** Unique resource suffix for {@link GL2ES2#GL_FRAGMENT_SHADER} in binary: bfp */ public static final String SUFFIX_FRAGMENT_BINARY = "bfp" ; - + /** Unique relative path for binary shader resources for {@link GLES2#GL_NVIDIA_PLATFORM_BINARY_NV NVIDIA}: nvidia */ public static final String SUB_PATH_NVIDIA = "nvidia" ; @@ -94,7 +94,7 @@ public class ShaderCode { * @param count number of shaders * @param source CharSequence array containing the shader sources, organized as source[count][strings-per-shader]. * May be either an immutable String - or mutable StringBuilder array. - * + * * @throws IllegalArgumentException if count and source.length do not match */ public ShaderCode(int type, int count, CharSequence[][] source) { @@ -125,7 +125,7 @@ public class ShaderCode { /** * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} * @param count number of shaders - * @param binary binary buffer containing the shader binaries, + * @param binary binary buffer containing the shader binaries, */ public ShaderCode(int type, int count, int binFormat, Buffer binary) { switch (type) { @@ -147,19 +147,19 @@ public class ShaderCode { /** * Creates a complete {@link ShaderCode} object while reading all shader source of sourceFiles, * which location is resolved using the context class, see {@link #readShaderSource(Class, String)}. - * + * * @param gl current GL object to determine whether a shader compiler is available. If null, no validation is performed. * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} * @param count number of shaders * @param context class used to help resolving the source location * @param sourceFiles array of source locations, organized as sourceFiles[count] * @param mutableStringBuilder if true method returns a mutable StringBuilder instance - * which can be edited later on at the costs of a String conversion when passing to + * which can be edited later on at the costs of a String conversion when passing to * {@link GL2ES2#glShaderSource(int, int, String[], IntBuffer)}. * If false method returns an immutable String instance, * which can be passed to {@link GL2ES2#glShaderSource(int, int, String[], IntBuffer)} * at no additional costs. - * + * * @throws IllegalArgumentException if count and sourceFiles.length do not match * @see #readShaderSource(Class, String) */ @@ -192,16 +192,16 @@ public class ShaderCode { /** * Creates a complete {@link ShaderCode} object while reading the shader binary of binaryFile, * which location is resolved using the context class, see {@link #readShaderBinary(Class, String)}. - * + * * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} * @param count number of shaders * @param context class used to help resolving the source location * @param binFormat a valid native binary format as they can be queried by {@link ShaderUtil#getShaderBinaryFormats(GL)}. * @param sourceFiles array of source locations, organized as sourceFiles[count] - * + * * @see #readShaderBinary(Class, String) * @see ShaderUtil#getShaderBinaryFormats(GL) - */ + */ public static ShaderCode create(int type, int count, Class context, int binFormat, String binaryFile) { ByteBuffer shaderBinary = null; if(null!=binaryFile && 0<=binFormat) { @@ -231,12 +231,12 @@ public class ShaderCode { *
      • {@link GL2ES2#GL_VERTEX_SHADER vertex}: {@link #SUFFIX_VERTEX_BINARY}
      • *
      • {@link GL2ES2#GL_FRAGMENT_SHADER fragment}: {@link #SUFFIX_FRAGMENT_BINARY}
      • *
      • {@link GL3#GL_GEOMETRY_SHADER geometry}: {@link #SUFFIX_GEOMETRY_BINARY}
      - *
    - * @param binary true for a binary resource, false for a source resource + * + * @param binary true for a binary resource, false for a source resource * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} - * + * * @throws GLException if type is not supported - * + * * @see #create(GL2ES2, int, Class, String, String, String, boolean) */ public static String getFileSuffix(boolean binary, int type) { @@ -252,16 +252,16 @@ public class ShaderCode { } } - /** + /** * Returns a unique relative path for binary shader resources as follows: *
      *
    • {@link GLES2#GL_NVIDIA_PLATFORM_BINARY_NV NVIDIA}: {@link #SUB_PATH_NVIDIA}
    • *
    - * + * * @throws GLException if binFormat is not supported - * + * * @see #create(GL2ES2, int, Class, String, String, String, boolean) - */ + */ public static String getBinarySubPath(int binFormat) { switch (binFormat) { case GLES2.GL_NVIDIA_PLATFORM_BINARY_NV: @@ -272,42 +272,42 @@ public class ShaderCode { } /** - * Convenient creation method for instantiating a complete {@link ShaderCode} object - * either from source code using {@link #create(GL2ES2, int, int, Class, String[])}, + * Convenient creation method for instantiating a complete {@link ShaderCode} object + * either from source code using {@link #create(GL2ES2, int, int, Class, String[])}, * or from a binary code using {@link #create(int, int, Class, int, String)}, * whatever is available first. *

    - * The source and binary location names are expected w/o suffixes which are + * The source and binary location names are expected w/o suffixes which are * resolved and appended using {@link #getFileSuffix(boolean, int)}. *

    *

    * Additionally, the binary resource is expected within a subfolder of binRoot * which reflects the vendor specific binary format, see {@link #getBinarySubPath(int)}. * All {@link ShaderUtil#getShaderBinaryFormats(GL)} are being iterated - * using the binary subfolder, the first existing resource is being used. + * using the binary subfolder, the first existing resource is being used. *

    - * + * * Example: *
          *   Your std JVM layout (plain or within a JAR):
    -     *   
    +     *
          *      org/test/glsl/MyShaderTest.class
          *      org/test/glsl/shader/vertex.vp
          *      org/test/glsl/shader/fragment.fp
          *      org/test/glsl/shader/bin/nvidia/vertex.bvp
          *      org/test/glsl/shader/bin/nvidia/fragment.bfp
    -     *      
    +     *
          *   Your Android APK layout:
    -     *   
    +     *
          *      classes.dex
          *      assets/org/test/glsl/shader/vertex.vp
          *      assets/org/test/glsl/shader/fragment.fp
          *      assets/org/test/glsl/shader/bin/nvidia/vertex.bvp
          *      assets/org/test/glsl/shader/bin/nvidia/fragment.bfp
          *      ...
    -     *   
    +     *
          *   Your invocation in org/test/glsl/MyShaderTest.java:
    -     *   
    +     *
          *      ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, 1, this.getClass(),
          *                                         "shader", new String[] { "vertex" }, "shader/bin", "vertex");
          *      ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, 1, this.getClass(),
    @@ -318,11 +318,11 @@ public class ShaderCode {
          *      st.attachShaderProgram(gl, sp0, true);
          * 
    * A simplified entry point is {@link #create(GL2ES2, int, Class, String, String, String, boolean)}. - * + * *

    * The location is finally being resolved using the context class, see {@link #readShaderBinary(Class, String)}. *

    - * + * * @param gl current GL object to determine whether a shader compiler is available (if source is used), * or to determine the shader binary format (if binary is used). * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} @@ -333,22 +333,22 @@ public class ShaderCode { * @param binRoot relative root path for binBasenames * @param binBasename basename w/o path or suffix relative to binRoot for the shader's binary code * @param mutableStringBuilder if true method returns a mutable StringBuilder instance - * which can be edited later on at the costs of a String conversion when passing to + * which can be edited later on at the costs of a String conversion when passing to * {@link GL2ES2#glShaderSource(int, int, String[], IntBuffer)}. * If false method returns an immutable String instance, * which can be passed to {@link GL2ES2#glShaderSource(int, int, String[], IntBuffer)} * at no additional costs. - * + * * @throws IllegalArgumentException if count and srcBasenames.length do not match - * + * * @see #create(GL2ES2, int, int, Class, String[]) * @see #create(int, int, Class, int, String) * @see #readShaderSource(Class, String) * @see #getFileSuffix(boolean, int) * @see ShaderUtil#getShaderBinaryFormats(GL) * @see #getBinarySubPath(int) - */ - public static ShaderCode create(GL2ES2 gl, int type, int count, Class context, + */ + public static ShaderCode create(GL2ES2 gl, int type, int count, Class context, String srcRoot, String[] srcBasenames, String binRoot, String binBasename, boolean mutableStringBuilder) { ShaderCode res = null; @@ -391,28 +391,28 @@ public class ShaderCode { /** * Simplified variation of {@link #create(GL2ES2, int, int, Class, String, String[], String, String)}. *
    - * + * * Example: *
          *   Your std JVM layout (plain or within a JAR):
    -     *   
    +     *
          *      org/test/glsl/MyShaderTest.class
          *      org/test/glsl/shader/vertex.vp
          *      org/test/glsl/shader/fragment.fp
          *      org/test/glsl/shader/bin/nvidia/vertex.bvp
          *      org/test/glsl/shader/bin/nvidia/fragment.bfp
    -     *      
    +     *
          *   Your Android APK layout:
    -     *   
    +     *
          *      classes.dex
          *      assets/org/test/glsl/shader/vertex.vp
          *      assets/org/test/glsl/shader/fragment.fp
          *      assets/org/test/glsl/shader/bin/nvidia/vertex.bvp
          *      assets/org/test/glsl/shader/bin/nvidia/fragment.bfp
          *      ...
    -     *   
    +     *
          *   Your invocation in org/test/glsl/MyShaderTest.java:
    -     *   
    +     *
          *      ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(),
          *                                         "shader", "shader/bin", "vertex");
          *      ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(),
    @@ -422,7 +422,7 @@ public class ShaderCode {
          *      sp0.add(gl, fp0, System.err);
          *      st.attachShaderProgram(gl, sp0, true);
          * 
    - * + * * @param gl current GL object to determine whether a shader compiler is available (if source is used), * or to determine the shader binary format (if binary is used). * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} @@ -433,20 +433,20 @@ public class ShaderCode { * @param basenames basename w/o path or suffix relative to srcRoot and binRoot * for the shader's source and binary code. * @param mutableStringBuilder if true method returns a mutable StringBuilder instance - * which can be edited later on at the costs of a String conversion when passing to + * which can be edited later on at the costs of a String conversion when passing to * {@link GL2ES2#glShaderSource(int, int, String[], IntBuffer)}. * If false method returns an immutable String instance, * which can be passed to {@link GL2ES2#glShaderSource(int, int, String[], IntBuffer)} * at no additional costs. * @throws IllegalArgumentException if count is not 1 - * + * * @see #create(GL2ES2, int, int, Class, String, String[], String, String) - */ - public static ShaderCode create(GL2ES2 gl, int type, Class context, + */ + public static ShaderCode create(GL2ES2 gl, int type, Class context, String srcRoot, String binRoot, String basename, boolean mutableStringBuilder) { - return create(gl, type, 1, context, srcRoot, new String[] { basename }, binRoot, basename, mutableStringBuilder ); + return create(gl, type, 1, context, srcRoot, new String[] { basename }, binRoot, basename, mutableStringBuilder ); } - + /** * returns the uniq shader id as an integer */ @@ -455,7 +455,7 @@ public class ShaderCode { public int shaderType() { return shaderType; } public String shaderTypeStr() { return shaderTypeStr(shaderType); } - public static String shaderTypeStr(int type) { + public static String shaderTypeStr(int type) { switch (type) { case GL2ES2.GL_VERTEX_SHADER: return "VERTEX_SHADER"; @@ -553,7 +553,7 @@ public class ShaderCode { } else { CharSequence[] src = shaderSource[i]; int lineno=0; - + for(int j=0; jdata after the line containing tag. *

    * Note: The shader source to be edit must be created using a mutable StringBuilder. *

    - * + * * @param shaderIdx the shader index to be used. * @param tag search string * @param fromIndex start search tag begininig with this index * @param data the text to be inserted. Shall end with an EOL '\n' character. * @return index after the inserted data - * + * * @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type StringBuilder */ public int insertShaderSource(int shaderIdx, String tag, int fromIndex, CharSequence data) { @@ -595,7 +595,7 @@ public class ShaderCode { final int sourceCount = (null!=shaderSource)?shaderSource.length:0; if(shaderIdx>=sourceCount) { throw new IndexOutOfBoundsException("shaderIdx not within source bounds [0.."+(sourceCount-1)+"]: "+shaderIdx); - } + } final CharSequence[] src = shaderSource[shaderIdx]; int curEndIndex = 0; for(int j=0; joldName
    with newName in all shader sources. *

    * In case oldName and newName are equal, no action is performed. - *

    + *

    *

    * Note: The shader source to be edit must be created using a mutable StringBuilder. *

    - * + * * @param oldName the to be replace string * @param newName the replacement string * @return the number of replacements - * + * * @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type StringBuilder */ public int replaceInShaderSource(String oldName, String newName) { @@ -675,18 +675,18 @@ public class ShaderCode { } return num; } - + /** * Adds data at offset in shader source for shader shaderIdx. *

    * Note: The shader source to be edit must be created using a mutable StringBuilder. *

    - * + * * @param shaderIdx the shader index to be used. * @param position in shader source segments of shader shaderIdx * @param data the text to be inserted. Shall end with an EOL '\n' character * @return index after the inserted data - * + * * @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type StringBuilder */ public int insertShaderSource(int shaderIdx, int position, CharSequence data) { @@ -700,7 +700,7 @@ public class ShaderCode { final int sourceCount = (null!=shaderSource)?shaderSource.length:0; if(shaderIdx>=sourceCount) { throw new IndexOutOfBoundsException("shaderIdx not within source bounds [0.."+(sourceCount-1)+"]: "+shaderIdx); - } + } final CharSequence[] src = shaderSource[shaderIdx]; int curEndIndex = 0; for(int j=0; j context, URLConnection conn, StringBuilder result) throws IOException { readShaderSource(context, conn, result, 0); } - + /** * Reads shader source located in path, * either relative to the context class or absolute as-is. @@ -774,21 +774,21 @@ public class ShaderCode { * Final location lookup is performed via {@link ClassLoader#getResource(String)} and {@link ClassLoader#getSystemResource(String)}, * see {@link IOUtil#getResource(Class, String)}. *

    - * + * * @param context class used to help resolve the source location * @param path location of shader source * @param mutableStringBuilder if true method returns a mutable StringBuilder instance - * which can be edited later on at the costs of a String conversion when passing to + * which can be edited later on at the costs of a String conversion when passing to * {@link GL2ES2#glShaderSource(int, int, String[], IntBuffer)}. * If false method returns an immutable String instance, * which can be passed to {@link GL2ES2#glShaderSource(int, int, String[], IntBuffer)} * at no additional costs. - * @throws IOException - * + * @throws IOException + * * @see IOUtil#getResource(Class, String) - */ + */ public static CharSequence readShaderSource(Class context, String path, boolean mutableStringBuilder) throws IOException { - URLConnection conn = IOUtil.getResource(context, path); + URLConnection conn = IOUtil.getResource(context, path); if (conn == null) { return null; } @@ -798,17 +798,17 @@ public class ShaderCode { } /** - * Reads shader binary located in path, + * Reads shader binary located in path, * either relative to the context class or absolute as-is. *

    * Final location lookup is perfomed via {@link ClassLoader#getResource(String)} and {@link ClassLoader#getSystemResource(String)}, * see {@link IOUtil#getResource(Class, String)}. *

    - * + * * @param context class used to help resolve the source location * @param path location of shader binary - * @throws IOException - * + * @throws IOException + * * @see IOUtil#getResource(Class, String) */ public static ByteBuffer readShaderBinary(Class context, String path) throws IOException { @@ -824,41 +824,41 @@ public class ShaderCode { } } - // Shall we use: #ifdef GL_FRAGMENT_PRECISION_HIGH .. #endif for using highp in fragment shader if avail ? + // Shall we use: #ifdef GL_FRAGMENT_PRECISION_HIGH .. #endif for using highp in fragment shader if avail ? /** Default precision of {@link GL#isGLES2() ES2} for {@link GL2ES2#GL_VERTEX_SHADER vertex-shader}: {@value #es2_default_precision_vp} */ public static final String es2_default_precision_vp = "\nprecision highp float;\nprecision highp int;\n"; /** Default precision of {@link GL#isGLES2() ES2} for {@link GL2ES2#GL_FRAGMENT_SHADER fragment-shader}: {@value #es2_default_precision_fp} */ public static final String es2_default_precision_fp = "\nprecision mediump float;\nprecision mediump int;\n/*precision lowp sampler2D;*/\n"; - + /** Default precision of GLSL ≥ 1.30 as required until < 1.50 for {@link GL2ES2#GL_VERTEX_SHADER vertex-shader} or {@link GL3#GL_GEOMETRY_SHADER geometry-shader}: {@value #gl3_default_precision_vp_gp}. See GLSL Spec 1.30-1.50 Section 4.5.3. */ public static final String gl3_default_precision_vp_gp = "\nprecision highp float;\nprecision highp int;\n"; /** Default precision of GLSL ≥ 1.30 as required until < 1.50 for {@link GL2ES2#GL_FRAGMENT_SHADER fragment-shader}: {@value #gl3_default_precision_fp}. See GLSL Spec 1.30-1.50 Section 4.5.3. */ public static final String gl3_default_precision_fp = "\nprecision highp float;\nprecision mediump int;\n/*precision mediump sampler2D;*/\n"; - + /** Prefer enable over require, since it won't force a failure. */ public static final String extOESDerivativesEnable = "#extension GL_OES_standard_derivatives : enable\n"; - + /** * Add GLSL version at the head of this shader source code. *

    * Note: The shader source to be edit must be created using a mutable StringBuilder. *

    - * @param gl a GL context, which must have been made current once + * @param gl a GL context, which must have been made current once * @return the index after the inserted data, maybe 0 if nothing has be inserted. */ public final int addGLSLVersion(GL2ES2 gl) { return insertShaderSource(0, 0, gl.getContext().getGLSLVersionString()); } - + /** * Adds default precision to source code at given position if required, i.e. - * {@link #es2_default_precision_vp}, {@link #es2_default_precision_fp}, + * {@link #es2_default_precision_vp}, {@link #es2_default_precision_fp}, * {@link #gl3_default_precision_vp_gp}, {@link #gl3_default_precision_fp} or none, * depending on the {@link GLContext#getGLSLVersionNumber() GLSL version} being used. *

    * Note: The shader source to be edit must be created using a mutable StringBuilder. *

    - * @param gl a GL context, which must have been made current once + * @param gl a GL context, which must have been made current once * @param pos position within this mutable shader source. * @return the index after the inserted data, maybe 0 if nothing has be inserted. */ @@ -871,7 +871,7 @@ public class ShaderCode { case GL2ES2.GL_FRAGMENT_SHADER: defaultPrecision = es2_default_precision_vp; break; default: - defaultPrecision = null; + defaultPrecision = null; break; } } else if( requiresGL3DefaultPrecision(gl) ) { @@ -883,7 +883,7 @@ public class ShaderCode { case GL2ES2.GL_FRAGMENT_SHADER: defaultPrecision = gl3_default_precision_fp; break; default: - defaultPrecision = null; + defaultPrecision = null; break; } } else { @@ -894,7 +894,7 @@ public class ShaderCode { } return pos; } - + /** Returns true, if GLSL version requires default precision, i.e. ES2 or GLSL [1.30 .. 1.50[. */ public static final boolean requiresDefaultPrecision(GL2ES2 gl) { if( gl.isGLES2() ) { @@ -902,7 +902,7 @@ public class ShaderCode { } return requiresGL3DefaultPrecision(gl); } - + /** Returns true, if GL3 GLSL version requires default precision, i.e. GLSL [1.30 .. 1.50[. */ public static final boolean requiresGL3DefaultPrecision(GL2ES2 gl) { if( gl.isGL3() ) { @@ -912,16 +912,16 @@ public class ShaderCode { return false; } } - + /** * Default customization of this shader source code. *

    * Note: The shader source to be edit must be created using a mutable StringBuilder. *

    - * @param gl a GL context, which must have been made current once + * @param gl a GL context, which must have been made current once * @param preludeVersion if true {@link GLContext#getGLSLVersionString()} is preluded, otherwise not. - * @param addDefaultPrecision if true default precision source code line(s) are added, i.e. - * {@link #es2_default_precision_vp}, {@link #es2_default_precision_fp}, + * @param addDefaultPrecision if true default precision source code line(s) are added, i.e. + * {@link #es2_default_precision_vp}, {@link #es2_default_precision_fp}, * {@link #gl3_default_precision_vp_gp}, {@link #gl3_default_precision_fp} or none, * depending on the {@link GLContext#getGLSLVersionNumber() GLSL version} being used. * @return the index after the inserted data, maybe 0 if nothing has be inserted. @@ -940,13 +940,13 @@ public class ShaderCode { } return pos; } - + /** * Default customization of this shader source code. *

    * Note: The shader source to be edit must be created using a mutable StringBuilder. *

    - * @param gl a GL context, which must have been made current once + * @param gl a GL context, which must have been made current once * @param preludeVersion if true {@link GLContext#getGLSLVersionString()} is preluded, otherwise not. * @param esDefaultPrecision optional default precision source code line(s) preluded if not null and if {@link GL#isGLES()}. * You may use {@link #es2_default_precision_fp} for fragment shader and {@link #es2_default_precision_vp} for vertex shader. @@ -967,8 +967,8 @@ public class ShaderCode { pos = addDefaultShaderPrecision(gl, pos); } return pos; - } - + } + //---------------------------------------------------------------------- // Internals only below this point // diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java index 1337a7e2b..d737d6f4e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java @@ -37,7 +37,7 @@ import java.util.Iterator; import java.io.PrintStream; public class ShaderProgram { - + public ShaderProgram() { id = getNextID(); } @@ -111,7 +111,7 @@ public class ShaderProgram { /** * Adds a new shader to this program. - * + * *

    This command does not compile and attach the shader, * use {@link #add(GL2ES2, ShaderCode)} for this purpose.

    */ @@ -122,7 +122,7 @@ public class ShaderProgram { public synchronized boolean contains(ShaderCode shaderCode) { return allShaderCode.contains(shaderCode); } - + /** * Warning slow O(n) operation .. * @param id @@ -145,9 +145,9 @@ public class ShaderProgram { /** * Creates the empty GL program object using {@link GL2ES2#glCreateProgram()}, * if not already created. - * + * * @param gl - * @return true if shader program is valid, i.e. not zero + * @return true if shader program is valid, i.e. not zero */ public synchronized final boolean init(GL2ES2 gl) { if( 0 == shaderProgram ) { @@ -155,12 +155,12 @@ public class ShaderProgram { } return 0 != shaderProgram; } - + /** * Adds a new shader to a this non running program. * *

    Compiles and attaches the shader, if not done yet.

    - * + * * @return true if the shader was successfully added, false if compilation failed. */ public synchronized boolean add(GL2ES2 gl, ShaderCode shaderCode, PrintStream verboseOut) { @@ -179,11 +179,11 @@ public class ShaderProgram { /** * Replace a shader in a program and re-links the program. * - * @param gl + * @param gl * @param oldShader the to be replace Shader * @param newShader the new ShaderCode * @param verboseOut the optional verbose output stream - * + * * @return true if all steps are valid, shader compilation, attachment and linking; otherwise false. * * @see ShaderState#glEnableVertexAttribArray @@ -199,25 +199,25 @@ public class ShaderProgram { if(!init(gl) || !newShader.compile(gl, verboseOut)) { return false; } - + boolean shaderWasInUse = inUse(); if(shaderWasInUse) { useProgram(gl, false); } - + if(null != oldShader && allShaderCode.remove(oldShader)) { if(attachedShaderCode.remove(oldShader)) { ShaderUtil.detachShader(gl, shaderProgram, oldShader.shader()); } } - + add(newShader); if(attachedShaderCode.add(newShader)) { ShaderUtil.attachShader(gl, shaderProgram, newShader.shader()); } - + gl.glLinkProgram(shaderProgram); - + programLinked = ShaderUtil.isProgramLinkStatusValid(gl, shaderProgram, System.err); if ( programLinked && shaderWasInUse ) { useProgram(gl, true); @@ -227,19 +227,19 @@ public class ShaderProgram { /** * Links the shader code to the program. - * + * *

    Compiles and attaches the shader code to the program if not done by yet

    - * + * *

    Within this process, all GL resources (shader and program objects) are created if necessary.

    - * + * * @param gl * @param verboseOut * @return true if program was successfully linked and is valid, otherwise false - * + * * @see #init(GL2ES2) */ public synchronized boolean link(GL2ES2 gl, PrintStream verboseOut) { - if( !init(gl) ) { + if( !init(gl) ) { programLinked = false; // mark unlinked due to user attempt to [re]link return false; } @@ -287,7 +287,7 @@ public class ShaderProgram { sb.append("]"); return sb; } - + public String toString() { return toString(null).toString(); } @@ -299,7 +299,7 @@ public class ShaderProgram { public synchronized boolean validateProgram(GL2ES2 gl, PrintStream verboseOut) { return ShaderUtil.isProgramExecStatusValid(gl, shaderProgram, verboseOut); } - + public synchronized void useProgram(GL2ES2 gl, boolean on) { if(!programLinked) { throw new GLException("Program is not linked"); } if(programInUse==on) { return; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java index 8e7781f07..f60cb6088 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java @@ -48,21 +48,21 @@ import com.jogamp.opengl.util.GLArrayDataEditable; * while updating the attribute and uniform locations when switching. *

    * This allows seamless switching of programs using almost same data - * but performing different artifacts. + * but performing different artifacts. *

    *

    * A {@link #useProgram(GL2ES2, boolean) used} ShaderState is attached to the current GL context * and can be retrieved via {@link #getShaderState(GL)}. *

    */ -public class ShaderState { +public class ShaderState { public static final boolean DEBUG; - + static { Debug.initSingleton(); DEBUG = Debug.isPropertyDefined("jogl.debug.GLSLState", true); } - + public ShaderState() { } @@ -80,7 +80,7 @@ public class ShaderState { /** * Attach user object for the given name to this ShaderState. * Returns the previously set object or null. - * + * * @return the previous mapped object or null if none */ public final Object attachObject(String name, Object obj) { @@ -89,13 +89,13 @@ public class ShaderState { /** * @param name name of the mapped object to detach - * + * * @return the previous mapped object or null if none */ public final Object detachObject(String name) { return attachedObjectsByString.remove(name); - } - + } + /** * Turns the shader program on or off.
    * @@ -104,7 +104,7 @@ public class ShaderState { * @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean) */ public synchronized void useProgram(GL2ES2 gl, boolean on) throws GLException { - if(null==shaderProgram) { throw new GLException("No program is attached"); } + if(null==shaderProgram) { throw new GLException("No program is attached"); } if(on) { if(shaderProgram.linked()) { shaderProgram.useProgram(gl, true); @@ -112,7 +112,7 @@ public class ShaderState { resetAllAttributes(gl); resetAllUniforms(gl); } - } else { + } else { if(resetAllShaderData) { setAllAttributes(gl); } @@ -124,7 +124,7 @@ public class ShaderState { resetAllUniforms(gl); } } - resetAllShaderData = false; + resetAllShaderData = false; } else { shaderProgram.useProgram(gl, false); } @@ -141,17 +141,17 @@ public class ShaderState { /** * Attach or switch a shader program * - *

    Attaching a shader program the first time, + *

    Attaching a shader program the first time, * as well as switching to another program on the fly, * while managing all attribute and uniform data.

    - * + * *

    [Re]sets all data and use program in case of a program switch.

    - * + * *

    Use program, {@link #useProgram(GL2ES2, boolean)}, * if enable is true.

    - * + * * @return true if shader program was attached, otherwise false (already attached) - * + * * @throws GLException if program was not linked and linking fails */ public synchronized boolean attachShaderProgram(GL2ES2 gl, ShaderProgram prog, boolean enable) throws GLException { @@ -161,7 +161,7 @@ public class ShaderState { System.err.println("ShaderState: attachShaderProgram: "+curId+" -> "+newId+" (enable: "+enable+")\n\t"+shaderProgram+"\n\t"+prog); if(DEBUG) { Thread.dumpStack(); - } + } } if(null!=shaderProgram) { if(shaderProgram.equals(prog)) { @@ -190,7 +190,7 @@ public class ShaderState { shaderProgram = prog; if(null!=shaderProgram) { - // [re]set all data and use program if switching program, + // [re]set all data and use program if switching program, // or use program if program is linked if(resetAllShaderData || enable) { useProgram(gl, true); // may reset all data @@ -216,7 +216,7 @@ public class ShaderState { */ public synchronized void destroy(GL2ES2 gl) { release(gl, true, true, true); - attachedObjectsByString.clear(); + attachedObjectsByString.clear(); } /** @@ -242,7 +242,7 @@ public class ShaderState { if(destroyBoundAttributes) { for(Iterator iter = managedAttributes.iterator(); iter.hasNext(); ) { iter.next().destroy(gl); - } + } } releaseAllAttributes(gl); releaseAllUniforms(gl); @@ -258,7 +258,7 @@ public class ShaderState { /** * Gets the cached location of a shader attribute. * - * @return -1 if there is no such attribute available, + * @return -1 if there is no such attribute available, * otherwise >= 0 * * @see #bindAttribLocation(GL2ES2, int, String) @@ -270,7 +270,7 @@ public class ShaderState { Integer idx = activeAttribLocationMap.get(name); return (null!=idx)?idx.intValue():-1; } - + /** * Get the previous cached vertex attribute data. * @@ -289,27 +289,27 @@ public class ShaderState { public GLArrayData getAttribute(String name) { return activeAttribDataMap.get(name); } - + public boolean isActiveAttribute(GLArrayData attribute) { return attribute == activeAttribDataMap.get(attribute.getName()); } - + /** * Binds or unbinds the {@link GLArrayData} lifecycle to this ShaderState. - * + * *

    If an attribute location is cached (ie {@link #bindAttribLocation(GL2ES2, int, String)}) * it is promoted to the {@link GLArrayData} instance.

    - * - *

    The attribute will be destroyed with {@link #destroy(GL2ES2)} + * + *

    The attribute will be destroyed with {@link #destroy(GL2ES2)} * and it's location will be reset when switching shader with {@link #attachShaderProgram(GL2ES2, ShaderProgram)}.

    - * + * *

    The data will not be transfered to the GPU, use {@link #vertexAttribPointer(GL2ES2, GLArrayData)} additionally.

    - * + * *

    The data will also be {@link GLArrayData#associate(Object, boolean) associated} with this ShaderState.

    - * + * * @param attribute the {@link GLArrayData} which lifecycle shall be managed * @param own true if owning shall be performs, false if disowning. - * + * * @see #bindAttribLocation(GL2ES2, int, String) * @see #getAttribute(String) * @see GLArrayData#associate(Object, boolean) @@ -326,11 +326,11 @@ public class ShaderState { } attribute.associate(this, own); } - + public boolean ownsAttribute(GLArrayData attribute) { return managedAttributes.contains(attribute); } - + /** * Binds a shader attribute to a location. * Multiple names can be bound to one location. @@ -339,14 +339,14 @@ public class ShaderState { * * @throws GLException if no program is attached * @throws GLException if the program is already linked - * + * * @see javax.media.opengl.GL2ES2#glBindAttribLocation(int, int, String) * @see #getAttribLocation(GL2ES2, String) * @see #getCachedAttribLocation(String) */ public void bindAttribLocation(GL2ES2 gl, int location, String name) { if(null==shaderProgram) throw new GLException("No program is attached"); - if(shaderProgram.linked()) throw new GLException("Program is already linked"); + if(shaderProgram.linked()) throw new GLException("Program is already linked"); final Integer loc = new Integer(location); activeAttribLocationMap.put(name, loc); gl.glBindAttribLocation(shaderProgram.program(), location, name); @@ -361,7 +361,7 @@ public class ShaderState { * * @throws GLException if no program is attached * @throws GLException if the program is already linked - * + * * @see javax.media.opengl.GL2ES2#glBindAttribLocation(int, int, String) * @see #getAttribLocation(GL2ES2, String) * @see #getCachedAttribLocation(String) @@ -382,7 +382,7 @@ public class ShaderState { * or the GLSL queried via {@link GL2ES2#glGetAttribLocation(int, String)}.
    * The location will be cached. * - * @return -1 if there is no such attribute available, + * @return -1 if there is no such attribute available, * otherwise >= 0 * @throws GLException if no program is attached * @throws GLException if the program is not linked and no location was cached. @@ -407,22 +407,22 @@ public class ShaderState { System.err.println("ShaderState: glGetAttribLocation failed, no location for: "+name+", loc: "+location); if(DEBUG) { Thread.dumpStack(); - } + } } } return location; } - + /** * Validates and returns the location of a shader attribute.
    - * Uses either the cached value {@link #getCachedAttribLocation(String)} if valid, + * Uses either the cached value {@link #getCachedAttribLocation(String)} if valid, * or the GLSL queried via {@link GL2ES2#glGetAttribLocation(int, String)}.
    - * The location will be cached and set in the + * The location will be cached and set in the * {@link GLArrayData} object. * - * @return -1 if there is no such attribute available, + * @return -1 if there is no such attribute available, * otherwise >= 0 - * + * * @throws GLException if no program is attached * @throws GLException if the program is not linked and no location was cached. * @@ -451,13 +451,13 @@ public class ShaderState { System.err.println("ShaderState: glGetAttribLocation failed, no location for: "+name+", loc: "+location); if(DEBUG) { Thread.dumpStack(); - } + } } - } + } activeAttribDataMap.put(data.getName(), data); return location; } - + // // Enabled Vertex Arrays and its data // @@ -469,14 +469,14 @@ public class ShaderState { final Boolean v = activedAttribEnabledMap.get(name); return null != v && v.booleanValue(); } - + /** * @return true if the {@link GLArrayData} attribute is enable */ public final boolean isVertexAttribArrayEnabled(GLArrayData data) { return isVertexAttribArrayEnabled(data.getName()); } - + private boolean enableVertexAttribArray(GL2ES2 gl, String name, int location) { activedAttribEnabledMap.put(name, Boolean.TRUE); if(0>location) { @@ -486,7 +486,7 @@ public class ShaderState { System.err.println("ShaderState: glEnableVertexAttribArray failed, no index for: "+name); if(DEBUG) { Thread.dumpStack(); - } + } } return false; } @@ -497,12 +497,12 @@ public class ShaderState { gl.glEnableVertexAttribArray(location); return true; } - + /** * Enables a vertex attribute array. - * + * * This method retrieves the the location via {@link #getAttribLocation(GL2ES2, GLArrayData)} - * hence {@link #enableVertexAttribArray(GL2ES2, GLArrayData)} shall be preferred. + * hence {@link #enableVertexAttribArray(GL2ES2, GLArrayData)} shall be preferred. * * Even if the attribute is not found in the current shader, * it is marked enabled in this state. @@ -510,7 +510,7 @@ public class ShaderState { * @return false, if the name is not found, otherwise true * * @throws GLException if the program is not linked and no location was cached. - * + * * @see #glEnableVertexAttribArray * @see #glDisableVertexAttribArray * @see #glVertexAttribPointer @@ -519,7 +519,7 @@ public class ShaderState { public boolean enableVertexAttribArray(GL2ES2 gl, String name) { return enableVertexAttribArray(gl, name, -1); } - + /** * Enables a vertex attribute array, usually invoked by {@link GLArrayDataEditable#enableBuffer(GL, boolean)}. @@ -528,7 +528,7 @@ public class ShaderState { * and is the preferred alternative to {@link #enableVertexAttribArray(GL2ES2, String)}. * If data location is unset it will be retrieved via {@link #getAttribLocation(GL2ES2, GLArrayData)} set * and cached in this state. - * + * * Even if the attribute is not found in the current shader, * it is marked enabled in this state. * @@ -547,11 +547,11 @@ public class ShaderState { getAttribLocation(gl, data); } else { // ensure data is the current bound one - activeAttribDataMap.put(data.getName(), data); + activeAttribDataMap.put(data.getName(), data); } return enableVertexAttribArray(gl, data.getName(), data.getLocation()); } - + private boolean disableVertexAttribArray(GL2ES2 gl, String name, int location) { activedAttribEnabledMap.put(name, Boolean.FALSE); if(0>location) { @@ -572,13 +572,13 @@ public class ShaderState { gl.glDisableVertexAttribArray(location); return true; } - + /** * Disables a vertex attribute array * * This method retrieves the the location via {@link #getAttribLocation(GL2ES2, GLArrayData)} * hence {@link #disableVertexAttribArray(GL2ES2, GLArrayData)} shall be preferred. - * + * * Even if the attribute is not found in the current shader, * it is removed from this state enabled list. * @@ -603,7 +603,7 @@ public class ShaderState { * and is the preferred alternative to {@link #disableVertexAttribArray(GL2ES2, String)}. * If data location is unset it will be retrieved via {@link #getAttribLocation(GL2ES2, GLArrayData)} set * and cached in this state. - * + * * Even if the attribute is not found in the current shader, * it is removed from this state enabled list. * @@ -623,20 +623,20 @@ public class ShaderState { } return disableVertexAttribArray(gl, data.getName(), data.getLocation()); } - + /** * Set the {@link GLArrayData} vertex attribute data, if it's location is valid, i.e. ≥ 0. *

    * This method uses the {@link GLArrayData}'s location if valid, i.e. ≥ 0.
    - * If data's location is invalid, it will be retrieved via {@link #getAttribLocation(GL2ES2, GLArrayData)}, + * If data's location is invalid, it will be retrieved via {@link #getAttribLocation(GL2ES2, GLArrayData)}, * set and cached in this state. *

    - * + * * @return false, if the location could not be determined, otherwise true * * @throws GLException if no program is attached * @throws GLException if the program is not linked and no location was cached. - * + * * @see #glEnableVertexAttribArray * @see #glDisableVertexAttribArray * @see #glVertexAttribPointer @@ -646,7 +646,7 @@ public class ShaderState { int location = data.getLocation(); if(0 > location) { location = getAttribLocation(gl, data); - } + } if(0 <= location) { // only pass the data, if the attribute exists in the current shader if(DEBUG) { @@ -683,16 +683,16 @@ public class ShaderState { activeAttribDataMap.clear(); activedAttribEnabledMap.clear(); activeAttribLocationMap.clear(); - managedAttributes.clear(); + managedAttributes.clear(); } - + /** * Disables all vertex attribute arrays. * * Their enabled stated will be removed from this state only * if 'removeFromState' is true. * - * This method purpose is more for debugging. + * This method purpose is more for debugging. * * @see #glEnableVertexAttribArray * @see #glDisableVertexAttribArray @@ -717,7 +717,7 @@ public class ShaderState { } private final void relocateAttribute(GL2ES2 gl, GLArrayData attribute) { - // get new location .. note: 'activeAttribLocationMap' is cleared before + // get new location .. note: 'activeAttribLocationMap' is cleared before final String name = attribute.getName(); final int loc = attribute.setLocation(gl, shaderProgram.program()); if(0<=loc) { @@ -729,34 +729,34 @@ public class ShaderState { // enable attrib, VBO and pass location/data gl.glEnableVertexAttribArray(loc); } - + if( attribute.isVBO() ) { gl.glBindBuffer(GL.GL_ARRAY_BUFFER, attribute.getVBOName()); gl.glVertexAttribPointer(attribute); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0); - } else { + } else { gl.glVertexAttribPointer(attribute); } } } - + /** * Reset all previously enabled mapped vertex attribute data. - * + * *

    * Attribute data is bound to the GL state, i.e. VBO data itself will not be updated. *

    - * + * *

    * Attribute location and it's data assignment is bound to the program, * hence both are updated. *

    - * + * *

    - * Note: Such update could only be prevented, + * Note: Such update could only be prevented, * if tracking am attribute/program dirty flag. *

    - * + * * @throws GLException is the program is not linked * * @see #attachShaderProgram(GL2ES2, ShaderProgram) @@ -764,7 +764,7 @@ public class ShaderState { private final void resetAllAttributes(GL2ES2 gl) { if(!shaderProgram.linked()) throw new GLException("Program is not linked"); activeAttribLocationMap.clear(); - + for(int i=0; i= 0 */ public final int getCachedUniformLocation(String name) { @@ -822,38 +822,38 @@ public class ShaderState { /** * Bind the {@link GLUniform} lifecycle to this ShaderState. - * + * *

    If a uniform location is cached it is promoted to the {@link GLUniformData} instance.

    - * - *

    The attribute will be destroyed with {@link #destroy(GL2ES2)} + * + *

    The attribute will be destroyed with {@link #destroy(GL2ES2)} * and it's location will be reset when switching shader with {@link #attachShaderProgram(GL2ES2, ShaderProgram)}.

    - * + * *

    The data will not be transfered to the GPU, use {@link #uniform(GL2ES2, GLUniformData)} additionally.

    - * + * * @param uniform the {@link GLUniformData} which lifecycle shall be managed - * + * * @see #getUniform(String) */ public void ownUniform(GLUniformData uniform) { final int location = getCachedUniformLocation(uniform.getName()); if(0<=location) { uniform.setLocation(location); - } + } activeUniformDataMap.put(uniform.getName(), uniform); - managedUniforms.add(uniform); + managedUniforms.add(uniform); } - + public boolean ownsUniform(GLUniformData uniform) { return managedUniforms.contains(uniform); } - + /** * Gets the location of a shader uniform with given name.
    * Uses either the cached value {@link #getCachedUniformLocation(String)} if valid, * or the GLSL queried via {@link GL2ES2#glGetUniformLocation(int, String)}.
    * The location will be cached. *

    - * The current shader program ({@link #attachShaderProgram(GL2ES2, ShaderProgram)}) + * The current shader program ({@link #attachShaderProgram(GL2ES2, ShaderProgram)}) * must be in use ({@link #useProgram(GL2ES2, boolean) }) !

    * * @return -1 if there is no such attribute available, @@ -884,15 +884,15 @@ public class ShaderState { } return location; } - + /** * Validates and returns the location of a shader uniform.
    * Uses either the cached value {@link #getCachedUniformLocation(String)} if valid, * or the GLSL queried via {@link GL2ES2#glGetUniformLocation(int, String)}.
    - * The location will be cached and set in the + * The location will be cached and set in the * {@link GLUniformData} object. *

    - * The current shader program ({@link #attachShaderProgram(GL2ES2, ShaderProgram)}) + * The current shader program ({@link #attachShaderProgram(GL2ES2, ShaderProgram)}) * must be in use ({@link #useProgram(GL2ES2, boolean) }) !

    * * @return -1 if there is no such attribute available, @@ -922,16 +922,16 @@ public class ShaderState { Thread.dumpStack(); } } - } - activeUniformDataMap.put(name, data); + } + activeUniformDataMap.put(name, data); return location; } - + /** * Set the uniform data, if it's location is valid, i.e. ≥ 0. *

    * This method uses the {@link GLUniformData}'s location if valid, i.e. ≥ 0.
    - * If data's location is invalid, it will be retrieved via {@link #getUniformLocation(GL2ES2, GLUniformData)}, + * If data's location is invalid, it will be retrieved via {@link #getUniformLocation(GL2ES2, GLUniformData)}, * set and cached in this state. *

    * @@ -959,7 +959,7 @@ public class ShaderState { } return false; } - + /** * Get the uniform data, previously set. * @@ -978,7 +978,7 @@ public class ShaderState { activeUniformLocationMap.clear(); managedUniforms.clear(); } - + /** * Reset all previously mapped uniform data *

    @@ -986,20 +986,20 @@ public class ShaderState { * hence both are updated. *

    *

    - * Note: Such update could only be prevented, + * Note: Such update could only be prevented, * if tracking a uniform/program dirty flag. *

    - * + * * @throws GLException is the program is not in use - * + * * @see #attachShaderProgram(GL2ES2, ShaderProgram) */ private final void resetAllUniforms(GL2ES2 gl) { - if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); + if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); activeUniformLocationMap.clear(); for(Iterator iter = managedUniforms.iterator(); iter.hasNext(); ) { iter.next().setLocation(-1); - } + } for(Iterator iter = activeUniformDataMap.values().iterator(); iter.hasNext(); ) { final GLUniformData data = iter.next(); final int loc = data.setLocation(gl, shaderProgram.program()); @@ -1018,9 +1018,9 @@ public class ShaderState { if(null==sb) { sb = new StringBuilder(); } - + sb.append("ShaderState[ "); - + sb.append(Platform.getNewline()).append(" "); if(null != shaderProgram) { shaderProgram.toString(sb); @@ -1066,25 +1066,25 @@ public class ShaderState { sb.append(Platform.getNewline()).append(" ]").append(Platform.getNewline()).append("]"); return sb; } - + @Override public String toString() { return toString(null, DEBUG).toString(); } - + private boolean verbose = DEBUG; private ShaderProgram shaderProgram=null; - + private HashMap activedAttribEnabledMap = new HashMap(); private HashMap activeAttribLocationMap = new HashMap(); private HashMap activeAttribDataMap = new HashMap(); private ArrayList managedAttributes = new ArrayList(); - + private HashMap activeUniformLocationMap = new HashMap(); private HashMap activeUniformDataMap = new HashMap(); private ArrayList managedUniforms = new ArrayList(); - - private HashMap attachedObjectsByString = new HashMap(); + + private HashMap attachedObjectsByString = new HashMap(); private boolean resetAllShaderData = false; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java index d18fd4bae..5cd384c58 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,7 +28,7 @@ * 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.opengl.util.glsl; @@ -117,11 +117,11 @@ public class ShaderUtil { } return true; } - + /** * Performs {@link GL2ES2#glValidateProgram(int)} *

    - * One shall only call this method while debugging and only if all required + * One shall only call this method while debugging and only if all required * resources by the shader are set. *

    *

    @@ -150,7 +150,7 @@ public class ShaderUtil { } /** - * If supported, queries the natively supported shader binary formats using + * If supported, queries the natively supported shader binary formats using * {@link GL2ES2#GL_NUM_SHADER_BINARY_FORMATS} and {@link GL2ES2#GL_SHADER_BINARY_FORMATS} * via {@link GL2ES2#glGetIntegerv(int, int[], int)}. */ @@ -172,9 +172,9 @@ public class ShaderUtil { info.shaderBinaryFormats.add(new Integer(formats[i])); } } - } catch (GLException gle) { - System.err.println("Catched Exception on thread "+Thread.currentThread().getName()); - gle.printStackTrace(); + } catch (GLException gle) { + System.err.println("Catched Exception on thread "+Thread.currentThread().getName()); + gle.printStackTrace(); } } } @@ -202,13 +202,13 @@ public class ShaderUtil { } info.shaderCompilerAvailable = new Boolean(v); queryOK = true; - } catch (GLException gle) { - System.err.println("Catched Exception on thread "+Thread.currentThread().getName()); - gle.printStackTrace(); + } catch (GLException gle) { + System.err.println("Catched Exception on thread "+Thread.currentThread().getName()); + gle.printStackTrace(); } if(!queryOK) { info.shaderCompilerAvailable = new Boolean(true); - } + } } else if( gl.isGL2ES2() ) { info.shaderCompilerAvailable = new Boolean(true); } else { @@ -217,8 +217,8 @@ public class ShaderUtil { } return info.shaderCompilerAvailable.booleanValue(); } - - /** Returns true if GeometryShader is supported, i.e. whether GLContext is ≥ 3.2 or ARB_geometry_shader4 extension is available. */ + + /** Returns true if GeometryShader is supported, i.e. whether GLContext is ≥ 3.2 or ARB_geometry_shader4 extension is available. */ public static boolean isGeometryShaderSupported(GL _gl) { final GLContext ctx = _gl.getContext(); return ctx.getGLVersionNumber().compareTo(GLContext.Version320) >= 0 || @@ -240,7 +240,7 @@ public class ShaderUtil { IntBuffer lengths = Buffers.newDirectIntBuffer(count); for(int i=0; i shaderBinaryFormats = null; - } + } private static ProfileInformation getProfileInformation(GL gl) { final GLContext context = gl.getContext(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java index a653bd467..2f8884a3a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java @@ -24,13 +24,13 @@ import com.jogamp.opengl.util.PMVMatrix; public class FixedFuncUtil { /** * @param gl - * @param mode one of the {@link ShaderSelectionMode}s + * @param mode one of the {@link ShaderSelectionMode}s * @param pmvMatrix optional pass through PMVMatrix for the {@link FixedFuncHook} and {@link FixedFuncPipeline} * @return If gl is a GL2ES1 and force is false, return the type cast object, * otherwise create a fixed function emulation pipeline using the given GL2ES2 impl * and hook it to the GLContext via {@link GLContext#setGL(GL)}. * @throws GLException if the GL object is neither GL2ES1 nor GL2ES2 - * + * * @see ShaderSelectionMode#AUTO * @see ShaderSelectionMode#COLOR * @see ShaderSelectionMode#COLOR_LIGHT_PER_VERTEX @@ -53,13 +53,13 @@ public class FixedFuncUtil { /** * @param gl - * @param mode one of the {@link ShaderSelectionMode}s + * @param mode one of the {@link ShaderSelectionMode}s * @param pmvMatrix optional pass through PMVMatrix for the {@link FixedFuncHook} and {@link FixedFuncPipeline} * @return If gl is a GL2ES1, return the type cast object, * otherwise create a fixed function emulation pipeline using the GL2ES2 impl. * and hook it to the GLContext via {@link GLContext#setGL(GL)}. * @throws GLException if the GL object is neither GL2ES1 nor GL2ES2 - * + * * @see ShaderSelectionMode#AUTO * @see ShaderSelectionMode#COLOR * @see ShaderSelectionMode#COLOR_LIGHT_PER_VERTEX @@ -71,11 +71,11 @@ public class FixedFuncUtil { } /** - * Mapping fixed function (client) array indices to + * Mapping fixed function (client) array indices to * GLSL array attribute names. * * Useful for uniq mapping of canonical array index names as listed. - * + * * @see #mgl_Vertex * @see javax.media.opengl.fixedfunc.GLPointerFunc#GL_VERTEX_ARRAY * @see #mgl_Normal diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/ShaderSelectionMode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/ShaderSelectionMode.java index e6bdf702c..426fb0d85 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/ShaderSelectionMode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/ShaderSelectionMode.java @@ -1,8 +1,8 @@ package com.jogamp.opengl.util.glsl.fixedfunc; -/** +/** * Shader selection mode - * + * * @see ShaderSelectionMode#AUTO * @see ShaderSelectionMode#COLOR * @see ShaderSelectionMode#COLOR_LIGHT_PER_VERTEX @@ -11,17 +11,17 @@ package com.jogamp.opengl.util.glsl.fixedfunc; */ public enum ShaderSelectionMode { /** Auto shader selection, based upon FFP states. */ - AUTO, + AUTO, /** Fixed shader selection: Simple color. */ - COLOR, + COLOR, /** Fixed shader selection: Multi-Textured color. 2 texture units. */ - COLOR_TEXTURE2, + COLOR_TEXTURE2, /** Fixed shader selection: Multi-Textured color. 4 texture units. */ - COLOR_TEXTURE4, + COLOR_TEXTURE4, /** Fixed shader selection: Multi-Textured color. 8 texture units. */ - COLOR_TEXTURE8, + COLOR_TEXTURE8, /** Fixed shader selection: Color with vertex-lighting. */ - COLOR_LIGHT_PER_VERTEX, + COLOR_LIGHT_PER_VERTEX, /** Fixed shader selection: Multi-Textured color with vertex-lighting. 8 texture units.*/ - COLOR_TEXTURE8_LIGHT_PER_VERTEX + COLOR_TEXTURE8_LIGHT_PER_VERTEX } \ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java index a5b1c6687..9573ea5c3 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java @@ -55,8 +55,8 @@ public abstract class CompileShader { URL resourceURL = IOUtil.getResource(null, resourceName).getURL(); String dirName = dirname(resourceURL.getPath()); - outName = dirName + File.separator + "bin" + File.separator + - ShaderCode.getBinarySubPath(getBinaryFormat()) + File.separator + + outName = dirName + File.separator + "bin" + File.separator + + ShaderCode.getBinarySubPath(getBinaryFormat()) + File.separator + outName; processOneShader(resourceName, outName, type); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/BackingStoreManager.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/BackingStoreManager.java index 7b6a1b479..c1b5025f8 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/BackingStoreManager.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/BackingStoreManager.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2006 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/Level.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/Level.java index 5ba3f7330..44b4fea9e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/Level.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/Level.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2006 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -128,7 +128,7 @@ public class Level { candidate.setSize(candidate.w() - rect.w(), height); freeList.add(candidate); } - + coalesceFreeList(); return true; diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/LevelSet.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/LevelSet.java index 6783aec3b..e14eef5ba 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/LevelSet.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/LevelSet.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2006 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -108,7 +108,7 @@ public class LevelSet { if (level.remove(rect)) return true; } - + return false; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/Rect.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/Rect.java index 6206c4a11..23f143b83 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/Rect.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/Rect.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2006 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -72,7 +72,7 @@ public class Rect { // there is no room left due either to fragmentation or just being // out of space) private Rect nextLocation; - + public Rect() { this(null); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/RectVisitor.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/RectVisitor.java index 49cfc82e6..5db216742 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/RectVisitor.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/RectVisitor.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2006 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java index 1496a04a6..a9d609745 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2006 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -203,7 +203,7 @@ public class RectanglePacker { } nextLevelSet = new LevelSet(newWidth, newHeight); - + // Make copies of all existing rectangles List/**/ newRects = new ArrayList/**/(); for (Iterator i1 = levels.iterator(); i1.hasNext(); ) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java index 4236e22fb..fd026d76e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -53,8 +53,8 @@ import com.jogamp.opengl.util.texture.spi.*; * for enabling/disabling OpenGL texture state, binding this texture, * and computing texture coordinates for both the entire image as well * as a sub-image. - * - *

    Order of Texture Commands
    + * + *
    Order of Texture Commands
    *

    * Due to many confusions w/ texture usage, following list described the order * and semantics of texture unit selection, binding and enabling. @@ -67,16 +67,16 @@ import com.jogamp.opengl.util.texture.spi.*; *

  • Issue draw commands
  • * *

    - * + * *

    Non-power-of-two restrictions *
    When creating an OpenGL texture object, the Texture class will * attempt to use non-power-of-two textures (NPOT) if available, see {@link GL#isNPOTTextureAvailable()}. - * Further more, + * Further more, * GL_ARB_texture_rectangle * (RECT) will be attempted on OSX w/ ATI drivers. * If NPOT is not available or RECT not chosen, the Texture class will simply upload a non-pow2-sized * image into a standard pow2-sized texture (without any special - * scaling). + * scaling). * Since the choice of extension (or whether one is used at * all) depends on the user's machine configuration, developers are * recommended to use {@link #getImageTexCoords} and {@link @@ -106,7 +106,7 @@ import com.jogamp.opengl.util.texture.spi.*; * #bind}, but when drawing many triangles all using the same texture, * for best performance only one call to {@link #bind} should be made. * User may also utilize multiple texture units, - * see order of texture commands above. + * see order of texture commands above. * *

    Alpha premultiplication and blending *

    @@ -119,7 +119,7 @@ import com.jogamp.opengl.util.texture.spi.*; *

    * The mathematically correct way to perform blending in OpenGL * with the SrcOver "source over destination" mode, or any other - * Porter-Duff rule, is to use premultiplied color components, + * Porter-Duff rule, is to use premultiplied color components, * which means the R/G/ B color components must have been multiplied by * the alpha value. If using premultiplied color components * it is important to use the correct blending function; for @@ -137,7 +137,7 @@ import com.jogamp.opengl.util.texture.spi.*; float g = g * a; float b = b * a; gl.glColor4f(r, g, b, a); - + * * For reference, here is a list of the Porter-Duff compositing rules * and the associated OpenGL blend functions (source and destination @@ -187,8 +187,8 @@ public class Texture { /** The texture coordinates corresponding to the entire image. */ private TextureCoords coords; - - public String toString() { + + public String toString() { return "Texture[target 0x"+Integer.toHexString(target)+", name "+texID+", "+ imgWidth+"/"+texWidth+" x "+imgHeight+"/"+texHeight+", y-flip "+mustFlipVertically+ ", "+estimatedMemorySize+" bytes]"; @@ -237,7 +237,7 @@ public class Texture { * gl.glEnable(texture.getTarget()); * *

    - * Call is ignored if the {@link GL} object's context + * Call is ignored if the {@link GL} object's context * is using a core profile, see {@link GL#isGLcore()}, * or if {@link #getTarget()} is {@link GLES2#GL_TEXTURE_EXTERNAL_OES}. *

    @@ -255,7 +255,7 @@ public class Texture { gl.glEnable(target); } } - + /** * Disables this texture's target (e.g., GL_TEXTURE_2D) in the * given GL state. This method is a shorthand equivalent @@ -264,7 +264,7 @@ public class Texture { * gl.glDisable(texture.getTarget()); * *

    - * Call is ignored if the {@link GL} object's context + * Call is ignored if the {@link GL} object's context * is using a core profile, see {@link GL#isGLcore()}, * or if {@link #getTarget()} is {@link GLES2#GL_TEXTURE_EXTERNAL_OES}. *

    @@ -282,7 +282,7 @@ public class Texture { gl.glDisable(target); } } - + /** * Binds this texture to the given GL context. This method is a * shorthand equivalent of the following OpenGL code: @@ -292,16 +292,16 @@ public class Texture { * * See the performance tips above for hints * on how to maximize performance when using many Texture objects. - * + * * @param gl the current GL context * @throws GLException if no OpenGL context was current or if any * OpenGL-related errors occurred */ public void bind(GL gl) throws GLException { validateTexID(gl, true); - gl.glBindTexture(target, texID); + gl.glBindTexture(target, texID); } - + /** * Destroys the native resources used by this texture object. * @@ -335,7 +335,7 @@ public class Texture { public int getWidth() { return texWidth; } - + /** * Returns the height of the allocated OpenGL texture in pixels. * Note that the texture height will be greater than or equal to the @@ -345,9 +345,9 @@ public class Texture { */ public int getHeight() { return texHeight; - } - - /** + } + + /** * Returns the width of the image contained within this texture. * Note that for non-power-of-two textures in particular this may * not be equal to the result of {@link #getWidth}. It is @@ -389,7 +389,7 @@ public class Texture { * entire image. If the TextureData indicated that the texture * coordinates must be flipped vertically, the returned * TextureCoords will take that into account. - * + * * @return the texture coordinates corresponding to the entire image */ public TextureCoords getImageTexCoords() { @@ -406,7 +406,7 @@ public class Texture { * flipped vertically, the returned TextureCoords will take that * into account; this should not be handled by the end user in the * specification of the y1 and y2 coordinates. - * + * * @return the texture coordinates corresponding to the specified sub-image */ public TextureCoords getSubImageTexCoords(int x1, int y1, int x2, int y2) { @@ -431,9 +431,9 @@ public class Texture { } /** - * Updates the entire content area incl. {@link TextureCoords} + * Updates the entire content area incl. {@link TextureCoords} * of this texture using the data in the given image. - * + * * @throws GLException if any OpenGL-related errors occurred */ public void updateImage(GL gl, TextureData data) throws GLException { @@ -465,12 +465,12 @@ public class Texture { updateTexCoords(); } } - + /** * Updates the content area incl. {@link TextureCoords} of the specified target of this texture * using the data in the given image. In general this is intended * for construction of cube maps. - * + * * @throws GLException if any OpenGL-related errors occurred */ public void updateImage(GL gl, TextureData data, int targetOverride) throws GLException { @@ -791,7 +791,7 @@ public class Texture { * texture's target. This gives control over parameters such as * GL_TEXTURE_MAX_ANISOTROPY_EXT. Causes this texture to be bound to * the current texture state. - * + * * @throws GLException if no OpenGL context was current or if any * OpenGL-related errors occurred */ @@ -805,7 +805,7 @@ public class Texture { * Sets the OpenGL multi-floating-point texture parameter for the * texture's target. Causes this texture to be bound to the current * texture state. - * + * * @throws GLException if any OpenGL-related errors occurred */ public void setTexParameterfv(GL gl, int parameterName, @@ -818,7 +818,7 @@ public class Texture { * Sets the OpenGL multi-floating-point texture parameter for the * texture's target. Causes this texture to be bound to the current * texture state. - * + * * @throws GLException if any OpenGL-related errors occurred */ public void setTexParameterfv(GL gl, int parameterName, @@ -834,7 +834,7 @@ public class Texture { * to GL_CLAMP_TO_EDGE if OpenGL 1.2 is supported on the current * platform and GL_CLAMP if not. Causes this texture to be bound to * the current texture state. - * + * * @throws GLException if any OpenGL-related errors occurred */ public void setTexParameteri(GL gl, int parameterName, @@ -847,7 +847,7 @@ public class Texture { * Sets the OpenGL multi-integer texture parameter for the texture's * target. Causes this texture to be bound to the current texture * state. - * + * * @throws GLException if any OpenGL-related errors occurred */ public void setTexParameteriv(GL gl, int parameterName, @@ -860,7 +860,7 @@ public class Texture { * Sets the OpenGL multi-integer texture parameter for the texture's * target. Causes this texture to be bound to the current texture * state. - * + * * @throws GLException if any OpenGL-related errors occurred */ public void setTexParameteriv(GL gl, int parameterName, @@ -886,7 +886,7 @@ public class Texture { } /** - * Returns the underlying OpenGL texture object for this texture, + * Returns the underlying OpenGL texture object for this texture, * maybe 0 if not yet generated. *

    * Most applications will not need to access this, since it is @@ -967,19 +967,19 @@ public class Texture { } } else { if (mustFlipVertically) { - coords = new TextureCoords(0, // l + coords = new TextureCoords(0, // l (float) imgHeight / (float) texHeight, // b (float) imgWidth / (float) texWidth, // r 0 // t ); } else { - coords = new TextureCoords(0, // l + coords = new TextureCoords(0, // l 0, // b (float) imgWidth / (float) texWidth, // r (float) imgHeight / (float) texHeight // t ); } - } + } } private void updateSubImageImpl(GL gl, TextureData data, int newTarget, int mipmapLevel, diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java index 3931b7290..63f100630 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2012 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -77,7 +77,7 @@ public class TextureCoords { d[6+d_off] = right *ss; d[7+d_off] = top *ts; return d; } - + /** Returns the leftmost (x) texture coordinate of this rectangle. */ public float left() { return left; } @@ -93,6 +93,6 @@ public class TextureCoords { /** Returns the topmost (y) texture coordinate of this rectangle. */ public float top() { return top; } - + public String toString() { return "TexCoord[h: "+left+" - "+right+", v: "+bottom+" - "+top+"]"; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java index afc5bf70c..28029efc5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -57,8 +57,8 @@ import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; public class TextureData { /** ColorSpace of pixel data. */ - public static enum ColorSpace { RGB, YCbCr, YCCK, CMYK }; - + public static enum ColorSpace { RGB, YCbCr, YCCK, CMYK }; + protected int width; protected int height; private int border; @@ -83,7 +83,7 @@ public class TextureData { protected GLProfile glProfile; protected ColorSpace pixelCS = ColorSpace.RGB; - /** + /** * Constructs a new TextureData object with the specified parameters * and data contained in the given Buffer. The optional Flusher can * be used to clean up native resources associated with this @@ -123,7 +123,7 @@ public class TextureData { * data were invalid, such as requesting mipmap generation for a * compressed texture */ - public TextureData(GLProfile glp, + public TextureData(GLProfile glp, int internalFormat, int width, int height, @@ -135,11 +135,11 @@ public class TextureData { boolean mustFlipVertically, Buffer buffer, Flusher flusher) throws IllegalArgumentException { - this(glp, internalFormat, width, height, border, new GLPixelAttributes(pixelFormat, pixelType), + this(glp, internalFormat, width, height, border, new GLPixelAttributes(pixelFormat, pixelType), mipmap, dataIsCompressed, mustFlipVertically, buffer, flusher); } - /** + /** * Constructs a new TextureData object with the specified parameters * and data contained in the given Buffer. The optional Flusher can * be used to clean up native resources associated with this @@ -178,7 +178,7 @@ public class TextureData { * data were invalid, such as requesting mipmap generation for a * compressed texture */ - public TextureData(GLProfile glp, + public TextureData(GLProfile glp, int internalFormat, int width, int height, @@ -207,8 +207,8 @@ public class TextureData { alignment = 1; // FIXME: is this correct enough in all situations? estimatedMemorySize = estimatedMemorySize(buffer); } - - /** + + /** * Constructs a new TextureData object with the specified parameters * and data for multiple mipmap levels contained in the given array * of Buffers. The optional Flusher can be used to clean up native @@ -258,11 +258,11 @@ public class TextureData { boolean mustFlipVertically, Buffer[] mipmapData, Flusher flusher) throws IllegalArgumentException { - this(glp, internalFormat, width, height, border, new GLPixelAttributes(pixelFormat, pixelType), + this(glp, internalFormat, width, height, border, new GLPixelAttributes(pixelFormat, pixelType), dataIsCompressed, mustFlipVertically, mipmapData, flusher); } - /** + /** * Constructs a new TextureData object with the specified parameters * and data for multiple mipmap levels contained in the given array * of Buffers. The optional Flusher can be used to clean up native @@ -325,19 +325,19 @@ public class TextureData { estimatedMemorySize += estimatedMemorySize(mipmapData[i]); } } - - /** + + /** * Returns the color space of the pixel data. - * @see #setColorSpace(ColorSpace) + * @see #setColorSpace(ColorSpace) */ public ColorSpace getColorSpace() { return pixelCS; } - /** + /** * Set the color space of the pixel data, which defaults to {@link ColorSpace#RGB}. - * @see #getColorSpace() + * @see #getColorSpace() */ public void setColorSpace(ColorSpace cs) { pixelCS = cs; } - + /** Used only by subclasses */ protected TextureData(GLProfile glp) { this.glProfile = glp; this.pixelAttributes = GLPixelAttributes.UNDEF; } @@ -346,8 +346,8 @@ public class TextureData { /** Returns the height in pixels of the texture data. */ public int getHeight() { return height; } /** Returns the border in pixels of the texture data. */ - public int getBorder() { - return border; + public int getBorder() { + return border; } /** Returns the intended OpenGL {@link GLPixelAttributes} of the texture data, i.e. format and type. */ public GLPixelAttributes getPixelAttributes() { @@ -362,21 +362,21 @@ public class TextureData { return pixelAttributes.type; } /** Returns the intended OpenGL internal format of the texture data. */ - public int getInternalFormat() { - return internalFormat; + public int getInternalFormat() { + return internalFormat; } /** Returns whether mipmaps should be generated for the texture data. */ - public boolean getMipmap() { - return mipmap; + public boolean getMipmap() { + return mipmap; } /** Indicates whether the texture data is in compressed form. */ - public boolean isDataCompressed() { - return dataIsCompressed; + public boolean isDataCompressed() { + return dataIsCompressed; } /** Indicates whether the texture coordinates must be flipped vertically for proper display. */ - public boolean getMustFlipVertically() { - return mustFlipVertically; + public boolean getMustFlipVertically() { + return mustFlipVertically; } /** Returns the texture data, or null if it is specified as a set of mipmaps. */ public Buffer getBuffer() { @@ -384,18 +384,18 @@ public class TextureData { } /** Returns all mipmap levels for the texture data, or null if it is specified as a single image. */ - public Buffer[] getMipmapData() { - return mipmapData; + public Buffer[] getMipmapData() { + return mipmapData; } /** Returns the required byte alignment for the texture data. */ - public int getAlignment() { - return alignment; + public int getAlignment() { + return alignment; } /** Returns the row length needed for correct GL_UNPACK_ROW_LENGTH specification. This is currently only supported for non-mipmapped, non-compressed textures. */ - public int getRowLength() { - return rowLength; + public int getRowLength() { + return rowLength; } /** Sets the width in pixels of the texture data. */ @@ -405,25 +405,25 @@ public class TextureData { /** Sets the border in pixels of the texture data. */ public void setBorder(int border) { this.border = border; } /** Sets the intended OpenGL pixel format of the texture data. */ - public void setPixelAttributes(GLPixelAttributes pixelAttributes) { this.pixelAttributes = pixelAttributes; } - /** + public void setPixelAttributes(GLPixelAttributes pixelAttributes) { this.pixelAttributes = pixelAttributes; } + /** * Sets the intended OpenGL pixel format component of {@link GLPixelAttributes} of the texture data. *

    - * Use {@link #setPixelAttributes(GLPixelAttributes)}, if setting format and type. - *

    + * Use {@link #setPixelAttributes(GLPixelAttributes)}, if setting format and type. + *

    */ public void setPixelFormat(int pixelFormat) { if( pixelAttributes.format != pixelFormat ) { pixelAttributes = new GLPixelAttributes(pixelFormat, pixelAttributes.type); } } - /** + /** * Sets the intended OpenGL pixel type component of {@link GLPixelAttributes} of the texture data. *

    - * Use {@link #setPixelAttributes(GLPixelAttributes)}, if setting format and type. - *

    + * Use {@link #setPixelAttributes(GLPixelAttributes)}, if setting format and type. + *

    */ - public void setPixelType(int pixelType) { + public void setPixelType(int pixelType) { if( pixelAttributes.type != pixelType) { pixelAttributes = new GLPixelAttributes(pixelAttributes.format, pixelType); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java index 3748cd336..b6d89d6d2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2011 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -161,11 +161,11 @@ public class TextureIO { /** Constant which can be used as a file suffix to indicate a PAM file, NetPbm magic 7 - binary RGB and RGBA. Write support only. */ public static final String PAM = "pam"; - + /** Constant which can be used as a file suffix to indicate a PAM file, NetPbm magic 6 - binary RGB. Write support only. */ public static final String PPM = "ppm"; - + private static final boolean DEBUG = Debug.debug("TextureIO"); // For manually disabling the use of the texture rectangle @@ -421,7 +421,7 @@ public class TextureIO { // methods that *do* require a current context // - /** + /** * Creates an OpenGL texture object from the specified TextureData * using the current OpenGL context. * @@ -434,7 +434,7 @@ public class TextureIO { return newTexture(GLContext.getCurrentGL(), data); } - /** + /** * Creates an OpenGL texture object from the specified TextureData * using the given OpenGL context. * @@ -449,8 +449,8 @@ public class TextureIO { } return new Texture(gl, data); } - - /** + + /** * Creates an OpenGL texture object from the specified file using * the current OpenGL context. * @@ -474,7 +474,7 @@ public class TextureIO { return texture; } - /** + /** * Creates an OpenGL texture object from the specified stream using * the current OpenGL context. * @@ -503,7 +503,7 @@ public class TextureIO { return texture; } - /** + /** * Creates an OpenGL texture object from the specified URL using the * current OpenGL context. * @@ -535,13 +535,13 @@ public class TextureIO { return texture; } - /** + /** * Creates an OpenGL texture object associated with the given OpenGL * texture target. The texture has * no initial data. This is used, for example, to construct cube * maps out of multiple TextureData objects. * - * @param target the OpenGL target type, eg GL.GL_TEXTURE_2D, + * @param target the OpenGL target type, eg GL.GL_TEXTURE_2D, * GL.GL_TEXTURE_RECTANGLE_ARB */ public static Texture newTexture(int target) { @@ -556,7 +556,7 @@ public class TextureIO { * undefined results. * * @param textureID the OpenGL texture object to wrap - * @param target the OpenGL texture target, eg GL.GL_TEXTURE_2D, + * @param target the OpenGL texture target, eg GL.GL_TEXTURE_2D, * GL2.GL_TEXTURE_RECTANGLE * @param texWidth the width of the texture in pixels * @param texHeight the height of the texture in pixels @@ -689,7 +689,7 @@ public class TextureIO { gl.glPixelStorei(GL2.GL_PACK_SKIP_ROWS, packSkipRows); gl.glPixelStorei(GL2.GL_PACK_SKIP_PIXELS, packSkipPixels); gl.glPixelStorei(GL2.GL_PACK_SWAP_BYTES, packSwapBytes); - + data = new TextureData(gl.getGLProfile(), internalFormat, width, height, border, fetchedFormat, GL.GL_UNSIGNED_BYTE, false, false, false, res, null); @@ -701,7 +701,7 @@ public class TextureIO { write(data, file); } - + public static void write(TextureData data, File file) throws IOException, GLException { for (Iterator iter = textureWriters.iterator(); iter.hasNext(); ) { TextureWriter writer = iter.next(); @@ -712,12 +712,12 @@ public class TextureIO { throw new IOException("No suitable texture writer found for "+file.getAbsolutePath()); } - + //---------------------------------------------------------------------- // SPI support // - /** + /** * Adds a TextureProvider to support reading of a new file format. *

    * The last provider added, will be the first provider to be tested. @@ -730,7 +730,7 @@ public class TextureIO { textureProviders.add(0, provider); } - /** + /** * Adds a TextureWriter to support writing of a new file format. *

    * The last provider added, will be the first provider to be tested. @@ -779,7 +779,7 @@ public class TextureIO { private static List textureProviders = new ArrayList(); private static List textureWriters = new ArrayList(); - static { + static { // ImageIO provider, the fall-back, must be the first one added if(GLProfile.isAWTAvailable()) { try { @@ -1221,7 +1221,7 @@ public class TextureIO { return null; } } - + //---------------------------------------------------------------------- // DDS texture writer // @@ -1249,7 +1249,7 @@ public class TextureIO { case GL.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: d3dFormat = DDSImage.D3DFMT_DXT5; break; default: throw new IOException("Unsupported pixel format 0x" + Integer.toHexString(pixelFormat) + " by DDS writer"); } - + ByteBuffer[] mipmaps = null; if (data.getMipmapData() != null) { mipmaps = new ByteBuffer[data.getMipmapData().length]; @@ -1319,7 +1319,7 @@ public class TextureIO { //---------------------------------------------------------------------- // TGA (Targa) texture writer - + static class TGATextureWriter implements TextureWriter { public boolean write(File file, TextureData data) throws IOException { @@ -1329,19 +1329,19 @@ public class TextureIO { final int pixelFormat = pixelAttribs.format; final int pixelType = pixelAttribs.type; if ((pixelFormat == GL.GL_RGB || - pixelFormat == GL.GL_RGBA || + pixelFormat == GL.GL_RGBA || pixelFormat == GL2.GL_BGR || pixelFormat == GL.GL_BGRA ) && (pixelType == GL.GL_BYTE || pixelType == GL.GL_UNSIGNED_BYTE)) { - + ByteBuffer buf = (ByteBuffer) data.getBuffer(); if (null == buf) { buf = (ByteBuffer) data.getMipmapData()[0]; } buf.rewind(); - - if( pixelFormat == GL.GL_RGB || pixelFormat == GL.GL_RGBA ) { + + if( pixelFormat == GL.GL_RGB || pixelFormat == GL.GL_RGBA ) { // Must reverse order of red and blue channels to get correct results int skip = ((pixelFormat == GL.GL_RGB) ? 3 : 4); for (int i = 0; i < buf.remaining(); i += skip) { @@ -1364,12 +1364,12 @@ public class TextureIO { } return false; - } + } } //---------------------------------------------------------------------- // PNG texture writer - + static class PNGTextureWriter implements TextureWriter { public boolean write(File file, TextureData data) throws IOException { if (PNG.equals(IOUtil.getFileSuffix(file))) { @@ -1402,13 +1402,13 @@ public class TextureIO { break; } if ( ( 1 == bytesPerPixel || 3 == bytesPerPixel || 4 == bytesPerPixel) && - ( pixelType == GL.GL_BYTE || pixelType == GL.GL_UNSIGNED_BYTE)) { + ( pixelType == GL.GL_BYTE || pixelType == GL.GL_UNSIGNED_BYTE)) { ByteBuffer buf = (ByteBuffer) data.getBuffer(); if (null == buf) { buf = (ByteBuffer) data.getMipmapData()[0]; } buf.rewind(); - + PNGImage image = PNGImage.createFromData(data.getWidth(), data.getHeight(), -1f, -1f, bytesPerPixel, reversedChannels, !data.getMustFlipVertically(), buf); image.write(file, true); @@ -1418,9 +1418,9 @@ public class TextureIO { " / type 0x"+Integer.toHexString(pixelFormat)+" (only GL_RGB/A, GL_BGR/A + bytes)"); } return false; - } + } } - + //---------------------------------------------------------------------- // Helper routines // diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index 5c6b63535..e4f72abf0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -36,26 +36,26 @@ import com.jogamp.opengl.util.TimeFrameI; /** * Protocol for texture sequences, like animations, movies, etc. *

    - * Ensure to respect the texture coordinates provided by + * Ensure to respect the texture coordinates provided by * {@link TextureFrame}.{@link TextureFrame#getTexture() getTexture()}.{@link Texture#getImageTexCoords() getImageTexCoords()}. *

    - * The user's shader shall be fitted for this implementation. + * The user's shader shall be fitted for this implementation. * Assuming we use a base shader code w/o headers using
    ShaderCode
    . * (Code copied from unit test / demo TexCubeES2) *
    - * 
    + *
         static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" };
         static final String gl2_prelude = "#version 110\n";
         static final String shaderBasename = "texsequence_xxx";  // the base shader code w/o headers
    -    static final String myTextureLookupName = "myTexture2D"; // the desired texture lookup function    
    -    
    +    static final String myTextureLookupName = "myTexture2D"; // the desired texture lookup function
    +
         private void initShader(GL2ES2 gl, TextureSequence texSeq) {
             // Create & Compile the shader objects
    -        ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TexCubeES2.class, 
    +        ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TexCubeES2.class,
                                                 "shader", "shader/bin", shaderBasename, true);
    -        ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TexCubeES2.class, 
    +        ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TexCubeES2.class,
                                                 "shader", "shader/bin", shaderBasename, true);
    -        
    +
             // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ]
             int rsFpPos;
             if(gl.isGLES2()) {
    @@ -72,25 +72,25 @@ import com.jogamp.opengl.util.TimeFrameI;
             if(gl.isGLES2()) {
                 // insert ES2 default precision declaration
                 rsFpPos = rsFp.insertShaderSource(0, rsFpPos, es2_prelude[1]);
    -        }        
    +        }
             // negotiate the texture lookup function name
             final String texLookupFuncName = texSeq.getTextureLookupFunctionName(myTextureLookupName);
    -        
    -        // in case a fixed lookup function is being chosen, replace the name in our code        
    +
    +        // in case a fixed lookup function is being chosen, replace the name in our code
             rsFp.replaceInShaderSource(myTextureLookupName, texLookupFuncName);
    -        
    +
             // Cache the TextureSequence shader details in StringBuilder:
             final StringBuilder sFpIns = new StringBuilder();
    -        
    +
             // .. declaration of the texture sampler using the implementation specific type
             sFpIns.append("uniform ").append(texSeq.getTextureSampler2DType()).append(" mgl_ActiveTexture;\n");
    -        
    +
             // .. the actual texture lookup function, maybe null in case a built-in function is being used
             sFpIns.append(texSeq.getTextureLookupFragmentShaderImpl());
    -        
    +
             // Now insert the TextureShader details in our shader after the given tag:
             rsFp.insertShaderSource(0, "TEXTURE-SEQUENCE-CODE-BEGIN", 0, sFpIns);
    -        
    +
             // Create & Link the shader program
             ShaderProgram sp = new ShaderProgram();
             sp.add(rsVp);
    @@ -102,16 +102,16 @@ import com.jogamp.opengl.util.TimeFrameI;
      * 
    * The above procedure might look complicated, however, it allows most flexibility and * workarounds to also deal with GLSL bugs. - * + * */ public interface TextureSequence { public static final String GL_OES_EGL_image_external_Required_Prelude = "#extension GL_OES_EGL_image_external : enable\n"; public static final String samplerExternalOES = "samplerExternalOES"; public static final String sampler2D = "sampler2D"; - - /** + + /** * Texture holder interface, maybe specialized by implementation - * to associated related data. + * to associated related data. */ public static class TextureFrame extends TimeFrameI { public TextureFrame(Texture t, int pts, int duration) { @@ -121,9 +121,9 @@ public interface TextureSequence { public TextureFrame(Texture t) { texture = t; } - + public final Texture getTexture() { return texture; } - + public String toString() { return "TextureFrame[pts " + pts + " ms, l " + duration + " ms, texID "+ (null != texture ? texture.getTextureObject() : 0) + "]"; } @@ -139,30 +139,30 @@ public interface TextureSequence { *

    * Further more, the call may happen off-thread, possibly holding another, possibly shared, OpenGL context current. *

    - * Hence a user shall not issue any OpenGL, time consuming + * Hence a user shall not issue any OpenGL, time consuming * or {@link TextureSequence} lifecycle operations directly.
    * Instead, the user shall: *
      *
    • issue commands off-thread via spawning off another thread, or
    • *
    • injecting {@link GLRunnable} objects via {@link GLAutoDrawable#invoke(boolean, GLRunnable)}, or
    • *
    • simply changing a volatile state of their {@link GLEventListener} implementation.
    • - *
    + * *

    * */ public interface TexSeqEventListener { - /** + /** * Signaling listeners that a new {@link TextureFrame} is available. *

    - * User shall utilize {@link TextureSequence#getNextTexture(GL)} to dequeue it to maintain - * a consistent queue. + * User shall utilize {@link TextureSequence#getNextTexture(GL)} to dequeue it to maintain + * a consistent queue. *

    - * @param ts the event source + * @param ts the event source * @param newFrame the newly enqueued frame - * @param when system time in msec. + * @param when system time in msec. **/ public void newFrameAvailable(T ts, TextureFrame newFrame, long when); } - + /** Return the texture unit used to render the current frame. */ public int getTextureUnit(); @@ -174,17 +174,17 @@ public interface TextureSequence { * Returns the last updated texture. *

    * In case the instance is just initialized, it shall return a TextureFrame - * object with valid attributes. The texture content may be undefined + * object with valid attributes. The texture content may be undefined * until the first call of {@link #getNextTexture(GL)}.
    - *

    + *

    * Not blocking. - * - * @throws IllegalStateException if instance is not initialized + * + * @throws IllegalStateException if instance is not initialized */ public TextureFrame getLastTexture() throws IllegalStateException ; /** - * Returns the next texture to be rendered. + * Returns the next texture to be rendered. *

    * Implementation shall return the next frame if available, may block if a next frame may arrive soon. * Otherwise implementation shall return the last frame. @@ -192,41 +192,41 @@ public interface TextureSequence { *

    * Shall return null in case no next or last frame is available. *

    - * - * @throws IllegalStateException if instance is not initialized + * + * @throws IllegalStateException if instance is not initialized */ public TextureFrame getNextTexture(GL gl) throws IllegalStateException ; - + /** - * In case a shader extension is required, based on the implementation + * In case a shader extension is required, based on the implementation * and the runtime GL profile, this method returns the preprocessor macros, e.g.: *
          * #extension GL_OES_EGL_image_external : enable
    -     * 
    - * - * @throws IllegalStateException if instance is not initialized + * + * + * @throws IllegalStateException if instance is not initialized */ public String getRequiredExtensionsShaderStub() throws IllegalStateException ; - - /** + + /** * Returns either sampler2D or samplerExternalOES - * depending on {@link #getLastTexture()}.{@link TextureFrame#getTexture() getTexture()}.{@link Texture#getTarget() getTarget()}. - * - * @throws IllegalStateException if instance is not initialized + * depending on {@link #getLastTexture()}.{@link TextureFrame#getTexture() getTexture()}.{@link Texture#getTarget() getTarget()}. + * + * @throws IllegalStateException if instance is not initialized **/ public String getTextureSampler2DType() throws IllegalStateException ; - + /** * @param desiredFuncName desired lookup function name. If null or ignored by the implementation, - * a build-in name is returned. + * a build-in name is returned. * @return the final lookup function name - * + * * @see {@link #getTextureLookupFragmentShaderImpl()} - * + * * @throws IllegalStateException if instance is not initialized */ public String getTextureLookupFunctionName(String desiredFuncName) throws IllegalStateException ; - + /** * Returns the complete texture2D lookup function code of type *
    @@ -239,14 +239,14 @@ public interface TextureSequence {
          * funcName can be negotiated and queried via {@link #getTextureLookupFunctionName(String)}.
          * 

    * Note: This function may return an empty string in case a build-in lookup - * function is being chosen. If the implementation desires so, + * function is being chosen. If the implementation desires so, * {@link #getTextureLookupFunctionName(String)} will ignore the desired function name * and returns the build-in lookup function name. *

    * @see #getTextureLookupFunctionName(String) * @see #getTextureSampler2DType() - * - * @throws IllegalStateException if instance is not initialized + * + * @throws IllegalStateException if instance is not initialized */ - public String getTextureLookupFragmentShaderImpl() throws IllegalStateException ; + public String getTextureLookupFragmentShaderImpl() throws IllegalStateException ; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java index 4a5d368e3..c8437d07c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java @@ -43,55 +43,55 @@ import javax.media.opengl.GLException; * - GL.GL_TEXTURE_MAG_FILTER * - GL.GL_TEXTURE_MIN_FILTER * - GL.GL_TEXTURE_WRAP_S - * - GL.GL_TEXTURE_WRAP_T + * - GL.GL_TEXTURE_WRAP_T *
    */ public class TextureState { - /** + /** * Returns the pname to query the textureTarget currently bound to the active texture-unit. *

    * Returns 0 is textureTarget is not supported. - *

    - */ + *

    + */ public static final int getTextureTargetQueryName(int textureTarget) { final int texBindQName; switch(textureTarget) { - case GL.GL_TEXTURE_2D: texBindQName = GL.GL_TEXTURE_BINDING_2D; break; - case GL.GL_TEXTURE_CUBE_MAP: texBindQName = GL.GL_TEXTURE_BINDING_CUBE_MAP; break; - case GL2ES2.GL_TEXTURE_3D: texBindQName = GL2ES2.GL_TEXTURE_BINDING_3D; break; - case GL2GL3.GL_TEXTURE_1D: texBindQName = GL2GL3.GL_TEXTURE_BINDING_1D; break; - case GL2GL3.GL_TEXTURE_1D_ARRAY: texBindQName = GL2GL3.GL_TEXTURE_BINDING_1D_ARRAY; break; - case GL2GL3.GL_TEXTURE_2D_ARRAY: texBindQName = GL2GL3.GL_TEXTURE_BINDING_2D_ARRAY; break; - case GL2GL3.GL_TEXTURE_RECTANGLE: texBindQName = GL2GL3.GL_TEXTURE_BINDING_RECTANGLE; break; - case GL2GL3.GL_TEXTURE_BUFFER: texBindQName = GL2GL3.GL_TEXTURE_BINDING_BUFFER; break; - case GL3.GL_TEXTURE_2D_MULTISAMPLE: texBindQName = GL3.GL_TEXTURE_BINDING_2D_MULTISAMPLE; break; + case GL.GL_TEXTURE_2D: texBindQName = GL.GL_TEXTURE_BINDING_2D; break; + case GL.GL_TEXTURE_CUBE_MAP: texBindQName = GL.GL_TEXTURE_BINDING_CUBE_MAP; break; + case GL2ES2.GL_TEXTURE_3D: texBindQName = GL2ES2.GL_TEXTURE_BINDING_3D; break; + case GL2GL3.GL_TEXTURE_1D: texBindQName = GL2GL3.GL_TEXTURE_BINDING_1D; break; + case GL2GL3.GL_TEXTURE_1D_ARRAY: texBindQName = GL2GL3.GL_TEXTURE_BINDING_1D_ARRAY; break; + case GL2GL3.GL_TEXTURE_2D_ARRAY: texBindQName = GL2GL3.GL_TEXTURE_BINDING_2D_ARRAY; break; + case GL2GL3.GL_TEXTURE_RECTANGLE: texBindQName = GL2GL3.GL_TEXTURE_BINDING_RECTANGLE; break; + case GL2GL3.GL_TEXTURE_BUFFER: texBindQName = GL2GL3.GL_TEXTURE_BINDING_BUFFER; break; + case GL3.GL_TEXTURE_2D_MULTISAMPLE: texBindQName = GL3.GL_TEXTURE_BINDING_2D_MULTISAMPLE; break; case GL3.GL_TEXTURE_2D_MULTISAMPLE_ARRAY: texBindQName = GL3.GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY; break; default: texBindQName = 0; } return texBindQName; } - + private final int target; - /** + /** *
          *   0 - unit
          *   1 - texture object
          *   2 - GL.GL_TEXTURE_MAG_FILTER
          *   3 - GL.GL_TEXTURE_MIN_FILTER
          *   4 - GL.GL_TEXTURE_WRAP_S
    -     *   5 - GL.GL_TEXTURE_WRAP_T            
    +     *   5 - GL.GL_TEXTURE_WRAP_T
          * 
    */ private final int[] state = new int[] { 0, 0, 0, 0, 0, 0 }; - + private static final String toHexString(int i) { return "0x"+Integer.toHexString(i); } - + private static final int activeTexture(GL gl) { final int[] vi = { 0 }; gl.glGetIntegerv(GL.GL_ACTIVE_TEXTURE, vi, 0); return vi[0]; } - + /** * Creates a texture state for the retrieved active texture-unit and the given texture-target. * See {@link TextureState}. @@ -102,7 +102,7 @@ public class TextureState { public TextureState(GL gl, int textureTarget) throws GLException { this(gl, activeTexture(gl), textureTarget); } - + /** * Creates a texture state for the given active texture-unit and the given texture-target. * See {@link TextureState}. @@ -124,7 +124,7 @@ public class TextureState { gl.glGetTexParameteriv(target, GL.GL_TEXTURE_WRAP_S, state, 4); gl.glGetTexParameteriv(target, GL.GL_TEXTURE_WRAP_T, state, 5); } - + /** * Restores the texture-unit's texture-target state. *

    @@ -140,12 +140,12 @@ public class TextureState { gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_S, state[4]); gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_T, state[5]); } - + /** Returns the texture-unit of this state, key value. Unit is of range [ {@link GL#GL_TEXTURE0}.. ]. */ public final int getUnit() { return state[0]; } /** Returns the texture-target of this state, key value. */ public final int getTarget() { return target; } - + /** Returns the state's texture-object. */ public final int getObject() { return state[1]; } /** Returns the state's mag-filter param. */ @@ -156,12 +156,12 @@ public class TextureState { public final int getWrapS() { return state[4]; } /** Returns the state's wrap-t param. */ public final int getWrapT() { return state[5]; } - - + + public final String toString() { return "TextureState[unit "+(state[0] - GL.GL_TEXTURE0)+", target "+toHexString(target)+ ": obj "+toHexString(state[1])+ - ", filter[mag "+toHexString(state[2])+", min "+toHexString(state[3])+"], "+ + ", filter[mag "+toHexString(state[2])+", min "+toHexString(state[3])+"], "+ ": wrap[s "+toHexString(state[4])+", t "+toHexString(state[5])+"]]"; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java index d7e825c1d..202c08e4e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -80,7 +80,7 @@ public class AWTTextureData extends TextureData { private static final java.awt.image.ColorModel rgbaColorModel = new ComponentColorModel(java.awt.color.ColorSpace.getInstance(java.awt.color.ColorSpace.CS_sRGB), - new int[] {8, 8, 8, 8}, true, true, + new int[] {8, 8, 8, 8}, true, true, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); private static final java.awt.image.ColorModel rgbColorModel = @@ -90,7 +90,7 @@ public class AWTTextureData extends TextureData { DataBuffer.TYPE_BYTE); - /** + /** * Constructs a new TextureData object with the specified parameters * and data contained in the given BufferedImage. The resulting * TextureData "wraps" the contents of the BufferedImage, so if a @@ -113,7 +113,7 @@ public class AWTTextureData extends TextureData { * texture * @param image the image containing the texture data */ - public AWTTextureData(GLProfile glp, + public AWTTextureData(GLProfile glp, int internalFormat, int pixelFormat, boolean mipmap, @@ -142,15 +142,15 @@ public class AWTTextureData extends TextureData { (expectingGL12 && haveGL12))) { revertPixelAttributes(); } - } + } } - + @Override public GLPixelAttributes getPixelAttributes() { validatePixelAttributes(); return super.getPixelAttributes(); } - + @Override public int getPixelFormat() { validatePixelAttributes(); @@ -246,7 +246,7 @@ public class AWTTextureData extends TextureData { // we can pass the image data directly to OpenGL only if // we have an integral number of pixels in each scanline // and only if the GL_EXT_abgr extension is present - + // NOTE: disabling this code path for now as it appears it's // buggy at least on some NVidia drivers and doesn't perform // the necessary byte swapping (FIXME: needs more @@ -255,7 +255,7 @@ public class AWTTextureData extends TextureData { pixelAttributes = new GLPixelAttributes(GL2.GL_ABGR_EXT, GL.GL_UNSIGNED_BYTE); rowLength = scanlineStride / 4; alignment = 4; - + // Store a reference to the original image for later in // case it turns out that we don't have GL_EXT_abgr at the // time we're going to do the texture upload to OpenGL diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureIO.java b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureIO.java index fdd1365f7..c70f5d0f3 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureIO.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureIO.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -100,7 +100,7 @@ public class AWTTextureIO extends TextureIO { return newTextureDataImpl(glp, image, internalFormat, pixelFormat, mipmap); } - /** + /** * Creates an OpenGL texture object from the specified BufferedImage * using the current OpenGL context. * @@ -119,7 +119,7 @@ public class AWTTextureIO extends TextureIO { return texture; } - private static TextureData newTextureDataImpl(GLProfile glp, + private static TextureData newTextureDataImpl(GLProfile glp, BufferedImage image, int internalFormat, int pixelFormat, diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java index 3f91ae966..d75bb3767 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -166,7 +166,7 @@ public class DDSImage { public static DDSImage read(String filename) throws IOException { return read(new File(filename)); } - + /** Reads a DirectDraw surface from the specified file, returning the resulting DDSImage. @@ -212,7 +212,7 @@ public class DDSImage { } } - /** + /** * Creates a new DDSImage from data supplied by the user. The * resulting DDSImage can be written to disk using the write() * method. @@ -763,7 +763,7 @@ public class DDSImage { default: throw new IllegalArgumentException("d3dFormat must be one of the known formats"); } - + // Now check the mipmaps against this size int curSize = topmostMipmapSize; int totalSize = 0; @@ -785,7 +785,7 @@ public class DDSImage { buf.put(mipmapData[i]); } this.buf = buf; - + // Allocate and initialize a Header header = new Header(); header.size = Header.size(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java index 4d3d088ba..471938754 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -40,12 +40,12 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.util.texture.TextureData.ColorSpace; public class JPEGImage { - private static final boolean DEBUG = Debug.debug("JPEGImage"); - - + private static final boolean DEBUG = Debug.debug("JPEGImage"); + + /** * Reads a JPEG image from the specified InputStream, using the given color space for storage. - * + * * @param in * @param cs Storage color space, either {@link ColorSpace#RGB} or {@link ColorSpace#YCbCr}. {@link ColorSpace#YCCK} and {@link ColorSpace#CMYK} will throw an exception! * @return @@ -54,12 +54,12 @@ public class JPEGImage { public static JPEGImage read(InputStream in, ColorSpace cs) throws IOException { return new JPEGImage(in, cs); } - + /** Reads a JPEG image from the specified InputStream, using the {@link ColorSpace#RGB}. */ public static JPEGImage read(InputStream in) throws IOException { return new JPEGImage(in, ColorSpace.RGB); } - + private static class JPEGColorSink implements JPEGDecoder.ColorSink { int width=0, height=0; int sourceComponents=0; @@ -67,7 +67,7 @@ public class JPEGImage { int storageComponents; final ColorSpace storageCS; ByteBuffer data = null; - + JPEGColorSink(ColorSpace storageCM) { this.storageCS = storageCM; switch(storageCS) { @@ -79,7 +79,7 @@ public class JPEGImage { throw new IllegalArgumentException("Unsupported storage color-space: "+storageCS); } } - + @Override public final ColorSpace allocate(int width, int height, ColorSpace sourceCM, int sourceComponents) throws RuntimeException { this.width = width; @@ -96,7 +96,7 @@ public class JPEGImage { data.put(i++, r); data.put(i++, g); data.put(i++, b); - // data.put(i++, (byte)0xff); + // data.put(i++, (byte)0xff); } @Override @@ -111,12 +111,12 @@ public class JPEGImage { data.put(i++, Cb); data.put(i++, Cr); } - + public String toString() { return "JPEGPixels["+width+"x"+height+", sourceComp "+sourceComponents+", sourceCS "+sourceCS+", storageCS "+storageCS+", storageComp "+storageComponents+"]"; } }; - + private JPEGImage(InputStream in, ColorSpace cs) throws IOException { pixelStorage = new JPEGColorSink(cs); final JPEGDecoder decoder = new JPEGDecoder(); @@ -126,7 +126,7 @@ public class JPEGImage { decoder.getPixel(pixelStorage, pixelWidth, pixelHeight); data = pixelStorage.data; final boolean hasAlpha = false; - + bytesPerPixel = 3; glFormat = GL.GL_RGB; reversedChannels = false; // RGB[A] @@ -142,7 +142,7 @@ public class JPEGImage { private final int pixelWidth, pixelHeight, glFormat, bytesPerPixel; private boolean reversedChannels; private final ByteBuffer data; - + /** Returns the color space of the pixel data */ public ColorSpace getColorSpace() { return pixelStorage.storageCS; } @@ -157,10 +157,10 @@ public class JPEGImage { /** Returns true if data has the channels reversed to BGR or BGRA, otherwise RGB or RGBA is expected. */ public boolean getHasReversedChannels() { return reversedChannels; } - + /** Returns the OpenGL format for this texture; e.g. GL.GL_LUMINANCE, GL.GL_RGB or GL.GL_RGBA. */ public int getGLFormat() { return glFormat; } - + /** Returns the OpenGL data type: GL.GL_UNSIGNED_BYTE. */ public int getGLType() { return GL.GL_UNSIGNED_BYTE; } @@ -170,6 +170,6 @@ public class JPEGImage { /** Returns the raw data for this texture in the correct (bottom-to-top) order for calls to glTexImage2D. */ public ByteBuffer getData() { return data; } - + public String toString() { return "JPEGImage["+pixelWidth+"x"+pixelHeight+", bytesPerPixel "+bytesPerPixel+", reversedChannels "+reversedChannels+", "+pixelStorage+", "+data+"]"; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java index b7262aa3e..4020ab3c0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -148,7 +148,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput } public final int readUnsignedShort() throws IOException - { + { int ch1 = dataIn.read(); int ch2 = dataIn.read(); if ((ch1 | ch2) < 0) @@ -195,7 +195,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput /** * dont call this it is not implemented. - * @return empty new string + * @return empty new string **/ public final String readLine() throws IOException { @@ -204,7 +204,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput /** * dont call this it is not implemented - * @return empty new string + * @return empty new string **/ public final String readUTF() throws IOException { @@ -213,7 +213,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput /** * dont call this it is not implemented - * @return empty new string + * @return empty new string **/ public final static String readUTF(DataInput in) throws IOException { diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java index e1e1ca924..a7101a576 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java index cd42a1157..43b8eebe6 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -87,8 +87,8 @@ public class NetPbmTextureWriter implements TextureWriter { public boolean write(File file, TextureData data) throws IOException { boolean res; final int magic_old = magic; - - // file suffix selection + + // file suffix selection if (0==magic) { if (PPM.equals(IOUtil.getFileSuffix(file))) { magic = 6; @@ -97,7 +97,7 @@ public class NetPbmTextureWriter implements TextureWriter { } else { return false; } - } + } try { res = writeImpl(file, data); } finally { @@ -105,7 +105,7 @@ public class NetPbmTextureWriter implements TextureWriter { } return res; } - + private boolean writeImpl(File file, TextureData data) throws IOException { int pixelFormat = data.getPixelFormat(); final int pixelType = data.getPixelType(); @@ -115,16 +115,16 @@ public class NetPbmTextureWriter implements TextureWriter { pixelFormat == GL.GL_BGRA ) && (pixelType == GL.GL_BYTE || pixelType == GL.GL_UNSIGNED_BYTE)) { - + ByteBuffer buf = (ByteBuffer) data.getBuffer(); if (null == buf ) { buf = (ByteBuffer) data.getMipmapData()[0]; } buf.rewind(); - + int comps = ( pixelFormat == GL.GL_RGBA || pixelFormat == GL.GL_BGRA ) ? 4 : 3 ; - - if( pixelFormat == GL2.GL_BGR || pixelFormat == GL.GL_BGRA ) { + + if( pixelFormat == GL2.GL_BGR || pixelFormat == GL.GL_BGRA ) { // Must reverse order of red and blue channels to get correct results for (int i = 0; i < buf.remaining(); i += comps) { byte red = buf.get(i + 0); @@ -141,7 +141,7 @@ public class NetPbmTextureWriter implements TextureWriter { } FileOutputStream fos = IOUtil.getFileOutputStream(file, true); - + StringBuilder header = new StringBuilder(); header.append("P"); header.append(magic); @@ -171,7 +171,7 @@ public class NetPbmTextureWriter implements TextureWriter { } fos.write(header.toString().getBytes()); - + FileChannel fosc = fos.getChannel(); fosc.write(buf); fosc.force(true); @@ -180,7 +180,7 @@ public class NetPbmTextureWriter implements TextureWriter { buf.rewind(); return true; - } + } throw new IOException("NetPbmTextureWriter writer doesn't support this pixel format / type (only GL_RGB/A + bytes)"); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java index 0f4559036..bfde1bfac 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -51,15 +51,15 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; public class PNGImage { - private static final boolean DEBUG = Debug.debug("PNGImage"); - + private static final boolean DEBUG = Debug.debug("PNGImage"); + /** * Creates a PNGImage from data supplied by the end user. Shares * data with the passed ByteBuffer. Assumes the data is already in * the correct byte order for writing to disk, i.e., LUMINANCE, RGB or RGBA. * Orientation is bottom-to-top (OpenGL coord. default) * or top-to-bottom depending on isGLOriented. - * + * * @param width * @param height * @param dpiX @@ -74,17 +74,17 @@ public class PNGImage { int bytesPerPixel, boolean reversedChannels, boolean isGLOriented, ByteBuffer data) { return new PNGImage(width, height, dpiX, dpiY, bytesPerPixel, reversedChannels, isGLOriented, data); } - - /** + + /** * Reads a PNG image from the specified InputStream. *

    * Implicitly flip image to GL orientation, see {@link #isGLOriented()}. - *

    + *

    */ public static PNGImage read(InputStream in) throws IOException { return new PNGImage(in); } - + /** Reverse read and store, implicitly flip image to GL orientation, see {@link #isGLOriented()}. */ private static final int getPixelRGBA8(ByteBuffer d, int dOff, int[] scanline, int lineOff, boolean hasAlpha) { final int b = hasAlpha ? 4-1 : 3-1; @@ -95,11 +95,11 @@ public class PNGImage { d.put(dOff--, (byte)scanline[lineOff + 3]); // A } d.put(dOff--, (byte)scanline[lineOff + 2]); // B - d.put(dOff--, (byte)scanline[lineOff + 1]); // G + d.put(dOff--, (byte)scanline[lineOff + 1]); // G d.put(dOff--, (byte)scanline[lineOff ]); // R return dOff; } - + /** Reverse write and store, implicitly flip image from current orientation, see {@link #isGLOriented()}. Handle reversed channels (BGR[A]). */ private int setPixelRGBA8(ImageLine line, int lineOff, ByteBuffer d, int dOff, boolean hasAlpha) { final int b = hasAlpha ? 4-1 : 3-1; @@ -138,9 +138,9 @@ public class PNGImage { this.bytesPerPixel = bytesPerPixel; this.reversedChannels = reversedChannels; this.isGLOriented = isGLOriented; - this.data = data; + this.data = data; } - + private PNGImage(InputStream in) { final PngReader pngr = new PngReader(new BufferedInputStream(in), null); final ImageInfo imgInfo = pngr.imgInfo; @@ -148,12 +148,12 @@ public class PNGImage { final PngChunkTRNS trns = pngr.getMetadata().getTRNS(); final boolean indexed = imgInfo.indexed; final boolean hasAlpha = indexed ? ( trns != null ) : imgInfo.alpha ; - + final int channels = indexed ? ( hasAlpha ? 4 : 3 ) : imgInfo.channels ; if ( ! ( 1 == channels || 3 == channels || 4 == channels ) ) { throw new RuntimeException("PNGImage can only handle Lum/RGB/RGBA [1/3/4 channels] images for now. Channels "+channels + " Paletted: " + indexed); } - + bytesPerPixel = indexed ? channels : imgInfo.bytesPixel ; if ( ! ( 1 == bytesPerPixel || 3 == bytesPerPixel || 4 == bytesPerPixel ) ) { throw new RuntimeException("PNGImage can only handle Lum/RGB/RGBA [1/3/4 bpp] images for now. BytesPerPixel "+bytesPerPixel); @@ -189,14 +189,14 @@ public class PNGImage { ", bytesPerPixel "+bytesPerPixel+"/"+imgInfo.bytesPixel+ ", pixels "+pixelWidth+"x"+pixelHeight+", dpi "+dpi[0]+"x"+dpi[1]+", glFormat 0x"+Integer.toHexString(glFormat)); } - + data = Buffers.newDirectByteBuffer(bytesPerPixel * pixelWidth * pixelHeight); reversedChannels = false; // RGB[A] isGLOriented = true; int dataOff = bytesPerPixel * pixelWidth * pixelHeight - 1; // start at end-of-buffer, reverse store int[] rgbaScanline = indexed ? new int[imgInfo.cols * channels] : null; - + for (int row = 0; row < pixelHeight; row++) { final ImageLine l1 = pngr.readRow(row); int lineOff = ( pixelWidth - 1 ) * bytesPerPixel ; // start w/ last pixel in line, reverse read (PNG top-left -> OpenGL bottom-left origin) @@ -224,7 +224,7 @@ public class PNGImage { private final boolean isGLOriented; private final double[] dpi; private final ByteBuffer data; - + /** Returns the width of the image. */ public int getWidth() { return pixelWidth; } @@ -233,23 +233,23 @@ public class PNGImage { /** Returns true if data has the channels reversed to BGR or BGRA, otherwise RGB or RGBA is expected. */ public boolean getHasReversedChannels() { return reversedChannels; } - + /** - * Returns true if the drawable is rendered in + * Returns true if the drawable is rendered in * OpenGL's coordinate system, origin at bottom left. * Otherwise returns false, i.e. origin at top left. *

    * Default impl. is true, i.e. OpenGL coordinate system. - *

    + *

    */ public boolean isGLOriented() { return isGLOriented; } - + /** Returns the dpi of the image. */ public double[] getDpi() { return dpi; } - + /** Returns the OpenGL format for this texture; e.g. GL.GL_LUMINANCE, GL.GL_RGB or GL.GL_RGBA. */ public int getGLFormat() { return glFormat; } - + /** Returns the OpenGL data type: GL.GL_UNSIGNED_BYTE. */ public int getGLType() { return GL.GL_UNSIGNED_BYTE; } @@ -260,12 +260,12 @@ public class PNGImage { (bottom-to-top) order for calls to glTexImage2D. */ public ByteBuffer getData() { return data; } - public void write(File out, boolean allowOverwrite) throws IOException { - final ImageInfo imi = new ImageInfo(pixelWidth, pixelHeight, 8, (4 == bytesPerPixel) ? true : false); // 8 bits per channel, no alpha + public void write(File out, boolean allowOverwrite) throws IOException { + final ImageInfo imi = new ImageInfo(pixelWidth, pixelHeight, 8, (4 == bytesPerPixel) ? true : false); // 8 bits per channel, no alpha // open image for writing to a output stream final OutputStream outs = new BufferedOutputStream(IOUtil.getFileOutputStream(out, allowOverwrite)); try { - final PngWriter png = new PngWriter(outs, imi); + final PngWriter png = new PngWriter(outs, imi); // add some optional metadata (chunks) png.getMetadata().setDpi(dpi[0], dpi[1]); png.getMetadata().setTimeNow(0); // 0 seconds fron now = now @@ -275,7 +275,7 @@ public class PNGImage { final ImageLine l1 = new ImageLine(imi); if( isGLOriented ) { // start at last pixel at end-of-buffer, reverse read (OpenGL bottom-left -> PNG top-left origin) - int dataOff = ( pixelWidth * bytesPerPixel * ( pixelHeight - 1 ) ) + // full lines - 1 line + int dataOff = ( pixelWidth * bytesPerPixel * ( pixelHeight - 1 ) ) + // full lines - 1 line ( ( pixelWidth - 1 ) * bytesPerPixel ); // one line - 1 pixel for (int row = 0; row < pixelHeight; row++) { int lineOff = ( pixelWidth - 1 ) * bytesPerPixel ; // start w/ last pixel in line, reverse store (OpenGL bottom-left -> PNG top-left origin) @@ -306,13 +306,13 @@ public class PNGImage { } } png.writeRow(l1, row); - } + } } png.end(); } finally { IOUtil.close(outs, false); } } - - public String toString() { return "PNGImage["+pixelWidth+"x"+pixelHeight+", dpi "+dpi[0]+" x "+dpi[1]+", bytesPerPixel "+bytesPerPixel+", reversedChannels "+reversedChannels+", "+data+"]"; } + + public String toString() { return "PNGImage["+pixelWidth+"x"+pixelHeight+", dpi "+dpi[0]+" x "+dpi[1]+", bytesPerPixel "+bytesPerPixel+", reversedChannels "+reversedChannels+", "+data+"]"; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java index d35330f58..fd96fba80 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java @@ -1,21 +1,21 @@ /* * Portions Copyright (c) 2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -72,15 +72,15 @@ public class SGIImage { byte storage; // Storage format // 0 for uncompressed // 1 for RLE compression - byte bpc; // Number of bytes per pixel channel + byte bpc; // Number of bytes per pixel channel // Legally 1 or 2 short dimension; // Number of dimensions // Legally 1, 2, or 3 // 1 means a single row, XSIZE long // 2 means a single 2D image // 3 means multiple 2D images - short xsize; // X size in pixels - short ysize; // Y size in pixels + short xsize; // X size in pixels + short ysize; // Y size in pixels short zsize; // Number of channels // 1 indicates greyscale // 3 indicates RGB @@ -233,7 +233,7 @@ public class SGIImage { //---------------------------------------------------------------------- // Internals only below this point // - + private void decodeImage(DataInputStream in) throws IOException { if (header.storage == 1) { // Read RLE compression data; row starts and sizes @@ -478,7 +478,7 @@ public class SGIImage { for (int z = 0; z < zsize; z++) { for (int y = ystart; y != yend; y += yincr) { // RLE-compress each row. - + int x = 0; byte count = 0; boolean repeat_mode = false; @@ -486,7 +486,7 @@ public class SGIImage { int start_ptr = ptr; int num_ptr = ptr++; byte repeat_val = 0; - + while (x < xsize) { // see if we should switch modes should_switch = false; @@ -503,7 +503,7 @@ public class SGIImage { if (DEBUG) System.err.println("left side was " + ((int) imgref(data, x, y, z, xsize, ysize, zsize)) + ", right side was " + (int)imgref(data, x+i, y, z, xsize, ysize, zsize)); - + if (imgref(data, x, y, z, xsize, ysize, zsize) != imgref(data, x+i, y, z, xsize, ysize, zsize)) should_switch = false; @@ -531,7 +531,7 @@ public class SGIImage { repeat_mode = true; repeat_val = imgref(data, x, y, z, xsize, ysize, zsize); } - + if (x > 0) { // reset the number pointer num_ptr = ptr++; @@ -539,7 +539,7 @@ public class SGIImage { count = 0; } } - + // if not in repeat mode, copy element to ptr if (!repeat_mode) { rlebuf[ptr++] = imgref(data, x, y, z, xsize, ysize, zsize); @@ -581,8 +581,8 @@ public class SGIImage { // Now we have the offset tables computed, as well as the RLE data. // Output this information to the file. total_size = ptr; - - if (DEBUG) + + if (DEBUG) System.err.println("total_size was " + total_size); DataOutputStream stream = new DataOutputStream(new BufferedOutputStream(IOUtil.getFileOutputStream(file, true))); @@ -604,7 +604,7 @@ public class SGIImage { byte[] dest = new byte[16384]; int pos = 0; int numRead = 0; - + boolean done = false; do { diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java index 2ff3b9cf0..df9430a26 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2003-2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -146,9 +146,9 @@ public class TGAImage { tgaType = TYPE_OLD; // dont try and get footer. // initial header fields - idLength = in.readUnsignedByte(); + idLength = in.readUnsignedByte(); colorMapType = in.readUnsignedByte(); - imageType = in.readUnsignedByte(); + imageType = in.readUnsignedByte(); // color map header fields firstEntryIndex = in.readUnsignedShort(); @@ -288,14 +288,14 @@ public class TGAImage { throw new IOException("TGADecoder Compressed Grayscale images not supported"); } } - + /** * This assumes that the body is for a 24 bit or 32 bit for a * RGB or ARGB image respectively. */ private void decodeRGBImageU24_32(GLProfile glp, LEDataInputStream dIn) throws IOException { setupImage24_32(glp); - + int i; // row index int y; // output row index int rawWidth = header.width() * bpp; @@ -317,14 +317,14 @@ public class TGAImage { swapBGR(tmpData, rawWidth, header.height(), bpp); data = ByteBuffer.wrap(tmpData); } - + /** * This assumes that the body is for a 24 bit or 32 bit for a * RGB or ARGB image respectively. */ private void decodeRGBImageRLE24_32(GLProfile glp, LEDataInputStream dIn) throws IOException { setupImage24_32(glp); - + byte[] pixel = new byte[bpp]; int rawWidth = header.width() * bpp; byte[] tmpData = new byte[rawWidth * header.height()]; @@ -341,17 +341,17 @@ public class TGAImage { dIn.read(tmpData, i, len * bpp); i += bpp * len; } - + if(format == GL.GL_RGB || format == GL.GL_RGBA) swapBGR(tmpData, rawWidth, header.height(), bpp); data = ByteBuffer.wrap(tmpData); } - + private void setupImage24_32(GLProfile glp) { bpp = header.pixelDepth / 8; switch (header.pixelDepth) { - case 24: - format = glp.isGL2GL3() ? GL2GL3.GL_BGR : GL.GL_RGB; + case 24: + format = glp.isGL2GL3() ? GL2GL3.GL_BGR : GL.GL_RGB; break; case 32: boolean useBGRA = glp.isGL2GL3(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TextureProvider.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TextureProvider.java index 88018edbe..0299531b1 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TextureProvider.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TextureProvider.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TextureWriter.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TextureWriter.java index 55527cef5..35b8efa72 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TextureWriter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TextureWriter.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java index 6e2f1b992..f23cb74bf 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java index 89d0d20a1..438ab6cc2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -113,7 +113,7 @@ public class IIOTextureWriter implements TextureWriter { return ImageIO.write(image, IOUtil.getFileSuffix(file), file); } - + throw new IOException("ImageIO writer doesn't support this pixel format / type (only GL_RGB/A + bytes)"); } } diff --git a/src/jogl/classes/javax/media/opengl/DebugGL2.java b/src/jogl/classes/javax/media/opengl/DebugGL2.java index 05bcf3d5e..3c064a18f 100644 --- a/src/jogl/classes/javax/media/opengl/DebugGL2.java +++ b/src/jogl/classes/javax/media/opengl/DebugGL2.java @@ -10,7 +10,7 @@ package javax.media.opengl; * Sample code which installs this pipeline, manual: *
      *     gl = drawable.setGL(new DebugGL(drawable.getGL()));
    - * 
    + * * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. *

    */ diff --git a/src/jogl/classes/javax/media/opengl/DebugGL3.java b/src/jogl/classes/javax/media/opengl/DebugGL3.java index c17f90667..b490a63f4 100644 --- a/src/jogl/classes/javax/media/opengl/DebugGL3.java +++ b/src/jogl/classes/javax/media/opengl/DebugGL3.java @@ -10,7 +10,7 @@ package javax.media.opengl; * Sample code which installs this pipeline, manual: *
      *     gl = drawable.setGL(new DebugGL(drawable.getGL()));
    - * 
    + * * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. *

    */ diff --git a/src/jogl/classes/javax/media/opengl/DebugGL3bc.java b/src/jogl/classes/javax/media/opengl/DebugGL3bc.java index 6e294d42b..1d42afbc6 100644 --- a/src/jogl/classes/javax/media/opengl/DebugGL3bc.java +++ b/src/jogl/classes/javax/media/opengl/DebugGL3bc.java @@ -10,7 +10,7 @@ package javax.media.opengl; * Sample code which installs this pipeline, manual: *
      *     gl = drawable.setGL(new DebugGL(drawable.getGL()));
    - * 
    + * * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. *

    */ diff --git a/src/jogl/classes/javax/media/opengl/DebugGL4.java b/src/jogl/classes/javax/media/opengl/DebugGL4.java index d21d39390..249d850a3 100644 --- a/src/jogl/classes/javax/media/opengl/DebugGL4.java +++ b/src/jogl/classes/javax/media/opengl/DebugGL4.java @@ -10,7 +10,7 @@ package javax.media.opengl; * Sample code which installs this pipeline, manual: *
      *     gl = drawable.setGL(new DebugGL(drawable.getGL()));
    - * 
    + * * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. *

    */ diff --git a/src/jogl/classes/javax/media/opengl/DebugGLES2.java b/src/jogl/classes/javax/media/opengl/DebugGLES2.java index dee363c1b..6d666d82a 100644 --- a/src/jogl/classes/javax/media/opengl/DebugGLES2.java +++ b/src/jogl/classes/javax/media/opengl/DebugGLES2.java @@ -10,7 +10,7 @@ package javax.media.opengl; * Sample code which installs this pipeline, manual: *
      *     gl = drawable.setGL(new DebugGL(drawable.getGL()));
    - * 
    + * * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. *

    */ diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java index b0f3da8e4..7e243471e 100644 --- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java +++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003-2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -91,7 +91,7 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { Debug.initSingleton(); DEBUG = Debug.isPropertyDefined("jogl.debug.CapabilitiesChooser", true); } - + private final static int NO_SCORE = -9999999; private final static int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000; private final static int OPAQUE_MISMATCH_PENALTY = 750; @@ -106,7 +106,7 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { private final static int ACCUM_MISMATCH_PENALTY_SCALE = 1; private final static int STENCIL_MISMATCH_PENALTY_SCALE = 3; private final static int MULTISAMPLE_MISMATCH_PENALTY_SCALE = 3; - + @Override public int chooseCapabilities(final CapabilitiesImmutable desired, final List available, @@ -143,12 +143,12 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { // Create score array int[] scores = new int[availnum]; - + for (int i = 0; i < scores.length; i++) { scores[i] = NO_SCORE; } final int gldes_samples = gldes.getNumSamples(); - + // Compute score for each for (int i = 0; i < availnum; i++) { final GLCapabilitiesImmutable cur = (GLCapabilitiesImmutable) available.get(i); @@ -165,24 +165,24 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { } */ if (gldes.isPBuffer() && !cur.isPBuffer()) { continue; // requested pBuffer, but n/a - } + } if (gldes.isBitmap() && !cur.isBitmap()) { continue; // requested pBuffer, but n/a - } + } } if (gldes.getStereo() != cur.getStereo()) { continue; } final int cur_samples = cur.getNumSamples() ; int score = 0; - + // Compute difference in color depth // (Note that this decides the direction of all other penalties) score += (COLOR_MISMATCH_PENALTY_SCALE * ((cur.getRedBits() + cur.getGreenBits() + cur.getBlueBits() + cur.getAlphaBits()) - (gldes.getRedBits() + gldes.getGreenBits() + gldes.getBlueBits() + gldes.getAlphaBits()))); // Compute difference in depth buffer depth - score += (DEPTH_MISMATCH_PENALTY_SCALE * sign(score) * + score += (DEPTH_MISMATCH_PENALTY_SCALE * sign(score) * Math.abs(cur.getDepthBits() - gldes.getDepthBits())); // Compute difference in accumulation buffer depth score += (ACCUM_MISMATCH_PENALTY_SCALE * sign(score) * @@ -261,7 +261,7 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { System.err.println(" ]"); } - // Ready to select. Choose score closest to 0. + // Ready to select. Choose score closest to 0. int scoreClosestToZero = NO_SCORE; int chosenIndex = -1; for (int i = 0; i < availnum; i++) { diff --git a/src/jogl/classes/javax/media/opengl/FPSCounter.java b/src/jogl/classes/javax/media/opengl/FPSCounter.java index 9c07b58e4..4997258e0 100644 --- a/src/jogl/classes/javax/media/opengl/FPSCounter.java +++ b/src/jogl/classes/javax/media/opengl/FPSCounter.java @@ -36,28 +36,28 @@ import java.io.PrintStream; */ public interface FPSCounter { public static final int DEFAULT_FRAMES_PER_INTERVAL = 5*60; - + /** - * @param frames Update interval in frames.
    At every rendered frames interval the currentTime and fps values are updated. + * @param frames Update interval in frames.
    At every rendered frames interval the currentTime and fps values are updated. * If the frames interval is <= 0, no update will be issued, ie the FPSCounter feature is turned off. You may choose {@link #DEFAULT_FRAMES_PER_INTERVAL}. - * @param out optional print stream where the fps values gets printed if not null at every frames interval + * @param out optional print stream where the fps values gets printed if not null at every frames interval */ void setUpdateFPSFrames(int frames, PrintStream out); - + /** * Reset all performance counter (startTime, currentTime, frame number) */ void resetFPSCounter(); - + /** * @return update interval in frames - * + * * @see #setUpdateFPSFrames(int, PrintStream) */ int getUpdateFPSFrames(); - + /** - * Returns the time of the first display call in milliseconds after enabling this feature via {@link #setUpdateFPSFrames(int, PrintStream)}.
    + * Returns the time of the first display call in milliseconds after enabling this feature via {@link #setUpdateFPSFrames(int, PrintStream)}.
    * This value is reset via {@link #resetFPSCounter()}. * * @see #setUpdateFPSFrames(int, PrintStream) @@ -81,18 +81,18 @@ public interface FPSCounter { * @see #resetFPSCounter() */ long getLastFPSPeriod(); - + /** * @return Last update interval's frames per seconds, {@link #getUpdateFPSFrames()} / {@link #getLastFPSPeriod()} - * + * * @see #setUpdateFPSFrames(int, PrintStream) * @see #resetFPSCounter() */ - float getLastFPS(); - + float getLastFPS(); + /** * @return Number of frame rendered since {@link #getFPSStartTime()} up to {@link #getLastFPSUpdateTime()} - * + * * @see #setUpdateFPSFrames(int, PrintStream) * @see #resetFPSCounter() */ @@ -108,10 +108,10 @@ public interface FPSCounter { /** - * @return Total frames per seconds, {@link #getTotalFPSFrames()} / {@link #getTotalFPSDuration()} - * + * @return Total frames per seconds, {@link #getTotalFPSFrames()} / {@link #getTotalFPSDuration()} + * * @see #setUpdateFPSFrames(int, PrintStream) * @see #resetFPSCounter() */ - float getTotalFPS(); + float getTotalFPS(); } diff --git a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java index a72403eae..827145654 100644 --- a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java +++ b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java @@ -29,7 +29,7 @@ package javax.media.opengl; /** - * An animator control interface, + * An animator control interface, * which implementation may drive a {@link javax.media.opengl.GLAutoDrawable} animation. */ public interface GLAnimatorControl extends FPSCounter { @@ -56,8 +56,8 @@ public interface GLAnimatorControl extends FPSCounter { boolean isAnimating(); /** - * Indicates whether this animator {@link #isStarted() is started} - * and either {@link #pause() manually paused} or paused + * Indicates whether this animator {@link #isStarted() is started} + * and either {@link #pause() manually paused} or paused * automatically due to no {@link #add(GLAutoDrawable) added} {@link GLAutoDrawable}s. * * @see #start() @@ -157,15 +157,15 @@ public interface GLAnimatorControl extends FPSCounter { /** * Adds a drawable to this animator's list of rendering drawables. *

    - * This allows the animator thread to become {@link #isAnimating() animating}, + * This allows the animator thread to become {@link #isAnimating() animating}, * in case the first drawable is added and the animator {@link #isStarted() is started}. *

    - * + * * @param drawable the drawable to be added * @throws IllegalArgumentException if drawable was already added to this animator */ void add(GLAutoDrawable drawable); - + /** * Removes a drawable from the animator's list of rendering drawables. *

    @@ -173,10 +173,10 @@ public interface GLAnimatorControl extends FPSCounter { * and will not be recovered. *

    *

    - * This allows the animator thread to become {@link #isAnimating() not animating}, + * This allows the animator thread to become {@link #isAnimating() not animating}, * in case the last drawable has been removed. *

    - * + * * @param drawable the drawable to be removed * @throws IllegalArgumentException if drawable was not added to this animator */ diff --git a/src/jogl/classes/javax/media/opengl/GLArrayData.java b/src/jogl/classes/javax/media/opengl/GLArrayData.java index 8e1383031..4025170cf 100644 --- a/src/jogl/classes/javax/media/opengl/GLArrayData.java +++ b/src/jogl/classes/javax/media/opengl/GLArrayData.java @@ -43,7 +43,7 @@ public interface GLArrayData { * Implementation and type dependent object association. *

    * One currently known use case is to associate a {@link com.jogamp.opengl.util.glsl.ShaderState ShaderState} - * to an GLSL aware vertex attribute object, allowing to use the ShaderState to handle it's + * to an GLSL aware vertex attribute object, allowing to use the ShaderState to handle it's * data persistence, location and state change.
    * This is implicitly done via {@link com.jogamp.opengl.util.glsl.ShaderState#ownAttribute(GLArrayData, boolean) shaderState.ownAttribute(GLArrayData, boolean)}. *

    @@ -51,7 +51,7 @@ public interface GLArrayData { * @param enable pass true to enable the association and false to disable it. */ public void associate(Object obj, boolean enable); - + /** * Returns true if this data set is intended for a GLSL vertex shader attribute, * otherwise false, ie intended for fixed function vertex pointer @@ -110,7 +110,7 @@ public interface GLArrayData { * <0 denotes an invalid location, i.e. not found or used in the given shader program. */ public int setLocation(GL2ES2 gl, int program); - + /** * Binds the location of the shader attribute to the given location for the unlinked shader program. *

    @@ -121,7 +121,7 @@ public interface GLArrayData { * @return the given location */ public int setLocation(GL2ES2 gl, int program, int location); - + /** * Determines whether the data is server side (VBO) and enabled, * or a client side array (false). @@ -150,7 +150,7 @@ public interface GLArrayData { */ public int getVBOTarget(); - + /** * The Buffer holding the data, may be null if a GPU buffer without client bound data */ @@ -179,7 +179,7 @@ public interface GLArrayData { * In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position. */ public int getElementCount(); - + /** * The currently used size in bytes.
    * In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position. @@ -187,18 +187,18 @@ public interface GLArrayData { public int getSizeInBytes(); /** - * True, if GL shall normalize fixed point data while converting + * True, if GL shall normalize fixed point data while converting * them into float. - *

    + *

    * Default behavior (of the fixed function pipeline) is true * for fixed point data type and false for floating point data types. *

    */ public boolean getNormalized(); - /** + /** * @return the byte offset between consecutive components - */ + */ public int getStride(); public String toString(); diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index 989a61aaf..38824ce8f 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -50,8 +50,8 @@ import jogamp.opengl.Debug; rendering context which is associated with the GLAutoDrawable for the lifetime of the object.

    - Since the {@link GLContext} {@link GLContext#makeCurrent makeCurrent} - implementation is synchronized, i.e. blocks if the context + Since the {@link GLContext} {@link GLContext#makeCurrent makeCurrent} + implementation is synchronized, i.e. blocks if the context is current on another thread, the internal {@link GLContext} for the GLAutoDrawable can be used for the event based rendering mechanism and by end users directly. @@ -123,7 +123,7 @@ public interface GLAutoDrawable extends GLDrawable { * otherwise return this instance. */ public GLDrawable getDelegatedDrawable(); - + /** * Returns the context associated with this drawable. The returned * context will be synchronized. @@ -135,38 +135,38 @@ public interface GLAutoDrawable extends GLDrawable { * Associate the new context, newtCtx, to this auto-drawable. *

    * The current context will be destroyed if destroyPrevCtx is true, - * otherwise it will be dis-associated from this auto-drawable + * otherwise it will be dis-associated from this auto-drawable * via {@link GLContext#setGLDrawable(GLDrawable, boolean) setGLDrawable(null, true);} first. *

    *

    - * The new context will be associated with this auto-drawable + * The new context will be associated with this auto-drawable * via {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. - *

    + *

    *

    * If the old or new context was current on this thread, it is being released before switching the association. - * The new context will be made current afterwards, if it was current before. + * The new context will be made current afterwards, if it was current before. * However the user shall take extra care that no other thread * attempts to make this context current. *

    - * + * * @param newCtx the new context, maybe null for dis-association. - * @param destroyPrevCtx if true, destroy the previous context if exists + * @param destroyPrevCtx if true, destroy the previous context if exists * @return the previous GLContext, maybe null - * + * * @see GLContext#setGLDrawable(GLDrawable, boolean) * @see GLContext#setGLReadDrawable(GLDrawable) * @see jogamp.opengl.GLDrawableHelper#switchContext(GLDrawable, GLContext, boolean, GLContext, int) */ public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx); - + /** * Adds the given {@link GLEventListener listener} to the end of this drawable queue. * The {@link GLEventListener listeners} are notified of events in the order of the queue. *

    - * The newly added listener's {@link GLEventListener#init(GLAutoDrawable) init(..)} + * The newly added listener's {@link GLEventListener#init(GLAutoDrawable) init(..)} * method will be called once before any other of it's callback methods. * See {@link #getGLEventListenerInitState(GLEventListener)} for details. - *

    + *

    * @param listener The GLEventListener object to be inserted */ public void addGLEventListener(GLEventListener listener); @@ -175,10 +175,10 @@ public interface GLAutoDrawable extends GLDrawable { * Adds the given {@link GLEventListener listener} at the given index of this drawable queue. * The {@link GLEventListener listeners} are notified of events in the order of the queue. *

    - * The newly added listener's {@link GLEventListener#init(GLAutoDrawable) init(..)} + * The newly added listener's {@link GLEventListener#init(GLAutoDrawable) init(..)} * method will be called once before any other of it's callback methods. * See {@link #getGLEventListenerInitState(GLEventListener)} for details. - *

    + *

    * @param index Position where the listener will be inserted. * Should be within (0 <= index && index <= size()). * An index value of -1 is interpreted as the end of the list, size(). @@ -192,7 +192,7 @@ public interface GLAutoDrawable extends GLDrawable { * @return The number of GLEventListener objects of this drawable queue. */ public int getGLEventListenerCount(); - + /** * Returns the {@link GLEventListener} at the given index of this drawable queue. * @param index Position of the listener to be returned. @@ -202,18 +202,18 @@ public interface GLAutoDrawable extends GLDrawable { * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index < size()), or -1 */ public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException; - + /** * Retrieves whether the given {@link GLEventListener listener} is initialized or not. *

    - * After {@link #addGLEventListener(GLEventListener) adding} a {@link GLEventListener} it is + * After {@link #addGLEventListener(GLEventListener) adding} a {@link GLEventListener} it is * marked uninitialized and added to a list of to be initialized {@link GLEventListener}. - * If such uninitialized {@link GLEventListener}'s handler methods (reshape, display) + * If such uninitialized {@link GLEventListener}'s handler methods (reshape, display) * are about to be invoked, it's {@link GLEventListener#init(GLAutoDrawable) init(..)} method is invoked first. * Afterwards the {@link GLEventListener} is marked initialized * and removed from the list of to be initialized {@link GLEventListener}. *

    - *

    + *

    * This methods returns the {@link GLEventListener} initialized state, * i.e. returns false if it is included in the list of to be initialized {@link GLEventListener}, * otherwise true. @@ -221,17 +221,17 @@ public interface GLAutoDrawable extends GLDrawable { * @param listener the GLEventListener object to query it's initialized state. */ public boolean getGLEventListenerInitState(GLEventListener listener); - + /** * Sets the given {@link GLEventListener listener's} initialized state. - *

    + *

    * This methods allows manually setting the {@link GLEventListener} initialized state, * i.e. adding it to, or removing it from the list of to be initialized {@link GLEventListener}. * See {@link #getGLEventListenerInitState(GLEventListener)} for details. *

    *

    * Warning: This method does not validate whether the given {@link GLEventListener listener's} - * is member of this drawable queue, i.e. {@link #addGLEventListener(GLEventListener) added}. + * is member of this drawable queue, i.e. {@link #addGLEventListener(GLEventListener) added}. *

    *

    * This method is only exposed to allow users full control over the {@link GLEventListener}'s state @@ -239,16 +239,16 @@ public interface GLAutoDrawable extends GLDrawable { *

    *

    * One use case is moving a {@link GLContext} and their initialized {@link GLEventListener} - * from one {@link GLAutoDrawable} to another, + * from one {@link GLAutoDrawable} to another, * where a subsequent {@link GLEventListener#init(GLAutoDrawable) init(..)} call after adding it - * to the new owner is neither required nor desired. + * to the new owner is neither required nor desired. * See {@link com.jogamp.opengl.util.GLDrawableUtil#swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable) swapGLContextAndAllGLEventListener(..)}. *

    * @param listener the GLEventListener object to perform a state change. - * @param initialized if true, mark the listener initialized, otherwise uninitialized. + * @param initialized if true, mark the listener initialized, otherwise uninitialized. */ public void setGLEventListenerInitState(GLEventListener listener, boolean initialized); - + /** * Disposes the given {@link GLEventListener listener} via {@link GLEventListener#dispose(GLAutoDrawable) dispose(..)} * if it has been initialized and added to this queue. @@ -257,7 +257,7 @@ public interface GLAutoDrawable extends GLDrawable { * otherwise marked uninitialized. *

    *

    - * If an {@link GLAnimatorControl} is being attached and the current thread is different + * If an {@link GLAnimatorControl} is being attached and the current thread is different * than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation. *

    *

    @@ -268,8 +268,8 @@ public interface GLAutoDrawable extends GLDrawable { * Use {@link #removeGLEventListener(GLEventListener) removeGLEventListener(listener)} instead * if you just want to remove the {@link GLEventListener listener} and don't care about the disposal of the it's (OpenGL) resources. *

    - *

    - * Also note that this is done from within a particular drawable's + *

    + * Also note that this is done from within a particular drawable's * {@link GLEventListener} handler (reshape, display, etc.), that it is not * guaranteed that all other listeners will be evaluated properly * during this update cycle. @@ -277,30 +277,30 @@ public interface GLAutoDrawable extends GLDrawable { * @param listener The GLEventListener object to be disposed and removed if remove is true * @param remove pass true to have the listener removed from this drawable queue, otherwise pass false * @return the disposed and/or removed GLEventListener, or null if no action was performed, i.e. listener was not added - */ + */ public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove); - - /** + + /** * Removes the given {@link GLEventListener listener} from this drawable queue. *

    - * This is an inexpensive operation, since the removed listener's + * This is an inexpensive operation, since the removed listener's * {@link GLEventListener#dispose(GLAutoDrawable) dispose(..)} method will not be called. *

    *

    - * Use {@link #disposeGLEventListener(GLEventListener, boolean) disposeGLEventListener(listener, true)} + * Use {@link #disposeGLEventListener(GLEventListener, boolean) disposeGLEventListener(listener, true)} * instead to ensure disposal of the {@link GLEventListener listener}'s (OpenGL) resources. - *

    - *

    - * Note that if this is done from within a particular drawable's + *

    + *

    + * Note that if this is done from within a particular drawable's * {@link GLEventListener} handler (reshape, display, etc.), that it is not * guaranteed that all other listeners will be evaluated properly * during this update cycle. *

    * @param listener The GLEventListener object to be removed * @return the removed GLEventListener, or null if listener was not added - */ + */ public GLEventListener removeGLEventListener(GLEventListener listener); - + /** * Registers the usage of an animator, an {@link javax.media.opengl.GLAnimatorControl} implementation. * The animator will be queried whether it's animating, ie periodically issuing {@link #display()} calls or not. @@ -334,17 +334,17 @@ public interface GLAutoDrawable extends GLDrawable { /** * Dedicates this instance's {@link GLContext} to the given thread.
    * The thread will exclusively claim the {@link GLContext} via {@link #display()} and not release it - * until {@link #destroy()} or setExclusiveContextThread(null) has been called. + * until {@link #destroy()} or setExclusiveContextThread(null) has been called. *

    * Default non-exclusive behavior is requested via setExclusiveContextThread(null), - * which will cause the next call of {@link #display()} on the exclusive thread to - * release the {@link GLContext}. Only after it's async release, {@link #getExclusiveContextThread()} + * which will cause the next call of {@link #display()} on the exclusive thread to + * release the {@link GLContext}. Only after it's async release, {@link #getExclusiveContextThread()} * will return null. *

    *

    * To release a previous made exclusive thread, a user issues setExclusiveContextThread(null) - * and may poll {@link #getExclusiveContextThread()} until it returns null, - * while the exclusive thread is still running. + * and may poll {@link #getExclusiveContextThread()} until it returns null, + * while the exclusive thread is still running. *

    *

    * Note: Setting a new exclusive thread without properly releasing a previous one @@ -359,17 +359,17 @@ public interface GLAutoDrawable extends GLDrawable { * and spare redundant context switches, see {@link com.jogamp.opengl.util.AnimatorBase#setExclusiveContext(boolean)}. *

    * @param t the exclusive thread to claim the context, or null for default operation. - * @return previous exclusive context thread + * @return previous exclusive context thread * @throws GLException If an exclusive thread is still active but a new one is attempted to be set * @see com.jogamp.opengl.util.AnimatorBase#setExclusiveContext(boolean) */ public Thread setExclusiveContextThread(Thread t) throws GLException; - + /** - * @see #setExclusiveContextThread(Thread) + * @see #setExclusiveContextThread(Thread) */ public Thread getExclusiveContextThread(); - + /** * Enqueues a one-shot {@link GLRunnable}, * which will be executed within the next {@link #display()} call @@ -391,7 +391,7 @@ public interface GLAutoDrawable extends GLDrawable { * has been executed by the {@link GLAnimatorControl animator}, otherwise the method returns immediately. *

    *

    - * If wait is true and + * If wait is true and * {@link #isRealized()} returns false or {@link #getContext()} returns null, * the call is ignored and returns false.
    * This helps avoiding deadlocking the caller. @@ -404,16 +404,16 @@ public interface GLAutoDrawable extends GLDrawable { * @param wait if true block until execution of glRunnable is finished, otherwise return immediately w/o waiting * @param glRunnable the {@link GLRunnable} to execute within {@link #display()} * @return true if the {@link GLRunnable} has been processed or queued, otherwise false. - * + * * @see #setAnimator(GLAnimatorControl) * @see #display() * @see GLRunnable * @see #invoke(boolean, List) */ public boolean invoke(boolean wait, GLRunnable glRunnable); - + /** - * Extends {@link #invoke(boolean, GLRunnable)} functionality + * Extends {@link #invoke(boolean, GLRunnable)} functionality * allowing to inject a list of {@link GLRunnable}s. * @param wait if true block until execution of the last glRunnable is finished, otherwise return immediately w/o waiting * @param glRunnables the {@link GLRunnable}s to execute within {@link #display()} @@ -494,16 +494,16 @@ public interface GLAutoDrawable extends GLDrawable { *

    * This GLAutoDrawable implementation holds it's own GLContext reference, * thus created a GLContext using this methods won't replace it implicitly. - * To replace or set this GLAutoDrawable's GLContext you need to call {@link #setContext(GLContext, boolean)}. + * To replace or set this GLAutoDrawable's GLContext you need to call {@link #setContext(GLContext, boolean)}. *

    *

    - * The GLAutoDrawable implementation shall also set the - * context creation flags as customized w/ {@link #setContextCreationFlags(int)}. + * The GLAutoDrawable implementation shall also set the + * context creation flags as customized w/ {@link #setContextCreationFlags(int)}. *

    */ @Override public GLContext createContext(GLContext shareWith); - + /** Returns the {@link GL} pipeline object this GLAutoDrawable uses. If this method is called outside of the {@link GLEventListener}'s callback methods (init, display, etc.) it may @@ -522,13 +522,13 @@ public interface GLAutoDrawable extends GLDrawable { demos for examples. @return the set GL pipeline or null if not successful */ public GL setGL(GL gl); - + /** * Method may return the upstream UI toolkit object * holding this {@link GLAutoDrawable} instance, if exist. *

    * Currently known Java UI toolkits and it's known return types are: - * + * *

    *
    Toolkit GLAutoDrawable Implementation ~ Return Type of getUpstreamWidget() *
    NEWT {@link com.jogamp.newt.opengl.GLWindow} has a {@link com.jogamp.newt.Window} @@ -536,7 +536,7 @@ public interface GLAutoDrawable extends GLDrawable { *
    AWT {@link javax.media.opengl.awt.GLCanvas} is a {@link java.awt.Canvas} *
    AWT {@link javax.media.opengl.awt.GLJPanel} is a {@link javax.swing.JPanel} *
    - * However, the result may be other object types than the listed above + * However, the result may be other object types than the listed above * due to new supported toolkits. *

    *

    diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index 1f75a7b4a..e84dd7be9 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -32,7 +32,7 @@ package javax.media.opengl; /** *

    The base interface from which all GL profiles derive, providing * checked conversion down to concrete profiles, access to the - * OpenGL context associated with the GL and extension/function + * OpenGL context associated with the GL and extension/function * availability queries as described below.

    * *

    While the APIs for vendor extensions are unconditionally @@ -79,7 +79,7 @@ package javax.media.opengl; * */ public interface GLBase { - + /** * Indicates whether this GL object conforms to any of the OpenGL profiles. */ @@ -131,7 +131,7 @@ public interface GLBase { *

    * Remark: ES2 compatible desktop profiles are not included. * To query whether core ES2 functionality is provided, use {@link #isGLES2Compatible()}. - *

    + *

    * @see #isGLES2Compatible() * @see GLContext#isGLES2() */ @@ -142,12 +142,12 @@ public interface GLBase { *

    * Remark: ES3 compatible desktop profiles are not included. * To query whether core ES3 functionality is provided, use {@link #isGLES3Compatible()}. - *

    + *

    * @see #isGLES3Compatible() * @see GLContext#isGLES3() */ public boolean isGLES3(); - + /** * Indicates whether this GL object conforms to one of the OpenGL ES profiles, * see {@link #isGLES1()} and {@link #isGLES2()}. @@ -180,7 +180,7 @@ public interface GLBase { public boolean isGL3ES3(); /** - * Returns true if this GL object conforms to a GL4ES3 compatible profile, i.e. if {@link #isGLES3Compatible()} returns true. + * Returns true if this GL object conforms to a GL4ES3 compatible profile, i.e. if {@link #isGLES3Compatible()} returns true. *

    Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]

    * @see GLContext#isGL4ES3() */ @@ -192,29 +192,29 @@ public interface GLBase { */ public boolean isGL2GL3(); - /** + /** * Indicates whether this GL object uses a GL4 core profile.

    Includes [ GL4 ].

    * @see GLContext#isGL4core() */ public boolean isGL4core(); - - /** + + /** * Indicates whether this GL object uses a GL3 core profile.

    Includes [ GL4, GL3 ].

    * @see GLContext#isGL3core() */ public boolean isGL3core(); - - /** + + /** * Indicates whether this GL object uses a GL core profile.

    Includes [ GL4, GL3, GLES3, GL2ES2 ].

    * @see GLContext#isGLcore() */ public boolean isGLcore(); - + /** * Indicates whether this GL object is compatible with the core OpenGL ES2 functionality. - * @return true if this context is an ES2 context or implements + * @return true if this context is an ES2 context or implements * the extension GL_ARB_ES2_compatibility, otherwise false - * @see GLContext#isGLES2Compatible() + * @see GLContext#isGLES2Compatible() */ public boolean isGLES2Compatible(); @@ -227,26 +227,26 @@ public interface GLBase { *

    * Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ] *

    - * @see GLContext#isGLES3Compatible() + * @see GLContext#isGLES3Compatible() */ public boolean isGLES3Compatible(); - /** - * Indicates whether this GL object supports GLSL. - * @see GLContext#hasGLSL() + /** + * Indicates whether this GL object supports GLSL. + * @see GLContext#hasGLSL() */ public boolean hasGLSL(); /** * Returns the downstream GL instance in case this is a wrapping pipeline, otherwise null. *

    - * See {@link #getRootGL()} for retrieving the implementing root instance. + * See {@link #getRootGL()} for retrieving the implementing root instance. *

    * @throws GLException if the downstream instance is not null and not a GL implementation * @see #getRootGL() */ public GL getDownstreamGL() throws GLException; - + /** * Returns the implementing root instance, considering a wrapped pipelined hierarchy, see {@link #getDownstreamGL()}. *

    @@ -256,7 +256,7 @@ public interface GLBase { * @throws GLException if the root instance is not a GL implementation */ public GL getRootGL() throws GLException; - + /** * Casts this object to the GL interface. * @throws GLException if this object is not a GL implementation @@ -360,14 +360,14 @@ public interface GLBase { /** * Returns true if the specified OpenGL core- or extension-function can be * used successfully through this GL instance given the current host (OpenGL - * client) and display (OpenGL server) configuration.

    - * By "successfully" we mean that the function is both callable - * on the machine running the program and available on the current - * display.

    + * client) and display (OpenGL server) configuration.

    + * By "successfully" we mean that the function is both callable + * on the machine running the program and available on the current + * display.

    * * In order to call a function successfully, the function must be both - * callable on the machine running the program and available on - * the display device that is rendering the output (note: on non-networked, + * callable on the machine running the program and available on + * the display device that is rendering the output (note: on non-networked, * single-display machines these two conditions are identical; on networked and/or * multi-display machines this becomes more complicated). These conditions are * met if the function is either part of the core OpenGL version supported by @@ -376,7 +376,7 @@ public interface GLBase { * * A GL function is callable if it is successfully linked at runtime, * hence the GLContext must be made current at least once. - * + * * @param glFunctionName the name of the OpenGL function (e.g., use * "glBindRenderbufferEXT" or "glBindRenderbuffer" to check if {@link * GL#glBindRenderbuffer(int,int)} is available). @@ -386,14 +386,14 @@ public interface GLBase { /** * Returns true if the specified OpenGL extension can be * used successfully through this GL instance given the current host (OpenGL - * client) and display (OpenGL server) configuration.

    + * client) and display (OpenGL server) configuration.

    * * @param glExtensionName the name of the OpenGL extension (e.g., * "GL_ARB_vertex_program"). */ public boolean isExtensionAvailable(String glExtensionName); - /** + /** * Returns true if basic FBO support is available, otherwise false. *

    * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= core 3.0 or implements the extensions @@ -407,12 +407,12 @@ public interface GLBase { */ public boolean hasBasicFBOSupport(); - /** + /** * Returns true if full FBO support is available, otherwise false. *

    * Full FBO is supported if the context is either GL >= core 3.0 or implements the extensions * ARB_framebuffer_object, or all of - * EXT_framebuffer_object, EXT_framebuffer_multisample, + * EXT_framebuffer_object, EXT_framebuffer_multisample, * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil. *

    *

    @@ -424,7 +424,7 @@ public interface GLBase { /** * Returns the maximum number of FBO RENDERBUFFER samples - * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. + * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. * @see GLContext#getMaxRenderbufferSamples() */ public int getMaxRenderbufferSamples(); @@ -440,7 +440,7 @@ public interface GLBase { public boolean isNPOTTextureAvailable(); public boolean isTextureFormatBGRA8888Available(); - + /** Provides a platform-independent way to specify the minimum swap interval for buffer swaps. An argument of 0 disables sync-to-vertical-refresh completely, while an argument of 1 @@ -449,7 +449,7 @@ public interface GLBase { is usually either 0 or 1. This function is not guaranteed to have an effect, and in particular only affects heavyweight onscreen components. - + @see #getSwapInterval @throws GLException if this context is not the current */ @@ -458,8 +458,8 @@ public interface GLBase { /** Provides a platform-independent way to get the swap interval set by {@link #setSwapInterval}.
    - If the interval is not set by {@link #setSwapInterval} yet, - -1 is returned, indicating that the platforms default + If the interval is not set by {@link #setSwapInterval} yet, + -1 is returned, indicating that the platforms default is being used. @see #setSwapInterval @@ -498,10 +498,10 @@ public interface GLBase { */ public Object getExtension(String extensionName); - /** Aliased entrypoint of void {@native glClearDepth}(GLclampd depth); and void {@native glClearDepthf}(GLclampf depth); . */ + /** Aliased entrypoint of void {@native glClearDepth}(GLclampd depth); and void {@native glClearDepthf}(GLclampf depth); . */ public void glClearDepth( double depth ); - /** Aliased entrypoint of void {@native glDepthRange}(GLclampd depth); and void {@native glDepthRangef}(GLclampf depth); . */ + /** Aliased entrypoint of void {@native glDepthRange}(GLclampd depth); and void {@native glDepthRangef}(GLclampf depth); . */ public void glDepthRange(double zNear, double zFar); /** @@ -526,44 +526,44 @@ public interface GLBase { */ public boolean glIsVBOElementArrayBound(); - /** - * Return the framebuffer name bound to this context, + /** + * Return the framebuffer name bound to this context, * see {@link GL#glBindFramebuffer(int, int)}. */ public int getBoundFramebuffer(int target); - /** + /** * Return the default draw framebuffer name. - *

    + *

    * May differ from it's default zero * in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable * is being used. - *

    + *

    */ public int getDefaultDrawFramebuffer(); - /** + /** * Return the default read framebuffer name. - *

    + *

    * May differ from it's default zero * in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable * is being used. - *

    + *

    */ public int getDefaultReadFramebuffer(); - - /** - * Returns the default color buffer within the current bound + + /** + * Returns the default color buffer within the current bound * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER, - * which will be used as the source for pixel reading commands, + * which will be used as the source for pixel reading commands, * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)} etc. *

    * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0}, - * otherwise this is {@link GL#GL_FRONT} for single buffer configurations + * otherwise this is {@link GL#GL_FRONT} for single buffer configurations * and {@link GL#GL_BACK} for double buffer configurations. - *

    + *

    */ public int getDefaultReadBuffer(); - + } diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java index 872069fb8..b825d6388 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java @@ -99,7 +99,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil } /** - * Copies all {@link GLCapabilities} and {@link Capabilities} values + * Copies all {@link GLCapabilities} and {@link Capabilities} values * from source into this instance. * @return this instance */ @@ -122,11 +122,11 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil sampleExtension = source.getSampleExtension(); return this; } - + @Override public int hashCode() { // 31 * x == (x << 5) - x - int hash = super.hashCode(); + int hash = super.hashCode(); hash = ((hash << 5) - hash) + this.glProfile.hashCode() ; hash = ((hash << 5) - hash) + ( this.hardwareAccelerated ? 1 : 0 ); hash = ((hash << 5) - hash) + ( this.stereo ? 1 : 0 ); @@ -238,7 +238,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil public void setGLProfile(GLProfile profile) { glProfile=profile; } - + @Override public final boolean isPBuffer() { return isPBuffer; @@ -255,7 +255,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil *

    * Requesting offscreen pbuffer mode disables the offscreen auto selection. *

    - */ + */ public void setPBuffer(boolean enable) { if(enable) { setOnscreen(false); @@ -267,7 +267,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil public final boolean isFBO() { return isFBO; } - + /** * Requesting offscreen FBO mode. *

    @@ -422,7 +422,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil return sampleBuffers; } - /** + /** * If sample buffers are enabled, indicates the number of buffers * to be allocated. Defaults to 2. * @see #getNumSamples() @@ -491,7 +491,7 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil if(isOnscreen()) { sink.append("."); // no additional off-screen modes besides on-screen } else { - sink.append("auto-cfg"); // auto-config off-screen mode + sink.append("auto-cfg"); // auto-config off-screen mode } } sink.append("]"); diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java index 5d575c2ee..2e0bec1f9 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesChooser.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003-2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -53,7 +53,7 @@ import javax.media.opengl.GLCapabilitiesImmutable; the appropriate method of {@link GLDrawableFactory}; the chooser will be called during the OpenGL context creation process. Note that this is only a marker interface; its signature is the same as - {@link CapabilitiesChooser} and the {@link List} of + {@link CapabilitiesChooser} and the {@link List} of objects extending {@link CapabilitiesImmutable} passed to {@link #chooseCapabilities chooseCapabilities} is actually a {@link List} of type {@link GLCapabilitiesImmutable}. */ diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java index 6af35021f..dc28539a0 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java @@ -37,13 +37,13 @@ import javax.media.nativewindow.CapabilitiesImmutable; * @see javax.media.nativewindow.CapabilitiesImmutable */ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { - /** - * One of the platform's default sample extension + /** + * One of the platform's default sample extension * EGL.EGL_SAMPLES, GLX.GLX_SAMPLES, WGLExt.WGL_SAMPLES_ARB * if available, or any other known fallback one, ie EGLExt.EGL_COVERAGE_SAMPLES_NV */ public static final String DEFAULT_SAMPLE_EXTENSION = "default" ; - + /** * Returns the GL profile you desire or used by the drawable. */ @@ -110,10 +110,10 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { *

    */ String getSampleExtension(); - + /** * Returns whether sample buffers for full-scene antialiasing - * (FSAA) should be allocated for this drawable. + * (FSAA) should be allocated for this drawable. *

    * Default is false. *

    diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index f4dbde6b2..bd6867359 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -72,14 +72,14 @@ import com.jogamp.opengl.GLRendererQuirks; abstraction provides a stable object which clients can use to refer to a given context. */ public abstract class GLContext { - + public static final boolean DEBUG = Debug.debug("GLContext"); public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true); - public static final boolean DEBUG_TRACE_SWITCH = DEBUG || TRACE_SWITCH; + public static final boolean DEBUG_TRACE_SWITCH = DEBUG || TRACE_SWITCH; - /** - * If true (default), bootstrapping the available GL profiles - * will use the highest compatible GL context for each profile, + /** + * If true (default), bootstrapping the available GL profiles + * will use the highest compatible GL context for each profile, * hence skipping querying lower profiles if a compatible higher one is found: *
      *
    • 4.2-core -> 4.2-core, 3.3-core
    • @@ -95,17 +95,17 @@ public abstract class GLContext { *
    * Using aliasing speeds up initialization about: *
      - *
    • Linux x86_64 - Nvidia: 28%, 700ms down to 500ms
    • - *
    • Linux x86_64 - AMD : 40%, 1500ms down to 900ms
    • + *
    • Linux x86_64 - Nvidia: 28%, 700ms down to 500ms
    • + *
    • Linux x86_64 - AMD : 40%, 1500ms down to 900ms
    • *

      * Can be turned off with property jogl.debug.GLContext.NoProfileAliasing. *

      */ public static final boolean PROFILE_ALIASING = !Debug.isPropertyDefined("jogl.debug.GLContext.NoProfileAliasing", true); - + protected static final boolean FORCE_NO_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.none", true); protected static final boolean FORCE_MIN_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.min", true); - + /** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */ public static final boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true); /** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */ @@ -130,31 +130,31 @@ public abstract class GLContext { public static final VersionNumber Version140 = new VersionNumber(1, 40, 0); /* Version 1.50, i.e. GLSL 1.50 for GL 3.2. */ public static final VersionNumber Version150 = new VersionNumber(1, 50, 0); - + /** Version 3.0. As an OpenGL version, it qualifies for desktop {@link #isGL2()} only, or ES 3.0. */ public static final VersionNumber Version300 = new VersionNumber(3, 0, 0); - + /** Version 3.1. As an OpenGL version, it qualifies for {@link #isGL3core()}, {@link #isGL3bc()} and {@link #isGL3()} */ public static final VersionNumber Version310 = new VersionNumber(3, 1, 0); - + /** Version 3.2. As an OpenGL version, it qualifies for geometry shader */ public static final VersionNumber Version320 = new VersionNumber(3, 2, 0); - + /** Version 4.3. As an OpenGL version, it qualifies for GL_ARB_ES3_compatibility */ public static final VersionNumber Version430 = new VersionNumber(4, 3, 0); - + protected static final VersionNumber Version800 = new VersionNumber(8, 0, 0); // // Cached keys, bits [0..15] // - + /** Context option bits, full bit mask covering bits [0..15], i.e. 0x0000FFFF, {@value}. */ protected static final int CTX_IMPL_FULL_MASK = 0x0000FFFF; - + /** Context option bits, cached bit mask covering 9 bits [0..8], i.e. 0x000001FF, {@value}. Leaving 7 bits for non cached options, i.e. 9:7. */ protected static final int CTX_IMPL_CACHE_MASK = 0x000001FF; - + /** ARB_create_context related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IS_ARB_CREATED = 1 << 0; /** ARB_create_context related: desktop compatibility profile. Cache key value. See {@link #isGLCompatibilityProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ @@ -173,14 +173,14 @@ public abstract class GLContext { // // Non cached keys, bits [9..15] // - + /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IMPL_ES2_COMPAT = 1 << 9; /** GL_ARB_ES3_compatibility implementation related: Context is compatible w/ ES3. Not a cache key. See {@link #isGLES3Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IMPL_ES3_COMPAT = 1 << 10; - - /** + + /** * Context supports basic FBO, details see {@link #hasBasicFBOSupport()}. * Not a cache key. * @see #hasBasicFBOSupport() @@ -188,15 +188,15 @@ public abstract class GLContext { */ protected static final int CTX_IMPL_FBO = 1 << 11; - /** - * Context supports OES_single_precision, fp32, fixed function point (FFP) compatibility entry points, + /** + * Context supports OES_single_precision, fp32, fixed function point (FFP) compatibility entry points, * see {@link #hasFP32CompatAPI()}. * Not a cache key. * @see #hasFP32CompatAPI() * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) */ protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 12; - + private static final ThreadLocal currentContext = new ThreadLocal(); private final HashMap attachedObjects = new HashMap(); @@ -219,9 +219,9 @@ public abstract class GLContext { private int currentSwapInterval; protected GLRendererQuirks glRendererQuirks; - /** Did the drawable association changed ? see {@link GLRendererQuirks#NoSetSwapIntervalPostRetarget} */ - protected boolean drawableRetargeted; - + /** Did the drawable association changed ? see {@link GLRendererQuirks#NoSetSwapIntervalPostRetarget} */ + protected boolean drawableRetargeted; + /** * @param isInit true if called for class initialization, otherwise false (re-init or destruction). */ @@ -242,12 +242,12 @@ public abstract class GLContext { drawableRetargeted = false; } - /** + /** * Returns the instance of {@link GLRendererQuirks}, allowing one to determine workarounds. * @return instance of {@link GLRendererQuirks} if context was made current once, otherwise null. */ public final GLRendererQuirks getRendererQuirks() { return glRendererQuirks; } - + /** * Returns true if the quirk exist in {@link #getRendererQuirks()}, otherwise false. *

      @@ -260,10 +260,10 @@ public abstract class GLContext { * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}. * @throws IllegalArgumentException if the quirk is out of range */ - public final boolean hasRendererQuirk(int quirk) throws IllegalArgumentException { - return null != glRendererQuirks ? glRendererQuirks.exist(quirk) : false ; + public final boolean hasRendererQuirk(int quirk) throws IllegalArgumentException { + return null != glRendererQuirks ? glRendererQuirks.exist(quirk) : false ; } - + /** * Sets the read/write drawable for framebuffer operations. *

      @@ -276,13 +276,13 @@ public abstract class GLContext { * attempts to make this context current. Otherwise a race condition may happen. *

      * @param readWrite The read/write drawable for framebuffer operations, maybe null to remove association. - * @param setWriteOnly Only change the write-drawable, if setWriteOnly is true and - * if the {@link #getGLReadDrawable() read-drawable} differs - * from the {@link #getGLDrawable() write-drawable}. + * @param setWriteOnly Only change the write-drawable, if setWriteOnly is true and + * if the {@link #getGLReadDrawable() read-drawable} differs + * from the {@link #getGLDrawable() write-drawable}. * Otherwise set both drawables, read and write. * @return The previous read/write drawable * - * @throws GLException in case null is being passed or + * @throws GLException in case null is being passed or * this context is made current on another thread. * * @see #isGLReadDrawableAvailable() @@ -292,13 +292,13 @@ public abstract class GLContext { * @see #getGLDrawable() */ public abstract GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly); - + /** * Returns the write-drawable this context uses for framebuffer operations. *

      * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)}, * it equals to the write-drawable (default). - *

      + *

      * @see #setGLDrawable(GLDrawable, boolean) * @see #setGLReadDrawable(GLDrawable) */ @@ -336,10 +336,10 @@ public abstract class GLContext { *

      * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)}, * it equals to the write-drawable (default). - *

      + *

      * @see #isGLReadDrawableAvailable() * @see #setGLReadDrawable(GLDrawable) - * @see #getGLReadDrawable() + * @see #getGLReadDrawable() */ public abstract GLDrawable getGLReadDrawable(); @@ -354,9 +354,9 @@ public abstract class GLContext { *

      *

      * A return value of {@link #CONTEXT_CURRENT_NEW} - * indicates that that context has been made current for the 1st time, + * indicates that that context has been made current for the 1st time, * or that the state of the underlying context or drawable has - * changed since the last time this context was current. + * changed since the last time this context was current. * In this case, the application may wish to initialize the render state. *

      *

      @@ -378,7 +378,7 @@ public abstract class GLContext { *

      * * @return
        - *
      • {@link #CONTEXT_CURRENT_NEW} if the context was successfully made current the 1st time,
      • + *
      • {@link #CONTEXT_CURRENT_NEW} if the context was successfully made current the 1st time,
      • *
      • {@link #CONTEXT_CURRENT} if the context was successfully made current,
      • *
      • {@link #CONTEXT_NOT_CURRENT} if the context could not be made current.
      • *
      @@ -514,7 +514,7 @@ public abstract class GLContext { public abstract void destroy(); /** - * Returns the implementing root GL instance of this GLContext's GL object, + * Returns the implementing root GL instance of this GLContext's GL object, * considering a wrapped pipelined hierarchy, see {@link GLBase#getDownstreamGL()}. * @throws GLException if the root instance is not a GL implementation * @see GLBase#getRootGL() @@ -523,7 +523,7 @@ public abstract class GLContext { * @see #setGL(GL) */ public abstract GL getRootGL(); - + /** * Returns the GL pipeline object for this GLContext. * @@ -716,16 +716,16 @@ public abstract class GLContext { } /** - * Returns this context OpenGL version. - * @see #getGLSLVersionNumber() + * Returns this context OpenGL version. + * @see #getGLSLVersionNumber() **/ public final VersionNumber getGLVersionNumber() { return ctxVersion; } - /** + /** * Returns the vendor's version, i.e. version number at the end of GL_VERSION not being the GL version. *

      - * In case no such version exists within GL_VERSION, + * In case no such version exists within GL_VERSION, * the {@link VersionNumberString#zeroVersion zero version} instance is returned. - *

      + *

      *

      * The vendor's version is usually the vendor's OpenGL driver version. *

      @@ -743,31 +743,31 @@ public abstract class GLContext { * via {@link GL2ES2#GL_SHADING_LANGUAGE_VERSION} if ≥ ES2.0 or GL2.0, * otherwise a static match is being utilized. *

      - * The context must have been current once, - * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned. + * The context must have been current once, + * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned. *

      *

      - * Examples w/ major.minor: + * Examples w/ major.minor: *

      -   *    1.00 (ES 2.0), 1.10 (GL 2.0), 1.20 (GL 2.1), 1.50 (GL 3.2), 
      +   *    1.00 (ES 2.0), 1.10 (GL 2.0), 1.20 (GL 2.1), 1.50 (GL 3.2),
          *    3.30 (GL 3.3), 4.00 (GL 4.0), 4.10 (GL 4.1), 4.20 (GL 4.2)
          * 
      *

      *

      * Matching could also refer to the maximum GLSL version usable by this context * since normal GL implementations are capable of using a lower GLSL version as well. - * The latter is not true on OSX w/ a GL3 context. + * The latter is not true on OSX w/ a GL3 context. *

      - * - * @return GLSL version number if context has been made current at least once, + * + * @return GLSL version number if context has been made current at least once, * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned. - * + * * @see #getGLVersionNumber() */ public final VersionNumber getGLSLVersionNumber() { return ctxGLSLVersion; } - + /** * Returns the GLSL version string as to be used in a shader program, including a terminating newline '\n', * i.e. for desktop @@ -794,10 +794,10 @@ public abstract class GLContext { return ""; } final int minor = ctxGLSLVersion.getMinor(); - final String esSuffix = isGLES() && ctxGLSLVersion.compareTo(Version300) >= 0 ? " es" : ""; + final String esSuffix = isGLES() && ctxGLSLVersion.compareTo(Version300) >= 0 ? " es" : ""; return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + esSuffix + "\n" ; } - + protected static final VersionNumber getStaticGLSLVersionNumber(int glMajorVersion, int glMinorVersion, int ctxOptions) { if( 0 != ( CTX_PROFILE_ES & ctxOptions ) ) { if( 3 > glMajorVersion ) { @@ -814,13 +814,13 @@ public abstract class GLContext { switch ( glMinorVersion ) { case 0: return Version130; // GL 3.0 -> GLSL 1.30 case 1: return Version140; // GL 3.1 -> GLSL 1.40 - default: return Version150; // GL 3.2 -> GLSL 1.50 + default: return Version150; // GL 3.2 -> GLSL 1.50 } } // The new default: GL >= 3.3, ES >= 3.0 return new VersionNumber(glMajorVersion, glMinorVersion * 10, 0); // GL M.N -> GLSL M.N } - + /** * @return true if this context is an ES2 context or implements * the extension GL_ARB_ES3_compatibility or GL_ARB_ES2_compatibility, otherwise false @@ -840,18 +840,18 @@ public abstract class GLContext { return 0 != ( ctxOptions & CTX_IMPL_ES3_COMPAT ) ; } - /** + /** * @return true if impl. is a hardware rasterizer, otherwise false. * @see #isHardwareRasterizer(AbstractGraphicsDevice, GLProfile) - * @see GLProfile#isHardwareRasterizer() + * @see GLProfile#isHardwareRasterizer() */ public final boolean isHardwareRasterizer() { return 0 == ( ctxOptions & CTX_IMPL_ACCEL_SOFT ) ; } - + /** * @return true if context supports GLSL, i.e. is either {@link #isGLES2()}, {@link #isGL3()} or {@link #isGL2()} and major-version > 1. - * @see GLProfile#hasGLSL() + * @see GLProfile#hasGLSL() */ public final boolean hasGLSL() { return isGLES2() || @@ -859,7 +859,7 @@ public abstract class GLContext { isGL2() && ctxVersion.getMajor()>1 ; } - /** + /** * Returns true if basic FBO support is available, otherwise false. *

      * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= core 3.0 or implements the extensions @@ -875,30 +875,30 @@ public abstract class GLContext { return 0 != ( ctxOptions & CTX_IMPL_FBO ) ; } - /** - * Returns true if OES_single_precision, fp32, fixed function point (FFP) compatibility entry points available, + /** + * Returns true if OES_single_precision, fp32, fixed function point (FFP) compatibility entry points available, * otherwise false. * @see #CTX_IMPL_FP32_COMPAT_API */ public final boolean hasFP32CompatAPI() { return 0 != ( ctxOptions & CTX_IMPL_FP32_COMPAT_API ) ; } - - /** + + /** * Returns true if full FBO support is available, otherwise false. *

      * Full FBO is supported if the context is either GL >= core 3.0 or implements the extensions * ARB_framebuffer_object, or all of - * EXT_framebuffer_object, EXT_framebuffer_multisample, + * EXT_framebuffer_object, EXT_framebuffer_multisample, * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil. *

      *

      * Full FBO support includes multiple color attachments and multisampling. *

      */ - public final boolean hasFullFBOSupport() { + public final boolean hasFullFBOSupport() { return hasBasicFBOSupport() && !hasRendererQuirk(GLRendererQuirks.NoFullFBOSupport) && - ( isGL3() || // GL >= 3.0 + ( isGL3() || // GL >= 3.0 isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object ( isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object* isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) && @@ -907,10 +907,10 @@ public abstract class GLContext { ) ) ; } - + /** * Returns the maximum number of FBO RENDERBUFFER samples - * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. + * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. */ public final int getMaxRenderbufferSamples() { if( hasFullFBOSupport() ) { @@ -928,7 +928,7 @@ public abstract class GLContext { } return 0; } - + /** Note: The GL impl. may return a const value, ie {@link GLES2#isNPOTTextureAvailable()} always returns true. */ public boolean isNPOTTextureAvailable() { return isGL3() || isGLES2Compatible() || isExtensionAvailable(GLExtensions.ARB_texture_non_power_of_two); @@ -940,9 +940,9 @@ public abstract class GLContext { isExtensionAvailable(GLExtensions.IMG_texture_format_BGRA8888) ; } - /** + /** * Indicates whether this GLContext is capable of GL4bc.

      Includes [ GL4bc ].

      - * @see GLProfile#isGL4bc() + * @see GLProfile#isGL4bc() */ public final boolean isGL4bc() { return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && @@ -950,9 +950,9 @@ public abstract class GLContext { ctxVersion.getMajor() >= 4; } - /** + /** * Indicates whether this GLContext is capable of GL4.

      Includes [ GL4bc, GL4 ].

      - * @see GLProfile#isGL4() + * @see GLProfile#isGL4() */ public final boolean isGL4() { return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && @@ -960,7 +960,7 @@ public abstract class GLContext { ctxVersion.getMajor() >= 4; } - /** + /** * Indicates whether this GLContext uses a GL4 core profile.

      Includes [ GL4 ].

      */ public final boolean isGL4core() { @@ -968,10 +968,10 @@ public abstract class GLContext { 0 != ( ctxOptions & CTX_PROFILE_CORE ) && ctxVersion.getMajor() >= 4; } - - /** + + /** * Indicates whether this GLContext is capable of GL3bc.

      Includes [ GL4bc, GL3bc ].

      - * @see GLProfile#isGL3bc() + * @see GLProfile#isGL3bc() */ public final boolean isGL3bc() { return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && @@ -979,17 +979,17 @@ public abstract class GLContext { ctxVersion.compareTo(Version310) >= 0 ; } - /** + /** * Indicates whether this GLContext is capable of GL3.

      Includes [ GL4bc, GL4, GL3bc, GL3 ].

      - * @see GLProfile#isGL3() + * @see GLProfile#isGL3() */ public final boolean isGL3() { return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)) && ctxVersion.compareTo(Version310) >= 0 ; - } - - /** + } + + /** * Indicates whether this GLContext uses a GL3 core profile.

      Includes [ GL4, GL3 ].

      */ public final boolean isGL3core() { @@ -997,8 +997,8 @@ public abstract class GLContext { 0 != ( ctxOptions & CTX_PROFILE_CORE ) && ctxVersion.compareTo(Version310) >= 0; } - - /** + + /** * Indicates whether this GLContext uses a GL core profile.

      Includes [ GL4, GL3, GLES3, GLES2 ].

      */ public final boolean isGLcore() { @@ -1008,26 +1008,26 @@ public abstract class GLContext { ctxVersion.compareTo(Version310) >= 0 ) ; } - + /** * Indicates whether this GLContext allows CPU data sourcing (indices, vertices ..) as opposed to using a GPU buffer source (VBO), - * e.g. {@link GL2#glDrawElements(int, int, int, java.nio.Buffer)}. + * e.g. {@link GL2#glDrawElements(int, int, int, java.nio.Buffer)}. *

      Includes [GL2ES1, GLES2] == [ GL4bc, GL3bc, GL2, GLES1, GL2ES1, GLES2 ].

      *

      See Bug 852 - https://jogamp.org/bugzilla/show_bug.cgi?id=852

      */ public final boolean isCPUDataSourcingAvail() { return isGL2ES1() || isGLES2(); } - - /** - * Indicates whether this GLContext's native profile does not implement a default vertex array object (VAO), + + /** + * Indicates whether this GLContext's native profile does not implement a default vertex array object (VAO), * starting w/ OpenGL 3.1 core and GLES3. *

      Includes [ GL4, GL3, GLES3 ].

      *
            Due to GL 3.1 core spec: E.1. DEPRECATED AND REMOVED FEATURES (p 296),
                   GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331)
            there is no more default VAO buffer 0 bound, hence generating and binding one
      -     to avoid INVALID_OPERATION at VertexAttribPointer. 
      +     to avoid INVALID_OPERATION at VertexAttribPointer.
            More clear is GL 4.3 core spec: 10.4 (p 307).
          * 
      *
      @@ -1047,87 +1047,87 @@ public abstract class GLContext {
                      ctxVersion.compareTo(Version310) >= 0
                    ) ;
         }
      -  
      +
         /**
          * If this GLContext does not implement a default VAO, see {@link #hasNoDefaultVAO()},
          * an own default VAO will be created and bound at context creation.
          * 

      * If this GLContext does implement a default VAO, i.e. {@link #hasNoDefaultVAO()} * returns false, this method returns 0. - *

      + *

      *

      * Otherwise this method returns the VAO object name - * representing this GLContext's own default VAO. - *

      + * representing this GLContext's own default VAO. + *

      * @see #hasNoDefaultVAO() */ public abstract int getDefaultVAO(); - /** + /** * Indicates whether this GLContext is capable of GL2.

      Includes [ GL4bc, GL3bc, GL2 ].

      - * @see GLProfile#isGL2() + * @see GLProfile#isGL2() */ public final boolean isGL2() { return 0 != ( ctxOptions & CTX_PROFILE_COMPAT ) && ctxVersion.getMajor()>=1 ; } - /** + /** * Indicates whether this GLContext is capable of GL2GL3.

      Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].

      - * @see GLProfile#isGL2GL3() - */ + * @see GLProfile#isGL2GL3() + */ public final boolean isGL2GL3() { return isGL2() || isGL3(); } - /** + /** * Indicates whether this GLContext is capable of GLES1.

      Includes [ GLES1 ].

      - * @see GLProfile#isGLES1() + * @see GLProfile#isGLES1() */ public final boolean isGLES1() { return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 1 ; } /** - * Indicates whether this GLContext is capable of GLES2.

      Includes [ GLES2 ].

      - * @see GLProfile#isGLES2() + * Indicates whether this GLContext is capable of GLES2.

      Includes [ GLES2 ].

      + * @see GLProfile#isGLES2() */ public final boolean isGLES2() { return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 2 ; } - /** + /** * Indicates whether this GLContext is capable of GLES3.

      Includes [ GLES3 ].

      - * @see GLProfile#isGLES3() + * @see GLProfile#isGLES3() */ public final boolean isGLES3() { return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ; } - /** + /** * Indicates whether this GLContext is capable of GLES.

      Includes [ GLES3, GLES1, GLES2 ].

      - * @see GLProfile#isGLES() + * @see GLProfile#isGLES() */ public final boolean isGLES() { return 0 != ( CTX_PROFILE_ES & ctxOptions ) ; } - /** + /** * Indicates whether this GLContext is capable of GL2ES1.

      Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].

      - * @see GLProfile#isGL2ES1() + * @see GLProfile#isGL2ES1() */ public final boolean isGL2ES1() { return isGLES1() || isGL2(); } - /** + /** * Indicates whether this GLContext is capable of GL2ES2.

      Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GL2GL3, GL2ES2, GLES2 ].

      - * @see GLProfile#isGL2ES2() + * @see GLProfile#isGL2ES2() */ public final boolean isGL2ES2() { return isGLES2() || isGL2GL3(); } - /** + /** * Indicates whether this GLContext is capable of GL2ES3.

      Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL3ES3, GL2, GL2GL3 ].

      * @see GLProfile#isGL2ES3() * @see #isGL3ES3() @@ -1137,16 +1137,16 @@ public abstract class GLContext { return isGL3ES3() || isGL2GL3(); } - /** + /** * Indicates whether this GLContext is capable of GL3ES3.

      Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].

      - * @see GLProfile#isGL3ES3() + * @see GLProfile#isGL3ES3() */ public final boolean isGL3ES3() { return isGL4ES3() || isGL3(); } - /** - * Returns true if this profile is capable of GL4ES3, i.e. if {@link #isGLES3Compatible()} returns true. + /** + * Returns true if this profile is capable of GL4ES3, i.e. if {@link #isGLES3Compatible()} returns true. *

      Includes [ GL ≥ 4.3, GL ≥ 3.1 w/ GL_ARB_ES3_compatibility and GLES3 ]

      * @see GLProfile#isGL4ES3() */ @@ -1185,7 +1185,7 @@ public abstract class GLContext { *

      *

      * For a valid context the default value is 1 - * in case of an EGL based profile (ES1 or ES2) and -1 + * in case of an EGL based profile (ES1 or ES2) and -1 * (undefined) for desktop. *

      */ @@ -1222,51 +1222,51 @@ public abstract class GLContext { } protected boolean bindSwapBarrierImpl(int group, int barrier) { /** nop per default .. **/ return false; } - /** - * Return the framebuffer name bound to this context, + /** + * Return the framebuffer name bound to this context, * see {@link GL#glBindFramebuffer(int, int)}. */ public abstract int getBoundFramebuffer(int target); - - /** + + /** * Return the default draw framebuffer name. - *

      + *

      * May differ from it's default zero * in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable * is being used. - *

      + *

      */ public abstract int getDefaultDrawFramebuffer(); - - /** + + /** * Return the default read framebuffer name. - *

      + *

      * May differ from it's default zero * in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable * is being used. - *

      + *

      */ public abstract int getDefaultReadFramebuffer(); - - /** - * Returns the default color buffer within the current bound - * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​, - * which will be used as the source for pixel reading commands, + + /** + * Returns the default color buffer within the current bound + * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​, + * which will be used as the source for pixel reading commands, * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)} etc. *

      * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0}, - * otherwise this is {@link GL#GL_FRONT} for single buffer configurations + * otherwise this is {@link GL#GL_FRONT} for single buffer configurations * and {@link GL#GL_BACK} for double buffer configurations. - *

      + *

      */ public abstract int getDefaultReadBuffer(); - + /** Get the default pixel data type, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}. */ public abstract int getDefaultPixelDataType(); - + /** Get the default pixel data format, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}. */ public abstract int getDefaultPixelDataFormat(); - + /** * @return The extension implementing the GLDebugOutput feature, * either {@link GLExtensions#ARB_debug_output} or {@link GLExtensions#AMD_debug_output}. @@ -1486,13 +1486,13 @@ public abstract class GLContext { } if (DEBUG) { System.err.println(getThreadName() + ": createContextARB: SET mappedVersionsAvailableSet "+devKey); - System.err.println(GLContext.dumpAvailableGLVersions(null).toString()); + System.err.println(GLContext.dumpAvailableGLVersions(null).toString()); } } } - /** - * Returns a unique String object using {@link String#intern()} for the given arguments, + /** + * Returns a unique String object using {@link String#intern()} for the given arguments, * which object reference itself can be used as a key. */ protected static String getDeviceVersionAvailableKey(AbstractGraphicsDevice device, int major, int profile) { @@ -1575,7 +1575,7 @@ public abstract class GLContext { } return val; } - + /** * @param reqMajor Key Value either 1, 2, 3 or 4 * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES} @@ -1647,7 +1647,7 @@ public abstract class GLContext { reqMajorCTP[1]=CTX_PROFILE_CORE; } } - + /** * @param device the device the context profile is being requested for * @param GLProfile the GLProfile the context profile is being requested for @@ -1656,7 +1656,7 @@ public abstract class GLContext { protected static final int getAvailableContextProperties(final AbstractGraphicsDevice device, final GLProfile glp) { final int[] reqMajorCTP = new int[] { 0, 0 }; getRequestMajorAndCompat(glp, reqMajorCTP); - + int _major[] = { 0 }; int _minor[] = { 0 }; int _ctp[] = { 0 }; @@ -1702,7 +1702,7 @@ public abstract class GLContext { * Returns true if it is possible to create an framebuffer object (FBO). *

      * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. - *

      + *

      *

      * FBO support is queried as described in {@link #hasBasicFBOSupport()}. *

      @@ -1714,16 +1714,16 @@ public abstract class GLContext { public static final boolean isFBOAvailable(AbstractGraphicsDevice device, GLProfile glp) { return 0 != ( CTX_IMPL_FBO & getAvailableContextProperties(device, glp) ); } - + /** - * @return 1 if using a hardware rasterizer, 0 if using a software rasterizer and -1 if not determined yet. + * @return 1 if using a hardware rasterizer, 0 if using a software rasterizer and -1 if not determined yet. * @see GLContext#isHardwareRasterizer() - * @see GLProfile#isHardwareRasterizer() + * @see GLProfile#isHardwareRasterizer() */ public static final int isHardwareRasterizer(AbstractGraphicsDevice device, GLProfile glp) { final int r; final int ctp = getAvailableContextProperties(device, glp); - if(0 == ctp) { + if(0 == ctp) { r = -1; } else if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctp ) ) { r = 1; @@ -1732,7 +1732,7 @@ public abstract class GLContext { } return r; } - + /** * @param device the device to request whether the profile is available for * @param reqMajor Key Value either 1, 2, 3 or 4 @@ -1774,7 +1774,7 @@ public abstract class GLContext { int minor[] = { 0 }; int ctp[] = { 0 }; boolean ok; - + ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_ES, major, minor, ctp); if( !ok ) { ok = GLContext.getAvailableGLVersion(device, 3, GLContext.CTX_PROFILE_CORE, major, minor, ctp); @@ -1784,7 +1784,7 @@ public abstract class GLContext { } return 0 != ( ctp[0] & CTX_IMPL_ES3_COMPAT ); } - + public static boolean isGL4bcAvailable(AbstractGraphicsDevice device, boolean isHardware[]) { return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT, isHardware); } @@ -1859,6 +1859,6 @@ public abstract class GLContext { } protected static String getThreadName() { return Thread.currentThread().getName(); } - + } diff --git a/src/jogl/classes/javax/media/opengl/GLDebugListener.java b/src/jogl/classes/javax/media/opengl/GLDebugListener.java index 8887d022a..ec7f7cec1 100644 --- a/src/jogl/classes/javax/media/opengl/GLDebugListener.java +++ b/src/jogl/classes/javax/media/opengl/GLDebugListener.java @@ -29,16 +29,16 @@ package javax.media.opengl; /** * Listener for {@link GLDebugMessage}s. - * + * *

      One can enable GLDebugOutput via {@link GLContext#enableGLDebugMessage(boolean)} * and add listeners via {@link GLContext#addGLDebugListener(GLDebugListener)}. */ public interface GLDebugListener { - /** + /** * Handle {@link GLDebugMessage} message sent from native GL implementation. - * + * *

      Since this method is invoked directly by the GL implementation, it shall * return as fast as possible.

      */ - void messageSent(GLDebugMessage event); + void messageSent(GLDebugMessage event); } diff --git a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java index 4b8d62898..1032cf929 100644 --- a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java +++ b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java @@ -30,18 +30,18 @@ package javax.media.opengl; import com.jogamp.common.os.Platform; /** - * OpenGL debug message generated by the driver + * OpenGL debug message generated by the driver * and delivered via {@link GLDebugListener}. */ public class GLDebugMessage { final GLContext source; - final long when; + final long when; final int dbgSource; final int dbgType; final int dbgId; final int dbgSeverity; final String dbgMsg; - + /** * @param source The source of the event * @param when The time of the event @@ -60,9 +60,9 @@ public class GLDebugMessage { this.dbgSeverity = dbgSeverity; this.dbgMsg = dbgMsg; } - + /** - * + * * @param source * @param when * @param dbgId @@ -73,88 +73,88 @@ public class GLDebugMessage { */ public static GLDebugMessage translateAMDEvent(GLContext source, long when, int dbgId, int amdDbgCategory, int dbgSeverity, String dbgMsg) { int dbgSource, dbgType; - + // AMD category == ARB source/type switch(amdDbgCategory) { - case GL2GL3.GL_DEBUG_CATEGORY_API_ERROR_AMD: + case GL2GL3.GL_DEBUG_CATEGORY_API_ERROR_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_API; - dbgType = GL2GL3.GL_DEBUG_TYPE_ERROR; + dbgType = GL2GL3.GL_DEBUG_TYPE_ERROR; break; // // def source / other type // - - case GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD: + + case GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM; - dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; break; - + case GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER; - dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; break; - + case GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_APPLICATION; dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; break; - - + + // // other source / def type // - + case GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; - dbgType = GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR; + dbgType = GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR; break; - + case GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; - dbgType = GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR; + dbgType = GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR; break; - + case GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD: dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; - dbgType = GL2GL3.GL_DEBUG_TYPE_PERFORMANCE; + dbgType = GL2GL3.GL_DEBUG_TYPE_PERFORMANCE; break; - - case GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD: + + case GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD: default: dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; } - - return new GLDebugMessage(source, when, dbgSource, dbgType, dbgId, dbgSeverity, dbgMsg); + + return new GLDebugMessage(source, when, dbgSource, dbgType, dbgId, dbgSeverity, dbgMsg); } public static int translateARB2AMDCategory(int dbgSource, int dbgType) { switch (dbgSource) { case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM: - return GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD; - + return GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD; + case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER: return GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD; - + case GL2GL3.GL_DEBUG_SOURCE_APPLICATION: return GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD; } - + switch(dbgType) { case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD; - + case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD; - - case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE: + + case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE: return GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD; } - - return GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD; + + return GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD; } - + public GLContext getSource() { return source; } @@ -162,7 +162,7 @@ public class GLDebugMessage { public long getWhen() { return when; } - + public int getDbgSource() { return dbgSource; } @@ -182,14 +182,14 @@ public class GLDebugMessage { public String getDbgMsg() { return dbgMsg; } - + public StringBuilder toString(StringBuilder sb) { - final String crtab = Platform.getNewline()+"\t"; + final String crtab = Platform.getNewline()+"\t"; if(null==sb) { sb = new StringBuilder(); - } + } sb.append("GLDebugEvent[ id "); - toHexString(sb, dbgId) + toHexString(sb, dbgId) .append(crtab).append("type ").append(getDbgTypeString(dbgType)) .append(crtab).append("severity ").append(getDbgSeverityString(dbgSeverity)) .append(crtab).append("source ").append(getDbgSourceString(dbgSource)) @@ -199,46 +199,46 @@ public class GLDebugMessage { sb.append(crtab).append("source ").append(source.getGLVersion()).append(" - hash 0x").append(Integer.toHexString(source.hashCode())); } sb.append("]"); - return sb; + return sb; } public String toString() { return toString(null).toString(); } - + public static String getDbgSourceString(int dbgSource) { switch(dbgSource) { case GL2GL3.GL_DEBUG_SOURCE_API: return "GL API"; - case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER: return "GLSL or extension compiler"; - case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "Native Windowing binding"; + case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER: return "GLSL or extension compiler"; + case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "Native Windowing binding"; case GL2GL3.GL_DEBUG_SOURCE_THIRD_PARTY: return "Third party"; case GL2GL3.GL_DEBUG_SOURCE_APPLICATION: return "Application"; case GL2GL3.GL_DEBUG_SOURCE_OTHER: return "generic"; default: return "Unknown (" + toHexString(dbgSource) + ")"; } } - + public static String getDbgTypeString(int dbgType) { switch(dbgType) { case GL2GL3.GL_DEBUG_TYPE_ERROR: return "Error"; - case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "Warning: marked for deprecation"; + case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "Warning: marked for deprecation"; case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return "Warning: undefined behavior"; - case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE: return "Warning: implementation dependent performance"; - case GL2GL3.GL_DEBUG_TYPE_PORTABILITY: return "Warning: vendor-specific extension use"; - case GL2GL3.GL_DEBUG_TYPE_OTHER: return "Warning: generic"; + case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE: return "Warning: implementation dependent performance"; + case GL2GL3.GL_DEBUG_TYPE_PORTABILITY: return "Warning: vendor-specific extension use"; + case GL2GL3.GL_DEBUG_TYPE_OTHER: return "Warning: generic"; default: return "Unknown (" + toHexString(dbgType) + ")"; } } - + public static String getDbgSeverityString(int dbgSeverity) { switch(dbgSeverity) { - case GL2GL3.GL_DEBUG_SEVERITY_HIGH: return "High: dangerous undefined behavior"; - case GL2GL3.GL_DEBUG_SEVERITY_MEDIUM: return "Medium: Severe performance/deprecation/other warnings"; - case GL2GL3.GL_DEBUG_SEVERITY_LOW: return "Low: Performance warnings (redundancy/undefined)"; + case GL2GL3.GL_DEBUG_SEVERITY_HIGH: return "High: dangerous undefined behavior"; + case GL2GL3.GL_DEBUG_SEVERITY_MEDIUM: return "Medium: Severe performance/deprecation/other warnings"; + case GL2GL3.GL_DEBUG_SEVERITY_LOW: return "Low: Performance warnings (redundancy/undefined)"; default: return "Unknown (" + toHexString(dbgSeverity) + ")"; } } - + public static StringBuilder toHexString(StringBuilder sb, int i) { if(null==sb) { sb = new StringBuilder(); @@ -247,6 +247,6 @@ public class GLDebugMessage { } public static String toHexString(int i) { return "0x"+Integer.toHexString(i); - } - + } + } diff --git a/src/jogl/classes/javax/media/opengl/GLDrawable.java b/src/jogl/classes/javax/media/opengl/GLDrawable.java index 46fa923ad..5a032db29 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawable.java @@ -73,13 +73,13 @@ public interface GLDrawable { *

      *

      * End users do not need to call this method; it is not necessary to - * call setRealized on a {@link GLAutoDrawable} + * call setRealized on a {@link GLAutoDrawable} * as these perform the appropriate calls on their underlying GLDrawables internally. *

      *

      * Developers implementing new OpenGL components for various window * toolkits need to call this method against GLDrawables obtained - * from the GLDrawableFactory via the + * from the GLDrawableFactory via the * {@link GLDrawableFactory#createGLDrawable(NativeSurface)} method. * It must typically be * called with an argument of true when the component @@ -89,7 +89,7 @@ public interface GLDrawable { * the addNotify method and with an argument of * false in the removeNotify method. *

      - *

      + *

      * GLDrawable implementations should handle multiple * cycles of setRealized(true) / * setRealized(false) calls. Most, if not all, Java @@ -104,7 +104,7 @@ public interface GLDrawable { * associated resources as the component becomes realized and * unrealized, respectively. *

      - *

      + *

      * With an argument of true, * the minimum implementation shall call * {@link NativeSurface#lockSurface() NativeSurface's lockSurface()} and if successful: @@ -117,7 +117,7 @@ public interface GLDrawable { * ensures resolving the window/surface handles, and the drawable's {@link GLCapabilities} * might have changed. *

      - *

      + *

      * Calling this method has no other effects. For example, if * removeNotify is called on a Canvas implementation * for which a GLDrawable has been created, it is also necessary to @@ -130,7 +130,7 @@ public interface GLDrawable { */ public void setRealized(boolean realized); - /** + /** * Returns true if this drawable is realized, otherwise true. *

      * A drawable can be realized and unrealized via {@link #setRealized(boolean)}. @@ -146,19 +146,19 @@ public interface GLDrawable { public int getHeight(); /** - * Returns true if the drawable is rendered in + * Returns true if the drawable is rendered in * OpenGL's coordinate system, origin at bottom left. * Otherwise returns false, i.e. origin at top left. *

      * Default impl. is true, i.e. OpenGL coordinate system. - *

      + *

      *

      * Currently only MS-Windows bitmap offscreen drawable uses a non OpenGL orientation and hence returns false.
      * This removes the need of a vertical flip when used in AWT or Windows applications. *

      */ public boolean isGLOriented(); - + /** Swaps the front and back buffers of this drawable. For {@link GLAutoDrawable} implementations, when automatic buffer swapping is enabled (as is the default), this method is called @@ -191,11 +191,11 @@ public interface GLDrawable { public NativeSurface getNativeSurface(); /** - * Returns the GL drawable handle, + * Returns the GL drawable handle, * guaranteed to be valid after {@link #setRealized(boolean) realization} * and while it's {@link NativeSurface surface} is being {@link NativeSurface#lockSurface() locked}. *

      - * It is usually identical to the underlying windowing toolkit {@link NativeSurface surface}'s + * It is usually identical to the underlying windowing toolkit {@link NativeSurface surface}'s * {@link javax.media.nativewindow.NativeSurface#getSurfaceHandle() handle} * or an intermediate layer to suite GL, e.g. an EGL surface. *

      diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 7c3c42e45..e486e2bfd 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -83,7 +83,7 @@ import jogamp.opengl.Debug; during the first repaint of the {@link javax.media.opengl.awt.GLCanvas} or {@link javax.media.opengl.awt.GLJPanel} if the capabilities can not be met.
      {@link javax.media.opengl.GLPbuffer} are always - created immediately and their creation will fail with a + created immediately and their creation will fail with a {@link javax.media.opengl.GLException} if errors occur.

      The concrete GLDrawableFactory subclass instantiated by {@link @@ -94,21 +94,21 @@ import jogamp.opengl.Debug; public abstract class GLDrawableFactory { protected static final boolean DEBUG = Debug.debug("GLDrawable"); - - /** - * We have to disable support for ANGLE, the D3D ES2 emulation on Windows provided w/ Firefox and Chrome. + + /** + * We have to disable support for ANGLE, the D3D ES2 emulation on Windows provided w/ Firefox and Chrome. * When run in the mentioned browsers, the eglInitialize(..) implementation crashes. *

      * This can be overridden by explicitly enabling ANGLE on Windows by setting the property * jogl.enable.ANGLE. - *

      + *

      */ protected static final boolean enableANGLE = Debug.isPropertyDefined("jogl.enable.ANGLE", true); - /** + /** * In case no OpenGL ES implementation is required * and if the running platform may have a buggy implementation, - * setting the property jogl.disable.opengles disables querying a possible existing OpenGL ES implementation. + * setting the property jogl.disable.opengles disables querying a possible existing OpenGL ES implementation. */ protected static final boolean disableOpenGLES = Debug.isPropertyDefined("jogl.disable.opengles", true); @@ -117,11 +117,11 @@ public abstract class GLDrawableFactory { private static GLDrawableFactory nativeOSFactory; private static ArrayList glDrawableFactories = new ArrayList(); - + /** * Instantiate singleton factories if available, EGLES1, EGLES2 and the OS native ones. */ - public static final void initSingleton() { + public static final void initSingleton() { if (!isInit) { // volatile: ok synchronized (GLDrawableFactory.class) { if (!isInit) { @@ -130,7 +130,7 @@ public abstract class GLDrawableFactory { } } } - } + } private static final void initSingletonImpl() { NativeWindowFactory.initSingleton(); NativeWindowFactory.addCustomShutdownHook(false /* head */, new Runnable() { @@ -138,7 +138,7 @@ public abstract class GLDrawableFactory { shutdown0(); } }); - + final String nwt = NativeWindowFactory.getNativeWindowType(true); GLDrawableFactory tmp = null; String factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true); @@ -163,7 +163,7 @@ public abstract class GLDrawableFactory { } try { tmp = (GLDrawableFactory) ReflectionUtil.createInstance(factoryClassName, cl); - } catch (Exception jre) { + } catch (Exception jre) { if (DEBUG || GLProfile.DEBUG) { System.err.println("Info: GLDrawableFactory.static - Native Platform: "+nwt+" - not available: "+factoryClassName); jre.printStackTrace(); @@ -202,7 +202,7 @@ public abstract class GLDrawableFactory { } } } - + private static void shutdown0() { // Following code will _always_ remain in shutdown hook // due to special semantics of native utils, i.e. X11Utils. @@ -228,22 +228,22 @@ public abstract class GLDrawableFactory { } } glDrawableFactories.clear(); - - // both were members of glDrawableFactories and are shutdown already + + // both were members of glDrawableFactories and are shutdown already nativeOSFactory = null; eglFactory = null; } GLContext.shutdown(); } - + protected GLDrawableFactory() { synchronized(glDrawableFactories) { glDrawableFactories.add(this); } } - + protected static String getThreadName() { return Thread.currentThread().getName(); } - + /** Returns true if this factory is complete, i.e. ready to be used. Otherwise return false. */ protected abstract boolean isComplete(); @@ -253,14 +253,14 @@ public abstract class GLDrawableFactory { protected abstract void destroy(); public abstract void resetDisplayGamma(); - + /** * Retrieve the default device {@link AbstractGraphicsDevice#getConnection() connection}, * {@link AbstractGraphicsDevice#getUnitID() unit ID} and {@link AbstractGraphicsDevice#getUniqueID() unique ID name}. for this factory
      * The implementation must return a non null default device, which must not be opened, ie. it's native handle is null. *

      * This method shall return the default device if available - * even if the GLDrawableFactory is not functional and hence not compatible. + * even if the GLDrawableFactory is not functional and hence not compatible. * The latter situation may happen because no native OpenGL implementation is available for the specific implementation. *

      * @return the default shared device for this factory, eg. :0.0 on X11 desktop. @@ -272,7 +272,7 @@ public abstract class GLDrawableFactory { * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. * @return true if the device is compatible with this factory, ie. if it can be used for GLDrawable creation. Otherwise false. * This implies validation whether the implementation is functional. - * + * * @see #getDefaultDevice() */ public abstract boolean getIsDeviceCompatible(AbstractGraphicsDevice device); @@ -287,8 +287,8 @@ public abstract class GLDrawableFactory { System.err.println("Info: "+getClass().getSimpleName()+".validateDevice: using default device : "+device); } } - - // Always validate the device, + + // Always validate the device, // since even the default device may not be used by this factory. if( !getIsDeviceCompatible(device) ) { if (GLProfile.DEBUG) { @@ -300,29 +300,29 @@ public abstract class GLDrawableFactory { } /** - * Validate and start the shared resource runner thread if necessary and + * Validate and start the shared resource runner thread if necessary and * if the implementation uses it. - * + * * @return the shared resource runner thread, if implementation uses it. */ protected abstract Thread getSharedResourceThread(); - + /** * Create the shared resource used internally as a reference for capabilities etc. *

      - * Returns true if a shared resource could be created + * Returns true if a shared resource could be created * for the device {@link AbstractGraphicsDevice#getConnection()}.
      * This does not imply a shared resource is mapped (ie. made persistent), but is available in general
      . *

      * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. - * @return true if a shared resource could been created, otherwise false. + * @return true if a shared resource could been created, otherwise false. */ protected final boolean createSharedResource(AbstractGraphicsDevice device) { return createSharedResourceImpl(device); - } + } protected abstract boolean createSharedResourceImpl(AbstractGraphicsDevice device); - + /** * Returns true if the quirk exist in the shared resource's context {@link GLRendererQuirks}. *

      @@ -332,7 +332,7 @@ public abstract class GLDrawableFactory { return null != glrq ? glrq.exist(quirk) : false; *

      *

      - * + * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}. * @throws IllegalArgumentException if the quirk is out of range @@ -343,7 +343,7 @@ public abstract class GLDrawableFactory { final GLRendererQuirks glrq = getRendererQuirks(device); return null != glrq ? glrq.exist(quirk) : false; } - + /** * Returns the shared resource's context {@link GLRendererQuirks}. *

      @@ -358,12 +358,12 @@ public abstract class GLDrawableFactory { * @see GLRendererQuirks */ public abstract GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device); - + /** * Returns the sole GLDrawableFactory instance for the desktop (X11, WGL, ..) if exist or null */ public static GLDrawableFactory getDesktopFactory() { - GLProfile.initSingleton(); + GLProfile.initSingleton(); return nativeOSFactory; } @@ -371,14 +371,14 @@ public abstract class GLDrawableFactory { * Returns the sole GLDrawableFactory instance for EGL if exist or null */ public static GLDrawableFactory getEGLFactory() { - GLProfile.initSingleton(); + GLProfile.initSingleton(); return eglFactory; } - /** - * Returns the sole GLDrawableFactory instance. - * - * @param glProfile GLProfile to determine the factory type, ie EGLDrawableFactory, + /** + * Returns the sole GLDrawableFactory instance. + * + * @param glProfile GLProfile to determine the factory type, ie EGLDrawableFactory, * or one of the native GLDrawableFactory's, ie X11/GLX, Windows/WGL or MacOSX/CGL. */ public static GLDrawableFactory getFactory(GLProfile glProfile) throws GLException { @@ -387,7 +387,7 @@ public abstract class GLDrawableFactory { protected static GLDrawableFactory getFactoryImpl(String glProfileImplName) throws GLException { if ( GLProfile.usesNativeGLES(glProfileImplName) ) { - if(null!=eglFactory) { + if(null!=eglFactory) { return eglFactory; } } else if(null!=nativeOSFactory) { @@ -446,10 +446,10 @@ public abstract class GLDrawableFactory { * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true. *

      *

      - * If not onscreen and neither FBO nor Pbuffer is available, + * If not onscreen and neither FBO nor Pbuffer is available, * a simple pixmap/bitmap drawable/surface is created, which is unlikely to be hardware accelerated. *

      - * + * * @throws IllegalArgumentException if the passed target is null * @throws GLException if any window system-specific errors caused * the creation of the GLDrawable to fail. @@ -463,12 +463,12 @@ public abstract class GLDrawableFactory { */ public abstract GLDrawable createGLDrawable(NativeSurface target) throws IllegalArgumentException, GLException; - + /** - * Creates a {@link GLDrawable#isRealized() realized} {@link GLOffscreenAutoDrawable} + * Creates a {@link GLDrawable#isRealized() realized} {@link GLOffscreenAutoDrawable} * incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. *

      - * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized} + * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized} * and it's {@link GLContext} assigned but not yet made current. *

      *

      @@ -485,7 +485,7 @@ public abstract class GLDrawableFactory { * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true. *

      *

      - * If neither FBO nor Pbuffer is available, + * If neither FBO nor Pbuffer is available, * a simple pixmap/bitmap auto drawable is created, which is unlikely to be hardware accelerated. *

      * @@ -498,7 +498,7 @@ public abstract class GLDrawableFactory { * * @throws GLException if any window system-specific errors caused * the creation of the Offscreen to fail. - * + * * @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) */ public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, @@ -507,7 +507,7 @@ public abstract class GLDrawableFactory { int width, int height, GLContext shareWith) throws GLException; /** - * Creates an {@link GLDrawable#isRealized() unrealized} offscreen {@link GLDrawable} + * Creates an {@link GLDrawable#isRealized() unrealized} offscreen {@link GLDrawable} * incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. *

      * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e. @@ -523,7 +523,7 @@ public abstract class GLDrawableFactory { * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true. *

      *

      - * If neither FBO nor Pbuffer is available, + * If neither FBO nor Pbuffer is available, * a simple pixmap/bitmap drawable is created, which is unlikely to be hardware accelerated. *

      * @@ -537,7 +537,7 @@ public abstract class GLDrawableFactory { * * @throws GLException if any window system-specific errors caused * the creation of the Offscreen to fail. - * + * * @see #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext) */ public abstract GLDrawable createOffscreenDrawable(AbstractGraphicsDevice device, @@ -546,7 +546,7 @@ public abstract class GLDrawableFactory { int width, int height) throws GLException; /** - * Creates an {@link GLDrawable#isRealized() unrealized} dummy {@link GLDrawable}. + * Creates an {@link GLDrawable#isRealized() unrealized} dummy {@link GLDrawable}. * A dummy drawable is not visible on screen and will not be used to render directly to, it maybe on- or offscreen. *

      * It is used to allow the creation of a {@link GLContext} to query information. @@ -558,26 +558,26 @@ public abstract class GLDrawableFactory { * @return the created dummy {@link GLDrawable} */ public abstract GLDrawable createDummyDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLProfile glp); - + /** - * Creates a proxy {@link NativeSurface} w/ defined surface handle, - * i.e. a {@link jogamp.nativewindow.WrappedSurface} or {@link jogamp.nativewindow.windows.GDISurface} instance. + * Creates a proxy {@link NativeSurface} w/ defined surface handle, + * i.e. a {@link jogamp.nativewindow.WrappedSurface} or {@link jogamp.nativewindow.windows.GDISurface} instance. *

      - * It's {@link AbstractGraphicsConfiguration} is properly set according to the given + * It's {@link AbstractGraphicsConfiguration} is properly set according to the given * windowHandle's native visualID if set or the given {@link GLCapabilitiesImmutable}. *

      *

      * Lifecycle (creation and destruction) of the given surface handle shall be handled by the caller - * via {@link ProxySurface#createNotify()} and {@link ProxySurface#destroyNotify()}. + * via {@link ProxySurface#createNotify()} and {@link ProxySurface#destroyNotify()}. *

      *

      * Such surface can be used to instantiate a GLDrawable. With the help of {@link GLAutoDrawableDelegate} - * you will be able to implement a new native windowing system binding almost on-the-fly, - * see {@link com.jogamp.opengl.swt.GLCanvas}. + * you will be able to implement a new native windowing system binding almost on-the-fly, + * see {@link com.jogamp.opengl.swt.GLCanvas}. *

      - * + * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. - * Caller has to ensure it is compatible w/ the given windowHandle + * Caller has to ensure it is compatible w/ the given windowHandle * @param screenIdx matching screen index of given windowHandle * @param windowHandle the native window handle * @param caps the requested GLCapabilties @@ -586,15 +586,15 @@ public abstract class GLDrawableFactory { * @return the created {@link ProxySurface} instance w/ defined surface handle. */ public abstract ProxySurface createProxySurface(AbstractGraphicsDevice device, - int screenIdx, - long windowHandle, + int screenIdx, + long windowHandle, GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream); - + /** * Returns true if it is possible to create an framebuffer object (FBO). *

      * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. - *

      + *

      *

      * FBO support is queried as described in {@link GLContext#hasBasicFBOSupport()}. *

      @@ -607,9 +607,9 @@ public abstract class GLDrawableFactory { /** * Returns true if it is possible to create an pbuffer surface. - *

      - * Some older graphics cards do not have this capability, - * as well as some new GL implementation, i.e. OpenGL 3 core on OSX. + *

      + * Some older graphics cards do not have this capability, + * as well as some new GL implementation, i.e. OpenGL 3 core on OSX. *

      * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. @@ -637,7 +637,7 @@ public abstract class GLDrawableFactory { * * @throws GLException if any window system-specific errors caused * the creation of the GLPbuffer to fail. - * + * * @deprecated {@link GLPbuffer} is deprecated, use {@link #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext)} */ public abstract GLPbuffer createGLPbuffer(AbstractGraphicsDevice device, @@ -648,7 +648,7 @@ public abstract class GLDrawableFactory { GLContext shareWith) throws GLException; - + //---------------------------------------------------------------------- // Methods for interacting with third-party OpenGL libraries diff --git a/src/jogl/classes/javax/media/opengl/GLEventListener.java b/src/jogl/classes/javax/media/opengl/GLEventListener.java index 15fae4a39..c8c3440b5 100644 --- a/src/jogl/classes/javax/media/opengl/GLEventListener.java +++ b/src/jogl/classes/javax/media/opengl/GLEventListener.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -49,7 +49,7 @@ import java.util.EventListener; public interface GLEventListener extends EventListener { /** Called by the drawable immediately after the OpenGL context is initialized. Can be used to perform one-time OpenGL - initialization per GLContext, such as setup of lights and display lists.

      + initialization per GLContext, such as setup of lights and display lists.

      Note that this method may be called more than once if the underlying OpenGL context for the GLAutoDrawable is destroyed and @@ -57,7 +57,7 @@ public interface GLEventListener extends EventListener { hierarchy and later added again. */ public void init(GLAutoDrawable drawable); - + /** Notifies the listener to perform the release of all OpenGL resources per GLContext, such as memory buffers and GLSL programs.

      @@ -68,11 +68,11 @@ public interface GLEventListener extends EventListener { Note that this event does not imply the end of life of the application. It could be produced with a followup call to {@link #init(GLAutoDrawable)} - in case the GLContext has been recreated, + in case the GLContext has been recreated, e.g. due to a pixel configuration change in a multihead environment. */ public void dispose(GLAutoDrawable drawable); - + /** Called by the drawable to initiate OpenGL rendering by the client. After all GLEventListeners have been notified of a display event, the drawable will swap its buffers if {@link diff --git a/src/jogl/classes/javax/media/opengl/GLException.java b/src/jogl/classes/javax/media/opengl/GLException.java index 644042e15..460f17be9 100644 --- a/src/jogl/classes/javax/media/opengl/GLException.java +++ b/src/jogl/classes/javax/media/opengl/GLException.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java index df38745d5..052b08a4b 100644 --- a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -33,17 +33,17 @@ import javax.media.nativewindow.NativeWindowException; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.FBObject.TextureAttachment; -/** +/** * Platform-independent {@link GLDrawable} specialization, * exposing {@link FBObject} functionality. * *

      - * A {@link GLFBODrawable} is uninitialized until a {@link GLContext} is bound + * A {@link GLFBODrawable} is uninitialized until a {@link GLContext} is bound * and made current the first time, hence only then it's capabilities fully reflect expectations, * i.e. color, depth, stencil and MSAA bits will be valid only after the first {@link GLContext#makeCurrent() makeCurrent()} call. * On-/offscreen bits are valid after {@link #setRealized(boolean) setRealized(true)}. *

      - * + * *

      * MSAA is used if {@link GLCapabilitiesImmutable#getNumSamples() requested}. *

      @@ -51,7 +51,7 @@ import com.jogamp.opengl.FBObject.TextureAttachment; * Double buffering is used if {@link GLCapabilitiesImmutable#getDoubleBuffered() requested}. *

      *

      - * In MSAA mode, it always uses the implicit 2nd {@link FBObject framebuffer} {@link FBObject#getSamplingSinkFBO() sink}. + * In MSAA mode, it always uses the implicit 2nd {@link FBObject framebuffer} {@link FBObject#getSamplingSinkFBO() sink}. * Hence double buffering is always the case w/ MSAA. *

      *

      @@ -61,7 +61,7 @@ import com.jogamp.opengl.FBObject.TextureAttachment; * This method also allows usage of both textures seperately. *

      *

      - * It would be possible to implement double buffering simply using + * It would be possible to implement double buffering simply using * {@link TextureAttachment}s with one {@link FBObject framebuffer}. * This would require mode selection and hence complicate the API. Besides, it would * not support differentiation of read and write framebuffer and hence not be spec compliant. @@ -71,50 +71,50 @@ import com.jogamp.opengl.FBObject.TextureAttachment; * is performed either in the {@link jogamp.opengl.GLContextImpl#contextMadeCurrent(boolean) context current hook} * or when {@link jogamp.opengl.GLDrawableImpl#swapBuffersImpl(boolean) swapping buffers}, whatever comes first. *

      - */ + */ public interface GLFBODrawable extends GLDrawable { // public enum DoubleBufferMode { NONE, TEXTURE, FBO }; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support - + /** * @return true if initialized, i.e. a {@link GLContext} is bound and made current once, otherwise false. */ public boolean isInitialized(); - + /** * Notify this instance about upstream size change * to reconfigure the {@link FBObject}. - * @param gl GL context object bound to this drawable, will be made current during operation. - * A prev. current context will be make current after operation. + * @param gl GL context object bound to this drawable, will be made current during operation. + * A prev. current context will be make current after operation. * @throws GLException if resize operation failed */ void resetSize(GL gl) throws GLException; - + /** * @return the used texture unit */ int getTextureUnit(); - + /** - * + * * @param unit the texture unit to be used */ void setTextureUnit(int unit); - + /** * Set the number of sample buffers if using MSAA - * - * @param gl GL context object bound to this drawable, will be made current during operation. - * A prev. current context will be make current after operation. + * + * @param gl GL context object bound to this drawable, will be made current during operation. + * A prev. current context will be make current after operation. * @param newSamples new sample size * @throws GLException if resetting the FBO failed */ void setNumSamples(GL gl, int newSamples) throws GLException; - + /** * @return the number of sample buffers if using MSAA, otherwise 0 */ int getNumSamples(); - + /** * Sets the number of buffers (FBO) being used if using {@link GLCapabilities#getDoubleBuffered() double buffering}. *

      @@ -123,22 +123,22 @@ public interface GLFBODrawable extends GLDrawable { *

      * Must be called before {@link #isInitialized() initialization}, otherwise an exception is thrown. *

      - * @return the new number of buffers (FBO) used, maybe different than the requested bufferCount (see above) + * @return the new number of buffers (FBO) used, maybe different than the requested bufferCount (see above) * @throws GLException if already initialized, see {@link #isInitialized()}. */ int setNumBuffers(int bufferCount) throws GLException; - - /** + + /** * @return the number of buffers (FBO) being used. 1 if not using {@link GLCapabilities#getDoubleBuffered() double buffering}, - * otherwise ≥ 2, depending on {@link #setNumBuffers(int)}. + * otherwise ≥ 2, depending on {@link #setNumBuffers(int)}. */ int getNumBuffers(); - + /** - * @return the used {@link DoubleBufferMode} + * @return the used {@link DoubleBufferMode} */ // DoubleBufferMode getDoubleBufferMode(); // TODO: Add or remove TEXTURE (only) DoubleBufferMode support - + /** * Sets the {@link DoubleBufferMode}. Must be called before {@link #isInitialized() initialization}, * otherwise an exception is thrown. @@ -153,11 +153,11 @@ public interface GLFBODrawable extends GLDrawable { * @throws GLException if already initialized, see {@link #isInitialized()}. */ // void setDoubleBufferMode(DoubleBufferMode mode) throws GLException; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support - + /** * If MSAA is being used and {@link GL#GL_FRONT} is requested, - * the internal {@link FBObject} {@link FBObject#getSamplingSinkFBO() sample sink} is being returned. - * + * the internal {@link FBObject} {@link FBObject#getSamplingSinkFBO() sample sink} is being returned. + * * @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names * @return the named {@link FBObject} * @throws IllegalArgumentException if an illegal buffer name is being used @@ -167,7 +167,7 @@ public interface GLFBODrawable extends GLDrawable { /** * Returns the named texture buffer. *

      - * If MSAA is being used, only the {@link GL#GL_FRONT} buffer is accessible + * If MSAA is being used, only the {@link GL#GL_FRONT} buffer is accessible * and an exception is being thrown if {@link GL#GL_BACK} is being requested. *

      * @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names @@ -176,20 +176,20 @@ public interface GLFBODrawable extends GLDrawable { */ FBObject.TextureAttachment getTextureBuffer(int bufferName) throws IllegalArgumentException; - /** Resizeable {@link GLFBODrawable} specialization */ + /** Resizeable {@link GLFBODrawable} specialization */ public interface Resizeable extends GLFBODrawable { /** * Resize this drawable. *

      * This drawable is being locked during operation. *

      - * @param context the {@link GLContext} bound to this drawable, will be made current during operation - * A prev. current context will be make current after operation. + * @param context the {@link GLContext} bound to this drawable, will be made current during operation + * A prev. current context will be make current after operation. * @param newWidth * @param newHeight * @throws NativeWindowException in case the surface could no be locked * @throws GLException in case an error during the resize operation occurred */ - void setSize(GLContext context, int newWidth, int newHeight) throws NativeWindowException, GLException; + void setSize(GLContext context, int newWidth, int newHeight) throws NativeWindowException, GLException; } } diff --git a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java index 6fe76a3f4..be90d935f 100644 --- a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -32,7 +32,7 @@ import javax.media.nativewindow.NativeWindowException; import com.jogamp.opengl.FBObject; -/** +/** * Platform-independent {@link GLAutoDrawable} specialization, * exposing offscreen functionality. *

      @@ -41,7 +41,7 @@ import com.jogamp.opengl.FBObject; *

      */ public interface GLOffscreenAutoDrawable extends GLAutoDrawable { - + /** * Resize this auto drawable. * @param newWidth @@ -56,8 +56,8 @@ public interface GLOffscreenAutoDrawable extends GLAutoDrawable { * @see #getUpstreamWidget() */ void setUpstreamWidget(Object newUpstreamWidget); - - /** {@link FBObject} based {@link GLOffscreenAutoDrawable} specialization */ - public interface FBO extends GLOffscreenAutoDrawable, GLFBODrawable { - } + + /** {@link FBObject} based {@link GLOffscreenAutoDrawable} specialization */ + public interface FBO extends GLOffscreenAutoDrawable, GLFBODrawable { + } } diff --git a/src/jogl/classes/javax/media/opengl/GLPbuffer.java b/src/jogl/classes/javax/media/opengl/GLPbuffer.java index 12f57fcd8..f36a4bf29 100644 --- a/src/jogl/classes/javax/media/opengl/GLPbuffer.java +++ b/src/jogl/classes/javax/media/opengl/GLPbuffer.java @@ -46,8 +46,8 @@ package javax.media.opengl; as a texture map and enabling rendering to floating-point frame buffers. These methods are not guaranteed to be supported on all platforms and may be deprecated in a future release. - - @deprecated Use {@link GLOffscreenAutoDrawable} w/ {@link GLCapabilities#setFBO(boolean)} + + @deprecated Use {@link GLOffscreenAutoDrawable} w/ {@link GLCapabilities#setFBO(boolean)} via {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext) GLDrawableFactory.createOffscreenAutoDrawable(..)}. */ public interface GLPbuffer extends GLAutoDrawable { diff --git a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java index c6bf26235..d947bada2 100644 --- a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,7 +28,7 @@ * 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. @@ -49,7 +49,7 @@ import jogamp.opengl.*; public class GLPipelineFactory { public static final boolean DEBUG = Debug.debug("GLPipelineFactory"); - /** + /** * Creates a pipelined GL instance using the given downstream downstream * and optional arguments additionalArgs for the constructor. * @@ -66,7 +66,7 @@ public class GLPipelineFactory { * gl = drawable.setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ); *
    *

    - * + * *

    * The upstream GL instance is determined as follows: *

      @@ -76,7 +76,7 @@ public class GLPipelineFactory { *
    • For all downstream class and superclass interfaces, do:
    • *
        *
      • If reqInterface is not null and the interface is unequal, continue loop.
      • - *
      • If downstream is not instance of interface, continue loop.
      • + *
      • If downstream is not instance of interface, continue loop.
      • *
      • If upstream class is available use it, end loop.
      • *
      *
    @@ -116,7 +116,7 @@ public class GLPipelineFactory { if(DEBUG) { System.out.println("GLPipelineFactory: "+downstream.getClass().getName() + " is _not_ instance of "+ clazzes[i].getName()); } - continue; // not a compatible one + continue; // not a compatible one } else { if(DEBUG) { System.out.println("GLPipelineFactory: "+downstream.getClass().getName() + " _is_ instance of "+ clazzes[i].getName()); @@ -153,7 +153,7 @@ public class GLPipelineFactory { // throws exception if cstr not found! Constructor cstr = ReflectionUtil.getConstructor(upstreamClazz, cstrArgTypes); Object instance = null; - try { + try { Object[] cstrArgs = new Object[ 1 + ( ( null==additionalArgs ) ? 0 : additionalArgs.length ) ] ; { int i = 0; diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 4a2edc56b..15300e397 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -66,48 +66,48 @@ import java.util.List; /** * Specifies the the OpenGL profile. - * + * * This class static singleton initialization queries the availability of all OpenGL Profiles * and instantiates singleton GLProfile objects for each available profile. * - * The platform default profile may be used, using {@link GLProfile#GetProfileDefault()}, + * The platform default profile may be used, using {@link GLProfile#GetProfileDefault()}, * or more specialized versions using the other static GetProfile methods. */ public class GLProfile { - + public static final boolean DEBUG = Debug.debug("GLProfile"); - + static { // Also initializes TempJarCache if shall be used. Platform.initSingleton(); } - + /** * Static initialization of JOGL. * *

    * This method shall not need to be called for other reasons than having a defined initialization sequence. *

    - * + * *

    * In case this method is not invoked, GLProfile is initialized implicit by * the first call to {@link #getDefault()}, {@link #get(java.lang.String)}. *

    - * + * *

    - * To initialize JOGL at startup ASAP, this method may be invoked in the main class's + * To initialize JOGL at startup ASAP, this method may be invoked in the main class's * static initializer block, in the static main() method or in the Applet init() method. *

    - * + * *

    * Since JOGL's initialization is complex and involves multi threading, it is not recommended - * to be have it invoked on the AWT EDT thread. In case all JOGL usage is performed + * to be have it invoked on the AWT EDT thread. In case all JOGL usage is performed * on the AWT EDT, invoke this method outside the AWT EDT - see above. *

    - * + * */ public static void initSingleton() { - final boolean justInitialized; + final boolean justInitialized; initLock.lock(); try { if(!initialized) { // volatile: ok @@ -117,13 +117,13 @@ public class GLProfile { System.err.println("GLProfile.initSingleton() - thread "+Thread.currentThread().getName()); Thread.dumpStack(); } - + // run the whole static initialization privileged to speed up, // since this skips checking further access AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Platform.initSingleton(); - + // Performance hack to trigger classloading of the GL classes impl, which makes up to 12%, 800ms down to 700ms new Thread(new Runnable() { public void run() { @@ -132,15 +132,15 @@ public class GLProfile { ReflectionUtil.createInstance(getGLImplBaseClassName(GL4bc)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); } catch (Throwable t) {} try { - ReflectionUtil.createInstance(getGLImplBaseClassName(GLES3)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); + ReflectionUtil.createInstance(getGLImplBaseClassName(GLES3)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); } catch (Throwable t) {} try { - ReflectionUtil.createInstance(getGLImplBaseClassName(GLES1)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); + ReflectionUtil.createInstance(getGLImplBaseClassName(GLES1)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); } catch (Throwable t) {} } - }, "GLProfile-GL_Bootstrapping").start(); + }, "GLProfile-GL_Bootstrapping").start(); + - if(TempJarCache.isInitialized()) { final ClassLoader cl = GLProfile.class.getClassLoader(); final String newtFactoryClassName = "com.jogamp.newt.NewtFactory"; @@ -164,13 +164,13 @@ public class GLProfile { if( justInitialized && ( hasGL234Impl || hasGLES1Impl || hasGLES3Impl ) ) { System.err.println(JoglVersion.getDefaultOpenGLInfo(defaultDevice, null, true)); } - } + } } /** * Trigger eager initialization of GLProfiles for the given device, * in case it isn't done yet. - * + * * @throws GLException if no profile for the given device is available. */ public static void initProfiles(AbstractGraphicsDevice device) throws GLException { @@ -194,7 +194,7 @@ public class GLProfile { if(DEBUG) { System.err.println("GLProfile.shutdown() - thread "+Thread.currentThread().getName()); Thread.dumpStack(); - } + } GLDrawableFactory.shutdown(); } } finally { @@ -206,11 +206,11 @@ public class GLProfile { // Query platform available OpenGL implementation // - /** + /** * Returns the availability of a profile on a device. - * + * * @param device a valid AbstractGraphicsDevice, or null for the default device. - * @param profile a valid GLProfile name ({@link #GL4bc}, {@link #GL4}, {@link #GL2}, ..), + * @param profile a valid GLProfile name ({@link #GL4bc}, {@link #GL4}, {@link #GL2}, ..), * or [ null, GL ] for the default profile. * @return true if the profile is available for the device, otherwise false. */ @@ -221,31 +221,31 @@ public class GLProfile { private static boolean isAvailableImpl(HashMap map, String profile) { return null != map && null != map.get(profile); } - - /** + + /** * Returns the availability of a profile on the default device. - * - * @param profile a valid GLProfile name ({@link #GL4bc}, {@link #GL4}, {@link #GL2}, ..), + * + * @param profile a valid GLProfile name ({@link #GL4bc}, {@link #GL4}, {@link #GL2}, ..), * or [ null, GL ] for the default profile. * @return true if the profile is available for the default device, otherwise false. */ public static boolean isAvailable(String profile) { return isAvailable(null, profile); } - - /** + + /** * Returns the availability of any profile on the default device. - * + * * @return true if any profile is available for the default device, otherwise false. */ public static boolean isAnyAvailable() { return isAvailable(null, null); } - + public static String glAvailabilityToString(AbstractGraphicsDevice device) { return glAvailabilityToString(device, null).toString(); } - + public static StringBuilder glAvailabilityToString(AbstractGraphicsDevice device, StringBuilder sb) { return glAvailabilityToString(device, sb, null, 0); } @@ -264,19 +264,19 @@ public class GLProfile { final boolean useIndent = null != indent; initSingleton(); - + if(null==device) { device = defaultDevice; } final HashMap map = getProfileMap(device, false); - + if(useIndent) { doIndent(sb, indent, indentCount).append("Native"); indentCount++; doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4bc").append(indent); } else { sb.append("Native[GL4bc "); - } + } avail=isAvailableImpl(map, GL4bc); sb.append(avail); if(avail) { @@ -366,7 +366,7 @@ public class GLProfile { sb.append(", GL4ES3 "); } sb.append(isAvailableImpl(map, GL4ES3)); - + if(useIndent) { doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent); } else { @@ -388,7 +388,7 @@ public class GLProfile { } else { sb.append("], Profiles["); } - + if(null != map) { for(Iterator i=map.values().iterator(); i.hasNext(); ) { if(useIndent) { @@ -418,7 +418,7 @@ public class GLProfile { return sb; } - + /** Uses the default device */ public static String glAvailabilityToString() { return glAvailabilityToString(null); @@ -465,11 +465,11 @@ public class GLProfile { /** The intersection of the desktop GL4 and ES3 profile */ public static final String GL4ES3 = "GL4ES3"; - + /** The default profile, used for the device default profile map */ private static final String GL_DEFAULT = "GL_DEFAULT"; - /** + /** * All GL Profiles in the order of default detection. * Desktop compatibility profiles (the one with fixed function pipeline) comes first * from highest to lowest version. @@ -492,7 +492,7 @@ public class GLProfile { * */ public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL4bc, GL3bc, GL2, GL4, GL3, GLES3, GL4ES3, GL2GL3, GLES2, GL2ES2, GLES1, GL2ES1 }; - + /** * Order of maximum profiles. * @@ -526,7 +526,7 @@ public class GLProfile { * */ public static final String[] GL_PROFILE_LIST_MIN = new String[] { GLES1, GLES2, GL2, GLES3, GL3, GL3bc, GL4, GL4bc }; - + /** * Order of minimum original desktop profiles. * @@ -540,7 +540,7 @@ public class GLProfile { * */ public static final String[] GL_PROFILE_LIST_MIN_DESKTOP = new String[] { GL2, GL3bc, GL4bc, GL3, GL4 }; - + /** * Order of maximum fixed function profiles * @@ -582,7 +582,7 @@ public class GLProfile { * */ public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER_CORE = new String[] { GL4, GL3, GLES3, GLES2 }; - + /** 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} * and favors hardware acceleration. @@ -597,7 +597,7 @@ public class GLProfile { /** 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} * and favors hardware acceleration. - *

    Uses the default device.

    + *

    Uses the default device.

    * @throws GLException if no profile is available for the default device. */ public static GLProfile getDefault() { @@ -617,7 +617,7 @@ public class GLProfile { return get(device, GL_PROFILE_LIST_MAX, favorHardwareRasterizer); } - /** Uses the default device + /** Uses the default device * @throws GLException if no profile is available for the default device. * @see #GL_PROFILE_LIST_MAX */ @@ -640,7 +640,7 @@ public class GLProfile { return get(device, GL_PROFILE_LIST_MIN, favorHardwareRasterizer); } - /** Uses the default device + /** Uses the default device * @throws GLException if no desktop profile is available for the default device. * @see #GL_PROFILE_LIST_MIN */ @@ -664,7 +664,7 @@ public class GLProfile { return get(device, GL_PROFILE_LIST_MAX_FIXEDFUNC, favorHardwareRasterizer); } - /** Uses the default device + /** Uses the default device * @throws GLException if no fixed function profile is available for the default device. * @see #GL_PROFILE_LIST_MAX_FIXEDFUNC */ @@ -687,7 +687,7 @@ public class GLProfile { return get(device, GL_PROFILE_LIST_MAX_PROGSHADER, favorHardwareRasterizer); } - /** Uses the default device + /** Uses the default device * @throws GLException if no programmable profile is available for the default device. * @see #GL_PROFILE_LIST_MAX_PROGSHADER */ @@ -706,11 +706,11 @@ public class GLProfile { */ public static GLProfile getMaxProgrammableCore(AbstractGraphicsDevice device, boolean favorHardwareRasterizer) throws GLException - { + { return get(device, GL_PROFILE_LIST_MAX_PROGSHADER_CORE, favorHardwareRasterizer); } - /** Uses the default device + /** Uses the default device * @throws GLException if no programmable core profile is available for the default device. * @see #GL_PROFILE_LIST_MAX_PROGSHADER_CORE */ @@ -719,8 +719,8 @@ public class GLProfile { { return get(GL_PROFILE_LIST_MAX_PROGSHADER_CORE, favorHardwareRasterizer); } - - /** + + /** * Returns the GL2ES1 profile implementation, hence compatible w/ GL2ES1.
    * It returns: *
    @@ -739,8 +739,8 @@ public class GLProfile {
             return get(device, GL2ES1).getImpl();
         }
     
    -    /** 
    -     * Calls {@link #getGL2ES1(AbstractGraphicsDevice)} using the default device. 
    +    /**
    +     * Calls {@link #getGL2ES1(AbstractGraphicsDevice)} using the default device.
          * 

    Selection favors hardware rasterizer.

    * @see #getGL2ES1(AbstractGraphicsDevice) */ @@ -750,7 +750,7 @@ public class GLProfile { return get(defaultDevice, GL2ES1).getImpl(); } - /** + /** * Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
    * It returns: *
    @@ -769,8 +769,8 @@ public class GLProfile {
             return get(device, GL2ES2).getImpl();
         }
     
    -    /** 
    -     * Calls {@link #getGL2ES2(AbstractGraphicsDevice)} using the default device. 
    +    /**
    +     * Calls {@link #getGL2ES2(AbstractGraphicsDevice)} using the default device.
          * 

    Selection favors hardware rasterizer.

    * @see #getGL2ES2(AbstractGraphicsDevice) */ @@ -780,7 +780,7 @@ public class GLProfile { return get(defaultDevice, GL2ES2).getImpl(); } - /** + /** * Returns the GL4ES3 profile implementation, hence compatible w/ GL4ES3.
    * It returns: *
    @@ -799,8 +799,8 @@ public class GLProfile {
             return get(device, GL4ES3).getImpl();
         }
     
    -    /** 
    -     * Calls {@link #getGL4ES3(AbstractGraphicsDevice)} using the default device. 
    +    /**
    +     * Calls {@link #getGL4ES3(AbstractGraphicsDevice)} using the default device.
          * 

    Selection favors hardware rasterizer.

    * @see #getGL4ES3(AbstractGraphicsDevice) */ @@ -810,7 +810,7 @@ public class GLProfile { return get(defaultDevice, GL4ES3).getImpl(); } - /** + /** * Returns the GL2GL3 profile implementation, hence compatible w/ GL2GL3.
    * It returns: *
    @@ -829,8 +829,8 @@ public class GLProfile {
             return get(device, GL2GL3).getImpl();
         }
     
    -    /** 
    -     * Calls {@link #getGL2GL3(AbstractGraphicsDevice)} using the default device. 
    +    /**
    +     * Calls {@link #getGL2GL3(AbstractGraphicsDevice)} using the default device.
          * 

    Selection favors hardware rasterizer.

    * @see #getGL2GL3(AbstractGraphicsDevice) */ @@ -846,7 +846,7 @@ public class GLProfile { * the default profile. * * @param device a valid AbstractGraphicsDevice, or null for the default device. - * @param profile a valid GLProfile name ({@link #GL4bc}, {@link #GL4}, {@link #GL2}, ..), + * @param profile a valid GLProfile name ({@link #GL4bc}, {@link #GL4}, {@link #GL2}, ..), * or [ null, GL ] for the default profile. * @throws GLException if the requested profile is not available for the device. */ @@ -864,8 +864,8 @@ public class GLProfile { return glp; } - /** Uses the default device - * @param profile a valid GLProfile name ({@link #GL4bc}, {@link #GL4}, {@link #GL2}, ..), + /** Uses the default device + * @param profile a valid GLProfile name ({@link #GL4bc}, {@link #GL4}, {@link #GL2}, ..), * or [ null, GL ] for the default profile. * @throws GLException if the requested profile is not available for the default device. */ @@ -881,14 +881,14 @@ public class GLProfile { * * @param device a valid AbstractGraphicsDevice, or null for the default device. * @param profiles array of valid GLProfile name ({@link #GL4bc}, {@link #GL4}, {@link #GL2}, ..) - * @param favorHardwareRasterizer set to true, if hardware rasterizer shall be favored, otherwise false. + * @param favorHardwareRasterizer set to true, if hardware rasterizer shall be favored, otherwise false. * @throws GLException if the non of the requested profiles is available for the device. */ public static GLProfile get(AbstractGraphicsDevice device, String[] profiles, boolean favorHardwareRasterizer) throws GLException { GLProfile glProfileAny = null; - + HashMap map = getProfileMap(device, true); for(int i=0; i GL2, or GL3 -> GL3 + + /** + * return this profiles implementation name, eg. GL2ES2 -> GL2, or GL3 -> GL3 */ public final String getImplName() { return null != profileImpl ? profileImpl.getName() : getName(); @@ -1102,12 +1102,12 @@ public class GLProfile { public final boolean isGLES2() { return GLES2 == profile; } - + /** Indicates whether this profile is capable of GLES3.

    Includes [ GLES3 ].

    */ public final boolean isGLES3() { return GLES3 == profile; } - + /** Indicates whether this profile is capable of GLES.

    Includes [ GLES3, GLES1, GLES2 ].

    */ public final boolean isGLES() { return GLES3 == profile || GLES2 == profile || GLES1 == profile; @@ -1122,21 +1122,21 @@ public class GLProfile { public final boolean isGL2GL3() { return GL2GL3 == profile || isGL3() || isGL2(); } - + /** Indicates whether this profile is capable of GL2ES2.

    Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GL2GL3, GL2ES2, GLES2 ].

    */ public final boolean isGL2ES2() { return GL2ES2 == profile || isGLES2() || isGL2GL3(); } - /** + /** * Indicates whether this profile is capable of GL2ES3.

    Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL3ES3, GL2, GL2GL3 ].

    - * @see #isGL3ES3() - * @see #isGL2GL3() + * @see #isGL3ES3() + * @see #isGL2GL3() */ public final boolean isGL2ES3() { return isGL3ES3() || isGL2GL3(); } - + /** Indicates whether this profile is capable of GL3ES3.

    Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].

    */ public final boolean isGL3ES3() { return isGL4ES3() || isGL3(); @@ -1172,7 +1172,7 @@ public class GLProfile { return usesNativeGLES2() || usesNativeGLES1(); } - /** + /** * General validation if type is a valid GL data type * for the current profile */ @@ -1200,14 +1200,14 @@ public class GLProfile { if( isGL2() ) { return true; } - } + } if(throwException) { throw new GLException("Illegal data type on profile "+this+": "+type); } return false; } - - public boolean isValidArrayDataType(int index, int comps, int type, + + public boolean isValidArrayDataType(int index, int comps, int type, boolean isVertexAttribPointer, boolean throwException) { final String arrayName = getGLArrayName(index); if( isGLES1() ) { @@ -1226,7 +1226,7 @@ public class GLProfile { case GL.GL_FIXED: case GL.GL_FLOAT: break; - default: + default: if(throwException) { throw new GLException("Illegal data type for "+arrayName+" on profile GLES1: "+type); } @@ -1238,7 +1238,7 @@ public class GLProfile { case 3: case 4: break; - default: + default: if(throwException) { throw new GLException("Illegal component number for "+arrayName+" on profile GLES1: "+comps); } @@ -1252,7 +1252,7 @@ public class GLProfile { case GL.GL_FIXED: case GL.GL_FLOAT: break; - default: + default: if(throwException) { throw new GLException("Illegal data type for "+arrayName+" on profile GLES1: "+type); } @@ -1262,7 +1262,7 @@ public class GLProfile { case 0: case 3: break; - default: + default: if(throwException) { throw new GLException("Illegal component number for "+arrayName+" on profile GLES1: "+comps); } @@ -1275,7 +1275,7 @@ public class GLProfile { case GL.GL_FIXED: case GL.GL_FLOAT: break; - default: + default: if(throwException) { throw new GLException("Illegal data type for "+arrayName+" on profile GLES1: "+type); } @@ -1285,7 +1285,7 @@ public class GLProfile { case 0: case 4: break; - default: + default: if(throwException) { throw new GLException("Illegal component number for "+arrayName+" on profile GLES1: "+comps); } @@ -1303,7 +1303,7 @@ public class GLProfile { case GL.GL_FLOAT: case GL.GL_FIXED: break; - default: + default: if(throwException) { throw new GLException("Illegal data type for "+arrayName+" on profile GLES2: "+type); } @@ -1317,7 +1317,7 @@ public class GLProfile { case 3: case 4: break; - default: + default: if(throwException) { throw new GLException("Illegal component number for "+arrayName+" on profile GLES2: "+comps); } @@ -1335,7 +1335,7 @@ public class GLProfile { case javax.media.opengl.GL2ES2.GL_UNSIGNED_INT: case javax.media.opengl.GL2.GL_DOUBLE: break; - default: + default: if(throwException) { throw new GLException("Illegal data type for "+arrayName+" on profile GL2: "+type); } @@ -1348,7 +1348,7 @@ public class GLProfile { case 3: case 4: break; - default: + default: if(throwException) { throw new GLException("Illegal component number for "+arrayName+" on profile GL2: "+comps); } @@ -1363,7 +1363,7 @@ public class GLProfile { case javax.media.opengl.GL2ES2.GL_INT: case javax.media.opengl.GL2.GL_DOUBLE: break; - default: + default: if(throwException) { throw new GLException("Illegal data type for "+arrayName+" on profile GL2: "+type); } @@ -1375,7 +1375,7 @@ public class GLProfile { case 3: case 4: break; - default: + default: if(throwException) { throw new GLException("Illegal component number for "+arrayName+" on profile GL2: "+comps); } @@ -1390,7 +1390,7 @@ public class GLProfile { case javax.media.opengl.GL2ES2.GL_INT: case javax.media.opengl.GL2.GL_DOUBLE: break; - default: + default: if(throwException) { throw new GLException("Illegal data type for "+arrayName+" on profile GL2: "+type); } @@ -1400,7 +1400,7 @@ public class GLProfile { case 0: case 3: break; - default: + default: if(throwException) { throw new GLException("Illegal component number for "+arrayName+" on profile GLES1: "+comps); } @@ -1418,7 +1418,7 @@ public class GLProfile { case javax.media.opengl.GL2ES2.GL_UNSIGNED_INT: case javax.media.opengl.GL2.GL_DOUBLE: break; - default: + default: if(throwException) { throw new GLException("Illegal data type for "+arrayName+" on profile GL2: "+type); } @@ -1429,7 +1429,7 @@ public class GLProfile { case 3: case 4: break; - default: + default: if(throwException) { throw new GLException("Illegal component number for "+arrayName+" on profile GL2: "+comps); } @@ -1443,7 +1443,7 @@ public class GLProfile { case javax.media.opengl.GL2ES2.GL_INT: case javax.media.opengl.GL2.GL_DOUBLE: break; - default: + default: if(throwException) { throw new GLException("Illegal data type for "+arrayName+" on profile GL2: "+type); } @@ -1456,7 +1456,7 @@ public class GLProfile { case 3: case 4: break; - default: + default: if(throwException) { throw new GLException("Illegal component number for "+arrayName+" on profile GL2: "+comps); } @@ -1475,7 +1475,7 @@ public class GLProfile { private static /*final*/ boolean isAWTAvailable; - private static /*final*/ boolean hasDesktopGLFactory; + private static /*final*/ boolean hasDesktopGLFactory; private static /*final*/ boolean hasGL234Impl; private static /*final*/ boolean hasEGLFactory; private static /*final*/ boolean hasGLES3Impl; @@ -1508,11 +1508,11 @@ public class GLProfile { // depends on hasDesktopGLFactory hasGL234Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.gl4.GL4bcImpl", classloader); - + // depends on hasEGLFactory hasGLES1Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.es1.GLES1Impl", classloader); hasGLES3Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.es3.GLES3Impl", classloader); - + // // Iteration of desktop GL availability detection // utilizing the detected GL version in the shared context. @@ -1521,7 +1521,7 @@ public class GLProfile { // which will register at GLContext .. // GLDrawableFactory.initSingleton(); - + Throwable t=null; // if successfull it has a shared dummy drawable and context created try { @@ -1592,14 +1592,14 @@ public class GLProfile { System.err.println("Info: GLProfile.init - EGL GLDrawable factory not available"); } } else { - defaultEGLDevice = eglFactory.getDefaultDevice(); + defaultEGLDevice = eglFactory.getDefaultDevice(); } if( null != defaultDesktopDevice ) { defaultDevice = defaultDesktopDevice; if(DEBUG) { System.err.println("Info: GLProfile.init - Default device is desktop derived: "+defaultDevice); - } + } } else if ( null != defaultEGLDevice ) { defaultDevice = defaultEGLDevice; if(DEBUG) { @@ -1611,12 +1611,12 @@ public class GLProfile { } defaultDevice = null; } - + // we require to initialize the EGL device 1st, if available final boolean addedEGLProfile = null != defaultEGLDevice ? initProfilesForDevice(defaultEGLDevice) : false; - final boolean addedDesktopProfile = null != defaultDesktopDevice ? initProfilesForDevice(defaultDesktopDevice) : false; + final boolean addedDesktopProfile = null != defaultDesktopDevice ? initProfilesForDevice(defaultDesktopDevice) : false; final boolean addedAnyProfile = addedEGLProfile || addedDesktopProfile ; - + if(DEBUG) { System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile+" (desktop: "+addedDesktopProfile+", egl "+addedEGLProfile+")"); System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable); @@ -1672,8 +1672,8 @@ public class GLProfile { boolean addedDesktopProfile = false; boolean addedEGLProfile = false; - final boolean deviceIsDesktopCompatible = hasDesktopGLFactory && desktopFactory.getIsDeviceCompatible(device); - + final boolean deviceIsDesktopCompatible = hasDesktopGLFactory && desktopFactory.getIsDeviceCompatible(device); + if( deviceIsDesktopCompatible ) { // 1st pretend we have all Desktop and EGL profiles .. computeProfileMap(device, true /* desktopCtxUndef*/, true /* esCtxUndef */); @@ -1698,9 +1698,9 @@ public class GLProfile { } addedDesktopProfile = computeProfileMap(device, false /* desktopCtxUndef*/, false /* esCtxUndef */); } - + final boolean deviceIsEGLCompatible = hasEGLFactory && eglFactory.getIsDeviceCompatible(device); - + // also test GLES1, GLES2 and GLES3 on desktop, since we have implementations / emulations available. if( deviceIsEGLCompatible && ( hasGLES3Impl || hasGLES1Impl ) ) { // 1st pretend we have all EGL profiles .. @@ -1718,7 +1718,7 @@ public class GLProfile { } if(!eglSharedCtxAvail) { // Remark: On Windows there is a libEGL.dll delivered w/ Chrome 15.0.874.121m and Firefox 8.0.1 - // but it seems even EGL.eglInitialize(eglDisplay, null, null) + // but it seems even EGL.eglInitialize(eglDisplay, null, null) // fails in some scenarios (eg VirtualBox 4.1.6) w/ EGL error 0x3001 (EGL_NOT_INITIALIZED). hasEGLFactory = false; hasGLES3Impl = false; @@ -1993,7 +1993,7 @@ public class GLProfile { return null; } - private static /*final*/ HashMap> deviceConn2ProfileMap = + private static /*final*/ HashMap> deviceConn2ProfileMap = new HashMap>(); /** @@ -2004,22 +2004,22 @@ public class GLProfile { * * @param device the key 'device -> GLProfiles-Map' * @param throwExceptionOnZeroProfile true if GLException shall be thrown in case of no mapped profile, otherwise false. - * @return the GLProfile HashMap if exists, otherwise null + * @return the GLProfile HashMap if exists, otherwise null * @throws GLException if no profile for the given device is available. */ - private static HashMap getProfileMap(AbstractGraphicsDevice device, boolean throwExceptionOnZeroProfile) - throws GLException + private static HashMap getProfileMap(AbstractGraphicsDevice device, boolean throwExceptionOnZeroProfile) + throws GLException { initSingleton(); if(null==defaultDevice) { // avoid NPE and notify of incomplete initialization throw new GLException("No default device available"); } - + if(null==device) { device = defaultDevice; } - + final String deviceKey = device.getUniqueID(); HashMap map = deviceConn2ProfileMap.get(deviceKey); if( null != map ) { diff --git a/src/jogl/classes/javax/media/opengl/GLRunnable.java b/src/jogl/classes/javax/media/opengl/GLRunnable.java index 1ae1c9b22..ad68662ce 100644 --- a/src/jogl/classes/javax/media/opengl/GLRunnable.java +++ b/src/jogl/classes/javax/media/opengl/GLRunnable.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package javax.media.opengl; /** @@ -33,8 +33,8 @@ package javax.media.opengl; * Declares a one-shot OpenGL command usable for injection * via {@link GLAutoDrawable#invoke(boolean, javax.media.opengl.GLRunnable)}.
    * {@link GLAutoDrawable} executes the GLRunnables within it's {@link GLAutoDrawable#display() display()} - * method after all registered {@link GLEventListener}s - * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)} + * method after all registered {@link GLEventListener}s + * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)} * methods has been called. *

    *

    @@ -44,13 +44,13 @@ package javax.media.opengl; * This might be useful to inject OpenGL commands from an I/O event listener. *

    */ -public interface GLRunnable { +public interface GLRunnable { /** * @param drawable the associated drawable and current context for this call * @return true if the GL [back] framebuffer remains intact by this runnable, otherwise false. * If returning false {@link GLAutoDrawable} will call - * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)} - * of all registered {@link GLEventListener}s once more. + * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)} + * of all registered {@link GLEventListener}s once more. * @see GLRunnable */ boolean run(GLAutoDrawable drawable); diff --git a/src/jogl/classes/javax/media/opengl/GLRunnable2.java b/src/jogl/classes/javax/media/opengl/GLRunnable2.java index 1598a6215..5f0393257 100644 --- a/src/jogl/classes/javax/media/opengl/GLRunnable2.java +++ b/src/jogl/classes/javax/media/opengl/GLRunnable2.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package javax.media.opengl; /** @@ -33,11 +33,11 @@ package javax.media.opengl; * Declares a one-shot OpenGL command. *

    */ -public interface GLRunnable2 { +public interface GLRunnable2 { /** * @param gl a current GL object * @param args custom arguments - * @return the desired object + * @return the desired object */ T run(GL gl, U args); } diff --git a/src/jogl/classes/javax/media/opengl/GLUniformData.java b/src/jogl/classes/javax/media/opengl/GLUniformData.java index 60d0c58bf..700bba2eb 100644 --- a/src/jogl/classes/javax/media/opengl/GLUniformData.java +++ b/src/jogl/classes/javax/media/opengl/GLUniformData.java @@ -77,16 +77,16 @@ public class GLUniformData { sb = new StringBuilder(); } sb.append("GLUniformData[name ").append(name). - append(", location ").append(location). + append(", location ").append(location). append(", size ").append(rows).append("x").append(columns). - append(", count ").append(count). - append(", data "); + append(", count ").append(count). + append(", data "); if(isMatrix() && data instanceof FloatBuffer) { sb.append("\n"); - final FloatBuffer fb = (FloatBuffer)getBuffer(); + final FloatBuffer fb = (FloatBuffer)getBuffer(); for(int i=0; i @@ -59,12 +59,12 @@ import jogamp.opengl.ThreadingImpl; Due to these limitations, and due to the inherent multithreading in the Java platform (in particular, in the Abstract Window - Toolkit), it is often necessary to limit the multithreading - occurring in the typical application using the OpenGL API. + Toolkit), it is often necessary to limit the multithreading + occurring in the typical application using the OpenGL API.

    - In the current reference implementation, for instance, multithreading + In the current reference implementation, for instance, multithreading has been limited by forcing all OpenGL-related work for GLAutoDrawables on to a single thread. In other words, if an application uses only the @@ -93,9 +93,9 @@ import jogamp.opengl.ThreadingImpl; This class also provides mechanisms for querying whether this internal serialization of OpenGL work is in effect, and a - programmatic way of disabling it. In the current reference - implementation it is enabled by default, although it could be - disabled in the future if OpenGL drivers become more robust on + programmatic way of disabling it. In the current reference + implementation it is enabled by default, although it could be + disabled in the future if OpenGL drivers become more robust on all platforms.

    @@ -113,7 +113,7 @@ import jogamp.opengl.ThreadingImpl; platforms, and also the default behavior older releases) -Djogl.1thread=worker Enable single-threading of OpenGL work on newly-created worker thread (not suitable for Mac OS X or X11 platforms, and risky on Windows in applet environments) -

    +
    */ public class Threading { @@ -121,9 +121,9 @@ public class Threading { /** No reason to ever instantiate this class */ private Threading() {} - /** If an implementation of the javax.media.opengl APIs offers a - multithreading option but the default behavior is single-threading, - this API provides a mechanism for end users to disable single-threading + /** If an implementation of the javax.media.opengl APIs offers a + multithreading option but the default behavior is single-threading, + this API provides a mechanism for end users to disable single-threading in this implementation. Users are strongly discouraged from calling this method unless they are aware of all of the consequences and are prepared to enforce some amount of @@ -133,7 +133,7 @@ public class Threading { GLPbuffer. Currently there is no supported way to re-enable it once disabled, partly to discourage careless use of this method. This method should be called as early as possible in an - application. */ + application. */ public static final void disableSingleThreading() { ThreadingImpl.disableSingleThreading(); } @@ -145,11 +145,11 @@ public class Threading { } /** Indicates whether the current thread is the designated toolkit thread, - if such semantics exists. */ + if such semantics exists. */ public static final boolean isToolkitThread() throws GLException { return ThreadingImpl.isToolkitThread(); } - + /** Indicates whether the current thread is the single thread on which this implementation of the javax.media.opengl APIs performs all of its OpenGL-related work. This method should only @@ -166,12 +166,12 @@ public class Threading { thread (i.e., if isOpenGLThread() returns false). It is up to the end user to check to see whether the current thread is the OpenGL thread and either execute the - Runnable directly or perform the work inside it. + Runnable directly or perform the work inside it. **/ public static final void invokeOnOpenGLThread(boolean wait, Runnable r) throws GLException { ThreadingImpl.invokeOnOpenGLThread(wait, r); } - + /** * If {@link #isSingleThreaded()} and not {@link #isOpenGLThread()} * and the lock is not being hold by this thread, @@ -179,14 +179,14 @@ public class Threading { *

    * Otherwise invoke Runnable r on the current thread. *

    - * - * @param wait set to true for waiting until Runnable r is finished, otherwise false. + * + * @param wait set to true for waiting until Runnable r is finished, otherwise false. * @param r the Runnable to be executed * @param lock optional lock object to be tested * @throws GLException */ public static final void invoke(boolean wait, Runnable r, Object lock) throws GLException { - if ( isSingleThreaded() && !isOpenGLThread() && + if ( isSingleThreaded() && !isOpenGLThread() && ( null == lock || !Thread.holdsLock(lock) ) ) { invokeOnOpenGLThread(wait, r); } else { diff --git a/src/jogl/classes/javax/media/opengl/TraceGL2.java b/src/jogl/classes/javax/media/opengl/TraceGL2.java index 58f5d9f99..c577332e9 100644 --- a/src/jogl/classes/javax/media/opengl/TraceGL2.java +++ b/src/jogl/classes/javax/media/opengl/TraceGL2.java @@ -12,7 +12,7 @@ import java.io.PrintStream; * Sample code which installs this pipeline, manual: *
      *     gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
    - * 
    + *
    * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. *

    */ diff --git a/src/jogl/classes/javax/media/opengl/TraceGL3.java b/src/jogl/classes/javax/media/opengl/TraceGL3.java index 616b31f61..5fccf40c7 100644 --- a/src/jogl/classes/javax/media/opengl/TraceGL3.java +++ b/src/jogl/classes/javax/media/opengl/TraceGL3.java @@ -12,7 +12,7 @@ import java.io.PrintStream; * Sample code which installs this pipeline, manual: *
      *     gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
    - * 
    + *
    * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. *

    */ diff --git a/src/jogl/classes/javax/media/opengl/TraceGL3bc.java b/src/jogl/classes/javax/media/opengl/TraceGL3bc.java index f3761d4d6..84f537f60 100644 --- a/src/jogl/classes/javax/media/opengl/TraceGL3bc.java +++ b/src/jogl/classes/javax/media/opengl/TraceGL3bc.java @@ -12,7 +12,7 @@ import java.io.PrintStream; * Sample code which installs this pipeline, manual: *
      *     gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
    - * 
    + * * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. *

    */ diff --git a/src/jogl/classes/javax/media/opengl/TraceGL4.java b/src/jogl/classes/javax/media/opengl/TraceGL4.java index a12bf0f47..afe2cd9a1 100644 --- a/src/jogl/classes/javax/media/opengl/TraceGL4.java +++ b/src/jogl/classes/javax/media/opengl/TraceGL4.java @@ -12,7 +12,7 @@ import java.io.PrintStream; * Sample code which installs this pipeline, manual: *
      *     gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
    - * 
    + * * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. *

    */ diff --git a/src/jogl/classes/javax/media/opengl/TraceGLES2.java b/src/jogl/classes/javax/media/opengl/TraceGLES2.java index 38d60e3ac..4740e2e72 100644 --- a/src/jogl/classes/javax/media/opengl/TraceGLES2.java +++ b/src/jogl/classes/javax/media/opengl/TraceGLES2.java @@ -12,7 +12,7 @@ import java.io.PrintStream; * Sample code which installs this pipeline, manual: *
      *     gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));
    - * 
    + * * For automatic instantiation see {@link GLPipelineFactory#create(String, Class, GL, Object[])}. *

    */ diff --git a/src/jogl/classes/javax/media/opengl/awt/ComponentEvents.java b/src/jogl/classes/javax/media/opengl/awt/ComponentEvents.java index 0c4f63c2d..5feaa5760 100644 --- a/src/jogl/classes/javax/media/opengl/awt/ComponentEvents.java +++ b/src/jogl/classes/javax/media/opengl/awt/ComponentEvents.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 6828beb10..f08fbafe8 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -115,15 +115,15 @@ import jogamp.opengl.awt.AWTTilePainter; of Z-ordering or LayoutManager problems. * *
    Offscreen Layer Remarks
    - * + * * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} - * maybe called to use an offscreen drawable (FBO or PBuffer) allowing + * maybe called to use an offscreen drawable (FBO or PBuffer) allowing * the underlying JAWT mechanism to composite the image, if supported. *

    * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} * is being called if {@link GLCapabilitiesImmutable#isOnscreen()} is false. *

    - * + * *
    Java2D OpenGL Remarks
    * * To avoid any conflicts with a potential Java2D OpenGL context,
    @@ -274,7 +274,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public final Object getUpstreamWidget() { return this; } - + @Override public void setShallUseOffscreenLayer(boolean v) { shallUseOffscreenLayer = v; @@ -315,11 +315,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing * all platforms since the peer hasn't been created. */ final GraphicsConfiguration gc = super.getGraphicsConfiguration(); - + if( Beans.isDesignTime() ) { return gc; } - + /* * chosen is only non-null on platforms where the GLDrawableFactory * returns a non-null GraphicsConfiguration (in the GLCanvas @@ -431,11 +431,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing _lock.unlock(); } } - + private final void setRealizedImpl(boolean realized) { final RecursiveLock _lock = lock; _lock.lock(); - try { + try { final GLDrawable _drawable = drawable; if( null == _drawable || realized == _drawable.isRealized() || realized && ( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) ) { @@ -448,10 +448,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } finally { _lock.unlock(); } - } + } private final Runnable realizeOnEDTAction = new Runnable() { public void run() { setRealizedImpl(true); } }; private final Runnable unrealizeOnEDTAction = new Runnable() { public void run() { setRealizedImpl(false); } }; - + @Override public final void setRealized(boolean realized) { // Make sure drawable realization happens on AWT-EDT and only there. Consider the AWTTree lock! @@ -503,7 +503,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void destroy() { destroyImpl( false ); } - + protected void destroyImpl(boolean destroyJAWTWindowAndAWTDevice) { Threading.invoke(true, destroyOnEDTAction, getTreeLock()); if( destroyJAWTWindowAndAWTDevice ) { @@ -553,14 +553,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void addNotify() { final RecursiveLock _lock = lock; _lock.lock(); - try { + try { final boolean isBeansDesignTime = Beans.isDesignTime(); - + if(DEBUG) { System.err.println(getThreadName()+": Info: addNotify - start, bounds: "+this.getBounds()+", isBeansDesignTime "+isBeansDesignTime); // Thread.dumpStack(); } - + if( isBeansDesignTime ) { super.addNotify(); } else { @@ -576,21 +576,21 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if(null==awtConfig) { throw new GLException("Error: NULL AWTGraphicsConfiguration"); } - + // before native peer is valid: X11 disableBackgroundErase(); - + // issues getGraphicsConfiguration() and creates the native peer super.addNotify(); - + // after native peer is valid: Windows disableBackgroundErase(); - + createDrawableAndContext( true ); - + // init drawable by paint/display makes the init sequence more equal // for all launch flavors (applet/javaws/..) - // validateGLDrawable(); + // validateGLDrawable(); } awtWindowClosingProtocol.addClosingListener(); @@ -606,7 +606,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if ( !Beans.isDesignTime() ) { if( createJAWTWindow ) { jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); - jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); + jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); } jawtWindow.lockSurface(); try { @@ -617,7 +617,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing jawtWindow.unlockSurface(); } } - } + } private boolean validateGLDrawable() { if( Beans.isDesignTime() || !isDisplayable() ) { @@ -641,7 +641,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } return false; } - + /**

    Overridden to track when this component is removed from a container. Subclasses which override this method must call super.removeNotify() in their removeNotify() method in order to @@ -686,13 +686,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void reshape(int x, int y, int width, int height) { synchronized (getTreeLock()) { // super.reshape(..) claims tree lock, so we do extend it's lock over reshape super.reshape(x, y, width, height); - + if(DEBUG) { final NativeSurface ns = getNativeSurface(); final long nsH = null != ns ? ns.getSurfaceHandle() : 0; System.err.println("GLCanvas.sizeChanged: ("+getThreadName()+"): "+width+"x"+height+" - surfaceHandle 0x"+Long.toHexString(nsH)); // Thread.dumpStack(); - } + } if( validateGLDrawable() && !printActive ) { final GLDrawableImpl _drawable = drawable; if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) { @@ -701,7 +701,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing try { final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, width, height); if(_drawable != _drawableNew) { - // write back + // write back drawable = _drawableNew; } } finally { @@ -723,13 +723,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } private volatile boolean printActive = false; - private GLAnimatorControl printAnimator = null; + private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; - + @Override public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { - printActive = true; + printActive = true; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG); @@ -742,14 +742,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if(DEBUG) { System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable not valid yet"); } - printActive = false; + printActive = false; return; // not yet available .. } if( !isVisible() ) { if(DEBUG) { System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable visible"); } - printActive = false; + printActive = false; return; // not yet available .. } sendReshape = false; // clear reshape flag @@ -757,7 +757,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( null != printAnimator ) { printAnimator.remove(GLCanvas.this); } - printGLAD = GLCanvas.this; // _not_ default, shall be replaced by offscreen GLAD + printGLAD = GLCanvas.this; // _not_ default, shall be replaced by offscreen GLAD final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); final int printNumSamples = printAWTTiles.getNumSamples(caps); GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); @@ -783,8 +783,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing caps.setNumSamples(printNumSamples); } final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, - printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, null); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); @@ -801,7 +801,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } }; - + @Override public void releasePrint() { if( !printActive || null == printGLAD ) { @@ -832,7 +832,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing display(); } }; - + @Override public void print(Graphics graphics) { if( !printActive || null == printGLAD ) { @@ -843,7 +843,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // we cannot dispatch print on AWT-EDT due to printing internal locking .. } sendReshape = false; // clear reshape flag - + final Graphics2D g2d = (Graphics2D)graphics; try { printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); @@ -876,7 +876,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing System.err.println("AWT print.X: "+printAWTTiles); } } - + @Override public void addGLEventListener(GLEventListener listener) { helper.addGLEventListener(listener); @@ -906,14 +906,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void setGLEventListenerInitState(GLEventListener listener, boolean initialized) { helper.setGLEventListenerInitState(listener, initialized); } - + @Override public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove) { final DisposeGLEventListenerAction r = new DisposeGLEventListenerAction(listener, remove); Threading.invoke(true, r, getTreeLock()); return r.listener; } - + @Override public GLEventListener removeGLEventListener(GLEventListener listener) { return helper.removeGLEventListener(listener); @@ -948,7 +948,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public boolean invoke(final boolean wait, final List glRunnables) { return helper.invoke(this, wait, glRunnables); } - + @Override public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx) { final RecursiveLock _lock = lock; @@ -967,7 +967,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public final GLDrawable getDelegatedDrawable() { return drawable; } - + @Override public GLContext getContext() { return context; @@ -1049,7 +1049,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final GLDrawable _drawable = drawable; return null != _drawable ? _drawable.isGLOriented() : true; } - + @Override public NativeSurface getNativeSurface() { final GLDrawable _drawable = drawable; @@ -1093,7 +1093,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void run() { final RecursiveLock _lock = lock; _lock.lock(); - try { + try { final GLAnimatorControl animator = getAnimator(); if(DEBUG) { @@ -1101,7 +1101,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing (null!=context) + ", hasDrawable " + (null!=drawable)+", "+animator); // Thread.dumpStack(); } - + final boolean animatorPaused; if(null!=animator) { // can't remove us from animator for recreational addNotify() @@ -1109,7 +1109,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } else { animatorPaused = false; } - + // OLS will be detached by disposeGL's context destruction below if( null != context ) { if( context.isCreated() ) { @@ -1137,11 +1137,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if(animatorPaused) { animator.resume(); } - + if(DEBUG) { System.err.println(getThreadName()+": dispose() - END, animator "+animator); } - + } finally { _lock.unlock(); } @@ -1170,7 +1170,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } jawtWindow=null; } - + if(null != awtConfig) { final AbstractGraphicsConfiguration aconfig = awtConfig.getNativeGraphicsConfiguration(); final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); @@ -1188,7 +1188,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing awtConfig=null; } }; - + private final Runnable initAction = new Runnable() { @Override public void run() { @@ -1250,7 +1250,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing this.listener = listener; this.remove = remove; } - + @Override public void run() { final RecursiveLock _lock = lock; @@ -1262,7 +1262,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } }; - + // Disables the AWT's erasing of this Canvas's background on Windows // in Java SE 6. This internal API is not available in previous // releases, but the system property diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 1ec0ad7bc..84db62515 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -129,7 +129,7 @@ import com.jogamp.opengl.util.texture.TextureState;

    In case the above mentioned GLSL vertical-flipping is not performed, - {@link System#arraycopy(Object, int, Object, int, int) System.arraycopy(..)} is used line by line. + {@link System#arraycopy(Object, int, Object, int, int) System.arraycopy(..)} is used line by line. This step causes more CPU load per frame and is not hardware-accelerated.

    @@ -139,8 +139,8 @@ import com.jogamp.opengl.util.texture.TextureState;

    * Please read Java2D OpenGL Remarks. *

    - * -
    FBO / GLSL Vertical Flip
    + * +
    FBO / GLSL Vertical Flip
    The FBO / GLSL code path uses one texture-unit and binds the FBO texture to it's active texture-target, see {@link #setTextureUnit(int)} and {@link #getTextureUnit()}.

    @@ -154,7 +154,7 @@ import com.jogamp.opengl.util.texture.TextureState; Warning (Bug 842): Certain GL states other than viewport and texture (see above) influencing rendering, will also influence the GLSL vertical flip, e.g. {@link GL#glFrontFace(int) glFrontFace}({@link GL#GL_CCW}). It is recommended to reset those states to default when leaving the {@link GLEventListener#display(GLAutoDrawable)} method! - We may change this behavior in the future, i.e. preserve all influencing states. + We may change this behavior in the future, i.e. preserve all influencing states.

    */ @@ -162,23 +162,23 @@ import com.jogamp.opengl.util.texture.TextureState; public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosingProtocol, AWTPrintLifecycle { private static final boolean DEBUG; private static final boolean DEBUG_VIEWPORT; - private static final boolean USE_GLSL_TEXTURE_RASTERIZER; + private static final boolean USE_GLSL_TEXTURE_RASTERIZER; /** Indicates whether the Java 2D OpenGL pipeline is requested by user. */ private static final boolean java2dOGLEnabledByProp; - + /** Indicates whether the Java 2D OpenGL pipeline is enabled, resource-compatible and requested by user. */ private static final boolean useJava2DGLPipeline; - + /** Indicates whether the Java 2D OpenGL pipeline's usage is error free. */ private static boolean java2DGLPipelineOK; - + static { Debug.initSingleton(); DEBUG = Debug.debug("GLJPanel"); DEBUG_VIEWPORT = Debug.isPropertyDefined("jogl.debug.GLJPanel.Viewport", true); USE_GLSL_TEXTURE_RASTERIZER = !Debug.isPropertyDefined("jogl.gljpanel.noglsl", true); - + boolean enabled = Debug.getBooleanProperty("sun.java2d.opengl", false); java2dOGLEnabledByProp = enabled && !Debug.isPropertyDefined("jogl.gljpanel.noogl", true); @@ -201,7 +201,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing System.err.println("GLJPanel: java2DGLPipelineOK "+java2DGLPipelineOK); } } - + private static SingleAWTGLPixelBufferProvider singleAWTGLPixelBufferProvider = null; private static synchronized SingleAWTGLPixelBufferProvider getSingleAWTGLPixelBufferProvider() { if( null == singleAWTGLPixelBufferProvider ) { @@ -209,7 +209,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } return singleAWTGLPixelBufferProvider; } - + private GLDrawableHelper helper = new GLDrawableHelper(); private volatile boolean isInitialized; @@ -236,14 +236,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // Width of the actual GLJPanel: reshapeWidth -> panelWidth -> backend.width private int panelWidth = 0; private int panelHeight = 0; - + // These are always set to (0, 0) except when the Java2D / OpenGL // pipeline is active private int viewportX; private int viewportY; private int requestedTextureUnit = 0; // default - + // The backend in use private volatile Backend backend; @@ -316,7 +316,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing this.factory = GLDrawableFactoryImpl.getFactoryImpl(glProfile); this.chooser = ((chooser != null) ? chooser : new DefaultGLCapabilitiesChooser()); this.shareWith = shareWith; - + this.setFocusable(true); // allow keyboard input! } @@ -336,12 +336,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } customPixelBufferProvider = custom; } - + @Override public final Object getUpstreamWidget() { return this; } - + @Override public void display() { if( isVisible() ) { @@ -446,7 +446,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing handleReshape = false; sendReshape = handleReshape(); } - + if( isVisible() ) { updater.setGraphics(g); backend.doPaintComponent(g); @@ -489,7 +489,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing which override this method must call super.reshape() in their reshape() method in order to function properly.

    * - * {@inheritDoc} + * {@inheritDoc} */ @SuppressWarnings("deprecation") @Override @@ -500,7 +500,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing System.err.println(getThreadName()+": GLJPanel.reshape resize"+(printActive?"WithinPrint":"")+" [ panel "+ panelWidth+"x"+panelHeight + ", reshape: " +reshapeWidth+"x"+reshapeHeight + - "] -> "+(printActive?"skipped":"") + width+"x"+height); + "] -> "+(printActive?"skipped":"") + width+"x"+height); } if( !printActive ) { reshapeWidth = width; @@ -510,13 +510,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } private volatile boolean printActive = false; - private GLAnimatorControl printAnimator = null; + private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; - + @Override public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { - printActive = true; + printActive = true; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG); @@ -532,14 +532,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if(DEBUG) { System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable not valid yet"); } - printActive = false; + printActive = false; return; // not yet available .. } if( !isVisible() ) { if(DEBUG) { System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable visible"); } - printActive = false; + printActive = false; return; // not yet available .. } sendReshape = false; // clear reshape flag @@ -548,8 +548,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if( null != printAnimator ) { printAnimator.remove(GLJPanel.this); } - - printGLAD = GLJPanel.this; // default: re-use + + printGLAD = GLJPanel.this; // default: re-use final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); final int printNumSamples = printAWTTiles.getNumSamples(caps); GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); @@ -570,8 +570,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing caps.setSampleBuffers(0 < printNumSamples); caps.setNumSamples(printNumSamples); final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, - printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, null); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); @@ -588,7 +588,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } }; - + @Override public void releasePrint() { if( !printActive ) { @@ -598,7 +598,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing handleReshape = false; // ditto AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, releasePrintOnEDT); } - + private final Runnable releasePrintOnEDT = new Runnable() { @Override public void run() { @@ -616,7 +616,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printAnimator.add(GLJPanel.this); printAnimator = null; } - + // trigger reshape, i.e. gl-viewport and -listener - this component might got resized! final int awtWidth = GLJPanel.this.getWidth(); final int awtHeight= GLJPanel.this.getHeight(); @@ -639,7 +639,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing display(); } }; - + @Override public void print(Graphics graphics) { if( !printActive ) { @@ -651,7 +651,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } sendReshape = false; // clear reshape flag handleReshape = false; // ditto - + final Graphics2D g2d = (Graphics2D)graphics; try { printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); @@ -691,7 +691,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } print(g); } - + @Override public void setOpaque(boolean opaque) { if (backend != null) { @@ -729,7 +729,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing public void setGLEventListenerInitState(GLEventListener listener, boolean initialized) { helper.setGLEventListenerInitState(listener, initialized); } - + @Override public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove) { final DisposeGLEventListenerAction r = new DisposeGLEventListenerAction(listener, remove); @@ -746,7 +746,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } return r.listener; } - + @Override public GLEventListener removeGLEventListener(GLEventListener listener) { return helper.removeGLEventListener(listener); @@ -781,7 +781,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing public boolean invoke(final boolean wait, final List glRunnables) { return helper.invoke(this, wait, glRunnables); } - + @Override public GLContext createContext(GLContext shareWith) { final Backend b = backend; @@ -821,7 +821,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } return b.getDrawable(); } - + @Override public GLContext getContext() { final Backend b = backend; @@ -918,7 +918,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } return b.getDrawable().isGLOriented(); } - + @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { final Backend b = backend; @@ -956,11 +956,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return factory; } - /** + /** * Returns the used texture unit, i.e. a value of [0..n], or -1 if non used. *

    * If implementation uses a texture-unit, it will be known only after the first initialization, i.e. display call. - *

    + *

    *

    * See FBO / GLSL Vertical Flip. *

    @@ -970,9 +970,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if ( null == b ) { return -1; } - return b.getTextureUnit(); + return b.getTextureUnit(); } - + /** * Allows user to request a texture unit to be used, * must be called before the first initialization, i.e. {@link #display()} call. @@ -982,14 +982,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing *

    * See FBO / GLSL Vertical Flip. *

    - * + * * @param v requested texture unit * @see #getTextureUnit() */ public final void setTextureUnit(int v) { requestedTextureUnit = v; } - + //---------------------------------------------------------------------- // Internals only below this point // @@ -1004,7 +1004,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if (DEBUG) { System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend: " +panelWidth+"x"+panelHeight + " -> " + reshapeWidth+"x"+reshapeHeight); - } + } // Pull down reshapeWidth and reshapeHeight into panelWidth and // panelHeight eagerly in order to complete initialization, and // force a reshape later @@ -1039,7 +1039,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private boolean handleReshape() { if (DEBUG) { System.err.println(getThreadName()+": GLJPanel.handleReshape: " +panelWidth+"x"+panelHeight + " -> " + reshapeWidth+"x"+reshapeHeight); - } + } panelWidth = reshapeWidth; panelHeight = reshapeHeight; @@ -1089,7 +1089,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing public void plainPaint(GLAutoDrawable drawable) { helper.display(GLJPanel.this); } - + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { // This is handled above and dispatched directly to the appropriate context @@ -1148,7 +1148,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing updater.plainPaint(GLJPanel.this); } }; - + private final Runnable paintImmediatelyAction = new Runnable() { @Override public void run() { @@ -1172,7 +1172,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } }; - + private int getGLInteger(GL gl, int which) { int[] tmp = new int[1]; gl.glGetIntegerv(which, tmp, 0); @@ -1203,7 +1203,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing /** Called when the opacity of the GLJPanel is changed */ public void setOpaque(boolean opaque); - /** + /** * Called to manually create an additional OpenGL context against * this GLJPanel */ @@ -1220,7 +1220,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing /** Returns the used texture unit, i.e. a value of [0..n], or -1 if non used. */ public int getTextureUnit(); - + /** Called to fetch the "real" GLCapabilities for the backend */ public GLCapabilitiesImmutable getChosenGLCapabilities(); @@ -1240,7 +1240,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing */ public boolean preGL(Graphics g); - /** + /** * Called after the OpenGL work is done in init() and display(). * The isDisplay argument indicates whether this was called on * behalf of a call to display() rather than init(). @@ -1262,7 +1262,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final boolean useSingletonBuffer; private AWTGLPixelBuffer pixelBuffer; private BufferedImage alignedImage; - + // One of these is used to store the read back pixels before storing // in the BufferedImage protected IntBuffer readBackIntsForCPUVFlip; @@ -1272,10 +1272,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private boolean offscreenIsFBO; private FBObject fboFlipped; private GLSLTextureRaster glslTextureRaster; - + private GLContextImpl offscreenContext; - private boolean flipVertical; - + private boolean flipVertical; + // For saving/restoring of OpenGL state during ReadPixels private final GLPixelStorageModes psm = new GLPixelStorageModes(); @@ -1291,7 +1291,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing useSingletonBuffer = false; } } - + @Override public boolean isUsingOwnLifecycle() { return false; } @@ -1351,11 +1351,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } else { fboFlipped = null; glslTextureRaster = null; - } + } offscreenContext.release(); } else { isInitialized = false; - } + } } finally { if( !isInitialized ) { if(null != offscreenContext) { @@ -1376,7 +1376,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing System.err.println(getThreadName()+": OffscreenBackend: destroy() - offscreenContext: "+(null!=offscreenContext)+" - offscreenDrawable: "+(null!=offscreenDrawable)); } if ( null != offscreenContext && offscreenContext.isCreated() ) { - if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { + if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { try { final GL gl = offscreenContext.getGL(); if(null != glslTextureRaster) { @@ -1394,7 +1394,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing glslTextureRaster = null; fboFlipped = null; offscreenContext = null; - + if (offscreenDrawable != null) { final AbstractGraphicsDevice adevice = offscreenDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); offscreenDrawable.setRealized(false); @@ -1404,8 +1404,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } offscreenIsFBO = false; - - if( null != readBackIntsForCPUVFlip ) { + + if( null != readBackIntsForCPUVFlip ) { readBackIntsForCPUVFlip.clear(); readBackIntsForCPUVFlip = null; } @@ -1449,10 +1449,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing componentCount = 4; alignment = 4; } - - final GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount); - - if( useSingletonBuffer ) { // attempt to fetch the latest AWTGLPixelBuffer + + final GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount); + + if( useSingletonBuffer ) { // attempt to fetch the latest AWTGLPixelBuffer pixelBuffer = (AWTGLPixelBuffer) ((SingletonGLPixelBufferProvider)pixelBufferProvider).getSingleBuffer(pixelAttribs); } if( null != pixelBuffer && pixelBuffer.requiresNewBuffer(gl, panelWidth, panelHeight, 0) ) { @@ -1463,7 +1463,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if ( null == pixelBuffer ) { if (0 >= panelWidth || 0 >= panelHeight ) { return; - } + } pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, panelWidth, panelHeight, 1, true, 0); if(DEBUG) { System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: pixelBufferProvider isSingletonBufferProvider "+useSingletonBuffer+", 0x"+Integer.toHexString(pixelBufferProvider.hashCode())+", "+pixelBufferProvider.getClass().getSimpleName()); @@ -1482,7 +1482,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } final IntBuffer readBackInts; - + if( !flipVertical || null != glslTextureRaster ) { readBackInts = (IntBuffer) pixelBuffer.buffer; } else { @@ -1494,7 +1494,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing final TextureState usrTexState, fboTexState; final int fboTexUnit = GL.GL_TEXTURE0 + ( offscreenIsFBO ? ((GLFBODrawable)offscreenDrawable).getTextureUnit() : 0 ); - + if( offscreenIsFBO ) { usrTexState = new TextureState(gl, GL.GL_TEXTURE_2D); if( fboTexUnit != usrTexState.getUnit() ) { @@ -1510,9 +1510,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing usrTexState = null; fboTexState = null; } - + // Must now copy pixels from offscreen context into surface - + // Save current modes psm.setAlignment(gl, alignment, alignment); if(gl.isGL2ES3()) { @@ -1520,14 +1520,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing gl2es3.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, panelWidth); gl2es3.glReadBuffer(gl2es3.getDefaultReadBuffer()); } - + offscreenDrawable.swapBuffers(); - + if(null != glslTextureRaster) { // implies flippedVertical final boolean viewportChange; final int[] usrViewport = new int[] { 0, 0, 0, 0 }; gl.glGetIntegerv(GL.GL_VIEWPORT, usrViewport, 0); - viewportChange = 0 != usrViewport[0] || 0 != usrViewport[1] || + viewportChange = 0 != usrViewport[0] || 0 != usrViewport[1] || offscreenDrawable.getWidth() != usrViewport[2] || offscreenDrawable.getHeight() != usrViewport[3]; if( DEBUG_VIEWPORT ) { System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL: Viewport: change "+viewportChange+ @@ -1536,21 +1536,21 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } if( viewportChange ) { gl.glViewport(0, 0, offscreenDrawable.getWidth(), offscreenDrawable.getHeight()); - } - - // perform vert-flipping via OpenGL/FBO + } + + // perform vert-flipping via OpenGL/FBO final GLFBODrawable fboDrawable = (GLFBODrawable)offscreenDrawable; final FBObject.TextureAttachment fboTex = fboDrawable.getTextureBuffer(GL.GL_FRONT); - + fboFlipped.bind(gl); - + // gl.glActiveTexture(GL.GL_TEXTURE0 + fboDrawable.getTextureUnit()); // implicit by GLFBODrawableImpl: swapBuffers/contextMadeCurent -> swapFBOImpl - gl.glBindTexture(GL.GL_TEXTURE_2D, fboTex.getName()); + gl.glBindTexture(GL.GL_TEXTURE_2D, fboTex.getName()); // gl.glClear(GL.GL_DEPTH_BUFFER_BIT); // fboFlipped runs w/o DEPTH! - + glslTextureRaster.display(gl.getGL2ES2()); gl.glReadPixels(0, 0, panelWidth, panelHeight, pixelAttribs.format, pixelAttribs.type, readBackInts); - + fboFlipped.unbind(gl); if( viewportChange ) { gl.glViewport(usrViewport[0], usrViewport[1], usrViewport[2], usrViewport[3]); @@ -1558,7 +1558,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing fboTexState.restore(gl); } else { gl.glReadPixels(0, 0, panelWidth, panelHeight, pixelAttribs.format, pixelAttribs.type, readBackInts); - + if ( flipVertical ) { // Copy temporary data into raster of BufferedImage for faster // blitting Note that we could avoid this copy in the cases @@ -1586,7 +1586,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // correctness on all platforms } } - + @Override public int getTextureUnit() { if(null != glslTextureRaster && null != offscreenDrawable) { // implies flippedVertical @@ -1598,16 +1598,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void doPaintComponent(Graphics g) { helper.invokeGL(offscreenDrawable, offscreenContext, updaterDisplayAction, updaterInitAction); - + if ( null != alignedImage ) { // Draw resulting image in one shot g.drawImage(alignedImage, 0, 0, alignedImage.getWidth(), alignedImage.getHeight(), null); // Null ImageObserver since image data is ready. } } - + @Override public void doPlainPaint() { - helper.invokeGL(offscreenDrawable, offscreenContext, updaterPlainDisplayAction, updaterInitAction); + helper.invokeGL(offscreenDrawable, offscreenContext, updaterPlainDisplayAction, updaterInitAction); } @Override @@ -1616,7 +1616,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing { final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, offscreenContext, panelWidth, panelHeight); if(_drawable != _drawableNew) { - // write back + // write back _drawable = _drawableNew; offscreenDrawable = _drawableNew; } @@ -1626,9 +1626,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } panelWidth = _drawable.getWidth(); panelHeight = _drawable.getHeight(); - + if( null != glslTextureRaster ) { - if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { + if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { try { final GL gl = offscreenContext.getGL(); fboFlipped.reset(gl, _drawable.getWidth(), _drawable.getHeight(), 0, false); @@ -1640,7 +1640,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } return _drawable.isRealized(); } - + @Override public GLContext createContext(GLContext shareWith) { return (null != offscreenDrawable) ? offscreenDrawable.createContext(shareWith) : null; @@ -1790,7 +1790,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public int getTextureUnit() { return -1; } - + @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { // FIXME: should do better than this; is it possible to using only platform-independent code? @@ -2114,9 +2114,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void doPlainPaint() { - helper.invokeGL(joglDrawable, joglContext, updaterPlainDisplayAction, updaterInitAction); + helper.invokeGL(joglDrawable, joglContext, updaterPlainDisplayAction, updaterInitAction); } - + private void captureJ2DState(GL gl, Graphics g) { gl.glGetIntegerv(GL2.GL_DRAW_BUFFER, drawBuffer, 0); gl.glGetIntegerv(GL2.GL_READ_BUFFER, readBuffer, 0); diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java index 9fee0a2e2..b4d788329 100644 --- a/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java +++ b/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java @@ -58,18 +58,18 @@ public interface GLMatrixFunc { * which is the same behavior than the native JOGL GL impl */ public void glGetFloatv(int pname, java.nio.FloatBuffer params); - + /** * Copy the named matrix to the given storage at offset. * @param pname {@link #GL_MODELVIEW_MATRIX}, {@link #GL_PROJECTION_MATRIX} or {@link #GL_TEXTURE_MATRIX} * @param params storage * @param params_offset storage offset - */ + */ public void glGetFloatv(int pname, float[] params, int params_offset); - + /** * glGetIntegerv - * @param pname {@link #GL_MATRIX_MODE} to receive the current matrix mode + * @param pname {@link #GL_MATRIX_MODE} to receive the current matrix mode * @param params the FloatBuffer's position remains unchanged * which is the same behavior than the native JOGL GL impl */ @@ -89,7 +89,7 @@ public interface GLMatrixFunc { *

    */ public void glPushMatrix(); - + /** * Pop the current matrix from it's stack. * @see #glPushMatrix() @@ -97,19 +97,19 @@ public interface GLMatrixFunc { public void glPopMatrix(); /** - * Load the current matrix with the identity matrix + * Load the current matrix with the identity matrix */ public void glLoadIdentity() ; /** - * Load the current matrix w/ the provided one. + * Load the current matrix w/ the provided one. * @param params the FloatBuffer's position remains unchanged, * which is the same behavior than the native JOGL GL impl */ - public void glLoadMatrixf(java.nio.FloatBuffer m) ; + public void glLoadMatrixf(java.nio.FloatBuffer m) ; /** * Load the current matrix w/ the provided one. - */ + */ public void glLoadMatrixf(float[] m, int m_offset); /** diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java index 786835f4d..4aff24b36 100644 --- a/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java +++ b/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFunc.java @@ -31,7 +31,7 @@ package javax.media.opengl.fixedfunc; import javax.media.opengl.*; -public interface GLPointerFunc { +public interface GLPointerFunc { public static final int GL_VERTEX_ARRAY = 0x8074; public static final int GL_NORMAL_ARRAY = 0x8075; public static final int GL_COLOR_ARRAY = 0x8076; diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFuncUtil.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFuncUtil.java index 79ec38e0c..9bd644223 100644 --- a/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFuncUtil.java +++ b/src/jogl/classes/javax/media/opengl/fixedfunc/GLPointerFuncUtil.java @@ -28,7 +28,7 @@ package javax.media.opengl.fixedfunc; -public class GLPointerFuncUtil { +public class GLPointerFuncUtil { public static final String mgl_Vertex = "mgl_Vertex"; public static final String mgl_Normal = "mgl_Normal"; public static final String mgl_Color = "mgl_Color"; @@ -37,16 +37,16 @@ public class GLPointerFuncUtil { /** * @param glArrayIndex the fixed function array index - * @return default fixed function array name + * @return default fixed function array name */ public static String getPredefinedArrayIndexName(int glArrayIndex) { return getPredefinedArrayIndexName(glArrayIndex, -1); } - + /** * @param glArrayIndex the fixed function array index - * @param multiTexCoordIndex index for multiTexCoordIndex - * @return default fixed function array name + * @param multiTexCoordIndex index for multiTexCoordIndex + * @return default fixed function array name */ public static String getPredefinedArrayIndexName(int glArrayIndex, int multiTexCoordIndex) { switch(glArrayIndex) { diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java index 1f59b5805..515583b14 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionFactory.java @@ -30,20 +30,20 @@ package jogamp.graph.curve.opengl; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; -/** RegionFactory to create a Context specific Region implementation. - * +/** RegionFactory to create a Context specific Region implementation. + * * @see GLRegion */ public class RegionFactory { - + /** * Create a Region using the passed render mode - * + * *

    In case {@link Region#VBAA_RENDERING_BIT} is being requested the default texture unit * {@link Region#TWO_PASS_DEFAULT_TEXTURE_UNIT} is being used.

    - * + * * @param rs the RenderState to be used - * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, {@link Region#VBAA_RENDERING_BIT} + * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, {@link Region#VBAA_RENDERING_BIT} */ public static GLRegion create(int renderModes) { if( 0 != ( Region.VBAA_RENDERING_BIT & renderModes ) ){ @@ -53,18 +53,18 @@ public class RegionFactory { return new VBORegionSPES2(renderModes); } } - + /** Create a Single Pass Region using the passed render mode - * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, + * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, * {@link Region#VBAA_RENDERING_BIT} * @return */ public static GLRegion createSinglePass(int renderModes) { return new VBORegionSPES2(renderModes); } - + /** Create a Two Pass (VBAA) Region using the passed render mode - * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, + * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, * {@link Region#VBAA_RENDERING_BIT} * @return */ diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index 7f5afcd02..22600cb89 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -43,12 +43,12 @@ import com.jogamp.opengl.util.glsl.ShaderState; public class RegionRendererImpl01 extends RegionRenderer { public RegionRendererImpl01(RenderState rs, int renderModes) { super(rs, renderModes); - + } - + protected boolean initShaderProgram(GL2ES2 gl) { final ShaderState st = rs.getShaderState(); - + final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RegionRendererImpl01.class, "shader", "shader/bin", getVertexShaderName(), true); final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RegionRendererImpl01.class, "shader", @@ -57,29 +57,29 @@ public class RegionRendererImpl01 extends RegionRenderer { // rsFp.defaultShaderCustomization(gl, true, true); int pos = rsFp.addGLSLVersion(gl); if( gl.isGLES2() ) { - pos = rsFp.insertShaderSource(0, pos, ShaderCode.extOESDerivativesEnable); + pos = rsFp.insertShaderSource(0, pos, ShaderCode.extOESDerivativesEnable); } final String rsFpDefPrecision = getFragmentShaderPrecision(gl); if( null != rsFpDefPrecision ) { rsFp.insertShaderSource(0, pos, rsFpDefPrecision); } - + final ShaderProgram sp = new ShaderProgram(); sp.add(rsVp); sp.add(rsFp); - if( !sp.init(gl) ) { + if( !sp.init(gl) ) { throw new GLException("RegionRenderer: Couldn't init program: "+sp); } - st.attachShaderProgram(gl, sp, false); + st.attachShaderProgram(gl, sp, false); st.bindAttribLocation(gl, AttributeNames.VERTEX_ATTR_IDX, AttributeNames.VERTEX_ATTR_NAME); - st.bindAttribLocation(gl, AttributeNames.TEXCOORD_ATTR_IDX, AttributeNames.TEXCOORD_ATTR_NAME); - + st.bindAttribLocation(gl, AttributeNames.TEXCOORD_ATTR_IDX, AttributeNames.TEXCOORD_ATTR_NAME); + if(!sp.link(gl, System.err)) { throw new GLException("RegionRenderer: Couldn't link program: "+sp); - } + } st.useProgram(gl, true); - + if(DEBUG) { System.err.println("RegionRendererImpl01 initialized: " + Thread.currentThread()+" "+st); } @@ -94,5 +94,5 @@ public class RegionRendererImpl01 extends RegionRenderer { @Override protected void drawImpl(GL2ES2 gl, Region region, float[] position, int[] texSize) { ((GLRegion)region).draw(gl, rs, vp_width, vp_height, texSize); - } + } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java b/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java index 51356ca13..8ca29b9f0 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java @@ -38,9 +38,9 @@ import com.jogamp.graph.geom.Vertex; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderState; -public class RenderStateImpl extends RenderState { +public class RenderStateImpl extends RenderState { /** - * weight is equivalent to the + * weight is equivalent to the * global off-curve vertex weight. * TODO: change to per vertex */ @@ -50,7 +50,7 @@ public class RenderStateImpl extends RenderState { public RenderStateImpl(ShaderState st, Vertex.Factory pointFactory, PMVMatrix pmvMatrix) { super(st, pointFactory, pmvMatrix); - + gcu_Weight = new GLUniformData(UniformNames.gcu_Weight, 1.0f); st.ownUniform(gcu_PMVMatrix); gcu_Alpha = new GLUniformData(UniformNames.gcu_Alpha, 1.0f); @@ -60,15 +60,15 @@ public class RenderStateImpl extends RenderState { // gcu_Strength = new GLUniformData(UniformNames.gcu_Strength, 3.0f); // st.ownUniform(gcu_Strength); } - + public RenderStateImpl(ShaderState st, Vertex.Factory pointFactory) { this(st, pointFactory, new PMVMatrix()); } - + public final GLUniformData getWeight() { return gcu_Weight; } public final GLUniformData getAlpha() { return gcu_Alpha; } public final GLUniformData getColorStatic() { return gcu_ColorStatic; } //public final GLUniformData getStrength() { return gcu_Strength; } - - + + } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java index 81c421371..60758b90b 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java @@ -40,11 +40,11 @@ import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; -public class TextRendererImpl01 extends TextRenderer { +public class TextRendererImpl01 extends TextRenderer { public TextRendererImpl01(RenderState rs, int type) { - super(rs, type); + super(rs, type); } - + @Override protected boolean initShaderProgram(GL2ES2 gl){ final ShaderState st = rs.getShaderState(); @@ -63,18 +63,18 @@ public class TextRendererImpl01 extends TextRenderer { if( null != rsFpDefPrecision ) { rsFp.insertShaderSource(0, pos, rsFpDefPrecision); } - + final ShaderProgram sp = new ShaderProgram(); sp.add(rsVp); sp.add(rsFp); - - if( !sp.init(gl) ) { + + if( !sp.init(gl) ) { throw new GLException("RegionRenderer: Couldn't init program: "+sp); } - st.attachShaderProgram(gl, sp, false); + st.attachShaderProgram(gl, sp, false); st.bindAttribLocation(gl, AttributeNames.VERTEX_ATTR_IDX, AttributeNames.VERTEX_ATTR_NAME); - st.bindAttribLocation(gl, AttributeNames.TEXCOORD_ATTR_IDX, AttributeNames.TEXCOORD_ATTR_NAME); - + st.bindAttribLocation(gl, AttributeNames.TEXCOORD_ATTR_IDX, AttributeNames.TEXCOORD_ATTR_NAME); + if(!sp.link(gl, System.err)) { throw new GLException("TextRendererImpl01: Couldn't link program: "+sp); } @@ -82,15 +82,15 @@ public class TextRendererImpl01 extends TextRenderer { if(DEBUG) { System.err.println("TextRendererImpl01 initialized: " + Thread.currentThread()+" "+st); - } + } return true; } - + @Override protected void destroyImpl(GL2ES2 gl) { super.destroyImpl(gl); } - + @Override public void drawString3D(GL2ES2 gl, Font font, String str, float[] position, int fontSize, int[/*1*/] texSize) { if(!isInitialized()){ @@ -101,7 +101,7 @@ public class TextRendererImpl01 extends TextRenderer { glyphString = createString(gl, font, fontSize, str); addCachedGlyphString(gl, font, str, fontSize, glyphString); } - + glyphString.renderString3D(gl, rs, vp_width, vp_height, texSize); } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java index 85d3ad5a7..86c0db8c6 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java @@ -30,7 +30,7 @@ package jogamp.graph.curve.opengl; import java.nio.FloatBuffer; import javax.media.opengl.GL2ES2; -// FIXME: Subsume GL2GL3.GL_DRAW_FRAMEBUFFER -> GL2ES2.GL_DRAW_FRAMEBUFFER ! +// FIXME: Subsume GL2GL3.GL_DRAW_FRAMEBUFFER -> GL2ES2.GL_DRAW_FRAMEBUFFER ! import javax.media.opengl.GL; import javax.media.opengl.GLUniformData; import javax.media.opengl.fixedfunc.GLMatrixFunc; @@ -58,90 +58,90 @@ public class VBORegion2PES2 extends GLRegion { private GLArrayDataServer verticeFboAttr; private GLArrayDataServer texCoordFboAttr; private GLArrayDataServer indicesFbo; - - + + private FBObject fbo; private TextureAttachment texA; private PMVMatrix fboPMVMatrix; GLUniformData mgl_fboPMVMatrix; - + private int tex_width_c = 0; private int tex_height_c = 0; - GLUniformData mgl_ActiveTexture; + GLUniformData mgl_ActiveTexture; GLUniformData mgl_TextureSize; // if GLSL < 1.30 - + public VBORegion2PES2(int renderModes, int textureEngine) { super(renderModes); fboPMVMatrix = new PMVMatrix(); - mgl_fboPMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, fboPMVMatrix.glGetPMvMatrixf()); - mgl_ActiveTexture = new GLUniformData(UniformNames.gcu_TextureUnit, textureEngine); + mgl_fboPMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, fboPMVMatrix.glGetPMvMatrixf()); + mgl_ActiveTexture = new GLUniformData(UniformNames.gcu_TextureUnit, textureEngine); } - + public void update(GL2ES2 gl, RenderState rs) { if(!isDirty()) { - return; + return; } if(null == indicesFbo) { final int initialElementCount = 256; final ShaderState st = rs.getShaderState(); - - indicesFbo = GLArrayDataServer.createData(3, GL2ES2.GL_SHORT, initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); + + indicesFbo = GLArrayDataServer.createData(3, GL2ES2.GL_SHORT, initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); indicesFbo.puts((short) 0); indicesFbo.puts((short) 1); indicesFbo.puts((short) 3); indicesFbo.puts((short) 1); indicesFbo.puts((short) 2); indicesFbo.puts((short) 3); indicesFbo.seal(true); - - texCoordFboAttr = GLArrayDataServer.createGLSL(AttributeNames.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, + + texCoordFboAttr = GLArrayDataServer.createGLSL(AttributeNames.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, false, initialElementCount, GL.GL_STATIC_DRAW); st.ownAttribute(texCoordFboAttr, true); - texCoordFboAttr.putf(5); texCoordFboAttr.putf(5); - texCoordFboAttr.putf(5); texCoordFboAttr.putf(6); - texCoordFboAttr.putf(6); texCoordFboAttr.putf(6); - texCoordFboAttr.putf(6); texCoordFboAttr.putf(5); + texCoordFboAttr.putf(5); texCoordFboAttr.putf(5); + texCoordFboAttr.putf(5); texCoordFboAttr.putf(6); + texCoordFboAttr.putf(6); texCoordFboAttr.putf(6); + texCoordFboAttr.putf(6); texCoordFboAttr.putf(5); texCoordFboAttr.seal(true); - - verticeFboAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, - false, initialElementCount, GL.GL_STATIC_DRAW); + + verticeFboAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, + false, initialElementCount, GL.GL_STATIC_DRAW); st.ownAttribute(verticeFboAttr, true); - - - indicesTxt = GLArrayDataServer.createData(3, GL2ES2.GL_SHORT, initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); - - verticeTxtAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, + + + indicesTxt = GLArrayDataServer.createData(3, GL2ES2.GL_SHORT, initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); + + verticeTxtAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, false, initialElementCount, GL.GL_STATIC_DRAW); st.ownAttribute(verticeTxtAttr, true); - - texCoordTxtAttr = GLArrayDataServer.createGLSL(AttributeNames.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, + + texCoordTxtAttr = GLArrayDataServer.createGLSL(AttributeNames.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, false, initialElementCount, GL.GL_STATIC_DRAW); st.ownAttribute(texCoordTxtAttr, true); - + if(DEBUG_INSTANCE) { System.err.println("VBORegion2PES2 Create: " + this); - } + } } // process triangles indicesTxt.seal(gl, false); - indicesTxt.rewind(); + indicesTxt.rewind(); for(int i=0; i maxTexSize[0]) { texWidth[0] = maxTexSize[0]; // clip to max - write-back user value! } - renderRegion2FBO(gl, rs, texWidth); + renderRegion2FBO(gl, rs, texWidth); } // System.out.println("Scale: " + matrix.glGetMatrixf().get(1+4*3) +" " + matrix.glGetMatrixf().get(2+4*3)); renderFBO(gl, rs, vp_width, vp_height); } } - + private void renderFBO(GL2ES2 gl, RenderState rs, int width, int hight) { final ShaderState st = rs.getShaderState(); - - gl.glViewport(0, 0, width, hight); - st.uniform(gl, mgl_ActiveTexture); + + gl.glViewport(0, 0, width, hight); + st.uniform(gl, mgl_ActiveTexture); gl.glActiveTexture(GL.GL_TEXTURE0 + mgl_ActiveTexture.intValue()); - fbo.use(gl, texA); - verticeFboAttr.enableBuffer(gl, true); - texCoordFboAttr.enableBuffer(gl, true); + fbo.use(gl, texA); + verticeFboAttr.enableBuffer(gl, true); + texCoordFboAttr.enableBuffer(gl, true); indicesFbo.bindBuffer(gl, true); // keeps VBO binding - + gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesFbo.getElementCount() * indicesFbo.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0); - - indicesFbo.bindBuffer(gl, false); + + indicesFbo.bindBuffer(gl, false); texCoordFboAttr.enableBuffer(gl, false); - verticeFboAttr.enableBuffer(gl, false); + verticeFboAttr.enableBuffer(gl, false); fbo.unuse(gl); - + // setback: gl.glActiveTexture(currentActiveTextureEngine[0]); } - + private void renderRegion2FBO(GL2ES2 gl, RenderState rs, int[/*1*/] texWidth) { final ShaderState st = rs.getShaderState(); - + if(0>=texWidth[0]) { throw new IllegalArgumentException("texWidth must be greater than 0: "+texWidth[0]); } - + tex_width_c = texWidth[0]; tex_height_c = (int) ( ( ( tex_width_c * box.getHeight() ) / box.getWidth() ) + 0.5f ); - + // System.out.println("FBO Size: "+texWidth[0]+" -> "+tex_width_c+"x"+tex_height_c); // System.out.println("FBO Scale: " + m.glGetMatrixf().get(0) +" " + m.glGetMatrixf().get(5)); - + if(null != fbo && fbo.getWidth() != tex_width_c && fbo.getHeight() != tex_height_c ) { fbo.reset(gl, tex_width_c, tex_height_c); } - - if(null == fbo) { + + if(null == fbo) { fbo = new FBObject(); - fbo.reset(gl, tex_width_c, tex_height_c); + fbo.reset(gl, tex_width_c, tex_height_c); // FIXME: shall not use bilinear, due to own AA ? However, w/o bilinear result is not smooth texA = fbo.attachTexture2D(gl, 0, true, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE); // texA = fbo.attachTexture2D(gl, 0, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE); @@ -260,18 +260,18 @@ public class VBORegion2PES2 extends GLRegion { } else { fbo.bind(gl); } - + //render texture gl.glViewport(0, 0, tex_width_c, tex_height_c); st.uniform(gl, mgl_fboPMVMatrix); // use orthogonal matrix - + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT); renderRegion(gl); fbo.unbind(gl); - + st.uniform(gl, rs.getPMVMatrix()); // switch back to real PMV matrix - + // if( !gl.isGL3() ) { // GLSL < 1.30 if(null == mgl_TextureSize) { @@ -281,21 +281,21 @@ public class VBORegion2PES2 extends GLRegion { texSize.put(0, (float)fbo.getWidth()); texSize.put(1, (float)fbo.getHeight()); st.uniform(gl, mgl_TextureSize); - //} + //} } - + private void renderRegion(GL2ES2 gl) { - verticeTxtAttr.enableBuffer(gl, true); + verticeTxtAttr.enableBuffer(gl, true); texCoordTxtAttr.enableBuffer(gl, true); indicesTxt.bindBuffer(gl, true); // keeps VBO binding - + gl.glDrawElements(GL2ES2.GL_TRIANGLES, indicesTxt.getElementCount() * indicesTxt.getComponentCount(), GL2ES2.GL_UNSIGNED_SHORT, 0); - - indicesTxt.bindBuffer(gl, false); + + indicesTxt.bindBuffer(gl, false); texCoordTxtAttr.enableBuffer(gl, false); - verticeTxtAttr.enableBuffer(gl, false); + verticeTxtAttr.enableBuffer(gl, false); } - + public void destroy(GL2ES2 gl, RenderState rs) { if(DEBUG_INSTANCE) { System.err.println("VBORegion2PES2 Destroy: " + this); @@ -305,7 +305,7 @@ public class VBORegion2PES2 extends GLRegion { fbo.destroy(gl); fbo = null; texA = null; - } + } if(null != verticeTxtAttr) { st.ownAttribute(verticeTxtAttr, false); verticeTxtAttr.destroy(gl); @@ -335,6 +335,6 @@ public class VBORegion2PES2 extends GLRegion { indicesFbo = null; } triangles.clear(); - vertices.clear(); - } + vertices.clear(); + } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java index 0cba444ad..0a867b45c 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -44,13 +44,13 @@ public class VBORegionSPES2 extends GLRegion { private GLArrayDataServer texCoordAttr = null; private GLArrayDataServer indices = null; - protected VBORegionSPES2(int renderModes) { + protected VBORegionSPES2(int renderModes) { super(renderModes); } protected void update(GL2ES2 gl, RenderState rs) { if(!isDirty()) { - return; + return; } if(null == indices) { @@ -59,11 +59,11 @@ public class VBORegionSPES2 extends GLRegion { indices = GLArrayDataServer.createData(3, GL2ES2.GL_SHORT, initialElementCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); - verticeAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, - false, initialElementCount, GL.GL_STATIC_DRAW); + verticeAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL2ES2.GL_FLOAT, + false, initialElementCount, GL.GL_STATIC_DRAW); st.ownAttribute(verticeAttr, true); - texCoordAttr = GLArrayDataServer.createGLSL(AttributeNames.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, + texCoordAttr = GLArrayDataServer.createGLSL(AttributeNames.TEXCOORD_ATTR_NAME, 2, GL2ES2.GL_FLOAT, false, initialElementCount, GL.GL_STATIC_DRAW); st.ownAttribute(texCoordAttr, true); @@ -74,7 +74,7 @@ public class VBORegionSPES2 extends GLRegion { // process triangles indices.seal(gl, false); - indices.rewind(); + indices.rewind(); for(int i=0; i loops; private ArrayList vertices; - + private ArrayList triangles; private int maxTriID = 0; - + /** Constructor for a new Delaunay triangulator */ public CDTriangulator2D() { reset(); } - + /** Reset the triangulation to initial state * Clearing cached data */ @@ -71,14 +71,14 @@ public class CDTriangulator2D implements Triangulator{ triangles = new ArrayList(3); loops = new ArrayList(); } - + public void addCurve(Outline polyline) { Loop loop = null; - + if(!loops.isEmpty()) { loop = getContainerLoop(polyline); } - + if(loop == null) { GraphOutline outline = new GraphOutline(polyline); GraphOutline innerPoly = extractBoundaryTriangles(outline, false); @@ -92,8 +92,8 @@ public class CDTriangulator2D implements Triangulator{ loop.addConstraintCurve(innerPoly); } } - - public ArrayList generate() { + + public ArrayList generate() { for(int i=0;i vertices = polyline.getVertices(); for(int i=0; i < loops.size(); i++) { diff --git a/src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java b/src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java index c8251af15..2e8d4f58f 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/GraphOutline.java @@ -35,13 +35,13 @@ import com.jogamp.graph.geom.Vertex; public class GraphOutline { final private Outline outline; final private ArrayList controlpoints = new ArrayList(3); - + public GraphOutline(){ this.outline = new Outline(); } - + /**Create a control polyline of control vertices - * the curve pieces can be identified by onCurve flag + * the curve pieces can be identified by onCurve flag * of each cp the control polyline is open by default */ public GraphOutline(Outline ol){ @@ -59,7 +59,7 @@ public class GraphOutline { public ArrayList getGraphPoint() { return controlpoints; } - + public ArrayList getVertices() { return outline.getVertices(); } @@ -68,5 +68,5 @@ public class GraphOutline { controlpoints.add(v); outline.addVertex(v.getPoint()); } - + } diff --git a/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java b/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java index 52d02baa5..1ef1d8c7f 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java @@ -35,7 +35,7 @@ public class GraphVertex { private Vertex point; private ArrayList edges = null; private boolean boundaryContained = false; - + public GraphVertex(Vertex point) { this.point = point; } @@ -43,15 +43,15 @@ public class GraphVertex { public Vertex getPoint() { return point; } - + public float getX(){ return point.getX(); } - + public float getY(){ return point.getY(); } - + public float getZ(){ return point.getZ(); } @@ -70,7 +70,7 @@ public class GraphVertex { public void setEdges(ArrayList edges) { this.edges = edges; } - + public void addEdge(HEdge edge){ if(edges == null){ edges = new ArrayList(); @@ -112,7 +112,7 @@ public class GraphVertex { } return null; } - + public boolean isBoundaryContained() { return boundaryContained; } diff --git a/src/jogl/classes/jogamp/graph/curve/tess/HEdge.java b/src/jogl/classes/jogamp/graph/curve/tess/HEdge.java index 4d29a81f3..acaa3d708 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/HEdge.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/HEdge.java @@ -35,14 +35,14 @@ public class HEdge { public static int BOUNDARY = 3; public static int INNER = 1; public static int HOLE = 2; - + private GraphVertex vert; private HEdge prev = null; private HEdge next = null; private HEdge sibling = null; private int type = BOUNDARY; private Triangle triangle = null; - + public HEdge(GraphVertex vert, int type) { this.vert = vert; this.type = type; @@ -112,19 +112,19 @@ public class HEdge { public void setTriangle(Triangle triangle) { this.triangle = triangle; } - + public static void connect(HEdge first, HEdge next){ first.setNext(next); next.setPrev(first); } - + public static void makeSiblings(HEdge first, HEdge second){ first.setSibling(second); second.setSibling(first); } - + public boolean vertexOnCurveVertex(){ return vert.getPoint().isOnCurve(); } - + } diff --git a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java index 651179062..c1dafc0d1 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java @@ -51,7 +51,7 @@ public class Loop { public Triangle cut(boolean delaunay){ if(isSimplex()){ - Triangle t = new Triangle(root.getGraphPoint().getPoint(), root.getNext().getGraphPoint().getPoint(), + Triangle t = new Triangle(root.getGraphPoint().getPoint(), root.getNext().getGraphPoint().getPoint(), root.getNext().getNext().getGraphPoint().getPoint()); t.setVerticesBoundary(checkVerticesBoundary(root)); return t; @@ -103,20 +103,20 @@ public class Loop { throw new IllegalArgumentException("outline's vertices < 3: " + vertices.size()); } final VectorUtil.Winding hasWinding = VectorUtil.getWinding( - vertices.get(0).getPoint(), + vertices.get(0).getPoint(), vertices.get(1).getPoint(), vertices.get(2).getPoint()); //FIXME: handle case when vertices come inverted - Rami // skips inversion CW -> CCW final boolean invert = hasWinding != reqWinding && reqWinding == VectorUtil.Winding.CW; - + final int max; final int edgeType = reqWinding == VectorUtil.Winding.CCW ? HEdge.BOUNDARY : HEdge.HOLE ; int index; HEdge firstEdge = null; HEdge lastEdge = null; - + if(!invert) { max = vertices.size(); index = 0; @@ -160,7 +160,7 @@ public class Loop { public void addConstraintCurve(GraphOutline polyline) { // GraphOutline outline = new GraphOutline(polyline); /**needed to generate vertex references.*/ - initFromPolyline(polyline, VectorUtil.Winding.CW); + initFromPolyline(polyline, VectorUtil.Winding.CW); GraphVertex v3 = locateClosestVertex(polyline); HEdge v3Edge = v3.findBoundEdge(); @@ -180,9 +180,9 @@ public class Loop { HEdge.connect(crossEdgeSib, root); } - /** Locates the vertex and update the loops root - * to have (root + vertex) as closest pair - * @param polyline the control polyline + /** Locates the vertex and update the loops root + * to have (root + vertex) as closest pair + * @param polyline the control polyline * to search for closestvertices * @return the vertex that is closest to the newly set root Hedge. */ @@ -205,7 +205,7 @@ public class Loop { for (GraphVertex vert:vertices){ if(vert == v || vert == nextV || vert == cand) continue; - inValid = VectorUtil.inCircle(v.getPoint(), nextV.getPoint(), + inValid = VectorUtil.inCircle(v.getPoint(), nextV.getPoint(), cand.getPoint(), vert.getPoint()); if(inValid){ break; @@ -243,8 +243,8 @@ public class Loop { Vertex cand = candEdge.getGraphPoint().getPoint(); HEdge e = candEdge.getNext(); while (e != candEdge){ - if(e.getGraphPoint() == root.getGraphPoint() - || e.getGraphPoint() == next.getGraphPoint() + if(e.getGraphPoint() == root.getGraphPoint() + || e.getGraphPoint() == next.getGraphPoint() || e.getGraphPoint().getPoint() == cand){ e = e.getNext(); continue; @@ -311,15 +311,15 @@ public class Loop { (v.getX() < (v2.getX() - v1.getX()) * (v.getY() - v1.getY()) / (v2.getY() - v1.getY()) + v1.getX()) ){ inside = !inside; } - + current = next; next = current.getNext(); - + } while(current != root); - + return inside; } - + public int computeLoopSize(){ int size = 0; HEdge e = root; diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java index 751a7e7ac..ff46c3338 100644 --- a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java +++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java @@ -37,17 +37,17 @@ import com.jogamp.graph.curve.OutlineShape; import com.jogamp.opengl.math.Quaternion; public class GlyphShape { - + private Quaternion quat= null; private OutlineShape shape = null; - + /** Create a new Glyph shape * based on Parametric curve control polyline */ public GlyphShape(Vertex.Factory factory){ shape = new OutlineShape(factory); } - + /** Create a new GlyphShape from a {@link OutlineShape} * @param factory vertex impl factory {@link Factory} * @param shape {@link OutlineShape} representation of the Glyph @@ -57,24 +57,24 @@ public class GlyphShape { this.shape = shape; this.shape.transformOutlines(OutlineShape.VerticesState.QUADRATIC_NURBS); } - + public final Vertex.Factory vertexFactory() { return shape.vertexFactory(); } - + public OutlineShape getShape() { return shape; } - + public int getNumVertices() { return shape.getVertices().size(); } - + /** Get the rotational Quaternion attached to this Shape * @return the Quaternion Object */ public Quaternion getQuat() { return quat; } - + /** Set the Quaternion that shall defien the rotation * of this shape. * @param quat @@ -82,7 +82,7 @@ public class GlyphShape { public void setQuat(Quaternion quat) { this.quat = quat; } - + /** Triangluate the glyph shape * @return ArrayList of triangles which define this shape */ @@ -95,5 +95,5 @@ public class GlyphShape { */ public ArrayList getVertices(){ return shape.getVertices(); - } + } } diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java index cc850b823..2284ab669 100644 --- a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java +++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java @@ -52,51 +52,51 @@ public class GlyphString { *

    The actual font size shall be accomplished by the GL PMV matrix.

    */ public static final int STATIC_FONT_SIZE = 10; - + private ArrayList glyphs = new ArrayList(); private CharSequence str; private String fontname; private GLRegion region; - + private SVertex origin = new SVertex(); /** *

    Uses {@link #STATIC_FONT_SIZE}.

    *

    No caching is performed.

    - * + * * @param shape is not null, add all {@link GlyphShape}'s {@link Outline} to this instance. * @param vertexFactory vertex impl factory {@link Factory} - * @param font the target {@link Font} + * @param font the target {@link Font} * @param str string text * @return the created {@link GlyphString} instance */ public static GlyphString createString(OutlineShape shape, Factory vertexFactory, Font font, String str) { - return createString(shape, vertexFactory, font, STATIC_FONT_SIZE, str); + return createString(shape, vertexFactory, font, STATIC_FONT_SIZE, str); } - + /** *

    No caching is performed.

    - * + * * @param shape is not null, add all {@link GlyphShape}'s {@link Outline} to this instance. * @param vertexFactory vertex impl factory {@link Factory} - * @param font the target {@link Font} + * @param font the target {@link Font} * @param fontSize font size * @param str string text * @return the created {@link GlyphString} instance */ public static GlyphString createString(OutlineShape shape, Factory vertexFactory, Font font, int fontSize, String str) { ArrayList shapes = ((FontInt)font).getOutlineShapes(str, fontSize, vertexFactory); - + GlyphString glyphString = new GlyphString(font.getName(Font.NAME_UNIQUNAME), str); glyphString.createfromOutlineShapes(vertexFactory, shapes); if(null != shape) { for(int i=0; i vertexFactory, ArrayList shapes) { final int numGlyps = shapes.size(); @@ -126,31 +126,31 @@ public class GlyphString { continue; } GlyphShape glyphShape = new GlyphShape(vertexFactory, shapes.get(index)); - + if(glyphShape.getNumVertices() < 3) { continue; - } + } addGlyphShape(glyphShape); } } - - + + /** Generate a OGL Region to represent this Object. * @param gl the current gl object * @param rs the current attached RenderState - * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, {@link Region#VBAA_RENDERING_BIT} + * @param renderModes bit-field of modes, e.g. {@link Region#VARIABLE_CURVE_WEIGHT_BIT}, {@link Region#VBAA_RENDERING_BIT} */ public GLRegion createRegion(GL2ES2 gl, int renderModes){ region = RegionFactory.create(renderModes); // region.setFlipped(true); - + int numVertices = region.getNumVertices(); - + for(int i=0; i< glyphs.size(); i++) { final GlyphShape glyph = glyphs.get(i); ArrayList gtris = glyph.triangulate(); region.addTriangles(gtris); - + final ArrayList gVertices = glyph.getVertices(); for(int j=0; j getOutlineShapes(CharSequence string, float pixelSize, Factory vertexFactory); diff --git a/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java b/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java index 3736c5f13..5978e937d 100644 --- a/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java +++ b/src/jogl/classes/jogamp/graph/font/JavaFontLoader.java @@ -40,16 +40,16 @@ import com.jogamp.graph.font.FontSet; import com.jogamp.graph.font.FontFactory; public class JavaFontLoader implements FontSet { - - // FIXME: Add cache size to limit memory usage + + // FIXME: Add cache size to limit memory usage private static final IntObjectHashMap fontMap = new IntObjectHashMap(); - + private static final FontSet fontLoader = new JavaFontLoader(); public static FontSet get() { return fontLoader; } - + final static String availableFontFileNames[] = { /* 00 */ "LucidaBrightRegular.ttf", @@ -61,9 +61,9 @@ public class JavaFontLoader implements FontSet { /* 06 */ "LucidaTypewriterRegular.ttf", /* 07 */ "LucidaTypewriterBold.ttf", }; - + final String javaFontPath; - + private JavaFontLoader() { final String javaHome = AccessController.doPrivileged(new PrivilegedAction() { public String run() { @@ -80,11 +80,11 @@ public class JavaFontLoader implements FontSet { static boolean is(int bits, int bit) { return 0 != ( bits & bit ) ; } - + public Font getDefault() throws IOException { - return get(FAMILY_REGULAR, 0) ; // Sans Serif Regular + return get(FAMILY_REGULAR, 0) ; // Sans Serif Regular } - + public Font get(int family, int style) throws IOException { Font font = (Font)fontMap.get( ( family << 8 ) | style ); if (font != null) { @@ -92,8 +92,8 @@ public class JavaFontLoader implements FontSet { } // 1st process Sans Serif (2 fonts) - if( is(style, STYLE_SERIF) ) { - if( is(style, STYLE_BOLD) ) { + if( is(style, STYLE_SERIF) ) { + if( is(style, STYLE_BOLD) ) { font = abspath(availableFontFileNames[5], family, style); } else { font = abspath(availableFontFileNames[4], family, style); @@ -103,53 +103,53 @@ public class JavaFontLoader implements FontSet { } return font; } - + // Serif Fonts .. switch (family) { case FAMILY_LIGHT: case FAMILY_MEDIUM: case FAMILY_CONDENSED: case FAMILY_REGULAR: - if( is(style, STYLE_BOLD) ) { - if( is(style, STYLE_ITALIC) ) { + if( is(style, STYLE_BOLD) ) { + if( is(style, STYLE_ITALIC) ) { font = abspath(availableFontFileNames[3], family, style); } else { font = abspath(availableFontFileNames[2], family, style); } - } else if( is(style, STYLE_ITALIC) ) { + } else if( is(style, STYLE_ITALIC) ) { font = abspath(availableFontFileNames[1], family, style); } else { font = abspath(availableFontFileNames[0], family, style); } break; - + case FAMILY_MONOSPACED: - if( is(style, STYLE_BOLD) ) { + if( is(style, STYLE_BOLD) ) { font = abspath(availableFontFileNames[7], family, style); } else { font = abspath(availableFontFileNames[6], family, style); } - break; + break; } return font; } - + Font abspath(String fname, int family, int style) throws IOException { if(null == javaFontPath) { throw new GLException("java font path undefined"); } final String err = "Problem loading font "+fname+", file "+javaFontPath+fname ; - + try { final Font f = FontFactory.get( new File(javaFontPath+fname) ); if(null != f) { fontMap.put( ( family << 8 ) | style, f ); return f; } - throw new IOException (err); + throw new IOException (err); } catch (IOException ioe) { - throw new IOException(err, ioe); + throw new IOException(err, ioe); } - } + } } diff --git a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java index c4c580290..254583739 100644 --- a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java +++ b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java @@ -39,23 +39,23 @@ import com.jogamp.graph.font.FontFactory; import java.net.URLConnection; public class UbuntuFontLoader implements FontSet { - - // FIXME: Add cache size to limit memory usage + + // FIXME: Add cache size to limit memory usage private static final IntObjectHashMap fontMap = new IntObjectHashMap(); - - private static final String relPath = "fonts/ubuntu/" ; - + + private static final String relPath = "fonts/ubuntu/" ; + private static final FontSet fontLoader = new UbuntuFontLoader(); public static final FontSet get() { return fontLoader; } - + final static String availableFontFileNames[] = { /* 00 */ "Ubuntu-R.ttf", // regular /* 01 */ "Ubuntu-RI.ttf", // regular italic - /* 02 */ "Ubuntu-B.ttf", // bold + /* 02 */ "Ubuntu-B.ttf", // bold /* 03 */ "Ubuntu-BI.ttf", // bold italic /* 04 */ "Ubuntu-L.ttf", // light /* 05 */ "Ubuntu-LI.ttf", // light italic @@ -63,18 +63,18 @@ public class UbuntuFontLoader implements FontSet { /* 07 */ "Ubuntu-MI.ttf", // medium italic }; - + private UbuntuFontLoader() { } static boolean is(int bits, int bit) { return 0 != ( bits & bit ) ; } - + public Font getDefault() throws IOException { - return get(FAMILY_REGULAR, 0) ; // Sans Serif Regular + return get(FAMILY_REGULAR, 0) ; // Sans Serif Regular } - + public Font get(int family, int style) throws IOException { Font font = (Font)fontMap.get( ( family << 8 ) | style ); if (font != null) { @@ -97,7 +97,7 @@ public class UbuntuFontLoader implements FontSet { font = abspath(availableFontFileNames[0], family, style); } break; - + case FAMILY_LIGHT: if( is(style, STYLE_ITALIC) ) { font = abspath(availableFontFileNames[5], family, style); @@ -105,19 +105,19 @@ public class UbuntuFontLoader implements FontSet { font = abspath(availableFontFileNames[4], family, style); } break; - + case FAMILY_MEDIUM: if( is(style, STYLE_ITALIC) ) { font = abspath(availableFontFileNames[6], family, style); } else { font = abspath(availableFontFileNames[7], family, style); } - break; + break; } return font; } - + Font abspath(String fname, int family, int style) throws IOException { final String err = "Problem loading font "+fname+", stream "+relPath+fname; try { @@ -129,10 +129,10 @@ public class UbuntuFontLoader implements FontSet { if(null != f) { fontMap.put( ( family << 8 ) | style, f ); return f; - } + } throw new IOException(err); } catch(IOException ioe) { - throw new IOException(err, ioe); + throw new IOException(err, ioe); } - } + } } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java index 0441bf836..ba6c72650 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java @@ -51,20 +51,20 @@ import com.jogamp.opengl.math.geom.AABBox; class TypecastFont implements FontInt { static final boolean DEBUG = false; - + final OTFontCollection fontset; final OTFont font; TypecastHMetrics metrics; final CmapFormat cmapFormat; int cmapentries; - - // FIXME: Add cache size to limit memory usage ?? - IntObjectHashMap char2Glyph; + + // FIXME: Add cache size to limit memory usage ?? + IntObjectHashMap char2Glyph; public TypecastFont(OTFontCollection fontset) { this.fontset = fontset; this.font = fontset.getFont(0); - + // FIXME: Generic attempt to find the best CmapTable, // which is assumed to be the one with the most entries (stupid 'eh?) CmapTable cmapTable = font.getCmapTable(); @@ -77,14 +77,14 @@ class TypecastFont implements FontInt { int pidx = cmapIdxEntry.getPlatformId(); CmapFormat cf = cmapIdxEntry.getFormat(); if(DEBUG) { - System.err.println("CmapFormat["+i+"]: platform " + pidx + + System.err.println("CmapFormat["+i+"]: platform " + pidx + ", encoding "+cmapIdxEntry.getEncodingId() + ": "+cf); } - if( _cmapFormatP[pidx] == null || + if( _cmapFormatP[pidx] == null || _cmapFormatP[pidx].getLength() < cf.getLength() ) { _cmapFormatP[pidx] = cf; if( cf.getLength() > platformLength ) { - platformLength = cf.getLength() ; + platformLength = cf.getLength() ; platform = pidx; encoding = cmapIdxEntry.getEncodingId(); } @@ -93,10 +93,10 @@ class TypecastFont implements FontInt { if(0 <= platform) { cmapFormat = _cmapFormatP[platform]; if(DEBUG) { - System.err.println("Selected CmapFormat: platform " + platform + + System.err.println("Selected CmapFormat: platform " + platform + ", encoding "+encoding + ": "+cmapFormat); } - } else { + } else { CmapFormat _cmapFormat = null; /*if(null == _cmapFormat) { platform = ID.platformMacintosh; @@ -127,14 +127,14 @@ class TypecastFont implements FontInt { cmapentries = 0; for (int i = 0; i < cmapFormat.getRangeCount(); ++i) { CmapFormat.Range range = cmapFormat.getRange(i); - cmapentries += range.getEndCode() - range.getStartCode() + 1; // end included - } + cmapentries += range.getEndCode() - range.getStartCode() + 1; // end included + } if(DEBUG) { System.err.println("font direction hint: "+font.getHeadTable().getFontDirectionHint()); System.err.println("num glyphs: "+font.getNumGlyphs()); System.err.println("num cmap entries: "+cmapentries); System.err.println("num cmap ranges: "+cmapFormat.getRangeCount()); - + for (int i = 0; i < cmapFormat.getRangeCount(); ++i) { CmapFormat.Range range = cmapFormat.getRange(i); for (int j = range.getStartCode(); j <= range.getEndCode(); ++j) { @@ -147,7 +147,7 @@ class TypecastFont implements FontInt { } char2Glyph = new IntObjectHashMap(cmapentries + cmapentries/4); } - + public StringBuilder getName(StringBuilder sb, int nameIndex) { return font.getName(nameIndex, sb); } @@ -161,12 +161,12 @@ class TypecastFont implements FontInt { sb = getName(sb, Font.NAME_FAMILY).append("-"); getName(sb, Font.NAME_SUBFAMILY); return sb; - } + } public float getAdvanceWidth(int i, float pixelSize) { - return font.getHmtxTable().getAdvanceWidth(i) * metrics.getScale(pixelSize); + return font.getHmtxTable().getAdvanceWidth(i) * metrics.getScale(pixelSize); } - + public Metrics getMetrics() { if (metrics == null) { metrics = new TypecastHMetrics(this); @@ -175,7 +175,7 @@ class TypecastFont implements FontInt { } public Glyph getGlyph(char symbol) { - TypecastGlyph result = (TypecastGlyph) char2Glyph.get(symbol); + TypecastGlyph result = (TypecastGlyph) char2Glyph.get(symbol); if (null == result) { // final short code = (short) char2Code.get(symbol); short code = (short) cmapFormat.mapCharCode(symbol); @@ -187,7 +187,7 @@ class TypecastFont implements FontInt { default: code = Glyph.ID_UNKNOWN; } } - + jogamp.graph.font.typecast.ot.OTGlyph glyph = font.getGlyph(code); if(null == glyph) { glyph = font.getGlyph(Glyph.ID_UNKNOWN); @@ -200,25 +200,25 @@ class TypecastFont implements FontInt { if(DEBUG) { System.err.println("New glyph: " + (int)symbol + " ( " + (char)symbol +" ) -> " + code + ", contours " + glyph.getPointCount() + ": " + path); } - final HdmxTable hdmx = font.getHdmxTable(); + final HdmxTable hdmx = font.getHdmxTable(); if (null!= result && null != hdmx) { /*if(DEBUG) { System.err.println("hdmx "+hdmx); }*/ for (int i=0; i getOutlineShapes(CharSequence string, float pixelSize, Factory vertexFactory) { AffineTransform transform = new AffineTransform(vertexFactory); return TypecastRenderer.getOutlineShapes(this, string, pixelSize, transform, vertexFactory); @@ -238,7 +238,7 @@ class TypecastFont implements FontInt { } } - return (int)(width + 0.5f); + return (int)(width + 0.5f); } public float getStringHeight(CharSequence string, float pixelSize) { @@ -254,7 +254,7 @@ class TypecastFont implements FontInt { height = (int)Math.ceil(Math.max(bbox.getHeight(), height)); } } - return height; + return height; } public AABBox getStringBounds(CharSequence string, float pixelSize) { @@ -284,17 +284,17 @@ class TypecastFont implements FontInt { totalHeight -= advanceY; totalWidth = Math.max(curLineWidth, totalWidth); } - return new AABBox(0, 0, 0, totalWidth, totalHeight,0); + return new AABBox(0, 0, 0, totalWidth, totalHeight,0); } final public int getNumGlyphs() { return font.getNumGlyphs(); } - + public boolean isPrintableChar( char c ) { return FontFactory.isPrintableChar(c); } - + public String toString() { return getFullFamilyName(null).toString(); } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java index 8479c08ca..77b5a9aa9 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java @@ -46,7 +46,7 @@ public class TypecastFontConstructor implements FontConstructor { public Font create(final File ffile) throws IOException { Object o = AccessController.doPrivileged(new PrivilegedAction() { public Object run() { - OTFontCollection fontset; + OTFontCollection fontset; try { fontset = OTFontCollection.create(ffile); return new TypecastFont(fontset); @@ -63,14 +63,14 @@ public class TypecastFontConstructor implements FontConstructor { } throw new InternalError("Unexpected Object: "+o); } - + public Font create(final URLConnection fconn) throws IOException { return AccessController.doPrivileged(new PrivilegedAction() { public Font run() { File tf = null; int len=0; Font f = null; - try { + try { tf = IOUtil.createTempFile( "jogl.font", ".ttf", false); len = IOUtil.copyURLConn2File(fconn, tf); if(len==0) { @@ -84,7 +84,7 @@ public class TypecastFontConstructor implements FontConstructor { } return f; } - }); + }); } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java index 1205c6539..476b3fd4e 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java @@ -40,45 +40,45 @@ public class TypecastGlyph implements FontInt.GlyphInt { public class Advance { final Font font; - final float advance; - HashMap size2advance = new HashMap(); - + final float advance; + HashMap size2advance = new HashMap(); + public Advance(Font font, float advance) { this.font = font; this.advance = advance; } - + public void reset() { size2advance.clear(); } - + public float getScale(float pixelSize) { return this.font.getMetrics().getScale(pixelSize); } - + public void add(float advance, float size) { size2advance.put(size, advance); } - + public float get(float size, boolean useFrationalMetrics) { Float fo = size2advance.get(size); - if(null == fo) { + if(null == fo) { float value = (this.advance * getScale(size)); if (useFrationalMetrics == false) { //value = (float)Math.ceil(value); // value = (int)value; - value = (int) ( value + 0.5f ) ; // TODO: check + value = (int) ( value + 0.5f ) ; // TODO: check } size2advance.put(size, value); return value; } return fo.floatValue(); } - + public String toString() { return "\nAdvance:"+ @@ -86,147 +86,147 @@ public class TypecastGlyph implements FontInt.GlyphInt { "\n advances: \n"+size2advance; } } - + public class Metrics { AABBox bbox; Advance advance; - + public Metrics(Font font, AABBox bbox, float advance) { this.bbox = bbox; this.advance = new Advance(font, advance); } - + public void reset() { advance.reset(); } - + public float getScale(float pixelSize) { return this.advance.getScale(pixelSize); } - + public AABBox getBBox() { return this.bbox; } - + public void addAdvance(float advance, float size) { this.advance.add(advance, size); } - + public float getAdvance(float size, boolean useFrationalMetrics) { return this.advance.get(size, useFrationalMetrics); } - + public String toString() { return "\nMetrics:"+ "\n bbox: "+this.bbox+ this.advance; } - } + } public static final short INVALID_ID = (short)((1 << 16) - 1); public static final short MAX_ID = (short)((1 << 16) - 2); - + private final Font font; - + char symbol; short id; int advance; Metrics metrics; - + protected Path2D path; // in EM units protected Path2D pathSized; protected float numberSized; - + protected TypecastGlyph(Font font, char symbol) { this.font = font; this.symbol = symbol; } - + protected TypecastGlyph(Font font, char symbol, short id, AABBox bbox, int advance, Path2D path) { this.font = font; this.symbol = symbol; this.advance = advance; - + init(id, bbox, advance); - + this.path = path; this.pathSized = null; this.numberSized = 0.0f; } - + void init(short id, AABBox bbox, int advance) { this.id = id; this.advance = advance; this.metrics = new Metrics(this.font, bbox, this.advance); } - + public void reset(Path2D path) { this.path = path; this.metrics.reset(); } - + public Font getFont() { return this.font; } - + public char getSymbol() { return this.symbol; } - + AABBox getBBoxUnsized() { return this.metrics.getBBox(); } - + public AABBox getBBox() { return this.metrics.getBBox(); } - + public Metrics getMetrics() { return this.metrics; } - + public short getID() { return this.id; } - + public float getScale(float pixelSize) { return this.metrics.getScale(pixelSize); } - + public AABBox getBBox(float pixelSize) { final float size = getScale(pixelSize); AABBox newBox = getBBox().clone(); newBox.scale(size); - return newBox; + return newBox; } - + protected void addAdvance(float advance, float size) { this.metrics.addAdvance(advance, size); } - + public float getAdvance(float pixelSize, boolean useFrationalMetrics) { return this.metrics.getAdvance(pixelSize, useFrationalMetrics); } - + public Path2D getPath() { return this.path; } - + public Path2D getPath(float pixelSize) { final float size = getScale(pixelSize); - + if (this.numberSized != size) { this.numberSized = size; this.pathSized = AffineTransform.getScaleInstance(null, size, size).createTransformedShape(getPath()); - } + } return this.pathSized; - } + } } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java index f170f5819..a6ce58ae2 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java @@ -35,7 +35,7 @@ import com.jogamp.opengl.math.geom.AABBox; class TypecastHMetrics implements Metrics { private final TypecastFont fontImpl; - + // HeadTable private final HeadTable headTable; private final float unitsPerEM_Inv; @@ -44,23 +44,23 @@ class TypecastHMetrics implements Metrics { private final HheaTable hheaTable; // VheaTable (for horizontal fonts) // private final VheaTable vheaTable; - + public TypecastHMetrics(TypecastFont fontImpl) { this.fontImpl = fontImpl; headTable = this.fontImpl.font.getHeadTable(); - hheaTable = this.fontImpl.font.getHheaTable(); + hheaTable = this.fontImpl.font.getHheaTable(); // vheaTable = this.fontImpl.font.getVheaTable(); unitsPerEM_Inv = 1.0f / ( (float) headTable.getUnitsPerEm() ); - + int maxWidth = headTable.getXMax() - headTable.getXMin(); - int maxHeight = headTable.getYMax() - headTable.getYMin(); + int maxHeight = headTable.getYMax() - headTable.getYMin(); float lowx= headTable.getXMin(); float lowy = -(headTable.getYMin()+maxHeight); float highx = lowx + maxWidth; float highy = lowy + maxHeight; bbox = new AABBox(lowx, lowy, 0, highx, highy, 0); // invert } - + public final float getAscent(float pixelSize) { return getScale(pixelSize) * -hheaTable.getAscender(); // invert } @@ -78,7 +78,7 @@ class TypecastHMetrics implements Metrics { } public final AABBox getBBox(float pixelSize) { AABBox res = new AABBox(bbox.getLow(), bbox.getHigh()); - res.scale(getScale(pixelSize)); + res.scale(getScale(pixelSize)); return res; } } \ No newline at end of file diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java index f155345aa..127e260ca 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java @@ -43,14 +43,14 @@ import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Vertex.Factory; /** - * Factory to build a {@link com.jogamp.graph.geom.Path2D Path2D} from - * {@link jogamp.graph.font.typecast.ot.OTGlyph Glyph}s. + * Factory to build a {@link com.jogamp.graph.geom.Path2D Path2D} from + * {@link jogamp.graph.font.typecast.ot.OTGlyph Glyph}s. */ public class TypecastRenderer { - private static void getPaths(TypecastFont font, + private static void getPaths(TypecastFont font, CharSequence string, float pixelSize, AffineTransform transform, Path2D[] p) - { + { if (string == null) { return; } @@ -79,14 +79,14 @@ public class TypecastRenderer { } else if (character == ' ') { advanceTotal += font.getAdvanceWidth(Glyph.ID_SPACE, pixelSize); continue; - } + } Glyph glyph = font.getGlyph(character); Path2D gp = ((GlyphInt)glyph).getPath(); float scale = metrics.getScale(pixelSize); t.translate(advanceTotal, y); t.scale(scale, scale); p[i].append(gp.iterator(t), false); - advanceTotal += glyph.getAdvance(pixelSize, true); + advanceTotal += glyph.getAdvance(pixelSize, true); } } @@ -119,19 +119,19 @@ public class TypecastRenderer { case PathIterator.SEG_MOVETO: shape.closeLastOutline(); shape.addEmptyOutline(); - shape.addVertex(0, vertexFactory.create(coords, 0, 2, true)); + shape.addVertex(0, vertexFactory.create(coords, 0, 2, true)); break; case PathIterator.SEG_LINETO: - shape.addVertex(0, vertexFactory.create(coords, 0, 2, true)); + shape.addVertex(0, vertexFactory.create(coords, 0, 2, true)); break; case PathIterator.SEG_QUADTO: shape.addVertex(0, vertexFactory.create(coords, 0, 2, false)); - shape.addVertex(0, vertexFactory.create(coords, 2, 2, true)); + shape.addVertex(0, vertexFactory.create(coords, 2, 2, true)); break; case PathIterator.SEG_CUBICTO: shape.addVertex(0, vertexFactory.create(coords, 0, 2, false)); shape.addVertex(0, vertexFactory.create(coords, 2, 2, false)); - shape.addVertex(0, vertexFactory.create(coords, 4, 2, true)); + shape.addVertex(0, vertexFactory.create(coords, 4, 2, true)); break; case PathIterator.SEG_CLOSE: shape.closeLastOutline(); @@ -184,12 +184,12 @@ public class TypecastRenderer { if (point_plus1.onCurve) { // s = new Line2D.Float(point.x, point.y, point_plus1.x, point_plus1.y); gp.lineTo( point_plus1.x, point_plus1.y ); - offset++; + offset++; } else { if (point_plus2.onCurve) { // s = new QuadCurve2D.Float( point.x, point.y, point_plus1.x, point_plus1.y, point_plus2.x, point_plus2.y); gp.quadTo(point_plus1.x, point_plus1.y, point_plus2.x, point_plus2.y); - offset+=2; + offset+=2; } else { // s = new QuadCurve2D.Float(point.x,point.y,point_plus1.x,point_plus1.y, // midValue(point_plus1.x, point_plus2.x), midValue(point_plus1.y, point_plus2.y)); @@ -210,7 +210,7 @@ public class TypecastRenderer { // midValue(point.x, point_plus1.x), midValue(point.y, point_plus1.y)); //gp.curve3(midValue(point.x, point_plus1.x), midValue(point.y, point_plus1.y), point.x, point.y); gp.quadTo(point.x, point.y, midValue(point.x, point_plus1.x), midValue(point.y, point_plus1.y)); - offset++; + offset++; } } } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/Disassembler.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/Disassembler.java index b5535758d..8b685659e 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/Disassembler.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/Disassembler.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/Fixed.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/Fixed.java index ece0aae4b..0a4786f82 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/Fixed.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/Fixed.java @@ -840,11 +840,11 @@ public class Fixed { } return n; } - + public static float floatValue(long fixed) { return (fixed >> 16) + (float)(fixed & 0xffff) / 0x10000; } - + public static float roundedFloatValue(long fixed, int decimalPlaces) { int factor = 10 * decimalPlaces; return (float)((int)(floatValue(fixed) * factor)) / factor; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/Mnemonic.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/Mnemonic.java index 6b3dc1f6f..d6c9da268 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/Mnemonic.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/Mnemonic.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java index 8c14b7302..8fc4be92d 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java @@ -104,10 +104,10 @@ public class OTFont { public StringBuilder getName(int nameIndex, StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); - } + } return _name.getRecordsRecordString(sb, nameIndex); } - + public StringBuilder getAllNames(StringBuilder sb, String separator) { if(null != _name) { if(null == sb) { @@ -117,9 +117,9 @@ public class OTFont { _name.getRecord(i).getRecordString(sb).append(separator); } } - return sb; + return sb; } - + public Table getTable(int tableType) { for (int i = 0; i < _tables.length; i++) { if ((_tables[i] != null) && (_tables[i].getType() == tableType)) { @@ -132,31 +132,31 @@ public class OTFont { public Os2Table getOS2Table() { return _os2; } - + public CmapTable getCmapTable() { return _cmap; } - + public HeadTable getHeadTable() { return _head; } - + public HheaTable getHheaTable() { return _hhea; } - + public HdmxTable getHdmxTable() { return _hdmx; } - + public HmtxTable getHmtxTable() { return _hmtx; } - + public LocaTable getLocaTable() { return _loca; } - + public MaxpTable getMaxpTable() { return _maxp; } @@ -186,8 +186,8 @@ public class OTFont { } public OTGlyph getGlyph(int i) { - - final GlyfDescript _glyfDescr = _glyf.getDescription(i); + + final GlyfDescript _glyfDescr = _glyf.getDescription(i); return (null != _glyfDescr) ? new OTGlyph( _glyfDescr, @@ -195,11 +195,11 @@ public class OTFont { _hmtx.getAdvanceWidth(i)) : null; } - + public TableDirectory getTableDirectory() { return _tableDirectory; } - + private Table readTable( DataInputStream dis, int tablesOrigin, @@ -228,13 +228,13 @@ public class OTFont { DataInputStream dis, int directoryOffset, int tablesOrigin) throws IOException { - + // Load the table directory dis.reset(); dis.skip(directoryOffset); _tableDirectory = new TableDirectory(dis); _tables = new Table[_tableDirectory.getNumTables()]; - + // Load some prerequisite tables _head = (HeadTable) readTable(dis, tablesOrigin, Table.head); _hhea = (HheaTable) readTable(dis, tablesOrigin, Table.hhea); @@ -252,7 +252,7 @@ public class OTFont { if (_vhea != null) { _tables[index++] = _vhea; } - + // Load all other tables for (int i = 0; i < _tableDirectory.getNumTables(); i++) { DirectoryEntry entry = _tableDirectory.getEntry(i); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java index 4a041604d..c79380f16 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFontCollection.java @@ -75,11 +75,11 @@ public class OTFontCollection { public OTFont getFont(int i) { return _fonts[i]; } - + public int getFontCount() { return _fonts.length; } - + public TTCHeader getTtcHeader() { return _ttcHeader; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java index 244ab400a..e0d652bd4 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTGlyph.java @@ -102,10 +102,10 @@ public class OTGlyph { } } - public AABBox getBBox() { - return _bbox; + public AABBox getBBox() { + return _bbox; } - + public int getAdvanceWidth() { return _advanceWidth; } @@ -163,7 +163,7 @@ public class OTGlyph { // Append the origin and advanceWidth points (n & n+1) // _points[gd.getPointCount()] = new Point(0, 0, true, true); // _points[gd.getPointCount()+1] = new Point(_advanceWidth, 0, true, true); - + _bbox = new AABBox(gd.getXMinimum(), gd.getYMinimum(), 0, gd.getXMaximum(), gd.getYMaximum(), 0); } } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceData.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceData.java index 433ff6051..7a5b0c4d2 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceData.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceData.java @@ -31,7 +31,7 @@ import java.io.IOException; public class ResourceData { private byte[] data; - + /** Creates new ResourceData */ public ResourceData(DataInput di) throws IOException { int dataLen = di.readInt(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceFile.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceFile.java index 2ada22c82..468ab2e1c 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceFile.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceFile.java @@ -33,14 +33,14 @@ public class ResourceFile { private ResourceHeader header; private ResourceMap map; - + /** Creates new Resource */ public ResourceFile(RandomAccessFile raf) throws IOException { // Read header at the beginning of the file raf.seek(0); header = new ResourceHeader(raf); - + // Seek to the map offset and read the map raf.seek(header.getMapOffset()); map = new ResourceMap(raf); @@ -53,18 +53,18 @@ public class ResourceFile { public static void main(String[] args) { try { //RandomAccessFile raf = new RandomAccessFile("/Library/Fonts/GillSans.dfont", "r"); - + // Tests loading a font from a resource fork on Mac OS X RandomAccessFile raf = new RandomAccessFile("/Library/Fonts/Georgia/..namedfork/rsrc", "r"); ResourceFile resource = new ResourceFile(raf); for (int i = 0; i < resource.getResourceMap().getResourceTypeCount(); i++) { System.out.println(resource.getResourceMap().getResourceType(i).getTypeAsString()); } - + // Get the first 'sfnt' resource ResourceType type = resource.getResourceMap().getResourceType("sfnt"); ResourceReference reference = type.getReference(0); - + type = resource.getResourceMap().getResourceType("FOND"); for (int i = 0; i < type.getCount(); ++i) { reference = type.getReference(i); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceHeader.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceHeader.java index 8f5224632..de13b116f 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceHeader.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceHeader.java @@ -46,15 +46,15 @@ public class ResourceHeader { public int getDataOffset() { return dataOffset; } - + public int getMapOffset() { return mapOffset; } - + public int getDataLength() { return dataLen; } - + public int getMapLength() { return mapLen; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceMap.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceMap.java index 96ba06087..d348c645e 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceMap.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceMap.java @@ -35,7 +35,7 @@ public class ResourceMap { private int fileReferenceNumber; private int attributes; private ResourceType[] types; - + /** Creates new ResourceMap */ public ResourceMap(DataInput di) throws IOException { di.readFully(headerCopy); @@ -45,18 +45,18 @@ public class ResourceMap { int typeOffset = di.readUnsignedShort(); int nameOffset = di.readUnsignedShort(); int typeCount = di.readUnsignedShort() + 1; - + // Read types types = new ResourceType[typeCount]; for (int i = 0; i < typeCount; i++) { types[i] = new ResourceType(di); } - + // Read the references for (int i = 0; i < typeCount; i++) { types[i].readRefs(di); } - + // Read the names for (int i = 0; i < typeCount; i++) { types[i].readNames(di); @@ -76,7 +76,7 @@ public class ResourceMap { public ResourceType getResourceType(int i) { return types[i]; } - + public int getResourceTypeCount() { return types.length; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceReference.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceReference.java index fd7ec46b2..9d1534821 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceReference.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceReference.java @@ -36,7 +36,7 @@ public class ResourceReference { private int dataOffset; private int handle; private String name; - + /** Creates new ResourceReference */ protected ResourceReference(DataInput di) throws IOException { id = di.readUnsignedShort(); @@ -58,23 +58,23 @@ public class ResourceReference { public int getId() { return id; } - + public short getNameOffset() { return nameOffset; } - + public short getAttributes() { return attributes; } - + public int getDataOffset() { return dataOffset; } - + public int getHandle() { return handle; } - + public String getName() { return name; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceType.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceType.java index 1c7e24c0f..2ad002e6a 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceType.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/mac/ResourceType.java @@ -34,7 +34,7 @@ public class ResourceType { private int count; private int offset; private ResourceReference[] references; - + /** Creates new ResourceType */ protected ResourceType(DataInput di) throws IOException { type = di.readInt(); @@ -42,7 +42,7 @@ public class ResourceType { offset = di.readUnsignedShort(); references = new ResourceReference[count]; } - + protected void readRefs(DataInput di) throws IOException { for (int i = 0; i < count; i++) { references[i] = new ResourceReference(di); @@ -58,7 +58,7 @@ public class ResourceType { public int getType() { return type; } - + public String getTypeAsString() { return new StringBuilder() .append((char)((type>>24)&0xff)) @@ -67,11 +67,11 @@ public class ResourceType { .append((char)((type)&0xff)) .toString(); } - + public int getCount() { return count; } - + public int getOffset() { return offset; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/BaseTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/BaseTable.java index ed615eb72..b6626a9cc 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/BaseTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/BaseTable.java @@ -31,18 +31,18 @@ import java.io.IOException; * @author David Schweinsberg */ public class BaseTable implements Table { - + private abstract class BaseCoord { public abstract int getBaseCoordFormat(); - + public abstract short getCoordinate(); } - + private class BaseCoordFormat1 extends BaseCoord { private short _coordinate; - + protected BaseCoordFormat1(DataInput di) throws IOException { _coordinate = di.readShort(); } @@ -50,19 +50,19 @@ public class BaseTable implements Table { public int getBaseCoordFormat() { return 1; } - + public short getCoordinate() { return _coordinate; } - + } - + private class BaseCoordFormat2 extends BaseCoord { private short _coordinate; private int _referenceGlyph; private int _baseCoordPoint; - + protected BaseCoordFormat2(DataInput di) throws IOException { _coordinate = di.readShort(); _referenceGlyph = di.readUnsignedShort(); @@ -72,18 +72,18 @@ public class BaseTable implements Table { public int getBaseCoordFormat() { return 2; } - + public short getCoordinate() { return _coordinate; } - + } - + private class BaseCoordFormat3 extends BaseCoord { private short _coordinate; private int _deviceTableOffset; - + protected BaseCoordFormat3(DataInput di) throws IOException { _coordinate = di.readShort(); _deviceTableOffset = di.readUnsignedShort(); @@ -92,33 +92,33 @@ public class BaseTable implements Table { public int getBaseCoordFormat() { return 2; } - + public short getCoordinate() { return _coordinate; } - + } - + private class FeatMinMaxRecord { - + private int _tag; private int _minCoordOffset; private int _maxCoordOffset; - + protected FeatMinMaxRecord(DataInput di) throws IOException { _tag = di.readInt(); _minCoordOffset = di.readUnsignedShort(); _maxCoordOffset = di.readUnsignedShort(); } } - + private class MinMax { - + private int _minCoordOffset; private int _maxCoordOffset; private int _featMinMaxCount; private FeatMinMaxRecord[] _featMinMaxRecord; - + protected MinMax(int minMaxOffset) throws IOException { DataInput di = getDataInputForOffset(minMaxOffset); _minCoordOffset = di.readUnsignedShort(); @@ -130,14 +130,14 @@ public class BaseTable implements Table { } } } - + private class BaseValues { - + private int _defaultIndex; private int _baseCoordCount; private int[] _baseCoordOffset; private BaseCoord[] _baseCoords; - + protected BaseValues(int baseValuesOffset) throws IOException { DataInput di = getDataInputForOffset(baseValuesOffset); _defaultIndex = di.readUnsignedShort(); @@ -163,12 +163,12 @@ public class BaseTable implements Table { } } } - + private class BaseLangSysRecord { - + private int _baseLangSysTag; private int _minMaxOffset; - + protected BaseLangSysRecord(DataInput di) throws IOException { _baseLangSysTag = di.readInt(); _minMaxOffset = di.readUnsignedShort(); @@ -177,14 +177,14 @@ public class BaseTable implements Table { public int getBaseLangSysTag() { return _baseLangSysTag; } - + public int getMinMaxOffset() { return _minMaxOffset; } } - + private class BaseScript { - + private int _thisOffset; private int _baseValuesOffset; private int _defaultMinMaxOffset; @@ -192,7 +192,7 @@ public class BaseTable implements Table { private BaseLangSysRecord[] _baseLangSysRecord; private BaseValues _baseValues; private MinMax[] _minMax; - + protected BaseScript(int baseScriptOffset) throws IOException { _thisOffset = baseScriptOffset; DataInput di = getDataInputForOffset(baseScriptOffset); @@ -231,9 +231,9 @@ public class BaseTable implements Table { return sb.toString(); } } - + private class BaseScriptRecord { - + private int _baseScriptTag; private int _baseScriptOffset; @@ -245,19 +245,19 @@ public class BaseTable implements Table { public int getBaseScriptTag() { return _baseScriptTag; } - + public int getBaseScriptOffset() { return _baseScriptOffset; } } - + private class BaseScriptList { - + private int _thisOffset; private int _baseScriptCount; private BaseScriptRecord[] _baseScriptRecord; private BaseScript[] _baseScripts; - + protected BaseScriptList(int baseScriptListOffset) throws IOException { _thisOffset = baseScriptListOffset; DataInput di = getDataInputForOffset(baseScriptListOffset); @@ -288,13 +288,13 @@ public class BaseTable implements Table { return sb.toString(); } } - + private class BaseTagList { - + private int _thisOffset; private int _baseTagCount; private int[] _baselineTag; - + protected BaseTagList(int baseTagListOffset) throws IOException { _thisOffset = baseTagListOffset; DataInput di = getDataInputForOffset(baseTagListOffset); @@ -315,9 +315,9 @@ public class BaseTable implements Table { return sb.toString(); } } - + private class Axis { - + private int _thisOffset; private int _baseTagListOffset; private int _baseScriptListOffset; @@ -348,7 +348,7 @@ public class BaseTable implements Table { .toString(); } } - + private DirectoryEntry _de; private int _version; private int _horizAxisOffset; @@ -375,25 +375,25 @@ public class BaseTable implements Table { if (_vertAxisOffset != 0) { _vertAxis = new Axis(_vertAxisOffset); } - + // Let go of the buffer _buf = null; } - + private DataInput getDataInputForOffset(int offset) { return new DataInputStream(new ByteArrayInputStream( _buf, offset, _de.getLength() - offset)); } - + // private String valueAsShortHex(int value) { // return String.format("%1$4x", value); // } -// +// // private String valueAsLongHex(int value) { // return String.format("%1$8x", value); // } - + static protected String tagAsString(int tag) { char[] c = new char[4]; c[0] = (char)((tag >> 24) & 0xff); @@ -402,7 +402,7 @@ public class BaseTable implements Table { c[3] = (char)(tag & 0xff); return String.valueOf(c); } - + public int getType() { return BASE; } @@ -422,7 +422,7 @@ public class BaseTable implements Table { } return sb.toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CffTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CffTable.java index 966f6e17b..62486fb7f 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CffTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CffTable.java @@ -36,13 +36,13 @@ import java.util.Hashtable; * @author David Schweinsberg */ public class CffTable implements Table { - + public class Dict { - + private Dictionary _entries = new Hashtable(); private int[] _data; private int _index; - + protected Dict(int[] data, int offset, int length) { _data = data; _index = offset; @@ -50,11 +50,11 @@ public class CffTable implements Table { addKeyAndValueEntry(); } } - + public Object getValue(int key) { return _entries.get(key); } - + private boolean addKeyAndValueEntry() { ArrayList operands = new ArrayList(); Object operand = null; @@ -74,7 +74,7 @@ public class CffTable implements Table { } return true; } - + private boolean isOperandAtIndex() { int b0 = _data[_index]; if ((32 <= b0 && b0 <= 254) @@ -97,31 +97,31 @@ public class CffTable implements Table { private Object nextOperand() { int b0 = _data[_index]; if (32 <= b0 && b0 <= 246) { - + // 1 byte integer ++_index; return new Integer(b0 - 139); } else if (247 <= b0 && b0 <= 250) { - + // 2 byte integer int b1 = _data[_index + 1]; _index += 2; return new Integer((b0 - 247) * 256 + b1 + 108); } else if (251 <= b0 && b0 <= 254) { - + // 2 byte integer int b1 = _data[_index + 1]; _index += 2; return new Integer(-(b0 - 251) * 256 - b1 - 108); } else if (b0 == 28) { - + // 3 byte integer int b1 = _data[_index + 1]; int b2 = _data[_index + 2]; _index += 3; return new Integer(b1 << 8 | b2); } else if (b0 == 29) { - + // 5 byte integer int b1 = _data[_index + 1]; int b2 = _data[_index + 2]; @@ -130,7 +130,7 @@ public class CffTable implements Table { _index += 5; return new Integer(b1 << 24 | b2 << 16 | b3 << 8 | b4); } else if (b0 == 30) { - + // Real number StringBuilder fString = new StringBuilder(); int nibble1 = 0; @@ -142,13 +142,13 @@ public class CffTable implements Table { ++_index; fString.append(decodeRealNibble(nibble1)); fString.append(decodeRealNibble(nibble2)); - } + } return new Float(fString.toString()); } else { return null; } } - + private String decodeRealNibble(int nibble) { if (nibble < 0xa) { return Integer.toString(nibble); @@ -163,7 +163,7 @@ public class CffTable implements Table { } return ""; } - + public String toString() { StringBuilder sb = new StringBuilder(); Enumeration keys = _entries.keys(); @@ -179,14 +179,14 @@ public class CffTable implements Table { return sb.toString(); } } - + public class Index { - + private int _count; private int _offSize; private int[] _offset; private int[] _data; - + protected Index(DataInput di) throws IOException { _count = di.readUnsignedShort(); _offset = new int[_count + 1]; @@ -203,19 +203,19 @@ public class CffTable implements Table { _data[i] = di.readUnsignedByte(); } } - + public int getCount() { return _count; } - + public int getOffset(int index) { return _offset[index]; } - + public int getDataLength() { return _offset[_offset.length - 1] - 1; } - + public int[] getData() { return _data; } @@ -241,13 +241,13 @@ public class CffTable implements Table { return sb.toString(); } } - + public class TopDictIndex extends Index { protected TopDictIndex(DataInput di) throws IOException { super(di); } - + public Dict getTopDict(int index) { int offset = getOffset(index) - 1; int len = getOffset(index + 1) - offset - 1; @@ -262,13 +262,13 @@ public class CffTable implements Table { return sb.toString(); } } - + public class NameIndex extends Index { protected NameIndex(DataInput di) throws IOException { super(di); } - + public String getName(int index) { String name = null; int offset = getOffset(index) - 1; @@ -286,7 +286,7 @@ public class CffTable implements Table { } return name; } - + public String toString() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < getCount(); ++i) { @@ -301,7 +301,7 @@ public class CffTable implements Table { protected StringIndex(DataInput di) throws IOException { super(di); } - + public String getString(int index) { if (index < CffStandardStrings.standardStrings.length) { return CffStandardStrings.standardStrings[index]; @@ -320,7 +320,7 @@ public class CffTable implements Table { return sb.toString(); } } - + public String toString() { int nonStandardBase = CffStandardStrings.standardStrings.length; StringBuilder sb = new StringBuilder(); @@ -331,12 +331,12 @@ public class CffTable implements Table { return sb.toString(); } } - + private class CharsetRange { - + private int _first; private int _left; - + public int getFirst() { return _first; } @@ -344,7 +344,7 @@ public class CffTable implements Table { protected void setFirst(int first) { _first = first; } - + public int getLeft() { return _left; } @@ -355,39 +355,39 @@ public class CffTable implements Table { } private class CharsetRange1 extends CharsetRange { - + protected CharsetRange1(DataInput di) throws IOException { setFirst(di.readUnsignedShort()); setLeft(di.readUnsignedByte()); } } - + private class CharsetRange2 extends CharsetRange { - + protected CharsetRange2(DataInput di) throws IOException { setFirst(di.readUnsignedShort()); setLeft(di.readUnsignedShort()); } } - + private abstract class Charset { - + public abstract int getFormat(); - + public abstract int getSID(int gid); } - + private class CharsetFormat0 extends Charset { - + private int[] _glyph; - + protected CharsetFormat0(DataInput di, int glyphCount) throws IOException { _glyph = new int[glyphCount - 1]; // minus 1 because .notdef is omitted for (int i = 0; i < glyphCount - 1; ++i) { _glyph[i] = di.readUnsignedShort(); } } - + public int getFormat() { return 0; } @@ -399,11 +399,11 @@ public class CffTable implements Table { return _glyph[gid - 1]; } } - + private class CharsetFormat1 extends Charset { - + private ArrayList _charsetRanges = new ArrayList(); - + protected CharsetFormat1(DataInput di, int glyphCount) throws IOException { int glyphsCovered = glyphCount - 1; // minus 1 because .notdef is omitted while (glyphsCovered > 0) { @@ -421,7 +421,7 @@ public class CffTable implements Table { if (gid == 0) { return 0; } - + // Count through the ranges to find the one of interest int count = 0; for (CharsetRange range : _charsetRanges) { @@ -436,9 +436,9 @@ public class CffTable implements Table { } private class CharsetFormat2 extends Charset { - + private ArrayList _charsetRanges = new ArrayList(); - + protected CharsetFormat2(DataInput di, int glyphCount) throws IOException { int glyphsCovered = glyphCount - 1; // minus 1 because .notdef is omitted while (glyphsCovered > 0) { @@ -456,7 +456,7 @@ public class CffTable implements Table { if (gid == 0) { return 0; } - + // Count through the ranges to find the one of interest int count = 0; for (CharsetRange range : _charsetRanges) { @@ -469,7 +469,7 @@ public class CffTable implements Table { return 0; } } - + private DirectoryEntry _de; private int _major; private int _minor; @@ -499,24 +499,24 @@ public class CffTable implements Table { _minor = di2.readUnsignedByte(); _hdrSize = di2.readUnsignedByte(); _offSize = di2.readUnsignedByte(); - + // Name INDEX di2 = getDataInputForOffset(_hdrSize); _nameIndex = new NameIndex(di2); - + // Top DICT INDEX _topDictIndex = new TopDictIndex(di2); // String INDEX _stringIndex = new StringIndex(di2); - + // Global Subr INDEX _globalSubrIndex = new Index(di2); - + // Encodings go here -- but since this is an OpenType font will this // not always be a CIDFont? In which case there are no encodings // within the CFF data. - + // Load each of the fonts _charStringsIndexArray = new Index[_topDictIndex.getCount()]; _charsets = new Charset[_topDictIndex.getCount()]; @@ -530,7 +530,7 @@ public class CffTable implements Table { di2 = getDataInputForOffset(charStringsOffset); _charStringsIndexArray[i] = new Index(di2); int glyphCount = _charStringsIndexArray[i].getCount(); - + // Charsets Integer charsetOffset = (Integer) _topDictIndex.getTopDict(i).getValue(15); di2 = getDataInputForOffset(charsetOffset); @@ -563,7 +563,7 @@ public class CffTable implements Table { } } } - + private DataInput getDataInputForOffset(int offset) { return new DataInputStream(new ByteArrayInputStream( _buf, offset, @@ -573,7 +573,7 @@ public class CffTable implements Table { public NameIndex getNameIndex() { return _nameIndex; } - + public Charset getCharset(int fontIndex) { return _charsets[fontIndex]; } @@ -581,7 +581,7 @@ public class CffTable implements Table { public Charstring getCharstring(int fontIndex, int gid) { return _charstringsArray[fontIndex][gid]; } - + public int getCharstringCount(int fontIndex) { return _charstringsArray[fontIndex].length; } @@ -607,7 +607,7 @@ public class CffTable implements Table { } return sb.toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Charstring.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Charstring.java index d411d1e00..01e2d4934 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Charstring.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Charstring.java @@ -28,6 +28,6 @@ package jogamp.graph.font.typecast.ot.table; public abstract class Charstring { public abstract int getIndex(); - + public abstract String getName(); } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CharstringType2.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CharstringType2.java index 9c40a0e5e..93ff60988 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CharstringType2.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CharstringType2.java @@ -28,7 +28,7 @@ import jogamp.graph.font.typecast.ot.table.CffTable; * @author David Schweinsberg */ public class CharstringType2 extends Charstring { - + private static final String[] _oneByteOperators = { "-Reserved-", "hstem", @@ -105,7 +105,7 @@ public class CharstringType2 extends Charstring { "flex1", "-Reserved-" }; - + private int _index; private String _name; private int[] _data; @@ -132,7 +132,7 @@ public class CharstringType2 extends Charstring { _localSubrIndex = localSubrIndex; _globalSubrIndex = globalSubrIndex; } - + public int getIndex() { return _index; } @@ -140,7 +140,7 @@ public class CharstringType2 extends Charstring { public String getName() { return _name; } - + private void disassemble(StringBuilder sb) { Number operand = null; while (isOperandAtIndex()) { @@ -151,7 +151,7 @@ public class CharstringType2 extends Charstring { String mnemonic; if (operator == 12) { operator = nextByte(); - + // Check we're not exceeding the upper limit of our mnemonics if (operator > 38) { operator = 38; @@ -162,7 +162,7 @@ public class CharstringType2 extends Charstring { } sb.append(mnemonic); } - + public void resetIP() { _ip = _offset; } @@ -214,15 +214,15 @@ public class CharstringType2 extends Charstring { return null; } } - + public int nextByte() { return _data[_ip++]; } - + public boolean moreBytes() { return _ip < _offset + _length; } - + public String toString() { StringBuilder sb = new StringBuilder(); resetIP(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDef.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDef.java index 4c2f3decb..21698c76b 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDef.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDef.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat1.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat1.java index 0c99ad66a..1079aeed4 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat1.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat1.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat2.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat2.java index 5b7c4d655..59bc7b329 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat2.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat2.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat.java index 7ce531cd9..62ce5ae4c 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat.java @@ -58,21 +58,21 @@ import java.io.IOException; * @author David Schweinsberg */ public abstract class CmapFormat { - + public class Range { - + private int _startCode; private int _endCode; - + protected Range(int startCode, int endCode) { _startCode = startCode; _endCode = endCode; } - + public int getStartCode() { return _startCode; } - + public int getEndCode() { return _endCode; } @@ -116,12 +116,12 @@ public abstract class CmapFormat { } public abstract int getRangeCount(); - + public abstract Range getRange(int index) throws ArrayIndexOutOfBoundsException; public abstract int mapCharCode(int charCode); - + public String toString() { return new StringBuilder() .append("format: ") diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat0.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat0.java index e374f82d2..2093158bd 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat0.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat0.java @@ -74,7 +74,7 @@ public class CmapFormat0 extends CmapFormat { public int getRangeCount() { return 1; } - + public Range getRange(int index) throws ArrayIndexOutOfBoundsException { if (index != 0) { throw new ArrayIndexOutOfBoundsException(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat2.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat2.java index 319d8c0d0..222c93852 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat2.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat2.java @@ -67,7 +67,7 @@ public class CmapFormat2 extends CmapFormat { int _idRangeOffset; int _arrayIndex; } - + private int[] _subHeaderKeys = new int[256]; private SubHeader[] _subHeaders; private int[] _glyphIndexArray; @@ -75,9 +75,9 @@ public class CmapFormat2 extends CmapFormat { protected CmapFormat2(DataInput di) throws IOException { super(di); _format = 2; - + int pos = 6; - + // Read the subheader keys, noting the highest value, as this will // determine the number of subheaders to read. int highest = 0; @@ -88,7 +88,7 @@ public class CmapFormat2 extends CmapFormat { } int subHeaderCount = highest / 8 + 1; _subHeaders = new SubHeader[subHeaderCount]; - + // Read the subheaders, once again noting the highest glyphIndexArray // index range. int indexArrayOffset = 8 * subHeaderCount + 518; @@ -99,18 +99,18 @@ public class CmapFormat2 extends CmapFormat { sh._entryCount = di.readUnsignedShort(); sh._idDelta = di.readShort(); sh._idRangeOffset = di.readUnsignedShort(); - + // Calculate the offset into the _glyphIndexArray pos += 8; sh._arrayIndex = (pos - 2 + sh._idRangeOffset - indexArrayOffset) / 2; - + // What is the highest range within the glyphIndexArray? highest = Math.max(highest, sh._arrayIndex + sh._entryCount); - + _subHeaders[i] = sh; } - + // Read the glyphIndexArray _glyphIndexArray = new int[highest]; for (int i = 0; i < _glyphIndexArray.length; ++i) { @@ -121,12 +121,12 @@ public class CmapFormat2 extends CmapFormat { public int getRangeCount() { return _subHeaders.length; } - + public Range getRange(int index) throws ArrayIndexOutOfBoundsException { if (index < 0 || index >= _subHeaders.length) { throw new ArrayIndexOutOfBoundsException(); } - + // Find the high-byte (if any) int highByte = 0; if (index != 0) { @@ -137,7 +137,7 @@ public class CmapFormat2 extends CmapFormat { } } } - + return new Range( highByte | _subHeaders[index]._firstCode, highByte | (_subHeaders[index]._firstCode + @@ -145,7 +145,7 @@ public class CmapFormat2 extends CmapFormat { } public int mapCharCode(int charCode) { - + // Get the appropriate subheader int index = 0; int highByte = charCode >> 8; @@ -153,14 +153,14 @@ public class CmapFormat2 extends CmapFormat { index = _subHeaderKeys[highByte] / 8; } SubHeader sh = _subHeaders[index]; - + // Is the charCode out-of-range? int lowByte = charCode & 0xff; if (lowByte < sh._firstCode || lowByte >= (sh._firstCode + sh._entryCount)) { return 0; } - + // Now calculate the glyph index int glyphIndex = _glyphIndexArray[sh._arrayIndex + (lowByte - sh._firstCode)]; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat4.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat4.java index c09bdc8c3..ef65867af 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat4.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat4.java @@ -102,7 +102,7 @@ public class CmapFormat4 extends CmapFormat { for (int i = 0; i < count; i++) { _glyphIdArray[i] = di.readUnsignedShort(); } // + 2*count (8*segCount + 2*count + 18) - + // Are there any padding bytes we need to consume? // int leftover = length - (8*segCount + 2*count + 18); // if (leftover > 0) { @@ -113,7 +113,7 @@ public class CmapFormat4 extends CmapFormat { public int getRangeCount() { return _segCount; } - + public Range getRange(int index) throws ArrayIndexOutOfBoundsException { if (index < 0 || index >= _segCount) { throw new ArrayIndexOutOfBoundsException(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat6.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat6.java index a58531d11..a22e33244 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat6.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat6.java @@ -67,7 +67,7 @@ public class CmapFormat6 extends CmapFormat { protected CmapFormat6(DataInput di) throws IOException { super(di); _format = 6; - + // HACK: As this is not yet implemented, we need to skip over the bytes // we should be consuming //di.skipBytes(_length - 4); @@ -76,7 +76,7 @@ public class CmapFormat6 extends CmapFormat { public int getRangeCount() { return 0; } - + public Range getRange(int index) throws ArrayIndexOutOfBoundsException { throw new ArrayIndexOutOfBoundsException(); } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormatUnknown.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormatUnknown.java index 83366b593..3544b6f62 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormatUnknown.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormatUnknown.java @@ -30,12 +30,12 @@ import java.io.IOException; * @version $Id: CmapFormatUnknown.java,v 1.1 2004-12-21 10:21:23 davidsch Exp $ */ public class CmapFormatUnknown extends CmapFormat { - + /** Creates a new instance of CmapFormatUnknown */ protected CmapFormatUnknown(int format, DataInput di) throws IOException { super(di); _format = format; - + // We don't know how to handle this data, so we'll just skip over it di.skipBytes(_length - 4); } @@ -43,7 +43,7 @@ public class CmapFormatUnknown extends CmapFormat { public int getRangeCount() { return 0; } - + public Range getRange(int index) throws ArrayIndexOutOfBoundsException { throw new ArrayIndexOutOfBoundsException(); } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapIndexEntry.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapIndexEntry.java index 85fdf7225..47f6c470d 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapIndexEntry.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapIndexEntry.java @@ -85,7 +85,7 @@ public class CmapIndexEntry implements Comparable { public CmapFormat getFormat() { return _format; } - + public void setFormat(CmapFormat format) { _format = format; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapTable.java index 0050fdd8e..016efa093 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapTable.java @@ -94,7 +94,7 @@ public class CmapTable implements Table { } else if (_entries[i].getOffset() > bytesRead) { di.skipBytes(_entries[i].getOffset() - (int) bytesRead); } else if (_entries[i].getOffset() != bytesRead) { - + // Something is amiss throw new IOException(); } @@ -109,15 +109,15 @@ public class CmapTable implements Table { public int getVersion() { return _version; } - + public int getNumTables() { return _numTables; } - + public CmapIndexEntry getCmapIndexEntry(int i) { return _entries[i]; } - + public CmapFormat getCmapFormat(short platformId, short encodingId) { // Find the requested format @@ -148,7 +148,7 @@ public class CmapTable implements Table { // } return sb.toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Coverage.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Coverage.java index e85fadb5e..4f526f51d 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Coverage.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Coverage.java @@ -68,7 +68,7 @@ public abstract class Coverage { * can't be found. */ public abstract int findGlyph(int glyphId); - + protected static Coverage read(DataInput di) throws IOException { Coverage c = null; int format = di.readUnsignedShort(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CvtTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CvtTable.java index 963163584..867ef1823 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CvtTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CvtTable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -47,7 +47,7 @@ public class CvtTable implements Table { } return sb.toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -57,5 +57,5 @@ public class CvtTable implements Table { public DirectoryEntry getDirectoryEntry() { return de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Device.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Device.java index 6b4af6908..5451f4502 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Device.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Device.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DirectoryEntry.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DirectoryEntry.java index c98f03fe9..7abcec0ce 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DirectoryEntry.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DirectoryEntry.java @@ -70,7 +70,7 @@ public class DirectoryEntry implements Cloneable { _offset = di.readInt(); _length = di.readInt(); } - + public Object clone() { try { return super.clone(); @@ -103,7 +103,7 @@ public class DirectoryEntry implements Cloneable { .append((char)((_tag)&0xff)) .toString(); } - + public String toString() { return new StringBuilder() .append("'").append(getTagAsString()) diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DsigEntry.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DsigEntry.java index 4b41f451d..4a09a4c34 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DsigEntry.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DsigEntry.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -21,7 +21,7 @@ public class DsigEntry { private int format; private int length; private int offset; - + /** Creates new DsigEntry */ protected DsigEntry(DataInput di) throws IOException { format = di.readInt(); @@ -32,11 +32,11 @@ public class DsigEntry { public int getFormat() { return format; } - + public int getLength() { return length; } - + public int getOffset() { return offset; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DsigTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DsigTable.java index e2784f9e6..f25c595d0 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DsigTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DsigTable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -48,7 +48,7 @@ public class DsigTable implements Table { public int getType() { return DSIG; } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -58,7 +58,7 @@ public class DsigTable implements Table { public DirectoryEntry getDirectoryEntry() { return de; } - + public String toString() { StringBuilder sb = new StringBuilder().append("DSIG\n"); for (int i = 0; i < numSigs; i++) { diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FeatureList.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FeatureList.java index 3cfb54a38..fdedca94a 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FeatureList.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FeatureList.java @@ -66,11 +66,11 @@ public class FeatureList { /** Creates new FeatureList */ public FeatureList(DataInputStream dis, int offset) throws IOException { - + // Ensure we're in the right place dis.reset(); dis.skipBytes(offset); - + // Start reading _featureCount = dis.readUnsignedShort(); _featureRecords = new FeatureRecord[_featureCount]; @@ -88,11 +88,11 @@ public class FeatureList { public int getFeatureCount() { return _featureCount; } - + public FeatureRecord getFeatureRecord(int i) { return _featureRecords[i]; } - + public Feature getFeature(int i) { return _features[i]; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FeatureRecord.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FeatureRecord.java index eb610814b..1da74f4d5 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FeatureRecord.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FeatureRecord.java @@ -72,7 +72,7 @@ public class FeatureRecord { public int getTag() { return _tag; } - + public int getOffset() { return _offset; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FpgmTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FpgmTable.java index 9a6000156..b662265d9 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FpgmTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FpgmTable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -33,7 +33,7 @@ public class FpgmTable extends Program implements Table { public String toString() { return Disassembler.disassemble(getInstructions(), 0); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -43,5 +43,5 @@ public class FpgmTable extends Program implements Table { public DirectoryEntry getDirectoryEntry() { return de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspRange.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspRange.java index 2748406df..cf4afa88e 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspRange.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspRange.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -20,10 +20,10 @@ public class GaspRange { public static final int GASP_GRIDFIT = 1; public static final int GASP_DOGRAY = 2; - + private int rangeMaxPPEM; private int rangeGaspBehavior; - + /** Creates new GaspRange */ protected GaspRange(DataInput di) throws IOException { rangeMaxPPEM = di.readUnsignedShort(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspTable.java index a83db5bff..45498eda1 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspTable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -22,7 +22,7 @@ public class GaspTable implements Table { private int version; private int numRanges; private GaspRange[] gaspRange; - + /** Creates new GaspTable */ protected GaspTable(DirectoryEntry de, DataInput di) throws IOException { this.de = (DirectoryEntry) de.clone(); @@ -49,7 +49,7 @@ public class GaspTable implements Table { } return sb.toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -59,5 +59,5 @@ public class GaspTable implements Table { public DirectoryEntry getDirectoryEntry() { return de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java index 4cf254198..50f62ed62 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java @@ -73,7 +73,7 @@ public class GlyfCompositeDescript extends GlyfDescript { int glyphIndex, DataInput di) throws IOException { super(parentTable, glyphIndex, (short) -1, di); - + // Get all of the composite components GlyfCompositeComp comp; int firstIndex = 0; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfDescript.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfDescript.java index a9342a434..a7e2e7b69 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfDescript.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfDescript.java @@ -111,7 +111,7 @@ public abstract class GlyfDescript extends Program implements GlyphDescription { public short getYMinimum() { return _yMin; } - + public String toString() { return new StringBuilder() .append(" numberOfContours: ").append(_numberOfContours) diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfSimpleDescript.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfSimpleDescript.java index c11d2d8ff..f67162cff 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfSimpleDescript.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfSimpleDescript.java @@ -73,7 +73,7 @@ public class GlyfSimpleDescript extends GlyfDescript { short numberOfContours, DataInput di) throws IOException { super(parentTable, glyphIndex, numberOfContours, di); - + // Simple glyph description _endPtsOfContours = new int[numberOfContours]; for (int i = 0; i < numberOfContours; i++) { @@ -184,7 +184,7 @@ public class GlyfSimpleDescript extends GlyfDescript { System.out.println("error: array index out of bounds"); } } - + public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfTable.java index 22fdd8886..34a8218d9 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfTable.java @@ -71,12 +71,12 @@ public class GlyfTable implements Table { LocaTable loca) throws IOException { _de = (DirectoryEntry) de.clone(); _descript = new GlyfDescript[maxp.getNumGlyphs()]; - + // Buffer the whole table so we can randomly access it byte[] buf = new byte[de.getLength()]; di.readFully(buf); ByteArrayInputStream bais = new ByteArrayInputStream(buf); - + // Process all the simple glyphs for (int i = 0; i < maxp.getNumGlyphs(); i++) { int len = loca.getOffset(i + 1) - loca.getOffset(i); @@ -119,7 +119,7 @@ public class GlyfTable implements Table { public int getType() { return glyf; } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyphDescription.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyphDescription.java index 106e17917..025778dfc 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyphDescription.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyphDescription.java @@ -56,29 +56,29 @@ package jogamp.graph.font.typecast.ot.table; * @author David Schweinsberg */ public interface GlyphDescription { - + public int getGlyphIndex(); - + public int getEndPtOfContours(int i); - + public byte getFlags(int i); - + public short getXCoordinate(int i); - + public short getYCoordinate(int i); - + public short getXMaximum(); - + public short getXMinimum(); - + public short getYMaximum(); - + public short getYMinimum(); - + public boolean isComposite(); - + public int getPointCount(); - + public int getContourCount(); // public int getComponentIndex(int c); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GposTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GposTable.java index 91a62362a..9a367412d 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GposTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GposTable.java @@ -48,7 +48,7 @@ public class GposTable implements Table { public int getType() { return GPOS; } - + public String toString() { return "GPOS"; } @@ -62,5 +62,5 @@ public class GposTable implements Table { public DirectoryEntry getDirectoryEntry() { return _de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GsubTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GsubTable.java index c002de374..0351c903d 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GsubTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GsubTable.java @@ -66,10 +66,10 @@ public class GsubTable implements Table, LookupSubtableFactory { private ScriptList _scriptList; private FeatureList _featureList; private LookupList _lookupList; - + protected GsubTable(DirectoryEntry de, DataInput di) throws IOException { _de = (DirectoryEntry) de.clone(); - + // Load into a temporary buffer, and create another input stream byte[] buf = new byte[de.getLength()]; di.readFully(buf); @@ -86,17 +86,17 @@ public class GsubTable implements Table, LookupSubtableFactory { // Feature List _featureList = new FeatureList(dis, featureListOffset); - + // Lookup List _lookupList = new LookupList(dis, lookupListOffset, this); } /** - * 1 - Single - Replace one glyph with one glyph - * 2 - Multiple - Replace one glyph with more than one glyph - * 3 - Alternate - Replace one glyph with one of many glyphs - * 4 - Ligature - Replace multiple glyphs with one glyph - * 5 - Context - Replace one or more glyphs in context + * 1 - Single - Replace one glyph with one glyph + * 2 - Multiple - Replace one glyph with more than one glyph + * 3 - Alternate - Replace one glyph with one of many glyphs + * 4 - Ligature - Replace multiple glyphs with one glyph + * 5 - Context - Replace one or more glyphs in context * 6 - Chaining - Context Replace one or more glyphs in chained context */ public LookupSubtable read( @@ -167,7 +167,7 @@ public class GsubTable implements Table, LookupSubtableFactory { } return "Unknown"; } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -177,5 +177,5 @@ public class GsubTable implements Table, LookupSubtableFactory { public DirectoryEntry getDirectoryEntry() { return _de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HdmxTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HdmxTable.java index 5b1fa2020..42f9bf0d0 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HdmxTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HdmxTable.java @@ -30,9 +30,9 @@ import java.io.IOException; * @version $Id: HdmxTable.java,v 1.2 2007-07-26 11:12:30 davidsch Exp $ */ public class HdmxTable implements Table { - + public class DeviceRecord { - + private short _pixelSize; private short _maxWidth; private short[] _widths; @@ -49,11 +49,11 @@ public class HdmxTable implements Table { public short getPixelSize() { return _pixelSize; } - + public short getMaxWidth() { return _maxWidth; } - + public short[] getWidths() { return _widths; } @@ -61,9 +61,9 @@ public class HdmxTable implements Table { public short getWidth(int glyphidx) { return _widths[glyphidx]; } - + } - + private DirectoryEntry _de; private int _version; private short _numRecords; @@ -78,7 +78,7 @@ public class HdmxTable implements Table { _numRecords = di.readShort(); _sizeDeviceRecords = di.readInt(); _records = new DeviceRecord[_numRecords]; - + // Read the device records for (int i = 0; i < _numRecords; ++i) { _records[i] = new DeviceRecord(maxp.getNumGlyphs(), di); @@ -88,15 +88,15 @@ public class HdmxTable implements Table { public int getNumberOfRecords() { return _numRecords; } - + public DeviceRecord getRecord(int i) { return _records[i]; } - + public int getType() { return hdmx; } - + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'hdmx' Table - Horizontal Device Metrics\n----------------------------------------\n"); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java index 9d7fe4251..cf7c58449 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java @@ -192,7 +192,7 @@ public class HeadTable implements Table { .append("\n glyphDataFormat: ").append(_glyphDataFormat) .toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -202,5 +202,5 @@ public class HeadTable implements Table { public DirectoryEntry getDirectoryEntry() { return _de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HheaTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HheaTable.java index 20a21e4d9..0278929f1 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HheaTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HheaTable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -122,7 +122,7 @@ public class HheaTable implements Table { .append("\n numOf_LongHorMetrics: ").append(numberOfHMetrics) .toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -132,5 +132,5 @@ public class HheaTable implements Table { public DirectoryEntry getDirectoryEntry() { return de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ID.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ID.java index 9fd66e728..eed8c1841 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ID.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ID.java @@ -38,7 +38,7 @@ public abstract class ID { public static final short encodingUnicode11Semantics = 1; public static final short encodingISO10646Semantics = 2; public static final short encodingUnicode20Semantics = 3; - + // Microsoft Encoding IDs // public static final short encodingUndefined = 0; // public static final short encodingUGL = 1; @@ -203,7 +203,7 @@ public abstract class ID { public static String getEncodingName(short platformId, short encodingId) { if (platformId == platformUnicode) { - + // Unicode specific encodings switch (encodingId) { case encodingUnicode10Semantics: return "Unicode 1.0 semantics"; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtable.java index 7a4cccba2..04fd646a7 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -21,7 +21,7 @@ public abstract class KernSubtable { /** Creates new KernSubtable */ protected KernSubtable() { } - + public abstract int getKerningPairCount(); public abstract KerningPair getKerningPair(int i); @@ -32,7 +32,7 @@ public abstract class KernSubtable { int length = di.readUnsignedShort(); int coverage = di.readUnsignedShort(); int format = coverage >> 8; - + switch (format) { case 0: table = new KernSubtableFormat0(di); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java index b55bef6d5..89e6f9f11 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -17,7 +17,7 @@ import java.io.IOException; * @version $Id: KernSubtableFormat0.java,v 1.1.1.1 2004-12-05 23:14:48 davidsch Exp $ */ public class KernSubtableFormat0 extends KernSubtable { - + private int nPairs; private int searchRange; private int entrySelector; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java index 60d584ca6..6f5e1f5e8 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java index 70aee70d2..1d526865a 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -17,7 +17,7 @@ import java.io.IOException; * @version $Id: KernTable.java,v 1.1.1.1 2004-12-05 23:14:48 davidsch Exp $ */ public class KernTable implements Table { - + private DirectoryEntry de; private int version; private int nTables; @@ -37,7 +37,7 @@ public class KernTable implements Table { public int getSubtableCount() { return nTables; } - + public KernSubtable getSubtable(int i) { return tables[i]; } @@ -58,5 +58,5 @@ public class KernTable implements Table { public DirectoryEntry getDirectoryEntry() { return de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KerningPair.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KerningPair.java index ce7cebc97..52f82cc85 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KerningPair.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KerningPair.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LangSys.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LangSys.java index 6759208f5..1ab112a78 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LangSys.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LangSys.java @@ -64,7 +64,7 @@ public class LangSys { private int _reqFeatureIndex; private int _featureCount; private int[] _featureIndex; - + /** Creates new LangSys */ protected LangSys(DataInput di) throws IOException { _lookupOrder = di.readUnsignedShort(); @@ -75,19 +75,19 @@ public class LangSys { _featureIndex[i] = di.readUnsignedShort(); } } - + public int getLookupOrder() { return _lookupOrder; } - + public int getReqFeatureIndex() { return _reqFeatureIndex; } - + public int getFeatureCount() { return _featureCount; } - + public int getFeatureIndex(int i) { return _featureIndex[i]; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LangSysRecord.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LangSysRecord.java index 9511f66ba..f3befe3b6 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LangSysRecord.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LangSysRecord.java @@ -62,7 +62,7 @@ public class LangSysRecord { private int _tag; private int _offset; - + /** Creates new LangSysRecord */ public LangSysRecord(DataInput di) throws IOException { _tag = di.readInt(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Ligature.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Ligature.java index d3e2ad5cd..de862a983 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Ligature.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Ligature.java @@ -73,11 +73,11 @@ public class Ligature { _components[i] = di.readUnsignedShort(); } } - + public int getGlyphCount() { return _compCount; } - + public int getGlyphId(int i) { return (i == 0) ? _ligGlyph : _components[i-1]; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LigatureSubstFormat1.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LigatureSubstFormat1.java index a0f42662c..cad5e106a 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LigatureSubstFormat1.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LigatureSubstFormat1.java @@ -91,5 +91,5 @@ public class LigatureSubstFormat1 extends LigatureSubst { public String getTypeAsString() { return "LigatureSubstFormat1"; - } + } } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LocaTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LocaTable.java index 5eb7c5856..ce0862eea 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LocaTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LocaTable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -64,7 +64,7 @@ public class LocaTable implements Table { } return sb.toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Lookup.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Lookup.java index 2899c24d9..6496c3791 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Lookup.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Lookup.java @@ -79,7 +79,7 @@ public class Lookup { // Ensure we're in the right place dis.reset(); dis.skipBytes(offset); - + // Start reading _type = dis.readUnsignedShort(); _flag = dis.readUnsignedShort(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LookupList.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LookupList.java index a3b71b639..e70a932e4 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LookupList.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LookupList.java @@ -67,11 +67,11 @@ public class LookupList { /** Creates new LookupList */ public LookupList(DataInputStream dis, int offset, LookupSubtableFactory factory) throws IOException { - + // Ensure we're in the right place dis.reset(); dis.skipBytes(offset); - + // Start reading _lookupCount = dis.readUnsignedShort(); _lookupOffsets = new int[_lookupCount]; @@ -87,11 +87,11 @@ public class LookupList { public int getLookupCount() { return _lookupCount; } - + public int getLookupOffset(int i) { return _lookupOffsets[i]; } - + public Lookup getLookup(int i) { return _lookups[i]; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LookupSubtableFactory.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LookupSubtableFactory.java index cb4d28d2c..ca67df7fb 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LookupSubtableFactory.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LookupSubtableFactory.java @@ -47,13 +47,13 @@ Apache Software Foundation, please see . */ - + package jogamp.graph.font.typecast.ot.table; import java.io.DataInputStream; import java.io.IOException; -/** +/** * * @author David Schweinsberg * @version $Id: LookupSubtableFactory.java,v 1.2 2007-01-24 09:47:46 davidsch Exp $ diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LtshTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LtshTable.java index ace3d38b5..9b0c8e6b4 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LtshTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LtshTable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -22,7 +22,7 @@ public class LtshTable implements Table { private int version; private int numGlyphs; private int[] yPels; - + /** Creates new LtshTable */ protected LtshTable(DirectoryEntry de, DataInput di) throws IOException { this.de = (DirectoryEntry) de.clone(); @@ -41,7 +41,7 @@ public class LtshTable implements Table { public int getType() { return LTSH; } - + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'LTSH' Table - Linear Threshold Table\n-------------------------------------") @@ -54,7 +54,7 @@ public class LtshTable implements Table { } return sb.toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -64,5 +64,5 @@ public class LtshTable implements Table { public DirectoryEntry getDirectoryEntry() { return de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/MaxpTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/MaxpTable.java index 0e8ec44c7..5ab6b51ca 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/MaxpTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/MaxpTable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -39,7 +39,7 @@ public class MaxpTable implements Table { protected MaxpTable(DirectoryEntry de, DataInput di) throws IOException { this.de = (DirectoryEntry) de.clone(); versionNumber = di.readInt(); - + // CFF fonts use version 0.5, TrueType fonts use version 1.0 if (versionNumber == 0x00005000) { numGlyphs = di.readUnsignedShort(); @@ -149,7 +149,7 @@ public class MaxpTable implements Table { } return sb.toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -159,5 +159,5 @@ public class MaxpTable implements Table { public DirectoryEntry getDirectoryEntry() { return de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java index 268d6cfca..9f9822986 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java @@ -75,19 +75,19 @@ public class NameRecord { _stringLength = di.readShort(); _stringOffset = di.readShort(); } - + public short getEncodingId() { return _encodingId; } - + public short getLanguageId() { return _languageId; } - + public short getNameId() { return _nameId; } - + public short getPlatformId() { return _platformId; } @@ -101,7 +101,7 @@ public class NameRecord { StringBuilder sb = new StringBuilder(); di.skipBytes(_stringOffset); if (_platformId == ID.platformUnicode) { - + // Unicode (big-endian) for (int i = 0; i < _stringLength/2; i++) { sb.append(di.readChar()); @@ -113,13 +113,13 @@ public class NameRecord { sb.append((char) di.readByte()); } } else if (_platformId == ID.platformISO) { - + // ISO encoding, ASCII for (int i = 0; i < _stringLength; i++) { sb.append((char) di.readByte()); } } else if (_platformId == ID.platformMicrosoft) { - + // Microsoft encoding, Unicode char c; for (int i = 0; i < _stringLength/2; i++) { @@ -132,7 +132,7 @@ public class NameRecord { public String toString() { StringBuilder sb = new StringBuilder(); - + sb.append(" Platform ID: ").append(_platformId) .append("\n Specific ID: ").append(_encodingId) .append("\n Language ID: ").append(_languageId) @@ -140,7 +140,7 @@ public class NameRecord { .append("\n Length: ").append(_stringLength) .append("\n Offset: ").append(_stringOffset) .append("\n\n").append(_record); - + return sb.toString(); } } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java index 6daf2ad60..5b7a17d3b 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java @@ -68,25 +68,25 @@ public class NameTable implements Table { private short _numberOfNameRecords; private short _stringStorageOffset; private NameRecord[] _records; - + protected NameTable(DirectoryEntry de, DataInput di) throws IOException { _de = (DirectoryEntry) de.clone(); _formatSelector = di.readShort(); _numberOfNameRecords = di.readShort(); _stringStorageOffset = di.readShort(); _records = new NameRecord[_numberOfNameRecords]; - + // Load the records, which contain the encoding information and string // offsets for (int i = 0; i < _numberOfNameRecords; i++) { _records[i] = new NameRecord(di); } - + // Load the string data into a buffer so the records can copy out the // bits they are interested in byte[] buffer = new byte[_de.getLength() - _stringStorageOffset]; di.readFully(buffer); - + // Now let the records get their hands on them for (int i = 0; i < _numberOfNameRecords; i++) { _records[i].loadString( @@ -98,7 +98,7 @@ public class NameTable implements Table { return _numberOfNameRecords; } - + public NameRecord getRecord(int i) { if(_numberOfNameRecords > i) { return _records[i]; @@ -133,7 +133,7 @@ public class NameTable implements Table { public int getType() { return name; } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -143,5 +143,5 @@ public class NameTable implements Table { public DirectoryEntry getDirectoryEntry() { return _de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Os2Table.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Os2Table.java index f4fa76e81..9dfbceb99 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Os2Table.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Os2Table.java @@ -134,7 +134,7 @@ public class Os2Table implements Table { _usWinDescent = di.readUnsignedShort(); _ulCodePageRange1 = di.readInt(); _ulCodePageRange2 = di.readInt(); - + // OpenType 1.3 if (_version == 2) { _sxHeight = di.readShort(); @@ -276,19 +276,19 @@ public class Os2Table implements Table { public short getXHeight() { return _sxHeight; } - + public short getCapHeight() { return _sCapHeight; } - + public int getDefaultChar() { return _usDefaultChar; } - + public int getBreakChar() { return _usBreakChar; } - + public int getMaxContext() { return _usMaxContext; } @@ -335,7 +335,7 @@ public class Os2Table implements Table { .append("\n CodePage Range 2( Bits 32- 63 ): ").append(Integer.toHexString(_ulCodePageRange2).toUpperCase()) .toString(); } - + private String getVendorIDAsString() { return new StringBuilder() .append((char)((_achVendorID>>24)&0xff)) @@ -344,7 +344,7 @@ public class Os2Table implements Table { .append((char)((_achVendorID)&0xff)) .toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Panose.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Panose.java index 6127140d1..1f6c5a1dd 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Panose.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Panose.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -42,11 +42,11 @@ public class Panose { public byte getFamilyType() { return bFamilyType; } - + public byte getSerifStyle() { return bSerifStyle; } - + public byte getWeight() { return bWeight; } @@ -54,31 +54,31 @@ public class Panose { public byte getProportion() { return bProportion; } - + public byte getContrast() { return bContrast; } - + public byte getStrokeVariation() { return bStrokeVariation; } - + public byte getArmStyle() { return bArmStyle; } - + public byte getLetterForm() { return bLetterform; } - + public byte getMidline() { return bMidline; } - + public byte getXHeight() { return bXHeight; } - + public String toString() { StringBuilder sb = new StringBuilder(); sb.append(String.valueOf(bFamilyType)).append(" ") diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PcltTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PcltTable.java index f9dcf2ce7..6ed9b2b9c 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PcltTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PcltTable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -68,7 +68,7 @@ public class PcltTable implements Table { public int getType() { return PCLT; } - + public String toString() { return new StringBuilder() .append("'PCLT' Table - Printer Command Language Table\n---------------------------------------------") @@ -91,7 +91,7 @@ public class PcltTable implements Table { .append("\n reserved: ").append(reserved) .toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -101,5 +101,5 @@ public class PcltTable implements Table { public DirectoryEntry getDirectoryEntry() { return de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PostTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PostTable.java index c913b4c71..46f1ac088 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PostTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PostTable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -294,7 +294,7 @@ public class PostTable implements Table { private int maxMemType42; private int minMemType1; private int maxMemType1; - + // v2 private int numGlyphs; private int[] glyphNameIndex; @@ -312,7 +312,7 @@ public class PostTable implements Table { maxMemType42 = di.readInt(); minMemType1 = di.readInt(); maxMemType1 = di.readInt(); - + if (version == 0x00020000) { numGlyphs = di.readUnsignedShort(); glyphNameIndex = new int[numGlyphs]; @@ -366,7 +366,7 @@ public class PostTable implements Table { return false; } } - + /** Get the table type, as a table directory value. * @return The table type */ @@ -409,7 +409,7 @@ public class PostTable implements Table { } return sb.toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -419,5 +419,5 @@ public class PostTable implements Table { public DirectoryEntry getDirectoryEntry() { return de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PrepTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PrepTable.java index aac10c539..2046d7fe4 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PrepTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PrepTable.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -33,7 +33,7 @@ public class PrepTable extends Program implements Table { public String toString() { return Disassembler.disassemble(getInstructions(), 0); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a @@ -43,5 +43,5 @@ public class PrepTable extends Program implements Table { public DirectoryEntry getDirectoryEntry() { return de; } - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Program.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Program.java index 28c148c2b..e3beabef8 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Program.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Program.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/RangeRecord.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/RangeRecord.java index 72d703bb4..40ddf4215 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/RangeRecord.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/RangeRecord.java @@ -75,7 +75,7 @@ public class RangeRecord { public boolean isInRange(int glyphId) { return (_start <= glyphId && glyphId <= _end); } - + public int getCoverageIndex(int glyphId) { if (isInRange(glyphId)) { return _startCoverageIndex + glyphId - _start; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Script.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Script.java index eb534b5dd..04781a8f9 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Script.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Script.java @@ -65,14 +65,14 @@ public class Script { private LangSysRecord[] _langSysRecords; private LangSys _defaultLangSys; private LangSys[] _langSys; - + /** Creates new ScriptTable */ protected Script(DataInputStream dis, int offset) throws IOException { // Ensure we're in the right place dis.reset(); dis.skipBytes(offset); - + // Start reading _defaultLangSysOffset = dis.readUnsignedShort(); _langSysCount = dis.readUnsignedShort(); @@ -102,7 +102,7 @@ public class Script { public int getLangSysCount() { return _langSysCount; } - + public LangSysRecord getLangSysRecord(int i) { return _langSysRecords[i]; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ScriptList.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ScriptList.java index 4af62b0ee..18589b712 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ScriptList.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ScriptList.java @@ -63,14 +63,14 @@ public class ScriptList { private int _scriptCount = 0; private ScriptRecord[] _scriptRecords; private Script[] _scripts; - + /** Creates new ScriptList */ protected ScriptList(DataInputStream dis, int offset) throws IOException { - + // Ensure we're in the right place dis.reset(); dis.skipBytes(offset); - + // Start reading _scriptCount = dis.readUnsignedShort(); _scriptRecords = new ScriptRecord[_scriptCount]; @@ -86,15 +86,15 @@ public class ScriptList { public int getScriptCount() { return _scriptCount; } - + public ScriptRecord getScriptRecord(int i) { return _scriptRecords[i]; } - + public Script getScript(int i) { return _scripts[i]; } - + public Script findScript(String tag) { if (tag.length() != 4) { return null; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ScriptRecord.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ScriptRecord.java index 5da0608dd..183ca2ffd 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ScriptRecord.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ScriptRecord.java @@ -62,7 +62,7 @@ public class ScriptRecord { private int _tag; private int _offset; - + /** Creates new ScriptRecord */ protected ScriptRecord(DataInput di) throws IOException { _tag = di.readInt(); @@ -72,7 +72,7 @@ public class ScriptRecord { public int getTag() { return _tag; } - + public int getOffset() { return _offset; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SignatureBlock.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SignatureBlock.java index 5a5de119f..15f0cd04f 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SignatureBlock.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SignatureBlock.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -22,7 +22,7 @@ public class SignatureBlock { private int reserved2; private int signatureLen; private byte[] signature; - + /** Creates new SignatureBlock */ protected SignatureBlock(DataInput di) throws IOException { reserved1 = di.readUnsignedShort(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubst.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubst.java index 8c56a740f..e31281f2e 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubst.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubst.java @@ -63,7 +63,7 @@ public abstract class SingleSubst extends LookupSubtable { public abstract int getFormat(); public abstract int substitute(int glyphId); - + public static SingleSubst read(DataInputStream dis, int offset) throws IOException { SingleSubst s = null; dis.reset(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat1.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat1.java index 99b85f35c..a8df78504 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat1.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat1.java @@ -84,7 +84,7 @@ public class SingleSubstFormat1 extends SingleSubst { } return glyphId; } - + public String getTypeAsString() { return "SingleSubstFormat1"; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat2.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat2.java index cd3b6d147..2e47b2924 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat2.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat2.java @@ -92,6 +92,6 @@ public class SingleSubstFormat2 extends SingleSubst { public String getTypeAsString() { return "SingleSubstFormat2"; - } + } } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TTCHeader.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TTCHeader.java index b801517f8..f7c7d99b5 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TTCHeader.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TTCHeader.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -17,7 +17,7 @@ import java.io.IOException; * @author David Schweinsberg */ public class TTCHeader { - + public static final int ttcf = 0x74746366; private int ttcTag; @@ -47,7 +47,7 @@ public class TTCHeader { public int getDirectoryCount() { return directoryCount; } - + public int getTableDirectory(int i) { return tableDirectory[i]; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Table.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Table.java index 624f47bef..30fd2f457 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Table.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Table.java @@ -1,9 +1,9 @@ /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * *****************************************************************************/ package jogamp.graph.font.typecast.ot.table; @@ -51,7 +51,7 @@ public interface Table { public static final int vmtx = 0x766d7478; // Vertical Metrics public static final String notAvailable = "n/a"; - + /** * Get the table type, as a table directory value. * @return The table type @@ -65,5 +65,5 @@ public interface Table { * @return A directory entry */ public DirectoryEntry getDirectoryEntry(); - + } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableDirectory.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableDirectory.java index bacc26d30..8c5678088 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableDirectory.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableDirectory.java @@ -112,7 +112,7 @@ public class TableDirectory { public int getVersion() { return _version; } - + public String toString() { StringBuilder sb = new StringBuilder() .append("Offset Table\n------ -----") diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableException.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableException.java index 7749ea856..65aa84bff 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableException.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableException.java @@ -26,7 +26,7 @@ package jogamp.graph.font.typecast.ot.table; * @version $Id: TableException.java,v 1.1.1.1 2004-12-05 23:15:00 davidsch Exp $ */ public class TableException extends java.lang.Exception { - + private static final long serialVersionUID = 1L; /** @@ -34,8 +34,8 @@ public class TableException extends java.lang.Exception { */ public TableException() { } - - + + /** * Constructs an instance of TableException with the specified detail message. * @param msg the detail message. diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableFactory.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableFactory.java index 998ce08e3..956d1aecd 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableFactory.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableFactory.java @@ -47,7 +47,7 @@ Apache Software Foundation, please see . */ - + package jogamp.graph.font.typecast.ot.table; import java.io.DataInputStream; @@ -56,7 +56,7 @@ import java.io.IOException; import jogamp.graph.font.typecast.ot.OTFont; import jogamp.graph.font.typecast.ot.OTFontCollection; -/** +/** * * @version $Id: TableFactory.java,v 1.7 2007-02-05 12:39:51 davidsch Exp $ * @author David Schweinsberg @@ -69,7 +69,7 @@ public class TableFactory { DirectoryEntry de, DataInputStream dis) throws IOException { Table t = null; - + // First, if we have a font collection, look for the table there if (fc != null) { t = fc.getTable(de); @@ -77,7 +77,7 @@ public class TableFactory { return t; } } - + // Create the table switch (de.getTag()) { case Table.BASE: @@ -175,7 +175,7 @@ public class TableFactory { t = new VmtxTable(de, dis, font.getVheaTable(), font.getMaxpTable()); break; } - + // If we have a font collection, add this table to it if ((fc != null) && (t != null)) { fc.addTable(t); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VdmxTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VdmxTable.java index 80579f5cd..28f9aa6e3 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VdmxTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VdmxTable.java @@ -31,12 +31,12 @@ import java.io.IOException; public class VdmxTable implements Table { private class Ratio { - + private byte _bCharSet; private byte _xRatio; private byte _yStartRatio; private byte _yEndRatio; - + protected Ratio(DataInput di) throws IOException { _bCharSet = di.readByte(); _xRatio = di.readByte(); @@ -47,26 +47,26 @@ public class VdmxTable implements Table { public byte getBCharSet() { return _bCharSet; } - + public byte getXRatio() { return _xRatio; } - + public byte getYStartRatio() { return _yStartRatio; } - + public byte getYEndRatio() { return _yEndRatio; } } - + private class VTableRecord { - + private int _yPelHeight; private short _yMax; private short _yMin; - + protected VTableRecord(DataInput di) throws IOException { _yPelHeight = di.readUnsignedShort(); _yMax = di.readShort(); @@ -76,23 +76,23 @@ public class VdmxTable implements Table { public int getYPelHeight() { return _yPelHeight; } - + public short getYMax() { return _yMax; } - + public short getYMin() { return _yMin; } } - + private class Group { - + private int _recs; private int _startsz; private int _endsz; private VTableRecord[] _entry; - + protected Group(DataInput di) throws IOException { _recs = di.readUnsignedShort(); _startsz = di.readUnsignedByte(); @@ -106,20 +106,20 @@ public class VdmxTable implements Table { public int getRecs() { return _recs; } - + public int getStartSZ() { return _startsz; } - + public int getEndSZ() { return _endsz; } - + public VTableRecord[] getEntry() { return _entry; } } - + private DirectoryEntry _de; private int _version; private int _numRecs; @@ -127,7 +127,7 @@ public class VdmxTable implements Table { private Ratio[] _ratRange; private int _offset[]; private Group[] _groups; - + /** Creates a new instance of VdmxTable */ protected VdmxTable(DirectoryEntry de, DataInput di) throws IOException { _de = (DirectoryEntry) de.clone(); @@ -147,11 +147,11 @@ public class VdmxTable implements Table { _groups[i] = new Group(di); } } - + public int getType() { return VDMX; } - + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'VDMX' Table - Precomputed Vertical Device Metrics\n") diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VheaTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VheaTable.java index 19c91765b..f42da119b 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VheaTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VheaTable.java @@ -135,7 +135,7 @@ public class VheaTable implements Table { .append("\n numOf_LongVerMetrics: ").append(_numberOfLongVerMetrics) .toString(); } - + /** * Get a directory entry for this table. This uniquely identifies the * table in collections where there may be more than one instance of a diff --git a/src/jogl/classes/jogamp/graph/font/typecast/t2/T2Interpreter.java b/src/jogl/classes/jogamp/graph/font/typecast/t2/T2Interpreter.java index 887f8c34f..181ec7e10 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/t2/T2Interpreter.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/t2/T2Interpreter.java @@ -34,23 +34,23 @@ import jogamp.graph.font.typecast.ot.table.CharstringType2; * @version $Id: T2Interpreter.java,v 1.2 2007-07-26 11:10:18 davidsch Exp $ */ public class T2Interpreter { - + private static final int ARGUMENT_STACK_LIMIT = 48; private static final int SUBR_STACK_LIMIT = 10; private static final int TRANSIENT_ARRAY_ELEMENT_COUNT = 32; - + private Number[] _argStack = new Number[ARGUMENT_STACK_LIMIT]; private int _argStackIndex = 0; private int[] _subrStack = new int[SUBR_STACK_LIMIT]; private int _subrStackIndex = 0; private Number[] _transientArray = new Number[TRANSIENT_ARRAY_ELEMENT_COUNT]; - + private ArrayList _points; /** Creates a new instance of T2Interpreter */ public T2Interpreter() { } - + /** * Moves the current point to a position at the relative coordinates * (dx1, dy1). @@ -72,7 +72,7 @@ public class T2Interpreter { Point lastPoint = getLastPoint(); moveTo(lastPoint.x + dx1, lastPoint.y); } - + /** * Moves the current point dy1 units in the vertical direction. */ @@ -82,7 +82,7 @@ public class T2Interpreter { Point lastPoint = getLastPoint(); moveTo(lastPoint.x, lastPoint.y + dy1); } - + /** * Appends a line from the current point to a position at the * relative coordinates dxa, dya. Additional rlineto operations are @@ -103,7 +103,7 @@ public class T2Interpreter { } clearArg(); } - + /** * Appends a horizontal line of length dx1 to the current point. * With an odd number of arguments, subsequent argument pairs @@ -130,7 +130,7 @@ public class T2Interpreter { } clearArg(); } - + /** * Appends a vertical line of length dy1 to the current point. With * an odd number of arguments, subsequent argument pairs are @@ -157,7 +157,7 @@ public class T2Interpreter { } clearArg(); } - + /** * Appends a Bezier curve, defined by dxa...dyc, to the current * point. For each subsequent set of six arguments, an additional @@ -194,7 +194,7 @@ public class T2Interpreter { } clearArg(); } - + /** * Appends one or more Bezier curves, as described by the * dxa...dxc set of arguments, to the current point. For each curve, @@ -230,7 +230,7 @@ public class T2Interpreter { } clearArg(); } - + /** * Appends one or more Bezier curves to the current point. The * tangent for the first Bezier must be horizontal, and the second @@ -327,13 +327,13 @@ public class T2Interpreter { int yf = ye + dyf[i]; curveTo(xa, ya, xb, yb, xc, yc); curveTo(xd, yd, xe, ye, xf, yf); - + // What on earth do we do with dx1, dx2, dy2 and dy3? } } clearArg(); } - + /** * Is equivalent to one rrcurveto for each set of six arguments * dxa...dyc, followed by exactly one rlineto using the dxd, dyd @@ -373,7 +373,7 @@ public class T2Interpreter { lineTo(xc + dxd, yc + dyd); clearArg(); } - + /** * Is equivalent to one rlineto for each pair of arguments beyond * the six arguments dxb...dyd needed for the one rrcurveto @@ -411,7 +411,7 @@ public class T2Interpreter { curveTo(xb, yb, xc, yc, xd, yd); clearArg(); } - + /** * Appends one or more Bezier curves to the current point, where * the first tangent is vertical and the second tangent is horizontal. @@ -465,7 +465,7 @@ public class T2Interpreter { } clearArg(); } - + /** * Appends one or more curves to the current point. If the argument * count is a multiple of four, the curve starts and ends vertical. If @@ -473,10 +473,10 @@ public class T2Interpreter { * vertical tangent. */ private void _vvcurveto() { - + clearArg(); } - + /** * Causes two Bezier curves, as described by the arguments (as * shown in Figure 2 below), to be rendered as a straight line when @@ -485,10 +485,10 @@ public class T2Interpreter { * pixels. */ private void _flex() { - + clearArg(); } - + /** * Causes the two curves described by the arguments dx1...dx6 to * be rendered as a straight line when the flex depth is less than @@ -496,10 +496,10 @@ public class T2Interpreter { * flex depth is greater than or equal to 0.5 device pixels. */ private void _hflex() { - + clearArg(); } - + /** * Causes the two curves described by the arguments to be * rendered as a straight line when the flex depth is less than 0.5 @@ -507,10 +507,10 @@ public class T2Interpreter { * than or equal to 0.5 device pixels. */ private void _hflex1() { - + clearArg(); } - + /** * Causes the two curves described by the arguments to be * rendered as a straight line when the flex depth is less than 0.5 @@ -518,10 +518,10 @@ public class T2Interpreter { * than or equal to 0.5 device pixels. */ private void _flex1() { - + clearArg(); } - + /** * Finishes a charstring outline definition, and must be the * last operator in a character's outline. @@ -530,37 +530,37 @@ public class T2Interpreter { endContour(); clearArg(); } - + private void _hstem() { - + clearArg(); } - + private void _vstem() { - + clearArg(); } - + private void _hstemhm() { - + clearArg(); } - + private void _vstemhm() { - + clearArg(); } - + private void _hintmask() { - + clearArg(); } - + private void _cntrmask() { - + clearArg(); } - + /** * Returns the absolute value of num. */ @@ -568,7 +568,7 @@ public class T2Interpreter { double num = popArg().doubleValue(); pushArg(Math.abs(num)); } - + /** * Returns the sum of the two numbers num1 and num2. */ @@ -577,7 +577,7 @@ public class T2Interpreter { double num1 = popArg().doubleValue(); pushArg(num1 + num2); } - + /** * Returns the result of subtracting num2 from num1. */ @@ -586,7 +586,7 @@ public class T2Interpreter { double num1 = popArg().doubleValue(); pushArg(num1 - num2); } - + /** * Returns the quotient of num1 divided by num2. The result is * undefined if overflow occurs and is zero for underflow. @@ -596,7 +596,7 @@ public class T2Interpreter { double num1 = popArg().doubleValue(); pushArg(num1 / num2); } - + /** * Returns the negative of num. */ @@ -604,7 +604,7 @@ public class T2Interpreter { double num = popArg().doubleValue(); pushArg(-num); } - + /** * Returns a pseudo random number num2 in the range (0,1], that * is, greater than zero and less than or equal to one. @@ -612,7 +612,7 @@ public class T2Interpreter { private void _random() { pushArg(1.0 - Math.random()); } - + /** * Returns the product of num1 and num2. If overflow occurs, the * result is undefined, and zero is returned for underflow. @@ -622,7 +622,7 @@ public class T2Interpreter { double num1 = popArg().doubleValue(); pushArg(num1 * num2); } - + /** * Returns the square root of num. If num is negative, the result is * undefined. @@ -631,14 +631,14 @@ public class T2Interpreter { double num = popArg().doubleValue(); pushArg(Math.sqrt(num)); } - + /** * Removes the top element num from the Type 2 argument stack. */ private void _drop() { popArg(); } - + /** * Exchanges the top two elements on the argument stack. */ @@ -648,7 +648,7 @@ public class T2Interpreter { pushArg(num2); pushArg(num1); } - + /** * Retrieves the element i from the top of the argument stack and * pushes a copy of that element onto that stack. If i is negative, @@ -666,7 +666,7 @@ public class T2Interpreter { } pushArg(nums[i]); } - + /** * Performs a circular shift of the elements num(Nx1) ... num0 on * the argument stack by the amount J. Positive J indicates upward @@ -685,7 +685,7 @@ public class T2Interpreter { pushArg(nums[(n + i + j) % n]); } } - + /** * Duplicates the top element on the argument stack. */ @@ -694,7 +694,7 @@ public class T2Interpreter { pushArg(any); pushArg(any); } - + /** * Stores val into the transient array at the location given by i. */ @@ -703,7 +703,7 @@ public class T2Interpreter { Number val = popArg(); _transientArray[i] = val; } - + /** * Retrieves the value stored in the transient array at the location * given by i and pushes the value onto the argument stack. If get @@ -714,7 +714,7 @@ public class T2Interpreter { int i = popArg().intValue(); pushArg(_transientArray[i]); } - + /** * Puts a 1 on the stack if num1 and num2 are both non-zero, and * puts a 0 on the stack if either argument is zero. @@ -724,7 +724,7 @@ public class T2Interpreter { double num1 = popArg().doubleValue(); pushArg((num1!=0.0) && (num2!=0.0) ? 1 : 0); } - + /** * Puts a 1 on the stack if either num1 or num2 are non-zero, and * puts a 0 on the stack if both arguments are zero. @@ -734,7 +734,7 @@ public class T2Interpreter { double num1 = popArg().doubleValue(); pushArg((num1!=0.0) || (num2!=0.0) ? 1 : 0); } - + /** * Returns a 0 if num1 is non-zero; returns a 1 if num1 is zero. */ @@ -742,7 +742,7 @@ public class T2Interpreter { double num1 = popArg().doubleValue(); pushArg((num1!=0.0) ? 0 : 1); } - + /** * Puts a 1 on the stack if num1 equals num2, otherwise a 0 (zero) * is put on the stack. @@ -752,7 +752,7 @@ public class T2Interpreter { double num1 = popArg().doubleValue(); pushArg(num1 == num2 ? 1 : 0); } - + /** * Leaves the value s1 on the stack if v1 ? v2, or leaves s2 on the * stack if v1 > v2. The value of s1 and s2 is usually the biased @@ -765,7 +765,7 @@ public class T2Interpreter { Number s1 = popArg(); pushArg(v1 <= v2 ? s1 : s2); } - + /** * Calls a charstring subroutine with index subr# (actually the subr * number plus the subroutine bias number, as described in section @@ -777,25 +777,25 @@ public class T2Interpreter { * Calling an undefined subr (gsubr) has undefined results. */ private void _callsubr() { - + } - + /** * Operates in the same manner as callsubr except that it calls a * global subroutine. */ private void _callgsubr() { - + } - + /** * Returns from either a local or global charstring subroutine, and * continues execution after the corresponding call(g)subr. */ private void _return() { - + } - + public Point[] execute(CharstringType2 cs) { _points = new ArrayList(); cs.resetIP(); @@ -975,7 +975,7 @@ public class T2Interpreter { private int getArgCount() { return _argStackIndex; } - + /** * Pop a value off the argument stack */ @@ -989,7 +989,7 @@ public class T2Interpreter { private void pushArg(Number n) { _argStack[_argStackIndex++] = n; } - + /** * Pop a value off the subroutine stack */ @@ -1003,14 +1003,14 @@ public class T2Interpreter { private void pushSubr(int n) { _subrStack[_subrStackIndex++] = n; } - + /** * Clear the argument stack */ private void clearArg() { _argStackIndex = 0; } - + private Point getLastPoint() { int size = _points.size(); if (size > 0) { @@ -1019,22 +1019,22 @@ public class T2Interpreter { return new Point(0, 0, true, false); } } - + private void moveTo(int x, int y) { endContour(); _points.add(new Point(x, y, true, false)); } - + private void lineTo(int x, int y) { _points.add(new Point(x, y, true, false)); } - + private void curveTo(int cx1, int cy1, int cx2, int cy2, int x, int y) { _points.add(new Point(cx1, cy1, false, false)); _points.add(new Point(cx2, cy2, false, false)); _points.add(new Point(x, y, true, false)); } - + private void endContour() { Point lastPoint = getLastPoint(); if (lastPoint != null) { diff --git a/src/jogl/classes/jogamp/graph/font/typecast/tt/engine/Interpreter.java b/src/jogl/classes/jogamp/graph/font/typecast/tt/engine/Interpreter.java index a659a7003..2bb5cec0c 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/tt/engine/Interpreter.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/tt/engine/Interpreter.java @@ -570,7 +570,7 @@ public class Interpreter { private void _mps() { push(0); } - + private void _msirp(short param) { pop(); pop(); @@ -1190,7 +1190,7 @@ public class Interpreter { while (ip < ((ip & 0xffff0000) | parser.getISLength(ip >> 16))) { short opcode = parser.getOpcode(ip); if (inFuncDef) { - + // We're within a function definition, so don't execute the code if (opcode == Mnemonic.ENDF) { inFuncDef = false; diff --git a/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java b/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java index 0fd174cda..32e2b6a39 100644 --- a/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java +++ b/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java @@ -33,7 +33,7 @@ public class AffineTransform implements Cloneable, Serializable { private static final long serialVersionUID = 1330973210523860834L; static final String determinantIsZero = "Determinant is zero"; - + public static final int TYPE_IDENTITY = 0; public static final int TYPE_TRANSLATION = 1; public static final int TYPE_UNIFORM_SCALE = 2; @@ -49,14 +49,14 @@ public class AffineTransform implements Cloneable, Serializable { * The TYPE_UNKNOWN is an initial type value */ static final int TYPE_UNKNOWN = -1; - + /** - * The min value equivalent to zero. If absolute value less then ZERO it considered as zero. + * The min value equivalent to zero. If absolute value less then ZERO it considered as zero. */ static final float ZERO = (float) 1E-10; - + private final Vertex.Factory pointFactory; - + /** * The values of transformation matrix */ @@ -68,7 +68,7 @@ public class AffineTransform implements Cloneable, Serializable { float m12; /** - * The transformation type + * The transformation type */ transient int type; @@ -123,20 +123,20 @@ public class AffineTransform implements Cloneable, Serializable { /* * Method returns type of affine transformation. - * + * * Transform matrix is * m00 m01 m02 * m10 m11 m12 - * - * According analytic geometry new basis vectors are (m00, m01) and (m10, m11), - * translation vector is (m02, m12). Original basis vectors are (1, 0) and (0, 1). - * Type transformations classification: + * + * According analytic geometry new basis vectors are (m00, m01) and (m10, m11), + * translation vector is (m02, m12). Original basis vectors are (1, 0) and (0, 1). + * Type transformations classification: * TYPE_IDENTITY - new basis equals original one and zero translation - * TYPE_TRANSLATION - translation vector isn't zero + * TYPE_TRANSLATION - translation vector isn't zero * TYPE_UNIFORM_SCALE - vectors length of new basis equals - * TYPE_GENERAL_SCALE - vectors length of new basis doesn't equal + * TYPE_GENERAL_SCALE - vectors length of new basis doesn't equal * TYPE_FLIP - new basis vector orientation differ from original one - * TYPE_QUADRANT_ROTATION - new basis is rotated by 90, 180, 270, or 360 degrees + * TYPE_QUADRANT_ROTATION - new basis is rotated by 90, 180, 270, or 360 degrees * TYPE_GENERAL_ROTATION - new basis is rotated by arbitrary angle * TYPE_GENERAL_TRANSFORM - transformation can't be inversed */ @@ -322,7 +322,7 @@ public class AffineTransform implements Cloneable, Serializable { } public static AffineTransform getShearInstance(Vertex.Factory factory, float shx, float shy) { - AffineTransform t = new AffineTransform(factory); + AffineTransform t = new AffineTransform(factory); t.setToShear(shx, shy); return t; } @@ -359,13 +359,13 @@ public class AffineTransform implements Cloneable, Serializable { concatenate(AffineTransform.getRotateInstance(pointFactory, angle, px, py)); } - /** + /** * Multiply matrix of two AffineTransform objects. * The first argument's {@link Vertex.Factory} is being used. - * + * * @param t1 - the AffineTransform object is a multiplicand * @param t2 - the AffineTransform object is a multiplier - * @return an AffineTransform object that is a result of t1 multiplied by matrix t2. + * @return an AffineTransform object that is a result of t1 multiplied by matrix t2. */ AffineTransform multiply(AffineTransform t1, AffineTransform t2) { return new AffineTransform(t1.pointFactory, @@ -415,7 +415,7 @@ public class AffineTransform implements Cloneable, Serializable { public void transform(Vertex[] src, int srcOff, Vertex[] dst, int dstOff, int length) { while (--length >= 0) { - Vertex srcPoint = src[srcOff++]; + Vertex srcPoint = src[srcOff++]; float x = srcPoint.getX(); float y = srcPoint.getY(); Vertex dstPoint = dst[dstOff]; @@ -426,7 +426,7 @@ public class AffineTransform implements Cloneable, Serializable { dst[dstOff++] = dstPoint; } } - + public void transform(float[] src, int srcOff, float[] dst, int dstOff, int length) { int step = 2; if (src == dst && srcOff < dstOff && dstOff < srcOff + length * 2) { @@ -443,7 +443,7 @@ public class AffineTransform implements Cloneable, Serializable { dstOff += step; } } - + public Vertex deltaTransform(Vertex src, Vertex dst) { if (dst == null) { dst = pointFactory.create(); @@ -486,7 +486,7 @@ public class AffineTransform implements Cloneable, Serializable { { float det = getDeterminant(); if (FloatUtil.abs(det) < ZERO) { - throw new NoninvertibleTransformException(determinantIsZero); + throw new NoninvertibleTransformException(determinantIsZero); } while (--length >= 0) { @@ -554,7 +554,7 @@ public class AffineTransform implements Cloneable, Serializable { return false; } - + /** * Write AffineTrasform object to the output steam. * @param stream - the output stream @@ -564,12 +564,12 @@ public class AffineTransform implements Cloneable, Serializable { stream.defaultWriteObject(); } - + /** * Read AffineTransform object from the input stream * @param stream - the input steam * @throws IOException - if there are I/O errors while reading from the input strem - * @throws ClassNotFoundException - if class could not be found + * @throws ClassNotFoundException - if class could not be found */ private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); diff --git a/src/jogl/classes/jogamp/graph/geom/plane/Crossing.java b/src/jogl/classes/jogamp/graph/geom/plane/Crossing.java index cd4ee2a91..4ee0c250d 100644 --- a/src/jogl/classes/jogamp/graph/geom/plane/Crossing.java +++ b/src/jogl/classes/jogamp/graph/geom/plane/Crossing.java @@ -29,17 +29,17 @@ public class Crossing { * Allowable tolerance for bounds comparison */ static final float DELTA = (float) 1E-5; - + /** * If roots have distance less then ROOT_DELTA they are double */ static final float ROOT_DELTA = (float) 1E-10; - + /** * Rectangle cross segment */ public static final int CROSSING = 255; - + /** * Unknown crossing result */ @@ -130,8 +130,8 @@ public class Crossing { } /** - * Excludes float roots. Roots are float if they lies enough close with each other. - * @param res - the roots + * Excludes float roots. Roots are float if they lies enough close with each other. + * @param res - the roots * @param rc - the roots count * @return new roots count */ @@ -384,12 +384,12 @@ public class Crossing { // START if (x == x1) { - return x1 < x2 ? 0 : -1; + return x1 < x2 ? 0 : -1; } - + // END if (x == x2) { - return x1 < x2 ? 1 : 0; + return x1 < x2 ? 1 : 0; } // INSIDE-DOWN @@ -493,10 +493,10 @@ public class Crossing { } break; default: - throw new IllegalArgumentException("Unhandled Segment Type: "+segmentType); + throw new IllegalArgumentException("Unhandled Segment Type: "+segmentType); } - - // checks if the point (x,y) is the vertex of shape with PathIterator p + + // checks if the point (x,y) is the vertex of shape with PathIterator p if (x == cx && y == cy) { cross = 0; cy = my; @@ -554,9 +554,9 @@ public class Crossing { } } } - + /** - * Returns are bounds intersect or not intersect rectangle + * Returns are bounds intersect or not intersect rectangle */ static int crossBound(float bound[], int bc, float py1, float py2) { diff --git a/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java b/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java index 945eeceeb..c1ee17a4b 100644 --- a/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java +++ b/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java @@ -33,12 +33,12 @@ public final class Path2D implements Cloneable { static final String invalidWindingRuleValue = "Invalid winding rule value"; static final String iteratorOutOfBounds = "Iterator out of bounds"; - + /** * The buffers size */ private static final int BUFFER_SIZE = 10; - + /** * The buffers capacity */ @@ -48,24 +48,24 @@ public final class Path2D implements Cloneable { * The point's types buffer */ byte[] types; - + /** * The points buffer */ float[] points; - + /** * The point's type buffer size */ int typeSize; - + /** * The points buffer size */ int pointSize; - + /** - * The path rule + * The path rule */ int rule; @@ -80,7 +80,7 @@ public final class Path2D implements Cloneable { 0}; // CLOSE /* - * GeneralPath path iterator + * GeneralPath path iterator */ class Iterator implements PathIterator { @@ -88,17 +88,17 @@ public final class Path2D implements Cloneable { * The current cursor position in types buffer */ int typeIndex; - + /** * The current cursor position in points buffer */ int pointIndex; - + /** * The source GeneralPath object */ Path2D p; - + /** * The path iterator transformation */ @@ -183,7 +183,7 @@ public final class Path2D implements Cloneable { } /** - * Checks points and types buffer size to add pointCount points. If necessary realloc buffers to enlarge size. + * Checks points and types buffer size to add pointCount points. If necessary realloc buffers to enlarge size. * @param pointCount - the point count to be added in buffer */ void checkBuf(int pointCount, boolean checkMove) { @@ -244,18 +244,18 @@ public final class Path2D implements Cloneable { final public int size() { return typeSize; } - + final public boolean isClosed() { return typeSize > 0 && types[typeSize - 1] == PathIterator.SEG_CLOSE ; } - + public void closePath() { if (!isClosed()) { checkBuf(0, true); types[typeSize++] = PathIterator.SEG_CLOSE; } } - + public String toString() { return "[size "+size()+", closed "+isClosed()+"]"; } @@ -295,7 +295,7 @@ public final class Path2D implements Cloneable { closePath(); break; default: - throw new IllegalArgumentException("Unhandled Segment Type: "+segmentType); + throw new IllegalArgumentException("Unhandled Segment Type: "+segmentType); } path.next(); connect = false; @@ -366,9 +366,9 @@ public final class Path2D implements Cloneable { } /** - * Checks cross count according to path rule to define is it point inside shape or not. + * Checks cross count according to path rule to define is it point inside shape or not. * @param cross - the point cross count - * @return true if point is inside path, or false otherwise + * @return true if point is inside path, or false otherwise */ boolean isInside(int cross) { if (rule == WIND_NON_ZERO) { @@ -396,7 +396,7 @@ public final class Path2D implements Cloneable { } public boolean contains(AABBox r) { - return contains(r.getMinX(), r.getMinY(), r.getWidth(), r.getHeight()); + return contains(r.getMinX(), r.getMinY(), r.getWidth(), r.getHeight()); } public boolean intersects(AABBox r) { @@ -404,9 +404,9 @@ public final class Path2D implements Cloneable { } public PathIterator iterator() { - return new Iterator(this); + return new Iterator(this); } - + public PathIterator iterator(AffineTransform t) { return new Iterator(this, t); } diff --git a/src/jogl/classes/jogamp/opengl/Debug.java b/src/jogl/classes/jogamp/opengl/Debug.java index b88a09b71..74892d894 100644 --- a/src/jogl/classes/jogamp/opengl/Debug.java +++ b/src/jogl/classes/jogamp/opengl/Debug.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -51,14 +51,14 @@ public class Debug extends PropertyAccess { // Some common properties private static final boolean verbose; private static final boolean debugAll; - + static { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { PropertyAccess.addTrustedPrefix("jogl."); return null; } } ); - + verbose = isPropertyDefined("jogl.verbose", true); debugAll = isPropertyDefined("jogl.debug", true); if (verbose) { @@ -68,7 +68,7 @@ public class Debug extends PropertyAccess { System.err.println("JOGL implementation vendor " + p.getImplementationVendor()); } } - + /** Ensures static init block has been issues, i.e. if calling through to {@link PropertyAccess#isPropertyDefined(String, boolean)}. */ public static final void initSingleton() {} diff --git a/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLibraryBundleInfo.java index ef9477a31..578f416b7 100644 --- a/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLibraryBundleInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl; import java.util.List; @@ -47,11 +47,11 @@ public abstract class DesktopGLDynamicLibraryBundleInfo extends GLDynamicLibrary public final List getGlueLibNames() { return glueLibNames; } - + @Override public final boolean useToolGetProcAdressFirst(String funcName) { return true; } - + } diff --git a/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java b/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java index 8eb3468ed..a1023acd2 100644 --- a/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java +++ b/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl; import com.jogamp.common.os.NativeLibrary; diff --git a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java index 94acf93b0..b8bcd2e78 100644 --- a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java +++ b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -59,7 +59,7 @@ final class ExtensionAvailabilityCache { } /** - * Flush the cache. + * Flush the cache. */ final void flush() { @@ -87,7 +87,7 @@ final class ExtensionAvailabilityCache { validateInitialization(); return availableExtensionCache.size(); } - + final boolean isExtensionAvailable(String glExtensionName) { validateInitialization(); return availableExtensionCache.contains(glExtensionName); @@ -97,7 +97,7 @@ final class ExtensionAvailabilityCache { validateInitialization(); return glXExtensionCount; } - + final String getPlatformExtensionsString() { validateInitialization(); return glXExtensions; @@ -107,7 +107,7 @@ final class ExtensionAvailabilityCache { validateInitialization(); return glExtensionCount; } - + final String getGLExtensionsString() { validateInitialization(); if(DEBUG) { @@ -151,7 +151,7 @@ final class ExtensionAvailabilityCache { ", use "+ ( useGetStringi ? "glGetStringi" : "glGetString" ) ); } - HashSet glExtensionSet = new HashSet(gl.isGLES() ? 50 : 320); // far less gl extension expected on mobile + HashSet glExtensionSet = new HashSet(gl.isGLES() ? 50 : 320); // far less gl extension expected on mobile if(useGetStringi) { GL2GL3 gl2gl3 = gl.getGL2GL3(); final int count; @@ -163,7 +163,7 @@ final class ExtensionAvailabilityCache { StringBuilder sb = new StringBuilder(); for (int i = 0; i < count; i++) { if(i > 0) { - sb.append(" "); + sb.append(" "); } final String ext = gl2gl3.glGetStringi(GL.GL_EXTENSIONS, i); glExtensionSet.add(ext); @@ -185,7 +185,7 @@ final class ExtensionAvailabilityCache { } } } - glExtensionCount = glExtensionSet.size(); + glExtensionCount = glExtensionSet.size(); if (DEBUG) { System.err.println(getThreadName() + ":ExtensionAvailabilityCache: GL_EXTENSIONS: "+glExtensionCount+ ", used "+ ( useGetStringi ? "glGetStringi" : "glGetString" ) ); @@ -193,17 +193,17 @@ final class ExtensionAvailabilityCache { // Platform Extensions HashSet glXExtensionSet = new HashSet(50); - { - // unify platform extension .. might have duplicates + { + // unify platform extension .. might have duplicates StringTokenizer tok = new StringTokenizer(context.getPlatformExtensionsStringImpl().toString()); while (tok.hasMoreTokens()) { - glXExtensionSet.add(tok.nextToken().trim()); + glXExtensionSet.add(tok.nextToken().trim()); } final StringBuilder sb = new StringBuilder(); for(Iterator iter = glXExtensionSet.iterator(); iter.hasNext(); ) { sb.append(iter.next()); if(iter.hasNext()) { - sb.append(" "); + sb.append(" "); } } glXExtensions = sb.toString(); @@ -222,7 +222,7 @@ final class ExtensionAvailabilityCache { final int ctxOptions = context.getCtxOptions(); final VersionNumber version = context.getGLVersionNumber(); int major[] = new int[] { version.getMajor() }; - int minor[] = new int[] { version.getMinor() }; + int minor[] = new int[] { version.getMinor() }; while (GLContext.isValidGLVersion(ctxOptions, major[0], minor[0])) { final String GL_XX_VERSION = ( context.isGLES() ? "GL_ES_VERSION_" : "GL_VERSION_" ) + major[0] + "_" + minor[0]; availableExtensionCache.add(GL_XX_VERSION); diff --git a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java index b74ac9f41..c96f7db32 100644 --- a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java +++ b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java @@ -41,39 +41,39 @@ public class FPSCounterImpl implements FPSCounter { private long fpsStartTime, fpsLastUpdateTime, fpsLastPeriod, fpsTotalDuration; private int fpsTotalFrames; private float fpsLast, fpsTotal; - + /** Creates a disabled instance */ public FPSCounterImpl() { setUpdateFPSFrames(0, null); } - + /** * Increases total frame count and updates values if feature is enabled and * update interval is reached.
    - * + * * Shall be called by actual FPSCounter implementing renderer, after display a new frame. - * + * */ public final synchronized void tickFPS() { fpsTotalFrames++; if(fpsUpdateFramesInterval>0 && fpsTotalFrames%fpsUpdateFramesInterval == 0) { final long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); fpsLastPeriod = now - fpsLastUpdateTime; - fpsLastPeriod = Math.max(fpsLastPeriod, 1); // div 0 - fpsLast = ( (float)fpsUpdateFramesInterval * 1000f ) / ( (float) fpsLastPeriod ) ; - + fpsLastPeriod = Math.max(fpsLastPeriod, 1); // div 0 + fpsLast = ( (float)fpsUpdateFramesInterval * 1000f ) / ( (float) fpsLastPeriod ) ; + fpsTotalDuration = now - fpsStartTime; fpsTotalDuration = Math.max(fpsTotalDuration, 1); // div 0 fpsTotal= ( (float)fpsTotalFrames * 1000f ) / ( (float) fpsTotalDuration ) ; - + if(null != fpsOutputStream) { fpsOutputStream.println(toString()); } - + fpsLastUpdateTime = now; } } - + public StringBuilder toString(StringBuilder sb) { if(null==sb) { sb = new StringBuilder(); @@ -81,22 +81,22 @@ public class FPSCounterImpl implements FPSCounter { String fpsLastS = String.valueOf(fpsLast); fpsLastS = fpsLastS.substring(0, fpsLastS.indexOf('.') + 2); String fpsTotalS = String.valueOf(fpsTotal); - fpsTotalS = fpsTotalS.substring(0, fpsTotalS.indexOf('.') + 2); + fpsTotalS = fpsTotalS.substring(0, fpsTotalS.indexOf('.') + 2); sb.append(fpsTotalDuration/1000 +" s: "+ fpsUpdateFramesInterval+" f / "+ fpsLastPeriod+" ms, " + fpsLastS+" fps, "+ fpsLastPeriod/fpsUpdateFramesInterval+" ms/f; "+ "total: "+ fpsTotalFrames+" f, "+ fpsTotalS+ " fps, "+ fpsTotalDuration/fpsTotalFrames+" ms/f"); return sb; } - + public String toString() { return toString(null).toString(); } - + public final synchronized void setUpdateFPSFrames(int frames, PrintStream out) { fpsUpdateFramesInterval = frames; fpsOutputStream = out; resetFPSCounter(); } - + public final synchronized void resetFPSCounter() { fpsStartTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); // overwrite startTime to real init one fpsLastUpdateTime = fpsStartTime; @@ -109,9 +109,9 @@ public class FPSCounterImpl implements FPSCounter { public final synchronized int getUpdateFPSFrames() { return fpsUpdateFramesInterval; } - - public final synchronized long getFPSStartTime() { - return fpsStartTime; + + public final synchronized long getFPSStartTime() { + return fpsStartTime; } public final synchronized long getLastFPSUpdateTime() { @@ -121,20 +121,20 @@ public class FPSCounterImpl implements FPSCounter { public final synchronized long getLastFPSPeriod() { return fpsLastPeriod; } - + public final synchronized float getLastFPS() { return fpsLast; } - - public final synchronized int getTotalFPSFrames() { - return fpsTotalFrames; + + public final synchronized int getTotalFPSFrames() { + return fpsTotalFrames; } - public final synchronized long getTotalFPSDuration() { - return fpsTotalDuration; + public final synchronized long getTotalFPSDuration() { + return fpsTotalDuration; } - + public final synchronized float getTotalFPS() { return fpsTotal; - } + } } diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index f8b453555..bb2983399 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl; import java.io.PrintStream; @@ -56,7 +56,7 @@ import com.jogamp.opengl.GLStateKeeper; /** * Abstract common code for GLAutoDrawable implementations. - * + * * @see GLAutoDrawable * @see GLAutoDrawableDelegate * @see GLPBufferImpl @@ -64,10 +64,10 @@ import com.jogamp.opengl.GLStateKeeper; */ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeeper, FPSCounter { public static final boolean DEBUG = GLDrawableImpl.DEBUG; - + protected final GLDrawableHelper helper = new GLDrawableHelper(); protected final FPSCounterImpl fpsCounter = new FPSCounterImpl(); - + protected volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access protected GLContextImpl context; protected boolean preserveGLELSAtDestroy; @@ -79,9 +79,9 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe protected volatile boolean sendDestroy = false; // volatile: maybe written by WindowManager thread w/o locking /** - * @param drawable upstream {@link GLDrawableImpl} instance, + * @param drawable upstream {@link GLDrawableImpl} instance, * may be null for lazy initialization - * @param context upstream {@link GLContextImpl} instance, + * @param context upstream {@link GLContextImpl} instance, * may not have been made current (created) yet, * may not be associated w/ drawable yet, * may be null for lazy initialization @@ -100,19 +100,19 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe if(null != context && null != drawable) { context.setGLDrawable(drawable, false); } - resetFPSCounter(); + resetFPSCounter(); } - - /** Returns the recursive lock object of the upstream implementation, which synchronizes multithreaded access on top of {@link NativeSurface#lockSurface()}. */ + + /** Returns the recursive lock object of the upstream implementation, which synchronizes multithreaded access on top of {@link NativeSurface#lockSurface()}. */ protected abstract RecursiveLock getLock(); @Override public final GLStateKeeper.Listener setGLStateKeeperListener(Listener l) { final GLStateKeeper.Listener pre = glStateKeeperListener; glStateKeeperListener = l; - return pre; + return pre; } - + @Override public final boolean preserveGLStateAtDestroy(boolean value) { final boolean res = isGLStatePreservationSupported() ? true : false; @@ -125,10 +125,10 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe } return res; } - + @Override public boolean isGLStatePreservationSupported() { return false; } - + @Override public final GLEventListenerState getPreservedGLState() { return glels; @@ -140,20 +140,20 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe glels = null; return r; } - + /** * Pulls the {@link GLEventListenerState} from this {@link GLAutoDrawable}. - * + * * @return true if the {@link GLEventListenerState} is pulled successfully from this {@link GLAutoDrawable}, * otherwise false. - * + * * @throws IllegalStateException if the {@link GLEventListenerState} is already pulled - * + * * @see #pushGLEventListenerState() */ protected final boolean pullGLEventListenerState() throws IllegalStateException { if( null != glels ) { - throw new IllegalStateException("GLEventListenerState already pulled"); + throw new IllegalStateException("GLEventListenerState already pulled"); } if( null != context && context.isCreated() ) { if( null!= glStateKeeperListener) { @@ -164,14 +164,14 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe } return false; } - + /** * Pushes a previously {@link #pullGLEventListenerState() pulled} {@link GLEventListenerState} to this {@link GLAutoDrawable}. - * - * @return true if the {@link GLEventListenerState} was previously {@link #pullGLEventListenerState() pulled} + * + * @return true if the {@link GLEventListenerState} was previously {@link #pullGLEventListenerState() pulled} * and is pushed successfully to this {@link GLAutoDrawable}, * otherwise false. - * + * * @see #pullGLEventListenerState() */ protected final boolean pushGLEventListenerState() { @@ -180,12 +180,12 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe glels = null; if( null!= glStateKeeperListener) { glStateKeeperListener.glStateRestored(this); - } + } return true; } - return false; + return false; } - + /** Default implementation to handle repaint events from the windowing system */ protected final void defaultWindowRepaintOp() { final GLDrawable _drawable = drawable; @@ -195,7 +195,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe } } } - + /** Default implementation to handle resize events from the windowing system. All required locks are being claimed. */ protected final void defaultWindowResizedOp(int newWidth, int newHeight) throws NativeWindowException, GLException { GLDrawableImpl _drawable = drawable; @@ -210,7 +210,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe try { final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, newWidth, newHeight); if(_drawable != _drawableNew) { - // write back + // write back _drawable = _drawableNew; drawable = _drawableNew; } @@ -226,15 +226,15 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe } } } - - /** + + /** * Default implementation to handle destroy notifications from the windowing system. - * + * *

    - * If the {@link NativeSurface} does not implement {@link WindowClosingProtocol} + * If the {@link NativeSurface} does not implement {@link WindowClosingProtocol} * or {@link WindowClosingMode#DISPOSE_ON_CLOSE} is enabled (default), * a thread safe destruction is being induced. - *

    + *

    */ protected final void defaultWindowDestroyNotifyOp() { final NativeSurface ns = getNativeSurface(); @@ -243,22 +243,22 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe shallClose = WindowClosingMode.DISPOSE_ON_CLOSE == ((WindowClosingProtocol)ns).getDefaultCloseOperation(); } else { shallClose = true; - } + } if( shallClose ) { destroyAvoidAwareOfLocking(); - } + } } /** - * Calls {@link #destroy()} + * Calls {@link #destroy()} * directly if the following requirements are met: *
      - *
    • An {@link GLAnimatorControl} is bound (see {@link #getAnimator()}) and running on another thread. + *
    • An {@link GLAnimatorControl} is bound (see {@link #getAnimator()}) and running on another thread. * Here we pause the animation while issuing the destruction.
    • *
    • Surface is not locked by another thread (considered anonymous).
    • *
    *

    - * Otherwise destroy is being flagged to be called within the next + * Otherwise destroy is being flagged to be called within the next * call of display(). *

    *

    @@ -270,9 +270,9 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe */ protected final void destroyAvoidAwareOfLocking() { final NativeSurface ns = getNativeSurface(); - + final GLAnimatorControl ctrl = helper.getAnimator(); - + // Is an animator thread perform rendering? if ( helper.isAnimatorStartedOnOtherThread() ) { // Pause animations before initiating safe destroy. @@ -292,7 +292,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe destroy(); } } - + /** * Calls {@link #destroyImplInLock()} while claiming the lock. */ @@ -305,7 +305,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe lock.unlock(); } } - + /** * Default implementation to destroys the drawable and context of this GLAutoDrawable: *

      @@ -323,7 +323,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe pullGLEventListenerState(); } if( null != context ) { - if( context.isCreated() ) { + if( context.isCreated() ) { // Catch dispose GLExceptions by GLEventListener, just 'print' them // so we can continue with the destruction. try { @@ -341,9 +341,9 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe if( ownsDevice ) { device.close(); } - } + } } - + public final void defaultSwapBuffers() throws GLException { final RecursiveLock _lock = getLock(); _lock.lock(); @@ -359,7 +359,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe // // GLAutoDrawable // - + protected final Runnable defaultInitAction = new Runnable() { @Override public final void run() { @@ -397,7 +397,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe _lock.unlock(); } } - + protected final GLEventListener defaultDisposeGLEventListener(GLEventListener listener, boolean remove) { final RecursiveLock _lock = getLock(); _lock.lock(); @@ -405,14 +405,14 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe return helper.disposeGLEventListener(GLAutoDrawableBase.this, drawable, context, listener, remove); } finally { _lock.unlock(); - } + } } - + @Override public final GLDrawable getDelegatedDrawable() { return drawable; } - + @Override public final GLContext getContext() { return context; @@ -458,7 +458,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe @Override public final void addGLEventListener(int index, GLEventListener listener) throws IndexOutOfBoundsException { - helper.addGLEventListener(index, listener); + helper.addGLEventListener(index, listener); } @Override @@ -480,21 +480,21 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe public void setGLEventListenerInitState(GLEventListener listener, boolean initialized) { helper.setGLEventListenerInitState(listener, initialized); } - + @Override public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove) { return defaultDisposeGLEventListener(listener, remove); } - + @Override public final GLEventListener removeGLEventListener(GLEventListener listener) { - return helper.removeGLEventListener(listener); + return helper.removeGLEventListener(listener); } - + @Override public final void setAnimator(GLAnimatorControl animatorControl) throws GLException { - helper.setAnimator(animatorControl); + helper.setAnimator(animatorControl); } @Override @@ -511,20 +511,20 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe public final Thread getExclusiveContextThread() { return helper.getExclusiveContextThread(); } - + @Override public final boolean invoke(boolean wait, GLRunnable glRunnable) { - return helper.invoke(this, wait, glRunnable); + return helper.invoke(this, wait, glRunnable); } @Override public boolean invoke(final boolean wait, final List glRunnables) { return helper.invoke(this, wait, glRunnables); } - + @Override public final void setAutoSwapBufferMode(boolean enable) { - helper.setAutoSwapBufferMode(enable); + helper.setAutoSwapBufferMode(enable); } @Override @@ -534,7 +534,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe @Override public final void setContextCreationFlags(int flags) { - additionalCtxCreationFlags = flags; + additionalCtxCreationFlags = flags; final GLContext _context = context; if(null != _context) { _context.setContextCreationFlags(additionalCtxCreationFlags); @@ -549,7 +549,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe // // FPSCounter // - + @Override public final void setUpdateFPSFrames(int frames, PrintStream out) { fpsCounter.setUpdateFPSFrames(frames, out); @@ -599,11 +599,11 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe public final float getTotalFPS() { return fpsCounter.getTotalFPS(); } - + // // GLDrawable delegation // - + @Override public final GLContext createContext(final GLContext shareWith) { final RecursiveLock lock = getLock(); @@ -624,10 +624,10 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe public final void setRealized(boolean realized) { final RecursiveLock _lock = getLock(); _lock.lock(); - try { + try { final GLDrawable _drawable = drawable; if( null == _drawable || realized && ( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) ) { - return; + return; } _drawable.setRealized(realized); if( realized && _drawable.isRealized() ) { @@ -637,7 +637,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe _lock.unlock(); } } - + @Override public final boolean isRealized() { final GLDrawable _drawable = drawable; @@ -661,7 +661,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe final GLDrawable _drawable = drawable; return null != _drawable ? _drawable.isGLOriented() : true; } - + @Override public final GLCapabilitiesImmutable getChosenGLCapabilities() { final GLDrawable _drawable = drawable; @@ -685,7 +685,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe final GLDrawable _drawable = drawable; return null != _drawable ? _drawable.getHandle() : 0; } - + protected static String getThreadName() { return Thread.currentThread().getName(); } @Override diff --git a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java index 17646cc7b..73a864304 100644 --- a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java +++ b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -93,7 +93,7 @@ public class GLBufferSizeTracker { Debug.initSingleton(); DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferSizeTracker", true); } - + // Map from buffer names to sizes. // Note: should probably have some way of shrinking this map, but // can't just make it a WeakHashMap because nobody holds on to the @@ -102,7 +102,7 @@ public class GLBufferSizeTracker { // pattern of buffer objects indicates that the fact that this map // never shrinks is probably not that bad. private IntLongHashMap bufferSizeMap; - + public GLBufferSizeTracker() { bufferSizeMap = new IntLongHashMap(); bufferSizeMap.setKeyNotFoundValue(0xFFFFFFFFFFFFFFFFL); diff --git a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java index f14d16ec4..cd9eea287 100644 --- a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java +++ b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -50,7 +50,7 @@ import com.jogamp.common.util.IntIntHashMap; * This class is used to verify that e.g. the vertex * buffer object extension is in use when the glVertexPointer variant * taking a long as argument is called.

      - * + * * Note that because the enumerated value used for the binding of a * buffer object (e.g. GL_ARRAY_BUFFER) is different than that used to * query the binding using glGetIntegerv (e.g. @@ -77,16 +77,16 @@ import com.jogamp.common.util.IntIntHashMap; public class GLBufferStateTracker { protected static final boolean DEBUG; - + static { Debug.initSingleton(); DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferStateTracker", true); } - + // Maps binding targets to buffer objects. A null value indicates // that the binding is unknown. A zero value indicates that it is - // known that no buffer is bound to the target, according to the - // OpenGL specifications. + // known that no buffer is bound to the target, according to the + // OpenGL specifications. // http://www.opengl.org/sdk/docs/man/xhtml/glBindBuffer.xml private IntIntHashMap bindingMap; @@ -108,7 +108,7 @@ public class GLBufferStateTracker { public final void setBoundBufferObject(int target, int value) { bindingMap.put(target, value); if (DEBUG) { - System.err.println("GLBufferStateTracker.setBoundBufferObject() target 0x" + + System.err.println("GLBufferStateTracker.setBoundBufferObject() target 0x" + Integer.toHexString(target) + " -> mapped bound buffer 0x" + Integer.toHexString(value)); // Thread.dumpStack(); @@ -146,7 +146,7 @@ public class GLBufferStateTracker { value = 0; } if (DEBUG) { - System.err.println("GLBufferStateTracker.getBoundBufferObject() glerr[pre 0x"+Integer.toHexString(glerrPre)+", post 0x"+Integer.toHexString(glerrPost)+"], [queried value]: target 0x" + + System.err.println("GLBufferStateTracker.getBoundBufferObject() glerr[pre 0x"+Integer.toHexString(glerrPre)+", post 0x"+Integer.toHexString(glerrPost)+"], [queried value]: target 0x" + Integer.toHexString(target) + " / query 0x"+Integer.toHexString(queryTarget)+ " -> mapped bound buffer 0x" + Integer.toHexString(value)); } @@ -156,7 +156,7 @@ public class GLBufferStateTracker { return 0; } if (DEBUG) { - System.err.println("GLBufferStateTracker.getBoundBufferObject() [mapped value]: target 0x" + + System.err.println("GLBufferStateTracker.getBoundBufferObject() [mapped value]: target 0x" + Integer.toHexString(target) + " -> mapped bound buffer 0x" + Integer.toHexString(value)); } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 7f9f20a21..7c3a5922b 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -106,14 +106,14 @@ public abstract class GLContextImpl extends GLContext { private final GLStateTracker glStateTracker = new GLStateTracker(); private GLDebugMessageHandler glDebugHandler = null; private final int[] boundFBOTarget = new int[] { 0, 0 }; // { draw, read } - private int defaultVAO = 0; - + private int defaultVAO = 0; + protected GLDrawableImpl drawable; protected GLDrawableImpl drawableRead; - + private volatile boolean pixelDataEvaluated; private int /* pixelDataInternalFormat, */ pixelDataFormat, pixelDataType; - + protected GL gl; protected static final Object mappedContextTypeObjectLock; @@ -161,7 +161,7 @@ public abstract class GLContextImpl extends GLContext { glStateTracker.setEnabled(false); glStateTracker.clearStates(); } - + @Override protected void resetStates(boolean isInit) { if( !isInit ) { @@ -177,12 +177,12 @@ public abstract class GLContextImpl extends GLContext { glRenderer = glVendor; glRendererLowerCase = glRenderer; glVersion = glVendor; - + if (boundFBOTarget != null) { // boundFBOTarget[0] = 0; // draw boundFBOTarget[1] = 0; // read } - + pixelDataEvaluated = false; super.resetStates(isInit); @@ -190,7 +190,7 @@ public abstract class GLContextImpl extends GLContext { @Override public final GLDrawable setGLReadDrawable(GLDrawable read) { - if(!isGLReadDrawableAvailable()) { + if(!isGLReadDrawableAvailable()) { throw new GLException("Setting read drawable feature not available"); } final boolean lockHeld = lock.isOwner(Thread.currentThread()); @@ -220,7 +220,7 @@ public abstract class GLContextImpl extends GLContext { final Thread currentThread = Thread.currentThread(); if( lock.isLockedByOtherThread() ) { throw new GLException("GLContext current by other thread "+lock.getOwner().getName()+", operation not allowed on this thread "+currentThread.getName()); - } + } final boolean lockHeld = lock.isOwner(currentThread); if( lockHeld && lock.getHoldCount() > 1 ) { // would need to makeCurrent * holdCount @@ -272,7 +272,7 @@ public abstract class GLContextImpl extends GLContext { } return _gl; } - + @Override public final GL getGL() { return gl; @@ -314,7 +314,7 @@ public abstract class GLContextImpl extends GLContext { @Override public void release() throws GLException { release(false); - } + } private void release(boolean inDestruction) throws GLException { if( TRACE_SWITCH ) { System.err.println(getThreadName() +": GLContext.ContextSwitch[release.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+", inDestruction: "+inDestruction+", "+lock); @@ -332,7 +332,7 @@ public abstract class GLContextImpl extends GLContext { } throw new GLException(msg); } - + Throwable drawableContextMadeCurrentException = null; final boolean actualRelease = ( inDestruction || lock.getHoldCount() == 1 ) && 0 != contextHandle; try { @@ -365,7 +365,7 @@ public abstract class GLContextImpl extends GLContext { if(null != drawableContextMadeCurrentException) { throw new GLException("GLContext.release(false) during GLDrawableImpl.contextMadeCurrent(this, false)", drawableContextMadeCurrentException); } - + } private Throwable lastCtxReleaseStack = null; protected abstract void releaseImpl() throws GLException; @@ -518,21 +518,21 @@ public abstract class GLContextImpl extends GLContext { public final int makeCurrent() throws GLException { return makeCurrent(false); } - + protected final int makeCurrent(boolean forceDrawableAssociation) throws GLException { if( TRACE_SWITCH ) { System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - "+lock); - } + } // Note: the surface is locked within [makeCurrent .. swap .. release] final int lockRes = drawable.lockSurface(); if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { if( DEBUG_TRACE_SWITCH ) { - System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X1]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - Surface Not Ready - CONTEXT_NOT_CURRENT - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X1]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - Surface Not Ready - CONTEXT_NOT_CURRENT - "+lock); } return CONTEXT_NOT_CURRENT; } - + boolean unlockResources = true; // Must be cleared if successful, otherwise finally block will release context and/or surface! int res = CONTEXT_NOT_CURRENT; try { @@ -552,7 +552,7 @@ public abstract class GLContextImpl extends GLContext { drawableUpdatedNotify(); unlockResources = false; // success if( TRACE_SWITCH ) { - System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X2]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - keep - CONTEXT_CURRENT - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X2]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - keep - CONTEXT_CURRENT - "+lock); } return CONTEXT_CURRENT; } else { @@ -561,7 +561,7 @@ public abstract class GLContextImpl extends GLContext { } res = makeCurrentWithinLock(lockRes); unlockResources = CONTEXT_NOT_CURRENT == res; // success ? - + /** * FIXME: refactor dependence on Java 2D / JOGL bridge if ( tracker != null && res == CONTEXT_CURRENT_NEW ) { @@ -608,16 +608,16 @@ public abstract class GLContextImpl extends GLContext { if(TRACE_GL) { gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ); } - + forceDrawableAssociation = true; } - + if( forceDrawableAssociation ) { associateDrawable(true); } - + contextMadeCurrent(true); - + /* FIXME: refactor dependence on Java 2D / JOGL bridge // Try cleaning up any stale server-side OpenGL objects @@ -629,10 +629,10 @@ public abstract class GLContextImpl extends GLContext { } if( TRACE_SWITCH ) { System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X3]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - "+makeCurrentResultToString(res)+" - stateTracker.on "+glStateTracker.isEnabled()+" - "+lock); - } + } return res; } - + private final int makeCurrentWithinLock(int surfaceLockRes) throws GLException { if (!isCreated()) { if( 0 >= drawable.getWidth() || 0 >= drawable.getHeight() ) { @@ -683,7 +683,7 @@ public abstract class GLContextImpl extends GLContext { final AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice device = config.getScreen().getDevice(); - // Non ARB desktop profiles may not have been registered + // Non ARB desktop profiles may not have been registered if( !GLContext.getAvailableGLVersionsSet(device) ) { // not yet set if( 0 == ( ctxOptions & GLContext.CTX_PROFILE_ES) ) { // not ES profile final int reqMajor; @@ -701,10 +701,10 @@ public abstract class GLContextImpl extends GLContext { GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); GLContext.setAvailableGLVersionsSet(device); - + if (DEBUG) { System.err.println(getThreadName() + ": createContextOLD-MapVersionsAvailable HAVE: " + device+" -> "+reqMajor+"."+reqProfile+ " -> "+getGLVersion()); - } + } } } } @@ -717,17 +717,17 @@ public abstract class GLContextImpl extends GLContext { protected abstract void makeCurrentImpl() throws GLException; /** - * Calls {@link GLDrawableImpl#associateContext(GLContext, boolean)} - */ - protected void associateDrawable(boolean bound) { - drawable.associateContext(this, bound); + * Calls {@link GLDrawableImpl#associateContext(GLContext, boolean)} + */ + protected void associateDrawable(boolean bound) { + drawable.associateContext(this, bound); } - + /** - * Calls {@link GLDrawableImpl#contextMadeCurrent(GLContext, boolean)} - */ + * Calls {@link GLDrawableImpl#contextMadeCurrent(GLContext, boolean)} + */ protected void contextMadeCurrent(boolean current) { - drawable.contextMadeCurrent(this, current); + drawable.contextMadeCurrent(this, current); } /** @@ -827,7 +827,7 @@ public abstract class GLContextImpl extends GLContext { final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); final int[] reqMajorCTP = new int[] { 0, 0 }; getRequestMajorAndCompat(glCaps.getGLProfile(), reqMajorCTP); - + int _major[] = { 0 }; int _minor[] = { 0 }; int _ctp[] = { 0 }; @@ -842,7 +842,7 @@ public abstract class GLContextImpl extends GLContext { } return _ctx; } - + private final boolean mapGLVersions(AbstractGraphicsDevice device) { synchronized (GLContext.deviceVersionAvailable) { final long t0 = ( DEBUG ) ? System.nanoTime() : 0; @@ -854,7 +854,7 @@ public abstract class GLContextImpl extends GLContext { boolean hasGL4 = false; boolean hasGL3 = false; boolean hasES3 = false; - + // Even w/ PROFILE_ALIASING, try to use true core GL profiles // ensuring proper user behavior across platforms due to different feature sets! // @@ -863,7 +863,7 @@ public abstract class GLContextImpl extends GLContext { success |= hasGL4; if(hasGL4) { // Map all lower compatible profiles: GL3 - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); if(PROFILE_ALIASING) { hasGL3 = true; } @@ -874,7 +874,7 @@ public abstract class GLContextImpl extends GLContext { hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3 success |= hasGL3; if(hasGL3) { - resetStates(false); // clean this context states, since creation was temporary + resetStates(false); // clean this context states, since creation was temporary } } if(!hasGL4bc) { @@ -919,14 +919,14 @@ public abstract class GLContextImpl extends GLContext { hasGL2 = createContextARBMapVersionsAvailable(2, CTX_PROFILE_COMPAT); // GL2 success |= hasGL2; if(hasGL2) { - resetStates(false); // clean this context states, since creation was temporary + resetStates(false); // clean this context states, since creation was temporary } } if(!hasES3) { hasES3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_ES); // ES3 success |= hasES3; if(hasES3) { - resetStates(false); // clean this context states, since creation was temporary + resetStates(false); // clean this context states, since creation was temporary } } if(success) { @@ -935,7 +935,7 @@ public abstract class GLContextImpl extends GLContext { if(DEBUG) { final long t1 = System.nanoTime(); System.err.println("GLContextImpl.mapGLVersions: "+device+", profileAliasing: "+PROFILE_ALIASING+", total "+(t1-t0)/1e6 +"ms"); - System.err.println(GLContext.dumpAvailableGLVersions(null).toString()); + System.err.println(GLContext.dumpAvailableGLVersions(null).toString()); } } else if (DEBUG) { System.err.println(getThreadName() + ": createContextARB-MapVersions NONE for :"+device); @@ -944,9 +944,9 @@ public abstract class GLContextImpl extends GLContext { } } - /** + /** * Note: Since context creation is temporary, caller need to issue {@link #resetStates(boolean)}, if creation was successful, i.e. returns true. - * This method does not reset the states, allowing the caller to utilize the state variables. + * This method does not reset the states, allowing the caller to utilize the state variables. **/ private final boolean createContextARBMapVersionsAvailable(int reqMajor, int reqProfile) { long _context; @@ -1059,7 +1059,7 @@ public abstract class GLContextImpl extends GLContext { if ( 0 == ctp ) { throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } - + if (!GLContext.isValidGLVersion(ctp, major, minor)) { throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } @@ -1080,10 +1080,10 @@ public abstract class GLContextImpl extends GLContext { if( ctxGLSLVersion.isZero() ) { ctxGLSLVersion = getStaticGLSLVersionNumber(major, minor, ctxOptions); } - } + } } } - + //---------------------------------------------------------------------- // Helpers for various context implementations // @@ -1107,8 +1107,8 @@ public abstract class GLContextImpl extends GLContext { */ return gl; } - - /** + + /** * Finalizes GL instance initialization after this context has been initialized. *

      * Method calls 'void finalizeInit()' of instance 'gl' as retrieved by reflection, if exist. @@ -1138,7 +1138,7 @@ public abstract class GLContextImpl extends GLContext { * ie for GLXExt, EGLExt, .. */ public abstract ProcAddressTable getPlatformExtProcAddressTable(); - + /** * Part of GL_NV_vertex_array_range. *

      @@ -1154,7 +1154,7 @@ public abstract class GLContextImpl extends GLContext { * Provides platform-independent access to the wglFreeMemoryNV / * glXFreeMemoryNV. *

      - */ + */ public abstract void glFreeMemoryNV(ByteBuffer pointer); /** Maps the given "platform-independent" function name to a real function @@ -1195,7 +1195,7 @@ public abstract class GLContextImpl extends GLContext { } } ); } - + private final boolean initGLRendererAndGLVersionStrings() { final GLDynamicLookupHelper glDynLookupHelper = getDrawableImpl().getGLDynamicLookupHelper(); final long _glGetString = glDynLookupHelper.dynamicLookupFunction("glGetString"); @@ -1215,7 +1215,7 @@ public abstract class GLContextImpl extends GLContext { return false; } glVendor = _glVendor; - + final String _glRenderer = glGetStringInt(GL.GL_RENDERER, _glGetString); if(null == _glRenderer) { if(DEBUG) { @@ -1226,7 +1226,7 @@ public abstract class GLContextImpl extends GLContext { } glRenderer = _glRenderer; glRendererLowerCase = glRenderer.toLowerCase(); - + final String _glVersion = glGetStringInt(GL.GL_VERSION, _glGetString); if(null == _glVersion) { // FIXME @@ -1237,7 +1237,7 @@ public abstract class GLContextImpl extends GLContext { return false; } glVersion = _glVersion; - + return true; } } @@ -1251,7 +1251,7 @@ public abstract class GLContextImpl extends GLContext { minor[0] = 0; } } - + /** * Returns null if version string is invalid, otherwise a valid instance. *

      @@ -1278,7 +1278,7 @@ public abstract class GLContextImpl extends GLContext { * version for given arrays. *

      * If the GL query fails, major will be zero. - *

      + *

      *

      * Note: Non ARB ctx is limited to GL 3.0. *

      @@ -1292,20 +1292,20 @@ public abstract class GLContextImpl extends GLContext { if(DEBUG) { Thread.dumpStack(); } - return false; + return false; } else { glGetIntegervInt(GL2GL3.GL_MAJOR_VERSION, glIntMajor, 0, _glGetIntegerv); glGetIntegervInt(GL2GL3.GL_MINOR_VERSION, glIntMinor, 0, _glGetIntegerv); limitNonARBContextVersion(glIntMajor, glIntMinor, ctp); - return true; + return true; } } - + protected final int getCtxOptions() { return ctxOptions; } - + /** * Sets the OpenGL implementation class and * the cache of which GL functions are available for calling through this @@ -1325,8 +1325,8 @@ public abstract class GLContextImpl extends GLContext { *
    • be greater or equal than the requested major.minor version, and
    • *
    • match the ctxProfileBits
    • *
    , otherwise method aborts and returns false. - * @return returns true if successful, otherwise false. See strictMatch. - * If false is returned, no data has been cached or mapped, i.e. ProcAddressTable, Extensions, Version, etc. + * @return returns true if successful, otherwise false. See strictMatch. + * If false is returned, no data has been cached or mapped, i.e. ProcAddressTable, Extensions, Version, etc. * @see #setContextVersion * @see javax.media.opengl.GLContext#CTX_OPTION_ANY * @see javax.media.opengl.GLContext#CTX_PROFILE_COMPAT @@ -1340,7 +1340,7 @@ public abstract class GLContextImpl extends GLContext { if ( 0 < major && !GLContext.isValidGLVersion(ctxProfileBits, major, minor) ) { throw new GLException("Invalid GL Version Request "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); } - + if(null==this.gl || !verifyInstance(gl.getGLProfile(), "Impl", this.gl)) { setGL( createGL( getGLDrawable().getGLProfile() ) ); } @@ -1348,7 +1348,7 @@ public abstract class GLContextImpl extends GLContext { final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); - + { final boolean initGLRendererAndGLVersionStringsOK = initGLRendererAndGLVersionStrings(); if( !initGLRendererAndGLVersionStringsOK ) { @@ -1367,7 +1367,7 @@ public abstract class GLContextImpl extends GLContext { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Given "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)); } } - + // // Validate GL version either by GL-Integer or GL-String // @@ -1377,8 +1377,8 @@ public abstract class GLContextImpl extends GLContext { boolean versionValidated = false; boolean versionGL3IntFailed = false; { - // Validate the requested version w/ the GL-version from an integer query. - final int[] glIntMajor = new int[] { 0 }, glIntMinor = new int[] { 0 }; + // Validate the requested version w/ the GL-version from an integer query. + final int[] glIntMajor = new int[] { 0 }, glIntMinor = new int[] { 0 }; final boolean getGLIntVersionOK = getGLIntVersion(glIntMajor, glIntMinor, ctxProfileBits); if( !getGLIntVersionOK ) { final String errMsg = "Fetching GL Integer Version failed. "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null); @@ -1392,14 +1392,14 @@ public abstract class GLContextImpl extends GLContext { // unusable GL context - non query mode - hard fail! throw new GLException(errMsg); } - } + } if (DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: version verification (Int): "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); } - + // Only validate if a valid int version was fetched, otherwise cont. w/ version-string method -> 3.0 > Version || Version > MAX! if ( GLContext.isValidGLVersion(ctxProfileBits, glIntMajor[0], glIntMinor[0]) ) { - if( glIntMajor[0] "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); @@ -1415,13 +1415,13 @@ public abstract class GLContextImpl extends GLContext { } } if( !versionValidated ) { - // Validate the requested version w/ the GL-version from the version string. + // Validate the requested version w/ the GL-version from the version string. final VersionNumber setGLVersionNumber = new VersionNumber(major, minor, 0); final VersionNumber strGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion); if (DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: version verification (String): "+glVersion+", "+strGLVersionNumber); } - + // Only validate if a valid string version was fetched -> MIN > Version || Version > MAX! if( null != strGLVersionNumber ) { if( strGLVersionNumber.compareTo(setGLVersionNumber) < 0 || 0 == major ) { @@ -1438,7 +1438,7 @@ public abstract class GLContextImpl extends GLContext { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL3 version Int failed, String: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+strGLVersionNumber); } - return false; + return false; } versionValidated = true; } @@ -1447,27 +1447,27 @@ public abstract class GLContextImpl extends GLContext { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, No GL version validation possible: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion); } - return false; + return false; } if (DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: post version verification "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed); } - + if( 2 > major ) { // there is no ES2/3-compat for a profile w/ major < 2 ctxProfileBits &= ~ ( GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_ES3_COMPAT ) ; } - + final VersionNumberString vendorVersion = GLVersionNumber.createVendorVersion(glVersion); - + setRendererQuirks(adevice, major, minor, ctxProfileBits, vendorVersion); - + if( strictMatch && glRendererQuirks.exist(GLRendererQuirks.GLNonCompliant) ) { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL is not compliant: "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)+", "+glRenderer); } return false; } - + if(!isCurrentContextHardwareRasterizer()) { ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; } @@ -1529,7 +1529,7 @@ public abstract class GLContextImpl extends GLContext { } } } - + if( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) ) { if( major >= 3 ) { ctxProfileBits |= CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ; @@ -1550,45 +1550,45 @@ public abstract class GLContextImpl extends GLContext { } else if( hasFBOImpl(major, ctxProfileBits, extensionAvailability) ) { ctxProfileBits |= CTX_IMPL_FBO; } - + if( ( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) && major == 1 ) || isExtensionAvailable(GLExtensions.OES_single_precision) ) { ctxProfileBits |= CTX_IMPL_FP32_COMPAT_API; } - + if(FORCE_NO_FBO_SUPPORT) { ctxProfileBits &= ~CTX_IMPL_FBO ; - } - + } + // // Set GL Version (complete w/ version string) // setContextVersion(major, minor, ctxProfileBits, vendorVersion, true); - + finalizeInit(gl); - + setDefaultSwapInterval(); - + final int glErrX = gl.glGetError(); // clear GL error, maybe caused by above operations - + if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: OK "+contextFQN+" - "+GLContext.getGLVersion(ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions, null)+" - glErr "+toHexString(glErrX)); } return true; } - + private final void setRendererQuirks(final AbstractGraphicsDevice adevice, int major, int minor, int ctp, final VersionNumberString vendorVersion) { int[] quirks = new int[GLRendererQuirks.COUNT + 1]; // + 1 ( NoFullFBOSupport ) int i = 0; - + final String MesaSP = "Mesa "; - // final String MesaRendererAMDsp = " AMD "; - // final String MesaRendererIntelsp = "Intel(R)"; + // final String MesaRendererAMDsp = " AMD "; + // final String MesaRendererIntelsp = "Intel(R)"; final boolean hwAccel = 0 == ( ctp & GLContext.CTX_IMPL_ACCEL_SOFT ); final boolean compatCtx = 0 != ( ctp & GLContext.CTX_PROFILE_COMPAT ); final boolean isDriverMesa = glRenderer.contains(MesaSP) || glRenderer.contains("Gallium "); final boolean isDriverATICatalyst = !isDriverMesa && ( glVendor.contains("ATI Technologies") || glRenderer.startsWith("ATI ") ); final boolean isDriverNVIDIAGeForce = !isDriverMesa && ( glVendor.contains("NVIDIA Corporation") || glRenderer.contains("NVIDIA ") ); - + // // OS related quirks // @@ -1603,7 +1603,7 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } - + if( isDriverNVIDIAGeForce ) { final VersionNumber osxVersionNVFlushClean = new VersionNumber(10,7,3); // < OSX 10.7.3 w/ NV needs glFlush if( Platform.getOSVersionNumber().compareTo(osxVersionNVFlushClean) < 0 ) { @@ -1622,7 +1622,7 @@ public abstract class GLContextImpl extends GLContext { quirks[i++] = quirk; } } - } else if( Platform.getOSType() == Platform.OSType.WINDOWS ) { + } else if( Platform.getOSType() == Platform.OSType.WINDOWS ) { // // WINDOWS // @@ -1633,28 +1633,28 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } - + if( isDriverATICatalyst ) { - final VersionNumber winXPVersionNumber = new VersionNumber ( 5, 1, 0); - final VersionNumber amdSafeMobilityVersion = new VersionNumber(12, 102, 3); - + final VersionNumber winXPVersionNumber = new VersionNumber ( 5, 1, 0); + final VersionNumber amdSafeMobilityVersion = new VersionNumber(12, 102, 3); + if ( vendorVersion.compareTo(amdSafeMobilityVersion) < 0 ) { // includes: vendorVersion.isZero() final int quirk = GLRendererQuirks.NeedCurrCtx4ARBCreateContext; if(DEBUG) { System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", [Vendor "+glVendor+" or Renderer "+glRenderer+"], driverVersion "+vendorVersion); } - quirks[i++] = quirk; + quirks[i++] = quirk; } - + if( Platform.getOSVersionNumber().compareTo(winXPVersionNumber) <= 0 ) { final int quirk = GLRendererQuirks.NeedCurrCtx4ARBPixFmtQueries; if(DEBUG) { System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS-Version "+Platform.getOSType()+" "+Platform.getOSVersionNumber()+", [Vendor "+glVendor+" or Renderer "+glRenderer+"]"); } - quirks[i++] = quirk; + quirks[i++] = quirk; } } - } else if( Platform.OSType.ANDROID == Platform.getOSType() ) { + } else if( Platform.OSType.ANDROID == Platform.getOSType() ) { // // ANDROID // @@ -1667,7 +1667,7 @@ public abstract class GLContextImpl extends GLContext { quirks[i++] = quirk; } } - + // // Windowing Toolkit related quirks // @@ -1704,8 +1704,8 @@ public abstract class GLContextImpl extends GLContext { } } } - - + + // // RENDERER related quirks // @@ -1735,8 +1735,8 @@ public abstract class GLContextImpl extends GLContext { } if( Platform.getOSType() == Platform.OSType.WINDOWS && glRenderer.contains("SVGA3D") ) { - final VersionNumber mesaSafeFBOVersion = new VersionNumber(8, 0, 0); - if ( vendorVersion.compareTo(mesaSafeFBOVersion) < 0 ) { // includes: vendorVersion.isZero() + final VersionNumber mesaSafeFBOVersion = new VersionNumber(8, 0, 0); + if ( vendorVersion.compareTo(mesaSafeFBOVersion) < 0 ) { // includes: vendorVersion.isZero() final int quirk = GLRendererQuirks.NoFullFBOSupport; if(DEBUG) { System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + " / Renderer " + glRenderer + " / Mesa-Version "+vendorVersion); @@ -1745,7 +1745,7 @@ public abstract class GLContextImpl extends GLContext { } } } - + // // Property related quirks // @@ -1754,28 +1754,28 @@ public abstract class GLContextImpl extends GLContext { if(DEBUG) { System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: property"); } - quirks[i++] = quirk; + quirks[i++] = quirk; } - + glRendererQuirks = new GLRendererQuirks(quirks, 0, i); } - + private static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) { return ( 0 != (ctp & CTX_PROFILE_ES) && major >= 2 ) || // ES >= 2.0 - - major >= 3 || // any >= 3.0 GL ctx - + + major >= 3 || // any >= 3.0 GL ctx + ( null != extCache && - + extCache.isExtensionAvailable(GLExtensions.ARB_ES2_compatibility) || // ES 2.0 compatible - + extCache.isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object - + extCache.isExtensionAvailable(GLExtensions.EXT_framebuffer_object) || // EXT_framebuffer_object - - extCache.isExtensionAvailable(GLExtensions.OES_framebuffer_object) ) ; // OES_framebuffer_object excluded + + extCache.isExtensionAvailable(GLExtensions.OES_framebuffer_object) ) ; // OES_framebuffer_object excluded } - + private final void removeCachedVersion(int major, int minor, int ctxProfileBits) { if(!isCurrentContextHardwareRasterizer()) { ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; @@ -1932,7 +1932,7 @@ public abstract class GLContextImpl extends GLContext { evalPixelDataType(); return pixelDataFormat; } - + private final void evalPixelDataType() { if(!pixelDataEvaluated) { synchronized(this) { @@ -1946,14 +1946,14 @@ public abstract class GLContextImpl extends GLContext { } else */ if( isGLES2Compatible() || isExtensionAvailable(GLExtensions.OES_read_format) ) { final int[] glImplColorReadVals = new int[] { 0, 0 }; gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_FORMAT, glImplColorReadVals, 0); - gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_TYPE, glImplColorReadVals, 1); + gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_TYPE, glImplColorReadVals, 1); // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB; pixelDataFormat = glImplColorReadVals[0]; pixelDataType = glImplColorReadVals[1]; ok = 0 != pixelDataFormat && 0 != pixelDataType; } if( !ok ) { - // RGBA read is safe for all GL profiles + // RGBA read is safe for all GL profiles // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB; pixelDataFormat=GL.GL_RGBA; pixelDataType = GL.GL_UNSIGNED_BYTE; @@ -1984,54 +1984,54 @@ public abstract class GLContextImpl extends GLContext { public final GLStateTracker getGLStateTracker() { return glStateTracker; } - + //--------------------------------------------------------------------------- // Helpers for context optimization where the last context is left // current on the OpenGL worker thread // - /** + /** * Returns true if the given thread is owner, otherwise false. *

    * Method exists merely for code validation of {@link #isCurrent()}. - *

    + *

    */ public final boolean isOwner(Thread thread) { return lock.isOwner(thread); } - - /** + + /** * Returns true if there are other threads waiting for this GLContext to {@link #makeCurrent()}, otherwise false. *

    * Since method does not perform any synchronization, accurate result are returned if lock is hold - only. - *

    + *

    */ public final boolean hasWaiters() { return lock.getQueueLength()>0; } - - /** + + /** * Returns the number of hold locks. See {@link RecursiveLock#getHoldCount()} for semantics. *

    * Since method does not perform any synchronization, accurate result are returned if lock is hold - only. - *

    + *

    */ public final int getLockCount() { return lock.getHoldCount(); } - + //--------------------------------------------------------------------------- // Special FBO hook // - + /** * Tracks {@link GL#GL_FRAMEBUFFER}, {@link GL2GL3#GL_DRAW_FRAMEBUFFER} and {@link GL2GL3#GL_READ_FRAMEBUFFER} * to be returned via {@link #getBoundFramebuffer(int)}. - * + * *

    Invoked by {@link GL#glBindFramebuffer(int, int)}.

    - * - *

    Assumes valid framebufferName range of [0..{@link Integer#MAX_VALUE}]

    - * + * + *

    Assumes valid framebufferName range of [0..{@link Integer#MAX_VALUE}]

    + * *

    Does not throw an exception if target is unknown or framebufferName invalid.

    */ public final void setBoundFramebuffer(int target, int framebufferName) { @@ -2064,14 +2064,14 @@ public abstract class GLContextImpl extends GLContext { throw new InternalError("Invalid FBO target name: "+toHexString(target)); } } - + @Override - public final int getDefaultDrawFramebuffer() { return drawable.getDefaultDrawFramebuffer(); } + public final int getDefaultDrawFramebuffer() { return drawable.getDefaultDrawFramebuffer(); } @Override - public final int getDefaultReadFramebuffer() { return drawable.getDefaultReadFramebuffer(); } + public final int getDefaultReadFramebuffer() { return drawable.getDefaultReadFramebuffer(); } @Override public final int getDefaultReadBuffer() { return drawable.getDefaultReadBuffer(gl); } - + //--------------------------------------------------------------------------- // GL_ARB_debug_output, GL_AMD_debug_output helpers // @@ -2090,7 +2090,7 @@ public abstract class GLContextImpl extends GLContext { public final int getContextCreationFlags() { return additionalCtxCreationFlags; } - + @Override public final void setContextCreationFlags(int flags) { if(!isCreated()) { @@ -2160,7 +2160,7 @@ public abstract class GLContextImpl extends GLContext { /** Internal bootstraping glGetString(GL_RENDERER) */ private static native String glGetStringInt(int name, long procAddress); - + /** Internal bootstraping glGetIntegerv(..) for version */ private static native void glGetIntegervInt(int pname, int[] params, int params_offset, long procAddress); } diff --git a/src/jogl/classes/jogamp/opengl/GLContextShareSet.java b/src/jogl/classes/jogamp/opengl/GLContextShareSet.java index b7acc0dff..70ade34b7 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextShareSet.java +++ b/src/jogl/classes/jogamp/opengl/GLContextShareSet.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2011 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -55,7 +55,7 @@ import javax.media.opengl.GLException; public class GLContextShareSet { private static final boolean DEBUG = GLContextImpl.DEBUG; - + // This class is implemented using a HashMap which maps from all shared contexts // to a share set, containing all shared contexts itself. @@ -74,17 +74,17 @@ public class GLContextShareSet { } else { destroyedShares.put(ctx, dummyValue); } - } + } } public Set getCreatedShares() { return createdShares.keySet(); } - + public Set getDestroyedShares() { return destroyedShares.keySet(); } - + public GLContext getCreatedShare(GLContext ignore) { for (Iterator iter = createdShares.keySet().iterator(); iter.hasNext(); ) { GLContext ctx = iter.next(); @@ -133,9 +133,9 @@ public class GLContextShareSet { addEntry(share1, share); addEntry(share2, share); if (DEBUG) { - System.err.println("GLContextShareSet: registereSharing: 1: " + + System.err.println("GLContextShareSet: registereSharing: 1: " + toHexString(share1.getHandle()) + ", 2: " + toHexString(share2.getHandle())); - } + } } public static synchronized void unregisterSharing(GLContext lastContext) { @@ -155,9 +155,9 @@ public class GLContextShareSet { throw new GLException("Last context's share set contains no destroyed context"); } if (DEBUG) { - System.err.println("GLContextShareSet: unregisterSharing: " + + System.err.println("GLContextShareSet: unregisterSharing: " + toHexString(lastContext.getHandle())+", entries: "+s.size()); - } + } for(Iterator iter = s.iterator() ; iter.hasNext() ; ) { GLContext ctx = iter.next(); if(null == removeEntry(ctx)) { @@ -165,7 +165,7 @@ public class GLContextShareSet { } } } - + private static synchronized Set getCreatedSharedImpl(GLContext context) { if (context == null) { throw new IllegalArgumentException("context is null"); @@ -174,9 +174,9 @@ public class GLContextShareSet { if (share != null) { return share.getCreatedShares(); } - return null; + return null; } - + public static synchronized boolean isShared(GLContext context) { if (context == null) { throw new IllegalArgumentException("context is null"); @@ -184,12 +184,12 @@ public class GLContextShareSet { final ShareSet share = entryFor(context); return share != null; } - + public static synchronized boolean hasCreatedSharedLeft(GLContext context) { final Set s = getCreatedSharedImpl(context); return null != s && s.size()>0 ; } - + /** currently not used .. public static synchronized Set getCreatedShared(GLContext context) { final Set s = getCreatedSharedImpl(context); @@ -198,7 +198,7 @@ public class GLContextShareSet { } return s; } - + public static synchronized Set getDestroyedShared(GLContext context) { if (context == null) { throw new IllegalArgumentException("context is null"); @@ -209,7 +209,7 @@ public class GLContextShareSet { } return share.getDestroyedShares(); } */ - + public static synchronized GLContext getShareContext(GLContext contextToCreate) { ShareSet share = entryFor(contextToCreate); if (share == null) { @@ -262,7 +262,7 @@ public class GLContextShareSet { //---------------------------------------------------------------------- // Internals only below this point - + private static ShareSet entryFor(GLContext context) { return (ShareSet) shareMap.get(context); @@ -276,8 +276,8 @@ public class GLContextShareSet { private static ShareSet removeEntry(GLContext context) { return (ShareSet) shareMap.remove(context); } - + protected static String toHexString(long hex) { return "0x" + Long.toHexString(hex); - } + } } diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java index 9ecaca75d..b770f3b05 100644 --- a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java +++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java @@ -44,57 +44,57 @@ import com.jogamp.opengl.GLExtensions; /** * The GLDebugMessageHandler, handling GL_ARB_debug_output or GL_AMD_debug_output * debug messages.
    - * + * *

    An instance must be bound to the current thread's GLContext to achieve thread safety.

    - * - *

    A native callback function is registered at {@link #enable(boolean) enable(true)}, - * which forwards received messages to the added {@link GLDebugListener} directly. + * + *

    A native callback function is registered at {@link #enable(boolean) enable(true)}, + * which forwards received messages to the added {@link GLDebugListener} directly. * Hence the {@link GLDebugListener#messageSent(GLDebugMessage)} implementation shall * return as fast as possible.

    - * + * *

    In case no GL_ARB_debug_output is available, but GL_AMD_debug_output, * the messages are translated to ARB {@link GLDebugMessage}, using {@link GLDebugMessage#translateAMDEvent(javax.media.opengl.GLContext, long, int, int, int, String)}.

    */ public class GLDebugMessageHandler { private static final boolean DEBUG = Debug.debug("GLDebugMessageHandler"); - + private static final int EXT_ARB = 1; - private static final int EXT_AMD = 2; - + private static final int EXT_AMD = 2; + static { if ( !initIDs0() ) { throw new NativeWindowException("Failed to initialize GLDebugMessageHandler jmethodIDs"); - } + } } - - private final GLContextImpl ctx; + + private final GLContextImpl ctx; private final ListenerSyncedImplStub listenerImpl; - + // licefycle: init - EOL private String extName; private int extType; private long glDebugMessageCallbackProcAddress; - private boolean extAvailable; + private boolean extAvailable; private boolean synchronous; - + // licefycle: enable - disable/EOL private long handle; - + /** * @param ctx the associated GLContext * @param glDebugExtension chosen extension to use */ - public GLDebugMessageHandler(GLContextImpl ctx) { + public GLDebugMessageHandler(GLContextImpl ctx) { this.ctx = ctx; - this.listenerImpl = new ListenerSyncedImplStub(); + this.listenerImpl = new ListenerSyncedImplStub(); this.glDebugMessageCallbackProcAddress = 0; this.extName = null; this.extType = 0; - this.extAvailable = false; + this.extAvailable = false; this.handle = 0; this.synchronous = true; } - + public void init(boolean enable) { if(DEBUG) { System.err.println("GLDebugMessageHandler.init("+enable+")"); @@ -106,13 +106,13 @@ public class GLDebugMessageHandler { System.err.println("GLDebugMessageHandler.init("+enable+") .. n/a"); } } - + private final long getAddressFor(final ProcAddressTable table, final String functionName) { return AccessController.doPrivileged(new PrivilegedAction() { public Long run() { try { return Long.valueOf( table.getAddressFor(functionName) ); - } catch (IllegalArgumentException iae) { + } catch (IllegalArgumentException iae) { return Long.valueOf(0); } } @@ -124,12 +124,12 @@ public class GLDebugMessageHandler { if( isAvailable()) { return; } - + if( !ctx.isGLDebugEnabled() ) { if(DEBUG) { System.err.println("GLDebugMessageHandler: GL DEBUG not set in ARB ctx options: "+ctx.getGLVersion()); } - return; + return; } if(Platform.OS_TYPE == Platform.OSType.WINDOWS && Platform.is32Bit()) { // Currently buggy, ie. throws an exception after leaving the native callback. @@ -149,93 +149,93 @@ public class GLDebugMessageHandler { if(DEBUG) { System.err.println("GLDebugMessageHandler: Using extension: <"+extName+">"); } - + if(0 == extType) { if(DEBUG) { System.err.println("GLDebugMessageHandler: No extension available! "+ctx.getGLVersion()); System.err.println("GL_EXTENSIONS "+ctx.getGLExtensionCount()); - System.err.println(ctx.getGLExtensionsString()); + System.err.println(ctx.getGLExtensionsString()); } return; } - + final ProcAddressTable procAddressTable = ctx.getGLProcAddressTable(); if( !ctx.isGLES1() && !ctx.isGLES2() ) { switch(extType) { - case EXT_ARB: + case EXT_ARB: glDebugMessageCallbackProcAddress = getAddressFor(procAddressTable, "glDebugMessageCallbackARB"); break; - case EXT_AMD: + case EXT_AMD: glDebugMessageCallbackProcAddress = getAddressFor(procAddressTable, "glDebugMessageCallbackAMD"); break; } } else { glDebugMessageCallbackProcAddress = 0; if(DEBUG) { - System.err.println("Non desktop context not supported"); - } + System.err.println("Non desktop context not supported"); + } } extAvailable = 0 < extType && null != extName && 0 != glDebugMessageCallbackProcAddress; - + if(DEBUG) { System.err.println("GLDebugMessageHandler: extAvailable: "+extAvailable+", glDebugMessageCallback* : 0x"+Long.toHexString(glDebugMessageCallbackProcAddress)); } - + if(!extAvailable) { glDebugMessageCallbackProcAddress = 0; } - + handle = 0; } public final boolean isAvailable() { return extAvailable; } - + /** - * @return The extension implementing the GLDebugMessage feature, - * either {@link #GL_ARB_debug_output} or {@link #GL_AMD_debug_output}. - * If unavailable null is returned. + * @return The extension implementing the GLDebugMessage feature, + * either {@link #GL_ARB_debug_output} or {@link #GL_AMD_debug_output}. + * If unavailable null is returned. */ public final String getExtension() { return extName; } - + public final boolean isExtensionARB() { return extName == GLExtensions.ARB_debug_output; } - + public final boolean isExtensionAMD() { return extName == GLExtensions.AMD_debug_output; } - + /** - * @see javax.media.opengl.GLContext#isGLDebugSynchronous() + * @see javax.media.opengl.GLContext#isGLDebugSynchronous() */ public final boolean isSynchronous() { return synchronous; } - + /** - * @see javax.media.opengl.GLContext#setGLDebugSynchronous(boolean) + * @see javax.media.opengl.GLContext#setGLDebugSynchronous(boolean) */ public final void setSynchronous(boolean synchronous) { this.synchronous = synchronous; if( isEnabled() ) { setSynchronousImpl(); } - } + } private final void setSynchronousImpl() { if(isExtensionARB()) { if(synchronous) { ctx.getGL().glEnable(GL2GL3.GL_DEBUG_OUTPUT_SYNCHRONOUS); } else { ctx.getGL().glDisable(GL2GL3.GL_DEBUG_OUTPUT_SYNCHRONOUS); - } + } if(DEBUG) { System.err.println("GLDebugMessageHandler: synchronous "+synchronous); } } } - + /** - * @see javax.media.opengl.GLContext#enableGLDebugMessage(boolean) + * @see javax.media.opengl.GLContext#enableGLDebugMessage(boolean) */ public final void enable(boolean enable) throws GLException { ctx.validateCurrent(); @@ -243,7 +243,7 @@ public class GLDebugMessageHandler { return; } enableImpl(enable); - } + } final void enableImpl(boolean enable) throws GLException { if(enable) { if(0 == handle) { @@ -257,19 +257,19 @@ public class GLDebugMessageHandler { if(0 != handle) { unregister0(glDebugMessageCallbackProcAddress, handle); handle = 0; - } + } } if(DEBUG) { System.err.println("GLDebugMessageHandler: enable("+enable+") -> 0x" + Long.toHexString(handle)); } } - + public final boolean isEnabled() { return 0 != handle; } - public final int listenerSize() { - return listenerImpl.size(); + public final int listenerSize() { + return listenerImpl.size(); } - + public final void addListener(GLDebugListener listener) { listenerImpl.addListener(-1, listener); } @@ -277,11 +277,11 @@ public class GLDebugMessageHandler { public final void addListener(int index, GLDebugListener listener) { listenerImpl.addListener(index, listener); } - + public final void removeListener(GLDebugListener listener) { listenerImpl.removeListener(listener); } - + private final void sendMessage(GLDebugMessage msg) { synchronized(listenerImpl) { if(DEBUG) { @@ -293,10 +293,10 @@ public class GLDebugMessageHandler { } } } - + public static class StdErrGLDebugListener implements GLDebugListener { boolean threadDump; - + public StdErrGLDebugListener(boolean threadDump) { this.threadDump = threadDump; } @@ -305,13 +305,13 @@ public class GLDebugMessageHandler { if(threadDump) { Thread.dumpStack(); } - } + } } - + // // native -> java // - + protected final void glDebugMessageARB(int source, int type, int id, int severity, String msg) { final GLDebugMessage event = new GLDebugMessage(ctx, System.currentTimeMillis(), source, type, id, severity, msg); sendMessage(event); @@ -321,11 +321,11 @@ public class GLDebugMessageHandler { final GLDebugMessage event = GLDebugMessage.translateAMDEvent(ctx, System.currentTimeMillis(), id, category, severity, msg); sendMessage(event); } - + // // java -> native - // - + // + private static native boolean initIDs0(); private native long register0(long glDebugMessageCallbackProcAddress, int extType); private native void unregister0(long glDebugMessageCallbackProcAddress, long handle); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index f5ceb8058..1e4cb38fa 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -95,14 +95,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } } catch (GLException gle) { if(DEBUG) { - System.err.println("Catched Exception on thread "+getThreadName()); + System.err.println("Catched Exception on thread "+getThreadName()); gle.printStackTrace(); } } return null; } protected abstract SharedResourceRunner.Resource getOrCreateSharedResourceImpl(AbstractGraphicsDevice device); - + /** * Returns the shared context mapped to the device {@link AbstractGraphicsDevice#getConnection()}, * either a pre-existing or newly created, or null if creation failed or not supported.
    @@ -176,7 +176,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(target, true); if(null != ols) { final GLCapabilitiesImmutable chosenCapsMod = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(chosenCaps, this, adevice); - + // layered surface -> Offscreen/[FBO|PBuffer] if( !chosenCapsMod.isFBO() && !chosenCapsMod.isPBuffer() ) { throw new GLException("Neither FBO nor Pbuffer is available for "+chosenCapsMod+", "+target); @@ -193,10 +193,10 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } if( ! ( target instanceof MutableSurface ) ) { throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen layered surface: "+target); - } + } if( chosenCapsMod.isFBO() ) { result = createFBODrawableImpl(target, chosenCapsMod, 0); - } else { + } else { result = createOffscreenDrawableImpl(target); } } else if(chosenCaps.isOnscreen()) { @@ -217,7 +217,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { throw new IllegalArgumentException("Passed NativeSurface must implement MutableSurface for offscreen: "+target); } if( chosenCaps.isFBO() && isFBOAvailable ) { - // need to hook-up a native dummy surface since source may not have & use minimum GLCapabilities for it w/ same profile + // need to hook-up a native dummy surface since source may not have & use minimum GLCapabilities for it w/ same profile final ProxySurface dummySurface = createDummySurfaceImpl(adevice, false, new GLCapabilities(chosenCaps.getGLProfile()), (GLCapabilitiesImmutable)config.getRequestedCapabilities(), null, 64, 64); dummySurface.setUpstreamSurfaceHook(new DelegatedUpstreamSurfaceHookWithSurfaceSize(dummySurface.getUpstreamSurfaceHook(), target)); result = createFBODrawableImpl(dummySurface, chosenCaps, 0); @@ -245,7 +245,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { // // PBuffer Offscreen GLAutoDrawable construction // - + @Override public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device, GLProfile glp); @@ -271,7 +271,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { GLDrawableImpl drawable = null; device.lock(); try { - drawable = createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, + drawable = createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, new UpstreamSurfaceHookMutableSize(width, height) ) ); if(null != drawable) { drawable.setRealized(true); @@ -294,9 +294,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } - return GLContext.isFBOAvailable(device, glp); + return GLContext.isFBOAvailable(device, glp); } - + @Override public final GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable capsRequested, @@ -311,7 +311,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } return new GLOffscreenAutoDrawableImpl( drawable, context, null, null); } - + @Override public final GLDrawable createOffscreenDrawable(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable capsRequested, @@ -324,18 +324,18 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } - + final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, this, device); device.lock(); try { if( capsChosen.isFBO() ) { - // Use minimum GLCapabilities for the dummy surface w/ same profile + // Use minimum GLCapabilities for the dummy surface w/ same profile final ProxySurface dummySurface = createDummySurfaceImpl(device, true, new GLCapabilities(capsChosen.getGLProfile()), capsRequested, null, width, height); final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); return new GLFBODrawableImpl.ResizeableImpl(this, dummyDrawable, dummySurface, capsChosen, 0); - } - return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, + } + return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, new UpstreamSurfaceHookMutableSize(width, height) ) ); } finally { device.unlock(); @@ -343,7 +343,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } @Override - public final GLDrawable createDummyDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLProfile glp) { + public final GLDrawable createDummyDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLProfile glp) { final AbstractGraphicsDevice device = createNewDevice ? getOrCreateSharedDevice(deviceReq) : deviceReq; if(null == device) { throw new GLException("No shared device for requested: "+deviceReq+", createNewDevice "+createNewDevice); @@ -357,14 +357,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { device.unlock(); } } - - /** Creates a platform independent unrealized FBO offscreen GLDrawable */ + + /** Creates a platform independent unrealized FBO offscreen GLDrawable */ protected final GLFBODrawable createFBODrawableImpl(NativeSurface dummySurface, GLCapabilitiesImmutable fboCaps, int textureUnit) { final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); return new GLFBODrawableImpl(this, dummyDrawable, dummySurface, fboCaps, textureUnit); } - - /** Creates a platform dependent unrealized offscreen pbuffer/pixmap GLDrawable instance */ + + /** Creates a platform dependent unrealized offscreen pbuffer/pixmap GLDrawable instance */ protected abstract GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) ; /** @@ -381,10 +381,10 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @param capsChosen * @param capsRequested * @param chooser the custom chooser, may be null for default - * @param upstreamHook surface size information and optional control of the surface's lifecycle + * @param upstreamHook surface size information and optional control of the surface's lifecycle * @return the created {@link MutableSurface} instance w/o defined surface handle */ - protected abstract ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, + protected abstract ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook); @@ -399,7 +399,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @param deviceReq which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. * @param requestedCaps * @param chooser the custom chooser, may be null for default - * @param width the initial width as returned by {@link NativeSurface#getWidth()}, not the actual dummy surface width. + * @param width the initial width as returned by {@link NativeSurface#getWidth()}, not the actual dummy surface width. * The latter is platform specific and small * @param height the initial height as returned by {@link NativeSurface#getHeight()}, not the actual dummy surface height, * The latter is platform specific and small @@ -419,7 +419,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { device.unlock(); } } - + /** * A dummy surface is not visible on screen and will not be used to render directly to, * it maybe on- or offscreen. @@ -433,22 +433,22 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @param chosenCaps * @param requestedCaps * @param chooser the custom chooser, may be null for default - * @param width the initial width as returned by {@link NativeSurface#getWidth()}, not the actual dummy surface width. + * @param width the initial width as returned by {@link NativeSurface#getWidth()}, not the actual dummy surface width. * The latter is platform specific and small * @param height the initial height as returned by {@link NativeSurface#getHeight()}, not the actual dummy surface height, * The latter is platform specific and small * @return the created {@link ProxySurface} instance w/o defined surface handle but platform specific {@link UpstreamSurfaceHook}. */ - public abstract ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, + public abstract ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height); //--------------------------------------------------------------------------- // // ProxySurface (Wrapped pre-existing native surface) construction // - + @Override - public ProxySurface createProxySurface(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, + public ProxySurface createProxySurface(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { final AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); if(null == device) { @@ -473,7 +473,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { *

    * @param upstream TODO */ - protected abstract ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, + protected abstract ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream); //--------------------------------------------------------------------------- diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 5418fbaf3..2cf384fd7 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -63,12 +63,12 @@ import javax.media.opengl.GLRunnable; public class GLDrawableHelper { /** true if property jogl.debug.GLDrawable.PerfStats is defined. */ private static final boolean PERF_STATS; - + static { Debug.initSingleton(); PERF_STATS = Debug.isPropertyDefined("jogl.debug.GLDrawable.PerfStats", true); } - + protected static final boolean DEBUG = GLDrawableImpl.DEBUG; private final Object listenersLock = new Object(); private final ArrayList listeners = new ArrayList(); @@ -120,7 +120,7 @@ public class GLDrawableHelper { /** Limit release calls of {@link #forceNativeRelease(GLContext)} to {@value}. */ private static final int MAX_RELEASE_ITER = 512; - + /** * Since GLContext's {@link GLContext#makeCurrent()} and {@link GLContext#release()} * is recursive, a call to {@link GLContext#release()} may not natively release the context. @@ -138,36 +138,36 @@ public class GLDrawableHelper { System.err.println("GLDrawableHelper.forceNativeRelease() #"+releaseCount+" -- currentThread "+Thread.currentThread()+" -> "+GLContext.getCurrent()); } } while( MAX_RELEASE_ITER > releaseCount && ctx.isCurrent() ); - + if( ctx.isCurrent() ) { throw new GLException("Context still current after "+MAX_RELEASE_ITER+" releases: "+ctx); } } - + /** * Switch {@link GLContext} / {@link GLDrawable} association. *

    * The oldCtx will be destroyed if destroyPrevCtx is true, - * otherwise dis-associate oldCtx from drawable + * otherwise dis-associate oldCtx from drawable * via {@link GLContext#setGLDrawable(GLDrawable, boolean) oldCtx.setGLDrawable(null, true);}. *

    *

    - * Re-associate newCtx with drawable + * Re-associate newCtx with drawable * via {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. *

    - *

    + *

    * If the old or new context was current on this thread, it is being released before switching the drawable. *

    *

    * No locking is being performed on the drawable, caller is required to take care of it. *

    - * + * * @param drawable the drawable which context is changed * @param oldCtx the old context, maybe null. * @param destroyOldCtx if true, destroy the oldCtx * @param newCtx the new context, maybe null for dis-association. * @param newCtxCreationFlags additional creation flags if newCtx is not null and not been created yet, see {@link GLContext#setContextCreationFlags(int)} - * + * * @see GLAutoDrawable#setContext(GLContext, boolean) */ public static final void switchContext(GLDrawable drawable, GLContext oldCtx, boolean destroyOldCtx, GLContext newCtx, int newCtxCreationFlags) { @@ -178,16 +178,16 @@ public class GLDrawableHelper { oldCtx.setGLDrawable(null, true); // dis-associate old pair } } - + if(null!=newCtx) { newCtx.setContextCreationFlags(newCtxCreationFlags); - newCtx.setGLDrawable(drawable, true); // re-associate new pair + newCtx.setGLDrawable(drawable, true); // re-associate new pair } } - + /** * If the drawable is not realized, OP is a NOP. - *
      + *
        *
      • release context if current
      • *
      • destroy old drawable
      • *
      • create new drawable
      • @@ -197,12 +197,12 @@ public class GLDrawableHelper { *

        * Locking is performed via {@link GLContext#makeCurrent()} on the passed context. *

        - * + * * @param drawable * @param context maybe null * @return the new drawable */ - public static final GLDrawableImpl recreateGLDrawable(GLDrawableImpl drawable, GLContext context) { + public static final GLDrawableImpl recreateGLDrawable(GLDrawableImpl drawable, GLContext context) { if( ! drawable.isRealized() ) { return drawable; } @@ -210,7 +210,7 @@ public class GLDrawableHelper { final GLDrawableFactory factory = drawable.getFactory(); final NativeSurface surface = drawable.getNativeSurface(); final ProxySurface proxySurface = (surface instanceof ProxySurface) ? (ProxySurface)surface : null; - + if( null != context ) { // Ensure to sync GL command stream if( currentContext != context ) { @@ -219,7 +219,7 @@ public class GLDrawableHelper { context.getGL().glFinish(); context.setGLDrawable(null, true); // dis-associate } - + if(null != proxySurface) { proxySurface.enableUpstreamSurfaceHookLifecycle(false); } @@ -236,18 +236,18 @@ public class GLDrawableHelper { if(null != context) { context.setGLDrawable(drawable, true); // re-association } - + if( null != currentContext ) { currentContext.makeCurrent(); } return drawable; } - + /** * Performs resize operation on the given drawable, assuming it is offscreen. *

        * The {@link GLDrawableImpl}'s {@link NativeSurface} is being locked during operation. - * In case the holder is an auto drawable or similar, it's lock shall be claimed by the caller. + * In case the holder is an auto drawable or similar, it's lock shall be claimed by the caller. *

        *

        * May recreate the drawable via {@link #recreateGLDrawable(GLDrawableImpl, GLContext)} @@ -257,10 +257,10 @@ public class GLDrawableHelper { * FBO drawables are resized w/o drawable destruction. *

        *

        - * Offscreen resize operation is validated w/ drawable size in the end. + * Offscreen resize operation is validated w/ drawable size in the end. * An exception is thrown if not successful. *

        - * + * * @param drawable * @param context * @param newWidth the new width, it's minimum is capped to 1 @@ -270,7 +270,7 @@ public class GLDrawableHelper { * @throws GLException may be thrown a resize operation */ public static final GLDrawableImpl resizeOffscreenDrawable(GLDrawableImpl drawable, GLContext context, int newWidth, int newHeight) - throws NativeWindowException, GLException + throws NativeWindowException, GLException { if(drawable.getChosenGLCapabilities().isOnscreen()) { throw new NativeWindowException("Drawable is not offscreen: "+drawable); @@ -288,7 +288,7 @@ public class GLDrawableHelper { } if(0>=newWidth) { newWidth = 1; validateSize=false; } if(0>=newHeight) { newHeight = 1; validateSize=false; } - // propagate new size + // propagate new size if(ns instanceof ProxySurface) { final ProxySurface ps = (ProxySurface) ns; final UpstreamSurfaceHook ush = ps.getUpstreamSurfaceHook(); @@ -301,7 +301,7 @@ public class GLDrawableHelper { System.err.println("GLDrawableHelper.resizeOffscreenDrawable: Drawable's offscreen surface n.a. ProxySurface, but "+ns.getClass().getName()+": "+ns); } if(drawable instanceof GLFBODrawable) { - if( null != context && context.isCreated() ) { + if( null != context && context.isCreated() ) { ((GLFBODrawable) drawable).resetSize(context.getGL()); } } else { @@ -315,7 +315,7 @@ public class GLDrawableHelper { } return drawable; } - + public final void addGLEventListener(GLEventListener listener) { addGLEventListener(-1, listener); } @@ -328,14 +328,14 @@ public class GLDrawableHelper { // GLEventListener may be added after context is created, // hence we earmark initialization for the next display call. listenersToBeInit.add(listener); - + listeners.add(index, listener); } } /** * Note that no {@link GLEventListener#dispose(GLAutoDrawable)} call is being issued - * due to the lack of a current context. + * due to the lack of a current context. * Consider calling {@link #disposeGLEventListener(GLAutoDrawable, GLDrawable, GLContext, GLEventListener)}. * @return the removed listener, or null if listener was not added */ @@ -356,11 +356,11 @@ public class GLDrawableHelper { return listener; } } - + public final int getGLEventListenerCount() { synchronized(listenersLock) { return listeners.size(); - } + } } public final GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException { @@ -371,13 +371,13 @@ public class GLDrawableHelper { return listeners.get(index); } } - + public final boolean getGLEventListenerInitState(GLEventListener listener) { synchronized(listenersLock) { return !listenersToBeInit.contains(listener); } } - + public final void setGLEventListenerInitState(GLEventListener listener, boolean initialized) { synchronized(listenersLock) { if(initialized) { @@ -387,16 +387,16 @@ public class GLDrawableHelper { } } } - + /** - * Disposes the given {@link GLEventListener} via {@link GLEventListener#dispose(GLAutoDrawable)} + * Disposes the given {@link GLEventListener} via {@link GLEventListener#dispose(GLAutoDrawable)} * if it has been initialized and added to this queue. *

        * If remove is true, the {@link GLEventListener} is removed from this drawable queue before disposal, * otherwise marked uninitialized. *

        *

        - * Please consider using {@link #disposeGLEventListener(GLAutoDrawable, GLDrawable, GLContext, GLEventListener)} + * Please consider using {@link #disposeGLEventListener(GLAutoDrawable, GLDrawable, GLContext, GLEventListener)} * for correctness, i.e. encapsulating all calls w/ makeCurrent etc. *

        * @param autoDrawable @@ -405,9 +405,9 @@ public class GLDrawableHelper { */ public final GLEventListener disposeGLEventListener(GLAutoDrawable autoDrawable, GLEventListener listener, boolean remove) { synchronized(listenersLock) { - if( remove ) { + if( remove ) { if( listeners.remove(listener) ) { - if( !listenersToBeInit.remove(listener) ) { + if( !listenersToBeInit.remove(listener) ) { listener.dispose(autoDrawable); } return listener; @@ -417,12 +417,12 @@ public class GLDrawableHelper { listener.dispose(autoDrawable); listenersToBeInit.add(listener); return listener; - } + } } } return null; } - + /** * Disposes all added initialized {@link GLEventListener}s via {@link GLEventListener#dispose(GLAutoDrawable)}. *

        @@ -456,20 +456,20 @@ public class GLDrawableHelper { listenersToBeInit.add(listener); disposeCount++; } - } + } } } return disposeCount; } /** - * Principal helper method which runs {@link #disposeGLEventListener(GLAutoDrawable, GLEventListener, boolean)} + * Principal helper method which runs {@link #disposeGLEventListener(GLAutoDrawable, GLEventListener, boolean)} * with the context made current. *

        - * If an {@link GLAnimatorControl} is being attached and the current thread is different + * If an {@link GLAnimatorControl} is being attached and the current thread is different * than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation. *

        - * + * * @param autoDrawable * @param context * @param listener @@ -477,7 +477,7 @@ public class GLDrawableHelper { */ public final GLEventListener disposeGLEventListener(final GLAutoDrawable autoDrawable, final GLDrawable drawable, - final GLContext context, + final GLContext context, final GLEventListener listener, final boolean remove) { synchronized(listenersLock) { @@ -485,7 +485,7 @@ public class GLDrawableHelper { if( listenersToBeInit.contains(listener) ) { if( remove ) { listenersToBeInit.remove(listener); - return listeners.remove(listener) ? listener : null; + return listeners.remove(listener) ? listener : null; } return null; } @@ -498,21 +498,21 @@ public class GLDrawableHelper { } }; invokeGL(drawable, context, action, nop); - + if(isPaused) { animatorCtrl.resume(); } return res[0]; } - + /** - * Principal helper method which runs {@link #disposeAllGLEventListener(GLAutoDrawable, boolean)} + * Principal helper method which runs {@link #disposeAllGLEventListener(GLAutoDrawable, boolean)} * with the context made current. *

        - * If an {@link GLAnimatorControl} is being attached and the current thread is different + * If an {@link GLAnimatorControl} is being attached and the current thread is different * than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation. *

        - * + * * @param autoDrawable * @param context * @param remove @@ -521,21 +521,21 @@ public class GLDrawableHelper { final GLDrawable drawable, final GLContext context, final boolean remove) { - + final boolean isPaused = isAnimatorAnimatingOnOtherThread() && animatorCtrl.pause(); - + final Runnable action = new Runnable() { public void run() { disposeAllGLEventListener(autoDrawable, remove); } }; invokeGL(drawable, context, action, nop); - + if(isPaused) { animatorCtrl.resume(); } } - + private final void init(GLEventListener l, GLAutoDrawable drawable, boolean sendReshape, boolean setViewport) { l.init(drawable); if(sendReshape) { @@ -543,8 +543,8 @@ public class GLDrawableHelper { } } - /** - * The default init action to be called once after ctx is being created @ 1st makeCurrent(). + /** + * The default init action to be called once after ctx is being created @ 1st makeCurrent(). * @param sendReshape set to true if the subsequent display call won't reshape, otherwise false to avoid double reshape. **/ public final void init(GLAutoDrawable drawable, boolean sendReshape) { @@ -554,7 +554,7 @@ public class GLDrawableHelper { if( listenerCount > 0 ) { for (int i=0; i < listenerCount; i++) { final GLEventListener listener = _listeners.get(i) ; - + // If make ctx current, invoked by invokGL(..), results in a new ctx, init gets called. // This may happen not just for initial setup, but for ctx recreation due to resource change (drawable/window), // hence it must be called unconditional, always. @@ -571,7 +571,7 @@ public class GLDrawableHelper { public final void display(GLAutoDrawable drawable) { displayImpl(drawable); if( glRunnables.size()>0 && !execGLRunnables(drawable) ) { // glRunnables volatile OK; execGL.. only executed if size > 0 - displayImpl(drawable); + displayImpl(drawable); } } private final void displayImpl(GLAutoDrawable drawable) { @@ -580,7 +580,7 @@ public class GLDrawableHelper { final int listenerCount = _listeners.size(); for (int i=0; i < listenerCount; i++) { final GLEventListener listener = _listeners.get(i) ; - // GLEventListener may need to be init, + // GLEventListener may need to be init, // in case this one is added after the realization of the GLAutoDrawable if( listenersToBeInit.remove(listener) ) { init( listener, drawable, true /* sendReshape */, listenersToBeInit.size() + 1 == listenerCount /* setViewport if 1st init */ ); @@ -589,11 +589,11 @@ public class GLDrawableHelper { } } } - + private final void reshape(GLEventListener listener, GLAutoDrawable drawable, int x, int y, int width, int height, boolean setViewport, boolean checkInit) { if(checkInit) { - // GLEventListener may need to be init, + // GLEventListener may need to be init, // in case this one is added after the realization of the GLAutoDrawable synchronized(listenersLock) { if( listenersToBeInit.remove(listener) ) { @@ -627,7 +627,7 @@ public class GLDrawableHelper { _glRunnables = null; } } - + if(null!=_glRunnables) { for (int i=0; i < _glRunnables.size(); i++) { res = _glRunnables.get(i).run(drawable) && res; @@ -648,7 +648,7 @@ public class GLDrawableHelper { _glRunnables = null; } } - + if(null!=_glRunnables) { for (int i=0; i < _glRunnables.size(); i++) { _glRunnables.get(i).flush(); @@ -656,7 +656,7 @@ public class GLDrawableHelper { } } } - + public final void setAnimator(GLAnimatorControl animator) throws GLException { synchronized(glRunnablesLock) { if(animatorCtrl!=animator && null!=animator && null!=animatorCtrl) { @@ -693,7 +693,7 @@ public class GLDrawableHelper { * If wait is true the call blocks until the glRunnable * has been executed.

        *

        - * If wait is true and + * If wait is true and * {@link GLDrawable#isRealized()} returns false or {@link GLAutoDrawable#getContext()} returns null, * the call is ignored and returns false.
        * This helps avoiding deadlocking the caller. @@ -709,7 +709,7 @@ public class GLDrawableHelper { wait && ( !drawable.isRealized() || null==drawable.getContext() ) ) { return false; } - + GLRunnableTask rTask = null; Object rTaskLock = new Object(); Throwable throwable = null; @@ -743,13 +743,13 @@ public class GLDrawableHelper { } return true; } - + public final boolean invoke(GLAutoDrawable drawable, boolean wait, List newGLRunnables) { if( null == newGLRunnables || newGLRunnables.size() == 0 || null == drawable || wait && ( !drawable.isRealized() || null==drawable.getContext() ) ) { return false; } - + final int count = newGLRunnables.size(); GLRunnableTask rTask = null; Object rTaskLock = new Object(); @@ -785,18 +785,18 @@ public class GLDrawableHelper { } } } - return true; + return true; } public final void enqueue(GLRunnable glRunnable) { if( null == glRunnable) { return; - } + } synchronized(glRunnablesLock) { glRunnables.add( new GLRunnableTask(glRunnable, null, false) ); } } - + public final void setAutoSwapBufferMode(boolean enable) { autoSwapBufferMode = enable; } @@ -812,17 +812,17 @@ public class GLDrawableHelper { /** * Dedicates this instance's {@link GLContext} to the given thread.
        * The thread will exclusively claim the {@link GLContext} via {@link #display()} and not release it - * until {@link #destroy()} or setExclusiveContextThread(null) has been called. + * until {@link #destroy()} or setExclusiveContextThread(null) has been called. *

        * Default non-exclusive behavior is requested via setExclusiveContextThread(null), - * which will cause the next call of {@link #display()} on the exclusive thread to - * release the {@link GLContext}. Only after it's async release, {@link #getExclusiveContextThread()} + * which will cause the next call of {@link #display()} on the exclusive thread to + * release the {@link GLContext}. Only after it's async release, {@link #getExclusiveContextThread()} * will return null. *

        *

        * To release a previous made exclusive thread, a user issues setExclusiveContextThread(null) - * and may poll {@link #getExclusiveContextThread()} until it returns null, - * while the exclusive thread is still running. + * and may poll {@link #getExclusiveContextThread()} until it returns null, + * while the exclusive thread is still running. *

        *

        * Note: Setting a new exclusive thread without properly releasing a previous one @@ -833,7 +833,7 @@ public class GLDrawableHelper { * and spare redundant context switches. *

        * @param t the exclusive thread to claim the context, or null for default operation. - * @return previous exclusive context thread + * @return previous exclusive context thread * @throws GLException If an exclusive thread is still active but a new one is attempted to be set */ public final Thread setExclusiveContextThread(Thread t, GLContext context) throws GLException { @@ -857,7 +857,7 @@ public class GLDrawableHelper { ex.printStackTrace(); throw new GLException(ex); } - } + } exclusiveContextThread = t; } if (DEBUG) { @@ -865,14 +865,14 @@ public class GLDrawableHelper { } return oldExclusiveContextThread; } - + /** - * @see #setExclusiveContextThread(Thread, GLContext) + * @see #setExclusiveContextThread(Thread, GLContext) */ public final Thread getExclusiveContextThread() { return exclusiveContextThread; } - + private static final ThreadLocal perThreadInitAction = new ThreadLocal(); /** Principal helper method which runs a Runnable with the context @@ -904,15 +904,15 @@ public class GLDrawableHelper { } if(PERF_STATS) { - invokeGLImplStats(drawable, context, runnable, initAction); + invokeGLImplStats(drawable, context, runnable, initAction); } else { invokeGLImpl(drawable, context, runnable, initAction); } } - /** - * Principal helper method which runs - * {@link #disposeAllGLEventListener(GLAutoDrawable, boolean) disposeAllGLEventListener(autoDrawable, false)} + /** + * Principal helper method which runs + * {@link #disposeAllGLEventListener(GLAutoDrawable, boolean) disposeAllGLEventListener(autoDrawable, false)} * with the context made current. *

        * If destroyContext is true the context is destroyed in the end while holding the lock. @@ -940,7 +940,7 @@ public class GLDrawableHelper { } } - int res; + int res; try { res = context.makeCurrent(); if (GLContext.CONTEXT_NOT_CURRENT != res) { @@ -975,7 +975,7 @@ public class GLDrawableHelper { private final void invokeGLImpl(final GLDrawable drawable, final GLContext context, final Runnable runnable, - final Runnable initAction) { + final Runnable initAction) { final Thread currentThread = Thread.currentThread(); // Exclusive Cases: @@ -1013,7 +1013,7 @@ public class GLDrawableHelper { lastContext.release(); } } - + try { final boolean releaseContext; if( GLContext.CONTEXT_NOT_CURRENT == res ) { @@ -1110,7 +1110,7 @@ public class GLDrawableHelper { long tdX = 0; // release boolean ctxClaimed = false; boolean ctxReleased = false; - boolean ctxDestroyed = false; + boolean ctxDestroyed = false; try { final boolean releaseContext; if( GLContext.CONTEXT_NOT_CURRENT == res ) { @@ -1129,7 +1129,7 @@ public class GLDrawableHelper { } initAction.run(); } - tdR = System.currentTimeMillis(); + tdR = System.currentTimeMillis(); tdA = tdR - t0; // makeCurrent runnable.run(); tdS = System.currentTimeMillis(); @@ -1172,5 +1172,5 @@ public class GLDrawableHelper { } protected static String getThreadName() { return Thread.currentThread().getName(); } - + } diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index e1088da29..a79a3cf25 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -53,11 +53,11 @@ import javax.media.opengl.GLProfile; public abstract class GLDrawableImpl implements GLDrawable { protected static final boolean DEBUG = GLDrawableFactoryImpl.DEBUG; - + protected GLDrawableImpl(GLDrawableFactory factory, NativeSurface comp, boolean realized) { this(factory, comp, (GLCapabilitiesImmutable) comp.getGraphicsConfiguration().getRequestedCapabilities(), realized); } - + protected GLDrawableImpl(GLDrawableFactory factory, NativeSurface comp, GLCapabilitiesImmutable requestedCapabilities, boolean realized) { this.factory = factory; this.surface = comp; @@ -100,20 +100,20 @@ public abstract class GLDrawableImpl implements GLDrawable { } } finally { unlockSurface(); - } + } surface.surfaceUpdated(this, surface, System.currentTimeMillis()); } - + /** * Platform and implementation depending surface swap. *

        The surface is locked.

        *

        - * If doubleBuffered is true, + * If doubleBuffered is true, * an actual platform dependent surface swap shall be executed. *

        *

        - * If doubleBuffered is false, - * {@link GL#glFlush()} has been called already and + * If doubleBuffered is false, + * {@link GL#glFlush()} has been called already and * the implementation may execute implementation specific code. *

        * @param doubleBuffered indicates whether double buffering is enabled, see above. @@ -143,19 +143,19 @@ public abstract class GLDrawableImpl implements GLDrawable { return surface; } - /** + /** * called with locked surface @ setRealized(false) or @ lockSurface(..) when surface changed *

        * Must be paired w/ {@link #createHandle()}. - *

        + *

        */ protected void destroyHandle() {} - /** + /** * called with locked surface @ setRealized(true) or @ lockSurface(..) when surface changed *

        * Must be paired w/ {@link #destroyHandle()}. - *

        + *

        */ protected void createHandle() {} @@ -213,16 +213,16 @@ public abstract class GLDrawableImpl implements GLDrawable { System.err.println(getThreadName() + ": setRealized: "+getClass().getName()+" "+this.realized+" == "+realizedArg); } } - + /** - * Platform specific realization of drawable + * Platform specific realization of drawable */ protected abstract void setRealizedImpl(); /** * Callback for special implementations, allowing *
          - *
        • to associate bound context to this drawable (bound == true) + *
        • to associate bound context to this drawable (bound == true) * or to remove such association (bound == false).
        • *
        • to trigger GLContext/GLDrawable related lifecycle: construct, destroy.
        • *
        @@ -239,8 +239,8 @@ public abstract class GLDrawableImpl implements GLDrawable { * @param bound if true create an association, otherwise remove it */ protected void associateContext(GLContext ctx, boolean bound) { } - - /** + + /** * Callback for special implementations, allowing GLContext to trigger GL related lifecycle: makeCurrent, release. *

        * If current is true, the context has just been made current. @@ -252,13 +252,13 @@ public abstract class GLDrawableImpl implements GLDrawable { * Being called by {@link GLContextImpl#contextMadeCurrent(boolean)}. *

        * @see #associateContext(GLContext, boolean) - */ + */ protected void contextMadeCurrent(GLContext glc, boolean current) { } /** Callback for special implementations, allowing GLContext to fetch a custom default render framebuffer. Defaults to zero.*/ protected int getDefaultDrawFramebuffer() { return 0; } /** Callback for special implementations, allowing GLContext to fetch a custom default read framebuffer. Defaults to zero. */ - protected int getDefaultReadFramebuffer() { return 0; } + protected int getDefaultReadFramebuffer() { return 0; } /** Callback for special implementations, allowing GLContext to fetch a custom default read buffer of current framebuffer. */ protected int getDefaultReadBuffer(GL gl) { if(gl.isGLES() || getChosenGLCapabilities().getDoubleBuffered()) { @@ -266,9 +266,9 @@ public abstract class GLDrawableImpl implements GLDrawable { // Note-2: ES3 only supports GL_BACK, GL_NONE or GL_COLOR_ATTACHMENT0+i return GL.GL_BACK; } - return GL.GL_FRONT ; + return GL.GL_FRONT ; } - + @Override public final boolean isRealized() { return realized; @@ -286,22 +286,22 @@ public abstract class GLDrawableImpl implements GLDrawable { @Override public boolean isGLOriented() { - return true; + return true; } - - /** + + /** * {@link NativeSurface#lockSurface() Locks} the underlying windowing toolkit's {@link NativeSurface surface}. *

        * If drawable is {@link #setRealized(boolean) realized}, - * the {@link #getHandle() drawable handle} is valid after successfully {@link NativeSurface#lockSurface() locking} + * the {@link #getHandle() drawable handle} is valid after successfully {@link NativeSurface#lockSurface() locking} * it's {@link NativeSurface surface} until being {@link #unlockSurface() unlocked}. *

        *

        - * In case the {@link NativeSurface surface} has changed as indicated by it's + * In case the {@link NativeSurface surface} has changed as indicated by it's * {@link NativeSurface#lockSurface() lock} result {@link NativeSurface#LOCK_SURFACE_CHANGED}, - * the implementation is required to update this information as needed within it's implementation. + * the implementation is required to update this information as needed within it's implementation. *

        - * + * * @see NativeSurface#lockSurface() * @see #getHandle() */ @@ -312,7 +312,7 @@ public abstract class GLDrawableImpl implements GLDrawable { final long _handle1 = getHandle(); destroyHandle(); createHandle(); - final long _handle2 = getHandle(); + final long _handle2 = getHandle(); if(DEBUG) { if( _handle1 != _handle2) { System.err.println(getThreadName() + ": Drawable handle changed: "+toHexString(_handle1)+" -> "+toHexString(_handle2)); @@ -320,14 +320,14 @@ public abstract class GLDrawableImpl implements GLDrawable { } } return lockRes; - + } - /** + /** * {@link NativeSurface#unlockSurface() Unlocks} the underlying windowing toolkit {@link NativeSurface surface}, * which may render the {@link #getHandle() drawable handle} invalid. - * - * @see NativeSurface#unlockSurface() + * + * @see NativeSurface#unlockSurface() * @see #getHandle() */ public final void unlockSurface() { diff --git a/src/jogl/classes/jogamp/opengl/GLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/GLDynamicLibraryBundleInfo.java index 8ba9f617b..640e181ae 100644 --- a/src/jogl/classes/jogamp/opengl/GLDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/GLDynamicLibraryBundleInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl; import com.jogamp.common.os.DynamicLibraryBundle; @@ -36,7 +36,7 @@ public abstract class GLDynamicLibraryBundleInfo implements DynamicLibraryBundle protected GLDynamicLibraryBundleInfo() { } - /** + /** * Returns true, * since we might load a desktop GL library and allow symbol access to subsequent libs. *

        @@ -47,19 +47,19 @@ public abstract class GLDynamicLibraryBundleInfo implements DynamicLibraryBundle *

        */ public final boolean shallLinkGlobal() { return true; } - + /** * {@inheritDoc} *

        * Returns false. *

        - */ + */ @Override public boolean shallLookupGlobal() { return false; } @Override public final RunnableExecutor getLibLoaderExecutor() { return DynamicLibraryBundle.getDefaultRunnableExecutor(); - } + } } diff --git a/src/jogl/classes/jogamp/opengl/GLDynamicLookupHelper.java b/src/jogl/classes/jogamp/opengl/GLDynamicLookupHelper.java index 1ed73f15e..421f06205 100644 --- a/src/jogl/classes/jogamp/opengl/GLDynamicLookupHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDynamicLookupHelper.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl; import com.jogamp.common.os.DynamicLibraryBundle; diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index f2248b388..ab318927c 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -26,11 +26,11 @@ import com.jogamp.opengl.JoglVersion; * to initialize the {@link FBObject} instance. *

        *

        - * It utilizes the context current hook {@link #contextMadeCurrent(GLContext, boolean) contextMadeCurrent(context, true)} + * It utilizes the context current hook {@link #contextMadeCurrent(GLContext, boolean) contextMadeCurrent(context, true)} * to {@link FBObject#bind(GL) bind} the FBO. *

        * See {@link GLFBODrawable} for double buffering details. - * + * * @see GLDrawableImpl#contextRealized(GLContext, boolean) * @see GLDrawableImpl#contextMadeCurrent(GLContext, boolean) * @see GLDrawableImpl#getDefaultDrawFramebuffer() @@ -39,21 +39,21 @@ import com.jogamp.opengl.JoglVersion; public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { protected static final boolean DEBUG; protected static final boolean DEBUG_SWAP; - + static { Debug.initSingleton(); DEBUG = GLDrawableImpl.DEBUG || Debug.debug("FBObject"); DEBUG_SWAP = DEBUG || Debug.isPropertyDefined("jogl.debug.FBObject.Swap", true); } - + private final GLDrawableImpl parent; private GLCapabilitiesImmutable origParentChosenCaps; - + private boolean initialized; private int texUnit; private int samples; private boolean fboResetQuirk; - + private FBObject[] fbos; private int fboIBack; // points to GL_BACK buffer private int fboIFront; // points to GL_FRONT buffer @@ -64,19 +64,19 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { private boolean fboSwapped; /** dump fboResetQuirk info only once pre ClassLoader and only in DEBUG mode */ - private static volatile boolean resetQuirkInfoDumped = false; - + private static volatile boolean resetQuirkInfoDumped = false; + /** number of FBOs for double buffering. TODO: Possible to configure! */ - private static final int bufferCount = 2; - + private static final int bufferCount = 2; + // private DoubleBufferMode doubleBufferMode; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support - + private SwapBufferContext swapBufferContext; - + public static interface SwapBufferContext { public void swapBuffers(boolean doubleBuffered); } - + /** * @param factory * @param parent @@ -84,7 +84,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { * @param fboCaps the requested FBO capabilities * @param textureUnit */ - protected GLFBODrawableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, NativeSurface surface, + protected GLFBODrawableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, NativeSurface surface, GLCapabilitiesImmutable fboCaps, int textureUnit) { super(factory, surface, fboCaps, false); this.initialized = false; @@ -94,13 +94,13 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { this.texUnit = textureUnit; this.samples = fboCaps.getNumSamples(); fboResetQuirk = false; - + // default .. // TODO: Add or remove TEXTURE (only) DoubleBufferMode support // this.doubleBufferMode = ( samples > 0 || fboCaps.getDoubleBuffered() ) ? DoubleBufferMode.FBO : DoubleBufferMode.NONE ; - + this.swapBufferContext = null; } - + private final void initialize(boolean realize, GL gl) { if( !initialized && !realize ) { if( DEBUG ) { @@ -114,7 +114,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { } if(realize) { final GLCapabilities chosenFBOCaps = (GLCapabilities) getChosenGLCapabilities(); // cloned at setRealized(true) - + final int maxSamples = gl.getMaxRenderbufferSamples(); { final int newSamples = samples <= maxSamples ? samples : maxSamples; @@ -123,7 +123,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { } samples = newSamples; } - + final int fbosN; if(samples > 0) { fbosN = 1; @@ -136,7 +136,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { fbos = new FBObject[fbosN]; fboIBack = 0; // head fboIFront = fbos.length - 1; // tail - + for(int i=0; i "+newSamples+"/"+maxSamples); } @@ -297,11 +297,11 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { System.err.println("GLFBODrawableImpl.reset(newSamples "+newSamples+"): END "+this); } } - + // // GLDrawable // - + @Override public final GLContext createContext(GLContext shareWith) { final GLContext ctx = parent.createContext(shareWith); @@ -312,7 +312,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { // // GLDrawableImpl // - + @Override public final GLDynamicLookupHelper getGLDynamicLookupHelper() { return parent.getGLDynamicLookupHelper(); @@ -320,13 +320,13 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { @Override protected final int getDefaultDrawFramebuffer() { return initialized ? fbos[fboIBack].getWriteFramebuffer() : 0; } - + @Override protected final int getDefaultReadFramebuffer() { return initialized ? fbos[fboIFront].getReadFramebuffer() : 0; } @Override protected final int getDefaultReadBuffer(GL gl) { return initialized ? fbos[fboIFront].getDefaultReadBuffer() : GL.GL_COLOR_ATTACHMENT0 ; } - + @Override protected final void setRealizedImpl() { final MutableGraphicsConfiguration msConfig = (MutableGraphicsConfiguration) surface.getGraphicsConfiguration(); @@ -341,12 +341,12 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { parent.setRealized(false); } } - + @Override protected void associateContext(GLContext glc, boolean bound) { - initialize(bound, glc.getGL()); + initialize(bound, glc.getGL()); } - + @Override protected final void contextMadeCurrent(GLContext glc, boolean current) { final GL gl = glc.getGL(); @@ -367,7 +367,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { } } } - + @Override protected void swapBuffersImpl(boolean doubleBuffered) { final GLContext ctx = GLContext.getCurrent(); @@ -389,7 +389,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { swapFBOImplPost(ctx); } } - + private final void swapFBOImplPost(GLContext glc) { // Safely reset the previous front FBO - after completing propagating swap if(0 <= pendingFBOReset) { @@ -398,18 +398,18 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { pendingFBOReset = -1; } } - + private final void swapFBOImpl(GLContext glc) { final GL gl = glc.getGL(); fbos[fboIBack].markUnbound(); // fast path, use(gl,..) is called below - + if(DEBUG) { int _fboIFront = ( fboIFront + 1 ) % fbos.length; if(_fboIFront != fboIBack) { throw new InternalError("XXX: "+_fboIFront+"!="+fboIBack); } } fboIFront = fboIBack; fboIBack = ( fboIBack + 1 ) % fbos.length; - + final Colorbuffer colorbuffer = samples > 0 ? fbos[fboIFront].getSamplingSink() : fbos[fboIFront].getColorbuffer(0); final TextureAttachment texAttachment; if(colorbuffer instanceof TextureAttachment) { @@ -423,12 +423,12 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { } gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit); fbos[fboIFront].use(gl, texAttachment); - - /* Included in above use command: + + /* Included in above use command: gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, fbos[fboIBack].getDrawFramebuffer()); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, fbos[fboIFront].getReadFramebuffer()); } */ - + if(DEBUG_SWAP) { System.err.println("Post FBO swap(X): fboI back "+fboIBack+", front "+fboIFront+", num "+fbos.length); } @@ -436,62 +436,62 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { // // GLFBODrawable - // - + // + @Override public final boolean isInitialized() { return initialized; } - + @Override public final void resetSize(GL gl) throws GLException { reset(gl, samples); - } - + } + @Override public final int getTextureUnit() { return texUnit; } - + @Override public final void setTextureUnit(int u) { texUnit = u; } - + @Override public final int getNumSamples() { return samples; } - + @Override public void setNumSamples(GL gl, int newSamples) throws GLException { if(samples != newSamples) { reset(gl, newSamples); } } - + @Override public final int setNumBuffers(int bufferCount) throws GLException { // FIXME: Implement return bufferCount; } - + @Override public final int getNumBuffers() { return bufferCount; } - + /** // TODO: Add or remove TEXTURE (only) DoubleBufferMode support @Override public final DoubleBufferMode getDoubleBufferMode() { return doubleBufferMode; } - + @Override public final void setDoubleBufferMode(DoubleBufferMode mode) throws GLException { if(initialized) { throw new GLException("Not allowed past initialization: "+this); - } + } final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); if(0 == samples && caps.getDoubleBuffered() && DoubleBufferMode.NONE != mode) { doubleBufferMode = mode; } } */ - + @Override public FBObject getFBObject(int bufferName) throws IllegalArgumentException { if(!initialized) { @@ -509,12 +509,12 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { case GL.GL_BACK: res = fbos[fboIBack]; break; - default: + default: throw new IllegalArgumentException(illegalBufferName+toHexString(bufferName)); - } - return res; + } + return res; } - + @Override public final TextureAttachment getTextureBuffer(int bufferName) throws IllegalArgumentException { if(!initialized) { @@ -536,13 +536,13 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { res = (TextureAttachment) fbos[fboIBack].getColorbuffer(0); } break; - default: + default: throw new IllegalArgumentException(illegalBufferName+toHexString(bufferName)); - } - return res; + } + return res; } private static final String illegalBufferName = "Only GL_FRONT and GL_BACK buffer are allowed, passed "; - + @Override public String toString() { return getClass().getSimpleName()+"[Initialized "+initialized+", realized "+isRealized()+", texUnit "+texUnit+", samples "+samples+ @@ -555,13 +555,13 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { ",\n\tSurface "+getNativeSurface()+ "]"; } - + public static class ResizeableImpl extends GLFBODrawableImpl implements GLFBODrawable.Resizeable { - protected ResizeableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, ProxySurface surface, + protected ResizeableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, ProxySurface surface, GLCapabilitiesImmutable fboCaps, int textureUnit) { super(factory, parent, surface, fboCaps, textureUnit); } - + @Override public final void setSize(GLContext context, int newWidth, int newHeight) throws NativeWindowException, GLException { if(DEBUG) { @@ -572,7 +572,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { throw new NativeWindowException("Could not lock surface: "+this); } try { - // propagate new size + // propagate new size final ProxySurface ps = (ProxySurface) getNativeSurface(); final UpstreamSurfaceHook ush = ps.getUpstreamSurfaceHook(); if(ush instanceof UpstreamSurfaceHook.MutableSize) { diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java index d54da4d28..702fb77de 100644 --- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java +++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java @@ -85,12 +85,12 @@ public class GLGraphicsConfigurationUtil { } if(isFBO) { winattrbits |= FBO_BIT; - } + } if(isPBuffer ){ winattrbits |= PBUFFER_BIT; - } + } if(isBitmap) { - winattrbits |= BITMAP_BIT; + winattrbits |= BITMAP_BIT; } return winattrbits; } @@ -110,7 +110,7 @@ public class GLGraphicsConfigurationUtil { } else if(isPBuffer ){ winattrbits = PBUFFER_BIT; } else if(isBitmap) { - winattrbits = BITMAP_BIT; + winattrbits = BITMAP_BIT; } else { throw new InternalError("Empty bitmask"); } @@ -136,9 +136,9 @@ public class GLGraphicsConfigurationUtil { caps.setHardwareAccelerated(false); } - return caps; + return caps; } - + /** * Fixes the requested {@link GLCapabilitiesImmutable} according to on- and offscreen usage. *

        @@ -150,17 +150,17 @@ public class GLGraphicsConfigurationUtil { * @param device the device on which the drawable will be created, maybe null for the {@link GLDrawableFactory#getDefaultDevice() default device}. * @return either the given requested {@link GLCapabilitiesImmutable} instance if no modifications were required, or a modified {@link GLCapabilitiesImmutable} instance. */ - public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested, + public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested, GLDrawableFactory factory, AbstractGraphicsDevice device) { if( !capsRequested.isOnscreen() ) { return fixOffscreenGLCapabilities(capsRequested, factory, device); } return capsRequested; } - + public static GLCapabilitiesImmutable fixOnscreenGLCapabilities(GLCapabilitiesImmutable capsRequested) { - if( !capsRequested.isOnscreen() || capsRequested.isFBO() || capsRequested.isPBuffer() || capsRequested.isBitmap() ) { + if( !capsRequested.isOnscreen() || capsRequested.isFBO() || capsRequested.isPBuffer() || capsRequested.isBitmap() ) { // fix caps .. final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); caps2.setBitmap (false); @@ -174,7 +174,7 @@ public class GLGraphicsConfigurationUtil { public static GLCapabilitiesImmutable fixOffscreenBitOnly(GLCapabilitiesImmutable capsRequested) { - if( capsRequested.isOnscreen() ) { + if( capsRequested.isOnscreen() ) { // fix caps .. final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); caps2.setOnscreen(false); @@ -182,7 +182,7 @@ public class GLGraphicsConfigurationUtil { } return capsRequested; } - + /** * Fixes the requested {@link GLCapabilitiesImmutable} according to: *

          @@ -203,15 +203,15 @@ public class GLGraphicsConfigurationUtil { final GLProfile glp = capsRequested.getGLProfile(); final boolean fboAvailable = GLContext.isFBOAvailable(device, glp); final boolean pbufferAvailable = factory.canCreateGLPbuffer(device, glp); - + final GLRendererQuirks glrq = factory.getRendererQuirks(device); final boolean bitmapAvailable; final boolean doubleBufferAvailable; - + if(null != glrq) { bitmapAvailable = !glrq.exist(GLRendererQuirks.NoOffscreenBitmap); if( capsRequested.getDoubleBuffered() && - ( capsRequested.isPBuffer() && glrq.exist(GLRendererQuirks.NoDoubleBufferedPBuffer) ) || + ( capsRequested.isPBuffer() && glrq.exist(GLRendererQuirks.NoDoubleBufferedPBuffer) ) || ( capsRequested.isBitmap() && glrq.exist(GLRendererQuirks.NoDoubleBufferedBitmap) ) ) { doubleBufferAvailable = false; } else { @@ -221,25 +221,25 @@ public class GLGraphicsConfigurationUtil { bitmapAvailable = true; doubleBufferAvailable = true; } - - final boolean auto = !( fboAvailable && capsRequested.isFBO() ) && - !( pbufferAvailable && capsRequested.isPBuffer() ) && + + final boolean auto = !( fboAvailable && capsRequested.isFBO() ) && + !( pbufferAvailable && capsRequested.isPBuffer() ) && !( bitmapAvailable && capsRequested.isBitmap() ) ; final boolean useFBO = fboAvailable && ( auto || capsRequested.isFBO() ) ; final boolean usePbuffer = !useFBO && pbufferAvailable && ( auto || capsRequested.isPBuffer() ) ; final boolean useBitmap = !useFBO && !usePbuffer && bitmapAvailable && ( auto || capsRequested.isBitmap() ) ; - + if( capsRequested.isOnscreen() || - useFBO != capsRequested.isFBO() || - usePbuffer != capsRequested.isPBuffer() || + useFBO != capsRequested.isFBO() || + usePbuffer != capsRequested.isPBuffer() || useBitmap != capsRequested.isBitmap() || !doubleBufferAvailable && capsRequested.getDoubleBuffered() ) { // fix caps .. final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); caps2.setOnscreen(false); - caps2.setFBO( useFBO ); + caps2.setFBO( useFBO ); caps2.setPBuffer( usePbuffer ); caps2.setBitmap( useBitmap ); if( !doubleBufferAvailable ) { @@ -253,8 +253,8 @@ public class GLGraphicsConfigurationUtil { public static GLCapabilitiesImmutable fixGLPBufferGLCapabilities(GLCapabilitiesImmutable capsRequested) { if( capsRequested.isOnscreen() || - !capsRequested.isPBuffer() || - capsRequested.isFBO() ) + !capsRequested.isPBuffer() || + capsRequested.isFBO() ) { // fix caps .. final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); @@ -277,7 +277,7 @@ public class GLGraphicsConfigurationUtil { } return capsRequested; } - + /** Fix double buffered setting */ public static GLCapabilitiesImmutable fixDoubleBufferedGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean doubleBuffered) { @@ -288,7 +288,7 @@ public class GLGraphicsConfigurationUtil { } return capsRequested; } - + public static GLCapabilitiesImmutable clipRGBAGLCapabilities(GLCapabilitiesImmutable caps, boolean allowRGB555, boolean allowAlpha) { final int iR = caps.getRedBits(); @@ -305,21 +305,21 @@ public class GLGraphicsConfigurationUtil { caps2.setGreenBits(oG); caps2.setBlueBits(oB); caps2.setAlphaBits(oA); - return caps2; + return caps2; } return caps; } - + public static int clipColor(final int compIn, final boolean allowRGB555) { final int compOut; if( 5 < compIn || !allowRGB555 ) { - compOut = 8; + compOut = 8; } else { compOut = 5; - } + } return compOut; } - + public static GLCapabilitiesImmutable fixGLProfile(GLCapabilitiesImmutable caps, GLProfile glp) { if( caps.getGLProfile() != glp ) { diff --git a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java index 6d9116303..a22454d60 100644 --- a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -42,10 +42,10 @@ import com.jogamp.opengl.GLAutoDrawableDelegate; import jogamp.opengl.GLFBODrawableImpl; public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implements GLOffscreenAutoDrawable { - + /** * @param drawable a valid {@link GLDrawable}, may not be {@link GLDrawable#isRealized() realized} yet. - * @param context a valid {@link GLContext}, + * @param context a valid {@link GLContext}, * may not have been made current (created) yet, * may not be associated w/ drawable yet, * may be null for lazy initialization @@ -55,16 +55,16 @@ public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implemen public GLOffscreenAutoDrawableImpl(GLDrawable drawable, GLContext context, Object upstreamWidget, RecursiveLock lock) { super(drawable, context, upstreamWidget, true, lock); } - + @Override public void setSize(int newWidth, int newHeight) throws NativeWindowException, GLException { this.defaultWindowResizedOp(newWidth, newHeight); } - - public static class FBOImpl extends GLOffscreenAutoDrawableImpl implements GLOffscreenAutoDrawable.FBO { + + public static class FBOImpl extends GLOffscreenAutoDrawableImpl implements GLOffscreenAutoDrawable.FBO { /** * @param drawable a valid {@link GLDrawable}, may not be {@link GLDrawable#isRealized() realized} yet. - * @param context a valid {@link GLContext}, + * @param context a valid {@link GLContext}, * may not have been made current (created) yet, * may not be associated w/ drawable yet, * may be null for lazy initialization @@ -74,7 +74,7 @@ public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implemen public FBOImpl(GLFBODrawableImpl drawable, GLContext context, Object upstreamWidget, RecursiveLock lock) { super(drawable, context, upstreamWidget, lock); } - + @Override public boolean isInitialized() { return ((GLFBODrawableImpl)drawable).isInitialized(); @@ -84,7 +84,7 @@ public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implemen public final int getTextureUnit() { return ((GLFBODrawableImpl)drawable).getTextureUnit(); } - + @Override public final void setTextureUnit(int unit) { ((GLFBODrawableImpl)drawable).setTextureUnit(unit); @@ -94,23 +94,23 @@ public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implemen public final int getNumSamples() { return ((GLFBODrawableImpl)drawable).getNumSamples(); } - + @Override public final void setNumSamples(GL gl, int newSamples) throws GLException { ((GLFBODrawableImpl)drawable).setNumSamples(gl, newSamples); windowRepaintOp(); } - + @Override public final int setNumBuffers(int bufferCount) throws GLException { return ((GLFBODrawableImpl)drawable).setNumBuffers(bufferCount); } - + @Override public final int getNumBuffers() { return ((GLFBODrawableImpl)drawable).getNumBuffers(); } - + /** // TODO: Add or remove TEXTURE (only) DoubleBufferMode support @Override public DoubleBufferMode getDoubleBufferMode() { @@ -119,14 +119,14 @@ public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implemen @Override public void setDoubleBufferMode(DoubleBufferMode mode) throws GLException { - ((GLFBODrawableImpl)drawable).setDoubleBufferMode(mode); + ((GLFBODrawableImpl)drawable).setDoubleBufferMode(mode); } */ - + @Override - public final FBObject getFBObject(int bufferName) { + public final FBObject getFBObject(int bufferName) { return ((GLFBODrawableImpl)drawable).getFBObject(bufferName); } - + public final FBObject.TextureAttachment getTextureBuffer(int bufferName) { return ((GLFBODrawableImpl)drawable).getTextureBuffer(bufferName); } @@ -134,6 +134,6 @@ public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implemen @Override public void resetSize(GL gl) throws GLException { ((GLFBODrawableImpl)drawable).resetSize(gl); - } + } } } diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index b8841d6e2..c32957b86 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -51,7 +51,7 @@ import com.jogamp.common.util.locks.RecursiveLock; public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContextImpl pbufferContext) { - super(pbufferDrawable, pbufferContext, true); // drawable := pbufferDrawable, context := pbufferContext + super(pbufferDrawable, pbufferContext, true); // drawable := pbufferDrawable, context := pbufferContext } // @@ -60,26 +60,26 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { // // GLDrawable delegation - // - + // + @Override public final void swapBuffers() throws GLException { defaultSwapBuffers(); } - + // // GLAutoDrawable completion // private final RecursiveLock lock = LockFactory.createRecursiveLock(); // instance wide lock - + @Override protected final RecursiveLock getLock() { return lock; } - + @Override public final Object getUpstreamWidget() { return null; } - + @Override public void destroy() { defaultDestroy(); @@ -92,7 +92,7 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { @Override public final void display() { - final RecursiveLock _lock = lock; + final RecursiveLock _lock = lock; _lock.lock(); // sync: context/drawable could been recreated/destroyed while animating try { if( null != context ) { diff --git a/src/jogl/classes/jogamp/opengl/GLRunnableTask.java b/src/jogl/classes/jogamp/opengl/GLRunnableTask.java index 244a3fd79..2238d49bc 100644 --- a/src/jogl/classes/jogamp/opengl/GLRunnableTask.java +++ b/src/jogl/classes/jogamp/opengl/GLRunnableTask.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl; import javax.media.opengl.GLRunnable; @@ -86,41 +86,41 @@ public class GLRunnableTask implements GLRunnable { } return res; } - - /** + + /** * Simply flush this task and notify a waiting executor. * The executor which might have been blocked until notified * will be unblocked and the task removed from the queue. - * + * * @see #isFlushed() * @see #isInQueue() - */ + */ public void flush() { if(!isExecuted() && null != notifyObject) { synchronized (notifyObject) { isFlushed=true; - notifyObject.notifyAll(); + notifyObject.notifyAll(); } } } - + /** * @return !{@link #isExecuted()} && !{@link #isFlushed()} */ public boolean isInQueue() { return !isExecuted && !isFlushed; } - + /** * @return whether this task has been executed. * @see #isInQueue() */ public boolean isExecuted() { return isExecuted; } - + /** * @return whether this task has been flushed. * @see #isInQueue() */ public boolean isFlushed() { return isFlushed; } - + public Throwable getThrowable() { return runnableException; } } diff --git a/src/jogl/classes/jogamp/opengl/GLStateTracker.java b/src/jogl/classes/jogamp/opengl/GLStateTracker.java index 01c3716e0..307fd0a15 100644 --- a/src/jogl/classes/jogamp/opengl/GLStateTracker.java +++ b/src/jogl/classes/jogamp/opengl/GLStateTracker.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2006 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -53,47 +53,47 @@ import java.util.ArrayList; * Currently supported states: PixelStorei */ public class GLStateTracker { - - /** Minimum value of MAX_CLIENT_ATTRIB_STACK_DEPTH */ + + /** Minimum value of MAX_CLIENT_ATTRIB_STACK_DEPTH */ public static final int MIN_CLIENT_ATTRIB_STACK_DEPTH = 16; - + /** static size of pixel state map */ static final int PIXEL_STATE_MAP_SIZE = 16; /** avoid rehash of static size pixel state map */ static final int PIXEL_STATE_MAP_CAPACITY = 32; - + private volatile boolean enabled = true; private IntIntHashMap pixelStateMap; private final ArrayList stack; - + private static class SavedState { /** * Empty pixel-store state - */ + */ private IntIntHashMap pixelStateMap; - + /** * set (client) pixel-store state, deep copy - */ + */ private final void setPixelStateMap(IntIntHashMap pixelStateMap) { this.pixelStateMap = (IntIntHashMap) pixelStateMap.clone(); } - + /** * get (client) pixel-store state, return reference - */ + */ private final IntIntHashMap getPixelStateMap() { return pixelStateMap; } } - - public GLStateTracker() { + + public GLStateTracker() { pixelStateMap = new IntIntHashMap(PIXEL_STATE_MAP_CAPACITY, 0.75f); pixelStateMap.setKeyNotFoundValue(0xFFFFFFFF); resetStates(); - + stack = new ArrayList(MIN_CLIENT_ATTRIB_STACK_DEPTH); } @@ -102,18 +102,18 @@ public class GLStateTracker { } public final void setEnabled(boolean on) { - enabled = on; + enabled = on; } public final boolean isEnabled() { return enabled; } - /** @return true if found in our map, otherwise false, + /** @return true if found in our map, otherwise false, * which forces the caller to query GL. */ public final boolean getInt(int pname, int[] params, int params_offset) { if(enabled) { - final int value = pixelStateMap.get(pname); + final int value = pixelStateMap.get(pname); if(0xFFFFFFFF != value) { params[params_offset] = value; return true; @@ -122,7 +122,7 @@ public class GLStateTracker { return false; } - /** @return true if found in our map, otherwise false, + /** @return true if found in our map, otherwise false, * which forces the caller to query GL. */ public final boolean getInt(int pname, IntBuffer params, int dummy) { if(enabled) { @@ -158,7 +158,7 @@ public class GLStateTracker { throw new GLException("stack contains no elements"); } SavedState state = stack.remove(stack.size()-1); // pop - + if(null==state) { throw new GLException("null stack element (remaining stack size "+stack.size()+")"); } @@ -166,7 +166,7 @@ public class GLStateTracker { if ( null != state.getPixelStateMap() ) { // use pulled client pixel-store state from stack pixelStateMap = state.getPixelStateMap(); - } // else: empty-slot, not pushed by GL_CLIENT_PIXEL_STORE_BIT + } // else: empty-slot, not pushed by GL_CLIENT_PIXEL_STORE_BIT } } diff --git a/src/jogl/classes/jogamp/opengl/GLVersionNumber.java b/src/jogl/classes/jogamp/opengl/GLVersionNumber.java index e4187b35b..431c1a387 100644 --- a/src/jogl/classes/jogamp/opengl/GLVersionNumber.java +++ b/src/jogl/classes/jogamp/opengl/GLVersionNumber.java @@ -43,9 +43,9 @@ public class GLVersionNumber extends VersionNumberString { super(val[0], val[1], val[2], strEnd, state, versionString); this.valid = valid; } - + private static java.util.regex.Pattern getUnderscorePattern() { - if( null == _Pattern ) { // volatile dbl-checked-locking OK + if( null == _Pattern ) { // volatile dbl-checked-locking OK synchronized( VersionNumber.class ) { if( null == _Pattern ) { _Pattern = getVersionNumberPattern("_"); @@ -55,7 +55,7 @@ public class GLVersionNumber extends VersionNumberString { return _Pattern; } private static volatile java.util.regex.Pattern _Pattern = null; - + public static final GLVersionNumber create(String versionString) { int[] val = new int[] { 0, 0, 0 }; int strEnd = 0; @@ -73,7 +73,7 @@ public class GLVersionNumber extends VersionNumberString { strEnd = version.endOfStringMatch(); val[0] = version.getMajor(); val[1] = version.getMinor(); - state = (short) ( ( version.hasMajor() ? VersionNumber.HAS_MAJOR : (short)0 ) | + state = (short) ( ( version.hasMajor() ? VersionNumber.HAS_MAJOR : (short)0 ) | ( version.hasMinor() ? VersionNumber.HAS_MINOR : (short)0 ) ); valid = version.hasMajor() && version.hasMinor(); // Requires at least a defined major and minor version component! } catch (Exception e) { @@ -82,16 +82,16 @@ public class GLVersionNumber extends VersionNumberString { val[0] = 1; val[1] = 0; } - } + } return new GLVersionNumber(val, strEnd, state, versionString, valid); } public final boolean isValid() { return valid; } - - /** - * Returns the optional vendor version at the end of the + + /** + * Returns the optional vendor version at the end of the * GL_VERSION string if exists, otherwise the {@link VersionNumberString#zeroVersion zero version} instance. *
                *   2.1 Mesa 7.0.3-rc2 -> 7.0.3 (7.0.3-rc2)
          @@ -105,14 +105,14 @@ public class GLVersionNumber extends VersionNumberString {
                   if (versionString == null || versionString.length() <= 0) {
                       return null;
                   }
          -        
          +
                   // Skip the 1st GL version
                   String str;
                   {
                       final GLVersionNumber glv = create(versionString);
                       str = versionString.substring(glv.endOfStringMatch()).trim();
                   }
          -        
          +
                   while ( str.length() > 0 ) {
                       final VersionNumberString version = new VersionNumberString(str, getDefaultVersionNumberPattern());
                       final int eosm = version.endOfStringMatch();
          diff --git a/src/jogl/classes/jogamp/opengl/GLWorkerThread.java b/src/jogl/classes/jogamp/opengl/GLWorkerThread.java
          index 112dfcb64..979c6dc0a 100644
          --- a/src/jogl/classes/jogamp/opengl/GLWorkerThread.java
          +++ b/src/jogl/classes/jogamp/opengl/GLWorkerThread.java
          @@ -1,21 +1,21 @@
           /*
            * Copyright (c) 2006 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
          @@ -28,11 +28,11 @@
            * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
            * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
            * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
          - * 
          + *
            * You acknowledge that this software is not designed or intended for use
            * in the design, construction, operation or maintenance of any nuclear
            * facility.
          - * 
          + *
            * Sun gratefully acknowledges that this software was originally authored
            * and developed by Kenneth Bradley Russell and Christopher John Kline.
            */
          @@ -67,7 +67,7 @@ public class GLWorkerThread {
             private static volatile Runnable work;
             // Queue of Runnables to be asynchronously invoked
             private static List queue = new ArrayList();
          -  
          +
             /** Should only be called by Threading class if creation of the
                 GLWorkerThread was requested via the opengl.1thread system
                 property. 
          @@ -149,7 +149,7 @@ public class GLWorkerThread { } } - public static void invoke(boolean wait, Runnable runnable) + public static void invoke(boolean wait, Runnable runnable) throws InvocationTargetException, InterruptedException { if(wait) { invokeAndWait(runnable); @@ -157,7 +157,7 @@ public class GLWorkerThread { invokeLater(runnable); } } - + public static void invokeAndWait(Runnable runnable) throws InvocationTargetException, InterruptedException { if (!started) { @@ -220,7 +220,7 @@ public class GLWorkerThread { } protected static String getThreadName() { return Thread.currentThread().getName(); } - + static class WorkerRunnable implements Runnable { public void run() { // Notify starting thread that we're ready @@ -244,7 +244,7 @@ public class GLWorkerThread { break; } } - + if (shouldTerminate) { lock.notifyAll(); thread = null; diff --git a/src/jogl/classes/jogamp/opengl/GLXExtensions.java b/src/jogl/classes/jogamp/opengl/GLXExtensions.java index 36c6c4665..9325c6f68 100644 --- a/src/jogl/classes/jogamp/opengl/GLXExtensions.java +++ b/src/jogl/classes/jogamp/opengl/GLXExtensions.java @@ -28,9 +28,9 @@ package jogamp.opengl; /** - * Class holding GLX/WGL/.. extension strings, commonly used by JOGL's implementation. + * Class holding GLX/WGL/.. extension strings, commonly used by JOGL's implementation. */ -public class GLXExtensions { +public class GLXExtensions { public static final String GLX_MESA_swap_control = "GLX_MESA_swap_control"; public static final String GLX_SGI_swap_control = "GLX_SGI_swap_control"; public static final String GLX_NV_swap_group = "GLX_NV_swap_group"; diff --git a/src/jogl/classes/jogamp/opengl/ListenerSyncedImplStub.java b/src/jogl/classes/jogamp/opengl/ListenerSyncedImplStub.java index 1cde551be..a64a2f5cd 100644 --- a/src/jogl/classes/jogamp/opengl/ListenerSyncedImplStub.java +++ b/src/jogl/classes/jogamp/opengl/ListenerSyncedImplStub.java @@ -33,9 +33,9 @@ import java.util.ArrayList; /** * Simple locked listener implementation stub to be used for listener handler, * synchronized on it's instance. - * + * *

          Utilizing simple locking via synchronized.

          - * + * * @param The listener type */ public class ListenerSyncedImplStub { @@ -48,7 +48,7 @@ public class ListenerSyncedImplStub { public synchronized final void reset() { listeners = new ArrayList(); } - + public synchronized final void destroy() { listeners.clear(); listeners = null; @@ -57,7 +57,7 @@ public class ListenerSyncedImplStub { public synchronized final int size() { return listeners.size(); } - + public synchronized final void addListener(E listener) { addListener(-1, listener); } @@ -68,12 +68,12 @@ public class ListenerSyncedImplStub { } listeners.add(index, listener); } - + public synchronized final void removeListener(E listener) { listeners.remove(listener); } public final ArrayList getListeners() { return listeners; - } + } } diff --git a/src/jogl/classes/jogamp/opengl/ProjectFloat.java b/src/jogl/classes/jogamp/opengl/ProjectFloat.java index 439ddc76e..d4fd1c935 100644 --- a/src/jogl/classes/jogamp/opengl/ProjectFloat.java +++ b/src/jogl/classes/jogamp/opengl/ProjectFloat.java @@ -6,9 +6,9 @@ ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** +** ** http://oss.sgi.com/projects/FreeB -** +** ** Note that, as provided in the License, the Software is distributed on an ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND @@ -24,13 +24,13 @@ ** except that Section 2.2 and 11 are omitted. Any differences between ** the Alternative License and the SGI License are offered solely by Sun ** and not by SGI. -** +** ** Original Code. The Original Code is: OpenGL Sample Implementation, ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. ** Copyright in any portions created by third parties is as indicated ** elsewhere herein. All Rights Reserved. -** +** ** Additional Notice Provisions: The application programming interfaces ** established by SGI in conjunction with the Original Code are The ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -45,34 +45,34 @@ ** $Header$ */ -/* +/* * Copyright (c) 2002-2004 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions 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 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ @@ -80,22 +80,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2011 JogAmp Community. 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 @@ -108,7 +108,7 @@ * 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. @@ -129,14 +129,14 @@ import com.jogamp.opengl.math.FloatUtil; *

          * Created 11-jan-2004 *

          - * + * * @author Erik Duijs * @author Kenneth Russell * @author Sven Gothel */ public class ProjectFloat { public static final int getRequiredFloatBufferSize() { return 1*16; } - + // Note that we have cloned parts of the implementation in order to // support incoming Buffers. The reason for this is to avoid loading // non-direct buffer subclasses unnecessarily, because doing so can @@ -162,22 +162,22 @@ public class ProjectFloat { public ProjectFloat() { this(true); } - + public ProjectFloat(boolean useBackingArray) { - this(useBackingArray ? null : Buffers.newDirectByteBuffer(getRequiredFloatBufferSize() * Buffers.SIZEOF_FLOAT), - useBackingArray ? new float[getRequiredFloatBufferSize()] : null, + this(useBackingArray ? null : Buffers.newDirectByteBuffer(getRequiredFloatBufferSize() * Buffers.SIZEOF_FLOAT), + useBackingArray ? new float[getRequiredFloatBufferSize()] : null, 0); } /** * @param floatBuffer source buffer, may be ByteBuffer (recommended) or FloatBuffer or null. - * If used, shall be ≥ {@link #getRequiredFloatBufferSize()} + floatOffset. + * If used, shall be ≥ {@link #getRequiredFloatBufferSize()} + floatOffset. * Buffer's position is ignored and floatPos is being used. * @param floatArray source float array or null. * If used, size shall be ≥ {@link #getRequiredFloatBufferSize()} + floatOffset. * @param floatOffset Offset for either of the given sources (buffer or array) */ - public ProjectFloat(Buffer floatBuffer, float[] floatArray, int floatOffset) { + public ProjectFloat(Buffer floatBuffer, float[] floatArray, int floatOffset) { matrixBuf = Buffers.slice2Float(floatBuffer, floatArray, floatOffset, 16); } @@ -259,7 +259,7 @@ public class ProjectFloat { /** * @param src * @param inverse - * + * * @return */ public boolean gluInvertMatrixf(FloatBuffer src, FloatBuffer inverse) { @@ -268,7 +268,7 @@ public class ProjectFloat { final int srcPos = src.position(); final int invPos = inverse.position(); - + final float[][] temp = tempInvertMatrix; for (i = 0; i < 4; i++) { @@ -297,7 +297,7 @@ public class ProjectFloat { t = temp[i][k]; temp[i][k] = temp[swap][k]; temp[swap][k] = t; - + t = inverse.get(i*4+k + invPos); inverse.put(i*4+k + invPos, inverse.get(swap*4+k + invPos)); inverse.put(swap*4+k + invPos, t); @@ -335,7 +335,7 @@ public class ProjectFloat { /** * Method gluOrtho2D. - * + * * @param left * @param right * @param bottom @@ -347,7 +347,7 @@ public class ProjectFloat { /** * Method gluPerspective. - * + * * @param fovy * @param aspect * @param zNear @@ -380,7 +380,7 @@ public class ProjectFloat { /** * Method gluLookAt - * + * * @param eyex * @param eyey * @param eyez @@ -436,7 +436,7 @@ public class ProjectFloat { /** * Map object coordinates to window coordinates. - * + * * @param objx * @param objy * @param objz @@ -444,7 +444,7 @@ public class ProjectFloat { * @param projMatrix * @param viewport * @param win_pos - * + * * @return */ public boolean gluProject(float objx, float objy, float objz, @@ -518,13 +518,13 @@ public class ProjectFloat { win_pos[0+win_pos_offset] = in[0] * viewport[2+viewport_offset] + viewport[0+viewport_offset]; win_pos[1+win_pos_offset] = in[1] * viewport[3+viewport_offset] + viewport[1+viewport_offset]; win_pos[2+win_pos_offset] = in[2]; - + return true; } - + /** * Map object coordinates to window coordinates. - * + * * @param objx * @param objy * @param objz @@ -532,7 +532,7 @@ public class ProjectFloat { * @param projMatrix * @param viewport * @param win_pos - * + * * @return */ public boolean gluProject(float objx, float objy, float objz, @@ -576,7 +576,7 @@ public class ProjectFloat { /** * Map window coordinates to object coordinates. - * + * * @param winx * @param winy * @param winz @@ -584,7 +584,7 @@ public class ProjectFloat { * @param projMatrix * @param viewport * @param obj_pos - * + * * @return */ public boolean gluUnProject(float winx, float winy, float winz, @@ -633,7 +633,7 @@ public class ProjectFloat { /** * Map window coordinates to object coordinates. - * + * * @param winx * @param winy * @param winz @@ -646,7 +646,7 @@ public class ProjectFloat { * @return */ public boolean gluUnProject(float winx, float winy, float winz, - FloatBuffer modelMatrix, + FloatBuffer modelMatrix, FloatBuffer projMatrix, int[] viewport, int viewport_offset, float[] obj_pos, int obj_pos_offset) { @@ -674,7 +674,7 @@ public class ProjectFloat { in[2] = in[2] * 2 - 1; FloatUtil.multMatrixVecf(matrixBuf, in, out); - + if (out[3] == 0.0) { return false; } @@ -687,10 +687,10 @@ public class ProjectFloat { return true; } - + /** * Map window coordinates to object coordinates. - * + * * @param winx * @param winy * @param winz @@ -698,11 +698,11 @@ public class ProjectFloat { * @param projMatrix * @param viewport * @param obj_pos - * + * * @return */ public boolean gluUnProject(float winx, float winy, float winz, - FloatBuffer modelMatrix, + FloatBuffer modelMatrix, FloatBuffer projMatrix, IntBuffer viewport, FloatBuffer obj_pos) { @@ -722,7 +722,7 @@ public class ProjectFloat { // Map x and y from window coordinates final int vPos = viewport.position(); - final int oPos = obj_pos.position(); + final int oPos = obj_pos.position(); in[0] = (in[0] - viewport.get(0+vPos)) / viewport.get(2+vPos); in[1] = (in[1] - viewport.get(1+vPos)) / viewport.get(3+vPos); @@ -749,7 +749,7 @@ public class ProjectFloat { /** * Map window coordinates to object coordinates. - * + * * @param winx * @param winy * @param winz @@ -760,7 +760,7 @@ public class ProjectFloat { * @param near * @param far * @param obj_pos - * + * * @return */ public boolean gluUnProject4(float winx, @@ -815,7 +815,7 @@ public class ProjectFloat { /** * Map window coordinates to object coordinates. - * + * * @param winx * @param winy * @param winz @@ -826,7 +826,7 @@ public class ProjectFloat { * @param near * @param far * @param obj_pos - * + * * @return */ public boolean gluUnProject4(float winx, @@ -857,7 +857,7 @@ public class ProjectFloat { in[0] = (in[0] - viewport.get(0+vPos)) / viewport.get(2+vPos); in[1] = (in[1] - viewport.get(1+vPos)) / viewport.get(3+vPos); in[2] = (in[2] - near) / (far - near); - + // Map to range -1 to 1 in[0] = in[0] * 2 - 1; in[1] = in[1] * 2 - 1; @@ -873,14 +873,14 @@ public class ProjectFloat { obj_pos.put(0+oPos, out[0]); obj_pos.put(1+oPos, out[1]); obj_pos.put(2+oPos, out[2]); - obj_pos.put(3+oPos, out[3]); + obj_pos.put(3+oPos, out[3]); return true; } /** * Method gluPickMatrix - * + * * @param x * @param y * @param deltaX @@ -907,7 +907,7 @@ public class ProjectFloat { /** * Method gluPickMatrix - * + * * @param x * @param y * @param deltaX diff --git a/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java b/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java index e5f5ee09a..eddb36975 100644 --- a/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java +++ b/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java @@ -52,30 +52,30 @@ public class SharedResourceRunner implements Runnable { *

          * Called within synchronized block. *

          - * @param connection for creation a {@link AbstractGraphicsDevice} instance. - * @return true if the device supports all protocols required for the implementation, otherwise false. + * @param connection for creation a {@link AbstractGraphicsDevice} instance. + * @return true if the device supports all protocols required for the implementation, otherwise false. */ boolean isDeviceSupported(String connection); - + /** *

          * Called within synchronized block. *

          - * @param connection for creation a {@link AbstractGraphicsDevice} instance. - * @return A new shared resource instance + * @param connection for creation a {@link AbstractGraphicsDevice} instance. + * @return A new shared resource instance */ Resource createSharedResource(String connection); - - /** Called within synchronized block. */ + + /** Called within synchronized block. */ void releaseSharedResource(Resource shared); - /** Called within synchronized block. */ + /** Called within synchronized block. */ void clear(); - /** Called within synchronized block. */ + /** Called within synchronized block. */ Resource mapPut(String connection, Resource resource); - /** Called within synchronized block. */ + /** Called within synchronized block. */ Resource mapGet(String connection); - /** Called within synchronized block. */ + /** Called within synchronized block. */ Collection mapValues(); } @@ -103,7 +103,7 @@ public class SharedResourceRunner implements Runnable { this.impl = impl; resetState(); } - + private void resetState() { // synchronized call devicesTried.clear(); thread = null; @@ -114,12 +114,12 @@ public class SharedResourceRunner implements Runnable { releaseConnection = null; } - /** + /** * Start the shared resource runner thread, if not running. *

          * Validate the thread upfront and release all related resource if it was killed. *

          - * + * * @return the shared resource runner thread. */ public Thread start() { @@ -132,7 +132,7 @@ public class SharedResourceRunner implements Runnable { releaseSharedResources(); thread = null; running = false; - } + } if( null == thread ) { if (DEBUG) { System.err.println("SharedResourceRunner.start() - start new Thread - "+getThreadName()); @@ -150,7 +150,7 @@ public class SharedResourceRunner implements Runnable { } return thread; } - + public void stop() { synchronized (this) { if(null != thread) { @@ -160,7 +160,7 @@ public class SharedResourceRunner implements Runnable { synchronized (this) { shouldRelease = true; this.notifyAll(); - + while (running) { try { this.wait(); @@ -170,7 +170,7 @@ public class SharedResourceRunner implements Runnable { } } } - + public SharedResourceRunner.Resource getOrCreateShared(AbstractGraphicsDevice device) { SharedResourceRunner.Resource sr = null; if(null != device) { @@ -203,7 +203,7 @@ public class SharedResourceRunner implements Runnable { if(null != device) { synchronized (this) { final String connection = device.getConnection(); - sr = impl.mapGet(connection); + sr = impl.mapGet(connection); if (null != sr) { removeDeviceTried(connection); if (DEBUG) { @@ -261,7 +261,7 @@ public class SharedResourceRunner implements Runnable { synchronized (this) { running = true; - + while (!shouldRelease) { try { // wait for stop or init @@ -271,7 +271,7 @@ public class SharedResourceRunner implements Runnable { } notifyAll(); this.wait(); - } catch (InterruptedException ex) { + } catch (InterruptedException ex) { shouldRelease = true; if(DEBUG) { System.err.println("SharedResourceRunner.run(): INTERRUPTED - "+threadName); @@ -311,7 +311,7 @@ public class SharedResourceRunner implements Runnable { } catch (Exception e) { e.printStackTrace(); } - } + } } } initConnection = null; diff --git a/src/jogl/classes/jogamp/opengl/ThreadingImpl.java b/src/jogl/classes/jogamp/opengl/ThreadingImpl.java index d55a2c976..6ffe46b36 100644 --- a/src/jogl/classes/jogamp/opengl/ThreadingImpl.java +++ b/src/jogl/classes/jogamp/opengl/ThreadingImpl.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.opengl; @@ -49,14 +49,14 @@ import com.jogamp.common.util.ReflectionUtil; public class ThreadingImpl { public enum Mode { - MT(0), ST_AWT(1), ST_WORKER(2); - + MT(0), ST_AWT(1), ST_WORKER(2); + public final int id; Mode(int id){ this.id = id; } - } + } protected static final boolean DEBUG = Debug.debug("Threading"); @@ -68,7 +68,7 @@ public class ThreadingImpl { private static boolean _isX11; private static final ToolkitThreadingPlugin threadingPlugin; - + static { threadingPlugin = AccessController.doPrivileged(new PrivilegedAction() { @@ -94,7 +94,7 @@ public class ThreadingImpl { // default setting singleThreaded = true; mode = ( hasAWT ? Mode.ST_AWT : Mode.ST_WORKER ); - + if (singleThreadProp != null) { if (singleThreadProp.equals("true") || singleThreadProp.equals("auto")) { @@ -113,7 +113,7 @@ public class ThreadingImpl { throw new RuntimeException("Unsupported value for property jogl.1thread: "+singleThreadProp+", should be [true/auto, worker, awt or false]"); } } - + ToolkitThreadingPlugin threadingPlugin=null; if(hasAWT) { // try to fetch the AWTThreadingPlugin @@ -139,9 +139,9 @@ public class ThreadingImpl { public static boolean isX11() { return _isX11; } public static Mode getMode() { return mode; } - /** If an implementation of the javax.media.opengl APIs offers a - multithreading option but the default behavior is single-threading, - this API provides a mechanism for end users to disable single-threading + /** If an implementation of the javax.media.opengl APIs offers a + multithreading option but the default behavior is single-threading, + this API provides a mechanism for end users to disable single-threading in this implementation. Users are strongly discouraged from calling this method unless they are aware of all of the consequences and are prepared to enforce some amount of @@ -151,7 +151,7 @@ public class ThreadingImpl { GLPbuffer. Currently there is no supported way to re-enable it once disabled, partly to discourage careless use of this method. This method should be called as early as possible in an - application. */ + application. */ public static final void disableSingleThreading() { singleThreaded = false; if (Debug.verbose()) { @@ -183,7 +183,7 @@ public class ThreadingImpl { throw new InternalError("Illegal single-threading mode " + mode); } } - + public static final boolean isToolkitThread() throws GLException { if(null!=threadingPlugin) { return threadingPlugin.isToolkitThread(); @@ -215,7 +215,7 @@ public class ThreadingImpl { throw new InternalError("Illegal single-threading mode " + mode); } } - + public static final void invokeOnWorkerThread(boolean wait, Runnable r) throws GLException { GLWorkerThread.start(); // singleton start via volatile-dbl-checked-locking try { @@ -224,6 +224,6 @@ public class ThreadingImpl { throw new GLException(e.getTargetException()); } catch (InterruptedException e) { throw new GLException(e); - } + } } } diff --git a/src/jogl/classes/jogamp/opengl/ToolkitThreadingPlugin.java b/src/jogl/classes/jogamp/opengl/ToolkitThreadingPlugin.java index 22972953a..06fb0fe91 100644 --- a/src/jogl/classes/jogamp/opengl/ToolkitThreadingPlugin.java +++ b/src/jogl/classes/jogamp/opengl/ToolkitThreadingPlugin.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2012 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -46,7 +46,7 @@ public interface ToolkitThreadingPlugin { /** Indicates whether the current thread is the designated toolkit thread, if such semantics exists. */ public boolean isToolkitThread() throws GLException; - + /** Indicates whether the current thread is the thread on which this implementation of the javax.media.opengl APIs performs all of its OpenGL-related work. This method should only diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java index 56f00b370..cd1bb45c9 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -57,7 +57,7 @@ public class AWTThreadingPlugin implements ToolkitThreadingPlugin { public final boolean isToolkitThread() throws GLException { return EventQueue.isDispatchThread(); } - + public final boolean isOpenGLThread() throws GLException { switch (ThreadingImpl.getMode()) { case ST_AWT: diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index 9bdceff48..5faee1307 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -67,19 +67,19 @@ import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider; */ public class AWTTilePainter { private static final boolean DEBUG_TILES = Debug.debug("TileRenderer.PNG"); - + public final TileRenderer renderer; public final int componentCount; public final double scaleMatX, scaleMatY; public final int customTileWidth, customTileHeight, customNumSamples; public final boolean verbose; - + public boolean flipVertical; private AWTGLPixelBuffer tBuffer = null; private BufferedImage vFlipImage = null; private Graphics2D g2d = null; - private AffineTransform saveAT = null; - + private AffineTransform saveAT = null; + public static void dumpHintsAndScale(Graphics2D g2d) { final RenderingHints rHints = g2d.getRenderingHints(); final Set> rEntries = rHints.entrySet(); @@ -92,13 +92,13 @@ public class AWTTilePainter { if( null != aTrans ) { System.err.println(" type "+aTrans.getType()); System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); - System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); + System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); System.err.println(" mat "+aTrans); } else { System.err.println(" null transform"); } } - + /** * @return resulting number of samples by comparing w/ {@link #customNumSamples} and the caps-config, 0 if disabled */ @@ -114,12 +114,12 @@ public class AWTTilePainter { return caps.getNumSamples(); } } - - /** + + /** * Assumes a configured {@link TileRenderer}, i.e. * an {@link TileRenderer#attachAutoDrawable(GLAutoDrawable) attached} * {@link GLAutoDrawable} with {@link TileRenderer#setTileSize(int, int, int) set tile size}. - *

          + *

          * Sets the renderer to {@link TileRenderer#TR_TOP_TO_BOTTOM} row order. *

          *

          @@ -129,7 +129,7 @@ public class AWTTilePainter { * @param componentCount * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels - * @param numSamples custom multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param numSamples custom multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param verbose @@ -146,13 +146,13 @@ public class AWTTilePainter { this.verbose = verbose; this.flipVertical = true; } - + public String toString() { return renderer.toString(); } - + public void setIsGLOriented(boolean v) { flipVertical = v; } - + private static Rectangle2D getClipBounds2D(Graphics2D g) { final Shape shape = g.getClip(); return null != shape ? shape.getBounds2D() : null; @@ -170,7 +170,7 @@ public class AWTTilePainter { } return new Rectangle2D.Double(x, y, width, height); } - + /** * Caches the {@link Graphics2D} instance for rendering. *

          @@ -201,9 +201,9 @@ public class AWTTilePainter { final Rectangle2D dClipOrigR = getClipBounds2D(g2d); final Rectangle2D dClipOrig = clipNegative(dClipOrigR); final Rectangle2D dImageSizeOrig = new Rectangle2D.Double(0, 0, width, height); - + // Retrieve scaled image-size and clip-bounds - // Note: Clip bounds lie within image-size! + // Note: Clip bounds lie within image-size! final Rectangle2D dImageSizeScaled, dClipScaled; { final AffineTransform scaledATI; @@ -230,10 +230,10 @@ public class AWTTilePainter { // GL y-offset is lower-left origin, AWT y-offset upper-left. scaledYOffset = iClipScaled.y; renderer.setTileOffset(iClipScaled.x, iImageSizeScaled.height - ( iClipScaled.y + clipH )); - + // Scale actual Grahics2D matrix g2d.scale(scaleMatX, scaleMatY); - + if( verbose ) { System.err.println("AWT print.0: image "+dImageSizeOrig + " -> " + dImageSizeScaled + " -> " + iImageSizeScaled); System.err.println("AWT print.0: clip "+dClipOrigR + " -> " + dClipOrig + " -> " + dClipScaled + " -> " + iClipScaled); @@ -241,12 +241,12 @@ public class AWTTilePainter { } } private int scaledYOffset; - + /** See {@ #setupGraphics2DAndClipBounds(Graphics2D)}. */ - public void resetGraphics2D() { + public void resetGraphics2D() { g2d.setTransform(saveAT); } - + /** * Disposes resources and {@link TileRenderer#detachAutoDrawable() detaches} * the {@link TileRenderer}'s {@link GLAutoDrawable}. @@ -263,7 +263,7 @@ public class AWTTilePainter { vFlipImage = null; } } - + final GLEventListener preTileGLEL = new GLEventListener() { @Override public void init(GLAutoDrawable drawable) {} @@ -275,7 +275,7 @@ public class AWTTilePainter { if( null == tBuffer ) { final int tWidth = renderer.getParam(TileRenderer.TR_TILE_WIDTH); final int tHeight = renderer.getParam(TileRenderer.TR_TILE_HEIGHT); - final AWTGLPixelBufferProvider printBufferProvider = new AWTGLPixelBufferProvider( true /* allowRowStride */ ); + final AWTGLPixelBufferProvider printBufferProvider = new AWTGLPixelBufferProvider( true /* allowRowStride */ ); final GLPixelAttributes pixelAttribs = printBufferProvider.getAttributes(gl, componentCount); tBuffer = printBufferProvider.allocate(gl, pixelAttribs, tWidth, tHeight, 1, true, 0); renderer.setTileBuffer(tBuffer); @@ -300,7 +300,7 @@ public class AWTTilePainter { @Override public void dispose(GLAutoDrawable drawable) {} @Override - public void display(GLAutoDrawable drawable) { + public void display(GLAutoDrawable drawable) { final DimensionImmutable cis = renderer.getClippedImageSize(); final int tWidth = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH); final int tHeight = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT); @@ -309,26 +309,26 @@ public class AWTTilePainter { final int imgYOff = flipVertical ? 0 : renderer.getParam(TileRenderer.TR_TILE_HEIGHT) - tHeight; // imgYOff will be cut-off via sub-image final int pX = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); // tileX == pX final int pY = cis.getHeight() - ( tY - tYOff + tHeight ) + scaledYOffset; - + // Copy temporary data into raster of BufferedImage for faster // blitting Note that we could avoid this copy in the cases // where !offscreenDrawable.isGLOriented(), // but that's the software rendering path which is very slow anyway. final BufferedImage dstImage; if( DEBUG_TILES ) { - final String fname = String.format("file_%03d_0_tile_[%02d][%02d]_sz_%03dx%03d_pos0_%03d_%03d_yOff_%03d_pos1_%03d_%03d.png", - _counter, + final String fname = String.format("file_%03d_0_tile_[%02d][%02d]_sz_%03dx%03d_pos0_%03d_%03d_yOff_%03d_pos1_%03d_%03d.png", + _counter, renderer.getParam(TileRenderer.TR_CURRENT_COLUMN), renderer.getParam(TileRenderer.TR_CURRENT_ROW), tWidth, tHeight, pX, tY, tYOff, pX, pY).replace(' ', '_'); System.err.println("XXX file "+fname); - final File fout = new File(fname); + final File fout = new File(fname); try { ImageIO.write(tBuffer.image, "png", fout); } catch (IOException e) { e.printStackTrace(); } - } + } if( flipVertical ) { final BufferedImage srcImage = tBuffer.image; dstImage = vFlipImage; @@ -347,20 +347,20 @@ public class AWTTilePainter { dstImage = tBuffer.image; } if( DEBUG_TILES ) { - final String fname = String.format("file_%03d_1_tile_[%02d][%02d]_sz_%03dx%03d_pos0_%03d_%03d_yOff_%03d_pos1_%03d_%03d.png", - _counter, + final String fname = String.format("file_%03d_1_tile_[%02d][%02d]_sz_%03dx%03d_pos0_%03d_%03d_yOff_%03d_pos1_%03d_%03d.png", + _counter, renderer.getParam(TileRenderer.TR_CURRENT_COLUMN), renderer.getParam(TileRenderer.TR_CURRENT_ROW), tWidth, tHeight, pX, tY, tYOff, pX, pY).replace(' ', '_'); System.err.println("XXX file "+fname); - final File fout = new File(fname); + final File fout = new File(fname); try { ImageIO.write(dstImage, "png", fout); } catch (IOException e) { e.printStackTrace(); } _counter++; - } + } // Draw resulting image in one shot final BufferedImage outImage = dstImage.getSubimage(0, imgYOff, tWidth, tHeight); final boolean drawDone = g2d.drawImage(outImage, pX, pY, null); // Null ImageObserver since image data is ready. diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTUtil.java b/src/jogl/classes/jogamp/opengl/awt/AWTUtil.java index e15e538c2..dc286ca59 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTUtil.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTUtil.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -85,7 +85,7 @@ public class AWTUtil { NativeWindowFactory.getAWTToolkitLock().lock(); } } catch (Exception e) { j2dOk=false; } - } + } if(!j2dOk) { NativeWindowFactory.getAWTToolkitLock().lock(); } @@ -108,7 +108,7 @@ public class AWTUtil { NativeWindowFactory.getAWTToolkitLock().unlock(); } } catch (Exception e) { j2dOk=false; } - } + } if(!j2dOk) { NativeWindowFactory.getAWTToolkitLock().unlock(); } diff --git a/src/jogl/classes/jogamp/opengl/awt/Java2D.java b/src/jogl/classes/jogamp/opengl/awt/Java2D.java index edf9e89f8..7a8ddf0b4 100644 --- a/src/jogl/classes/jogamp/opengl/awt/Java2D.java +++ b/src/jogl/classes/jogamp/opengl/awt/Java2D.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2003-2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -144,7 +144,7 @@ public class Java2D { } else { if (DEBUG) { System.err.println("Java2D support disabled: by Property "+java2dOGLDisabledByProp+", by OS "+java2dOGLDisabledByOS); - } + } cfg = null; cfgName = "nil"; } @@ -154,8 +154,8 @@ public class Java2D { System.err.println("Java2D support: default GraphicsConfiguration = " + cfgName); } isOGLPipelineActive = cfgName.startsWith("sun.java2d.opengl"); - isOGLPipelineResourceCompatible = isOGLPipelineActive; - + isOGLPipelineResourceCompatible = isOGLPipelineActive; + if (isOGLPipelineActive) { try { // Try to get methods we need to integrate @@ -179,19 +179,19 @@ public class Java2D { Integer.TYPE }); getOGLViewportMethod.setAccessible(true); - + getOGLScissorBoxMethod = utils.getDeclaredMethod("getOGLScissorBox", new Class[] { Graphics.class }); getOGLScissorBoxMethod.setAccessible(true); - + getOGLSurfaceIdentifierMethod = utils.getDeclaredMethod("getOGLSurfaceIdentifier", new Class[] { Graphics.class }); getOGLSurfaceIdentifierMethod.setAccessible(true); - + // Try to get additional methods required for proper FBO support fbObjectSupportInitialized = true; try { @@ -201,7 +201,7 @@ public class Java2D { Runnable.class }); invokeWithOGLSharedContextCurrentMethod.setAccessible(true); - + getOGLSurfaceTypeMethod = utils.getDeclaredMethod("getOGLSurfaceType", new Class[] { Graphics.class @@ -214,7 +214,7 @@ public class Java2D { System.err.println("Info: Disabling Java2D/JOGL FBO support"); } } - + // Try to get an additional method for FBO support in recent Mustang builds try { getOGLTextureTypeMethod = utils.getDeclaredMethod("getOGLTextureType", @@ -228,7 +228,7 @@ public class Java2D { System.err.println("Info: GL_ARB_texture_rectangle FBO support disabled"); } } - + // Try to set up APIs for enabling the bridge on OS X, // where it isn't possible to create generalized // external GLDrawables @@ -244,7 +244,7 @@ public class Java2D { if (cglSurfaceData != null) { // FIXME: for now, assume that FBO support is not enabled on OS X fbObjectSupportInitialized = false; - + // We need to find these methods in order to make the bridge work on OS X createOGLContextOnSurfaceMethod = cglSurfaceData.getDeclaredMethod("createOGLContextOnSurface", new Class[] { @@ -252,14 +252,14 @@ public class Java2D { Long.TYPE }); createOGLContextOnSurfaceMethod.setAccessible(true); - + makeOGLContextCurrentOnSurfaceMethod = cglSurfaceData.getDeclaredMethod("makeOGLContextCurrentOnSurface", new Class[] { Graphics.class, Long.TYPE }); makeOGLContextCurrentOnSurfaceMethod.setAccessible(true); - + destroyOGLContextMethod = cglSurfaceData.getDeclaredMethod("destroyOGLContext", new Class[] { Long.TYPE @@ -273,7 +273,7 @@ public class Java2D { System.err.println("Info: Disabling Java2D/JOGL integration"); } isOGLPipelineActive = false; - isOGLPipelineResourceCompatible = false; + isOGLPipelineResourceCompatible = false; } } } catch (HeadlessException e) { @@ -297,7 +297,7 @@ public class Java2D { public static boolean isOGLPipelineActive() { return isOGLPipelineActive; } - + public static boolean isOGLPipelineResourceCompatible() { return isOGLPipelineResourceCompatible; } @@ -317,7 +317,7 @@ public class Java2D { throw (InternalError) new InternalError().initCause(e); } } - + /** Makes current the OpenGL context associated with the passed Graphics object and runs the given Runnable on the Queue Flushing Thread in one atomic action. */ @@ -556,7 +556,7 @@ public class Java2D { throw new GLException("Java2D OpenGL pipeline not active"); } } - + private static void checkCompatible() { if ( !isOGLPipelineResourceCompatible() ) { throw new GLException("Java2D OpenGL pipeline not resource compatible"); diff --git a/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java b/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java index 55fb3f9a2..a29d1e6aa 100644 --- a/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java +++ b/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java @@ -42,7 +42,7 @@ public class VersionApplet extends Applet { va.init(); frame.add(va, BorderLayout.CENTER); frame.validate(); - + frame.setVisible(true); va.start(); } @@ -68,7 +68,7 @@ public class VersionApplet extends Applet { if(null != canvas) { return; } setEnabled(true); - + GLProfile glp = GLProfile.getDefault(); GLCapabilities glcaps = new GLCapabilities(glp); @@ -87,7 +87,7 @@ public class VersionApplet extends Applet { /* s = NativeWindowVersion.getInstance().toString(); System.err.println(s); - tareaVersion.append(NativeWindowVersion.getInstance().toString()); + tareaVersion.append(NativeWindowVersion.getInstance().toString()); */ s = JoglVersion.getInstance().toString(); diff --git a/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java index 3d59d1d53..1179e2b7f 100644 --- a/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl.egl; import java.util.*; @@ -60,12 +60,12 @@ public final class DesktopES2DynamicLibraryBundleInfo extends GLDynamicLibraryBu public final boolean useToolGetProcAdressFirst(String funcName) { return true; } - + public final List> getToolLibNames() { final List> libsList = new ArrayList>(); final List libsGL = new ArrayList(); - - // Be aware that on DRI systems, eg ATI fglrx, etc, + + // Be aware that on DRI systems, eg ATI fglrx, etc, // you have to set LIBGL_DRIVERS_PATH env variable. // Eg on Ubuntu 64bit systems this is: // export LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri @@ -82,15 +82,15 @@ public final class DesktopES2DynamicLibraryBundleInfo extends GLDynamicLibraryBu // OSX (guess ES2 on OSX will never happen) libsGL.add("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"); - + // last but not least .. the generic one libsGL.add("GL"); - + libsList.add(libsGL); return libsList; - } - + } + public final List getGlueLibNames() { return glueLibNames; - } + } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 179cb7504..3de910369 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -115,7 +115,7 @@ public class EGLContext extends GLContextImpl { if (EGL.eglGetCurrentContext() != contextHandle) { final long dpy = drawable.getNativeSurface().getDisplayHandle(); if (!EGL.eglMakeCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { - throw new GLException("Error making context " + toHexString(contextHandle) + + throw new GLException("Error making context " + toHexString(contextHandle) + " current on Thread " + getThreadName() + " with display " + toHexString(dpy) + ", drawableWrite " + toHexString(drawable.getHandle()) + @@ -128,7 +128,7 @@ public class EGLContext extends GLContextImpl { @Override protected void releaseImpl() throws GLException { if (!EGL.eglMakeCurrent(drawable.getNativeSurface().getDisplayHandle(), EGL.EGL_NO_SURFACE, EGL.EGL_NO_SURFACE, EGL.EGL_NO_CONTEXT)) { - throw new GLException("Error freeing OpenGL context " + toHexString(contextHandle) + + throw new GLException("Error freeing OpenGL context " + toHexString(contextHandle) + ": error code " + toHexString(EGL.eglGetError())); } } @@ -138,7 +138,7 @@ public class EGLContext extends GLContextImpl { if (!EGL.eglDestroyContext(drawable.getNativeSurface().getDisplayHandle(), contextHandle)) { final int eglError = EGL.eglGetError(); if(EGL.EGL_SUCCESS != eglError) { /* oops, Mesa EGL impl. may return false, but has no EGL error */ - throw new GLException("Error destroying OpenGL context " + toHexString(contextHandle) + + throw new GLException("Error destroying OpenGL context " + toHexString(contextHandle) + ": error code " + toHexString(eglError)); } } @@ -285,11 +285,11 @@ public class EGLContext extends GLContextImpl { // // Accessible .. // - + /* pp */ void mapCurrentAvailableGLVersion(AbstractGraphicsDevice device) { mapStaticGLVersion(device, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); } - /* pp */ int getContextOptions() { return ctxOptions; } + /* pp */ int getContextOptions() { return ctxOptions; } /* pp */ static void mapStaticGLESVersion(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps) { final GLProfile glp = caps.getGLProfile(); final int[] reqMajorCTP = new int[2]; @@ -305,7 +305,7 @@ public class EGLContext extends GLContextImpl { reqMajorCTP[1] |= GLContext.CTX_IMPL_ACCEL_SOFT; } mapStaticGLVersion(device, reqMajorCTP[0], 0, reqMajorCTP[1]); - } + } /* pp */ static void mapStaticGLESVersion(AbstractGraphicsDevice device, final int major) { int ctp = GLContext.CTX_PROFILE_ES; if( major >= 3 ) { @@ -324,20 +324,20 @@ public class EGLContext extends GLContextImpl { if(! ( device instanceof EGLGraphicsDevice ) ) { final EGLGraphicsDevice eglDevice = new EGLGraphicsDevice(device.getHandle(), EGL.EGL_NO_DISPLAY, device.getConnection(), device.getUnitID(), null); GLContext.mapAvailableGLVersion(eglDevice, reqMajor, reqProfile, major, minor, ctp); - } + } } } protected static String getGLVersion(int major, int minor, int ctp, String gl_version) { return GLContext.getGLVersion(major, minor, ctp, gl_version); } - + protected static boolean getAvailableGLVersionsSet(AbstractGraphicsDevice device) { return GLContext.getAvailableGLVersionsSet(device); } protected static void setAvailableGLVersionsSet(AbstractGraphicsDevice device) { GLContext.setAvailableGLVersionsSet(device); } - + protected static String toHexString(int hex) { return GLContext.toHexString(hex); } @@ -358,7 +358,7 @@ public class EGLContext extends GLContextImpl { public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { throw new GLException("Should not call this"); } - + @Override public final void glFreeMemoryNV(ByteBuffer pointer) { throw new GLException("Should not call this"); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index f2efb0479..89f34432d 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -41,8 +41,8 @@ import jogamp.opengl.Debug; import com.jogamp.common.util.LongObjectHashMap; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; -/** - * This implementation provides recursive calls to +/** + * This implementation provides recursive calls to * {@link EGL#eglInitialize(long, IntBuffer, IntBuffer)} and {@link EGL#eglTerminate(long)}, * where eglInitialize(..) is issued only for the 1st call per eglDisplay * and eglTerminate(..) is issued only for the last call. @@ -53,30 +53,30 @@ import com.jogamp.nativewindow.egl.EGLGraphicsDevice; */ public class EGLDisplayUtil { protected static final boolean DEBUG = Debug.debug("EGLDisplayUtil"); - + private static class DpyCounter { final long eglDisplay; final Throwable createdStack; int refCount; - + private DpyCounter(long eglDisplay) { this.eglDisplay = eglDisplay; this.refCount = 0; this.createdStack = DEBUG ? new Throwable() : null; } - + public String toString() { return "EGLDisplay[0x"+Long.toHexString(eglDisplay)+": refCnt "+refCount+"]"; } } static final LongObjectHashMap eglDisplayCounter; - + static { eglDisplayCounter = new LongObjectHashMap(); eglDisplayCounter.setKeyNotFoundValue(null); } - /** + /** * @return number of unclosed EGL Displays.
          */ public static int shutdown(boolean verbose) { @@ -91,7 +91,7 @@ public class EGLDisplayUtil { } return eglDisplayCounter.size(); } - + public static void dumpOpenDisplayConnections() { System.err.println("EGLDisplayUtil: Open EGL Display Connections: "+eglDisplayCounter.size()); int i=0; @@ -104,7 +104,7 @@ public class EGLDisplayUtil { } } } - + public static long eglGetDisplay(long nativeDisplay_id) { final long eglDisplay = EGL.eglGetDisplay(nativeDisplay_id); if(DEBUG) { @@ -114,16 +114,16 @@ public class EGLDisplayUtil { } return eglDisplay; } - + /** * @param eglDisplay * @param major * @param minor * @return true if the eglDisplay is valid and it's reference counter becomes one and {@link EGL#eglInitialize(long, IntBuffer, IntBuffer)} was successful, otherwise false - * + * * @see EGL#eglInitialize(long, IntBuffer, IntBuffer) */ - public static synchronized boolean eglInitialize(long eglDisplay, IntBuffer major, IntBuffer minor) { + public static synchronized boolean eglInitialize(long eglDisplay, IntBuffer major, IntBuffer minor) { if( EGL.EGL_NO_DISPLAY == eglDisplay) { return false; } @@ -157,16 +157,16 @@ public class EGLDisplayUtil { } return res; } - + /** * @param nativeDisplayID * @param eglDisplay array of size 1 holding return value if successful, otherwise {@link EGL#EGL_NO_DISPLAY}. - * @param eglErr array of size 1 holding the EGL error value as retrieved by {@link EGL#eglGetError()} if not successful. + * @param eglErr array of size 1 holding the EGL error value as retrieved by {@link EGL#eglGetError()} if not successful. * @param major * @param minor - * @return {@link EGL#EGL_SUCCESS} if successful, otherwise {@link EGL#EGL_BAD_DISPLAY} if {@link #eglGetDisplay(long)} failed + * @return {@link EGL#EGL_SUCCESS} if successful, otherwise {@link EGL#EGL_BAD_DISPLAY} if {@link #eglGetDisplay(long)} failed * or {@link EGL#EGL_NOT_INITIALIZED} if {@link #eglInitialize(long, IntBuffer, IntBuffer)} failed. - * + * * @see #eglGetDisplay(long) * @see #eglInitialize(long, IntBuffer, IntBuffer) */ @@ -184,7 +184,7 @@ public class EGLDisplayUtil { eglDisplay[0] = _eglDisplay; return EGL.EGL_SUCCESS; } - + /** * @param nativeDisplayID in/out array of size 1, passing the requested nativeVisualID, may return a different revised nativeVisualID handle * @return the initialized EGL display ID @@ -209,7 +209,7 @@ public class EGLDisplayUtil { } throw new GLException("Failed to created/initialize EGL display incl. fallback default: native "+EGLContext.toHexString(nativeDisplayID[0])+", error "+EGLContext.toHexString(eglRes)+"/"+EGLContext.toHexString(eglError[0])); } - + /** * @param eglDisplay the EGL display handle * @return true if the eglDisplay is valid and it's reference counter becomes zero and {@link EGL#eglTerminate(long)} was successful, otherwise false @@ -218,7 +218,7 @@ public class EGLDisplayUtil { if( EGL.EGL_NO_DISPLAY == eglDisplay) { return false; } - final boolean res; + final boolean res; final int refCnt; final DpyCounter d; { @@ -237,7 +237,7 @@ public class EGLDisplayUtil { } else { if(0 < refCnt) { // no negative refCount d.refCount = refCnt; - } + } res = true; } if(DEBUG) { @@ -246,7 +246,7 @@ public class EGLDisplayUtil { } return res; } - + public static final EGLGraphicsDevice.EGLDisplayLifecycleCallback eglLifecycleCallback = new EGLGraphicsDevice.EGLDisplayLifecycleCallback() { public long eglGetAndInitDisplay(long[] nativeDisplayID) { return eglGetDisplayAndInitialize(nativeDisplayID); @@ -255,25 +255,25 @@ public class EGLDisplayUtil { EGLDisplayUtil.eglTerminate(eglDisplayHandle); } }; - + /** * @param nativeDisplayID * @param connection * @param unitID - * @return an initialized EGLGraphicsDevice + * @return an initialized EGLGraphicsDevice * @throws GLException if {@link EGL#eglGetDisplay(long)} or {@link EGL#eglInitialize(long, int[], int, int[], int)} fails - * @see EGLGraphicsDevice#EGLGraphicsDevice(long, long, String, int, com.jogamp.nativewindow.egl.EGLGraphicsDevice.EGLDisplayLifecycleCallback) + * @see EGLGraphicsDevice#EGLGraphicsDevice(long, long, String, int, com.jogamp.nativewindow.egl.EGLGraphicsDevice.EGLDisplayLifecycleCallback) */ public static EGLGraphicsDevice eglCreateEGLGraphicsDevice(long nativeDisplayID, String connection, int unitID) { final EGLGraphicsDevice eglDisplay = new EGLGraphicsDevice(nativeDisplayID, EGL.EGL_NO_DISPLAY, connection, unitID, eglLifecycleCallback); eglDisplay.open(); return eglDisplay; } - + /** * @param surface - * @return an initialized EGLGraphicsDevice - * @throws GLException if {@link EGL#eglGetDisplay(long)} or {@link EGL#eglInitialize(long, int[], int, int[], int)} fails incl fallback + * @return an initialized EGLGraphicsDevice + * @throws GLException if {@link EGL#eglGetDisplay(long)} or {@link EGL#eglInitialize(long, int[], int, int[], int)} fails incl fallback */ public static EGLGraphicsDevice eglCreateEGLGraphicsDevice(NativeSurface surface) { final long nativeDisplayID; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java index 2edf26145..bf269c548 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java @@ -59,15 +59,15 @@ public abstract class EGLDrawable extends GLDrawableImpl { @Override public abstract GLContext createContext(GLContext shareWith); - protected abstract long createSurface(EGLGraphicsConfiguration config, int width, int height, long nativeSurfaceHandle); + protected abstract long createSurface(EGLGraphicsConfiguration config, int width, int height, long nativeSurfaceHandle); private final long createEGLSurface() { final EGLWrappedSurface eglws = (EGLWrappedSurface) surface; - final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) eglws.getGraphicsConfiguration(); + final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) eglws.getGraphicsConfiguration(); final NativeSurface upstreamSurface = eglws.getUpstreamSurface(); - + long eglSurface = createSurface(eglConfig, eglws.getWidth(), eglws.getHeight(), upstreamSurface.getSurfaceHandle()); - + int eglError0; if (EGL.EGL_NO_SURFACE == eglSurface) { eglError0 = EGL.eglGetError(); @@ -104,7 +104,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { final EGLWrappedSurface eglws = (EGLWrappedSurface) surface; if(DEBUG) { System.err.println(getThreadName() + ": createHandle of "+eglws); - } + } if( eglws.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { if( EGL.EGL_NO_SURFACE != eglws.getSurfaceHandle() ) { throw new InternalError("Set surface but claimed to be invalid: "+eglws); @@ -114,12 +114,12 @@ public abstract class EGLDrawable extends GLDrawableImpl { throw new InternalError("Nil surface but claimed to be valid: "+eglws); } } - - protected void destroyHandle() { + + protected void destroyHandle() { final EGLWrappedSurface eglws = (EGLWrappedSurface) surface; if(DEBUG) { System.err.println(getThreadName() + ": destroyHandle of "+eglws); - } + } if( EGL.EGL_NO_SURFACE == eglws.getSurfaceHandle() ) { throw new InternalError("Nil surface but claimed to be valid: "+eglws); } @@ -134,7 +134,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { if( 0 == surfaceHandle ) { return false; } - final IntBuffer val = Buffers.newDirectIntBuffer(1); + final IntBuffer val = Buffers.newDirectIntBuffer(1); final boolean eglSurfaceValid = EGL.eglQuerySurface(eglDisplayHandle, surfaceHandle, EGL.EGL_CONFIG_ID, val); if( !eglSurfaceValid ) { final int eglErr = EGL.eglGetError(); @@ -144,7 +144,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { } return eglSurfaceValid; } - + @Override protected final void setRealizedImpl() { if(DEBUG) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 5d99e3eba..a0d896e3a 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -83,14 +83,14 @@ import com.jogamp.opengl.GLRendererQuirks; public class EGLDrawableFactory extends GLDrawableFactoryImpl { protected static final boolean DEBUG = GLDrawableFactoryImpl.DEBUG; // allow package access - + /* package */ static final boolean QUERY_EGL_ES_NATIVE_TK; - + static { Debug.initSingleton(); QUERY_EGL_ES_NATIVE_TK = Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.QueryNativeTK", true); } - + private static GLDynamicLookupHelper eglES1DynamicLookupHelper = null; private static GLDynamicLookupHelper eglES2DynamicLookupHelper = null; @@ -109,7 +109,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { dl.isFunctionAvailable("glEnableClientState") && dl.isFunctionAvailable("glColorPointer"); } - + public EGLDrawableFactory() { super(); @@ -189,10 +189,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } else { if( isANGLE && ( DEBUG || GLProfile.DEBUG ) ) { System.err.println("Info: EGLDrawableFactory.init - EGL/ES2 ANGLE enabled"); - } + } sharedMap = new HashMap(); sharedMapCreateAttempt = new HashSet(); - + // FIXME: Following triggers eglInitialize(..) which crashed on Windows w/ Chrome/Angle, FF/Angle! defaultDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } @@ -204,8 +204,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { protected final boolean isComplete() { return null != sharedMap; // null != eglES2DynamicLookupHelper || null != eglES1DynamicLookupHelper; } - - + + @Override protected final void destroy() { if(null != sharedMap) { @@ -247,7 +247,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { EGLGraphicsConfigurationFactory.unregisterFactory(); EGLDisplayUtil.shutdown(DEBUG); } - + private void dumpMap() { synchronized(sharedMap) { System.err.println("EGLDrawableFactory.map "+sharedMap.size()); @@ -265,7 +265,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } private HashMap sharedMap = null; - private HashSet sharedMapCreateAttempt = null; + private HashSet sharedMapCreateAttempt = null; private EGLGraphicsDevice defaultDevice = null; private SharedResource defaultSharedResource = null; private boolean isANGLE = false; @@ -286,9 +286,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { private final boolean hasPBufferES1; private final boolean hasPBufferES3ES2; - SharedResource(EGLGraphicsDevice dev, - boolean wasContextES1Created, boolean hasPBufferES1, GLRendererQuirks rendererQuirksES1, int ctpES1, - boolean wasContextES2Created, boolean wasContextES3Created, + SharedResource(EGLGraphicsDevice dev, + boolean wasContextES1Created, boolean hasPBufferES1, GLRendererQuirks rendererQuirksES1, int ctpES1, + boolean wasContextES2Created, boolean wasContextES3Created, boolean hasPBufferES3ES2, GLRendererQuirks rendererQuirksES3ES2, int ctpES3ES2) { this.device = dev; // this.contextES1 = ctxES1; @@ -296,7 +296,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { this.hasPBufferES1= hasPBufferES1; this.rendererQuirksES1 = rendererQuirksES1; this.ctpES1 = ctpES1; - + // this.contextES2 = ctxES2; // this.contextES3 = ctxES3; this.wasES2ContextCreated = wasContextES2Created; @@ -314,7 +314,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { // final EGLContext getContextES1() { return contextES1; } // final EGLContext getContextES2() { return contextES2; } // final EGLContext getContextES3() { return contextES3; } - + @Override public AbstractGraphicsScreen getScreen() { return null; @@ -329,7 +329,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } @Override public GLRendererQuirks getRendererQuirks() { - return null != rendererQuirksES3ES2 ? rendererQuirksES3ES2 : rendererQuirksES1 ; + return null != rendererQuirksES3ES2 ? rendererQuirksES3ES2 : rendererQuirksES1 ; } } @@ -359,18 +359,18 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } return new ArrayList(0); } - - private boolean mapAvailableEGLESConfig(AbstractGraphicsDevice adevice, int esProfile, + + private boolean mapAvailableEGLESConfig(AbstractGraphicsDevice adevice, int esProfile, boolean[] hasPBuffer, GLRendererQuirks[] rendererQuirks, int[] ctp) { final String profileString; switch( esProfile ) { case 3: - profileString = GLProfile.GLES3; break; + profileString = GLProfile.GLES3; break; case 2: - profileString = GLProfile.GLES2; break; - case 1: + profileString = GLProfile.GLES2; break; + case 1: profileString = GLProfile.GLES1; break; - default: + default: throw new GLException("Invalid ES profile number "+esProfile); } if ( !GLProfile.isAvailable(adevice, profileString) ) { @@ -394,23 +394,23 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { ProxySurface upstreamSurface = null; // X11, GLX, .. boolean success = false; boolean deviceFromUpstreamSurface = false; - try { + try { final GLCapabilities reqCapsAny = new GLCapabilities(glp); reqCapsAny.setRedBits(5); reqCapsAny.setGreenBits(5); reqCapsAny.setBlueBits(5); reqCapsAny.setAlphaBits(0); reqCapsAny.setDoubleBuffered(false); - + if( mapsADeviceToDefaultDevice ) { // In this branch, any non EGL device is mapped to EGL default shared resources (default behavior). - // Only one default shared resource instance is ever be created. + // Only one default shared resource instance is ever be created. final GLCapabilitiesImmutable reqCapsPBuffer = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(reqCapsAny); final List availablePBufferCapsL = getAvailableEGLConfigs(defaultDevice, reqCapsPBuffer); hasPBuffer[0] = availablePBufferCapsL.size() > 0; - + // 1st case: adevice is not the EGL default device, map default shared resources if( adevice != defaultDevice ) { if(null == defaultSharedResource) { return false; - } + } switch(esProfile) { case 3: if( !defaultSharedResource.wasES3ContextCreated ) { @@ -419,14 +419,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { rendererQuirks[0] = defaultSharedResource.rendererQuirksES3ES2; ctp[0] = defaultSharedResource.ctpES3ES2; break; - case 2: + case 2: if( !defaultSharedResource.wasES2ContextCreated ) { return false; } rendererQuirks[0] = defaultSharedResource.rendererQuirksES3ES2; ctp[0] = defaultSharedResource.ctpES3ES2; break; - case 1: + case 1: if( !defaultSharedResource.wasES1ContextCreated ) { return false; } @@ -437,11 +437,11 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { EGLContext.mapStaticGLVersion(adevice, esProfile, 0, ctp[0]); return true; } - + // attempt to created the default shared resources .. - + eglDevice = defaultDevice; // reuse - + if( hasPBuffer[0] ) { // 2nd case create defaultDevice shared resource using pbuffer surface surface = createDummySurfaceImpl(eglDevice, false, reqCapsPBuffer, reqCapsPBuffer, null, 64, 64); // egl pbuffer offscreen @@ -459,15 +459,15 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if(DEBUG) { System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig() no pbuffer config available, detected !pbuffer config: "+success); EGLGraphicsConfigurationFactory.printCaps("!PBufferCaps", capsAnyL, System.err); - } - } + } + } } else { - // 4th case always creates a true mapping of given device to EGL + // 4th case always creates a true mapping of given device to EGL surface = desktopFactory.createDummySurface(adevice, reqCapsAny, null, 64, 64); // X11, WGL, .. dummy window upstreamSurface = ( surface instanceof ProxySurface ) ? (ProxySurface)surface : null ; if(null != upstreamSurface) { upstreamSurface.createNotify(); - } + } eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface); deviceFromUpstreamSurface = true; hasPBuffer[0] = true; @@ -482,7 +482,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { context.makeCurrent(); // could cause exception if(context.isCurrent()) { final String glVersion = context.getGL().glGetString(GL.GL_VERSION); - if(null != glVersion) { + if(null != glVersion) { context.mapCurrentAvailableGLVersion(eglDevice); if(eglDevice != adevice) { context.mapCurrentAvailableGLVersion(adevice); @@ -493,7 +493,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } else { // Oops .. something is wrong if(DEBUG) { - System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: "+eglDevice+", "+context.getGLVersion()+" - VERSION is null, dropping availability!"); + System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: "+eglDevice+", "+context.getGLVersion()+" - VERSION is null, dropping availability!"); } } } @@ -510,7 +510,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } } catch (Throwable t) { if(DEBUG) { - System.err.println("Catched Exception on thread "+getThreadName()); + System.err.println("Catched Exception on thread "+getThreadName()); t.printStackTrace(); } success = false; @@ -518,7 +518,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if(eglDevice == defaultDevice) { if(null != upstreamSurface) { upstreamSurface.destroyNotify(); - } + } } else if( deviceFromUpstreamSurface ) { if(null != eglDevice) { eglDevice.close(); @@ -529,7 +529,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } else { if(null != upstreamSurface) { upstreamSurface.destroyNotify(); - } + } if(null != eglDevice) { eglDevice.close(); } @@ -553,9 +553,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } return false; } - } + } } - + @Override protected final SharedResource getOrCreateSharedResourceImpl(AbstractGraphicsDevice adevice) { if(null == sharedMap) { // null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper @@ -571,27 +571,27 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { dumpMap(); throw new InternalError("defaultSharedResource already exist: "+defaultSharedResource); } - defaultSharedResource = createEGLSharedResourceImpl(defaultDevice); + defaultSharedResource = createEGLSharedResourceImpl(defaultDevice); } - + final String key = adevice.getUniqueID(); if( defaultDevice.getUniqueID().equals(key) ) { return defaultSharedResource; } else { - if( null == defaultSharedResource) { // defaultDevice must be initialized before host-device + if( null == defaultSharedResource) { // defaultDevice must be initialized before host-device dumpMap(); - throw new InternalError("defaultSharedResource does not exist"); + throw new InternalError("defaultSharedResource does not exist"); } final SharedResource[] existing = new SharedResource[] { null }; if ( !needsToCreateSharedResource(key, existing) ) { return existing[0]; - } + } return createEGLSharedResourceImpl(adevice); } } - + private SharedResource createEGLSharedResourceImpl(AbstractGraphicsDevice adevice) { - final boolean madeCurrentES1; + final boolean madeCurrentES1; final boolean madeCurrentES2; final boolean madeCurrentES3; boolean[] hasPBufferES1 = new boolean[] { false }; @@ -602,12 +602,12 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { GLRendererQuirks[] rendererQuirksES3ES2 = new GLRendererQuirks[] { null }; int[] ctpES1 = new int[] { -1 }; int[] ctpES3ES2 = new int[] { -1 }; - - + + if (DEBUG) { System.err.println("EGLDrawableFactory.createShared(): device "+adevice); } - + if( null != eglES1DynamicLookupHelper ) { madeCurrentES1 = mapAvailableEGLESConfig(adevice, 1, hasPBufferES1, rendererQuirksES1, ctpES1); } else { @@ -625,10 +625,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { madeCurrentES2 = false; madeCurrentES3 = false; } - + if( !EGLContext.getAvailableGLVersionsSet(adevice) ) { // Even though we override the non EGL native mapping intentionally, - // avoid exception due to double 'set' - carefull exception of the rule. + // avoid exception due to double 'set' - carefull exception of the rule. EGLContext.setAvailableGLVersionsSet(adevice); } if( hasX11 ) { @@ -637,7 +637,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } final SharedResource sr = new SharedResource(defaultDevice, madeCurrentES1, hasPBufferES1[0], rendererQuirksES1[0], ctpES1[0], madeCurrentES2, madeCurrentES3, hasPBufferES3ES2[0], rendererQuirksES3ES2[0], ctpES3ES2[0]); - + synchronized(sharedMap) { sharedMap.put(adevice.getUniqueID(), sr); } @@ -650,7 +650,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } return sr; } - + private void handleDontCloseX11DisplayQuirk(GLRendererQuirks quirks) { if( null != quirks && quirks.exist( GLRendererQuirks.DontCloseX11Display ) ) { jogamp.nativewindow.x11.X11Util.markAllDisplaysUnclosable(); @@ -692,7 +692,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } return new EGLOnscreenDrawable(this, EGLWrappedSurface.get(target)); } - + @Override protected GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) { if (target == null) { @@ -715,8 +715,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, - GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, + protected ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final boolean ownDevice; final EGLGraphicsDevice device; @@ -732,21 +732,21 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); final EGLGraphicsConfiguration config = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); if(null == config) { - throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); - } + throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); + } return new WrappedSurface(config, 0, upstreamHook, ownDevice); } - + @Override - public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { - chosenCaps = GLGraphicsConfigurationUtil.fixOffscreenBitOnly(chosenCaps); // complete validation in EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(..) above + chosenCaps = GLGraphicsConfigurationUtil.fixOffscreenBitOnly(chosenCaps); // complete validation in EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(..) above return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new EGLDummyUpstreamSurfaceHook(width, height)); } - + /** - * @param ms {@link MutableSurface} which dimensions and config are being used to create the pbuffer surface. - * It will also hold the resulting pbuffer surface handle. + * @param ms {@link MutableSurface} which dimensions and config are being used to create the pbuffer surface. + * It will also hold the resulting pbuffer surface handle. * @param useTexture * @return the passed {@link MutableSurface} which now has the EGL pbuffer surface set as it's handle */ diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java index 162e7166a..eb6578ec5 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java @@ -9,17 +9,17 @@ import com.jogamp.nativewindow.egl.EGLGraphicsDevice; public class EGLDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { /** - * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, - * not the actual dummy surface width. + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, * not the actual dummy surface height, * The latter is platform specific and small */ public EGLDummyUpstreamSurfaceHook(int width, int height) { super(width, height); } - + @Override public final void create(ProxySurface s) { final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) s.getGraphicsConfiguration().getScreen().getDevice(); @@ -31,14 +31,14 @@ public class EGLDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize } if( EGL.EGL_NO_SURFACE == s.getSurfaceHandle() ) { s.setSurfaceHandle( EGLDrawableFactory.createPBufferSurfaceImpl((EGLGraphicsConfiguration)s.getGraphicsConfiguration(), 64, 64, false) ); - s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); } finally { eglDevice.unlock(); } } - + @Override public final void destroy(ProxySurface s) { if( s.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java index 778f0cb38..ac880ebc0 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl.egl; import com.jogamp.common.os.AndroidVersion; @@ -52,7 +52,7 @@ public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundle super(); } - /** + /** * Returns true on Android, * and false otherwise. */ @@ -65,7 +65,7 @@ public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundle // default behavior for other platforms return false; } - + @Override public final List getToolGetProcAddressFuncNameList() { List res = new ArrayList(); @@ -87,26 +87,26 @@ public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundle return true; } } - + protected final List getEGLLibNamesList() { List eglLibNames = new ArrayList(); - - // this is the default EGL lib name, according to the spec + + // this is the default EGL lib name, according to the spec eglLibNames.add("libEGL.so.1"); - + // try these as well, if spec fails eglLibNames.add("libEGL.so"); eglLibNames.add("EGL"); - - // for windows distributions using the 'unlike' lib prefix, + + // for windows distributions using the 'unlike' lib prefix, // where our tool does not add it. eglLibNames.add("libEGL"); - + return eglLibNames; } @Override public final List getGlueLibNames() { return glueLibNames; - } + } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java index dd3d6faea..9ffcea864 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl.egl; import java.util.*; @@ -39,29 +39,29 @@ public final class EGLES1DynamicLibraryBundleInfo extends EGLDynamicLibraryBundl final List> libsList = new ArrayList>(); { final List libsGL = new ArrayList(); - - // this is the default lib name, according to the spec + + // this is the default lib name, according to the spec libsGL.add("libGLESv1_CM.so.2"); - + // try these as well, if spec fails libsGL.add("libGLESv1_CM.so"); - libsGL.add("GLESv1_CM"); + libsGL.add("GLESv1_CM"); // alternative names libsGL.add("GLES_CM"); libsGL.add("GLES_CL"); - - // for windows distributions using the 'unlike' lib prefix, + + // for windows distributions using the 'unlike' lib prefix, // where our tool does not add it. libsGL.add("libGLESv1_CM"); libsGL.add("libGLES_CM"); libsGL.add("libGLES_CL"); - + libsList.add(libsGL); } libsList.add(getEGLLibNamesList()); - + return libsList; - } + } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java index 0d20fd4e8..de1f0a42e 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,17 +20,17 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl.egl; import java.util.*; -/** +/** *

          * Covering ES3 and ES2. *

          @@ -44,12 +44,12 @@ public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundl final List> libsList = new ArrayList>(); { final List libsGL = new ArrayList(); - - // ES3: This is the default lib name, according to the spec + + // ES3: This is the default lib name, according to the spec libsGL.add("libGLESv3.so.3"); - + // ES3: Try these as well, if spec fails - libsGL.add("libGLESv3.so"); + libsGL.add("libGLESv3.so"); libsGL.add("GLESv3"); // ES3: Alternative names @@ -59,12 +59,12 @@ public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundl // where our tool does not add it. libsGL.add("libGLESv3"); libsGL.add("libGLES30"); - - // ES2: This is the default lib name, according to the spec + + // ES2: This is the default lib name, according to the spec libsGL.add("libGLESv2.so.2"); - + // ES2: Try these as well, if spec fails - libsGL.add("libGLESv2.so"); + libsGL.add("libGLESv2.so"); libsGL.add("GLESv2"); // ES2: Alternative names @@ -75,14 +75,14 @@ public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundl // where our tool does not add it. libsGL.add("libGLESv2"); libsGL.add("libGLESv2_CM"); - libsGL.add("libGLES20"); - + libsGL.add("libGLES20"); + libsList.add(libsGL); } libsList.add(getEGLLibNamesList()); - + return libsList; - } - + } + } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index b1ffe608e..f3592c150 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -57,7 +57,7 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { - + public final long getNativeConfig() { return ((EGLGLCapabilities)capabilitiesChosen).getEGLConfig(); } @@ -66,7 +66,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple return ((EGLGLCapabilities)capabilitiesChosen).getEGLConfigID(); } - EGLGraphicsConfiguration(AbstractGraphicsScreen absScreen, + EGLGraphicsConfiguration(AbstractGraphicsScreen absScreen, EGLGLCapabilities capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { super(absScreen, capsChosen, capsRequested); this.chooser = chooser; @@ -77,7 +77,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple * @param absScreen * @param eglConfigID {@link EGL#EGL_CONFIG_ID} for which the config is being created for. * @return - * @throws GLException if invalid EGL display. + * @throws GLException if invalid EGL display. */ public static EGLGraphicsConfiguration create(GLCapabilitiesImmutable capsRequested, AbstractGraphicsScreen absScreen, int eglConfigID) { final AbstractGraphicsDevice absDevice = absScreen.getDevice(); @@ -101,9 +101,9 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple public Object clone() { return super.clone(); } - + void updateGraphicsConfiguration() { - CapabilitiesImmutable capsChosen = getChosenCapabilities(); + CapabilitiesImmutable capsChosen = getChosenCapabilities(); EGLGraphicsConfiguration newConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(getScreen().getDevice(), capsChosen).chooseGraphicsConfiguration( capsChosen, getRequestedCapabilities(), chooser, getScreen(), VisualIDHolder.VID_UNDEFINED); @@ -140,7 +140,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple return false; } final IntBuffer val = Buffers.newDirectIntBuffer(1); - + // get the configID if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_CONFIG_ID, val)) { final int eglErr = EGL.eglGetError(); @@ -169,7 +169,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } if ( 0 != ( _stype & EGL.EGL_PBUFFER_BIT ) ) { val |= GLGraphicsConfigurationUtil.PBUFFER_BIT | - GLGraphicsConfigurationUtil.FBO_BIT; + GLGraphicsConfigurationUtil.FBO_BIT; } return val; } @@ -189,7 +189,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple final int cfgID; final int rType; final int visualID; - + // get the configID if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_CONFIG_ID, val)) { if(DEBUG) { @@ -199,7 +199,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple return null; } cfgID = val.get(0); - + if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_RENDERABLE_TYPE, val)) { if(DEBUG) { System.err.println("EGL couldn't retrieve EGL_RENDERABLE_TYPE for config "+toHexString(config)+", error "+toHexString(EGL.eglGetError())); @@ -213,8 +213,8 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } else { visualID = VisualIDHolder.VID_UNDEFINED; } - - EGLGLCapabilities caps = null; + + EGLGLCapabilities caps = null; try { if(null == glp) { glp = EGLGLCapabilities.getCompatible(device, rType); @@ -232,8 +232,8 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple System.err.println("config "+toHexString(config)+": "+gle); } return null; - } - + } + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_CONFIG_CAVEAT, val)) { if( EGL.EGL_SLOW_CONFIG == val.get(0) ) { caps.setHardwareAccelerated(false); @@ -244,11 +244,11 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple caps.setNumSamples(val.get(0)); } if(!caps.getSampleBuffers()) { - // try NV_coverage_sample extension + // try NV_coverage_sample extension if(EGL.eglGetConfigAttrib(display, config, EGLExt.EGL_COVERAGE_BUFFERS_NV, val)) { if(val.get(0)>0 && EGL.eglGetConfigAttrib(display, config, EGLExt.EGL_COVERAGE_SAMPLES_NV, val)) { - caps.setSampleExtension(GLGraphicsConfigurationUtil.NV_coverage_sample); + caps.setSampleExtension(GLGraphicsConfigurationUtil.NV_coverage_sample); caps.setSampleBuffers(true); caps.setNumSamples(val.get(0)); } @@ -269,7 +269,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_BLUE_VALUE, val)) { caps.setTransparentBlueValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0)); } - /** Not defined in EGL + /** Not defined in EGL if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_ALPHA_VALUE, val)) { caps.setTransparentAlphaValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0)); } */ @@ -294,16 +294,16 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple caps.setDepthBits(val.get(0)); } - // Since the passed GLProfile may be null, + // Since the passed GLProfile may be null, // we use EGL_RENDERABLE_TYPE derived profile as created in the EGLGLCapabilities constructor. - final int availableTypeBits = EGLConfigDrawableTypeBits(device, config); + final int availableTypeBits = EGLConfigDrawableTypeBits(device, config); final int drawableTypeBits = winattrmask & availableTypeBits; if( 0 == drawableTypeBits ) { return null; } - - return (EGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, caps); + + return (EGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, caps); } public static IntBuffer GLCapabilities2AttribList(GLCapabilitiesImmutable caps) { @@ -313,7 +313,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple attrs.put(idx++, EGL.EGL_SURFACE_TYPE); final int surfaceType; if( caps.isOnscreen() ) { - surfaceType = EGL.EGL_WINDOW_BIT; + surfaceType = EGL.EGL_WINDOW_BIT; } else if( caps.isFBO() ) { surfaceType = EGL.EGL_PBUFFER_BIT; // native replacement! } else if( caps.isPBuffer() ) { @@ -338,7 +338,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple attrs.put(idx++, EGL.EGL_ALPHA_SIZE); attrs.put(idx++, caps.getAlphaBits()); } - + if(caps.getStencilBits()>0) { attrs.put(idx++, EGL.EGL_STENCIL_SIZE); attrs.put(idx++, caps.getStencilBits()); @@ -382,7 +382,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple attrs.put(idx++, caps.getTransparentAlphaValue()>=0?caps.getTransparentAlphaValue():EGL.EGL_DONT_CARE; */ } - // 28 + // 28 attrs.put(idx++, EGL.EGL_RENDERABLE_TYPE); if(caps.getGLProfile().usesNativeGLES1()) { attrs.put(idx++, EGL.EGL_OPENGL_ES_BIT); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index b44e08500..5764a6178 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -75,10 +75,10 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact static GraphicsConfigurationFactory nativeGraphicsConfigurationFactory = null; static GraphicsConfigurationFactory kdeglGraphicsConfigurationFactory = null; static GraphicsConfigurationFactory fallbackGraphicsConfigurationFactory = null; - + static void registerFactory() { GraphicsConfigurationFactory eglFactory = new EGLGraphicsConfigurationFactory(); - + // become the pre-selector for X11/.. to match the native visual id w/ EGL, if native ES is selected final String nwType = NativeWindowFactory.getNativeWindowType(false); if(NativeWindowFactory.TYPE_X11 == nwType) { @@ -86,32 +86,32 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(null != nativeGraphicsConfigurationFactory) { fallbackGraphicsConfigurationFactory = nativeGraphicsConfigurationFactory; } else { - fallbackGraphicsConfigurationFactory = GraphicsConfigurationFactory.getFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, CapabilitiesImmutable.class); + fallbackGraphicsConfigurationFactory = GraphicsConfigurationFactory.getFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, CapabilitiesImmutable.class); } } /* else if(NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false)) { nativeGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.windows.WindowsGraphicsDevice.class, eglFactory); - } else if(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)) { + } else if(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)) { } */ - + // become the selector for KD/EGL .. - kdeglGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.egl.EGLGraphicsDevice.class, GLCapabilitiesImmutable.class, eglFactory); + kdeglGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.egl.EGLGraphicsDevice.class, GLCapabilitiesImmutable.class, eglFactory); } - + static void unregisterFactory() { final String nwType = NativeWindowFactory.getNativeWindowType(false); if(NativeWindowFactory.TYPE_X11 == nwType) { - GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, GLCapabilitiesImmutable.class, nativeGraphicsConfigurationFactory); + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, GLCapabilitiesImmutable.class, nativeGraphicsConfigurationFactory); } /* else if(NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false)) { GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.windows.WindowsGraphicsDevice.class, nativeGraphicsConfigurationFactory); - } else if(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)) { + } else if(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)) { } */ nativeGraphicsConfigurationFactory = null; fallbackGraphicsConfigurationFactory = null; - + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.egl.EGLGraphicsDevice.class, GLCapabilitiesImmutable.class, kdeglGraphicsConfigurationFactory); kdeglGraphicsConfigurationFactory = null; } - + private EGLGraphicsConfigurationFactory() { } @@ -139,21 +139,21 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact AbstractGraphicsDevice absDevice = absScreen.getDevice(); if(null==absDevice) { throw new GLException("Null AbstractGraphicsDevice"); - } - + } + AbstractGraphicsConfiguration cfg = null; - + if( absDevice instanceof EGLGraphicsDevice ) { cfg = chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable) capsChosen, (GLCapabilitiesImmutable) capsRequested, (GLCapabilitiesChooser) chooser, - absScreen, nativeVisualID, false); + absScreen, nativeVisualID, false); } else { - // handle non native cases (X11, ..) + // handle non native cases (X11, ..) if(null == fallbackGraphicsConfigurationFactory) { throw new InternalError("Native fallback GraphicsConfigurationFactory is null, but call issued for device: "+absDevice+" of type "+absDevice.getClass().getSimpleName()); } - + if(glCapsChosen.getGLProfile().usesNativeGLES()) { if(DEBUG) { System.err.println("EGLGraphicsConfigurationFactory.choose..: Handle native device "+absDevice.getClass().getSimpleName()); @@ -175,7 +175,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact System.err.println("EGLGraphicsConfigurationFactory.choose..: Delegate to "+fallbackGraphicsConfigurationFactory.getClass().getSimpleName()); } cfg = fallbackGraphicsConfigurationFactory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, absScreen, nativeVisualID); - } + } } return cfg; } @@ -219,7 +219,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact public static EGLGraphicsConfiguration chooseGraphicsConfigurationStatic(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsReq, GLCapabilitiesChooser chooser, - AbstractGraphicsScreen absScreen, int nativeVisualID, + AbstractGraphicsScreen absScreen, int nativeVisualID, boolean forceTransparentFlag) { if (capsChosen == null) { capsChosen = new GLCapabilities(null); @@ -232,7 +232,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(null==absDevice) { throw new GLException("Null AbstractGraphicsDevice"); } - + final EGLGraphicsDevice eglDevice; final boolean ownEGLDisplay; if( absDevice instanceof EGLGraphicsDevice ) { @@ -253,7 +253,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(DEBUG) { System.err.println("eglChooseConfig failed with given capabilities "+capsChosen); } - + // Last try .. add a fixed embedded profile [ATI, Nokia, Intel, ..] // // rgb888 - d16, s4 @@ -268,7 +268,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact fixedCaps.setOnscreen(false); fixedCaps.setPBuffer(capsChosen.isPBuffer()); fixedCaps.setFBO(capsChosen.isFBO()); - } + } if(DEBUG) { System.err.println("trying fixed caps (1): "+fixedCaps); } @@ -286,7 +286,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact fixedCaps.setOnscreen(false); fixedCaps.setPBuffer(capsChosen.isPBuffer()); fixedCaps.setFBO(capsChosen.isFBO()); - } + } if(DEBUG) { System.err.println("trying fixed caps (2): "+fixedCaps); } @@ -306,7 +306,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact fixedCaps.setOnscreen(false); fixedCaps.setPBuffer(capsChosen.isPBuffer()); fixedCaps.setFBO(capsChosen.isFBO()); - } + } if(DEBUG) { System.err.println("trying fixed caps (3): "+fixedCaps); } @@ -322,8 +322,8 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact return res; } - - static EGLGraphicsConfiguration eglChooseConfig(EGLGraphicsDevice device, + + static EGLGraphicsConfiguration eglChooseConfig(EGLGraphicsDevice device, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, @@ -354,7 +354,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact final IntBuffer attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen); PointerBuffer configs = PointerBuffer.allocateDirect(numConfigs.get(0)); - // 1st choice: get GLCapabilities based on users GLCapabilities + // 1st choice: get GLCapabilities based on users GLCapabilities // setting recommendedIndex as preferred choice // skipped if nativeVisualID is given if( VisualIDHolder.VID_UNDEFINED != nativeVisualID || !EGL.eglChooseConfig(eglDisplay, attrs, configs, configs.capacity(), numConfigs) ) { @@ -387,7 +387,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: #2 Get all configs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError())); } if (numConfigs.get(0) > 0) { - availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag); + availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag); } } @@ -400,7 +400,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact } return null; } - + if(DEBUG) { System.err.println("EGLGraphicsConfiguration.eglChooseConfig: got configs: "+availableCaps.size()); for(int i=0; i this "+surface.getClass().getSimpleName()+" ): "; - System.err.println(dbgPrefix+this); + System.err.println(dbgPrefix+this); } else { dbgPrefix = null; } - + if(upstreamSurface instanceof ProxySurface) { - // propagate createNotify(..) so upstreamSurface will be created + // propagate createNotify(..) so upstreamSurface will be created ((ProxySurface)upstreamSurface).createNotify(); } - + // lock upstreamSurface, so it can be used in case EGLDisplay is derived from it! if(NativeSurface.LOCK_SURFACE_NOT_READY >= upstreamSurface.lockSurface()) { throw new GLException("Could not lock: "+upstreamSurface); @@ -73,16 +73,16 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { evalUpstreamSurface(dbgPrefix, surface); } finally { upstreamSurface.unlockSurface(); - } + } } - + private final void evalUpstreamSurface(String dbgPrefix, ProxySurface surface) { // // evaluate nature of upstreamSurface, may create EGL instances if required // - + boolean isEGLSurfaceValid = true; // assume yes - + final EGLGraphicsDevice eglDevice; final AbstractGraphicsConfiguration aConfig; { @@ -92,14 +92,14 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { System.err.println(dbgPrefix+"SurfaceDevice: "+surfaceDevice.getClass().getSimpleName()+", hash 0x"+Integer.toHexString(surfaceDevice.hashCode())+", "+surfaceDevice); System.err.println(dbgPrefix+"SurfaceConfig: "+surfaceConfig.getClass().getSimpleName()+", hash 0x"+Integer.toHexString(surfaceConfig.hashCode())+", "+surfaceConfig); } - - final AbstractGraphicsConfiguration upstreamConfig = upstreamSurface.getGraphicsConfiguration(); + + final AbstractGraphicsConfiguration upstreamConfig = upstreamSurface.getGraphicsConfiguration(); final AbstractGraphicsDevice upstreamDevice = upstreamConfig.getScreen().getDevice(); if(DEBUG) { System.err.println(dbgPrefix+"UpstreamDevice: "+upstreamDevice.getClass().getSimpleName()+", hash 0x"+Integer.toHexString(upstreamDevice.hashCode())+", "+upstreamDevice); System.err.println(dbgPrefix+"UpstreamConfig: "+upstreamConfig.getClass().getSimpleName()+", hash 0x"+Integer.toHexString(upstreamConfig.hashCode())+", "+upstreamConfig); } - + if( surfaceDevice instanceof EGLGraphicsDevice ) { eglDevice = (EGLGraphicsDevice) surfaceDevice; aConfig = surfaceConfig; @@ -129,13 +129,13 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); } } - + final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities(); final EGLGraphicsConfiguration eglConfig; if( aConfig instanceof EGLGraphicsConfiguration ) { // Config is already in EGL type - reuse .. final EGLGLCapabilities capsChosen = (EGLGLCapabilities) aConfig.getChosenCapabilities(); - if( !isEGLSurfaceValid || !EGLGraphicsConfiguration.isEGLConfigValid(eglDevice.getHandle(), capsChosen.getEGLConfig()) ) { + if( !isEGLSurfaceValid || !EGLGraphicsConfiguration.isEGLConfigValid(eglDevice.getHandle(), capsChosen.getEGLConfig()) ) { // 'refresh' the native EGLConfig handle capsChosen.setEGLConfig(EGLGraphicsConfiguration.EGLConfigId2EGLConfig(eglDevice.getHandle(), capsChosen.getEGLConfigID())); if( 0 == capsChosen.getEGLConfig() ) { @@ -166,7 +166,7 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { isEGLSurfaceValid = false; } surface.setGraphicsConfiguration(eglConfig); - + if(isEGLSurfaceValid) { isEGLSurfaceValid = EGLDrawable.isValidEGLSurface(eglDevice.getHandle(), upstreamSurface.getSurfaceHandle()); } @@ -182,15 +182,15 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { if(DEBUG) { System.err.println(dbgPrefix+"Fin: EGL surface n/a - TBD: "+upstreamSurface); } - } + } } @Override public final void destroy(ProxySurface surface) { if(EGLDrawableFactory.DEBUG) { - System.err.println("EGLUpstreamSurfaceHook.destroy("+surface.getClass().getSimpleName()+"): "+this); + System.err.println("EGLUpstreamSurfaceHook.destroy("+surface.getClass().getSimpleName()+"): "+this); } - surface.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + surface.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); if(upstreamSurface instanceof ProxySurface) { ((ProxySurface)upstreamSurface).destroyNotify(); } @@ -205,7 +205,7 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { public final int getHeight(ProxySurface s) { return upstreamSurface.getHeight(); } - + @Override public String toString() { final String us_s = null != upstreamSurface ? ( upstreamSurface.getClass().getName() + ": 0x" + Long.toHexString(upstreamSurface.getSurfaceHandle()) ) : "nil"; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java b/src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java index f816151c7..e6d43d957 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java @@ -19,16 +19,16 @@ public class EGLWrappedSurface extends WrappedSurface { } return new EGLWrappedSurface(surface); } - + public EGLWrappedSurface(NativeSurface surface) { super(surface.getGraphicsConfiguration(), EGL.EGL_NO_SURFACE, new EGLUpstreamSurfaceHook(surface), false /* tbd in UpstreamSurfaceHook */); if(EGLDrawableFactory.DEBUG) { - System.err.println("EGLWrappedSurface.ctor(): "+this); + System.err.println("EGLWrappedSurface.ctor(): "+this); } } @Override - public final NativeSurface getUpstreamSurface() { - return ((EGLUpstreamSurfaceHook)super.getUpstreamSurfaceHook()).getUpstreamSurface(); - } + public final NativeSurface getUpstreamSurface() { + return ((EGLUpstreamSurfaceHook)super.getUpstreamSurfaceHook()).getUpstreamSurface(); + } } diff --git a/src/jogl/classes/jogamp/opengl/gl2/ProjectDouble.java b/src/jogl/classes/jogamp/opengl/gl2/ProjectDouble.java index 9165dbc4b..a4aa1c7c5 100644 --- a/src/jogl/classes/jogamp/opengl/gl2/ProjectDouble.java +++ b/src/jogl/classes/jogamp/opengl/gl2/ProjectDouble.java @@ -6,9 +6,9 @@ ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** +** ** http://oss.sgi.com/projects/FreeB -** +** ** Note that, as provided in the License, the Software is distributed on an ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND @@ -24,13 +24,13 @@ ** except that Section 2.2 and 11 are omitted. Any differences between ** the Alternative License and the SGI License are offered solely by Sun ** and not by SGI. -** +** ** Original Code. The Original Code is: OpenGL Sample Implementation, ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. ** Copyright in any portions created by third parties is as indicated ** elsewhere herein. All Rights Reserved. -** +** ** Additional Notice Provisions: The application programming interfaces ** established by SGI in conjunction with the Original Code are The ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -45,56 +45,56 @@ ** $Header$ */ -/* +/* * Copyright (c) 2002-2004 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions 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 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * 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 @@ -107,7 +107,7 @@ * 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. @@ -125,7 +125,7 @@ import com.jogamp.common.nio.Buffers; *

          *

          * Created 11-jan-2004 - * + * * @author Erik Duijs * @author Kenneth Russell */ @@ -155,7 +155,7 @@ public class ProjectDouble { private final double[] forward = new double[3]; private final double[] side = new double[3]; private final double[] up = new double[3]; - + // Buffer-based implementation private DoubleBuffer locbuf; private final DoubleBuffer matrixBuf; @@ -227,7 +227,7 @@ public class ProjectDouble { /** * Method __gluMultMatrixVecd - * + * * @param matrix * @param in * @param out @@ -244,7 +244,7 @@ public class ProjectDouble { /** * Method __gluMultMatrixVecd - * + * * @param matrix * @param in * @param out @@ -265,7 +265,7 @@ public class ProjectDouble { /** * @param src * @param inverse - * + * * @return */ private boolean __gluInvertMatrixd(double[] src, double[] inverse) { @@ -335,7 +335,7 @@ public class ProjectDouble { /** * @param src * @param inverse - * + * * @return */ private boolean __gluInvertMatrixd(DoubleBuffer src, DoubleBuffer inverse) { @@ -525,7 +525,7 @@ public class ProjectDouble { /** * Method gluOrtho2D. - * + * * @param left * @param right * @param bottom @@ -537,7 +537,7 @@ public class ProjectDouble { /** * Method gluPerspective. - * + * * @param fovy * @param aspect * @param zNear @@ -570,7 +570,7 @@ public class ProjectDouble { /** * Method gluLookAt - * + * * @param eyex * @param eyey * @param eyez @@ -631,7 +631,7 @@ public class ProjectDouble { /** * Method gluProject - * + * * @param objx * @param objy * @param objz @@ -639,7 +639,7 @@ public class ProjectDouble { * @param projMatrix * @param viewport * @param win_pos - * + * * @return */ public boolean gluProject(double objx, @@ -685,7 +685,7 @@ public class ProjectDouble { /** * Method gluProject - * + * * @param objx * @param objy * @param objz @@ -693,7 +693,7 @@ public class ProjectDouble { * @param projMatrix * @param viewport * @param win_pos - * + * * @return */ public boolean gluProject(double objx, @@ -738,7 +738,7 @@ public class ProjectDouble { /** * Method gluUnproject - * + * * @param winx * @param winy * @param winz @@ -746,7 +746,7 @@ public class ProjectDouble { * @param projMatrix * @param viewport * @param obj_pos - * + * * @return */ public boolean gluUnProject(double winx, @@ -799,7 +799,7 @@ public class ProjectDouble { /** * Method gluUnproject - * + * * @param winx * @param winy * @param winz @@ -807,7 +807,7 @@ public class ProjectDouble { * @param projMatrix * @param viewport * @param obj_pos - * + * * @return */ public boolean gluUnProject(double winx, @@ -858,7 +858,7 @@ public class ProjectDouble { /** * Method gluUnproject4 - * + * * @param winx * @param winy * @param winz @@ -869,7 +869,7 @@ public class ProjectDouble { * @param near * @param far * @param obj_pos - * + * * @return */ public boolean gluUnProject4(double winx, @@ -923,7 +923,7 @@ public class ProjectDouble { /** * Method gluUnproject4 - * + * * @param winx * @param winy * @param winz @@ -934,7 +934,7 @@ public class ProjectDouble { * @param near * @param far * @param obj_pos - * + * * @return */ public boolean gluUnProject4(double winx, @@ -987,7 +987,7 @@ public class ProjectDouble { /** * Method gluPickMatrix - * + * * @param x * @param y * @param deltaX @@ -1014,7 +1014,7 @@ public class ProjectDouble { /** * Method gluPickMatrix - * + * * @param x * @param y * @param deltaX diff --git a/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java b/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java index 7cd7da53e..b4383c2e6 100644 --- a/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java +++ b/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java @@ -6,15 +6,15 @@ ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** +** ** http://oss.sgi.com/projects/FreeB -** +** ** Note that, as provided in the License, the Software is distributed on an ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** +** ** NOTE: The Original Code (as defined below) has been licensed to Sun ** Microsystems, Inc. ("Sun") under the SGI Free Software License B ** (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. ** Copyright in any portions created by third parties is as indicated ** elsewhere herein. All Rights Reserved. -** +** ** Additional Notice Provisions: The application programming interfaces ** established by SGI in conjunction with the Original Code are The ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -45,56 +45,56 @@ ** $Header$ */ -/* +/* * Copyright (c) 2002-2004 LWJGL Project * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions 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 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * 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 @@ -107,7 +107,7 @@ * 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. @@ -124,8 +124,8 @@ import com.jogamp.opengl.util.glsl.ShaderState; /** * GLUquadricImpl.java - * - * + * + * * Created 22-dec-2003 (originally Quadric.java) * @author Erik Duijs * @author Kenneth Russell, Sven Gothel @@ -197,19 +197,19 @@ public class GLUquadricImpl implements GLUquadric { ImmModeSink res = immModeSink; if(useGLSL) { if(null != shaderState) { - immModeSink = ImmModeSink.createGLSL (32, - 3, GL.GL_FLOAT, // vertex + immModeSink = ImmModeSink.createGLSL (32, + 3, GL.GL_FLOAT, // vertex 0, GL.GL_FLOAT, // color USE_NORM?3:0, normalType, // normal USE_TEXT?2:0, GL.GL_FLOAT, // texCoords GL.GL_STATIC_DRAW, shaderState); } else { - immModeSink = ImmModeSink.createGLSL (32, - 3, GL.GL_FLOAT, // vertex + immModeSink = ImmModeSink.createGLSL (32, + 3, GL.GL_FLOAT, // vertex 0, GL.GL_FLOAT, // color USE_NORM?3:0, normalType, // normal USE_TEXT?2:0, GL.GL_FLOAT, // texCoords - GL.GL_STATIC_DRAW, shaderProgram); + GL.GL_STATIC_DRAW, shaderProgram); } } else { immModeSink = ImmModeSink.createFixed(32, @@ -229,7 +229,7 @@ public class GLUquadricImpl implements GLUquadric { } /** - * specifies the draw style for quadrics. + * specifies the draw style for quadrics. * * The legal values are as follows: * @@ -243,7 +243,7 @@ public class GLUquadricImpl implements GLUquadric { * separating coplanar faces will not be drawn. * * GLU.POINT: Quadrics are rendered as a set of points. - * + * * @param drawStyle The drawStyle to set */ public void setDrawStyle(int drawStyle) { @@ -260,7 +260,7 @@ public class GLUquadricImpl implements GLUquadric { * * GLU.SMOOTH: One normal is generated for every vertex of a quadric. This * is the default. - * + * * @param normals The normals to set */ public void setNormals(int normals) { @@ -277,7 +277,7 @@ public class GLUquadricImpl implements GLUquadric { * * Note that the interpretation of outward and inward depends on the quadric * being drawn. - * + * * @param orientation The orientation to set */ public void setOrientation(int orientation) { @@ -292,7 +292,7 @@ public class GLUquadricImpl implements GLUquadric { * * The manner in which texture coordinates are generated depends upon the * specific quadric rendered. - * + * * @param textureFlag The textureFlag to set */ public void setTextureFlag(boolean textureFlag) { @@ -512,10 +512,10 @@ public class GLUquadricImpl implements GLUquadric { glNormal3f(gl, 0.0f, 0.0f, -1.0f); } } - + da = 2.0f * PI / slices; dr = (outerRadius - innerRadius) / loops; - + switch (drawStyle) { case GLU.GLU_FILL: { @@ -648,18 +648,18 @@ public class GLUquadricImpl implements GLUquadric { * through startAngle + sweepAngle is included (where 0 degrees is along * the +y axis, 90 degrees along the +x axis, 180 along the -y axis, and * 270 along the -x axis). - * + * * The partial disk has a radius of outerRadius, and contains a concentric * circular hole with a radius of innerRadius. If innerRadius is zero, then * no hole is generated. The partial disk is subdivided around the z axis * into slices (like pizza slices), and also about the z axis into rings * (as specified by slices and loops, respectively). - * + * * With respect to orientation, the +z side of the partial disk is * considered to be outside (see gluQuadricOrientation). This means that if * the orientation is set to GLU.GLU_OUTSIDE, then any normals generated point * along the +z axis. Otherwise, they point along the -z axis. - * + * * If texturing is turned on (with gluQuadricTexture), texture coordinates * are generated linearly such that where r=outerRadius, the value at (r, 0, 0) * is (1, 0.5), at (0, r, 0) it is (0.5, 1), at (-r, 0, 0) it is (0, 0.5), @@ -1204,7 +1204,7 @@ public class GLUquadricImpl implements GLUquadric { */ private void normal3f(GL gl, float x, float y, float z) { float mag; - + mag = (float)Math.sqrt(x * x + y * y + z * z); if (mag > 0.00001F) { x /= mag; diff --git a/src/jogl/classes/jogamp/opengl/glu/Glue.java b/src/jogl/classes/jogamp/opengl/glu/Glue.java index 636d17f29..2ad3d8c89 100644 --- a/src/jogl/classes/jogamp/opengl/glu/Glue.java +++ b/src/jogl/classes/jogamp/opengl/glu/Glue.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -89,15 +89,15 @@ public class Glue { "null control point reference", "duplicate point on piecewise linear trimming curve" } ; - + /** Creates a new instance of Glue */ public Glue() { } - + public static String __gluNURBSErrorString( int errno ) { return( __gluNurbsErrors[ errno ] ); } - + private static String[] __gluTessErrors = { " ", "gluTessBeginPolygon() must precede a gluTessEndPolygon", @@ -107,7 +107,7 @@ public class Glue { "a coordinate is too large", "need combine callback" }; - + public static String __gluTessErrorString( int errno ) { return( __gluTessErrors[ errno ] ); } diff --git a/src/jogl/classes/jogamp/opengl/glu/error/Error.java b/src/jogl/classes/jogamp/opengl/glu/error/Error.java index 2f49db9a4..ffb8d9471 100644 --- a/src/jogl/classes/jogamp/opengl/glu/error/Error.java +++ b/src/jogl/classes/jogamp/opengl/glu/error/Error.java @@ -6,9 +6,9 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND @@ -24,13 +24,13 @@ * except that Section 2.2 and 11 are omitted. Any differences between * the Alternative License and the SGI License are offered solely by Sun * and not by SGI. - * + * * Original Code. The Original Code is: OpenGL Sample Implementation, * Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -53,7 +53,7 @@ import jogamp.opengl.glu.Glue; * @author Administrator */ public class Error { - + private static String[] glErrorStrings = { "invalid enumerant", "invalid value", @@ -63,7 +63,7 @@ public class Error { "out of memory", "invalid framebuffer operation" }; - + private static String[] gluErrorStrings = { "invalid enumerant", "invalid value", @@ -71,11 +71,11 @@ public class Error { "", "invalid operation" }; - + /** Creates a new instance of Error */ public Error() { } - + public static String gluErrorString( int errorCode ) { if( errorCode == 0 ) { return( "no error" ); diff --git a/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GL2CurveEvaluator.java b/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GL2CurveEvaluator.java index 2ef4468e5..f57c2310f 100644 --- a/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GL2CurveEvaluator.java +++ b/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GL2CurveEvaluator.java @@ -48,7 +48,7 @@ import javax.media.opengl.glu.gl2.GLUgl2; class GL2CurveEvaluator implements CurveEvaluator { /** - * Output triangles (for callback) or render curve + * Output triangles (for callback) or render curve */ private boolean output_triangles; diff --git a/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GLUgl2nurbsImpl.java b/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GLUgl2nurbsImpl.java index 58b565484..f83b3a805 100644 --- a/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GLUgl2nurbsImpl.java +++ b/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GLUgl2nurbsImpl.java @@ -43,9 +43,9 @@ import javax.media.opengl.glu.GLUnurbs; /** * Base object for working with NURBS curves and surfaces - * + * * @author Tomas Hrasky - * + * */ public class GLUgl2nurbsImpl implements GLUnurbs { @@ -272,7 +272,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Sets domain distance for dom.dist. sampling in u direction - * + * * @param d * distance */ @@ -283,7 +283,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Sets domain distance for dom.dist. sampling in v direction - * + * * @param d * distance */ @@ -303,7 +303,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Calls a method with given name and passes argumet - * + * * @param name * name of a method to be called * @param arg @@ -329,7 +329,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Calls a method with given name - * + * * @param name * name of a method to be called */ @@ -349,7 +349,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Begins a NURBS curve - * + * * @param o_curve * curve object */ @@ -381,7 +381,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Begins new surface - * + * * @param o_surface * surface object */ @@ -503,7 +503,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Method for handling error codes - * + * * @param i * error code */ @@ -539,7 +539,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Make a NURBS curve - * + * * @param nknots * number of knots in knot vector * @param knot @@ -587,7 +587,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Check knot vector specification - * + * * @param knots * knot vector * @param msg @@ -607,7 +607,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Draw a curve - * + * * @param o_nurbscurve * NURBS curve object */ @@ -660,7 +660,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Draw NURBS surface - * + * * @param o_nurbssurface * NURBS surface object */ @@ -704,7 +704,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Define a map of given properties - * + * * @param type * map type * @param rational @@ -719,7 +719,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Set NURBS property - * + * * @param type * property type * @param tag @@ -744,7 +744,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Set parameters of existing property - * + * * @param prop * property */ @@ -755,7 +755,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Set given property to rendering hints - * + * * @param prop * property to be set */ @@ -767,7 +767,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Sets wheteher we use domain distance sampling - * + * * @param i * domain distance sampling flag */ @@ -805,7 +805,7 @@ public class GLUgl2nurbsImpl implements GLUnurbs { /** * Make NURBS surface - * + * * @param sknot_count * number of knots in s direction * @param sknot diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/BuildMipmap.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/BuildMipmap.java index f5fe17a7b..81a99beab 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/BuildMipmap.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/BuildMipmap.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -64,7 +64,7 @@ public class BuildMipmap { /** Creates a new instance of BuildMipmap */ public BuildMipmap() { } - + public static int gluBuild1DMipmapLevelsCore( GL gl, int target, int internalFormat, int width, int widthPowerOf2, int format, int type, int userLevel, int baseLevel, int maxLevel, ByteBuffer data ) { @@ -78,34 +78,34 @@ public class BuildMipmap { int maxsize; int cmpts; PixelStorageModes psm = new PixelStorageModes(); - + assert( Mipmap.checkMipmapArgs( internalFormat, format, type ) == 0 ); assert( width >= 1 ); - + newwidth = widthPowerOf2; levels = Mipmap.computeLog( newwidth ); - + levels += userLevel; - + Mipmap.retrieveStoreModes( gl, psm ); try { - newImage = Buffers.newDirectByteBuffer( Mipmap.image_size( width, 1, format, + newImage = Buffers.newDirectByteBuffer( Mipmap.image_size( width, 1, format, GL2.GL_UNSIGNED_SHORT ) ).asShortBuffer(); } catch( OutOfMemoryError ome ) { return( GLU.GLU_OUT_OF_MEMORY ); } newImage_width = width; - + Image.fill_image( psm, width, 1, format, type, Mipmap.is_index( format ), data, newImage ); cmpts = Mipmap.elements_per_group( format, type ); gl.glPixelStorei( GL2.GL_UNPACK_ALIGNMENT, 2 ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_PIXELS, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_ROW_LENGTH, 0 ); - + // if swap_bytes was set, swapping occurred in fill_image gl.glPixelStorei( GL2.GL_UNPACK_SWAP_BYTES, GL2.GL_FALSE ); - + for( level = userLevel; level <= levels; level++ ) { if( newImage_width == newwidth ) { // user newimage for this level @@ -132,10 +132,10 @@ public class BuildMipmap { imageTemp = otherImage; otherImage = newImage; newImage = imageTemp; - + newImage_width = newwidth; if( baseLevel <= level && level <= maxLevel ) { - gl.getGL2().glTexImage1D( target, level, internalFormat, newImage_width, 0, + gl.getGL2().glTexImage1D( target, level, internalFormat, newImage_width, 0, format, GL2.GL_UNSIGNED_SHORT, newImage ); } } @@ -148,10 +148,10 @@ public class BuildMipmap { gl.glPixelStorei( GL2.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() ); gl.glPixelStorei( GL2.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() ); gl.glPixelStorei( GL2.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) ); - + return( 0 ); } - + public static int bitmapBuild2DMipmaps( GL gl, int target, int internalFormat, int width, int height, int format, int type, ByteBuffer data ) { int newwidth[] = new int[1]; @@ -166,37 +166,37 @@ public class BuildMipmap { int maxsize; int cmpts; PixelStorageModes psm = new PixelStorageModes(); - + Mipmap.retrieveStoreModes( gl, psm ); - + Mipmap.closestFit( gl, target, width, height, internalFormat, format, type, newwidth, newheight ); - + levels = Mipmap.computeLog( newwidth[0] ); level = Mipmap.computeLog( newheight[0] ); if( level > levels ) { levels = level; } - + try { - newImage = Buffers.newDirectByteBuffer( Mipmap.image_size( width, height, + newImage = Buffers.newDirectByteBuffer( Mipmap.image_size( width, height, format, GL2.GL_UNSIGNED_SHORT ) ).asShortBuffer(); } catch( OutOfMemoryError ome ) { return( GLU.GLU_OUT_OF_MEMORY ); } newImage_width = width; newImage_height = height; - + Image.fill_image( psm, width, height, format, type, Mipmap.is_index( format ), data, newImage ); - + cmpts = Mipmap.elements_per_group( format, type ); gl.glPixelStorei( GL2.GL_UNPACK_ALIGNMENT, 2 ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_PIXELS, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_ROW_LENGTH, 0 ); - + // if swap_bytes is set, swapping occurred in fill_image gl.glPixelStorei( GL2.GL_UNPACK_SWAP_BYTES, GL2.GL_FALSE ); - + for( level = 0; level < levels; level++ ) { if( newImage_width == newwidth[0] && newImage_height == newheight[0] ) { newImage.rewind(); @@ -216,13 +216,13 @@ public class BuildMipmap { return( GLU.GLU_OUT_OF_MEMORY ); } } - ScaleInternal.scale_internal( cmpts, newImage_width, newImage_height, + ScaleInternal.scale_internal( cmpts, newImage_width, newImage_height, newImage, newwidth[0], newheight[0], otherImage ); // swap newImage and otherImage tempImage = otherImage; otherImage = newImage; newImage = tempImage; - + newImage_width = newwidth[0]; newImage_height = newheight[0]; newImage.rewind(); @@ -241,10 +241,10 @@ public class BuildMipmap { gl.glPixelStorei( GL2.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() ); gl.glPixelStorei( GL2.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() ); gl.glPixelStorei( GL2.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) ); - + return( 0 ); } - + public static int gluBuild2DMipmapLevelsCore( GL gl, int target, int internalFormat, int width, int height, int widthPowerOf2, int heightPowerOf2, int format, int type, int userLevel, int baseLevel, int maxLevel, @@ -263,19 +263,19 @@ public class BuildMipmap { int maxsize; int cmpts; int mark=-1; - + boolean myswap_bytes; int groups_per_line, element_size, group_size; int rowsize, padding; PixelStorageModes psm = new PixelStorageModes(); - + assert( Mipmap.checkMipmapArgs( internalFormat, format, type ) == 0 ); assert( width >= 1 && height >= 1 ); - + if( type == GL2.GL_BITMAP ) { return( bitmapBuild2DMipmaps( gl, target, internalFormat, width, height, format, type, data ) ); } - + newwidth = widthPowerOf2; newheight = heightPowerOf2; levels = Mipmap.computeLog( newwidth ); @@ -283,9 +283,9 @@ public class BuildMipmap { if( level > levels ) { levels = level; } - + levels += userLevel; - + Mipmap.retrieveStoreModes( gl, psm ); myswap_bytes = psm.getUnpackSwapBytes(); cmpts = Mipmap.elements_per_group( format, type ); @@ -294,28 +294,28 @@ public class BuildMipmap { } else { groups_per_line = width; } - + element_size = Mipmap.bytes_per_element( type ); group_size = element_size * cmpts; if( element_size == 1 ) { myswap_bytes = false; } - + rowsize = groups_per_line * group_size; padding = ( rowsize % psm.getUnpackAlignment() ); if( padding != 0 ) { rowsize += psm.getUnpackAlignment() - padding; } - + mark = psm.getUnpackSkipRows() * rowsize + psm.getUnpackSkipPixels() * group_size; data.position( mark ); - + gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_PIXELS, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_ROW_LENGTH, 0 ); - + level = userLevel; - + // already power of two square if( width == newwidth && height == newheight ) { // use usersImage for level userLevel @@ -333,7 +333,7 @@ public class BuildMipmap { } int nextWidth = newwidth / 2; int nextHeight = newheight / 2; - + // clamp to 1 if( nextWidth < 1 ) { nextWidth = 1; @@ -342,7 +342,7 @@ public class BuildMipmap { nextHeight = 1; } memReq = Mipmap.image_size( nextWidth, nextHeight, format, type ); - + try { switch( type ) { case( GL2.GL_UNSIGNED_BYTE ): @@ -452,7 +452,7 @@ public class BuildMipmap { if( newheight < 1 ) { newheight = 1; } - + myswap_bytes = false; rowsize = newwidth * group_size; memReq = Mipmap.image_size( newwidth, newheight, format, type ); @@ -498,7 +498,7 @@ public class BuildMipmap { level = userLevel + 1; } else { // user's image is not nice powerof2 size square memReq = Mipmap.image_size( newwidth, newheight, format, type ); - try { + try { switch( type ) { case( GL2.GL_UNSIGNED_BYTE ): case( GL2.GL_BYTE ): @@ -535,15 +535,15 @@ public class BuildMipmap { data.position( mark ); switch( type ) { case( GL2.GL_UNSIGNED_BYTE ): - ScaleInternal.scale_internal_ubyte( cmpts, width, height, data, + ScaleInternal.scale_internal_ubyte( cmpts, width, height, data, newwidth, newheight, dstImage, element_size, rowsize, group_size ); break; case( GL2.GL_BYTE ): - ScaleInternal.scale_internal_byte( cmpts, width, height, data, newwidth, + ScaleInternal.scale_internal_byte( cmpts, width, height, data, newwidth, newheight, dstImage, element_size, rowsize, group_size ); break; case( GL2.GL_UNSIGNED_SHORT ): - ScaleInternal.scale_internal_ushort( cmpts, width, height, data, newwidth, + ScaleInternal.scale_internal_ushort( cmpts, width, height, data, newwidth, newheight, dstImage.asShortBuffer(), element_size, rowsize, group_size, myswap_bytes ); break; case( GL2.GL_SHORT ): @@ -620,7 +620,7 @@ public class BuildMipmap { tempImage = srcImage; srcImage = dstImage; dstImage = tempImage; - + if( levels != 0 ) { // use as little memory as possible int nextWidth = newwidth / 2; int nextHeight = newheight / 2; @@ -630,7 +630,7 @@ public class BuildMipmap { if( nextHeight < 1 ) { nextHeight = 1; } - + memReq = Mipmap.image_size( nextWidth, nextHeight, format, type ); try { switch( type ) { @@ -670,7 +670,7 @@ public class BuildMipmap { // level userLevel is in srcImage; nothing saved yet level = userLevel; } - + gl.glPixelStorei( GL2.GL_UNPACK_SWAP_BYTES, GL2.GL_FALSE ); if( baseLevel <= level && level <= maxLevel ) { srcImage.rewind(); @@ -685,7 +685,7 @@ public class BuildMipmap { } } } - + level++; // update current level for the loop for( ; level <= levels; level++ ) { srcImage.rewind(); @@ -754,12 +754,12 @@ public class BuildMipmap { assert( false ); break; } - + // swap dstImage and srcImage tempImage = srcImage; srcImage = dstImage; dstImage = tempImage; - + if( newwidth > 1 ) { newwidth /= 2; rowsize /= 2; @@ -769,7 +769,7 @@ public class BuildMipmap { } // compute amount to pad per row if any int rowPad = rowsize % psm.getUnpackAlignment(); - + // should row be padded if( rowPad == 0 ) { // call teximage with srcImage untouched since its not padded @@ -792,7 +792,7 @@ public class BuildMipmap { int ii, jj; int dstTrav; int srcTrav; - + // allocate new image for mipmap of size newRowLength x newheight ByteBuffer newMipmapImage = null; try { @@ -813,7 +813,7 @@ public class BuildMipmap { newMipmapImage.put( srcImage.get() ); } } - + // and use this new image for mipmapping instead if( baseLevel <= level && level <= maxLevel ) { newMipmapImage.rewind(); @@ -833,10 +833,10 @@ public class BuildMipmap { gl.glPixelStorei( GL2.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() ); gl.glPixelStorei( GL2.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() ); gl.glPixelStorei( GL2.GL_UNPACK_SWAP_BYTES, (psm.getUnpackSwapBytes() ? 1 : 0) ); - + return( 0 ); } - + public static int fastBuild2DMipmaps( GL gl, PixelStorageModes psm, int target, int components, int width, int height, int format, int type, ByteBuffer data ) { int[] newwidth = new int[1]; @@ -850,22 +850,22 @@ public class BuildMipmap { int memReq; int maxsize; int cmpts; - - Mipmap.closestFit( gl, target, width, height, components, format, type, newwidth, + + Mipmap.closestFit( gl, target, width, height, components, format, type, newwidth, newheight ); - + levels = Mipmap.computeLog( newwidth[0] ); level = Mipmap.computeLog( newheight[0] ); if( level > levels ) { levels = level; } - + cmpts = Mipmap.elements_per_group( format, type ); - + otherImage = null; // No need to copy the user data if its packed correctly. // Make sure that later routines don't change that data. - + if( psm.getUnpackSkipRows() == 0 && psm.getUnpackSkipPixels() == 0 ) { newImage = data; newImage_width = width; @@ -878,7 +878,7 @@ public class BuildMipmap { int iter; int iter2; int i, j; - + try { newImage = Buffers.newDirectByteBuffer( Mipmap.image_size(width, height, format, GL2.GL_UNSIGNED_BYTE ) ); } catch( OutOfMemoryError err ) { @@ -896,7 +896,7 @@ public class BuildMipmap { rowsize = group_per_line * cmpts; elements_per_line = width * cmpts; start = psm.getUnpackSkipRows() * rowsize + psm.getUnpackSkipPixels() * cmpts; - + for( i = 0; i < height; i++ ) { iter = start; data.position( iter ); @@ -906,13 +906,13 @@ public class BuildMipmap { start += rowsize; } } - + gl.glPixelStorei( GL2.GL_UNPACK_ALIGNMENT, 1 ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_PIXELS, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_ROW_LENGTH, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_SWAP_BYTES, GL2.GL_FALSE ); - + for( level = 0; level <= levels; level++ ) { if( newImage_width == newwidth[0] && newImage_height == newheight[0] ) { // use newImage for this level @@ -937,7 +937,7 @@ public class BuildMipmap { imageTemp = otherImage; otherImage = newImage; newImage = imageTemp; - + newImage_width = newwidth[0]; newImage_height = newheight[0]; newImage.rewind(); @@ -956,10 +956,10 @@ public class BuildMipmap { gl.glPixelStorei( GL2.GL_UNPACK_SKIP_PIXELS, psm.getUnpackSkipPixels() ); gl.glPixelStorei( GL2.GL_UNPACK_ROW_LENGTH, psm.getUnpackRowLength() ); gl.glPixelStorei( GL2.GL_UNPACK_SWAP_BYTES, ( psm.getUnpackSwapBytes() ? 1 : 0 ) ) ; - + return( 0 ); } - + public static int gluBuild3DMipmapLevelsCore( GL gl, int target, int internalFormat, int width, int height, int depth, int widthPowerOf2, int heightPowerOf2, int depthPowerOf2, int format, int type, int userLevel, int baseLevel, @@ -977,19 +977,19 @@ public class BuildMipmap { int maxSize; int cmpts; int mark=-1; - + boolean myswapBytes; int groupsPerLine, elementSize, groupSize; int rowsPerImage, imageSize; int rowSize, padding; PixelStorageModes psm = new PixelStorageModes(); - + assert( Mipmap.checkMipmapArgs( internalFormat, format, type ) == 0 ); assert( width >= 1 && height >= 1 && depth >= 1 ); assert( type != GL2.GL_BITMAP ); - + srcImage = dstImage = null; - + newWidth = widthPowerOf2; newHeight = heightPowerOf2; newDepth = depthPowerOf2; @@ -1002,9 +1002,9 @@ public class BuildMipmap { if( level > levels ) { levels = level; } - + levels += userLevel; - + Mipmap.retrieveStoreModes3D( gl, psm ); myswapBytes = psm.getUnpackSwapBytes(); cmpts = Mipmap.elements_per_group( format, type ); @@ -1013,42 +1013,42 @@ public class BuildMipmap { } else { groupsPerLine = width; } - + elementSize = Mipmap.bytes_per_element( type ); groupSize = elementSize * cmpts; if( elementSize == 1 ) { myswapBytes = false; } - + // 3dstuff if( psm.getUnpackImageHeight() > 0 ) { rowsPerImage = psm.getUnpackImageHeight(); } else { rowsPerImage = height; } - + rowSize = groupsPerLine * groupSize; padding = ( rowSize % psm.getUnpackAlignment() ); if( padding != 0 ) { rowSize += psm.getUnpackAlignment() - padding; } - + imageSize = rowsPerImage * rowSize; - + usersImage = ByteBuffer.wrap(data.array()); mark = psm.getUnpackSkipRows() * rowSize + psm.getUnpackSkipPixels() * groupSize + psm.getUnpackSkipImages() * imageSize; usersImage.position( mark ); - + gl.glPixelStorei( GL2.GL_UNPACK_SKIP_ROWS, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_PIXELS, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_ROW_LENGTH, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_SKIP_IMAGES, 0 ); gl.glPixelStorei( GL2.GL_UNPACK_IMAGE_HEIGHT, 0 ); - + level = userLevel; - + if( width == newWidth && height == newHeight && depth == newDepth ) { // use usersImage for level userlevel if( baseLevel <= level && level <= maxLevel ) { @@ -1068,7 +1068,7 @@ public class BuildMipmap { int nextWidth = newWidth / 2; int nextHeight = newHeight / 2; int nextDepth = newDepth / 2; - + // clamp to one if( nextWidth < 1 ) { nextWidth = 1; @@ -1116,13 +1116,13 @@ public class BuildMipmap { gl.glPixelStorei( GL2.GL_UNPACK_IMAGE_HEIGHT, psm.getUnpackImageHeight() ); return( GLU.GLU_OUT_OF_MEMORY ); } - + if( dstImage != null ) { switch( type ) { case( GL2.GL_UNSIGNED_BYTE ): if( depth > 1 ) { HalveImage.halveImage3D( cmpts, new ExtractUByte(), width, height, depth, - usersImage, dstImage, elementSize, + usersImage, dstImage, elementSize, groupSize, rowSize, imageSize, myswapBytes ); } else { HalveImage.halveImage_ubyte( cmpts, width, height, usersImage, @@ -1145,7 +1145,7 @@ public class BuildMipmap { usersImage, dstImage, elementSize, groupSize, rowSize, imageSize, myswapBytes ); } else { - HalveImage.halveImage_ushort( cmpts, width, height, usersImage, + HalveImage.halveImage_ushort( cmpts, width, height, usersImage, dstImage.asShortBuffer(), elementSize, rowSize, groupSize, myswapBytes ); } break; @@ -1257,7 +1257,7 @@ public class BuildMipmap { if( newDepth < 1 ) { newDepth = 1; } - + myswapBytes = false; rowSize = newWidth * groupSize; imageSize = rowSize * newHeight; @@ -1302,7 +1302,7 @@ public class BuildMipmap { gl.glPixelStorei( GL2.GL_UNPACK_IMAGE_HEIGHT, psm.getUnpackImageHeight() ); return( GLU.GLU_OUT_OF_MEMORY ); } - + // level userLevel + 1 is in srcImage; level userLevel already saved level = userLevel + 1; } else { @@ -1343,10 +1343,10 @@ public class BuildMipmap { gl.glPixelStorei( GL2.GL_UNPACK_IMAGE_HEIGHT, psm.getUnpackImageHeight() ); return( GLU.GLU_OUT_OF_MEMORY ); } - + ScaleInternal.gluScaleImage3D( gl, format, width, height, depth, type, usersImage, newWidth, newHeight, newDepth, type, dstImage ); - + myswapBytes = false; rowSize = newWidth * groupSize; imageSize = rowSize * newHeight; @@ -1354,7 +1354,7 @@ public class BuildMipmap { tempImage = srcImage; srcImage = dstImage; dstImage = tempImage; - + if( levels != 0 ) { int nextWidth = newWidth / 2; int nextHeight = newHeight / 2; @@ -1409,7 +1409,7 @@ public class BuildMipmap { // level userLevel is in srcImage; nothing saved yet level = userLevel; } - + gl.glPixelStorei( GL2.GL_UNPACK_SWAP_BYTES, GL2.GL_FALSE ); if( baseLevel <= level && level <= maxLevel ) { usersImage.position( mark ); @@ -1541,11 +1541,11 @@ public class BuildMipmap { assert( false ); break; } - + tempImage = srcImage; srcImage = dstImage; dstImage = tempImage; - + if( newWidth > 1 ) { newWidth /= 2; rowSize /= 2; diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract.java index a564269fb..0eee9bf32 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1010102.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1010102.java index 10ea1d729..5269024b4 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1010102.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1010102.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,42 +51,42 @@ import java.nio.ByteBuffer; * @author Administrator */ public class Extract1010102 implements Extract { - + /** Creates a new instance of Extract1010102 */ public Extract1010102() { } - + public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { long uint = 0; - + if( isSwap ) { uint = 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( packedPixel.getInt() ); } else { uint = 0x00000000FFFFFFFF & packedPixel.getInt(); } - + // 11111111,11000000,00000000,00000000 == 0xFFC00000 // 00000000,00111111,11110000,00000000 == 0x003F0000 // 00000000,00000000,00001111,11111100 == 0x00000FFC // 00000000,00000000,00000000,00000011 == 0x00000003 - + extractComponents[0] = (float)( ( uint & 0xFFC00000 ) >> 22 ) / 1023.0f; extractComponents[1] = (float)( ( uint & 0x003FF000 ) >> 12 ) / 1023.0f; extractComponents[2] = (float)( ( uint & 0x00000FFC ) >> 2 ) / 1023.0f; extractComponents[3] = (float)( ( uint & 0x00000003 ) ) / 3.0f; } - + public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 // 00000000,11110000 == 0x00F0 // 00000000,00001111 == 0x000F - + assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f ); assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f ); assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f ); assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f ); - + // due to limited precision, need to round before shoving long uint = (((int)((shoveComponents[0] * 1023) + 0.5f) << 22) & 0xFFC00000 ); uint |= (((int)((shoveComponents[1] * 1023) + 0.5f) << 12) & 0x003FF000 ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1555rev.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1555rev.java index 1234da5f8..6982931d3 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1555rev.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1555rev.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,42 +51,42 @@ import java.nio.ByteBuffer; * @author Administrator */ public class Extract1555rev implements Extract { - + /** Creates a new instance of Extract1555rev */ public Extract1555rev() { } - + public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { int ushort = 0; - + if( isSwap ) { ushort = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( packedPixel.getShort() ); } else { ushort = 0x0000FFFF & packedPixel.getShort(); } - + // 00000000,00011111 == 0x001F // 00000011,11100000 == 0x03E0 // 01111100,00000000 == 0x7C00 // 10000000,00000000 == 0x8000 - + extractComponents[0] = (float)( ( ushort & 0x001F ) ) / 31.0f; extractComponents[1] = (float)( ( ushort & 0x003E ) >> 5 ) / 31.0f; extractComponents[2] = (float)( ( ushort & 0x7C00 ) >> 10) / 31.0f; extractComponents[3] = (float)( ( ushort & 0x8000 ) >> 15); } - + public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 00000000,00011111 == 0x001F // 00000011,11100000 == 0x03E0 // 01111100,00000000 == 0x7C00 // 10000000,00000000 == 0x8000 - + assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f ); assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f ); assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f ); assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f ); - + // due to limited precision, need to round before shoving int ushort = (((int)((shoveComponents[0] * 31) + 0.5f) ) & 0x0000001F ); ushort |= (((int)((shoveComponents[1] * 31) + 0.5f) << 5) & 0x000003E0 ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract2101010rev.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract2101010rev.java index 226254f99..1c7db6218 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract2101010rev.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract2101010rev.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,42 +51,42 @@ import java.nio.ByteBuffer; * @author Administrator */ public class Extract2101010rev implements Extract { - + /** Creates a new instance of Extract2101010 */ public Extract2101010rev() { } - + public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { long uint = 0; - + if( isSwap ) { uint = 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( packedPixel.getInt() ); } else { uint = 0x00000000FFFFFFFF & packedPixel.getInt(); } - + // 11111111,11000000,00000000,00000000 == 0xFFC00000 // 00000000,00111111,11110000,00000000 == 0x003F0000 // 00000000,00000000,00001111,11111100 == 0x00000FFC // 00000000,00000000,00000000,00000011 == 0x00000003 - + extractComponents[0] = (float)( ( uint & 0x000003FF ) ) / 1023.0f; extractComponents[1] = (float)( ( uint & 0x000FFC00 ) >> 10 ) / 1023.0f; extractComponents[2] = (float)( ( uint & 0x3FF00000 ) >> 20 ) / 1023.0f; extractComponents[3] = (float)( ( uint & 0xC0000000 ) >> 30 ) / 3.0f; } - + public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 // 00000000,11110000 == 0x00F0 // 00000000,00001111 == 0x000F - + assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f ); assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f ); assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f ); assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f ); - + // due to limited precision, need to round before shoving long uint = (((int)((shoveComponents[0] * 1023) + 0.5f) ) & 0x000003FF ); uint |= (((int)((shoveComponents[1] * 1023) + 0.5f) << 10) & 0x000FFC00 ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract233rev.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract233rev.java index 9fa2a3a54..672c86c32 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract233rev.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract233rev.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,11 +51,11 @@ import java.nio.ByteBuffer; * @author Administrator */ public class Extract233rev implements Extract { - + /** Creates a new instance of Extract223rev */ public Extract233rev() { } - + public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { // 11100000 == 0xe0 // 00011100 == 0x1c @@ -65,16 +65,16 @@ public class Extract233rev implements Extract { extractComponents[1] = (float)((ubyte & 0x38) >> 3) / 7.0f; extractComponents[2] = (float)((ubyte & 0xC0) >> 6) / 3.0f; } - + public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11100000 == 0xE0 // 00011100 == 0x1C // 00000011 == 0x03 - + assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f ); assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f ); assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f ); - + // due to limited precision, need to round before shoving byte b = (byte)( ( (int)( ( shoveComponents[0] * 7 ) + 0.5f ) ) & 0x07 ); b |= (byte)( ( (int)( ( shoveComponents[1] * 7 ) + 0.5f ) << 3 ) & 0x38 ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract332.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract332.java index 92d141be5..6cdbc5cb0 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract332.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract332.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,11 +51,11 @@ import java.nio.ByteBuffer; * @author Administrator */ public class Extract332 implements Extract { - + /** Creates a new instance of Extract332 */ public Extract332() { } - + public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { // 11100000 == 0xe0 // 00011100 == 0x1c @@ -65,16 +65,16 @@ public class Extract332 implements Extract { extractComponents[1] = (float)((ubyte & 0x1c) >> 2) / 7.0f; extractComponents[2] = (float)((ubyte & 0x03)) / 3.0f; } - + public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11100000 == 0xE0 // 00011100 == 0x1C // 00000011 == 0x03 - + assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f ); assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f ); assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f ); - + // due to limited precision, need to round before shoving byte b = (byte)( ( (int)( ( shoveComponents[0] * 7 ) + 0.5f ) << 5 ) & 0xE0 ); b |= (byte)( ( (int)( ( shoveComponents[1] * 7 ) + 0.5f ) << 2 ) & 0x1C ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444.java index af99d154c..b36b9fb82 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,41 +51,41 @@ import java.nio.*; * @author Administrator */ public class Extract4444 implements Extract { - + /** Creates a new instance of Extract4444 */ public Extract4444() { } - + public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { int ushort = 0; - + if( isSwap ) { ushort = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( packedPixel.getShort() ); } else { ushort = 0x0000FFFF & packedPixel.getShort(); } - + // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 // 00000000,11110000 == 0x00F0 // 00000000,00001111 == 0x000F - + extractComponents[0] = (float)( ( ushort & 0xF000 ) >> 12 ) / 15.0f; extractComponents[1] = (float)( ( ushort & 0x0F00 ) >> 8 ) / 15.0f; extractComponents[2] = (float)( ( ushort & 0x00F0 ) >> 4 ) / 15.0f; extractComponents[3] = (float)( ( ushort & 0x000F ) ) / 15.0f; } - + public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 // 00000000,11110000 == 0x00F0 // 00000000,00001111 == 0x000F - + assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f ); assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f ); assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f ); - + // due to limited precision, need to round before shoving int ushort = (((int)((shoveComponents[0] * 15) + 0.5f) << 12) & 0x0000F000 ); ushort |= (((int)((shoveComponents[1] * 15) + 0.5f) << 8) & 0x00000F00 ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444rev.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444rev.java index e5bce60d8..b7a3ed55f 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444rev.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444rev.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,42 +51,42 @@ import java.nio.*; * @author Administrator */ public class Extract4444rev implements Extract { - + /** Creates a new instance of Extract4444rev */ public Extract4444rev() { } - + public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { int ushort = 0; - + if( isSwap ) { ushort = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( packedPixel.getShort() ); } else { ushort = 0x0000FFFF & packedPixel.getShort(); } - + // 00000000,00001111 == 0x000F // 00000000,11110000 == 0x00F0 // 00001111,00000000 == 0x0F00 // 11110000,00000000 == 0xF000 - + extractComponents[0] = (float)( ( ushort & 0x000F ) ) / 15.0f; extractComponents[1] = (float)( ( ushort & 0x00F0 ) >> 4 ) / 15.0f; extractComponents[2] = (float)( ( ushort & 0x0F00 ) >> 8 ) / 15.0f; extractComponents[3] = (float)( ( ushort & 0xF000 ) >> 12 ) / 15.0f; } - + public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 // 00000000,11110000 == 0x00F0 // 00000000,00001111 == 0x000F - + assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f ); assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f ); assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f ); assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f ); - + // due to limited precision, need to round before shoving int ushort = (((int)((shoveComponents[0] * 15) + 0.5f) ) & 0x0000000F ); ushort |= (((int)((shoveComponents[1] * 15) + 0.5f) << 4) & 0x000000F0 ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract5551.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract5551.java index 5c383103e..4dc566b25 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract5551.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract5551.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,42 +51,42 @@ import java.nio.*; * @author Administrator */ public class Extract5551 implements Extract { - + /** Creates a new instance of Extract5551 */ public Extract5551() { } - + public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { int ushort = 0; - + if( isSwap ) { ushort = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( packedPixel.getShort() ); } else { ushort = 0x0000FFFF & packedPixel.getShort(); } - + // 11111000,00000000 == 0xF800 // 00000111,11000000 == 0x07C0 // 00000000,00111110 == 0x003E // 00000000,00000001 == 0x0001 - + extractComponents[0] = (float)( ( ushort & 0xF800 ) >> 11 ) / 31.0f; extractComponents[1] = (float)( ( ushort & 0x00F0 ) >> 6 ) / 31.0f; extractComponents[2] = (float)( ( ushort & 0x0F00 ) >> 1 ) / 31.0f; extractComponents[3] = (float)( ( ushort & 0xF000 ) ); } - + public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 // 00000000,11110000 == 0x00F0 // 00000000,00001111 == 0x000F - + assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f ); assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f ); assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f ); assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f ); - + // due to limited precision, need to round before shoving int ushort = (((int)((shoveComponents[0] * 31) + 0.5f) << 11) & 0x0000F800 ); ushort |= (((int)((shoveComponents[1] * 31) + 0.5f) << 6) & 0x000007C0 ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565.java index f6193dd2d..e198e46d4 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,38 +51,38 @@ import java.nio.*; * @author Administrator */ public class Extract565 implements Extract { - + /** Creates a new instance of Extract565 */ public Extract565() { } - + public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { int ushort = 0; - + if( isSwap ) { ushort = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( packedPixel.getShort() ); } else { ushort = 0x0000FFFF & packedPixel.getShort(); } - + // 11111000,00000000 == 0xF800 // 00000111,11100000 == 0x07E0 // 00000000,00111111 == 0x001F - + extractComponents[0] = (float)( ( ushort & 0xF800 ) >> 11 ) / 31.0f; extractComponents[1] = (float)( ( ushort & 0x07E0 ) >> 5 ) / 63.0f; extractComponents[2] = (float)( ( ushort & 0x001F ) ) / 31.0f; } - + public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11111000,00000000 == 0xF800 // 00000111,11100000 == 0x07E0 // 00000000,00111111 == 0x001F - + assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f ); assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f ); assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f ); - + // due to limited precision, need to round before shoving int ushort = (((int)((shoveComponents[0] * 31) + 0.5f) << 11) & 0x0000F800 ); ushort |= (((int)((shoveComponents[1] * 63) + 0.5f) << 5) & 0x000007E0 ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565rev.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565rev.java index 2e455adfa..fe19540ee 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565rev.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565rev.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,38 +51,38 @@ import java.nio.*; * @author Administrator */ public class Extract565rev implements Extract { - + /** Creates a new instance of Extract565rev */ public Extract565rev() { } - + public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { int ushort = 0; - + if( isSwap ) { ushort = 0x0000FFFF & Mipmap.GLU_SWAP_2_BYTES( packedPixel.getShort() ); } else { ushort = 0x0000FFFF & packedPixel.getShort(); } - + // 00000000,00011111 == 0x001F // 00000111,11100000 == 0x07E0 // 11111000,00000000 == 0xF800 - + extractComponents[0] = (float)( ( ushort & 0x001F ) ) / 31.0f; extractComponents[1] = (float)( ( ushort & 0x07E0 ) >> 5 ) / 63.0f; extractComponents[2] = (float)( ( ushort & 0xF800 ) >> 11 ) / 31.0f; } - + public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 00000000,00111111 == 0x001F // 00000111,11100000 == 0x07E0 // 11111000,00000000 == 0xF800 - + assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f ); assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f ); assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f ); - + // due to limited precision, need to round before shoving int ushort = (((int)((shoveComponents[0] * 31) + 0.5f) ) & 0x0000001F ); ushort |= (((int)((shoveComponents[1] * 63) + 0.5f) << 5) & 0x000007E0 ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888.java index 137fa3c21..4602f2af9 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,42 +51,42 @@ import java.nio.*; * @author Administrator */ public class Extract8888 implements Extract { - + /** Creates a new instance of Extract8888 */ public Extract8888() { } - + public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { long uint = 0; - + if( isSwap ) { uint = 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( packedPixel.getInt() ); } else { uint = 0x00000000FFFFFFFF & packedPixel.getInt(); } - + // 11111000,00000000 == 0xF800 // 00000111,11000000 == 0x07C0 // 00000000,00111110 == 0x003E // 00000000,00000001 == 0x0001 - + extractComponents[0] = (float)( ( uint & 0xFF000000 ) >> 24 ) / 255.0f; extractComponents[1] = (float)( ( uint & 0x00FF0000 ) >> 16 ) / 255.0f; extractComponents[2] = (float)( ( uint & 0x0000FF00 ) >> 8 ) / 255.0f; extractComponents[3] = (float)( ( uint & 0x000000FF ) ) / 255.0f; } - + public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 // 00000000,11110000 == 0x00F0 // 00000000,00001111 == 0x000F - + assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f ); assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f ); assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f ); assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f ); - + // due to limited precision, need to round before shoving long uint = (((int)((shoveComponents[0] * 255) + 0.5f) << 24) & 0xFF000000 ); uint |= (((int)((shoveComponents[1] * 255) + 0.5f) << 16) & 0x00FF0000 ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888rev.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888rev.java index 2ac942c84..373cb102a 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888rev.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888rev.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,42 +51,42 @@ import java.nio.*; * @author Administrator */ public class Extract8888rev implements Extract { - + /** Creates a new instance of Extract8888rev */ public Extract8888rev() { } - + public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { long uint = 0; - + if( isSwap ) { uint = 0x00000000FFFFFFFF & Mipmap.GLU_SWAP_4_BYTES( packedPixel.getInt() ); } else { uint = 0x00000000FFFFFFFF & packedPixel.getInt(); } - + // 11111000,00000000 == 0xF800 // 00000111,11000000 == 0x07C0 // 00000000,00111110 == 0x003E // 00000000,00000001 == 0x0001 - + extractComponents[0] = (float)( ( uint & 0x000000FF ) ) / 255.0f; extractComponents[1] = (float)( ( uint & 0x0000FF00 ) >> 8 ) / 255.0f; extractComponents[2] = (float)( ( uint & 0x00FF0000 ) >> 16 ) / 255.0f; extractComponents[3] = (float)( ( uint & 0xFF000000 ) >> 24 ) / 255.0f; } - + public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 // 00000000,11110000 == 0x00F0 // 00000000,00001111 == 0x000F - + assert( 0.0f <= shoveComponents[0] && shoveComponents[0] <= 1.0f ); assert( 0.0f <= shoveComponents[1] && shoveComponents[1] <= 1.0f ); assert( 0.0f <= shoveComponents[2] && shoveComponents[2] <= 1.0f ); assert( 0.0f <= shoveComponents[3] && shoveComponents[3] <= 1.0f ); - + // due to limited precision, need to round before shoving long uint = (((int)((shoveComponents[0] * 255) + 0.5f) ) & 0x000000FF ); uint |= (((int)((shoveComponents[1] * 255) + 0.5f) << 8) & 0x0000FF00 ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractFloat.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractFloat.java index 52c2191b9..ac0f2f290 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractFloat.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractFloat.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,11 +51,11 @@ import java.nio.*; * @author Administrator */ public class ExtractFloat implements ExtractPrimitive { - + /** Creates a new instance of ExtractFloat */ public ExtractFloat() { } - + public double extract( boolean isSwap, ByteBuffer data ) { float f = 0; if( isSwap ) { @@ -66,7 +66,7 @@ public class ExtractFloat implements ExtractPrimitive { assert( f <= 1.0f ); return( f ); } - + public void shove( double value, int index, ByteBuffer data ) { assert(0.0 <= value && value < 1.0); data.asFloatBuffer().put( index, (float)value ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractPrimitive.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractPrimitive.java index 926096649..a44fb9508 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractPrimitive.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractPrimitive.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java index 2e1a9a0a6..399386e30 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,17 +51,17 @@ import java.nio.ByteBuffer; * @author Administrator */ public class ExtractSByte implements ExtractPrimitive { - + /** Creates a new instance of ExtractUByte */ public ExtractSByte() { } - + public double extract( boolean isSwap, ByteBuffer sbyte ) { byte b = sbyte.get(); assert( b <= 127 ); return( b ); } - + public void shove( double value, int index, ByteBuffer data ) { data.position( index ); data.put( (byte)value ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSInt.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSInt.java index ca80747c4..be3fb3092 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSInt.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSInt.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,11 +51,11 @@ import java.nio.*; * @author Administrator */ public class ExtractSInt implements ExtractPrimitive { - + /** Creates a new instance of ExtractSInt */ public ExtractSInt() { } - + public double extract( boolean isSwap, ByteBuffer uint ) { int i = 0; if( isSwap ) { @@ -66,7 +66,7 @@ public class ExtractSInt implements ExtractPrimitive { assert( i <= 0x7FFFFFFF ); return( i ); } - + public void shove( double value, int index, ByteBuffer data ) { assert(0.0 <= value && value < Integer.MAX_VALUE); IntBuffer ib = data.asIntBuffer(); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSShort.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSShort.java index 979c3b449..1e123c9b4 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSShort.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSShort.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,11 +51,11 @@ import java.nio.*; * @author Administrator */ public class ExtractSShort implements ExtractPrimitive { - + /** Creates a new instance of ExtractSShort */ public ExtractSShort() { } - + public double extract( boolean isSwap, ByteBuffer ushort ) { short s = 0; if( isSwap ) { @@ -66,7 +66,7 @@ public class ExtractSShort implements ExtractPrimitive { assert( s <= 32767 ); return( s ); } - + public void shove( double value, int index, ByteBuffer data ) { assert(0.0 <= value && value < 32768.0); ShortBuffer sb = data.asShortBuffer(); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUByte.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUByte.java index 4d14212ab..26ca5cd40 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUByte.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUByte.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,17 +51,17 @@ import java.nio.ByteBuffer; * @author Administrator */ public class ExtractUByte implements ExtractPrimitive { - + /** Creates a new instance of ExtractUByte */ public ExtractUByte() { } - + public double extract( boolean isSwap, ByteBuffer ubyte ) { int i = 0x000000FF & ubyte.get(); assert( i <= 255 ); return( i ); } - + public void shove( double value, int index, ByteBuffer data ) { assert(0.0 <= value && value < 256.0); data.position( index ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUInt.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUInt.java index c088ca301..8c94c89fc 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUInt.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUInt.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,11 +51,11 @@ import java.nio.*; * @author Administrator */ public class ExtractUInt implements ExtractPrimitive { - + /** Creates a new instance of ExtractUInt */ public ExtractUInt() { } - + public double extract( boolean isSwap, ByteBuffer uint ) { long i = 0; if( isSwap ) { @@ -66,7 +66,7 @@ public class ExtractUInt implements ExtractPrimitive { assert( i <= 0xFFFFFFFF ); return( i ); } - + public void shove( double value, int index, ByteBuffer data ) { assert(0.0 <= value && value < 0xFFFFFFFF); IntBuffer ib = data.asIntBuffer(); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUShort.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUShort.java index 81db60f0f..55115c6f7 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUShort.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUShort.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,11 +51,11 @@ import java.nio.*; * @author Administrator */ public class ExtractUShort implements ExtractPrimitive { - + /** Creates a new instance of ExtracUShort */ public ExtractUShort() { } - + public double extract( boolean isSwap, ByteBuffer ushort ) { int i = 0; if( isSwap ) { @@ -66,7 +66,7 @@ public class ExtractUShort implements ExtractPrimitive { assert( i <= 65535 ); return( i ); } - + public void shove( double value, int index, ByteBuffer data ) { assert(0.0 <= value && value < 65536.0); ShortBuffer sb = data.asShortBuffer(); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/HalveImage.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/HalveImage.java index 7549044ba..184c5fda8 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/HalveImage.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/HalveImage.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -52,11 +52,11 @@ import java.nio.*; * @author Administrator */ public class HalveImage { - + private static final int BOX2 = 2; private static final int BOX4 = 4; private static final int BOX8 = 8; - + public static void halveImage( int components, int width, int height, ShortBuffer datain, ShortBuffer dataout ) { int i, j, k; @@ -64,11 +64,11 @@ public class HalveImage { int delta; int t = 0; short temp = 0; - + newwidth = width / 2; newheight = height /2; delta = width * components; - + // Piece of cake for( i = 0; i < newheight; i++ ) { for( j = 0; j < newwidth; j++ ) { @@ -91,7 +91,7 @@ public class HalveImage { t += delta; } } - + public static void halveImage_ubyte( int components, int width, int height, ByteBuffer datain, ByteBuffer dataout, int element_size, int ysize, int group_size ) { @@ -99,19 +99,19 @@ public class HalveImage { int newwidth, newheight; int s; int t; - + // Handle case where there is only 1 column/row if( width == 1 || height == 1 ) { assert( !( width == 1 && height == 1 ) ); // can't be 1x1 halve1Dimage_ubyte( components, width, height, datain, dataout, element_size, ysize, group_size ); return; } - + newwidth = width / 2; newheight = height / 2; s = 0; t = 0; - + int temp = 0; // piece of cake for( i = 0; i < newheight; i++ ) { @@ -133,9 +133,9 @@ public class HalveImage { t += ysize; } } - + public static void halve1Dimage_ubyte( int components, int width, int height, - ByteBuffer datain, ByteBuffer dataout, + ByteBuffer datain, ByteBuffer dataout, int element_size, int ysize, int group_size ) { int halfWidth = width / 2; int halfHeight = height / 2; @@ -143,14 +143,14 @@ public class HalveImage { int dest = 0; int jj; int temp = 0; - + assert( width == 1 || height == 1 ); // Must be 1D assert( width != height ); // can't be square - + if( height == 1 ) { // 1 row assert( width != 1 ); // widthxheight can't be 1x1 halfHeight = 1; - + for( jj = 0; jj < halfWidth; jj++ ) { int kk; for( kk = 0; kk < components; kk++ ) { @@ -161,7 +161,7 @@ public class HalveImage { temp /= 2; dataout.put( (byte)temp ); /* - dataout.setByte( (byte)(((0x000000FF & datain.setIndexInBytes(src).getByte()) + + dataout.setByte( (byte)(((0x000000FF & datain.setIndexInBytes(src).getByte()) + (0x000000FF & datain.setIndexInBytes( src + group_size ).getByte())) / 2 ) ); */ src += element_size; @@ -188,7 +188,7 @@ public class HalveImage { temp /= 2; dataout.put( (byte)temp ); /* - dataout.setByte( (byte)(((0x000000FF & datain.setIndexInBytes(src).getByte()) + + dataout.setByte( (byte)(((0x000000FF & datain.setIndexInBytes(src).getByte()) + (0x000000FF & datain.setIndexInBytes(src + ysize).getByte()) ) / 2 ) ); */ src += element_size; @@ -202,7 +202,7 @@ public class HalveImage { assert( src == ysize * height ); assert( dest == components * element_size * halfWidth * halfHeight ); } - + public static void halveImage_byte( int components, int width, int height, ByteBuffer datain, ByteBuffer dataout, int element_size, int ysize, int group_size ) { @@ -211,7 +211,7 @@ public class HalveImage { int s = 0; int t = 0; byte temp = (byte)0; - + // handle case where there is only 1 column if( width == 1 || height == 1 ) { assert( !( width == 1 && height == 1 ) ); @@ -219,10 +219,10 @@ public class HalveImage { ysize, group_size ); return; } - + newwidth = width / 2; newheight = height / 2; - + for( i = 0; i < newheight; i++ ) { for( j = 0; j < newwidth; j++ ) { for( k = 0; k < components; k++ ) { @@ -244,7 +244,7 @@ public class HalveImage { t += ysize; } } - + public static void halve1Dimage_byte( int components, int width, int height, ByteBuffer datain, ByteBuffer dataout, int element_size, int ysize, int group_size ) { @@ -254,14 +254,14 @@ public class HalveImage { int dest = 0; int jj; byte temp = (byte)0; - + assert( width == 1 || height == 1 ); // must be 1D assert( width != height ); // can't be square - + if( height == 1 ) { // 1 row assert( width != 1 ); // widthxheight can't be 1 halfHeight = 1; - + for( jj = 0; jj < halfWidth; jj++ ) { int kk; for( kk = 0; kk < components; kk++ ) { @@ -284,7 +284,7 @@ public class HalveImage { halfWidth = 1; // one vertical column with possible pad bytes per row // average two at a time - + for( jj = 0; jj < halfHeight; jj++ ) { int kk; for( kk = 0; kk < components; kk++ ) { @@ -303,7 +303,7 @@ public class HalveImage { } assert( dest == components * element_size * halfWidth * halfHeight ); } - + public static void halveImage_ushort( int components, int width, int height, ByteBuffer datain, ShortBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { @@ -319,10 +319,10 @@ public class HalveImage { ysize, group_size, myswap_bytes ); return; } - + newwidth = width / 2; newheight = height / 2; - + // Piece of cake if( !myswap_bytes ) { for( i = 0; i < newheight; i++ ) { @@ -364,7 +364,7 @@ public class HalveImage { } } } - + public static void halve1Dimage_ushort( int components, int width, int height, ByteBuffer datain, ShortBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { @@ -373,14 +373,14 @@ public class HalveImage { int src = 0; int dest = 0; int jj; - + assert( width == 1 || height == 1 ); // must be 1D assert( width != height ); // can't be square - + if( height == 1 ) { // 1 row assert( width != 1 ); // widthxheight can't be 1 halfHeight = 1; - + for( jj = 0; jj < halfWidth; jj++ ) { int kk; for( kk = 0; kk < halfHeight; kk++ ) { @@ -410,7 +410,7 @@ public class HalveImage { halfWidth = 1; // one vertical column with possible pad bytes per row // average two at a time - + for( jj = 0; jj < halfHeight; jj++ ) { int kk; for( kk = 0; kk < components; kk++ ) { @@ -437,7 +437,7 @@ public class HalveImage { } assert( dest == components * element_size * halfWidth * halfHeight ); } - + public static void halveImage_short( int components, int width, int height, ByteBuffer datain, ShortBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { @@ -453,10 +453,10 @@ public class HalveImage { ysize, group_size, myswap_bytes ); return; } - + newwidth = width / 2; newheight = height / 2; - + // Piece of cake if( !myswap_bytes ) { for( i = 0; i < newheight; i++ ) { @@ -504,7 +504,7 @@ public class HalveImage { } } } - + public static void halve1Dimage_short( int components, int width, int height, ByteBuffer datain, ShortBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { @@ -513,14 +513,14 @@ public class HalveImage { int src = 0; int dest = 0; int jj; - + assert( width == 1 || height == 1 ); // must be 1D assert( width != height ); // can't be square - + if( height == 1 ) { // 1 row assert( width != 1 ); // can't be 1x1 halfHeight = 1; - + for( jj = 0; jj < halfWidth; jj++ ) { int kk; for( kk = 0; kk < components; kk++ ) { @@ -550,7 +550,7 @@ public class HalveImage { halfWidth = 1; // one vertical column with possible pad bytes per row // average two at a time - + for( jj = 0; jj < halfHeight; jj++ ) { int kk; for( kk = 0; kk < components; kk++ ) { @@ -577,7 +577,7 @@ public class HalveImage { } assert( dest == ( components * element_size * halfWidth * halfHeight ) ); } - + public static void halveImage_uint( int components, int width, int height, ByteBuffer datain, IntBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { @@ -586,7 +586,7 @@ public class HalveImage { int s = 0; int t = 0; double temp = 0; - + // handle case where there is only 1 column/row if( width == 1 || height == 1 ) { assert( !( width == 1 && height == 1 ) ); // can't be 1x1 @@ -594,10 +594,10 @@ public class HalveImage { ysize, group_size, myswap_bytes ); return; } - + newwidth = width / 2; newheight = height / 2; - + // Piece of cake if( !myswap_bytes ) { for( i = 0; i < newheight; i++ ) { @@ -643,7 +643,7 @@ public class HalveImage { } } } - + public static void halve1Dimage_uint( int components, int width, int height, ByteBuffer datain, IntBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { @@ -652,14 +652,14 @@ public class HalveImage { int src = 0; int dest = 0; int jj; - + assert( width == 1 || height == 1 ); // must be 1D assert( width != height ); // can't be square - + if( height == 1 ) { // 1 row assert( width != 1 ); // widthxheight can't be 1 halfHeight = 1; - + for( jj = 0; jj < halfWidth; jj++ ) { int kk; for( kk = 0; kk < halfHeight; kk++ ) { @@ -689,7 +689,7 @@ public class HalveImage { halfWidth = 1; // one vertical column with possible pad bytes per row // average two at a time - + for( jj = 0; jj < halfHeight; jj++ ) { int kk; for( kk = 0; kk < components; kk++ ) { @@ -716,7 +716,7 @@ public class HalveImage { } assert( dest == components * element_size * halfWidth * halfHeight ); } - + public static void halveImage_int( int components, int width, int height, ByteBuffer datain, IntBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { @@ -725,7 +725,7 @@ public class HalveImage { int s = 0; int t = 0; int temp = 0; - + // handle case where there is only 1 column/row if( width == 1 || height == 1 ) { assert( !( width == 1 && height == 1 ) ); // can't be 1x1 @@ -733,10 +733,10 @@ public class HalveImage { ysize, group_size, myswap_bytes ); return; } - + newwidth = width / 2; newheight = height / 2; - + // Piece of cake if( !myswap_bytes ) { for( i = 0; i < newheight; i++ ) { @@ -785,7 +785,7 @@ public class HalveImage { } } } - + public static void halve1Dimage_int( int components, int width, int height, ByteBuffer datain, IntBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { @@ -794,14 +794,14 @@ public class HalveImage { int src = 0; int dest = 0; int jj; - + assert( width == 1 || height == 1 ); // must be 1D assert( width != height ); // can't be square - + if( height == 1 ) { // 1 row assert( width != 1 ); // can't be 1x1 halfHeight = 1; - + for( jj = 0; jj < halfWidth; jj++ ) { int kk; for( kk = 0; kk < components; kk++ ) { @@ -831,7 +831,7 @@ public class HalveImage { halfWidth = 1; // one vertical column with possible pad bytes per row // average two at a time - + for( jj = 0; jj < halfHeight; jj++ ) { int kk; for( kk = 0; kk < components; kk++ ) { @@ -858,7 +858,7 @@ public class HalveImage { } assert( dest == ( components * element_size * halfWidth * halfHeight ) ); } - + public static void halveImage_float( int components, int width, int height, ByteBuffer datain, FloatBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { @@ -874,10 +874,10 @@ public class HalveImage { ysize, group_size, myswap_bytes ); return; } - + newwidth = width / 2; newheight = height / 2; - + // Piece of cake if( !myswap_bytes ) { for( i = 0; i < newheight; i++ ) { @@ -920,7 +920,7 @@ public class HalveImage { } } } - + public static void halve1Dimage_float( int components, int width, int height, ByteBuffer datain, FloatBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { @@ -929,14 +929,14 @@ public class HalveImage { int src = 0; int dest = 0; int jj; - + assert( width == 1 || height == 1 ); // must be 1D assert( width != height ); // can't be square - + if( height == 1 ) { // 1 row assert( width != 1 ); // can't be 1x1 halfHeight = 1; - + for( jj = 0; jj < halfWidth; jj++ ) { int kk; for( kk = 0; kk < components; kk++ ) { @@ -966,7 +966,7 @@ public class HalveImage { halfWidth = 1; // one vertical column with possible pad bytes per row // average two at a time - + for( jj = 0; jj < halfHeight; jj++ ) { int kk; for( kk = 0; kk < components; kk++ ) { @@ -993,9 +993,9 @@ public class HalveImage { } assert( dest == ( components * element_size * halfWidth * halfHeight ) ); } - - public static void halveImagePackedPixel( int components, Extract extract, int width, - int height, ByteBuffer datain, ByteBuffer dataout, + + public static void halveImagePackedPixel( int components, Extract extract, int width, + int height, ByteBuffer datain, ByteBuffer dataout, int pixelSizeInBytes, int rowSizeInBytes, boolean isSwap ) { if( width == 1 || height == 1 ) { assert( !( width == 1 && height == 1 ) ); @@ -1004,19 +1004,19 @@ public class HalveImage { return; } int ii, jj; - + int halfWidth = width / 2; int halfHeight = height / 2; int src = 0; int padBytes = rowSizeInBytes - ( width * pixelSizeInBytes ); int outIndex = 0; - + for( ii = 0; ii < halfHeight; ii++ ) { for( jj = 0; jj < halfWidth; jj++ ) { float totals[] = new float[4]; float extractTotals[][] = new float[BOX4][4]; int cc; - + datain.position( src ); extract.extract( isSwap, datain, extractTotals[0] ); datain.position( src + pixelSizeInBytes ); @@ -1045,7 +1045,7 @@ public class HalveImage { assert( src == rowSizeInBytes * height ); assert( outIndex == halfWidth * halfHeight ); } - + public static void halve1DimagePackedPixel( int components, Extract extract, int width, int height, ByteBuffer datain, ByteBuffer dataout, int pixelSizeInBytes, int rowSizeInBytes, boolean isSwap ) { @@ -1053,23 +1053,23 @@ public class HalveImage { int halfHeight = height / 2; int src = 0; int jj; - + assert( width == 1 || height == 1 ); assert( width != height ); - + if( height == 1 ) { int outIndex = 0; - + assert( width != 1 ); halfHeight = 1; - + // one horizontal row with possible pad bytes - + for( jj = 0; jj < halfWidth; jj++ ) { float[] totals = new float[4]; float[][] extractTotals = new float[BOX2][4]; int cc; - + datain.position( src ); extract.extract( isSwap, datain, extractTotals[0] ); datain.position( src + pixelSizeInBytes ); @@ -1090,17 +1090,17 @@ public class HalveImage { } int padBytes = rowSizeInBytes - ( width * pixelSizeInBytes ); src += padBytes; - + assert( src == rowSizeInBytes ); assert( outIndex == halfWidth * halfHeight ); } else if( width == 1 ) { int outIndex = 0; - + assert( height != 1 ); halfWidth = 1; // one vertical volumn with possible pad bytes per row // average two at a time - + for( jj = 0; jj < halfHeight; jj++ ) { float[] totals = new float[4]; float[][] extractTotals = new float[BOX2][4]; @@ -1128,7 +1128,7 @@ public class HalveImage { assert( outIndex == halfWidth * halfHeight ); } } - + public static void halveImagePackedPixelSlice( int components, Extract extract, int width, int height, int depth, ByteBuffer dataIn, ByteBuffer dataOut, int pixelSizeInBytes, int rowSizeInBytes, @@ -1140,26 +1140,26 @@ public class HalveImage { int src = 0; int padBytes = rowSizeInBytes - ( width * pixelSizeInBytes ); int outIndex = 0; - + assert( (width == 1 || height == 1) && depth >= 2 ); - + if( width == height ) { assert( width == 1 && height == 1 ); assert( depth >= 2 ); - + for( ii = 0; ii < halfDepth; ii++ ) { float totals[] = new float[4]; float extractTotals[][] = new float[BOX2][4]; int cc; - + dataIn.position( src ); extract.extract( isSwap, dataIn, extractTotals[0] ); dataIn.position( src + imageSizeInBytes ); extract.extract( isSwap, dataIn, extractTotals[1] ); - + for( cc = 0; cc < components; cc++ ) { int kk; - + // average only 2 pixels since a column totals[cc]= 0.0f; for( kk = 0; kk < BOX2; kk++ ) { @@ -1167,7 +1167,7 @@ public class HalveImage { } totals[cc] /= BOX2; } // for cc - + extract.shove( totals, outIndex, dataOut ); outIndex++; // skip over to next group of 2 @@ -1175,13 +1175,13 @@ public class HalveImage { } // for ii } else if( height == 1 ) { assert( width != 1 ); - + for( ii = 0; ii < halfDepth; ii++ ) { for( jj = 0; jj < halfWidth; jj++ ) { float totals[] = new float[4]; float extractTotals[][] = new float[BOX4][4]; int cc; - + dataIn.position( src ); extract.extract( isSwap, dataIn, extractTotals[0] ); dataIn.position( src + pixelSizeInBytes ); @@ -1190,10 +1190,10 @@ public class HalveImage { extract.extract( isSwap, dataIn, extractTotals[2] ); dataIn.position( src + pixelSizeInBytes + imageSizeInBytes ); extract.extract( isSwap, dataIn, extractTotals[3] ); - + for( cc = 0; cc < components; cc++ ) { int kk; - + // grab 4 pixels to average totals[cc] = 0.0f; for( kk = 0; kk < BOX4; kk++ ) { @@ -1209,13 +1209,13 @@ public class HalveImage { } } else if( width == 1 ) { assert( height != 1 ); - + for( ii = 0; ii < halfDepth; ii++ ) { for( jj = 0; jj < halfWidth; jj++ ) { float totals[] = new float[4]; float extractTotals[][] = new float[BOX4][4]; int cc; - + dataIn.position( src ); extract.extract( isSwap, dataIn, extractTotals[0] ); dataIn.position( src + rowSizeInBytes ); @@ -1224,10 +1224,10 @@ public class HalveImage { extract.extract( isSwap, dataIn, extractTotals[2] ); dataIn.position( src + rowSizeInBytes + imageSizeInBytes ); extract.extract( isSwap, dataIn, extractTotals[3] ); - + for( cc = 0; cc < components; cc++ ) { int kk; - + // grab 4 pixels to average totals[cc] = 0.0f; for( kk = 0; kk < BOX4; kk++ ) { @@ -1243,7 +1243,7 @@ public class HalveImage { } } } - + public static void halveImageSlice( int components, ExtractPrimitive extract, int width, int height, int depth, ByteBuffer dataIn, ByteBuffer dataOut, int elementSizeInBytes, int groupSizeInBytes, int rowSizeInBytes, @@ -1255,25 +1255,25 @@ public class HalveImage { int src = 0; int padBytes = rowSizeInBytes - ( width * groupSizeInBytes ); int outIndex = 0; - + assert( (width == 1 || height == 1) && depth >= 2 ); - + if( width == height ) { assert( width == 1 && height == 1 ); assert( depth >= 2 ); - + for( ii = 0; ii < halfDepth; ii++ ) { int cc; for( cc = 0; cc < components; cc++ ) { double[] totals = new double[4]; double[][] extractTotals = new double[BOX2][4]; int kk; - + dataIn.position( src ); extractTotals[0][cc] = extract.extract( isSwap, dataIn ); dataIn.position( src + imageSizeInBytes ); extractTotals[1][cc] = extract.extract( isSwap, dataIn ); - + // average 2 pixels since only a column totals[cc] = 0.0f; // totals[red] = extractTotals[0][red] + extractTotals[1][red]; @@ -1282,7 +1282,7 @@ public class HalveImage { totals[cc] += extractTotals[kk][cc]; } totals[cc] /= (double)BOX2; - + extract.shove( totals[cc], outIndex, dataOut ); outIndex++; src += elementSizeInBytes; @@ -1290,12 +1290,12 @@ public class HalveImage { // skip over next group of 2 src += rowSizeInBytes; } // for ii - + assert( src == rowSizeInBytes * height * depth ); assert( outIndex == halfDepth * components ); } else if( height == 1 ) { assert( width != 1 ); - + for( ii = 0; ii < halfDepth; ii++ ) { for( jj = 0; jj < halfWidth; jj++ ) { int cc; @@ -1303,7 +1303,7 @@ public class HalveImage { int kk; double totals[] = new double[4]; double extractTotals[][] = new double[BOX4][4]; - + dataIn.position( src ); extractTotals[0][cc] = extract.extract( isSwap, dataIn ); dataIn.position( src + groupSizeInBytes ); @@ -1312,7 +1312,7 @@ public class HalveImage { extractTotals[2][cc] = extract.extract( isSwap, dataIn ); dataIn.position( src + imageSizeInBytes + groupSizeInBytes ); extractTotals[3][cc] = extract.extract( isSwap, dataIn ); - + // grab 4 pixels to average totals[cc] = 0.0f; // totals[red] = extractTotals[0][red] + extractTotals[1][red] + @@ -1322,7 +1322,7 @@ public class HalveImage { totals[cc] += extractTotals[kk][cc]; } totals[cc] /= (double)BOX4; - + extract.shove( totals[cc], outIndex, dataOut ); outIndex++; src += elementSizeInBytes; @@ -1337,7 +1337,7 @@ public class HalveImage { assert( outIndex == halfWidth * halfDepth * components ); } else if( width == 1 ) { assert( height != 1 ); - + for( ii = 0; ii < halfDepth; ii++ ) { for( jj = 0; jj < halfHeight; jj++ ) { int cc; @@ -1345,7 +1345,7 @@ public class HalveImage { int kk; double totals[] = new double[4]; double extractTotals[][] = new double[BOX4][4]; - + dataIn.position( src ); extractTotals[0][cc] = extract.extract( isSwap, dataIn ); dataIn.position( src + rowSizeInBytes ); @@ -1354,8 +1354,8 @@ public class HalveImage { extractTotals[2][cc] = extract.extract( isSwap, dataIn ); dataIn.position( src + imageSizeInBytes + groupSizeInBytes ); extractTotals[3][cc] = extract.extract( isSwap, dataIn ); - - + + // grab 4 pixels to average totals[cc] = 0.0f; // totals[red] = extractTotals[0][red] + extractTotals[1][red] + @@ -1365,7 +1365,7 @@ public class HalveImage { totals[cc] += extractTotals[kk][cc]; } totals[cc] /= (double)BOX4; - + extract.shove( totals[cc], outIndex, dataOut ); outIndex++; src += elementSizeInBytes; @@ -1380,32 +1380,32 @@ public class HalveImage { assert( outIndex == halfWidth * halfDepth * components ); } } - + public static void halveImage3D( int components, ExtractPrimitive extract, int width, int height, int depth, ByteBuffer dataIn, ByteBuffer dataOut, int elementSizeInBytes, int groupSizeInBytes, int rowSizeInBytes, int imageSizeInBytes, boolean isSwap ) { assert( depth > 1 ); - + // horizontal/vertical/onecolumn slice viewed from top if( width == 1 || height == 1 ) { assert( 1 <= depth ); - + halveImageSlice( components, extract, width, height, depth, dataIn, dataOut, elementSizeInBytes, groupSizeInBytes, rowSizeInBytes, imageSizeInBytes, isSwap ); return; } - + int ii, jj, dd; - + int halfWidth = width / 2; int halfHeight = height / 2; int halfDepth = depth / 2; int src = 0; int padBytes = rowSizeInBytes - ( width * groupSizeInBytes ); int outIndex = 0; - + for( dd = 0; dd < halfDepth; dd++ ) { for( ii = 0; ii < halfHeight; ii++ ) { for( jj = 0; jj < halfWidth; jj++ ) { @@ -1414,7 +1414,7 @@ public class HalveImage { int kk; double totals[] = new double[4]; double extractTotals[][] = new double[BOX8][4]; - + dataIn.position( src ); extractTotals[0][cc] = extract.extract( isSwap, dataIn ); dataIn.position( src + groupSizeInBytes ); @@ -1431,17 +1431,17 @@ public class HalveImage { extractTotals[6][cc] = extract.extract( isSwap, dataIn ); dataIn.position( src + rowSizeInBytes + imageSizeInBytes + groupSizeInBytes ); extractTotals[7][cc] = extract.extract( isSwap, dataIn ); - + totals[cc] = 0.0f; - + for( kk = 0; kk < BOX8; kk++ ) { totals[cc] += extractTotals[kk][cc]; } totals[cc] /= (double)BOX8; - + extract.shove( totals[cc], outIndex, dataOut ); outIndex++; - + src += elementSizeInBytes; } // for cc // skip over to next square of 4 @@ -1456,40 +1456,40 @@ public class HalveImage { assert( src == rowSizeInBytes * height * depth ); assert( outIndex == halfWidth * halfHeight * halfDepth * components ); } - + public static void halveImagePackedPixel3D( int components, Extract extract, - int width, int height, int depth, ByteBuffer dataIn, + int width, int height, int depth, ByteBuffer dataIn, ByteBuffer dataOut, int pixelSizeInBytes, int rowSizeInBytes, int imageSizeInBytes, boolean isSwap ) { if( depth == 1 ) { assert( 1 <= width && 1 <= height ); - + halveImagePackedPixel( components, extract, width, height, dataIn, dataOut, pixelSizeInBytes, rowSizeInBytes, isSwap ); return; } else if( width == 1 || height == 1 ) { // a horizontal or vertical slice viewed from top assert( 1 <= depth ); - + halveImagePackedPixelSlice( components, extract, width, height, depth, dataIn, dataOut, pixelSizeInBytes, rowSizeInBytes, imageSizeInBytes, isSwap ); return; } int ii, jj, dd; - + int halfWidth = width / 2; int halfHeight = height / 2; int halfDepth = depth / 2; int src = 0; int padBytes = rowSizeInBytes - ( width * pixelSizeInBytes ); int outIndex = 0; - + for( dd = 0; dd < halfDepth; dd++ ) { for( ii = 0; ii < halfHeight; ii++ ) { for( jj = 0; jj < halfWidth; jj++ ) { float totals[] = new float[4]; // 4 is max components float extractTotals[][] = new float[BOX8][4]; int cc; - + dataIn.position( src ); extract.extract( isSwap, dataIn, extractTotals[0] ); dataIn.position( src + pixelSizeInBytes ); @@ -1506,7 +1506,7 @@ public class HalveImage { extract.extract( isSwap, dataIn, extractTotals[6] ); dataIn.position( src + rowSizeInBytes + pixelSizeInBytes + imageSizeInBytes ); extract.extract( isSwap, dataIn, extractTotals[7] ); - + for( cc = 0; cc < components; cc++ ) { int kk; // grab 8 pixels to average diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Image.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Image.java index b610ce86b..18f814dde 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Image.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Image.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -53,18 +53,18 @@ import java.nio.*; * @author Administrator */ public class Image { - + /** Creates a new instance of Image */ public Image() { } - + public static short getShortFromByteArray( byte[] array, int index ) { short s; s = (short)(array[index] << 8 ); s |= (short)(0x00FF & array[index+1]); return( s ); } - + public static int getIntFromByteArray( byte[] array, int index ) { int i; i = ( array[index] << 24 ) & 0xFF000000; @@ -73,12 +73,12 @@ public class Image { i |= ( array[index+3] ) & 0x000000FF; return( i ); } - + public static float getFloatFromByteArray( byte[] array, int index ) { int i = getIntFromByteArray( array, index ); return( Float.intBitsToFloat(i) ); } - + /* * Extract array from user's data applying all pixel store modes. * The internal format used is an array of unsigned shorts. @@ -98,7 +98,7 @@ public class Image { int iter2; int i, j, k; boolean myswap_bytes; - + // Create a Extract interface object Extract extract = null; switch( type ) { @@ -139,7 +139,7 @@ public class Image { extract = new Extract2101010rev(); break; } - + myswap_bytes = psm.getUnpackSwapBytes(); components = Mipmap.elements_per_group( format, type ); if( psm.getUnpackRowLength() > 0 ) { @@ -147,12 +147,12 @@ public class Image { } else { groups_per_line = width; } - + // All formats except GL_BITMAP fall out trivially if( type == GL2.GL_BITMAP ) { int bit_offset; int current_bit; - + rowsize = ( groups_per_line * components + 7 ) / 8; padding = ( rowsize % psm.getUnpackAlignment() ); if( padding != 0 ) { @@ -200,7 +200,7 @@ public class Image { if( element_size == 1 ) { myswap_bytes = false; } - + rowsize = groups_per_line * group_size; padding = ( rowsize % psm.getUnpackAlignment() ); if( padding != 0 ) { @@ -208,7 +208,7 @@ public class Image { } start = psm.getUnpackSkipRows() * rowsize + psm.getUnpackSkipPixels() * group_size; elements_per_line = width * components; - + iter2 = 0; for( i = 0; i < height; i++ ) { iter = start; @@ -364,7 +364,7 @@ public class Image { // want iter pointing at start, not within, row for assertion purposes iter = start; } // for i - + // iterators should be one byte past end if( !Mipmap.isTypePackedPixel( type ) ) { assert( iter2 == ( width * height * components ) ); @@ -374,16 +374,16 @@ public class Image { assert( iter == ( rowsize * height + psm.getUnpackSkipRows() * rowsize + psm.getUnpackSkipPixels() * group_size ) ); } } - + /* * Insert array into user's data applying all pixel store modes. * Theinternal format is an array of unsigned shorts. * empty_image() because it is the opposet of fill_image(). */ - public static void empty_image( PixelStorageModes psm, int width, int height, - int format, int type, boolean index_format, + public static void empty_image( PixelStorageModes psm, int width, int height, + int format, int type, boolean index_format, ShortBuffer oldimage, ByteBuffer userdata ) { - + int components; int element_size; int rowsize; @@ -396,7 +396,7 @@ public class Image { int iter2; int i, j, k; boolean myswap_bytes; - + // Create a Extract interface object Extract extract = null; switch( type ) { @@ -437,7 +437,7 @@ public class Image { extract = new Extract2101010rev(); break; } - + myswap_bytes = psm.getPackSwapBytes(); components = Mipmap.elements_per_group( format, type ); if( psm.getPackRowLength() > 0 ) { @@ -445,12 +445,12 @@ public class Image { } else { groups_per_line = width; } - + // all formats except GL_BITMAP fall out trivially if( type == GL2.GL_BITMAP ) { int bit_offset; int current_bit; - + rowsize = ( groups_per_line * components + 7 ) / 8; padding = ( rowsize % psm.getPackAlignment() ); if( padding != 0 ) { @@ -472,7 +472,7 @@ public class Image { current_bit = 0; } } - + if( current_bit != 0 ) { if( psm.getPackLsbFirst() ) { userdata.put( iter, (byte)( ( userdata.get( iter ) | ( 1 << bit_offset ) ) ) ); @@ -488,7 +488,7 @@ public class Image { userdata.put( iter, (byte)( ( userdata.get( iter ) & ~( 7 - bit_offset ) ) ) ); } } - + bit_offset++; if( bit_offset == 8 ) { bit_offset = 0; @@ -500,13 +500,13 @@ public class Image { } } else { float shoveComponents[] = new float[4]; - + element_size = Mipmap.bytes_per_element( type ); group_size = element_size * components; if( element_size == 1 ) { myswap_bytes = false; } - + rowsize = groups_per_line * group_size; padding = ( rowsize % psm.getPackAlignment() ); if( padding != 0 ) { @@ -514,13 +514,13 @@ public class Image { } start = psm.getPackSkipRows() * rowsize + psm.getPackSkipPixels() * group_size; elements_per_line = width * components; - + iter2 = 0; for( i = 0; i < height; i++ ) { iter = start; for( j = 0; j < elements_per_line; j++ ) { Type_Widget widget = new Type_Widget(); - + switch( type ) { case( GL2.GL_UNSIGNED_BYTE_3_3_2 ): for( k = 0; k < 3; k++ ) { @@ -799,7 +799,7 @@ public class Image { assert( iter == rowsize * height + psm.getPackSkipRows() * rowsize + psm.getPackSkipPixels() * group_size ); } } - + public static void fillImage3D( PixelStorageModes psm, int width, int height, int depth, int format, int type, boolean indexFormat, ByteBuffer userImage, ShortBuffer newImage ) { @@ -819,7 +819,7 @@ public class Image { int ww, hh, dd, k; Type_Widget widget = new Type_Widget(); float extractComponents[] = new float[4]; - + // Create a Extract interface object Extract extract = null; switch( type ) { @@ -860,7 +860,7 @@ public class Image { extract = new Extract2101010rev(); break; } - + myswapBytes = psm.getUnpackSwapBytes(); components = Mipmap.elements_per_group( format, type ); if( psm.getUnpackRowLength() > 0 ) { @@ -873,7 +873,7 @@ public class Image { if( elementSize == 1 ) { myswapBytes = false; } - + // 3dstuff begin if( psm.getUnpackImageHeight() > 0 ) { rowsPerImage = psm.getUnpackImageHeight(); @@ -881,27 +881,27 @@ public class Image { rowsPerImage = height; } // 3dstuff end - + rowSize = groupsPerLine * groupSize; padding = rowSize % psm.getUnpackAlignment(); if( padding != 0 ) { rowSize += psm.getUnpackAlignment() - padding; } - + imageSize = rowsPerImage * rowSize; // 3dstuff - - start = psm.getUnpackSkipRows() * rowSize + - psm.getUnpackSkipPixels() * groupSize + + + start = psm.getUnpackSkipRows() * rowSize + + psm.getUnpackSkipPixels() * groupSize + psm.getUnpackSkipImages() * imageSize; elementsPerLine = width * components; - + iter2 = 0; for( dd = 0; dd < depth; dd++ ) { rowStart = start; for( hh = 0; hh < height; hh++ ) { iter = rowStart; for( ww = 0; ww < elementsPerLine; ww++ ) { - + switch( type ) { case( GL2.GL_UNSIGNED_BYTE ): if( indexFormat ) { @@ -1063,18 +1063,18 @@ public class Image { } // for hh start += imageSize; }// for dd - + // iterators should be one byte past end if( !Mipmap.isTypePackedPixel( type ) ) { assert( iter2 == width * height * depth * components ); } else { assert( iter2 == width * height * depth * Mipmap.elements_per_group( format, 0 ) ); } - assert( iter == rowSize * height * depth + psm.getUnpackSkipRows() * rowSize + + assert( iter == rowSize * height * depth + psm.getUnpackSkipRows() * rowSize + psm.getUnpackSkipPixels() * groupSize + psm.getUnpackSkipImages() * imageSize ); } - + public static void emptyImage3D( PixelStorageModes psm, int width, int height, int depth, int format, int type, boolean indexFormat, ShortBuffer oldImage, ByteBuffer userImage ) { boolean myswapBytes; @@ -1092,7 +1092,7 @@ public class Image { int imageSize; Type_Widget widget = new Type_Widget(); float[] shoveComponents = new float[4]; - + // Create a Extract interface object Extract extract = null; switch( type ) { @@ -1133,9 +1133,9 @@ public class Image { extract = new Extract2101010rev(); break; } - + iter = 0; - + myswapBytes = psm.getPackSwapBytes(); components = Mipmap.elements_per_group( format, type ); if( psm.getPackRowLength() > 0 ) { @@ -1143,44 +1143,44 @@ public class Image { } else { groupsPerLine = width; } - + elementSize = Mipmap.bytes_per_element( type ); groupSize = elementSize * components; if( elementSize == 1 ) { myswapBytes = false; } - + // 3dstuff begin if( psm.getPackImageHeight() > 0 ) { rowsPerImage = psm.getPackImageHeight(); } else { rowsPerImage = height; } - + // 3dstuff end - + rowSize = groupsPerLine * groupSize; padding = rowSize % psm.getPackAlignment(); if( padding != 0 ) { rowSize += psm.getPackAlignment() - padding; } - + imageSize = rowsPerImage * rowSize; - + start = psm.getPackSkipRows() * rowSize + psm.getPackSkipPixels() * groupSize + psm.getPackSkipImages() * imageSize; elementsPerLine = width * components; - + iter2 = 0; for( dd = 0; dd < depth; dd++ ) { rowStart = start; - + for( ii = 0; ii < height; ii++ ) { iter = rowStart; - + for( jj = 0; jj < elementsPerLine; jj++ ) { - + switch( type ) { case( GL2.GL_UNSIGNED_BYTE ): if( indexFormat ) { @@ -1392,20 +1392,20 @@ public class Image { default: assert( false ); } - + iter += elementSize; } // for jj rowStart += rowSize; } // for ii start += imageSize; } // for dd - + if( !Mipmap.isTypePackedPixel( type ) ) { assert( iter2 == width * height * depth * components ); } else { assert( iter2 == width * height * depth * Mipmap.elements_per_group( format, 0 ) ); } - assert( iter == rowSize * height * depth + + assert( iter == rowSize * height * depth + psm.getUnpackSkipRows() * rowSize + psm.getUnpackSkipPixels() * groupSize + psm.getUnpackSkipImages() * imageSize ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java index b74d0a6b8..938873ec5 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Mipmap.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -57,11 +57,11 @@ import com.jogamp.common.nio.Buffers; * @author Administrator */ public class Mipmap { - + /** Creates a new instance of Mipmap */ public Mipmap() { } - + public static int computeLog( int value ) { int i = 0; // Error @@ -79,7 +79,7 @@ public class Mipmap { i++; } } - + /* Compute the nearest power of 2 number. This algorithm is a little strange * but it works quite well. */ @@ -99,7 +99,7 @@ public class Mipmap { i *= 2; } } - + public static short GLU_SWAP_2_BYTES( short s ) { byte b = 0; b = (byte)( s >>> 8 ); @@ -107,7 +107,7 @@ public class Mipmap { s = (short)( s | (0x00FF & b) ); return( s ); } - + public static int GLU_SWAP_4_BYTES( int i ) { int t = i << 24; t |= 0x00FF0000 & ( i << 8 ); @@ -115,13 +115,13 @@ public class Mipmap { t |= 0x000000FF & ( i >>> 24 ); return( t ); } - + public static float GLU_SWAP_4_BYTES( float f ) { int i = Float.floatToRawIntBits( f ); float temp = Float.intBitsToFloat( i ); return( temp ); } - + public static int checkMipmapArgs( int internalFormat, int format, int type ) { if( !legalFormat( format ) || !legalType( type ) ) { return( GLU.GLU_INVALID_ENUM ); @@ -134,7 +134,7 @@ public class Mipmap { } return( 0 ); } - + public static boolean legalFormat( int format ) { switch( format ) { case( GL2.GL_COLOR_INDEX ): @@ -155,7 +155,7 @@ public class Mipmap { return( false ); } } - + public static boolean legalType( int type ) { switch( type ) { case( GL2.GL_BITMAP ): @@ -183,10 +183,10 @@ public class Mipmap { return( false ); } } - + public static boolean isTypePackedPixel( int type ) { assert( legalType( type ) ); - + if( type == GL2GL3.GL_UNSIGNED_BYTE_3_3_2 || type == GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV || type == GL2GL3.GL_UNSIGNED_SHORT_5_6_5 || @@ -203,20 +203,20 @@ public class Mipmap { } return( false ); } - + public static boolean isLegalFormatForPackedPixelType( int format, int type ) { // if not a packed pixel type then return true if( isTypePackedPixel( type ) ) { return( true ); } - + // 3_3_2/2_3_3_REV & 5_6_5/5_6_5_REV are only compatible with RGB if( (type == GL2GL3.GL_UNSIGNED_BYTE_3_3_2 || type == GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV || type == GL2GL3.GL_UNSIGNED_SHORT_5_6_5 || type == GL2GL3.GL_UNSIGNED_SHORT_5_6_5_REV ) & format != GL2GL3.GL_RGB ) { return( false ); } - + // 4_4_4_4/4_4_4_4_REV & 5_5_5_1/1_5_5_5_REV & 8_8_8_8/8_8_8_8_REV & // 10_10_10_2/2_10_10_10_REV are only campatible with RGBA, BGRA & ARGB_EXT if( ( type == GL2GL3.GL_UNSIGNED_SHORT_4_4_4_4 || @@ -232,7 +232,7 @@ public class Mipmap { } return( true ); } - + public static boolean isLegalLevels( int userLevel, int baseLevel, int maxLevel, int totalLevels ) { if( (baseLevel < 0) || (baseLevel < userLevel) || (maxLevel < baseLevel) || @@ -241,7 +241,7 @@ public class Mipmap { } return( true ); } - + /* Given user requested textures size, determine if it fits. If it doesn't then * halve both sides and make the determination again until it does fit ( for * IR only ). @@ -257,7 +257,7 @@ public class Mipmap { int heightPowerOf2 = nearestPower( height ); int[] proxyWidth = new int[1]; boolean noProxyTextures = false; - + // Some drivers (in particular, ATI's) seem to set a GL error // when proxy textures are used even though this is in violation // of the spec. Guard against this and interactions with the @@ -268,20 +268,20 @@ public class Mipmap { int widthAtLevelOne = ( ( width > 1 ) ? (widthPowerOf2 >> 1) : widthPowerOf2 ); int heightAtLevelOne = ( ( height > 1 ) ? (heightPowerOf2 >> 1) : heightPowerOf2 ); int proxyTarget; - + assert( widthAtLevelOne > 0 ); assert( heightAtLevelOne > 0 ); - + // does width x height at level 1 & all their mipmaps fit? if( target == GL2GL3.GL_TEXTURE_2D || target == GL2GL3.GL_PROXY_TEXTURE_2D ) { proxyTarget = GL2GL3.GL_PROXY_TEXTURE_2D; gl.glTexImage2D( proxyTarget, 1, internalFormat, widthAtLevelOne, heightAtLevelOne, 0, format, type, null ); - } else if( (target == GL2GL3.GL_TEXTURE_CUBE_MAP_POSITIVE_X) || - (target == GL2GL3.GL_TEXTURE_CUBE_MAP_NEGATIVE_X) || - (target == GL2GL3.GL_TEXTURE_CUBE_MAP_POSITIVE_Y) || - (target == GL2GL3.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y) || - (target == GL2GL3.GL_TEXTURE_CUBE_MAP_POSITIVE_Z) || + } else if( (target == GL2GL3.GL_TEXTURE_CUBE_MAP_POSITIVE_X) || + (target == GL2GL3.GL_TEXTURE_CUBE_MAP_NEGATIVE_X) || + (target == GL2GL3.GL_TEXTURE_CUBE_MAP_POSITIVE_Y) || + (target == GL2GL3.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y) || + (target == GL2GL3.GL_TEXTURE_CUBE_MAP_POSITIVE_Z) || (target == GL2GL3.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z) ) { proxyTarget = GL2GL3.GL_PROXY_TEXTURE_CUBE_MAP; gl.glTexImage2D( proxyTarget, 1, internalFormat, widthAtLevelOne, @@ -289,7 +289,7 @@ public class Mipmap { } else { assert( target == GL2GL3.GL_TEXTURE_1D || target == GL2GL3.GL_PROXY_TEXTURE_1D ); proxyTarget = GL2GL3.GL_PROXY_TEXTURE_1D; - gl.getGL2GL3().glTexImage1D( proxyTarget, 1, internalFormat, widthAtLevelOne, + gl.getGL2GL3().glTexImage1D( proxyTarget, 1, internalFormat, widthAtLevelOne, 0, format, type, null ); } if(gl.isGL2GL3()) { @@ -336,15 +336,15 @@ public class Mipmap { newHeight[0] = maxsize[0]; } } - - public static void closestFit3D( GL gl, int target, int width, int height, int depth, + + public static void closestFit3D( GL gl, int target, int width, int height, int depth, int internalFormat, int format, int type, int[] newWidth, int[] newHeight, int[] newDepth ) { int widthPowerOf2 = nearestPower( width ); int heightPowerOf2 = nearestPower( height ); int depthPowerOf2 = nearestPower( depth ); int[] proxyWidth = new int[1]; - + do { // compute level 1 width & height & depth, clamping each at 1 int widthAtLevelOne = (widthPowerOf2 > 1) ? widthPowerOf2 >> 1 : widthPowerOf2; @@ -354,7 +354,7 @@ public class Mipmap { assert( widthAtLevelOne > 0 ); assert( heightAtLevelOne > 0 ); assert( depthAtLevelOne > 0 ); - + // does width x height x depth at level 1 & all their mipmaps fit? if( target == GL2GL3.GL_TEXTURE_3D || target == GL2GL3.GL_PROXY_TEXTURE_3D ) { proxyTarget = GL2GL3.GL_PROXY_TEXTURE_3D; @@ -378,16 +378,16 @@ public class Mipmap { } } while( proxyWidth[0] == 0 ); // loop must terminate - + // return the width & height at level 0 that fits newWidth[0] = widthPowerOf2; newHeight[0] = heightPowerOf2; newDepth[0] = depthPowerOf2; } - + public static int elements_per_group( int format, int type ) { // Return the number of elements per grtoup of a specified gromat - + // If the type is packedpixels then answer is 1 if( type == GL2GL3.GL_UNSIGNED_BYTE_3_3_2 || type == GL2GL3.GL_UNSIGNED_BYTE_2_3_3_REV || @@ -403,7 +403,7 @@ public class Mipmap { type == GL2GL3.GL_UNSIGNED_INT_2_10_10_10_REV ) { return( 1 ); } - + // Types are not packed pixels so get elements per group switch( format ) { case( GL2GL3.GL_RGB ): @@ -418,10 +418,10 @@ public class Mipmap { return( 1 ); } } - + public static int bytes_per_element( int type ) { // return the number of bytes per element, based on the element type - + switch( type ) { case( GL2.GL_BITMAP ): case( GL2GL3.GL_BYTE ): @@ -450,17 +450,17 @@ public class Mipmap { return( 4 ); } } - + public static boolean is_index( int format ) { return( format == GL2.GL_COLOR_INDEX || format == GL2GL3.GL_STENCIL_INDEX ); } - + /* Compute memory required for internal packed array of data of given type and format. */ - + public static int image_size( int width, int height, int format, int type ) { int bytes_per_row; int components; - + assert( width > 0 ); assert( height > 0 ); components = elements_per_group( format, type ); @@ -471,17 +471,17 @@ public class Mipmap { } return( bytes_per_row * height * components ); } - + public static int imageSize3D( int width, int height, int depth, int format, int type ) { int components = elements_per_group( format, type ); int bytes_per_row = bytes_per_element( type ) * width; - + assert( width > 0 && height > 0 && depth > 0 ); assert( type != GL2.GL_BITMAP ); - + return( bytes_per_row * height * depth * components ); } - + public static void retrieveStoreModes( GL gl, PixelStorageModes psm ) { int[] a = new int[1]; gl.glGetIntegerv( GL2GL3.GL_UNPACK_ALIGNMENT, a, 0); @@ -496,7 +496,7 @@ public class Mipmap { psm.setUnpackLsbFirst( ( a[0] == 1 ) ); gl.glGetIntegerv( GL2GL3.GL_UNPACK_SWAP_BYTES, a, 0); psm.setUnpackSwapBytes( ( a[0] == 1 ) ); - + gl.glGetIntegerv( GL2GL3.GL_PACK_ALIGNMENT, a, 0); psm.setPackAlignment( a[0] ); gl.glGetIntegerv( GL2GL3.GL_PACK_ROW_LENGTH, a, 0); @@ -510,7 +510,7 @@ public class Mipmap { gl.glGetIntegerv( GL2GL3.GL_PACK_SWAP_BYTES, a, 0); psm.setPackSwapBytes( ( a[0] == 1 ) ); } - + public static void retrieveStoreModes3D( GL gl, PixelStorageModes psm ) { int[] a = new int[1]; gl.glGetIntegerv( GL2GL3.GL_UNPACK_ALIGNMENT, a, 0); @@ -529,7 +529,7 @@ public class Mipmap { psm.setUnpackSkipImages( a[0] ); gl.glGetIntegerv( GL2GL3.GL_UNPACK_IMAGE_HEIGHT, a, 0); psm.setUnpackImageHeight( a[0] ); - + gl.glGetIntegerv( GL2GL3.GL_PACK_ALIGNMENT, a, 0); psm.setPackAlignment( a[0] ); gl.glGetIntegerv( GL2GL3.GL_PACK_ROW_LENGTH, a, 0); @@ -547,9 +547,9 @@ public class Mipmap { gl.glGetIntegerv( GL2GL3.GL_PACK_IMAGE_HEIGHT, a, 0 ); psm.setPackImageHeight( a[0] ); } - - public static int gluScaleImage( GL gl, int format, int widthin, int heightin, - int typein, ByteBuffer datain, int widthout, int heightout, + + public static int gluScaleImage( GL gl, int format, int widthin, int heightin, + int typein, ByteBuffer datain, int widthout, int heightout, int typeout, ByteBuffer dataout ) { int datainPos = datain.position(); int dataoutPos = dataout.position(); @@ -559,7 +559,7 @@ public class Mipmap { ByteBuffer beforeimage; ByteBuffer afterimage; PixelStorageModes psm = new PixelStorageModes(); - + if( (widthin == 0) || (heightin == 0) || (widthout == 0) || (heightout == 0) ) { return( 0 ); } @@ -580,20 +580,20 @@ public class Mipmap { if( beforeimage == null || afterimage == null ) { return( GLU.GLU_OUT_OF_MEMORY ); } - + retrieveStoreModes( gl, psm ); Image.fill_image( psm, widthin, heightin, format, typein, is_index( format ), datain, beforeimage.asShortBuffer() ); components = elements_per_group( format, 0 ); ScaleInternal.scale_internal( components, widthin, heightin, beforeimage.asShortBuffer(), widthout, heightout, afterimage.asShortBuffer() ); Image.empty_image( psm, widthout, heightout, format, typeout, is_index( format ), afterimage.asShortBuffer(), dataout ); - + return( 0 ); } finally { datain.position(datainPos); dataout.position(dataoutPos); } } - + public static int gluBuild1DMipmapLevels( GL gl, int target, int internalFormat, int width, int format, int type, int userLevel, int baseLevel, int maxLevel, ByteBuffer data ) { @@ -601,30 +601,30 @@ public class Mipmap { try { int levels; - + int rc = checkMipmapArgs( internalFormat, format, type ); if( rc != 0 ) { return( rc ); } - + if( width < 1 ) { return( GLU.GLU_INVALID_VALUE ); } - + levels = computeLog( width ); - + levels += userLevel; if( !isLegalLevels( userLevel, baseLevel, maxLevel, levels ) ) { return( GLU.GLU_INVALID_VALUE ); } - + return( BuildMipmap.gluBuild1DMipmapLevelsCore( gl, target, internalFormat, width, width, format, type, userLevel, baseLevel, maxLevel, data ) ); } finally { data.position(dataPos); } } - + public static int gluBuild1DMipmaps( GL gl, int target, int internalFormat, int width, int format, int type, ByteBuffer data ) { int dataPos = data.position(); @@ -633,54 +633,54 @@ public class Mipmap { int[] widthPowerOf2 = new int[1]; int levels; int[] dummy = new int[1]; - + int rc = checkMipmapArgs( internalFormat, format, type ); if( rc != 0 ) { return( rc ); } - + if( width < 1 ) { return( GLU.GLU_INVALID_VALUE ); } - + closestFit( gl, target, width, 1, internalFormat, format, type, widthPowerOf2, dummy ); levels = computeLog( widthPowerOf2[0] ); - - return( BuildMipmap.gluBuild1DMipmapLevelsCore( gl, target, internalFormat, + + return( BuildMipmap.gluBuild1DMipmapLevelsCore( gl, target, internalFormat, width, widthPowerOf2[0], format, type, 0, 0, levels, data ) ); } finally { data.position(dataPos); } } - + public static int gluBuild2DMipmapLevels( GL gl, int target, int internalFormat, int width, int height, int format, int type, int userLevel, int baseLevel, int maxLevel, Object data ) { int dataPos = 0; int level, levels; - + int rc = checkMipmapArgs( internalFormat, format, type ); if( rc != 0 ) { return( rc ); } - + if( width < 1 || height < 1 ) { return( GLU.GLU_INVALID_VALUE ); } - + levels = computeLog( width ); level = computeLog( height ); if( level > levels ) { levels = level; } - + levels += userLevel; if( !isLegalLevels( userLevel, baseLevel, maxLevel, levels ) ) { return( GLU.GLU_INVALID_VALUE ); } - + //PointerWrapper pointer = PointerWrapperFactory.getPointerWrapper( data ); ByteBuffer buffer = null; if( data instanceof ByteBuffer ) { @@ -706,7 +706,7 @@ public class Mipmap { FloatBuffer fb = buffer.asFloatBuffer(); fb.put( array ); } - + try { return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat, width, height, width, height, format, type, userLevel, baseLevel, @@ -716,7 +716,7 @@ public class Mipmap { } } - + public static int gluBuild2DMipmaps( GL gl, int target, int internalFormat, int width, int height, int format, int type, Object data ) { int dataPos = 0; @@ -724,25 +724,25 @@ public class Mipmap { int[] widthPowerOf2 = new int[1]; int[] heightPowerOf2 = new int[1]; int level, levels; - + int rc = checkMipmapArgs( internalFormat, format, type ); if( rc != 0 ) { return( rc ); } - + if( width < 1 || height < 1 ) { return( GLU.GLU_INVALID_VALUE ); } - - closestFit( gl, target, width, height, internalFormat, format, type, + + closestFit( gl, target, width, height, internalFormat, format, type, widthPowerOf2, heightPowerOf2 ); - + levels = computeLog( widthPowerOf2[0] ); level = computeLog( heightPowerOf2[0] ); if( level > levels ) { levels = level; } - + //PointerWrapper pointer = PointerWrapperFactory.getPointerWrapper( data ); ByteBuffer buffer = null; if( data instanceof ByteBuffer ) { @@ -768,17 +768,17 @@ public class Mipmap { FloatBuffer fb = buffer.asFloatBuffer(); fb.put( array ); } - + try { - return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat, - width, height, widthPowerOf2[0], heightPowerOf2[0], format, type, 0, + return( BuildMipmap.gluBuild2DMipmapLevelsCore( gl, target, internalFormat, + width, height, widthPowerOf2[0], heightPowerOf2[0], format, type, 0, 0, levels, buffer ) ); } finally { buffer.position(dataPos); } } - - + + public static int gluBuild3DMipmaps( GL gl, int target, int internalFormat, int width, int height, int depth, int format, int type, ByteBuffer data ) { int dataPos = data.position(); @@ -788,23 +788,23 @@ public class Mipmap { int[] heightPowerOf2 = new int[1]; int[] depthPowerOf2 = new int[1]; int level, levels; - + int rc = checkMipmapArgs( internalFormat, format, type ); if( rc != 0 ) { return( rc ); } - + if( width < 1 || height < 1 || depth < 1 ) { return( GLU.GLU_INVALID_VALUE ); } - + if( type == GL2.GL_BITMAP ) { return( GLU.GLU_INVALID_ENUM ); } - + closestFit3D( gl, target, width, height, depth, internalFormat, format, type, widthPowerOf2, heightPowerOf2, depthPowerOf2 ); - + levels = computeLog( widthPowerOf2[0] ); level = computeLog( heightPowerOf2[0] ); if( level > levels ) { @@ -814,7 +814,7 @@ public class Mipmap { if( level > levels ) { levels = level; } - + return( BuildMipmap.gluBuild3DMipmapLevelsCore( gl, target, internalFormat, width, height, depth, widthPowerOf2[0], heightPowerOf2[0], depthPowerOf2[0], format, type, 0, 0, levels, data ) ); @@ -822,27 +822,27 @@ public class Mipmap { data.position(dataPos); } } - + public static int gluBuild3DMipmapLevels( GL gl, int target, int internalFormat, int width, int height, int depth, int format, int type, int userLevel, int baseLevel, int maxLevel, ByteBuffer data ) { int dataPos = data.position(); try { int level, levels; - + int rc = checkMipmapArgs( internalFormat, format, type ); if( rc != 0 ) { return( rc ); } - + if( width < 1 || height < 1 || depth < 1 ) { return( GLU.GLU_INVALID_VALUE ); } - + if( type == GL2.GL_BITMAP ) { return( GLU.GLU_INVALID_ENUM ); } - + levels = computeLog( width ); level = computeLog( height ); if( level > levels ) { @@ -852,12 +852,12 @@ public class Mipmap { if( level > levels ) { levels = level; } - + levels += userLevel; if( !isLegalLevels( userLevel, baseLevel, maxLevel, levels ) ) { return( GLU.GLU_INVALID_VALUE ); } - + return( BuildMipmap.gluBuild3DMipmapLevelsCore( gl, target, internalFormat, width, height, depth, width, height, depth, format, type, userLevel, baseLevel, maxLevel, data ) ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/PixelStorageModes.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/PixelStorageModes.java index 0b1af8323..7eb98db35 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/PixelStorageModes.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/PixelStorageModes.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -129,7 +129,7 @@ public class PixelStorageModes { * Holds value of property unpackImageHeight. */ private int unpackImageHeight; - + /** Creates a new instance of PixelStorageModes */ public PixelStorageModes() { } @@ -421,6 +421,6 @@ public class PixelStorageModes { this.unpackImageHeight = unpackImageHeight; } - - + + } diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java index 9c95ae304..9aca1fb03 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -55,9 +55,9 @@ import com.jogamp.common.nio.Buffers; * @author Administrator */ public class ScaleInternal { - + public static final float UINT_MAX = (float)(0x00000000FFFFFFFF); - + public static void scale_internal( int components, int widthin, int heightin, ShortBuffer datain, int widthout, int heightout, ShortBuffer dataout ) { float x, lowx, highx, convx, halfconvx; @@ -69,7 +69,7 @@ public class ScaleInternal { float area; int i, j, k, yint, xint, xindex, yindex; int temp; - + if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) { HalveImage.halveImage( components, widthin, heightin, datain, dataout ); return; @@ -101,7 +101,7 @@ public class ScaleInternal { // data. totals[0] = totals[1] = totals[2] = totals[3] = 0.0f; area = 0.0f; - + y = lowy; yint = (int)Math.floor( y ); while( y < highy ) { @@ -111,10 +111,10 @@ public class ScaleInternal { } else { ypercent = yint + 1 - y; } - + x = lowx; xint = (int)Math.floor( x ); - + while( x < highx ) { xindex = ( xint + widthin ) % widthin; if( highx < xint + 1 ) { @@ -122,21 +122,21 @@ public class ScaleInternal { } else { xpercent = xint + 1 - x; } - + percent = xpercent * ypercent; area += percent; temp = ( xindex + ( yindex * widthin) ) * components; for( k = 0; k < components; k++ ) { - totals[k] += datain.get( temp + k ) * percent; + totals[k] += datain.get( temp + k ) * percent; } - + xint++; x = xint; } yint++; y = yint; } - + temp = ( j + ( i * widthout ) ) * components; for( k = 0; k < components; k++ ) { // totals[] should be rounded in the case of enlarging an RGB @@ -146,9 +146,9 @@ public class ScaleInternal { } } } - + public static void scale_internal_ubyte( int components, int widthin, int heightin, - ByteBuffer datain, int widthout, int heightout, + ByteBuffer datain, int widthout, int heightout, ByteBuffer dataout, int element_size, int ysize, int group_size ) { float x, convx; float y, convy; @@ -157,11 +157,11 @@ public class ScaleInternal { float[] totals = new float[4]; float area; int i, j, k, xindex; - + int temp, temp0; int temp_index; int outindex; - + int lowx_int, highx_int, lowy_int, highy_int; float x_percent, y_percent; float lowx_float, highx_float, lowy_float, highy_float; @@ -169,9 +169,9 @@ public class ScaleInternal { int convy_int, convx_int; int l, m; int left, right; - + if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) { - HalveImage.halveImage_ubyte( components, widthin, heightin, datain, dataout, + HalveImage.halveImage_ubyte( components, widthin, heightin, datain, dataout, element_size, ysize, group_size ); return; } @@ -181,14 +181,14 @@ public class ScaleInternal { convy_float = convy - convy_int; convx_int = (int)Math.floor( convx ); convx_float = convx - convx_int; - + area = convx * convy; - + lowy_int = 0; lowy_float = 0.0f; highy_int = convy_int; highy_float = convy_float; - + for( i = 0; i < heightout; i++ ) { // Clamp here to be sure we don't read beyond input buffer. if (highy_int >= heightin) @@ -204,19 +204,19 @@ public class ScaleInternal { highx_int = convx_int; highx_float = convx_float; } - + for( j = 0; j < widthout; j++ ) { - + // Ok, now apply box filter to box that goes from (lowx, lowy) // to (highx, highy) on input data into this pixel on output // data. totals[0] = totals[1] = totals[2] = totals[3] = 0.0f; - + // caulate the value for pixels in the 1st row xindex = lowx_int * group_size; if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) { - + y_percent = 1 - lowy_float; temp = xindex + lowy_int * ysize; percent = y_percent * ( 1 - lowx_float ); @@ -239,7 +239,7 @@ public class ScaleInternal { datain.position( temp_index ); totals[k] += ( 0x000000FF & datain.get() ) * percent; } - + // calculate the value for pixels in the last row y_percent = highy_float; percent = y_percent * ( 1 - lowx_float ); @@ -261,7 +261,7 @@ public class ScaleInternal { datain.position( temp_index ); totals[k] += ( 0x000000FF & datain.get() ) * percent; } - + // calculate the value for the pixels in the 1st and last column for( m = lowy_int + 1; m < highy_int; m++ ) { left += ysize; @@ -339,7 +339,7 @@ public class ScaleInternal { } temp0 += ysize; } - + outindex = ( j + ( i * widthout ) ) * components; for( k = 0; k < components; k++ ) { dataout.position( outindex + k ); @@ -371,9 +371,9 @@ public class ScaleInternal { } } } - + public static void scale_internal_byte( int components, int widthin, int heightin, - ByteBuffer datain, int widthout, int heightout, + ByteBuffer datain, int widthout, int heightout, ByteBuffer dataout, int element_size, int ysize, int group_size ) { float x, convx; @@ -383,11 +383,11 @@ public class ScaleInternal { float[] totals = new float[4]; float area; int i, j, k, xindex; - + int temp, temp0; int temp_index; int outindex; - + int lowx_int, highx_int, lowy_int, highy_int; float x_percent, y_percent; float lowx_float, highx_float, lowy_float, highy_float; @@ -395,9 +395,9 @@ public class ScaleInternal { int convy_int, convx_int; int l, m; int left, right; - + if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) { - HalveImage.halveImage_byte( components, widthin, heightin, datain, dataout, + HalveImage.halveImage_byte( components, widthin, heightin, datain, dataout, element_size, ysize, group_size ); return; } @@ -407,14 +407,14 @@ public class ScaleInternal { convy_float = convy - convy_int; convx_int = (int)Math.floor( convx ); convx_float = convx - convx_int; - + area = convx * convy; - + lowy_int = 0; lowy_float = 0.0f; highy_int = convy_int; highy_float = convy_float; - + for( i = 0; i < heightout; i++ ) { // Clamp here to be sure we don't read beyond input buffer. if (highy_int >= heightin) @@ -430,18 +430,18 @@ public class ScaleInternal { highx_int = convx_int; highx_float = convx_float; } - + for( j = 0; j < widthout; j++ ) { - + // Ok, now apply box filter to box that goes from (lowx, lowy) // to (highx, highy) on input data into this pixel on output // data. totals[0] = totals[1] = totals[2] = totals[3] = 0.0f; - + // caulate the value for pixels in the 1st row xindex = lowx_int * group_size; if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) { - + y_percent = 1 - lowy_float; temp = xindex + lowy_int * ysize; percent = y_percent * ( 1 - lowx_float ); @@ -464,7 +464,7 @@ public class ScaleInternal { datain.position( temp_index ); totals[k] += datain.get() * percent; } - + // calculate the value for pixels in the last row y_percent = highy_float; percent = y_percent * ( 1 - lowx_float ); @@ -486,7 +486,7 @@ public class ScaleInternal { datain.position( temp_index ); totals[k] += datain.get() * percent; } - + // calculate the value for the pixels in the 1st and last column for( m = lowy_int + 1; m < highy_int; m++ ) { left += ysize; @@ -550,7 +550,7 @@ public class ScaleInternal { totals[k] += datain.get() * percent; } } - + // this is for the pixels in the body temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize; for( m = lowy_int + 1; m < highy_int; m++ ) { @@ -564,7 +564,7 @@ public class ScaleInternal { } temp0 += ysize; } - + outindex = ( j + ( i * widthout ) ) * components; for( k = 0; k < components; k++ ) { dataout.position( outindex + k ); @@ -596,10 +596,10 @@ public class ScaleInternal { } } } - + public static void scale_internal_ushort( int components, int widthin, int heightin, - ByteBuffer datain, int widthout, int heightout, - ShortBuffer dataout, int element_size, int ysize, + ByteBuffer datain, int widthout, int heightout, + ShortBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { float x, convx; float y, convy; @@ -608,11 +608,11 @@ public class ScaleInternal { float[] totals = new float[4]; float area; int i, j, k, xindex; - + int temp, temp0; int temp_index; int outindex; - + int lowx_int, highx_int, lowy_int, highy_int; float x_percent, y_percent; float lowx_float, highx_float, lowy_float, highy_float; @@ -620,9 +620,9 @@ public class ScaleInternal { int convy_int, convx_int; int l, m; int left, right; - + if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) { - HalveImage.halveImage_ushort( components, widthin, heightin, datain, dataout, + HalveImage.halveImage_ushort( components, widthin, heightin, datain, dataout, element_size, ysize, group_size, myswap_bytes ); return; } @@ -632,14 +632,14 @@ public class ScaleInternal { convy_float = convy - convy_int; convx_int = (int)Math.floor( convx ); convx_float = convx - convx_int; - + area = convx * convy; - + lowy_int = 0; lowy_float = 0.0f; highy_int = convy_int; highy_float = convy_float; - + for( i = 0; i < heightout; i++ ) { // Clamp here to be sure we don't read beyond input buffer. if (highy_int >= heightin) @@ -655,18 +655,18 @@ public class ScaleInternal { highx_int = convx_int; highx_float = convx_float; } - + for( j = 0; j < widthout; j++ ) { - + // Ok, now apply box filter to box that goes from (lowx, lowy) // to (highx, highy) on input data into this pixel on output // data. totals[0] = totals[1] = totals[2] = totals[3] = 0.0f; - + // caulate the value for pixels in the 1st row xindex = lowx_int * group_size; if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) { - + y_percent = 1 - lowy_float; temp = xindex + lowy_int * ysize; percent = y_percent * ( 1 - lowx_float ); @@ -701,7 +701,7 @@ public class ScaleInternal { totals[k] += ( 0x0000FFFF & datain.getShort()) * percent; } } - + // calculate the value for pixels in the last row y_percent = highy_float; percent = y_percent * ( 1 - lowx_float ); @@ -735,7 +735,7 @@ public class ScaleInternal { totals[k] += ( 0x0000FFFF & datain.getShort()) * percent; } } - + // calculate the value for the pixels in the 1st and last column for( m = lowy_int + 1; m < highy_int; m++ ) { left += ysize; @@ -834,7 +834,7 @@ public class ScaleInternal { } } } - + // this is for the pixels in the body temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize; for( m = lowy_int + 1; m < highy_int; m++ ) { @@ -852,7 +852,7 @@ public class ScaleInternal { } temp0 += ysize; } - + outindex = ( j + ( i * widthout ) ) * components; for( k = 0; k < components; k++ ) { dataout.position( outindex + k ); @@ -884,10 +884,10 @@ public class ScaleInternal { } } } - + public static void scale_internal_short( int components, int widthin, int heightin, ByteBuffer datain, int widthout, int heightout, - ShortBuffer dataout, int element_size, int ysize, + ShortBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { float x, convx; float y, convy; @@ -896,11 +896,11 @@ public class ScaleInternal { float[] totals = new float[4]; float area; int i, j, k, xindex; - + int temp, temp0; int temp_index; int outindex; - + int lowx_int, highx_int, lowy_int, highy_int; float x_percent, y_percent; float lowx_float, highx_float, lowy_float, highy_float; @@ -908,11 +908,11 @@ public class ScaleInternal { int convy_int, convx_int; int l, m; int left, right; - + int swapbuf; // unsigned buffer - + if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) { - HalveImage.halveImage_short( components, widthin, heightin, datain, dataout, + HalveImage.halveImage_short( components, widthin, heightin, datain, dataout, element_size, ysize, group_size, myswap_bytes ); return; } @@ -922,14 +922,14 @@ public class ScaleInternal { convy_float = convy - convy_int; convx_int = (int)Math.floor( convx ); convx_float = convx - convx_int; - + area = convx * convy; - + lowy_int = 0; lowy_float = 0.0f; highy_int = convy_int; highy_float = convy_float; - + for( i = 0; i < heightout; i++ ) { // Clamp here to be sure we don't read beyond input buffer. if (highy_int >= heightin) @@ -945,18 +945,18 @@ public class ScaleInternal { highx_int = convx_int; highx_float = convx_float; } - + for( j = 0; j < widthout; j++ ) { - + // Ok, now apply box filter to box that goes from (lowx, lowy) // to (highx, highy) on input data into this pixel on output // data. totals[0] = totals[1] = totals[2] = totals[3] = 0.0f; - + // caulate the value for pixels in the 1st row xindex = lowx_int * group_size; if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) { - + y_percent = 1 - lowy_float; temp = xindex + lowy_int * ysize; percent = y_percent * ( 1 - lowx_float ); @@ -994,7 +994,7 @@ public class ScaleInternal { totals[k] += datain.getShort() * percent; } } - + // calculate the value for pixels in the last row y_percent = highy_float; percent = y_percent * ( 1 - lowx_float ); @@ -1031,7 +1031,7 @@ public class ScaleInternal { totals[k] += datain.getShort() * percent; } } - + // calculate the value for the pixels in the 1st and last column for( m = lowy_int + 1; m < highy_int; m++ ) { left += ysize; @@ -1137,7 +1137,7 @@ public class ScaleInternal { } } } - + // this is for the pixels in the body temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize; for( m = lowy_int + 1; m < highy_int; m++ ) { @@ -1156,7 +1156,7 @@ public class ScaleInternal { } temp0 += ysize; } - + outindex = ( j + ( i * widthout ) ) * components; for( k = 0; k < components; k++ ) { dataout.position( outindex + k ); @@ -1188,10 +1188,10 @@ public class ScaleInternal { } } } - + public static void scale_internal_uint( int components, int widthin, int heightin, - ByteBuffer datain, int widthout, int heightout, - IntBuffer dataout, int element_size, int ysize, + ByteBuffer datain, int widthout, int heightout, + IntBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { float x, convx; float y, convy; @@ -1200,11 +1200,11 @@ public class ScaleInternal { float[] totals = new float[4]; float area; int i, j, k, xindex; - + int temp, temp0; int temp_index; int outindex; - + int lowx_int, highx_int, lowy_int, highy_int; float x_percent, y_percent; float lowx_float, highx_float, lowy_float, highy_float; @@ -1212,9 +1212,9 @@ public class ScaleInternal { int convy_int, convx_int; int l, m; int left, right; - + if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) { - HalveImage.halveImage_uint( components, widthin, heightin, datain, dataout, + HalveImage.halveImage_uint( components, widthin, heightin, datain, dataout, element_size, ysize, group_size, myswap_bytes ); return; } @@ -1224,14 +1224,14 @@ public class ScaleInternal { convy_float = convy - convy_int; convx_int = (int)Math.floor( convx ); convx_float = convx - convx_int; - + area = convx * convy; - + lowy_int = 0; lowy_float = 0.0f; highy_int = convy_int; highy_float = convy_float; - + for( i = 0; i < heightout; i++ ) { // Clamp here to be sure we don't read beyond input buffer. if (highy_int >= heightin) @@ -1247,18 +1247,18 @@ public class ScaleInternal { highx_int = convx_int; highx_float = convx_float; } - + for( j = 0; j < widthout; j++ ) { - + // Ok, now apply box filter to box that goes from (lowx, lowy) // to (highx, highy) on input data into this pixel on output // data. totals[0] = totals[1] = totals[2] = totals[3] = 0.0f; - + // caulate the value for pixels in the 1st row xindex = lowx_int * group_size; if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) { - + y_percent = 1 - lowy_float; temp = xindex + lowy_int * ysize; percent = y_percent * ( 1 - lowx_float ); @@ -1293,7 +1293,7 @@ public class ScaleInternal { totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent; } } - + // calculate the value for pixels in the last row y_percent = highy_float; percent = y_percent * ( 1 - lowx_float ); @@ -1327,7 +1327,7 @@ public class ScaleInternal { totals[k] += (0x00000000FFFFFFFF & datain.getInt()) * percent; } } - + // calculate the value for the pixels in the 1st and last column for( m = lowy_int + 1; m < highy_int; m++ ) { left += ysize; @@ -1427,7 +1427,7 @@ public class ScaleInternal { } } } - + // this is for the pixels in the body temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize; for( m = lowy_int + 1; m < highy_int; m++ ) { @@ -1445,7 +1445,7 @@ public class ScaleInternal { } temp0 += ysize; } - + outindex = ( j + ( i * widthout ) ) * components; float value = 0.0f; for( k = 0; k < components; k++ ) { @@ -1483,10 +1483,10 @@ public class ScaleInternal { } } } - + public static void scale_internal_int( int components, int widthin, int heightin, - ByteBuffer datain, int widthout, int heightout, - IntBuffer dataout, int element_size, int ysize, + ByteBuffer datain, int widthout, int heightout, + IntBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { float x, convx; float y, convy; @@ -1495,11 +1495,11 @@ public class ScaleInternal { float[] totals = new float[4]; float area; int i, j, k, xindex; - + int temp, temp0; int temp_index; int outindex; - + int lowx_int, highx_int, lowy_int, highy_int; float x_percent, y_percent; float lowx_float, highx_float, lowy_float, highy_float; @@ -1507,11 +1507,11 @@ public class ScaleInternal { int convy_int, convx_int; int l, m; int left, right; - + long swapbuf; // unsigned buffer - + if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) { - HalveImage.halveImage_int( components, widthin, heightin, datain, dataout, + HalveImage.halveImage_int( components, widthin, heightin, datain, dataout, element_size, ysize, group_size, myswap_bytes ); return; } @@ -1521,14 +1521,14 @@ public class ScaleInternal { convy_float = convy - convy_int; convx_int = (int)Math.floor( convx ); convx_float = convx - convx_int; - + area = convx * convy; - + lowy_int = 0; lowy_float = 0.0f; highy_int = convy_int; highy_float = convy_float; - + for( i = 0; i < heightout; i++ ) { // Clamp here to be sure we don't read beyond input buffer. if (highy_int >= heightin) @@ -1544,18 +1544,18 @@ public class ScaleInternal { highx_int = convx_int; highx_float = convx_float; } - + for( j = 0; j < widthout; j++ ) { - + // Ok, now apply box filter to box that goes from (lowx, lowy) // to (highx, highy) on input data into this pixel on output // data. totals[0] = totals[1] = totals[2] = totals[3] = 0.0f; - + // caulate the value for pixels in the 1st row xindex = lowx_int * group_size; if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) { - + y_percent = 1 - lowy_float; temp = xindex + lowy_int * ysize; percent = y_percent * ( 1 - lowx_float ); @@ -1593,7 +1593,7 @@ public class ScaleInternal { totals[k] += datain.getInt() * percent; } } - + // calculate the value for pixels in the last row y_percent = highy_float; percent = y_percent * ( 1 - lowx_float ); @@ -1630,7 +1630,7 @@ public class ScaleInternal { totals[k] += datain.getInt() * percent; } } - + // calculate the value for the pixels in the 1st and last column for( m = lowy_int + 1; m < highy_int; m++ ) { left += ysize; @@ -1736,7 +1736,7 @@ public class ScaleInternal { } } } - + // this is for the pixels in the body temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize; for( m = lowy_int + 1; m < highy_int; m++ ) { @@ -1755,7 +1755,7 @@ public class ScaleInternal { } temp0 += ysize; } - + outindex = ( j + ( i * widthout ) ) * components; for( k = 0; k < components; k++ ) { dataout.position( outindex + k ); @@ -1787,10 +1787,10 @@ public class ScaleInternal { } } } - + public static void scale_internal_float( int components, int widthin, int heightin, - ByteBuffer datain, int widthout, int heightout, - FloatBuffer dataout, int element_size, int ysize, + ByteBuffer datain, int widthout, int heightout, + FloatBuffer dataout, int element_size, int ysize, int group_size, boolean myswap_bytes ) { float x, convx; float y, convy; @@ -1799,11 +1799,11 @@ public class ScaleInternal { float[] totals = new float[4]; float area; int i, j, k, xindex; - + int temp, temp0; int temp_index; int outindex; - + int lowx_int, highx_int, lowy_int, highy_int; float x_percent, y_percent; float lowx_float, highx_float, lowy_float, highy_float; @@ -1811,11 +1811,11 @@ public class ScaleInternal { int convy_int, convx_int; int l, m; int left, right; - + float swapbuf; // unsigned buffer - + if( (widthin == (widthout * 2)) && (heightin == (heightout * 2)) ) { - HalveImage.halveImage_float( components, widthin, heightin, datain, dataout, + HalveImage.halveImage_float( components, widthin, heightin, datain, dataout, element_size, ysize, group_size, myswap_bytes ); return; } @@ -1825,14 +1825,14 @@ public class ScaleInternal { convy_float = convy - convy_int; convx_int = (int)Math.floor( convx ); convx_float = convx - convx_int; - + area = convx * convy; - + lowy_int = 0; lowy_float = 0.0f; highy_int = convy_int; highy_float = convy_float; - + for( i = 0; i < heightout; i++ ) { // Clamp here to be sure we don't read beyond input buffer. if (highy_int >= heightin) @@ -1848,18 +1848,18 @@ public class ScaleInternal { highx_int = convx_int; highx_float = convx_float; } - + for( j = 0; j < widthout; j++ ) { - + // Ok, now apply box filter to box that goes from (lowx, lowy) // to (highx, highy) on input data into this pixel on output // data. totals[0] = totals[1] = totals[2] = totals[3] = 0.0f; - + // caulate the value for pixels in the 1st row xindex = lowx_int * group_size; if( ( highy_int > lowy_int ) && ( highx_int > lowx_int ) ) { - + y_percent = 1 - lowy_float; temp = xindex + lowy_int * ysize; percent = y_percent * ( 1 - lowx_float ); @@ -1897,7 +1897,7 @@ public class ScaleInternal { totals[k] += datain.getFloat() * percent; } } - + // calculate the value for pixels in the last row y_percent = highy_float; percent = y_percent * ( 1 - lowx_float ); @@ -1934,7 +1934,7 @@ public class ScaleInternal { totals[k] += datain.getFloat() * percent; } } - + // calculate the value for the pixels in the 1st and last column for( m = lowy_int + 1; m < highy_int; m++ ) { left += ysize; @@ -2040,7 +2040,7 @@ public class ScaleInternal { } } } - + // this is for the pixels in the body temp0 = xindex + group_size + ( lowy_int + 1 ) * ysize; for( m = lowy_int + 1; m < highy_int; m++ ) { @@ -2059,7 +2059,7 @@ public class ScaleInternal { } temp0 += ysize; } - + outindex = ( j + ( i * widthout ) ) * components; for( k = 0; k < components; k++ ) { dataout.position( outindex + k ); @@ -2091,28 +2091,28 @@ public class ScaleInternal { } } } - - public static void scaleInternalPackedPixel( int components, Extract extract, + + public static void scaleInternalPackedPixel( int components, Extract extract, int widthIn, int heightIn, ByteBuffer dataIn, int widthOut, int heightOut, ByteBuffer dataOut, int pixelSizeInBytes, int rowSizeInBytes, boolean isSwap ) { float x, convx; float y, convy; float percent; - + // max components in a format is 4, so float[] totals = new float[4]; float[] extractTotals = new float[4]; float[] extractMoreTotals = new float[4]; float[] shoveTotals = new float[4]; - + float area; int i, j, k, xindex; - + int temp, temp0; int temp_index; int outIndex = 0; - + int lowx_int, highx_int, lowy_int, highy_int; float x_percent, y_percent; float lowx_float, highx_float, lowy_float, highy_float; @@ -2120,7 +2120,7 @@ public class ScaleInternal { int convy_int, convx_int; int l, m; int left, right; - + if( widthIn == widthOut * 2 && heightIn == heightOut * 2 ) { HalveImage.halveImagePackedPixel( components, extract, widthIn, heightIn, dataIn, dataOut, pixelSizeInBytes, rowSizeInBytes, isSwap ); @@ -2132,14 +2132,14 @@ public class ScaleInternal { convy_float = convy - convy_int; convx_int = (int)Math.floor( convx ); convx_float = convx - convx_int; - + area = convx * convy; - + lowy_int = 0; lowy_float = 0.0f; highy_int = convy_int; highy_float = convx_float; - + for( i = 0; i < heightOut; i++ ) { // Clamp here to be sure we don't read beyond input buffer. if (highy_int >= heightIn) @@ -2148,16 +2148,16 @@ public class ScaleInternal { lowx_float = 0.0f; highx_int = convx_int; highx_float = convx_float; - + for( j = 0; j < widthOut; j++ ) { // ok now apply box filter to box that goes from( lowx, lowy ) // to ( highx, highy ) on input data into this pixel on output data totals[0] = totals[1] = totals[2] = totals[3] = 0.0f; - + // calculate that value for pixels in the 1st row xindex = lowx_int * pixelSizeInBytes; if( (highy_int > lowy_int) && (highx_int > lowx_int) ) { - + y_percent = 1 - lowy_float; temp = xindex + lowy_int * rowSizeInBytes; percent = y_percent * ( 1 - lowx_float ); @@ -2184,7 +2184,7 @@ public class ScaleInternal { totals[k] += extractTotals[k] * percent; } // calculate the value for pixels in the last row - + y_percent = highy_float; percent = y_percent * ( 1 - lowx_float ); temp = xindex + highy_int * rowSizeInBytes; @@ -2207,7 +2207,7 @@ public class ScaleInternal { for( k = 0; k < components; k++ ) { totals[k] += extractTotals[k] * percent; } - + // calculate the value for pixels in the 1st and last column for( m = lowy_int + 1; m < highy_int; m++ ) { left += rowSizeInBytes; @@ -2277,7 +2277,7 @@ public class ScaleInternal { totals[k] += extractTotals[k] * percent; } } - + // this is for the pixels in the body temp0 = xindex + pixelSizeInBytes + ( lowy_int + 1 ) * rowSizeInBytes; for( m = lowy_int + 1; m < highy_int; m++ ) { @@ -2292,7 +2292,7 @@ public class ScaleInternal { } temp0 += rowSizeInBytes; } - + outIndex = ( j + ( i * widthOut ) ); for( k = 0; k < components; k++ ) { shoveTotals[k] = totals[k] / area; @@ -2325,7 +2325,7 @@ public class ScaleInternal { } assert( outIndex == ( widthOut * heightOut - 1) ); } - + public static void scaleInternal3D( int components, int widthIn, int heightIn, int depthIn, ShortBuffer dataIn, int widthOut, int heightOut, int depthOut, ShortBuffer dataOut ) { @@ -2339,9 +2339,9 @@ public class ScaleInternal { float volume; int i, j, d, k, zint, yint, xint, xindex, yindex, zindex; int temp; - + lowy = highy = lowx = highx = 0.0f; - + convz = (float)depthIn / depthOut; convy = (float)heightIn / heightOut; convx = (float)widthIn / widthOut; @@ -2375,13 +2375,13 @@ public class ScaleInternal { highz = x + 0.5f; lowz = x - 0.5f; } - + // Ok, now apply box filter to box that goes from ( lowx, lowy, lowz ) // to ( highx, highy, highz ) on input data into this pixel on output data - + totals[0] = totals[1] = totals[2] = totals[3] = 0.0f; volume = 0.0f; - + z = lowz; zint = (int)(Math.floor( z ) ); while( z < highz ) { @@ -2391,7 +2391,7 @@ public class ScaleInternal { } else { zpercent = zint + 1 - z; } - + y = lowy; yint = (int)(Math.floor( y ) ); while( y < highy ) { @@ -2401,10 +2401,10 @@ public class ScaleInternal { } else { ypercent = yint + 1 - y; } - + x = lowx; xint = (int)(Math.floor( x ) ); - + while( x < highx ) { xindex = (xint + widthIn ) % widthIn; if( highx < xint + 1 ) { @@ -2412,10 +2412,10 @@ public class ScaleInternal { } else { xpercent = xint + 1 - x; } - + percent = xpercent * ypercent * zpercent; volume += percent; - + temp = (xindex + ( yindex *widthIn) + (zindex * widthIn *heightIn)) * components; for( k = 0; k < components; k++ ) { assert( 0 <= (temp+k) && (temp+k) < (widthIn * heightIn * depthIn * components) ); @@ -2430,7 +2430,7 @@ public class ScaleInternal { zint++; z = zint; } // while z - + temp = ( j + ( i * widthOut ) + (d * widthOut * heightOut ) ) * components; for( k = 0; k < components; k++ ) { // totals should be rounded in the case of enlarging an rgb ramp when the type is 332 or 4444 @@ -2441,48 +2441,48 @@ public class ScaleInternal { } } } - - public static int gluScaleImage3D( GL gl, int format, int widthIn, int heightIn, - int depthIn, int typeIn, ByteBuffer dataIn, int widthOut, int heightOut, + + public static int gluScaleImage3D( GL gl, int format, int widthIn, int heightIn, + int depthIn, int typeIn, ByteBuffer dataIn, int widthOut, int heightOut, int depthOut, int typeOut, ByteBuffer dataOut ) { int components; ShortBuffer beforeImage, afterImage; PixelStorageModes psm = new PixelStorageModes(); - + if( widthIn == 0 || heightIn == 0 || depthIn == 0 || widthOut == 0 || heightOut == 0 || depthOut == 0 ) { return( 0 ); } - + if( widthIn < 0 || heightIn < 0 || depthIn < 0 || widthOut < 0 || heightOut < 0 || depthOut < 0 ) { return( GLU.GLU_INVALID_VALUE ); } - - if( !Mipmap.legalFormat(format) || !Mipmap.legalType(typeIn) || + + if( !Mipmap.legalFormat(format) || !Mipmap.legalType(typeIn) || !Mipmap.legalType(typeOut) || typeIn == GL2.GL_BITMAP || typeOut == GL2.GL_BITMAP ) { return( GLU.GLU_INVALID_ENUM ); } - + if( !Mipmap.isLegalFormatForPackedPixelType( format, typeIn ) ) { return( GLU.GLU_INVALID_OPERATION ); } - + if( !Mipmap.isLegalFormatForPackedPixelType( format, typeOut ) ) { return( GLU.GLU_INVALID_OPERATION ); } - + try { - beforeImage = Buffers.newDirectByteBuffer( Mipmap.imageSize3D( widthIn, + beforeImage = Buffers.newDirectByteBuffer( Mipmap.imageSize3D( widthIn, heightIn, depthIn, format, GL2.GL_UNSIGNED_SHORT ) ).asShortBuffer(); - afterImage = Buffers.newDirectByteBuffer( Mipmap.imageSize3D( widthIn, + afterImage = Buffers.newDirectByteBuffer( Mipmap.imageSize3D( widthIn, heightIn, depthIn, format, GL2.GL_UNSIGNED_SHORT ) ).asShortBuffer(); } catch( OutOfMemoryError err ) { return( GLU.GLU_OUT_OF_MEMORY ); } Mipmap.retrieveStoreModes3D( gl, psm ); - + Image.fillImage3D( psm, widthIn, heightIn, depthIn, format, typeIn, Mipmap.is_index( format ), dataIn, beforeImage ); components = Mipmap.elements_per_group( format, 0 ); @@ -2490,7 +2490,7 @@ public class ScaleInternal { beforeImage, widthOut, heightOut, depthOut, afterImage ); Image.emptyImage3D( psm, widthOut, heightOut, depthOut, format, typeOut, Mipmap.is_index( format ), afterImage, dataOut ); - + return( 0 ); } } diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Type_Widget.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Type_Widget.java index 38113f601..dc401880d 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Type_Widget.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Type_Widget.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,176 +51,176 @@ import java.nio.*; * @author Administrator */ public class Type_Widget { - + ByteBuffer buffer; - + /** Creates a new instance of Type_Widget */ public Type_Widget() { // can't make this direct, because JVM doesn't allocate small direct buffers efficiently // see https://jogamp.org/bugzilla/show_bug.cgi?id=463 for details buffer = ByteBuffer.allocate( 4 ); } - + public void setUB0( byte b ) { buffer.position( 0 ); buffer.put( b ); } - + public byte getUB0() { buffer.position( 0 ); return( buffer.get() ); } - + public void setUB1( byte b ) { buffer.position( 1 ); buffer.put( b ); } - + public byte getUB1() { buffer.position( 1 ); return( buffer.get() ); } - + public void setUB2( byte b ) { buffer.position( 2 ); buffer.put( b ); } - + public byte getUB2() { buffer.position( 2 ); return( buffer.get() ); } - + public void setUB3( byte b ) { buffer.position( 3 ); buffer.put( b ); } - + public byte getUB3() { buffer.position( 3 ); return( buffer.get() ); } - + public void setUS0( short s ) { buffer.position( 0 ); buffer.putShort( s ); } - + public short getUS0() { buffer.position( 0 ); return( buffer.getShort() ); } - + public void setUS1( short s ) { buffer.position( 2 ); buffer.putShort( s ); } - + public short getUS1() { buffer.position( 2 ); return( buffer.getShort() ); } - + public void setUI( int i ) { buffer.position( 0 ); buffer.putInt( i ); } - + public int getUI() { buffer.position( 0 ); return( buffer.getInt() ); } - + public void setB0( byte b ) { buffer.position( 0 ); buffer.put( b ); } - + public byte getB0() { buffer.position( 0 ); return( buffer.get() ); } - + public void setB1( byte b ) { buffer.position( 1 ); buffer.put( b ); } - + public byte getB1() { buffer.position( 1 ); return( buffer.get() ); } - + public void setB2( byte b ) { buffer.position( 2 ); buffer.put( b ); } - + public byte getB2() { buffer.position( 2 ); return( buffer.get() ); } - + public void setB3( byte b ) { buffer.position( 3 ); buffer.put( b ); } - + public byte getB3() { buffer.position( 3 ); return( buffer.get() ); } - + public void setS0( short s ) { buffer.position( 0 ); buffer.putShort( s ); } - + public short getS0() { buffer.position( 0 ); return( buffer.getShort() ); } - + public void setS1( short s ) { buffer.position( 2 ); buffer.putShort( s ); } - + public short getS1() { buffer.position( 2 ); return( buffer.getShort() ); } - + public void setI( int i ) { buffer.position( 0 ); buffer.putInt( i ); } - + public int getI() { buffer.position( 0 ); return( buffer.getInt() ); } - + public void setF( float f ) { buffer.position( 0 ); buffer.putFloat( f ); } - + public float getF() { buffer.position( 0 ); return( buffer.getFloat() ); } - + public ByteBuffer getBuffer() { buffer.rewind(); return( buffer ); } - + public static void main( String args[] ) { Type_Widget t = new Type_Widget(); t.setI( 1000000 ); - + System.out.println("int: " + Integer.toHexString( t.getI() ) ); - + } } diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Arc.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Arc.java index 422f8d4df..df2b9a147 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Arc.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Arc.java @@ -72,7 +72,7 @@ public class Arc { /** * Makes new arc at specified side - * + * * @param side * which side doeas this arc form */ @@ -86,7 +86,7 @@ public class Arc { /** * Sets side the arc is at - * + * * @param side * arc side */ @@ -104,7 +104,7 @@ public class Arc { type &= ~(0x7 << 8); } - // this one replaces enum arc_side + // this one replaces enum arc_side /** * Side not specified */ @@ -147,7 +147,7 @@ public class Arc { /** * Appends arc to the list - * + * * @param jarc * arc to be append * @return this @@ -169,7 +169,7 @@ public class Arc { /** * Unused - * + * * @return true */ public boolean check() { @@ -187,7 +187,7 @@ public class Arc { /** * Returns tail of linked list coords - * + * * @return tail coords */ public float[] tail() { @@ -197,7 +197,7 @@ public class Arc { /** * Returns head of linked list coords - * + * * @return head coords */ public float[] head() { @@ -207,7 +207,7 @@ public class Arc { /** * Returns whether arc is marked with arc_tag - * + * * @return is arc marked with arc_tag */ public boolean ismarked() { @@ -241,7 +241,7 @@ public class Arc { /** * Returns whether arc is marked tail - * + * * @return is tail */ public boolean getitail() { diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/ArcSdirSorter.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/ArcSdirSorter.java index f4ad70193..c299b10af 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/ArcSdirSorter.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/ArcSdirSorter.java @@ -44,7 +44,7 @@ public class ArcSdirSorter { /** * Makes new ArcSdirSorter with Subdivider * @param subdivider subdivider - */ + */ public ArcSdirSorter(Subdivider subdivider) { //TODO // System.out.println("TODO arcsdirsorter.constructor"); diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/ArcTdirSorter.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/ArcTdirSorter.java index be72c53d2..1a584c396 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/ArcTdirSorter.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/ArcTdirSorter.java @@ -43,7 +43,7 @@ public class ArcTdirSorter { /** * Makes new ArcSdirSorter with Subdivider * @param subdivider subdivider - */ + */ public ArcTdirSorter(Subdivider subdivider) { // TODO Auto-generated constructor stub // System.out.println("TODO arcTsorter.konstruktor"); diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Backend.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Backend.java index 610a19556..3e974247b 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Backend.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Backend.java @@ -67,7 +67,7 @@ public abstract class Backend { protected SurfaceEvaluator surfaceEvaluator; /** - * Makes new backend + * Makes new backend */ public Backend() { // curveEvaluator = new OpenGLCurveEvaluator(); diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Bin.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Bin.java index df8b16ab5..17437ef01 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Bin.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Bin.java @@ -143,7 +143,7 @@ public class Bin { /** * Returns next arc in linked list * @return next arc - * + * */ private Arc nextarc() { // DONE diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Breakpt.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Breakpt.java index f45571dac..f84640d28 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Breakpt.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Breakpt.java @@ -36,9 +36,9 @@ package jogamp.opengl.glu.nurbs; /** * Class holding break point parameters - * + * * @author Tomas Hrasky - * + * */ public class Breakpt { diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfArcs.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfArcs.java index aaa8cb5f2..b67764c30 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfArcs.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfArcs.java @@ -2,9 +2,9 @@ package jogamp.opengl.glu.nurbs; /** * Class replacing C language pointer - * + * * @author Tomas Hrasky - * + * */ public class CArrayOfArcs { /** @@ -24,7 +24,7 @@ public class CArrayOfArcs { /** * Makes new CArray - * + * * @param array * underlaying array * @param pointer @@ -38,7 +38,7 @@ public class CArrayOfArcs { /** * Makes new CArray from other CArray - * + * * @param carray * reference array */ @@ -50,7 +50,7 @@ public class CArrayOfArcs { /** * Makes new CArray with pointer set to 0 - * + * * @param ctlarray * underlaying array */ @@ -61,7 +61,7 @@ public class CArrayOfArcs { /** * Returns element at pointer - * + * * @return element at pointer */ public Arc get() { @@ -78,7 +78,7 @@ public class CArrayOfArcs { /** * Sets element at pointer - * + * * @param f * desired value */ @@ -89,7 +89,7 @@ public class CArrayOfArcs { /** * Returns array element at specified index - * + * * @param i * array index * @return element at index @@ -100,7 +100,7 @@ public class CArrayOfArcs { /** * Returns array element at specified index relatively to pointer - * + * * @param i * relative index * @return element at relative index @@ -111,7 +111,7 @@ public class CArrayOfArcs { /** * Sets value of element at specified index relatively to pointer - * + * * @param i * relative index * @param value @@ -123,7 +123,7 @@ public class CArrayOfArcs { /** * Lessens pointer by value - * + * * @param i * lessen by */ @@ -134,7 +134,7 @@ public class CArrayOfArcs { /** * Returns pointer value - * + * * @return pointer value */ public int getPointer() { @@ -143,7 +143,7 @@ public class CArrayOfArcs { /** * Sets ponter value - * + * * @param pointer * pointer value to be set */ @@ -156,7 +156,7 @@ public class CArrayOfArcs { /** * Raises pointer by value - * + * * @param i * raise by */ @@ -175,7 +175,7 @@ public class CArrayOfArcs { /** * Returns underlaying array - * + * * @return underlaying array */ public Arc[] getArray() { @@ -184,7 +184,7 @@ public class CArrayOfArcs { /** * Sets underlaying array - * + * * @param array * underlaying array */ diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfBreakpts.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfBreakpts.java index 5112b07fc..b5f588960 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfBreakpts.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfBreakpts.java @@ -2,9 +2,9 @@ package jogamp.opengl.glu.nurbs; /** * Class replacing C language pointer - * + * * @author Tomas Hrasky - * + * */ public class CArrayOfBreakpts { /** @@ -19,7 +19,7 @@ public class CArrayOfBreakpts { /** * Makes new CArray - * + * * @param array * underlaying array * @param pointer @@ -32,7 +32,7 @@ public class CArrayOfBreakpts { /** * Makes new CArray from other CArray - * + * * @param carray * reference array */ @@ -43,7 +43,7 @@ public class CArrayOfBreakpts { /** * Returns element at pointer - * + * * @return element at pointer */ public Breakpt get() { @@ -59,7 +59,7 @@ public class CArrayOfBreakpts { /** * Sets element at pointer - * + * * @param f * desired value */ @@ -70,7 +70,7 @@ public class CArrayOfBreakpts { /** * Returns array element at specified index - * + * * @param i * array index * @return element at index @@ -81,7 +81,7 @@ public class CArrayOfBreakpts { /** * Lessens pointer by value - * + * * @param i * lessen by */ @@ -92,7 +92,7 @@ public class CArrayOfBreakpts { /** * Returns pointer value - * + * * @return pointer value */ public int getPointer() { @@ -101,7 +101,7 @@ public class CArrayOfBreakpts { /** * Sets ponter value - * + * * @param pointer * pointer value to be set */ @@ -111,7 +111,7 @@ public class CArrayOfBreakpts { /** * Raises pointer by value - * + * * @param i * raise by */ diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfFloats.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfFloats.java index 39ef841ec..d9e4d0ff1 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfFloats.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfFloats.java @@ -2,9 +2,9 @@ package jogamp.opengl.glu.nurbs; /** * Class replacing C language pointer - * + * * @author Tomas Hrasky - * + * */ public class CArrayOfFloats { @@ -25,7 +25,7 @@ public class CArrayOfFloats { /** * Makes new CArray - * + * * @param array * underlaying array * @param pointer @@ -39,7 +39,7 @@ public class CArrayOfFloats { /** * Makes new CArray from other CArray - * + * * @param carray * reference array */ @@ -51,7 +51,7 @@ public class CArrayOfFloats { /** * Makes new CArray with pointer set to 0 - * + * * @param ctlarray * underlaying array */ @@ -62,7 +62,7 @@ public class CArrayOfFloats { /** * Returns element at pointer - * + * * @return element at pointer */ public float get() { @@ -79,7 +79,7 @@ public class CArrayOfFloats { /** * Sets element at pointer - * + * * @param f * desired value */ @@ -90,7 +90,7 @@ public class CArrayOfFloats { /** * Returns array element at specified index - * + * * @param i * array index * @return element at index @@ -101,7 +101,7 @@ public class CArrayOfFloats { /** * Returns array element at specified index relatively to pointer - * + * * @param i * relative index * @return element at relative index @@ -112,7 +112,7 @@ public class CArrayOfFloats { /** * Sets value of element at specified index relatively to pointer - * + * * @param i * relative index * @param value @@ -124,7 +124,7 @@ public class CArrayOfFloats { /** * Lessens pointer by value - * + * * @param i * lessen by */ @@ -135,7 +135,7 @@ public class CArrayOfFloats { /** * Returns pointer value - * + * * @return pointer value */ public int getPointer() { @@ -144,7 +144,7 @@ public class CArrayOfFloats { /** * Sets ponter value - * + * * @param pointer * pointer value to be set */ @@ -157,7 +157,7 @@ public class CArrayOfFloats { /** * Raises pointer by value - * + * * @param i * raise by */ @@ -176,7 +176,7 @@ public class CArrayOfFloats { /** * Returns underlaying array - * + * * @return underlaying array */ public float[] getArray() { @@ -185,7 +185,7 @@ public class CArrayOfFloats { /** * Sets underlaying array - * + * * @param array * underlaying array */ diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfQuiltspecs.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfQuiltspecs.java index 4b21f2d50..e7bbac16a 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfQuiltspecs.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/CArrayOfQuiltspecs.java @@ -2,9 +2,9 @@ package jogamp.opengl.glu.nurbs; /** * Class replacing C language pointer - * + * * @author Tomas Hrasky - * + * */ public class CArrayOfQuiltspecs { /** @@ -19,7 +19,7 @@ public class CArrayOfQuiltspecs { /** * Makes new CArray - * + * * @param array * underlaying array * @param pointer @@ -32,7 +32,7 @@ public class CArrayOfQuiltspecs { /** * Makes new CArray from other CArray - * + * * @param carray * reference array */ @@ -43,7 +43,7 @@ public class CArrayOfQuiltspecs { /** * Makes new CArray with pointer set to 0 - * + * * @param array * underlaying array */ @@ -54,7 +54,7 @@ public class CArrayOfQuiltspecs { /** * Returns element at pointer - * + * * @return element at pointer */ public Quiltspec get() { @@ -70,7 +70,7 @@ public class CArrayOfQuiltspecs { /** * Sets element at pointer - * + * * @param f * desired value */ @@ -81,7 +81,7 @@ public class CArrayOfQuiltspecs { /** * Returns array element at specified index - * + * * @param i * array index * @return element at index @@ -92,7 +92,7 @@ public class CArrayOfQuiltspecs { /** * Lessens pointer by value - * + * * @param i * lessen by */ @@ -103,7 +103,7 @@ public class CArrayOfQuiltspecs { /** * Returns pointer value - * + * * @return pointer value */ public int getPointer() { @@ -112,7 +112,7 @@ public class CArrayOfQuiltspecs { /** * Sets ponter value - * + * * @param pointer * pointer value to be set */ @@ -122,7 +122,7 @@ public class CArrayOfQuiltspecs { /** * Raises pointer by value - * + * * @param i * raise by */ @@ -141,7 +141,7 @@ public class CArrayOfQuiltspecs { /** * Returns underlaying array - * + * * @return underlaying array */ public Quiltspec[] getArray() { @@ -150,7 +150,7 @@ public class CArrayOfQuiltspecs { /** * Sets underlaying array - * + * * @param array * underlaying array */ diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Curve.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Curve.java index 786781723..ea3a3d14e 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Curve.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Curve.java @@ -103,7 +103,7 @@ public class Curve { /** * Makes new Curve - * + * * @param geo * @param pta * @param ptb @@ -143,7 +143,7 @@ public class Curve { range[0] = qs.get().breakpoints[qs.get().index]; range[1] = qs.get().breakpoints[qs.get().index + 1]; range[2] = range[1] - range[0]; - // TODO it is necessary to solve problem with "this" pointer here + // TODO it is necessary to solve problem with "this" pointer here if (range[0] != pta[0]) { // System.out.println("TODO curve.Curve-range0"); // Curve lower=new Curve(this,pta,0); @@ -229,7 +229,7 @@ public class Curve { /** * Tells whether curve needs subdivision - * + * * @return curve needs subdivison */ public boolean needsSamplingSubdivision() { diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Flist.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Flist.java index 6983691d9..f9c4c2d6f 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Flist.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Flist.java @@ -45,12 +45,12 @@ public class Flist { /** * Data elements end index - * + * */ public int end; /** - *Data elements start index + *Data elements start index */ public int start; @@ -80,7 +80,7 @@ public class Flist { } /** - * Removes duplicate array elemnts + * Removes duplicate array elemnts */ public void filter() { // INFO the aim of this method is to remove duplicates from array diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Knotspec.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Knotspec.java index 114832a1c..1dcf393a9 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Knotspec.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Knotspec.java @@ -36,9 +36,9 @@ package jogamp.opengl.glu.nurbs; /** * Knot vector specification - * + * * @author Tomas Hrasky - * + * */ public class Knotspec { @@ -314,7 +314,7 @@ public class Knotspec { /** * Copies control points - * + * * @param _inpt * input control points * @param _outpt @@ -346,7 +346,7 @@ public class Knotspec { /** * Copies one control point to other - * + * * @param topt * source control point * @param frompt @@ -374,7 +374,7 @@ public class Knotspec { /** * Inserts a knot - * + * * @param _p * inserted knot */ @@ -402,7 +402,7 @@ public class Knotspec { } } - } else {//code for curve + } else {//code for curve if (this.equals(kspectotrans)) { insert(p); } else { @@ -428,7 +428,7 @@ public class Knotspec { /** * Inserts a knot and computes new control points - * + * * @param p * inserted knot */ @@ -490,7 +490,7 @@ public class Knotspec { /** * Copies one control point to another - * + * * @param topt * source ctrl point * @param frompt @@ -519,7 +519,7 @@ public class Knotspec { /** * Computes new control point - * + * * @param x * first point * @param y @@ -549,7 +549,7 @@ public class Knotspec { * z.getRelative(0))); break; default: - //no need of default - see previous method and its case statement + //no need of default - see previous method and its case statement // System.out.println("TODO pt_oo_sum default"); break; } diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Knotvector.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Knotvector.java index aac4dfc52..571f44f06 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Knotvector.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Knotvector.java @@ -36,9 +36,9 @@ package jogamp.opengl.glu.nurbs; /** * Knot vector used in curve specification - * + * * @author Tomas Hrasky - * + * */ public class Knotvector { @@ -75,7 +75,7 @@ public class Knotvector { /** * Makes new knotvector - * + * * @param nknots * number of knots * @param stride @@ -92,7 +92,7 @@ public class Knotvector { /** * Initializes knotvector - * + * * @param nknots * number of knots * @param stride @@ -116,7 +116,7 @@ public class Knotvector { /** * Validates knot vector parameters - * + * * @return knot vector validity */ public int validate() { @@ -154,7 +154,7 @@ public class Knotvector { /** * Show specified message - * + * * @param msg * message to be shown */ @@ -166,7 +166,7 @@ public class Knotvector { /** * Compares two knots for equality - * + * * @param a * first knot * @param b diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Mapdesc.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Mapdesc.java index bd5d2db98..86638a827 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Mapdesc.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Mapdesc.java @@ -112,7 +112,7 @@ public class Mapdesc { float clampfactor; /** - * Value of N_MINSAVINGS property + * Value of N_MINSAVINGS property */ private float minsavings; @@ -162,7 +162,7 @@ public class Mapdesc { private float[] bboxsize; /** - * Makes new mapdesc + * Makes new mapdesc * @param type map type * @param rational is rational * @param ncoords number of control points coords @@ -318,7 +318,7 @@ public class Mapdesc { } /** - * Tells whether map is culling + * Tells whether map is culling * @return is map culling */ public boolean isCulling() { @@ -327,7 +327,7 @@ public class Mapdesc { } /** - * Tells whether map is constantly sampling + * Tells whether map is constantly sampling * @return is map constant sampling */ public boolean isConstantSampling() { @@ -335,7 +335,7 @@ public class Mapdesc { } /** - * Tells whether map is domain sampling + * Tells whether map is domain sampling * @return is map domain sampling */ public boolean isDomainSampling() { @@ -343,7 +343,7 @@ public class Mapdesc { } /** - * Returns property of specified tag value + * Returns property of specified tag value * @param tag property tag * @return property value */ diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/O_nurbscurve.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/O_nurbscurve.java index 05c89ebcf..a686da696 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/O_nurbscurve.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/O_nurbscurve.java @@ -68,7 +68,7 @@ public class O_nurbscurve { /** * Makes new O_nurbscurve - * @param realType type of curve + * @param realType type of curve */ public O_nurbscurve(int realType) { // DONE diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Patchlist.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Patchlist.java index f1e499a28..8c2922565 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Patchlist.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Patchlist.java @@ -52,7 +52,7 @@ public class Patchlist { private Patch patch; /** - * Makes new list of patches + * Makes new list of patches * @param quilts list of quilts * @param pta low border * @param ptb high border diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Property.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Property.java index 25b4dc441..79f36ce43 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Property.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Property.java @@ -36,9 +36,9 @@ package jogamp.opengl.glu.nurbs; /** * Class representing property - * + * * @author Tomas Hrasky - * + * */ public class Property { @@ -59,7 +59,7 @@ public class Property { /** * Makes new property with given parameters - * + * * @param type * property type * @param tag diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Renderhints.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Renderhints.java index 4729e2421..7c636122f 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Renderhints.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Renderhints.java @@ -35,7 +35,7 @@ package jogamp.opengl.glu.nurbs; */ /** - * Class holding rendering params + * Class holding rendering params * @author Tomas Hrasky * */ diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/Subdivider.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/Subdivider.java index 37774f811..4d8296cca 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/Subdivider.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/Subdivider.java @@ -41,7 +41,7 @@ package jogamp.opengl.glu.nurbs; */ public class Subdivider { /** - * Cull type + * Cull type */ public static final int CULL_TRIVIAL_REJECT = 0; @@ -76,7 +76,7 @@ public class Subdivider { private int subdivisions; /** - * U step when using domain distance sampling + * U step when using domain distance sampling */ private float domain_distance_u_rate; @@ -375,7 +375,7 @@ public class Subdivider { } /** - * Sample + * Sample * @param source * @param patchlist * @param subdivisions diff --git a/src/jogl/classes/jogamp/opengl/glu/nurbs/TrimVertex.java b/src/jogl/classes/jogamp/opengl/glu/nurbs/TrimVertex.java index e88d69709..1025afb7c 100644 --- a/src/jogl/classes/jogamp/opengl/glu/nurbs/TrimVertex.java +++ b/src/jogl/classes/jogamp/opengl/glu/nurbs/TrimVertex.java @@ -36,9 +36,9 @@ package jogamp.opengl.glu.nurbs; /** * Holds vertex used in trim - * + * * @author Tomas Hrasky - * + * */ public class TrimVertex { diff --git a/src/jogl/classes/jogamp/opengl/glu/registry/Registry.java b/src/jogl/classes/jogamp/opengl/glu/registry/Registry.java index 3d669d9bb..9c8523e51 100644 --- a/src/jogl/classes/jogamp/opengl/glu/registry/Registry.java +++ b/src/jogl/classes/jogamp/opengl/glu/registry/Registry.java @@ -6,15 +6,15 @@ * this file except in compliance with the License. You may obtain a copy * of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 * Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: - * + * * http://oss.sgi.com/projects/FreeB - * + * * Note that, as provided in the License, the Software is distributed on an * "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS * DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND * CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A * PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - * + * * NOTE: The Original Code (as defined below) has been licensed to Sun * Microsystems, Inc. ("Sun") under the SGI Free Software License B * (Version 1.1), shown above ("SGI License"). Pursuant to Section @@ -30,7 +30,7 @@ * Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. * Copyright in any portions created by third parties is as indicated * elsewhere herein. All Rights Reserved. - * + * * Additional Notice Provisions: The application programming interfaces * established by SGI in conjunction with the Original Code are The * OpenGL(R) Graphics System: A Specification (Version 1.2.1), released @@ -51,11 +51,11 @@ import javax.media.opengl.glu.GLU; * @author Administrator */ public class Registry { - + /** Creates a new instance of Registry */ public Registry() { } - + public static String gluGetString(int name) { if( name == GLU.GLU_VERSION ) { return( "1.3" ); @@ -64,7 +64,7 @@ public class Registry { } return( null ); } - + public static boolean gluCheckExtension( String extName, String extString ) { if( extName == null || extString == null ) { return( false ); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 0828d1dc3..5cc4003fe 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -80,7 +80,7 @@ import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; public class MacOSXCGLContext extends GLContextImpl -{ +{ // Abstract interface for implementation of this context (either // NSOpenGL-based or CGL-based) protected interface GLBackendImpl { @@ -140,13 +140,13 @@ public class MacOSXCGLContext extends GLContextImpl } private static final String shaderBasename = "texture01_xxx"; - + private static ShaderProgram createCALayerShader(GL3ES3 gl) { // Create & Link the shader program final ShaderProgram sp = new ShaderProgram(); - final ShaderCode vp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, MacOSXCGLContext.class, + final ShaderCode vp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, MacOSXCGLContext.class, "../../shader", "../../shader/bin", shaderBasename, true); - final ShaderCode fp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, MacOSXCGLContext.class, + final ShaderCode fp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, MacOSXCGLContext.class, "../../shader", "../../shader/bin", shaderBasename, true); vp.defaultShaderCustomization(gl, true, true); fp.defaultShaderCustomization(gl, true, true); @@ -162,7 +162,7 @@ public class MacOSXCGLContext extends GLContextImpl pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); - pmvMatrix.glLoadIdentity(); + pmvMatrix.glLoadIdentity(); final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv pmvMatrixUniform.setLocation(gl, sp.program()); gl.glUniform(pmvMatrixUniform); @@ -170,8 +170,8 @@ public class MacOSXCGLContext extends GLContextImpl sp.useProgram(gl, false); return sp; } - - + + private boolean haveSetOpenGLMode = false; private GLBackendType openGLMode = GLBackendType.NSOPENGL; @@ -185,7 +185,7 @@ public class MacOSXCGLContext extends GLContextImpl private long updateHandle = 0; private int lastWidth, lastHeight; - + protected MacOSXCGLContext(GLDrawableImpl drawable, GLContext shareWith) { super(drawable, shareWith); @@ -303,7 +303,7 @@ public class MacOSXCGLContext extends GLContextImpl @Override protected void makeCurrentImpl() throws GLException { /** FIXME: won't work w/ special drawables (like FBO) - check for CGL mode regressions! - * + * if (getOpenGLMode() != ((MacOSXCGLDrawable)drawable).getOpenGLMode()) { setOpenGLMode(((MacOSXCGLDrawable)drawable).getOpenGLMode()); } */ @@ -327,7 +327,7 @@ public class MacOSXCGLContext extends GLContextImpl throw new GLException("Error destroying OpenGL Context: "+this); } } - + private final long getUpdateHandle() { if( 0 == updateHandle ) { lastWidth = -1; @@ -340,7 +340,7 @@ public class MacOSXCGLContext extends GLContextImpl } else { incompleteView = false; } - if(!incompleteView) { + if(!incompleteView) { updateHandle = CGL.updateContextRegister(contextHandle, drawable.getHandle()); if(0 == updateHandle) { throw new InternalError("XXX2"); @@ -350,14 +350,14 @@ public class MacOSXCGLContext extends GLContextImpl } return updateHandle; } - + private final void releaseUpdateHandle() { if ( 0 != updateHandle ) { CGL.updateContextUnregister(updateHandle); updateHandle = 0; - } + } } - + @Override protected void drawableUpdatedNotify() throws GLException { if( drawable.getChosenGLCapabilities().isOnscreen() ) { @@ -376,7 +376,7 @@ public class MacOSXCGLContext extends GLContextImpl } } } - + @Override protected void associateDrawable(boolean bound) { // context stuff depends on drawable stuff @@ -390,12 +390,12 @@ public class MacOSXCGLContext extends GLContextImpl super.associateDrawable(false); // 2) free drawable stuff } } - + /* pp */ void detachPBuffer() { impl.detachPBuffer(); } - + @Override protected void copyImpl(GLContext source, int mask) throws GLException { if( isNSContext() != ((MacOSXCGLContext)source).isNSContext() ) { @@ -429,7 +429,7 @@ public class MacOSXCGLContext extends GLContextImpl // FIXME: apparently the Apple extension doesn't require a custom memory allocator throw new GLException("Not yet implemented"); } - + @Override protected final void updateGLXProcAddressTable() { final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); @@ -520,11 +520,11 @@ public class MacOSXCGLContext extends GLContextImpl private int lastWidth=0, lastHeight=0; // allowing to detect size change private boolean needsSetContextPBuffer = false; private ShaderProgram gl3ShaderProgram = null; - + @Override public boolean isNSContext() { return true; } - + /** Only returns a valid NSView. If !NSView, return null and mark either pbuffer and FBO. */ private long getNSViewHandle(boolean[] isPBuffer, boolean[] isFBO) { final long nsViewHandle; @@ -558,11 +558,11 @@ public class MacOSXCGLContext extends GLContextImpl needsSetContextPBuffer = isPBuffer[0]; return nsViewHandle; } - + @Override public long create(long share, int ctp, int major, int minor) { long ctx = 0; - final NativeSurface surface = drawable.getNativeSurface(); + final NativeSurface surface = drawable.getNativeSurface(); final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration(); final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); final long nsViewHandle; @@ -606,7 +606,7 @@ public class MacOSXCGLContext extends GLContextImpl if( !_fixedCaps.isPBuffer() && isPBuffer ) { throw new InternalError("handle is PBuffer, fixedCaps not: "+drawable); } - // determine on-/offscreen caps, since pformat is ambiguous + // determine on-/offscreen caps, since pformat is ambiguous _fixedCaps.setPBuffer( isPBuffer ); // exclusive _fixedCaps.setBitmap( false ); // n/a in our OSX impl. _fixedCaps.setOnscreen( !isFBO && !isPBuffer ); @@ -632,7 +632,7 @@ public class MacOSXCGLContext extends GLContextImpl // Thread.dumpStack(); } config.setChosenCapabilities(fixedCaps); - + final IntBuffer viewNotReady = Buffers.newDirectIntBuffer(1); // Try to allocate a context with this ctx = CGL.createContext(share, nsViewHandle, incompleteView, @@ -665,12 +665,12 @@ public class MacOSXCGLContext extends GLContextImpl *

          * Since NSOpenGLLayer creation requires this context for it's shared context creation, * this method attempts to acquire the surface and context lock with {@link #screenVSyncTimeout}/2 maximum wait time. - * If the surface and context lock could not be acquired, this runnable is being re-queued for later execution. + * If the surface and context lock could not be acquired, this runnable is being re-queued for later execution. *

          *

          * Hence this method blocks the main-thread only for a short period of time. *

          - */ + */ class AttachGLLayerCmd implements Runnable { final OffscreenLayerSurface ols; final long ctx; @@ -685,7 +685,7 @@ public class MacOSXCGLContext extends GLContextImpl long nsOpenGLLayer; /** Synchronized by instance's monitor */ boolean valid; - + AttachGLLayerCmd(OffscreenLayerSurface ols, long ctx, int shaderProgram, long pfmt, long pbuffer, int texID, boolean isOpaque, int width, int height) { this.ols = ols; this.ctx = ctx; @@ -699,23 +699,23 @@ public class MacOSXCGLContext extends GLContextImpl this.valid = false; this.nsOpenGLLayer = 0; } - + public final String contentToString() { return "valid "+valid+", size "+width+"x"+height+", ctx "+toHexString(ctx)+", opaque "+isOpaque+", texID "+texID+", pbuffer "+toHexString(pbuffer)+", nsOpenGLLayer "+toHexString(nsOpenGLLayer); } - + @Override public final String toString() { return "AttachGLLayerCmd["+contentToString()+"]"; } - + @Override public void run() { synchronized(this) { if( !valid ) { try { final int maxwait = screenVSyncTimeout/2000; // TO 1/2 of current screen-vsync in [ms] - final RecursiveLock surfaceLock = ols.getLock(); + final RecursiveLock surfaceLock = ols.getLock(); if( surfaceLock.tryLock( maxwait ) ) { try { if( MacOSXCGLContext.this.lock.tryLock( maxwait ) ) { @@ -752,19 +752,19 @@ public class MacOSXCGLContext extends GLContextImpl } } AttachGLLayerCmd attachGLLayerCmd = null; - + class DetachGLLayerCmd implements Runnable { final AttachGLLayerCmd cmd; - + DetachGLLayerCmd(AttachGLLayerCmd cmd) { this.cmd = cmd; } - + @Override public final String toString() { return "DetachGLLayerCmd["+cmd.contentToString()+"]"; } - + @Override public void run() { synchronized( cmd ) { @@ -777,7 +777,7 @@ public class MacOSXCGLContext extends GLContextImpl ols.detachSurfaceLayer(); } } catch(Throwable t) { - System.err.println("Catched Exception on thread "+getThreadName()); + System.err.println("Catched Exception on thread "+getThreadName()); t.printStackTrace(); } CGL.releaseNSOpenGLLayer(cmd.nsOpenGLLayer); @@ -790,27 +790,27 @@ public class MacOSXCGLContext extends GLContextImpl System.err.println("NSOpenGLLayer.Detach: Skipped "+toHexString(cmd.nsOpenGLLayer)+" - "+getThreadName()); } } - } + } } - + @Override public void associateDrawable(boolean bound) { backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(drawable.getNativeSurface(), true); - + if(DEBUG) { System.err.println("MaxOSXCGLContext.NSOpenGLImpl.associateDrawable: "+bound+", ctx "+toHexString(contextHandle)+ ", hasBackingLayerHost "+(null!=backingLayerHost)+", attachGLLayerCmd "+attachGLLayerCmd); // Thread.dumpStack(); - } - - if( bound ) { + } + + if( bound ) { if( null != backingLayerHost ) { final GLCapabilitiesImmutable chosenCaps; final long ctx; final int texID; final long pbufferHandle; final int gl3ShaderProgramName; - + // // handled layered surface // @@ -823,8 +823,8 @@ public class MacOSXCGLContext extends GLContextImpl pbufferHandle = 0; fbod.setSwapBufferContext(new GLFBODrawableImpl.SwapBufferContext() { public void swapBuffers(boolean doubleBuffered) { - MacOSXCGLContext.NSOpenGLImpl.this.swapBuffers(); - } } ) ; + MacOSXCGLContext.NSOpenGLImpl.this.swapBuffers(); + } } ) ; } else if( CGL.isNSOpenGLPixelBuffer(drawableHandle) ) { texID = 0; pbufferHandle = drawableHandle; @@ -847,19 +847,19 @@ public class MacOSXCGLContext extends GLContextImpl gl3ShaderProgramName = gl3ShaderProgram.program(); } else { gl3ShaderProgramName = 0; - } - + } + // All CALayer lifecycle ops are deferred on main-thread - attachGLLayerCmd = new AttachGLLayerCmd( - backingLayerHost, ctx, gl3ShaderProgramName, pixelFormat, pbufferHandle, texID, + attachGLLayerCmd = new AttachGLLayerCmd( + backingLayerHost, ctx, gl3ShaderProgramName, pixelFormat, pbufferHandle, texID, chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight ); if(DEBUG) { System.err.println("MaxOSXCGLContext.NSOpenGLImpl.associateDrawable(true): "+attachGLLayerCmd); - } + } OSXUtil.RunOnMainThread(false, attachGLLayerCmd); - } else { // -> null == backingLayerHost + } else { // -> null == backingLayerHost lastWidth = drawable.getWidth(); - lastHeight = drawable.getHeight(); + lastHeight = drawable.getHeight(); boolean[] isPBuffer = { false }; boolean[] isFBO = { false }; CGL.setContextView(contextHandle, getNSViewHandle(isPBuffer, isFBO)); @@ -882,7 +882,7 @@ public class MacOSXCGLContext extends GLContextImpl final DetachGLLayerCmd dCmd = new DetachGLLayerCmd(cmd); if(DEBUG) { System.err.println("MaxOSXCGLContext.NSOpenGLImpl.associateDrawable(false): "+dCmd); - } + } OSXUtil.RunOnMainThread(false, dCmd); if( null != gl3ShaderProgram ) { gl3ShaderProgram.destroy(MacOSXCGLContext.this.gl.getGL3()); @@ -903,11 +903,11 @@ public class MacOSXCGLContext extends GLContextImpl needsSetContextPBuffer = false; CGL.setContextPBuffer(ctx, drawableHandle); if(DEBUG) { - System.err.println("NS.validateDrawableConfig bind pbuffer "+toHexString(drawableHandle)+" -> ctx "+toHexString(ctx)); + System.err.println("NS.validateDrawableConfig bind pbuffer "+toHexString(drawableHandle)+" -> ctx "+toHexString(ctx)); } } } - + /** Returns true if size has been updated, otherwise false (same size). */ private final boolean validateDrawableSizeConfig(long ctx) { final int width = drawable.getWidth(); @@ -916,13 +916,13 @@ public class MacOSXCGLContext extends GLContextImpl lastWidth = drawable.getWidth(); lastHeight = drawable.getHeight(); if(DEBUG) { - System.err.println("NS.validateDrawableConfig size changed"); + System.err.println("NS.validateDrawableConfig size changed"); } return true; } return false; } - + @Override public boolean copyImpl(long src, int mask) { CGL.copyContext(contextHandle, src, mask); @@ -975,7 +975,7 @@ public class MacOSXCGLContext extends GLContextImpl // CGL.setContextPBuffer(contextHandle, 0); // doesn't work, i.e. not taking nil return true; } - + @Override public boolean setSwapInterval(int interval) { final AttachGLLayerCmd cmd = attachGLLayerCmd; @@ -1004,7 +1004,7 @@ public class MacOSXCGLContext extends GLContextImpl if(DEBUG) { System.err.println("CGL setSwapInterval: "+interval); } CGL.setSwapInterval(contextHandle, interval); } - + private int skipSync=0; /** TODO: Remove after discussion private boolean perfIterReset = false; @@ -1014,7 +1014,7 @@ public class MacOSXCGLContext extends GLContextImpl private long frameXS = 0; private long lastFrameStart = 0; */ - + @Override public boolean swapBuffers() { final AttachGLLayerCmd cmd = attachGLLayerCmd; @@ -1026,7 +1026,7 @@ public class MacOSXCGLContext extends GLContextImpl // allowing to update the texture IDs ASAP. skipSync = 10; } - + final boolean res; final int texID; final boolean valid; @@ -1054,19 +1054,19 @@ public class MacOSXCGLContext extends GLContextImpl final long lastFramePeriod0 = TimeUnit.NANOSECONDS.toMicros(System.nanoTime()) - lastFrameStart; gl.glFinish(); // Require to finish previous GL rendering to give CALayer proper result final long lastFramePeriod1 = TimeUnit.NANOSECONDS.toMicros(System.nanoTime()) - lastFrameStart; - - // If v-sync is disabled, frames will be drawn as quickly as possible w/o delay, + + // If v-sync is disabled, frames will be drawn as quickly as possible w/o delay, // while still synchronizing w/ CALayer. // If v-sync is enabled wait until next swap interval (v-sync). CGL.waitUntilNSOpenGLLayerIsReady(cmd.nsOpenGLLayer, vsyncTimeout); final long lastFramePeriodX = TimeUnit.NANOSECONDS.toMicros(System.nanoTime()) - lastFrameStart; - + final long finishGL = lastFramePeriod1 - lastFramePeriod0; final long waitGL = lastFramePeriodX - lastFramePeriod1; finishGLS += finishGL; waitGLS += waitGL; frameXS += lastFramePeriodX; - + System.err.println("XXX["+perfIter+"] TO "+vsyncTimeout/1000+" ms, "+ "lFrame0 "+lastFramePeriod0/1000+" ms, "+ "lFrameX "+lastFramePeriodX/1000+" / "+frameXS/1000+" ~"+(frameXS/perfIter)/1000.0+" ms, "+ @@ -1080,8 +1080,8 @@ public class MacOSXCGLContext extends GLContextImpl // FIXME: IMHO this synchronization should be implicitly performed via 'CGL.flushBuffer(contextHandle)' above, // in case this will be determined a driver bug - use a QUIRK entry in GLRendererQuirks! gl.glFinish(); - - // If v-sync is disabled, frames will be drawn as quickly as possible w/o delay, + + // If v-sync is disabled, frames will be drawn as quickly as possible w/o delay, // while still synchronizing w/ CALayer. // If v-sync is enabled wait until next swap interval (v-sync). CGL.waitUntilNSOpenGLLayerIsReady(cmd.nsOpenGLLayer, vsyncTimeout); @@ -1093,7 +1093,7 @@ public class MacOSXCGLContext extends GLContextImpl CGL.setNSOpenGLLayerNeedsDisplayFBO(cmd.nsOpenGLLayer, texID); } else { // trigger CALayer to update incl. possible surface change (new pbuffer handle) - CGL.setNSOpenGLLayerNeedsDisplayPBuffer(cmd.nsOpenGLLayer, drawable.getHandle()); + CGL.setNSOpenGLLayerNeedsDisplayPBuffer(cmd.nsOpenGLLayer, drawable.getHandle()); } // lastFrameStart = TimeUnit.NANOSECONDS.toMicros(System.nanoTime()); } @@ -1137,8 +1137,8 @@ public class MacOSXCGLContext extends GLContextImpl if (0 != ctx) { GLCapabilities fixedCaps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(pixelFormat); fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(fixedCaps, chosenCaps.isBackgroundOpaque()); - { // determine on-/offscreen caps, since pformat is ambiguous - fixedCaps.setFBO( false ); // n/a for CGLImpl + { // determine on-/offscreen caps, since pformat is ambiguous + fixedCaps.setFBO( false ); // n/a for CGLImpl fixedCaps.setPBuffer( fixedCaps.isPBuffer() && !chosenCaps.isOnscreen() ); fixedCaps.setBitmap( false ); // n/a in our OSX impl. fixedCaps.setOnscreen( !fixedCaps.isPBuffer() ); @@ -1153,7 +1153,7 @@ public class MacOSXCGLContext extends GLContextImpl if (res != CGL.kCGLNoError) { throw new GLException("Error code " + res + " while attaching context to pbuffer"); } - } + } } } finally { CGL.CGLDestroyPixelFormat(pixelFormat); @@ -1224,7 +1224,7 @@ public class MacOSXCGLContext extends GLContextImpl } */ return true; } - + @Override public boolean setSwapInterval(int interval) { final IntBuffer lval = Buffers.newDirectIntBuffer(1); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index 4bd7bc994..bb36a7219 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -105,7 +105,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { @Override protected void setRealizedImpl() { } - + @Override protected void associateContext(GLContext ctx, boolean bound) { // NOTE: we need to keep track of the created contexts in order to @@ -123,14 +123,14 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { } else { i++; } - } + } } - } + } } - + @Override protected final void swapBuffersImpl(boolean doubleBuffered) { - if(doubleBuffered) { + if(doubleBuffered) { synchronized (createdContexts) { for(int i=0; i libsGL = new ArrayList(); libsGL.add("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"); libsGL.add("GL"); - libsList.add(libsGL); + libsList.add(libsGL); return libsList; } - + @Override public final List getToolGetProcAddressFuncNameList() { - return null; + return null; /** OSX manual says: NSImage use is discouraged List res = new ArrayList(); res.add("GetProcAddress"); // dummy @@ -59,7 +59,7 @@ public final class MacOSXCGLDynamicLibraryBundleInfo extends DesktopGLDynamicLib public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) { return 0; /** OSX manual says: NSImage use is discouraged - return CGL.getProcAddress(glFuncName); // manual implementation + return CGL.getProcAddress(glFuncName); // manual implementation */ } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java index 5eb11c6a4..535c4d2d3 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -54,7 +54,7 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration; public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { - MacOSXCGLGraphicsConfiguration(AbstractGraphicsScreen screen, + MacOSXCGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested) { super(screen, capsChosen, capsRequested); } @@ -71,10 +71,10 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration // MacOSXGraphicsDevice osxDevice = sharedResource.getDevice(); return new ArrayList(0); } - + static final IntBuffer cglInternalAttributeToken = Buffers.newDirectIntBuffer(new int[] { CGL.kCGLPFAOpenGLProfile, // >= lion - CGL.NSOpenGLPFAAccelerated, // query only (prefer accelerated, but allow non accelerated), ignored for createPixelformat + CGL.NSOpenGLPFAAccelerated, // query only (prefer accelerated, but allow non accelerated), ignored for createPixelformat CGL.NSOpenGLPFANoRecovery, CGL.kCGLPFAColorFloat, CGL.NSOpenGLPFAPixelBuffer, @@ -96,13 +96,13 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration for (int idx = 0; idx < len; idx++) { final int attr = attrToken.get(idx+off); switch (attr) { - case CGL.kCGLPFAOpenGLProfile: + case CGL.kCGLPFAOpenGLProfile: ivalues.put(idx, MacOSXCGLContext.GLProfile2CGLOGLProfileValue(ctp, major, minor)); break; case CGL.NSOpenGLPFANoRecovery: ivalues.put(idx, caps.getHardwareAccelerated() ? 1 : 0); break; - + case CGL.kCGLPFAColorFloat: // ivalues.put(idx, ( !caps.isOnscreen() && caps.isPBuffer() && caps.getPbufferFloatingPointBuffers() ) ? 1 : 0); ivalues.put(idx, 0); @@ -160,7 +160,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration if ( !MacOSXCGLContext.isLionOrLater ) { // no OpenGLProfile attrToken.position(1); - } + } final IntBuffer ivalues = GLCapabilities2NSAttribList(attrToken, caps, ctp, major, minor); return CGL.createPixelFormat(attrToken, attrToken.remaining(), ivalues); } @@ -174,7 +174,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration final IntBuffer attrs = Buffers.newDirectIntBuffer(256); int i = 0; if(MacOSXCGLContext.isLionOrLater) { - attrs.put(i++, CGL.kCGLPFAOpenGLProfile); + attrs.put(i++, CGL.kCGLPFAOpenGLProfile); attrs.put(i++, MacOSXCGLContext.GLProfile2CGLOGLProfileValue(ctp, major, minor)); } /** @@ -222,8 +222,8 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration } return fmt.get(0); } - - static GLCapabilities CGLPixelFormat2GLCapabilities(long pixelFormat) { + + static GLCapabilities CGLPixelFormat2GLCapabilities(long pixelFormat) { return PixelFormat2GLCapabilities(null, pixelFormat, false); } @@ -235,7 +235,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration off = 1; } else { off = 0; - } + } attrToken.position(off); final int len = attrToken.remaining(); final IntBuffer ivalues = Buffers.newDirectIntBuffer(len); @@ -243,7 +243,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration // On this platform the pixel format is associated with the // context and not the drawable. However it's a reasonable // approximation to just store the chosen pixel format up in the - // NativeSurface's AbstractGraphicsConfiguration, + // NativeSurface's AbstractGraphicsConfiguration, // since the public API doesn't provide for a different GLCapabilities per context. // Note: These restrictions of the platform's API might be considered as a bug anyways. @@ -253,7 +253,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration } else { CGL.CGLQueryPixelFormat(pixelFormat, attrToken, len, ivalues); } - + if(null == glp && MacOSXCGLContext.isLionOrLater) { // pre-scan for OpenGL Profile for (int i = 0; i < len; i++) { @@ -265,11 +265,11 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration break; case CGL.kCGLOGLPVersion_Legacy: glp = GLProfile.get(GLProfile.GL2); - break; + break; default: throw new RuntimeException("Unhandled OSX OpenGL Profile: 0x"+Integer.toHexString(ivalue)); } - } + } } } if(null == glp) { @@ -284,7 +284,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration case CGL.NSOpenGLPFAAccelerated: caps.setHardwareAccelerated(ivalue != 0); break; - + case CGL.kCGLPFAColorFloat: // caps.setPbufferFloatingPointBuffers(ivalue != 0); break; @@ -346,7 +346,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration } } caps.setAlphaBits(alphaBits); - + return caps; } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java index 3bbba2c52..e761be7b7 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -56,13 +56,13 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GLGraphicsConfigurati static void registerFactory() { GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice.class, GLCapabilitiesImmutable.class, new MacOSXCGLGraphicsConfigurationFactory()); } - private MacOSXCGLGraphicsConfigurationFactory() { + private MacOSXCGLGraphicsConfigurationFactory() { } protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { - + if (absScreen == null) { throw new IllegalArgumentException("AbstractGraphicsScreen is null"); } @@ -78,7 +78,7 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GLGraphicsConfigurati if (chooser != null && !(chooser instanceof GLCapabilitiesChooser)) { throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects"); } - + return chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested, (GLCapabilitiesChooser)chooser, absScreen, false); } @@ -91,7 +91,7 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GLGraphicsConfigurati } final AbstractGraphicsDevice device = absScreen.getDevice(); capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLDrawableFactory.getDesktopFactory(), device); - + return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested); } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 4e791cb5f..f6e8b8fa3 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -90,7 +90,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { public GLContext createContext(GLContext shareWith) { return new MacOSXCGLContext(this, shareWith); } - + protected int getTextureTarget() { return pBufferTexTarget; } protected int getTextureWidth() { return pBufferTexWidth; } protected int getTextureHeight() { return pBufferTexHeight; } @@ -101,7 +101,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { if (0 != pBuffer) { synchronized (createdContexts) { for(int i=0; i ref = createdContexts.get(i); + final WeakReference ref = createdContexts.get(i); final MacOSXCGLContext ctx = ref.get(); if (ctx != null) { ctx.detachPBuffer(); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java index edf9b7c84..c08259665 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -59,7 +59,7 @@ import jogamp.opengl.macosx.cgl.MacOSXCGLGraphicsConfiguration; public class MacOSXAWTCGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory { public static void registerFactory() { GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, GLCapabilitiesImmutable.class, new MacOSXAWTCGLGraphicsConfigurationFactory()); - } + } private MacOSXAWTCGLGraphicsConfigurationFactory() { } diff --git a/src/jogl/classes/jogamp/opengl/util/GLArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/GLArrayHandler.java index 1a4ca345b..810a9286b 100644 --- a/src/jogl/classes/jogamp/opengl/util/GLArrayHandler.java +++ b/src/jogl/classes/jogamp/opengl/util/GLArrayHandler.java @@ -37,22 +37,22 @@ import javax.media.opengl.*; */ public interface GLArrayHandler { - + /** - * if bind is true and the data uses VBO, + * if bind is true and the data uses VBO, * the latter will be bound and data written to the GPU if required. *

          * If bind is false and the data uses VBO, * the latter will be unbound. *

          - * + * * @param gl current GL object - * @param bind true if VBO shall be bound and data written, + * @param bind true if VBO shall be bound and data written, * otherwise clear VBO binding. - * @return true if data uses VBO and action was performed, otherwise false + * @return true if data uses VBO and action was performed, otherwise false */ public boolean bindBuffer(GL gl, boolean bind); - + /** * Implementation shall enable or disable the array state. *

          @@ -60,23 +60,23 @@ public interface GLArrayHandler { * implementation shall synchronize the data with the GPU * and associate the data with the array. *

          - * + * * @param gl current GL object * @param enable true if array shall be enabled, otherwise false. - * @param ext extension object allowing passing of an implementation detail + * @param ext extension object allowing passing of an implementation detail */ public void enableState(GL gl, boolean enable, Object ext); - + /** - * Supporting interleaved arrays, where sub handlers may handle + * Supporting interleaved arrays, where sub handlers may handle * the array state and the master handler the buffer consistency. - * + * * @param handler the sub handler * @throws UnsupportedOperationException if this array handler does not support interleaved arrays */ public void addSubHandler(GLArrayHandlerFlat handler) throws UnsupportedOperationException; public void setSubArrayVBOName(int vboName); - + } diff --git a/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerFlat.java b/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerFlat.java index 4a8f40608..179142fee 100644 --- a/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerFlat.java +++ b/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerFlat.java @@ -39,21 +39,21 @@ public interface GLArrayHandlerFlat { /** * Implementation shall associate the data with the array - * + * * @param gl current GL object - * @param ext extension object allowing passing of an implementation detail + * @param ext extension object allowing passing of an implementation detail */ public void syncData(GL gl, Object ext); - + /** * Implementation shall enable or disable the array state. - * + * * @param gl current GL object * @param enable true if array shall be enabled, otherwise false. - * @param ext extension object allowing passing of an implementation detail + * @param ext extension object allowing passing of an implementation detail */ - public void enableState(GL gl, boolean enable, Object ext); - + public void enableState(GL gl, boolean enable, Object ext); + public GLArrayDataWrapper getData(); } diff --git a/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java index 98f711b8e..5f9b25530 100644 --- a/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java +++ b/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java @@ -36,8 +36,8 @@ import javax.media.opengl.GL; import com.jogamp.opengl.util.GLArrayDataEditable; /** - * Interleaved fixed function arrays, i.e. where this buffer data - * represents many arrays. + * Interleaved fixed function arrays, i.e. where this buffer data + * represents many arrays. */ public class GLArrayHandlerInterleaved extends GLVBOArrayHandler implements GLArrayHandler { private List subArrays = new ArrayList(); @@ -45,13 +45,13 @@ public class GLArrayHandlerInterleaved extends GLVBOArrayHandler implements GLAr public GLArrayHandlerInterleaved(GLArrayDataEditable ad) { super(ad); } - + public final void setSubArrayVBOName(int vboName) { for(int i=0; i{@link #setTextureTarget(int)} *
        • {@link EGLMediaPlayerImpl#setEGLTexImageAttribs(boolean, boolean)}.
        • *
        - * + * *

        * See {@link GLMediaPlayer}. *

        @@ -75,21 +75,21 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected volatile State state; private Object stateLock = new Object(); - + protected int textureCount; protected int textureTarget; protected int textureFormat; - protected int textureInternalFormat; + protected int textureInternalFormat; protected int textureType; protected int texUnit; - - + + protected int[] texMinMagFilter = { GL.GL_NEAREST, GL.GL_NEAREST }; protected int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE }; - + /** User requested URI stream location. */ protected URI streamLoc = null; - /** + /** * In case {@link #streamLoc} is a {@link GLMediaPlayer#CameraInputScheme}, * {@link #cameraPath} holds the URI's path portion * as parsed in {@link #initStream(URI, int, int, int)}. @@ -98,10 +98,10 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected String cameraPath = null; /** Optional camera properties, see {@link #cameraPath}. */ protected Map cameraProps = null; - + protected volatile float playSpeed = 1.0f; protected float audioVolume = 1.0f; - + /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected int vid = GLMediaPlayer.STREAM_ID_AUTO; /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ @@ -130,20 +130,20 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected String acodec = unknown; /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected String vcodec = unknown; - + protected volatile int decodedFrameCount = 0; protected int presentedFrameCount = 0; protected int displayedFrameCount = 0; protected volatile int video_pts_last = 0; - + /** See {@link #getAudioSink()}. Set by implementation if used from within {@link #initStreamImpl(int, int)}! */ protected AudioSink audioSink = null; protected boolean audioSinkPlaySpeedSet = false; - + /** System Clock Reference (SCR) of first audio PTS at start time. */ private long audio_scr_t0 = 0; private boolean audioSCR_reset = true; - + /** System Clock Reference (SCR) of first video frame at start time. */ private long video_scr_t0 = 0; /** System Clock Reference (SCR) PTS offset, i.e. first video PTS at start time. */ @@ -152,7 +152,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private float video_dpts_cum = 0; /** Cumulative video frames. */ private int video_dpts_count = 0; - /** Number of min frame count required for video cumulative sync. */ + /** Number of min frame count required for video cumulative sync. */ private static final int VIDEO_DPTS_NUM = 20; /** Cumulative coefficient, value {@value}. */ private static final float VIDEO_DPTS_COEFF = 0.7943282f; // (float) Math.exp(Math.log(0.01) / VIDEO_DPTS_NUM); @@ -160,7 +160,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private static final int VIDEO_DPTS_MAX = 5000; // 5s max diff /** Trigger video PTS reset with given cause as bitfield. */ private boolean videoSCR_reset = false; - + protected TextureFrame[] videoFramesOrig = null; protected Ringbuffer videoFramesFree = null; protected Ringbuffer videoFramesDecoded = null; @@ -177,42 +177,42 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { this.textureTarget=GL.GL_TEXTURE_2D; this.textureFormat = GL.GL_RGBA; this.textureInternalFormat = GL.GL_RGBA; - this.textureType = GL.GL_UNSIGNED_BYTE; + this.textureType = GL.GL_UNSIGNED_BYTE; this.texUnit = 0; this.state = State.Uninitialized; } @Override public final void setTextureUnit(int u) { texUnit = u; } - + @Override public final int getTextureUnit() { return texUnit; } - + @Override public final int getTextureTarget() { return textureTarget; } - + @Override public final int getTextureCount() { return textureCount; } - + protected final void setTextureTarget(int target) { textureTarget=target; } - protected final void setTextureFormat(int internalFormat, int format) { - textureInternalFormat=internalFormat; - textureFormat=format; - } + protected final void setTextureFormat(int internalFormat, int format) { + textureInternalFormat=internalFormat; + textureFormat=format; + } protected final void setTextureType(int t) { textureType=t; } public final void setTextureMinMagFilter(int[] minMagFilter) { texMinMagFilter[0] = minMagFilter[0]; texMinMagFilter[1] = minMagFilter[1];} public final int[] getTextureMinMagFilter() { return texMinMagFilter; } - + public final void setTextureWrapST(int[] wrapST) { texWrapST[0] = wrapST[0]; texWrapST[1] = wrapST[1];} - public final int[] getTextureWrapST() { return texWrapST; } - + public final int[] getTextureWrapST() { return texWrapST; } + private final void checkGLInit() { if(State.Uninitialized == state || State.Initialized == state ) { throw new IllegalStateException("GL not initialized: "+this); - } + } } - + @Override public String getRequiredExtensionsShaderStub() throws IllegalStateException { checkGLInit(); @@ -221,24 +221,24 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } return ""; } - + @Override public String getTextureSampler2DType() throws IllegalStateException { checkGLInit(); switch(textureTarget) { case GL.GL_TEXTURE_2D: - case GL2.GL_TEXTURE_RECTANGLE: + case GL2.GL_TEXTURE_RECTANGLE: return TextureSequence.sampler2D; case GLES2.GL_TEXTURE_EXTERNAL_OES: return TextureSequence.samplerExternalOES; default: - throw new GLException("Unsuported texture target: "+toHexString(textureTarget)); + throw new GLException("Unsuported texture target: "+toHexString(textureTarget)); } } - + /** * {@inheritDoc} - * + * * This implementation simply returns the build-in function name of texture2D, * if not overridden by specialization. */ @@ -247,31 +247,31 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { checkGLInit(); return "texture2D"; } - + /** * {@inheritDoc} - * - * This implementation simply returns an empty string since it's using + * + * This implementation simply returns an empty string since it's using * the build-in function texture2D, * if not overridden by specialization. */ @Override public String getTextureLookupFragmentShaderImpl() throws IllegalStateException { checkGLInit(); - return ""; + return ""; } - + @Override public final int getDecodedFrameCount() { return decodedFrameCount; } - + @Override public final int getPresentedFrameCount() { return presentedFrameCount; } - + @Override public final int getVideoPTS() { return video_pts_last; } - + @Override - public final int getAudioPTS() { + public final int getAudioPTS() { if( State.Uninitialized != state ) { return getAudioPTSImpl(); } @@ -285,10 +285,10 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { return 0; } } - + @Override public final State getState() { return state; } - + @Override public final State play() { synchronized( stateLock ) { @@ -310,7 +310,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } protected abstract boolean playImpl(); - + @Override public final State pause(boolean flush) { return pauseImpl(flush, 0); @@ -337,7 +337,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } protected abstract boolean pauseImpl(); - + @Override public final State destroy(GL gl) { return destroyImpl(gl, 0); @@ -354,7 +354,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } protected abstract void destroyImpl(GL gl); - + @Override public final int seek(int msec) { synchronized( stateLock ) { @@ -383,12 +383,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } protected abstract int seekImpl(int msec); - + @Override public final float getPlaySpeed() { return playSpeed; } - + @Override public final boolean setPlaySpeed(float rate) { synchronized( stateLock ) { @@ -410,18 +410,18 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { return res; } } - /** + /** * Override if not using AudioSink, or AudioSink's {@link AudioSink#setPlaySpeed(float)} is not sufficient! *

        - * AudioSink shall respect !audioSinkPlaySpeedSet to determine data_size + * AudioSink shall respect !audioSinkPlaySpeedSet to determine data_size * at {@link AudioSink#enqueueData(com.jogamp.opengl.util.av.AudioSink.AudioFrame)}. - *

        + *

        */ protected boolean setPlaySpeedImpl(float rate) { if( null != audioSink ) { audioSinkPlaySpeedSet = audioSink.setPlaySpeed(rate); } - // still true, even if audioSink rejects command since we deal w/ video sync + // still true, even if audioSink rejects command since we deal w/ video sync // and AudioSink w/ audioSinkPlaySpeedSet at enqueueData(..). return true; } @@ -431,7 +431,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { getAudioVolumeImpl(); return audioVolume; } - /** + /** * Override if not using AudioSink, or AudioSink's {@link AudioSink#getVolume()} is not sufficient! */ protected void getAudioVolumeImpl() { @@ -439,7 +439,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { audioVolume = audioSink.getVolume(); } } - + @Override public boolean setAudioVolume(float v) { synchronized( stateLock ) { @@ -460,7 +460,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { return res; } } - /** + /** * Override if not using AudioSink, or AudioSink's {@link AudioSink#setVolume(float)} is not sufficient! */ protected boolean setAudioVolumeImpl(float v) { @@ -470,7 +470,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { // still true, even if audioSink rejects command .. return true; } - + @Override public final void initStream(URI streamLoc, int vid, int aid, int reqTextureCount) throws IllegalStateException, IllegalArgumentException { synchronized( stateLock ) { @@ -490,7 +490,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } decodedFrameCount = 0; presentedFrameCount = 0; - displayedFrameCount = 0; + displayedFrameCount = 0; this.streamLoc = streamLoc; // Pre-parse for camera-input scheme @@ -500,7 +500,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( null != streamLocScheme && streamLocScheme.equals(CameraInputScheme) ) { final String rawPath = streamLoc.getRawPath(); if( null != rawPath && rawPath.length() > 0 ) { - // cut-off root fwd-slash + // cut-off root fwd-slash cameraPath = rawPath.substring(1); final URIQueryProps props = URIQueryProps.create(streamLoc, ';'); cameraProps = props.getProperties(); @@ -508,7 +508,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { throw new IllegalArgumentException("Camera path is empty: "+streamLoc.toString()); } } - + this.vid = vid; this.aid = aid; if (this.streamLoc != null) { @@ -519,7 +519,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { /** * Implementation shall set the following set of data here * @see #vid - * @see #aid + * @see #aid * @see #width * @see #height * @see #fps @@ -530,7 +530,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { * @see #vcodec */ protected abstract void initStreamImpl(int vid, int aid) throws Exception; - + @Override public final StreamException getStreamException() { synchronized( stateLock ) { @@ -541,26 +541,26 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } - + @Override public final void initGL(GL gl) throws IllegalStateException, StreamException, GLException { synchronized( stateLock ) { if(State.Initialized != state ) { throw new IllegalStateException("Stream not in state initialized: "+this); - } + } final StreamException streamInitErr = streamWorker.getStreamErr(); if( null != streamInitErr ) { streamWorker = null; // already terminated! destroy(null); throw streamInitErr; } - try { + try { if( STREAM_ID_NONE != vid ) { removeAllTextureFrames(gl); initGLImpl(gl); if(DEBUG) { System.err.println("initGLImpl.X "+this); - } + } videoFramesOrig = createTexFrames(gl, textureCount); videoFramesFree = new LFRingbuffer(videoFramesOrig); videoFramesDecoded = new LFRingbuffer(TextureFrame[].class, textureCount); @@ -583,7 +583,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } - /** + /** * Shall initialize all GL related resources, if not audio-only. *

        * Shall also take care of {@link AudioSink} initialization if appropriate. @@ -593,8 +593,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { * @throws GLException */ protected abstract void initGLImpl(GL gl) throws IOException, GLException; - - /** + + /** * Returns the validated number of textures to be handled. *

        * Default is {@link #TEXTURE_COUNT_MIN} minimum textures. @@ -606,7 +606,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected int validateTextureCount(int desiredTextureCount) { return desiredTextureCount < TEXTURE_COUNT_MIN ? TEXTURE_COUNT_MIN : desiredTextureCount; } - + protected TextureFrame[] createTexFrames(GL gl, final int count) { final int[] texNames = new int[count]; gl.glGenTextures(count, texNames, 0); @@ -621,7 +621,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { return texFrames; } protected abstract TextureFrame createTexImage(GL gl, int texName); - + protected final Texture createTexImageImpl(GL gl, int texName, int tWidth, int tHeight) { if( 0 > texName ) { throw new RuntimeException("TextureName "+toHexString(texName)+" invalid."); @@ -661,19 +661,19 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MIN_FILTER, texMinMagFilter[0]); - gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MAG_FILTER, texMinMagFilter[1]); + gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MAG_FILTER, texMinMagFilter[1]); gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, texWrapST[0]); gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, texWrapST[1]); - + return com.jogamp.opengl.util.texture.TextureIO.newTexture( texName, textureTarget, tWidth, tHeight, width, height, - !isInGLOrientation); + !isInGLOrientation); } - + protected void destroyTexFrame(GL gl, TextureFrame frame) { - frame.getTexture().destroy(gl); + frame.getTexture().destroy(gl); } @Override @@ -683,7 +683,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } return lastFrame; } - + private final void removeAllTextureFrames(GL gl) { final TextureFrame[] texFrames = videoFramesOrig; videoFramesOrig = null; @@ -699,14 +699,14 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } texFrames[i] = null; } - System.err.println(Thread.currentThread().getName()+"> Clear TexFrame["+i+"]: "+frame+" -> null"); - } + System.err.println(Thread.currentThread().getName()+"> Clear TexFrame["+i+"]: "+frame+" -> null"); + } } } - + protected TextureFrame cachedFrame = null; protected long lastTimeMillis = 0; - + @Override public final TextureFrame getNextTexture(GL gl) throws IllegalStateException { synchronized( stateLock ) { @@ -750,7 +750,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } else { d_apts = 0; } - + final int frame_period_last = video_pts - video_pts_last; // rendering loop interrupted ? if( videoSCR_reset || frame_period_last > frame_duration*10 ) { videoSCR_reset = false; @@ -782,7 +782,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { cachedFrame = nextFrame; nextFrame = null; } else if ( !droppedFrame && dt < -maxVideoDelay && videoFramesDecoded.size() > 0 ) { - // only drop if prev. frame has not been dropped and + // only drop if prev. frame has not been dropped and // frame is too late and one decoded frame is already available. dropFrame = true; } @@ -791,7 +791,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { System.err.println( "AV_: dT "+(currentTimeMillis-lastTimeMillis)+", "+ getPerfStringImpl( video_scr, video_pts, d_vpts, audio_scr, audio_pts, d_apts, - video_dpts_avg_diff ) + + video_dpts_avg_diff ) + ", avg dpy-fps "+avg_dpy_duration+" ms/f, maxD "+maxVideoDelay+" ms, "+_nextFrame+", playCached " + playCached + ", dropFrame "+dropFrame); } } @@ -803,7 +803,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { lastFrame = nextFrame; videoFramesFree.putBlocking(_lastFrame); } - } else if( DEBUG ) { + } else if( DEBUG ) { final int video_pts = lastFrame.getPTS(); final int audio_pts = getAudioPTSImpl(); final int audio_scr = (int) ( ( currentTimeMillis - audio_scr_t0 ) * playSpeed ); @@ -835,25 +835,25 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { * Audio frames, i.e. {@link AudioSink.AudioFrame}, shall be handled in the process. *

        * Video frames shall be ignored, if {@link #getVID()} is {@link #STREAM_ID_NONE}. - *

        + *

        *

        * Audio frames shall be ignored, if {@link #getAID()} is {@link #STREAM_ID_NONE}. *

        *

        * Method may be invoked on the StreamWorker decoding thread. - *

        + *

        *

        * Implementation shall care of OpenGL synchronization as required, e.g. glFinish()/glFlush()! *

        - * @param gl valid and current GL instance, shall be null for audio only. + * @param gl valid and current GL instance, shall be null for audio only. * @param nextFrame the {@link TextureFrame} to store the video PTS and texture data, * shall be null for audio only. * @return the last processed video PTS value, maybe {@link TimeFrameI#INVALID_PTS} if video frame is invalid or n/a. - * Will be {@link TimeFrameI#END_OF_STREAM_PTS} if end of stream reached. + * Will be {@link TimeFrameI#END_OF_STREAM_PTS} if end of stream reached. */ protected abstract int getNextTextureImpl(GL gl, TextureFrame nextFrame); - - /** + + /** * {@inheritDoc} *

        * Note: All {@link AudioSink} operations are performed from {@link GLMediaPlayerImpl}, @@ -866,8 +866,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { */ @Override public final AudioSink getAudioSink() { return audioSink; } - - /** + + /** * To be called from implementation at 1st PTS after start * w/ current pts value in milliseconds. * @param audio_scr_t0 @@ -908,10 +908,10 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private final int getVideoDPTSAvg() { return (int) ( video_dpts_cum * (1.0f - VIDEO_DPTS_COEFF) + 0.5f ); } - + private final void newFrameAvailable(TextureFrame frame, long currentTimeMillis) { decodedFrameCount++; - if( 0 == frame.getDuration() ) { // patch frame duration if not set already + if( 0 == frame.getDuration() ) { // patch frame duration if not set already frame.setDuration( (int) frame_duration ); } synchronized(eventListenersLock) { @@ -920,38 +920,38 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } - + class StreamWorker extends Thread { private volatile boolean isRunning = false; private volatile boolean isActive = false; private volatile boolean isBlocked = false; - + private volatile boolean shallPause = true; private volatile boolean shallStop = false; - + private volatile StreamException streamErr = null; private volatile GLContext sharedGLCtx = null; private boolean sharedGLCtxCurrent = false; private GLDrawable dummyDrawable = null; - - /** - * Starts this daemon thread, + + /** + * Starts this daemon thread, * which initializes the stream first via {@link GLMediaPlayerImpl#initStreamImpl(int, int)} first. *

        * After stream initialization, this thread pauses! *

        - **/ + **/ StreamWorker() { setDaemon(true); start(); } - + private void makeCurrent(GLContext ctx) { if( GLContext.CONTEXT_NOT_CURRENT >= ctx.makeCurrent() ) { throw new GLException("Couldn't make ctx current: "+ctx); } } - + private void destroySharedGL() { if( null != sharedGLCtx ) { if( sharedGLCtx.isCreated() ) { @@ -963,16 +963,16 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { gle.printStackTrace(); } } - sharedGLCtx = null; + sharedGLCtx = null; } if( null != dummyDrawable ) { final AbstractGraphicsDevice device = dummyDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); dummyDrawable.setRealized(false); dummyDrawable = null; device.close(); - } + } } - + public synchronized void initGL(GL gl) { final GLContext glCtx = gl.getContext(); final boolean glCtxCurrent = glCtx.isCurrent(); @@ -1013,7 +1013,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { while( !isActive ) { this.notify(); // wake-up pause-block try { - this.wait(); // wait until resumed + this.wait(); // wait until resumed } catch (InterruptedException e) { e.printStackTrace(); } @@ -1041,12 +1041,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } public boolean isRunning() { return isRunning; } public boolean isActive() { return isActive; } - public StreamException getStreamErr() { return streamErr; } - + public StreamException getStreamErr() { return streamErr; } + public void run() { setName(getName()+"-StreamWorker_"+StreamWorkerInstanceId); StreamWorkerInstanceId++; - + synchronized ( this ) { isRunning = true; try { @@ -1061,7 +1061,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { return; // end of thread! } // also initializes width, height, .. etc } - + while( !shallStop ){ if( shallPause ) { synchronized ( this ) { @@ -1100,7 +1100,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } - + if( !shallStop ) { TextureFrame nextFrame = null; try { @@ -1121,7 +1121,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { Thread.sleep(STREAM_WORKER_DELAY); } if( !videoFramesDecoded.put(nextFrame) ) { - throw new InternalError("XXX: free "+videoFramesFree+", decoded "+videoFramesDecoded+", "+GLMediaPlayerImpl.this); + throw new InternalError("XXX: free "+videoFramesFree+", decoded "+videoFramesDecoded+", "+GLMediaPlayerImpl.this); } newFrameAvailable(nextFrame, Platform.currentTimeMillis()); nextFrame = null; @@ -1170,10 +1170,10 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { this.notify(); // wake-up doStop() } } - } - static int StreamWorkerInstanceId = 0; + } + static int StreamWorkerInstanceId = 0; private StreamWorker streamWorker = null; - + protected final int addStateEventMask(int event_mask, State newState) { if( state != newState ) { switch( newState ) { @@ -1193,7 +1193,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } return event_mask; } - + protected final void attributesUpdated(int event_mask) { if( 0 != event_mask ) { final long now = Platform.currentTimeMillis(); @@ -1204,7 +1204,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } - + protected final void changeState(int event_mask, State newState) { event_mask = addStateEventMask(event_mask, newState); if( 0 != event_mask ) { @@ -1212,9 +1212,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { attributesUpdated( event_mask ); } } - - protected final void updateAttributes(int vid, int aid, int width, int height, int bps_stream, - int bps_video, int bps_audio, float fps, + + protected final void updateAttributes(int vid, int aid, int width, int height, int bps_stream, + int bps_video, int bps_audio, float fps, int videoFrames, int audioFrames, int duration, String vcodec, String acodec) { int event_mask = 0; if( state == State.Uninitialized ) { @@ -1227,19 +1227,19 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( this.vid != vid ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_VID; this.vid = vid; - } + } if( STREAM_ID_AUTO == vid ) { vid = STREAM_ID_NONE; } if( this.aid != aid ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_AID; this.aid = aid; - } + } if( this.width != width || this.height != height ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_SIZE; this.width = width; this.height = height; - } + } if( this.fps != fps ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_FPS; this.fps = fps; @@ -1257,7 +1257,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { this.audioFrames = audioFrames; this.duration = duration; } - if( (null!=acodec && acodec.length()>0 && !this.acodec.equals(acodec)) ) { + if( (null!=acodec && acodec.length()>0 && !this.acodec.equals(acodec)) ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_CODEC; this.acodec = acodec; } @@ -1283,7 +1283,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { attributesUpdated(GLMediaEventListener.EVENT_CHANGE_SIZE); } } - + @Override public final URI getURI() { return streamLoc; @@ -1291,10 +1291,10 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public final int getVID() { return vid; } - + @Override public final int getAID() { return aid; } - + @Override public final String getVideoCodec() { return vcodec; @@ -1309,7 +1309,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final int getVideoFrames() { return videoFrames; } - + @Override public final int getAudioFrames() { return audioFrames; @@ -1319,7 +1319,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final int getDuration() { return duration; } - + @Override public final long getStreamBitrate() { return bps_stream; @@ -1329,12 +1329,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final int getVideoBitrate() { return bps_video; } - + @Override public final int getAudioBitrate() { return bps_audio; } - + @Override public final float getFramerate() { return fps; @@ -1344,7 +1344,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final boolean isGLOriented() { return isInGLOrientation; } - + @Override public final int getWidth() { return width; @@ -1369,11 +1369,11 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { "Video[id "+vid+", <"+vcodec+">, "+width+"x"+height+", glOrient "+isInGLOrientation+", "+fps+" fps, "+frame_duration+" fdur, "+bps_video+" bps], "+ "Audio[id "+aid+", <"+acodec+">, "+bps_audio+" bps, "+audioFrames+" frames], uri "+loc+camPath+"]"; } - + @Override public final String getPerfString() { final long currentTimeMillis = Platform.currentTimeMillis(); - final int video_scr = video_scr_pts + (int) ( ( currentTimeMillis - video_scr_t0 ) * playSpeed ); + final int video_scr = video_scr_pts + (int) ( ( currentTimeMillis - video_scr_t0 ) * playSpeed ); final int d_vpts = video_pts_last - video_scr; final int audio_scr = (int) ( ( currentTimeMillis - audio_scr_t0 ) * playSpeed ); final int audio_pts = getAudioPTSImpl(); @@ -1383,7 +1383,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private final String getPerfStringImpl(final int video_scr, final int video_pts, final int d_vpts, final int audio_scr, final int audio_pts, final int d_apts, final int video_dpts_avg_diff) { - final float tt = getDuration() / 1000.0f; + final float tt = getDuration() / 1000.0f; final String audioSinkInfo; final AudioSink audioSink = getAudioSink(); if( null != audioSink ) { diff --git a/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java b/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java index 85fab96a4..6e006d9c0 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java +++ b/src/jogl/classes/jogamp/opengl/util/av/JavaSoundAudioSink.java @@ -22,75 +22,75 @@ public class JavaSoundAudioSink implements AudioSink { public static final int BUFFER_SIZE = 1000; public static final int SAMPLES_PER_BUFFER = BUFFER_SIZE / 2; private static final boolean staticAvailable; - + // Sample time values // public static final double SAMPLE_TIME_IN_SECS = 1.0 / DEFAULT_SAMPLE_RATE; // public static final double BUFFER_TIME_IN_SECS = SAMPLE_TIME_IN_SECS * SAMPLES_PER_BUFFER; - + private javax.sound.sampled.AudioFormat format; private DataLine.Info info; private SourceDataLine auline; private int bufferCount; - private byte [] sampleData = new byte[BUFFER_SIZE]; + private byte [] sampleData = new byte[BUFFER_SIZE]; private boolean initialized = false; private AudioSink.AudioFormat chosenFormat = null; - + private volatile boolean playRequested = false; private float volume = 1.0f; - + static { boolean ok = false; try { AudioSystem.getAudioFileTypes(); ok = true; } catch (Throwable t) { - + } staticAvailable=ok; - } - + } + @Override public String toString() { return "JavaSoundSink[init "+initialized+", dataLine "+info+", source "+auline+", bufferCount "+bufferCount+ ", chosen "+chosenFormat+", jsFormat "+format; } - + @Override public final float getPlaySpeed() { return 1.0f; } // FIXME - + @Override - public final boolean setPlaySpeed(float rate) { - return false; // FIXME + public final boolean setPlaySpeed(float rate) { + return false; // FIXME } - + @Override public final float getVolume() { // FIXME - return volume; + return volume; } - + @Override public final boolean setVolume(float v) { // FIXME volume = v; return true; } - + @Override public AudioSink.AudioFormat getPreferredFormat() { return DefaultFormat; } - + @Override public final int getMaxSupportedChannels() { return 2; } - + @Override public final boolean isSupported(AudioSink.AudioFormat format) { return true; } - + @Override public boolean init(AudioSink.AudioFormat requestedFormat, float frameDuration, int initialQueueSize, int queueGrowAmount, int queueLimit) { if( !staticAvailable ) { @@ -117,12 +117,12 @@ public class JavaSoundAudioSink implements AudioSink { } return true; } - + @Override public boolean isPlaying() { return playRequested && auline.isRunning(); } - + @Override public void play() { if( null != auline ) { @@ -135,7 +135,7 @@ public class JavaSoundAudioSink implements AudioSink { auline.start(); } } - + @Override public void pause() { if( null != auline ) { @@ -143,9 +143,9 @@ public class JavaSoundAudioSink implements AudioSink { auline.stop(); } } - + @Override - public void flush() { + public void flush() { if( null != auline ) { playRequested = false; auline.stop(); @@ -157,17 +157,17 @@ public class JavaSoundAudioSink implements AudioSink { public final int getEnqueuedFrameCount() { return 0; // FIXME } - + @Override public int getFrameCount() { return 1; } - + @Override public int getQueuedFrameCount() { return 0; } - + @Override public boolean isInitialized() { return initialized; @@ -179,7 +179,7 @@ public class JavaSoundAudioSink implements AudioSink { chosenFormat = null; // FIXEM: complete code! } - + @Override public AudioFrame enqueueData(AudioDataFrame audioDataFrame) { int byteSize = audioDataFrame.getByteSize(); @@ -188,7 +188,7 @@ public class JavaSoundAudioSink implements AudioSink { final int p = byteBuffer.position(); byteBuffer.get(bytes, 0, byteSize); byteBuffer.position(p); - + int written = 0; int len; while (byteSize > 0) { @@ -203,27 +203,27 @@ public class JavaSoundAudioSink implements AudioSink { @Override public AudioFrame enqueueData(int pts, ByteBuffer bytes, int byteCount) { return enqueueData(new AudioDataFrame(pts, chosenFormat.getBytesDuration(byteCount), bytes, byteCount)); - } - + } + @Override public int getQueuedByteCount() { return auline.getBufferSize() - auline.available(); } - + @Override public int getFreeFrameCount() { return auline.available(); } - + @Override public int getQueuedTime() { return getQueuedTimeImpl( getQueuedByteCount() ); } private final int getQueuedTimeImpl(int byteCount) { final int bytesPerSample = chosenFormat.sampleSize >>> 3; // /8 - return byteCount / ( chosenFormat.channelCount * bytesPerSample * ( chosenFormat.sampleRate / 1000 ) ); + return byteCount / ( chosenFormat.channelCount * bytesPerSample * ( chosenFormat.sampleRate / 1000 ) ); } @Override - public final int getPTS() { return 0; } // FIXME + public final int getPTS() { return 0; } // FIXME } diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java b/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java index 723bb9dd1..8d3dbdf44 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java @@ -15,32 +15,32 @@ public class NullAudioSink implements AudioSink { private volatile float playSpeed = 1.0f; private volatile boolean playRequested = false; private float volume = 1.0f; - + @Override public final float getPlaySpeed() { return playSpeed; } - + @Override - public final boolean setPlaySpeed(float rate) { + public final boolean setPlaySpeed(float rate) { if( Math.abs(1.0f - rate) < 0.01f ) { rate = 1.0f; } - playSpeed = rate; + playSpeed = rate; return true; } - + @Override public final float getVolume() { // FIXME - return volume; + return volume; } - + @Override public final boolean setVolume(float v) { // FIXME - volume = v; + volume = v; return true; } - + @Override public AudioFormat getPreferredFormat() { return DefaultFormat; @@ -50,73 +50,73 @@ public class NullAudioSink implements AudioSink { public final int getMaxSupportedChannels() { return 8; } - + @Override public final boolean isSupported(AudioFormat format) { return true; } - + @Override public boolean init(AudioFormat requestedFormat, float frameDuration, int initialQueueSize, int queueGrowAmount, int queueLimit) { return true; } - + @Override public boolean isPlaying() { return playRequested; } - + @Override public void play() { playRequested = true; } - + @Override public void pause() { playRequested = false; } - + @Override - public void flush() { + public void flush() { } - + @Override public void destroy() { } - + @Override public final int getEnqueuedFrameCount() { return 0; } - + @Override public int getFrameCount() { return 0; } - + @Override public int getQueuedFrameCount() { return 0; } - + @Override public int getQueuedByteCount() { return 0; } - + @Override public int getQueuedTime() { return 0; } - + @Override public final int getPTS() { return 0; } - + @Override public int getFreeFrameCount() { - return 1; + return 1; } - + @Override public AudioFrame enqueueData(AudioDataFrame audioDataFrame) { return null; @@ -125,5 +125,5 @@ public class NullAudioSink implements AudioSink { @Override public AudioFrame enqueueData(int pts, ByteBuffer bytes, int byteCount) { return null; - } + } } diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java index 1cddaa9cf..840149272 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -54,10 +54,10 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { private TextureData texData = null; private int pos_ms = 0; private long pos_start = 0; - + public NullGLMediaPlayer() { super(); - + } @Override @@ -82,16 +82,16 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { validatePos(); return pos_ms; } - + @Override protected final int getNextTextureImpl(GL gl, TextureFrame nextFrame) { final int pts = getAudioPTSImpl(); nextFrame.setPTS( pts ); return pts; } - + @Override - protected final int getAudioPTSImpl() { + protected final int getAudioPTSImpl() { pos_ms = (int) ( Platform.currentTimeMillis() - pos_start ); validatePos(); return pos_ms; @@ -102,9 +102,9 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { if(null != texData) { texData.destroy(); texData = null; - } + } } - + public final static TextureData createTestTextureData() { TextureData res = null; try { @@ -125,28 +125,28 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { buffer.rewind(); res = new TextureData(GLProfile.getGL2ES2(), GL.GL_RGBA, w, h, 0, - GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, false, + GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, false, false, false, buffer, null); } return res; } - + @Override protected final void initStreamImpl(int vid, int aid) throws IOException { texData = createTestTextureData(); final float _fps = 24f; final int _duration = 10*60*1000; // msec final int _totalFrames = (int) ( (_duration/1000)*_fps ); - updateAttributes(0 /* fake */, GLMediaPlayer.STREAM_ID_NONE, - texData.getWidth(), texData.getHeight(), 0, - 0, 0, _fps, + updateAttributes(0 /* fake */, GLMediaPlayer.STREAM_ID_NONE, + texData.getWidth(), texData.getHeight(), 0, + 0, 0, _fps, _totalFrames, 0, _duration, "png-static", null); - } + } @Override protected final void initGLImpl(GL gl) throws IOException, GLException { isInGLOrientation = true; } - + /** * {@inheritDoc} *

        @@ -157,21 +157,21 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { protected int validateTextureCount(int desiredTextureCount) { return 2; } - + @Override protected final TextureSequence.TextureFrame createTexImage(GL gl, int texName) { final Texture texture = super.createTexImageImpl(gl, texName, width, height); if(null != texData) { texture.updateImage(gl, texData); - } + } return new TextureSequence.TextureFrame( texture ); } - + @Override protected final void destroyTexFrame(GL gl, TextureSequence.TextureFrame frame) { super.destroyTexFrame(gl, frame); } - + private void validatePos() { boolean considerPausing = false; if( 0 > pos_ms) { diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java index 146a47ebc..390c20346 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl.util.av.impl; import java.security.AccessController; @@ -48,9 +48,9 @@ import com.jogamp.common.util.VersionNumber; */ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { private static final boolean DEBUG = FFMPEGMediaPlayer.DEBUG || DynamicLibraryBundleInfo.DEBUG; - + private static final List glueLibNames = new ArrayList(); // none - + private static final int symbolCount = 65; private static final String[] symbolNames = { "avutil_version", @@ -61,10 +61,10 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { // libavcodec "avcodec_register_all", - "avcodec_close", - "avcodec_string", - "avcodec_find_decoder", - "avcodec_open2", // 53.6.0 (opt) + "avcodec_close", + "avcodec_string", + "avcodec_find_decoder", + "avcodec_open2", // 53.6.0 (opt) "avcodec_alloc_frame", "avcodec_get_frame_defaults", "avcodec_free_frame", // 54.28.0 (opt) @@ -79,10 +79,10 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "av_init_packet", "av_new_packet", "av_destruct_packet", - "av_free_packet", + "av_free_packet", "avcodec_decode_audio4", // 53.25.0 (opt) /* 27 */ "avcodec_decode_video2", // 52.23.0 - + // libavutil "av_pix_fmt_descriptors", "av_frame_unref", // 55.0.0 (opt) @@ -101,10 +101,10 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avformat_alloc_context", "avformat_free_context", // 52.96.0 (opt) "avformat_close_input", // 53.17.0 (opt) - "av_register_all", + "av_register_all", "av_find_input_format", - "avformat_open_input", - "av_dump_format", + "avformat_open_input", + "av_dump_format", "av_read_frame", "av_seek_frame", "avformat_seek_file", // ??? (opt) @@ -115,24 +115,24 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { /* 54 */ "avformat_find_stream_info", // 53.3.0 (opt) // libavdevice -/* 55 */ "avdevice_register_all", // ??? - +/* 55 */ "avdevice_register_all", // ??? + // libavresample "avresample_alloc_context", // 1.0.1 "avresample_open", "avresample_close", "avresample_free", /* 60 */ "avresample_convert", - + // libavresample "av_opt_set_sample_fmt", // actually lavu .. but exist only w/ swresample! "swr_alloc", - "swr_init", + "swr_init", "swr_free", /* 65 */ "swr_convert", }; - + // optional symbol names private static final String[] optionalSymbolNames = { "avformat_seek_file", // ??? (opt) @@ -145,7 +145,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { // libavdevice "avdevice_register_all", // 53.0.0 (opt) - + // libavresample "avresample_version", // 1.0.1 "avresample_alloc_context", // 1.0.1 @@ -153,43 +153,43 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avresample_close", "avresample_free", "avresample_convert", - + // libavresample "av_opt_set_sample_fmt", // actually lavu .. but exist only w/ swresample! "swresample_version", // 0 "swr_alloc", - "swr_init", + "swr_init", "swr_free", "swr_convert", }; - + private static final long[] symbolAddr = new long[symbolCount]; private static final boolean ready; private static final boolean libsUFCLoaded; private static final boolean avresampleLoaded; // optional private static final boolean swresampleLoaded; // optional private static final boolean avdeviceLoaded; // optional - static final VersionNumber avCodecVersion; + static final VersionNumber avCodecVersion; static final VersionNumber avFormatVersion; static final VersionNumber avUtilVersion; static final VersionNumber avResampleVersion; static final VersionNumber swResampleVersion; private static final FFMPEGNatives natives; - + private static final int LIB_IDX_UTI = 0; private static final int LIB_IDX_FMT = 1; private static final int LIB_IDX_COD = 2; private static final int LIB_IDX_DEV = 3; private static final int LIB_IDX_AVR = 4; private static final int LIB_IDX_SWR = 5; - + static { - // native ffmpeg media player implementation is included in jogl_desktop and jogl_mobile + // native ffmpeg media player implementation is included in jogl_desktop and jogl_mobile GLProfile.initSingleton(); boolean _ready = false; - /** util, format, codec, device, avresample, swresample */ - boolean[] _loaded= new boolean[6]; - /** util, format, codec, avresample, swresample */ + /** util, format, codec, device, avresample, swresample */ + boolean[] _loaded= new boolean[6]; + /** util, format, codec, avresample, swresample */ VersionNumber[] _versions = new VersionNumber[5]; try { _ready = initSymbols(_loaded, _versions); @@ -226,7 +226,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { } else { System.err.println("LIB_AV No Version/Native-Impl Match"); natives = null; - } + } if( null != natives && FFMPEGStaticNatives.initIDs0() ) { ready = natives.initSymbols0(symbolAddr, symbolCount); } else { @@ -234,7 +234,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { } } } - + static boolean libsLoaded() { return libsUFCLoaded; } static boolean avDeviceLoaded() { return avdeviceLoaded; } static boolean avResampleLoaded() { return avresampleLoaded; } @@ -265,11 +265,11 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { if(symbolNames.length != symbolCount) { throw new InternalError("XXX0 "+symbolNames.length+" != "+symbolCount); } - + // optional symbol name set final Set optionalSymbolNameSet = new HashSet(); optionalSymbolNameSet.addAll(Arrays.asList(optionalSymbolNames)); - + // lookup AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -278,9 +278,9 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { } return null; } } ); - + // validate results - boolean res = true; + boolean res = true; for(int i = 0; i * Returns true. *

        - */ + */ @Override public final boolean shallLookupGlobal() { - return true; + return true; } - + @Override public final List getGlueLibNames() { return glueLibNames; @@ -329,7 +329,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { List> libsList = new ArrayList>(); // 6: util, format, codec, device, avresample, swresample - + final List avutil = new ArrayList(); avutil.add("avutil"); // default @@ -337,13 +337,13 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { avutil.add("libavutil.so.52"); // ffmpeg 1.2 + 2 / libav 9 + 10 avutil.add("libavutil.so.51"); // 0.8 avutil.add("libavutil.so.50"); // 0.7 - + avutil.add("avutil-53"); // dummy future proof avutil.add("avutil-52"); // ffmpeg 1.2 + 2 / libav 9 + 10 avutil.add("avutil-51"); // 0.8 avutil.add("avutil-50"); // 0.7 libsList.add(avutil); - + final List avformat = new ArrayList(); avformat.add("avformat"); // default @@ -352,14 +352,14 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { avformat.add("libavformat.so.54"); // ffmpeg 1.2 / libav 9 avformat.add("libavformat.so.53"); // 0.8 avformat.add("libavformat.so.52"); // 0.7 - + avformat.add("avformat-56"); // dummy future proof avformat.add("avformat-55"); // ffmpeg 2 / libav 10 avformat.add("avformat-54"); // ffmpeg 1.2 / libav 9 avformat.add("avformat-53"); // 0.8 - avformat.add("avformat-52"); // 0.7 + avformat.add("avformat-52"); // 0.7 libsList.add(avformat); - + final List avcodec = new ArrayList(); avcodec.add("avcodec"); // default @@ -367,15 +367,15 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { avcodec.add("libavcodec.so.55"); // ffmpeg 2/ libav 10 avcodec.add("libavcodec.so.54"); // ffmpeg 1.2 / libav 9 avcodec.add("libavcodec.so.53"); // 0.8 - avcodec.add("libavcodec.so.52"); // 0.7 - + avcodec.add("libavcodec.so.52"); // 0.7 + avcodec.add("avcodec-56"); // dummy future proof avcodec.add("avcodec-55"); // ffmpeg 2/ libav 10 avcodec.add("avcodec-54"); // ffmpeg 1.2 / libav 9 avcodec.add("avcodec-53"); // 0.8 - avcodec.add("avcodec-52"); // 0.7 + avcodec.add("avcodec-52"); // 0.7 libsList.add(avcodec); - + final List avdevice = new ArrayList(); avdevice.add("avdevice"); // default @@ -383,19 +383,19 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { avdevice.add("libavdevice.so.55"); // ffmpeg 2 avdevice.add("libavdevice.so.54"); // ffmpeg 1.2 / libav 10 avdevice.add("libavdevice.so.53"); // 0.8 && libav 9 - + avdevice.add("avdevice-56"); // dummy future proof avdevice.add("avdevice-55"); // ffmpeg 2 avdevice.add("avdevice-54"); // ffmpeg 1.2 / libav 10 avdevice.add("avdevice-53"); // 0.8 && libav 9 libsList.add(avdevice); - + final List avresample = new ArrayList(); avresample.add("avresample"); // default avresample.add("libavresample.so.2"); // dummy future proof avresample.add("libavresample.so.1"); // libav 9 + 10 - + avresample.add("avresample-2"); // dummy future proof avresample.add("avresample-1"); // libav 9 + 10 libsList.add(avresample); @@ -405,11 +405,11 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { swresample.add("libswresample.so.1"); // dummy future proof swresample.add("libswresample.so.0"); // ffmpeg 1.2 + 2.x - + swresample.add("swresample-1"); // dummy future proof swresample.add("swresample-0"); // ffmpeg 1.2 + 2.x libsList.add(swresample); - + return libsList; } @@ -431,5 +431,5 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { @Override public final RunnableExecutor getLibLoaderExecutor() { return DynamicLibraryBundle.getDefaultRunnableExecutor(); - } + } } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index f196ebef1..2abd73181 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -65,18 +65,18 @@ import jogamp.opengl.util.av.impl.FFMPEGNatives.SampleFormat; * Besides the default BSD/Linux/.. repositories and installations, * precompiled binaries can be found at the * listed location below. - *

        - * + *

        + * *
        Implementation specifics
        *

        - * The decoded video frame is written directly into an OpenGL texture - * on the GPU in it's native format. A custom fragment shader converts - * the native pixelformat to a usable RGB format if required. - * Hence only 1 copy is required before bloating the picture + * The decoded video frame is written directly into an OpenGL texture + * on the GPU in it's native format. A custom fragment shader converts + * the native pixelformat to a usable RGB format if required. + * Hence only 1 copy is required before bloating the picture * from YUV* to RGB, for example. - *

        + *

        *

        - * Implements pixel format conversion to RGB via + * Implements pixel format conversion to RGB via * fragment shader texture-lookup functions: *

          *
        • {@link PixelFormat#YUV420P}
        • @@ -88,10 +88,10 @@ import jogamp.opengl.util.av.impl.FFMPEGNatives.SampleFormat; *
        *

        *

        - * + * *

        Libav Specifics
        *

        - * Utilizes a slim dynamic and native binding to the Lib_av + * Utilizes a slim dynamic and native binding to the Lib_av * libraries: *

          *
        • libavcodec
        • @@ -99,9 +99,9 @@ import jogamp.opengl.util.av.impl.FFMPEGNatives.SampleFormat; *
        • libavutil
        • *
        • libavresample (opt)
        • *
        • libavdevice (opt)
        • - *
        + * *

        - * + * *
        LibAV Compatibility
        *

        * Currently we are binary compatible w/: @@ -115,25 +115,25 @@ import jogamp.opengl.util.av.impl.FFMPEGNatives.SampleFormat; *

        * See http://upstream-tracker.org/versions/libav.html *

        - *

        - * Check tag 'FIXME: Add more planar formats !' + *

        + * Check tag 'FIXME: Add more planar formats !' * here and in the corresponding native code * jogl/src/jogl/native/libav/ffmpeg_impl_template.c *

        - * - * + * + * *
        TODO:
        *

        *

          *
        • better audio synchronization handling? (video is synchronized)
        • - *
        + * *

        - * + * *
        FFMPEG / LibAV Availability
        *

        *

          *
        • GNU/Linux: ffmpeg or libav are deployed in most distributions.
        • - *
        • Windows: + *
        • Windows: *
            *
          • http://ffmpeg.zeranoe.com/builds/ (ffmpeg) recommended, works w/ dshow
          • *
          • http://win32.libav.org/releases/ (libav)
          • @@ -144,22 +144,22 @@ import jogamp.opengl.util.av.impl.FFMPEGNatives.SampleFormat; * pkt install pkg:/video/ffmpeg * *
          - *

          + *

          */ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { /** POSIX ENOSYS {@value}: Function not implemented. FIXME: Move to GlueGen ?!*/ private static final int ENOSYS = 38; - + // Instance data private static final FFMPEGNatives natives; private static final int avUtilMajorVersionCC; private static final int avFormatMajorVersionCC; - private static final int avCodecMajorVersionCC; + private static final int avCodecMajorVersionCC; private static final int avResampleMajorVersionCC; private static final int swResampleMajorVersionCC; private static final boolean available; - + static { final boolean libAVGood = FFMPEGDynamicLibraryBundleInfo.initSingleton(); final boolean libAVVersionGood; @@ -171,7 +171,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { avUtilMajorVersionCC = natives.getAvUtilMajorVersionCC0(); avResampleMajorVersionCC = natives.getAvResampleMajorVersionCC0(); swResampleMajorVersionCC = natives.getSwResampleMajorVersionCC0(); - } else { + } else { avUtilMajorVersionCC = 0; avFormatMajorVersionCC = 0; avCodecMajorVersionCC = 0; @@ -211,25 +211,25 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } available = libAVGood && libAVVersionGood && null != natives; } - + public static final boolean isAvailable() { return available; } // // General // - - private long moviePtr = 0; - + + private long moviePtr = 0; + // // Video // - + private String texLookupFuncName = "ffmpegTexture2D"; - private boolean usesTexLookupShader = false; + private boolean usesTexLookupShader = false; private PixelFormat vPixelFmt = null; private int vPlanes = 0; private int vBitsPerPixel = 0; - private int vBytesPerPixelPerPlane = 0; + private int vBytesPerPixelPerPlane = 0; private int texWidth, texHeight; // overall (stuffing planes in one texture) private String singleTexComp = "r"; private GLPixelStorageModes psm; @@ -237,10 +237,10 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { // // Audio // - + private AudioSink.AudioFormat avChosenAudioFormat; private int audioSamplesPerFrameAndChannel = 0; - + public FFMPEGMediaPlayer() { if(!available) { throw new RuntimeException("FFMPEGMediaPlayer not available"); @@ -263,14 +263,14 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } private final void destroyAudioSink() { final AudioSink _audioSink = audioSink; - if( null != _audioSink ) { + if( null != _audioSink ) { audioSink = null; _audioSink.destroy(); } } - + public static final String dev_video_linux = "/dev/video"; - + @Override protected final void initStreamImpl(int vid, int aid) throws IOException { if(0==moviePtr) { @@ -279,7 +279,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { if(DEBUG) { System.err.println("initStream: p1 "+this); } - + final String streamLocS=IOUtil.decodeFromURI(streamLoc.toString()); destroyAudioSink(); if( GLMediaPlayer.STREAM_ID_NONE == aid ) { @@ -291,7 +291,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { if(DEBUG) { System.err.println("initStream: p2 preferred "+preferredAudioFormat+", "+this); } - + final boolean isCameraInput = null != cameraPath; final String resStreamLocS; // int rw=640, rh=480, rr=15; @@ -314,7 +314,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case OPENKODE: default: resStreamLocS = streamLocS; // FIXME: ?? - break; + break; } if( null != cameraProps ) { sizes = cameraProps.get(CameraPropSizeS); @@ -362,7 +362,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { if(DEBUG) { System.err.println("initGL: p3 avChosen "+avChosenAudioFormat); } - + if( STREAM_ID_NONE == aid ) { audioSink.destroy(); audioSink = AudioSinkFactory.createNull(); @@ -386,7 +386,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { System.err.println("initGL: p4 chosen "+avChosenAudioFormat); System.err.println("initGL: p4 chosen "+audioSink); } - + if( null != gl && STREAM_ID_NONE != vid ) { int tf, tif=GL.GL_RGBA; // texture format and internal format int tt = GL.GL_UNSIGNED_BYTE; @@ -413,9 +413,9 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { tf = GL2ES2.GL_BGRA; tif=GL.GL_RGBA; break; } else { tf = GL2ES2.GL_RGBA; tif=GL.GL_RGBA; break; - } + } default: throw new RuntimeException("Unsupported bytes-per-pixel / plane "+vBytesPerPixelPerPlane); - } + } setTextureFormat(tif, tf); setTextureType(tt); if(DEBUG) { @@ -423,12 +423,12 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { ", tex "+texWidth+"x"+texHeight+", usesTexLookupShader "+usesTexLookupShader); } } - } + } @Override protected final TextureFrame createTexImage(GL gl, int texName) { return new TextureFrame( createTexImageImpl(gl, texName, texWidth, texHeight) ); } - + /** * @param sampleRate sample rate in Hz (1/s) * @param sampleSize sample size in bits @@ -439,10 +439,10 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { * @param littleEndian true for little-endian, false for big endian * @return */ - + /** * Native callback - * Converts the given libav/ffmpeg values to {@link AudioFormat} and returns {@link AudioSink#isSupported(AudioFormat)}. + * Converts the given libav/ffmpeg values to {@link AudioFormat} and returns {@link AudioSink#isSupported(AudioFormat)}. * @param audioSampleFmt ffmpeg/libav audio-sample-format, see {@link SampleFormat}. * @param audioSampleRate sample rate in Hz (1/s) * @param audioChannels number of channels @@ -456,9 +456,9 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } return res; } - + /** - * Returns {@link AudioFormat} as converted from the given libav/ffmpeg values. + * Returns {@link AudioFormat} as converted from the given libav/ffmpeg values. * @param audioSampleFmt ffmpeg/libav audio-sample-format, see {@link SampleFormat}. * @param audioSampleRate sample rate in Hz (1/s) * @param audioChannels number of channels @@ -506,7 +506,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } return new AudioFormat(audioSampleRate, sampleSize, audioChannels, signed, fixedP, planar, true /* littleEndian */); } - + /** * Native callback * @param vid @@ -523,9 +523,9 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { * @param audioChannels * @param audioSamplesPerFrameAndChannel in audio samples per frame and channel */ - void setupFFAttributes(int vid, int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, + void setupFFAttributes(int vid, int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, int tWd0, int tWd1, int tWd2, int vW, int vH, - int aid, int audioSampleFmt, int audioSampleRate, + int aid, int audioSampleFmt, int audioSampleRate, int audioChannels, int audioSamplesPerFrameAndChannel) { // defaults .. vPixelFmt = null; @@ -534,28 +534,28 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { vBytesPerPixelPerPlane = 0; usesTexLookupShader = false; texWidth = 0; texHeight = 0; - + final int[] vTexWidth = { 0, 0, 0 }; // per plane - + if( STREAM_ID_NONE != vid ) { vPixelFmt = PixelFormat.valueOf(pixFmt); vPlanes = planes; vBitsPerPixel = bitsPerPixel; - vBytesPerPixelPerPlane = bytesPerPixelPerPlane; + vBytesPerPixelPerPlane = bytesPerPixelPerPlane; vTexWidth[0] = tWd0; vTexWidth[1] = tWd1; vTexWidth[2] = tWd2; - + switch(vPixelFmt) { case YUVJ420P: case YUV420P: // < planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) usesTexLookupShader = true; // YUV420P: Adding U+V on right side of fixed height texture, // since width is already aligned by decoder. - // Splitting texture to 4 quadrants: + // Splitting texture to 4 quadrants: // Y covers left top/low quadrant // U on top-right quadrant. // V on low-right quadrant. // Y=w*h, U=w/2*h/2, V=w/2*h/2 - // w*h + 2 ( w/2 * h/2 ) + // w*h + 2 ( w/2 * h/2 ) // w*h + w*h/2 texWidth = vTexWidth[0] + vTexWidth[1]; texHeight = vH; break; @@ -573,27 +573,27 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case YUYV422: // < packed YUV 4:2:2, 2x 16bpp, Y0 Cb Y1 Cr - stuffed into RGBA half width texture case BGR24: usesTexLookupShader = true; - texWidth = vTexWidth[0]; texHeight = vH; + texWidth = vTexWidth[0]; texHeight = vH; break; - + case RGB24: case ARGB: case RGBA: case ABGR: case BGRA: usesTexLookupShader = false; - texWidth = vTexWidth[0]; texHeight = vH; + texWidth = vTexWidth[0]; texHeight = vH; break; default: // FIXME: Add more formats ! throw new RuntimeException("Unsupported pixelformat: "+vPixelFmt); } } - + // defaults .. final SampleFormat aSampleFmt; avChosenAudioFormat = null;; this.audioSamplesPerFrameAndChannel = 0; - + if( STREAM_ID_NONE != aid ) { aSampleFmt = SampleFormat.valueOf(audioSampleFmt); avChosenAudioFormat = avAudioFormat2Local(aSampleFmt, audioSampleRate, audioChannels); @@ -601,7 +601,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } else { aSampleFmt = null; } - + if(DEBUG) { System.err.println("audio: id "+aid+", fmt "+aSampleFmt+", "+avChosenAudioFormat+", aFrameSize/fc "+audioSamplesPerFrameAndChannel); System.err.println("video: id "+vid+", fmt "+vW+"x"+vH+", "+vPixelFmt+", planes "+vPlanes+", bpp "+vBitsPerPixel+"/"+vBytesPerPixelPerPlane+", usesTexLookupShader "+usesTexLookupShader); @@ -612,7 +612,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { System.err.println(this.toString()); } } - + /** * Native callback * @param isInGLOrientation @@ -624,13 +624,13 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { * @param tWd1 * @param tWd2 */ - void updateVidAttributes(boolean isInGLOrientation, int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, + void updateVidAttributes(boolean isInGLOrientation, int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, int tWd0, int tWd1, int tWd2, int vW, int vH) { } - + /** * {@inheritDoc} - * + * * If this implementation generates a specialized shader, * it allows the user to override the default function name ffmpegTexture2D. * Otherwise the call is delegated to it's super class. @@ -646,15 +646,15 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } return texLookupFuncName; } - return super.getTextureLookupFunctionName(desiredFuncName); + return super.getTextureLookupFunctionName(desiredFuncName); } - + /** * {@inheritDoc} - * + * * Depending on the pixelformat, a specific conversion shader is being created, - * e.g. YUV420P to RGB. Otherwise the call is delegated to it's super class. - */ + * e.g. YUV420P to RGB. Otherwise the call is delegated to it's super class. + */ @Override public final String getTextureLookupFragmentShaderImpl() throws IllegalStateException { if(State.Uninitialized == state) { @@ -685,7 +685,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { " return vec4(r, g, b, 1);\n"+ "}\n" ; - + case YUVJ422P: case YUV422P: ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) return @@ -706,7 +706,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { " return vec4(r, g, b, 1);\n"+ "}\n" ; - + case YUYV422: // < packed YUV 4:2:2, 2 x 16bpp, [Y0 Cb] [Y1 Cr] // Stuffed into RGBA half width texture return @@ -740,9 +740,9 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { default: // FIXME: Add more formats ! throw new InternalError("Add proper mapping of: vPixelFmt "+vPixelFmt+", usesTexLookupShader "+usesTexLookupShader); - } + } } - + @Override public final boolean playImpl() { if(0==moviePtr) { @@ -754,7 +754,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } return true; } - + @Override public final boolean pauseImpl() { if(0==moviePtr) { @@ -780,12 +780,12 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { psm.setUnpackAlignment(gl, 1); // RGBA ? 4 : 1 gl.glActiveTexture(GL.GL_TEXTURE0+getTextureUnit()); } - + @Override protected void postNextTextureImpl(GL gl) { psm.restore(gl); } - + @Override protected final int getNextTextureImpl(GL gl, TextureFrame nextFrame) { if(0==moviePtr) { @@ -806,14 +806,14 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { nextFrame.setPTS(vPTS); } return vPTS; - } - + } + final void pushSound(ByteBuffer sampleData, int data_size, int audio_pts) { setFirstAudioPTS2SCR( audio_pts ); if( 1.0f == playSpeed || audioSinkPlaySpeedSet ) { audioSink.enqueueData( audio_pts, sampleData, data_size); } } - + } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java index 8e08c23fa..bc0865aa9 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -30,21 +30,21 @@ package jogamp.opengl.util.av.impl; import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; interface FFMPEGNatives { - + boolean initSymbols0(long[] symbols, int count); int getAvUtilMajorVersionCC0(); int getAvFormatMajorVersionCC0(); int getAvCodecMajorVersionCC0(); int getAvResampleMajorVersionCC0(); int getSwResampleMajorVersionCC0(); - + long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose); void destroyInstance0(long moviePtr); - + /** * Issues {@link #updateAttributes(int, int, int, int, int, int, int, float, int, int, String, String)} * and {@link #updateAttributes2(int, int, int, int, int, int, int, int, int, int)}. - * + * * @param moviePtr * @param url * @param vid @@ -56,25 +56,25 @@ interface FFMPEGNatives { * @param aPrefSampleRate * @param aPrefChannelCount */ - void setStream0(long moviePtr, String url, boolean isCameraInput, - int vid, String sizes, int vWidth, int vHeight, + void setStream0(long moviePtr, String url, boolean isCameraInput, + int vid, String sizes, int vWidth, int vHeight, int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); - + void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); - int getVideoPTS0(long moviePtr); - + int getVideoPTS0(long moviePtr); + int getAudioPTS0(long moviePtr); - + /** * @return resulting current video PTS, or {@link TextureFrame#INVALID_PTS} */ int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); - + int play0(long moviePtr); int pause0(long moviePtr); int seek0(long moviePtr, int position); - + /** FFMPEG/libAV Audio Sample Format */ public static enum SampleFormat { // NONE = -1, @@ -89,10 +89,10 @@ interface FFMPEGNatives { S32P, ///< signed 32 bits, planar FLTP, ///< float, planar DBLP, ///< double, planar - + COUNT; ///< Number of sample formats. - - /** + + /** * Returns the matching SampleFormat value corresponding to the given SampleFormat's integer ordinal. *
                    *   given:
          @@ -131,7 +131,7 @@ interface FFMPEGNatives {
                   /** planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) */
                   YUV411P,
                   /** Y, 8bpp */
          -        GRAY8,        
          +        GRAY8,
                   /** Y,  1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb */
                   MONOWHITE,
                   /** Y,  1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb */
          @@ -151,57 +151,57 @@ interface FFMPEGNatives {
                   /** packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 */
                   UYVY422,
                   /** packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 */
          -        UYYVYY411, 
          +        UYYVYY411,
                   /** packed RGB 3:3:2,  8bpp, (msb)2B 3G 3R(lsb) */
          -        BGR8, 
          +        BGR8,
                   /** packed RGB 1:2:1 bitstream,  4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits */
          -        BGR4, 
          +        BGR4,
                   /** packed RGB 1:2:1,  8bpp, (msb)1B 2G 1R(lsb) */
          -        BGR4_BYTE, 
          +        BGR4_BYTE,
                   /** packed RGB 3:3:2,  8bpp, (msb)2R 3G 3B(lsb) */
          -        RGB8, 
          +        RGB8,
                   /** packed RGB 1:2:1 bitstream,  4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits */
          -        RGB4, 
          +        RGB4,
                   /** packed RGB 1:2:1,  8bpp, (msb)1R 2G 1B(lsb) */
          -        RGB4_BYTE, 
          +        RGB4_BYTE,
                   /** planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) */
          -        NV12, 
          +        NV12,
                   /** as above, but U and V bytes are swapped */
          -        NV21, 
          +        NV21,
           
                   /** packed ARGB 8:8:8:8, 32bpp, ARGBARGB... */
          -        ARGB, 
          +        ARGB,
                   /** packed RGBA 8:8:8:8, 32bpp, RGBARGBA... */
          -        RGBA, 
          +        RGBA,
                   /** packed ABGR 8:8:8:8, 32bpp, ABGRABGR... */
          -        ABGR, 
          +        ABGR,
                   /** packed BGRA 8:8:8:8, 32bpp, BGRABGRA... */
          -        BGRA, 
          +        BGRA,
           
                   /** Y, 16bpp, big-endian */
          -        GRAY16BE,        
          +        GRAY16BE,
                   /** Y        , 16bpp, little-endian */
          -        GRAY16LE,        
          +        GRAY16LE,
                   /** planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) */
          -        YUV440P, 
          +        YUV440P,
                   /** planar YUV 4:4:0 full scale (JPEG), deprecated in favor of YUV440P and setting color_range */
          -        YUVJ440P, 
          +        YUVJ440P,
                   /** planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples) */
          -        YUVA420P, 
          +        YUVA420P,
                   /** H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */
          -        VDPAU_H264, 
          +        VDPAU_H264,
                   /** MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */
          -        VDPAU_MPEG1, 
          +        VDPAU_MPEG1,
                   /** MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */
          -        VDPAU_MPEG2, 
          +        VDPAU_MPEG2,
                   /** WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */
          -        VDPAU_WMV3, 
          +        VDPAU_WMV3,
                   /** VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */
          -        VDPAU_VC1, 
          +        VDPAU_VC1,
                   /** packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian */
          -        RGB48BE, 
          +        RGB48BE,
                   /** packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian */
          -        RGB48LE, 
          +        RGB48LE,
           
                   RGB565BE,  ///< packed RGB 5:6:5, 16bpp, (msb)   5R 6G 5B(lsb), big-endian
                   RGB565LE,  ///< packed RGB 5:6:5, 16bpp, (msb)   5R 6G 5B(lsb), little-endian
          @@ -255,7 +255,7 @@ interface FFMPEGNatives {
                   GBRP16LE,  ///< planar GBR 4:4:4 48bpp, little endian
                   COUNT      ///< number of pixel formats in this list
                   ;
          -        /** 
          +        /**
                    * Returns the matching PixelFormat value corresponding to the given PixelFormat's integer ordinal.
                    * 
                    *   given:
          diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGStaticNatives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGStaticNatives.java
          index 01c249313..22a045825 100644
          --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGStaticNatives.java
          +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGStaticNatives.java
          @@ -3,14 +3,14 @@
            *
            * Redistribution and use in source and binary forms, with or without modification, are
            * permitted provided that the following conditions are met:
          - * 
          + *
            *    1. Redistributions of source code must retain the above copyright notice, this list of
            *       conditions and the following disclaimer.
          - * 
          + *
            *    2. Redistributions 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.
          - * 
          + *
            * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
            * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
            * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
          @@ -20,7 +20,7 @@
            * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
            * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
            * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
          - * 
          + *
            * The views and conclusions contained in the software and documentation are those of the
            * authors and should not be interpreted as representing official policies, either expressed
            * or implied, of JogAmp Community.
          @@ -29,7 +29,7 @@ package jogamp.opengl.util.av.impl;
           
           import com.jogamp.common.util.VersionNumber;
           
          -class FFMPEGStaticNatives {        
          +class FFMPEGStaticNatives {
               static VersionNumber getAVVersion(int vers) {
                   return new VersionNumber( ( vers >> 16 ) & 0xFF,
                                             ( vers >>  8 ) & 0xFF,
          diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java
          index 22694888d..4b013c1b3 100644
          --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java
          +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java
          @@ -3,14 +3,14 @@
            *
            * Redistribution and use in source and binary forms, with or without modification, are
            * permitted provided that the following conditions are met:
          - * 
          + *
            *    1. Redistributions of source code must retain the above copyright notice, this list of
            *       conditions and the following disclaimer.
          - * 
          + *
            *    2. Redistributions 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.
          - * 
          + *
            * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
            * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
            * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
          @@ -20,7 +20,7 @@
            * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
            * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
            * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
          - * 
          + *
            * The views and conclusions contained in the software and documentation are those of the
            * authors and should not be interpreted as representing official policies, either expressed
            * or implied, of JogAmp Community.
          @@ -45,7 +45,7 @@ class FFMPEGv08Natives implements FFMPEGNatives {
           
               @Override
               public native int getSwResampleMajorVersionCC0();
          -    
          +
               @Override
               public native long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose);
           
          diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java
          index 08e19d5e6..d69763287 100644
          --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java
          +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java
          @@ -3,14 +3,14 @@
            *
            * Redistribution and use in source and binary forms, with or without modification, are
            * permitted provided that the following conditions are met:
          - * 
          + *
            *    1. Redistributions of source code must retain the above copyright notice, this list of
            *       conditions and the following disclaimer.
          - * 
          + *
            *    2. Redistributions 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.
          - * 
          + *
            * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
            * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
            * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
          @@ -20,7 +20,7 @@
            * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
            * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
            * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
          - * 
          + *
            * The views and conclusions contained in the software and documentation are those of the
            * authors and should not be interpreted as representing official policies, either expressed
            * or implied, of JogAmp Community.
          @@ -45,7 +45,7 @@ class FFMPEGv09Natives implements FFMPEGNatives {
           
               @Override
               public native int getSwResampleMajorVersionCC0();
          -    
          +
               @Override
               public native long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose);
           
          diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv10Natives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv10Natives.java
          index 0081743fa..0b5f70d7c 100644
          --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv10Natives.java
          +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv10Natives.java
          @@ -3,14 +3,14 @@
            *
            * Redistribution and use in source and binary forms, with or without modification, are
            * permitted provided that the following conditions are met:
          - * 
          + *
            *    1. Redistributions of source code must retain the above copyright notice, this list of
            *       conditions and the following disclaimer.
          - * 
          + *
            *    2. Redistributions 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.
          - * 
          + *
            * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
            * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
            * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
          @@ -20,7 +20,7 @@
            * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
            * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
            * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
          - * 
          + *
            * The views and conclusions contained in the software and documentation are those of the
            * authors and should not be interpreted as representing official policies, either expressed
            * or implied, of JogAmp Community.
          @@ -45,7 +45,7 @@ class FFMPEGv10Natives implements FFMPEGNatives {
           
               @Override
               public native int getSwResampleMajorVersionCC0();
          -    
          +
               @Override
               public native long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose);
           
          diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java
          index a5a701a4f..24198703a 100644
          --- a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java
          +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java
          @@ -3,14 +3,14 @@
            *
            * Redistribution and use in source and binary forms, with or without modification, are
            * permitted provided that the following conditions are met:
          - * 
          + *
            *    1. Redistributions of source code must retain the above copyright notice, this list of
            *       conditions and the following disclaimer.
          - * 
          + *
            *    2. Redistributions 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.
          - * 
          + *
            * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
            * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
            * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
          @@ -20,7 +20,7 @@
            * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
            * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
            * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
          - * 
          + *
            * The views and conclusions contained in the software and documentation are those of the
            * authors and should not be interpreted as representing official policies, either expressed
            * or implied, of JogAmp Community.
          @@ -45,19 +45,19 @@ import jogamp.opengl.util.av.EGLMediaPlayerImpl;
            */
           public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
               static final boolean available;
          -    
          +
               static {
                   available = false;
                   /** FIXME!
          -        // OMX binding is included in jogl_desktop and jogl_mobile     
          +        // OMX binding is included in jogl_desktop and jogl_mobile
                   GLProfile.initSingleton();
                   available = initIDs0(); */
               }
          -    
          +
               public static final boolean isAvailable() { return available; }
          -    
          +
               protected long moviePtr = 0;
          -    
          +
               public OMXGLMediaPlayer() {
                   super(TextureType.KHRImage, true);
                   if(!available) {
          @@ -70,21 +70,21 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
                   moviePtr = _createInstance();
                   if(0==moviePtr) {
                       throw new GLException("Couldn't create OMXInstance");
          -        }        
          +        }
               }
          -    
          +
               @Override
               protected TextureSequence.TextureFrame createTexImage(GL gl, int texName) {
                   final EGLTextureFrame eglTex = (EGLTextureFrame) super.createTexImage(gl, texName);
                   _setStreamEGLImageTexture2D(moviePtr, texName, eglTex.getImage(), eglTex.getSync());
                   return eglTex;
               }
          -    
          +
               @Override
               protected void destroyTexFrame(GL gl, TextureSequence.TextureFrame imgTex) {
          -        super.destroyTexFrame(gl, imgTex);        
          +        super.destroyTexFrame(gl, imgTex);
               }
          -    
          +
               @Override
               protected void destroyImpl(GL gl) {
                   if (moviePtr != 0) {
          @@ -94,20 +94,20 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
                       moviePtr = 0;
                   }
               }
          -    
          +
               @Override
               protected void initStreamImpl(int vid, int aid) throws IOException {
                   if(0==moviePtr) {
                       throw new GLException("OMX native instance null");
                   }
                   if(!streamLoc.getScheme().equals("file")) {
          -            throw new IOException("Only file schemes are allowed: "+streamLoc);            
          +            throw new IOException("Only file schemes are allowed: "+streamLoc);
                   }
                   final String path=streamLoc.getPath();
                   if(DEBUG) {
                       System.out.println("initGLStream: clean path "+path);
                   }
          -    
          +
                   if(DEBUG) {
                       System.out.println("initGLStream: p1 "+this);
                   }
          @@ -121,7 +121,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
                   // NOP
                   isInGLOrientation = true;
               }
          -    
          +
               @Override
               protected int getAudioPTSImpl() {
                   return 0!=moviePtr ? _getCurrentPosition(moviePtr) : 0;
          @@ -172,8 +172,8 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
                   final int nextTex = _getNextTextureID(moviePtr, true);
                   if(0 < nextTex) {
                       // FIXME set pts !
          -            /* FIXME 
          -            final TextureSequence.TextureFrame eglImgTex = 
          +            /* FIXME
          +            final TextureSequence.TextureFrame eglImgTex =
                               texFrameMap.get(new Integer(_getNextTextureID(moviePtr, blocking)));
                       if(null!=eglImgTex) {
                           lastTex = eglImgTex;
          @@ -181,7 +181,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
                   }
                   return 0; // FIXME: return pts
               }
          -    
          +
               private String replaceAll(String orig, String search, String repl) {
                   String dest=null;
                   // In case replaceAll / java.util.regex.* is not supported (-> CVM)
          @@ -203,14 +203,14 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl {
               }
           
               private static native boolean initIDs0();
          -    private native long _createInstance();    
          +    private native long _createInstance();
               private native void _destroyInstance(long moviePtr);
          -    
          +
               private native void _detachVideoRenderer(long moviePtr); // stop before
               private native void _attachVideoRenderer(long moviePtr); // detach before
               private native void _setStream(long moviePtr, int textureNum, String path);
               private native void _activateStream(long moviePtr);
          -    
          +
               private native void _setStreamEGLImageTexture2D(long moviePtr, int tex, long image, long sync);
               private native int  _seek(long moviePtr, int position);
               private native void _setPlaySpeed(long moviePtr, float rate);
          diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
          index 3c468f358..2d74fa532 100644
          --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
          +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java
          @@ -41,23 +41,23 @@ import com.jogamp.opengl.util.GLArrayDataEditable;
           import com.jogamp.opengl.util.glsl.ShaderState;
           
           /**
          - * Used for 1:1 GLSL arrays, i.e. where the buffer data 
          - * represents this array only. 
          + * Used for 1:1 GLSL arrays, i.e. where the buffer data
          + * represents this array only.
            */
          -public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandler {    
          -  
          +public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandler {
          +
             public GLSLArrayHandler(GLArrayDataEditable ad) {
               super(ad);
             }
          -  
          +
             public final void setSubArrayVBOName(int vboName) {
                 throw new UnsupportedOperationException();
             }
          -  
          +
             public final void addSubHandler(GLArrayHandlerFlat handler) {
                 throw new UnsupportedOperationException();
             }
          -  
          +
             public final void enableState(GL gl, boolean enable, Object ext) {
               final GL2ES2 glsl = gl.getGL2ES2();
               if( null != ext ) {
          @@ -66,12 +66,12 @@ public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandle
                   enableSimple(glsl, enable);
               }
             }
          -  
          +
             private final void enableShaderState(GL2ES2 glsl, boolean enable, ShaderState st) {
               if(enable) {
                   /*
                    * This would be the non optimized code path:
          -         * 
          +         *
                   if(ad.isVBO()) {
                       glsl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName());
                       if(!ad.isVBOWritten()) {
          @@ -108,13 +108,13 @@ public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandle
                   } else if(null!=buffer) {
                       st.vertexAttribPointer(glsl, ad);
                   }
          -        
          +
                   st.enableVertexAttribArray(glsl, ad);
               } else {
                   st.disableVertexAttribArray(glsl, ad);
               }
             }
          -  
          +
             private final void enableSimple(GL2ES2 glsl, boolean enable) {
               final int location = ad.getLocation();
               if( 0 > location ) {
          @@ -123,7 +123,7 @@ public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandle
               if(enable) {
                   /*
                    * This would be the non optimized code path:
          -         * 
          +         *
                   if(ad.isVBO()) {
                       glsl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName());
                       if(!ad.isVBOWritten()) {
          diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
          index 855406db3..a5f78b5d6 100644
          --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
          +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java
          @@ -37,7 +37,7 @@ import com.jogamp.opengl.util.GLArrayDataWrapper;
           import com.jogamp.opengl.util.glsl.ShaderState;
           
           /**
          - * Used for interleaved GLSL arrays, i.e. where the buffer data itself is handled 
          + * Used for interleaved GLSL arrays, i.e. where the buffer data itself is handled
            * separately and interleaves many arrays.
            */
           public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat {
          @@ -50,7 +50,7 @@ public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat {
             public GLArrayDataWrapper getData() {
                 return ad;
             }
          -    
          +
             public final void syncData(GL gl, Object ext) {
               final GL2ES2 glsl = gl.getGL2ES2();
               if( null != ext ) {
          @@ -62,7 +62,7 @@ public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat {
               }
               /**
                * Due to probable application VBO switching, this might not make any sense ..
          -     * 
          +     *
               if(!written) {
                   st.vertexAttribPointer(glsl, ad);
               } else if(st.getAttribLocation(glsl, ad) >= 0) {
          @@ -94,7 +94,7 @@ public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat {
                       } else {
                           glsl.glDisableVertexAttribArray(location);
                       }
          -        }        
          +        }
               }
          -  }  
          +  }
           }
          diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java
          index c2048d652..bcc146d78 100644
          --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java
          +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java
          @@ -40,8 +40,8 @@ import jogamp.opengl.util.GLVBOArrayHandler;
           import com.jogamp.opengl.util.GLArrayDataEditable;
           
           /**
          - * Interleaved fixed function arrays, i.e. where this buffer data 
          - * represents many arrays. 
          + * Interleaved fixed function arrays, i.e. where this buffer data
          + * represents many arrays.
            */
           public class GLSLArrayHandlerInterleaved extends GLVBOArrayHandler implements GLArrayHandler {
             private List subArrays = new ArrayList();
          @@ -49,13 +49,13 @@ public class GLSLArrayHandlerInterleaved extends GLVBOArrayHandler implements GL
             public GLSLArrayHandlerInterleaved(GLArrayDataEditable ad) {
               super(ad);
             }
          -  
          +
             public final void setSubArrayVBOName(int vboName) {
                 for(int i=0; i shaderRootClass, String shaderSrcRoot, String shaderBinRoot,
                                    String vertexColorFile, String vertexColorLightFile,
                                    String fragmentColorFile, String fragmentColorTextureFile) {
          @@ -90,14 +90,14 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
                       this.pmvMatrix = new PMVMatrix();
                   }
           
          -        fixedFunction = new FixedFuncPipeline(this.gl, mode, this.pmvMatrix, shaderRootClass, shaderSrcRoot, 
          +        fixedFunction = new FixedFuncPipeline(this.gl, mode, this.pmvMatrix, shaderRootClass, shaderSrcRoot,
                                                         shaderBinRoot, vertexColorFile, vertexColorLightFile, fragmentColorFile, fragmentColorTextureFile);
               }
           
               public boolean verbose() { return fixedFunction.verbose(); }
           
               public void setVerbose(boolean v) { fixedFunction.setVerbose(v); }
          -    
          +
               public void destroy() {
                   fixedFunction.destroy(gl);
                   fixedFunction = null;
          @@ -111,16 +111,16 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
               public PMVMatrix getMatrix() { return pmvMatrix; }
           
               //
          -    // FixedFuncHookIf - hooks 
          +    // FixedFuncHookIf - hooks
               //
               public void glDrawArrays(int mode, int first, int count) {
                   fixedFunction.glDrawArrays(gl, mode, first, count);
               }
               public void glDrawElements(int mode, int count, int type, java.nio.Buffer indices) {
          -        fixedFunction.glDrawElements(gl, mode, count, type, indices);        
          +        fixedFunction.glDrawElements(gl, mode, count, type, indices);
               }
               public void glDrawElements(int mode, int count, int type, long indices_buffer_offset) {
          -        fixedFunction.glDrawElements(gl, mode, count, type, indices_buffer_offset); 
          +        fixedFunction.glDrawElements(gl, mode, count, type, indices_buffer_offset);
               }
           
               public void glActiveTexture(int texture) {
          @@ -136,7 +136,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
                   if(fixedFunction.glEnable(cap, false)) {
                       gl.glDisable(cap);
                   }
          -    }    
          +    }
               public void glGetFloatv(int pname, java.nio.FloatBuffer params) {
                   if(PMVMatrix.isMatrixGetName(pname)) {
                       pmvMatrix.glGetFloatv(pname, params);
          @@ -165,7 +165,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
                   }
                   gl.glGetIntegerv(pname, params, params_offset);
               }
          -    
          +
               public void glTexEnvi(int target, int pname, int value) {
                   fixedFunction.glTexEnvi(target, pname, value);
               }
          @@ -179,7 +179,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
                   fixedFunction.glBindTexture(target, texture);
                   gl.glBindTexture(target, texture);
               }
          -    public void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, 
          +    public void glTexImage2D(int target, int level, int internalformat, int width, int height, int border,
                                        int format, int type,  Buffer pixels) {
                   // align internalformat w/ format, an ES2 requirement
                   switch(internalformat) {
          @@ -212,8 +212,8 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
               public  void glPointParameterfv(int pname, java.nio.FloatBuffer params) {
                   fixedFunction.glPointParameterfv(pname, params);
               }
          -    
          -    // 
          +
          +    //
               // MatrixIf
               //
               public int  glGetMatrixMode() {
          @@ -253,29 +253,29 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
                   pmvMatrix.glScalef(x, y, z);
               }
               public void glOrtho(double left, double right, double bottom, double top, double near_val, double far_val) {
          -        glOrthof((float) left, (float) right, (float) bottom, (float) top, (float) near_val, (float) far_val); 
          +        glOrthof((float) left, (float) right, (float) bottom, (float) top, (float) near_val, (float) far_val);
               }
               public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) {
                   pmvMatrix.glOrthof(left, right, bottom, top, zNear, zFar);
               }
               public void glFrustum(double left, double right, double bottom, double top, double zNear, double zFar) {
          -        glFrustumf((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar); 
          +        glFrustumf((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar);
               }
               public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) {
                   pmvMatrix.glFrustumf(left, right, bottom, top, zNear, zFar);
               }
           
          -    // 
          +    //
               // LightingIf
               //
               public void glColor4f(float red, float green, float blue, float alpha) {
                 fixedFunction.glColor4f(gl, red, green, blue, alpha);
               }
          -    
          +
               public  void glColor4ub(byte red, byte green, byte blue, byte alpha) {
          -      glColor4f(ValueConv.byte_to_float(red, false), 
          -                ValueConv.byte_to_float(green, false), 
          -                ValueConv.byte_to_float(blue, false), 
          +      glColor4f(ValueConv.byte_to_float(red, false),
          +                ValueConv.byte_to_float(green, false),
          +                ValueConv.byte_to_float(blue, false),
                           ValueConv.byte_to_float(alpha, false) );
               }
               public void glLightfv(int light, int pname, java.nio.FloatBuffer params) {
          @@ -299,17 +299,17 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
               //
               public void glShadeModel(int mode) {
                 fixedFunction.glShadeModel(gl, mode);
          -    }    
          +    }
               public  void glAlphaFunc(int func, float ref) {
                   fixedFunction.glAlphaFunc(func, ref);
               }
          -    
          -    /** ES2 supports CullFace implicit 
          +
          +    /** ES2 supports CullFace implicit
               public void glCullFace(int faceName) {
                   fixedFunction.glCullFace(faceName);
                   gl.glCullFace(faceName);
               } */
          -    
          +
               //
               // PointerIf
               //
          @@ -340,7 +340,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
               }
           
               public void glVertexPointer(int size, int type, int stride, java.nio.Buffer pointer) {
          -      glVertexPointer(GLArrayDataWrapper.createFixed(GL_VERTEX_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, 
          +      glVertexPointer(GLArrayDataWrapper.createFixed(GL_VERTEX_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride,
                                                                pointer, 0, 0, 0, GL.GL_ARRAY_BUFFER));
               }
               public void glVertexPointer(int size, int type, int stride, long pointer_buffer_offset) {
          @@ -348,7 +348,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
                 if(vboName==0) {
                   throw new GLException("no GL_ARRAY_BUFFER VBO bound");
                 }
          -      glVertexPointer(GLArrayDataWrapper.createFixed(GL_VERTEX_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, 
          +      glVertexPointer(GLArrayDataWrapper.createFixed(GL_VERTEX_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride,
                                                                null, vboName, pointer_buffer_offset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER));
               }
           
          @@ -368,7 +368,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
                 fixedFunction.glColorPointer(gl, array);
               }
               public void glColorPointer(int size, int type, int stride, java.nio.Buffer pointer) {
          -      glColorPointer(GLArrayDataWrapper.createFixed(GL_COLOR_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, 
          +      glColorPointer(GLArrayDataWrapper.createFixed(GL_COLOR_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride,
                                                               pointer, 0, 0, 0, GL.GL_ARRAY_BUFFER));
               }
               public void glColorPointer(int size, int type, int stride, long pointer_buffer_offset) {
          @@ -376,7 +376,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
                 if(vboName==0) {
                   throw new GLException("no GL_ARRAY_BUFFER VBO bound");
                 }
          -      glColorPointer(GLArrayDataWrapper.createFixed(GL_COLOR_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, 
          +      glColorPointer(GLArrayDataWrapper.createFixed(GL_COLOR_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride,
                                                              null, vboName, pointer_buffer_offset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER));
               }
           
          @@ -399,7 +399,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
                 fixedFunction.glNormalPointer(gl, array);
               }
               public void glNormalPointer(int type, int stride, java.nio.Buffer pointer) {
          -      glNormalPointer(GLArrayDataWrapper.createFixed(GL_NORMAL_ARRAY, 3, type, GLBuffers.isGLTypeFixedPoint(type), stride, 
          +      glNormalPointer(GLArrayDataWrapper.createFixed(GL_NORMAL_ARRAY, 3, type, GLBuffers.isGLTypeFixedPoint(type), stride,
                                                                pointer, 0, 0, 0, GL.GL_ARRAY_BUFFER));
               }
               public void glNormalPointer(int type, int stride, long pointer_buffer_offset) {
          @@ -407,7 +407,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
                 if(vboName==0) {
                   throw new GLException("no GL_ARRAY_BUFFER VBO bound");
                 }
          -      glNormalPointer(GLArrayDataWrapper.createFixed(GL_NORMAL_ARRAY, 3, type, GLBuffers.isGLTypeFixedPoint(type), stride, 
          +      glNormalPointer(GLArrayDataWrapper.createFixed(GL_NORMAL_ARRAY, 3, type, GLBuffers.isGLTypeFixedPoint(type), stride,
                                                                null, vboName, pointer_buffer_offset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER));
               }
           
          @@ -428,7 +428,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
               }
               public void glTexCoordPointer(int size, int type, int stride, java.nio.Buffer pointer) {
                 glTexCoordPointer(
          -        GLArrayDataWrapper.createFixed(GL_TEXTURE_COORD_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, 
          +        GLArrayDataWrapper.createFixed(GL_TEXTURE_COORD_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride,
                                                  pointer, 0, 0, 0, GL.GL_ARRAY_BUFFER));
               }
               public void glTexCoordPointer(int size, int type, int stride, long pointer_buffer_offset) {
          @@ -437,7 +437,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun
                   throw new GLException("no GL_ARRAY_BUFFER VBO bound");
                 }
                 glTexCoordPointer(
          -        GLArrayDataWrapper.createFixed(GL_TEXTURE_COORD_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, 
          +        GLArrayDataWrapper.createFixed(GL_TEXTURE_COORD_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride,
                                                  null, vboName, pointer_buffer_offset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER) );
               }
           
          diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
          index 5349745ea..187fdb309 100644
          --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
          +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java
          @@ -59,25 +59,25 @@ import com.jogamp.opengl.util.glsl.ShaderState;
           import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode;
           
           /**
          - * 
          + *
            * 

          - * Note: Certain GL FFP state values (e.g.: alphaTestFunc and cullFace) - * are mapped to a lower number range so they can be stored in low precision storage, + * Note: Certain GL FFP state values (e.g.: alphaTestFunc and cullFace) + * are mapped to a lower number range so they can be stored in low precision storage, * i.e. in a 'lowp int' (GL ES2). *

          */ public class FixedFuncPipeline { protected static final boolean DEBUG; - + static { Debug.initSingleton(); DEBUG = Debug.isPropertyDefined("jogl.debug.FixedFuncPipeline", true); } - + /** The maximum texture units which could be used, depending on {@link ShaderSelectionMode}. */ public static final int MAX_TEXTURE_UNITS = 8; public static final int MAX_LIGHTS = 8; - + public FixedFuncPipeline(GL2ES2 gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix) { shaderRootClass = FixedFuncPipeline.class; shaderSrcRoot = shaderSrcRootDef; @@ -88,8 +88,8 @@ public class FixedFuncPipeline { fragmentColorTextureFile = fragmentColorTextureFileDef; init(gl, mode, pmvMatrix); } - public FixedFuncPipeline(GL2ES2 gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix, - Class shaderRootClass, String shaderSrcRoot, + public FixedFuncPipeline(GL2ES2 gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix, + Class shaderRootClass, String shaderSrcRoot, String shaderBinRoot, String vertexColorFile, String vertexColorLightFile, String fragmentColorFile, String fragmentColorTextureFile) { @@ -100,9 +100,9 @@ public class FixedFuncPipeline { this.vertexColorLightFile = vertexColorLightFile; this.fragmentColorFile = fragmentColorFile; this.fragmentColorTextureFile = fragmentColorTextureFile; - init(gl, mode, pmvMatrix); + init(gl, mode, pmvMatrix); } - + public ShaderSelectionMode getShaderSelectionMode() { return requestedShaderSelectionMode; } public void setShaderSelectionMode(ShaderSelectionMode mode) { requestedShaderSelectionMode=mode; } public ShaderSelectionMode getCurrentShaderSelectionMode() { return currentShaderSelectionMode; } @@ -153,21 +153,21 @@ public class FixedFuncPipeline { colorStatic.put(1, green); colorStatic.put(2, blue); colorStatic.put(3, alpha); - + shaderState.useProgram(gl, true); - final GLUniformData ud = shaderState.getUniform(mgl_ColorStatic); + final GLUniformData ud = shaderState.getUniform(mgl_ColorStatic); if(null!=ud) { // same data object .. shaderState.uniform(gl, ud); } else { throw new GLException("Failed to update: mgl_ColorStatic"); - } + } } - + // // Arrays / States // - + public void glEnableClientState(GL2ES2 gl, int glArrayIndex) { glToggleClientState(gl, glArrayIndex, true); } @@ -202,7 +202,7 @@ public class FixedFuncPipeline { break; } } - + public void glVertexPointer(GL2ES2 gl, GLArrayData data) { shaderState.useProgram(gl, true); shaderState.vertexAttribPointer(gl, data); @@ -217,14 +217,14 @@ public class FixedFuncPipeline { shaderState.useProgram(gl, true); shaderState.vertexAttribPointer(gl, data); } - + // // MULTI-TEXTURE // /** Enables/Disables the named texture unit (if changed), returns previous state */ private boolean glEnableTexture(boolean enable, int unit) { - final boolean isEnabled = 0 != ( textureEnabledBits & ( 1 << activeTextureUnit ) ); + final boolean isEnabled = 0 != ( textureEnabledBits & ( 1 << activeTextureUnit ) ); if( isEnabled != enable ) { if(enable) { textureEnabledBits |= ( 1 << unit ); @@ -237,7 +237,7 @@ public class FixedFuncPipeline { } return isEnabled; } - + public void glClientActiveTexture(int textureUnit) { textureUnit -= GL.GL_TEXTURE0; if(0 <= textureUnit && textureUnit "+toHexString(ifmt)); } } else { - System.err.println("FixedFuncPipeline: Unimplemented glTexImage2D: target "+toHexString(target)+", internalformat "+toHexString(internalformat)); + System.err.println("FixedFuncPipeline: Unimplemented glTexImage2D: target "+toHexString(target)+", internalformat "+toHexString(internalformat)); } } /* public void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, - int format, int type, long pixels_buffer_offset) { + int format, int type, long pixels_buffer_offset) { textureFormat.put(activeTextureUnit, internalformat); textureFormatDirty = true; }*/ - + public void glTexEnvi(int target, int pname, int value) { if(GL2ES1.GL_TEXTURE_ENV == target && GL2ES1.GL_TEXTURE_ENV_MODE == pname) { final int mode; @@ -351,7 +351,7 @@ public class FixedFuncPipeline { if( value != textureEnvMode.get(activeTextureUnit) ) { textureEnvMode.put(activeTextureUnit, value); textureEnvModeDirty = true; - } + } } public void glGetTexEnviv(int target, int pname, IntBuffer params) { // FIXME System.err.println("FixedFuncPipeline: Unimplemented glGetTexEnviv: target "+toHexString(target)+", pname "+toHexString(pname)); @@ -359,13 +359,13 @@ public class FixedFuncPipeline { public void glGetTexEnviv(int target, int pname, int[] params, int params_offset) { // FIXME System.err.println("FixedFuncPipeline: Unimplemented glGetTexEnviv: target "+toHexString(target)+", pname "+toHexString(pname)); } - + // // Point Sprites // public void glPointSize(float size) { pointParams.put(0, size); - pointParamsDirty = true; + pointParamsDirty = true; } public void glPointParameterf(int pname, float param) { switch(pname) { @@ -379,7 +379,7 @@ public class FixedFuncPipeline { pointParams.put(4+3, param); break; } - pointParamsDirty = true; + pointParamsDirty = true; } public void glPointParameterfv(int pname, float[] params, int params_offset) { switch(pname) { @@ -389,7 +389,7 @@ public class FixedFuncPipeline { pointParams.put(4+2, params[params_offset + 2]); break; } - pointParamsDirty = true; + pointParamsDirty = true; } public void glPointParameterfv(int pname, java.nio.FloatBuffer params) { final int o = params.position(); @@ -400,24 +400,24 @@ public class FixedFuncPipeline { pointParams.put(4+2, params.get(o + 2)); break; } - pointParamsDirty = true; + pointParamsDirty = true; } // private int[] pointTexObj = new int[] { 0 }; - + private void glDrawPoints(GL2ES2 gl, GLRunnable2 glDrawAction, Object args) { if(gl.isGL2GL3()) { gl.glEnable(GL2GL3.GL_VERTEX_PROGRAM_POINT_SIZE); } if(gl.isGL2ES1()) { gl.glEnable(GL2ES1.GL_POINT_SPRITE); - } + } loadShaderPoints(gl); shaderState.attachShaderProgram(gl, shaderProgramPoints, true); validate(gl, false); // sync uniforms glDrawAction.run(gl, args); - + if(gl.isGL2ES1()) { gl.glDisable(GL2ES1.GL_POINT_SPRITE); } @@ -432,17 +432,17 @@ public class FixedFuncPipeline { int[] _args = (int[])args; gl.glDrawArrays(GL.GL_POINTS, _args[0], _args[1]); return null; - } - }; + } + }; private final void glDrawPointArrays(GL2ES2 gl, int first, int count) { - glDrawPoints(gl, glDrawArraysAction, new int[] { first, count }); + glDrawPoints(gl, glDrawArraysAction, new int[] { first, count }); } - + // // Lighting - // + // - public void glLightfv(GL2ES2 gl, int light, int pname, java.nio.FloatBuffer params) { + public void glLightfv(GL2ES2 gl, int light, int pname, java.nio.FloatBuffer params) { shaderState.useProgram(gl, true); light -=GLLightingFunc.GL_LIGHT0; if(0 <= light && light < MAX_LIGHTS) { @@ -536,14 +536,14 @@ public class FixedFuncPipeline { ud.setData(params); shaderState.uniform(gl, ud); } else if(verbose) { - + } } // // Misc States // - + public void glShadeModel(GL2ES2 gl, int mode) { shaderState.useProgram(gl, true); GLUniformData ud = shaderState.getUniform(mgl_ShadeModel); @@ -608,7 +608,7 @@ public class FixedFuncPipeline { _func = 8; break; default: - throw new GLException("glAlphaFunc invalid func: "+toHexString(func)); + throw new GLException("glAlphaFunc invalid func: "+toHexString(func)); } if(0 < _func) { if(0>alphaTestFunc) { @@ -623,7 +623,7 @@ public class FixedFuncPipeline { } /** - * @return false if digested in regard to GL2ES2 spec, + * @return false if digested in regard to GL2ES2 spec, * eg this call must not be passed to an underlying ES2 implementation. * true if this call shall be passed to an underlying GL2ES2/ES2 implementation as well. */ @@ -631,16 +631,16 @@ public class FixedFuncPipeline { switch(cap) { case GL.GL_BLEND: case GL.GL_DEPTH_TEST: - case GL.GL_DITHER: + case GL.GL_DITHER: case GL.GL_POLYGON_OFFSET_FILL: case GL.GL_SAMPLE_ALPHA_TO_COVERAGE: case GL.GL_SAMPLE_COVERAGE: case GL.GL_SCISSOR_TEST: case GL.GL_STENCIL_TEST: return true; - + case GL.GL_CULL_FACE: - /** ES2 supports CullFace implicit + /** ES2 supports CullFace implicit final int _cullFace; if(0>cullFace && enable || 0alphaTestFunc && enable || 0=0; i--) { @@ -776,12 +776,12 @@ public class FixedFuncPipeline { } return n; } - + public void validate(GL2ES2 gl, boolean selectShader) { if( selectShader ) { if( ShaderSelectionMode.AUTO == requestedShaderSelectionMode) { final ShaderSelectionMode newMode; - + // pre-validate shader switch if( 0 != textureEnabledBits ) { if(lightingEnabled) { @@ -808,9 +808,9 @@ public class FixedFuncPipeline { shaderState.useProgram(gl, true); } } - + GLUniformData ud; - if( pmvMatrix.update() ) { + if( pmvMatrix.update() ) { ud = shaderState.getUniform(mgl_PMVMatrix); if(null!=ud) { final FloatBuffer m; @@ -818,7 +818,7 @@ public class FixedFuncPipeline { ShaderSelectionMode.COLOR_LIGHT_PER_VERTEX== currentShaderSelectionMode ) { m = pmvMatrix.glGetPMvMvitMatrixf(); } else { - m = pmvMatrix.glGetPMvMatrixf(); + m = pmvMatrix.glGetPMvMatrixf(); } if(m != ud.getBuffer()) { ud.setData(m); @@ -829,7 +829,7 @@ public class FixedFuncPipeline { throw new GLException("Failed to update: mgl_PMVMatrix"); } } - if(colorVAEnabledDirty) { + if(colorVAEnabledDirty) { ud = shaderState.getUniform(mgl_ColorEnabled); if(null!=ud) { int ca = true == shaderState.isVertexAttribArrayEnabled(GLPointerFuncUtil.mgl_Color) ? 1 : 0 ; @@ -838,7 +838,7 @@ public class FixedFuncPipeline { shaderState.uniform(gl, ud); } } else { - throw new GLException("Failed to update: mgl_ColorEnabled"); + throw new GLException("Failed to update: mgl_ColorEnabled"); } colorVAEnabledDirty = false; } @@ -868,16 +868,16 @@ public class FixedFuncPipeline { if(pointParamsDirty) { ud = shaderState.getUniform(mgl_PointParams); if(null!=ud) { - // same data object + // same data object shaderState.uniform(gl, ud); } pointParamsDirty = false; } - + if(lightsEnabledDirty) { ud = shaderState.getUniform(mgl_LightsEnabled); if(null!=ud) { - // same data object + // same data object shaderState.uniform(gl, ud); } lightsEnabledDirty=false; @@ -886,41 +886,41 @@ public class FixedFuncPipeline { if(textureCoordEnabledDirty) { ud = shaderState.getUniform(mgl_TexCoordEnabled); if(null!=ud) { - // same data object + // same data object shaderState.uniform(gl, ud); } textureCoordEnabledDirty=false; - } + } if(textureEnvModeDirty) { ud = shaderState.getUniform(mgl_TexEnvMode); if(null!=ud) { - // same data object + // same data object shaderState.uniform(gl, ud); } textureEnvModeDirty = false; } - + if(textureFormatDirty) { for(int i = 0; i shaderRootClass; - private final String shaderSrcRoot; + private final String shaderSrcRoot; private final String shaderBinRoot; private final String vertexColorFile; private final String vertexColorLightFile; private final String fragmentColorFile; - private final String fragmentColorTextureFile; + private final String fragmentColorTextureFile; } diff --git a/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java b/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java index 833771dd1..1833a1d87 100644 --- a/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java +++ b/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java @@ -1,16 +1,16 @@ /** * Original JavaScript code from , * ported to Java for JogAmp Community. - * + * * Enhancements: * * InputStream instead of memory buffer * * User provided memory handler - * * Fixed JPEG Component ID/Index mapping + * * Fixed JPEG Component ID/Index mapping * * Color space conversion (YCCK, CMYK -> RGB) * * More error tolerant - * + * * ***************** - * + * * Copyright 2011 notmasteryet * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,21 +24,21 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * ***************** - * + * * Copyright 2013 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -48,7 +48,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -70,7 +70,7 @@ import com.jogamp.opengl.util.texture.TextureData; import com.jogamp.opengl.util.texture.TextureData.ColorSpace; /** - * + * *
            *
          • The JPEG specification can be found in the ITU CCITT Recommendation T.81 * (www.w3.org/Graphics/JPEG/itu-t81.pdf)
          • @@ -89,22 +89,22 @@ public class JPEGDecoder { private static final boolean DEBUG = Debug.debug("JPEGImage"); private static final boolean DEBUG_IN = false; - /** Allows user to hook a {@link ColorSink} to another toolkit to produce {@link TextureData}. */ + /** Allows user to hook a {@link ColorSink} to another toolkit to produce {@link TextureData}. */ public static interface ColorSink { /** * @param width * @param height * @param sourceCS the color-space of the decoded JPEG * @param sourceComponents number of components used for the given source color-space - * @return Either {@link TextureData.ColorSpace#RGB} or {@link TextureData.ColorSpace#YCbCr}. {@link TextureData.ColorSpace#YCCK} and {@link TextureData.ColorSpace#CMYK} will throw an exception! + * @return Either {@link TextureData.ColorSpace#RGB} or {@link TextureData.ColorSpace#YCbCr}. {@link TextureData.ColorSpace#YCCK} and {@link TextureData.ColorSpace#CMYK} will throw an exception! * @throws RuntimeException */ public TextureData.ColorSpace allocate(int width, int height, TextureData.ColorSpace sourceCS, int sourceComponents) throws RuntimeException; public void store2(int x, int y, byte c1, byte c2); public void storeRGB(int x, int y, byte r, byte g, byte b); - public void storeYCbCr(int x, int y, byte Y, byte Cb, byte Cr); + public void storeYCbCr(int x, int y, byte Y, byte Cb, byte Cr); } - + public static class JFIF { final VersionNumber version; final int densityUnits; @@ -138,11 +138,11 @@ public class JPEGDecoder { } else { return null; } - } + } public final String toString() { return "JFIF[ver "+version+", density[units "+densityUnits+", "+xDensity+"x"+yDensity+"], thumb "+thumbWidth+"x"+thumbHeight+"]"; - } + } } public static class Adobe { @@ -151,7 +151,7 @@ public class JPEGDecoder { final short flags1; final short colorCode; final ColorSpace colorSpace; - + private Adobe(final byte[] data) { version = data[6]; flags0 = (short) ( (data[7] << 8) | data[8] ) ; @@ -174,7 +174,7 @@ public class JPEGDecoder { } public final String toString() { return "Adobe[ver "+version+", flags["+toHexString(flags0)+", "+toHexString(flags1)+"], colorSpace/Code "+colorSpace+"/"+toHexString(colorCode)+"]"; - } + } } /** TODO */ public static class EXIF { @@ -189,10 +189,10 @@ public class JPEGDecoder { } else { return null; } - } + } public final String toString() { return "EXIF[]"; - } + } } @SuppressWarnings("serial") @@ -210,7 +210,7 @@ public class JPEGDecoder { } public int getMarker() { return marker; } } - + /** Start of Image */ private static final int M_SOI = 0xFFD8; /** End of Image */ @@ -264,8 +264,8 @@ public class JPEGDecoder { private static final int M_APP15 = 0xFFEF; /** Annotation / Comment */ - private static final int M_ANO = 0xFFFE; - + private static final int M_ANO = 0xFFFE; + static final int[] dctZigZag = new int[] { 0, 1, 8, @@ -323,7 +323,7 @@ public class JPEGDecoder { private final void checkBounds(int idx) { if( 0 > idx || idx >= compCount ) { throw new CodecException("Idx out of bounds "+idx+", "+this); - } + } } public final void validateComponents() { for(int i=0; i= blocksPerColumnForMcu || col >= blocksPerLineForMcu ) { throw new CodecException("Out of bounds given ["+row+"]["+col+"] - "+this); } - return blocks[row][col]; + return blocks[row][col]; } - + public final String toString() { return "CompIn[h "+h+", v "+v+", qttIdx "+qttIdx+", blocks["+blocksPerColumn+", mcu "+blocksPerColumnForMcu+"]["+blocksPerLine+", mcu "+blocksPerLineForMcu+"][64]]"; } @@ -410,7 +410,7 @@ public class JPEGDecoder { /** The decoded components */ class ComponentOut { - private final ArrayList lines; + private final ArrayList lines; final float scaleX; final float scaleY; @@ -419,13 +419,13 @@ public class JPEGDecoder { this.scaleX = scaleX; this.scaleY = scaleY; } - + /** Safely returning a line, if index exceeds number of lines, last line is returned. */ public final byte[] getLine(int i) { final int sz = lines.size(); return lines.get( i < sz ? i : sz - 1); } - + public final String toString() { return "CompOut[lines "+lines.size()+", scale "+scaleX+"x"+scaleY+"]"; } @@ -442,7 +442,7 @@ public class JPEGDecoder { private BufferedInputStream istream; private int _ipos = 0; private int _iposSave = 0; - + private int width = 0; private int height = 0; private JFIF jfif = null; @@ -457,14 +457,14 @@ public class JPEGDecoder { public final int getHeight() { return height; } private final void resetInput(InputStream is) { - if( is instanceof BufferedInputStream ) { + if( is instanceof BufferedInputStream ) { istream = (BufferedInputStream) is; } else { istream = new BufferedInputStream(is); } _ipos = 0; } - + private final void markStream(int readLimit) { istream.mark(readLimit); _iposSave = _ipos; @@ -480,7 +480,7 @@ public class JPEGDecoder { if( -1 < r ) { if(DEBUG_IN) { System.err.println("u8["+_ipos+"]: "+toHexString(r)); } _ipos++; - } else if(DEBUG_IN) { + } else if(DEBUG_IN) { System.err.println("u8["+_ipos+"]: EOS"); } return r; @@ -519,7 +519,7 @@ public class JPEGDecoder { } if(DEBUG_IN) { System.err.println("JPEG.readDataBlock: net-len "+(len-2)+", "+this); dumpData(data, 0, len-2); } return data; - } + } static final void dumpData(byte[] data, int offset, int len) { for(int i=0; i frames = new ArrayList(); // JAU: max 1-frame - + Frame frame = null; int resetInterval = 0; int fileMarker = readUint16(); @@ -614,7 +614,7 @@ public class JPEGDecoder { quantizationTables[tableIdx] = tableData; if( DEBUG ) { System.err.println("JPEG.parse.QTT["+tableIdx+"]: spec "+quantizationTableSpec+", precision "+precisionID+", data "+count+"/"+quantizationTablesLength); - } + } } if(count!=quantizationTablesLength){ throw new CodecException("ERROR: QTT format error [count!=Length]: "+count+"/"+quantizationTablesLength); @@ -660,7 +660,7 @@ public class JPEGDecoder { } break; - case M_DHT: { + case M_DHT: { int count = 0; final int huffmanLength = readUint16(); count+=2; int i=count, codeLengthTotal = 0; @@ -675,7 +675,7 @@ public class JPEGDecoder { for (int j = 0; j < codeLengthSum; j++) { huffmanValues[j] = (byte)readUint8(); count++; } - codeLengthTotal += codeLengthSum; + codeLengthTotal += codeLengthSum; i += 17 + codeLengthSum; final BinObj[] table = ( huffmanTableSpec >> 4 ) == 0 ? huffmanTablesDC : huffmanTablesAC; table[huffmanTableSpec & 0x0F] = buildHuffmanTable(codeLengths, huffmanValues); @@ -699,7 +699,7 @@ public class JPEGDecoder { final int sosLen = readUint16(); count+=2; final int selectorsCount = readUint8(); count++; ArrayList components = new ArrayList(); - if(DEBUG) { System.err.println("JPG.parse.SOS: selectorCount [0.."+(selectorsCount-1)+"]: "+frame); } + if(DEBUG) { System.err.println("JPG.parse.SOS: selectorCount [0.."+(selectorsCount-1)+"]: "+frame); } for (int i = 0; i < selectorsCount; i++) { final int compID = readUint8(); count++; final ComponentIn component = frame.getCompByID(compID); @@ -751,8 +751,8 @@ public class JPEGDecoder { final ComponentIn component = frame.getCompByIndex(i); // System.err.println("JPG.parse.buildComponentData["+i+"]: "+component); // JAU // System.err.println("JPG.parse.buildComponentData["+i+"]: "+frame); // JAU - this.components[i] = new ComponentOut( output.buildComponentData(frame, component), - (float)component.h / (float)frame.maxH, + this.components[i] = new ComponentOut( output.buildComponentData(frame, component), + (float)component.h / (float)frame.maxH, (float)component.v / (float)frame.maxV ); } if(DEBUG) { System.err.println("JPG.parse.X: End of processing input "+this); } @@ -797,7 +797,7 @@ public class JPEGDecoder { final boolean isValue; final BinObj[] tree; final byte b; - + BinObj(byte b) { this.isValue= true; this.b = b; @@ -815,13 +815,13 @@ public class JPEGDecoder { } private BinObj buildHuffmanTable(int[] codeLengths, byte[] values) { - int k = 0; - int length = 16; + int k = 0; + int length = 16; final ArrayList code = new ArrayList(); while (length > 0 && 0==codeLengths[length - 1]) { length--; } - code.add(new BinObjIdxed()); + code.add(new BinObjIdxed()); BinObjIdxed p = code.get(0), q; for (int i = 0; i < length; i++) { for (int j = 0; j < codeLengths[i]; j++) { @@ -959,7 +959,7 @@ public class JPEGDecoder { t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12; v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12; v6 = t; - + // stage 1 p[0 + row] = v0 + v7; p[7 + row] = v0 - v7; @@ -1066,7 +1066,7 @@ public class JPEGDecoder { private int successiveACState, successiveACNextValue; private int decodeScan(Frame frame, ArrayList components, int resetInterval, - int spectralStart, int spectralEnd, int successivePrev, int successive) throws IOException { + int spectralStart, int spectralEnd, int successivePrev, int successive) throws IOException { // this.precision = frame.precision; // this.samplesPerLine = frame.samplesPerLine; // this.scanLines = frame.scanLines; @@ -1079,7 +1079,7 @@ public class JPEGDecoder { this.spectralStart = spectralStart; this.spectralEnd = spectralEnd; this.successive = successive; - + final int componentsLength = components.size(); final DecoderFunction decodeFn; @@ -1096,7 +1096,7 @@ public class JPEGDecoder { int mcu = 0; int mcuExpected; if (componentsLength == 1) { - final ComponentIn c = components.get(0); + final ComponentIn c = components.get(0); mcuExpected = c.blocksPerLine * c.blocksPerColumn; } else { mcuExpected = mcusPerLine * frame.mcusPerColumn; @@ -1153,14 +1153,14 @@ public class JPEGDecoder { if( marker < 0xFF00 ) { rewindStream(); throw new CodecException("marker not found @ mcu "+mcu+"/"+mcuExpected+", u16: "+toHexString(marker)); - } + } final boolean isRSTx = 0xFFD0 <= marker && marker <= 0xFFD7; // !RSTx if(DEBUG) { System.err.println("JPEG.decodeScan: MCUs "+mcu+"/"+mcuExpected+", u16 "+toHexString(marker)+", RSTx "+isRSTx+", "+frame); } if ( !isRSTx ) { break; // handle !RSTx marker in caller - } + } } return marker; } @@ -1306,7 +1306,7 @@ public class JPEGDecoder { successiveACState = 1; } } else { - // if (s !== 1) { + // if (s !== 1) { if (s != 1) { throw new CodecException("invalid ACn encoding"); } @@ -1380,18 +1380,18 @@ public class JPEGDecoder { int R = Y + ( ( 91881 * Cr ) >> 16 ); if(R<0) R=0; else if(R>255) R=255; - + pixelStorage.storeRGB(x, y, (byte)R, (byte)G, (byte)B); } */ - + public synchronized void getPixel(JPEGDecoder.ColorSink pixelStorage, int width, int height) { final int scaleX = this.width / width, scaleY = this.height / height; final int componentCount = this.components.length; - final ColorSpace sourceCS = ( null != adobe ) ? adobe.colorSpace : ColorSpace.YCbCr; + final ColorSpace sourceCS = ( null != adobe ) ? adobe.colorSpace : ColorSpace.YCbCr; final ColorSpace storageCS = pixelStorage.allocate(width, height, sourceCS, componentCount); if( ColorSpace.RGB != storageCS && ColorSpace.YCbCr != storageCS ) { - throw new IllegalArgumentException("Unsupported storage color space: "+storageCS); + throw new IllegalArgumentException("Unsupported storage color space: "+storageCS); } switch (componentCount) { @@ -1504,7 +1504,7 @@ public class JPEGDecoder { final byte G = clampTo8bit( ( cM * cK ) / 255f ); final byte B = clampTo8bit( ( cY * cK ) / 255f ); pixelStorage.storeRGB(x, y, R, G, B); - } + } } else { // ColorModel.YCCK == sourceCM for (int x = 0; x < width; x++) { final int xs = x * scaleX; @@ -1525,7 +1525,7 @@ public class JPEGDecoder { } } } - } + } break; default: throw new CodecException("Unsupported color model: Space "+sourceCS+", components "+componentCount); diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java b/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java index 0fffc85b1..5e177b8c3 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java @@ -4,7 +4,7 @@ import java.util.HashMap; /** * Internal PNG predictor filter, or strategy to select it. - * + * */ public enum FilterType { /** diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java index e62134cd5..ac7b858e1 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java @@ -98,7 +98,7 @@ public class ImageInfo { /** * Full constructor - * + * * @param cols * Width in pixels * @param rows diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java index e34e6a226..906ce6373 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java @@ -25,7 +25,7 @@ public class ImageLine { * Except for 'packed' formats (gray/indexed with 1-2-4 bitdepth) each * int is a "sample" (one for channel), (0-255 or 0-65535) in * the corresponding PNG sequence: R G B R G B... or - * R G B A R G B A... + * R G B A R G B A... * or g g g ... or i i i (palette index) *

            * For bitdepth=1/2/4 , and if samplesUnpacked=false, each value is a PACKED @@ -60,7 +60,7 @@ public class ImageLine { /** * true: each element of the scanline array represents a sample always, even * for internally packed PNG formats - * + * * false: if the original image was of packed type (bit depth less than 8) * we keep samples packed in a single array element */ @@ -74,7 +74,7 @@ public class ImageLine { } /** - * + * * @param imgInfo * Inmutable ImageInfo, basic parameter of the image we are * reading or writing @@ -84,7 +84,7 @@ public class ImageLine { * @param unpackedMode * If true, we use unpacked format, even for packed original * images - * + * */ public ImageLine(ImageInfo imgInfo, SampleType stype, boolean unpackedMode) { this(imgInfo, stype, unpackedMode, null, null); @@ -124,13 +124,13 @@ public class ImageLine { /* * Unpacks scanline (for bitdepth 1-2-4) - * + * * Arrays must be prealocated. src : samplesPerRowPacked dst : samplesPerRow - * + * * This usually works in place (with src==dst and length=samplesPerRow)! - * + * * If not, you should only call this only when necesary (bitdepth <8) - * + * * If scale==true, it scales the value (just a bit shift) towards 0-255. */ static void unpackInplaceInt(final ImageInfo iminfo, final int[] src, final int[] dst, final boolean scale) { @@ -165,15 +165,15 @@ public class ImageLine { /* * Unpacks scanline (for bitdepth 1-2-4) - * + * * Arrays must be prealocated. src : samplesPerRow dst : samplesPerRowPacked - * + * * This usually works in place (with src==dst and length=samplesPerRow)! If not, you should only call this only when * necesary (bitdepth <8) - * + * * The trailing elements are trash - * - * + * + * * If scale==true, it scales the value (just a bit shift) towards 0-255. */ static void packInplaceInt(final ImageInfo iminfo, final int[] src, final int[] dst, final boolean scaled) { @@ -270,7 +270,7 @@ public class ImageLine { /** * Creates a new ImageLine similar to this, but unpacked - * + * * The caller must be sure that the original was really packed */ public ImageLine unpackToNewImageLine() { @@ -284,7 +284,7 @@ public class ImageLine { /** * Creates a new ImageLine similar to this, but packed - * + * * The caller must be sure that the original was really unpacked */ public ImageLine packToNewImageLine() { diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java index 91516a704..438a69984 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java @@ -23,7 +23,7 @@ public class ImageLineHelper { /** * Given an indexed line with a palette, unpacks as a RGB array, or RGBA if * a non nul PngChunkTRNS chunk is passed - * + * * @param line * ImageLine as returned from PngReader * @param pal @@ -143,7 +143,7 @@ public class ImageLineHelper { /** * integer packed R G B only for bitdepth=8! (does not check!) - * + * **/ public static int getPixelRGB8(ImageLine line, int column) { int offset = column * line.channels; @@ -252,7 +252,7 @@ public class ImageLineHelper { * scale==true, it scales the value (just a bit shift) towards 0-255. *

            * You probably should use {@link ImageLine#unpackToNewImageLine()} - * + * */ public static int[] unpack(ImageInfo imgInfo, int[] src, int[] dst, boolean scale) { int len1 = imgInfo.samplesPerRow; @@ -282,7 +282,7 @@ public class ImageLineHelper { * Packs scanline (for bitdepth 1-2-4) from array into the scanline *

            * If scale==true, it scales the value (just a bit shift). - * + * * You probably should use {@link ImageLine#packToNewImageLine()} */ public static int[] pack(ImageInfo imgInfo, int[] src, int[] dst, boolean scale) { diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java index feb50e7b6..fb2cf5910 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java @@ -5,7 +5,7 @@ import jogamp.opengl.util.pngj.ImageLine.SampleType; /** * Wraps in a matrix a set of image rows, not necessarily contiguous - but * equispaced. - * + * * The fields mirrors those of {@link ImageLine}, and you can access each row as * a ImageLine backed by the matrix row, see * {@link #getImageLineAtMatrixRow(int)} @@ -28,7 +28,7 @@ public class ImageLines { * Allocates a matrix to store {@code nRows} image rows. See * {@link ImageLine} and {@link PngReader#readRowsInt()} * {@link PngReader#readRowsByte()} - * + * * @param imgInfo * @param stype * @param unpackedMode @@ -77,7 +77,7 @@ public class ImageLines { /** * Converts from matrix row number (0 : nRows-1) to image row number - * + * * @param mrow * Matrix row number * @return Image row number. Invalid only if mrow is invalid @@ -88,7 +88,7 @@ public class ImageLines { /** * Returns a ImageLine is backed by the matrix, no allocation done - * + * * @param mrow * Matrix row, from 0 to nRows This is not necessarily the image * row, see {@link #imageRowToMatrixRow(int)} and diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java index a950c6b33..1f598a5de 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java @@ -49,7 +49,7 @@ public class PngHelperInternal { /** * -1 if eof - * + * * PNG uses "network byte order" */ public static int readInt2(InputStream is) { diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java index e42dd8733..73442e0bb 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java @@ -92,13 +92,13 @@ public class PngReader { * Constructs a PngReader from an InputStream. *

            * See also FileHelper.createPngReader(File f) if available. - * + * * Reads only the signature and first chunk (IDHR) - * + * * @param filenameOrDescription * : Optional, can be a filename or a description. Just for * error/debug messages - * + * */ public PngReader(InputStream inputStream, String filenameOrDescription) { this.filename = filenameOrDescription == null ? "" : filenameOrDescription; @@ -411,7 +411,7 @@ public class PngReader { /** * Determines which ancillary chunks (metada) are to be loaded - * + * * @param chunkLoadBehaviour * {@link ChunkLoadBehaviour} */ @@ -427,7 +427,7 @@ public class PngReader { * replaced by a single dummy-marker IDAT chunk. These might be copied to * the PngWriter *

            - * + * * @see #getMetadata() */ public ChunksList getChunksList() { @@ -442,7 +442,7 @@ public class PngReader { /** * High level wrapper over chunksList - * + * * @see #getChunksList() */ public PngMetadata getMetadata() { @@ -456,7 +456,7 @@ public class PngReader { * appropiate readRowInt/readRowByte *

            * In general, specifying the concrete readRowInt/readRowByte is preferrable - * + * * @see #readRowInt(int) {@link #readRowByte(int)} */ public ImageLine readRow(int nrow) { @@ -468,9 +468,9 @@ public class PngReader { /** * Reads the row as INT, storing it in the {@link #imgLine} property and * returning it. - * + * * The row must be greater or equal than the last read row. - * + * * @param nrow * Row number, from 0 to rows-1. Increasing order. * @return ImageLine object, also available as field. Data is in @@ -490,10 +490,10 @@ public class PngReader { /** * Reads the row as BYTES, storing it in the {@link #imgLine} property and * returning it. - * + * * The row must be greater or equal than the last read row. This method * allows to pass the same row that was last read. - * + * * @param nrow * Row number, from 0 to rows-1. Increasing order. * @return ImageLine object, also available as field. Data is in @@ -524,13 +524,13 @@ public class PngReader { *

            * If the bitdepth is less than 8, the bytes are packed - unless * {@link #unpackedMode} is true. - * + * * @param buffer * Prealocated buffer, or null. * @param nrow * Row number (0 is top). Most be strictly greater than the last * read row. - * + * * @return The scanline in the same passwd buffer if it was allocated, a * newly allocated one otherwise */ @@ -562,13 +562,13 @@ public class PngReader { * {@link #unpackedMode} is true.
            * If the bitdepth is 16, the least significant byte is lost. *

            - * + * * @param buffer * Prealocated buffer, or null. * @param nrow * Row number (0 is top). Most be strictly greater than the last * read row. - * + * * @return The scanline in the same passwd buffer if it was allocated, a * newly allocated one otherwise */ @@ -632,9 +632,9 @@ public class PngReader { *

            * Notice that the columns in the matrix is not the pixel width of the * image, but rather pixels x channels - * + * * @see #readRowInt(int) to read about the format of each row - * + * * @param rowOffset * Number of rows to be skipped * @param nRows @@ -678,7 +678,7 @@ public class PngReader { /** * Same as readRowsInt(0, imgInfo.rows, 1) - * + * * @see #readRowsInt(int, int, int) */ public ImageLines readRowsInt() { @@ -696,10 +696,10 @@ public class PngReader { *

            * Notice that the columns in the matrix is not the pixel width of the * image, but rather pixels x channels - * + * * @see #readRowByte(int) to read about the format of each row. Notice that * if the bitdepth is 16 this will lose information - * + * * @param rowOffset * Number of rows to be skipped * @param nRows @@ -743,7 +743,7 @@ public class PngReader { /** * Same as readRowsByte(0, imgInfo.rows, 1) - * + * * @see #readRowsByte(int, int, int) */ public ImageLines readRowsByte() { @@ -752,13 +752,13 @@ public class PngReader { /* * For the interlaced case, nrow indicates the subsampled image - the pass must be set already. - * + * * This must be called in strict order, both for interlaced or no interlaced. - * + * * Updates rowNum. - * + * * Leaves raw result in rowb - * + * * Returns bytes actually read (not including the filter byte) */ private int readRowRaw(final int nrow) { @@ -933,7 +933,7 @@ public class PngReader { * scanline will be sample. This implies more processing and memory, but * it's the most efficient option if you intend to read individual pixels.
            * This option should only be set before start reading. - * + * * @param unPackedMode */ public void setUnpackedMode(boolean unPackedMode) { @@ -951,7 +951,7 @@ public class PngReader { * Tries to reuse the allocated buffers from other already used PngReader * object. This will have no effect if the buffers are smaller than necessary. * It also reuses the inflater. - * + * * @param other A PngReader that has already finished reading pixels. Can be null. */ public void reuseBuffersFrom(PngReader other) { @@ -977,7 +977,7 @@ public class PngReader { /** * Just for testing. TO be called after ending reading, only if * initCrctest() was called before start - * + * * @return CRC of the raw pixels values */ long getCrctestVal() { diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java index 3e684a881..2f475aab1 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java @@ -88,7 +88,7 @@ public class PngWriter { * filters) and queue chunks before start writing the pixels. *

            * See also FileHelper.createPngWriter() if available. - * + * * @param outputStream * Opened stream for binary writing * @param imgInfo @@ -422,7 +422,7 @@ public class PngWriter { * Should be called when creating an image from another, before starting * writing lines, to copy relevant chunks. *

            - * + * * @param reader * : PngReader object, already opened. * @param copy_mask @@ -439,7 +439,7 @@ public class PngWriter { * Should be called when creating an image from another, after writing all * lines, before closing the writer, to copy additional chunks. *

            - * + * * @param reader * : PngReader object, already opened and fully read. * @param copy_mask @@ -455,7 +455,7 @@ public class PngWriter { *

            * Actually: compressed size = total size of IDAT data , raw size = * uncompressed pixel bytes = rows * (bytesPerRow + 1). - * + * * This must be called after pngw.end() */ public double computeCompressionRatio() { @@ -512,7 +512,7 @@ public class PngWriter { * This must be called just after constructor, before starting writing. *

            * See also setFilterType() - * + * * @param compLevel * between 0 and 9 (default:6 , recommended: 6 or more) */ @@ -528,7 +528,7 @@ public class PngWriter { * This must be called just after constructor, before starting writing. *

            * See also setCompLevel() - * + * * @param filterType * One of the five prediction types or strategy to choose it (see * PngFilterType) Recommended values: DEFAULT @@ -542,7 +542,7 @@ public class PngWriter { * Sets maximum size of IDAT fragments. This has little effect on * performance you should rarely call this *

            - * + * * @param idatMaxSize * default=0 : use defaultSize (32K) */ @@ -572,7 +572,7 @@ public class PngWriter { /** * Writes line, checks that the row number is consistent with that of the * ImageLine See writeRow(int[] newrow, int rown) - * + * * @deprecated Better use writeRow(ImageLine imgline, int rownumber) */ public void writeRow(ImageLine imgline) { @@ -581,9 +581,9 @@ public class PngWriter { /** * Writes line. See writeRow(int[] newrow, int rown) - * + * * The packed flag of the imageline is honoured! - * + * * @see #writeRowInt(int[], int) */ public void writeRow(ImageLine imgline, int rownumber) { @@ -596,7 +596,7 @@ public class PngWriter { /** * Same as writeRow(int[] newrow, int rown), but does not check row number - * + * * @param newrow */ public void writeRow(int[] newrow) { @@ -605,7 +605,7 @@ public class PngWriter { /** * Alias to writeRowInt - * + * * @see #writeRowInt(int[], int) */ public void writeRow(int[] newrow, int rown) { @@ -624,7 +624,7 @@ public class PngWriter { * Warning: the array might be modified in some cases (unpacked row with low * bitdepth) *

            - * + * * @param newrow * Array of pixel values. Warning: the array size should be exact * (samplesPerRowP) @@ -642,7 +642,7 @@ public class PngWriter { * Same semantics as writeRowInt but using bytes. Each byte is still a * sample. If 16bitdepth, we are passing only the most significant byte (and * hence losing some info) - * + * * @see PngWriter#writeRowInt(int[], int) */ public void writeRowByte(byte[] newrow, int rown) { diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngjException.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngjException.java index 4a45cb5bf..97e24fc73 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngjException.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngjException.java @@ -2,9 +2,9 @@ package jogamp.opengl.util.pngj; /** * Generic exception - * + * * @author Hernan J Gonzalez - * + * */ public class PngjException extends RuntimeException { private static final long serialVersionUID = 1L; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java index c429b893b..5da70de7b 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java @@ -3,9 +3,9 @@ package jogamp.opengl.util.pngj; /** * Exception for anomalous internal problems (sort of asserts) that point to * some issue with the library - * + * * @author Hernan J Gonzalez - * + * */ public class PngjExceptionInternal extends RuntimeException { private static final long serialVersionUID = 1L; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java index a995e4481..82abb902d 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java @@ -59,7 +59,7 @@ public class ChunkHelper { }; /* - * static auxiliary buffer. any method that uses this should synchronize against this + * static auxiliary buffer. any method that uses this should synchronize against this */ private static byte[] tmpbuffer = new byte[4096]; @@ -136,7 +136,7 @@ public class ChunkHelper { /** * Finds position of null byte in array - * + * * @param b * @return -1 if not found */ @@ -149,7 +149,7 @@ public class ChunkHelper { /** * Decides if a chunk should be loaded, according to a ChunkLoadBehaviour - * + * * @param id * @param behav * @return true/false @@ -208,7 +208,7 @@ public class ChunkHelper { /** * Returns only the chunks that "match" the predicate - * + * * See also trimList() */ public static List filterList(List target, ChunkPredicate predicateKeep) { @@ -223,7 +223,7 @@ public class ChunkHelper { /** * Remove (in place) the chunks that "match" the predicate - * + * * See also filterList */ public static int trimList(List target, ChunkPredicate predicateRemove) { @@ -244,10 +244,10 @@ public class ChunkHelper { * they have same id and (perhaps, if multiple are allowed) if the match * also in some "internal key" (eg: key for string values, palette for sPLT, * etc) - * + * * Notice that the use of this is optional, and that the PNG standard allows * Text chunks that have same key - * + * * @return true if "equivalent" */ public static final boolean equivalent(PngChunk c1, PngChunk c2) { diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkLoadBehaviour.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkLoadBehaviour.java index 82ab3bcf9..1fa00380a 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkLoadBehaviour.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkLoadBehaviour.java @@ -15,7 +15,7 @@ public enum ChunkLoadBehaviour { */ LOAD_CHUNK_KNOWN, /** - * + * * Load chunk if "known" or "safe to copy". */ LOAD_CHUNK_IF_SAFE, diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkPredicate.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkPredicate.java index a750ae34f..4695ccf44 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkPredicate.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkPredicate.java @@ -6,7 +6,7 @@ package jogamp.opengl.util.pngj.chunks; public interface ChunkPredicate { /** * The other chunk matches with this one - * + * * @param chunk * @return true if match */ diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java index 5ce94ff9f..3e0d03051 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java @@ -24,7 +24,7 @@ public class ChunksList { /** * All chunks, read (or written) - * + * * But IDAT is a single pseudo chunk without data */ protected List chunks = new ArrayList(); @@ -37,7 +37,7 @@ public class ChunksList { /** * Keys of processed (read or writen) chunks - * + * * @return key:chunk id, val: number of occurrences */ public HashMap getChunksKeys() { @@ -87,7 +87,7 @@ public class ChunksList { /** * All chunks with this ID - * + * * @param id * @return List, empty if none */ @@ -98,7 +98,7 @@ public class ChunksList { /** * If innerid!=null and the chunk is PngChunkTextVar or PngChunkSPLT, it's * filtered by that id - * + * * @param id * @return innerid Only used for text and SPLT chunks * @return List, empty if none @@ -109,7 +109,7 @@ public class ChunksList { /** * Returns only one chunk - * + * * @param id * @return First chunk found, null if not found */ @@ -146,7 +146,7 @@ public class ChunksList { /** * Finds all chunks "equivalent" to this one - * + * * @param c2 * @return Empty if nothing found */ diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java index e76456ad4..3b84ab800 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java @@ -67,7 +67,7 @@ public class ChunksListForWrite extends ChunksList { /** * Remove Chunk: only from queued - * + * * WARNING: this depends on c.equals() implementation, which is * straightforward for SingleChunks. For MultipleChunks, it will normally * check for reference equality! @@ -78,9 +78,9 @@ public class ChunksListForWrite extends ChunksList { /** * Adds chunk to queue - * + * * Does not check for duplicated or anything - * + * * @param c */ public boolean queue(PngChunk c) { diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java index a45979ec2..6cd86eb98 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java @@ -248,7 +248,7 @@ public abstract class PngChunk { /** * Creates the physical chunk. This is used when writing (serialization). * Each particular chunk class implements its own logic. - * + * * @return A newly allocated and filled raw chunk */ public abstract ChunkRaw createRawChunk(); diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkBKGD.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkBKGD.java index 4a8502a3d..ea6235432 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkBKGD.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkBKGD.java @@ -70,7 +70,7 @@ public class PngChunkBKGD extends PngChunkSingle { /** * Set gray value (0-255 if bitdept=8) - * + * * @param gray */ public void setGray(int gray) { @@ -87,7 +87,7 @@ public class PngChunkBKGD extends PngChunkSingle { /** * Set pallette index - * + * */ public void setPaletteIndex(int i) { if (!imgInfo.indexed) @@ -103,7 +103,7 @@ public class PngChunkBKGD extends PngChunkSingle { /** * Set rgb values - * + * */ public void setRGB(int r, int g, int b) { if (imgInfo.greyscale || imgInfo.indexed) diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java index d44250a2f..057f6c25e 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java @@ -19,9 +19,9 @@ public abstract class PngChunkMultiple extends PngChunk { /** * NOTE: this chunk uses the default Object's equals() hashCode() * implementation. - * + * * This is the right thing to do, normally. - * + * * This is important, eg see ChunkList.removeFromList() */ diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSBIT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSBIT.java index bc70c6e5e..3a490654a 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSBIT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSBIT.java @@ -106,7 +106,7 @@ public class PngChunkSBIT extends PngChunkSingle { /** * Set rgb values - * + * */ public void setRGB(int r, int g, int b) { if (imgInfo.greyscale || imgInfo.indexed) diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java index b68776477..867e34861 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java @@ -82,7 +82,7 @@ public class PngChunkTRNS extends PngChunkSingle { /** * Set rgb values - * + * */ public void setRGB(int r, int g, int b) { if (imgInfo.greyscale || imgInfo.indexed) diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java index ecf8b98c3..fa3649613 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java @@ -87,7 +87,7 @@ public class PngMetadata { /** * Creates a time chunk with current time, less secsAgo seconds *

            - * + * * @return Returns the created-queued chunk, just in case you want to * examine or modify it */ @@ -105,7 +105,7 @@ public class PngMetadata { /** * Creates a time chunk with diven date-time *

            - * + * * @return Returns the created-queued chunk, just in case you want to * examine or modify it */ @@ -133,7 +133,7 @@ public class PngMetadata { /** * Creates a text chunk and queue it. *

            - * + * * @param k * : key (latin1) * @param val @@ -201,7 +201,7 @@ public class PngMetadata { /** * Returns the palette chunk, if present - * + * * @return null if not present */ public PngChunkPLTE getPLTE() { @@ -220,7 +220,7 @@ public class PngMetadata { /** * Returns the TRNS chunk, if present - * + * * @return null if not present */ public PngChunkTRNS getTRNS() { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java index bf2d3fa47..7a4e08d26 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java @@ -58,7 +58,7 @@ public class WGLGLCapabilities extends GLCapabilities { setRedBits(pfd.getCRedBits()); setGreenBits(pfd.getCGreenBits()); setBlueBits(pfd.getCBlueBits()); - setAlphaBits(pfd.getCAlphaBits()); + setAlphaBits(pfd.getCAlphaBits()); setAccumRedBits(pfd.getCAccumRedBits()); setAccumGreenBits(pfd.getCAccumGreenBits()); setAccumBlueBits(pfd.getCAccumBlueBits()); @@ -77,12 +77,12 @@ public class WGLGLCapabilities extends GLCapabilities { return true; } - + public static final String PFD2String(PIXELFORMATDESCRIPTOR pfd, int pfdID) { final int dwFlags = pfd.getDwFlags(); StringBuilder sb = new StringBuilder(); boolean sep = false; - + if( 0 != (GDI.PFD_DRAW_TO_WINDOW & dwFlags ) ) { sep = true; sb.append("window"); @@ -106,7 +106,7 @@ public class WGLGLCapabilities extends GLCapabilities { if( 0 == (GDI.PFD_GENERIC_FORMAT & dwFlags ) || 0 == (GDI.PFD_GENERIC_ACCELERATED & dwFlags ) ) { if(sep) { sb.append(CSEP); } sep=true; sb.append("hw-accel"); - } + } return "PFD[id = "+pfdID+" (0x"+Integer.toHexString(pfdID)+ "), colorBits "+pfd.getCColorBits()+", rgba "+pfd.getCRedBits()+ESEP+pfd.getCGreenBits()+ESEP+pfd.getCBlueBits()+ESEP+pfd.getCAlphaBits()+ ", accum-rgba "+pfd.getCAccumRedBits()+ESEP+pfd.getCAccumGreenBits()+ESEP+pfd.getCAccumBlueBits()+ESEP+pfd.getCAccumAlphaBits()+ diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java index 3e788d286..6454a34b5 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLUtil.java @@ -33,15 +33,15 @@ import jogamp.opengl.Debug; public class WGLUtil { /** - * Switch to use the wgl variants of {@link jogamp.opengl.windows.wgl.WGL} + * Switch to use the wgl variants of {@link jogamp.opengl.windows.wgl.WGL} * to replace the following 5 GDI based functions (see below). *

            * Disabled per default. - *

            + *

            *

            * You can enable it by defining the property jogl.windows.useWGLVersionOf5WGLGDIFuncSet. *

            - * + * * @see jogamp.nativewindow.windows.GDI#ChoosePixelFormat(long, PIXELFORMATDESCRIPTOR) * @see jogamp.nativewindow.windows.GDI#DescribePixelFormat(long, int, int, PIXELFORMATDESCRIPTOR) * @see jogamp.nativewindow.windows.GDI#GetPixelFormat(long) @@ -49,7 +49,7 @@ public class WGLUtil { * @see jogamp.nativewindow.windows.GDI#SwapBuffers(long) */ public static final boolean USE_WGLVersion_Of_5WGLGDIFuncSet; - + static { Debug.initSingleton(); USE_WGLVersion_Of_5WGLGDIFuncSet = Debug.isPropertyDefined("jogl.windows.useWGLVersionOf5WGLGDIFuncSet", true); @@ -63,34 +63,34 @@ public class WGLUtil { return WGL.wglChoosePixelFormat(hdc, pfd); } else { return GDI.ChoosePixelFormat(hdc, pfd); - } + } } public static int DescribePixelFormat(long hdc, int pfdid, int pfdSize, PIXELFORMATDESCRIPTOR pfd) { if(USE_WGLVersion_Of_5WGLGDIFuncSet) { return WGL.wglDescribePixelFormat(hdc, pfdid, pfdSize, pfd); } else { return GDI.DescribePixelFormat(hdc, pfdid, pfdSize, pfd); - } + } } public static int GetPixelFormat(long hdc) { if(USE_WGLVersion_Of_5WGLGDIFuncSet) { return WGL.wglGetPixelFormat(hdc); } else { return GDI.GetPixelFormat(hdc); - } + } } - public static boolean SetPixelFormat(long hdc, int pfdid, PIXELFORMATDESCRIPTOR pfd) { + public static boolean SetPixelFormat(long hdc, int pfdid, PIXELFORMATDESCRIPTOR pfd) { if(USE_WGLVersion_Of_5WGLGDIFuncSet) { return WGL.wglSetPixelFormat(hdc, pfdid, pfd); } else { return GDI.SetPixelFormat(hdc, pfdid, pfd); - } + } } - public static boolean SwapBuffers(long hdc) { + public static boolean SwapBuffers(long hdc) { if(USE_WGLVersion_Of_5WGLGDIFuncSet) { return WGL.wglSwapBuffers(hdc); } else { return GDI.SwapBuffers(hdc); - } + } } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java index 909a017b0..f658a3598 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java @@ -63,7 +63,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable { private WindowsBitmapWGLDrawable(GLDrawableFactory factory, NativeSurface comp) { super(factory, comp, false); } - + protected static WindowsBitmapWGLDrawable create(GLDrawableFactory factory, NativeSurface comp) { final WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)comp.getGraphicsConfiguration(); final AbstractGraphicsDevice aDevice = config.getScreen().getDevice(); @@ -102,7 +102,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable { public boolean isGLOriented() { return false; } - + private void createBitmap() { int werr; final NativeSurface ns = getNativeSurface(); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java index a5893775a..966a8b28a 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java @@ -56,7 +56,7 @@ import jogamp.nativewindow.windows.GDI; import jogamp.opengl.GLContextShareSet; public class WindowsExternalWGLContext extends WindowsWGLContext { - + private WindowsExternalWGLContext(Drawable drawable, long ctx, WindowsWGLGraphicsConfiguration cfg) { super(drawable, null); this.contextHandle = ctx; diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java index 217ca18e8..2e60c682b 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -127,7 +127,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { } final int winattrPbuffer = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(false /* onscreen */, false /* fbo */, true /* pbuffer */, false /* bitmap */); - + final IntBuffer iattributes = Buffers.newDirectIntBuffer(2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS); final FloatBuffer fattributes = Buffers.newDirectFloatBuffer(1); int[] floatModeTmp = new int[1]; @@ -162,7 +162,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { if (DEBUG) { System.err.println("" + nformats + " suitable pixel formats found"); for (int i = 0; i < nformats; i++) { - WGLGLCapabilities dbgCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, device, glProfile, + WGLGLCapabilities dbgCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, device, glProfile, sharedHdc, pformats.get(i), winattrPbuffer); System.err.println("pixel format " + pformats.get(i) + " (index " + i + "): " + dbgCaps); } @@ -209,7 +209,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { // Re-query chosen pixel format { - WGLGLCapabilities newCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, device, glProfile, + WGLGLCapabilities newCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, device, glProfile, sharedHdc, pfdid, winattrPbuffer); if(null == newCaps) { throw new GLException("pbuffer creation error: unable to re-query chosen PFD ID: " + pfdid + ", hdc " + GLDrawableImpl.toHexString(tmpHdc)); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index 3fad22d88..d936308af 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -280,7 +280,7 @@ public class WindowsWGLContext extends GLContextImpl { if (DEBUG) { System.err.println(getThreadName() + ": createImpl: START "+glCaps+", share "+shareWith); } - + // Windows can set up sharing of display lists after creation time long share; if ( null != shareWith ) { @@ -405,7 +405,7 @@ public class WindowsWGLContext extends GLContextImpl { protected void makeCurrentImpl() throws GLException { if (WGL.wglGetCurrentContext() != contextHandle) { if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { - throw new GLException("Error making context " + toHexString(contextHandle) + + throw new GLException("Error making context " + toHexString(contextHandle) + " current on Thread " + getThreadName() + ", drawableWrite " + toHexString(drawable.getHandle()) + ", drawableRead "+ toHexString(drawableRead.getHandle()) + @@ -563,13 +563,13 @@ public class WindowsWGLContext extends GLContextImpl { } @Override - public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { + public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { return getWGLExt().wglAllocateMemoryNV(size, readFrequency, writeFrequency, priority); } - + @Override public final void glFreeMemoryNV(ByteBuffer pointer) { getWGLExt().wglFreeMemoryNV(pointer); } - + } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java index 741e671eb..66071cbe1 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java @@ -52,12 +52,12 @@ import jogamp.opengl.GLDynamicLookupHelper; public abstract class WindowsWGLDrawable extends GLDrawableImpl { private static final boolean PROFILING; - + static { Debug.initSingleton(); PROFILING = Debug.isPropertyDefined("jogl.debug.GLDrawable.profiling", true); } - + private static final int PROFILING_TICKS = 200; private int profilingSwapBuffersTicks; private long profilingSwapBuffersTime; @@ -87,11 +87,11 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl { } else { t0 = 0; } - + if (!WGLUtil.SwapBuffers(getHandle()) && (GDI.GetLastError() != GDI.ERROR_SUCCESS)) { throw new GLException("Error swapping buffers"); } - + if (PROFILING) { profilingSwapBuffersTime += System.currentTimeMillis() - t0; if (++profilingSwapBuffersTicks == PROFILING_TICKS) { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 156e75196..203af110c 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -137,8 +137,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { protected final boolean isComplete() { return null != windowsWGLDynamicLookupHelper; } - - + + @Override protected final void destroy() { if(null != sharedResourceRunner) { @@ -216,7 +216,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { private AbstractGraphicsScreen screen; private GLDrawableImpl drawable; private GLContextImpl context; - + SharedResource(WindowsGraphicsDevice dev, AbstractGraphicsScreen scrn, GLDrawableImpl draw, GLContextImpl ctx, boolean arbPixelFormat, boolean arbMultisample, boolean arbPBuffer, boolean arbReadDrawable) { device = dev; @@ -243,7 +243,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { final public GLContextImpl getContext() { return context; } @Override public GLRendererQuirks getRendererQuirks() { - return null != context ? context.getRendererQuirks() : null; + return null != context ? context.getRendererQuirks() : null; } final boolean hasARBPixelFormat() { return hasARBPixelFormat; } @@ -276,7 +276,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { public boolean isDeviceSupported(String connection) { return true; } - + @Override public SharedResourceRunner.Resource createSharedResource(String connection) { final WindowsGraphicsDevice sharedDevice = new WindowsGraphicsDevice(connection, AbstractGraphicsDevice.DEFAULT_UNIT); @@ -290,7 +290,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { final GLCapabilitiesImmutable caps = new GLCapabilities(glp); final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, caps, caps, null, 64, 64)); sharedDrawable.setRealized(true); - + final GLContextImpl sharedContext = (GLContextImpl) sharedDrawable.createContext(null); if (null == sharedContext) { throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable); @@ -473,8 +473,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected final ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, - GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, + protected final ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final WindowsGraphicsDevice device; if(createNewDevice || !(deviceReq instanceof WindowsGraphicsDevice)) { @@ -485,13 +485,13 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); final WindowsWGLGraphicsConfiguration config = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen); if(null == config) { - throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); - } + throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); + } return new WrappedSurface(config, 0, upstreamHook, createNewDevice); } @Override - public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { final WindowsGraphicsDevice device; if( createNewDevice || !(deviceReq instanceof WindowsGraphicsDevice) ) { @@ -502,12 +502,12 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); final WindowsWGLGraphicsConfiguration config = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(chosenCaps, requestedCaps, chooser, screen); - if(null == config) { + if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+chosenCaps+" on "+screen); - } + } return new GDISurface(config, 0, new GDIDummyUpstreamSurfaceHook(width, height), createNewDevice); - } - + } + @Override protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { final WindowsGraphicsDevice device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java index 7ec6c50f8..6098cde7f 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDynamicLibraryBundleInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl.windows.wgl; import jogamp.opengl.*; @@ -41,10 +41,10 @@ public final class WindowsWGLDynamicLibraryBundleInfo extends DesktopGLDynamicLi final List> libsList = new ArrayList>(); final List libsGL = new ArrayList(); libsGL.add("OpenGL32"); - libsList.add(libsGL); + libsList.add(libsGL); return libsList; } - + @Override public final List getToolGetProcAddressFuncNameList() { List res = new ArrayList(); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 42b92305a..cb445f005 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -58,7 +58,7 @@ import jogamp.nativewindow.windows.MARGINS; import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR; import jogamp.opengl.GLGraphicsConfigurationUtil; -public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { +public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { protected static final int MAX_PFORMATS = 256; protected static final int MAX_ATTRIBS = 256; @@ -66,7 +66,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio private boolean isDetermined = false; private boolean isExternal = false; - WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen, + WindowsWGLGraphicsConfiguration(AbstractGraphicsScreen screen, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { super(screen, capsChosen, capsRequested); @@ -161,7 +161,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio if (0 == hdc) { throw new GLException("Error: HDC is null"); } - + if (!WGLUtil.SetPixelFormat(hdc, caps.getPFDID(), caps.getPFD())) { throw new GLException("Unable to set pixel format " + caps.getPFDID() + " of " + caps + " for device context " + toHexString(hdc) + @@ -192,7 +192,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } setCapsPFD(caps); } - + /** * Only sets this configuration's capabilities and marks it as determined, * the actual pixelformat is not set. @@ -209,20 +209,20 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio * External configuration's HDC pixelformat shall not be modified */ public final boolean isExternal() { return isExternal; } - + final void markExternal() { this.isExternal=true; } - + /** * Determined configuration states set target capabilties via {@link #setCapsPFD(WGLGLCapabilities)}, * but does not imply a set pixelformat. - * - * @see #setPixelFormat(long, WGLGLCapabilities) + * + * @see #setPixelFormat(long, WGLGLCapabilities) * @see #setCapsPFD(WGLGLCapabilities) */ public final boolean isDetermined() { return isDetermined; } - + public final PIXELFORMATDESCRIPTOR getPixelFormat() { return isDetermined ? ((WGLGLCapabilities)capabilitiesChosen).getPFD() : null; } public final int getPixelFormatID() { return isDetermined ? ((WGLGLCapabilities)capabilitiesChosen).getPFDID() : 0; } public final boolean isChoosenByARB() { return isDetermined ? ((WGLGLCapabilities)capabilitiesChosen).isSetByARB() : false; } @@ -255,7 +255,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } return niattribs; } - + static boolean wglARBPFIDValid(WindowsWGLContext sharedCtx, long hdc, int pfdID) { final IntBuffer out = Buffers.newDirectIntBuffer(1); final IntBuffer in = Buffers.newDirectIntBuffer(1); @@ -270,7 +270,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio static int wglARBPFDIDCount(WindowsWGLContext sharedCtx, long hdc) { final IntBuffer iresults = Buffers.newDirectIntBuffer(1); final IntBuffer iattributes = Buffers.newDirectIntBuffer(1); - iattributes.put(0, WGLExt.WGL_NUMBER_PIXEL_FORMATS_ARB); + iattributes.put(0, WGLExt.WGL_NUMBER_PIXEL_FORMATS_ARB); WGLExt wglExt = sharedCtx.getWGLExt(); // pfdID shall be ignored here (spec), however, pass a valid pdf index '1' below (possible driver bug) @@ -293,7 +293,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } return pfdIDCount; } - + static int[] wglAllARBPFDIDs(int pfdIDCount) { int[] pfdIDs = new int[pfdIDCount]; for (int i = 0; i < pfdIDCount; i++) { @@ -301,7 +301,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } return pfdIDs; } - + static WGLGLCapabilities wglARBPFID2GLCapabilities(WindowsWGLDrawableFactory.SharedResource sharedResource, AbstractGraphicsDevice device, GLProfile glp, long hdc, int pfdID, int winattrbits) { @@ -314,7 +314,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio final int niattribs = fillAttribsForGeneralWGLARBQuery(sharedResource, iattributes); if (!((WindowsWGLContext)sharedResource.getContext()).getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdID, 0, niattribs, iattributes, iresults)) { - throw new GLException("wglARBPFID2GLCapabilities: Error getting pixel format attributes for pixel format " + pfdID + + throw new GLException("wglARBPFID2GLCapabilities: Error getting pixel format attributes for pixel format " + pfdID + " of device context " + toHexString(hdc) + ", werr " + GDI.GetLastError()); } return AttribList2GLCapabilities(device, glp, hdc, pfdID, iattributes, niattribs, iresults, winattrbits); @@ -338,7 +338,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio final WGLExt wglExt = ((WindowsWGLContext)sharedResource.getContext()).getWGLExt(); final IntBuffer pformatsTmp = Buffers.newDirectIntBuffer(WindowsWGLGraphicsConfiguration.MAX_PFORMATS); final IntBuffer numFormatsTmp = Buffers.newDirectIntBuffer(1); - + if ( !wglExt.wglChoosePixelFormatARB(hdc, iattributes, fattributes, WindowsWGLGraphicsConfiguration.MAX_PFORMATS, pformatsTmp, numFormatsTmp) ) { @@ -388,7 +388,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio if(null != caps) { bucket.add(caps); if(DEBUG) { - final int j = bucket.size() - 1; + final int j = bucket.size() - 1; System.err.println("wglARBPFIDs2GLCapabilities: bucket["+i+" -> "+j+"]: "+caps); } } else if(DEBUG) { @@ -411,7 +411,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio IntBuffer iattributes, WindowsWGLDrawableFactory.SharedResource sharedResource, int accelerationValue, - int[] floatMode) throws GLException { + int[] floatMode) throws GLException { if (!sharedResource.hasARBPixelFormat()) { return false; } @@ -426,10 +426,10 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } final boolean usePBuffer = caps.isPBuffer() && sharedResource.hasARBPBuffer() ; - + final int surfaceType; if( caps.isOnscreen() ) { - surfaceType = WGLExt.WGL_DRAW_TO_WINDOW_ARB; + surfaceType = WGLExt.WGL_DRAW_TO_WINDOW_ARB; } else if( caps.isFBO() ) { surfaceType = WGLExt.WGL_DRAW_TO_WINDOW_ARB; // native replacement! } else if( usePBuffer ) { @@ -441,7 +441,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } iattributes.put(niattribs++, surfaceType); iattributes.put(niattribs++, GL.GL_TRUE); - + iattributes.put(niattribs++, WGLExt.WGL_DOUBLE_BUFFER_ARB); if (caps.getDoubleBuffered()) { iattributes.put(niattribs++, GL.GL_TRUE); @@ -455,7 +455,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } else { iattributes.put(niattribs++, GL.GL_FALSE); } - + iattributes.put(niattribs++, WGLExt.WGL_RED_BITS_ARB); iattributes.put(niattribs++, caps.getRedBits()); iattributes.put(niattribs++, WGLExt.WGL_GREEN_BITS_ARB); @@ -505,7 +505,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio return true; } - static int AttribList2DrawableTypeBits(final IntBuffer iattribs, + static int AttribList2DrawableTypeBits(final IntBuffer iattribs, final int niattribs, final IntBuffer iresults) { int val = 0; @@ -533,7 +533,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio return val; } - static WGLGLCapabilities AttribList2GLCapabilities(final AbstractGraphicsDevice device, + static WGLGLCapabilities AttribList2GLCapabilities(final AbstractGraphicsDevice device, final GLProfile glp, final long hdc, final int pfdID, final IntBuffer iattribs, final int niattribs, IntBuffer iresults, final int winattrmask) { final int allDrawableTypeBits = AttribList2DrawableTypeBits(iattribs, niattribs, iresults); @@ -554,7 +554,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); res.setValuesByARB(iattribs, niattribs, iresults); - return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); + return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } // @@ -608,7 +608,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } if( GLGraphicsConfigurationUtil.BITMAP_BIT == drawableTypeBits ) { // BITMAP exclusive PFD SafeGuard: Only accept BITMAP compatible color formats! - final int pfdColorBits = pfd.getCColorBits(); + final int pfdColorBits = pfd.getCColorBits(); if ( pfdColorBits != 24 || 0 < pfd.getCAlphaBits() ) { // Allowed: RGB888 && !alpha if(DEBUG) { System.err.println("Drop [color bits excl BITMAP]: " + WGLGLCapabilities.PFD2String(pfd, pfdID)); @@ -619,24 +619,24 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); res.setValuesByGDI(); - return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); + return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(AbstractGraphicsDevice device, final GLProfile glp, final long hdc, final int pfdID) { PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor(hdc, pfdID); return PFD2GLCapabilitiesNoCheck(device, glp, pfd, pfdID); } - + static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(AbstractGraphicsDevice device, GLProfile glp, PIXELFORMATDESCRIPTOR pfd, int pfdID) { if(null == pfd) { return null; } final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); res.setValuesByGDI(); - - return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, PFD2DrawableTypeBits(pfd), res); + + return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, PFD2DrawableTypeBits(pfd), res); } - + static PIXELFORMATDESCRIPTOR GLCapabilities2PFD(GLCapabilitiesImmutable caps, PIXELFORMATDESCRIPTOR pfd) { int colorDepth = (caps.getRedBits() + caps.getGreenBits() + @@ -665,7 +665,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio pfdFlags |= GDI.PFD_DOUBLEBUFFER; } } - + if (caps.getStereo()) { pfdFlags |= GDI.PFD_STEREO; } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index 3d093b972..9e917a0eb 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -93,7 +93,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat if (chooser != null && !(chooser instanceof GLCapabilitiesChooser)) { throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects"); } - + return chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested, (GLCapabilitiesChooser)chooser, absScreen); } @@ -123,7 +123,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat final GLProfile glp = GLProfile.getDefault(device); List availableCaps = null; - + final GLContext sharedContext; if ( factory.hasRendererQuirk(device, GLRendererQuirks.NeedCurrCtx4ARBPixFmtQueries) ) { sharedContext = sharedResource.getContext(); @@ -151,10 +151,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } } finally { if ( null != sharedContext ) { - sharedContext.release(); + sharedContext.release(); } else { sharedDrawable.unlockSurface(); - } + } } if( null != availableCaps && availableCaps.size() > 1 ) { @@ -166,7 +166,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat private static List getAvailableGLCapabilitiesARB(WindowsWGLDrawableFactory.SharedResource sharedResource, AbstractGraphicsDevice device, GLProfile glProfile, long hdc) { final int pfdIDCount = WindowsWGLGraphicsConfiguration.wglARBPFDIDCount((WindowsWGLContext)sharedResource.getContext(), hdc); final int[] pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFDIDs(pfdIDCount); - return WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, device, glProfile, hdc, pformats, + return WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, device, glProfile, hdc, pformats, GLGraphicsConfigurationUtil.ALL_BITS & ~GLGraphicsConfigurationUtil.BITMAP_BIT); // w/o BITMAP } @@ -175,7 +175,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat int numFormats = pformats.length; List bucket = new ArrayList(numFormats); for (int i = 0; i < numFormats; i++) { - final GLCapabilitiesImmutable caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pformats[i], + final GLCapabilitiesImmutable caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pformats[i], bitmapOnly ? GLGraphicsConfigurationUtil.BITMAP_BIT : GLGraphicsConfigurationUtil.ALL_BITS ); if(null != caps) { bucket.add(caps); @@ -226,7 +226,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat " for device context " + toHexString(hdc) + ": error code " + GDI.GetLastError()); } - set = true; + set = true; } if (DEBUG) { System.err.println("setPixelFormat (post): hdc "+toHexString(hdc) +", "+pfdID+" -> "+config.getPixelFormatID()+", set: "+set); @@ -332,9 +332,9 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat final boolean isOpaque = capsChosen.isBackgroundOpaque() && GDI.DwmIsCompositionEnabled(); final int winattrbits = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsChosen) & ~GLGraphicsConfigurationUtil.BITMAP_BIT; // w/o BITMAP final GLProfile glProfile = capsChosen.getGLProfile(); - + final int pfdIDCount = WindowsWGLGraphicsConfiguration.wglARBPFDIDCount((WindowsWGLContext)sharedResource.getContext(), hdc); - + if(DEBUG) { System.err.println("updateGraphicsConfigurationARB: hdc "+toHexString(hdc)+", pfdIDCount(hdc) "+pfdIDCount+", capsChosen "+capsChosen+", "+GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrbits).toString()); System.err.println("isOpaque "+isOpaque+" (translucency requested: "+(!capsChosen.isBackgroundOpaque())+", compositioning enabled: "+GDI.DwmIsCompositionEnabled()+")"); @@ -346,7 +346,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } return false; } - + WGLGLCapabilities pixelFormatCaps = null; // chosen or preset PFD ID's caps boolean pixelFormatSet = false; // indicates a preset PFD ID [caps] final int presetPFDID = extHDC ? -1 : WGLUtil.GetPixelFormat(hdc) ; @@ -406,9 +406,9 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } } - List availableCaps = + List availableCaps = WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, device, glProfile, hdc, pformats, winattrbits); - + if( null == availableCaps || 0 == availableCaps.size() ) { if (DEBUG) { System.err.println("updateGraphicsConfigurationARB: wglARBPFIDs2GLCapabilities failed with " + pformats.length + " pfd ids"); @@ -467,11 +467,11 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat // final boolean useFBO = capsChosen.isFBO(); final GLProfile glProfile = capsChosen.getGLProfile(); final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsChosen); - + if(DEBUG) { System.err.println("updateGraphicsConfigurationGDI: capsChosen "+capsChosen+", "+GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrmask).toString()); } - + AbstractGraphicsDevice device = config.getScreen().getDevice(); int pfdID; // chosen or preset PFD ID WGLGLCapabilities pixelFormatCaps = null; // chosen or preset PFD ID's caps @@ -503,7 +503,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat if(null != caps) { availableCaps.add(caps); if(DEBUG) { - final int j = availableCaps.size() - 1; + final int j = availableCaps.size() - 1; System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> "+j+"]: "+caps); } } else if(DEBUG) { @@ -543,7 +543,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } pixelFormatCaps = (WGLGLCapabilities) availableCaps.get(chosenIndex); if (DEBUG) { - System.err.println("chosen pfdID (GDI): chosenIndex "+ chosenIndex + ", caps " + pixelFormatCaps + + System.err.println("chosen pfdID (GDI): chosenIndex "+ chosenIndex + ", caps " + pixelFormatCaps + " (" + WGLGLCapabilities.PFD2String(pixelFormatCaps.getPFD(), pixelFormatCaps.getPFDID()) +")"); } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java index 3b2ff133a..ddfcbb55b 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -65,7 +65,7 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu public static void registerFactory() { GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, GLCapabilitiesImmutable.class, new WindowsAWTWGLGraphicsConfigurationFactory()); } - private WindowsAWTWGLGraphicsConfigurationFactory() { + private WindowsAWTWGLGraphicsConfigurationFactory() { } protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( @@ -114,7 +114,7 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu throw new GLException("Unable to choose a GraphicsConfiguration: "+capsChosen+",\n\t"+chooser+"\n\t"+winScreen); } - GLDrawableFactory drawableFactory = GLDrawableFactory.getFactory(((GLCapabilitiesImmutable)capsChosen).getGLProfile()); + GLDrawableFactory drawableFactory = GLDrawableFactory.getFactory(((GLCapabilitiesImmutable)capsChosen).getGLProfile()); GraphicsConfiguration chosenGC = null; if ( drawableFactory instanceof WindowsWGLDrawableFactory ) { @@ -138,7 +138,7 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu } // go on .. } - + if( null == chosenGC ) { // 2nd Choice: Choose and match the GL Visual with AWT: // - collect all AWT PFDs @@ -147,7 +147,7 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu // The resulting GraphicsConfiguration has to be 'forced' on the AWT native peer, // ie. returned by GLCanvas's getGraphicsConfiguration() befor call by super.addNotify(). // - + // collect all available PFD IDs GraphicsConfiguration[] configs = device.getConfigurations(); int[] pfdIDs = new int[configs.length]; @@ -171,11 +171,11 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found matching AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig); } } - } + } } else { chosenGC = device.getDefaultConfiguration(); } - + if ( null == chosenGC ) { throw new GLException("Unable to determine GraphicsConfiguration: "+winConfig); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java b/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java index 2c591cfbd..12e3db3bd 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -45,14 +45,14 @@ import com.jogamp.nativewindow.x11.X11GraphicsDevice; public class GLXUtil { public static final boolean DEBUG = Debug.debug("GLXUtil"); - + public static synchronized boolean isGLXAvailableOnServer(X11GraphicsDevice x11Device) { if(null == x11Device) { throw new IllegalArgumentException("null X11GraphicsDevice"); } if(0 == x11Device.getHandle()) { throw new IllegalArgumentException("null X11GraphicsDevice display handle"); - } + } boolean glXAvailable = false; x11Device.lock(); try { @@ -60,17 +60,17 @@ public class GLXUtil { } catch (Throwable t) { /* n/a */ } finally { x11Device.unlock(); - } - return glXAvailable; + } + return glXAvailable; } - + public static String getGLXClientString(X11GraphicsDevice x11Device, int name) { x11Device.lock(); try { return GLX.glXGetClientString(x11Device.getHandle(), name); } finally { x11Device.unlock(); - } + } } public static String queryGLXServerString(X11GraphicsDevice x11Device, int screen_idx, int name) { x11Device.lock(); @@ -78,27 +78,27 @@ public class GLXUtil { return GLX.glXQueryServerString(x11Device.getHandle(), screen_idx, name); } finally { x11Device.unlock(); - } - } + } + } public static String queryGLXExtensionsString(X11GraphicsDevice x11Device, int screen_idx) { x11Device.lock(); try { return GLX.glXQueryExtensionsString(x11Device.getHandle(), screen_idx); } finally { x11Device.unlock(); - } + } } - + public static VersionNumber getGLXServerVersionNumber(X11GraphicsDevice x11Device) { final IntBuffer major = Buffers.newDirectIntBuffer(1); final IntBuffer minor = Buffers.newDirectIntBuffer(1); - + x11Device.lock(); try { if (!GLX.glXQueryVersion(x11Device.getHandle(), major, minor)) { throw new GLException("glXQueryVersion failed"); } - + // Work around bugs in ATI's Linux drivers where they report they // only implement GLX version 1.2 on the server side if (major.get(0) == 1 && minor.get(0) == 2) { @@ -117,7 +117,7 @@ public class GLXUtil { } return new VersionNumber(major.get(0), minor.get(0), 0); } - + public static boolean isMultisampleAvailable(String extensions) { if (extensions != null) { return (extensions.indexOf("GLX_ARB_multisample") >= 0); @@ -142,8 +142,8 @@ public class GLXUtil { public static VersionNumber getClientVersionNumber() { return clientVersionNumber; } - - public static synchronized void initGLXClientDataSingleton(X11GraphicsDevice x11Device) { + + public static synchronized void initGLXClientDataSingleton(X11GraphicsDevice x11Device) { if(null != clientVendorName) { return; // already initialized } @@ -152,10 +152,10 @@ public class GLXUtil { } if(0 == x11Device.getHandle()) { throw new IllegalArgumentException("null X11GraphicsDevice display handle"); - } + } clientMultisampleAvailable = isMultisampleAvailable(GLX.glXGetClientString(x11Device.getHandle(), GLX.GLX_EXTENSIONS)); clientVendorName = GLX.glXGetClientString(x11Device.getHandle(), GLX.GLX_VENDOR); - + int[] major = new int[1]; int[] minor = new int[1]; final String str = GLX.glXGetClientString(x11Device.getHandle(), GLX.GLX_VERSION); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index 72e84b05e..ba88ff3c4 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -79,15 +79,15 @@ public class X11ExternalGLXContext extends X11GLXContext { long drawable = GLX.glXGetCurrentDrawable(); if (drawable == 0) { throw new GLException("Error: attempted to make an external GLDrawable without a drawable/context current"); - } + } IntBuffer val = Buffers.newDirectIntBuffer(1); - + int w, h; GLX.glXQueryDrawable(display, drawable, GLX.GLX_WIDTH, val); w=val.get(0); GLX.glXQueryDrawable(display, drawable, GLX.GLX_HEIGHT, val); h=val.get(0); - + GLX.glXQueryContext(display, ctx, GLX.GLX_SCREEN, val); X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val.get(0), false); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java index fca36c0cc..650fd31d3 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java @@ -73,7 +73,7 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { throw new GLException("Error: attempted to make an external GLDrawable without a drawable current"); } IntBuffer val = Buffers.newDirectIntBuffer(1); - + GLX.glXQueryContext(display, context, GLX.GLX_SCREEN, val); X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val.get(0), false); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index 0ecf11a43..22a48e093 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -142,7 +142,7 @@ public class X11GLXContext extends GLContextImpl { if(null != glXServerVersion) { return isGLXVersionGreaterEqualOneThree; } - glXServerVersion = ((X11GLXDrawableFactory)drawable.getFactoryImpl()).getGLXVersionNumber(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice()); + glXServerVersion = ((X11GLXDrawableFactory)drawable.getFactoryImpl()).getGLXVersionNumber(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice()); isGLXVersionGreaterEqualOneThree = null != glXServerVersion ? glXServerVersion.compareTo(X11GLXDrawableFactory.versionOneThree) >= 0 : false; return isGLXVersionGreaterEqualOneThree; } @@ -262,7 +262,7 @@ public class X11GLXContext extends GLContextImpl { t.printStackTrace(); } } - + if(0!=ctx) { if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), ctx)) { if(DEBUG) { @@ -419,7 +419,7 @@ public class X11GLXContext extends GLContextImpl { if (GLX.glXGetCurrentContext() != contextHandle) { if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { - throw new GLException("Error making context " + toHexString(contextHandle) + + throw new GLException("Error making context " + toHexString(contextHandle) + " current on Thread " + getThreadName() + " with display " + toHexString(dpy) + ", drawableWrite " + toHexString(drawable.getHandle()) + @@ -525,7 +525,7 @@ public class X11GLXContext extends GLContextImpl { @Override protected boolean setSwapIntervalImpl(int interval) { - if( !drawable.getChosenGLCapabilities().isOnscreen() ) { return false; } + if( !drawable.getChosenGLCapabilities().isOnscreen() ) { return false; } final GLXExt glXExt = getGLXExt(); if(0==hasSwapInterval) { @@ -534,7 +534,7 @@ public class X11GLXContext extends GLContextImpl { if( glXExt.isExtensionAvailable(GLXExtensions.GLX_MESA_swap_control) ) { if(DEBUG) { System.err.println("X11GLXContext.setSwapInterval using: "+GLXExtensions.GLX_MESA_swap_control); } hasSwapInterval = 1; - } else */ + } else */ if ( glXExt.isExtensionAvailable(GLXExtensions.GLX_SGI_swap_control) ) { if(DEBUG) { System.err.println("X11GLXContext.setSwapInterval using: "+GLXExtensions.GLX_SGI_swap_control); } hasSwapInterval = 2; @@ -542,7 +542,7 @@ public class X11GLXContext extends GLContextImpl { hasSwapInterval = -1; } } catch (Throwable t) { hasSwapInterval=-1; } - } + } /* try { switch( hasSwapInterval ) { case 1: @@ -581,7 +581,7 @@ public class X11GLXContext extends GLContextImpl { try { final IntBuffer maxGroupsNIO = Buffers.newDirectIntBuffer(maxGroups.length - maxGroups_offset); final IntBuffer maxBarriersNIO = Buffers.newDirectIntBuffer(maxBarriers.length - maxBarriers_offset); - + if( glXExt.glXQueryMaxSwapGroupsNV(ns.getDisplayHandle(), ns.getScreenIndex(), maxGroupsNIO, maxBarriersNIO) ) { maxGroupsNIO.get(maxGroups, maxGroups_offset, maxGroupsNIO.remaining()); @@ -623,7 +623,7 @@ public class X11GLXContext extends GLContextImpl { } @Override - public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { + public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { return getGLXExt().glXAllocateMemoryNV(size, readFrequency, writeFrequency, priority); } @@ -631,7 +631,7 @@ public class X11GLXContext extends GLContextImpl { public final void glFreeMemoryNV(ByteBuffer pointer) { getGLXExt().glXFreeMemoryNV(pointer); } - + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 5df458b7e..3f0841b6c 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -86,7 +86,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { public static final VersionNumber versionOneFour = new VersionNumber(1, 4, 0); static final String GLX_SGIX_pbuffer = "GLX_SGIX_pbuffer"; - + private static DesktopGLDynamicLookupHelper x11GLXDynamicLookupHelper = null; public X11GLXDrawableFactory() { @@ -134,7 +134,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { protected final boolean isComplete() { return null != x11GLXDynamicLookupHelper; } - + @Override protected final void destroy() { if(null != sharedResourceRunner) { @@ -205,7 +205,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { final public GLContextImpl getContext() { return context; } @Override public GLRendererQuirks getRendererQuirks() { - return null != context ? context.getRendererQuirks() : null; + return null != context ? context.getRendererQuirks() : null; } final String getGLXVendorName() { return glXServerVendorName; } @@ -251,18 +251,18 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } return res; } - + @Override public SharedResourceRunner.Resource createSharedResource(String connection) { final X11GraphicsDevice sharedDevice = new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); sharedDevice.lock(); try { final X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, sharedDevice.getDefaultScreen()); - + GLXUtil.initGLXClientDataSingleton(sharedDevice); final String glXServerVendorName = GLX.glXQueryServerString(sharedDevice.getHandle(), 0, GLX.GLX_VENDOR); final boolean glXServerMultisampleAvailable = GLXUtil.isMultisampleAvailable(GLX.glXQueryServerString(sharedDevice.getHandle(), 0, GLX.GLX_EXTENSIONS)); - + final GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP, false); if (null == glp) { throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice); @@ -283,7 +283,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if (null == sharedContext) { throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable); } - + boolean madeCurrent = false; sharedContext.makeCurrent(); try { @@ -493,12 +493,12 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected final ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + protected final ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final X11GraphicsDevice device; - if( createNewDevice || !(deviceReq instanceof X11GraphicsDevice) ) { + if( createNewDevice || !(deviceReq instanceof X11GraphicsDevice) ) { device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true /* owner */); } else { device = (X11GraphicsDevice) deviceReq; @@ -506,18 +506,18 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { final X11GraphicsScreen screen = new X11GraphicsScreen(device, device.getDefaultScreen()); final X11GLXGraphicsConfiguration config = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED); if(null == config) { - throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); + throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } return new WrappedSurface(config, 0, upstreamHook, createNewDevice); } - + @Override - public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new X11DummyUpstreamSurfaceHook(width, height)); - } - + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new X11DummyUpstreamSurfaceHook(width, height)); + } + @Override protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true /* owner */); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDynamicLibraryBundleInfo.java index f25f7ae2c..951174f71 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDynamicLibraryBundleInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl.x11.glx; import jogamp.opengl.*; @@ -40,8 +40,8 @@ public final class X11GLXDynamicLibraryBundleInfo extends DesktopGLDynamicLibrar public final List> getToolLibNames() { final List> libsList = new ArrayList>(); final List libsGL = new ArrayList(); - - // Be aware that on DRI systems, eg ATI fglrx, etc, + + // Be aware that on DRI systems, eg ATI fglrx, etc, // you have to set LIBGL_DRIVERS_PATH env variable. // Eg on Ubuntu 64bit systems this is: // export LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri @@ -55,11 +55,11 @@ public final class X11GLXDynamicLibraryBundleInfo extends DesktopGLDynamicLibrar // last but not least .. the generic one libsGL.add("GL"); - - libsList.add(libsGL); + + libsList.add(libsGL); return libsList; - } - + } + @Override public final List getToolGetProcAddressFuncNameList() { List res = new ArrayList(); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java index c23bd5337..5aea33f21 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -61,9 +61,9 @@ import com.jogamp.nativewindow.x11.X11GraphicsScreen; public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implements Cloneable { public static final int MAX_ATTRIBS = 128; - private GLCapabilitiesChooser chooser; + private GLCapabilitiesChooser chooser; - X11GLXGraphicsConfiguration(X11GraphicsScreen screen, + X11GLXGraphicsConfiguration(X11GraphicsScreen screen, X11GLCapabilities capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { super(screen, capsChosen, capsRequested, capsChosen.getXVisualInfo()); this.chooser=chooser; @@ -86,8 +86,8 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem void updateGraphicsConfiguration() { final CapabilitiesImmutable aChosenCaps = getChosenCapabilities(); if( !(aChosenCaps instanceof X11GLCapabilities) || VisualIDHolder.VID_UNDEFINED == aChosenCaps.getVisualID(VIDType.X11_XVISUAL) ) { - // This case is actually quite impossible, since on X11 the visualID and hence GraphicsConfiguration - // must be determined _before_ window creation! + // This case is actually quite impossible, since on X11 the visualID and hence GraphicsConfiguration + // must be determined _before_ window creation! final X11GLXGraphicsConfiguration newConfig = (X11GLXGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(getScreen().getDevice(), aChosenCaps).chooseGraphicsConfiguration( aChosenCaps, getRequestedCapabilities(), chooser, getScreen(), VisualIDHolder.VID_UNDEFINED); @@ -121,7 +121,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem glp = GLProfile.getDefault(x11Screen.getDevice()); } final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - final X11GLCapabilities caps = GLXFBConfig2GLCapabilities(device, glp, fbcfg, GLGraphicsConfigurationUtil.ALL_BITS, factory.isGLXMultisampleAvailable(device)); + final X11GLCapabilities caps = GLXFBConfig2GLCapabilities(device, glp, fbcfg, GLGraphicsConfigurationUtil.ALL_BITS, factory.isGLXMultisampleAvailable(device)); if(null==caps) { throw new GLException("GLCapabilities null of "+toHexString(fbcfg)); } @@ -130,7 +130,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem static IntBuffer GLCapabilities2AttribList(GLCapabilitiesImmutable caps, boolean forFBAttr, boolean isMultisampleAvailable, - long display, int screen) + long display, int screen) { int colorDepth = (caps.getRedBits() + caps.getGreenBits() + @@ -143,7 +143,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem if (forFBAttr) { res.put(idx++, GLX.GLX_DRAWABLE_TYPE); - + final int surfaceType; if( caps.isOnscreen() ) { surfaceType = GLX.GLX_WINDOW_BIT; @@ -157,7 +157,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem throw new GLException("no surface type set in caps: "+caps); } res.put(idx++, surfaceType); - + res.put(idx++, GLX.GLX_RENDER_TYPE); res.put(idx++, GLX.GLX_RGBA_BIT); } else { @@ -233,8 +233,8 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem } // FBConfig - - static boolean GLXFBConfigIDValid(long display, int screen, int fbcfgid) { + + static boolean GLXFBConfigIDValid(long display, int screen, int fbcfgid) { long fbcfg = X11GLXGraphicsConfiguration.glXFBConfigID2FBConfig(display, screen, fbcfgid); return (0 != fbcfg) ? X11GLXGraphicsConfiguration.GLXFBConfigValid( display, fbcfg ) : false ; } @@ -278,8 +278,8 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem int winattrmask, boolean isMultisampleAvailable) { final int allDrawableTypeBits = FBCfgDrawableTypeBits(device, fbcfg); int drawableTypeBits = winattrmask & allDrawableTypeBits; - - final long display = device.getHandle(); + + final long display = device.getHandle(); int fbcfgid = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfg); XVisualInfo visualInfo = GLX.glXGetVisualFromFBConfig(display, fbcfg); if(null == visualInfo) { @@ -307,8 +307,8 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.setSampleBuffers(glXGetFBConfig(display, fbcfg, GLX.GLX_SAMPLE_BUFFERS, tmp) != 0); res.setNumSamples (glXGetFBConfig(display, fbcfg, GLX.GLX_SAMPLES, tmp)); } - final XRenderDirectFormat xrmask = ( null != visualInfo ) ? - XVisual2XRenderMask( display, visualInfo.getVisual() ) : + final XRenderDirectFormat xrmask = ( null != visualInfo ) ? + XVisual2XRenderMask( display, visualInfo.getVisual() ) : null ; final int alphaMask = ( null != xrmask ) ? xrmask.getAlphaMask() : 0; res.setBackgroundOpaque( 0 >= alphaMask ); @@ -318,7 +318,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.setTransparentBlueValue(xrmask.getBlueMask()); res.setTransparentAlphaValue(alphaMask); } - // ALPHA shall be set at last - due to it's auto setting by the above (!opaque / samples) + // ALPHA shall be set at last - due to it's auto setting by the above (!opaque / samples) res.setDoubleBuffered(glXGetFBConfig(display, fbcfg, GLX.GLX_DOUBLEBUFFER, tmp) != 0); res.setStereo (glXGetFBConfig(display, fbcfg, GLX.GLX_STEREO, tmp) != 0); res.setHardwareAccelerated(glXGetFBConfig(display, fbcfg, GLX.GLX_CONFIG_CAVEAT, tmp) != GLX.GLX_SLOW_CONFIG); @@ -332,8 +332,8 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.setAccumAlphaBits(glXGetFBConfig(display, fbcfg, GLX.GLX_ACCUM_ALPHA_SIZE, tmp)); res.setDepthBits (glXGetFBConfig(display, fbcfg, GLX.GLX_DEPTH_SIZE, tmp)); res.setStencilBits (glXGetFBConfig(display, fbcfg, GLX.GLX_STENCIL_SIZE, tmp)); - - return (X11GLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); + + return (X11GLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } private static String glXGetFBConfigErrorCode(int err) { @@ -363,7 +363,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem static long glXFBConfigID2FBConfig(long display, int screen, int id) { final IntBuffer attribs = Buffers.newDirectIntBuffer(new int[] { GLX.GLX_FBCONFIG_ID, id, 0 }); final IntBuffer count = Buffers.newDirectIntBuffer(1); - count.put(0, -1); + count.put(0, -1); PointerBuffer fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, count); if (fbcfgsL == null || fbcfgsL.limit()<1) { return 0; @@ -380,7 +380,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem XVisualInfo[] infos = X11Lib.XGetVisualInfo(display, X11Lib.VisualIDMask, template, count, 0); if (infos == null || infos.length == 0) { return null; - } + } XVisualInfo res = XVisualInfo.create(infos[0]); if (DEBUG) { System.err.println("Fetched XVisualInfo for visual ID " + toHexString(visualID)); @@ -391,10 +391,10 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem static X11GLCapabilities XVisualInfo2GLCapabilities(final X11GraphicsDevice device, GLProfile glp, XVisualInfo info, final int winattrmask, boolean isMultisampleEnabled) { - final int allDrawableTypeBits = GLGraphicsConfigurationUtil.WINDOW_BIT | + final int allDrawableTypeBits = GLGraphicsConfigurationUtil.WINDOW_BIT | GLGraphicsConfigurationUtil.BITMAP_BIT | GLGraphicsConfigurationUtil.FBO_BIT ; - + final int drawableTypeBits = winattrmask & allDrawableTypeBits; if( 0 == drawableTypeBits ) { @@ -425,13 +425,13 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem // Note: use of hardware acceleration is determined by // glXCreateContext, not by the XVisualInfo. Optimistically claim // that all GLCapabilities have the capability to be hardware - // accelerated. + // accelerated. if (isMultisampleEnabled) { res.setSampleBuffers(glXGetConfig(display, info, GLX.GLX_SAMPLE_BUFFERS, tmp) != 0); res.setNumSamples (glXGetConfig(display, info, GLX.GLX_SAMPLES, tmp)); } - final XRenderDirectFormat xrmask = ( null != info ) ? - XVisual2XRenderMask( display, info.getVisual() ) : + final XRenderDirectFormat xrmask = ( null != info ) ? + XVisual2XRenderMask( display, info.getVisual() ) : null ; final int alphaMask = ( null != xrmask ) ? xrmask.getAlphaMask() : 0; res.setBackgroundOpaque( 0 >= alphaMask ); @@ -454,7 +454,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.setAccumBlueBits (glXGetConfig(display, info, GLX.GLX_ACCUM_BLUE_SIZE, tmp)); res.setAccumAlphaBits(glXGetConfig(display, info, GLX.GLX_ACCUM_ALPHA_SIZE, tmp)); - return (X11GLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); + return (X11GLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } private static String glXGetConfigErrorCode(int err) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java index a7c7d3fe6..abe310a3f 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -109,7 +109,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF if (chooser != null && !(chooser instanceof GLCapabilitiesChooser)) { throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects"); } - + if(!GLXUtil.isGLXAvailableOnServer((X11GraphicsDevice)absScreen.getDevice())) { if(null != fallbackX11GraphicsConfigurationFactory) { if(DEBUG) { @@ -118,7 +118,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF return fallbackX11GraphicsConfigurationFactory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, absScreen, VisualIDHolder.VID_UNDEFINED); } throw new InternalError("No GLX and no fallback GraphicsConfigurationFactory available for: "+absScreen); - } + } return chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested, (GLCapabilitiesChooser)chooser, (X11GraphicsScreen)absScreen, nativeVisualID); } @@ -134,7 +134,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF final GLProfile glp = GLProfile.getDefault(device); List availableCaps = null; - + sharedDevice.lock(); try { if( sharedResource.isGLXVersionGreaterEqualOneThree() ) { @@ -219,9 +219,9 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF if (capsChosen == null) { capsChosen = new GLCapabilities(null); } - X11GraphicsDevice x11Device = (X11GraphicsDevice) x11Screen.getDevice(); + X11GraphicsDevice x11Device = (X11GraphicsDevice) x11Screen.getDevice(); X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - + capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, factory, x11Device); final boolean usePBuffer = !capsChosen.isOnscreen() && capsChosen.isPBuffer(); @@ -262,7 +262,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF return null; } final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - + final X11GLCapabilities caps = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(x11Device, glp, fbcfg, GLGraphicsConfigurationUtil.ALL_BITS, factory.isGLXMultisampleAvailable(x11Device)); return new X11GLXGraphicsConfiguration(x11Screen, caps, caps, new DefaultGLCapabilitiesChooser()); } @@ -280,8 +280,8 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF X11GraphicsDevice x11Device = (X11GraphicsDevice) x11Screen.getDevice(); long display = x11Device.getHandle(); int screen = x11Screen.getIndex(); - - final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); + + final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); final boolean isMultisampleAvailable = factory.isGLXMultisampleAvailable(x11Device); final IntBuffer attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capsChosen, true, isMultisampleAvailable, display, screen); final IntBuffer count = Buffers.newDirectIntBuffer(1); @@ -337,14 +337,14 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } } } - + if(DEBUG) { System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: got configs: "+availableCaps.size()); for(int i=0; i chosenIndex ) { if (DEBUG) { @@ -393,15 +393,15 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF X11GraphicsDevice absDevice = (X11GraphicsDevice) x11Screen.getDevice(); long display = absDevice.getHandle(); int screen = x11Screen.getIndex(); - - final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - final boolean isMultisampleAvailable = factory.isGLXMultisampleAvailable(absDevice); + + final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); + final boolean isMultisampleAvailable = factory.isGLXMultisampleAvailable(absDevice); final IntBuffer attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capsChosen, false, isMultisampleAvailable, display, screen); XVisualInfo recommendedVis = null; // 1st choice: get GLCapabilities based on users GLCapabilities setting recommendedIndex as preferred choice // skipped if xvisualID is given - if( VisualIDHolder.VID_UNDEFINED == xvisualID ) { + if( VisualIDHolder.VID_UNDEFINED == xvisualID ) { recommendedVis = GLX.glXChooseVisual(display, screen, attribs); if (DEBUG) { System.err.print("glXChooseVisual recommended "); @@ -441,7 +441,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF System.err.println(i+": "+availableCaps.get(i)); } } - + if( VisualIDHolder.VID_UNDEFINED != xvisualID ) { for(int i=0; i chosenIndex ) { if (DEBUG) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java index 22c95f3dd..c98bf5436 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java @@ -29,11 +29,11 @@ public class DelegatedUpstreamSurfaceHookMutableSize extends UpstreamSurfaceHook upstream.destroy(s); } } - + @Override public String toString() { - return getClass().getSimpleName()+"[ "+ width + "x" + height + ", " + upstream + "]"; + return getClass().getSimpleName()+"[ "+ width + "x" + height + ", " + upstream + "]"; } - + } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java index 85e24582c..1557f4e51 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java @@ -42,13 +42,13 @@ public class DelegatedUpstreamSurfaceHookWithSurfaceSize implements UpstreamSurf @Override public final int getHeight(ProxySurface s) { return surface.getHeight(); - } - + } + @Override public String toString() { - final String us_s = null != surface ? ( surface.getClass().getName() + ": 0x" + Long.toHexString(surface.getSurfaceHandle()) + " " +surface.getWidth() + "x" + surface.getHeight() ) : "nil"; + final String us_s = null != surface ? ( surface.getClass().getName() + ": 0x" + Long.toHexString(surface.getSurfaceHandle()) + " " +surface.getWidth() + "x" + surface.getHeight() ) : "nil"; return getClass().getSimpleName()+"["+upstream+", "+us_s+"]"; } - + } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java index eaad513aa..8b8ccb191 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/MutableGraphicsConfiguration.java @@ -41,10 +41,10 @@ public class MutableGraphicsConfiguration extends DefaultGraphicsConfiguration { public void setChosenCapabilities(CapabilitiesImmutable caps) { super.setChosenCapabilities(caps); } - + @Override public void setScreen(AbstractGraphicsScreen screen) { super.setScreen(screen); } - + } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java index 29f4964c0..a8dd9165c 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.nativewindow; import com.jogamp.common.GlueGenVersion; diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java index 29c540ac4..5838c7a56 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java @@ -18,9 +18,9 @@ public class UpstreamSurfaceHookMutableSize implements UpstreamSurfaceHook.Mutab @Override public final void setSize(int width, int height) { this.width = width; - this.height = height; + this.height = height; } - + @Override public final int getWidth(ProxySurface s) { return width; @@ -35,11 +35,11 @@ public class UpstreamSurfaceHookMutableSize implements UpstreamSurfaceHook.Mutab @Override public void destroy(ProxySurface s) { /* nop */ } - + @Override public String toString() { - return getClass().getSimpleName()+"[ "+ width + "x" + height + "]"; + return getClass().getSimpleName()+"[ "+ width + "x" + height + "]"; } - + } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java index 7e3d30a47..15f3355d0 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -57,7 +57,7 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple private GraphicsConfiguration config; AbstractGraphicsConfiguration encapsulated; - public AWTGraphicsConfiguration(AWTGraphicsScreen screen, + public AWTGraphicsConfiguration(AWTGraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, GraphicsConfiguration config, AbstractGraphicsConfiguration encapsulated) { super(screen, capsChosen, capsRequested); @@ -71,9 +71,9 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple this.config = config; this.encapsulated=null; } - + /** - * @param capsChosen if null, capsRequested is copied and aligned + * @param capsChosen if null, capsRequested is copied and aligned * with the graphics {@link Capabilities} of the AWT Component to produce the chosen {@link Capabilities}. * Otherwise the capsChosen is used. * @param capsRequested if null, default {@link Capabilities} are used, otherwise the given values. @@ -81,7 +81,7 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple public static AWTGraphicsConfiguration create(Component awtComp, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) { final GraphicsConfiguration awtGfxConfig = awtComp.getGraphicsConfiguration(); if(null==awtGfxConfig) { - throw new NativeWindowException("AWTGraphicsConfiguration.create: Null AWT GraphicsConfiguration @ "+awtComp); + throw new NativeWindowException("AWTGraphicsConfiguration.create: Null AWT GraphicsConfiguration @ "+awtComp); } final GraphicsDevice awtGraphicsDevice = awtGfxConfig.getDevice(); if(null==awtGraphicsDevice) { @@ -112,7 +112,7 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple public void setChosenCapabilities(CapabilitiesImmutable capsChosen) { super.setChosenCapabilities(capsChosen); } - + @Override public Object clone() { return super.clone(); @@ -171,7 +171,7 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple public String toString() { return getClass().getSimpleName()+"[" + getScreen() + ",\n\tchosen " + capabilitiesChosen+ - ",\n\trequested " + capabilitiesRequested+ + ",\n\trequested " + capabilitiesRequested+ ",\n\t" + config + ",\n\tencapsulated "+encapsulated+"]"; } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java index 635e6d263..a7fa53577 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsDevice.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java index f4ee06e28..d3cf5bff6 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java index e5290aee1..44163fc73 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -69,15 +69,15 @@ import jogamp.nativewindow.awt.AWTMisc; } finally { ctx.releasePrint(); } - * + * *
          *

          */ public interface AWTPrintLifecycle { public static final int DEFAULT_PRINT_TILE_SIZE = 1024; - - + + /** * Shall be called before {@link PrinterJob#print()}. *

          @@ -85,12 +85,12 @@ public interface AWTPrintLifecycle { *

          * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels - * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples * @param tileWidth custom tile width for {@link com.jogamp.opengl.util.TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param tileHeight custom tile height for {@link com.jogamp.opengl.util.TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. */ void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight); - + /** * Shall be called after {@link PrinterJob#print()}. *

          @@ -111,11 +111,11 @@ public interface AWTPrintLifecycle { *

          * See Usage. *

          - * + * * @param c container to be traversed through to perform {@link AWTPrintLifecycle#setupPrint(double, double, int, int, int) setupPrint(..)} on all {@link AWTPrintLifecycle} elements. * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels - * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @return the context @@ -139,7 +139,7 @@ public interface AWTPrintLifecycle { * @return count of performed actions of last {@link #setupPrint(Container, double, double, int, int, int) setupPrint(..)} or {@link #releasePrint()}. */ public int getCount() { return count; } - + private final Container cont; private final double scaleMatX; private final double scaleMatY; @@ -147,7 +147,7 @@ public interface AWTPrintLifecycle { private final int tileWidth; private final int tileHeight; private int count; - + private final AWTMisc.ComponentAction setupAction = new AWTMisc.ComponentAction() { @Override public void run(Component c) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java index e499ff705..e350aaff4 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java @@ -78,7 +78,7 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol { /** * Adds this closing listener to the components Window if exist and only one time. *

          - * If the closing listener is already added, and {@link IllegalStateException} is thrown. + * If the closing listener is already added, and {@link IllegalStateException} is thrown. *

          * * @return true if added, otherwise false. diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java index 7a7a771d6..e4d3884a7 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -45,29 +45,29 @@ import com.jogamp.common.nio.Buffers; * {@link DataBuffer} specialization using NIO direct buffer of type {@link DataBuffer#TYPE_INT} as storage. */ public final class DirectDataBufferInt extends DataBuffer { - + public static class DirectWritableRaster extends WritableRaster { protected DirectWritableRaster(SampleModel sampleModel, DirectDataBufferInt dataBuffer, Point origin) { super(sampleModel, dataBuffer, origin); } } - + public static class BufferedImageInt extends BufferedImage { final int customImageType; public BufferedImageInt (int customImageType, ColorModel cm, WritableRaster raster, Hashtable properties) { super(cm, raster, false /* isRasterPremultiplied */, properties); - this.customImageType = customImageType; + this.customImageType = customImageType; } - + /** - * @return one of the custom image-type values {@link BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}, - * {@link BufferedImage#TYPE_INT_ARGB_PRE TYPE_INT_ARGB_PRE}, + * @return one of the custom image-type values {@link BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}, + * {@link BufferedImage#TYPE_INT_ARGB_PRE TYPE_INT_ARGB_PRE}, * {@link BufferedImage#TYPE_INT_RGB TYPE_INT_RGB} or {@link BufferedImage#TYPE_INT_BGR TYPE_INT_BGR}. */ public int getCustomType() { return customImageType; } - + @Override public String toString() { return new String("BufferedImageInt@"+Integer.toHexString(hashCode()) @@ -75,26 +75,26 @@ public final class DirectDataBufferInt extends DataBuffer { +" "+getColorModel()+" "+getRaster()); } } - + /** - * Creates a {@link BufferedImageInt} using a {@link DirectColorModel direct color model} in {@link ColorSpace#CS_sRGB sRGB color space}.
          + * Creates a {@link BufferedImageInt} using a {@link DirectColorModel direct color model} in {@link ColorSpace#CS_sRGB sRGB color space}.
          * It uses a {@link DirectWritableRaster} utilizing {@link DirectDataBufferInt} storage. *

          - * Note that due to using the custom storage type {@link DirectDataBufferInt}, the resulting + * Note that due to using the custom storage type {@link DirectDataBufferInt}, the resulting * {@link BufferedImage}'s {@link BufferedImage#getType() image-type} is of {@link BufferedImage#TYPE_CUSTOM TYPE_CUSTOM}. * We are not able to change this detail, since the AWT image implementation associates the {@link BufferedImage#getType() image-type} * with a build-in storage-type. * Use {@link BufferedImageInt#getCustomType()} to retrieve the custom image-type, which will return the imageType - * value passed here. + * value passed here. *

          - * + * * @param width * @param height - * @param imageType one of {@link BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}, {@link BufferedImage#TYPE_INT_ARGB_PRE TYPE_INT_ARGB_PRE}, + * @param imageType one of {@link BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}, {@link BufferedImage#TYPE_INT_ARGB_PRE TYPE_INT_ARGB_PRE}, * {@link BufferedImage#TYPE_INT_RGB TYPE_INT_RGB} or {@link BufferedImage#TYPE_INT_BGR TYPE_INT_BGR}. * @param location origin, if null 0/0 is assumed. * @param properties Hashtable of - * String/Object pairs. Used for {@link BufferedImage#getProperty(String)} etc. + * String/Object pairs. Used for {@link BufferedImage#getProperty(String)} etc. * @return */ public static BufferedImageInt createBufferedImage(int width, int height, int imageType, Point location, Hashtable properties) { @@ -150,30 +150,30 @@ public final class DirectDataBufferInt extends DataBuffer { bandMasks[0] = rmask; bandMasks[1] = gmask; bandMasks[2] = bmask; - + final DirectDataBufferInt dataBuffer = new DirectDataBufferInt(width*height); if( null == location ) { location = new Point(0,0); } - final SinglePixelPackedSampleModel sppsm = new SinglePixelPackedSampleModel(dataBuffer.getDataType(), + final SinglePixelPackedSampleModel sppsm = new SinglePixelPackedSampleModel(dataBuffer.getDataType(), width, height, width /* scanLineStride */, bandMasks); // IntegerComponentRasters must haveinteger DataBuffers: // final WritableRaster raster = new IntegerInterleavedRaster(sppsm, dataBuffer, location); // Not public: // final WritableRaster raster = new SunWritableRaster(sppsm, dataBuffer, location); final WritableRaster raster = new DirectWritableRaster(sppsm, dataBuffer, location); - + return new BufferedImageInt(imageType, colorModel, raster, properties); } - + /** Default data bank. */ private IntBuffer data; /** All data banks */ private IntBuffer bankdata[]; - + /** - * Constructs an nio integer-based {@link DataBuffer} with a single bank + * Constructs an nio integer-based {@link DataBuffer} with a single bank * and the specified size. * * @param size The size of the {@link DataBuffer}. @@ -222,17 +222,17 @@ public final class DirectDataBufferInt extends DataBuffer { /** * Returns the default (first) int data array in {@link DataBuffer}. - * + * * @return The first integer data array. */ public IntBuffer getData() { return data; } - /** - * Returns the data array for the specified bank. - * - * @param bank The bank whose data array you want to get. + /** + * Returns the data array for the specified bank. + * + * @param bank The bank whose data array you want to get. * @return The data array for the specified bank. */ public IntBuffer getData(int bank) { @@ -241,7 +241,7 @@ public final class DirectDataBufferInt extends DataBuffer { /** * Returns the requested data array element from the first (default) bank. - * + * * @param i The data array element you want to get. * @return The requested data array element as an integer. * @see #setElem(int, int) @@ -253,7 +253,7 @@ public final class DirectDataBufferInt extends DataBuffer { /** * Returns the requested data array element from the specified bank. - * + * * @param bank The bank from which you want to get a data array element. * @param i The data array element you want to get. * @return The requested data array element as an integer. diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 38a46f214..49b2daeae 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -123,7 +123,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, private boolean localVisibility = component.isVisible(); private boolean globalVisibility = localVisibility; private boolean visibilityPropagation = false; - + private String s(ComponentEvent e) { return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"],"+Platform.getNewline()+ " ** COMP "+e.getComponent()+Platform.getNewline()+ @@ -164,7 +164,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override - public void componentHidden(ComponentEvent e) { + public void componentHidden(ComponentEvent e) { if(DEBUG) { System.err.println("JAWTWindow.componentHidden: "+s(e)); } @@ -174,7 +174,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, @Override public void hierarchyChanged(HierarchyEvent e) { final long bits = e.getChangeFlags(); - final java.awt.Component changed = e.getChanged(); + final java.awt.Component changed = e.getChanged(); if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) { final boolean displayable = changed.isDisplayable(); final boolean resetLocalVisibility = changed == component && !displayable && localVisibility != component.isVisible(); @@ -220,7 +220,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(DEBUG) { System.err.println("JAWTWindow.invalidate() - "+Thread.currentThread().getName()); if( isSurfaceLayerAttached() ) { - System.err.println("OffscreenSurfaceLayer still attached: 0x"+Long.toHexString(offscreenSurfaceLayer)); + System.err.println("OffscreenSurfaceLayer still attached: 0x"+Long.toHexString(offscreenSurfaceLayer)); } // Thread.dumpStack(); } @@ -237,14 +237,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected final boolean updateBounds(JAWT_Rectangle jawtBounds) { final Rectangle jb = new Rectangle(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); final boolean changed = !bounds.equals(jb); - + if(changed) { if(DEBUG) { System.err.println("JAWTWindow.updateBounds: "+bounds+" -> "+jb); // Thread.dumpStack(); } bounds.set(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); - + if(component instanceof Container) { final java.awt.Insets contInsets = ((Container)component).getInsets(); insets.set(contInsets.left, contInsets.right, contInsets.top, contInsets.bottom); @@ -279,7 +279,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, // // OffscreenLayerOption // - + @Override public void setShallUseOffscreenLayer(boolean v) { shallUseOffscreenLayer = v; @@ -316,9 +316,9 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, * Layout the offscreen layer according to the implementing class's constraints. *

          * This method allows triggering a re-layout of the offscreen surface - * in case the implementation requires it. + * in case the implementation requires it. *

          - *

          + *

          * Call this method if any parent or ancestor's layout has been changed, * which could affects the layout of this surface. *

          @@ -326,14 +326,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false */ protected void layoutSurfaceLayerImpl(long layerHandle, boolean visible) {} - + private final void layoutSurfaceLayerIfEnabled(boolean visible) throws NativeWindowException { if( isOffscreenLayerSurfaceEnabled() && 0 != offscreenSurfaceLayer ) { layoutSurfaceLayerImpl(offscreenSurfaceLayer, visible); } } - - + + @Override public final void detachSurfaceLayer() throws NativeWindowException { if( 0 == offscreenSurfaceLayer) { @@ -351,35 +351,35 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } }; - /** + /** * @param detachNotify Runnable to be called before native detachment */ protected void detachSurfaceLayerImpl(final long layerHandle, final Runnable detachNotify) { throw new UnsupportedOperationException("offscreen layer not supported"); } - + @Override public final long getAttachedSurfaceLayer() { return offscreenSurfaceLayer; } - + @Override public final boolean isSurfaceLayerAttached() { return 0 != offscreenSurfaceLayer; } - + @Override public final void setChosenCapabilities(CapabilitiesImmutable caps) { ((MutableGraphicsConfiguration)getGraphicsConfiguration()).setChosenCapabilities(caps); - getPrivateGraphicsConfiguration().setChosenCapabilities(caps); + getPrivateGraphicsConfiguration().setChosenCapabilities(caps); } - + @Override public final RecursiveLock getLock() { return surfaceLock; } - + // // SurfaceUpdateListener // @@ -527,7 +527,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, public final AbstractGraphicsConfiguration getGraphicsConfiguration() { return config.getNativeGraphicsConfiguration(); } - + @Override public final long getDisplayHandle() { return getGraphicsConfiguration().getScreen().getDevice().getHandle(); @@ -545,7 +545,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, @Override public final int getHeight() { - return component.getHeight(); + return component.getHeight(); } // @@ -647,10 +647,10 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected abstract Point getLocationOnScreenNativeImpl(int x, int y); protected static Component getLocationOnScreenNonBlocking(Point storage, Component comp) { - final java.awt.Insets insets = new java.awt.Insets(0, 0, 0, 0); // DEBUG + final java.awt.Insets insets = new java.awt.Insets(0, 0, 0, 0); // DEBUG Component last = null; while(null != comp) { - final int dx = comp.getX(); + final int dx = comp.getX(); final int dy = comp.getY(); if( DEBUG ) { final java.awt.Insets ins = AWTMisc.getInsets(comp, false); @@ -674,7 +674,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } return last; } - + @Override public boolean hasFocus() { return component.hasFocus(); @@ -693,7 +693,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } return sb; } - + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -715,7 +715,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return sb.toString(); } - + protected final String toHexString(long l) { return "0x"+Long.toHexString(l); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java index fb6d39b2f..c83814907 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java @@ -1,21 +1,21 @@ /* * 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 @@ -45,7 +45,7 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl *

          * FIXME: This shall be removed when relocated EGL to the nativewindow package, * since then it can be utilized directly. - *

          + *

          */ public interface EGLDisplayLifecycleCallback { /** @@ -55,14 +55,14 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl * @return the initialized EGL display ID, or 0 if not successful */ public long eglGetAndInitDisplay(long[] nativeDisplayID); - + /** * Implementation should issue an EGL.eglTerminate(eglDisplayHandle) call. * @param eglDisplayHandle */ void eglTerminate(long eglDisplayHandle); } - + /** * Note that this is not an open connection, ie no native display handle exist. * This constructor exist to setup a default device connection/unit.
          @@ -78,9 +78,9 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl this.nativeDisplayID[0] = nativeDisplayID; this.eglLifecycleCallback = eglLifecycleCallback; } - + public long getNativeDisplayID() { return nativeDisplayID[0]; } - + @Override public Object clone() { return super.clone(); @@ -100,7 +100,7 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return false; } - + @Override public boolean close() { if(null != eglLifecycleCallback && 0 != handle) { @@ -111,11 +111,11 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return super.close(); } - + @Override public boolean isHandleOwner() { return null != eglLifecycleCallback; - } + } @Override public void clearHandleOwner() { eglLifecycleCallback = null; @@ -126,9 +126,9 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } @Override protected Object setHandleOwnership(Object newOwnership) { - final EGLDisplayLifecycleCallback oldOwnership = eglLifecycleCallback; + final EGLDisplayLifecycleCallback oldOwnership = eglLifecycleCallback; eglLifecycleCallback = (EGLDisplayLifecycleCallback) newOwnership; return oldOwnership; - } + } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java index 0dc788c17..89df7f853 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java @@ -1,21 +1,21 @@ /* * 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 diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 5c4fd82d2..6057f6700 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -54,28 +54,28 @@ import jogamp.nativewindow.x11.X11Lib; public class SWTAccessor { private static final boolean DEBUG = true; - + private static final Field swt_control_handle; private static final boolean swt_uses_long_handles; - - private static Object swt_osx_init = new Object(); + + private static Object swt_osx_init = new Object(); private static Field swt_osx_control_view = null; private static Field swt_osx_view_id = null; - + private static final String nwt; private static final boolean isOSX; private static final boolean isWindows; private static final boolean isX11; private static final boolean isX11GTK; - + // X11/GTK, Windows/GDI, .. private static final String str_handle = "handle"; - + // OSX/Cocoa private static final String str_osx_view = "view"; // OSX private static final String str_osx_id = "id"; // OSX // static final String str_NSView = "org.eclipse.swt.internal.cocoa.NSView"; - + private static final Method swt_control_internal_new_GC; private static final Method swt_control_internal_dispose_GC; private static final String str_internal_new_GC = "internal_new_GC"; @@ -85,18 +85,18 @@ public class SWTAccessor { public static final Class OS_gtk_class; private static final String str_OS_gtk_version = "GTK_VERSION"; public static final VersionNumber OS_gtk_version; - + private static final Method OS_gtk_widget_realize; private static final Method OS_gtk_widget_unrealize; // optional (removed in SWT 4.3) private static final Method OS_GTK_WIDGET_WINDOW; private static final Method OS_gtk_widget_get_window; private static final Method OS_gdk_x11_drawable_get_xdisplay; private static final Method OS_gdk_x11_display_get_xdisplay; - private static final Method OS_gdk_window_get_display; - private static final Method OS_gdk_x11_drawable_get_xid; + private static final Method OS_gdk_window_get_display; + private static final Method OS_gdk_x11_drawable_get_xid; private static final Method OS_gdk_x11_window_get_xid; private static final Method OS_gdk_window_set_back_pixmap; - + private static final String str_gtk_widget_realize = "gtk_widget_realize"; private static final String str_gtk_widget_unrealize = "gtk_widget_unrealize"; private static final String str_GTK_WIDGET_WINDOW = "GTK_WIDGET_WINDOW"; @@ -107,11 +107,11 @@ public class SWTAccessor { private static final String str_gdk_x11_drawable_get_xid = "gdk_x11_drawable_get_xid"; private static final String str_gdk_x11_window_get_xid = "gdk_x11_window_get_xid"; private static final String str_gdk_window_set_back_pixmap = "gdk_window_set_back_pixmap"; - + private static final VersionNumber GTK_VERSION_2_14_0 = new VersionNumber(2, 14, 0); private static final VersionNumber GTK_VERSION_2_24_0 = new VersionNumber(2, 24, 0); private static final VersionNumber GTK_VERSION_3_0_0 = new VersionNumber(3, 0, 0); - + private static VersionNumber GTK_VERSION(int version) { // return (major << 16) + (minor << 8) + micro; final int micro = ( version ) & 0x0f; @@ -119,20 +119,20 @@ public class SWTAccessor { final int major = ( version >> 16 ) & 0x0f; return new VersionNumber(major, minor, micro); } - + static { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { NativeWindowFactory.initSingleton(); // last resort .. return null; } } ); - + nwt = NativeWindowFactory.getNativeWindowType(false); isOSX = NativeWindowFactory.TYPE_MACOSX == nwt; isWindows = NativeWindowFactory.TYPE_WINDOWS == nwt; isX11 = NativeWindowFactory.TYPE_X11 == nwt; - - Field f = null; + + Field f = null; if( !isOSX ) { try { f = Control.class.getField(str_handle); @@ -141,7 +141,7 @@ public class SWTAccessor { } } swt_control_handle = f; // maybe null ! - + boolean ulh; if (null != swt_control_handle) { ulh = swt_control_handle.getGenericType().toString().equals(long.class.toString()); @@ -151,7 +151,7 @@ public class SWTAccessor { swt_uses_long_handles = ulh; // System.err.println("SWT long handles: " + swt_uses_long_handles); // System.err.println("Platform 64bit: "+Platform.is64Bit()); - + Method m=null; try { m = ReflectionUtil.getMethod(Control.class, str_internal_new_GC, new Class[] { GCData.class }); @@ -159,12 +159,12 @@ public class SWTAccessor { throw new NativeWindowException(ex); } swt_control_internal_new_GC = m; - + try { if(swt_uses_long_handles) { - m = Control.class.getDeclaredMethod(str_internal_dispose_GC, new Class[] { long.class, GCData.class }); + m = Control.class.getDeclaredMethod(str_internal_dispose_GC, new Class[] { long.class, GCData.class }); } else { - m = Control.class.getDeclaredMethod(str_internal_dispose_GC, new Class[] { int.class, GCData.class }); + m = Control.class.getDeclaredMethod(str_internal_dispose_GC, new Class[] { int.class, GCData.class }); } } catch (NoSuchMethodException ex) { throw new NativeWindowException(ex); @@ -181,7 +181,7 @@ public class SWTAccessor { c = ReflectionUtil.getClass(str_OS_gtk_class, false, SWTAccessor.class.getClassLoader()); Field field_OS_gtk_version = c.getField(str_OS_gtk_version); _gtk_version = GTK_VERSION(field_OS_gtk_version.getInt(null)); - m1 = c.getDeclaredMethod(str_gtk_widget_realize, handleType); + m1 = c.getDeclaredMethod(str_gtk_widget_realize, handleType); if (_gtk_version.compareTo(GTK_VERSION_2_14_0) >= 0) { m4 = c.getDeclaredMethod(str_gtk_widget_get_window, handleType); } else { @@ -189,9 +189,9 @@ public class SWTAccessor { } if (_gtk_version.compareTo(GTK_VERSION_2_24_0) >= 0) { m6 = c.getDeclaredMethod(str_gdk_x11_display_get_xdisplay, handleType); - m7 = c.getDeclaredMethod(str_gdk_window_get_display, handleType); + m7 = c.getDeclaredMethod(str_gdk_window_get_display, handleType); } else { - m5 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xdisplay, handleType); + m5 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xdisplay, handleType); } if (_gtk_version.compareTo(GTK_VERSION_3_0_0) >= 0) { m9 = c.getDeclaredMethod(str_gdk_x11_window_get_xid, handleType); @@ -200,7 +200,7 @@ public class SWTAccessor { } ma = c.getDeclaredMethod(str_gdk_window_set_back_pixmap, handleType, handleType, boolean.class); } catch (Exception ex) { throw new NativeWindowException(ex); } - // optional + // optional try { m2 = c.getDeclaredMethod(str_gtk_widget_unrealize, handleType); } catch (Exception ex) { } @@ -213,33 +213,33 @@ public class SWTAccessor { OS_gtk_widget_get_window = m4; OS_gdk_x11_drawable_get_xdisplay = m5; OS_gdk_x11_display_get_xdisplay = m6; - OS_gdk_window_get_display = m7; + OS_gdk_window_get_display = m7; OS_gdk_x11_drawable_get_xid = m8; OS_gdk_x11_window_get_xid = m9; OS_gdk_window_set_back_pixmap = ma; - + isX11GTK = isX11 && null != OS_gtk_class; - + if(DEBUG) { System.err.println("SWTAccessor.: GTK Version: "+OS_gtk_version); } } - + private static Number getIntOrLong(long arg) { if(swt_uses_long_handles) { return new Long(arg); } return new Integer((int) arg); } - - private static void callStaticMethodL2V(Method m, long arg) { + + private static void callStaticMethodL2V(Method m, long arg) { ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg) }); } - - private static void callStaticMethodLLZ2V(Method m, long arg0, long arg1, boolean arg3) { + + private static void callStaticMethodLLZ2V(Method m, long arg0, long arg1, boolean arg3) { ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg0), getIntOrLong(arg1), Boolean.valueOf(arg3) }); } - + private static long callStaticMethodL2L(Method m, long arg) { Object o = ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg) }); if(o instanceof Number) { @@ -252,18 +252,18 @@ public class SWTAccessor { // // Public properties // - + public static boolean isUsingLongHandles() { return swt_uses_long_handles; } public static boolean useX11GTK() { return isX11GTK; } public static VersionNumber GTK_VERSION() { return OS_gtk_version; } - + // // Common GTK // - + public static long gdk_widget_get_window(long handle) { final long window; if (OS_gtk_version.compareTo(GTK_VERSION_2_14_0) >= 0) { @@ -276,7 +276,7 @@ public class SWTAccessor { } return window; } - + public static long gdk_window_get_xdisplay(long window) { final long xdisplay; if (OS_gtk_version.compareTo(GTK_VERSION_2_24_0) >= 0) { @@ -293,7 +293,7 @@ public class SWTAccessor { } return xdisplay; } - + public static long gdk_window_get_xwindow(long window) { final long xWindow; if (OS_gtk_version.compareTo(GTK_VERSION_3_0_0) >= 0) { @@ -306,15 +306,15 @@ public class SWTAccessor { } return xWindow; } - + public static void gdk_window_set_back_pixmap(long window, long pixmap, boolean parent_relative) { callStaticMethodLLZ2V(OS_gdk_window_set_back_pixmap, window, pixmap, parent_relative); } - + // // Common any toolkit // - + /** * @param swtControl the SWT Control to retrieve the native widget-handle from * @return the native widget-handle @@ -335,9 +335,9 @@ public class SWTAccessor { } } catch (Exception ex) { throw new NativeWindowException(ex); - } + } } - } else { + } else { try { h = swt_control_handle.getLong(swtControl); } catch (Exception ex) { @@ -350,14 +350,14 @@ public class SWTAccessor { return h; } - public static void setRealized(final Control swtControl, final boolean realize) - throws NativeWindowException + public static void setRealized(final Control swtControl, final boolean realize) + throws NativeWindowException { if(!realize && swtControl.isDisposed()) { return; } final long handle = getHandle(swtControl); - + if(null != OS_gtk_class) { invoke(true, new Runnable() { public void run() { @@ -365,16 +365,16 @@ public class SWTAccessor { callStaticMethodL2V(OS_gtk_widget_realize, handle); } else if(null != OS_gtk_widget_unrealize) { callStaticMethodL2V(OS_gtk_widget_unrealize, handle); - } + } } }); } } - + /** * @param swtControl the SWT Control to retrieve the native device handle from * @return the AbstractGraphicsDevice w/ the native device handle - * @throws NativeWindowException if the widget handle is null + * @throws NativeWindowException if the widget handle is null * @throws UnsupportedOperationException if the windowing system is not supported */ public static AbstractGraphicsDevice getDevice(Control swtControl) throws NativeWindowException, UnsupportedOperationException { @@ -391,7 +391,7 @@ public class SWTAccessor { } throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } - + /** * @param device * @param screen -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen @@ -400,7 +400,7 @@ public class SWTAccessor { public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) { return NativeWindowFactory.createScreen(device, screen); } - + public static int getNativeVisualID(AbstractGraphicsDevice device, long windowHandle) { if( isX11 ) { return X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle); @@ -408,29 +408,29 @@ public class SWTAccessor { if( isWindows || isOSX ) { return VisualIDHolder.VID_UNDEFINED; } - throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); + throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } - + /** * @param swtControl the SWT Control to retrieve the native window handle from * @return the native window handle - * @throws NativeWindowException if the widget handle is null + * @throws NativeWindowException if the widget handle is null * @throws UnsupportedOperationException if the windowing system is not supported */ public static long getWindowHandle(Control swtControl) throws NativeWindowException, UnsupportedOperationException { - final long handle = getHandle(swtControl); + final long handle = getHandle(swtControl); if(0 == handle) { throw new NativeWindowException("Null SWT handle of SWT control "+swtControl); } if( isX11GTK ) { - return gdk_window_get_xwindow( gdk_widget_get_window( handle ) ); + return gdk_window_get_xwindow( gdk_widget_get_window( handle ) ); } if( isWindows || isOSX ) { return handle; } throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } - + public static long newGC(final Control swtControl, final GCData gcData) { final Object[] o = new Object[1]; invoke(true, new Runnable() { @@ -444,7 +444,7 @@ public class SWTAccessor { throw new InternalError("SWT internal_new_GC did not return int or long but "+o[0].getClass()); } } - + public static void disposeGC(final Control swtControl, final long gc, final GCData gcData) { invoke(true, new Runnable() { public void run() { @@ -456,7 +456,7 @@ public class SWTAccessor { } }); } - + /** * Runs the specified action in an SWT compatible thread, which is: *
            @@ -468,7 +468,7 @@ public class SWTAccessor { *
          • Linux, Windows, .. *
              *
            • Current thread.
            • - *
          • + *
          * * @see Platform#AWT_AVAILABLE * @see Platform#getOSType() @@ -479,9 +479,9 @@ public class SWTAccessor { OSXUtil.RunOnMainThread(wait, runnable); } else { runnable.run(); - } + } } - + /** * Runs the specified action on the SWT UI thread. *

          @@ -492,56 +492,56 @@ public class SWTAccessor { public static void invoke(org.eclipse.swt.widgets.Display display, boolean wait, Runnable runnable) { if( display.isDisposed() || Thread.currentThread() == display.getThread() ) { invoke(wait, runnable); - } else if( wait ) { + } else if( wait ) { display.syncExec(runnable); } else { display.asyncExec(runnable); } } - + // // Specific X11 GTK ChildWindow - Using plain X11 native parenting (works well) // - + public static long createCompatibleX11ChildWindow(AbstractGraphicsScreen screen, Control swtControl, int visualID, int width, int height) { final long handle = getHandle(swtControl); final long parentWindow = gdk_widget_get_window( handle ); gdk_window_set_back_pixmap (parentWindow, 0, false); - + final long x11ParentHandle = gdk_window_get_xwindow(parentWindow); final long x11WindowHandle = X11Lib.CreateWindow(x11ParentHandle, screen.getDevice().getHandle(), screen.getIndex(), visualID, width, height, true, true); - + return x11WindowHandle; } - + public static void resizeX11Window(AbstractGraphicsDevice device, Rectangle clientArea, long x11Window) { - X11Lib.SetWindowPosSize(device.getHandle(), x11Window, clientArea.x, clientArea.y, clientArea.width, clientArea.height); + X11Lib.SetWindowPosSize(device.getHandle(), x11Window, clientArea.x, clientArea.y, clientArea.width, clientArea.height); } public static void destroyX11Window(AbstractGraphicsDevice device, long x11Window) { X11Lib.DestroyWindow(device.getHandle(), x11Window); } - + // // Specific X11 SWT/GTK ChildWindow - Using SWT/GTK native parenting (buggy - sporadic resize flickering, sporadic drop of rendering) // // FIXME: Need to use reflection for 32bit access as well ! // - + // public static final int GDK_WA_TYPE_HINT = 1 << 9; // public static final int GDK_WA_VISUAL = 1 << 6; - + public static long createCompatibleGDKChildWindow(Control swtControl, int visualID, int width, int height) { return 0; /** final long handle = SWTAccessor.getHandle(swtControl); final long parentWindow = gdk_widget_get_window( handle ); - + final long screen = OS.gdk_screen_get_default (); final long gdkvisual = OS.gdk_x11_screen_lookup_visual (screen, visualID); - + final GdkWindowAttr attrs = new GdkWindowAttr(); attrs.width = width > 0 ? width : 1; - attrs.height = height > 0 ? height : 1; + attrs.height = height > 0 ? height : 1; attrs.event_mask = OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK | OS.GDK_FOCUS_CHANGE_MASK | OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK | @@ -550,16 +550,16 @@ public class SWTAccessor { OS.GDK_POINTER_MOTION_HINT_MASK; attrs.window_type = OS.GDK_WINDOW_CHILD; attrs.visual = gdkvisual; - + final long childWindow = OS.gdk_window_new (parentWindow, attrs, OS.GDK_WA_VISUAL|GDK_WA_TYPE_HINT); OS.gdk_window_set_user_data (childWindow, handle); OS.gdk_window_set_back_pixmap (parentWindow, 0, false); - + OS.gdk_window_show (childWindow); OS.gdk_flush(); return childWindow; */ } - + public static void showGDKWindow(long gdkWindow) { /* OS.gdk_window_show (gdkWindow); OS.gdk_flush(); */ @@ -576,8 +576,8 @@ public class SWTAccessor { OS.gdk_window_resize (gdkWindow, clientArea.width, clientArea.height); OS.gdk_flush(); */ } - + public static void destroyGDKWindow(long gdkWindow) { // OS.gdk_window_destroy (gdkWindow); - } + } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java index 5cabdf150..7468d254b 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java @@ -1,21 +1,21 @@ /* * 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 @@ -34,7 +34,7 @@ package com.jogamp.nativewindow.windows; import javax.media.nativewindow.*; -/** +/** * Encapsulates a graphics device on Windows platforms.
          */ public class WindowsGraphicsDevice extends DefaultGraphicsDevice implements Cloneable { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java index 0d2914c7d..120c86584 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsConfiguration.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -48,7 +48,7 @@ import jogamp.nativewindow.x11.XVisualInfo; public class X11GraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { private XVisualInfo info; - public X11GraphicsConfiguration(X11GraphicsScreen screen, + public X11GraphicsConfiguration(X11GraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, XVisualInfo info) { super(screen, capsChosen, capsRequested); @@ -71,12 +71,12 @@ public class X11GraphicsConfiguration extends MutableGraphicsConfiguration imple final public int getXVisualID() { return (null!=info)?(int)info.getVisualid():0; } - + @Override public String toString() { return getClass().getSimpleName()+"["+getScreen()+", visualID 0x" + Long.toHexString(getXVisualID()) + ",\n\tchosen " + capabilitiesChosen+ - ",\n\trequested " + capabilitiesRequested+ + ",\n\trequested " + capabilitiesRequested+ "]"; } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index e630e012e..40d212df3 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -87,12 +87,12 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl handleOwner = owner; isXineramaEnabled = X11Util.XineramaIsEnabled(this); } - + private static int getDefaultScreenImpl(long dpy) { return X11Lib.DefaultScreen(dpy); } - + /** * Returns the default screen number as referenced by the display connection, i.e. 'somewhere:0.1' -> 1 *

          @@ -110,7 +110,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return ds; } - + public int getDefaultVisualID() { final long display = getHandle(); if(0==display) { @@ -118,11 +118,11 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return X11Lib.DefaultVisualID(display, getDefaultScreenImpl(display)); } - + public final boolean isXineramaEnabled() { return isXineramaEnabled; } - + @Override public Object clone() { return super.clone(); @@ -142,7 +142,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return false; } - + @Override public boolean close() { if(handleOwner && 0 != handle) { @@ -153,11 +153,11 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return super.close(); } - + @Override public boolean isHandleOwner() { return handleOwner; - } + } @Override public void clearHandleOwner() { handleOwner = false; @@ -168,8 +168,8 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } @Override protected Object setHandleOwnership(Object newOwnership) { - final Boolean oldOwnership = Boolean.valueOf(handleOwner); + final Boolean oldOwnership = Boolean.valueOf(handleOwner); handleOwner = ((Boolean) newOwnership).booleanValue(); return oldOwnership; - } + } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java index 2ec66290a..8aac7095a 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -62,7 +62,7 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl // It still could be an AWT hold handle .. return X11Lib.DefaultVisualID(getDevice().getHandle(), getIndex()); } - + public Object clone() { return super.clone(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java index 4e45113d4..48f72e574 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -44,7 +44,7 @@ package javax.media.nativewindow; pixel format in a toolkit-independent manner. */ public interface AbstractGraphicsConfiguration extends VisualIDHolder, Cloneable { public Object clone(); - + /** * Return the screen this graphics configuration is valid for */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java index ed305d49e..31b64269f 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -47,7 +47,7 @@ import jogamp.nativewindow.Debug; */ public interface AbstractGraphicsDevice extends Cloneable { public static final boolean DEBUG = Debug.debug("GraphicsDevice"); - + /** Dummy connection value for a default connection where no native support for multiple devices is available */ public static String DEFAULT_CONNECTION = "decon"; @@ -58,7 +58,7 @@ public interface AbstractGraphicsDevice extends Cloneable { public static int DEFAULT_UNIT = 0; public Object clone(); - + /** * Returns the type of the underlying subsystem, ie * NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, .. @@ -96,7 +96,7 @@ public interface AbstractGraphicsDevice extends Cloneable { * The unique ID may be used as a key for semantic device mapping. *

          *

          - * The returned string object reference is unique using {@link String#intern()} + * The returned string object reference is unique using {@link String#intern()} * and hence can be used as a key itself. *

          */ @@ -114,29 +114,29 @@ public interface AbstractGraphicsDevice extends Cloneable { */ public void lock(); - /** + /** * Optionally unlocking the device, utilizing eg {@link javax.media.nativewindow.ToolkitLock#unlock()}. * The lock implementation must be recursive. - * + * * @throws RuntimeException in case the lock is not acquired by this thread. */ public void unlock(); /** - * @throws RuntimeException if current thread does not hold the lock + * @throws RuntimeException if current thread does not hold the lock */ public void validateLocked() throws RuntimeException; - - /** + + /** * Optionally [re]opening the device if handle is null. *

          * The default implementation is a NOP. *

          *

          - * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} - * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} + * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} + * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} * issue the native open operation in case handle is null. - *

          + *

          * * @return true if the handle was null and opening was successful, otherwise false. */ @@ -148,19 +148,19 @@ public interface AbstractGraphicsDevice extends Cloneable { * The default implementation {@link ToolkitLock#dispose() dispose} it's {@link ToolkitLock} and sets the handle to null. *

          *

          - * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} - * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} + * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} + * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} * issue the native close operation or skip it depending on the {@link #isHandleOwner() handles's ownership}. - *

          + *

          * * @return true if the handle was not null and closing was successful, otherwise false. */ public boolean close(); - + /** * @return true if instance owns the handle to issue {@link #close()}, otherwise false. */ public boolean isHandleOwner(); - + public void clearHandleOwner(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java index acb98073b..da8f12f3e 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java @@ -1,21 +1,21 @@ /* * Copyright (c) 2005 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -45,7 +45,7 @@ package javax.media.nativewindow; public interface AbstractGraphicsScreen extends Cloneable { public Object clone(); - + /** * Return the device this graphics configuration is valid for */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java index f2a8e2394..9eed887b5 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java +++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java @@ -61,7 +61,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { // Switch for on- or offscreen private boolean onscreen = true; - + // offscreen bitmap mode private boolean isBitmap = false; @@ -74,7 +74,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { public Object cloneMutable() { return clone(); } - + @Override public Object clone() { try { @@ -85,7 +85,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { } /** - * Copies all {@link Capabilities} values + * Copies all {@link Capabilities} values * from source into this instance. * @return this instance */ @@ -103,7 +103,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { transparentValueAlpha = other.getTransparentAlphaValue(); return this; } - + @Override public int hashCode() { // 31 * x == (x << 5) - x @@ -150,15 +150,15 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { **/ @Override public int compareTo(final CapabilitiesImmutable caps) { - /** + /** if ( ! ( o instanceof CapabilitiesImmutable ) ) { Class c = (null != o) ? o.getClass() : null ; throw new ClassCastException("Not a CapabilitiesImmutable object, but " + c); } final CapabilitiesImmutable caps = (CapabilitiesImmutable) o; */ - + final int rgba = redBits * greenBits * blueBits * ( alphaBits + 1 ); - + final int xrgba = caps.getRedBits() * caps.getGreenBits() * caps.getBlueBits() * ( caps.getAlphaBits() + 1 ); if(rgba > xrgba) { @@ -222,17 +222,17 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { return alphaBits; } - /** + /** * Sets the number of bits requested for the color buffer's alpha * component. On some systems only the color depth, which is the * sum of the red, green, and blue bits, is considered. *

          - * Note: If alpha bits are zero, they are set to one + * Note: If alpha bits are zero, they are set to one * by {@link #setBackgroundOpaque(boolean)} and it's OpenGL specialization GLCapabilities::setSampleBuffers(boolean).
          * Ensure to call this method after the above to ensure a zero value.
          * The above automated settings takes into account, that the user calls this method to request alpha bits, * not to reflect a current state. Nevertheless if this is the case - call it at last. - *

          + *

          */ public void setAlphaBits(int alphaBits) { this.alphaBits = alphaBits; @@ -271,7 +271,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { * Defaults to true. *

          *

          - * If requesting an offscreen surface without further selection of it's mode, + * If requesting an offscreen surface without further selection of it's mode, * e.g. FBO, Pbuffer or {@link #setBitmap(boolean) bitmap}, * the implementation will choose the best available offscreen mode. *

          @@ -304,12 +304,12 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { } isBitmap = enable; } - + @Override public boolean isBitmap() { - return isBitmap; + return isBitmap; } - + @Override public final int getTransparentRedValue() { return transparentValueRed; } @@ -354,7 +354,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { public StringBuilder toString(StringBuilder sink) { return toString(sink, true); } - + /** Returns a textual representation of this Capabilities object. */ @Override @@ -365,7 +365,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { msg.append("]"); return msg.toString(); } - + /** Return a textual representation of this object's on/off screen state. Use the given StringBuilder [optional]. */ protected StringBuilder onoffScreenToString(StringBuilder sink) { if(null == sink) { @@ -381,19 +381,19 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { } else if(onscreen) { sink.append("."); // no additional off-screen modes besides on-screen } else { - sink.append("auto-cfg"); // auto-config off-screen mode + sink.append("auto-cfg"); // auto-config off-screen mode } - sink.append("]"); - + sink.append("]"); + return sink; } - + /** Element separator */ protected static final String ESEP = "/"; /** Component separator */ protected static final String CSEP = ", "; - - protected StringBuilder toString(StringBuilder sink, boolean withOnOffScreen) { + + protected StringBuilder toString(StringBuilder sink, boolean withOnOffScreen) { if(null == sink) { sink = new StringBuilder(); } @@ -409,6 +409,6 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { } return sink; } - + protected final String toHexString(int val) { return Integer.toHexString(val); } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java index e1fdf4938..1f4db7997 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java +++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesChooser.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -58,7 +58,7 @@ public interface CapabilitiesChooser { not necessarily required, that the chooser select that entry.

          Note: this method is called automatically by the - {@link GraphicsConfigurationFactory#chooseGraphicsConfiguration} method + {@link GraphicsConfigurationFactory#chooseGraphicsConfiguration} method when an instance of this class is passed in to it. It should generally not be invoked by users directly, unless it is desired to delegate the diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java index 85659f286..c496a1535 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java @@ -70,12 +70,12 @@ public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, C * Returns whether an opaque or translucent surface is requested, supported or chosen. *

          * Default is true, i.e. opaque. - *

          + *

          */ boolean isBackgroundOpaque(); /** - * Returns whether an on- or offscreen surface is requested, available or chosen. + * Returns whether an on- or offscreen surface is requested, available or chosen. *

          * Default is true, i.e. onscreen. *

          @@ -83,7 +83,7 @@ public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, C * Mind that an capabilities intance w/ available semantics * may show onscreen, but also the offscreen modes FBO, Pbuffer or {@link #setBitmap(boolean) bitmap}. * This is valid, since one native configuration maybe used for either functionality. - *

          + *

          */ boolean isOnscreen(); @@ -97,7 +97,7 @@ public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, C *

          */ boolean isBitmap(); - + /** * Gets the transparent red value for the frame buffer configuration. This * value is undefined if; equals true. diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java index 4f07bca9b..6095db052 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -66,16 +66,16 @@ import jogamp.nativewindow.Debug; */ public class DefaultCapabilitiesChooser implements CapabilitiesChooser { - private static final boolean DEBUG; + private static final boolean DEBUG; static { Debug.initSingleton(); DEBUG = Debug.isPropertyDefined("nativewindow.debug.CapabilitiesChooser", true); } - + private final static int NO_SCORE = -9999999; private final static int COLOR_MISMATCH_PENALTY_SCALE = 36; - + public int chooseCapabilities(final CapabilitiesImmutable desired, final List available, final int windowSystemRecommendedChoice) { @@ -112,7 +112,7 @@ public class DefaultCapabilitiesChooser implements CapabilitiesChooser { if (desired.isOnscreen() && !cur.isOnscreen()) { continue; // requested onscreen, but n/a } - + int score = 0; // Compute difference in color depth score += (COLOR_MISMATCH_PENALTY_SCALE * @@ -132,7 +132,7 @@ public class DefaultCapabilitiesChooser implements CapabilitiesChooser { System.err.println(" ]"); } - // Ready to select. Choose score closest to 0. + // Ready to select. Choose score closest to 0. int scoreClosestToZero = NO_SCORE; int chosenIndex = -1; for (int i = 0; i < availnum; i++) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java index 6b23172e1..3e32f30df 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java @@ -1,21 +1,21 @@ /* * 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 @@ -36,12 +36,12 @@ import jogamp.nativewindow.Debug; public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphicsConfiguration { protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration"); - + private AbstractGraphicsScreen screen; protected CapabilitiesImmutable capabilitiesChosen; protected CapabilitiesImmutable capabilitiesRequested; - public DefaultGraphicsConfiguration(AbstractGraphicsScreen screen, + public DefaultGraphicsConfiguration(AbstractGraphicsScreen screen, CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) { if(null == screen) { throw new IllegalArgumentException("Null screen"); @@ -89,7 +89,7 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics final public int getVisualID(VIDType type) throws NativeWindowException { return capabilitiesChosen.getVisualID(type); } - + /** * Set the capabilities to a new value. * @@ -119,7 +119,7 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics public String toString() { return getClass().getSimpleName()+"[" + screen + ",\n\tchosen " + capabilitiesChosen+ - ",\n\trequested " + capabilitiesRequested+ + ",\n\trequested " + capabilitiesRequested+ "]"; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java index 0bf5c2937..d74954a0d 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -140,8 +140,8 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice public final void validateLocked() throws RuntimeException { toolkitLock.validateLocked(); } - - /** + + /** * {@inheritDoc} *

          * Locking is perfomed via delegation to {@link ToolkitLock#lock()}, {@link ToolkitLock#unlock()}. @@ -154,7 +154,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice public final void unlock() { toolkitLock.unlock(); } - + @Override public boolean open() { return false; @@ -174,11 +174,11 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice public boolean isHandleOwner() { return false; } - + @Override - public void clearHandleOwner() { + public void clearHandleOwner() { } - + @Override public String toString() { return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", owner "+isHandleOwner()+", "+toolkitLock+"]"; @@ -193,14 +193,14 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice handle = newHandle; return oldHandle; } - + protected Object getHandleOwnership() { return null; } protected Object setHandleOwnership(Object newOwnership) { return null; } - + public static final void swapDeviceHandleAndOwnership(final DefaultGraphicsDevice aDevice1, final DefaultGraphicsDevice aDevice2) { aDevice1.lock(); try { @@ -219,7 +219,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice aDevice1.unlock(); } } - + /** * Set the internal ToolkitLock, which is used within the * {@link #lock()} and {@link #unlock()} implementation. @@ -228,7 +228,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice * The current ToolkitLock is being locked/unlocked while swapping the reference, * ensuring no concurrent access can occur during the swap. *

          - * + * * @param locker the ToolkitLock, if null, {@link jogamp.nativewindow.NullToolkitLock} is being used * @return the previous ToolkitLock instance */ @@ -253,8 +253,8 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice return toolkitLock; } - /** - * Returns a unique String object using {@link String#intern()} for the given arguments, + /** + * Returns a unique String object using {@link String#intern()} for the given arguments, * which object reference itself can be used as a key. */ protected static String getUniqueID(String type, String connection, int unitID) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java index 9fa58c7a3..ffcad235c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java @@ -1,21 +1,21 @@ /* * 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 @@ -57,7 +57,7 @@ public class DefaultGraphicsScreen implements Cloneable, AbstractGraphicsScreen public AbstractGraphicsDevice getDevice() { return device; } - + public int getIndex() { return idx; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java index 9694f2491..e1aa91959 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008-2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -48,7 +48,7 @@ import java.util.Set; /** * Provides the mechanism by which the graphics configuration for a - * window can be chosen before the window is created. The graphics + * window can be chosen before the window is created. The graphics * configuration decides parameters related to hardware accelerated rendering such * as the OpenGL pixel format.
          * On some window systems (EGL/OpenKODE and X11 in particular) it is necessary to @@ -69,21 +69,21 @@ public abstract class GraphicsConfigurationFactory { public final Class deviceType; public final Class capsType; private final int hash32; - + public DeviceCapsType(Class deviceType, Class capsType) { this.deviceType = deviceType; this.capsType = capsType; - + // 31 * x == (x << 5) - x int hash32 = 31 + deviceType.hashCode(); hash32 = ((hash32 << 5) - hash32) + capsType.hashCode(); this.hash32 = hash32; } - + public final int hashCode() { return hash32; } - + public final boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof DeviceCapsType) { @@ -92,18 +92,18 @@ public abstract class GraphicsConfigurationFactory { } return false; } - + @Override public final String toString() { return "DeviceCapsType["+deviceType.getName()+", "+capsType.getName()+"]"; } - + } - + private static final Map registeredFactories; - private static final DeviceCapsType defaultDeviceCapsType; + private static final DeviceCapsType defaultDeviceCapsType; static boolean initialized = false; - + static { DEBUG = Debug.debug("GraphicsConfiguration"); if(DEBUG) { @@ -113,7 +113,7 @@ public abstract class GraphicsConfigurationFactory { registeredFactories = Collections.synchronizedMap(new HashMap()); defaultDeviceCapsType = new DeviceCapsType(AbstractGraphicsDevice.class, CapabilitiesImmutable.class); } - + public static synchronized void initSingleton() { if(!initialized) { initialized = true; @@ -121,31 +121,31 @@ public abstract class GraphicsConfigurationFactory { if(DEBUG) { System.err.println(Thread.currentThread().getName()+" - GraphicsConfigurationFactory.initSingleton()"); } - + // Register the default no-op factory for arbitrary // AbstractGraphicsDevice implementations, including // AWTGraphicsDevice instances -- the OpenGL binding will take // care of handling AWTGraphicsDevices on X11 platforms (as // well as X11GraphicsDevices in non-AWT situations) registerFactory(defaultDeviceCapsType.deviceType, defaultDeviceCapsType.capsType, new DefaultGraphicsConfigurationFactoryImpl()); - + if (NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true)) { try { - ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.X11GraphicsConfigurationFactory", - "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader()); + ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.X11GraphicsConfigurationFactory", + "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader()); } catch (Exception e) { throw new RuntimeException(e); } if(NativeWindowFactory.isAWTAvailable()) { try { - ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.awt.X11AWTGraphicsConfigurationFactory", - "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader()); + ReflectionUtil.callStaticMethod("jogamp.nativewindow.x11.awt.X11AWTGraphicsConfigurationFactory", + "registerFactory", null, null, GraphicsConfigurationFactory.class.getClassLoader()); } catch (Exception e) { /* n/a */ } } } } } - + public static synchronized void shutdown() { if(initialized) { initialized = false; @@ -155,7 +155,7 @@ public abstract class GraphicsConfigurationFactory { registeredFactories.clear(); } } - + protected static String getThreadName() { return Thread.currentThread().getName(); } @@ -176,10 +176,10 @@ public abstract class GraphicsConfigurationFactory { /** * Returns the graphics configuration factory for use with the * given device and capability. - * + * * @see #getFactory(Class, Class) */ - public static GraphicsConfigurationFactory getFactory(AbstractGraphicsDevice device, CapabilitiesImmutable caps) { + public static GraphicsConfigurationFactory getFactory(AbstractGraphicsDevice device, CapabilitiesImmutable caps) { if (device == null) { throw new IllegalArgumentException("null device"); } @@ -195,7 +195,7 @@ public abstract class GraphicsConfigurationFactory { *

          * Note: Registered device types maybe classes or interfaces, where capabilities types are interfaces only. *

          - * + * *

          * Pseudo code for finding a suitable factory is: *

          @@ -211,7 +211,7 @@ public abstract class GraphicsConfigurationFactory {
                * @param deviceType the minimum capabilities class type accepted, must implement or extend {@link AbstractGraphicsDevice}
                * @param capabilitiesType the minimum capabilities class type accepted, must implement or extend {@link CapabilitiesImmutable}
                *
          -     * @throws IllegalArgumentException if the deviceType does not implement {@link AbstractGraphicsDevice} or 
          +     * @throws IllegalArgumentException if the deviceType does not implement {@link AbstractGraphicsDevice} or
                *                                  capabilitiesType does not implement {@link CapabilitiesImmutable}
                */
               public static GraphicsConfigurationFactory getFactory(Class deviceType, Class capabilitiesType)
          @@ -228,12 +228,12 @@ public abstract class GraphicsConfigurationFactory {
                       System.err.println("GraphicsConfigurationFactory.getFactory: "+deviceType.getName()+", "+capabilitiesType.getName());
                       dumpFactories();
                   }
          -        
          -        final List> deviceTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.deviceType, deviceType, false);        
          +
          +        final List> deviceTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.deviceType, deviceType, false);
                   if(DEBUG) {
                       System.err.println("GraphicsConfigurationFactory.getFactory() deviceTypes: " + deviceTypes);
                   }
          -        final List> capabilitiesTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.capsType, capabilitiesType, true);        
          +        final List> capabilitiesTypes = getAllAssignableClassesFrom(defaultDeviceCapsType.capsType, capabilitiesType, true);
                   if(DEBUG) {
                       System.err.println("GraphicsConfigurationFactory.getFactory() capabilitiesTypes: " + capabilitiesTypes);
                   }
          @@ -259,7 +259,7 @@ public abstract class GraphicsConfigurationFactory {
                   return factory;
               }
               private static ArrayList> getAllAssignableClassesFrom(Class superClassOrInterface, Class fromClass, boolean interfacesOnly) {
          -        // Using a todo list avoiding a recursive loop! 
          +        // Using a todo list avoiding a recursive loop!
                   final ArrayList> inspectClasses  = new ArrayList>();
                   final ArrayList> resolvedInterfaces = new ArrayList>();
                   inspectClasses.add(fromClass);
          @@ -277,7 +277,7 @@ public abstract class GraphicsConfigurationFactory {
                       }
                   }
                   types.addAll(Arrays.asList(fromClass.getInterfaces()));
          -                
          +
                   for(int i=0; i iface = types.get(i);
                       if( superClassOrInterface.isAssignableFrom(iface) && !resolvedInterfaces.contains(iface) ) {
          @@ -302,20 +302,20 @@ public abstract class GraphicsConfigurationFactory {
                   }
               }
           
          -    /** 
          +    /**
                * Registers a GraphicsConfigurationFactory handling
                * the given graphics device and capability class.
                * 

          * This does not need to be called by end users, only implementors of new * GraphicsConfigurationFactory subclasses. *

          - * + * *

          * Note: Registered device types maybe classes or interfaces, where capabilities types are interfaces only. - *

          - * + *

          + * *

          See {@link #getFactory(Class, Class)} for a description of the find algorithm.

          - * + * * @param deviceType the minimum capabilities class type accepted, must implement or extend interface {@link AbstractGraphicsDevice} * @param capabilitiesType the minimum capabilities class type accepted, must extend interface {@link CapabilitiesImmutable} * @return the previous registered factory, or null if none @@ -329,7 +329,7 @@ public abstract class GraphicsConfigurationFactory { } if (!(defaultDeviceCapsType.capsType.isAssignableFrom(capabilitiesType))) { throw new IllegalArgumentException("Given capabilities class must implement CapabilitiesImmutable"); - } + } final DeviceCapsType dct = new DeviceCapsType(abstractGraphicsDeviceImplementor, capabilitiesType); final GraphicsConfigurationFactory prevFactory; if(null == factory) { @@ -352,7 +352,7 @@ public abstract class GraphicsConfigurationFactory { *

          Selects a graphics configuration on the specified graphics * device compatible with the supplied {@link Capabilities}. Some * platforms (e.g.: X11, EGL, KD) require the graphics configuration - * to be specified when the native window is created. + * to be specified when the native window is created. * These architectures have seperated their device, screen, window and drawable * context and hence are capable of quering the capabilities for each screen. * A fully established window is not required.

          @@ -360,7 +360,7 @@ public abstract class GraphicsConfigurationFactory { *

          Other platforms (e.g. Windows, MacOSX) don't offer the mentioned seperation * and hence need a fully established window and it's drawable. * Here the validation of the capabilities is performed later. - * In this case, the AbstractGraphicsConfiguration implementation + * In this case, the AbstractGraphicsConfiguration implementation * must allow an overwrite of the Capabilites, for example * {@link DefaultGraphicsConfiguration#setChosenCapabilities DefaultGraphicsConfiguration.setChosenCapabilities(..)}. *

          @@ -385,7 +385,7 @@ public abstract class GraphicsConfigurationFactory { * @param capsRequested the original requested capabilities * @param chooser the choosing implementation * @param screen the referring Screen - * @param nativeVisualID if not {@link VisualIDHolder#VID_UNDEFINED} it reflects a pre-chosen visualID of the native platform's windowing system. + * @param nativeVisualID if not {@link VisualIDHolder#VID_UNDEFINED} it reflects a pre-chosen visualID of the native platform's windowing system. * @return the complete GraphicsConfiguration * * @throws IllegalArgumentException if the data type of the passed diff --git a/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java b/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java index ff53c8109..a0db11ad9 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java @@ -31,12 +31,12 @@ package javax.media.nativewindow; /** * Provides a {@link NativeSurface} with a mutable surfaceHandle * via {@link #setSurfaceHandle(long)}. - * + * * @see NativeSurface */ public interface MutableSurface extends NativeSurface { - /** + /** * Sets the surface handle which is created outside of this implementation. */ public void setSurfaceHandle(long surfaceHandle); diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java index a89caec76..a755b1812 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package javax.media.nativewindow; /** Provides low-level information required for @@ -54,10 +54,10 @@ public interface NativeSurface extends SurfaceUpdatedListener { *

          * The surface handle shall be valid after a successfull call, * ie return a value other than {@link #LOCK_SURFACE_UNLOCKED} and {@link #LOCK_SURFACE_NOT_READY}, - * which is - *

           
          -   *    boolean ok = LOCK_SURFACE_NOT_READY < lockSurface(); 
          -   * 
          + * which is + *
          +   *    boolean ok = LOCK_SURFACE_NOT_READY < lockSurface();
          +   * 
          *

          *

          * The caller may need to take care of the result {@link #LOCK_SURFACE_CHANGED}, @@ -71,7 +71,7 @@ public interface NativeSurface extends SurfaceUpdatedListener { * This call allows recursion from the same thread. *

          *

          - * The implementation may want to aquire the + * The implementation may want to aquire the * application level {@link com.jogamp.common.util.locks.RecursiveLock} * first before proceeding with a native surface lock. *

          @@ -115,7 +115,7 @@ public interface NativeSurface extends SurfaceUpdatedListener { *
          */ public boolean isSurfaceLockedByOtherThread(); - + /** * Return the locking owner's Thread, or null if not locked. */ @@ -123,15 +123,15 @@ public interface NativeSurface extends SurfaceUpdatedListener { /** * Provide a mechanism to utilize custom (pre-) swap surface - * code. This method is called before the render toolkit (e.g. JOGL) + * code. This method is called before the render toolkit (e.g. JOGL) * swaps the buffer/surface if double buffering is enabled. - *

          + *

          * The implementation may itself apply the swapping, * in which case true shall be returned. *

          * * @return true if this method completed swapping the surface, - * otherwise false, in which case eg the GLDrawable + * otherwise false, in which case eg the GLDrawable * implementation has to swap the code. */ public boolean surfaceSwap(); @@ -153,13 +153,13 @@ public interface NativeSurface extends SurfaceUpdatedListener { /** Remove the specified {@link SurfaceUpdatedListener} from the list. */ public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l); - + /** * Returns the handle to the surface for this NativeSurface.

          - * + * * The surface handle should be set/update by {@link #lockSurface()}, * where {@link #unlockSurface()} is not allowed to modify it. - * After {@link #unlockSurface()} it is no more guaranteed + * After {@link #unlockSurface()} it is no more guaranteed * that the surface handle is still valid. * * The surface handle shall reflect the platform one @@ -195,16 +195,16 @@ public interface NativeSurface extends SurfaceUpdatedListener { public AbstractGraphicsConfiguration getGraphicsConfiguration(); /** - * Convenience: Get display handle from + * Convenience: Get display handle from * AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice */ public long getDisplayHandle(); /** - * Convenience: Get display handle from + * Convenience: Get display handle from * AbstractGraphicsConfiguration . AbstractGraphicsScreen */ public int getScreenIndex(); - + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java index 593c1e7d6..0943c8c09 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowException.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 07d1008b4..bad72f355 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008-2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -90,13 +90,13 @@ public abstract class NativeWindowFactory { private static final String nativeWindowingTypePure; // canonical String via String.intern() private static final String nativeWindowingTypeCustom; // canonical String via String.intern() - + private static NativeWindowFactory defaultFactory; private static Map, NativeWindowFactory> registeredFactories; - + private static Class nativeWindowClass; private static boolean isAWTAvailable; - + private static final String JAWTUtilClassName = "jogamp.nativewindow.jawt.JAWTUtil" ; /** {@link jogamp.nativewindow.x11.X11Util} implements {@link ToolkitProperties}. */ private static final String X11UtilClassName = "jogamp.nativewindow.x11.X11Util"; @@ -104,16 +104,16 @@ public abstract class NativeWindowFactory { private static final String OSXUtilClassName = "jogamp.nativewindow.macosx.OSXUtil"; /** {@link jogamp.nativewindow.windows.GDIUtil} implements {@link ToolkitProperties}. */ private static final String GDIClassName = "jogamp.nativewindow.windows.GDIUtil"; - + private static ToolkitLock jawtUtilJAWTToolkitLock; - + private static boolean requiresToolkitLock; private static boolean desktopHasThreadingIssues; // Shutdown hook mechanism for the factory private static volatile boolean isJVMShuttingDown = false; private static final List customShutdownHooks = new ArrayList(); - + /** Creates a new NativeWindowFactory instance. End users do not need to call this method. */ protected NativeWindowFactory() { @@ -139,10 +139,10 @@ public abstract class NativeWindowFactory { case MACOS: return TYPE_MACOSX; case WINDOWS: - return TYPE_WINDOWS; + return TYPE_WINDOWS; case OPENKODE: return TYPE_EGL; - + case LINUX: case FREEBSD: case SUNOS: @@ -158,7 +158,7 @@ public abstract class NativeWindowFactory { static { final boolean[] _DEBUG = new boolean[] { false }; final String[] _tmp = new String[] { null }; - + AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Platform.initSingleton(); // last resort .. @@ -168,16 +168,16 @@ public abstract class NativeWindowFactory { new Thread(new Runnable() { public void run() { NativeWindowFactory.shutdown(true); - } }, "NativeWindowFactory_ShutdownHook" ) ) ; + } }, "NativeWindowFactory_ShutdownHook" ) ) ; return null; } } ) ; - + DEBUG = _DEBUG[0]; if(DEBUG) { System.err.println(Thread.currentThread().getName()+" - Info: NativeWindowFactory."); // Thread.dumpStack(); } - + // Gather the windowing TK first nativeWindowingTypePure = _getNativeWindowingType(); if(null==_tmp[0] || _tmp[0].length()==0) { @@ -202,23 +202,23 @@ public abstract class NativeWindowFactory { } if( null != clazzName ) { ReflectionUtil.callStaticMethod(clazzName, "initSingleton", null, null, cl ); - + final Boolean res1 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresToolkitLock", null, null, cl); requiresToolkitLock = res1.booleanValue(); final Boolean res2 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "hasThreadingIssues", null, null, cl); desktopHasThreadingIssues = res2.booleanValue(); - } else { + } else { requiresToolkitLock = false; desktopHasThreadingIssues = false; } } - /** Returns true if the JVM is shutting down, otherwise false. */ + /** Returns true if the JVM is shutting down, otherwise false. */ public static final boolean isJVMShuttingDown() { return isJVMShuttingDown; } - - /** + + /** * Add a custom shutdown hook to be performed at JVM shutdown before shutting down NativeWindowFactory instance. - * + * * @param head if true add runnable at the start, otherwise at the end * @param runnable runnable to be added. */ @@ -234,7 +234,7 @@ public abstract class NativeWindowFactory { } } - /** + /** * Cleanup resources at JVM shutdown */ public static synchronized void shutdown(boolean _isJVMShuttingDown) { @@ -246,14 +246,14 @@ public abstract class NativeWindowFactory { final int cshCount = customShutdownHooks.size(); for(int i=0; i < cshCount; i++) { try { - if( DEBUG ) { + if( DEBUG ) { System.err.println("NativeWindowFactory.shutdown - customShutdownHook #"+(i+1)+"/"+cshCount); } customShutdownHooks.get(i).run(); } catch(Throwable t) { System.err.println("NativeWindowFactory.shutdown: Catched "+t.getClass().getName()+" during customShutdownHook #"+(i+1)+"/"+cshCount); - if( DEBUG ) { - t.printStackTrace(); + if( DEBUG ) { + t.printStackTrace(); } } } @@ -262,7 +262,7 @@ public abstract class NativeWindowFactory { if(DEBUG) { System.err.println("NativeWindowFactory.shutdown(): Post customShutdownHook"); } - + if(initialized) { initialized = false; if(null != registeredFactories) { @@ -271,14 +271,14 @@ public abstract class NativeWindowFactory { } GraphicsConfigurationFactory.shutdown(); } - + shutdownNativeImpl(NativeWindowFactory.class.getClassLoader()); // always re-shutdown // SharedResourceToolkitLock.shutdown(DEBUG); // not used yet if(DEBUG) { System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.shutdown() END JVM Shutdown "+isJVMShuttingDown); } } - + private static void shutdownNativeImpl(final ClassLoader cl) { final String clazzName; if( TYPE_X11 == nativeWindowingTypePure ) { @@ -292,11 +292,11 @@ public abstract class NativeWindowFactory { } if( null != clazzName ) { ReflectionUtil.callStaticMethod(clazzName, "shutdown", null, null, cl ); - } + } } - + /** Returns true if {@link #initSingleton()} has been called w/o subsequent {@link #shutdown(boolean)}. */ - public static synchronized boolean isInitialized() { return initialized; } + public static synchronized boolean isInitialized() { return initialized; } /** * Static one time initialization of this factory.
          @@ -316,7 +316,7 @@ public abstract class NativeWindowFactory { if( Platform.AWT_AVAILABLE && ReflectionUtil.isClassAvailable("com.jogamp.nativewindow.awt.AWTGraphicsDevice", cl) ) { - + Method[] jawtUtilMethods = AccessController.doPrivileged(new PrivilegedAction() { public Method[] run() { try { @@ -327,7 +327,7 @@ public abstract class NativeWindowFactory { jawtUtilInitMethod.setAccessible(true); Method jawtUtilGetJAWTToolkitLockMethod = _jawtUtilClass.getDeclaredMethod("getJAWTToolkitLock", new Class[]{}); jawtUtilGetJAWTToolkitLockMethod.setAccessible(true); - return new Method[] { jawtUtilInitMethod, jawtUtilIsHeadlessMethod, jawtUtilGetJAWTToolkitLockMethod }; + return new Method[] { jawtUtilInitMethod, jawtUtilIsHeadlessMethod, jawtUtilGetJAWTToolkitLockMethod }; } catch (Exception e) { if(DEBUG) { e.printStackTrace(); @@ -340,7 +340,7 @@ public abstract class NativeWindowFactory { final Method jawtUtilInitMethod = jawtUtilMethods[0]; final Method jawtUtilIsHeadlessMethod = jawtUtilMethods[1]; final Method jawtUtilGetJAWTToolkitLockMethod = jawtUtilMethods[2]; - + ReflectionUtil.callMethod(null, jawtUtilInitMethod); Object resO = ReflectionUtil.callMethod(null, jawtUtilIsHeadlessMethod); @@ -351,21 +351,21 @@ public abstract class NativeWindowFactory { } else { throw new RuntimeException("JAWTUtil.isHeadlessMode() didn't return a Boolean"); } - resO = ReflectionUtil.callMethod(null, jawtUtilGetJAWTToolkitLockMethod); + resO = ReflectionUtil.callMethod(null, jawtUtilGetJAWTToolkitLockMethod); if(resO instanceof ToolkitLock) { jawtUtilJAWTToolkitLock = (ToolkitLock) resO; } else { throw new RuntimeException("JAWTUtil.getJAWTToolkitLock() didn't return a ToolkitLock"); - } + } } } - + // X11 initialization after possible AWT initialization // This is performed post AWT initialization, allowing AWT to complete the same, - // which may have been triggered before NativeWindow initialization. - // This way behavior is more uniforms across configurations (Applet/RCP, applications, ..). + // which may have been triggered before NativeWindow initialization. + // This way behavior is more uniforms across configurations (Applet/RCP, applications, ..). initSingletonNativeImpl(cl); - + registeredFactories = Collections.synchronizedMap(new HashMap, NativeWindowFactory>()); // register our default factory -> NativeWindow @@ -373,17 +373,17 @@ public abstract class NativeWindowFactory { nativeWindowClass = javax.media.nativewindow.NativeWindow.class; registerFactory(nativeWindowClass, factory); defaultFactory = factory; - + if ( isAWTAvailable ) { // register either our default factory or (if exist) the X11/AWT one -> AWT Component registerFactory(ReflectionUtil.getClass(ReflectionUtil.AWTNames.ComponentClass, false, cl), factory); } - + if(DEBUG) { System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock+", desktopHasThreadingIssues "+desktopHasThreadingIssues); System.err.println("NativeWindowFactory isAWTAvailable "+isAWTAvailable+", defaultFactory "+factory); } - + GraphicsConfigurationFactory.initSingleton(); } } @@ -392,20 +392,20 @@ public abstract class NativeWindowFactory { public static boolean requiresToolkitLock() { return requiresToolkitLock; } - + /** @return true if not headless, AWT Component and NativeWindow's AWT part available */ public static boolean isAWTAvailable() { return isAWTAvailable; } /** * @param useCustom if false return the native value, if true return a custom value if set, otherwise fallback to the native value. - * @return the native window type, e.g. {@link #TYPE_X11}, which is canonical via {@link String#intern()}. + * @return the native window type, e.g. {@link #TYPE_X11}, which is canonical via {@link String#intern()}. * Hence {@link String#equals(Object)} and == produce the same result. */ public static String getNativeWindowType(boolean useCustom) { return useCustom?nativeWindowingTypeCustom:nativeWindowingTypePure; } - /** Don't know if we shall add this factory here .. + /** Don't know if we shall add this factory here .. public static AbstractGraphicsDevice createGraphicsDevice(String type, String connection, int unitID, long handle, ToolkitLock locker) { if(TYPE_EGL == type) { return new @@ -427,13 +427,13 @@ public abstract class NativeWindowFactory { return defaultFactory; } - /** + /** * Returns the AWT {@link ToolkitLock} (JAWT based) if {@link #isAWTAvailable}, otherwise null. *

          * The JAWT based {@link ToolkitLock} also locks the global lock, * which matters if the latter is required. - *

          - */ + *

          + */ public static ToolkitLock getAWTToolkitLock() { return jawtUtilJAWTToolkitLock; } @@ -441,7 +441,7 @@ public abstract class NativeWindowFactory { public static ToolkitLock getNullToolkitLock() { return NativeWindowFactoryImpl.getNullToolkitLock(); } - + /** * Provides the system default {@link ToolkitLock} for the default system windowing type. * @see #getNativeWindowType(boolean) @@ -486,7 +486,7 @@ public abstract class NativeWindowFactory { } return NativeWindowFactoryImpl.getNullToolkitLock(); } - + /** * @param device * @param screen -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen @@ -510,7 +510,7 @@ public abstract class NativeWindowFactory { } return new DefaultGraphicsScreen(device, screen); } - + /** Returns the appropriate NativeWindowFactory to handle window objects of the given type. The windowClass might be {@link NativeWindow NativeWindow}, in which case the client has @@ -543,7 +543,7 @@ public abstract class NativeWindowFactory { } /** Converts the given window object and it's - {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration} into a + {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration} into a {@link NativeWindow NativeWindow} which can be operated upon by a custom toolkit, e.g. {@link javax.media.opengl.GLDrawableFactory javax.media.opengl.GLDrawableFactory}.
          The object may be a component for a particular window toolkit, such as an AWT @@ -554,7 +554,7 @@ public abstract class NativeWindowFactory { NativeWindowFactory is responsible for handling objects from a particular window toolkit. The built-in NativeWindowFactory handles NativeWindow instances as well as AWT Components.
          - + @throws IllegalArgumentException if the given window object could not be handled by any of the registered NativeWindowFactory instances @@ -573,22 +573,22 @@ public abstract class NativeWindowFactory { NativeWindow. Implementors of concrete NativeWindowFactory subclasses should override this method. */ protected abstract NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException; - + /** * Returns the {@link OffscreenLayerSurface} instance of this {@link NativeSurface}. *

          - * In case this surface is a {@link NativeWindow}, we traverse from the given surface + * In case this surface is a {@link NativeWindow}, we traverse from the given surface * up to root until an implementation of {@link OffscreenLayerSurface} is found. * In case ifEnabled is true, the surface must also implement {@link OffscreenLayerOption} - * where {@link OffscreenLayerOption#isOffscreenLayerSurfaceEnabled()} is true. + * where {@link OffscreenLayerOption#isOffscreenLayerSurfaceEnabled()} is true. *

          - * + * * @param surface The surface to query. - * @param ifEnabled If true, only return the enabled {@link OffscreenLayerSurface}, see {@link OffscreenLayerOption#isOffscreenLayerSurfaceEnabled()}. + * @param ifEnabled If true, only return the enabled {@link OffscreenLayerSurface}, see {@link OffscreenLayerOption#isOffscreenLayerSurfaceEnabled()}. * @return */ public static OffscreenLayerSurface getOffscreenLayerSurface(NativeSurface surface, boolean ifEnabled) { - if(surface instanceof OffscreenLayerSurface && + if(surface instanceof OffscreenLayerSurface && ( !ifEnabled || surface instanceof OffscreenLayerOption ) ) { final OffscreenLayerSurface ols = (OffscreenLayerSurface) surface; return ( !ifEnabled || ((OffscreenLayerOption)ols).isOffscreenLayerSurfaceEnabled() ) ? ols : null; @@ -601,12 +601,12 @@ public abstract class NativeWindowFactory { final OffscreenLayerSurface ols = (OffscreenLayerSurface) nw; return ( !ifEnabled || ((OffscreenLayerOption)ols).isOffscreenLayerSurfaceEnabled() ) ? ols : null; } - nw = nw.getParent(); + nw = nw.getParent(); } } - return null; + return null; } - + /** * Returns true if the given visualID is valid for further processing, i.e. OpenGL usage, * otherwise return false. @@ -619,8 +619,8 @@ public abstract class NativeWindowFactory { *

          */ public static boolean isNativeVisualIDValidForProcessing(int visualID) { - return NativeWindowFactory.TYPE_X11 != NativeWindowFactory.getNativeWindowType(false) || + return NativeWindowFactory.TYPE_X11 != NativeWindowFactory.getNativeWindowType(false) || VisualIDHolder.VID_UNDEFINED != visualID ; } - + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java index 12d30b3cd..11496899a 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerOption.java @@ -32,30 +32,30 @@ package javax.media.nativewindow; * within the implementation. */ public interface OffscreenLayerOption { - /** + /** * Request an offscreen layer, if supported. *

          * Shall be called before the first {@link NativeWindow#lockSurface()}, * and hence before realization. *

          - * + * * @see #getShallUseOffscreenLayer() - * @see #isOffscreenLayerSurfaceEnabled() + * @see #isOffscreenLayerSurfaceEnabled() */ public void setShallUseOffscreenLayer(boolean v); /** Returns the property set by {@link #setShallUseOffscreenLayer(boolean)}. */ public boolean getShallUseOffscreenLayer(); - /** + /** * Returns true if this instance uses an offscreen layer, otherwise false. *

          * This instance is an offscreen layer, if {@link #setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} * has been called before it's realization and first lock and the underlying implementation supports it. *

          * The return value is undefined before issuing the first {@link NativeWindow#lockSurface()}. - * - * @see #setShallUseOffscreenLayer(boolean) + * + * @see #setShallUseOffscreenLayer(boolean) */ public boolean isOffscreenLayerSurfaceEnabled(); } \ No newline at end of file diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index 1826008ad..8681422ef 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -33,36 +33,36 @@ import com.jogamp.common.util.locks.RecursiveLock; * Interface specifying the offscreen layer surface protocol. */ public interface OffscreenLayerSurface { - /** + /** * Attach the offscreen layer to this offscreen layer surface. *

          * Implementation may realize all required resources at this point. *

          - * + * * @see #isOffscreenLayerSurfaceEnabled() * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false */ public void attachSurfaceLayer(final long layerHandle) throws NativeWindowException; - - /** + + /** * Detaches a previously attached offscreen layer from this offscreen layer surface. * @see #attachSurfaceLayer(long) * @see #isOffscreenLayerSurfaceEnabled() - * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false + * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false * or no surface layer is attached. */ public void detachSurfaceLayer() throws NativeWindowException; - + /** Returns the attached surface layer or null if none is attached. */ public long getAttachedSurfaceLayer(); - + /** Returns true if a surface layer is attached, otherwise false. */ public boolean isSurfaceLayerAttached(); - + /** Sets the capabilities of this instance, allowing upstream API's to refine it, i.e. OpenGL related settings. */ public void setChosenCapabilities(CapabilitiesImmutable caps); - - /** Returns the recursive lock object of this surface, which synchronizes multithreaded access. */ + + /** Returns the recursive lock object of this surface, which synchronizes multithreaded access. */ public RecursiveLock getLock(); - + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java index 15a8738c5..eb0a6cf04 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java @@ -33,44 +33,44 @@ import jogamp.nativewindow.Debug; /** * Provides a mutable {@link NativeSurface}, i.e. {@link MutableSurface}, while allowing an * {@link UpstreamSurfaceHook} to influence the lifecycle and information. - * + * * @see UpstreamSurfaceHook * @see MutableSurface * @see NativeSurface */ -public interface ProxySurface extends MutableSurface { +public interface ProxySurface extends MutableSurface { public static final boolean DEBUG = Debug.debug("ProxySurface"); - - /** + + /** * Implementation specific bit-value stating this {@link ProxySurface} owns the upstream's surface handle * @see #addUpstreamOptionBits(int) * @see #clearUpstreamOptionBits(int) * @see #getUpstreamOptionBits() - */ + */ public static final int OPT_PROXY_OWNS_UPSTREAM_SURFACE = 1 << 6; - - /** + + /** * Implementation specific bit-value stating this {@link ProxySurface} owns the upstream's {@link AbstractGraphicsDevice}. * @see #addUpstreamOptionBits(int) * @see #clearUpstreamOptionBits(int) * @see #getUpstreamOptionBits() - */ + */ public static final int OPT_PROXY_OWNS_UPSTREAM_DEVICE = 1 << 7; - - /** + + /** * Implementation specific bitvalue stating the upstream's {@link NativeSurface} is an invisible window, i.e. maybe incomplete. * @see #addUpstreamOptionBits(int) * @see #clearUpstreamOptionBits(int) * @see #getUpstreamOptionBits() - */ + */ public static final int OPT_UPSTREAM_WINDOW_INVISIBLE = 1 << 8; /** Allow redefining the AbstractGraphicsConfiguration */ - public void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg); + public void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg); /** * Return the upstream {@link NativeSurface} if used, otherwise null. - *

          + *

          * An upstream {@link NativeSurface} may backup this {@link ProxySurface} instance's representation, * e.g. via a {@link #setUpstreamSurfaceHook(UpstreamSurfaceHook) set} {@link UpstreamSurfaceHook}. *

          @@ -80,47 +80,47 @@ public interface ProxySurface extends MutableSurface { *

          */ public NativeSurface getUpstreamSurface(); - + /** Returns the {@link UpstreamSurfaceHook} if {@link #setUpstreamSurfaceHook(UpstreamSurfaceHook) set}, otherwise null. */ public UpstreamSurfaceHook getUpstreamSurfaceHook(); - + /** * Sets the {@link UpstreamSurfaceHook} and returns the previous value. */ public void setUpstreamSurfaceHook(UpstreamSurfaceHook hook); - - /** - * Enables or disables the {@link UpstreamSurfaceHook} lifecycle functions + + /** + * Enables or disables the {@link UpstreamSurfaceHook} lifecycle functions * {@link UpstreamSurfaceHook#create(ProxySurface)} and {@link UpstreamSurfaceHook#destroy(ProxySurface)}. *

          * Use this for small code blocks where the native resources shall not change, * i.e. resizing a derived (OpenGL) drawable. - *

          + *

          */ public void enableUpstreamSurfaceHookLifecycle(boolean enable); - - /** + + /** * {@link UpstreamSurfaceHook#create(ProxySurface)} is being issued and the proxy surface/window handles shall be set. - */ + */ public void createNotify(); - - /** + + /** * {@link UpstreamSurfaceHook#destroy(ProxySurface)} is being issued and all proxy surface/window handles shall be cleared. - */ + */ public void destroyNotify(); - + public StringBuilder getUpstreamOptionBits(StringBuilder sink); public int getUpstreamOptionBits(); - + /** Returns true if the give bit-mask v is set in this instance upstream-option-bits, otherwise false.*/ public boolean containsUpstreamOptionBits(int v); - + /** Add the given bit-mask to this instance upstream-option-bits using bit-or w/ v.*/ public void addUpstreamOptionBits(int v); - + /** Clear the given bit-mask from this instance upstream-option-bits using bit-and w/ ~v*/ public void clearUpstreamOptionBits(int v); - + public StringBuilder toString(StringBuilder sink); public String toString(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java b/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java index 0912b5afe..de65a3031 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java +++ b/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 javax.media.nativewindow; diff --git a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java index eccfcfa4f..017b996d7 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java @@ -53,26 +53,26 @@ public interface ToolkitLock { * @throws RuntimeException in case of a timeout */ public void lock(); - + /** * Release the lock. * * @throws RuntimeException in case the lock is not acquired by this thread. */ public void unlock(); - + /** - * @throws RuntimeException if current thread does not hold the lock + * @throws RuntimeException if current thread does not hold the lock */ public void validateLocked() throws RuntimeException; - - /** + + /** * Dispose this instance. - *

          + *

          * Shall be called when instance is no more required. *

          * This allows implementations sharing a lock via resources - * to decrease the reference counter. + * to decrease the reference counter. */ public void dispose(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java b/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java index 6fe2e5364..f08a6c938 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java +++ b/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java @@ -28,24 +28,24 @@ package javax.media.nativewindow; -/** - * Interface allowing upstream caller to pass lifecycle actions and size info - * to a {@link ProxySurface} instance. - */ +/** + * Interface allowing upstream caller to pass lifecycle actions and size info + * to a {@link ProxySurface} instance. + */ public interface UpstreamSurfaceHook { /** called within {@link ProxySurface#createNotify()} within lock, before using surface. */ public void create(ProxySurface s); /** called within {@link ProxySurface#destroyNotify()} within lock, before clearing fields. */ public void destroy(ProxySurface s); - /** Returns the width of the upstream surface, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */ + /** Returns the width of the upstream surface, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */ public int getWidth(ProxySurface s); - /** Returns the height of the upstream surface, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */ + /** Returns the height of the upstream surface, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */ public int getHeight(ProxySurface s); - + /** - * {@link UpstreamSurfaceHook} w/ mutable size, allowing it's {@link ProxySurface} user to resize. - */ + * {@link UpstreamSurfaceHook} w/ mutable size, allowing it's {@link ProxySurface} user to resize. + */ public interface MutableSize extends UpstreamSurfaceHook { public void setSize(int width, int height); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java b/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java index 4f3d3ff00..4ee71ee79 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java +++ b/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java @@ -38,7 +38,7 @@ import java.util.Comparator; *

          */ public interface VisualIDHolder { - + public enum VIDType { // Generic Values INTRINSIC(0), NATIVE(1), @@ -47,19 +47,19 @@ public interface VisualIDHolder { // X11 Values X11_XVISUAL(20), X11_FBCONFIG(21), // Windows Values - WIN32_PFD(30); - + WIN32_PFD(30); + public final int id; VIDType(int id){ this.id = id; } - } - + } + /** * Returns the native visual ID of the given type * if supported, or {@link #VID_UNDEFINED} if not supported. - *

          + *

          * Depending on the native windowing system, type is handled as follows: *

            *
          • X11 throws NativeWindowException on EGL_CONFIG, WIN32_PFD @@ -76,7 +76,7 @@ public interface VisualIDHolder { *
          • X11_XVISUAL: X11 XVisual ID
          • *
          • X11_FBCONFIG: X11 FBConfig ID or VID_UNDEFINED
          • *
          - *
        • Windows/GL throws NativeWindowException on EGL_CONFIG, X11_XVISUAL, X11_FBCONFIG + *
        • Windows/GL throws NativeWindowException on EGL_CONFIG, X11_XVISUAL, X11_FBCONFIG *
            *
          • INTRINSIC: Win32 PIXELFORMATDESCRIPTOR ID
          • *
          • NATIVE: Win32 PIXELFORMATDESCRIPTOR ID
          • @@ -91,35 +91,35 @@ public interface VisualIDHolder { *
          *

          * Note: INTRINSIC and NATIVE are always handled, - * but may result in {@link #VID_UNDEFINED}. The latter is true if - * the native value are actually undefined or the corresponding object is not + * but may result in {@link #VID_UNDEFINED}. The latter is true if + * the native value are actually undefined or the corresponding object is not * mapped to a native visual object. - * + * * @throws NativeWindowException if type is neither * INTRINSIC nor NATIVE - * and does not match the native implementation. + * and does not match the native implementation. */ int getVisualID(VIDType type) throws NativeWindowException ; - - /** + + /** * {@link #getVisualID(VIDType)} result indicating an undefined value, * which could be cause by an unsupported query. *

          * We assume the const value 0 doesn't reflect a valid native visual ID * and is interpreted as no value on all platforms. * This is currently true for Android, X11 and Windows. - *

          + *

          */ static final int VID_UNDEFINED = 0; - + /** Comparing {@link VIDType#NATIVE} */ public static class VIDComparator implements Comparator { private VIDType type; - + public VIDComparator(VIDType type) { this.type = type; } - + public int compare(VisualIDHolder vid1, VisualIDHolder vid2) { final int id1 = vid1.getVisualID(type); final int id2 = vid2.getVisualID(type); @@ -131,5 +131,5 @@ public interface VisualIDHolder { } return 0; } - } + } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java b/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java index 02f68f442..8570b78da 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java +++ b/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java @@ -37,7 +37,7 @@ package javax.media.nativewindow; * this protocol default behavior {@link WindowClosingMode#DISPOSE_ON_CLOSE DISPOSE_ON_CLOSE} shall be used.

          */ public interface WindowClosingProtocol { - + /** * Window closing mode if triggered by toolkit close operation. */ @@ -47,7 +47,7 @@ public interface WindowClosingProtocol { * This is the default behavior within an AWT environment. */ DO_NOTHING_ON_CLOSE, - + /** * Dispose resources on native window close operation.
          * This is the default behavior in case no underlying toolkit defines otherwise. diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index 17b4930c5..b8b48a46c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -4,14 +4,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -21,12 +21,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package javax.media.nativewindow.util; public class Dimension implements Cloneable, DimensionImmutable { @@ -48,7 +48,7 @@ public class Dimension implements Cloneable, DimensionImmutable { public Object cloneMutable() { return clone(); } - + public Object clone() { try { return super.clone(); @@ -92,7 +92,7 @@ public class Dimension implements Cloneable, DimensionImmutable { public int compareTo(final DimensionImmutable d) { final int tsq = width*height; final int xsq = d.getWidth()*d.getHeight(); - + if(tsq > xsq) { return 1; } else if(tsq < xsq) { @@ -100,13 +100,13 @@ public class Dimension implements Cloneable, DimensionImmutable { } return 0; } - + @Override public boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof Dimension) { Dimension p = (Dimension)obj; - return height == p.height && + return height == p.height && width == p.width ; } return false; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java index 22bd3f48b..9caa433a6 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java @@ -46,12 +46,12 @@ public interface DimensionImmutable extends WriteCloneable, Comparable * Compares square of size. - *

          + *

          * {@inheritDoc} */ @Override public int compareTo(final DimensionImmutable d); - + /** * Checks whether two dimensions objects are equal. Two instances * of DimensionReadOnly are equal if two components diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java index 942c12c2b..dbd997c60 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,18 +20,18 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package javax.media.nativewindow.util; public class Insets implements Cloneable, InsetsImmutable { static final InsetsImmutable zeroInsets = new Insets(); public static final InsetsImmutable getZero() { return zeroInsets; } - + int l, r, t, b; public Insets() { @@ -44,11 +44,11 @@ public class Insets implements Cloneable, InsetsImmutable { this.t=top; this.b=bottom; } - + public Object cloneMutable() { return clone(); } - + protected Object clone() { try { return super.clone(); @@ -77,7 +77,7 @@ public class Insets implements Cloneable, InsetsImmutable { public final void setRightWidth(int right) { r = right; } public final void setTopHeight(int top) { t = top; } public final void setBottomHeight(int bottom) { b = bottom; } - + @Override public boolean equals(Object obj) { if(this == obj) { return true; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java index 075641ede..0f99a7861 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java @@ -41,13 +41,13 @@ public interface InsetsImmutable extends WriteCloneable { /** @return total width, ie. left_width + right_width */ int getTotalWidth(); - + /** @return top inset height */ int getTopHeight(); /** @return bottom inset height */ int getBottomHeight(); - + /** @return total height, ie. top_height + bottom_height */ int getTotalHeight(); diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index 4c233bb16..aba515d52 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -45,7 +45,7 @@ public class Point implements Cloneable, PointImmutable { public Object cloneMutable() { return clone(); } - + public Object clone() { try { return super.clone(); @@ -58,7 +58,7 @@ public class Point implements Cloneable, PointImmutable { public int compareTo(final PointImmutable d) { final int sq = x*y; final int xsq = d.getX()*d.getY(); - + if(sq > xsq) { return 1; } else if(sq < xsq) { @@ -66,7 +66,7 @@ public class Point implements Cloneable, PointImmutable { } return 0; } - + @Override public boolean equals(Object obj) { if(this == obj) { return true; } @@ -120,5 +120,5 @@ public class Point implements Cloneable, PointImmutable { y *= sy ; return this; } - + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java index b00329bb5..f5377e059 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java @@ -41,12 +41,12 @@ public interface PointImmutable extends WriteCloneable, Comparable * Compares the square of the position. - *

          + *

          * {@inheritDoc} */ @Override public int compareTo(final PointImmutable d); - + /** * Checks whether two points objects are equal. Two instances * of PointReadOnly are equal if the two components @@ -57,5 +57,5 @@ public interface PointImmutable extends WriteCloneable, Comparable xsq) { return 1; } else if(sq < xsq) { @@ -160,7 +160,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { { final int sq = x*y; final int xsq = d.getX()*d.getY(); - + if(sq > xsq) { return 1; } else if(sq < xsq) { @@ -169,7 +169,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { } return 0; } - + @Override public boolean equals(Object obj) { if(this == obj) { return true; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java index 440d9e000..ce735f53f 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java @@ -49,7 +49,7 @@ public interface RectangleImmutable extends WriteCloneable, Comparable0.0 and 1.0. *

          * Coverage is computed by: @@ -57,19 +57,19 @@ public interface RectangleImmutable extends WriteCloneable, Comparable - *

          + *

          */ float coverage(RectangleImmutable r); - + /** *

          * Compares square of size 1st, if equal the square of position. - *

          + *

          * {@inheritDoc} */ @Override public int compareTo(final RectangleImmutable d); - + /** * Checks whether two rect objects are equal. Two instances * of Rectangle are equal if the four integer values diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java index 3084816a5..917f7e230 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java @@ -4,14 +4,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -21,15 +21,15 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package javax.media.nativewindow.util; -/** +/** * Immutable SurfaceSize Class, consisting of it's read only components:
          *
            *
          • {@link javax.media.nativewindow.util.DimensionImmutable} size in pixels
          • @@ -63,7 +63,7 @@ public class SurfaceSize implements Comparable { /** *

            * Compares {@link DimensionImmutable#compareTo(DimensionImmutable) resolution} 1st, if equal the bitsPerPixel. - *

            + *

            * {@inheritDoc} */ @Override @@ -72,7 +72,7 @@ public class SurfaceSize implements Comparable { if( 0 != rres ) { return rres; } - final int xbpp = ssz.getBitsPerPixel(); + final int xbpp = ssz.getBitsPerPixel(); if(bitsPerPixel > xbpp) { return 1; } else if(bitsPerPixel < xbpp) { @@ -80,7 +80,7 @@ public class SurfaceSize implements Comparable { } return 0; } - + /** * Checks whether two size objects are equal. Two instances * of SurfaceSize are equal if the two components diff --git a/src/nativewindow/classes/jogamp/nativewindow/Debug.java b/src/nativewindow/classes/jogamp/nativewindow/Debug.java index c5e316364..a7bf536ec 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/Debug.java +++ b/src/nativewindow/classes/jogamp/nativewindow/Debug.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -51,7 +51,7 @@ public class Debug extends PropertyAccess { // Some common properties private static final boolean verbose; private static final boolean debugAll; - + static { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { diff --git a/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java index 52e9c8308..b3b5d2131 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 diff --git a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java index c9f830811..5fdbbf697 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java @@ -36,20 +36,20 @@ import com.jogamp.common.util.locks.RecursiveLock; /** * Implementing a global recursive {@link javax.media.nativewindow.ToolkitLock}. *

            - * This is the last resort for unstable driver where multiple X11 display connections + * This is the last resort for unstable driver where multiple X11 display connections * to the same connection name are not treated thread safe within the GL/X11 driver. *

            */ public class GlobalToolkitLock implements ToolkitLock { private static final RecursiveLock globalLock = LockFactory.createRecursiveLock(); private static GlobalToolkitLock singleton = new GlobalToolkitLock(); - + public static final GlobalToolkitLock getSingleton() { return singleton; } - + private GlobalToolkitLock() { } - + @Override public final void lock() { globalLock.lock(); @@ -61,17 +61,17 @@ public class GlobalToolkitLock implements ToolkitLock { if(TRACE_LOCK) { System.err.println("GlobalToolkitLock.unlock()"); } globalLock.unlock(); // implicit lock validation } - + @Override public final void validateLocked() throws RuntimeException { globalLock.validateLocked(); } - + @Override public final void dispose() { // nop } - + public String toString() { return "GlobalToolkitLock[obj 0x"+Integer.toHexString(hashCode())+", isOwner "+globalLock.isOwner(Thread.currentThread())+", "+globalLock.toString()+"]"; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java index 1a106b1b9..36a25acfb 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.nativewindow; @@ -36,7 +36,7 @@ import com.jogamp.common.jvm.JNILibLoaderBase; import com.jogamp.common.os.Platform; import com.jogamp.common.util.cache.TempJarCache; -public class NWJNILibLoader extends JNILibLoaderBase { +public class NWJNILibLoader extends JNILibLoaderBase { public static boolean loadNativeWindow(final String ossuffix) { return AccessController.doPrivileged(new PrivilegedAction() { public Boolean run() { diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java index a3a66b7f1..e3f6ab5ca 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java @@ -1,21 +1,21 @@ /* * 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 @@ -48,7 +48,7 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { public static ToolkitLock getNullToolkitLock() { return nullToolkitLock; } - + // This subclass of NativeWindowFactory handles the case of // NativeWindows being passed in protected NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException { @@ -69,7 +69,7 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { winObj.getClass().getName() + " is unsupported; expected " + "javax.media.nativewindow.NativeWindow or "+AWTNames.ComponentClass); } - + private Constructor nativeWindowConstructor = null; private NativeWindow getAWTNativeWindow(Object winObj, AbstractGraphicsConfiguration config) { @@ -93,7 +93,7 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { } nativeWindowConstructor = ReflectionUtil.getConstructor( - windowClassName, new Class[] { Object.class, AbstractGraphicsConfiguration.class }, + windowClassName, new Class[] { Object.class, AbstractGraphicsConfiguration.class }, getClass().getClassLoader()); } catch (Exception e) { throw new IllegalArgumentException(e); diff --git a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java index 5fc5fe376..d8ce98acb 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java @@ -38,7 +38,7 @@ import javax.media.nativewindow.ToolkitLock; public class NullToolkitLock implements ToolkitLock { /** Singleton via {@link NativeWindowFactoryImpl#getNullToolkitLock()} */ protected NullToolkitLock() { } - + @Override public final void lock() { if(TRACE_LOCK) { @@ -51,21 +51,21 @@ public class NullToolkitLock implements ToolkitLock { public final void unlock() { if(TRACE_LOCK) { System.err.println("NullToolkitLock.unlock()"); } } - + @Override public final void validateLocked() throws RuntimeException { if( NativeWindowFactory.requiresToolkitLock() ) { throw new RuntimeException("NullToolkitLock does not lock, but locking is required."); } } - + @Override public final void dispose() { // nop } - + public String toString() { return "NullToolkitLock[]"; } - + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java index 56e342793..8a1048c6f 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java @@ -40,7 +40,7 @@ import javax.media.nativewindow.UpstreamSurfaceHook; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; -public abstract class ProxySurfaceImpl implements ProxySurface { +public abstract class ProxySurfaceImpl implements ProxySurface { private final SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); private AbstractGraphicsConfiguration config; // control access due to delegation private UpstreamSurfaceHook upstream; @@ -70,15 +70,15 @@ public abstract class ProxySurfaceImpl implements ProxySurface { this.upstreamSurfaceHookLifecycleEnabled = true; if(ownsDevice) { addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); - } + } } @Override public NativeSurface getUpstreamSurface() { return null; } - + @Override public final UpstreamSurfaceHook getUpstreamSurfaceHook() { return upstream; } - + @Override public void setUpstreamSurfaceHook(UpstreamSurfaceHook hook) { if(null == hook) { @@ -86,14 +86,14 @@ public abstract class ProxySurfaceImpl implements ProxySurface { } upstream = hook; } - + @Override public final void enableUpstreamSurfaceHookLifecycle(boolean enable) { upstreamSurfaceHookLifecycleEnabled = enable; } - + @Override - public void createNotify() { + public void createNotify() { if(upstreamSurfaceHookLifecycleEnabled) { upstream.create(this); } @@ -113,15 +113,15 @@ public abstract class ProxySurfaceImpl implements ProxySurface { } this.surfaceHandle_old = 0; } - - /** + + /** * Must be overridden by implementations allowing having a {@link UpstreamSurfaceHook} being passed. - * @see #destroyNotify() + * @see #destroyNotify() */ protected void invalidateImpl() { - throw new InternalError("UpstreamSurfaceHook given, but required method not implemented."); + throw new InternalError("UpstreamSurfaceHook given, but required method not implemented."); } - + protected final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() { return config; } @@ -140,7 +140,7 @@ public abstract class ProxySurfaceImpl implements ProxySurface { public final void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg) { config = cfg; } - + @Override public final int getScreenIndex() { return getGraphicsConfiguration().getScreen().getIndex(); @@ -151,7 +151,7 @@ public abstract class ProxySurfaceImpl implements ProxySurface { @Override public abstract void setSurfaceHandle(long surfaceHandle); - + @Override public final int getWidth() { return upstream.getWidth(this); @@ -252,7 +252,7 @@ public abstract class ProxySurfaceImpl implements ProxySurface { public final Thread getSurfaceLockOwner() { return surfaceLock.getOwner(); } - + public final StringBuilder getUpstreamOptionBits(StringBuilder sink) { if(null == sink) { sink = new StringBuilder(); @@ -284,21 +284,21 @@ public abstract class ProxySurfaceImpl implements ProxySurface { sink.append(" ]"); return sink; } - + @Override public final int getUpstreamOptionBits() { return implBitfield; } - + @Override public final boolean containsUpstreamOptionBits(int v) { return v == ( implBitfield & v ) ; } - + @Override public final void addUpstreamOptionBits(int v) { implBitfield |= v; } - + @Override public final void clearUpstreamOptionBits(int v) { implBitfield &= ~v; } - + @Override public StringBuilder toString(StringBuilder sink) { if(null == sink) { @@ -315,7 +315,7 @@ public abstract class ProxySurfaceImpl implements ProxySurface { // append("\n, upstreamSurface "+getUpstreamSurface()); return sink; } - + @Override public String toString() { StringBuilder msg = new StringBuilder(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java index 5b79de0b8..51dd58543 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java @@ -50,7 +50,7 @@ public class ResourceToolkitLock implements ToolkitLock { private ResourceToolkitLock() { this.lock = LockFactory.createRecursiveLock(); } - + @Override public final void lock() { lock.lock(); @@ -62,17 +62,17 @@ public class ResourceToolkitLock implements ToolkitLock { if(TRACE_LOCK) { System.err.println("ResourceToolkitLock.unlock()"); } lock.unlock(); // implicit lock validation } - + @Override public final void validateLocked() throws RuntimeException { lock.validateLocked(); } - + @Override public final void dispose() { // nop } - + public String toString() { return "ResourceToolkitLock[obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString()+"]"; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java index 94d12e6fc..e20d3d138 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java @@ -54,8 +54,8 @@ public class SharedResourceToolkitLock implements ToolkitLock { handle2Lock = new LongObjectHashMap(); handle2Lock.setKeyNotFoundValue(null); } - - /** + + /** * @return number of unclosed EGL Displays.
            */ public static int shutdown(boolean verbose) { @@ -70,7 +70,7 @@ public class SharedResourceToolkitLock implements ToolkitLock { } return handle2Lock.size(); } - + public static void dumpOpenDisplayConnections() { System.err.println("SharedResourceToolkitLock: Open ResourceToolkitLock's: "+handle2Lock.size()); int i=0; @@ -79,7 +79,7 @@ public class SharedResourceToolkitLock implements ToolkitLock { System.err.println("SharedResourceToolkitLock: Open["+i+"]: "+e.value); } } - + public static final SharedResourceToolkitLock get(long handle) { SharedResourceToolkitLock res; synchronized(handle2Lock) { @@ -106,8 +106,8 @@ public class SharedResourceToolkitLock implements ToolkitLock { this.handle = handle; this.refCount = 0; } - - + + @Override public final void lock() { lock.lock(); @@ -119,12 +119,12 @@ public class SharedResourceToolkitLock implements ToolkitLock { if(TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.unlock()"); } lock.unlock(); } - + @Override public final void validateLocked() throws RuntimeException { lock.validateLocked(); } - + @Override public final void dispose() { if(0 < refCount) { // volatile OK @@ -141,7 +141,7 @@ public class SharedResourceToolkitLock implements ToolkitLock { if(DEBUG || TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.dispose() * NULL *: "+this); } } } - + public String toString() { return "SharedResourceToolkitLock[refCount "+refCount+", handle 0x"+Long.toHexString(handle)+", obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString()+"]"; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java index 4f68c6945..d11e240fa 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -39,27 +39,27 @@ public class SurfaceUpdatedHelper implements SurfaceUpdatedListener { // // Management Utils - // + // public int size() { return surfaceUpdatedListeners.size(); } public SurfaceUpdatedListener get(int i) { return surfaceUpdatedListeners.get(i); } - + // // Implementation of NativeSurface SurfaceUpdatedListener methods - // - + // + public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { addSurfaceUpdatedListener(-1, l); } - public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) + public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { if(l == null) { return; } synchronized(surfaceUpdatedListenersLock) { - if(0>index) { - index = surfaceUpdatedListeners.size(); + if(0>index) { + index = surfaceUpdatedListeners.size(); } surfaceUpdatedListeners.add(index, l); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java b/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java index ed23def8f..47b3e63fa 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java @@ -8,14 +8,14 @@ import javax.media.nativewindow.NativeWindowFactory; * Implementation requires to provide static methods: *
                 public static void initSingleton() {}
            -    
            +
                 public static void shutdown() {}
            -    
            +
                 public static boolean requiresToolkitLock() {}
            -    
            +
                 public static boolean hasThreadingIssues() {}
              * 
            - * Above static methods are invoked by {@link NativeWindowFactory#initSingleton()}, + * Above static methods are invoked by {@link NativeWindowFactory#initSingleton()}, * or {@link NativeWindowFactory#shutdown()} via reflection. *

            */ @@ -25,23 +25,23 @@ public interface ToolkitProperties { * Called by {@link NativeWindowFactory#initSingleton()} */ // void initSingleton(); - - /** + + /** * Cleanup resources. *

            * Called by {@link NativeWindowFactory#shutdown()} *

            */ // void shutdown(); - + /** * Called by {@link NativeWindowFactory#initSingleton()} */ // boolean requiresToolkitLock(); - + /** * Called by {@link NativeWindowFactory#initSingleton()} */ - // boolean hasThreadingIssues(); - + // boolean hasThreadingIssues(); + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java index c94f249a1..f622db8cc 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java @@ -37,7 +37,7 @@ import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; /** * Generic Surface implementation which wraps an existing window handle. - * + * * @see ProxySurface */ public class WrappedSurface extends ProxySurfaceImpl { @@ -46,7 +46,7 @@ public class WrappedSurface extends ProxySurfaceImpl { /** * Utilizes a {@link UpstreamSurfaceHook.MutableSize} to hold the size information, * which is being passed to the {@link ProxySurface} instance. - * + * * @param cfg the {@link AbstractGraphicsConfiguration} to be used * @param handle the wrapped pre-existing native surface handle, maybe 0 if not yet determined * @param initialWidth @@ -59,7 +59,7 @@ public class WrappedSurface extends ProxySurfaceImpl { super(cfg, new UpstreamSurfaceHookMutableSize(initialWidth, initialHeight), ownsDevice); surfaceHandle=handle; } - + /** * @param cfg the {@link AbstractGraphicsConfiguration} to be used * @param handle the wrapped pre-existing native surface handle, maybe 0 if not yet determined @@ -74,7 +74,7 @@ public class WrappedSurface extends ProxySurfaceImpl { } @Override - protected void invalidateImpl() { + protected void invalidateImpl() { surfaceHandle = 0; } @@ -87,7 +87,7 @@ public class WrappedSurface extends ProxySurfaceImpl { public final void setSurfaceHandle(long surfaceHandle) { this.surfaceHandle=surfaceHandle; } - + @Override protected final int lockSurfaceImpl() { return LOCK_SUCCESS; diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index 23c48d20e..0fa5006cc 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -71,19 +71,19 @@ public class AWTMisc { } return (Container) c; } - + /** * Return insets of the component w/o traversing up to parent, * i.e. trying Window and JComponent. *

            - * Exception is JRootPane. + * Exception is JRootPane. * Return it's parent's Window component's insets if available, * otherwise return JRootPane's insets.
            - * This is due to experience that some JRootPane's + * This is due to experience that some JRootPane's * do not expose valid insets value. *

            * @param topLevelOnly if true only returns insets of top-level components, i.e. Window and JRootPanel, - * otherwise for JComponent as well. + * otherwise for JComponent as well. */ public static Insets getInsets(Component c, boolean topLevelOnly) { if( c instanceof Window ) { @@ -108,7 +108,7 @@ public class AWTMisc { */ public void run(Component c); } - + public static int performAction(Container c, Class cType, ComponentAction action) { int count = 0; final int cc = c.getComponentCount(); @@ -128,18 +128,18 @@ public class AWTMisc { } return count; } - + /** * Traverse to the next forward or backward component using the * container's FocusTraversalPolicy. - * - * @param comp the assumed current focuse component + * + * @param comp the assumed current focuse component * @param forward if true, returns the next focus component, otherwise the previous one. * @return */ public static Component getNextFocus(Component comp, boolean forward) { Container focusContainer = comp.getFocusCycleRootAncestor(); - while ( focusContainer != null && + while ( focusContainer != null && ( !focusContainer.isShowing() || !focusContainer.isFocusable() || !focusContainer.isEnabled() ) ) { comp = focusContainer; @@ -155,7 +155,7 @@ public class AWTMisc { } return next; } - + /** * Issue this when your non AWT toolkit gains focus to clear AWT menu path */ diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java index f579da217..815facbee 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -47,7 +47,7 @@ import java.awt.Toolkit; import java.security.AccessController; import java.security.PrivilegedAction; -public class JAWTJNILibLoader extends NWJNILibLoader { +public class JAWTJNILibLoader extends NWJNILibLoader { static { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -55,7 +55,7 @@ public class JAWTJNILibLoader extends NWJNILibLoader { // a Dialog with "awt.dll not found" might pop up. // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4481947. Toolkit.getDefaultToolkit(); - + // Must pre-load JAWT on all non-Mac platforms to // ensure references from jogl_awt shared object // will succeed since JAWT shared object isn't in @@ -74,9 +74,9 @@ public class JAWTJNILibLoader extends NWJNILibLoader { } }); } - + public static void initSingleton() { - // just exist to ensure static init has been run + // just exist to ensure static init has been run } - + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index 844b17469..32946fe2d 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -63,13 +63,13 @@ public class JAWTUtil { /** OSX JAWT version option to use CALayer */ public static final int JAWT_MACOSX_USE_CALAYER = 0x80000000; - + /** OSX JAWT CALayer availability on Mac OS X >= 10.6 Update 4 (recommended) */ public static final VersionNumber JAWT_MacOSXCALayerMinVersion = new VersionNumber(10,6,4); - + /** OSX JAWT CALayer required with Java >= 1.7.0 (implies OS X >= 10.7 */ public static final VersionNumber JAWT_MacOSXCALayerRequiredForJavaVersion = Platform.Version17; - + // See whether we're running in headless mode private static final boolean headlessMode; private static final JAWT jawtLockObject; @@ -81,27 +81,27 @@ public class JAWTUtil { private static final Method sunToolkitAWTLockMethod; private static final Method sunToolkitAWTUnlockMethod; private static final boolean hasSunToolkitAWTLock; - + private static final RecursiveLock jawtLock; private static final ToolkitLock jawtToolkitLock; private static class PrivilegedDataBlob1 { PrivilegedDataBlob1() { ok = false; - } + } Method sunToolkitAWTLockMethod; Method sunToolkitAWTUnlockMethod; boolean ok; } - + /** * Returns true if this platform's JAWT implementation supports offscreen layer. */ public static boolean isOffscreenLayerSupported() { return Platform.OS_TYPE == Platform.OSType.MACOS && - Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0; + Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0; } - + /** * Returns true if this platform's JAWT implementation requires using offscreen layer. */ @@ -109,8 +109,8 @@ public class JAWTUtil { return Platform.OS_TYPE == Platform.OSType.MACOS && Platform.JAVA_VERSION_NUMBER.compareTo(JAWT_MacOSXCALayerRequiredForJavaVersion)>=0; } - - /** + + /** * CALayer size needs to be set using the AWT component size. *

            * AWT's super-calayer, i.e. the AWT's own component CALayer, @@ -120,13 +120,13 @@ public class JAWTUtil { *

            * As of today, this flag is enabled for all known AWT versions. *

            - *

            + *

            * Sync w/ NativeWindowProtocols.h - *

            + *

            */ public static final int JAWT_OSX_CALAYER_QUIRK_SIZE = 1 << 0; - - /** + + /** * CALayer position needs to be set to zero. *

            * AWT's super-calayer, i.e. the AWT's own component CALayer, @@ -137,19 +137,19 @@ public class JAWTUtil { *

            *

            * Further more a re-layout seems to be required in this case, - * i.e. a programmatic forced resize +1 and it's inverted resize -1. + * i.e. a programmatic forced resize +1 and it's inverted resize -1. *

            *

            - * This flag is enabled w/ AWT < 1.7.0_40. + * This flag is enabled w/ AWT < 1.7.0_40. *

            - *

            + *

            * Sync w/ NativeWindowProtocols.h - *

            + *

            */ public static final int JAWT_OSX_CALAYER_QUIRK_POSITION = 1 << 1; - - /** - * CALayer position needs to be derived from AWT position + + /** + * CALayer position needs to be derived from AWT position * in relation to super CALayer. *

            * AWT's super-calayer, i.e. the AWT top-container's CALayer, @@ -165,7 +165,7 @@ public class JAWTUtil { *

            *

            * The super-calayer lies within the AWT top-container client space (content). - *

            + *

            *

            * Component's location in super-calayer: *

            @@ -188,12 +188,12 @@ public class JAWTUtil {
                * 

            * As of today, this flag is enabled for w/ AWT >= 1.7.0_40. *

            - *

            + *

            * Sync w/ NativeWindowProtocols.h - *

            + *

            */ public static final int JAWT_OSX_CALAYER_QUIRK_LAYOUT = 1 << 2; - + /** * Returns bitfield of required JAWT OSX CALayer quirks to mediate AWT impl. bugs. *

            @@ -211,12 +211,12 @@ public class JAWTUtil { */ public static int getOSXCALayerQuirks() { int res = 0; - if( Platform.OS_TYPE == Platform.OSType.MACOS && + if( Platform.OS_TYPE == Platform.OSType.MACOS && Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0 ) { - + /** Knowing impl. all expose the SIZE bug */ res |= JAWT_OSX_CALAYER_QUIRK_SIZE; - + final int c = Platform.JAVA_VERSION_NUMBER.compareTo(Platform.Version17); if( c < 0 || c == 0 && Platform.JAVA_VERSION_UPDATE < 40 ) { res |= JAWT_OSX_CALAYER_QUIRK_POSITION; @@ -226,20 +226,20 @@ public class JAWTUtil { } return res; } - + /** * @param useOffscreenLayerIfAvailable * @return */ public static JAWT getJAWT(boolean useOffscreenLayerIfAvailable) { - final int jawt_version_flags = JAWTFactory.JAWT_VERSION_1_4; + final int jawt_version_flags = JAWTFactory.JAWT_VERSION_1_4; JAWT jawt = JAWT.create(); - + // default queries boolean tryOffscreenLayer; boolean tryOnscreen; int jawt_version_flags_offscreen = jawt_version_flags; - + if(isOffscreenLayerRequired()) { if(Platform.OS_TYPE == Platform.OSType.MACOS) { if(Platform.OS_VERSION_NUMBER.compareTo(JAWTUtil.JAWT_MacOSXCALayerMinVersion) >= 0) { @@ -263,11 +263,11 @@ public class JAWTUtil { } else { tryOffscreenLayer = false; tryOnscreen = true; - } + } if(DEBUG) { System.err.println("JAWTUtil.getJAWT(tryOffscreenLayer "+tryOffscreenLayer+", tryOnscreen "+tryOnscreen+")"); } - + StringBuilder errsb = new StringBuilder(); if(tryOffscreenLayer) { errsb.append("Offscreen 0x").append(Integer.toHexString(jawt_version_flags_offscreen)); @@ -282,15 +282,15 @@ public class JAWTUtil { errsb.append("Onscreen 0x").append(Integer.toHexString(jawt_version_flags)); if( JAWT.getJAWT(jawt, jawt_version_flags) ) { return jawt; - } + } } throw new RuntimeException("Unable to initialize JAWT, trials: "+errsb.toString()); } - + public static boolean isJAWTUsingOffscreenLayer(JAWT jawt) { return 0 != ( jawt.getCachedVersion() & JAWTUtil.JAWT_MACOSX_USE_CALAYER ); } - + static { if(DEBUG) { System.err.println("JAWTUtil initialization (JAWT/JNI/..."); @@ -319,10 +319,10 @@ public class JAWTUtil { isQueueFlusherThread = m; j2dExist = ok; - PrivilegedDataBlob1 pdb1 = (PrivilegedDataBlob1) AccessController.doPrivileged(new PrivilegedAction() { + PrivilegedDataBlob1 pdb1 = (PrivilegedDataBlob1) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { PrivilegedDataBlob1 d = new PrivilegedDataBlob1(); - try { + try { final Class sunToolkitClass = Class.forName("sun.awt.SunToolkit"); d.sunToolkitAWTLockMethod = sunToolkitClass.getDeclaredMethod("awtLock", new Class[]{}); d.sunToolkitAWTLockMethod.setAccessible(true); @@ -337,7 +337,7 @@ public class JAWTUtil { }); sunToolkitAWTLockMethod = pdb1.sunToolkitAWTLockMethod; sunToolkitAWTUnlockMethod = pdb1.sunToolkitAWTUnlockMethod; - + boolean _hasSunToolkitAWTLock = false; if ( pdb1.ok ) { try { @@ -351,10 +351,10 @@ public class JAWTUtil { // hasSunToolkitAWTLock = false; jawtLock = LockFactory.createRecursiveLock(); - jawtToolkitLock = new ToolkitLock() { + jawtToolkitLock = new ToolkitLock() { public final void lock() { JAWTUtil.lockToolkit(); - } + } public final void unlock() { JAWTUtil.unlockToolkit(); } @@ -411,11 +411,11 @@ public class JAWTUtil { public static void initSingleton() { // just exist to ensure static init has been run } - + /** * Called by {@link NativeWindowFactory#shutdown()} */ - public static void shutdown() { + public static void shutdown() { } public static boolean hasJava2D() { @@ -443,7 +443,7 @@ public class JAWTUtil { * which just uses AWT's global ReentrantLock. *

            *

            - * AWT locking is wrapped through a recursive lock object. + * AWT locking is wrapped through a recursive lock object. *

            */ public static void lockToolkit() throws NativeWindowException { @@ -471,11 +471,11 @@ public class JAWTUtil { * which just uses AWT's global ReentrantLock. *

            *

            - * AWT unlocking is wrapped through a recursive lock object. + * AWT unlocking is wrapped through a recursive lock object. *

            */ public static void unlockToolkit() { - jawtLock.validateLocked(); + jawtLock.validateLocked(); if(ToolkitLock.TRACE_LOCK) { System.err.println("JAWTUtil-ToolkitLock.unlock(): "+jawtLock); } if( 1 == jawtLock.getHoldCount() ) { if(!headlessMode && !isJava2DQueueFlusherThread()) { @@ -492,14 +492,14 @@ public class JAWTUtil { } jawtLock.unlock(); } - + public static final void validateLocked() throws RuntimeException { jawtLock.validateLocked(); - } + } public static ToolkitLock getJAWTToolkitLock() { return jawtToolkitLock; } - + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWT_PlatformInfo.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWT_PlatformInfo.java index 40d7b8032..4f12d1925 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWT_PlatformInfo.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWT_PlatformInfo.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index b712f6a1a..87e3d3dd8 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -102,7 +102,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } windowHandle=0; } - + @Override protected void attachSurfaceLayerImpl(final long layerHandle) { OSXUtil.RunOnMainThread(false, new Runnable() { @@ -119,7 +119,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if( null != outterInsets ) { p1.translate(-outterInsets.left, -outterInsets.top); } - + if( DEBUG ) { final java.awt.Point pA0 = component.getLocationOnScreen(); final Point pA1 = new Point(pA0.x, pA0.y); @@ -133,7 +133,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, p1.getX(), p1.getY(), getWidth(), getHeight(), JAWTUtil.getOSXCALayerQuirks()); } } ); } - + @Override protected void layoutSurfaceLayerImpl(long layerHandle, boolean visible) { final int caLayerQuirks = JAWTUtil.getOSXCALayerQuirks(); @@ -149,7 +149,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if( null != outterInsets ) { p1.translate(-outterInsets.left, -outterInsets.top); } - + if( DEBUG ) { final java.awt.Point pA0 = component.getLocationOnScreen(); final Point pA1 = new Point(pA0.x, pA0.y); @@ -163,7 +163,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, visible, p1.getX(), p1.getY(), getWidth(), getHeight(), caLayerQuirks); } - + @Override protected void detachSurfaceLayerImpl(final long layerHandle, final Runnable detachNotify) { OSXUtil.RunOnMainThread(false, new Runnable() { @@ -172,17 +172,17 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.RemoveCASublayer(rootSurfaceLayer, layerHandle); } } ); } - + @Override public final long getWindowHandle() { return windowHandle; } - + @Override public final long getSurfaceHandle() { return offscreenSurfaceDrawableSet ? offscreenSurfaceDrawable : drawable /* super.getSurfaceHandle() */ ; } - + public void setSurfaceHandle(long surfaceHandle) { if( !isOffscreenLayerSurfaceEnabled() ) { throw new java.lang.UnsupportedOperationException("Not using CALAYER"); @@ -198,7 +198,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { // use offscreen if supported and [ applet or requested ] return JAWTUtil.getJAWT(getShallUseOffscreenLayer() || isApplet()); } - + protected int lockSurfaceImpl() throws NativeWindowException { int ret = NativeWindow.LOCK_SURFACE_NOT_READY; ds = getJAWT().GetDrawingSurface(component); @@ -247,7 +247,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { return NativeWindow.LOCK_SURFACE_NOT_READY; } drawable = macosxdsi.getCocoaViewRef(); - + if (drawable == 0) { unlockSurfaceImpl(); return NativeWindow.LOCK_SURFACE_NOT_READY; @@ -259,9 +259,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { /** * Only create a fake invisible NSWindow for the drawable handle * to please frameworks requiring such (eg. NEWT). - * - * The actual surface/ca-layer shall be created/attached - * by the upper framework (JOGL) since they require more information. + * + * The actual surface/ca-layer shall be created/attached + * by the upper framework (JOGL) since they require more information. */ String errMsg = null; if(0 == drawable) { @@ -286,10 +286,10 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { String errMsg = null; - if(0 == rootSurfaceLayer && 0 != jawtSurfaceLayersHandle) { + if(0 == rootSurfaceLayer && 0 != jawtSurfaceLayersHandle) { rootSurfaceLayer = OSXUtil.CreateCALayer(bounds.getWidth(), bounds.getHeight()); if(0 == rootSurfaceLayer) { - errMsg = "Could not create root CALayer"; + errMsg = "Could not create root CALayer"; } else { try { SetJAWTRootSurfaceLayer0(jawtSurfaceLayersHandle, rootSurfaceLayer); @@ -318,10 +318,10 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } ret = NativeWindow.LOCK_SUCCESS; } - + return ret; } - + protected void unlockSurfaceImpl() throws NativeWindowException { if(null!=ds) { if (null!=dsi) { @@ -340,7 +340,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { System.err.println("MaxOSXJAWTWindow: 0x"+Integer.toHexString(this.hashCode())+" - thread: "+Thread.currentThread().getName()); dumpJAWTInfo(); } - + /** * {@inheritDoc} *

            @@ -350,9 +350,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { * .. * ds = getJAWT().GetDrawingSurface(component); * due to a SIGSEGV. - * + * * Hence we have some threading / sync issues with the native JAWT implementation. - *

            + *

            */ @Override public Point getLocationOnScreen(Point storage) { @@ -361,36 +361,36 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } getLocationOnScreenNonBlocking(storage, component); return storage; - } + } protected Point getLocationOnScreenNativeImpl(final int x0, final int y0) { return null; } - - + + private static native long GetJAWTSurfaceLayersHandle0(Buffer jawtDrawingSurfaceInfoBuffer); - - /** + + /** * Set the given root CALayer in the JAWT surface - */ + */ private static native void SetJAWTRootSurfaceLayer0(long jawtSurfaceLayersHandle, long caLayer); - - /** + + /** * Unset the given root CALayer in the JAWT surface, passing the NIO DrawingSurfaceInfo buffer - */ + */ private static native void UnsetJAWTRootSurfaceLayer0(long jawtSurfaceLayersHandle, long caLayer); - + // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; private boolean dsLocked; private JAWT_DrawingSurfaceInfo dsi; private long jawtSurfaceLayersHandle; - + private JAWT_MacOSXDrawingSurfaceInfo macosxdsi; - + private volatile long rootSurfaceLayer = 0; // attached to the JAWT_SurfaceLayer - + private long windowHandle = 0; private long offscreenSurfaceDrawable = 0; private boolean offscreenSurfaceDrawableSet = false; - + // Workaround for instance of 4796548 private boolean firstLock = true; diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java index 74dabb67f..876531151 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java index 905a313d5..64e177155 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -67,7 +67,7 @@ public class WindowsJAWTWindow extends JAWTWindow { protected JAWT fetchJAWTImpl() throws NativeWindowException { return JAWTUtil.getJAWT(false); // no offscreen } - + protected int lockSurfaceImpl() throws NativeWindowException { int ret = NativeWindow.LOCK_SUCCESS; ds = getJAWT().GetDrawingSurface(component); diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java index 2e5dc7fb5..b08a7d83a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -62,7 +62,7 @@ public class X11JAWTWindow extends JAWTWindow { protected JAWT fetchJAWTImpl() throws NativeWindowException { return JAWTUtil.getJAWT(false); // no offscreen } - + protected int lockSurfaceImpl() throws NativeWindowException { int ret = NativeWindow.LOCK_SUCCESS; ds = getJAWT().GetDrawingSurface(component); @@ -123,11 +123,11 @@ public class X11JAWTWindow extends JAWTWindow { // surface is locked and hence the device return X11Lib.GetRelativeLocation(getDisplayHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); } - + // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; private boolean dsLocked; private JAWT_DrawingSurfaceInfo dsi; private JAWT_X11DrawingSurfaceInfo x11dsi; - + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java index 27e0a5e50..f1104d02f 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java index de3206c0c..b71af1042 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java @@ -9,12 +9,12 @@ import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; public class OSXDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { long nsWindow; - + /** - * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, - * not the actual dummy surface width. + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, * not the actual dummy surface height, * The latter is platform specific and small */ @@ -22,7 +22,7 @@ public class OSXDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize super(width, height); nsWindow = 0; } - + @Override public final void create(ProxySurface s) { if(0 == nsWindow && 0 == s.getSurfaceHandle()) { @@ -35,11 +35,11 @@ public class OSXDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize throw new NativeWindowException("Error NS view 0"); } s.setSurfaceHandle(nsView); - s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); } - + @Override public final void destroy(ProxySurface s) { if( s.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 0d498fa54..004a91a42 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -41,9 +41,9 @@ import jogamp.nativewindow.NWJNILibLoader; import jogamp.nativewindow.ToolkitProperties; public class OSXUtil implements ToolkitProperties { - private static boolean isInit = false; + private static boolean isInit = false; private static final boolean DEBUG = Debug.debug("OSXUtil"); - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties @@ -56,10 +56,10 @@ public class OSXUtil implements ToolkitProperties { if(!NWJNILibLoader.loadNativeWindow("macosx")) { throw new NativeWindowException("NativeWindow MacOSX native library load error."); } - + if( !initIDs0() ) { throw new NativeWindowException("MacOSX: Could not initialized native stub"); - } + } isInit = true; } } @@ -69,27 +69,27 @@ public class OSXUtil implements ToolkitProperties { * @see ToolkitProperties */ public static void shutdown() { } - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ public static boolean requiresToolkitLock() { return false; } - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ public static final boolean hasThreadingIssues() { return false; } - + public static boolean isNSView(long object) { return 0 != object ? isNSView0(object) : false; } - + public static boolean isNSWindow(long object) { return 0 != object ? isNSWindow0(object) : false; } - + /** * In case the windowOrView is top-level, * you shall set topLevel to true where @@ -108,7 +108,7 @@ public class OSXUtil implements ToolkitProperties { * @param src_y * @return the client position */ - public static Point GetLocationOnScreen(long windowOrView, boolean topLevel, int src_x, int src_y) { + public static Point GetLocationOnScreen(long windowOrView, boolean topLevel, int src_x, int src_y) { final Point los = (Point) GetLocationOnScreen0(windowOrView, src_x, src_y); if(topLevel) { // top-level position -> client window position @@ -117,11 +117,11 @@ public class OSXUtil implements ToolkitProperties { } return los; } - + public static Insets GetInsets(long windowOrView) { return (Insets) GetInsets0(windowOrView); } - + public static long CreateNSWindow(int x, int y, int width, int height) { return CreateNSWindow0(x, y, width, height); } @@ -134,11 +134,11 @@ public class OSXUtil implements ToolkitProperties { public static long GetNSWindow(long nsView) { return GetNSWindow0(nsView); } - - /** + + /** * Create a CALayer suitable to act as a root CALayer. * @see #DestroyCALayer(long) - * @see #AddCASublayer(long, long) + * @see #AddCASublayer(long, long) */ public static long CreateCALayer(final int width, final int height) { final long l = CreateCALayer0(width, height); @@ -147,8 +147,8 @@ public class OSXUtil implements ToolkitProperties { } return l; } - - /** + + /** * Attach a sub CALayer to the root CALayer *

            * Method will trigger a display @@ -156,7 +156,7 @@ public class OSXUtil implements ToolkitProperties { *

            *

            * Hence it is important that related resources are not locked if - * they will be used for creation. + * they will be used for creation. *

            * @param caLayerQuirks TODO * @see #CreateCALayer(int, int) @@ -171,18 +171,18 @@ public class OSXUtil implements ToolkitProperties { } AddCASublayer0(rootCALayer, subCALayer, x, y, width, height, caLayerQuirks); } - - /** + + /** * Fix root and sub CALayer position to 0/0 and size *

            * If the sub CALayer implements the Objective-C NativeWindow protocol NWDedicatedSize (e.g. JOGL's MyNSOpenGLLayer), - * the dedicated size is passed to the layer, which propagates it appropriately. + * the dedicated size is passed to the layer, which propagates it appropriately. *

            *

            * On OSX/Java7 our root CALayer's frame position and size gets corrupted by its NSView, * hence we have created the NWDedicatedSize protocol. *

            - * + * * @param rootCALayer the root surface layer, maybe null. * @param subCALayer the client surface layer, maybe null. * @param visible TODO @@ -196,8 +196,8 @@ public class OSXUtil implements ToolkitProperties { } FixCALayerLayout0(rootCALayer, subCALayer, visible, x, y, width, height, caLayerQuirks); } - - /** + + /** * Detach a sub CALayer from the root CALayer. */ public static void RemoveCASublayer(final long rootCALayer, final long subCALayer) { @@ -209,11 +209,11 @@ public class OSXUtil implements ToolkitProperties { } RemoveCASublayer0(rootCALayer, subCALayer); } - - /** + + /** * Destroy a CALayer. * @see #CreateCALayer(int, int) - */ + */ public static void DestroyCALayer(final long caLayer) { if(0==caLayer) { throw new IllegalArgumentException("caLayer 0x"+Long.toHexString(caLayer)); @@ -223,13 +223,13 @@ public class OSXUtil implements ToolkitProperties { } DestroyCALayer0(caLayer); } - + /** * Run on OSX UI main thread. - *

            + *

            * 'waitUntilDone' is implemented on Java site via lock/wait on {@link RunnableTask} to not freeze OSX main thread. *

            - * + * * @param waitUntilDone * @param runnable */ @@ -238,10 +238,10 @@ public class OSXUtil implements ToolkitProperties { runnable.run(); // don't leave the JVM } else { // Utilize Java side lock/wait and simply pass the Runnable async to OSX main thread, - // otherwise we may freeze the OSX main thread. + // otherwise we may freeze the OSX main thread. Throwable throwable = null; final Object sync = new Object(); - final RunnableTask rt = new RunnableTask( runnable, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); + final RunnableTask rt = new RunnableTask( runnable, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); synchronized(sync) { RunOnMainThread0(rt); if( waitUntilDone ) { @@ -260,7 +260,7 @@ public class OSXUtil implements ToolkitProperties { } } } - + /** * Run later on .. * @param onMain if true, run on main-thread, otherwise on the current OSX thread. @@ -270,20 +270,20 @@ public class OSXUtil implements ToolkitProperties { public static void RunLater(boolean onMain, Runnable runnable, int delay) { RunLater0(onMain, new RunnableTask( runnable, null, true, System.err ), delay); } - + private static Runnable _nop = new Runnable() { public void run() {}; }; - - /** Issues a {@link #RunOnMainThread(boolean, Runnable)} w/ an NOP runnable, while waiting until done. */ + + /** Issues a {@link #RunOnMainThread(boolean, Runnable)} w/ an NOP runnable, while waiting until done. */ public static void WaitUntilFinish() { RunOnMainThread(true, _nop); } - + /** * Run on OSX UI main thread. - *

            + *

            * 'waitUntilDone' is implemented on Java site via lock/wait on {@link FunctionTask} to not freeze OSX main thread. *

            - * + * * @param waitUntilDone * @param func */ @@ -292,10 +292,10 @@ public class OSXUtil implements ToolkitProperties { return func.eval(args); // don't leave the JVM } else { // Utilize Java side lock/wait and simply pass the Runnable async to OSX main thread, - // otherwise we may freeze the OSX main thread. + // otherwise we may freeze the OSX main thread. Throwable throwable = null; final Object sync = new Object(); - final FunctionTask rt = new FunctionTask( func, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); + final FunctionTask rt = new FunctionTask( func, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); synchronized(sync) { rt.setArgs(args); RunOnMainThread0(rt); @@ -316,20 +316,20 @@ public class OSXUtil implements ToolkitProperties { return rt.getResult(); } } - + public static boolean IsMainThread() { return IsMainThread0(); } - + /** Returns the screen refresh rate in Hz. If unavailable, returns 60Hz. */ public static int GetScreenRefreshRate(int scrn_idx) { return GetScreenRefreshRate0(scrn_idx); } - + /*** private static boolean isAWTEDTMainThreadInit = false; private static boolean isAWTEDTMainThread; - + public synchronized static boolean isAWTEDTMainThread() { if(!isAWTEDTMainThreadInit) { isAWTEDTMainThreadInit = true; @@ -343,10 +343,10 @@ public class OSXUtil implements ToolkitProperties { } else { isAWTEDTMainThread = false; } - } + } return isAWTEDTMainThread; } */ - + private static native boolean initIDs0(); private static native boolean isNSView0(long object); private static native boolean isNSWindow0(long object); diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java index aa5f3dac5..e5de43c0a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java @@ -9,31 +9,31 @@ import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; public class GDIDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { /** - * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, - * not the actual dummy surface width. + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, * not the actual dummy surface height, * The latter is platform specific and small */ public GDIDummyUpstreamSurfaceHook(int width, int height) { super(width, height); } - + @Override public final void create(ProxySurface s) { final GDISurface ms = (GDISurface)s; - if(0 == ms.getWindowHandle()) { + if(0 == ms.getWindowHandle()) { final long windowHandle = GDIUtil.CreateDummyWindow(0, 0, 64, 64); if(0 == windowHandle) { throw new NativeWindowException("Error windowHandle 0, werr: "+GDI.GetLastError()); - } + } ms.setWindowHandle(windowHandle); - ms.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + ms.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); } - + @Override public final void destroy(ProxySurface s) { final GDISurface ms = (GDISurface)s; @@ -46,5 +46,5 @@ public class GDIDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize ms.setWindowHandle(0); ms.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } - } + } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java index cc9c9853b..3e07b2a9e 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java @@ -43,7 +43,7 @@ import jogamp.nativewindow.windows.GDI; * allowing the use of HDC via lockSurface()/unlockSurface() protocol. * The latter will get and release the HDC. * The size via getWidth()/getHeight() is invalid. - * + * * @see ProxySurface */ public class GDISurface extends ProxySurfaceImpl { @@ -65,20 +65,20 @@ public class GDISurface extends ProxySurfaceImpl { } @Override - protected void invalidateImpl() { + protected void invalidateImpl() { if(0 != surfaceHandle) { throw new NativeWindowException("didn't release surface Handle: "+this); } windowHandle = 0; // surfaceHandle = 0; } - + /** * {@inheritDoc} *

            - * Actually the window handle (HWND), since the surfaceHandle (HDC) is derived + * Actually the window handle (HWND), since the surfaceHandle (HDC) is derived * from it at {@link #lockSurface()}. - *

            + *

            */ @Override public final void setSurfaceHandle(long surfaceHandle) { @@ -86,7 +86,7 @@ public class GDISurface extends ProxySurfaceImpl { } /** - * Sets the window handle (HWND). + * Sets the window handle (HWND). */ public final void setWindowHandle(long windowHandle) { this.windowHandle = windowHandle; @@ -118,7 +118,7 @@ public class GDISurface extends ProxySurfaceImpl { final protected void unlockSurfaceImpl() { if (0 != surfaceHandle) { if(0 == GDI.ReleaseDC(windowHandle, surfaceHandle)) { - throw new NativeWindowException("DC not released: "+this+", isWindow "+GDI.IsWindow(windowHandle)+", werr "+GDI.GetLastError()+", thread: "+Thread.currentThread().getName()); + throw new NativeWindowException("DC not released: "+this+", isWindow "+GDI.IsWindow(windowHandle)+", werr "+GDI.GetLastError()+", thread: "+Thread.currentThread().getName()); } surfaceHandle=0; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index 00741a328..db61b1efd 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -37,11 +37,11 @@ import jogamp.nativewindow.ToolkitProperties; public class GDIUtil implements ToolkitProperties { private static final boolean DEBUG = Debug.debug("GDIUtil"); - + private static final String dummyWindowClassNameBase = "_dummyWindow_clazz" ; private static RegisteredClassFactory dummyWindowClassFactory; private static boolean isInit = false; - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties @@ -59,42 +59,42 @@ public class GDIUtil implements ToolkitProperties { if( !initIDs0() ) { throw new NativeWindowException("GDI: Could not initialized native stub"); } - dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0()); + dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0()); isInit = true; } } } } - + /** * Called by {@link NativeWindowFactory#shutdown()} * @see ToolkitProperties */ - public static void shutdown() { + public static void shutdown() { } - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ public static boolean requiresToolkitLock() { return false; } - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ public static final boolean hasThreadingIssues() { return false; } - + private static RegisteredClass dummyWindowClass = null; private static Object dummyWindowSync = new Object(); - + public static long CreateDummyWindow(int x, int y, int width, int height) { synchronized(dummyWindowSync) { dummyWindowClass = dummyWindowClassFactory.getSharedClass(); return CreateDummyWindow0(dummyWindowClass.getHInstance(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height); } } - + public static boolean DestroyDummyWindow(long hwnd) { boolean res; synchronized(dummyWindowSync) { @@ -106,27 +106,27 @@ public class GDIUtil implements ToolkitProperties { } return res; } - + public static Point GetRelativeLocation(long src_win, long dest_win, int src_x, int src_y) { return (Point) GetRelativeLocation0(src_win, dest_win, src_x, src_y); } - + public static boolean IsUndecorated(long win) { return IsUndecorated0(win); } - + public static boolean IsChild(long win) { return IsChild0(win); } - + public static native boolean CreateWindowClass(long hInstance, String clazzName, long wndProc); public static native boolean DestroyWindowClass(long hInstance, String className); - + private static native boolean initIDs0(); - private static native long getDummyWndProc0(); + private static native long getDummyWndProc0(); private static native Object GetRelativeLocation0(long src_win, long dest_win, int src_x, int src_y); private static native boolean IsChild0(long win); private static native boolean IsUndecorated0(long win); - - static native long CreateDummyWindow0(long hInstance, String className, String windowName, int x, int y, int width, int height); + + static native long CreateDummyWindow0(long hInstance, String className, String windowName, int x, int y, int width, int height); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java index 949f5d06d..976693e3a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java @@ -39,7 +39,7 @@ public class RegisteredClass { /** Application handle, same as {@link RegisteredClassFactory#getHInstance()}. */ public final long getHInstance() { return hInstance; } - + /** Unique Window Class Name */ public final String getName() { return className; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java index 0280b0df7..e033a9f66 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java @@ -34,9 +34,9 @@ import javax.media.nativewindow.NativeWindowException; public class RegisteredClassFactory { private static final boolean DEBUG = Debug.debug("RegisteredClass"); - private static final ArrayList registeredFactories; + private static final ArrayList registeredFactories; private static final long hInstance; - + static { hInstance = GDI.GetApplicationHandle(); if( 0 == hInstance ) { @@ -44,7 +44,7 @@ public class RegisteredClassFactory { } registeredFactories = new ArrayList(); } - + private String classBaseName; private long wndProc; @@ -52,9 +52,9 @@ public class RegisteredClassFactory { private int classIter = 0; private int sharedRefCount = 0; private final Object sync = new Object(); - + /** - * Release the {@link RegisteredClass} of all {@link RegisteredClassFactory}. + * Release the {@link RegisteredClass} of all {@link RegisteredClassFactory}. */ public static void shutdownSharedClasses() { synchronized(registeredFactories) { @@ -65,7 +65,7 @@ public class RegisteredClassFactory { GDIUtil.DestroyWindowClass(rcf.sharedClass.getHInstance(), rcf.sharedClass.getName()); rcf.sharedClass = null; rcf.sharedRefCount = 0; - rcf.classIter = 0; + rcf.classIter = 0; if(DEBUG) { System.err.println("RegisteredClassFactory #"+j+"/"+registeredFactories.size()+" shutdownSharedClasses : "+rcf.sharedClass); } @@ -74,7 +74,7 @@ public class RegisteredClassFactory { } } } - + /** Application handle. */ public static long getHInstance() { return hInstance; } @@ -94,7 +94,7 @@ public class RegisteredClassFactory { } String clazzName = null; boolean registered = false; - final int classIterMark = classIter - 1; + final int classIterMark = classIter - 1; while ( !registered && classIterMark != classIter ) { // Retry with next clazz name, this could happen if more than one JVM is running clazzName = classBaseName + classIter; diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java index 827862002..2c8ef642c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java @@ -14,17 +14,17 @@ import com.jogamp.nativewindow.x11.X11GraphicsScreen; public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { /** - * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, - * not the actual dummy surface width. + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. * The latter is platform specific and small - * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, * not the actual dummy surface height, * The latter is platform specific and small */ public X11DummyUpstreamSurfaceHook(int width, int height) { super(width, height); } - + @Override public final void create(ProxySurface s) { final X11GraphicsConfiguration cfg = (X11GraphicsConfiguration) s.getGraphicsConfiguration(); @@ -42,14 +42,14 @@ public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize throw new NativeWindowException("Creating dummy window failed w/ "+cfg); } s.setSurfaceHandle(windowHandle); - s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); } finally { device.unlock(); } } - + @Override public final void destroy(ProxySurface s) { if( s.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { @@ -59,7 +59,7 @@ public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize } device.lock(); try { - X11Lib.DestroyWindow(device.getHandle(), s.getSurfaceHandle()); + X11Lib.DestroyWindow(device.getHandle(), s.getSurfaceHandle()); s.setSurfaceHandle(0); s.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } finally { diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java index b11dd1df1..d6e7b5970 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -47,10 +47,10 @@ import com.jogamp.nativewindow.x11.X11GraphicsScreen; public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactory { public static void registerFactory() { GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, CapabilitiesImmutable.class, new X11GraphicsConfigurationFactory()); - } + } private X11GraphicsConfigurationFactory() { } - + protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen screen, int nativeVisualID) throws IllegalArgumentException, NativeWindowException { @@ -109,7 +109,7 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor XVisualInfo best=null; int rdepth = capabilities.getRedBits() + capabilities.getGreenBits() + capabilities.getBlueBits() + capabilities.getAlphaBits(); for (int i = 0; vinfos!=null && i < num[0]; i++) { - if ( best == null || + if ( best == null || best.getDepth() < vinfos[i].getDepth() ) { best = vinfos[i]; diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 78e432b7f..6431fb3f5 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -54,16 +54,16 @@ import com.jogamp.nativewindow.x11.X11GraphicsDevice; */ public class X11Util implements ToolkitProperties { public static final boolean DEBUG = Debug.debug("X11Util"); - - /** + + /** * See Bug 515 - https://jogamp.org/bugzilla/show_bug.cgi?id=515 - *

            + *

            * It is observed that ATI X11 drivers, eg. - *

              + *
                *
              • fglrx 8.78.6,
              • *
              • fglrx 11.08/8.881 and
              • *
              • fglrx 11.11/8.911
              • - *
              + *
            * are quite sensitive to multiple Display connections. *

            *

            @@ -81,11 +81,11 @@ public class X11Util implements ToolkitProperties { *

            *

            * With ATI X11 drivers all connections must be closed at JVM shutdown, - * otherwise a SIGSEGV (after JVM safepoint) will be caused. + * otherwise a SIGSEGV (after JVM safepoint) will be caused. *

            */ public static final boolean ATI_HAS_XCLOSEDISPLAY_BUG = !Debug.isPropertyDefined("nativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG", true); - + /** See {@link #ATI_HAS_XCLOSEDISPLAY_BUG}. */ public static final boolean HAS_XCLOSEDISPLAY_BUG = Debug.isPropertyDefined("nativewindow.debug.X11Util.HAS_XCLOSEDISPLAY_BUG", true); @@ -105,7 +105,7 @@ public class X11Util implements ToolkitProperties { private static final Object setX11ErrorHandlerLock = new Object(); private static final String X11_EXTENSION_ATIFGLRXDRI = "ATIFGLRXDRI"; private static final String X11_EXTENSION_ATIFGLEXTENSION = "ATIFGLEXTENSION"; - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties @@ -121,15 +121,15 @@ public class X11Util implements ToolkitProperties { if(!NWJNILibLoader.loadNativeWindow("x11")) { throw new NativeWindowException("NativeWindow X11 native library load error."); } - + final boolean isInitOK = initialize0( XERROR_STACKDUMP ); - + final boolean hasX11_EXTENSION_ATIFGLRXDRI, hasX11_EXTENSION_ATIFGLEXTENSION; final long dpy = X11Lib.XOpenDisplay(PropertyAccess.getProperty("nativewindow.x11.display.default", true)); if(0 != dpy) { if(XSYNC_ENABLED) { X11Lib.XSynchronize(dpy, true); - } + } try { nullDisplayName = X11Lib.XDisplayString(dpy); hasX11_EXTENSION_ATIFGLRXDRI = X11Lib.QueryExtension(dpy, X11_EXTENSION_ATIFGLRXDRI); @@ -147,7 +147,7 @@ public class X11Util implements ToolkitProperties { if ( !markAllDisplaysUnclosable ) { markAllDisplaysUnclosable = ( ATI_HAS_XCLOSEDISPLAY_BUG && isATIFGLRX ) || HAS_XCLOSEDISPLAY_BUG; } - + if(DEBUG) { System.err.println("X11Util.initSingleton(): OK "+isInitOK+"]"+ ",\n\t X11 Display(NULL) <"+nullDisplayName+">"+ @@ -164,17 +164,17 @@ public class X11Util implements ToolkitProperties { } } } - + // 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 Object globalLock = new Object(); private static LongObjectHashMap openDisplayMap = new LongObjectHashMap(); // handle -> name private static List openDisplayList = new ArrayList(); // open, no close attempt private static List reusableDisplayList = new ArrayList(); // close attempt, marked uncloseable, for reuse private static List pendingDisplayList = new ArrayList(); // all open (close attempt or reusable) in creation order private static final HashMap displayXineramaEnabledMap = new HashMap(); - - /** + + /** * Cleanup resources. *

            * Called by {@link NativeWindowFactory#shutdown()} @@ -184,7 +184,7 @@ public class X11Util implements ToolkitProperties { public static void shutdown() { if(isInit) { synchronized(X11Util.class) { - if(isInit) { + if(isInit) { final boolean isJVMShuttingDown = NativeWindowFactory.isJVMShuttingDown() ; if( DEBUG || ( ( openDisplayMap.size() > 0 || reusableDisplayList.size() > 0 || pendingDisplayList.size() > 0 ) && @@ -207,9 +207,9 @@ public class X11Util implements ToolkitProperties { } } } - - // Only at JVM shutdown time, since AWT impl. seems to - // dislike closing of X11 Display's (w/ ATI driver). + + // Only at JVM shutdown time, since AWT impl. seems to + // dislike closing of X11 Display's (w/ ATI driver). if( isJVMShuttingDown ) { synchronized(globalLock) { isInit = false; @@ -226,7 +226,7 @@ public class X11Util implements ToolkitProperties { } } } - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties @@ -234,15 +234,15 @@ public class X11Util implements ToolkitProperties { public static final boolean requiresToolkitLock() { return true; // JAWT locking: yes, instead of native X11 locking w use a recursive lock per display connection. } - + /** * Called by {@link NativeWindowFactory#initSingleton()} * @see ToolkitProperties */ public static final boolean hasThreadingIssues() { - return hasThreadingIssues; // JOGL impl. may utilize special locking "somewhere" + return hasThreadingIssues; // JOGL impl. may utilize special locking "somewhere" } - + public static void setX11ErrorHandler(boolean onoff, boolean quiet) { synchronized(setX11ErrorHandlerLock) { setX11ErrorHandler0(onoff, quiet); @@ -271,7 +271,7 @@ public class X11Util implements ToolkitProperties { public static boolean getMarkAllDisplaysUnclosable() { return markAllDisplaysUnclosable; } - + private X11Util() {} public static class NamedDisplay { @@ -303,7 +303,7 @@ public class X11Util implements ToolkitProperties { public final int hashCode() { return hash32; } - + public final boolean equals(Object obj) { if(this == obj) { return true; } if(obj instanceof NamedDisplay) { @@ -311,10 +311,10 @@ public class X11Util implements ToolkitProperties { } return false; } - + public final void addRef() { refCount++; } public final void removeRef() { refCount--; } - + public final String getName() { return name; } public final long getHandle() { return handle; } public final int getRefCount() { return refCount; } @@ -365,7 +365,7 @@ public class X11Util implements ToolkitProperties { return openDisplayList.size(); } } - + public static void dumpOpenDisplayConnections() { synchronized(globalLock) { System.err.println("X11Util: Open X11 Display Connections: "+openDisplayList.size()); @@ -381,7 +381,7 @@ public class X11Util implements ToolkitProperties { } } } - + public static int getReusableDisplayConnectionNumber() { synchronized(globalLock) { return reusableDisplayList.size(); @@ -439,7 +439,7 @@ public class X11Util implements ToolkitProperties { NamedDisplay namedDpy = null; name = validateDisplayName(name); boolean reused = false; - + synchronized(globalLock) { for(int i=0; i - * If usrEDTUtil is null, + * If usrEDTUtil is null, * the device's default EDTUtil is created and used. *

            *

            - * If a previous one exists and it differs from usrEDTUtil, + * If a previous one exists and it differs from usrEDTUtil, * it's being stopped, wait-until-idle. *

            *

            @@ -167,7 +167,7 @@ public abstract class Display { *

            */ public abstract EDTUtil setEDTUtil(EDTUtil usrEDTUtil); - + public abstract EDTUtil getEDTUtil(); /** @@ -176,7 +176,7 @@ public abstract class Display { public abstract boolean isEDTRunning(); public abstract void dispatchMessages(); - + // Global Displays protected static final ArrayList> displayList = new ArrayList>(); protected static int displaysActive = 0; @@ -193,12 +193,12 @@ public abstract class Display { } /** - * + * * @param type * @param name * @param fromIndex start index, then increasing until found or end of list - * @paran shared if true, only shared instances are found, otherwise also exclusive - * @return + * @paran shared if true, only shared instances are found, otherwise also exclusive + * @return */ public static Display getFirstDisplayOf(String type, String name, int fromIndex, boolean shared) { return getDisplayOfImpl(type, name, fromIndex, 1, shared); @@ -209,7 +209,7 @@ public abstract class Display { * @param type * @param name * @param fromIndex start index, then decreasing until found or end of list. -1 is interpreted as size - 1. - * @paran shared if true, only shared instances are found, otherwise also exclusive + * @paran shared if true, only shared instances are found, otherwise also exclusive * @return */ public static Display getLastDisplayOf(String type, String name, int fromIndex, boolean shared) { @@ -231,7 +231,7 @@ public abstract class Display { } else { if( display.getType().equals(type) && display.getName().equals(name) && - ( !shared || shared && !display.isExclusive() ) + ( !shared || shared && !display.isExclusive() ) ) { return display; } @@ -241,7 +241,7 @@ public abstract class Display { } return null; } - + protected static void addDisplay2List(Display display) { synchronized(displayList) { // GC before add @@ -256,7 +256,7 @@ public abstract class Display { displayList.add(new WeakReference(display)); } } - + /** Returns the global display collection */ public static Collection getAllDisplays() { ArrayList list; diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index 42ac34240..625a7b39f 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.newt; import java.util.List; @@ -36,7 +36,7 @@ import javax.media.nativewindow.util.RectangleImmutable; import com.jogamp.common.util.ArrayHashSet; -/** +/** * Visual output device, i.e. a CRT, LED ..consisting of it's components:
            * *
          • Immutable @@ -55,7 +55,7 @@ import com.jogamp.common.util.ArrayHashSet; */ public abstract class MonitorDevice { protected final Screen screen; // backref - protected final int nativeId; // unique monitor device ID + protected final int nativeId; // unique monitor device ID protected final DimensionImmutable sizeMM; // in [mm] protected final MonitorMode originalMode; protected final ArrayHashSet supportedModes; // FIXME: May need to support mutable mode, i.e. adding modes on the fly! @@ -73,14 +73,14 @@ public abstract class MonitorDevice { this.viewport = viewport; this.modeChanged = false; } - + /** Returns the {@link Screen} owning this monitor. */ public final Screen getScreen() { return screen; } - + /** - * Tests equality of two MonitorDevice objects + * Tests equality of two MonitorDevice objects * by evaluating equality of it's components:
            *
              *
            • nativeID
            • @@ -105,10 +105,10 @@ public abstract class MonitorDevice { public final int hashCode() { return nativeId; } - + /** @return the immutable unique native Id of this monitor device. */ public final int getId() { return nativeId; } - + /** * @return the immutable monitor size in millimeters. */ @@ -140,11 +140,11 @@ public abstract class MonitorDevice { return supportedModes.getData(); } - /** Returns the {@link RectangleImmutable rectangular} portion of the rotated virtual {@link Screen} size represented by this monitor. */ + /** Returns the {@link RectangleImmutable rectangular} portion of the rotated virtual {@link Screen} size represented by this monitor. */ public final RectangleImmutable getViewport() { return viewport; } - + /** Returns true if given coordinates are contained by this {@link #getViewport() viewport}, otherwise false. */ public final boolean contains(int x, int y) { return x >= viewport.getX() && @@ -152,8 +152,8 @@ public abstract class MonitorDevice { y >= viewport.getY() && y < viewport.getY() + viewport.getHeight() ; } - - /** + + /** * Returns the coverage of given rectangle w/ this this {@link #getViewport() viewport}, i.e. between 0.0 and 1.0. *

              * Coverage is computed by: @@ -161,12 +161,12 @@ public abstract class MonitorDevice { * isect = viewport.intersection(r); * coverage = area( isect ) / area( viewport ) ; * - *

              + *

              */ public final float coverage(RectangleImmutable r) { return viewport.coverage(r); } - + /** * Returns the union of the given monitor's {@link #getViewport() viewport}. * @param result storage for result, will be returned @@ -186,14 +186,14 @@ public abstract class MonitorDevice { result.set(x1, y1, x2 - x1, y2 - y1); return result; } - + public final boolean isOriginalMode() { return currentMode.hashCode() == originalMode.hashCode(); } - + /** * Returns true if the {@link MonitorMode} - * has been changed programmatic via this API only, otherwise false. + * has been changed programmatic via this API only, otherwise false. *

              * Note: We cannot guarantee that we won't interfere w/ another running * application's screen mode change or vice versa. @@ -202,7 +202,7 @@ public abstract class MonitorDevice { public final boolean isModeChangedByUs() { return modeChanged && !isOriginalMode(); } - + /** * Returns the cached current {@link MonitorMode} w/o native query. *

              @@ -212,7 +212,7 @@ public abstract class MonitorDevice { public final MonitorMode getCurrentMode() { return currentMode; } - + /** * Returns the current {@link MonitorMode} resulting from a native query. *

              diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java index 218cd8bd5..175d6e5f2 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorMode.java +++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java @@ -37,7 +37,7 @@ import javax.media.nativewindow.util.SurfaceSize; import com.jogamp.newt.util.MonitorModeUtil; -/** +/** * Immutable MonitorMode Class, consisting of it's read only components:
              *

                *
              • nativeId
              • @@ -79,7 +79,7 @@ import com.jogamp.newt.util.MonitorModeUtil; // Pick the monitor: // Either the one used by a window .. MonitorDevice monitor = window.getMainMonitor(); - + // Or arbitrary from the list .. List allMonitor = getMonitorDevices(); MonitorDevice monitor = allMonitor.get(0); @@ -87,7 +87,7 @@ import com.jogamp.newt.util.MonitorModeUtil; // Current and original modes .. MonitorMode mmCurrent = monitor.queryCurrentMode(); MonitorMode mmOrig = monitor.getOriginalMode(); - + // Target resolution Dimension res = new Dimension(800, 600); @@ -102,7 +102,7 @@ import com.jogamp.newt.util.MonitorModeUtil; monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc monitorModes = MonitorModeUtil.filterByRotation(monitorModes, rot); monitorModes = MonitorModeUtil.filterByResolution(monitorModes, res); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, freq); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, freq); monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); // pick 1st one and set to current .. @@ -111,20 +111,20 @@ import com.jogamp.newt.util.MonitorModeUtil; * */ public class MonitorMode implements Comparable { - + /** Comparator for 2 {@link MonitorMode}s, following comparison order as described in {@link MonitorMode#compareTo(MonitorMode)}, returning the ascending order. */ public static final Comparator monitorModeComparator = new Comparator() { public int compare(MonitorMode mm1, MonitorMode mm2) { return mm1.compareTo(mm2); } }; - + /** Comparator for 2 {@link MonitorMode}s, following comparison order as described in {@link MonitorMode#compareTo(MonitorMode)}, returning the descending order. */ public static final Comparator monitorModeComparatorInv = new Comparator() { public int compare(MonitorMode mm1, MonitorMode mm2) { return mm2.compareTo(mm1); } }; - - /** + + /** * Immutable surfaceSize, flags and refreshRate Class, consisting of it's read only components:
                *
                  *
                • nativeId
                • @@ -141,7 +141,7 @@ public class MonitorMode implements Comparable { /** Vertical refresh rate */ public final float refreshRate; public final int hashCode; - + public SizeAndRRate(SurfaceSize surfaceSize, float refreshRate, int flags) { if(null==surfaceSize) { throw new IllegalArgumentException("surfaceSize must be set ("+surfaceSize+")"); @@ -151,11 +151,11 @@ public class MonitorMode implements Comparable { this.refreshRate=refreshRate; this.hashCode = getHashCode(); } - + private final static String STR_INTERLACE = "Interlace"; private final static String STR_DOUBLESCAN = "DoubleScan"; private final static String STR_SEP = ", "; - + public static final StringBuilder flags2String(int flags) { final StringBuilder sb = new StringBuilder(); boolean sp = false; @@ -175,11 +175,11 @@ public class MonitorMode implements Comparable { public final String toString() { return new String(surfaceSize+" @ "+refreshRate+" Hz, flags ["+flags2String(flags).toString()+"]"); } - + /** *

                  * Compares {@link SurfaceSize#compareTo(SurfaceSize) surfaceSize} 1st, then {@link #flags}, then {@link #refreshRate}. - *

                  + *

                  *

                  * Flags are compared as follows: *

                  @@ -196,7 +196,7 @@ public class MonitorMode implements Comparable {
                               final int rssz = surfaceSize.compareTo(sszr.surfaceSize);
                               if( 0 != rssz ) {
                                   return rssz;
                  -            }            
                  +            }
                               final int tflags = 0 == flags ? Integer.MAX_VALUE : flags; // normalize NONE
                               final int xflags = 0 == sszr.flags ? Integer.MAX_VALUE : sszr.flags; // normalize NONE
                               if( tflags == xflags ) {
                  @@ -218,9 +218,9 @@ public class MonitorMode implements Comparable {
                                   return 0;
                               }
                           }
                  -        
                  +
                           /**
                  -         * Tests equality of two {@link SizeAndRRate} objects 
                  +         * Tests equality of two {@link SizeAndRRate} objects
                            * by evaluating equality of it's components:
                  *
                    *
                  • surfaceSize
                  • @@ -238,7 +238,7 @@ public class MonitorMode implements Comparable { } return false; } - + /** * Returns a combined hash code of it's elements:
                    *
                      @@ -249,16 +249,16 @@ public class MonitorMode implements Comparable { */ public final int hashCode() { return hashCode; - } + } private final int getHashCode() { // 31 * x == (x << 5) - x int hash = 31 + surfaceSize.hashCode(); hash = ((hash << 5) - hash) + flags; hash = ((hash << 5) - hash) + (int)(refreshRate*100.0f); return hash; - } + } } - + /** zero rotation, compared to normal settings */ public static final int ROTATE_0 = 0; @@ -270,15 +270,15 @@ public class MonitorMode implements Comparable { /** 270 degrees CCW rotation */ public static final int ROTATE_270 = 270; - + /** Frame is split into two fields. See {@link #getFlags()}. */ public static final int FLAG_INTERLACE = 1 << 0; - + /** Lines are doubled. See {@link #getFlags()}. */ public static final int FLAG_DOUBLESCAN = 1 << 1; /** The immutable native Id of this instance, which may not be unique. */ - private final int nativeId; + private final int nativeId; private final SizeAndRRate sizeAndRRate; private final int rotation; private final int hashCode; @@ -301,7 +301,7 @@ public class MonitorMode implements Comparable { this.rotation = rotation; this.hashCode = getHashCode(); } - + /** * Creates a user instance w/o {@link #getId() identity} to filter our matching modes w/ identity. *

                      @@ -314,16 +314,16 @@ public class MonitorMode implements Comparable { */ public MonitorMode(SurfaceSize surfaceSize, float refreshRate, int flags, int rotation) { this(0, new SizeAndRRate(surfaceSize, refreshRate, flags), rotation); - } + } /** @return the immutable native Id of this mode, may not be unique, may be 0. */ public final int getId() { return nativeId; } - + /** Returns the surfaceSize and refreshRate instance. */ - public final SizeAndRRate getSizeAndRRate() { + public final SizeAndRRate getSizeAndRRate() { return sizeAndRRate; } - + /** Returns the unrotated {@link SurfaceSize} */ public final SurfaceSize getSurfaceSize() { return sizeAndRRate.surfaceSize; @@ -338,23 +338,23 @@ public class MonitorMode implements Comparable { public final int getFlags() { return sizeAndRRate.flags; } - + /** Returns the CCW rotation of this mode */ public final int getRotation() { return rotation; } - - /** Returns the rotated screen width, + + /** Returns the rotated screen width, * derived from getMonitorMode().getSurfaceSize().getResolution() - * and getRotation() + * and getRotation() */ public final int getRotatedWidth() { return getRotatedWH(true); } - - /** Returns the rotated screen height, + + /** Returns the rotated screen height, * derived from getMonitorMode().getSurfaceSize().getResolution() - * and getRotation() + * and getRotation() */ public final int getRotatedHeight() { return getRotatedWH(false); @@ -367,9 +367,9 @@ public class MonitorMode implements Comparable { /** *

                      * Compares {@link SizeAndRRate#compareTo(SizeAndRRate) sizeAndRRate} 1st, then {@link #rotation}. - *

                      + *

                      *

                      - * Rotation is compared inverted, i.e. 360 - rotation, + * Rotation is compared inverted, i.e. 360 - rotation, * so the lowest rotation reflects a higher value. *

                      *

                      @@ -380,7 +380,7 @@ public class MonitorMode implements Comparable { *

                    • flags
                    • *
                    • refresh rate
                    • *
                    • rotation
                    • - *
                    + *
                  *

                  * {@inheritDoc} */ @@ -399,9 +399,9 @@ public class MonitorMode implements Comparable { } return 0; } - + /** - * Tests equality of two {@link MonitorMode} objects + * Tests equality of two {@link MonitorMode} objects * by evaluating equality of it's components:
                  *
                    *
                  • nativeId
                  • @@ -438,7 +438,7 @@ public class MonitorMode implements Comparable { hash = ((hash << 5) - hash) + getRotation(); return hash; } - + private final int getRotatedWH(boolean width) { final DimensionImmutable d = sizeAndRRate.surfaceSize.getResolution(); final boolean swap = MonitorMode.ROTATE_90 == rotation || MonitorMode.ROTATE_270 == rotation ; @@ -446,5 +446,5 @@ public class MonitorMode implements Comparable { return d.getHeight(); } return d.getWidth(); - } + } } diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index e66b2f624..7116877a3 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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; @@ -53,16 +53,16 @@ public class NewtFactory { public static final boolean DEBUG_IMPLEMENTATION = Debug.debug("Window"); public static final String DRIVER_DEFAULT_ROOT_PACKAGE = "jogamp.newt.driver"; - + static { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { NativeWindowFactory.initSingleton(); // last resort .. - + // Work-around for initialization order problems on Mac OS X // between native Newt and (apparently) Fmod WindowImpl.init(NativeWindowFactory.getNativeWindowType(true)); - + return null; } } ); } @@ -75,7 +75,7 @@ public class NewtFactory { clazzName = DRIVER_DEFAULT_ROOT_PACKAGE + packageName + "." + classBaseName ; } else { clazzName = packageName + "." + classBaseName ; - } + } try { clazz = Class.forName(clazzName); } catch (Throwable t) { @@ -90,7 +90,7 @@ public class NewtFactory { 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.
                    @@ -108,7 +108,7 @@ public class NewtFactory { * Native creation is lazily done at usage, ie. {@link Display#addReference()}. *

                    *

                    - * An already existing display connection of the same name will be reused. + * An already existing display connection of the same name will be reused. *

                    * @param name the display connection name which is a technical platform specific detail, * see {@link AbstractGraphicsDevice#getConnection()}. Use null for default. diff --git a/src/newt/classes/com/jogamp/newt/NewtVersion.java b/src/newt/classes/com/jogamp/newt/NewtVersion.java index 9adb7aac5..e70d63f88 100644 --- a/src/newt/classes/com/jogamp/newt/NewtVersion.java +++ b/src/newt/classes/com/jogamp/newt/NewtVersion.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.newt; import com.jogamp.common.GlueGenVersion; diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index f56ee344b..1274b3459 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -39,7 +39,7 @@ import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; -/** +/** * A screen may span multiple {@link MonitorDevice}s representing their combined virtual size. */ public abstract class Screen { @@ -102,7 +102,7 @@ public abstract class Screen { /** * See {@link Display#addReference()} - * + * * @return number of references post operation * @throws NativeWindowException if the native creation failed. * @see #removeReference() @@ -113,7 +113,7 @@ public abstract class Screen { /** * See {@link Display#removeReference()} - * + * * @return number of references post operation * @see #addReference() * @see #setDestroyWhenUnused(boolean) @@ -132,12 +132,12 @@ public abstract class Screen { * @return the x position of the virtual viewport's top-left origin. */ public abstract int getX(); - + /** * @return the y position of the virtual viewport's top-left origin. */ public abstract int getY(); - + /** * @return the rotated virtual viewport's width. */ @@ -152,19 +152,19 @@ public abstract class Screen { * @return the rotated virtual viewport, i.e. origin and size. */ public abstract RectangleImmutable getViewport(); - + /** * @return the associated Display */ public abstract Display getDisplay(); - /** + /** * @return The screen fully qualified Screen name, * which is a key of {@link com.jogamp.newt.Display#getFQName()} + {@link #getIndex()}. */ public abstract String getFQName(); - /** + /** * Return a list of all {@link MonitorMode}s for all {@link MonitorDevice}s. *

                    * The list is ordered in descending order, @@ -173,23 +173,23 @@ public abstract class Screen { */ public abstract List getMonitorModes(); - /** + /** * Return a list of available {@link MonitorDevice}s. */ public abstract List getMonitorDevices(); /** - * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} + * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} * {@link MonitorDevice#coverage(RectangleImmutable) covers} the given rectangle the most. *

                    - * If no coverage is detected the first {@link MonitorDevice} is returned. + * If no coverage is detected the first {@link MonitorDevice} is returned. *

                    */ public final MonitorDevice getMainMonitor(RectangleImmutable r) { MonitorDevice res = null; float maxCoverage = Float.MIN_VALUE; final List monitors = getMonitorDevices(); - for(int i=monitors.size()-1; i>=0; i--) { + for(int i=monitors.size()-1; i>=0; i--) { final MonitorDevice monitor = monitors.get(i); final float coverage = monitor.coverage(r); if( coverage > maxCoverage ) { @@ -207,14 +207,14 @@ public abstract class Screen { * Returns the union of all monitor's {@link MonitorDevice#getViewport() viewport}. *

                    * Should be equal to {@link #getX()}, {@link #getY()}, {@link #getWidth()} and {@link #getHeight()}, - * however, some native toolkits may choose a different virtual screen area. + * however, some native toolkits may choose a different virtual screen area. *

                    * @param result storage for result, will be returned */ public final Rectangle unionOfMonitorViewportSize(final Rectangle result) { return MonitorDevice.unionOfViewports(result, getMonitorDevices()); } - + /** * @param sml {@link MonitorModeListener} to be added for {@link MonitorEvent} */ @@ -274,7 +274,7 @@ public abstract class Screen { } return null; } - + protected static void addScreen2List(Screen screen) { synchronized(screenList) { // GC before add @@ -289,7 +289,7 @@ public abstract class Screen { screenList.add(new WeakReference(screen)); } } - + /** Returns the global screen collection */ public static Collection getAllScreens() { ArrayList list; @@ -308,7 +308,7 @@ public abstract class Screen { } return list; } - + public static int getActiveScreenNumber() { synchronized(screenList) { return screensActive; diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 02727353f..04eb07a25 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -58,8 +58,8 @@ import javax.media.nativewindow.util.RectangleImmutable; *
                  • ... and more
                  • * *

                    - * One use case is {@link com.jogamp.newt.opengl.GLWindow}, which delegates - * window operation to an instance of this interface while providing OpenGL + * One use case is {@link com.jogamp.newt.opengl.GLWindow}, which delegates + * window operation to an instance of this interface while providing OpenGL * functionality. *

                    */ @@ -90,14 +90,14 @@ public interface Window extends NativeWindow, WindowClosingProtocol { Screen getScreen(); /** - * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} + * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} * {@link MonitorDevice#coverage(RectangleImmutable) covers} this window the most. *

                    - * If no coverage is detected the first {@link MonitorDevice} is returned. + * If no coverage is detected the first {@link MonitorDevice} is returned. *

                    */ MonitorDevice getMainMonitor(); - + /** * Set the CapabilitiesChooser to help determine the native visual type. * @@ -129,7 +129,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * Visibility is set to false. *

                    *

                    - * Method sends out {@link WindowEvent#EVENT_WINDOW_DESTROY_NOTIFY pre-} and + * Method sends out {@link WindowEvent#EVENT_WINDOW_DESTROY_NOTIFY pre-} and * {@link WindowEvent#EVENT_WINDOW_DESTROYED post-} destruction events * to all of it's {@link WindowListener}. *

                    @@ -151,7 +151,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * Set a custom action handling destruction issued by a {@link WindowImpl#windowDestroyNotify(boolean) toolkit triggered window destroy} * replacing the default {@link #destroy()} action. *

                    - * The custom action shall call {@link #destroy()} + * The custom action shall call {@link #destroy()} * but may perform further tasks before and after. *

                    */ @@ -369,7 +369,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * @param x new top-level position, use -1 for default position. * @param y new top-level position, use -1 for default position. * @param forceDestroyCreate if true, uses re-creation strategy for reparenting, default is false. - * + * * @return The issued reparent action type (strategy) as defined in Window.ReparentAction * @see #reparentWindow(NativeWindow) */ @@ -378,7 +378,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { /** * Enable or disable fullscreen mode for this window. *

                    - * Fullscreen mode is established on the {@link #getMainMonitor() main monitor}. + * Fullscreen mode is established on the {@link #getMainMonitor() main monitor}. *

                    * @param fullscreen enable or disable fullscreen mode * @return success @@ -393,14 +393,14 @@ public interface Window extends NativeWindow, WindowClosingProtocol { *

                    * Disable fullscreen via {@link #setFullscreen(boolean)}. *

                    - * @param monitors if null fullscreen will be spanned across all {@link MonitorDevice}s, + * @param monitors if null fullscreen will be spanned across all {@link MonitorDevice}s, * otherwise across the given list of {@link MonitorDevice}. * @return success * @see #setFullscreen(boolean) * @see #isFullscreen() */ boolean setFullscreen(List monitors); - + boolean isFullscreen(); static interface FocusRunnable { @@ -429,7 +429,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * and to perform focus traversal with a 3rd party toolkit. *

                    *

                    - * The {@link KeyListener} methods are not invoked for {@link KeyEvent#isAutoRepeat() auto-repeat} events. + * The {@link KeyListener} methods are not invoked for {@link KeyEvent#isAutoRepeat() auto-repeat} events. *

                    * @param l */ @@ -469,7 +469,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { /** * Send a {@link WindowEvent} to all {@link WindowListener}. - * @param eventType a {@link WindowEvent} type, e.g. {@link WindowEvent#EVENT_WINDOW_REPAINT}. + * @param eventType a {@link WindowEvent} type, e.g. {@link WindowEvent#EVENT_WINDOW_REPAINT}. */ public void sendWindowEvent(int eventType); @@ -585,8 +585,8 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * Returns all {@link MouseListener} */ MouseListener[] getMouseListeners(); - - /** Enable or disable default {@link GestureHandler}. Default is enabled. */ + + /** Enable or disable default {@link GestureHandler}. Default is enabled. */ void setDefaultGesturesEnabled(boolean enable); /** Return true if default {@link GestureHandler} are enabled. */ boolean areDefaultGesturesEnabled(); @@ -627,5 +627,5 @@ public interface Window extends NativeWindow, WindowClosingProtocol { /** * Removes the given {@link GestureHandler.GestureListener} from the list. */ - void removeGestureListener(GestureHandler.GestureListener gl); + void removeGestureListener(GestureHandler.GestureListener gl); } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 13affdf49..de1b7224f 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.newt.awt; @@ -84,11 +84,11 @@ import com.jogamp.opengl.util.TileRenderer; /** * AWT {@link java.awt.Canvas Canvas} containing a NEWT {@link Window} using native parenting. - * + * *
                    Offscreen Layer Remarks
                    - * + * * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} - * maybe called to use an offscreen drawable (FBO or PBuffer) allowing + * maybe called to use an offscreen drawable (FBO or PBuffer) allowing * the underlying JAWT mechanism to composite the image, if supported. */ @SuppressWarnings("serial") @@ -104,7 +104,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private AWTParentWindowAdapter awtAdapter = null; private AWTAdapter awtMouseAdapter = null; private AWTAdapter awtKeyAdapter = null; - + private AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { public void run() { @@ -115,7 +115,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( newtChild != null ) { newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); } - } + } } ); /** @@ -147,36 +147,36 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto super(gc); setNEWTChild(child); } - + public void setShallUseOffscreenLayer(boolean v) { shallUseOffscreenLayer = v; } - + public final boolean getShallUseOffscreenLayer() { - return shallUseOffscreenLayer; + return shallUseOffscreenLayer; } - - public final boolean isOffscreenLayerSurfaceEnabled() { + + public final boolean isOffscreenLayerSurfaceEnabled() { return jawtWindow.isOffscreenLayerSurfaceEnabled(); } - - /** - * Returns true if the AWT component is parented to an {@link java.applet.Applet}, - * otherwise false. This information is valid only after {@link #addNotify()} is issued, - * ie. before adding the component to the AWT tree and make it visible. + + /** + * Returns true if the AWT component is parented to an {@link java.applet.Applet}, + * otherwise false. This information is valid only after {@link #addNotify()} is issued, + * ie. before adding the component to the AWT tree and make it visible. */ public boolean isApplet() { return jawtWindow.isApplet(); } boolean isParent() { - return null!=newtChild && jawtWindow == newtChild.getParent(); + return null!=newtChild && jawtWindow == newtChild.getParent(); } - + boolean isFullscreen() { return null != newtChild && newtChild.isFullscreen(); } - + class FocusAction implements Window.FocusRunnable { public boolean run() { final boolean isParent = isParent(); @@ -199,7 +199,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } private FocusAction focusAction = new FocusAction(); - + WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() { @Override public void windowResized(WindowEvent e) { @@ -224,15 +224,15 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto handleKey(e, true); } } - - void handleKey(KeyEvent evt, boolean onRelease) { + + void handleKey(KeyEvent evt, boolean onRelease) { if(null == keyboardFocusManager) { throw new InternalError("XXX"); } final AWTKeyStroke ks = AWTKeyStroke.getAWTKeyStroke(evt.getKeyCode(), evt.getModifiers(), onRelease); boolean suppress = false; if(null != ks) { - final Set fwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); + final Set fwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); final Set bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); if(fwdKeys.contains(ks)) { final Component nextFocus = AWTMisc.getNextFocus(NewtCanvasAWT.this, true /* forward */); @@ -253,38 +253,38 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } if(suppress) { - evt.setConsumed(true); + evt.setConsumed(true); } if(DEBUG) { System.err.println("NewtCanvasAWT.focusKey: XXX: "+ks); } } } - private final FocusTraversalKeyListener newtFocusTraversalKeyListener = new FocusTraversalKeyListener(); + private final FocusTraversalKeyListener newtFocusTraversalKeyListener = new FocusTraversalKeyListener(); class FocusPropertyChangeListener implements PropertyChangeListener { public void propertyChange(PropertyChangeEvent evt) { final Object oldF = evt.getOldValue(); final Object newF = evt.getNewValue(); final boolean isParent = isParent(); - final boolean isFullscreen = isFullscreen(); + final boolean isFullscreen = isFullscreen(); if(DEBUG) { System.err.println("NewtCanvasAWT.FocusProperty: "+evt.getPropertyName()+", src "+evt.getSource()+", "+oldF+" -> "+newF+", isParent "+isParent+", isFS "+isFullscreen); } if(isParent && !isFullscreen) { if(newF == NewtCanvasAWT.this) { - if(DEBUG) { + if(DEBUG) { System.err.println("NewtCanvasAWT.FocusProperty: AWT focus -> NEWT focus traversal"); } requestFocusNEWTChild(); } else if(oldF == NewtCanvasAWT.this && newF == null) { // focus traversal to NEWT - NOP - if(DEBUG) { + if(DEBUG) { System.err.println("NewtCanvasAWT.FocusProperty: NEWT focus"); } } else if(null != newF && newF != NewtCanvasAWT.this) { // focus traversal to another AWT component - if(DEBUG) { + if(DEBUG) { System.err.println("NewtCanvasAWT.FocusProperty: lost focus - clear focus"); } if(newtChild.getDelegatedWindow() instanceof DriverClearFocus) { @@ -292,7 +292,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } } - } + } } private final FocusPropertyChangeListener focusPropertyChangeListener = new FocusPropertyChangeListener(); private volatile KeyboardFocusManager keyboardFocusManager = null; @@ -300,7 +300,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final void requestFocusNEWTChild() { if(null!=newtChild) { newtChild.setFocusAction(null); - if(isOnscreen) { + if(isOnscreen) { KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); } newtChild.requestFocus(); @@ -308,17 +308,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } - /** + /** * Sets a new NEWT child, provoking reparenting. *

                    * A previously detached newChild will be released to top-level status - * and made invisible. + * and made invisible. *

                    *

                    - * Note: When switching NEWT child's, detaching the previous first via setNEWTChild(null) - * produced much cleaner visual results. + * Note: When switching NEWT child's, detaching the previous first via setNEWTChild(null) + * produced much cleaner visual results. *

                    - * @return the previous attached newt child. + * @return the previous attached newt child. */ public Window setNEWTChild(Window newChild) { final Window prevChild = newtChild; @@ -336,17 +336,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto updateLayoutSize(); // will be done later at paint/display/..: attachNewtChild(cont); - + return prevChild; } - + private final void updateLayoutSize() { if( null != newtChild ) { // use NEWT child's size for min/pref size! java.awt.Dimension minSize = new java.awt.Dimension(newtChild.getWidth(), newtChild.getHeight()); setMinimumSize(minSize); setPreferredSize(minSize); - } + } } /** @return the current NEWT child */ @@ -357,7 +357,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto /** @return this AWT Canvas NativeWindow representation, may be null in case {@link #removeNotify()} has been called, * or {@link #addNotify()} hasn't been called yet.*/ public NativeWindow getNativeWindow() { return jawtWindow; } - + public WindowClosingMode getDefaultCloseOperation() { return awtWindowClosingProtocol.getDefaultCloseOperation(); } @@ -373,16 +373,16 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } else { // before native peer is valid: X11 disableBackgroundErase(); - + // creates the native peer super.addNotify(); - + // after native peer is valid: Windows disableBackgroundErase(); - - jawtWindow = NewtFactoryAWT.getNativeWindow(this, null != newtChild ? newtChild.getRequestedCapabilities() : null); + + jawtWindow = NewtFactoryAWT.getNativeWindow(this, null != newtChild ? newtChild.getRequestedCapabilities() : null); jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); - + if(DEBUG) { // if ( isShowing() == false ) -> Container was not visible yet. // if ( isShowing() == true ) -> Container is already visible. @@ -397,7 +397,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public void removeNotify() { awtWindowClosingProtocol.removeClosingListener(); - + if( Beans.isDesignTime() ) { super.removeNotify(); } else { @@ -419,7 +419,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto public final void destroy() { destroyImpl(false /* removeNotify */, false /* windowClosing */); } - + private final void destroyImpl(boolean removeNotify, boolean windowClosing) { if( null !=newtChild ) { java.awt.Container cont = AWTMisc.getContainer(this); @@ -427,7 +427,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.destroy(removeNotify "+removeNotify+", windowClosing "+windowClosing+"): nw "+newtWinHandleToHexString(newtChild)+", from "+cont); } detachNewtChild(cont); - + if( !removeNotify ) { final Window cWin = newtChild; final Window dWin = cWin.getDelegatedWindow(); @@ -437,14 +437,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } else { cWin.destroy(); } - } + } } if( ( removeNotify || windowClosing ) && null!=jawtWindow ) { NewtFactoryAWT.destroyNativeWindow(jawtWindow); jawtWindow=null; - } + } } - + @Override public void paint(Graphics g) { if( validateComponent(true) && !printActive ) { @@ -469,9 +469,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } } - + private volatile boolean printActive = false; - private GLAnimatorControl printAnimator = null; + private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @@ -481,15 +481,15 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } return null; } - + @Override public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { - printActive = true; + printActive = true; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG); AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); - } + } private final Runnable setupPrintOnEDT = new Runnable() { @Override public void run() { @@ -497,14 +497,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); } - printActive = false; + printActive = false; return; // not yet available .. } if( !isVisible() ) { if(DEBUG) { System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); } - printActive = false; + printActive = false; return; // not yet available .. } final GLAutoDrawable glad = getGLAD(); @@ -512,14 +512,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( DEBUG ) { System.err.println("AWT print.setup exit, newtChild not a GLAutoDrawable: "+newtChild); } - printActive = false; + printActive = false; return; } printAnimator = glad.getAnimator(); if( null != printAnimator ) { printAnimator.remove(glad); } - printGLAD = glad; // _not_ default, shall be replaced by offscreen GLAD + printGLAD = glad; // _not_ default, shall be replaced by offscreen GLAD final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); final int printNumSamples = printAWTTiles.getNumSamples(caps); GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); @@ -527,7 +527,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); final boolean reqNewGLADOnscrn = caps.isOnscreen(); - + // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context. // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); @@ -546,8 +546,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto caps.setNumSamples(printNumSamples); } final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, - printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, null); GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); @@ -634,7 +634,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("AWT print.X: "+printAWTTiles); } } - + private final boolean validateComponent(boolean attachNewtChild) { if( Beans.isDesignTime() || !isDisplayable() ) { return false; @@ -645,14 +645,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( 0 >= getWidth() || 0 >= getHeight() ) { return false; } - + if( attachNewtChild && !newtChildAttached && null != newtChild ) { attachNewtChild(); } return true; } - + private final void configureNewtChild(boolean attach) { if(null!=awtAdapter) { awtAdapter.removeFrom(this); @@ -670,13 +670,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener); keyboardFocusManager = null; } - + if( null != newtChild ) { newtChild.setKeyboardFocusHandler(null); if(attach) { if(null == jawtWindow.getGraphicsConfiguration()) { throw new InternalError("XXX"); - } + } isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this); awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! @@ -733,13 +733,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.reparentWindow(jawtWindow); newtChild.addSurfaceUpdatedListener(jawtWindow); if( jawtWindow.isOffscreenLayerSurfaceEnabled() && - 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) { + 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) { AWTEDTExecutor.singleton.invoke(false, forceRelayout); } newtChild.setVisible(true); configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener - + if(DEBUG) { System.err.println("NewtCanvasAWT.attachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); } @@ -759,7 +759,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.forceRelayout.X"); } } }; - + private final void detachNewtChild(java.awt.Container cont) { if( null == newtChild || null == jawtWindow || !newtChildAttached ) { return; // nop @@ -773,14 +773,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto ", cont "+cont); } - newtChild.removeSurfaceUpdatedListener(jawtWindow); + newtChild.removeSurfaceUpdatedListener(jawtWindow); newtChildAttached = false; newtChild.setFocusAction(null); // no AWT focus traversal .. configureNewtChild(false); newtChild.setVisible(false); - + newtChild.reparentWindow(null); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer - + if(DEBUG) { System.err.println("NewtCanvasAWT.detachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); } @@ -837,7 +837,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } protected static String getThreadName() { return Thread.currentThread().getName(); } - + static String newtWinHandleToHexString(Window w) { return null != w ? toHexString(w.getWindowHandle()) : "nil"; } diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java index c7153840f..9b1b82297 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java @@ -47,12 +47,12 @@ import jogamp.nativewindow.jawt.JAWTUtil; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; -/** +/** * Simple GLEventListener deployment as an applet using JOGL. This demo must be * referenced from a web page via an <applet> tag. - * + * *

                    - * Example of an applet tag using GearsES2 within the applet area (normal case): + * Example of an applet tag using GearsES2 within the applet area (normal case): *

                             <applet width=100 height=100>
                                <param name="java_arguments" value="-Dsun.java2d.noddraw=true">
                    @@ -65,9 +65,9 @@ import com.jogamp.newt.opengl.GLWindow;
                             </applet>Hello Gears !
                      *  
                    *

                    - * + * *

                    - * Example of an applet tag using GearsES2 in an undecorated, translucent, closeable and always-on-top window: + * Example of an applet tag using GearsES2 in an undecorated, translucent, closeable and always-on-top window: *

                             <applet width=1 height=1>
                                <param name="java_arguments" value="-Dsun.java2d.noddraw=true">
                    @@ -95,12 +95,12 @@ import com.jogamp.newt.opengl.GLWindow;
                     @SuppressWarnings("serial")
                     public class JOGLNewtApplet1Run extends Applet {
                         public static final boolean DEBUG = JOGLNewtAppletBase.DEBUG;
                    -    
                    +
                         GLWindow glWindow = null;
                         NewtCanvasAWT newtCanvasAWT = null;
                         JOGLNewtAppletBase base = null;
                         /** if valid glStandalone:=true (own window) ! */
                    -    int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE; 
                    +    int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE;
                     
                         public void init() {
                             if(DEBUG) {
                    @@ -135,7 +135,7 @@ public class JOGLNewtApplet1Run extends Applet {
                                 glCloseable = JOGLNewtAppletBase.str2Bool(getParameter("gl_closeable"), glCloseable);
                                 glOpaque = JOGLNewtAppletBase.str2Bool(getParameter("gl_opaque"), glOpaque);
                                 glAlphaBits = JOGLNewtAppletBase.str2Int(getParameter("gl_alpha"), glAlphaBits);
                    -            glNumMultisampleBuffer = JOGLNewtAppletBase.str2Int(getParameter("gl_multisamplebuffer"), glNumMultisampleBuffer); 
                    +            glNumMultisampleBuffer = JOGLNewtAppletBase.str2Int(getParameter("gl_multisamplebuffer"), glNumMultisampleBuffer);
                                 glXd = JOGLNewtAppletBase.str2Int(getParameter("gl_dx"), glXd);
                                 glYd = JOGLNewtAppletBase.str2Int(getParameter("gl_dy"), glYd);
                                 glWidth = JOGLNewtAppletBase.str2Int(getParameter("gl_width"), glWidth);
                    @@ -168,8 +168,8 @@ public class JOGLNewtApplet1Run extends Applet {
                                 System.err.println("glNumMultisampleBuffer: "+glNumMultisampleBuffer);
                                 System.err.println("glNoDefaultKeyListener: "+glNoDefaultKeyListener);
                             }
                    -        
                    -        base = new JOGLNewtAppletBase(glEventListenerClazzName, 
                    +
                    +        base = new JOGLNewtAppletBase(glEventListenerClazzName,
                                                           glSwapInterval,
                                                           glNoDefaultKeyListener,
                                                           glCloseable,
                    @@ -252,9 +252,9 @@ public class JOGLNewtApplet1Run extends Applet {
                                 System.err.println("GLWindow: "+glWindow);
                             }
                             base.start();
                    -        if( null != newtCanvasAWT && 
                    +        if( null != newtCanvasAWT &&
                                 newtCanvasAWT.isOffscreenLayerSurfaceEnabled() &&
                    -            0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) {          
                    +            0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) {
                                 // force relayout
                                 final int cW = newtCanvasAWT.getWidth();
                                 final int cH = newtCanvasAWT.getHeight();
                    diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
                    index 1004adb8e..a6a30a8bf 100644
                    --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
                    +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java
                    @@ -57,7 +57,7 @@ import com.jogamp.opengl.util.Animator;
                     
                     public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
                         public static final boolean DEBUG = Debug.debug("Applet");
                    -    
                    +
                         String glEventListenerClazzName;
                         int glSwapInterval;
                         boolean noDefaultKeyListener;
                    @@ -71,13 +71,13 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
                         boolean isValid = false;
                         NativeWindow awtParent;
                     
                    -    public JOGLNewtAppletBase(String glEventListenerClazzName, 
                    +    public JOGLNewtAppletBase(String glEventListenerClazzName,
                                                   int glSwapInterval,
                                                   boolean noDefaultKeyListener,
                                                   boolean glClosable,
                                                   boolean glDebug,
                                                   boolean glTrace) {
                    -    
                    +
                             this.glEventListenerClazzName=glEventListenerClazzName;
                             this.glSwapInterval=glSwapInterval;
                             this.noDefaultKeyListener = noDefaultKeyListener;
                    @@ -174,8 +174,8 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
                                                         glWindow.reparentWindow(awtParent);
                                                     }
                                                    }
                    -                            }).start();                         
                    -                        }                        
                    +                            }).start();
                    +                        }
                                         }
                                     } } );
                     
                    @@ -203,7 +203,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
                                 if(glEventListener instanceof KeyListener) {
                                     glWindow.addKeyListener((KeyListener)glEventListener);
                                 }
                    -            
                    +
                                 if(!noDefaultKeyListener) {
                                     glWindow.addKeyListener(this);
                                 }
                    @@ -216,7 +216,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
                                 glAnimator.setThreadGroup(tg);
                                 glAnimator.add(glWindow);
                                 glAnimator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, null);
                    -            
                    +
                             } catch (Throwable t) {
                                 throw new RuntimeException(t);
                             }
                    @@ -262,14 +262,14 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
                             if(glDebug) {
                                 try {
                                     _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, _gl, null) );
                    -            } catch (Exception e) {e.printStackTrace();} 
                    +            } catch (Exception e) {e.printStackTrace();}
                             }
                     
                             if(glTrace) {
                                 try {
                                     // Trace ..
                                     _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, _gl, new Object[] { System.err } ) );
                    -            } catch (Exception e) {e.printStackTrace();} 
                    +            } catch (Exception e) {e.printStackTrace();}
                             }
                     
                             if(glSwapInterval>=0) {
                    @@ -317,9 +317,9 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener {
                                 }
                            }
                         }
                    -    
                    +
                         @Override
                    -    public void keyReleased(KeyEvent e) { 
                    +    public void keyReleased(KeyEvent e) {
                         }
                     }
                     
                    diff --git a/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java b/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java
                    index bc67cbee6..7dda47534 100644
                    --- a/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java
                    +++ b/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java
                    @@ -41,15 +41,15 @@ import jogamp.newt.Debug;
                      *
                      *    - touchSlop (scaled in pixels):
                      *       - Min. movement w/ 2 pointer within ScaledDoubleTapSlop starting 'scroll' mode
                    - *       
                    + *
                      *    - Avoid computation if not within gesture, especially for MOVE/DRAG
                    - *    
                    + *
                      *    - Only allow gesture to start with PRESS
                    - *    
                    - *    - Leave gesture completely with RELEASE of both/all fingers, or dist-diff exceeds doubleTapSlop 
                    - *    
                    + *
                    + *    - Leave gesture completely with RELEASE of both/all fingers, or dist-diff exceeds doubleTapSlop
                    + *
                      *    - Tolerate temporary lift 1 of 2 pointer
                    - *    
                    + *
                      *     - Always validate pointer-id
                      * 
                    *

                    @@ -74,27 +74,27 @@ public class DoubleTapScrollGesture implements GestureHandler { public static final int SCROLL_SLOP_PIXEL; /** Two pointer 'double tap' slop in pixels (fallback), defaults to 104 pixels. Can be overriden by integer property newt.event.double_tap_slop_pixel.*/ public static final int DOUBLE_TAP_SLOP_PIXEL; - + /** Scroll threshold in millimeter, defaults to 3 mm. Can be overriden by integer property newt.event.scroll_slop_mm.*/ public static final float SCROLL_SLOP_MM; /** Two pointer 'double tap' slop in millimeter, defaults to 20 mm. Can be overriden by integer property newt.event.double_tap_slop_mm.*/ public static final float DOUBLE_TAP_SLOP_MM; - + static { Debug.initSingleton(); - + SCROLL_SLOP_PIXEL = Debug.getIntProperty("newt.event.scroll_slop_pixel", true, 16); DOUBLE_TAP_SLOP_PIXEL = Debug.getIntProperty("newt.event.double_tap_slop_pixel", true, 104); SCROLL_SLOP_MM = Debug.getIntProperty("newt.event.scroll_slop_mm", true, 3); DOUBLE_TAP_SLOP_MM = Debug.getIntProperty("newt.event.double_tap_slop_mm", true, 20); } - + private static final int ST_NONE = 0; private static final int ST_1PRESS = 1; private static final int ST_2PRESS_T = 2; private static final int ST_2PRESS_C = 3; private static final int ST_SCROLL = 4; - + private final int scrollSlop, scrollSlopSquare, doubleTapSlop, doubleTapSlopSquare; private final float[] scrollDistance = new float[] { 0f, 0f }; private int[] pIds = new int[] { -1, -1 }; @@ -104,18 +104,18 @@ public class DoubleTapScrollGesture implements GestureHandler { private int lastX, lastY; private int pointerDownCount; private MouseEvent hitGestureEvent; - + private static final int getSquareDistance(float x1, float y1, float x2, float y2) { final int deltaX = (int) x1 - (int) x2; final int deltaY = (int) y1 - (int) y2; return deltaX * deltaX + deltaY * deltaY; } - + private int gesturePointers(final MouseEvent e, final int excludeIndex) { - int j = 0; + int j = 0; for(int i=e.getPointerCount()-1; i>=0; i--) { if( excludeIndex != i ) { - final int id = e.getPointerId(i); + final int id = e.getPointerId(i); if( pIds[0] == id || pIds[1] == id ) { j++; } @@ -123,10 +123,10 @@ public class DoubleTapScrollGesture implements GestureHandler { } return j; } - + /** * scaledScrollSlop < scaledDoubleTapSlop - * @param scaledScrollSlop Distance a pointer can wander before we think the user is scrolling in pixels. + * @param scaledScrollSlop Distance a pointer can wander before we think the user is scrolling in pixels. * @param scaledDoubleTapSlop Distance in pixels between the first touch and second touch to still be considered a double tap. */ public DoubleTapScrollGesture(int scaledScrollSlop, int scaledDoubleTapSlop) { @@ -137,9 +137,9 @@ public class DoubleTapScrollGesture implements GestureHandler { pointerDownCount = 0; clear(true); if(DEBUG) { - System.err.println("DoubleTapScroll scrollSlop (scaled) "+scrollSlop); - System.err.println("DoubleTapScroll doubleTapSlop (scaled) "+doubleTapSlop); - } + System.err.println("DoubleTapScroll scrollSlop (scaled) "+scrollSlop); + System.err.println("DoubleTapScroll doubleTapSlop (scaled) "+doubleTapSlop); + } } public String toString() { @@ -160,17 +160,17 @@ public class DoubleTapScrollGesture implements GestureHandler { lastY = 0; } } - + @Override public boolean isWithinGesture() { return ST_2PRESS_C <= gestureState; } - + @Override public boolean hasGesture() { return null != hitGestureEvent; } - + @Override public InputEvent getGestureEvent() { if( null != hitGestureEvent ) { @@ -184,17 +184,17 @@ public class DoubleTapScrollGesture implements GestureHandler { modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; } return new MouseEvent(MouseEvent.EVENT_MOUSE_WHEEL_MOVED, ge.getSource(), ge.getWhen(), modifiers, - ge.getAllPointerTypes(), ge.getAllPointerIDs(), - ge.getAllX(), ge.getAllY(), ge.getAllPressures(), ge.getMaxPressure(), + ge.getAllPointerTypes(), ge.getAllPointerIDs(), + ge.getAllX(), ge.getAllY(), ge.getAllPressures(), ge.getMaxPressure(), ge.getButton(), ge.getClickCount(), rotationXYZ, scrollSlop); } return null; } - + public final float[] getScrollDistanceXY() { return scrollDistance; } - + @Override public boolean process(final InputEvent in) { if( null != hitGestureEvent || !(in instanceof MouseEvent) ) { @@ -220,7 +220,7 @@ public class DoubleTapScrollGesture implements GestureHandler { final int y1 = pe.getY(1); final int xm = (x0+x1)/2; final int ym = (y0+y1)/2; - + if( ST_1PRESS == gestureState ) { final int sqDist = getSquareDistance(x0, y0, x1, y1); final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; @@ -254,7 +254,7 @@ public class DoubleTapScrollGesture implements GestureHandler { System.err.println(this+".pressed: gPtr "+gPtr+", this "+lastX+"/"+lastY+", "+pe); } } break; - + case MouseEvent.EVENT_MOUSE_RELEASED: { pointerDownCount--; // lifted final int gPtr = gesturePointers(pe, 0); // w/o lifted pointer @@ -269,7 +269,7 @@ public class DoubleTapScrollGesture implements GestureHandler { System.err.println(this+".released: gPtr "+gPtr+", "+pe); } } break; - + case MouseEvent.EVENT_MOUSE_DRAGGED: { if( 2 == pointerDownCount && ST_1PRESS < gestureState ) { final int gPtr = gesturePointers(pe, -1); @@ -289,11 +289,11 @@ public class DoubleTapScrollGesture implements GestureHandler { gestureState = ST_SCROLL; } } break; - + case ST_2PRESS_C: gestureState = ST_SCROLL; break; - + case ST_SCROLL: scrollDistance[0] = lastX - xm; scrollDistance[1] = lastY - ym; @@ -338,7 +338,7 @@ public class DoubleTapScrollGesture implements GestureHandler { } } } break; - + default: } return null != hitGestureEvent; diff --git a/src/newt/classes/com/jogamp/newt/event/GestureHandler.java b/src/newt/classes/com/jogamp/newt/event/GestureHandler.java index 2c8f29bb7..2e98a8a01 100644 --- a/src/newt/classes/com/jogamp/newt/event/GestureHandler.java +++ b/src/newt/classes/com/jogamp/newt/event/GestureHandler.java @@ -30,7 +30,7 @@ package com.jogamp.newt.event; import jogamp.newt.Debug; /** - * Generic gesture handler interface designed to allow pass-through + * Generic gesture handler interface designed to allow pass-through * filtering of {@link InputEvent}s. *

                    * To avoid negative impact on event processing, @@ -44,18 +44,18 @@ import jogamp.newt.Debug; */ public interface GestureHandler { public static final boolean DEBUG = Debug.debug("Window.MouseEvent"); - + /** A custom gesture event */ @SuppressWarnings("serial") public static class GestureEvent extends InputEvent { /** A gesture has been detected. */ public static final short EVENT_GESTURE_DETECTED = 400; - + private final GestureHandler handler; - + /** * Creates a gesture event with default type {@link #EVENT_GESTURE_DETECTED}. - * + * * @param source * @param when * @param modifiers @@ -65,7 +65,7 @@ public interface GestureHandler { super(EVENT_GESTURE_DETECTED, source, when, modifiers); this.handler = handler; } - + /** * Creates a gesture event with custom event_type ! * @param event_type must lie within [400..599] @@ -78,14 +78,14 @@ public interface GestureHandler { super(event_type, source, when, modifiers); this.handler = handler; } - + /** Return the {@link GestureHandler}, which produced the event. */ public final GestureHandler getHandler() { return handler; } } - + /** * Listener for {@link GestureEvent}s. - * + * * @see GestureEvent */ public static interface GestureListener extends NEWTEventListener @@ -93,50 +93,50 @@ public interface GestureHandler { /** {@link GestureHandler} {@link GestureHandler#hasGesture() has detected} the gesture. */ public void gestureDetected(GestureEvent gh); } - - /** - * Clears state of handler, i.e. resets all states incl. previous detected gesture. + + /** + * Clears state of handler, i.e. resets all states incl. previous detected gesture. * @param clearStarted if true, also clears {@link #isWithinGesture() started} state, * otherwise stay within gesture - if appropriate. - * Staying within a gesture allows fluent continuous gesture sequence, - * e.g. for scrolling. + * Staying within a gesture allows fluent continuous gesture sequence, + * e.g. for scrolling. */ public void clear(boolean clearStarted); - - /** + + /** * Returns true if a previous {@link #process(InputEvent)} command produced a gesture, - * which has not been {@link #clear(boolean) cleared}. + * which has not been {@link #clear(boolean) cleared}. * Otherwise returns false. - */ + */ public boolean hasGesture(); - - /** + + /** * Returns the corresponding {@link InputEvent} for the gesture as detected by * a previous {@link #process(InputEvent)}, which has not been {@link #clear(boolean) cleared}. * Otherwise returns null. *

                    * Only implemented for gestures mapping to {@link InputEvent}s. - *

                    - */ + *

                    + */ public InputEvent getGestureEvent(); - - /** + + /** * Returns true if within a gesture as detected by a previous {@link #process(InputEvent)} command, - * which has not been {@link #clear(boolean) cleared}. + * which has not been {@link #clear(boolean) cleared}. * Otherwise returns false. - */ + */ public boolean isWithinGesture(); /** * Process the given {@link InputEvent} and returns true if it produced the gesture. * Otherwise returns false. *

                    - * If a gesture was already detected previously and has not been cleared, - * method does not process the event and returns true. + * If a gesture was already detected previously and has not been cleared, + * method does not process the event and returns true. *

                    *

                    - * Besides validation of the event's details, - * the handler may also validate the {@link InputEvent.InputClass} and/or {@link InputEvent.InputType}. + * Besides validation of the event's details, + * the handler may also validate the {@link InputEvent.InputClass} and/or {@link InputEvent.InputType}. *

                    */ public boolean process(InputEvent e); diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index 1bd67efa5..6520dafcf 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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.event; @@ -43,17 +43,17 @@ public abstract class InputEvent extends NEWTEvent /** Interface marking class of input types */ public static interface InputClass { } - + /** Interface marking type of input devices */ public static interface InputType { } - + 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 << 4; - + public static final int BUTTON1_MASK = 1 << 5; public static final int BUTTON2_MASK = 1 << 6; public static final int BUTTON3_MASK = 1 << 7; @@ -63,23 +63,23 @@ public abstract class InputEvent extends NEWTEvent public static final int BUTTON7_MASK = 1 << 11; public static final int BUTTON8_MASK = 1 << 12; public static final int BUTTON9_MASK = 1 << 13; - + public static final int BUTTONLAST_MASK = 1 << 20; // 16 buttons public static final int BUTTONALL_MASK = 0xffff << 5 ; // 16 buttons - + /** Event is caused by auto-repeat. */ public static final int AUTOREPEAT_MASK = 1 << 29; - + /** Pointer is confined, see {@link Window#confinePointer(boolean)}. */ public static final int CONFINED_MASK = 1 << 30; - + /** Pointer is invisible, see {@link Window#setPointerVisible(boolean)}. */ public static final int INVISIBLE_MASK = 1 << 31; - /** + /** * Returns the corresponding button mask for the given button. *

                    - * In case the given button lies outside + * In case the given button lies outside * of the valid range [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON_COUNT}], * null is returned. *

                    @@ -90,7 +90,7 @@ public abstract class InputEvent extends NEWTEvent } return 0; } - + protected InputEvent(short eventType, Object source, long when, int modifiers) { super(eventType, source, when); this.modifiers=modifiers; @@ -128,11 +128,11 @@ public abstract class InputEvent extends NEWTEvent public boolean isConfined() { return (modifiers&CONFINED_MASK)!=0; } - /** {@link #getModifiers()} contains {@link #INVISIBLE_MASK}. Pointer is invisible, see {@link Window#setPointerVisible(boolean)}. */ + /** {@link #getModifiers()} contains {@link #INVISIBLE_MASK}. Pointer is invisible, see {@link Window#setPointerVisible(boolean)}. */ public boolean isInvisible() { return (modifiers&INVISIBLE_MASK)!=0; } - + public StringBuilder getModifiersString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); @@ -141,7 +141,7 @@ public abstract class InputEvent extends NEWTEvent boolean isFirst = true; if(isShiftDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("shift"); } if(isControlDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("ctrl"); } - if(isMetaDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("meta"); } + if(isMetaDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("meta"); } if(isAltDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("alt"); } if(isAltGraphDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("altgr"); } if(isAutoRepeat()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("repeat"); } @@ -151,18 +151,18 @@ public abstract class InputEvent extends NEWTEvent if(isConfined()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("confined"); } if(isInvisible()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("invisible"); } sb.append("]"); - + return sb; } /** * See also {@link MouseEvent}'s section about Multiple-Pointer Events. - * @return Array of pressed mouse buttons [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON6}]. + * @return Array of pressed mouse buttons [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON6}]. * If none is down, the resulting array is of length 0. */ public final short[] getButtonsDown() { final int len = getButtonDownCount(); - + final short[] res = new short[len]; int j = 0; for(int i=1; i<=MouseEvent.BUTTON_COUNT; i++) { @@ -174,13 +174,13 @@ public abstract class InputEvent extends NEWTEvent /** * See also {@link MouseEvent}'s section about Multiple-Pointer Events. * @param button the button to test - * @return true if the given button is down + * @return true if the given button is down */ public final boolean isButtonDown(int button) { return ( modifiers & getButtonMask(button) ) != 0; } - /** + /** * Returns the number of pressed buttons by counting the set bits: *
                       *     getBitCount(modifiers & BUTTONALL_MASK);
                    @@ -194,8 +194,8 @@ public abstract class InputEvent extends NEWTEvent
                      public final int getButtonDownCount() {
                          return IntBitfield.getBitCount(modifiers & BUTTONALL_MASK);
                      }
                    - 
                    - /** 
                    +
                    + /**
                       * Returns true if at least one button is pressed, otherwise false:
                       * 
                       *     0 != ( modifiers & BUTTONALL_MASK )
                    @@ -209,11 +209,11 @@ public abstract class InputEvent extends NEWTEvent
                      public final boolean isAnyButtonDown() {
                          return 0 != ( modifiers & BUTTONALL_MASK );
                      }
                    - 
                    +
                      public String toString() {
                          return toString(null).toString();
                      }
                    - 
                    +
                      public StringBuilder toString(StringBuilder sb) {
                          if(null == sb) {
                              sb = new StringBuilder();
                    diff --git a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java
                    index 42ebea722..a89148574 100644
                    --- a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java
                    +++ b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java
                    @@ -4,14 +4,14 @@
                      *
                      * Redistribution and use in source and binary forms, with or without modification, are
                      * permitted provided that the following conditions are met:
                    - * 
                    + *
                      *    1. Redistributions of source code must retain the above copyright notice, this list of
                      *       conditions and the following disclaimer.
                    - * 
                    + *
                      *    2. Redistributions 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.
                    - * 
                    + *
                      * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
                      * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
                      * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
                    @@ -21,12 +21,12 @@
                      * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
                      * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
                      * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                    - * 
                    + *
                      * The views and conclusions contained in the software and documentation are those of the
                      * authors and should not be interpreted as representing official policies, either expressed
                      * or implied, of JogAmp Community.
                      */
                    - 
                    +
                     package com.jogamp.newt.event;
                     
                     public abstract class KeyAdapter implements KeyListener
                    diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
                    index 085f598dc..81680bf32 100644
                    --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
                    +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java
                    @@ -1,22 +1,22 @@
                     /*
                      * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
                      * Copyright (c) 2010 JogAmp Community. 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
                    @@ -29,7 +29,7 @@
                      * 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.event;
                    @@ -37,8 +37,8 @@ package com.jogamp.newt.event;
                     import com.jogamp.common.util.IntBitfield;
                     
                     /**
                    - * 
                    KeyEvent Delivery
                    - * + *
                    KeyEvent Delivery
                    + * * Key events are delivered in the following order: *

                    * @@ -48,10 +48,10 @@ import com.jogamp.common.util.IntBitfield; *
                    *

                    * In case the native platform does not - * deliver keyboard events in the above order or skip events, - * the NEWT driver will reorder and inject synthetic events if required. + * deliver keyboard events in the above order or skip events, + * the NEWT driver will reorder and inject synthetic events if required. *

                    - * Besides regular modifiers like {@link InputEvent#SHIFT_MASK} etc., + * Besides regular modifiers like {@link InputEvent#SHIFT_MASK} etc., * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected, following above constraints. *

                    *

                    @@ -60,38 +60,38 @@ import com.jogamp.common.util.IntBitfield; P = pressed, R = released 0 = normal, 1 = auto-repeat - P(0), [ R(1), P(1), R(1), ..], R(0) + P(0), [ R(1), P(1), R(1), ..], R(0) *

                    * The idea is if you mask out auto-repeat in your event listener * you just get one long pressed P/R tuple for {@link #isPrintableKey() printable} and {@link #isActionKey() Action} keys. *

                    *

                    - * {@link #isActionKey() Action} keys will produce {@link #EVENT_KEY_PRESSED pressed} + * {@link #isActionKey() Action} keys will produce {@link #EVENT_KEY_PRESSED pressed} * and {@link #EVENT_KEY_RELEASED released} events including {@link #isAutoRepeat() auto-repeat}. *

                    *

                    * {@link #isPrintableKey() Printable} keys will produce {@link #EVENT_KEY_PRESSED pressed} and {@link #EVENT_KEY_RELEASED released} events. *

                    *

                    - * {@link #isModifierKey() Modifier} keys will produce {@link #EVENT_KEY_PRESSED pressed} and {@link #EVENT_KEY_RELEASED released} events + * {@link #isModifierKey() Modifier} keys will produce {@link #EVENT_KEY_PRESSED pressed} and {@link #EVENT_KEY_RELEASED released} events * excluding {@link #isAutoRepeat() auto-repeat}. * They will also influence subsequent event's {@link #getModifiers() modifier} bits while pressed. *

                    - * + * *
                    Unicode Mapping
                    *

                    - * {@link #getKeyChar() Key-chars}, as well as + * {@link #getKeyChar() Key-chars}, as well as * {@link #isPrintableKey() printable} {@link #getKeyCode() key-codes} and {@link #getKeySymbol() key-symbols} - * use the UTF-16 unicode space w/o collision. - * + * use the UTF-16 unicode space w/o collision. + * *

                    *

                    - * Non-{@link #isPrintableKey() printable} {@link #getKeyCode() key-codes} and {@link #getKeySymbol() key-symbols}, + * Non-{@link #isPrintableKey() printable} {@link #getKeyCode() key-codes} and {@link #getKeySymbol() key-symbols}, * i.e. {@link #isModifierKey() modifier-} and {@link #isActionKey() action-}keys, * are mapped to unicode's control and private range and do not collide w/ {@link #isPrintableKey() printable} unicode values * with the following exception. *

                    - * + * *
                    Unicode Collision
                    *

                    * The following {@link #getKeyCode() Key-code}s and {@link #getKeySymbol() key-symbol}s collide w/ unicode space:
                    @@ -103,9 +103,9 @@ import com.jogamp.common.util.IntBitfield; *

                    * Collision was chosen for {@link #getKeyCode() Key-code} and {@link #getKeySymbol() key-symbol} mapping * to allow a minimal code range, i.e. [0..255]. - * The reduced code range in turn allows the implementation to utilize fast and small lookup tables, - * e.g. to implement a key-press state tracker. - *

                    + * The reduced code range in turn allows the implementation to utilize fast and small lookup tables, + * e.g. to implement a key-press state tracker. + *

                    *
                      * http://www.utf8-chartable.de/unicode-utf8-table.pl
                      * http://www.unicode.org/Public/5.1.0/ucd/PropList.txt
                    @@ -136,7 +136,7 @@ public class KeyEvent extends InputEvent
                                     }
                                 }
                                 flags = _flags;
                    -            
                    +
                                 //
                                 // Validate flags
                                 //
                    @@ -147,12 +147,12 @@ public class KeyEvent extends InputEvent
                                 }
                             }
                         }
                    -    
                    +
                         public static KeyEvent create(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, char keyChar) {
                             return new KeyEvent(eventType, source, when, modifiers, keyCode, keySym, getModifierMask(keySym), keyChar);
                         }
                     
                    -    /** 
                    +    /**
                          * Returns the UTF-16 character reflecting the {@link #getKeySymbol() key symbol}
                          * incl. active {@link #isModifierKey() modifiers}.
                          * @see #getKeySymbol()
                    @@ -162,12 +162,12 @@ public class KeyEvent extends InputEvent
                             return keyChar;
                         }
                     
                    -    /** 
                    +    /**
                          * Returns the virtual key symbol reflecting the current keyboard layout.
                          * 

                    * For {@link #isPrintableKey() printable keys}, the key symbol is the {@link #isModifierKey() unmodified} - * representation of the UTF-16 {@link #getKeyChar() key char}.
                    - * E.g. symbol [{@link #VK_A}, 'A'] for char 'a'. + * representation of the UTF-16 {@link #getKeyChar() key char}.
                    + * E.g. symbol [{@link #VK_A}, 'A'] for char 'a'. *

                    * @see #isPrintableKey() * @see #getKeyChar() @@ -176,18 +176,18 @@ public class KeyEvent extends InputEvent public final short getKeySymbol() { return keySym; } - - /** + + /** * Returns the virtual key code using a fixed mapping to the US keyboard layout. *

                    - * In contrast to {@link #getKeySymbol() key symbol}, key code - * uses a fixed US keyboard layout and therefore is keyboard layout independent. + * In contrast to {@link #getKeySymbol() key symbol}, key code + * uses a fixed US keyboard layout and therefore is keyboard layout independent. *

                    *

                    - * E.g. virtual key code {@link #VK_Y} denotes the same physical key - * regardless whether keyboard layout QWERTY or + * E.g. virtual key code {@link #VK_Y} denotes the same physical key + * regardless whether keyboard layout QWERTY or * QWERTZ is active. The {@link #getKeySymbol() key symbol} of the former is - * {@link #VK_Y}, where the latter produces {@link #VK_Y}. + * {@link #VK_Y}, where the latter produces {@link #VK_Y}. *

                    * @see #getKeyChar() * @see #getKeySymbol() @@ -228,9 +228,9 @@ public class KeyEvent extends InputEvent } return (short) keyChar; } - - /** - * Returns true if the given virtualKey represents a modifier key, otherwise false. + + /** + * Returns true if the given virtualKey represents a modifier key, otherwise false. *

                    * A modifier key is one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. *

                    @@ -247,10 +247,10 @@ public class KeyEvent extends InputEvent return false; } } - + /** * If vKey is a {@link #isModifierKey() modifier key}, method returns the corresponding modifier mask, - * otherwise 0. + * otherwise 0. */ public static int getModifierMask(short vKey) { switch (vKey) { @@ -266,10 +266,10 @@ public class KeyEvent extends InputEvent } return 0; } - - /** + + /** * Returns true if {@link #getKeySymbol() key symbol} represents a modifier key, - * otherwise false. + * otherwise false. *

                    * See {@link #isModifierKey(short)} for details. *

                    @@ -280,8 +280,8 @@ public class KeyEvent extends InputEvent public final boolean isModifierKey() { return 0 != ( F_MODIFIER_MASK & flags ) ; } - - /** + + /** * Returns true if {@link #getKeySymbol() key symbol} represents a non-printable and * non-{@link #isModifierKey(short) modifier} action key, otherwise false. *

                    @@ -289,12 +289,12 @@ public class KeyEvent extends InputEvent * A = U - ( P + M ) *

                    * @see #isPrintableKey() - * @see #isModifierKey() + * @see #isModifierKey() */ public final boolean isActionKey() { return 0 != ( F_ACTION_MASK & flags ) ; } - + /** * Returns true if given uniChar represents a printable character, * i.e. a value other than {@link #VK_UNDEFINED} and not a control or non-printable private code. @@ -307,7 +307,7 @@ public class KeyEvent extends InputEvent *

                    * Distinction of key character and virtual key code is made due to unicode collision. *

                    - * + * * @param uniChar the UTF-16 unicode value, which maybe a virtual key code or key character. * @param isKeyChar true if uniChar is a key character, otherwise a virtual key code */ @@ -333,9 +333,9 @@ public class KeyEvent extends InputEvent return VK_UNDEFINED != uniChar; } - /** - * Returns true if {@link #getKeySymbol() key symbol} and {@link #getKeyChar() key char} - * represents a printable character, i.e. a value other than {@link #VK_UNDEFINED} + /** + * Returns true if {@link #getKeySymbol() key symbol} and {@link #getKeyChar() key char} + * represents a printable character, i.e. a value other than {@link #VK_UNDEFINED} * and not a control or non-printable private code. *

                    * A printable character is neither a {@link #isModifierKey(short) modifier key}, nor an {@link #isActionKey(short) action key}. @@ -347,7 +347,7 @@ public class KeyEvent extends InputEvent public final boolean isPrintableKey() { return 0 != ( F_PRINTABLE_MASK & flags ) ; } - + private final short keyCode; private final short keySym; private final char keyChar; @@ -370,7 +370,7 @@ public class KeyEvent extends InputEvent public static class NonPrintableRange { /** min. unicode value, inclusive */ - public short min; + public short min; /** max. unicode value, inclusive */ public short max; /** true if valid for keyChar values as well, otherwise only valid for keyCode and keySym due to collision. */ @@ -381,7 +381,7 @@ public class KeyEvent extends InputEvent this.inclKeyChar = inclKeyChar; } }; - /** + /** * Non printable key ranges, currently fixed to an array of size 4. *

                    * Not included, queried upfront: @@ -390,98 +390,98 @@ public class KeyEvent extends InputEvent *

                  • {@link #VK_TAB}
                  • *
                  • {@link #VK_ENTER}
                  • * - *

                    + *

                    */ - public final static NonPrintableRange[] nonPrintableKeys = { + public final static NonPrintableRange[] nonPrintableKeys = { new NonPrintableRange( (short)0x0000, (short)0x001F, true ), // Unicode: Non printable controls: [0x00 - 0x1F], see exclusion above new NonPrintableRange( (short)0x0061, (short)0x0078, false), // Small 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym - Re-used for Fn (collision) - new NonPrintableRange( (short)0x008F, (short)0x009F, true ), // Unicode: Non printable controls: [0x7F - 0x9F], Numpad keys [0x7F - 0x8E] are printable! + new NonPrintableRange( (short)0x008F, (short)0x009F, true ), // Unicode: Non printable controls: [0x7F - 0x9F], Numpad keys [0x7F - 0x8E] are printable! new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) }; - + // // Unicode: Non printable controls: [0x00 - 0x1F] // - + /** * This value, {@value}, is used to indicate that the keyCode is unknown. */ public static final short VK_UNDEFINED = (short) 0x0; - + static final short VK_FREE01 = (short) 0x01; - + /** Constant for the HOME function key. ASCII: Start Of Text. */ public static final short VK_HOME = (short) 0x02; - + /** Constant for the END function key. ASCII: End Of Text. */ public static final short VK_END = (short) 0x03; - + /** Constant for the END function key. ASCII: End Of Transmission. */ public static final short VK_FINAL = (short) 0x04; /** Constant for the PRINT function key. ASCII: Enquiry. */ public static final short VK_PRINTSCREEN = (short) 0x05; - + static final short VK_FREE06 = (short) 0x06; static final short VK_FREE07 = (short) 0x07; - + /** Constant for the BACK SPACE key "\b", matching ASCII. Printable! */ public static final short VK_BACK_SPACE = (short) 0x08; - + /** Constant for the HORIZ TAB key "\t", matching ASCII. Printable! */ public static final short VK_TAB = (short) 0x09; - + /** LINE_FEED "\n", matching ASCII, n/a on keyboard. */ static final short VK_FREE0A = (short) 0x0A; - + /** Constant for the PAGE DOWN function key. ASCII: Vertical Tabulation. */ public static final short VK_PAGE_DOWN = (short) 0x0B; - + /** Constant for the CLEAR key, i.e. FORM FEED, matching ASCII. */ public static final short VK_CLEAR = (short) 0x0C; - + /** Constant for the ENTER key, i.e. CARRIAGE RETURN, matching ASCII. Printable! */ public static final short VK_ENTER = (short) 0x0D; - + static final short VK_FREE0E = (short) 0x0E; - + /** Constant for the CTRL function key. ASCII: shift-in. */ public static final short VK_SHIFT = (short) 0x0F; /** Constant for the PAGE UP function key. ASCII: Data Link Escape. */ public static final short VK_PAGE_UP = (short) 0x10; - + /** Constant for the CTRL function key. ASCII: device-ctrl-one. */ public static final short VK_CONTROL = (short) 0x11; - + /** Constant for the left ALT function key. ASCII: device-ctrl-two. */ public static final short VK_ALT = (short) 0x12; - + /** Constant for the ALT_GRAPH function key, i.e. right ALT key. ASCII: device-ctrl-three. */ public static final short VK_ALT_GRAPH = (short) 0x13; - + /** Constant for the CAPS LOCK function key. ASCII: device-ctrl-four. */ public static final short VK_CAPS_LOCK = (short) 0x14; - + static final short VK_FREE15 = (short) 0x15; - + /** Constant for the PAUSE function key. ASCII: sync-idle. */ public static final short VK_PAUSE = (short) 0x16; - + /** scroll lock key. ASCII: End Of Transmission Block. */ public static final short VK_SCROLL_LOCK = (short) 0x17; - + /** Constant for the CANCEL function key. ASCII: Cancel. */ public static final short VK_CANCEL = (short) 0x18; - + static final short VK_FREE19 = (short) 0x19; - + /** Constant for the INSERT function key. ASCII: Substitute. */ public static final short VK_INSERT = (short) 0x1A; - + /** Constant for the ESCAPE function key. ASCII: Escape. */ public static final short VK_ESCAPE = (short) 0x1B; - + /** Constant for the Convert function key, Japanese "henkan". ASCII: File Separator. */ public static final short VK_CONVERT = (short) 0x1C; @@ -496,48 +496,48 @@ public class KeyEvent extends InputEvent // // Unicode: Printable [0x20 - 0x7E] - // NOTE: Collision of 'a' - 'x' [0x61 .. 0x78], used for keyCode/keySym Fn function keys + // NOTE: Collision of 'a' - 'x' [0x61 .. 0x78], used for keyCode/keySym Fn function keys // - + /** Constant for the SPACE function key. ASCII: SPACE. */ public static final short VK_SPACE = (short) 0x20; - + /** Constant for the "!" key. */ public static final short VK_EXCLAMATION_MARK = (short) 0x21; /** Constant for the """ key. */ public static final short VK_QUOTEDBL = (short) 0x22; - + /** Constant for the "#" key. */ public static final short VK_NUMBER_SIGN = (short) 0x23; /** Constant for the "$" key. */ public static final short VK_DOLLAR = (short) 0x24; - + /** Constant for the "%" key. */ public static final short VK_PERCENT = (short) 0x25; - + /** Constant for the "&" key. */ public static final short VK_AMPERSAND = (short) 0x26; - + /** Constant for the "'" key. */ public static final short VK_QUOTE = (short) 0x27; - + /** Constant for the "(" key. */ public static final short VK_LEFT_PARENTHESIS = (short) 0x28; - + /** Constant for the ")" key. */ public static final short VK_RIGHT_PARENTHESIS = (short) 0x29; - + /** Constant for the "*" key */ public static final short VK_ASTERISK = (short) 0x2A; - + /** Constant for the "+" key. */ public static final short VK_PLUS = (short) 0x2B; - + /** Constant for the comma key, "," */ public static final short VK_COMMA = (short) 0x2C; - + /** Constant for the minus key, "-" */ public static final short VK_MINUS = (short) 0x2D; @@ -582,13 +582,13 @@ public class KeyEvent extends InputEvent /** Constant for the equals key, ">" */ public static final short VK_GREATER = (short) 0x3E; - + /** Constant for the equals key, "?" */ public static final short VK_QUESTIONMARK = (short) 0x3F; - + /** Constant for the equals key, "@" */ public static final short VK_AT = (short) 0x40; - + /** VK_A thru VK_Z are the same as Capital UTF16/ASCII 'A' thru 'Z' (0x41 - 0x5A) */ public static final short VK_A = (short) 0x41; /** See {@link #VK_A}. */ @@ -656,17 +656,17 @@ public class KeyEvent extends InputEvent /** Constant for the "_" key */ public static final short VK_UNDERSCORE = (short) 0x5F; - + /** Constant for the "`" key */ public static final short VK_BACK_QUOTE = (short) 0x60; - + /** Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym. */ - - /** - * Constant for the Fn function keys. + + /** + * Constant for the Fn function keys. *

                    * F1..F24, i.e. Fn, are mapped from on 0x60+n -> [0x61 .. 0x78]. - *

                    + *

                    *

                    * Warning: The Fn function keys do collide with unicode characters small 'a' thru 'x'!
                    * See Unicode Collision for details. @@ -743,26 +743,26 @@ public class KeyEvent extends InputEvent /** Constant for the F24 function key. See {@link #VK_F1}. */ public static final short VK_F24 = (short) ( 0x60+24 ); - + /** Constant for the "{" key */ public static final short VK_LEFT_BRACE = (short) 0x7B; /** Constant for the "|" key */ public static final short VK_PIPE = (short) 0x7C; /** Constant for the "}" key */ public static final short VK_RIGHT_BRACE = (short) 0x7D; - + /** Constant for the "~" key, matching ASCII */ public static final short VK_TILDE = (short) 0x7E; - + // // Unicode: Non printable controls: [0x7F - 0x9F] // // Numpad keys [0x7F - 0x8E] are printable // - + /** Numeric keypad decimal separator key. Non printable UTF control. */ public static final short VK_SEPARATOR = (short) 0x7F; - + /** Numeric keypad VK_NUMPAD0 thru VK_NUMPAD9 are mapped to UTF control (0x80 - 0x89). Non printable UTF control. */ public static final short VK_NUMPAD0 = (short) 0x80; /** See {@link #VK_NUMPAD0}. */ @@ -783,28 +783,28 @@ public class KeyEvent extends InputEvent public static final short VK_NUMPAD8 = (short) 0x88; /** See {@link #VK_NUMPAD0}. */ public static final short VK_NUMPAD9 = (short) 0x89; - + /** Numeric keypad decimal separator key. Non printable UTF control. */ public static final short VK_DECIMAL = (short) 0x8A; - + /** Numeric keypad add key. Non printable UTF control. */ public static final short VK_ADD = (short) 0x8B; /** Numeric keypad subtract key. Non printable UTF control. */ public static final short VK_SUBTRACT = (short) 0x8C; - + /** Numeric keypad multiply key. Non printable UTF control. */ public static final short VK_MULTIPLY = (short) 0x8D; - + /** Numeric keypad divide key. Non printable UTF control. */ public static final short VK_DIVIDE = (short) 0x8E; - + /** Constant for the DEL key, matching ASCII. Non printable UTF control. */ public static final short VK_DELETE = (short) 0x93; - + /** Numeric keypad num lock key. Non printable UTF control. */ public static final short VK_NUM_LOCK = (short) 0x94; - + /** Constant for the cursor- or numerical-pad left arrow key. Non printable UTF control. */ public static final short VK_LEFT = (short) 0x95; @@ -816,22 +816,22 @@ public class KeyEvent extends InputEvent /** Constant for the cursor- or numerical pad down arrow key. Non printable UTF control. */ public static final short VK_DOWN = (short) 0x98; - + /** Constant for the Context Menu key. Non printable UTF control. */ public static final short VK_CONTEXT_MENU = (short) 0x99; /** * Constant for the MS "Windows" function key. - * It is used for both the left and right version of the key. + * It is used for both the left and right version of the key. */ public static final short VK_WINDOWS = (short) 0x9A; /** Constant for the Meta function key. */ public static final short VK_META = (short) 0x9B; - + /** Constant for the Help function key. */ public static final short VK_HELP = (short) 0x9C; - + /** Constant for the Compose function key. */ public static final short VK_COMPOSE = (short) 0x9D; @@ -840,21 +840,21 @@ public class KeyEvent extends InputEvent /** Constant for the Stop function key. */ public static final short VK_STOP = (short) 0x9F; - + // // Unicode: Printable [0x00A0 - 0xDFFF] // - + /** Constant for the inverted exclamation mark key. */ public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0xA1; - + /** Constant for the Euro currency sign key. */ public static final short VK_EURO_SIGN = (short) 0x20AC; // // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) // - + /* for Sun keyboards */ public static final short VK_CUT = (short) 0xF879; public static final short VK_COPY = (short) 0xF87A; @@ -871,7 +871,7 @@ public class KeyEvent extends InputEvent */ /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */ public static final short VK_INPUT_METHOD_ON_OFF = (short) 0xF890; - + /** * Constant for the Code Input function key. */ diff --git a/src/newt/classes/com/jogamp/newt/event/KeyListener.java b/src/newt/classes/com/jogamp/newt/event/KeyListener.java index b3927d81a..4b16ab61e 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyListener.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyListener.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,22 +29,22 @@ * 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.event; /** * Listener for {@link KeyEvent}s. - * + * * @see KeyEvent */ public interface KeyListener extends NEWTEventListener { /** A key has been {@link KeyEvent#EVENT_KEY_PRESSED pressed}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */ public void keyPressed(KeyEvent e); - - /** + + /** * A key has been {@link KeyEvent#EVENT_KEY_RELEASED released}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. *

                    * To simulated the removed keyTyped(KeyEvent e) semantics, @@ -52,9 +52,9 @@ public interface KeyListener extends NEWTEventListener *

                             if( !e.isPrintableKey() || e.isAutoRepeat() ) {
                                 return;
                    -        }            
                    +        }
                          * 
                    - *

                    + *

                    */ public void keyReleased(KeyEvent e); } diff --git a/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java b/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java index c47936a7a..77c66a2da 100644 --- a/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java @@ -35,19 +35,19 @@ import com.jogamp.newt.MonitorMode; public class MonitorEvent extends OutputEvent { public static final short EVENT_MONITOR_MODE_CHANGE_NOTIFY = 600; public static final short EVENT_MONITOR_MODE_CHANGED = 601; - + private final MonitorMode mode; - + public MonitorEvent (short eventType, MonitorDevice source, long when, MonitorMode mode) { super(eventType, source, when); this.mode = mode; } - + /** Returns the {@link #getSource() source}, which is a {@link MonitorDevice}. */ public final MonitorDevice getMonitor() { return (MonitorDevice)source; } - + public final MonitorMode getMode() { return mode; } - + public static String getEventTypeString(short type) { switch(type) { case EVENT_MONITOR_MODE_CHANGE_NOTIFY: return "EVENT_MONITOR_MODE_CHANGE_NOTIFY"; @@ -55,7 +55,7 @@ public class MonitorEvent extends OutputEvent { default: return "unknown (" + type + ")"; } } - + public final String toString() { return toString(null).toString(); } diff --git a/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java index 3607ae634..652f87d5b 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.newt.event; public abstract class MouseAdapter implements MouseListener diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 57dd7e68c..4d7cc3b36 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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.event; @@ -37,12 +37,12 @@ package com.jogamp.newt.event; /** * Pointer event of type {@link PointerType}. *

                    - * The historical misleading class name may change in the future to PointerEvent. + * The historical misleading class name may change in the future to PointerEvent. *

                    *

                    * http://www.w3.org/Submission/pointer-events/#pointerevent-interface *

                    - *
                    Multiple-Pointer Events
                    + *
                    Multiple-Pointer Events
                    *

                    * In case an instance represents a multiple-pointer event, i.e. {@link #getPointerCount()} is > 1, * the first data element of the multiple-pointer fields represents the pointer triggering this event.
                    @@ -62,10 +62,10 @@ package com.jogamp.newt.event; *

                    *

                    * If representing a multiple-pointer event, the {@link #getButton() button number} is mapped to the first {@link #getPointerId(int) pointer ID} - * triggering the event and the {@link InputEvent#BUTTON1_MASK button mask bits} in the {@link #getModifiers() modifiers} + * triggering the event and the {@link InputEvent#BUTTON1_MASK button mask bits} in the {@link #getModifiers() modifiers} * field represent the pressed pointer IDs.
                    * Hence users can query the pressed button count as well as the pressed pointer count via {@link InputEvent#getButtonDownCount()} - * or use the simple query {@link InputEvent#isAnyButtonDown()}. + * or use the simple query {@link InputEvent#isAnyButtonDown()}. *

                    */ @SuppressWarnings("serial") @@ -75,7 +75,7 @@ public class MouseEvent extends InputEvent public static enum PointerClass implements InputEvent.InputClass { Offscreen, Onscreen, Undefined; } - + /** Type of pointer devices */ public static enum PointerType implements InputEvent.InputType { /** {@link PointerClass#Offscreen} mouse. Ordinal 0. */ @@ -88,10 +88,10 @@ public class MouseEvent extends InputEvent Pen(PointerClass.Onscreen), /** {@link PointerClass#Undefined} ?. Ordinal 4. */ Undefined(PointerClass.Undefined); - + public PointerClass getPointerClass() { return pc; } - - /** + + /** * Returns the matching PointerType value corresponding to the given PointerType's integer ordinal. *
                              *   given:
                    @@ -108,8 +108,8 @@ public class MouseEvent extends InputEvent
                                 }
                                 throw new IllegalArgumentException("Ordinal "+ordinal+" out of range of PointerType.values()[0.."+(all.length-1)+"]");
                             }
                    -        
                    -        /** 
                    +
                    +        /**
                              * Returns the PointerType array of matching PointerType values corresponding to the given PointerType's integer ordinal values.
                              * 

                    * See {@link #valueOf(int)}. @@ -124,13 +124,13 @@ public class MouseEvent extends InputEvent } return types; } - + private PointerType(PointerClass pc) { this.pc = pc; } PointerClass pc; } - + /** ID for button 1, value 1 */ public static final short BUTTON1 = 1; /** ID for button 2, value 2 */ @@ -149,17 +149,17 @@ public class MouseEvent extends InputEvent public static final short BUTTON8 = 8; /** ID for button 6, value 9 */ public static final short BUTTON9 = 9; - + /** Maximum number of buttons, value 16 */ public static final short BUTTON_COUNT = 16; - /** + /** * Maximum number of buttons, value 16. * @deprecated Use {@link #BUTTON_COUNT} .. semantics. */ public static final short BUTTON_NUMBER = 16; - - /** Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods). */ + + /** Returns the 3-axis XYZ rotation array by given rotation on Y axis or X axis (if SHIFT_MASK is given in mods). */ public static final float[] getRotationXYZ(final float rotationXorY, final int mods) { final float[] rotationXYZ = new float[] { 0f, 0f, 0f }; if( 0 != ( mods & InputEvent.SHIFT_MASK ) ) { @@ -169,14 +169,14 @@ public class MouseEvent extends InputEvent } return rotationXYZ; } - - public static final short getClickTimeout() { - return 300; + + public static final short getClickTimeout() { + return 300; } - - /** + + /** * Constructor for traditional one-pointer event. - * + * * @param eventType * @param source * @param when @@ -193,7 +193,7 @@ public class MouseEvent extends InputEvent int modifiers, int x, int y, short clickCount, short button, float[] rotationXYZ, float rotationScale) { - super(eventType, source, when, modifiers); + super(eventType, source, when, modifiers); this.x = new int[]{x}; this.y = new int[]{y}; switch(eventType) { @@ -214,15 +214,15 @@ public class MouseEvent extends InputEvent this.pointerType = constMousePointerTypes; } - /** + /** * Constructor for a multiple-pointer event. *

                    * First element of multiple-pointer arrays represents the pointer which triggered the event! *

                    - *

                    + *

                    * See details for multiple-pointer events. *

                    - * + * * @param eventType * @param source * @param when @@ -239,12 +239,12 @@ public class MouseEvent extends InputEvent * @param rotationXYZ Rotation of all axis * @param rotationScale Rotation scale */ - public MouseEvent(short eventType, Object source, long when, int modifiers, - PointerType pointerType[], short[] pointerID, - int[] x, int[] y, float[] pressure, float maxPressure, + public MouseEvent(short eventType, Object source, long when, int modifiers, + PointerType pointerType[], short[] pointerID, + int[] x, int[] y, float[] pressure, float maxPressure, short button, short clickCount, float[] rotationXYZ, float rotationScale) { - super(eventType, source, when, modifiers); + super(eventType, source, when, modifiers); this.x = x; this.y = y; final int pointerCount = pointerType.length; @@ -266,12 +266,12 @@ public class MouseEvent extends InputEvent this.rotationScale = rotationScale; this.pointerType = pointerType; } - + public MouseEvent createVariant(short newEventType) { return new MouseEvent(newEventType, source, getWhen(), getModifiers(), pointerType, pointerID, x, y, pressure, maxPressure, button, clickCount, rotationXYZ, rotationScale); } - + /** * See details for multiple-pointer events. * @return the count of pointers involved in this event @@ -279,7 +279,7 @@ public class MouseEvent extends InputEvent public final int getPointerCount() { return pointerType.length; } - + /** * See details for multiple-pointer events. * @return the {@link PointerType} for the data at index or null if index not available. @@ -290,7 +290,7 @@ public class MouseEvent extends InputEvent } return pointerType[index]; } - + /** * See details for multiple-pointer events. * @return array of all {@link PointerType}s for all pointers @@ -298,10 +298,10 @@ public class MouseEvent extends InputEvent public final PointerType[] getAllPointerTypes() { return pointerType; } - + /** * Return the pointer id for the given index or -1 if index not available. - *

                    + *

                    * IDs start w/ 0 and are consecutive numbers. *

                    *

                    @@ -317,7 +317,7 @@ public class MouseEvent extends InputEvent } return pointerID[index]; } - + /** * See details for multiple-pointer events. * @return the pointer index for the given pointer id or -1 if id not available. @@ -332,7 +332,7 @@ public class MouseEvent extends InputEvent } return -1; } - + /** * See details for multiple-pointer events. * @return array of all pointer IDs for all pointers. IDs start w/ 0 and are consecutive numbers. @@ -340,15 +340,15 @@ public class MouseEvent extends InputEvent public final short[] getAllPointerIDs() { return pointerID; } - - /** + + /** * Returns the button number, e.g. [{@link #BUTTON1}..{@link #BUTTON_COUNT}-1]. *

                    * A button value of 0 denotes no button activity, i.e. {@link PointerType#Mouse} move. *

                    *

                    * See details for multiple-pointer events. - *

                    + *

                    */ public final short getButton() { return button; @@ -357,16 +357,16 @@ public class MouseEvent extends InputEvent public final short getClickCount() { return clickCount; } - + public final int getX() { return x[0]; } - + public final int getY() { return y[0]; } - /** + /** * See details for multiple-pointer events. * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] * @return X-Coord associated with the pointer-index. @@ -376,7 +376,7 @@ public class MouseEvent extends InputEvent return x[index]; } - /** + /** * See details for multiple-pointer events. * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] * @return Y-Coord associated with the pointer-index. @@ -385,7 +385,7 @@ public class MouseEvent extends InputEvent public final int getY(int index) { return y[index]; } - + /** * See details for multiple-pointer events. * @return array of all X-Coords for all pointers @@ -393,7 +393,7 @@ public class MouseEvent extends InputEvent public final int[] getAllX() { return x; } - + /** * See details for multiple-pointer events. * @return array of all Y-Coords for all pointers @@ -401,9 +401,9 @@ public class MouseEvent extends InputEvent public final int[] getAllY() { return y; } - + /** - * @param normalized if true, method returns the normalized pressure, i.e. pressure / maxPressure + * @param normalized if true, method returns the normalized pressure, i.e. pressure / maxPressure * @return The pressure associated with the pointer-index 0. * The value of zero is return if not available. * @see #getMaxPressure() @@ -411,11 +411,11 @@ public class MouseEvent extends InputEvent public final float getPressure(boolean normalized){ return normalized ? pressure[0] / maxPressure : pressure[0]; } - + /** * See details for multiple-pointer events. * @param index pointer-index within [0 .. {@link #getPointerCount()}-1] - * @param normalized if true, method returns the normalized pressure, i.e. pressure / maxPressure + * @param normalized if true, method returns the normalized pressure, i.e. pressure / maxPressure * @return The pressure associated with the pointer-index. * The value of zero is return if not available. * @see #getMaxPressure() @@ -423,7 +423,7 @@ public class MouseEvent extends InputEvent public final float getPressure(int index, boolean normalized){ return normalized ? pressure[index] / maxPressure : pressure[index]; } - + /** * See details for multiple-pointer events. * @return array of all raw, un-normalized pressures for all pointers @@ -431,12 +431,12 @@ public class MouseEvent extends InputEvent public final float[] getAllPressures() { return pressure; } - - /** + + /** * Returns the maximum pressure known for the input device generating this event. *

                    * This value may be self calibrating on devices/OS, where no known maximum pressure is known. - * Hence subsequent events may return a higher value. + * Hence subsequent events may return a higher value. *

                    *

                    * Self calibrating maximum pressure is performed on: @@ -448,25 +448,25 @@ public class MouseEvent extends InputEvent public final float getMaxPressure() { return maxPressure; } - + /** * Returns a 3-component float array filled with the values of the rotational axis * in the following order: horizontal-, vertical- and z-axis. - *

                    + *

                    * A vertical rotation of > 0.0f is up and < 0.0f is down. *

                    *

                    - * A horizontal rotation of > 0.0f is left and < 0.0f is right. + * A horizontal rotation of > 0.0f is left and < 0.0f is right. *

                    *

                    - * A z-axis rotation of > 0.0f is back and < 0.0f is front. + * A z-axis rotation of > 0.0f is back and < 0.0f is front. *

                    *

                    * However, on some OS this might be flipped due to the OS default behavior. * The latter is true for OS X 10.7 (Lion) for example. *

                    *

                    - * On PointerClass {@link PointerClass#Onscreen onscreen} devices, i.e. {@link PointerType#TouchScreen touch screens}, + * On PointerClass {@link PointerClass#Onscreen onscreen} devices, i.e. {@link PointerType#TouchScreen touch screens}, * rotation events are usually produced by a 2-finger movement, where horizontal and vertical rotation values are filled. *

                    *

                    @@ -475,13 +475,13 @@ public class MouseEvent extends InputEvent *

                    *

                    * The {@link InputEvent#SHIFT_MASK} modifier is set in case |horizontal| > |vertical| value.
                    - * This can be utilized to implement only one 2d rotation direction, you may use {@link #isShiftDown()} to query it. + * This can be utilized to implement only one 2d rotation direction, you may use {@link #isShiftDown()} to query it. *

                    *

                    * In case the pointer type is {@link PointerType#Mouse mouse}, * events are usually send in steps of one, ie. -1.0f and 1.0f. * Higher values may result due to fast scrolling. - * Fractional values may result due to slow scrolling with high resolution devices.
                    + * Fractional values may result due to slow scrolling with high resolution devices.
                    * Here the button number refers to the wheel number. *

                    *

                    @@ -492,24 +492,24 @@ public class MouseEvent extends InputEvent public final float[] getRotation() { return rotationXYZ; } - - /** + + /** * Returns the scale used to determine the {@link #getRotation() rotation value}, * which semantics depends on the {@link #getPointerType() pointer type's} {@link PointerClass}. *

                    * For {@link PointerClass#Offscreen}, the scale is usually 1.0f and denominates * an abstract value without association to a physical value. - *

                    + *

                    *

                    * For {@link PointerClass#Onscreen}, the scale varies and denominates - * the divisor of the distance the finger[s] have moved on the screen. - * Hence scale * rotation reproduces the screen distance in pixels the finger[s] have moved. - *

                    + * the divisor of the distance the finger[s] have moved on the screen. + * Hence scale * rotation reproduces the screen distance in pixels the finger[s] have moved. + *

                    */ public final float getRotationScale() { return rotationScale; } - + public final String toString() { return toString(null).toString(); } @@ -533,7 +533,7 @@ public class MouseEvent extends InputEvent .append("p[").append(pressure[i]).append("/").append(maxPressure).append("=").append(pressure[i]/maxPressure).append("]"); } sb.append("]"); - } + } sb.append(", "); return super.toString(sb).append("]"); } @@ -551,14 +551,14 @@ public class MouseEvent extends InputEvent default: return "unknown (" + type + ")"; } } - + /** PointerType for each pointer (multiple pointer) */ private final PointerType pointerType[]; - /** + /** * Pointer-ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. - *

                    + *

                    * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move. - *

                    + *

                    */ private final short pointerID[]; /** X-axis for each pointer (multiple pointer) */ @@ -581,11 +581,11 @@ public class MouseEvent extends InputEvent /** Rotation scale */ private final float rotationScale; private final float maxPressure; - + private static final float[] constMousePressure0 = new float[]{0f}; private static final float[] constMousePressure1 = new float[]{1f}; private static final PointerType[] constMousePointerTypes = new PointerType[] { PointerType.Mouse }; - + public static final short EVENT_MOUSE_CLICKED = 200; public static final short EVENT_MOUSE_ENTERED = 201; public static final short EVENT_MOUSE_EXITED = 202; diff --git a/src/newt/classes/com/jogamp/newt/event/MouseListener.java b/src/newt/classes/com/jogamp/newt/event/MouseListener.java index ce6796081..5378080b9 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseListener.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseListener.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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.event; @@ -38,7 +38,7 @@ import com.jogamp.newt.event.MouseEvent.PointerType; /** * Listener for {@link MouseEvent}s. - * + * * @see MouseEvent */ public interface MouseListener extends NEWTEventListener @@ -50,13 +50,13 @@ public interface MouseListener extends NEWTEventListener public void mouseReleased(MouseEvent e); public void mouseMoved(MouseEvent e); public void mouseDragged(MouseEvent e); - + /** * Traditional event name originally produced by a {@link PointerType#Mouse mouse} pointer type. *

                    * Triggered for any rotational pointer events, see - * {@link MouseEvent#getRotation()} and {@link MouseEvent#getRotationScale()}. - *

                    + * {@link MouseEvent#getRotation()} and {@link MouseEvent#getRotationScale()}. + *

                    */ public void mouseWheelMoved(MouseEvent e); } diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index 02bb4f929..022e2d0e1 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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.event; @@ -50,7 +50,7 @@ package com.jogamp.newt.event; */ @SuppressWarnings("serial") public class NEWTEvent extends java.util.EventObject { - /** + /** * See {@link #setConsumed(boolean)} for description. */ public static final Object consumedTag = new Object(); @@ -78,11 +78,11 @@ public class NEWTEvent extends java.util.EventObject { return when; } - /** + /** * Attach the passed object to this event.
                    * If an object was previously attached, it will be replaced.
                    * Attachments to NEWT events allow users to pass on information - * from one custom listener to another, ie custom listener to listener + * from one custom listener to another, ie custom listener to listener * communication. * @param attachment User application specific object */ @@ -90,14 +90,14 @@ public class NEWTEvent extends java.util.EventObject { this.attachment = attachment; } - /** + /** * @return The user application specific attachment, or null */ public final Object getAttachment() { return attachment; } - - /** + + /** * Returns true if this events has been {@link #setConsumed(boolean) consumed}, * otherwise false. * @see #setConsumed(boolean) @@ -105,8 +105,8 @@ public class NEWTEvent extends java.util.EventObject { public final boolean isConsumed() { return consumedTag == attachment; } - - /** + + /** * If consumed is true, this event is marked as consumed, * ie. the event will not be propagated any further to potential other event listener. * Otherwise the event will be propagated to other event listener, the default. @@ -130,7 +130,7 @@ public class NEWTEvent extends java.util.EventObject { setAttachment( null ); } } - + public String toString() { return toString(null).toString(); } diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEventConsumer.java b/src/newt/classes/com/jogamp/newt/event/NEWTEventConsumer.java index 6aa19e5f8..14fba6742 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEventConsumer.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEventConsumer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,18 +20,18 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.newt.event; public interface NEWTEventConsumer { - /** - * Consume the event + /** + * Consume the event * * @return true if the event has been consumed, * otherwise it returns false for later propagation. diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java b/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java index fe224bba6..7dd56ad1e 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEventFiFo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.newt.event; import java.util.LinkedList; diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEventListener.java b/src/newt/classes/com/jogamp/newt/event/NEWTEventListener.java index 677136573..f7ee3d739 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEventListener.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEventListener.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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.event; diff --git a/src/newt/classes/com/jogamp/newt/event/OutputEvent.java b/src/newt/classes/com/jogamp/newt/event/OutputEvent.java index 86fa95877..80c7780f8 100644 --- a/src/newt/classes/com/jogamp/newt/event/OutputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/OutputEvent.java @@ -39,7 +39,7 @@ public abstract class OutputEvent extends NEWTEvent public String toString() { return toString(null).toString(); } - + public StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); diff --git a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java index eceea053d..d275eab46 100644 --- a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java +++ b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java @@ -35,7 +35,7 @@ import jogamp.newt.Debug; * 2 pointer zoom, a.k.a. pinch to zoom, gesture handler processing {@link MouseEvent}s * while producing {@link ZoomEvent}s if gesture is completed. *

                    - * Zoom value lies within [0..2], with 1 as 1:1. + * Zoom value lies within [0..2], with 1 as 1:1. *

                    *
                      *   - choosing the smallest surface edge (width/height -> x/y)
                    @@ -44,7 +44,7 @@ import jogamp.newt.Debug;
                      */
                     public class PinchToZoomGesture implements GestureHandler {
                         public static final boolean DEBUG = Debug.debug("Window.MouseEvent");
                    -    
                    +
                         /** A {@link GestureHandler.GestureEvent} denominating zoom. */
                         @SuppressWarnings("serial")
                         public static class ZoomEvent extends GestureEvent {
                    @@ -57,10 +57,10 @@ public class PinchToZoomGesture implements GestureHandler {
                             }
                             /** Triggering {@link MouseEvent} */
                             public final MouseEvent getTrigger() { return pe; }
                    -        /** Zoom value lies within [0..2], with 1 as 1:1. */ 
                    +        /** Zoom value lies within [0..2], with 1 as 1:1. */
                             public final float getZoom() { return zoom; }
                         }
                    -    
                    +
                         private final NativeSurface surface;
                         private float zoom;
                         private int zoomLastEdgeDist;
                    @@ -68,7 +68,7 @@ public class PinchToZoomGesture implements GestureHandler {
                         private boolean zoomMode;
                         private ZoomEvent zoomEvent;
                         private short[] pIds = new short[] { -1, -1 };
                    -    
                    +
                         public PinchToZoomGesture(NativeSurface surface) {
                             clear(true);
                             this.surface = surface;
                    @@ -80,10 +80,10 @@ public class PinchToZoomGesture implements GestureHandler {
                         }
                     
                         private int gesturePointers(final MouseEvent e, final int excludeIndex) {
                    -        int j = 0;       
                    +        int j = 0;
                             for(int i=e.getPointerCount()-1; i>=0; i--) {
                                 if( excludeIndex != i ) {
                    -                final int id = e.getPointerId(i); 
                    +                final int id = e.getPointerId(i);
                                     if( pIds[0] == id || pIds[1] == id ) {
                                         j++;
                                     }
                    @@ -91,7 +91,7 @@ public class PinchToZoomGesture implements GestureHandler {
                             }
                             return j;
                         }
                    -    
                    +
                         @Override
                         public void clear(boolean clearStarted) {
                             zoomEvent = null;
                    @@ -103,31 +103,31 @@ public class PinchToZoomGesture implements GestureHandler {
                                 pIds[1] = -1;
                             }
                         }
                    -    
                    +
                         @Override
                         public boolean isWithinGesture() {
                             return zoomMode;
                         }
                    -    
                    +
                         @Override
                         public boolean hasGesture() {
                             return null != zoomEvent;
                         }
                    -    
                    +
                         @Override
                         public InputEvent getGestureEvent() {
                             return zoomEvent;
                         }
                    -    
                    -    /** Zoom value lies within [0..2], with 1 as 1:1. */ 
                    +
                    +    /** Zoom value lies within [0..2], with 1 as 1:1. */
                         public final float getZoom() {
                             return zoom;
                         }
                    -    /** Set zoom value within [0..2], with 1 as 1:1. */ 
                    +    /** Set zoom value within [0..2], with 1 as 1:1. */
                         public final void setZoom(float zoom) {
                             this.zoom=zoom;
                         }
                    -    
                    +
                         @Override
                         public boolean process(final InputEvent in) {
                             if( null != zoomEvent || !(in instanceof MouseEvent) ) {
                    @@ -137,15 +137,15 @@ public class PinchToZoomGesture implements GestureHandler {
                             if( pe.getPointerType(0).getPointerClass() != MouseEvent.PointerClass.Onscreen ) {
                                 return false;
                             }
                    -        
                    +
                             final int pointerDownCount = pe.getPointerCount();
                             final int eventType = pe.getEventType();
                             final boolean useY = surface.getWidth() >= surface.getHeight(); // use smallest dimension
                             switch ( eventType ) {
                                 case MouseEvent.EVENT_MOUSE_PRESSED: {
                                     if( 1 == pointerDownCount ) {
                    -                    pIds[0] = pe.getPointerId(0);                    
                    -                    pIds[1] = -1;                    
                    +                    pIds[0] = pe.getPointerId(0);
                    +                    pIds[1] = -1;
                                     } else if ( 2 <= pointerDownCount ) { // && 1 == gesturePointers(pe, 0) /* w/o pressed pointer */) {
                                         pIds[0] = pe.getPointerId(0);
                                         pIds[1] = pe.getPointerId(1);
                    @@ -155,13 +155,13 @@ public class PinchToZoomGesture implements GestureHandler {
                                         System.err.println(this+".pressed: down "+pointerDownCount+", gPtr "+gesturePointers(pe, -1)+", event "+pe);
                                     }
                                 } break;
                    -            
                    +
                                 case MouseEvent.EVENT_MOUSE_RELEASED: {
                                     final int gPtr = gesturePointers(pe, 0); // w/o lifted pointer
                                     if ( 1 == gPtr ) {
                                         zoomFirstTouch = true;
                                         zoomMode = false;
                    -                } else if( 0 == gPtr ) { 
                    +                } else if( 0 == gPtr ) {
                                         // all lifted
                                         clear(true);
                                     }
                    @@ -169,7 +169,7 @@ public class PinchToZoomGesture implements GestureHandler {
                                         System.err.println(this+".released: down "+pointerDownCount+", gPtr "+gPtr+", event "+pe);
                                     }
                                 } break;
                    -            
                    +
                                 case MouseEvent.EVENT_MOUSE_DRAGGED: {
                                     if( 2 <= pointerDownCount ) {
                                         final int gPtr = gesturePointers(pe, -1);
                    @@ -187,13 +187,13 @@ public class PinchToZoomGesture implements GestureHandler {
                                                     zoomMode = true;
                                                 } else if( zoomMode ) {
                                                     final int d = Math.abs(edge0-edge1);
                    -                                final int dd = d - zoomLastEdgeDist;                        
                    +                                final int dd = d - zoomLastEdgeDist;
                                                     final float screenEdge = useY ? surface.getHeight() : surface.getWidth();
                                                     final float incr = (float)dd / screenEdge; // [-1..1]
                                                     if(DEBUG) {
                                                         System.err.println("XXX2: id0 "+pIds[0]+" -> idx0 "+p0Idx+", id1 "+pIds[1]+" -> idx1 "+p1Idx);
                                                         System.err.println("XXX3: d "+d+", ld "+zoomLastEdgeDist+", dd "+dd+", screen "+screenEdge+" -> incr "+incr+", zoom "+zoom+" -> "+(zoom+incr));
                    -                                }        
                    +                                }
                                                     zoom += incr;
                                                     // clip value
                                                     if( 2f < zoom ) {
                    @@ -211,7 +211,7 @@ public class PinchToZoomGesture implements GestureHandler {
                                         }
                                     }
                                 } break;
                    -            
                    +
                                 default:
                             }
                             return null != zoomEvent;
                    diff --git a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java
                    index 629dc50d7..e826f4a6a 100644
                    --- a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java
                    +++ b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java
                    @@ -3,14 +3,14 @@
                      *
                      * Redistribution and use in source and binary forms, with or without modification, are
                      * permitted provided that the following conditions are met:
                    - * 
                    + *
                      *    1. Redistributions of source code must retain the above copyright notice, this list of
                      *       conditions and the following disclaimer.
                    - * 
                    + *
                      *    2. Redistributions 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.
                    - * 
                    + *
                      * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
                      * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
                      * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
                    @@ -20,12 +20,12 @@
                      * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
                      * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
                      * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                    - * 
                    + *
                      * The views and conclusions contained in the software and documentation are those of the
                      * authors and should not be interpreted as representing official policies, either expressed
                      * or implied, of JogAmp Community.
                      */
                    - 
                    +
                     package com.jogamp.newt.event;
                     
                     public class TraceKeyAdapter implements KeyListener {
                    diff --git a/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java
                    index 14ee633a0..d035091c4 100644
                    --- a/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java
                    +++ b/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java
                    @@ -3,14 +3,14 @@
                      *
                      * Redistribution and use in source and binary forms, with or without modification, are
                      * permitted provided that the following conditions are met:
                    - * 
                    + *
                      *    1. Redistributions of source code must retain the above copyright notice, this list of
                      *       conditions and the following disclaimer.
                    - * 
                    + *
                      *    2. Redistributions 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.
                    - * 
                    + *
                      * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
                      * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
                      * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
                    @@ -20,12 +20,12 @@
                      * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
                      * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
                      * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                    - * 
                    + *
                      * The views and conclusions contained in the software and documentation are those of the
                      * authors and should not be interpreted as representing official policies, either expressed
                      * or implied, of JogAmp Community.
                      */
                    - 
                    +
                     package com.jogamp.newt.event;
                     
                     public class TraceMouseAdapter implements MouseListener {
                    diff --git a/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java
                    index 8542820c4..630e85303 100644
                    --- a/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java
                    +++ b/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java
                    @@ -3,14 +3,14 @@
                      *
                      * Redistribution and use in source and binary forms, with or without modification, are
                      * permitted provided that the following conditions are met:
                    - * 
                    + *
                      *    1. Redistributions of source code must retain the above copyright notice, this list of
                      *       conditions and the following disclaimer.
                    - * 
                    + *
                      *    2. Redistributions 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.
                    - * 
                    + *
                      * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
                      * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
                      * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
                    @@ -20,12 +20,12 @@
                      * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
                      * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
                      * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                    - * 
                    + *
                      * The views and conclusions contained in the software and documentation are those of the
                      * authors and should not be interpreted as representing official policies, either expressed
                      * or implied, of JogAmp Community.
                      */
                    - 
                    +
                     package com.jogamp.newt.event;
                     
                     public class TraceWindowAdapter implements WindowListener {
                    diff --git a/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java
                    index b9e487e9b..e237c0d80 100644
                    --- a/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java
                    +++ b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java
                    @@ -3,14 +3,14 @@
                      *
                      * Redistribution and use in source and binary forms, with or without modification, are
                      * permitted provided that the following conditions are met:
                    - * 
                    + *
                      *    1. Redistributions of source code must retain the above copyright notice, this list of
                      *       conditions and the following disclaimer.
                    - * 
                    + *
                      *    2. Redistributions 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.
                    - * 
                    + *
                      * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
                      * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
                      * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
                    @@ -20,12 +20,12 @@
                      * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
                      * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
                      * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                    - * 
                    + *
                      * The views and conclusions contained in the software and documentation are those of the
                      * authors and should not be interpreted as representing official policies, either expressed
                      * or implied, of JogAmp Community.
                      */
                    - 
                    +
                     package com.jogamp.newt.event;
                     
                     public abstract class WindowAdapter implements WindowListener
                    diff --git a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java
                    index 24b3b380a..8c7abfe99 100644
                    --- a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java
                    +++ b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java
                    @@ -1,22 +1,22 @@
                     /*
                      * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
                      * Copyright (c) 2010 JogAmp Community. 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
                    @@ -29,7 +29,7 @@
                      * 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.event;
                    @@ -42,7 +42,7 @@ package com.jogamp.newt.event;
                     @SuppressWarnings("serial")
                     public class WindowEvent extends NEWTEvent {
                         public static final short EVENT_WINDOW_RESIZED = 100;
                    -    public static final short EVENT_WINDOW_MOVED   = 101; 
                    +    public static final short EVENT_WINDOW_MOVED   = 101;
                         public static final short EVENT_WINDOW_DESTROY_NOTIFY = 102;
                         public static final short EVENT_WINDOW_GAINED_FOCUS = 103;
                         public static final short EVENT_WINDOW_LOST_FOCUS = 104;
                    @@ -65,7 +65,7 @@ public class WindowEvent extends NEWTEvent {
                                 default: return "unknown (" + type + ")";
                             }
                         }
                    -    
                    +
                         public String toString() {
                             return toString(null).toString();
                         }
                    diff --git a/src/newt/classes/com/jogamp/newt/event/WindowListener.java b/src/newt/classes/com/jogamp/newt/event/WindowListener.java
                    index dde182510..e097edf23 100644
                    --- a/src/newt/classes/com/jogamp/newt/event/WindowListener.java
                    +++ b/src/newt/classes/com/jogamp/newt/event/WindowListener.java
                    @@ -1,22 +1,22 @@
                     /*
                      * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
                      * Copyright (c) 2010 JogAmp Community. 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
                    @@ -29,7 +29,7 @@
                      * 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.event;
                    @@ -44,17 +44,17 @@ public interface WindowListener extends NEWTEventListener {
                         /** Window has been moved. */
                         public void windowMoved(WindowEvent e);
                     
                    -    /** 
                    +    /**
                          * Window destruction has been requested.
                          * 

                    * Depending on the {@link WindowClosingProtocol#getDefaultCloseOperation() default close operation}, * the window maybe destroyed or not. *

                    - * In case the window will be destroyed (see above), release of resources is recommended. + * In case the window will be destroyed (see above), release of resources is recommended. **/ public void windowDestroyNotify(WindowEvent e); - /** + /** * Window has been destroyed. */ public void windowDestroyed(WindowEvent e); diff --git a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java index a0f6e2cb4..8a204d234 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.newt.event; import javax.media.nativewindow.util.Rectangle; diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java index 6de2eee45..e3bf18448 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.newt.event.awt; import jogamp.newt.Debug; @@ -48,10 +48,10 @@ import jogamp.newt.Debug; * Common:
                    *
                         // your demo/render code
                    -    javax.media.opengl.GLEvenListener demo1 = new javax.media.opengl.GLEvenListener() { ... } ; 
                    +    javax.media.opengl.GLEvenListener demo1 = new javax.media.opengl.GLEvenListener() { ... } ;
                     
                         // your AWT agnostic NEWT mouse listener code
                    -    com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ; 
                    +    com.jogamp.newt.event.MouseListener mouseListener = new com.jogamp.newt.event.MouseAdapter() { ... } ;
                      * 

                    *

                    * Default NEWT use case, without using the AWTAdapter:
                    @@ -96,7 +96,7 @@ import jogamp.newt.Debug;
                    new AWTMouseAdapter(mouseListener, glWindow).addTo(comp);
                    *

                    - * + * * Last but not least, the AWTAdapter maybe used as a general AWT event forwarder to NEWT.
                    * *

                    @@ -108,7 +108,7 @@ import jogamp.newt.Debug;
                    new AWTMouseAdapter(glWindow).addTo(comp); // forward all AWT events to glWindow, as NEWT events
                    *

                    - * + * * @see #attachTo */ public abstract class AWTAdapter implements java.util.EventListener @@ -118,7 +118,7 @@ public abstract class AWTAdapter implements java.util.EventListener com.jogamp.newt.event.NEWTEventListener newtListener; com.jogamp.newt.Window newtWindow; - /** + /** * Simply wrap aroung a NEWT EventListener, exposed as an AWT EventListener.
                    * The NEWT EventListener will be called when an event happens.
                    */ @@ -130,7 +130,7 @@ public abstract class AWTAdapter implements java.util.EventListener this.newtWindow = null; } - /** + /** * Wrap aroung a NEWT EventListener, exposed as an AWT EventListener,
                    * where the given NEWT Window impersonates as the event's source. * The NEWT EventListener will be called when an event happens.
                    @@ -146,7 +146,7 @@ public abstract class AWTAdapter implements java.util.EventListener this.newtWindow = newtProxy; } - /** + /** * Create a pipeline adapter, AWT EventListener.
                    * Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.
                    * This is only supported with EDT enabled! @@ -162,15 +162,15 @@ public abstract class AWTAdapter implements java.util.EventListener } } - public final com.jogamp.newt.Window getNewtWindow() { - return newtWindow; + public final com.jogamp.newt.Window getNewtWindow() { + return newtWindow; } - + public final com.jogamp.newt.event.NEWTEventListener getNewtEventListener() { - return newtListener; + return newtListener; } - - /** + + /** * Due to the fact that some NEWT {@link com.jogamp.newt.event.NEWTEventListener} * are mapped to more than one {@link java.util.EventListener}, * this method is for your convenience to use this Adapter as a listener for all types.
                    diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java index bef2e5d0f..1b53671ba 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,18 +20,18 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.newt.event.awt; import jogamp.newt.awt.event.AWTNewtEventFactory; /** - * AWT: + * AWT: * printable: PRESSED (t0), TYPED (t0), RELEASED (t1) * non-printable: PRESSED (t0), RELEASED (t1) */ diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java index 115743a0d..ab4bf7a3f 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,17 +20,17 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.newt.event.awt; import jogamp.newt.awt.event.AWTNewtEventFactory; -public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseListener, +public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener { diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java index e91bb2f82..8c9781b77 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,20 +20,20 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.newt.event.awt; import java.awt.Dimension; import jogamp.newt.awt.event.AWTNewtEventFactory; -public class AWTWindowAdapter - extends AWTAdapter +public class AWTWindowAdapter + extends AWTAdapter implements java.awt.event.ComponentListener, java.awt.event.WindowListener, java.awt.event.FocusListener { WindowClosingListener windowClosingListener; @@ -63,17 +63,17 @@ public class AWTWindowAdapter if(awtComponent instanceof java.awt.Window) { ((java.awt.Window)awtComponent).addWindowListener(this); } - return this; + return this; } - + public AWTAdapter removeWindowClosingFrom(java.awt.Component awtComponent) { java.awt.Window win = getWindow(awtComponent); if( null != win && null != windowClosingListener ) { win.removeWindowListener(windowClosingListener); } - return this; + return this; } - + public AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeFocusListener(this); awtComponent.removeComponentListener(this); @@ -225,7 +225,7 @@ public class AWTWindowAdapter enqueueEvent(true, event); } } - public void windowClosed(java.awt.event.WindowEvent e) { + public void windowClosed(java.awt.event.WindowEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyed(event); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index cae1a06a2..ac81e8469 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -127,7 +127,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } @Override - public void windowResized(WindowEvent e) { + public void windowResized(WindowEvent e) { defaultWindowResizedOp(getWidth(), getHeight()); } @@ -139,7 +139,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final Object getUpstreamWidget() { return window; } - + /** * Creates a new GLWindow attaching a new Window referencing a * new default Screen and default Display with the given GLCapabilities. @@ -218,7 +218,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind @Override public final CapabilitiesImmutable getChosenCapabilities() { final GLDrawable _drawable = drawable; - return null != _drawable ? _drawable.getChosenGLCapabilities() : window.getChosenCapabilities(); + return null != _drawable ? _drawable.getChosenGLCapabilities() : window.getChosenCapabilities(); } @Override @@ -339,7 +339,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final int getY() { return window.getY(); } - + @Override public final int getWidth() { return window.getWidth(); @@ -349,7 +349,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final int getHeight() { return window.getHeight(); } - + @Override public final void setPosition(int x, int y) { window.setPosition(x, y); @@ -363,7 +363,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final boolean setFullscreen(boolean fullscreen) { return window.setFullscreen(fullscreen); } - + @Override public boolean setFullscreen(List monitors) { return window.setFullscreen(monitors); @@ -418,7 +418,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public void setWindowDestroyNotifyAction(Runnable r) { window.setWindowDestroyNotifyAction(r); } - + @Override public final void setVisible(boolean visible) { window.setVisible(visible); @@ -450,7 +450,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public void preserveGLStateAtDestroy(boolean value) { GLWindow.this.preserveGLStateAtDestroy(value); } - + @Override public synchronized void destroyActionPreLock() { // nop @@ -464,7 +464,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind //Exception e1 = new Exception(msg); //e1.printStackTrace(); } - + destroyImplInLock(); if(Window.DEBUG_IMPLEMENTATION) { @@ -493,7 +493,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } else { t0 = 0; } - + if (null == drawable && visible && 0 != window.getWindowHandle() && 0 * At native creation, {@link #setVisible(boolean) setVisible(true)}, @@ -619,7 +619,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind setVisible(true); } } - + /** * {@inheritDoc} *

                    @@ -643,7 +643,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final void swapBuffers() throws GLException { defaultSwapBuffers(); } - + //---------------------------------------------------------------------- // NEWTEventConsumer // @@ -807,7 +807,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final void removeGestureListener(GestureHandler.GestureListener gl) { window.removeGestureListener(gl); } - + //---------------------------------------------------------------------- // NativeWindow completion // @@ -893,7 +893,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind _forceGL3 = true; } else if(args[i].equals("-gl4es3")) { _forceGL4ES3 = true; - } + } } } forceES2 = _forceES2; @@ -905,7 +905,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind System.err.println("forceES3 "+forceES3); System.err.println("forceGL3 "+forceGL3); System.err.println("forceGL4ES3 "+forceGL4ES3); - + System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); System.err.println(JoglVersion.getInstance()); diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index a2135273b..a25b43777 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -71,9 +71,9 @@ import com.jogamp.newt.util.EDTUtil; public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("Window"); private static final boolean isOSX = NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false); - - private final AbstractGraphicsScreen screen; - + + private final AbstractGraphicsScreen screen; + private WindowClosingMode newtChildCloseOp = WindowClosingMode.DISPOSE_ON_CLOSE; private volatile Rectangle clientArea; @@ -82,22 +82,22 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { private volatile boolean newtChildReady = false; // ready if SWTEDTUtil is set and newtChild parented private volatile boolean postSetSize = false; // pending resize - /** - * Creates an instance using {@link #NewtCanvasSWT(Composite, int, Window)} + /** + * Creates an instance using {@link #NewtCanvasSWT(Composite, int, Window)} * on the SWT thread. - * + * *

                    * Note: The NEWT child {@link Display}'s {@link EDTUtil} is being set to an SWT conform implementation - * via {@link Display#setEDTUtil(EDTUtil)}. + * via {@link Display#setEDTUtil(EDTUtil)}. *

                    - * + * * @param parent the SWT composite - * @param style additional styles to SWT#NO_BACKGROUND - * @param child optional preassigned {@link #Window}, maybe null + * @param style additional styles to SWT#NO_BACKGROUND + * @param child optional preassigned {@link #Window}, maybe null * @return a new instance */ public static NewtCanvasSWT create(final Composite parent, final int style, final Window child) { - final NewtCanvasSWT[] res = new NewtCanvasSWT[] { null }; + final NewtCanvasSWT[] res = new NewtCanvasSWT[] { null }; parent.getDisplay().syncExec( new Runnable() { public void run() { res[0] = new NewtCanvasSWT( parent, style, child); @@ -105,22 +105,22 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { }); return res[0]; } - + /** * Instantiates a NewtCanvas with a NEWT child. - * + * *

                    * Note: The NEWT child {@link Display}'s {@link EDTUtil} is being set to an SWT conform implementation - * via {@link Display#setEDTUtil(EDTUtil)}. + * via {@link Display#setEDTUtil(EDTUtil)}. *

                    - * + * * @param parent the SWT composite - * @param style additional styles to SWT#NO_BACKGROUND - * @param child optional preassigned {@link #Window}, maybe null + * @param style additional styles to SWT#NO_BACKGROUND + * @param child optional preassigned {@link #Window}, maybe null */ public NewtCanvasSWT(final Composite parent, final int style, Window child) { super(parent, style | SWT.NO_BACKGROUND); - + SWTAccessor.setRealized(this, true); clientArea = getClientArea(); @@ -128,7 +128,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { final AbstractGraphicsDevice device = SWTAccessor.getDevice(this); screen = SWTAccessor.getScreen(device, -1 /* default */); nativeWindow = null; - + if(null != child) { setNEWTChild(child); } @@ -161,12 +161,12 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { addListener (SWT.Paint, listener); addListener (SWT.Dispose, listener); } - + /** assumes nativeWindow == null ! */ protected final boolean validateNative() { updateSizeCheck(); final Rectangle nClientArea = clientArea; - if(0 >= nClientArea.width || 0 >= nClientArea.height) { + if(0 >= nClientArea.width || 0 >= nClientArea.height) { return false; } screen.getDevice().open(); @@ -177,9 +177,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { final boolean visualIDValid = NativeWindowFactory.isNativeVisualIDValidForProcessing(visualID); if(DEBUG) { System.err.println("NewtCanvasSWT.validateNative() windowHandle 0x"+Long.toHexString(nativeWindowHandle)+", visualID 0x"+Integer.toHexString(visualID)+", valid "+visualIDValid); - } + } if( visualIDValid ) { - /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). + /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). * Note: SWT is owner of the native handle, hence no closing operation will be a NOP. */ final CapabilitiesImmutable caps = new Capabilities(); final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(screen.getDevice(), caps); @@ -187,7 +187,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if(DEBUG) { System.err.println("NewtCanvasSWT.validateNative() factory: "+factory+", windowHandle 0x"+Long.toHexString(nativeWindowHandle)+", visualID 0x"+Integer.toHexString(visualID)+", chosen config: "+config); // Thread.dumpStack(); - } + } if (null == config) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } @@ -198,11 +198,11 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { return null != nativeWindow; } - + protected final void updateSizeCheck() { final Rectangle oClientArea = clientArea; final Rectangle nClientArea = getClientArea(); - if ( nClientArea != null && + if ( nClientArea != null && ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) ) { clientArea = nClientArea; // write back new value @@ -217,12 +217,12 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } } } - + @Override public void update() { // don't paint background etc .. nop avoids flickering } - + /** * Destroys this resource: *
                      @@ -248,12 +248,12 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } screen.getDevice().close(); nativeWindow = null; - super.dispose(); + super.dispose(); } - + /** @return this SWT Canvas NativeWindow representation, may be null in case it has not been realized. */ public NativeWindow getNativeWindow() { return nativeWindow; } - + public WindowClosingMode getDefaultCloseOperation() { return newtChildCloseOp; // TODO: implement ?! } @@ -264,28 +264,28 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { boolean isParent() { - return null!=newtChild ; + return null!=newtChild ; } boolean isFullscreen() { return null != newtChild && newtChild.isFullscreen(); } - /** + /** * Sets a new NEWT child, provoking reparenting. *

                      * A previously detached newChild will be released to top-level status - * and made invisible. + * and made invisible. *

                      *

                      - * Note: When switching NEWT child's, detaching the previous first via setNEWTChild(null) - * produced much cleaner visual results. + * Note: When switching NEWT child's, detaching the previous first via setNEWTChild(null) + * produced much cleaner visual results. *

                      *

                      * Note: The NEWT child {@link Display}'s {@link EDTUtil} is being set to an SWT conform implementation - * via {@link Display#setEDTUtil(EDTUtil)}. + * via {@link Display#setEDTUtil(EDTUtil)}. *

                      - * @return the previous attached newt child. + * @return the previous attached newt child. */ public Window setNEWTChild(final Window newChild) { final Window prevChild = newtChild; @@ -302,14 +302,14 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if(null != nativeWindow && null != newChild) { reparentWindow( true ); } - return prevChild; + return prevChild; } - + /** @return the current NEWT child */ public Window getNEWTChild() { return newtChild; } - + @Override public boolean setParent(Composite parent) { return super.setParent(parent); @@ -319,11 +319,11 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { newtChildReady = attach; if( null != newtChild ) { newtChild.setKeyboardFocusHandler(null); - if(attach) { - newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); + if(attach) { + newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); } else { newtChild.setFocusAction(null); - newtChild.setDefaultCloseOperation(newtChildCloseOp); + newtChild.setDefaultCloseOperation(newtChildCloseOp); } } } @@ -335,13 +335,13 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if(DEBUG) { System.err.println("NewtCanvasSWT.reparentWindow.0: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); } - + newtChild.setFocusAction(null); // no AWT focus traversal .. if(add) { updateSizeCheck(); final int w = clientArea.width; final int h = clientArea.height; - + // set SWT EDT and start it { final Display newtDisplay = newtChild.getScreen().getDisplay(); @@ -349,14 +349,14 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { edtUtil.start(); newtDisplay.setEDTUtil( edtUtil ); } - - newtChild.setSize(w, h); + + newtChild.setSize(w, h); newtChild.reparentWindow(nativeWindow); newtChild.setVisible(true); - configureNewtChild(true); + configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener - - // force this SWT Canvas to be focus-able, + + // force this SWT Canvas to be focus-able, // since it is completely covered by the newtChild (z-order). setEnabled(true); } else { @@ -375,19 +375,19 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { newtChild.requestFocus(); } } - + @Override public boolean forceFocus() { final boolean res = NewtCanvasSWT.super.forceFocus(); requestFocusNEWTChild(); - return res; + return res; } - + private class SWTNativeWindow implements NativeWindow { private final AbstractGraphicsConfiguration config; private final long nativeWindowHandle; private final InsetsImmutable insets; // only required to allow proper client position calculation on OSX - + public SWTNativeWindow(AbstractGraphicsConfiguration config, long nativeWindowHandle) { this.config = config; this.nativeWindowHandle = nativeWindowHandle; @@ -397,7 +397,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { this.insets = new Insets(0, 0, 0, 0); } } - + @Override public int lockSurface() throws NativeWindowException, RuntimeException { return NativeSurface.LOCK_SUCCESS; @@ -432,7 +432,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { } @Override - public long getSurfaceHandle() { + public long getSurfaceHandle() { return 0; } @@ -462,7 +462,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } @Override - public void surfaceUpdated(Object updater, NativeSurface ns, long when) { } + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { } @Override public void destroy() { } @@ -497,7 +497,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if( isOSX ) { final Point los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); // top-level position -> client window position - los.set(los.getX() + insets.getLeftWidth(), los.getY() + insets.getTopHeight()); + los.set(los.getX() + insets.getLeftWidth(), los.getY() + insets.getTopHeight()); if(null!=point) { return point.translate(los); } else { @@ -506,7 +506,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } else { // client position on 'normal' windowing systems is 0/0 if(null == point) { - point = new Point(0, 0); + point = new Point(0, 0); } return point; } @@ -515,7 +515,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { @Override public boolean hasFocus() { return isFocusControl(); - } + } }; static String newtWinHandleToHexString(Window w) { diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index 52ca95682..582dc3e1f 100644 --- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -63,17 +63,17 @@ public interface EDTUtil { * @param ms poll period in milliseconds */ public void setPollPeriod(long ms); - + /** * Starts the EDT after it's creation or after {@link #invokeStop(boolean, Runnable) stopping}. *

                      * If the EDT is running, it must be {@link #invokeStop(boolean, Runnable) stopped} first * and the caller should wait {@link #waitUntilStopped() until it's stopped}. *

                      - * + * * @return true if EDT has been successfully restarted, otherwise false * @throws IllegalStateException if EDT is running and not subject to be stopped, i.e. {@link #isRunning()} returns true - * + * * @see #invokeStop(boolean, java.lang.Runnable) * @see #waitUntilStopped() */ @@ -82,11 +82,11 @@ public interface EDTUtil { /** * Returns true if the current thread is the event dispatch thread (EDT). *

                      - * The EDT is the platform specific thread dispatching toolkit-events + * The EDT is the platform specific thread dispatching toolkit-events * and executing toolkit-tasks enqueued via {@link #invoke(boolean, Runnable)}. *

                      *

                      - * Usually it is the same thread as used to dequeue informal {@link NEWTEvent}s (NEDT), see {@link #isCurrentThreadNEDT()}, + * Usually it is the same thread as used to dequeue informal {@link NEWTEvent}s (NEDT), see {@link #isCurrentThreadNEDT()}, * however, this may differ, e.g. SWT and AWT implementation. *

                      */ @@ -95,28 +95,28 @@ public interface EDTUtil { /** * Returns true if the current thread is the internal NEWT event dequeue thread (NEDT). *

                      - * The NEDT is the NEWT thread used to dequeue informal {@link NEWTEvent}s enqueued internally + * The NEDT is the NEWT thread used to dequeue informal {@link NEWTEvent}s enqueued internally * via {@link DisplayImpl#enqueueEvent(boolean, NEWTEvent)}. *

                      *

                      - * Usually it is the same thread as the EDT, see {@link #isCurrentThreadEDT()}, + * Usually it is the same thread as the EDT, see {@link #isCurrentThreadEDT()}, * however, this may differ, e.g. SWT and AWT implementation. *

                      */ public boolean isCurrentThreadNEDT(); - + /** * Returns true if either {@link #isCurrentThreadEDT()} or {@link #isCurrentThreadNEDT()} is true, * otherwise false. */ public boolean isCurrentThreadEDTorNEDT(); - + /** * @return True if EDT is running and not subject to be stopped. */ public boolean isRunning(); - /** + /** * Append the final task to the EDT task queue, * signals EDT to stop. *

                      @@ -133,22 +133,22 @@ public interface EDTUtil { *

                    • {@link #start()} may follow immediately, ie creating a new EDT
                    • *
                    *

                    - * @return true if task has been executed or queued for later execution, otherwise false + * @return true if task has been executed or queued for later execution, otherwise false */ public boolean invokeStop(boolean wait, Runnable finalTask); - /** + /** * Appends task to the EDT task queue if current thread is not EDT, - * otherwise execute task immediately. + * otherwise execute task immediately. *

                    * Wait until execution is finished if wait == true. *

                    * Can be issued from within EDT, ie from within an enqueued task.
                    - * @return true if task has been executed or queued for later execution, otherwise false + * @return true if task has been executed or queued for later execution, otherwise false */ public boolean invoke(boolean wait, Runnable task); - /** + /** * Wait until the EDT task queue is empty.
                    * The last task may still be in execution when this method returns. * @return true if waited for idle, otherwise false, i.e. in case of current thread is EDT or NEDT diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java index 5e79e9b49..049320b21 100644 --- a/src/newt/classes/com/jogamp/newt/util/MainThread.java +++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -54,13 +54,13 @@ import jogamp.newt.NEWTJNILibLoader; * NEWT Utility class MainThread

                    * *

                    - * FIXME: Update this documentation! + * FIXME: Update this documentation! * This class just provides a main-thread utility, forking of a main java class * on another thread while being able to continue doing platform specific things * on the main-thread. The latter is essential for eg. MacOSX, where we continue * to run NSApp.run(). *

                    - * + * * This class provides a startup singleton main thread, * from which a new thread with the users main class is launched.
                    * @@ -72,17 +72,17 @@ import jogamp.newt.NEWTJNILibLoader; * use a NEWT multithreaded application with window handling within the different threads, * even on these restricted platforms.
                    * - * To support your NEWT Window platform, + * To support your NEWT Window platform, * you have to pass your main thread actions to {@link #invoke invoke(..)}, * have a look at the {@link jogamp.newt.driver.macosx.WindowDriver NEWT Mac OSX Window} driver implementation.
                    - * TODO: Some hardcoded dependencies exist in this implementation, + * TODO: Some hardcoded dependencies exist in this implementation, * where you have to patch this code or factor it out.

                    - * + * * 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 newt.MainThread.force to true.

                    * * 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 + * Since those platforms won't trigger the main thread serialization, the main method * will be simply executed, in case you haven't set newt.MainThread.force to true.

                    * * Test case on Mac OS X (or any other platform): @@ -96,35 +96,35 @@ public class MainThread { private static final Platform.OSType osType; private static final boolean isMacOSX; private static final ThreadGroup rootThreadGroup; - + /** if true, use the main thread EDT, otherwise AWT's EDT */ public static final boolean HINT_USE_MAIN_THREAD; - + static { NativeWindowFactory.initSingleton(); NEWTJNILibLoader.loadNEWT(); - HINT_USE_MAIN_THREAD = !NativeWindowFactory.isAWTAvailable() || + HINT_USE_MAIN_THREAD = !NativeWindowFactory.isAWTAvailable() || Debug.getBooleanProperty("newt.MainThread.force", true); osType = Platform.getOSType(); isMacOSX = osType == Platform.OSType.MACOS; rootThreadGroup = getRootThreadGroup(); } - + public static boolean useMainThread = false; - + protected static final boolean DEBUG = Debug.debug("MainThread"); private static final MainThread singletonMainThread = new MainThread(); // one singleton MainThread - + private static final ThreadGroup getRootThreadGroup() { ThreadGroup rootGroup = Thread.currentThread( ).getThreadGroup( ); ThreadGroup parentGroup; while ( ( parentGroup = rootGroup.getParent() ) != null ) { rootGroup = parentGroup; } - return rootGroup; + return rootGroup; } - + private static final Thread[] getAllThreads(int[] count) { int tn; Thread[] threads = new Thread[ rootThreadGroup.activeCount() ]; @@ -149,17 +149,17 @@ public class MainThread { t.printStackTrace(); } } - return res; + return res; } private static final int getNonDaemonThreadCount(List ignoreThreads) { int res = 0; int[] tn = { 0 }; Thread[] threads = getAllThreads(tn); - + for(int i = tn[0] - 1; i >= 0; i--) { final Thread thread = threads[i]; try { - if(thread.isAlive() && !thread.isDaemon() && !ignoreThreads.contains(thread)) { + if(thread.isAlive() && !thread.isDaemon() && !ignoreThreads.contains(thread)) { res++; if(DEBUG) System.err.println("MainAction.run(): non daemon thread: "+thread); } @@ -167,9 +167,9 @@ public class MainThread { t.printStackTrace(); } } - return res; + return res; } - + static class UserApp extends Thread { private final String mainClassNameShort; private final String mainClassName; @@ -181,7 +181,7 @@ public class MainThread { super(); this.mainClassName=mainClassName; this.mainClassArgs=mainClassArgs; - + final Class mainClass = ReflectionUtil.getClass(mainClassName, true, getClass().getClassLoader()); if(null==mainClass) { throw new ClassNotFoundException("MainAction couldn't find main class "+mainClassName); @@ -192,7 +192,7 @@ public class MainThread { setName(getName()+"-UserApp-"+mainClassNameShort); setDaemon(false); - + if(DEBUG) System.err.println("MainAction(): instantiated: "+getName()+", is daemon "+isDaemon()+", main-class: "+mainClass.getName()); } @@ -230,32 +230,32 @@ public class MainThread { if(isMacOSX) { try { if(DEBUG) { - System.err.println("MainAction.main(): "+Thread.currentThread()+" MainAction fin - stopNSApp.0"); + System.err.println("MainAction.main(): "+Thread.currentThread()+" MainAction fin - stopNSApp.0"); } - ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "stopNSApplication", + ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "stopNSApplication", null, null, MainThread.class.getClassLoader()); if(DEBUG) { - System.err.println("MainAction.main(): "+Thread.currentThread()+" MainAction fin - stopNSApp.X"); + System.err.println("MainAction.main(): "+Thread.currentThread()+" MainAction fin - stopNSApp.X"); } } catch (Exception e) { e.printStackTrace(); } } else { if(DEBUG) System.err.println("MainAction.run(): "+Thread.currentThread().getName()+" MainAction fin - System.exit(0)"); - System.exit(0); - } + System.exit(0); + } } } } private static UserApp mainAction; - /** Your new java application main entry, which pipelines your application - * @throws ClassNotFoundException - * @throws NoSuchMethodException + /** Your new java application main entry, which pipelines your application + * @throws ClassNotFoundException + * @throws NoSuchMethodException * @throws SecurityException */ public static void main(String[] args) throws SecurityException, NoSuchMethodException, ClassNotFoundException { final Thread cur = Thread.currentThread(); - + useMainThread = HINT_USE_MAIN_THREAD; if(DEBUG) { @@ -268,7 +268,7 @@ public class MainThread { if(!useMainThread && !NativeWindowFactory.isAWTAvailable()) { throw new RuntimeException("!USE_MAIN_THREAD and no AWT available"); } - + if(args.length==0) { return; } @@ -282,7 +282,7 @@ public class MainThread { mainAction = new UserApp(mainClassName, mainClassArgs); if(isMacOSX) { - ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "initSingleton", + ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "initSingleton", null, null, MainThread.class.getClassLoader()); } @@ -290,24 +290,24 @@ public class MainThread { try { cur.setName(cur.getName()+"-MainThread"); } catch (Exception e) {} - + // dispatch user's main thread .. mainAction.start(); - + if(isMacOSX) { try { if(DEBUG) { - System.err.println("MainThread.main(): "+cur.getName()+"- runNSApp"); + System.err.println("MainThread.main(): "+cur.getName()+"- runNSApp"); } - ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "runNSApplication", + ReflectionUtil.callStaticMethod(MACOSXDisplayClassName, "runNSApplication", null, null, MainThread.class.getClassLoader()); } catch (Exception e) { e.printStackTrace(); } - } - if(DEBUG) { System.err.println("MainThread - wait until last non daemon thread ends ..."); } + } + if(DEBUG) { System.err.println("MainThread - wait until last non daemon thread ends ..."); } } else { - // run user's main in this thread + // run user's main in this thread mainAction.run(); } } diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java index c30b427d6..fdd7985fe 100644 --- a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java @@ -42,7 +42,7 @@ import javax.media.nativewindow.util.SurfaceSize; * filters etc. */ public class MonitorModeUtil { - + public static int getIndex(List monitorModes, MonitorMode search) { return monitorModes.indexOf(search); } @@ -69,7 +69,7 @@ public class MonitorModeUtil { } return null; } - + /** Sort the given {@link MonitorMode} collection w/ {@link MonitorMode#compareTo(MonitorMode)} function. */ public static void sort(List monitorModes, boolean ascendingOrder) { if( ascendingOrder ) { @@ -78,9 +78,9 @@ public class MonitorModeUtil { Collections.sort(monitorModes, MonitorMode.monitorModeComparatorInv); } } - + /** - * + * * @param monitorModes * @param surfaceSize * @return modes with exact {@link SurfaceSize}. May return zero sized list for non. @@ -99,7 +99,7 @@ public class MonitorModeUtil { } /** - * + * * @param monitorModes * @param rotation * @return modes with exact rotation. May return zero sized list for non. @@ -118,7 +118,7 @@ public class MonitorModeUtil { } /** - * + * * @param monitorModes * @param bitsPerPixel * @return modes with exact bpp. May return zero sized list for non. @@ -137,7 +137,7 @@ public class MonitorModeUtil { } /** - * + * * @param monitorModes * @param flags * @return modes with exact flags. May return zero sized list for non. @@ -165,7 +165,7 @@ public class MonitorModeUtil { if( null!=monitorModes && monitorModes.size()>0 ) { final int resolution_sq = resolution.getHeight()*resolution.getWidth(); int mode_dsq=Integer.MAX_VALUE, mode_dsq_idx=0; - + for (int i=0; null!=monitorModes && i() { public Object run() { PropertyAccess.addTrustedPrefix("newt."); return null; } } ); - + verbose = isPropertyDefined("newt.verbose", true); debugAll = isPropertyDefined("newt.debug", true); if (verbose) { diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index 3d1037ad5..f33b4744e 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -51,7 +51,7 @@ public class DefaultEDTUtil implements EDTUtil { public static final boolean DEBUG = Debug.debug("EDT"); private final Object edtLock = new Object(); // locking the EDT start/stop state - private /* final */ ThreadGroup threadGroup; + private /* final */ ThreadGroup threadGroup; private final String name; private final Runnable dispatchMessages; private NEDT edt = null; @@ -75,7 +75,7 @@ public class DefaultEDTUtil implements EDTUtil { final public void setPollPeriod(long ms) { pollPeriod = ms; } - + @Override public final boolean start() throws IllegalStateException { synchronized(edtLock) { @@ -117,7 +117,7 @@ public class DefaultEDTUtil implements EDTUtil { public final boolean isCurrentThreadEDT() { return edt == Thread.currentThread(); // EDT == NEDT } - + @Override public final boolean isCurrentThreadNEDT() { return edt == Thread.currentThread(); // EDT == NEDT @@ -126,8 +126,8 @@ public class DefaultEDTUtil implements EDTUtil { @Override public final boolean isCurrentThreadEDTorNEDT() { return edt == Thread.currentThread(); // EDT == NEDT - } - + } + @Override public final boolean isRunning() { return edt.isRunning() ; @@ -149,9 +149,9 @@ public class DefaultEDTUtil implements EDTUtil { private static Runnable nullTask = new Runnable() { @Override - public void run() { } + public void run() { } }; - + private final boolean invokeImpl(boolean wait, Runnable task, boolean stop) { Throwable throwable = null; RunnableTask rTask = null; @@ -201,7 +201,7 @@ public class DefaultEDTUtil implements EDTUtil { synchronized(edt.tasks) { rTask = new RunnableTask(task, wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */, + true /* always catch and report Exceptions, don't disturb EDT */, wait ? null : System.err); if(stop) { rTask.setAttachment(new Boolean(true)); // mark final task, will imply shouldStop:=true @@ -305,8 +305,8 @@ public class DefaultEDTUtil implements EDTUtil { throw new InternalError("XXX"); } } - - /** + + /** * Utilizing locking only on tasks and its execution, * not for event dispatching. */ @@ -315,7 +315,7 @@ public class DefaultEDTUtil implements EDTUtil { if(DEBUG) { System.err.println(getName()+": Default-EDT run() START "+ getName()); } - if(Lock.DEBUG) { + if(Lock.DEBUG) { validateNoRecursiveLocksHold(); } RuntimeException error = null; @@ -368,7 +368,7 @@ public class DefaultEDTUtil implements EDTUtil { } finally { if(DEBUG) { RunnableTask rt = ( tasks.size() > 0 ) ? tasks.get(0) : null ; - System.err.println(getName()+": Default-EDT run() END "+ getName()+", tasks: "+tasks.size()+", "+rt+", "+error); + System.err.println(getName()+": Default-EDT run() END "+ getName()+", tasks: "+tasks.size()+", "+rt+", "+error); } synchronized(edtLock) { isRunning = false; diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 0f47c87a0..c6cb706a4 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt; @@ -60,16 +60,16 @@ public abstract class DisplayImpl extends Display { } }); } - + /** Ensure static init has been run. */ /* pp */static void initSingleton() { } - - private static Class getDisplayClass(String type) - throws ClassNotFoundException + + private static Class getDisplayClass(String type) + throws ClassNotFoundException { final Class displayClass = NewtFactory.getCustomClass(type, "DisplayDriver"); if(null==displayClass) { - throw new ClassNotFoundException("Failed to find NEWT Display Class <"+type+".DisplayDriver>"); + throw new ClassNotFoundException("Failed to find NEWT Display Class <"+type+".DisplayDriver>"); } return displayClass; } @@ -100,7 +100,7 @@ public abstract class DisplayImpl extends Display { display.setEDTUtil( display.edtUtil ); // device's default if EDT is used, or null Display.addDisplay2List(display); } - + if(DEBUG) { System.err.println("Display.create() NEW: "+display+" "+getThreadName()); } @@ -109,7 +109,7 @@ public abstract class DisplayImpl extends Display { throw new RuntimeException(e); } } - + @Override public boolean equals(Object obj) { if (obj == null) { @@ -168,7 +168,7 @@ public abstract class DisplayImpl extends Display { protected EDTUtil createEDTUtil() { final EDTUtil def; if(NewtFactory.useEDT()) { - def = new DefaultEDTUtil(Thread.currentThread().getThreadGroup(), "Display-"+getFQName(), dispatchMessagesRunnable); + def = new DefaultEDTUtil(Thread.currentThread().getThreadGroup(), "Display-"+getFQName(), dispatchMessagesRunnable); if(DEBUG) { System.err.println("Display.createEDTUtil("+getFQName()+"): "+def.getClass().getName()); } @@ -271,7 +271,7 @@ public abstract class DisplayImpl extends Display { if(DEBUG) { System.err.println("Display.destroy(): "+this+", active "+displaysActive+" "+getThreadName()); } - } + } final DisplayImpl f_dpy = this; final AbstractGraphicsDevice f_aDevice = aDevice; aDevice = null; @@ -287,10 +287,10 @@ public abstract class DisplayImpl extends Display { dumpDisplayList("Display.destroy("+getFQName()+") END"); } } - + /** May be utilized at a shutdown hook, impl. does not block. */ /* pp */ static final void shutdownAll() { - final int dCount = displayList.size(); + final int dCount = displayList.size(); if(DEBUG) { dumpDisplayList("Display.shutdownAll "+dCount+" instances, on thread "+getThreadName()); } @@ -306,7 +306,7 @@ public abstract class DisplayImpl extends Display { final EDTUtil edtUtil = d.getEDTUtil(); final AbstractGraphicsDevice f_aDevice = d.aDevice; d.aDevice = null; - d.refCount=0; + d.refCount=0; final Runnable closeNativeTask = new Runnable() { public void run() { if ( null != d.getGraphicsDevice() ) { @@ -381,7 +381,7 @@ public abstract class DisplayImpl extends Display { public final String getFQName() { return fqname; } - + @Override public final boolean isExclusive() { return exclusive; @@ -438,7 +438,7 @@ public abstract class DisplayImpl extends Display { @Override public String toString() { final EDTUtil _edtUtil = edtUtil; - final boolean _edtUtilRunning = ( null != _edtUtil ) ? _edtUtil.isRunning() : false; + final boolean _edtUtilRunning = ( null != _edtUtil ) ? _edtUtil.isRunning() : false; return "NEWT-Display["+getFQName()+", excl "+exclusive+", refCount "+refCount+", hasEDT "+(null!=_edtUtil)+", edtRunning "+_edtUtilRunning+", "+aDevice+"]"; } @@ -455,8 +455,8 @@ public abstract class DisplayImpl extends Display { } }; final void dispatchMessage(final NEWTEvent event) { - try { - final Object source = event.getSource(); + try { + final Object source = event.getSource(); if(source instanceof NEWTEventConsumer) { final NEWTEventConsumer consumer = (NEWTEventConsumer) source ; if(!consumer.consumeEvent(event)) { @@ -476,10 +476,10 @@ public abstract class DisplayImpl extends Display { throw re; } } - + final void dispatchMessage(final NEWTEventTask eventTask) { final NEWTEvent event = eventTask.get(); - try { + try { if(null == event) { // Ooops ? System.err.println("Warning: event of eventTask is NULL"); @@ -495,15 +495,15 @@ public abstract class DisplayImpl extends Display { throw re; } } - eventTask.notifyCaller(); + eventTask.notifyCaller(); } - + @Override public void dispatchMessages() { // System.err.println("Display.dispatchMessages() 0 "+this+" "+getThreadName()); - if(0==refCount || // no screens + if(0==refCount || // no screens null==getGraphicsDevice() // no native device - ) + ) { return; } @@ -541,13 +541,13 @@ public abstract class DisplayImpl extends Display { } return; } - + // can't wait if we are on EDT or NEDT -> consume right away if(wait && _edtUtil.isCurrentThreadEDTorNEDT() ) { dispatchMessage(e); return; } - + final Object lock = new Object(); final NEWTEventTask eTask = new NEWTEventTask(e, wait?lock:null); synchronized(lock) { @@ -565,13 +565,13 @@ public abstract class DisplayImpl extends Display { if( null != eTask.getException() ) { throw eTask.getException(); } - } + } } } public interface DisplayRunnable { T run(long dpy); - } + } public static final T runWithLockedDevice(AbstractGraphicsDevice device, DisplayRunnable action) { T res; device.lock(); @@ -589,7 +589,7 @@ public abstract class DisplayImpl extends Display { } return runWithLockedDevice(device, action); } - + protected volatile EDTUtil edtUtil = null; protected int id; protected String name; diff --git a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java index 43d558515..9e10879c4 100644 --- a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java +++ b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.newt; import javax.media.nativewindow.util.DimensionImmutable; @@ -41,7 +41,7 @@ public class MonitorDeviceImpl extends MonitorDevice { public MonitorDeviceImpl(ScreenImpl screen, int nativeId, DimensionImmutable sizeMM, Rectangle viewport, MonitorMode currentMode, ArrayHashSet supportedModes) { super(screen, nativeId, sizeMM, viewport, currentMode, supportedModes); } - + @Override public final MonitorMode queryCurrentMode() { final ScreenImpl screenImpl = (ScreenImpl)screen; @@ -54,7 +54,7 @@ public class MonitorDeviceImpl extends MonitorDevice { } MonitorMode mmU = supportedModes.get(mm0); // unified instance if( null == mmU ) { - // add new mode avoiding exception! + // add new mode avoiding exception! mmU = sms.getMonitorModes().getOrAdd(mm0); mmU = supportedModes.getOrAdd(mmU); if( Screen.DEBUG ) { @@ -89,21 +89,21 @@ public class MonitorDeviceImpl extends MonitorDevice { if( mmU.equals( mmC ) ) { if(Screen.DEBUG) { System.err.println("Screen.setCurrentMode: 0.0 is-current (skip) "+mmU+" == "+mmC); - } + } return true; } final long tStart; if(Screen.DEBUG) { - tStart = System.currentTimeMillis(); + tStart = System.currentTimeMillis(); } else { tStart = 0; } - + sms.fireMonitorModeChangeNotify(this, mmU); if(Screen.DEBUG) { System.err.println("Screen.setCurrentMode ("+(System.currentTimeMillis()-tStart)+"ms): fireModeChangeNotify() "+mmU); } - + boolean success = screenImpl.setCurrentMonitorModeImpl(this, mmU); if(success) { if(Screen.DEBUG) { @@ -135,13 +135,13 @@ public class MonitorDeviceImpl extends MonitorDevice { private final void setCurrentModeValue(MonitorMode currentMode) { this.currentMode = currentMode; } - + /* pp */ final void setViewportValue(Rectangle viewport) { this.viewport = viewport; } - + /* pp */ ArrayHashSet getSupportedModesImpl() { return supportedModes; } - + } diff --git a/src/newt/classes/jogamp/newt/MonitorModeProps.java b/src/newt/classes/jogamp/newt/MonitorModeProps.java index 820807e15..9d8f4919c 100644 --- a/src/newt/classes/jogamp/newt/MonitorModeProps.java +++ b/src/newt/classes/jogamp/newt/MonitorModeProps.java @@ -54,12 +54,12 @@ public class MonitorModeProps { * 1: bpp */ public static final int NUM_SURFACE_SIZE_PROPERTIES = 1; - + /** WARNING: must be synchronized with ScreenMode.h, native implementation * 2: refresh-rate (Hz*100), flags */ public static final int NUM_SIZEANDRATE_PROPERTIES = 2; - + /** WARNING: must be synchronized with ScreenMode.h, native implementation * 2: id, rotation */ @@ -69,7 +69,7 @@ public class MonitorModeProps { * count + all the above */ public static final int NUM_MONITOR_MODE_PROPERTIES_ALL = 8; - + public static final int IDX_MONITOR_MODE_BPP = 1 // count + MonitorModeProps.NUM_RESOLUTION_PROPERTIES ; @@ -79,7 +79,7 @@ public class MonitorModeProps { + MonitorModeProps.NUM_SIZEANDRATE_PROPERTIES + 1 // id of MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES ; - + /** WARNING: must be synchronized with ScreenMode.h, native implementation * 10: count + id, ScreenSizeMM[width, height], rotated Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ */ @@ -89,15 +89,15 @@ public class MonitorModeProps { + 1 // native mode + MonitorModeProps.NUM_RESOLUTION_PROPERTIES // sizeMM ; - + public static class Cache { public final ArrayHashSet resolutions = new ArrayHashSet(); public final ArrayHashSet surfaceSizes = new ArrayHashSet(); - public final ArrayHashSet sizeAndRates = new ArrayHashSet(); + public final ArrayHashSet sizeAndRates = new ArrayHashSet(); public final ArrayHashSet monitorModes = new ArrayHashSet(); public final ArrayHashSet monitorDevices = new ArrayHashSet(); } - + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ private static DimensionImmutable streamInResolution(int[] resolutionProperties, int offset) { Dimension resolution = new Dimension(resolutionProperties[offset++], resolutionProperties[offset++]); @@ -116,7 +116,7 @@ public class MonitorModeProps { final int flags = sizeAndRRateProperties[offset++]; return new MonitorMode.SizeAndRRate(surfaceSize, refreshRate, flags); } - + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ private static MonitorMode streamInMonitorMode0(MonitorMode.SizeAndRRate sizeAndRate, int[] modeProperties, int offset) { final int id = modeProperties[offset++]; @@ -161,7 +161,7 @@ public class MonitorModeProps { if(null!=cache) { sizeAndRate = cache.sizeAndRates.getOrAdd(sizeAndRate); } - + MonitorMode monitorMode = MonitorModeProps.streamInMonitorMode0(sizeAndRate, modeProperties, offset); if(null!=cache) { monitorMode = cache.monitorModes.getOrAdd(monitorMode); @@ -193,12 +193,12 @@ public class MonitorModeProps { } return data; } - - /** + + /** * WARNING: must be synchronized with ScreenMode.h, native implementation *

                    * Note: This variant only works for impl. w/ a unique mode key pair modeId, rotation. - *

                    + *

                    * @param mode_idx if not null, returns the index of resulting {@link MonitorDevice} within {@link Cache#monitorDevices}. * @param cache hash arrays of unique {@link MonitorMode} components and {@link MonitorDevice}s, allowing to avoid duplicates * @param modeProperties the input data @@ -218,7 +218,7 @@ public class MonitorModeProps { if(count > monitorProperties.length-offset) { throw new RuntimeException("properties array too short (count), should be >= "+count+", is "+(monitorProperties.length-offset)); } - final int limit = offset + count; + final int limit = offset + count; offset++; final List allMonitorModes = cache.monitorModes.getData(); final int id = monitorProperties[offset++]; @@ -252,7 +252,7 @@ public class MonitorModeProps { monitor_idx[0] = _monitorIdx; } return monitorDevice; - } + } private static MonitorMode getByNativeIdAndRotation(List monitorModes, int modeId, int rotation) { if( null!=monitorModes && monitorModes.size()>0 ) { for (int i=0; i * This variant expects count to be {@link MIN_MONITOR_DEVICE_PROPERTIES} - 1 - {@link NUM_MONITOR_MODE_PROPERTIES}, - * due to lack of supported mode and current mode. + * due to lack of supported mode and current mode. *

                    * * @param mode_idx if not null, returns the index of resulting {@link MonitorDevice} within {@link Cache#monitorDevices}. @@ -310,7 +310,7 @@ public class MonitorModeProps { } return monitorDevice; } - + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ public static int[] streamOutMonitorDevice (MonitorDevice monitorDevice) { // min 11: count, id, ScreenSizeMM[width, height], Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ @@ -339,7 +339,7 @@ public class MonitorModeProps { } return data; } - + public final void swapRotatePair(int rotation, int[] pairs, int offset, int numPairs) { if( MonitorMode.ROTATE_0 == rotation || MonitorMode.ROTATE_180 == rotation ) { // nop @@ -347,9 +347,9 @@ public class MonitorModeProps { } for(int i=0; i() { public Boolean run() { diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index 0a302d76b..eba844230 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt; @@ -50,7 +50,7 @@ import com.jogamp.newt.MonitorDevice; public class OffscreenWindow extends WindowImpl implements MutableSurface { long surfaceHandle; - + public OffscreenWindow() { surfaceHandle = 0; } @@ -72,7 +72,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { synchronized(OffscreenWindow.class) { setWindowHandle(nextWindowHandle++); } - visibleChanged(false, true); + visibleChanged(false, true); } protected void closeNativeImpl() { @@ -92,7 +92,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { @Override public long getSurfaceHandle() { return surfaceHandle; - } + } protected void requestFocusImpl(boolean reparented) { } @@ -101,7 +101,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { public void setPosition(int x, int y) { // nop } - + @Override public boolean setFullscreen(boolean fullscreen) { return false; // nop @@ -112,7 +112,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { return false; // nop } - + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { sizeChanged(false, width, height, false); if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { @@ -137,13 +137,13 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { } return new Point(0,0); } - + protected Point getLocationOnScreenImpl(int x, int y) { return new Point(x,y); } - + protected void updateInsetsImpl(Insets insets) { - // nop .. + // nop .. } } diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 7068d7464..d7e6c641c 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt; @@ -56,7 +56,7 @@ import com.jogamp.newt.util.MonitorModeUtil; public abstract class ScreenImpl extends Screen implements MonitorModeListener { protected static final boolean DEBUG_TEST_SCREENMODE_DISABLED; - + static { Debug.initSingleton(); DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true); @@ -67,14 +67,14 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { public static final int default_sm_heightmm = 324; public static final int default_sm_rate = 60; public static final int default_sm_rotation = 0; - + static { DisplayImpl.initSingleton(); } - + /** Ensure static init has been run. */ /* pp */static void initSingleton() { } - + protected DisplayImpl display; protected int screen_idx; protected String fqname; @@ -85,14 +85,14 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { protected static Dimension usrSize = null; // property values: newt.ws.swidth and newt.ws.sheight protected static volatile boolean usrSizeQueried = false; private ArrayList refMonitorModeListener = new ArrayList(); - + private long tCreated; // creationTime - private static Class getScreenClass(String type) throws ClassNotFoundException + private static Class getScreenClass(String type) throws ClassNotFoundException { final Class screenClass = NewtFactory.getCustomClass(type, "ScreenDriver"); if(null==screenClass) { - throw new ClassNotFoundException("Failed to find NEWT Screen Class <"+type+".ScreenDriver>"); + throw new ClassNotFoundException("Failed to find NEWT Screen Class <"+type+".ScreenDriver>"); } return screenClass; } @@ -104,7 +104,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if(!usrSizeQueried) { usrSizeQueried = true; final int w = Debug.getIntProperty("newt.ws.swidth", true, 0); - final int h = Debug.getIntProperty("newt.ws.sheight", true, 0); + final int h = Debug.getIntProperty("newt.ws.sheight", true, 0); if(w>0 && h>0) { usrSize = new Dimension(w, h); System.err.println("User screen size "+usrSize); @@ -135,7 +135,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { System.err.println("Screen.create() NEW: "+screen+" "+Display.getThreadName()); } return screen; - } + } } catch (Exception e) { throw new RuntimeException(e); } @@ -167,16 +167,16 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { @Override public synchronized final void createNative() throws NativeWindowException - { + { if(null == aScreen) { if(DEBUG) { tCreated = System.nanoTime(); System.err.println("Screen.createNative() START ("+DisplayImpl.getThreadName()+", "+this+")"); } else { tCreated = 0; - } + } display.addReference(); - + createNativeImpl(); if(null == aScreen) { throw new NativeWindowException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen"); @@ -249,7 +249,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { protected abstract void createNativeImpl(); protected abstract void closeNativeImpl(); - + /** * Returns the validated screen index, which is either the passed idx * value or 0. @@ -258,23 +258,23 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { *

                    */ protected abstract int validateScreenIndex(int idx); - + /** * Stores the virtual origin and virtual rotated screen size. *

                    - * This method is called after the MonitorMode has been set or changed, + * This method is called after the MonitorMode has been set or changed, * hence you may utilize it. *

                    *

                    * Default implementation uses the union of all monitor's viewport, - * calculated via {@link #unionOfMonitorViewportSize()}. + * calculated via {@link #unionOfMonitorViewportSize()}. *

                    * @param vOriginSize storage for result */ - protected void calcVirtualScreenOriginAndSize(final Rectangle vOriginSize) { + protected void calcVirtualScreenOriginAndSize(final Rectangle vOriginSize) { unionOfMonitorViewportSize(vOriginSize); } - + @Override public final String getFQName() { return fqname; @@ -335,15 +335,15 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } // - // MonitorDevice and MonitorMode + // MonitorDevice and MonitorMode // - + /** * To be implemented by the native specification.
                    * Is called within a thread safe environment.
                    * Is called only to collect the {@link MonitorMode}s and {@link MonitorDevice}s, usually at startup setting up modes.
                    *
                    - * WARNING: must be synchronized with + * WARNING: must be synchronized with *
                      *
                    • {@link MonitorModeProps#NUM_SCREEN_MODE_PROPERTIES} and
                    • *
                    • {@link MonitorModeProps#MIN_MONITOR_DEVICE_PROPERTIES}
                    • @@ -356,19 +356,19 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { * @param cache memory pool caching the result */ protected abstract void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache); - + protected Rectangle getNativeMonitorDeviceViewportImpl(MonitorDevice monitor) { return null; } - + /** * To be implemented by the native specification.
                      * Is called within a thread safe environment.
                      *

                      - * Implementation shall not unify the result w/ monitor's supported modes or a locally + * Implementation shall not unify the result w/ monitor's supported modes or a locally * saved {@link MonitorModeProps.Cache}, since caller will perform such tasks. *

                      */ protected abstract MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor); - + /** * To be implemented by the native specification.
                      * Is called within a thread safe environment.
                      @@ -378,13 +378,13 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { @Override public final List getMonitorModes() { final ScreenMonitorState sms = getScreenMonitorStatus(false); - return null != sms ? sms.getMonitorModes().getData() : null; + return null != sms ? sms.getMonitorModes().getData() : null; } - + @Override public final List getMonitorDevices() { final ScreenMonitorState sms = getScreenMonitorStatus(false); - return null != sms ? sms.getMonitorDevices().getData() : null; + return null != sms ? sms.getMonitorDevices().getData() : null; } final ScreenMonitorState getScreenMonitorStatus(boolean throwException) { @@ -395,7 +395,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } return res; } - + @Override public void monitorModeChangeNotify(MonitorEvent me) { if(DEBUG) { @@ -417,9 +417,9 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( null != newViewport ) { monitor.setViewportValue(newViewport); } - } + } } - + @Override public void monitorModeChanged(MonitorEvent me, boolean success) { if(success) { @@ -443,9 +443,9 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { public synchronized final void removeMonitorModeListener(MonitorModeListener sml) { refMonitorModeListener.remove(sml); } - + /** - * + * * @param cache optional .. * @param modeId * @return @@ -468,7 +468,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } /** - * + * * @param cache mandatory ! * @param monitorId * @param currentMode @@ -493,7 +493,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } return MonitorModeProps.streamInMonitorDevice(null, cache, this, props, 0); } - + /** * Utilizes {@link #getCurrentMonitorModeImpl()}, if the latter returns null it uses * the current screen size and dummy values. @@ -530,7 +530,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { sms = ScreenMonitorState.getScreenMonitorState(this.getFQName()); if(null==sms) { final MonitorModeProps.Cache cache = new MonitorModeProps.Cache(); - if( 0 >= collectNativeMonitorModes(cache) ) { + if( 0 >= collectNativeMonitorModes(cache) ) { updateVirtualScreenOriginAndSize(); vScrnSizeUpdated = true; final MonitorMode mode = getVirtualMonitorMode(cache, 0); @@ -557,7 +557,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { System.err.println("["+i+"]["+j+"]: "+iMode.next()); } } - } + } sms = new ScreenMonitorState(cache.monitorDevices, cache.monitorModes); ScreenMonitorState.mapScreenMonitorState(this.getFQName(), sms); } @@ -580,7 +580,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { * Collects {@link MonitorDevice}s and {@link MonitorMode}s within the given cache. *

                      */ - private final int collectNativeMonitorModes(MonitorModeProps.Cache cache) { + private final int collectNativeMonitorModes(MonitorModeProps.Cache cache) { if(!DEBUG_TEST_SCREENMODE_DISABLED) { collectNativeMonitorModesAndDevicesImpl(cache); } @@ -639,12 +639,12 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } finally { sms.unlock(); } - } + } } finally { ScreenMonitorState.unlockScreenMonitorState(); } } - + private final void shutdown() { ScreenMonitorState sms = ScreenMonitorState.getScreenMonitorStateUnlocked(getFQName()); if(null != sms) { @@ -661,11 +661,11 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } } ScreenMonitorState.unmapScreenMonitorStateUnlocked(getFQName()); - } + } } - + /** pp */ static final void shutdownAll() { - final int sCount = screenList.size(); + final int sCount = screenList.size(); if(DEBUG) { System.err.println("Screen.shutdownAll "+sCount+" instances, on thread "+Display.getThreadName()); } diff --git a/src/newt/classes/jogamp/newt/ScreenMonitorState.java b/src/newt/classes/jogamp/newt/ScreenMonitorState.java index 66e75be16..01e6cfee9 100644 --- a/src/newt/classes/jogamp/newt/ScreenMonitorState.java +++ b/src/newt/classes/jogamp/newt/ScreenMonitorState.java @@ -42,7 +42,7 @@ import java.util.HashMap; public class ScreenMonitorState { private static boolean DEBUG = Screen.DEBUG; - + private final RecursiveLock lock = LockFactory.createRecursiveLock(); private final ArrayHashSet allMonitors; private final ArrayHashSet allMonitorModes; @@ -105,21 +105,21 @@ public class ScreenMonitorState { protected static void unlockScreenMonitorState() { screen2ScreenMonitorState.unlock(); } - + public ScreenMonitorState(ArrayHashSet allMonitors, ArrayHashSet allMonitorModes) { - this.allMonitors = allMonitors; + this.allMonitors = allMonitors; this.allMonitorModes = allMonitorModes; } - protected ArrayHashSet getMonitorDevices() { + protected ArrayHashSet getMonitorDevices() { return allMonitors; } - - protected ArrayHashSet getMonitorModes() { + + protected ArrayHashSet getMonitorModes() { return allMonitorModes; } - + protected final int addListener(MonitorModeListener l) { lock(); try { @@ -151,14 +151,14 @@ public class ScreenMonitorState { protected final MonitorDevice getMonitor(MonitorDevice monitor) { return allMonitors.get(monitor); } - + protected final void validateMonitor(MonitorDevice monitor) { final MonitorDevice md = allMonitors.get(monitor); if( null == md ) { throw new InternalError("Monitor unknown: "+monitor); } } - + protected final void fireMonitorModeChangeNotify(MonitorDevice monitor, MonitorMode desiredMode) { lock(); try { diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index a35d89408..a0ef8816b 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt; @@ -87,19 +87,19 @@ import jogamp.nativewindow.SurfaceUpdatedHelper; public abstract class WindowImpl implements Window, NEWTEventConsumer { public static final boolean DEBUG_TEST_REPARENT_INCOMPATIBLE; - + static { Debug.initSingleton(); DEBUG_TEST_REPARENT_INCOMPATIBLE = Debug.isPropertyDefined("newt.test.Window.reparent.incompatible", true); - + ScreenImpl.initSingleton(); } - - protected static final ArrayList> windowList = new ArrayList>(); - + + protected static final ArrayList> windowList = new ArrayList>(); + /** Maybe utilized at a shutdown hook, impl. does not block. */ public static final void shutdownAll() { - final int wCount = windowList.size(); + final int wCount = windowList.size(); if(DEBUG_IMPLEMENTATION) { System.err.println("Window.shutdownAll "+wCount+" instances, on thread "+getThreadName()); } @@ -132,25 +132,25 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } - + /** Timeout of queued events (repaint and resize) */ - static final long QUEUED_EVENT_TO = 1200; // ms + static final long QUEUED_EVENT_TO = 1200; // ms private static final PointerType[] constMousePointerTypes = new PointerType[] { PointerType.Mouse }; - + // // Volatile: Multithread Mutable Access - // + // private volatile long windowHandle = 0; // lifecycle critical private volatile boolean visible = false; // lifecycle critical - private volatile boolean hasFocus = false; + private volatile boolean hasFocus = false; private volatile int width = 128, height = 128; // client-area size w/o insets, default: may be overwritten by user private volatile int x = 64, y = 64; // client-area pos w/o insets private volatile Insets insets = new Insets(); // insets of decoration (if top-level && decorated) - + private RecursiveLock windowLock = LockFactory.createRecursiveLock(); // Window instance wide lock private int surfaceLockCount = 0; // surface lock recursion count - + private ScreenImpl screen; // never null after create - may change reference though (reparent) private boolean screenReferenceAdded = false; private NativeWindow parentWindow = null; @@ -162,7 +162,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private List fullscreenMonitors = null; private boolean fullscreenUseMainMonitor = true; private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user) - + private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets private NativeWindow nfs_parent = null; // non fullscreen parent, in case explicit reparenting is performed (offscreen) private String title = "Newt Window"; @@ -178,26 +178,26 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private KeyListener keyboardFocusHandler = null; private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); - + private Object childWindowsLock = new Object(); private ArrayList childWindows = new ArrayList(); private ArrayList mouseListeners = new ArrayList(); - + /** from event passing: {@link WindowImpl#consumePointerEvent(MouseEvent)}. */ private static class PointerState0 { /** mouse entered window - is inside the window (may be synthetic) */ boolean insideWindow = false; - + /** last time when a mouse button was pressed */ long lastButtonPressTime = 0; - + void clearButton() { lastButtonPressTime = 0; } } private PointerState0 pState0 = new PointerState0(); - + /** from direct input: {@link WindowImpl#doPointerEvent(boolean, boolean, int[], short, int, int, boolean, short[], int[], int[], float[], float, float[], float)}. */ private static class PointerState1 extends PointerState0 { /** current pressed mouse button number */ @@ -206,15 +206,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int buttonPressedMask = 0; /** last mouse button click count */ short lastButtonClickCount = (short)0; - + final void clearButton() { super.clearButton(); lastButtonPressTime = 0; - lastButtonClickCount = (short)0; + lastButtonClickCount = (short)0; buttonPressed = 0; - buttonPressedMask = 0; + buttonPressedMask = 0; } - + /** last pointer-move position for 8 touch-down pointers */ final Point[] movePositions = new Point[] { new Point(), new Point(), new Point(), new Point(), @@ -227,16 +227,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } private PointerState1 pState1 = new PointerState1(); - + /** pointer names -> pointer ID (consecutive index, starting w/ 0) */ private final ArrayHashSet pName2pID = new ArrayHashSet(); - + private boolean defaultGestureHandlerEnabled = true; private DoubleTapScrollGesture gesture2PtrTouchScroll = null; private ArrayList pointerGestureHandler = new ArrayList(); - + private ArrayList gestureListeners = new ArrayList(); - + private ArrayList keyListeners = new ArrayList(); private ArrayList windowListeners = new ArrayList(); @@ -267,7 +267,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer { final Class windowClass = NewtFactory.getCustomClass(type, "WindowDriver"); if(null==windowClass) { - throw new ClassNotFoundException("Failed to find NEWT Window Class <"+type+".WindowDriver>"); + throw new ClassNotFoundException("Failed to find NEWT Window Class <"+type+".WindowDriver>"); } return windowClass; } @@ -293,7 +293,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer throw new NativeWindowException(t); } } - + public static WindowImpl create(Object[] cstrArguments, Screen screen, CapabilitiesImmutable caps) { try { Class windowClass = getWindowClass(screen.getDisplay().getType()); @@ -329,11 +329,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer hasFocus = false; parentWindowHandle = 0; } - + protected final void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg) { config = cfg; } - + public static interface LifecycleHook { /** * Reset of internal state counter, ie totalFrames, etc. @@ -341,8 +341,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer */ public abstract void resetCounter(); - /** - * Invoked after Window setVisible, + /** + * Invoked after Window setVisible, * allows allocating resources depending on the native Window. * Called from EDT while window is locked. */ @@ -354,9 +354,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param value true to set the one-shot preservation if supported, otherwise clears it. */ void preserveGLStateAtDestroy(boolean value); - - /** - * Invoked before Window destroy action, + + /** + * Invoked before Window destroy action, * allows releasing of resources depending on the native Window.
                      * Surface not locked yet.
                      * Called not necessarily from EDT. @@ -388,12 +388,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @see #pauseRenderingAction() */ void resumeRenderingAction(); - + /** * Shutdown rendering action (thread) abnormally. *

                      * Should be called only at shutdown, if necessary. - *

                      + *

                      */ void shutdownRenderingAction(); } @@ -406,14 +406,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else { tStart = 0; } - - if( null != parentWindow && + + if( null != parentWindow && NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindow.lockSurface() ) { throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow); } - + // child window: position defaults to 0/0, no auto position, no negative position - if( null != parentWindow && ( autoPosition || 0>getX() || 0>getY() ) ) { + if( null != parentWindow && ( autoPosition || 0>getX() || 0>getY() ) ) { definePosition(0, 0); } boolean postParentlockFocus = false; @@ -556,28 +556,28 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** * Notifies the driver impl. that the instantiation is finished, - * ie. instance created and all fields set. + * ie. instance created and all fields set. */ protected void instantiationFinished() { // nop } - + protected boolean canCreateNativeImpl() { return true; // default: always able to be created } - - /** + + /** * The native implementation must set the native windowHandle.
                      * *

                      * The implementation shall respect the states {@link #isAlwaysOnTop()}/{@link #FLAG_IS_ALWAYSONTOP} and * {@link #isUndecorated()}/{@link #FLAG_IS_UNDECORATED}, ie. the created window shall reflect those settings. *

                      - * + * *

                      * The implementation should invoke the referenced java state callbacks * to notify this Java object of state changes.

                      - * + * * @see #windowDestroyNotify(boolean) * @see #focusChanged(boolean, boolean) * @see #visibleChanged(boolean, boolean) @@ -589,16 +589,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected abstract void closeNativeImpl(); - /** + /** * Async request which shall be performed within {@link #TIMEOUT_NATIVEWINDOW}. *

                      - * If if force == false the native implementation + * If if force == false the native implementation * may only request focus if not yet owner.

                      *

                      * {@link #focusChanged(boolean, boolean)} should be called - * to notify about the focus traversal. - *

                      - * + * to notify about the focus traversal. + *

                      + * * @param force if true, bypass {@link #focusChanged(boolean, boolean)} and force focus request */ protected abstract void requestFocusImpl(boolean force); @@ -608,7 +608,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public static final int FLAG_CHANGE_FULLSCREEN = 1 << 2; public static final int FLAG_CHANGE_ALWAYSONTOP = 1 << 3; public static final int FLAG_CHANGE_VISIBILITY = 1 << 4; - + public static final int FLAG_HAS_PARENT = 1 << 8; public static final int FLAG_IS_UNDECORATED = 1 << 9; public static final int FLAG_IS_FULLSCREEN = 1 << 10; @@ -619,12 +619,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** * The native implementation should invoke the referenced java state callbacks * to notify this Java object of state changes. - * + * *

                      * Implementations shall set x/y to 0, in case it's negative. This could happen due * to insets and positioning a decorated window to 0/0, which would place the frame * outside of the screen.

                      - * + * * @param x client-area position, or <0 if unchanged * @param y client-area position, or <0 if unchanged * @param width client-area size, or <=0 if unchanged @@ -635,12 +635,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @see #positionChanged(boolean,int, int) */ protected abstract boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags); - - /** + + /** * Tests whether a single reconfigure flag is supported by implementation. *

                      * Default is all but {@link #FLAG_IS_FULLSCREEN_SPAN} - *

                      + *

                      */ protected boolean isReconfigureFlagSupported(int changeFlags) { return 0 == ( changeFlags & FLAG_IS_FULLSCREEN_SPAN ); @@ -656,14 +656,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected static String getReconfigureFlagsAsString(StringBuilder sb, int flags) { if(null == sb) { sb = new StringBuilder(); } sb.append("["); - + if( 0 != ( FLAG_CHANGE_PARENTING & flags) ) { sb.append("*"); } sb.append("PARENT_"); sb.append(0 != ( FLAG_HAS_PARENT & flags)); sb.append(", "); - + if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { sb.append("*"); } @@ -679,24 +679,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer sb.append("UNDECOR_"); sb.append(0 != ( FLAG_IS_UNDECORATED & flags)); sb.append(", "); - + if( 0 != ( FLAG_CHANGE_ALWAYSONTOP & flags) ) { sb.append("*"); } sb.append("ALWAYSONTOP_"); sb.append(0 != ( FLAG_IS_ALWAYSONTOP & flags)); sb.append(", "); - + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { sb.append("*"); } sb.append("VISIBLE_"); sb.append(0 != ( FLAG_IS_VISIBLE & flags)); - + sb.append("]"); return sb.toString(); } - + protected void setTitleImpl(String title) {} /** @@ -713,11 +713,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @return if not null, the screen location of the given coordinates */ protected abstract Point getLocationOnScreenImpl(int x, int y); - + /** Triggered by user via {@link #getInsets()}.
                      - * Implementations may implement this hook to update the insets.
                      + * Implementations may implement this hook to update the insets.
                      * However, they may prefer the event driven path via {@link #insetsChanged(boolean, int, int, int, int)}. - * + * * @see #getInsets() * @see #insetsChanged(boolean, int, int, int, int) */ @@ -726,7 +726,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected boolean setPointerVisibleImpl(boolean pointerVisible) { return false; } protected boolean confinePointerImpl(boolean confine) { return false; } protected void warpPointerImpl(int x, int y) { } - + //---------------------------------------------------------------------- // NativeSurface // @@ -791,7 +791,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public final RecursiveLock getLock() { return windowLock; } - + @Override public long getSurfaceHandle() { return windowHandle; // default: return window handle @@ -810,7 +810,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final long getDisplayHandle() { return config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); - } + } @Override public final int getScreenIndex() { @@ -879,19 +879,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public final Screen getScreen() { return screen; } - + @Override public final MonitorDevice getMainMonitor() { return screen.getMainMonitor(new Rectangle(getX(), getY(), getWidth(), getHeight())); } - + protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) { - reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible)); - } + reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible)); + } final void setVisibleActionImpl(boolean visible) { boolean nativeWindowCreated = false; boolean madeVisible = false; - + final RecursiveLock _lock = windowLock; _lock.lock(); try { @@ -911,7 +911,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer madeVisible = nativeWindowCreated; } // always flag visible, allowing a retry .. - WindowImpl.this.visible = true; + WindowImpl.this.visible = true; } else if(WindowImpl.this.visible != visible) { if(isNativeValid()) { setVisibleImpl(visible, getX(), getY(), getWidth(), getHeight()); @@ -965,14 +965,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window setVisible: START ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)); } - runOnEDTIfAvail(wait, new VisibleAction(visible)); + runOnEDTIfAvail(wait, new VisibleAction(visible)); } @Override public void setVisible(boolean visible) { setVisible(true, visible); } - + private class SetSizeAction implements Runnable { int width, height; boolean disregardFS; @@ -1024,11 +1024,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private void setFullscreenSize(int width, int height) { runOnEDTIfAvail(true, new SetSizeAction(width, height, true)); - } + } @Override public void setSize(int width, int height) { runOnEDTIfAvail(true, new SetSizeAction(width, height, false)); - } + } @Override public void setTopLevelSize(int width, int height) { setSize(width - getInsets().getTotalWidth(), height - getInsets().getTotalHeight()); @@ -1049,10 +1049,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window DestroyAction() hasScreen "+(null != screen)+", isNativeValid "+isNativeValid()+" - "+getThreadName()); } - + // send synced destroy-notify notification sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); - + // Childs first .. synchronized(childWindowsLock) { if(childWindows.size()>0) { @@ -1111,30 +1111,30 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(animatorPaused) { lifecycleHook.resumeRenderingAction(); } - + // these refs shall be kept alive - resurrection via setVisible(true) /** if(null!=parentWindow && parentWindow instanceof Window) { ((Window)parentWindow).removeChild(WindowImpl.this); - } + } childWindows = null; surfaceUpdatedListeners = null; mouseListeners = null; keyListeners = null; capsRequested = null; lifecycleHook = null; - - screen = null; + + screen = null; windowListeners = null; parentWindow = null; - */ + */ } } private final DestroyAction destroyAction = new DestroyAction(); @Override public void destroy() { - visible = false; // Immediately mark synchronized visibility flag, avoiding possible recreation + visible = false; // Immediately mark synchronized visibility flag, avoiding possible recreation runOnEDTIfAvail(true, destroyAction); } @@ -1144,15 +1144,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } destroy(); } - + /** * @param cWin child window, must not be null * @param pWin parent window, may be null - * @return true if at least one of both window's configurations is offscreen + * @return true if at least one of both window's configurations is offscreen */ protected static boolean isOffscreenInstance(NativeWindow cWin, NativeWindow pWin) { boolean ofs = false; - final AbstractGraphicsConfiguration cWinCfg = cWin.getGraphicsConfiguration(); + final AbstractGraphicsConfiguration cWinCfg = cWin.getGraphicsConfiguration(); if( null != cWinCfg ) { ofs = !cWinCfg.getChosenCapabilities().isOnscreen(); } @@ -1164,7 +1164,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } return ofs; } - + private class ReparentAction implements Runnable { final NativeWindow newParentWindow; final int topLevelX, topLevelY; @@ -1187,7 +1187,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer removeScreenReference(); screen = newScreen; } - + public final void run() { boolean animatorPaused = false; if(null!=lifecycleHook) { @@ -1198,7 +1198,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer lifecycleHook.resumeRenderingAction(); } } - + private void reparent() { // mirror pos/size so native change notification can get overwritten final int oldX = getX(); @@ -1209,7 +1209,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int width = oldWidth; int height = oldHeight; boolean wasVisible; - + final RecursiveLock _lock = windowLock; _lock.lock(); try { @@ -1217,7 +1217,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // force recreation if offscreen, since it may become onscreen forceDestroyCreate |= isOffscreenInstance(WindowImpl.this, newParentWindow); } - + wasVisible = isVisible(); Window newParentWindowNEWT = null; @@ -1233,7 +1233,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(null!=newParentWindow) { // REPARENT TO CHILD WINDOW - + // reset position to 0/0 within parent space x = 0; y = 0; @@ -1278,7 +1278,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer operation = ReparentOperation.ACTION_NATIVE_CREATION_PENDING; } } else if ( forceDestroyCreate || !NewtFactory.isScreenCompatible(newParentWindow, screen) ) { - // Destroy this window, may create a new compatible Screen/Display, while trying to preserve resources if becoming visible again. + // Destroy this window, may create a new compatible Screen/Display, while trying to preserve resources if becoming visible again. destroy( wasVisible ); if(null!=newParentWindowNEWT) { setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); @@ -1333,11 +1333,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if ( ReparentOperation.ACTION_INVALID == operation ) { throw new NativeWindowException("Internal Error: reparentAction not set"); } - + if(DEBUG_IMPLEMENTATION) { System.err.println("Window.reparent: ACTION ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" new parentWindowHandle "+toHexString(newParentWindowHandle)+", reparentAction "+operation+", pos/size "+x+"/"+y+" "+width+"x"+height+", visible "+wasVisible); } - + if( ReparentOperation.ACTION_NOP == operation ) { return; } @@ -1401,18 +1401,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(ok) { requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */); - display.dispatchMessagesNative(); // status up2date + display.dispatchMessagesNative(); // status up2date } } } if(!ok || !wasVisible) { - // make size and position persistent manual, + // make size and position persistent manual, // since we don't have a WM feedback (invisible or recreation) definePosition(x, y); defineSize(width, height); } - + if(!ok) { // native reparent failed -> try creation, while trying to preserve resources if becoming visible again. if(DEBUG_IMPLEMENTATION) { @@ -1430,7 +1430,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer definePosition(x, y); defineSize(width, height); } - + if(DEBUG_IMPLEMENTATION) { System.err.println("Window.reparent: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } @@ -1451,7 +1451,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // This may run on the new Display/Screen connection, hence a new EDT task runOnEDTIfAvail(true, reparentActionRecreate); break; - + default: } } @@ -1566,7 +1566,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(WindowImpl.this.alwaysOnTop != alwaysOnTop) { // set current state WindowImpl.this.alwaysOnTop = alwaysOnTop; - + if( isNativeValid() ) { // Mirror pos/size so native change notification can get overwritten final int x = getX(); @@ -1591,12 +1591,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public final void setAlwaysOnTop(boolean value) { runOnEDTIfAvail(true, new AlwaysOnTopAction(value)); } - + @Override public final boolean isAlwaysOnTop() { return alwaysOnTop; } - + @Override public String getTitle() { return title; @@ -1624,7 +1624,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer setVal = setPointerVisibleImpl(pointerVisible); } if(setVal) { - this.pointerVisible = pointerVisible; + this.pointerVisible = pointerVisible; } } } @@ -1632,7 +1632,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public boolean isPointerConfined() { return pointerConfined; } - + @Override public void confinePointer(boolean confine) { if(this.pointerConfined != confine) { @@ -1652,18 +1652,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } if(setVal) { - this.pointerConfined = confine; + this.pointerConfined = confine; } - } + } } - + @Override public void warpPointer(int x, int y) { if(0 != getWindowHandle()) { warpPointerImpl(x, y); } } - + @Override public final InsetsImmutable getInsets() { if(isUndecorated()) { @@ -1672,7 +1672,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer updateInsetsImpl(insets); return insets; } - + @Override public final int getWidth() { return width; @@ -1694,8 +1694,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } protected final boolean autoPosition() { return autoPosition; } - - /** Sets the position fields {@link #x} and {@link #y} to the given values and {@link #autoPosition} to false. */ + + /** Sets the position fields {@link #x} and {@link #y} to the given values and {@link #autoPosition} to false. */ protected final void definePosition(int x, int y) { if(DEBUG_IMPLEMENTATION) { System.err.println("definePosition: "+this.x+"/"+this.y+" -> "+x+"/"+y); @@ -1705,7 +1705,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer this.x = x; this.y = y; } - /** Sets the size fields {@link #width} and {@link #height} to the given values. */ + /** Sets the size fields {@link #width} and {@link #height} to the given values. */ protected final void defineSize(int width, int height) { if(DEBUG_IMPLEMENTATION) { System.err.println("defineSize: "+this.width+"x"+this.height+" -> "+width+"x"+height); @@ -1713,7 +1713,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } this.width = width; this.height = height; } - + @Override public final boolean isVisible() { return visible; @@ -1732,7 +1732,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public final Window getDelegatedWindow() { return this; } - + //---------------------------------------------------------------------- // WindowImpl // @@ -1755,8 +1755,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return old; } - /** - * If this Window actually wraps a {@link NativeSurface} from another instance or toolkit, + /** + * If this Window actually wraps a {@link NativeSurface} from another instance or toolkit, * it will return such reference. Otherwise returns null. */ public NativeSurface getWrappedSurface() { @@ -1768,13 +1768,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer windowDestroyNotifyAction = r; } - /** - * Returns the non delegated {@link AbstractGraphicsConfiguration}, + /** + * Returns the non delegated {@link AbstractGraphicsConfiguration}, * see {@link #getGraphicsConfiguration()}. */ public final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() { return config; } - + protected final long getParentWindowHandle() { return isFullscreen() ? 0 : parentWindowHandle; } @@ -1864,7 +1864,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public void requestFocus(boolean wait) { requestFocus(wait /* wait */, false /* skipFocusAction */, brokenFocusChange /* force */); } - + private void requestFocus(boolean wait, boolean skipFocusAction, boolean force) { if( isNativeValid() && ( force || !hasFocus() ) && @@ -1872,7 +1872,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer runOnEDTIfAvail(wait, force ? requestFocusActionForced : requestFocusAction); } } - + /** Internally forcing request focus on current thread */ private void requestFocusInt(boolean skipFocusAction) { if( skipFocusAction || !focusAction() ) { @@ -1880,14 +1880,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("Window.RequestFocusInt: forcing - ("+getThreadName()+"): skipFocusAction "+skipFocusAction+", focus "+hasFocus+" -> true - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); } requestFocusImpl(true); - } + } } - + @Override public void setFocusAction(FocusRunnable focusAction) { this.focusAction = focusAction; } - + private boolean focusAction() { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.focusAction() START - "+getThreadName()+", focusAction: "+focusAction+" - windowHandle "+toHexString(getWindowHandle())); @@ -1903,16 +1903,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } return res; } - + protected void setBrokenFocusChange(boolean v) { brokenFocusChange = v; } - + @Override public void setKeyboardFocusHandler(KeyListener l) { keyboardFocusHandler = l; } - + private class SetPositionAction implements Runnable { int x, y; @@ -1932,7 +1932,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(isNativeValid()) { // this.x/this.y will be set by sizeChanged, triggered by windowing event system reconfigureWindowImpl(x, y, getWidth(), getHeight(), getReconfigureFlags(0, isVisible())); - + // Wait until custom position is reached within tolerances waitForPosition(true, x, y, Window.TIMEOUT_NATIVEWINDOW); } else { @@ -1950,16 +1950,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer autoPosition = false; runOnEDTIfAvail(true, new SetPositionAction(x, y)); } - + @Override public void setTopLevelPosition(int x, int y) { setPosition(x + getInsets().getLeftWidth(), y + getInsets().getTopHeight()); } - + private class FullScreenAction implements Runnable { boolean fullscreen; - private boolean init(boolean fullscreen) { + private boolean init(boolean fullscreen) { if(isNativeValid()) { this.fullscreen = fullscreen; return isFullscreen() != fullscreen; @@ -1967,7 +1967,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer WindowImpl.this.fullscreen = fullscreen; // set current state for createNative(..) return false; } - } + } public boolean fsOn() { return fullscreen; } public final void run() { @@ -1981,9 +1981,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final int oldY = getY(); final int oldWidth = getWidth(); final int oldHeight = getHeight(); - + int x,y,w,h; - + final RectangleImmutable sviewport = screen.getViewport(); final RectangleImmutable viewport; final int fs_span_flag; @@ -2007,7 +2007,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer nfs_y = oldY; nfs_width = oldWidth; nfs_height = oldHeight; - x = viewport.getX(); + x = viewport.getX(); y = viewport.getY(); w = viewport.getWidth(); h = viewport.getHeight(); @@ -2020,12 +2020,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer y = nfs_y; w = nfs_width; h = nfs_height; - + if(null!=parentWindow) { // reset position to 0/0 within parent space x = 0; y = 0; - + // refit if size is bigger than parent if( w > parentWindow.getWidth() ) { w = parentWindow.getWidth(); @@ -2044,7 +2044,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date final boolean wasVisible = isVisible(); - + // Lock parentWindow only during reparenting (attempt) final NativeWindow parentWindowLocked; if( null != parentWindow ) { @@ -2065,8 +2065,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer parentWindowLocked = null; } try { - reconfigureWindowImpl(x, y, w, h, - getReconfigureFlags( ( ( null != parentWindowLocked ) ? FLAG_CHANGE_PARENTING : 0 ) | + reconfigureWindowImpl(x, y, w, h, + getReconfigureFlags( ( ( null != parentWindowLocked ) ? FLAG_CHANGE_PARENTING : 0 ) | fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, isVisible()) ); } finally { if(null!=parentWindowLocked) { @@ -2074,7 +2074,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } display.dispatchMessagesNative(); // status up2date - + if(wasVisible) { setVisibleImpl(true, x, y, w, h); boolean ok = 0 <= WindowImpl.this.waitForVisible(true, false); @@ -2086,7 +2086,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(ok) { requestFocusInt(fullscreen /* skipFocusAction if fullscreen */); - display.dispatchMessagesNative(); // status up2date + display.dispatchMessagesNative(); // status up2date } if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs done: ok " + ok + ", " + WindowImpl.this); @@ -2098,24 +2098,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener } } - private final FullScreenAction fullScreenAction = new FullScreenAction(); + private final FullScreenAction fullScreenAction = new FullScreenAction(); @Override public boolean setFullscreen(boolean fullscreen) { return setFullscreenImpl(fullscreen, true, null); } - + @Override public boolean setFullscreen(List monitors) { return setFullscreenImpl(true, false, monitors); } - + private boolean setFullscreenImpl(boolean fullscreen, boolean useMainMonitor, List monitors) { synchronized(fullScreenAction) { fullscreenMonitors = monitors; fullscreenUseMainMonitor = useMainMonitor; if( fullScreenAction.init(fullscreen) ) { - if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { + if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { // enable fullscreen on offscreen instance if(null != parentWindow) { nfs_parent = parentWindow; @@ -2124,19 +2124,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer throw new InternalError("Offscreen instance w/o parent unhandled"); } } - + runOnEDTIfAvail(true, fullScreenAction); - + if(!fullScreenAction.fsOn() && null != nfs_parent) { // disable fullscreen on offscreen instance reparentWindow(nfs_parent, -1, -1, true /* forceDestroyCreate */); nfs_parent = null; } } - return this.fullscreen; + return this.fullscreen; } } - + private class MonitorModeListenerImpl implements MonitorModeListener { boolean animatorPaused = false; boolean hadFocus = false; @@ -2226,7 +2226,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer //---------------------------------------------------------------------- // Child Window Management - // + // @Override public final boolean removeChild(NativeWindow win) { @@ -2282,7 +2282,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window.consumeEvent: REPAINT "+Thread.currentThread().getName()+" - queued "+e+", discard-to "+discardTO); // Thread.dumpStack(); - } + } return discardTO; // discardTO:=true -> consumed } return true; @@ -2343,11 +2343,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // MouseListener/Event Support // - + // // Native MouseEvents pre-processed to be enqueued or consumed directly // - + public final void sendMouseEvent(short eventType, int modifiers, int x, int y, short button, float rotation) { doMouseEvent(false, false, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); @@ -2369,11 +2369,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int x, int y, short button, float[] rotationXYZ, float rotationScale) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); } */ - + /** * Send mouse event (one-pointer) either to be directly consumed or to be enqueued - * - * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, + * + * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. */ @@ -2383,7 +2383,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer throw new NativeWindowException("Invalid mouse button number" + button); } doPointerEvent(enqueue, wait, constMousePointerTypes, eventType, modifiers, - 0 /*actionIdx*/, new short[] { (short)(button-1) }, + 0 /*actionIdx*/, new short[] { (short)(button-1) }, new int[]{x}, new int[]{y}, new float[]{0f} /*pressure*/, 1f /*maxPressure*/, rotationXYZ, rotationScale); } @@ -2396,11 +2396,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer *

                      *

                      * The given pointer names, pNames, are mapped to consecutive pointer IDs starting w/ 0 - * using a hash-map if normalPNames is false. - * Otherwise a simple int to short type cast is performed. + * using a hash-map if normalPNames is false. + * Otherwise a simple int to short type cast is performed. *

                      - * - * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, + * + * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. * @param pTypes {@link MouseEvent.PointerType} for each pointer (multiple pointer) @@ -2410,14 +2410,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param normalPNames see pName below. * @param pNames Pointer name for each pointer (multiple pointer). * We assume consecutive pointer names starting w/ 0 if normalPIDs is true. - * Otherwise we hash-map the values during state pressed to retrieve the normal ID. + * Otherwise we hash-map the values during state pressed to retrieve the normal ID. * @param pX X-axis for each pointer (multiple pointer) * @param pY Y-axis for each pointer (multiple pointer) * @param pPressure Pressure for each pointer (multiple pointer) * @param maxPressure Maximum pointer pressure for all pointer */ public final void doPointerEvent(boolean enqueue, boolean wait, - final PointerType[] pTypes, short eventType, int modifiers, + final PointerType[] pTypes, short eventType, int modifiers, int actionIdx, boolean normalPNames, final int[] pNames, final int[] pX, final int[] pY, float[] pPressure, float maxPressure, final float[] rotationXYZ, final float rotationScale) { @@ -2447,25 +2447,25 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer pIDs[i] = (short)pNames[i]; } } - doPointerEvent(enqueue, wait, pTypes, eventType, modifiers, actionIdx, pIDs, + doPointerEvent(enqueue, wait, pTypes, eventType, modifiers, actionIdx, pIDs, pX, pY, pPressure, maxPressure, rotationXYZ, rotationScale); } - + /** * Send multiple-pointer event either to be directly consumed or to be enqueued *

                      * The index for the element of multiple-pointer arrays represents the pointer which triggered the event * is passed via actionIdx. - *

                      - * - * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, + *

                      + * + * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. * @param pTypes {@link MouseEvent.PointerType} for each pointer (multiple pointer) * @param eventType * @param modifiers * @param pActionIdx index of multiple-pointer arrays representing the pointer which triggered the event - * @param pID Pointer ID for each pointer (multiple pointer). We assume consecutive pointerIDs starting w/ 0. + * @param pID Pointer ID for each pointer (multiple pointer). We assume consecutive pointerIDs starting w/ 0. * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move. * @param pX X-axis for each pointer (multiple pointer) * @param pY Y-axis for each pointer (multiple pointer) @@ -2473,14 +2473,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param maxPressure Maximum pointer pressure for all pointer */ public final void doPointerEvent(boolean enqueue, boolean wait, - final PointerType[] pTypes, short eventType, int modifiers, + final PointerType[] pTypes, short eventType, int modifiers, int pActionIdx, final short[] pID, final int[] pX, final int[] pY, final float[] pPressure, float maxPressure, final float[] rotationXYZ, float rotationScale) { final long when = System.currentTimeMillis(); final int pCount = pTypes.length; - + if( 0 > pActionIdx || pActionIdx >= pCount) { - throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pCount-1)+"]"); + throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pCount-1)+"]"); } if( 0 < pActionIdx ) { // swap values to make idx 0 the triggering pointer @@ -2518,11 +2518,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer button = com.jogamp.newt.event.MouseEvent.BUTTON1; } } - + // // - Determine ENTERED/EXITED state // - Remove redundant move/drag events - // - Reset states if applicable + // - Reset states if applicable // int x = pX[0]; int y = pY[0]; @@ -2537,7 +2537,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer movePositionP0.set(0, 0); } // Fall through intended! - + case MouseEvent.EVENT_MOUSE_ENTERED: // clip coordinates to window dimension x = Math.min(Math.max(x, 0), getWidth()-1); @@ -2545,11 +2545,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer pState1.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; pState1.clearButton(); break; - + case MouseEvent.EVENT_MOUSE_MOVED: case MouseEvent.EVENT_MOUSE_DRAGGED: if( null != movePositionP0 ) { - if( pState1.insideWindow && movePositionP0.getX() == x && movePositionP0.getY() == y ) { + if( pState1.insideWindow && movePositionP0.getX() == x && movePositionP0.getY() == y ) { if(DEBUG_MOUSE_EVENT) { System.err.println("doPointerEvent: skip "+MouseEvent.getEventTypeString(eventType)+" w/ same position: "+movePositionP0); } @@ -2557,16 +2557,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } movePositionP0.set(x, y); } - + // Fall through intended ! - + default: if(!pState1.insideWindow) { - pState1.insideWindow = true; + pState1.insideWindow = true; pState1.clearButton(); } } - + if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { if(DEBUG_MOUSE_EVENT) { System.err.println("doPointerEvent: drop: "+MouseEvent.getEventTypeString(eventType)+ @@ -2582,29 +2582,29 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final int buttonMask = InputEvent.getButtonMask(button); modifiers |= buttonMask; // Always add current button to modifier mask (Bug 571) modifiers |= pState1.buttonPressedMask; // Always add currently pressed mouse buttons to modifier mask - + if( isPointerConfined() ) { modifiers |= InputEvent.CONFINED_MASK; } if( !isPointerVisible() ) { modifiers |= InputEvent.INVISIBLE_MASK; } - + pX[0] = x; pY[0] = y; - + // // - Determine CLICK COUNT // - Ignore sent CLICKED // - Track buttonPressed incl. buttonPressedMask // - Fix MOVED/DRAGGED event // - final MouseEvent e; + final MouseEvent e; switch( eventType ) { case MouseEvent.EVENT_MOUSE_CLICKED: e = null; break; - + case MouseEvent.EVENT_MOUSE_PRESSED: if( 0 >= pPressure[0] ) { pPressure[0] = maxPressure; @@ -2618,16 +2618,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } pState1.lastButtonPressTime = when; pState1.buttonPressed = button; - e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, pState1.lastButtonClickCount, rotationXYZ, rotationScale); } else { - e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); } break; case MouseEvent.EVENT_MOUSE_RELEASED: if( 1 == pCount ) { - e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, pState1.lastButtonClickCount, rotationXYZ, rotationScale); if( when - pState1.lastButtonPressTime >= MouseEvent.getClickTimeout() ) { pState1.lastButtonClickCount = (short)0; @@ -2635,7 +2635,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } pState1.buttonPressed = 0; } else { - e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); } pState1.buttonPressedMask &= ~buttonMask; @@ -2645,10 +2645,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer break; case MouseEvent.EVENT_MOUSE_MOVED: if ( 0 != pState1.buttonPressedMask ) { // any button or pointer move -> drag - e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, modifiers, pTypes, pID, + e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, pState1.buttonPressed, (short)1, rotationXYZ, rotationScale); } else { - e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)0, rotationXYZ, rotationScale); } break; @@ -2658,12 +2658,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } // Fall through intended! default: - e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, + e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)0, rotationXYZ, rotationScale); } doEvent(enqueue, wait, e); // actual mouse event } - + @Override public final void addMouseListener(MouseListener l) { addMouseListener(-1, l); @@ -2676,8 +2676,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); - if(0>index) { - index = clonedListeners.size(); + if(0>index) { + index = clonedListeners.size(); } clonedListeners.add(index, l); mouseListeners = clonedListeners; @@ -2698,8 +2698,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public final MouseListener getMouseListener(int index) { @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); - if(0>index) { - index = clonedListeners.size()-1; + if(0>index) { + index = clonedListeners.size()-1; } return clonedListeners.get(index); } @@ -2717,7 +2717,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public final boolean areDefaultGesturesEnabled() { return defaultGestureHandlerEnabled; } - + @Override public final void addGestureHandler(GestureHandler gh) { addGestureHandler(-1, gh); @@ -2729,7 +2729,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @SuppressWarnings("unchecked") ArrayList cloned = (ArrayList) pointerGestureHandler.clone(); - if(0>index) { + if(0>index) { index = cloned.size(); } cloned.add(index, gh); @@ -2756,7 +2756,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @SuppressWarnings("unchecked") ArrayList cloned = (ArrayList) gestureListeners.clone(); - if(0>index) { + if(0>index) { index = cloned.size(); } cloned.add(index, gl); @@ -2772,11 +2772,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer cloned.remove(gl); gestureListeners= cloned; } - + private static int step(int lower, int edge, int value) { return value < edge ? lower : value; } - + /** * Consume the {@link MouseEvent}, i.e. *
                      @@ -2786,18 +2786,18 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                            *   - dispatch event to listener
                            * 
                      */ - protected void consumePointerEvent(MouseEvent pe) { + protected void consumePointerEvent(MouseEvent pe) { int x = pe.getX(); int y = pe.getY(); - + if(DEBUG_MOUSE_EVENT) { System.err.println("consumePointerEvent.in: "+pe); } - + // // - Determine ENTERED/EXITED state // - Synthesize ENTERED event - // - Reset states if applicable + // - Reset states if applicable // final long when = pe.getWhen(); int eventType = pe.getEventType(); @@ -2812,7 +2812,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer pState0.clearButton(); eEntered = null; break; - + default: if(!pState0.insideWindow) { pState0.insideWindow = true; @@ -2833,12 +2833,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } return; // .. invalid .. } - + // // Handle Default Gestures // if( defaultGestureHandlerEnabled && - pe.getPointerType(0).getPointerClass() == MouseEvent.PointerClass.Onscreen ) + pe.getPointerType(0).getPointerClass() == MouseEvent.PointerClass.Onscreen ) { if( null == gesture2PtrTouchScroll ) { final int scaledScrollSlop; @@ -2849,16 +2849,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final float pixWPerMM = (float)monitor.getCurrentMode().getRotatedWidth() / (float)mm.getWidth(); final float pixHPerMM = (float)monitor.getCurrentMode().getRotatedHeight() / (float)mm.getHeight(); final float pixPerMM = Math.min(pixHPerMM, pixWPerMM); - scaledScrollSlop = Math.round(DoubleTapScrollGesture.SCROLL_SLOP_MM * pixPerMM); - scaledDoubleTapSlop = Math.round(DoubleTapScrollGesture.DOUBLE_TAP_SLOP_MM * pixPerMM); + scaledScrollSlop = Math.round(DoubleTapScrollGesture.SCROLL_SLOP_MM * pixPerMM); + scaledDoubleTapSlop = Math.round(DoubleTapScrollGesture.DOUBLE_TAP_SLOP_MM * pixPerMM); if(DEBUG_MOUSE_EVENT) { System.err.println("consumePointerEvent.gscroll: scrollSlop "+scaledScrollSlop+", doubleTapSlop "+scaledDoubleTapSlop+", pixPerMM "+pixPerMM+", "+monitor); } } else { scaledScrollSlop = DoubleTapScrollGesture.SCROLL_SLOP_PIXEL; - scaledDoubleTapSlop = DoubleTapScrollGesture.DOUBLE_TAP_SLOP_PIXEL; + scaledDoubleTapSlop = DoubleTapScrollGesture.DOUBLE_TAP_SLOP_PIXEL; } - gesture2PtrTouchScroll = new DoubleTapScrollGesture(step(DoubleTapScrollGesture.SCROLL_SLOP_PIXEL, DoubleTapScrollGesture.SCROLL_SLOP_PIXEL/2, scaledScrollSlop), + gesture2PtrTouchScroll = new DoubleTapScrollGesture(step(DoubleTapScrollGesture.SCROLL_SLOP_PIXEL, DoubleTapScrollGesture.SCROLL_SLOP_PIXEL/2, scaledScrollSlop), step(DoubleTapScrollGesture.DOUBLE_TAP_SLOP_PIXEL, DoubleTapScrollGesture.DOUBLE_TAP_SLOP_PIXEL/2, scaledDoubleTapSlop)); } if( gesture2PtrTouchScroll.process(pe) ) { @@ -2903,11 +2903,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } - + // // - Synthesize mouse CLICKED // - Ignore sent CLICKED - // + // final MouseEvent eClicked; switch( eventType ) { case MouseEvent.EVENT_MOUSE_PRESSED: @@ -2921,7 +2921,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer eClicked = pe.createVariant(MouseEvent.EVENT_MOUSE_CLICKED); } else { eClicked = null; - pState0.lastButtonPressTime = 0; + pState0.lastButtonPressTime = 0; } break; case MouseEvent.EVENT_MOUSE_CLICKED: @@ -2935,7 +2935,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer default: eClicked = null; } - + if( null != pe ) { if(DEBUG_MOUSE_EVENT) { System.err.println("consumePointerEvent.send.1: "+pe); @@ -2949,7 +2949,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer dispatchMouseEvent(eClicked); } } - + private final void dispatchMouseEvent(MouseEvent e) { for(int i = 0; !e.isConsumed() && i < mouseListeners.size(); i++ ) { MouseListener l = mouseListeners.get(i); @@ -2989,15 +2989,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // private static final int keyTrackingRange = 255; private final IntBitfield keyPressedState = new IntBitfield( keyTrackingRange + 1 ); - + protected final boolean isKeyCodeTracked(final short keyCode) { return ( 0xFFFF & (int)keyCode ) <= keyTrackingRange; } - + /** * @param keyCode the keyCode to set pressed state * @param pressed true if pressed, otherwise false - * @return the previus pressed value + * @return the previus pressed value */ protected final boolean setKeyPressed(short keyCode, boolean pressed) { final int v = 0xFFFF & (int)keyCode; @@ -3008,7 +3008,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** * @param keyCode the keyCode to test pressed state - * @return true if pressed, otherwise false + * @return true if pressed, otherwise false */ protected final boolean isKeyPressed(short keyCode) { final int v = 0xFFFF & (int)keyCode; @@ -3017,7 +3017,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } return false; } - + public void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask consumeKeyEvent( KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState1.buttonPressedMask, keyCode, keySym, keyChar) ); @@ -3027,12 +3027,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Always add currently pressed mouse buttons to modifier mask enqueueEvent(wait, KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState1.buttonPressedMask, keyCode, keySym, keyChar) ); } - + @Override public final void setKeyboardVisible(boolean visible) { if(isNativeValid()) { // We don't skip the impl. if it seems that there is no state change, - // since we cannot assume the impl. reliably gives us it's current state. + // since we cannot assume the impl. reliably gives us it's current state. final boolean ok = setKeyboardVisibleImpl(visible); if(DEBUG_IMPLEMENTATION || DEBUG_KEY_EVENT) { System.err.println("setKeyboardVisible(native): visible "+keyboardVisible+" -- op[visible:"+visible +", ok "+ok+"] -> "+(visible && ok)); @@ -3046,13 +3046,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public final boolean isKeyboardVisible() { return keyboardVisible; } - /** + /** * Returns true if operation was successful, otherwise false. *

                      * We assume that a failed invisible operation is due to an already invisible keyboard, - * hence even if an invisible operation failed, the keyboard is considered invisible! - *

                      - */ + * hence even if an invisible operation failed, the keyboard is considered invisible! + *

                      + */ protected boolean setKeyboardVisibleImpl(boolean visible) { return false; // nop } @@ -3066,7 +3066,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } protected boolean keyboardVisible = false; - + @Override public void addKeyListener(KeyListener l) { addKeyListener(-1, l); @@ -3079,7 +3079,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) keyListeners.clone(); - if(0>index) { + if(0>index) { index = clonedListeners.size(); } clonedListeners.add(index, l); @@ -3101,7 +3101,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public KeyListener getKeyListener(int index) { @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) keyListeners.clone(); - if(0>index) { + if(0>index) { index = clonedListeners.size()-1; } return clonedListeners.get(index); @@ -3125,7 +3125,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } return e.isConsumed(); } - + protected void consumeKeyEvent(KeyEvent e) { boolean consumedE = false; if( null != keyboardFocusHandler && !e.isAutoRepeat() ) { @@ -3164,7 +3164,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void addWindowListener(int index, WindowListener l) + public void addWindowListener(int index, WindowListener l) throws IndexOutOfBoundsException { if(l == null) { @@ -3172,8 +3172,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) windowListeners.clone(); - if(0>index) { - index = clonedListeners.size(); + if(0>index) { + index = clonedListeners.size(); } clonedListeners.add(index, l); windowListeners = clonedListeners; @@ -3194,8 +3194,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public WindowListener getWindowListener(int index) { @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) windowListeners.clone(); - if(0>index) { - index = clonedListeners.size()-1; + if(0>index) { + index = clonedListeners.size()-1; } return clonedListeners.get(index); } @@ -3234,7 +3234,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer l.windowRepaint((WindowUpdateEvent)e); break; default: - throw + throw new NativeWindowException("Unexpected window event type " + e.getEventType()); } @@ -3248,7 +3248,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("Window.focusChanged: ("+getThreadName()+"): (defer: "+defer+") "+this.hasFocus+" -> "+focusGained+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); } hasFocus = focusGained; - final int evt = focusGained ? WindowEvent.EVENT_WINDOW_GAINED_FOCUS : WindowEvent.EVENT_WINDOW_LOST_FOCUS ; + final int evt = focusGained ? WindowEvent.EVENT_WINDOW_GAINED_FOCUS : WindowEvent.EVENT_WINDOW_LOST_FOCUS ; if(!defer) { sendWindowEvent(evt); } else { @@ -3256,7 +3256,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } - + /** Triggered by implementation's WM events to update the visibility state. */ protected void visibleChanged(boolean defer, boolean visible) { if(this.visible != visible) { @@ -3282,7 +3282,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer display.dispatchMessagesNative(); // status up2date } if(this.visible != visible) { - final String msg = "Visibility not reached as requested within "+timeOut+"ms : requested "+visible+", is "+this.visible; + final String msg = "Visibility not reached as requested within "+timeOut+"ms : requested "+visible+", is "+this.visible; if(failFast) { throw new NativeWindowException(msg); } else if (DEBUG_IMPLEMENTATION) { @@ -3297,7 +3297,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - /** Triggered by implementation's WM events to update the client-area size w/o insets/decorations. */ + /** Triggered by implementation's WM events to update the client-area size w/o insets/decorations. */ protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { if(force || getWidth() != newWidth || getHeight() != newHeight) { if(DEBUG_IMPLEMENTATION) { @@ -3316,7 +3316,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } - + private boolean waitForSize(int w, int h, boolean failFast, long timeOut) { final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date @@ -3338,8 +3338,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return true; } } - - /** Triggered by implementation's WM events to update the position. */ + + /** Triggered by implementation's WM events to update the position. */ protected void positionChanged(boolean defer, int newX, int newY) { if ( getX() != newX || getY() != newY ) { if(DEBUG_IMPLEMENTATION) { @@ -3352,7 +3352,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer enqueueWindowEvent(false, WindowEvent.EVENT_WINDOW_MOVED); } } else { - autoPosition = false; // ensure it's off even w/ same position + autoPosition = false; // ensure it's off even w/ same position } } @@ -3396,10 +3396,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } return ok; } - + /** - * Triggered by implementation's WM events to update the insets. - * + * Triggered by implementation's WM events to update the insets. + * * @see #getInsets() * @see #updateInsetsImpl(Insets) */ @@ -3409,7 +3409,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window.insetsChanged: skip insets change for undecoration mode"); } - } else if ( (left != insets.getLeftWidth() || right != insets.getRightWidth() || + } else if ( (left != insets.getLeftWidth() || right != insets.getRightWidth() || top != insets.getTopHeight() || bottom != insets.getBottomHeight() ) ) { insets.set(left, right, top, bottom); @@ -3419,10 +3419,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } - + /** * Triggered by implementation's WM events or programmatic while respecting {@link #getDefaultCloseOperation()}. - * + * * @param force if true, overrides {@link #setDefaultCloseOperation(WindowClosingMode)} with {@link WindowClosingProtocol#DISPOSE_ON_CLOSE} * and hence force destruction. Otherwise is follows the user settings. * @return true if this window is no more valid and hence has been destroyed, otherwise false. @@ -3434,9 +3434,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("Window.windowDestroyNotify(isNativeValid: "+isNativeValid()+", force: "+force+", mode "+defMode+" -> "+mode+") "+getThreadName()+": "+this); // Thread.dumpStack(); } - + final boolean destroyed; - + if( isNativeValid() ) { if( WindowClosingMode.DISPOSE_ON_CLOSE == mode ) { if(force) { @@ -3457,7 +3457,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // send synced destroy notifications sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); } - + destroyed = !isNativeValid(); } else { destroyed = true; @@ -3465,19 +3465,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window.windowDestroyNotify(isNativeValid: "+isNativeValid()+", force: "+force+", mode "+mode+") END "+getThreadName()+": destroyed "+destroyed+", "+this); - } - + } + return destroyed; } @Override public void windowRepaint(int x, int y, int width, int height) { - windowRepaint(false, x, y, width, height); + windowRepaint(false, x, y, width, height); } - + /** * Triggered by implementation's WM events to update the content - */ + */ protected void windowRepaint(boolean defer, int x, int y, int width, int height) { width = ( 0 >= width ) ? getWidth() : width; height = ( 0 >= height ) ? getHeight() : height; @@ -3542,7 +3542,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected final void shouldNotCallThis() { throw new NativeWindowException("Should not call this"); } - + public static String getThreadName() { return Display.getThreadName(); } diff --git a/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java index 861a6d6be..2ba5b3460 100644 --- a/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java +++ b/src/newt/classes/jogamp/newt/awt/NewtFactoryAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.newt.awt; import javax.media.nativewindow.AbstractGraphicsConfiguration; @@ -76,12 +76,12 @@ public class NewtFactoryAWT extends NewtFactory { } return (JAWTWindow)nw; } - + public static void destroyNativeWindow(JAWTWindow jawtWindow) { final AbstractGraphicsConfiguration config = jawtWindow.getGraphicsConfiguration(); jawtWindow.destroy(); - config.getScreen().getDevice().close(); + config.getScreen().getDevice().close(); } - + } diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index d71ad175b..0ee3cc0cd 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,26 +20,26 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.newt.awt.event; import com.jogamp.newt.event.MouseEvent; /** * - *
                      AWT Event Modifier Mapping
                      + *
                      AWT Event Modifier Mapping
                      *
                           Modifier       AWT Constant                     AWT Bit  AWT Ex  NEWT Constant              NEWT Bit
                           -------------  -------------------------------  -------  ------  -------------------------  --------
                      -    Shift          Event.SHIFT_MASK                 0                
                      -    Ctrl           Event.CTRL_MASK                  1                
                      -    Meta           Event.META_MASK                  2                
                      -    Alt            Event.ALT_MASK                   3               
                      +    Shift          Event.SHIFT_MASK                 0
                      +    Ctrl           Event.CTRL_MASK                  1
                      +    Meta           Event.META_MASK                  2
                      +    Alt            Event.ALT_MASK                   3
                           Button1        InputEvent.BUTTON1_MASK          4
                           Button2        InputEvent.BUTTON2_MASK          3
                           Button3        InputEvent.BUTTON3_MASK          2
                      @@ -88,10 +88,10 @@ public class AWTNewtEventFactory {
                                   Method _getMaskForButtonMethod = null;
                                   try {
                                       _getMaskForButtonMethod = ReflectionUtil.getMethod(java.awt.event.InputEvent.class, "getMaskForButton", int.class);
                      -            } catch(Throwable t) {}        
                      +            } catch(Throwable t) {}
                                   getMaskForButtonMethod = _getMaskForButtonMethod;
                               } */
                      -        
                      +
                               awtButtonDownMasks = new int[com.jogamp.newt.event.MouseEvent.BUTTON_COUNT] ; // java.awt.MouseInfo.getNumberOfButtons() ;
                               for (int n = 0 ; n < awtButtonDownMasks.length ; ++n) {
                                   awtButtonDownMasks[n] = getAWTButtonDownMaskImpl(n+1);
                      @@ -112,12 +112,12 @@ public class AWTNewtEventFactory {
                                   case java.awt.event.WindowEvent.WINDOW_LOST_FOCUS: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS;
                                   case java.awt.event.FocusEvent.FOCUS_LOST: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS;
                                   // n/a case java.awt.event.WindowEvent.WINDOW_STATE_CHANGED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_STATE_CHANGED;
                      -    
                      +
                                   case java.awt.event.ComponentEvent.COMPONENT_MOVED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_MOVED;
                                   case java.awt.event.ComponentEvent.COMPONENT_RESIZED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_RESIZED;
                                   // n/a case java.awt.event.ComponentEvent.COMPONENT_SHOWN: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_SHOWN;
                                   // n/a case java.awt.event.ComponentEvent.COMPONENT_HIDDEN: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_HIDDEN;
                      -    
                      +
                                   case java.awt.event.MouseEvent.MOUSE_CLICKED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED;
                                   case java.awt.event.MouseEvent.MOUSE_PRESSED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED;
                                   case java.awt.event.MouseEvent.MOUSE_RELEASED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED;
                      @@ -126,17 +126,17 @@ public class AWTNewtEventFactory {
                                   case java.awt.event.MouseEvent.MOUSE_EXITED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED;
                                   case java.awt.event.MouseEvent.MOUSE_DRAGGED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED;
                                   case java.awt.event.MouseEvent.MOUSE_WHEEL: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED;
                      -    
                      +
                                   case java.awt.event.KeyEvent.KEY_PRESSED: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED;
                                   case java.awt.event.KeyEvent.KEY_RELEASED: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED;
                               }
                               return (short)0;
                           }
                      -    
                      +
                           private static int getAWTButtonDownMaskImpl(int button) {
                               /**
                                * java.awt.event.InputEvent.getMaskForButton(button);
                      -         * 
                      +         *
                               if(null != getMaskForButtonMethod) {
                                   Object r=null;
                                   try {
                      @@ -157,16 +157,16 @@ public class AWTNewtEventFactory {
                                           m = 1 << ( 10 + button ) ; // b4 = 1<<14, b5 = 1<<15, etc
                                       } else {
                                           m = 0;
                      -                }                
                      +                }
                               }
                               return m;
                           }
                      -    
                      +
                           /**
                            * 

                      * See AWT event modifier mapping details. *

                      - * + * * @param button * @return */ @@ -175,9 +175,9 @@ public class AWTNewtEventFactory { return awtButtonDownMasks[button-1]; } else { return 0; - } + } } - + public static final short awtButton2Newt(int awtButton) { if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { return (short)awtButton; @@ -185,32 +185,32 @@ public class AWTNewtEventFactory { return (short)0; } } - + /** * Converts the specified set of AWT event modifiers and extended event * modifiers to the equivalent NEWT event modifiers. - * + * *

                      * See AWT event modifier mapping details. *

                      - * + * * @param awtMods * The AWT event modifiers. - * + * * @param awtModsEx * The AWT extended event modifiers. * AWT passes mouse button specific bits here and are the preferred way check the mouse button state. */ public static final int awtModifiers2Newt(final int awtMods, final int awtModsEx) { int newtMods = 0; - + /** Redundant old modifiers .. if ((awtMods & java.awt.event.InputEvent.SHIFT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; if ((awtMods & java.awt.event.InputEvent.CTRL_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK; if ((awtMods & java.awt.event.InputEvent.META_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; if ((awtMods & java.awt.event.InputEvent.ALT_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK; if ((awtMods & java.awt.event.InputEvent.ALT_GRAPH_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK; */ - + if ((awtModsEx & java.awt.event.InputEvent.SHIFT_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; if ((awtModsEx & java.awt.event.InputEvent.CTRL_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK; if ((awtModsEx & java.awt.event.InputEvent.META_DOWN_MASK) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; @@ -221,7 +221,7 @@ public class AWTNewtEventFactory { // being ignored intentionally. The AWT docs say that the // BUTTON1_DOWN_MASK etc bits in the extended modifiers are // the preferred place to check current button state. - + if( 0 != awtModsEx ) { for (int n = 0 ; n < awtButtonDownMasks.length ; ++n) { if ( (awtModsEx & awtButtonDownMasks[n]) != 0 ) { @@ -232,7 +232,7 @@ public class AWTNewtEventFactory { return newtMods; } - + public static short awtKeyCode2NewtKeyCode(final int awtKeyCode) { final short defNEWTKeyCode = (short)awtKeyCode; switch (awtKeyCode) { @@ -371,7 +371,7 @@ public class AWTNewtEventFactory { case java.awt.event.KeyEvent.VK_MULTIPLY : return com.jogamp.newt.event.KeyEvent.VK_MULTIPLY; case java.awt.event.KeyEvent.VK_DIVIDE : return com.jogamp.newt.event.KeyEvent.VK_DIVIDE; case java.awt.event.KeyEvent.VK_NUM_LOCK : return com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK; - case java.awt.event.KeyEvent.VK_KP_LEFT : /** Fall through intended .. */ + case java.awt.event.KeyEvent.VK_KP_LEFT : /** Fall through intended .. */ case java.awt.event.KeyEvent.VK_LEFT : return com.jogamp.newt.event.KeyEvent.VK_LEFT; case java.awt.event.KeyEvent.VK_KP_UP : /** Fall through intended .. */ case java.awt.event.KeyEvent.VK_UP : return com.jogamp.newt.event.KeyEvent.VK_UP; @@ -381,7 +381,7 @@ public class AWTNewtEventFactory { case java.awt.event.KeyEvent.VK_DOWN : return com.jogamp.newt.event.KeyEvent.VK_DOWN; case java.awt.event.KeyEvent.VK_CONTEXT_MENU : return com.jogamp.newt.event.KeyEvent.VK_CONTEXT_MENU; case java.awt.event.KeyEvent.VK_WINDOWS : return com.jogamp.newt.event.KeyEvent.VK_WINDOWS; - case java.awt.event.KeyEvent.VK_META : return com.jogamp.newt.event.KeyEvent.VK_META; + case java.awt.event.KeyEvent.VK_META : return com.jogamp.newt.event.KeyEvent.VK_META; case java.awt.event.KeyEvent.VK_HELP : return com.jogamp.newt.event.KeyEvent.VK_HELP; case java.awt.event.KeyEvent.VK_COMPOSE : return com.jogamp.newt.event.KeyEvent.VK_COMPOSE; case java.awt.event.KeyEvent.VK_BEGIN : return com.jogamp.newt.event.KeyEvent.VK_BEGIN; @@ -558,7 +558,7 @@ public class AWTNewtEventFactory { case com.jogamp.newt.event.KeyEvent.VK_DOWN : return java.awt.event.KeyEvent.VK_DOWN; case com.jogamp.newt.event.KeyEvent.VK_CONTEXT_MENU : return java.awt.event.KeyEvent.VK_CONTEXT_MENU; case com.jogamp.newt.event.KeyEvent.VK_WINDOWS : return java.awt.event.KeyEvent.VK_WINDOWS; - case com.jogamp.newt.event.KeyEvent.VK_META : return java.awt.event.KeyEvent.VK_META; + case com.jogamp.newt.event.KeyEvent.VK_META : return java.awt.event.KeyEvent.VK_META; case com.jogamp.newt.event.KeyEvent.VK_HELP : return java.awt.event.KeyEvent.VK_HELP; case com.jogamp.newt.event.KeyEvent.VK_COMPOSE : return java.awt.event.KeyEvent.VK_COMPOSE; case com.jogamp.newt.event.KeyEvent.VK_BEGIN : return java.awt.event.KeyEvent.VK_BEGIN; @@ -636,7 +636,7 @@ public class AWTNewtEventFactory { } return new com.jogamp.newt.event.MouseEvent( newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), - mods, event.getX(), event.getY(), (short)event.getClickCount(), + mods, event.getX(), event.getY(), (short)event.getClickCount(), newtButton, MouseEvent.getRotationXYZ(rotation, mods), 1f); } return null; // no mapping .. @@ -650,11 +650,11 @@ public class AWTNewtEventFactory { if( (short)0 != newtType ) { final short newtKeyCode = awtKeyCode2NewtKeyCode( event.getKeyCode() ); return com.jogamp.newt.event.KeyEvent.create( - newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), - awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()), + newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), + awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()), newtKeyCode, newtKeyCode, event.getKeyChar()); } return null; // no mapping .. } - + } diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index fa494adca..325f17278 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.newt.awt.event; import java.awt.KeyboardFocusManager; @@ -45,7 +45,7 @@ import com.jogamp.newt.event.awt.AWTWindowAdapter; public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt.event.HierarchyListener { NativeWindow downstreamParent; - + public AWTParentWindowAdapter(NativeWindow downstreamParent, com.jogamp.newt.Window downstream) { super(downstream); this.downstreamParent = downstreamParent; @@ -111,12 +111,12 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt public void componentMoved(java.awt.event.ComponentEvent e) { if(DEBUG_IMPLEMENTATION) { - System.err.println("AWT: componentMoved: "+e); + System.err.println("AWT: componentMoved: "+e); } final Window newtWindow = getNewtWindow(); if(newtWindow.getDelegatedWindow() instanceof DriverUpdatePosition) { ((DriverUpdatePosition)newtWindow.getDelegatedWindow()).updatePosition(0, 0); - } + } } public void windowActivated(java.awt.event.WindowEvent e) { @@ -130,7 +130,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt public void hierarchyChanged(java.awt.event.HierarchyEvent e) { if( null == getNewtEventListener() ) { long bits = e.getChangeFlags(); - final java.awt.Component changed = e.getChanged(); + final java.awt.Component changed = e.getChanged(); if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) { final boolean showing = changed.isShowing(); if(DEBUG_IMPLEMENTATION) { @@ -142,7 +142,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt getNewtWindow().setVisible(showing); } }}); - } + } if(DEBUG_IMPLEMENTATION) { if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) { final boolean displayability = changed.isDisplayable(); diff --git a/src/newt/classes/jogamp/newt/driver/DriverClearFocus.java b/src/newt/classes/jogamp/newt/driver/DriverClearFocus.java index 0a824e83b..0ff86fe93 100644 --- a/src/newt/classes/jogamp/newt/driver/DriverClearFocus.java +++ b/src/newt/classes/jogamp/newt/driver/DriverClearFocus.java @@ -1,10 +1,10 @@ package jogamp.newt.driver; -/** +/** * Interface tagging driver requirement of clearing the focus. *

                      - * Some drivers require a programmatic {@link #clearFocus()} when traversing the focus. - *

                      + * Some drivers require a programmatic {@link #clearFocus()} when traversing the focus. + *

                      */ public interface DriverClearFocus { /** Programmatic clear the focus */ diff --git a/src/newt/classes/jogamp/newt/driver/DriverUpdatePosition.java b/src/newt/classes/jogamp/newt/driver/DriverUpdatePosition.java index 2ec327187..e5f9b6a68 100644 --- a/src/newt/classes/jogamp/newt/driver/DriverUpdatePosition.java +++ b/src/newt/classes/jogamp/newt/driver/DriverUpdatePosition.java @@ -1,14 +1,14 @@ package jogamp.newt.driver; -/** +/** * Interface tagging driver requirement of absolute positioning, ie. depend on parent position. */ public interface DriverUpdatePosition { - /** + /** * Programmatic update the top-left corner * of the client area relative to it's parent. - * - * @param x x-component + * + * @param x x-component * @param y y-component **/ void updatePosition(int x, int y); diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index 9a1632130..14cc9c69d 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.awt; @@ -100,7 +100,7 @@ public class AWTCanvas extends Canvas { @Override public void paint(Graphics g) { } - + public boolean hasDeviceChanged() { boolean res = displayConfigChanged; displayConfigChanged=false; @@ -154,12 +154,12 @@ public class AWTCanvas extends Canvas { public NativeWindow getNativeWindow() { final JAWTWindow _jawtWindow = jawtWindow; return (null != _jawtWindow) ? _jawtWindow : null; - } - + } + public boolean isOffscreenLayerSurfaceEnabled() { - return null != jawtWindow ? jawtWindow.isOffscreenLayerSurfaceEnabled() : false; + return null != jawtWindow ? jawtWindow.isOffscreenLayerSurfaceEnabled() : false; } - + public void removeNotify() { try { dispose(); @@ -188,7 +188,7 @@ public class AWTCanvas extends Canvas { } } } - + private String getThreadName() { return Thread.currentThread().getName(); } /** @@ -200,7 +200,7 @@ public class AWTCanvas extends Canvas { * Workaround for problems with Xinerama and java.awt.Component.checkGD * when adding to a container on a different graphics device than the * one that this Canvas is associated with. - * + * * GC will be null unless: * - A native peer has assigned it. This means we have a native * peer, and are already comitted to a graphics configuration. @@ -214,7 +214,7 @@ public class AWTCanvas extends Canvas { * chosen is only non-null on platforms where the GLDrawableFactory * returns a non-null GraphicsConfiguration (in the GLCanvas * constructor). - * + * * if gc is from this Canvas' native peer then it should equal chosen, * otherwise it is from an ancestor component that this Canvas is being * added to, and we go into this block. @@ -224,21 +224,21 @@ public class AWTCanvas extends Canvas { * Check for compatibility with gc. If they differ by only the * device then return a new GCconfig with the super-class' GDevice * (and presumably the same visual ID in Xinerama). - * + * */ if (!chosen.getDevice().getIDstring().equals(gc.getDevice().getIDstring())) { /* * Here we select a GraphicsConfiguration on the alternate * device that is presumably identical to the chosen * configuration, but on the other device. - * + * * Should really check to ensure that we select a configuration * with the same X visual ID for Xinerama screens, otherwise the * GLDrawable may have the wrong visual ID (I don't think this * ever gets updated). May need to add a method to * X11GLDrawableFactory to do this in a platform specific * manner. - * + * * However, on platforms where we can actually get into this * block, both devices should have the same visual list, and the * same configuration should be selected here. @@ -265,7 +265,7 @@ public class AWTCanvas extends Canvas { chosen = compatible; if( !config.getChosenCapabilities().equals(awtConfig.getChosenCapabilities())) { displayConfigChanged=true; - } + } awtConfig = config; } } @@ -275,7 +275,7 @@ public class AWTCanvas extends Canvas { * return the GC that was selected in the constructor (and might * cause an exception in Component.checkGD when adding to a * container, but in this case that would be the desired behavior). - * + * */ return chosen; } else if (gc == null) { @@ -299,7 +299,7 @@ public class AWTCanvas extends Canvas { CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, GraphicsDevice device) { - final AbstractGraphicsScreen aScreen = null != device ? + final AbstractGraphicsScreen aScreen = null != device ? AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT): AWTGraphicsScreen.createDefault(); AWTGraphicsConfiguration config = (AWTGraphicsConfiguration) diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 02f4be0cd..bddb43b30 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -40,9 +40,9 @@ import jogamp.newt.Debug; public class AWTEDTUtil implements EDTUtil { public static final boolean DEBUG = Debug.debug("EDT"); - + private final Object edtLock = new Object(); // locking the EDT start/stop state - private final ThreadGroup threadGroup; + private final ThreadGroup threadGroup; private final String name; private final Runnable dispatchMessages; private NEDT nedt = null; @@ -66,7 +66,7 @@ public class AWTEDTUtil implements EDTUtil { final public void setPollPeriod(long ms) { pollPeriod = ms; } - + @Override public final boolean start() throws IllegalStateException { synchronized(edtLock) { @@ -107,12 +107,12 @@ public class AWTEDTUtil implements EDTUtil { public final boolean isCurrentThreadNEDT() { return nedt == Thread.currentThread(); } - + @Override public final boolean isCurrentThreadEDTorNEDT() { - return EventQueue.isDispatchThread() || nedt == Thread.currentThread(); + return EventQueue.isDispatchThread() || nedt == Thread.currentThread(); } - + @Override final public boolean isRunning() { return nedt.isRunning() ; @@ -127,12 +127,12 @@ public class AWTEDTUtil implements EDTUtil { public final boolean invoke(boolean wait, Runnable task) { return invokeImpl(wait, task, false); } - + private static Runnable nullTask = new Runnable() { @Override - public void run() { } + public void run() { } }; - + private final boolean invokeImpl(boolean wait, Runnable task, boolean stop) { Throwable throwable = null; RunnableTask rTask = null; @@ -145,7 +145,7 @@ public class AWTEDTUtil implements EDTUtil { if(DEBUG) { Thread.dumpStack(); } - return false; + return false; } if( isCurrentThreadEDT() ) { if(null != task) { @@ -181,7 +181,7 @@ public class AWTEDTUtil implements EDTUtil { if(null != task) { rTask = new RunnableTask(task, wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */, + true /* always catch and report Exceptions, don't disturb EDT */, wait ? null : System.err); AWTEDTExecutor.singleton.invoke(false, rTask); } @@ -205,7 +205,7 @@ public class AWTEDTUtil implements EDTUtil { } return true; } - } + } @Override final public boolean waitUntilIdle() { @@ -241,7 +241,7 @@ public class AWTEDTUtil implements EDTUtil { } } } - + class NEDT extends Thread { volatile boolean shouldStop = false; volatile boolean isRunning = false; @@ -261,7 +261,7 @@ public class AWTEDTUtil implements EDTUtil { super.start(); } - /** + /** * Utilizing locking only on tasks and its execution, * not for event dispatching. */ @@ -302,7 +302,7 @@ public class AWTEDTUtil implements EDTUtil { } } finally { if(DEBUG) { - System.err.println(getName()+": AWT-EDT run() END "+ getName()+", "+error); + System.err.println(getName()+": AWT-EDT run() END "+ getName()+", "+error); } synchronized(edtLock) { isRunning = false; @@ -317,7 +317,7 @@ public class AWTEDTUtil implements EDTUtil { } // finally } // run() } // EventDispatchThread - + } diff --git a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java index 30449f9bc..9e716d544 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.awt; @@ -57,7 +57,7 @@ public class DisplayDriver extends DisplayImpl { protected EDTUtil createEDTUtil() { final EDTUtil def; if(NewtFactory.useEDT()) { - def = new AWTEDTUtil(Thread.currentThread().getThreadGroup(), "AWTDisplay-"+getFQName(), dispatchMessagesRunnable); + def = new AWTEDTUtil(Thread.currentThread().getThreadGroup(), "AWTDisplay-"+getFQName(), dispatchMessagesRunnable); if(DEBUG) { System.err.println("Display.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName()); } @@ -67,7 +67,7 @@ public class DisplayDriver extends DisplayImpl { return def; } - protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java index 126143e1e..a2430e2bb 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,7 +28,7 @@ * 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 jogamp.newt.driver.awt; @@ -66,10 +66,10 @@ public class ScreenDriver extends ScreenImpl { } protected void closeNativeImpl() { } - + protected int validateScreenIndex(int idx) { - return idx; // pass through ... - } + return idx; // pass through ... + } private static MonitorMode getModeProps(Cache cache, DisplayMode mode) { int rate = mode.getRefreshRate(); @@ -90,16 +90,16 @@ public class ScreenDriver extends ScreenImpl { props[i++] = 0; // flags props[i++] = 0; // mode_idx props[i++] = 0; // rotation - return MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + return MonitorModeProps.streamInMonitorMode(null, cache, props, 0); } - + @Override protected void collectNativeMonitorModesAndDevicesImpl(Cache cache) { final GraphicsDevice awtGD = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice(); final DisplayMode[] awtModes = awtGD.getDisplayModes(); for(int i=0; i=0 || y>=0) { System.err.println("BCEGL Window.setPositionImpl n/a in BroadcomEGL"); } - + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } @@ -122,7 +122,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } protected void updateInsetsImpl(Insets insets) { - // nop .. + // nop .. } @Override diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java index 4872a9071..52c92a5da 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -72,7 +72,7 @@ public class DisplayDriver extends DisplayImpl { DispatchMessages(); } - protected static native boolean initIDs(); + protected static native boolean initIDs(); private native void DispatchMessages(); } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java index be99052d7..5a1917419 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -53,9 +53,9 @@ public class ScreenDriver extends ScreenImpl { protected void closeNativeImpl() { } protected int validateScreenIndex(int idx) { - return 0; // only one screen available - } - + return 0; // only one screen available + } + @Override protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; @@ -92,20 +92,20 @@ public class ScreenDriver extends ScreenImpl { protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { return false; } - + @Override protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { vOriginSize.set(0, 0, cachedWidth, cachedHeight); } - + /** Called from {@link #initNative()}. */ protected void setScreenSize(int width, int height) { cachedWidth = width; cachedHeight = height; } - + private static int cachedWidth = 0; - private static int cachedHeight = 0; + private static int cachedHeight = 0; protected static native boolean initIDs(); protected native void initNative(); diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index e820439d0..560e49e96 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -65,7 +65,7 @@ public class WindowDriver extends WindowImpl { final EGLGraphicsDevice aDevice = (EGLGraphicsDevice) aScreen.getDevice(); final EGLGraphicsDevice eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(aDevice.getNativeDisplayID(), aDevice.getConnection(), aDevice.getUnitID()); final DefaultGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aScreen.getIndex()); - + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( capsRequested, capsRequested, capabilitiesChooser, eglScreen, VisualIDHolder.VID_UNDEFINED); if (null == cfg) { @@ -89,24 +89,24 @@ public class WindowDriver extends WindowImpl { windowHandleClose = nativeWindowHandle; addWindowListener(LinuxMouseTracker.getSingleton()); addWindowListener(LinuxEventDeviceTracker.getSingleton()); - focusChanged(false, true); + focusChanged(false, true); } protected void closeNativeImpl() { final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getGraphicsConfiguration().getScreen().getDevice(); - + removeWindowListener(LinuxMouseTracker.getSingleton()); removeWindowListener(LinuxEventDeviceTracker.getSingleton()); - + if(0!=windowHandleClose) { CloseWindow(windowHandleClose, windowUserData); windowUserData=0; } - + eglDevice.close(); } - protected void requestFocusImpl(boolean reparented) { + protected void requestFocusImpl(boolean reparented) { focusChanged(false, true); } @@ -115,7 +115,7 @@ public class WindowDriver extends WindowImpl { setVisible0(nativeWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } - + if(0!=nativeWindowHandle) { if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; @@ -135,11 +135,11 @@ public class WindowDriver extends WindowImpl { System.err.println("setPosition n/a in KD"); } } - + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } - + return true; } @@ -148,9 +148,9 @@ public class WindowDriver extends WindowImpl { } protected void updateInsetsImpl(Insets insets) { - // nop .. + // nop .. } - + //---------------------------------------------------------------------- // Internals only // diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java index ee93eb932..4cb566bc2 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2012 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.intel.gdl; diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java index 27b776562..b5202aaf9 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2012 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.intel.gdl; @@ -62,9 +62,9 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { protected void closeNativeImpl() { } protected int validateScreenIndex(int idx) { - return 0; // only one screen available + return 0; // only one screen available } - + @Override protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; @@ -101,11 +101,11 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { return false; } - + protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { vOriginSize.set(0, 0, cachedWidth, cachedHeight); } - + //---------------------------------------------------------------------- // Internals only // @@ -118,7 +118,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { cachedWidth = width; cachedHeight = height; } - + private static int cachedWidth = 0; private static int cachedHeight = 0; } diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java index 98335f192..80821d4da 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2012 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.intel.gdl; @@ -108,7 +108,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } - + return true; } @@ -126,9 +126,9 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } protected void updateInsetsImpl(Insets insets) { - // nop .. + // nop .. } - + //---------------------------------------------------------------------- // Internals only // diff --git a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java index 3cd72e971..1b92ca586 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2012 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.kd; diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java index f893275ca..17cc5dd2f 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2012 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.kd; @@ -58,9 +58,9 @@ public class ScreenDriver extends ScreenImpl { protected void closeNativeImpl() { } protected int validateScreenIndex(int idx) { - return 0; // only one screen available - } - + return 0; // only one screen available + } + @Override protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; @@ -97,16 +97,16 @@ public class ScreenDriver extends ScreenImpl { protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { return false; } - + protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { vOriginSize.set(0, 0, cachedWidth, cachedHeight); } - + protected void sizeChanged(int w, int h) { cachedWidth = w; cachedHeight = h; } - + private static int cachedWidth = 0; - private static int cachedHeight = 0; + private static int cachedHeight = 0; } diff --git a/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java index c733a3e94..d30d4f025 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2012 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.kd; @@ -97,7 +97,7 @@ public class WindowDriver extends WindowImpl { setVisible0(eglWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } - + if(0!=eglWindowHandle) { if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; @@ -117,11 +117,11 @@ public class WindowDriver extends WindowImpl { System.err.println("setPosition n/a in KD"); } } - + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } - + return true; } @@ -130,9 +130,9 @@ public class WindowDriver extends WindowImpl { } protected void updateInsetsImpl(Insets insets) { - // nop .. + // nop .. } - + //---------------------------------------------------------------------- // Internals only // diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java index e68b91d82..b7c86a26d 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxEventDeviceTracker.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -126,7 +126,7 @@ public class LinuxEventDeviceTracker implements WindowListener { try { while(true) { Thread.sleep(1000); - } + } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -186,7 +186,7 @@ public class LinuxEventDeviceTracker implements WindowListener { /** * The Linux input event interface. * http://www.kernel.org/doc/Documentation/input/input.txt - * + * * struct input_event { * struct timeval time; * unsigned short type; @@ -262,7 +262,7 @@ public class LinuxEventDeviceTracker implements WindowListener { break; case 1: // EV_KEY keyCode = LinuxEVKey2NewtVKey(code); // The device independent code. - keyChar = NewtVKey2Unicode(keyCode, modifiers); // The printable character w/ key modifiers. + keyChar = NewtVKey2Unicode(keyCode, modifiers); // The printable character w/ key modifiers. if(Window.DEBUG_KEY_EVENT) { System.out.println("[EV_KEY: [time "+timeSeconds+":"+timeSecondFraction+"] type "+type+" / code "+code+" = value "+value); } @@ -946,7 +946,7 @@ public class LinuxEventDeviceTracker implements WindowListener { case 248: // mic mute break; // FIXME - default: + default: } if(Window.DEBUG_KEY_EVENT) { diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java index 0d6278bfb..1e314b7f4 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -48,16 +48,16 @@ import com.jogamp.newt.event.WindowUpdateEvent; * within it's own polling thread. */ public class LinuxMouseTracker implements WindowListener { - + private static final LinuxMouseTracker lmt; - + static { lmt = new LinuxMouseTracker(); final Thread t = new Thread(lmt.mouseDevicePoller, "NEWT-LinuxMouseTracker"); t.setDaemon(true); t.start(); } - + public static LinuxMouseTracker getSingleton() { return lmt; } @@ -71,7 +71,7 @@ public class LinuxMouseTracker implements WindowListener { private short old_buttonDown = 0; private WindowImpl focusedWindow = null; private MouseDevicePoller mouseDevicePoller = new MouseDevicePoller(); - + @Override public void windowResized(WindowEvent e) { } @@ -107,7 +107,7 @@ public class LinuxMouseTracker implements WindowListener { @Override public void windowRepaint(WindowUpdateEvent e) { } - + class MouseDevicePoller implements Runnable { @Override public void run() { @@ -150,17 +150,17 @@ public class LinuxMouseTracker implements WindowListener { yo=(b[0]&128)>0; xd=b[1]; yd=b[2]; - + x+=xd; y-=yd; - + if(x<0) { x=0; } if(y<0) { y=0; } - + buttonDown = 0; if(lb) { buttonDown = MouseEvent.BUTTON1; @@ -171,7 +171,7 @@ public class LinuxMouseTracker implements WindowListener { if(rb) { buttonDown = MouseEvent.BUTTON3; } - + if(null != focusedWindow) { if( x >= focusedWindow.getScreen().getWidth() ) { x = focusedWindow.getScreen().getWidth() - 1; @@ -179,31 +179,31 @@ public class LinuxMouseTracker implements WindowListener { if( y >= focusedWindow.getScreen().getHeight() ) { y = focusedWindow.getScreen().getHeight() - 1; } - int wx = x - focusedWindow.getX(), wy = y - focusedWindow.getY(); - + int wx = x - focusedWindow.getX(), wy = y - focusedWindow.getY(); + if(old_x != x || old_y != y) { // mouse moved - focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_MOVED, 0, wx, wy, (short)0, 0 ); + focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_MOVED, 0, wx, wy, (short)0, 0 ); } - + if(old_buttonDown != buttonDown) { // press/release if( 0 != buttonDown ) { - focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_PRESSED, 0, wx, wy, buttonDown, 0 ); + focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_PRESSED, 0, wx, wy, buttonDown, 0 ); } else { - focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_RELEASED, 0, wx, wy, old_buttonDown, 0 ); + focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_RELEASED, 0, wx, wy, old_buttonDown, 0 ); } - } + } } else { if(Window.DEBUG_MOUSE_EVENT) { System.out.println(x+"/"+y+", hs="+hs+",vs="+vs+",lb="+lb+",rb="+rb+",mb="+mb+",xo="+xo+",yo="+yo+"xd="+xd+",yd="+yd); } } - + old_x = x; old_y = y; old_buttonDown = buttonDown; - + } if(null != fis) { try { @@ -214,5 +214,5 @@ public class LinuxMouseTracker implements WindowListener { } } } - } + } } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index a99bc4f23..2dbdfdce7 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2012 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.macosx; @@ -60,19 +60,19 @@ public class DisplayDriver extends DisplayImpl { public static void initSingleton() { // just exist to ensure static init has been run } - + public DisplayDriver() { } protected void dispatchMessagesNative() { // nop } - + protected void createNativeImpl() { aDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java index baa94facd..a89150d7c 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -30,7 +30,7 @@ package jogamp.newt.driver.macosx; import com.jogamp.newt.event.KeyEvent; public class MacKeyUtil { - + // // KeyCodes (Layout Dependent) // @@ -64,17 +64,17 @@ public class MacKeyUtil { private static final short kVK_ANSI_8 = 0x1C; private static final short kVK_ANSI_0 = 0x1D; private static final short kVK_ANSI_RightBracket = 0x1E; - private static final short kVK_ANSI_O = 0x1F; + private static final short kVK_ANSI_O = 0x1F; private static final short kVK_ANSI_U = 0x20; private static final short kVK_ANSI_LeftBracket = 0x21; private static final short kVK_ANSI_I = 0x22; private static final short kVK_ANSI_P = 0x23; private static final short kVK_ANSI_L = 0x25; private static final short kVK_ANSI_J = 0x26; - private static final short kVK_ANSI_Quote = 0x27; + private static final short kVK_ANSI_Quote = 0x27; private static final short kVK_ANSI_K = 0x28; private static final short kVK_ANSI_Semicolon = 0x29; - private static final short kVK_ANSI_Backslash = 0x2A; + private static final short kVK_ANSI_Backslash = 0x2A; private static final short kVK_ANSI_Comma = 0x2B; private static final short kVK_ANSI_Slash = 0x2C; private static final short kVK_ANSI_N = 0x2D; @@ -99,7 +99,7 @@ public class MacKeyUtil { private static final short kVK_ANSI_Keypad7 = 0x59; private static final short kVK_ANSI_Keypad8 = 0x5B; private static final short kVK_ANSI_Keypad9 = 0x5C; - + // // KeyCodes (Layout Independent) // @@ -150,7 +150,7 @@ public class MacKeyUtil { private static final short kVK_RightArrow = 0x7C; private static final short kVK_DownArrow = 0x7D; private static final short kVK_UpArrow = 0x7E; - + // // Key constants handled differently on Mac OS X than other platforms // @@ -230,8 +230,8 @@ public class MacKeyUtil { private static final char NSHelpFunctionKey = 0xF746; private static final char NSModeSwitchFunctionKey = 0xF747; */ - - static short validateKeyCode(short keyCode, char keyChar) { + + static short validateKeyCode(short keyCode, char keyChar) { // OS X Virtual Keycodes switch(keyCode) { // @@ -267,17 +267,17 @@ public class MacKeyUtil { case kVK_ANSI_8: return KeyEvent.VK_8; case kVK_ANSI_0: return KeyEvent.VK_0; case kVK_ANSI_RightBracket: return KeyEvent.VK_CLOSE_BRACKET; - case kVK_ANSI_O: return KeyEvent.VK_O; + case kVK_ANSI_O: return KeyEvent.VK_O; case kVK_ANSI_U: return KeyEvent.VK_U; case kVK_ANSI_LeftBracket: return KeyEvent.VK_OPEN_BRACKET; case kVK_ANSI_I: return KeyEvent.VK_I; case kVK_ANSI_P: return KeyEvent.VK_P; case kVK_ANSI_L: return KeyEvent.VK_L; case kVK_ANSI_J: return KeyEvent.VK_J; - case kVK_ANSI_Quote: return KeyEvent.VK_QUOTE; + case kVK_ANSI_Quote: return KeyEvent.VK_QUOTE; case kVK_ANSI_K: return KeyEvent.VK_K; case kVK_ANSI_Semicolon: return KeyEvent.VK_SEMICOLON; - case kVK_ANSI_Backslash: return KeyEvent.VK_BACK_SLASH; + case kVK_ANSI_Backslash: return KeyEvent.VK_BACK_SLASH; case kVK_ANSI_Comma: return KeyEvent.VK_COMMA; case kVK_ANSI_Slash: return KeyEvent.VK_SLASH; case kVK_ANSI_N: return KeyEvent.VK_N; @@ -302,7 +302,7 @@ public class MacKeyUtil { case kVK_ANSI_Keypad7: return KeyEvent.VK_7; case kVK_ANSI_Keypad8: return KeyEvent.VK_8; case kVK_ANSI_Keypad9: return KeyEvent.VK_9; - + // // KeyCodes (Layout Independent) // @@ -321,7 +321,7 @@ public class MacKeyUtil { case kVK_RightControl: return KeyEvent.VK_CONTROL; // case kVK_Function: return KeyEvent.VK_F; case kVK_F17: return KeyEvent.VK_F17; - // case kVK_VolumeUp: + // case kVK_VolumeUp: // case kVK_VolumeDown: // case kVK_Mute: case kVK_F18: return KeyEvent.VK_F18; @@ -354,7 +354,7 @@ public class MacKeyUtil { case kVK_DownArrow: return KeyEvent.VK_DOWN; case kVK_UpArrow: return KeyEvent.VK_UP; } - + switch (keyChar) { case NSUpArrowFunctionKey: return KeyEvent.VK_UP; case NSDownArrowFunctionKey: return KeyEvent.VK_DOWN; @@ -422,5 +422,5 @@ public class MacKeyUtil { } return (short) keyChar; // let's hope for the best (compatibility of keyChar/keyCode's) - } + } } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java index a3bb26731..5d3b7287b 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2011 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.macosx; @@ -44,7 +44,7 @@ import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; public class ScreenDriver extends ScreenImpl { - + static { DisplayDriver.initSingleton(); } @@ -68,7 +68,7 @@ public class ScreenDriver extends ScreenImpl { } return res; } - + @Override protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { int crtIdx = 0; @@ -85,16 +85,16 @@ public class ScreenDriver extends ScreenImpl { final MonitorMode currentMode = getMonitorModeImpl(cache, crtIdx, -1); if ( null == currentMode ) { throw new InternalError("Could not gather current mode of device "+crtIdx+", but gathered "+modeIdx+" modes"); - } + } final int[] monitorProps = getMonitorProps0(crtIdx); if ( null == monitorProps ) { throw new InternalError("Could not gather device "+crtIdx+", but gathered "+modeIdx+" modes"); - } + } // merge monitor-props + supported modes MonitorModeProps.streamInMonitorDevice(null, cache, this, supportedModes, currentMode, monitorProps, 0); - + // next monitor, 1st mode - supportedModes= new ArrayHashSet(); + supportedModes= new ArrayHashSet(); crtIdx++; modeIdx=0; } else { @@ -108,16 +108,16 @@ public class ScreenDriver extends ScreenImpl { protected MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor) { return getMonitorModeImpl(null, monitor.getId(), -1); } - + @Override protected boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode) { return setMonitorMode0(monitor.getId(), mode.getId(), mode.getRotation()); } - + protected int validateScreenIndex(int idx) { - return 0; // big-desktop w/ multiple monitor attached, only one screen available + return 0; // big-desktop w/ multiple monitor attached, only one screen available } - + private native int[] getMonitorProps0(int crt_idx); private native int[] getMonitorMode0(int crt_index, int mode_idx); private native boolean setMonitorMode0(int crt_index, int nativeId, int rot); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 08638d868..f36d32772 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.macosx; @@ -53,14 +53,14 @@ import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; public class WindowDriver extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { - + static { DisplayDriver.initSingleton(); } public WindowDriver() { } - + @Override protected void createNativeImpl() { final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( @@ -69,7 +69,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } setGraphicsConfiguration(cfg); - reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true)); + reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true)); if (0 == getWindowHandle()) { throw new NativeWindowException("Error creating window"); } @@ -79,7 +79,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl protected void closeNativeImpl() { try { if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.CloseAction "+Thread.currentThread().getName()); } - final long handle = getWindowHandle(); + final long handle = getWindowHandle(); visibleChanged(true, false); setWindowHandle(0); surfaceHandle = 0; @@ -92,16 +92,16 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } ); } } catch (Throwable t) { - if(DEBUG_IMPLEMENTATION) { + if(DEBUG_IMPLEMENTATION) { Exception e = new Exception("Warning: closeNative failed - "+Thread.currentThread().getName(), t); e.printStackTrace(); } } } - + @Override protected int lockSurfaceImpl() { - /** + /** * if( isOffscreenInstance ) { * return LOCK_SUCCESS; * } @@ -116,7 +116,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected void unlockSurfaceImpl() { - /** + /** * if( isOffscreenInstance ) { * return; * } @@ -129,7 +129,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } } - + @Override public final long getSurfaceHandle() { return 0 != sscSurfaceHandle ? sscSurfaceHandle : surfaceHandle; @@ -147,14 +147,14 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl public void run() { orderOut0( 0 != getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); } } ); - } /** this is done by recreation! + } /** this is done by recreation! else if (isVisible()){ OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { orderFront0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); } } ); } */ - } + } } @Override @@ -179,7 +179,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl focusChanged(false, true); } } - + @Override public final void clearFocus() { if(DEBUG_IMPLEMENTATION) { @@ -194,9 +194,9 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl focusChanged(false, false); } } - + private boolean useParent(NativeWindow parent) { return null != parent && 0 != parent.getWindowHandle(); } - + @Override public void updatePosition(int x, int y) { final long handle = getWindowHandle(); @@ -215,8 +215,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // no native event (fullscreen, some reparenting) positionChanged(true, x, y); } - } - + } + @Override protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { final long handle = getWindowHandle(); @@ -237,7 +237,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } super.sizeChanged(defer, newWidth, newHeight, force); } - + @Override protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, int flags) { final boolean _isOffscreenInstance = isOffscreenInstance(this, this.getParent()); @@ -250,11 +250,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final boolean useParent = useParent(parent); if( useParent ) { pClientLevelOnSreen = getLocationOnScreenImpl(x, y, parent, useParent); - } else { + } else { pClientLevelOnSreen = new Point(x, y); } } - + if(DEBUG_IMPLEMENTATION) { final AbstractGraphicsConfiguration cWinCfg = this.getGraphicsConfiguration(); final NativeWindow pWin = getParent(); @@ -269,9 +269,9 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl "\n\t, "+getReconfigureFlagsAsString(null, flags)); // Thread.dumpStack(); } - + final boolean setVisible = 0 != ( FLAG_IS_VISIBLE & flags); - + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && !setVisible ) { if ( !isOffscreenInstance ) { OSXUtil.RunOnMainThread(false, new Runnable() { @@ -290,11 +290,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if(isOffscreenInstance) { createWindow(true, 0 != getWindowHandle(), pClientLevelOnSreen, 64, 64, false, setVisible, false); } else { - createWindow(false, 0 != getWindowHandle(), pClientLevelOnSreen, width, height, + createWindow(false, 0 != getWindowHandle(), pClientLevelOnSreen, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags), setVisible, 0 != ( FLAG_IS_ALWAYSONTOP & flags)); } } else { - if( width>0 && height>0 ) { + if( width>0 && height>0 ) { if( !isOffscreenInstance ) { OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { @@ -306,7 +306,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl sizeChanged(true, width, height, false); } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && setVisible ) { - if( !isOffscreenInstance ) { + if( !isOffscreenInstance ) { OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { orderFront0(getWindowHandle()); @@ -321,7 +321,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow reconfig.X: clientPos "+pClientLevelOnSreen+", "+width+"x"+height+" -> clientPos "+getLocationOnScreenImpl(0, 0)+", insets: "+getInsets()); + System.err.println("MacWindow reconfig.X: clientPos "+pClientLevelOnSreen+", "+width+"x"+height+" -> clientPos "+getLocationOnScreenImpl(0, 0)+", insets: "+getInsets()); } return true; } @@ -332,28 +332,28 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final boolean useParent = useParent(parent); return getLocationOnScreenImpl(x, y, parent, useParent); } - + private Point getLocationOnScreenImpl(final int x, final int y, final NativeWindow parent, final boolean useParent) { if( !useParent && !isOffscreenInstance && 0 != surfaceHandle) { return OSXUtil.GetLocationOnScreen(surfaceHandle, true, x, y); } - + final Point p = new Point(x, y); if( useParent ) { p.translate( parent.getLocationOnScreen(null) ); } return p; } - + @Override protected void updateInsetsImpl(Insets insets) { // nop - using event driven insetsChange(..) } - + /** Callback for native screen position change event of the client area. */ - protected void screenPositionChanged(boolean defer, int newX, int newY) { + protected void screenPositionChanged(boolean defer, int newX, int newY) { // passed coordinates are in screen position of the client area - if(getWindowHandle()!=0) { + if(getWindowHandle()!=0) { final NativeWindow parent = getParent(); if( null == parent || isOffscreenInstance ) { if(DEBUG_IMPLEMENTATION) { @@ -362,7 +362,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl positionChanged(defer, newX, newY); } else { // screen position -> rel child window position - Point absPos = new Point(newX, newY); + Point absPos = new Point(newX, newY); Point parentOnScreen = parent.getLocationOnScreen(null); absPos.translate( parentOnScreen.scale(-1, -1) ); if(DEBUG_IMPLEMENTATION) { @@ -374,10 +374,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl System.err.println("MacWindow.positionChanged.2 (Screen Pos - IGN): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY); } } - + @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { - if( !isOffscreenInstance ) { + if( !isOffscreenInstance ) { return setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible); } // else may need offscreen solution ? FIXME return false; @@ -385,29 +385,29 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected boolean confinePointerImpl(final boolean confine) { - if( !isOffscreenInstance ) { + if( !isOffscreenInstance ) { return confinePointer0(getWindowHandle(), confine); } // else may need offscreen solution ? FIXME return false; } - + @Override protected void warpPointerImpl(final int x, final int y) { - if( !isOffscreenInstance ) { + if( !isOffscreenInstance ) { warpPointer0(getWindowHandle(), x, y); } // else may need offscreen solution ? FIXME } - + @Override public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); } - + @Override public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short _keyCode, short _keySym, char keyChar) { - throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); + throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); } - + protected final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short _keyCode, char keyChar, char keySymChar) { // Note that we send the key char for the key code on this // platform -- we do not get any useful key codes out of the system @@ -427,7 +427,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl ", was: pressed "+isKeyPressed(keyCode)+", isModifierKeyCode "+isModifierKeyCode+ ", nativeValid "+isNativeValid()+", isOffscreen "+isOffscreenInstance); } */ - + // OSX delivery order is PRESSED (t0), RELEASED (t1) and TYPED (t2) -> NEWT order: PRESSED (t0) and RELEASED (t1) // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE key _before_ PRESSED switch(eventType) { @@ -451,15 +451,15 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl //---------------------------------------------------------------------- // Internals only - // - - private void createWindow(final boolean offscreenInstance, final boolean recreate, - final PointImmutable pS, final int width, final int height, + // + + private void createWindow(final boolean offscreenInstance, final boolean recreate, + final PointImmutable pS, final int width, final int height, final boolean fullscreen, final boolean visible, final boolean alwaysOnTop) { final long parentWinHandle = getParentWindowHandle(); final long preWinHandle = getWindowHandle(); - + if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.createWindow on thread "+Thread.currentThread().getName()+ ": offscreen "+offscreenInstance+", recreate "+recreate+ @@ -474,7 +474,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl setWindowHandle(0); if( 0 == surfaceHandle ) { throw new NativeWindowException("Internal Error - create w/ window, but no Newt NSView"); - } + } OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { changeContentView0(parentWinHandle, preWinHandle, 0); @@ -483,14 +483,14 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } else { if( 0 != surfaceHandle ) { throw new NativeWindowException("Internal Error - create w/o window, but has Newt NSView"); - } + } surfaceHandle = createView0(pS.getX(), pS.getY(), width, height, fullscreen); if( 0 == surfaceHandle ) { throw new NativeWindowException("Could not create native view "+Thread.currentThread().getName()+" "+this); } } - - final long newWin = createWindow0( pS.getX(), pS.getY(), width, height, fullscreen, + + final long newWin = createWindow0( pS.getX(), pS.getY(), width, height, fullscreen, ( isUndecorated() || offscreenInstance ) ? NSBorderlessWindowMask : NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask, NSBackingStoreBuffered, surfaceHandle); @@ -498,9 +498,9 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl throw new NativeWindowException("Could not create native window "+Thread.currentThread().getName()+" "+this); } setWindowHandle( newWin ); - + final boolean isOpaque = getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance; - // Blocking initialization on main-thread! + // Blocking initialization on main-thread! OSXUtil.RunOnMainThread(true, new Runnable() { public void run() { initWindow0( parentWinHandle, newWin, pS.getX(), pS.getY(), width, height, @@ -517,7 +517,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl ie.printStackTrace(); } } - + protected static native boolean initIDs0(); private native long createView0(int x, int y, int w, int h, boolean fullscreen); private native long createWindow0(int x, int y, int w, int h, boolean fullscreen, int windowStyle, int backingStoreType, long view); @@ -543,7 +543,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private native void changeContentView0(long parentWindowOrView, long window, long view); /** Must be called on Main-Thread */ private native void setWindowClientTopLeftPointAndSize0(long window, int x, int y, int w, int h, boolean display); - /** Must be called on Main-Thread */ + /** Must be called on Main-Thread */ private native void setWindowClientTopLeftPoint0(long window, int x, int y, boolean display); /** Must be called on Main-Thread */ private native void setAlwaysOnTop0(long window, boolean atop); @@ -551,7 +551,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); private static native boolean confinePointer0(long windowHandle, boolean confine); private static native void warpPointer0(long windowHandle, int x, int y); - + // Window styles private static final int NSBorderlessWindowMask = 0; private static final int NSTitledWindowMask = 1 << 0; @@ -567,5 +567,5 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private volatile long surfaceHandle = 0; private long sscSurfaceHandle = 0; private boolean isOffscreenInstance = false; - + } diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index 595d5e952..d3c7416cc 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.windows; @@ -52,10 +52,10 @@ public class DisplayDriver extends DisplayImpl { NEWTJNILibLoader.loadNEWT(); sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowDriver.getNewtWndProc0()); - + if (!WindowDriver.initIDs0(RegisteredClassFactory.getHInstance())) { throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs"); - } + } } public static void initSingleton() { @@ -76,7 +76,7 @@ public class DisplayDriver extends DisplayImpl { aDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { sharedClassFactory.releaseSharedClass(); aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java index 621091320..e789b995f 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.windows; @@ -60,7 +60,7 @@ public class ScreenDriver extends ScreenImpl { protected void createNativeImpl() { aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); } - + @Override protected void closeNativeImpl() { } @@ -71,7 +71,7 @@ public class ScreenDriver extends ScreenImpl { private final String getActiveMonitorName(String adapterName, int monitor_idx) { return getActiveMonitorName0(adapterName, monitor_idx); } - + private final MonitorMode getMonitorModeImpl(MonitorModeProps.Cache cache, String adapterName, int crtModeIdx) { if( null == adapterName ) { return null; @@ -107,7 +107,7 @@ public class ScreenDriver extends ScreenImpl { final int[] monitorProps = getMonitorDevice0(adapterName, crtIdx); // merge monitor-props + supported modes MonitorModeProps.streamInMonitorDevice(null, cache, this, supportedModes, currentMode, monitorProps, 0); - + // next monitor, 1st mode supportedModes= new ArrayHashSet(); } @@ -116,7 +116,7 @@ public class ScreenDriver extends ScreenImpl { adapterName = getAdapterName(crtIdx); } } - + @Override protected Rectangle getNativeMonitorDeviceViewportImpl(MonitorDevice monitor) { final String adapterName = getAdapterName(monitor.getId()); @@ -135,7 +135,7 @@ public class ScreenDriver extends ScreenImpl { protected MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor) { return getMonitorModeImpl(null, getAdapterName(monitor.getId()), -1); } - + @Override protected boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode) { return setMonitorMode0(monitor.getId(), @@ -150,14 +150,14 @@ public class ScreenDriver extends ScreenImpl { @Override protected int validateScreenIndex(int idx) { - return 0; // big-desktop w/ multiple monitor attached, only one screen available + return 0; // big-desktop w/ multiple monitor attached, only one screen available } - + @Override protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { vOriginSize.set(getVirtualOriginX0(), getVirtualOriginY0(), getVirtualWidthImpl0(), getVirtualHeightImpl0()); } - + // Native calls private native int getVirtualOriginX0(); private native int getVirtualOriginY0(); diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index b2e175415..30405aa05 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.windows; @@ -74,26 +74,26 @@ public class WindowDriver extends WindowImpl { } final long hWnd = getWindowHandle(); hdc = GDI.GetDC(hWnd); - + // return ( 0 == hdc ) ? LOCK_SURFACE_NOT_READY : ( hdc_old != hdc ) ? LOCK_SURFACE_CHANGED : LOCK_SUCCESS ; - if( 0 == hdc ) { + if( 0 == hdc ) { return LOCK_SURFACE_NOT_READY; - } + } hmon = MonitorFromWindow0(hWnd); - + // Let's not trigger on HDC change, GLDrawableImpl.'s destroy/create is a nop here anyways. // FIXME: Validate against EGL surface creation: ANGLE uses HWND -> fine! - return LOCK_SUCCESS; - + return LOCK_SUCCESS; + /** if( hdc_old == hdc ) { return LOCK_SUCCESS; } - if(DEBUG_IMPLEMENTATION) { + if(DEBUG_IMPLEMENTATION) { System.err.println("WindowsWindow: surface change "+toHexString(hdc_old)+" -> "+toHexString(hdc)); // Thread.dumpStack(); } - return LOCK_SURFACE_CHANGED; */ + return LOCK_SURFACE_CHANGED; */ } @Override @@ -137,24 +137,24 @@ public class WindowDriver extends WindowImpl { } setGraphicsConfiguration(cfg); final VersionNumber winVer = Platform.getOSVersionNumber(); - final int flags = getReconfigureFlags(0, true) & + final int flags = getReconfigureFlags(0, true) & ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; final long _windowHandle = CreateWindow0(DisplayDriver.getHInstance(), display.getWindowClassName(), display.getWindowClassName(), winVer.getMajor(), winVer.getMinor(), - getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags); + getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags); if ( 0 == _windowHandle ) { throw new NativeWindowException("Error creating window"); } setWindowHandle(_windowHandle); windowHandleClose = _windowHandle; - + if(DEBUG_IMPLEMENTATION) { Exception e = new Exception("Info: Window new window handle "+Thread.currentThread().getName()+ " (Parent HWND "+toHexString(getParentWindowHandle())+ ") : HWND "+toHexString(_windowHandle)+", "+Thread.currentThread()); e.printStackTrace(); } - } + } protected void closeNativeImpl() { if(windowHandleClose != 0) { @@ -162,7 +162,7 @@ public class WindowDriver extends WindowImpl { try { GDI.ReleaseDC(windowHandleClose, hdc); } catch (Throwable t) { - if(DEBUG_IMPLEMENTATION) { + if(DEBUG_IMPLEMENTATION) { Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); e.printStackTrace(); } @@ -188,14 +188,14 @@ public class WindowDriver extends WindowImpl { System.err.println("WindowsWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); } - + if(0 == ( FLAG_IS_UNDECORATED & flags)) { final InsetsImmutable i = getInsets(); - + // client position -> top-level window position x -= i.getLeftWidth() ; y -= i.getTopHeight() ; - + if(0 top-level window size width += i.getTotalWidth(); @@ -203,9 +203,9 @@ public class WindowDriver extends WindowImpl { } } reconfigureWindow0( getParentWindowHandle(), getWindowHandle(), x, y, width, height, flags); - + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } return true; } @@ -222,7 +222,7 @@ public class WindowDriver extends WindowImpl { @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { final boolean[] res = new boolean[] { false }; - + this.runOnEDTIfAvail(true, new Runnable() { public void run() { res[0] = setPointerVisible0(getWindowHandle(), pointerVisible); @@ -234,19 +234,19 @@ public class WindowDriver extends WindowImpl { @Override protected boolean confinePointerImpl(final boolean confine) { final Boolean[] res = new Boolean[] { Boolean.FALSE }; - + this.runOnEDTIfAvail(true, new Runnable() { public void run() { final Point p0 = getLocationOnScreenImpl(0, 0); - res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine, + res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine, p0.getX(), p0.getY(), p0.getX()+getWidth(), p0.getY()+getHeight())); } }); return res[0].booleanValue(); } - + @Override - protected void warpPointerImpl(final int x, final int y) { + protected void warpPointerImpl(final int x, final int y) { this.runOnEDTIfAvail(true, new Runnable() { public void run() { final Point sPos = getLocationOnScreenImpl(x, y); @@ -255,44 +255,44 @@ public class WindowDriver extends WindowImpl { }); return; } - + protected Point getLocationOnScreenImpl(int x, int y) { return GDIUtil.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y); } protected void updateInsetsImpl(Insets insets) { - // nop - using event driven insetsChange(..) + // nop - using event driven insetsChange(..) } - + // // PointerEvent Handling // /** * Send multiple-pointer {@link MouseEvent.PointerType#TouchScreen} event to be directly consumed *

                      - * Assumes non normal pointer names and rotation/scroll will be determined by a gesture handler. + * Assumes non normal pointer names and rotation/scroll will be determined by a gesture handler. *

                      *

                      * See {@link #doPointerEvent(boolean, boolean, PointerType[], short, int, int, boolean, int[], int[], int[], float[], float, float[], float)} * for details. *

                      */ - public final void sendTouchScreenEvent(short eventType, int modifiers, + public final void sendTouchScreenEvent(short eventType, int modifiers, int pActionIdx, int[] pNames, int[] pX, int[] pY, float[] pPressure, float maxPressure) { final int pCount = pNames.length; final MouseEvent.PointerType[] pTypes = new MouseEvent.PointerType[pCount]; for(int i=pCount-1; i>=0; i--) { pTypes[i] = PointerType.TouchScreen; } - doPointerEvent(false /*enqueue*/, false /*wait*/, - pTypes, eventType, modifiers, pActionIdx, false /*normalPNames*/, pNames, + doPointerEvent(false /*enqueue*/, false /*wait*/, + pTypes, eventType, modifiers, pActionIdx, false /*normalPNames*/, pNames, pX, pY, pPressure, maxPressure, new float[] { 0f, 0f, 0f} /*rotationXYZ*/, 1f/*rotationScale*/); } - + // // KeyEvent Handling // private short repeatedKey = KeyEvent.VK_UNDEFINED; - + private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, int modifiers, short keyCode, short keySym, char keyChar) { if( setKeyPressed(keyCode, true) ) { // AR: Key was already pressed: Either [enter | within] AR mode @@ -308,18 +308,18 @@ public class WindowDriver extends WindowImpl { super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); } return true; - } + } return false; } - + @Override public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { final boolean isModifierKey = KeyEvent.isModifierKey(keySym); // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+ // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", printableKey "+KeyEvent.isPrintableKey(keyCode, false)+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); - + // Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0) and RELEASED (t1) - // Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0). + // Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0). switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: if( isKeyCodeTracked(keyCode) ) { @@ -339,12 +339,12 @@ public class WindowDriver extends WindowImpl { break; } } - + @Override public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); } - + //---------------------------------------------------------------------- // Internals only // @@ -361,5 +361,5 @@ public class WindowDriver extends WindowImpl { private static native boolean setPointerVisible0(long windowHandle, boolean visible); private static native boolean confinePointer0(long windowHandle, boolean grab, int l, int t, int r, int b); - private static native void warpPointer0(long windowHandle, int x, int y); + private static native void warpPointer0(long windowHandle, int x, int y); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index d911483b0..aa8067520 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.x11; @@ -83,7 +83,7 @@ public class DisplayDriver extends DisplayImpl { CompleteDisplay0(aDevice.getHandle()); } catch(RuntimeException e) { closeNativeImpl(aDevice); - throw e; + throw e; } } @@ -114,14 +114,14 @@ public class DisplayDriver extends DisplayImpl { protected long getJavaObjectAtom() { return javaObjectAtom; } protected long getWindowDeleteAtom() { return windowDeleteAtom; } // protected long getKbdHandle() { return kbdHandle; } // XKB disabled for now - - /** Returns null if !{@link #isNativeValid()}, otherwise the Boolean value of {@link X11GraphicsDevice#isXineramaEnabled()}. */ + + /** Returns null if !{@link #isNativeValid()}, otherwise the Boolean value of {@link X11GraphicsDevice#isXineramaEnabled()}. */ protected Boolean isXineramaEnabled() { return isNativeValid() ? Boolean.valueOf(((X11GraphicsDevice)aDevice).isXineramaEnabled()) : null; } - + //---------------------------------------------------------------------- // Internals only // - + private static native boolean initIDs0(boolean debug); private native void CompleteDisplay0(long handle); @@ -137,10 +137,10 @@ public class DisplayDriver extends DisplayImpl { /** X11 Window delete atom marker used on EDT */ private long windowDeleteAtom; - + /** X11 Window java object property used on EDT */ - private long javaObjectAtom; - + private long javaObjectAtom; + /** X11 Keyboard handle used on EDT */ // private long kbdHandle; // XKB disabled for now } diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR.java b/src/newt/classes/jogamp/newt/driver/x11/RandR.java index e39a6c63a..8b065d1f0 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR.java @@ -38,18 +38,18 @@ import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; public interface RandR { - public static final VersionNumber version110 = new VersionNumber(1, 1, 0); + public static final VersionNumber version110 = new VersionNumber(1, 1, 0); public static final VersionNumber version130 = new VersionNumber(1, 3, 0); public static final VersionNumber version140 = new VersionNumber(1, 4, 0); VersionNumber getVersion(); - + void dumpInfo(final long dpy, final int screen_idx); - + /** - * Encapsulate initial device query allowing caching of internal data structures. + * Encapsulate initial device query allowing caching of internal data structures. * Methods covered: - *
                        + *
                          *
                        • {@link #getMonitorDeviceCount(long, ScreenDriver)}
                        • *
                        • {@link #getAvailableRotations(long, ScreenDriver, int)}
                        • *
                        • {@link #getMonitorModeProps(long, ScreenDriver, int)}
                        • @@ -57,7 +57,7 @@ public interface RandR { *
                        • {@link #getMonitorDeviceProps(long, ScreenDriver, List, int, MonitorMode)}
                        • *
                        *

                        - * Above methods may be called w/o begin/end, in which case no + * Above methods may be called w/o begin/end, in which case no * internal data structures can be cached: *

                        * @param dpy TODO @@ -66,11 +66,11 @@ public interface RandR { */ boolean beginInitialQuery(long dpy, ScreenDriver screen); void endInitialQuery(long dpy, ScreenDriver screen); - + int getMonitorDeviceCount(final long dpy, final ScreenDriver screen); int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_idx); /** - * + * * @param dpy * @param screen * @param mode_idx w/o indexing rotation @@ -80,7 +80,7 @@ public interface RandR { int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, MonitorModeProps.Cache cache, final int crt_idx); int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_idx); int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx); - boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode); - - public void updateScreenViewport(final long dpy, final ScreenDriver screen, RectangleImmutable viewport); + boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode); + + public void updateScreenViewport(final long dpy, final ScreenDriver screen, RectangleImmutable viewport); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java index 877607f72..6c22a3fc6 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java @@ -38,8 +38,8 @@ import com.jogamp.newt.MonitorMode; class RandR11 implements RandR { private static final boolean DEBUG = ScreenDriver.DEBUG; - - RandR11() { + + RandR11() { } @Override @@ -51,13 +51,13 @@ class RandR11 implements RandR { public void dumpInfo(final long dpy, final int screen_idx) { // NOP } - + private int widthMM=0, heightMM=0; private int modeCount = 0; private int resolutionCount = 0; private int[][] nrates = null; // [nres_number][nrate_number] private int[] idx_rate = null, idx_res = null; - + @Override public boolean beginInitialQuery(long dpy, ScreenDriver screen) { // initialize iterators and static data @@ -76,11 +76,11 @@ class RandR11 implements RandR { return false; } } - + for(int nresIdx=0; nresIdx < resolutionCount; nresIdx++) { modeCount += nrates[nresIdx].length; } - + idx_rate = new int[modeCount]; idx_res = new int[modeCount]; @@ -94,23 +94,23 @@ class RandR11 implements RandR { } return true; } - + @Override public void endInitialQuery(long dpy, ScreenDriver screen) { idx_rate=null; - idx_res=null; - nrates=null; + idx_res=null; + nrates=null; } - + @Override public int getMonitorDeviceCount(final long dpy, final ScreenDriver screen) { return 1; } - + @Override public int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_idx) { if( 0 < crt_idx ) { - // RandR11 only supports 1 CRT + // RandR11 only supports 1 CRT return null; } final int screen_idx = screen.getIndex(); @@ -120,17 +120,17 @@ class RandR11 implements RandR { } return availRotations; } - + @Override public int[] getMonitorModeProps(final long dpy, final ScreenDriver screen, final int mode_idx) { if( mode_idx >= modeCount ) { return null; - } + } final int screen_idx = screen.getIndex(); - + final int nres_index = idx_res[mode_idx]; final int nrate_index = idx_rate[mode_idx]; - + final int[] res = getScreenResolution0(dpy, screen_idx, nres_index); if(null==res || 0==res.length) { return null; @@ -144,7 +144,7 @@ class RandR11 implements RandR { if( res[3] > heightMM ) { heightMM = res[3]; } - + int rate = nrates[nres_index][nrate_index]; if(0>=rate) { rate = ScreenImpl.default_sm_rate; @@ -166,13 +166,13 @@ class RandR11 implements RandR { if( MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL != i ) { throw new InternalError("XX"); } - return props; + return props; } - + @Override public int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, final MonitorModeProps.Cache cache, final int crt_idx) { if( 0 < crt_idx ) { - // RandR11 only supports 1 CRT + // RandR11 only supports 1 CRT return null; } final int[] currentModeProps = getCurrentMonitorModeProps(dpy, screen, crt_idx); @@ -194,15 +194,15 @@ class RandR11 implements RandR { props[i++] = currentMode.getId(); // current mode id props[i++] = currentMode.getRotation(); for(int j=0; jresId || resId>=resolutionCount) { throw new RuntimeException("Invalid resolution index: ! 0 < "+resId+" < "+resolutionCount+", "+monitor+", "+mode); - } + } final int f = (int)mode.getRefreshRate(); // simply cut-off, orig is int final int r = mode.getRotation(); @@ -335,11 +335,11 @@ class RandR11 implements RandR { } return done; } - + @Override public final void updateScreenViewport(final long dpy, final ScreenDriver screen, RectangleImmutable viewport) { // nop - } + } /** @return int[] { rot1, .. } */ private static native int[] getAvailableScreenRotations0(long display, int screen_index); @@ -353,7 +353,7 @@ class RandR11 implements RandR { private static native long getScreenConfiguration0(long display, int screen_index); private static native void freeScreenConfiguration0(long screenConfiguration); - + private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); private static native int getCurrentScreenRate0(long screenConfiguration); private static native int getCurrentScreenRotation0(long screenConfiguration); @@ -361,5 +361,5 @@ class RandR11 implements RandR { /** needs own Display connection for XRANDR event handling */ private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); - + } diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java index ac83fc5f2..a08741d9e 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java @@ -43,19 +43,19 @@ import com.jogamp.newt.MonitorMode; *
                          * MonitorMode.id   == XRR mode-id (not index)
                          * MonitorDevice.id == XRR monitor-idx (not id)
                        - * 
                        + *
                      */ class RandR13 implements RandR { private static final boolean DEBUG = ScreenDriver.DEBUG; - - RandR13() { + + RandR13() { } - + @Override public final VersionNumber getVersion() { return version130; } - + @Override public void dumpInfo(final long dpy, final int screen_idx) { long screenResources = getScreenResources0(dpy, screen_idx); @@ -66,12 +66,12 @@ class RandR13 implements RandR { dumpInfo0(dpy, screen_idx, screenResources); } finally { freeScreenResources0(screenResources); - } + } } - + long sessionScreenResources = 0; IntLongHashMap crtInfoHandleMap = null; - + @Override public boolean beginInitialQuery(long dpy, ScreenDriver screen) { final int screen_idx = screen.getIndex(); @@ -84,7 +84,7 @@ class RandR13 implements RandR { return false; } } - + @Override public void endInitialQuery(long dpy, ScreenDriver screen) { if( null != crtInfoHandleMap ) { @@ -100,7 +100,7 @@ class RandR13 implements RandR { sessionScreenResources = 0; } } - + private final long getScreenResourceHandle(final long dpy, final int screen_idx) { if( 0 != sessionScreenResources ) { return sessionScreenResources; @@ -112,7 +112,7 @@ class RandR13 implements RandR { freeScreenResources0( screenResourceHandle ); } } - + private final long getMonitorInfoHandle(final long dpy, final int screen_idx, long screenResources, final int monitor_idx) { if( null != crtInfoHandleMap ) { long h = crtInfoHandleMap.get(monitor_idx); @@ -129,8 +129,8 @@ class RandR13 implements RandR { if( null == crtInfoHandleMap ) { freeMonitorInfoHandle0(monitorInfoHandle); } - } - + } + @Override public int getMonitorDeviceCount(final long dpy, final ScreenDriver screen) { final int screen_idx = screen.getIndex(); @@ -141,7 +141,7 @@ class RandR13 implements RandR { releaseScreenResourceHandle(screenResources); } } - + @Override public int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_idx) { final int screen_idx = screen.getIndex(); @@ -152,7 +152,7 @@ class RandR13 implements RandR { final int[] availRotations = getAvailableRotations0(monitorInfo); if(null==availRotations || 0==availRotations.length) { return null; - } + } return availRotations; } finally { releaseMonitorInfoHandle(monitorInfo); @@ -161,7 +161,7 @@ class RandR13 implements RandR { releaseScreenResourceHandle(screenResources); } } - + @Override public int[] getMonitorModeProps(final long dpy, final ScreenDriver screen, final int mode_idx) { final int screen_idx = screen.getIndex(); @@ -172,7 +172,7 @@ class RandR13 implements RandR { releaseScreenResourceHandle(screenResources); } } - + @Override public int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, MonitorModeProps.Cache cache, final int crt_idx) { final int screen_idx = screen.getIndex(); @@ -188,9 +188,9 @@ class RandR13 implements RandR { releaseScreenResourceHandle(screenResources); } } - + @Override - public int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_idx) { + public int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_idx) { final int screen_idx = screen.getIndex(); final long screenResources = getScreenResourceHandle(dpy, screen_idx); try { @@ -204,7 +204,7 @@ class RandR13 implements RandR { releaseScreenResourceHandle(screenResources); } } - + @Override public int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx) { final int screen_idx = screen.getIndex(); @@ -220,7 +220,7 @@ class RandR13 implements RandR { releaseScreenResourceHandle(screenResources); } } - + @Override public boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode) { final int screen_idx = screen.getIndex(); @@ -229,7 +229,7 @@ class RandR13 implements RandR { try { final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, monitor.getId()); try { - res = setMonitorMode0(dpy, screenResources, monitorInfo, monitor.getId(), mode.getId(), mode.getRotation(), + res = setMonitorMode0(dpy, screenResources, monitorInfo, monitor.getId(), mode.getId(), mode.getRotation(), -1, -1); // no fixed position! } finally { releaseMonitorInfoHandle(monitorInfo); @@ -239,36 +239,36 @@ class RandR13 implements RandR { } return res; } - + @Override public final void updateScreenViewport(final long dpy, final ScreenDriver screen, final RectangleImmutable viewport) { final int screen_idx = screen.getIndex(); final long screenResources = getScreenResourceHandle(dpy, screen_idx); try { - setScreenViewport0(dpy, screen_idx, screenResources, viewport.getX(), viewport.getY(), viewport.getWidth(), viewport.getHeight()); + setScreenViewport0(dpy, screen_idx, screenResources, viewport.getX(), viewport.getY(), viewport.getWidth(), viewport.getHeight()); } finally { dumpInfo0(dpy, screen_idx, screenResources); releaseScreenResourceHandle(screenResources); } } - + private static native long getScreenResources0(long display, int screen_index); private static native void freeScreenResources0(long screenResources); private static native void dumpInfo0(long display, int screen_index, long screenResources); - + private static native int getMonitorDeviceCount0(long screenResources); - + private static native long getMonitorInfoHandle0(long display, int screen_index, long screenResources, int monitor_index); private static native void freeMonitorInfoHandle0(long monitorInfoHandle); - + private static native int[] getAvailableRotations0(long monitorInfo); private static native int[] getMonitorViewport0(long monitorInfo); private static native int[] getMonitorCurrentMode0(long monitorInfo); - + private static native int[] getMonitorMode0(long screenResources, int mode_index); private static native int[] getMonitorCurrentMode0(long screenResources, long monitorInfo); private static native int[] getMonitorDevice0(long display, long screenResources, long monitorInfo, int monitor_idx); - + private static native boolean setMonitorMode0(long display, long screenResources, long monitorInfo, int monitor_idx, int mode_id, int rotation, int x, int y); private static native boolean setScreenViewport0(long display, int screen_index, long screenResources, int x, int y, int width, int height); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index c01d899f8..7f75e03f0 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.x11; @@ -54,19 +54,19 @@ import com.jogamp.nativewindow.x11.X11GraphicsScreen; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.MonitorMode; -public class ScreenDriver extends ScreenImpl { +public class ScreenDriver extends ScreenImpl { protected static final boolean DEBUG_TEST_RANDR13_DISABLED; - + static { Debug.initSingleton(); DEBUG_TEST_RANDR13_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableRandR13", true); - + DisplayDriver.initSingleton(); } /** Ensure static init has been run. */ /* pp */static void initSingleton() { } - + public ScreenDriver() { } @@ -74,14 +74,14 @@ public class ScreenDriver extends ScreenImpl { protected void createNativeImpl() { // validate screen index Long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - public Long run(long dpy) { + public Long run(long dpy) { return new Long(GetScreen0(dpy, screen_idx)); } } ); if (handle.longValue() == 0) { throw new RuntimeException("Error creating screen: " + screen_idx); } - final X11GraphicsDevice x11dev = (X11GraphicsDevice) getDisplay().getGraphicsDevice(); - final long dpy = x11dev.getHandle(); + final X11GraphicsDevice x11dev = (X11GraphicsDevice) getDisplay().getGraphicsDevice(); + final long dpy = x11dev.getHandle(); aScreen = new X11GraphicsScreen(x11dev, screen_idx); { int v[] = getRandRVersion0(dpy); @@ -118,7 +118,7 @@ public class ScreenDriver extends ScreenImpl { if( rAndR.beginInitialQuery(device.getHandle(), this) ) { try { final int crtCount = rAndR.getMonitorDeviceCount(device.getHandle(), this); - + // Gather all available rotations final ArrayHashSet availableRotations = new ArrayHashSet(); for(int i = 0; i < crtCount; i++) { @@ -129,7 +129,7 @@ public class ScreenDriver extends ScreenImpl { availableRotations.addAll(rotationList); } } - + // collect all modes, while injecting all available rotations { int modeIdx = 0; @@ -147,8 +147,8 @@ public class ScreenDriver extends ScreenImpl { if( cache.monitorModes.size() > 0 ) { for(int i = 0; i < crtCount; i++) { final int[] monitorProps = rAndR.getMonitorDeviceProps(device.getHandle(), this, cache, i); - if( null != monitorProps && - MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps[0] && // Enabled ? I.e. contains active modes ? + if( null != monitorProps && + MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps[0] && // Enabled ? I.e. contains active modes ? MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps.length ) { MonitorModeProps.streamInMonitorDevice(null, cache, this, monitorProps, 0); } @@ -174,11 +174,11 @@ public class ScreenDriver extends ScreenImpl { device.unlock(); } } - + @Override protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { if( null == rAndR ) { return null; } - + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public MonitorMode run(long dpy) { final int[] currentModeProps = rAndR.getCurrentMonitorModeProps(dpy, ScreenDriver.this, monitor.getId()); @@ -189,14 +189,14 @@ public class ScreenDriver extends ScreenImpl { @Override protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { if( null == rAndR ) { return false; } - + final long t0 = System.currentTimeMillis(); boolean done = runWithOptTempDisplayHandle( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { return Boolean.valueOf( rAndR.setCurrentMonitorMode(dpy, ScreenDriver.this, monitor, mode) ); - } + } }).booleanValue(); - + if(DEBUG || !done) { System.err.println("X11Screen.setCurrentMonitorModeImpl: TO ("+SCREEN_MODE_CHANGE_TIMEOUT+") reached: "+ (System.currentTimeMillis()-t0)+"ms; "+monitor.getCurrentMode()+" -> "+mode); @@ -205,10 +205,10 @@ public class ScreenDriver extends ScreenImpl { } private DisplayImpl.DisplayRunnable xineramaEnabledQueryWithTemp = new DisplayImpl.DisplayRunnable() { - public Boolean run(long dpy) { - return new Boolean(X11Util.XineramaIsEnabled(dpy)); + public Boolean run(long dpy) { + return new Boolean(X11Util.XineramaIsEnabled(dpy)); } }; - + @Override protected int validateScreenIndex(final int idx) { final DisplayDriver x11Display = (DisplayDriver) getDisplay(); @@ -219,7 +219,7 @@ public class ScreenDriver extends ScreenImpl { return runWithTempDisplayHandle( xineramaEnabledQueryWithTemp ).booleanValue() ? 0 : idx; } } - + @Override protected void calcVirtualScreenOriginAndSize(final Rectangle vOriginSize) { final RectangleImmutable ov = (RectangleImmutable) getViewport().cloneMutable(); @@ -244,17 +244,17 @@ public class ScreenDriver extends ScreenImpl { System.err.println("X11Screen.calcVirtualScreenOriginAndSize: Querying X11: "+ov+" -> "+vOriginSize); } } - } - + } + //---------------------------------------------------------------------- // Internals only - // + // private final T runWithLockedDisplayDevice(DisplayRunnable action) { return display.runWithLockedDisplayDevice(action); } - + private final T runWithTempDisplayHandle(DisplayRunnable action) { - final long displayHandle = X11Util.openDisplay(display.getName()); + final long displayHandle = X11Util.openDisplay(display.getName()); if(0 == displayHandle) { throw new RuntimeException("null device"); } @@ -266,7 +266,7 @@ public class ScreenDriver extends ScreenImpl { } return res; } - + private final T runWithOptTempDisplayHandle(DisplayRunnable action) { if( null != rAndR && rAndR.getVersion().compareTo(RandR.version130) >= 0 ) { return display.runWithLockedDisplayDevice(action); @@ -274,12 +274,12 @@ public class ScreenDriver extends ScreenImpl { return runWithTempDisplayHandle(action); } } - + private static native long GetScreen0(long dpy, int scrn_idx); private static native int getWidth0(long display, int scrn_idx); private static native int getHeight0(long display, int scrn_idx); - + private static native int[] getRandRVersion0(long display); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 806dd270c..02f80c0c3 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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 jogamp.newt.driver.x11; @@ -57,7 +57,7 @@ public class WindowDriver extends WindowImpl { private static final int X11_WHEEL_ONE_DOWN_BUTTON = 5; private static final int X11_WHEEL_TWO_UP_BUTTON = 6; private static final int X11_WHEEL_TWO_DOWN_BUTTON = 7; - + static { ScreenDriver.initSingleton(); } @@ -70,21 +70,21 @@ public class WindowDriver extends WindowImpl { final ScreenDriver screen = (ScreenDriver) getScreen(); final DisplayDriver display = (DisplayDriver) screen.getDisplay(); final AbstractGraphicsDevice edtDevice = display.getGraphicsDevice(); - - // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering + + // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering final long renderDeviceHandle = X11Util.openDisplay(edtDevice.getConnection()); if( 0 == renderDeviceHandle ) { throw new RuntimeException("Error creating display(GfxCfg/Render): "+edtDevice.getConnection()); } renderDevice = new X11GraphicsDevice(renderDeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); final AbstractGraphicsScreen renderScreen = new X11GraphicsScreen(renderDevice, screen.getIndex()); - + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested); final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( capsRequested, capsRequested, capabilitiesChooser, renderScreen, VisualIDHolder.VID_UNDEFINED); if(DEBUG_IMPLEMENTATION) { System.err.println("X11Window.createNativeImpl() factory: "+factory+", chosen config: "+cfg); - } + } if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } @@ -93,13 +93,13 @@ public class WindowDriver extends WindowImpl { throw new NativeWindowException("Chosen Configuration w/o native visual ID: "+cfg); } setGraphicsConfiguration(cfg); - final int flags = getReconfigureFlags(0, true) & + final int flags = getReconfigureFlags(0, true) & ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; edtDevice.lock(); - try { + try { setWindowHandle(CreateWindow0(getParentWindowHandle(), - edtDevice.getHandle(), screen.getIndex(), visualID, - display.getJavaObjectAtom(), display.getWindowDeleteAtom(), + edtDevice.getHandle(), screen.getIndex(), visualID, + display.getJavaObjectAtom(), display.getWindowDeleteAtom(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); } finally { edtDevice.unlock(); @@ -117,10 +117,10 @@ public class WindowDriver extends WindowImpl { final AbstractGraphicsDevice edtDevice = display.getGraphicsDevice(); edtDevice.lock(); try { - CloseWindow0(edtDevice.getHandle(), windowHandleClose, + CloseWindow0(edtDevice.getHandle(), windowHandleClose, display.getJavaObjectAtom(), display.getWindowDeleteAtom() /* , display.getKbdHandle() */); // XKB disabled for now } catch (Throwable t) { - if(DEBUG_IMPLEMENTATION) { + if(DEBUG_IMPLEMENTATION) { Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); e.printStackTrace(); } @@ -135,7 +135,7 @@ public class WindowDriver extends WindowImpl { } } - /** + /** *

                      * X11 Window supports {@link #FLAG_IS_FULLSCREEN_SPAN} *

                      @@ -145,7 +145,7 @@ public class WindowDriver extends WindowImpl { protected boolean isReconfigureFlagSupported(int changeFlags) { return true; // all flags! } - + @Override protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, int flags) { if(DEBUG_IMPLEMENTATION) { @@ -153,8 +153,8 @@ public class WindowDriver extends WindowImpl { } final int _x, _y; if(0 == ( FLAG_IS_UNDECORATED & flags)) { - final InsetsImmutable i = getInsets(); - + final InsetsImmutable i = getInsets(); + // client position -> top-level window position _x = x - i.getLeftWidth() ; _y = y - i.getTopHeight() ; @@ -177,7 +177,7 @@ public class WindowDriver extends WindowImpl { final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { - reconfigureWindow0( dpy, getScreenIndex(), + reconfigureWindow0( dpy, getScreenIndex(), getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), _x, _y, width, height, fflags); return null; @@ -205,23 +205,23 @@ public class WindowDriver extends WindowImpl { public Object run(long dpy) { reconfigureWindow0( dpy, getScreenIndex(), getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), - getX(), getY(), getWidth(), getHeight(), flags); + getX(), getY(), getWidth(), getHeight(), flags); return null; } }); } super.focusChanged(defer, focusGained); } - + protected void reparentNotify(long newParentWindowHandle) { if(DEBUG_IMPLEMENTATION) { final long p0 = getParentWindowHandle(); System.err.println("Window.reparentNotify ("+getThreadName()+"): "+toHexString(p0)+" -> "+toHexString(newParentWindowHandle)); } } - + @Override - protected void requestFocusImpl(final boolean force) { + protected void requestFocusImpl(final boolean force) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { requestFocus0(dpy, getWindowHandle(), force); @@ -239,7 +239,7 @@ public class WindowDriver extends WindowImpl { } }); } - + @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { @@ -257,7 +257,7 @@ public class WindowDriver extends WindowImpl { } }).booleanValue(); } - + @Override protected void warpPointerImpl(final int x, final int y) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { @@ -267,7 +267,7 @@ public class WindowDriver extends WindowImpl { } }); } - + @Override protected Point getLocationOnScreenImpl(final int x, final int y) { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { @@ -279,9 +279,9 @@ public class WindowDriver extends WindowImpl { @Override protected void updateInsetsImpl(Insets insets) { - // nop - using event driven insetsChange(..) + // nop - using event driven insetsChange(..) } - + @Override protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, int x, int y, short button, float[] rotationXYZ, float rotationScale) { @@ -321,34 +321,34 @@ public class WindowDriver extends WindowImpl { rotationXYZ[0] = -1; modifiers |= InputEvent.SHIFT_MASK; break; - } + } break; } super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); } - + /** Called by native TK */ protected final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar0, String keyString) { // handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); final boolean isModifierKey = KeyEvent.isModifierKey(keyCode); final boolean isAutoRepeat = 0 != ( KeyEvent.AUTOREPEAT_MASK & modifiers ); - final char keyChar = ( null != keyString ) ? keyString.charAt(0) : keyChar0; + final char keyChar = ( null != keyString ) ? keyString.charAt(0) : keyChar0; // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar0+">/<"+keyChar+">, keyString "+keyString+", mods "+toHexString(modifiers)+ // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isAutoRepeat+", [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); - + if( !isAutoRepeat || !isModifierKey ) { // ! ( isModifierKey && isAutoRepeat ) switch(eventType) { case KeyEvent.EVENT_KEY_PRESSED: super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar); break; - + case KeyEvent.EVENT_KEY_RELEASED: super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); break; } } } - + @Override public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); @@ -357,33 +357,33 @@ public class WindowDriver extends WindowImpl { public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); } - + //---------------------------------------------------------------------- // Internals only // private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI - + private final T runWithLockedDisplayDevice(DisplayRunnable action) { return ((DisplayDriver) getScreen().getDisplay()).runWithLockedDisplayDevice(action); } protected static native boolean initIDs0(); - - private native long CreateWindow0(long parentWindowHandle, long display, int screen_index, - int visualID, long javaObjectAtom, long windowDeleteAtom, - int x, int y, int width, int height, boolean autoPosition, int flags); + + private native long CreateWindow0(long parentWindowHandle, long display, int screen_index, + int visualID, long javaObjectAtom, long windowDeleteAtom, + int x, int y, int width, int height, boolean autoPosition, int flags); private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom /*, long kbdHandle*/ ); // XKB disabled for now private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle, - long windowDeleteAtom, int x, int y, int width, int height, int flags); + long windowDeleteAtom, int x, int y, int width, int height, int flags); private native void requestFocus0(long display, long windowHandle, boolean force); - + private static native void setTitle0(long display, long windowHandle, String title); private static native long getParentWindow0(long display, long windowHandle); private static native boolean setPointerVisible0(long display, long windowHandle, boolean visible); private static native boolean confinePointer0(long display, long windowHandle, boolean grab); private static native void warpPointer0(long display, long windowHandle, int x, int y); - + private long windowHandleClose; private X11GraphicsDevice renderDevice; } diff --git a/src/newt/classes/jogamp/newt/event/NEWTEventTask.java b/src/newt/classes/jogamp/newt/event/NEWTEventTask.java index 93d5e2fb9..38a434279 100644 --- a/src/newt/classes/jogamp/newt/event/NEWTEventTask.java +++ b/src/newt/classes/jogamp/newt/event/NEWTEventTask.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.newt.event; import com.jogamp.newt.event.NEWTEvent; diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java index 6024195e3..08eacdee5 100644 --- a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java @@ -40,16 +40,16 @@ import com.jogamp.newt.util.EDTUtil; */ public class SWTEDTUtil implements EDTUtil { public static final boolean DEBUG = Debug.debug("EDT"); - + private final Object edtLock = new Object(); // locking the EDT start/stop state - private final ThreadGroup threadGroup; + private final ThreadGroup threadGroup; private final String name; private final Runnable dispatchMessages; private final org.eclipse.swt.widgets.Display swtDisplay; private NEDT nedt = null; private int start_iter=0; private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; - + public SWTEDTUtil(final com.jogamp.newt.Display newtDisplay, org.eclipse.swt.widgets.Display swtDisplay) { this.threadGroup = Thread.currentThread().getThreadGroup(); this.name=Thread.currentThread().getName()+"-SWTDisplay-"+newtDisplay.getFQName()+"-EDT-"; @@ -61,11 +61,11 @@ public class SWTEDTUtil implements EDTUtil { this.nedt = new NEDT(threadGroup, name); this.nedt.setDaemon(true); // don't stop JVM from shutdown .. } - + public final org.eclipse.swt.widgets.Display getDisplay() { return swtDisplay; } - + @Override public long getPollPeriod() { return pollPeriod; @@ -116,7 +116,7 @@ public class SWTEDTUtil implements EDTUtil { } nedt.start(); } - + @Override public boolean isCurrentThreadEDT() { return !swtDisplay.isDisposed() && swtDisplay.getThread() == Thread.currentThread(); @@ -126,18 +126,18 @@ public class SWTEDTUtil implements EDTUtil { public final boolean isCurrentThreadNEDT() { return nedt == Thread.currentThread(); } - + @Override public final boolean isCurrentThreadEDTorNEDT() { final Thread ct = Thread.currentThread(); return ( !swtDisplay.isDisposed() && ct == swtDisplay.getThread() ) || ct == nedt ; } - + @Override public boolean isRunning() { return nedt.isRunning(); } - + @Override public final boolean invokeStop(boolean wait, Runnable task) { return invokeImpl(wait, task, true); @@ -147,12 +147,12 @@ public class SWTEDTUtil implements EDTUtil { public final boolean invoke(boolean wait, Runnable task) { return invokeImpl(wait, task, false); } - + private static Runnable nullTask = new Runnable() { @Override - public void run() { } + public void run() { } }; - + private final boolean invokeImpl(boolean wait, Runnable task, boolean stop) { Throwable throwable = null; RunnableTask rTask = null; @@ -165,12 +165,12 @@ public class SWTEDTUtil implements EDTUtil { System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop); Thread.dumpStack(); } - return false; + return false; } if( swtDisplay.isDisposed() ) { stop = true; } - + if( isCurrentThreadEDT() ) { if(null != task) { task.run(); @@ -179,7 +179,7 @@ public class SWTEDTUtil implements EDTUtil { if( stop ) { nedt.shouldStop = true; } - } else { + } else { if( !nedt.isRunning && !swtDisplay.isDisposed() ) { if( null != task ) { if( stop ) { @@ -210,11 +210,11 @@ public class SWTEDTUtil implements EDTUtil { return false; } } - + if( null != task ) { rTask = new RunnableTask(task, wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */, + true /* always catch and report Exceptions, don't disturb EDT */, wait ? null : System.err); swtDisplay.asyncExec(rTask); } @@ -238,7 +238,7 @@ public class SWTEDTUtil implements EDTUtil { } return true; } - } + } @Override final public boolean waitUntilIdle() { @@ -278,7 +278,7 @@ public class SWTEDTUtil implements EDTUtil { } } } - + class NEDT extends Thread { volatile boolean shouldStop = false; volatile boolean isRunning = false; @@ -298,7 +298,7 @@ public class SWTEDTUtil implements EDTUtil { super.start(); } - /** + /** * Utilizing locking only on tasks and its execution, * not for event dispatching. */ @@ -315,7 +315,7 @@ public class SWTEDTUtil implements EDTUtil { // EDT invoke thread is SWT-EDT, // hence dispatching is required to run on SWT-EDT as well. // Otherwise a deadlock may happen due to dispatched event's - // triggering a locking action. + // triggering a locking action. if ( !swtDisplay.isDisposed() ) { swtDisplay.syncExec(dispatchMessages); } else { @@ -343,7 +343,7 @@ public class SWTEDTUtil implements EDTUtil { } } finally { if(DEBUG) { - System.err.println(getName()+": SWT-EDT run() END "+ getName()+", "+error); + System.err.println(getName()+": SWT-EDT run() END "+ getName()+", "+error); } synchronized(edtLock) { isRunning = false; @@ -358,5 +358,5 @@ public class SWTEDTUtil implements EDTUtil { } // finally } // run() } // EventDispatchThread - + } diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java index 3782a1186..b5c45c1aa 100644 --- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.newt.swt.event; import org.eclipse.swt.SWT; @@ -206,7 +206,7 @@ public class SWTNewtEventFactory { } return res; } - + public static final com.jogamp.newt.event.MouseEvent createMouseEvent(org.eclipse.swt.widgets.Event event, Object source) { switch(event.type) { case SWT.MouseDown: @@ -229,7 +229,7 @@ public class SWTNewtEventFactory { } int mods = swtModifiers2Newt(event.stateMask, true); - + if( source instanceof com.jogamp.newt.Window) { final com.jogamp.newt.Window newtSource = (com.jogamp.newt.Window)source; if(newtSource.isPointerConfined()) { @@ -239,7 +239,7 @@ public class SWTNewtEventFactory { mods |= InputEvent.INVISIBLE_MASK; } } - + return new com.jogamp.newt.event.MouseEvent( type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), mods, event.x, event.y, (short)event.count, (short)event.button, MouseEvent.getRotationXYZ(rotation, mods), 1f); @@ -260,32 +260,32 @@ public class SWTNewtEventFactory { final short newtKeyCode = swtKeyCode2NewtKeyCode( event.keyCode ); return com.jogamp.newt.event.KeyEvent.create( type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), - swtModifiers2Newt(event.stateMask, false), + swtModifiers2Newt(event.stateMask, false), newtKeyCode, newtKeyCode, event.character); } return null; // no mapping .. } - + // // // - + short dragButtonDown = 0; - + public SWTNewtEventFactory() { resetButtonsDown(); } - + final void resetButtonsDown() { dragButtonDown = 0; } - + public final boolean dispatchMouseEvent(org.eclipse.swt.widgets.Event event, Object source, com.jogamp.newt.event.MouseListener l) { com.jogamp.newt.event.MouseEvent res = createMouseEvent(event, source); if(null != res) { if(null != l) { switch(event.type) { - case SWT.MouseDown: + case SWT.MouseDown: dragButtonDown = (short) event.button; l.mousePressed(res); break; case SWT.MouseUp: @@ -293,7 +293,7 @@ public class SWTNewtEventFactory { l.mouseReleased(res); { final com.jogamp.newt.event.MouseEvent res2 = new com.jogamp.newt.event.MouseEvent( - com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED, + com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED, res.getSource(), res.getWhen(), res.getModifiers(), res.getX(), res.getY(), res.getClickCount(), @@ -304,7 +304,7 @@ public class SWTNewtEventFactory { case SWT.MouseMove: if( 0 < dragButtonDown ) { final com.jogamp.newt.event.MouseEvent res2 = new com.jogamp.newt.event.MouseEvent( - com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED, + com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED, res.getSource(), res.getWhen(), res.getModifiers(), res.getX(), res.getY(), res.getClickCount(), @@ -315,14 +315,14 @@ public class SWTNewtEventFactory { } break; case SWT.MouseEnter: - l.mouseEntered(res); + l.mouseEntered(res); break; case SWT.MouseExit: resetButtonsDown(); - l.mouseExited(res); + l.mouseExited(res); break; case SWT.MouseVerticalWheel: - l.mouseWheelMoved(res); + l.mouseWheelMoved(res); break; } } @@ -337,7 +337,7 @@ public class SWTNewtEventFactory { if(null != l) { switch(event.type) { case SWT.KeyDown: - l.keyPressed(res); + l.keyPressed(res); break; case SWT.KeyUp: l.keyReleased(res); @@ -347,9 +347,9 @@ public class SWTNewtEventFactory { return true; } return false; - } - - public final void attachDispatchListener(final org.eclipse.swt.widgets.Control ctrl, final Object source, + } + + public final void attachDispatchListener(final org.eclipse.swt.widgets.Control ctrl, final Object source, final com.jogamp.newt.event.MouseListener ml, final com.jogamp.newt.event.KeyListener kl) { final Listener listener = new Listener () { -- cgit v1.2.3 From f1ae8ddb87c88a57dce4593f006881ef6a7f0932 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Thu, 17 Oct 2013 22:51:47 -0700 Subject: jogl: add missing @Override annotations Signed-off-by: Harvey Harrison --- .../com/jogamp/audio/windows/waveout/Mixer.java | 2 ++ .../com/jogamp/audio/windows/waveout/Vec3f.java | 1 + .../gluegen/opengl/BuildComposablePipeline.java | 31 +++++++++++++++++ .../com/jogamp/gluegen/opengl/GLEmitter.java | 3 ++ .../jogamp/gluegen/opengl/ant/StaticGLGenTask.java | 1 + .../NativeSignatureJavaMethodBindingEmitter.java | 6 ++++ .../runtime/opengl/GLProcAddressResolver.java | 1 + .../com/jogamp/graph/curve/OutlineShape.java | 3 ++ .../com/jogamp/graph/curve/opengl/RenderState.java | 1 + src/jogl/classes/com/jogamp/graph/font/Font.java | 1 + .../classes/com/jogamp/graph/geom/Outline.java | 3 ++ .../classes/com/jogamp/graph/geom/Triangle.java | 1 + src/jogl/classes/com/jogamp/graph/geom/Vertex.java | 1 + .../com/jogamp/graph/geom/opengl/SVertex.java | 21 ++++++++++++ src/jogl/classes/com/jogamp/opengl/FBObject.java | 4 +++ .../com/jogamp/opengl/GLRendererQuirks.java | 1 + .../opengl/cg/CgDynamicLibraryBundleInfo.java | 1 + .../com/jogamp/opengl/math/geom/AABBox.java | 3 ++ .../classes/com/jogamp/opengl/swt/GLCanvas.java | 1 + .../com/jogamp/opengl/util/AWTAnimatorImpl.java | 3 ++ .../classes/com/jogamp/opengl/util/Animator.java | 13 ++++++++ .../com/jogamp/opengl/util/AnimatorBase.java | 4 +++ .../jogamp/opengl/util/DefaultAnimatorImpl.java | 2 ++ .../com/jogamp/opengl/util/FPSAnimator.java | 14 ++++++++ .../com/jogamp/opengl/util/GLArrayDataClient.java | 1 + .../jogamp/opengl/util/GLArrayDataEditable.java | 1 + .../com/jogamp/opengl/util/GLArrayDataServer.java | 5 +++ .../com/jogamp/opengl/util/GLPixelBuffer.java | 2 ++ .../com/jogamp/opengl/util/ImmModeSink.java | 2 ++ .../classes/com/jogamp/opengl/util/PMVMatrix.java | 1 + .../com/jogamp/opengl/util/TileRendererBase.java | 1 + .../classes/com/jogamp/opengl/util/TimeFrameI.java | 1 + .../com/jogamp/opengl/util/av/AudioSink.java | 3 ++ .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 1 + .../jogamp/opengl/util/awt/AWTGLPixelBuffer.java | 4 +++ .../com/jogamp/opengl/util/awt/TextRenderer.java | 32 ++++++++++++++++++ .../com/jogamp/opengl/util/glsl/ShaderCode.java | 3 ++ .../com/jogamp/opengl/util/glsl/ShaderProgram.java | 3 ++ .../jogamp/opengl/util/glsl/sdk/CompileShader.java | 1 + .../opengl/util/glsl/sdk/CompileShaderNVidia.java | 4 +++ .../com/jogamp/opengl/util/packrect/Level.java | 2 ++ .../com/jogamp/opengl/util/packrect/Rect.java | 1 + .../opengl/util/packrect/RectanglePacker.java | 2 ++ .../com/jogamp/opengl/util/texture/Texture.java | 1 + .../jogamp/opengl/util/texture/TextureCoords.java | 1 + .../jogamp/opengl/util/texture/TextureData.java | 1 + .../com/jogamp/opengl/util/texture/TextureIO.java | 14 ++++++++ .../opengl/util/texture/TextureSequence.java | 1 + .../jogamp/opengl/util/texture/TextureState.java | 1 + .../jogamp/opengl/util/texture/spi/JPEGImage.java | 2 ++ .../opengl/util/texture/spi/LEDataInputStream.java | 18 ++++++++++ .../util/texture/spi/LEDataOutputStream.java | 15 +++++++++ .../util/texture/spi/NetPbmTextureWriter.java | 1 + .../jogamp/opengl/util/texture/spi/PNGImage.java | 1 + .../jogamp/opengl/util/texture/spi/SGIImage.java | 2 ++ .../jogamp/opengl/util/texture/spi/TGAImage.java | 1 + .../util/texture/spi/awt/IIOTextureProvider.java | 3 ++ .../util/texture/spi/awt/IIOTextureWriter.java | 1 + .../classes/javax/media/opengl/GLArrayData.java | 1 + .../classes/javax/media/opengl/GLDebugMessage.java | 1 + .../javax/media/opengl/GLDrawableFactory.java | 1 + src/jogl/classes/javax/media/opengl/GLProfile.java | 5 +++ .../classes/javax/media/opengl/GLUniformData.java | 1 + .../classes/javax/media/opengl/awt/GLCanvas.java | 10 ++++-- .../opengl/glu/GLUtessellatorCallbackAdapter.java | 12 +++++++ .../graph/curve/opengl/RegionRendererImpl01.java | 1 + .../jogamp/graph/curve/opengl/RenderStateImpl.java | 3 ++ .../jogamp/graph/curve/opengl/VBORegion2PES2.java | 3 ++ .../jogamp/graph/curve/opengl/VBORegionSPES2.java | 3 ++ .../jogamp/graph/curve/tess/CDTriangulator2D.java | 3 ++ .../classes/jogamp/graph/font/JavaFontLoader.java | 3 ++ .../jogamp/graph/font/UbuntuFontLoader.java | 2 ++ .../jogamp/graph/font/typecast/TypecastFont.java | 14 ++++++++ .../font/typecast/TypecastFontConstructor.java | 4 +++ .../jogamp/graph/font/typecast/TypecastGlyph.java | 8 +++++ .../graph/font/typecast/TypecastHMetrics.java | 6 ++++ .../jogamp/graph/font/typecast/ot/OTFont.java | 1 + .../graph/font/typecast/ot/table/BaseTable.java | 13 ++++++++ .../graph/font/typecast/ot/table/CffTable.java | 14 ++++++++ .../font/typecast/ot/table/CharstringType2.java | 3 ++ .../font/typecast/ot/table/ClassDefFormat1.java | 1 + .../font/typecast/ot/table/ClassDefFormat2.java | 1 + .../graph/font/typecast/ot/table/CmapFormat.java | 1 + .../graph/font/typecast/ot/table/CmapFormat0.java | 3 ++ .../graph/font/typecast/ot/table/CmapFormat2.java | 3 ++ .../graph/font/typecast/ot/table/CmapFormat4.java | 4 +++ .../graph/font/typecast/ot/table/CmapFormat6.java | 3 ++ .../font/typecast/ot/table/CmapFormatUnknown.java | 3 ++ .../font/typecast/ot/table/CmapIndexEntry.java | 2 ++ .../graph/font/typecast/ot/table/CmapTable.java | 3 ++ .../font/typecast/ot/table/CoverageFormat1.java | 2 ++ .../font/typecast/ot/table/CoverageFormat2.java | 2 ++ .../graph/font/typecast/ot/table/CvtTable.java | 3 ++ .../font/typecast/ot/table/DirectoryEntry.java | 2 ++ .../graph/font/typecast/ot/table/DsigTable.java | 3 ++ .../graph/font/typecast/ot/table/FpgmTable.java | 3 ++ .../graph/font/typecast/ot/table/GaspRange.java | 1 + .../graph/font/typecast/ot/table/GaspTable.java | 3 ++ .../typecast/ot/table/GlyfCompositeDescript.java | 7 ++++ .../graph/font/typecast/ot/table/GlyfDescript.java | 6 ++++ .../font/typecast/ot/table/GlyfSimpleDescript.java | 8 +++++ .../graph/font/typecast/ot/table/GlyfTable.java | 2 ++ .../graph/font/typecast/ot/table/GposTable.java | 3 ++ .../graph/font/typecast/ot/table/GsubTable.java | 4 +++ .../graph/font/typecast/ot/table/HdmxTable.java | 3 ++ .../graph/font/typecast/ot/table/HeadTable.java | 3 ++ .../graph/font/typecast/ot/table/HheaTable.java | 3 ++ .../graph/font/typecast/ot/table/HmtxTable.java | 3 ++ .../typecast/ot/table/KernSubtableFormat0.java | 2 ++ .../typecast/ot/table/KernSubtableFormat2.java | 2 ++ .../graph/font/typecast/ot/table/KernTable.java | 2 ++ .../typecast/ot/table/LigatureSubstFormat1.java | 1 + .../graph/font/typecast/ot/table/LocaTable.java | 3 ++ .../graph/font/typecast/ot/table/LtshTable.java | 3 ++ .../graph/font/typecast/ot/table/MaxpTable.java | 3 ++ .../graph/font/typecast/ot/table/NameRecord.java | 1 + .../graph/font/typecast/ot/table/NameTable.java | 2 ++ .../graph/font/typecast/ot/table/Os2Table.java | 3 ++ .../graph/font/typecast/ot/table/Panose.java | 1 + .../graph/font/typecast/ot/table/PcltTable.java | 3 ++ .../graph/font/typecast/ot/table/PostTable.java | 3 ++ .../graph/font/typecast/ot/table/PrepTable.java | 3 ++ .../font/typecast/ot/table/SignatureBlock.java | 1 + .../font/typecast/ot/table/SingleSubstFormat1.java | 3 ++ .../font/typecast/ot/table/SingleSubstFormat2.java | 3 ++ .../font/typecast/ot/table/TableDirectory.java | 1 + .../graph/font/typecast/ot/table/VdmxTable.java | 3 ++ .../graph/font/typecast/ot/table/VheaTable.java | 3 ++ .../graph/font/typecast/ot/table/VmtxTable.java | 3 ++ .../graph/font/typecast/tt/engine/Parser.java | 1 + .../classes/jogamp/graph/geom/plane/Path2D.java | 5 +++ src/jogl/classes/jogamp/opengl/Debug.java | 1 + .../opengl/DesktopGLDynamicLookupHelper.java | 1 + src/jogl/classes/jogamp/opengl/FPSCounterImpl.java | 11 ++++++ src/jogl/classes/jogamp/opengl/GLContextImpl.java | 1 + .../jogamp/opengl/GLDebugMessageHandler.java | 2 ++ .../classes/jogamp/opengl/GLDrawableHelper.java | 4 ++- .../jogamp/opengl/GLDynamicLibraryBundleInfo.java | 1 + .../jogamp/opengl/GLOffscreenAutoDrawableImpl.java | 1 + src/jogl/classes/jogamp/opengl/GLRunnableTask.java | 1 + src/jogl/classes/jogamp/opengl/GLWorkerThread.java | 1 + src/jogl/classes/jogamp/opengl/MemoryObject.java | 2 ++ .../jogamp/opengl/SharedResourceRunner.java | 1 + src/jogl/classes/jogamp/opengl/ThreadingImpl.java | 1 + .../jogamp/opengl/awt/AWTThreadingPlugin.java | 3 ++ .../classes/jogamp/opengl/awt/AWTTilePainter.java | 1 + src/jogl/classes/jogamp/opengl/awt/Java2D.java | 3 ++ .../classes/jogamp/opengl/awt/VersionApplet.java | 9 +++++ .../egl/DesktopES2DynamicLibraryBundleInfo.java | 5 +++ .../classes/jogamp/opengl/egl/EGLDisplayUtil.java | 3 ++ .../classes/jogamp/opengl/egl/EGLDrawable.java | 1 + .../opengl/egl/EGLES1DynamicLibraryBundleInfo.java | 1 + .../opengl/egl/EGLES2DynamicLibraryBundleInfo.java | 1 + .../egl/EGLGraphicsConfigurationFactory.java | 1 + .../jogamp/opengl/egl/EGLUpstreamSurfaceHook.java | 1 + .../classes/jogamp/opengl/glu/GLUquadricImpl.java | 6 ++++ .../opengl/glu/gl2/nurbs/GL2CurveEvaluator.java | 6 ++++ .../opengl/glu/gl2/nurbs/GL2SurfaceEvaluator.java | 8 +++++ .../jogamp/opengl/glu/mipmap/Extract1010102.java | 2 ++ .../jogamp/opengl/glu/mipmap/Extract1555rev.java | 2 ++ .../opengl/glu/mipmap/Extract2101010rev.java | 2 ++ .../jogamp/opengl/glu/mipmap/Extract233rev.java | 2 ++ .../jogamp/opengl/glu/mipmap/Extract332.java | 2 ++ .../jogamp/opengl/glu/mipmap/Extract4444.java | 2 ++ .../jogamp/opengl/glu/mipmap/Extract4444rev.java | 2 ++ .../jogamp/opengl/glu/mipmap/Extract5551.java | 2 ++ .../jogamp/opengl/glu/mipmap/Extract565.java | 2 ++ .../jogamp/opengl/glu/mipmap/Extract565rev.java | 2 ++ .../jogamp/opengl/glu/mipmap/Extract8888.java | 2 ++ .../jogamp/opengl/glu/mipmap/Extract8888rev.java | 2 ++ .../jogamp/opengl/glu/mipmap/ExtractFloat.java | 2 ++ .../jogamp/opengl/glu/mipmap/ExtractSByte.java | 2 ++ .../jogamp/opengl/glu/mipmap/ExtractSInt.java | 2 ++ .../jogamp/opengl/glu/mipmap/ExtractSShort.java | 2 ++ .../jogamp/opengl/glu/mipmap/ExtractUByte.java | 2 ++ .../jogamp/opengl/glu/mipmap/ExtractUInt.java | 2 ++ .../jogamp/opengl/glu/mipmap/ExtractUShort.java | 2 ++ .../opengl/glu/tessellator/PriorityQHeap.java | 7 ++++ .../opengl/glu/tessellator/PriorityQSort.java | 7 ++++ .../jogamp/opengl/glu/tessellator/Render.java | 3 ++ .../jogamp/opengl/glu/tessellator/Sweep.java | 2 ++ .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 1 + .../macosx/cgl/MacOSXCGLDrawableFactory.java | 1 + .../macosx/cgl/MacOSXCGLGraphicsConfiguration.java | 1 + .../cgl/MacOSXCGLGraphicsConfigurationFactory.java | 1 + .../MacOSXAWTCGLGraphicsConfigurationFactory.java | 1 + .../opengl/util/GLArrayHandlerInterleaved.java | 3 ++ .../jogamp/opengl/util/GLDataArrayHandler.java | 3 ++ .../jogamp/opengl/util/GLFixedArrayHandler.java | 3 ++ .../opengl/util/GLFixedArrayHandlerFlat.java | 3 ++ .../jogamp/opengl/util/GLVBOArrayHandler.java | 1 + .../jogamp/opengl/util/av/EGLMediaPlayerImpl.java | 1 + .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 5 +++ .../av/impl/FFMPEGDynamicLibraryBundleInfo.java | 2 ++ .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 1 + .../jogamp/opengl/util/glsl/GLSLArrayHandler.java | 3 ++ .../opengl/util/glsl/GLSLArrayHandlerFlat.java | 3 ++ .../util/glsl/GLSLArrayHandlerInterleaved.java | 3 ++ .../opengl/util/glsl/fixedfunc/FixedFuncHook.java | 39 ++++++++++++++++++++++ .../util/glsl/fixedfunc/FixedFuncPipeline.java | 1 + .../jogamp/opengl/util/jpeg/JPEGDecoder.java | 12 +++++++ .../classes/jogamp/opengl/util/pngj/ImageLine.java | 1 + .../jogamp/opengl/util/pngj/ImageLineHelper.java | 1 + .../jogamp/opengl/util/pngj/PngHelperInternal.java | 1 + .../classes/jogamp/opengl/util/pngj/PngReader.java | 1 + .../opengl/util/pngj/chunks/ChunkHelper.java | 2 ++ .../jogamp/opengl/util/pngj/chunks/ChunkRaw.java | 1 + .../jogamp/opengl/util/pngj/chunks/ChunksList.java | 4 +++ .../util/pngj/chunks/ChunksListForWrite.java | 2 ++ .../opengl/util/pngj/chunks/PngChunkSingle.java | 1 + .../opengl/util/pngj/chunks/PngMetadata.java | 1 + .../windows/wgl/WindowsWGLDrawableFactory.java | 1 + .../wgl/WindowsWGLGraphicsConfiguration.java | 2 ++ .../WindowsWGLGraphicsConfigurationFactory.java | 1 + .../WindowsAWTWGLGraphicsConfigurationFactory.java | 1 + .../opengl/x11/glx/X11GLXDrawableFactory.java | 1 + .../x11/glx/X11GLXGraphicsConfiguration.java | 2 ++ .../glx/X11GLXGraphicsConfigurationFactory.java | 1 + .../nativewindow/awt/AWTGraphicsConfiguration.java | 1 + .../jogamp/nativewindow/awt/AWTGraphicsScreen.java | 1 + .../nativewindow/awt/AWTWindowClosingProtocol.java | 2 ++ .../nativewindow/awt/DirectDataBufferInt.java | 4 +++ .../nativewindow/macosx/MacOSXGraphicsDevice.java | 1 + .../com/jogamp/nativewindow/swt/SWTAccessor.java | 4 +++ .../windows/WindowsGraphicsDevice.java | 1 + .../jogamp/nativewindow/x11/X11GraphicsScreen.java | 1 + .../nativewindow/DefaultCapabilitiesChooser.java | 1 + .../nativewindow/DefaultGraphicsConfiguration.java | 4 +++ .../media/nativewindow/DefaultGraphicsScreen.java | 2 ++ .../nativewindow/GraphicsConfigurationFactory.java | 2 ++ .../media/nativewindow/NativeWindowFactory.java | 4 +++ .../javax/media/nativewindow/ProxySurface.java | 1 + .../javax/media/nativewindow/VisualIDHolder.java | 1 + .../javax/media/nativewindow/util/Dimension.java | 2 ++ .../nativewindow/util/DimensionImmutable.java | 2 ++ .../javax/media/nativewindow/util/Insets.java | 3 ++ .../media/nativewindow/util/InsetsImmutable.java | 2 ++ .../javax/media/nativewindow/util/Point.java | 3 ++ .../media/nativewindow/util/PointImmutable.java | 2 ++ .../javax/media/nativewindow/util/Rectangle.java | 3 ++ .../nativewindow/util/RectangleImmutable.java | 2 ++ .../javax/media/nativewindow/util/SurfaceSize.java | 3 ++ .../classes/jogamp/nativewindow/Debug.java | 1 + .../DefaultGraphicsConfigurationFactoryImpl.java | 1 + .../jogamp/nativewindow/GlobalToolkitLock.java | 1 + .../jogamp/nativewindow/NWJNILibLoader.java | 1 + .../nativewindow/NativeWindowFactoryImpl.java | 1 + .../jogamp/nativewindow/NullToolkitLock.java | 1 + .../jogamp/nativewindow/ProxySurfaceImpl.java | 1 + .../jogamp/nativewindow/ResourceToolkitLock.java | 1 + .../nativewindow/SharedResourceToolkitLock.java | 1 + .../jogamp/nativewindow/SurfaceUpdatedHelper.java | 1 + .../jogamp/nativewindow/jawt/JAWTJNILibLoader.java | 1 + .../classes/jogamp/nativewindow/jawt/JAWTUtil.java | 4 +++ .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 10 ++++++ .../jawt/windows/Win32SunJDKReflection.java | 1 + .../jawt/windows/WindowsJAWTWindow.java | 5 +++ .../nativewindow/jawt/x11/X11JAWTWindow.java | 5 +++ .../nativewindow/jawt/x11/X11SunJDKReflection.java | 1 + .../jogamp/nativewindow/macosx/OSXUtil.java | 2 +- .../x11/X11GraphicsConfigurationFactory.java | 1 + .../classes/jogamp/nativewindow/x11/X11Util.java | 2 ++ .../awt/X11AWTGraphicsConfigurationFactory.java | 1 + src/newt/classes/com/jogamp/newt/Display.java | 2 ++ .../classes/com/jogamp/newt/MonitorDevice.java | 3 ++ src/newt/classes/com/jogamp/newt/MonitorMode.java | 8 +++++ src/newt/classes/com/jogamp/newt/NewtFactory.java | 1 + src/newt/classes/com/jogamp/newt/Screen.java | 2 ++ .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 13 ++++++++ .../jogamp/newt/awt/applet/JOGLNewtApplet1Run.java | 4 +++ .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 6 ++++ .../jogamp/newt/event/DoubleTapScrollGesture.java | 1 + .../classes/com/jogamp/newt/event/InputEvent.java | 2 ++ .../classes/com/jogamp/newt/event/KeyAdapter.java | 2 ++ .../classes/com/jogamp/newt/event/KeyEvent.java | 2 ++ .../com/jogamp/newt/event/MonitorEvent.java | 2 ++ .../com/jogamp/newt/event/MouseAdapter.java | 8 +++++ .../classes/com/jogamp/newt/event/MouseEvent.java | 2 ++ .../classes/com/jogamp/newt/event/NEWTEvent.java | 1 + .../com/jogamp/newt/event/PinchToZoomGesture.java | 1 + .../com/jogamp/newt/event/TraceKeyAdapter.java | 2 ++ .../com/jogamp/newt/event/TraceMouseAdapter.java | 8 +++++ .../com/jogamp/newt/event/TraceWindowAdapter.java | 7 ++++ .../com/jogamp/newt/event/WindowAdapter.java | 7 ++++ .../classes/com/jogamp/newt/event/WindowEvent.java | 2 ++ .../com/jogamp/newt/event/WindowUpdateEvent.java | 2 ++ .../com/jogamp/newt/event/awt/AWTKeyAdapter.java | 2 ++ .../com/jogamp/newt/event/awt/AWTMouseAdapter.java | 10 ++++++ .../jogamp/newt/event/awt/AWTWindowAdapter.java | 22 ++++++++++++ .../classes/com/jogamp/newt/opengl/GLWindow.java | 2 ++ .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 3 ++ src/newt/classes/jogamp/newt/Debug.java | 1 + src/newt/classes/jogamp/newt/DisplayImpl.java | 9 +++++ src/newt/classes/jogamp/newt/NEWTJNILibLoader.java | 1 + src/newt/classes/jogamp/newt/OffscreenWindow.java | 7 ++++ src/newt/classes/jogamp/newt/WindowImpl.java | 16 +++++++++ .../newt/awt/event/AWTParentWindowAdapter.java | 11 ++++++ .../classes/jogamp/newt/driver/awt/AWTCanvas.java | 4 +++ .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 1 + .../jogamp/newt/driver/awt/DisplayDriver.java | 4 +++ .../jogamp/newt/driver/awt/ScreenDriver.java | 3 ++ .../jogamp/newt/driver/awt/WindowDriver.java | 6 ++++ .../jogamp/newt/driver/bcm/egl/DisplayDriver.java | 3 ++ .../jogamp/newt/driver/bcm/egl/ScreenDriver.java | 4 +++ .../jogamp/newt/driver/bcm/egl/WindowDriver.java | 6 ++++ .../newt/driver/bcm/vc/iv/DisplayDriver.java | 3 ++ .../jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java | 3 ++ .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 6 ++++ .../newt/driver/intel/gdl/DisplayDriver.java | 3 ++ .../jogamp/newt/driver/intel/gdl/ScreenDriver.java | 4 +++ .../jogamp/newt/driver/intel/gdl/WindowDriver.java | 6 ++++ .../jogamp/newt/driver/kd/DisplayDriver.java | 3 ++ .../jogamp/newt/driver/kd/ScreenDriver.java | 4 +++ .../jogamp/newt/driver/kd/WindowDriver.java | 6 ++++ .../jogamp/newt/driver/macosx/DisplayDriver.java | 3 ++ .../jogamp/newt/driver/macosx/ScreenDriver.java | 3 ++ .../jogamp/newt/driver/macosx/WindowDriver.java | 12 +++++++ .../jogamp/newt/driver/windows/DisplayDriver.java | 3 ++ .../jogamp/newt/driver/windows/WindowDriver.java | 9 +++++ .../jogamp/newt/driver/x11/DisplayDriver.java | 2 ++ .../jogamp/newt/driver/x11/ScreenDriver.java | 5 +++ .../jogamp/newt/driver/x11/WindowDriver.java | 8 +++++ src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java | 2 ++ 323 files changed, 1132 insertions(+), 4 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java index 0a502c123..3b76d2ebf 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java @@ -129,6 +129,7 @@ public class Mixer { super("Mixer Thread"); } + @Override public void run() { while (!shutdown) { List/**/ curTracks = tracks; @@ -166,6 +167,7 @@ public class Mixer { } } + @Override public void run() { while (!shutdown) { // Get the next buffer diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/Vec3f.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/Vec3f.java index 0726e5762..79fb80169 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/Vec3f.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/Vec3f.java @@ -206,6 +206,7 @@ class Vec3f { z *= arg.z; } + @Override public String toString() { return "(" + x + ", " + y + ", " + z + ")"; } diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 8429fbcfd..5f358a6d3 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -402,6 +402,7 @@ public class BuildComposablePipeline { ifNames, null, new CodeGenUtils.EmissionCallback() { + @Override public void emit(PrintWriter w) { emitClassDocComment(w); } @@ -752,18 +753,22 @@ public class BuildComposablePipeline { this.mode = mode; } + @Override protected String getOutputName() { return className; } + @Override protected int getMode() { return mode; } + @Override protected boolean emptyMethodAllowed() { return true; } + @Override protected boolean emptyDownstreamAllowed() { return true; } @@ -773,6 +778,7 @@ public class BuildComposablePipeline { super.preMethodEmissionHook(output); } + @Override protected void constructorHook(PrintWriter output) { output.print(" public " + getOutputName() + "("); output.print(downstreamName + " " + getDownstreamObjectName()); @@ -803,6 +809,7 @@ public class BuildComposablePipeline { } } + @Override protected void emitClassDocComment(PrintWriter output) { output.println("/**"); output.println(" * Composable pipeline {@link " + outputPackage + "." + outputName + "}, implementing the interface"); @@ -837,10 +844,12 @@ public class BuildComposablePipeline { output.println("*/"); } + @Override protected boolean hasPreDownstreamCallHook(Method m) { return null != getMethod(prologClassOpt, m); } + @Override protected void preDownstreamCallHook(PrintWriter output, Method m) { if (null != prologNameOpt) { output.print(getPrologObjectNameOpt()); @@ -852,10 +861,12 @@ public class BuildComposablePipeline { } } + @Override protected boolean hasPostDownstreamCallHook(Method m) { return false; } + @Override protected void postDownstreamCallHook(PrintWriter output, Method m) { } } // end class CustomPipeline @@ -869,18 +880,22 @@ public class BuildComposablePipeline { className = "Debug" + getBaseInterfaceName(); } + @Override protected String getOutputName() { return className; } + @Override protected int getMode() { return 0; } + @Override protected boolean emptyMethodAllowed() { return false; } + @Override protected boolean emptyDownstreamAllowed() { return false; } @@ -890,6 +905,7 @@ public class BuildComposablePipeline { super.preMethodEmissionHook(output); } + @Override protected void constructorHook(PrintWriter output) { output.print(" public " + getOutputName() + "("); output.println(downstreamName + " " + getDownstreamObjectName() + ")"); @@ -971,6 +987,7 @@ public class BuildComposablePipeline { output.println(" private GLContext _context;"); } + @Override protected void emitClassDocComment(PrintWriter output) { output.println("/**"); output.println(" *

                      "); @@ -988,18 +1005,22 @@ public class BuildComposablePipeline { output.println(" */"); } + @Override protected boolean hasPreDownstreamCallHook(Method m) { return true; } + @Override protected void preDownstreamCallHook(PrintWriter output, Method m) { output.println(" checkContext();"); } + @Override protected boolean hasPostDownstreamCallHook(Method m) { return true; } + @Override protected void postDownstreamCallHook(PrintWriter output, Method m) { if (m.getName().equals("glBegin")) { output.println(" insideBeginEndPair = true;"); @@ -1041,18 +1062,22 @@ public class BuildComposablePipeline { className = "Trace" + getBaseInterfaceName(); } + @Override protected String getOutputName() { return className; } + @Override protected int getMode() { return 0; } + @Override protected boolean emptyMethodAllowed() { return false; } + @Override protected boolean emptyDownstreamAllowed() { return false; } @@ -1062,6 +1087,7 @@ public class BuildComposablePipeline { super.preMethodEmissionHook(output); } + @Override protected void constructorHook(PrintWriter output) { output.print(" public " + getOutputName() + "("); output.println(downstreamName + " " + getDownstreamObjectName() + ", PrintStream " + getOutputStreamName() + ")"); @@ -1112,6 +1138,7 @@ public class BuildComposablePipeline { output.println("}"); } + @Override protected void emitClassDocComment(PrintWriter output) { output.println("/**"); output.println(" *

                      "); @@ -1129,10 +1156,12 @@ public class BuildComposablePipeline { output.println(" */"); } + @Override protected boolean hasPreDownstreamCallHook(Method m) { return true; } + @Override protected void preDownstreamCallHook(PrintWriter output, Method m) { if (m.getName().equals("glEnd") || m.getName().equals("glEndList")) { output.println("indent-=2;"); @@ -1146,10 +1175,12 @@ public class BuildComposablePipeline { output.println(");"); } + @Override protected boolean hasPostDownstreamCallHook(Method m) { return true; } + @Override protected void postDownstreamCallHook(PrintWriter output, Method m) { Class ret = m.getReturnType(); if (ret != Void.TYPE) { diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java index 1af632682..547382ed1 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java @@ -134,6 +134,7 @@ public class GLEmitter extends ProcAddressEmitter { private List constants; private List functions; + @Override public void filterSymbols(List constants, List functions) { this.constants = constants; @@ -141,10 +142,12 @@ public class GLEmitter extends ProcAddressEmitter { doWork(); } + @Override public List getConstants() { return constants; } + @Override public List getFunctions() { return functions; } diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java b/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java index b98f17117..21946ea89 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java @@ -186,6 +186,7 @@ public class StaticGLGenTask extends Task * * @see org.apache.tools.ant.Task#execute() */ + @Override public void execute() throws BuildException { diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java index a17657382..6d9d6f2bb 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java @@ -131,6 +131,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } } + @Override protected String getReturnTypeString(boolean skipArray) { if (isForImplementingMethodCall()) { JavaType returnType = getBinding().getJavaReturnType(); @@ -142,6 +143,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding return super.getReturnTypeString(skipArray); } + @Override protected void emitPreCallSetup(MethodBinding binding, PrintWriter writer) { super.emitPreCallSetup(binding, writer); for (int i = 0; i < binding.getNumArguments(); i++) { @@ -162,6 +164,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding return "__buffer_array_" + argNumber; } + @Override protected int emitArguments(PrintWriter writer) { boolean needComma = false; @@ -242,6 +245,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding return numEmitted; } + @Override protected void emitReturnVariableSetupAndCall(MethodBinding binding, PrintWriter writer) { writer.print(" "); JavaType returnType = binding.getJavaReturnType(); @@ -455,6 +459,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding return numArgsEmitted; } + @Override protected void emitCallResultReturn(MethodBinding binding, PrintWriter writer) { for (int i = 0; i < binding.getNumArguments(); i++) { JavaType type = binding.getJavaArgumentType(i); @@ -468,6 +473,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding super.emitCallResultReturn(binding, writer); } + @Override public String getName() { String res = super.getName(); if (forImplementingMethodCall && bufferObjectVariant) { diff --git a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java index f8406075c..3fb315c99 100644 --- a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java +++ b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java @@ -42,6 +42,7 @@ public class GLProcAddressResolver implements FunctionAddressResolver { public static final boolean DEBUG = false; + @Override public long resolve(String name, DynamicLookupHelper lookup) { long newProcAddress = 0; diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java index cb2885e0f..60d5199eb 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java +++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java @@ -554,6 +554,7 @@ public class OutlineShape implements Comparable { * as criteria. * @see java.lang.Comparable#compareTo(java.lang.Object) */ + @Override public final int compareTo(OutlineShape outline) { float size = getBounds().getSize(); float newSize = outline.getBounds().getSize(); @@ -586,6 +587,7 @@ public class OutlineShape implements Comparable { * @return true if {@code obj} is an OutlineShape, not null, * same outlineState, equal bounds and equal outlines in the same order */ + @Override public boolean equals(Object obj) { if( obj == this) { return true; @@ -614,6 +616,7 @@ public class OutlineShape implements Comparable { /** * @return deep clone of this OutlineShape w/o Region */ + @Override public OutlineShape clone() { OutlineShape o; try { diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java index 9c833fd24..6a8fb6a67 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java @@ -105,6 +105,7 @@ public abstract class RenderState { return sb; } + @Override public String toString() { return toString(null, false).toString(); } diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java index 82211da92..a4a8fd53d 100644 --- a/src/jogl/classes/com/jogamp/graph/font/Font.java +++ b/src/jogl/classes/com/jogamp/graph/font/Font.java @@ -109,5 +109,6 @@ public interface Font { public boolean isPrintableChar( char c ); /** Shall return {@link #getFullFamilyName()} */ + @Override public String toString(); } \ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/graph/geom/Outline.java b/src/jogl/classes/com/jogamp/graph/geom/Outline.java index dfa6a8635..77a318078 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Outline.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Outline.java @@ -173,6 +173,7 @@ public class Outline implements Cloneable, Comparable { * as criteria. * @see java.lang.Comparable#compareTo(java.lang.Object) */ + @Override public final int compareTo(Outline outline) { float size = getBounds().getSize(); float newSize = outline.getBounds().getSize(); @@ -204,6 +205,7 @@ public class Outline implements Cloneable, Comparable { * @param obj the Object to compare this Outline with * @return true if {@code obj} is an Outline, not null, equals bounds and equal vertices in the same order */ + @Override public boolean equals(Object obj) { if( obj == this) { return true; @@ -229,6 +231,7 @@ public class Outline implements Cloneable, Comparable { /** * @return deep clone of this Outline */ + @Override public Outline clone() { Outline o; try { diff --git a/src/jogl/classes/com/jogamp/graph/geom/Triangle.java b/src/jogl/classes/com/jogamp/graph/geom/Triangle.java index bd0900495..a01cd834f 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Triangle.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Triangle.java @@ -73,6 +73,7 @@ public class Triangle { this.boundaryVertices = boundaryVertices; } + @Override public String toString() { return "Tri ID: " + id + "\n" + vertices[0] + "\n" + vertices[1] + "\n" + vertices[2]; } diff --git a/src/jogl/classes/com/jogamp/graph/geom/Vertex.java b/src/jogl/classes/com/jogamp/graph/geom/Vertex.java index 40048235e..994253f71 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Vertex.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Vertex.java @@ -76,6 +76,7 @@ public interface Vertex extends Vert3fImmutable, Cloneable { * @param obj the Object to compare this Vertex with * @return true if {@code obj} is a Vertex and not null, on-curve flag is equal and has same vertex- and tex-coords. */ + @Override boolean equals(Object obj); /** diff --git a/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java b/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java index 6b07688a7..b27604a44 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java +++ b/src/jogl/classes/com/jogamp/graph/geom/opengl/SVertex.java @@ -45,14 +45,17 @@ public class SVertex implements Vertex { public static Factory factory() { return factory; } public static class Factory implements Vertex.Factory { + @Override public SVertex create() { return new SVertex(); } + @Override public SVertex create(float x, float y, float z, boolean onCurve) { return new SVertex(x, y, z, onCurve); } + @Override public SVertex create(float[] coordsBuffer, int offset, int length, boolean onCurve) { return new SVertex(coordsBuffer, offset, length, onCurve); } @@ -78,12 +81,14 @@ public class SVertex implements Vertex { setOnCurve(onCurve); } + @Override public final void setCoord(float x, float y, float z) { this.coord[0] = x; this.coord[1] = y; this.coord[2] = z; } + @Override public final void setCoord(float[] coordsBuffer, int offset, int length) { System.arraycopy(coordsBuffer, offset, coord, 0, length); } @@ -98,46 +103,57 @@ public class SVertex implements Vertex { return coord; } + @Override public final void setX(float x) { this.coord[0] = x; } + @Override public final void setY(float y) { this.coord[1] = y; } + @Override public final void setZ(float z) { this.coord[2] = z; } + @Override public final float getX() { return this.coord[0]; } + @Override public final float getY() { return this.coord[1]; } + @Override public final float getZ() { return this.coord[2]; } + @Override public final boolean isOnCurve() { return onCurve; } + @Override public final void setOnCurve(boolean onCurve) { this.onCurve = onCurve; } + @Override public final int getId(){ return id; } + @Override public final void setId(int id){ this.id = id; } + @Override public boolean equals(Object obj) { if( obj == this) { return true; @@ -152,15 +168,18 @@ public class SVertex implements Vertex { VectorUtil.checkEquality(getCoord(), v.getCoord()) ; } + @Override public final float[] getTexCoord() { return texCoord; } + @Override public final void setTexCoord(float s, float t) { this.texCoord[0] = s; this.texCoord[1] = t; } + @Override public final void setTexCoord(float[] texCoordsBuffer, int offset, int length) { System.arraycopy(texCoordsBuffer, offset, texCoord, 0, length); } @@ -168,10 +187,12 @@ public class SVertex implements Vertex { /** * @return deep clone of this Vertex, but keeping the id blank */ + @Override public SVertex clone(){ return new SVertex(this.coord, 0, 3, this.texCoord, 0, 2, this.onCurve); } + @Override public String toString() { return "[ID: " + id + ", onCurve: " + onCurve + ": p " + coord[0] + ", " + coord[1] + ", " + coord[2] + diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java index c78b2b83d..72041a389 100644 --- a/src/jogl/classes/com/jogamp/opengl/FBObject.java +++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java @@ -292,6 +292,7 @@ public class FBObject { int objectHashCode() { return super.hashCode(); } + @Override public String toString() { return getClass().getSimpleName()+"[type "+type+", format "+toHexString(format)+", "+width+"x"+height+ "; name "+toHexString(name)+", obj "+toHexString(objectHashCode())+"]"; @@ -414,6 +415,7 @@ public class FBObject { } } + @Override public String toString() { return getClass().getSimpleName()+"[type "+type+", format "+toHexString(format)+", samples "+samples+", "+getWidth()+"x"+getHeight()+ ", name "+toHexString(getName())+", obj "+toHexString(objectHashCode())+"]"; @@ -527,6 +529,7 @@ public class FBObject { setName(0); } } + @Override public String toString() { return getClass().getSimpleName()+"[type "+type+", target GL_TEXTURE_2D, level 0, format "+toHexString(format)+ ", "+getWidth()+"x"+getHeight()+", border 0, dataFormat "+toHexString(dataFormat)+ @@ -2306,6 +2309,7 @@ public class FBObject { int objectHashCode() { return super.hashCode(); } + @Override public final String toString() { final String caps = null != colorAttachmentPoints ? Arrays.asList(colorAttachmentPoints).toString() : null ; return "FBO[name r/w "+fbName+"/"+getReadFramebuffer()+", init "+initialized+", bound "+bound+", size "+width+"x"+height+ diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index ee77f8d2d..9c9129ae6 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -262,6 +262,7 @@ public class GLRendererQuirks { return sb; } + @Override public final String toString() { return toString(null).toString(); } diff --git a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java index 8d2d07d58..4270607f2 100644 --- a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java @@ -43,6 +43,7 @@ public final class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInf private static final List glueLibNames; static { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { Platform.initSingleton(); diff --git a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java index f1880a61b..d48677da5 100644 --- a/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java +++ b/src/jogl/classes/com/jogamp/opengl/math/geom/AABBox.java @@ -333,10 +333,12 @@ public class AABBox implements Cloneable { return high[2] - low[2]; } + @Override public final AABBox clone() { return new AABBox(this.low, this.high); } + @Override public final boolean equals(Object obj) { if( obj == this ) { return true; @@ -349,6 +351,7 @@ public class AABBox implements Cloneable { VectorUtil.checkEquality(high, other.high) ; } + @Override public final String toString() { return "[ "+low[0]+"/"+low[1]+"/"+low[1]+" .. "+high[0]+"/"+high[0]+"/"+high[0]+", ctr "+ center[0]+"/"+center[1]+"/"+center[1]+" ]"; diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 33941a407..1a3e1e0c0 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -286,6 +286,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { final GLCapabilitiesChooser chooser, final GLContext shareWith) { final GLCanvas[] res = new GLCanvas[] { null }; parent.getDisplay().syncExec(new Runnable() { + @Override public void run() { res[0] = new GLCanvas( parent, style, caps, chooser, shareWith ); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java index 80289acf3..d0de3b3a0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AWTAnimatorImpl.java @@ -58,6 +58,7 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { private Map repaintManagers = new IdentityHashMap(); private Map dirtyRegions = new IdentityHashMap(); + @Override public void display(ArrayList drawables, boolean ignoreExceptions, boolean printExceptions) { @@ -97,6 +98,7 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { // Uses RepaintManager APIs to implement more efficient redrawing of // the Swing widgets we're animating private Runnable drawWithRepaintManagerRunnable = new Runnable() { + @Override public void run() { for (Iterator iter = lightweights.iterator(); iter.hasNext(); ) { JComponent comp = iter.next(); @@ -164,6 +166,7 @@ class AWTAnimatorImpl implements AnimatorBase.AnimatorImpl { } }; + @Override public boolean blockUntilDone(Thread thread) { return Thread.currentThread() != thread && !EventQueue.isDispatchThread(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index cdfb73b21..27b9427eb 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -109,6 +109,7 @@ public class Animator extends AnimatorBase { } } + @Override protected String getBaseName(String prefix) { return prefix + "Animator" ; } @@ -138,10 +139,12 @@ public class Animator extends AnimatorBase { } class MainLoop implements Runnable { + @Override public String toString() { return "[started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]"; } + @Override public void run() { try { if(DEBUG) { @@ -228,6 +231,7 @@ public class Animator extends AnimatorBase { private final boolean isAnimatingImpl() { return animThread != null && isAnimating ; } + @Override public final boolean isAnimating() { stateSync.lock(); try { @@ -240,6 +244,7 @@ public class Animator extends AnimatorBase { private final boolean isPausedImpl() { return animThread != null && pauseIssued ; } + @Override public final boolean isPaused() { stateSync.lock(); try { @@ -262,6 +267,7 @@ public class Animator extends AnimatorBase { threadGroup = tg; } + @Override public synchronized boolean start() { if ( isStartedImpl() ) { return false; @@ -286,10 +292,12 @@ public class Animator extends AnimatorBase { return finishLifecycleAction(waitForStartedCondition, 0); } private final Condition waitForStartedCondition = new Condition() { + @Override public boolean eval() { return !isStartedImpl() || (!drawablesEmpty && !isAnimating) ; } }; + @Override public synchronized boolean stop() { if ( !isStartedImpl() ) { return false; @@ -298,10 +306,12 @@ public class Animator extends AnimatorBase { return finishLifecycleAction(waitForStoppedCondition, 0); } private final Condition waitForStoppedCondition = new Condition() { + @Override public boolean eval() { return isStartedImpl(); } }; + @Override public synchronized boolean pause() { if ( !isStartedImpl() || pauseIssued ) { return false; @@ -310,11 +320,13 @@ public class Animator extends AnimatorBase { return finishLifecycleAction(waitForPausedCondition, 0); } private final Condition waitForPausedCondition = new Condition() { + @Override public boolean eval() { // end waiting if stopped as well return isStartedImpl() && isAnimating; } }; + @Override public synchronized boolean resume() { if ( !isStartedImpl() || !pauseIssued ) { return false; @@ -323,6 +335,7 @@ public class Animator extends AnimatorBase { return finishLifecycleAction(waitForResumeCondition, 0); } private final Condition waitForResumeCondition = new Condition() { + @Override public boolean eval() { // end waiting if stopped as well return isStartedImpl() && ( !drawablesEmpty && !isAnimating || drawablesEmpty && !pauseIssued ) ; diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index b447a339b..f6ee3376f 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -194,6 +194,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { resume(); } final Condition waitForAnimatingAndECTCondition = new Condition() { + @Override public boolean eval() { final Thread dect = drawable.getExclusiveContextThread(); return isStarted() && !isPaused() && !isAnimating() && ( exclusiveContext && null == dect || !exclusiveContext && null != dect ); @@ -217,6 +218,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { if( exclusiveContext && isAnimating() ) { drawable.setExclusiveContextThread( null ); final Condition waitForNullECTCondition = new Condition() { + @Override public boolean eval() { return null != drawable.getExclusiveContextThread(); } }; @@ -240,6 +242,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { notifyAll(); } private final Condition waitForNotAnimatingIfEmptyCondition = new Condition() { + @Override public boolean eval() { return isStarted() && drawablesEmpty && isAnimating(); } }; @@ -577,6 +580,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { protected static String getThreadName() { return Thread.currentThread().getName(); } + @Override public String toString() { return getClass().getName()+"[started "+isStarted()+", animating "+isAnimating()+", paused "+isPaused()+", drawable "+drawables.size()+ ", totals[dt "+getTotalFPSDuration()+", frames "+getTotalFPSFrames()+", fps "+getTotalFPS()+ diff --git a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java index 0477e1903..a9c6e6456 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/util/DefaultAnimatorImpl.java @@ -41,6 +41,7 @@ import javax.media.opengl.GLAutoDrawable; up this behavior if desired. */ class DefaultAnimatorImpl implements AnimatorBase.AnimatorImpl { + @Override public void display(ArrayList drawables, boolean ignoreExceptions, boolean printExceptions) { @@ -60,6 +61,7 @@ class DefaultAnimatorImpl implements AnimatorBase.AnimatorImpl { } } + @Override public boolean blockUntilDone(Thread thread) { return Thread.currentThread() != thread; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java index b48169c27..351c47e7e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java @@ -64,6 +64,7 @@ public class FPSAnimator extends AnimatorBase { private volatile boolean shouldRun; // MainTask trigger private volatile boolean shouldStop; // MainTask trigger + @Override protected String getBaseName(String prefix) { return "FPS" + prefix + "Animator" ; } @@ -140,10 +141,12 @@ public class FPSAnimator extends AnimatorBase { public boolean isActive() { return !alreadyStopped && !alreadyPaused; } + @Override public String toString() { return "Task[thread "+animThread+", stopped "+alreadyStopped+", paused "+alreadyPaused+" shouldRun "+shouldRun+", shouldStop "+shouldStop+" -- started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]"; } + @Override public void run() { if( justStarted ) { justStarted = false; @@ -208,6 +211,7 @@ public class FPSAnimator extends AnimatorBase { private final boolean isAnimatingImpl() { return animThread != null && isAnimating ; } + @Override public final boolean isAnimating() { stateSync.lock(); try { @@ -220,6 +224,7 @@ public class FPSAnimator extends AnimatorBase { private final boolean isPausedImpl() { return animThread != null && ( !shouldRun && !shouldStop ) ; } + @Override public final boolean isPaused() { stateSync.lock(); try { @@ -231,6 +236,7 @@ public class FPSAnimator extends AnimatorBase { static int timerNo = 0; + @Override public synchronized boolean start() { if ( null != timer || null != task || isStartedImpl() ) { return false; @@ -254,10 +260,12 @@ public class FPSAnimator extends AnimatorBase { return res; } private final Condition waitForStartedAddedCondition = new Condition() { + @Override public boolean eval() { return !isStartedImpl() || !isAnimating ; } }; private final Condition waitForStartedEmptyCondition = new Condition() { + @Override public boolean eval() { return !isStartedImpl() || isAnimating ; } }; @@ -265,6 +273,7 @@ public class FPSAnimator extends AnimatorBase { /** Stops this FPSAnimator. Due to the implementation of the FPSAnimator it is not guaranteed that the FPSAnimator will be completely stopped by the time this method returns. */ + @Override public synchronized boolean stop() { if ( null == timer || !isStartedImpl() ) { return false; @@ -297,10 +306,12 @@ public class FPSAnimator extends AnimatorBase { return res; } private final Condition waitForStoppedCondition = new Condition() { + @Override public boolean eval() { return isStartedImpl(); } }; + @Override public synchronized boolean pause() { if ( !isStartedImpl() || ( null != task && isPausedImpl() ) ) { return false; @@ -327,11 +338,13 @@ public class FPSAnimator extends AnimatorBase { return res; } private final Condition waitForPausedCondition = new Condition() { + @Override public boolean eval() { // end waiting if stopped as well return isAnimating && isStartedImpl(); } }; + @Override public synchronized boolean resume() { if ( null != task || !isStartedImpl() || !isPausedImpl() ) { return false; @@ -353,6 +366,7 @@ public class FPSAnimator extends AnimatorBase { return res; } private final Condition waitForResumeCondition = new Condition() { + @Override public boolean eval() { // end waiting if stopped as well return !drawablesEmpty && !isAnimating && isStartedImpl(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java index 2d685a1a8..f480c4bde 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java @@ -321,6 +321,7 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData Buffers.putf(buffer, v); } + @Override public String toString() { return "GLArrayDataClient["+name+ ", index "+index+ diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java index 701f88e59..9a0f1cb37 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataEditable.java @@ -31,6 +31,7 @@ public interface GLArrayDataEditable extends GLArrayData { // Data and GL state modification .. // + @Override public void destroy(GL gl); public void reset(GL gl); diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java index 80639c5c7..e30fea2f4 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java @@ -327,6 +327,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE // Data and GL state modification .. // + @Override public void destroy(GL gl) { // super.destroy(gl): // - GLArrayDataClient.destroy(gl): disables & clears client-side buffer @@ -349,11 +350,13 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE * switch to client side data one * Only possible if buffer is defined. */ + @Override public void setVBOEnabled(boolean vboUsage) { checkSeal(false); super.setVBOEnabled(vboUsage); } + @Override public String toString() { return "GLArrayDataServer["+name+ ", index "+index+ @@ -384,6 +387,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE // non public matters .. // + @Override protected void init(String name, int index, int comps, int dataType, boolean normalized, int stride, Buffer data, int initialElementCount, boolean isVertexAttribute, GLArrayHandler glArrayHandler, @@ -396,6 +400,7 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE vboEnabled=true; } + @Override protected void init_vbo(GL gl) { super.init_vbo(gl); if(vboEnabled && vboName==0) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java index f0c6be44f..50124c349 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java @@ -216,6 +216,7 @@ public class GLPixelBuffer { } } } + @Override public String toString() { return "PixelAttributes[comp "+componentCount+", fmt 0x"+Integer.toHexString(format)+", type 0x"+Integer.toHexString(type)+", bytesPerPixel "+bytesPerPixel+"]"; } @@ -258,6 +259,7 @@ public class GLPixelBuffer { .append(", buffer[bytes ").append(byteSize).append(", elemSize ").append(bufferElemSize).append(", ").append(buffer).append("]"); return sb; } + @Override public String toString() { return "GLPixelBuffer["+toString(null).toString()+"]"; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java index 697b7cca0..986f6d8d3 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java @@ -173,6 +173,7 @@ public class ImmModeSink { vboSet.reset(gl); } + @Override public String toString() { StringBuilder sb = new StringBuilder("ImmModeSink["); sb.append(",\n\tVBO list: "+vboSetList.size()+" ["); @@ -1236,6 +1237,7 @@ public class ImmModeSink { } } + @Override public String toString() { final String glslS = useGLSL ? ", useShaderState "+(null!=shaderState)+ diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index b4a0156e9..218897ffe 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -897,6 +897,7 @@ public class PMVMatrix implements GLMatrixFunc { return sb; } + @Override public String toString() { return toString(null, "%10.5f").toString(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index ff7cc5516..2ac4b1f82 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -244,6 +244,7 @@ public abstract class TileRendererBase { sb.append(", isSetup "+isSetup()); return sb; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); return getClass().getSimpleName()+ diff --git a/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java b/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java index 45f5d2694..b29846d91 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TimeFrameI.java @@ -74,6 +74,7 @@ public class TimeFrameI { /** Set this frame's duration in milliseconds. */ public final void setDuration(int duration) { this.duration = duration; } + @Override public String toString() { return "TimeFrame[pts " + pts + " ms, l " + duration + " ms]"; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java index dffdfae8e..b964245ad 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java @@ -193,6 +193,7 @@ public interface AudioSink { return ( byteCount << 3 ) / sampleSize; } + @Override public String toString() { return "AudioDataFormat[sampleRate "+sampleRate+", sampleSize "+sampleSize+", channelCount "+channelCount+ ", signed "+signed+", fixedP "+fixedP+", "+(planar?"planar":"packed")+", "+(littleEndian?"little":"big")+"-endian]"; } @@ -217,6 +218,7 @@ public interface AudioSink { /** Set this frame's size in bytes. */ public final void setByteSize(int size) { this.byteSize=size; } + @Override public String toString() { return "AudioFrame[pts " + pts + " ms, l " + duration + " ms, "+byteSize + " bytes]"; } @@ -235,6 +237,7 @@ public interface AudioSink { /** Get this frame's data. */ public final ByteBuffer getData() { return data; } + @Override public String toString() { return "AudioDataFrame[pts " + pts + " ms, l " + duration + " ms, "+byteSize + " bytes, " + data + "]"; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index db6f5fdee..3f6b78d7e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -609,6 +609,7 @@ public interface GLMediaPlayer extends TextureSequence { public int getHeight(); /** Returns a string represantation of this player, incl. state and audio/video details. */ + @Override public String toString(); /** Returns a string represantation of this player's performance values. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java index fb2bdbbcb..77b14b424 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java @@ -117,11 +117,13 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { return new BufferedImage (cm, raster1, cm.isAlphaPremultiplied(), null); } + @Override public StringBuilder toString(StringBuilder sb) { sb = super.toString(sb); sb.append(", allowRowStride ").append(allowRowStride).append(", image [").append(image.getWidth()).append("x").append(image.getHeight()).append(", ").append(image.toString()).append("]"); return sb; } + @Override public String toString() { return "AWTGLPixelBuffer["+toString(null).toString()+"]"; } @@ -213,6 +215,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { } /** Return the last {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated} {@link AWTGLPixelBuffer} w/ {@link GLPixelAttributes#componentCount}. */ + @Override public AWTGLPixelBuffer getSingleBuffer(GLPixelAttributes pixelAttributes) { return 4 == pixelAttributes.componentCount ? singleRGBA4 : singleRGB3; } @@ -221,6 +224,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { * Initializes the single {@link AWTGLPixelBuffer} w/ a given size, if not yet {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated}. * @return the newly initialized single {@link AWTGLPixelBuffer}, or null if already allocated. */ + @Override public AWTGLPixelBuffer initSingleton(int componentCount, int width, int height, int depth, boolean pack) { if( 4 == componentCount ) { if( null != singleRGBA4 ) { diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java index 6e504c089..73d06cae0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java @@ -755,6 +755,7 @@ public class TextRenderer { // Iterate through the contents of the backing store, removing // text strings that haven't been used recently packer.visit(new RectVisitor() { + @Override public void visit(Rect rect) { TextData data = (TextData) rect.getUserData(); @@ -914,11 +915,13 @@ public class TextRenderer { final FPSAnimator anim = new FPSAnimator(dbgCanvas, 10); dbgFrame.addWindowListener(new WindowAdapter() { + @Override public void windowClosing(WindowEvent e) { // Run this on another thread than the AWT event queue to // make sure the call to Animator.stop() completes before // exiting new Thread(new Runnable() { + @Override public void run() { anim.stop(); } @@ -1009,12 +1012,14 @@ public class TextRenderer { mCurrentIndex = 0; } + @Override public char last() { mCurrentIndex = Math.max(0, mLength - 1); return current(); } + @Override public char current() { if ((mLength == 0) || (mCurrentIndex >= mLength)) { return CharacterIterator.DONE; @@ -1023,36 +1028,43 @@ public class TextRenderer { return mSequence.charAt(mCurrentIndex); } + @Override public char next() { mCurrentIndex++; return current(); } + @Override public char previous() { mCurrentIndex = Math.max(mCurrentIndex - 1, 0); return current(); } + @Override public char setIndex(int position) { mCurrentIndex = position; return current(); } + @Override public int getBeginIndex() { return 0; } + @Override public int getEndIndex() { return mLength; } + @Override public int getIndex() { return mCurrentIndex; } + @Override public Object clone() { CharSequenceIterator iter = new CharSequenceIterator(mSequence); iter.mCurrentIndex = mCurrentIndex; @@ -1060,6 +1072,7 @@ public class TextRenderer { return iter; } + @Override public char first() { if (mLength == 0) { return CharacterIterator.DONE; @@ -1143,6 +1156,7 @@ public class TextRenderer { class Manager implements BackingStoreManager { private Graphics2D g; + @Override public Object allocateBackingStore(int w, int h) { // FIXME: should consider checking Font's attributes to see // whether we're likely to need to support a full RGBA backing @@ -1165,10 +1179,12 @@ public class TextRenderer { return renderer; } + @Override public void deleteBackingStore(Object backingStore) { ((TextureRenderer) backingStore).dispose(); } + @Override public boolean preExpand(Rect cause, int attemptNumber) { // Only try this one time; clear out potentially obsolete entries // NOTE: this heuristic and the fact that it clears the used bit @@ -1204,6 +1220,7 @@ public class TextRenderer { return false; } + @Override public boolean additionFailed(Rect cause, int attemptNumber) { // Heavy hammer -- might consider doing something different packer.clear(); @@ -1222,10 +1239,12 @@ public class TextRenderer { return false; } + @Override public boolean canCompact() { return true; } + @Override public void beginMovement(Object oldBackingStore, Object newBackingStore) { // Exit the begin / end pair if necessary if (inBeginEndPair) { @@ -1259,6 +1278,7 @@ public class TextRenderer { g = newRenderer.createGraphics(); } + @Override public void move(Object oldBackingStore, Rect oldLocation, Object newBackingStore, Rect newLocation) { TextureRenderer oldRenderer = (TextureRenderer) oldBackingStore; @@ -1280,6 +1300,7 @@ public class TextRenderer { } } + @Override public void endMovement(Object oldBackingStore, Object newBackingStore) { g.dispose(); @@ -1316,10 +1337,12 @@ public class TextRenderer { } public static class DefaultRenderDelegate implements RenderDelegate { + @Override public boolean intensityOnly() { return true; } + @Override public Rectangle2D getBounds(CharSequence str, Font font, FontRenderContext frc) { return getBounds(font.createGlyphVector(frc, @@ -1327,20 +1350,24 @@ public class TextRenderer { frc); } + @Override public Rectangle2D getBounds(String str, Font font, FontRenderContext frc) { return getBounds(font.createGlyphVector(frc, str), frc); } + @Override public Rectangle2D getBounds(GlyphVector gv, FontRenderContext frc) { return gv.getVisualBounds(); } + @Override public void drawGlyphVector(Graphics2D graphics, GlyphVector str, int x, int y) { graphics.drawGlyphVector(str, x, y); } + @Override public void draw(Graphics2D graphics, String str, int x, int y) { graphics.drawString(str, x, y); } @@ -1896,6 +1923,7 @@ public class TextRenderer { this.frame = frame; } + @Override public void display(GLAutoDrawable drawable) { GL2 gl = GLContext.getCurrentGL().getGL2(); gl.glClear(GL2.GL_DEPTH_BUFFER_BIT | GL2.GL_COLOR_BUFFER_BIT); @@ -1913,6 +1941,7 @@ public class TextRenderer { if ((frame.getWidth() != w) || (frame.getHeight() != h)) { EventQueue.invokeLater(new Runnable() { + @Override public void run() { frame.setSize(w, h); } @@ -1920,6 +1949,7 @@ public class TextRenderer { } } + @Override public void dispose(GLAutoDrawable drawable) { glu.destroy(); glu=null; @@ -1927,9 +1957,11 @@ public class TextRenderer { } // Unused methods + @Override public void init(GLAutoDrawable drawable) { } + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index 68c1d0fec..6f16cc4fe 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -514,6 +514,7 @@ public class ShaderCode { id=-1; } + @Override public boolean equals(Object obj) { if(this==obj) { return true; } if(obj instanceof ShaderCode) { @@ -521,9 +522,11 @@ public class ShaderCode { } return false; } + @Override public int hashCode() { return id; } + @Override public String toString() { StringBuilder buf = new StringBuilder("ShaderCode[id="+id+", type="+shaderTypeStr()+", valid="+valid+", shader: "); for(int i=0; i= other.h()); } + @Override public String toString() { return "[Rect x: " + x() + " y: " + y() + " w: " + w() + " h: " + h() + "]"; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java index a9d609745..2ee6a79b3 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java @@ -61,12 +61,14 @@ public class RectanglePacker { private int maxHeight = -1; static class RectHComparator implements Comparator { + @Override public int compare(Object o1, Object o2) { Rect r1 = (Rect) o1; Rect r2 = (Rect) o2; return r2.h() - r1.h(); } + @Override public boolean equals(Object obj) { return this == obj; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java index fd026d76e..584cacf8c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java @@ -188,6 +188,7 @@ public class Texture { /** The texture coordinates corresponding to the entire image. */ private TextureCoords coords; + @Override public String toString() { return "Texture[target 0x"+Integer.toHexString(target)+", name "+texID+", "+ imgWidth+"/"+texWidth+" x "+imgHeight+"/"+texHeight+", y-flip "+mustFlipVertically+ diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java index 63f100630..ba59f89c5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureCoords.java @@ -94,5 +94,6 @@ public class TextureCoords { rectangle. */ public float top() { return top; } + @Override public String toString() { return "TexCoord[h: "+left+" - "+right+", v: "+bottom+" - "+top+"]"; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java index 28029efc5..5d88a76c0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java @@ -499,6 +499,7 @@ public class TextureData { public void flush(); } + @Override public String toString() { return "TextureData["+width+"x"+height+", y-flip "+mustFlipVertically+", internFormat 0x"+Integer.toHexString(internalFormat)+", "+ pixelAttributes+", border "+border+", estSize "+estimatedMemorySize+", alignment "+alignment+", rowlen "+rowLength; diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java index b6d89d6d2..67ab5176d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java @@ -914,6 +914,7 @@ public class TextureIO { //---------------------------------------------------------------------- // DDS provider -- supports files only for now static class DDSTextureProvider implements TextureProvider { + @Override public TextureData newTextureData(GLProfile glp, File file, int internalFormat, int pixelFormat, @@ -928,6 +929,7 @@ public class TextureIO { return null; } + @Override public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, @@ -944,6 +946,7 @@ public class TextureIO { return null; } + @Override public TextureData newTextureData(GLProfile glp, URL url, int internalFormat, int pixelFormat, @@ -999,6 +1002,7 @@ public class TextureIO { } } TextureData.Flusher flusher = new TextureData.Flusher() { + @Override public void flush() { image.close(); } @@ -1042,6 +1046,7 @@ public class TextureIO { //---------------------------------------------------------------------- // Base class for SGI RGB and TGA image providers static abstract class StreamBasedTextureProvider implements TextureProvider { + @Override public TextureData newTextureData(GLProfile glp, File file, int internalFormat, int pixelFormat, @@ -1062,6 +1067,7 @@ public class TextureIO { } } + @Override public TextureData newTextureData(GLProfile glp, URL url, int internalFormat, int pixelFormat, @@ -1079,6 +1085,7 @@ public class TextureIO { //---------------------------------------------------------------------- // SGI RGB image provider static class SGITextureProvider extends StreamBasedTextureProvider { + @Override public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, @@ -1114,6 +1121,7 @@ public class TextureIO { //---------------------------------------------------------------------- // TGA (Targa) image provider static class TGATextureProvider extends StreamBasedTextureProvider { + @Override public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, @@ -1151,6 +1159,7 @@ public class TextureIO { //---------------------------------------------------------------------- // PNG image provider static class PNGTextureProvider extends StreamBasedTextureProvider { + @Override public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, @@ -1188,6 +1197,7 @@ public class TextureIO { //---------------------------------------------------------------------- // JPEG image provider static class JPGTextureProvider extends StreamBasedTextureProvider { + @Override public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, @@ -1226,6 +1236,7 @@ public class TextureIO { // DDS texture writer // static class DDSTextureWriter implements TextureWriter { + @Override public boolean write(File file, TextureData data) throws IOException { if (DDS.equals(IOUtil.getFileSuffix(file))) { @@ -1276,6 +1287,7 @@ public class TextureIO { // SGI (rgb) texture writer // static class SGITextureWriter implements TextureWriter { + @Override public boolean write(File file, TextureData data) throws IOException { String fileSuffix = IOUtil.getFileSuffix(file); @@ -1321,6 +1333,7 @@ public class TextureIO { // TGA (Targa) texture writer static class TGATextureWriter implements TextureWriter { + @Override public boolean write(File file, TextureData data) throws IOException { if (TGA.equals(IOUtil.getFileSuffix(file))) { @@ -1371,6 +1384,7 @@ public class TextureIO { // PNG texture writer static class PNGTextureWriter implements TextureWriter { + @Override public boolean write(File file, TextureData data) throws IOException { if (PNG.equals(IOUtil.getFileSuffix(file))) { // See whether the PNG writer can handle this TextureData diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index e4f72abf0..c34e019c2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -124,6 +124,7 @@ public interface TextureSequence { public final Texture getTexture() { return texture; } + @Override public String toString() { return "TextureFrame[pts " + pts + " ms, l " + duration + " ms, texID "+ (null != texture ? texture.getTextureObject() : 0) + "]"; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java index c8437d07c..d8320c690 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java @@ -158,6 +158,7 @@ public class TextureState { public final int getWrapT() { return state[5]; } + @Override public final String toString() { return "TextureState[unit "+(state[0] - GL.GL_TEXTURE0)+", target "+toHexString(target)+ ": obj "+toHexString(state[1])+ diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java index 471938754..2081788ba 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java @@ -112,6 +112,7 @@ public class JPEGImage { data.put(i++, Cr); } + @Override public String toString() { return "JPEGPixels["+width+"x"+height+", sourceComp "+sourceComponents+", sourceCS "+sourceCS+", storageCS "+storageCS+", storageComp "+storageComponents+"]"; } @@ -171,5 +172,6 @@ public class JPEGImage { (bottom-to-top) order for calls to glTexImage2D. */ public ByteBuffer getData() { return data; } + @Override public String toString() { return "JPEGImage["+pixelWidth+"x"+pixelHeight+", bytesPerPixel "+bytesPerPixel+", reversedChannels "+reversedChannels+", "+pixelStorage+", "+data+"]"; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java index 4020ab3c0..3c90d96e4 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataInputStream.java @@ -82,38 +82,45 @@ public class LEDataInputStream extends FilterInputStream implements DataInput dataIn = new DataInputStream(in); } + @Override public void close() throws IOException { dataIn.close(); // better close as we create it. // this will close underlying as well. } + @Override public synchronized final int read(byte b[]) throws IOException { return dataIn.read(b, 0, b.length); } + @Override public synchronized final int read(byte b[], int off, int len) throws IOException { int rl = dataIn.read(b, off, len); return rl; } + @Override public final void readFully(byte b[]) throws IOException { dataIn.readFully(b, 0, b.length); } + @Override public final void readFully(byte b[], int off, int len) throws IOException { dataIn.readFully(b, off, len); } + @Override public final int skipBytes(int n) throws IOException { return dataIn.skipBytes(n); } + @Override public final boolean readBoolean() throws IOException { int ch = dataIn.read(); @@ -122,6 +129,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput return (ch != 0); } + @Override public final byte readByte() throws IOException { int ch = dataIn.read(); @@ -130,6 +138,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput return (byte)(ch); } + @Override public final int readUnsignedByte() throws IOException { int ch = dataIn.read(); @@ -138,6 +147,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput return ch; } + @Override public final short readShort() throws IOException { int ch1 = dataIn.read(); @@ -147,6 +157,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput return (short)((ch1 << 0) + (ch2 << 8)); } + @Override public final int readUnsignedShort() throws IOException { int ch1 = dataIn.read(); @@ -156,6 +167,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput return (ch1 << 0) + (ch2 << 8); } + @Override public final char readChar() throws IOException { int ch1 = dataIn.read(); @@ -165,6 +177,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput return (char)((ch1 << 0) + (ch2 << 8)); } + @Override public final int readInt() throws IOException { int ch1 = dataIn.read(); @@ -176,6 +189,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput return ((ch1 << 0) + (ch2 << 8) + (ch3 << 16) + (ch4 << 24)); } + @Override public final long readLong() throws IOException { int i1 = readInt(); @@ -183,11 +197,13 @@ public class LEDataInputStream extends FilterInputStream implements DataInput return ((long)i1 & 0xFFFFFFFFL) + ((long)i2 << 32); } + @Override public final float readFloat() throws IOException { return Float.intBitsToFloat(readInt()); } + @Override public final double readDouble() throws IOException { return Double.longBitsToDouble(readLong()); @@ -197,6 +213,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput * dont call this it is not implemented. * @return empty new string **/ + @Override public final String readLine() throws IOException { return new String(); @@ -206,6 +223,7 @@ public class LEDataInputStream extends FilterInputStream implements DataInput * dont call this it is not implemented * @return empty new string **/ + @Override public final String readUTF() throws IOException { return new String(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java index a7101a576..93b097500 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/LEDataOutputStream.java @@ -78,43 +78,51 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput dataOut = new DataOutputStream(out); } + @Override public void close() throws IOException { dataOut.close(); // better close as we create it. // this will close underlying as well. } + @Override public synchronized final void write(byte b[]) throws IOException { dataOut.write(b, 0, b.length); } + @Override public synchronized final void write(byte b[], int off, int len) throws IOException { dataOut.write(b, off, len); } + @Override public final void write(int b) throws IOException { dataOut.write(b); } + @Override public final void writeBoolean(boolean v) throws IOException { dataOut.writeBoolean(v); } + @Override public final void writeByte(int v) throws IOException { dataOut.writeByte(v); } /** Don't call this -- not implemented */ + @Override public final void writeBytes(String s) throws IOException { throw new UnsupportedOperationException(); } + @Override public final void writeChar(int v) throws IOException { dataOut.writeChar(((v >> 8) & 0xff) | @@ -122,21 +130,25 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput } /** Don't call this -- not implemented */ + @Override public final void writeChars(String s) throws IOException { throw new UnsupportedOperationException(); } + @Override public final void writeDouble(double v) throws IOException { writeLong(Double.doubleToRawLongBits(v)); } + @Override public final void writeFloat(float v) throws IOException { writeInt(Float.floatToRawIntBits(v)); } + @Override public final void writeInt(int v) throws IOException { dataOut.writeInt((v >>> 24) | @@ -145,12 +157,14 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput (v << 24)); } + @Override public final void writeLong(long v) throws IOException { writeInt((int) v); writeInt((int) (v >>> 32)); } + @Override public final void writeShort(int v) throws IOException { dataOut.writeShort(((v >> 8) & 0xff) | @@ -158,6 +172,7 @@ public class LEDataOutputStream extends FilterOutputStream implements DataOutput } /** Don't call this -- not implemented */ + @Override public final void writeUTF(String s) throws IOException { throw new UnsupportedOperationException(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java index 43b8eebe6..cabf4ebc5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/NetPbmTextureWriter.java @@ -84,6 +84,7 @@ public class NetPbmTextureWriter implements TextureWriter { public String getSuffix() { return (magic==6)?PPM:PAM; } + @Override public boolean write(File file, TextureData data) throws IOException { boolean res; final int magic_old = magic; diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java index bfde1bfac..71cbbf97e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java @@ -314,5 +314,6 @@ public class PNGImage { } } + @Override public String toString() { return "PNGImage["+pixelWidth+"x"+pixelHeight+", dpi "+dpi[0]+" x "+dpi[1]+", bytesPerPixel "+bytesPerPixel+", reversedChannels "+reversedChannels+", "+data+"]"; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java index fd96fba80..cbc8e652f 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/SGIImage.java @@ -126,6 +126,7 @@ public class SGIImage { in.read(tmp); } + @Override public String toString() { return ("magic: " + magic + " storage: " + (int) storage + @@ -226,6 +227,7 @@ public class SGIImage { (bottom-to-top) order for calls to glTexImage2D. */ public byte[] getData() { return data; } + @Override public String toString() { return header.toString(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java index df9430a26..15cd63eb3 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java @@ -199,6 +199,7 @@ public class TGAImage { public byte[] imageIDbuf() { return imageIDbuf; } public String imageID() { return imageID; } + @Override public String toString() { return "TGA Header " + " id length: " + idLength + diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java index f23cb74bf..18ad429d2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureProvider.java @@ -54,6 +54,7 @@ import com.jogamp.opengl.util.texture.spi.*; public class IIOTextureProvider implements TextureProvider { private static final boolean DEBUG = Debug.debug("TextureIO"); + @Override public TextureData newTextureData(GLProfile glp, File file, int internalFormat, int pixelFormat, @@ -70,6 +71,7 @@ public class IIOTextureProvider implements TextureProvider { return new AWTTextureData(glp, internalFormat, pixelFormat, mipmap, img); } + @Override public TextureData newTextureData(GLProfile glp, InputStream stream, int internalFormat, int pixelFormat, @@ -86,6 +88,7 @@ public class IIOTextureProvider implements TextureProvider { return new AWTTextureData(glp, internalFormat, pixelFormat, mipmap, img); } + @Override public TextureData newTextureData(GLProfile glp, URL url, int internalFormat, int pixelFormat, diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java index 438ab6cc2..be82e4fb8 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/awt/IIOTextureWriter.java @@ -53,6 +53,7 @@ import com.jogamp.opengl.util.texture.*; import com.jogamp.opengl.util.texture.spi.*; public class IIOTextureWriter implements TextureWriter { + @Override public boolean write(File file, TextureData data) throws IOException { int pixelFormat = data.getPixelFormat(); diff --git a/src/jogl/classes/javax/media/opengl/GLArrayData.java b/src/jogl/classes/javax/media/opengl/GLArrayData.java index 4025170cf..97f58a92a 100644 --- a/src/jogl/classes/javax/media/opengl/GLArrayData.java +++ b/src/jogl/classes/javax/media/opengl/GLArrayData.java @@ -201,6 +201,7 @@ public interface GLArrayData { */ public int getStride(); + @Override public String toString(); public void destroy(GL gl); diff --git a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java index 1032cf929..acb33b058 100644 --- a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java +++ b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java @@ -202,6 +202,7 @@ public class GLDebugMessage { return sb; } + @Override public String toString() { return toString(null).toString(); } diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index e486e2bfd..26bafd961 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -134,6 +134,7 @@ public abstract class GLDrawableFactory { private static final void initSingletonImpl() { NativeWindowFactory.initSingleton(); NativeWindowFactory.addCustomShutdownHook(false /* head */, new Runnable() { + @Override public void run() { shutdown0(); } diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 15300e397..35dcce0f7 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -121,11 +121,13 @@ public class GLProfile { // run the whole static initialization privileged to speed up, // since this skips checking further access AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { Platform.initSingleton(); // Performance hack to trigger classloading of the GL classes impl, which makes up to 12%, 800ms down to 700ms new Thread(new Runnable() { + @Override public void run() { final ClassLoader cl = GLProfile.class.getClassLoader(); try { @@ -1020,6 +1022,7 @@ public class GLProfile { * @return true if given Object is a GLProfile and * if both, profile and profileImpl is equal with this. */ + @Override public final boolean equals(Object o) { if(this==o) { return true; } if(o instanceof GLProfile) { @@ -1029,6 +1032,7 @@ public class GLProfile { return false; } + @Override public int hashCode() { int hash = 5; hash = 97 * hash + getImplName().hashCode(); @@ -1469,6 +1473,7 @@ public class GLProfile { return true; } + @Override public String toString() { return "GLProfile[" + getName() + "/" + getImplName() + "."+(this.isHardwareRasterizer?"hw":"sw")+"]"; } diff --git a/src/jogl/classes/javax/media/opengl/GLUniformData.java b/src/jogl/classes/javax/media/opengl/GLUniformData.java index 700bba2eb..412bfb0a9 100644 --- a/src/jogl/classes/javax/media/opengl/GLUniformData.java +++ b/src/jogl/classes/javax/media/opengl/GLUniformData.java @@ -97,6 +97,7 @@ public class GLUniformData { return sb; } + @Override public String toString() { return toString(null).toString(); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index f08fbafe8..8757c7a26 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -449,8 +449,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing _lock.unlock(); } } - private final Runnable realizeOnEDTAction = new Runnable() { public void run() { setRealizedImpl(true); } }; - private final Runnable unrealizeOnEDTAction = new Runnable() { public void run() { setRealizedImpl(false); } }; + private final Runnable realizeOnEDTAction = new Runnable() { + @Override + public void run() { setRealizedImpl(true); } + }; + private final Runnable unrealizeOnEDTAction = new Runnable() { + @Override + public void run() { setRealizedImpl(false); } + }; @Override public final void setRealized(boolean realized) { diff --git a/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallbackAdapter.java b/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallbackAdapter.java index bd12dfb9d..15a7bb2a1 100644 --- a/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallbackAdapter.java +++ b/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallbackAdapter.java @@ -64,20 +64,32 @@ package javax.media.opengl.glu; */ public class GLUtessellatorCallbackAdapter implements GLUtessellatorCallback { + @Override public void begin(int type) {} + @Override public void edgeFlag(boolean boundaryEdge) {} + @Override public void vertex(Object vertexData) {} + @Override public void end() {} // public void mesh(jogamp.opengl.tessellator.GLUmesh mesh) {} + @Override public void error(int errnum) {} + @Override public void combine(double[] coords, Object[] data, float[] weight, Object[] outData) {} + @Override public void beginData(int type, Object polygonData) {} + @Override public void edgeFlagData(boolean boundaryEdge, Object polygonData) {} + @Override public void vertexData(Object vertexData, Object polygonData) {} + @Override public void endData(Object polygonData) {} + @Override public void errorData(int errnum, Object polygonData) {} + @Override public void combineData(double[] coords, Object[] data, float[] weight, Object[] outData, Object polygonData) {} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index 22600cb89..012b1d1dd 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -46,6 +46,7 @@ public class RegionRendererImpl01 extends RegionRenderer { } + @Override protected boolean initShaderProgram(GL2ES2 gl) { final ShaderState st = rs.getShaderState(); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java b/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java index 8ca29b9f0..fe2dd7363 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java @@ -65,8 +65,11 @@ public class RenderStateImpl extends RenderState { this(st, pointFactory, new PMVMatrix()); } + @Override public final GLUniformData getWeight() { return gcu_Weight; } + @Override public final GLUniformData getAlpha() { return gcu_Alpha; } + @Override public final GLUniformData getColorStatic() { return gcu_ColorStatic; } //public final GLUniformData getStrength() { return gcu_Strength; } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java index 86c0db8c6..77c862ed4 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java @@ -77,6 +77,7 @@ public class VBORegion2PES2 extends GLRegion { mgl_ActiveTexture = new GLUniformData(UniformNames.gcu_TextureUnit, textureEngine); } + @Override public void update(GL2ES2 gl, RenderState rs) { if(!isDirty()) { return; @@ -194,6 +195,7 @@ public class VBORegion2PES2 extends GLRegion { int[] maxTexSize = new int[] { -1 } ; + @Override protected void drawImpl(GL2ES2 gl, RenderState rs, int vp_width, int vp_height, int[/*1*/] texWidth) { if(vp_width <=0 || vp_height <= 0 || null==texWidth || texWidth[0] <= 0){ renderRegion(gl); @@ -296,6 +298,7 @@ public class VBORegion2PES2 extends GLRegion { verticeTxtAttr.enableBuffer(gl, false); } + @Override public void destroy(GL2ES2 gl, RenderState rs) { if(DEBUG_INSTANCE) { System.err.println("VBORegion2PES2 Destroy: " + this); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java index 0a867b45c..9feb18a12 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -48,6 +48,7 @@ public class VBORegionSPES2 extends GLRegion { super(renderModes); } + @Override protected void update(GL2ES2 gl, RenderState rs) { if(!isDirty()) { return; @@ -125,6 +126,7 @@ public class VBORegionSPES2 extends GLRegion { setDirty(false); } + @Override protected void drawImpl(GL2ES2 gl, RenderState rs, int vp_width, int vp_height, int[/*1*/] texWidth) { verticeAttr.enableBuffer(gl, true); texCoordAttr.enableBuffer(gl, true); @@ -137,6 +139,7 @@ public class VBORegionSPES2 extends GLRegion { verticeAttr.enableBuffer(gl, false); } + @Override public final void destroy(GL2ES2 gl, RenderState rs) { if(DEBUG_INSTANCE) { System.err.println("VBORegionSPES2 Destroy: " + this); diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java index 4f48b2d20..a60f91b87 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java @@ -65,6 +65,7 @@ public class CDTriangulator2D implements Triangulator{ /** Reset the triangulation to initial state * Clearing cached data */ + @Override public void reset() { maxTriID = 0; vertices = new ArrayList(); @@ -72,6 +73,7 @@ public class CDTriangulator2D implements Triangulator{ loops = new ArrayList(); } + @Override public void addCurve(Outline polyline) { Loop loop = null; @@ -93,6 +95,7 @@ public class CDTriangulator2D implements Triangulator{ } } + @Override public ArrayList generate() { for(int i=0;i() { + @Override public String run() { return System.getProperty("java.home"); } @@ -81,10 +82,12 @@ public class JavaFontLoader implements FontSet { return 0 != ( bits & bit ) ; } + @Override public Font getDefault() throws IOException { return get(FAMILY_REGULAR, 0) ; // Sans Serif Regular } + @Override public Font get(int family, int style) throws IOException { Font font = (Font)fontMap.get( ( family << 8 ) | style ); if (font != null) { diff --git a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java index 254583739..9096f7d16 100644 --- a/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java +++ b/src/jogl/classes/jogamp/graph/font/UbuntuFontLoader.java @@ -71,10 +71,12 @@ public class UbuntuFontLoader implements FontSet { return 0 != ( bits & bit ) ; } + @Override public Font getDefault() throws IOException { return get(FAMILY_REGULAR, 0) ; // Sans Serif Regular } + @Override public Font get(int family, int style) throws IOException { Font font = (Font)fontMap.get( ( family << 8 ) | style ); if (font != null) { diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java index ba6c72650..67ae6c387 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java @@ -148,25 +148,31 @@ class TypecastFont implements FontInt { char2Glyph = new IntObjectHashMap(cmapentries + cmapentries/4); } + @Override public StringBuilder getName(StringBuilder sb, int nameIndex) { return font.getName(nameIndex, sb); } + @Override public String getName(int nameIndex) { return getName(null, nameIndex).toString(); } + @Override public StringBuilder getAllNames(StringBuilder sb, String separator) { return font.getAllNames(sb, separator); } + @Override public StringBuilder getFullFamilyName(StringBuilder sb) { sb = getName(sb, Font.NAME_FAMILY).append("-"); getName(sb, Font.NAME_SUBFAMILY); return sb; } + @Override public float getAdvanceWidth(int i, float pixelSize) { return font.getHmtxTable().getAdvanceWidth(i) * metrics.getScale(pixelSize); } + @Override public Metrics getMetrics() { if (metrics == null) { metrics = new TypecastHMetrics(this); @@ -174,6 +180,7 @@ class TypecastFont implements FontInt { return metrics; } + @Override public Glyph getGlyph(char symbol) { TypecastGlyph result = (TypecastGlyph) char2Glyph.get(symbol); if (null == result) { @@ -219,11 +226,13 @@ class TypecastFont implements FontInt { return result; } + @Override public ArrayList getOutlineShapes(CharSequence string, float pixelSize, Factory vertexFactory) { AffineTransform transform = new AffineTransform(vertexFactory); return TypecastRenderer.getOutlineShapes(this, string, pixelSize, transform, vertexFactory); } + @Override public float getStringWidth(CharSequence string, float pixelSize) { float width = 0; final int len = string.length(); @@ -241,6 +250,7 @@ class TypecastFont implements FontInt { return (int)(width + 0.5f); } + @Override public float getStringHeight(CharSequence string, float pixelSize) { int height = 0; @@ -257,6 +267,7 @@ class TypecastFont implements FontInt { return height; } + @Override public AABBox getStringBounds(CharSequence string, float pixelSize) { if (string == null) { return new AABBox(); @@ -287,14 +298,17 @@ class TypecastFont implements FontInt { return new AABBox(0, 0, 0, totalWidth, totalHeight,0); } + @Override final public int getNumGlyphs() { return font.getNumGlyphs(); } + @Override public boolean isPrintableChar( char c ) { return FontFactory.isPrintableChar(c); } + @Override public String toString() { return getFullFamilyName(null).toString(); } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java index 77b5a9aa9..d7db981b0 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java @@ -43,8 +43,10 @@ import com.jogamp.graph.font.Font; public class TypecastFontConstructor implements FontConstructor { + @Override public Font create(final File ffile) throws IOException { Object o = AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { OTFontCollection fontset; try { @@ -64,8 +66,10 @@ public class TypecastFontConstructor implements FontConstructor { throw new InternalError("Unexpected Object: "+o); } + @Override public Font create(final URLConnection fconn) throws IOException { return AccessController.doPrivileged(new PrivilegedAction() { + @Override public Font run() { File tf = null; int len=0; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java index 476b3fd4e..574aeb86d 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java @@ -79,6 +79,7 @@ public class TypecastGlyph implements FontInt.GlyphInt { return fo.floatValue(); } + @Override public String toString() { return "\nAdvance:"+ @@ -122,6 +123,7 @@ public class TypecastGlyph implements FontInt.GlyphInt { return this.advance.get(size, useFrationalMetrics); } + @Override public String toString() { return "\nMetrics:"+ @@ -173,10 +175,12 @@ public class TypecastGlyph implements FontInt.GlyphInt { this.metrics.reset(); } + @Override public Font getFont() { return this.font; } + @Override public char getSymbol() { return this.symbol; } @@ -201,6 +205,7 @@ public class TypecastGlyph implements FontInt.GlyphInt { return this.metrics.getScale(pixelSize); } + @Override public AABBox getBBox(float pixelSize) { final float size = getScale(pixelSize); AABBox newBox = getBBox().clone(); @@ -212,14 +217,17 @@ public class TypecastGlyph implements FontInt.GlyphInt { this.metrics.addAdvance(advance, size); } + @Override public float getAdvance(float pixelSize, boolean useFrationalMetrics) { return this.metrics.getAdvance(pixelSize, useFrationalMetrics); } + @Override public Path2D getPath() { return this.path; } + @Override public Path2D getPath(float pixelSize) { final float size = getScale(pixelSize); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java index a6ce58ae2..ecc41e438 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastHMetrics.java @@ -61,21 +61,27 @@ class TypecastHMetrics implements Metrics { bbox = new AABBox(lowx, lowy, 0, highx, highy, 0); // invert } + @Override public final float getAscent(float pixelSize) { return getScale(pixelSize) * -hheaTable.getAscender(); // invert } + @Override public final float getDescent(float pixelSize) { return getScale(pixelSize) * -hheaTable.getDescender(); // invert } + @Override public final float getLineGap(float pixelSize) { return getScale(pixelSize) * -hheaTable.getLineGap(); // invert } + @Override public final float getMaxExtend(float pixelSize) { return getScale(pixelSize) * hheaTable.getXMaxExtent(); } + @Override public final float getScale(float pixelSize) { return pixelSize * unitsPerEM_Inv; } + @Override public final AABBox getBBox(float pixelSize) { AABBox res = new AABBox(bbox.getLow(), bbox.getHigh()); res.scale(getScale(pixelSize)); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java index 8fc4be92d..7c3b32e2c 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/OTFont.java @@ -283,6 +283,7 @@ public class OTFont { _glyf = (GlyfTable) getTable(Table.glyf); } + @Override public String toString() { if (_tableDirectory != null) { return _tableDirectory.toString(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/BaseTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/BaseTable.java index b6626a9cc..60975dd52 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/BaseTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/BaseTable.java @@ -47,10 +47,12 @@ public class BaseTable implements Table { _coordinate = di.readShort(); } + @Override public int getBaseCoordFormat() { return 1; } + @Override public short getCoordinate() { return _coordinate; } @@ -69,10 +71,12 @@ public class BaseTable implements Table { _baseCoordPoint = di.readUnsignedShort(); } + @Override public int getBaseCoordFormat() { return 2; } + @Override public short getCoordinate() { return _coordinate; } @@ -89,10 +93,12 @@ public class BaseTable implements Table { _deviceTableOffset = di.readUnsignedShort(); } + @Override public int getBaseCoordFormat() { return 2; } + @Override public short getCoordinate() { return _coordinate; } @@ -211,6 +217,7 @@ public class BaseTable implements Table { } } + @Override public String toString() { StringBuilder sb = new StringBuilder() .append("\nBaseScript BaseScriptT").append(Integer.toHexString(_thisOffset)) @@ -273,6 +280,7 @@ public class BaseTable implements Table { } } + @Override public String toString() { StringBuilder sb = new StringBuilder() .append("\nBaseScriptList BaseScriptListT").append(Integer.toHexString(_thisOffset)) @@ -305,6 +313,7 @@ public class BaseTable implements Table { } } + @Override public String toString() { StringBuilder sb = new StringBuilder() .append("\nBaseTagList BaseTagListT").append(Integer.toHexString(_thisOffset)) @@ -338,6 +347,7 @@ public class BaseTable implements Table { } } + @Override public String toString() { return new StringBuilder() .append("\nAxis AxisT").append(Integer.toHexString(_thisOffset)) @@ -403,10 +413,12 @@ public class BaseTable implements Table { return String.valueOf(c); } + @Override public int getType() { return BASE; } + @Override public String toString() { StringBuilder sb = new StringBuilder() .append("; 'BASE' Table - Baseline\n;-------------------------------------\n\n") @@ -429,6 +441,7 @@ public class BaseTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CffTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CffTable.java index 62486fb7f..a36a49923 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CffTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CffTable.java @@ -164,6 +164,7 @@ public class CffTable implements Table { return ""; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); Enumeration keys = _entries.keys(); @@ -220,6 +221,7 @@ public class CffTable implements Table { return _data; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("DICT\n"); @@ -254,6 +256,7 @@ public class CffTable implements Table { return new Dict(getData(), offset, len); } + @Override public String toString() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < getCount(); ++i) { @@ -287,6 +290,7 @@ public class CffTable implements Table { return name; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < getCount(); ++i) { @@ -321,6 +325,7 @@ public class CffTable implements Table { } } + @Override public String toString() { int nonStandardBase = CffStandardStrings.standardStrings.length; StringBuilder sb = new StringBuilder(); @@ -388,10 +393,12 @@ public class CffTable implements Table { } } + @Override public int getFormat() { return 0; } + @Override public int getSID(int gid) { if (gid == 0) { return 0; @@ -413,10 +420,12 @@ public class CffTable implements Table { } } + @Override public int getFormat() { return 1; } + @Override public int getSID(int gid) { if (gid == 0) { return 0; @@ -448,10 +457,12 @@ public class CffTable implements Table { } } + @Override public int getFormat() { return 2; } + @Override public int getSID(int gid) { if (gid == 0) { return 0; @@ -586,10 +597,12 @@ public class CffTable implements Table { return _charstringsArray[fontIndex].length; } + @Override public int getType() { return CFF; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'CFF' Table - Compact Font Format\n---------------------------------\n"); @@ -614,6 +627,7 @@ public class CffTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CharstringType2.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CharstringType2.java index 93ff60988..7a7b51890 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CharstringType2.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CharstringType2.java @@ -133,10 +133,12 @@ public class CharstringType2 extends Charstring { _globalSubrIndex = globalSubrIndex; } + @Override public int getIndex() { return _index; } + @Override public String getName() { return _name; } @@ -223,6 +225,7 @@ public class CharstringType2 extends Charstring { return _ip < _offset + _length; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); resetIP(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat1.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat1.java index 1079aeed4..94910e4f6 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat1.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat1.java @@ -32,6 +32,7 @@ public class ClassDefFormat1 extends ClassDef { } } + @Override public int getFormat() { return 1; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat2.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat2.java index 59bc7b329..9906ecfb1 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat2.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/ClassDefFormat2.java @@ -30,6 +30,7 @@ public class ClassDefFormat2 extends ClassDef { } } + @Override public int getFormat() { return 2; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat.java index 62ce5ae4c..f7054852a 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat.java @@ -122,6 +122,7 @@ public abstract class CmapFormat { public abstract int mapCharCode(int charCode); + @Override public String toString() { return new StringBuilder() .append("format: ") diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat0.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat0.java index 2093158bd..dd1ede232 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat0.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat0.java @@ -71,10 +71,12 @@ public class CmapFormat0 extends CmapFormat { } } + @Override public int getRangeCount() { return 1; } + @Override public Range getRange(int index) throws ArrayIndexOutOfBoundsException { if (index != 0) { throw new ArrayIndexOutOfBoundsException(); @@ -82,6 +84,7 @@ public class CmapFormat0 extends CmapFormat { return new Range(0, 255); } + @Override public int mapCharCode(int charCode) { if (0 <= charCode && charCode < 256) { return _glyphIdArray[charCode]; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat2.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat2.java index 222c93852..d071e9421 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat2.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat2.java @@ -118,10 +118,12 @@ public class CmapFormat2 extends CmapFormat { } } + @Override public int getRangeCount() { return _subHeaders.length; } + @Override public Range getRange(int index) throws ArrayIndexOutOfBoundsException { if (index < 0 || index >= _subHeaders.length) { throw new ArrayIndexOutOfBoundsException(); @@ -144,6 +146,7 @@ public class CmapFormat2 extends CmapFormat { _subHeaders[index]._entryCount - 1)); } + @Override public int mapCharCode(int charCode) { // Get the appropriate subheader diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat4.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat4.java index ef65867af..2ae23d031 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat4.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat4.java @@ -110,10 +110,12 @@ public class CmapFormat4 extends CmapFormat { // } } + @Override public int getRangeCount() { return _segCount; } + @Override public Range getRange(int index) throws ArrayIndexOutOfBoundsException { if (index < 0 || index >= _segCount) { throw new ArrayIndexOutOfBoundsException(); @@ -121,6 +123,7 @@ public class CmapFormat4 extends CmapFormat { return new Range(_startCode[index], _endCode[index]); } + @Override public int mapCharCode(int charCode) { try { for (int i = 0; i < _segCount; i++) { @@ -142,6 +145,7 @@ public class CmapFormat4 extends CmapFormat { return 0; } + @Override public String toString() { return new StringBuilder() .append(super.toString()) diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat6.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat6.java index a22e33244..2a33d8d40 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat6.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormat6.java @@ -73,14 +73,17 @@ public class CmapFormat6 extends CmapFormat { //di.skipBytes(_length - 4); } + @Override public int getRangeCount() { return 0; } + @Override public Range getRange(int index) throws ArrayIndexOutOfBoundsException { throw new ArrayIndexOutOfBoundsException(); } + @Override public int mapCharCode(int charCode) { return 0; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormatUnknown.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormatUnknown.java index 3544b6f62..392683bcd 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormatUnknown.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapFormatUnknown.java @@ -40,14 +40,17 @@ public class CmapFormatUnknown extends CmapFormat { di.skipBytes(_length - 4); } + @Override public int getRangeCount() { return 0; } + @Override public Range getRange(int index) throws ArrayIndexOutOfBoundsException { throw new ArrayIndexOutOfBoundsException(); } + @Override public int mapCharCode(int charCode) { return 0; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapIndexEntry.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapIndexEntry.java index 47f6c470d..4833318d5 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapIndexEntry.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapIndexEntry.java @@ -90,6 +90,7 @@ public class CmapIndexEntry implements Comparable { _format = format; } + @Override public String toString() { return new StringBuilder() .append("platform id: ") @@ -104,6 +105,7 @@ public class CmapIndexEntry implements Comparable { .append(_offset).toString(); } + @Override public int compareTo(java.lang.Object obj) { CmapIndexEntry entry = (CmapIndexEntry) obj; if (getOffset() < entry.getOffset()) { diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapTable.java index 016efa093..2cdddb3ef 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CmapTable.java @@ -130,10 +130,12 @@ public class CmapTable implements Table { return null; } + @Override public int getType() { return cmap; } + @Override public String toString() { StringBuilder sb = new StringBuilder().append("cmap\n"); @@ -155,6 +157,7 @@ public class CmapTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CoverageFormat1.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CoverageFormat1.java index 712da54df..715bf11ec 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CoverageFormat1.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CoverageFormat1.java @@ -72,10 +72,12 @@ public class CoverageFormat1 extends Coverage { } } + @Override public int getFormat() { return 1; } + @Override public int findGlyph(int glyphId) { for (int i = 0; i < _glyphCount; i++) { if (_glyphIds[i] == glyphId) { diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CoverageFormat2.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CoverageFormat2.java index 7196ed595..bd2a28f79 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CoverageFormat2.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CoverageFormat2.java @@ -72,10 +72,12 @@ public class CoverageFormat2 extends Coverage { } } + @Override public int getFormat() { return 2; } + @Override public int findGlyph(int glyphId) { for (int i = 0; i < _rangeCount; i++) { int n = _rangeRecords[i].getCoverageIndex(glyphId); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CvtTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CvtTable.java index 867ef1823..9e1c47de9 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CvtTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/CvtTable.java @@ -29,6 +29,7 @@ public class CvtTable implements Table { } } + @Override public int getType() { return cvt; } @@ -37,6 +38,7 @@ public class CvtTable implements Table { return values; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'cvt ' Table - Control Value Table\n----------------------------------\n"); @@ -54,6 +56,7 @@ public class CvtTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DirectoryEntry.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DirectoryEntry.java index 7abcec0ce..e34fa32e8 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DirectoryEntry.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DirectoryEntry.java @@ -71,6 +71,7 @@ public class DirectoryEntry implements Cloneable { _length = di.readInt(); } + @Override public Object clone() { try { return super.clone(); @@ -104,6 +105,7 @@ public class DirectoryEntry implements Cloneable { .toString(); } + @Override public String toString() { return new StringBuilder() .append("'").append(getTagAsString()) diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DsigTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DsigTable.java index f25c595d0..2b85f52d8 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DsigTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/DsigTable.java @@ -45,6 +45,7 @@ public class DsigTable implements Table { * Get the table type, as a table directory value. * @return The table type */ + @Override public int getType() { return DSIG; } @@ -55,10 +56,12 @@ public class DsigTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return de; } + @Override public String toString() { StringBuilder sb = new StringBuilder().append("DSIG\n"); for (int i = 0; i < numSigs; i++) { diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FpgmTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FpgmTable.java index b662265d9..467a4f360 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FpgmTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/FpgmTable.java @@ -26,10 +26,12 @@ public class FpgmTable extends Program implements Table { readInstructions(di, de.getLength()); } + @Override public int getType() { return fpgm; } + @Override public String toString() { return Disassembler.disassemble(getInstructions(), 0); } @@ -40,6 +42,7 @@ public class FpgmTable extends Program implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspRange.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspRange.java index cf4afa88e..cc87b19a4 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspRange.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspRange.java @@ -30,6 +30,7 @@ public class GaspRange { rangeGaspBehavior = di.readUnsignedShort(); } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(" rangeMaxPPEM: ").append(rangeMaxPPEM) diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspTable.java index 45498eda1..8f91e6d00 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GaspTable.java @@ -34,10 +34,12 @@ public class GaspTable implements Table { } } + @Override public int getType() { return gasp; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'gasp' Table - Grid-fitting And Scan-conversion Procedure\n---------------------------------------------------------"); @@ -56,6 +58,7 @@ public class GaspTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java index 50f62ed62..50e0fa339 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfCompositeDescript.java @@ -99,6 +99,7 @@ public class GlyfCompositeDescript extends GlyfDescript { } } + @Override public int getEndPtOfContours(int i) { GlyfCompositeComp c = getCompositeCompEndPt(i); if (c != null) { @@ -108,6 +109,7 @@ public class GlyfCompositeDescript extends GlyfDescript { return 0; } + @Override public byte getFlags(int i) { GlyfCompositeComp c = getCompositeComp(i); if (c != null) { @@ -117,6 +119,7 @@ public class GlyfCompositeDescript extends GlyfDescript { return 0; } + @Override public short getXCoordinate(int i) { GlyfCompositeComp c = getCompositeComp(i); if (c != null) { @@ -131,6 +134,7 @@ public class GlyfCompositeDescript extends GlyfDescript { return 0; } + @Override public short getYCoordinate(int i) { GlyfCompositeComp c = getCompositeComp(i); if (c != null) { @@ -145,10 +149,12 @@ public class GlyfCompositeDescript extends GlyfDescript { return 0; } + @Override public boolean isComposite() { return true; } + @Override public int getPointCount() { GlyfCompositeComp c = _components.get(_components.size()-1); GlyphDescription gd = _parentTable.getDescription(c.getGlyphIndex()); @@ -159,6 +165,7 @@ public class GlyfCompositeDescript extends GlyfDescript { } } + @Override public int getContourCount() { GlyfCompositeComp c = _components.get(_components.size()-1); return c.getFirstContour() + _parentTable.getDescription(c.getGlyphIndex()).getContourCount(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfDescript.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfDescript.java index a7e2e7b69..6b06eb3de 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfDescript.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfDescript.java @@ -92,26 +92,32 @@ public abstract class GlyfDescript extends Program implements GlyphDescription { return _numberOfContours; } + @Override public int getGlyphIndex() { return _glyphIndex; } + @Override public short getXMaximum() { return _xMax; } + @Override public short getXMinimum() { return _xMin; } + @Override public short getYMaximum() { return _yMax; } + @Override public short getYMinimum() { return _yMin; } + @Override public String toString() { return new StringBuilder() .append(" numberOfContours: ").append(_numberOfContours) diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfSimpleDescript.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfSimpleDescript.java index f67162cff..c06ceaa13 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfSimpleDescript.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfSimpleDescript.java @@ -92,30 +92,37 @@ public class GlyfSimpleDescript extends GlyfDescript { readCoords(_count, di); } + @Override public int getEndPtOfContours(int i) { return _endPtsOfContours[i]; } + @Override public byte getFlags(int i) { return _flags[i]; } + @Override public short getXCoordinate(int i) { return _xCoordinates[i]; } + @Override public short getYCoordinate(int i) { return _yCoordinates[i]; } + @Override public boolean isComposite() { return false; } + @Override public int getPointCount() { return _count; } + @Override public int getContourCount() { return getNumberOfContours(); } @@ -185,6 +192,7 @@ public class GlyfSimpleDescript extends GlyfDescript { } } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfTable.java index 34a8218d9..4b196c9e2 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GlyfTable.java @@ -116,6 +116,7 @@ public class GlyfTable implements Table { } } + @Override public int getType() { return glyf; } @@ -126,6 +127,7 @@ public class GlyfTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GposTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GposTable.java index 9a367412d..30ecdd051 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GposTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GposTable.java @@ -45,10 +45,12 @@ public class GposTable implements Table { /** Get the table type, as a table directory value. * @return The table type */ + @Override public int getType() { return GPOS; } + @Override public String toString() { return "GPOS"; } @@ -59,6 +61,7 @@ public class GposTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GsubTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GsubTable.java index 0351c903d..c23d420a8 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GsubTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/GsubTable.java @@ -99,6 +99,7 @@ public class GsubTable implements Table, LookupSubtableFactory { * 5 - Context - Replace one or more glyphs in context * 6 - Chaining - Context Replace one or more glyphs in chained context */ + @Override public LookupSubtable read( int type, DataInputStream dis, @@ -130,6 +131,7 @@ public class GsubTable implements Table, LookupSubtableFactory { /** Get the table type, as a table directory value. * @return The table type */ + @Override public int getType() { return GSUB; } @@ -146,6 +148,7 @@ public class GsubTable implements Table, LookupSubtableFactory { return _lookupList; } + @Override public String toString() { return "GSUB"; } @@ -174,6 +177,7 @@ public class GsubTable implements Table, LookupSubtableFactory { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HdmxTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HdmxTable.java index 42f9bf0d0..64f5e6415 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HdmxTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HdmxTable.java @@ -93,10 +93,12 @@ public class HdmxTable implements Table { return _records[i]; } + @Override public int getType() { return hdmx; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'hdmx' Table - Horizontal Device Metrics\n----------------------------------------\n"); @@ -124,6 +126,7 @@ public class HdmxTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java index cf7c58449..47e60f900 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HeadTable.java @@ -142,6 +142,7 @@ public class HeadTable implements Table { return _modified; } + @Override public int getType() { return head; } @@ -170,6 +171,7 @@ public class HeadTable implements Table { return _yMin; } + @Override public String toString() { return new StringBuilder() .append("'head' Table - Font Header\n--------------------------") @@ -199,6 +201,7 @@ public class HeadTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HheaTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HheaTable.java index 0278929f1..242c9b139 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HheaTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HheaTable.java @@ -92,6 +92,7 @@ public class HheaTable implements Table { return numberOfHMetrics; } + @Override public int getType() { return hhea; } @@ -100,6 +101,7 @@ public class HheaTable implements Table { return xMaxExtent; } + @Override public String toString() { return new StringBuilder() .append("'hhea' Table - Horizontal Header\n--------------------------------") @@ -129,6 +131,7 @@ public class HheaTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HmtxTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HmtxTable.java index dacd9e265..122a0a826 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HmtxTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/HmtxTable.java @@ -106,10 +106,12 @@ public class HmtxTable implements Table { } } + @Override public int getType() { return hmtx; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'hmtx' Table - Horizontal Metrics\n---------------------------------\n"); @@ -135,6 +137,7 @@ public class HmtxTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java index 89e6f9f11..1e7ff8c2d 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat0.java @@ -36,10 +36,12 @@ public class KernSubtableFormat0 extends KernSubtable { } } + @Override public int getKerningPairCount() { return nPairs; } + @Override public KerningPair getKerningPair(int i) { return kerningPairs[i]; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java index 6f5e1f5e8..9c7fc81f9 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernSubtableFormat2.java @@ -31,10 +31,12 @@ public class KernSubtableFormat2 extends KernSubtable { array = di.readUnsignedShort(); } + @Override public int getKerningPairCount() { return 0; } + @Override public KerningPair getKerningPair(int i) { return null; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java index 1d526865a..006a86895 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/KernTable.java @@ -45,6 +45,7 @@ public class KernTable implements Table { /** Get the table type, as a table directory value. * @return The table type */ + @Override public int getType() { return kern; } @@ -55,6 +56,7 @@ public class KernTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LigatureSubstFormat1.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LigatureSubstFormat1.java index cad5e106a..1979ea586 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LigatureSubstFormat1.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LigatureSubstFormat1.java @@ -89,6 +89,7 @@ public class LigatureSubstFormat1 extends LigatureSubst { return 1; } + @Override public String getTypeAsString() { return "LigatureSubstFormat1"; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LocaTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LocaTable.java index ce0862eea..2c7079fec 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LocaTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LocaTable.java @@ -49,10 +49,12 @@ public class LocaTable implements Table { return _offsets[i] * _factor; } + @Override public int getType() { return loca; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'loca' Table - Index To Location Table\n--------------------------------------\n") @@ -71,6 +73,7 @@ public class LocaTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LtshTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LtshTable.java index 9b0c8e6b4..47874cc56 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LtshTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/LtshTable.java @@ -38,10 +38,12 @@ public class LtshTable implements Table { * Get the table type, as a table directory value. * @return The table type */ + @Override public int getType() { return LTSH; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'LTSH' Table - Linear Threshold Table\n-------------------------------------") @@ -61,6 +63,7 @@ public class LtshTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/MaxpTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/MaxpTable.java index 5ab6b51ca..abb6047fc 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/MaxpTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/MaxpTable.java @@ -121,10 +121,12 @@ public class MaxpTable implements Table { return numGlyphs; } + @Override public int getType() { return maxp; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'maxp' Table - Maximum Profile\n------------------------------") @@ -156,6 +158,7 @@ public class MaxpTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java index 9f9822986..a1787e3e7 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameRecord.java @@ -130,6 +130,7 @@ public class NameRecord { _record = sb.toString(); } + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java index 5b7a17d3b..ad8198b7f 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/NameTable.java @@ -130,6 +130,7 @@ public class NameTable implements Table { return sb; } + @Override public int getType() { return name; } @@ -140,6 +141,7 @@ public class NameTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Os2Table.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Os2Table.java index 9dfbceb99..5340b297c 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Os2Table.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Os2Table.java @@ -293,10 +293,12 @@ public class Os2Table implements Table { return _usMaxContext; } + @Override public int getType() { return OS_2; } + @Override public String toString() { return new StringBuilder() .append("'OS/2' Table - OS/2 and Windows Metrics\n---------------------------------------") @@ -351,6 +353,7 @@ public class Os2Table implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Panose.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Panose.java index 1f6c5a1dd..771318108 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Panose.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/Panose.java @@ -79,6 +79,7 @@ public class Panose { return bXHeight; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(String.valueOf(bFamilyType)).append(" ") diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PcltTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PcltTable.java index 6ed9b2b9c..a1f603d8f 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PcltTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PcltTable.java @@ -65,10 +65,12 @@ public class PcltTable implements Table { * Get the table type, as a table directory value. * @return The table type */ + @Override public int getType() { return PCLT; } + @Override public String toString() { return new StringBuilder() .append("'PCLT' Table - Printer Command Language Table\n---------------------------------------------") @@ -98,6 +100,7 @@ public class PcltTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PostTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PostTable.java index 46f1ac088..188b441ac 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PostTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PostTable.java @@ -370,10 +370,12 @@ public class PostTable implements Table { /** Get the table type, as a table directory value. * @return The table type */ + @Override public int getType() { return post; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'post' Table - PostScript Metrics\n---------------------------------\n") @@ -416,6 +418,7 @@ public class PostTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PrepTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PrepTable.java index 2046d7fe4..4c64673b7 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PrepTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/PrepTable.java @@ -26,10 +26,12 @@ public class PrepTable extends Program implements Table { readInstructions(di, de.getLength()); } + @Override public int getType() { return prep; } + @Override public String toString() { return Disassembler.disassemble(getInstructions(), 0); } @@ -40,6 +42,7 @@ public class PrepTable extends Program implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SignatureBlock.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SignatureBlock.java index 15f0cd04f..31a2d17c9 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SignatureBlock.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SignatureBlock.java @@ -32,6 +32,7 @@ public class SignatureBlock { di.readFully(signature); } + @Override public String toString() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < signatureLen; i += 16) { diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat1.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat1.java index a8df78504..e97e62a58 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat1.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat1.java @@ -73,10 +73,12 @@ public class SingleSubstFormat1 extends SingleSubst { _coverage = Coverage.read(dis); } + @Override public int getFormat() { return 1; } + @Override public int substitute(int glyphId) { int i = _coverage.findGlyph(glyphId); if (i > -1) { @@ -85,6 +87,7 @@ public class SingleSubstFormat1 extends SingleSubst { return glyphId; } + @Override public String getTypeAsString() { return "SingleSubstFormat1"; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat2.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat2.java index 2e47b2924..4d46b07b4 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat2.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/SingleSubstFormat2.java @@ -78,10 +78,12 @@ public class SingleSubstFormat2 extends SingleSubst { _coverage = Coverage.read(dis); } + @Override public int getFormat() { return 2; } + @Override public int substitute(int glyphId) { int i = _coverage.findGlyph(glyphId); if (i > -1) { @@ -90,6 +92,7 @@ public class SingleSubstFormat2 extends SingleSubst { return glyphId; } + @Override public String getTypeAsString() { return "SingleSubstFormat2"; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableDirectory.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableDirectory.java index 8c5678088..23ecba804 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableDirectory.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/TableDirectory.java @@ -113,6 +113,7 @@ public class TableDirectory { return _version; } + @Override public String toString() { StringBuilder sb = new StringBuilder() .append("Offset Table\n------ -----") diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VdmxTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VdmxTable.java index 28f9aa6e3..bebd7f946 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VdmxTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VdmxTable.java @@ -148,10 +148,12 @@ public class VdmxTable implements Table { } } + @Override public int getType() { return VDMX; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'VDMX' Table - Precomputed Vertical Device Metrics\n") @@ -191,6 +193,7 @@ public class VdmxTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VheaTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VheaTable.java index f42da119b..521b87cc8 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VheaTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VheaTable.java @@ -105,6 +105,7 @@ public class VheaTable implements Table { return _numberOfLongVerMetrics; } + @Override public int getType() { return vhea; } @@ -113,6 +114,7 @@ public class VheaTable implements Table { return _yMaxExtent; } + @Override public String toString() { return new StringBuilder() .append("'vhea' Table - Vertical Header\n------------------------------") @@ -142,6 +144,7 @@ public class VheaTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VmtxTable.java b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VmtxTable.java index 348405380..1b77a6fdc 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VmtxTable.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/ot/table/VmtxTable.java @@ -77,10 +77,12 @@ public class VmtxTable implements Table { } } + @Override public int getType() { return vmtx; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("'vmtx' Table - Vertical Metrics\n-------------------------------\n"); @@ -106,6 +108,7 @@ public class VmtxTable implements Table { * particular table. * @return A directory entry */ + @Override public DirectoryEntry getDirectoryEntry() { return _de; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/tt/engine/Parser.java b/src/jogl/classes/jogamp/graph/font/typecast/tt/engine/Parser.java index c5a2b6e87..1159b2c17 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/tt/engine/Parser.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/tt/engine/Parser.java @@ -148,6 +148,7 @@ public class Parser { instructions[2] = program; } + @Override public String toString() { StringBuilder sb = new StringBuilder(); int ip = 0; diff --git a/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java b/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java index c1ee17a4b..33b80d6b8 100644 --- a/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java +++ b/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java @@ -122,18 +122,22 @@ public final class Path2D implements Cloneable { this.t = at; } + @Override public int getWindingRule() { return p.getWindingRule(); } + @Override public boolean isDone() { return typeIndex >= p.typeSize; } + @Override public void next() { typeIndex++; } + @Override public int currentSegment(float[] coords) { if (isDone()) { throw new NoSuchElementException(iteratorOutOfBounds); @@ -256,6 +260,7 @@ public final class Path2D implements Cloneable { } } + @Override public String toString() { return "[size "+size()+", closed "+isClosed()+"]"; } diff --git a/src/jogl/classes/jogamp/opengl/Debug.java b/src/jogl/classes/jogamp/opengl/Debug.java index 74892d894..9332b670a 100644 --- a/src/jogl/classes/jogamp/opengl/Debug.java +++ b/src/jogl/classes/jogamp/opengl/Debug.java @@ -54,6 +54,7 @@ public class Debug extends PropertyAccess { static { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { PropertyAccess.addTrustedPrefix("jogl."); return null; diff --git a/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java b/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java index a1023acd2..c1e1d1821 100644 --- a/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java +++ b/src/jogl/classes/jogamp/opengl/DesktopGLDynamicLookupHelper.java @@ -39,6 +39,7 @@ public class DesktopGLDynamicLookupHelper extends GLDynamicLookupHelper { public final DesktopGLDynamicLibraryBundleInfo getDesktopGLBundleInfo() { return (DesktopGLDynamicLibraryBundleInfo) getBundleInfo(); } + @Override public final synchronized boolean loadGLULibrary() { /** hacky code .. where all platform GLU libs are tried ..*/ if(null==gluLib) { diff --git a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java index c96f7db32..08a1fe882 100644 --- a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java +++ b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java @@ -87,16 +87,19 @@ public class FPSCounterImpl implements FPSCounter { return sb; } + @Override public String toString() { return toString(null).toString(); } + @Override public final synchronized void setUpdateFPSFrames(int frames, PrintStream out) { fpsUpdateFramesInterval = frames; fpsOutputStream = out; resetFPSCounter(); } + @Override public final synchronized void resetFPSCounter() { fpsStartTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); // overwrite startTime to real init one fpsLastUpdateTime = fpsStartTime; @@ -106,34 +109,42 @@ public class FPSCounterImpl implements FPSCounter { fpsLastPeriod = 0; fpsTotalDuration=0; } + @Override public final synchronized int getUpdateFPSFrames() { return fpsUpdateFramesInterval; } + @Override public final synchronized long getFPSStartTime() { return fpsStartTime; } + @Override public final synchronized long getLastFPSUpdateTime() { return fpsLastUpdateTime; } + @Override public final synchronized long getLastFPSPeriod() { return fpsLastPeriod; } + @Override public final synchronized float getLastFPS() { return fpsLast; } + @Override public final synchronized int getTotalFPSFrames() { return fpsTotalFrames; } + @Override public final synchronized long getTotalFPSDuration() { return fpsTotalDuration; } + @Override public final synchronized float getTotalFPS() { return fpsTotal; } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 7c3a5922b..5f487fa6d 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1189,6 +1189,7 @@ public abstract class GLContextImpl extends GLContext { GLEmitter by looking up anew all of its function pointers. */ protected final void resetProcAddressTable(final ProcAddressTable table) { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { table.reset(getDrawableImpl().getGLDynamicLookupHelper() ); return null; diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java index b770f3b05..2c947693c 100644 --- a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java +++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java @@ -109,6 +109,7 @@ public class GLDebugMessageHandler { private final long getAddressFor(final ProcAddressTable table, final String functionName) { return AccessController.doPrivileged(new PrivilegedAction() { + @Override public Long run() { try { return Long.valueOf( table.getAddressFor(functionName) ); @@ -300,6 +301,7 @@ public class GLDebugMessageHandler { public StdErrGLDebugListener(boolean threadDump) { this.threadDump = threadDump; } + @Override public void messageSent(GLDebugMessage event) { System.err.println(event); if(threadDump) { diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 2cf384fd7..4ce6a7121 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -80,7 +80,7 @@ public class GLDrawableHelper { /** -1 release, 0 nop, 1 claim */ private volatile int exclusiveContextSwitch; private GLAnimatorControl animatorCtrl; - private static Runnable nop = new Runnable() { public void run() {} }; + private static Runnable nop = new Runnable() { @Override public void run() {} }; public GLDrawableHelper() { reset(); @@ -493,6 +493,7 @@ public class GLDrawableHelper { final boolean isPaused = isAnimatorAnimatingOnOtherThread() && animatorCtrl.pause(); final GLEventListener[] res = new GLEventListener[] { null }; final Runnable action = new Runnable() { + @Override public void run() { res[0] = disposeGLEventListener(autoDrawable, listener, remove); } @@ -525,6 +526,7 @@ public class GLDrawableHelper { final boolean isPaused = isAnimatorAnimatingOnOtherThread() && animatorCtrl.pause(); final Runnable action = new Runnable() { + @Override public void run() { disposeAllGLEventListener(autoDrawable, remove); } diff --git a/src/jogl/classes/jogamp/opengl/GLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/GLDynamicLibraryBundleInfo.java index 640e181ae..39de3200d 100644 --- a/src/jogl/classes/jogamp/opengl/GLDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/GLDynamicLibraryBundleInfo.java @@ -46,6 +46,7 @@ public abstract class GLDynamicLibraryBundleInfo implements DynamicLibraryBundle * *

                      */ + @Override public final boolean shallLinkGlobal() { return true; } /** diff --git a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java index a22454d60..f175acf28 100644 --- a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java @@ -127,6 +127,7 @@ public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implemen return ((GLFBODrawableImpl)drawable).getFBObject(bufferName); } + @Override public final FBObject.TextureAttachment getTextureBuffer(int bufferName) { return ((GLFBODrawableImpl)drawable).getTextureBuffer(bufferName); } diff --git a/src/jogl/classes/jogamp/opengl/GLRunnableTask.java b/src/jogl/classes/jogamp/opengl/GLRunnableTask.java index 2238d49bc..6de92f533 100644 --- a/src/jogl/classes/jogamp/opengl/GLRunnableTask.java +++ b/src/jogl/classes/jogamp/opengl/GLRunnableTask.java @@ -52,6 +52,7 @@ public class GLRunnableTask implements GLRunnable { isFlushed = false; } + @Override public boolean run(GLAutoDrawable drawable) { boolean res = true; if(null == notifyObject) { diff --git a/src/jogl/classes/jogamp/opengl/GLWorkerThread.java b/src/jogl/classes/jogamp/opengl/GLWorkerThread.java index 979c6dc0a..100b46a5e 100644 --- a/src/jogl/classes/jogamp/opengl/GLWorkerThread.java +++ b/src/jogl/classes/jogamp/opengl/GLWorkerThread.java @@ -222,6 +222,7 @@ public class GLWorkerThread { protected static String getThreadName() { return Thread.currentThread().getName(); } static class WorkerRunnable implements Runnable { + @Override public void run() { // Notify starting thread that we're ready synchronized (lock) { diff --git a/src/jogl/classes/jogamp/opengl/MemoryObject.java b/src/jogl/classes/jogamp/opengl/MemoryObject.java index df793dadd..d10747690 100644 --- a/src/jogl/classes/jogamp/opengl/MemoryObject.java +++ b/src/jogl/classes/jogamp/opengl/MemoryObject.java @@ -59,10 +59,12 @@ public class MemoryObject { /** * @return the 32bit hash value generated via {@link HashUtil#getAddrSizeHash32_EqualDist(long, long)}. */ + @Override public int hashCode() { return hash; } + @Override public String toString() { return "MemoryObject[addr 0x"+Long.toHexString(addr)+", size 0x"+Long.toHexString(size)+", hash32: 0x"+Integer.toHexString(hash)+"]"; } diff --git a/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java b/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java index eddb36975..283ecdb9d 100644 --- a/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java +++ b/src/jogl/classes/jogamp/opengl/SharedResourceRunner.java @@ -252,6 +252,7 @@ public class SharedResourceRunner implements Runnable { // done } + @Override public final void run() { final String threadName = getThreadName(); diff --git a/src/jogl/classes/jogamp/opengl/ThreadingImpl.java b/src/jogl/classes/jogamp/opengl/ThreadingImpl.java index 6ffe46b36..bf700d970 100644 --- a/src/jogl/classes/jogamp/opengl/ThreadingImpl.java +++ b/src/jogl/classes/jogamp/opengl/ThreadingImpl.java @@ -72,6 +72,7 @@ public class ThreadingImpl { static { threadingPlugin = AccessController.doPrivileged(new PrivilegedAction() { + @Override public ToolkitThreadingPlugin run() { final String singleThreadProp; { diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java index cd1bb45c9..72c9ac54b 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTThreadingPlugin.java @@ -54,10 +54,12 @@ public class AWTThreadingPlugin implements ToolkitThreadingPlugin { public AWTThreadingPlugin() {} + @Override public final boolean isToolkitThread() throws GLException { return EventQueue.isDispatchThread(); } + @Override public final boolean isOpenGLThread() throws GLException { switch (ThreadingImpl.getMode()) { case ST_AWT: @@ -83,6 +85,7 @@ public class AWTThreadingPlugin implements ToolkitThreadingPlugin { } } + @Override public final void invokeOnOpenGLThread(boolean wait, Runnable r) throws GLException { switch (ThreadingImpl.getMode()) { case ST_AWT: diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index 5faee1307..ff07b04d0 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -147,6 +147,7 @@ public class AWTTilePainter { this.flipVertical = true; } + @Override public String toString() { return renderer.toString(); } public void setIsGLOriented(boolean v) { diff --git a/src/jogl/classes/jogamp/opengl/awt/Java2D.java b/src/jogl/classes/jogamp/opengl/awt/Java2D.java index 7a8ddf0b4..886cd9368 100644 --- a/src/jogl/classes/jogamp/opengl/awt/Java2D.java +++ b/src/jogl/classes/jogamp/opengl/awt/Java2D.java @@ -116,6 +116,7 @@ public class Java2D { static { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { if (DEBUG) { System.err.println("Checking for Java2D/OpenGL support"); @@ -565,6 +566,7 @@ public class Java2D { private static int getOGLUtilitiesIntField(final String name) { Integer i = AccessController.doPrivileged(new PrivilegedAction() { + @Override public Integer run() { try { Class utils = Class.forName("sun.java2d.opengl.OGLUtilities"); @@ -608,6 +610,7 @@ public class Java2D { System.err.println("Starting initialization of J2D FBO share context"); } invokeWithOGLSharedContextCurrent(device.getDefaultConfiguration(), new Runnable() { + @Override public void run() { j2dFBOShareContext = GLDrawableFactory.getFactory(GLProfile.getDefault(GLProfile.getDefaultDevice())).createExternalGLContext(); } diff --git a/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java b/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java index a29d1e6aa..9173a38cb 100644 --- a/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java +++ b/src/jogl/classes/jogamp/opengl/awt/VersionApplet.java @@ -54,6 +54,7 @@ public class VersionApplet extends Applet { this.f = f; this.va = va; } + @Override public void windowClosing(WindowEvent ev) { f.setVisible(false); va.stop(); @@ -129,24 +130,28 @@ public class VersionApplet extends Applet { } } + @Override public void init() { System.err.println("VersionApplet: init() - begin"); my_init(); System.err.println("VersionApplet: init() - end"); } + @Override public void start() { System.err.println("VersionApplet: start() - begin"); canvas.setVisible(true); System.err.println("VersionApplet: start() - end"); } + @Override public void stop() { System.err.println("VersionApplet: stop() - begin"); canvas.setVisible(false); System.err.println("VersionApplet: stop() - end"); } + @Override public void destroy() { System.err.println("VersionApplet: destroy() - start"); my_release(); @@ -154,6 +159,7 @@ public class VersionApplet extends Applet { } class GLInfo implements GLEventListener { + @Override public void init(GLAutoDrawable drawable) { GL gl = drawable.getGL(); String s = JoglVersion.getGLInfo(gl, null).toString(); @@ -161,12 +167,15 @@ public class VersionApplet extends Applet { tareaVersion.append(s); } + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + @Override public void display(GLAutoDrawable drawable) { } + @Override public void dispose(GLAutoDrawable drawable) { } } diff --git a/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java index 1179e2b7f..7b85c3e75 100644 --- a/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java @@ -47,20 +47,24 @@ public final class DesktopES2DynamicLibraryBundleInfo extends GLDynamicLibraryBu super(); } + @Override public final List getToolGetProcAddressFuncNameList() { List res = new ArrayList(); res.add("eglGetProcAddress"); return res; } + @Override public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) { return EGL.eglGetProcAddress(toolGetProcAddressHandle, funcName); } + @Override public final boolean useToolGetProcAdressFirst(String funcName) { return true; } + @Override public final List> getToolLibNames() { final List> libsList = new ArrayList>(); final List libsGL = new ArrayList(); @@ -90,6 +94,7 @@ public final class DesktopES2DynamicLibraryBundleInfo extends GLDynamicLibraryBu return libsList; } + @Override public final List getGlueLibNames() { return glueLibNames; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index 89f34432d..3d864ad76 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -65,6 +65,7 @@ public class EGLDisplayUtil { this.createdStack = DEBUG ? new Throwable() : null; } + @Override public String toString() { return "EGLDisplay[0x"+Long.toHexString(eglDisplay)+": refCnt "+refCount+"]"; } @@ -248,9 +249,11 @@ public class EGLDisplayUtil { } public static final EGLGraphicsDevice.EGLDisplayLifecycleCallback eglLifecycleCallback = new EGLGraphicsDevice.EGLDisplayLifecycleCallback() { + @Override public long eglGetAndInitDisplay(long[] nativeDisplayID) { return eglGetDisplayAndInitialize(nativeDisplayID); } + @Override public void eglTerminate(long eglDisplayHandle) { EGLDisplayUtil.eglTerminate(eglDisplayHandle); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java index bf269c548..ab28fb3fb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java @@ -115,6 +115,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { } } + @Override protected void destroyHandle() { final EGLWrappedSurface eglws = (EGLWrappedSurface) surface; if(DEBUG) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java index 9ffcea864..361ec26ff 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java @@ -35,6 +35,7 @@ public final class EGLES1DynamicLibraryBundleInfo extends EGLDynamicLibraryBundl super(); } + @Override public final List> getToolLibNames() { final List> libsList = new ArrayList>(); { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java index de1f0a42e..74738463f 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java @@ -40,6 +40,7 @@ public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundl super(); } + @Override public final List> getToolLibNames() { final List> libsList = new ArrayList>(); { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 5764a6178..31fa14fbb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -115,6 +115,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact private EGLGraphicsConfigurationFactory() { } + @Override protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl ( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java index 5083c854f..dac058dc7 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java @@ -44,6 +44,7 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { static String getThreadName() { return Thread.currentThread().getName(); } + @Override public final void setSize(int width, int height) { if(null != upstreamSurfaceHookMutableSize) { upstreamSurfaceHookMutableSize.setSize(width, height); diff --git a/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java b/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java index b4383c2e6..717b1255c 100644 --- a/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java +++ b/src/jogl/classes/jogamp/opengl/glu/GLUquadricImpl.java @@ -164,6 +164,7 @@ public class GLUquadricImpl implements GLUquadric { replaceImmModeSink(); } + @Override public void enableImmModeSink(boolean val) { if(gl.isGL2()) { immModeSinkEnabled=val; @@ -175,10 +176,12 @@ public class GLUquadricImpl implements GLUquadric { } } + @Override public boolean isImmModeSinkEnabled() { return immModeSinkEnabled; } + @Override public void setImmMode(boolean val) { if(immModeSinkEnabled) { immModeSinkImmediate=val; @@ -187,10 +190,12 @@ public class GLUquadricImpl implements GLUquadric { } } + @Override public boolean getImmMode() { return immModeSinkImmediate; } + @Override public ImmModeSink replaceImmModeSink() { if(!immModeSinkEnabled) return null; @@ -222,6 +227,7 @@ public class GLUquadricImpl implements GLUquadric { return res; } + @Override public void resetImmModeSink(GL gl) { if(immModeSinkEnabled) { immModeSink.reset(gl); diff --git a/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GL2CurveEvaluator.java b/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GL2CurveEvaluator.java index f57c2310f..4213dfd46 100644 --- a/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GL2CurveEvaluator.java +++ b/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GL2CurveEvaluator.java @@ -92,6 +92,7 @@ class GL2CurveEvaluator implements CurveEvaluator { /** * Pushes eval bit */ + @Override public void bgnmap1f() { // DONE if (output_triangles) { @@ -108,6 +109,7 @@ class GL2CurveEvaluator implements CurveEvaluator { /** * Pops all OpenGL attributes */ + @Override public void endmap1f() { // DONE if (output_triangles) { @@ -127,6 +129,7 @@ class GL2CurveEvaluator implements CurveEvaluator { * @param order curve order * @param ps control points */ + @Override public void map1f(int type, float ulo, float uhi, int stride, int order, CArrayOfFloats ps) { if (output_triangles) { @@ -153,6 +156,7 @@ class GL2CurveEvaluator implements CurveEvaluator { * Calls opengl enable * @param type what to enable */ + @Override public void enable(int type) { // DONE gl.glEnable(type); @@ -164,6 +168,7 @@ class GL2CurveEvaluator implements CurveEvaluator { * @param u1 low u * @param u2 high u */ + @Override public void mapgrid1f(int nu, float u1, float u2) { if (output_triangles) { // System.out.println("TODO curveevaluator.mapgrid1f"); @@ -179,6 +184,7 @@ class GL2CurveEvaluator implements CurveEvaluator { * @param from lowest param * @param to highest param */ + @Override public void mapmesh1f(int style, int from, int to) { /* //DEBUG drawing control points this.poradi++; diff --git a/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GL2SurfaceEvaluator.java b/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GL2SurfaceEvaluator.java index 155c4f9a9..e9c9fca3f 100644 --- a/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GL2SurfaceEvaluator.java +++ b/src/jogl/classes/jogamp/opengl/glu/gl2/nurbs/GL2SurfaceEvaluator.java @@ -72,6 +72,7 @@ class GL2SurfaceEvaluator implements SurfaceEvaluator { /** * Pushes eval bit */ + @Override public void bgnmap2f() { if (output_triangles) { @@ -88,6 +89,7 @@ class GL2SurfaceEvaluator implements SurfaceEvaluator { * Sets glPolygonMode * @param style polygon mode (N_MESHFILL/N_MESHLINE/N_MESHPOINT) */ + @Override public void polymode(int style) { if (!output_triangles) { switch (style) { @@ -109,6 +111,7 @@ class GL2SurfaceEvaluator implements SurfaceEvaluator { /** * Pops all attributes */ + @Override public void endmap2f() { // TODO Auto-generated method stub if (output_triangles) { @@ -126,6 +129,7 @@ class GL2SurfaceEvaluator implements SurfaceEvaluator { * @param vlo * @param vhi */ + @Override public void domain2f(float ulo, float uhi, float vlo, float vhi) { // DONE } @@ -139,6 +143,7 @@ class GL2SurfaceEvaluator implements SurfaceEvaluator { * @param v0 lowest v * @param v1 highest v */ + @Override public void mapgrid2f(int nu, float u0, float u1, int nv, float v0, float v1) { if (output_triangles) { @@ -157,6 +162,7 @@ class GL2SurfaceEvaluator implements SurfaceEvaluator { * @param vmin minimum V * @param vmax maximum V */ + @Override public void mapmesh2f(int style, int umin, int umax, int vmin, int vmax) { if (output_triangles) { // System.out.println("TODO openglsurfaceavaluator.mapmesh2f output_triangles"); @@ -195,6 +201,7 @@ class GL2SurfaceEvaluator implements SurfaceEvaluator { * @param vorder surface order in v direction * @param pts control points */ + @Override public void map2f(int type, float ulo, float uhi, int ustride, int uorder, float vlo, float vhi, int vstride, int vorder, CArrayOfFloats pts) { // TODO Auto-generated method stub @@ -210,6 +217,7 @@ class GL2SurfaceEvaluator implements SurfaceEvaluator { * Calls opengl enable * @param type what to enable */ + @Override public void enable(int type) { //DONE gl.glEnable(type); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1010102.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1010102.java index 5269024b4..0c155ff96 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1010102.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1010102.java @@ -56,6 +56,7 @@ public class Extract1010102 implements Extract { public Extract1010102() { } + @Override public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { long uint = 0; @@ -76,6 +77,7 @@ public class Extract1010102 implements Extract { extractComponents[3] = (float)( ( uint & 0x00000003 ) ) / 3.0f; } + @Override public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1555rev.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1555rev.java index 6982931d3..5208ea537 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1555rev.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract1555rev.java @@ -56,6 +56,7 @@ public class Extract1555rev implements Extract { public Extract1555rev() { } + @Override public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { int ushort = 0; @@ -76,6 +77,7 @@ public class Extract1555rev implements Extract { extractComponents[3] = (float)( ( ushort & 0x8000 ) >> 15); } + @Override public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 00000000,00011111 == 0x001F // 00000011,11100000 == 0x03E0 diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract2101010rev.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract2101010rev.java index 1c7db6218..1bf8abcc3 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract2101010rev.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract2101010rev.java @@ -56,6 +56,7 @@ public class Extract2101010rev implements Extract { public Extract2101010rev() { } + @Override public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { long uint = 0; @@ -76,6 +77,7 @@ public class Extract2101010rev implements Extract { extractComponents[3] = (float)( ( uint & 0xC0000000 ) >> 30 ) / 3.0f; } + @Override public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract233rev.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract233rev.java index 672c86c32..c86b39e63 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract233rev.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract233rev.java @@ -56,6 +56,7 @@ public class Extract233rev implements Extract { public Extract233rev() { } + @Override public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { // 11100000 == 0xe0 // 00011100 == 0x1c @@ -66,6 +67,7 @@ public class Extract233rev implements Extract { extractComponents[2] = (float)((ubyte & 0xC0) >> 6) / 3.0f; } + @Override public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11100000 == 0xE0 // 00011100 == 0x1C diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract332.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract332.java index 6cdbc5cb0..706f0c3f2 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract332.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract332.java @@ -56,6 +56,7 @@ public class Extract332 implements Extract { public Extract332() { } + @Override public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { // 11100000 == 0xe0 // 00011100 == 0x1c @@ -66,6 +67,7 @@ public class Extract332 implements Extract { extractComponents[2] = (float)((ubyte & 0x03)) / 3.0f; } + @Override public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11100000 == 0xE0 // 00011100 == 0x1C diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444.java index b36b9fb82..182d66ce2 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444.java @@ -56,6 +56,7 @@ public class Extract4444 implements Extract { public Extract4444() { } + @Override public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { int ushort = 0; @@ -76,6 +77,7 @@ public class Extract4444 implements Extract { extractComponents[3] = (float)( ( ushort & 0x000F ) ) / 15.0f; } + @Override public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444rev.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444rev.java index b7a3ed55f..52ecdc17c 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444rev.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract4444rev.java @@ -56,6 +56,7 @@ public class Extract4444rev implements Extract { public Extract4444rev() { } + @Override public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { int ushort = 0; @@ -76,6 +77,7 @@ public class Extract4444rev implements Extract { extractComponents[3] = (float)( ( ushort & 0xF000 ) >> 12 ) / 15.0f; } + @Override public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract5551.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract5551.java index 4dc566b25..21f53aa1d 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract5551.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract5551.java @@ -56,6 +56,7 @@ public class Extract5551 implements Extract { public Extract5551() { } + @Override public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { int ushort = 0; @@ -76,6 +77,7 @@ public class Extract5551 implements Extract { extractComponents[3] = (float)( ( ushort & 0xF000 ) ); } + @Override public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565.java index e198e46d4..7408c45b2 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565.java @@ -56,6 +56,7 @@ public class Extract565 implements Extract { public Extract565() { } + @Override public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { int ushort = 0; @@ -74,6 +75,7 @@ public class Extract565 implements Extract { extractComponents[2] = (float)( ( ushort & 0x001F ) ) / 31.0f; } + @Override public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11111000,00000000 == 0xF800 // 00000111,11100000 == 0x07E0 diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565rev.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565rev.java index fe19540ee..adaafa7ea 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565rev.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract565rev.java @@ -56,6 +56,7 @@ public class Extract565rev implements Extract { public Extract565rev() { } + @Override public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { int ushort = 0; @@ -74,6 +75,7 @@ public class Extract565rev implements Extract { extractComponents[2] = (float)( ( ushort & 0xF800 ) >> 11 ) / 31.0f; } + @Override public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 00000000,00111111 == 0x001F // 00000111,11100000 == 0x07E0 diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888.java index 4602f2af9..be155d578 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888.java @@ -56,6 +56,7 @@ public class Extract8888 implements Extract { public Extract8888() { } + @Override public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { long uint = 0; @@ -76,6 +77,7 @@ public class Extract8888 implements Extract { extractComponents[3] = (float)( ( uint & 0x000000FF ) ) / 255.0f; } + @Override public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888rev.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888rev.java index 373cb102a..294e60e12 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888rev.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/Extract8888rev.java @@ -56,6 +56,7 @@ public class Extract8888rev implements Extract { public Extract8888rev() { } + @Override public void extract( boolean isSwap, ByteBuffer packedPixel, float[] extractComponents ) { long uint = 0; @@ -76,6 +77,7 @@ public class Extract8888rev implements Extract { extractComponents[3] = (float)( ( uint & 0xFF000000 ) >> 24 ) / 255.0f; } + @Override public void shove( float[] shoveComponents, int index, ByteBuffer packedPixel ) { // 11110000,00000000 == 0xF000 // 00001111,00000000 == 0x0F00 diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractFloat.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractFloat.java index ac0f2f290..1dd8bff8a 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractFloat.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractFloat.java @@ -56,6 +56,7 @@ public class ExtractFloat implements ExtractPrimitive { public ExtractFloat() { } + @Override public double extract( boolean isSwap, ByteBuffer data ) { float f = 0; if( isSwap ) { @@ -67,6 +68,7 @@ public class ExtractFloat implements ExtractPrimitive { return( f ); } + @Override public void shove( double value, int index, ByteBuffer data ) { assert(0.0 <= value && value < 1.0); data.asFloatBuffer().put( index, (float)value ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java index 399386e30..dcbe52a40 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSByte.java @@ -56,12 +56,14 @@ public class ExtractSByte implements ExtractPrimitive { public ExtractSByte() { } + @Override public double extract( boolean isSwap, ByteBuffer sbyte ) { byte b = sbyte.get(); assert( b <= 127 ); return( b ); } + @Override public void shove( double value, int index, ByteBuffer data ) { data.position( index ); data.put( (byte)value ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSInt.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSInt.java index be3fb3092..547bd944a 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSInt.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSInt.java @@ -56,6 +56,7 @@ public class ExtractSInt implements ExtractPrimitive { public ExtractSInt() { } + @Override public double extract( boolean isSwap, ByteBuffer uint ) { int i = 0; if( isSwap ) { @@ -67,6 +68,7 @@ public class ExtractSInt implements ExtractPrimitive { return( i ); } + @Override public void shove( double value, int index, ByteBuffer data ) { assert(0.0 <= value && value < Integer.MAX_VALUE); IntBuffer ib = data.asIntBuffer(); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSShort.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSShort.java index 1e123c9b4..7dc172976 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSShort.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractSShort.java @@ -56,6 +56,7 @@ public class ExtractSShort implements ExtractPrimitive { public ExtractSShort() { } + @Override public double extract( boolean isSwap, ByteBuffer ushort ) { short s = 0; if( isSwap ) { @@ -67,6 +68,7 @@ public class ExtractSShort implements ExtractPrimitive { return( s ); } + @Override public void shove( double value, int index, ByteBuffer data ) { assert(0.0 <= value && value < 32768.0); ShortBuffer sb = data.asShortBuffer(); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUByte.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUByte.java index 26ca5cd40..3e933811c 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUByte.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUByte.java @@ -56,12 +56,14 @@ public class ExtractUByte implements ExtractPrimitive { public ExtractUByte() { } + @Override public double extract( boolean isSwap, ByteBuffer ubyte ) { int i = 0x000000FF & ubyte.get(); assert( i <= 255 ); return( i ); } + @Override public void shove( double value, int index, ByteBuffer data ) { assert(0.0 <= value && value < 256.0); data.position( index ); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUInt.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUInt.java index 8c94c89fc..1c34828b3 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUInt.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUInt.java @@ -56,6 +56,7 @@ public class ExtractUInt implements ExtractPrimitive { public ExtractUInt() { } + @Override public double extract( boolean isSwap, ByteBuffer uint ) { long i = 0; if( isSwap ) { @@ -67,6 +68,7 @@ public class ExtractUInt implements ExtractPrimitive { return( i ); } + @Override public void shove( double value, int index, ByteBuffer data ) { assert(0.0 <= value && value < 0xFFFFFFFF); IntBuffer ib = data.asIntBuffer(); diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUShort.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUShort.java index 55115c6f7..8e0d25c42 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUShort.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ExtractUShort.java @@ -56,6 +56,7 @@ public class ExtractUShort implements ExtractPrimitive { public ExtractUShort() { } + @Override public double extract( boolean isSwap, ByteBuffer ushort ) { int i = 0; if( isSwap ) { @@ -67,6 +68,7 @@ public class ExtractUShort implements ExtractPrimitive { return( i ); } + @Override public void shove( double value, int index, ByteBuffer data ) { assert(0.0 <= value && value < 65536.0); ShortBuffer sb = data.asShortBuffer(); diff --git a/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQHeap.java b/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQHeap.java index 474056cc3..1ac0fd438 100644 --- a/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQHeap.java +++ b/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQHeap.java @@ -81,6 +81,7 @@ class PriorityQHeap extends jogamp.opengl.glu.tessellator.PriorityQ { } /* really __gl_pqHeapDeletePriorityQ */ + @Override void pqDeletePriorityQ() { handles = null; nodes = null; @@ -137,6 +138,7 @@ class PriorityQHeap extends jogamp.opengl.glu.tessellator.PriorityQ { } /* really __gl_pqHeapInit */ + @Override boolean pqInit() { int i; @@ -152,6 +154,7 @@ class PriorityQHeap extends jogamp.opengl.glu.tessellator.PriorityQ { /* really __gl_pqHeapInsert */ /* returns LONG_MAX iff out of memory */ + @Override int pqInsert(Object keyNew) { int curr; int free; @@ -207,6 +210,7 @@ class PriorityQHeap extends jogamp.opengl.glu.tessellator.PriorityQ { } /* really __gl_pqHeapExtractMin */ + @Override Object pqExtractMin() { jogamp.opengl.glu.tessellator.PriorityQ.PQnode[] n = nodes; jogamp.opengl.glu.tessellator.PriorityQ.PQhandleElem[] h = handles; @@ -229,6 +233,7 @@ class PriorityQHeap extends jogamp.opengl.glu.tessellator.PriorityQ { } /* really __gl_pqHeapDelete */ + @Override void pqDelete(int hCurr) { jogamp.opengl.glu.tessellator.PriorityQ.PQnode[] n = nodes; jogamp.opengl.glu.tessellator.PriorityQ.PQhandleElem[] h = handles; @@ -252,10 +257,12 @@ class PriorityQHeap extends jogamp.opengl.glu.tessellator.PriorityQ { freeList = hCurr; } + @Override Object pqMinimum() { return handles[nodes[1].handle].key; } + @Override boolean pqIsEmpty() { return size == 0; } diff --git a/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQSort.java b/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQSort.java index f9e0225e3..cf54b15c3 100644 --- a/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQSort.java +++ b/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQSort.java @@ -71,6 +71,7 @@ class PriorityQSort extends jogamp.opengl.glu.tessellator.PriorityQ { } /* really __gl_pqSortDeletePriorityQ */ + @Override void pqDeletePriorityQ() { if (heap != null) heap.pqDeletePriorityQ(); order = null; @@ -100,6 +101,7 @@ class PriorityQSort extends jogamp.opengl.glu.tessellator.PriorityQ { } /* really __gl_pqSortInit */ + @Override boolean pqInit() { int p, r, i, j; int piv; @@ -191,6 +193,7 @@ class PriorityQSort extends jogamp.opengl.glu.tessellator.PriorityQ { /* really __gl_pqSortInsert */ /* returns LONG_MAX iff out of memory */ + @Override int pqInsert(Object keyNew) { int curr; @@ -220,6 +223,7 @@ class PriorityQSort extends jogamp.opengl.glu.tessellator.PriorityQ { } /* really __gl_pqSortExtractMin */ + @Override Object pqExtractMin() { Object sortMin, heapMin; @@ -240,6 +244,7 @@ class PriorityQSort extends jogamp.opengl.glu.tessellator.PriorityQ { } /* really __gl_pqSortMinimum */ + @Override Object pqMinimum() { Object sortMin, heapMin; @@ -257,11 +262,13 @@ class PriorityQSort extends jogamp.opengl.glu.tessellator.PriorityQ { } /* really __gl_pqSortIsEmpty */ + @Override boolean pqIsEmpty() { return (size == 0) && heap.pqIsEmpty(); } /* really __gl_pqSortDelete */ + @Override void pqDelete(int curr) { if (curr >= 0) { heap.pqDelete(curr); diff --git a/src/jogl/classes/jogamp/opengl/glu/tessellator/Render.java b/src/jogl/classes/jogamp/opengl/glu/tessellator/Render.java index 1801e1c59..a2e973508 100644 --- a/src/jogl/classes/jogamp/opengl/glu/tessellator/Render.java +++ b/src/jogl/classes/jogamp/opengl/glu/tessellator/Render.java @@ -279,6 +279,7 @@ class Render { } private static class RenderTriangle implements renderCallBack { + @Override public void render(GLUtessellatorImpl tess, jogamp.opengl.glu.tessellator.GLUhalfEdge e, long size) { /* Just add the triangle to a triangle list, so we can render all * the separate triangles at once. @@ -323,6 +324,7 @@ class Render { } private static class RenderFan implements renderCallBack { + @Override public void render(GLUtessellatorImpl tess, jogamp.opengl.glu.tessellator.GLUhalfEdge e, long size) { /* Render as many CCW triangles as possible in a fan starting from * edge "e". The fan *should* contain exactly "size" triangles @@ -345,6 +347,7 @@ class Render { } private static class RenderStrip implements renderCallBack { + @Override public void render(GLUtessellatorImpl tess, jogamp.opengl.glu.tessellator.GLUhalfEdge e, long size) { /* Render as many CCW triangles as possible in a strip starting from * edge "e". The strip *should* contain exactly "size" triangles diff --git a/src/jogl/classes/jogamp/opengl/glu/tessellator/Sweep.java b/src/jogl/classes/jogamp/opengl/glu/tessellator/Sweep.java index b4a400c1c..364a7f198 100644 --- a/src/jogl/classes/jogamp/opengl/glu/tessellator/Sweep.java +++ b/src/jogl/classes/jogamp/opengl/glu/tessellator/Sweep.java @@ -1150,6 +1150,7 @@ class Sweep { */ { /* __gl_dictListNewDict */ tess.dict = Dict.dictNewDict(tess, new Dict.DictLeq() { + @Override public boolean leq(Object frame, Object key1, Object key2) { return EdgeLeq(tess, (ActiveRegion) key1, (ActiveRegion) key2); } @@ -1231,6 +1232,7 @@ class Sweep { /* __gl_pqSortNewPriorityQ */ pq = tess.pq = PriorityQ.pqNewPriorityQ(new PriorityQ.Leq() { + @Override public boolean leq(Object key1, Object key2) { return Geom.VertLeq(((GLUvertex) key1), (GLUvertex) key2); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 5cc4003fe..03aae3f78 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -822,6 +822,7 @@ public class MacOSXCGLContext extends GLContextImpl texID = fbod.getTextureBuffer(GL.GL_FRONT).getName(); pbufferHandle = 0; fbod.setSwapBufferContext(new GLFBODrawableImpl.SwapBufferContext() { + @Override public void swapBuffers(boolean doubleBuffered) { MacOSXCGLContext.NSOpenGLImpl.this.swapBuffers(); } } ) ; diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index 6f86e840b..994eee8d7 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -229,6 +229,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { } } + @Override protected final SharedResource getOrCreateSharedResourceImpl(AbstractGraphicsDevice adevice) { final String connection = adevice.getConnection(); SharedResource sr; diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java index 535c4d2d3..13e249a58 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java @@ -59,6 +59,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration super(screen, capsChosen, capsRequested); } + @Override public Object clone() { return super.clone(); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java index e761be7b7..db2a1df68 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java @@ -59,6 +59,7 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GLGraphicsConfigurati private MacOSXCGLGraphicsConfigurationFactory() { } + @Override protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java index c08259665..21923531f 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java @@ -63,6 +63,7 @@ public class MacOSXAWTCGLGraphicsConfigurationFactory extends GLGraphicsConfigur private MacOSXAWTCGLGraphicsConfigurationFactory() { } + @Override protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { diff --git a/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java index 5f9b25530..0d4452864 100644 --- a/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java +++ b/src/jogl/classes/jogamp/opengl/util/GLArrayHandlerInterleaved.java @@ -46,12 +46,14 @@ public class GLArrayHandlerInterleaved extends GLVBOArrayHandler implements GLAr super(ad); } + @Override public final void setSubArrayVBOName(int vboName) { for(int i=0; i() { + @Override public DynamicLibraryBundle run() { return new DynamicLibraryBundle(new FFMPEGDynamicLibraryBundleInfo()); } } ); @@ -272,6 +273,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { // lookup AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { for(int i = 0; i() { + @Override public Object run() { final ProcAddressTable pt = ctx.getGLProcAddressTable(); final long procAddrGLTexSubImage2D = pt.getAddressFor("glTexSubImage2D"); diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java index 2d74fa532..3b443fdd0 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java @@ -50,14 +50,17 @@ public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandle super(ad); } + @Override public final void setSubArrayVBOName(int vboName) { throw new UnsupportedOperationException(); } + @Override public final void addSubHandler(GLArrayHandlerFlat handler) { throw new UnsupportedOperationException(); } + @Override public final void enableState(GL gl, boolean enable, Object ext) { final GL2ES2 glsl = gl.getGL2ES2(); if( null != ext ) { diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java index a5f78b5d6..34a381d7d 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java @@ -47,10 +47,12 @@ public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat { this.ad = ad; } + @Override public GLArrayDataWrapper getData() { return ad; } + @Override public final void syncData(GL gl, Object ext) { final GL2ES2 glsl = gl.getGL2ES2(); if( null != ext ) { @@ -77,6 +79,7 @@ public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat { }*/ } + @Override public final void enableState(GL gl, boolean enable, Object ext) { final GL2ES2 glsl = gl.getGL2ES2(); if( null != ext ) { diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java index bcc146d78..b175bb5dc 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java @@ -50,12 +50,14 @@ public class GLSLArrayHandlerInterleaved extends GLVBOArrayHandler implements GL super(ad); } + @Override public final void setSubArrayVBOName(int vboName) { for(int i=0; i 0) { eobrun--; @@ -1288,6 +1299,7 @@ public class JPEGDecoder { } } class ACSuccessiveDecoder implements DecoderFunction { + @Override public void decode(ComponentIn component, int[] zz) throws IOException { int k = spectralStart, e = spectralEnd, r = 0; while (k <= e) { diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java index 906ce6373..e6afd8694 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java @@ -315,6 +315,7 @@ public class ImageLine { /** * Basic info */ + @Override public String toString() { return "row=" + rown + " cols=" + imgInfo.cols + " bpc=" + imgInfo.bitDepth + " size=" + scanline.length; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java index 438a69984..4636c3955 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java @@ -92,6 +92,7 @@ public class ImageLineHelper { public double[] maxdif = { BIG_VALUE_NEG, BIG_VALUE_NEG, BIG_VALUE_NEG, BIG_VALUE }; // maxima public final int channels; // diferencia + @Override public String toString() { return channels == 3 ? String.format( "prom=%.1f (%.1f %.1f %.1f) max=%.1f (%.1f %.1f %.1f) min=%.1f (%.1f %.1f %.1f)", promlum, prom[0], diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java index 1f598a5de..9e64c3eb1 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java @@ -186,6 +186,7 @@ public class PngHelperInternal { } private static final ThreadLocal crcProvider = new ThreadLocal() { + @Override protected CRC32 initialValue() { return new CRC32(); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java index 73442e0bb..0412beb8c 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java @@ -994,6 +994,7 @@ public class PngReader { /** * Basic info, for debugging. */ + @Override public String toString() { // basic info return "filename=" + filename + " " + imgInfo.toString(); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java index 82abb902d..4e8bf5635 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java @@ -47,12 +47,14 @@ public class ChunkHelper { public static final String zTXt = "zTXt"; private static final ThreadLocal inflaterProvider = new ThreadLocal() { + @Override protected Inflater initialValue() { return new Inflater(); } }; private static final ThreadLocal deflaterProvider = new ThreadLocal() { + @Override protected Deflater initialValue() { return new Deflater(); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java index 3aba26cca..dcb1958df 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java @@ -108,6 +108,7 @@ public class ChunkRaw { return new ByteArrayInputStream(data); } + @Override public String toString() { return "chunkid=" + ChunkHelper.toString(idbytes) + " len=" + len; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java index 3e0d03051..75107d761 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java @@ -59,12 +59,14 @@ public class ChunksList { protected static List getXById(final List list, final String id, final String innerid) { if (innerid == null) return ChunkHelper.filterList(list, new ChunkPredicate() { + @Override public boolean match(PngChunk c) { return c.id.equals(id); } }); else return ChunkHelper.filterList(list, new ChunkPredicate() { + @Override public boolean match(PngChunk c) { if (!c.id.equals(id)) return false; @@ -152,12 +154,14 @@ public class ChunksList { */ public List getEquivalent(final PngChunk c2) { return ChunkHelper.filterList(chunks, new ChunkPredicate() { + @Override public boolean match(PngChunk c) { return ChunkHelper.equivalent(c, c2); } }); } + @Override public String toString() { return "ChunkList: read: " + chunks.size(); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java index 3b84ab800..c502e9071 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java @@ -149,6 +149,7 @@ public class ChunksListForWrite extends ChunksList { return queuedChunks; } + @Override public String toString() { return "ChunkList: written: " + chunks.size() + " queue: " + queuedChunks.size(); } @@ -156,6 +157,7 @@ public class ChunksListForWrite extends ChunksList { /** * for debugging */ + @Override public String toStringFull() { StringBuilder sb = new StringBuilder(toString()); sb.append("\n Written:\n"); diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java index 5247169e0..7df5ba021 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java @@ -12,6 +12,7 @@ public abstract class PngChunkSingle extends PngChunk { super(id, imgInfo); } + @Override public final boolean allowsMultiple() { return false; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java index fa3649613..139603448 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java @@ -41,6 +41,7 @@ public class PngMetadata { throw new PngjException("cannot set chunk : readonly metadata"); if (lazyOverwrite) { ChunkHelper.trimList(cl.getQueuedChunks(), new ChunkPredicate() { + @Override public boolean match(PngChunk c2) { return ChunkHelper.equivalent(c, c2); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 203af110c..95485b033 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -92,6 +92,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { synchronized(WindowsWGLDrawableFactory.class) { if( null == windowsWGLDynamicLookupHelper ) { windowsWGLDynamicLookupHelper = AccessController.doPrivileged(new PrivilegedAction() { + @Override public DesktopGLDynamicLookupHelper run() { DesktopGLDynamicLookupHelper tmp; try { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java index cb445f005..5f2b0c227 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -119,6 +119,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio return cfg; } + @Override public Object clone() { return super.clone(); } @@ -715,6 +716,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio return createPixelFormatDescriptor(0, 0); } + @Override public String toString() { return "WindowsWGLGraphicsConfiguration["+getScreen()+", pfdID " + getPixelFormatID() + ", ARB-Choosen " + isChoosenByARB() + ",\n\trequested " + getRequestedCapabilities() + diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index 9e917a0eb..961295208 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -79,6 +79,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat private WindowsWGLGraphicsConfigurationFactory() { } + @Override protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java index ddfcbb55b..96bd0bdd0 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java @@ -68,6 +68,7 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu private WindowsAWTWGLGraphicsConfigurationFactory() { } + @Override protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 3f0841b6c..78e549508 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -95,6 +95,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { synchronized(X11GLXDrawableFactory.class) { if( null == x11GLXDynamicLookupHelper ) { x11GLXDynamicLookupHelper = AccessController.doPrivileged(new PrivilegedAction() { + @Override public DesktopGLDynamicLookupHelper run() { DesktopGLDynamicLookupHelper tmp; try { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java index 5aea33f21..4d1ed3985 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java @@ -69,6 +69,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem this.chooser=chooser; } + @Override public Object clone() { return super.clone(); } @@ -478,6 +479,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem return tmp.get(tmp.position()); } + @Override public String toString() { return "X11GLXGraphicsConfiguration["+getScreen()+", visualID " + toHexString(getXVisualID()) + ", fbConfigID " + toHexString(getFBConfigID()) + ",\n\trequested " + getRequestedCapabilities()+ diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java index abe310a3f..6050dabbb 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -92,6 +92,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF private X11GLXGraphicsConfigurationFactory() { } + @Override protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { if (!(absScreen instanceof X11GraphicsScreen)) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java index 15f3355d0..aa9b876dd 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsConfiguration.java @@ -109,6 +109,7 @@ public class AWTGraphicsConfiguration extends DefaultGraphicsConfiguration imple } // open access to superclass method + @Override public void setChosenCapabilities(CapabilitiesImmutable capsChosen) { super.setChosenCapabilities(capsChosen); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java index d3cf5bff6..83d6efa75 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTGraphicsScreen.java @@ -87,6 +87,7 @@ public class AWTGraphicsScreen extends DefaultGraphicsScreen implements Cloneabl return new AWTGraphicsScreen(AWTGraphicsDevice.createDefault()); } + @Override public Object clone() { return super.clone(); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java index e350aaff4..27275c6e0 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java @@ -119,6 +119,7 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol { * otherwise return the AWT/Swing close operation value translated to * a {@link WindowClosingProtocol} value . */ + @Override public final WindowClosingMode getDefaultCloseOperation() { synchronized(closingListenerLock) { if(defaultCloseOperationSetByUser) { @@ -129,6 +130,7 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol { return AWTMisc.getNWClosingOperation(comp); } + @Override public final WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { synchronized(closingListenerLock) { final WindowClosingMode _op = defaultCloseOperation; diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java index e4d3884a7..c02fc0a04 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java @@ -247,6 +247,7 @@ public final class DirectDataBufferInt extends DataBuffer { * @see #setElem(int, int) * @see #setElem(int, int, int) */ + @Override public int getElem(int i) { return data.get(i+offset); } @@ -260,6 +261,7 @@ public final class DirectDataBufferInt extends DataBuffer { * @see #setElem(int, int) * @see #setElem(int, int, int) */ + @Override public int getElem(int bank, int i) { return bankdata[bank].get(i+offsets[bank]); } @@ -273,6 +275,7 @@ public final class DirectDataBufferInt extends DataBuffer { * @see #getElem(int) * @see #getElem(int, int) */ + @Override public void setElem(int i, int val) { data.put(i+offset, val); } @@ -286,6 +289,7 @@ public final class DirectDataBufferInt extends DataBuffer { * @see #getElem(int) * @see #getElem(int, int) */ + @Override public void setElem(int bank, int i, int val) { bankdata[bank].put(i+offsets[bank], val); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java index 89df7f853..99ca006fa 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/macosx/MacOSXGraphicsDevice.java @@ -43,6 +43,7 @@ public class MacOSXGraphicsDevice extends DefaultGraphicsDevice implements Clone super(NativeWindowFactory.TYPE_MACOSX, AbstractGraphicsDevice.DEFAULT_CONNECTION, unitID); } + @Override public Object clone() { return super.clone(); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 6057f6700..361d61c65 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -122,6 +122,7 @@ public class SWTAccessor { static { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { NativeWindowFactory.initSingleton(); // last resort .. return null; @@ -360,6 +361,7 @@ public class SWTAccessor { if(null != OS_gtk_class) { invoke(true, new Runnable() { + @Override public void run() { if(realize) { callStaticMethodL2V(OS_gtk_widget_realize, handle); @@ -434,6 +436,7 @@ public class SWTAccessor { public static long newGC(final Control swtControl, final GCData gcData) { final Object[] o = new Object[1]; invoke(true, new Runnable() { + @Override public void run() { o[0] = ReflectionUtil.callMethod(swtControl, swt_control_internal_new_GC, new Object[] { gcData }); } @@ -447,6 +450,7 @@ public class SWTAccessor { public static void disposeGC(final Control swtControl, final long gc, final GCData gcData) { invoke(true, new Runnable() { + @Override public void run() { if(swt_uses_long_handles) { ReflectionUtil.callMethod(swtControl, swt_control_internal_dispose_GC, new Object[] { new Long(gc), gcData }); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java index 7468d254b..643982715 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/windows/WindowsGraphicsDevice.java @@ -47,6 +47,7 @@ public class WindowsGraphicsDevice extends DefaultGraphicsDevice implements Clon super(NativeWindowFactory.TYPE_WINDOWS, connection, unitID); } + @Override public Object clone() { return super.clone(); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java index 8aac7095a..700937829 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java @@ -63,6 +63,7 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl return X11Lib.DefaultVisualID(getDevice().getHandle(), getIndex()); } + @Override public Object clone() { return super.clone(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java index 6095db052..77cbe2995 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java @@ -76,6 +76,7 @@ public class DefaultCapabilitiesChooser implements CapabilitiesChooser { private final static int NO_SCORE = -9999999; private final static int COLOR_MISMATCH_PENALTY_SCALE = 36; + @Override public int chooseCapabilities(final CapabilitiesImmutable desired, final List available, final int windowSystemRecommendedChoice) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java index 3e32f30df..42d7f3a23 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java @@ -69,18 +69,22 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics } } + @Override final public AbstractGraphicsScreen getScreen() { return screen; } + @Override final public CapabilitiesImmutable getChosenCapabilities() { return capabilitiesChosen; } + @Override final public CapabilitiesImmutable getRequestedCapabilities() { return capabilitiesRequested; } + @Override public AbstractGraphicsConfiguration getNativeGraphicsConfiguration() { return this; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java index ffcad235c..4bd548916 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java @@ -54,10 +54,12 @@ public class DefaultGraphicsScreen implements Cloneable, AbstractGraphicsScreen } } + @Override public AbstractGraphicsDevice getDevice() { return device; } + @Override public int getIndex() { return idx; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java index e1aa91959..c09e6eaa4 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java @@ -80,10 +80,12 @@ public abstract class GraphicsConfigurationFactory { this.hash32 = hash32; } + @Override public final int hashCode() { return hash32; } + @Override public final boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof DeviceCapsType) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index bad72f355..6962ce505 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -123,6 +123,7 @@ public abstract class NativeWindowFactory { return AccessController.doPrivileged(new PrivilegedAction() { private final File vcliblocation = new File( "/opt/vc/lib/libbcm_host.so"); + @Override public Boolean run() { if ( vcliblocation.isFile() ) { return Boolean.TRUE; @@ -160,12 +161,14 @@ public abstract class NativeWindowFactory { final String[] _tmp = new String[] { null }; AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { Platform.initSingleton(); // last resort .. _DEBUG[0] = Debug.debug("NativeWindow"); _tmp[0] = Debug.getProperty("nativewindow.ws.name", true); Runtime.getRuntime().addShutdownHook( new Thread(new Runnable() { + @Override public void run() { NativeWindowFactory.shutdown(true); } }, "NativeWindowFactory_ShutdownHook" ) ) ; @@ -318,6 +321,7 @@ public abstract class NativeWindowFactory { ReflectionUtil.isClassAvailable("com.jogamp.nativewindow.awt.AWTGraphicsDevice", cl) ) { Method[] jawtUtilMethods = AccessController.doPrivileged(new PrivilegedAction() { + @Override public Method[] run() { try { Class _jawtUtilClass = Class.forName(JAWTUtilClassName, true, NativeWindowFactory.class.getClassLoader()); diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java index eb0a6cf04..0af2bdaf9 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java @@ -122,5 +122,6 @@ public interface ProxySurface extends MutableSurface { public void clearUpstreamOptionBits(int v); public StringBuilder toString(StringBuilder sink); + @Override public String toString(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java b/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java index 4ee71ee79..4ed79b1dc 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java +++ b/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java @@ -120,6 +120,7 @@ public interface VisualIDHolder { this.type = type; } + @Override public int compare(VisualIDHolder vid1, VisualIDHolder vid2) { final int id1 = vid1.getVisualID(type); final int id2 = vid2.getVisualID(type); diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index b8b48a46c..b8dc53c83 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -45,10 +45,12 @@ public class Dimension implements Cloneable, DimensionImmutable { this.height=height; } + @Override public Object cloneMutable() { return clone(); } + @Override public Object clone() { try { return super.clone(); diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java index 9caa433a6..e6cacf4ff 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java @@ -59,8 +59,10 @@ public interface DimensionImmutable extends WriteCloneable, Comparabletrue if the two dimensions are equal; * otherwise false. */ + @Override boolean equals(Object obj); + @Override int hashCode(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java index dbd997c60..c84359dcd 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java @@ -45,10 +45,12 @@ public class Insets implements Cloneable, InsetsImmutable { this.b=bottom; } + @Override public Object cloneMutable() { return clone(); } + @Override protected Object clone() { try { return super.clone(); @@ -99,6 +101,7 @@ public class Insets implements Cloneable, InsetsImmutable { return sum3 * (sum3 + 1)/2 + val2; } + @Override public String toString() { return new String("[ l "+l+", r "+r+" - t "+t+", b "+b+" - "+getTotalWidth()+"x"+getTotalHeight()+"]"); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java index 0f99a7861..8256068cd 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java @@ -59,8 +59,10 @@ public interface InsetsImmutable extends WriteCloneable { * @return true if the two Insets are equal; * otherwise false. */ + @Override boolean equals(Object obj); + @Override int hashCode(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index aba515d52..57c6fb716 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -42,10 +42,12 @@ public class Point implements Cloneable, PointImmutable { this(0, 0); } + @Override public Object cloneMutable() { return clone(); } + @Override public Object clone() { try { return super.clone(); @@ -95,6 +97,7 @@ public class Point implements Cloneable, PointImmutable { return hash; } + @Override public String toString() { return new String( x + " / " + y ); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java index f5377e059..08c628cc1 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java @@ -54,8 +54,10 @@ public interface PointImmutable extends WriteCloneable, Comparabletrue if the two points are equal; * otherwise false. */ + @Override public boolean equals(Object obj); + @Override public int hashCode(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index 3a51fb67d..8dc8f4562 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -47,10 +47,12 @@ public class Rectangle implements Cloneable, RectangleImmutable { this.height=height; } + @Override public Object cloneMutable() { return clone(); } + @Override protected Object clone() { try { return super.clone(); @@ -191,6 +193,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { return sum3 * (sum3 + 1)/2 + val2; } + @Override public String toString() { return new String("[ "+x+" / "+y+" "+width+" x "+height+" ]"); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java index ce735f53f..7ca92ff53 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java @@ -78,8 +78,10 @@ public interface RectangleImmutable extends WriteCloneable, Comparabletrue if the two rectangles are equal; * otherwise false. */ + @Override boolean equals(Object obj); + @Override int hashCode(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java index 917f7e230..f1749dfa6 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java @@ -56,6 +56,7 @@ public class SurfaceSize implements Comparable { return bitsPerPixel; } + @Override public final String toString() { return new String("[ "+resolution+" x "+bitsPerPixel+" bpp ]"); } @@ -89,6 +90,7 @@ public class SurfaceSize implements Comparable { * @return true if the two dimensions are equal; * otherwise false. */ + @Override public final boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof SurfaceSize) { @@ -99,6 +101,7 @@ public class SurfaceSize implements Comparable { return false; } + @Override public final int hashCode() { // 31 * x == (x << 5) - x int hash = 31 + getResolution().hashCode(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/Debug.java b/src/nativewindow/classes/jogamp/nativewindow/Debug.java index a7bf536ec..b7197dbca 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/Debug.java +++ b/src/nativewindow/classes/jogamp/nativewindow/Debug.java @@ -54,6 +54,7 @@ public class Debug extends PropertyAccess { static { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { PropertyAccess.addTrustedPrefix("nativewindow."); return null; diff --git a/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java index b3b5d2131..8fb819251 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/DefaultGraphicsConfigurationFactoryImpl.java @@ -36,6 +36,7 @@ package jogamp.nativewindow; import javax.media.nativewindow.*; public class DefaultGraphicsConfigurationFactoryImpl extends GraphicsConfigurationFactory { + @Override protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen screen, int nativeVisualID) { return new DefaultGraphicsConfiguration(screen, capsChosen, capsRequested); diff --git a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java index 5fdbbf697..cadef9bf1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java @@ -72,6 +72,7 @@ public class GlobalToolkitLock implements ToolkitLock { // nop } + @Override public String toString() { return "GlobalToolkitLock[obj 0x"+Integer.toHexString(hashCode())+", isOwner "+globalLock.isOwner(Thread.currentThread())+", "+globalLock.toString()+"]"; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java index 36a25acfb..e7eb13756 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java @@ -39,6 +39,7 @@ import com.jogamp.common.util.cache.TempJarCache; public class NWJNILibLoader extends JNILibLoaderBase { public static boolean loadNativeWindow(final String ossuffix) { return AccessController.doPrivileged(new PrivilegedAction() { + @Override public Boolean run() { Platform.initSingleton(); final String libName = "nativewindow_"+ossuffix ; diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java index e3f6ab5ca..22ac3bd94 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java @@ -51,6 +51,7 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { // This subclass of NativeWindowFactory handles the case of // NativeWindows being passed in + @Override protected NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config) throws IllegalArgumentException { if (winObj instanceof NativeWindow) { // Use the NativeWindow directly diff --git a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java index d8ce98acb..bda20522c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java @@ -64,6 +64,7 @@ public class NullToolkitLock implements ToolkitLock { // nop } + @Override public String toString() { return "NullToolkitLock[]"; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java index 8a1048c6f..097fffead 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java @@ -253,6 +253,7 @@ public abstract class ProxySurfaceImpl implements ProxySurface { return surfaceLock.getOwner(); } + @Override public final StringBuilder getUpstreamOptionBits(StringBuilder sink) { if(null == sink) { sink = new StringBuilder(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java index 51dd58543..f1efb8133 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java @@ -73,6 +73,7 @@ public class ResourceToolkitLock implements ToolkitLock { // nop } + @Override public String toString() { return "ResourceToolkitLock[obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString()+"]"; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java index e20d3d138..7b74e1f1f 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java @@ -142,6 +142,7 @@ public class SharedResourceToolkitLock implements ToolkitLock { } } + @Override public String toString() { return "SharedResourceToolkitLock[refCount "+refCount+", handle 0x"+Long.toHexString(handle)+", obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString()+"]"; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java index d11e240fa..1e83232bb 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java @@ -74,6 +74,7 @@ public class SurfaceUpdatedHelper implements SurfaceUpdatedListener { } } + @Override public void surfaceUpdated(Object updater, NativeSurface ns, long when) { synchronized(surfaceUpdatedListenersLock) { for(int i = 0; i < surfaceUpdatedListeners.size(); i++ ) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java index 815facbee..a5da41424 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTJNILibLoader.java @@ -50,6 +50,7 @@ import java.security.PrivilegedAction; public class JAWTJNILibLoader extends NWJNILibLoader { static { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { // Make sure that awt.dll is loaded before loading jawt.dll. Otherwise // a Dialog with "awt.dll not found" might pop up. diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index 32946fe2d..5a1d915ce 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -320,6 +320,7 @@ public class JAWTUtil { j2dExist = ok; PrivilegedDataBlob1 pdb1 = (PrivilegedDataBlob1) AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { PrivilegedDataBlob1 d = new PrivilegedDataBlob1(); try { @@ -352,9 +353,11 @@ public class JAWTUtil { jawtLock = LockFactory.createRecursiveLock(); jawtToolkitLock = new ToolkitLock() { + @Override public final void lock() { JAWTUtil.lockToolkit(); } + @Override public final void unlock() { JAWTUtil.unlockToolkit(); } @@ -380,6 +383,7 @@ public class JAWTUtil { } else { final ArrayList> desktophintsBucket = new ArrayList>(1); EventQueue.invokeAndWait(new Runnable() { + @Override public void run() { Map _desktophints = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); if(null!=_desktophints) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 87e3d3dd8..600aa6cb2 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -88,6 +88,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.DestroyNSWindow(windowHandle); } OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { if( 0 != rootSurfaceLayer ) { if( 0 != jawtSurfaceLayersHandle) { @@ -106,6 +107,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { @Override protected void attachSurfaceLayerImpl(final long layerHandle) { OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { // AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets. // Determine p0: components location on screen w/o insets. @@ -167,6 +169,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { @Override protected void detachSurfaceLayerImpl(final long layerHandle, final Runnable detachNotify) { OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { detachNotify.run(); OSXUtil.RemoveCASublayer(rootSurfaceLayer, layerHandle); @@ -183,6 +186,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { return offscreenSurfaceDrawableSet ? offscreenSurfaceDrawable : drawable /* super.getSurfaceHandle() */ ; } + @Override public void setSurfaceHandle(long surfaceHandle) { if( !isOffscreenLayerSurfaceEnabled() ) { throw new java.lang.UnsupportedOperationException("Not using CALAYER"); @@ -194,11 +198,13 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { this.offscreenSurfaceDrawableSet = true; } + @Override protected JAWT fetchJAWTImpl() throws NativeWindowException { // use offscreen if supported and [ applet or requested ] return JAWTUtil.getJAWT(getShallUseOffscreenLayer() || isApplet()); } + @Override protected int lockSurfaceImpl() throws NativeWindowException { int ret = NativeWindow.LOCK_SURFACE_NOT_READY; ds = getJAWT().GetDrawingSurface(component); @@ -223,6 +229,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } if (firstLock) { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { dsi = ds.GetDrawingSurfaceInfo(); return null; @@ -284,6 +291,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if(null == errMsg) { jawtSurfaceLayersHandle = GetJAWTSurfaceLayersHandle0(dsi.getBuffer()); OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { String errMsg = null; if(0 == rootSurfaceLayer && 0 != jawtSurfaceLayersHandle) { @@ -322,6 +330,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { return ret; } + @Override protected void unlockSurfaceImpl() throws NativeWindowException { if(null!=ds) { if (null!=dsi) { @@ -362,6 +371,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { getLocationOnScreenNonBlocking(storage, component); return storage; } + @Override protected Point getLocationOnScreenNativeImpl(final int x0, final int y0) { return null; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java index 876531151..8b9dfabfd 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/Win32SunJDKReflection.java @@ -65,6 +65,7 @@ public class Win32SunJDKReflection { static { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { try { win32GraphicsDeviceClass = Class.forName("sun.awt.Win32GraphicsDevice"); diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java index 64e177155..54bdb34f6 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/windows/WindowsJAWTWindow.java @@ -60,14 +60,17 @@ public class WindowsJAWTWindow extends JAWTWindow { super(comp, config); } + @Override protected void invalidateNative() { windowHandle = 0; } + @Override protected JAWT fetchJAWTImpl() throws NativeWindowException { return JAWTUtil.getJAWT(false); // no offscreen } + @Override protected int lockSurfaceImpl() throws NativeWindowException { int ret = NativeWindow.LOCK_SUCCESS; ds = getJAWT().GetDrawingSurface(component); @@ -110,6 +113,7 @@ public class WindowsJAWTWindow extends JAWTWindow { return ret; } + @Override protected void unlockSurfaceImpl() throws NativeWindowException { drawable = 0; // invalid HDC if(null!=ds) { @@ -131,6 +135,7 @@ public class WindowsJAWTWindow extends JAWTWindow { return windowHandle; } + @Override protected Point getLocationOnScreenNativeImpl(int x, int y) { return GDIUtil.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java index b08a7d83a..4599b9021 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java @@ -57,12 +57,15 @@ public class X11JAWTWindow extends JAWTWindow { super(comp, config); } + @Override protected void invalidateNative() { } + @Override protected JAWT fetchJAWTImpl() throws NativeWindowException { return JAWTUtil.getJAWT(false); // no offscreen } + @Override protected int lockSurfaceImpl() throws NativeWindowException { int ret = NativeWindow.LOCK_SUCCESS; ds = getJAWT().GetDrawingSurface(component); @@ -104,6 +107,7 @@ public class X11JAWTWindow extends JAWTWindow { return ret; } + @Override protected void unlockSurfaceImpl() throws NativeWindowException { if(null!=ds) { if (null!=dsi) { @@ -119,6 +123,7 @@ public class X11JAWTWindow extends JAWTWindow { x11dsi = null; } + @Override protected Point getLocationOnScreenNativeImpl(int x, int y) { // surface is locked and hence the device return X11Lib.GetRelativeLocation(getDisplayHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java index f1104d02f..b2c3a931b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11SunJDKReflection.java @@ -65,6 +65,7 @@ public class X11SunJDKReflection { static { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { try { x11GraphicsDeviceClass = Class.forName("sun.awt.X11GraphicsDevice"); diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 004a91a42..bac07b85a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -271,7 +271,7 @@ public class OSXUtil implements ToolkitProperties { RunLater0(onMain, new RunnableTask( runnable, null, true, System.err ), delay); } - private static Runnable _nop = new Runnable() { public void run() {}; }; + private static Runnable _nop = new Runnable() { @Override public void run() {}; }; /** Issues a {@link #RunOnMainThread(boolean, Runnable)} w/ an NOP runnable, while waiting until done. */ public static void WaitUntilFinish() { diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java index d6e7b5970..6258632cd 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java @@ -51,6 +51,7 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor private X11GraphicsConfigurationFactory() { } + @Override protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen screen, int nativeVisualID) throws IllegalArgumentException, NativeWindowException { diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 6431fb3f5..2576c7db1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -300,10 +300,12 @@ public class X11Util implements ToolkitProperties { } } + @Override public final int hashCode() { return hash32; } + @Override public final boolean equals(Object obj) { if(this == obj) { return true; } if(obj instanceof NamedDisplay) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java index 7b37d3cca..062040232 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java @@ -66,6 +66,7 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac private X11AWTGraphicsConfigurationFactory() { } + @Override protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl( CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID) { diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 83383d23c..a0a098481 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -41,9 +41,11 @@ public abstract class Display { public static final boolean DEBUG = Debug.debug("Display"); /** return precomputed hashCode from FQN {@link #getFQName()} */ + @Override public abstract int hashCode(); /** return true if obj is of type Display and both FQN {@link #getFQName()} equals */ + @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof Display) { diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index 625a7b39f..28d9f53a1 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -87,6 +87,7 @@ public abstract class MonitorDevice { * *
                      */ + @Override public final boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof MonitorDevice) { @@ -102,6 +103,7 @@ public abstract class MonitorDevice { *
                    • nativeID
                    • * */ + @Override public final int hashCode() { return nativeId; } @@ -228,6 +230,7 @@ public abstract class MonitorDevice { */ public abstract boolean setCurrentMode(MonitorMode mode); + @Override public String toString() { return "Monitor[Id "+Display.toHexString(nativeId)+", "+sizeMM+" mm, viewport "+viewport+ ", orig "+originalMode+", curr "+currentMode+ ", modeChanged "+modeChanged+", modeCount "+supportedModes.size()+"]"; diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java index 175d6e5f2..59f28e791 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorMode.java +++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java @@ -114,12 +114,14 @@ public class MonitorMode implements Comparable { /** Comparator for 2 {@link MonitorMode}s, following comparison order as described in {@link MonitorMode#compareTo(MonitorMode)}, returning the ascending order. */ public static final Comparator monitorModeComparator = new Comparator() { + @Override public int compare(MonitorMode mm1, MonitorMode mm2) { return mm1.compareTo(mm2); } }; /** Comparator for 2 {@link MonitorMode}s, following comparison order as described in {@link MonitorMode#compareTo(MonitorMode)}, returning the descending order. */ public static final Comparator monitorModeComparatorInv = new Comparator() { + @Override public int compare(MonitorMode mm1, MonitorMode mm2) { return mm2.compareTo(mm1); } }; @@ -172,6 +174,7 @@ public class MonitorMode implements Comparable { } return sb; } + @Override public final String toString() { return new String(surfaceSize+" @ "+refreshRate+" Hz, flags ["+flags2String(flags).toString()+"]"); } @@ -228,6 +231,7 @@ public class MonitorMode implements Comparable { *
                    • flags
                    • * */ + @Override public final boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof SizeAndRRate) { @@ -247,6 +251,7 @@ public class MonitorMode implements Comparable { *
                    • refreshRate
                    • * */ + @Override public final int hashCode() { return hashCode; } @@ -360,6 +365,7 @@ public class MonitorMode implements Comparable { return getRotatedWH(false); } + @Override public final String toString() { return "[Id "+Display.toHexString(nativeId)+", " + sizeAndRRate + ", " + rotation + " degr]"; } @@ -409,6 +415,7 @@ public class MonitorMode implements Comparable { *
                    • rotation
                    • * */ + @Override public final boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof MonitorMode) { @@ -428,6 +435,7 @@ public class MonitorMode implements Comparable { *
                    • rotation
                    • * */ + @Override public final int hashCode() { return hashCode; } diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 7116877a3..5ae3f3692 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -56,6 +56,7 @@ public class NewtFactory { static { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { NativeWindowFactory.initSingleton(); // last resort .. diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index 1274b3459..ef62ec95d 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -53,9 +53,11 @@ public abstract class Screen { public static final boolean DEBUG = Debug.debug("Screen"); /** return precomputed hashCode from FQN {@link #getFQName()} */ + @Override public abstract int hashCode(); /** return true if obj is of type Display and both FQN {@link #getFQName()} equals */ + @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof Screen) { diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index de1b7224f..1f5c26f27 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -107,10 +107,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { + @Override public void run() { NewtCanvasAWT.this.destroyImpl(false /* removeNotify */, true /* windowClosing */); } }, new Runnable() { + @Override public void run() { if( newtChild != null ) { newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); @@ -148,14 +150,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto setNEWTChild(child); } + @Override public void setShallUseOffscreenLayer(boolean v) { shallUseOffscreenLayer = v; } + @Override public final boolean getShallUseOffscreenLayer() { return shallUseOffscreenLayer; } + @Override public final boolean isOffscreenLayerSurfaceEnabled() { return jawtWindow.isOffscreenLayerSurfaceEnabled(); } @@ -178,6 +183,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } class FocusAction implements Window.FocusRunnable { + @Override public boolean run() { final boolean isParent = isParent(); final boolean isFullscreen = isFullscreen(); @@ -214,11 +220,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto }; class FocusTraversalKeyListener implements KeyListener { + @Override public void keyPressed(KeyEvent e) { if( isParent() && !isFullscreen() ) { handleKey(e, false); } } + @Override public void keyReleased(KeyEvent e) { if( isParent() && !isFullscreen() ) { handleKey(e, true); @@ -263,6 +271,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final FocusTraversalKeyListener newtFocusTraversalKeyListener = new FocusTraversalKeyListener(); class FocusPropertyChangeListener implements PropertyChangeListener { + @Override public void propertyChange(PropertyChangeEvent evt) { final Object oldF = evt.getOldValue(); final Object newF = evt.getNewValue(); @@ -358,10 +367,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto * or {@link #addNotify()} hasn't been called yet.*/ public NativeWindow getNativeWindow() { return jawtWindow; } + @Override public WindowClosingMode getDefaultCloseOperation() { return awtWindowClosingProtocol.getDefaultCloseOperation(); } + @Override public WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { return awtWindowClosingProtocol.setDefaultCloseOperation(op); } @@ -745,6 +756,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } private final Runnable forceRelayout = new Runnable() { + @Override public void run() { if(DEBUG) { System.err.println("NewtCanvasAWT.forceRelayout.0"); @@ -797,6 +809,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if (!disableBackgroundEraseInitialized) { try { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { try { Class clazz = getToolkit().getClass(); diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java index 9b1b82297..409f78307 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java @@ -102,6 +102,7 @@ public class JOGLNewtApplet1Run extends Applet { /** if valid glStandalone:=true (own window) ! */ int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE; + @Override public void init() { if(DEBUG) { System.err.println("JOGLNewtApplet1Run.init() START"); @@ -223,6 +224,7 @@ public class JOGLNewtApplet1Run extends Applet { } } + @Override public void start() { if(DEBUG) { System.err.println("JOGLNewtApplet1Run.start() START (isVisible "+isVisible()+", isDisplayable "+isDisplayable()+")"); @@ -266,6 +268,7 @@ public class JOGLNewtApplet1Run extends Applet { } } + @Override public void stop() { if(DEBUG) { System.err.println("JOGLNewtApplet1Run.stop() START"); @@ -276,6 +279,7 @@ public class JOGLNewtApplet1Run extends Applet { } } + @Override public void destroy() { if(DEBUG) { System.err.println("JOGLNewtApplet1Run.destroy() START"); diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index a6a30a8bf..d17d2e77c 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -112,6 +112,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { try { final Class clazz = AccessController.doPrivileged(new PrivilegedAction>() { + @Override public Class run() { final ClassLoader cl = Thread.currentThread().getContextClassLoader(); Class clazz = null; @@ -169,6 +170,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { if(null == glWindow.getParent()) { // we may be called directly by the native EDT new Thread(new Runnable() { + @Override public void run() { if( glWindow.isNativeValid() ) { glWindow.reparentWindow(awtParent); @@ -256,6 +258,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { // *********************************************************************************** // *********************************************************************************** + @Override public void init(GLAutoDrawable drawable) { GL _gl = drawable.getGL(); @@ -276,10 +279,13 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { _gl.setSwapInterval(glSwapInterval); } } + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + @Override public void display(GLAutoDrawable drawable) { } + @Override public void dispose(GLAutoDrawable drawable) { } diff --git a/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java b/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java index 7dda47534..edb2429bb 100644 --- a/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java +++ b/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java @@ -142,6 +142,7 @@ public class DoubleTapScrollGesture implements GestureHandler { } } + @Override public String toString() { return "DoubleTapScroll[state "+gestureState+", in "+isWithinGesture()+", has "+(null!=hitGestureEvent)+", pc "+pointerDownCount+"]"; } diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index 6520dafcf..f29b632e8 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -210,10 +210,12 @@ public abstract class InputEvent extends NEWTEvent return 0 != ( modifiers & BUTTONALL_MASK ); } + @Override public String toString() { return toString(null).toString(); } + @Override public StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); diff --git a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java index a89148574..5cef734bb 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java @@ -31,8 +31,10 @@ package com.jogamp.newt.event; public abstract class KeyAdapter implements KeyListener { + @Override public void keyPressed(KeyEvent e) { } + @Override public void keyReleased(KeyEvent e) { } } diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 81680bf32..49aa4e054 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -196,10 +196,12 @@ public class KeyEvent extends InputEvent return keyCode; } + @Override public final String toString() { return toString(null).toString(); } + @Override public final StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); diff --git a/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java b/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java index 77c66a2da..03242e147 100644 --- a/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java @@ -56,10 +56,12 @@ public class MonitorEvent extends OutputEvent { } } + @Override public final String toString() { return toString(null).toString(); } + @Override public final StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); diff --git a/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java index 652f87d5b..98252fe14 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseAdapter.java @@ -30,20 +30,28 @@ package com.jogamp.newt.event; public abstract class MouseAdapter implements MouseListener { + @Override public void mouseClicked(MouseEvent e) { } + @Override public void mouseEntered(MouseEvent e) { } + @Override public void mouseExited(MouseEvent e) { } + @Override public void mousePressed(MouseEvent e) { } + @Override public void mouseReleased(MouseEvent e) { } + @Override public void mouseMoved(MouseEvent e) { } + @Override public void mouseDragged(MouseEvent e) { } + @Override public void mouseWheelMoved(MouseEvent e) { } } diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 4d7cc3b36..635bdba52 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -510,10 +510,12 @@ public class MouseEvent extends InputEvent return rotationScale; } + @Override public final String toString() { return toString(null).toString(); } + @Override public final StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index 022e2d0e1..af800e61e 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -131,6 +131,7 @@ public class NEWTEvent extends java.util.EventObject { } } + @Override public String toString() { return toString(null).toString(); } diff --git a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java index d275eab46..b4e1341da 100644 --- a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java +++ b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java @@ -75,6 +75,7 @@ public class PinchToZoomGesture implements GestureHandler { this.zoom = 1f; } + @Override public String toString() { return "PinchZoom[1stTouch "+zoomFirstTouch+", in "+isWithinGesture()+", has "+(null!=zoomEvent)+", zoom "+zoom+"]"; } diff --git a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java index e826f4a6a..bbc170958 100644 --- a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java @@ -40,10 +40,12 @@ public class TraceKeyAdapter implements KeyListener { this.downstream = downstream; } + @Override public void keyPressed(KeyEvent e) { System.err.println(e); if(null!=downstream) { downstream.keyPressed(e); } } + @Override public void keyReleased(KeyEvent e) { System.err.println(e); if(null!=downstream) { downstream.keyReleased(e); } diff --git a/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java index d035091c4..db8376034 100644 --- a/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/TraceMouseAdapter.java @@ -40,34 +40,42 @@ public class TraceMouseAdapter implements MouseListener { this.downstream = downstream; } + @Override public void mouseClicked(MouseEvent e) { System.err.println(e); if(null!=downstream) { downstream.mouseClicked(e); } } + @Override public void mouseEntered(MouseEvent e) { System.err.println(e); if(null!=downstream) { downstream.mouseEntered(e); } } + @Override public void mouseExited(MouseEvent e) { System.err.println(e); if(null!=downstream) { downstream.mouseExited(e); } } + @Override public void mousePressed(MouseEvent e) { System.err.println(e); if(null!=downstream) { downstream.mousePressed(e); } } + @Override public void mouseReleased(MouseEvent e) { System.err.println(e); if(null!=downstream) { downstream.mouseReleased(e); } } + @Override public void mouseMoved(MouseEvent e) { System.err.println(e); if(null!=downstream) { downstream.mouseMoved(e); } } + @Override public void mouseDragged(MouseEvent e) { System.err.println(e); if(null!=downstream) { downstream.mouseDragged(e); } } + @Override public void mouseWheelMoved(MouseEvent e) { System.err.println(e); if(null!=downstream) { downstream.mouseWheelMoved(e); } diff --git a/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java index 630e85303..7b844f059 100644 --- a/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/TraceWindowAdapter.java @@ -40,30 +40,37 @@ public class TraceWindowAdapter implements WindowListener { this.downstream = downstream; } + @Override public void windowResized(WindowEvent e) { System.err.println(e); if(null!=downstream) { downstream.windowResized(e); } } + @Override public void windowMoved(WindowEvent e) { System.err.println(e); if(null!=downstream) { downstream.windowMoved(e); } } + @Override public void windowDestroyNotify(WindowEvent e) { System.err.println(e); if(null!=downstream) { downstream.windowDestroyNotify(e); } } + @Override public void windowDestroyed(WindowEvent e) { System.err.println(e); if(null!=downstream) { downstream.windowDestroyed(e); } } + @Override public void windowGainedFocus(WindowEvent e) { System.err.println(e); if(null!=downstream) { downstream.windowGainedFocus(e); } } + @Override public void windowLostFocus(WindowEvent e) { System.err.println(e); if(null!=downstream) { downstream.windowLostFocus(e); } } + @Override public void windowRepaint(WindowUpdateEvent e) { System.err.println(e); if(null!=downstream) { downstream.windowRepaint(e); } diff --git a/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java index e237c0d80..ccc627444 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowAdapter.java @@ -30,18 +30,25 @@ package com.jogamp.newt.event; public abstract class WindowAdapter implements WindowListener { + @Override public void windowResized(WindowEvent e) { } + @Override public void windowMoved(WindowEvent e) { } + @Override public void windowDestroyNotify(WindowEvent e) { } + @Override public void windowDestroyed(WindowEvent e) { } + @Override public void windowGainedFocus(WindowEvent e) { } + @Override public void windowLostFocus(WindowEvent e) { } + @Override public void windowRepaint(WindowUpdateEvent e) { } } diff --git a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java index 8c7abfe99..2841fd0f6 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java @@ -66,10 +66,12 @@ public class WindowEvent extends NEWTEvent { } } + @Override public String toString() { return toString(null).toString(); } + @Override public StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); diff --git a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java index 8a204d234..9044517b5 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java @@ -44,10 +44,12 @@ public class WindowUpdateEvent extends WindowEvent { return bounds; } + @Override public String toString() { return toString(null).toString(); } + @Override public StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java index 1b53671ba..f6f11b81f 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java @@ -49,11 +49,13 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe super(downstream); } + @Override public AWTAdapter addTo(java.awt.Component awtComponent) { awtComponent.addKeyListener(this); return this; } + @Override public AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeKeyListener(this); return this; diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java index ab4bf7a3f..73a02c9fc 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java @@ -46,6 +46,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL super(downstream); } + @Override public AWTAdapter addTo(java.awt.Component awtComponent) { awtComponent.addMouseListener(this); awtComponent.addMouseMotionListener(this); @@ -53,6 +54,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL return this; } + @Override public AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeMouseListener(this); awtComponent.removeMouseMotionListener(this); @@ -60,6 +62,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL return this; } + @Override public void mouseClicked(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if(null!=newtListener) { @@ -69,6 +72,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } } + @Override public void mouseEntered(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if(null!=newtListener) { @@ -78,6 +82,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } } + @Override public void mouseExited(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if(null!=newtListener) { @@ -87,6 +92,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } } + @Override public void mousePressed(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if(null!=newtListener) { @@ -96,6 +102,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } } + @Override public void mouseReleased(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if(null!=newtListener) { @@ -105,6 +112,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } } + @Override public void mouseDragged(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if(null!=newtListener) { @@ -114,6 +122,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } } + @Override public void mouseMoved(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if(null!=newtListener) { @@ -123,6 +132,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } } + @Override public void mouseWheelMoved(java.awt.event.MouseWheelEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if(null!=newtListener) { diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java index 8c9781b77..8a9a2a49f 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java @@ -50,6 +50,7 @@ public class AWTWindowAdapter super(downstream); } + @Override public AWTAdapter addTo(java.awt.Component awtComponent) { java.awt.Window win = getWindow(awtComponent); awtComponent.addComponentListener(this); @@ -74,6 +75,7 @@ public class AWTWindowAdapter return this; } + @Override public AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeFocusListener(this); awtComponent.removeComponentListener(this); @@ -94,6 +96,7 @@ public class AWTWindowAdapter return null; } + @Override public void focusGained(java.awt.event.FocusEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { @@ -106,6 +109,7 @@ public class AWTWindowAdapter } } + @Override public void focusLost(java.awt.event.FocusEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { @@ -118,6 +122,7 @@ public class AWTWindowAdapter } } + @Override public void componentResized(java.awt.event.ComponentEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { @@ -142,6 +147,7 @@ public class AWTWindowAdapter } } + @Override public void componentMoved(java.awt.event.ComponentEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { @@ -154,6 +160,7 @@ public class AWTWindowAdapter } } + @Override public void componentShown(java.awt.event.ComponentEvent e) { final java.awt.Component comp = e.getComponent(); if(DEBUG_IMPLEMENTATION) { @@ -171,6 +178,7 @@ public class AWTWindowAdapter }*/ } + @Override public void componentHidden(java.awt.event.ComponentEvent e) { final java.awt.Component comp = e.getComponent(); if(DEBUG_IMPLEMENTATION) { @@ -188,6 +196,7 @@ public class AWTWindowAdapter }*/ } + @Override public void windowActivated(java.awt.event.WindowEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(null!=newtListener) { @@ -197,10 +206,13 @@ public class AWTWindowAdapter } } + @Override public void windowClosed(java.awt.event.WindowEvent e) { } + @Override public void windowClosing(java.awt.event.WindowEvent e) { } + @Override public void windowDeactivated(java.awt.event.WindowEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(null!=newtListener) { @@ -210,13 +222,17 @@ public class AWTWindowAdapter } } + @Override public void windowDeiconified(java.awt.event.WindowEvent e) { } + @Override public void windowIconified(java.awt.event.WindowEvent e) { } + @Override public void windowOpened(java.awt.event.WindowEvent e) { } class WindowClosingListener implements java.awt.event.WindowListener { + @Override public void windowClosing(java.awt.event.WindowEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(null!=newtListener) { @@ -225,6 +241,7 @@ public class AWTWindowAdapter enqueueEvent(true, event); } } + @Override public void windowClosed(java.awt.event.WindowEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(null!=newtListener) { @@ -234,10 +251,15 @@ public class AWTWindowAdapter } } + @Override public void windowActivated(java.awt.event.WindowEvent e) { } + @Override public void windowDeactivated(java.awt.event.WindowEvent e) { } + @Override public void windowDeiconified(java.awt.event.WindowEvent e) { } + @Override public void windowIconified(java.awt.event.WindowEvent e) { } + @Override public void windowOpened(java.awt.event.WindowEvent e) { } } } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index ac81e8469..8c1110ed3 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -117,6 +117,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind super(null, null, false /* always handle device lifecycle ourselves */); this.window = (WindowImpl) window; this.window.setWindowDestroyNotifyAction( new Runnable() { + @Override public void run() { defaultWindowDestroyNotifyOp(); } } ); @@ -549,6 +550,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind anim.stop(); // on anim thread, non-blocking } else { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { if( anim.isAnimating() && null != animThread ) { try { diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index a25b43777..e63a53524 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -99,6 +99,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { public static NewtCanvasSWT create(final Composite parent, final int style, final Window child) { final NewtCanvasSWT[] res = new NewtCanvasSWT[] { null }; parent.getDisplay().syncExec( new Runnable() { + @Override public void run() { res[0] = new NewtCanvasSWT( parent, style, child); } @@ -254,10 +255,12 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { /** @return this SWT Canvas NativeWindow representation, may be null in case it has not been realized. */ public NativeWindow getNativeWindow() { return nativeWindow; } + @Override public WindowClosingMode getDefaultCloseOperation() { return newtChildCloseOp; // TODO: implement ?! } + @Override public WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { return newtChildCloseOp = op; // TODO: implement ?! } diff --git a/src/newt/classes/jogamp/newt/Debug.java b/src/newt/classes/jogamp/newt/Debug.java index 46a354d4a..7ef2d7ffc 100644 --- a/src/newt/classes/jogamp/newt/Debug.java +++ b/src/newt/classes/jogamp/newt/Debug.java @@ -54,6 +54,7 @@ public class Debug extends PropertyAccess { static { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { PropertyAccess.addTrustedPrefix("newt."); return null; diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index c6cb706a4..0c29d772a 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -53,6 +53,7 @@ public abstract class DisplayImpl extends Display { static { NativeWindowFactory.addCustomShutdownHook(true /* head */, new Runnable() { + @Override public void run() { WindowImpl.shutdownAll(); ScreenImpl.shutdownAll(); @@ -147,6 +148,7 @@ public abstract class DisplayImpl extends Display { final DisplayImpl f_dpy = this; try { runOnEDTIfAvail(true, new Runnable() { + @Override public void run() { f_dpy.createNativeImpl(); }}); @@ -244,6 +246,7 @@ public abstract class DisplayImpl extends Display { task.run(); } + @Override public boolean validateEDTStopped() { if( 0==refCount && null == aDevice ) { final EDTUtil _edtUtil = edtUtil; @@ -277,6 +280,7 @@ public abstract class DisplayImpl extends Display { aDevice = null; refCount=0; stopEDT( edtUtil, new Runnable() { // blocks! + @Override public void run() { if ( null != f_aDevice ) { f_dpy.closeNativeImpl(f_aDevice); @@ -308,6 +312,7 @@ public abstract class DisplayImpl extends Display { d.aDevice = null; d.refCount=0; final Runnable closeNativeTask = new Runnable() { + @Override public void run() { if ( null != d.getGraphicsDevice() ) { d.closeNativeImpl(f_aDevice); @@ -329,6 +334,7 @@ public abstract class DisplayImpl extends Display { } } + @Override public synchronized final int addReference() { if(DEBUG) { System.err.println("Display.addReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount+1)); @@ -343,6 +349,7 @@ public abstract class DisplayImpl extends Display { } + @Override public synchronized final int removeReference() { if(DEBUG) { System.err.println("Display.removeReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount-1)); @@ -355,6 +362,7 @@ public abstract class DisplayImpl extends Display { return refCount; } + @Override public synchronized final int getReferenceCount() { return refCount; } @@ -450,6 +458,7 @@ public abstract class DisplayImpl extends Display { private volatile boolean haveEvents = false; final protected Runnable dispatchMessagesRunnable = new Runnable() { + @Override public void run() { DisplayImpl.this.dispatchMessages(); } }; diff --git a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java index f1e212394..9364ada30 100644 --- a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java +++ b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java @@ -51,6 +51,7 @@ import com.jogamp.common.util.cache.TempJarCache; public class NEWTJNILibLoader extends JNILibLoaderBase { public static boolean loadNEWT() { return AccessController.doPrivileged(new PrivilegedAction() { + @Override public Boolean run() { Platform.initSingleton(); final String libName = "newt"; diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index eba844230..2478b1e5d 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -57,6 +57,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { static long nextWindowHandle = 0x100; // start here - a marker + @Override protected void createNativeImpl() { if(capsRequested.isOnscreen()) { throw new NativeWindowException("Capabilities is onscreen"); @@ -75,6 +76,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { visibleChanged(false, true); } + @Override protected void closeNativeImpl() { // nop } @@ -85,6 +87,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { surfaceHandle = 0; } + @Override public void setSurfaceHandle(long handle) { surfaceHandle = handle ; } @@ -94,6 +97,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { return surfaceHandle; } + @Override protected void requestFocusImpl(boolean reparented) { } @@ -113,6 +117,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { } + @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { sizeChanged(false, width, height, false); if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { @@ -138,10 +143,12 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { return new Point(0,0); } + @Override protected Point getLocationOnScreenImpl(int x, int y) { return new Point(x,y); } + @Override protected void updateInsetsImpl(Insets insets) { // nop .. } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index a0ef8816b..5102fd26d 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -207,6 +207,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** last mouse button click count */ short lastButtonClickCount = (short)0; + @Override final void clearButton() { super.clearButton(); lastButtonPressTime = 0; @@ -536,12 +537,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private Object closingListenerLock = new Object(); private WindowClosingMode defaultCloseOperation = WindowClosingMode.DISPOSE_ON_CLOSE; + @Override public WindowClosingMode getDefaultCloseOperation() { synchronized (closingListenerLock) { return defaultCloseOperation; } } + @Override public WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { synchronized (closingListenerLock) { WindowClosingMode _op = defaultCloseOperation; @@ -956,6 +959,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer this.visible = visible; } + @Override public final void run() { setVisibleActionImpl(visible); } @@ -983,6 +987,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer this.disregardFS = disregardFS; } + @Override public final void run() { final RecursiveLock _lock = windowLock; _lock.lock(); @@ -1035,6 +1040,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private class DestroyAction implements Runnable { + @Override public final void run() { boolean animatorPaused = false; if(null!=lifecycleHook) { @@ -1188,6 +1194,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer screen = newScreen; } + @Override public final void run() { boolean animatorPaused = false; if(null!=lifecycleHook) { @@ -1462,6 +1469,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private class ReparentActionRecreate implements Runnable { + @Override public final void run() { final RecursiveLock _lock = windowLock; _lock.lock(); @@ -1514,6 +1522,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer this.undecorated = undecorated; } + @Override public final void run() { final RecursiveLock _lock = windowLock; _lock.lock(); @@ -1559,6 +1568,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer this.alwaysOnTop = alwaysOnTop; } + @Override public final void run() { final RecursiveLock _lock = windowLock; _lock.lock(); @@ -1834,6 +1844,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private final Runnable requestFocusAction = new Runnable() { + @Override public final void run() { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.RequestFocusAction: force 0 - ("+getThreadName()+"): "+hasFocus+" -> true - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); @@ -1842,6 +1853,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } }; private final Runnable requestFocusActionForced = new Runnable() { + @Override public final void run() { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.RequestFocusAction: force 1 - ("+getThreadName()+"): "+hasFocus+" -> true - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); @@ -1921,6 +1933,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer this.y = y; } + @Override public final void run() { final RecursiveLock _lock = windowLock; _lock.lock(); @@ -1970,6 +1983,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public boolean fsOn() { return fullscreen; } + @Override public final void run() { final RecursiveLock _lock = windowLock; _lock.lock(); @@ -2144,6 +2158,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer List _fullscreenMonitors = null; boolean _fullscreenUseMainMonitor = true; + @Override public void monitorModeChangeNotify(MonitorEvent me) { hadFocus = hasFocus(); if(DEBUG_IMPLEMENTATION) { @@ -2164,6 +2179,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + @Override public void monitorModeChanged(MonitorEvent me, boolean success) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.monitorModeChanged: hadFocus "+hadFocus+", "+me+", success: "+success+" @ "+Thread.currentThread().getName()); diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index 325f17278..4bcb0fc82 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -51,16 +51,19 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt this.downstreamParent = downstreamParent; } + @Override public AWTAdapter addTo(java.awt.Component awtComponent) { awtComponent.addHierarchyListener(this); return super.addTo(awtComponent); } + @Override public AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeHierarchyListener(this); return super.removeFrom(awtComponent); } + @Override public void focusGained(java.awt.event.FocusEvent e) { // forward focus to NEWT child final com.jogamp.newt.Window newtChild = getNewtWindow(); @@ -78,12 +81,14 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt } } + @Override public void focusLost(java.awt.event.FocusEvent e) { if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: focusLost: "+ e); } } + @Override public void componentResized(java.awt.event.ComponentEvent e) { // Need to resize the NEWT child window // the resized event will be send via the native window feedback. @@ -93,6 +98,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt } final Window newtWindow = getNewtWindow(); newtWindow.runOnEDTIfAvail(false, new Runnable() { + @Override public void run() { int cw = comp.getWidth(); int ch = comp.getHeight(); @@ -109,6 +115,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt }}); } + @Override public void componentMoved(java.awt.event.ComponentEvent e) { if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentMoved: "+e); @@ -119,14 +126,17 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt } } + @Override public void windowActivated(java.awt.event.WindowEvent e) { // no propagation to NEWT child window } + @Override public void windowDeactivated(java.awt.event.WindowEvent e) { // no propagation to NEWT child window } + @Override public void hierarchyChanged(java.awt.event.HierarchyEvent e) { if( null == getNewtEventListener() ) { long bits = e.getChangeFlags(); @@ -137,6 +147,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt System.err.println("AWT: hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed+", source "+e.getComponent()); } getNewtWindow().runOnEDTIfAvail(false, new Runnable() { + @Override public void run() { if(getNewtWindow().isVisible() != showing) { getNewtWindow().setVisible(showing); diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index 14cc9c69d..f7722c91c 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -107,6 +107,7 @@ public class AWTCanvas extends Canvas { return res; } + @Override public void addNotify() { /** @@ -160,6 +161,7 @@ public class AWTCanvas extends Canvas { return null != jawtWindow ? jawtWindow.isOffscreenLayerSurfaceEnabled() : false; } + @Override public void removeNotify() { try { dispose(); @@ -195,6 +197,7 @@ public class AWTCanvas extends Canvas { * Overridden to choose a GraphicsConfiguration on a parent container's * GraphicsDevice because both devices */ + @Override public GraphicsConfiguration getGraphicsConfiguration() { /* * Workaround for problems with Xinerama and java.awt.Component.checkGD @@ -324,6 +327,7 @@ public class AWTCanvas extends Canvas { if (!disableBackgroundEraseInitialized) { try { AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { try { Class clazz = getToolkit().getClass(); diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index bddb43b30..4a7193306 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -218,6 +218,7 @@ public class AWTEDTUtil implements EDTUtil { } try { AWTEDTExecutor.singleton.invoke(true, new Runnable() { + @Override public void run() { } }); } catch (Exception e) { } diff --git a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java index 9e716d544..d9a4a48e5 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java @@ -46,6 +46,7 @@ public class DisplayDriver extends DisplayImpl { public DisplayDriver() { } + @Override protected void createNativeImpl() { aDevice = AWTGraphicsDevice.createDefault(); } @@ -54,6 +55,7 @@ public class DisplayDriver extends DisplayImpl { aDevice = d; } + @Override protected EDTUtil createEDTUtil() { final EDTUtil def; if(NewtFactory.useEDT()) { @@ -67,10 +69,12 @@ public class DisplayDriver extends DisplayImpl { return def; } + @Override protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } + @Override protected void dispatchMessagesNative() { /* nop */ } } diff --git a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java index a2430e2bb..a4356707e 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java @@ -49,6 +49,7 @@ public class ScreenDriver extends ScreenImpl { public ScreenDriver() { } + @Override protected void createNativeImpl() { aScreen = new AWTGraphicsScreen((AWTGraphicsDevice)display.getGraphicsDevice()); } @@ -65,8 +66,10 @@ public class ScreenDriver extends ScreenImpl { super.updateVirtualScreenOriginAndSize(); } + @Override protected void closeNativeImpl() { } + @Override protected int validateScreenIndex(int idx) { return idx; // pass through ... } diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index db71695b7..9854524d9 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -86,6 +86,7 @@ public class WindowDriver extends WindowImpl { private Frame awtFrame = null; private AWTCanvas awtCanvas; + @Override protected void requestFocusImpl(boolean reparented) { awtContainer.requestFocus(); } @@ -97,6 +98,7 @@ public class WindowDriver extends WindowImpl { } } + @Override protected void createNativeImpl() { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported in AWT, use AWTWindow(Frame) cstr for wrapping instead"); @@ -140,6 +142,7 @@ public class WindowDriver extends WindowImpl { } } + @Override protected void closeNativeImpl() { setWindowHandle(0); if(null!=awtContainer) { @@ -176,6 +179,7 @@ public class WindowDriver extends WindowImpl { return res; } + @Override protected void updateInsetsImpl(javax.media.nativewindow.util.Insets insets) { final Insets contInsets = awtContainer.getInsets(); insets.set(contInsets.left, contInsets.right, contInsets.top, contInsets.bottom); @@ -214,6 +218,7 @@ public class WindowDriver extends WindowImpl { awtContainer.validate(); } + @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { if(DEBUG_IMPLEMENTATION) { System.err.println("AWTWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ @@ -266,6 +271,7 @@ public class WindowDriver extends WindowImpl { return true; } + @Override protected Point getLocationOnScreenImpl(int x, int y) { java.awt.Point ap = awtCanvas.getLocationOnScreen(); ap.translate(x, y); diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java index 1b73cb381..9da671d37 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java @@ -61,6 +61,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { public DisplayDriver() { } + @Override protected void createNativeImpl() { final long handle = CreateDisplay(ScreenDriver.fixedWidth, ScreenDriver.fixedHeight); if (handle == EGL.EGL_NO_DISPLAY) { @@ -69,6 +70,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { aDevice = new EGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, handle, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, null); } + @Override protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { DestroyDisplay(aDevice.getHandle()); @@ -76,6 +78,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { aDevice.close(); } + @Override protected void dispatchMessagesNative() { // n/a .. DispatchMessages(); } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java index 269574adc..d3231557f 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java @@ -53,12 +53,15 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { public ScreenDriver() { } + @Override protected void createNativeImpl() { aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); } + @Override protected void closeNativeImpl() { } + @Override protected int validateScreenIndex(int idx) { return 0; // only one screen available } @@ -100,6 +103,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { return false; } + @Override protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { vOriginSize.set(0, 0, fixedWidth, fixedHeight); // FIXME } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java index bed0520ff..39f168e0f 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java @@ -52,6 +52,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { public WindowDriver() { } + @Override protected void createNativeImpl() { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); @@ -72,12 +73,14 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } } + @Override protected void closeNativeImpl() { if(0!=windowHandleClose) { CloseWindow(getDisplayHandle(), windowHandleClose); } } + @Override protected void requestFocusImpl(boolean reparented) { } protected void setSizeImpl(int width, int height) { @@ -89,6 +92,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } } + @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { if(0!=getWindowHandle()) { if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { @@ -117,10 +121,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl { return true; } + @Override protected Point getLocationOnScreenImpl(int x, int y) { return new Point(x,y); } + @Override protected void updateInsetsImpl(Insets insets) { // nop .. } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java index 52c92a5da..d8d93f123 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java @@ -59,15 +59,18 @@ public class DisplayDriver extends DisplayImpl { public DisplayDriver() { } + @Override protected void createNativeImpl() { // FIXME: map name to EGL_*_DISPLAY aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } + @Override protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } + @Override protected void dispatchMessagesNative() { DispatchMessages(); } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java index 5a1917419..dc2a8459a 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java @@ -45,13 +45,16 @@ public class ScreenDriver extends ScreenImpl { public ScreenDriver() { } + @Override protected void createNativeImpl() { aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); initNative(); } + @Override protected void closeNativeImpl() { } + @Override protected int validateScreenIndex(int idx) { return 0; // only one screen available } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index 560e49e96..4d4977776 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -55,6 +55,7 @@ public class WindowDriver extends WindowImpl { public WindowDriver() { } + @Override protected void createNativeImpl() { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); @@ -92,6 +93,7 @@ public class WindowDriver extends WindowImpl { focusChanged(false, true); } + @Override protected void closeNativeImpl() { final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getGraphicsConfiguration().getScreen().getDevice(); @@ -106,10 +108,12 @@ public class WindowDriver extends WindowImpl { eglDevice.close(); } + @Override protected void requestFocusImpl(boolean reparented) { focusChanged(false, true); } + @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { setVisible0(nativeWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); @@ -143,10 +147,12 @@ public class WindowDriver extends WindowImpl { return true; } + @Override protected Point getLocationOnScreenImpl(int x, int y) { return new Point(x,y); } + @Override protected void updateInsetsImpl(Insets insets) { // nop .. } diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java index 4cb566bc2..cc435540f 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java @@ -59,6 +59,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { public DisplayDriver() { } + @Override protected void createNativeImpl() { synchronized(DisplayDriver.class) { if(0==initCounter) { @@ -72,6 +73,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { aDevice = new DefaultGraphicsDevice(NativeWindowFactory.TYPE_DEFAULT, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, displayHandle); } + @Override protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { if(0==displayHandle) { throw new NativeWindowException("displayHandle null; initCnt "+initCounter); @@ -87,6 +89,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { aDevice.close(); } + @Override protected void dispatchMessagesNative() { if(0!=displayHandle) { DispatchMessages(displayHandle, focusedWindow); diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java index b5202aaf9..44802e348 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java @@ -53,14 +53,17 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { public ScreenDriver() { } + @Override protected void createNativeImpl() { AbstractGraphicsDevice adevice = getDisplay().getGraphicsDevice(); GetScreenInfo(adevice.getHandle(), screen_idx); aScreen = new DefaultGraphicsScreen(adevice, screen_idx); } + @Override protected void closeNativeImpl() { } + @Override protected int validateScreenIndex(int idx) { return 0; // only one screen available } @@ -102,6 +105,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { return false; } + @Override protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { vOriginSize.set(0, 0, cachedWidth, cachedHeight); } diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java index 80821d4da..0e96c65d0 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java @@ -48,6 +48,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { static long nextWindowHandle = 1; + @Override protected void createNativeImpl() { if(0!=getParentWindowHandle()) { throw new NativeWindowException("GDL Window does not support window parenting"); @@ -72,6 +73,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } } + @Override protected void closeNativeImpl() { if(0!=surfaceHandle) { synchronized(WindowDriver.class) { @@ -82,6 +84,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { } } + @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { ScreenDriver screen = (ScreenDriver) getScreen(); @@ -112,6 +115,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl { return true; } + @Override protected void requestFocusImpl(boolean reparented) { ((DisplayDriver)getScreen().getDisplay()).setFocus(this); } @@ -121,10 +125,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl { return surfaceHandle; } + @Override protected Point getLocationOnScreenImpl(int x, int y) { return new Point(x,y); } + @Override protected void updateInsetsImpl(Insets insets) { // nop .. } diff --git a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java index 1b92ca586..929688b11 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java @@ -59,15 +59,18 @@ public class DisplayDriver extends DisplayImpl { public DisplayDriver() { } + @Override protected void createNativeImpl() { // FIXME: map name to EGL_*_DISPLAY aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } + @Override protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } + @Override protected void dispatchMessagesNative() { DispatchMessages(); } diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java index 17cc5dd2f..9ebe2629a 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java @@ -51,12 +51,15 @@ public class ScreenDriver extends ScreenImpl { public ScreenDriver() { } + @Override protected void createNativeImpl() { aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); } + @Override protected void closeNativeImpl() { } + @Override protected int validateScreenIndex(int idx) { return 0; // only one screen available } @@ -98,6 +101,7 @@ public class ScreenDriver extends ScreenImpl { return false; } + @Override protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { vOriginSize.set(0, 0, cachedWidth, cachedHeight); } diff --git a/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java index d30d4f025..158e6ab2f 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java @@ -56,6 +56,7 @@ public class WindowDriver extends WindowImpl { public WindowDriver() { } + @Override protected void createNativeImpl() { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); @@ -83,6 +84,7 @@ public class WindowDriver extends WindowImpl { windowHandleClose = eglWindowHandle; } + @Override protected void closeNativeImpl() { if(0!=windowHandleClose) { CloseWindow(windowHandleClose, windowUserData); @@ -90,8 +92,10 @@ public class WindowDriver extends WindowImpl { } } + @Override protected void requestFocusImpl(boolean reparented) { } + @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { setVisible0(eglWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); @@ -125,10 +129,12 @@ public class WindowDriver extends WindowImpl { return true; } + @Override protected Point getLocationOnScreenImpl(int x, int y) { return new Point(x,y); } + @Override protected void updateInsetsImpl(Insets insets) { // nop .. } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index 2dbdfdce7..c44685dc8 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -64,14 +64,17 @@ public class DisplayDriver extends DisplayImpl { public DisplayDriver() { } + @Override protected void dispatchMessagesNative() { // nop } + @Override protected void createNativeImpl() { aDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } + @Override protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java index 5d3b7287b..4f3cc691b 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java @@ -52,10 +52,12 @@ public class ScreenDriver extends ScreenImpl { public ScreenDriver() { } + @Override protected void createNativeImpl() { aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); } + @Override protected void closeNativeImpl() { } private MonitorMode getMonitorModeImpl(MonitorModeProps.Cache cache, int crt_idx, int mode_idx) { @@ -114,6 +116,7 @@ public class ScreenDriver extends ScreenImpl { return setMonitorMode0(monitor.getId(), mode.getId(), mode.getRotation()); } + @Override protected int validateScreenIndex(int idx) { return 0; // big-desktop w/ multiple monitor attached, only one screen available } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index f36d32772..7db3e2aab 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -87,6 +87,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl isOffscreenInstance = false; if (0 != handle) { OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { close0( handle ); } } ); @@ -144,6 +145,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if (isNativeValid()) { if (0 != sscSurfaceHandle) { OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { orderOut0( 0 != getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); } } ); @@ -160,6 +162,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected void setTitleImpl(final String title) { OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { setTitle0(getWindowHandle(), title); } } ); @@ -172,6 +175,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } if(!isOffscreenInstance) { OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { requestFocus0(getWindowHandle(), force); } } ); @@ -187,6 +191,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } if(!isOffscreenInstance) { OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { resignFocus0(getWindowHandle()); } } ); @@ -209,6 +214,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl System.err.println("MacWindow: updatePosition() parent["+useParent+" "+pX+"/"+pY+"] "+x+"/"+y+" -> "+x+"/"+y+" rel-client-pos, "+p0S+" screen-client-pos"); } OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { setWindowClientTopLeftPoint0(handle, p0S.getX(), p0S.getY(), isVisible()); } } ); @@ -230,6 +236,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl System.err.println("MacWindow: sizeChanged() parent["+useParent+" "+x+"/"+y+"] "+getX()+"/"+getY()+" "+newWidth+"x"+newHeight+" -> "+p0S+" screen-client-pos"); } OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY(), isVisible()); } } ); @@ -275,6 +282,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && !setVisible ) { if ( !isOffscreenInstance ) { OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { orderOut0(getWindowHandle()); visibleChanged(true, false); @@ -297,6 +305,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( width>0 && height>0 ) { if( !isOffscreenInstance ) { OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { setWindowClientTopLeftPointAndSize0(getWindowHandle(), pClientLevelOnSreen.getX(), pClientLevelOnSreen.getY(), width, height, setVisible); } } ); @@ -308,6 +317,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && setVisible ) { if( !isOffscreenInstance ) { OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { orderFront0(getWindowHandle()); visibleChanged(true, true); @@ -476,6 +486,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl throw new NativeWindowException("Internal Error - create w/ window, but no Newt NSView"); } OSXUtil.RunOnMainThread(false, new Runnable() { + @Override public void run() { changeContentView0(parentWinHandle, preWinHandle, 0); close0( preWinHandle ); @@ -502,6 +513,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final boolean isOpaque = getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance; // Blocking initialization on main-thread! OSXUtil.RunOnMainThread(true, new Runnable() { + @Override public void run() { initWindow0( parentWinHandle, newWin, pS.getX(), pS.getY(), width, height, isOpaque, fullscreen, visible && !offscreenInstance, surfaceHandle); diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index d3c7416cc..d8ff7ecb5 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -71,16 +71,19 @@ public class DisplayDriver extends DisplayImpl { public DisplayDriver() { } + @Override protected void createNativeImpl() { sharedClass = sharedClassFactory.getSharedClass(); aDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } + @Override protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { sharedClassFactory.releaseSharedClass(); aDevice.close(); } + @Override protected void dispatchMessagesNative() { DispatchMessages0(); } diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 30405aa05..6e8ac3efa 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -127,6 +127,7 @@ public class WindowDriver extends WindowImpl { return false; } + @Override protected void createNativeImpl() { final ScreenDriver screen = (ScreenDriver) getScreen(); final DisplayDriver display = (DisplayDriver) screen.getDisplay(); @@ -156,6 +157,7 @@ public class WindowDriver extends WindowImpl { } } + @Override protected void closeNativeImpl() { if(windowHandleClose != 0) { if (hdc != 0) { @@ -183,6 +185,7 @@ public class WindowDriver extends WindowImpl { hdc_old = 0; } + @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { if(DEBUG_IMPLEMENTATION) { System.err.println("WindowsWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ @@ -210,6 +213,7 @@ public class WindowDriver extends WindowImpl { return true; } + @Override protected void requestFocusImpl(boolean force) { requestFocus0(getWindowHandle(), force); } @@ -224,6 +228,7 @@ public class WindowDriver extends WindowImpl { final boolean[] res = new boolean[] { false }; this.runOnEDTIfAvail(true, new Runnable() { + @Override public void run() { res[0] = setPointerVisible0(getWindowHandle(), pointerVisible); } @@ -236,6 +241,7 @@ public class WindowDriver extends WindowImpl { final Boolean[] res = new Boolean[] { Boolean.FALSE }; this.runOnEDTIfAvail(true, new Runnable() { + @Override public void run() { final Point p0 = getLocationOnScreenImpl(0, 0); res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine, @@ -248,6 +254,7 @@ public class WindowDriver extends WindowImpl { @Override protected void warpPointerImpl(final int x, final int y) { this.runOnEDTIfAvail(true, new Runnable() { + @Override public void run() { final Point sPos = getLocationOnScreenImpl(x, y); warpPointer0(getWindowHandle(), sPos.getX(), sPos.getY()); @@ -256,10 +263,12 @@ public class WindowDriver extends WindowImpl { return; } + @Override protected Point getLocationOnScreenImpl(int x, int y) { return GDIUtil.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y); } + @Override protected void updateInsetsImpl(Insets insets) { // nop - using event driven insetsChange(..) } diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index aa8067520..504839797 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -63,6 +63,7 @@ public class DisplayDriver extends DisplayImpl { public DisplayDriver() { } + @Override public String validateDisplayName(String name, long handle) { return X11Util.validateDisplayName(name, handle); } @@ -72,6 +73,7 @@ public class DisplayDriver extends DisplayImpl { * * We use a private non-shared X11 Display instance for EDT window operations and one for exposed animation, eg. OpenGL. */ + @Override protected void createNativeImpl() { X11Util.setX11ErrorHandler(true, DEBUG ? false : true); // make sure X11 error handler is set long handle = X11Util.openDisplay(name); diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index 7f75e03f0..bef7f60ec 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -74,6 +74,7 @@ public class ScreenDriver extends ScreenImpl { protected void createNativeImpl() { // validate screen index Long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override public Long run(long dpy) { return new Long(GetScreen0(dpy, screen_idx)); } } ); @@ -180,6 +181,7 @@ public class ScreenDriver extends ScreenImpl { if( null == rAndR ) { return null; } return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override public MonitorMode run(long dpy) { final int[] currentModeProps = rAndR.getCurrentMonitorModeProps(dpy, ScreenDriver.this, monitor.getId()); return MonitorModeProps.streamInMonitorMode(null, null, currentModeProps, 0); @@ -192,6 +194,7 @@ public class ScreenDriver extends ScreenImpl { final long t0 = System.currentTimeMillis(); boolean done = runWithOptTempDisplayHandle( new DisplayImpl.DisplayRunnable() { + @Override public Boolean run(long dpy) { return Boolean.valueOf( rAndR.setCurrentMonitorMode(dpy, ScreenDriver.this, monitor, mode) ); } @@ -205,6 +208,7 @@ public class ScreenDriver extends ScreenImpl { } private DisplayImpl.DisplayRunnable xineramaEnabledQueryWithTemp = new DisplayImpl.DisplayRunnable() { + @Override public Boolean run(long dpy) { return new Boolean(X11Util.XineramaIsEnabled(dpy)); } }; @@ -236,6 +240,7 @@ public class ScreenDriver extends ScreenImpl { } } ); } else */ { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override public Object run(long dpy) { vOriginSize.set(0, 0, getWidth0(dpy, screen_idx), getHeight0(dpy, screen_idx)); return null; diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 02f80c0c3..5e1f7a6ed 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -176,6 +176,7 @@ public class WindowDriver extends WindowImpl { final int fflags = flags; final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override public Object run(long dpy) { reconfigureWindow0( dpy, getScreenIndex(), getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), @@ -202,6 +203,7 @@ public class WindowDriver extends WindowImpl { } final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override public Object run(long dpy) { reconfigureWindow0( dpy, getScreenIndex(), getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), @@ -223,6 +225,7 @@ public class WindowDriver extends WindowImpl { @Override protected void requestFocusImpl(final boolean force) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override public Object run(long dpy) { requestFocus0(dpy, getWindowHandle(), force); return null; @@ -233,6 +236,7 @@ public class WindowDriver extends WindowImpl { @Override protected void setTitleImpl(final String title) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override public Object run(long dpy) { setTitle0(dpy, getWindowHandle(), title); return null; @@ -243,6 +247,7 @@ public class WindowDriver extends WindowImpl { @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override public Boolean run(long dpy) { return Boolean.valueOf(setPointerVisible0(dpy, getWindowHandle(), pointerVisible)); } @@ -252,6 +257,7 @@ public class WindowDriver extends WindowImpl { @Override protected boolean confinePointerImpl(final boolean confine) { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override public Boolean run(long dpy) { return Boolean.valueOf(confinePointer0(dpy, getWindowHandle(), confine)); } @@ -261,6 +267,7 @@ public class WindowDriver extends WindowImpl { @Override protected void warpPointerImpl(final int x, final int y) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override public Object run(long dpy) { warpPointer0(dpy, getWindowHandle(), x, y); return null; @@ -271,6 +278,7 @@ public class WindowDriver extends WindowImpl { @Override protected Point getLocationOnScreenImpl(final int x, final int y) { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override public Point run(long dpy) { return X11Lib.GetRelativeLocation(dpy, getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); } diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java index 08eacdee5..db89690f4 100644 --- a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java @@ -54,6 +54,7 @@ public class SWTEDTUtil implements EDTUtil { this.threadGroup = Thread.currentThread().getThreadGroup(); this.name=Thread.currentThread().getName()+"-SWTDisplay-"+newtDisplay.getFQName()+"-EDT-"; this.dispatchMessages = new Runnable() { + @Override public void run() { ((jogamp.newt.DisplayImpl) newtDisplay).dispatchMessages(); } }; @@ -252,6 +253,7 @@ public class SWTEDTUtil implements EDTUtil { } try { swtDisplay.syncExec(new Runnable() { + @Override public void run() { } }); } catch (Exception e) { } -- cgit v1.2.3 From 9b2013182516b77a39123894ad1b71619bd9785b Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Fri, 18 Oct 2013 00:16:51 -0700 Subject: jogl: avoid creating a second String object, one is enough One String is already being built, passing it to new String() is just wasteful as the temp String can be returned just as easily. Signed-off-by: Harvey Harrison --- src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java | 2 +- src/nativewindow/classes/javax/media/nativewindow/util/Insets.java | 2 +- src/nativewindow/classes/javax/media/nativewindow/util/Point.java | 2 +- src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java | 2 +- src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java | 2 +- src/newt/classes/com/jogamp/newt/MonitorMode.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/newt/classes') diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index b8dc53c83..24ccc836a 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -87,7 +87,7 @@ public class Dimension implements Cloneable, DimensionImmutable { @Override public String toString() { - return new String(width+" x "+height); + return width + " x " + height; } @Override diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java index c84359dcd..3644916fe 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java @@ -103,7 +103,7 @@ public class Insets implements Cloneable, InsetsImmutable { @Override public String toString() { - return new String("[ l "+l+", r "+r+" - t "+t+", b "+b+" - "+getTotalWidth()+"x"+getTotalHeight()+"]"); + return "[ l "+l+", r "+r+" - t "+t+", b "+b+" - "+getTotalWidth()+"x"+getTotalHeight()+"]"; } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index 57c6fb716..331c1388e 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -99,7 +99,7 @@ public class Point implements Cloneable, PointImmutable { @Override public String toString() { - return new String( x + " / " + y ); + return x + " / " + y; } public final void set(int x, int y) { this.x = x; this.y = y; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index 8dc8f4562..d0d8bfb13 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -195,7 +195,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { @Override public String toString() { - return new String("[ "+x+" / "+y+" "+width+" x "+height+" ]"); + return "[ "+x+" / "+y+" "+width+" x "+height+" ]"; } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java index f1749dfa6..77619731f 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java @@ -58,7 +58,7 @@ public class SurfaceSize implements Comparable { @Override public final String toString() { - return new String("[ "+resolution+" x "+bitsPerPixel+" bpp ]"); + return "[ "+resolution+" x "+bitsPerPixel+" bpp ]"; } /** diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java index 59f28e791..9690f18db 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorMode.java +++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java @@ -176,7 +176,7 @@ public class MonitorMode implements Comparable { } @Override public final String toString() { - return new String(surfaceSize+" @ "+refreshRate+" Hz, flags ["+flags2String(flags).toString()+"]"); + return surfaceSize+" @ "+refreshRate+" Hz, flags ["+flags2String(flags).toString()+"]"; } /** -- cgit v1.2.3 From 0ba264e878993d8f24254257d39a189b4ebf3937 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 19 Oct 2013 03:40:31 +0200 Subject: PinchToZoomGesture: Add ctor arg 'allowMorePointer', should be false to be more stable (i.e. only 2 pointer pressed) --- make/scripts/tests-x64-dbg.bat | 4 +- make/scripts/tests.sh | 6 +- .../com/jogamp/newt/event/PinchToZoomGesture.java | 18 ++- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 124 +++++++++++---------- 4 files changed, 81 insertions(+), 71 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 7c30d4db3..726be54ba 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -20,7 +20,7 @@ set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\% echo CP_ALL %CP_ALL% -set D_ARGS="-Djogamp.debug=all" +REM set D_ARGS="-Djogamp.debug=all" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" @@ -53,7 +53,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.Til REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" -REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" +set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ece235a60..fd79b028e 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -155,7 +155,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" - D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" @@ -300,7 +300,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -313,7 +313,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java index b4e1341da..42f006f08 100644 --- a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java +++ b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java @@ -62,16 +62,22 @@ public class PinchToZoomGesture implements GestureHandler { } private final NativeSurface surface; + private final boolean allowMorePointer; private float zoom; private int zoomLastEdgeDist; private boolean zoomFirstTouch; private boolean zoomMode; private ZoomEvent zoomEvent; - private short[] pIds = new short[] { -1, -1 }; + private final short[] pIds = new short[] { -1, -1 }; - public PinchToZoomGesture(NativeSurface surface) { + /** + * @param surface the {@link NativeSurface}, which size is used to compute the relative zoom factor + * @param allowMorePointer if false, allow only 2 pressed pointers (safe and recommended), otherwise accept other pointer to be pressed. + */ + public PinchToZoomGesture(NativeSurface surface, boolean allowMorePointer) { clear(true); this.surface = surface; + this.allowMorePointer = allowMorePointer; this.zoom = 1f; } @@ -135,11 +141,13 @@ public class PinchToZoomGesture implements GestureHandler { return true; } final MouseEvent pe = (MouseEvent)in; - if( pe.getPointerType(0).getPointerClass() != MouseEvent.PointerClass.Onscreen ) { + final int pointerDownCount = pe.getPointerCount(); + + if( pe.getPointerType(0).getPointerClass() != MouseEvent.PointerClass.Onscreen || + ( !allowMorePointer && pointerDownCount > 2 ) ) { return false; } - final int pointerDownCount = pe.getPointerCount(); final int eventType = pe.getEventType(); final boolean useY = surface.getWidth() >= surface.getHeight(); // use smallest dimension switch ( eventType ) { @@ -190,7 +198,7 @@ public class PinchToZoomGesture implements GestureHandler { final int d = Math.abs(edge0-edge1); final int dd = d - zoomLastEdgeDist; final float screenEdge = useY ? surface.getHeight() : surface.getWidth(); - final float incr = (float)dd / screenEdge; // [-1..1] + final float incr = dd / screenEdge; // [-1..1] if(DEBUG) { System.err.println("XXX2: id0 "+pIds[0]+" -> idx0 "+p0Idx+", id1 "+pIds[1]+" -> idx1 "+p1Idx); System.err.println("XXX3: d "+d+", ld "+zoomLastEdgeDist+", dd "+dd+", screen "+screenEdge+" -> incr "+incr+", zoom "+zoom+" -> "+(zoom+incr)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 53c813563..9817ea57f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -7,10 +7,10 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -55,12 +55,14 @@ import javax.media.opengl.GLUniformData; */ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererListener { private final FloatBuffer lightPos = Buffers.newDirectFloatBuffer( new float[] { 5.0f, 5.0f, 10.0f } ); - + private ShaderState st = null; private PMVMatrix pmvMatrix = null; private GLUniformData pmvMatrixUniform = null; private GLUniformData colorU = null; - private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; + private float view_rotx = 20.0f, view_roty = 30.0f; + + private final float view_rotz = 0.0f; private float panX = 0.0f, panY = 0.0f, panZ=0.0f; private GearsObjectES2 gear1=null, gear2=null, gear3=null; private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue; @@ -68,7 +70,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL private int swapInterval = 0; private boolean pmvUseBackingArray = true; // the default for PMVMatrix now, since it's faster // private MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter()); - public MouseListener gearsMouse = new GearsMouseAdapter(); + public MouseListener gearsMouse = new GearsMouseAdapter(); public KeyListener gearsKeys = new GearsKeyAdapter(); private TileRendererBase tileRendererInUse = null; private boolean doRotateBeforePrinting; @@ -78,7 +80,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL private float[] clearColor = null; private boolean clearBuffers = true; private boolean verbose = true; - + private PinchToZoomGesture pinchToZoomGesture = null; @@ -94,12 +96,12 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL public void addTileRendererNotify(TileRendererBase tr) { tileRendererInUse = tr; doRotateBeforePrinting = doRotate; - setDoRotation(false); + setDoRotation(false); } @Override public void removeTileRendererNotify(TileRendererBase tr) { tileRendererInUse = null; - setDoRotation(doRotateBeforePrinting); + setDoRotation(doRotateBeforePrinting); } @Override public void startTileRendering(TileRendererBase tr) { @@ -109,27 +111,27 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL public void endTileRendering(TileRendererBase tr) { System.err.println("GearsES2.endTileRendering: "+tr); } - + public void setIgnoreFocus(boolean v) { ignoreFocus = v; } public void setDoRotation(boolean rotate) { this.doRotate = rotate; } public void setClearBuffers(boolean v) { clearBuffers = v; } public void setVerbose(boolean v) { verbose = v; } - + public void setPMVUseBackingArray(boolean pmvUseBackingArray) { this.pmvUseBackingArray = pmvUseBackingArray; } - + /** float[4] */ public void setClearColor(float[] clearColor) { - this.clearColor = clearColor; + this.clearColor = clearColor; } - + public void setGearsColors(FloatBuffer gear1Color, FloatBuffer gear2Color, FloatBuffer gear3Color) { this.gear1Color = gear1Color; this.gear2Color = gear2Color; this.gear3Color = gear3Color; } - + public void setGears(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) { gear1 = g1; gear2 = g2; @@ -162,14 +164,14 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); System.err.println("INIT GL IS: " + gl.getClass().getName()); System.err.println(JoglVersion.getGLStrings(gl, null, false).toString()); - } + } if( !gl.hasGLSL() ) { System.err.println("No GLSL available, no rendering."); return; } gl.glEnable(GL.GL_DEPTH_TEST); - + st = new ShaderState(); // st.setVerbose(true); final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader", @@ -184,7 +186,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL st.attachShaderProgram(gl, sp0, true); // Use debug pipeline // drawable.setGL(new DebugGL(drawable.getGL())); - + pmvMatrix = new PMVMatrix(pmvUseBackingArray); st.attachObject("pmvMatrix", pmvMatrix); pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.glGetPMvMvitMatrixf()); // P, Mv, Mvi and Mvit @@ -210,7 +212,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL System.err.println("gear1 reused: "+gear1); } } - + if(null == gear2) { gear2 = new GearsObjectES2(st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); if(verbose) { @@ -222,7 +224,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL System.err.println("gear2 reused: "+gear2); } } - + if(null == gear3) { gear3 = new GearsObjectES2(st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); if(verbose) { @@ -234,31 +236,31 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL System.err.println("gear3 reused: "+gear3); } } - + final Object upstreamWidget = drawable.getUpstreamWidget(); if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; window.addMouseListener(gearsMouse); window.addKeyListener(gearsKeys); window.addGestureListener(pinchToZoomListener); - pinchToZoomGesture = new PinchToZoomGesture(drawable.getNativeSurface()); + pinchToZoomGesture = new PinchToZoomGesture(drawable.getNativeSurface(), false); window.addGestureHandler(pinchToZoomGesture); } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { final java.awt.Component comp = (java.awt.Component) upstreamWidget; new com.jogamp.newt.event.awt.AWTMouseAdapter(gearsMouse).addTo(comp); new com.jogamp.newt.event.awt.AWTKeyAdapter(gearsKeys).addTo(comp); } - + st.useProgram(gl, false); - + System.err.println(Thread.currentThread()+" GearsES2.init FIN"); } - - private final GestureHandler.GestureListener pinchToZoomListener = new GestureHandler.GestureListener() { + + private final GestureHandler.GestureListener pinchToZoomListener = new GestureHandler.GestureListener() { @Override public void gestureDetected(GestureEvent gh) { final PinchToZoomGesture.ZoomEvent ze = (PinchToZoomGesture.ZoomEvent) gh; - final float zoom = ze.getZoom() * ( ze.getTrigger().getPointerCount() - 1 ); + final float zoom = ze.getZoom(); // * ( ze.getTrigger().getPointerCount() - 1 ); <- too much .. panZ = zoom * 30f - 30f; // [0 .. 2] -> [-30f .. 30f] } }; @@ -266,35 +268,35 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL @Override public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { final GL2ES2 gl = glad.getGL().getGL2ES2(); - if(-1 != swapInterval) { + if(-1 != swapInterval) { gl.setSwapInterval(swapInterval); } reshapeImpl(gl, x, y, width, height, width, height); } - + @Override public void reshapeTile(TileRendererBase tr, - int tileX, int tileY, int tileWidth, int tileHeight, + int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final GL2ES2 gl = tr.getAttachedDrawable().getGL().getGL2ES2(); gl.setSwapInterval(0); reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); } - + void reshapeImpl(GL2ES2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers(); System.err.println(Thread.currentThread()+" GearsES2.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); - + if( !gl.hasGLSL() ) { return; } - + st.useProgram(gl, true); pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); pmvMatrix.glLoadIdentity(); - + // compute projection parameters 'normal' - float left, right, bottom, top; + float left, right, bottom, top; if( imageHeight > imageWidth ) { float a = (float)imageHeight / (float)imageWidth; left = -1.0f; @@ -310,27 +312,27 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL } final float w = right - left; final float h = top - bottom; - + // compute projection parameters 'tiled' final float l = left + tileX * w / imageWidth; final float r = l + tileWidth * w / imageWidth; final float b = bottom + tileY * h / imageHeight; final float t = b + tileHeight * h / imageHeight; - + final float _w = r - l; final float _h = t - b; if(verbose) { System.err.println(">> angle "+angle+", [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); } - + pmvMatrix.glFrustumf(l, r, b, t, 5.0f, 200.0f); - + pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); pmvMatrix.glTranslatef(0.0f, 0.0f, -40.0f); st.uniform(gl, pmvMatrixUniform); st.useProgram(gl, false); - + // System.err.println(Thread.currentThread()+" GearsES2.reshape FIN"); } // private boolean useAndroidDebug = false; @@ -339,7 +341,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES2.dispose: tileRendererInUse "+tileRendererInUse); final Object upstreamWidget = drawable.getUpstreamWidget(); - if (upstreamWidget instanceof Window) { + if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; window.removeMouseListener(gearsMouse); window.removeKeyListener(gearsKeys); @@ -357,12 +359,12 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL gear2.destroy(gl); gear2 = null; gear3.destroy(gl); - gear3 = null; + gear3 = null; pmvMatrix = null; - colorU = null; + colorU = null; st.destroy(gl); st = null; - + System.err.println(Thread.currentThread()+" GearsES2.dispose FIN"); } @@ -387,7 +389,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL } else { hasFocus = true; } - + if( clearBuffers ) { if( null != clearColor ) { gl.glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); @@ -400,7 +402,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL } // Special handling for the case where the GLJPanel is translucent // and wants to be composited with other Java 2D content - if (GLProfile.isAWTAvailable() && + if (GLProfile.isAWTAvailable() && (drawable instanceof javax.media.opengl.awt.GLJPanel) && !((javax.media.opengl.awt.GLJPanel) drawable).isOpaque() && ((javax.media.opengl.awt.GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) { @@ -408,13 +410,13 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL } else { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); } - } + } if( !gl.hasGLSL() ) { return; } gl.glEnable(GL.GL_CULL_FACE); - + st.useProgram(gl, true); pmvMatrix.glPushMatrix(); pmvMatrix.glTranslatef(panX, panY, panZ); @@ -424,20 +426,20 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL gear1.draw(gl, -3.0f, -2.0f, 1f * angle - 0f); gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f); - gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f); + gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f); pmvMatrix.glPopMatrix(); st.useProgram(gl, false); - + gl.glDisable(GL.GL_CULL_FACE); } - + boolean confinedFixedCenter = false; - + public void setConfinedFixedCenter(boolean v) { confinedFixedCenter = v; } - - class GearsKeyAdapter extends KeyAdapter { + + class GearsKeyAdapter extends KeyAdapter { public void keyPressed(KeyEvent e) { int kc = e.getKeyCode(); if(KeyEvent.VK_LEFT == kc) { @@ -454,7 +456,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL class GearsMouseAdapter implements MouseListener{ private int prevMouseX, prevMouseY; - + @Override public void mouseClicked(MouseEvent e) { } @@ -476,12 +478,12 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL panZ += incr; System.err.println("panZ.2: incr "+incr+", dblZoom "+e.isShiftDown()+" -> "+panZ); } else { - // panning + // panning panX -= rot[0]; // positive -> left panY += rot[1]; // positive -> up } } - + public void mousePressed(MouseEvent e) { if( e.getPointerCount()==1 ) { prevMouseX = e.getX(); @@ -507,15 +509,15 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL prevMouseY = e.getY(); } } - + public void mouseDragged(MouseEvent e) { navigate(e); } - + private void navigate(MouseEvent e) { int x = e.getX(); int y = e.getY(); - + int width, height; Object source = e.getSource(); Window window = null; @@ -533,12 +535,12 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL height=comp.getHeight(); } else { throw new RuntimeException("Event source neither Window nor Component: "+source); - } + } final float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width); final float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height); view_rotx += thetaX; view_roty += thetaY; - if(e.isConfined() && confinedFixedCenter && null!=window) { + if(e.isConfined() && confinedFixedCenter && null!=window) { x=window.getWidth()/2; y=window.getHeight()/2; window.warpPointer(x, y); -- cgit v1.2.3 From 7f7a23dd0ddf106e6f0c69fc2a05ff92ac56200e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 27 Oct 2013 17:51:08 +0100 Subject: Bug 776 GLContext Sharing: Refine API for relaxed and lazy GLContext sharing ; Fix GLContext memory contract (volatile) (Unit test remarks see below) - Add shared GLContext queries - Refined GLContextShareSet: - Use IdentityHashMap since GLContext's can only be identical w/ same reference (footprint, performance) - Add API doc for clarification - Add methods: - ArrayList getCreatedShares(final GLContext context) - ArrayList getDestroyedShares(final GLContext context) - Use 'final' where possible - Add GLContext methods: - boolean isShared() - List getCreatedShares() - List getDestroyedShares() - Add GLSharedContextSetter interface defining setting a shared GLContext directly (GLContext) or via a GLAutoDrawable: - setSharedContext(GLContext) - setSharedAutoDrawable(GLAutoDrawable) Both cause initialization/creation of GLAutoDrawable's drawable/context to be postponed, if the shared GLContext is not yet created natively or the shared GLAutoDrawable's GLContext does not yet exist. Most of impl. resides in GLDrawableHelper Implemented in: - GLAutoDrawableBase, GLOffscreenAutoDrawable - GLWindow - AWT GLCanvas TODO: - GLJPanel - SWT GLCanvas - GLDrawableFactory: - Add 'GLOffscreenAutoDrawable createOffscreenAutoDrawable(..)' variant w/o passing the optional shared GLContext _and_ specifying lazy GLContext creation. This allows to benefit from GLSharedContextSetter contract. Lazy GLContext creation is performed at 2st display() call at the latest. All JOGL code and unit tests use this new method now. - Mark 'createOffscreenAutoDrawable(..)' w/ shared GLContext argument and immediate GLContext creation deprecated - shall be removed in 2.2.0 - Make reference to GLContext and it's native handle volatile Since we rely on the query 'GLContext.isCreated()' to properly allow GLAutoDrawable's to query whether a shared GLContext is natively created (already), the handle must be volatile since such query and the actual creation may operate on different threads. +++++ - Add/Refine shared GLContext unit tests demonstrating diff. sharing methods. All variants of using shared GLContext: com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBO* Most convenient way to share via setSharedAutoDrawable(GLAutoDrawable): com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2[NEWT|AWT]3 AWT use w/ JTabbedPane using setSharedAutoDrawable(GLAutoDrawable): com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT --- make/scripts/tests.sh | 32 +- .../com/jogamp/opengl/GLAutoDrawableDelegate.java | 9 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 4 +- .../com/jogamp/opengl/util/awt/TextRenderer.java | 32 +- src/jogl/classes/javax/media/opengl/GLContext.java | 21 +- .../javax/media/opengl/GLDrawableFactory.java | 55 +++- .../media/opengl/GLOffscreenAutoDrawable.java | 2 +- .../javax/media/opengl/GLSharedContextSetter.java | 78 +++++ .../classes/javax/media/opengl/awt/GLCanvas.java | 122 +++++--- .../classes/javax/media/opengl/awt/GLJPanel.java | 46 +-- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 72 +++-- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 4 +- .../classes/jogamp/opengl/GLContextShareSet.java | 150 ++++++---- .../jogamp/opengl/GLDrawableFactoryImpl.java | 13 + .../classes/jogamp/opengl/GLDrawableHelper.java | 60 +++- .../jogamp/opengl/GLOffscreenAutoDrawableImpl.java | 2 +- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 7 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 45 ++- .../jogl/acore/TestFBOAutoDrawableDeadlockAWT.java | 28 +- .../jogl/acore/TestFBOAutoDrawableFactoryNEWT.java | 130 ++++----- ...tFBOOffThreadSharedContextMix2DemosES2NEWT.java | 100 +++---- .../TestFBOOnThreadSharedContext1DemoES2NEWT.java | 89 +++--- .../jogl/acore/TestGLAutoDrawableDelegateNEWT.java | 46 +-- ...estGLAutoDrawableFactoryES2OffscrnCapsNEWT.java | 106 +++---- ...estGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java | 118 ++++---- ...TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java | 66 ++--- .../jogl/acore/TestGLExtensionQueryOffscreen.java | 22 +- .../jogl/acore/TestNEWTCloseX11DisplayBug565.java | 24 +- .../junit/jogl/acore/TestSharedContextListAWT.java | 43 +-- .../jogl/acore/TestSharedContextListNEWT.java | 20 +- .../jogl/acore/TestSharedContextNewtAWTBug523.java | 94 +++--- .../jogl/acore/TestSharedContextVBOES1NEWT.java | 75 +++-- .../jogl/acore/TestSharedContextVBOES2AWT3.java | 321 +++++++++++++++++++++ .../jogl/acore/TestSharedContextVBOES2NEWT.java | 245 ---------------- .../jogl/acore/TestSharedContextVBOES2NEWT0.java | 270 +++++++++++++++++ .../jogl/acore/TestSharedContextVBOES2NEWT1.java | 295 +++++++++++++++++++ .../jogl/acore/TestSharedContextVBOES2NEWT2.java | 315 ++++++++++++++++++++ .../jogl/acore/TestSharedContextVBOES2NEWT3.java | 296 +++++++++++++++++++ .../acore/TestSharedContextWithJTabbedPaneAWT.java | 264 +++++++++++++++++ .../acore/glels/GLContextDrawableSwitchBase.java | 96 +++--- .../glels/TestGLContextDrawableSwitch02AWT.java | 52 ++-- .../awt/TestBug461FBOSupersamplingSwingAWT.java | 46 +-- .../junit/jogl/caps/TestBug605FlippedImageAWT.java | 2 +- .../jogl/caps/TestBug605FlippedImageNEWT.java | 2 +- .../junit/jogl/caps/TestMultisampleES1AWT.java | 18 +- .../opengl/test/junit/jogl/demos/es1/GearsES1.java | 85 +++--- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 114 ++++++-- .../jogl/glu/TestBug365TextureGenerateMipMaps.java | 108 ++++--- .../tile/TestRandomTiledRendering2GL2NEWT.java | 26 +- .../junit/jogl/tile/TestTiledRendering2NEWT.java | 36 +-- .../opengl/test/junit/util/AWTRobotUtil.java | 230 ++++++++------- .../jogamp/opengl/test/junit/util/MiscUtils.java | 73 +++-- 52 files changed, 3301 insertions(+), 1308 deletions(-) create mode 100644 src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextWithJTabbedPaneAWT.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 3f4fe9c19..23477b254 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -353,9 +353,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* @@ -368,10 +367,25 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAO $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLExtensionQueryOffscreen $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* + +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* @@ -391,12 +405,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* - #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT $* @@ -418,6 +426,9 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* + #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* @@ -447,9 +458,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testawt jogamp.newt.awt.opengl.VersionApplet $* #testawt javax.media.opengl.awt.GLCanvas $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java index ce58d29c1..6b1bb0e5e 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java @@ -64,11 +64,18 @@ import jogamp.opengl.GLDrawableImpl; */ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAutoDrawable { /** + *

                      + * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)} + * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
                      + * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account + * which has been set {@link #setSharedContext(GLContext) directly} + * or {@link #setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}. + *

                      * @param drawable a valid {@link GLDrawable}, may not be {@link GLDrawable#isRealized() realized} yet. * @param context a valid {@link GLContext}, * may not have been made current (created) yet, * may not be associated w/ drawable yet, - * may be null for lazy initialization + * may be null for lazy initialization at 1st {@link #display()}. * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, * otherwise pass false. Closing the device is required in case diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 1a3e1e0c0..5e3731984 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -242,7 +242,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private class DisposeGLEventListenerAction implements Runnable { private GLEventListener listener; - private boolean remove; + private final boolean remove; private DisposeGLEventListenerAction(GLEventListener listener, boolean remove) { this.listener = listener; this.remove = remove; @@ -677,7 +677,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLContext getContext() { - return null != drawable ? context : null; + return context; } @Override diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java index 3662223f4..46dc73003 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java @@ -159,20 +159,20 @@ public class TextRenderer { static final int kTotalBufferSizeBytesTex = kTotalBufferSizeCoordsTex * 4; static final int kSizeInBytes_OneVertices_VertexData = kCoordsPerVertVerts * 4; static final int kSizeInBytes_OneVertices_TexData = kCoordsPerVertTex * 4; - private Font font; - private boolean antialiased; - private boolean useFractionalMetrics; + private final Font font; + private final boolean antialiased; + private final boolean useFractionalMetrics; // Whether we're attempting to use automatic mipmap generation support private boolean mipmap; private RectanglePacker packer; private boolean haveMaxSize; - private RenderDelegate renderDelegate; + private final RenderDelegate renderDelegate; private TextureRenderer cachedBackingStore; private Graphics2D cachedGraphics; private FontRenderContext cachedFontRenderContext; - private Map stringLocations = new HashMap(); - private GlyphProducer mGlyphProducer; + private final Map stringLocations = new HashMap(); + private final GlyphProducer mGlyphProducer; private int numRenderCycles; @@ -905,8 +905,8 @@ public class TextRenderer { private void debug(GL gl) { dbgFrame = new Frame("TextRenderer Debug Output"); - GLCanvas dbgCanvas = new GLCanvas(new GLCapabilities(gl.getGLProfile()), null, - GLContext.getCurrent(), null); + GLCanvas dbgCanvas = new GLCanvas(new GLCapabilities(gl.getGLProfile())); + dbgCanvas.setSharedContext(GLContext.getCurrent()); dbgCanvas.addGLEventListener(new DebugListener(gl, dbgFrame)); dbgFrame.add(dbgCanvas); @@ -1085,7 +1085,7 @@ public class TextRenderer { static class TextData { // Back-pointer to String this TextData describes, if it // represents a String rather than a single glyph - private String str; + private final String str; // If this TextData represents a single glyph, this is its // unicode ID @@ -1096,7 +1096,7 @@ public class TextRenderer { // 2D coordinate system) at which the string must be rasterized in // order to fit within the rectangle -- the leftmost point of the // baseline. - private Point origin; + private final Point origin; // This represents the pre-normalized rectangle, which fits // within the rectangle on the backing store. We keep a @@ -1104,7 +1104,7 @@ public class TextRenderer { // prevent bleeding of adjacent letters when using GL_LINEAR // filtering for rendering. The origin of this rectangle is // equivalent to the origin above. - private Rectangle2D origRect; + private final Rectangle2D origRect; private boolean used; // Whether this text was used recently @@ -1375,7 +1375,7 @@ public class TextRenderer { // // A temporary to prevent excessive garbage creation - private char[] singleUnicode = new char[1]; + private final char[] singleUnicode = new char[1]; /** A Glyph represents either a single unicode glyph or a substring of characters to be drawn. The reason for the dual @@ -1497,10 +1497,10 @@ public class TextRenderer { int width = (int) origRect.getWidth(); int height = (int) origRect.getHeight(); - float tx1 = xScale * (float) texturex / (float) renderer.getWidth(); + float tx1 = xScale * texturex / renderer.getWidth(); float ty1 = yScale * (1.0f - ((float) texturey / (float) renderer.getHeight())); - float tx2 = xScale * (float) (texturex + width) / (float) renderer.getWidth(); + float tx2 = xScale * (texturex + width) / renderer.getWidth(); float ty2 = yScale * (1.0f - ((float) (texturey + height) / (float) renderer.getHeight())); @@ -1829,7 +1829,7 @@ public class TextRenderer { GL2 gl = GLContext.getCurrentGL().getGL2(); TextureRenderer renderer = getBackingStore(); - Texture texture = renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious? + renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious? mVertCoords.rewind(); mTexCoords.rewind(); @@ -1872,7 +1872,7 @@ public class TextRenderer { private void drawIMMEDIATE() { if (mOutstandingGlyphsVerticesPipeline > 0) { TextureRenderer renderer = getBackingStore(); - Texture texture = renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious? + renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious? GL2 gl = GLContext.getCurrentGL().getGL2(); gl.glBegin(GL2.GL_QUADS); diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index e83d60b66..5c6c7073a 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -44,12 +44,14 @@ import java.nio.IntBuffer; import java.util.HashMap; import java.util.IdentityHashMap; import java.util.Iterator; +import java.util.List; import java.util.Set; import javax.media.nativewindow.AbstractGraphicsDevice; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; +import jogamp.opengl.GLContextShareSet; import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionNumber; @@ -205,7 +207,7 @@ public abstract class GLContext { protected final RecursiveLock lock = LockFactory.createRecursiveLock(); /** The underlying native OpenGL context */ - protected long contextHandle; + protected volatile long contextHandle; protected GLContext() { resetStates(true); @@ -242,6 +244,21 @@ public abstract class GLContext { drawableRetargeted = false; } + /** Returns true if this GLContext is shared, otherwise false. */ + public final boolean isShared() { + return GLContextShareSet.isShared(this); + } + + /** Returns a new list of created GLContext shared with this GLContext. */ + public final List getCreatedShares() { + return GLContextShareSet.getCreatedShares(this); + } + + /** Returns a new list of destroyed GLContext shared with this GLContext. */ + public final List getDestroyedShares() { + return GLContextShareSet.getDestroyedShares(this); + } + /** * Returns the instance of {@link GLRendererQuirks}, allowing one to determine workarounds. * @return instance of {@link GLRendererQuirks} if context was made current once, otherwise null. @@ -590,7 +607,7 @@ public abstract class GLContext { sb.append(toHexString(hashCode())); sb.append(", handle "); sb.append(toHexString(contextHandle)); - sb.append(", "); + sb.append(", isShared "+isShared()+", "); sb.append(getGL()); sb.append(",\n\t quirks: "); if(null != glRendererQuirks) { diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 26bafd961..817dff8ad 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -475,7 +475,8 @@ public abstract class GLDrawableFactory { *

                      * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e. * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} == true, - * it is auto-configured. The latter will set offscreen and also FBO or Pbuffer, whichever is available in that order. + * it is auto-configured. Auto configuration will set {@link GLCapabilitiesImmutable caps} to offscreen + * and FBO or Pbuffer, whichever is available in that order. *

                      *

                      * A FBO based auto drawable, {@link GLOffscreenAutoDrawable.FBO}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()} @@ -501,12 +502,62 @@ public abstract class GLDrawableFactory { * the creation of the Offscreen to fail. * * @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) + * @deprecated Use {@link #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) */ public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, int width, int height, GLContext shareWith) throws GLException; + + /** + * Creates a {@link GLDrawable#isRealized() realized} {@link GLOffscreenAutoDrawable} + * incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. + *

                      + * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized} + * without an assigned {@link GLContext}.
                      + * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)} + * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
                      + * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account + * which has been set {@link GLOffscreenAutoDrawable#setSharedContext(GLContext) directly} + * or {@link GLOffscreenAutoDrawable#setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}. + *

                      + *

                      + * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e. + * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} == true, + * it is auto-configured. Auto configuration will set {@link GLCapabilitiesImmutable caps} to offscreen + * and FBO or Pbuffer, whichever is available in that order. + *

                      + *

                      + * A FBO based auto drawable, {@link GLOffscreenAutoDrawable.FBO}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()} + * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true. + *

                      + *

                      + * A Pbuffer based auto drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()} + * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true. + *

                      + *

                      + * If neither FBO nor Pbuffer is available, + * a simple pixmap/bitmap auto drawable is created, which is unlikely to be hardware accelerated. + *

                      + * + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. + * @param caps the requested GLCapabilties + * @param chooser the custom chooser, may be null for default + * @param width the requested offscreen width + * @param height the requested offscreen height + * @return the created and initialized offscreen {@link GLOffscreenAutoDrawable} instance + * + * @throws GLException if any window system-specific errors caused + * the creation of the Offscreen to fail. + * + * @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) + */ + public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, + GLCapabilitiesImmutable caps, + GLCapabilitiesChooser chooser, + int width, int height) throws GLException; + /** * Creates an {@link GLDrawable#isRealized() unrealized} offscreen {@link GLDrawable} * incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. @@ -625,7 +676,7 @@ public abstract class GLDrawableFactory { *

                      * * See the note in the overview documentation on - * context sharing. + * context sharing. * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. * @param capabilities the requested capabilities diff --git a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java index be90d935f..d34edaf2e 100644 --- a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java @@ -40,7 +40,7 @@ import com.jogamp.opengl.FBObject; * with it's {@link #setSize(int, int)} functionality. *

                      */ -public interface GLOffscreenAutoDrawable extends GLAutoDrawable { +public interface GLOffscreenAutoDrawable extends GLAutoDrawable, GLSharedContextSetter { /** * Resize this auto drawable. diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java new file mode 100644 index 000000000..d5a10931e --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java @@ -0,0 +1,78 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package javax.media.opengl; + +/** + * Adds capabilities to set a shared {@link GLContext} directly or via an {@link GLAutoDrawable}. + *

                      + * Warning: Don't reference this interface directly, since it may end up in {@link GLAutoDrawable} + *

                      + */ +public interface GLSharedContextSetter extends GLAutoDrawable { + /** + * Specifies an {@link GLContext OpenGL context}, which shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. + *

                      + * Since the {@link GLDrawable drawable} and {@link GLContext context} is created + * at {@link GLAutoDrawable#initialization GLAutoDrawable initialization} + * this method shall be called beforehand to have any effect. + *

                      + *

                      + * A set sharedContext will block context creation, i.e. {@link GLAutoDrawable#initialization GLAutoDrawable initialization}, + * as long it is not {@link GLContext#isCreated() created natively}. + *

                      + * + * @param sharedContext The OpenGL context to be shared by this {@link GLAutoDrawable}'s {@link GLContext}. + * @throws IllegalStateException if a {@link #setSharedContext(GLContext) shared GLContext} + * or {@link #setSharedAutoDrawable(GLAutoDrawable) shared GLAutoDrawable} is already set, + * the given sharedContext is null or equal to this {@link GLAutoDrawable}'s context. + * @see #setSharedAutoDrawable(GLAutoDrawable) + */ + void setSharedContext(GLContext sharedContext) throws IllegalStateException; + + /** + * Specifies an {@link GLAutoDrawable}, which {@link GLContext OpenGL context} shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. + *

                      + * Since the {@link GLDrawable drawable} and {@link GLContext context} is created + * at {@link GLAutoDrawable#initialization GLAutoDrawable initialization} + * this method shall be called beforehand to have any effect. + *

                      + *

                      + * A set sharedAutoDrawable will block context creation, i.e. {@link GLAutoDrawable#initialization GLAutoDrawable initialization}, + * as long it's {@link GLContext} is null + * or has not been {@link GLContext#isCreated() created natively}. + *

                      + * + * @param sharedContext The GLAutoDrawable, which OpenGL context shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. + * @throws IllegalStateException if a {@link #setSharedContext(GLContext) shared GLContext} + * or {@link #setSharedAutoDrawable(GLAutoDrawable) shared GLAutoDrawable} is already set, + * the given sharedAutoDrawable is null or equal to this GLAutoDrawable. + * @see #setSharedContext(GLContext) + */ + void setSharedAutoDrawable(GLAutoDrawable sharedAutoDrawable) throws IllegalStateException; +} diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 8757c7a26..b070ddd7d 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -81,6 +81,7 @@ import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; +import javax.media.opengl.GLSharedContextSetter; import javax.media.opengl.Threading; import com.jogamp.common.GlueGenVersion; @@ -114,7 +115,7 @@ import jogamp.opengl.awt.AWTTilePainter; interfaces when adding a heavyweight doesn't work either because of Z-ordering or LayoutManager problems. * - *
                      Offscreen Layer Remarks
                      + *
                      Offscreen Layer Remarks
                      * * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} * maybe called to use an offscreen drawable (FBO or PBuffer) allowing @@ -124,7 +125,7 @@ import jogamp.opengl.awt.AWTTilePainter; * is being called if {@link GLCapabilitiesImmutable#isOnscreen()} is false. *

                      * - *
                      Java2D OpenGL Remarks
                      + *
                      Java2D OpenGL Remarks
                      * * To avoid any conflicts with a potential Java2D OpenGL context,
                      * you shall consider setting the following JVM properties:
                      @@ -141,7 +142,7 @@ import jogamp.opengl.awt.AWTTilePainter; *
                    • sun.java2d.noddraw=true
                    • * * - *
                      Disable Background Erase
                      + *
                      Disable Background Erase
                      * * GLCanvas tries to disable background erase for the AWT Canvas * before native peer creation (X11) and after it (Windows),
                      @@ -153,7 +154,7 @@ import jogamp.opengl.awt.AWTTilePainter; */ @SuppressWarnings("serial") -public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosingProtocol, OffscreenLayerOption, AWTPrintLifecycle { +public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosingProtocol, OffscreenLayerOption, AWTPrintLifecycle, GLSharedContextSetter { private static final boolean DEBUG = Debug.debug("GLCanvas"); @@ -162,18 +163,20 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private AWTGraphicsConfiguration awtConfig; private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access private volatile JAWTWindow jawtWindow; // the JAWTWindow presentation of this AWT Canvas, bound to the 'drawable' lifecycle - private GLContextImpl context; + private volatile GLContextImpl context; private volatile boolean sendReshape = false; // volatile: maybe written by EDT w/o locking // copy of the cstr args, mainly for recreation - private GLCapabilitiesImmutable capsReqUser; - private GLCapabilitiesChooser chooser; - private GLContext shareWith; + private final GLCapabilitiesImmutable capsReqUser; + private final GLCapabilitiesChooser chooser; private int additionalCtxCreationFlags = 0; - private GraphicsDevice device; + private final GraphicsDevice device; private boolean shallUseOffscreenLayer = false; - private AWTWindowClosingProtocol awtWindowClosingProtocol = + protected GLContext sharedContext = null; + protected GLAutoDrawable sharedAutoDrawable = null; + + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override public void run() { @@ -207,6 +210,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing * * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. * @see GLCanvas#GLCanvas(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, javax.media.opengl.GLContext, java.awt.GraphicsDevice) + * @deprecated Use {@link #GLCanvas(GLCapabilitiesImmutable)} + * and set shared GLContext via {@link #setSharedContext(GLContext)} or {@link #setSharedAutoDrawable(GLAutoDrawable)}. */ public GLCanvas(GLCapabilitiesImmutable capsReqUser, GLContext shareWith) throws GLException @@ -214,6 +219,26 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing this(capsReqUser, null, shareWith, null); } + /** Creates a new GLCanvas component. The passed GLCapabilities + specifies the OpenGL capabilities for the component; if null, a + default set of capabilities is used. The GLCapabilitiesChooser + specifies the algorithm for selecting one of the available + GLCapabilities for the component; a DefaultGLCapabilitesChooser + is used if null is passed for this argument. + The passed GraphicsDevice indicates the screen on + which to create the GLCanvas; the GLDrawableFactory uses the + default screen device of the local GraphicsEnvironment if null + is passed for this argument. + * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. + */ + public GLCanvas(GLCapabilitiesImmutable capsReqUser, + GLCapabilitiesChooser chooser, + GraphicsDevice device) + throws GLException + { + this(capsReqUser, chooser, null, device); + } + /** Creates a new GLCanvas component. The passed GLCapabilities specifies the OpenGL capabilities for the component; if null, a default set of capabilities is used. The GLCapabilitiesChooser @@ -224,12 +249,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing textures, display lists and other OpenGL state, and may be null if sharing is not desired. See the note in the overview documentation on context + href="../../../spec-summary.html#SHARING">context sharing. The passed GraphicsDevice indicates the screen on which to create the GLCanvas; the GLDrawableFactory uses the default screen device of the local GraphicsEnvironment if null is passed for this argument. * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. + * @deprecated Use {@link #GLCanvas(GLCapabilitiesImmutable, GLCapabilitiesChooser, GraphicsDevice)} + * and set shared GLContext via {@link #setSharedContext(GLContext)} or {@link #setSharedAutoDrawable(GLAutoDrawable)}. */ public GLCanvas(GLCapabilitiesImmutable capsReqUser, GLCapabilitiesChooser chooser, @@ -266,10 +293,20 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // instantiation will be issued in addNotify() this.capsReqUser = capsReqUser; this.chooser = chooser; - this.shareWith = shareWith; + this.sharedContext = shareWith; this.device = device; } + @Override + public final void setSharedContext(GLContext sharedContext) throws IllegalStateException { + helper.setSharedContext(this.context, sharedContext); + } + + @Override + public final void setSharedAutoDrawable(GLAutoDrawable sharedAutoDrawable) throws IllegalStateException { + helper.setSharedAutoDrawable(this, sharedAutoDrawable); + } + @Override public final Object getUpstreamWidget() { return this; @@ -383,7 +420,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing destroyImpl( true ); // recreation! awtConfig = config; - createDrawableAndContext( true ); + createJAWTDrawableAndContext(); validateGLDrawable(); } else { awtConfig = config; @@ -592,7 +629,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // after native peer is valid: Windows disableBackgroundErase(); - createDrawableAndContext( true ); + createJAWTDrawableAndContext(); // init drawable by paint/display makes the init sequence more equal // for all launch flavors (applet/javaws/..) @@ -608,22 +645,35 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } - private void createDrawableAndContext(boolean createJAWTWindow) { + private void createJAWTDrawableAndContext() { if ( !Beans.isDesignTime() ) { - if( createJAWTWindow ) { - jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); - jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); - } + jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); + jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); jawtWindow.lockSurface(); try { drawable = (GLDrawableImpl) GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); - context = (GLContextImpl) drawable.createContext(shareWith); - context.setContextCreationFlags(additionalCtxCreationFlags); + createContextImpl(drawable); } finally { jawtWindow.unlockSurface(); } } } + private boolean createContextImpl(final GLDrawable drawable) { + final GLContext[] shareWith = { null }; + if( !helper.isSharedGLContextPending(shareWith) ) { + context = (GLContextImpl) drawable.createContext(shareWith[0]); + context.setContextCreationFlags(additionalCtxCreationFlags); + if(DEBUG) { + System.err.println(getThreadName()+": Context created: has shared "+(null != shareWith[0])); + } + return true; + } else { + if(DEBUG) { + System.err.println(getThreadName()+": Context !created: pending share"); + } + return false; + } + } private boolean validateGLDrawable() { if( Beans.isDesignTime() || !isDisplayable() ) { @@ -631,17 +681,22 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } final GLDrawable _drawable = drawable; if ( null != _drawable ) { - if( _drawable.isRealized() ) { - return true; - } - if( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { - return false; // early out! + boolean res = _drawable.isRealized(); + if( !res ) { + // re-try drawable creation + if( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { + return false; // early out! + } + setRealized(true); + res = _drawable.isRealized(); + if(DEBUG) { + System.err.println(getThreadName()+": Realized Drawable: isRealized "+res+", "+_drawable.toString()); + // Thread.dumpStack(); + } } - setRealized(true); - final boolean res = _drawable.isRealized(); - if(DEBUG) { - System.err.println(getThreadName()+": Realized Drawable: isRealized "+res+", "+_drawable.toString()); - // Thread.dumpStack(); + if( res && null == context ) { + // re-try context creation + res = createContextImpl(_drawable); // pending creation. } return res; } @@ -791,8 +846,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, - null); + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } @@ -1251,7 +1305,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private class DisposeGLEventListenerAction implements Runnable { GLEventListener listener; - private boolean remove; + private final boolean remove; private DisposeGLEventListenerAction(GLEventListener listener, boolean remove) { this.listener = listener; this.remove = remove; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 84db62515..93e8b2c0b 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -108,22 +108,23 @@ import com.jogamp.opengl.util.texture.TextureState; support. Provided for compatibility with Swing user interfaces when adding a heavyweight doesn't work either because of Z-ordering or LayoutManager problems. -

                      +

                      The GLJPanel can be made transparent by creating it with a GLCapabilities object with alpha bits specified and calling {@link #setOpaque}(false). Pixels with resulting OpenGL alpha values less - than 1.0 will be overlaid on any underlying Swing rendering.

                      -

                      + than 1.0 will be overlaid on any underlying Swing rendering. +

                      +

                      This component attempts to use hardware-accelerated rendering via FBO or pbuffers and falls back on to software rendering if none of the former are available using {@link GLDrawableFactory#createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) GLDrawableFactory.createOffscreenDrawable(..)}.
                      -

                      -

                      +

                      +

                      In case FBO is used and GLSL is available, a fragment shader is utilized to flip the FBO texture vertically. This hardware-accelerated step can be disabled via system property jogl.gljpanel.noglsl. See details here. -

                      -

                      +

                      +

                      The OpenGL path is concluded by copying the rendered pixels an {@link BufferedImage} via {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)} for later Java2D composition.

                      @@ -210,7 +211,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return singleAWTGLPixelBufferProvider; } - private GLDrawableHelper helper = new GLDrawableHelper(); + private final GLDrawableHelper helper = new GLDrawableHelper(); private volatile boolean isInitialized; // @@ -219,10 +220,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private AWTGLPixelBufferProvider customPixelBufferProvider = null; /** Single buffered offscreen caps */ private GLCapabilitiesImmutable offscreenCaps; - private GLProfile glProfile; - private GLDrawableFactoryImpl factory; - private GLCapabilitiesChooser chooser; - private GLContext shareWith; + private final GLProfile glProfile; + private final GLDrawableFactoryImpl factory; + private final GLCapabilitiesChooser chooser; + private final GLContext shareWith; private int additionalCtxCreationFlags = 0; // Lazy reshape notification: reshapeWidth -> panelWidth -> backend.width @@ -248,13 +249,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private volatile Backend backend; // Used by all backends either directly or indirectly to hook up callbacks - private Updater updater = new Updater(); + private final Updater updater = new Updater(); private boolean oglPipelineUsable() { return null == customPixelBufferProvider && useJava2DGLPipeline && java2DGLPipelineOK; } - private AWTWindowClosingProtocol awtWindowClosingProtocol = + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override public void run() { @@ -289,7 +290,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing GLContext specifies an OpenGL context with which to share textures, display lists and other OpenGL state, and may be null if sharing is not desired. See the note in the overview documentation on - context sharing. + context sharing.

                      Note: Sharing cannot be enabled using J2D OpenGL FBO sharing, since J2D GL Context must be shared and we can only share one context. @@ -572,8 +573,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, - null); + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } @@ -1158,7 +1158,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private class DisposeGLEventListenerAction implements Runnable { GLEventListener listener; - private boolean remove; + private final boolean remove; private DisposeGLEventListenerAction(GLEventListener listener, boolean remove) { this.listener = listener; this.remove = remove; @@ -1268,12 +1268,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing protected IntBuffer readBackIntsForCPUVFlip; // Implementation using software rendering - private GLDrawableImpl offscreenDrawable; + private volatile GLDrawableImpl offscreenDrawable; private boolean offscreenIsFBO; private FBObject fboFlipped; private GLSLTextureRaster glslTextureRaster; - private GLContextImpl offscreenContext; + private volatile GLContextImpl offscreenContext; private boolean flipVertical; // For saving/restoring of OpenGL state during ReadPixels @@ -1694,11 +1694,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private GLContext joglContext; // State captured from Java2D OpenGL context necessary in order to // properly render into Java2D back buffer - private int[] drawBuffer = new int[1]; - private int[] readBuffer = new int[1]; + private final int[] drawBuffer = new int[1]; + private final int[] readBuffer = new int[1]; // This is required when the FBO option of the Java2D / OpenGL // pipeline is active - private int[] frameBuffer = new int[1]; + private final int[] frameBuffer = new int[1]; // Current (as of this writing) NVidia drivers have a couple of bugs // relating to the sharing of framebuffer and renderbuffer objects // between contexts. It appears we have to (a) reattach the color diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index bb2983399..42d0a2ec4 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -45,8 +45,10 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; +import javax.media.opengl.GLSharedContextSetter; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.opengl.GLAutoDrawableDelegate; @@ -59,17 +61,18 @@ import com.jogamp.opengl.GLStateKeeper; * * @see GLAutoDrawable * @see GLAutoDrawableDelegate + * @see GLOffscreenAutoDrawable + * @see GLOffscreenAutoDrawableImpl * @see GLPBufferImpl - * @see GLWindow + * @see com.jogamp.newt.opengl.GLWindow */ -public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeeper, FPSCounter { +public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeeper, FPSCounter, GLSharedContextSetter { public static final boolean DEBUG = GLDrawableImpl.DEBUG; - protected final GLDrawableHelper helper = new GLDrawableHelper(); protected final FPSCounterImpl fpsCounter = new FPSCounterImpl(); protected volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access - protected GLContextImpl context; + protected volatile GLContextImpl context; protected boolean preserveGLELSAtDestroy; protected GLEventListenerState glels; protected GLStateKeeper.Listener glStateKeeperListener; @@ -79,12 +82,19 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe protected volatile boolean sendDestroy = false; // volatile: maybe written by WindowManager thread w/o locking /** + *

                      + * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)} + * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
                      + * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account + * which has been set {@link #setSharedContext(GLContext) directly} + * or {@link #setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}. + *

                      * @param drawable upstream {@link GLDrawableImpl} instance, * may be null for lazy initialization * @param context upstream {@link GLContextImpl} instance, * may not have been made current (created) yet, * may not be associated w/ drawable yet, - * may be null for lazy initialization + * may be null for lazy initialization at 1st {@link #display()}. * @param ownsDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, * otherwise pass false. Closing the device is required in case * the drawable is created w/ it's own new instance, e.g. offscreen drawables, @@ -103,6 +113,16 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe resetFPSCounter(); } + @Override + public final void setSharedContext(GLContext sharedContext) throws IllegalStateException { + helper.setSharedContext(this.context, sharedContext); + } + + @Override + public final void setSharedAutoDrawable(GLAutoDrawable sharedAutoDrawable) throws IllegalStateException { + helper.setSharedAutoDrawable(this, sharedAutoDrawable); + } + /** Returns the recursive lock object of the upstream implementation, which synchronizes multithreaded access on top of {@link NativeSurface#lockSurface()}. */ protected abstract RecursiveLock getLock(); @@ -142,16 +162,16 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe } /** - * Pulls the {@link GLEventListenerState} from this {@link GLAutoDrawable}. + * Preserves the {@link GLEventListenerState} from this {@link GLAutoDrawable}. * - * @return true if the {@link GLEventListenerState} is pulled successfully from this {@link GLAutoDrawable}, + * @return true if the {@link GLEventListenerState} is preserved successfully from this {@link GLAutoDrawable}, * otherwise false. * - * @throws IllegalStateException if the {@link GLEventListenerState} is already pulled + * @throws IllegalStateException if the {@link GLEventListenerState} is already preserved * - * @see #pushGLEventListenerState() + * @see #restoreGLEventListenerState() */ - protected final boolean pullGLEventListenerState() throws IllegalStateException { + protected final boolean preserveGLEventListenerState() throws IllegalStateException { if( null != glels ) { throw new IllegalStateException("GLEventListenerState already pulled"); } @@ -166,15 +186,15 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe } /** - * Pushes a previously {@link #pullGLEventListenerState() pulled} {@link GLEventListenerState} to this {@link GLAutoDrawable}. + * Restores a previously {@link #preserveGLEventListenerState() preserved} {@link GLEventListenerState} to this {@link GLAutoDrawable}. * - * @return true if the {@link GLEventListenerState} was previously {@link #pullGLEventListenerState() pulled} - * and is pushed successfully to this {@link GLAutoDrawable}, + * @return true if the {@link GLEventListenerState} was previously {@link #preserveGLEventListenerState() preserved} + * and is moved successfully to this {@link GLAutoDrawable}, * otherwise false. * - * @see #pullGLEventListenerState() + * @see #preserveGLEventListenerState() */ - protected final boolean pushGLEventListenerState() { + protected final boolean restoreGLEventListenerState() { if( null != glels ) { glels.moveTo(this); glels = null; @@ -320,7 +340,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe protected void destroyImplInLock() { if( preserveGLELSAtDestroy ) { preserveGLStateAtDestroy(false); - pullGLEventListenerState(); + preserveGLEventListenerState(); } if( null != context ) { if( context.isCreated() ) { @@ -389,7 +409,25 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe final RecursiveLock _lock = getLock(); _lock.lock(); try { - if( null != context ) { + if( null == context ) { + boolean contextCreated = false; + final GLDrawableImpl _drawable = drawable; + if ( null != _drawable && _drawable.isRealized() && 0<_drawable.getWidth()*_drawable.getHeight() ) { + final GLContext[] shareWith = { null }; + if( !helper.isSharedGLContextPending(shareWith) ) { + if( !restoreGLEventListenerState() ) { + context = (GLContextImpl) _drawable.createContext(shareWith[0]); + context.setContextCreationFlags(additionalCtxCreationFlags); + contextCreated = true; + // surface is locked/unlocked implicit by context's makeCurrent/release + helper.invokeGL(_drawable, context, defaultDisplayAction, defaultInitAction); + } + } + } + if(DEBUG) { + System.err.println("GLAutoDrawableBase.defaultDisplay: contextCreated "+contextCreated); + } + } else { // surface is locked/unlocked implicit by context's makeCurrent/release helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction); } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index dff55488d..377ebd9f5 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -429,7 +429,7 @@ public abstract class GLContextImpl extends GLContext { contextHandle = 0; glDebugHandler = null; // this maybe impl. in a platform specific way to release remaining shared ctx. - if(GLContextShareSet.contextDestroyed(this) && !GLContextShareSet.hasCreatedSharedLeft(this)) { + if( GLContextShareSet.contextDestroyed(this) && !GLContextShareSet.hasCreatedSharedLeft(this) ) { GLContextShareSet.unregisterSharing(this); } resetStates(false); @@ -647,7 +647,7 @@ public abstract class GLContextImpl extends GLContext { additionalCtxCreationFlags |= GLContext.CTX_OPTION_DEBUG ; } - final GLContextImpl shareWith = (GLContextImpl) GLContextShareSet.getShareContext(this); + final GLContextImpl shareWith = (GLContextImpl) GLContextShareSet.getCreatedShare(this); if (null != shareWith) { shareWith.getDrawableImpl().lockSurface(); } diff --git a/src/jogl/classes/jogamp/opengl/GLContextShareSet.java b/src/jogl/classes/jogamp/opengl/GLContextShareSet.java index 70ade34b7..483767b44 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextShareSet.java +++ b/src/jogl/classes/jogamp/opengl/GLContextShareSet.java @@ -40,7 +40,8 @@ package jogamp.opengl; -import java.util.HashMap; +import java.util.ArrayList; +import java.util.IdentityHashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -59,15 +60,15 @@ public class GLContextShareSet { // This class is implemented using a HashMap which maps from all shared contexts // to a share set, containing all shared contexts itself. - private static final Map shareMap = new HashMap(); + private static final Map shareMap = new IdentityHashMap(); private static final Object dummyValue = new Object(); private static class ShareSet { - private Map allShares = new HashMap(); - private Map createdShares = new HashMap(); - private Map destroyedShares = new HashMap(); + private final Map allShares = new IdentityHashMap(); + private final Map createdShares = new IdentityHashMap(); + private final Map destroyedShares = new IdentityHashMap(); - public void add(GLContext ctx) { + public void add(final GLContext ctx) { if (allShares.put(ctx, dummyValue) == null) { if (ctx.isCreated()) { createdShares.put(ctx, dummyValue); @@ -85,9 +86,9 @@ public class GLContextShareSet { return destroyedShares.keySet(); } - public GLContext getCreatedShare(GLContext ignore) { - for (Iterator iter = createdShares.keySet().iterator(); iter.hasNext(); ) { - GLContext ctx = iter.next(); + public GLContext getCreatedShare(final GLContext ignore) { + for (final Iterator iter = createdShares.keySet().iterator(); iter.hasNext(); ) { + final GLContext ctx = iter.next(); if (ctx != ignore) { return ctx; } @@ -95,21 +96,21 @@ public class GLContextShareSet { return null; } - public void contextCreated(GLContext ctx) { - Object res = destroyedShares.remove(ctx); + public void contextCreated(final GLContext ctx) { + final Object res = destroyedShares.remove(ctx); assert res != null : "State of ShareSet corrupted; thought context " + ctx + " should have been in destroyed set but wasn't"; - res = createdShares.put(ctx, dummyValue); - assert res == null : "State of ShareSet corrupted; thought context " + + final Object res2 = createdShares.put(ctx, dummyValue); + assert res2 == null : "State of ShareSet corrupted; thought context " + ctx + " shouldn't have been in created set but was"; } - public void contextDestroyed(GLContext ctx) { - Object res = createdShares.remove(ctx); + public void contextDestroyed(final GLContext ctx) { + final Object res = createdShares.remove(ctx); assert res != null : "State of ShareSet corrupted; thought context " + ctx + " should have been in created set but wasn't"; - res = destroyedShares.put(ctx, dummyValue); - assert res == null : "State of ShareSet corrupted; thought context " + + final Object res2 = destroyedShares.put(ctx, dummyValue); + assert res2 == null : "State of ShareSet corrupted; thought context " + ctx + " shouldn't have been in destroyed set but was"; } } @@ -117,7 +118,7 @@ public class GLContextShareSet { /** Indicate that contexts share1 and share2 will share textures and display lists. Both must be non-null. */ - public static synchronized void registerSharing(GLContext share1, GLContext share2) { + public static synchronized void registerSharing(final GLContext share1, final GLContext share2) { if (share1 == null || share2 == null) { throw new IllegalArgumentException("Both share1 and share2 must be non-null"); } @@ -138,7 +139,7 @@ public class GLContextShareSet { } } - public static synchronized void unregisterSharing(GLContext lastContext) { + public static synchronized void unregisterSharing(final GLContext lastContext) { if (lastContext == null) { throw new IllegalArgumentException("Last context is null"); } @@ -166,7 +167,25 @@ public class GLContextShareSet { } } - private static synchronized Set getCreatedSharedImpl(GLContext context) { + /** Returns true if the given GLContext is shared, otherwise false. */ + public static synchronized boolean isShared(final GLContext context) { + if (context == null) { + throw new IllegalArgumentException("context is null"); + } + final ShareSet share = entryFor(context); + return share != null; + } + + /** Returns one created GLContext shared with the given context, otherwise return null. */ + public static synchronized GLContext getCreatedShare(final GLContext context) { + final ShareSet share = entryFor(context); + if (share == null) { + return null; + } + return share.getCreatedShare(context); + } + + private static synchronized Set getCreatedSharesImpl(final GLContext context) { if (context == null) { throw new IllegalArgumentException("context is null"); } @@ -176,50 +195,56 @@ public class GLContextShareSet { } return null; } - - public static synchronized boolean isShared(GLContext context) { + private static synchronized Set getDestroyedSharesImpl(final GLContext context) { if (context == null) { throw new IllegalArgumentException("context is null"); } final ShareSet share = entryFor(context); - return share != null; + if (share != null) { + return share.getDestroyedShares(); + } + return null; } + /** Returns true if the given GLContext has shared and created GLContext left including itself, otherwise false. */ public static synchronized boolean hasCreatedSharedLeft(GLContext context) { - final Set s = getCreatedSharedImpl(context); - return null != s && s.size()>0 ; + final Set s = getCreatedSharesImpl(context); + return null != s && s.size() > 0; } - /** currently not used .. - public static synchronized Set getCreatedShared(GLContext context) { - final Set s = getCreatedSharedImpl(context); - if (s == null) { - throw new GLException("context is unknown: "+context); - } - return s; + /** Returns a new array-list of created GLContext shared with the given GLContext. */ + public static synchronized ArrayList getCreatedShares(final GLContext context) { + final ArrayList otherShares = new ArrayList(); + final Set createdShares = getCreatedSharesImpl(context); + if( null != createdShares ) { + for (final Iterator iter = createdShares.iterator(); iter.hasNext(); ) { + final GLContext ctx = iter.next(); + if (ctx != context) { + otherShares.add(ctx); + } + } + } + return otherShares; } - public static synchronized Set getDestroyedShared(GLContext context) { - if (context == null) { - throw new IllegalArgumentException("context is null"); - } - ShareSet share = entryFor(context); - if (share == null) { - throw new GLException("context is unknown: "+context); - } - return share.getDestroyedShares(); - } */ - - public static synchronized GLContext getShareContext(GLContext contextToCreate) { - ShareSet share = entryFor(contextToCreate); - if (share == null) { - return null; - } - return share.getCreatedShare(contextToCreate); + /** Returns a new array-list of destroyed GLContext shared with the given GLContext. */ + public static synchronized ArrayList getDestroyedShares(final GLContext context) { + final ArrayList otherShares = new ArrayList(); + final Set destroyedShares = getDestroyedSharesImpl(context); + if( null != destroyedShares ) { + for (final Iterator iter = destroyedShares.iterator(); iter.hasNext(); ) { + final GLContext ctx = iter.next(); + if (ctx != context) { + otherShares.add(ctx); + } + } + } + return otherShares; } - public static synchronized boolean contextCreated(GLContext context) { - ShareSet share = entryFor(context); + /** Mark the given GLContext as being created. */ + public static synchronized boolean contextCreated(final GLContext context) { + final ShareSet share = entryFor(context); if (share != null) { share.contextCreated(context); return true; @@ -227,8 +252,9 @@ public class GLContextShareSet { return false; } - public static synchronized boolean contextDestroyed(GLContext context) { - ShareSet share = entryFor(context); + /** Mark the given GLContext as being destroyed. */ + public static synchronized boolean contextDestroyed(final GLContext context) { + final ShareSet share = entryFor(context); if (share != null) { share.contextDestroyed(context); return true; @@ -245,9 +271,9 @@ public class GLContextShareSet { currently only needed in a fairly esoteric case, when the Java2D/JOGL bridge is active, but the GLBufferSizeTracker mechanism is now always required.) */ - public static void synchronizeBufferObjectSharing(GLContext olderContextOrNull, GLContext newContext) { - GLContextImpl older = (GLContextImpl) olderContextOrNull; - GLContextImpl newer = (GLContextImpl) newContext; + public static void synchronizeBufferObjectSharing(final GLContext olderContextOrNull, final GLContext newContext) { + final GLContextImpl older = (GLContextImpl) olderContextOrNull; + final GLContextImpl newer = (GLContextImpl) newContext; GLBufferSizeTracker tracker = null; if (older != null) { tracker = older.getBufferSizeTracker(); @@ -264,20 +290,20 @@ public class GLContextShareSet { // Internals only below this point - private static ShareSet entryFor(GLContext context) { - return (ShareSet) shareMap.get(context); + private static ShareSet entryFor(final GLContext context) { + return shareMap.get(context); } - private static void addEntry(GLContext context, ShareSet share) { + private static void addEntry(final GLContext context, final ShareSet share) { if (shareMap.get(context) == null) { shareMap.put(context, share); } } - private static ShareSet removeEntry(GLContext context) { - return (ShareSet) shareMap.remove(context); + private static ShareSet removeEntry(final GLContext context) { + return shareMap.remove(context); } - protected static String toHexString(long hex) { + private static String toHexString(long hex) { return "0x" + Long.toHexString(hex); } } diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 1e4cb38fa..ecb9f7dd1 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -312,6 +312,19 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { return new GLOffscreenAutoDrawableImpl( drawable, context, null, null); } + @Override + public final GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice deviceReq, + GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, + int width, int height) { + final GLDrawable drawable = createOffscreenDrawable( deviceReq, capsRequested, chooser, width, height ); + drawable.setRealized(true); + if(drawable instanceof GLFBODrawableImpl) { + return new GLOffscreenAutoDrawableImpl.FBOImpl( (GLFBODrawableImpl)drawable, null, null, null ); + } + return new GLOffscreenAutoDrawableImpl( drawable, null, null, null); + } + @Override public final GLDrawable createOffscreenDrawable(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable capsRequested, diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 4ce6a7121..cf5d7a206 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -82,6 +82,10 @@ public class GLDrawableHelper { private GLAnimatorControl animatorCtrl; private static Runnable nop = new Runnable() { @Override public void run() {} }; + private GLContext sharedContext; + private GLAutoDrawable sharedAutoDrawable; + + public GLDrawableHelper() { reset(); } @@ -98,6 +102,60 @@ public class GLDrawableHelper { glRunnables.clear(); } animatorCtrl = null; + sharedContext = null; + sharedAutoDrawable = null; + } + + public final void setSharedContext(GLContext thisContext, GLContext sharedContext) throws IllegalStateException { + if( null == sharedContext ) { + throw new IllegalStateException("Null shared GLContext"); + } + if( thisContext == sharedContext ) { + throw new IllegalStateException("Shared GLContext same as local"); + } + if( null != this.sharedContext ) { + throw new IllegalStateException("Shared GLContext already set"); + } + if( null != this.sharedAutoDrawable ) { + throw new IllegalStateException("Shared GLAutoDrawable already set"); + } + this.sharedContext = sharedContext; + } + + public final void setSharedAutoDrawable(GLAutoDrawable thisAutoDrawable, GLAutoDrawable sharedAutoDrawable) throws IllegalStateException { + if( null == sharedAutoDrawable ) { + throw new IllegalStateException("Null shared GLAutoDrawable"); + } + if( thisAutoDrawable == sharedAutoDrawable ) { + throw new IllegalStateException("Shared GLAutoDrawable same as this"); + } + if( null != this.sharedContext ) { + throw new IllegalStateException("Shared GLContext already set"); + } + if( null != this.sharedAutoDrawable ) { + throw new IllegalStateException("Shared GLAutoDrawable already set"); + } + this.sharedAutoDrawable = sharedAutoDrawable; + } + + /** + * @param shared returns the shared GLContext, based on set shared GLAutoDrawable + * or GLContext. Maybe null if none is set. + * @return true if initialization is pending due to a set shared GLAutoDrawable or GLContext + * which is not ready yet. Otherwise false. + */ + public boolean isSharedGLContextPending(GLContext[] shared) { + final GLContext shareWith; + final boolean pending; + if ( null != sharedAutoDrawable ) { + shareWith = sharedAutoDrawable.getContext(); + pending = null == shareWith || !shareWith.isCreated(); + } else { + shareWith = sharedContext; + pending = null != shareWith && !shareWith.isCreated(); + } + shared[0] = shareWith; + return pending; } @Override @@ -612,7 +670,7 @@ public class GLDrawableHelper { public final void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { synchronized(listenersLock) { for (int i=0; i < listeners.size(); i++) { - reshape((GLEventListener) listeners.get(i), drawable, x, y, width, height, 0==i /* setViewport */, true /* checkInit */); + reshape(listeners.get(i), drawable, x, y, width, height, 0==i /* setViewport */, true /* checkInit */); } } } diff --git a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java index f175acf28..345f08e4c 100644 --- a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java @@ -48,7 +48,7 @@ public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implemen * @param context a valid {@link GLContext}, * may not have been made current (created) yet, * may not be associated w/ drawable yet, - * may be null for lazy initialization + * may be null for lazy initialization at 1st {@link #display()}. * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. * @param lock optional upstream lock, may be null */ diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 1f5c26f27..70157fe4b 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -105,7 +105,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private AWTAdapter awtMouseAdapter = null; private AWTAdapter awtKeyAdapter = null; - private AWTWindowClosingProtocol awtWindowClosingProtocol = + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override public void run() { @@ -204,7 +204,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto return false; // NEWT shall proceed requesting the native focus } } - private FocusAction focusAction = new FocusAction(); + private final FocusAction focusAction = new FocusAction(); WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() { @Override @@ -559,8 +559,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, - null); + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 8c1110ed3..4f259fe9a 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -499,21 +499,24 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind if( ( null != context ) ) { throw new InternalError("GLWindow.LifecycleHook.setVisiblePost: "+WindowImpl.getThreadName()+" - Null drawable, but valid context - "+GLWindow.this); } - final NativeSurface ns; - { - final NativeSurface wrapped_ns = window.getWrappedSurface(); - ns = null != wrapped_ns ? wrapped_ns : window; - } - final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) ns.getGraphicsConfiguration().getChosenCapabilities(); - if(null==factory) { - factory = GLDrawableFactory.getFactory(glCaps.getGLProfile()); - } - drawable = (GLDrawableImpl) factory.createGLDrawable(ns); - drawable.setRealized(true); + final GLContext[] shareWith = { null }; + if( !helper.isSharedGLContextPending(shareWith) ) { + final NativeSurface ns; + { + final NativeSurface wrapped_ns = window.getWrappedSurface(); + ns = null != wrapped_ns ? wrapped_ns : window; + } + final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) ns.getGraphicsConfiguration().getChosenCapabilities(); + if(null==factory) { + factory = GLDrawableFactory.getFactory(glCaps.getGLProfile()); + } + drawable = (GLDrawableImpl) factory.createGLDrawable(ns); + drawable.setRealized(true); - if( !GLWindow.this.pushGLEventListenerState() ) { - context = (GLContextImpl) drawable.createContext(sharedContext); - context.setContextCreationFlags(additionalCtxCreationFlags); + if( !GLWindow.this.restoreGLEventListenerState() ) { + context = (GLContextImpl) drawable.createContext(shareWith[0]); + context.setContextCreationFlags(additionalCtxCreationFlags); + } } } if(Window.DEBUG_IMPLEMENTATION) { @@ -573,25 +576,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind // OpenGL-related methods and state // - private GLContext sharedContext = null; - @Override protected final RecursiveLock getLock() { return window.getLock(); } - /** - * Specifies an {@link javax.media.opengl.GLContext OpenGL context} to share with.
                      - * At native creation, {@link #setVisible(boolean) setVisible(true)}, - * a {@link javax.media.opengl.GLDrawable drawable} and {@link javax.media.opengl.GLContext context} is created besides the native Window itself,
                      - * hence you shall set the shared context before. - * - * @param sharedContext The OpenGL context shared by this GLWindow's one - */ - public void setSharedContext(GLContext sharedContext) { - this.sharedContext = sharedContext; - } - @Override public void display() { if( !isNativeValid() || !isVisible() ) { return; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java index 2df14d151..1548c08b5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -61,12 +61,8 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase { } protected void runTestGL( GLCapabilities caps ) throws InterruptedException, InvocationTargetException { - final GLOffscreenAutoDrawable fbod = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable( - null, - caps, new DefaultGLCapabilitiesChooser(), - 512, 512, - null - ); + final GLOffscreenAutoDrawable fbod = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable( + null, caps, new DefaultGLCapabilitiesChooser(), 512, 512); final boolean[] done = {false}; final Runnable pbufferCreationAction = new Runnable() { @@ -77,30 +73,30 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase { System.err.println("AA.X"); } }; - + EventQueue.invokeAndWait(new Runnable() { public void run() { Assert.assertTrue(EventQueue.isDispatchThread()); JAWTUtil.lockToolkit(); try { - final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false, null); + final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false, null); System.err.println("BB.0: "+rTask.getSyncObject()); synchronized (rTask.getSyncObject()) { System.err.println("BB.1: "+rTask.getSyncObject()); - new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start(); + new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start(); try { System.err.println("BB.2"); rTask.getSyncObject().wait(); System.err.println("BB.3"); } catch (InterruptedException e) { throw new RuntimeException(e); - } + } System.err.println("BB.X"); } } finally { JAWTUtil.unlockToolkit(); } - } + } }); Assert.assertTrue(done[0]); fbod.destroy(); @@ -128,4 +124,4 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase { } org.junit.runner.JUnitCore.main( TestFBOAutoDrawableDeadlockAWT.class.getName() ); } -} +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java index 9151a88a5..cc06136d6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; @@ -52,53 +52,53 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; /** - * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the - * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. *

                      - * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. + * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. *

                      *

                      * Extensive FBO reconfiguration (size and sample buffer count) and validation are performed. - *

                      + *

                      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { - + static final int widthStep = 800/4; static final int heightStep = 600/4; volatile int szStep = 2; - + interface MyGLEventListener extends GLEventListener { void setMakeSnapshot(); } - + @Test - public void testGL2ES2_Demo1_SingleBuffer_Normal() throws InterruptedException { + public void testGL2ES2_Demo1_SingleBuffer_Normal() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities(glp); caps.setDoubleBuffered(false); testGLFBODrawableImpl(caps, new GearsES2(0)); } - + @Test - public void testGL2ES2_Demo1_DoubleBuffer_Normal() throws InterruptedException { + public void testGL2ES2_Demo1_DoubleBuffer_Normal() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities(glp); caps.setDoubleBuffered(true); // default testGLFBODrawableImpl(caps, new GearsES2(0)); } - + @Test - public void testGL2ES2_Demo2MSAA4() throws InterruptedException { + public void testGL2ES2_Demo2MSAA4() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities(glp); caps.setSampleBuffers(true); caps.setNumSamples(4); testGLFBODrawableImpl(caps, new MultisampleDemoES2(true)); } - + @Test - public void testGL2ES2_FBODemoMSAA4() throws InterruptedException { + public void testGL2ES2_FBODemoMSAA4() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0); demo.setDoRotation(false); @@ -107,9 +107,9 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { caps.setNumSamples(4); testGLFBODrawableImpl(caps, demo); } - + @Test - public void testEGLES2_Demo0Normal() throws InterruptedException { + public void testEGLES2_Demo0Normal() throws InterruptedException { if( GLProfile.isAvailable(GLProfile.GLES2) ) { final GLProfile glp = GLProfile.get(GLProfile.GLES2); final GLCapabilities caps = new GLCapabilities(glp); @@ -118,9 +118,9 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { System.err.println("EGL ES2 n/a"); } } - + @Test - public void testEGLES2_Demo0MSAA4() throws InterruptedException { + public void testEGLES2_Demo0MSAA4() throws InterruptedException { if( GLProfile.isAvailable(GLProfile.GLES2) ) { final GLProfile glp = GLProfile.get(GLProfile.GLES2); final GLCapabilities caps = new GLCapabilities(glp); @@ -136,71 +136,71 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { caps.setFBO(true); final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); final GLOffscreenAutoDrawable.FBO glad = (GLOffscreenAutoDrawable.FBO) - factory.createOffscreenAutoDrawable(null, caps, null, widthStep*szStep, heightStep*szStep, null); + factory.createOffscreenAutoDrawable(null, caps, null, widthStep*szStep, heightStep*szStep); Assert.assertNotNull(glad); - + System.out.println("Realized GLAD: "+glad); System.out.println("Realized GLAD: "+glad.getChosenGLCapabilities()); Assert.assertTrue("FBO drawable is initialized before ctx creation", !glad.isInitialized()); - + glad.display(); // initial display incl. init! { final GLContext context = glad.getContext(); Assert.assertNotNull(context); Assert.assertTrue(context.isCreated()); } - Assert.assertTrue("FBO drawable is not initialized after ctx creation", glad.isInitialized()); - + Assert.assertTrue("FBO drawable is not initialized after ctx creation", glad.isInitialized()); + // // FBO incl. MSAA is fully initialized now // - + final GLCapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); System.out.println("Init GLAD: "+glad); System.out.println("Init GLAD: "+chosenCaps); - + final FBObject fboFront = glad.getFBObject(GL.GL_FRONT); final FBObject fboBack = glad.getFBObject(GL.GL_BACK); - + System.out.println("Init front FBO: "+fboFront); System.out.println("Init back FBO: "+fboBack); - + Assert.assertTrue("FBO drawable is not initialized before ctx creation", glad.isInitialized()); Assert.assertTrue("FBO Front is not initialized before ctx creation", fboFront.isInitialized()); Assert.assertTrue("FBO Back is not initialized before ctx creation", fboBack.isInitialized()); - + if( chosenCaps.getDoubleBuffered() ) { Assert.assertTrue("FBO are equal: "+fboFront+" == "+fboBack, !fboFront.equals(fboBack)); Assert.assertNotSame(fboFront, fboBack); } else { Assert.assertTrue("FBO are not equal: "+fboFront+" != "+fboBack, fboFront.equals(fboBack)); - Assert.assertSame(fboFront, fboBack); + Assert.assertSame(fboFront, fboBack); } - + final FBObject.TextureAttachment texAttachA, texAttachB; - + texAttachA = glad.getTextureBuffer(GL.GL_FRONT); if(0==glad.getNumSamples()) { texAttachB = glad.getTextureBuffer(GL.GL_BACK); } else { texAttachB = null; } - + final FBObject.Colorbuffer colorA, colorB; final FBObject.RenderAttachment depthA, depthB; - + colorA = fboFront.getColorbuffer(0); Assert.assertNotNull(colorA); colorB = fboBack.getColorbuffer(0); Assert.assertNotNull(colorB); - + depthA = fboFront.getDepthAttachment(); Assert.assertNotNull(depthA); depthB = fboBack.getDepthAttachment(); Assert.assertNotNull(depthB); glad.display(); // SWAP_ODD - + if( chosenCaps.getDoubleBuffered() ) { // double buffer or MSAA Assert.assertTrue("Color attachments are equal: "+colorB+" == "+colorA, !colorB.equals(colorA)); @@ -214,16 +214,16 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { Assert.assertEquals(depthA, depthB); Assert.assertSame(depthA, depthB); } - + Assert.assertEquals(texAttachA, colorA); Assert.assertSame(texAttachA, colorA); if(0==glad.getNumSamples()) { Assert.assertEquals(texAttachB, colorB); - Assert.assertSame(texAttachB, colorB); + Assert.assertSame(texAttachB, colorB); } if( chosenCaps.getNumSamples() > 0 ) { - // MSAA + // MSAA FBObject _fboFront = glad.getFBObject(GL.GL_FRONT); FBObject _fboBack = glad.getFBObject(GL.GL_BACK); Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboFront, fboFront.equals(_fboFront)); @@ -251,22 +251,22 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront.equals(_fboBack)); Assert.assertSame(fboFront, _fboBack); } - + glad.addGLEventListener(demo); - + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); glad.addGLEventListener(snapshotGLEventListener); - + glad.display(); // - SWAP_EVEN // 1 - szStep = 2 snapshotGLEventListener.setMakeSnapshot(); glad.display(); // - SWAP_ODD - + // 2, 3 (resize + display) szStep = 1; glad.setSize(widthStep*szStep, heightStep*szStep); // SWAP_EVEN - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); // - SWAP_ODD @@ -283,34 +283,34 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { Assert.assertSame(fboFront, _fboFront); Assert.assertEquals(fboBack, _fboBack); Assert.assertSame(fboBack, _fboBack); - + FBObject.Colorbuffer _color = _fboFront.getColorbuffer(0); Assert.assertNotNull(_color); Assert.assertEquals(colorA, _color); Assert.assertSame(colorA, _color); - + FBObject.RenderAttachment _depth = _fboFront.getDepthAttachment(); System.err.println("Resize1.oldDepth "+depthA); System.err.println("Resize1.newDepth "+_depth); Assert.assertNotNull(_depth); - + Assert.assertEquals(depthA, _depth); Assert.assertSame(depthA, _depth); _depth = _fboBack.getDepthAttachment(); Assert.assertNotNull(_depth); Assert.assertEquals(depthB, _depth); Assert.assertSame(depthB, _depth); - + _color = _fboFront.getColorbuffer(colorA); Assert.assertNotNull(_color); Assert.assertEquals(colorA, _color); Assert.assertSame(colorA, _color); } - + // 4, 5 (resize + display) szStep = 4; glad.setSize(widthStep*szStep, heightStep*szStep); // SWAP_ODD - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); // - SWAP_EVEN @@ -330,47 +330,47 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { } else { // single or MSAA Assert.assertEquals(fboFront, _fboFront); - Assert.assertEquals(fboBack, _fboBack); + Assert.assertEquals(fboBack, _fboBack); } - + FBObject.Colorbuffer _color = fboBack.getColorbuffer(0); Assert.assertNotNull(_color); Assert.assertEquals(colorB, _color); Assert.assertSame(colorB, _color); - + FBObject.RenderAttachment _depth = fboBack.getDepthAttachment(); - Assert.assertNotNull(_depth); // MSAA back w/ depth + Assert.assertNotNull(_depth); // MSAA back w/ depth Assert.assertEquals(depthB, _depth); Assert.assertSame(depthB, _depth); - + _depth = fboFront.getDepthAttachment(); Assert.assertNotNull(_depth); Assert.assertEquals(depthA, _depth); Assert.assertSame(depthA, _depth); - + _color = fboBack.getColorbuffer(colorB); Assert.assertNotNull(_color); Assert.assertEquals(colorB, _color); Assert.assertSame(colorB, _color); } - + // 6 + 7 (samples + display) glad.setNumSamples(glad.getGL(), chosenCaps.getNumSamples() > 0 ? 0 : 4); // triggers repaint snapshotGLEventListener.setMakeSnapshot(); glad.display(); // actual screenshot - + // 8, 9 (resize + samples + display) szStep = 3; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + glad.destroy(); System.out.println("Fin: "+glad); } - + public static void main(String args[]) throws IOException { org.junit.runner.JUnitCore.main(TestFBOAutoDrawableFactoryNEWT.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java index b3e5e95b0..51dd9df37 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.io.BufferedReader; @@ -68,10 +68,10 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; /** - * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the - * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. *

                      - * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. + * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. *

                      *

                      * This test simulates shared off-thread GL context / texture usage, @@ -81,7 +81,7 @@ import org.junit.runners.MethodSorters; *

                        *
                      • 2 {@link GLOffscreenAutoDrawable.FBO} double buffered *
                          - *
                        • each with their own {@link GLContext}, which is shares the {@link GLWindow} one (see below)
                        • + *
                        • each with their own {@link GLContext}, which is shares the {@link GLWindow} one (see below)
                        • *
                        • both run within one {@link FPSAnimator} @ 30fps
                        • *
                        • produce a texture
                        • *
                        • notify the onscreen renderer about new textureID (swapping double buffer)
                        • @@ -91,18 +91,18 @@ import org.junit.runners.MethodSorters; *
                        • shares it's {@link GLContext} w/ above FBOs
                        • *
                        • running within one {@link Animator} at v-sync
                        • *
                        • uses the shared FBO textures and blends them onscreen
                        • - *
                      • - *
                      - *

                      + * + * + *

                      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { +public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { static long duration = 500; // ms static int swapInterval = 1; static boolean showFPS = false; static boolean forceES2 = false; static boolean mainRun = false; - + @AfterClass public static void releaseClass() { } @@ -110,37 +110,38 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); System.err.println("requested: vsync "+swapInterval+", "+caps); - + final GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval); if(mainRun) { - glWindow.setSize(512, 512); + glWindow.setSize(512, 512); } else { glWindow.setSize(256, 256); } // eager initialization of context glWindow.setVisible(true); - glWindow.display(); + glWindow.display(); final int fbod1_texUnit = 0; final int fbod2_texUnit = 1; - + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); GLCapabilities fbodCaps = (GLCapabilities) caps.cloneMutable(); // fbodCaps.setDoubleBuffered(false); - + final Mix2TexturesES2 mixerDemo = new Mix2TexturesES2(1, fbod1_texUnit, fbod2_texUnit); - // FBOD1 + // FBOD1 final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO) - factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); + factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight()); + fbod1.setSharedAutoDrawable(glWindow); fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen! fbod1.setTextureUnit(fbod1_texUnit); { GearsES2 demo0 = new GearsES2(-1); fbod1.addGLEventListener(demo0); - fbod1.addGLEventListener(new GLFinishOnDisplay()); + fbod1.addGLEventListener(new GLFinishOnDisplay()); demo0.setIgnoreFocus(true); } fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { @@ -151,13 +152,14 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { fbod1.display(); // init System.err.println("FBOD1 "+fbod1); Assert.assertTrue(fbod1.isInitialized()); - + // FBOD2 final GLOffscreenAutoDrawable.FBO fbod2 = (GLOffscreenAutoDrawable.FBO) - factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); + factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight()); + fbod2.setSharedAutoDrawable(glWindow); fbod2.setTextureUnit(fbod2_texUnit); fbod2.addGLEventListener(new RedSquareES2(-1)); - fbod2.addGLEventListener(new GLFinishOnDisplay()); + fbod2.addGLEventListener(new GLFinishOnDisplay()); fbod2.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { @Override public void surfaceUpdated(Object updater, NativeSurface ns, long when) { @@ -170,7 +172,7 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { // preinit texIDs mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName()); mixerDemo.setTexID1(fbod2.getTextureBuffer(GL.GL_FRONT).getName()); - + glWindow.addGLEventListener(mixerDemo); glWindow.addGLEventListener(new GLEventListener() { int i=0, c=0; @@ -178,39 +180,39 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { if(mainRun) return; - + final int dw = drawable.getWidth(); final int dh = drawable.getHeight(); c++; - + if(dw<800) { System.err.println("XXX: "+dw+"x"+dh+", c "+c); if(8 == c) { - snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null); + snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null); } if(9 == c) { c=0; - new Thread() { + new Thread() { @Override public void run() { glWindow.setSize(dw+256, dh+256); - } }.start(); + } }.start(); } } } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { fbod1.setSize(width, height); fbod2.setSize(width, height); } }); - + final FPSAnimator animator0 = new FPSAnimator(30); animator0.add(fbod1); animator0.add(fbod2); - + final Animator animator1 = new Animator(); animator1.add(glWindow); - + QuitAdapter quitAdapter = new QuitAdapter(); //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); @@ -224,22 +226,22 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { } public void windowMoved(WindowEvent e) { System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); - } + } }); - + animator0.start(); animator1.start(); // glWindow.setSkipContextReleaseThread(animator.getThread()); glWindow.setVisible(true); - + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); - + animator0.setUpdateFPSFrames(30, showFPS ? System.err : null); animator1.setUpdateFPSFrames(60, showFPS ? System.err : null); - + while(!quitAdapter.shouldQuit() && animator1.isAnimating() && animator1.getTotalFPSDuration() - * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. + * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. *

                      *

                      * This test simulates shared on-thread GL context / texture usage, @@ -79,7 +79,7 @@ import org.junit.runners.MethodSorters; *

                        *
                      • 1 {@link GLOffscreenAutoDrawable.FBO} double buffered *
                          - * + * *
                        • running within common {@link Animator} @ 60fps
                        • *
                        • produce a texture
                        • *
                        • notify the onscreen renderer about new textureID (swapping double buffer)
                        • @@ -89,18 +89,18 @@ import org.junit.runners.MethodSorters; *
                        • shares it's {@link GLContext} w/ above FBO
                        • *
                        • running within common {@link Animator} @ 60fps
                        • *
                        • uses the shared FBO texture and draws it onscreen
                        • - *
                      • - *
                      - *

                      + * + * + *

                      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { +public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { static long duration = 500; // ms static int swapInterval = 1; static boolean showFPS = false; static boolean forceES2 = false; static boolean mainRun = false; - + @AfterClass public static void releaseClass() { } @@ -108,30 +108,31 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); System.err.println("requested: vsync "+swapInterval+", "+caps); - + final GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval); if(mainRun) { - glWindow.setSize(512, 512); + glWindow.setSize(512, 512); } else { glWindow.setSize(256, 256); } // eager initialization of context glWindow.setVisible(true); - glWindow.display(); + glWindow.display(); final int fbod1_texUnit = 0; - + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); GLCapabilities fbodCaps = (GLCapabilities) caps.cloneMutable(); // fbodCaps.setDoubleBuffered(false); - + final Mix2TexturesES2 mixerDemo = new Mix2TexturesES2(1, fbod1_texUnit, 0); - // FBOD1 + // FBOD1 final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO) - factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); + factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight()); + fbod1.setSharedAutoDrawable(glWindow); fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen! fbod1.setTextureUnit(fbod1_texUnit); { @@ -148,10 +149,10 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { fbod1.display(); // init System.err.println("FBOD1 "+fbod1); Assert.assertTrue(fbod1.isInitialized()); - + // preinit texIDs mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName()); - + glWindow.addWindowListener(new WindowAdapter() { @Override public void windowResized(WindowEvent e) { @@ -165,33 +166,33 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { if(mainRun) return; - + final int dw = drawable.getWidth(); final int dh = drawable.getHeight(); c++; - + if(dw<800) { System.err.println("XXX: "+dw+"x"+dh+", c "+c); if(8 == c) { - snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null); + snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null); } if(9 == c) { c=0; - new Thread() { + new Thread() { @Override public void run() { glWindow.setSize(dw+256, dh+256); - } }.start(); + } }.start(); } } } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); - + final Animator animator1 = new Animator(); animator1.add(fbod1); animator1.add(glWindow); - + QuitAdapter quitAdapter = new QuitAdapter(); //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); @@ -205,20 +206,20 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { } public void windowMoved(WindowEvent e) { System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); - } + } }); - + animator1.start(); // glWindow.setSkipContextReleaseThread(animator.getThread()); glWindow.setVisible(true); - + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); - + animator1.setUpdateFPSFrames(60, showFPS ? System.err : null); - + while(!quitAdapter.shouldQuit() && animator1.isAnimating() && animator1.getTotalFPSDuration() - * Creates a {@link GLDrawable} using the + * Creates a {@link GLDrawable} using the * {@link GLDrawableFactory#createGLDrawable(javax.media.nativewindow.NativeSurface) factory model}. * The {@link GLContext} is derived {@link GLDrawable#createContext(GLContext) from the drawable}. *

                      *

                      * Finally a {@link GLAutoDrawableDelegate} is created with the just created {@link GLDrawable} and {@link GLContext}. - * It is being used to run the {@link GLEventListener}. - *

                      + * It is being used to run the {@link GLEventListener}. + *

                      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestGLAutoDrawableDelegateNEWT extends UITestCase { static long duration = 500; // ms - + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); - + // // Create native windowing resources .. X11/Win/OSX - // + // final Window window = NewtFactory.createWindow(reqGLCaps); Assert.assertNotNull(window); window.setSize(640, 400); @@ -85,24 +85,24 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); System.out.println("Window: "+window.getClass().getName()); - + final GLDrawable drawable = factory.createGLDrawable(window); Assert.assertNotNull(drawable); drawable.setRealized(true); - - final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, drawable.createContext(null), window, false, null) { + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false, null) { @Override protected void destroyImplInLock() { super.destroyImplInLock(); // destroys drawable/context window.destroy(); // destroys the actual window, incl. the device } }; - + window.setWindowDestroyNotifyAction( new Runnable() { public void run() { glad.windowDestroyNotifyOp(); } } ); - + window.addWindowListener(new WindowAdapter() { @Override public void windowRepaint(WindowUpdateEvent e) { @@ -116,13 +116,13 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase { }); glad.addGLEventListener(demo); - + QuitAdapter quitAdapter = new QuitAdapter(); //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); window.addKeyListener(quitAdapter); window.addWindowListener(quitAdapter); - + Animator animator = new Animator(); animator.setUpdateFPSFrames(60, System.err); animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); @@ -130,17 +130,17 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase { animator.start(); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); - + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() - * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. - *

                      + * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. + *

                      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { @@ -71,7 +71,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { } return new GLCapabilities(GLProfile.get(profile)); } - + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { System.out.println("Requested GL Caps: "+reqGLCaps); final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); @@ -79,15 +79,15 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { System.out.println("Expected GL Caps: "+expGLCaps); // - // Create native OpenGL resources .. XGL/WGL/CGL .. + // Create native OpenGL resources .. XGL/WGL/CGL .. // equivalent to GLAutoDrawable methods: setVisible(true) // - final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null); - + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep); + Assert.assertNotNull(glad); - System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); Assert.assertTrue(glad.isRealized()); - + // Check caps of NativeWindow config w/o GL final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); System.out.println("Drawable Caps Pre_GL : "+chosenCaps); @@ -95,7 +95,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { Assert.assertTrue(chosenCaps.getGreenBits()>4); Assert.assertTrue(chosenCaps.getBlueBits()>4); Assert.assertTrue(chosenCaps.getRedBits()>4); - + glad.display(); // force native context creation // Check caps of GLDrawable after realization @@ -113,45 +113,45 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); - /** Single/Double buffer cannot be checked since result may vary .. + /** Single/Double buffer cannot be checked since result may vary .. if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { // dbl buffer may be disabled w/ offscreen pbuffer and bitmap Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); - } */ + } */ glad.addGLEventListener(demo); - + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); glad.addGLEventListener(snapshotGLEventListener); - + glad.display(); // initial resize/display - + // 1 - szStep = 2 - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + // 2, 3 (resize + display) szStep = 1; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + // 4, 5 (resize + display) szStep = 4; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + Thread.sleep(50); - + glad.destroy(); - System.out.println("Fin Drawable: "+glad); + System.out.println("Fin Drawable: "+glad); } @Test @@ -164,8 +164,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { if(null != f) { System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); } - } - + } + @Test public void testES2OffScreenAutoDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -182,7 +182,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setFBO(true); doTest(reqGLCaps, new GearsES2(1)); } - + @Test public void testES2OffScreenFBOSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -191,8 +191,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setFBO(true); reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); - } - + } + @Test public void testES2OffScreenFBODblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -202,7 +202,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new GearsES2(1)); } - + @Test public void testES2OffScreenFBODblBufMSAA() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -212,8 +212,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); - } - + } + @Test public void testES2OffScreenFBODblBufStencilMSAA() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -224,8 +224,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); - } - + } + @Test public void testES2OffScreenPbufferDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -233,8 +233,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setOnscreen(false); reqGLCaps.setPBuffer(true); doTest(reqGLCaps, new GearsES2(1)); - } - + } + @Test public void testES2OffScreenPbufferSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -244,7 +244,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); } - + // Might be reduced to !stencil @Test public void testES2OffScreenPbufferDblBufStencil() throws InterruptedException { @@ -255,7 +255,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new GearsES2(1)); } - + // Might be reduced to !MSAA @Test public void testES2OffScreenPbufferDblBufMSAA() throws InterruptedException { @@ -266,8 +266,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); - } - + } + // Might be reduced to !stencil && !MSAA @Test public void testES2OffScreenPbufferDblBufStencilMSAA() throws InterruptedException { @@ -279,9 +279,9 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); - } + } - /** NOT Implemented: + /** NOT Implemented: // Might be reduced to !double-buff @Test public void testES2OffScreenBitmapDblBuf() throws InterruptedException { @@ -291,7 +291,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setBitmap(true); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testES2OffScreenBitmapSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -301,7 +301,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new Gears(1)); } - + // Might be reduced to !stencil @Test public void testES2OffScreenBitmapDblBufStencil() throws InterruptedException { @@ -312,7 +312,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new GearsES2(1)); } - + // Might be reduced to !MSAA @Test public void testES2OffScreenBitmapDblBufMSAA() throws InterruptedException { @@ -323,8 +323,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); - } - + } + // Might be reduced to !stencil && !MSAA @Test public void testES2OffScreenBitmapDblBufStencilMSAA() throws InterruptedException { @@ -337,7 +337,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); } */ - + public static void main(String args[]) throws IOException { org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryES2OffscrnCapsNEWT.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java index 06dc7c83e..09e211332 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; @@ -52,11 +52,11 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; /** - * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the - * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. *

                      - * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. - *

                      + * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. + *

                      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { @@ -71,7 +71,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { } return new GLCapabilities(GLProfile.get(profile)); } - + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { System.out.println("Requested GL Caps: "+reqGLCaps); final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); @@ -79,15 +79,15 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { System.out.println("Expected GL Caps: "+expGLCaps); // - // Create native OpenGL resources .. XGL/WGL/CGL .. + // Create native OpenGL resources .. XGL/WGL/CGL .. // equivalent to GLAutoDrawable methods: setVisible(true) // - final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null); - + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep); + Assert.assertNotNull(glad); - System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); Assert.assertTrue(glad.isRealized()); - + // Check caps of NativeWindow config w/o GL final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); System.out.println("Drawable Caps Pre_GL : "+chosenCaps); @@ -95,7 +95,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { Assert.assertTrue(chosenCaps.getGreenBits()>4); Assert.assertTrue(chosenCaps.getBlueBits()>4); Assert.assertTrue(chosenCaps.getRedBits()>4); - + glad.display(); // force native context creation // Check caps of GLDrawable after realization @@ -113,45 +113,45 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); - /** Single/Double buffer cannot be checked since result may vary .. + /** Single/Double buffer cannot be checked since result may vary .. if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { // dbl buffer may be disabled w/ offscreen pbuffer and bitmap Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); - } */ + } */ glad.addGLEventListener(demo); - + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); glad.addGLEventListener(snapshotGLEventListener); - + glad.display(); // initial resize/display - + // 1 - szStep = 2 - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + // 2, 3 (resize + display) szStep = 1; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + // 4, 5 (resize + display) szStep = 4; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + Thread.sleep(50); - + glad.destroy(); - System.out.println("Fin Drawable: "+glad); + System.out.println("Fin Drawable: "+glad); } @Test @@ -164,8 +164,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { if(null != f) { System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); } - } - + } + @Test public void testGL2OffScreenAutoDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -182,7 +182,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setFBO(true); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testGL2OffScreenFBOSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -191,8 +191,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setFBO(true); reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new Gears(1)); - } - + } + @Test public void testGL2OffScreenFBODblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -202,7 +202,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testGL2OffScreenFBODblBufMSAA() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -212,8 +212,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - + } + @Test public void testGL2OffScreenFBODblBufStencilMSAA() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -224,8 +224,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - + } + @Test public void testGL2OffScreenPbufferDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -233,8 +233,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setOnscreen(false); reqGLCaps.setPBuffer(true); doTest(reqGLCaps, new Gears(1)); - } - + } + @Test public void testGL2OffScreenPbufferSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -244,8 +244,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new Gears(1)); } - - // Might be reduced to !stencil + + // Might be reduced to !stencil @Test public void testGL2OffScreenPbufferDblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -255,7 +255,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new Gears(1)); } - + // Might be reduced to !MSAA @Test public void testGL2OffScreenPbufferDblBufMSAA() throws InterruptedException { @@ -266,8 +266,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - + } + // Might be reduced to !stencil && !MSAA @Test public void testGL2OffScreenPbufferDblBufStencilMSAA() throws InterruptedException { @@ -279,9 +279,9 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - - + } + + // Might be reduced to !double-buff @Test public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { @@ -291,7 +291,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setBitmap(true); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testGL2OffScreenBitmapDblBufRGBA8881() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -304,7 +304,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setBitmap(true); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testGL2OffScreenBitmapDblBufRGB555() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -317,7 +317,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setBitmap(true); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testGL2OffScreenBitmapDblBufRGBA5551() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -330,7 +330,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setBitmap(true); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testGL2OffScreenBitmapSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -340,7 +340,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new Gears(1)); } - + // Might be reduced to !stencil @Test public void testGL2OffScreenBitmapDblBufStencil() throws InterruptedException { @@ -351,7 +351,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new Gears(1)); } - + // Might be reduced to !MSAA @Test public void testGL2OffScreenBitmapDblBufMSAA() throws InterruptedException { @@ -362,8 +362,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - + } + // Might be reduced to !stencil && !MSAA @Test public void testGL2OffScreenBitmapDblBufStencilMSAA() throws InterruptedException { @@ -375,8 +375,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - + } + public static void main(String args[]) throws IOException { org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java index 75609224e..f35f8c8b0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; @@ -52,11 +52,11 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; /** - * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the - * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. *

                      - * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. - *

                      + * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. + *

                      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { @@ -71,15 +71,15 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { System.out.println("Expected GL Caps: "+expGLCaps); // - // Create native OpenGL resources .. XGL/WGL/CGL .. + // Create native OpenGL resources .. XGL/WGL/CGL .. // equivalent to GLAutoDrawable methods: setVisible(true) // - final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null); - + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep); + Assert.assertNotNull(glad); - System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); Assert.assertTrue(glad.isRealized()); - + // Check caps of NativeWindow config w/o GL final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); System.out.println("Drawable Caps Pre_GL : "+chosenCaps); @@ -87,7 +87,7 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { Assert.assertTrue(chosenCaps.getGreenBits()>4); Assert.assertTrue(chosenCaps.getBlueBits()>4); Assert.assertTrue(chosenCaps.getRedBits()>4); - + glad.display(); // force native context creation // Check caps of GLDrawable after realization @@ -105,45 +105,45 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); - /** Single/Double buffer cannot be checked since result may vary .. + /** Single/Double buffer cannot be checked since result may vary .. if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { // dbl buffer may be disabled w/ offscreen pbuffer and bitmap Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); - } */ + } */ glad.addGLEventListener(demo); - + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); glad.addGLEventListener(snapshotGLEventListener); - + glad.display(); // initial resize/display - + // 1 - szStep = 2 - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + // 2, 3 (resize + display) szStep = 1; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + // 4, 5 (resize + display) szStep = 4; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + Thread.sleep(50); - + glad.destroy(); - System.out.println("Fin Drawable: "+glad); + System.out.println("Fin Drawable: "+glad); } @Test @@ -156,8 +156,8 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { if(null != f) { System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); } - } - + } + // Might be reduced to !double-buff @Test public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { @@ -166,7 +166,7 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { reqGLCaps.setBitmap(true); doTest(reqGLCaps, new Gears(1)); } - + // Might be reduced to !MSAA @Test public void testGL2OffScreenBitmapDblBufMSAA() throws InterruptedException { @@ -176,8 +176,8 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - + } + public static void main(String args[]) throws IOException { org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java index f9ab6c4b3..4bc8e7ee3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.util.Collections; @@ -47,14 +47,14 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestGLExtensionQueryOffscreen { - + public static void main(String[] args) { TestGLExtensionQueryOffscreen instance = new TestGLExtensionQueryOffscreen(); instance.testJogl2ExtensionCheck1(); instance.testJogl2ExtensionCheck2(); } - /** + /** * @deprecated This test uses a non public API in jogamp.opengl.* and hence is not recommended */ @Test @@ -74,13 +74,13 @@ public class TestGLExtensionQueryOffscreen { System.out.println("SharedContext: "+sharedContext); System.out.println("SharedContext: "+setExtensions); } - + @Test public void testJogl2ExtensionCheck2() { final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); - + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256); + drawable.display(); // trigger context creation .. final GLContext context = drawable.getContext(); context.makeCurrent(); String extensions; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java index c8cc294a2..83e55b7e0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java @@ -30,16 +30,16 @@ public class TestNEWTCloseX11DisplayBug565 { try { for ( int j = 0; j < 10; j++ ) { final int open0; - if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { open0 = X11Util.getOpenDisplayConnectionNumber(); } else { open0 = 0; } - + GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault( ) ); - + GLWindow window = GLWindow.create(caps); - window.setTitle("NEWT Resource X11 Leak - #" + j ); + window.setTitle("NEWT Resource X11 Leak - #" + j ); window.setSize( 128, 128 ); window.setVisible(true); window.display(); @@ -69,7 +69,7 @@ public class TestNEWTCloseX11DisplayBug565 { try { for ( int j = 0; j < 10; j++ ) { final int open0; - if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { open0 = X11Util.getOpenDisplayConnectionNumber(); } else { open0 = 0; @@ -111,7 +111,7 @@ public class TestNEWTCloseX11DisplayBug565 { try { for ( int j = 0; j < 10; j++ ) { final int open0; - if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { open0 = X11Util.getOpenDisplayConnectionNumber(); } else { open0 = 0; @@ -121,13 +121,7 @@ public class TestNEWTCloseX11DisplayBug565 { GLOffscreenAutoDrawable buffer = GLDrawableFactory.getFactory( glp ).createOffscreenAutoDrawable( - null, - caps, - new DefaultGLCapabilitiesChooser(), - 256, - 256, - null - ); + null, caps, new DefaultGLCapabilitiesChooser(), 256, 256); buffer.display(); buffer.destroy(); @@ -146,10 +140,10 @@ public class TestNEWTCloseX11DisplayBug565 { Assert.fail(e.getMessage()); } } - + public static void main(String args[]) { org.junit.runner.JUnitCore.main(TestNEWTCloseX11DisplayBug565.class.getName()); } - + } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java index a3eb6db84..77657f6f1 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import javax.media.opengl.GLCapabilities; @@ -73,7 +73,7 @@ public class TestSharedContextListAWT extends UITestCase { } private void initShared() { - sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null); + sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height); Assert.assertNotNull(sharedDrawable); sharedGears = new Gears(); Assert.assertNotNull(sharedGears); @@ -86,8 +86,8 @@ public class TestSharedContextListAWT extends UITestCase { Assert.assertNotNull(sharedDrawable); sharedDrawable.destroy(); } - - protected void setFrameTitle(final Frame f, final boolean useShared) + + protected void setFrameTitle(final Frame f, final boolean useShared) throws InterruptedException, InvocationTargetException { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -99,12 +99,13 @@ public class TestSharedContextListAWT extends UITestCase { protected GLCanvas runTestGL(final Frame frame, final Animator animator, final int x, final int y, final boolean useShared, final boolean vsync) throws InterruptedException, InvocationTargetException { - final GLCanvas glCanvas = new GLCanvas(caps, useShared ? sharedDrawable.getContext() : null); + final GLCanvas glCanvas = new GLCanvas(caps); Assert.assertNotNull(glCanvas); + glCanvas.setSharedAutoDrawable(sharedDrawable); frame.add(glCanvas); frame.setLocation(x, y); frame.setSize(width, height); - + Gears gears = new Gears(vsync ? 1 : 0); if(useShared) { gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3()); @@ -133,22 +134,22 @@ public class TestSharedContextListAWT extends UITestCase { final GLCanvas glc1 = runTestGL(f1, animator, 0, 0, true, false); int x0 = f1.getX(); int y0 = f1.getY(); - - final GLCanvas glc2 = runTestGL(f2, animator, + + final GLCanvas glc2 = runTestGL(f2, animator, x0+width, - y0+0, + y0+0, true, false); - - final GLCanvas glc3 = runTestGL(f3, animator, - x0+0, - y0+height, + + final GLCanvas glc3 = runTestGL(f3, animator, + x0+0, + y0+height, false, true); setFrameTitle(f1, true); setFrameTitle(f2, true); setFrameTitle(f3, false); - - animator.setUpdateFPSFrames(1, null); + + animator.setUpdateFPSFrames(1, null); animator.start(); while(animator.isAnimating() && animator.getTotalFPSDuration() + * This is achieved by creating a master GLContext to an offscreen invisible GLAutoDrawable, + * which is then shared by the 3 GLContext of the three GLWindow instances. + *

                      + *

                      + * The original VBO is created by attaching a GearsES1 instance to + * the master GLAutoDrawable and initializing it. + *

                      + *

                      + * Above method allows random creation of all GLWindow instances. + *

                      + *

                      + * One animator is being used, hence the GLWindow, GLDrawable and GLContext + * creation of all 3 GLWindows is sequential. + *

                      + */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestSharedContextVBOES1NEWT extends UITestCase { static GLProfile glp; static GLCapabilities caps; static int width, height; - GLOffscreenAutoDrawable sharedDrawable; + GLAutoDrawable sharedDrawable; GearsES1 sharedGears; @BeforeClass @@ -69,14 +91,22 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { } } - private void initShared() { - sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null); + private void initShared() throws InterruptedException { + GLDrawable dummyDrawable = GLDrawableFactory.getFactory(glp).createDummyDrawable(null, true /* createNewDevice */, caps.getGLProfile()); + dummyDrawable.setRealized(true); + sharedDrawable = new GLAutoDrawableDelegate(dummyDrawable, null, null, true /*ownDevice*/, null) { }; Assert.assertNotNull(sharedDrawable); + Assert.assertTrue(AWTRobotUtil.waitForRealized(sharedDrawable, true)); + sharedGears = new GearsES1(); Assert.assertNotNull(sharedGears); sharedDrawable.addGLEventListener(sharedGears); // init and render one frame, which will setup the Gears display lists sharedDrawable.display(); + final GLContext ctxM = sharedDrawable.getContext(); + Assert.assertTrue("Master ctx not created", AWTRobotUtil.waitForCreated(ctxM, true)); + Assert.assertTrue("Master Ctx is shared before shared creation", !ctxM.isShared()); + Assert.assertTrue("Master Gears is shared", !sharedGears.usesSharedGears()); } private void releaseShared() { @@ -87,6 +117,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException { GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); + glWindow.setPosition(x, y); glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared); if(useShared) { glWindow.setSharedContext(sharedDrawable.getContext()); @@ -96,7 +127,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { GearsES1 gears = new GearsES1(vsync ? 1 : 0); if(useShared) { - gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3()); + gears.setSharedGearsObjects(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3()); } glWindow.addGLEventListener(gears); @@ -105,9 +136,17 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { glWindow.setVisible(true); Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); - - glWindow.setPosition(x, y); - + Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true)); + + System.err.println("Master Context: "); + MiscUtils.dumpSharedGLContext(sharedDrawable.getContext()); + System.err.println("New Context: "); + MiscUtils.dumpSharedGLContext(glWindow.getContext()); + if( useShared ) { + Assert.assertEquals("Master Context not shared as expected", true, sharedDrawable.getContext().isShared()); + } + Assert.assertEquals("New Context not shared as expected", useShared, glWindow.getContext().isShared()); + Assert.assertEquals("Gears is not shared as expected", useShared, gears.usesSharedGears()); return glWindow; } @@ -117,11 +156,11 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { Animator animator = new Animator(); GLWindow f1 = runTestGL(animator, 0, 0, true, false); InsetsImmutable insets = f1.getInsets(); - GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), + GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), f1.getY()+0, true, false); - GLWindow f3 = runTestGL(animator, f1.getX()+0, - f1.getY()+height+insets.getTotalHeight(), false, true); - animator.setUpdateFPSFrames(1, null); + GLWindow f3 = runTestGL(animator, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), false, true); + animator.setUpdateFPSFrames(1, null); animator.start(); while(animator.isAnimating() && animator.getTotalFPSDuration() + * This is achieved by using the 1st GLCanvas as the master + * and using the build-in blocking mechanism to postpone creation + * of the 2nd and 3rd GLCanvas until the 1st GLCanvas's GLContext becomes created. + *

                      + *

                      + * Above method allows random creation of the 1st GLCanvas, which triggers + * creation of the dependent other GLCanvas sharing it's GLContext. + *

                      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2AWT3 extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + width = 256; + height = 256; + } else { + setTestSupported(false); + } + } + + protected GLCanvas createGLCanvas(final Frame frame, int x, int y, GearsES2 gears) throws InterruptedException { + final GLCanvas glCanvas = new GLCanvas(caps); + Assert.assertNotNull(glCanvas); + glCanvas.addGLEventListener(gears); + frame.add(glCanvas); + frame.setLocation(x, y); + frame.setSize(width, height); + frame.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true"); + return glCanvas; + } + + @Test + public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + final Frame f1 = new Frame(); + final Animator animator = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLCanvas c1 = createGLCanvas(f1, 0, 0, g1); + animator.add(c1); + + final Frame f2 = new Frame(); + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLCanvas c2 = createGLCanvas(f2, f1.getX()+width, + f1.getY()+0, g2); + c2.setSharedAutoDrawable(c1); + animator.add(c2); + + final Frame f3 = new Frame(); + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLCanvas c3 = createGLCanvas(f3, f1.getX()+0, + f1.getY()+height, g3); + c3.setSharedAutoDrawable(c1); + animator.add(c3); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f2.setVisible(true); // shall wait until f1 is ready + f1.setVisible(true); // master .. + f3.setVisible(true); // shall wait until f1 is ready + } } ); + animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion + + Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = c1.getContext(); + final GLContext ctx2 = c2.getContext(); + final GLContext ctx3 = c3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + f1.dispose(); + f2.dispose(); + f3.dispose(); + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, false)); + } + + @Test + public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + final Frame f1 = new Frame(); + final Animator a1 = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLCanvas c1 = createGLCanvas(f1, 0, 0, g1); + a1.add(c1); + a1.start(); + // f1.setVisible(true); // we do this post f2 .. to test pending creation! + + final Frame f2 = new Frame(); + final Animator a2 = new Animator(); + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLCanvas c2 = createGLCanvas(f2, f1.getX()+width, f1.getY()+0, g2); + c2.setSharedAutoDrawable(c1); + a2.add(c2); + a2.start(); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f2.setVisible(true); + } } ); + + Thread.sleep(200); // wait a while .. + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f1.setVisible(true); // test pending creation of f2 + } } ); + + final Frame f3 = new Frame(); + final Animator a3 = new Animator(); + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLCanvas c3 = createGLCanvas(f3, f1.getX()+0, f1.getY()+height, g3); + c3.setSharedAutoDrawable(c1); + a3.add(c3); + a3.start(); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f3.setVisible(true); + } } ); + + Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = c1.getContext(); + final GLContext ctx2 = c2.getContext(); + final GLContext ctx3 = c3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + a1.stop(); + a2.stop(); + a3.stop(); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + f1.dispose(); + f2.dispose(); + f3.dispose(); + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, false)); + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i 0 ) { - // instable on OSX .. driver/OS bug when multi threading (3 animator) - System.err.println("Shared context w/ 3 context each running in there own thread is instable here on OSX 10.7.4/NVidia,"); - System.err.println("SIGSEGV @ glDrawArrays / glBindBuffer .. any shared VBO."); - System.err.println("Seems to run fine on 10.6.8/NVidia."); - return; - } - initShared(false); - Animator animator1 = new Animator(); - Animator animator2 = new Animator(); - Animator animator3 = new Animator(); - GLWindow f1 = runTestGL(animator1, 0, 0, true, false); - InsetsImmutable insets = f1.getInsets(); - GLWindow f2 = runTestGL(animator2, f1.getX()+width+insets.getTotalWidth(), - f1.getY()+0, true, false); - GLWindow f3 = runTestGL(animator3, f1.getX()+0, - f1.getY()+height+insets.getTotalHeight(), true, false); - - try { - Thread.sleep(duration); - } catch(Exception e) { - e.printStackTrace(); - } - animator1.stop(); - animator2.stop(); - animator3.stop(); - - f1.destroy(); - f2.destroy(); - f3.destroy(); - Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); - Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); - Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); - Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); - Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); - Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); - - releaseShared(); - } - - static long duration = 2000; // ms - - public static void main(String args[]) { - for(int i=0; i + * This is achieved by relying on the sequential creation + * of the 3 GLWindows with their GLDrawable and GLContext. + *

                      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2NEWT0 extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + width = 256; + height = 256; + } else { + setTestSupported(false); + } + } + + protected GLWindow runTestGL(Animator animator, int x, int y, GearsES2 gears, GLContext sharedContext) throws InterruptedException { + final boolean useShared = null != sharedContext; + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setPosition(x, y); + glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared); + if(useShared) { + glWindow.setSharedContext(sharedContext); + } + glWindow.setSize(width, height); + glWindow.addGLEventListener(gears); + + animator.add(glWindow); + glWindow.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); + glWindow.display(); + Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true)); + Assert.assertTrue("Gears not initialized", gears.waitForInit(true)); + + return glWindow; + } + + @Test + public void testCommonAnimatorShared() throws InterruptedException { + final Animator animator = new Animator(); + + // + // 1st + // + final GearsES2 g1 = new GearsES2(0); + final GLWindow f1 = runTestGL(animator, 0, 0, g1, null); + final GLContext ctx1 = f1.getContext(); + Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared()); + final InsetsImmutable insets = f1.getInsets(); + + System.err.println("XXX-C-2.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + + // + // 2nd + // + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGearsObjects(g1.getGear1(), g1.getGear2(), g1.getGear3()); + final GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, g2, f1.getContext()); + final GLContext ctx2 = f2.getContext(); + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + System.err.println("XXX-C-2.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-2.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + + Assert.assertEquals("Ctx1 has unexpected number of created shares", 1, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size()); + } + + // + // 3rd + // + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGearsObjects(g1.getGear1(), g1.getGear2(), g1.getGear3()); + final GLWindow f3 = runTestGL(animator, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), g3, f1.getContext()); + + final GLContext ctx3 = f3.getContext(); + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + animator.start(); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + f1.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-D-2.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-D-2.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-D-2.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 1, ctx3Shares.size()); + } + + f2.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-D-1.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-D-1.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-D-1.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 1, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 0, ctx3Shares.size()); + } + + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-D-0.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-D-0.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-D-0.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is shared", !ctx1.isShared()); + Assert.assertTrue("Ctx2 is shared", !ctx2.isShared()); + Assert.assertTrue("Ctx3 is shared", !ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 0, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 0, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 0, ctx3Shares.size()); + } + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i + * This is achieved by creating a master GLContext to an offscreen invisible GLAutoDrawable, + * which is then shared by the 3 GLContext of the three GLWindow instances. + *

                      + *

                      + * The original VBO is created by attaching a GearsES2 instance to + * the master GLAutoDrawable and initializing it. + *

                      + *

                      + * Above method allows random creation of all GLWindow instances. + *

                      + *

                      + * One tests uses only one animator, where the GLWindow, GLDrawable and GLContext + * creation of all 3 GLWindows is sequential. + *

                      + *

                      + * Another tests uses 3 animator, one for each GLWindow, + * where the GLWindow, GLDrawable and GLContext creation + * of all 3 GLWindows is random. + * This fact benefits from the master GLContext/GLAutoDrawable, + * since it is guaranteed it exist and is realized at the time of the shared + * GLWindow creation. + *

                      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2NEWT1 extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + GLAutoDrawable sharedDrawable; + GearsES2 sharedGears; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + width = 256; + height = 256; + } else { + setTestSupported(false); + } + } + + private void initShared(boolean onscreen) throws InterruptedException { + if(onscreen) { + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setSize(width, height); + glWindow.setVisible(true); + sharedDrawable = glWindow; + } else { + GLDrawable dummyDrawable = GLDrawableFactory.getFactory(glp).createDummyDrawable(null, true /* createNewDevice */, caps.getGLProfile()); + dummyDrawable.setRealized(true); + sharedDrawable = new GLAutoDrawableDelegate(dummyDrawable, null, null, true /*ownDevice*/, null) { }; + } + Assert.assertNotNull(sharedDrawable); + Assert.assertTrue(AWTRobotUtil.waitForRealized(sharedDrawable, true)); + + sharedGears = new GearsES2(); + Assert.assertNotNull(sharedGears); + sharedDrawable.addGLEventListener(sharedGears); + // init and render one frame, which will setup the Gears display lists + sharedDrawable.display(); + final GLContext ctxM = sharedDrawable.getContext(); + Assert.assertTrue("Master ctx not created", AWTRobotUtil.waitForCreated(ctxM, true)); + Assert.assertTrue("Master Ctx is shared before shared creation", !ctxM.isShared()); + Assert.assertTrue("Master Gears not initialized", sharedGears.waitForInit(true)); + Assert.assertTrue("Master Gears is shared", !sharedGears.usesSharedGears()); + } + + private void releaseShared() { + Assert.assertNotNull(sharedDrawable); + sharedDrawable.destroy(); + sharedDrawable = null; + } + + protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException { + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setPosition(x, y); + glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared); + if(useShared) { + glWindow.setSharedContext(sharedDrawable.getContext()); + } + + glWindow.setSize(width, height); + + GearsES2 gears = new GearsES2(vsync ? 1 : 0); + if(useShared) { + gears.setSharedGearsObjects(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3()); + } + glWindow.addGLEventListener(gears); + + animator.add(glWindow); + animator.start(); + glWindow.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true)); + + System.err.println("Master Context: "); + MiscUtils.dumpSharedGLContext(sharedDrawable.getContext()); + System.err.println("New Context: "); + MiscUtils.dumpSharedGLContext(glWindow.getContext()); + if( useShared ) { + Assert.assertEquals("Master Context not shared as expected", true, sharedDrawable.getContext().isShared()); + } + Assert.assertEquals("New Context not shared as expected", useShared, glWindow.getContext().isShared()); + + Assert.assertTrue("Gears not initialized", sharedGears.waitForInit(true)); + Assert.assertEquals("Gears is not shared as expected", useShared, gears.usesSharedGears()); + + return glWindow; + } + + @Test + public void test01CommonAnimatorSharedOnscreen() throws InterruptedException { + initShared(true); + Animator animator = new Animator(); + GLWindow f1 = runTestGL(animator, 0, 0, true, false); + InsetsImmutable insets = f1.getInsets(); + GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, true, false); + GLWindow f3 = runTestGL(animator, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), true, false); + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + + releaseShared(); + } + + @Test + public void test02CommonAnimatorSharedOffscreen() throws InterruptedException { + initShared(false); + Animator animator = new Animator(); + GLWindow f1 = runTestGL(animator, 0, 0, true, false); + InsetsImmutable insets = f1.getInsets(); + GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, true, false); + GLWindow f3 = runTestGL(animator, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), true, false); + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + + releaseShared(); + } + + @Test + public void test03EachWithAnimatorSharedOffscreen() throws InterruptedException { + initShared(false); + Animator animator1 = new Animator(); + Animator animator2 = new Animator(); + Animator animator3 = new Animator(); + GLWindow f1 = runTestGL(animator1, 0, 0, true, false); + InsetsImmutable insets = f1.getInsets(); + GLWindow f2 = runTestGL(animator2, f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, true, false); + GLWindow f3 = runTestGL(animator3, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), true, false); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator1.stop(); + animator2.stop(); + animator3.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + + releaseShared(); + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i + * This is achieved by using the 1st GLWindow's GLContext as the master + * and manually triggering creation of the 2nd and 3rd GLWindow when the 1st GLWindow's + * GLContext becomes created. The trigger is performed by simply + * inserting a GLRunnable in the 1st GLWindow, which makes the other visible. + *

                      + *

                      + * Above method allows random creation of the 1st GLWindow, which triggers + * creation of the dependent other GLWindow sharing it's GLContext. + *

                      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2NEWT2 extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + width = 256; + height = 256; + } else { + setTestSupported(false); + } + } + + protected GLWindow createGLWindow(int x, int y, GearsES2 gears) throws InterruptedException { + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setPosition(x, y); + glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true"); + glWindow.setSize(width, height); + glWindow.addGLEventListener(gears); + + return glWindow; + } + + @Test + public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException { + final Animator animator = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLWindow f1 = createGLWindow(0, 0, g1); + animator.add(f1); + InsetsImmutable insets = f1.getInsets(); + + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, g2); + animator.add(f2); + + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLWindow f3 = createGLWindow(f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), g3); + animator.add(f3); + + // f1's shared GLContext is ready ! + f1.invoke(false, new GLRunnable() { + @Override + public boolean run(GLAutoDrawable drawable) { + final GLContext ctx1 = f1.getContext(); + Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared()); + f2.setSharedContext(ctx1); + f2.setVisible(true); + f2.display(); // kick off GLContext .. + f3.setSharedContext(ctx1); + f3.setVisible(true); + f3.display(); // kick off GLContext .. + return true; + } + }); + + f1.setVisible(true); + f1.display(); // kick off GLContext .. and hence f2 + f3 creation + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + animator.start(); // post start animator, otherwise display will be suppressed + + final GLContext ctx1 = f1.getContext(); + final GLContext ctx2 = f2.getContext(); + final GLContext ctx3 = f3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + } + + @Test + public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException { + final Animator a1 = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLWindow f1 = createGLWindow(0, 0, g1); + a1.add(f1); + a1.start(); + f1.setVisible(true); + + InsetsImmutable insets = f1.getInsets(); + + final Animator a2 = new Animator(); + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, g2); + a2.add(f2); + a2.start(); + + final Animator a3 = new Animator(); + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLWindow f3 = createGLWindow(f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), g3); + a3.add(f3); + a3.start(); + + // f1's shared GLContext is ready ! + f1.invoke(false, new GLRunnable() { + @Override + public boolean run(GLAutoDrawable drawable) { + final GLContext ctx1 = f1.getContext(); + Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared()); + f2.setSharedContext(ctx1); + f2.setVisible(true); + f3.setSharedContext(ctx1); + f3.setVisible(true); + return true; + } + }); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = f1.getContext(); + final GLContext ctx2 = f2.getContext(); + final GLContext ctx3 = f3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + a1.stop(); + a2.stop(); + a3.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i + * This is achieved by using the 1st GLWindow as the master + * and using the build-in blocking mechanism to postpone creation + * of the 2nd and 3rd GLWindow until the 1st GLWindow's GLContext becomes created. + *

                      + *

                      + * Above method allows random creation of the 1st GLWindow, which triggers + * creation of the dependent other GLWindow sharing it's GLContext. + *

                      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2NEWT3 extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + width = 256; + height = 256; + } else { + setTestSupported(false); + } + } + + protected GLWindow createGLWindow(int x, int y, GearsES2 gears) throws InterruptedException { + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setPosition(x, y); + glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true"); + glWindow.setSize(width, height); + glWindow.addGLEventListener(gears); + + return glWindow; + } + + @Test + public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException { + final Animator animator = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLWindow f1 = createGLWindow(0, 0, g1); + animator.add(f1); + InsetsImmutable insets = f1.getInsets(); + + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, g2); + f2.setSharedAutoDrawable(f1); + animator.add(f2); + + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLWindow f3 = createGLWindow(f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), g3); + f3.setSharedAutoDrawable(f1); + animator.add(f3); + + f2.setVisible(true); // shall wait until f1 is ready + f1.setVisible(true); // master .. + f3.setVisible(true); // shall wait until f1 is ready + animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion + + Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = f1.getContext(); + final GLContext ctx2 = f2.getContext(); + final GLContext ctx3 = f3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + } + + @Test + public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException { + final Animator a1 = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLWindow f1 = createGLWindow(0, 0, g1); + a1.add(f1); + a1.start(); + // f1.setVisible(true); // we do this post f2 .. to test pending creation! + + InsetsImmutable insets = f1.getInsets(); + + final Animator a2 = new Animator(); + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, g2); + f2.setSharedAutoDrawable(f1); + a2.add(f2); + a2.start(); + f2.setVisible(true); + + f1.setVisible(true); // test pending creation of f2 + + final Animator a3 = new Animator(); + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLWindow f3 = createGLWindow(f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), g3); + f3.setSharedAutoDrawable(f1); + a3.add(f3); + a3.start(); + f3.setVisible(true); + + Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = f1.getContext(); + final GLContext ctx2 = f2.getContext(); + final GLContext ctx3 = f3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + a1.stop(); + a2.stop(); + a3.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i0; w-=100) { + Thread.sleep(100); + } + } else { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + demo.tabbedPanel.setSelectedIndex(0); + }}); + Thread.sleep(durationPerTest/4); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + demo.tabbedPanel.setSelectedIndex(1); + }}); + Thread.sleep(durationPerTest/4); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + demo.tabbedPanel.setSelectedIndex(0); + }}); + Thread.sleep(durationPerTest/4); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + demo.tabbedPanel.setSelectedIndex(1); + }}); + Thread.sleep(durationPerTest/4); + } + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + System.err.println("XXX SetVisible XXX"); + f.dispose(); + } }); + } + + public static void main(String args[]) { + for(int i=0; i - * Test utilizes {@link GLEventListenerState} for preserving the - * GLAutoDrawable state, i.e. GLContext, all GLEventListener + * Test utilizes {@link GLEventListenerState} for preserving the + * GLAutoDrawable state, i.e. GLContext, all GLEventListener * and the GLAnimatorControl association. *

                      *

                      @@ -70,7 +70,7 @@ import org.junit.BeforeClass; */ public abstract class GLContextDrawableSwitchBase extends UITestCase { static protected enum GLADType { GLCanvasOnscreen, GLCanvasOffscreen, GLWindow, GLOffscreen }; - + // default period for 1 GLAD cycle static long duration = 1000; // ms @@ -83,7 +83,7 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { } return new GLCapabilities(GLProfile.get(profile)); } - + @BeforeClass public static void initClass() { width = 256; @@ -101,37 +101,37 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); - } + } } - + static void setFrameVisible(final Frame frame) throws InterruptedException { try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.pack(); - frame.setVisible(true); - }}); + frame.setVisible(true); + }}); } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } } - + static void destroyFrame(final Frame frame) throws InterruptedException { try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.dispose(); - }}); + }}); } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); - } + } } - + private GLOffscreenAutoDrawable createGLOffscreenAutoDrawable(GLCapabilities caps, int width, int height) throws InterruptedException { final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - return factory.createOffscreenAutoDrawable(null, caps, null, width, height, null); + return factory.createOffscreenAutoDrawable(null, caps, null, width, height); } protected static boolean validateOnOffscreenLayer(GLADType gladType1, GLADType gladType2) { @@ -150,37 +150,37 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { } return true; } - - protected void testGLADOneLifecycle(Screen screen, GLCapabilities caps, GLADType gladType, int width, + + protected void testGLADOneLifecycle(Screen screen, GLCapabilities caps, GLADType gladType, int width, int height, GLEventListenerCounter glelTracker, - SnapshotGLEventListener snapshotGLEventListener, final GLEventListenerState glelsIn, final GLEventListenerState glelsOut[], GLAnimatorControl animator) + SnapshotGLEventListener snapshotGLEventListener, final GLEventListenerState glelsIn, final GLEventListenerState glelsOut[], GLAnimatorControl animator) throws InterruptedException { - + System.err.println("GLAD Lifecycle.0 "+gladType+", restoring "+((null!=glelsIn)?true:false)+", preserving "+((null!=glelsOut)?true:false)); final Frame frame; final GLAutoDrawable glad; - if( GLADType.GLCanvasOnscreen == gladType ) { + if( GLADType.GLCanvasOnscreen == gladType ) { if( jogamp.nativewindow.jawt.JAWTUtil.isOffscreenLayerRequired() ) { throw new InternalError("Platform requires offscreen rendering, but onscreen requested: "+gladType); } frame = new Frame("AWT GLCanvas"); - + glad = new GLCanvas(caps); setGLCanvasSize((GLCanvas)glad, new Dimension(width, height)); frame.add((GLCanvas)glad); - } else if( GLADType.GLCanvasOffscreen == gladType ) { + } else if( GLADType.GLCanvasOffscreen == gladType ) { if( !jogamp.nativewindow.jawt.JAWTUtil.isOffscreenLayerSupported() ) { throw new InternalError("Platform doesn't support offscreen rendering: "+gladType); } frame = new Frame("AWT GLCanvas"); - + glad = new GLCanvas(caps); ((GLCanvas)glad).setShallUseOffscreenLayer(true); setGLCanvasSize((GLCanvas)glad, new Dimension(width, height)); frame.add((GLCanvas)glad); } else if( GLADType.GLWindow == gladType ) { frame = null; - + if( null != screen ) { glad = GLWindow.create(screen, caps); } else { @@ -190,60 +190,60 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { ((GLWindow)glad).setSize(width, height); } else if( GLADType.GLOffscreen == gladType ) { frame = null; - + glad = this.createGLOffscreenAutoDrawable(caps, width, height); } else { throw new InternalError("Unsupported: "+gladType); } - + if( null == glelsIn ) { if( null != animator ) { animator.add(glad); } glad.addGLEventListener(glelTracker); glad.addGLEventListener(new GearsES2(1)); - glad.addGLEventListener(snapshotGLEventListener); + glad.addGLEventListener(snapshotGLEventListener); } snapshotGLEventListener.setMakeSnapshot(); - - if( GLADType.GLCanvasOnscreen == gladType || GLADType.GLCanvasOffscreen == gladType ) { - setFrameVisible(frame); + + if( GLADType.GLCanvasOnscreen == gladType || GLADType.GLCanvasOffscreen == gladType ) { + setFrameVisible(frame); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); } else if( GLADType.GLWindow == gladType ) { ((GLWindow)glad).setVisible(true); - } - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, true)); + } + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, true)); Assert.assertNotNull(glad.getContext()); Assert.assertTrue(glad.isRealized()); - + if( null != glelsIn ) { Assert.assertEquals(0, glad.getGLEventListenerCount()); System.err.println(".. restoring.0"); - glelsIn.moveTo(glad); + glelsIn.moveTo(glad); System.err.println(".. restoring.X"); - + Assert.assertEquals(1, glelTracker.initCount); Assert.assertTrue(1 <= glelTracker.reshapeCount); Assert.assertTrue(1 <= glelTracker.displayCount); Assert.assertEquals(0, glelTracker.disposeCount); Assert.assertEquals(3, glad.getGLEventListenerCount()); - + Assert.assertEquals(glelsIn.context, glad.getContext()); Assert.assertEquals(glelsIn.listenerCount(), glad.getGLEventListenerCount()); Assert.assertEquals(glelsIn.context.getGLReadDrawable(), glad.getDelegatedDrawable()); Assert.assertEquals(glelsIn.context.getGLDrawable(), glad.getDelegatedDrawable()); Assert.assertEquals(false, glelsIn.isOwner()); } - - for (int wait=0; wait glelTracker.initCount || 1 > glelTracker.reshapeCount || 1 > glelTracker.displayCount ); wait++) { Thread.sleep(AWTRobotUtil.TIME_SLICE); } - + final long t0 = System.currentTimeMillis(); long t1 = t0; - + while( ( t1 - t0 ) < duration ) { Thread.sleep(100); t1 = System.currentTimeMillis(); @@ -253,13 +253,13 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { Assert.assertTrue(1 <= glelTracker.reshapeCount); Assert.assertTrue(1 <= glelTracker.displayCount); Assert.assertEquals(0, glelTracker.disposeCount); - + if( null != glelsOut ) { final GLContext context1 = glad.getContext(); System.err.println(".. preserving.0"); glelsOut[0] = GLEventListenerState.moveFrom(glad); System.err.println(".. preserving.X"); - + Assert.assertEquals(context1, glelsOut[0].context); Assert.assertNull(context1.getGLReadDrawable()); Assert.assertNull(context1.getGLDrawable()); @@ -276,8 +276,8 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { } else if( GLADType.GLOffscreen == gladType ) { glad.destroy(); } - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, false)); - + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, false)); + Assert.assertEquals(1, glelTracker.initCount); Assert.assertTrue(1 <= glelTracker.reshapeCount); Assert.assertTrue(1 <= glelTracker.displayCount); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java index e568f87a1..316199d07 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore.glels; import java.awt.BorderLayout; @@ -71,7 +71,7 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { } return new GLCapabilities(GLProfile.get(profile)); } - + @BeforeClass public static void initClass() { width = 256; @@ -82,13 +82,13 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { final GLAutoDrawable glad; if( caps.isOnscreen() ) { GLCanvas glCanvas = new GLCanvas(caps); - Assert.assertNotNull(glCanvas); + Assert.assertNotNull(glCanvas); Dimension glc_sz = new Dimension(width, height); glCanvas.setMinimumSize(glc_sz); glCanvas.setPreferredSize(glc_sz); glCanvas.setSize(glc_sz); glad = glCanvas; - + frame.setLayout(new BorderLayout()); frame.add(glCanvas, BorderLayout.CENTER); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { @@ -96,48 +96,48 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { frame.pack(); frame.setVisible(true); }}); - - } else { + + } else { final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height, null); + glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height); Assert.assertNotNull(glad); } return glad; } - + @Test(timeout=30000) public void testSwitch2AWTGLCanvas2OffscreenGL2ES2() throws InterruptedException, InvocationTargetException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); if(null == reqGLCaps) return; testSwitch2AWTGLCanvas2OffscreenImpl(reqGLCaps); } - + private void testSwitch2AWTGLCanvas2OffscreenImpl(GLCapabilities capsOnscreen) throws InterruptedException, InvocationTargetException { final GLCapabilities capsOffscreen = (GLCapabilities) capsOnscreen.clone(); capsOffscreen.setOnscreen(false); - + final QuitAdapter quitAdapter = new QuitAdapter(); - + final Frame frame = new Frame("Gears AWT Test"); Assert.assertNotNull(frame); new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); - + GLAutoDrawable glCanvas = createGLAutoDrawable(frame, capsOnscreen, width, height); - - final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); GearsES2 gears = new GearsES2(1); glCanvas.addGLEventListener(gears); glCanvas.addGLEventListener(snapshotGLEventListener); snapshotGLEventListener.setMakeSnapshot(); - + Animator animator = new Animator(); animator.add(glCanvas); animator.start(); - + int s = 0; long t0 = System.currentTimeMillis(); long t1 = t0; - + GLAutoDrawable glOffscreen = createGLAutoDrawable(null, capsOffscreen, width, height); while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { if( ( t1 - t0 ) / period > s) { @@ -147,8 +147,8 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { // switch context _and_ the demo synchronously GLDrawableUtil.swapGLContextAndAllGLEventListener(glCanvas, glOffscreen); snapshotGLEventListener.setMakeSnapshot(); - - System.err.println(s+" - switch - END "+ ( t1 - t0 )); + + System.err.println(s+" - switch - END "+ ( t1 - t0 )); } Thread.sleep(100); t1 = System.currentTimeMillis(); @@ -157,14 +157,14 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { animator.stop(); // glCanvas.destroy(); glOffscreen.destroy(); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { final Frame _frame = frame; _frame.dispose(); }}); } - + // default timing for 2 switches static long duration = 2900; // ms static long period = 1000; // ms @@ -186,7 +186,7 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { /** BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); System.err.println("Press enter to continue"); - System.err.println(stdin.readLine()); */ + System.err.println(stdin.readLine()); */ org.junit.runner.JUnitCore.main(TestGLContextDrawableSwitch02AWT.class.getName()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java index 033e55da3..96ec8ab75 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -31,7 +31,7 @@ package com.jogamp.opengl.test.junit.jogl.awt; import java.awt.Container; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; - + import java.awt.image.BufferedImage; import java.lang.reflect.InvocationTargetException; @@ -68,11 +68,11 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL JFrame jframe; GLOffscreenAutoDrawable offScreenBuffer; AWTGLReadBufferUtil awtGLReadBufferUtil; - + private void render(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); Assert.assertNotNull(gl); - gl.glClear(GL.GL_COLOR_BUFFER_BIT); + gl.glClear(GL.GL_COLOR_BUFFER_BIT); // draw a triangle filling the window gl.glBegin(GL.GL_TRIANGLES); @@ -84,7 +84,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL gl.glVertex2d(1, -1); gl.glEnd(); } - + /* @Override */ public void init(GLAutoDrawable drawable) { awtGLReadBufferUtil = new AWTGLReadBufferUtil(drawable.getGLProfile(), false); @@ -92,16 +92,16 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL /* @Override */ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } - + } + /* @Override */ - public void display(GLAutoDrawable drawable) { + public void display(GLAutoDrawable drawable) { render(offScreenBuffer); // BufferedImage outputImage = com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(200, 200, false); BufferedImage outputImage = awtGLReadBufferUtil.readPixelsToBufferedImage(drawable.getGL(), 0, 0, 200, 200, true /* awtOrientation */); Assert.assertNotNull(outputImage); ImageIcon imageIcon = new ImageIcon(outputImage); - final JLabel imageLabel = new JLabel(imageIcon); + final JLabel imageLabel = new JLabel(imageIcon); try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -116,7 +116,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL } /* @Override */ - public void dispose(GLAutoDrawable drawable) { + public void dispose(GLAutoDrawable drawable) { try { awtGLReadBufferUtil.dispose(drawable.getGL()); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { @@ -141,29 +141,29 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL GLProfile glp = GLProfile.get(GLProfile.GL2); Assert.assertNotNull(glp); - + GLDrawableFactory fac = GLDrawableFactory.getFactory(glp); Assert.assertNotNull(fac); - + Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice(), glp) ); - + GLCapabilities glCap = new GLCapabilities(glp); Assert.assertNotNull(glCap); - - // COMMENTING OUT THIS LINE FIXES THE ISSUE. + + // COMMENTING OUT THIS LINE FIXES THE ISSUE. // Setting this in JOGL1 works. Thus this is a JOGL2 issue. glCap.setSampleBuffers(true); - + // Without line below, there is an error on Windows. // glCap.setDoubleBuffered(false); // implicit double buffer -> MSAA + FBO - + // Needed for drop shadows glCap.setStencilBits(1); //makes a new buffer - offScreenBuffer = fac.createOffscreenAutoDrawable(GLProfile.getDefaultDevice(), glCap, null, 200, 200, null); + offScreenBuffer = fac.createOffscreenAutoDrawable(GLProfile.getDefaultDevice(), glCap, null, 200, 200); Assert.assertNotNull(offScreenBuffer); - offScreenBuffer.addGLEventListener(this); + offScreenBuffer.addGLEventListener(this); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { jframe.setSize( 300, 300); @@ -171,7 +171,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL }}); offScreenBuffer.display(); // read from front buffer due to FBO+MSAA -> double-buffer offScreenBuffer.display(); // now we have prev. image in front buffer to be read out - + Thread.sleep(durationPerTest); offScreenBuffer.destroy(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java index 89470a922..e87c34419 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java @@ -132,7 +132,7 @@ public class TestBug605FlippedImageAWT extends UITestCase { private void test(GLCapabilitiesImmutable caps) { final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); + final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256); final FlippedImageTest tglel = new FlippedImageTest(); glad.addGLEventListener(tglel); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java index 8d4710ad3..28fcb9885 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java @@ -119,7 +119,7 @@ public class TestBug605FlippedImageNEWT extends UITestCase { private void test(GLCapabilitiesImmutable caps) { final GLReadBufferUtil rbu = new GLReadBufferUtil(false, false); final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); + final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256); final FlippedImageTest tglel = new FlippedImageTest(); glad.addGLEventListener(tglel); final SnapshotGLEventListener snap = new SnapshotGLEventListener(rbu); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java index 521224c01..ba93dcdcd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -104,7 +104,7 @@ public class TestMultisampleES1AWT extends UITestCase { caps.setNumSamples(reqSamples); } - canvas = new GLCanvas(caps, chooser, null, null); + canvas = new GLCanvas(caps, chooser, null); canvas.addGLEventListener(new MultisampleDemoES1(reqSamples>0?true:false)); canvas.addGLEventListener(new GLEventListener() { int displayCount = 0; @@ -115,7 +115,7 @@ public class TestMultisampleES1AWT extends UITestCase { } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); - + final Frame frame = new Frame("Multi Samples "+reqSamples); frame.setLayout(new BorderLayout()); canvas.setSize(512, 512); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java index 63e89952f..db1f217ba 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java @@ -7,10 +7,10 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -55,16 +55,18 @@ public class GearsES1 implements GLEventListener { private boolean forceFFPEmu = false; private boolean debug = false ; private boolean trace = false ; - + private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f }; - private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; + private float view_rotx = 20.0f, view_roty = 30.0f; + private final float view_rotz = 0.0f; private GearsObject gear1=null, gear2=null, gear3=null; private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue; + private volatile boolean usesSharedGears = false; private float angle = 0.0f; - private int swapInterval; - private MouseListener gearsMouse = new GearsMouseAdapter(); - private KeyListener gearsKeys = new GearsKeyAdapter(); + private final int swapInterval; + private final MouseListener gearsMouse = new GearsMouseAdapter(); + private final KeyListener gearsKeys = new GearsKeyAdapter(); private int prevMouseX, prevMouseY; @@ -76,21 +78,21 @@ public class GearsES1 implements GLEventListener { public GearsES1() { this.swapInterval = 1; } - + public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) { this.forceFFPEmu = forceFFPEmu; this.verboseFFPEmu = verboseFFPEmu; this.debugFFPEmu = debugFFPEmu; this.traceFFPEmu = traceFFPEmu; } - + public void setGearsColors(FloatBuffer gear1Color, FloatBuffer gear2Color, FloatBuffer gear3Color) { this.gear1Color = gear1Color; this.gear2Color = gear2Color; this.gear3Color = gear3Color; } - - public void setGears(GearsObject g1, GearsObject g2, GearsObject g3) { + + public void setSharedGearsObjects(GearsObject g1, GearsObject g2, GearsObject g3) { gear1 = g1; gear2 = g2; gear3 = g3; @@ -110,15 +112,17 @@ public class GearsES1 implements GLEventListener { * @return gear3 */ public GearsObject getGear3() { return gear3; } - + + public boolean usesSharedGears() { return usesSharedGears; } + public void init(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES1.init ..."); - + // Use debug pipeline // drawable.setGL(new DebugGL(drawable.getGL())); GL _gl = drawable.getGL(); - + if(debugFFPEmu) { // Debug .. _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) ); @@ -130,12 +134,12 @@ public class GearsES1 implements GLEventListener { trace = false; } GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu); - + if(debug) { try { // Debug .. gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) ); - } catch (Exception e) {e.printStackTrace();} + } catch (Exception e) {e.printStackTrace();} } if(trace) { try { @@ -143,7 +147,7 @@ public class GearsES1 implements GLEventListener { gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) ); } catch (Exception e) {e.printStackTrace();} } - + System.err.println("GearsES1 init on "+Thread.currentThread()); System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); System.err.println("INIT GL IS: " + gl.getClass().getName()); @@ -154,33 +158,36 @@ public class GearsES1 implements GLEventListener { gl.glEnable(GL2ES1.GL_LIGHTING); gl.glEnable(GL2ES1.GL_LIGHT0); gl.glEnable(GL2ES1.GL_DEPTH_TEST); - + /* make the gears */ if(null == gear1) { gear1 = new GearsObjectES1(gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f); System.err.println("gear1 created: "+gear1); } else { + usesSharedGears = true; System.err.println("gear1 reused: "+gear1); } - + if(null == gear2) { gear2 = new GearsObjectES1(gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f); System.err.println("gear2 created: "+gear2); } else { + usesSharedGears = true; System.err.println("gear2 reused: "+gear2); } - + if(null == gear3) { gear3 = new GearsObjectES1(gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f); System.err.println("gear3 created: "+gear3); } else { + usesSharedGears = true; System.err.println("gear3 reused: "+gear3); } - + gl.glEnable(GL2ES1.GL_NORMALIZE); - + final Object upstreamWidget = drawable.getUpstreamWidget(); - if (upstreamWidget instanceof Window) { + if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; window.addMouseListener(gearsMouse); window.addKeyListener(gearsKeys); @@ -191,7 +198,7 @@ public class GearsES1 implements GLEventListener { } System.err.println(Thread.currentThread()+" GearsES1.init FIN"); } - + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { System.err.println(Thread.currentThread()+" GearsES1.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval); GL2ES1 gl = drawable.getGL().getGL2ES1(); @@ -217,7 +224,7 @@ public class GearsES1 implements GLEventListener { public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES1.dispose ... "); final Object upstreamWidget = drawable.getUpstreamWidget(); - if (upstreamWidget instanceof Window) { + if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; window.removeMouseListener(gearsMouse); window.removeKeyListener(gearsKeys); @@ -232,7 +239,7 @@ public class GearsES1 implements GLEventListener { System.err.println(Thread.currentThread()+" GearsES1.dispose FIN"); } - public void display(GLAutoDrawable drawable) { + public void display(GLAutoDrawable drawable) { // Turn the gears' teeth angle += 2.0f; @@ -251,10 +258,10 @@ public class GearsES1 implements GLEventListener { } else { gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f); } - + // Special handling for the case where the GLJPanel is translucent // and wants to be composited with other Java 2D content - if (GLProfile.isAWTAvailable() && + if (GLProfile.isAWTAvailable() && (drawable instanceof javax.media.opengl.awt.GLJPanel) && !((javax.media.opengl.awt.GLJPanel) drawable).isOpaque() && ((javax.media.opengl.awt.GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) { @@ -264,25 +271,25 @@ public class GearsES1 implements GLEventListener { } gl.glNormal3f(0.0f, 0.0f, 1.0f); - + // Rotate the entire assembly of gears based on how the user // dragged the mouse around gl.glPushMatrix(); gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); - - gear1.draw(gl, -3.0f, -2.0f, angle); - gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f); + + gear1.draw(gl, -3.0f, -2.0f, angle); + gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f); gear3.draw(gl, -3.1f, 4.2f, -2.0f * angle - 25.0f); - + // Remember that every push needs a pop; this one is paired with // rotating the entire gear assembly gl.glPopMatrix(); } - - class GearsKeyAdapter extends KeyAdapter { + + class GearsKeyAdapter extends KeyAdapter { public void keyPressed(KeyEvent e) { int kc = e.getKeyCode(); if(KeyEvent.VK_LEFT == kc) { @@ -296,16 +303,16 @@ public class GearsES1 implements GLEventListener { } } } - + class GearsMouseAdapter extends MouseAdapter { public void mousePressed(MouseEvent e) { prevMouseX = e.getX(); prevMouseY = e.getY(); } - + public void mouseReleased(MouseEvent e) { } - + public void mouseDragged(MouseEvent e) { int x = e.getX(); int y = e.getY(); @@ -324,7 +331,7 @@ public class GearsES1 implements GLEventListener { } float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width); float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height); - + prevMouseX = x; prevMouseY = y; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 9817ea57f..60242d604 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -45,6 +45,7 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLContext; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import javax.media.opengl.GLUniformData; @@ -64,7 +65,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL private final float view_rotz = 0.0f; private float panX = 0.0f, panY = 0.0f, panZ=0.0f; - private GearsObjectES2 gear1=null, gear2=null, gear3=null; + private volatile GearsObjectES2 gear1=null, gear2=null, gear3=null; + private GearsES2 sharedGears = null; + private volatile boolean usesSharedGears = false; private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue; private float angle = 0.0f; private int swapInterval = 0; @@ -80,6 +83,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL private float[] clearColor = null; private boolean clearBuffers = true; private boolean verbose = true; + private volatile boolean isInit = false; private PinchToZoomGesture pinchToZoomGesture = null; @@ -132,12 +136,16 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL this.gear3Color = gear3Color; } - public void setGears(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) { + public void setSharedGearsObjects(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) { gear1 = g1; gear2 = g2; gear3 = g3; } + public void setSharedGears(GearsES2 shared) { + sharedGears = shared; + } + /** * @return gear1 */ @@ -153,12 +161,33 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL */ public GearsObjectES2 getGear3() { return gear3; } + public boolean usesSharedGears() { return usesSharedGears; } + + private static final int TIME_OUT = 2000; // 2s + private static final int POLL_DIVIDER = 20; // TO/20 + private static final int TIME_SLICE = TIME_OUT / POLL_DIVIDER ; + + /** + * @return True if this GLEventListener became initialized within TIME_OUT 2s + */ + public boolean waitForInit(boolean initialized) throws InterruptedException { + int wait; + for (wait=0; wait "+gear1); + System.err.println("gear2 created w/ share: "+sharedGears.getGear2()+" -> "+gear2); + System.err.println("gear3 created w/ share: "+sharedGears.getGear3()+" -> "+gear3); + } } else { - gear1 = new GearsObjectES2(gear1, st, pmvMatrix, pmvMatrixUniform, colorU); - if(verbose) { - System.err.println("gear1 reused: "+gear1); + if(null == gear1) { + gear1 = new GearsObjectES2(st, gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); + if(verbose) { + System.err.println("gear1 created: "+gear1); + } + } else { + final GearsObjectES2 _gear1 = gear1; + gear1 = new GearsObjectES2(_gear1, st, pmvMatrix, pmvMatrixUniform, colorU); + usesSharedGears = true; + if(verbose) { + System.err.println("gear1 created w/ share: "+_gear1+" -> "+gear1); + } } - } - if(null == gear2) { - gear2 = new GearsObjectES2(st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); - if(verbose) { - System.err.println("gear2 created: "+gear2); - } - } else { - gear2 = new GearsObjectES2(gear2, st, pmvMatrix, pmvMatrixUniform, colorU); - if(verbose) { - System.err.println("gear2 reused: "+gear2); + if(null == gear2) { + gear2 = new GearsObjectES2(st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); + if(verbose) { + System.err.println("gear2 created: "+gear2); + } + } else { + final GearsObjectES2 _gear2 = gear2; + gear2 = new GearsObjectES2(_gear2, st, pmvMatrix, pmvMatrixUniform, colorU); + usesSharedGears = true; + if(verbose) { + System.err.println("gear2 created w/ share: "+_gear2+" -> "+gear2); + } } - } - if(null == gear3) { - gear3 = new GearsObjectES2(st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); - if(verbose) { - System.err.println("gear3 created: "+gear3); - } - } else { - gear3 = new GearsObjectES2(gear3, st, pmvMatrix, pmvMatrixUniform, colorU); - if(verbose) { - System.err.println("gear3 reused: "+gear3); + if(null == gear3) { + gear3 = new GearsObjectES2(st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); + if(verbose) { + } + } else { + final GearsObjectES2 _gear3 = gear3; + gear3 = new GearsObjectES2(_gear3, st, pmvMatrix, pmvMatrixUniform, colorU); + usesSharedGears = true; + if(verbose) { + System.err.println("gear3 created w/ share: "+_gear3+" -> "+gear3); + } } } @@ -254,6 +300,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL st.useProgram(gl, false); System.err.println(Thread.currentThread()+" GearsES2.init FIN"); + isInit = true; } private final GestureHandler.GestureListener pinchToZoomListener = new GestureHandler.GestureListener() { @@ -267,6 +314,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL @Override public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { + if( !isInit ) { return; } final GL2ES2 gl = glad.getGL().getGL2ES2(); if(-1 != swapInterval) { gl.setSwapInterval(swapInterval); @@ -278,6 +326,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL public void reshapeTile(TileRendererBase tr, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { + if( !isInit ) { return; } final GL2ES2 gl = tr.getAttachedDrawable().getGL().getGL2ES2(); gl.setSwapInterval(0); reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); @@ -339,6 +388,8 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL @Override public void dispose(GLAutoDrawable drawable) { + if( !isInit ) { return; } + isInit = false; System.err.println(Thread.currentThread()+" GearsES2.dispose: tileRendererInUse "+tileRendererInUse); final Object upstreamWidget = drawable.getUpstreamWidget(); if (upstreamWidget instanceof Window) { @@ -370,6 +421,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL @Override public void display(GLAutoDrawable drawable) { + if( !isInit ) { return; } GLAnimatorControl anim = drawable.getAnimator(); if( verbose && ( null == anim || !anim.isAnimating() ) ) { System.err.println(Thread.currentThread()+" GearsES2.display "+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java index 4d9b750c4..b9e64e1da 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java @@ -31,7 +31,7 @@ import com.jogamp.opengl.util.texture.TextureIO; *

                      * Bug Reference: https://jogamp.org/bugzilla/show_bug.cgi?id=365 *

                      - * The bug pertains to mipmap generation from a Texture and exists in {@link ScaleInternal} + * The bug pertains to mipmap generation from a Texture and exists in {@link ScaleInternal} * where a {@link java.nio.BufferUnderflowException} is thrown. *

                      *

                        This suite of test cases test: @@ -43,14 +43,14 @@ import com.jogamp.opengl.util.texture.TextureIO; *
                      • {@link ScaleInternal#scale_internal_int(int, int, int, ByteBuffer, int, int, java.nio.IntBuffer, int, int, int, boolean)}
                      • *
                      • {@link ScaleInternal#scale_internal_float(int, int, int, ByteBuffer, int, int, java.nio.FloatBuffer, int, int, int, boolean)}
                      • *
                      - * + * * @author Michael Esemplare, et.al. * */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestBug365TextureGenerateMipMaps extends UITestCase { static GLOffscreenAutoDrawable drawable; - + @BeforeClass public static void setup() throws Throwable { // disableNPOT @@ -61,23 +61,21 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase { throw t; } } - + @AfterClass public static void teardown() { tearDownOffscreenAutoDrawable(); } - + private static void setUpOffscreenAutoDrawable() throws Throwable { GLProfile glp = GLProfile.getDefault(); GLCapabilities caps = new GLCapabilities(glp); - + GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); - - // Make a drawable to get an offscreen context - drawable = factory.createOffscreenAutoDrawable(null, caps, null, 2, 2, null); - - drawable.setRealized(true); + // Make a drawable to get an offscreen context + drawable = factory.createOffscreenAutoDrawable(null, caps, null, 2, 2); + drawable.display(); // trigger context creation GLContext glContext = drawable.getContext(); try { Assert.assertTrue("Could not make context current", GLContext.CONTEXT_NOT_CURRENT < glContext.makeCurrent()); @@ -86,7 +84,7 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase { throw t; } } - + private static void tearDownOffscreenAutoDrawable() { if(drawable != null) { drawable.getContext().release(); @@ -94,30 +92,30 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase { drawable = null; } } - + private static void testTextureMipMapGeneration(int width, int height, int pixelFormat, int pixelType) { int internalFormat = pixelFormat; int border = 0; boolean mipmap = true; boolean dataIsCompressed = false; boolean mustFlipVertically = false; - + int memReq = Mipmap.image_size( width, height, pixelFormat, pixelType ); ByteBuffer buffer = Buffers.newDirectByteBuffer( memReq ); - - TextureData data = new TextureData(drawable.getGLProfile(), - internalFormat, - width, - height, - border, - pixelFormat, - pixelType, - mipmap, - dataIsCompressed, - mustFlipVertically, - buffer, + + TextureData data = new TextureData(drawable.getGLProfile(), + internalFormat, + width, + height, + border, + pixelFormat, + pixelType, + mipmap, + dataIsCompressed, + mustFlipVertically, + buffer, null); - + Texture texture = TextureIO.newTexture(drawable.getGL(), data); // Cleanup texture.destroy(drawable.getGL()); @@ -125,144 +123,144 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase { buffer.clear(); buffer = null; } - + @Test public void test00_MipMap_ScaleInternal_RGB_UBYTE () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_UNSIGNED_BYTE; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test01_MipMap_ScaleInternal_RGBA_UBYTE () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_UNSIGNED_BYTE; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test02_MipMap_ScaleInternal_RGB_BYTE () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_BYTE; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test03_MipMap_ScaleInternal_RGBA_BYTE () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_BYTE; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test04_MipMap_ScaleInternal_RGB_USHORT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_UNSIGNED_SHORT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test05_MipMap_ScaleInternal_RGBA_USHORT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_UNSIGNED_SHORT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test06_MipMap_ScaleInternal_RGB_SHORT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_SHORT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test07_MipMap_ScaleInternal_RGBA_SHORT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_SHORT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test08_MipMap_ScaleInternal_RGB_UINT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_UNSIGNED_INT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test09_MipMap_ScaleInternal_RGBA_UINT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_UNSIGNED_INT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test10_MipMap_ScaleInternal_RGB_INT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_INT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test11_MipMap_ScaleInternal_RGBA_INT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_INT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test12_MipMap_ScaleInternal_RGB_FLOAT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_FLOAT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test13_MipMap_ScaleInternal_RGBA_FLOAT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_FLOAT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java index d539b5e55..16c1b33f4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -60,14 +60,14 @@ import org.junit.runners.MethodSorters; *

                      *

                      * {@link RandomTileRenderer} buffer allocation is performed - * within the pre {@link GLEventListener} + * within the pre {@link GLEventListener} * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} - * on the main thread. + * on the main thread. *

                      *

                      * At tile rendering finish, the viewport and * and the original {@link GLEventListener}'s PMV matrix as well. - * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. + * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. *

                      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -83,7 +83,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { doTest(8); } - void doTest(int msaaCount) throws IOException, InterruptedException, InvocationTargetException { + void doTest(int msaaCount) throws IOException, InterruptedException, InvocationTargetException { final GLCapabilities caps = new GLCapabilities(null); caps.setDoubleBuffered(true); if( msaaCount > 0 ) { @@ -93,7 +93,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { final int maxTileSize = 64; final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize, null); + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize); final Gears gears = new Gears(); glad.addGLEventListener( gears ); @@ -156,7 +156,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); gears.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); return false; - } + } }); glad.destroy(); @@ -168,9 +168,9 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { caps.getGLProfile(), 0 /* internalFormat */, imageWidth, imageHeight, - 0, + 0, imageBuffer.pixelAttributes, - false, false, + false, false, flipVertically[0], imageBuffer.buffer, null /* Flusher */); @@ -189,5 +189,5 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { } } org.junit.runner.JUnitCore.main(TestRandomTiledRendering2GL2NEWT.class.getName()); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java index 74909dc8c..2220c1fb3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -60,14 +60,14 @@ import org.junit.runners.MethodSorters; *

                      *

                      * {@link TileRenderer} buffer allocation is performed - * within the pre {@link GLEventListener} + * within the pre {@link GLEventListener} * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} - * on the main thread. + * on the main thread. *

                      *

                      * At tile rendering finish, the viewport and * and the original {@link GLEventListener}'s PMV matrix as well. - * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. + * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. *

                      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -88,8 +88,8 @@ public class TestTiledRendering2NEWT extends UITestCase { return null; } return glp; - } - + } + @Test public void test001_off_gl2___aa0() throws IOException { GLProfile glp = getGLProfile(GLProfile.GL2); @@ -155,8 +155,8 @@ public class TestTiledRendering2NEWT extends UITestCase { doTest(true, new GearsES2(), glp, 8); } - void doTest(boolean onscreen, final GLEventListener demo, GLProfile glp, final int msaaCount) throws IOException { - GLCapabilities caps = new GLCapabilities(glp); + void doTest(boolean onscreen, final GLEventListener demo, GLProfile glp, final int msaaCount) throws IOException { + GLCapabilities caps = new GLCapabilities(glp); caps.setDoubleBuffered(onscreen); if( msaaCount > 0 ) { caps.setSampleBuffers(true); @@ -172,7 +172,7 @@ public class TestTiledRendering2NEWT extends UITestCase { glad = glWin; } else { final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); - glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize, null); + glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize); } glad.addGLEventListener( demo ); @@ -220,7 +220,7 @@ public class TestTiledRendering2NEWT extends UITestCase { } renderer.detachAutoDrawable(); - + // Restore viewport and Gear's PMV matrix // .. even though we close the demo, this is for documentation! glad.invoke(true, new GLRunnable() { @@ -229,7 +229,7 @@ public class TestTiledRendering2NEWT extends UITestCase { drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); demo.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); return false; - } + } }); final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); @@ -237,15 +237,15 @@ public class TestTiledRendering2NEWT extends UITestCase { caps.getGLProfile(), 0 /* internalFormat */, imageWidth, imageHeight, - 0, + 0, imageBuffer.pixelAttributes, - false, false, + false, false, flipVertically[0], imageBuffer.buffer, null /* Flusher */); TextureIO.write(textureData, file); - + glad.destroy(); } @@ -259,5 +259,5 @@ public class TestTiledRendering2NEWT extends UITestCase { } } org.junit.runner.JUnitCore.main(TestTiledRendering2NEWT.class.getName()); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index e85052d08..b1e9f477e 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.util; import jogamp.newt.WindowImplAccess; @@ -40,6 +40,7 @@ import java.awt.Robot; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import org.junit.Assert; @@ -50,17 +51,17 @@ import com.jogamp.newt.event.WindowEvent; public class AWTRobotUtil { static final boolean DEBUG = false; - + public static final int RETRY_NUMBER = 5; public static final int ROBOT_DELAY = 100; // ms public static final int TIME_OUT = 2000; // 2s public static final int POLL_DIVIDER = 20; // TO/20 public static final int TIME_SLICE = TIME_OUT / POLL_DIVIDER ; - public static Integer AWT_CLICK_TO = null; - + public static Integer AWT_CLICK_TO = null; + static Object awtEDTAliveSync = new Object(); - static volatile boolean awtEDTAliveFlag = false; - + static volatile boolean awtEDTAliveFlag = false; + static class OurUncaughtExceptionHandler implements UncaughtExceptionHandler { @Override public void uncaughtException(Thread t, Throwable e) { @@ -68,16 +69,16 @@ public class AWTRobotUtil { e.printStackTrace(); } } - + static { Thread.setDefaultUncaughtExceptionHandler( new OurUncaughtExceptionHandler() ); // System.err.println("AWT EDT alive: "+isAWTEDTAlive()); } - + /** Probes whether AWT's EDT is alive or not. */ public static boolean isAWTEDTAlive() { if( EventQueue.isDispatchThread() ) { - return true; + return true; } synchronized ( awtEDTAliveSync ) { awtEDTAliveFlag = false; @@ -85,7 +86,7 @@ public class AWTRobotUtil { @Override public void run() { awtEDTAliveFlag = true; - } + } }); for (int wait=0; wait tc && j tc && j delta ) { throw new AssertionError(msg+"; Expected @ ["+a0+"+"+i+"] has "+ai+", but actual @ ["+b0+"+"+i+"] has "+bi+", it's delta "+daibi+" > "+delta); } } } - + public static void assertFloatBufferNotEqual(String errmsg, FloatBuffer expected, FloatBuffer actual, float delta) { if(null == expected || null == actual) { return; } if(expected.remaining() != actual.remaining()) { - return; + return; } String msg = null != errmsg ? errmsg + " " : ""; final int a0 = expected.position(); @@ -131,14 +135,14 @@ public class MiscUtils { for(int i=0; i delta ) { return; } } throw new AssertionError(msg+"; Expected and actual are equal."); } - + public static boolean setFieldIfExists(Object instance, String fieldName, Object value) { try { Field f = instance.getClass().getField(fieldName); @@ -155,14 +159,14 @@ public class MiscUtils { } return false; } - + public static class StreamDump extends Thread { final InputStream is; final StringBuilder outString; final OutputStream outStream; final String prefix; final Object sync; - volatile boolean eos = false; + volatile boolean eos = false; public StreamDump(OutputStream out, String prefix, InputStream is, Object sync) { this.is = is; @@ -178,7 +182,7 @@ public class MiscUtils { this.prefix = null; this.sync = sync; } - + public final boolean eos() { return eos; } @Override @@ -208,7 +212,28 @@ public class MiscUtils { } } } - } + } + + public static void dumpSharedGLContext(GLContext self) { + int i = 0, j = 0; + System.err.println("Myself: hash 0x"+Integer.toHexString(self.hashCode())+", \t(isShared "+self.isShared()+", created "+self.isCreated()+")"); + { + final List set = self.getCreatedShares(); + for (final Iterator iter = set.iterator(); iter.hasNext(); ) { + final GLContext c = iter.next(); + System.err.println("Ctx #"+(i++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")"); + } + } + { + final List set = self.getDestroyedShares(); + for (final Iterator iter = set.iterator(); iter.hasNext(); ) { + final GLContext c = iter.next(); + System.err.println("Ctx #"+(j++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")"); + } + } + System.err.println("\t Total created "+i+" + destroyed "+j+" = "+(i+j)); + System.err.println(); + } } -- cgit v1.2.3 From 802f52a2ed4769703786f03fbc9b036fecca49bd Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 30 Oct 2013 18:28:22 +0100 Subject: Android NEWT.ScreenDriver MonitorSize: Use xdpi for for width (fix); Add DEBUG output. --- .../jogamp/newt/driver/android/ScreenDriver.java | 60 +++++++++++++--------- 1 file changed, 35 insertions(+), 25 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java index cc35ff710..66237204c 100644 --- a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -61,35 +61,35 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { @Override protected int validateScreenIndex(int idx) { - return 0; // FIXME: only one screen available ? + return 0; // FIXME: only one screen available ? } - + private final MonitorMode getModeImpl(final Cache cache, final android.view.Display aDisplay, DisplayMetrics outMetrics, int modeIdx, int screenSizeNRot, int nrot) { final int[] props = new int[MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; i = getScreenSize(outMetrics, screenSizeNRot, props, i); // width, height - i = getBpp(aDisplay, props, i); // bpp + i = getBpp(aDisplay, props, i); // bpp props[i++] = (int) ( aDisplay.getRefreshRate() * 100.0f ); // Hz * 100 props[i++] = 0; // flags props[i++] = modeIdx; // modeId; props[i++] = nrot; return MonitorModeProps.streamInMonitorMode(null, cache, props, 0); } - + @Override protected void collectNativeMonitorModesAndDevicesImpl(Cache cache) { // FIXME: Multi Monitor Implementation missing [for newer Android version ?] - + final Context ctx = jogamp.common.os.android.StaticContext.getContext(); final WindowManager wmgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); final DisplayMetrics outMetrics = new DisplayMetrics(); final android.view.Display aDisplay = wmgr.getDefaultDisplay(); aDisplay.getMetrics(outMetrics); - + final int arot = aDisplay.getRotation(); final int nrot = androidRotation2NewtRotation(arot); - + final int modeIdx=0; // no native modeId in use - use 0 MonitorMode currentMode = null; for(int r=0; r<4; r++) { // for all rotations @@ -98,7 +98,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { if( nrot == nrot_i ) { currentMode = mode; } - } + } final int[] props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 - MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES]; int i = 0; @@ -109,17 +109,17 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { props[i++] = 0; // rotated viewport y props[i++] = outMetrics.widthPixels; // rotated viewport width props[i++] = outMetrics.heightPixels; // rotated viewport height - MonitorModeProps.streamInMonitorDevice(null, cache, this, cache.monitorModes, currentMode, props, 0); + MonitorModeProps.streamInMonitorDevice(null, cache, this, cache.monitorModes, currentMode, props, 0); } @Override - protected MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor) { + protected MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor) { final Context ctx = jogamp.common.os.android.StaticContext.getContext(); final WindowManager wmgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); final DisplayMetrics outMetrics = new DisplayMetrics(); final android.view.Display aDisplay = wmgr.getDefaultDisplay(); aDisplay.getMetrics(outMetrics); - + final int currNRot = androidRotation2NewtRotation(aDisplay.getRotation()); return getModeImpl(null, aDisplay, outMetrics, 0, currNRot, currNRot); } @@ -128,7 +128,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { protected boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode) { return false; } - + //---------------------------------------------------------------------- // Internals only // @@ -151,7 +151,7 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { props[offset++] = outMetrics.heightPixels; } return offset; - } + } static int getBpp(android.view.Display aDisplay, int[] props, int offset) { int bpp; switch(aDisplay.getPixelFormat()) { @@ -162,18 +162,28 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { case PixelFormat.RGBA_5551: bpp=16; break; case PixelFormat.RGBA_4444: bpp=16; break; case PixelFormat.RGB_332: bpp= 8; break; - default: bpp=32; - } - props[offset++] = bpp; + default: bpp=32; + } + props[offset++] = bpp; return offset; } static int getScreenSizeMM(DisplayMetrics outMetrics, int[] props, int offset) { - final float iw = (float) outMetrics.widthPixels / outMetrics.xdpi; - final float ih = (float) outMetrics.heightPixels / outMetrics.xdpi; + final float inW = outMetrics.widthPixels / outMetrics.xdpi; + final float inH = outMetrics.heightPixels / outMetrics.ydpi; final float mmpi = 25.4f; - props[offset++] = (int) ((iw * mmpi)+0.5); - props[offset++] = (int) ((ih * mmpi)+0.5); + final float mmW = inW * mmpi; + final float mmH = inH * mmpi; + if( DEBUG ) { + System.err.println("Screen A screen "+outMetrics.widthPixels+" x "+outMetrics.heightPixels); + System.err.println("Screen A xy dpi "+outMetrics.xdpi+" x "+outMetrics.ydpi); + System.err.println("Screen A densityDPI "+outMetrics.densityDpi); + System.err.println("Screen A density "+outMetrics.density); + System.err.println("Screen N xy inch "+inW+" x "+inH); + System.err.println("Screen N xy mm "+mmW+" x "+mmH); + } + props[offset++] = Math.round(mmW); + props[offset++] = Math.round(mmH); return offset; - } + } } -- cgit v1.2.3 From 24eab4dc2a14eed97897ec61b69f7f845ab84e04 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 6 Nov 2013 07:06:58 +0100 Subject: NEWT Window: Expose 'setVisible(boolean wait, boolean visible)' allowing applications to not block until window becomes visible. --- src/newt/classes/com/jogamp/newt/Window.java | 21 +++++++++++++++----- .../classes/com/jogamp/newt/opengl/GLWindow.java | 5 +++++ src/newt/classes/jogamp/newt/WindowImpl.java | 23 +++++++++++----------- 3 files changed, 33 insertions(+), 16 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 04eb07a25..869b56331 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -158,10 +158,21 @@ public interface Window extends NativeWindow, WindowClosingProtocol { void setWindowDestroyNotifyAction(Runnable r); /** - * setVisible makes the window and children visible if visible is true, + * Calls {@link #setVisible(boolean, boolean) setVisible(true, visible)}, + * i.e. blocks until the window becomes visible. + * @see #setVisible(boolean, boolean) + */ + void setVisible(boolean visible); + + /** + * setVisible(..) makes the window and children visible if visible is true, * otherwise the window and children becomes invisible. *

                      - * The setVisible(true) is responsible to actual create the native window. + * setVisible(wait, true) is responsible to actual create the native window. + *

                      + *

                      + * If wait is true, method blocks until window is {@link #isVisible() visible} and {@link #isNativeValid() valid}, + * otherwise method returns immediately. *

                      *

                      * Zero size semantics are respected, see {@link #setSize(int,int)}:
                      @@ -178,12 +189,12 @@ public interface Window extends NativeWindow, WindowClosingProtocol { *

                      *

                      * In case this window is a child window and has a {@link javax.media.nativewindow.NativeWindow} parent,
                      - * setVisible(true) has no effect as long the parent's is not valid yet, + * setVisible(wait, true) has no effect as long the parent's is not valid yet, * i.e. {@link javax.media.nativewindow.NativeWindow#getWindowHandle()} returns null.
                      - * setVisible(true) shall be repeated when the parent becomes valid. + * setVisible(wait, true) shall be repeated when the parent becomes valid. *

                      */ - void setVisible(boolean visible); + void setVisible(boolean wait, boolean visible); boolean isVisible(); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 4f259fe9a..52f19f783 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -425,6 +425,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind window.setVisible(visible); } + @Override + public void setVisible(boolean wait, boolean visible) { + window.setVisible(wait, visible); + } + @Override public final void setSize(int width, int height) { window.setSize(width, height); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 5102fd26d..77c19ae05 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -148,7 +148,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private volatile int x = 64, y = 64; // client-area pos w/o insets private volatile Insets insets = new Insets(); // insets of decoration (if top-level && decorated) - private RecursiveLock windowLock = LockFactory.createRecursiveLock(); // Window instance wide lock + private final RecursiveLock windowLock = LockFactory.createRecursiveLock(); // Window instance wide lock private int surfaceLockCount = 0; // surface lock recursion count private ScreenImpl screen; // never null after create - may change reference though (reparent) @@ -177,10 +177,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private FocusRunnable focusAction = null; private KeyListener keyboardFocusHandler = null; - private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); + private final SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); - private Object childWindowsLock = new Object(); - private ArrayList childWindows = new ArrayList(); + private final Object childWindowsLock = new Object(); + private final ArrayList childWindows = new ArrayList(); private ArrayList mouseListeners = new ArrayList(); @@ -196,7 +196,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer lastButtonPressTime = 0; } } - private PointerState0 pState0 = new PointerState0(); + private final PointerState0 pState0 = new PointerState0(); /** from direct input: {@link WindowImpl#doPointerEvent(boolean, boolean, int[], short, int, int, boolean, short[], int[], int[], float[], float, float[], float)}. */ private static class PointerState1 extends PointerState0 { @@ -227,7 +227,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return null; } } - private PointerState1 pState1 = new PointerState1(); + private final PointerState1 pState1 = new PointerState1(); /** pointer names -> pointer ID (consecutive index, starting w/ 0) */ private final ArrayHashSet pName2pID = new ArrayHashSet(); @@ -534,7 +534,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer //---------------------------------------------------------------------- // WindowClosingProtocol implementation // - private Object closingListenerLock = new Object(); + private final Object closingListenerLock = new Object(); private WindowClosingMode defaultCloseOperation = WindowClosingMode.DISPOSE_ON_CLOSE; @Override @@ -965,7 +965,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - protected void setVisible(boolean wait, boolean visible) { + @Override + public void setVisible(boolean wait, boolean visible) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window setVisible: START ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)); } @@ -3007,7 +3008,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private final IntBitfield keyPressedState = new IntBitfield( keyTrackingRange + 1 ); protected final boolean isKeyCodeTracked(final short keyCode) { - return ( 0xFFFF & (int)keyCode ) <= keyTrackingRange; + return ( 0xFFFF & keyCode ) <= keyTrackingRange; } /** @@ -3016,7 +3017,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @return the previus pressed value */ protected final boolean setKeyPressed(short keyCode, boolean pressed) { - final int v = 0xFFFF & (int)keyCode; + final int v = 0xFFFF & keyCode; if( v <= keyTrackingRange ) { return keyPressedState.put(v, pressed); } @@ -3027,7 +3028,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @return true if pressed, otherwise false */ protected final boolean isKeyPressed(short keyCode) { - final int v = 0xFFFF & (int)keyCode; + final int v = 0xFFFF & keyCode; if( v <= keyTrackingRange ) { return keyPressedState.get(v); } -- cgit v1.2.3 From de8a370258e60ad9bcf40cf8e6d239ecf306114e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 6 Nov 2013 15:30:50 +0100 Subject: Bug 894 - GLDrawableFactory* [dummy|offscreen] Surface creation w/ own device does _not_ require locking on global shared device. --- .../javax/media/opengl/GLDrawableFactory.java | 13 ++++++ .../jogamp/opengl/GLDrawableFactoryImpl.java | 53 +++++++++------------- .../classes/jogamp/opengl/egl/EGLDisplayUtil.java | 2 + .../macosx/cgl/MacOSXCGLDrawableFactory.java | 4 +- .../windows/wgl/WindowsWGLDrawableFactory.java | 5 +- .../jogamp/newt/driver/bcm/egl/DisplayDriver.java | 1 - 6 files changed, 41 insertions(+), 37 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 2af4ba306..2b1d228ad 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -490,6 +490,9 @@ public abstract class GLDrawableFactory { * If neither FBO nor Pbuffer is available, * a simple pixmap/bitmap auto drawable is created, which is unlikely to be hardware accelerated. *

                      + *

                      + * The resulting {@link GLOffscreenAutoDrawable} has it's own independent device instance using device details. + *

                      * * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. * @param caps the requested GLCapabilties @@ -540,6 +543,9 @@ public abstract class GLDrawableFactory { * If neither FBO nor Pbuffer is available, * a simple pixmap/bitmap auto drawable is created, which is unlikely to be hardware accelerated. *

                      + *

                      + * The resulting {@link GLOffscreenAutoDrawable} has it's own independent device instance using device details. + *

                      * * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. * @param caps the requested GLCapabilties @@ -604,6 +610,9 @@ public abstract class GLDrawableFactory { * If neither FBO nor Pbuffer is available, * a simple pixmap/bitmap drawable is created, which is unlikely to be hardware accelerated. *

                      + *

                      + * The resulting {@link GLDrawable} has it's own independent device instance using device details. + *

                      * * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. * @param caps the requested GLCapabilties @@ -657,6 +666,10 @@ public abstract class GLDrawableFactory { * you will be able to implement a new native windowing system binding almost on-the-fly, * see {@link com.jogamp.opengl.swt.GLCanvas}. *

                      + *

                      + * The resulting {@link GLOffscreenAutoDrawable} has it's own independent device instance using device details + * which may be blocking depending on platform and windowing-toolkit requirements. + *

                      * * @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. * Caller has to ensure it is compatible w/ the given windowHandle diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index cadf40f02..c914b5e10 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -270,16 +270,10 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(capsRequested); - GLDrawableImpl drawable = null; - device.lock(); - try { - drawable = createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, - new UpstreamSurfaceHookMutableSize(width, height) ) ); - if(null != drawable) { - drawable.setRealized(true); - } - } finally { - device.unlock(); + final GLDrawableImpl drawable = createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, + new UpstreamSurfaceHookMutableSize(width, height) ) ); + if(null != drawable) { + drawable.setRealized(true); } return new GLPbufferImpl( drawable, (GLContextImpl) drawable.createContext(shareWith) ); @@ -350,19 +344,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, this, device); - device.lock(); - try { - if( capsChosen.isFBO() ) { - // Use minimum GLCapabilities for the dummy surface w/ same profile - final ProxySurface dummySurface = createDummySurfaceImpl(device, true, new GLCapabilities(capsChosen.getGLProfile()), capsRequested, null, width, height); - final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); - return new GLFBODrawableImpl.ResizeableImpl(this, dummyDrawable, dummySurface, capsChosen, 0); - } - return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, - new UpstreamSurfaceHookMutableSize(width, height) ) ); - } finally { - device.unlock(); + if( capsChosen.isFBO() ) { + // Use minimum GLCapabilities for the dummy surface w/ same profile + final ProxySurface dummySurface = createDummySurfaceImpl(device, true, new GLCapabilities(capsChosen.getGLProfile()), capsRequested, null, width, height); + final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); + return new GLFBODrawableImpl.ResizeableImpl(this, dummyDrawable, dummySurface, capsChosen, 0); } + return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, + new UpstreamSurfaceHookMutableSize(width, height) ) ); } @Override @@ -371,12 +360,16 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if(null == device) { throw new GLException("No shared device for requested: "+deviceReq+", createNewDevice "+createNewDevice); } - device.lock(); + if( !createNewDevice ) { + device.lock(); + } try { final ProxySurface dummySurface = createDummySurfaceImpl(device, createNewDevice, capsRequested, capsRequested, chooser, 64, 64); return createOnscreenDrawableImpl(dummySurface); } finally { - device.unlock(); + if( !createNewDevice ) { + device.unlock(); + } } } @@ -398,7 +391,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * Lifecycle (destruction) of the TBD surface handle shall be handled by the caller. *

                      * @param device a valid platform dependent target device. - * @param createNewDevice if true a new device instance is created using device details, + * @param createNewDevice if true a new independent device instance is created using device details, * otherwise device instance is used as-is. * @param capsChosen * @param capsRequested @@ -418,6 +411,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * It is used to allow the creation of a {@link GLDrawable} and {@link GLContext} to query information. * It also allows creation of framebuffer objects which are used for rendering or using a shared GLContext w/o actually rendering to a usable framebuffer. *

                      + *

                      + * Creates a new independent device instance using deviceReq details. + *

                      * @param deviceReq which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. * @param requestedCaps * @param chooser the custom chooser, may be null for default @@ -434,12 +430,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } - device.lock(); - try { - return createDummySurfaceImpl(device, true, requestedCaps, requestedCaps, chooser, width, height); - } finally { - device.unlock(); - } + return createDummySurfaceImpl(device, true, requestedCaps, requestedCaps, chooser, width, height); } /** diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index 3d864ad76..0577124eb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -34,6 +34,7 @@ import java.util.Iterator; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.ToolkitLock; import javax.media.opengl.GLException; import jogamp.opengl.Debug; @@ -260,6 +261,7 @@ public class EGLDisplayUtil { }; /** + * Using the default {@link ToolkitLock}, via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}. * @param nativeDisplayID * @param connection * @param unitID diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index 994eee8d7..e41c97827 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -151,7 +151,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { static class SharedResource implements SharedResourceRunner.Resource { // private MacOSXCGLDrawable drawable; // private MacOSXCGLContext context; - private GLRendererQuirks glRendererQuirks; + private final GLRendererQuirks glRendererQuirks; MacOSXGraphicsDevice device; boolean valid; boolean hasNPOTTextures; @@ -211,7 +211,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { return false; } - private HashSet devicesTried = new HashSet(); + private final HashSet devicesTried = new HashSet(); private boolean getDeviceTried(String connection) { synchronized (devicesTried) { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 95485b033..64ed197ea 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -41,7 +41,6 @@ package jogamp.opengl.windows.wgl; import java.nio.Buffer; - import java.nio.ShortBuffer; import java.security.AccessController; import java.security.PrivilegedAction; @@ -171,8 +170,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { private HashMap sharedMap; private long processAffinityChanges = 0; - private PointerBuffer procMask = PointerBuffer.allocateDirect(1); - private PointerBuffer sysMask = PointerBuffer.allocateDirect(1); + private final PointerBuffer procMask = PointerBuffer.allocateDirect(1); + private final PointerBuffer sysMask = PointerBuffer.allocateDirect(1); @Override protected void enterThreadCriticalZone() { diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java index 9da671d37..d1b30f7cc 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java @@ -39,7 +39,6 @@ import javax.media.nativewindow.NativeWindowException; import jogamp.newt.NEWTJNILibLoader; import jogamp.opengl.egl.EGL; -import jogamp.opengl.egl.EGLDisplayUtil; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; -- cgit v1.2.3 From 55e897e9b4484a6770a58c7943361663bb2355e4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 7 Nov 2013 06:22:52 +0100 Subject: Android: Add NewtDebugActivity --- make/resources/android/AndroidManifest-jogl.xml | 16 +++- make/resources/android/res-jogl/values/strings.xml | 6 +- .../newt/driver/android/NewtDebugActivity.java | 31 +++++++ .../driver/android/NewtDebugActivityLauncher.java | 21 +++++ .../newt/driver/android/NewtVersionActivity.java | 101 ++++++++++++--------- .../android/NewtVersionActivityLauncher.java | 8 +- 6 files changed, 130 insertions(+), 53 deletions(-) create mode 100644 src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java create mode 100644 src/newt/classes/jogamp/newt/driver/android/NewtDebugActivityLauncher.java (limited to 'src/newt/classes') diff --git a/make/resources/android/AndroidManifest-jogl.xml b/make/resources/android/AndroidManifest-jogl.xml index d88b48fe0..d9a9ac819 100644 --- a/make/resources/android/AndroidManifest-jogl.xml +++ b/make/resources/android/AndroidManifest-jogl.xml @@ -20,8 +20,20 @@ android:finishOnTaskLaunch="true" android:launchMode="singleTop" android:configChanges="keyboardHidden|orientation" - android:label="@string/activity_v_name" - android:description="@string/activity_v_descr" + android:label="@string/activity_version_name" + android:description="@string/activity_version_descr" + > + + + + + + diff --git a/make/resources/android/res-jogl/values/strings.xml b/make/resources/android/res-jogl/values/strings.xml index 3064dad88..ae4816665 100644 --- a/make/resources/android/res-jogl/values/strings.xml +++ b/make/resources/android/res-jogl/values/strings.xml @@ -3,6 +3,8 @@ Jogl Library JogAmp\'s Jogl Library Contains Dalvik and native code, supporting native bindings. - Jogl\'s Version - Shows the version of the JOGL Library and runtime GL infos. + Jogl\'s Version + Shows the version of the JOGL Library and runtime GL infos. + Jogl Debug + Debug output of JOGL\'s initialization. diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java new file mode 100644 index 000000000..a3d9d90a1 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java @@ -0,0 +1,31 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.driver.android; + +public class NewtDebugActivity extends NewtVersionActivity { +} diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivityLauncher.java b/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivityLauncher.java new file mode 100644 index 000000000..9d16fdec5 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivityLauncher.java @@ -0,0 +1,21 @@ +package jogamp.newt.driver.android; + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.util.Log; + +public class NewtDebugActivityLauncher extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtDebugActivity?sys=com.jogamp.common&sys=javax.media.opengl&pkg=com.jogamp.opengl.test&jogamp.debug=all&nativewindow.debug=all&jogl.debug=all&newt.debug=all"); + final Intent intent = new Intent("org.jogamp.launcher.action.LAUNCH_ACTIVITY_NORMAL", uri); + Log.d(getClass().getSimpleName(), "Launching Activity: "+intent); + startActivity (intent); + + finish(); // done + } +} diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java index 9f6210269..dcf176939 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -50,12 +50,12 @@ public class NewtVersionActivity extends NewtBaseActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + setFullscreenFeature(getWindow(), true); final android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getActivity().getApplicationContext()); getWindow().setContentView(viewGroup); - + final TextView tv = new TextView(getActivity()); final ScrollView scroller = new ScrollView(getActivity()); scroller.addView(tv); @@ -63,47 +63,58 @@ public class NewtVersionActivity extends NewtBaseActivity { final String info1 = VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+JoglVersion.getInstance()+Platform.NEWLINE; Log.d(MD.TAG, info1); - tv.setText(info1); - - // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) - GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); - GLWindow glWindow = GLWindow.create(caps); - glWindow.setUndecorated(true); - glWindow.setSize(32, 32); - glWindow.setPosition(0, 0); - final android.view.View androidGLView = ((WindowDriver)glWindow.getDelegatedWindow()).getAndroidView(); - viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getWidth(), glWindow.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); - registerNEWTWindow(glWindow); - - glWindow.addGLEventListener(new GLEventListener() { - public void init(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); - final StringBuilder sb = new StringBuilder(); - sb.append(JoglVersion.getGLInfo(gl, null, true)).append(Platform.NEWLINE); - sb.append("Requested: ").append(Platform.NEWLINE); - sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); - sb.append("Chosen: ").append(Platform.NEWLINE); - sb.append(drawable.getChosenGLCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); - final String info2 = sb.toString(); - // Log.d(MD.TAG, info2); // too big! - System.err.println(info2); - viewGroup.post(new Runnable() { - public void run() { - tv.append(info2); - viewGroup.removeView(androidGLView); - } } ); - } + tv.setText(info1); + + final GLProfile glp; + if( GLProfile.isAvailable(GLProfile.GL2ES2) ) { + glp = GLProfile.get(GLProfile.GL2ES2); + } else if( GLProfile.isAvailable(GLProfile.GL2ES1) ) { + glp = GLProfile.get(GLProfile.GL2ES1); + } else { + glp = null; + tv.append("No GLProfile GL2ES2 nor GL2ES1 available!"); + } + if( null != glp ) { + // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) + GLCapabilities caps = new GLCapabilities(glp); + GLWindow glWindow = GLWindow.create(caps); + glWindow.setUndecorated(true); + glWindow.setSize(32, 32); + glWindow.setPosition(0, 0); + final android.view.View androidGLView = ((WindowDriver)glWindow.getDelegatedWindow()).getAndroidView(); + viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getWidth(), glWindow.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); + registerNEWTWindow(glWindow); + + glWindow.addGLEventListener(new GLEventListener() { + public void init(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); + final StringBuilder sb = new StringBuilder(); + sb.append(JoglVersion.getGLInfo(gl, null, true)).append(Platform.NEWLINE); + sb.append("Requested: ").append(Platform.NEWLINE); + sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); + sb.append("Chosen: ").append(Platform.NEWLINE); + sb.append(drawable.getChosenGLCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); + final String info2 = sb.toString(); + // Log.d(MD.TAG, info2); // too big! + System.err.println(info2); + viewGroup.post(new Runnable() { + public void run() { + tv.append(info2); + viewGroup.removeView(androidGLView); + } } ); + } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + } - public void display(GLAutoDrawable drawable) { - } + public void display(GLAutoDrawable drawable) { + } - public void dispose(GLAutoDrawable drawable) { - } - }); - glWindow.setVisible(true); + public void dispose(GLAutoDrawable drawable) { + } + }); + glWindow.setVisible(true); + } Log.d(MD.TAG, "onCreate - X"); - } + } } diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java index 9b3c6e24b..3374e4184 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java @@ -10,12 +10,12 @@ public class NewtVersionActivityLauncher extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtVersionActivity?sys=com.jogamp.common&sys=javax.media.opengl&pkg=com.jogamp.opengl.test"); - final Intent intent = new Intent("org.jogamp.launcher.action.LAUNCH_ACTIVITY_NORMAL", uri); + final Intent intent = new Intent("org.jogamp.launcher.action.LAUNCH_ACTIVITY_NORMAL", uri); Log.d(getClass().getSimpleName(), "Launching Activity: "+intent); startActivity (intent); - + finish(); // done - } + } } -- cgit v1.2.3 From 46209e7fc903ae14ee2b0a0f443b08b68ebd53c4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 7 Nov 2013 08:37:44 +0100 Subject: Android Newt[Debug|Version]Activity: Separate both activities (testing odd reusing of app) --- .../newt/driver/android/NewtDebugActivity.java | 9 +- .../newt/driver/android/NewtVersionActivity.java | 87 +-------------- .../driver/android/NewtVersionBaseActivity.java | 120 +++++++++++++++++++++ 3 files changed, 130 insertions(+), 86 deletions(-) create mode 100644 src/newt/classes/jogamp/newt/driver/android/NewtVersionBaseActivity.java (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java index a3d9d90a1..40a6ec6dc 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java @@ -27,5 +27,12 @@ */ package jogamp.newt.driver.android; -public class NewtDebugActivity extends NewtVersionActivity { +import android.os.Bundle; + +public class NewtDebugActivity extends NewtVersionBaseActivity { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate("NewtDebugActivity - DEBUG MODE", savedInstanceState); + } } diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java index dcf176939..8a7f3af87 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java @@ -27,94 +27,11 @@ */ package jogamp.newt.driver.android; -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; - -import com.jogamp.common.GlueGenVersion; -import com.jogamp.common.os.Platform; -import com.jogamp.common.util.VersionUtil; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.JoglVersion; - import android.os.Bundle; -import android.util.Log; -import android.view.Gravity; -import android.view.ViewGroup.LayoutParams; -import android.widget.ScrollView; -import android.widget.TextView; -public class NewtVersionActivity extends NewtBaseActivity { +public class NewtVersionActivity extends NewtVersionBaseActivity { @Override public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setFullscreenFeature(getWindow(), true); - - final android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getActivity().getApplicationContext()); - getWindow().setContentView(viewGroup); - - final TextView tv = new TextView(getActivity()); - final ScrollView scroller = new ScrollView(getActivity()); - scroller.addView(tv); - viewGroup.addView(scroller, new android.widget.FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.TOP|Gravity.LEFT)); - - final String info1 = VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+JoglVersion.getInstance()+Platform.NEWLINE; - Log.d(MD.TAG, info1); - tv.setText(info1); - - final GLProfile glp; - if( GLProfile.isAvailable(GLProfile.GL2ES2) ) { - glp = GLProfile.get(GLProfile.GL2ES2); - } else if( GLProfile.isAvailable(GLProfile.GL2ES1) ) { - glp = GLProfile.get(GLProfile.GL2ES1); - } else { - glp = null; - tv.append("No GLProfile GL2ES2 nor GL2ES1 available!"); - } - if( null != glp ) { - // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) - GLCapabilities caps = new GLCapabilities(glp); - GLWindow glWindow = GLWindow.create(caps); - glWindow.setUndecorated(true); - glWindow.setSize(32, 32); - glWindow.setPosition(0, 0); - final android.view.View androidGLView = ((WindowDriver)glWindow.getDelegatedWindow()).getAndroidView(); - viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getWidth(), glWindow.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); - registerNEWTWindow(glWindow); - - glWindow.addGLEventListener(new GLEventListener() { - public void init(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); - final StringBuilder sb = new StringBuilder(); - sb.append(JoglVersion.getGLInfo(gl, null, true)).append(Platform.NEWLINE); - sb.append("Requested: ").append(Platform.NEWLINE); - sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); - sb.append("Chosen: ").append(Platform.NEWLINE); - sb.append(drawable.getChosenGLCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); - final String info2 = sb.toString(); - // Log.d(MD.TAG, info2); // too big! - System.err.println(info2); - viewGroup.post(new Runnable() { - public void run() { - tv.append(info2); - viewGroup.removeView(androidGLView); - } } ); - } - - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } - - public void display(GLAutoDrawable drawable) { - } - - public void dispose(GLAutoDrawable drawable) { - } - }); - glWindow.setVisible(true); - } - Log.d(MD.TAG, "onCreate - X"); + super.onCreate("NewtVersionActivity - NORMAL MODE", savedInstanceState); } } diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionBaseActivity.java new file mode 100644 index 000000000..f24fb20ac --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionBaseActivity.java @@ -0,0 +1,120 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.driver.android; + +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import com.jogamp.common.GlueGenVersion; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.VersionUtil; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.JoglVersion; + +import android.os.Bundle; +import android.util.Log; +import android.view.Gravity; +import android.view.ViewGroup.LayoutParams; +import android.widget.ScrollView; +import android.widget.TextView; + +public class NewtVersionBaseActivity extends NewtBaseActivity { + + public void onCreate(String prefix, Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setFullscreenFeature(getWindow(), true); + + final android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getActivity().getApplicationContext()); + getWindow().setContentView(viewGroup); + + final TextView tv = new TextView(getActivity()); + final ScrollView scroller = new ScrollView(getActivity()); + scroller.addView(tv); + viewGroup.addView(scroller, new android.widget.FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.TOP|Gravity.LEFT)); + + final String info1 = prefix+Platform.NEWLINE+VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+JoglVersion.getInstance()+Platform.NEWLINE; + Log.d(MD.TAG, info1); + tv.setText(info1); + + final GLProfile glp; + if( GLProfile.isAvailable(GLProfile.GL2ES2) ) { + glp = GLProfile.get(GLProfile.GL2ES2); + } else if( GLProfile.isAvailable(GLProfile.GL2ES1) ) { + glp = GLProfile.get(GLProfile.GL2ES1); + } else { + glp = null; + tv.append("No GLProfile GL2ES2 nor GL2ES1 available!"); + } + if( null != glp ) { + // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) + GLCapabilities caps = new GLCapabilities(glp); + GLWindow glWindow = GLWindow.create(caps); + glWindow.setUndecorated(true); + glWindow.setSize(32, 32); + glWindow.setPosition(0, 0); + final android.view.View androidGLView = ((WindowDriver)glWindow.getDelegatedWindow()).getAndroidView(); + viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getWidth(), glWindow.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); + registerNEWTWindow(glWindow); + + glWindow.addGLEventListener(new GLEventListener() { + public void init(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); + final StringBuilder sb = new StringBuilder(); + sb.append(JoglVersion.getGLInfo(gl, null, true)).append(Platform.NEWLINE); + sb.append("Requested: ").append(Platform.NEWLINE); + sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); + sb.append("Chosen: ").append(Platform.NEWLINE); + sb.append(drawable.getChosenGLCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); + final String info2 = sb.toString(); + // Log.d(MD.TAG, info2); // too big! + System.err.println(info2); + viewGroup.post(new Runnable() { + public void run() { + tv.append(info2); + viewGroup.removeView(androidGLView); + } } ); + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + } + + public void display(GLAutoDrawable drawable) { + } + + public void dispose(GLAutoDrawable drawable) { + } + }); + glWindow.setVisible(true); + } + Log.d(MD.TAG, "onCreate - X"); + } +} -- cgit v1.2.3 From 937b29bc3b3d33d2928956ceacbfe55ef77346de Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 13 Nov 2013 17:53:57 +0100 Subject: NEWT: Add more documentation to WindowImpl's doPointerEvent(..) and consumePointerEvent(..) impl. details --- src/newt/classes/jogamp/newt/WindowImpl.java | 55 +++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 9 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 77c19ae05..246c288d0 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2416,6 +2416,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * using a hash-map if normalPNames is false. * Otherwise a simple int to short type cast is performed. *

                      + *

                      + * See {@link #doPointerEvent(boolean, boolean, PointerType[], short, int, int, short[], int[], int[], float[], float, float[], float)} + * for details! + *

                      * * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. @@ -2469,11 +2473,29 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** - * Send multiple-pointer event either to be directly consumed or to be enqueued + * Send multiple-pointer event either to be directly consumed or to be enqueued. + *

                      + * Pointer/Mouse Processing Pass 1 (Pass 2 is performed in {@link #consumePointerEvent(MouseEvent)}. + *

                      + *

                      + * Usually directly called by event source to enqueue and process event. + *

                      *

                      * The index for the element of multiple-pointer arrays represents the pointer which triggered the event * is passed via actionIdx. *

                      + *

                      + *

                        + *
                      • Determine ENTERED/EXITED state
                      • + *
                      • Remove redundant move/drag events
                      • + *
                      • Reset states if applicable
                      • + *
                      • Drop exterior events
                      • + *
                      • Determine CLICK COUNT
                      • + *
                      • Ignore sent CLICKED
                      • + *
                      • Track buttonPressed incl. buttonPressedMask
                      • + *
                      • Synthesize DRAGGED event (from MOVED if pointer is pressed)
                      • + *
                      + *

                      * * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. @@ -2584,6 +2606,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + // + // Drop exterior events + // if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { if(DEBUG_MOUSE_EVENT) { System.err.println("doPointerEvent: drop: "+MouseEvent.getEventTypeString(eventType)+ @@ -2614,7 +2639,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // - Determine CLICK COUNT // - Ignore sent CLICKED // - Track buttonPressed incl. buttonPressedMask - // - Fix MOVED/DRAGGED event + // - Synthesize DRAGGED event (from MOVED if pointer is pressed) // final MouseEvent e; switch( eventType ) { @@ -2795,13 +2820,22 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** - * Consume the {@link MouseEvent}, i.e. - *
                      -     *   - validate
                      -     *   - handle gestures
                      -     *   - synthesize events if applicable (like gestures)
                      -     *   - dispatch event to listener
                      -     * 
                      + * Consume the {@link MouseEvent}. + *

                      + * Pointer/Mouse Processing Pass 2 (Pass 1 is performed in {@link #doPointerEvent(boolean, boolean, PointerType[], short, int, int, short[], int[], int[], float[], float, float[], float)}). + *

                      + *

                      + * Invoked before dispatching the dequeued event. + *

                      + *

                      + *

                        + *
                      • Validate
                      • + *
                      • Handle gestures
                      • + *
                      • Synthesize events ENTERED, CLICK and gestures.
                      • + *
                      • Drop exterior events
                      • + *
                      • Dispatch event to listener
                      • + *
                      + *

                      */ protected void consumePointerEvent(MouseEvent pe) { int x = pe.getX(); @@ -2845,6 +2879,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } dispatchMouseEvent(eEntered); } else if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { + // + // Drop exterior events + // if(DEBUG_MOUSE_EVENT) { System.err.println("consumePointerEvent.drop: "+pe); } -- cgit v1.2.3 From 88f6e0012b36ca69dedaadb4e403e2a424b20cbf Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 17 Nov 2013 01:54:32 +0100 Subject: Bug 903 - NEWT: Support 'Continue Drag on Exit'; Consistent Mouse ENTER/EXIT - Support 'Continue Drag on Exit' - Track dragging operation, allow exterior dragging - Hence track EXIT (see below) - Windows: - Capture mouse for exterior dragging - Only 'NewtWindows_trackPointerLeave' if 'entering' - Simplify touch: No 'inside' check - Not required. - Consistent Mouse ENTER/EXIT - Track ENTER/EXIT and synthesize if required, drop duplicate - OSX benefits, since it never produced ENTER/EXIT events - AWT (or other TK) translated events beahve equal now. - Required for EXIT event after ending exterior dragging and final RELEASE Tests: Passed unit tests 'junit.run.newt.event' on - GNU/Linux - Windows7 - OSX 10.7 Tested exterior tracking manually w/ NEWT TestGearsES2NEWT and TestGearsES2NewtCanvasAWT: - GNU/Linux - Windows7 (mouse) - Windows8.1 (touch) - OSX 10.7 --- make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64.bat | 1 + make/scripts/tests.sh | 6 +- .../classes/com/jogamp/newt/event/MouseEvent.java | 2 + .../com/jogamp/newt/event/MouseListener.java | 2 + src/newt/classes/jogamp/newt/WindowImpl.java | 236 ++++++++++++++------- src/newt/native/InputEvent.h | 6 + src/newt/native/WindowsWindow.c | 132 ++++++++---- 8 files changed, 263 insertions(+), 126 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 2fd401f00..90e736188 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -24,7 +24,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT %* diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 379bcf323..2227396d3 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -21,6 +21,7 @@ echo CP_ALL %CP_ALL% REM set D_ARGS="" REM set D_ARGS="-Djogl.gljpanel.noverticalflip" +set D_ARGS="-Dnewt.debug.Window.MouseEvent" set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 97e524254..ed3a91f99 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -192,7 +192,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - #D_ARGS="-Dnewt.debug.Window.MouseEvent" + D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -319,7 +319,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -351,7 +351,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT $* # diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 635bdba52..272e4beb0 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -589,7 +589,9 @@ public class MouseEvent extends InputEvent private static final PointerType[] constMousePointerTypes = new PointerType[] { PointerType.Mouse }; public static final short EVENT_MOUSE_CLICKED = 200; + /** Only generated for {@link PointerType#Mouse} */ public static final short EVENT_MOUSE_ENTERED = 201; + /** Only generated for {@link PointerType#Mouse} */ public static final short EVENT_MOUSE_EXITED = 202; public static final short EVENT_MOUSE_PRESSED = 203; public static final short EVENT_MOUSE_RELEASED = 204; diff --git a/src/newt/classes/com/jogamp/newt/event/MouseListener.java b/src/newt/classes/com/jogamp/newt/event/MouseListener.java index 5378080b9..6e5142044 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseListener.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseListener.java @@ -44,7 +44,9 @@ import com.jogamp.newt.event.MouseEvent.PointerType; public interface MouseListener extends NEWTEventListener { public void mouseClicked(MouseEvent e); + /** Only generated for {@link PointerType#Mouse} */ public void mouseEntered(MouseEvent e); + /** Only generated for {@link PointerType#Mouse} */ public void mouseExited(MouseEvent e); public void mousePressed(MouseEvent e); public void mouseReleased(MouseEvent e); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 246c288d0..99e863a0e 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -186,37 +186,45 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** from event passing: {@link WindowImpl#consumePointerEvent(MouseEvent)}. */ private static class PointerState0 { - /** mouse entered window - is inside the window (may be synthetic) */ + /** Pointer entered window - is inside the window (may be synthetic) */ boolean insideWindow = false; + /** Mouse EXIT has been sent (only for MOUSE type enter/exit)*/ + boolean exitSent = false; - /** last time when a mouse button was pressed */ + /** last time when a pointer button was pressed */ long lastButtonPressTime = 0; + /** Pointer in dragging mode */ + boolean dragging = false; + void clearButton() { lastButtonPressTime = 0; } + public String toString() { return "PState0[inside "+insideWindow+", exitSent "+exitSent+", lastPress "+lastButtonPressTime+", dragging "+dragging+"]"; } } private final PointerState0 pState0 = new PointerState0(); /** from direct input: {@link WindowImpl#doPointerEvent(boolean, boolean, int[], short, int, int, boolean, short[], int[], int[], float[], float, float[], float)}. */ private static class PointerState1 extends PointerState0 { - /** current pressed mouse button number */ + /** Current pressed mouse button number */ short buttonPressed = (short)0; - /** current pressed mouse button modifier mask */ + /** Current pressed mouse button modifier mask */ int buttonPressedMask = 0; - /** last mouse button click count */ + /** Last mouse button click count */ short lastButtonClickCount = (short)0; @Override final void clearButton() { super.clearButton(); - lastButtonPressTime = 0; lastButtonClickCount = (short)0; - buttonPressed = 0; - buttonPressedMask = 0; + if( !dragging || 0 == buttonPressedMask ) { + buttonPressed = 0; + buttonPressedMask = 0; + dragging = false; + } } - /** last pointer-move position for 8 touch-down pointers */ + /** Last pointer-move position for 8 touch-down pointers */ final Point[] movePositions = new Point[] { new Point(), new Point(), new Point(), new Point(), new Point(), new Point(), new Point(), new Point() }; @@ -226,10 +234,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } return null; } + public final String toString() { return "PState1[inside "+insideWindow+", exitSent "+exitSent+", lastPress "+lastButtonPressTime+ + ", pressed [button "+buttonPressed+", mask "+buttonPressedMask+", dragging "+dragging+", clickCount "+lastButtonClickCount+"]"; } } private final PointerState1 pState1 = new PointerState1(); - /** pointer names -> pointer ID (consecutive index, starting w/ 0) */ + /** Pointer names -> pointer ID (consecutive index, starting w/ 0) */ private final ArrayHashSet pName2pID = new ArrayHashSet(); private boolean defaultGestureHandlerEnabled = true; @@ -2365,25 +2375,25 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Native MouseEvents pre-processed to be enqueued or consumed directly // - public final void sendMouseEvent(short eventType, int modifiers, - int x, int y, short button, float rotation) { + public final void sendMouseEvent(final short eventType, final int modifiers, + final int x, final int y, final short button, final float rotation) { doMouseEvent(false, false, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } - public final void enqueueMouseEvent(boolean wait, short eventType, int modifiers, - int x, int y, short button, float rotation) { + public final void enqueueMouseEvent(final boolean wait, final short eventType, final int modifiers, + final int x, final int y, final short button, final float rotation) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } - protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, - int x, int y, short button, float rotation) { + protected final void doMouseEvent(final boolean enqueue, final boolean wait, final short eventType, final int modifiers, + final int x, final int y, final short button, final float rotation) { doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } /** - public final void sendMouseEvent(short eventType, int modifiers, - int x, int y, short button, float[] rotationXYZ, float rotationScale) { + public final void sendMouseEvent(final short eventType, final int modifiers, + final int x, final int y, final short button, final float[] rotationXYZ, final float rotationScale) { doMouseEvent(false, false, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); } - public final void enqueueMouseEvent(boolean wait, short eventType, int modifiers, - int x, int y, short button, float[] rotationXYZ, float rotationScale) { + public final void enqueueMouseEvent(final boolean wait, final short eventType, final int modifiers, + final int x, final int y, final short button, final float[] rotationXYZ, final float rotationScale) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); } */ @@ -2394,8 +2404,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. */ - protected void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, - int x, int y, short button, final float[] rotationXYZ, float rotationScale) { + protected void doMouseEvent(final boolean enqueue, final boolean wait, final short eventType, final int modifiers, + final int x, final int y, final short button, final float[] rotationXYZ, final float rotationScale) { if( 0 > button || button > MouseEvent.BUTTON_COUNT ) { throw new NativeWindowException("Invalid mouse button number" + button); } @@ -2437,10 +2447,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param pPressure Pressure for each pointer (multiple pointer) * @param maxPressure Maximum pointer pressure for all pointer */ - public final void doPointerEvent(boolean enqueue, boolean wait, - final PointerType[] pTypes, short eventType, int modifiers, - int actionIdx, boolean normalPNames, final int[] pNames, - final int[] pX, final int[] pY, float[] pPressure, + public final void doPointerEvent(final boolean enqueue, final boolean wait, + final PointerType[] pTypes, final short eventType, final int modifiers, + final int actionIdx, final boolean normalPNames, final int[] pNames, + final int[] pX, final int[] pY, final float[] pPressure, float maxPressure, final float[] rotationXYZ, final float rotationScale) { final int pCount = pNames.length; final short[] pIDs = new short[pCount]; @@ -2511,10 +2521,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param pPressure Pressure for each pointer (multiple pointer) * @param maxPressure Maximum pointer pressure for all pointer */ - public final void doPointerEvent(boolean enqueue, boolean wait, - final PointerType[] pTypes, short eventType, int modifiers, - int pActionIdx, final short[] pID, final int[] pX, final int[] pY, final float[] pPressure, - float maxPressure, final float[] rotationXYZ, float rotationScale) { + public final void doPointerEvent(final boolean enqueue, final boolean wait, + final PointerType[] pTypes, final short eventType, int modifiers, + final int pActionIdx, final short[] pID, final int[] pX, final int[] pY, final float[] pPressure, + final float maxPressure, final float[] rotationXYZ, final float rotationScale) { final long when = System.currentTimeMillis(); final int pCount = pTypes.length; @@ -2565,9 +2575,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // int x = pX[0]; int y = pY[0]; + final boolean insideWindow = x >= 0 && y >= 0 && x < getWidth() && y < getHeight(); final Point movePositionP0 = pState1.getMovePosition(id); switch( eventType ) { case MouseEvent.EVENT_MOUSE_EXITED: + if( pState1.dragging ) { + // Drop mouse EXIT if dragging, i.e. due to exterior dragging outside of window. + // NOTE-1: X11 produces the 'premature' EXIT, however it also produces 'EXIT' after exterior dragging! + // NOTE-2: consumePointerEvent(MouseEvent) will synthesize a missing EXIT event! + if(DEBUG_MOUSE_EVENT) { + System.err.println("doPointerEvent: drop "+MouseEvent.getEventTypeString(eventType)+" due to dragging: "+pState1); + } + return; + } if( null != movePositionP0 ) { if( x==-1 && y==-1 ) { x = movePositionP0.getX(); @@ -2578,21 +2598,35 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Fall through intended! case MouseEvent.EVENT_MOUSE_ENTERED: + if( eventType == MouseEvent.EVENT_MOUSE_ENTERED ) { + pState1.insideWindow = true; + pState1.exitSent = false; + } else { + pState1.insideWindow = false; + pState1.exitSent = true; + } + pState1.clearButton(); + if( pTypes[0] != PointerType.Mouse ) { + // Drop !MOUSE ENTER/EXIT Events - Safeguard for non compliant implementations only. + if(DEBUG_MOUSE_EVENT) { + System.err.println("doPointerEvent: drop "+MouseEvent.getEventTypeString(eventType)+" due to !Mouse but "+pTypes[0]+": "+pState1); + } + return; + } // clip coordinates to window dimension x = Math.min(Math.max(x, 0), getWidth()-1); y = Math.min(Math.max(y, 0), getHeight()-1); - pState1.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; - pState1.clearButton(); break; case MouseEvent.EVENT_MOUSE_MOVED: case MouseEvent.EVENT_MOUSE_DRAGGED: if( null != movePositionP0 ) { - if( pState1.insideWindow && movePositionP0.getX() == x && movePositionP0.getY() == y ) { + if( movePositionP0.getX() == x && movePositionP0.getY() == y ) { + // Drop same position if(DEBUG_MOUSE_EVENT) { - System.err.println("doPointerEvent: skip "+MouseEvent.getEventTypeString(eventType)+" w/ same position: "+movePositionP0); + System.err.println("doPointerEvent: drop "+MouseEvent.getEventTypeString(eventType)+" w/ same position: "+movePositionP0+", "+pState1); } - return; // skip same position + return; } movePositionP0.set(x, y); } @@ -2600,25 +2634,30 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Fall through intended ! default: - if(!pState1.insideWindow) { - pState1.insideWindow = true; + if( pState1.insideWindow != insideWindow ) { + // ENTER/EXIT! + pState1.insideWindow = insideWindow; + if( insideWindow ) { + pState1.exitSent = false; + } pState1.clearButton(); } } // - // Drop exterior events + // Drop exterior events if not dragging pointer and not EXIT event + // Safeguard for non compliant implementations! // - if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { + if( !pState1.dragging && !insideWindow && MouseEvent.EVENT_MOUSE_EXITED != eventType ) { if(DEBUG_MOUSE_EVENT) { System.err.println("doPointerEvent: drop: "+MouseEvent.getEventTypeString(eventType)+ - ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0+", insideWindow "+insideWindow+", "+pState1); } return; // .. invalid .. } if(DEBUG_MOUSE_EVENT) { System.err.println("doPointerEvent: enqueue "+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+ - ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0+", "+pState1); } final int buttonMask = InputEvent.getButtonMask(button); @@ -2668,6 +2707,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } break; case MouseEvent.EVENT_MOUSE_RELEASED: + pState1.buttonPressedMask &= ~buttonMask; if( 1 == pCount ) { e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, pState1.lastButtonClickCount, rotationXYZ, rotationScale); @@ -2676,11 +2716,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer pState1.lastButtonPressTime = 0; } pState1.buttonPressed = 0; + pState1.dragging = false; } else { e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); + if( 0 == pState1.buttonPressedMask ) { + pState1.clearButton(); + } } - pState1.buttonPressedMask &= ~buttonMask; if( null != movePositionP0 ) { movePositionP0.set(0, 0); } @@ -2689,6 +2732,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if ( 0 != pState1.buttonPressedMask ) { // any button or pointer move -> drag e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, pState1.buttonPressed, (short)1, rotationXYZ, rotationScale); + pState1.dragging = true; } else { e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)0, rotationXYZ, rotationScale); @@ -2698,6 +2742,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( 0 >= pPressure[0] ) { pPressure[0] = maxPressure; } + pState1.dragging = true; // Fall through intended! default: e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, @@ -2831,7 +2876,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer *
                        *
                      • Validate
                      • *
                      • Handle gestures
                      • - *
                      • Synthesize events ENTERED, CLICK and gestures.
                      • + *
                      • Synthesize events [ENTERED, EXIT, CLICK] and gestures.
                      • *
                      • Drop exterior events
                      • *
                      • Dispatch event to listener
                      • *
                      @@ -2842,50 +2887,84 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int y = pe.getY(); if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.in: "+pe); + System.err.println("consumePointerEvent.in: "+pe+", "+pState0+", pos "+x+"/"+y+" clientSize["+getWidth()+"x"+getHeight()+"]"); } // // - Determine ENTERED/EXITED state - // - Synthesize ENTERED event + // - Synthesize ENTERED and EXIT event // - Reset states if applicable // final long when = pe.getWhen(); - int eventType = pe.getEventType(); - final MouseEvent eEntered; + final int eventType = pe.getEventType(); + final boolean insideWindow; + boolean eExitAllowed = false; + MouseEvent eEntered = null, eExited = null; switch( eventType ) { case MouseEvent.EVENT_MOUSE_EXITED: + if( pState0.exitSent || pState0.dragging ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumePointerEvent: drop "+(pState0.exitSent?"already sent":"due to dragging")+": "+pe+", "+pState0); + } + return; + } + // Fall through intended ! case MouseEvent.EVENT_MOUSE_ENTERED: // clip coordinates to window dimension x = Math.min(Math.max(x, 0), getWidth()-1); y = Math.min(Math.max(y, 0), getHeight()-1); - pState0.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; pState0.clearButton(); - eEntered = null; + if( eventType == MouseEvent.EVENT_MOUSE_ENTERED ) { + insideWindow = true; + pState0.insideWindow = true; + pState0.exitSent = false; + pState0.dragging = false; + } else { + insideWindow = false; + pState0.insideWindow = false; + pState0.exitSent = true; + } break; + case MouseEvent.EVENT_MOUSE_MOVED: + case MouseEvent.EVENT_MOUSE_RELEASED: + if( 1 >= pe.getButtonDownCount() ) { // MOVE or RELEASE last button + eExitAllowed = !pState0.exitSent; + pState0.dragging = false; + } + // Fall through intended ! + default: - if(!pState0.insideWindow) { - pState0.insideWindow = true; + insideWindow = x >= 0 && y >= 0 && x < getWidth() && y < getHeight(); + if( pe.getPointerType(0) == PointerType.Mouse ) { + if( !pState0.insideWindow && insideWindow ) { + // ENTER .. use clipped coordinates + eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, pe.getSource(), pe.getWhen(), pe.getModifiers(), + Math.min(Math.max(x, 0), getWidth()-1), + Math.min(Math.max(y, 0), getHeight()-1), + (short)0, (short)0, pe.getRotation(), pe.getRotationScale()); + pState0.exitSent = false; + } else if( !insideWindow && eExitAllowed ) { + // EXIT .. use clipped coordinates + eExited = new MouseEvent(MouseEvent.EVENT_MOUSE_EXITED, pe.getSource(), pe.getWhen(), pe.getModifiers(), + Math.min(Math.max(x, 0), getWidth()-1), + Math.min(Math.max(y, 0), getHeight()-1), + (short)0, (short)0, pe.getRotation(), pe.getRotationScale()); + pState0.exitSent = true; + } + } + if( pState0.insideWindow != insideWindow || null != eEntered || null != eExited) { pState0.clearButton(); - eEntered = pe.createVariant(MouseEvent.EVENT_MOUSE_ENTERED); - } else { - eEntered = null; } + pState0.insideWindow = insideWindow; } if( null != eEntered ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.send.0: "+eEntered); + System.err.println("consumePointerEvent.send.0: "+eEntered+", "+pState0); } dispatchMouseEvent(eEntered); - } else if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { - // - // Drop exterior events - // - if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.drop: "+pe); - } - return; // .. invalid .. + } else if( DEBUG_MOUSE_EVENT && !insideWindow ) { + System.err.println("INFO consumePointerEvent.exterior: "+pState0+", "+pe); } // @@ -2906,7 +2985,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer scaledScrollSlop = Math.round(DoubleTapScrollGesture.SCROLL_SLOP_MM * pixPerMM); scaledDoubleTapSlop = Math.round(DoubleTapScrollGesture.DOUBLE_TAP_SLOP_MM * pixPerMM); if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.gscroll: scrollSlop "+scaledScrollSlop+", doubleTapSlop "+scaledDoubleTapSlop+", pixPerMM "+pixPerMM+", "+monitor); + System.err.println("consumePointerEvent.gscroll: scrollSlop "+scaledScrollSlop+", doubleTapSlop "+scaledDoubleTapSlop+", pixPerMM "+pixPerMM+", "+monitor+", "+pState0); } } else { scaledScrollSlop = DoubleTapScrollGesture.SCROLL_SLOP_PIXEL; @@ -2919,7 +2998,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer pe = (MouseEvent) gesture2PtrTouchScroll.getGestureEvent(); gesture2PtrTouchScroll.clear(false); if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.gscroll: "+pe); + System.err.println("consumePointerEvent.gscroll: "+pe+", "+pState0); } dispatchMouseEvent(pe); return; @@ -2962,46 +3041,51 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // - Synthesize mouse CLICKED // - Ignore sent CLICKED // - final MouseEvent eClicked; + MouseEvent eClicked = null; switch( eventType ) { case MouseEvent.EVENT_MOUSE_PRESSED: if( 1 == pe.getPointerCount() ) { pState0.lastButtonPressTime = when; } - eClicked = null; break; case MouseEvent.EVENT_MOUSE_RELEASED: if( 1 == pe.getPointerCount() && when - pState0.lastButtonPressTime < MouseEvent.getClickTimeout() ) { eClicked = pe.createVariant(MouseEvent.EVENT_MOUSE_CLICKED); } else { - eClicked = null; pState0.lastButtonPressTime = 0; } break; case MouseEvent.EVENT_MOUSE_CLICKED: // ignore - synthesized here .. if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent: drop recv'ed (synth here) "+pe); + System.err.println("consumePointerEvent: drop recv'ed (synth here) "+pe+", "+pState0); } pe = null; - eClicked = null; break; - default: - eClicked = null; + + case MouseEvent.EVENT_MOUSE_DRAGGED: + pState0.dragging = true; + break; } if( null != pe ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.send.1: "+pe); + System.err.println("consumePointerEvent.send.1: "+pe+", "+pState0); } dispatchMouseEvent(pe); // actual mouse event } if( null != eClicked ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.send.2: "+eClicked); + System.err.println("consumePointerEvent.send.2: "+eClicked+", "+pState0); } dispatchMouseEvent(eClicked); } + if( null != eExited ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumePointerEvent.send.3: "+eExited+", "+pState0); + } + dispatchMouseEvent(eExited); + } } private final void dispatchMouseEvent(MouseEvent e) { @@ -3205,11 +3289,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // @Override public void sendWindowEvent(int eventType) { - consumeWindowEvent( new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); // FIXME + consumeWindowEvent( new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); } public void enqueueWindowEvent(boolean wait, int eventType) { - enqueueEvent( wait, new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); // FIXME + enqueueEvent( wait, new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); } @Override diff --git a/src/newt/native/InputEvent.h b/src/newt/native/InputEvent.h index 3fa7dbefe..2de46f82e 100644 --- a/src/newt/native/InputEvent.h +++ b/src/newt/native/InputEvent.h @@ -50,6 +50,12 @@ #define EVENT_BUTTON8_MASK (1 << 12) #define EVENT_BUTTON9_MASK (1 << 13) +/** 16 buttons */ +#define EVENT_BUTTONLAST_MASK (1 << 20) + +/** 16 buttons */ +#define EVENT_BUTTONALL_MASK ( 0xffff << 5 ) + #define EVENT_AUTOREPEAT_MASK (1 << 29) #define EVENT_CONFINED_MASK (1 << 30) #define EVENT_INVISIBLE_MASK (1 << 31) diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 884e538d3..692bb9d4f 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -186,7 +186,8 @@ typedef struct { int height; /** Tristate: -1 HIDE, 0 NOP, 1 SHOW */ int setPointerVisible; - int mouseInside; + int pointerCaptured; + int pointerInside; int touchDownCount; int touchDownLastUp; // mitigate LBUTTONUP after last TOUCH lift int supportsMTouch; @@ -985,11 +986,14 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP case WM_LBUTTONDOWN: { - DBG_PRINT("*** WindowsWindow: WM_LBUTTONDOWN %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_LBUTTONDOWN %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownLastUp && 0 == wud->touchDownCount ) { - wud->mouseInside = 1; + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED, @@ -1002,14 +1006,22 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_LBUTTONUP: { - DBG_PRINT("*** WindowsWindow: WM_LBUTTONUP %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_LBUTTONUP %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 < wud->touchDownLastUp ) { // mitigate LBUTTONUP after last TOUCH lift wud->touchDownLastUp = 0; } else if( 0 == wud->touchDownCount ) { - wud->mouseInside = 1; + jint modifiers = GetModifiers(0); + if( wud->pointerCaptured && 0 == ( modifiers & EVENT_BUTTONALL_MASK ) ) { + wud->pointerCaptured = 0; + ReleaseCapture(); + } + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, GetModifiers( 0 ), @@ -1021,11 +1033,14 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_MBUTTONDOWN: { - DBG_PRINT("*** WindowsWindow: WM_MBUTTONDOWN %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_MBUTTONDOWN %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownCount ) { - wud->mouseInside = 1; + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED, @@ -1038,11 +1053,19 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_MBUTTONUP: { - DBG_PRINT("*** WindowsWindow: WM_MBUTTONUP %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_MBUTTONUP %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownCount ) { - wud->mouseInside = 1; + jint modifiers = GetModifiers(0); + if( wud->pointerCaptured && 0 == ( modifiers & EVENT_BUTTONALL_MASK ) ) { + wud->pointerCaptured = 0; + ReleaseCapture(); + } + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, GetModifiers( 0 ), @@ -1054,11 +1077,14 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_RBUTTONDOWN: { - DBG_PRINT("*** WindowsWindow: WM_RBUTTONDOWN %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_RBUTTONDOWN %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownCount ) { - wud->mouseInside = 1; + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED, @@ -1071,11 +1097,19 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_RBUTTONUP: { - DBG_PRINT("*** WindowsWindow: WM_RBUTTONUP %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_RBUTTONUP %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownCount ) { - wud->mouseInside = 1; + jint modifiers = GetModifiers(0); + if( wud->pointerCaptured && 0 == ( modifiers & EVENT_BUTTONALL_MASK ) ) { + wud->pointerCaptured = 0; + ReleaseCapture(); + } + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, GetModifiers( 0 ), @@ -1087,15 +1121,22 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_MOUSEMOVE: { - DBG_PRINT("*** WindowsWindow: WM_MOUSEMOVE %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_MOUSEMOVE %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownLastUp && 0 == wud->touchDownCount ) { - wud->mouseInside = 1; - NewtWindows_trackPointerLeave(wnd); + jint modifiers = GetModifiers(0); + if( 0 == wud->pointerCaptured && 0 != ( modifiers & EVENT_BUTTONALL_MASK ) ) { + wud->pointerCaptured = 1; + SetCapture(wnd); + } + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED, - GetModifiers( 0 ), + modifiers, (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jshort) 0, (jfloat) 0.0f); } @@ -1103,11 +1144,11 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP } break; case WM_MOUSELEAVE: { - DBG_PRINT("*** WindowsWindow: WM_MOUSELEAVE %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_MOUSELEAVE %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownCount ) { - wud->mouseInside = 0; + wud->pointerInside = 0; (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_EXITED, 0, @@ -1203,7 +1244,6 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP int isPrim = pTi->dwFlags & TOUCHEVENTF_PRIMARY; int isNoCoalesc = pTi->dwFlags & TOUCHEVENTF_NOCOALESCE; - int isPInside; #ifdef VERBOSE_ON const char * touchAction; @@ -1223,8 +1263,8 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP eventPt.y = TOUCH_COORD_TO_PIXEL(pTi->y); ScreenToClient(wnd, &eventPt); - isPInside = 0 <= eventPt.x && 0 <= eventPt.y && eventPt.x < wud->width && eventPt.y < wud->height; - allPInside &= isPInside; + int pInside = 0 <= eventPt.x && 0 <= eventPt.y && eventPt.x < wud->width && eventPt.y < wud->height; + allPInside &= pInside; x[i] = (jint)eventPt.x; y[i] = (jint)eventPt.y; @@ -1252,16 +1292,16 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP #ifdef VERBOSE_ON DBG_PRINT("*** WindowsWindow: WM_TOUCH[%d/%d].%s name 0x%x, prim %d, nocoalsc %d, %d/%d [%dx%d] inside [%d/%d], tDown [c %d, lastUp %d]\n", (i+1), cInputs, touchAction, (int)(pTi->dwID), isPrim, isNoCoalesc, x[i], y[i], wud->width, wud->height, - isPInside, allPInside, wud->touchDownCount, wud->touchDownLastUp); + pInside, allPInside, wud->touchDownCount, wud->touchDownLastUp); #endif } - wud->mouseInside = allPInside; - if( sendFocus && allPInside ) { + wud->pointerInside = allPInside; + if( sendFocus ) { (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); } int sentCount = 0, updownCount=0, moveCount=0; // Primary first, if available! - if( 0 <= actionIdx && allPInside ) { + if( 0 <= actionIdx ) { sendTouchScreenEvent(env, window, eventType[actionIdx], modifiers, actionIdx, cInputs, pointerNames, x, y, pressure, maxPressure); sentCount++; @@ -1270,7 +1310,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP for (i=0; i < cInputs; i++) { short et = eventType[i]; if( (jshort) EVENT_MOUSE_MOVED == et ) { - if( i != actionIdx && 0 == moveCount && allPInside ) { + if( i != actionIdx && 0 == moveCount ) { sendTouchScreenEvent(env, window, et, modifiers, i, cInputs, pointerNames, x, y, pressure, maxPressure); sentCount++; @@ -1282,7 +1322,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP for (i=0; i < cInputs; i++) { short et = eventType[i]; if( (jshort) EVENT_MOUSE_MOVED != et ) { - if( i != actionIdx && allPInside ) { + if( i != actionIdx ) { sendTouchScreenEvent(env, window, et, modifiers, i, cInputs, pointerNames, x, y, pressure, maxPressure); sentCount++; @@ -1290,8 +1330,8 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP updownCount++; } } - DBG_PRINT("*** WindowsWindow: WM_TOUCH.summary pCount %d, prim %d, updown %d, move %d, sent %d, inside %d, tDown [c %d, lastUp %d]\n", - cInputs, actionIdx, updownCount, moveCount, sentCount, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + DBG_PRINT("*** WindowsWindow: WM_TOUCH.summary pCount %d, prim %d, updown %d, move %d, sent %d, inside %d, captured %d, tDown [c %d, lastUp %d]\n", + cInputs, actionIdx, updownCount, moveCount, sentCount, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); // Message processed - close it WinTouch_CloseTouchInputHandle(hTouch); @@ -1310,10 +1350,14 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_KILLFOCUS: - DBG_PRINT("*** WindowsWindow: WM_KILLFOCUS window %p, received %p, inside %d, tDown %d\n", - wnd, (HWND)wParam, wud->mouseInside, wud->touchDownCount); + DBG_PRINT("*** WindowsWindow: WM_KILLFOCUS window %p, received %p, inside %d, captured %d, tDown %d\n", + wnd, (HWND)wParam, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount); if( wud->touchDownCount == 0 ) { - wud->mouseInside=0; + wud->pointerInside = 0; + if( wud->pointerCaptured ) { + wud->pointerCaptured = 0; + ReleaseCapture(); + } (*env)->CallVoidMethod(env, window, focusChangedID, JNI_FALSE, JNI_FALSE); useDefWindowProc = 1; } else { @@ -1963,7 +2007,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo wud->width = width; wud->height = height; wud->setPointerVisible = 0; - wud->mouseInside = 0; + wud->pointerCaptured = 0; + wud->pointerInside = 0; wud->touchDownCount = 0; wud->touchDownLastUp = 0; wud->supportsMTouch = 0; @@ -2214,12 +2259,9 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_confineP jboolean res; if(JNI_TRUE == confine) { - // SetCapture(hwnd); - // res = ( GetCapture() == hwnd ) ? JNI_TRUE : JNI_FALSE; RECT rect = { l, t, r, b }; res = ClipCursor(&rect) ? JNI_TRUE : JNI_FALSE; } else { - // res = ReleaseCapture() ? JNI_TRUE : JNI_FALSE; res = ClipCursor(NULL) ? JNI_TRUE : JNI_FALSE; } DBG_PRINT( "*** WindowsWindow: confinePointer0: %d, [ l %d t %d r %d b %d ], res %d\n", -- cgit v1.2.3 From 0be87f241c0f0b2f5881d9a602ce12378b8e453d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 17 Nov 2013 04:55:33 +0100 Subject: Fix Bug 879 - Threads deadlock in native keyboardfocus calls made form multiple threads; Fix Bug 892: Reduce Focus Hopping Since we manage focus key traversal ourselves w/o requiring the AWT component to have the focus[1], we simply can drop requesting the focus for 'focus hopping' NEWT -> AWT -> NEWT[2]. Further more, 'MenuSelectionManager.defaultManager().clearSelectedPath()' must be performed on AWT-EDT w/o blocking. Otherwise it may perform blocking tasks on AWT-EDT. [1] Commit cb7118fc875b6722803e4b11d5681671962a8d3a introduced function to query the next or previous 'to be focused' component: AWTMisc.getNextFocus(..) .. etc. [2] Focus hopping is also addressed in Bug 892 --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests.sh | 8 ++++---- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 23 +++++++++++----------- 3 files changed, 17 insertions(+), 18 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 90e736188..8008e959f 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -139,7 +139,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslu REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ed3a91f99..aab20980d 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -192,14 +192,14 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - D_ARGS="-Dnewt.debug.Window.MouseEvent" + #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -319,7 +319,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -610,7 +610,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* # # Misc Utils diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 70157fe4b..9611cc960 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -190,23 +190,22 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println("NewtCanvasAWT.FocusAction: "+Display.getThreadName()+", isOnscreen "+isOnscreen+", hasFocus "+hasFocus()+", isParent "+isParent+", isFS "+isFullscreen); } - if(isParent && !isFullscreen) { - // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. - if(!hasFocus()) { - // Acquire the AWT focus 1st for proper AWT traversal - NewtCanvasAWT.super.requestFocus(); - } - if(isOnscreen) { - // Remove the AWT focus in favor of the native NEWT focus - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); - } + if( isParent && !isFullscreen && isOnscreen ) { + // Remove the AWT focus in favor of the native NEWT focus + KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); } return false; // NEWT shall proceed requesting the native focus } } private final FocusAction focusAction = new FocusAction(); - WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() { + /** Must run on AWT-EDT non-blocking, since it invokes tasks on AWT-EDT w/ waiting otherwise. */ + private final Runnable awtClearSelectedMenuPath = new Runnable() { + public void run() { + MenuSelectionManager.defaultManager().clearSelectedPath(); + } + }; + private final WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() { @Override public void windowResized(WindowEvent e) { updateLayoutSize(); @@ -214,7 +213,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public void windowGainedFocus(WindowEvent arg0) { if( isParent() && !isFullscreen() ) { - MenuSelectionManager.defaultManager().clearSelectedPath(); + AWTEDTExecutor.singleton.invoke(false, awtClearSelectedMenuPath); } } }; -- cgit v1.2.3 From 23697c7921039e9655a5760e21d7029598b679d7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 01:11:15 +0100 Subject: Fix Bug 879 Regression (2/2) - NewtCanvasAWT.FocusAction must take focus when in offscreen-mode (OSX/CALayer) NewtCanvasAWT.FocusAction must take focus when in offscreen-mode (OSX/CALayer) since the NEWT window _is_ offscreen (no input events) and AWT events are translated to NEWT. Regression of commit 0be87f241c0f0b2f5881d9a602ce12378b8e453d --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests-x64-dbg.bat | 3 ++- make/scripts/tests-x64.bat | 4 ---- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 14 +++++++++++--- .../parenting/TestParentingFocus03KeyTraversalAWT.java | 10 +++++++++- 5 files changed, 24 insertions(+), 11 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 8008e959f..17362185e 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -13,7 +13,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGea REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* @@ -139,7 +139,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslu REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index a42c79254..822ad0e54 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -51,7 +51,8 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" "-Djogl.debug.TileRenderer.PNG" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" -REM set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Djogl.gljpanel.noverticalflip" +set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 2227396d3..ac74f4c94 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -19,10 +19,6 @@ set LIB_DIR= set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\%BLD_SUB%\joal.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar echo CP_ALL %CP_ALL% -REM set D_ARGS="" -REM set D_ARGS="-Djogl.gljpanel.noverticalflip" -set D_ARGS="-Dnewt.debug.Window.MouseEvent" - set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" scripts\tests-win.bat %* diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 9611cc960..b8de1f596 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -190,9 +190,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println("NewtCanvasAWT.FocusAction: "+Display.getThreadName()+", isOnscreen "+isOnscreen+", hasFocus "+hasFocus()+", isParent "+isParent+", isFS "+isFullscreen); } - if( isParent && !isFullscreen && isOnscreen ) { - // Remove the AWT focus in favor of the native NEWT focus - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + if( isParent && !isFullscreen ) { // must be parent of newtChild _and_ newtChild not fullscreen + if( isOnscreen ) { + // Remove the AWT focus in favor of the native NEWT focus + KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + } else if( !isOnscreen ) { + // In offscreen mode we require the focus! + if( !hasFocus() ) { + // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. + NewtCanvasAWT.super.requestFocus(); + } + } } return false; // NEWT shall proceed requesting the native focus } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java index 1e6cf4a1d..e928b2a34 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java @@ -283,7 +283,15 @@ public class TestParentingFocus03KeyTraversalAWT extends UITestCase { System.err.println("Test: Direct NEWT-Child request focus"); glWindow1.requestFocus(); - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); + { + // Short: Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); + // More verbose: + final boolean ok = AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA); + System.err.println("glWindow hasFocus "+glWindow1.hasFocus()); + System.err.println("glWindow1FA "+glWindow1FA); + System.err.println("bWestFA "+bWestFA); + Assert.assertTrue("Did not gain focus", ok); + } Assert.assertEquals(true, glWindow1FA.focusGained()); Assert.assertEquals(true, bWestFA.focusLost()); Thread.sleep(durationPerTest/numFocus); -- cgit v1.2.3 From 5c6c11abf643013976ecbc0df463a923a1f52696 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 13:01:12 +0100 Subject: NEWT AWTAdapter: Add notion of consuming the AWT InputEvent (will be used for key events); Allow AWTAdapter to be lazily setup w/ downstream object. --- .../com/jogamp/newt/event/awt/AWTAdapter.java | 42 ++++++++- .../com/jogamp/newt/event/awt/AWTKeyAdapter.java | 23 ++++- .../com/jogamp/newt/event/awt/AWTMouseAdapter.java | 48 ++++++++-- .../jogamp/newt/event/awt/AWTWindowAdapter.java | 63 +++++++------ .../newt/awt/event/AWTParentWindowAdapter.java | 102 ++++++++++++--------- .../opengl/test/junit/util/AWTKeyAdapter.java | 35 ++++--- .../opengl/test/junit/util/AWTMouseAdapter.java | 35 ++++--- .../test/junit/util/InputEventCountAdapter.java | 15 +-- .../opengl/test/junit/util/NEWTKeyAdapter.java | 39 +++++--- .../opengl/test/junit/util/NEWTMouseAdapter.java | 33 ++++--- 10 files changed, 285 insertions(+), 150 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java index e3bf18448..977b38dd0 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java @@ -117,17 +117,19 @@ public abstract class AWTAdapter implements java.util.EventListener com.jogamp.newt.event.NEWTEventListener newtListener; com.jogamp.newt.Window newtWindow; + boolean consumeAWTEvent; /** * Simply wrap aroung a NEWT EventListener, exposed as an AWT EventListener.
                      * The NEWT EventListener will be called when an event happens.
                      */ - public AWTAdapter(com.jogamp.newt.event.NEWTEventListener newtListener) { + protected AWTAdapter(com.jogamp.newt.event.NEWTEventListener newtListener) { if(null==newtListener) { throw new RuntimeException("Argument newtListener is null"); } this.newtListener = newtListener; this.newtWindow = null; + this.consumeAWTEvent = false; } /** @@ -135,7 +137,7 @@ public abstract class AWTAdapter implements java.util.EventListener * where the given NEWT Window impersonates as the event's source. * The NEWT EventListener will be called when an event happens.
                      */ - public AWTAdapter(com.jogamp.newt.event.NEWTEventListener newtListener, com.jogamp.newt.Window newtProxy) { + protected AWTAdapter(com.jogamp.newt.event.NEWTEventListener newtListener, com.jogamp.newt.Window newtProxy) { if(null==newtListener) { throw new RuntimeException("Argument newtListener is null"); } @@ -144,6 +146,7 @@ public abstract class AWTAdapter implements java.util.EventListener } this.newtListener = newtListener; this.newtWindow = newtProxy; + this.consumeAWTEvent = false; } /** @@ -151,22 +154,51 @@ public abstract class AWTAdapter implements java.util.EventListener * Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.
                      * This is only supported with EDT enabled! */ - public AWTAdapter(com.jogamp.newt.Window downstream) { + protected AWTAdapter(com.jogamp.newt.Window downstream) { + this(); + setDownstream(downstream); + } + + public AWTAdapter() { + this.newtListener = null; + this.newtWindow = null; + this.consumeAWTEvent = false; + } + + /** + * Setup a pipeline adapter, AWT EventListener.
                      + * Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream window.
                      + * This is only supported with EDT enabled! + */ + public synchronized AWTAdapter setDownstream(com.jogamp.newt.Window downstream) { if(null==downstream) { throw new RuntimeException("Argument downstream is null"); } this.newtListener = null; this.newtWindow = downstream; + this.consumeAWTEvent = false; if( null == newtWindow.getScreen().getDisplay().getEDTUtil() ) { throw new RuntimeException("EDT not enabled"); } + return this; + } + + /** Removes all references, downstream and NEWT-EventListener. */ + public synchronized AWTAdapter clear() { + this.newtListener = null; + this.newtWindow = null; + return this; + } + + public final synchronized void setConsumeAWTEvent(boolean v) { + this.consumeAWTEvent = v; } - public final com.jogamp.newt.Window getNewtWindow() { + public final synchronized com.jogamp.newt.Window getNewtWindow() { return newtWindow; } - public final com.jogamp.newt.event.NEWTEventListener getNewtEventListener() { + public final synchronized com.jogamp.newt.event.NEWTEventListener getNewtEventListener() { return newtListener; } diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java index f6f11b81f..e8545aa52 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java @@ -49,21 +49,28 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe super(downstream); } + public AWTKeyAdapter() { + super(); + } + @Override - public AWTAdapter addTo(java.awt.Component awtComponent) { + public synchronized AWTAdapter addTo(java.awt.Component awtComponent) { awtComponent.addKeyListener(this); return this; } @Override - public AWTAdapter removeFrom(java.awt.Component awtComponent) { + public synchronized AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeKeyListener(this); return this; } @Override - public void keyPressed(java.awt.event.KeyEvent e) { + public synchronized void keyPressed(java.awt.event.KeyEvent e) { final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, e, newtWindow); + if( consumeAWTEvent ) { + e.consume(); + } if(null!=newtListener) { ((com.jogamp.newt.event.KeyListener)newtListener).keyPressed(event); } else { @@ -72,8 +79,11 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe } @Override - public void keyReleased(java.awt.event.KeyEvent e) { + public synchronized void keyReleased(java.awt.event.KeyEvent e) { final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow); + if( consumeAWTEvent ) { + e.consume(); + } if(null!=newtListener) { ((com.jogamp.newt.event.KeyListener)newtListener).keyReleased(event); } else { @@ -82,7 +92,10 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe } @Override - public void keyTyped(java.awt.event.KeyEvent e) { + public synchronized void keyTyped(java.awt.event.KeyEvent e) { + if( consumeAWTEvent ) { + e.consume(); + } } } diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java index 73a02c9fc..365bc4e2a 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java @@ -46,8 +46,12 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL super(downstream); } + public AWTMouseAdapter() { + super(); + } + @Override - public AWTAdapter addTo(java.awt.Component awtComponent) { + public synchronized AWTAdapter addTo(java.awt.Component awtComponent) { awtComponent.addMouseListener(this); awtComponent.addMouseMotionListener(this); awtComponent.addMouseWheelListener(this); @@ -55,7 +59,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } @Override - public AWTAdapter removeFrom(java.awt.Component awtComponent) { + public synchronized AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeMouseListener(this); awtComponent.removeMouseMotionListener(this); awtComponent.removeMouseWheelListener(this); @@ -63,8 +67,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } @Override - public void mouseClicked(java.awt.event.MouseEvent e) { + public synchronized void mouseClicked(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + if( consumeAWTEvent ) { + e.consume(); + } if(null!=newtListener) { ((com.jogamp.newt.event.MouseListener)newtListener).mouseClicked(event); } else { @@ -73,8 +80,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } @Override - public void mouseEntered(java.awt.event.MouseEvent e) { + public synchronized void mouseEntered(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + if( consumeAWTEvent ) { + e.consume(); + } if(null!=newtListener) { ((com.jogamp.newt.event.MouseListener)newtListener).mouseEntered(event); } else { @@ -83,8 +93,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } @Override - public void mouseExited(java.awt.event.MouseEvent e) { + public synchronized void mouseExited(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + if( consumeAWTEvent ) { + e.consume(); + } if(null!=newtListener) { ((com.jogamp.newt.event.MouseListener)newtListener).mouseExited(event); } else { @@ -93,8 +106,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } @Override - public void mousePressed(java.awt.event.MouseEvent e) { + public synchronized void mousePressed(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + if( consumeAWTEvent ) { + e.consume(); + } if(null!=newtListener) { ((com.jogamp.newt.event.MouseListener)newtListener).mousePressed(event); } else { @@ -103,8 +119,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } @Override - public void mouseReleased(java.awt.event.MouseEvent e) { + public synchronized void mouseReleased(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + if( consumeAWTEvent ) { + e.consume(); + } if(null!=newtListener) { ((com.jogamp.newt.event.MouseListener)newtListener).mouseReleased(event); } else { @@ -113,8 +132,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } @Override - public void mouseDragged(java.awt.event.MouseEvent e) { + public synchronized void mouseDragged(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + if( consumeAWTEvent ) { + e.consume(); + } if(null!=newtListener) { ((com.jogamp.newt.event.MouseListener)newtListener).mouseDragged(event); } else { @@ -123,8 +145,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } @Override - public void mouseMoved(java.awt.event.MouseEvent e) { + public synchronized void mouseMoved(java.awt.event.MouseEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + if( consumeAWTEvent ) { + e.consume(); + } if(null!=newtListener) { ((com.jogamp.newt.event.MouseListener)newtListener).mouseMoved(event); } else { @@ -133,8 +158,11 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL } @Override - public void mouseWheelMoved(java.awt.event.MouseWheelEvent e) { + public synchronized void mouseWheelMoved(java.awt.event.MouseWheelEvent e) { com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); + if( consumeAWTEvent ) { + e.consume(); + } if(null!=newtListener) { ((com.jogamp.newt.event.MouseListener)newtListener).mouseWheelMoved(event); } else { diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java index 8a9a2a49f..57821fcb1 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java @@ -49,16 +49,17 @@ public class AWTWindowAdapter public AWTWindowAdapter(com.jogamp.newt.Window downstream) { super(downstream); } + public AWTWindowAdapter() { + super(); + } @Override - public AWTAdapter addTo(java.awt.Component awtComponent) { + public synchronized AWTAdapter addTo(java.awt.Component awtComponent) { java.awt.Window win = getWindow(awtComponent); awtComponent.addComponentListener(this); awtComponent.addFocusListener(this); - if( null == windowClosingListener ) { + if( null != win && null == windowClosingListener ) { windowClosingListener = new WindowClosingListener(); - } - if( null != win ) { win.addWindowListener(windowClosingListener); } if(awtComponent instanceof java.awt.Window) { @@ -67,7 +68,7 @@ public class AWTWindowAdapter return this; } - public AWTAdapter removeWindowClosingFrom(java.awt.Component awtComponent) { + public synchronized AWTAdapter removeWindowClosingFrom(java.awt.Component awtComponent) { java.awt.Window win = getWindow(awtComponent); if( null != win && null != windowClosingListener ) { win.removeWindowListener(windowClosingListener); @@ -76,7 +77,7 @@ public class AWTWindowAdapter } @Override - public AWTAdapter removeFrom(java.awt.Component awtComponent) { + public synchronized AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeFocusListener(this); awtComponent.removeComponentListener(this); removeWindowClosingFrom(awtComponent); @@ -97,7 +98,7 @@ public class AWTWindowAdapter } @Override - public void focusGained(java.awt.event.FocusEvent e) { + public synchronized void focusGained(java.awt.event.FocusEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: focusGained: "+e+" -> "+event); @@ -110,7 +111,7 @@ public class AWTWindowAdapter } @Override - public void focusLost(java.awt.event.FocusEvent e) { + public synchronized void focusLost(java.awt.event.FocusEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: focusLost: "+e+" -> "+event); @@ -123,7 +124,7 @@ public class AWTWindowAdapter } @Override - public void componentResized(java.awt.event.ComponentEvent e) { + public synchronized void componentResized(java.awt.event.ComponentEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { final java.awt.Component c = e.getComponent(); @@ -148,7 +149,7 @@ public class AWTWindowAdapter } @Override - public void componentMoved(java.awt.event.ComponentEvent e) { + public synchronized void componentMoved(java.awt.event.ComponentEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentMoved: "+e+" -> "+event); @@ -161,7 +162,7 @@ public class AWTWindowAdapter } @Override - public void componentShown(java.awt.event.ComponentEvent e) { + public synchronized void componentShown(java.awt.event.ComponentEvent e) { final java.awt.Component comp = e.getComponent(); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentShown: "+comp); @@ -179,7 +180,7 @@ public class AWTWindowAdapter } @Override - public void componentHidden(java.awt.event.ComponentEvent e) { + public synchronized void componentHidden(java.awt.event.ComponentEvent e) { final java.awt.Component comp = e.getComponent(); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentHidden: "+comp); @@ -197,7 +198,7 @@ public class AWTWindowAdapter } @Override - public void windowActivated(java.awt.event.WindowEvent e) { + public synchronized void windowActivated(java.awt.event.WindowEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowGainedFocus(event); @@ -207,13 +208,13 @@ public class AWTWindowAdapter } @Override - public void windowClosed(java.awt.event.WindowEvent e) { } + public synchronized void windowClosed(java.awt.event.WindowEvent e) { } @Override - public void windowClosing(java.awt.event.WindowEvent e) { } + public synchronized void windowClosing(java.awt.event.WindowEvent e) { } @Override - public void windowDeactivated(java.awt.event.WindowEvent e) { + public synchronized void windowDeactivated(java.awt.event.WindowEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowLostFocus(event); @@ -223,31 +224,35 @@ public class AWTWindowAdapter } @Override - public void windowDeiconified(java.awt.event.WindowEvent e) { } + public synchronized void windowDeiconified(java.awt.event.WindowEvent e) { } @Override - public void windowIconified(java.awt.event.WindowEvent e) { } + public synchronized void windowIconified(java.awt.event.WindowEvent e) { } @Override - public void windowOpened(java.awt.event.WindowEvent e) { } + public synchronized void windowOpened(java.awt.event.WindowEvent e) { } class WindowClosingListener implements java.awt.event.WindowListener { @Override public void windowClosing(java.awt.event.WindowEvent e) { - com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); - if(null!=newtListener) { - ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event); - } else { - enqueueEvent(true, event); + synchronized( AWTWindowAdapter.this ) { + com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + if(null!=newtListener) { + ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event); + } else { + enqueueEvent(true, event); + } } } @Override public void windowClosed(java.awt.event.WindowEvent e) { - com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); - if(null!=newtListener) { - ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyed(event); - } else { - enqueueEvent(true, event); + synchronized( AWTWindowAdapter.this ) { + com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + if(null!=newtListener) { + ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyed(event); + } else { + enqueueEvent(true, event); + } } } diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index 4bcb0fc82..add2f291e 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -50,95 +50,115 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt super(downstream); this.downstreamParent = downstreamParent; } + public AWTParentWindowAdapter() { + super(); + } + public AWTParentWindowAdapter setDownstream(NativeWindow downstreamParent, com.jogamp.newt.Window downstream) { + setDownstream(downstream); + this.downstreamParent = downstreamParent; + return this; + } @Override - public AWTAdapter addTo(java.awt.Component awtComponent) { + public synchronized AWTAdapter clear() { + super.clear(); + this.downstreamParent = null; + return this; + } + + @Override + public synchronized AWTAdapter addTo(java.awt.Component awtComponent) { awtComponent.addHierarchyListener(this); return super.addTo(awtComponent); } @Override - public AWTAdapter removeFrom(java.awt.Component awtComponent) { + public synchronized AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeHierarchyListener(this); return super.removeFrom(awtComponent); } @Override - public void focusGained(java.awt.event.FocusEvent e) { + public synchronized void focusGained(java.awt.event.FocusEvent e) { // forward focus to NEWT child final com.jogamp.newt.Window newtChild = getNewtWindow(); - final boolean isOnscreen = newtChild.isNativeValid() && newtChild.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); - final boolean isParent = downstreamParent == newtChild.getParent(); - final boolean isFullscreen = newtChild.isFullscreen(); - if(DEBUG_IMPLEMENTATION) { - System.err.println("AWT: focusGained: onscreen "+ isOnscreen+", "+e+", isParent: "+isParent+", isFS "+isFullscreen); - } - if(isParent) { - if(isOnscreen && !isFullscreen) { - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + if( null != newtChild ) { + final boolean isOnscreen = newtChild.isNativeValid() && newtChild.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); + final boolean isParent = downstreamParent == newtChild.getParent(); + final boolean isFullscreen = newtChild.isFullscreen(); + if(DEBUG_IMPLEMENTATION) { + System.err.println("AWT: focusGained: onscreen "+ isOnscreen+", "+e+", isParent: "+isParent+", isFS "+isFullscreen); + } + if(isParent) { + if(isOnscreen && !isFullscreen) { + KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + } + newtChild.requestFocus(false); } - newtChild.requestFocus(false); } } @Override - public void focusLost(java.awt.event.FocusEvent e) { + public synchronized void focusLost(java.awt.event.FocusEvent e) { if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: focusLost: "+ e); } } @Override - public void componentResized(java.awt.event.ComponentEvent e) { + public synchronized void componentResized(java.awt.event.ComponentEvent e) { // Need to resize the NEWT child window // the resized event will be send via the native window feedback. final java.awt.Component comp = e.getComponent(); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentResized: "+comp); } - final Window newtWindow = getNewtWindow(); - newtWindow.runOnEDTIfAvail(false, new Runnable() { - @Override - public void run() { - int cw = comp.getWidth(); - int ch = comp.getHeight(); - if( 0 < cw && 0 < ch ) { - if( newtWindow.getWidth() != cw || newtWindow.getHeight() != ch ) { - newtWindow.setSize(cw, ch); - if(comp.isVisible() != newtWindow.isVisible()) { - newtWindow.setVisible(comp.isVisible()); + final Window newtChild = getNewtWindow(); + if( null != newtChild ) { + newtChild.runOnEDTIfAvail(false, new Runnable() { + @Override + public void run() { + int cw = comp.getWidth(); + int ch = comp.getHeight(); + if( 0 < cw && 0 < ch ) { + if( newtChild.getWidth() != cw || newtChild.getHeight() != ch ) { + newtChild.setSize(cw, ch); + if(comp.isVisible() != newtChild.isVisible()) { + newtChild.setVisible(comp.isVisible()); + } } + } else if(newtChild.isVisible()) { + newtChild.setVisible(false); } - } else if(newtWindow.isVisible()) { - newtWindow.setVisible(false); - } - }}); + }}); + } } @Override - public void componentMoved(java.awt.event.ComponentEvent e) { + public synchronized void componentMoved(java.awt.event.ComponentEvent e) { if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentMoved: "+e); } - final Window newtWindow = getNewtWindow(); - if(newtWindow.getDelegatedWindow() instanceof DriverUpdatePosition) { - ((DriverUpdatePosition)newtWindow.getDelegatedWindow()).updatePosition(0, 0); + final Window newtChild = getNewtWindow(); + if( null != newtChild && ( newtChild.getDelegatedWindow() instanceof DriverUpdatePosition ) ) { + ((DriverUpdatePosition)newtChild.getDelegatedWindow()).updatePosition(0, 0); } } @Override - public void windowActivated(java.awt.event.WindowEvent e) { + public synchronized void windowActivated(java.awt.event.WindowEvent e) { // no propagation to NEWT child window } @Override - public void windowDeactivated(java.awt.event.WindowEvent e) { + public synchronized void windowDeactivated(java.awt.event.WindowEvent e) { // no propagation to NEWT child window } @Override - public void hierarchyChanged(java.awt.event.HierarchyEvent e) { - if( null == getNewtEventListener() ) { + public synchronized void hierarchyChanged(java.awt.event.HierarchyEvent e) { + final Window newtChild = getNewtWindow(); + if( null != newtChild && null == getNewtEventListener() ) { long bits = e.getChangeFlags(); final java.awt.Component changed = e.getChanged(); if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) { @@ -146,11 +166,11 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed+", source "+e.getComponent()); } - getNewtWindow().runOnEDTIfAvail(false, new Runnable() { + newtChild.runOnEDTIfAvail(false, new Runnable() { @Override public void run() { - if(getNewtWindow().isVisible() != showing) { - getNewtWindow().setVisible(showing); + if(newtChild.isVisible() != showing) { + newtChild.setVisible(showing); } }}); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java index 776c3c7eb..5ae473e18 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.util; import java.awt.event.KeyEvent; @@ -37,6 +37,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent String prefix; int keyPressed, keyReleased; + int consumed; boolean pressed; List queue = new ArrayList(); boolean verbose = true; @@ -51,30 +52,35 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent public synchronized boolean isPressed() { return pressed; } - + public synchronized int getCount() { return keyReleased; } + public synchronized int getConsumedCount() { + return consumed; + } + public synchronized int getKeyPressedCount(boolean autoRepeatOnly) { - return keyPressed; + return keyPressed; } - + public synchronized int getKeyReleasedCount(boolean autoRepeatOnly) { - return keyReleased; + return keyReleased; } - + public synchronized List getQueued() { return queue; } - + public synchronized int getQueueSize() { return queue.size(); } - + public synchronized void reset() { keyPressed = 0; keyReleased = 0; + consumed = 0; pressed = false; queue.clear(); } @@ -91,12 +97,15 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent public synchronized void keyReleased(KeyEvent e) { pressed = false; keyReleased++; + if(e.isConsumed()) { + consumed++; + } queue.add(e); if( verbose ) { System.err.println("KEY AWT RELEASED ["+pressed+"]: "+prefix+", "+e); } } - public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+"]"; } + public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+", consumed "+consumed+"]"; } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java index 31362bfa1..f6cbd0a04 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.util; import java.awt.event.MouseEvent; @@ -36,6 +36,7 @@ import java.util.List; public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements InputEventCountAdapter { String prefix; int mouseClicked; + int consumed; boolean pressed; List queue = new ArrayList(); boolean verbose = true; @@ -46,25 +47,30 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu } public synchronized void setVerbose(boolean v) { verbose = false; } - + public synchronized boolean isPressed() { return pressed; } - + public synchronized int getCount() { return mouseClicked; } - + + public synchronized int getConsumedCount() { + return consumed; + } + public synchronized List getQueued() { return queue; } - + public synchronized int getQueueSize() { return queue.size(); } public synchronized void reset() { mouseClicked = 0; + consumed = 0; pressed = false; queue.clear(); } @@ -84,15 +90,18 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu System.err.println("MOUSE AWT RELEASED ["+pressed+"]: "+prefix+", "+e); } } - + public synchronized void mouseClicked(java.awt.event.MouseEvent e) { mouseClicked+=e.getClickCount(); + if(e.isConsumed()) { + consumed++; + } queue.add(e); if( verbose ) { System.err.println("MOUSE AWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e); } - } - - public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+"]"; } + } + + public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+", consumed "+consumed+"]"; } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java index c4078436f..1804b9cb6 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,22 +20,23 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.util; import java.util.EventObject; import java.util.List; public interface InputEventCountAdapter extends EventCountAdapter { + int getConsumedCount(); int getCount(); boolean isPressed(); - - public List getQueued(); + + public List getQueued(); public int getQueueSize(); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java index d143b3ca1..5242da637 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.util; import java.util.ArrayList; @@ -41,6 +41,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { String prefix; int keyPressed, keyReleased; int keyPressedAR, keyReleasedAR; + int consumed; boolean pressed; List queue = new ArrayList(); boolean verbose = true; @@ -49,29 +50,33 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { this.prefix = prefix; reset(); } - + public synchronized void setVerbose(boolean v) { verbose = false; } public synchronized boolean isPressed() { return pressed; } - + public synchronized int getCount() { return keyReleased; } + public synchronized int getConsumedCount() { + return consumed; + } + public synchronized int getKeyPressedCount(boolean autoRepeatOnly) { - return autoRepeatOnly ? keyPressedAR: keyPressed; + return autoRepeatOnly ? keyPressedAR: keyPressed; } - + public synchronized int getKeyReleasedCount(boolean autoRepeatOnly) { - return autoRepeatOnly ? keyReleasedAR: keyReleased; + return autoRepeatOnly ? keyReleasedAR: keyReleased; } - + public synchronized List getQueued() { return queue; } - + public synchronized int getQueueSize() { return queue.size(); } @@ -79,6 +84,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { public synchronized void reset() { keyPressed = 0; keyReleased = 0; + consumed = 0; keyPressedAR = 0; keyReleasedAR = 0; pressed = false; @@ -96,10 +102,13 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { System.err.println("KEY NEWT PRESSED ["+pressed+"]: "+prefix+", "+e); } } - + public synchronized void keyReleased(KeyEvent e) { pressed = false; keyReleased++; + if(e.isConsumed()) { + consumed++; + } if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { keyReleasedAR++; } @@ -108,7 +117,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { System.err.println("KEY NEWT RELEASED ["+pressed+"]: "+prefix+", "+e); } } - - public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+"]"; } + + public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+", consumed "+consumed+"]"; } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java index 644523782..6850fcf47 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.util; import java.util.ArrayList; @@ -39,6 +39,7 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda String prefix; int mouseClicked; + int consumed; boolean pressed; List queue = new ArrayList(); boolean verbose = true; @@ -49,25 +50,30 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda } public synchronized void setVerbose(boolean v) { verbose = false; } - + public synchronized boolean isPressed() { return pressed; } - + public synchronized int getCount() { return mouseClicked; } + public synchronized int getConsumedCount() { + return consumed; + } + public synchronized List getQueued() { return queue; } - + public synchronized int getQueueSize() { return queue.size(); } public synchronized void reset() { mouseClicked = 0; + consumed = 0; pressed = false; queue.clear(); } @@ -79,7 +85,7 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda System.err.println("MOUSE NEWT PRESSED ["+pressed+"]: "+prefix+", "+e); } } - + public synchronized void mouseReleased(MouseEvent e) { pressed = false; queue.add(e); @@ -87,15 +93,18 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda System.err.println("MOUSE NEWT RELEASED ["+pressed+"]: "+prefix+", "+e); } } - + public synchronized void mouseClicked(MouseEvent e) { mouseClicked+=e.getClickCount(); + if(e.isConsumed()) { + consumed++; + } queue.add(e); if( verbose ) { System.err.println("MOUSE NEWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e); } } - - public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+"]"; } + + public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+", consumed "+consumed+"]"; } } -- cgit v1.2.3 From b335cf086f8ee85985962b6f6676b99ab8141a77 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 13:03:58 +0100 Subject: NewtCanvasAWT: Use final AWT[Key|Mouse]Adapter and set downstream lazily; Consume AWT KeyEvents in downstream mode; Test respects 'consumed' key events. --- make/scripts/tests.sh | 4 +- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 51 ++++++++++++++-------- .../TestParentingFocus01SwingAWTRobot.java | 2 +- .../TestParentingFocus02SwingAWTRobot.java | 4 +- 4 files changed, 37 insertions(+), 24 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index aab20980d..9510734a3 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -608,9 +608,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* # # Misc Utils diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index b8de1f596..f9f869781 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -101,9 +101,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private boolean newtChildAttached = false; private boolean isOnscreen = true; private WindowClosingMode newtChildCloseOp; - private AWTParentWindowAdapter awtAdapter = null; - private AWTAdapter awtMouseAdapter = null; - private AWTAdapter awtKeyAdapter = null; + private final AWTParentWindowAdapter awtAdapter; + private final AWTAdapter awtMouseAdapter; + private final AWTAdapter awtKeyAdapter; private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @@ -125,6 +125,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public NewtCanvasAWT() { super(); + awtMouseAdapter = new AWTMouseAdapter().addTo(this); + awtKeyAdapter = new AWTKeyAdapter().addTo(this); + awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! } /** @@ -132,6 +136,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public NewtCanvasAWT(GraphicsConfiguration gc) { super(gc); + awtMouseAdapter = new AWTMouseAdapter().addTo(this); + awtKeyAdapter = new AWTKeyAdapter().addTo(this); + awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! } /** @@ -139,6 +147,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public NewtCanvasAWT(Window child) { super(); + awtMouseAdapter = new AWTMouseAdapter().addTo(this); + awtKeyAdapter = new AWTKeyAdapter().addTo(this); + awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! setNEWTChild(child); } @@ -147,6 +159,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public NewtCanvasAWT(GraphicsConfiguration gc, Window child) { super(gc); + awtMouseAdapter = new AWTMouseAdapter().addTo(this); + awtKeyAdapter = new AWTKeyAdapter().addTo(this); + awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! setNEWTChild(child); } @@ -671,18 +687,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } private final void configureNewtChild(boolean attach) { - if(null!=awtAdapter) { - awtAdapter.removeFrom(this); - awtAdapter=null; - } - if(null!=awtMouseAdapter) { - awtMouseAdapter.removeFrom(this); - awtMouseAdapter = null; - } - if(null!=awtKeyAdapter) { - awtKeyAdapter.removeFrom(this); - awtKeyAdapter = null; - } + awtAdapter.clear(); + awtMouseAdapter.clear(); + awtKeyAdapter.setConsumeAWTEvent(false); + awtMouseAdapter.clear(); + awtKeyAdapter.setConsumeAWTEvent(false); + if(null != keyboardFocusManager) { keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener); keyboardFocusManager = null; @@ -695,8 +705,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto throw new InternalError("XXX"); } isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); - awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this); - awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! + awtAdapter.setDownstream(jawtWindow, newtChild); newtChild.addWindowListener(clearAWTMenusOnNewtFocus); newtChild.setFocusAction(focusAction); // enable AWT focus traversal newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); @@ -710,8 +719,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.setKeyboardFocusHandler(newtFocusTraversalKeyListener); } else { // offscreen newt child requires AWT to fwd AWT key/mouse event - awtMouseAdapter = new AWTMouseAdapter(newtChild).addTo(this); - awtKeyAdapter = new AWTKeyAdapter(newtChild).addTo(this); + awtMouseAdapter.setDownstream(newtChild); + // We cannot consume AWT mouse click, since it would disable focus via mouse click! + // awtMouseAdapter.setConsumeAWTEvent(true); + awtKeyAdapter.setDownstream(newtChild); + // We manually transfer the focus via NEWT KeyListener, hence we can mark AWT keys as consumed! + awtKeyAdapter.setConsumeAWTEvent(true); } } else { newtChild.removeWindowListener(clearAWTMenusOnNewtFocus); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java index 29c3279aa..54842cd6e 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java @@ -193,7 +193,7 @@ public class TestParentingFocus01SwingAWTRobot extends UITestCase { } System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); - Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount()); + Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount()); // Remove listeners to avoid logging during dispose/destroy. glWindow1.removeKeyListener(glWindow1KA); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java index aa02e096b..3aa952e30 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java @@ -215,7 +215,7 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase { Assert.assertEquals(false, buttonNorthInnerFA.focusGained()); System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); - Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount()); + Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount()); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1, glWindow1, glWindow1MA); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2, @@ -253,7 +253,7 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase { Assert.assertEquals(false, buttonNorthOuterFA.focusGained()); System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); - Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount()); + Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount()); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1, glWindow1, glWindow1MA); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2, -- cgit v1.2.3 From 97c8e627068af729d9ea0f7992b2bc5981655296 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 13:35:59 +0100 Subject: NEWT AWTAdapter*: Don't act if not setup (due to lazy setup mode), refines commit 5c6c11abf643013976ecbc0df463a923a1f52696 --- src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java | 8 ++++++-- src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java | 3 +++ .../classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java | 8 ++++++++ .../classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java | 10 ++++++++++ .../classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java | 5 +++++ 5 files changed, 32 insertions(+), 2 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java index 977b38dd0..864db1f7b 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java @@ -118,6 +118,7 @@ public abstract class AWTAdapter implements java.util.EventListener com.jogamp.newt.event.NEWTEventListener newtListener; com.jogamp.newt.Window newtWindow; boolean consumeAWTEvent; + protected boolean isSetup; /** * Simply wrap aroung a NEWT EventListener, exposed as an AWT EventListener.
                      @@ -130,6 +131,7 @@ public abstract class AWTAdapter implements java.util.EventListener this.newtListener = newtListener; this.newtWindow = null; this.consumeAWTEvent = false; + this.isSetup = true; } /** @@ -147,6 +149,7 @@ public abstract class AWTAdapter implements java.util.EventListener this.newtListener = newtListener; this.newtWindow = newtProxy; this.consumeAWTEvent = false; + this.isSetup = true; } /** @@ -160,8 +163,7 @@ public abstract class AWTAdapter implements java.util.EventListener } public AWTAdapter() { - this.newtListener = null; - this.newtWindow = null; + clear(); this.consumeAWTEvent = false; } @@ -180,6 +182,7 @@ public abstract class AWTAdapter implements java.util.EventListener if( null == newtWindow.getScreen().getDisplay().getEDTUtil() ) { throw new RuntimeException("EDT not enabled"); } + this.isSetup = true; return this; } @@ -187,6 +190,7 @@ public abstract class AWTAdapter implements java.util.EventListener public synchronized AWTAdapter clear() { this.newtListener = null; this.newtWindow = null; + this.isSetup = false; return this; } diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java index e8545aa52..d4226f53e 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java @@ -67,6 +67,7 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe @Override public synchronized void keyPressed(java.awt.event.KeyEvent e) { + if( !isSetup ) { return; } final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, e, newtWindow); if( consumeAWTEvent ) { e.consume(); @@ -80,6 +81,7 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe @Override public synchronized void keyReleased(java.awt.event.KeyEvent e) { + if( !isSetup ) { return; } final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow); if( consumeAWTEvent ) { e.consume(); @@ -93,6 +95,7 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe @Override public synchronized void keyTyped(java.awt.event.KeyEvent e) { + if( !isSetup ) { return; } if( consumeAWTEvent ) { e.consume(); } diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java index 365bc4e2a..8ad1fa6ab 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTMouseAdapter.java @@ -68,6 +68,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseClicked(java.awt.event.MouseEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if( consumeAWTEvent ) { e.consume(); @@ -81,6 +82,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseEntered(java.awt.event.MouseEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if( consumeAWTEvent ) { e.consume(); @@ -94,6 +96,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseExited(java.awt.event.MouseEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if( consumeAWTEvent ) { e.consume(); @@ -107,6 +110,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mousePressed(java.awt.event.MouseEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if( consumeAWTEvent ) { e.consume(); @@ -120,6 +124,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseReleased(java.awt.event.MouseEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if( consumeAWTEvent ) { e.consume(); @@ -133,6 +138,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseDragged(java.awt.event.MouseEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if( consumeAWTEvent ) { e.consume(); @@ -146,6 +152,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseMoved(java.awt.event.MouseEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if( consumeAWTEvent ) { e.consume(); @@ -159,6 +166,7 @@ public class AWTMouseAdapter extends AWTAdapter implements java.awt.event.MouseL @Override public synchronized void mouseWheelMoved(java.awt.event.MouseWheelEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.MouseEvent event = AWTNewtEventFactory.createMouseEvent(e, newtWindow); if( consumeAWTEvent ) { e.consume(); diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java index 57821fcb1..2e5527ee1 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java @@ -99,6 +99,7 @@ public class AWTWindowAdapter @Override public synchronized void focusGained(java.awt.event.FocusEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: focusGained: "+e+" -> "+event); @@ -112,6 +113,7 @@ public class AWTWindowAdapter @Override public synchronized void focusLost(java.awt.event.FocusEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: focusLost: "+e+" -> "+event); @@ -125,6 +127,7 @@ public class AWTWindowAdapter @Override public synchronized void componentResized(java.awt.event.ComponentEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { final java.awt.Component c = e.getComponent(); @@ -150,6 +153,7 @@ public class AWTWindowAdapter @Override public synchronized void componentMoved(java.awt.event.ComponentEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentMoved: "+e+" -> "+event); @@ -163,6 +167,7 @@ public class AWTWindowAdapter @Override public synchronized void componentShown(java.awt.event.ComponentEvent e) { + if( !isSetup ) { return; } final java.awt.Component comp = e.getComponent(); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentShown: "+comp); @@ -181,6 +186,7 @@ public class AWTWindowAdapter @Override public synchronized void componentHidden(java.awt.event.ComponentEvent e) { + if( !isSetup ) { return; } final java.awt.Component comp = e.getComponent(); if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentHidden: "+comp); @@ -199,6 +205,7 @@ public class AWTWindowAdapter @Override public synchronized void windowActivated(java.awt.event.WindowEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowGainedFocus(event); @@ -215,6 +222,7 @@ public class AWTWindowAdapter @Override public synchronized void windowDeactivated(java.awt.event.WindowEvent e) { + if( !isSetup ) { return; } com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowLostFocus(event); @@ -236,6 +244,7 @@ public class AWTWindowAdapter @Override public void windowClosing(java.awt.event.WindowEvent e) { synchronized( AWTWindowAdapter.this ) { + if( !isSetup ) { return; } com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyNotify(event); @@ -247,6 +256,7 @@ public class AWTWindowAdapter @Override public void windowClosed(java.awt.event.WindowEvent e) { synchronized( AWTWindowAdapter.this ) { + if( !isSetup ) { return; } com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyed(event); diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index add2f291e..e152d96d5 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -80,6 +80,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt @Override public synchronized void focusGained(java.awt.event.FocusEvent e) { + if( !isSetup ) { return; } // forward focus to NEWT child final com.jogamp.newt.Window newtChild = getNewtWindow(); if( null != newtChild ) { @@ -100,6 +101,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt @Override public synchronized void focusLost(java.awt.event.FocusEvent e) { + if( !isSetup ) { return; } if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: focusLost: "+ e); } @@ -107,6 +109,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt @Override public synchronized void componentResized(java.awt.event.ComponentEvent e) { + if( !isSetup ) { return; } // Need to resize the NEWT child window // the resized event will be send via the native window feedback. final java.awt.Component comp = e.getComponent(); @@ -136,6 +139,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt @Override public synchronized void componentMoved(java.awt.event.ComponentEvent e) { + if( !isSetup ) { return; } if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentMoved: "+e); } @@ -157,6 +161,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt @Override public synchronized void hierarchyChanged(java.awt.event.HierarchyEvent e) { + if( !isSetup ) { return; } final Window newtChild = getNewtWindow(); if( null != newtChild && null == getNewtEventListener() ) { long bits = e.getChangeFlags(); -- cgit v1.2.3 From ead9d65722ac8c647ac1dde654fd4e8250e4d572 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 13:36:54 +0100 Subject: NewtCanvasAWT: Add method of 'isAWTEventPassThrough()', used in unit tests to fix event validation for offscreen mode (OSX/CALayer) --- make/scripts/tests.sh | 4 ++-- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 14 ++++++++++++++ .../newt/parenting/TestParentingFocus01SwingAWTRobot.java | 3 +++ .../newt/parenting/TestParentingFocus02SwingAWTRobot.java | 10 ++++++++-- 4 files changed, 27 insertions(+), 4 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9510734a3..311bfd0a1 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -608,8 +608,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* # diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index f9f869781..5780f2540 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -735,6 +735,20 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } + /** + * Returns true if Key and Mouse input events will be passed through AWT, + * otherwise only the {@link #getNEWTChild() NEWT child} will receive them. + *

                      + * Normally only the {@link #getNEWTChild() NEWT child} will receive Key and Mouse input events. + * In offscreen mode, e.g. OSX/CALayer, the AWT events will be received and translated into NEWT events + * and delivered to the NEWT child window.
                      + * Note: AWT key events will {@link java.awt.event.InputEvent#consume() consumed} in pass-through mode. + *

                      + */ + public final boolean isAWTEventPassThrough() { + return !isOnscreen; + } + private final void attachNewtChild() { if( null == newtChild || null == jawtWindow || newtChildAttached ) { return; // nop diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java index 54842cd6e..f45a48759 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java @@ -194,6 +194,9 @@ public class TestParentingFocus01SwingAWTRobot extends UITestCase { System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount()); + if( !newtCanvasAWT.isAWTEventPassThrough() ) { + Assert.assertEquals("AWT parent canvas received consumed keyboard events", 0, newtCanvasAWTKA.getConsumedCount()); + } // Remove listeners to avoid logging during dispose/destroy. glWindow1.removeKeyListener(glWindow1KA); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java index 3aa952e30..909fadda7 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java @@ -220,7 +220,10 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase { glWindow1, glWindow1MA); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2, glWindow1, glWindow1MA); - Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount()); + if( !newtCanvasAWT.isAWTEventPassThrough() ) { + Assert.assertEquals("AWT parent canvas received consumed keyboard events", 0, newtCanvasAWTKA.getConsumedCount()); + Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount()); + } // Button Inner Focus Thread.sleep(100); // allow event sync @@ -258,7 +261,10 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase { glWindow1, glWindow1MA); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2, glWindow1, glWindow1MA); - Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount()); + if( !newtCanvasAWT.isAWTEventPassThrough() ) { + Assert.assertEquals("AWT parent canvas received consumed keyboard events", 0, newtCanvasAWTKA.getConsumedCount()); + Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount()); + } animator1.stop(); Assert.assertEquals(false, animator1.isAnimating()); -- cgit v1.2.3 From 3614f908d0f6ae1174a85dbd44a2bad4df2ea8a6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 13:43:42 +0100 Subject: NEWT WindowImpl: Move consumePointerEvent(..) below doPointerEvent(..) to easy editing/review --- src/newt/classes/jogamp/newt/WindowImpl.java | 218 +++++++++++++-------------- 1 file changed, 109 insertions(+), 109 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 99e863a0e..51740cb8d 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2751,115 +2751,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer doEvent(enqueue, wait, e); // actual mouse event } - @Override - public final void addMouseListener(MouseListener l) { - addMouseListener(-1, l); - } - - @Override - public final void addMouseListener(int index, MouseListener l) { - if(l == null) { - return; - } - @SuppressWarnings("unchecked") - ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); - if(0>index) { - index = clonedListeners.size(); - } - clonedListeners.add(index, l); - mouseListeners = clonedListeners; - } - - @Override - public final void removeMouseListener(MouseListener l) { - if (l == null) { - return; - } - @SuppressWarnings("unchecked") - ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); - clonedListeners.remove(l); - mouseListeners = clonedListeners; - } - - @Override - public final MouseListener getMouseListener(int index) { - @SuppressWarnings("unchecked") - ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); - if(0>index) { - index = clonedListeners.size()-1; - } - return clonedListeners.get(index); - } - - @Override - public final MouseListener[] getMouseListeners() { - return mouseListeners.toArray(new MouseListener[mouseListeners.size()]); - } - - @Override - public final void setDefaultGesturesEnabled(boolean enable) { - defaultGestureHandlerEnabled = enable; - } - @Override - public final boolean areDefaultGesturesEnabled() { - return defaultGestureHandlerEnabled; - } - - @Override - public final void addGestureHandler(GestureHandler gh) { - addGestureHandler(-1, gh); - } - @Override - public final void addGestureHandler(int index, GestureHandler gh) { - if(gh == null) { - return; - } - @SuppressWarnings("unchecked") - ArrayList cloned = (ArrayList) pointerGestureHandler.clone(); - if(0>index) { - index = cloned.size(); - } - cloned.add(index, gh); - pointerGestureHandler = cloned; - } - @Override - public final void removeGestureHandler(GestureHandler gh) { - if (gh == null) { - return; - } - @SuppressWarnings("unchecked") - ArrayList cloned = (ArrayList) pointerGestureHandler.clone(); - cloned.remove(gh); - pointerGestureHandler = cloned; - } - @Override - public final void addGestureListener(GestureHandler.GestureListener gl) { - addGestureListener(-1, gl); - } - @Override - public final void addGestureListener(int index, GestureHandler.GestureListener gl) { - if(gl == null) { - return; - } - @SuppressWarnings("unchecked") - ArrayList cloned = (ArrayList) gestureListeners.clone(); - if(0>index) { - index = cloned.size(); - } - cloned.add(index, gl); - gestureListeners = cloned; - } - @Override - public final void removeGestureListener(GestureHandler.GestureListener gl) { - if (gl == null) { - return; - } - @SuppressWarnings("unchecked") - ArrayList cloned = (ArrayList) gestureListeners.clone(); - cloned.remove(gl); - gestureListeners= cloned; - } - private static int step(int lower, int edge, int value) { return value < edge ? lower : value; } @@ -3088,6 +2979,115 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + @Override + public final void addMouseListener(MouseListener l) { + addMouseListener(-1, l); + } + + @Override + public final void addMouseListener(int index, MouseListener l) { + if(l == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); + if(0>index) { + index = clonedListeners.size(); + } + clonedListeners.add(index, l); + mouseListeners = clonedListeners; + } + + @Override + public final void removeMouseListener(MouseListener l) { + if (l == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); + clonedListeners.remove(l); + mouseListeners = clonedListeners; + } + + @Override + public final MouseListener getMouseListener(int index) { + @SuppressWarnings("unchecked") + ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); + if(0>index) { + index = clonedListeners.size()-1; + } + return clonedListeners.get(index); + } + + @Override + public final MouseListener[] getMouseListeners() { + return mouseListeners.toArray(new MouseListener[mouseListeners.size()]); + } + + @Override + public final void setDefaultGesturesEnabled(boolean enable) { + defaultGestureHandlerEnabled = enable; + } + @Override + public final boolean areDefaultGesturesEnabled() { + return defaultGestureHandlerEnabled; + } + + @Override + public final void addGestureHandler(GestureHandler gh) { + addGestureHandler(-1, gh); + } + @Override + public final void addGestureHandler(int index, GestureHandler gh) { + if(gh == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList cloned = (ArrayList) pointerGestureHandler.clone(); + if(0>index) { + index = cloned.size(); + } + cloned.add(index, gh); + pointerGestureHandler = cloned; + } + @Override + public final void removeGestureHandler(GestureHandler gh) { + if (gh == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList cloned = (ArrayList) pointerGestureHandler.clone(); + cloned.remove(gh); + pointerGestureHandler = cloned; + } + @Override + public final void addGestureListener(GestureHandler.GestureListener gl) { + addGestureListener(-1, gl); + } + @Override + public final void addGestureListener(int index, GestureHandler.GestureListener gl) { + if(gl == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList cloned = (ArrayList) gestureListeners.clone(); + if(0>index) { + index = cloned.size(); + } + cloned.add(index, gl); + gestureListeners = cloned; + } + @Override + public final void removeGestureListener(GestureHandler.GestureListener gl) { + if (gl == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList cloned = (ArrayList) gestureListeners.clone(); + cloned.remove(gl); + gestureListeners= cloned; + } + private final void dispatchMouseEvent(MouseEvent e) { for(int i = 0; !e.isConsumed() && i < mouseListeners.size(); i++ ) { MouseListener l = mouseListeners.get(i); -- cgit v1.2.3 From d8f7418f170aba4703df2b11d5ae11598f71a796 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 16:12:52 +0100 Subject: Fix Bug 893 - NewtCanvasAWT Lifecycle Race Condition (NPE on shutdown periodically) As suggested: Employ synchronization on lifecycle actions _and_ perform destroyImpl(..) always on AWT-EDT to avoid a deadlock. --- make/scripts/tests.sh | 8 +- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 347 +++++++++++---------- 2 files changed, 189 insertions(+), 166 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2a97b42bc..157c8703a 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -106,7 +106,7 @@ function jrun() { #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" - D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.debug.GLContext" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" @@ -199,7 +199,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -305,7 +305,7 @@ function testawtswt() { #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* #testnoawt com.jogamp.newt.NewtVersion $* -testnoawt com.jogamp.newt.opengl.GLWindow $* +#testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* @@ -319,7 +319,7 @@ testnoawt com.jogamp.newt.opengl.GLWindow $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 5780f2540..49bd0d778 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -95,6 +95,7 @@ import com.jogamp.opengl.util.TileRenderer; public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol, OffscreenLayerOption, AWTPrintLifecycle { public static final boolean DEBUG = Debug.debug("Window"); + private final Object sync = new Object(); private JAWTWindow jawtWindow = null; private boolean shallUseOffscreenLayer = false; private Window newtChild = null; @@ -178,7 +179,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public final boolean isOffscreenLayerSurfaceEnabled() { - return jawtWindow.isOffscreenLayerSurfaceEnabled(); + final JAWTWindow w = jawtWindow; + return null != w && w.isOffscreenLayerSurfaceEnabled(); } /** @@ -187,7 +189,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto * ie. before adding the component to the AWT tree and make it visible. */ public boolean isApplet() { - return jawtWindow.isApplet(); + final JAWTWindow w = jawtWindow; + return null != w && w.isApplet(); } boolean isParent() { @@ -353,29 +356,32 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto * @return the previous attached newt child. */ public Window setNEWTChild(Window newChild) { - final Window prevChild = newtChild; - if(DEBUG) { - System.err.println("NewtCanvasAWT.setNEWTChild.0: win "+newtWinHandleToHexString(prevChild)+" -> "+newtWinHandleToHexString(newChild)); - } - final java.awt.Container cont = AWTMisc.getContainer(this); - // remove old one - if(null != newtChild) { - detachNewtChild( cont ); - newtChild = null; - } - // add new one, reparent only if ready - newtChild = newChild; + synchronized(sync) { + final Window prevChild = newtChild; + if(DEBUG) { + System.err.println("NewtCanvasAWT.setNEWTChild.0: win "+newtWinHandleToHexString(prevChild)+" -> "+newtWinHandleToHexString(newChild)); + } + final java.awt.Container cont = AWTMisc.getContainer(this); + // remove old one + if(null != newtChild) { + detachNewtChild( cont ); + newtChild = null; + } + // add new one, reparent only if ready + newtChild = newChild; - updateLayoutSize(); - // will be done later at paint/display/..: attachNewtChild(cont); + updateLayoutSize(); + // will be done later at paint/display/..: attachNewtChild(cont); - return prevChild; + return prevChild; + } } private final void updateLayoutSize() { - if( null != newtChild ) { + final Window w = newtChild; + if( null != w ) { // use NEWT child's size for min/pref size! - java.awt.Dimension minSize = new java.awt.Dimension(newtChild.getWidth(), newtChild.getHeight()); + java.awt.Dimension minSize = new java.awt.Dimension(w.getWidth(), w.getHeight()); setMinimumSize(minSize); setPreferredSize(minSize); } @@ -414,15 +420,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto // after native peer is valid: Windows disableBackgroundErase(); - jawtWindow = NewtFactoryAWT.getNativeWindow(this, null != newtChild ? newtChild.getRequestedCapabilities() : null); - jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); + synchronized(sync) { + jawtWindow = NewtFactoryAWT.getNativeWindow(this, null != newtChild ? newtChild.getRequestedCapabilities() : null); + jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); - if(DEBUG) { - // if ( isShowing() == false ) -> Container was not visible yet. - // if ( isShowing() == true ) -> Container is already visible. - System.err.println("NewtCanvasAWT.addNotify: win "+newtWinHandleToHexString(newtChild)+ - ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+ - ", displayable "+isDisplayable()+", cont "+AWTMisc.getContainer(this)); + if(DEBUG) { + // if ( isShowing() == false ) -> Container was not visible yet. + // if ( isShowing() == true ) -> Container is already visible. + System.err.println("NewtCanvasAWT.addNotify: win "+newtWinHandleToHexString(newtChild)+ + ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+ + ", displayable "+isDisplayable()+", cont "+AWTMisc.getContainer(this)); + } } } awtWindowClosingProtocol.addClosingListener(); @@ -451,38 +459,45 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto * @see Window#destroy() */ public final void destroy() { - destroyImpl(false /* removeNotify */, false /* windowClosing */); + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + destroyImpl(false /* removeNotify */, false /* windowClosing */); + } } ); } private final void destroyImpl(boolean removeNotify, boolean windowClosing) { - if( null !=newtChild ) { - java.awt.Container cont = AWTMisc.getContainer(this); - if(DEBUG) { - System.err.println("NewtCanvasAWT.destroy(removeNotify "+removeNotify+", windowClosing "+windowClosing+"): nw "+newtWinHandleToHexString(newtChild)+", from "+cont); - } - detachNewtChild(cont); - - if( !removeNotify ) { - final Window cWin = newtChild; - final Window dWin = cWin.getDelegatedWindow(); - newtChild=null; - if( windowClosing && dWin instanceof WindowImpl ) { - ((WindowImpl)dWin).windowDestroyNotify(true); - } else { - cWin.destroy(); + synchronized(sync) { + if( null !=newtChild ) { + java.awt.Container cont = AWTMisc.getContainer(this); + if(DEBUG) { + System.err.println("NewtCanvasAWT.destroy(removeNotify "+removeNotify+", windowClosing "+windowClosing+"): nw "+newtWinHandleToHexString(newtChild)+", from "+cont); + } + detachNewtChild(cont); + + if( !removeNotify ) { + final Window cWin = newtChild; + final Window dWin = cWin.getDelegatedWindow(); + newtChild=null; + if( windowClosing && dWin instanceof WindowImpl ) { + ((WindowImpl)dWin).windowDestroyNotify(true); + } else { + cWin.destroy(); + } } } - } - if( ( removeNotify || windowClosing ) && null!=jawtWindow ) { - NewtFactoryAWT.destroyNativeWindow(jawtWindow); - jawtWindow=null; + if( ( removeNotify || windowClosing ) && null!=jawtWindow ) { + NewtFactoryAWT.destroyNativeWindow(jawtWindow); + jawtWindow=null; + } } } @Override public void paint(Graphics g) { - if( validateComponent(true) && !printActive ) { - newtChild.windowRepaint(0, 0, getWidth(), getHeight()); + synchronized(sync) { + if( validateComponent(true) && !printActive ) { + newtChild.windowRepaint(0, 0, getWidth(), getHeight()); + } } } @Override @@ -494,12 +509,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public void reshape(int x, int y, int width, int height) { synchronized (getTreeLock()) { // super.reshape(..) claims tree lock, so we do extend it's lock over reshape - super.reshape(x, y, width, height); - if(DEBUG) { - System.err.println("NewtCanvasAWT.reshape: "+x+"/"+y+" "+width+"x"+height); - } - if( validateComponent(true) ) { - // newtChild.setSize(width, height); + synchronized(sync) { + super.reshape(x, y, width, height); + if(DEBUG) { + System.err.println("NewtCanvasAWT.reshape: "+x+"/"+y+" "+width+"x"+height); + } + if( validateComponent(true) ) { + // newtChild.setSize(width, height); + } } } } @@ -527,73 +544,75 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final Runnable setupPrintOnEDT = new Runnable() { @Override public void run() { - if( !validateComponent(true) ) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); + synchronized(sync) { + if( !validateComponent(true) ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); + } + printActive = false; + return; // not yet available .. } - printActive = false; - return; // not yet available .. - } - if( !isVisible() ) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); + if( !isVisible() ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); + } + printActive = false; + return; // not yet available .. } - printActive = false; - return; // not yet available .. - } - final GLAutoDrawable glad = getGLAD(); - if( null == glad ) { + final GLAutoDrawable glad = getGLAD(); + if( null == glad ) { + if( DEBUG ) { + System.err.println("AWT print.setup exit, newtChild not a GLAutoDrawable: "+newtChild); + } + printActive = false; + return; + } + printAnimator = glad.getAnimator(); + if( null != printAnimator ) { + printAnimator.remove(glad); + } + printGLAD = glad; // _not_ default, shall be replaced by offscreen GLAD + final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); + final int printNumSamples = printAWTTiles.getNumSamples(caps); + GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); + final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); + final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || + printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); + final boolean reqNewGLADOnscrn = caps.isOnscreen(); + + // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context. + // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX + final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); if( DEBUG ) { - System.err.println("AWT print.setup exit, newtChild not a GLAutoDrawable: "+newtChild); + System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ + ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ + ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ + ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ + ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } - printActive = false; - return; - } - printAnimator = glad.getAnimator(); - if( null != printAnimator ) { - printAnimator.remove(glad); - } - printGLAD = glad; // _not_ default, shall be replaced by offscreen GLAD - final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); - final int printNumSamples = printAWTTiles.getNumSamples(caps); - GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); - final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); - final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || - printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); - final boolean reqNewGLADOnscrn = caps.isOnscreen(); - - // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context. - // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX - final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); - if( DEBUG ) { - System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ - ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ - ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ - ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ - ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); - } - if( reqNewGLAD ) { - caps.setDoubleBuffered(false); - caps.setOnscreen(false); - if( printNumSamples != caps.getNumSamples() ) { - caps.setSampleBuffers(0 < printNumSamples); - caps.setNumSamples(printNumSamples); + if( reqNewGLAD ) { + caps.setDoubleBuffered(false); + caps.setOnscreen(false); + if( printNumSamples != caps.getNumSamples() ) { + caps.setSampleBuffers(0 < printNumSamples); + caps.setNumSamples(printNumSamples); + } + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); + GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); + printDrawable = printGLAD.getDelegatedDrawable(); + } + printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); + printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); + printAWTTiles.renderer.attachAutoDrawable(printGLAD); + if( DEBUG ) { + System.err.println("AWT print.setup "+printAWTTiles); + System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); + System.err.println("AWT print.setup printGLAD: "+printGLAD.getWidth()+"x"+printGLAD.getHeight()+", "+printGLAD); + System.err.println("AWT print.setup printDraw: "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+", "+printDrawable); } - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, - printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); - GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); - printDrawable = printGLAD.getDelegatedDrawable(); - } - printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); - printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); - printAWTTiles.renderer.attachAutoDrawable(printGLAD); - if( DEBUG ) { - System.err.println("AWT print.setup "+printAWTTiles); - System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); - System.err.println("AWT print.setup printGLAD: "+printGLAD.getWidth()+"x"+printGLAD.getHeight()+", "+printGLAD); - System.err.println("AWT print.setup printDraw: "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+", "+printDrawable); } } }; @@ -610,61 +629,65 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final Runnable releasePrintOnEDT = new Runnable() { @Override public void run() { - if( DEBUG ) { - System.err.println("AWT print.release "+printAWTTiles); - } - final GLAutoDrawable glad = getGLAD(); - printAWTTiles.dispose(); - printAWTTiles= null; - if( printGLAD != glad ) { - GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, glad); - printGLAD.destroy(); - } - printGLAD = null; - if( null != printAnimator ) { - printAnimator.add(glad); - printAnimator = null; + synchronized(sync) { + if( DEBUG ) { + System.err.println("AWT print.release "+printAWTTiles); + } + final GLAutoDrawable glad = getGLAD(); + printAWTTiles.dispose(); + printAWTTiles= null; + if( printGLAD != glad ) { + GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, glad); + printGLAD.destroy(); + } + printGLAD = null; + if( null != printAnimator ) { + printAnimator.add(glad); + printAnimator = null; + } + printActive = false; } - printActive = false; } }; @Override public void print(Graphics graphics) { - if( !printActive || null == printGLAD ) { - throw new IllegalStateException("setupPrint() not called"); - } - if(DEBUG && !EventQueue.isDispatchThread()) { - System.err.println(getThreadName()+": Warning: GLCanvas print - not called from AWT-EDT"); - // we cannot dispatch print on AWT-EDT due to printing internal locking .. - } - - final Graphics2D g2d = (Graphics2D)graphics; - try { - printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); - final TileRenderer tileRenderer = printAWTTiles.renderer; - if( DEBUG ) { - System.err.println("AWT print.0: "+tileRenderer); + synchronized(sync) { + if( !printActive || null == printGLAD ) { + throw new IllegalStateException("setupPrint() not called"); } - if( !tileRenderer.eot() ) { - try { - do { - tileRenderer.display(); - } while ( !tileRenderer.eot() ); - if( DEBUG ) { - System.err.println("AWT print.1: "+printAWTTiles); + if(DEBUG && !EventQueue.isDispatchThread()) { + System.err.println(getThreadName()+": Warning: GLCanvas print - not called from AWT-EDT"); + // we cannot dispatch print on AWT-EDT due to printing internal locking .. + } + + final Graphics2D g2d = (Graphics2D)graphics; + try { + printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); + } + if( !tileRenderer.eot() ) { + try { + do { + tileRenderer.display(); + } while ( !tileRenderer.eot() ); + if( DEBUG ) { + System.err.println("AWT print.1: "+printAWTTiles); + } + tileRenderer.reset(); + } finally { + printAWTTiles.resetGraphics2D(); } - tileRenderer.reset(); - } finally { - printAWTTiles.resetGraphics2D(); } + } catch (NoninvertibleTransformException nte) { + System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); + nte.printStackTrace(); + } + if( DEBUG ) { + System.err.println("AWT print.X: "+printAWTTiles); } - } catch (NoninvertibleTransformException nte) { - System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); - nte.printStackTrace(); - } - if( DEBUG ) { - System.err.println("AWT print.X: "+printAWTTiles); } } -- cgit v1.2.3 From 417675219de9fb5fceca5771812366ae8768b658 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Mon, 18 Nov 2013 10:54:01 -0800 Subject: jogl: add missing @Override annotation in NewtCanvasAWT Signed-off-by: Harvey Harrison --- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 49bd0d778..35f4fca73 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -228,6 +228,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto /** Must run on AWT-EDT non-blocking, since it invokes tasks on AWT-EDT w/ waiting otherwise. */ private final Runnable awtClearSelectedMenuPath = new Runnable() { + @Override public void run() { MenuSelectionManager.defaultManager().clearSelectedPath(); } @@ -460,6 +461,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public final void destroy() { AWTEDTExecutor.singleton.invoke(true, new Runnable() { + @Override public void run() { destroyImpl(false /* removeNotify */, false /* windowClosing */); } } ); -- cgit v1.2.3 From 0a9d16f057727652220a5983b65f22f427df6a22 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Mon, 18 Nov 2013 10:55:30 -0800 Subject: jogl: simplify conditional that repeats test for isOnScreen if (isOnscreen) else if (!isOnScreen) change to if (isOnscreen) else Signed-off-by: Harvey Harrison --- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 35f4fca73..e5c76f25d 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -213,7 +213,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( isOnscreen ) { // Remove the AWT focus in favor of the native NEWT focus KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); - } else if( !isOnscreen ) { + } + else { // In offscreen mode we require the focus! if( !hasFocus() ) { // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. -- cgit v1.2.3 From d544c839f6df10f20977c786a446833f3aa7ef13 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Mon, 18 Nov 2013 10:54:35 -0800 Subject: jogl: do the clearGlobalFocusOwner() call on the AWT EDT in NewtCanvasAWT Otherwise we can deadlock in the native focusrequest calls from the AWT thread, see bug 879 for the details. Signed-off-by: Harvey Harrison --- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index e5c76f25d..e1a819e77 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -212,7 +212,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( isParent && !isFullscreen ) { // must be parent of newtChild _and_ newtChild not fullscreen if( isOnscreen ) { // Remove the AWT focus in favor of the native NEWT focus - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + AWTEDTExecutor.singleton.invoke(false, awtClearGlobalFocusOwner); } else { // In offscreen mode we require the focus! @@ -227,6 +227,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } private final FocusAction focusAction = new FocusAction(); + private static class ClearFocusOwner implements Runnable { + @Override + public void run() { + KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + } + } + private static final Runnable awtClearGlobalFocusOwner = new ClearFocusOwner(); + /** Must run on AWT-EDT non-blocking, since it invokes tasks on AWT-EDT w/ waiting otherwise. */ private final Runnable awtClearSelectedMenuPath = new Runnable() { @Override -- cgit v1.2.3 From 177d0da1a9a8e031f15efa9e89465f8ed97f25e5 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Mon, 18 Nov 2013 11:28:40 -0800 Subject: jogl: push other call to clearGlobalFocus to the AWT EDT Follow-on to commit: d544c839f6df10f20977c786a446833f3aa7ef13 (jogl: do the clearGlobalFocusOwner() call on the AWT EDT in NewtCanvasAWT) Likely this won't hurt anything. Signed-off-by: Harvey Harrison --- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index e1a819e77..fd8d44a74 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -346,7 +346,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(null!=newtChild) { newtChild.setFocusAction(null); if(isOnscreen) { - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + AWTEDTExecutor.singleton.invoke(false, awtClearGlobalFocusOwner); } newtChild.requestFocus(); newtChild.setFocusAction(focusAction); -- cgit v1.2.3 From b5b5b0f9f5a12e131b4718af8a4cea899f74e1dc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 22:15:53 +0100 Subject: NewtCanvasAWT: Remove useless block in else branch --- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index fd8d44a74..749002b0f 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -213,13 +213,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( isOnscreen ) { // Remove the AWT focus in favor of the native NEWT focus AWTEDTExecutor.singleton.invoke(false, awtClearGlobalFocusOwner); - } - else { + } else if( !hasFocus() ) { // In offscreen mode we require the focus! - if( !hasFocus() ) { - // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. - NewtCanvasAWT.super.requestFocus(); - } + // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. + NewtCanvasAWT.super.requestFocus(); } } return false; // NEWT shall proceed requesting the native focus -- cgit v1.2.3 From 42f56dea3dc31de8049186825e18dc4b4767827e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 23 Nov 2013 13:22:13 +0100 Subject: JOGLNewtAppletBase's windowDestroyNotify(): Double check 'awtParent' before reparenting 'back to parent' --- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index d17d2e77c..2c4f25804 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -166,18 +166,19 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { // Closing action: back to parent! @Override public void windowDestroyNotify(WindowEvent e) { - if( isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() ) { - if(null == glWindow.getParent()) { - // we may be called directly by the native EDT - new Thread(new Runnable() { - @Override - public void run() { - if( glWindow.isNativeValid() ) { - glWindow.reparentWindow(awtParent); - } - } - }).start(); - } + if( isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() && + null == glWindow.getParent() && null != awtParent && 0 != awtParent.getWindowHandle() ) + { + Thread.dumpStack(); + // we may be called directly by the native EDT + new Thread(new Runnable() { + @Override + public void run() { + if( glWindow.isNativeValid() && null != awtParent && 0 != awtParent.getWindowHandle() ) { + glWindow.reparentWindow(awtParent); + } + } + }).start(); } } } ); -- cgit v1.2.3 From 832a69834200f34a44d72639bfd47e73c72d2b42 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 23 Nov 2013 13:25:21 +0100 Subject: JOGLNewtApplet1Run: Perform AWT Operations on AWT-EDT ; Remove redundant explicit call to reparentWindow(null) @ destroy --- .../jogamp/newt/awt/applet/JOGLNewtApplet1Run.java | 86 ++++++++++++++-------- 1 file changed, 54 insertions(+), 32 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java index 409f78307..0bdc70586 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java @@ -32,6 +32,7 @@ import java.awt.BorderLayout; import java.awt.Button; import java.awt.Component; import java.awt.Container; +import java.awt.EventQueue; import java.awt.event.KeyListener; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -44,6 +45,7 @@ import javax.media.opengl.GLProfile; import jogamp.nativewindow.jawt.JAWTUtil; +import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; @@ -105,12 +107,12 @@ public class JOGLNewtApplet1Run extends Applet { @Override public void init() { if(DEBUG) { - System.err.println("JOGLNewtApplet1Run.init() START"); + System.err.println("JOGLNewtApplet1Run.init() START - "+currentThreadName()); } if(!(this instanceof Container)) { throw new RuntimeException("This Applet is not a AWT Container"); } - final Container container = (Container) this; + final Container container = this; String glEventListenerClazzName=null; String glProfileName=null; @@ -192,10 +194,13 @@ public class JOGLNewtApplet1Run extends Applet { glWindow.setDefaultCloseOperation(glCloseable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE); container.setLayout(new BorderLayout()); if(appletDebugTestBorder) { - container.add(new Button("North"), BorderLayout.NORTH); - container.add(new Button("South"), BorderLayout.SOUTH); - container.add(new Button("East"), BorderLayout.EAST); - container.add(new Button("West"), BorderLayout.WEST); + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + container.add(new Button("North"), BorderLayout.NORTH); + container.add(new Button("South"), BorderLayout.SOUTH); + container.add(new Button("East"), BorderLayout.EAST); + container.add(new Button("West"), BorderLayout.WEST); + } } ); } base.init(glWindow); if(base.isValid()) { @@ -212,32 +217,43 @@ public class JOGLNewtApplet1Run extends Applet { } } if( !glStandalone ) { - newtCanvasAWT = new NewtCanvasAWT(glWindow); - container.add(newtCanvasAWT, BorderLayout.CENTER); - container.validate(); + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + newtCanvasAWT = new NewtCanvasAWT(glWindow); + container.add(newtCanvasAWT, BorderLayout.CENTER); + container.validate(); + } } ); } } catch (Throwable t) { throw new RuntimeException(t); } if(DEBUG) { - System.err.println("JOGLNewtApplet1Run.init() END"); + System.err.println("JOGLNewtApplet1Run.init() END - "+currentThreadName()); } } + private static String currentThreadName() { return "["+Thread.currentThread().getName()+", isAWT-EDT "+EventQueue.isDispatchThread()+"]"; } + @Override public void start() { if(DEBUG) { - System.err.println("JOGLNewtApplet1Run.start() START (isVisible "+isVisible()+", isDisplayable "+isDisplayable()+")"); + System.err.println("JOGLNewtApplet1Run.start() START (isVisible "+isVisible()+", isDisplayable "+isDisplayable()+") - "+currentThreadName()); } - this.setVisible(true); - final java.awt.Point p0 = this.getLocationOnScreen(); - if( null != newtCanvasAWT ) { - newtCanvasAWT.setFocusable(true); - newtCanvasAWT.requestFocus(); - } else { + final java.awt.Point[] p0 = { null }; + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + setVisible(true); + p0[0] = getLocationOnScreen(); + if( null != newtCanvasAWT ) { + newtCanvasAWT.setFocusable(true); + newtCanvasAWT.requestFocus(); + } + } + }); + if( null == newtCanvasAWT ) { glWindow.requestFocus(); glWindow.setSize(glWidth, glHeight); - glWindow.setPosition(p0.x+glXd, p0.y+glYd); + glWindow.setPosition(p0[0].x+glXd, p0[0].y+glYd); } if(DEBUG) { Component topC = this; @@ -258,43 +274,49 @@ public class JOGLNewtApplet1Run extends Applet { newtCanvasAWT.isOffscreenLayerSurfaceEnabled() && 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) { // force relayout - final int cW = newtCanvasAWT.getWidth(); - final int cH = newtCanvasAWT.getHeight(); - newtCanvasAWT.setSize(cW+1, cH+1); - newtCanvasAWT.setSize(cW, cH); + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + final int cW = newtCanvasAWT.getWidth(); + final int cH = newtCanvasAWT.getHeight(); + newtCanvasAWT.setSize(cW+1, cH+1); + newtCanvasAWT.setSize(cW, cH); + } } ); } if(DEBUG) { - System.err.println("JOGLNewtApplet1Run.start() END"); + System.err.println("JOGLNewtApplet1Run.start() END - "+currentThreadName()); } } @Override public void stop() { if(DEBUG) { - System.err.println("JOGLNewtApplet1Run.stop() START"); + System.err.println("JOGLNewtApplet1Run.stop() START - "+currentThreadName()); } base.stop(); if(DEBUG) { - System.err.println("JOGLNewtApplet1Run.stop() END"); + System.err.println("JOGLNewtApplet1Run.stop() END - "+currentThreadName()); } } @Override public void destroy() { if(DEBUG) { - System.err.println("JOGLNewtApplet1Run.destroy() START"); - } - glWindow.setVisible(false); // hide 1st - if( null != newtCanvasAWT ) { - glWindow.reparentWindow(null); // get out of newtCanvasAWT - this.remove(newtCanvasAWT); // remove newtCanvasAWT + System.err.println("JOGLNewtApplet1Run.destroy() START - "+currentThreadName()); } + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + glWindow.setVisible(false); // hide 1st + if( null != newtCanvasAWT ) { + remove(newtCanvasAWT); // remove newtCanvasAWT incl. glWindow.reparentWindow(null) if not done yet! + newtCanvasAWT.destroy(); + } + } } ); base.destroy(); // destroy glWindow unrecoverable base=null; glWindow=null; newtCanvasAWT=null; if(DEBUG) { - System.err.println("JOGLNewtApplet1Run.destroy() END"); + System.err.println("JOGLNewtApplet1Run.destroy() END - "+currentThreadName()); } } } -- cgit v1.2.3 From fa1d211c9658ce209f411e559333da0e2fccd402 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 23 Nov 2013 16:59:27 +0100 Subject: JOGLNewtAppletBase's add/remove 'reparentHome WindowListener' at start()/stop() --- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 41 +++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 2c4f25804..4a2878e3a 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -162,26 +162,6 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { public void init(ThreadGroup tg, final GLWindow glWindow) { isValid = false; this.glWindow = glWindow; - this.glWindow.addWindowListener(new WindowAdapter() { - // Closing action: back to parent! - @Override - public void windowDestroyNotify(WindowEvent e) { - if( isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() && - null == glWindow.getParent() && null != awtParent && 0 != awtParent.getWindowHandle() ) - { - Thread.dumpStack(); - // we may be called directly by the native EDT - new Thread(new Runnable() { - @Override - public void run() { - if( glWindow.isNativeValid() && null != awtParent && 0 != awtParent.getWindowHandle() ) { - glWindow.reparentWindow(awtParent); - } - } - }).start(); - } - } } ); - glEventListener = createInstance(glEventListenerClazzName); if(null == glEventListener) { return; @@ -226,17 +206,38 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { isValid = true; } + private final WindowListener reparentHomeListener = new WindowAdapter() { + // Closing action: back to parent! + @Override + public void windowDestroyNotify(WindowEvent e) { + if( isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() && + null == glWindow.getParent() && null != awtParent && 0 != awtParent.getWindowHandle() ) + { + // we may be called directly by the native EDT + new Thread(new Runnable() { + @Override + public void run() { + if( glWindow.isNativeValid() && null != awtParent && 0 != awtParent.getWindowHandle() ) { + glWindow.reparentWindow(awtParent); + } + } + }).start(); + } + } }; + public void start() { if(isValid) { glWindow.setVisible(true); glWindow.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); glAnimator.start(); awtParent = glWindow.getParent(); + glWindow.addWindowListener(reparentHomeListener); } } public void stop() { if(null!=glAnimator) { + glWindow.removeWindowListener(reparentHomeListener); glAnimator.stop(); glWindow.setVisible(false); } -- cgit v1.2.3 From 0c3709ba4ba2dd4ba7bb2e7f0783fba346e090e1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 23 Nov 2013 17:01:09 +0100 Subject: Workaround Bug 910 (IcedTea-Web): NewtCanvasAWT shall postpone JAWTWindow destruction if removeNotify() is called from non AWT-EDT --- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 117 ++++++++++++++++----- 1 file changed, 88 insertions(+), 29 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 749002b0f..9c66daf1c 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -29,6 +29,7 @@ package com.jogamp.newt.awt; +import java.applet.Applet; import java.awt.AWTKeyStroke; import java.awt.Canvas; import java.awt.Component; @@ -97,6 +98,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final Object sync = new Object(); private JAWTWindow jawtWindow = null; + private boolean isApplet = false; private boolean shallUseOffscreenLayer = false; private Window newtChild = null; private boolean newtChildAttached = false; @@ -106,16 +108,26 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final AWTAdapter awtMouseAdapter; private final AWTAdapter awtKeyAdapter; + /** Mitigates Bug 910 (IcedTea-Web), i.e. crash via removeNotify() from 'other' AWT-EDT. */ + private boolean addedOnAWTEDT = false; + /** Mitigates Bug 910 (IcedTea-Web), i.e. crash via removeNotify() from 'other' AWT-EDT. */ + private boolean destroyJAWTPending = false; + + /** Safeguard for AWTWindowClosingProtocol and 'removeNotify()' on other thread than AWT-EDT. */ + private volatile boolean componentAdded = false; + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override public void run() { - NewtCanvasAWT.this.destroyImpl(false /* removeNotify */, true /* windowClosing */); + if( componentAdded ) { + NewtCanvasAWT.this.destroyImpl(false /* removeNotify */, true /* windowClosing */); + } } }, new Runnable() { @Override public void run() { - if( newtChild != null ) { + if( componentAdded && newtChild != null ) { newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); } } @@ -185,20 +197,20 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto /** * Returns true if the AWT component is parented to an {@link java.applet.Applet}, - * otherwise false. This information is valid only after {@link #addNotify()} is issued, - * ie. before adding the component to the AWT tree and make it visible. + * otherwise false. This information is valid only after {@link #addNotify()} is issued. */ - public boolean isApplet() { - final JAWTWindow w = jawtWindow; - return null != w && w.isApplet(); + public final boolean isApplet() { + return isApplet; } - boolean isParent() { - return null!=newtChild && jawtWindow == newtChild.getParent(); + private final boolean isParent() { + final Window nw = newtChild; + return null!=nw && jawtWindow == nw.getParent(); } - boolean isFullscreen() { - return null != newtChild && newtChild.isFullscreen(); + private final boolean isFullscreen() { + final Window nw = newtChild; + return null != nw && nw.isFullscreen(); } class FocusAction implements Window.FocusRunnable { @@ -413,6 +425,15 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto return awtWindowClosingProtocol.setDefaultCloseOperation(op); } + private final void determineIfApplet() { + isApplet = false; + Component c = this; + while(!isApplet && null != c) { + isApplet = c instanceof Applet; + c = c.getParent(); + } + } + @Override public void addNotify() { if( Beans.isDesignTime() ) { @@ -428,30 +449,43 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto disableBackgroundErase(); synchronized(sync) { - jawtWindow = NewtFactoryAWT.getNativeWindow(this, null != newtChild ? newtChild.getRequestedCapabilities() : null); + determineIfApplet(); + addedOnAWTEDT = EventQueue.isDispatchThread(); + if(DEBUG) { + System.err.println("NewtCanvasAWT.addNotify.0 - isApplet "+isApplet+", addedOnAWTEDT "+addedOnAWTEDT+" @ "+currentThreadName()); + Thread.dumpStack(); + } + jawtWindow = NewtFactoryAWT.getNativeWindow(NewtCanvasAWT.this, null != newtChild ? newtChild.getRequestedCapabilities() : null); jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); - + awtWindowClosingProtocol.addClosingListener(); + componentAdded = true; // Bug 910 if(DEBUG) { // if ( isShowing() == false ) -> Container was not visible yet. // if ( isShowing() == true ) -> Container is already visible. - System.err.println("NewtCanvasAWT.addNotify: win "+newtWinHandleToHexString(newtChild)+ + System.err.println("NewtCanvasAWT.addNotify.X: twin "+newtWinHandleToHexString(newtChild)+ ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+ ", displayable "+isDisplayable()+", cont "+AWTMisc.getContainer(this)); } } } - awtWindowClosingProtocol.addClosingListener(); } @Override public void removeNotify() { - awtWindowClosingProtocol.removeClosingListener(); - if( Beans.isDesignTime() ) { super.removeNotify(); } else { + if(DEBUG) { + System.err.println("NewtCanvasAWT.removeNotify.0 - isApplet "+isApplet+" @ "+currentThreadName()); + Thread.dumpStack(); + } + componentAdded = false; // Bug 910 + awtWindowClosingProtocol.removeClosingListener(); destroyImpl(true /* removeNotify */, false /* windowClosing */); super.removeNotify(); + if(DEBUG) { + System.err.println("NewtCanvasAWT.removeNotify.X @ "+currentThreadName()); + } } } @@ -466,6 +500,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto * @see Window#destroy() */ public final void destroy() { + if(DEBUG) { + System.err.println("NewtCanvasAWT.destroy() @ "+currentThreadName()); + Thread.dumpStack(); + } AWTEDTExecutor.singleton.invoke(true, new Runnable() { @Override public void run() { @@ -475,11 +513,24 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final void destroyImpl(boolean removeNotify, boolean windowClosing) { synchronized(sync) { + final java.awt.Container cont = AWTMisc.getContainer(this); + /** + * Mitigates Bug 910 (IcedTea-Web), i.e. crash via removeNotify() from 'other' AWT-EDT. + * + * 'destroyJAWT' defaults to 'true' - however, IcedTea-Web (Applet) issues removeNotify() from + * a different AWT-EDT thread, which is not recognized as an AWT-EDT thread! + * This 'different AWT-EDT thread' maybe caused due to a AppContext issue in IcedTea-Web. + */ + final boolean isOnAWTEDT = EventQueue.isDispatchThread(); + final boolean destroyJAWTOK = !isApplet || !addedOnAWTEDT || isOnAWTEDT; + if(DEBUG) { + System.err.println("NewtCanvasAWT.destroyImpl @ "+currentThreadName()); + System.err.println("NewtCanvasAWT.destroyImpl.0 - isApplet "+isApplet+", addedOnAWTEDT "+addedOnAWTEDT+", isOnAWTEDT "+isOnAWTEDT+" -> destroyJAWTOK "+destroyJAWTOK+ + "; removeNotify "+removeNotify+", windowClosing "+windowClosing+", destroyJAWTPending "+destroyJAWTPending+ + ", hasJAWT "+(null!=jawtWindow)+", hasNEWT "+(null!=newtChild)+ + "): nw "+newtWinHandleToHexString(newtChild)+", from "+cont); + } if( null !=newtChild ) { - java.awt.Container cont = AWTMisc.getContainer(this); - if(DEBUG) { - System.err.println("NewtCanvasAWT.destroy(removeNotify "+removeNotify+", windowClosing "+windowClosing+"): nw "+newtWinHandleToHexString(newtChild)+", from "+cont); - } detachNewtChild(cont); if( !removeNotify ) { @@ -493,9 +544,16 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } } - if( ( removeNotify || windowClosing ) && null!=jawtWindow ) { - NewtFactoryAWT.destroyNativeWindow(jawtWindow); - jawtWindow=null; + if( ( destroyJAWTPending || removeNotify || windowClosing ) && null!=jawtWindow ) { + if( destroyJAWTOK ) { + NewtFactoryAWT.destroyNativeWindow(jawtWindow); + jawtWindow=null; + destroyJAWTPending = false; + } else { + // Bug 910 - See above FIXME + destroyJAWTPending = true; + System.err.println("Info: JAWT destruction pending due to: isApplet "+isApplet+", addedOnAWTEDT "+addedOnAWTEDT+", isOnAWTEDT "+isOnAWTEDT+" -> destroyJAWTOK "+destroyJAWTOK); + } } } } @@ -555,14 +613,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto synchronized(sync) { if( !validateComponent(true) ) { if(DEBUG) { - System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); + System.err.println(currentThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); } printActive = false; return; // not yet available .. } if( !isVisible() ) { if(DEBUG) { - System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); + System.err.println(currentThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); } printActive = false; return; // not yet available .. @@ -665,7 +723,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto throw new IllegalStateException("setupPrint() not called"); } if(DEBUG && !EventQueue.isDispatchThread()) { - System.err.println(getThreadName()+": Warning: GLCanvas print - not called from AWT-EDT"); + System.err.println(currentThreadName()+": Warning: GLCanvas print - not called from AWT-EDT"); // we cannot dispatch print on AWT-EDT due to printing internal locking .. } @@ -787,7 +845,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { // if ( isShowing() == false ) -> Container was not visible yet. // if ( isShowing() == true ) -> Container is already visible. - System.err.println("NewtCanvasAWT.attachNewtChild.0 @ "+Thread.currentThread().getName()+": win "+newtWinHandleToHexString(newtChild)+ + System.err.println("NewtCanvasAWT.attachNewtChild.0 @ "+currentThreadName()); + System.err.println("\twin "+newtWinHandleToHexString(newtChild)+ ", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+ ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+", displayable "+isDisplayable()+ ", cont "+AWTMisc.getContainer(this)); @@ -913,7 +972,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } - protected static String getThreadName() { return Thread.currentThread().getName(); } + protected static String currentThreadName() { return "["+Thread.currentThread().getName()+", isAWT-EDT "+EventQueue.isDispatchThread()+"]"; } static String newtWinHandleToHexString(Window w) { return null != w ? toHexString(w.getWindowHandle()) : "nil"; -- cgit v1.2.3 From 5db2c65cd030311b5cfcb8174ada6e870db10258 Mon Sep 17 00:00:00 2001 From: Petros Koutsolampros Date: Sun, 24 Nov 2013 22:46:58 +0000 Subject: Bug 672 (NewtCanvasSWT ignore windowing offset on OSX'). The NewtCanvasSWT is now brought into place by the parent SWT Composite and the super SWT Canvas it extends. Also added two test cases. One with a simple SashForm and the NewtCanvasSWT in the second cell, and another with the NewtCanvasSWT in a Composite, that Composite now in the second cell of the SashForm. The second test is necessary because the NewtCanvasSWT does not receive SWT.Resize events in this configuration, but only SWT.Paint ones (a behaviour inherited from the super SWT Canvas) --- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 7 +- .../es2/newt/Bug672NewtCanvasSWTSashForm.java | 392 ++++++++++++++++++++ .../newt/Bug672NewtCanvasSWTSashFormComposite.java | 394 +++++++++++++++++++++ 3 files changed, 792 insertions(+), 1 deletion(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/Bug672NewtCanvasSWTSashForm.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/Bug672NewtCanvasSWTSashFormComposite.java (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index e63a53524..029cee3da 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -145,6 +145,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { newtChild.setSize(clientArea.width, clientArea.height); postSetSize = false; } + if( isOSX ) newtChild.setPosition(parent.getLocation().x,parent.getLocation().y); newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height); } } @@ -252,6 +253,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { super.dispose(); } + private Rectangle getSWTCanvasPosition() { + return super.getBounds(); + } /** @return this SWT Canvas NativeWindow representation, may be null in case it has not been realized. */ public NativeWindow getNativeWindow() { return nativeWindow; } @@ -500,7 +504,8 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { if( isOSX ) { final Point los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); // top-level position -> client window position - los.set(los.getX() + insets.getLeftWidth(), los.getY() + insets.getTopHeight()); + final Rectangle swtCanvasPosition = getSWTCanvasPosition(); + los.set(swtCanvasPosition.x + los.getX() + insets.getLeftWidth(), swtCanvasPosition.y + los.getY() + insets.getTopHeight()); if(null!=point) { return point.translate(los); } else { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/Bug672NewtCanvasSWTSashForm.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/Bug672NewtCanvasSWTSashForm.java new file mode 100644 index 000000000..30c2b8446 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/Bug672NewtCanvasSWTSashForm.java @@ -0,0 +1,392 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.es2.newt; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import com.jogamp.nativewindow.swt.SWTAccessor; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.event.KeyAdapter; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.swt.NewtCanvasSWT; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.util.QuitAdapter; + +import com.jogamp.opengl.util.Animator; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; + +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.PointImmutable; +import javax.media.nativewindow.util.DimensionImmutable; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLProfile; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.junit.After; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class Bug672NewtCanvasSWTSashForm extends UITestCase { + static int screenIdx = 0; + static PointImmutable wpos; + static DimensionImmutable wsize, rwsize = null; + + static long duration = 500; // ms + static boolean opaque = true; + static int forceAlpha = -1; + static boolean fullscreen = false; + static boolean pmvUseBackingArray = true; + static int swapInterval = 1; + static boolean showFPS = false; + static int loops = 1; + static boolean loop_shutdown = false; + static boolean forceES2 = false; + static boolean forceGL3 = false; + static boolean mainRun = false; + static boolean exclusiveContext = false; + + @BeforeClass + public static void initClass() { + setTestSupported(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)); + if(null == wsize) { + wsize = new Dimension(640, 480); + } + } + + @AfterClass + public static void releaseClass() { + } + + Display display = null; + Shell shell = null; + Composite composite = null; + com.jogamp.newt.Display swtNewtDisplay = null; + + @Before + public void init() { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display = new Display(); + Assert.assertNotNull( display ); + }}); + display.syncExec(new Runnable() { + public void run() { + shell = new Shell( display ); + Assert.assertNotNull( shell ); + shell.setLayout( new FillLayout() ); + composite = new Composite( shell, SWT.NONE ); + composite.setLayout( new FillLayout() ); + Assert.assertNotNull( composite ); + }}); + swtNewtDisplay = NewtFactory.createDisplay(null, false); // no-reuse + } + + @After + public void release() { + Assert.assertNotNull( display ); + Assert.assertNotNull( shell ); + Assert.assertNotNull( composite ); + try { + display.syncExec(new Runnable() { + public void run() { + composite.dispose(); + shell.dispose(); + }}); + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display.dispose(); + }}); + } + catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + swtNewtDisplay = null; + display = null; + shell = null; + composite = null; + } + + protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException, InvocationTargetException { + System.err.println("requested: vsync "+swapInterval+", "+caps); + com.jogamp.newt.Screen screen = NewtFactory.createScreen(swtNewtDisplay, screenIdx); + final GLWindow glWindow = GLWindow.create(screen, caps); + Assert.assertNotNull(glWindow); + + final GearsES2 demo = new GearsES2(swapInterval); + demo.setPMVUseBackingArray(pmvUseBackingArray); + glWindow.addGLEventListener(demo); + + Animator animator = new Animator(); + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + animator.setExclusiveContext(exclusiveContext); + + QuitAdapter quitAdapter = new QuitAdapter(); + //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); + //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + glWindow.addKeyListener(quitAdapter); + glWindow.addWindowListener(quitAdapter); + + glWindow.addWindowListener(new WindowAdapter() { + public void windowResized(WindowEvent e) { + System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + public void windowMoved(WindowEvent e) { + System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + }); + + glWindow.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } + if(e.getKeyChar()=='f') { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); + glWindow.setFullscreen(!glWindow.isFullscreen()); + System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } + } + }); + + animator.add(glWindow); + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread()); + final SashForm sash = new SashForm(composite, SWT.NONE); + org.eclipse.swt.widgets.Label c = new org.eclipse.swt.widgets.Label(sash, SWT.NONE); + c.setText("Left cell"); + final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( sash, 0, glWindow ); + Assert.assertNotNull( canvas1 ); + + display.syncExec( new Runnable() { + public void run() { + shell.setText( getSimpleTestName(".") ); + shell.setSize( wsize.getWidth(), wsize.getHeight() ); + if( null != wpos ) { + shell.setLocation( wpos.getX(), wpos.getY() ); + } + shell.open(); + } + }); + + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); + System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); + System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + + if( null != rwsize ) { + for(int i=0; i<50; i++) { // 500 ms dispatched delay + if( !display.readAndDispatch() ) { + // blocks on linux .. display.sleep(); + Thread.sleep(10); + } + } + display.syncExec( new Runnable() { + public void run() { + shell.setSize( rwsize.getWidth(), rwsize.getHeight() ); + } + }); + System.err.println("window resize pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + } + + Assert.assertNotNull( canvas1.getNativeWindow() ); + Assert.assertNotEquals( canvas1.getNativeWindow().getLocationOnScreen(null), 0 ); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() 0 ); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() Date: Mon, 25 Nov 2013 04:25:04 +0100 Subject: Bug 672 (NewtCanvasSWT): Reuse SWTAccessor.isOS_TYPE ; Impl NW.getLocationOnScreen(..) for X11 and Windows ; Allow unit test to run on all platforms. - Reuse SWTAccessor.isOS_TYPE (public now) - Impl NW.getLocationOnScreen(..) for X11 and Windows reusing existing native code - Allow unit test to run on all platforms. Note: NewtCanvasSWT unit tests require a 'wait for realized' while SWT dispatching. Otherwise the 'sash unit test' will fail since realiziation happens later, at least on X11. Hence extended AWTRobotUtil.waitForRealized(..) to use a 'waitAction' which is used here w/ special SWT dispatch Runnable. AWTRobotUtil.waitForRealized(..) operates on time-delta instead of iteration-counter, allowing above 'waitAction' Runnable. AWTRobotUtil.waitForRealized(..) removed 2nd 'glad.isRealized()' loop .. --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 8 +- .../com/jogamp/nativewindow/swt/SWTAccessor.java | 8 +- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 42 ++-- .../jogl/swt/TestBug672NewtCanvasSWTSashForm.java | 210 +++++++------------- .../TestBug672NewtCanvasSWTSashFormComposite.java | 219 ++++++++------------- .../TestNewtCanvasSWTBug628ResizeDeadlockAWT.java | 20 +- .../test/junit/jogl/swt/TestNewtCanvasSWTGLn.java | 74 ++++--- .../opengl/test/junit/util/AWTRobotUtil.java | 82 ++++++-- 9 files changed, 320 insertions(+), 347 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index d0bae1b4b..a8ef44cce 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -13,7 +13,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGea REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* @@ -146,6 +146,8 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashForm %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashFormComposite %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 809aceb0c..a27def007 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -204,7 +204,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl" - D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.DebugGL" + #D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.DebugGL" #D_ARGS="-Djogl.gljpanel.noverticalflip" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" @@ -529,7 +529,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelTextureStateAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* @@ -542,7 +542,9 @@ testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT $* # #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -#testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashForm $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashFormComposite $* # # awtswt (testawtswt) diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 361d61c65..36bf646d5 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -63,10 +63,10 @@ public class SWTAccessor { private static Field swt_osx_view_id = null; private static final String nwt; - private static final boolean isOSX; - private static final boolean isWindows; - private static final boolean isX11; - private static final boolean isX11GTK; + public static final boolean isOSX; + public static final boolean isWindows; + public static final boolean isX11; + public static final boolean isX11GTK; // X11/GTK, Windows/GDI, .. private static final String str_handle = "handle"; diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 029cee3da..5ed8d9e63 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -46,6 +46,8 @@ import javax.media.nativewindow.util.Point; import javax.media.opengl.GLCapabilities; import jogamp.nativewindow.macosx.OSXUtil; +import jogamp.nativewindow.windows.GDIUtil; +import jogamp.nativewindow.x11.X11Lib; import jogamp.newt.Debug; import jogamp.newt.swt.SWTEDTUtil; @@ -70,7 +72,6 @@ import com.jogamp.newt.util.EDTUtil; */ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("Window"); - private static final boolean isOSX = NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false); private final AbstractGraphicsScreen screen; @@ -145,7 +146,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { newtChild.setSize(clientArea.width, clientArea.height); postSetSize = false; } - if( isOSX ) newtChild.setPosition(parent.getLocation().x,parent.getLocation().y); + if( SWTAccessor.isOSX ) { + newtChild.setPosition(parent.getLocation().x,parent.getLocation().y); + } newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height); } } @@ -398,7 +401,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { public SWTNativeWindow(AbstractGraphicsConfiguration config, long nativeWindowHandle) { this.config = config; this.nativeWindowHandle = nativeWindowHandle; - if(isOSX) { + if( SWTAccessor.isOSX ) { this.insets = OSXUtil.GetInsets(nativeWindowHandle); } else { this.insets = new Insets(0, 0, 0, 0); @@ -501,22 +504,25 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { @Override public Point getLocationOnScreen(Point point) { - if( isOSX ) { - final Point los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); - // top-level position -> client window position - final Rectangle swtCanvasPosition = getSWTCanvasPosition(); - los.set(swtCanvasPosition.x + los.getX() + insets.getLeftWidth(), swtCanvasPosition.y + los.getY() + insets.getTopHeight()); - if(null!=point) { - return point.translate(los); - } else { - return los; - } + final Point los; // client window location on screen + if( SWTAccessor.isOSX ) { + los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); + // top-level position -> client window position: OSX needs to add SWT parent position incl. insets + final Rectangle swtCanvasPosition = getSWTCanvasPosition(); + los.translate(swtCanvasPosition.x + insets.getLeftWidth(), swtCanvasPosition.y + insets.getTopHeight()); + } else if (SWTAccessor.isX11) { + final AbstractGraphicsScreen s = config.getScreen(); + los = X11Lib.GetRelativeLocation(s.getDevice().getHandle(), s.getIndex(), nativeWindowHandle, 0 /*root win*/, 0, 0); + } else if (SWTAccessor.isWindows) { + los = GDIUtil.GetRelativeLocation( nativeWindowHandle, 0 /*root win*/, 0, 0); } else { - // client position on 'normal' windowing systems is 0/0 - if(null == point) { - point = new Point(0, 0); - } - return point; + // fall-back to 0/0 + los = new Point(0, 0); + } + if(null!=point) { + return point.translate(los); + } else { + return los; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java index f6f8918a3..4b7537655 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.swt; import java.io.IOException; @@ -43,17 +43,13 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; - import com.jogamp.opengl.util.Animator; - import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.util.Dimension; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; import javax.media.nativewindow.util.DimensionImmutable; - import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLProfile; @@ -75,28 +71,15 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBug672NewtCanvasSWTSashForm extends UITestCase { +public class TestBug672NewtCanvasSWTSashForm extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; static DimensionImmutable wsize, rwsize = null; static long duration = 500; // ms - static boolean opaque = true; - static int forceAlpha = -1; - static boolean fullscreen = false; - static boolean pmvUseBackingArray = true; - static int swapInterval = 1; - static boolean showFPS = false; - static int loops = 1; - static boolean loop_shutdown = false; - static boolean forceES2 = false; - static boolean forceGL3 = false; - static boolean mainRun = false; - static boolean exclusiveContext = false; - + @BeforeClass public static void initClass() { - setTestSupported(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)); if(null == wsize) { wsize = new Dimension(640, 480); } @@ -109,23 +92,28 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { Display display = null; Shell shell = null; Composite composite = null; + SashForm sash = null; com.jogamp.newt.Display swtNewtDisplay = null; - + @Before public void init() { SWTAccessor.invoke(true, new Runnable() { - public void run() { + public void run() { display = new Display(); Assert.assertNotNull( display ); }}); display.syncExec(new Runnable() { - public void run() { + public void run() { shell = new Shell( display ); Assert.assertNotNull( shell ); shell.setLayout( new FillLayout() ); composite = new Composite( shell, SWT.NONE ); composite.setLayout( new FillLayout() ); Assert.assertNotNull( composite ); + sash = new SashForm(composite, SWT.NONE); + Assert.assertNotNull( sash ); + final org.eclipse.swt.widgets.Label c = new org.eclipse.swt.widgets.Label(sash, SWT.NONE); + c.setText("Left cell"); }}); swtNewtDisplay = NewtFactory.createDisplay(null, false); // no-reuse } @@ -135,9 +123,11 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { Assert.assertNotNull( display ); Assert.assertNotNull( shell ); Assert.assertNotNull( composite ); + Assert.assertNotNull( sash ); try { display.syncExec(new Runnable() { public void run() { + sash.dispose(); composite.dispose(); shell.dispose(); }}); @@ -154,22 +144,38 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { display = null; shell = null; composite = null; + sash = null; + } + + class WaitAction implements Runnable { + private final long sleepMS; + + WaitAction(long sleepMS) { + this.sleepMS = sleepMS; + } + public void run() { + if( !display.readAndDispatch() ) { + // blocks on linux .. display.sleep(); + try { + Thread.sleep(sleepMS); + } catch (InterruptedException e) { } + } + } } - + final WaitAction awtRobotWaitAction = new WaitAction(AWTRobotUtil.TIME_SLICE); + final WaitAction generalWaitAction = new WaitAction(10); + protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException, InvocationTargetException { - System.err.println("requested: vsync "+swapInterval+", "+caps); com.jogamp.newt.Screen screen = NewtFactory.createScreen(swtNewtDisplay, screenIdx); final GLWindow glWindow = GLWindow.create(screen, caps); Assert.assertNotNull(glWindow); - - final GearsES2 demo = new GearsES2(swapInterval); - demo.setPMVUseBackingArray(pmvUseBackingArray); + + final GearsES2 demo = new GearsES2(1); glWindow.addGLEventListener(demo); - + Animator animator = new Animator(); animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); - animator.setExclusiveContext(exclusiveContext); - + QuitAdapter quitAdapter = new QuitAdapter(); //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); @@ -182,14 +188,14 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { } public void windowMoved(WindowEvent e) { System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); - } + } }); - + glWindow.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; - } + } if(e.getKeyChar()=='f') { new Thread() { public void run() { @@ -207,10 +213,7 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { animator.start(); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); - Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread()); - final SashForm sash = new SashForm(composite, SWT.NONE); - org.eclipse.swt.widgets.Label c = new org.eclipse.swt.widgets.Label(sash, SWT.NONE); - c.setText("Left cell"); + animator.setUpdateFPSFrames(60, null); final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( sash, 0, glWindow ); Assert.assertNotNull( canvas1 ); @@ -224,116 +227,68 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { shell.open(); } }); - - animator.setUpdateFPSFrames(60, showFPS ? System.err : null); - + Assert.assertTrue("GLWindow didn't become visible natively!", AWTRobotUtil.waitForRealized(glWindow, awtRobotWaitAction, true)); + Assert.assertNotNull( canvas1.getNativeWindow() ); + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); - System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); - + System.err.println("window pos/siz.0: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + System.err.println("GLWindow LOS.0: "+glWindow.getLocationOnScreen(null)); + System.err.println("NewtCanvasSWT LOS.0: "+canvas1.getNativeWindow().getLocationOnScreen(null)); + if( null != rwsize ) { for(int i=0; i<50; i++) { // 500 ms dispatched delay - if( !display.readAndDispatch() ) { - // blocks on linux .. display.sleep(); - Thread.sleep(10); - } + generalWaitAction.run(); } display.syncExec( new Runnable() { public void run() { shell.setSize( rwsize.getWidth(), rwsize.getHeight() ); } }); - System.err.println("window resize pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + System.err.println("window resize pos/siz.1: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + System.err.println("GLWindow LOS.1: "+glWindow.getLocationOnScreen(null)); + System.err.println("NewtCanvasSWT LOS.1: "+canvas1.getNativeWindow().getLocationOnScreen(null)); } - - Assert.assertNotNull( canvas1.getNativeWindow() ); - Assert.assertNotEquals( canvas1.getNativeWindow().getLocationOnScreen(null), 0 ); - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()= sash-right "+pSashRightClient, pNatWinLOS.compareTo(pSashRightClient) >= 0 ); + Assert.assertTrue( "GLWindow LOS "+pGLWinLOS+" not >= sash-right "+pSashRightClient, pGLWinLOS.compareTo(pSashRightClient) >= 0 ); + + while( !quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() 0 ); - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()= sash-right "+pSashRightClient, pNatWinLOS.compareTo(pSashRightClient) >= 0 ); + Assert.assertTrue( "GLWindow LOS "+pGLWinLOS+" not >= sash-right "+pSashRightClient, pGLWinLOS.compareTo(pSashRightClient) >= 0 ); + + while( !quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() + * _and_ custom GLCapabilities. + *

                      * Uses JOGL's NewtCanvasSWT, which allows to be a native container of a NEWT Window.
                      * This method allows utilizing custom GLCapability settings, * independent from the already instantiated SWT visual. *

                      *

                      - * Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/ + * Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/ * SWT running on Mac OSX, i.e. to enforce UI action on the main thread. *

                      */ @@ -87,7 +87,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase { Shell shell = null; Composite composite = null; com.jogamp.newt.Display swtNewtDisplay = null; - + @BeforeClass public static void startup() { System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() ); @@ -96,12 +96,12 @@ public class TestNewtCanvasSWTGLn extends UITestCase { @Before public void init() { SWTAccessor.invoke(true, new Runnable() { - public void run() { + public void run() { display = new Display(); Assert.assertNotNull( display ); }}); display.syncExec(new Runnable() { - public void run() { + public void run() { shell = new Shell( display ); Assert.assertNotNull( shell ); shell.setLayout( new FillLayout() ); @@ -138,10 +138,28 @@ public class TestNewtCanvasSWTGLn extends UITestCase { composite = null; } - protected void runTestAGL( GLCapabilitiesImmutable caps, GLEventListener demo, + class WaitAction implements Runnable { + private final long sleepMS; + + WaitAction(long sleepMS) { + this.sleepMS = sleepMS; + } + public void run() { + if( !display.readAndDispatch() ) { + // blocks on linux .. display.sleep(); + try { + Thread.sleep(sleepMS); + } catch (InterruptedException e) { } + } + } + } + final WaitAction awtRobotWaitAction = new WaitAction(AWTRobotUtil.TIME_SLICE); + final WaitAction generalWaitAction = new WaitAction(10); + + protected void runTestAGL( GLCapabilitiesImmutable caps, GLEventListener demo, boolean postAttach, boolean useAnimator ) throws InterruptedException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); - + final Screen screen = NewtFactory.createScreen(swtNewtDisplay, 0); final GLWindow glWindow1 = GLWindow.create(screen, caps); Assert.assertNotNull(glWindow1); @@ -151,7 +169,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase { glWindow1.addGLEventListener(demo); glWindow1.addGLEventListener(new GLEventListener() { int displayCount = 0; - public void init(final GLAutoDrawable drawable) { } + public void init(final GLAutoDrawable drawable) { } public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { } public void display(final GLAutoDrawable drawable) { if(displayCount < 3) { @@ -159,8 +177,8 @@ public class TestNewtCanvasSWTGLn extends UITestCase { } } public void dispose(final GLAutoDrawable drawable) { } - }); - + }); + final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( composite, 0, postAttach ? null : glWindow1 ); Assert.assertNotNull( canvas1 ); @@ -171,13 +189,18 @@ public class TestNewtCanvasSWTGLn extends UITestCase { shell.open(); } }); - + if(postAttach) { canvas1.setNEWTChild(glWindow1); } - + + Assert.assertTrue("GLWindow didn't become visible natively!", AWTRobotUtil.waitForRealized(glWindow1, awtRobotWaitAction, true)); + + System.err.println("GLWindow LOS.0: "+glWindow1.getLocationOnScreen(null)); + System.err.println("NewtCanvasSWT LOS.0: "+canvas1.getNativeWindow().getLocationOnScreen(null)); + // canvas1.update(); - + Animator anim; if(useAnimator) { anim = new Animator(glWindow1); @@ -185,15 +208,12 @@ public class TestNewtCanvasSWTGLn extends UITestCase { } else { anim = null; } - + long lStartTime = System.currentTimeMillis(); long lEndTime = lStartTime + duration; try { while( (System.currentTimeMillis() < lEndTime) && !canvas1.isDisposed() ) { - if( !display.readAndDispatch() ) { - // blocks on linux .. display.sleep(); - Thread.sleep(10); - } + generalWaitAction.run(); } } catch( Throwable throwable ) { throwable.printStackTrace(); @@ -202,7 +222,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase { if(null != anim) { anim.stop(); } - + canvas1.dispose(); } @@ -220,7 +240,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase { public void postAttach_WithAnimator() throws InterruptedException { runTestAGL( new GLCapabilities(GLProfile.getGL2ES2()), new GearsES2(), true /* postAttach */, true /* animator */); } - + @Test public void test_MultisampleAndAlpha() throws InterruptedException { GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index cd14835bb..657936adc 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -682,53 +682,97 @@ public class AWTRobotUtil { } /** + * @param obj the component to wait for + * @param realized true if waiting for component to become realized, otherwise false * @return True if the Component becomes realized (not displayable, native invalid) within TIME_OUT + * @throws InterruptedException */ public static boolean waitForRealized(Object obj, boolean realized) throws InterruptedException { - int wait; + return waitForRealized(obj, null, realized); + } + + /** + * @param obj the component to wait for + * @param waitAction if not null, Runnable shall wait {@link #TIME_SLICE} ms, if appropriate + * @param realized true if waiting for component to become realized, otherwise false + * @return True if the Component becomes realized (not displayable, native invalid) within TIME_OUT + * @throws InterruptedException + */ + public static boolean waitForRealized(Object obj, Runnable waitAction, boolean realized) throws InterruptedException { + long t0 = System.currentTimeMillis(); + long t1 = t0; if(obj instanceof com.jogamp.newt.Screen) { com.jogamp.newt.Screen screen = (com.jogamp.newt.Screen) obj; - for (wait=0; wait drawable.setRealized(true); - if(wait=POLL_DIVIDER) { + if( (t1-t0) >= TIME_OUT ) { // for some reason GLCanvas hasn't been painted yet, force it! System.err.println("XXX: FORCE REPAINT PRE - glad: "+glad); comp.repaint(); - for (wait=0; wait Date: Mon, 25 Nov 2013 22:08:50 +0100 Subject: Workaround Bug 910 (IcedTea-Web): NewtCanvasAWT shall postpone JAWTWindow destruction via explicit set flag. IcedTea-Web_1.5pre+rbc73a1362e9c still issues NewtCanvasAWT.removeNotify() before before Applet.destroy(), i.e. removes NewtCanvasAWT from the Container ahead of time (Applet protocol destroy()). However, it fixes the non AWT-EDT issue, i.e. calls NewtCanvasAWT.removeNotify() from the actual AWT-EDT - good. Since the root cause still exist, we cannot use heuristics as described in Bug 910 comment 9, but need to set a flag in NewtCanvasAWT to skip JAWT destruction and remove it latter within Applet.destroy(). NewtCanvasAWT.removeNotify.0 - isApplet true @ [AWT-EventQueue-0, isAWT-EDT true] --- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 43 ++++++++++++---------- .../jogamp/newt/awt/applet/JOGLNewtApplet1Run.java | 2 + 2 files changed, 25 insertions(+), 20 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 9c66daf1c..b6b8cf9e8 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -108,10 +108,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final AWTAdapter awtMouseAdapter; private final AWTAdapter awtKeyAdapter; - /** Mitigates Bug 910 (IcedTea-Web), i.e. crash via removeNotify() from 'other' AWT-EDT. */ - private boolean addedOnAWTEDT = false; - /** Mitigates Bug 910 (IcedTea-Web), i.e. crash via removeNotify() from 'other' AWT-EDT. */ + /** Mitigates Bug 910 (IcedTea-Web), i.e. crash via removeNotify() invoked before Applet.destroy(). */ private boolean destroyJAWTPending = false; + /** Mitigates Bug 910 (IcedTea-Web), i.e. crash via removeNotify() invoked before Applet.destroy(). */ + private boolean skipJAWTDestroy = false; /** Safeguard for AWTWindowClosingProtocol and 'removeNotify()' on other thread than AWT-EDT. */ private volatile boolean componentAdded = false; @@ -425,6 +425,20 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto return awtWindowClosingProtocol.setDefaultCloseOperation(op); } + /** + * Mitigates Bug 910 (IcedTea-Web), i.e. crash via removeNotify() invoked before Applet.destroy(). + *

                      + * skipJAWTDestroy defaults to false. + * Due to above IcedTea-Web issue the Applet code needs to avoid JAWT destruction before + * Applet.destroy() is reached by setting skipJAWTDestroy to true. + * Afterwards the value should be reset to false and {@link #destroy()} needs to be called, + * which finally will perform the pending JAWT destruction. + *

                      + */ + public final void setSkipJAWTDestroy(boolean v) { skipJAWTDestroy = v; } + /** See {@link #setSkipJAWTDestroy(boolean)}. */ + public final boolean getSkipJAWTDestroy() { return skipJAWTDestroy; } + private final void determineIfApplet() { isApplet = false; Component c = this; @@ -450,9 +464,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto synchronized(sync) { determineIfApplet(); - addedOnAWTEDT = EventQueue.isDispatchThread(); if(DEBUG) { - System.err.println("NewtCanvasAWT.addNotify.0 - isApplet "+isApplet+", addedOnAWTEDT "+addedOnAWTEDT+" @ "+currentThreadName()); + System.err.println("NewtCanvasAWT.addNotify.0 - isApplet "+isApplet+", addedOnAWTEDT "+EventQueue.isDispatchThread()+" @ "+currentThreadName()); Thread.dumpStack(); } jawtWindow = NewtFactoryAWT.getNativeWindow(NewtCanvasAWT.this, null != newtChild ? newtChild.getRequestedCapabilities() : null); @@ -514,18 +527,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final void destroyImpl(boolean removeNotify, boolean windowClosing) { synchronized(sync) { final java.awt.Container cont = AWTMisc.getContainer(this); - /** - * Mitigates Bug 910 (IcedTea-Web), i.e. crash via removeNotify() from 'other' AWT-EDT. - * - * 'destroyJAWT' defaults to 'true' - however, IcedTea-Web (Applet) issues removeNotify() from - * a different AWT-EDT thread, which is not recognized as an AWT-EDT thread! - * This 'different AWT-EDT thread' maybe caused due to a AppContext issue in IcedTea-Web. - */ - final boolean isOnAWTEDT = EventQueue.isDispatchThread(); - final boolean destroyJAWTOK = !isApplet || !addedOnAWTEDT || isOnAWTEDT; if(DEBUG) { System.err.println("NewtCanvasAWT.destroyImpl @ "+currentThreadName()); - System.err.println("NewtCanvasAWT.destroyImpl.0 - isApplet "+isApplet+", addedOnAWTEDT "+addedOnAWTEDT+", isOnAWTEDT "+isOnAWTEDT+" -> destroyJAWTOK "+destroyJAWTOK+ + System.err.println("NewtCanvasAWT.destroyImpl.0 - isApplet "+isApplet+", isOnAWTEDT "+EventQueue.isDispatchThread()+", skipJAWTDestroy "+skipJAWTDestroy+ "; removeNotify "+removeNotify+", windowClosing "+windowClosing+", destroyJAWTPending "+destroyJAWTPending+ ", hasJAWT "+(null!=jawtWindow)+", hasNEWT "+(null!=newtChild)+ "): nw "+newtWinHandleToHexString(newtChild)+", from "+cont); @@ -545,14 +549,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } if( ( destroyJAWTPending || removeNotify || windowClosing ) && null!=jawtWindow ) { - if( destroyJAWTOK ) { + if( skipJAWTDestroy ) { + // Bug 910 - See setSkipJAWTDestroy(boolean) + destroyJAWTPending = true; + } else { NewtFactoryAWT.destroyNativeWindow(jawtWindow); jawtWindow=null; destroyJAWTPending = false; - } else { - // Bug 910 - See above FIXME - destroyJAWTPending = true; - System.err.println("Info: JAWT destruction pending due to: isApplet "+isApplet+", addedOnAWTEDT "+addedOnAWTEDT+", isOnAWTEDT "+isOnAWTEDT+" -> destroyJAWTOK "+destroyJAWTOK); } } } diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java index 0bdc70586..74d4d833a 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java @@ -220,6 +220,7 @@ public class JOGLNewtApplet1Run extends Applet { AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { newtCanvasAWT = new NewtCanvasAWT(glWindow); + newtCanvasAWT.setSkipJAWTDestroy(true); // Bug 910 container.add(newtCanvasAWT, BorderLayout.CENTER); container.validate(); } } ); @@ -307,6 +308,7 @@ public class JOGLNewtApplet1Run extends Applet { public void run() { glWindow.setVisible(false); // hide 1st if( null != newtCanvasAWT ) { + newtCanvasAWT.setSkipJAWTDestroy(false); // Bug 910 remove(newtCanvasAWT); // remove newtCanvasAWT incl. glWindow.reparentWindow(null) if not done yet! newtCanvasAWT.destroy(); } -- cgit v1.2.3 From 586446311ea1ba87f98236d5347955bf99b465d6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 29 Nov 2013 02:24:01 +0100 Subject: Bug 907 - Refine DummyDispatchThread (DDT) Handling: Proper OO integration in RegisteredClass; Safe DDT Post/WaitForReady handling and error cases ; ... Proper OO integration of DDT in RegisteredClass - DDT is optional to RegisteredClass[Factory], i.e. NEWT without DDT and DummyWindow with DDT. - Using native type DummyThreadContext per DDT passed as DDT handle to java referenced in RegisteredClass - Passing DDT handle to related native methods, if not null use DDT - otherwise work on current thread. The latter impacts CreateDummyWindow0 and DestroyWindow0. Safe DDT Post/WaitForReady handling and error cases ; ... - Wait until command it complete using a 3s timeout - Terminate thread if errors occur and throw an exception +++ Discussion: DDT Native Implementation Due to original code, the DDT is implemented in native code. Usually we should favor running the DDT from a java thread. However, since it's main purpose is _not_ to interact w/ java and the native implementation has less footprint (performance and memory) we shall be OK w/ it for now - as long the implementation IS SAFE. --- make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64-dbg.bat | 8 +- make/scripts/tests.sh | 27 +- .../jogamp/nativewindow/windows/GDIUtil.java | 21 +- .../nativewindow/windows/RegisteredClass.java | 17 +- .../windows/RegisteredClassFactory.java | 30 +- src/nativewindow/native/NativewindowCommon.c | 7 + src/nativewindow/native/NativewindowCommon.h | 3 + src/nativewindow/native/win32/GDImisc.c | 446 ++++++++++++++------- .../jogamp/newt/driver/windows/DisplayDriver.java | 2 +- 10 files changed, 373 insertions(+), 192 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index fb224c882..d95b0025f 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -18,7 +18,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLa REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 851c1dbec..3e56a31a6 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -21,16 +21,18 @@ set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\% echo CP_ALL %CP_ALL% REM set D_ARGS="-Djogamp.debug=all" +set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" +REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" +REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" +REM set D_ARGS="-Dnativewindow.debug.GDIUtil" "-Dnativewindow.debug.RegisteredClass" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" -REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.GLCanvas" -REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" REM set D_ARGS="-Djogamp.debug.IOUtil" REM set D_ARGS="-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" -set D_ARGS="-Djogl.debug.GLMediaPlayer" +REM set D_ARGS="-Djogl.debug.GLMediaPlayer" REM set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.AudioSink" REM set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.GLMediaPlayer.Native" REM set D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25" "-Djogl.debug.GLMediaPlayer" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ce8005821..56a07e768 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -84,6 +84,17 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL" + + #D_ARGS="-Djogamp.debug=all" + #D_ARGS="-Dnativewindow.debug=all" + #D_ARGS="-Djogl.debug=all" + #D_ARGS="-Dnewt.debug=all" + #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" + D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" + #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" + #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_MULTITHREADING_BUG" #D_ARGS="-Djogl.disable.opengles" @@ -93,7 +104,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL" - #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" @@ -110,10 +121,6 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.debug.GLContext" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" - #D_ARGS="-Djogamp.debug=all" - #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.Animator -Djogl.debug.GLDrawable -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" @@ -122,8 +129,6 @@ function jrun() { #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLEventListenerState" #D_ARGS="-Djogl.fbo.force.none" - #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" - #D_ARGS="-Djogl.debug=all" #D_ARGS="-Djogl.debug.EGLDrawableFactory.DontQuery -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.QueryNativeTK -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLDebugMessageHandler" @@ -137,7 +142,7 @@ function jrun() { #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" - D_ARGS="-Djogl.debug.GLMediaPlayer" + #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.AudioSink" @@ -201,7 +206,6 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" - #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl" #D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.DebugGL" @@ -225,7 +229,6 @@ function jrun() { #D_ARGS="-Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=10000" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" - #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer -Djogl.debug.TileRenderer.PNG" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" #D_ARGS="-Djogl.debug.PNGImage" @@ -322,7 +325,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* @@ -345,7 +348,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # performance tests diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index bab4b5c6e..a872e63d8 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -59,7 +59,7 @@ public class GDIUtil implements ToolkitProperties { if( !initIDs0() ) { throw new NativeWindowException("GDI: Could not initialized native stub"); } - dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0()); + dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0(), true /* useDummyDispatchThread */); if(DEBUG) { System.out.println("GDI.initSingleton() dummyWindowClassFactory "+dummyWindowClassFactory); } @@ -98,8 +98,7 @@ public class GDIUtil implements ToolkitProperties { System.out.println("GDI.CreateDummyWindow() dummyWindowClassFactory "+dummyWindowClassFactory); System.out.println("GDI.CreateDummyWindow() dummyWindowClass "+dummyWindowClass); } - // FIXME return CreateDummyWindow0(dummyWindowClass.getHInstance(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height); - return CreateDummyWindowAndMessageLoop(dummyWindowClass.getHInstance(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height); + return CreateDummyWindow0(dummyWindowClass.getHInstance(), dummyWindowClass.getName(), dummyWindowClass.getHDispThreadContext(), dummyWindowClass.getName(), x, y, width, height); } } @@ -109,8 +108,7 @@ public class GDIUtil implements ToolkitProperties { if( null == dummyWindowClass ) { throw new InternalError("GDI Error ("+dummyWindowClassFactory.getSharedRefCount()+"): SharedClass is null"); } - // FIXME res = GDI.DestroyWindow(hwnd); - res = SendCloseMessage(hwnd); + res = DestroyWindow0(dummyWindowClass.getHDispThreadContext(), hwnd); dummyWindowClassFactory.releaseSharedClass(); } return res; @@ -128,8 +126,11 @@ public class GDIUtil implements ToolkitProperties { return IsChild0(win); } - public static native boolean CreateWindowClass(long hInstance, String clazzName, long wndProc); - public static native boolean DestroyWindowClass(long hInstance, String className); + private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI + + static native boolean CreateWindowClass0(long hInstance, String clazzName, long wndProc); + static native boolean DestroyWindowClass0(long hInstance, String className, long dispThreadCtx); + static native long CreateDummyDispatchThread0(); private static native boolean initIDs0(); private static native long getDummyWndProc0(); @@ -137,8 +138,6 @@ public class GDIUtil implements ToolkitProperties { private static native boolean IsChild0(long win); private static native boolean IsUndecorated0(long win); - private static native long CreateDummyWindow0(long hInstance, String className, String windowName, int x, int y, int width, int height); - - private static native long CreateDummyWindowAndMessageLoop(long hInstance, String className, String windowName, int x, int y, int width, int height); - private static native boolean SendCloseMessage(long win); + private static native long CreateDummyWindow0(long hInstance, String className, long dispThreadCtx, String windowName, int x, int y, int width, int height); + private static native boolean DestroyWindow0(long dispThreadCtx, long win); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java index 976693e3a..1f6cb7c05 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java @@ -29,12 +29,14 @@ package jogamp.nativewindow.windows; public class RegisteredClass { - long hInstance; - String className; + private final long hInstance; + private final String className; + private final long hDDTCtx; - RegisteredClass(long hInst, String name) { - hInstance = hInst; - className = name; + RegisteredClass(long hInst, String name, long hDispatchThreadCtx) { + this.hInstance = hInst; + this.className = name; + this.hDDTCtx = hDispatchThreadCtx; } /** Application handle, same as {@link RegisteredClassFactory#getHInstance()}. */ @@ -43,6 +45,9 @@ public class RegisteredClass { /** Unique Window Class Name */ public final String getName() { return className; } + /** Unique associated dispatch thread context for this Window Class, or 0 for none. */ + public final long getHDispThreadContext() { return hDDTCtx; } + @Override - public final String toString() { return "RegisteredClass[handle 0x"+Long.toHexString(hInstance)+", "+className+"]"; } + public final String toString() { return "RegisteredClass[handle 0x"+Long.toHexString(hInstance)+", "+className+", dtx 0x"+Long.toHexString(hDDTCtx)+"]"; } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java index 19a48d3bf..ee41fe192 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java @@ -49,6 +49,7 @@ public class RegisteredClassFactory { private final String classBaseName; private final long wndProc; + private final boolean useDummyDispatchThread; private RegisteredClass sharedClass = null; private int classIter = 0; @@ -59,24 +60,29 @@ public class RegisteredClassFactory { @Override public final String toString() { return "RegisteredClassFactory[moduleHandle "+toHexString(hInstance)+", "+classBaseName+ - ", wndProc "+toHexString(wndProc)+", shared[refCount "+sharedRefCount+", class "+sharedClass+"]]"; } + ", wndProc "+toHexString(wndProc)+", useDDT "+useDummyDispatchThread+", shared[refCount "+sharedRefCount+", class "+sharedClass+"]]"; } /** * Release the {@link RegisteredClass} of all {@link RegisteredClassFactory}. */ public static void shutdownSharedClasses() { synchronized(registeredFactories) { + if( DEBUG ) { + System.err.println("RegisteredClassFactory.shutdownSharedClasses: "+registeredFactories.size()); + } for(int j=0; j +#include static const char * const ClazzNameRuntimeException = "java/lang/RuntimeException"; static jclass runtimeExceptionClz=NULL; @@ -106,3 +107,9 @@ JNIEnv* NativewindowCommon_GetJNIEnv (JavaVM * jvmHandle, int jvmVersion, int as return curEnv; } +int64_t NativewindowCommon_CurrentTimeMillis() { + struct timeval tv; + gettimeofday(&tv,NULL); + return (int64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000; +} + diff --git a/src/nativewindow/native/NativewindowCommon.h b/src/nativewindow/native/NativewindowCommon.h index a2975f3fd..a23fad9fd 100644 --- a/src/nativewindow/native/NativewindowCommon.h +++ b/src/nativewindow/native/NativewindowCommon.h @@ -4,6 +4,7 @@ #include #include +#include int NativewindowCommon_init(JNIEnv *env); @@ -15,4 +16,6 @@ void NativewindowCommon_throwNewRuntimeException(JNIEnv *env, const char* msg, . JNIEnv* NativewindowCommon_GetJNIEnv (JavaVM * jvmHandle, int jvmVersion, int asDaemon, int * shallBeDetached); +int64_t NativewindowCommon_CurrentTimeMillis(); + #endif diff --git a/src/nativewindow/native/win32/GDImisc.c b/src/nativewindow/native/win32/GDImisc.c index d3ac3873c..b55988c11 100644 --- a/src/nativewindow/native/win32/GDImisc.c +++ b/src/nativewindow/native/win32/GDImisc.c @@ -20,8 +20,10 @@ #ifdef VERBOSE_ON #define DBG_PRINT(args...) fprintf(stderr, args); + #define DBG_PRINT_FLUSH(args...) fprintf(stderr, args); fflush(stderr); #else #define DBG_PRINT(args...) + #define DBG_PRINT_FLUSH(args...) #endif static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; @@ -30,12 +32,17 @@ static const char * const ClazzNamePointCstrSignature = "(II)V"; static jclass pointClz = NULL; static jmethodID pointCstr = NULL; +static jmethodID dumpStackID = NULL; -static volatile DWORD threadid = 0; +typedef struct { + HANDLE threadHandle; + DWORD threadId; + volatile BOOL threadReady; + volatile BOOL threadDead; +} DummyThreadContext; -typedef struct ThreadParam_s -{ - jlong jHInstance; +typedef struct { + HINSTANCE hInstance; const TCHAR* wndClassName; const TCHAR* wndName; jint x; @@ -44,17 +51,88 @@ typedef struct ThreadParam_s jint height; volatile HWND hWnd; volatile BOOL threadReady; -} ThreadParam; +} DummyThreadCommand; #define TM_OPENWIN WM_APP+1 #define TM_CLOSEWIN WM_APP+2 #define TM_STOP WM_APP+3 -DWORD WINAPI ThreadFunc(LPVOID param) +static const char * sTM_OPENWIN = "TM_OPENWIN"; +static const char * sTM_CLOSEWIN = "TM_CLOSEWIN"; +static const char * sTM_STOP = "TM_STOP"; + +/** 3s timeout */ +static const int64_t TIME_OUT = 3000000; + +static jboolean DDT_CheckAlive(JNIEnv *env, const char *msg, DummyThreadContext *ctx) { + if( ctx->threadDead ) { + NativewindowCommon_throwNewRuntimeException(env, "DDT is dead at %s", msg); + return JNI_FALSE; + } else { + DBG_PRINT_FLUSH("*** DDT-Check ALIVE @ %s\n", msg); + return JNI_TRUE; + } +} + +static jboolean DDT_WaitUntilCreated(JNIEnv *env, DummyThreadContext *ctx, BOOL created) { + const int64_t t0 = NativewindowCommon_CurrentTimeMillis(); + int64_t t1 = t0; + if( created ) { + while( !ctx->threadReady && t1-t0 < TIME_OUT ) { + t1 = NativewindowCommon_CurrentTimeMillis(); + } + if( !ctx->threadReady ) { + NativewindowCommon_throwNewRuntimeException(env, "TIMEOUT (%d ms) while waiting for DDT CREATED", (int)(t1-t0)); + return JNI_FALSE; + } + DBG_PRINT_FLUSH("*** DDT-Check CREATED\n"); + } else { + while( !ctx->threadDead && t1-t0 < TIME_OUT ) { + t1 = NativewindowCommon_CurrentTimeMillis(); + } + if( !ctx->threadDead ) { + NativewindowCommon_throwNewRuntimeException(env, "TIMEOUT (%d ms) while waiting for DDT DESTROYED", (int)(t1-t0)); + return JNI_FALSE; + } + DBG_PRINT_FLUSH("*** DDT-Check DEAD\n"); + } + return JNI_TRUE; +} + +static jboolean DDT_WaitUntilReady(JNIEnv *env, const char *msg, DummyThreadCommand *cmd) { + const int64_t t0 = NativewindowCommon_CurrentTimeMillis(); + int64_t t1 = t0; + while( !cmd->threadReady && t1-t0 < TIME_OUT ) { + t1 = NativewindowCommon_CurrentTimeMillis(); + } + if( !cmd->threadReady ) { + NativewindowCommon_throwNewRuntimeException(env, "TIMEOUT (%d ms) while waiting for DDT %s", (int)(t1-t0), msg); + return JNI_FALSE; + } + DBG_PRINT_FLUSH("*** DDT-Check READY @ %s\n", msg); + return JNI_TRUE; +} + +static HWND DummyWindowCreate + (HINSTANCE hInstance, const TCHAR* wndClassName, const TCHAR* wndName, jint x, jint y, jint width, jint height) +{ + DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; + DWORD dwStyle = WS_OVERLAPPEDWINDOW; + HWND hWnd = CreateWindowEx( dwExStyle, + wndClassName, + wndName, + dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + x, y, width, height, + NULL, NULL, hInstance, NULL ); + return hWnd; +} + +static DWORD WINAPI DummyDispatchThreadFunc(LPVOID param) { MSG msg; BOOL bRet; - ThreadParam *startupThreadParam = (ThreadParam*)param; + BOOL bEOL=FALSE; + DummyThreadContext *threadContext = (DummyThreadContext*)param; /* there can not be any messages for us now, as the creator waits for threadReady before continuing, but we must use this PeekMessage() to @@ -62,42 +140,40 @@ DWORD WINAPI ThreadFunc(LPVOID param) PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE); /* now we can safely say: we have a qeue and are ready to receive messages */ - startupThreadParam->threadReady = TRUE; - - while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) { - if (bRet == -1) { - return 0; + // threadContext->threadId = GetCurrentThreadId(); + threadContext->threadDead = FALSE; + threadContext->threadReady = TRUE; + + while( !bEOL && (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0 ) { + if ( -1 == bRet ) { + fprintf(stderr, "DummyDispatchThread (id %d): GetMessage Error %d, werr %d\n", + (int)threadContext->threadId, (int)bRet, (int)GetLastError()); + fflush(stderr); + bEOL = TRUE; + break; // EOL } else { switch(msg.message) { case TM_OPENWIN: { - ThreadParam *tParam = (ThreadParam*)msg.wParam; - HINSTANCE hInstance = (HINSTANCE) (intptr_t) tParam->jHInstance; - DWORD dwExStyle; - DWORD dwStyle; - - dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; - dwStyle = WS_OVERLAPPEDWINDOW; - - HWND hwnd = CreateWindowEx( dwExStyle, - tParam->wndClassName, - tParam->wndName, - dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - tParam->x, tParam->y, tParam->width, tParam->height, - NULL, NULL, hInstance, NULL ); - - tParam->hWnd = hwnd; + DummyThreadCommand *tParam = (DummyThreadCommand*)msg.wParam; + DBG_PRINT_FLUSH("*** DDT-Dispatch OPENWIN\n"); + tParam->hWnd = DummyWindowCreate(tParam->hInstance, tParam->wndClassName, tParam->wndName, tParam->x, tParam->y, tParam->width, tParam->height); tParam->threadReady = TRUE; } break; case TM_CLOSEWIN: { - ThreadParam *tParam = (ThreadParam*)msg.wParam; - HWND hwnd = tParam->hWnd; - DestroyWindow(hwnd); + DummyThreadCommand *tParam = (DummyThreadCommand*)msg.wParam; + DBG_PRINT_FLUSH("*** DDT-Dispatch CLOSEWIN\n"); + DestroyWindow(tParam->hWnd); tParam->threadReady = TRUE; } break; - case TM_STOP: - return 0; + case TM_STOP: { + DummyThreadCommand *tParam = (DummyThreadCommand*)msg.wParam; + DBG_PRINT_FLUSH("*** DDT-Dispatch STOP -> DEAD\n"); + tParam->threadReady = TRUE; + bEOL = TRUE; + } + break; // EOL default: TranslateMessage(&msg); DispatchMessage(&msg); @@ -105,8 +181,12 @@ DWORD WINAPI ThreadFunc(LPVOID param) } } } + /* dead */ + DBG_PRINT_FLUSH("*** DDT-Dispatch DEAD\n"); + threadContext->threadDead = TRUE; + ExitThread(0); return 0; -} /* ThreadFunc */ +} HINSTANCE GetApplicationHandle() { @@ -115,11 +195,48 @@ HINSTANCE GetApplicationHandle() { /* Java->C glue code: * Java package: jogamp.nativewindow.windows.GDIUtil - * Java method: boolean CreateWindowClass(long hInstance, java.lang.String clazzName, long wndProc) - * C function: BOOL CreateWindowClass(HANDLE hInstance, LPCSTR clazzName, HANDLE wndProc); + * Java method: long CreateDummyDispatchThread0() + */ +JNIEXPORT jlong JNICALL +Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyDispatchThread0 + (JNIEnv *env, jclass _unused) +{ + DWORD threadId = 0; + DummyThreadContext * dispThreadCtx = calloc(1, sizeof(DummyThreadContext)); + + dispThreadCtx->threadHandle = CreateThread(NULL, 0, DummyDispatchThreadFunc, (LPVOID)dispThreadCtx, 0, &threadId); + if( NULL == dispThreadCtx->threadHandle || 0 == threadId ) { + const HANDLE threadHandle = dispThreadCtx->threadHandle; + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT CREATE failed handle %p, id %d, werr %d", + (void*)threadHandle, (int)threadId, (int)GetLastError()); + return (jlong)0; + } + if( JNI_FALSE == DDT_WaitUntilCreated(env, dispThreadCtx, TRUE) ) { + const HANDLE threadHandle = dispThreadCtx->threadHandle; + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT CREATE (ack) failed handle %p, id %d, werr %d", + (void*)threadHandle, (int)threadId, (int)GetLastError()); + return (jlong)0; + } + DBG_PRINT_FLUSH("*** DDT Created %d\n", (int)threadId); + dispThreadCtx->threadId = threadId; + return (jlong) (intptr_t) dispThreadCtx; +} + +/* Java->C glue code: + * Java package: jogamp.nativewindow.windows.GDIUtil + * Java method: boolean CreateWindowClass0(long hInstance, java.lang.String clazzName, long wndProc) + * C function: BOOL CreateWindowClass0(HANDLE hInstance, LPCSTR clazzName, HANDLE wndProc); */ JNIEXPORT jboolean JNICALL -Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass +Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass0 (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jClazzName, jlong wndProc) { HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance; @@ -127,11 +244,6 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass WNDCLASS wc; jboolean res; - if( 0 != threadid ) { - NativewindowCommon_throwNewRuntimeException(env, "Native threadid already created 0x%X", (int)threadid); - return JNI_FALSE; - } - #ifdef UNICODE clazzName = NewtCommon_GetNullTerminatedStringChars(env, jClazzName); #else @@ -164,31 +276,20 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass (*env)->ReleaseStringUTFChars(env, jClazzName, clazzName); #endif - if( JNI_TRUE == res ) { - ThreadParam tParam = {0}; - - CreateThread(NULL, 0, ThreadFunc, (LPVOID)&tParam, 0, (DWORD *)&threadid); - if(threadid) { - while(!tParam.threadReady) { /* nop */ } - } else { - res = JNI_FALSE; - } - } - return res; } /* Java->C glue code: * Java package: jogamp.nativewindow.windows.GDIUtil - * Java method: boolean DestroyWindowClass(long hInstance, java.lang.String className) - * C function: BOOL DestroyWindowClass(HANDLE hInstance, LPCSTR className); + * Java method: boolean DestroyWindowClass0(long hInstance, java.lang.String className, long dispThreadCtx) */ JNIEXPORT jboolean JNICALL -Java_jogamp_nativewindow_windows_GDIUtil_DestroyWindowClass - (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jClazzName) +Java_jogamp_nativewindow_windows_GDIUtil_DestroyWindowClass0 + (JNIEnv *env, jclass gdiClazz, jlong jHInstance, jstring jClazzName, jlong jDispThreadCtx) { HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance; const TCHAR* clazzName = NULL; + DummyThreadContext * dispThreadCtx = (DummyThreadContext *) (intptr_t) jDispThreadCtx; jboolean res; #ifdef UNICODE @@ -205,39 +306,73 @@ Java_jogamp_nativewindow_windows_GDIUtil_DestroyWindowClass (*env)->ReleaseStringUTFChars(env, jClazzName, clazzName); #endif - if( 0 == threadid ) { - NativewindowCommon_throwNewRuntimeException(env, "Native threadid zero 0x%X", (int)threadid); - return JNI_FALSE; - } + if( NULL != dispThreadCtx) { + const HANDLE threadHandle = dispThreadCtx->threadHandle; + const DWORD threadId = dispThreadCtx->threadId; + DummyThreadCommand tParam = {0}; + tParam.threadReady = FALSE; + DBG_PRINT_FLUSH("*** DDT Destroy %d\n", (int)threadId); +#ifdef VERBOSE_ON + (*env)->CallStaticVoidMethod(env, gdiClazz, dumpStackID); +#endif - PostThreadMessage(threadid, TM_STOP, 0, 0); + if( JNI_FALSE == DDT_CheckAlive(env, sTM_STOP, dispThreadCtx) ) { + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT %s (alive) failed handle %p, id %d, werr %d", + sTM_STOP, (void*)threadHandle, (int)threadId, (int)GetLastError()); + return JNI_FALSE; + } + if ( 0 != PostThreadMessage(dispThreadCtx->threadId, TM_STOP, (WPARAM)&tParam, 0) ) { + if( JNI_FALSE == DDT_WaitUntilReady(env, sTM_STOP, &tParam) ) { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT Post %s (ack) failed handle %p, id %d, werr %d", + sTM_STOP, (void*)threadHandle, (int)threadId, (int)GetLastError()); + return JNI_FALSE; + } + if( JNI_FALSE == DDT_WaitUntilCreated(env, dispThreadCtx, FALSE) ) { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT KILL %s (ack) failed handle %p, id %d, werr %d", + sTM_STOP, (void*)threadHandle, (int)threadId, (int)GetLastError()); + return JNI_FALSE; + } + free(dispThreadCtx); // free after proper DDT shutdown! + } else { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT Post %s failed handle %p, id %d, werr %d", + sTM_STOP, (void*)threadHandle, (int)threadId, (int)GetLastError()); + return JNI_FALSE; + } + } return res; } /* Java->C glue code: * Java package: jogamp.nativewindow.windows.GDIUtil - * Java method: long CreateDummyWindowAndMessageLoop(long hInstance, java.lang.String className, java.lang.String windowName, int x, int y, int width, int height) - * C function: HANDLE CreateDummyWindowAndMessageLoop(HANDLE hInstance, LPCSTR className, LPCSTR windowName, int x, int y, int width, int height); + * Java method: long CreateDummyWindow0(long hInstance, java.lang.String className, jlong dispThreadCtx, java.lang.String windowName, int x, int y, int width, int height) */ JNIEXPORT jlong JNICALL -Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyWindowAndMessageLoop - (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jWndClassName, jstring jWndName, jint x, jint y, jint width, jint height) +Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyWindow0 + (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jWndClassName, jlong jDispThreadCtx, jstring jWndName, jint x, jint y, jint width, jint height) { - volatile HWND hWnd = 0; - ThreadParam tParam = {0}; - - if( 0 == threadid ) { - NativewindowCommon_throwNewRuntimeException(env, "Native threadid zero 0x%X", (int)threadid); - return JNI_FALSE; - } + DummyThreadContext * dispThreadCtx = (DummyThreadContext *) (intptr_t) jDispThreadCtx; + DummyThreadCommand tParam = {0}; - tParam.jHInstance = jHInstance; + tParam.hInstance = (HINSTANCE) (intptr_t) jHInstance; tParam.x = x; tParam.y = y; tParam.width = width; tParam.height = height; - tParam.hWnd = hWnd; + tParam.hWnd = 0; tParam.threadReady = FALSE; #ifdef UNICODE @@ -248,9 +383,37 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyWindowAndMessageLoop tParam.wndName = (*env)->GetStringUTFChars(env, jWndName, NULL); #endif - PostThreadMessage(threadid, TM_OPENWIN, (WPARAM)&tParam, 0); - - while(!tParam.threadReady) { /* nop */ } + if( NULL == dispThreadCtx ) { + tParam.hWnd = DummyWindowCreate(tParam.hInstance, tParam.wndClassName, tParam.wndName, tParam.x, tParam.y, tParam.width, tParam.height); + } else { + const HANDLE threadHandle = dispThreadCtx->threadHandle; + const DWORD threadId = dispThreadCtx->threadId; + if( JNI_FALSE == DDT_CheckAlive(env, sTM_OPENWIN, dispThreadCtx) ) { + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT %s (alive) failed handle %p, id %d, werr %d", + sTM_OPENWIN, (void*)threadHandle, (int)threadId, (int)GetLastError()); + } else { + if( 0 != PostThreadMessage(dispThreadCtx->threadId, TM_OPENWIN, (WPARAM)&tParam, 0) ) { + if( JNI_FALSE == DDT_WaitUntilReady(env, sTM_OPENWIN, &tParam) ) { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + tParam.hWnd = 0; + NativewindowCommon_throwNewRuntimeException(env, "DDT Post %s (ack) failed handle %p, id %d, werr %d", + sTM_OPENWIN, (void*)threadHandle, (int)threadId, (int)GetLastError()); + } + } else { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + tParam.hWnd = 0; + NativewindowCommon_throwNewRuntimeException(env, "DDT Post %s to handle %p, id %d failed, werr %d", + sTM_OPENWIN, (void*)threadHandle, (int)threadId, (int)GetLastError()); + } + } + } #ifdef UNICODE free((void*) tParam.wndClassName); @@ -260,62 +423,66 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyWindowAndMessageLoop (*env)->ReleaseStringUTFChars(env, jWndName, tParam.wndName); #endif - return (jlong) (intptr_t) hWnd; + return (jlong) (intptr_t) tParam.hWnd; } -/* Java->C glue code: - * Java package: jogamp.nativewindow.windows.GDIUtil - * Java method: long CreateDummyWindow0(long hInstance, java.lang.String className, java.lang.String windowName, int x, int y, int width, int height) - * C function: HANDLE CreateDummyWindow0(HANDLE hInstance, LPCSTR className, LPCSTR windowName, int x, int y, int width, int height); +/* + * Class: jogamp_nativewindow_windows_GDIUtil + * Method: DestroyWindow0 */ -JNIEXPORT jlong JNICALL -Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyWindow0 - (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jWndClassName, jstring jWndName, jint x, jint y, jint width, jint height) +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_DestroyWindow0 +(JNIEnv *env, jclass unused, jlong jDispThreadCtx, jlong jwin) { - HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance; - const TCHAR* wndClassName = NULL; - const TCHAR* wndName = NULL; - DWORD dwExStyle; - DWORD dwStyle; - HWND hWnd; - -#ifdef UNICODE - wndClassName = NewtCommon_GetNullTerminatedStringChars(env, jWndClassName); - wndName = NewtCommon_GetNullTerminatedStringChars(env, jWndName); -#else - wndClassName = (*env)->GetStringUTFChars(env, jWndClassName, NULL); - wndName = (*env)->GetStringUTFChars(env, jWndName, NULL); -#endif - - dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; - dwStyle = WS_OVERLAPPEDWINDOW; - - hWnd = CreateWindowEx( dwExStyle, - wndClassName, - wndName, - dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - x, y, width, height, - NULL, NULL, hInstance, NULL ); + jboolean res = JNI_TRUE; + DummyThreadContext * dispThreadCtx = (DummyThreadContext *) (intptr_t) jDispThreadCtx; + HWND hWnd = (HWND) (intptr_t) jwin; + if( NULL == dispThreadCtx ) { + DestroyWindow(hWnd); + } else { + const HANDLE threadHandle = dispThreadCtx->threadHandle; + const DWORD threadId = dispThreadCtx->threadId; + DummyThreadCommand tParam = {0}; -#ifdef UNICODE - free((void*) wndClassName); - free((void*) wndName); -#else - (*env)->ReleaseStringUTFChars(env, jWndClassName, wndClassName); - (*env)->ReleaseStringUTFChars(env, jWndName, wndName); -#endif + tParam.hWnd = hWnd; + tParam.threadReady = FALSE; - return (jlong) (intptr_t) hWnd; + if( JNI_FALSE == DDT_CheckAlive(env, sTM_CLOSEWIN, dispThreadCtx) ) { + free(dispThreadCtx); + res = JNI_FALSE; + NativewindowCommon_throwNewRuntimeException(env, "DDT %s (alive) failed handle %p, id %d, werr %d", + sTM_CLOSEWIN, (void*)threadHandle, (int)threadId, (int)GetLastError()); + } else { + if ( 0 != PostThreadMessage(dispThreadCtx->threadId, TM_CLOSEWIN, (WPARAM)&tParam, 0) ) { + if( JNI_FALSE == DDT_WaitUntilReady(env, sTM_CLOSEWIN, &tParam) ) { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + res = JNI_FALSE; + NativewindowCommon_throwNewRuntimeException(env, "DDT Post %s (ack) failed handle %p, id %d, werr %d", + sTM_CLOSEWIN, (void*)threadHandle, (int)threadId, (int)GetLastError()); + } + } else { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + res = JNI_FALSE; + NativewindowCommon_throwNewRuntimeException(env, "DDT Post %s to handle %p, id %d failed, werr %d", + sTM_CLOSEWIN, (void*)threadHandle, (int)threadId, (int)GetLastError()); + } + } + } + return res; } - /* * Class: jogamp_nativewindow_windows_GDIUtil * Method: initIDs0 * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_initIDs0 - (JNIEnv *env, jclass clazz) + (JNIEnv *env, jclass gdiClazz) { if(NativewindowCommon_init(env)) { jclass c = (*env)->FindClass(env, ClazzNamePoint); @@ -332,11 +499,15 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_initIDs0 NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDIUtil: can't fetch %s.%s %s", ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature); } + dumpStackID = (*env)->GetStaticMethodID(env, gdiClazz, "dumpStack", "()V"); + if(NULL==dumpStackID) { + NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDIUtil: can't get method dumpStack"); + } } return JNI_TRUE; } -LRESULT CALLBACK DummyWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { +static LRESULT CALLBACK DummyWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return DefWindowProc(hWnd,uMsg,wParam,lParam); } @@ -379,8 +550,8 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_windows_GDIUtil_GetRelativeLo JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_IsChild0 (JNIEnv *env, jclass unused, jlong jwin) { - HWND hwnd = (HWND) (intptr_t) jwin; - LONG style = GetWindowLong(hwnd, GWL_STYLE); + HWND hWnd = (HWND) (intptr_t) jwin; + LONG style = GetWindowLong(hWnd, GWL_STYLE); BOOL bIsChild = 0 != (style & WS_CHILD) ; return bIsChild ? JNI_TRUE : JNI_FALSE; } @@ -392,34 +563,9 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_IsChild0 JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_IsUndecorated0 (JNIEnv *env, jclass unused, jlong jwin) { - HWND hwnd = (HWND) (intptr_t) jwin; - LONG style = GetWindowLong(hwnd, GWL_STYLE); + HWND hWnd = (HWND) (intptr_t) jwin; + LONG style = GetWindowLong(hWnd, GWL_STYLE); BOOL bIsUndecorated = 0 != (style & (WS_CHILD|WS_POPUP)) ; return bIsUndecorated ? JNI_TRUE : JNI_FALSE; } -/* - * Class: jogamp_nativewindow_windows_GDIUtil - * Method: SendCloseMessage - */ -JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_SendCloseMessage -(JNIEnv *env, jclass unused, jlong jwin) -{ - ThreadParam tParam = {0}; - volatile HWND hwnd = (HWND) (intptr_t) jwin; - - if( 0 == threadid ) { - NativewindowCommon_throwNewRuntimeException(env, "Native threadid zero 0x%X", (int)threadid); - return JNI_FALSE; - } - - tParam.hWnd = hwnd; - tParam.threadReady = FALSE; - - PostThreadMessage(threadid, TM_CLOSEWIN, (WPARAM)&tParam, 0); - - while(!tParam.threadReady) { /* nop */ } - - return JNI_TRUE; -} - diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index d8ff7ecb5..c4cfd98b3 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -51,7 +51,7 @@ public class DisplayDriver extends DisplayImpl { static { NEWTJNILibLoader.loadNEWT(); - sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowDriver.getNewtWndProc0()); + sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowDriver.getNewtWndProc0(), false /* useDummyDispatchThread */); if (!WindowDriver.initIDs0(RegisteredClassFactory.getHInstance())) { throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs"); -- cgit v1.2.3 From 4cb35d98a1b25fb8347584b0ab6534c7cfc5946c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 1 Dec 2013 23:22:17 +0100 Subject: Bug 914 - Don't allow 'alwaysontop' in fullscreen mode, always allow switching to other applications via ALT-TAB As described @ , we shall not steal the desktop in fullscreen mode via 'alwaysontop'. Latest tests on X11/GNU/Linux and Windows7 - before this patch: With default settings, i.e. alwaysontop (atop) disabled, it works as expected here, i.e.: - ALT-TAB triggers WM dialog, switching between apps. - ALT-TAB can actually switch to other apps. However, with enabled atop: - ALT-TAB triggers WM dialog, switching between apps. - ALT-TAB does _not_ switch to other apps. (*) I consider this a serious issue, since we shall not steal the desktop in fullscreen mode. This patch disables atop in fullscreen mode, i.e. (*) will switch to other apps again! --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- src/newt/classes/jogamp/newt/WindowImpl.java | 25 +++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index d0c3f5d2e..d95b0025f 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -24,7 +24,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 601ede4e4..56a07e768 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -325,7 +325,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* @@ -355,7 +355,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT $* # diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 51740cb8d..d62a19f44 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -164,6 +164,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user) private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets + private boolean nfs_alwaysOnTop; // non fullscreen alwaysOnTop setting private NativeWindow nfs_parent = null; // non fullscreen parent, in case explicit reparenting is performed (offscreen) private String title = "Newt Window"; private boolean undecorated = false; @@ -1610,7 +1611,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final void setAlwaysOnTop(boolean value) { - runOnEDTIfAvail(true, new AlwaysOnTopAction(value)); + if( isFullscreen() ) { + nfs_alwaysOnTop = value; + } else { + runOnEDTIfAvail(true, new AlwaysOnTopAction(value)); + } } @Override @@ -2012,6 +2017,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final RectangleImmutable sviewport = screen.getViewport(); final RectangleImmutable viewport; final int fs_span_flag; + final boolean alwaysOnTopChange; if(fullscreen) { if( null == fullscreenMonitors ) { if( fullscreenUseMainMonitor ) { @@ -2032,10 +2038,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer nfs_y = oldY; nfs_width = oldWidth; nfs_height = oldHeight; + nfs_alwaysOnTop = alwaysOnTop; x = viewport.getX(); y = viewport.getY(); w = viewport.getWidth(); h = viewport.getHeight(); + alwaysOnTop = false; + alwaysOnTopChange = nfs_alwaysOnTop != alwaysOnTop; } else { fullscreenUseMainMonitor = true; fullscreenMonitors = null; @@ -2045,6 +2054,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer y = nfs_y; w = nfs_width; h = nfs_height; + alwaysOnTopChange = nfs_alwaysOnTop != alwaysOnTop; + alwaysOnTop = nfs_alwaysOnTop; if(null!=parentWindow) { // reset position to 0/0 within parent space @@ -2063,7 +2074,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ ", virtl-screenSize: "+sviewport+", monitorsViewport "+viewport+ - ", spanning "+(0!=fs_span_flag)+" @ "+Thread.currentThread().getName()); + ", spanning "+(0!=fs_span_flag)+ + ", alwaysOnTop "+alwaysOnTop+(alwaysOnTopChange?"*":"")+ + " @ "+Thread.currentThread().getName()); } final DisplayImpl display = (DisplayImpl) screen.getDisplay(); @@ -2090,9 +2103,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer parentWindowLocked = null; } try { + if(alwaysOnTopChange && fullscreen) { + // Enter fullscreen - Disable alwaysOnTop + reconfigureWindowImpl(nfs_x, nfs_y, nfs_width, nfs_height, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); + } reconfigureWindowImpl(x, y, w, h, getReconfigureFlags( ( ( null != parentWindowLocked ) ? FLAG_CHANGE_PARENTING : 0 ) | fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, isVisible()) ); + if(alwaysOnTopChange && !fullscreen) { + // Leave fullscreen - Restore alwaysOnTop + reconfigureWindowImpl(x, y, w, h, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); + } } finally { if(null!=parentWindowLocked) { parentWindowLocked.unlockSurface(); -- cgit v1.2.3 From 0237bde0f3c13d393c3942b41f79656a80fd578d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 3 Dec 2013 21:54:57 +0100 Subject: Bug 914: Newt OSX: Reset NSApp's presentationOptions @ windowClose0() / Assume having focus in fullscreen-mode - Reset NSApp's presentationOptions @ windowClose0() Commit 69c334448cfe8af553fd97689137ecf8f996b378 started using the [NSApp setPresentationOptions: opts] but missed to reset to defaults @ windowClose0(); - Assume having focus in fullscreen-mode NewtMacWindow::windowDidBecomeKey()' is not always called in fullscreen-mode! Note: OSX Fullscreen from a browser still shows the browser title-bar until mouse-click. Don't know how to avoid this. Minor issue.. --- src/newt/classes/jogamp/newt/WindowImpl.java | 14 ++--- .../jogamp/newt/driver/macosx/WindowDriver.java | 15 ++++-- src/newt/native/MacWindow.m | 63 +++++++++++++--------- src/newt/native/NewtMacWindow.h | 8 +-- src/newt/native/NewtMacWindow.m | 47 ++++++++-------- 5 files changed, 84 insertions(+), 63 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index d62a19f44..21343b263 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -674,37 +674,37 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( 0 != ( FLAG_CHANGE_PARENTING & flags) ) { sb.append("*"); } - sb.append("PARENT_"); + sb.append("PARENT "); sb.append(0 != ( FLAG_HAS_PARENT & flags)); sb.append(", "); if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { sb.append("*"); } - sb.append("FS_"); + sb.append("FS "); sb.append(0 != ( FLAG_IS_FULLSCREEN & flags)); - sb.append("_span_"); + sb.append("[span "); sb.append(0 != ( FLAG_IS_FULLSCREEN_SPAN & flags)); - sb.append(", "); + sb.append("], "); if( 0 != ( FLAG_CHANGE_DECORATION & flags) ) { sb.append("*"); } - sb.append("UNDECOR_"); + sb.append("UNDECOR "); sb.append(0 != ( FLAG_IS_UNDECORATED & flags)); sb.append(", "); if( 0 != ( FLAG_CHANGE_ALWAYSONTOP & flags) ) { sb.append("*"); } - sb.append("ALWAYSONTOP_"); + sb.append("ALWAYSONTOP "); sb.append(0 != ( FLAG_IS_ALWAYSONTOP & flags)); sb.append(", "); if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { sb.append("*"); } - sb.append("VISIBLE_"); + sb.append("VISIBLE "); sb.append(0 != ( FLAG_IS_VISIBLE & flags)); sb.append("]"); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 7db3e2aab..641d7437c 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -170,14 +170,20 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected void requestFocusImpl(final boolean force) { + final boolean _isFullscreen = isFullscreen(); + final boolean _isOffscreenInstance = isOffscreenInstance; if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow: requestFocusImpl(), isOffscreenInstance "+isOffscreenInstance); + System.err.println("MacWindow: requestFocusImpl(), isOffscreenInstance "+_isOffscreenInstance+", isFullscreen "+_isFullscreen); } - if(!isOffscreenInstance) { + if(!_isOffscreenInstance) { OSXUtil.RunOnMainThread(false, new Runnable() { @Override public void run() { requestFocus0(getWindowHandle(), force); + if(_isFullscreen) { + // 'NewtMacWindow::windowDidBecomeKey()' is not always called in fullscreen-mode! + focusChanged(false, true); + } } } ); } else { focusChanged(false, true); @@ -516,7 +522,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override public void run() { initWindow0( parentWinHandle, newWin, pS.getX(), pS.getY(), width, height, - isOpaque, fullscreen, visible && !offscreenInstance, surfaceHandle); + isOpaque, visible && !offscreenInstance, surfaceHandle); if( offscreenInstance ) { orderOut0(0!=parentWinHandle ? parentWinHandle : newWin); } else { @@ -534,8 +540,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private native long createView0(int x, int y, int w, int h, boolean fullscreen); private native long createWindow0(int x, int y, int w, int h, boolean fullscreen, int windowStyle, int backingStoreType, long view); /** Must be called on Main-Thread */ - private native void initWindow0(long parentWindow, long window, int x, int y, int w, int h, - boolean opaque, boolean fullscreen, boolean visible, long view); + private native void initWindow0(long parentWindow, long window, int x, int y, int w, int h, boolean opaque, boolean visible, long view); private native boolean lockSurface0(long window, long view); private native boolean unlockSurface0(long window, long view); /** Must be called on Main-Thread */ diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 3e8935787..30d3458ad 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -693,11 +693,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initWindow0 (JNIEnv *env, jobject jthis, jlong parent, jlong window, jint x, jint y, jint w, jint h, - jboolean opaque, jboolean fullscreen, jboolean visible, jlong jview) + jboolean opaque, jboolean visible, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* myWindow = (NewtMacWindow*) ((intptr_t) window); NewtView* myView = (NewtView*) (intptr_t) jview ; + BOOL fullscreen = myWindow->isFullscreenWindow; DBG_PRINT( "initWindow0 - %p (this), %p (parent), %p (window), %d/%d %dx%d, opaque %d, fs %d, visible %d, view %p (START)\n", (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, (int)x, (int)y, (int)w, (int)h, @@ -824,8 +825,20 @@ NS_ENDHANDLER // [myView lockFocus]; // [myView unlockFocus]; + // Set the next responder to be the window so that we can forward + // right mouse button down events + [myView setNextResponder: myWindow]; + + DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n", + dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView); + + [myView setDestroyNotifySent: false]; + setJavaWindowObject(env, jthis, myView, YES); + + DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n", + dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView); + NS_DURING - // Available >= 10.5 - Makes the menubar disapear if( fullscreen ) { /** * See Bug 914: We don't use exclusive fullscreen anymore (capturing display) @@ -834,29 +847,18 @@ NS_DURING * * if ( [myView respondsToSelector:@selector(enterFullScreenMode:withOptions:)] ) { + // Available >= 10.5 - Makes the menubar disapear [myView enterFullScreenMode: myScreen withOptions:NULL]; } */ - if ( 0 != myView->fullscreenPresentationOptions ) { - [NSApp setPresentationOptions: myView->fullscreenPresentationOptions]; - } - } else { - if ( 0 != myView->defaultPresentationOptions ) { - [NSApp setPresentationOptions: myView->defaultPresentationOptions]; + if( myWindow->hasPresentationSwitch ) { + DBG_PRINT( "initWindow0.%d - %p view %p, setPresentationOptions 0x%X\n", + dbgIdx++, myWindow, myView, (int)myWindow->fullscreenPresentationOptions); + [NSApp setPresentationOptions: myWindow->fullscreenPresentationOptions]; } } NS_HANDLER NS_ENDHANDLER - // Set the next responder to be the window so that we can forward - // right mouse button down events - [myView setNextResponder: myWindow]; - - DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n", - dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView); - - [myView setDestroyNotifySent: false]; - setJavaWindowObject(env, jthis, myView, YES); - DBG_PRINT( "initWindow0.%d - %p (this), %p (parent): new window: %p, view %p\n", dbgIdx++, (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView); @@ -890,6 +892,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 return; } NewtView* mView = (NewtView *)[mWin contentView]; + BOOL fullscreen = mWin->isFullscreenWindow; BOOL destroyNotifySent, isNSView, isNewtView; if( NULL != mView ) { isNSView = [mView isKindOfClass:[NSView class]]; @@ -901,8 +904,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 destroyNotifySent = false; } - DBG_PRINT( "windowClose.0 - %p, destroyNotifySent %d, view %p [isNSView %d, isNewtView %d], parent %p\n", - mWin, destroyNotifySent, mView, isNSView, isNewtView, pWin); + DBG_PRINT( "windowClose.0 - %p, destroyNotifySent %d, view %p [isNSView %d, isNewtView %d], fullscreen %d, parent %p\n", + mWin, destroyNotifySent, mView, isNSView, isNewtView, (int)fullscreen, pWin); [mWin setRealized: NO]; @@ -913,8 +916,10 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 } NS_DURING + /** + * See Bug 914: We don't use exclusive fullscreen anymore (capturing display) + * See initWindow0(..) above .. if(NULL!=mView) { - // Available >= 10.5 - Makes the menubar disapear BOOL iifs; if ( [mView respondsToSelector:@selector(isInFullScreenMode)] ) { iifs = [mView isInFullScreenMode]; @@ -924,7 +929,15 @@ NS_DURING if(iifs && [mView respondsToSelector:@selector(exitFullScreenModeWithOptions:)] ) { [mView exitFullScreenModeWithOptions: NULL]; } - // Note: mWin's release will also release it's mView! + } */ + // Note: mWin's release will also release it's mView! + DBG_PRINT( "windowClose.1a - %p view %p, fullscreen %d, hasPresSwitch %d, defaultPresentationOptions 0x%X\n", + mWin, mView, (int)fullscreen, (int)mWin->hasPresentationSwitch, (int)mWin->defaultPresentationOptions); + + if( fullscreen && mWin->hasPresentationSwitch ) { + DBG_PRINT( "windowClose.1b - %p view %p, setPresentationOptions 0x%X\n", + mWin, mView, (int)mWin->defaultPresentationOptions); + [NSApp setPresentationOptions: mWin->defaultPresentationOptions]; } NS_HANDLER NS_ENDHANDLER @@ -934,7 +947,7 @@ NS_ENDHANDLER } [mWin orderOut: mWin]; - DBG_PRINT( "windowClose.1 - %p view %p, parent %p\n", mWin, mView, pWin); + DBG_PRINT( "windowClose.2 - %p view %p, parent %p\n", mWin, mView, pWin); [mWin release]; @@ -1208,7 +1221,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setAlwaysOnTo NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); - DBG_PRINT( "setAlwaysOnTop0 - window: %p (START)\n", win); + DBG_PRINT( "setAlwaysOnTop0 - window: %p, atop %d (START)\n", win, (int)atop); if(atop) { [win setLevel:NSFloatingWindowLevel]; @@ -1216,7 +1229,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setAlwaysOnTo [win setLevel:NSNormalWindowLevel]; } - DBG_PRINT( "setAlwaysOnTop0 - window: %p (END)\n", win); + DBG_PRINT( "setAlwaysOnTop0 - window: %p, atop %d (END)\n", win, (int)atop); [pool release]; } diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index a3bd5c41b..ba60b5665 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -64,9 +64,6 @@ volatile NSTrackingRectTag ptrTrackingTag; NSRect ptrRect; NSCursor * myCursor; -@public - NSUInteger defaultPresentationOptions; - NSUInteger fullscreenPresentationOptions; } - (id)initWithFrame:(NSRect)frameRect; @@ -113,7 +110,6 @@ @interface NewtMacWindow : NSWindow #endif { - BOOL isFullscreenWindow; BOOL mouseConfined; BOOL mouseVisible; BOOL mouseInside; @@ -122,6 +118,10 @@ BOOL modsDown[4]; // shift, ctrl, alt/option, win/command NSPoint lastInsideMousePosition; @public + BOOL hasPresentationSwitch; + NSUInteger defaultPresentationOptions; + NSUInteger fullscreenPresentationOptions; + BOOL isFullscreenWindow; int cachedInsets[4]; // l, r, t, b } diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 266b63081..4b0198c7e 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -129,27 +129,6 @@ static jmethodID windowRepaintID = NULL; */ myCursor = NULL; - // OSX 10.6 - if ( [NSApp respondsToSelector:@selector(currentSystemPresentationOptions)] && - [NSApp respondsToSelector:@selector(setPresentationOptions:)] ) { - defaultPresentationOptions = [NSApp currentSystemPresentationOptions]; - fullscreenPresentationOptions = - // NSApplicationPresentationDefault| - // NSApplicationPresentationAutoHideDock| - NSApplicationPresentationHideDock| - // NSApplicationPresentationAutoHideMenuBar| - NSApplicationPresentationHideMenuBar| - NSApplicationPresentationDisableAppleMenu| - // NSApplicationPresentationDisableProcessSwitching| - // NSApplicationPresentationDisableSessionTermination| - NSApplicationPresentationDisableHideApplication| - // NSApplicationPresentationDisableMenuBarTransparency| - 0 ; - } else { - defaultPresentationOptions = 0; - fullscreenPresentationOptions = 0; - } - DBG_PRINT("NewtView::create: %p (refcnt %d)\n", res, (int)[res retainCount]); return res; } @@ -466,6 +445,29 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { styleMask: windowStyle backing: bufferingType defer: deferCreation]; + // OSX 10.6 + if ( [NSApp respondsToSelector:@selector(currentSystemPresentationOptions)] && + [NSApp respondsToSelector:@selector(setPresentationOptions:)] ) { + hasPresentationSwitch = YES; + defaultPresentationOptions = [NSApp currentSystemPresentationOptions]; + fullscreenPresentationOptions = + // NSApplicationPresentationDefault| + // NSApplicationPresentationAutoHideDock| + NSApplicationPresentationHideDock| + // NSApplicationPresentationAutoHideMenuBar| + NSApplicationPresentationHideMenuBar| + NSApplicationPresentationDisableAppleMenu| + // NSApplicationPresentationDisableProcessSwitching| + // NSApplicationPresentationDisableSessionTermination| + NSApplicationPresentationDisableHideApplication| + // NSApplicationPresentationDisableMenuBarTransparency| + // NSApplicationPresentationFullScreen| // OSX 10.7 + 0 ; + } else { + hasPresentationSwitch = NO; + defaultPresentationOptions = 0; + fullscreenPresentationOptions = 0; + } isFullscreenWindow = isfs; // Why is this necessary? Without it we don't get any of the // delegate methods like resizing and window movement. @@ -483,7 +485,8 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { mouseInside = NO; cursorIsHidden = NO; realized = YES; - DBG_PRINT("NewtWindow::create: %p, realized %d (refcnt %d)\n", res, realized, (int)[res retainCount]); + DBG_PRINT("NewtWindow::create: %p, realized %d, hasPresentationSwitch %d[defaultOptions 0x%X, fullscreenOptions 0x%X], (refcnt %d)\n", + res, realized, (int)hasPresentationSwitch, (int)defaultPresentationOptions, (int)fullscreenPresentationOptions, (int)[res retainCount]); return res; } -- cgit v1.2.3 From f8c2a90129736844a12b76d658cb339a7c36cd9a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 10 Dec 2013 21:27:14 +0100 Subject: Bug 904: 'User Vertical Flip' for GLJPanel w/o vertical flip must be considered in AWTTilePainter: 'Origin of GL image is still on Bottom' --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 4 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 2 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 2 +- .../classes/jogamp/opengl/awt/AWTTilePainter.java | 21 ++- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 2 +- .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 77 ++++++++-- .../jogl/tile/TestTiledPrintingGearsSwingAWT2.java | 161 +++++++++++++++------ 8 files changed, 201 insertions(+), 72 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 22d474e7f..6d79c596c 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -32,7 +32,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRenderi REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* @@ -115,7 +115,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bdc67a5fa..26b70cbd0 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -366,7 +366,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* @@ -567,7 +567,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* -testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 36c0144a9..0bc002f8e 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -858,7 +858,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } - printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); + printAWTTiles.setGLOrientation(printGLAD.isGLOriented(), printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 8670c3746..a71b47c64 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -649,7 +649,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } - printAWTTiles.setIsGLOriented( !GLJPanel.this.skipGLOrientationVerticalFlip && printGLAD.isGLOriented() ); + printAWTTiles.setGLOrientation( !GLJPanel.this.skipGLOrientationVerticalFlip && printGLAD.isGLOriented(), printGLAD.isGLOriented() ); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index ff07b04d0..1c1d2350a 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -74,7 +74,10 @@ public class AWTTilePainter { public final int customTileWidth, customTileHeight, customNumSamples; public final boolean verbose; + /** Default for OpenGL: True */ public boolean flipVertical; + /** Default for OpenGL: True */ + public boolean originBottomLeft; private AWTGLPixelBuffer tBuffer = null; private BufferedImage vFlipImage = null; private Graphics2D g2d = null; @@ -148,10 +151,18 @@ public class AWTTilePainter { } @Override - public String toString() { return renderer.toString(); } + public String toString() { + return "AWTTilePainter[flipVertical "+flipVertical+", startFromBottom "+originBottomLeft+", "+ + renderer.toString()+"]"; + } - public void setIsGLOriented(boolean v) { - flipVertical = v; + /** + * @param flipVertical if true, the image will be flipped vertically (Default for OpenGL). + * @param originBottomLeft if true, the image's origin is on the bottom left (Default for OpenGL). + */ + public void setGLOrientation(boolean flipVertical, boolean originBottomLeft) { + this.flipVertical = flipVertical; + this.originBottomLeft = originBottomLeft; } private static Rectangle2D getClipBounds2D(Graphics2D g) { @@ -307,7 +318,7 @@ public class AWTTilePainter { final int tHeight = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT); final int tY = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); final int tYOff = renderer.getParam(TileRenderer.TR_TILE_Y_OFFSET); - final int imgYOff = flipVertical ? 0 : renderer.getParam(TileRenderer.TR_TILE_HEIGHT) - tHeight; // imgYOff will be cut-off via sub-image + final int imgYOff = originBottomLeft ? 0 : renderer.getParam(TileRenderer.TR_TILE_HEIGHT) - tHeight; // imgYOff will be cut-off via sub-image final int pX = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); // tileX == pX final int pY = cis.getHeight() - ( tY - tYOff + tHeight ) + scaledYOffset; @@ -380,7 +391,7 @@ public class AWTTilePainter { System.err.println("XXX tile-post.X "+renderer); System.err.println("XXX tile-post.X dst-img "+dstImage.getWidth()+"x"+dstImage.getHeight()); System.err.println("XXX tile-post.X out-img "+outImage.getWidth()+"x"+outImage.getHeight()); - System.err.println("XXX tile-post.X y-flip "+flipVertical+" -> "+pX+"/"+pY+", drawDone "+drawDone); + System.err.println("XXX tile-post.X y-flip "+flipVertical+", originBottomLeft "+originBottomLeft+" -> "+pX+"/"+pY+", drawDone "+drawDone); } } @Override diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index b6b8cf9e8..d0ec8ae36 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -673,7 +673,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } - printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); + printAWTTiles.setGLOrientation(printGLAD.isGLOriented(), printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java index e0d0e00dc..3dd3a83c8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java @@ -100,11 +100,12 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { public static void releaseClass() { } - protected void runTestGL(GLCapabilities caps, boolean layered) throws InterruptedException, InvocationTargetException { + protected void runTestGL(GLCapabilities caps, boolean layered, boolean skipGLOrientationVerticalFlip) throws InterruptedException, InvocationTargetException { final int layerStepX = width/6, layerStepY = height/6; final Dimension glc_sz = new Dimension(layered ? width - 2*layerStepX : width/2, layered ? height - 2*layerStepY : height); final GLJPanel glJPanel1 = new GLJPanel(caps); Assert.assertNotNull(glJPanel1); + glJPanel1.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip); glJPanel1.setMinimumSize(glc_sz); glJPanel1.setPreferredSize(glc_sz); if( layered ) { @@ -112,10 +113,15 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { } else { glJPanel1.setBounds(0, 0, glc_sz.width, glc_sz.height); } - glJPanel1.addGLEventListener(new Gears()); + { + final Gears demo = new Gears(); + demo.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); + glJPanel1.addGLEventListener(demo); + } final GLJPanel glJPanel2 = new GLJPanel(caps); Assert.assertNotNull(glJPanel2); + glJPanel2.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip); glJPanel2.setMinimumSize(glc_sz); glJPanel2.setPreferredSize(glc_sz); if( layered ) { @@ -123,8 +129,11 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { } else { glJPanel2.setBounds(0, 0, glc_sz.width, glc_sz.height); } - glJPanel2.addGLEventListener(new RedSquareES1()); - // glJPanel2.addGLEventListener(new Gears()); + { + final RedSquareES1 demo = new RedSquareES1(); + demo.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); + glJPanel2.addGLEventListener(demo); + } final JComponent demoPanel; if( layered ) { @@ -293,43 +302,83 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { } @Test - public void test01_aa0() throws InterruptedException, InvocationTargetException { + public void test01_flip1_aa0() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + runTestGL(caps, false, false); + } + + @Test + public void test01_flip1_aa0_layered() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + caps.setAlphaBits(8); + runTestGL(caps, true, false); + } + + @Test + public void test01_flip1_aa0_bitmap() throws InterruptedException, InvocationTargetException { + if( Platform.OSType.WINDOWS == Platform.getOSType() ) { + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + runTestGL(caps, false, false); + } // issues w/ AMD catalyst driver and pixmap surface .. + } + + @Test + public void test01_flip1_aa0_bitmap_layered() throws InterruptedException, InvocationTargetException { + if( Platform.OSType.WINDOWS == Platform.getOSType() ) { + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + caps.setAlphaBits(8); + runTestGL(caps, true, false); + } // issues w/ AMD catalyst driver and pixmap surface .. + } + + @Test + public void test02_flip1_aa8() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(8); + runTestGL(caps, false, false); + } + + @Test + public void test11_flip0_aa0() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); - runTestGL(caps, false); + runTestGL(caps, false, true); } @Test - public void test01_aa0_layered() throws InterruptedException, InvocationTargetException { + public void test11_flip0_aa0_layered() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); caps.setAlphaBits(8); - runTestGL(caps, true); + runTestGL(caps, true, true); } @Test - public void test01_aa0_bitmap() throws InterruptedException, InvocationTargetException { + public void test11_flip0_aa0_bitmap() throws InterruptedException, InvocationTargetException { if( Platform.OSType.WINDOWS == Platform.getOSType() ) { GLCapabilities caps = new GLCapabilities(glp); caps.setBitmap(true); - runTestGL(caps, false); + runTestGL(caps, false, true); } // issues w/ AMD catalyst driver and pixmap surface .. } @Test - public void test01_aa0_bitmap_layered() throws InterruptedException, InvocationTargetException { + public void test11_flip0_aa0_bitmap_layered() throws InterruptedException, InvocationTargetException { if( Platform.OSType.WINDOWS == Platform.getOSType() ) { GLCapabilities caps = new GLCapabilities(glp); caps.setBitmap(true); caps.setAlphaBits(8); - runTestGL(caps, true); + runTestGL(caps, true, true); } // issues w/ AMD catalyst driver and pixmap surface .. } @Test - public void test02_aa8() throws InterruptedException, InvocationTargetException { + public void test12_flip0_aa8() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); caps.setSampleBuffers(true); caps.setNumSamples(8); - runTestGL(caps, false); + runTestGL(caps, false, true); } static long duration = 500; // ms diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java index 2d4973d6b..29bf8a6c3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.tile; import java.awt.BorderLayout; @@ -77,7 +77,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { static boolean waitForKey = false; static GLProfile glp; static int width, height; - + @BeforeClass public static void initClass() { if(GLProfile.isAvailable(GLProfile.GL2)) { @@ -95,16 +95,21 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { @AfterClass public static void releaseClass() { } - - protected void runTestGL(GLCapabilities caps, final boolean addLayout, boolean layered, boolean useAnim) throws InterruptedException, InvocationTargetException { + + protected void runTestGL(GLCapabilities caps, final boolean addLayout, boolean layered, boolean skipGLOrientationVerticalFlip, boolean useAnim) throws InterruptedException, InvocationTargetException { final Dimension glc_sz = new Dimension(width, height); final GLJPanel glJPanel1 = new GLJPanel(caps); - Assert.assertNotNull(glJPanel1); + Assert.assertNotNull(glJPanel1); + glJPanel1.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip); glJPanel1.setMinimumSize(glc_sz); glJPanel1.setPreferredSize(glc_sz); glJPanel1.setBounds(0, 0, glc_sz.width, glc_sz.height); - glJPanel1.addGLEventListener(new Gears()); - + { + final Gears demo = new Gears(); + demo.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); + glJPanel1.addGLEventListener(demo); + } + final JComponent tPanel, demoPanel; if( layered ) { glJPanel1.setOpaque(true); @@ -133,13 +138,13 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { demoPanel = new JPanel(); demoPanel.add(glJPanel1); } else { - demoPanel = glJPanel1; + demoPanel = glJPanel1; } } - + final JFrame frame = new JFrame("Swing Print"); Assert.assertNotNull(frame); - + final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { doPrintManual(frame, 72, 0, -1, -1); @@ -158,7 +163,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { print150DPIButton.addActionListener(print150DPIAction); final Button print300DPIButton = new Button("300dpi"); print300DPIButton.addActionListener(print300DPIAction); - + final JPanel printPanel = new JPanel(); printPanel.add(print72DPIButton); printPanel.add(print150DPIButton); @@ -169,7 +174,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { eastPanel.add(new Label("East")); final JPanel westPanel = new JPanel(); westPanel.add(new Label("West")); - + final Animator animator = useAnim ? new Animator() : null; if( null != animator ) { animator.add(glJPanel1); @@ -181,7 +186,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { SwingUtilities.invokeAndWait(new Runnable() { public void run() { - final Container fcont = frame.getContentPane(); + final Container fcont = frame.getContentPane(); if( addLayout ) { fcont.setLayout(new BorderLayout()); fcont.add(printPanel, BorderLayout.NORTH); @@ -201,12 +206,12 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { } frame.setVisible(true); } } ) ; - + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel1, true)); - + if( null != animator ) { - animator.setUpdateFPSFrames(60, System.err); + animator.setUpdateFPSFrames(60, System.err); animator.start(); Assert.assertEquals(true, animator.isAnimating()); } @@ -226,11 +231,11 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { } t1 = System.currentTimeMillis(); } - + Assert.assertNotNull(frame); Assert.assertNotNull(glJPanel1); - if( null != animator ) { + if( null != animator ) { animator.stop(); Assert.assertEquals(false, animator.isAnimating()); } @@ -248,69 +253,133 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { } @Test - public void test01_norm_layout0_layered0() throws InterruptedException, InvocationTargetException { + public void test001_flip1_norm_layout0_layered0() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); - runTestGL(caps, false /* addLayout */, false /* layered */, false /* useAnim */); + runTestGL(caps, false /* addLayout */, false /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test02_norm_layout1_layered0() throws InterruptedException, InvocationTargetException { + public void test002_flip1_norm_layout1_layered0() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); - runTestGL(caps, true /* addLayout */, false /* layered */, false /* useAnim */); + runTestGL(caps, true /* addLayout */, false /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test03_norm_layout0_layered1() throws InterruptedException, InvocationTargetException { + public void test003_flip1_norm_layout0_layered1() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); - runTestGL(caps, false /* addLayout */, true /* layered */, false /* useAnim */); + runTestGL(caps, false /* addLayout */, true /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test04_norm_layout1_layered1() throws InterruptedException, InvocationTargetException { + public void test004_flip1_norm_layout1_layered1() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); - runTestGL(caps, true /* addLayout */, true /* layered */, false /* useAnim */); + runTestGL(caps, true /* addLayout */, true /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test11_bitm_layout0_layered0() throws InterruptedException, InvocationTargetException { + public void test011_flip1_bitm_layout0_layered0() throws InterruptedException, InvocationTargetException { if( Platform.OSType.WINDOWS != Platform.getOSType() ) { return; } GLCapabilities caps = new GLCapabilities(glp); caps.setBitmap(true); - runTestGL(caps, false /* addLayout */, false /* layered */, false /* useAnim */); + runTestGL(caps, false /* addLayout */, false /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test12_bitm_layout1_layered0() throws InterruptedException, InvocationTargetException { + public void test012_flip1_bitm_layout1_layered0() throws InterruptedException, InvocationTargetException { if( Platform.OSType.WINDOWS != Platform.getOSType() ) { return; } GLCapabilities caps = new GLCapabilities(glp); caps.setBitmap(true); - runTestGL(caps, true /* addLayout */, false /* layered */, false /* useAnim */); + runTestGL(caps, true /* addLayout */, false /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test13_bitm_layout0_layered1() throws InterruptedException, InvocationTargetException { + public void test013_flip1_bitm_layout0_layered1() throws InterruptedException, InvocationTargetException { if( Platform.OSType.WINDOWS != Platform.getOSType() ) { return; } GLCapabilities caps = new GLCapabilities(glp); caps.setBitmap(true); - runTestGL(caps, false /* addLayout */, true /* layered */, false /* useAnim */); + runTestGL(caps, false /* addLayout */, true /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test14_bitm_layout1_layered1() throws InterruptedException, InvocationTargetException { + public void test014_flip1_bitm_layout1_layered1() throws InterruptedException, InvocationTargetException { if( Platform.OSType.WINDOWS != Platform.getOSType() ) { return; } GLCapabilities caps = new GLCapabilities(glp); caps.setBitmap(true); - runTestGL(caps, true /* addLayout */, true /* layered */, false /* useAnim */); + runTestGL(caps, true /* addLayout */, true /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test101_flip1_norm_layout0_layered0() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + runTestGL(caps, false /* addLayout */, false /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test102_flip1_norm_layout1_layered0() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + runTestGL(caps, true /* addLayout */, false /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test103_flip1_norm_layout0_layered1() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + runTestGL(caps, false /* addLayout */, true /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + + @Test + public void test104_flip1_norm_layout1_layered1() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + runTestGL(caps, true /* addLayout */, true /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test111_flip1_bitm_layout0_layered0() throws InterruptedException, InvocationTargetException { + if( Platform.OSType.WINDOWS != Platform.getOSType() ) { + return; + } + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + runTestGL(caps, false /* addLayout */, false /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test112_flip1_bitm_layout1_layered0() throws InterruptedException, InvocationTargetException { + if( Platform.OSType.WINDOWS != Platform.getOSType() ) { + return; + } + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + runTestGL(caps, true /* addLayout */, false /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test113_flip1_bitm_layout0_layered1() throws InterruptedException, InvocationTargetException { + if( Platform.OSType.WINDOWS != Platform.getOSType() ) { + return; + } + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + runTestGL(caps, false /* addLayout */, true /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test114_flip1_bitm_layout1_layered1() throws InterruptedException, InvocationTargetException { + if( Platform.OSType.WINDOWS != Platform.getOSType() ) { + return; + } + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + runTestGL(caps, true /* addLayout */, true /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + static long duration = 500; // ms public static void main(String args[]) { -- cgit v1.2.3 From a00406f289ebaaae8d91e9ccc980829f202421a8 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 11 Dec 2013 05:23:31 +0100 Subject: Bug 922 (1/2): NEWT Window.reparentWindow(..): Provide REPARENT_HINT_BECOMES_VISIBLE hint via new method variant using hints; Deprecate other reparentWindow(..) variants w/o hints. NEWT Window.reparentWindow(..): Provide REPARENT_HINT_BECOMES_VISIBLE hint via new method variant using hints: - Add REPARENT_HINT_FORCE_RECREATION, covering 'old' forceDestroyCreate boolean argument - Add REPARENT_HINT_BECOMES_VISIBLE, Claim window becomes visible after reparenting, which is important for e.g. preserving the GL-states in case window is invisible while reparenting. Deprecate other reparentWindow(..) variants w/o hints. Use only new variant using hints w/o semantical change. --- make/scripts/tests.sh | 6 +- src/newt/classes/com/jogamp/newt/Window.java | 25 +++++++- .../classes/com/jogamp/newt/opengl/GLWindow.java | 5 ++ src/newt/classes/jogamp/newt/WindowImpl.java | 55 ++++++++++++------ .../parenting/NewtAWTReparentingKeyAdapter.java | 28 ++++----- .../junit/newt/parenting/TestParenting01NEWT.java | 64 +++++++++++---------- .../junit/newt/parenting/TestParenting01aAWT.java | 66 +++++++++------------- .../junit/newt/parenting/TestParenting01bAWT.java | 30 +++++----- .../junit/newt/parenting/TestParenting01cAWT.java | 4 +- .../newt/parenting/TestParenting01cSwingAWT.java | 4 +- .../junit/newt/parenting/TestParenting02AWT.java | 24 ++++---- .../junit/newt/parenting/TestParenting02NEWT.java | 20 +++---- .../junit/newt/parenting/TestParenting03AWT.java | 30 +++++----- .../junit/newt/parenting/TestParenting04AWT.java | 4 +- .../junit/newt/parenting/TestParenting04SWT.java | 4 +- 15 files changed, 206 insertions(+), 163 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6cf493de2..9b7d43453 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -147,10 +147,8 @@ function jrun() { #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLArrayData" - #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" - #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Screen" #D_ARGS="-Dnewt.test.Screen.disableRandR13" @@ -163,7 +161,6 @@ function jrun() { #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil" - #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" @@ -414,7 +411,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* @@ -611,6 +608,7 @@ testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 869b56331..5c3bb7889 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -353,6 +353,11 @@ public interface Window extends NativeWindow, WindowClosingProtocol { ACTION_NATIVE_CREATION_PENDING; } + /** Reparenting hint (bitfield value): Force destroy and hence {@link ReparentOperation#ACTION_NATIVE_CREATION re-creating} the window. */ + public static final int REPARENT_HINT_FORCE_RECREATION = 1 << 0; + /** Reparenting hint (bitfield value): Claim window becomes visible after reparenting, which is important for e.g. preserving the GL-states in case window is invisible while reparenting. */ + public static final int REPARENT_HINT_BECOMES_VISIBLE = 1 << 1; + /** * Change this window's parent window.
                      *

                      @@ -365,6 +370,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * * @return The issued reparent action type (strategy) as defined in Window.ReparentAction * @see #reparentWindow(NativeWindow, int, int, boolean) + * @deprecated Use {@link #reparentWindow(NativeWindow, int, int, int)} */ ReparentOperation reparentWindow(NativeWindow newParent); @@ -382,10 +388,27 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * @param forceDestroyCreate if true, uses re-creation strategy for reparenting, default is false. * * @return The issued reparent action type (strategy) as defined in Window.ReparentAction - * @see #reparentWindow(NativeWindow) + * @deprecated Use {@link #reparentWindow(NativeWindow, int, int, int)} */ ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate); + /** + * Change this window's parent window.
                      + *

                      + * In case the old parent is not null and a Window, + * this window is removed from it's list of children.
                      + * In case the new parent is not null and a Window, + * this window is added to it's list of children.

                      + * + * @param newParent The new parent NativeWindow. If null, this Window becomes a top level window. + * @param x new top-level position, use -1 for default position. + * @param y new top-level position, use -1 for default position. + * @param hints May contain hints (bitfield values) like {@link #REPARENT_HINT_FORCE_RECREATION} or {@link #REPARENT_HINT_BECOMES_VISIBLE}. + * + * @return The issued reparent action type (strategy) as defined in Window.ReparentAction + */ + ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints); + /** * Enable or disable fullscreen mode for this window. *

                      diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 52f19f783..208602aa1 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -396,6 +396,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return window.reparentWindow(newParent, x, y, forceDestroyCreate); } + @Override + public final ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints) { + return window.reparentWindow(newParent, x, y, hints); + } + @Override public final boolean removeChild(NativeWindow win) { return window.removeChild(win); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 21343b263..ae4cb9924 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1186,14 +1186,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class ReparentAction implements Runnable { final NativeWindow newParentWindow; final int topLevelX, topLevelY; - boolean forceDestroyCreate; + final int hints; ReparentOperation operation; - private ReparentAction(NativeWindow newParentWindow, int topLevelX, int topLevelY, boolean forceDestroyCreate) { + private ReparentAction(NativeWindow newParentWindow, int topLevelX, int topLevelY, int hints) { this.newParentWindow = newParentWindow; this.topLevelX = topLevelX; this.topLevelY = topLevelY; - this.forceDestroyCreate = forceDestroyCreate | DEBUG_TEST_REPARENT_INCOMPATIBLE; + if( DEBUG_TEST_REPARENT_INCOMPATIBLE ) { + hints |= REPARENT_HINT_FORCE_RECREATION; + } + this.hints = hints; this.operation = ReparentOperation.ACTION_INVALID; // ensure it's set } @@ -1227,17 +1230,25 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final int x, y; int width = oldWidth; int height = oldHeight; - boolean wasVisible; + + final boolean wasVisible; + final boolean becomesVisible; + final boolean forceDestroyCreate; final RecursiveLock _lock = windowLock; _lock.lock(); try { - if(isNativeValid()) { - // force recreation if offscreen, since it may become onscreen - forceDestroyCreate |= isOffscreenInstance(WindowImpl.this, newParentWindow); + { + boolean v = 0 != ( REPARENT_HINT_FORCE_RECREATION & hints ); + if(isNativeValid()) { + // force recreation if offscreen, since it may become onscreen + v |= isOffscreenInstance(WindowImpl.this, newParentWindow); + } + forceDestroyCreate = v; } wasVisible = isVisible(); + becomesVisible = wasVisible || 0 != ( REPARENT_HINT_BECOMES_VISIBLE & hints ); Window newParentWindowNEWT = null; if(newParentWindow instanceof Window) { @@ -1246,8 +1257,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer long newParentWindowHandle = 0 ; - if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparent: START ("+getThreadName()+") valid "+isNativeValid()+", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+", visible "+wasVisible+", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow)+", forceDestroyCreate "+forceDestroyCreate); + if( DEBUG_IMPLEMENTATION) { + System.err.println("Window.reparent: START ("+getThreadName()+") valid "+isNativeValid()+ + ", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+ + ", visible "+wasVisible+", becomesVisible "+becomesVisible+ + ", forceDestroyCreate "+forceDestroyCreate+ + ", HINT_FORCE_RECREATION "+( 0 != ( REPARENT_HINT_FORCE_RECREATION & hints ) )+ + ", HINT_BECOMES_VISIBLE "+( 0 != ( REPARENT_HINT_BECOMES_VISIBLE & hints ) ) + + ", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+ + ", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow) ); } if(null!=newParentWindow) { @@ -1274,7 +1292,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } // Destroy this window and use parent's Screen. // It may be created properly when the parent is made visible. - destroy( false ); + destroy( becomesVisible ); setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); operation = ReparentOperation.ACTION_NATIVE_CREATION_PENDING; } else if(newParentWindow != getParent()) { @@ -1298,7 +1316,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } else if ( forceDestroyCreate || !NewtFactory.isScreenCompatible(newParentWindow, screen) ) { // Destroy this window, may create a new compatible Screen/Display, while trying to preserve resources if becoming visible again. - destroy( wasVisible ); + destroy( becomesVisible ); if(null!=newParentWindowNEWT) { setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); } else { @@ -1336,7 +1354,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else if( !isNativeValid() || forceDestroyCreate ) { // Destroy this window and mark it for [pending] creation. // If isNativeValid() and becoming visible again - try to preserve resources, i.e. b/c on-/offscreen switch. - destroy( isNativeValid() && wasVisible ); + destroy( becomesVisible ); if( 0 < width && 0 < height ) { operation = ReparentOperation.ACTION_NATIVE_CREATION; } else { @@ -1437,7 +1455,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window.reparent: native reparenting failed ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+" -> "+toHexString(newParentWindowHandle)+" - Trying recreation"); } - destroy( wasVisible ); + destroy( becomesVisible ); operation = ReparentOperation.ACTION_NATIVE_CREATION ; } } else { @@ -1500,12 +1518,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final ReparentOperation reparentWindow(NativeWindow newParent) { - return reparentWindow(newParent, -1, -1, false); + return reparentWindow(newParent, -1, -1, 0); } @Override public ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate) { - final ReparentAction reparentAction = new ReparentAction(newParent, x, y, forceDestroyCreate); + return reparentWindow(newParent, x, y, forceDestroyCreate ? REPARENT_HINT_FORCE_RECREATION : 0); + } + + @Override + public ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints) { + final ReparentAction reparentAction = new ReparentAction(newParent, x, y, hints); runOnEDTIfAvail(true, reparentAction); return reparentAction.getOp(); } @@ -2161,7 +2184,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreenMonitors = monitors; fullscreenUseMainMonitor = useMainMonitor; if( fullScreenAction.init(fullscreen) ) { - if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { + if( fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow) ) { // enable fullscreen on offscreen instance if(null != parentWindow) { nfs_parent = parentWindow; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 4bf1f95c3..f7fbc7332 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -42,24 +42,24 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final NewtCanvasAWT newtCanvasAWT; final GLWindow glWindow; final QuitAdapter quitAdapter; - + public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow, QuitAdapter quitAdapter) { this.frame = frame; this.newtCanvasAWT = newtCanvasAWT; this.glWindow = glWindow; this.quitAdapter = quitAdapter; } - + public void keyReleased(KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; - } + } if( e.getKeySymbol() == KeyEvent.VK_I ) { System.err.println(glWindow); } else if( e.getKeySymbol() == KeyEvent.VK_L ) { javax.media.nativewindow.util.Point p0 = newtCanvasAWT.getNativeWindow().getLocationOnScreen(null); javax.media.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null); - System.err.println("NewtCanvasAWT position: "+p0+", "+p1); + System.err.println("NewtCanvasAWT position: "+p0+", "+p1); } else if( e.getKeySymbol() == KeyEvent.VK_D ) { glWindow.setUndecorated(!glWindow.isUndecorated()); } else if( e.getKeySymbol() == KeyEvent.VK_S ) { @@ -68,7 +68,7 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { glWindow.setPosition(100, 100); } else { System.err.println("XXX glWin to 0/0"); - glWindow.setPosition(0, 0); + glWindow.setPosition(0, 0); } } else if( e.getKeySymbol() == KeyEvent.VK_F ) { if( null != quitAdapter ) { @@ -92,8 +92,8 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { if(glWindow.getAnimator().isPaused()) { glWindow.getAnimator().resume(); } else { - glWindow.getAnimator().pause(); - } + glWindow.getAnimator().pause(); + } } }.run(); } else if( e.getKeySymbol() == KeyEvent.VK_R ) { @@ -105,7 +105,7 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final Thread t = glWindow.setExclusiveContextThread(null); if(glWindow.getParent()==null) { System.err.println("XXX glWin to HOME"); - glWindow.reparentWindow(newtCanvasAWT.getNativeWindow()); + glWindow.reparentWindow(newtCanvasAWT.getNativeWindow(), -1, -1, 0 /* hints */); } else { if( null != frame ) { final InsetsImmutable nInsets = glWindow.getInsets(); @@ -121,10 +121,10 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final int topLevelX = frame.getX()+frame.getWidth()+dx; final int topLevelY = frame.getY()+dy; System.err.println("XXX glWin to TOP.1 "+topLevelX+"/"+topLevelY+" - insets " + nInsets + ", " + aInsets); - glWindow.reparentWindow(null, topLevelX, topLevelY, false); + glWindow.reparentWindow(null, topLevelX, topLevelY, 0 /* hint */); } else { System.err.println("XXX glWin to TOP.0"); - glWindow.reparentWindow(null); + glWindow.reparentWindow(null, -1, -1, 0 /* hints */); } } glWindow.requestFocus(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java index 1f19241d8..7beceb291 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.parenting; @@ -62,7 +62,7 @@ public class TestParenting01NEWT extends UITestCase { } @Test - public void testWindowParenting01CreateVisibleDestroy() throws InterruptedException { + public void test01CreateVisibleDestroy() throws InterruptedException { Assert.assertEquals(0,Display.getActiveDisplayNumber()); Display display = null; Screen screen = null; @@ -82,7 +82,7 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(0,Display.getActiveDisplayNumber()); - glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); + glWindow1.setTitle("test01CreateVisibleDestroy"); glWindow1.setSize(640, 480); GLEventListener demo1 = new RedSquareES2(); setDemoFields(demo1, glWindow1, false); @@ -151,13 +151,13 @@ public class TestParenting01NEWT extends UITestCase { glWindow1.resetFPSCounter(); glWindow2.resetFPSCounter(); Animator animator1 = new Animator(glWindow1); - animator1.setUpdateFPSFrames(1, null); + animator1.setUpdateFPSFrames(1, null); animator1.start(); Assert.assertEquals(true, animator1.isAnimating()); Assert.assertEquals(false, animator1.isPaused()); Assert.assertNotNull(animator1.getThread()); Animator animator2 = new Animator(glWindow2); - animator2.setUpdateFPSFrames(1, null); + animator2.setUpdateFPSFrames(1, null); animator2.start(); Assert.assertEquals(true, animator2.isAnimating()); Assert.assertEquals(false, animator2.isPaused()); @@ -286,25 +286,27 @@ public class TestParenting01NEWT extends UITestCase { } @Test - public void testWindowParenting02ReparentTop2WinReparentRecreate() throws InterruptedException { - testWindowParenting02ReparentTop2WinImpl(true); + public void test02aReparentTop2WinReparentRecreate() throws InterruptedException { + test02ReparentTop2WinImpl(true); } @Test - public void testWindowParenting02ReparentTop2WinReparentNative() throws InterruptedException { - testWindowParenting02ReparentTop2WinImpl(false); + public void test02bReparentTop2WinReparentNative() throws InterruptedException { + test02ReparentTop2WinImpl(false); } /** * @param reparentRecreate true, if the followup reparent should utilize destroy/create, instead of native reparenting */ - protected void testWindowParenting02ReparentTop2WinImpl(boolean reparentRecreate) throws InterruptedException { + protected void test02ReparentTop2WinImpl(final boolean reparentRecreate) throws InterruptedException { + final int reparentHints = reparentRecreate ? Window.REPARENT_HINT_FORCE_RECREATION : 0; + Assert.assertEquals(0,Display.getActiveDisplayNumber()); Display display1 = null; Screen screen1 = null; GLWindow glWindow1 = GLWindow.create(glCaps); - glWindow1.setTitle("testWindowParenting02ReparentTop2Win"); + glWindow1.setTitle("test02ReparentTop2Win"); glWindow1.setSize(640, 480); GLEventListener demo1 = new RedSquareES2(); setDemoFields(demo1, glWindow1, false); @@ -379,7 +381,7 @@ public class TestParenting01NEWT extends UITestCase { // glWindow2 -- child --> glWindow1: compatible Assert.assertEquals(true, glWindow2.isVisible()); System.err.println("Frames(1) "+glWindow2.getTotalFPSFrames()); - reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentRecreate); + reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentHints); System.err.println("Frames(2) "+glWindow2.getTotalFPSFrames()); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); @@ -405,7 +407,7 @@ public class TestParenting01NEWT extends UITestCase { // glWindow2 --> top Assert.assertEquals(true, glWindow2.isVisible()); - reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentRecreate); + reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentHints); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); @@ -484,16 +486,18 @@ public class TestParenting01NEWT extends UITestCase { } @Test - public void testWindowParenting03ReparentWin2TopReparentRecreate() throws InterruptedException { - testWindowParenting03ReparentWin2TopImpl(true); + public void test03aReparentWin2TopReparentRecreate() throws InterruptedException { + test03ReparentWin2TopImpl(true); } @Test - public void testWindowParenting03ReparentWin2TopReparentNative() throws InterruptedException { - testWindowParenting03ReparentWin2TopImpl(false); + public void test03bReparentWin2TopReparentNative() throws InterruptedException { + test03ReparentWin2TopImpl(false); } - protected void testWindowParenting03ReparentWin2TopImpl(boolean reparentRecreate) throws InterruptedException { + protected void test03ReparentWin2TopImpl(final boolean reparentRecreate) throws InterruptedException { + final int reparentHints = reparentRecreate ? Window.REPARENT_HINT_FORCE_RECREATION : 0; + Assert.assertEquals(0,Display.getActiveDisplayNumber()); Display display1 = null; Screen screen1 = null; @@ -503,7 +507,7 @@ public class TestParenting01NEWT extends UITestCase { GLWindow glWindow1 = GLWindow.create(glCaps); screen1 = glWindow1.getScreen(); display1 = screen1.getDisplay(); - glWindow1.setTitle("testWindowParenting03ReparentWin2Top"); + glWindow1.setTitle("test03ReparentWin2Top"); glWindow1.setSize(640, 480); GLEventListener demo1 = new RedSquareES2(); setDemoFields(demo1, glWindow1, false); @@ -567,14 +571,14 @@ public class TestParenting01NEWT extends UITestCase { switch(state) { case 0: Assert.assertEquals(true, glWindow2.isVisible()); - reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentRecreate); + reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentHints); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); Thread.sleep(20*16); // Wait for a few frames since counter could be reset - 20 frames at 60Hz System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B2: "+glWindow2.getTotalFPSFrames()); Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); - + Assert.assertNull(glWindow2.getParent()); Assert.assertSame(screen1,glWindow2.getScreen()); Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); @@ -582,14 +586,14 @@ public class TestParenting01NEWT extends UITestCase { break; case 1: Assert.assertEquals(true, glWindow2.isVisible()); - reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentRecreate); + reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentHints); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); Thread.sleep(20*16); // Wait for a few frames since counter could be reset - 20 frames at 60Hz System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B3 "+glWindow2.getTotalFPSFrames()); Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); - + Assert.assertSame(glWindow1,glWindow2.getParent()); Assert.assertSame(screen1,glWindow2.getScreen()); Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); @@ -657,7 +661,7 @@ public class TestParenting01NEWT extends UITestCase { public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { Assert.assertNotNull(demo); - Assert.assertNotNull(glWindow); + Assert.assertNotNull(glWindow); if(debug) { MiscUtils.setFieldIfExists(demo, "glDebug", true); MiscUtils.setFieldIfExists(demo, "glTrace", true); @@ -689,8 +693,8 @@ public class TestParenting01NEWT extends UITestCase { try { TestParenting01NEWT.initClass(); TestParenting01NEWT m = new TestParenting01NEWT(); - m.testWindowParenting02ReparentTop2WinReparentRecreate(); - m.testWindowParenting01CreateVisibleDestroy(); + m.test02aReparentTop2WinReparentRecreate(); + m.test01CreateVisibleDestroy(); } catch (Throwable t ) { t.printStackTrace(); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java index 6de24d1ea..420a39cb2 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -68,7 +68,7 @@ public class TestParenting01aAWT extends UITestCase { } @Test - public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { + public void test01WindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { final GLWindow glWindow1 = GLWindow.create(glCaps); Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); @@ -112,11 +112,11 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); final Animator animator1 = new Animator(glWindow1); - animator1.setUpdateFPSFrames(1, null); + animator1.setUpdateFPSFrames(1, null); animator1.start(); Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow1, true)); - + while(animator1.isAnimating() && animator1.getTotalFPSDuration() TOP: "+glWindow1.reparentWindow(null, -1, -1, 0 /* hints */)); Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParent()); break; case 1: - glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow()); + System.err.println("Reparent TOP -> CHILD: "+glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow(), -1, -1, 0 /* hints */)); Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); break; @@ -315,7 +315,7 @@ public class TestParenting01aAWT extends UITestCase { } @Test - public void testWindowParenting04ReparentNewtWin2TopLayouted() throws InterruptedException, InvocationTargetException { + public void test05WindowParenting04ReparentNewtWin2TopLayouted() throws InterruptedException, InvocationTargetException { GLWindow glWindow1 = GLWindow.create(glCaps); GLEventListener demo1 = new RedSquareES2(); setDemoFields(demo1, glWindow1, false); @@ -329,7 +329,7 @@ public class TestParenting01aAWT extends UITestCase { frame.add(new Button("South"), BorderLayout.SOUTH); frame.add(new Button("East"), BorderLayout.EAST); frame.add(new Button("West"), BorderLayout.WEST); - + SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.setSize(width, height); @@ -344,11 +344,11 @@ public class TestParenting01aAWT extends UITestCase { frame.validate(); } }); - + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); - animator1.setUpdateFPSFrames(1, null); + animator1.setUpdateFPSFrames(1, null); animator1.start(); int state = 0; @@ -356,12 +356,12 @@ public class TestParenting01aAWT extends UITestCase { Thread.sleep(durationPerTest); switch(state) { case 0: - glWindow1.reparentWindow(null); + System.err.println("Reparent CHILD -> TOP: "+glWindow1.reparentWindow(null, -1, -1, 0 /* hints */)); Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParent()); break; case 1: - glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow()); + System.err.println("Reparent TOP -> CHILD: "+glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow(), -1, -1, 0 /* hints */)); Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); break; @@ -380,7 +380,7 @@ public class TestParenting01aAWT extends UITestCase { } @Test - public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { + public void test06WindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUndecorated(true); GLEventListener demo1 = new RedSquareES2(); @@ -427,7 +427,7 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); - animator1.setUpdateFPSFrames(1, null); + animator1.setUpdateFPSFrames(1, null); animator1.start(); int state = 0; @@ -442,7 +442,7 @@ public class TestParenting01aAWT extends UITestCase { frame1.validate(); frame2.validate(); } - }); + }); break; case 1: SwingUtilities.invokeAndWait(new Runnable() { @@ -452,7 +452,7 @@ public class TestParenting01aAWT extends UITestCase { frame2.validate(); frame1.validate(); } - }); + }); break; } state++; @@ -471,7 +471,7 @@ public class TestParenting01aAWT extends UITestCase { public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { Assert.assertNotNull(demo); - Assert.assertNotNull(glWindow); + Assert.assertNotNull(glWindow); if(debug) { MiscUtils.setFieldIfExists(demo, "glDebug", true); MiscUtils.setFieldIfExists(demo, "glTrace", true); @@ -498,17 +498,7 @@ public class TestParenting01aAWT extends UITestCase { } } String tstname = TestParenting01aAWT.class.getName(); - org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] { - tstname, - "filtertrace=true", - "haltOnError=false", - "haltOnFailure=false", - "showoutput=true", - "outputtoformatters=true", - "logfailedtests=true", - "logtestlistenerevents=true", - "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter", - "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); + org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java index 45612eb1a..598e5f10f 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.parenting; import org.junit.Assert; @@ -68,16 +68,16 @@ public class TestParenting01bAWT extends UITestCase { } @Test - public void testWindowParenting05ReparentAWTWinHopFrame2FrameFPS25Animator() throws InterruptedException, InvocationTargetException { - testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(25); + public void test01AWTWinHopFrame2FrameFPS25Animator() throws InterruptedException, InvocationTargetException { + testAWTWinHopFrame2FrameImpl(25); } @Test - public void testWindowParenting05ReparentAWTWinHopFrame2FrameStdAnimator() throws InterruptedException, InvocationTargetException { - testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(0); + public void test02AWTWinHopFrame2FrameStdAnimator() throws InterruptedException, InvocationTargetException { + testAWTWinHopFrame2FrameImpl(0); } - public void testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(int fps) throws InterruptedException, InvocationTargetException { + public void testAWTWinHopFrame2FrameImpl(int fps) throws InterruptedException, InvocationTargetException { GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUndecorated(true); GLEventListener demo1 = new RedSquareES2(); @@ -85,7 +85,7 @@ public class TestParenting01bAWT extends UITestCase { glWindow1.addGLEventListener(demo1); final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - + final Frame frame1 = new Frame("AWT Parent Frame"); frame1.setLayout(new BorderLayout()); frame1.add(new Button("North"), BorderLayout.NORTH); @@ -96,7 +96,7 @@ public class TestParenting01bAWT extends UITestCase { public void run() { frame1.setSize(width, height); frame1.setLocation(0, 0); - frame1.setVisible(true); + frame1.setVisible(true); } }); @@ -110,7 +110,7 @@ public class TestParenting01bAWT extends UITestCase { public void run() { frame2.setSize(width, height); frame2.setLocation(640, 480); - frame2.setVisible(true); + frame2.setVisible(true); } }); @@ -142,7 +142,7 @@ public class TestParenting01bAWT extends UITestCase { frame1.validate(); frame2.validate(); } - }); + }); break; case 1: SwingUtilities.invokeAndWait(new Runnable() { @@ -152,7 +152,7 @@ public class TestParenting01bAWT extends UITestCase { frame2.validate(); frame1.validate(); } - }); + }); break; } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java index dd5d6eb13..1d7401728 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java @@ -66,7 +66,7 @@ public class TestParenting01cAWT extends UITestCase { } @Test - public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { + public void test01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { int i; GLWindow glWindow1 = GLWindow.create(glCaps); @@ -154,7 +154,7 @@ public class TestParenting01cAWT extends UITestCase { } @Test - public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { + public void test02AWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUndecorated(true); GLEventListener demo1 = new RedSquareES2(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java index 375f676f4..4d5c3b25d 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java @@ -121,7 +121,7 @@ public class TestParenting01cSwingAWT extends UITestCase { } @Test - public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { + public void test01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { /** * JFrame . JPanel . Container . NewtCanvasAWT . GLWindow */ @@ -236,7 +236,7 @@ public class TestParenting01cSwingAWT extends UITestCase { } @Test - public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { + public void test02AWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { /** * JFrame . JPanel . Container . NewtCanvasAWT . GLWindow */ diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java index d79bdcaf6..b304a2ce7 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.parenting; import org.junit.Assert; @@ -65,22 +65,22 @@ public class TestParenting02AWT extends UITestCase { } @Test - public void testWindowParenting01NewtChildOnAWTParentLayouted() throws InterruptedException, InvocationTargetException { + public void test01NewtChildOnAWTParentLayouted() throws InterruptedException, InvocationTargetException { runNewtChildOnAWTParent(true, false); } @Test - public void testWindowParenting02NewtChildOnAWTParentLayoutedDef() throws InterruptedException, InvocationTargetException { + public void test02NewtChildOnAWTParentLayoutedDef() throws InterruptedException, InvocationTargetException { runNewtChildOnAWTParent(true, true); } @Test - public void testWindowParenting03NewtChildOnAWTParentDirect() throws InterruptedException, InvocationTargetException { + public void test03NewtChildOnAWTParentDirect() throws InterruptedException, InvocationTargetException { runNewtChildOnAWTParent(false, false); } @Test - public void testWindowParenting04NewtChildOnAWTParentDirectDef() throws InterruptedException, InvocationTargetException { + public void test04NewtChildOnAWTParentDirectDef() throws InterruptedException, InvocationTargetException { runNewtChildOnAWTParent(false, true); } @@ -152,7 +152,7 @@ public class TestParenting02AWT extends UITestCase { } while(!glWindow.isNativeValid()) ; final boolean wasOnscreen = glWindow.getChosenCapabilities().isOnscreen(); - + Assert.assertEquals(true, glWindow.isNativeValid()); Assert.assertNotNull(glWindow.getParent()); if(verbose) { @@ -203,7 +203,7 @@ public class TestParenting02AWT extends UITestCase { Thread.sleep(step); duration -= step; - while( null != ( event = (NEWTEvent) eventFifo.get() ) ) { + while( null != ( event = eventFifo.get() ) ) { Window source = (Window) event.getSource(); if(event instanceof KeyEvent) { KeyEvent keyEvent = (KeyEvent) event; @@ -215,7 +215,7 @@ public class TestParenting02AWT extends UITestCase { source.setFullscreen(!source.isFullscreen()); break; } - } + } } } if(verbose) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java index 6294483f0..9f56ecdbf 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.parenting; @@ -92,7 +92,7 @@ public class TestParenting02NEWT extends UITestCase { } @Test - public void testWindowParenting01NewtOnNewtParentChildDraw() throws InterruptedException { + public void test01NewtOnNewtParentChildDraw() throws InterruptedException { GLCapabilities caps = new GLCapabilities(null); Assert.assertNotNull(caps); Display display = NewtFactory.createDisplay(null); // local display @@ -112,7 +112,7 @@ public class TestParenting02NEWT extends UITestCase { glWindow1.setSize(width, height); Assert.assertEquals(width,glWindow1.getWidth()); Assert.assertEquals(height,glWindow1.getHeight()); - glWindow1.setTitle("testWindowParenting01NewtOnNewtParentChildDraw - PARENT"); + glWindow1.setTitle("test01NewtOnNewtParentChildDraw - PARENT"); glWindow1.setPosition(x,y); //glWindow1.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); //glWindow1.addWindowListener(new TraceWindowAdapter()); @@ -133,7 +133,7 @@ public class TestParenting02NEWT extends UITestCase { glWindow2.setSize(width/2, height/2); //Assert.assertEquals(width/2,glWindow2.getWidth()); //Assert.assertEquals(height/2,glWindow2.getHeight()); - glWindow2.setTitle("testWindowParenting01NewtOnNewtParentChildDraw - CHILD"); + glWindow2.setTitle("test01NewtOnNewtParentChildDraw - CHILD"); glWindow2.setPosition(glWindow1.getWidth()/2, glWindow1.getHeight()/2); //glWindow2.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); //glWindow2.addWindowListener(new TraceWindowAdapter(new WindowAction(eventFifo))); @@ -166,7 +166,7 @@ public class TestParenting02NEWT extends UITestCase { glWindow2.setPosition(glWindow1.getWidth()/2,glWindow1.getHeight()/2-y); Thread.sleep(step); - while( null != ( event = (NEWTEvent) eventFifo.get() ) ) { + while( null != ( event = eventFifo.get() ) ) { Window source = (Window) event.getSource(); if(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY == event.getEventType()) { shouldQuit = true; @@ -180,7 +180,7 @@ public class TestParenting02NEWT extends UITestCase { source.setFullscreen(!source.isFullscreen()); break; } - } + } } } destroyWindow(null, null, window2, glWindow2); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java index 30ee0f129..b7497196c 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.parenting; import java.lang.reflect.*; @@ -69,16 +69,16 @@ public class TestParenting03AWT extends UITestCase { } @Test - public void testWindowParenting1AWTOneNewtChilds01() throws InterruptedException, InvocationTargetException { - testWindowParenting1AWT(false); + public void test01AWTOneNewtChilds01() throws InterruptedException, InvocationTargetException { + testImpl(false); } @Test - public void testWindowParenting1AWTTwoNewtChilds01() throws InterruptedException, InvocationTargetException { - testWindowParenting1AWT(true); + public void test02AWTTwoNewtChilds01() throws InterruptedException, InvocationTargetException { + testImpl(true); } - - public void testWindowParenting1AWT(boolean use2nd) throws InterruptedException, InvocationTargetException { + + public void testImpl(boolean use2nd) throws InterruptedException, InvocationTargetException { final Frame frame1 = new Frame("AWT Parent Frame"); GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUpdateFPSFrames(1, null); @@ -100,7 +100,7 @@ public class TestParenting03AWT extends UITestCase { glWindow2.setUpdateFPSFrames(1, null); newtCanvasAWT2 = new NewtCanvasAWT(glWindow2); newtCanvasAWT2.setPreferredSize(glSize); - + GLEventListener demo2 = new GearsES2(1); setDemoFields(demo2, glWindow2, false); glWindow2.addGLEventListener(demo2); @@ -141,12 +141,12 @@ public class TestParenting03AWT extends UITestCase { System.err.println("******* Frame setVisible"); frame1.setLocation(0, 0); frame1.setSize(fSize); - frame1.validate(); + frame1.validate(); frame1.setVisible(true); }}); Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent()); - + Assert.assertEquals(true, animator1.isAnimating()); Assert.assertEquals(false, animator1.isPaused()); Assert.assertNotNull(animator1.getThread()); @@ -157,7 +157,7 @@ public class TestParenting03AWT extends UITestCase { Assert.assertNotNull(animator2.getThread()); Thread.sleep(waitAdd2nd); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame1.add(cont2, BorderLayout.WEST); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04AWT.java index 827ac525a..126aaaffa 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04AWT.java @@ -70,13 +70,13 @@ public class TestParenting04AWT extends UITestCase { } @Test - public void winHopFrame2FrameDirectHop() throws InterruptedException, InvocationTargetException { + public void test01WinHopFrame2FrameDirectHop() throws InterruptedException, InvocationTargetException { // Will produce some artifacts .. resizing etc winHopFrame2Frame(false); } @Test - public void winHopFrame2FrameDetachFirst() throws InterruptedException, InvocationTargetException { + public void test02WinHopFrame2FrameDetachFirst() throws InterruptedException, InvocationTargetException { // Note: detaching first setNEWTChild(null) is much cleaner visually winHopFrame2Frame(true); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java index 78b3bc464..586db8a2b 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java @@ -136,13 +136,13 @@ public class TestParenting04SWT extends UITestCase { } @Test - public void winHopFrame2FrameDirectHop() throws InterruptedException, InvocationTargetException { + public void test01WinHopFrame2FrameDirectHop() throws InterruptedException, InvocationTargetException { // Will produce some artifacts .. resizing etc winHopFrame2Frame(false); } @Test - public void winHopFrame2FrameDetachFirst() throws InterruptedException, InvocationTargetException { + public void test02WinHopFrame2FrameDetachFirst() throws InterruptedException, InvocationTargetException { // Note: detaching first setNEWTChild(null) is much cleaner visually winHopFrame2Frame(true); } -- cgit v1.2.3 From 45525950b0ad41b10790515c8b6142d746cd24f5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 11 Dec 2013 05:25:31 +0100 Subject: Bug 922 (2/2): NEWT Window.reparentWindow(..): Use REPARENT_HINT_BECOMES_VISIBLE to ensure GL State Preservation ; Add unit test ! --- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 4 +- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 7 +- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 6 +- src/newt/classes/jogamp/newt/WindowImpl.java | 4 +- .../junit/newt/parenting/TestParenting01dAWT.java | 248 +++++++++++++++++++++ .../test/junit/util/GLEventListenerCounter.java | 22 +- 6 files changed, 272 insertions(+), 19 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01dAWT.java (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index d0ec8ae36..00c3f1eb7 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -867,7 +867,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } newtChild.setVisible(false); newtChild.setSize(w, h); - newtChild.reparentWindow(jawtWindow); + newtChild.reparentWindow(jawtWindow, -1, -1, Window.REPARENT_HINT_BECOMES_VISIBLE); newtChild.addSurfaceUpdatedListener(jawtWindow); if( jawtWindow.isOffscreenLayerSurfaceEnabled() && 0 != ( JAWTUtil.JAWT_OSX_CALAYER_QUIRK_POSITION & JAWTUtil.getOSXCALayerQuirks() ) ) { @@ -917,7 +917,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto configureNewtChild(false); newtChild.setVisible(false); - newtChild.reparentWindow(null); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer + newtChild.reparentWindow(null, -1, -1, 0 /* hint */); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer if(DEBUG) { System.err.println("NewtCanvasAWT.detachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 4a2878e3a..e6571d21a 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -42,6 +42,7 @@ import javax.media.opengl.GLPipelineFactory; import jogamp.newt.Debug; +import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.MouseListener; @@ -218,7 +219,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { @Override public void run() { if( glWindow.isNativeValid() && null != awtParent && 0 != awtParent.getWindowHandle() ) { - glWindow.reparentWindow(awtParent); + glWindow.reparentWindow(awtParent, -1, -1, Window.REPARENT_HINT_BECOMES_VISIBLE); } } }).start(); @@ -308,7 +309,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop()); } else if(e.getKeyChar()=='r' && null!=awtParent) { if(null == glWindow.getParent()) { - glWindow.reparentWindow(awtParent); + glWindow.reparentWindow(awtParent, -1, -1, 0 /* hints */); } else { final InsetsImmutable insets = glWindow.getInsets(); final int x, y; @@ -320,7 +321,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { x = insets.getLeftWidth(); y = insets.getTopHeight(); } - glWindow.reparentWindow(null, x, y, false /* forceDestroyCreate */); + glWindow.reparentWindow(null, x, y, 0 /* hints */); glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE ); } } diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 5ed8d9e63..43e56c874 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -247,7 +247,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } configureNewtChild(false); newtChild.setVisible(false); - newtChild.reparentWindow(null); + newtChild.reparentWindow(null, -1, -1, 0 /* hint */); newtChild.destroy(); newtChild = null; } @@ -361,7 +361,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } newtChild.setSize(w, h); - newtChild.reparentWindow(nativeWindow); + newtChild.reparentWindow(nativeWindow, -1, -1, Window.REPARENT_HINT_BECOMES_VISIBLE); newtChild.setVisible(true); configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener @@ -372,7 +372,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } else { configureNewtChild(false); newtChild.setVisible(false); - newtChild.reparentWindow(null); + newtChild.reparentWindow(null, -1, -1, 0 /* hints */); } if(DEBUG) { System.err.println("NewtCanvasSWT.reparentWindow.X: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index ae4cb9924..ed7dd5600 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2188,7 +2188,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // enable fullscreen on offscreen instance if(null != parentWindow) { nfs_parent = parentWindow; - reparentWindow(null, -1, -1, true /* forceDestroyCreate */); + reparentWindow(null, -1, -1, REPARENT_HINT_FORCE_RECREATION | REPARENT_HINT_BECOMES_VISIBLE); } else { throw new InternalError("Offscreen instance w/o parent unhandled"); } @@ -2198,7 +2198,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(!fullScreenAction.fsOn() && null != nfs_parent) { // disable fullscreen on offscreen instance - reparentWindow(nfs_parent, -1, -1, true /* forceDestroyCreate */); + reparentWindow(nfs_parent, -1, -1, REPARENT_HINT_FORCE_RECREATION | REPARENT_HINT_BECOMES_VISIBLE); nfs_parent = null; } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01dAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01dAWT.java new file mode 100644 index 000000000..00b32ac35 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01dAWT.java @@ -0,0 +1,248 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.parenting; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +import java.awt.Button; +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Frame; + +import javax.media.opengl.*; +import javax.swing.SwingUtilities; + +import com.jogamp.newt.Window; +import com.jogamp.newt.opengl.*; +import com.jogamp.newt.awt.NewtCanvasAWT; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import com.jogamp.opengl.test.junit.util.*; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; + +/** + * Test GL preservation case for reparenting. + *

                      + * Also simulates adding and attaching an already created GLWindow + * to a NewtCanvasAWT in recreation mode, where the GL state shall be preserved. + *

                      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestParenting01dAWT extends UITestCase { + static int width, height; + static long durationPerTest = 800; + static GLCapabilities glCaps; + + @BeforeClass + public static void initClass() throws InterruptedException { + width = 640; + height = 480; + glCaps = new GLCapabilities(null); + // Thread.sleep(10000); + } + + static class MyGLEventListenerCounter extends GLEventListenerCounter { + @Override + public void init(GLAutoDrawable drawable) { + super.init(drawable); + System.err.println("MyGLEventListenerCounter.init: "+this); + // Thread.dumpStack(); + } + + @Override + public void dispose(GLAutoDrawable drawable) { + super.dispose(drawable); + System.err.println("MyGLEventListenerCounter.dispose: "+this); + // Thread.dumpStack(); + } + } + + @Test + public void test01GLWindowReparentRecreateNoPreserve() throws InterruptedException, InvocationTargetException { + testGLWindowInvisibleReparentRecreateImpl(false /* triggerPreserveGLState */); + } + + @Test + public void test02GLWindowReparentRecreateGLPreserve() throws InterruptedException, InvocationTargetException { + testGLWindowInvisibleReparentRecreateImpl(true /* triggerPreserveGLState */); + } + + private void testGLWindowInvisibleReparentRecreateImpl(boolean triggerPreserveGLState) throws InterruptedException, InvocationTargetException { + final GLWindow glWindow1 = GLWindow.create(glCaps); + Assert.assertNotNull(glWindow1); + Assert.assertEquals(false, glWindow1.isVisible()); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertNull(glWindow1.getParent()); + glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); + final MyGLEventListenerCounter glelCounter = new MyGLEventListenerCounter(); + glWindow1.addGLEventListener(glelCounter); + GLEventListener demo1 = new RedSquareES2(); + glWindow1.addGLEventListener(demo1); + Assert.assertEquals("Init Counter Invalid "+glelCounter, 0, glelCounter.initCount); + + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); + Assert.assertNotNull(newtCanvasAWT); + Assert.assertEquals(false, glWindow1.isVisible()); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertNull(glWindow1.getParent()); + Assert.assertEquals("Init Counter Invalid "+glelCounter, 0, glelCounter.initCount); + + final Frame frame1 = new Frame("AWT Parent Frame"); + frame1.setLayout(new BorderLayout()); + frame1.add(new Button("North"), BorderLayout.NORTH); + frame1.add(new Button("South"), BorderLayout.SOUTH); + frame1.add(new Button("East"), BorderLayout.EAST); + frame1.add(new Button("West"), BorderLayout.WEST); + + final Container container1 = new Container(); + container1.setLayout(new BorderLayout()); + container1.add(new Button("north"), BorderLayout.NORTH); + container1.add(new Button("south"), BorderLayout.SOUTH); + container1.add(new Button("east"), BorderLayout.EAST); + container1.add(new Button("west"), BorderLayout.WEST); + container1.add(newtCanvasAWT, BorderLayout.CENTER); + + frame1.add(container1, BorderLayout.CENTER); + + // visible test + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setSize(width, height); + frame1.setVisible(true); + } + }); + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow1, true)); + glWindow1.display(); + Assert.assertEquals("Init Counter Invalid "+glelCounter, 1, glelCounter.initCount); + Assert.assertEquals("Dispose Counter Invalid "+glelCounter, 0, glelCounter.disposeCount); + + final int reparentingHints = Window.REPARENT_HINT_FORCE_RECREATION | + ( triggerPreserveGLState ? Window.REPARENT_HINT_BECOMES_VISIBLE : 0 ); + + // + // Even though the hint REPARENT_HINT_BECOMES_VISIBLE is not set (triggerPrerveGLState == false), + // since GLWindow is visible already the GL state shall be preserved! + // + System.err.println(getSimpleTestName(".")+": Start Reparent #1"); + final Window.ReparentOperation rop1 = glWindow1.reparentWindow(null, -1, -1, reparentingHints); + System.err.println(getSimpleTestName(".")+": Result Reparent #1: "+rop1); + Assert.assertEquals(Window.ReparentOperation.ACTION_NATIVE_CREATION, rop1); + glWindow1.display(); + Assert.assertEquals("Init Counter Invalid (Preserve Failed 1) "+glelCounter, 1, glelCounter.initCount); + Assert.assertEquals("Dispose Counter Invalid (Preserve Failed 1) "+glelCounter, 0, glelCounter.disposeCount); + + // + // The following step is equivalent with adding and attaching an already created GLWindow + // to a NewtCanvasAWT in recreation mode if REPARENT_HINT_BECOMES_VISIBLE hint is set (triggerPrerveGLState == true). + // GL state shall be preserved! + // + glWindow1.setVisible(false); + System.err.println(getSimpleTestName(".")+": Start Reparent #2"); + final Window.ReparentOperation rop2 = glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow(), -1, -1, reparentingHints); + System.err.println(getSimpleTestName(".")+": Result Reparent #2: "+rop2); + Assert.assertEquals(Window.ReparentOperation.ACTION_NATIVE_CREATION, rop2); + glWindow1.setVisible(true); + glWindow1.display(); + if( triggerPreserveGLState ) { + Assert.assertEquals("Init Counter Invalid (Preserve Failed 2) "+glelCounter, 1, glelCounter.initCount); + Assert.assertEquals("Dispose Counter Invalid (Preserve Failed 2) "+glelCounter, 0, glelCounter.disposeCount); + } else { + Assert.assertEquals("Init Counter Invalid (Preserve Failed 2) "+glelCounter, 2, glelCounter.initCount); + Assert.assertEquals("Dispose Counter Invalid (Preserve Failed 2) "+glelCounter, 1, glelCounter.disposeCount); + } + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while( t1 - t0 < durationPerTest ) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(false); + } } ); + Assert.assertEquals(true, glWindow1.isNativeValid()); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + } } ); + Assert.assertEquals(true, glWindow1.isNativeValid()); + + final boolean wasOnscreen = glWindow1.getChosenCapabilities().isOnscreen(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.remove(newtCanvasAWT); + } } ); + // Assert.assertNull(glWindow1.getParent()); + if( wasOnscreen ) { + Assert.assertEquals(true, glWindow1.isNativeValid()); + } // else OK to be destroyed - due to offscreen/onscreen transition + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.dispose(); + } } ); + if( wasOnscreen ) { + Assert.assertEquals(true, glWindow1.isNativeValid()); + } // else OK to be destroyed - due to offscreen/onscreen transition + + glWindow1.destroy(); + Assert.assertEquals(false, glWindow1.isNativeValid()); + if( triggerPreserveGLState ) { + Assert.assertEquals("Init Counter Invalid (Preserve Failed 1) "+glelCounter, 1, glelCounter.initCount); + Assert.assertEquals("Dispose Counter Invalid (Preserve Failed 1) "+glelCounter, 1, glelCounter.disposeCount); + } else { + Assert.assertEquals("Init Counter Invalid (Preserve Failed 1) "+glelCounter, 2, glelCounter.initCount); + Assert.assertEquals("Dispose Counter Invalid (Preserve Failed 1) "+glelCounter, 2, glelCounter.disposeCount); + } + } + + public static void main(String args[]) throws IOException { + for(int i=0; i Date: Thu, 19 Dec 2013 12:47:52 +0100 Subject: Bug 924: Ignore reparent when in fullscreen - otherwise may confuse WM --- src/newt/classes/jogamp/newt/WindowImpl.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index ed7dd5600..29d3b9ee2 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1211,6 +1211,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final void run() { + if( WindowImpl.this.isFullscreen() ) { + // Bug 924: Ignore reparent when in fullscreen - otherwise may confuse WM + if( DEBUG_IMPLEMENTATION) { + System.err.println("Window.reparent: NOP (in fullscreen, "+getThreadName()+") valid "+isNativeValid()+ + ", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); + } + return; + } boolean animatorPaused = false; if(null!=lifecycleHook) { animatorPaused = lifecycleHook.pauseRenderingAction(); -- cgit v1.2.3 From 0e1b4bf1b17b10933c3ccdfea5cef7eca6aad2fb Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 19 Dec 2013 12:50:02 +0100 Subject: Bug 924: X11 WindowDriver: Only perform 'tempFSAlwaysOnTop' toggle @ focusChanged(..) if isFullscreen() .. otherwise it will be triggered by reconfigure tasks while enabling/disabling fullscreen. --- .../classes/jogamp/newt/driver/x11/WindowDriver.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 5e1f7a6ed..f2a27b0c9 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -148,20 +148,21 @@ public class WindowDriver extends WindowImpl { @Override protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, int flags) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); - } final int _x, _y; - if(0 == ( FLAG_IS_UNDECORATED & flags)) { - final InsetsImmutable i = getInsets(); - + final InsetsImmutable _insets; + if( 0 == ( FLAG_IS_UNDECORATED & flags) ) { // client position -> top-level window position - _x = x - i.getLeftWidth() ; - _y = y - i.getTopHeight() ; + _insets = getInsets(); + _x = x - _insets.getLeftWidth() ; + _y = y - _insets.getTopHeight() ; } else { + _insets = null; _x = x; _y = y; } + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window reconfig: "+x+"/"+y+" -> "+_x+"/"+_y+" "+width+"x"+height+", insets "+_insets+", "+ getReconfigureFlagsAsString(null, flags)); + } if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags ) ) { if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) { tempFSAlwaysOnTop = true; @@ -196,7 +197,7 @@ public class WindowDriver extends WindowImpl { */ @Override protected void focusChanged(boolean defer, boolean focusGained) { - if( tempFSAlwaysOnTop && hasFocus() != focusGained && isNativeValid() ) { + if( isNativeValid() && isFullscreen() && tempFSAlwaysOnTop && hasFocus() != focusGained ) { final int flags = getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible()) | ( focusGained ? FLAG_IS_ALWAYSONTOP : 0 ); if(DEBUG_IMPLEMENTATION) { System.err.println("X11Window reconfig.3 (focus): temporary "+getReconfigureFlagsAsString(null, flags)); -- cgit v1.2.3 From 9b2bbaf82ed410096ac279542357daefc0d6dc7f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 19 Dec 2013 12:54:07 +0100 Subject: Bug 924: Remove position criteria from reparent/fullscreen success, WM's only regard custom position as a hint (X11). --- src/newt/classes/jogamp/newt/WindowImpl.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 29d3b9ee2..e3174bd9f 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1442,9 +1442,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); } if(ok) { - ok = WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); - } - if(ok) { + // Position mismatch shall not lead to reparent failure + WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); + requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */); display.dispatchMessagesNative(); // status up2date } @@ -2158,8 +2158,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(ok) { ok = WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); } - if(ok && !fullscreen) { - ok = WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); + if(ok && !_fullscreen) { + // Position mismatch shall not lead to fullscreen failure + WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); } if(ok) { requestFocusInt(fullscreen /* skipFocusAction if fullscreen */); -- cgit v1.2.3 From e217858a83f947ffdd7e4ce3395073584e57108a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 19 Dec 2013 12:54:56 +0100 Subject: NEWT WindowImpl: Enhance insetsChanged(..) DEBUG output --- src/newt/classes/jogamp/newt/WindowImpl.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index e3174bd9f..aa2d264af 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1270,6 +1270,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+ ", visible "+wasVisible+", becomesVisible "+becomesVisible+ ", forceDestroyCreate "+forceDestroyCreate+ + ", DEBUG_TEST_REPARENT_INCOMPATIBLE "+DEBUG_TEST_REPARENT_INCOMPATIBLE+ ", HINT_FORCE_RECREATION "+( 0 != ( REPARENT_HINT_FORCE_RECREATION & hints ) )+ ", HINT_BECOMES_VISIBLE "+( 0 != ( REPARENT_HINT_BECOMES_VISIBLE & hints ) ) + ", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+ @@ -3596,17 +3597,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer */ protected void insetsChanged(boolean defer, int left, int right, int top, int bottom) { if ( left >= 0 && right >= 0 && top >= 0 && bottom >= 0 ) { - if(isUndecorated()) { + if( isUndecorated() ) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.insetsChanged: skip insets change for undecoration mode"); + System.err.println("Window.insetsChanged (defer: "+defer+"): Skip insets change "+insets+" -> "+new Insets(left, right, top, bottom)+" (undecoration mode)"); } } else if ( (left != insets.getLeftWidth() || right != insets.getRightWidth() || top != insets.getTopHeight() || bottom != insets.getBottomHeight() ) ) { - insets.set(left, right, top, bottom); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.insetsChanged: (defer: "+defer+") "+insets); + System.err.println("Window.insetsChanged (defer: "+defer+"): Changed "+insets+" -> "+new Insets(left, right, top, bottom)); } + insets.set(left, right, top, bottom); } } } -- cgit v1.2.3 From 0f1ddc82329835b903e31e301fcf134d1d7337be Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 19 Dec 2013 12:59:05 +0100 Subject: Bug 924: More robost Fullscreen Exit - 'tempInvisible' shall be also performed for top windows, solves Unity-WM background refresh issue - Rename local field 'fullscreen' -> '_fullscreen' to avoid confusion - Proper insets handling: Set 'WindowImpl.this.fullscreen = _fullscreen' only before reconfiguring, otherwise wrong position maybe used due to wrong insets value. Tested w/ WMs: KWin + Unity --- make/scripts/tests.sh | 7 ++-- src/newt/classes/jogamp/newt/WindowImpl.java | 50 +++++++++++++++------------- 2 files changed, 30 insertions(+), 27 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 746985d83..b680d2b25 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -93,6 +93,7 @@ function jrun() { #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + D_ARGS="-Dnativewindow.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" @@ -192,7 +193,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" - D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" + #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" @@ -320,7 +321,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -506,7 +507,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bB849AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $* ##testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index aa2d264af..437179f12 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2018,27 +2018,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private class FullScreenAction implements Runnable { - boolean fullscreen; + boolean _fullscreen; private boolean init(boolean fullscreen) { if(isNativeValid()) { - this.fullscreen = fullscreen; + this._fullscreen = fullscreen; return isFullscreen() != fullscreen; } else { WindowImpl.this.fullscreen = fullscreen; // set current state for createNative(..) return false; } } - public boolean fsOn() { return fullscreen; } + public boolean fsOn() { return _fullscreen; } @Override public final void run() { final RecursiveLock _lock = windowLock; _lock.lock(); try { - // set current state - WindowImpl.this.fullscreen = fullscreen; - final int oldX = getX(); final int oldY = getY(); final int oldWidth = getWidth(); @@ -2050,7 +2047,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final RectangleImmutable viewport; final int fs_span_flag; final boolean alwaysOnTopChange; - if(fullscreen) { + if(_fullscreen) { if( null == fullscreenMonitors ) { if( fullscreenUseMainMonitor ) { fullscreenMonitors = new ArrayList(); @@ -2103,30 +2100,33 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } + + final DisplayImpl display = (DisplayImpl) screen.getDisplay(); + display.dispatchMessagesNative(); // status up2date + final boolean wasVisible = isVisible(); + final boolean tempInvisible = !_fullscreen && wasVisible && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true); + if(DEBUG_IMPLEMENTATION) { - System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ + System.err.println("Window fs: "+_fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ ", virtl-screenSize: "+sviewport+", monitorsViewport "+viewport+ ", spanning "+(0!=fs_span_flag)+ ", alwaysOnTop "+alwaysOnTop+(alwaysOnTopChange?"*":"")+ + ", wasVisible "+wasVisible+", tempInvisible "+tempInvisible+ + ", hasParent "+(null!=parentWindow)+ " @ "+Thread.currentThread().getName()); } - final DisplayImpl display = (DisplayImpl) screen.getDisplay(); - display.dispatchMessagesNative(); // status up2date - final boolean wasVisible = isVisible(); + // fullscreen off: !visible first (fixes X11 unsuccessful return to parent window _and_ wrong window size propagation) + if( tempInvisible ) { + setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight); + WindowImpl.this.waitForVisible(false, false); + try { Thread.sleep(100); } catch (InterruptedException e) { } + display.dispatchMessagesNative(); // status up2date + } // Lock parentWindow only during reparenting (attempt) final NativeWindow parentWindowLocked; if( null != parentWindow ) { - // fullscreen off: !visible first (fixes X11 unsuccessful return to parent window) - if( !fullscreen && wasVisible && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { - setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight); - WindowImpl.this.waitForVisible(false, false); - // FIXME: Some composite WM behave slacky .. give 'em chance to change state -> invisible, - // even though we do exactly that (KDE+Composite) - try { Thread.sleep(100); } catch (InterruptedException e) { } - display.dispatchMessagesNative(); // status up2date - } parentWindowLocked = parentWindow; if( NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindowLocked.lockSurface() ) { throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow); @@ -2135,14 +2135,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer parentWindowLocked = null; } try { - if(alwaysOnTopChange && fullscreen) { + if(alwaysOnTopChange && _fullscreen) { // Enter fullscreen - Disable alwaysOnTop - reconfigureWindowImpl(nfs_x, nfs_y, nfs_width, nfs_height, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); + reconfigureWindowImpl(oldX, oldY, oldWidth, oldHeight, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); } + + WindowImpl.this.fullscreen = _fullscreen; reconfigureWindowImpl(x, y, w, h, getReconfigureFlags( ( ( null != parentWindowLocked ) ? FLAG_CHANGE_PARENTING : 0 ) | fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, isVisible()) ); - if(alwaysOnTopChange && !fullscreen) { + if(alwaysOnTopChange && !_fullscreen) { // Leave fullscreen - Restore alwaysOnTop reconfigureWindowImpl(x, y, w, h, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); } @@ -2164,7 +2166,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); } if(ok) { - requestFocusInt(fullscreen /* skipFocusAction if fullscreen */); + requestFocusInt(_fullscreen /* skipFocusAction if fullscreen */); display.dispatchMessagesNative(); // status up2date } if(DEBUG_IMPLEMENTATION) { -- cgit v1.2.3 From 904adbe63a806ff73ea654da6cc964277bbbb8d3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 20 Dec 2013 08:49:05 +0100 Subject: Bug 924: Make ALWAYS_ON_TOP Persistent when Reparenting (child -> top) (2nd attempt) Commit c8726ef04b94ad8e66e1191a06ff793b908d130c reinforced ALWAYS_ON_TOP in native reconfig code issued at reparenting call, which might be too early for the WM. Perform ALWAYS_ON_TOP reinforcement from java side when reparenting CHILD -> TOP was successful and visibility is reached. X11 only! NewtAWTReparentingKeyAdapter: Add 'a' alwaysOnTop toggle to test w/o applet code. --- make/scripts/tests.sh | 2 +- src/newt/classes/jogamp/newt/WindowImpl.java | 4 ++++ src/newt/native/X11Window.c | 4 ---- .../test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java | 6 ++++++ 4 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b680d2b25..57b13ab3b 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -93,7 +93,7 @@ function jrun() { #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - D_ARGS="-Dnativewindow.debug=all -Dnewt.debug=all" + D_ARGS="-Dnativewindow.debug=all -Dnewt.debug.Window" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 437179f12..d63104c71 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1440,6 +1440,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer setVisibleImpl(true, x, y, width, height); ok = 0 <= WindowImpl.this.waitForVisible(true, false); if(ok) { + if( isAlwaysOnTop() && 0 == parentWindowHandle && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { + // Reinforce ALWAYSONTOP when CHILD -> TOP reparenting, since reparenting itself cause X11 WM to loose it's state. + reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); + } ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); } if(ok) { diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index ad17f970b..5f5dddbe0 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -822,10 +822,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo XSetWMProtocols(dpy, w, &wm_delete_atom, 1); // windowDeleteAtom // Fix for Unity WM, i.e. _remove_ persistent previous states NewtWindows_setStackingEWMHFlags(dpy, root, w, fsEWMHFlags, isVisible, False); - if( TST_FLAG_IS_ALWAYSONTOP(flags) ) { - // Reinforce always-on-top, lost by WM during reparenting - NewtWindows_setStackingEWMHFlags(dpy, root, w, _NET_WM_STATE_FLAG_ABOVE, isVisible, True); - } } if( TST_FLAG_CHANGE_DECORATION(flags) ) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index f7fbc7332..189645d3d 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -96,6 +96,12 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { } } }.run(); + } else if( e.getKeySymbol() == KeyEvent.VK_A ) { + new Thread() { + public void run() { + glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop()); + } + }.run(); } else if( e.getKeySymbol() == KeyEvent.VK_R ) { if( null != quitAdapter ) { quitAdapter.enable(false); -- cgit v1.2.3 From ded0a8fb68067e3dbb42ff4f6fce315a237afa8f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 20 Dec 2013 17:06:47 +0100 Subject: Bug 924: Fullscreen toggle in X11 requires a 'sleep' on sluggish WMs (Unity) ; Block insets change while toggling fullscreen mode. --- src/newt/classes/jogamp/newt/WindowImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index d63104c71..432613394 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -147,6 +147,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private volatile int width = 128, height = 128; // client-area size w/o insets, default: may be overwritten by user private volatile int x = 64, y = 64; // client-area pos w/o insets private volatile Insets insets = new Insets(); // insets of decoration (if top-level && decorated) + private boolean blockInsetsChange = false; // block insets change (from same thread) private final RecursiveLock windowLock = LockFactory.createRecursiveLock(); // Window instance wide lock private int surfaceLockCount = 0; // surface lock recursion count @@ -2039,6 +2040,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public final void run() { final RecursiveLock _lock = windowLock; _lock.lock(); + blockInsetsChange = true; try { final int oldX = getX(); final int oldY = getY(); @@ -2160,6 +2162,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer display.dispatchMessagesNative(); // status up2date if(wasVisible) { + if( NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { + // Give sluggy WM's (e.g. Unity) a chance to properly restore window .. + try { Thread.sleep(100); } catch (InterruptedException e) { } + display.dispatchMessagesNative(); // status up2date + } setVisibleImpl(true, x, y, w, h); boolean ok = 0 <= WindowImpl.this.waitForVisible(true, false); if(ok) { @@ -2178,6 +2185,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } finally { + blockInsetsChange = false; _lock.unlock(); } sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener @@ -3603,9 +3611,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer */ protected void insetsChanged(boolean defer, int left, int right, int top, int bottom) { if ( left >= 0 && right >= 0 && top >= 0 && bottom >= 0 ) { - if( isUndecorated() ) { + if( blockInsetsChange || isUndecorated() ) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.insetsChanged (defer: "+defer+"): Skip insets change "+insets+" -> "+new Insets(left, right, top, bottom)+" (undecoration mode)"); + System.err.println("Window.insetsChanged (defer: "+defer+"): Skip insets change "+insets+" -> "+new Insets(left, right, top, bottom)+" (blocked "+blockInsetsChange+", undecoration "+isUndecorated()+")"); } } else if ( (left != insets.getLeftWidth() || right != insets.getRightWidth() || top != insets.getTopHeight() || bottom != insets.getBottomHeight() ) -- cgit v1.2.3 From 852fcbf1b8d87e35884082e792ff0ac6fdeed3a7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 31 Dec 2013 00:47:21 +0100 Subject: NEWT WindowImpl: Add 'final' qualifier where possible --- src/newt/classes/jogamp/newt/WindowImpl.java | 103 +++++++++++++-------------- 1 file changed, 49 insertions(+), 54 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 432613394..d06eb3e25 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -550,14 +550,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private WindowClosingMode defaultCloseOperation = WindowClosingMode.DISPOSE_ON_CLOSE; @Override - public WindowClosingMode getDefaultCloseOperation() { + public final WindowClosingMode getDefaultCloseOperation() { synchronized (closingListenerLock) { return defaultCloseOperation; } } @Override - public WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { + public final WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { synchronized (closingListenerLock) { WindowClosingMode _op = defaultCloseOperation; defaultCloseOperation = op; @@ -978,7 +978,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void setVisible(boolean wait, boolean visible) { + public final void setVisible(boolean wait, boolean visible) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window setVisible: START ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)); } @@ -986,7 +986,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void setVisible(boolean visible) { + public final void setVisible(boolean visible) { setVisible(true, visible); } @@ -1044,11 +1044,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer runOnEDTIfAvail(true, new SetSizeAction(width, height, true)); } @Override - public void setSize(int width, int height) { + public final void setSize(int width, int height) { runOnEDTIfAvail(true, new SetSizeAction(width, height, false)); } @Override - public void setTopLevelSize(int width, int height) { + public final void setTopLevelSize(int width, int height) { setSize(width - getInsets().getTotalWidth(), height - getInsets().getTotalHeight()); } @@ -1536,19 +1536,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate) { + public final ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate) { return reparentWindow(newParent, x, y, forceDestroyCreate ? REPARENT_HINT_FORCE_RECREATION : 0); } @Override - public ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints) { + public final ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints) { final ReparentAction reparentAction = new ReparentAction(newParent, x, y, hints); runOnEDTIfAvail(true, reparentAction); return reparentAction.getOp(); } @Override - public CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser) { + public final CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser) { CapabilitiesChooser old = this.capabilitiesChooser; this.capabilitiesChooser = chooser; return old; @@ -1601,7 +1601,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void setUndecorated(boolean value) { + public final void setUndecorated(boolean value) { runOnEDTIfAvail(true, new DecorationAction(value)); } @@ -1661,11 +1661,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public String getTitle() { + public final String getTitle() { return title; } @Override - public void setTitle(String title) { + public final void setTitle(String title) { if (title == null) { title = ""; } @@ -1676,11 +1676,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public boolean isPointerVisible() { + public final boolean isPointerVisible() { return pointerVisible; } @Override - public void setPointerVisible(boolean pointerVisible) { + public final void setPointerVisible(boolean pointerVisible) { if(this.pointerVisible != pointerVisible) { boolean setVal = 0 == getWindowHandle(); if(!setVal) { @@ -1692,12 +1692,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } @Override - public boolean isPointerConfined() { + public final boolean isPointerConfined() { return pointerConfined; } - @Override - public void confinePointer(boolean confine) { + public final void confinePointer(boolean confine) { if(this.pointerConfined != confine) { boolean setVal = 0 == getWindowHandle(); if(!setVal) { @@ -1721,7 +1720,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void warpPointer(int x, int y) { + public final void warpPointer(int x, int y) { if(0 != getWindowHandle()) { warpPointerImpl(x, y); } @@ -1808,11 +1807,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return false; } - public LifecycleHook getLifecycleHook() { + public final LifecycleHook getLifecycleHook() { return lifecycleHook; } - public LifecycleHook setLifecycleHook(LifecycleHook hook) { + public final LifecycleHook setLifecycleHook(LifecycleHook hook) { LifecycleHook old = lifecycleHook; lifecycleHook = hook; return old; @@ -1827,7 +1826,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void setWindowDestroyNotifyAction(Runnable r) { + public final void setWindowDestroyNotifyAction(Runnable r) { windowDestroyNotifyAction = r; } @@ -1843,7 +1842,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public String toString() { + public final String toString() { StringBuilder sb = new StringBuilder(); sb.append(getClass().getName()+"[Config "+config+ @@ -1888,7 +1887,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void runOnEDTIfAvail(boolean wait, final Runnable task) { + public final void runOnEDTIfAvail(boolean wait, final Runnable task) { if( windowLock.isOwner( Thread.currentThread() ) ) { task.run(); } else { @@ -1921,12 +1920,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void requestFocus() { + public final void requestFocus() { requestFocus(true); } @Override - public void requestFocus(boolean wait) { + public final void requestFocus(boolean wait) { requestFocus(wait /* wait */, false /* skipFocusAction */, brokenFocusChange /* force */); } @@ -1949,7 +1948,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void setFocusAction(FocusRunnable focusAction) { + public final void setFocusAction(FocusRunnable focusAction) { this.focusAction = focusAction; } @@ -1969,12 +1968,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return res; } - protected void setBrokenFocusChange(boolean v) { + protected final void setBrokenFocusChange(boolean v) { brokenFocusChange = v; } @Override - public void setKeyboardFocusHandler(KeyListener l) { + public final void setKeyboardFocusHandler(KeyListener l) { keyboardFocusHandler = l; } @@ -2018,7 +2017,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void setTopLevelPosition(int x, int y) { + public final void setTopLevelPosition(int x, int y) { setPosition(x + getInsets().getLeftWidth(), y + getInsets().getTopHeight()); } @@ -2357,7 +2356,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event) { + public final void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event) { if(isNativeValid()) { ((DisplayImpl)screen.getDisplay()).enqueueEvent(wait, event); } @@ -2416,22 +2415,22 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // SurfaceUpdatedListener Support // @Override - public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { + public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { surfaceUpdatedHelper.addSurfaceUpdatedListener(l); } @Override - public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { + public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); } @Override - public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { + public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); } @Override - public void surfaceUpdated(Object updater, NativeSurface ns, long when) { + public final void surfaceUpdated(Object updater, NativeSurface ns, long when) { surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); } @@ -3274,12 +3273,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected boolean keyboardVisible = false; @Override - public void addKeyListener(KeyListener l) { + public final void addKeyListener(KeyListener l) { addKeyListener(-1, l); } @Override - public void addKeyListener(int index, KeyListener l) { + public final void addKeyListener(int index, KeyListener l) { if(l == null) { return; } @@ -3293,7 +3292,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void removeKeyListener(KeyListener l) { + public final void removeKeyListener(KeyListener l) { if (l == null) { return; } @@ -3304,7 +3303,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public KeyListener getKeyListener(int index) { + public final KeyListener getKeyListener(int index) { @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) keyListeners.clone(); if(0>index) { @@ -3314,7 +3313,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public KeyListener[] getKeyListeners() { + public final KeyListener[] getKeyListeners() { return keyListeners.toArray(new KeyListener[keyListeners.size()]); } @@ -3356,21 +3355,21 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // WindowListener/Event Support // @Override - public void sendWindowEvent(int eventType) { + public final void sendWindowEvent(int eventType) { consumeWindowEvent( new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); } - public void enqueueWindowEvent(boolean wait, int eventType) { + public final void enqueueWindowEvent(boolean wait, int eventType) { enqueueEvent( wait, new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); } @Override - public void addWindowListener(WindowListener l) { + public final void addWindowListener(WindowListener l) { addWindowListener(-1, l); } @Override - public void addWindowListener(int index, WindowListener l) + public final void addWindowListener(int index, WindowListener l) throws IndexOutOfBoundsException { if(l == null) { @@ -3397,7 +3396,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public WindowListener getWindowListener(int index) { + public final WindowListener getWindowListener(int index) { @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) windowListeners.clone(); if(0>index) { @@ -3407,7 +3406,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public WindowListener[] getWindowListeners() { + public final WindowListener[] getWindowListeners() { return windowListeners.toArray(new WindowListener[windowListeners.size()]); } @@ -3464,7 +3463,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** Triggered by implementation's WM events to update the visibility state. */ - protected void visibleChanged(boolean defer, boolean visible) { + protected final void visibleChanged(boolean defer, boolean visible) { if(this.visible != visible) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.visibleChanged ("+getThreadName()+"): (defer: "+defer+") "+this.visible+" -> "+visible+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); @@ -3546,7 +3545,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** Triggered by implementation's WM events to update the position. */ - protected void positionChanged(boolean defer, int newX, int newY) { + protected final void positionChanged(boolean defer, int newX, int newY) { if ( getX() != newX || getY() != newY ) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window.positionChanged: ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY+" - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); @@ -3633,7 +3632,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * and hence force destruction. Otherwise is follows the user settings. * @return true if this window is no more valid and hence has been destroyed, otherwise false. */ - public boolean windowDestroyNotify(boolean force) { + public final boolean windowDestroyNotify(boolean force) { final WindowClosingMode defMode = getDefaultCloseOperation(); final WindowClosingMode mode = force ? WindowClosingMode.DISPOSE_ON_CLOSE : defMode; if(DEBUG_IMPLEMENTATION) { @@ -3677,14 +3676,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void windowRepaint(int x, int y, int width, int height) { + public final void windowRepaint(int x, int y, int width, int height) { windowRepaint(false, x, y, width, height); } /** * Triggered by implementation's WM events to update the content */ - protected void windowRepaint(boolean defer, int x, int y, int width, int height) { + protected final void windowRepaint(boolean defer, int x, int y, int width, int height) { width = ( 0 >= width ) ? getWidth() : width; height = ( 0 >= height ) ? getHeight() : height; if(DEBUG_IMPLEMENTATION) { @@ -3745,10 +3744,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return sb.toString(); } - protected final void shouldNotCallThis() { - throw new NativeWindowException("Should not call this"); - } - public static String getThreadName() { return Display.getThreadName(); } -- cgit v1.2.3 From e7032ae9ca4b754bd9737f86d9496211e9155db4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 31 Dec 2013 08:01:28 +0100 Subject: NEWT Cleanup - Remove Type Casts and OSX Newt/Fmod Workaround (Early WindowImpl initialization) --- src/newt/classes/com/jogamp/newt/Display.java | 2 +- src/newt/classes/com/jogamp/newt/NewtFactory.java | 17 ++++++----------- src/newt/classes/jogamp/newt/WindowImpl.java | 16 ---------------- 3 files changed, 7 insertions(+), 28 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index a0a098481..4469189a8 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -222,7 +222,7 @@ public abstract class Display { synchronized(displayList) { int i = fromIndex >= 0 ? fromIndex : displayList.size() - 1 ; while( ( incr > 0 ) ? i < displayList.size() : i >= 0 ) { - final Display display = (Display) displayList.get(i).get(); + final Display display = displayList.get(i).get(); if( null == display ) { // Clear GC'ed dead reference entry! displayList.remove(i); diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 5ae3f3692..157e2bb3c 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -59,11 +59,6 @@ public class NewtFactory { @Override public Object run() { NativeWindowFactory.initSingleton(); // last resort .. - - // Work-around for initialization order problems on Mac OS X - // between native Newt and (apparently) Fmod - WindowImpl.init(NativeWindowFactory.getNativeWindowType(true)); - return null; } } ); } @@ -320,9 +315,9 @@ public class NewtFactory { public static boolean isScreenCompatible(NativeWindow parent, Screen childScreen) { // Get parent's NativeWindow details - AbstractGraphicsConfiguration parentConfig = (AbstractGraphicsConfiguration) parent.getGraphicsConfiguration(); - AbstractGraphicsScreen parentScreen = (AbstractGraphicsScreen) parentConfig.getScreen(); - AbstractGraphicsDevice parentDevice = (AbstractGraphicsDevice) parentScreen.getDevice(); + AbstractGraphicsConfiguration parentConfig = parent.getGraphicsConfiguration(); + AbstractGraphicsScreen parentScreen = parentConfig.getScreen(); + AbstractGraphicsDevice parentDevice = parentScreen.getDevice(); DisplayImpl childDisplay = (DisplayImpl) childScreen.getDisplay(); String parentDisplayName = childDisplay.validateDisplayName(null, parentDevice.getHandle()); @@ -343,9 +338,9 @@ public class NewtFactory { public static Screen createCompatibleScreen(NativeWindow parent, Screen childScreen) { // Get parent's NativeWindow details - AbstractGraphicsConfiguration parentConfig = (AbstractGraphicsConfiguration) parent.getGraphicsConfiguration(); - AbstractGraphicsScreen parentScreen = (AbstractGraphicsScreen) parentConfig.getScreen(); - AbstractGraphicsDevice parentDevice = (AbstractGraphicsDevice) parentScreen.getDevice(); + AbstractGraphicsConfiguration parentConfig = parent.getGraphicsConfiguration(); + AbstractGraphicsScreen parentScreen = parentConfig.getScreen(); + AbstractGraphicsDevice parentDevice = parentScreen.getDevice(); if(null != childScreen) { // check if child Display/Screen is compatible already diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index d06eb3e25..7a7e69e48 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -255,22 +255,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private ArrayList windowListeners = new ArrayList(); private boolean repaintQueued = false; - /** - * 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 - */ - public static void init(String type) { - if (NativeWindowFactory.TYPE_MACOSX.equals(type)) { - try { - getWindowClass(type); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - // // Construction Methods // -- cgit v1.2.3 From e7ffa68bce9bb707005be72530b207c732f62c31 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 31 Dec 2013 08:14:21 +0100 Subject: Bug 934, Bug 935: NEWT: Add support for custom Application/Window and Pointer Icons - Utilizing JOGL's PNG decoder for all icons, if available. - Application/window icons: - Providing default application/window icons in 16x16 and 32x32 size - NewtFactory.setWindowIcons(..) or property 'newt.window.icons' maybe used to override default icons. - Using icons at application/window instantiation - Display.PointerIcons: - NativeWindow Win32 WindowClass no more references a default cursor in favor of fine grained cursor control [in NEWT] - Display provides create/destroy methods, where display destruction also releases open PointerIcon references. - Window.setPointerIcon(..) sets custom PointerIcon - Implemented Platforms - X11 - Windows - OSX - Manual Test: TestGearsES2NEWT (Press 'c') --- make/build-jogl.xml | 2 +- make/build-newt.xml | 12 +- .../resources/assets-test/jogamp-pointer-64x64.png | Bin 0 -> 2843 bytes make/resources/assets/newt/data/jogamp-16x16.png | Bin 0 -> 549 bytes make/resources/assets/newt/data/jogamp-32x32.png | Bin 0 -> 1020 bytes make/resources/misc/jogamp-48x48.png | Bin 0 -> 1278 bytes make/resources/misc/jogamp-64x64.png | Bin 0 -> 1833 bytes make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64-dbg.bat | 3 +- make/scripts/tests.sh | 5 +- src/nativewindow/native/win32/GDImisc.c | 2 +- src/newt/classes/com/jogamp/newt/Display.java | 50 +++++++- src/newt/classes/com/jogamp/newt/NewtFactory.java | 33 +++++ src/newt/classes/com/jogamp/newt/Window.java | 15 +++ .../classes/com/jogamp/newt/opengl/GLWindow.java | 11 ++ src/newt/classes/jogamp/newt/DisplayImpl.java | 68 +++++++++- src/newt/classes/jogamp/newt/WindowImpl.java | 22 ++++ src/newt/classes/jogamp/newt/driver/PNGIcon.java | 102 +++++++++++++++ .../jogamp/newt/driver/macosx/DisplayDriver.java | 51 ++++++++ .../jogamp/newt/driver/macosx/WindowDriver.java | 11 ++ .../jogamp/newt/driver/opengl/JoglUtilPNGIcon.java | 139 +++++++++++++++++++++ .../jogamp/newt/driver/windows/DisplayDriver.java | 38 ++++++ .../jogamp/newt/driver/windows/WindowDriver.java | 56 +++++++-- .../jogamp/newt/driver/x11/DisplayDriver.java | 46 +++++++ .../jogamp/newt/driver/x11/WindowDriver.java | 51 +++++++- src/newt/native/MacWindow.m | 73 ++++++++++- src/newt/native/NewtMacWindow.h | 4 +- src/newt/native/NewtMacWindow.m | 41 ++++-- src/newt/native/WindowsWindow.c | 115 ++++++++++++++++- src/newt/native/X11Display.c | 52 ++++++++ src/newt/native/X11Window.c | 35 +++++- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 29 ++++- 32 files changed, 1027 insertions(+), 43 deletions(-) create mode 100644 make/resources/assets-test/jogamp-pointer-64x64.png create mode 100644 make/resources/assets/newt/data/jogamp-16x16.png create mode 100644 make/resources/assets/newt/data/jogamp-32x32.png create mode 100644 make/resources/misc/jogamp-48x48.png create mode 100644 make/resources/misc/jogamp-64x64.png create mode 100644 src/newt/classes/jogamp/newt/driver/PNGIcon.java create mode 100644 src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java (limited to 'src/newt/classes') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 28b738b10..4cdb93f4d 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1833,7 +1833,7 @@ - + + value="com/jogamp/newt/opengl/** jogamp/newt/driver/opengl/**"/> @@ -277,12 +277,14 @@ + + @@ -302,6 +304,7 @@ + @@ -309,6 +312,7 @@ + @@ -316,6 +320,7 @@ + @@ -323,6 +328,7 @@ + @@ -332,18 +338,21 @@ + + + @@ -798,6 +807,7 @@ + diff --git a/make/resources/assets-test/jogamp-pointer-64x64.png b/make/resources/assets-test/jogamp-pointer-64x64.png new file mode 100644 index 000000000..a965dcab1 Binary files /dev/null and b/make/resources/assets-test/jogamp-pointer-64x64.png differ diff --git a/make/resources/assets/newt/data/jogamp-16x16.png b/make/resources/assets/newt/data/jogamp-16x16.png new file mode 100644 index 000000000..02df8997f Binary files /dev/null and b/make/resources/assets/newt/data/jogamp-16x16.png differ diff --git a/make/resources/assets/newt/data/jogamp-32x32.png b/make/resources/assets/newt/data/jogamp-32x32.png new file mode 100644 index 000000000..ab21c6e1b Binary files /dev/null and b/make/resources/assets/newt/data/jogamp-32x32.png differ diff --git a/make/resources/misc/jogamp-48x48.png b/make/resources/misc/jogamp-48x48.png new file mode 100644 index 000000000..216f8c0b7 Binary files /dev/null and b/make/resources/misc/jogamp-48x48.png differ diff --git a/make/resources/misc/jogamp-64x64.png b/make/resources/misc/jogamp-64x64.png new file mode 100644 index 000000000..9936616ca Binary files /dev/null and b/make/resources/misc/jogamp-64x64.png differ diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index f5417bf7a..d95b0025f 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -39,7 +39,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 6e8407f3e..ce2df922c 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -55,9 +55,10 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" "-Djogl.debug.TileRenderer.PNG" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" REM set D_ARGS="-Djogl.gljpanel.noverticalflip" +set D_ARGS="-Dnewt.debug=all" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" -set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Window.KeyEvent" "-Dnewt.debug.EDT" +REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Window.KeyEvent" "-Dnewt.debug.EDT" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6cb1966d1..4c084d705 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -312,7 +312,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* # # demos (any TK, more user driven tests) @@ -325,7 +325,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -636,6 +636,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.ToolPNG2CSource $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* diff --git a/src/nativewindow/native/win32/GDImisc.c b/src/nativewindow/native/win32/GDImisc.c index b55988c11..25b98acf3 100644 --- a/src/nativewindow/native/win32/GDImisc.c +++ b/src/nativewindow/native/win32/GDImisc.c @@ -263,7 +263,7 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass0 wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = NULL; - wc.hCursor = LoadCursor( NULL, IDC_ARROW); + wc.hCursor = NULL; wc.hbrBackground = NULL; // no background paint - GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = clazzName; diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 4469189a8..ee6dfd080 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -28,15 +28,21 @@ package com.jogamp.newt; -import com.jogamp.newt.util.EDTUtil; -import jogamp.newt.Debug; - +import java.io.IOException; import java.lang.ref.WeakReference; -import java.util.*; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import jogamp.newt.Debug; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.newt.util.EDTUtil; + public abstract class Display { public static final boolean DEBUG = Debug.debug("Display"); @@ -55,6 +61,42 @@ public abstract class Display { return false; } + /** + * Native PointerIcon handle. + *

                      + * Instances can be created via {@link Display#createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int)} + * and released via {@link Display#destroyPointerIcon(PointerIcon)}. + *

                      + *

                      + * PointerIcons can be used via {@link Window#setPointerIcon(PointerIcon)}. + *

                      + */ + public static interface PointerIcon { } + + /** + * Returns the created {@link PointerIcon} or null if not implemented on platform. + * + * @param pngResource PNG resource + * @param hotX pointer hotspot x-coord, origin is upper-left corner + * @param hotY pointer hotspot y-coord, origin is upper-left corner + * @throws MalformedURLException + * @throws InterruptedException + * @throws IOException + * + * @see PointerIcon + * @see #destroyPointerIcon(PointerIcon) + * @see Window#setPointerIcon(PointerIcon) + */ + + public abstract PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException; + + /** + * @param pi + * + * @see #createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int) + */ + public abstract void destroyPointerIcon(PointerIcon pi); + /** * Manual trigger the native creation, if it is not done yet.
                      * This is useful to be able to request the {@link javax.media.nativewindow.AbstractGraphicsDevice}, via diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 157e2bb3c..92339ea73 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -36,6 +36,7 @@ package com.jogamp.newt; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Arrays; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -44,6 +45,8 @@ import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowFactory; +import com.jogamp.common.util.IOUtil; + import jogamp.newt.Debug; import jogamp.newt.DisplayImpl; import jogamp.newt.ScreenImpl; @@ -54,15 +57,45 @@ public class NewtFactory { public static final String DRIVER_DEFAULT_ROOT_PACKAGE = "jogamp.newt.driver"; + private static IOUtil.ClassResources defaultWindowIcons; + static { AccessController.doPrivileged(new PrivilegedAction() { @Override public Object run() { NativeWindowFactory.initSingleton(); // last resort .. + { + final String[] paths = Debug.getProperty("newt.window.icons", true, "newt/data/jogamp-16x16.png newt/data/jogamp-32x32.png").split("\\s"); + if( paths.length < 2 ) { + throw new IllegalArgumentException("Property 'newt.window.icons' did not specify at least two PNG icons, but "+Arrays.toString(paths)); + } + final Class clazz = NewtFactory.class; + defaultWindowIcons = new IOUtil.ClassResources(clazz, paths); + } return null; } } ); } + /** + * Returns the application window icon resources to be used. + *

                      + * Property newt.window.icons may define a list of PNG icons separated by a whitespace character. + * Shall reference at least two PNG icons, from lower (16x16) to higher (>= 32x32) resolution. + *

                      + *

                      + * Users may also specify application window icons using {@link #setWindowIcons(com.jogamp.common.util.IOUtil.ClassResources)}. + *

                      + */ + public static IOUtil.ClassResources getWindowIcons() { return defaultWindowIcons; } + + /** + * Allow user to set custom window icons, only applicable at application start before creating any NEWT instance. + *

                      + * Shall reference at least two PNG icons, from lower (16x16) to higher (>= 32x32) resolution. + *

                      + */ + public static void setWindowIcons(IOUtil.ClassResources cres) { defaultWindowIcons = cres; } + public static Class getCustomClass(String packageName, String classBaseName) { Class clazz = null; if(packageName!=null && classBaseName!=null) { diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 5c3bb7889..8e73ba1d2 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -30,6 +30,7 @@ package com.jogamp.newt; import java.util.List; +import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; @@ -307,6 +308,20 @@ public interface Window extends NativeWindow, WindowClosingProtocol { */ void setPointerVisible(boolean pointerVisible); + /** + * Returns the current {@link PointerIcon}, which maybe null for the default. + * @see #setPointerIcon(PointerIcon) + */ + PointerIcon getPointerIcon(); + + /** + * @param pi Valid {@link PointerIcon} reference or null to reset the pointer icon to default. + * + * @see PointerIcon + * @see Display#createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int) + */ + void setPointerIcon(final PointerIcon pi); + /** @see #confinePointer(boolean) */ boolean isPointerConfined(); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 208602aa1..ca8ab6733 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -77,6 +77,7 @@ import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; +import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.MouseListener; @@ -267,6 +268,16 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind window.setPointerVisible(mouseVisible); } + @Override + public final PointerIcon getPointerIcon() { + return window.getPointerIcon(); + } + + @Override + public final void setPointerIcon(final PointerIcon pi) { + window.setPointerIcon(pi); + } + @Override public final boolean isPointerConfined() { return window.isPointerConfined(); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 0c29d772a..4e9b8b441 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -34,14 +34,18 @@ package jogamp.newt; +import com.jogamp.common.util.IOUtil; import com.jogamp.newt.Display; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.event.NEWTEvent; import com.jogamp.newt.event.NEWTEventConsumer; import jogamp.newt.event.NEWTEventTask; + import com.jogamp.newt.util.EDTUtil; +import java.io.IOException; +import java.net.MalformedURLException; import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -62,6 +66,67 @@ public abstract class DisplayImpl extends Display { }); } + public static class PointerIconImpl implements PointerIcon { + public final long handle; + public PointerIconImpl(long handle) { + this.handle=handle; + } + } + + private void addPointerIconToList(final PointerIcon pi) { + synchronized(pointerIconList) { + pointerIconList.add(pi); + } + } + private void delPointerIconFromList(final PointerIcon pi) { + synchronized(pointerIconList) { + pointerIconList.remove(pi); + } + } + private final ArrayList pointerIconList = new ArrayList(); + + /** Executed from EDT! */ + private void destroyAllPointerIconFromList(final long dpy) { + synchronized(pointerIconList) { + for( int i=0; i < pointerIconList.size(); i++ ) { + final PointerIcon item = pointerIconList.get(i); + if( null != item ) { + // destroy! + destroyPointerIconImpl(dpy, item); + } + } + pointerIconList.clear(); + } + } + + @Override + public final PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + final PointerIcon res = createPointerIconImpl(pngResource, hotX, hotY); + addPointerIconToList(res); + return res; + } + protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + return null; + } + + @Override + public final void destroyPointerIcon(final PointerIcon pi) { + delPointerIconFromList(pi); + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override + public Object run(long dpy) { + try { + destroyPointerIconImpl(dpy, pi); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + }); + } + /** Executed from EDT! */ + protected void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { } + /** Ensure static init has been run. */ /* pp */static void initSingleton() { } @@ -283,6 +348,7 @@ public abstract class DisplayImpl extends Display { @Override public void run() { if ( null != f_aDevice ) { + f_dpy.destroyAllPointerIconFromList(f_aDevice.getHandle()); f_dpy.closeNativeImpl(f_aDevice); } } @@ -453,7 +519,7 @@ public abstract class DisplayImpl extends Display { /** Dispatch native Toolkit messageges */ protected abstract void dispatchMessagesNative(); - private Object eventsLock = new Object(); + private final Object eventsLock = new Object(); private ArrayList events = new ArrayList(); private volatile boolean haveEvents = false; diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 7a7e69e48..d078caa3b 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -42,6 +42,7 @@ import java.lang.reflect.Method; import com.jogamp.common.util.ArrayHashSet; import com.jogamp.common.util.IntBitfield; import com.jogamp.common.util.ReflectionUtil; +import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Display; @@ -83,6 +84,7 @@ import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; import jogamp.nativewindow.SurfaceUpdatedHelper; +import jogamp.newt.DisplayImpl.PointerIconImpl; public abstract class WindowImpl implements Window, NEWTEventConsumer { @@ -170,6 +172,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private String title = "Newt Window"; private boolean undecorated = false; private boolean alwaysOnTop = false; + private PointerIcon pointerIcon = null; private boolean pointerVisible = true; private boolean pointerConfined = false; private LifecycleHook lifecycleHook = null; @@ -436,6 +439,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer createNativeImpl(); screen.addMonitorModeListener(monitorModeListenerImpl); setTitleImpl(title); + if( null != pointerIcon ) { + setPointerIcon(pointerIcon); + } setPointerVisibleImpl(pointerVisible); confinePointerImpl(pointerConfined); setKeyboardVisible(keyboardVisible); @@ -725,6 +731,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected boolean setPointerVisibleImpl(boolean pointerVisible) { return false; } protected boolean confinePointerImpl(boolean confine) { return false; } protected void warpPointerImpl(int x, int y) { } + protected void setPointerIconImpl(final PointerIconImpl pi) { } //---------------------------------------------------------------------- // NativeSurface @@ -1675,6 +1682,21 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } + + @Override + public final PointerIcon getPointerIcon() { return pointerIcon; } + + @Override + public final void setPointerIcon(final PointerIcon pi) { + if( this.pointerIcon != pi ) { + setPointerIcon(pointerIcon); + if( isNativeValid() ) { + setPointerIconImpl((PointerIconImpl)pi); + } + this.pointerIcon = pi; + } + } + @Override public final boolean isPointerConfined() { return pointerConfined; diff --git a/src/newt/classes/jogamp/newt/driver/PNGIcon.java b/src/newt/classes/jogamp/newt/driver/PNGIcon.java new file mode 100644 index 000000000..c958f6ec2 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/PNGIcon.java @@ -0,0 +1,102 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.driver; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.nio.ByteBuffer; + +import jogamp.newt.Debug; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.common.util.ReflectionUtil; + +public class PNGIcon { + private static final String err0 = "PNG decoder not implemented."; + + private static final boolean avail; + + static { + Debug.initSingleton(); + + final ClassLoader cl = PNGIcon.class.getClassLoader(); + avail = ReflectionUtil.isClassAvailable("jogamp.newt.driver.opengl.JoglUtilPNGIcon", cl) && + ReflectionUtil.isClassAvailable("com.jogamp.opengl.util.texture.spi.PNGImage", cl); + } + + /** Returns true if PNG decoder is available. */ + public static boolean isAvailable() { + return avail; + } + + /** + * Implemented for X11. + * @param resources + * @param data_size + * @param elem_bytesize + * + * @return BGRA8888 bytes with origin at upper-left corner where component B is located on the lowest 8-bit and component A is located on the highest 8-bit. + * + * @throws UnsupportedOperationException if not implemented + * @throws InterruptedException + * @throws IOException + * @throws MalformedURLException + */ + public static ByteBuffer arrayToX11BGRAImages(IOUtil.ClassResources resources, int[] data_size, int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { + if( avail ) { + return jogamp.newt.driver.opengl.JoglUtilPNGIcon.arrayToX11BGRAImages(resources, data_size, elem_bytesize); + } + throw new UnsupportedOperationException(err0); + } + + /** + * Implemented for Windows. + * @param resources + * @param toBGRA if true, arranges stores in BGRA888 order, otherwise RGBA888 + * @param width + * @param height + * @param data_size + * @param elem_bytesize + * @param resourcesIdx + * @return pixels with origin at upper-left corner. + * If storing RGBA8888, component R is located on the lowest 8-bit. + * If storing BGRA8888, component B is located on the lowest 8-bit. + * Component A is located on the highest 8-bit. + * + * @throws UnsupportedOperationException if not implemented + * @throws InterruptedException + * @throws IOException + * @throws MalformedURLException + */ + public static ByteBuffer singleToRGBAImage(IOUtil.ClassResources resources, int resourceIdx, boolean toBGRA, int[] width, int[] height, int[] data_size, int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { + if( avail ) { + return jogamp.newt.driver.opengl.JoglUtilPNGIcon.singleToRGBAImage(resources, resourceIdx, toBGRA, width, height, data_size, elem_bytesize); + } + throw new UnsupportedOperationException(err0); + } +} diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index c44685dc8..86c8464a8 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -34,15 +34,26 @@ package jogamp.newt.driver.macosx; +import java.io.IOException; +import java.net.MalformedURLException; +import java.nio.Buffer; +import java.nio.ByteBuffer; + import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import com.jogamp.common.util.IOUtil; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; +import com.jogamp.newt.NewtFactory; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; +import jogamp.newt.driver.PNGIcon; public class DisplayDriver extends DisplayImpl { + private static final int defaultIconWidth, defaultIconHeight; + private static final Buffer defaultIconData; + static { NEWTJNILibLoader.loadNEWT(); @@ -52,6 +63,25 @@ public class DisplayDriver extends DisplayImpl { if(!WindowDriver.initIDs0()) { throw new NativeWindowException("Failed to initialize jmethodIDs"); } + { + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; + Buffer data=null; + if( PNGIcon.isAvailable() ) { + try { + final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons(); + data = PNGIcon.singleToRGBAImage(iconRes, iconRes.resourceCount()-1, false /* toBGRA */, width, height, data_size, elem_bytesize); + } catch (Exception e) { + e.printStackTrace(); + } + } + defaultIconWidth = width[0]; + defaultIconHeight = height[0]; + defaultIconData = data; + if( null != defaultIconData ) { + DisplayDriver.setAppIcon0(defaultIconData, defaultIconWidth, defaultIconHeight); + } + } + if(DEBUG) { System.err.println("MacDisplay.init App and IDs OK "+Thread.currentThread().getName()); } @@ -79,6 +109,23 @@ public class DisplayDriver extends DisplayImpl { aDevice.close(); } + @Override + protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + if( PNGIcon.isAvailable() ) { + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; + if( null != pngResource && 0 < pngResource.resourceCount() ) { + final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size, elem_bytesize); + return new PointerIconImpl( createPointerIcon0(data, width[0], height[0], hotX, hotY) ); + } + } + return null; + } + + @Override + protected final void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { + destroyPointerIcon0(((PointerIconImpl)pi).handle); + } + public static void runNSApplication() { runNSApplication0(); } @@ -89,5 +136,9 @@ public class DisplayDriver extends DisplayImpl { private static native boolean initNSApplication0(); private static native void runNSApplication0(); private static native void stopNSApplication0(); + /* pp */ static native void setAppIcon0(Object iconData, int iconWidth, int iconHeight); + private static native long createPointerIcon0(Object iconData, int iconWidth, int iconHeight, int hotX, int hotY); + private static native long destroyPointerIcon0(long handle); + } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 641d7437c..a55fa915a 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.util.PointImmutable; import jogamp.nativewindow.macosx.OSXUtil; import jogamp.newt.WindowImpl; +import jogamp.newt.DisplayImpl.PointerIconImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; @@ -391,6 +392,15 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } + @Override + protected void setPointerIconImpl(final PointerIconImpl pi) { + OSXUtil.RunOnMainThread(false, new Runnable() { + @Override + public void run() { + setPointerIcon0(getWindowHandle(), null != pi ? pi.handle : 0); + } } ); + } + @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { if( !isOffscreenInstance ) { @@ -568,6 +578,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); private static native boolean confinePointer0(long windowHandle, boolean confine); private static native void warpPointer0(long windowHandle, int x, int y); + private static native void setPointerIcon0(long windowHandle, long handle); // Window styles private static final int NSBorderlessWindowMask = 0; diff --git a/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java b/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java new file mode 100644 index 000000000..ea9029006 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java @@ -0,0 +1,139 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.driver.opengl; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URLConnection; +import java.nio.ByteBuffer; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.util.texture.spi.PNGImage; + +public class JoglUtilPNGIcon { + + public static ByteBuffer arrayToX11BGRAImages(IOUtil.ClassResources resources, int[] data_size, int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { + final PNGImage[] images = new PNGImage[resources.resourceCount()]; + data_size[0] = 0; + for(int i=0; inull if !{@link #isNativeValid()}, otherwise the Boolean value of {@link X11GraphicsDevice#isXineramaEnabled()}. */ protected Boolean isXineramaEnabled() { return isNativeValid() ? Boolean.valueOf(((X11GraphicsDevice)aDevice).isXineramaEnabled()) : null; } + @Override + protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + if( PNGIcon.isAvailable() ) { + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; + if( null != pngResource && 0 < pngResource.resourceCount() ) { + final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, false /* toBGRA */, width, height, data_size, elem_bytesize); + final long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override + public Long run(long dpy) { + long h = 0; + try { + h = createPointerIcon0(dpy, data, width[0], height[0], hotX, hotY); + } catch (Exception e) { + e.printStackTrace(); + } + return Long.valueOf(h); + } + }).longValue(); + return new PointerIconImpl(handle); + } + } + return null; + } + + @Override + protected final void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { + destroyPointerIcon0(displayHandle, ((PointerIconImpl)pi).handle); + } + //---------------------------------------------------------------------- // Internals only // @@ -137,6 +174,15 @@ public class DisplayDriver extends DisplayImpl { private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom /* , long kbdHandle */); // XKB disabled for now + static long createPointerIcon0(long display, Buffer data, int width, int height, int hotX, int hotY) { + if( !Buffers.isDirect(data) ) { + throw new IllegalArgumentException("data buffer is not direct "+data); + } + return createPointerIcon0(display, data, Buffers.getDirectBufferByteOffset(data), width, height, hotX, hotY); + } + private static native long createPointerIcon0(long display, Object data, int data_offset, int width, int height, int hotX, int hotY); + static native void destroyPointerIcon0(long display, long handle); + /** X11 Window delete atom marker used on EDT */ private long windowDeleteAtom; diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index f2a27b0c9..0ea2c5358 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -34,11 +34,16 @@ package jogamp.newt.driver.x11; +import java.nio.Buffer; + import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; import jogamp.newt.DisplayImpl; import jogamp.newt.DisplayImpl.DisplayRunnable; +import jogamp.newt.DisplayImpl.PointerIconImpl; import jogamp.newt.WindowImpl; +import jogamp.newt.driver.PNGIcon; + import javax.media.nativewindow.*; import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.nativewindow.util.Insets; @@ -47,6 +52,7 @@ import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; +import com.jogamp.newt.NewtFactory; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseEvent; @@ -58,8 +64,29 @@ public class WindowDriver extends WindowImpl { private static final int X11_WHEEL_TWO_UP_BUTTON = 6; private static final int X11_WHEEL_TWO_DOWN_BUTTON = 7; + private static final int defaultIconDataSize; + private static final Buffer defaultIconData; + static { ScreenDriver.initSingleton(); + + int _icon_data_size=0, _icon_elem_bytesize=0; + Buffer _icon_data=null; + if( PNGIcon.isAvailable() ) { + try { + final int[] data_size = { 0 }, elem_bytesize = { 0 }; + _icon_data = PNGIcon.arrayToX11BGRAImages(NewtFactory.getWindowIcons(), data_size, elem_bytesize); + _icon_data_size = data_size[0]; + _icon_elem_bytesize = elem_bytesize[0]; + } catch (Exception e) { + e.printStackTrace(); + } + } + defaultIconDataSize = _icon_data_size; + defaultIconData = _icon_data; + if(DEBUG_IMPLEMENTATION) { + System.err.println("Def. Icon: data_size "+defaultIconDataSize+" * elem_size "+_icon_elem_bytesize+" = data "+defaultIconData); + } } public WindowDriver() { @@ -100,7 +127,8 @@ public class WindowDriver extends WindowImpl { setWindowHandle(CreateWindow0(getParentWindowHandle(), edtDevice.getHandle(), screen.getIndex(), visualID, display.getJavaObjectAtom(), display.getWindowDeleteAtom(), - getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); + getX(), getY(), getWidth(), getHeight(), autoPosition(), flags, + defaultIconDataSize, defaultIconData)); } finally { edtDevice.unlock(); } @@ -245,6 +273,21 @@ public class WindowDriver extends WindowImpl { }); } + @Override + protected void setPointerIconImpl(final PointerIconImpl pi) { + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override + public Object run(long dpy) { + try { + setPointerIcon0(dpy, getWindowHandle(), null != pi ? pi.handle : 0); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + }); + } + @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { @@ -381,13 +424,17 @@ public class WindowDriver extends WindowImpl { private native long CreateWindow0(long parentWindowHandle, long display, int screen_index, int visualID, long javaObjectAtom, long windowDeleteAtom, - int x, int y, int width, int height, boolean autoPosition, int flags); + int x, int y, int width, int height, boolean autoPosition, int flags, + int iconDataSize, Object iconData); private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom /*, long kbdHandle*/ ); // XKB disabled for now private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle, long windowDeleteAtom, int x, int y, int width, int height, int flags); private native void requestFocus0(long display, long windowHandle, boolean force); private static native void setTitle0(long display, long windowHandle, String title); + + private static native void setPointerIcon0(long display, long windowHandle, long handle); + private static native long getParentWindow0(long display, long windowHandle); private static native boolean setPointerVisible0(long display, long windowHandle, boolean visible); private static native boolean confinePointer0(long display, long windowHandle, boolean grab); diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 30d3458ad..16e9814ef 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -285,6 +285,76 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_stopNSApplic [pool release]; } +static NSImage * createNSImageFromData(JNIEnv *env, jobject jiconData, jint jiconWidth, jint jiconHeight) { + if( NULL != jiconData ) { + unsigned char * iconData = (unsigned char *) (*env)->GetDirectBufferAddress(env, jiconData); + NSInteger iconWidth = (NSInteger) jiconWidth; + NSInteger iconHeight = (NSInteger) jiconHeight; + const NSInteger bpc = 8 /* bits per component */, spp=4 /* RGBA */, bpp = bpc * spp; + const NSBitmapFormat bfmt = NSAlphaNonpremultipliedBitmapFormat; + const BOOL hasAlpha = YES; + + NSBitmapImageRep* bir = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: &iconData + pixelsWide: iconWidth + pixelsHigh: iconHeight + bitsPerSample: bpc + samplesPerPixel: spp + hasAlpha: hasAlpha + isPlanar: NO + colorSpaceName: NSCalibratedRGBColorSpace + bitmapFormat: bfmt + bytesPerRow: iconWidth*4 + bitsPerPixel: bpp]; + [bir autorelease]; + NSImage* nsImage = [[NSImage alloc] initWithCGImage: [bir CGImage] size:NSZeroSize]; + return nsImage; + } + return NULL; +} + +/* + * Class: jogamp_newt_driver_macosx_DisplayDriver + * Method: setAppIcon0 + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_setAppIcon0 + (JNIEnv *env, jobject unused, jobject jiconData, jint jiconWidth, jint jiconHeight) +{ + NSImage * nsImage = createNSImageFromData(env, jiconData, jiconWidth, jiconHeight); + if( NULL != nsImage ) { + [nsImage autorelease]; + [NSApp setApplicationIconImage: nsImage]; + } +} + +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_createPointerIcon0 + (JNIEnv *env, jobject unused, jobject jiconData, jint jiconWidth, jint jiconHeight, jint hotX, jint hotY) +{ + NSImage * nsImage = createNSImageFromData(env, jiconData, jiconWidth, jiconHeight); + if( NULL != nsImage ) { + [nsImage autorelease]; + NSPoint hotP = { hotX, hotY }; + NSCursor * c = [[NSCursor alloc] initWithImage: nsImage hotSpot: hotP]; + return (jlong) (intptr_t) c; + } + return 0; +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_destroyPointerIcon0 + (JNIEnv *env, jobject unused, jlong handle) +{ + NSCursor * c = (NSCursor*) (intptr_t) handle ; + [c release]; +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerIcon0 + (JNIEnv *env, jobject unused, jlong window, jlong handle) +{ + NewtMacWindow *mWin = (NewtMacWindow*) (intptr_t) window; + NSCursor * c = (NSCursor*) (intptr_t) handle ; + + [mWin setCustomCursor: c]; +} + static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx, BOOL cap) { NSArray *screens = [NSScreen screens]; if( screen_idx<0 || screen_idx>=[screens count] ) { @@ -632,7 +702,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createView0 [pool release]; - return (jlong) ((intptr_t) myView); + return (jlong) (intptr_t) myView; } /** @@ -674,7 +744,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow backing: (NSBackingStoreType) bufferingType defer: YES isFullscreenWindow: fullscreen]; - // DBG_PRINT( "createWindow0.1 - %p, isVisible %d\n", myWindow, [myWindow isVisible]); DBG_PRINT( "createWindow0.X - %p, isVisible %d\n", myWindow, [myWindow isVisible]); diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index ba60b5665..1f907f30e 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -114,6 +114,7 @@ BOOL mouseVisible; BOOL mouseInside; BOOL cursorIsHidden; + NSCursor * customCursor; BOOL realized; BOOL modsDown[4]; // shift, ctrl, alt/option, win/command NSPoint lastInsideMousePosition; @@ -151,7 +152,8 @@ - (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p; - (BOOL) isMouseInside; -- (void) cursorHide:(BOOL)v; +- (void) cursorHide:(BOOL)v enter:(int)enterState; +- (void) setCustomCursor:(NSCursor*)c; - (void) setMouseVisible:(BOOL)v hasFocus:(BOOL)focus; - (void) setMouseConfined:(BOOL)v; - (void) setMousePosition:(NSPoint)p; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 4b0198c7e..a7bab9b9d 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -41,6 +41,8 @@ #include +#define PRINTF(...) NSLog(@ __VA_ARGS__) + static jfloat GetDelta(NSEvent *event, jint javaMods[]) { CGEventRef cgEvent = [event CGEvent]; CGFloat deltaY = 0.0; @@ -468,6 +470,7 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { defaultPresentationOptions = 0; fullscreenPresentationOptions = 0; } + isFullscreenWindow = isfs; // Why is this necessary? Without it we don't get any of the // delegate methods like resizing and window movement. @@ -484,6 +487,7 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { mouseVisible = YES; mouseInside = NO; cursorIsHidden = NO; + customCursor = NULL; realized = YES; DBG_PRINT("NewtWindow::create: %p, realized %d, hasPresentationSwitch %d[defaultOptions 0x%X, fullscreenOptions 0x%X], (refcnt %d)\n", res, realized, (int)hasPresentationSwitch, (int)defaultPresentationOptions, (int)fullscreenPresentationOptions, (int)[res retainCount]); @@ -678,13 +682,36 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { DBG_PRINT( "setMouseVisible: confined %d, visible %d (current: %d), mouseInside %d, hasFocus %d\n", mouseConfined, mouseVisible, !cursorIsHidden, mouseInside, focus); if(YES == focus && YES == mouseInside) { - [self cursorHide: !mouseVisible]; + [self cursorHide: !mouseVisible enter: 0]; + } +} + +- (void) setCustomCursor:(NSCursor*)c +{ + if(YES == mouseInside) { + if( NULL != c ) { + DBG_PRINT( "setCustomCursor push: %p\n", c); + [c push]; + } else if( NULL != customCursor && [NSCursor currentCursor] == customCursor ) { + DBG_PRINT( "setCustomCursor pop: %p\n", customCursor); + [customCursor pop]; + } } + customCursor = c; } -- (void) cursorHide:(BOOL)v +- (void) cursorHide:(BOOL)v enter:(int)enterState { - DBG_PRINT( "cursorHide: %d -> %d\n", cursorIsHidden, v); + DBG_PRINT( "cursorHide: %d -> %d, enter %d\n", cursorIsHidden, v, enterState); + if( NULL != customCursor ) { + if( 1 == enterState && [NSCursor currentCursor] != customCursor ) { + DBG_PRINT( "cursorHide.customCursor push: %p\n", customCursor); + [customCursor push]; + } else if( -1 == enterState && [NSCursor currentCursor] == customCursor ) { + DBG_PRINT( "cursorHide.customCursor pop: %p\n", customCursor); + [customCursor pop]; + } + } if(v) { if(!cursorIsHidden) { [NSCursor hide]; @@ -941,7 +968,7 @@ static jint mods2JavaMods(NSUInteger mods) DBG_PRINT( "*************** windowDidBecomeKey\n"); mouseInside = [self isMouseInside]; if(YES == mouseInside) { - [self cursorHide: !mouseVisible]; + [self cursorHide: !mouseVisible enter: 0]; } [self focusChanged: YES]; } @@ -995,7 +1022,7 @@ static jint mods2JavaMods(NSUInteger mods) { DBG_PRINT( "mouseEntered: confined %d, visible %d\n", mouseConfined, mouseVisible); mouseInside = YES; - [self cursorHide: !mouseVisible]; + [self cursorHide: !mouseVisible enter: 1]; if(NO == mouseConfined) { [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_ENTERED]; } @@ -1006,7 +1033,7 @@ static jint mods2JavaMods(NSUInteger mods) DBG_PRINT( "mouseExited: confined %d, visible %d\n", mouseConfined, mouseVisible); if(NO == mouseConfined) { mouseInside = NO; - [self cursorHide: NO]; + [self cursorHide: NO enter: -1]; [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_EXITED]; } else { [self setMousePosition: lastInsideMousePosition]; @@ -1160,7 +1187,7 @@ static jint mods2JavaMods(NSUInteger mods) jboolean closed = JNI_FALSE; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [self cursorHide: NO]; + [self cursorHide: NO enter: -1]; NSView* nsview = [self contentView]; if( ! [nsview isKindOfClass:[NewtView class]] ) { diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index dd0150e78..2a16dce57 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -139,7 +139,7 @@ #include "NewtCommon.h" -// #define VERBOSE_ON 1 +#define VERBOSE_ON 1 // #define DEBUG_KEYS 1 #ifdef VERBOSE_ON @@ -186,6 +186,10 @@ typedef struct { int height; /** Tristate: -1 HIDE, 0 NOP, 1 SHOW */ int setPointerVisible; + /** Tristate: -1 RESET, 0 NOP, 1 SET-NEW */ + int setPointerAction; + HCURSOR setPointerHandle; + HCURSOR defPointerHandle; /** Bool: 0 NOP, 1 FULLSCREEN */ int setFullscreen; int pointerCaptured; @@ -1023,10 +1027,22 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP } else /* -1 == wud->setPointerVisible */ { visibilityChangeSuccessful = SafeShowCursor(FALSE); } - useDefWindowProc = visibilityChangeSuccessful ? 1 : 0; DBG_PRINT("*** WindowsWindow: WM_SETCURSOR requested visibility: %d success: %d\n", wud->setPointerVisible, visibilityChangeSuccessful); wud->setPointerVisible = 0; - // own signal, consumed + // own signal, consumed, no further processing + useDefWindowProc = 0; + res = 1; + } else if( 0 != wud->setPointerAction ) { + if( -1 == wud->setPointerAction ) { + wud->setPointerHandle = wud->defPointerHandle; + } + HCURSOR preHandle = SetCursor(wud->setPointerHandle); + DBG_PRINT("*** WindowsWindow: WM_SETCURSOR requested change %d: pre %p -> set %p, def %p\n", + wud->setPointerAction, (void*)preHandle, (void*)wud->setPointerHandle, (void*)wud->defPointerHandle); + wud->setPointerAction = 0; + // own signal, consumed, no further processing + useDefWindowProc = 0; + res = 1; } else { useDefWindowProc = 1; // NOP for us, allow parent to act } @@ -1246,6 +1262,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP if( 0 == wud->pointerInside ) { wud->pointerInside = 1; NewtWindows_trackPointerLeave(wnd); + SetCursor(wud->setPointerHandle); } (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED, @@ -1997,7 +2014,8 @@ static void NewtWindow_setVisiblePosSize(HWND hwnd, BOOL atop, BOOL visible, JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindow0 (JNIEnv *env, jobject obj, jlong hInstance, jstring jWndClassName, jstring jWndName, jint winMajor, jint winMinor, - jlong parent, jint jx, jint jy, jint defaultWidth, jint defaultHeight, jboolean autoPosition, jint flags) + jlong parent, jint jx, jint jy, jint defaultWidth, jint defaultHeight, jboolean autoPosition, jint flags, + jlong iconSmallHandle, jlong iconBigHandle) { HWND parentWindow = (HWND) (intptr_t) parent; const TCHAR* wndClassName = NULL; @@ -2054,6 +2072,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo wud->width = width; wud->height = height; wud->setPointerVisible = 0; + wud->setPointerAction = 0; + wud->defPointerHandle = LoadCursor( NULL, IDC_ARROW); + wud->setPointerHandle = wud->defPointerHandle; wud->setFullscreen = 0; wud->pointerCaptured = 0; wud->pointerInside = 0; @@ -2083,6 +2104,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo RECT rc; RECT * insets; + if( 0 != iconSmallHandle ) { + SendMessage(window, WM_SETICON, ICON_SMALL, (LPARAM) iconSmallHandle ); + } + if( 0 != iconBigHandle ) { + SendMessage(window, WM_SETICON, ICON_BIG, (LPARAM) iconBigHandle ); + } ShowWindow(window, SW_SHOW); // send insets before visibility, allowing java code a proper sync point! @@ -2321,3 +2348,83 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_warpPointer0 SetCursorPos(x, y); } +JNIEXPORT jlong JNICALL +Java_jogamp_newt_driver_windows_DisplayDriver_createBGRA8888Icon0(JNIEnv *env, jobject _unused, + jobject data, jint data_offset, jint width, jint height, jboolean isCursor, jint hotX, jint hotY) { + + const unsigned char * data_ptr = (const unsigned char *) (*env)->GetDirectBufferAddress(env, data) + data_offset; + const int bytes = 4 * width * height; // BGRA8888 + + DWORD dwWidth, dwHeight; + BITMAPV5HEADER bi; + HBITMAP hBitmap; + void *lpBits; + HICON handle = NULL; + + dwWidth = width; // width of cursor + dwHeight = height; // height of cursor + + ZeroMemory(&bi,sizeof(BITMAPV5HEADER)); + bi.bV5Size = sizeof(BITMAPV5HEADER); + bi.bV5Width = dwWidth; + bi.bV5Height = -1 * dwHeight; + bi.bV5Planes = 1; + bi.bV5BitCount = 32; + bi.bV5Compression = BI_BITFIELDS; + // The following mask specification specifies a supported 32 BPP + // alpha format for Windows XP. + bi.bV5RedMask = 0x00FF0000; + bi.bV5GreenMask = 0x0000FF00; + bi.bV5BlueMask = 0x000000FF; + bi.bV5AlphaMask = 0xFF000000; + + HDC hdc; + hdc = GetDC(NULL); + + // Create the DIB section with an alpha channel. + hBitmap = CreateDIBSection(hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, + (void **)&lpBits, NULL, (DWORD)0); + + memcpy(lpBits, data_ptr, bytes); + + ReleaseDC(NULL,hdc); + + // Create an empty mask bitmap. + HBITMAP hMonoBitmap = CreateBitmap(dwWidth,dwHeight,1,1,NULL); + + ICONINFO ii; + ii.fIcon = isCursor ? FALSE : TRUE; + ii.xHotspot = hotX; + ii.yHotspot = hotY; + ii.hbmMask = hMonoBitmap; + ii.hbmColor = hBitmap; + + // Create the alpha cursor with the alpha DIB section. + handle = CreateIconIndirect(&ii); + + DeleteObject(hBitmap); + DeleteObject(hMonoBitmap); + + return (jlong) (intptr_t) handle; +} + +JNIEXPORT void JNICALL +Java_jogamp_newt_driver_windows_DisplayDriver_destroyIcon0(JNIEnv *env, jobject _unused, jlong jhandle) { + HICON handle = (HICON) (intptr_t) jhandle; + DestroyIcon(handle); +} + +JNIEXPORT void JNICALL +Java_jogamp_newt_driver_windows_WindowDriver_setPointerIcon0(JNIEnv *env, jobject _unused, jlong window, jlong iconHandle) { + HWND hwnd = (HWND) (intptr_t) window; + WindowUserData * wud; +#if !defined(__MINGW64__) && ( defined(UNDER_CE) || _MSC_VER <= 1200 ) + wud = (WindowUserData *) GetWindowLong(hwnd, GWL_USERDATA); +#else + wud = (WindowUserData *) GetWindowLongPtr(hwnd, GWLP_USERDATA); +#endif + wud->setPointerAction = 0 != iconHandle ? 1 : -1; + wud->setPointerHandle = (HCURSOR) (intptr_t) iconHandle; + SendMessage(hwnd, WM_SETCURSOR, 0, 0); +} + diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index e2392a113..19e733111 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -28,6 +28,8 @@ #include "X11Common.h" +#include + // #include // XKB disabled for now jclass X11NewtWindowClazz = NULL; @@ -670,4 +672,54 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage } } +/* + * Class: Java_jogamp_newt_driver_x11_DisplayDriver + * Method: createPointerIcon0 + * Signature: (JJILjava/lang/Object;I)V + */ +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_createPointerIcon0 + (JNIEnv *env, jclass clazz, jlong display, jobject data, jint data_offset, jint width, jint height, jint hotX, jint hotY) +{ + Cursor c; + + if( 0 != data ) { + Display * dpy = (Display *) (intptr_t) display; + char * data_ptr = (char *) (*env)->GetDirectBufferAddress(env, data) + data_offset; + XcursorImage ci; + ci.version = 1; // XCURSOR_IMAGE_VERSION; + ci.size = width; // nominal size (assume square ..) + ci.width = width; + ci.height = height; + ci.xhot = hotX; + ci.yhot = hotY; + ci.delay = 0; + ci.pixels = (XcursorPixel *)(intptr_t)data_ptr; + + c = XcursorImageLoadCursor (dpy, &ci); + + DBG_PRINT( "X11: createPointerIcon0: %p %dx%d %d/%d -> %p\n", data_ptr, width, height, hotX, hotY, (void *)c); + + } else { + c = 0; + } + return (jlong) (intptr_t) c; +} + +/* + * Class: Java_jogamp_newt_driver_x11_DisplayDriver + * Method: destroyPointerIcon0 + * Signature: (JJILjava/lang/Object;I)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_destroyPointerIcon0 + (JNIEnv *env, jclass clazz, jlong display, jlong handle) +{ + Display * dpy = (Display *) (intptr_t) display; + + if( 0 != handle ) { + Cursor c = (Cursor) (intptr_t) handle; + DBG_PRINT( "X11: destroyPointerIcon0: %p\n", (void *)c); + XFreeCursor(dpy, c); + } +} + diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 5f5dddbe0..da2778004 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -497,6 +497,12 @@ static void NewtWindows_setPosSize(Display *dpy, Window w, jint x, jint y, jint } } +static void NewtWindows_setIcon(Display *dpy, Window w, int data_size, const unsigned char * data_ptr) { + Atom _NET_WM_ICON = XInternAtom(dpy, "_NET_WM_ICON", False); + Atom CARDINAL = XInternAtom(dpy, "CARDINAL", False); + XChangeProperty(dpy, w, _NET_WM_ICON, CARDINAL, 32, PropModeReplace, data_ptr, data_size); +} + /* * Class: jogamp_newt_driver_x11_WindowDriver * Method: CreateWindow @@ -505,7 +511,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 (JNIEnv *env, jobject obj, jlong parent, jlong display, jint screen_index, jint visualID, jlong javaObjectAtom, jlong windowDeleteAtom, - jint x, jint y, jint width, jint height, jboolean autoPosition, int flags) + jint x, jint y, jint width, jint height, jboolean autoPosition, int flags, + jint iconDataSize, jobject iconData) { Display * dpy = (Display *)(intptr_t)display; Atom wm_delete_atom = (Atom)windowDeleteAtom; @@ -626,6 +633,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 XEvent event; int left=0, right=0, top=0, bottom=0; + if( 0 < iconDataSize && NULL != iconData ) { + const unsigned char * iconDataPtr = (const unsigned char *) (*env)->GetDirectBufferAddress(env, iconData); + NewtWindows_setIcon(dpy, window, (int)iconDataSize, iconDataPtr); + } + XMapWindow(dpy, window); XIfEvent( dpy, &event, WaitForMapNotify, (XPointer) window ); // wait to get proper insets values @@ -944,6 +956,27 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_setTitle0 #endif } +/* + * Class: Java_jogamp_newt_driver_x11_WindowDriver + * Method: setPointerIcon0 + * Signature: (JJILjava/lang/Object;I)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_setPointerIcon0 + (JNIEnv *env, jclass clazz, jlong display, jlong window, jlong handle) +{ + Display * dpy = (Display *) (intptr_t) display; + Window w = (Window)window; + + if( 0 == handle ) { + DBG_PRINT( "X11: setPointerIcon0: reset\n"); + XUndefineCursor(dpy, w); + } else { + Cursor c = (Cursor) (intptr_t) handle; + DBG_PRINT( "X11: setPointerIcon0: %p\n", (void*)c); + XDefineCursor(dpy, w, c); + } +} + /* * Class: Java_jogamp_newt_driver_x11_WindowDriver * Method: setPointerVisible0 diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index b54a2cd19..efec961de 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -30,7 +30,9 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.newt; import java.io.IOException; +import com.jogamp.common.util.IOUtil; import com.jogamp.newt.Display; +import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.event.KeyAdapter; @@ -44,9 +46,7 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; - import com.jogamp.opengl.util.Animator; - import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import javax.media.nativewindow.NativeWindowFactory; @@ -54,7 +54,6 @@ import javax.media.nativewindow.util.Dimension; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; import javax.media.nativewindow.util.DimensionImmutable; - import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; @@ -171,6 +170,20 @@ public class TestGearsES2NEWT extends UITestCase { } }); + final PointerIcon pointerIconOne; + { + PointerIcon _pointerIconOne = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); + final Display disp = glWindow.getScreen().getDisplay(); + disp.createNative(); + try { + _pointerIconOne = disp.createPointerIcon(res, 32, 0); + } catch (Exception e) { + e.printStackTrace(); + } + pointerIconOne = _pointerIconOne; + } + glWindow.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { @@ -203,6 +216,16 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("[set alwaysontop post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setExclusiveContextThread(t); } }.start(); + } else if(e.getKeyChar()=='c') { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set pointer-icon pre]"); + final PointerIcon currentPI = glWindow.getPointerIcon(); + glWindow.setPointerIcon( currentPI == pointerIconOne ? null : pointerIconOne); + System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); + glWindow.setExclusiveContextThread(t); + } }.start(); } else if(e.getKeyChar()=='d') { new Thread() { public void run() { -- cgit v1.2.3 From d8b3e369cf5365d09853db20b817cda7553b9a48 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 31 Dec 2013 08:40:48 +0100 Subject: Bug 935: NEWT: Expose Pointer Icons Feature in JOGLNewtAppletBase Tests --- ...nner-newt-ElektronenMultiplizierer-napplet.html | 3 + ...pplet-runner-newt-ElektronenMultiplizierer.html | 3 + ...let-runner-newt-GraphUISceneDemo01-napplet.html | 3 + ...jogl-applet-runner-newt-GraphUISceneDemo01.html | 3 + .../jogl-applet-runner-newt-MovieCube-napplet.html | 3 + jnlp-files/jogl-applet-runner-newt-MovieCube.html | 3 + .../jogl-applet-runner-newt-gears-gl3-napplet.html | 3 + ...plet-runner-newt-gears-normal-launcheronly.html | 3 + ...gl-applet-runner-newt-gears-normal-napplet.html | 3 + ...l-applet-runner-newt-gears-normal-napplet2.html | 3 + .../jogl-applet-runner-newt-gears-normal.html | 3 + ...l-applet-runner-newt-gears-special-napplet.html | 3 + .../jogl-applet-runner-newt-gears-special.html | 3 + .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 85 +++++++++++++++++----- 14 files changed, 105 insertions(+), 19 deletions(-) (limited to 'src/newt/classes') diff --git a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html index 19a3b2965..a989f7f09 100644 --- a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html @@ -58,6 +58,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • diff --git a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html index 71c9baff8..83131585a 100644 --- a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html +++ b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html @@ -75,6 +75,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • diff --git a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html index 8f9783f03..a22d8f26c 100644 --- a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html @@ -60,6 +60,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • diff --git a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html index 429e80311..0f050a98d 100644 --- a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html +++ b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html @@ -78,6 +78,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • diff --git a/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html b/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html index 5dc77f024..242efa6fd 100644 --- a/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html @@ -72,6 +72,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • diff --git a/jnlp-files/jogl-applet-runner-newt-MovieCube.html b/jnlp-files/jogl-applet-runner-newt-MovieCube.html index a154eb825..bb61fc143 100644 --- a/jnlp-files/jogl-applet-runner-newt-MovieCube.html +++ b/jnlp-files/jogl-applet-runner-newt-MovieCube.html @@ -89,6 +89,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • diff --git a/jnlp-files/jogl-applet-runner-newt-gears-gl3-napplet.html b/jnlp-files/jogl-applet-runner-newt-gears-gl3-napplet.html index cb2375e4c..9dd3806f1 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-gl3-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-gl3-napplet.html @@ -12,6 +12,9 @@ JOGL NEWT Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html b/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html index a9e42d342..328228146 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html @@ -12,6 +12,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html index 9b448394d..e1e9593de 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html @@ -12,6 +12,9 @@ JOGL NEWT Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html index 8970aea53..09c5f4b47 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html @@ -12,6 +12,9 @@ JOGL NEWT Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • If Applet is out of browser window, it is closeable.

                      diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal.html b/jnlp-files/jogl-applet-runner-newt-gears-normal.html index a6dd16a0c..310e659ba 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal.html @@ -26,6 +26,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • diff --git a/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html b/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html index 7df167844..bb27fde68 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html @@ -57,6 +57,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • Normal webpage text - Normal webpage text - Normal webpage text - Normal webpage text
                      Normal webpage text - Normal webpage text - Normal webpage text - Normal webpage text
                      diff --git a/jnlp-files/jogl-applet-runner-newt-gears-special.html b/jnlp-files/jogl-applet-runner-newt-gears-special.html index 0f5911414..01f37d6c7 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-special.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-special.html @@ -75,6 +75,9 @@ JOGL NEWT JNLP Applet Runner Special Keys:
                    • f - toggle fullscreen
                    • r - in/out browser window
                    • a - on/off always-on-top
                    • +
                    • c - change mouse pointer
                    • +
                    • i - invisible mouse pointer
                    • +
                    • w - warp mouse pointer to center
                    • Normal webpage text - Normal webpage text - Normal webpage text - Normal webpage text
                      Normal webpage text - Normal webpage text - Normal webpage text - Normal webpage text
                      diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index e6571d21a..eac328cdd 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -42,7 +42,10 @@ import javax.media.opengl.GLPipelineFactory; import jogamp.newt.Debug; +import com.jogamp.common.util.IOUtil; +import com.jogamp.newt.Display; import com.jogamp.newt.Window; +import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.MouseListener; @@ -65,6 +68,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { boolean glClosable; boolean glDebug; boolean glTrace; + PointerIcon pointerIconTest = null; GLEventListener glEventListener = null; GLWindow glWindow = null; @@ -230,6 +234,15 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { if(isValid) { glWindow.setVisible(true); glWindow.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); + if( null == pointerIconTest ) { + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/jogamp-32x32.png" } ); + final Display disp = glWindow.getScreen().getDisplay(); + try { + pointerIconTest = disp.createPointerIcon(res, 16, 0); + } catch (Exception e) { + e.printStackTrace(); + } + } glAnimator.start(); awtParent = glWindow.getParent(); glWindow.addWindowListener(reparentHomeListener); @@ -302,28 +315,62 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { return; } if(e.getKeyChar()=='d') { - glWindow.setUndecorated(!glWindow.isUndecorated()); + new Thread() { + public void run() { + glWindow.setUndecorated(!glWindow.isUndecorated()); + } }.start(); } if(e.getKeyChar()=='f') { - glWindow.setFullscreen(!glWindow.isFullscreen()); + new Thread() { + public void run() { + glWindow.setFullscreen(!glWindow.isFullscreen()); + } }.start(); } else if(e.getKeyChar()=='a') { - glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop()); + new Thread() { + public void run() { + glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop()); + } }.start(); } else if(e.getKeyChar()=='r' && null!=awtParent) { - if(null == glWindow.getParent()) { - glWindow.reparentWindow(awtParent, -1, -1, 0 /* hints */); - } else { - final InsetsImmutable insets = glWindow.getInsets(); - final int x, y; - if ( 0 >= insets.getTopHeight() ) { - // fail safe .. - x = 32; - y = 32; - } else { - x = insets.getLeftWidth(); - y = insets.getTopHeight(); - } - glWindow.reparentWindow(null, x, y, 0 /* hints */); - glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE ); - } + new Thread() { + public void run() { + if(null == glWindow.getParent()) { + glWindow.reparentWindow(awtParent, -1, -1, 0 /* hints */); + } else { + final InsetsImmutable insets = glWindow.getInsets(); + final int x, y; + if ( 0 >= insets.getTopHeight() ) { + // fail safe .. + x = 32; + y = 32; + } else { + x = insets.getLeftWidth(); + y = insets.getTopHeight(); + } + glWindow.reparentWindow(null, x, y, 0 /* hints */); + glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE ); + } + } }.start(); + } else if(e.getKeyChar()=='c') { + new Thread() { + public void run() { + System.err.println("[set pointer-icon pre]"); + final PointerIcon currentPI = glWindow.getPointerIcon(); + glWindow.setPointerIcon( currentPI == pointerIconTest ? null : pointerIconTest); + System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); + } }.start(); + } else if(e.getKeyChar()=='i') { + new Thread() { + public void run() { + System.err.println("[set mouse visible pre]: "+glWindow.isPointerVisible()); + glWindow.setPointerVisible(!glWindow.isPointerVisible()); + System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible()); + } }.start(); + } else if(e.getKeyChar()=='w') { + new Thread() { + public void run() { + System.err.println("[set mouse pos pre]"); + glWindow.warpPointer(glWindow.getWidth()/2, glWindow.getHeight()/2); + System.err.println("[set mouse pos post]"); + } }.start(); } } -- cgit v1.2.3 From 6da365d9d3aa29070afa1a1c82996ec7f92a690b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 31 Dec 2013 16:54:07 +0100 Subject: Bug 935: NEWT PointerIcon: Add size, hotspot 'getter' and String representation PointerIcon's size and hotspot maybe be useful for certain user-app calculation. --- src/newt/classes/com/jogamp/newt/Display.java | 12 +++++++++++- src/newt/classes/jogamp/newt/DisplayImpl.java | 20 +++++++++++++++++++- .../jogamp/newt/driver/macosx/DisplayDriver.java | 5 ++++- .../jogamp/newt/driver/windows/DisplayDriver.java | 5 ++++- .../jogamp/newt/driver/x11/DisplayDriver.java | 4 +++- 5 files changed, 41 insertions(+), 5 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index ee6dfd080..cf1099c85 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -37,6 +37,8 @@ import java.util.Iterator; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.PointImmutable; import jogamp.newt.Debug; @@ -71,7 +73,15 @@ public abstract class Display { * PointerIcons can be used via {@link Window#setPointerIcon(PointerIcon)}. *

                      */ - public static interface PointerIcon { } + public static interface PointerIcon { + /** Returns the size, i.e. width and height. */ + DimensionImmutable getSize(); + /** Returns the hotspot. */ + PointImmutable getHotspot(); + + @Override + String toString(); + } /** * Returns the created {@link PointerIcon} or null if not implemented on platform. diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 4e9b8b441..dc3705daa 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -51,6 +51,8 @@ import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.PointImmutable; public abstract class DisplayImpl extends Display { private static int serialno = 1; @@ -68,8 +70,24 @@ public abstract class DisplayImpl extends Display { public static class PointerIconImpl implements PointerIcon { public final long handle; - public PointerIconImpl(long handle) { + private final DimensionImmutable size; + private final PointImmutable hotspot; + public PointerIconImpl(final long handle, final DimensionImmutable size, final PointImmutable hotspot) { this.handle=handle; + this.size = size; + this.hotspot = hotspot; + } + @Override + public final DimensionImmutable getSize() { + return size; + } + @Override + public final PointImmutable getHotspot() { + return hotspot; + } + @Override + public final String toString() { + return "PointerIcon[0x"+Long.toHexString(handle)+", "+size+", "+hotspot+"]"; } } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index 86c8464a8..b932efde6 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -41,6 +41,8 @@ import java.nio.ByteBuffer; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; import com.jogamp.common.util.IOUtil; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; @@ -115,7 +117,8 @@ public class DisplayDriver extends DisplayImpl { final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; if( null != pngResource && 0 < pngResource.resourceCount() ) { final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size, elem_bytesize); - return new PointerIconImpl( createPointerIcon0(data, width[0], height[0], hotX, hotY) ); + return new PointerIconImpl( createPointerIcon0(data, width[0], height[0], hotX, hotY), + new Dimension(width[0], height[0]), new Point(hotX, hotY)); } } return null; diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index 8d4d8972b..72a93ce2e 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -47,6 +47,8 @@ import jogamp.newt.driver.PNGIcon; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; @@ -107,7 +109,8 @@ public class DisplayDriver extends DisplayImpl { final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; if( null != pngResource && 0 < pngResource.resourceCount() ) { final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size, elem_bytesize); - return new PointerIconImpl( createBGRA8888Icon0(data, width[0], height[0], true, hotX, hotY) ); + return new PointerIconImpl( createBGRA8888Icon0(data, width[0], height[0], true, hotX, hotY), + new Dimension(width[0], height[0]), new Point(hotX, hotY)); } } return null; diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 8170c2e3d..85b31a77c 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -41,6 +41,8 @@ import java.nio.ByteBuffer; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; @@ -146,7 +148,7 @@ public class DisplayDriver extends DisplayImpl { return Long.valueOf(h); } }).longValue(); - return new PointerIconImpl(handle); + return new PointerIconImpl(handle, new Dimension(width[0], height[0]), new Point(hotX, hotY)); } } return null; -- cgit v1.2.3 From 3e85aa120149d882f52faf2c7fb053156313c896 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 3 Jan 2014 04:32:44 +0100 Subject: Bug 935: NEWT PointerIcon PNGIcon: Remove return value 'elem_bytesize[]' which is always 4 (RGBA/BGRA) --- src/newt/classes/jogamp/newt/driver/PNGIcon.java | 5 ++--- src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java | 8 ++++---- src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java | 6 +++--- src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java | 4 ++-- src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/PNGIcon.java b/src/newt/classes/jogamp/newt/driver/PNGIcon.java index c958f6ec2..ffa62978f 100644 --- a/src/newt/classes/jogamp/newt/driver/PNGIcon.java +++ b/src/newt/classes/jogamp/newt/driver/PNGIcon.java @@ -81,7 +81,6 @@ public class PNGIcon { * @param width * @param height * @param data_size - * @param elem_bytesize * @param resourcesIdx * @return pixels with origin at upper-left corner. * If storing RGBA8888, component R is located on the lowest 8-bit. @@ -93,9 +92,9 @@ public class PNGIcon { * @throws IOException * @throws MalformedURLException */ - public static ByteBuffer singleToRGBAImage(IOUtil.ClassResources resources, int resourceIdx, boolean toBGRA, int[] width, int[] height, int[] data_size, int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { + public static ByteBuffer singleToRGBAImage(IOUtil.ClassResources resources, int resourceIdx, boolean toBGRA, int[] width, int[] height, int[] data_size) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { if( avail ) { - return jogamp.newt.driver.opengl.JoglUtilPNGIcon.singleToRGBAImage(resources, resourceIdx, toBGRA, width, height, data_size, elem_bytesize); + return jogamp.newt.driver.opengl.JoglUtilPNGIcon.singleToRGBAImage(resources, resourceIdx, toBGRA, width, height, data_size); } throw new UnsupportedOperationException(err0); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index b932efde6..f0f0a955a 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -66,12 +66,12 @@ public class DisplayDriver extends DisplayImpl { throw new NativeWindowException("Failed to initialize jmethodIDs"); } { - final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; Buffer data=null; if( PNGIcon.isAvailable() ) { try { final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons(); - data = PNGIcon.singleToRGBAImage(iconRes, iconRes.resourceCount()-1, false /* toBGRA */, width, height, data_size, elem_bytesize); + data = PNGIcon.singleToRGBAImage(iconRes, iconRes.resourceCount()-1, false /* toBGRA */, width, height, data_size); } catch (Exception e) { e.printStackTrace(); } @@ -114,11 +114,11 @@ public class DisplayDriver extends DisplayImpl { @Override protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { if( PNGIcon.isAvailable() ) { - final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; if( null != pngResource && 0 < pngResource.resourceCount() ) { - final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size, elem_bytesize); return new PointerIconImpl( createPointerIcon0(data, width[0], height[0], hotX, hotY), new Dimension(width[0], height[0]), new Point(hotX, hotY)); + final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size); } } return null; diff --git a/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java b/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java index ea9029006..216a0cb20 100644 --- a/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java +++ b/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java @@ -90,7 +90,7 @@ public class JoglUtilPNGIcon { return buffer; } - public static ByteBuffer singleToRGBAImage(IOUtil.ClassResources resources, int resourceIdx, boolean toBGRA, int[] width, int[] height, int[] data_size, int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { + public static ByteBuffer singleToRGBAImage(IOUtil.ClassResources resources, int resourceIdx, boolean toBGRA, int[] width, int[] height, int[] data_size) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { width[0] = 0; height[0] = 0; data_size[0] = 0; @@ -100,8 +100,8 @@ public class JoglUtilPNGIcon { height[0] = image.getHeight(); data_size[0] = image.getWidth() * image.getHeight(); - elem_bytesize[0] = 4; // BGRA - final ByteBuffer buffer = Buffers.newDirectByteBuffer( data_size[0] * elem_bytesize[0] ); + final int elem_bytesize = 4; // BGRA + final ByteBuffer buffer = Buffers.newDirectByteBuffer( data_size[0] * elem_bytesize ); final ByteBuffer bb = image.getData(); final int bpp = image.getBytesPerPixel(); diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index 72a93ce2e..39b2efd15 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -106,11 +106,11 @@ public class DisplayDriver extends DisplayImpl { @Override protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { if( PNGIcon.isAvailable() ) { - final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; if( null != pngResource && 0 < pngResource.resourceCount() ) { - final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size, elem_bytesize); return new PointerIconImpl( createBGRA8888Icon0(data, width[0], height[0], true, hotX, hotY), new Dimension(width[0], height[0]), new Point(hotX, hotY)); + final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size); } } return null; diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 85b31a77c..c377e7f85 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -133,9 +133,9 @@ public class DisplayDriver extends DisplayImpl { @Override protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { if( PNGIcon.isAvailable() ) { - final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; if( null != pngResource && 0 < pngResource.resourceCount() ) { - final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, false /* toBGRA */, width, height, data_size, elem_bytesize); + final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, false /* toBGRA */, width, height, data_size); final long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { @Override public Long run(long dpy) { -- cgit v1.2.3 From e3cf96249f4c722f8b2a7d0e052e19165cef171e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 3 Jan 2014 04:45:03 +0100 Subject: Bug 935: NEWT PointerIcon PNGIcon: Remove return value 'elem_bytesize[]' which is always 4 (RGBA/BGRA --- src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 3239aab5b..764d4fdab 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -68,14 +68,14 @@ public class WindowDriver extends WindowImpl { long[] _defaultIconHandle = { 0, 0 }; if( PNGIcon.isAvailable() ) { try { - final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons(); { - final ByteBuffer icon_data_small = PNGIcon.singleToRGBAImage(iconRes, 0, true /* toBGRA */, width, height, data_size, elem_bytesize); + final ByteBuffer icon_data_small = PNGIcon.singleToRGBAImage(iconRes, 0, true /* toBGRA */, width, height, data_size); _defaultIconHandle[0] = DisplayDriver.createBGRA8888Icon0(icon_data_small, width[0], height[0], false, 0, 0); } { - final ByteBuffer icon_data_big = PNGIcon.singleToRGBAImage(iconRes, iconRes.resourceCount()-1, true /* toBGRA */, width, height, data_size, elem_bytesize); + final ByteBuffer icon_data_big = PNGIcon.singleToRGBAImage(iconRes, iconRes.resourceCount()-1, true /* toBGRA */, width, height, data_size); _defaultIconHandle[1] = DisplayDriver.createBGRA8888Icon0(icon_data_big, width[0], height[0], false, 0, 0); } } catch (Exception e) { -- cgit v1.2.3 From fcc0e7397bb6f3ceb1fe143667f8c59b5bf63874 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 4 Jan 2014 17:15:04 +0100 Subject: Bug 935: NEWT PointerIcon: Refine Spec and Implementation / Fix OSX Crash and Issues - Refine Display.PointerIcon: Complete type allowing re-creation - Add associated Display reference - Add used IOUtil.ClassResources reference - Add isValid()/validate() methods for recreation - Refine API doc - Move Display.destroyPointerIcon(PointerIcon) -> PointerIcon.destroy() - Move DisplayImpl.PointerIconImpl -> PointerIconImpl (own source file) - Creation/Destruction and setting of PointerIcon happens on EDT - DisplayImpl.shutdownAll() and Display.destroy() calls destroyAllPointerIconFromList - WindowDriver.setPointerIconImpl: Validates PointerIconImpl (i.e. re-creates if required) - Fix 'initial' window.setPointerIcon(..) before createNative(..), tested w/ TestGearsES2NEWT - OSX Native Code: - Move mouse and pointer-state handling from NewtMacWindow -> NewtView class to retain states (pointer handle, pointer visibility, etc) when reparenting. Reparenting will move an exisiting NewtView into a new NewtMacWindow. - Enable all mouse move events: - NewtView::mouseEnter [nsWin makeFirstResponder: nsView]; - NewtView::mouseExited if( !mouseConfined ) { [nsView resignFirstResponder]; } - NewtView::mouseMoved issued [myCurser set] if required, fixing OSX issue not updating NSCursor properly. - MacWindow: - Test NewtMacWindow, NewtView and NSCursor handles before usage - Fix DBG_PRINT(..) warnings --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 4 +- src/newt/classes/com/jogamp/newt/Display.java | 67 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 91 +- src/newt/classes/jogamp/newt/PointerIconImpl.java | 126 ++ src/newt/classes/jogamp/newt/WindowImpl.java | 9 +- .../jogamp/newt/driver/macosx/DisplayDriver.java | 11 +- .../jogamp/newt/driver/macosx/WindowDriver.java | 34 +- .../jogamp/newt/driver/windows/DisplayDriver.java | 11 +- .../jogamp/newt/driver/windows/WindowDriver.java | 4 +- .../jogamp/newt/driver/x11/DisplayDriver.java | 22 +- .../jogamp/newt/driver/x11/WindowDriver.java | 14 +- src/newt/native/MacWindow.m | 113 +- src/newt/native/NewtMacWindow.h | 86 +- src/newt/native/NewtMacWindow.m | 1237 ++++++++++---------- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 28 +- .../parenting/NewtAWTReparentingKeyAdapter.java | 53 +- 17 files changed, 1106 insertions(+), 808 deletions(-) create mode 100644 src/newt/classes/jogamp/newt/PointerIconImpl.java (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index d95b0025f..1158abdbb 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,14 +6,14 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4c084d705..db852ce42 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -323,9 +323,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index cf1099c85..8d1445f80 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -66,16 +66,60 @@ public abstract class Display { /** * Native PointerIcon handle. *

                      - * Instances can be created via {@link Display#createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int)} - * and released via {@link Display#destroyPointerIcon(PointerIcon)}. + * Instances can be created via {@link Display}'s {@link Display#createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int) createPointerIcon(..)}. + *

                      + *

                      + * Instance is {@link #destroy()}'ed automatically if it's {@link #getDisplay() associated Display} is destroyed. + *

                      + *

                      + * Instance can be re-validated after destruction via {@link #validate()}. + *

                      + *

                      + * {@link PointerIcon} may be {@link #destroy() destroyed} manually after use, + * i.e. when no {@link Window} {@link Window#setPointerIcon(PointerIcon) uses them} anymore. *

                      *

                      * PointerIcons can be used via {@link Window#setPointerIcon(PointerIcon)}. *

                      */ public static interface PointerIcon { + /** + * @return the associated Display + */ + Display getDisplay(); + + /** + * @return the single {@link IOUtil.ClassResources}. + */ + IOUtil.ClassResources getResource(); + + /** + * Returns true if valid, otherwise false. + *

                      + * A PointerIcon instance becomes invalid if it's {@link #getDisplay() associated Display} is destroyed. + *

                      + */ + boolean isValid(); + + /** + * Returns true if instance {@link #isValid()} or validation was successful, otherwise false. + *

                      + * Validation, i.e. recreation, is required if instance became invalid, see {@link #isValid()}. + *

                      + */ + boolean validate(); + + /** + * Destroys this instance. + *

                      + * Will be called automatically if it's {@link #getDisplay() associated Display} is destroyed. + *

                      + */ + void destroy(); + /** Returns the size, i.e. width and height. */ DimensionImmutable getSize(); + /** Returns the hotspot. */ PointImmutable getHotspot(); @@ -84,28 +128,23 @@ public abstract class Display { } /** - * Returns the created {@link PointerIcon} or null if not implemented on platform. + * Returns the newly created {@link PointerIcon} or null if not implemented on platform. + *

                      + * See {@link PointerIcon} for lifecycle semantics. + *

                      * - * @param pngResource PNG resource + * @param pngResource single PNG resource, only the first entry of {@link IOUtil.ClassResources#resourcePaths} is used. * @param hotX pointer hotspot x-coord, origin is upper-left corner * @param hotY pointer hotspot y-coord, origin is upper-left corner + * @throws IllegalStateException if this Display instance is not {@link #isNativeValid() valid yet}. * @throws MalformedURLException * @throws InterruptedException * @throws IOException * * @see PointerIcon - * @see #destroyPointerIcon(PointerIcon) * @see Window#setPointerIcon(PointerIcon) */ - - public abstract PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException; - - /** - * @param pi - * - * @see #createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int) - */ - public abstract void destroyPointerIcon(PointerIcon pi); + public abstract PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws IllegalStateException, MalformedURLException, InterruptedException, IOException; /** * Manual trigger the native creation, if it is not done yet.
                      diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index dc3705daa..346c03b15 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -51,8 +51,6 @@ import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.PointImmutable; public abstract class DisplayImpl extends Display { private static int serialno = 1; @@ -68,49 +66,19 @@ public abstract class DisplayImpl extends Display { }); } - public static class PointerIconImpl implements PointerIcon { - public final long handle; - private final DimensionImmutable size; - private final PointImmutable hotspot; - public PointerIconImpl(final long handle, final DimensionImmutable size, final PointImmutable hotspot) { - this.handle=handle; - this.size = size; - this.hotspot = hotspot; - } - @Override - public final DimensionImmutable getSize() { - return size; - } - @Override - public final PointImmutable getHotspot() { - return hotspot; - } - @Override - public final String toString() { - return "PointerIcon[0x"+Long.toHexString(handle)+", "+size+", "+hotspot+"]"; - } - } - - private void addPointerIconToList(final PointerIcon pi) { - synchronized(pointerIconList) { - pointerIconList.add(pi); - } - } - private void delPointerIconFromList(final PointerIcon pi) { - synchronized(pointerIconList) { - pointerIconList.remove(pi); - } - } - private final ArrayList pointerIconList = new ArrayList(); + final ArrayList pointerIconList = new ArrayList(); /** Executed from EDT! */ private void destroyAllPointerIconFromList(final long dpy) { synchronized(pointerIconList) { - for( int i=0; i < pointerIconList.size(); i++ ) { - final PointerIcon item = pointerIconList.get(i); - if( null != item ) { - // destroy! - destroyPointerIconImpl(dpy, item); + final int count = pointerIconList.size(); + for( int i=0; i < count; i++ ) { + final PointerIconImpl item = pointerIconList.get(i); + if(DEBUG) { + System.err.println("destroyAllPointerIconFromList: dpy "+toHexString(dpy)+", # "+i+"/"+count+": "+item+" @ "+getThreadName()); + } + if( null != item && item.isValid() ) { + item.destroyOnEDT(dpy); } } pointerIconList.clear(); @@ -119,31 +87,37 @@ public abstract class DisplayImpl extends Display { @Override public final PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { - final PointerIcon res = createPointerIconImpl(pngResource, hotX, hotY); - addPointerIconToList(res); - return res; - } - protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { - return null; + return createPointerIcon(false /* isTemp */, pngResource, hotX, hotY); } - - @Override - public final void destroyPointerIcon(final PointerIcon pi) { - delPointerIconFromList(pi); - runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - @Override - public Object run(long dpy) { + PointerIcon createPointerIcon(final boolean isTemp, final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + if( !isNativeValid() ) { + throw new IllegalStateException("Display.createPointerIcon(1): Display invalid "+this); + } + final PointerIconImpl[] res = { null }; + runOnEDTIfAvail(true, new Runnable() { + public void run() { try { - destroyPointerIconImpl(dpy, pi); + if( !DisplayImpl.this.isNativeValid() ) { + throw new IllegalStateException("Display.createPointerIcon(2): Display invalid "+DisplayImpl.this); + } + res[0] = createPointerIconImpl(pngResource, hotX, hotY); } catch (Exception e) { e.printStackTrace(); } - return null; + } } ); + if( !isTemp ) { + synchronized(pointerIconList) { + pointerIconList.add(res[0]); } - }); + } + return res[0]; + } + /** Executed from EDT! */ + protected PointerIconImpl createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + return null; } /** Executed from EDT! */ - protected void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { } + protected void destroyPointerIconImpl(final long displayHandle, long piHandle) { } /** Ensure static init has been run. */ /* pp */static void initSingleton() { } @@ -399,6 +373,7 @@ public abstract class DisplayImpl extends Display { @Override public void run() { if ( null != d.getGraphicsDevice() ) { + d.destroyAllPointerIconFromList(f_aDevice.getHandle()); d.closeNativeImpl(f_aDevice); } } diff --git a/src/newt/classes/jogamp/newt/PointerIconImpl.java b/src/newt/classes/jogamp/newt/PointerIconImpl.java new file mode 100644 index 000000000..e2388be67 --- /dev/null +++ b/src/newt/classes/jogamp/newt/PointerIconImpl.java @@ -0,0 +1,126 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt; + +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.PointImmutable; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.common.util.IOUtil.ClassResources; +import com.jogamp.newt.Display; +import com.jogamp.newt.Display.PointerIcon; + +public class PointerIconImpl implements PointerIcon { + private final DisplayImpl display; + private final IOUtil.ClassResources resource; + private final DimensionImmutable size; + private final PointImmutable hotspot; + private long handle; + public PointerIconImpl(DisplayImpl display, ClassResources resource, final DimensionImmutable size, final PointImmutable hotspot, final long handle) { + this.display = display; + this.resource = resource; + this.size = size; + this.hotspot = hotspot; + this.handle=handle; + } + public synchronized final long getHandle() { return handle; } + public synchronized final long validatedHandle() { + synchronized(display.pointerIconList) { + if( !display.pointerIconList.contains(this) ) { + display.pointerIconList.add(this); + } + } + if( 0 == handle ) { + try { + final PointerIconImpl temp = (PointerIconImpl) display.createPointerIcon(true /* isTemp */, resource, hotspot.getX(), hotspot.getY()); + handle = temp.handle; + return handle; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } else { + return handle; + } + } + @Override + public final Display getDisplay() { return display; } + @Override + public final IOUtil.ClassResources getResource() { return resource; } + @Override + public synchronized final boolean isValid() { return 0 != handle; } + @Override + public synchronized final boolean validate() { + if( 0 == handle ) { + return 0 != validatedHandle(); + } + return true; + } + + @Override + public synchronized void destroy() { + if(DisplayImpl.DEBUG) { + System.err.println("PointerIcon.destroy: "+this+", "+display+", "+DisplayImpl.getThreadName()); + } + if( 0 != handle ) { + synchronized(display.pointerIconList) { + display.pointerIconList.remove(this); + } + display.runOnEDTIfAvail(false, new Runnable() { + public void run() { + if( display.isNativeValid() ) { + destroyOnEDT(display.getHandle()); + } + } } ); + } + } + + /** No checks, assume execution on EDT */ + synchronized void destroyOnEDT(final long dpy) { + final long h = handle; + handle = 0; + try { + display.destroyPointerIconImpl(dpy, h); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public final DimensionImmutable getSize() { + return size; + } + @Override + public final PointImmutable getHotspot() { + return hotspot; + } + @Override + public final String toString() { + return "PointerIcon["+DisplayImpl.toHexString(super.hashCode())+", "+display.getFQName()+", "+resource.resourcePaths[0]+", 0x"+Long.toHexString(handle)+", "+size+", "+hotspot+"]"; + } +} \ No newline at end of file diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index d078caa3b..8d9fb8d7e 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -84,7 +84,6 @@ import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; import jogamp.nativewindow.SurfaceUpdatedHelper; -import jogamp.newt.DisplayImpl.PointerIconImpl; public abstract class WindowImpl implements Window, NEWTEventConsumer { @@ -440,7 +439,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer screen.addMonitorModeListener(monitorModeListenerImpl); setTitleImpl(title); if( null != pointerIcon ) { - setPointerIcon(pointerIcon); + setPointerIconImpl((PointerIconImpl)pointerIcon); } setPointerVisibleImpl(pointerVisible); confinePointerImpl(pointerConfined); @@ -1689,9 +1688,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final void setPointerIcon(final PointerIcon pi) { if( this.pointerIcon != pi ) { - setPointerIcon(pointerIcon); if( isNativeValid() ) { - setPointerIconImpl((PointerIconImpl)pi); + runOnEDTIfAvail(true, new Runnable() { + public void run() { + setPointerIconImpl((PointerIconImpl)pi); + } } ); } this.pointerIcon = pi; } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index f0f0a955a..30583c48c 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -50,6 +50,7 @@ import com.jogamp.newt.NewtFactory; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; +import jogamp.newt.PointerIconImpl; import jogamp.newt.driver.PNGIcon; public class DisplayDriver extends DisplayImpl { @@ -112,21 +113,21 @@ public class DisplayDriver extends DisplayImpl { } @Override - protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + protected PointerIconImpl createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { if( PNGIcon.isAvailable() ) { final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; if( null != pngResource && 0 < pngResource.resourceCount() ) { - return new PointerIconImpl( createPointerIcon0(data, width[0], height[0], hotX, hotY), - new Dimension(width[0], height[0]), new Point(hotX, hotY)); final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size); + return new PointerIconImpl( this, pngResource, new Dimension(width[0], height[0]), + new Point(hotX, hotY), createPointerIcon0(data, width[0], height[0], hotX, hotY)); } } return null; } @Override - protected final void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { - destroyPointerIcon0(((PointerIconImpl)pi).handle); + protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) { + destroyPointerIcon0(piHandle); } public static void runNSApplication() { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index a55fa915a..6f3c95570 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -45,8 +45,8 @@ import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; import jogamp.nativewindow.macosx.OSXUtil; +import jogamp.newt.PointerIconImpl; import jogamp.newt.WindowImpl; -import jogamp.newt.DisplayImpl.PointerIconImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; @@ -394,17 +394,29 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected void setPointerIconImpl(final PointerIconImpl pi) { - OSXUtil.RunOnMainThread(false, new Runnable() { - @Override - public void run() { - setPointerIcon0(getWindowHandle(), null != pi ? pi.handle : 0); - } } ); + if( !isOffscreenInstance ) { + final long piHandle = null != pi ? pi.validatedHandle() : 0; + OSXUtil.RunOnMainThread(true, new Runnable() { // waitUntildone due to PointerIconImpl's Lifecycle ! + @Override + public void run() { + if( !setPointerIcon0(getWindowHandle(), piHandle) ) { + throw new RuntimeException("Failed: "+pi+", "+WindowDriver.this); + } + } } ); + } // else may need offscreen solution ? FIXME } @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { if( !isOffscreenInstance ) { - return setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible); + OSXUtil.RunOnMainThread(false, new Runnable() { + @Override + public void run() { + if( !setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible) ) { + throw new RuntimeException("Failed"); + } + } } ); + return true; // setPointerVisible0 always returns true .. } // else may need offscreen solution ? FIXME return false; } @@ -420,7 +432,9 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected void warpPointerImpl(final int x, final int y) { if( !isOffscreenInstance ) { - warpPointer0(getWindowHandle(), x, y); + if( !warpPointer0(getWindowHandle(), x, y) ) { + throw new RuntimeException("Failed"); + } } // else may need offscreen solution ? FIXME } @@ -575,10 +589,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl /** Must be called on Main-Thread */ private native void setAlwaysOnTop0(long window, boolean atop); private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y); + private static native boolean setPointerIcon0(long windowHandle, long handle); private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); private static native boolean confinePointer0(long windowHandle, boolean confine); - private static native void warpPointer0(long windowHandle, int x, int y); - private static native void setPointerIcon0(long windowHandle, long handle); + private static native boolean warpPointer0(long windowHandle, int x, int y); // Window styles private static final int NSBorderlessWindowMask = 0; diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index 39b2efd15..1e9c78a5d 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -43,6 +43,7 @@ import jogamp.nativewindow.windows.RegisteredClass; import jogamp.nativewindow.windows.RegisteredClassFactory; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; +import jogamp.newt.PointerIconImpl; import jogamp.newt.driver.PNGIcon; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -104,21 +105,21 @@ public class DisplayDriver extends DisplayImpl { } @Override - protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + protected PointerIconImpl createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { if( PNGIcon.isAvailable() ) { final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; if( null != pngResource && 0 < pngResource.resourceCount() ) { - return new PointerIconImpl( createBGRA8888Icon0(data, width[0], height[0], true, hotX, hotY), - new Dimension(width[0], height[0]), new Point(hotX, hotY)); final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size); + return new PointerIconImpl( this, pngResource, new Dimension(width[0], height[0]), + new Point(hotX, hotY), createBGRA8888Icon0(data, width[0], height[0], true, hotX, hotY)); } } return null; } @Override - protected final void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { - destroyIcon0(((PointerIconImpl)pi).handle); + protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) { + destroyIcon0(piHandle); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 764d4fdab..c8d7c65cc 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -38,8 +38,8 @@ import java.nio.ByteBuffer; import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.GDIUtil; +import jogamp.newt.PointerIconImpl; import jogamp.newt.WindowImpl; -import jogamp.newt.DisplayImpl.PointerIconImpl; import jogamp.newt.driver.PNGIcon; import javax.media.nativewindow.AbstractGraphicsConfiguration; @@ -252,7 +252,7 @@ public class WindowDriver extends WindowImpl { @Override protected void setPointerIconImpl(final PointerIconImpl pi) { - setPointerIcon0(getWindowHandle(), null != pi ? pi.handle : 0); + setPointerIcon0(getWindowHandle(), null != pi ? pi.validatedHandle() : 0); } @Override diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index c377e7f85..150337df4 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -51,6 +51,7 @@ import com.jogamp.nativewindow.x11.X11GraphicsDevice; import jogamp.nativewindow.x11.X11Util; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; +import jogamp.newt.PointerIconImpl; import jogamp.newt.driver.PNGIcon; public class DisplayDriver extends DisplayImpl { @@ -131,32 +132,21 @@ public class DisplayDriver extends DisplayImpl { protected Boolean isXineramaEnabled() { return isNativeValid() ? Boolean.valueOf(((X11GraphicsDevice)aDevice).isXineramaEnabled()) : null; } @Override - protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + protected PointerIconImpl createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { if( PNGIcon.isAvailable() ) { final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; if( null != pngResource && 0 < pngResource.resourceCount() ) { final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, false /* toBGRA */, width, height, data_size); - final long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - @Override - public Long run(long dpy) { - long h = 0; - try { - h = createPointerIcon0(dpy, data, width[0], height[0], hotX, hotY); - } catch (Exception e) { - e.printStackTrace(); - } - return Long.valueOf(h); - } - }).longValue(); - return new PointerIconImpl(handle, new Dimension(width[0], height[0]), new Point(hotX, hotY)); + final long handle = createPointerIcon0(getHandle(), data, width[0], height[0], hotX, hotY); + return new PointerIconImpl(DisplayDriver.this, pngResource, new Dimension(width[0], height[0]), new Point(hotX, hotY), handle); } } return null; } @Override - protected final void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { - destroyPointerIcon0(displayHandle, ((PointerIconImpl)pi).handle); + protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) { + destroyPointerIcon0(displayHandle, piHandle); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 0ea2c5358..ad1744f2e 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -40,7 +40,7 @@ import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; import jogamp.newt.DisplayImpl; import jogamp.newt.DisplayImpl.DisplayRunnable; -import jogamp.newt.DisplayImpl.PointerIconImpl; +import jogamp.newt.PointerIconImpl; import jogamp.newt.WindowImpl; import jogamp.newt.driver.PNGIcon; @@ -279,7 +279,7 @@ public class WindowDriver extends WindowImpl { @Override public Object run(long dpy) { try { - setPointerIcon0(dpy, getWindowHandle(), null != pi ? pi.handle : 0); + setPointerIcon0(dpy, getWindowHandle(), null != pi ? pi.validatedHandle() : 0); } catch (Exception e) { e.printStackTrace(); } @@ -293,7 +293,15 @@ public class WindowDriver extends WindowImpl { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { @Override public Boolean run(long dpy) { - return Boolean.valueOf(setPointerVisible0(dpy, getWindowHandle(), pointerVisible)); + final PointerIconImpl pi = (PointerIconImpl)getPointerIcon(); + final boolean res; + if( pointerVisible && null != pi ) { + setPointerIcon0(dpy, getWindowHandle(), null != pi ? pi.validatedHandle() : 0); + res = true; + } else { + res = setPointerVisible0(dpy, getWindowHandle(), pointerVisible); + } + return Boolean.valueOf(res); } }).booleanValue(); } diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 1be3a6ed5..eb5913706 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -347,30 +347,14 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_createPoint JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_destroyPointerIcon0 (JNIEnv *env, jobject unused, jlong handle) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSCursor * c = (NSCursor*) (intptr_t) handle ; - if( NULL != c ) { - if ( NO == [c isKindOfClass:[NSCursor class]] ) { - DBG_PRINT( "destroyPointerIcon0 NSCursor %p - is of invalid type\n", c); - } else { - DBG_PRINT( "destroyPointerIcon0 %p\n", c); - [c release]; - } + if( NULL != c && NO == [c isKindOfClass:[NSCursor class]] ) { + DBG_PRINT( "Not a NSCursor %p\n", c); + return; } - [pool release]; -} - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerIcon0 - (JNIEnv *env, jobject unused, jlong window, jlong handle) -{ + DBG_PRINT( "destroyPointerIcon0 %p\n", c); NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NewtMacWindow *mWin = (NewtMacWindow*) (intptr_t) window; - NSCursor * c = (NSCursor*) (intptr_t) handle ; - if ( NULL != c && NO == [c isKindOfClass:[NSCursor class]] ) { - DBG_PRINT( "setPointerIcon0 NSCursor %p - is of invalid type (1)\n", c); - } else { - [mWin setPointerIcon: c]; - } + [c release]; [pool release]; } @@ -717,7 +701,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createView0 NSRect rectView = NSMakeRect(0, 0, w, h); NewtView *myView = [[NewtView alloc] initWithFrame: rectView] ; - DBG_PRINT( "createView0.X.%d - new view: %p\n", myView); + DBG_PRINT( "createView0.X - new view: %p\n", myView); [pool release]; @@ -738,7 +722,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtView* myView = (NewtView*) (intptr_t) jview ; - DBG_PRINT( "createWindow0 - %p (this), %d/%d %dx%d, fs %d, style %X, buffType %X, screenidx %d, view %p (START)\n", + DBG_PRINT( "createWindow0 - %p (this), %d/%d %dx%d, fs %d, style %X, buffType %X, view %p (START)\n", (void*)(intptr_t)jthis, (int)x, (int)y, (int)w, (int)h, (int)fullscreen, (int)styleMask, (int)bufferingType, myView); (void)myView; @@ -865,6 +849,7 @@ NS_ENDHANDLER // Set the content view changeContentView(env, jthis, parentView, myWindow, myView, NO); + [myWindow setInitialFirstResponder: myView]; DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n", dbgIdx++, myWindow, myView, [myWindow isVisible]); @@ -965,7 +950,6 @@ NS_ENDHANDLER JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 (JNIEnv *env, jobject unused, jlong window) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window); if( NULL == mWin ) { DBG_PRINT( "windowClose.0 - NULL NEWT win - abort\n"); @@ -979,6 +963,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 DBG_PRINT( "windowClose.0 - Not a NEWT win - abort\n"); return; } + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtView* mView = (NewtView *)[mWin contentView]; BOOL fullscreen = mWin->isFullscreenWindow; BOOL destroyNotifySent, isNSView, isNewtView; @@ -1093,6 +1078,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_requestFocus0 #endif DBG_PRINT( "requestFocus - window: %p, force %d, hasFocus %d (START)\n", mWin, force, hasFocus); + [mWin setAcceptsMouseMovedEvents: YES]; [mWin makeFirstResponder: nil]; [mWin orderFrontRegardless]; [mWin makeKeyWindow]; @@ -1331,18 +1317,39 @@ JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_getLocatio (JNIEnv *env, jclass unused, jlong win, jint src_x, jint src_y) { NSObject *nsObj = (NSObject*) ((intptr_t) win); - NewtMacWindow * mWin = NULL; - - if( [nsObj isKindOfClass:[NewtMacWindow class]] ) { - mWin = (NewtMacWindow*) nsObj; - } else { - NewtCommon_throwNewRuntimeException(env, "not NewtMacWindow %p\n", nsObj); + NewtMacWindow * mWin = (NewtMacWindow*) nsObj; + if( ![mWin isKindOfClass:[NewtMacWindow class]] ) { + DBG_PRINT("Not a NewtMacWindow %p\n", nsObj); + return NULL; } - NSPoint p0 = [mWin getLocationOnScreen: NSMakePoint(src_x, src_y)]; return (*env)->NewObject(env, pointClz, pointCstr, (jint)p0.x, (jint)p0.y); } +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerIcon0 + (JNIEnv *env, jobject unused, jlong window, jlong handle) +{ + NSCursor *c = (NSCursor*) (intptr_t) handle ; + if ( NULL != c && NO == [c isKindOfClass:[NSCursor class]] ) { + DBG_PRINT("Not a NSCursor %p\n", c); + return JNI_FALSE; + } + NewtMacWindow *mWin = (NewtMacWindow*) (intptr_t) window; + if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) { + DBG_PRINT("Not a NewtMacWindow %p\n", mWin); + return JNI_FALSE; + } + NewtView* nView = (NewtView *) [mWin contentView]; + if( ! [nView isKindOfClass:[NewtView class]] ) { + DBG_PRINT("Not a NewtView %p\n", nView); + return JNI_FALSE; + } + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + [nView setPointerIcon: c]; + [pool release]; + return JNI_TRUE; +} + /* * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: setPointerVisible0 @@ -1351,10 +1358,19 @@ JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_getLocatio JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerVisible0 (JNIEnv *env, jclass clazz, jlong window, jboolean hasFocus, jboolean mouseVisible) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); - [mWin setMouseVisible: ( JNI_TRUE == mouseVisible ) ? YES : NO - hasFocus: ( JNI_TRUE == hasFocus ) ? YES : NO]; + if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) { + DBG_PRINT("Not a NewtMacWindow %p\n", mWin); + return JNI_FALSE; + } + NewtView* nView = (NewtView *) [mWin contentView]; + if( ! [nView isKindOfClass:[NewtView class]] ) { + DBG_PRINT("Not a NewtView %p\n", nView); + return JNI_FALSE; + } + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + [nView setMouseVisible: ( JNI_TRUE == mouseVisible ) ? YES : NO + hasFocus: ( JNI_TRUE == hasFocus ) ? YES : NO]; [pool release]; return JNI_TRUE; } @@ -1367,9 +1383,18 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointe JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_confinePointer0 (JNIEnv *env, jclass clazz, jlong window, jboolean confine) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); - [mWin setMouseConfined: ( JNI_TRUE == confine ) ? YES : NO]; + if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) { + DBG_PRINT("Not a NewtMacWindow %p\n", mWin); + return JNI_FALSE; + } + NewtView* nView = (NewtView *) [mWin contentView]; + if( ! [nView isKindOfClass:[NewtView class]] ) { + DBG_PRINT("Not a NewtView %p\n", nView); + return JNI_FALSE; + } + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + [nView setMouseConfined: ( JNI_TRUE == confine ) ? YES : NO]; [pool release]; return JNI_TRUE; } @@ -1379,12 +1404,22 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_confinePo * Method: warpPointer0 * Signature: (JJII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_warpPointer0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_warpPointer0 (JNIEnv *env, jclass clazz, jlong window, jint x, jint y) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); - [mWin setMousePosition: [mWin newtRelClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y)]]; + if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) { + DBG_PRINT("Not a NewtMacWindow %p\n", mWin); + return JNI_FALSE; + } + NewtView* nView = (NewtView *) [mWin contentView]; + if( ! [nView isKindOfClass:[NewtView class]] ) { + DBG_PRINT("Not a NewtView %p\n", nView); + return JNI_FALSE; + } + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + [nView setMousePosition: [mWin newtRelClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y)]]; [pool release]; + return JNI_TRUE; } diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index 2728c2201..daf75bec7 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -63,6 +63,14 @@ volatile NSTrackingRectTag ptrTrackingTag; NSRect ptrRect; + NSCursor * myCursor; + BOOL modsDown[4]; // shift, ctrl, alt/option, win/command + + BOOL mouseConfined; + BOOL mouseInside; + BOOL mouseVisible; + BOOL cursorIsHidden; + NSPoint lastInsideMousePosition; } - (id)initWithFrame:(NSRect)frameRect; @@ -83,9 +91,6 @@ - (void) setJavaWindowObject: (jobject) javaWindowObj; - (jobject) getJavaWindowObject; -- (void) rightMouseDown: (NSEvent*) theEvent; -- (void) resetCursorRects; - - (void) setDestroyNotifySent: (BOOL) v; - (BOOL) getDestroyNotifySent; @@ -99,6 +104,41 @@ - (void) viewDidHide; - (void) viewDidUnhide; - (BOOL) acceptsFirstResponder; +- (BOOL) becomeFirstResponder; +- (BOOL) resignFirstResponder; + +- (void) removeCursorRects; +- (void) addCursorRects; +- (void) removeMyCursor; +- (void) resetCursorRects; +- (void) setPointerIcon: (NSCursor*)c; +- (void) mouseEntered: (NSEvent*) theEvent; +- (void) mouseExited: (NSEvent*) theEvent; +- (BOOL) updateMouseInside; +- (void) cursorHide:(BOOL)v enter:(int)enterState; +- (void) setPointerIcon:(NSCursor*)c; +- (void) setMouseVisible:(BOOL)v hasFocus:(BOOL)focus; +- (BOOL) isMouseVisible; +- (void) setMouseConfined:(BOOL)v; +- (void) setMousePosition:(NSPoint)p; +- (void) mouseMoved: (NSEvent*) theEvent; +- (void) scrollWheel: (NSEvent*) theEvent; +- (void) mouseDown: (NSEvent*) theEvent; +- (void) mouseDragged: (NSEvent*) theEvent; +- (void) mouseUp: (NSEvent*) theEvent; +- (void) rightMouseDown: (NSEvent*) theEvent; +- (void) rightMouseDragged: (NSEvent*) theEvent; +- (void) rightMouseUp: (NSEvent*) theEvent; +- (void) otherMouseDown: (NSEvent*) theEvent; +- (void) otherMouseDragged: (NSEvent*) theEvent; +- (void) otherMouseUp: (NSEvent*) theEvent; +- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType; +- (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p; + +- (void) handleFlagsChanged:(NSUInteger) mods; +- (void) handleFlagsChanged:(int) keyMask keyIndex: (int) keyIdx keyCode: (int) keyCode modifiers: (NSUInteger) mods; +- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType; +- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType; @end @@ -108,14 +148,7 @@ @interface NewtMacWindow : NSWindow #endif { - BOOL mouseConfined; - BOOL mouseVisible; - BOOL mouseInside; - BOOL cursorIsHidden; - NSCursor * customCursor; BOOL realized; - BOOL modsDown[4]; // shift, ctrl, alt/option, win/command - NSPoint lastInsideMousePosition; @public BOOL hasPresentationSwitch; NSUInteger defaultPresentationOptions; @@ -147,20 +180,14 @@ - (NSPoint) newtRelClientTLWinPos2AbsBLScreenPos: (NSPoint) p; - (NSSize) newtClientSize2TLSize: (NSSize) nsz; - (NSPoint) getLocationOnScreen: (NSPoint) p; -- (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p; -- (BOOL) isMouseInside; -- (void) cursorHide:(BOOL)v enter:(int)enterState; -- (void) setPointerIcon:(NSCursor*)c; -- (void) setMouseVisible:(BOOL)v hasFocus:(BOOL)focus; -- (void) setMouseConfined:(BOOL)v; -- (void) setMousePosition:(NSPoint)p; - -- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType; -- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType; -- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType; - (void) focusChanged: (BOOL) gained; +- (void) keyDown: (NSEvent*) theEvent; +- (void) keyUp: (NSEvent*) theEvent; +- (void) flagsChanged: (NSEvent *) theEvent; +- (BOOL) acceptsMouseMovedEvents; +- (BOOL) acceptsFirstResponder; - (BOOL) becomeFirstResponder; - (BOOL) resignFirstResponder; - (BOOL) canBecomeKeyWindow; @@ -168,22 +195,7 @@ - (void) resignKeyWindow; - (void) windowDidBecomeKey: (NSNotification *) notification; - (void) windowDidResignKey: (NSNotification *) notification; -- (void) keyDown: (NSEvent*) theEvent; -- (void) keyUp: (NSEvent*) theEvent; -- (void) handleFlagsChanged:(int) keyMask keyIndex: (int) keyIdx keyCode: (int) keyCode modifiers: (NSUInteger) mods; -- (void) flagsChanged: (NSEvent *) theEvent; -- (void) mouseEntered: (NSEvent*) theEvent; -- (void) mouseExited: (NSEvent*) theEvent; -- (void) mouseMoved: (NSEvent*) theEvent; -- (void) scrollWheel: (NSEvent*) theEvent; -- (void) mouseDown: (NSEvent*) theEvent; -- (void) mouseDragged: (NSEvent*) theEvent; -- (void) mouseUp: (NSEvent*) theEvent; -- (void) rightMouseDown: (NSEvent*) theEvent; -- (void) rightMouseDragged: (NSEvent*) theEvent; -- (void) rightMouseUp: (NSEvent*) theEvent; -- (void) otherMouseDown: (NSEvent*) theEvent; -- (void) otherMouseUp: (NSEvent*) theEvent; + - (void) windowDidResize: (NSNotification*) notification; - (void) windowDidMove: (NSNotification*) notification; - (BOOL) windowClosingImpl: (BOOL) force; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 96965b67a..5ccd9c658 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -86,6 +86,88 @@ static jfloat GetDelta(NSEvent *event, jint javaMods[]) { return (jfloat) delta; } +#define kVK_Shift 0x38 +#define kVK_Option 0x3A +#define kVK_Control 0x3B +#define kVK_Command 0x37 + +static jint mods2JavaMods(NSUInteger mods) +{ + int javaMods = 0; + if (mods & NSShiftKeyMask) { + javaMods |= EVENT_SHIFT_MASK; + } + if (mods & NSControlKeyMask) { + javaMods |= EVENT_CTRL_MASK; + } + if (mods & NSCommandKeyMask) { + javaMods |= EVENT_META_MASK; + } + if (mods & NSAlternateKeyMask) { + javaMods |= EVENT_ALT_MASK; + } + return javaMods; +} + +static CFStringRef CKCH_CreateStringForKey(CGKeyCode keyCode, const UCKeyboardLayout *keyboardLayout) { + UInt32 keysDown = 0; + UniChar chars[4]; + UniCharCount realLength; + + UCKeyTranslate(keyboardLayout, keyCode, + kUCKeyActionDisplay, 0, + LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, + &keysDown, sizeof(chars) / sizeof(chars[0]), &realLength, chars); + + return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1); +} + +static CFMutableDictionaryRef CKCH_CreateCodeToCharDict(TISInputSourceRef keyboard) { + CFDataRef layoutData = (CFDataRef) TISGetInputSourceProperty(keyboard, kTISPropertyUnicodeKeyLayoutData); + const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData); + + CFMutableDictionaryRef codeToCharDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 128, NULL, NULL); + if ( NULL != codeToCharDict ) { + intptr_t i; + for (i = 0; i < 128; ++i) { + CFStringRef string = CKCH_CreateStringForKey((CGKeyCode)i, keyboardLayout); + if( NULL != string ) { + CFIndex stringLen = CFStringGetLength (string); + if ( 0 < stringLen ) { + UniChar character = CFStringGetCharacterAtIndex(string, 0); + DBG_PRINT("CKCH: MAP 0x%X -> %c\n", (int)i, character); + CFDictionaryAddValue(codeToCharDict, (const void *)i, (const void *)(intptr_t)character); + } + CFRelease(string); + } + } + } + return codeToCharDict; +} + +static CFMutableDictionaryRef CKCH_USCodeToNNChar = NULL; + +static void CKCH_CreateDictionaries() { + TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + CKCH_USCodeToNNChar = CKCH_CreateCodeToCharDict(currentKeyboard); + CFRelease(currentKeyboard); +} + +static UniChar CKCH_CharForKeyCode(jshort keyCode) { + UniChar rChar = 0; + + if ( NULL != CKCH_USCodeToNNChar ) { + intptr_t code = (intptr_t) keyCode; + intptr_t character = 0; + + if ( CFDictionaryGetValueIfPresent(CKCH_USCodeToNNChar, (void *)code, (const void **)&character) ) { + rChar = (UniChar) character; + DBG_PRINT("CKCH: OK 0x%X -> 0x%X\n", (int)keyCode, (int)rChar); + } + } + return rChar; +} + static jmethodID enqueueMouseEventID = NULL; static jmethodID enqueueKeyEventID = NULL; static jmethodID requestFocusID = NULL; @@ -122,6 +204,16 @@ static jmethodID windowRepaintID = NULL; pthread_mutex_init(&softLockSync, &softLockSyncAttr); // recursive ptrTrackingTag = 0; + myCursor = NULL; + + modsDown[0] = NO; // shift + modsDown[1] = NO; // ctrl + modsDown[2] = NO; // alt + modsDown[3] = NO; // win + mouseConfined = NO; + mouseVisible = YES; + mouseInside = NO; + cursorIsHidden = NO; DBG_PRINT("NewtView::create: %p (refcnt %d)\n", res, (int)[res retainCount]); return res; @@ -144,10 +236,9 @@ static jmethodID windowRepaintID = NULL; if( 0 < softLockCount ) { NSLog(@"NewtView::dealloc: softLock still hold @ dealloc!\n"); } - if(0 != ptrTrackingTag) { - [self removeTrackingRect: ptrTrackingTag]; - ptrTrackingTag = 0; - } + [self removeCursorRects]; + [self removeMyCursor]; + pthread_mutex_destroy(&softLockSync); DBG_PRINT("NewtView::dealloc.X: %p\n", self); [super dealloc]; @@ -182,26 +273,6 @@ static jmethodID windowRepaintID = NULL; return javaWindowObject; } -- (void) rightMouseDown: (NSEvent*) theEvent -{ - NSResponder* next = [self nextResponder]; - if (next != nil) { - [next rightMouseDown: theEvent]; - } -} - -- (void) resetCursorRects -{ - [super resetCursorRects]; - - if(0 != ptrTrackingTag) { - [self removeTrackingRect: ptrTrackingTag]; - ptrTrackingTag = 0; - } - ptrRect = [self bounds]; - ptrTrackingTag = [self addTrackingRect: ptrRect owner: self userData: nil assumeInside: NO]; -} - - (void) setDestroyNotifySent: (BOOL) v { destroyNotifySent = v; @@ -337,141 +408,462 @@ static jmethodID windowRepaintID = NULL; return YES; } -@end - -static CFStringRef CKCH_CreateStringForKey(CGKeyCode keyCode, const UCKeyboardLayout *keyboardLayout) { - UInt32 keysDown = 0; - UniChar chars[4]; - UniCharCount realLength; - - UCKeyTranslate(keyboardLayout, keyCode, - kUCKeyActionDisplay, 0, - LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, - &keysDown, sizeof(chars) / sizeof(chars[0]), &realLength, chars); - - return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1); +- (BOOL) becomeFirstResponder +{ + DBG_PRINT( "*************** View.becomeFirstResponder\n"); + return [super becomeFirstResponder]; } -static CFMutableDictionaryRef CKCH_CreateCodeToCharDict(TISInputSourceRef keyboard) { - CFDataRef layoutData = (CFDataRef) TISGetInputSourceProperty(keyboard, kTISPropertyUnicodeKeyLayoutData); - const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData); +- (BOOL) resignFirstResponder +{ + DBG_PRINT( "*************** View.resignFirstResponder\n"); + return [super resignFirstResponder]; +} - CFMutableDictionaryRef codeToCharDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 128, NULL, NULL); - if ( NULL != codeToCharDict ) { - intptr_t i; - for (i = 0; i < 128; ++i) { - CFStringRef string = CKCH_CreateStringForKey((CGKeyCode)i, keyboardLayout); - if( NULL != string ) { - CFIndex stringLen = CFStringGetLength (string); - if ( 0 < stringLen ) { - UniChar character = CFStringGetCharacterAtIndex(string, 0); - DBG_PRINT("CKCH: MAP 0x%X -> %c\n", (int)i, character); - CFDictionaryAddValue(codeToCharDict, (const void *)i, (const void *)(intptr_t)character); - } - CFRelease(string); - } +- (void) removeCursorRects +{ + if(0 != ptrTrackingTag) { + if(NULL != myCursor) { + [self removeCursorRect: ptrRect cursor: myCursor]; } + [self removeTrackingRect: ptrTrackingTag]; + ptrTrackingTag = 0; } - return codeToCharDict; } -static CFMutableDictionaryRef CKCH_USCodeToNNChar = NULL; +- (void) addCursorRects +{ + ptrRect = [self bounds]; + if(NULL != myCursor) { + [self addCursorRect: ptrRect cursor: myCursor]; + } + ptrTrackingTag = [self addTrackingRect: ptrRect owner: self userData: nil assumeInside: NO]; +} -static void CKCH_CreateDictionaries() { - TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); - CKCH_USCodeToNNChar = CKCH_CreateCodeToCharDict(currentKeyboard); - CFRelease(currentKeyboard); +- (void) removeMyCursor +{ + if(NULL != myCursor) { + [myCursor release]; + myCursor = NULL; + } } -static UniChar CKCH_CharForKeyCode(jshort keyCode) { - UniChar rChar = 0; +- (void) resetCursorRects +{ + [super resetCursorRects]; - if ( NULL != CKCH_USCodeToNNChar ) { - intptr_t code = (intptr_t) keyCode; - intptr_t character = 0; + [self removeCursorRects]; + [self addCursorRects]; +} - if ( CFDictionaryGetValueIfPresent(CKCH_USCodeToNNChar, (void *)code, (const void **)&character) ) { - rChar = (UniChar) character; - DBG_PRINT("CKCH: OK 0x%X -> 0x%X\n", (int)keyCode, (int)rChar); +- (void) setPointerIcon: (NSCursor*)c +{ + DBG_PRINT( "setPointerIcon: %p -> %p, top %p, mouseInside %d\n", myCursor, c, [NSCursor currentCursor], (int)mouseInside); + if( c != myCursor ) { + [self removeCursorRects]; + [self removeMyCursor]; + myCursor = c; + if( NULL != myCursor ) { + [myCursor retain]; } } - return rChar; + NSWindow* nsWin = [self window]; + if( NULL != nsWin ) { + [nsWin invalidateCursorRectsForView: self]; + } } -@implementation NewtMacWindow - -+ (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz +- (void) mouseEntered: (NSEvent*) theEvent { - enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZSIIISF)V"); - enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZSISCC)V"); - sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); - visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); - insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); - positionChangedID = (*env)->GetMethodID(env, clazz, "screenPositionChanged", "(ZII)V"); - focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(ZZ)V"); - windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); - windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); - requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V"); - if (enqueueMouseEventID && enqueueKeyEventID && sizeChangedID && visibleChangedID && insetsChangedID && - positionChangedID && focusChangedID && windowDestroyNotifyID && requestFocusID && windowRepaintID) - { - CKCH_CreateDictionaries(); - return YES; + DBG_PRINT( "mouseEntered: confined %d, visible %d, PointerIcon %p, top %p\n", mouseConfined, mouseVisible, myCursor, [NSCursor currentCursor]); + mouseInside = YES; + [self cursorHide: !mouseVisible enter: 1]; + if(NO == mouseConfined) { + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_ENTERED]; + } + NSWindow* nsWin = [self window]; + if( NULL != nsWin ) { + [nsWin makeFirstResponder: self]; } - return NO; } -- (id) initWithContentRect: (NSRect) contentRect - styleMask: (NSUInteger) windowStyle - backing: (NSBackingStoreType) bufferingType - defer: (BOOL) deferCreation - isFullscreenWindow:(BOOL)isfs +- (void) mouseExited: (NSEvent*) theEvent { - id res = [super initWithContentRect: contentRect - styleMask: windowStyle - backing: bufferingType - defer: deferCreation]; - // OSX 10.6 - if ( [NSApp respondsToSelector:@selector(currentSystemPresentationOptions)] && - [NSApp respondsToSelector:@selector(setPresentationOptions:)] ) { - hasPresentationSwitch = YES; - defaultPresentationOptions = [NSApp currentSystemPresentationOptions]; - fullscreenPresentationOptions = - // NSApplicationPresentationDefault| - // NSApplicationPresentationAutoHideDock| - NSApplicationPresentationHideDock| - // NSApplicationPresentationAutoHideMenuBar| - NSApplicationPresentationHideMenuBar| - NSApplicationPresentationDisableAppleMenu| - // NSApplicationPresentationDisableProcessSwitching| - // NSApplicationPresentationDisableSessionTermination| - NSApplicationPresentationDisableHideApplication| - // NSApplicationPresentationDisableMenuBarTransparency| - // NSApplicationPresentationFullScreen| // OSX 10.7 - 0 ; + DBG_PRINT( "mouseExited: confined %d, visible %d, PointerIcon %p, top %p\n", mouseConfined, mouseVisible, myCursor, [NSCursor currentCursor]); + if(NO == mouseConfined) { + mouseInside = NO; + [self cursorHide: NO enter: -1]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_EXITED]; + [self resignFirstResponder]; } else { - hasPresentationSwitch = NO; - defaultPresentationOptions = 0; - fullscreenPresentationOptions = 0; + [self setMousePosition: lastInsideMousePosition]; } +} - isFullscreenWindow = isfs; - // Why is this necessary? Without it we don't get any of the - // delegate methods like resizing and window movement. - [self setDelegate: self]; - cachedInsets[0] = 0; // l - cachedInsets[1] = 0; // r - cachedInsets[2] = 0; // t - cachedInsets[3] = 0; // b - modsDown[0] = NO; // shift - modsDown[1] = NO; // ctrl - modsDown[2] = NO; // alt - modsDown[3] = NO; // win - mouseConfined = NO; - mouseVisible = YES; - mouseInside = NO; - cursorIsHidden = NO; - customCursor = NULL; +- (void) setMousePosition:(NSPoint)p +{ + NSWindow* nsWin = [self window]; + if( NULL != nsWin ) { + NSScreen* screen = [nsWin screen]; + NSRect screenRect = [screen frame]; + + CGPoint pt = { p.x, screenRect.size.height - p.y }; // y-flip (CG is top-left origin) + CGEventRef ev = CGEventCreateMouseEvent (NULL, kCGEventMouseMoved, pt, kCGMouseButtonLeft); + CGEventPost (kCGHIDEventTap, ev); + } +} + +- (BOOL) updateMouseInside +{ + NSRect viewFrame = [self frame]; + NSPoint l1 = [NSEvent mouseLocation]; + NSPoint l0 = [self screenPos2NewtClientWinPos: l1]; + mouseInside = viewFrame.origin.x <= l0.x && l0.x < (viewFrame.origin.x+viewFrame.size.width) && + viewFrame.origin.y <= l0.y && l0.y < (viewFrame.origin.y+viewFrame.size.height) ; + return mouseInside; +} + +- (void) setMouseVisible:(BOOL)v hasFocus:(BOOL)focus +{ + mouseVisible = v; + [self updateMouseInside]; + DBG_PRINT( "setMouseVisible: confined %d, visible %d (current: %d), mouseInside %d, hasFocus %d\n", + mouseConfined, mouseVisible, !cursorIsHidden, mouseInside, focus); + if(YES == focus && YES == mouseInside) { + [self cursorHide: !mouseVisible enter: 0]; + } +} +- (BOOL) isMouseVisible +{ + return mouseVisible; +} + +- (void) cursorHide:(BOOL)v enter:(int)enterState +{ + DBG_PRINT( "cursorHide: %d -> %d, enter %d; PointerIcon: %p, top %p\n", + cursorIsHidden, v, enterState, myCursor, [NSCursor currentCursor]); + if(v) { + if(!cursorIsHidden) { + [NSCursor hide]; + cursorIsHidden = YES; + } + } else { + if(cursorIsHidden) { + [NSCursor unhide]; + cursorIsHidden = NO; + } + } +} + +- (void) setMouseConfined:(BOOL)v +{ + mouseConfined = v; + DBG_PRINT( "setMouseConfined: confined %d, visible %d\n", mouseConfined, mouseVisible); +} + +- (void) mouseMoved: (NSEvent*) theEvent +{ + if( mouseInside ) { + NSCursor * currentCursor = [NSCursor currentCursor]; + BOOL setCursor = NULL != myCursor && NO == cursorIsHidden && currentCursor != myCursor; + DBG_PRINT( "mouseMoved.set: %d; mouseInside %d, CursorHidden %d, PointerIcon: %p, top %p\n", + setCursor, mouseInside, cursorIsHidden, myCursor, currentCursor); + if( setCursor ) { + // FIXME: Workaround missing NSCursor update for 'fast moving' pointer + [myCursor set]; + } + lastInsideMousePosition = [NSEvent mouseLocation]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; + } +} + +- (void) scrollWheel: (NSEvent*) theEvent +{ + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_WHEEL_MOVED]; +} + +- (void) mouseDown: (NSEvent*) theEvent +{ + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; +} + +- (void) mouseDragged: (NSEvent*) theEvent +{ + lastInsideMousePosition = [NSEvent mouseLocation]; + // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; +} + +- (void) mouseUp: (NSEvent*) theEvent +{ + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; +} + +- (void) rightMouseDown: (NSEvent*) theEvent +{ + NSResponder* next = [self nextResponder]; + if (next != nil) { + [next rightMouseDown: theEvent]; + } + // FIXME: ^^ OR [super rightMouseDown: theEvent] ? + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; +} + +- (void) rightMouseDragged: (NSEvent*) theEvent +{ + lastInsideMousePosition = [NSEvent mouseLocation]; + // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; +} + +- (void) rightMouseUp: (NSEvent*) theEvent +{ + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; +} + +- (void) otherMouseDown: (NSEvent*) theEvent +{ + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; +} + +- (void) otherMouseDragged: (NSEvent*) theEvent +{ + lastInsideMousePosition = [NSEvent mouseLocation]; + // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; +} + +- (void) otherMouseUp: (NSEvent*) theEvent +{ + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; +} + +- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType +{ + if (javaWindowObject == NULL) { + DBG_PRINT("sendMouseEvent: null javaWindowObject\n"); + return; + } + int shallBeDetached = 0; + JNIEnv* env; + if( NULL != jvmHandle ) { + env = NewtCommon_GetJNIEnv(jvmHandle, [self getJVMVersion], 1 /* asDaemon */, &shallBeDetached); + } else { + env = NULL; + } + if(NULL==env) { + DBG_PRINT("sendMouseEvent: JVM %p JNIEnv %p\n", jvmHandle, env); + return; + } + jint javaMods[] = { 0 } ; + javaMods[0] = mods2JavaMods([event modifierFlags]); + + // convert to 1-based button number (or use zero if no button is involved) + // TODO: detect mouse button when mouse wheel scrolled + jshort javaButtonNum = 0; + jfloat scrollDeltaY = 0.0f; + switch ([event type]) { + case NSScrollWheel: { + scrollDeltaY = GetDelta(event, javaMods); + javaButtonNum = 1; + break; + } + case NSLeftMouseDown: + case NSLeftMouseUp: + case NSLeftMouseDragged: + javaButtonNum = 1; + break; + case NSRightMouseDown: + case NSRightMouseUp: + case NSRightMouseDragged: + javaButtonNum = 3; + break; + case NSOtherMouseDown: + case NSOtherMouseUp: + case NSOtherMouseDragged: + javaButtonNum = 2; + break; + } + + if (evType == EVENT_MOUSE_WHEEL_MOVED && scrollDeltaY == 0) { + // ignore 0 increment wheel scroll events + return; + } + if (evType == EVENT_MOUSE_PRESSED) { + (*env)->CallVoidMethod(env, javaWindowObject, requestFocusID, JNI_FALSE); + } + + NSPoint location = [self screenPos2NewtClientWinPos: [NSEvent mouseLocation]]; + + (*env)->CallVoidMethod(env, javaWindowObject, enqueueMouseEventID, JNI_FALSE, + evType, javaMods[0], + (jint) location.x, (jint) location.y, + javaButtonNum, scrollDeltaY); + + /* if (shallBeDetached) { + (*jvmHandle)->DetachCurrentThread(jvmHandle); + } */ +} + +- (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p +{ + NSRect viewFrame = [self frame]; + + NSRect r; + r.origin.x = p.x; + r.origin.y = p.y; + r.size.width = 0; + r.size.height = 0; + // NSRect rS = [[self window] convertRectFromScreen: r]; // 10.7 + NSPoint oS = [[self window] convertScreenToBase: r.origin]; + oS.y = viewFrame.size.height - oS.y; // y-flip + return oS; +} + +- (void) handleFlagsChanged:(NSUInteger) mods +{ + [self handleFlagsChanged: NSShiftKeyMask keyIndex: 0 keyCode: kVK_Shift modifiers: mods]; + [self handleFlagsChanged: NSControlKeyMask keyIndex: 1 keyCode: kVK_Control modifiers: mods]; + [self handleFlagsChanged: NSAlternateKeyMask keyIndex: 2 keyCode: kVK_Option modifiers: mods]; + [self handleFlagsChanged: NSCommandKeyMask keyIndex: 3 keyCode: kVK_Command modifiers: mods]; +} + +- (void) handleFlagsChanged:(int) keyMask keyIndex: (int) keyIdx keyCode: (int) keyCode modifiers: (NSUInteger) mods +{ + if ( NO == modsDown[keyIdx] && 0 != ( mods & keyMask ) ) { + modsDown[keyIdx] = YES; + [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_PRESSED]; + } else if ( YES == modsDown[keyIdx] && 0 == ( mods & keyMask ) ) { + modsDown[keyIdx] = NO; + [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_RELEASED]; + } +} + +- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType +{ + jshort keyCode = (jshort) [event keyCode]; + NSString* chars = [event charactersIgnoringModifiers]; + NSUInteger mods = [event modifierFlags]; + [self sendKeyEvent: keyCode characters: chars modifiers: mods eventType: evType]; +} + +- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType +{ + if (javaWindowObject == NULL) { + DBG_PRINT("sendKeyEvent: null javaWindowObject\n"); + return; + } + int shallBeDetached = 0; + JNIEnv* env; + if( NULL != jvmHandle ) { + env = NewtCommon_GetJNIEnv(jvmHandle, [self getJVMVersion], 1 /* asDaemon */, &shallBeDetached); + } else { + env = NULL; + } + if(NULL==env) { + DBG_PRINT("sendKeyEvent: JVM %p JNIEnv %p\n", jvmHandle, env); + return; + } + + int i; + int len = NULL != chars ? [chars length] : 0; + jint javaMods = mods2JavaMods(mods); + + if(len > 0) { + // printable chars + for (i = 0; i < len; i++) { + // Note: the key code in the NSEvent does not map to anything we can use + UniChar keyChar = (UniChar) [chars characterAtIndex: i]; + UniChar keySymChar = CKCH_CharForKeyCode(keyCode); + + DBG_PRINT("sendKeyEvent: %d/%d code 0x%X, char 0x%X, mods 0x%X/0x%X -> keySymChar 0x%X\n", i, len, (int)keyCode, (int)keyChar, + (int)mods, (int)javaMods, (int)keySymChar); + + (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, + evType, javaMods, keyCode, (jchar)keyChar, (jchar)keySymChar); + } + } else { + // non-printable chars + jchar keyChar = (jchar) 0; + + DBG_PRINT("sendKeyEvent: code 0x%X\n", (int)keyCode); + + (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, + evType, javaMods, keyCode, keyChar, keyChar); + } + + /* if (shallBeDetached) { + (*jvmHandle)->DetachCurrentThread(jvmHandle); + } */ +} + +@end + +@implementation NewtMacWindow + ++ (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz +{ + enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZSIIISF)V"); + enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZSISCC)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); + insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); + positionChangedID = (*env)->GetMethodID(env, clazz, "screenPositionChanged", "(ZII)V"); + focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(ZZ)V"); + windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); + windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); + requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V"); + if (enqueueMouseEventID && enqueueKeyEventID && sizeChangedID && visibleChangedID && insetsChangedID && + positionChangedID && focusChangedID && windowDestroyNotifyID && requestFocusID && windowRepaintID) + { + CKCH_CreateDictionaries(); + return YES; + } + return NO; +} + +- (id) initWithContentRect: (NSRect) contentRect + styleMask: (NSUInteger) windowStyle + backing: (NSBackingStoreType) bufferingType + defer: (BOOL) deferCreation + isFullscreenWindow:(BOOL)isfs +{ + id res = [super initWithContentRect: contentRect + styleMask: windowStyle + backing: bufferingType + defer: deferCreation]; + // OSX 10.6 + if ( [NSApp respondsToSelector:@selector(currentSystemPresentationOptions)] && + [NSApp respondsToSelector:@selector(setPresentationOptions:)] ) { + hasPresentationSwitch = YES; + defaultPresentationOptions = [NSApp currentSystemPresentationOptions]; + fullscreenPresentationOptions = + // NSApplicationPresentationDefault| + // NSApplicationPresentationAutoHideDock| + NSApplicationPresentationHideDock| + // NSApplicationPresentationAutoHideMenuBar| + NSApplicationPresentationHideMenuBar| + NSApplicationPresentationDisableAppleMenu| + // NSApplicationPresentationDisableProcessSwitching| + // NSApplicationPresentationDisableSessionTermination| + NSApplicationPresentationDisableHideApplication| + // NSApplicationPresentationDisableMenuBarTransparency| + // NSApplicationPresentationFullScreen| // OSX 10.7 + 0 ; + } else { + hasPresentationSwitch = NO; + defaultPresentationOptions = 0; + fullscreenPresentationOptions = 0; + } + + isFullscreenWindow = isfs; + // Why is this necessary? Without it we don't get any of the + // delegate methods like resizing and window movement. + [self setDelegate: self]; + cachedInsets[0] = 0; // l + cachedInsets[1] = 0; // r + cachedInsets[2] = 0; // t + cachedInsets[3] = 0; // b realized = YES; DBG_PRINT("NewtWindow::create: %p, realized %d, hasPresentationSwitch %d[defaultOptions 0x%X, fullscreenOptions 0x%X], (refcnt %d)\n", res, realized, (int)hasPresentationSwitch, (int)defaultPresentationOptions, (int)fullscreenPresentationOptions, (int)[res retainCount]); @@ -577,343 +969,79 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { NSScreen* screen = [self screen]; NSRect screenFrame = [screen frame]; - DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: screen %d/%d %dx%d\n", - (int)screenFrame.origin.x, (int)screenFrame.origin.y, (int)screenFrame.size.width, (int)screenFrame.size.height); - - NSPoint r = NSMakePoint(screenFrame.origin.x + p.x, - screenFrame.origin.y + screenFrame.size.height - p.y - totalHeight); - - DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: result %d/%d\n", (int)r.x, (int)r.y); - - return r; -} - -/** - * p rel client window position w/ top-left origin - * returns: abs screen position w/ bottom-left origin - */ -- (NSPoint) newtRelClientTLWinPos2AbsBLScreenPos: (NSPoint) p -{ - NSRect winFrame = [self frame]; - - NSView* mView = [self contentView]; - NSRect mViewFrame = [mView frame]; - - return NSMakePoint(winFrame.origin.x + p.x, - winFrame.origin.y + ( mViewFrame.size.height - p.y ) ); // y-flip in view -} - -- (NSSize) newtClientSize2TLSize: (NSSize) nsz -{ - NSSize topSZ = { nsz.width, nsz.height + cachedInsets[2] + cachedInsets[3] }; // height + insets.top + insets.bottom - return topSZ; -} - -/** - * y-flips input / output - * p rel client window position w/ top-left origin - * returns: location in 0/0 top-left space. - */ -- (NSPoint) getLocationOnScreen: (NSPoint) p -{ - NSScreen* screen = [self screen]; - NSRect screenRect = [screen frame]; - - NSView* view = [self contentView]; - NSRect viewFrame = [view frame]; - - NSRect r; - r.origin.x = p.x; - r.origin.y = viewFrame.size.height - p.y; // y-flip - r.size.width = 0; - r.size.height = 0; - // NSRect rS = [win convertRectToScreen: r]; // 10.7 - NSPoint oS = [self convertBaseToScreen: r.origin]; - oS.y = screenRect.origin.y + screenRect.size.height - oS.y; - return oS; -} - -- (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p -{ - NSView* view = [self contentView]; - NSRect viewFrame = [view frame]; - - NSRect r; - r.origin.x = p.x; - r.origin.y = p.y; - r.size.width = 0; - r.size.height = 0; - // NSRect rS = [win convertRectFromScreen: r]; // 10.7 - NSPoint oS = [self convertScreenToBase: r.origin]; - oS.y = viewFrame.size.height - oS.y; // y-flip - return oS; -} - -- (BOOL) isMouseInside -{ - NSView* view = [self contentView]; - NSRect viewFrame = [view frame]; - NSPoint l1 = [NSEvent mouseLocation]; - NSPoint l0 = [self screenPos2NewtClientWinPos: l1]; - return viewFrame.origin.x <= l0.x && l0.x < (viewFrame.origin.x+viewFrame.size.width) && - viewFrame.origin.y <= l0.y && l0.y < (viewFrame.origin.y+viewFrame.size.height) ; -} - -- (void) setMouseVisible:(BOOL)v hasFocus:(BOOL)focus -{ - mouseVisible = v; - mouseInside = [self isMouseInside]; - DBG_PRINT( "setMouseVisible: confined %d, visible %d (current: %d), mouseInside %d, hasFocus %d\n", - mouseConfined, mouseVisible, !cursorIsHidden, mouseInside, focus); - if(YES == focus && YES == mouseInside) { - [self cursorHide: !mouseVisible enter: 0]; - } -} - -- (void) setPointerIcon:(NSCursor*)c -{ - DBG_PRINT( "setPointerIcon: mouseInside cursor: %p -> %p (glob %p), mouseInside %d\n", customCursor, c, [NSCursor currentCursor], (int)mouseInside); - if(YES == mouseInside) { - if( NULL != c ) { - DBG_PRINT( "setPointerIcon push: %p\n", c); - [c push]; - } else if( NULL != customCursor ) { - if ( NO == [customCursor isKindOfClass:[NSCursor class]] ) { - DBG_PRINT( "setPointerIcon0 NSCursor %p - is of invalid type (2)\n", customCursor); - if( [NSCursor currentCursor] == customCursor ) { - [NSCursor pop]; - } - } else if( [NSCursor currentCursor] == customCursor ) { - DBG_PRINT( "setPointerIcon pop: %p\n", customCursor); - [customCursor pop]; - } - } - } - customCursor = c; -} - -- (void) cursorHide:(BOOL)v enter:(int)enterState -{ - DBG_PRINT( "cursorHide: %d -> %d, enter %d\n", cursorIsHidden, v, enterState); - if( NULL != customCursor ) { - if ( NO == [customCursor isKindOfClass:[NSCursor class]] ) { - DBG_PRINT( "setPointerIcon0 NSCursor %p - is of invalid type (3)\n", customCursor); - if( [NSCursor currentCursor] == customCursor ) { - [NSCursor pop]; - } - } else { - if( 1 == enterState && [NSCursor currentCursor] != customCursor ) { - DBG_PRINT( "cursorHide.PointerIcon push: %p\n", customCursor); - [customCursor push]; - } else if( -1 == enterState && [NSCursor currentCursor] == customCursor ) { - DBG_PRINT( "cursorHide.PointerIcon pop: %p\n", customCursor); - [customCursor pop]; - } - } - } - if(v) { - if(!cursorIsHidden) { - [NSCursor hide]; - cursorIsHidden = YES; - } - } else { - if(cursorIsHidden) { - [NSCursor unhide]; - cursorIsHidden = NO; - } - } -} - -- (void) setMouseConfined:(BOOL)v -{ - mouseConfined = v; - DBG_PRINT( "setMouseConfined: confined %d, visible %d\n", mouseConfined, mouseVisible); -} - -- (void) setMousePosition:(NSPoint)p -{ - NSScreen* screen = [self screen]; - NSRect screenRect = [screen frame]; - - CGPoint pt = { p.x, screenRect.size.height - p.y }; // y-flip (CG is top-left origin) - CGEventRef ev = CGEventCreateMouseEvent (NULL, kCGEventMouseMoved, pt, kCGMouseButtonLeft); - CGEventPost (kCGHIDEventTap, ev); -} - -static jint mods2JavaMods(NSUInteger mods) -{ - int javaMods = 0; - if (mods & NSShiftKeyMask) { - javaMods |= EVENT_SHIFT_MASK; - } - if (mods & NSControlKeyMask) { - javaMods |= EVENT_CTRL_MASK; - } - if (mods & NSCommandKeyMask) { - javaMods |= EVENT_META_MASK; - } - if (mods & NSAlternateKeyMask) { - javaMods |= EVENT_ALT_MASK; - } - return javaMods; -} - -- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType -{ - jshort keyCode = (jshort) [event keyCode]; - NSString* chars = [event charactersIgnoringModifiers]; - NSUInteger mods = [event modifierFlags]; - [self sendKeyEvent: keyCode characters: chars modifiers: mods eventType: evType]; -} - -- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType -{ - NSView* nsview = [self contentView]; - if( ! [nsview isKindOfClass:[NewtView class]] ) { - return; - } - NewtView* view = (NewtView *) nsview; - jobject javaWindowObject = [view getJavaWindowObject]; - if (javaWindowObject == NULL) { - DBG_PRINT("sendKeyEvent: null javaWindowObject\n"); - return; - } - int shallBeDetached = 0; - JavaVM *jvmHandle = [view getJVMHandle]; - JNIEnv* env; - if( NULL != jvmHandle ) { - env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], 1 /* asDaemon */, &shallBeDetached); - } else { - env = NULL; - } - if(NULL==env) { - DBG_PRINT("sendKeyEvent: JVM %p JNIEnv %p\n", jvmHandle, env); - return; - } - - int i; - int len = NULL != chars ? [chars length] : 0; - jint javaMods = mods2JavaMods(mods); - - if(len > 0) { - // printable chars - for (i = 0; i < len; i++) { - // Note: the key code in the NSEvent does not map to anything we can use - UniChar keyChar = (UniChar) [chars characterAtIndex: i]; - UniChar keySymChar = CKCH_CharForKeyCode(keyCode); - - DBG_PRINT("sendKeyEvent: %d/%d code 0x%X, char 0x%X -> keySymChar 0x%X\n", i, len, (int)keyCode, (int)keyChar, (int)keySymChar); - - (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, - evType, javaMods, keyCode, (jchar)keyChar, (jchar)keySymChar); - } - } else { - // non-printable chars - jchar keyChar = (jchar) 0; + DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: screen %d/%d %dx%d\n", + (int)screenFrame.origin.x, (int)screenFrame.origin.y, (int)screenFrame.size.width, (int)screenFrame.size.height); - DBG_PRINT("sendKeyEvent: code 0x%X\n", (int)keyCode); + NSPoint r = NSMakePoint(screenFrame.origin.x + p.x, + screenFrame.origin.y + screenFrame.size.height - p.y - totalHeight); - (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, - evType, javaMods, keyCode, keyChar, keyChar); - } + DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: result %d/%d\n", (int)r.x, (int)r.y); - /* if (shallBeDetached) { - (*jvmHandle)->DetachCurrentThread(jvmHandle); - } */ + return r; } -- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType +/** + * p rel client window position w/ top-left origin + * returns: abs screen position w/ bottom-left origin + */ +- (NSPoint) newtRelClientTLWinPos2AbsBLScreenPos: (NSPoint) p { - NSView* nsview = [self contentView]; - if( ! [nsview isKindOfClass:[NewtView class]] ) { - return; - } - NewtView* view = (NewtView *) nsview; - jobject javaWindowObject = [view getJavaWindowObject]; - if (javaWindowObject == NULL) { - DBG_PRINT("sendMouseEvent: null javaWindowObject\n"); - return; - } - int shallBeDetached = 0; - JavaVM *jvmHandle = [view getJVMHandle]; - JNIEnv* env; - if( NULL != jvmHandle ) { - env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], 1 /* asDaemon */, &shallBeDetached); - } else { - env = NULL; - } - if(NULL==env) { - DBG_PRINT("sendMouseEvent: JVM %p JNIEnv %p\n", jvmHandle, env); - return; - } - jint javaMods[] = { 0 } ; - javaMods[0] = mods2JavaMods([event modifierFlags]); + NSRect winFrame = [self frame]; - // convert to 1-based button number (or use zero if no button is involved) - // TODO: detect mouse button when mouse wheel scrolled - jshort javaButtonNum = 0; - jfloat scrollDeltaY = 0.0f; - switch ([event type]) { - case NSScrollWheel: { - scrollDeltaY = GetDelta(event, javaMods); - javaButtonNum = 1; - break; - } - case NSLeftMouseDown: - case NSLeftMouseUp: - case NSLeftMouseDragged: - javaButtonNum = 1; - break; - case NSRightMouseDown: - case NSRightMouseUp: - case NSRightMouseDragged: - javaButtonNum = 3; - break; - case NSOtherMouseDown: - case NSOtherMouseUp: - case NSOtherMouseDragged: - javaButtonNum = 2; - break; - } + NSView* mView = [self contentView]; + NSRect mViewFrame = [mView frame]; - if (evType == EVENT_MOUSE_WHEEL_MOVED && scrollDeltaY == 0) { - // ignore 0 increment wheel scroll events - return; - } - if (evType == EVENT_MOUSE_PRESSED) { - (*env)->CallVoidMethod(env, javaWindowObject, requestFocusID, JNI_FALSE); - } + return NSMakePoint(winFrame.origin.x + p.x, + winFrame.origin.y + ( mViewFrame.size.height - p.y ) ); // y-flip in view +} - NSPoint location = [self screenPos2NewtClientWinPos: [NSEvent mouseLocation]]; +- (NSSize) newtClientSize2TLSize: (NSSize) nsz +{ + NSSize topSZ = { nsz.width, nsz.height + cachedInsets[2] + cachedInsets[3] }; // height + insets.top + insets.bottom + return topSZ; +} - (*env)->CallVoidMethod(env, javaWindowObject, enqueueMouseEventID, JNI_FALSE, - evType, javaMods[0], - (jint) location.x, (jint) location.y, - javaButtonNum, scrollDeltaY); +/** + * y-flips input / output + * p rel client window position w/ top-left origin + * returns: location in 0/0 top-left space. + */ +- (NSPoint) getLocationOnScreen: (NSPoint) p +{ + NSScreen* screen = [self screen]; + NSRect screenRect = [screen frame]; - /* if (shallBeDetached) { - (*jvmHandle)->DetachCurrentThread(jvmHandle); - } */ + NSView* view = [self contentView]; + NSRect viewFrame = [view frame]; + + NSRect r; + r.origin.x = p.x; + r.origin.y = viewFrame.size.height - p.y; // y-flip + r.size.width = 0; + r.size.height = 0; + // NSRect rS = [win convertRectToScreen: r]; // 10.7 + NSPoint oS = [self convertBaseToScreen: r.origin]; + oS.y = screenRect.origin.y + screenRect.size.height - oS.y; + return oS; } - (void) focusChanged: (BOOL) gained { DBG_PRINT( "focusChanged: gained %d\n", gained); - NSView* nsview = [self contentView]; - if( ! [nsview isKindOfClass:[NewtView class]] ) { + NewtView* newtView = (NewtView *) [self contentView]; + if( ! [newtView isKindOfClass:[NewtView class]] ) { return; } - NewtView* view = (NewtView *) nsview; - jobject javaWindowObject = [view getJavaWindowObject]; + jobject javaWindowObject = [newtView getJavaWindowObject]; if (javaWindowObject == NULL) { DBG_PRINT("focusChanged: null javaWindowObject\n"); return; } int shallBeDetached = 0; - JavaVM *jvmHandle = [view getJVMHandle]; + JavaVM *jvmHandle = [newtView getJVMHandle]; JNIEnv* env; if( NULL != jvmHandle ) { - env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], 1 /* asDaemon */, &shallBeDetached); + env = NewtCommon_GetJNIEnv(jvmHandle, [newtView getJVMVersion], 1 /* asDaemon */, &shallBeDetached); } else { env = NULL; } @@ -929,15 +1057,50 @@ static jint mods2JavaMods(NSUInteger mods) } */ } +- (void) keyDown: (NSEvent*) theEvent +{ + NewtView* newtView = (NewtView *) [self contentView]; + if( [newtView isKindOfClass:[NewtView class]] ) { + [newtView sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_PRESSED]; + } +} + +- (void) keyUp: (NSEvent*) theEvent +{ + NewtView* newtView = (NewtView *) [self contentView]; + if( [newtView isKindOfClass:[NewtView class]] ) { + [newtView sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_RELEASED]; + } +} + +- (void) flagsChanged:(NSEvent *) theEvent +{ + NSUInteger mods = [theEvent modifierFlags]; + NewtView* newtView = (NewtView *) [self contentView]; + if( [newtView isKindOfClass:[NewtView class]] ) { + [newtView handleFlagsChanged: mods]; + } +} + +- (BOOL) acceptsMouseMovedEvents +{ + return YES; +} + +- (BOOL) acceptsFirstResponder +{ + return YES; +} + - (BOOL) becomeFirstResponder { - DBG_PRINT( "*************** becomeFirstResponder\n"); + DBG_PRINT( "*************** Win.becomeFirstResponder\n"); return [super becomeFirstResponder]; } - (BOOL) resignFirstResponder { - DBG_PRINT( "*************** resignFirstResponder\n"); + DBG_PRINT( "*************** Win.resignFirstResponder\n"); return [super resignFirstResponder]; } @@ -965,9 +1128,12 @@ static jint mods2JavaMods(NSUInteger mods) - (void) windowDidBecomeKey: (NSNotification *) notification { DBG_PRINT( "*************** windowDidBecomeKey\n"); - mouseInside = [self isMouseInside]; - if(YES == mouseInside) { - [self cursorHide: !mouseVisible enter: 0]; + NewtView* newtView = (NewtView *) [self contentView]; + if( [newtView isKindOfClass:[NewtView class]] ) { + BOOL mouseInside = [newtView updateMouseInside]; + if(YES == mouseInside) { + [newtView cursorHide: ![newtView isMouseVisible] enter: 1]; + } } [self focusChanged: YES]; } @@ -979,128 +1145,6 @@ static jint mods2JavaMods(NSUInteger mods) [self focusChanged: NO]; } -- (void) keyDown: (NSEvent*) theEvent -{ - [self sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_PRESSED]; -} - -- (void) keyUp: (NSEvent*) theEvent -{ - [self sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_RELEASED]; -} - -#define kVK_Shift 0x38 -#define kVK_Option 0x3A -#define kVK_Control 0x3B -#define kVK_Command 0x37 - -- (void) handleFlagsChanged:(int) keyMask keyIndex: (int) keyIdx keyCode: (int) keyCode modifiers: (NSUInteger) mods -{ - if ( NO == modsDown[keyIdx] && 0 != ( mods & keyMask ) ) { - modsDown[keyIdx] = YES; - [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_PRESSED]; - } else if ( YES == modsDown[keyIdx] && 0 == ( mods & keyMask ) ) { - modsDown[keyIdx] = NO; - [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_RELEASED]; - } -} - -- (void) flagsChanged:(NSEvent *) theEvent -{ - NSUInteger mods = [theEvent modifierFlags]; - - // BOOL modsDown[4]; // shift, ctrl, alt/option, win/command - - [self handleFlagsChanged: NSShiftKeyMask keyIndex: 0 keyCode: kVK_Shift modifiers: mods]; - [self handleFlagsChanged: NSControlKeyMask keyIndex: 1 keyCode: kVK_Control modifiers: mods]; - [self handleFlagsChanged: NSAlternateKeyMask keyIndex: 2 keyCode: kVK_Option modifiers: mods]; - [self handleFlagsChanged: NSCommandKeyMask keyIndex: 3 keyCode: kVK_Command modifiers: mods]; -} - -- (void) mouseEntered: (NSEvent*) theEvent -{ - DBG_PRINT( "mouseEntered: confined %d, visible %d\n", mouseConfined, mouseVisible); - mouseInside = YES; - [self cursorHide: !mouseVisible enter: 1]; - if(NO == mouseConfined) { - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_ENTERED]; - } -} - -- (void) mouseExited: (NSEvent*) theEvent -{ - DBG_PRINT( "mouseExited: confined %d, visible %d\n", mouseConfined, mouseVisible); - if(NO == mouseConfined) { - mouseInside = NO; - [self cursorHide: NO enter: -1]; - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_EXITED]; - } else { - [self setMousePosition: lastInsideMousePosition]; - } -} - -- (void) mouseMoved: (NSEvent*) theEvent -{ - lastInsideMousePosition = [NSEvent mouseLocation]; - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; -} - -- (void) scrollWheel: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_WHEEL_MOVED]; -} - -- (void) mouseDown: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; -} - -- (void) mouseDragged: (NSEvent*) theEvent -{ - lastInsideMousePosition = [NSEvent mouseLocation]; - // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; -} - -- (void) mouseUp: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; -} - -- (void) rightMouseDown: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; -} - -- (void) rightMouseDragged: (NSEvent*) theEvent -{ - lastInsideMousePosition = [NSEvent mouseLocation]; - // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; -} - -- (void) rightMouseUp: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; -} - -- (void) otherMouseDown: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; -} - -- (void) otherMouseDragged: (NSEvent*) theEvent -{ - lastInsideMousePosition = [NSEvent mouseLocation]; - // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; -} - -- (void) otherMouseUp: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; -} - - (void)windowDidResize: (NSNotification*) notification { JNIEnv* env = NULL; @@ -1108,14 +1152,13 @@ static jint mods2JavaMods(NSUInteger mods) int shallBeDetached = 0; JavaVM *jvmHandle = NULL; - NSView* nsview = [self contentView]; - if( [nsview isKindOfClass:[NewtView class]] ) { - NewtView* view = (NewtView *) nsview; - javaWindowObject = [view getJavaWindowObject]; + NewtView* newtView = (NewtView *) [self contentView]; + if( [newtView isKindOfClass:[NewtView class]] ) { + javaWindowObject = [newtView getJavaWindowObject]; if (javaWindowObject != NULL) { - jvmHandle = [view getJVMHandle]; + jvmHandle = [newtView getJVMHandle]; if( NULL != jvmHandle ) { - env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], 1 /* asDaemon */, &shallBeDetached); + env = NewtCommon_GetJNIEnv(jvmHandle, [newtView getJVMVersion], 1 /* asDaemon */, &shallBeDetached); } } } @@ -1139,21 +1182,20 @@ static jint mods2JavaMods(NSUInteger mods) - (void)windowDidMove: (NSNotification*) notification { - NSView* nsview = [self contentView]; - if( ! [nsview isKindOfClass:[NewtView class]] ) { + NewtView* newtView = (NewtView *) [self contentView]; + if( ! [newtView isKindOfClass:[NewtView class]] ) { return; } - NewtView* view = (NewtView *) nsview; - jobject javaWindowObject = [view getJavaWindowObject]; + jobject javaWindowObject = [newtView getJavaWindowObject]; if (javaWindowObject == NULL) { DBG_PRINT("windowDidMove: null javaWindowObject\n"); return; } int shallBeDetached = 0; - JavaVM *jvmHandle = [view getJVMHandle]; + JavaVM *jvmHandle = [newtView getJVMHandle]; JNIEnv* env; if( NULL != jvmHandle ) { - env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], 1 /* asDaemon */, &shallBeDetached); + env = NewtCommon_GetJNIEnv(jvmHandle, [newtView getJVMVersion], 1 /* asDaemon */, &shallBeDetached); } else { env = NULL; } @@ -1186,32 +1228,31 @@ static jint mods2JavaMods(NSUInteger mods) jboolean closed = JNI_FALSE; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [self cursorHide: NO enter: -1]; - - NSView* nsview = [self contentView]; - if( ! [nsview isKindOfClass:[NewtView class]] ) { + NewtView* newtView = (NewtView *) [self contentView]; + if( ! [newtView isKindOfClass:[NewtView class]] ) { return NO; } - NewtView* view = (NewtView *) nsview; - if( false == [view getDestroyNotifySent] ) { - jobject javaWindowObject = [view getJavaWindowObject]; + [newtView cursorHide: NO enter: -1]; + + if( false == [newtView getDestroyNotifySent] ) { + jobject javaWindowObject = [newtView getJavaWindowObject]; DBG_PRINT( "*************** windowWillClose.0: %p\n", (void *)(intptr_t)javaWindowObject); if (javaWindowObject == NULL) { DBG_PRINT("windowWillClose: null javaWindowObject\n"); return NO; } int shallBeDetached = 0; - JavaVM *jvmHandle = [view getJVMHandle]; + JavaVM *jvmHandle = [newtView getJVMHandle]; JNIEnv* env = NULL; NS_DURING if( NULL != jvmHandle ) { - env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], 1 /* asDaemon */, &shallBeDetached); + env = NewtCommon_GetJNIEnv(jvmHandle, [newtView getJVMVersion], 1 /* asDaemon */, &shallBeDetached); } NS_HANDLER jvmHandle = NULL; env = NULL; - [view setJVMHandle: NULL]; + [newtView setJVMHandle: NULL]; DBG_PRINT("windowWillClose: JVMHandler Exception\n"); NS_ENDHANDLER DBG_PRINT("windowWillClose: JVM %p JNIEnv %p\n", jvmHandle, env); @@ -1219,11 +1260,11 @@ NS_ENDHANDLER return NO; } - [view setDestroyNotifySent: true]; // earmark assumption of being closed + [newtView setDestroyNotifySent: true]; // earmark assumption of being closed closed = (*env)->CallBooleanMethod(env, javaWindowObject, windowDestroyNotifyID, force ? JNI_TRUE : JNI_FALSE); if(!force && !closed) { // not closed on java side, not force -> clear flag - [view setDestroyNotifySent: false]; + [newtView setDestroyNotifySent: false]; } /* if (shallBeDetached) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index efec961de..8cc676291 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -85,6 +85,7 @@ public class TestGearsES2NEWT extends UITestCase { static boolean waitForKey = false; static boolean mouseVisible = true; static boolean mouseConfined = false; + static boolean setPointerIcon = false; static boolean showFPS = false; static int loops = 1; static boolean loop_shutdown = false; @@ -183,6 +184,10 @@ public class TestGearsES2NEWT extends UITestCase { } pointerIconOne = _pointerIconOne; } + if( setPointerIcon ) { + glWindow.setPointerIcon(pointerIconOne); + System.err.println("Set PointerIcon: "+glWindow.getPointerIcon()); + } glWindow.addKeyListener(new KeyAdapter() { @Override @@ -216,16 +221,6 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("[set alwaysontop post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setExclusiveContextThread(t); } }.start(); - } else if(e.getKeyChar()=='c') { - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - System.err.println("[set pointer-icon pre]"); - final PointerIcon currentPI = glWindow.getPointerIcon(); - glWindow.setPointerIcon( currentPI == pointerIconOne ? null : pointerIconOne); - System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); - glWindow.setExclusiveContextThread(t); - } }.start(); } else if(e.getKeyChar()=='d') { new Thread() { public void run() { @@ -245,6 +240,16 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("[set position post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); glWindow.setExclusiveContextThread(t); } }.start(); + } else if(e.getKeyChar()=='c') { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set pointer-icon pre]"); + final PointerIcon currentPI = glWindow.getPointerIcon(); + glWindow.setPointerIcon( currentPI == pointerIconOne ? null : pointerIconOne); + System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); + glWindow.setExclusiveContextThread(t); + } }.start(); } else if(e.getKeyChar()=='i') { new Thread() { public void run() { @@ -482,6 +487,8 @@ public class TestGearsES2NEWT extends UITestCase { mouseVisible = false; } else if(args[i].equals("-mouseConfine")) { mouseConfined = true; + } else if(args[i].equals("-pointerIcon")) { + setPointerIcon = true; } else if(args[i].equals("-showFPS")) { showFPS = true; } else if(args[i].equals("-width")) { @@ -537,6 +544,7 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("pmvDirect "+(!pmvUseBackingArray)); System.err.println("mouseVisible "+mouseVisible); System.err.println("mouseConfined "+mouseConfined); + System.err.println("pointerIcon "+setPointerIcon); System.err.println("loops "+loops); System.err.println("loop shutdown "+loop_shutdown); System.err.println("forceES2 "+forceES2); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 189645d3d..69874df6b 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -31,6 +31,10 @@ import java.awt.Frame; import javax.media.nativewindow.util.InsetsImmutable; +import com.jogamp.common.util.IOUtil; +import com.jogamp.newt.Display; +import com.jogamp.newt.Window; +import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -42,6 +46,7 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final NewtCanvasAWT newtCanvasAWT; final GLWindow glWindow; final QuitAdapter quitAdapter; + PointerIcon pointerIconTest = null; public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow, QuitAdapter quitAdapter) { this.frame = frame; @@ -54,9 +59,7 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; } - if( e.getKeySymbol() == KeyEvent.VK_I ) { - System.err.println(glWindow); - } else if( e.getKeySymbol() == KeyEvent.VK_L ) { + if( e.getKeySymbol() == KeyEvent.VK_L ) { javax.media.nativewindow.util.Point p0 = newtCanvasAWT.getNativeWindow().getLocationOnScreen(null); javax.media.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null); System.err.println("NewtCanvasAWT position: "+p0+", "+p1); @@ -140,6 +143,50 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { quitAdapter.enable(true); } } }.start(); + } else if(e.getKeySymbol() == KeyEvent.VK_C ) { + if( null == pointerIconTest ) { + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/jogamp-32x32.png" } ); + final Display disp = glWindow.getScreen().getDisplay(); + try { + pointerIconTest = disp.createPointerIcon(res, 16, 0); + } catch (Exception err) { + err.printStackTrace(); + } + } + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set pointer-icon pre]"); + final PointerIcon currentPI = glWindow.getPointerIcon(); + glWindow.setPointerIcon( currentPI == pointerIconTest ? null : pointerIconTest); + System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } else if( e.getKeySymbol() == KeyEvent.VK_I ) { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set mouse visible pre]: "+glWindow.isPointerVisible()); + glWindow.setPointerVisible(!glWindow.isPointerVisible()); + System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } else if(e.getKeySymbol() == KeyEvent.VK_J ) { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined()); + glWindow.confinePointer(!glWindow.isPointerConfined()); + System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } else if(e.getKeySymbol() == KeyEvent.VK_W ) { + new Thread() { + public void run() { + System.err.println("[set mouse pos pre]"); + glWindow.warpPointer(glWindow.getWidth()/2, glWindow.getHeight()/2); + System.err.println("[set mouse pos post]"); + } }.start(); } } } \ No newline at end of file -- cgit v1.2.3 From bec29cf970e6a55eb8f720afdae5a3bdc97c1ba2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 4 Jan 2014 17:18:47 +0100 Subject: Bug 935: NEWT OSX PointerIcon/Pointer-Visibility: Impl. OffscreenLayerSurface (OSX CALayer) w/ JAWTWindow Path Add setCursor(..) and hideCursor() to OffscreenLayerSurface interface, impl. in JAWTWindow w/ AWT. This allows an OSX NEWT Window using CALayer (i.e. NewtCanvasAWT) to have setPointerIcon(..) and setPointerVisible(..) functionality! --- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 28 ++++++++++++++++ .../media/nativewindow/OffscreenLayerSurface.java | 20 ++++++++++++ .../classes/jogamp/nativewindow/awt/AWTMisc.java | 37 ++++++++++++++++++++++ .../jogamp/newt/driver/macosx/WindowDriver.java | 36 +++++++++++++++++++-- 4 files changed, 119 insertions(+), 2 deletions(-) (limited to 'src/newt/classes') diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 3c660b41b..46bdc4d1f 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -38,18 +38,21 @@ package com.jogamp.nativewindow.awt; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.MutableGraphicsConfiguration; import java.awt.Component; import java.awt.Container; +import java.awt.Cursor; import java.awt.Window; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.event.HierarchyEvent; import java.awt.event.HierarchyListener; import java.applet.Applet; +import java.io.IOException; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -63,6 +66,7 @@ import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.PointImmutable; import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; @@ -427,6 +431,30 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return surfaceLock; } + @Override + public final boolean setCursor(IOUtil.ClassResources resources, PointImmutable hotSpot) throws IOException { + final Cursor c; + if( null == resources || null == hotSpot ) { + c = Cursor.getDefaultCursor(); + } else { + final java.awt.Point awtHotspot = new java.awt.Point(hotSpot.getX(), hotSpot.getY()); + c = AWTMisc.getCursor(resources, awtHotspot); + } + if( null != c ) { + component.setCursor(c); + return true; + } else { + return false; + } + } + + @Override + public boolean hideCursor() { + final Cursor c = AWTMisc.getNullCursor(); + component.setCursor(c); + return true; + } + // // SurfaceUpdateListener // diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index 8681422ef..81983a7c2 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -27,6 +27,11 @@ */ package javax.media.nativewindow; +import java.io.IOException; + +import javax.media.nativewindow.util.PointImmutable; + +import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.locks.RecursiveLock; /** @@ -65,4 +70,19 @@ public interface OffscreenLayerSurface { /** Returns the recursive lock object of this surface, which synchronizes multithreaded access. */ public RecursiveLock getLock(); + /** + * Optional method setting cursor in the corresponding on-screen surface/window, if exists. + * + * @param resources maybe null for default cursor + * @param hotSpot maybe null for default cursor + * @return true if successful, i.e. on-screen surface/window w/ cursor capabilities exists. Otherwise false. + * @throws IOException + */ + public boolean setCursor(IOUtil.ClassResources resources, PointImmutable hotSpot) throws IOException; + /** + * Optional method hiding the cursor in the corresponding on-screen surface/window, if exists. + * + * @return true if successful, i.e. on-screen surface/window w/ cursor capabilities exists. Otherwise false. + */ + public boolean hideCursor(); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index 0fa5006cc..31de84137 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -27,21 +27,31 @@ */ package jogamp.nativewindow.awt; +import java.awt.Cursor; import java.awt.FocusTraversalPolicy; import java.awt.Insets; +import java.awt.Point; +import java.awt.Toolkit; import java.awt.Window; import java.awt.Component; import java.awt.Container; import java.awt.Frame; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.net.URLConnection; +import java.util.HashMap; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JRootPane; import javax.swing.WindowConstants; +import javax.imageio.ImageIO; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.WindowClosingProtocol; import javax.swing.MenuSelectionManager; +import com.jogamp.common.util.IOUtil; + public class AWTMisc { public static JFrame getJFrame(Component c) { @@ -163,6 +173,33 @@ public class AWTMisc { MenuSelectionManager.defaultManager().clearSelectedPath(); } + static final HashMap cursorMap = new HashMap(); + static final Cursor nulCursor; + static { + final Toolkit toolkit = Toolkit.getDefaultToolkit(); + BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR); + nulCursor = toolkit.createCustomCursor(img, new Point(0,0), "nullCursor"); + } + + public static synchronized Cursor getNullCursor() { return nulCursor; } + + public static synchronized Cursor getCursor(IOUtil.ClassResources resources, Point hotSpot) throws IOException { + final String key = resources.getClass().getName()+":"+resources.resourcePaths[0]; + Cursor cursor = cursorMap.get(key); + if( null == cursor ) { + cursor = createAWTCursor(resources, hotSpot); + cursorMap.put(key, cursor); + } + return cursor; + } + private static synchronized Cursor createAWTCursor(IOUtil.ClassResources resources, Point hotSpot) throws IOException { + final URLConnection urlConn = resources.resolve(0); + BufferedImage img = ImageIO.read(urlConn.getInputStream()); + + final Toolkit toolkit = Toolkit.getDefaultToolkit(); + return toolkit.createCustomCursor(img, hotSpot, resources.resourcePaths[0]); + } + public static WindowClosingProtocol.WindowClosingMode AWT2NWClosingOperation(int awtClosingOperation) { switch (awtClosingOperation) { case WindowConstants.DISPOSE_ON_CLOSE: diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 6f3c95570..748604994 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -39,6 +39,8 @@ import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; @@ -403,7 +405,23 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl throw new RuntimeException("Failed: "+pi+", "+WindowDriver.this); } } } ); - } // else may need offscreen solution ? FIXME + } else { + final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(this, true); + if( null != ols ) { + try { + setOLSPointer(ols, pi); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + private static void setOLSPointer(final OffscreenLayerSurface ols, final PointerIconImpl pi) throws Exception { + if( null != pi ) { + ols.setCursor(pi.getResource(), pi.getHotspot()); + } else { + ols.setCursor(null, null); // default + } } @Override @@ -417,7 +435,21 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } } ); return true; // setPointerVisible0 always returns true .. - } // else may need offscreen solution ? FIXME + } else { + final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(this, true); + if( null != ols ) { + try { + if( pointerVisible ) { + setOLSPointer(ols, (PointerIconImpl)getPointerIcon()); + } else { + ols.hideCursor(); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + } + } + } return false; } -- cgit v1.2.3 From 2d3a311b7863ed598865f19833417abb6e27a513 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 4 Jan 2014 17:20:00 +0100 Subject: JOGLNewtAppletBase Default Key-Action: Add 'j' for setPointerConfined() .. i.e. 'jailed' --- .../classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index eac328cdd..7ffbc2e83 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -364,6 +364,15 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { glWindow.setPointerVisible(!glWindow.isPointerVisible()); System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible()); } }.start(); + } else if(e.getKeyChar()=='j') { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined()); + glWindow.confinePointer(!glWindow.isPointerConfined()); + System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined()); + glWindow.setExclusiveContextThread(t); + } }.start(); } else if(e.getKeyChar()=='w') { new Thread() { public void run() { -- cgit v1.2.3 From 49e9ce7e641cb6923d9907ad66f667b3d3490e49 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 5 Jan 2014 03:38:15 +0100 Subject: Bug 935: NEWT Windows Window-Icon: Use WNDCLASSEX w/ Small/Big Default Icons (NativeWindow GDI / NEWT ) .. this allows using the icon definition of WNDCLASSEX instead of setting them at CreateWindow0(..). - NativeWindow GDIUtil/RegisteredFactory uses WNDCLASSEX and Small/Big Defailt Icons --- .../jogamp/nativewindow/windows/GDIUtil.java | 8 ++++-- .../windows/RegisteredClassFactory.java | 7 +++-- src/nativewindow/native/win32/GDImisc.c | 13 ++++++---- .../jogamp/newt/driver/windows/DisplayDriver.java | 26 +++++++++++++++++-- .../jogamp/newt/driver/windows/WindowDriver.java | 30 ++-------------------- src/newt/native/WindowsWindow.c | 9 +------ 6 files changed, 46 insertions(+), 47 deletions(-) (limited to 'src/newt/classes') diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index a872e63d8..720ff9bdb 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -59,7 +59,9 @@ public class GDIUtil implements ToolkitProperties { if( !initIDs0() ) { throw new NativeWindowException("GDI: Could not initialized native stub"); } - dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0(), true /* useDummyDispatchThread */); + dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0(), + true /* useDummyDispatchThread */, + 0 /* iconSmallHandle */, 0 /* iconBigHandle */); if(DEBUG) { System.out.println("GDI.initSingleton() dummyWindowClassFactory "+dummyWindowClassFactory); } @@ -128,7 +130,9 @@ public class GDIUtil implements ToolkitProperties { private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI - static native boolean CreateWindowClass0(long hInstance, String clazzName, long wndProc); + /** Creates WNDCLASSEX instance */ + static native boolean CreateWindowClass0(long hInstance, String clazzName, long wndProc, long iconSmallHandle, long iconBigHandle); + /** Destroys WNDCLASSEX instance */ static native boolean DestroyWindowClass0(long hInstance, String className, long dispThreadCtx); static native long CreateDummyDispatchThread0(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java index ee41fe192..c4b4d145c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java @@ -50,6 +50,7 @@ public class RegisteredClassFactory { private final String classBaseName; private final long wndProc; private final boolean useDummyDispatchThread; + private final long iconSmallHandle, iconBigHandle; private RegisteredClass sharedClass = null; private int classIter = 0; @@ -92,10 +93,12 @@ public class RegisteredClassFactory { /** Application handle. */ public static long getHInstance() { return hInstance; } - public RegisteredClassFactory(String classBaseName, long wndProc, boolean useDummyDispatchThread) { + public RegisteredClassFactory(String classBaseName, long wndProc, boolean useDummyDispatchThread, long iconSmallHandle, long iconBigHandle) { this.classBaseName = classBaseName; this.wndProc = wndProc; this.useDummyDispatchThread = useDummyDispatchThread; + this.iconSmallHandle = iconSmallHandle; + this.iconBigHandle = iconBigHandle; synchronized(registeredFactories) { registeredFactories.add(this); } @@ -114,7 +117,7 @@ public class RegisteredClassFactory { // Retry with next clazz name, this could happen if more than one JVM is running clazzName = classBaseName + classIter; classIter++; - registered = GDIUtil.CreateWindowClass0(hInstance, clazzName, wndProc); + registered = GDIUtil.CreateWindowClass0(hInstance, clazzName, wndProc, iconSmallHandle, iconBigHandle); } if( !registered ) { throw new NativeWindowException("Error: Could not create WindowClass: "+clazzName); diff --git a/src/nativewindow/native/win32/GDImisc.c b/src/nativewindow/native/win32/GDImisc.c index 25b98acf3..e28f68e7d 100644 --- a/src/nativewindow/native/win32/GDImisc.c +++ b/src/nativewindow/native/win32/GDImisc.c @@ -237,11 +237,12 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyDispatchThread0 */ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass0 - (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jClazzName, jlong wndProc) + (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jClazzName, jlong wndProc, + jlong iconSmallHandle, jlong iconBigHandle) { HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance; const TCHAR* clazzName = NULL; - WNDCLASS wc; + WNDCLASSEX wc; jboolean res; #ifdef UNICODE @@ -251,23 +252,25 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass0 #endif ZeroMemory( &wc, sizeof( wc ) ); - if( GetClassInfo( hInstance, clazzName, &wc ) ) { + if( GetClassInfoEx( hInstance, clazzName, &wc ) ) { // registered already res = JNI_TRUE; } else { // register now ZeroMemory( &wc, sizeof( wc ) ); + wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW ; wc.lpfnWndProc = (WNDPROC) (intptr_t) wndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; - wc.hIcon = NULL; + wc.hIcon = (HICON) (intptr_t) iconBigHandle; wc.hCursor = NULL; wc.hbrBackground = NULL; // no background paint - GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = clazzName; - res = ( 0 != RegisterClass( &wc ) ) ? JNI_TRUE : JNI_FALSE ; + wc.hIconSm = (HICON) (intptr_t) iconSmallHandle; + res = ( 0 != RegisterClassEx( &wc ) ) ? JNI_TRUE : JNI_FALSE ; } #ifdef UNICODE diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index 1e9c78a5d..a4db50165 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -54,16 +54,38 @@ import javax.media.nativewindow.util.Point; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; +import com.jogamp.newt.NewtFactory; public class DisplayDriver extends DisplayImpl { private static final String newtClassBaseName = "_newt_clazz" ; + private static final long[] defaultIconHandles; private static RegisteredClassFactory sharedClassFactory; static { NEWTJNILibLoader.loadNEWT(); - - sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowDriver.getNewtWndProc0(), false /* useDummyDispatchThread */); + { + long[] _defaultIconHandle = { 0, 0 }; + if( PNGIcon.isAvailable() ) { + try { + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; + final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons(); + { + final ByteBuffer icon_data_small = PNGIcon.singleToRGBAImage(iconRes, 0, true /* toBGRA */, width, height, data_size); + _defaultIconHandle[0] = DisplayDriver.createBGRA8888Icon0(icon_data_small, width[0], height[0], false, 0, 0); + } + { + final ByteBuffer icon_data_big = PNGIcon.singleToRGBAImage(iconRes, iconRes.resourceCount()-1, true /* toBGRA */, width, height, data_size); + _defaultIconHandle[1] = DisplayDriver.createBGRA8888Icon0(icon_data_big, width[0], height[0], false, 0, 0); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + defaultIconHandles = _defaultIconHandle; + } + sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowDriver.getNewtWndProc0(), + false /* useDummyDispatchThread */, defaultIconHandles[0], defaultIconHandles[1]); if (!WindowDriver.initIDs0(RegisteredClassFactory.getHInstance())) { throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs"); diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index c8d7c65cc..a48fe2f62 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -40,7 +40,6 @@ import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.GDIUtil; import jogamp.newt.PointerIconImpl; import jogamp.newt.WindowImpl; -import jogamp.newt.driver.PNGIcon; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.GraphicsConfigurationFactory; @@ -51,39 +50,16 @@ import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; import com.jogamp.common.os.Platform; -import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.VersionNumber; -import com.jogamp.newt.NewtFactory; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseEvent.PointerType; public class WindowDriver extends WindowImpl { - private static final long[] defaultIconHandles; static { DisplayDriver.initSingleton(); - { - long[] _defaultIconHandle = { 0, 0 }; - if( PNGIcon.isAvailable() ) { - try { - final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; - final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons(); - { - final ByteBuffer icon_data_small = PNGIcon.singleToRGBAImage(iconRes, 0, true /* toBGRA */, width, height, data_size); - _defaultIconHandle[0] = DisplayDriver.createBGRA8888Icon0(icon_data_small, width[0], height[0], false, 0, 0); - } - { - final ByteBuffer icon_data_big = PNGIcon.singleToRGBAImage(iconRes, iconRes.resourceCount()-1, true /* toBGRA */, width, height, data_size); - _defaultIconHandle[1] = DisplayDriver.createBGRA8888Icon0(icon_data_big, width[0], height[0], false, 0, 0); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - defaultIconHandles = _defaultIconHandle; - } } private long hmon; @@ -169,8 +145,7 @@ public class WindowDriver extends WindowImpl { ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; final long _windowHandle = CreateWindow0(DisplayDriver.getHInstance(), display.getWindowClassName(), display.getWindowClassName(), winVer.getMajor(), winVer.getMinor(), - getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags, - defaultIconHandles[0], defaultIconHandles[1]); + getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags); if ( 0 == _windowHandle ) { throw new NativeWindowException("Error creating window"); } @@ -393,8 +368,7 @@ public class WindowDriver extends WindowImpl { protected static native boolean initIDs0(long hInstance); private native long CreateWindow0(long hInstance, String wndClassName, String wndName, int winMajor, int winMinor, - long parentWindowHandle, int x, int y, int width, int height, boolean autoPosition, int flags, - long iconSmallHandle, long iconBigHandle); + long parentWindowHandle, int x, int y, int width, int height, boolean autoPosition, int flags); private native long MonitorFromWindow0(long windowHandle); private native void reconfigureWindow0(long parentWindowHandle, long windowHandle, int x, int y, int width, int height, int flags); diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 8671ee2e0..f193df2b6 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -2014,8 +2014,7 @@ static void NewtWindow_setVisiblePosSize(HWND hwnd, BOOL atop, BOOL visible, JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindow0 (JNIEnv *env, jobject obj, jlong hInstance, jstring jWndClassName, jstring jWndName, jint winMajor, jint winMinor, - jlong parent, jint jx, jint jy, jint defaultWidth, jint defaultHeight, jboolean autoPosition, jint flags, - jlong iconSmallHandle, jlong iconBigHandle) + jlong parent, jint jx, jint jy, jint defaultWidth, jint defaultHeight, jboolean autoPosition, jint flags) { HWND parentWindow = (HWND) (intptr_t) parent; const TCHAR* wndClassName = NULL; @@ -2104,12 +2103,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo RECT rc; RECT * insets; - if( 0 != iconSmallHandle ) { - SendMessage(window, WM_SETICON, ICON_SMALL, (LPARAM) iconSmallHandle ); - } - if( 0 != iconBigHandle ) { - SendMessage(window, WM_SETICON, ICON_BIG, (LPARAM) iconBigHandle ); - } ShowWindow(window, SW_SHOW); // send insets before visibility, allowing java code a proper sync point! -- cgit v1.2.3 From 69b5adb37a191e746fa55e495c2d02a942833899 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 5 Jan 2014 18:12:43 +0100 Subject: NEWT OSX: Add missing NewtCommon_init(env) (duh!) - Issuing NewtCommon_throwNewRuntimeException(..) if given references are of invalid type Missing NewtCommon_init(env) always lead to a crash when calling NewtCommon_throwNewRuntimeException(..) due to uninitialized clazz instances! --- .../jogamp/newt/driver/macosx/WindowDriver.java | 23 ++++----- src/newt/native/MacWindow.m | 59 ++++++++++------------ 2 files changed, 37 insertions(+), 45 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 748604994..edeb69f84 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -401,9 +401,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl OSXUtil.RunOnMainThread(true, new Runnable() { // waitUntildone due to PointerIconImpl's Lifecycle ! @Override public void run() { - if( !setPointerIcon0(getWindowHandle(), piHandle) ) { - throw new RuntimeException("Failed: "+pi+", "+WindowDriver.this); - } + setPointerIcon0(getWindowHandle(), piHandle); } } ); } else { final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(this, true); @@ -430,9 +428,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl OSXUtil.RunOnMainThread(false, new Runnable() { @Override public void run() { - if( !setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible) ) { - throw new RuntimeException("Failed"); - } + setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible); } } ); return true; // setPointerVisible0 always returns true .. } else { @@ -456,7 +452,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected boolean confinePointerImpl(final boolean confine) { if( !isOffscreenInstance ) { - return confinePointer0(getWindowHandle(), confine); + confinePointer0(getWindowHandle(), confine); + return true; } // else may need offscreen solution ? FIXME return false; } @@ -464,9 +461,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected void warpPointerImpl(final int x, final int y) { if( !isOffscreenInstance ) { - if( !warpPointer0(getWindowHandle(), x, y) ) { - throw new RuntimeException("Failed"); - } + warpPointer0(getWindowHandle(), x, y); } // else may need offscreen solution ? FIXME } @@ -621,10 +616,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl /** Must be called on Main-Thread */ private native void setAlwaysOnTop0(long window, boolean atop); private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y); - private static native boolean setPointerIcon0(long windowHandle, long handle); - private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); - private static native boolean confinePointer0(long windowHandle, boolean confine); - private static native boolean warpPointer0(long windowHandle, int x, int y); + private static native void setPointerIcon0(long windowHandle, long handle); + private static native void setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); + private static native void confinePointer0(long windowHandle, boolean confine); + private static native void warpPointer0(long windowHandle, int x, int y); // Window styles private static final int NSBorderlessWindowMask = 0; diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index eb5913706..359b67b39 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -210,6 +210,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_initNSAp if(initialized) return JNI_TRUE; initialized = 1; + NewtCommon_init(env); + // This little bit of magic is needed in order to receive mouse // motion events and allow key focus to be properly transferred. // FIXME: are these Carbon APIs? They come from the @@ -349,7 +351,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_destroyPoint { NSCursor * c = (NSCursor*) (intptr_t) handle ; if( NULL != c && NO == [c isKindOfClass:[NSCursor class]] ) { - DBG_PRINT( "Not a NSCursor %p\n", c); + NewtCommon_throwNewRuntimeException(env, "Not a NSCursor %p", c); return; } DBG_PRINT( "destroyPointerIcon0 %p\n", c); @@ -960,7 +962,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 NSWindow *pWin = [mWin parentWindow]; DBG_PRINT( "windowClose.0 - %p [isNSWindow %d, isNewtWin %d], parent %p\n", mWin, isNSWin, isNewtWin, pWin); if( !isNewtWin ) { - DBG_PRINT( "windowClose.0 - Not a NEWT win - abort\n"); + NewtCommon_throwNewRuntimeException(env, "Not a NewtMacWindow %p", mWin); return; } NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -1316,38 +1318,36 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setAlwaysOnTo JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_getLocationOnScreen0 (JNIEnv *env, jclass unused, jlong win, jint src_x, jint src_y) { - NSObject *nsObj = (NSObject*) ((intptr_t) win); - NewtMacWindow * mWin = (NewtMacWindow*) nsObj; + NewtMacWindow *mWin = (NewtMacWindow*) (intptr_t) win; if( ![mWin isKindOfClass:[NewtMacWindow class]] ) { - DBG_PRINT("Not a NewtMacWindow %p\n", nsObj); + NewtCommon_throwNewRuntimeException(env, "Not a NewtMacWindow %p", mWin); return NULL; } NSPoint p0 = [mWin getLocationOnScreen: NSMakePoint(src_x, src_y)]; return (*env)->NewObject(env, pointClz, pointCstr, (jint)p0.x, (jint)p0.y); } -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerIcon0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerIcon0 (JNIEnv *env, jobject unused, jlong window, jlong handle) { NSCursor *c = (NSCursor*) (intptr_t) handle ; if ( NULL != c && NO == [c isKindOfClass:[NSCursor class]] ) { - DBG_PRINT("Not a NSCursor %p\n", c); - return JNI_FALSE; + NewtCommon_throwNewRuntimeException(env, "Not a NSCursor %p", c); + return; } NewtMacWindow *mWin = (NewtMacWindow*) (intptr_t) window; if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) { - DBG_PRINT("Not a NewtMacWindow %p\n", mWin); - return JNI_FALSE; + NewtCommon_throwNewRuntimeException(env, "Not a NewtMacWindow %p", mWin); + return; } NewtView* nView = (NewtView *) [mWin contentView]; if( ! [nView isKindOfClass:[NewtView class]] ) { - DBG_PRINT("Not a NewtView %p\n", nView); - return JNI_FALSE; + NewtCommon_throwNewRuntimeException(env, "Not a NewtView %p", nView); + return; } NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [nView setPointerIcon: c]; [pool release]; - return JNI_TRUE; } /* @@ -1355,24 +1355,23 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointe * Method: setPointerVisible0 * Signature: (JZ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerVisible0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerVisible0 (JNIEnv *env, jclass clazz, jlong window, jboolean hasFocus, jboolean mouseVisible) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) { - DBG_PRINT("Not a NewtMacWindow %p\n", mWin); - return JNI_FALSE; + NewtCommon_throwNewRuntimeException(env, "Not a NewtMacWindow %p", mWin); + return; } NewtView* nView = (NewtView *) [mWin contentView]; if( ! [nView isKindOfClass:[NewtView class]] ) { - DBG_PRINT("Not a NewtView %p\n", nView); - return JNI_FALSE; + NewtCommon_throwNewRuntimeException(env, "Not a NewtView %p", nView); + return; } NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [nView setMouseVisible: ( JNI_TRUE == mouseVisible ) ? YES : NO hasFocus: ( JNI_TRUE == hasFocus ) ? YES : NO]; [pool release]; - return JNI_TRUE; } /* @@ -1380,23 +1379,22 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointe * Method: confinePointer0 * Signature: (JZ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_confinePointer0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_confinePointer0 (JNIEnv *env, jclass clazz, jlong window, jboolean confine) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) { - DBG_PRINT("Not a NewtMacWindow %p\n", mWin); - return JNI_FALSE; + NewtCommon_throwNewRuntimeException(env, "Not a NewtMacWindow %p", mWin); + return; } NewtView* nView = (NewtView *) [mWin contentView]; if( ! [nView isKindOfClass:[NewtView class]] ) { - DBG_PRINT("Not a NewtView %p\n", nView); - return JNI_FALSE; + NewtCommon_throwNewRuntimeException(env, "Not a NewtView %p", nView); + return; } NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [nView setMouseConfined: ( JNI_TRUE == confine ) ? YES : NO]; [pool release]; - return JNI_TRUE; } /* @@ -1404,22 +1402,21 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_confinePo * Method: warpPointer0 * Signature: (JJII)V */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_warpPointer0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_warpPointer0 (JNIEnv *env, jclass clazz, jlong window, jint x, jint y) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) { - DBG_PRINT("Not a NewtMacWindow %p\n", mWin); - return JNI_FALSE; + NewtCommon_throwNewRuntimeException(env, "Not a NewtMacWindow %p", mWin); + return; } NewtView* nView = (NewtView *) [mWin contentView]; if( ! [nView isKindOfClass:[NewtView class]] ) { - DBG_PRINT("Not a NewtView %p\n", nView); - return JNI_FALSE; + NewtCommon_throwNewRuntimeException(env, "Not a NewtView %p", nView); + return; } NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [nView setMousePosition: [mWin newtRelClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y)]]; [pool release]; - return JNI_TRUE; } -- cgit v1.2.3 From 58756bbd1d1fd63bb84dbfe2d6419d63de2da7ba Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 5 Jan 2014 18:21:26 +0100 Subject: Bug 935: NEWT PointerIcon/Visibility: Perform OffscreenLayerSurface delegation _always_ in common WindowImpl ; Workaround for Windows+Applet issue. Perform OffscreenLayerSurface delegation _always_ in common WindowImpl Instead of performing OffscreenLayerSurface task on OSX's WindowDriver implementation, use generic implementation in WindowImpl for all platform exposing same behavior. ReparentAction takes care of reset/setup of PointerIcon/Visibility states. +++ This is also a workaround for Windows+Applet issue, where the PointerIcon gets periodically overridden by the AWT Component's icon. --- src/newt/classes/jogamp/newt/WindowImpl.java | 162 ++++++++++++++++----- .../jogamp/newt/driver/macosx/WindowDriver.java | 34 +---- 2 files changed, 127 insertions(+), 69 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 8d9fb8d7e..50f30f04d 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -34,56 +34,59 @@ package jogamp.newt; -import java.util.ArrayList; -import java.util.List; import java.lang.ref.WeakReference; import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.CapabilitiesChooser; +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.OffscreenLayerSurface; +import javax.media.nativewindow.SurfaceUpdatedListener; +import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.PointImmutable; +import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.RectangleImmutable; + +import jogamp.nativewindow.SurfaceUpdatedHelper; import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.IntBitfield; import com.jogamp.common.util.ReflectionUtil; +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.newt.Display; import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Display; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.newt.event.DoubleTapScrollGesture; import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.event.MouseEvent; +import com.jogamp.newt.event.MouseEvent.PointerType; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.event.NEWTEvent; import com.jogamp.newt.event.NEWTEventConsumer; -import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.WindowUpdateEvent; -import com.jogamp.newt.event.MouseEvent.PointerType; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.CapabilitiesChooser; -import javax.media.nativewindow.CapabilitiesImmutable; -import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindow; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.SurfaceUpdatedListener; -import javax.media.nativewindow.WindowClosingProtocol; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.InsetsImmutable; -import javax.media.nativewindow.util.Point; -import javax.media.nativewindow.util.Rectangle; -import javax.media.nativewindow.util.RectangleImmutable; - -import jogamp.nativewindow.SurfaceUpdatedHelper; public abstract class WindowImpl implements Window, NEWTEventConsumer { @@ -171,7 +174,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private String title = "Newt Window"; private boolean undecorated = false; private boolean alwaysOnTop = false; - private PointerIcon pointerIcon = null; + private PointerIconImpl pointerIcon = null; private boolean pointerVisible = true; private boolean pointerConfined = false; private LifecycleHook lifecycleHook = null; @@ -438,10 +441,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer createNativeImpl(); screen.addMonitorModeListener(monitorModeListenerImpl); setTitleImpl(title); - if( null != pointerIcon ) { - setPointerIconImpl((PointerIconImpl)pointerIcon); - } - setPointerVisibleImpl(pointerVisible); + setPointerIconIntern(pointerIcon); + setPointerVisibleIntern(pointerVisible); confinePointerImpl(pointerConfined); setKeyboardVisible(keyboardVisible); final long remainingV = waitForVisible(true, false); @@ -1379,6 +1380,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return; } + if( null == newParentWindow ) { + // CLIENT -> TOP: Reset Parent's Pointer State + setOffscreenPointerIcon(null); + setOffscreenPointerVisible(true, null); + } + // rearrange window tree if(null!=parentWindow && parentWindow instanceof Window) { ((Window)parentWindow).removeChild(WindowImpl.this); @@ -1461,6 +1468,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } destroy( becomesVisible ); operation = ReparentOperation.ACTION_NATIVE_CREATION ; + } else { + if( null != parentWindow ) { + // TOP -> CLIENT: Setup Parent's Pointer State + setOffscreenPointerIcon(pointerIcon); + setOffscreenPointerVisible(pointerVisible, pointerIcon); + } } } else { // Case @@ -1670,32 +1683,109 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return pointerVisible; } @Override - public final void setPointerVisible(boolean pointerVisible) { + public final void setPointerVisible(final boolean pointerVisible) { if(this.pointerVisible != pointerVisible) { boolean setVal = 0 == getWindowHandle(); if(!setVal) { - setVal = setPointerVisibleImpl(pointerVisible); + setVal = setPointerVisibleIntern(pointerVisible); } if(setVal) { this.pointerVisible = pointerVisible; } } } + private boolean setPointerVisibleIntern(final boolean pointerVisible) { + boolean res = setOffscreenPointerVisible(pointerVisible, pointerIcon); + return setPointerVisibleImpl(pointerVisible) || res; // accept onscreen or offscreen positive result! + } + /** + * Helper method to delegate {@link #setPointerVisibleImpl(boolean)} to + * {@link OffscreenLayerSurface#hideCursor()} or {@link OffscreenLayerSurface#setCursor(IOUtil.ClassResources, PointImmutable)}. + *

                      + * Note: JAWTWindow is an OffscreenLayerSurface. + *

                      + *

                      + * Performing OffscreenLayerSurface's setCursor(..)/hideCursor(), if available, + * gives same behavior on all platforms. + *

                      + *

                      + * If visible, implementation invokes {@link #setOffscreenPointerIcon(OffscreenLayerSurface, PointerIconImpl)} using the + * given defaultPointerIcon, otherwise {@link OffscreenLayerSurface#hideCursor()} is invoked. + *

                      + * @param pointerVisible true for visible, otherwise invisible. + * @param defaultPointerIcon default PointerIcon for visibility + * @param ols the {@link OffscreenLayerSurface} instance, if null method does nothing. + */ + private boolean setOffscreenPointerVisible(final boolean pointerVisible, final PointerIconImpl defaultPointerIcon) { + if( pointerVisible ) { + return setOffscreenPointerIcon(defaultPointerIcon); + } else { + final NativeWindow parent = getParent(); + if( parent instanceof OffscreenLayerSurface ) { + final OffscreenLayerSurface ols = (OffscreenLayerSurface) parent; + try { + return ols.hideCursor(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return false; + } @Override public final PointerIcon getPointerIcon() { return pointerIcon; } @Override public final void setPointerIcon(final PointerIcon pi) { - if( this.pointerIcon != pi ) { + final PointerIconImpl piImpl = (PointerIconImpl)pi; + if( this.pointerIcon != piImpl ) { if( isNativeValid() ) { runOnEDTIfAvail(true, new Runnable() { public void run() { - setPointerIconImpl((PointerIconImpl)pi); + setPointerIconIntern(piImpl); } } ); } - this.pointerIcon = pi; + this.pointerIcon = piImpl; + } + } + private void setPointerIconIntern(final PointerIconImpl pi) { + setOffscreenPointerIcon(pi); + setPointerIconImpl(pi); + } + /** + * Helper method to delegate {@link #setPointerIconIntern(PointerIconImpl)} to + * {@link OffscreenLayerSurface#setCursor(IOUtil.ClassResources, PointImmutable)}. + *

                      + * Note: JAWTWindow is an OffscreenLayerSurface. + *

                      + *

                      + * Performing OffscreenLayerSurface's setCursor(..), if available, + * gives same behavior on all platforms. + *

                      + *

                      + * Workaround for AWT/Windows bug within browser, + * where the PointerIcon gets periodically overridden + * by the AWT Component's icon. + *

                      + * @param ols the {@link OffscreenLayerSurface} instance, if null method does nothing. + * @param pi the {@link PointerIconImpl} instance, if null PointerIcon gets reset. + */ + private boolean setOffscreenPointerIcon(final PointerIconImpl pi) { + final NativeWindow parent = getParent(); + if( parent instanceof OffscreenLayerSurface ) { + final OffscreenLayerSurface ols = (OffscreenLayerSurface) parent; + try { + if( null != pi ) { + return ols.setCursor(pi.getResource(), pi.getHotspot()); + } else { + return ols.setCursor(null, null); // default + } + } catch (Exception e) { + e.printStackTrace(); + } } + return false; } @Override diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index edeb69f84..e2a57debc 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -39,8 +39,6 @@ import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; -import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; @@ -403,22 +401,6 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl public void run() { setPointerIcon0(getWindowHandle(), piHandle); } } ); - } else { - final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(this, true); - if( null != ols ) { - try { - setOLSPointer(ols, pi); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } - private static void setOLSPointer(final OffscreenLayerSurface ols, final PointerIconImpl pi) throws Exception { - if( null != pi ) { - ols.setCursor(pi.getResource(), pi.getHotspot()); - } else { - ols.setCursor(null, null); // default } } @@ -430,21 +412,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl public void run() { setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible); } } ); - return true; // setPointerVisible0 always returns true .. - } else { - final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(this, true); - if( null != ols ) { - try { - if( pointerVisible ) { - setOLSPointer(ols, (PointerIconImpl)getPointerIcon()); - } else { - ols.hideCursor(); - } - return true; - } catch (Exception e) { - e.printStackTrace(); - } - } + return true; } return false; } -- cgit v1.2.3 From bd98b927b910d9421e63cf0dbc2b746eec019f80 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 8 Jan 2014 21:56:26 +0100 Subject: Bug 935: NEWT PointerIcon: Utilize Toolkit Agnostic PixelFormat and Conversion Utilities (Allowing 'arbitrary' PointerIcon data input) Commit fe28bc125429b38cdcd016746081f4a6d521c6fd added the notion of toolkit agnostic PixelFormat and conversion utilities, utilized and further tested by this patch. +++ - PointerIcon is a PixelRectangle and hence holds the decoded data. This allows on-the-fly conversion if required as well as recreation w/o PNG re-decoding. - Using array-backed PointerIcon data where possible, allowing better performance when converting PixelFormat etc. - NEWT Display adds 'createPointerIcon(final IOUtil.ClassResources pngResource...' method to support agnostic PointerIcon creation. - NEWT Display adds methods to allow users to avoid PixelFormat and Buffer NIO type forced conversion: - PixelFormat getNativePointerIconPixelFormat() - boolean getNativePointerIconForceDirectNIO() +++ PNGImage -> PNGPixelRect Deleted: com.jogamp.opengl.util.texture.spi.PNGImage Added: com.jogamp.opengl.util.PNGPixelRect (We hope nobody was using PNGImage directly since it was a service-plugin for TextureIO) PNGPixelRect is a PixelRectangle PNGPixelRect actually is implemented OpenGL agnostic, however - since our PNGJ support lives under package 'jogamp.opengl.util.pngj' it cannot be moved up (yet). PNGPixelRect now handles all PixelFormat for the target format and also added support for grayscale+alpha (2 channels). The latter is force-converted to RGB* - similar to paletted. Further more, PNGPixelRect allows simply passing an OutputStream to write the PNG data. Used by: TextureIO and NEWT +++ - OffscreenSurfaceLayer's setCursor(..) uses the agnostic PixelRectangle instead of a PNG resource. - AWTMisc uses the PixelRectangle to produce the AWT Cursor and converts it to the required format. Hence same pixels are used for NEWT and AWT pointer/cursor icon. - TestGearsES2Newt and NewtAWTReparentingKeyAdapter 'tests' iterate over 3 custom PointerIcon when pressed 'c'. - JOGLNewtAppletBase uses the new custom PointerIcon 'newt/data/crosshair-lumina-trans-32x32.png', which is included in NEWT (213 bytes only). - --- .../assets-test/crosshair-lumina-trans-64x64.png | Bin 0 -> 424 bytes .../newt/data/crosshair-lumina-trans-32x32.png | Bin 0 -> 213 bytes make/scripts/tests.sh | 9 +- .../com/jogamp/opengl/util/PNGPixelRect.java | 335 +++++++++++++++++++++ .../com/jogamp/opengl/util/texture/TextureIO.java | 63 ++-- .../jogamp/opengl/util/texture/spi/PNGImage.java | 319 -------------------- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 17 +- .../media/nativewindow/OffscreenLayerSurface.java | 10 +- .../classes/jogamp/nativewindow/awt/AWTMisc.java | 48 ++- src/newt/classes/com/jogamp/newt/Display.java | 119 ++++++-- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 4 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 156 +++++++++- src/newt/classes/jogamp/newt/PointerIconImpl.java | 63 +++- src/newt/classes/jogamp/newt/WindowImpl.java | 8 +- src/newt/classes/jogamp/newt/driver/PNGIcon.java | 35 +-- .../jogamp/newt/driver/macosx/DisplayDriver.java | 58 ++-- .../jogamp/newt/driver/opengl/JoglUtilPNGIcon.java | 92 ++---- .../jogamp/newt/driver/windows/DisplayDriver.java | 50 ++- .../jogamp/newt/driver/x11/DisplayDriver.java | 38 +-- .../jogamp/newt/driver/x11/WindowDriver.java | 20 +- src/newt/native/MacWindow.m | 32 +- src/newt/native/WindowsWindow.c | 16 +- src/newt/native/X11Display.c | 15 +- src/newt/native/X11Window.c | 20 +- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 59 +++- .../test/junit/jogl/util/texture/PNGTstFiles.java | 54 ++++ .../jogl/util/texture/TestPNGImage00NEWT.java | 92 ------ .../jogl/util/texture/TestPNGImage01NEWT.java | 182 ----------- .../jogl/util/texture/TestPNGPixelRect00NEWT.java | 224 ++++++++++++++ .../jogl/util/texture/TestPNGPixelRect01NEWT.java | 198 ++++++++++++ .../util/texture/TestPixelFormatUtil01NEWT.java | 105 +++++++ .../util/texture/crosshair-lumina-trans-32x32.png | Bin 0 -> 213 bytes .../util/texture/crosshair-lumina-trans-64x64.png | Bin 0 -> 424 bytes .../parenting/NewtAWTReparentingKeyAdapter.java | 62 +++- 34 files changed, 1573 insertions(+), 930 deletions(-) create mode 100644 make/resources/assets-test/crosshair-lumina-trans-64x64.png create mode 100644 make/resources/assets/newt/data/crosshair-lumina-trans-32x32.png create mode 100644 src/jogl/classes/com/jogamp/opengl/util/PNGPixelRect.java delete mode 100644 src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGPixelRect00NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGPixelRect01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPixelFormatUtil01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-32x32.png create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-64x64.png (limited to 'src/newt/classes') diff --git a/make/resources/assets-test/crosshair-lumina-trans-64x64.png b/make/resources/assets-test/crosshair-lumina-trans-64x64.png new file mode 100644 index 000000000..9be285335 Binary files /dev/null and b/make/resources/assets-test/crosshair-lumina-trans-64x64.png differ diff --git a/make/resources/assets/newt/data/crosshair-lumina-trans-32x32.png b/make/resources/assets/newt/data/crosshair-lumina-trans-32x32.png new file mode 100644 index 000000000..92279640b Binary files /dev/null and b/make/resources/assets/newt/data/crosshair-lumina-trans-32x32.png differ diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index db852ce42..55973eb12 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -229,7 +229,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer -Djogl.debug.TileRenderer.PNG" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" - #D_ARGS="-Djogl.debug.PNGImage" + #D_ARGS="-Djogl.debug.PNG -Dnewt.debug.Display.PointerIcon" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" @@ -634,9 +634,10 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTBenchmarkNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage00NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.ToolPNG2CSource $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGPixelRect00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGPixelRect01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPixelFormatUtil00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPixelFormatUtil01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/PNGPixelRect.java b/src/jogl/classes/com/jogamp/opengl/util/PNGPixelRect.java new file mode 100644 index 000000000..1bbc12f32 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/PNGPixelRect.java @@ -0,0 +1,335 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.ByteBuffer; + +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.PixelFormat; +import javax.media.nativewindow.util.PixelRectangle; +import javax.media.nativewindow.util.PixelFormatUtil; + +import jogamp.opengl.Debug; +import jogamp.opengl.util.pngj.ImageInfo; +import jogamp.opengl.util.pngj.ImageLine; +import jogamp.opengl.util.pngj.ImageLineHelper; +import jogamp.opengl.util.pngj.PngReader; +import jogamp.opengl.util.pngj.PngWriter; +import jogamp.opengl.util.pngj.chunks.PngChunkPLTE; +import jogamp.opengl.util.pngj.chunks.PngChunkTRNS; +import jogamp.opengl.util.pngj.chunks.PngChunkTextVar; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.common.util.IOUtil; + +public class PNGPixelRect extends PixelRectangle.GenericPixelRect { + private static final boolean DEBUG = Debug.debug("PNG"); + + /** + * Reads a PNG image from the specified InputStream. + *

                      + * Implicitly converts the image to match the desired: + *

                        + *
                      • {@link PixelFormat}, see {@link #getPixelformat()}
                      • + *
                      • destStrideInBytes, see {@link #getStride()}
                      • + *
                      • destIsGLOriented, see {@link #isGLOriented()}
                      • + *
                      + *

                      + * + * @param in input stream + * @param destFmt desired destination {@link PixelFormat} incl. conversion, maybe null to use source {@link PixelFormat} + * @param destDirectBuffer if true, using a direct NIO buffer, otherwise an array backed buffer + * @param destMinStrideInBytes used if greater than PNG's stride, otherwise using PNG's stride. Stride is width * bytes-per-pixel. + * @param destIsGLOriented + * @return the newly created PNGPixelRect instance + * @throws IOException + */ + public static PNGPixelRect read(final InputStream in, + final PixelFormat ddestFmt, final boolean destDirectBuffer, final int destMinStrideInBytes, + final boolean destIsGLOriented) throws IOException { + final PngReader pngr = new PngReader(new BufferedInputStream(in), null); + final ImageInfo imgInfo = pngr.imgInfo; + final PngChunkPLTE plte = pngr.getMetadata().getPLTE(); + final PngChunkTRNS trns = pngr.getMetadata().getTRNS(); + final boolean indexed = imgInfo.indexed; + final boolean hasAlpha = indexed ? ( trns != null ) : imgInfo.alpha ; + + if(DEBUG) { + System.err.println("PNGPixelRect: "+imgInfo); + } + final int channels = indexed ? ( hasAlpha ? 4 : 3 ) : imgInfo.channels ; + final boolean isGrayAlpha = 2 == channels && imgInfo.greyscale && imgInfo.alpha; + if ( ! ( 1 == channels || 3 == channels || 4 == channels || isGrayAlpha ) ) { + throw new RuntimeException("PNGPixelRect can only handle Lum/RGB/RGBA [1/3/4 channels] or Lum+A (GA) images for now. Channels "+channels + " Paletted: " + indexed); + } + final int bytesPerPixel = indexed ? channels : imgInfo.bytesPixel ; + if ( ! ( 1 == bytesPerPixel || 3 == bytesPerPixel || 4 == bytesPerPixel || isGrayAlpha ) ) { + throw new RuntimeException("PNGPixelRect can only handle Lum/RGB/RGBA [1/3/4 bpp] images for now. BytesPerPixel "+bytesPerPixel); + } + if( channels != bytesPerPixel ) { + throw new RuntimeException("PNGPixelRect currently only handles Channels [1/3/4] == BytePerPixel [1/3/4], channels: "+channels+", bytesPerPixel "+bytesPerPixel); + } + final int width = imgInfo.cols; + final int height = imgInfo.rows; + final double dpiX, dpiY; + { + final double[] dpi = pngr.getMetadata().getDpi(); + dpiX = dpi[0]; + dpiY = dpi[1]; + } + final PixelFormat srcFmt; + if ( indexed ) { + if ( hasAlpha ) { + srcFmt = PixelFormat.RGBA8888; + } else { + srcFmt = PixelFormat.RGB888; + } + } else { + switch( channels ) { + case 1: srcFmt = PixelFormat.LUMINANCE; break; + case 2: srcFmt = isGrayAlpha ? PixelFormat.LUMINANCE : null; break; + case 3: srcFmt = PixelFormat.RGB888; break; + case 4: srcFmt = PixelFormat.RGBA8888; break; + default: srcFmt = null; + } + if( null == srcFmt ) { + throw new InternalError("XXX: channels: "+channels+", bytesPerPixel "+bytesPerPixel); + } + } + final PixelFormat destFmt; + if( null == ddestFmt ) { + if( isGrayAlpha ) { + destFmt = PixelFormat.BGRA8888; // save alpha value on gray-alpha + } else { + destFmt = srcFmt; // 1:1 + } + } else { + destFmt = ddestFmt; // user choice + } + final int destStrideInBytes = Math.max(destMinStrideInBytes, destFmt.bytesPerPixel() * width); + final ByteBuffer destPixels = destDirectBuffer ? Buffers.newDirectByteBuffer(destStrideInBytes * height) : + ByteBuffer.allocate(destStrideInBytes * height); + { + final int reqBytes = destStrideInBytes * height; + if( destPixels.limit() < reqBytes ) { + throw new IndexOutOfBoundsException("Dest buffer has insufficient bytes left, needs "+reqBytes+": "+destPixels); + } + } + final boolean vert_flip = destIsGLOriented; + + int[] rgbaScanline = indexed ? new int[width * channels] : null; + if(DEBUG) { + System.err.println("PNGPixelRect: indexed "+indexed+", alpha "+hasAlpha+", grayscale "+imgInfo.greyscale+", channels "+channels+"/"+imgInfo.channels+ + ", bytesPerPixel "+bytesPerPixel+"/"+imgInfo.bytesPixel+ + ", grayAlpha "+isGrayAlpha+", pixels "+width+"x"+height+", dpi "+dpiX+"x"+dpiY+", format "+srcFmt); + System.err.println("PNGPixelRect: destFormat "+destFmt+" ("+ddestFmt+", bytesPerPixel "+destFmt.bytesPerPixel()+", fast-path "+(destFmt==srcFmt)+"), destDirectBuffer "+destDirectBuffer+", destIsGLOriented (flip) "+destIsGLOriented); + System.err.println("PNGPixelRect: destStrideInBytes "+destStrideInBytes+" (destMinStrideInBytes "+destMinStrideInBytes+")"); + } + + for (int row = 0; row < height; row++) { + final ImageLine l1 = pngr.readRow(row); + int lineOff = 0; + int dataOff = vert_flip ? ( height - 1 - row ) * destStrideInBytes : row * destStrideInBytes; + if( indexed ) { + for (int j = width - 1; j >= 0; j--) { + rgbaScanline = ImageLineHelper.palette2rgb(l1, plte, trns, rgbaScanline); // reuse rgbaScanline and update if resized + dataOff = getPixelRGBA8ToAny(destFmt, destPixels, dataOff, rgbaScanline, lineOff, hasAlpha); + lineOff += bytesPerPixel; + } + } else if( 1 == channels ) { + for (int j = width - 1; j >= 0; j--) { + dataOff = getPixelLUMToAny(destFmt, destPixels, dataOff, (byte)l1.scanline[lineOff++], (byte)0xff); // Luminance, 1 bytesPerPixel + } + } else if( isGrayAlpha ) { + for (int j = width - 1; j >= 0; j--) { + dataOff = getPixelLUMToAny(destFmt, destPixels, dataOff, (byte)l1.scanline[lineOff++], (byte)l1.scanline[lineOff++]); // Luminance+Alpha, 2 bytesPerPixel + } + } else if( srcFmt == destFmt ) { // fast-path + for (int j = width - 1; j >= 0; j--) { + dataOff = getPixelRGBSame(destPixels, dataOff, l1.scanline, lineOff, bytesPerPixel); + lineOff += bytesPerPixel; + } + } else { + for (int j = width - 1; j >= 0; j--) { + dataOff = getPixelRGBA8ToAny(destFmt, destPixels, dataOff, l1.scanline, lineOff, hasAlpha); + lineOff += bytesPerPixel; + } + } + } + pngr.end(); + + return new PNGPixelRect(destFmt, new Dimension(width, height), destStrideInBytes, destIsGLOriented, destPixels, dpiX, dpiY); + } + + private static final int getPixelLUMToAny(PixelFormat dest_fmt, ByteBuffer d, int dOff, byte lum, byte alpha) { + switch(dest_fmt) { + case LUMINANCE: + d.put(dOff++, lum); + break; + case BGR888: + case RGB888: + d.put(dOff++, lum); + d.put(dOff++, lum); + d.put(dOff++, lum); + break; + case ABGR8888: + case ARGB8888: + d.put(dOff++, alpha); // A + d.put(dOff++, lum); + d.put(dOff++, lum); + d.put(dOff++, lum); + break; + case BGRA8888: + case RGBA8888: + d.put(dOff++, lum); + d.put(dOff++, lum); + d.put(dOff++, lum); + d.put(dOff++, alpha); // A + break; + default: + throw new InternalError("Unhandled format "+dest_fmt); + } + return dOff; + } + private static final int getPixelRGBA8ToAny(final PixelFormat dest_fmt, final ByteBuffer d, int dOff, final int[] scanline, final int lineOff, final boolean srcHasAlpha) { + final int p = PixelFormatUtil.convertToInt32(dest_fmt, (byte)scanline[lineOff], // R + (byte)scanline[lineOff+1], // G + (byte)scanline[lineOff+2], // B + srcHasAlpha ? (byte)scanline[lineOff+3] : (byte)0xff); // A + final int dbpp = dest_fmt.bytesPerPixel(); + d.put(dOff++, (byte) ( p )); // 1 + if( 1 < dbpp ) { + d.put(dOff++, (byte) ( p >>> 8 )); // 2 + d.put(dOff++, (byte) ( p >>> 16 )); // 3 + if( 4 == dbpp ) { + d.put(dOff++, (byte) ( p >>> 24 )); // 4 + } + } + return dOff; + } + private static final int getPixelRGBSame(final ByteBuffer d, int dOff, final int[] scanline, final int lineOff, final int bpp) { + d.put(dOff++, (byte)scanline[lineOff]); // R + if( 1 < bpp ) { + d.put(dOff++, (byte)scanline[lineOff + 1]); // G + d.put(dOff++, (byte)scanline[lineOff + 2]); // B + if( 4 == bpp ) { + d.put(dOff++, (byte)scanline[lineOff + 3]); // A + } + } + return dOff; + } + private int setPixelRGBA8(final ImageLine line, final int lineOff, final ByteBuffer d, final int dOff, final int bytesPerPixel, final boolean hasAlpha) { + final int b = hasAlpha ? 4-1 : 3-1; + if( d.limit() <= dOff + b ) { + throw new IndexOutOfBoundsException("Buffer has unsufficient bytes left, needs ["+dOff+".."+(dOff+b)+"]: "+d); + } + final int p = PixelFormatUtil.convertToInt32(hasAlpha ? PixelFormat.RGBA8888 : PixelFormat.RGB888, pixelformat, d, dOff); + line.scanline[lineOff ] = 0xff & p; // R + line.scanline[lineOff + 1] = 0xff & ( p >>> 8 ); // G + line.scanline[lineOff + 2] = 0xff & ( p >>> 16 ); // B + if(hasAlpha) { + line.scanline[lineOff + 3] = 0xff & ( p >>> 24 ); // A + } + return dOff + pixelformat.bytesPerPixel(); + } + + /** + * Creates a PNGPixelRect from data supplied by the end user. Shares + * data with the passed ByteBuffer. + * + * @param pixelformat + * @param size + * @param strideInBytes + * @param isGLOriented see {@link #isGLOriented()}. + * @param pixels + * @param dpiX + * @param dpiY + */ + public PNGPixelRect(final PixelFormat pixelformat, final DimensionImmutable size, + final int strideInBytes, final boolean isGLOriented, final ByteBuffer pixels, + final double dpiX, final double dpiY) { + super(pixelformat, size, strideInBytes, isGLOriented, pixels); + this.dpi = new double[] { dpiX, dpiY }; + } + public PNGPixelRect(final PixelRectangle src, final double dpiX, final double dpiY) { + super(src); + this.dpi = new double[] { dpiX, dpiY }; + } + private final double[] dpi; + + /** Returns the dpi of the image. */ + public double[] getDpi() { return dpi; } + + public void write(final OutputStream outstream, final boolean closeOutstream) throws IOException { + final int width = size.getWidth(); + final int height = size.getHeight(); + final int bytesPerPixel = pixelformat.bytesPerPixel(); + final ImageInfo imi = new ImageInfo(width, height, 8 /* bitdepth */, + (4 == bytesPerPixel) ? true : false /* alpha */, + (1 == bytesPerPixel) ? true : false /* grayscale */, + false /* indexed */); + + // open image for writing to a output stream + try { + final PngWriter png = new PngWriter(outstream, imi); + // add some optional metadata (chunks) + png.getMetadata().setDpi(dpi[0], dpi[1]); + png.getMetadata().setTimeNow(0); // 0 seconds fron now = now + png.getMetadata().setText(PngChunkTextVar.KEY_Title, "JogAmp PNGPixelRect"); + // png.getMetadata().setText("my key", "my text"); + final boolean hasAlpha = 4 == bytesPerPixel; + + final ImageLine l1 = new ImageLine(imi); + for (int row = 0; row < height; row++) { + int dataOff = isGLOriented ? ( height - 1 - row ) * strideInBytes : row * strideInBytes; + int lineOff = 0; + if(1 == bytesPerPixel) { + for (int j = width - 1; j >= 0; j--) { + l1.scanline[lineOff++] = pixels.get(dataOff++); // // Luminance, 1 bytesPerPixel + } + } else { + for (int j = width - 1; j >= 0; j--) { + dataOff = setPixelRGBA8(l1, lineOff, pixels, dataOff, bytesPerPixel, hasAlpha); + lineOff += bytesPerPixel; + } + } + png.writeRow(l1, row); + } + png.end(); + } finally { + if( closeOutstream ) { + IOUtil.close(outstream, false); + } + } + } +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java index 67ab5176d..0cde24db4 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java @@ -41,10 +41,12 @@ package com.jogamp.opengl.util.texture; import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.net.URL; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -52,9 +54,10 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.PixelFormat; import javax.media.opengl.GL; import javax.media.opengl.GL2; -import javax.media.opengl.GL2ES2; import javax.media.opengl.GL2GL3; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; @@ -63,11 +66,11 @@ import javax.media.opengl.GLProfile; import jogamp.opengl.Debug; import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.util.PNGPixelRect; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.texture.spi.DDSImage; import com.jogamp.opengl.util.texture.spi.JPEGImage; import com.jogamp.opengl.util.texture.spi.NetPbmTextureWriter; -import com.jogamp.opengl.util.texture.spi.PNGImage; import com.jogamp.opengl.util.texture.spi.SGIImage; import com.jogamp.opengl.util.texture.spi.TGAImage; import com.jogamp.opengl.util.texture.spi.TextureProvider; @@ -1166,27 +1169,29 @@ public class TextureIO { boolean mipmap, String fileSuffix) throws IOException { if (PNG.equals(fileSuffix)) { - PNGImage image = PNGImage.read(/*glp, */ stream); - if (pixelFormat == 0) { - pixelFormat = image.getGLFormat(); - } - if (internalFormat == 0) { + final PNGPixelRect image = PNGPixelRect.read(stream, null, true /* directBuffer */, 0 /* destMinStrideInBytes */, true /* destIsGLOriented */); + final GLPixelAttributes glpa = GLPixelAttributes.convert(image.getPixelformat(), glp); + if ( 0 == pixelFormat ) { + pixelFormat = glpa.format; + } // else FIXME: Actually not supported w/ preset pixelFormat! + if ( 0 == internalFormat ) { + final boolean hasAlpha = 4 == glpa.bytesPerPixel; if(glp.isGL2ES3()) { - internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA8:GL.GL_RGB8; + internalFormat = hasAlpha ? GL.GL_RGBA8 : GL.GL_RGB8; } else { - internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA:GL.GL_RGB; + internalFormat = hasAlpha ? GL.GL_RGBA : GL.GL_RGB; } } return new TextureData(glp, internalFormat, - image.getWidth(), - image.getHeight(), + image.getSize().getWidth(), + image.getSize().getHeight(), 0, pixelFormat, - image.getGLType(), + glpa.type, mipmap, false, false, - image.getData(), + image.getPixels(), null); } @@ -1392,29 +1397,7 @@ public class TextureIO { final int pixelFormat = pixelAttribs.format; final int pixelType = pixelAttribs.type; final int bytesPerPixel = pixelAttribs.bytesPerPixel; - final boolean reversedChannels; - switch(pixelFormat) { - case GL.GL_ALPHA: - case GL.GL_LUMINANCE: - case GL2ES2.GL_RED: - reversedChannels=false; - break; - case GL.GL_RGB: - reversedChannels=false; - break; - case GL.GL_RGBA: - reversedChannels=false; - break; - case GL2.GL_BGR: - reversedChannels=true; - break; - case GL.GL_BGRA: - reversedChannels=true; - break; - default: - reversedChannels=false; - break; - } + final PixelFormat pixFmt = pixelAttribs.getPixelFormat(); if ( ( 1 == bytesPerPixel || 3 == bytesPerPixel || 4 == bytesPerPixel) && ( pixelType == GL.GL_BYTE || pixelType == GL.GL_UNSIGNED_BYTE)) { ByteBuffer buf = (ByteBuffer) data.getBuffer(); @@ -1423,9 +1406,11 @@ public class TextureIO { } buf.rewind(); - PNGImage image = PNGImage.createFromData(data.getWidth(), data.getHeight(), -1f, -1f, - bytesPerPixel, reversedChannels, !data.getMustFlipVertically(), buf); - image.write(file, true); + final PNGPixelRect image = new PNGPixelRect(pixFmt, new Dimension(data.getWidth(), data.getHeight()), + 0 /* stride */, true /* isGLOriented */, buf /* pixels */, + -1f, -1f); + final OutputStream outs = new BufferedOutputStream(IOUtil.getFileOutputStream(file, true /* allowOverwrite */)); + image.write(outs, true /* close */); return true; } throw new IOException("PNG writer doesn't support this pixel format 0x"+Integer.toHexString(pixelFormat)+ diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java deleted file mode 100644 index 71cbbf97e..000000000 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java +++ /dev/null @@ -1,319 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.util.texture.spi; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.ByteBuffer; - -import javax.media.opengl.GL; - -import jogamp.opengl.Debug; -import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.ImageLine; -import jogamp.opengl.util.pngj.ImageLineHelper; -import jogamp.opengl.util.pngj.PngReader; -import jogamp.opengl.util.pngj.PngWriter; -import jogamp.opengl.util.pngj.chunks.PngChunkPLTE; -import jogamp.opengl.util.pngj.chunks.PngChunkTRNS; -import jogamp.opengl.util.pngj.chunks.PngChunkTextVar; - -import com.jogamp.common.nio.Buffers; -import com.jogamp.common.util.IOUtil; - -public class PNGImage { - private static final boolean DEBUG = Debug.debug("PNGImage"); - - /** - * Creates a PNGImage from data supplied by the end user. Shares - * data with the passed ByteBuffer. Assumes the data is already in - * the correct byte order for writing to disk, i.e., LUMINANCE, RGB or RGBA. - * Orientation is bottom-to-top (OpenGL coord. default) - * or top-to-bottom depending on isGLOriented. - * - * @param width - * @param height - * @param dpiX - * @param dpiY - * @param bytesPerPixel - * @param reversedChannels - * @param isGLOriented see {@link #isGLOriented()}. - * @param data - * @return - */ - public static PNGImage createFromData(int width, int height, double dpiX, double dpiY, - int bytesPerPixel, boolean reversedChannels, boolean isGLOriented, ByteBuffer data) { - return new PNGImage(width, height, dpiX, dpiY, bytesPerPixel, reversedChannels, isGLOriented, data); - } - - /** - * Reads a PNG image from the specified InputStream. - *

                      - * Implicitly flip image to GL orientation, see {@link #isGLOriented()}. - *

                      - */ - public static PNGImage read(InputStream in) throws IOException { - return new PNGImage(in); - } - - /** Reverse read and store, implicitly flip image to GL orientation, see {@link #isGLOriented()}. */ - private static final int getPixelRGBA8(ByteBuffer d, int dOff, int[] scanline, int lineOff, boolean hasAlpha) { - final int b = hasAlpha ? 4-1 : 3-1; - if( d.limit() <= dOff || dOff - b < 0 ) { - throw new IndexOutOfBoundsException("Buffer has unsufficient bytes left, needs ["+(dOff-b)+".."+dOff+"]: "+d); - } - if(hasAlpha) { - d.put(dOff--, (byte)scanline[lineOff + 3]); // A - } - d.put(dOff--, (byte)scanline[lineOff + 2]); // B - d.put(dOff--, (byte)scanline[lineOff + 1]); // G - d.put(dOff--, (byte)scanline[lineOff ]); // R - return dOff; - } - - /** Reverse write and store, implicitly flip image from current orientation, see {@link #isGLOriented()}. Handle reversed channels (BGR[A]). */ - private int setPixelRGBA8(ImageLine line, int lineOff, ByteBuffer d, int dOff, boolean hasAlpha) { - final int b = hasAlpha ? 4-1 : 3-1; - if( d.limit() <= dOff + b ) { - throw new IndexOutOfBoundsException("Buffer has unsufficient bytes left, needs ["+dOff+".."+(dOff+b)+"]: "+d); - } - if( reversedChannels ) { - if(hasAlpha) { - line.scanline[lineOff + 3] = d.get(dOff++); // A - } - line.scanline[lineOff + 2] = d.get(dOff++); // R - line.scanline[lineOff + 1] = d.get(dOff++); // G - line.scanline[lineOff ] = d.get(dOff++); // B - } else { - line.scanline[lineOff ] = d.get(dOff++); // R - line.scanline[lineOff + 1] = d.get(dOff++); // G - line.scanline[lineOff + 2] = d.get(dOff++); // B - if(hasAlpha) { - line.scanline[lineOff + 3] = d.get(dOff++); // A - } - } - return isGLOriented ? dOff - bytesPerPixel - bytesPerPixel : dOff; - } - - private PNGImage(int width, int height, double dpiX, double dpiY, int bytesPerPixel, boolean reversedChannels, boolean isGLOriented, ByteBuffer data) { - pixelWidth=width; - pixelHeight=height; - dpi = new double[] { dpiX, dpiY }; - if(4 == bytesPerPixel) { - glFormat = GL.GL_RGBA; - } else if (3 == bytesPerPixel) { - glFormat = GL.GL_RGB; - } else { - throw new InternalError("XXX: bytesPerPixel "+bytesPerPixel); - } - this.bytesPerPixel = bytesPerPixel; - this.reversedChannels = reversedChannels; - this.isGLOriented = isGLOriented; - this.data = data; - } - - private PNGImage(InputStream in) { - final PngReader pngr = new PngReader(new BufferedInputStream(in), null); - final ImageInfo imgInfo = pngr.imgInfo; - final PngChunkPLTE plte = pngr.getMetadata().getPLTE(); - final PngChunkTRNS trns = pngr.getMetadata().getTRNS(); - final boolean indexed = imgInfo.indexed; - final boolean hasAlpha = indexed ? ( trns != null ) : imgInfo.alpha ; - - final int channels = indexed ? ( hasAlpha ? 4 : 3 ) : imgInfo.channels ; - if ( ! ( 1 == channels || 3 == channels || 4 == channels ) ) { - throw new RuntimeException("PNGImage can only handle Lum/RGB/RGBA [1/3/4 channels] images for now. Channels "+channels + " Paletted: " + indexed); - } - - bytesPerPixel = indexed ? channels : imgInfo.bytesPixel ; - if ( ! ( 1 == bytesPerPixel || 3 == bytesPerPixel || 4 == bytesPerPixel ) ) { - throw new RuntimeException("PNGImage can only handle Lum/RGB/RGBA [1/3/4 bpp] images for now. BytesPerPixel "+bytesPerPixel); - } - if( channels != bytesPerPixel ) { - throw new RuntimeException("PNGImage currently only handles Channels [1/3/4] == BytePerPixel [1/3/4], channels: "+channels+", bytesPerPixel "+bytesPerPixel); - } - pixelWidth = imgInfo.cols; - pixelHeight = imgInfo.rows; - dpi = new double[2]; - { - final double[] dpi2 = pngr.getMetadata().getDpi(); - dpi[0]=dpi2[0]; - dpi[1]=dpi2[1]; - } - if ( indexed ) { - if ( hasAlpha ) { - glFormat = GL.GL_RGBA; - } else { - glFormat = GL.GL_RGB; - } - } else { - switch( channels ) { - case 1: glFormat = GL.GL_LUMINANCE; break; - case 3: glFormat = GL.GL_RGB; break; - case 4: glFormat = GL.GL_RGBA; break; - default: throw new InternalError("XXX: channels: "+channels+", bytesPerPixel "+bytesPerPixel); - } - } - if(DEBUG) { - System.err.println("PNGImage: "+imgInfo); - System.err.println("PNGImage: indexed "+indexed+", alpha "+hasAlpha+", channels "+channels+"/"+imgInfo.channels+ - ", bytesPerPixel "+bytesPerPixel+"/"+imgInfo.bytesPixel+ - ", pixels "+pixelWidth+"x"+pixelHeight+", dpi "+dpi[0]+"x"+dpi[1]+", glFormat 0x"+Integer.toHexString(glFormat)); - } - - data = Buffers.newDirectByteBuffer(bytesPerPixel * pixelWidth * pixelHeight); - reversedChannels = false; // RGB[A] - isGLOriented = true; - int dataOff = bytesPerPixel * pixelWidth * pixelHeight - 1; // start at end-of-buffer, reverse store - - int[] rgbaScanline = indexed ? new int[imgInfo.cols * channels] : null; - - for (int row = 0; row < pixelHeight; row++) { - final ImageLine l1 = pngr.readRow(row); - int lineOff = ( pixelWidth - 1 ) * bytesPerPixel ; // start w/ last pixel in line, reverse read (PNG top-left -> OpenGL bottom-left origin) - if( indexed ) { - for (int j = pixelWidth - 1; j >= 0; j--) { - rgbaScanline = ImageLineHelper.palette2rgb(l1, plte, trns, rgbaScanline); // reuse rgbaScanline and update if resized - dataOff = getPixelRGBA8(data, dataOff, rgbaScanline, lineOff, hasAlpha); - lineOff -= bytesPerPixel; - } - } else if( 1 == channels ) { - for (int j = pixelWidth - 1; j >= 0; j--) { - data.put(dataOff--, (byte)l1.scanline[lineOff--]); // Luminance, 1 bytesPerPixel - } - } else { - for (int j = pixelWidth - 1; j >= 0; j--) { - dataOff = getPixelRGBA8(data, dataOff, l1.scanline, lineOff, hasAlpha); - lineOff -= bytesPerPixel; - } - } - } - pngr.end(); - } - private final int pixelWidth, pixelHeight, glFormat, bytesPerPixel; - private final boolean reversedChannels; - private final boolean isGLOriented; - private final double[] dpi; - private final ByteBuffer data; - - /** Returns the width of the image. */ - public int getWidth() { return pixelWidth; } - - /** Returns the height of the image. */ - public int getHeight() { return pixelHeight; } - - /** Returns true if data has the channels reversed to BGR or BGRA, otherwise RGB or RGBA is expected. */ - public boolean getHasReversedChannels() { return reversedChannels; } - - /** - * Returns true if the drawable is rendered in - * OpenGL's coordinate system, origin at bottom left. - * Otherwise returns false, i.e. origin at top left. - *

                      - * Default impl. is true, i.e. OpenGL coordinate system. - *

                      - */ - public boolean isGLOriented() { return isGLOriented; } - - /** Returns the dpi of the image. */ - public double[] getDpi() { return dpi; } - - /** Returns the OpenGL format for this texture; e.g. GL.GL_LUMINANCE, GL.GL_RGB or GL.GL_RGBA. */ - public int getGLFormat() { return glFormat; } - - /** Returns the OpenGL data type: GL.GL_UNSIGNED_BYTE. */ - public int getGLType() { return GL.GL_UNSIGNED_BYTE; } - - /** Returns the bytes per pixel */ - public int getBytesPerPixel() { return bytesPerPixel; } - - /** Returns the raw data for this texture in the correct - (bottom-to-top) order for calls to glTexImage2D. */ - public ByteBuffer getData() { return data; } - - public void write(File out, boolean allowOverwrite) throws IOException { - final ImageInfo imi = new ImageInfo(pixelWidth, pixelHeight, 8, (4 == bytesPerPixel) ? true : false); // 8 bits per channel, no alpha - // open image for writing to a output stream - final OutputStream outs = new BufferedOutputStream(IOUtil.getFileOutputStream(out, allowOverwrite)); - try { - final PngWriter png = new PngWriter(outs, imi); - // add some optional metadata (chunks) - png.getMetadata().setDpi(dpi[0], dpi[1]); - png.getMetadata().setTimeNow(0); // 0 seconds fron now = now - png.getMetadata().setText(PngChunkTextVar.KEY_Title, "JogAmp PNGImage"); - // png.getMetadata().setText("my key", "my text"); - final boolean hasAlpha = 4 == bytesPerPixel; - final ImageLine l1 = new ImageLine(imi); - if( isGLOriented ) { - // start at last pixel at end-of-buffer, reverse read (OpenGL bottom-left -> PNG top-left origin) - int dataOff = ( pixelWidth * bytesPerPixel * ( pixelHeight - 1 ) ) + // full lines - 1 line - ( ( pixelWidth - 1 ) * bytesPerPixel ); // one line - 1 pixel - for (int row = 0; row < pixelHeight; row++) { - int lineOff = ( pixelWidth - 1 ) * bytesPerPixel ; // start w/ last pixel in line, reverse store (OpenGL bottom-left -> PNG top-left origin) - if(1 == bytesPerPixel) { - for (int j = pixelWidth - 1; j >= 0; j--) { - l1.scanline[lineOff--] = data.get(dataOff--); // // Luminance, 1 bytesPerPixel - } - } else { - for (int j = pixelWidth - 1; j >= 0; j--) { - dataOff = setPixelRGBA8(l1, lineOff, data, dataOff, hasAlpha); - lineOff -= bytesPerPixel; - } - } - png.writeRow(l1, row); - } - } else { - int dataOff = 0; // start at first pixel at start-of-buffer, normal read (same origin: top-left) - for (int row = 0; row < pixelHeight; row++) { - int lineOff = 0; // start w/ first pixel in line, normal store (same origin: top-left) - if(1 == bytesPerPixel) { - for (int j = pixelWidth - 1; j >= 0; j--) { - l1.scanline[lineOff++] = data.get(dataOff++); // // Luminance, 1 bytesPerPixel - } - } else { - for (int j = pixelWidth - 1; j >= 0; j--) { - dataOff = setPixelRGBA8(l1, lineOff, data, dataOff, hasAlpha); - lineOff += bytesPerPixel; - } - } - png.writeRow(l1, row); - } - } - png.end(); - } finally { - IOUtil.close(outs, false); - } - } - - @Override - public String toString() { return "PNGImage["+pixelWidth+"x"+pixelHeight+", dpi "+dpi[0]+" x "+dpi[1]+", bytesPerPixel "+bytesPerPixel+", reversedChannels "+reversedChannels+", "+data+"]"; } -} diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index b947505cb..ddf513180 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -38,7 +38,6 @@ package com.jogamp.nativewindow.awt; import com.jogamp.common.os.Platform; -import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; @@ -53,7 +52,6 @@ import java.awt.event.ComponentListener; import java.awt.event.HierarchyEvent; import java.awt.event.HierarchyListener; import java.applet.Applet; -import java.io.IOException; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -66,6 +64,7 @@ import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.PixelRectangle; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; import javax.media.nativewindow.util.Rectangle; @@ -433,19 +432,19 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override - public final boolean setCursor(final IOUtil.ClassResources resources, final PointImmutable hotSpot) throws IOException { + public final boolean setCursor(final PixelRectangle pixelrect, final PointImmutable hotSpot) { AWTEDTExecutor.singleton.invoke(false, new Runnable() { public void run() { Cursor c = null; - if( null == resources || null == hotSpot ) { + if( null == pixelrect || null == hotSpot ) { c = Cursor.getDefaultCursor(); } else { final java.awt.Point awtHotspot = new java.awt.Point(hotSpot.getX(), hotSpot.getY()); try { - c = AWTMisc.getCursor(resources, awtHotspot); - } catch (IOException e) { - e.printStackTrace(); - } + c = AWTMisc.getCursor(pixelrect, awtHotspot); + } catch (Exception e) { + e.printStackTrace(); + } } if( null != c ) { component.setCursor(c); @@ -455,7 +454,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override - public boolean hideCursor() { + public final boolean hideCursor() { AWTEDTExecutor.singleton.invoke(false, new Runnable() { public void run() { component.setCursor(AWTMisc.getNullCursor()); diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index 81983a7c2..cf8cf89d2 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -27,11 +27,9 @@ */ package javax.media.nativewindow; -import java.io.IOException; - +import javax.media.nativewindow.util.PixelRectangle; import javax.media.nativewindow.util.PointImmutable; -import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.locks.RecursiveLock; /** @@ -73,12 +71,12 @@ public interface OffscreenLayerSurface { /** * Optional method setting cursor in the corresponding on-screen surface/window, if exists. * - * @param resources maybe null for default cursor + * @param pixelrect cursor pixels, maybe null for default cursor * @param hotSpot maybe null for default cursor * @return true if successful, i.e. on-screen surface/window w/ cursor capabilities exists. Otherwise false. - * @throws IOException */ - public boolean setCursor(IOUtil.ClassResources resources, PointImmutable hotSpot) throws IOException; + public boolean setCursor(PixelRectangle pixelrect, PointImmutable hotSpot); + /** * Optional method hiding the cursor in the corresponding on-screen surface/window, if exists. * diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index b690aff4d..069cffeb8 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -37,21 +37,19 @@ import java.awt.Component; import java.awt.Container; import java.awt.Frame; import java.awt.image.BufferedImage; -import java.io.IOException; -import java.net.URLConnection; import java.util.HashMap; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JRootPane; import javax.swing.WindowConstants; -import javax.imageio.ImageIO; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.nativewindow.util.PixelRectangle; +import javax.media.nativewindow.util.PixelFormat; +import javax.media.nativewindow.util.PixelFormatUtil; import javax.swing.MenuSelectionManager; -import com.jogamp.common.util.IOUtil; - public class AWTMisc { public static JFrame getJFrame(Component c) { @@ -173,7 +171,7 @@ public class AWTMisc { MenuSelectionManager.defaultManager().clearSelectedPath(); } - static final HashMap cursorMap = new HashMap(); + static final HashMap cursorMap = new HashMap(); static final Cursor nulCursor; static { final Toolkit toolkit = Toolkit.getDefaultToolkit(); @@ -183,21 +181,43 @@ public class AWTMisc { public static synchronized Cursor getNullCursor() { return nulCursor; } - public static synchronized Cursor getCursor(IOUtil.ClassResources resources, Point hotSpot) throws IOException { - final String key = resources.getClass().getName()+":"+resources.resourcePaths[0]; + public static synchronized Cursor getCursor(PixelRectangle pixelrect, Point hotSpot) { + // 31 * x == (x << 5) - x + int hash = 31 + pixelrect.hashCode(); + hash = ((hash << 5) - hash) + hotSpot.hashCode(); + final Integer key = Integer.valueOf(hash); + Cursor cursor = cursorMap.get(key); if( null == cursor ) { - cursor = createAWTCursor(resources, hotSpot); + cursor = createCursor(pixelrect, hotSpot); cursorMap.put(key, cursor); } return cursor; } - private static synchronized Cursor createAWTCursor(IOUtil.ClassResources resources, Point hotSpot) throws IOException { - final URLConnection urlConn = resources.resolve(0); - final BufferedImage img = ImageIO.read(urlConn.getInputStream()); - + private static synchronized Cursor createCursor(PixelRectangle pixelrect, Point hotSpot) { + final int width = pixelrect.getSize().getWidth(); + final int height = pixelrect.getSize().getHeight(); + final BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); // PixelFormat.BGRA8888 + final PixelFormatUtil.PixelSink32 imgSink = new PixelFormatUtil.PixelSink32() { + public void store(int x, int y, int pixel) { + img.setRGB(x, y, pixel); + } + @Override + public final PixelFormat getPixelformat() { + return PixelFormat.BGRA8888; + } + @Override + public int getStride() { + return width*4; + } + @Override + public final boolean isGLOriented() { + return false; + } + }; + PixelFormatUtil.convert32(imgSink, pixelrect); final Toolkit toolkit = Toolkit.getDefaultToolkit(); - return toolkit.createCustomCursor(img, hotSpot, resources.resourcePaths[0]); + return toolkit.createCustomCursor(img, hotSpot, pixelrect.toString()); } public static WindowClosingProtocol.WindowClosingMode AWT2NWClosingOperation(int awtClosingOperation) { diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 8d1445f80..4b38fcca5 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -30,14 +30,14 @@ package com.jogamp.newt; import java.io.IOException; import java.lang.ref.WeakReference; -import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.PixelRectangle; +import javax.media.nativewindow.util.PixelFormat; import javax.media.nativewindow.util.PointImmutable; import jogamp.newt.Debug; @@ -47,6 +47,7 @@ import com.jogamp.newt.util.EDTUtil; public abstract class Display { public static final boolean DEBUG = Debug.debug("Display"); + protected static final boolean DEBUG_POINTER_ICON = Debug.debug("Display.PointerIcon"); /** return precomputed hashCode from FQN {@link #getFQName()} */ @Override @@ -66,7 +67,9 @@ public abstract class Display { /** * Native PointerIcon handle. *

                      - * Instances can be created via {@link Display}'s {@link Display#createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int) createPointerIcon(..)}. + * Instances can be created via {@link Display}'s + * {@link Display#createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int) createPointerIcon(pngResource, ..)} + * or {@link Display#createPointerIcon(PixelRectangle, int, int) createPointerIcon(pixelrect, ..)}. *

                      *

                      * Instance is {@link #destroy()}'ed automatically if it's {@link #getDisplay() associated Display} is destroyed. @@ -75,23 +78,65 @@ public abstract class Display { * Instance can be re-validated after destruction via {@link #validate()}. *

                      *

                      + * {@link PointerIcon} must not be {@link #destroy() destroyed} while in use! + *

                      + *

                      * {@link PointerIcon} may be {@link #destroy() destroyed} manually after use, * i.e. when no {@link Window} {@link Window#setPointerIcon(PointerIcon) uses them} anymore. + * However, this is not required. *

                      *

                      * PointerIcons can be used via {@link Window#setPointerIcon(PointerIcon)}. *

                      */ - public static interface PointerIcon { + public static interface PointerIcon extends PixelRectangle { /** - * @return the associated Display + * Always neatly packed, i.e. width * bytes_per_pixel. + *

                      + * {@inheritDoc} + *

                      */ - Display getDisplay(); + @Override + int getStride(); + + /** + * Always false, i.e. origin is TOP-LEFT. + *

                      + * {@inheritDoc} + *

                      + */ + boolean isGLOriented(); + + /** + * Computes a hash code over: + *
                        + *
                      • display
                      • + *
                      • pixelformat
                      • + *
                      • size
                      • + *
                      • stride
                      • + *
                      • isGLOriented
                      • + *
                      • pixels
                      • + *
                      • hotspot
                      • + *
                      + * Dismissing the native handle! + *

                      + * The hashCode shall be computed only once with first call + * and stored for later retrieval to enhance performance. + *

                      + *

                      + * {@inheritDoc} + *

                      + */ + @Override + int hashCode(); /** - * @return the single {@link IOUtil.ClassResources}. + * @return the associated Display */ - IOUtil.ClassResources getResource(); + Display getDisplay(); + + /** Returns the hotspot. */ + PointImmutable getHotspot(); /** * Returns true if valid, otherwise false. @@ -116,35 +161,69 @@ public abstract class Display { *

                      */ void destroy(); + } - /** Returns the size, i.e. width and height. */ - DimensionImmutable getSize(); + /** + * Returns the native platform's {@link PointerIcon.PixelFormat} for pointer-icon pixel data. + *

                      + * Using this value will avoid conversion within {@link #createPointerIcon(PixelRectangle, int, int)}. + *

                      + */ + public abstract PixelFormat getNativePointerIconPixelFormat(); - /** Returns the hotspot. */ - PointImmutable getHotspot(); + /** + * Returns the native platform's direct NIO buffer requirement pointer-icon pixel data. + *

                      + * Using this value will avoid conversion within {@link #createPointerIcon(PixelRectangle, int, int)}. + *

                      + */ + public abstract boolean getNativePointerIconForceDirectNIO(); - @Override - String toString(); - } + /** + * Returns the newly created {@link PointerIcon} or null if not implemented on platform. + *

                      + * See {@link PointerIcon} for lifecycle semantics. + *

                      + * + * @param pngResource single PNG resource for the {@link PointerIcon}. Only the first entry of {@link IOUtil.ClassResources#resourcePaths} is used. + * @param hotX pointer hotspot x-coord, origin is upper-left corner + * @param hotY pointer hotspot y-coord, origin is upper-left corner + * + * @throws IllegalArgumentException if pngResource is null or invalid + * @throws IllegalStateException if this Display instance is not {@link #isNativeValid() valid yet}. + * @throws IOException if the pngResource could not be {@link IOUtil.ClassResources#resolve(int) resolved} + * or via the PNG parser processing the input stream. + * + * @see PointerIcon + * @see Window#setPointerIcon(PointerIcon) + */ + public abstract PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) + throws IllegalArgumentException, IllegalStateException, IOException; /** * Returns the newly created {@link PointerIcon} or null if not implemented on platform. *

                      * See {@link PointerIcon} for lifecycle semantics. *

                      + *

                      + * In case {@link #getNativePointerIconPixelFormat()} or {@link #getNativePointerIconForceDirectNIO()} + * is not matched by the given pixelrect, the pixelrect is converted + * into the required {@link PixelFormat} and NIO type. + *

                      * - * @param pngResource single PNG resource, only the first entry of {@link IOUtil.ClassResources#resourcePaths} is used. + * @param pixelrect {@link PixelRectangle} source for the {@link PointerIcon} * @param hotX pointer hotspot x-coord, origin is upper-left corner * @param hotY pointer hotspot y-coord, origin is upper-left corner + * + * @throws IllegalArgumentException if pixelrect is null. * @throws IllegalStateException if this Display instance is not {@link #isNativeValid() valid yet}. - * @throws MalformedURLException - * @throws InterruptedException - * @throws IOException * * @see PointerIcon * @see Window#setPointerIcon(PointerIcon) + * @see #getNativePointerIconPixelFormat() + * @see #getNativePointerIconForceDirectNIO() */ - public abstract PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws IllegalStateException, MalformedURLException, InterruptedException, IOException; + public abstract PointerIcon createPointerIcon(final PixelRectangle pixelrect, final int hotX, final int hotY) throws IllegalArgumentException, IllegalStateException; /** * Manual trigger the native creation, if it is not done yet.
                      diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 7ffbc2e83..472672fd9 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -235,10 +235,10 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { glWindow.setVisible(true); glWindow.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); if( null == pointerIconTest ) { - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/jogamp-32x32.png" } ); + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/crosshair-lumina-trans-32x32.png" } ); final Display disp = glWindow.getScreen().getDisplay(); try { - pointerIconTest = disp.createPointerIcon(res, 16, 0); + pointerIconTest = disp.createPointerIcon(res, 16, 16); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 346c03b15..4c7169ec4 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -34,7 +34,9 @@ package jogamp.newt; +import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; +import com.jogamp.common.util.ReflectionUtil; import com.jogamp.newt.Display; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.event.NEWTEvent; @@ -43,17 +45,25 @@ import com.jogamp.newt.event.NEWTEventConsumer; import jogamp.newt.event.NEWTEventTask; import com.jogamp.newt.util.EDTUtil; +import com.jogamp.opengl.util.PNGPixelRect; import java.io.IOException; -import java.net.MalformedURLException; +import java.net.URLConnection; +import java.nio.ByteBuffer; import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.util.PixelFormatUtil; +import javax.media.nativewindow.util.PixelRectangle; +import javax.media.nativewindow.util.PixelFormat; +import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.PointImmutable; public abstract class DisplayImpl extends Display { private static int serialno = 1; + private static final boolean pngUtilAvail; static { NativeWindowFactory.addCustomShutdownHook(true /* head */, new Runnable() { @@ -64,8 +74,14 @@ public abstract class DisplayImpl extends Display { DisplayImpl.shutdownAll(); } }); + + final ClassLoader cl = DisplayImpl.class.getClassLoader(); + pngUtilAvail = ReflectionUtil.isClassAvailable("jogamp.opengl.util.pngj.PngReader", cl) && + ReflectionUtil.isClassAvailable("com.jogamp.opengl.util.PNGPixelRect", cl); } + public static final boolean isPNGUtilAvailable() { return pngUtilAvail; } + final ArrayList pointerIconList = new ArrayList(); /** Executed from EDT! */ @@ -86,13 +102,94 @@ public abstract class DisplayImpl extends Display { } @Override - public final PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { - return createPointerIcon(false /* isTemp */, pngResource, hotX, hotY); + public PixelFormat getNativePointerIconPixelFormat() { return PixelFormat.BGRA8888; } + @Override + public boolean getNativePointerIconForceDirectNIO() { return false; } + + @Override + public final PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) + throws IllegalArgumentException, IllegalStateException, IOException + { + if( !isNativeValid() ) { + throw new IllegalStateException("Display.createPointerIcon(1): Display invalid "+this); + } + if( null == pngResource || 0 >= pngResource.resourceCount() ) { + throw new IllegalArgumentException("Null or invalid pngResource "+pngResource); + } + if( !pngUtilAvail ) { + return null; + } + final PointerIconImpl[] res = { null }; + runOnEDTIfAvail(true, new Runnable() { + public void run() { + try { + if( !DisplayImpl.this.isNativeValid() ) { + throw new IllegalStateException("Display.createPointerIcon(2): Display invalid "+DisplayImpl.this); + } + final URLConnection urlConn = pngResource.resolve(0); + if( null == urlConn ) { + throw new IOException("Could not resolve "+pngResource.resourcePaths[0]); + } + final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), + getNativePointerIconPixelFormat(), + getNativePointerIconForceDirectNIO(), + 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); + final long handle = createPointerIconImplChecked(image.getPixelformat(), image.getSize().getWidth(), image.getSize().getHeight(), + image.getPixels(), hotX, hotY); + final PointImmutable hotspot = new Point(hotX, hotY); + if( DEBUG_POINTER_ICON ) { + System.err.println("createPointerIconPNG.0: "+image+", handle: "+toHexString(handle)+", hot "+hotspot); + } + if( 0 != handle ) { + res[0] = new PointerIconImpl(DisplayImpl.this, image, hotspot, handle); + if( DEBUG_POINTER_ICON ) { + System.err.println("createPointerIconPNG.0: "+res[0]); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } } ); + if( null != res[0] ) { + synchronized(pointerIconList) { + pointerIconList.add(res[0]); + } + } + return res[0]; } - PointerIcon createPointerIcon(final boolean isTemp, final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + + @Override + public final PointerIcon createPointerIcon(final PixelRectangle pixelrect, final int hotX, final int hotY) + throws IllegalArgumentException, IllegalStateException + { if( !isNativeValid() ) { throw new IllegalStateException("Display.createPointerIcon(1): Display invalid "+this); } + if( null == pixelrect ) { + throw new IllegalArgumentException("Null or pixelrect"); + } + final PixelRectangle fpixelrect; + if( getNativePointerIconPixelFormat() != pixelrect.getPixelformat() || pixelrect.isGLOriented() ) { + // conversion ! + fpixelrect = PixelFormatUtil.convert32(pixelrect, getNativePointerIconPixelFormat(), + 0 /* ddestStride */, false /* isGLOriented */, getNativePointerIconForceDirectNIO() ); + if( DEBUG_POINTER_ICON ) { + System.err.println("createPointerIconRES.0: Conversion-FMT "+pixelrect+" -> "+fpixelrect); + } + } else if( getNativePointerIconForceDirectNIO() && !Buffers.isDirect(pixelrect.getPixels()) ) { + // transfer to direct NIO + final ByteBuffer sBB = pixelrect.getPixels(); + final ByteBuffer dBB = Buffers.newDirectByteBuffer(sBB.array(), sBB.arrayOffset()); + fpixelrect = new PixelRectangle.GenericPixelRect(pixelrect.getPixelformat(), pixelrect.getSize(), pixelrect.getStride(), pixelrect.isGLOriented(), dBB); + if( DEBUG_POINTER_ICON ) { + System.err.println("createPointerIconRES.0: Conversion-NIO "+pixelrect+" -> "+fpixelrect); + } + } else { + fpixelrect = pixelrect; + if( DEBUG_POINTER_ICON ) { + System.err.println("createPointerIconRES.0: No conversion "+fpixelrect); + } + } final PointerIconImpl[] res = { null }; runOnEDTIfAvail(true, new Runnable() { public void run() { @@ -100,22 +197,63 @@ public abstract class DisplayImpl extends Display { if( !DisplayImpl.this.isNativeValid() ) { throw new IllegalStateException("Display.createPointerIcon(2): Display invalid "+DisplayImpl.this); } - res[0] = createPointerIconImpl(pngResource, hotX, hotY); + if( null != fpixelrect ) { + final long handle = createPointerIconImplChecked(fpixelrect.getPixelformat(), + fpixelrect.getSize().getWidth(), + fpixelrect.getSize().getHeight(), + fpixelrect.getPixels(), hotX, hotY); + if( 0 != handle ) { + res[0] = new PointerIconImpl(DisplayImpl.this, fpixelrect, new Point(hotX, hotY), handle); + } + } } catch (Exception e) { e.printStackTrace(); } } } ); - if( !isTemp ) { + if( null != res[0] ) { synchronized(pointerIconList) { pointerIconList.add(res[0]); } } return res[0]; } - /** Executed from EDT! */ - protected PointerIconImpl createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { - return null; + + /** + * Executed from EDT! + * + * @param pixelformat the pixels's format + * @param width the pixels's width + * @param height the pixels's height + * @param pixels the pixels + * @param hotX the PointerIcon's hot-spot x-coord + * @param hotY the PointerIcon's hot-spot x-coord + * @return if successful a valid handle (not null), otherwise null. + */ + protected final long createPointerIconImplChecked(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + if( getNativePointerIconPixelFormat() != pixelformat ) { + throw new IllegalArgumentException("Pixelformat no "+getNativePointerIconPixelFormat()+", but "+pixelformat); + } + if( getNativePointerIconForceDirectNIO() && !Buffers.isDirect(pixels) ) { + throw new IllegalArgumentException("pixel buffer is not direct "+pixels); + } + return createPointerIconImpl(pixelformat, width, height, pixels, hotX, hotY); + } + + /** + * Executed from EDT! + * + * @param pixelformat the pixels's format + * @param width the pixels's width + * @param height the pixels's height + * @param pixels the pixels + * @param hotX the PointerIcon's hot-spot x-coord + * @param hotY the PointerIcon's hot-spot x-coord + * @return if successful a valid handle (not null), otherwise null. + */ + protected long createPointerIconImpl(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + return 0; } + /** Executed from EDT! */ protected void destroyPointerIconImpl(final long displayHandle, long piHandle) { } diff --git a/src/newt/classes/jogamp/newt/PointerIconImpl.java b/src/newt/classes/jogamp/newt/PointerIconImpl.java index e2388be67..7c8535f20 100644 --- a/src/newt/classes/jogamp/newt/PointerIconImpl.java +++ b/src/newt/classes/jogamp/newt/PointerIconImpl.java @@ -27,27 +27,63 @@ */ package jogamp.newt; +import java.nio.ByteBuffer; + import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.PixelFormat; +import javax.media.nativewindow.util.PixelRectangle; import javax.media.nativewindow.util.PointImmutable; -import com.jogamp.common.util.IOUtil; -import com.jogamp.common.util.IOUtil.ClassResources; import com.jogamp.newt.Display; import com.jogamp.newt.Display.PointerIcon; public class PointerIconImpl implements PointerIcon { private final DisplayImpl display; - private final IOUtil.ClassResources resource; + private final PixelFormat pixelformat; private final DimensionImmutable size; + private final ByteBuffer pixels; private final PointImmutable hotspot; private long handle; - public PointerIconImpl(DisplayImpl display, ClassResources resource, final DimensionImmutable size, final PointImmutable hotspot, final long handle) { + private int hashCode = 0; + private volatile boolean hashCodeComputed = false; + + public PointerIconImpl(final DisplayImpl display, final PixelFormat pixelformat, final DimensionImmutable size, final ByteBuffer pixels, final PointImmutable hotspot, final long handle) { this.display = display; - this.resource = resource; + this.pixelformat = pixelformat; this.size = size; + this.pixels = pixels; this.hotspot = hotspot; + this.handle=handle; } + public PointerIconImpl(final DisplayImpl display, final PixelRectangle pixelrect, final PointImmutable hotspot, final long handle) { + this.display = display; + this.pixelformat = pixelrect.getPixelformat(); + this.size = pixelrect.getSize(); + this.pixels = pixelrect.getPixels(); + this.hotspot = hotspot; + this.handle=handle; + } + + @Override + public int hashCode() { + if( !hashCodeComputed ) { // DBL CHECKED OK VOLATILE + synchronized (this) { + if( !hashCodeComputed ) { + // 31 * x == (x << 5) - x + int hash = 31 + display.getFQName().hashCode(); + hash = ((hash << 5) - hash) + pixelformat.hashCode(); + hash = ((hash << 5) - hash) + size.hashCode(); + hash = ((hash << 5) - hash) + getStride(); + hash = ((hash << 5) - hash) + ( isGLOriented() ? 1 : 0); + hash = ((hash << 5) - hash) + pixels.hashCode(); + hashCode = ((hash << 5) - hash) + hotspot.hashCode(); + } + } + } + return hashCode; + } + public synchronized final long getHandle() { return handle; } public synchronized final long validatedHandle() { synchronized(display.pointerIconList) { @@ -57,8 +93,7 @@ public class PointerIconImpl implements PointerIcon { } if( 0 == handle ) { try { - final PointerIconImpl temp = (PointerIconImpl) display.createPointerIcon(true /* isTemp */, resource, hotspot.getX(), hotspot.getY()); - handle = temp.handle; + handle = display.createPointerIconImpl(pixelformat, size.getWidth(), size.getHeight(), pixels, hotspot.getX(), hotspot.getY()); return handle; } catch (Exception e) { e.printStackTrace(); @@ -71,7 +106,9 @@ public class PointerIconImpl implements PointerIcon { @Override public final Display getDisplay() { return display; } @Override - public final IOUtil.ClassResources getResource() { return resource; } + public final PixelFormat getPixelformat() { return pixelformat; } + @Override + public final ByteBuffer getPixels() { return pixels; } @Override public synchronized final boolean isValid() { return 0 != handle; } @Override @@ -116,11 +153,19 @@ public class PointerIconImpl implements PointerIcon { return size; } @Override + public final int getStride() { + return size.getWidth() * pixelformat.bytesPerPixel(); + } + @Override + public final boolean isGLOriented() { + return false; + } + @Override public final PointImmutable getHotspot() { return hotspot; } @Override public final String toString() { - return "PointerIcon["+DisplayImpl.toHexString(super.hashCode())+", "+display.getFQName()+", "+resource.resourcePaths[0]+", 0x"+Long.toHexString(handle)+", "+size+", "+hotspot+"]"; + return "PointerIcon[obj 0x"+Integer.toHexString(super.hashCode())+", "+display.getFQName()+", 0x"+Long.toHexString(handle)+", "+pixelformat+", "+size+", "+hotspot+", pixels "+pixels+"]"; } } \ No newline at end of file diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 50f30f04d..dc9affd63 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -53,6 +53,7 @@ import javax.media.nativewindow.WindowClosingProtocol; import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.PixelRectangle; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; import javax.media.nativewindow.util.Rectangle; @@ -61,7 +62,6 @@ import javax.media.nativewindow.util.RectangleImmutable; import jogamp.nativewindow.SurfaceUpdatedHelper; import com.jogamp.common.util.ArrayHashSet; -import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.IntBitfield; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.locks.LockFactory; @@ -1700,7 +1700,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** * Helper method to delegate {@link #setPointerVisibleImpl(boolean)} to - * {@link OffscreenLayerSurface#hideCursor()} or {@link OffscreenLayerSurface#setCursor(IOUtil.ClassResources, PointImmutable)}. + * {@link OffscreenLayerSurface#hideCursor()} or {@link OffscreenLayerSurface#setCursor(PixelRectangle, PointImmutable)}. *

                      * Note: JAWTWindow is an OffscreenLayerSurface. *

                      @@ -1755,7 +1755,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** * Helper method to delegate {@link #setPointerIconIntern(PointerIconImpl)} to - * {@link OffscreenLayerSurface#setCursor(IOUtil.ClassResources, PointImmutable)}. + * {@link OffscreenLayerSurface#setCursor(PixelRectangle, PointImmutable)} *

                      * Note: JAWTWindow is an OffscreenLayerSurface. *

                      @@ -1777,7 +1777,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final OffscreenLayerSurface ols = (OffscreenLayerSurface) parent; try { if( null != pi ) { - return ols.setCursor(pi.getResource(), pi.getHotspot()); + return ols.setCursor(pi, pi.getHotspot()); } else { return ols.setCursor(null, null); // default } diff --git a/src/newt/classes/jogamp/newt/driver/PNGIcon.java b/src/newt/classes/jogamp/newt/driver/PNGIcon.java index ffa62978f..967acd413 100644 --- a/src/newt/classes/jogamp/newt/driver/PNGIcon.java +++ b/src/newt/classes/jogamp/newt/driver/PNGIcon.java @@ -32,6 +32,7 @@ import java.net.MalformedURLException; import java.nio.ByteBuffer; import jogamp.newt.Debug; +import jogamp.newt.DisplayImpl; import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.ReflectionUtil; @@ -45,8 +46,7 @@ public class PNGIcon { Debug.initSingleton(); final ClassLoader cl = PNGIcon.class.getClassLoader(); - avail = ReflectionUtil.isClassAvailable("jogamp.newt.driver.opengl.JoglUtilPNGIcon", cl) && - ReflectionUtil.isClassAvailable("com.jogamp.opengl.util.texture.spi.PNGImage", cl); + avail = DisplayImpl.isPNGUtilAvailable() && ReflectionUtil.isClassAvailable("jogamp.newt.driver.opengl.JoglUtilPNGIcon", cl); } /** Returns true if PNG decoder is available. */ @@ -55,7 +55,11 @@ public class PNGIcon { } /** - * Implemented for X11. + * Special implementation for X11 Window Icons + *

                      + * The returned byte buffer is a direct buffer! + *

                      + * * @param resources * @param data_size * @param elem_bytesize @@ -73,29 +77,4 @@ public class PNGIcon { } throw new UnsupportedOperationException(err0); } - - /** - * Implemented for Windows. - * @param resources - * @param toBGRA if true, arranges stores in BGRA888 order, otherwise RGBA888 - * @param width - * @param height - * @param data_size - * @param resourcesIdx - * @return pixels with origin at upper-left corner. - * If storing RGBA8888, component R is located on the lowest 8-bit. - * If storing BGRA8888, component B is located on the lowest 8-bit. - * Component A is located on the highest 8-bit. - * - * @throws UnsupportedOperationException if not implemented - * @throws InterruptedException - * @throws IOException - * @throws MalformedURLException - */ - public static ByteBuffer singleToRGBAImage(IOUtil.ClassResources resources, int resourceIdx, boolean toBGRA, int[] width, int[] height, int[] data_size) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { - if( avail ) { - return jogamp.newt.driver.opengl.JoglUtilPNGIcon.singleToRGBAImage(resources, resourceIdx, toBGRA, width, height, data_size); - } - throw new UnsupportedOperationException(err0); - } } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index 30583c48c..d850a18af 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -34,28 +34,25 @@ package jogamp.newt.driver.macosx; -import java.io.IOException; -import java.net.MalformedURLException; +import java.net.URLConnection; import java.nio.Buffer; import java.nio.ByteBuffer; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.PixelFormat; +import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.newt.NewtFactory; +import com.jogamp.opengl.util.PNGPixelRect; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; -import jogamp.newt.PointerIconImpl; -import jogamp.newt.driver.PNGIcon; public class DisplayDriver extends DisplayImpl { - private static final int defaultIconWidth, defaultIconHeight; - private static final Buffer defaultIconData; + private static final PNGPixelRect defaultIconData; static { NEWTJNILibLoader.loadNEWT(); @@ -67,21 +64,23 @@ public class DisplayDriver extends DisplayImpl { throw new NativeWindowException("Failed to initialize jmethodIDs"); } { - final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; - Buffer data=null; - if( PNGIcon.isAvailable() ) { + PNGPixelRect image=null; + if( DisplayImpl.isPNGUtilAvailable() ) { try { + // NOTE: MUST BE DIRECT BUFFER, since NSBitmapImageRep uses buffer directly! final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons(); - data = PNGIcon.singleToRGBAImage(iconRes, iconRes.resourceCount()-1, false /* toBGRA */, width, height, data_size); + final URLConnection urlConn = iconRes.resolve(iconRes.resourceCount()-1); + image = PNGPixelRect.read(urlConn.getInputStream(), PixelFormat.BGRA8888, true /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); } catch (Exception e) { e.printStackTrace(); } } - defaultIconWidth = width[0]; - defaultIconHeight = height[0]; - defaultIconData = data; + defaultIconData = image; if( null != defaultIconData ) { - DisplayDriver.setAppIcon0(defaultIconData, defaultIconWidth, defaultIconHeight); + final Buffer pixels = defaultIconData.getPixels(); + DisplayDriver.setAppIcon0( + pixels, Buffers.getDirectBufferByteOffset(pixels), true /* pixels_is_direct */, + defaultIconData.getSize().getWidth(), defaultIconData.getSize().getHeight()); } } @@ -112,17 +111,20 @@ public class DisplayDriver extends DisplayImpl { aDevice.close(); } + /** + * {@inheritDoc} + *

                      + * NOTE: MUST BE DIRECT BUFFER, since NSBitmapImageRep uses buffer directly! + *

                      + */ @Override - protected PointerIconImpl createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { - if( PNGIcon.isAvailable() ) { - final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; - if( null != pngResource && 0 < pngResource.resourceCount() ) { - final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size); - return new PointerIconImpl( this, pngResource, new Dimension(width[0], height[0]), - new Point(hotX, hotY), createPointerIcon0(data, width[0], height[0], hotX, hotY)); - } - } - return null; + public final boolean getNativePointerIconForceDirectNIO() { return true; } + + @Override + protected final long createPointerIconImpl(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + return createPointerIcon0( + pixels, Buffers.getDirectBufferByteOffset(pixels), true /* pixels_is_direct */, + width, height, hotX, hotY); } @Override @@ -140,8 +142,8 @@ public class DisplayDriver extends DisplayImpl { private static native boolean initNSApplication0(); private static native void runNSApplication0(); private static native void stopNSApplication0(); - /* pp */ static native void setAppIcon0(Object iconData, int iconWidth, int iconHeight); - private static native long createPointerIcon0(Object iconData, int iconWidth, int iconHeight, int hotX, int hotY); + /* pp */ static native void setAppIcon0(Object pixels, int pixels_byte_offset, boolean pixels_is_direct, int width, int height); + private static native long createPointerIcon0(Object pixels, int pixels_byte_offset, boolean pixels_is_direct, int width, int height, int hotX, int hotY); private static native long destroyPointerIcon0(long handle); } diff --git a/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java b/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java index 216a0cb20..551929b8d 100644 --- a/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java +++ b/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java @@ -32,20 +32,22 @@ import java.net.MalformedURLException; import java.net.URLConnection; import java.nio.ByteBuffer; +import javax.media.nativewindow.util.PixelFormat; + import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.Platform; import com.jogamp.common.util.IOUtil; -import com.jogamp.opengl.util.texture.spi.PNGImage; +import com.jogamp.opengl.util.PNGPixelRect; public class JoglUtilPNGIcon { public static ByteBuffer arrayToX11BGRAImages(IOUtil.ClassResources resources, int[] data_size, int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { - final PNGImage[] images = new PNGImage[resources.resourceCount()]; + final PNGPixelRect[] images = new PNGPixelRect[resources.resourceCount()]; data_size[0] = 0; for(int i=0; iGetDirectBufferAddress(env, jiconData); +static NSImage * createNSImageFromData(JNIEnv *env, unsigned char * iconData, jint jiconWidth, jint jiconHeight) { + if( NULL != iconData ) { NSInteger iconWidth = (NSInteger) jiconWidth; NSInteger iconHeight = (NSInteger) jiconHeight; const NSInteger bpc = 8 /* bits per component */, spp=4 /* RGBA */, bpp = bpc * spp; @@ -319,28 +318,47 @@ static NSImage * createNSImageFromData(JNIEnv *env, jobject jiconData, jint jico * Method: setAppIcon0 */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_setAppIcon0 - (JNIEnv *env, jobject unused, jobject jiconData, jint jiconWidth, jint jiconHeight) + (JNIEnv *env, jobject unused, jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct, jint width, jint height) { + if( 0 == pixels ) { + return; + } NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSImage * nsImage = createNSImageFromData(env, jiconData, jiconWidth, jiconHeight); + // NOTE: MUST BE DIRECT BUFFER, since NSBitmapImageRep uses buffer directly! + unsigned char * pixelPtr = (unsigned char *) ( JNI_TRUE == pixels_is_direct ? + (*env)->GetDirectBufferAddress(env, pixels) : + (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) ); + NSImage * nsImage = createNSImageFromData(env, pixelPtr + pixels_byte_offset, width, height); if( NULL != nsImage ) { [nsImage autorelease]; [NSApp setApplicationIconImage: nsImage]; } + if ( JNI_FALSE == pixels_is_direct ) { + (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT); + } [pool release]; } JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_createPointerIcon0 - (JNIEnv *env, jobject unused, jobject jiconData, jint jiconWidth, jint jiconHeight, jint hotX, jint hotY) + (JNIEnv *env, jobject unused, jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct, jint width, jint height, jint hotX, jint hotY) { + if( 0 == pixels ) { + return 0; + } NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSImage * nsImage = createNSImageFromData(env, jiconData, jiconWidth, jiconHeight); + unsigned char * pixelPtr = (unsigned char *) ( JNI_TRUE == pixels_is_direct ? + (*env)->GetDirectBufferAddress(env, pixels) : + (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) ); + NSImage * nsImage = createNSImageFromData(env, pixelPtr + pixels_byte_offset, width, height); NSCursor * res = NULL; if( NULL != nsImage ) { [nsImage autorelease]; NSPoint hotP = { hotX, hotY }; res = [[NSCursor alloc] initWithImage: nsImage hotSpot: hotP]; } + if ( JNI_FALSE == pixels_is_direct ) { + (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT); + } [pool release]; DBG_PRINT( "createPointerIcon0 %p\n", res); return (jlong) (intptr_t) res; diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 1fd8d0039..c20e156c1 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -2368,9 +2368,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_warpPointer0 JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_DisplayDriver_createBGRA8888Icon0(JNIEnv *env, jobject _unused, - jobject data, jint data_offset, jint width, jint height, jboolean isCursor, jint hotX, jint hotY) { + jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct, jint width, jint height, jboolean isCursor, jint hotX, jint hotY) { - const unsigned char * data_ptr = (const unsigned char *) (*env)->GetDirectBufferAddress(env, data) + data_offset; + if( 0 == pixels ) { + return 0; + } + + const unsigned char * pixelPtr = (const unsigned char *) ( JNI_TRUE == pixels_is_direct ? + (*env)->GetDirectBufferAddress(env, pixels) : + (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) ); const int bytes = 4 * width * height; // BGRA8888 DWORD dwWidth, dwHeight; @@ -2403,10 +2409,14 @@ Java_jogamp_newt_driver_windows_DisplayDriver_createBGRA8888Icon0(JNIEnv *env, j hBitmap = CreateDIBSection(hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, (void **)&lpBits, NULL, (DWORD)0); - memcpy(lpBits, data_ptr, bytes); + memcpy(lpBits, pixelPtr + pixels_byte_offset, bytes); ReleaseDC(NULL,hdc); + if ( JNI_FALSE == pixels_is_direct ) { + (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT); + } + // Create an empty mask bitmap. HBITMAP hMonoBitmap = CreateBitmap(dwWidth,dwHeight,1,1,NULL); diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 19e733111..b62a9b234 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -678,13 +678,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage * Signature: (JJILjava/lang/Object;I)V */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_createPointerIcon0 - (JNIEnv *env, jclass clazz, jlong display, jobject data, jint data_offset, jint width, jint height, jint hotX, jint hotY) + (JNIEnv *env, jclass clazz, jlong display, jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct, jint width, jint height, jint hotX, jint hotY) { Cursor c; - if( 0 != data ) { + if( 0 != pixels ) { Display * dpy = (Display *) (intptr_t) display; - char * data_ptr = (char *) (*env)->GetDirectBufferAddress(env, data) + data_offset; + const unsigned char * pixelPtr = (const unsigned char *) ( JNI_TRUE == pixels_is_direct ? + (*env)->GetDirectBufferAddress(env, pixels) : + (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) ); XcursorImage ci; ci.version = 1; // XCURSOR_IMAGE_VERSION; ci.size = width; // nominal size (assume square ..) @@ -693,11 +695,14 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_createPointerI ci.xhot = hotX; ci.yhot = hotY; ci.delay = 0; - ci.pixels = (XcursorPixel *)(intptr_t)data_ptr; + ci.pixels = (XcursorPixel *)(intptr_t)(pixelPtr + pixels_byte_offset); c = XcursorImageLoadCursor (dpy, &ci); - DBG_PRINT( "X11: createPointerIcon0: %p %dx%d %d/%d -> %p\n", data_ptr, width, height, hotX, hotY, (void *)c); + if ( JNI_FALSE == pixels_is_direct ) { + (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT); + } + DBG_PRINT( "X11: createPointerIcon0: %p %dx%d %d/%d -> %p\n", (pixelPtr+pixels_byte_offset), width, height, hotX, hotY, (void *)c); } else { c = 0; diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index da2778004..54b85c243 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -512,7 +512,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 jint visualID, jlong javaObjectAtom, jlong windowDeleteAtom, jint x, jint y, jint width, jint height, jboolean autoPosition, int flags, - jint iconDataSize, jobject iconData) + jint pixelDataSize, jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct) { Display * dpy = (Display *)(intptr_t)display; Atom wm_delete_atom = (Atom)windowDeleteAtom; @@ -632,10 +632,16 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 { XEvent event; int left=0, right=0, top=0, bottom=0; - - if( 0 < iconDataSize && NULL != iconData ) { - const unsigned char * iconDataPtr = (const unsigned char *) (*env)->GetDirectBufferAddress(env, iconData); - NewtWindows_setIcon(dpy, window, (int)iconDataSize, iconDataPtr); + const unsigned char * pixelPtr = NULL; + + // NOTE: MUST BE DIRECT BUFFER, since _NET_WM_ICON Atom uses buffer directly! + DBG_PRINT("X11: CreateWindow icon: size %d, pixels %p, offset %d, direct %d\n", pixelDataSize, (void*)pixels, pixels_byte_offset, pixels_is_direct); + if( 0 < pixelDataSize && NULL != pixels ) { + pixelPtr = (const unsigned char *) ( JNI_TRUE == pixels_is_direct ? + (*env)->GetDirectBufferAddress(env, pixels) : + (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) ); + DBG_PRINT("X11: CreateWindow icon: NIO %p\n", pixelPtr); + NewtWindows_setIcon(dpy, window, (int)pixelDataSize, pixelPtr+pixels_byte_offset); } XMapWindow(dpy, window); @@ -643,6 +649,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 XSync(dpy, False); + if( JNI_FALSE == pixels_is_direct && NULL != pixelPtr ) { + (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT); + } + // send insets before visibility, allowing java code a proper sync point! NewtWindows_updateInsets(env, jwindow, dpy, window, &left, &right, &top, &bottom); (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_FALSE, JNI_TRUE); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 8cc676291..780338492 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -29,6 +29,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.newt; import java.io.IOException; +import java.net.URLConnection; import com.jogamp.common.util.IOUtil; import com.jogamp.newt.Display; @@ -47,6 +48,7 @@ import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.PNGPixelRect; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import javax.media.nativewindow.NativeWindowFactory; @@ -171,25 +173,55 @@ public class TestGearsES2NEWT extends UITestCase { } }); - final PointerIcon pointerIconOne; + final PointerIcon[] pointerIcons = { null, null, null }; { - PointerIcon _pointerIconOne = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); final Display disp = glWindow.getScreen().getDisplay(); disp.createNative(); - try { - _pointerIconOne = disp.createPointerIcon(res, 32, 0); - } catch (Exception e) { - e.printStackTrace(); + { + PointerIcon _pointerIcon = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/crosshair-lumina-trans-32x32.png" } ); + try { + _pointerIcon = disp.createPointerIcon(res, 16, 16); + System.err.println("Create PointerIcon #01: "+_pointerIcon); + } catch (Exception e) { + e.printStackTrace(); + } + pointerIcons[0] = _pointerIcon; + } + { + PointerIcon _pointerIcon = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); + try { + _pointerIcon = disp.createPointerIcon(res, 32, 0); + System.err.println("Create PointerIcon #02: "+_pointerIcon); + } catch (Exception e) { + e.printStackTrace(); + } + pointerIcons[1] = _pointerIcon; + } + { + PointerIcon _pointerIcon = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "crosshair-lumina-trans-64x64.png" } ); + try { + final URLConnection urlConn = res.resolve(0); + final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); + System.err.println("Create PointerIcon #03: "+image); + _pointerIcon = disp.createPointerIcon(image, 32, 32); + System.err.println("Create PointerIcon #03: "+_pointerIcon); + } catch (Exception e) { + e.printStackTrace(); + } + pointerIcons[2] = _pointerIcon; } - pointerIconOne = _pointerIconOne; } if( setPointerIcon ) { - glWindow.setPointerIcon(pointerIconOne); + glWindow.setPointerIcon(pointerIcons[0]); System.err.println("Set PointerIcon: "+glWindow.getPointerIcon()); } glWindow.addKeyListener(new KeyAdapter() { + int pointerIconIdx = 0; + @Override public void keyPressed(final KeyEvent e) { if( e.isAutoRepeat() ) { @@ -246,7 +278,14 @@ public class TestGearsES2NEWT extends UITestCase { final Thread t = glWindow.setExclusiveContextThread(null); System.err.println("[set pointer-icon pre]"); final PointerIcon currentPI = glWindow.getPointerIcon(); - glWindow.setPointerIcon( currentPI == pointerIconOne ? null : pointerIconOne); + final PointerIcon newPI; + if( pointerIconIdx >= pointerIcons.length ) { + newPI=null; + pointerIconIdx=0; + } else { + newPI=pointerIcons[pointerIconIdx++]; + } + glWindow.setPointerIcon( newPI ); System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); glWindow.setExclusiveContextThread(t); } }.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java new file mode 100644 index 000000000..bb9bc42a8 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java @@ -0,0 +1,54 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.util.texture; + +public class PNGTstFiles { + static public final String[] allBasenames = { + "test-ntscN_3-01-160x90", + "test-ntscN_4-01-160x90", + "test-ntscNG4-01-160x90", + "test-ntscI_3-01-160x90", + "test-ntscI_4-01-160x90", + "test-ntscIG3-01-160x90", + "test-ntscIG4-01-160x90", + "test-ntscP_3-01-160x90", + "test-ntscP_4-01-160x90", + "grayscale_texture", + "bug724-transparent-grey_orig", + "bug724-transparent-grey_gimpexp", + "crosshair-lumina-trans-32x32", + "crosshair-lumina-trans-64x64", + }; + static public final String[] greyBasenames = { + "grayscale_texture", + "bug724-transparent-grey_orig", + "bug724-transparent-grey_gimpexp", + "crosshair-lumina-trans-32x32", + "crosshair-lumina-trans-64x64", + }; +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java deleted file mode 100644 index 3ace5ab6a..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.jogl.util.texture; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URLConnection; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.FixMethodOrder; -import org.junit.runners.MethodSorters; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.texture.spi.PNGImage; - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestPNGImage00NEWT extends UITestCase { - @Test - public void testPNGReadWriteAndCompare() throws InterruptedException, IOException, MalformedURLException { - final File out1_f=new File(getSimpleTestName(".")+"-PNGImageTest1.png"); - final File out2_f=new File(getSimpleTestName(".")+"-PNGImageTest2.png"); - final File out2F_f=new File(getSimpleTestName(".")+"-PNGImageTest2Flipped.png"); - final File out2R_f=new File(getSimpleTestName(".")+"-PNGImageTest2Reversed.png"); - final File out2RF_f=new File(getSimpleTestName(".")+"-PNGImageTest2ReversedFlipped.png"); - final String url_s="jogl/util/data/av/test-ntsc01-57x32.png"; - URLConnection urlConn = IOUtil.getResource(url_s, this.getClass().getClassLoader()); - PNGImage image1 = PNGImage.read(urlConn.getInputStream()); - System.err.println("PNGImage - Orig: "+image1); - image1.write(out1_f, true); - { - Assert.assertEquals(image1.getData(), PNGImage.read(out1_f.toURI().toURL().openStream()).getData()); - } - - final PNGImage image2 = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), false /* reverseChannels */, image1.isGLOriented(), image1.getData()); - image2.write(out2_f, true); - { - Assert.assertEquals(image1.getData(), PNGImage.read(out2_f.toURI().toURL().openStream()).getData()); - } - - // flipped - final PNGImage image2F = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), false /* reverseChannels */, !image1.isGLOriented(), image1.getData()); - image2F.write(out2F_f, true); - - // reversed channels - final PNGImage image2R = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), true /* reverseChannels */, image1.isGLOriented(), image1.getData()); - image2R.write(out2R_f, true); - - // reversed channels and flipped - final PNGImage image2RF = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), true /* reverseChannels */, !image1.isGLOriented(), image1.getData()); - image2RF.write(out2RF_f, true); - } - - public static void main(String args[]) { - org.junit.runner.JUnitCore.main(TestPNGImage00NEWT.class.getName()); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java deleted file mode 100644 index 29e041908..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.jogl.util.texture; - -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URLConnection; - -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.FixMethodOrder; -import org.junit.runners.MethodSorters; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor; -import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.test.junit.util.QuitAdapter; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; -import com.jogamp.opengl.util.texture.TextureData; -import com.jogamp.opengl.util.texture.TextureIO; -import com.jogamp.opengl.util.texture.spi.PNGImage; - -/** - * Test reading and displaying a PNG image. - *

                      - * Main function accepts arbitrary PNG file name for manual tests. - *

                      - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestPNGImage01NEWT extends UITestCase { - - static boolean showFPS = false; - static long duration = 200; // ms - - public void testImpl(final InputStream istream) throws InterruptedException, IOException { - final PNGImage image = PNGImage.read(istream); - Assert.assertNotNull(image); - final boolean hasAlpha = 4 == image.getBytesPerPixel(); - System.err.println("PNGImage: "+image); - - final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); - final GLProfile glp = GLProfile.getGL2ES2(); - final GLCapabilities caps = new GLCapabilities(glp); - if( hasAlpha ) { - caps.setAlphaBits(1); - } - - final int internalFormat; - if(glp.isGL2ES3()) { - internalFormat = hasAlpha ? GL.GL_RGBA8 : GL.GL_RGB8; - } else { - internalFormat = hasAlpha ? GL.GL_RGBA : GL.GL_RGB; - } - final TextureData texData = new TextureData(glp, internalFormat, - image.getWidth(), - image.getHeight(), - 0, - new GLPixelAttributes(image.getGLFormat(), image.getGLType()), - false /* mipmap */, - false /* compressed */, - false /* must flip-vert */, - image.getData(), - null); - - // final TextureData texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.PNG); - System.err.println("TextureData: "+texData); - - final GLWindow glad = GLWindow.create(caps); - glad.setTitle("TestPNGImage01NEWT"); - // Size OpenGL to Video Surface - glad.setSize(texData.getWidth(), texData.getHeight()); - - // load texture from file inside current GL context to match the way - // the bug submitter was doing it - final TextureDraw01ES2Listener gle = new TextureDraw01ES2Listener( texData, 0 ) ; - // gle.setClearColor(new float[] { 1.0f, 0.0f, 0.0f, 1.0f } ); - - glad.addGLEventListener(gle); - glad.addGLEventListener(new GLEventListener() { - boolean shot = false; - - @Override public void init(GLAutoDrawable drawable) { - System.err.println("Chosen Caps: " + drawable.getChosenGLCapabilities()); - System.err.println("GL ctx: " + drawable.getGL().getContext()); - } - - @Override public void display(GLAutoDrawable drawable) { - // 1 snapshot - if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) { - shot = true; - snapshot(0, null, drawable.getGL(), screenshot, TextureIO.PNG, null); - } - } - - @Override public void dispose(GLAutoDrawable drawable) { } - @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } - }); - - Animator animator = new Animator(glad); - animator.setUpdateFPSFrames(60, showFPS ? System.err : null); - QuitAdapter quitAdapter = new QuitAdapter(); - glad.addKeyListener(quitAdapter); - glad.addWindowListener(quitAdapter); - glad.setVisible(true); - animator.start(); - - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() + * Main function accepts arbitrary PNG file name for manual tests. + *

                      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestPNGPixelRect01NEWT extends UITestCase { + static boolean showFPS = false; + static long duration = 200; // ms + + public void testImpl(final int num, final String basename, final InputStream istream, final PixelFormat destFmt) throws InterruptedException, IOException { + final GLProfile glp = GLProfile.getGL2ES2(); + final PNGPixelRect image = PNGPixelRect.read(istream, destFmt, true /* directBuffer */, 0 /* destMinStrideInBytes */, true /* destIsGLOriented */); + Assert.assertNotNull(image); + final GLPixelAttributes glpa = GLPixelAttributes.convert(image.getPixelformat(), glp); + final boolean hasAlpha = 4 == glpa.bytesPerPixel; + System.err.println("PNGPixelRect: "+basename+", "+image+", glpa "+glpa); + + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); + final GLCapabilities caps = new GLCapabilities(glp); + if( hasAlpha ) { + caps.setAlphaBits(1); + } + + final int internalFormat; + if(glp.isGL2ES3()) { + internalFormat = hasAlpha ? GL.GL_RGBA8 : GL.GL_RGB8; + } else { + internalFormat = hasAlpha ? GL.GL_RGBA : GL.GL_RGB; + } + final TextureData texData = new TextureData(glp, internalFormat, + image.getSize().getWidth(), + image.getSize().getHeight(), + 0, + glpa, + false /* mipmap */, + false /* compressed */, + false /* must flip-vert */, + image.getPixels(), + null); + + // final TextureData texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.PNG); + System.err.println("TextureData: "+texData); + + final GLWindow glad = GLWindow.create(caps); + glad.setTitle(this.getSimpleTestName(".")); + // Size OpenGL to Video Surface + glad.setSize(texData.getWidth(), texData.getHeight()); + + // load texture from file inside current GL context to match the way + // the bug submitter was doing it + final TextureDraw01ES2Listener gle = new TextureDraw01ES2Listener( texData, 0 ) ; + // gle.setClearColor(new float[] { 1.0f, 0.0f, 0.0f, 1.0f } ); + + glad.addGLEventListener(gle); + glad.addGLEventListener(new GLEventListener() { + boolean shot = false; + + @Override public void init(GLAutoDrawable drawable) { + System.err.println("Chosen Caps: " + drawable.getChosenGLCapabilities()); + System.err.println("GL ctx: " + drawable.getGL().getContext()); + } + + @Override public void display(GLAutoDrawable drawable) { + // 1 snapshot + if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) { + shot = true; + snapshot(num, basename, drawable.getGL(), screenshot, TextureIO.PNG, null); + } + } + + @Override public void dispose(GLAutoDrawable drawable) { } + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + + Animator animator = new Animator(glad); + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + QuitAdapter quitAdapter = new QuitAdapter(); + glad.addKeyListener(quitAdapter); + glad.addWindowListener(quitAdapter); + glad.setVisible(true); + animator.start(); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() "+destFmt); + final PixelRectangle imageConv1 = PixelFormatUtil.convert32(image1, destFmt, destMinStrideInBytes, destIsGLOriented, false /* nio */); + System.err.println("PNGPixelRect - Conv1: "+imageConv1); + final PixelRectangle imageConv2 = PixelFormatUtil.convert32(imageConv1, image1.getPixelformat(), image1.getStride(), image1.isGLOriented(), false /* nio */); + System.err.println("PNGPixelRect - Conv2: "+imageConv2); + Assert.assertEquals(image1.getPixels(), imageConv2.getPixels()); + } + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestPixelFormatUtil01NEWT.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-32x32.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-32x32.png new file mode 100644 index 000000000..92279640b Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-32x32.png differ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-64x64.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-64x64.png new file mode 100644 index 000000000..9be285335 Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-64x64.png differ diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 69874df6b..70d01ae66 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -28,25 +28,27 @@ package com.jogamp.opengl.test.junit.newt.parenting; import java.awt.Frame; +import java.net.URLConnection; import javax.media.nativewindow.util.InsetsImmutable; import com.jogamp.common.util.IOUtil; import com.jogamp.newt.Display; -import com.jogamp.newt.Window; import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.util.PNGPixelRect; public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final Frame frame; final NewtCanvasAWT newtCanvasAWT; final GLWindow glWindow; final QuitAdapter quitAdapter; - PointerIcon pointerIconTest = null; + PointerIcon[] pointerIcons = null; + int pointerIconIdx = 0; public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow, QuitAdapter quitAdapter) { this.frame = frame; @@ -144,13 +146,46 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { } } }.start(); } else if(e.getKeySymbol() == KeyEvent.VK_C ) { - if( null == pointerIconTest ) { - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/jogamp-32x32.png" } ); - final Display disp = glWindow.getScreen().getDisplay(); - try { - pointerIconTest = disp.createPointerIcon(res, 16, 0); - } catch (Exception err) { - err.printStackTrace(); + if( null == pointerIcons ) { + { + pointerIcons = new PointerIcon[3]; + final Display disp = glWindow.getScreen().getDisplay(); + { + PointerIcon _pointerIcon = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/crosshair-lumina-trans-32x32.png" } ); + try { + _pointerIcon = disp.createPointerIcon(res, 16, 16); + System.err.println("Create PointerIcon #01: "+_pointerIcon); + } catch (Exception ex) { + ex.printStackTrace(); + } + pointerIcons[0] = _pointerIcon; + } + { + PointerIcon _pointerIcon = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); + try { + _pointerIcon = disp.createPointerIcon(res, 32, 0); + System.err.println("Create PointerIcon #02: "+_pointerIcon); + } catch (Exception ex) { + ex.printStackTrace(); + } + pointerIcons[1] = _pointerIcon; + } + { + PointerIcon _pointerIcon = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "crosshair-lumina-trans-64x64.png" } ); + try { + final URLConnection urlConn = res.resolve(0); + final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); + System.err.println("Create PointerIcon #03: "+image); + _pointerIcon = disp.createPointerIcon(image, 32, 32); + System.err.println("Create PointerIcon #03: "+_pointerIcon); + } catch (Exception ex) { + ex.printStackTrace(); + } + pointerIcons[2] = _pointerIcon; + } } } new Thread() { @@ -158,7 +193,14 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final Thread t = glWindow.setExclusiveContextThread(null); System.err.println("[set pointer-icon pre]"); final PointerIcon currentPI = glWindow.getPointerIcon(); - glWindow.setPointerIcon( currentPI == pointerIconTest ? null : pointerIconTest); + final PointerIcon newPI; + if( pointerIconIdx >= pointerIcons.length ) { + newPI=null; + pointerIconIdx=0; + } else { + newPI=pointerIcons[pointerIconIdx++]; + } + glWindow.setPointerIcon( newPI ); System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); glWindow.setExclusiveContextThread(t); } }.start(); -- cgit v1.2.3 From 1a0b3287870beca22b0a03aa604fc6a5574a962b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 9 Jan 2014 18:34:33 +0100 Subject: Bug 676: Use proper pointer icon images (artwork) .. shameless inspired by KDE's Oxgen scheme .. (they are best) --- make/resources/assets-test/crosshair-grey-alpha-64x64.png | Bin 0 -> 424 bytes .../assets-test/crosshair-lumina-trans-64x64.png | Bin 424 -> 0 bytes .../resources/assets/newt/data/cross-grey-alpha-16x16.png | Bin 0 -> 286 bytes .../assets/newt/data/crosshair-lumina-trans-32x32.png | Bin 213 -> 0 bytes .../assets/newt/data/pointer-grey-alpha-16x24.png | Bin 0 -> 511 bytes .../com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 4 ++-- .../test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java | 12 ++++++------ .../opengl/test/junit/jogl/util/texture/PNGTstFiles.java | 8 ++++---- .../junit/jogl/util/texture/cross-grey-alpha-16x16.png | Bin 0 -> 286 bytes .../jogl/util/texture/crosshair-lumina-trans-32x32.png | Bin 213 -> 0 bytes .../jogl/util/texture/crosshair-lumina-trans-64x64.png | Bin 424 -> 0 bytes .../junit/jogl/util/texture/pointer-grey-alpha-16x24.png | Bin 0 -> 511 bytes .../newt/parenting/NewtAWTReparentingKeyAdapter.java | 14 +++++++------- 13 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 make/resources/assets-test/crosshair-grey-alpha-64x64.png delete mode 100644 make/resources/assets-test/crosshair-lumina-trans-64x64.png create mode 100644 make/resources/assets/newt/data/cross-grey-alpha-16x16.png delete mode 100644 make/resources/assets/newt/data/crosshair-lumina-trans-32x32.png create mode 100644 make/resources/assets/newt/data/pointer-grey-alpha-16x24.png create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/cross-grey-alpha-16x16.png delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-32x32.png delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-64x64.png create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/pointer-grey-alpha-16x24.png (limited to 'src/newt/classes') diff --git a/make/resources/assets-test/crosshair-grey-alpha-64x64.png b/make/resources/assets-test/crosshair-grey-alpha-64x64.png new file mode 100644 index 000000000..9be285335 Binary files /dev/null and b/make/resources/assets-test/crosshair-grey-alpha-64x64.png differ diff --git a/make/resources/assets-test/crosshair-lumina-trans-64x64.png b/make/resources/assets-test/crosshair-lumina-trans-64x64.png deleted file mode 100644 index 9be285335..000000000 Binary files a/make/resources/assets-test/crosshair-lumina-trans-64x64.png and /dev/null differ diff --git a/make/resources/assets/newt/data/cross-grey-alpha-16x16.png b/make/resources/assets/newt/data/cross-grey-alpha-16x16.png new file mode 100644 index 000000000..303c454fa Binary files /dev/null and b/make/resources/assets/newt/data/cross-grey-alpha-16x16.png differ diff --git a/make/resources/assets/newt/data/crosshair-lumina-trans-32x32.png b/make/resources/assets/newt/data/crosshair-lumina-trans-32x32.png deleted file mode 100644 index 92279640b..000000000 Binary files a/make/resources/assets/newt/data/crosshair-lumina-trans-32x32.png and /dev/null differ diff --git a/make/resources/assets/newt/data/pointer-grey-alpha-16x24.png b/make/resources/assets/newt/data/pointer-grey-alpha-16x24.png new file mode 100644 index 000000000..98b2c8640 Binary files /dev/null and b/make/resources/assets/newt/data/pointer-grey-alpha-16x24.png differ diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 472672fd9..7a36505c1 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -235,10 +235,10 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { glWindow.setVisible(true); glWindow.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); if( null == pointerIconTest ) { - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/crosshair-lumina-trans-32x32.png" } ); + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/cross-gray-alpha-16x16.png" } ); final Display disp = glWindow.getScreen().getDisplay(); try { - pointerIconTest = disp.createPointerIcon(res, 16, 16); + pointerIconTest = disp.createPointerIcon(res, 8, 8); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 780338492..059a930ed 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -179,9 +179,9 @@ public class TestGearsES2NEWT extends UITestCase { disp.createNative(); { PointerIcon _pointerIcon = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/crosshair-lumina-trans-32x32.png" } ); + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/cross-grey-alpha-16x16.png" } ); try { - _pointerIcon = disp.createPointerIcon(res, 16, 16); + _pointerIcon = disp.createPointerIcon(res, 8, 8); System.err.println("Create PointerIcon #01: "+_pointerIcon); } catch (Exception e) { e.printStackTrace(); @@ -190,9 +190,9 @@ public class TestGearsES2NEWT extends UITestCase { } { PointerIcon _pointerIcon = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/pointer-grey-alpha-16x24.png" } ); try { - _pointerIcon = disp.createPointerIcon(res, 32, 0); + _pointerIcon = disp.createPointerIcon(res, 0, 0); System.err.println("Create PointerIcon #02: "+_pointerIcon); } catch (Exception e) { e.printStackTrace(); @@ -201,12 +201,12 @@ public class TestGearsES2NEWT extends UITestCase { } { PointerIcon _pointerIcon = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "crosshair-lumina-trans-64x64.png" } ); + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); try { final URLConnection urlConn = res.resolve(0); final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); System.err.println("Create PointerIcon #03: "+image); - _pointerIcon = disp.createPointerIcon(image, 32, 32); + _pointerIcon = disp.createPointerIcon(image, 32, 0); System.err.println("Create PointerIcon #03: "+_pointerIcon); } catch (Exception e) { e.printStackTrace(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java index bb9bc42a8..e3ad7fc03 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java @@ -41,14 +41,14 @@ public class PNGTstFiles { "grayscale_texture", "bug724-transparent-grey_orig", "bug724-transparent-grey_gimpexp", - "crosshair-lumina-trans-32x32", - "crosshair-lumina-trans-64x64", + "cross-gray-alpha-16x16", + "pointer-gray-alpha-16x24", }; static public final String[] greyBasenames = { "grayscale_texture", "bug724-transparent-grey_orig", "bug724-transparent-grey_gimpexp", - "crosshair-lumina-trans-32x32", - "crosshair-lumina-trans-64x64", + "cross-gray-alpha-16x16", + "pointer-gray-alpha-16x24", }; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/cross-grey-alpha-16x16.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/cross-grey-alpha-16x16.png new file mode 100644 index 000000000..303c454fa Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/cross-grey-alpha-16x16.png differ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-32x32.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-32x32.png deleted file mode 100644 index 92279640b..000000000 Binary files a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-32x32.png and /dev/null differ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-64x64.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-64x64.png deleted file mode 100644 index 9be285335..000000000 Binary files a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-64x64.png and /dev/null differ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/pointer-grey-alpha-16x24.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/pointer-grey-alpha-16x24.png new file mode 100644 index 000000000..98b2c8640 Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/pointer-grey-alpha-16x24.png differ diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 70d01ae66..dc9aac8ea 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -152,9 +152,9 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final Display disp = glWindow.getScreen().getDisplay(); { PointerIcon _pointerIcon = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/crosshair-lumina-trans-32x32.png" } ); + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/cross-grey-alpha-16x16.png" } ); try { - _pointerIcon = disp.createPointerIcon(res, 16, 16); + _pointerIcon = disp.createPointerIcon(res, 8, 8); System.err.println("Create PointerIcon #01: "+_pointerIcon); } catch (Exception ex) { ex.printStackTrace(); @@ -163,9 +163,9 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { } { PointerIcon _pointerIcon = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/pointer-grey-alpha-16x24.png" } ); try { - _pointerIcon = disp.createPointerIcon(res, 32, 0); + _pointerIcon = disp.createPointerIcon(res, 0, 0); System.err.println("Create PointerIcon #02: "+_pointerIcon); } catch (Exception ex) { ex.printStackTrace(); @@ -174,12 +174,12 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { } { PointerIcon _pointerIcon = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "crosshair-lumina-trans-64x64.png" } ); + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); try { final URLConnection urlConn = res.resolve(0); final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); System.err.println("Create PointerIcon #03: "+image); - _pointerIcon = disp.createPointerIcon(image, 32, 32); + _pointerIcon = disp.createPointerIcon(image, 32, 0); System.err.println("Create PointerIcon #03: "+_pointerIcon); } catch (Exception ex) { ex.printStackTrace(); @@ -231,4 +231,4 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { } }.start(); } } -} \ No newline at end of file +} -- cgit v1.2.3 From 2b899a55e365aa03aeb234187600526777c1a9ac Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 9 Jan 2014 18:35:44 +0100 Subject: NEWT DisplayImpl/PointerIcon: Don't use blocking isNativeValid() before and after EDT entry (deadlock) --- src/newt/classes/jogamp/newt/DisplayImpl.java | 17 +++++++---------- src/newt/classes/jogamp/newt/PointerIconImpl.java | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 4c7169ec4..b485a4763 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -110,9 +110,6 @@ public abstract class DisplayImpl extends Display { public final PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws IllegalArgumentException, IllegalStateException, IOException { - if( !isNativeValid() ) { - throw new IllegalStateException("Display.createPointerIcon(1): Display invalid "+this); - } if( null == pngResource || 0 >= pngResource.resourceCount() ) { throw new IllegalArgumentException("Null or invalid pngResource "+pngResource); } @@ -123,8 +120,8 @@ public abstract class DisplayImpl extends Display { runOnEDTIfAvail(true, new Runnable() { public void run() { try { - if( !DisplayImpl.this.isNativeValid() ) { - throw new IllegalStateException("Display.createPointerIcon(2): Display invalid "+DisplayImpl.this); + if( !DisplayImpl.this.isNativeValidAsync() ) { + throw new IllegalStateException("Display.createPointerIcon: Display invalid "+DisplayImpl.this); } final URLConnection urlConn = pngResource.resolve(0); if( null == urlConn ) { @@ -162,9 +159,6 @@ public abstract class DisplayImpl extends Display { public final PointerIcon createPointerIcon(final PixelRectangle pixelrect, final int hotX, final int hotY) throws IllegalArgumentException, IllegalStateException { - if( !isNativeValid() ) { - throw new IllegalStateException("Display.createPointerIcon(1): Display invalid "+this); - } if( null == pixelrect ) { throw new IllegalArgumentException("Null or pixelrect"); } @@ -194,8 +188,8 @@ public abstract class DisplayImpl extends Display { runOnEDTIfAvail(true, new Runnable() { public void run() { try { - if( !DisplayImpl.this.isNativeValid() ) { - throw new IllegalStateException("Display.createPointerIcon(2): Display invalid "+DisplayImpl.this); + if( !DisplayImpl.this.isNativeValidAsync() ) { + throw new IllegalStateException("Display.createPointerIcon: Display invalid "+DisplayImpl.this); } if( null != fpixelrect ) { final long handle = createPointerIconImplChecked(fpixelrect.getPixelformat(), @@ -630,6 +624,9 @@ public abstract class DisplayImpl extends Display { public synchronized final boolean isNativeValid() { return null != aDevice; } + protected final boolean isNativeValidAsync() { + return null != aDevice; + } @Override public boolean isEDTRunning() { diff --git a/src/newt/classes/jogamp/newt/PointerIconImpl.java b/src/newt/classes/jogamp/newt/PointerIconImpl.java index 7c8535f20..840799d55 100644 --- a/src/newt/classes/jogamp/newt/PointerIconImpl.java +++ b/src/newt/classes/jogamp/newt/PointerIconImpl.java @@ -130,7 +130,7 @@ public class PointerIconImpl implements PointerIcon { } display.runOnEDTIfAvail(false, new Runnable() { public void run() { - if( display.isNativeValid() ) { + if( !display.isNativeValidAsync() ) { destroyOnEDT(display.getHandle()); } } } ); -- cgit v1.2.3 From bf0e93260dbd6cb8b6ee0cd10d81341906e62da9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 9 Jan 2014 18:44:35 +0100 Subject: Bug 676 - Add support for native Mouse Pointer rendering (Rasp.-Pi.) - Utilizing layer element 2000 for PointerIcon - Using NEWT PointerIcon code - Using MouseListener to update PointerIcon position - FIXME: Check whether we shall intercept sendMouseEvent directly (lag) Misc: - Properly open, assign and close the BCM display handle - Properly destroy the window (BCM element) - Prepare for multiple windows, set position and size --- make/scripts/tests.sh | 6 +- .../newt/driver/bcm/vc/iv/DisplayDriver.java | 131 ++++++++- .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 78 ++++- .../newt/driver/linux/LinuxMouseTracker.java | 12 +- .../jogamp/newt/driver/x11/DisplayDriver.java | 2 +- src/newt/native/bcm_vc_iv.c | 325 +++++++++++++++++++-- src/newt/native/bcm_vc_iv.h | 125 +++++++- 7 files changed, 620 insertions(+), 59 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 55973eb12..c1cdaeb5a 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -229,7 +229,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer -Djogl.debug.TileRenderer.PNG" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" - #D_ARGS="-Djogl.debug.PNG -Dnewt.debug.Display.PointerIcon" + D_ARGS="-Djogl.debug.PNG -Dnewt.debug.Display.PointerIcon" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" @@ -323,9 +323,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java index d8d93f123..3d563d88f 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java @@ -28,15 +28,28 @@ package jogamp.newt.driver.bcm.vc.iv; +import java.net.URLConnection; +import java.nio.Buffer; +import java.nio.ByteBuffer; + import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.util.PixelFormat; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.util.PNGPixelRect; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; +import jogamp.newt.PointerIconImpl; +import jogamp.newt.driver.linux.LinuxMouseTracker; import jogamp.opengl.egl.EGL; import jogamp.opengl.egl.EGLDisplayUtil; public class DisplayDriver extends DisplayImpl { + static final PNGPixelRect defaultPointerIconImage; + static { NEWTJNILibLoader.loadNEWT(); @@ -49,6 +62,18 @@ public class DisplayDriver extends DisplayImpl { if (!WindowDriver.initIDs()) { throw new NativeWindowException("Failed to initialize bcm.vc.iv Window jmethodIDs"); } + + PNGPixelRect image = null; + if( DisplayImpl.isPNGUtilAvailable() ) { + final IOUtil.ClassResources res = new IOUtil.ClassResources(DisplayDriver.class, new String[] { "newt/data/pointer-grey-alpha-16x24.png" } ); + try { + final URLConnection urlConn = res.resolve(0); + image = PNGPixelRect.read(urlConn.getInputStream(), PixelFormat.BGRA8888, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); + } catch (Exception e) { + e.printStackTrace(); + } + } + defaultPointerIconImage = image; } public static void initSingleton() { @@ -57,25 +82,127 @@ public class DisplayDriver extends DisplayImpl { public DisplayDriver() { + bcmHandle = 0; + activePointerIcon = 0; + activePointerIconVisible = false; } @Override protected void createNativeImpl() { // FIXME: map name to EGL_*_DISPLAY + bcmHandle = OpenBCMDisplay0(); aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + + defaultPointerIcon = (PointerIconImpl) createPointerIcon(defaultPointerIconImage, 0, 0); + if( DEBUG_POINTER_ICON ) { + System.err.println("Display.PointerIcon.createDefault: "+defaultPointerIcon); + } + if( null != defaultPointerIcon ) { + final LinuxMouseTracker lmt = LinuxMouseTracker.getSingleton(); + setPointerIconActive(defaultPointerIcon.getHandle(), lmt.getLastX(), lmt.getLastY()); + } } + private PointerIconImpl defaultPointerIcon = null; @Override protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); + CloseBCMDisplay0(bcmHandle); + bcmHandle = 0; } + /* pp */ final long getBCMHandle() { return bcmHandle; } + @Override protected void dispatchMessagesNative() { - DispatchMessages(); + DispatchMessages0(); + } + + // @Override + // public final PixelFormat getNativePointerIconPixelFormat() { return PixelFormat.BGRA8888; } + + @Override + protected final long createPointerIconImpl(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + return CreatePointerIcon(bcmHandle, pixels, width, height, hotX, hotY); + } + + @Override + protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) { + DestroyPointerIcon0(piHandle); + } + + /* pp */ void setPointerIconActive(long piHandle, final int x, final int y) { + synchronized(pointerIconSync) { + if( DEBUG_POINTER_ICON ) { + System.err.println("Display.PointerIcon.set.0: active ["+toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"] -> "+toHexString(piHandle)); + } + if( 0 != activePointerIcon && activePointerIconVisible ) { + SetPointerIcon0(bcmHandle, activePointerIcon, false, x, y); + } + if( 0 == piHandle && null != defaultPointerIcon ) { + piHandle = defaultPointerIcon.getHandle(); + } + if( 0 != piHandle ) { + SetPointerIcon0(bcmHandle, piHandle, true, x, y); + activePointerIconVisible = true; + } else { + activePointerIconVisible = false; + } + activePointerIcon = piHandle; + if( DEBUG_POINTER_ICON ) { + System.err.println("Display.PointerIcon.set.X: active ["+toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"]"); + } + } + } + /* pp */ void setActivePointerIconVisible(final boolean visible, final int x, final int y) { + synchronized(pointerIconSync) { + if( DEBUG_POINTER_ICON ) { + System.err.println("Display.PointerIcon.visible: active ["+toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"] -> visible "+visible); + } + if( activePointerIconVisible != visible ) { + if( 0 != activePointerIcon ) { + SetPointerIcon0(bcmHandle, activePointerIcon, visible, x, y); + } + activePointerIconVisible = visible; + } + } + } + /* pp */ void moveActivePointerIcon(final int x, final int y) { + synchronized(pointerIconSync) { + if( DEBUG_POINTER_ICON ) { + System.err.println("Display.PointerIcon.move: active ["+toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"], "+x+"/"+y); + } + if( 0 != activePointerIcon && activePointerIconVisible ) { + MovePointerIcon0(activePointerIcon, x, y); + } + } } + //---------------------------------------------------------------------- + // Internals only + // + protected static native boolean initIDs(); - private native void DispatchMessages(); + private static native long OpenBCMDisplay0(); + private static native void CloseBCMDisplay0(long handle); + + private static long CreatePointerIcon(long bcmHandle, Buffer pixels, int width, int height, int hotX, int hotY) { + final boolean pixels_is_direct = Buffers.isDirect(pixels); + return CreatePointerIcon0(pixels_is_direct ? pixels : Buffers.getArray(pixels), + pixels_is_direct ? Buffers.getDirectBufferByteOffset(pixels) : Buffers.getIndirectBufferByteOffset(pixels), + pixels_is_direct, + width, height, hotX, hotY); + } + private static native long CreatePointerIcon0(Object pixels, int pixels_byte_offset, boolean pixels_is_direct, int width, int height, int hotX, int hotY); + private static native void DestroyPointerIcon0(long handle); + private static native void SetPointerIcon0(long bcmHandle, long handle, boolean enable, int x, int y); + private static native void MovePointerIcon0(long handle, int x, int y); + + private static native void DispatchMessages0(); + + private long bcmHandle; + private long activePointerIcon; + private boolean activePointerIconVisible; + private final Object pointerIconSync = new Object(); } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index 4d4977776..5109d0fbb 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -39,7 +39,10 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; +import com.jogamp.newt.event.MouseListener; +import com.jogamp.newt.event.MouseAdapter; +import jogamp.newt.PointerIconImpl; import jogamp.newt.WindowImpl; import jogamp.newt.driver.linux.LinuxEventDeviceTracker; import jogamp.newt.driver.linux.LinuxMouseTracker; @@ -53,6 +56,8 @@ public class WindowDriver extends WindowImpl { } public WindowDriver() { + linuxMouseTracker = LinuxMouseTracker.getSingleton(); + linuxEventDeviceTracker = LinuxEventDeviceTracker.getSingleton(); } @Override @@ -60,9 +65,12 @@ public class WindowDriver extends WindowImpl { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); } + final ScreenDriver screen = (ScreenDriver) getScreen(); + final DisplayDriver display = (DisplayDriver) screen.getDisplay(); + // Create own screen/device resource instance allowing independent ownership, // while still utilizing shared EGL resources. - final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); + final AbstractGraphicsScreen aScreen = screen.getGraphicsScreen(); final EGLGraphicsDevice aDevice = (EGLGraphicsDevice) aScreen.getDevice(); final EGLGraphicsDevice eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(aDevice.getNativeDisplayID(), aDevice.getConnection(), aDevice.getUnitID()); final DefaultGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aScreen.getIndex()); @@ -78,7 +86,8 @@ public class WindowDriver extends WindowImpl { chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque()); } setGraphicsConfiguration(cfg); - nativeWindowHandle = CreateWindow(getWidth(), getHeight(), chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits()); + nativeWindowHandle = CreateWindow0(display.getBCMHandle(), getX(), getY(), getWidth(), getHeight(), + chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits()); if (nativeWindowHandle == 0) { throw new NativeWindowException("Error creating egl window: "+cfg); } @@ -88,21 +97,37 @@ public class WindowDriver extends WindowImpl { throw new NativeWindowException("Error native Window Handle is null"); } windowHandleClose = nativeWindowHandle; - addWindowListener(LinuxMouseTracker.getSingleton()); - addWindowListener(LinuxEventDeviceTracker.getSingleton()); + + addWindowListener(linuxEventDeviceTracker); + addWindowListener(linuxMouseTracker); + addMouseListener(mousePointerTracker); focusChanged(false, true); } + final MouseListener mousePointerTracker = new MouseAdapter() { + @Override + public void mouseMoved(com.jogamp.newt.event.MouseEvent e) { + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + display.moveActivePointerIcon(e.getX(), e.getY()); + } + + @Override + public void mouseDragged(com.jogamp.newt.event.MouseEvent e) { + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + display.moveActivePointerIcon(e.getX(), e.getY()); + } + }; @Override protected void closeNativeImpl() { + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getGraphicsConfiguration().getScreen().getDevice(); - removeWindowListener(LinuxMouseTracker.getSingleton()); - removeWindowListener(LinuxEventDeviceTracker.getSingleton()); + removeMouseListener(mousePointerTracker); + removeWindowListener(linuxMouseTracker); + removeWindowListener(linuxEventDeviceTracker); if(0!=windowHandleClose) { - CloseWindow(windowHandleClose, windowUserData); - windowUserData=0; + CloseWindow0(display.getBCMHandle(), windowHandleClose); } eglDevice.close(); @@ -157,23 +182,44 @@ public class WindowDriver extends WindowImpl { // nop .. } + /** + @Override + public final void sendMouseEvent(final short eventType, final int modifiers, + final int x, final int y, final short button, final float rotation) { + if( MouseEvent.MOUSE_MOVED == eventType ) { + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + display.moveActivePointerIcon(x, y); + } + super.sendMouseEvent(eventType, modifiers, x, y, button, rotation); + } */ + + @Override + protected void setPointerIconImpl(final PointerIconImpl pi) { + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + display.setPointerIconActive(null != pi ? pi.validatedHandle() : 0, linuxMouseTracker.getLastX(), linuxMouseTracker.getLastY()); + } + + @Override + protected boolean setPointerVisibleImpl(final boolean pointerVisible) { + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + display.setActivePointerIconVisible(pointerVisible, linuxMouseTracker.getLastX(), linuxMouseTracker.getLastY()); + return true; + } + //---------------------------------------------------------------------- // Internals only // + private final LinuxMouseTracker linuxMouseTracker; + private final LinuxEventDeviceTracker linuxEventDeviceTracker; protected static native boolean initIDs(); - private native long CreateWindow(int width, int height, boolean opaque, int alphaBits); - private native long RealizeWindow(long eglWindowHandle); - private native int CloseWindow(long eglWindowHandle, long userData); + private native long CreateWindow0(long bcmDisplay, int x, int y, int width, int height, boolean opaque, int alphaBits); + private native void CloseWindow0(long bcmDisplay, long eglWindowHandle); private native void setVisible0(long eglWindowHandle, boolean visible); + private native void setPos0(long eglWindowHandle, int x, int y); 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 long nativeWindowHandle; private long windowHandleClose; - private long windowUserData; } diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java index 1e314b7f4..9d7b8931b 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java @@ -68,9 +68,14 @@ public class LinuxMouseTracker implements WindowListener { private short buttonDown = 0; private int old_x = 0; private int old_y = 0; + private volatile int lastFocusedX = 0; + private volatile int lastFocusedY = 0; private short old_buttonDown = 0; private WindowImpl focusedWindow = null; - private MouseDevicePoller mouseDevicePoller = new MouseDevicePoller(); + private final MouseDevicePoller mouseDevicePoller = new MouseDevicePoller(); + + public final int getLastX() { return lastFocusedX; } + public final int getLastY() { return lastFocusedY; } @Override public void windowResized(WindowEvent e) { } @@ -179,10 +184,11 @@ public class LinuxMouseTracker implements WindowListener { if( y >= focusedWindow.getScreen().getHeight() ) { y = focusedWindow.getScreen().getHeight() - 1; } - int wx = x - focusedWindow.getX(), wy = y - focusedWindow.getY(); - + final int wx = x - focusedWindow.getX(), wy = y - focusedWindow.getY(); if(old_x != x || old_y != y) { // mouse moved + lastFocusedX = wx; + lastFocusedY = wy; focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_MOVED, 0, wx, wy, (short)0, 0 ); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 4d1388eec..391b8b19d 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -165,7 +165,7 @@ public class DisplayDriver extends DisplayImpl { } private static native long createPointerIcon0(long display, Object pixels, int pixels_byte_offset, boolean pixels_is_direct, int width, int height, int hotX, int hotY); - static native void destroyPointerIcon0(long display, long handle); + private static native void destroyPointerIcon0(long display, long handle); /** X11 Window delete atom marker used on EDT */ private long windowDeleteAtom; diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index f3474ee34..50f0c140a 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -39,15 +39,36 @@ #define VERBOSE_ON 1 #ifdef VERBOSE_ON - #define DBG_PRINT(...) fprintf(stdout, __VA_ARGS__) + #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) #else #define DBG_PRINT(...) #endif +typedef struct { + DISPMANX_ELEMENT_HANDLE_T handle; // magic BCM EGL position (EGL_DISPMANX_WINDOW_T) + int width; // magic BCM EGL position (EGL_DISPMANX_WINDOW_T) + int height; // magic BCM EGL position (EGL_DISPMANX_WINDOW_T) + int x; + int y; + int32_t layer; +} BCM_ELEMENT_T; + +typedef struct { + DISPMANX_RESOURCE_HANDLE_T handle; + VC_IMAGE_TYPE_T type; + uint32_t native_image_handle; +} BCM_RESOURCE_T; + +typedef struct { + BCM_ELEMENT_T element; + BCM_RESOURCE_T resource; + int hotX, hotY; +} POINTER_ICON_T; + static jmethodID setScreenSizeID = NULL; -static jmethodID windowCreatedID = NULL; static jmethodID sizeChangedID = NULL; +static jmethodID positionChangedID = NULL; static jmethodID visibleChangedID = NULL; static jmethodID windowDestroyNotifyID = NULL; @@ -64,11 +85,210 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_initI return JNI_TRUE; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_DispatchMessages - (JNIEnv *env, jobject obj) +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_OpenBCMDisplay0 + (JNIEnv *env, jclass clazz) +{ + DISPMANX_DISPLAY_HANDLE_T dispman_display = vc_dispmanx_display_open( 0 /* LCD */); + DBG_PRINT( "BCM.Display Open %p\n", (void*)(intptr_t)dispman_display); + return (jlong) (intptr_t) dispman_display; +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_CloseBCMDisplay0 + (JNIEnv *env, jclass clazz, jlong display) +{ + DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display; + DBG_PRINT( "BCM.Display Close %p\n", (void*)(intptr_t)dispman_display); + vc_dispmanx_display_close( dispman_display ); +} + + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_DispatchMessages0 + (JNIEnv *env, jclass clazz) { } +static void bcm_moveTo(DISPMANX_ELEMENT_HANDLE_T element, uint32_t layer, int x, int y, int width, int height) { + VC_RECT_T src_rect; + VC_RECT_T dst_rect; + uint32_t change_flags = DISPMANX_ELEMENT_CHANGE_DEST_RECT | DISPMANX_ELEMENT_CHANGE_SRC_RECT; + DISPMANX_RESOURCE_HANDLE_T mask = 0; + DISPMANX_TRANSFORM_T transform = 0; + + uint8_t opacity = 0; // NOP + + dst_rect.x = x; + dst_rect.y = y; + dst_rect.width = width; + dst_rect.height = height; + + src_rect.x = 0; + src_rect.y = 0; + src_rect.width = width << 16; + src_rect.height = height << 16; + + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + vc_dispmanx_element_change_attributes( dispman_update, + element, + change_flags, + layer, + opacity, + &dst_rect, + &src_rect, + mask, + transform ); + vc_dispmanx_update_submit_sync( dispman_update ); +} + +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_CreatePointerIcon0 + (JNIEnv *env, jclass clazz, jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct, jint width, jint height, jint hotX, jint hotY) +{ + if( 0 == pixels ) { + return 0; + } + int32_t success = 0; + VC_RECT_T dst_rect; + VC_RECT_T src_rect; + int x = 0; + int y = 0; + int pitch = width * 4; // RGBA + + const unsigned char * pixelPtr = (const unsigned char *) ( JNI_TRUE == pixels_is_direct ? + (*env)->GetDirectBufferAddress(env, pixels) : + (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) ); + + POINTER_ICON_T * p = calloc(1, sizeof(POINTER_ICON_T)); + p->hotX = hotX; + p->hotY = hotY; + p->element.layer = 2000; + p->element.x = x; + p->element.y = y; + p->element.width = width; + p->element.height = height; + p->resource.type = VC_IMAGE_ARGB8888; /* 32bpp with 8bit alpha at MS byte, with R, G, B (LS byte) */ + p->resource.handle = vc_dispmanx_resource_create( p->resource.type, + width, + height, + &(p->resource.native_image_handle) ); + + dst_rect.x = x; + dst_rect.y = y; + dst_rect.width = width; + dst_rect.height = height; + + vc_dispmanx_resource_write_data( p->resource.handle, + p->resource.type, + pitch, + (void*)(intptr_t)(pixelPtr + pixels_byte_offset), + &dst_rect ); + + if ( JNI_FALSE == pixels_is_direct ) { + (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT); + } + + DBG_PRINT( "BCM.Display PointerIcon.Create PI %p, resource %p\n", p, (void*)(intptr_t)p->resource.handle); + return (jlong) (intptr_t) p; +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_DestroyPointerIcon0 + (JNIEnv *env, jclass clazz, jlong handle) +{ + POINTER_ICON_T * p = (POINTER_ICON_T *) (intptr_t) handle ; + if( 0 == p ) { + return; + } + + DBG_PRINT( "BCM.Display PointerIcon.Destroy.0 PI %p, resource %p, element %p\n", + p, (void*)(intptr_t)p->resource.handle, (void*)(intptr_t)p->element.handle); + + if( 0 != p->element.handle ) { + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + vc_dispmanx_element_remove( dispman_update, p->element.handle ); + p->element.handle = 0; + vc_dispmanx_update_submit_sync( dispman_update ); + } + if( 0 != p->resource.handle ) { + vc_dispmanx_resource_delete( p->resource.handle ); + p->resource.handle = 0; + } + free( p ); +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_SetPointerIcon0 + (JNIEnv *env, jclass clazz, jlong display, jlong handle, jboolean enable, jint x, jint y) +{ + DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display; + POINTER_ICON_T * p = (POINTER_ICON_T *) (intptr_t) handle ; + VC_RECT_T dst_rect; + VC_RECT_T src_rect; + + if( 0 == dispman_display || NULL == p || 0 == p->resource.handle ) { + return; + } + + DBG_PRINT( "BCM.Display PointerIcon.Set.0 %p, PI %p, resource %p, element %p - enable %d - %d/%d\n", + (void*)(intptr_t)display, p, (void*)(intptr_t)p->resource.handle, (void*)(intptr_t)p->element.handle, enable, x, y); + + if( enable ) { + if( 0 != p->element.handle ) { + return; + } + + p->element.x = x; + p->element.y = y; + dst_rect.x = p->element.x - p->hotX; + dst_rect.y = p->element.y - p->hotY; + dst_rect.width = p->element.width; + dst_rect.height = p->element.height; + + src_rect.x = 0; + src_rect.y = 0; + src_rect.width = p->element.width << 16; + src_rect.height = p->element.height << 16; + + VC_DISPMANX_ALPHA_T dispman_alpha; + memset(&dispman_alpha, 0x0, sizeof(VC_DISPMANX_ALPHA_T)); + dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE ; + dispman_alpha.opacity = 0xFF; + dispman_alpha.mask = 0xFF; + + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + p->element.handle = vc_dispmanx_element_add ( dispman_update, dispman_display, + p->element.layer, &dst_rect, + p->resource.handle /*src*/, + &src_rect, DISPMANX_PROTECTION_NONE, + &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/); + vc_dispmanx_update_submit_sync( dispman_update ); + } else { + // DISABLE + if( 0 == p->element.handle ) { + return; + } + p->element.x = x; + p->element.y = y; + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + vc_dispmanx_element_remove( dispman_update, p->element.handle ); + p->element.handle = 0; + vc_dispmanx_update_submit_sync( dispman_update ); + } + DBG_PRINT( "BCM.Display PointerIcon.Set.X %p, PI %p, resource %p, element %p - enable %d - %d/%d\n", + (void*)(intptr_t)display, p, (void*)(intptr_t)p->resource.handle, (void*)(intptr_t)p->element.handle, enable, x, y); +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_MovePointerIcon0 + (JNIEnv *env, jclass clazz, jlong handle, jint x, jint y) +{ + POINTER_ICON_T * p = (POINTER_ICON_T *) (intptr_t) handle ; + + if( NULL == p || 0 == p->element.handle ) { + return; + } + DBG_PRINT( "BCM.Display PointerIcon.Move.0 PI %p, resource %p, element %p - %d/%d\n", + p, (void*)(intptr_t)p->resource.handle, (void*)(intptr_t)p->element.handle, x, y); + p->element.x = x; + p->element.y = y; + bcm_moveTo( p->element.handle, p->element.layer, p->element.x - p->hotX, p->element.y - p->hotY, p->element.width, p->element.height); +} + /** * Screen */ @@ -111,12 +331,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initNative JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initIDs (JNIEnv *env, jclass clazz) { - windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(J)V"); sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZII)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); - if (windowCreatedID == NULL || - sizeChangedID == NULL || + if (sizeChangedID == NULL || + positionChangedID == NULL || visibleChangedID == NULL || windowDestroyNotifyID == NULL) { DBG_PRINT( "initIDs failed\n" ); @@ -126,20 +346,23 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow - (JNIEnv *env, jobject obj, jint width, jint height, jboolean opaque, jint alphaBits) +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow0 + (JNIEnv *env, jobject obj, jlong display, jint x, jint y, jint width, jint height, jboolean opaque, jint alphaBits) { int32_t success = 0; VC_RECT_T dst_rect; VC_RECT_T src_rect; + if( 0 == display ) { + return; + } dst_rect.x = 0; dst_rect.y = 0; dst_rect.width = width; dst_rect.height = height; - src_rect.x = 0; - src_rect.y = 0; + src_rect.x = x; + src_rect.y = y; src_rect.width = width << 16; src_rect.height = height << 16; @@ -156,37 +379,52 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin dispman_alpha.mask = 0xFF; } - DISPMANX_DISPLAY_HANDLE_T dispman_display = vc_dispmanx_display_open( 0 /* LCD */); + DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display; + + DBG_PRINT( "BCM.Display Window.Create.0 %p, %d/%d %dx%d, opaque %d, alphaBits %d\n", + (void*)(intptr_t)dispman_display, x, y, width, height, opaque, alphaBits); + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display, 0/*layer*/, &dst_rect, 0/*src*/, &src_rect, DISPMANX_PROTECTION_NONE, &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/); - EGL_DISPMANX_WINDOW_T * nativeWindowPtr = calloc(1, sizeof(EGL_DISPMANX_WINDOW_T)); - nativeWindowPtr->element = dispman_element; - nativeWindowPtr->width = width; - nativeWindowPtr->height = height; + BCM_ELEMENT_T * p = calloc(1, sizeof(BCM_ELEMENT_T)); + p->handle = dispman_element; + p->layer = 0; + p->x = x; + p->y = y; + p->width = width; + p->height = height; vc_dispmanx_update_submit_sync( dispman_update ); (*env)->CallVoidMethod(env, obj, visibleChangedID, JNI_FALSE, JNI_TRUE); // FIXME: or defer=true ? - return (jlong) (intptr_t) nativeWindowPtr; -} + DBG_PRINT( "BCM.Display Window.Create.X %p, element %p\n", + (void*)(intptr_t)dispman_display, (void*)(intptr_t)p->handle); -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_RealizeWindow - (JNIEnv *env, jobject obj, jlong window) -{ - return (jlong) (intptr_t) 0; + return (jlong) (intptr_t) p; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CloseWindow - (JNIEnv *env, jobject obj, jlong window, jlong juserData) +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CloseWindow0 + (JNIEnv *env, jobject obj, jlong display, jlong window) { - EGL_DISPMANX_WINDOW_T * nativeWindowPtr = (EGL_DISPMANX_WINDOW_T *) (intptr_t) window ; - free( nativeWindowPtr ); - return 0; + DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display; + BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ; + + DBG_PRINT( "BCM.Display Window.Close %p, element %p\n", + (void*)(intptr_t)dispman_display, (void*)(intptr_t)p->handle); + + if( 0 == dispman_display || NULL == p || 0 == p->handle ) { + return; + } + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + vc_dispmanx_element_remove( dispman_update, p->handle ); + p->handle = 0; + vc_dispmanx_update_submit_sync( dispman_update ); + free( p ); } /* @@ -204,10 +442,41 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setFullScr { } +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setPos0 + (JNIEnv *env, jobject obj, jlong window, jint x, jint y) +{ + BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ; + + if( NULL == p || 0 == p->handle ) { + return; + } + p->x = x; + p->y = y; + + DBG_PRINT( "BCM.Display Window.Pos %p, element %p - %d/%d %dx%d\n", + p, (void*)(intptr_t)p->handle, p->x, p->y, p->width, p->height); + + bcm_moveTo( p->handle, p->layer, p->x, p->y, p->width, p->height); + (*env)->CallVoidMethod(env, obj, positionChangedID, JNI_FALSE, x, y); +} + + JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setSize0 (JNIEnv *env, jobject obj, jlong window, jint width, jint height) { - // FIXME RESIZE (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); + BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ; + + if( NULL == p || 0 == p->handle ) { + return; + } + p->width = width; + p->height = height; + + DBG_PRINT( "BCM.Display Window.Resize %p, element %p - %d/%d %dx%d\n", + p, (void*)(intptr_t)p->handle, p->x, p->y, p->width, p->height); + + bcm_moveTo( p->handle, p->layer, p->x, p->y, p->width, p->height); + (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); } diff --git a/src/newt/native/bcm_vc_iv.h b/src/newt/native/bcm_vc_iv.h index b43483c10..f98700e4e 100644 --- a/src/newt/native/bcm_vc_iv.h +++ b/src/newt/native/bcm_vc_iv.h @@ -150,12 +150,6 @@ typedef struct { } DISPMANX_CLAMP_T; -typedef struct { - DISPMANX_ELEMENT_HANDLE_T element; - int width; /* This is necessary because dispmanx elements are not queriable. */ - int height; -} EGL_DISPMANX_WINDOW_T; - typedef struct tag_VC_RECT_T { int32_t x; int32_t y; @@ -163,6 +157,102 @@ typedef struct tag_VC_RECT_T { int32_t height; } VC_RECT_T; +/* Types of image supported. */ +/* Please add any new types to the *end* of this list. Also update + * case_VC_IMAGE_ANY_xxx macros (below), and the vc_image_type_info table in + * vc_image/vc_image_helper.c. + */ +typedef enum +{ + VC_IMAGE_MIN = 0, //bounds for error checking + + VC_IMAGE_RGB565 = 1, + VC_IMAGE_1BPP, + VC_IMAGE_YUV420, + VC_IMAGE_48BPP, + VC_IMAGE_RGB888, + VC_IMAGE_8BPP, + VC_IMAGE_4BPP, // 4bpp palettised image + VC_IMAGE_3D32, /* A separated format of 16 colour/light shorts followed by 16 z values */ + VC_IMAGE_3D32B, /* 16 colours followed by 16 z values */ + VC_IMAGE_3D32MAT, /* A separated format of 16 material/colour/light shorts followed by 16 z values */ + VC_IMAGE_RGB2X9, /* 32 bit format containing 18 bits of 6.6.6 RGB, 9 bits per short */ + VC_IMAGE_RGB666, /* 32-bit format holding 18 bits of 6.6.6 RGB */ + VC_IMAGE_PAL4_OBSOLETE, // 4bpp palettised image with embedded palette + VC_IMAGE_PAL8_OBSOLETE, // 8bpp palettised image with embedded palette + VC_IMAGE_RGBA32, /* RGB888 with an alpha byte after each pixel */ /* xxx: isn't it BEFORE each pixel? */ + VC_IMAGE_YUV422, /* a line of Y (32-byte padded), a line of U (16-byte padded), and a line of V (16-byte padded) */ + VC_IMAGE_RGBA565, /* RGB565 with a transparent patch */ + VC_IMAGE_RGBA16, /* Compressed (4444) version of RGBA32 */ + VC_IMAGE_YUV_UV, /* VCIII codec format */ + VC_IMAGE_TF_RGBA32, /* VCIII T-format RGBA8888 */ + VC_IMAGE_TF_RGBX32, /* VCIII T-format RGBx8888 */ + VC_IMAGE_TF_FLOAT, /* VCIII T-format float */ + VC_IMAGE_TF_RGBA16, /* VCIII T-format RGBA4444 */ + VC_IMAGE_TF_RGBA5551, /* VCIII T-format RGB5551 */ + VC_IMAGE_TF_RGB565, /* VCIII T-format RGB565 */ + VC_IMAGE_TF_YA88, /* VCIII T-format 8-bit luma and 8-bit alpha */ + VC_IMAGE_TF_BYTE, /* VCIII T-format 8 bit generic sample */ + VC_IMAGE_TF_PAL8, /* VCIII T-format 8-bit palette */ + VC_IMAGE_TF_PAL4, /* VCIII T-format 4-bit palette */ + VC_IMAGE_TF_ETC1, /* VCIII T-format Ericsson Texture Compressed */ + VC_IMAGE_BGR888, /* RGB888 with R & B swapped */ + VC_IMAGE_BGR888_NP, /* RGB888 with R & B swapped, but with no pitch, i.e. no padding after each row of pixels */ + VC_IMAGE_BAYER, /* Bayer image, extra defines which variant is being used */ + VC_IMAGE_CODEC, /* General wrapper for codec images e.g. JPEG from camera */ + VC_IMAGE_YUV_UV32, /* VCIII codec format */ + VC_IMAGE_TF_Y8, /* VCIII T-format 8-bit luma */ + VC_IMAGE_TF_A8, /* VCIII T-format 8-bit alpha */ + VC_IMAGE_TF_SHORT,/* VCIII T-format 16-bit generic sample */ + VC_IMAGE_TF_1BPP, /* VCIII T-format 1bpp black/white */ + VC_IMAGE_OPENGL, + VC_IMAGE_YUV444I, /* VCIII-B0 HVS YUV 4:4:4 interleaved samples */ + VC_IMAGE_YUV422PLANAR, /* Y, U, & V planes separately (VC_IMAGE_YUV422 has them interleaved on a per line basis) */ + VC_IMAGE_ARGB8888, /* 32bpp with 8bit alpha at MS byte, with R, G, B (LS byte) */ + VC_IMAGE_XRGB8888, /* 32bpp with 8bit unused at MS byte, with R, G, B (LS byte) */ + + VC_IMAGE_YUV422YUYV, /* interleaved 8 bit samples of Y, U, Y, V */ + VC_IMAGE_YUV422YVYU, /* interleaved 8 bit samples of Y, V, Y, U */ + VC_IMAGE_YUV422UYVY, /* interleaved 8 bit samples of U, Y, V, Y */ + VC_IMAGE_YUV422VYUY, /* interleaved 8 bit samples of V, Y, U, Y */ + + VC_IMAGE_RGBX32, /* 32bpp like RGBA32 but with unused alpha */ + VC_IMAGE_RGBX8888, /* 32bpp, corresponding to RGBA with unused alpha */ + VC_IMAGE_BGRX8888, /* 32bpp, corresponding to BGRA with unused alpha */ + + VC_IMAGE_YUV420SP, /* Y as a plane, then UV byte interleaved in plane with with same pitch, half height */ + + VC_IMAGE_YUV444PLANAR, /* Y, U, & V planes separately 4:4:4 */ + + VC_IMAGE_MAX, //bounds for error checking + VC_IMAGE_FORCE_ENUM_16BIT = 0xffff, +} VC_IMAGE_TYPE_T; + +/** + * From https://github.com/raspberrypi/userland/blob/master/interface/vmcs_host/vc_vchi_dispmanx.h + */ +typedef enum { + DISPMANX_ELEMENT_CHANGE_LAYER = (1<<0), + DISPMANX_ELEMENT_CHANGE_OPACITY = (1<<1), + DISPMANX_ELEMENT_CHANGE_DEST_RECT = (1<<2), + DISPMANX_ELEMENT_CHANGE_SRC_RECT = (1<<3), + DISPMANX_ELEMENT_CHANGE_MASK_RESOURCE = (1<<4), + DISPMANX_ELEMENT_CHANGE_TRANSFORM = (1<<5) +/** + * Not working /validated ! + DISPMANX_ELEMENT_CHANGE_MIN = 0x00, + DISPMANX_ELEMENT_CHANGE_SOURCE = 0x01, + DISPMANX_ELEMENT_INSERT_ABOVE = 0x80, + DISPMANX_ELEMENT_CHANGE_FLAGS = 0x100, + DISPMANX_ELEMENT_CHANGE_NOTHING = 0x200, + DISPMANX_ELEMENT_CHANGE_ALPHA_FLAGS = 0x400, + DISPMANX_ELEMENT_CHANGE_PROTECTION = 0x800, + DISPMANX_ELEMENT_CHANGE_MAX = 0x1000 + */ +} DISPMANX_ELEMENT_CHANGE_T; + + + extern void bcm_host_init(void); extern void bcm_host_deinit(void); @@ -171,15 +261,38 @@ extern int32_t graphics_get_display_size( const uint16_t display_number, uint32_t *height); extern DISPMANX_DISPLAY_HANDLE_T vc_dispmanx_display_open( uint32_t device ); +extern int vc_dispmanx_display_close( DISPMANX_DISPLAY_HANDLE_T display ); + +extern DISPMANX_RESOURCE_HANDLE_T vc_dispmanx_resource_create(VC_IMAGE_TYPE_T type, uint32_t width, uint32_t height, uint32_t *native_image_handle); +extern int vc_dispmanx_resource_write_data( DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type, int src_pitch, void * src_address, const VC_RECT_T * rect ); +//extern int vc_dispmanx_resource_write_data_handle( DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type, int src_pitch, +// VCHI_MEM_HANDLE_T handle, uint32_t offset, const VC_RECT_T * rect ); +extern int vc_dispmanx_resource_delete( DISPMANX_RESOURCE_HANDLE_T res ); + + + extern DISPMANX_UPDATE_HANDLE_T vc_dispmanx_update_start( int32_t priority ); extern DISPMANX_ELEMENT_HANDLE_T vc_dispmanx_element_add ( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_DISPLAY_HANDLE_T display, int32_t layer, const VC_RECT_T *dest_rect, DISPMANX_RESOURCE_HANDLE_T src, const VC_RECT_T *src_rect, DISPMANX_PROTECTION_T protection, VC_DISPMANX_ALPHA_T *alpha, DISPMANX_CLAMP_T *clamp, DISPMANX_TRANSFORM_T transform ); +extern int vc_dispmanx_element_remove( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element ); + extern int vc_dispmanx_update_submit_sync( DISPMANX_UPDATE_HANDLE_T update ); +//New function added to VCHI to change attributes, set_opacity does not work there. +extern int vc_dispmanx_element_change_attributes( DISPMANX_UPDATE_HANDLE_T update, + DISPMANX_ELEMENT_HANDLE_T element, + uint32_t change_flags, + int32_t layer, + uint8_t opacity, + const VC_RECT_T *dest_rect, + const VC_RECT_T *src_rect, + DISPMANX_RESOURCE_HANDLE_T mask, + DISPMANX_TRANSFORM_T transform ); + #ifdef __cplusplus } #endif -- cgit v1.2.3 From 667eca532d3749b0f08e694f36624ff7f621a9c8 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 9 Jan 2014 18:51:16 +0100 Subject: Bug 676 - Add support for native Mouse Pointer rendering (Rasp.-Pi.) - Intercept sendMouseEvent(..) Intercepting 'sendMouseEvent(..)' to reduce the lag (time) and listener footprint. --- src/newt/classes/jogamp/newt/WindowImpl.java | 4 ++-- .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 23 +++------------------- 2 files changed, 5 insertions(+), 22 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index dc9affd63..f3bbd7a24 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2539,8 +2539,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Native MouseEvents pre-processed to be enqueued or consumed directly // - public final void sendMouseEvent(final short eventType, final int modifiers, - final int x, final int y, final short button, final float rotation) { + public void sendMouseEvent(final short eventType, final int modifiers, + final int x, final int y, final short button, final float rotation) { doMouseEvent(false, false, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } public final void enqueueMouseEvent(final boolean wait, final short eventType, final int modifiers, diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index 5109d0fbb..c05d8d1e8 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -39,8 +39,7 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; -import com.jogamp.newt.event.MouseListener; -import com.jogamp.newt.event.MouseAdapter; +import com.jogamp.newt.event.MouseEvent; import jogamp.newt.PointerIconImpl; import jogamp.newt.WindowImpl; @@ -100,29 +99,14 @@ public class WindowDriver extends WindowImpl { addWindowListener(linuxEventDeviceTracker); addWindowListener(linuxMouseTracker); - addMouseListener(mousePointerTracker); focusChanged(false, true); } - final MouseListener mousePointerTracker = new MouseAdapter() { - @Override - public void mouseMoved(com.jogamp.newt.event.MouseEvent e) { - final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); - display.moveActivePointerIcon(e.getX(), e.getY()); - } - - @Override - public void mouseDragged(com.jogamp.newt.event.MouseEvent e) { - final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); - display.moveActivePointerIcon(e.getX(), e.getY()); - } - }; @Override protected void closeNativeImpl() { final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getGraphicsConfiguration().getScreen().getDevice(); - removeMouseListener(mousePointerTracker); removeWindowListener(linuxMouseTracker); removeWindowListener(linuxEventDeviceTracker); @@ -182,16 +166,15 @@ public class WindowDriver extends WindowImpl { // nop .. } - /** @Override public final void sendMouseEvent(final short eventType, final int modifiers, final int x, final int y, final short button, final float rotation) { - if( MouseEvent.MOUSE_MOVED == eventType ) { + if( MouseEvent.EVENT_MOUSE_MOVED == eventType ) { final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); display.moveActivePointerIcon(x, y); } super.sendMouseEvent(eventType, modifiers, x, y, button, rotation); - } */ + } @Override protected void setPointerIconImpl(final PointerIconImpl pi) { -- cgit v1.2.3 From 4e9fb8d0fd1b73c592840d6ba34b91da5cca9c18 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 9 Jan 2014 20:45:28 +0100 Subject: NEWT Rasp.Pi: Add Support for multiple Windows, dynamic set size and position Impl. manages up-to 32 windows (BCM layer elements) - dunno whether this is a proper value. Note: Layer 2000 is reserved for out PointerIcon. Removed 'dead code'. --- make/scripts/tests.sh | 4 +- .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 78 ++++++++++---------- src/newt/native/bcm_vc_iv.c | 82 ++++++++-------------- 3 files changed, 74 insertions(+), 90 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bf9eba958..10cd3f17c 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -325,7 +325,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -479,7 +479,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* +testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows03NEWTAnimResize $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index c05d8d1e8..e91c67813 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -38,6 +38,7 @@ import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; +import com.jogamp.common.util.IntBitfield; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import com.jogamp.newt.event.MouseEvent; @@ -57,6 +58,9 @@ public class WindowDriver extends WindowImpl { public WindowDriver() { linuxMouseTracker = LinuxMouseTracker.getSingleton(); linuxEventDeviceTracker = LinuxEventDeviceTracker.getSingleton(); + layer = -1; + nativeWindowHandle = 0; + windowHandleClose = 0; } @Override @@ -64,6 +68,26 @@ public class WindowDriver extends WindowImpl { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); } + synchronized( layerSync ) { + if( layerCount >= MAX_LAYERS ) { + throw new RuntimeException("Max windows reached: "+layerCount+" ( "+MAX_LAYERS+" )"); + } + for(int i=0; 0 > layer && i layer ) { + throw new InternalError("Could not find a free layer: count "+layerCount+", max "+MAX_LAYERS); + } final ScreenDriver screen = (ScreenDriver) getScreen(); final DisplayDriver display = (DisplayDriver) screen.getDisplay(); @@ -85,12 +109,11 @@ public class WindowDriver extends WindowImpl { chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque()); } setGraphicsConfiguration(cfg); - nativeWindowHandle = CreateWindow0(display.getBCMHandle(), getX(), getY(), getWidth(), getHeight(), + nativeWindowHandle = CreateWindow0(display.getBCMHandle(), layer, getX(), getY(), getWidth(), getHeight(), chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits()); if (nativeWindowHandle == 0) { throw new NativeWindowException("Error creating egl window: "+cfg); } - setVisible0(nativeWindowHandle, false); setWindowHandle(nativeWindowHandle); if (0 == getWindowHandle()) { throw new NativeWindowException("Error native Window Handle is null"); @@ -115,6 +138,13 @@ public class WindowDriver extends WindowImpl { } eglDevice.close(); + + synchronized( layerSync ) { + usedLayers.put(layer, false); + layerCount--; + layer = -1; + // System.err.println("XXX.Close capacity "+usedLayers.capacity()+", count "+usedLayers.getBitCount()); + } } @Override @@ -124,35 +154,7 @@ public class WindowDriver extends WindowImpl { @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - setVisible0(nativeWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - if(0!=nativeWindowHandle) { - if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { - final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; - setFullScreen0(nativeWindowHandle, fs); - if(fs) { - return true; - } - } - // int _x=(x>=0)?x:this.x; - // int _y=(x>=0)?y:this.y; - width=(width>0)?width:getWidth(); - height=(height>0)?height:getHeight(); - if(width>0 || height>0) { - setSize0(nativeWindowHandle, width, height); - } - if(x>=0 || y>=0) { - System.err.println("setPosition n/a in KD"); - } - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - + reconfigure0(nativeWindowHandle, x, y, width, height, flags); return true; } @@ -196,13 +198,17 @@ public class WindowDriver extends WindowImpl { private final LinuxEventDeviceTracker linuxEventDeviceTracker; protected static native boolean initIDs(); - private native long CreateWindow0(long bcmDisplay, int x, int y, int width, int height, boolean opaque, int alphaBits); + private native long CreateWindow0(long bcmDisplay, int layer, int x, int y, int width, int height, boolean opaque, int alphaBits); private native void CloseWindow0(long bcmDisplay, long eglWindowHandle); - private native void setVisible0(long eglWindowHandle, boolean visible); - private native void setPos0(long eglWindowHandle, int x, int y); - private native void setSize0(long eglWindowHandle, int width, int height); - private native void setFullScreen0(long eglWindowHandle, boolean fullscreen); + private native void reconfigure0(long eglWindowHandle, int x, int y, int width, int height, int flags); + private int layer; private long nativeWindowHandle; private long windowHandleClose; + + private static int nextLayer = 0; + private static int layerCount = 0; + private static final int MAX_LAYERS = 32; + private static final IntBitfield usedLayers = new IntBitfield(MAX_LAYERS); + private static final Object layerSync = new Object(); } diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index ea225772f..3a802650a 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -347,7 +347,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID } JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow0 - (JNIEnv *env, jobject obj, jlong display, jint x, jint y, jint width, jint height, jboolean opaque, jint alphaBits) + (JNIEnv *env, jobject obj, jlong display, jint layer, jint x, jint y, jint width, jint height, jboolean opaque, jint alphaBits) { int32_t success = 0; VC_RECT_T dst_rect; @@ -356,13 +356,13 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin if( 0 == display ) { return; } - dst_rect.x = 0; - dst_rect.y = 0; + dst_rect.x = x; + dst_rect.y = y; dst_rect.width = width; dst_rect.height = height; - src_rect.x = x; - src_rect.y = y; + src_rect.x = 0; + src_rect.y = 0; src_rect.width = width << 16; src_rect.height = height << 16; @@ -381,22 +381,20 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display; - DBG_PRINT( "BCM.Display Window.Create.0 %p, %d/%d %dx%d, opaque %d, alphaBits %d\n", - (void*)(intptr_t)dispman_display, x, y, width, height, opaque, alphaBits); - - DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); - DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display, - 0/*layer*/, &dst_rect, 0/*src*/, - &src_rect, DISPMANX_PROTECTION_NONE, - &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/); + DBG_PRINT( "BCM.Display Window.Create.0 %p, %d/%d %dx%d, opaque %d, alphaBits %d, layer %d\n", + (void*)(intptr_t)dispman_display, x, y, width, height, opaque, alphaBits, layer); BCM_ELEMENT_T * p = calloc(1, sizeof(BCM_ELEMENT_T)); - p->handle = dispman_element; - p->layer = 0; + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + p->layer = layer; p->x = x; p->y = y; p->width = width; p->height = height; + p->handle = vc_dispmanx_element_add ( dispman_update, dispman_display, + p->layer, &dst_rect, 0/*src*/, + &src_rect, DISPMANX_PROTECTION_NONE, + &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/); vc_dispmanx_update_submit_sync( dispman_update ); @@ -427,56 +425,36 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CloseWindo free( p ); } -/* - * Class: jogamp_newt_driver_bcm_vc_iv_WindowDriver - * Method: setVisible0 - * Signature: (JJZ)V - */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setVisible0 - (JNIEnv *env, jobject obj, jlong window, jboolean visible) -{ -} - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setFullScreen0 - (JNIEnv *env, jobject obj, jlong window, jboolean fullscreen) -{ -} - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setPos0 - (JNIEnv *env, jobject obj, jlong window, jint x, jint y) +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_reconfigure0 + (JNIEnv *env, jobject obj, jlong window, jint x, jint y, jint width, jint height, jint flags) { BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ; if( NULL == p || 0 == p->handle ) { return; } + /*** + int isVisible = !TST_FLAG_CHANGE_VISIBILITY(flags) && TST_FLAG_IS_VISIBLE(flags) ; + ... + see X11Window.c + */ + + int posChanged = p->x != x || p->y != y; + int sizeChanged = p->width != width || p->height != height; p->x = x; p->y = y; - - DBG_PRINT( "BCM.Display Window.Pos %p, element %p - %d/%d %dx%d\n", - p, (void*)(intptr_t)p->handle, p->x, p->y, p->width, p->height); - - bcm_moveTo( p->handle, p->layer, p->x, p->y, p->width, p->height); - (*env)->CallVoidMethod(env, obj, positionChangedID, JNI_FALSE, x, y); -} - - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setSize0 - (JNIEnv *env, jobject obj, jlong window, jint width, jint height) -{ - BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ; - - if( NULL == p || 0 == p->handle ) { - return; - } p->width = width; p->height = height; - DBG_PRINT( "BCM.Display Window.Resize %p, element %p - %d/%d %dx%d\n", + DBG_PRINT( "BCM.Display Window.Reconfig %p, element %p - %d/%d %dx%d\n", p, (void*)(intptr_t)p->handle, p->x, p->y, p->width, p->height); bcm_moveTo( p->handle, p->layer, p->x, p->y, p->width, p->height); - (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); + if( posChanged ) { + (*env)->CallVoidMethod(env, obj, positionChangedID, JNI_FALSE, x, y); + } + if( sizeChanged ) { + (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); + } } - -- cgit v1.2.3 From 6ea03078e162eed89653ae123d172b6fca7c6d61 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 11 Jan 2014 07:27:15 +0100 Subject: Misc Cleanup: JAWTWindow: Reusing visible in HIERARCHY listener; Remove obsolete 'getPrivateGraphicsConfiguration()' --- .../classes/jogamp/opengl/GLDrawableHelper.java | 10 ++++---- .../classes/jogamp/opengl/GLFBODrawableImpl.java | 4 ++-- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 27 ++++++++++------------ .../jogamp/nativewindow/ProxySurfaceImpl.java | 6 +---- src/newt/classes/jogamp/newt/WindowImpl.java | 7 ------ 5 files changed, 20 insertions(+), 34 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 61735c487..c0bf43d2c 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -336,7 +336,7 @@ public class GLDrawableHelper { } final NativeSurface ns = drawable.getNativeSurface(); final int lockRes = ns.lockSurface(); - if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { + if ( NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes ) { throw new NativeWindowException("Could not lock surface of drawable: "+drawable); } boolean validateSize = true; @@ -345,10 +345,10 @@ public class GLDrawableHelper { System.err.println("WARNING: Odd size detected: "+newWidth+"x"+newHeight+", using safe size 1x1. Drawable "+drawable); Thread.dumpStack(); } - if(0>=newWidth) { newWidth = 1; validateSize=false; } - if(0>=newHeight) { newHeight = 1; validateSize=false; } + if( 0 >= newWidth ) { newWidth = 1; validateSize=false; } + if( 0 >= newHeight ) { newHeight = 1; validateSize=false; } // propagate new size - if(ns instanceof ProxySurface) { + if( ns instanceof ProxySurface ) { final ProxySurface ps = (ProxySurface) ns; final UpstreamSurfaceHook ush = ps.getUpstreamSurfaceHook(); if(ush instanceof UpstreamSurfaceHook.MutableSize) { @@ -359,7 +359,7 @@ public class GLDrawableHelper { } else if(DEBUG) { // we have to assume surface contains the new size already, hence size check @ bottom System.err.println("GLDrawableHelper.resizeOffscreenDrawable: Drawable's offscreen surface n.a. ProxySurface, but "+ns.getClass().getName()+": "+ns); } - if(drawable instanceof GLFBODrawable) { + if( drawable instanceof GLFBODrawable ) { if( null != context && context.isCreated() ) { ((GLFBODrawable) drawable).resetSize(context.getGL()); } diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index ab318927c..0e9d142ba 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -90,7 +90,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { this.initialized = false; this.parent = parent; - this.origParentChosenCaps = (GLCapabilitiesImmutable) getChosenGLCapabilities(); // just to avoid null, will be reset at initialize(..) + this.origParentChosenCaps = getChosenGLCapabilities(); // just to avoid null, will be reset at initialize(..) this.texUnit = textureUnit; this.samples = fboCaps.getNumSamples(); fboResetQuirk = false; @@ -552,7 +552,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { ",\n\tfboI back "+fboIBack+", front "+fboIFront+", num "+(initialized ? fbos.length : 0)+ ",\n\tFBO front read "+getDefaultReadFramebuffer()+", "+getFBObject(GL.GL_FRONT)+ ",\n\tFBO back write "+getDefaultDrawFramebuffer()+", "+getFBObject(GL.GL_BACK)+ - ",\n\tSurface "+getNativeSurface()+ + ",\n\tSurface "+surface+ "]"; } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index ddf513180..ed25a497f 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -220,30 +220,31 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) { final boolean displayable = changed.isDisplayable(); final boolean propagateDisplayability = changed == component && ( displayable && localVisibility ) != compIsVisible; + final boolean visible = displayable && localVisibility; + final boolean propagateDisplayability = changed == component && visible != compIsVisible; if( propagateDisplayability ) { // Propagate parent's displayability, i.e. 'removeNotify()' and 'addNotify()' - final boolean _visible = displayable && localVisibility; visibilityPropagation = true; globalVisibility = displayable; if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged DISPLAYABILITY_CHANGED (1): displayable "+displayable+" -> visible "+_visible+", "+s(e)); + System.err.println(jawtStr()+".hierarchyChanged DISPLAYABILITY_CHANGED (1): displayable "+displayable+" -> visible "+visible+", "+s(e)); } - component.setVisible(_visible); + component.setVisible(visible); } else if(DEBUG) { System.err.println(jawtStr()+".hierarchyChanged DISPLAYABILITY_CHANGED (x): displayable "+displayable+", "+s(e)); } } else if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) { final boolean showing = changed.isShowing(); - final boolean propagateVisibility = changed != component && ( showing && localVisibility ) != compIsVisible; + final boolean visible = showing && localVisibility; + final boolean propagateVisibility = changed != component && visible != compIsVisible; if( propagateVisibility ) { // Propagate parent's visibility - final boolean _visible = showing && localVisibility; visibilityPropagation = true; globalVisibility = showing; if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (1): showing "+showing+" -> visible "+_visible+", "+s(e)); + System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (1): showing "+showing+" -> visible "+visible+", "+s(e)); } - component.setVisible(_visible); + component.setVisible(visible); } else if( changed == component ) { // Update component's local visibility state if(!visibilityPropagation) { @@ -251,10 +252,10 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } visibilityPropagation = false; if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (0): showing "+showing+" -> visible "+(showing && localVisibility)+", "+s(e)); + System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (0): showing "+showing+" -> visible "+visible+", "+s(e)); } } else if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (x): showing "+showing+" -> visible "+(showing && localVisibility)+", "+s(e)); + System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (x): showing "+showing+" -> visible "+visible+", "+s(e)); } } else if(DEBUG) { final boolean displayable = changed.isDisplayable(); @@ -423,7 +424,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, @Override public final void setChosenCapabilities(CapabilitiesImmutable caps) { ((MutableGraphicsConfiguration)getGraphicsConfiguration()).setChosenCapabilities(caps); - getPrivateGraphicsConfiguration().setChosenCapabilities(caps); + config.setChosenCapabilities(caps); } @Override @@ -601,10 +602,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return drawable; } - public final AWTGraphicsConfiguration getPrivateGraphicsConfiguration() { - return config; - } - @Override public final AbstractGraphicsConfiguration getGraphicsConfiguration() { return config.getNativeGraphicsConfiguration(); @@ -792,7 +789,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ ", visible "+component.isVisible()); sb.append(", lockedExt "+isSurfaceLockedByOtherThread()+ - ",\n\tconfig "+getPrivateGraphicsConfiguration()+ + ",\n\tconfig "+config+ ",\n\tawtComponent "+getAWTComponent()+ ",\n\tsurfaceLock "+surfaceLock+"]"); diff --git a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java index 097fffead..fbff7128e 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java @@ -45,7 +45,7 @@ public abstract class ProxySurfaceImpl implements ProxySurface { private AbstractGraphicsConfiguration config; // control access due to delegation private UpstreamSurfaceHook upstream; private long surfaceHandle_old; - private RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); + private final RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); private int implBitfield; private boolean upstreamSurfaceHookLifecycleEnabled; @@ -122,10 +122,6 @@ public abstract class ProxySurfaceImpl implements ProxySurface { throw new InternalError("UpstreamSurfaceHook given, but required method not implemented."); } - protected final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() { - return config; - } - @Override public final AbstractGraphicsConfiguration getGraphicsConfiguration() { return config.getNativeGraphicsConfiguration(); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index f3bbd7a24..260ae4dd8 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1927,13 +1927,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer windowDestroyNotifyAction = r; } - /** - * Returns the non delegated {@link AbstractGraphicsConfiguration}, - * see {@link #getGraphicsConfiguration()}. */ - public final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() { - return config; - } - protected final long getParentWindowHandle() { return isFullscreen() ? 0 : parentWindowHandle; } -- cgit v1.2.3 From 071bdd6ce9f8c41ccecdbf8bc74f276ccd7ff651 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 12 Jan 2014 07:27:55 +0100 Subject: Bug 937 - JAWTWindow: Unsatisfying Visibility Computation Simplify JAWTComponentListener's HierarchyListener: - Don't interfere w/ Component's visibility anymore! This shall reduce sideeffects. Utilize 'isShowing' in each Component specialization, i.e. GLCanvas. - On SHOWING_CHANGED if a parent caused a change of the tracked components showing state, propagate it to the offscreen-layer! - Remove all other complicated states! GLCanvas, GLJPanel: - Instead of 'isVisible()' use 'showing state', since only the 'showing state' reflects 'true' visibility throughout the hierarchy. - Add HierarchyListener and track volatile showing state to be used instead of 'isVisible'. Using a cached showing state is more efficient than quering 'isShowing()' all the time! NewtCanvasAWT: - Use 'isShowing()' instead of 'isVisible(), see above --- make/scripts/tests.sh | 50 +++++++++-- .../classes/javax/media/opengl/awt/GLCanvas.java | 30 ++++--- .../classes/javax/media/opengl/awt/GLJPanel.java | 20 ++++- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 78 +++++------------- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 4 +- .../TestAWTCardLayoutAnimatorStartStopBug532.java | 92 +++++++++++++-------- .../awt/TestBug664GLCanvasSetVisibleSwingAWT.java | 96 +++++++++++----------- ...estBug816JTabbedPanelVisibilityB849B878AWT.java | 47 +++++++---- .../awt/TestBug816OSXCALayerPos03aB729AWT.java | 6 +- .../awt/TestBug816OSXCALayerPos03bB849AWT.java | 6 +- .../awt/TestBug816OSXCALayerPos03cB849AWT.java | 6 +- 11 files changed, 249 insertions(+), 186 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bf9eba958..b99f7866c 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -107,6 +107,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL" #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" + #D_ARGS="-Dnativewindow.debug.JAWT -Djogl.debug.GLCanvas" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" @@ -193,7 +194,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" - #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" + D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" @@ -325,7 +326,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -466,7 +467,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLJPanel01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.Bug898AnimatorFromEDTAWT $* # @@ -500,15 +500,52 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # # AWT # -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* + +# +# OSX CALayer Position and Visibility (OSX CALayer, ..) +# +# + +# +# Simple GLCanvas setVisible on/off +# OK (X11, OSX) +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug664GLCanvasSetVisibleSwingAWT $* + +# +# GLCanvas moving between CardLayout's JPanels +# OK (X11, OSX) +#testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAWTCardLayoutAnimatorStartStopBug532 $* + +# +# GLCanvas moving between JTabbedPanel's tabs +# OK (X11, OSX) +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* + +# +# GLCanvas/AWT Checkbox Visibility +# OK (X11, OSX) #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aB729AWT $* + +# +# GLCanvas/AWT Checkbox Visibility (on parent's Panel) +# OK (X11, OSX) #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bB849AWT $* +# +# GLCanvas/Swing Checkbox Visibility (on parent's JPanel) +# OK (X11, OSX) #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* + +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* + +# +# OSX CALayer Position and Visibility (OSX CALayer, ..) +# +# + #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* @@ -519,7 +556,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug664GLCanvasSetVisibleSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 0bc002f8e..7ea216dd9 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -52,6 +52,8 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.Rectangle2D; import java.awt.EventQueue; @@ -173,6 +175,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private final GraphicsDevice device; private boolean shallUseOffscreenLayer = false; + private volatile boolean isShowing; + private final HierarchyListener hierarchyListener = new HierarchyListener() { + @Override + public void hierarchyChanged(HierarchyEvent e) { + isShowing = GLCanvas.this.isShowing(); + } + }; + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override @@ -294,6 +304,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing helper.setSharedContext(null, shareWith); } this.device = device; + + this.addHierarchyListener(hierarchyListener); + this.isShowing = isShowing(); } @Override @@ -524,7 +537,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } return; // not yet available .. } - if( isVisible() && !printActive ) { + if( isShowing && !printActive ) { Threading.invoke(true, displayOnEDTAction, getTreeLock()); } } @@ -583,15 +596,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } - @Override - public void setVisible(boolean b) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: setVisible("+b+")"); - Thread.dumpStack(); - } - super.setVisible(b); - } - /** Overridden to track when this component is added to a container. Subclasses which override this method must call super.addNotify() in their addNotify() method in order to @@ -814,9 +818,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printActive = false; return; // not yet available .. } - if( !isVisible() ) { + if( !isShowing ) { if(DEBUG) { - System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable visible"); + System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable valid, canvas not showing"); } printActive = false; return; // not yet available .. @@ -1148,7 +1152,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing ",\n\thandle 0x"+Long.toHexString(getHandle())+ ",\n\tDrawable size "+dw+"x"+dh+ ",\n\tAWT pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ - ",\n\tvisible "+isVisible()+", displayable "+isDisplayable()+ + ",\n\tvisible "+isVisible()+", displayable "+isDisplayable()+", showing "+isShowing+ ",\n\t"+awtConfig+"]"; } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index a71b47c64..f7200186b 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -48,6 +48,8 @@ import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; @@ -265,6 +267,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return null == customPixelBufferProvider && useJava2DGLPipeline && java2DGLPipelineOK; } + private volatile boolean isShowing; + private final HierarchyListener hierarchyListener = new HierarchyListener() { + @Override + public void hierarchyChanged(HierarchyEvent e) { + isShowing = GLJPanel.this.isShowing(); + } + }; + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override @@ -346,6 +356,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing helper.setSharedContext(null, shareWith); } this.setFocusable(true); // allow keyboard input! + this.addHierarchyListener(hierarchyListener); + this.isShowing = isShowing(); } /** @@ -418,7 +430,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void display() { - if( isVisible() ) { + if( isShowing ) { if (EventQueue.isDispatchThread()) { // Want display() to be synchronous, so call paintImmediately() paintImmediately(0, 0, getWidth(), getHeight()); @@ -521,7 +533,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing sendReshape = handleReshape(); } - if( isVisible() ) { + if( isShowing ) { updater.setGraphics(g); backend.doPaintComponent(g); } @@ -608,9 +620,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printActive = false; return; // not yet available .. } - if( !isVisible() ) { + if( !isShowing ) { if(DEBUG) { - System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable visible"); + System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable valid, panel not showing"); } printActive = false; return; // not yet available .. diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index ed25a497f..4b0ae5d20 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -125,9 +125,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, private String jawtStr() { return "JAWTWindow["+id(JAWTWindow.this)+"]"; } private class JAWTComponentListener implements ComponentListener, HierarchyListener { - private boolean localVisibility = component.isVisible(); - private boolean globalVisibility = localVisibility; - private boolean visibilityPropagation = false; + private boolean isShowing; private String str(Object obj) { if( null == obj ) { @@ -141,14 +139,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } } private String s(ComponentEvent e) { - return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"],"+Platform.getNewline()+ + return "visible[isShowing "+isShowing+"],"+Platform.getNewline()+ " ** COMP "+str(e.getComponent())+Platform.getNewline()+ " ** SOURCE "+str(e.getSource())+Platform.getNewline()+ " ** THIS "+str(component)+Platform.getNewline()+ " ** THREAD "+getThreadName(); } private String s(HierarchyEvent e) { - return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"], changeBits 0x"+Long.toHexString(e.getChangeFlags())+Platform.getNewline()+ + return "visible[isShowing "+isShowing+"], changeBits 0x"+Long.toHexString(e.getChangeFlags())+Platform.getNewline()+ " ** COMP "+str(e.getComponent())+Platform.getNewline()+ " ** SOURCE "+str(e.getSource())+Platform.getNewline()+ " ** CHANGED "+str(e.getChanged())+Platform.getNewline()+ @@ -158,12 +156,13 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override public final String toString() { - return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"],"+Platform.getNewline()+ + return "visible[isShowing "+isShowing+"],"+Platform.getNewline()+ " ** THIS "+str(component)+Platform.getNewline()+ " ** THREAD "+getThreadName(); } private JAWTComponentListener() { + isShowing = component.isShowing(); if(DEBUG) { System.err.println(jawtStr()+".attach @ Thread "+getThreadName()+": "+toString()); } @@ -177,7 +176,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } component.removeComponentListener(this); component.removeHierarchyListener(this); - component.setVisible(localVisibility); // restore component's original local state } @Override @@ -185,7 +183,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(DEBUG) { System.err.println(jawtStr()+".componentResized: "+s(e)); } - layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility); + layoutSurfaceLayerIfEnabled(isShowing); } @Override @@ -193,7 +191,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(DEBUG) { System.err.println(jawtStr()+".componentMoved: "+s(e)); } - layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility); + layoutSurfaceLayerIfEnabled(isShowing); } @Override @@ -201,7 +199,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(DEBUG) { System.err.println(jawtStr()+".componentShown: "+s(e)); } - layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility); + layoutSurfaceLayerIfEnabled(isShowing); } @Override @@ -209,59 +207,27 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(DEBUG) { System.err.println(jawtStr()+".componentHidden: "+s(e)); } - layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility); + layoutSurfaceLayerIfEnabled(isShowing); } @Override public final void hierarchyChanged(HierarchyEvent e) { - final long bits = e.getChangeFlags(); - final java.awt.Component changed = e.getChanged(); - final boolean compIsVisible = component.isVisible(); - if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) { - final boolean displayable = changed.isDisplayable(); - final boolean propagateDisplayability = changed == component && ( displayable && localVisibility ) != compIsVisible; - final boolean visible = displayable && localVisibility; - final boolean propagateDisplayability = changed == component && visible != compIsVisible; - if( propagateDisplayability ) { - // Propagate parent's displayability, i.e. 'removeNotify()' and 'addNotify()' - visibilityPropagation = true; - globalVisibility = displayable; - if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged DISPLAYABILITY_CHANGED (1): displayable "+displayable+" -> visible "+visible+", "+s(e)); - } - component.setVisible(visible); - } else if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged DISPLAYABILITY_CHANGED (x): displayable "+displayable+", "+s(e)); + final boolean wasAWTCompShowing = isShowing; + isShowing = component.isShowing(); + int action = 0; + if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & e.getChangeFlags() ) ) { + if( e.getChanged() != component && wasAWTCompShowing != isShowing ) { + // A parent component changed and caused a 'showing' state change, + // propagate to offscreen-layer! + layoutSurfaceLayerIfEnabled(isShowing); + action = 1; } - } else if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) { - final boolean showing = changed.isShowing(); - final boolean visible = showing && localVisibility; - final boolean propagateVisibility = changed != component && visible != compIsVisible; - if( propagateVisibility ) { - // Propagate parent's visibility - visibilityPropagation = true; - globalVisibility = showing; - if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (1): showing "+showing+" -> visible "+visible+", "+s(e)); - } - component.setVisible(visible); - } else if( changed == component ) { - // Update component's local visibility state - if(!visibilityPropagation) { - localVisibility = compIsVisible; - } - visibilityPropagation = false; - if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (0): showing "+showing+" -> visible "+visible+", "+s(e)); - } - } else if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (x): showing "+showing+" -> visible "+visible+", "+s(e)); - } - } else if(DEBUG) { + } + if(DEBUG) { + final java.awt.Component changed = e.getChanged(); final boolean displayable = changed.isDisplayable(); - final boolean _visible = displayable && localVisibility; final boolean showing = changed.isShowing(); - System.err.println(jawtStr()+".hierarchyChanged OTHER: displayable "+displayable+", showing "+showing+" -> visible "+_visible+", "+s(e)); + System.err.println(jawtStr()+".hierarchyChanged: action "+action+", displayable "+displayable+", showing [changed "+showing+", comp "+isShowing+"], "+s(e)); } } } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 00c3f1eb7..1ed628435 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -621,9 +621,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto printActive = false; return; // not yet available .. } - if( !isVisible() ) { + if( !isShowing() ) { if(DEBUG) { - System.err.println(currentThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); + System.err.println(currentThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable valid, canvas not showing"); } printActive = false; return; // not yet available .. diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAWTCardLayoutAnimatorStartStopBug532.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAWTCardLayoutAnimatorStartStopBug532.java index 7f861d89b..3790a87f7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAWTCardLayoutAnimatorStartStopBug532.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAWTCardLayoutAnimatorStartStopBug532.java @@ -2,6 +2,7 @@ package com.jogamp.opengl.test.junit.jogl.acore.anim; import java.awt.BorderLayout; import java.awt.CardLayout; +import java.awt.Component; import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -30,55 +31,60 @@ import com.jogamp.opengl.util.FPSAnimator; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { - static final String LABEL = "Label"; + static final String LABEL = "Label"; static final String CANVAS = "GLCanvas"; - + public enum AnimatorControlBehavior { StartStop, PauseResume, Continue; } - - static long durationPerTest = 200*4; // ms + + static long durationPerTest = 200*4; // ms static boolean manual = false; static volatile boolean shouldStop = false; - + private String selected = LABEL; - + @Test public void testFPSAnimatorStartStop() throws InterruptedException, InvocationTargetException { testImpl(AnimatorControlBehavior.StartStop, true); } - + @Test public void testFPSAnimatorResumePause() throws InterruptedException, InvocationTargetException { testImpl(AnimatorControlBehavior.PauseResume, true); } - + @Test public void testFPSAnimatorContinue() throws InterruptedException, InvocationTargetException { testImpl(AnimatorControlBehavior.Continue, true); } - + @Test public void testAnimatorStartStop() throws InterruptedException, InvocationTargetException { testImpl(AnimatorControlBehavior.StartStop, false); } - + @Test public void testAnimatorResumePause() throws InterruptedException, InvocationTargetException { testImpl(AnimatorControlBehavior.PauseResume, false); } - + @Test public void testAnimatorContinue() throws InterruptedException, InvocationTargetException { testImpl(AnimatorControlBehavior.Continue, false); } - + + private static String id(Object obj) { return "0x" + ( null!=obj ? Integer.toHexString(obj.hashCode()) : "nil" ); } + private static String str(Component c) { + return id(c)+": "+c.getClass().getSimpleName()+"[visible "+c.isVisible()+", showing "+c.isShowing()+", valid "+c.isValid()+ + ", displayable "+c.isDisplayable()+", "+c.getX()+"/"+c.getY()+" "+c.getWidth()+"x"+c.getHeight()+"]"; + } void testImpl(final AnimatorControlBehavior animCtrl, boolean useFPSAnimator) throws InterruptedException, InvocationTargetException { - final GLProfile glp = GLProfile.get(GLProfile.GL2); - final GLCapabilities caps = new GLCapabilities(glp); - final GLCanvas canvas = new GLCanvas(caps); + final GLProfile glp = GLProfile.get(GLProfile.GL2); + final GLCapabilities caps = new GLCapabilities(glp); + final GLCanvas canvas = new GLCanvas(caps); canvas.setPreferredSize(new Dimension(640, 480)); - + final GLAnimatorControl animatorCtrl = useFPSAnimator ? new FPSAnimator(canvas, 60) : new Animator(canvas); animatorCtrl.setUpdateFPSFrames(60, null);// System.err); switch (animCtrl) { @@ -95,7 +101,7 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { canvas.addGLEventListener(new GearsES2(1)); /* if(Platform.OS_TYPE == Platform.OSType.WINDOWS) { canvas.addGLEventListener(new GLEventListener() { - public void init(GLAutoDrawable drawable) { } + public void init(GLAutoDrawable drawable) { } public void dispose(GLAutoDrawable drawable) { } public void display(GLAutoDrawable drawable) { final NativeWindow win = (NativeWindow) drawable.getNativeSurface(); @@ -112,15 +118,17 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { final JFrame frame = new JFrame(); frame.setTitle(getSimpleTestName(" - ")); - frame.addWindowListener(new WindowAdapter() { + frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { animatorCtrl.stop(); shouldStop = true; - } + } }); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - final JPanel cards = new JPanel(new CardLayout()); + + final JLabel label = new JLabel("A label to cover the canvas"); + + final JPanel cards = new JPanel(new CardLayout()); final JPanel comboBoxPanel = new JPanel(); // nicer look .. final JComboBox comboBox = new JComboBox(new String[] { LABEL, CANVAS }); comboBox.setEditable(false); @@ -131,7 +139,13 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { if(!newSelection.equals(selected)) { final String oldSelected = selected; if(newSelection.equals(CANVAS)) { - cl.show(cards, CANVAS); + System.err.println("XXX Card.SHOW Canvas PRE: "); + System.err.println(" CANVAS "+str(canvas)); + System.err.println(" LABEL "+str(label)); + cl.show(cards, CANVAS); + System.err.println("XXX Card.SHOW Canvas POST: "); + System.err.println(" CANVAS "+str(canvas)); + System.err.println(" LABEL "+str(label)); switch (animCtrl) { case StartStop: animatorCtrl.start(); @@ -152,31 +166,37 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { break; default: } - cl.show(cards, LABEL); + System.err.println("XXX Card.SHOW Label PRE: "); + System.err.println(" CANVAS "+str(canvas)); + System.err.println(" LABEL "+str(label)); + cl.show(cards, LABEL); + System.err.println("XXX Card.SHOW Label POST: "); + System.err.println(" CANVAS "+str(canvas)); + System.err.println(" LABEL "+str(label)); selected = LABEL; } else { throw new RuntimeException("oops .. unexpected item: "+evt); } - System.err.println("Item Change: "+oldSelected+" -> "+selected+", "+animatorCtrl); + System.err.println("Item Change: "+oldSelected+" -> "+selected+", "+animatorCtrl); } else { System.err.println("Item Stays: "+selected+", "+animatorCtrl); } } }); - comboBoxPanel.add(comboBox); + comboBoxPanel.add(comboBox); - cards.add(new JLabel("A label to cover the canvas"), LABEL); + cards.add(label, LABEL); cards.add(canvas, CANVAS); - + frame.add(comboBoxPanel, BorderLayout.PAGE_START); frame.add(cards, BorderLayout.CENTER); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - frame.pack(); + frame.pack(); frame.setVisible(true); }}); - + if(manual) { for(long w=durationPerTest; !shouldStop && w>0; w-=100) { Thread.sleep(100); @@ -187,34 +207,34 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { comboBox.setSelectedItem(LABEL); }}); Thread.sleep(durationPerTest/4); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { comboBox.setSelectedItem(CANVAS); }}); Thread.sleep(durationPerTest/4); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { comboBox.setSelectedItem(LABEL); }}); Thread.sleep(durationPerTest/4); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { comboBox.setSelectedItem(CANVAS); }}); Thread.sleep(durationPerTest/4); } - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.setVisible(false); frame.dispose(); }}); - + } - + public static void main(String args[]) { for(int i=0; i= frameCountT1 - frameCountT0); - + + System.err.println("XXXX Visible Part 3/3"); setComponentVisible(glc, true); Assert.assertTrue("Component didn't become visible", AWTRobotUtil.waitForVisible(glc, true)); anim.resetFPSCounter(); - System.err.println("Visible Part 3/3"); - + while( anim.getTotalFPSDuration() < durationPerTest ) { Thread.sleep(60); } - + System.err.println("GLCanvas isOffscreenLayerSurfaceEnabled: "+glc.isOffscreenLayerSurfaceEnabled()+": "+glc.getChosenGLCapabilities()); - - dispose(top[0]); + + dispose(top[0]); } } @@ -258,7 +258,7 @@ public class TestBug664GLCanvasSetVisibleSwingAWT extends UITestCase { } runTestGL(false, caps); } - + public static void main(String args[]) throws IOException { for(int i=0; i Panel1("+id(panel1)+") START"); dumpGLCanvasStats(glCanvas); panel1.add(glCanvas, BorderLayout.CENTER); dumpGLCanvasStats(glCanvas); - } else { + } else if (tabbedPanel.getSelectedIndex() == 1) { System.err.println("XXXX Add GLCanvas Panel1("+id(panel1)+" -> Panel2("+id(panel2)+") START"); dumpGLCanvasStats(glCanvas); panel2.add(glCanvas, BorderLayout.CENTER); dumpGLCanvasStats(glCanvas); + } else { + System.err.println("XXXX NOP"); + dumpGLCanvasStats(glCanvas); } } }); @@ -119,33 +127,44 @@ public class TestBug816JTabbedPanelVisibilityB849B878AWT extends UITestCase { Thread.sleep(100); } } else { + Thread.sleep(durationPerTest/6); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - System.err.println("XXXX Add GLCanvas Panel2("+id(panel2)+") -> Panel1("+id(panel1)+" START"); - tabbedPanel.setSelectedIndex(0); + System.err.println("XXXX Panel1("+id(panel1)+" -> Panel2("+id(panel2)+") START"); + tabbedPanel.setSelectedIndex(1); }}); - Thread.sleep(durationPerTest/4); + Thread.sleep(durationPerTest/6); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - System.err.println("XXXX Add GLCanvas Panel1("+id(panel1)+" -> Panel2("+id(panel2)+") START"); - tabbedPanel.setSelectedIndex(1); + System.err.println("XXXX Panel2("+id(panel2)+") -> Panel3("+id(panel3)+" START"); + tabbedPanel.setSelectedIndex(2); }}); - Thread.sleep(durationPerTest/4); + Thread.sleep(durationPerTest/6); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - System.err.println("XXXX Add GLCanvas Panel2("+id(panel2)+") -> Panel1("+id(panel1)+" START"); + System.err.println("XXXX Panel3("+id(panel3)+") -> Panel1("+id(panel1)+" START"); tabbedPanel.setSelectedIndex(0); }}); - Thread.sleep(durationPerTest/4); + // one loop done + + Thread.sleep(durationPerTest/6); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - System.err.println("XXXX Add GLCanvas Panel1("+id(panel1)+" -> Panel2("+id(panel2)+") START"); + System.err.println("XXXX Panel1("+id(panel1)+" -> Panel2("+id(panel2)+") START"); tabbedPanel.setSelectedIndex(1); }}); - Thread.sleep(durationPerTest/4); + + Thread.sleep(durationPerTest/6); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + System.err.println("XXXX Panel2("+id(panel2)+") -> Panel1("+id(panel1)+" START"); + tabbedPanel.setSelectedIndex(0); + }}); + + Thread.sleep(durationPerTest/6); } SwingUtilities.invokeLater(new Runnable() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java index e1a0944e1..29dc9a190 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java @@ -95,8 +95,10 @@ public class TestBug816OSXCALayerPos03aB729AWT extends UITestCase { final Checkbox checkbox = new Checkbox("Visible canvas", true); checkbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { - glCanvas1.setVisible(checkbox.getState()); - System.out.println("Canvas visible: "+glCanvas1.isVisible()); + final boolean visible = checkbox.getState(); + System.err.println("XXXX Canvas setVisible "+visible); + glCanvas1.setVisible(visible); + System.err.println("XXXX Canvas visible: "+glCanvas1.isVisible()); if( glCanvas1.isVisible() ) { frame.validate(); // take care of resized frame while hidden } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java index b9ee6a4f6..3e60c8b47 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java @@ -101,8 +101,10 @@ public class TestBug816OSXCALayerPos03bB849AWT extends UITestCase { final Checkbox checkbox = new Checkbox("Visible canvas", true); checkbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { - panel.setVisible(checkbox.getState()); - System.out.println("Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); + final boolean visible = checkbox.getState(); + System.err.println("XXXX Panel setVisible "+visible); + panel.setVisible(visible); + System.err.println("XXXX Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); if( panel.isVisible() ) { frame.validate(); // take care of resized frame while hidden } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java index 9a536d50c..24f9de961 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java @@ -103,8 +103,10 @@ public class TestBug816OSXCALayerPos03cB849AWT extends UITestCase { final JCheckBox checkbox = new JCheckBox("Visible canvas", true); checkbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { - panel.setVisible(checkbox.getSelectedObjects()!=null); - System.out.println("Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); + final boolean visible = checkbox.getSelectedObjects()!=null; + System.err.println("XXXX Panel setVisible "+visible); + panel.setVisible(visible); + System.err.println("XXXX Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); if( panel.isVisible() ) { frame.validate(); // take care of resized frame while hidden } -- cgit v1.2.3 From d2f50f2ed523aa8443f647e46aeecc09fa27583d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 12 Jan 2014 07:56:54 +0100 Subject: AWTParentWindowAdapter/AWTRobotUtil: Use 'isShowing()' instead of 'isVisible()' determining actual on-screen showing state See commit 071bdd6ce9f8c41ccecdbf8bc74f276ccd7ff651 --- .../newt/awt/event/AWTParentWindowAdapter.java | 20 ++++++++++---------- .../jogamp/opengl/test/junit/util/AWTRobotUtil.java | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index e152d96d5..770502326 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -121,13 +121,14 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt newtChild.runOnEDTIfAvail(false, new Runnable() { @Override public void run() { - int cw = comp.getWidth(); - int ch = comp.getHeight(); + final int cw = comp.getWidth(); + final int ch = comp.getHeight(); if( 0 < cw && 0 < ch ) { if( newtChild.getWidth() != cw || newtChild.getHeight() != ch ) { newtChild.setSize(cw, ch); - if(comp.isVisible() != newtChild.isVisible()) { - newtChild.setVisible(comp.isVisible()); + final boolean v = comp.isShowing(); // compute showing-state throughout hierarchy + if(v != newtChild.isVisible()) { + newtChild.setVisible(v); } } } else if(newtChild.isVisible()) { @@ -164,12 +165,12 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt if( !isSetup ) { return; } final Window newtChild = getNewtWindow(); if( null != newtChild && null == getNewtEventListener() ) { - long bits = e.getChangeFlags(); - final java.awt.Component changed = e.getChanged(); + final long bits = e.getChangeFlags(); + final java.awt.Component comp = e.getComponent(); if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) { - final boolean showing = changed.isShowing(); + final boolean showing = comp.isShowing(); // compute showing-state throughout hierarchy if(DEBUG_IMPLEMENTATION) { - System.err.println("AWT: hierarchyChanged SHOWING_CHANGED: showing "+showing+", "+changed+", source "+e.getComponent()); + System.err.println("AWT: hierarchyChanged SHOWING_CHANGED: showing "+showing+", comp "+comp+", changed "+e.getChanged()); } newtChild.runOnEDTIfAvail(false, new Runnable() { @Override @@ -181,8 +182,7 @@ public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt } if(DEBUG_IMPLEMENTATION) { if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) { - final boolean displayability = changed.isDisplayable(); - System.err.println("AWT: hierarchyChanged DISPLAYABILITY_CHANGED: displayability "+displayability+", "+changed); + System.err.println("AWT: hierarchyChanged DISPLAYABILITY_CHANGED: "+e.getChanged()); } } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index cf58ae257..599a6dc9f 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -656,7 +656,7 @@ public class AWTRobotUtil { } } else if(NativeWindowFactory.isAWTAvailable() && obj instanceof java.awt.Component) { java.awt.Component comp = (java.awt.Component) obj; - for (wait=0; wait Date: Sun, 12 Jan 2014 08:08:42 +0100 Subject: DefaultEDTUtil: At EDT finish, notify all task-waiter to avoid deadlock at error / Add test method 'invokeAndWaitError(..)' --- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 49 ++++++++++++++++++---- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 49 +++++++++++++++++----- .../jogamp/opengl/test/junit/util/QuitAdapter.java | 17 ++++---- 3 files changed, 88 insertions(+), 27 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index f33b4744e..d481ce8f9 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -50,6 +50,11 @@ import com.jogamp.newt.util.EDTUtil; public class DefaultEDTUtil implements EDTUtil { public static final boolean DEBUG = Debug.debug("EDT"); + /** Used to implement {@link #invokeStop(boolean, Runnable)}. */ + private static final Object TASK_ATTACHMENT_STOP = new Object(); + /** Used to provoke an exception on the EDT while waiting / blocking. Merely exists to test code.*/ + private static final Object TASK_ATTACHMENT_TEST_ERROR = new Object(); + private final Object edtLock = new Object(); // locking the EDT start/stop state private /* final */ ThreadGroup threadGroup; private final String name; @@ -139,12 +144,20 @@ public class DefaultEDTUtil implements EDTUtil { System.err.println(Thread.currentThread()+": Default-EDT.invokeStop wait "+wait); Thread.dumpStack(); } - return invokeImpl(wait, task, true); + return invokeImpl(wait, task, true /* stop */, false /* provokeError */); + } + + public final boolean invokeAndWaitError(Runnable task) { + if(DEBUG) { + System.err.println(Thread.currentThread()+": Default-EDT.invokeAndWaitError"); + Thread.dumpStack(); + } + return invokeImpl(true /* wait */, task, false /* stop */, true /* provokeError */); } @Override public final boolean invoke(boolean wait, Runnable task) { - return invokeImpl(wait, task, false); + return invokeImpl(wait, task, false /* stop */, false /* provokeError */); } private static Runnable nullTask = new Runnable() { @@ -152,7 +165,7 @@ public class DefaultEDTUtil implements EDTUtil { public void run() { } }; - private final boolean invokeImpl(boolean wait, Runnable task, boolean stop) { + private final boolean invokeImpl(boolean wait, Runnable task, boolean stop, boolean provokeError) { Throwable throwable = null; RunnableTask rTask = null; final Object rTaskLock = new Object(); @@ -204,7 +217,9 @@ public class DefaultEDTUtil implements EDTUtil { true /* always catch and report Exceptions, don't disturb EDT */, wait ? null : System.err); if(stop) { - rTask.setAttachment(new Boolean(true)); // mark final task, will imply shouldStop:=true + rTask.setAttachment(TASK_ATTACHMENT_STOP); // mark final task, will imply shouldStop:=true + } else if(provokeError) { + rTask.setAttachment(TASK_ATTACHMENT_TEST_ERROR); } // append task .. edt.tasks.add(rTask); @@ -283,7 +298,7 @@ public class DefaultEDTUtil implements EDTUtil { class NEDT extends Thread { volatile boolean shouldStop = false; volatile boolean isRunning = false; - ArrayList tasks = new ArrayList(); // one shot tasks + final ArrayList tasks = new ArrayList(); // one shot tasks public NEDT(ThreadGroup tg, String name) { super(tg, name); @@ -340,8 +355,13 @@ public class DefaultEDTUtil implements EDTUtil { if(tasks.size()>0) { task = tasks.remove(0); tasks.notifyAll(); - if( null != task.getAttachment() ) { + final Object attachment = task.getAttachment(); + if( TASK_ATTACHMENT_STOP == attachment ) { shouldStop = true; + } else if( TASK_ATTACHMENT_TEST_ERROR == attachment ) { + tasks.add(0, task); + task = null; + throw new RuntimeException("TASK_ATTACHMENT_TEST_ERROR"); } } } @@ -366,16 +386,27 @@ public class DefaultEDTUtil implements EDTUtil { error = new RuntimeException("Within Default-EDT", t); } } finally { + final String msg = getName()+": Default-EDT finished w/ "+tasks.size()+" left"; if(DEBUG) { - RunnableTask rt = ( tasks.size() > 0 ) ? tasks.get(0) : null ; - System.err.println(getName()+": Default-EDT run() END "+ getName()+", tasks: "+tasks.size()+", "+rt+", "+error); + System.err.println(msg+", "+error); } synchronized(edtLock) { + int i = 0; + while( tasks.size() > 0 ) { + // notify all waiter + final String msg2 = msg+", task #"+i; + final Throwable t = null != error ? new Throwable(msg2, error) : new Throwable(msg2); + final RunnableTask rt = tasks.remove(0); + if( null != rt ) { + rt.flush(t); + i++; + } + } isRunning = false; edtLock.notifyAll(); } if(DEBUG) { - System.err.println(getName()+": Default-EDT run() EXIT "+ getName()+", exception: "+error); + System.err.println(msg+" EXIT, exception: "+error); } if(null!=error) { throw error; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 059a930ed..bfed497e8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -36,6 +36,7 @@ import com.jogamp.newt.Display; import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; @@ -43,6 +44,7 @@ import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.EDTUtil; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -63,6 +65,8 @@ import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; +import jogamp.newt.DefaultEDTUtil; + import org.junit.Assert; import org.junit.BeforeClass; import org.junit.AfterClass; @@ -98,7 +102,7 @@ public class TestGearsES2NEWT extends UITestCase { static boolean mainRun = false; static boolean exclusiveContext = false; static boolean useAnimator = true; - static enum SysExit { none, testExit, testError, displayExit, displayError }; + static enum SysExit { none, testExit, testError, testEDTError, displayExit, displayError, displayEDTError }; static SysExit sysExit = SysExit.none; @BeforeClass @@ -158,7 +162,7 @@ public class TestGearsES2NEWT extends UITestCase { animator.setExclusiveContext(exclusiveContext); } - QuitAdapter quitAdapter = new QuitAdapter(); + final QuitAdapter quitAdapter = new QuitAdapter(); //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); glWindow.addKeyListener(quitAdapter); @@ -349,25 +353,38 @@ public class TestGearsES2NEWT extends UITestCase { Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread()); } - if( SysExit.displayError == sysExit || SysExit.displayExit == sysExit ) { + if( SysExit.displayError == sysExit || SysExit.displayExit == sysExit || SysExit.displayEDTError == sysExit ) { glWindow.addGLEventListener(new GLEventListener() { - @Override public void init(GLAutoDrawable drawable) {} - @Override public void dispose(GLAutoDrawable drawable) { } - @Override public void display(GLAutoDrawable drawable) { final GLAnimatorControl anim = drawable.getAnimator(); if( null != anim && anim.isAnimating() ) { - if( anim.getTotalFPSDuration() >= duration/2 ) { + final long ms = anim.getTotalFPSDuration(); + if( ms >= duration/2 || ms >= 3000 ) { // max 3s wait until provoking error if( SysExit.displayError == sysExit ) { - throw new Error("test error send from GLEventListener"); + throw new Error("test error send from GLEventListener.display - "+Thread.currentThread()); } else if ( SysExit.displayExit == sysExit ) { System.err.println("exit(0) send from GLEventListener"); System.exit(0); + } else if ( SysExit.displayEDTError == sysExit ) { + final Object upstream = drawable.getUpstreamWidget(); + System.err.println("EDT invokeAndWaitError: upstream type "+upstream.getClass().getName()); + if( upstream instanceof Window ) { + final EDTUtil edt = ((Window)upstream).getScreen().getDisplay().getEDTUtil(); + System.err.println("EDT invokeAndWaitError: edt type "+edt.getClass().getName()); + if( edt instanceof DefaultEDTUtil ) { + quitAdapter.doQuit(); + ((DefaultEDTUtil)edt).invokeAndWaitError(new Runnable() { + public void run() { + throw new RuntimeException("XXX Should never ever be seen! - "+Thread.currentThread()); + } + }); + } + } } } } else { @@ -403,13 +420,25 @@ public class TestGearsES2NEWT extends UITestCase { while(!quitAdapter.shouldQuit() && t1-t0= duration/2 ) { - if( SysExit.testError == sysExit || SysExit.testExit == sysExit ) { + if( SysExit.testError == sysExit || SysExit.testExit == sysExit || SysExit.testEDTError == sysExit) { + final long ms = t1-t0; + if( ms >= duration/2 || ms >= 3000 ) { // max 3s wait until provoking error if( SysExit.testError == sysExit ) { throw new Error("test error send from test thread"); } else if ( SysExit.testExit == sysExit ) { System.err.println("exit(0) send from test thread"); System.exit(0); + } else if ( SysExit.testEDTError == sysExit ) { + final EDTUtil edt = glWindow.getScreen().getDisplay().getEDTUtil(); + System.err.println("EDT invokeAndWaitError: edt type "+edt.getClass().getName()); + if( edt instanceof DefaultEDTUtil ) { + quitAdapter.doQuit(); + ((DefaultEDTUtil)edt).invokeAndWaitError(new Runnable() { + public void run() { + throw new RuntimeException("XXX Should never ever be seen!"); + } + }); + } } } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/QuitAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/QuitAdapter.java index b5864e39c..467dd7fae 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/QuitAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/QuitAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.util; import com.jogamp.newt.event.*; @@ -35,10 +35,11 @@ public class QuitAdapter extends WindowAdapter implements WindowListener, KeyLis boolean enabled = true; public void enable(boolean v) { enabled = v; } - + public void clear() { shouldQuit = false; } - + public boolean shouldQuit() { return shouldQuit; } + public void doQuit() { shouldQuit=true; } public void windowDestroyNotify(WindowEvent e) { if( enabled ) { @@ -50,7 +51,7 @@ public class QuitAdapter extends WindowAdapter implements WindowListener, KeyLis public void keyReleased(KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; - } + } if( enabled ) { if(e.getKeyChar()=='q') { System.err.println("QUIT Key "+Thread.currentThread()); -- cgit v1.2.3 From 1635eeba33368aee52f23baebcfd74c25a7f113a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 12 Jan 2014 17:11:23 +0100 Subject: JOGLNewtAppletBase: Typo of new PNG icons .. used AE's 'gray' instead of BE's 'grey', which is used for the filename Same as 42d3b31d1becd8eb8e2847c87e14e47e15e730cd --- src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 7a36505c1..2afa97327 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -235,7 +235,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { glWindow.setVisible(true); glWindow.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); if( null == pointerIconTest ) { - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/cross-gray-alpha-16x16.png" } ); + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/cross-grey-alpha-16x16.png" } ); final Display disp = glWindow.getScreen().getDisplay(); try { pointerIconTest = disp.createPointerIcon(res, 8, 8); -- cgit v1.2.3 From 833045b419a501d5d7d0501dc8b2555b86e90474 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 23 Jan 2014 17:31:42 +0100 Subject: NEWT X11 DisplayDriver.dispatchMessagesNative(): Avoid aDevice NPE while being pulled --- src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 391b8b19d..5c2820dab 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -105,16 +105,15 @@ public class DisplayDriver extends DisplayImpl { @Override protected void dispatchMessagesNative() { - aDevice.lock(); + final AbstractGraphicsDevice _aDevice = aDevice; // aDevice could be pulled by destroy event + _aDevice.lock(); try { - final long handle = aDevice.getHandle(); + final long handle = _aDevice.getHandle(); if(0 != handle) { DispatchMessages0(handle, javaObjectAtom, windowDeleteAtom /*, kbdHandle */); // XKB disabled for now } } finally { - if(null != aDevice) { // could be pulled by destroy event - aDevice.unlock(); - } + _aDevice.unlock(); } } -- cgit v1.2.3 From 9a642c08f9ee818a89d5eab8ce16ca8e0ee7f9d9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 23 Jan 2014 18:00:04 +0100 Subject: EGLDisplayUtil.eglCreateEGLGraphicsDevice(..): Don't open() device implicit; EGLDrawableFactory.mapAvailableEGLESConfig(..): Clarify --- .../classes/jogamp/opengl/egl/EGLDisplayUtil.java | 35 ++-- .../jogamp/opengl/egl/EGLDrawableFactory.java | 46 ++--- .../opengl/egl/EGLDynamicLibraryBundleInfo.java | 3 + .../egl/EGLGraphicsConfigurationFactory.java | 9 +- .../jogamp/opengl/egl/EGLUpstreamSurfaceHook.java | 1 + .../jogamp/nativewindow/egl/EGLGraphicsDevice.java | 12 ++ .../jogamp/newt/driver/android/DisplayDriver.java | 11 +- .../jogamp/newt/driver/android/WindowDriver.java | 217 +++++++++++---------- .../newt/driver/bcm/vc/iv/DisplayDriver.java | 1 + .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 1 + .../jogamp/newt/driver/kd/DisplayDriver.java | 1 + 11 files changed, 182 insertions(+), 155 deletions(-) (limited to 'src/newt/classes') diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index 0577124eb..a1899e032 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -188,6 +188,11 @@ public class EGLDisplayUtil { } /** + * Attempts to {@link #eglGetDisplayAndInitialize(long, long[], int[], IntBuffer, IntBuffer)} with given nativeDisplayID. + * If this fails, method retries with nativeDisplayID {@link EGL#EGL_DEFAULT_DISPLAY} - the fallback mechanism. + * The actual used nativeDisplayID is returned in it's in/out array. + * + * @throws GLException if {@link EGL#eglGetDisplay(long)} or {@link EGL#eglInitialize(long, int[], int, int[], int)} fails incl fallback * @param nativeDisplayID in/out array of size 1, passing the requested nativeVisualID, may return a different revised nativeVisualID handle * @return the initialized EGL display ID * @throws GLException if not successful @@ -261,24 +266,34 @@ public class EGLDisplayUtil { }; /** + * Returns an uninitialized {@link EGLGraphicsDevice}. User needs to issue {@link EGLGraphicsDevice#open()} before usage. + *

                      + * Using {@link #eglGetDisplayAndInitialize(long[])} for the {@link EGLGraphicsDevice#open()} implementation + * and {@link #eglTerminate(long)} for {@link EGLGraphicsDevice#close()}. + *

                      + *

                      * Using the default {@link ToolkitLock}, via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}. + *

                      * @param nativeDisplayID * @param connection * @param unitID - * @return an initialized EGLGraphicsDevice - * @throws GLException if {@link EGL#eglGetDisplay(long)} or {@link EGL#eglInitialize(long, int[], int, int[], int)} fails - * @see EGLGraphicsDevice#EGLGraphicsDevice(long, long, String, int, com.jogamp.nativewindow.egl.EGLGraphicsDevice.EGLDisplayLifecycleCallback) + * @return an uninitialized {@link EGLGraphicsDevice} */ public static EGLGraphicsDevice eglCreateEGLGraphicsDevice(long nativeDisplayID, String connection, int unitID) { - final EGLGraphicsDevice eglDisplay = new EGLGraphicsDevice(nativeDisplayID, EGL.EGL_NO_DISPLAY, connection, unitID, eglLifecycleCallback); - eglDisplay.open(); - return eglDisplay; + return new EGLGraphicsDevice(nativeDisplayID, EGL.EGL_NO_DISPLAY, connection, unitID, eglLifecycleCallback); } /** + * Returns an uninitialized {@link EGLGraphicsDevice}. User needs to issue {@link EGLGraphicsDevice#open()} before usage. + *

                      + * Using {@link #eglGetDisplayAndInitialize(long[])} for the {@link EGLGraphicsDevice#open()} implementation + * and {@link #eglTerminate(long)} for {@link EGLGraphicsDevice#close()}. + *

                      + *

                      + * Using the default {@link ToolkitLock}, via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}. + *

                      * @param surface - * @return an initialized EGLGraphicsDevice - * @throws GLException if {@link EGL#eglGetDisplay(long)} or {@link EGL#eglInitialize(long, int[], int, int[], int)} fails incl fallback + * @return an uninitialized EGLGraphicsDevice */ public static EGLGraphicsDevice eglCreateEGLGraphicsDevice(NativeSurface surface) { final long nativeDisplayID; @@ -288,8 +303,6 @@ public class EGLDisplayUtil { nativeDisplayID = surface.getDisplayHandle(); // 0 == EGL.EGL_DEFAULT_DISPLAY } final AbstractGraphicsDevice adevice = surface.getGraphicsConfiguration().getScreen().getDevice(); - final EGLGraphicsDevice eglDevice = new EGLGraphicsDevice(nativeDisplayID, EGL.EGL_NO_DISPLAY, adevice.getConnection(), adevice.getUnitID(), eglLifecycleCallback); - eglDevice.open(); - return eglDevice; + return new EGLGraphicsDevice(nativeDisplayID, EGL.EGL_NO_DISPLAY, adevice.getConnection(), adevice.getUnitID(), eglLifecycleCallback); } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 1ff16fff8..3651d71a9 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -192,8 +192,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } sharedMap = new HashMap(); sharedMapCreateAttempt = new HashSet(); - - // FIXME: Following triggers eglInitialize(..) which crashed on Windows w/ Chrome/Angle, FF/Angle! + // FIXME: defaultDevice.open() triggers eglInitialize(..) which crashed on Windows w/ Chrome/ANGLE, FF/ANGLE! defaultDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } } @@ -394,8 +393,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { EGLGraphicsDevice eglDevice = null; NativeSurface surface = null; ProxySurface upstreamSurface = null; // X11, GLX, .. + ProxySurface downstreamSurface = null; // EGL boolean success = false; - boolean deviceFromUpstreamSurface = false; try { final GLCapabilities reqCapsAny = new GLCapabilities(glp); reqCapsAny.setRedBits(5); reqCapsAny.setGreenBits(5); reqCapsAny.setBlueBits(5); reqCapsAny.setAlphaBits(0); @@ -404,6 +403,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if( mapsADeviceToDefaultDevice ) { // In this branch, any non EGL device is mapped to EGL default shared resources (default behavior). // Only one default shared resource instance is ever be created. + defaultDevice.open(); final GLCapabilitiesImmutable reqCapsPBuffer = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(reqCapsAny); final List availablePBufferCapsL = getAvailableEGLConfigs(defaultDevice, reqCapsPBuffer); hasPBuffer[0] = availablePBufferCapsL.size() > 0; @@ -445,20 +445,19 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { // attempt to created the default shared resources .. - eglDevice = defaultDevice; // reuse - if( hasPBuffer[0] ) { // 2nd case create defaultDevice shared resource using pbuffer surface - surface = createDummySurfaceImpl(eglDevice, false, reqCapsPBuffer, reqCapsPBuffer, null, 64, 64); // egl pbuffer offscreen - upstreamSurface = (ProxySurface)surface; - upstreamSurface.createNotify(); - deviceFromUpstreamSurface = false; + downstreamSurface = createDummySurfaceImpl(defaultDevice, false, reqCapsPBuffer, reqCapsPBuffer, null, 64, 64); // egl pbuffer offscreen + if( null != downstreamSurface ) { + downstreamSurface.createNotify(); + } + surface = downstreamSurface; } else { // 3rd case fake creation of defaultDevice shared resource, no pbuffer available - final List capsAnyL = getAvailableEGLConfigs(eglDevice, reqCapsAny); + final List capsAnyL = getAvailableEGLConfigs(defaultDevice, reqCapsAny); if(capsAnyL.size() > 0) { final GLCapabilitiesImmutable chosenCaps = capsAnyL.get(0); - EGLContext.mapStaticGLESVersion(eglDevice, chosenCaps); + EGLContext.mapStaticGLESVersion(defaultDevice, chosenCaps); success = true; } if(DEBUG) { @@ -466,15 +465,16 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { EGLGraphicsConfigurationFactory.printCaps("!PBufferCaps", capsAnyL, System.err); } } + eglDevice = defaultDevice; // reuse } else { // 4th case always creates a true mapping of given device to EGL - surface = desktopFactory.createDummySurface(adevice, reqCapsAny, null, 64, 64); // X11, WGL, .. dummy window - upstreamSurface = ( surface instanceof ProxySurface ) ? (ProxySurface)surface : null ; + upstreamSurface = desktopFactory.createDummySurface(adevice, reqCapsAny, null, 64, 64); // X11, WGL, .. dummy window if(null != upstreamSurface) { upstreamSurface.createNotify(); } + surface = upstreamSurface; eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface); - deviceFromUpstreamSurface = true; + eglDevice.open(); hasPBuffer[0] = true; } @@ -521,24 +521,16 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } success = false; } finally { - if(eglDevice == defaultDevice) { - if(null != upstreamSurface) { - upstreamSurface.destroyNotify(); - } - } else if( deviceFromUpstreamSurface ) { + if(null != downstreamSurface) { + downstreamSurface.destroyNotify(); + } + if( defaultDevice != eglDevice ) { // don't close default device if(null != eglDevice) { eglDevice.close(); } if(null != upstreamSurface) { upstreamSurface.destroyNotify(); } - } else { - if(null != upstreamSurface) { - upstreamSurface.destroyNotify(); - } - if(null != eglDevice) { - eglDevice.close(); - } } } return success; @@ -734,6 +726,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { final long nativeDisplayID = ( deviceReq instanceof EGLGraphicsDevice) ? ( (EGLGraphicsDevice) deviceReq ).getNativeDisplayID() : deviceReq.getHandle() ; device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(nativeDisplayID, deviceReq.getConnection(), deviceReq.getUnitID()); + device.open(); ownDevice = true; } else { device = (EGLGraphicsDevice) deviceReq; @@ -792,6 +785,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { final EGLGraphicsDevice eglDeviceReq = (EGLGraphicsDevice) deviceReq; final EGLGraphicsDevice device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID()); + device.open(); final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); final EGLGraphicsConfiguration cfg = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); return new WrappedSurface(cfg, windowHandle, upstream, true); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java index ac880ebc0..ebe8f49c8 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java @@ -55,6 +55,9 @@ public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundle /** * Returns true on Android, * and false otherwise. + *

                      + * {@inheritDoc} + *

                      */ @Override public final boolean shallLookupGlobal() { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 8802c3c7d..5cfa378cb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -182,16 +182,15 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact } protected static List getAvailableCapabilities(EGLDrawableFactory factory, AbstractGraphicsDevice device) { - EGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResourceImpl(device); + final EGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResourceImpl(device); if(null == sharedResource) { throw new GLException("Shared resource for device n/a: "+device); } - EGLGraphicsDevice eglDevice = sharedResource.getDevice(); - long eglDisplay = eglDevice.getHandle(); + final EGLGraphicsDevice eglDevice = sharedResource.getDevice(); + final long eglDisplay = eglDevice.getHandle(); if(0 == eglDisplay) { throw new GLException("null eglDisplay"); } - List availableCaps = null; IntBuffer numConfigs = Buffers.newDirectIntBuffer(1); @@ -213,7 +212,6 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact Collections.sort(availableCaps, EglCfgIDComparator); } } - return availableCaps; } @@ -244,6 +242,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact ownEGLDisplay = false; } else { eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(absDevice.getHandle(), absDevice.getConnection(), absDevice.getUnitID()); + eglDevice.open(); ownEGLDisplay = true; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java index dac85e753..5b911576e 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java @@ -125,6 +125,7 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { } } else { eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(upstreamSurface); + eglDevice.open(); aConfig = upstreamConfig; isEGLSurfaceValid = false; surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java index c83814907..6dc52a702 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java @@ -86,6 +86,12 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl return super.clone(); } + /** + * Opens the EGL device if handle is null and it's {@link EGLDisplayLifecycleCallback} is valid. + *

                      + * {@inheritDoc} + *

                      + */ @Override public boolean open() { if(null != eglLifecycleCallback && 0 == handle) { @@ -101,6 +107,12 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl return false; } + /** + * Closes the EGL device if handle is not null and it's {@link EGLDisplayLifecycleCallback} is valid. + *

                      + * {@inheritDoc} + *

                      + */ @Override public boolean close() { if(null != eglLifecycleCallback && 0 != handle) { diff --git a/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java index a2877dba2..32bd970a1 100644 --- a/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -53,6 +53,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { protected void createNativeImpl() { // EGL Device aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + aDevice.open(); } protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { @@ -61,6 +62,6 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { protected void dispatchMessagesNative() { // n/a .. DispatchMessages(); - } + } } diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index 653cbf945..9af455445 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -74,50 +74,50 @@ import android.view.SurfaceView; import android.view.KeyEvent; -public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { +public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { static { DisplayDriver.initSingleton(); } /** - * First stage of selecting an Android PixelFormat, - * at construction via {@link SurfaceHolder#setFormat(int)} + * First stage of selecting an Android PixelFormat, + * at construction via {@link SurfaceHolder#setFormat(int)} * before native realization! - * + * * @param rCaps requested Capabilities * @return An Android PixelFormat number suitable for {@link SurfaceHolder#setFormat(int)}. */ public static final int getSurfaceHolderFormat(CapabilitiesImmutable rCaps) { int fmt = PixelFormat.UNKNOWN; - + if( !rCaps.isBackgroundOpaque() ) { fmt = PixelFormat.TRANSLUCENT; } else if( rCaps.getRedBits()<=5 && rCaps.getGreenBits()<=6 && rCaps.getBlueBits()<=5 && rCaps.getAlphaBits()==0 ) { - fmt = PixelFormat.RGB_565; + fmt = PixelFormat.RGB_565; } else if( rCaps.getAlphaBits()==0 ) { fmt = PixelFormat.RGB_888; - } else { + } else { fmt = PixelFormat.RGBA_8888; } Log.d(MD.TAG, "getSurfaceHolderFormat: requested: "+rCaps); Log.d(MD.TAG, "getSurfaceHolderFormat: returned: "+fmt); - + return fmt; } - - + + public static final int NATIVE_WINDOW_FORMAT_RGBA_8888 = 1; public static final int NATIVE_WINDOW_FORMAT_RGBX_8888 = 2; public static final int NATIVE_WINDOW_FORMAT_RGB_565 = 4; /** - * Second stage of selecting an Android PixelFormat, + * Second stage of selecting an Android PixelFormat, * at right after native (surface) realization at {@link Callback2#surfaceChanged(SurfaceHolder, int, int, int)}. * Selection happens via {@link #setSurfaceVisualID0(long, int)} before native EGL creation. - * + * * @param androidPixelFormat An Android PixelFormat delivered via {@link Callback2#surfaceChanged(SurfaceHolder, int, int, int)} params. * @return A native Android PixelFormat number suitable for {@link #setSurfaceVisualID0(long, int)}. */ @@ -127,40 +127,40 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { case PixelFormat.RGBA_8888: case PixelFormat.RGBA_5551: case PixelFormat.RGBA_4444: - nativePixelFormat = NATIVE_WINDOW_FORMAT_RGBA_8888; + nativePixelFormat = NATIVE_WINDOW_FORMAT_RGBA_8888; break; - + case PixelFormat.RGBX_8888: - case PixelFormat.RGB_888: - nativePixelFormat = NATIVE_WINDOW_FORMAT_RGBX_8888; + case PixelFormat.RGB_888: + nativePixelFormat = NATIVE_WINDOW_FORMAT_RGBX_8888; break; - - case PixelFormat.RGB_565: - case PixelFormat.RGB_332: - nativePixelFormat = NATIVE_WINDOW_FORMAT_RGB_565; + + case PixelFormat.RGB_565: + case PixelFormat.RGB_332: + nativePixelFormat = NATIVE_WINDOW_FORMAT_RGB_565; break; default: nativePixelFormat = NATIVE_WINDOW_FORMAT_RGBA_8888; } Log.d(MD.TAG, "getANativeWindowFormat: android: "+androidPixelFormat+" -> native "+nativePixelFormat); return nativePixelFormat; } - + /** - * Final stage of Android PixelFormat operation, - * match the requested Capabilities w/ Android PixelFormat number. + * Final stage of Android PixelFormat operation, + * match the requested Capabilities w/ Android PixelFormat number. * This is done at native realization @ {@link Callback2#surfaceChanged(SurfaceHolder, int, int, int)}. - * + * * @param matchFormatPrecise * @param format * @param rCaps requested Capabilities * @return The fixed Capabilities - */ + */ public static final CapabilitiesImmutable fixCaps(boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) { - PixelFormat pf = new PixelFormat(); + PixelFormat pf = new PixelFormat(); PixelFormat.getPixelFormatInfo(format, pf); - final CapabilitiesImmutable res; + final CapabilitiesImmutable res; int r, g, b, a; - + switch(format) { case PixelFormat.RGBA_8888: r=8; g=8; b=8; a=8; break; // NATIVE_WINDOW_FORMAT_RGBA_8888 case PixelFormat.RGBX_8888: r=8; g=8; b=8; a=0; break; // NATIVE_WINDOW_FORMAT_RGBX_8888 @@ -176,24 +176,24 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { rCaps.getGreenBits() > g && rCaps.getBlueBits() > b && rCaps.getAlphaBits() > a ; - + if(change) { Capabilities nCaps = (Capabilities) rCaps.cloneMutable(); nCaps.setRedBits(r); nCaps.setGreenBits(g); nCaps.setBlueBits(b); nCaps.setAlphaBits(a); - res = nCaps; + res = nCaps; } else { res = rCaps; } Log.d(MD.TAG, "fixCaps: format: "+format); Log.d(MD.TAG, "fixCaps: requested: "+rCaps); Log.d(MD.TAG, "fixCaps: chosen: "+res); - + return res; } - + public static final boolean isAndroidFormatTransparent(int aFormat) { switch (aFormat) { case PixelFormat.TRANSLUCENT: @@ -202,15 +202,15 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } return false; } - + public static Class[] getCustomConstructorArgumentTypes() { return new Class[] { Context.class } ; } - + public WindowDriver() { reset(); } - + public void registerActivity(Activity activity) { this.activity = activity; } @@ -227,15 +227,15 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { eglSurface = 0; definePosition(0, 0); // default to 0/0 defineSize(0, 0); // default size -> TBD ! - + setBrokenFocusChange(true); } - + private final void setupInputListener(final boolean enable) { Log.d(MD.TAG, "setupInputListener(enable "+enable+") - "+Thread.currentThread().getName()); - - final AndroidNewtEventTranslator eventTranslator = - enable ? new AndroidNewtEventTranslator(this, androidView.getContext(), androidView.getHandler()) : null; + + final AndroidNewtEventTranslator eventTranslator = + enable ? new AndroidNewtEventTranslator(this, androidView.getContext(), androidView.getHandler()) : null; androidView.setOnTouchListener(eventTranslator); androidView.setOnKeyListener(eventTranslator); androidView.setOnFocusChangeListener(eventTranslator); @@ -252,47 +252,47 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } } ); } } - + private final void setupAndroidView(Context ctx) { androidView = new MSurfaceView(ctx); - + final SurfaceHolder sh = androidView.getHolder(); - sh.addCallback(WindowDriver.this); - sh.setFormat(getSurfaceHolderFormat(getRequestedCapabilities())); + sh.addCallback(WindowDriver.this); + sh.setFormat(getSurfaceHolderFormat(getRequestedCapabilities())); } - + public final SurfaceView getAndroidView() { return androidView; } - + @Override protected final void instantiationFinished() { Log.d(MD.TAG, "instantiationFinished() - "+Thread.currentThread().getName()); - - final Context ctx = StaticContext.getContext(); + + final Context ctx = StaticContext.getContext(); if(null == ctx) { throw new NativeWindowException("No static [Application] Context has been set. Call StaticContext.setContext(Context) first."); } - + if( null != Looper.myLooper() ) { setupAndroidView(ctx); } } - + @Override protected final boolean canCreateNativeImpl() { Log.d(MD.TAG, "canCreateNativeImpl.0: surfaceHandle ready "+(0!=surfaceHandle)+" - on thread "+Thread.currentThread().getName()); if(WindowImpl.DEBUG_IMPLEMENTATION) { Thread.dumpStack(); } - + if( isFullscreen() ) { final MonitorDevice mainMonitor = getMainMonitor(); final RectangleImmutable viewport = mainMonitor.getViewport(); definePosition(viewport.getX(), viewport.getY()); defineSize(viewport.getWidth(), viewport.getHeight()); } - + final boolean b; - + if( 0 == surfaceHandle ) { // Static ViewGroup, i.e. self contained main code final ViewGroup viewGroup = StaticContext.getContentViewGroup(); @@ -305,20 +305,20 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { setupAndroidView( StaticContext.getContext() ); } viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(getWidth(), getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); - Log.d(MD.TAG, "canCreateNativeImpl: added to static ViewGroup - on thread "+Thread.currentThread().getName()); + Log.d(MD.TAG, "canCreateNativeImpl: added to static ViewGroup - on thread "+Thread.currentThread().getName()); } }); for(long sleep = TIMEOUT_NATIVEWINDOW; 0 * Accessible protected method! *

                      - * + * * {@inheritDoc} */ @Override public final void focusChanged(boolean defer, boolean focusGained) { super.focusChanged(defer, focusGained); } - + @Override - protected final void requestFocusImpl(boolean reparented) { + protected final void requestFocusImpl(boolean reparented) { if(null != androidView) { Log.d(MD.TAG, "requestFocusImpl: reparented "+reparented); androidView.post(new Runnable() { @@ -450,9 +451,9 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } @Override - protected final boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + protected final boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { boolean res = true; - + if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { Log.d(MD.TAG, "reconfigureWindowImpl.setFullscreen post creation (setContentView()) n/a"); return false; @@ -474,7 +475,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } return res; } @@ -486,22 +487,22 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { @Override protected final void updateInsetsImpl(Insets insets) { - // nop .. + // nop .. } - + //---------------------------------------------------------------------- - // Virtual On-Screen Keyboard / SoftInput + // Virtual On-Screen Keyboard / SoftInput // - + private class KeyboardVisibleReceiver extends ResultReceiver { public KeyboardVisibleReceiver() { super(null); } - - @Override + + @Override public void onReceiveResult(int r, Bundle data) { boolean v = false; - + switch(r) { case InputMethodManager.RESULT_UNCHANGED_SHOWN: case InputMethodManager.RESULT_SHOWN: @@ -510,14 +511,14 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { case InputMethodManager.RESULT_HIDDEN: case InputMethodManager.RESULT_UNCHANGED_HIDDEN: v = false; - break; + break; } Log.d(MD.TAG, "keyboardVisible: "+v); keyboardVisibilityChanged(v); } } - private KeyboardVisibleReceiver keyboardVisibleReceiver = new KeyboardVisibleReceiver(); - + private final KeyboardVisibleReceiver keyboardVisibleReceiver = new KeyboardVisibleReceiver(); + @Override protected final boolean setKeyboardVisibleImpl(boolean visible) { if(null != androidView) { @@ -536,13 +537,13 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return false; // nop } } - + //---------------------------------------------------------------------- - // Surface Callbacks + // Surface Callbacks // - + @Override - public final void surfaceCreated(SurfaceHolder holder) { + public final void surfaceCreated(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceCreated: "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - on thread "+Thread.currentThread().getName()); } @@ -570,14 +571,14 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { if(0>getX() || 0>getY()) { positionChanged(false, 0, 0); } - + if(0 == surfaceHandle) { androidFormat = aFormat; surface = aHolder.getSurface(); surfaceHandle = getSurfaceHandle0(surface); acquire0(surfaceHandle); final int aNativeWindowFormat = getANativeWindowFormat(androidFormat); - setSurfaceVisualID0(surfaceHandle, aNativeWindowFormat); + setSurfaceVisualID0(surfaceHandle, aNativeWindowFormat); nativeFormat = getSurfaceVisualID0(surfaceHandle); Log.d(MD.TAG, "surfaceChanged: androidFormat "+androidFormat+" -- (set-native "+aNativeWindowFormat+") --> nativeFormat "+nativeFormat); @@ -585,12 +586,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { final int nHeight = getHeight0(surfaceHandle); capsByFormat = (GLCapabilitiesImmutable) fixCaps(true /* matchFormatPrecise */, nativeFormat, getRequestedCapabilities()); sizeChanged(false, nWidth, nHeight, false); - + Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+ ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ ", format [a "+androidFormat+"/n "+nativeFormat+"], "+ getX()+"/"+getY()+" "+nWidth+"x"+nHeight+", visible: "+isVisible()); - + if(isVisible()) { setVisible(false, true); } @@ -599,7 +600,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { windowRepaint(0, 0, aWidth, aHeight); Log.d(MD.TAG, "surfaceChanged: X"); } - + @Override public final void surfaceDestroyed(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceDestroyed - on thread "+Thread.currentThread().getName()); @@ -612,14 +613,14 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { Log.d(MD.TAG, "surfaceRedrawNeeded - on thread "+Thread.currentThread().getName()); windowRepaint(0, 0, getWidth(), getHeight()); } - + protected boolean handleKeyCodeBack(KeyEvent.DispatcherState state, android.view.KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { Log.d(MD.TAG, "handleKeyCodeBack.0 : "+event); state.startTracking(event, this); } else if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled() && state.isTracking(event)) { - // Since we cannot trust the visibility state 'completly', - // assume an already invisible state if the invisible operation fails. + // Since we cannot trust the visibility state 'completly', + // assume an already invisible state if the invisible operation fails. final boolean wasVisible = setKeyboardVisibleImpl(false); Log.d(MD.TAG, "handleKeyCodeBack.1 : wasVisible "+wasVisible+": "+event); keyboardVisibilityChanged(false); @@ -635,7 +636,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } else { Log.d(MD.TAG, "handleKeyCodeBack.X1 : "+event); windowDestroyNotify(true); - // -> default BACK action, usually activity.finish() + // -> default BACK action, usually activity.finish() } } return false; // continue w/ further processing @@ -646,7 +647,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { enqueueEvent(false, eDown); enqueueEvent(false, eUp); } - + @Override protected void consumeKeyEvent(com.jogamp.newt.event.KeyEvent e) { super.consumeKeyEvent(e); // consume event, i.e. call all KeyListener @@ -659,7 +660,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { triggerHome(); } } - } + } private void triggerHome() { Context ctx = StaticContext.getContext(); if(null == ctx) { @@ -669,7 +670,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { showOptions.addCategory(Intent.CATEGORY_HOME); ctx.startActivity(showOptions); } - + private boolean added2StaticViewGroup; private MSurfaceView androidView; private int nativeFormat; // chosen current native PixelFormat (suitable for EGL) @@ -678,7 +679,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { private Surface surface; private volatile long surfaceHandle; private long eglSurface; - + class MSurfaceView extends SurfaceView { public MSurfaceView (Context ctx) { super(ctx); @@ -696,7 +697,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } } return false; // cont. processing - } + } } //---------------------------------------------------------------------- // Internals only diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java index 3d563d88f..178bb70f7 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java @@ -92,6 +92,7 @@ public class DisplayDriver extends DisplayImpl { // FIXME: map name to EGL_*_DISPLAY bcmHandle = OpenBCMDisplay0(); aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + aDevice.open(); defaultPointerIcon = (PointerIconImpl) createPointerIcon(defaultPointerIconImage, 0, 0); if( DEBUG_POINTER_ICON ) { diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index e91c67813..c3cb8a84c 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -96,6 +96,7 @@ public class WindowDriver extends WindowImpl { final AbstractGraphicsScreen aScreen = screen.getGraphicsScreen(); final EGLGraphicsDevice aDevice = (EGLGraphicsDevice) aScreen.getDevice(); final EGLGraphicsDevice eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(aDevice.getNativeDisplayID(), aDevice.getConnection(), aDevice.getUnitID()); + eglDevice.open(); final DefaultGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aScreen.getIndex()); final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( diff --git a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java index 929688b11..6c706148a 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java @@ -63,6 +63,7 @@ public class DisplayDriver extends DisplayImpl { protected void createNativeImpl() { // FIXME: map name to EGL_*_DISPLAY aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + aDevice.open(); } @Override -- cgit v1.2.3 From 87135467c4f292f7e43bc3957784b0e43769c9cc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 26 Jan 2014 02:59:12 +0100 Subject: Script: Correct joal.jar path; Remove redundant NewtDebugActivity (Debug is on for NewtVersionActivity) --- make/resources/android/AndroidManifest-jogl.xml | 12 --- make/resources/android/res-jogl/values/strings.xml | 2 - make/scripts/make.jogl.all.android-armv6-cross.sh | 2 + make/scripts/setenv-jogl.sh | 2 +- .../newt/driver/android/NewtDebugActivity.java | 38 ------- .../driver/android/NewtDebugActivityLauncher.java | 21 ---- .../newt/driver/android/NewtVersionActivity.java | 88 ++++++++++++++- .../android/NewtVersionActivityLauncher.java | 2 +- .../driver/android/NewtVersionBaseActivity.java | 120 --------------------- 9 files changed, 90 insertions(+), 197 deletions(-) delete mode 100644 src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java delete mode 100644 src/newt/classes/jogamp/newt/driver/android/NewtDebugActivityLauncher.java delete mode 100644 src/newt/classes/jogamp/newt/driver/android/NewtVersionBaseActivity.java (limited to 'src/newt/classes') diff --git a/make/resources/android/AndroidManifest-jogl.xml b/make/resources/android/AndroidManifest-jogl.xml index d9a9ac819..1b6c46356 100644 --- a/make/resources/android/AndroidManifest-jogl.xml +++ b/make/resources/android/AndroidManifest-jogl.xml @@ -28,18 +28,6 @@ - - - - - - diff --git a/make/resources/android/res-jogl/values/strings.xml b/make/resources/android/res-jogl/values/strings.xml index ae4816665..e88a0a4e0 100644 --- a/make/resources/android/res-jogl/values/strings.xml +++ b/make/resources/android/res-jogl/values/strings.xml @@ -5,6 +5,4 @@ Contains Dalvik and native code, supporting native bindings. Jogl\'s Version Shows the version of the JOGL Library and runtime GL infos. - Jogl Debug - Debug output of JOGL\'s initialization. diff --git a/make/scripts/make.jogl.all.android-armv6-cross.sh b/make/scripts/make.jogl.all.android-armv6-cross.sh index 2b8f9a30e..1b5f5bf44 100755 --- a/make/scripts/make.jogl.all.android-armv6-cross.sh +++ b/make/scripts/make.jogl.all.android-armv6-cross.sh @@ -1,5 +1,7 @@ #! /bin/sh +SDIR=`dirname $0` + if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh fi diff --git a/make/scripts/setenv-jogl.sh b/make/scripts/setenv-jogl.sh index 186da5505..dc121a596 100755 --- a/make/scripts/setenv-jogl.sh +++ b/make/scripts/setenv-jogl.sh @@ -73,7 +73,7 @@ if [ ! -e "$JOAL_BUILDDIR" ] ; then print_usage exit fi -JOAL_JAR="$JOAL_BUILDDIR"/joal.jar +JOAL_JAR="$JOAL_BUILDDIR"/jar/joal.jar if [ -z "$ANT_PATH" ] ; then ANT_PATH=$(dirname $(dirname $(which ant))) diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java deleted file mode 100644 index 40a6ec6dc..000000000 --- a/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package jogamp.newt.driver.android; - -import android.os.Bundle; - -public class NewtDebugActivity extends NewtVersionBaseActivity { - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate("NewtDebugActivity - DEBUG MODE", savedInstanceState); - } -} diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivityLauncher.java b/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivityLauncher.java deleted file mode 100644 index 9d16fdec5..000000000 --- a/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivityLauncher.java +++ /dev/null @@ -1,21 +0,0 @@ -package jogamp.newt.driver.android; - -import android.app.Activity; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.util.Log; - -public class NewtDebugActivityLauncher extends Activity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtDebugActivity?sys=com.jogamp.common&sys=javax.media.opengl&pkg=com.jogamp.opengl.test&jogamp.debug=all&nativewindow.debug=all&jogl.debug=all&newt.debug=all"); - final Intent intent = new Intent("org.jogamp.launcher.action.LAUNCH_ACTIVITY_NORMAL", uri); - Log.d(getClass().getSimpleName(), "Launching Activity: "+intent); - startActivity (intent); - - finish(); // done - } -} diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java index 8a7f3af87..259acb8f3 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java @@ -27,11 +27,95 @@ */ package jogamp.newt.driver.android; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import com.jogamp.common.GlueGenVersion; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.VersionUtil; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.JoglVersion; + import android.os.Bundle; +import android.util.Log; +import android.view.Gravity; +import android.view.ViewGroup.LayoutParams; +import android.widget.ScrollView; +import android.widget.TextView; + +public class NewtVersionActivity extends NewtBaseActivity { -public class NewtVersionActivity extends NewtVersionBaseActivity { @Override public void onCreate(Bundle savedInstanceState) { - super.onCreate("NewtVersionActivity - NORMAL MODE", savedInstanceState); + super.onCreate(savedInstanceState); + + setFullscreenFeature(getWindow(), true); + + final android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getActivity().getApplicationContext()); + getWindow().setContentView(viewGroup); + + final TextView tv = new TextView(getActivity()); + final ScrollView scroller = new ScrollView(getActivity()); + scroller.addView(tv); + viewGroup.addView(scroller, new android.widget.FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.TOP|Gravity.LEFT)); + + final String info1 = "JOGL Version Info"+Platform.NEWLINE+VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+JoglVersion.getInstance()+Platform.NEWLINE; + Log.d(MD.TAG, info1); + tv.setText(info1); + + final GLProfile glp; + if( GLProfile.isAvailable(GLProfile.GL2ES2) ) { + glp = GLProfile.get(GLProfile.GL2ES2); + } else if( GLProfile.isAvailable(GLProfile.GL2ES1) ) { + glp = GLProfile.get(GLProfile.GL2ES1); + } else { + glp = null; + tv.append("No GLProfile GL2ES2 nor GL2ES1 available!"); + } + if( null != glp ) { + // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) + GLCapabilities caps = new GLCapabilities(glp); + GLWindow glWindow = GLWindow.create(caps); + glWindow.setUndecorated(true); + glWindow.setSize(32, 32); + glWindow.setPosition(0, 0); + final android.view.View androidGLView = ((WindowDriver)glWindow.getDelegatedWindow()).getAndroidView(); + viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getWidth(), glWindow.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); + registerNEWTWindow(glWindow); + + glWindow.addGLEventListener(new GLEventListener() { + public void init(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); + final StringBuilder sb = new StringBuilder(); + sb.append(JoglVersion.getGLInfo(gl, null, true)).append(Platform.NEWLINE); + sb.append("Requested: ").append(Platform.NEWLINE); + sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); + sb.append("Chosen: ").append(Platform.NEWLINE); + sb.append(drawable.getChosenGLCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); + final String info2 = sb.toString(); + // Log.d(MD.TAG, info2); // too big! + System.err.println(info2); + viewGroup.post(new Runnable() { + public void run() { + tv.append(info2); + viewGroup.removeView(androidGLView); + } } ); + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + } + + public void display(GLAutoDrawable drawable) { + } + + public void dispose(GLAutoDrawable drawable) { + } + }); + glWindow.setVisible(true); + } + Log.d(MD.TAG, "onCreate - X"); } } diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java index 3374e4184..553900f6a 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java @@ -11,7 +11,7 @@ public class NewtVersionActivityLauncher extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtVersionActivity?sys=com.jogamp.common&sys=javax.media.opengl&pkg=com.jogamp.opengl.test"); + final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtVersionActivity?sys=com.jogamp.common&sys=javax.media.opengl&pkg=com.jogamp.opengl.test&jogamp.debug=all&nativewindow.debug=all&jogl.debug=all&newt.debug=all"); final Intent intent = new Intent("org.jogamp.launcher.action.LAUNCH_ACTIVITY_NORMAL", uri); Log.d(getClass().getSimpleName(), "Launching Activity: "+intent); startActivity (intent); diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionBaseActivity.java deleted file mode 100644 index f24fb20ac..000000000 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionBaseActivity.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package jogamp.newt.driver.android; - -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; - -import com.jogamp.common.GlueGenVersion; -import com.jogamp.common.os.Platform; -import com.jogamp.common.util.VersionUtil; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.JoglVersion; - -import android.os.Bundle; -import android.util.Log; -import android.view.Gravity; -import android.view.ViewGroup.LayoutParams; -import android.widget.ScrollView; -import android.widget.TextView; - -public class NewtVersionBaseActivity extends NewtBaseActivity { - - public void onCreate(String prefix, Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setFullscreenFeature(getWindow(), true); - - final android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getActivity().getApplicationContext()); - getWindow().setContentView(viewGroup); - - final TextView tv = new TextView(getActivity()); - final ScrollView scroller = new ScrollView(getActivity()); - scroller.addView(tv); - viewGroup.addView(scroller, new android.widget.FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.TOP|Gravity.LEFT)); - - final String info1 = prefix+Platform.NEWLINE+VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+JoglVersion.getInstance()+Platform.NEWLINE; - Log.d(MD.TAG, info1); - tv.setText(info1); - - final GLProfile glp; - if( GLProfile.isAvailable(GLProfile.GL2ES2) ) { - glp = GLProfile.get(GLProfile.GL2ES2); - } else if( GLProfile.isAvailable(GLProfile.GL2ES1) ) { - glp = GLProfile.get(GLProfile.GL2ES1); - } else { - glp = null; - tv.append("No GLProfile GL2ES2 nor GL2ES1 available!"); - } - if( null != glp ) { - // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) - GLCapabilities caps = new GLCapabilities(glp); - GLWindow glWindow = GLWindow.create(caps); - glWindow.setUndecorated(true); - glWindow.setSize(32, 32); - glWindow.setPosition(0, 0); - final android.view.View androidGLView = ((WindowDriver)glWindow.getDelegatedWindow()).getAndroidView(); - viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getWidth(), glWindow.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); - registerNEWTWindow(glWindow); - - glWindow.addGLEventListener(new GLEventListener() { - public void init(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); - final StringBuilder sb = new StringBuilder(); - sb.append(JoglVersion.getGLInfo(gl, null, true)).append(Platform.NEWLINE); - sb.append("Requested: ").append(Platform.NEWLINE); - sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); - sb.append("Chosen: ").append(Platform.NEWLINE); - sb.append(drawable.getChosenGLCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); - final String info2 = sb.toString(); - // Log.d(MD.TAG, info2); // too big! - System.err.println(info2); - viewGroup.post(new Runnable() { - public void run() { - tv.append(info2); - viewGroup.removeView(androidGLView); - } } ); - } - - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } - - public void display(GLAutoDrawable drawable) { - } - - public void dispose(GLAutoDrawable drawable) { - } - }); - glWindow.setVisible(true); - } - Log.d(MD.TAG, "onCreate - X"); - } -} -- cgit v1.2.3 From 5a661f4736c6d2e42b7114004a4dcbca3fe3f7a2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 30 Jan 2014 04:50:17 +0100 Subject: NEWT Window: Add API Doc for Custom Window Icons --- src/newt/classes/com/jogamp/newt/NewtFactory.java | 1 + src/newt/classes/com/jogamp/newt/Window.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 92339ea73..4fec00525 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -65,6 +65,7 @@ public class NewtFactory { public Object run() { NativeWindowFactory.initSingleton(); // last resort .. { + /** See API Doc in {@link Window} ! */ final String[] paths = Debug.getProperty("newt.window.icons", true, "newt/data/jogamp-16x16.png newt/data/jogamp-32x32.png").split("\\s"); if( paths.length < 2 ) { throw new IllegalArgumentException("Property 'newt.window.icons' did not specify at least two PNG icons, but "+Arrays.toString(paths)); diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 8e73ba1d2..4816e62e5 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -63,6 +63,21 @@ import javax.media.nativewindow.util.RectangleImmutable; * window operation to an instance of this interface while providing OpenGL * functionality. *

                      + *
                      Custom Window Icons
                      + *

                      + * Custom window icons can be defined via system property newt.window.icons, + * which shall contain a space separated list of PNG icon locations from low- to high-resolution. + * The location must be resolvable via classpath, i.e. shall reference a location within the jar file. + * Example (our default): + *

                      + *   -Dnewt.window.icons="newt/data/jogamp-16x16.png newt/data/jogamp-32x32.png"
                      + *   -Djnlp.newt.window.icons="newt/data/jogamp-16x16.png newt/data/jogamp-32x32.png"
                      + * 
                      + * The property can also be set programmatically, which must happen before any NEWT classes are touched: + *
                      + *   System.setProperty("newt.window.icons", "newt/data/jogamp-16x16.png newt/data/jogamp-32x32.png");
                      + * 
                      + *

                      */ public interface Window extends NativeWindow, WindowClosingProtocol { public static final boolean DEBUG_MOUSE_EVENT = Debug.debug("Window.MouseEvent"); -- cgit v1.2.3 From 6b37c1c3d109d3ae83d19ac84b50c7b3249af95a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 30 Jan 2014 11:37:05 +0100 Subject: NewtFactory: Fix createWindow(..) ctor w/ given native window handle (use displayConnection string and screen-idx) --- src/newt/classes/com/jogamp/newt/NewtFactory.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 4fec00525..fc3716a52 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -305,10 +305,6 @@ public class NewtFactory { return WindowImpl.create(parentNativeWindow, 0, screen, caps); } - protected static Window createWindowImpl(long parentWindowHandle, Screen screen, CapabilitiesImmutable caps) { - return WindowImpl.create(null, parentWindowHandle, screen, caps); - } - protected static Window createWindowImpl(Screen screen, CapabilitiesImmutable caps) { return WindowImpl.create(null, 0, screen, caps); } @@ -322,11 +318,17 @@ public class NewtFactory { /** * Create a child Window entity attached to the given parent, incl native creation
                      * - * @param parentWindowObject the native parent window handle - * @param undecorated only impacts if the window is in top-level state, while attached to a parent window it's rendered undecorated always + * @param displayConnection the parent window's display connection + * @param screenIdx the desired screen index + * @param parentWindowHandle the native parent window handle + * @param caps the desired capabilities + * @return */ - public static Window createWindow(long parentWindowHandle, Screen screen, CapabilitiesImmutable caps) { - return createWindowImpl(parentWindowHandle, screen, caps); + public static Window createWindow(String displayConnection, int screenIdx, long parentWindowHandle, CapabilitiesImmutable caps) { + final String type = NativeWindowFactory.getNativeWindowType(true); + Display display = NewtFactory.createDisplay(type, displayConnection, true); + Screen screen = NewtFactory.createScreen(display, screenIdx); + return WindowImpl.create(null, parentWindowHandle, screen, caps); } /** -- cgit v1.2.3 From ac55c5bfa469537c755730d3be9617d97f82950d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 30 Jan 2014 11:43:40 +0100 Subject: NEWT: Add Support for AWT-Less Applet3 - Adding 'plugin3-public' jar and sources for Applet3 support, copied from icedtea-web3 - Added com.jogamp.newt.util.applet.JOGLNewtApplet3Run capable to run Applet3 --- .classpath | 1 + make/build-common.xml | 5 + make/build-newt.xml | 2 +- make/lib/plugin3/plugin3-public-src.zip | Bin 0 -> 7555 bytes make/lib/plugin3/plugin3-public.jar | Bin 0 -> 12298 bytes .../jogamp/newt/awt/applet/JOGLNewtApplet1Run.java | 1 + .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 390 --------------------- .../newt/util/applet/JOGLNewtApplet3Run.java | 342 ++++++++++++++++++ .../newt/util/applet/JOGLNewtAppletBase.java | 390 +++++++++++++++++++++ .../jogamp/newt/util/applet/VersionApplet3.java | 212 +++++++++++ 10 files changed, 952 insertions(+), 391 deletions(-) create mode 100644 make/lib/plugin3/plugin3-public-src.zip create mode 100644 make/lib/plugin3/plugin3-public.jar delete mode 100644 src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java create mode 100644 src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java create mode 100644 src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtAppletBase.java create mode 100644 src/newt/classes/com/jogamp/newt/util/applet/VersionApplet3.java (limited to 'src/newt/classes') diff --git a/.classpath b/.classpath index 817f2b8ec..b0ed782b0 100644 --- a/.classpath +++ b/.classpath @@ -33,5 +33,6 @@ + diff --git a/make/build-common.xml b/make/build-common.xml index e38e296ee..1a5703aa9 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -177,6 +177,9 @@ + + + @@ -462,6 +465,7 @@ + @@ -470,6 +474,7 @@ + diff --git a/make/build-newt.xml b/make/build-newt.xml index 9bc2e0e83..dd0ccc1d6 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -100,7 +100,7 @@ + value="com/jogamp/newt/* com/jogamp/newt/event/* com/jogamp/newt/util/* com/jogamp/newt/util/applet/* jogamp/newt/* jogamp/newt/event/* jogamp/newt/driver/*"/> diff --git a/make/lib/plugin3/plugin3-public-src.zip b/make/lib/plugin3/plugin3-public-src.zip new file mode 100644 index 000000000..f9b7b8ea0 Binary files /dev/null and b/make/lib/plugin3/plugin3-public-src.zip differ diff --git a/make/lib/plugin3/plugin3-public.jar b/make/lib/plugin3/plugin3-public.jar new file mode 100644 index 000000000..3cec75a6a Binary files /dev/null and b/make/lib/plugin3/plugin3-public.jar differ diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java index 74d4d833a..9cecca9c5 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtApplet1Run.java @@ -48,6 +48,7 @@ import jogamp.nativewindow.jawt.JAWTUtil; import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.applet.JOGLNewtAppletBase; /** * Simple GLEventListener deployment as an applet using JOGL. This demo must be diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java deleted file mode 100644 index 2afa97327..000000000 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ /dev/null @@ -1,390 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions 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. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.newt.awt.applet; - -import java.lang.reflect.Field; -import java.security.AccessController; -import java.security.PrivilegedAction; - -import javax.media.nativewindow.NativeWindow; -import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; -import javax.media.nativewindow.util.InsetsImmutable; -import javax.media.opengl.FPSCounter; -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLPipelineFactory; - -import jogamp.newt.Debug; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.newt.Display; -import com.jogamp.newt.Window; -import com.jogamp.newt.Display.PointerIcon; -import com.jogamp.newt.event.KeyEvent; -import com.jogamp.newt.event.KeyListener; -import com.jogamp.newt.event.MouseListener; -import com.jogamp.newt.event.WindowAdapter; -import com.jogamp.newt.event.WindowEvent; -import com.jogamp.newt.event.WindowListener; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.util.Animator; - - -/** Shows how to deploy an applet using JOGL. This demo must be - referenced from a web page via an <applet> tag. */ - -public class JOGLNewtAppletBase implements KeyListener, GLEventListener { - public static final boolean DEBUG = Debug.debug("Applet"); - - String glEventListenerClazzName; - int glSwapInterval; - boolean noDefaultKeyListener; - boolean glClosable; - boolean glDebug; - boolean glTrace; - PointerIcon pointerIconTest = null; - - GLEventListener glEventListener = null; - GLWindow glWindow = null; - Animator glAnimator=null; - boolean isValid = false; - NativeWindow awtParent; - - public JOGLNewtAppletBase(String glEventListenerClazzName, - int glSwapInterval, - boolean noDefaultKeyListener, - boolean glClosable, - boolean glDebug, - boolean glTrace) { - - this.glEventListenerClazzName=glEventListenerClazzName; - this.glSwapInterval=glSwapInterval; - this.noDefaultKeyListener = noDefaultKeyListener; - this.glClosable = glClosable; - this.glDebug = glDebug; - this.glTrace = glTrace; - } - - public GLEventListener getGLEventListener() { return glEventListener; } - public GLWindow getGLWindow() { return glWindow; } - public Animator getGLAnimator() { return glAnimator; } - public boolean isValid() { return isValid; } - - public static boolean str2Bool(String str, boolean def) { - if(null==str) return def; - try { - return Boolean.valueOf(str).booleanValue(); - } catch (Exception ex) { ex.printStackTrace(); } - return def; - } - - public static int str2Int(String str, int def) { - if(null==str) return def; - try { - return Integer.parseInt(str); - } catch (Exception ex) { ex.printStackTrace(); } - return def; - } - - public static GLEventListener createInstance(final String clazzName) { - Object instance = null; - - try { - final Class clazz = AccessController.doPrivileged(new PrivilegedAction>() { - @Override - public Class run() { - final ClassLoader cl = Thread.currentThread().getContextClassLoader(); - Class clazz = null; - try { - clazz = Class.forName(clazzName, false, cl); - } catch (Throwable t) { - t.printStackTrace(); - } - return clazz; - } - }); - instance = clazz.newInstance(); - } catch (Throwable t) { - t.printStackTrace(); - throw new RuntimeException("Error while instantiating demo: "+clazzName); - } - if( null == instance ) { - throw new RuntimeException("Null GLEventListener: "+clazzName); - } - if( !(instance instanceof GLEventListener) ) { - throw new RuntimeException("Not a GLEventListener: "+clazzName); - } - return (GLEventListener) instance; - } - - public static boolean setField(Object instance, String fieldName, Object value) { - try { - Field f = instance.getClass().getField(fieldName); - if(f.getType().isInstance(value)) { - f.set(instance, value); - return true; - } else { - System.out.println(instance.getClass()+" '"+fieldName+"' field not assignable with "+value.getClass()+", it's a: "+f.getType()); - } - } catch (NoSuchFieldException nsfe) { - System.out.println(instance.getClass()+" has no '"+fieldName+"' field"); - } catch (Throwable t) { - t.printStackTrace(); - } - return false; - } - - public void init(GLWindow glWindow) { - init(Thread.currentThread().getThreadGroup(), glWindow); - } - - public void init(ThreadGroup tg, final GLWindow glWindow) { - isValid = false; - this.glWindow = glWindow; - glEventListener = createInstance(glEventListenerClazzName); - if(null == glEventListener) { - return; - } - - try { - if(!setField(glEventListener, "window", glWindow)) { - setField(glEventListener, "glWindow", glWindow); - } - - glWindow.addGLEventListener(this); - glWindow.addGLEventListener(glEventListener); - - if(glEventListener instanceof WindowListener) { - glWindow.addWindowListener((WindowListener)glEventListener); - } - - if(glEventListener instanceof MouseListener) { - glWindow.addMouseListener((MouseListener)glEventListener); - } - - if(glEventListener instanceof KeyListener) { - glWindow.addKeyListener((KeyListener)glEventListener); - } - - if(!noDefaultKeyListener) { - glWindow.addKeyListener(this); - } - - glWindow.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); - - // glAnimator = new FPSAnimator(canvas, 60); - glAnimator = new Animator(); - glAnimator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); // No AWT thread involved! - glAnimator.setThreadGroup(tg); - glAnimator.add(glWindow); - glAnimator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, null); - - } catch (Throwable t) { - throw new RuntimeException(t); - } - isValid = true; - } - - private final WindowListener reparentHomeListener = new WindowAdapter() { - // Closing action: back to parent! - @Override - public void windowDestroyNotify(WindowEvent e) { - if( isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() && - null == glWindow.getParent() && null != awtParent && 0 != awtParent.getWindowHandle() ) - { - // we may be called directly by the native EDT - new Thread(new Runnable() { - @Override - public void run() { - if( glWindow.isNativeValid() && null != awtParent && 0 != awtParent.getWindowHandle() ) { - glWindow.reparentWindow(awtParent, -1, -1, Window.REPARENT_HINT_BECOMES_VISIBLE); - } - } - }).start(); - } - } }; - - public void start() { - if(isValid) { - glWindow.setVisible(true); - glWindow.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); - if( null == pointerIconTest ) { - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/cross-grey-alpha-16x16.png" } ); - final Display disp = glWindow.getScreen().getDisplay(); - try { - pointerIconTest = disp.createPointerIcon(res, 8, 8); - } catch (Exception e) { - e.printStackTrace(); - } - } - glAnimator.start(); - awtParent = glWindow.getParent(); - glWindow.addWindowListener(reparentHomeListener); - } - } - - public void stop() { - if(null!=glAnimator) { - glWindow.removeWindowListener(reparentHomeListener); - glAnimator.stop(); - glWindow.setVisible(false); - } - } - - public void destroy() { - isValid = false; - if(null!=glAnimator) { - glAnimator.stop(); - glAnimator.remove(glWindow); - glAnimator=null; - } - if(null!=glWindow) { - glWindow.destroy(); - glWindow=null; - } - } - - // *********************************************************************************** - // *********************************************************************************** - // *********************************************************************************** - - @Override - public void init(GLAutoDrawable drawable) { - GL _gl = drawable.getGL(); - - if(glDebug) { - try { - _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, _gl, null) ); - } catch (Exception e) {e.printStackTrace();} - } - - if(glTrace) { - try { - // Trace .. - _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, _gl, new Object[] { System.err } ) ); - } catch (Exception e) {e.printStackTrace();} - } - - if(glSwapInterval>=0) { - _gl.setSwapInterval(glSwapInterval); - } - } - @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } - @Override - public void display(GLAutoDrawable drawable) { - } - @Override - public void dispose(GLAutoDrawable drawable) { - } - - // *********************************************************************************** - // *********************************************************************************** - // *********************************************************************************** - - @Override - public void keyPressed(KeyEvent e) { - if( !e.isPrintableKey() || e.isAutoRepeat() ) { - return; - } - if(e.getKeyChar()=='d') { - new Thread() { - public void run() { - glWindow.setUndecorated(!glWindow.isUndecorated()); - } }.start(); - } if(e.getKeyChar()=='f') { - new Thread() { - public void run() { - glWindow.setFullscreen(!glWindow.isFullscreen()); - } }.start(); - } else if(e.getKeyChar()=='a') { - new Thread() { - public void run() { - glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop()); - } }.start(); - } else if(e.getKeyChar()=='r' && null!=awtParent) { - new Thread() { - public void run() { - if(null == glWindow.getParent()) { - glWindow.reparentWindow(awtParent, -1, -1, 0 /* hints */); - } else { - final InsetsImmutable insets = glWindow.getInsets(); - final int x, y; - if ( 0 >= insets.getTopHeight() ) { - // fail safe .. - x = 32; - y = 32; - } else { - x = insets.getLeftWidth(); - y = insets.getTopHeight(); - } - glWindow.reparentWindow(null, x, y, 0 /* hints */); - glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE ); - } - } }.start(); - } else if(e.getKeyChar()=='c') { - new Thread() { - public void run() { - System.err.println("[set pointer-icon pre]"); - final PointerIcon currentPI = glWindow.getPointerIcon(); - glWindow.setPointerIcon( currentPI == pointerIconTest ? null : pointerIconTest); - System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); - } }.start(); - } else if(e.getKeyChar()=='i') { - new Thread() { - public void run() { - System.err.println("[set mouse visible pre]: "+glWindow.isPointerVisible()); - glWindow.setPointerVisible(!glWindow.isPointerVisible()); - System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible()); - } }.start(); - } else if(e.getKeyChar()=='j') { - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined()); - glWindow.confinePointer(!glWindow.isPointerConfined()); - System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined()); - glWindow.setExclusiveContextThread(t); - } }.start(); - } else if(e.getKeyChar()=='w') { - new Thread() { - public void run() { - System.err.println("[set mouse pos pre]"); - glWindow.warpPointer(glWindow.getWidth()/2, glWindow.getHeight()/2); - System.err.println("[set mouse pos post]"); - } }.start(); - } - } - - @Override - public void keyReleased(KeyEvent e) { - } -} - diff --git a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java new file mode 100644 index 000000000..465ee4df5 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java @@ -0,0 +1,342 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.newt.util.applet; + +import java.util.Locale; + +import com.jogamp.plugin.applet.Applet3; +import com.jogamp.plugin.applet.Applet3Context; +import com.jogamp.plugin.ui.NativeWindowDownstream; +import com.jogamp.plugin.ui.NativeWindowUpstream; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; +import javax.media.opengl.FPSCounter; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; +import com.jogamp.newt.opengl.GLWindow; + +/** + * Simple GLEventListener deployment as an applet using JOGL. This demo must be + * referenced from a web page via an <applet> tag. + * + *

                      + * Example of an applet tag using GearsES2 within the applet area (normal case): + *

                      +        <applet width=100 height=100>
                      +           <param name="java_arguments" value="-Dsun.java2d.noddraw=true">
                      +           <param name="gl_event_listener_class" value="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2">
                      +           <param name="gl_profile" value="GL2">
                      +           <param name="gl_swap_interval" value="1">
                      +           <param name="gl_debug" value="false">
                      +           <param name="gl_trace" value="false">
                      +           <param name="jnlp_href" value="jogl-newt-applet-runner.jnlp">
                      +        </applet>Hello Gears !
                      + *  
                      + *

                      + * + *

                      + * Example of an applet tag using GearsES2 in an undecorated, translucent, closeable and always-on-top window: + *

                      +        <applet width=1 height=1>
                      +           <param name="java_arguments" value="-Dsun.java2d.noddraw=true">
                      +           <param name="gl_event_listener_class" value="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2">
                      +           <param name="gl_profile" value="GL2">
                      +           <param name="gl_swap_interval" value="1">
                      +           <param name="gl_undecorated" value="true">
                      +           <param name="gl_alwaysontop" value="true">
                      +           <param name="gl_closeable" value="true">
                      +           <param name="gl_alpha" value="1">
                      +           <param name="gl_multisamplebuffer" value="0">
                      +           <param name="gl_opaque" value="false">
                      +           <param name="gl_dx" value="10">
                      +           <param name="gl_dy" value="0">
                      +           <param name="gl_width" value="100">
                      +           <param name="gl_height" value="100">
                      +           <param name="gl_nodefaultkeyListener" value="true">
                      +           <param name="gl_debug" value="false">
                      +           <param name="gl_trace" value="false">
                      +           <param name="jnlp_href" value="jogl-newt-applet-runner.jnlp">
                      +        </applet>Hello Gears !
                      + *  
                      + *

                      + */ +public class JOGLNewtApplet3Run implements Applet3 { + public static final boolean DEBUG = JOGLNewtAppletBase.DEBUG; + + GLWindow glWindow = null; + JOGLNewtAppletBase base = null; + /** if valid glStandalone:=true (own window) ! */ + int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE; + Applet3Context ctx; + boolean glStandalone = false; + + final String getParameter(String name) { + return ctx.getParameter(name); + } + + @Override + public NativeWindowDownstream createNativeWindow(final Applet3Context ctx, final NativeWindowUpstream upstreamWin) { + this.ctx = ctx; + + String glProfileName=null; + boolean glOpaque=true; + int glAlphaBits=0; + int glNumMultisampleBuffer=0; + boolean glUndecorated=false; + boolean glAlwaysOnTop=false; + try { + glProfileName = getParameter("gl_profile"); + glOpaque = JOGLNewtAppletBase.str2Bool(getParameter("gl_opaque"), glOpaque); + glAlphaBits = JOGLNewtAppletBase.str2Int(getParameter("gl_alpha"), glAlphaBits); + glNumMultisampleBuffer = JOGLNewtAppletBase.str2Int(getParameter("gl_multisamplebuffer"), glNumMultisampleBuffer); + glXd = JOGLNewtAppletBase.str2Int(getParameter("gl_dx"), glXd); + glYd = JOGLNewtAppletBase.str2Int(getParameter("gl_dy"), glYd); + glWidth = JOGLNewtAppletBase.str2Int(getParameter("gl_width"), glWidth); + glHeight = JOGLNewtAppletBase.str2Int(getParameter("gl_height"), glHeight); + glUndecorated = JOGLNewtAppletBase.str2Bool(getParameter("gl_undecorated"), glUndecorated); + glAlwaysOnTop = JOGLNewtAppletBase.str2Bool(getParameter("gl_alwaysontop"), glAlwaysOnTop); + } catch (Exception e) { + e.printStackTrace(); + } + glStandalone = Integer.MAX_VALUE>glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight; + if(DEBUG) { + System.err.println("JOGLNewtApplet1Run Configuration:"); + System.err.println("glStandalone: "+glStandalone); + if(glStandalone) { + System.err.println("pos-size: "+glXd+"/"+glYd+" "+glWidth+"x"+glHeight); + } + System.err.println("glProfileName: "+glProfileName); + System.err.println("glOpaque: "+glOpaque); + System.err.println("glAlphaBits: "+glAlphaBits); + System.err.println("glNumMultisampleBuffer: "+glNumMultisampleBuffer); + System.err.println("glUndecorated: "+glUndecorated); + System.err.println("glAlwaysOnTop: "+glAlwaysOnTop); + } + final GLCapabilities caps = new GLCapabilities(GLProfile.get(glProfileName)); + caps.setAlphaBits(glAlphaBits); + if(0glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight; + if(DEBUG) { + System.err.println("JOGLNewtApplet1Run Configuration:"); + System.err.println("glEventListenerClazzName: "+glEventListenerClazzName); + System.err.println("glSwapInterval: "+glSwapInterval); + System.err.println("glDebug: "+glDebug); + System.err.println("glTrace: "+glTrace); + System.err.println("glNoDefaultKeyListener: "+glNoDefaultKeyListener); + System.err.println("glCloseable: "+glCloseable); + } + + base = new JOGLNewtAppletBase(glEventListenerClazzName, + glSwapInterval, + glNoDefaultKeyListener, + glCloseable, + glDebug, + glTrace); + + try { + glWindow.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); + glWindow.setDefaultCloseOperation(glCloseable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE); + base.init(glWindow); + } catch (Throwable t) { + throw new RuntimeException(t); + } + if(DEBUG) { + System.err.println("JOGLNewtApplet1Run.init() END - "+currentThreadName()); + } + } + + private static String currentThreadName() { return "["+Thread.currentThread().getName()+"]"; } + + @Override + public void start() { + if(DEBUG) { + System.err.println("JOGLNewtApplet1Run.start() START (isVisible "+glWindow.isVisible()+") - "+currentThreadName()); + } + if( glStandalone ) { + glWindow.setSize(glWidth, glHeight); + glWindow.setPosition(glXd, glYd); + glWindow.setVisible(true); + glWindow.requestFocus(); + } + if(DEBUG) { + System.err.println("JOGLNewtApplet1Run start:"); + System.err.println("GLWindow Pos: "+glWindow.getX()+"/"+glWindow.getY()+" rel, "+glWindow.getLocationOnScreen(null)+" screen"); + System.err.println("GLWindow: "+glWindow); + } + base.start(); + if(DEBUG) { + System.err.println("JOGLNewtApplet1Run.start() END - "+currentThreadName()); + } + } + + @Override + public void stop() { + if(DEBUG) { + System.err.println("JOGLNewtApplet1Run.stop() START - "+currentThreadName()); + } + base.stop(); + if(DEBUG) { + System.err.println("JOGLNewtApplet1Run.stop() END - "+currentThreadName()); + } + } + + @Override + public void destroy() { + if(DEBUG) { + System.err.println("JOGLNewtApplet1Run.destroy() START - "+currentThreadName()); + } + glWindow.setVisible(false); // hide 1st + base.destroy(); // destroy glWindow unrecoverable + base=null; + glWindow=null; + if(DEBUG) { + System.err.println("JOGLNewtApplet1Run.destroy() END - "+currentThreadName()); + } + } + + @Override + public String getAppletInfo() { + return null; + } + + @Override + public Locale getLocale() { + return null; + } + + @Override + public String[][] getParameterInfo() { + return null; + } + +} + diff --git a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtAppletBase.java new file mode 100644 index 000000000..bbe6b8527 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtAppletBase.java @@ -0,0 +1,390 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions 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. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.newt.util.applet; + +import java.lang.reflect.Field; +import java.security.AccessController; +import java.security.PrivilegedAction; + +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; +import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.opengl.FPSCounter; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLPipelineFactory; + +import jogamp.newt.Debug; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.newt.Display; +import com.jogamp.newt.Window; +import com.jogamp.newt.Display.PointerIcon; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.KeyListener; +import com.jogamp.newt.event.MouseListener; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowListener; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.util.Animator; + + +/** Shows how to deploy an applet using JOGL. This demo must be + referenced from a web page via an <applet> tag. */ + +public class JOGLNewtAppletBase implements KeyListener, GLEventListener { + public static final boolean DEBUG = Debug.debug("Applet"); + + String glEventListenerClazzName; + int glSwapInterval; + boolean noDefaultKeyListener; + boolean glClosable; + boolean glDebug; + boolean glTrace; + PointerIcon pointerIconTest = null; + + GLEventListener glEventListener = null; + GLWindow glWindow = null; + Animator glAnimator=null; + boolean isValid = false; + NativeWindow parentWin; + + public JOGLNewtAppletBase(String glEventListenerClazzName, + int glSwapInterval, + boolean noDefaultKeyListener, + boolean glClosable, + boolean glDebug, + boolean glTrace) { + + this.glEventListenerClazzName=glEventListenerClazzName; + this.glSwapInterval=glSwapInterval; + this.noDefaultKeyListener = noDefaultKeyListener; + this.glClosable = glClosable; + this.glDebug = glDebug; + this.glTrace = glTrace; + } + + public GLEventListener getGLEventListener() { return glEventListener; } + public GLWindow getGLWindow() { return glWindow; } + public Animator getGLAnimator() { return glAnimator; } + public boolean isValid() { return isValid; } + + public static boolean str2Bool(String str, boolean def) { + if(null==str) return def; + try { + return Boolean.valueOf(str).booleanValue(); + } catch (Exception ex) { ex.printStackTrace(); } + return def; + } + + public static int str2Int(String str, int def) { + if(null==str) return def; + try { + return Integer.parseInt(str); + } catch (Exception ex) { ex.printStackTrace(); } + return def; + } + + public static GLEventListener createInstance(final String clazzName) { + Object instance = null; + + try { + final Class clazz = AccessController.doPrivileged(new PrivilegedAction>() { + @Override + public Class run() { + final ClassLoader cl = Thread.currentThread().getContextClassLoader(); + Class clazz = null; + try { + clazz = Class.forName(clazzName, false, cl); + } catch (Throwable t) { + t.printStackTrace(); + } + return clazz; + } + }); + instance = clazz.newInstance(); + } catch (Throwable t) { + t.printStackTrace(); + throw new RuntimeException("Error while instantiating demo: "+clazzName); + } + if( null == instance ) { + throw new RuntimeException("Null GLEventListener: "+clazzName); + } + if( !(instance instanceof GLEventListener) ) { + throw new RuntimeException("Not a GLEventListener: "+clazzName); + } + return (GLEventListener) instance; + } + + public static boolean setField(Object instance, String fieldName, Object value) { + try { + Field f = instance.getClass().getField(fieldName); + if(f.getType().isInstance(value)) { + f.set(instance, value); + return true; + } else { + System.out.println(instance.getClass()+" '"+fieldName+"' field not assignable with "+value.getClass()+", it's a: "+f.getType()); + } + } catch (NoSuchFieldException nsfe) { + System.out.println(instance.getClass()+" has no '"+fieldName+"' field"); + } catch (Throwable t) { + t.printStackTrace(); + } + return false; + } + + public void init(GLWindow glWindow) { + init(Thread.currentThread().getThreadGroup(), glWindow); + } + + public void init(ThreadGroup tg, final GLWindow glWindow) { + isValid = false; + this.glWindow = glWindow; + glEventListener = createInstance(glEventListenerClazzName); + if(null == glEventListener) { + return; + } + + try { + if(!setField(glEventListener, "window", glWindow)) { + setField(glEventListener, "glWindow", glWindow); + } + + glWindow.addGLEventListener(this); + glWindow.addGLEventListener(glEventListener); + + if(glEventListener instanceof WindowListener) { + glWindow.addWindowListener((WindowListener)glEventListener); + } + + if(glEventListener instanceof MouseListener) { + glWindow.addMouseListener((MouseListener)glEventListener); + } + + if(glEventListener instanceof KeyListener) { + glWindow.addKeyListener((KeyListener)glEventListener); + } + + if(!noDefaultKeyListener) { + glWindow.addKeyListener(this); + } + + glWindow.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); + + // glAnimator = new FPSAnimator(canvas, 60); + glAnimator = new Animator(); + glAnimator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); // No AWT thread involved! + glAnimator.setThreadGroup(tg); + glAnimator.add(glWindow); + glAnimator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, null); + + } catch (Throwable t) { + throw new RuntimeException(t); + } + isValid = true; + } + + private final WindowListener reparentHomeListener = new WindowAdapter() { + // Closing action: back to parent! + @Override + public void windowDestroyNotify(WindowEvent e) { + if( isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() && + null == glWindow.getParent() && null != parentWin && 0 != parentWin.getWindowHandle() ) + { + // we may be called directly by the native EDT + new Thread(new Runnable() { + @Override + public void run() { + if( glWindow.isNativeValid() && null != parentWin && 0 != parentWin.getWindowHandle() ) { + glWindow.reparentWindow(parentWin, -1, -1, Window.REPARENT_HINT_BECOMES_VISIBLE); + } + } + }).start(); + } + } }; + + public void start() { + if(isValid) { + glWindow.setVisible(true); + glWindow.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); + if( null == pointerIconTest ) { + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/cross-grey-alpha-16x16.png" } ); + final Display disp = glWindow.getScreen().getDisplay(); + try { + pointerIconTest = disp.createPointerIcon(res, 8, 8); + } catch (Exception e) { + e.printStackTrace(); + } + } + glAnimator.start(); + parentWin = glWindow.getParent(); + glWindow.addWindowListener(reparentHomeListener); + } + } + + public void stop() { + if(null!=glAnimator) { + glWindow.removeWindowListener(reparentHomeListener); + glAnimator.stop(); + glWindow.setVisible(false); + } + } + + public void destroy() { + isValid = false; + if(null!=glAnimator) { + glAnimator.stop(); + glAnimator.remove(glWindow); + glAnimator=null; + } + if(null!=glWindow) { + glWindow.destroy(); + glWindow=null; + } + } + + // *********************************************************************************** + // *********************************************************************************** + // *********************************************************************************** + + @Override + public void init(GLAutoDrawable drawable) { + GL _gl = drawable.getGL(); + + if(glDebug) { + try { + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, _gl, null) ); + } catch (Exception e) {e.printStackTrace();} + } + + if(glTrace) { + try { + // Trace .. + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, _gl, new Object[] { System.err } ) ); + } catch (Exception e) {e.printStackTrace();} + } + + if(glSwapInterval>=0) { + _gl.setSwapInterval(glSwapInterval); + } + } + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + } + @Override + public void display(GLAutoDrawable drawable) { + } + @Override + public void dispose(GLAutoDrawable drawable) { + } + + // *********************************************************************************** + // *********************************************************************************** + // *********************************************************************************** + + @Override + public void keyPressed(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } + if(e.getKeyChar()=='d') { + new Thread() { + public void run() { + glWindow.setUndecorated(!glWindow.isUndecorated()); + } }.start(); + } if(e.getKeyChar()=='f') { + new Thread() { + public void run() { + glWindow.setFullscreen(!glWindow.isFullscreen()); + } }.start(); + } else if(e.getKeyChar()=='a') { + new Thread() { + public void run() { + glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop()); + } }.start(); + } else if(e.getKeyChar()=='r' && null!=parentWin) { + new Thread() { + public void run() { + if(null == glWindow.getParent()) { + glWindow.reparentWindow(parentWin, -1, -1, 0 /* hints */); + } else { + final InsetsImmutable insets = glWindow.getInsets(); + final int x, y; + if ( 0 >= insets.getTopHeight() ) { + // fail safe .. + x = 32; + y = 32; + } else { + x = insets.getLeftWidth(); + y = insets.getTopHeight(); + } + glWindow.reparentWindow(null, x, y, 0 /* hints */); + glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE ); + } + } }.start(); + } else if(e.getKeyChar()=='c') { + new Thread() { + public void run() { + System.err.println("[set pointer-icon pre]"); + final PointerIcon currentPI = glWindow.getPointerIcon(); + glWindow.setPointerIcon( currentPI == pointerIconTest ? null : pointerIconTest); + System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); + } }.start(); + } else if(e.getKeyChar()=='i') { + new Thread() { + public void run() { + System.err.println("[set mouse visible pre]: "+glWindow.isPointerVisible()); + glWindow.setPointerVisible(!glWindow.isPointerVisible()); + System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible()); + } }.start(); + } else if(e.getKeyChar()=='j') { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined()); + glWindow.confinePointer(!glWindow.isPointerConfined()); + System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } else if(e.getKeyChar()=='w') { + new Thread() { + public void run() { + System.err.println("[set mouse pos pre]"); + glWindow.warpPointer(glWindow.getWidth()/2, glWindow.getHeight()/2); + System.err.println("[set mouse pos post]"); + } }.start(); + } + } + + @Override + public void keyReleased(KeyEvent e) { + } +} + diff --git a/src/newt/classes/com/jogamp/newt/util/applet/VersionApplet3.java b/src/newt/classes/com/jogamp/newt/util/applet/VersionApplet3.java new file mode 100644 index 000000000..90c8c3572 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/util/applet/VersionApplet3.java @@ -0,0 +1,212 @@ +package com.jogamp.newt.util.applet; + +import com.jogamp.plugin.applet.Applet3; +import com.jogamp.plugin.applet.Applet3Context; +import com.jogamp.plugin.ui.NativeWindowDownstream; +import com.jogamp.plugin.ui.NativeWindowUpstream; + +import java.util.List; +import java.util.Locale; + +import javax.media.opengl.GLProfile; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; + +import com.jogamp.common.GlueGenVersion; +import com.jogamp.common.util.VersionUtil; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.JoglVersion; + +public class VersionApplet3 implements Applet3 { + + public static void main(String[] args) { + VersionApplet3 va = new VersionApplet3(); + + final NativeWindowDownstream nwc = va.createNativeWindow(null, new NativeWindowUpstream() { + @Override + public long getWindowHandle() { + return 0; + } + @Override + public int getWidth() { + return 64; + } + @Override + public int getHeight() { + return 64; + } + @Override + public String getDisplayConnection() { + return null; // default + } + @Override + public int getScreenIndex() { + return 0; // default + } + @Override + public void notifySurfaceUpdated(NativeWindowDownstream swappedWin) { + // NOP + } + + }); + va.init(null); + va.start(); + va.stop(); + va.destroy(); + nwc.destroy(); + } + + GLWindow canvas; + + @Override + public NativeWindowDownstream createNativeWindow(final Applet3Context ctx, final NativeWindowUpstream parentWin) { + final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + final Window w = NewtFactory.createWindow(parentWin.getDisplayConnection(), parentWin.getScreenIndex(), parentWin.getWindowHandle(), caps); + canvas = GLWindow.create(w); + canvas.setSize(parentWin.getWidth(), parentWin.getHeight()); + + return new NativeWindowDownstream() { + @Override + public void setVisible(boolean v) { + if( null != canvas ) { + canvas.setVisible(v); + } + } + + @Override + public void setSize(int width, int height) { + if( null != canvas ) { + canvas.setSize(width, height); + } + } + + @Override + public void requestFocus() { + if( null != canvas ) { + canvas.requestFocus(); + } + } + + @Override + public void destroy() { + if( null != canvas ) { + canvas.destroy(); + } + } + + @Override + public NativeWindowUpstream getParent() { + return parentWin; + } + + @Override + public long getWindowHandle() { + if( null != canvas ) { + return canvas.getWindowHandle(); + } else { + return 0; + } + } + + @Override + public void display() { + if( null != canvas ) { + canvas.display(); + } + } + }; + } + + @Override + public void init(Applet3Context ctx) { + System.err.println("VersionApplet: init() - begin"); + canvas.addGLEventListener(new GLInfo()); + System.err.println("VersionApplet: init() - end"); + } + + @Override + public void start() { + System.err.println("VersionApplet: start() - begin"); + + String s; + + s = VersionUtil.getPlatformInfo().toString(); + System.err.println(s); + + s = GlueGenVersion.getInstance().toString(); + System.err.println(s); + + /* + s = NativeWindowVersion.getInstance().toString(); + System.err.println(s); + */ + + s = JoglVersion.getInstance().toString(); + System.err.println(s); + + GLDrawableFactory factory = GLDrawableFactory.getFactory(canvas.getGLProfile()); + List availCaps = factory.getAvailableCapabilities(null); + for(int i=0; i Date: Fri, 31 Jan 2014 10:59:47 +0100 Subject: NewtFactory: Cleanup / createWindow(..) w/ parentWindow variant shall fall back to top-level ctor if parentWindow is null --- src/newt/classes/com/jogamp/newt/NewtFactory.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index fc3716a52..9685200eb 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -244,7 +244,7 @@ public class NewtFactory { *

                      */ public static Window createWindow(Screen screen, CapabilitiesImmutable caps) { - return createWindowImpl(screen, caps); + return WindowImpl.create(null, 0, screen, caps); } /** @@ -271,6 +271,9 @@ public class NewtFactory { */ public static Window createWindow(NativeWindow parentWindow, CapabilitiesImmutable caps) { final String type = NativeWindowFactory.getNativeWindowType(true); + if( null == parentWindow ) { + return createWindowImpl(type, caps); + } Screen screen = null; Window newtParentWindow = null; @@ -291,7 +294,7 @@ public class NewtFactory { screen = NewtFactory.createScreen(display, 0); // screen 0 } } - final Window win = createWindowImpl(parentWindow, screen, caps); + final Window win = WindowImpl.create(parentWindow, 0, screen, caps); win.setSize(parentWindow.getWidth(), parentWindow.getHeight()); if ( null != newtParentWindow ) { @@ -301,15 +304,7 @@ public class NewtFactory { return win; } - protected static Window createWindowImpl(NativeWindow parentNativeWindow, Screen screen, CapabilitiesImmutable caps) { - return WindowImpl.create(parentNativeWindow, 0, screen, caps); - } - - protected static Window createWindowImpl(Screen screen, CapabilitiesImmutable caps) { - return WindowImpl.create(null, 0, screen, caps); - } - - protected static Window createWindowImpl(String type, CapabilitiesImmutable caps) { + private static Window createWindowImpl(String type, CapabilitiesImmutable caps) { Display display = NewtFactory.createDisplay(type, null, true); // local display Screen screen = NewtFactory.createScreen(display, 0); // screen 0 return WindowImpl.create(null, 0, screen, caps); -- cgit v1.2.3 From bd79528f54cea5b20b1c22e7662c3e064be3f079 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 31 Jan 2014 11:00:35 +0100 Subject: Adapt to new plugin3 / Use browser window's location on screen for top-level window. --- .../newt/util/applet/JOGLNewtApplet3Run.java | 64 ++++++++++++++-------- .../jogamp/newt/util/applet/VersionApplet3.java | 16 +++++- 2 files changed, 56 insertions(+), 24 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java index 465ee4df5..b8b69f631 100644 --- a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java +++ b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java @@ -39,11 +39,12 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; +import javax.media.nativewindow.util.PointImmutable; import javax.media.opengl.FPSCounter; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; -import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSizePos; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Window; import com.jogamp.newt.opengl.GLWindow; @@ -102,6 +103,9 @@ public class JOGLNewtApplet3Run implements Applet3 { int glXd=Integer.MAX_VALUE, glYd=Integer.MAX_VALUE, glWidth=Integer.MAX_VALUE, glHeight=Integer.MAX_VALUE; Applet3Context ctx; boolean glStandalone = false; + UpstreamSurfaceHookMutableSizePos upstreamSizePosHook; + PointImmutable upstreamLocOnScreen; + NativeWindow browserWin; final String getParameter(String name) { return ctx.getParameter(name); @@ -132,38 +136,43 @@ public class JOGLNewtApplet3Run implements Applet3 { e.printStackTrace(); } glStandalone = Integer.MAX_VALUE>glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight; + final GLCapabilities caps = new GLCapabilities(GLProfile.get(glProfileName)); + caps.setAlphaBits(glAlphaBits); + if(0glXd && Integer.MAX_VALUE>glYd && Integer.MAX_VALUE>glWidth && Integer.MAX_VALUE>glHeight; if(DEBUG) { System.err.println("JOGLNewtApplet1Run Configuration:"); System.err.println("glEventListenerClazzName: "+glEventListenerClazzName); @@ -283,7 +299,7 @@ public class JOGLNewtApplet3Run implements Applet3 { } if( glStandalone ) { glWindow.setSize(glWidth, glHeight); - glWindow.setPosition(glXd, glYd); + glWindow.setPosition(upstreamLocOnScreen.getX()+glXd, upstreamLocOnScreen.getY()+glYd); glWindow.setVisible(true); glWindow.requestFocus(); } @@ -318,6 +334,8 @@ public class JOGLNewtApplet3Run implements Applet3 { base.destroy(); // destroy glWindow unrecoverable base=null; glWindow=null; + browserWin.destroy(); // make sure the open display connection gets closed! + browserWin = null; if(DEBUG) { System.err.println("JOGLNewtApplet1Run.destroy() END - "+currentThreadName()); } diff --git a/src/newt/classes/com/jogamp/newt/util/applet/VersionApplet3.java b/src/newt/classes/com/jogamp/newt/util/applet/VersionApplet3.java index 90c8c3572..db0e8fc45 100644 --- a/src/newt/classes/com/jogamp/newt/util/applet/VersionApplet3.java +++ b/src/newt/classes/com/jogamp/newt/util/applet/VersionApplet3.java @@ -53,7 +53,14 @@ public class VersionApplet3 implements Applet3 { public void notifySurfaceUpdated(NativeWindowDownstream swappedWin) { // NOP } - + @Override + public int getX() { + return 0; + } + @Override + public int getY() { + return 0; + } }); va.init(null); va.start(); @@ -120,6 +127,13 @@ public class VersionApplet3 implements Applet3 { canvas.display(); } } + + @Override + public void notifyPositionChanged(NativeWindowUpstream nw) { + if( null != canvas ) { + canvas.setPosition(nw.getX(), nw.getY()); + } + } }; } -- cgit v1.2.3 From 2aa8d4bbaf93c6bdf9188d9a88b5a28af43b112e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 31 Jan 2014 15:12:01 +0100 Subject: NEWT WindowImpl: Don't waitForPosition(..) if child window - issues w/ different toolkits! With Applet3 plugin (firefox - using GTK), our child window seems to receives the absolute position, or 'arbitrary' values (?). Will need to figure out how to properly determine these cases. In the meantime, simply turn off waitForPosition(..) for child windows, which shall not harm NEWT. Impacts following actions as child window: - createNativeWindow - reparent - fullscreen --- src/newt/classes/jogamp/newt/WindowImpl.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 260ae4dd8..1e2291c8f 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -414,8 +414,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow); } + final boolean hasParent = null != parentWindow || 0 != this.parentWindowHandle; + // child window: position defaults to 0/0, no auto position, no negative position - if( null != parentWindow && ( autoPosition || 0>getX() || 0>getY() ) ) { + if( hasParent && ( autoPosition || 0>getX() || 0>getY() ) ) { definePosition(0, 0); } boolean postParentlockFocus = false; @@ -453,7 +455,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullScreenAction.init(true); fullScreenAction.run(); } - } else { + } else if ( !hasParent ) { // Wait until position is reached within tolerances, either auto-position or custom position. waitForPosition(usePosition, wX, wY, Window.TIMEOUT_NATIVEWINDOW); } @@ -1445,8 +1447,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); } if(ok) { - // Position mismatch shall not lead to reparent failure - WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); + if( 0 == parentWindowHandle ) { + // Position mismatch shall not lead to reparent failure + WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); + } requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */); display.dispatchMessagesNative(); // status up2date @@ -2087,9 +2091,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(isNativeValid()) { // this.x/this.y will be set by sizeChanged, triggered by windowing event system reconfigureWindowImpl(x, y, getWidth(), getHeight(), getReconfigureFlags(0, isVisible())); - - // Wait until custom position is reached within tolerances - waitForPosition(true, x, y, Window.TIMEOUT_NATIVEWINDOW); + if( null == parentWindow ) { + // Wait until custom position is reached within tolerances + waitForPosition(true, x, y, Window.TIMEOUT_NATIVEWINDOW); + } } else { definePosition(x, y); // set pos for createNative(..) } @@ -2261,7 +2266,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(ok) { ok = WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); } - if(ok && !_fullscreen) { + if(ok && !_fullscreen && null == parentWindow) { // Position mismatch shall not lead to fullscreen failure WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); } -- cgit v1.2.3 From c7ef2bf610ad3310aa9785820489f980c223cdb0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 31 Jan 2014 15:12:21 +0100 Subject: JOGLNewtApplet3Run: Don't set position if normal child window. --- src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/newt/classes') diff --git a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java index b8b69f631..8123126ee 100644 --- a/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java +++ b/src/newt/classes/com/jogamp/newt/util/applet/JOGLNewtApplet3Run.java @@ -172,7 +172,6 @@ public class JOGLNewtApplet3Run implements Applet3 { glWindow.setUndecorated(glUndecorated); glWindow.setAlwaysOnTop(glAlwaysOnTop); glWindow.setSize(browserWin.getWidth(), browserWin.getHeight()); - glWindow.setPosition(browserWin.getX(), browserWin.getY()); return new NativeWindowDownstream() { @Override -- cgit v1.2.3 From c5964bf2e3ebd6e05a7d551b033355c21ca9eea9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 12 Feb 2014 02:48:08 +0100 Subject: Bug 972 - Reduce ClassLoader Lookup, i.e. Class.forName(..): GLProfile, GLContextImpl, DisplayImpl GLProfile, GLContextImpl: - ReflectionUtil.DEBUG_STATS_FORNAME: Dump forName stats if set - Cache GL*Impl and GL*ProcAddressTable Constructor for GLContextImpl's createInstance(..) - Remove off-thread early classloading thread which only adds complications DisplayImpl: - Remove one redundant availability test --- make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64-dbg.bat | 5 +- make/scripts/tests.sh | 10 +- src/jogl/classes/javax/media/opengl/GLProfile.java | 141 ++++++++++++++++----- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 12 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 3 +- 6 files changed, 129 insertions(+), 46 deletions(-) (limited to 'src/newt/classes') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 5642cca6f..f4db03a15 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -38,7 +38,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 @@ -50,7 +50,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedConte REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index ce2df922c..b3ebc03c2 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -55,7 +55,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" "-Djogl.debug.TileRenderer.PNG" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" REM set D_ARGS="-Djogl.gljpanel.noverticalflip" -set D_ARGS="-Dnewt.debug=all" +REM set D_ARGS="-Dnewt.debug=all" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Window.KeyEvent" "-Dnewt.debug.EDT" @@ -74,6 +74,9 @@ REM set D_ARGS="-Dnewt.debug.Screen" REM set D_ARGS="-Dnewt.debug.Screen" "-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" +REM set D_ARGS="-Djogamp.debug.ReflectionUtil" "-Djogamp.debug.ReflectionUtil.forNameStats" +REM set D_ARGS="-Djogamp.debug.ReflectionUtil.forNameStats" + REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=false" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 85eb14252..cd9a2bb2e 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -96,6 +96,9 @@ function jrun() { #D_ARGS="-Dnativewindow.debug=all -Dnewt.debug.Window" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" + #D_ARGS="-Djogamp.debug.ReflectionUtil -Djogamp.debug.ReflectionUtil.forNameStats" + #D_ARGS="-Djogamp.debug.ReflectionUtil.forNameStats" + #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_MULTITHREADING_BUG" #D_ARGS="-Djogl.disable.opengles" @@ -242,7 +245,7 @@ function jrun() { #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" - D_ARGS="-Djogl.debug.GLMediaPlayer" + #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" @@ -355,7 +358,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # performance tests @@ -389,7 +392,8 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestBinary16NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index a43ddee07..80f46955d 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -39,7 +39,6 @@ package javax.media.opengl; import jogamp.nativewindow.NWJNILibLoader; import jogamp.opengl.Debug; -import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.DesktopGLDynamicLookupHelper; @@ -51,6 +50,7 @@ import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.cache.TempJarCache; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveThreadGroupLock; +import com.jogamp.gluegen.runtime.FunctionAddressResolver; import com.jogamp.nativewindow.NativeWindowVersion; import com.jogamp.opengl.JoglVersion; @@ -58,6 +58,7 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.fixedfunc.GLPointerFunc; +import java.lang.reflect.Constructor; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; @@ -110,7 +111,7 @@ public class GLProfile { final boolean justInitialized; initLock.lock(); try { - if(!initialized) { // volatile: ok + if(!initialized) { initialized = true; justInitialized = true; if(DEBUG) { @@ -118,6 +119,10 @@ public class GLProfile { Thread.dumpStack(); } + if(ReflectionUtil.DEBUG_STATS_FORNAME) { + ReflectionUtil.resetForNameCount(); + } + // run the whole static initialization privileged to speed up, // since this skips checking further access AccessController.doPrivileged(new PrivilegedAction() { @@ -125,24 +130,6 @@ public class GLProfile { public Object run() { Platform.initSingleton(); - // Performance hack to trigger classloading of the GL classes impl, which makes up to 12%, 800ms down to 700ms - new Thread(new Runnable() { - @Override - public void run() { - final ClassLoader cl = GLProfile.class.getClassLoader(); - try { - ReflectionUtil.createInstance(getGLImplBaseClassName(GL4bc)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); - } catch (Throwable t) {} - try { - ReflectionUtil.createInstance(getGLImplBaseClassName(GLES3)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); - } catch (Throwable t) {} - try { - ReflectionUtil.createInstance(getGLImplBaseClassName(GLES1)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); - } catch (Throwable t) {} - } - }, "GLProfile-GL_Bootstrapping").start(); - - if(TempJarCache.isInitialized()) { final ClassLoader cl = GLProfile.class.getClassLoader(); final String newtFactoryClassName = "com.jogamp.newt.NewtFactory"; @@ -156,6 +143,11 @@ public class GLProfile { return null; } }); + if( ReflectionUtil.DEBUG_STATS_FORNAME ) { + if( justInitialized ) { + System.err.println(ReflectionUtil.getForNameStats(null).toString()); + } + } } else { justInitialized = false; } @@ -191,7 +183,7 @@ public class GLProfile { public static void shutdown() { initLock.lock(); try { - if(initialized) { // volatile: ok + if(initialized) { initialized = false; if(DEBUG) { System.err.println("GLProfile.shutdown() - thread "+Thread.currentThread().getName()); @@ -1045,7 +1037,6 @@ public class GLProfile { public final String getGLImplBaseClassName() { return getGLImplBaseClassName(getImplName()); } - private static final String getGLImplBaseClassName(String profileImpl) { if( GLES2 == profileImpl || GLES3 == profileImpl ) { return "jogamp.opengl.es3.GLES3"; @@ -1062,6 +1053,25 @@ public class GLProfile { } } + public final Constructor getGLCtor(boolean glObject) { + return getGLCtor(getImplName(), glObject); + } + private static final Constructor getGLCtor(String profileImpl, boolean glObject) { + if( GLES2 == profileImpl || GLES3 == profileImpl ) { + return glObject ? ctorGLES3Impl : ctorGLES3ProcAddr; + } else if( GLES1 == profileImpl ) { + return glObject ? ctorGLES1Impl : ctorGLES1ProcAddr; + } else if ( GL4bc == profileImpl || + GL4 == profileImpl || + GL3bc == profileImpl || + GL3 == profileImpl || + GL2 == profileImpl ) { + return glObject ? ctorGL234Impl : ctorGL234ProcAddr; + } else { + throw new GLException("unsupported profile \"" + profileImpl + "\""); + } + } + /** * @param o GLProfile object to compare with * @return true if given Object is a GLProfile and @@ -1530,13 +1540,87 @@ public class GLProfile { private static /*final*/ boolean hasEGLFactory; private static /*final*/ boolean hasGLES3Impl; private static /*final*/ boolean hasGLES1Impl; + private static /*final*/ Constructor ctorGL234Impl; + private static /*final*/ Constructor ctorGLES3Impl; + private static /*final*/ Constructor ctorGLES1Impl; + private static /*final*/ Constructor ctorGL234ProcAddr; + private static /*final*/ Constructor ctorGLES3ProcAddr; + private static /*final*/ Constructor ctorGLES1ProcAddr; private static /*final*/ GLDrawableFactoryImpl eglFactory = null; private static /*final*/ GLDrawableFactoryImpl desktopFactory = null; private static /*final*/ AbstractGraphicsDevice defaultDevice = null; - private static volatile boolean initialized = false; - private static RecursiveThreadGroupLock initLock = LockFactory.createRecursiveThreadGroupLock(); + private static boolean initialized = false; + private static final RecursiveThreadGroupLock initLock = LockFactory.createRecursiveThreadGroupLock(); + + private static final Class[] ctorGLArgs = new Class[] { GLProfile.class, jogamp.opengl.GLContextImpl.class }; + private static final Class[] ctorProcArgs = new Class[] { FunctionAddressResolver.class }; + private static final String GL4bcImplClassName = "jogamp.opengl.gl4.GL4bcImpl"; + private static final String GL4bcProcClassName = "jogamp.opengl.gl4.GL4bcProcAddressTable"; + private static final String GLES1ImplClassName = "jogamp.opengl.es1.GLES1Impl"; + private static final String GLES1ProcClassName = "jogamp.opengl.es1.GLES1ProcAddressTable"; + private static final String GLES3ImplClassName = "jogamp.opengl.es3.GLES3Impl"; + private static final String GLES3ProcClassName = "jogamp.opengl.es3.GLES3ProcAddressTable"; + + private static final Constructor getCtor(final String clazzName, final boolean glObject, final ClassLoader cl) { + try { + return ReflectionUtil.getConstructor(clazzName, glObject ? ctorGLArgs : ctorProcArgs, cl); + } catch (Throwable t) { + if( DEBUG ) { + System.err.println("Catched: "+t.getMessage()); + t.printStackTrace(); + } + return null; + } + } + + private static final void initGLCtorImpl() { + final ClassLoader classloader = GLProfile.class.getClassLoader(); + + // depends on hasDesktopGLFactory + { + final Constructor ctorGL = getCtor(GL4bcImplClassName, true, classloader); + final Constructor ctorProc = null != ctorGL ? getCtor(GL4bcProcClassName, false, classloader) : null; + if( null != ctorProc ) { + hasGL234Impl = true; + ctorGL234Impl = ctorGL; + ctorGL234ProcAddr = ctorProc; + } else { + hasGL234Impl = false; + ctorGL234Impl = null; + ctorGL234ProcAddr = null; + } + } + + // depends on hasEGLFactory + { + final Constructor ctorGL = getCtor(GLES1ImplClassName, true, classloader); + final Constructor ctorProc = null != ctorGL ? getCtor(GLES1ProcClassName, false, classloader) : null; + if( null != ctorProc ) { + hasGLES1Impl = true; + ctorGLES1Impl = ctorGL; + ctorGLES1ProcAddr = ctorProc; + } else { + hasGLES1Impl = false; + ctorGLES1Impl = null; + ctorGLES1ProcAddr = null; + } + } + { + final Constructor ctorGL = getCtor(GLES3ImplClassName, true, classloader); + final Constructor ctorProc = null != ctorGL ? getCtor(GLES3ProcClassName, false, classloader) : null; + if( null != ctorProc ) { + hasGLES3Impl = true; + ctorGLES3Impl = ctorGL; + ctorGLES3ProcAddr = ctorProc; + } else { + hasGLES3Impl = false; + ctorGLES3Impl = null; + ctorGLES3ProcAddr = null; + } + } + } /** * Tries the profiles implementation and native libraries. @@ -1551,17 +1635,12 @@ public class GLProfile { System.err.println(JoglVersion.getInstance()); } - ClassLoader classloader = GLProfile.class.getClassLoader(); + final ClassLoader classloader = GLProfile.class.getClassLoader(); isAWTAvailable = NativeWindowFactory.isAWTAvailable() && ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas", classloader) ; // JOGL - // depends on hasDesktopGLFactory - hasGL234Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.gl4.GL4bcImpl", classloader); - - // depends on hasEGLFactory - hasGLES1Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.es1.GLES1Impl", classloader); - hasGLES3Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.es3.GLES3Impl", classloader); + initGLCtorImpl(); // // Iteration of desktop GL availability detection diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 431bba6de..b133fc017 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -54,7 +54,6 @@ import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.VersionNumber; import com.jogamp.common.util.VersionNumberString; import com.jogamp.common.util.locks.RecursiveLock; -import com.jogamp.gluegen.runtime.FunctionAddressResolver; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLNameResolver; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; @@ -1127,17 +1126,17 @@ public abstract class GLContextImpl extends GLContext { // Helpers for various context implementations // - private Object createInstance(GLProfile glp, String suffix, Class[] cstrArgTypes, Object[] cstrArgs) { - return ReflectionUtil.createInstance(glp.getGLImplBaseClassName()+suffix, cstrArgTypes, cstrArgs, getClass().getClassLoader()); + private Object createInstance(GLProfile glp, boolean glObject, Object[] cstrArgs) { + return ReflectionUtil.createInstance(glp.getGLCtor(glObject), cstrArgs); } private boolean verifyInstance(GLProfile glp, String suffix, Object instance) { - return ReflectionUtil.instanceOf(instance, glp.getGLImplBaseClassName()+suffix); + return ReflectionUtil.instanceOf(instance, glp.getGLImplBaseClassName()+suffix); } /** Create the GL for this context. */ protected GL createGL(GLProfile glp) { - final GL gl = (GL) createInstance(glp, "Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { glp, this } ); + final GL gl = (GL) createInstance(glp, true, new Object[] { glp, this } ); /* FIXME: refactor dependence on Java 2D / JOGL bridge if (tracker != null) { @@ -1585,8 +1584,7 @@ public abstract class GLContextImpl extends GLContext { System.err.println(getThreadName() + ": GLContext GL ProcAddressTable reusing key("+contextFQN+") -> "+toHexString(table.hashCode())); } } else { - glProcAddressTable = (ProcAddressTable) createInstance(gl.getGLProfile(), "ProcAddressTable", - new Class[] { FunctionAddressResolver.class } , + glProcAddressTable = (ProcAddressTable) createInstance(gl.getGLProfile(), false, new Object[] { new GLProcAddressResolver() } ); resetProcAddressTable(getGLProcAddressTable()); synchronized(mappedContextTypeObjectLock) { diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index b485a4763..952e611f2 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -76,8 +76,7 @@ public abstract class DisplayImpl extends Display { }); final ClassLoader cl = DisplayImpl.class.getClassLoader(); - pngUtilAvail = ReflectionUtil.isClassAvailable("jogamp.opengl.util.pngj.PngReader", cl) && - ReflectionUtil.isClassAvailable("com.jogamp.opengl.util.PNGPixelRect", cl); + pngUtilAvail = ReflectionUtil.isClassAvailable("com.jogamp.opengl.util.PNGPixelRect", cl); } public static final boolean isPNGUtilAvailable() { return pngUtilAvail; } -- cgit v1.2.3 From 8be9d9b5bd71854f4da15294b47125a8a4975e31 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 13 Feb 2014 18:12:27 +0100 Subject: SurfaceUpdatedListener: Order methods in impl. Class; SurfaceUpdatedListener: Mark methods final, use volatile 'isEmpty' to bail out early @ surfaceUpdated. --- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 44 ++++++++++------------ .../jogamp/nativewindow/SurfaceUpdatedHelper.java | 25 +++++++----- .../classes/com/jogamp/newt/opengl/GLWindow.java | 40 ++++++++++---------- src/newt/classes/jogamp/newt/WindowImpl.java | 43 ++++++++++----------- 4 files changed, 76 insertions(+), 76 deletions(-) (limited to 'src/newt/classes') diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index a57dafc92..20ab7a2ee 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -437,30 +437,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return true; } - // - // SurfaceUpdateListener - // - - @Override - public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { - surfaceUpdatedHelper.addSurfaceUpdatedListener(l); - } - - @Override - public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { - surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); - } - - @Override - public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { - surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); - } - - @Override - public void surfaceUpdated(Object updater, NativeSurface ns, long when) { - surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); - } - // // NativeSurface // @@ -571,6 +547,26 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return false; } + @Override + public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { + surfaceUpdatedHelper.addSurfaceUpdatedListener(l); + } + + @Override + public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { + surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); + } + + @Override + public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { + surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); + } + + @Override + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { + surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); + } + @Override public long getSurfaceHandle() { return drawable; diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java index 1e83232bb..0b033955e 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java @@ -36,22 +36,23 @@ import javax.media.nativewindow.SurfaceUpdatedListener; public class SurfaceUpdatedHelper implements SurfaceUpdatedListener { private final Object surfaceUpdatedListenersLock = new Object(); private final ArrayList surfaceUpdatedListeners = new ArrayList(); + private volatile boolean isEmpty = true; // // Management Utils // - public int size() { return surfaceUpdatedListeners.size(); } - public SurfaceUpdatedListener get(int i) { return surfaceUpdatedListeners.get(i); } + public final int size() { return surfaceUpdatedListeners.size(); } + public final SurfaceUpdatedListener get(int i) { return surfaceUpdatedListeners.get(i); } // // Implementation of NativeSurface SurfaceUpdatedListener methods // - public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { + public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { addSurfaceUpdatedListener(-1, l); } - public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) + public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { if(l == null) { @@ -62,23 +63,29 @@ public class SurfaceUpdatedHelper implements SurfaceUpdatedListener { index = surfaceUpdatedListeners.size(); } surfaceUpdatedListeners.add(index, l); + isEmpty = false; } } - public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { + public final boolean removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { if (l == null) { - return; + return false; } synchronized(surfaceUpdatedListenersLock) { - surfaceUpdatedListeners.remove(l); + final boolean res = surfaceUpdatedListeners.remove(l); + isEmpty = 0 == surfaceUpdatedListeners.size(); + return res; } } @Override - public void surfaceUpdated(Object updater, NativeSurface ns, long when) { + public final void surfaceUpdated(Object updater, NativeSurface ns, long when) { + if( isEmpty ) { + return; + } synchronized(surfaceUpdatedListenersLock) { for(int i = 0; i < surfaceUpdatedListeners.size(); i++ ) { - SurfaceUpdatedListener l = surfaceUpdatedListeners.get(i); + final SurfaceUpdatedListener l = surfaceUpdatedListeners.get(i); l.surfaceUpdated(updater, ns, when); } } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index ca8ab6733..4b740927b 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -682,21 +682,6 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind window.runOnEDTIfAvail(wait, task); } - @Override - public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { - window.removeSurfaceUpdatedListener(l); - } - - @Override - public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { - window.addSurfaceUpdatedListener(l); - } - - @Override - public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { - window.addSurfaceUpdatedListener(index, l); - } - @Override public void sendWindowEvent(int eventType) { window.sendWindowEvent(eventType); @@ -850,6 +835,26 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return window.surfaceSwap(); } + @Override + public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { + window.removeSurfaceUpdatedListener(l); + } + + @Override + public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { + window.addSurfaceUpdatedListener(l); + } + + @Override + public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { + window.addSurfaceUpdatedListener(index, l); + } + + @Override + public final void surfaceUpdated(Object updater, NativeSurface ns, long when) { + window.surfaceUpdated(updater, ns, when); + } + @Override public final long getWindowHandle() { return window.getWindowHandle(); @@ -877,11 +882,6 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return window.getScreenIndex(); } - @Override - public final void surfaceUpdated(Object updater, NativeSurface ns, long when) { - window.surfaceUpdated(updater, ns, when); - } - /** * A most simple JOGL AWT test entry */ diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 1e2291c8f..7f7cb61a9 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -810,6 +810,26 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return false; } + @Override + public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { + surfaceUpdatedHelper.addSurfaceUpdatedListener(l); + } + + @Override + public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { + surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); + } + + @Override + public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { + surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); + } + + @Override + public final void surfaceUpdated(Object updater, NativeSurface ns, long when) { + surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); + } + @Override public final AbstractGraphicsConfiguration getGraphicsConfiguration() { return config.getNativeGraphicsConfiguration(); @@ -2506,29 +2526,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return true; } - // - // SurfaceUpdatedListener Support - // - @Override - public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { - surfaceUpdatedHelper.addSurfaceUpdatedListener(l); - } - - @Override - public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { - surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); - } - - @Override - public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { - surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); - } - - @Override - public final void surfaceUpdated(Object updater, NativeSurface ns, long when) { - surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); - } - // // MouseListener/Event Support // -- cgit v1.2.3